@substrat-run/model-emit 0.12.37 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,99 @@
1
+ /**
2
+ * A vertical's worker entry, rendered from its declarations (#3378, D-76).
3
+ *
4
+ * The pure half of `tools/entry-emit.mts`, as `renderClient` is the pure half of
5
+ * `tools/client-emit.mts`: from resolved declarations to a string of TypeScript, with no
6
+ * filesystem and no `process.exit`. The tool loads the vertical's model and provision module,
7
+ * refuses a declaration they do not bear out, and hands this the names.
8
+ *
9
+ * ## Why it is the same chain, not a second generator
10
+ *
11
+ * Everything it writes is a call into the API a hand-written entry already uses: the scope class
12
+ * from `defineScopeDO`, sign-in from `workerDoor`, the routes from `mountOperations` over the
13
+ * operations `spec/model.ts` declares, the `/internal/*` contract from `mountPlatformSurface`. It
14
+ * reads the same declarations the client, the surface and the migrations are emitted from, and
15
+ * it adds none of its own beyond what an entry has to choose: the owner seat's role, the join
16
+ * operation, the world a seeded preview holds. What runs is typed TypeScript, checked by the
17
+ * compiler like every other file the vertical ships.
18
+ *
19
+ * ## What it emits
20
+ *
21
+ * The shape of the scaffold template's `src/worker.ts`, which was written to fit any vertical
22
+ * whose provision module exports the same few names, plus meridian's refusal of an unknown
23
+ * `/internal/*` verb with a 501, so a platform call never reads a 200 fallback. A vertical's own
24
+ * HTTP routes, when it declares a `routes` module, are mounted between the door and the declared
25
+ * operations, and the entry then exports the `Env` and `EntryRoutes` types that module is written
26
+ * against (#3523). A vertical's own door options, when it declares a `door` module, are spread into
27
+ * `workerDoor` beneath the ones the entry writes, typed by the `EntryDoor` the entry exports (#3524).
28
+ * The list of what
29
+ * the hand-written entries do, and which of it is emitted, is `docs/architecture/generated-entry.md`.
30
+ *
31
+ * ## Deterministic
32
+ *
33
+ * The output is a pure function of the config: a fixed order, `\n` line endings, and no time,
34
+ * path or machine in it (D-76: an emitter's output is part of its contract).
35
+ */
36
+ /** Raised for anything the caller must fix. The CLI turns it into exit 2 and a remedy. */
37
+ export declare class EntryEmitError extends Error {
38
+ constructor(message: string);
39
+ }
40
+ /** The declared operations of one module: the import specifier and the exports it holds. */
41
+ export interface EntryOperationsImport {
42
+ /** Relative to the emitted file, ending in `.js` (`../spec/model.js`). */
43
+ readonly from: string;
44
+ /** Exported bags of declared operations (`todoOperations`). */
45
+ readonly names: readonly string[];
46
+ }
47
+ /** What `renderEntry` needs, already resolved against the vertical's modules. */
48
+ export interface EntryConfig {
49
+ /** The vertical's display name, for the file's header. */
50
+ readonly name: string;
51
+ /** The files the entry was emitted from, repo-relative to the vertical, for the header. */
52
+ readonly sources: readonly string[];
53
+ /** The provision module, relative to the emitted file: exports `MODULES`, `ROLES`, `permissions`. */
54
+ readonly provision: string;
55
+ /** Whether the provision module exports `envSpec` (the declared per-instance settings). */
56
+ readonly envSpec: boolean;
57
+ /** The declared operations whose `http` the routes are mounted from. */
58
+ readonly operations: readonly EntryOperationsImport[];
59
+ /** The role the owner seat takes; one of `ROLES`. */
60
+ readonly ownerRole: string;
61
+ /** The operation a person's first arrival runs with `{ displayName }`. */
62
+ readonly join?: string;
63
+ /** The module exporting `WORLD`, the sample a seeded preview holds. */
64
+ readonly world?: string;
65
+ /** The module exporting `API_DOCUMENT`, served at `/api/openapi.json` and `/api/docs`. */
66
+ readonly document?: string;
67
+ /** Whether the door serves and removes files at `/api/attachments/:attachmentId`. */
68
+ readonly attachments?: boolean;
69
+ /**
70
+ * The module exporting `mountRoutes`, the vertical's HTTP routes of its own outside its declared
71
+ * operations (#3523). Mounted after the door and before the declared operations, and handed the
72
+ * door, the caller's stub, the routed node and `grantDeclaredShape` (the declared bootstrap shapes,
73
+ * given now). With it the entry exports the types `Env` and `EntryRoutes`, which that module's
74
+ * signature is written against.
75
+ */
76
+ readonly routes?: string;
77
+ /**
78
+ * The module exporting `DOOR`, the vertical's own `workerDoor` options (#3524): what `/api/me`
79
+ * adds, invite links, the platform's member verbs. Spread into the door beneath the options the
80
+ * entry writes, so it cannot replace those. With it the entry exports the types `Env` and
81
+ * `EntryDoor`, which that module's `DOOR` is written against.
82
+ */
83
+ readonly door?: string;
84
+ /**
85
+ * The module exporting `configureHost(host)`, called on every host `hostFor` builds, after the
86
+ * modules are registered (#3524): a declaration the host must carry wherever it is built, the
87
+ * sweeper and the inline drain as much as a request, such as a connector the vertical declares.
88
+ */
89
+ readonly host?: string;
90
+ /**
91
+ * The key the vertical's service accounts are recorded under in the tenant's identity directory
92
+ * (#3524), with the roles the provision module exports as `SERVICE_ROLES`: the door mints one per
93
+ * role at provision and hands routes a stub acting as each, and the host is told them all.
94
+ */
95
+ readonly services?: string;
96
+ }
97
+ /** Render the entry module for `config`. Throws `EntryEmitError` on a config it cannot spell. */
98
+ export declare function renderEntry(config: EntryConfig): string;
99
+ //# sourceMappingURL=emit-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-entry.d.ts","sourceRoot":"","sources":["../src/emit-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,0FAA0F;AAC1F,qBAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAMD,4FAA4F;AAC5F,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,qGAAqG;IACrG,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACtD,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qFAAqF;IACrF,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAyBD,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CA6QvD"}
@@ -0,0 +1,360 @@
1
+ /**
2
+ * A vertical's worker entry, rendered from its declarations (#3378, D-76).
3
+ *
4
+ * The pure half of `tools/entry-emit.mts`, as `renderClient` is the pure half of
5
+ * `tools/client-emit.mts`: from resolved declarations to a string of TypeScript, with no
6
+ * filesystem and no `process.exit`. The tool loads the vertical's model and provision module,
7
+ * refuses a declaration they do not bear out, and hands this the names.
8
+ *
9
+ * ## Why it is the same chain, not a second generator
10
+ *
11
+ * Everything it writes is a call into the API a hand-written entry already uses: the scope class
12
+ * from `defineScopeDO`, sign-in from `workerDoor`, the routes from `mountOperations` over the
13
+ * operations `spec/model.ts` declares, the `/internal/*` contract from `mountPlatformSurface`. It
14
+ * reads the same declarations the client, the surface and the migrations are emitted from, and
15
+ * it adds none of its own beyond what an entry has to choose: the owner seat's role, the join
16
+ * operation, the world a seeded preview holds. What runs is typed TypeScript, checked by the
17
+ * compiler like every other file the vertical ships.
18
+ *
19
+ * ## What it emits
20
+ *
21
+ * The shape of the scaffold template's `src/worker.ts`, which was written to fit any vertical
22
+ * whose provision module exports the same few names, plus meridian's refusal of an unknown
23
+ * `/internal/*` verb with a 501, so a platform call never reads a 200 fallback. A vertical's own
24
+ * HTTP routes, when it declares a `routes` module, are mounted between the door and the declared
25
+ * operations, and the entry then exports the `Env` and `EntryRoutes` types that module is written
26
+ * against (#3523). A vertical's own door options, when it declares a `door` module, are spread into
27
+ * `workerDoor` beneath the ones the entry writes, typed by the `EntryDoor` the entry exports (#3524).
28
+ * The list of what
29
+ * the hand-written entries do, and which of it is emitted, is `docs/architecture/generated-entry.md`.
30
+ *
31
+ * ## Deterministic
32
+ *
33
+ * The output is a pure function of the config: a fixed order, `\n` line endings, and no time,
34
+ * path or machine in it (D-76: an emitter's output is part of its contract).
35
+ */
36
+ /** Raised for anything the caller must fix. The CLI turns it into exit 2 and a remedy. */
37
+ export class EntryEmitError extends Error {
38
+ constructor(message) {
39
+ super(message);
40
+ this.name = 'EntryEmitError';
41
+ }
42
+ }
43
+ function fail(message) {
44
+ throw new EntryEmitError(message);
45
+ }
46
+ /** The names the emitted module binds itself; an operations export may not take one. */
47
+ const RESERVED = new Set([
48
+ 'Hono', 'Context', 'HTTPException', 'scopeId', 'tenantId', 'ScopeId', 'TenantId',
49
+ 'CloudflareScopeHost', 'defineScopeDO', 'defineScopeSweeperDO', 'SCOPE_SWEEPER_NAME', 'ScopeSweeperDo',
50
+ 'ScopeStub', 'defaultAttachmentExtractors', 'invocationLog', 'kickFlags', 'mountOperations',
51
+ 'mountPlatformSurface', 'problemResponse', 'readRoutedNode', 'refuse', 'refuseStatus',
52
+ 'RouterAssertionError', 'IdentityDO', 'workerDoor', 'MODULES', 'ROLES', 'permissions', 'envSpec',
53
+ 'WORLD', 'API_DOCUMENT', 'ScopeDO', 'SweeperDO', 'Env', 'Node', 'DEV_NODE', 'OWNER_ROLE_KEY',
54
+ 'ENV_SPEC', 'OPERATIONS', 'nodeFor', 'hostFor', 'sweeper', 'door', 'stub', 'app',
55
+ 'mountRoutes', 'EntryRoutes', 'DOOR', 'EntryDoor', 'WorkerDoorDeps', 'grantDeclaredShape', 'DECLARED',
56
+ 'EntityRef', 'PrincipalId', 'PermissionsInput', 'substratError', 'configureHost', 'SERVICE_ROLES',
57
+ ]);
58
+ const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
59
+ const SPECIFIER = /^\.\.?\/[A-Za-z0-9_./-]+\.js$/;
60
+ function specifier(field, value) {
61
+ if (!SPECIFIER.test(value) || value.includes('//')) {
62
+ fail(`${field}: "${value}" is not a relative import ending in .js`);
63
+ }
64
+ return value;
65
+ }
66
+ /** Render the entry module for `config`. Throws `EntryEmitError` on a config it cannot spell. */
67
+ export function renderEntry(config) {
68
+ if (config.sources.length === 0)
69
+ fail('sources: name at least one file the entry is emitted from');
70
+ if (config.operations.length === 0)
71
+ fail('operations: name at least one export of declared operations');
72
+ if (!config.ownerRole)
73
+ fail('ownerRole: name the role the owner seat takes');
74
+ specifier('provision', config.provision);
75
+ if (config.world !== undefined)
76
+ specifier('world', config.world);
77
+ if (config.document !== undefined)
78
+ specifier('document', config.document);
79
+ if (config.routes !== undefined)
80
+ specifier('routes', config.routes);
81
+ if (config.door !== undefined)
82
+ specifier('door', config.door);
83
+ if (config.host !== undefined)
84
+ specifier('host', config.host);
85
+ if (config.services !== undefined && !config.services.trim())
86
+ fail('services: name the key the service accounts are recorded under');
87
+ const exportsEnv = config.routes !== undefined || config.door !== undefined;
88
+ const seen = new Set();
89
+ for (const imp of config.operations) {
90
+ specifier('operations', imp.from);
91
+ if (imp.names.length === 0)
92
+ fail(`operations: ${imp.from} names no export`);
93
+ for (const n of imp.names) {
94
+ if (!IDENTIFIER.test(n))
95
+ fail(`operations: "${n}" is not an identifier`);
96
+ if (RESERVED.has(n))
97
+ fail(`operations: "${n}" is a name the entry binds itself; re-export it under another`);
98
+ if (seen.has(n))
99
+ fail(`operations: "${n}" is named twice`);
100
+ seen.add(n);
101
+ }
102
+ }
103
+ const names = config.operations.flatMap((i) => i.names);
104
+ // A single-quoted literal, escaped as JSON escapes it: the file reads in one quote style.
105
+ const lit = (s) => `'${JSON.stringify(s).slice(1, -1).replace(/\\"/g, '"').replace(/'/g, "\\'")}'`;
106
+ const out = [];
107
+ const line = (s = '') => out.push(s);
108
+ line(`// GENERATED by tools/entry-emit.mts from ${config.sources.join(', ')} — do not edit by hand.`);
109
+ line('/**');
110
+ line(` * ${config.name}'s worker entry: the module \`substrat push\` names as \`runtimeNeeds.entry\`.`);
111
+ line(' *');
112
+ line(' * Emitted from the declarations named above (#3378, D-76), so it changes when they do and is');
113
+ line(' * re-emitted with `pnpm lint:entry`. What it covers and what it does not yet is');
114
+ line(' * docs/architecture/generated-entry.md. The platform entry stays in front of it.');
115
+ line(' */');
116
+ line("import { Hono } from 'hono';");
117
+ line("import type { Context } from 'hono';");
118
+ line("import { HTTPException } from 'hono/http-exception';");
119
+ if (config.routes !== undefined) {
120
+ line('import {');
121
+ line(' scopeId,');
122
+ line(' substratError,');
123
+ line(' tenantId,');
124
+ line(' type EntityRef,');
125
+ line(' type PermissionsInput,');
126
+ line(' type PrincipalId,');
127
+ line(' type ScopeId,');
128
+ line(' type TenantId,');
129
+ line("} from '@substrat-run/contracts';");
130
+ }
131
+ else {
132
+ line("import { scopeId, tenantId, type ScopeId, type TenantId } from '@substrat-run/contracts';");
133
+ }
134
+ ;
135
+ line('import {');
136
+ line(' CloudflareScopeHost,');
137
+ line(' defineScopeDO,');
138
+ line(' defineScopeSweeperDO,');
139
+ line(' SCOPE_SWEEPER_NAME,');
140
+ line(' type ScopeSweeperDo,');
141
+ line("} from '@substrat-run/adapter-cloudflare';");
142
+ line("import type { ScopeStub } from '@substrat-run/kernel';");
143
+ line("import { defaultAttachmentExtractors } from '@substrat-run/attachment-extractors';");
144
+ line('import {');
145
+ line(' invocationLog,');
146
+ line(' kickFlags,');
147
+ line(' mountOperations,');
148
+ line(' mountPlatformSurface,');
149
+ line(' problemResponse,');
150
+ line(' readRoutedNode,');
151
+ line(' refuse,');
152
+ line(' refuseStatus,');
153
+ line(' RouterAssertionError,');
154
+ line("} from '@substrat-run/vertical-host';");
155
+ line(`import { IdentityDO, workerDoor${config.door !== undefined ? ', type WorkerDoorDeps' : ''} } from '@substrat-run/vertical-host/worker-door';`);
156
+ line(`import { MODULES, ROLES, ${config.services !== undefined ? 'SERVICE_ROLES, ' : ''}${config.envSpec ? 'envSpec, ' : ''}permissions } from ${lit(config.provision)};`);
157
+ for (const imp of config.operations)
158
+ line(`import { ${imp.names.join(', ')} } from ${lit(imp.from)};`);
159
+ if (config.document !== undefined)
160
+ line(`import { API_DOCUMENT } from ${lit(config.document)};`);
161
+ if (config.world !== undefined)
162
+ line(`import { WORLD } from ${lit(config.world)};`);
163
+ if (config.routes !== undefined)
164
+ line(`import { mountRoutes } from ${lit(config.routes)};`);
165
+ if (config.door !== undefined)
166
+ line(`import { DOOR } from ${lit(config.door)};`);
167
+ if (config.host !== undefined)
168
+ line(`import { configureHost } from ${lit(config.host)};`);
169
+ line();
170
+ line('/** The scope class: the kernel, the engines and this vertical, on one database per scope. */');
171
+ line('export const ScopeDO = defineScopeDO(MODULES, {}, { permissions });');
172
+ line();
173
+ line('/** The tenant\'s identity directory. Re-exported: workerd reads a class from the entry\'s exports. */');
174
+ line('export { IdentityDO };');
175
+ line();
176
+ line('/** The deployment\'s own timer (#461): runs each provisioned scope\'s due work. */');
177
+ line('export const SweeperDO = defineScopeSweeperDO<Env>({');
178
+ line(' versionId: (env) => env.SUBSTRAT_VERSION_ID ?? null,');
179
+ line(' intervalMs: 120_000,');
180
+ line(' host: hostFor,');
181
+ line('});');
182
+ line();
183
+ if (exportsEnv) {
184
+ const readers = [config.routes !== undefined ? 'routes' : null, config.door !== undefined ? 'door' : null].filter(Boolean);
185
+ line(`/** The bindings this entry runs with. Exported for the ${readers.join(' and ')} module${readers.length > 1 ? 's, which are' : ', which is'} written against it. */`);
186
+ }
187
+ line(`${exportsEnv ? 'export ' : ''}interface Env {`);
188
+ line(' /** Injected at deploy (#1242); absent locally. */');
189
+ line(' SUBSTRAT_VERSION_ID?: string;');
190
+ line(' SCOPE: DurableObjectNamespace;');
191
+ line(' SWEEPER: DurableObjectNamespace;');
192
+ line(' AUTH: DurableObjectNamespace<IdentityDO>;');
193
+ line(' /** Local `wrangler dev` only: fall back to DEV_NODE when no router asserted a node. */');
194
+ line(' ALLOW_DEV_NODE?: string;');
195
+ line(' ROUTER_SECRET?: string;');
196
+ line(' PLATFORM_SECRET?: string;');
197
+ line('}');
198
+ line();
199
+ line('interface Node {');
200
+ line(' tenantId: TenantId;');
201
+ line(' scopeId: ScopeId;');
202
+ line('}');
203
+ line();
204
+ if (config.routes !== undefined) {
205
+ line('/** What the routes this vertical declares are handed (#3523): the same door the declared operations go through. */');
206
+ line('export interface EntryRoutes {');
207
+ line(' /** Sign-in and the caller: their scope, their files, the scope\'s settings, a call to another app as them. */');
208
+ line(' readonly door: typeof door;');
209
+ line(' /** The caller\'s scope stub, flagged as the declared operations\' stubs are. 401 for nobody. */');
210
+ line(' readonly stub: typeof stub;');
211
+ line(' /** The routed (tenant, scope), from the router\'s verified assertion. */');
212
+ line(' readonly nodeFor: typeof nodeFor;');
213
+ line(' /** Give a person the bootstrap shapes the provision module declares on a record, now rather than never. */');
214
+ line(' readonly grantDeclaredShape: typeof grantDeclaredShape;');
215
+ line('}');
216
+ line();
217
+ }
218
+ if (config.door !== undefined) {
219
+ line('/** What this vertical\'s door module adds (#3524): the door\'s options this entry does not write itself. */');
220
+ line("export type EntryDoor = Omit<WorkerDoorDeps<Env>, 'directory' | 'nodeFor' | 'hostFor' | 'envSpec' | 'join' | 'world' | 'attachments' | 'services'>;");
221
+ line();
222
+ }
223
+ line('/** An address for an un-routed local request, never an identity. Only under ALLOW_DEV_NODE. */');
224
+ line('const DEV_NODE: Node = {');
225
+ line(" tenantId: tenantId.parse('01JZ00000000000000000DEV01'),");
226
+ line(" scopeId: scopeId.parse('01JZ00000000000000000DEV02'),");
227
+ line('};');
228
+ line();
229
+ line(`const OWNER_ROLE_KEY = ${lit(config.ownerRole)};`);
230
+ line();
231
+ line('/** The routed (tenant, scope): from a verified router assertion, or the dev node. */');
232
+ line('function nodeFor(req: Request, env: Env): Node {');
233
+ line(' let routed;');
234
+ line(' try {');
235
+ line(" routed = readRoutedNode(req.headers, { expectedSecret: env.ROUTER_SECRET, allowUnsigned: env.ALLOW_DEV_NODE === 'true' });");
236
+ line(' } catch (e) {');
237
+ line(' if (e instanceof RouterAssertionError) throw new HTTPException(400, { message: e.message });');
238
+ line(' throw e;');
239
+ line(' }');
240
+ line(' if (routed) return { tenantId: routed.tenantId, scopeId: routed.scopeId };');
241
+ line(" if (env.ALLOW_DEV_NODE === 'true') return DEV_NODE;");
242
+ line(" throw new HTTPException(503, { message: 'no scope was asserted for this request (missing router assertion)' });");
243
+ line('}');
244
+ line();
245
+ line('/** The host every route, the sweeper and the platform surface build. Exported for a workerd suite. */');
246
+ line('export function hostFor(env: Env): CloudflareScopeHost {');
247
+ if (config.services !== undefined) {
248
+ line(' const host = new CloudflareScopeHost({');
249
+ line(' scope: env.SCOPE,');
250
+ line(' attachmentExtractors: defaultAttachmentExtractors(),');
251
+ line(' permissions,');
252
+ line(' // The service accounts the door minted, so a reconcile does not count them as people (#1896).');
253
+ line(' servicePrincipals: (tenantId, scopeId) => door.servicePrincipals(env, { tenantId, scopeId }),');
254
+ line(' });');
255
+ }
256
+ else {
257
+ line(' const host = new CloudflareScopeHost({ scope: env.SCOPE, attachmentExtractors: defaultAttachmentExtractors(), permissions });');
258
+ }
259
+ line(' for (const m of MODULES) host.registerModule(m);');
260
+ if (config.host !== undefined)
261
+ line(' configureHost(host);');
262
+ line(' return host;');
263
+ line('}');
264
+ line();
265
+ line('function sweeper(env: Env): DurableObjectStub & ScopeSweeperDo {');
266
+ line(' return env.SWEEPER.get(env.SWEEPER.idFromName(SCOPE_SWEEPER_NAME)) as DurableObjectStub & ScopeSweeperDo;');
267
+ line('}');
268
+ line();
269
+ line('const door = workerDoor<Env>({');
270
+ // Beneath what the entry writes, so the module adds options and replaces none.
271
+ if (config.door !== undefined)
272
+ line(' ...(DOOR satisfies EntryDoor),');
273
+ line(' directory: (env, node) => env.AUTH.get(env.AUTH.idFromName(node.tenantId)),');
274
+ line(' nodeFor,');
275
+ line(' hostFor,');
276
+ line(` envSpec: ${config.envSpec ? 'envSpec' : '[]'},`);
277
+ if (config.join !== undefined)
278
+ line(` join: (scope, who) => scope.invoke(${lit(config.join)}, { displayName: who.display }),`);
279
+ if (config.world !== undefined)
280
+ line(' world: WORLD,');
281
+ if (config.attachments)
282
+ line(' attachments: true,');
283
+ if (config.services !== undefined)
284
+ line(` services: { roles: SERVICE_ROLES, record: ${lit(config.services)} },`);
285
+ line('});');
286
+ line();
287
+ line('/** The caller\'s scope stub, flagged so a committed intent or export is drained in seconds. 401 if nobody. */');
288
+ line('function stub(c: Context<{ Bindings: Env }>): Promise<ScopeStub> {');
289
+ line(' return door.scope(c, { ...kickFlags((name, value) => c.header(name, value)) });');
290
+ line('}');
291
+ line();
292
+ if (config.routes !== undefined) {
293
+ line('/** The provision module\'s declaration, read as the type every vertical\'s satisfies. */');
294
+ line('const DECLARED: PermissionsInput = permissions;');
295
+ line();
296
+ line('/**');
297
+ line(' * Give `principal` every shape the provision module declares `bootstrap` with a table holder on');
298
+ line(' * `entity`\'s type (#2071), for a record a route has just linked to them, each as the reconcile');
299
+ line(' * treats it. The platform\'s reconcile tops a holder up but gives a shape to nobody who does not');
300
+ line(' * hold it yet, so without this a person linked after the shapes were first reconciled would never');
301
+ line(' * hold them. Only those declared shapes, only on that type, and only for a signed-in caller: a');
302
+ line(' * route gives nothing else this way.');
303
+ line(' */');
304
+ line('async function grantDeclaredShape(c: Context<{ Bindings: Env }>, entity: EntityRef, principal: PrincipalId): Promise<void> {');
305
+ line(' await door.scope(c);');
306
+ line(" const shapes = (DECLARED.entityGrants ?? []).filter((s) => s.bootstrap && typeof s.holder === 'object' && s.entityType === entity.entityType);");
307
+ line(" if (shapes.length === 0) throw substratError('forbidden', `no bootstrap shape with a table holder is declared for '${entity.entityType}'`);");
308
+ line(' const host = hostFor(c.env);');
309
+ line(' const { scopeId } = nodeFor(c.req.raw, c.env);');
310
+ line(' for (const shape of shapes) await host.grantEntityShapeLocal(scopeId, principal, entity, shape.permissions);');
311
+ line('}');
312
+ line();
313
+ }
314
+ line('const app = new Hono<{ Bindings: Env }>();');
315
+ line();
316
+ line('// FIRST: Hono composes in registration order, so a route above this line would go unlogged.');
317
+ line('app.use(');
318
+ line(" '*',");
319
+ line(' invocationLog<Env>({');
320
+ line(' routerSecret: (env) => env.ROUTER_SECRET,');
321
+ line(" allowUnsigned: (env) => env.ALLOW_DEV_NODE === 'true',");
322
+ line(' }),');
323
+ line(');');
324
+ line();
325
+ line('door.mount(app);');
326
+ line();
327
+ line('app.onError((err, c) => problemResponse(c, err));');
328
+ if (config.routes !== undefined) {
329
+ line('// The vertical\'s own routes: behind the door, ahead of the declared operations and the catch-alls.');
330
+ line('mountRoutes(app, { door, stub, nodeFor, grantDeclaredShape });');
331
+ }
332
+ const bag = names.length === 1 ? names[0] : `{ ${names.map((n) => `...${n}`).join(', ')} }`;
333
+ const docs = config.document !== undefined ? ', { docs: { document: API_DOCUMENT } }' : '';
334
+ line(`mountOperations(app, ${bag}, stub${docs});`);
335
+ line();
336
+ line('mountPlatformSurface<Env>(app, {');
337
+ line(' platformSecret: (env) => env.PLATFORM_SECRET,');
338
+ line(' hostFor,');
339
+ line(' roles: ROLES,');
340
+ line(' ownerRoleKey: OWNER_ROLE_KEY,');
341
+ line(' ...door.platform,');
342
+ line(' onProvision: async (env, b) => {');
343
+ line(' const seat = await door.platform.onProvision(env, b);');
344
+ line(' await sweeper(env).noteScope(b.tenantId, b.scopeId);');
345
+ line(' return seat;');
346
+ line(' },');
347
+ line(' onDeleteScope: async (env, s, tenantId) => {');
348
+ line(' await door.platform.onDeleteScope(env, s, tenantId);');
349
+ line(' await sweeper(env).forgetScope(s);');
350
+ line(' },');
351
+ line('});');
352
+ line();
353
+ line('// Any other platform verb is unimplemented: a 501, never a 200 fallback the platform would misread.');
354
+ line("app.all('/internal/*', (c) => refuseStatus(c, 501, `not implemented: ${c.req.method} ${new URL(c.req.url).pathname}`));");
355
+ line("app.all('*', (c) => refuse(c, 'not_found', `unknown route: ${new URL(c.req.url).pathname}`));");
356
+ line();
357
+ line('export default app;');
358
+ return `${out.join('\n')}\n`;
359
+ }
360
+ //# sourceMappingURL=emit-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-entry.js","sourceRoot":"","sources":["../src/emit-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,0FAA0F;AAC1F,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,SAAS,IAAI,CAAC,OAAe;IAC3B,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AA6DD,wFAAwF;AACxF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;IACvB,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU;IAChF,qBAAqB,EAAE,eAAe,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,gBAAgB;IACtG,WAAW,EAAE,6BAA6B,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB;IAC3F,sBAAsB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc;IACrF,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,SAA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CAAC,CAAC;IAC7G,IAAI,CAAC,yHAAyH,CAAC,CAAC;IAChI,IAAI,CAAC,+FAA+F,CAAC,CAAC;IACtG,IAAI,EAAE,CAAC;IACP,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAC5B,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,5 +3,6 @@ export { journalColumns, journalUniques, journalPrimaryKeys, journalChecks } fro
3
3
  export { readSchema, statements, normaliseSql, columnChecks, type TableSchema } from './replay.js';
4
4
  export { planMigration, parseJournal, type Journal, type JournalEntry, type MigrationPlan, type MigrationPlanOptions, type ParseJournalOptions, } from './plan.js';
5
5
  export { renderClient, ClientEmitError, tsTypeOf, methodName, type ClientConfig, } from './emit-client.js';
6
+ export { renderEntry, EntryEmitError, type EntryConfig, type EntryOperationsImport, } from './emit-entry.js';
6
7
  export { emitXState, type EmitXStateOptions, type GuardWiring, type XStateMachine, type XStateNode, type XStateTransition, } from './emit-xstate.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EACL,aAAa,EACb,YAAY,EACZ,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,UAAU,EACV,KAAK,YAAY,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EACL,aAAa,EACb,YAAY,EACZ,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,UAAU,EACV,KAAK,YAAY,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -3,5 +3,6 @@ export { journalColumns, journalUniques, journalPrimaryKeys, journalChecks } fro
3
3
  export { readSchema, statements, normaliseSql, columnChecks } from './replay.js';
4
4
  export { planMigration, parseJournal, } from './plan.js';
5
5
  export { renderClient, ClientEmitError, tsTypeOf, methodName, } from './emit-client.js';
6
+ export { renderEntry, EntryEmitError, } from './emit-entry.js';
6
7
  export { emitXState, } from './emit-xstate.js';
7
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAC;AACnG,OAAO,EACL,aAAa,EACb,YAAY,GAMb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,UAAU,GAEX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,GAMX,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAC;AACnG,OAAO,EACL,aAAa,EACb,YAAY,GAMb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,UAAU,GAEX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,cAAc,GAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,UAAU,GAMX,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/model-emit",
3
- "version": "0.12.37",
3
+ "version": "0.13.0",
4
4
  "description": "Build-time tooling over a Substrat model — DDL emitted from the entity registry, and the journal reader that holds it honest",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -22,12 +22,12 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@substrat-run/contracts": "0.216.0"
25
+ "@substrat-run/contracts": "0.217.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.20.5",
29
29
  "typescript": "^7.0.0",
30
- "vitest": "^5.0.5",
30
+ "vitest": "5.0.5",
31
31
  "zod": "^4.4.3"
32
32
  },
33
33
  "publishConfig": {