@lunora/codegen 1.0.0-alpha.398 → 1.0.0-alpha.399
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.
- package/dist/index.d.mts +49 -5
- package/dist/index.d.ts +49 -5
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AGENTS_FILENAME-BxpEvZgW.mjs → AGENTS_FILENAME-Cli3X44r.mjs} +1 -1
- package/dist/packem_shared/COMPANION_BINDING-Da_v9XpC.mjs +1 -0
- package/dist/packem_shared/{CONTAINERS_FILENAME-CvPP3wR-.mjs → CONTAINERS_FILENAME-BX1_ALLp.mjs} +1 -1
- package/dist/packem_shared/{DEFAULT_TARGET-C0xI7Xqd.mjs → DEFAULT_TARGET-C-gcdslJ.mjs} +1 -1
- package/dist/packem_shared/{FLAGS_FILENAME-Ce1G6kZd.mjs → FLAGS_FILENAME-DY3yo1u_.mjs} +1 -1
- package/dist/packem_shared/{MUTATORS_FILENAME-JBFlT9aD.mjs → MUTATORS_FILENAME-Ck_l1lz7.mjs} +1 -1
- package/dist/packem_shared/{NOTIFY_FILENAME-DLGxunzB.mjs → NOTIFY_FILENAME-BIodzu3R.mjs} +1 -1
- package/dist/packem_shared/{OPENRPC_VERSION-CLZ5Em9J.mjs → OPENRPC_VERSION-Dr6Xjldk.mjs} +1 -1
- package/dist/packem_shared/{QUEUES_FILENAME-2K8DSvbt.mjs → QUEUES_FILENAME-C5xotY-M.mjs} +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-B1dOE0gb.mjs +52 -0
- package/dist/packem_shared/{SHAPES_FILENAME-DCqsIdQQ.mjs → SHAPES_FILENAME-DCtGHMEm.mjs} +1 -1
- package/dist/packem_shared/{WORKFLOWS_FILENAME-Cpx5Mg0z.mjs → WORKFLOWS_FILENAME-CyV1HQaP.mjs} +1 -1
- package/dist/packem_shared/{attribution-7Qs8xFmy.mjs → attribution-DjweYNgJ.mjs} +1 -1
- package/dist/packem_shared/{buildOpenApiDocument-KKQFkA_W.mjs → buildOpenApiDocument-BTp9vkHw.mjs} +1 -1
- package/dist/packem_shared/{capabilitiesUsedBy-CsqWN4ob.mjs → capabilitiesUsedBy-SSrieNZ1.mjs} +1 -1
- package/dist/packem_shared/chain-DWwd9wXd.mjs +1 -0
- package/dist/packem_shared/{classify-procedure-call-D7XTLd8w.mjs → classify-procedure-call-BuF5PNwV.mjs} +1 -1
- package/dist/packem_shared/companionServiceBinding-ChINWo8k.mjs +1 -0
- package/dist/packem_shared/{context-property-calls-Dh1E4-sW.mjs → context-property-calls-BcUYQ6ph.mjs} +1 -1
- package/dist/packem_shared/{context-root-DHXNIvVA.mjs → context-root-2wag3akK.mjs} +1 -1
- package/dist/packem_shared/{createCodegenProject-khHqIXPY.mjs → createCodegenProject-C8N4Zm8h.mjs} +1 -1
- package/dist/packem_shared/{database-calls-CxJgjC_X.mjs → database-calls-B_85LJIk.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-D-ZsZKvv.mjs → discoverAuthApiCalls-f8_WRQEA.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-BT_qyOt8.mjs → discoverCrons-DTqSuSDh.mjs} +1 -1
- package/dist/packem_shared/discoverFunctions-D4GIaVIP.mjs +1 -0
- package/dist/packem_shared/{discoverHttpRoutes-DOkHmHzy.mjs → discoverHttpRoutes-2gxHuLgt.mjs} +1 -1
- package/dist/packem_shared/discoverHyperdriveCalls-DaJLewG0.mjs +1 -0
- package/dist/packem_shared/{discoverInserts-d_zAWqc4.mjs → discoverInserts-CLh70kVu.mjs} +1 -1
- package/dist/packem_shared/discoverMaskProcedures-C0VcUGpb.mjs +1 -0
- package/dist/packem_shared/{discoverMigrations-Dq-7Od3H.mjs → discoverMigrations-e5_NQdf-.mjs} +1 -1
- package/dist/packem_shared/{discoverNondeterministicCalls-BnSxt5nN.mjs → discoverNondeterministicCalls-CrXAegUc.mjs} +1 -1
- package/dist/packem_shared/{discoverQueries-Bvh__ZjJ.mjs → discoverQueries-T8b_7ZZ-.mjs} +1 -1
- package/dist/packem_shared/discoverR2sqlCalls-CY0xmIWX.mjs +1 -0
- package/dist/packem_shared/{discoverRlsMetadata-CugyqoLu.mjs → discoverRlsMetadata-CnVvP2Ps.mjs} +1 -1
- package/dist/packem_shared/{discoverRlsProcedures-CDbsnndn.mjs → discoverRlsProcedures-DttY0Jld.mjs} +1 -1
- package/dist/packem_shared/{discoverSandboxUsage-CSt29RbS.mjs → discoverSandboxUsage-X0SECo-x.mjs} +1 -1
- package/dist/packem_shared/{discoverSchema-DTgg8rAu.mjs → discoverSchema-DDvMQheA.mjs} +1 -1
- package/dist/packem_shared/{discoverStorageRulesMetadata-DTXC-pY3.mjs → discoverStorageRulesMetadata-t_oMSn0L.mjs} +1 -1
- package/dist/packem_shared/{emitAgents-C-Mfsx39.mjs → emitAgents-ChXyTTzS.mjs} +1 -1
- package/dist/packem_shared/{emitApp-D-fxbE34.mjs → emitApp-xunr1-_c.mjs} +6 -4
- package/dist/packem_shared/{emitShard-CVPnBS0Y.mjs → emitShard-CueduzG1.mjs} +1 -1
- package/dist/packem_shared/{exported-procedure-chains-D1wkgxKb.mjs → exported-procedure-chains-BaxQ8C-S.mjs} +1 -1
- package/dist/packem_shared/{fingerprintSchemaSources-Pmxw808S.mjs → fingerprintSchemaSources-PmhepCVj.mjs} +1 -1
- package/dist/packem_shared/{handler-reference-HsMWpHnr.mjs → handler-reference-D2EE2q-4.mjs} +1 -1
- package/dist/packem_shared/{index-VKPwR6Cj.mjs → index-Dd6T5nSP.mjs} +1 -1
- package/dist/packem_shared/{index-DuvSMZEy.mjs → index-fVYBrxkP.mjs} +1 -1
- package/dist/packem_shared/{ip-reads-CAzOWzOH.mjs → ip-reads-WFubgB1G.mjs} +1 -1
- package/dist/packem_shared/{isTestPath-DrszPMtU.mjs → isTestPath-ClgKgMYM.mjs} +1 -1
- package/dist/packem_shared/loadProjectConfig-CtcJHHKS.mjs +1 -0
- package/dist/packem_shared/{modules-CYf6V2w7.mjs → modules-DE0ksIeR.mjs} +1 -1
- package/dist/packem_shared/{shard-DKSPraAt.mjs → shard-DNpjvEod.mjs} +113 -120
- package/dist/packem_shared/{shard-runtime-BHljpfS5.mjs → shard-runtime-knn-ER8x.mjs} +1 -1
- package/dist/packem_shared/{unwrap-handler-return-X7HuBhd5.mjs → unwrap-handler-return-BpigsVD6.mjs} +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-5N9d9CIu.mjs +0 -31
- package/dist/packem_shared/chain-DIvP6mqw.mjs +0 -1
- package/dist/packem_shared/discoverFunctions-DgzPoKGf.mjs +0 -1
- package/dist/packem_shared/discoverHyperdriveCalls-BGhSZp00.mjs +0 -1
- package/dist/packem_shared/discoverMaskProcedures-CFcLOe-9.mjs +0 -1
- package/dist/packem_shared/discoverR2sqlCalls-CexxhDRt.mjs +0 -1
- package/dist/packem_shared/loadProjectConfig-Dbux4jI3.mjs +0 -1
- package/dist/packem_shared/readServiceBindings-rDIqDBSW.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LunoraError as
|
|
1
|
+
import{LunoraError as pe}from"@lunora/errors";import{serializeSchemaSnapshot as Zt,hashSchemaSnapshot as er}from"./SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{isHyperdriveGlobalTable as tr,isD1GlobalTable as rr}from"./isD1GlobalTable-udvHAAzD.mjs";import{r as nr}from"./json-data-Chfs2Cz5.mjs";import{r as q,e as ar,a as sr,b as or,c as ir,d as dr,f as cr,g as lr,h as ur,i as hr,j as pr,k as mr,l as fr,m as gr,n as br,o as yr,p as wr,q as vr,s as kr}from"./shard-runtime-knn-ER8x.mjs";import{u as M,h as Sr,s as Rr,a as xr,I as Ar,c as Or,G as Tr,d as Dr}from"./shared-DhqnD5R3.mjs";import{p as _r}from"./platform-8oj7iXQy.mjs";import{i as Ir}from"./schema-BgM8A3XV.mjs";const m=(r,t)=>`((): (() => ${t}) => { let cached: ${t} | undefined; return () => (cached ??= JSON.parse(${JSON.stringify(JSON.stringify(r))}) as ${t}); })()`,me=["categories","description","facing","level","remediation","title"],Er=r=>{const t={};return{advisoryRows:r.map(o=>{let n=t[o.name];return n||(n=Object.fromEntries(me.filter(a=>a in o).map(a=>[a,o[a]])),t[o.name]=n),Object.fromEntries(Object.entries(o).filter(([a,i])=>!me.includes(a)||JSON.stringify(i)!==JSON.stringify(n[a])))}),advisoryRules:t}},Cr=` /**
|
|
2
2
|
* The bare writer every admin/maintenance entry point writes through.
|
|
3
3
|
*
|
|
4
4
|
* Admin and maintenance writes go through the SAME reactive-cache hooks as a
|
|
@@ -30,7 +30,7 @@ import{LunoraError as me}from"@lunora/errors";import{serializeSchemaSnapshot as
|
|
|
30
30
|
schema: schema as unknown as SchemaLike,
|
|
31
31
|
sql: this.sql as SqlExec,
|
|
32
32
|
});
|
|
33
|
-
}`,
|
|
33
|
+
}`,y=(r="")=>` const writer = this.adminWriter(${r});`,Lr=`${Cr}
|
|
34
34
|
|
|
35
35
|
protected override async runShardDataMigration(args: RunShardMigrationArgs): Promise<MigrationRunResult> {
|
|
36
36
|
this.ensureMigrated();
|
|
@@ -47,7 +47,7 @@ import{LunoraError as me}from"@lunora/errors";import{serializeSchemaSnapshot as
|
|
|
47
47
|
throw new LunoraError("MIGRATION_NOT_FOUND", \`data migration "\${args.id}" is not registered\`, { status: 404 });
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
${
|
|
50
|
+
${y()}
|
|
51
51
|
|
|
52
52
|
try {
|
|
53
53
|
return await runDataMigration({
|
|
@@ -86,7 +86,7 @@ ${g()}
|
|
|
86
86
|
|
|
87
87
|
this.ensureMigrated();
|
|
88
88
|
|
|
89
|
-
${
|
|
89
|
+
${y("headroom ?? this.transactionHeadroom()")}
|
|
90
90
|
|
|
91
91
|
if (args.op === "insert") {
|
|
92
92
|
const id = await writer.insert(args.table, args.doc ?? {});
|
|
@@ -141,7 +141,7 @@ ${g("headroom ?? this.transactionHeadroom()")}
|
|
|
141
141
|
protected override async runShardExport(args: RunShardExportArgs): Promise<ExportRow[]> {
|
|
142
142
|
this.ensureMigrated();
|
|
143
143
|
|
|
144
|
-
${
|
|
144
|
+
${y()}
|
|
145
145
|
|
|
146
146
|
const rows: ExportRow[] = [];
|
|
147
147
|
|
|
@@ -161,7 +161,7 @@ ${g()}
|
|
|
161
161
|
this.ensureMigrated();
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
${
|
|
164
|
+
${y()}
|
|
165
165
|
|
|
166
166
|
// \`importShardRows\` inserts with \`allowExplicitId\`, so a source
|
|
167
167
|
// database's \`_id\`s carry across verbatim and every foreign key
|
|
@@ -172,7 +172,7 @@ ${g()}
|
|
|
172
172
|
protected override async runShardRankBefore(args: RunShardRankBeforeArgs): Promise<{ before: number; total: number }> {
|
|
173
173
|
this.ensureMigrated();
|
|
174
174
|
|
|
175
|
-
${
|
|
175
|
+
${y()}
|
|
176
176
|
|
|
177
177
|
// \`rankBefore\` is optional on \`DatabaseWriterLike\` (the D1 twin omits it),
|
|
178
178
|
// but the shard writer from \`createShardCtxDb\` always defines it.
|
|
@@ -190,7 +190,7 @@ ${g()}
|
|
|
190
190
|
protected override async runShardFindRelated(args: RunShardFindRelatedArgs): Promise<RelatedPage> {
|
|
191
191
|
this.ensureMigrated();
|
|
192
192
|
|
|
193
|
-
${
|
|
193
|
+
${y()}
|
|
194
194
|
|
|
195
195
|
// \`related\` is optional on \`DatabaseWriterLike\` (the D1 twin omits it),
|
|
196
196
|
// but the shard writer from \`createShardCtxDb\` always defines it — it
|
|
@@ -208,7 +208,7 @@ ${g()}
|
|
|
208
208
|
protected override async runShardRankPage(args: RunShardRankPageArgs): Promise<ShardRankPageResult> {
|
|
209
209
|
this.ensureMigrated();
|
|
210
210
|
|
|
211
|
-
${
|
|
211
|
+
${y()}
|
|
212
212
|
|
|
213
213
|
// \`rankPageRows\` is optional on \`DatabaseWriterLike\` (the D1 twin omits it),
|
|
214
214
|
// but the shard writer from \`createShardCtxDb\` always defines it. The sort
|
|
@@ -229,18 +229,18 @@ ${g()}
|
|
|
229
229
|
protected override async runShardApplyCdc(args: RunShardApplyCdcArgs): Promise<{ applied: number }> {
|
|
230
230
|
this.ensureMigrated();
|
|
231
231
|
|
|
232
|
-
${
|
|
232
|
+
${y()}
|
|
233
233
|
|
|
234
234
|
await applyCdcChanges(writer, args.changes);
|
|
235
235
|
|
|
236
236
|
return { applied: args.changes.length };
|
|
237
|
-
}
|
|
238
|
-
orm: databaseContext.orm,`,
|
|
239
|
-
orm: { configurable: true, enumerable: true, value: mutationDatabase.orm, writable: true },`,
|
|
237
|
+
}`,Pr=({actionOnlyBuild:r,actionOnlyFields:t,agentsBuild:e,agentsContextField:o,agentsSchedulerSource:n,containersBuild:a,containersContextField:i,databaseOptions:f,everyContextBuild:c,everyContextField:g,facadeBlock:A,globalDatabaseLine:w,hasSensitiveArgs:u=!1,lazyFunctions:l=!1,notifyBuild:O,ormContextField:v,paymentsBuild:F,paymentsContextField:U,queuesBuild:R,queuesContextField:B,topicsBuild:d,topicsContextField:k,vectorsBuild:I,vectorsContextField:j,workflowsBuild:W,workflowsContextField:E})=>{const T=t.length>0,K=v===""?"{ db }":"{ db, orm: bindOrm(facade) }",H=v===""?"":`
|
|
238
|
+
orm: databaseContext.orm,`,C=v===""?"":`
|
|
239
|
+
orm: { configurable: true, enumerable: true, value: mutationDatabase.orm, writable: true },`,x=T?`
|
|
240
240
|
// ActionCtx-only helpers (external, non-deterministic I/O): constructed
|
|
241
241
|
// and attached only for an \`action\` so query/mutation ctx never carry them.
|
|
242
242
|
if (isAction) {
|
|
243
|
-
${r.replaceAll(/^(?=.)/gmu," ")}${t.map(
|
|
243
|
+
${r.replaceAll(/^(?=.)/gmu," ")}${t.map(p=>` ctx.${p} = ${p};`).join(`
|
|
244
244
|
`)}
|
|
245
245
|
}
|
|
246
246
|
`:"";return` private buildCtx(options: { bookmarks?: DispatchBookmark | undefined; functionPath?: string | undefined; headroom?: TransactionHeadroomTracker | undefined; identity?: SubscriptionIdentity | undefined; kind?: "query" | undefined; onRead?: ((table: string, idOrScan?: string) => void) | undefined; onReadRange?: ((range: KeyRange) => void) | undefined; replayKey?: boolean | undefined; scope?: QueryReadScope | undefined; sensitive?: SensitiveScope | undefined; trusted?: boolean | undefined } = {}): unknown {
|
|
@@ -300,7 +300,7 @@ ${r.replaceAll(/^(?=.)/gmu," ")}${t.map(y=>` ctx.${y} = ${y};`
|
|
|
300
300
|
|
|
301
301
|
return caller.ip;
|
|
302
302
|
};
|
|
303
|
-
${
|
|
303
|
+
${I}${c}${a}${W}${R}${d}${e}
|
|
304
304
|
// Which dispatch this ctx belongs to. Drives the two deferral facades
|
|
305
305
|
// below and the \`ctx.run*\` caller guard; a ctx built for an
|
|
306
306
|
// admin/lifecycle path has no registered function, and so no kind. An
|
|
@@ -406,7 +406,7 @@ ${b}${h}${a}${K}${j}${W}${e}
|
|
|
406
406
|
// so both write to the same trace.
|
|
407
407
|
const span = this.makeDispatchSpan(traceAnchor, observability, options.sensitive);
|
|
408
408
|
|
|
409
|
-
${
|
|
409
|
+
${w} // \`ctx.db\`, wrapped in automatic instrumentation: by default this
|
|
410
410
|
// adds aggregate counters (call count, total time, per-operation
|
|
411
411
|
// breakdown) to the wide event rather than a span per call, so a
|
|
412
412
|
// handler making hundreds of queries stays readable. See
|
|
@@ -414,12 +414,12 @@ ${v} // \`ctx.db\`, wrapped in automatic instrumentation: by default
|
|
|
414
414
|
// Schema triggers close over this DB's scheduler, so a composed
|
|
415
415
|
// mutation must rebuild its DB and table/ORM views with its own queue.
|
|
416
416
|
const makeDatabaseContext = (scheduler: SchedulerLike) => {
|
|
417
|
-
const db: DatabaseWriterLike = this.instrumentDb(createShardCtxDb(${
|
|
418
|
-
${
|
|
417
|
+
const db: DatabaseWriterLike = this.instrumentDb(createShardCtxDb(${f}), logFunctionPath, traceAnchor, observability, options.sensitive);
|
|
418
|
+
${A} return ${K};
|
|
419
419
|
};
|
|
420
420
|
const databaseContext = makeDatabaseContext(scheduler);
|
|
421
421
|
const db = databaseContext.db;
|
|
422
|
-
${
|
|
422
|
+
${F}
|
|
423
423
|
|
|
424
424
|
// \`ctx.trace\` / \`ctx.metrics\`: spans and measurements to the same sink.
|
|
425
425
|
// The trace anchor is threaded explicitly for the same reason \`identity\`
|
|
@@ -427,7 +427,7 @@ ${O}
|
|
|
427
427
|
// writing mutation's trace from the shared per-request field.
|
|
428
428
|
const trace = this.makeTracer(logFunctionPath, observability, traceAnchor, options.sensitive);
|
|
429
429
|
const metrics = this.makeMetrics(logFunctionPath, observability, options.sensitive);
|
|
430
|
-
${
|
|
430
|
+
${O}
|
|
431
431
|
// \`ctx.now\`: the wall-clock instant (epoch ms) this function began,
|
|
432
432
|
// captured ONCE so the whole handler body sees a single stable value.
|
|
433
433
|
// A \`query\` handler is re-run by every live subscription that reads it,
|
|
@@ -505,16 +505,16 @@ ${x}
|
|
|
505
505
|
// to the handler so code that signs its own URLs (a copy-in
|
|
506
506
|
// \`createStorage\`) can fall back to it too. \`undefined\` for a
|
|
507
507
|
// query and for a deferred dispatch, for the reasons given there.
|
|
508
|
-
origin: requestOrigin,${
|
|
508
|
+
origin: requestOrigin,${H}
|
|
509
509
|
scheduler,
|
|
510
510
|
span,
|
|
511
511
|
storage: contextStorage,
|
|
512
|
-
trace,${
|
|
512
|
+
trace,${j}${g}${U}${i}${E}${B}${k}${o}${u?`
|
|
513
513
|
[Symbol.for("lunora.admitSensitiveArgs")]: (args: Record<string, unknown>, names: ReadonlySet<string>): void => this.admitSensitiveValues(options.sensitive, args, names),`:""}
|
|
514
514
|
};
|
|
515
|
-
${
|
|
516
|
-
`:""}${
|
|
517
|
-
${
|
|
515
|
+
${T?` const isAction = contextKind === "action";
|
|
516
|
+
`:""}${x}
|
|
517
|
+
${l?` const captureScope = (): (() => void) => {
|
|
518
518
|
const requestScope = this.captureRequestScope();
|
|
519
519
|
return () => this.restoreRequestScope(requestScope);
|
|
520
520
|
};
|
|
@@ -524,7 +524,7 @@ ${d?` const captureScope = (): (() => void) => {
|
|
|
524
524
|
// The callee runs inside this invocation, so its marked arguments are scrubbed here too.
|
|
525
525
|
this.admitSensitiveArgs(options.sensitive, reference.__lunoraRef, fnArgs);
|
|
526
526
|
|
|
527
|
-
return dispatchRun("action", reference.__lunoraRef, fnArgs, target, kind${
|
|
527
|
+
return dispatchRun("action", reference.__lunoraRef, fnArgs, target, kind${l?", undefined, captureScope":""});
|
|
528
528
|
};
|
|
529
529
|
// The composed mutation runs under the SAME wrapper the top-level RPC
|
|
530
530
|
// uses, so "do the transactional work in a mutation and call it from the
|
|
@@ -547,7 +547,7 @@ ${d?` const captureScope = (): (() => void) => {
|
|
|
547
547
|
// refuses network I/O wherever it runs, so its \`fetch\` is overridden here.
|
|
548
548
|
return Object.defineProperties({}, {
|
|
549
549
|
...Object.getOwnPropertyDescriptors(target),
|
|
550
|
-
db: { configurable: true, enumerable: true, value: mutationDatabase.db, writable: true },${
|
|
550
|
+
db: { configurable: true, enumerable: true, value: mutationDatabase.db, writable: true },${C}
|
|
551
551
|
fetch: { configurable: true, enumerable: true, value: refuseFetch, writable: true },
|
|
552
552
|
random: { configurable: true, enumerable: true, value: mutationRandom, writable: true },
|
|
553
553
|
scheduler: { configurable: true, enumerable: true, value: mutationScheduler, writable: true },
|
|
@@ -559,7 +559,7 @@ ${d?` const captureScope = (): (() => void) => {
|
|
|
559
559
|
installRun(mutationCtx, kind);
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
return dispatchRun("mutation", reference.__lunoraRef, fnArgs, mutationCtx, kind, async (work) => this.runMutationTransaction(mutationCtx, work)${
|
|
562
|
+
return dispatchRun("mutation", reference.__lunoraRef, fnArgs, mutationCtx, kind, async (work) => this.runMutationTransaction(mutationCtx, work)${l?", captureScope":""});
|
|
563
563
|
};
|
|
564
564
|
// \`ctx.runQuery(ref, args, { untracked: true })\` runs the sub-query on
|
|
565
565
|
// its OWN query context, built without the subscription's read-footprint
|
|
@@ -584,7 +584,7 @@ ${d?` const captureScope = (): (() => void) => {
|
|
|
584
584
|
runOptions?.untracked === true
|
|
585
585
|
? this.buildCtx({ bookmarks: options.bookmarks, functionPath: options.functionPath, headroom: options.headroom, identity: caller, kind: "query", scope: options.scope, sensitive: options.sensitive })
|
|
586
586
|
: queryContext(),
|
|
587
|
-
kind,${
|
|
587
|
+
kind,${l?`
|
|
588
588
|
undefined,
|
|
589
589
|
captureScope,`:""}
|
|
590
590
|
);
|
|
@@ -610,7 +610,7 @@ ${d?` const captureScope = (): (() => void) => {
|
|
|
610
610
|
|
|
611
611
|
if (queryView === undefined) {
|
|
612
612
|
const descriptors: PropertyDescriptorMap = Object.getOwnPropertyDescriptors(ctx);
|
|
613
|
-
${t.map(
|
|
613
|
+
${t.map(p=>` delete descriptors.${p};
|
|
614
614
|
`).join("")} // Writable and configurable, like the plain fields they replace.
|
|
615
615
|
const field = (value: unknown): PropertyDescriptor => ({ configurable: true, enumerable: true, value, writable: true });
|
|
616
616
|
|
|
@@ -632,7 +632,7 @@ ${t.map(y=>` delete descriptors.${y};
|
|
|
632
632
|
installRun(ctx, contextKind);
|
|
633
633
|
|
|
634
634
|
return ctx;
|
|
635
|
-
}`},
|
|
635
|
+
}`},fe=`// Bound in-process \`ctx.run*\` composition depth so a self- or cyclically-
|
|
636
636
|
// referencing call fails loudly with a clear error instead of overflowing the
|
|
637
637
|
// stack. Tracked across the awaited handler chain (one DO invocation is
|
|
638
638
|
// single-threaded), so the counter reflects true nesting depth.
|
|
@@ -698,7 +698,7 @@ const dispatchRun = async (
|
|
|
698
698
|
} finally {
|
|
699
699
|
runDepth -= 1;
|
|
700
700
|
}
|
|
701
|
-
};`,
|
|
701
|
+
};`,Nr=r=>r?fe.replace(" runTransactional?: (work: () => Promise<unknown>) => Promise<unknown>,",` runTransactional?: (work: () => Promise<unknown>) => Promise<unknown>,
|
|
702
702
|
captureScope?: () => () => void,`).replace(` try {
|
|
703
703
|
// A mutation composed from an action`,` try {
|
|
704
704
|
let loaded = getLoadedFunction(functionPath);
|
|
@@ -719,7 +719,7 @@ const dispatchRun = async (
|
|
|
719
719
|
|
|
720
720
|
const loadedFunction = loaded;
|
|
721
721
|
|
|
722
|
-
// A mutation composed from an action`).replaceAll("registered.handler","loadedFunction.handler"):
|
|
722
|
+
// A mutation composed from an action`).replaceAll("registered.handler","loadedFunction.handler"):fe,$r=` public override async handleRpc(functionPath: string, args: Record<string, unknown>, headroom?: TransactionHeadroomTracker, scope?: QueryReadScope, bookmarks?: DispatchBookmark, sensitive?: SensitiveScope): Promise<unknown> {
|
|
723
723
|
// A dispatch that did not come through the shard's \`/rpc\` (a scheduled call,
|
|
724
724
|
// a lifecycle hook, an admin run) has no scope of its own, so it opens one here
|
|
725
725
|
// and releases it when the handler settles.
|
|
@@ -932,7 +932,7 @@ __COMMITTED_CATCH__ } finally {
|
|
|
932
932
|
// parked it, and there is nothing to park — an app with no scheduler has no
|
|
933
933
|
// \`ctx.scheduler\` call that reached the buffer in the first place.
|
|
934
934
|
protected override scheduleOutboxScheduler(): SchedulerLike | undefined {
|
|
935
|
-
__OUTBOX_SCHEDULER__ }`,
|
|
935
|
+
__OUTBOX_SCHEDULER__ }`,qr=` protected override async executeSubscription(functionPath: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): Promise<{ identityTracked?: boolean; ranges?: Map<string, KeyRange[]>; result: unknown; tables: Set<string> } | null> {
|
|
936
936
|
const registered = LUNORA_FUNCTIONS[functionPath];
|
|
937
937
|
|
|
938
938
|
if (!registered || registered.kind !== "query" || registered.visibility === "internal") {
|
|
@@ -980,7 +980,7 @@ __PREPARE_FUNCTION__ this.ensureServable();
|
|
|
980
980
|
return this.windowStreamReads(headroom, (registered.handler as (context: unknown, args: Record<string, unknown>, signal: AbortSignal) => AsyncIterable<unknown>)(this.buildCtx({ functionPath, headroom, identity }), args, signal));
|
|
981
981
|
},
|
|
982
982
|
};
|
|
983
|
-
}`,
|
|
983
|
+
}`,Mr=` } catch (error) {
|
|
984
984
|
// The write committed before this failed. Mark the error so the caller can tell
|
|
985
985
|
// a durable write from a rollback: the rethrow still reaches the caller unchanged.
|
|
986
986
|
if (typeof error === "object" && error !== null) {
|
|
@@ -988,7 +988,7 @@ __PREPARE_FUNCTION__ this.ensureServable();
|
|
|
988
988
|
}
|
|
989
989
|
|
|
990
990
|
throw error;
|
|
991
|
-
`,
|
|
991
|
+
`,Fr=(r,t=!1,e=!1)=>{const o=t?` const registeredBeforeLoad = LUNORA_FUNCTIONS[functionPath];
|
|
992
992
|
|
|
993
993
|
if (registeredBeforeLoad?.visibility === "internal" && !this.isSystemDispatch()) {
|
|
994
994
|
throw new LunoraError("FUNCTION_NOT_FOUND", "function not registered: " + functionPath);
|
|
@@ -1008,7 +1008,7 @@ __PREPARE_FUNCTION__ this.ensureServable();
|
|
|
1008
1008
|
`:"",a=e?` const configured = config.scheduler?.((this.env ?? {}) as Record<string, unknown>) as SchedulerLike | undefined;
|
|
1009
1009
|
return configured === undefined ? undefined : withAgentScheduleShard(configured, LUNORA_AGENTS, this.currentShardKey());
|
|
1010
1010
|
`:` return config.scheduler?.((this.env ?? {}) as Record<string, unknown>) as SchedulerLike | undefined;
|
|
1011
|
-
`;return
|
|
1011
|
+
`;return $r.replace("__COMMITTED_CATCH__",r?Mr:"").replace("__PREPARE_FUNCTION__",`${o}${n}`).replace("__OUTBOX_SCHEDULER__",a)},Ur=r=>{const t={};for(const e of r.tables){const o={};for(const[n,a]of Object.entries(e.shape)){const i=M(a);i.kind==="id"&&i.tableName!==void 0&&(o[n]=i.tableName)}Object.keys(o).length>0&&(t[e.name]=o)}return t},Br=r=>{const t={};for(const e of r.tables){const o=[];for(const[n,a]of Object.entries(e.shape))M(a).kind==="storage"&&o.push(n);o.length>0&&(t[e.name]=o)}return t},jr=r=>{const t={};for(const e of r.tables){const o=[...e.indexes.map(n=>({fields:[...n.fields],name:n.name,type:"index",...n.unique===!0?{unique:!0}:{}})),...e.searchIndexes.map(n=>({fields:[n.field,...n.filterFields??[]],name:n.name,type:"search"})),...(e.geoIndexes??[]).map(n=>({fields:[n.field],name:n.name,type:"geo"})),...e.rankIndexes.map(n=>({fields:n.sortBy.map(a=>a.field),name:n.name,type:"rank"})),...e.vectorIndexes.map(n=>({fields:n.field===void 0?[]:[n.field],name:n.name,type:"vector"}))];o.length>0&&(t[e.name]=o)}return t},Wr=r=>{const t=[];for(const e of r.tables)!e.ttl||e.shardMode==="global"||t.push({...e.ttl.after===void 0?{}:{after:e.ttl.after},field:e.ttl.field,...e.softDelete?{softDeleteField:e.softDelete.field}:{},table:e.name});return t},Kr=r=>{if(r.kind!=="union"||r.members===void 0||r.members.length===0)return;const t=[];for(const e of r.members){if(e.kind!=="literal"||e.literalValue===void 0)return;try{const o=JSON.parse(e.literalValue);if(typeof o!="string")return;t.push(o)}catch{return}}return t},Hr=new Set(["bigint","boolean","date","number","timestamp"]),Vr=r=>{const[t,e]=r.kind==="union"?r.members??[]:[];if(t===void 0||e===void 0||r.members?.length!==2)return;const o=a=>a.kind==="null"||a.kind==="literal"&&a.literalValue==="null",n=M(o(e)?t:e);return o(t)!==o(e)&&Hr.has(n.kind)?n:void 0},Gr=(r,t,e)=>{const o=M(t),n=Vr(o),a=n??o,i={name:r,optional:Sr(t),type:a.kind};if(a.kind==="id"&&a.tableName!==void 0){i.ref=a.tableName;const c=e.get(r);c!==void 0&&(i.onDelete=c)}a.kind==="storage"&&(i.isStorage=!0,a.bucket!==void 0&&(i.bucket=a.bucket));const f=Kr(a);return f!==void 0&&(i.enumValues=f),(a.column?.notNull===!1||n!==void 0)&&(i.nullable=!0),i},Qr=r=>{const t={};for(const e of r.tables){const o=[{name:"_id",optional:!1,pk:!0,type:"id"},{name:"_creationTime",optional:!1,type:"number"},...e.commitOrdered===!0?[{name:"_commitSeq",optional:!1,type:"number"}]:[]],n=new Map(e.relations.flatMap(a=>a.kind==="one"?[[a.field,a.onDelete]]:[]));for(const[a,i]of Object.entries(e.shape))o.push(Gr(a,i,n));t[e.name]=o}return t},zr=({hasMutators:r,hasSensitiveShapes:t,hasShapes:e,rlsData:o})=>{const n="{ columns?: readonly string[]; effectiveWhere?: WhereInput; global?: boolean; table: string } | undefined",a=t?` protected override resolveShape(name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): ${n} {
|
|
1012
1012
|
const sensitive = this.openSensitiveScope(\`__shape__:\${name}\`, args);
|
|
1013
1013
|
|
|
1014
1014
|
try {
|
|
@@ -1020,7 +1020,7 @@ __PREPARE_FUNCTION__ this.ensureServable();
|
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
|
-
private resolveShapeWithScope(name: string, args: Record<string, unknown>, identity: SubscriptionIdentity | undefined, sensitive: SensitiveScope): ${n} {`:` protected override resolveShape(name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): ${n} {`,
|
|
1023
|
+
private resolveShapeWithScope(name: string, args: Record<string, unknown>, identity: SubscriptionIdentity | undefined, sensitive: SensitiveScope): ${n} {`:` protected override resolveShape(name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): ${n} {`,f=e?`
|
|
1024
1024
|
${a}
|
|
1025
1025
|
const shape = LUNORA_SHAPES[name];
|
|
1026
1026
|
|
|
@@ -1083,14 +1083,14 @@ ${a}
|
|
|
1083
1083
|
|
|
1084
1084
|
return { ...(shape.columns === undefined ? {} : { columns: shape.columns }), effectiveWhere, global: isGlobal, table: shape.table };
|
|
1085
1085
|
}
|
|
1086
|
-
`:"",
|
|
1086
|
+
`:"",c=e?[...new Set(o.policies.filter(l=>l.on==="read"&&l.table!=="").map(l=>l.table))].toSorted((l,O)=>l.localeCompare(O)):[],g=c.length>0?`
|
|
1087
1087
|
/** Refuses to boot a shape that would replicate around the read policies its table is governed by (\`defineShape({ use })\` is how a shape opts in; \`use: []\` acknowledges an ungoverned one). */
|
|
1088
|
-
assertShapesDeclareReadPolicies(LUNORA_SHAPES, ${JSON.stringify(
|
|
1088
|
+
assertShapesDeclareReadPolicies(LUNORA_SHAPES, ${JSON.stringify(c)}, (schema as unknown as { rlsMode?: string }).rlsMode === "required");
|
|
1089
1089
|
`:"";return{customMutatorOverride:r?`
|
|
1090
1090
|
protected override isCustomMutator(functionPath: string): boolean {
|
|
1091
1091
|
return LUNORA_MUTATOR_PATHS.has(functionPath);
|
|
1092
1092
|
}
|
|
1093
|
-
`:"",shapeGuardImport:e?"assertShapeShardable, ":"",shapeReadPolicyAssertion:
|
|
1093
|
+
`:"",shapeGuardImport:e?"assertShapeShardable, ":"",shapeReadPolicyAssertion:g,shapeReadPolicyImport:g===""?"":"assertShapesDeclareReadPolicies, ",shapeResolveOverride:f}},Jr=(r,t)=>r?`
|
|
1094
1094
|
protected override async readGlobalShapeRows(resolved: { columns?: readonly string[]; effectiveWhere?: WhereInput; global?: boolean; table: string }, identity?: SubscriptionIdentity): Promise<Array<{ doc: Record<string, unknown>; id: string }>> {
|
|
1095
1095
|
const env = this.env as Record<string, unknown>;
|
|
1096
1096
|
// A shape read performs no writes, so the widened request only needs
|
|
@@ -1156,7 +1156,7 @@ assertShapesDeclareReadPolicies(LUNORA_SHAPES, ${JSON.stringify(h)}, (schema as
|
|
|
1156
1156
|
|
|
1157
1157
|
return globalDb.cdcChangedTables?.(sinceSeq, cursorOnly === undefined ? {} : { cursorOnly });
|
|
1158
1158
|
}
|
|
1159
|
-
`:"",
|
|
1159
|
+
`:"",Yr=r=>({externalSourceOverride:r?`
|
|
1160
1160
|
protected override async pollExternalSources(trace?: TraceRefLike): Promise<number | undefined> {
|
|
1161
1161
|
const env = (this.env ?? {}) as Record<string, unknown>;
|
|
1162
1162
|
const sourced = Object.entries((schema as unknown as SchemaLike).tables)
|
|
@@ -1313,8 +1313,8 @@ assertShapesDeclareReadPolicies(LUNORA_SHAPES, ${JSON.stringify(h)}, (schema as
|
|
|
1313
1313
|
`:"",sourceClientCacheConst:r?`
|
|
1314
1314
|
const sourceClientCache = new WeakMap<object, Map<string, SourceClientLike>>();
|
|
1315
1315
|
const sourcePollAtCache = new WeakMap<object, Map<string, number>>();
|
|
1316
|
-
`:""}),
|
|
1317
|
-
`:"",i=e?"namespace: vectorShardKey === ROOT_SHARD_NAME ? undefined : vectorShardKey, ":"",
|
|
1316
|
+
`:""}),Xr=(r,t)=>{const e=t.length>0,n=r?q("vectorsStub: VectorSearchLike","ctx.vectors: no vectors configured. Pass `vectors` to createShardDO().",["deleteByIds","getByIds","query","upsert","upsertMany","upsertNow"]):"",a=e?` const vectorShardKey = this.currentShardKey();
|
|
1317
|
+
`:"",i=e?"namespace: vectorShardKey === ROOT_SHARD_NAME ? undefined : vectorShardKey, ":"",c=`, { ${["deferAfterCommit: (work) => this.deferAfterCommit(work)",...e?["namespace: vectorShardKey === ROOT_SHARD_NAME ? undefined : vectorShardKey",`shardedIndexNames: [${t.map(w=>JSON.stringify(w)).join(", ")}]`]:[]].join(", ")} }`,g=r?`
|
|
1318
1318
|
const vectorSync = this.vectorSync(env);
|
|
1319
1319
|
// Vectorize lives outside this shard's SQLite, so a query whose result
|
|
1320
1320
|
// depends on a similarity search cannot be proven current on reconnect —
|
|
@@ -1331,7 +1331,7 @@ const sourcePollAtCache = new WeakMap<object, Map<string, number>>();
|
|
|
1331
1331
|
}
|
|
1332
1332
|
|
|
1333
1333
|
const lunora = createVectors({ indexes: config.vectors(env) });
|
|
1334
|
-
${a} const vectors = createContextVectors(lunora${
|
|
1334
|
+
${a} const vectors = createContextVectors(lunora${c});
|
|
1335
1335
|
|
|
1336
1336
|
return {
|
|
1337
1337
|
backfill: createVectorBackfillSync({ ${i}schema: schema as unknown as VectorSchemaLike, upsertMany: lunora.upsertMany, vectors }),
|
|
@@ -1357,14 +1357,14 @@ ${a} const vectors = createContextVectors(lunora${h});
|
|
|
1357
1357
|
ordered: async (read, work) => this.runOrderedAfterWrites(read, work),
|
|
1358
1358
|
});
|
|
1359
1359
|
}
|
|
1360
|
-
`:"",vectorsBuild:
|
|
1360
|
+
`:"",vectorsBuild:g,vectorsStub:n}},bn=({advisories:r=[],agents:t=[],capabilities:e=new Set,containers:o=[],env:n,flagKeys:a=[],hasFlags:i=!1,hasNotify:f=!1,hasRooms:c=!1,hasSecretValues:g=!1,hasSensitiveArgs:A=!1,hasSockets:w=!1,lazyFunctions:u=!1,hasVectors:l=!0,liveStreamDeclarations:O=[],liveStreams:v=!1,maskMetadata:F,mutators:U=[],queues:R=[],rlsMetadata:B,schema:d,schemaSnapshot:k,shapes:I=[],storageRules:j,studioFeatures:W,hasIpReaders:E=!1,services:T=[],topics:K=[],useUmbrella:H=!1,workflowEvents:C=[],workflows:x=[]})=>{const h=Dr(H),V=U.length>0,p=I.length>0,L=I.some(s=>Rr(s.args).length>0),G=A||L,ge=k===void 0?"":Zt(k),be=k===void 0?"":`
|
|
1361
1361
|
/** Structural schema snapshot + its content hash, recorded in the shard's \`__lunora_schema_history\` ledger on cold start so the studio can show a schema-version timeline and diff any two versions. */
|
|
1362
|
-
const LUNORA_SCHEMA_SNAPSHOT: { hash: string; json: string } = { hash: ${JSON.stringify(
|
|
1363
|
-
`,
|
|
1364
|
-
return { ${
|
|
1362
|
+
const LUNORA_SCHEMA_SNAPSHOT: { hash: string; json: string } = { hash: ${JSON.stringify(er(k))}, json: ${JSON.stringify(ge)} };
|
|
1363
|
+
`,ye=k===void 0?"":", schemaSnapshot: LUNORA_SCHEMA_SNAPSHOT",S=ar(e),P=sr(i,h.flags),Q=or(a,i,h.flags),z=kr(f),J=ir(n),{build:we,contextField:ve,importLines:ke,specs:Se}=dr(_r(R)),{build:Re,contextField:xe,importLines:Ae,specs:Oe}=cr(K,R),Y=lr(T,h.server),{build:Te,contextField:De,importLines:_e,specs:Ie}=ur(o,d.jurisdiction),{build:Ee,contextField:Ce,importLines:Le,specs:Pe}=hr(x),{build:Ne,contextField:$e,importLines:qe,schedulerSource:Me,specs:Fe,stampsOutbox:Ue}=pr(t,g&&t.length>0),{build:Be,configField:je,contextField:We,imports:Ke,stub:He}=mr(e.has("payments")),Ve=r,{advisoryRules:Ge,advisoryRows:Qe}=Er(Ve),ne=B??{policies:[],roles:[]},ze=F??{columns:[]},Je=j??{rules:[]},Ye=W??{analytics:!1,auth:!1,containers:!1,flags:!1,kv:!1,mail:!1,notifications:!1,payments:!1,privacy:!1,queues:!1,scheduler:!1,storage:!1,vectors:!1,workflows:!1},{constant:Xe,override:Ze}=fr(x,C),{constant:et,override:tt}=gr(x,C),{constant:rt,override:nt}=br(R),b=l&&d.vectorIndexes.length>0,X=new Set(d.tables.filter(s=>Ir(s)).map(s=>s.name)),ae=b&&d.vectorIndexes.some(s=>X.has(s.table)),D=d.tables.some(s=>s.shardMode==="global"),Z=yr(X),ee=d.tables.some(s=>tr(s)),se=d.tables.some(s=>rr(s)),N=d.tables.some(s=>s.externalSource!==void 0),oe=d.tables.some(s=>s.memory===!0),te=d.tables.some(s=>s.shardMode!=="global"&&s.searchIndexes.length>0);if(se&&ee)throw new pe("INTERNAL",'lunora codegen: mixing `.global()` (D1) and `.global({ backend: "hyperdrive" })` tables in one app is not supported yet — use a single global backend.');const re=d.tables.length>0,at=Ur(d),st=jr(d),ot=Qr(d),it=Br(d),ie=Wr(d),de=wr(b,x.length>0,R.length>0,i,te);p&&de.push("WhereInput");const ce=vr(D),{customMutatorOverride:dt,shapeGuardImport:ct,shapeReadPolicyAssertion:lt,shapeReadPolicyImport:ut,shapeResolveOverride:ht}=zr({hasMutators:V,hasSensitiveShapes:L,hasShapes:p,rlsData:ne}),_=v?O:[];for(const s of _)if(xr(s.exportName,"live stream export name"),!Ar.test(s.filePath))throw new pe("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe live stream file path: ${JSON.stringify(s.filePath)}`);const pt=u?[]:_.map(s=>`import { ${s.exportName} as liveStream_${s.exportName} } from "../${s.filePath}.js";`),mt=` protected override liveStreams() {
|
|
1364
|
+
return { ${_.map(s=>`${Or(s.id)}: liveStream_${s.exportName}`).join(", ")} };
|
|
1365
1365
|
}
|
|
1366
|
-
`,
|
|
1367
|
-
${
|
|
1366
|
+
`,ft=` private readonly liveStreamLoaders = new Map<string, () => Promise<{ validatePublish: (topic: string, payload: unknown) => unknown }>>([
|
|
1367
|
+
${_.map(s=>` [${JSON.stringify(s.id)}, () => import("../${s.filePath}.js").then((module) => module.${s.exportName})],`).join(`
|
|
1368
1368
|
`)}
|
|
1369
1369
|
]);
|
|
1370
1370
|
|
|
@@ -1385,11 +1385,11 @@ ${I.map(s=>` [${JSON.stringify(s.id)}, () => import("../${s.filePath}
|
|
|
1385
1385
|
protected override liveStreams() {
|
|
1386
1386
|
return Object.fromEntries(this.loadedLiveStreams);
|
|
1387
1387
|
}
|
|
1388
|
-
`;let
|
|
1389
|
-
vectors?: (env: Record<string, unknown>) => Record<string, VectorizeIndexLike>;`:"",
|
|
1390
|
-
d1?: (env: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onBookmark?: (bookmark: string | undefined) => void; userId?: string | undefined }) => DatabaseWriterLike | undefined;`:"",
|
|
1391
|
-
hyperdriveGlobal?: (env: Record<string, unknown>, request?: { cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; userId?: string | undefined }) => DatabaseWriterLike | undefined;`:"",
|
|
1392
|
-
sourceClient?: (env: Record<string, unknown>, binding: string) => { query: <Row = Record<string, unknown>>(text: string, params?: readonly unknown[]) => Promise<Row[]> } | undefined;`:"",
|
|
1388
|
+
`;let le="";_.length>0&&(le=u?ft:mt);const $=[`import type { ${de.join(", ")} } from "${h.do}";`,`import { applyCdcChanges, createStableIdFactory, createStableRandomFactory, ${te?"backfillSearchIndexes, ":""}${b?"backfillVectorIndexes, ":""}buildReprojectionMigration, ${oe?"clearMemoryTables, ":""}${ct}createReadFootprint, createShardCtxDb, exportShardRows, importShardRows, ${N?"isSourceDue, pullExternalSourceIncrementalTick, pullExternalSourceTick, ":""}markUnvouchableReads, ${ae?"ROOT_SHARD_NAME, ":""}runDataMigration, runShardMigrations, ${ce.importFragment}ShardDO as ShardDOBase } from "${h.do}";`,...N?[`import type { ExternalSourceLike, SourceClientLike, TraceRefLike } from "${h.do}";`]:[],p?`import { asBucketStorage, ${ut}beginDeferredDeletes, beginDeferredSchedules, composeShapeReadWhere, createSecrets, flushDeferredDeletes, LunoraError, withDeferredDeletes, withDeferredSchedules } from "${h.server}";`:`import { asBucketStorage, beginDeferredDeletes, beginDeferredSchedules, createSecrets, flushDeferredDeletes, LunoraError, withDeferredDeletes, withDeferredSchedules } from "${h.server}";`];re&&$.push(`import type { FacadeEntry } from "${h.server}";`,`import { bindOrm, defineLazyFacade } from "${h.server}";`),b&&$.push('import type { SchemaLike as VectorSchemaLike, VectorBackfillSync, VectorizeIndexLike, VectorSearchLike } from "@lunora/bindings/vectors";','import { createContextVectors, createVectorBackfillSync, createVectors, createVectorSyncHook, vectorBackfillTargets } from "@lunora/bindings/vectors";'),$.push(...S.importLines,...P.importLines,...z.importLines,...J.importLines,..._e,...Le,...ke,...Ae,...Y.importLines,...qe,...Ke,...G?[`import { sensitiveArgumentNames } from "${h.values}";`]:[],"",'import schema from "../schema.js";',...pt,`import { ${["LUNORA_FUNCTIONS","LUNORA_LIFECYCLE_HOOKS","LUNORA_MIGRATIONS",...u?["getLoadedFunction","loadFunction"]:[],...V?["LUNORA_MUTATOR_PATHS"]:[],...E?["LUNORA_IP_READER_PATHS"]:[],...c?["LUNORA_ROOMS"]:[],...w?["LUNORA_SOCKETS"]:[],...p?["LUNORA_SHAPES"]:[]].join(", ")} } from "./functions.js";`);const gt=b?`
|
|
1389
|
+
vectors?: (env: Record<string, unknown>) => Record<string, VectorizeIndexLike>;`:"",bt=se?`
|
|
1390
|
+
d1?: (env: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; onBookmark?: (bookmark: string | undefined) => void; userId?: string | undefined }) => DatabaseWriterLike | undefined;`:"",yt=ee?`
|
|
1391
|
+
hyperdriveGlobal?: (env: Record<string, unknown>, request?: { cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown> | undefined; userId?: string | undefined }) => DatabaseWriterLike | undefined;`:"",wt=N?`
|
|
1392
|
+
sourceClient?: (env: Record<string, unknown>, binding: string) => { query: <Row = Record<string, unknown>>(text: string, params?: readonly unknown[]) => Promise<Row[]> } | undefined;`:"",vt="ctx.db.<globalTable>: no global backend configured. Pass `d1` or `hyperdriveGlobal` to createShardDO().",kt="ctx.scheduler: no scheduler configured. Pass `scheduler` to createShardDO().",St="ctx.storage: no storage configured. Pass `storage` to createShardDO().",Rt=D?q("globalDbStub: DatabaseWriterLike",vt,["aggregate","count","delete","explain","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","normalizeId","patch","query","rank","rankPage","replace"],{sync:["normalizeId","query"]}):"",{vectorSyncMethod:xt,vectorsBuild:At,vectorsStub:Ot}=Xr(b,ae?d.vectorIndexes.filter(s=>X.has(s.table)).map(s=>s.name):[]),Tt=`{
|
|
1393
1393
|
...this.ctxDbTuning(),
|
|
1394
1394
|
auth: {
|
|
1395
1395
|
get identity() {
|
|
@@ -1436,7 +1436,7 @@ ${I.map(s=>` [${JSON.stringify(s.id)}, () => import("../${s.filePath}
|
|
|
1436
1436
|
// fallback rather than reporting into a no-op.
|
|
1437
1437
|
...(options.onReadRange !== undefined
|
|
1438
1438
|
? { onReadRange: options.onReadRange }
|
|
1439
|
-
: options.scope === undefined ? {} : { onReadRange: this.getCtxDbReadRangeHook(options.scope) }),${
|
|
1439
|
+
: options.scope === undefined ? {} : { onReadRange: this.getCtxDbReadRangeHook(options.scope) }),${b?`
|
|
1440
1440
|
// Vectorize is outside this shard's SQLite and cannot roll back, so
|
|
1441
1441
|
// the sync is held until the mutation's transaction has COMMITTED
|
|
1442
1442
|
// (\`deferAfterCommit\`) instead of running inline. Inline, a write
|
|
@@ -1448,11 +1448,11 @@ ${I.map(s=>` [${JSON.stringify(s.id)}, () => import("../${s.filePath}
|
|
|
1448
1448
|
scheduler,
|
|
1449
1449
|
schema: schema as unknown as SchemaLike,
|
|
1450
1450
|
sql: this.sql as SqlExec,
|
|
1451
|
-
storage,${
|
|
1451
|
+
storage,${D?`
|
|
1452
1452
|
globalDb,`:""}
|
|
1453
|
-
}`,
|
|
1454
|
-
vectors,`:"",
|
|
1455
|
-
orm: bindOrm(facade),`:"",
|
|
1453
|
+
}`,Dt=b?`
|
|
1454
|
+
vectors,`:"",_t=re?`
|
|
1455
|
+
orm: bindOrm(facade),`:"",ue=ee?"config.hyperdriveGlobal":"config.d1",It=D?` const bookmark = this.getInboundBookmark();
|
|
1456
1456
|
const globalRequest = {
|
|
1457
1457
|
...this.globalCdcOptions(config.cdc ?? false),
|
|
1458
1458
|
...(bookmark === undefined ? {} : { bookmark }),
|
|
@@ -1464,21 +1464,21 @@ ${I.map(s=>` [${JSON.stringify(s.id)}, () => import("../${s.filePath}
|
|
|
1464
1464
|
return readUserId();
|
|
1465
1465
|
},
|
|
1466
1466
|
};
|
|
1467
|
-
const globalDb: DatabaseWriterLike = ${
|
|
1468
|
-
`:"",
|
|
1467
|
+
const globalDb: DatabaseWriterLike = ${ue}?.(env, globalRequest) ?? globalDbStub;
|
|
1468
|
+
`:"",Et=Jr(p&&D,ue),Ct=c?` protected override roomHandlerPath(topic: string): string | undefined {
|
|
1469
1469
|
// Own properties only: a plain object would resolve \`toString\` and the like to inherited functions.
|
|
1470
1470
|
return Object.hasOwn(LUNORA_ROOMS, topic) ? LUNORA_ROOMS[topic] : undefined;
|
|
1471
1471
|
}
|
|
1472
|
-
`:"",
|
|
1472
|
+
`:"",Lt=w?` protected override socketRoute(path: string): { auth: boolean; functionPath: string } | undefined {
|
|
1473
1473
|
return LUNORA_SOCKETS[path];
|
|
1474
1474
|
}
|
|
1475
|
-
`:"",{externalSourceOverride
|
|
1475
|
+
`:"",{externalSourceOverride:Pt,sourceBootstrap:Nt,sourceClientCacheConst:$t}=Yr(N),qt=`
|
|
1476
1476
|
private shardInitDeferred = false;
|
|
1477
1477
|
private deferredShardInit?: Promise<void>;
|
|
1478
1478
|
|
|
1479
1479
|
protected override async runShardInit(): Promise<void> {
|
|
1480
1480
|
this.ensureMigrated();
|
|
1481
|
-
${
|
|
1481
|
+
${oe?` clearMemoryTables(this.sql as SqlExec, schema as unknown as SchemaLike);
|
|
1482
1482
|
`:""}
|
|
1483
1483
|
if (this.blockedUniqueIndexes.length > 0) {
|
|
1484
1484
|
this.shardInitDeferred = true;
|
|
@@ -1518,11 +1518,11 @@ ${ie?` clearMemoryTables(this.sql as SqlExec, schema as unknown as Sc
|
|
|
1518
1518
|
|
|
1519
1519
|
await this.deferredShardInit;
|
|
1520
1520
|
}
|
|
1521
|
-
`,
|
|
1521
|
+
`,Mt=ie.length>0?`
|
|
1522
1522
|
if (LUNORA_TTL_SWEEPS.length > 0) {
|
|
1523
1523
|
void this.scheduleTtlSweep();
|
|
1524
1524
|
}
|
|
1525
|
-
`:"",
|
|
1525
|
+
`:"",Ft=`
|
|
1526
1526
|
public constructor(state: ShardDOState, env: unknown) {
|
|
1527
1527
|
super(state, env, {
|
|
1528
1528
|
// Every writer this file builds spreads the ctxDbTuning() slice —
|
|
@@ -1539,10 +1539,10 @@ ${ie?` clearMemoryTables(this.sql as SqlExec, schema as unknown as Sc
|
|
|
1539
1539
|
// exists — a trigger that fails first still flushes and fuses.
|
|
1540
1540
|
...(config.observability === undefined ? {} : { telemetrySink: () => config.observability?.((env ?? {}) as Record<string, unknown>) }),
|
|
1541
1541
|
});
|
|
1542
|
-
${
|
|
1542
|
+
${E?` for (const path of LUNORA_IP_READER_PATHS) {
|
|
1543
1543
|
this.ipKeyedFunctionPaths.add(path);
|
|
1544
1544
|
}
|
|
1545
|
-
`:""}${
|
|
1545
|
+
`:""}${Nt}${Mt} }
|
|
1546
1546
|
|
|
1547
1547
|
protected override isCacheableQuery(functionPath: string): boolean {
|
|
1548
1548
|
// NOT \`kind === "query"\` alone. A cache hit answers without running
|
|
@@ -1566,7 +1566,7 @@ ${D?` for (const path of LUNORA_IP_READER_PATHS) {
|
|
|
1566
1566
|
protected override isPaidFunction(functionPath: string): boolean {
|
|
1567
1567
|
return LUNORA_FUNCTIONS[functionPath]?.x402 !== undefined;
|
|
1568
1568
|
}
|
|
1569
|
-
`,
|
|
1569
|
+
`,he=u?`
|
|
1570
1570
|
protected override prepareFunction(functionPath: string, reason: "rpc" | "subscription" | "stream" | "reactor"): Promise<void> | undefined {
|
|
1571
1571
|
const registered = LUNORA_FUNCTIONS[functionPath];
|
|
1572
1572
|
const allowsInternal = reason === "reactor" || (reason === "rpc" && this.isSystemDispatch());
|
|
@@ -1581,14 +1581,14 @@ ${D?` for (const path of LUNORA_IP_READER_PATHS) {
|
|
|
1581
1581
|
|
|
1582
1582
|
return this.holdShardWhileLoading(() => loadFunction(functionPath));
|
|
1583
1583
|
}
|
|
1584
|
-
`:"",
|
|
1584
|
+
`:"",Ut=he===""?`
|
|
1585
1585
|
|
|
1586
|
-
`:`${
|
|
1587
|
-
`,
|
|
1586
|
+
`:`${he}
|
|
1587
|
+
`,Bt=G?`
|
|
1588
1588
|
protected override sensitiveArgNames(functionPath: string): ReadonlySet<string> {
|
|
1589
|
-
const registered = LUNORA_FUNCTIONS[functionPath];${
|
|
1589
|
+
const registered = LUNORA_FUNCTIONS[functionPath];${L?`
|
|
1590
1590
|
const shape = functionPath.startsWith("__shape__:") ? LUNORA_SHAPES[functionPath.slice("__shape__:".length)] : undefined;`:""}
|
|
1591
|
-
const fromValidators = sensitiveArgumentNames(registered?.args ?? ${
|
|
1591
|
+
const fromValidators = sensitiveArgumentNames(registered?.args ?? ${L?"shape?.args ?? ":""}{});
|
|
1592
1592
|
|
|
1593
1593
|
if (registered?.sensitiveArgs === undefined) {
|
|
1594
1594
|
return fromValidators;
|
|
@@ -1597,22 +1597,22 @@ ${D?` for (const path of LUNORA_IP_READER_PATHS) {
|
|
|
1597
1597
|
return new Set([...registered.sensitiveArgs, ...fromValidators]);
|
|
1598
1598
|
}
|
|
1599
1599
|
|
|
1600
|
-
`:"",
|
|
1600
|
+
`:"",jt=Nr(u),Wt=u?` const preparation = this.prepareFunction(functionPath, "subscription");
|
|
1601
1601
|
if (preparation !== undefined) await preparation;
|
|
1602
|
-
`:"",
|
|
1602
|
+
`:"",Kt=qr.replace("__PREPARE_FUNCTION__",Wt),Ht=Fr(c,u,Ue),Vt=re?`
|
|
1603
1603
|
const facade = db as unknown as Record<string, FacadeEntry>;
|
|
1604
|
-
${
|
|
1604
|
+
${d.tables.map(s=>` defineLazyFacade(db, ${JSON.stringify(s.name)});`).join(`
|
|
1605
1605
|
`)}
|
|
1606
|
-
`:"",
|
|
1606
|
+
`:"",Gt=`${S.everyBuild}${P.build}${J.build}
|
|
1607
1607
|
const secrets = createSecrets(env);
|
|
1608
|
-
`,
|
|
1609
|
-
secrets,`,
|
|
1608
|
+
`,Qt=`${S.everyFields}${P.contextField}${z.contextField}${J.contextField}
|
|
1609
|
+
secrets,`,zt=z.build,Jt=v?`
|
|
1610
1610
|
const live = {
|
|
1611
1611
|
publish: async (ref: { __lunoraLive: string; topic: string }, payload: unknown, publishOptions?: { shardKey?: string }): Promise<void> => {
|
|
1612
1612
|
await this.publishLiveFromAction(ref.topic, payload, { ...publishOptions, stream: ref.__lunoraLive });
|
|
1613
1613
|
},
|
|
1614
1614
|
};
|
|
1615
|
-
`:"",
|
|
1615
|
+
`:"",Yt=[...S.actionFields,...T.length>0?["services"]:[],...v?["live"]:[]],Xt=`${S.actionBuild}${Y.build}${Jt}`;return`${Tr}${$.join(`
|
|
1616
1616
|
`)}
|
|
1617
1617
|
|
|
1618
1618
|
type FunctionKind = "action" | "mutation" | "query";
|
|
@@ -1622,13 +1622,13 @@ interface FunctionReference {
|
|
|
1622
1622
|
}
|
|
1623
1623
|
|
|
1624
1624
|
/** Foreign-key columns per table (\`v.id("target")\` fields) for the data browser. */
|
|
1625
|
-
const LUNORA_TABLE_REFS = ${
|
|
1625
|
+
const LUNORA_TABLE_REFS = ${m(at,"Record<string, Record<string, string>>")};
|
|
1626
1626
|
|
|
1627
1627
|
/** Declared indexes per table (secondary, search, geo, rank, vector) for the schema viewer. */
|
|
1628
|
-
const LUNORA_TABLE_INDEXES = ${
|
|
1628
|
+
const LUNORA_TABLE_INDEXES = ${m(st,'Record<string, Array<{ fields: string[]; name: string; type: "geo" | "index" | "rank" | "search" | "vector"; unique?: boolean }>>')};
|
|
1629
1629
|
|
|
1630
1630
|
/** Columns per table (typed, with PK/FK markers) for the studio's schema diagram, served via \`__lunora_admin__:describeTable\`. */
|
|
1631
|
-
const LUNORA_TABLE_COLUMNS = ${
|
|
1631
|
+
const LUNORA_TABLE_COLUMNS = ${m(ot,`Record<
|
|
1632
1632
|
string,
|
|
1633
1633
|
Array<{
|
|
1634
1634
|
bucket?: string;
|
|
@@ -1645,40 +1645,37 @@ const LUNORA_TABLE_COLUMNS = ${p(dt,`Record<
|
|
|
1645
1645
|
>`)};
|
|
1646
1646
|
|
|
1647
1647
|
/** Storage-key columns per table (\`v.storage(...)\` fields) for the file browser's records↔files join. */
|
|
1648
|
-
const LUNORA_STORAGE_COLUMNS = ${
|
|
1648
|
+
const LUNORA_STORAGE_COLUMNS = ${m(it,"Record<string, string[]>")};
|
|
1649
1649
|
|
|
1650
1650
|
/** Declarative TTL policies (\`.ttl(field, { after? })\`) the DO alarm sweep auto-expires rows for. */
|
|
1651
|
-
const LUNORA_TTL_SWEEPS = ${
|
|
1651
|
+
const LUNORA_TTL_SWEEPS = ${nr(ie,"Array<{ after?: number; field: string; softDeleteField?: string; table: string }>")};
|
|
1652
1652
|
|
|
1653
1653
|
/** Static schema advisories (computed by @lunora/advisor at codegen time) served via \`__lunora_admin__:getAdvisories\`. */
|
|
1654
|
-
const LUNORA_ADVISORY_RULES = ${
|
|
1654
|
+
const LUNORA_ADVISORY_RULES = ${m(Ge,"Record<string, Partial<AdvisoryFinding>>")};
|
|
1655
1655
|
|
|
1656
1656
|
/** Per-finding rows; rule-level text lives once in \`LUNORA_ADVISORY_RULES\` and is merged back on first read. */
|
|
1657
|
-
const LUNORA_ADVISORY_ROWS = ${
|
|
1657
|
+
const LUNORA_ADVISORY_ROWS = ${m(Qe,"Array<Partial<AdvisoryFinding> & { name: string }>")};
|
|
1658
1658
|
|
|
1659
1659
|
const LUNORA_ADVISORIES = ((): (() => AdvisoryFinding[]) => {
|
|
1660
1660
|
let cached: AdvisoryFinding[] | undefined;
|
|
1661
1661
|
return () => (cached ??= LUNORA_ADVISORY_ROWS().map((row) => ({ ...LUNORA_ADVISORY_RULES()[row.name], ...row }) as AdvisoryFinding));
|
|
1662
1662
|
})();
|
|
1663
1663
|
|
|
1664
|
-
/** Every declared procedure (discovered by @lunora/codegen) served via \`__lunora_admin__:getAdvisorProcedures\` — the health map's denominator. */
|
|
1665
|
-
const LUNORA_ADVISOR_PROCEDURES = ${p(Je,"AdvisorProcedure[]")};
|
|
1666
|
-
|
|
1667
1664
|
/** Read-only RLS metadata (policies + roles discovered from \`.use(rls(...))\` chains) served via \`__lunora_admin__:rlsPolicies\` for the studio's RLS inspector. */
|
|
1668
|
-
const LUNORA_RLS_METADATA = ${
|
|
1669
|
-
${
|
|
1665
|
+
const LUNORA_RLS_METADATA = ${m(ne,"RlsPoliciesResult")};
|
|
1666
|
+
${lt}
|
|
1670
1667
|
/** Read-only masking metadata (table + column + strategy discovered from \`.use(mask(...))\` chains) served via \`__lunora_admin__:maskPolicies\` for the studio's data-browser mask preview. */
|
|
1671
|
-
const LUNORA_MASK_METADATA = ${
|
|
1668
|
+
const LUNORA_MASK_METADATA = ${m(ze,"MaskPoliciesResult")};
|
|
1672
1669
|
|
|
1673
1670
|
/** Read-only storage access-rule metadata (discovered from \`.use(storageRules(...))\` chains) served via \`__lunora_admin__:storageRules\` for the studio's access-rules view. */
|
|
1674
|
-
const LUNORA_STORAGE_RULES = ${
|
|
1671
|
+
const LUNORA_STORAGE_RULES = ${m(Je,"StorageRulesResult")};
|
|
1675
1672
|
|
|
1676
1673
|
/** Which optional package-backed features this app wires up (discovered from imports / \`ctx.*\` reads / schema signals) served via \`__lunora_admin__:studioFeatures\` so the studio hides nav pages whose package isn't enabled. */
|
|
1677
|
-
const LUNORA_STUDIO_FEATURES = ${
|
|
1674
|
+
const LUNORA_STUDIO_FEATURES = ${m(Ye,"StudioFeaturesResult")};
|
|
1678
1675
|
|
|
1679
1676
|
/** How long a shard with a UNIQUE index blocked by duplicate rows serves the cached diagnostic before re-attempting the build. */
|
|
1680
1677
|
const BLOCKED_MIGRATION_RETRY_MS = 5000;
|
|
1681
|
-
${
|
|
1678
|
+
${be}${Z.constant}${Q.constant}${Xe}${et}${rt}${Ie}${Pe}${Se}${Oe}${Y.specs}${Fe}
|
|
1682
1679
|
export interface ShardDOConfig {
|
|
1683
1680
|
/** Opt into change-data-capture: records a post-image to \`__cdc_log\` on every write (backs streaming export + replay-PITR). */
|
|
1684
1681
|
cdc?: boolean;
|
|
@@ -1695,9 +1692,9 @@ export interface ShardDOConfig {
|
|
|
1695
1692
|
/** \`unknown\` because \`@lunora/scheduler\`'s \`Scheduler\` is not assignable to \`SchedulerLike\`; the shard casts it. */
|
|
1696
1693
|
scheduler?: (env: Record<string, unknown>) => unknown;
|
|
1697
1694
|
/** \`origin\` is the origin the current \`/rpc\` request reached the worker on — the fallback base for signed object URLs when no \`publicBaseUrl\` is configured. \`undefined\` off the synchronous dispatch path. */
|
|
1698
|
-
storage?: (env: Record<string, unknown>, origin?: string) => unknown;${
|
|
1695
|
+
storage?: (env: Record<string, unknown>, origin?: string) => unknown;${gt}${S.configFields}${P.configField}${je}${bt}${yt}${wt}${Z.configField}
|
|
1699
1696
|
}
|
|
1700
|
-
${
|
|
1697
|
+
${q("schedulerStub",kt,["cancel","runAfter","runAt"])}${q("storageStub",St,["createMultipartUpload","delete","download","generateUploadUrl","getMetadata","getPresignedUrl","getSignedUrl","getUrl","head","list","resumeMultipartUpload","store","upload"],{sync:["getUrl","resumeMultipartUpload"]})}${Rt}${$t}${Ot}${S.stubs}${He}
|
|
1701
1698
|
// \`ctx.fetch\` is action-only. A query is re-run by every live subscription and a
|
|
1702
1699
|
// mutation may be replayed, so a network call in either returns a different answer
|
|
1703
1700
|
// on each run. Refused at runtime, not only linted: the advisor sees just the call
|
|
@@ -1709,24 +1706,24 @@ const refuseFetch = (): never => {
|
|
|
1709
1706
|
throw new LunoraError("FORBIDDEN", "ctx.fetch is action-only: network I/O belongs in an action, not a query or mutation");
|
|
1710
1707
|
};
|
|
1711
1708
|
|
|
1712
|
-
${
|
|
1709
|
+
${jt}
|
|
1713
1710
|
|
|
1714
1711
|
/**
|
|
1715
1712
|
* Build the project's shard Durable Object. Export the result as \`ShardDO\`
|
|
1716
1713
|
* from the worker entry so wrangler binds it by name.
|
|
1717
1714
|
*/
|
|
1718
1715
|
export const createShardDO = (config: ShardDOConfig = {}): new (state: ShardDOState, env: unknown) => ShardDOBase =>
|
|
1719
|
-
class extends ShardDOBase {${
|
|
1716
|
+
class extends ShardDOBase {${Ft}
|
|
1720
1717
|
private blockedUniqueIndexes: readonly string[] = [];
|
|
1721
1718
|
private migrated = false;
|
|
1722
|
-
private migrationRetryAt = 0;${
|
|
1723
|
-
${
|
|
1724
|
-
${
|
|
1725
|
-
${
|
|
1719
|
+
private migrationRetryAt = 0;${Ut}${Bt}${Ht}
|
|
1720
|
+
${ce.override}
|
|
1721
|
+
${Kt}
|
|
1722
|
+
${dt}${ht}${Et}${Pt}
|
|
1726
1723
|
protected override lifecycleHookPaths(event: "connect" | "disconnect" | "init" | "reactor" | "whisper"): readonly string[] {
|
|
1727
1724
|
return LUNORA_LIFECYCLE_HOOKS[event];
|
|
1728
1725
|
}
|
|
1729
|
-
${
|
|
1726
|
+
${Ct}${Lt}${le}${Z.override}${qt}
|
|
1730
1727
|
// One \`onQueryChange\` dispatch. Mirrors \`executeSubscription\` — the
|
|
1731
1728
|
// socket-terminated half of the same reactivity — and differs only in who
|
|
1732
1729
|
// consumes the result: the base's \`dispatchReactors\` stores the digest as
|
|
@@ -1747,7 +1744,7 @@ ${Pt}${Nt}${ue}${ee.override}${Ut}
|
|
|
1747
1744
|
// would instead run an app's reactor as whichever user happened to write
|
|
1748
1745
|
// last, which is worse than running it as nobody.
|
|
1749
1746
|
protected override async runReactor(functionPath: string, previousDigest?: string): Promise<{ digest: string; ran: boolean; tables: readonly string[] } | undefined> {
|
|
1750
|
-
${
|
|
1747
|
+
${u?` const requestScope = this.captureRequestScope();
|
|
1751
1748
|
const preparation = this.prepareFunction(functionPath, "reactor");
|
|
1752
1749
|
|
|
1753
1750
|
if (preparation !== undefined) {
|
|
@@ -1825,16 +1822,12 @@ ${d?` const requestScope = this.captureRequestScope();
|
|
|
1825
1822
|
protected override studioFeatures(): StudioFeaturesResult {
|
|
1826
1823
|
return LUNORA_STUDIO_FEATURES();
|
|
1827
1824
|
}
|
|
1828
|
-
${
|
|
1825
|
+
${Q.evaluateOverride}${Q.subscriptionOverride}${Ze}${tt}${nt}
|
|
1829
1826
|
protected override advisories(): AdvisoryFinding[] {
|
|
1830
1827
|
return LUNORA_ADVISORIES();
|
|
1831
1828
|
}
|
|
1832
1829
|
|
|
1833
|
-
|
|
1834
|
-
return LUNORA_ADVISOR_PROCEDURES();
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
${Nr}
|
|
1830
|
+
${Lr}
|
|
1838
1831
|
|
|
1839
1832
|
/**
|
|
1840
1833
|
* Migrate the base schema. A UNIQUE index that existing duplicate rows block
|
|
@@ -1859,7 +1852,7 @@ ${Nr}
|
|
|
1859
1852
|
return;
|
|
1860
1853
|
}
|
|
1861
1854
|
|
|
1862
|
-
this.blockedUniqueIndexes = runShardMigrations(this.sql as SqlExec, schema as unknown as SchemaLike, { cdc: config.cdc ?? false, deferBlockedUniqueIndexes: true${
|
|
1855
|
+
this.blockedUniqueIndexes = runShardMigrations(this.sql as SqlExec, schema as unknown as SchemaLike, { cdc: config.cdc ?? false, deferBlockedUniqueIndexes: true${ye} });
|
|
1863
1856
|
this.invalidateCompanionMemo();
|
|
1864
1857
|
this.migrated = this.blockedUniqueIndexes.length === 0;
|
|
1865
1858
|
this.migrationRetryAt = now + BLOCKED_MIGRATION_RETRY_MS;
|
|
@@ -1877,7 +1870,7 @@ ${Nr}
|
|
|
1877
1870
|
throw new LunoraError("UNIQUE_INDEX_DUPLICATES", this.blockedUniqueIndexes.join("; "));
|
|
1878
1871
|
}
|
|
1879
1872
|
}
|
|
1880
|
-
${
|
|
1873
|
+
${te?`
|
|
1881
1874
|
protected override runShardSearchBackfill(options: { maxPages?: number }): SearchBackfillProgress {
|
|
1882
1875
|
// Migrations create the fts5 companions; without them every backfill
|
|
1883
1876
|
// statement would raise "no such table" on a shard that has never
|
|
@@ -1886,7 +1879,7 @@ ${re?`
|
|
|
1886
1879
|
|
|
1887
1880
|
return backfillSearchIndexes(this.sql as SqlExec, schema as unknown as SchemaLike, options);
|
|
1888
1881
|
}
|
|
1889
|
-
`:""}${
|
|
1890
|
-
${
|
|
1882
|
+
`:""}${xt}
|
|
1883
|
+
${Pr({hasSensitiveArgs:G,lazyFunctions:u,actionOnlyFields:Yt,agentsBuild:Ne,agentsContextField:$e,agentsSchedulerSource:Me,containersBuild:Te,containersContextField:De,databaseOptions:Tt,everyContextBuild:Gt,everyContextField:Qt,facadeBlock:Vt,globalDatabaseLine:It,notifyBuild:zt,ormContextField:_t,paymentsBuild:Be,paymentsContextField:We,queuesBuild:we,queuesContextField:ve,topicsBuild:Re,topicsContextField:xe,vectorsBuild:At,vectorsContextField:Dt,workflowsBuild:Ee,workflowsContextField:Ce,actionOnlyBuild:Xt})}
|
|
1891
1884
|
};
|
|
1892
|
-
`};export{
|
|
1885
|
+
`};export{Br as b,bn as e};
|