feat: transition module packages to database ABI v1
CI / verify (pull_request) Successful in 1m1s
CI / infrastructure-smoke (pull_request) Successful in 36s
CI / migration-smoke (pull_request) Successful in 1m54s
CI / image-build (pull_request) Successful in 31s
CI / deploy-smoke (same-origin) (pull_request) Successful in 52s
CI / deploy-smoke (split) (pull_request) Successful in 1m32s
CI / verify (pull_request) Successful in 1m1s
CI / infrastructure-smoke (pull_request) Successful in 36s
CI / migration-smoke (pull_request) Successful in 1m54s
CI / image-build (pull_request) Successful in 31s
CI / deploy-smoke (same-origin) (pull_request) Successful in 52s
CI / deploy-smoke (split) (pull_request) Successful in 1m32s
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { moduleDrizzle } from "@ekklesia/module-database/drizzle";
|
||||
import { defineModuleRuntime } from "@ekklesia/module-sdk";
|
||||
import { records } from "../schema/tables.js";
|
||||
|
||||
@@ -6,16 +7,17 @@ export const recordsCapability = Object.freeze({
|
||||
});
|
||||
|
||||
export default defineModuleRuntime({
|
||||
database: { abi: 1 },
|
||||
id: "example",
|
||||
version: "0.1.0",
|
||||
register({ capabilities, http }) {
|
||||
capabilities.provide("example.records", recordsCapability);
|
||||
|
||||
// The accepted module database boundary: `context.services.database` — provided only to an
|
||||
// authorized handler, never to `register` — is this module's one way to reach PostgreSQL. It
|
||||
// is a fully typed Drizzle query surface over the module's own table (`../schema/tables.js`),
|
||||
// never a raw `pg` client, a connection string, or a Drizzle instance this module built
|
||||
// itself. `example.records.read` is declared in `ekklesia.module.json`, exactly like every
|
||||
// authorized handler, never to `register` — is this module's ABI-v1 SQL executor. The adapter
|
||||
// keeps this module's own Drizzle query builder and table types entirely module-side; Core sees
|
||||
// only SQL text and bound values, never Drizzle objects, a raw `pg` client, or a connection
|
||||
// string. `example.records.read` is declared in `ekklesia.module.json`, exactly like every
|
||||
// other permission a module route enforces.
|
||||
http.route({
|
||||
method: "GET",
|
||||
@@ -28,9 +30,8 @@ export default defineModuleRuntime({
|
||||
// (`MODULE_ROUTE_MAX_BODY_BYTES_CEILING`, `@ekklesia/contracts`).
|
||||
maxBodyBytes: 0,
|
||||
async handler(_request, context) {
|
||||
const rows = await context.services.database
|
||||
.select({ id: records.id, value: records.value })
|
||||
.from(records);
|
||||
const database = moduleDrizzle(context.services.database);
|
||||
const rows = await database.select({ id: records.id, value: records.value }).from(records);
|
||||
// The accepted module configuration boundary: `context.config` is a frozen, already
|
||||
// validated snapshot of exactly this module's own declared keys (ADR 0029). It reaches
|
||||
// `register`, `start`, `stop`, and every handler as the same object. This module never
|
||||
|
||||
Reference in New Issue
Block a user