@lunora/codegen 1.0.0-alpha.393 → 1.0.0-alpha.394
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-Bx2x4Eva.mjs → SCHEMA_SNAPSHOT_FILENAME-B_VaVtUL.mjs} +2 -2
- package/dist/packem_shared/{emitAgents-IN6zekRg.mjs → emitAgents-C-Mfsx39.mjs} +1 -1
- package/dist/packem_shared/{emitApp-Bz0oVnTy.mjs → emitApp-CT3CIMwF.mjs} +26 -26
- package/dist/packem_shared/{emitShard--7JDasb6.mjs → emitShard-CKsjGAn3.mjs} +1 -1
- package/dist/packem_shared/{shard-CVJYK961.mjs → shard-DXVp_Iht.mjs} +109 -107
- package/dist/packem_shared/{shard-runtime-BfamDqXW.mjs → shard-runtime-BHljpfS5.mjs} +35 -35
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LunoraError as
|
|
1
|
+
import{LunoraError as R}from"@lunora/errors";import{r as $}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as S}from"./CAPABILITY_PROBES-BuNEmlCO.mjs";import{a as l,G as f,I as w}from"./shared-DhqnD5R3.mjs";import{s as L}from"./platform-8oj7iXQy.mjs";const M=e=>e?{importFragment:"serveRelationFanout, ",override:`
|
|
2
2
|
protected override async runRelationFanoutRead(functionPath: string, args: Record<string, unknown>): Promise<unknown> {
|
|
3
3
|
this.ensureServable();
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ import{LunoraError as k}from"@lunora/errors";import{r as b}from"./json-data-Chfs
|
|
|
13
13
|
const ${e} = {
|
|
14
14
|
${c}
|
|
15
15
|
}${n};
|
|
16
|
-
`},x={build:"",configField:"",contextField:"",importLines:[],stub:""},
|
|
16
|
+
`},x={build:"",configField:"",contextField:"",importLines:[],stub:""},K=e=>e.size===0?{configField:"",constant:"",override:""}:{configField:"\n /** The `ShardRegistryDO` namespace (typically `env.SHARD_REGISTRY`). This shard registers its key for each `.shardBy()` table it writes, so cross-shard export, sync and migrations reach it. */\n shardRegistry?: (env: Record<string, unknown>) => unknown;",constant:`
|
|
17
17
|
/** The \`.shardBy()\` tables this shard registers with the shard registry when it writes them. */
|
|
18
18
|
const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(r=>JSON.stringify(r)).join(", ")}]);
|
|
19
19
|
`,override:`
|
|
@@ -22,28 +22,28 @@ const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(r=>JSON.string
|
|
|
22
22
|
|
|
23
23
|
return namespace === undefined ? undefined : { namespace, shardedTables: SHARDED_TABLES };
|
|
24
24
|
}
|
|
25
|
-
`},
|
|
25
|
+
`},H=(e,r)=>e?{build:`
|
|
26
26
|
const flags: import("${r}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
27
27
|
provider: () => config.flags?.(env),
|
|
28
28
|
targetingKey: () => flagsConfig.identify?.({ identity: readIdentity() ?? null, userId: readUserId() ?? null }),
|
|
29
29
|
});
|
|
30
30
|
`,configField:`
|
|
31
31
|
flags?: (env: Record<string, unknown>) => import("${r}").Provider;`,contextField:`
|
|
32
|
-
flags,`,importLines:[`import { createFlags } from "${r}";`,'import flagsConfig from "../flags.js";'],stub:""}:x,
|
|
32
|
+
flags,`,importLines:[`import { createFlags } from "${r}";`,'import flagsConfig from "../flags.js";'],stub:""}:x,G=e=>e?{build:`
|
|
33
33
|
const { notify, push } = createNotify(notifyConfig, env, { log, metrics });
|
|
34
34
|
`,configField:"",contextField:`
|
|
35
35
|
notify,
|
|
36
|
-
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:x,
|
|
36
|
+
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:x,V=e=>e?{build:`
|
|
37
37
|
const envConfig = lunoraEnvContract.${e.exportName}(env);
|
|
38
38
|
`,configField:"",contextField:`
|
|
39
|
-
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:x,
|
|
39
|
+
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:x,J=(e,r,t)=>{if(!r)return{constant:"",evaluateOverride:"",subscriptionOverride:""};const n=a=>`
|
|
40
40
|
const env = (this.env ?? {}) as Record<string, unknown>;
|
|
41
41
|
const flags: import("${t}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
42
42
|
provider: () => config.flags?.(env),
|
|
43
43
|
targetingKey: ${a},
|
|
44
44
|
});`,s=`
|
|
45
45
|
/** Statically-discovered feature flags (\`ctx.flags.<type>("key")\` reads) served via \`__lunora_admin__:listFlags\` + the reactive \`__lunora_flags__:\` channel. */
|
|
46
|
-
const LUNORA_FLAG_KEYS = ${
|
|
46
|
+
const LUNORA_FLAG_KEYS = ${$(e,'ReadonlyArray<{ key: string; type: "boolean" | "number" | "object" | "string" }>')};
|
|
47
47
|
`,c=`
|
|
48
48
|
protected override async evaluateFlags(context?: Record<string, unknown>): Promise<FlagsResult> {${n("undefined")}
|
|
49
49
|
const evalContext = context as import("${t}").EvaluationContext | undefined;
|
|
@@ -99,7 +99,7 @@ const LUNORA_FLAG_KEYS = ${b(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
99
99
|
|
|
100
100
|
return flags.boolean(key, typeof args.default === "boolean" ? args.default : false, context);
|
|
101
101
|
}
|
|
102
|
-
`;return{constant:s,evaluateOverride:c,subscriptionOverride:u}},
|
|
102
|
+
`;return{constant:s,evaluateOverride:c,subscriptionOverride:u}},A=()=>({build:`
|
|
103
103
|
const aiBinding = config.ai?.(env) ?? (env as Record<string, unknown>).AI;
|
|
104
104
|
// Correlate AI-Gateway-routed calls with the Lunora trace: thread the
|
|
105
105
|
// function path + trace id into createAi, which folds them into the
|
|
@@ -116,9 +116,9 @@ const LUNORA_FLAG_KEYS = ${b(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
116
116
|
telemetry: { metrics, trace },
|
|
117
117
|
});
|
|
118
118
|
`,configField:`
|
|
119
|
-
ai?: (env: Record<string, unknown>) => AiBindingLike;`,importLines:['import type { AiBindingLike, LunoraAi } from "@lunora/ai/create";','import { createAi } from "@lunora/ai/create";'],stub:""}),
|
|
119
|
+
ai?: (env: Record<string, unknown>) => AiBindingLike;`,importLines:['import type { AiBindingLike, LunoraAi } from "@lunora/ai/create";','import { createAi } from "@lunora/ai/create";'],stub:""}),_=()=>({build:`
|
|
120
120
|
const access = lazyAccessFacade(readIdentity, readUserId);
|
|
121
|
-
`,configField:"",importLines:['import { lazyAccessFacade } from "@lunora/cloudflare-access/context";'],stub:""}),
|
|
121
|
+
`,configField:"",importLines:['import { lazyAccessFacade } from "@lunora/cloudflare-access/context";'],stub:""}),C=()=>({build:`
|
|
122
122
|
const r2sqlEnv = env as Record<string, unknown>;
|
|
123
123
|
const r2sqlAccountId = (r2sqlEnv.R2_SQL_ACCOUNT_ID ?? r2sqlEnv.CLOUDFLARE_ACCOUNT_ID) as string | undefined;
|
|
124
124
|
const r2sqlToken = r2sqlEnv.R2_SQL_TOKEN as string | undefined;
|
|
@@ -129,12 +129,12 @@ const LUNORA_FLAG_KEYS = ${b(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
129
129
|
? createR2Sql({ accountId: r2sqlAccountId, apiToken: r2sqlToken, bucket: r2sqlBucket })
|
|
130
130
|
: r2sqlStub;
|
|
131
131
|
`,configField:`
|
|
132
|
-
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:y("r2sqlStub: R2SqlClient","ctx.r2sql: no R2 SQL credentials found. Set `R2_SQL_TOKEN`, `R2_SQL_ACCOUNT_ID` (or `CLOUDFLARE_ACCOUNT_ID`), and `R2_SQL_BUCKET` in your env/.dev.vars, or pass an `r2sql` config thunk to createShardDO().",["describe","explain","from","query","showDatabases","showTables"],{sync:["from"]})}),
|
|
132
|
+
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:y("r2sqlStub: R2SqlClient","ctx.r2sql: no R2 SQL credentials found. Set `R2_SQL_TOKEN`, `R2_SQL_ACCOUNT_ID` (or `CLOUDFLARE_ACCOUNT_ID`), and `R2_SQL_BUCKET` in your env/.dev.vars, or pass an `r2sql` config thunk to createShardDO().",["describe","explain","from","query","showDatabases","showTables"],{sync:["from"]})}),F=()=>({build:`
|
|
133
133
|
const x402: X402Pay = config.x402
|
|
134
134
|
? lazyX402Pay(config.x402(env), { getSecret: (name: string) => secrets.get(name) })
|
|
135
135
|
: x402Stub;
|
|
136
136
|
`,configField:`
|
|
137
|
-
x402?: (env: Record<string, unknown>) => X402PayConfig;`,importLines:['import type { X402Pay, X402PayConfig } from "@lunora/x402/pay";','import { lazyX402Pay } from "@lunora/x402/pay";'],stub:y("x402Stub: X402Pay","ctx.x402: no pay rail configured. Pass `x402` to createShardDO().",["fetch"],{cast:" as unknown as X402Pay",sync:["fetch"]})}),
|
|
137
|
+
x402?: (env: Record<string, unknown>) => X402PayConfig;`,importLines:['import type { X402Pay, X402PayConfig } from "@lunora/x402/pay";','import { lazyX402Pay } from "@lunora/x402/pay";'],stub:y("x402Stub: X402Pay","ctx.x402: no pay rail configured. Pass `x402` to createShardDO().",["fetch"],{cast:" as unknown as X402Pay",sync:["fetch"]})}),E={access:_,ai:A,r2sql:C,x402:F},O=e=>e.shardBinding==="bespoke",P=e=>typeof e.shardBinding=="object",m=" ",q=(e,r,t)=>{const n=`${e}Binding`,{factory:s}=t;let i=`(${n} as ${r})`;if(s!==void 0){const c=`${n} as ${t.bindingType??r}`;i=s.option===void 0?`${s.name}(${c})`:`${s.name}({ ${s.option}: ${c} })`}return`${n} ? ${i} : ${e}Stub`},W=(e,r,t)=>{const n=q(e,r,t),s=`${m}const ${e}Binding = config.${e}?.(env) ?? (env as Record<string, unknown>).${t.envName};
|
|
138
138
|
`,i=t.unvouchableReads??[];return i.length===0?`
|
|
139
139
|
${s}${m}const ${e}: ${r} = ${n};
|
|
140
140
|
`:`
|
|
@@ -145,12 +145,12 @@ ${m}const ${e}: ${r} = markUnvouchableReads(${n}, options.onRead, [
|
|
|
145
145
|
${i.map(c=>`${m} ${JSON.stringify(c)},`).join(`
|
|
146
146
|
`)}
|
|
147
147
|
${m}]);
|
|
148
|
-
`},
|
|
148
|
+
`},T=(e,r,t)=>{const{binding:n,clientType:s}=t,i=y(`${e}Stub: ${s}`,t.missingMessage,t.stubMethods,{sync:t.syncStubMethods});if(n===void 0){const a=t.instrument===void 0?`config.${e}(env)`:`this.${t.instrument}(config.${e}(env), logFunctionPath, traceAnchor, observability)`;return{build:`
|
|
149
149
|
${m}const ${e}: ${s} = config.${e} ? ${a} : ${e}Stub;
|
|
150
150
|
`,configField:`
|
|
151
|
-
${e}?: (env: Record<string, unknown>) => ${s};`,importLines:[`import type { ${s} } from "${r}";`],stub:i}}const c=n.bindingType??s,u=[...new Set([c,s])].toSorted((a,o)=>a.localeCompare(o));return{build:
|
|
152
|
-
${e}?: (env: Record<string, unknown>) => ${c};`,importLines:[`import type { ${u.join(", ")} } from "${r}";`,...n.factory===void 0?[]:[`import { ${n.factory.name} } from "${r}";`]],stub:i}},
|
|
153
|
-
${d},`):(n+=o.build,r.push(d))}return{actionBuild:n,actionFields:r,configFields:s,everyBuild:i,everyFields:c,importLines:t,stubs:u}},
|
|
151
|
+
${e}?: (env: Record<string, unknown>) => ${s};`,importLines:[`import type { ${s} } from "${r}";`],stub:i}}const c=n.bindingType??s,u=[...new Set([c,s])].toSorted((a,o)=>a.localeCompare(o));return{build:W(e,s,n),configField:`
|
|
152
|
+
${e}?: (env: Record<string, unknown>) => ${c};`,importLines:[`import type { ${u.join(", ")} } from "${r}";`,...n.factory===void 0?[]:[`import { ${n.factory.name} } from "${r}";`]],stub:i}},Y=e=>{const r=[],t=[];let n="",s="",i="",c="",u="";for(const a of S.filter(({key:o})=>e.has(o))){let o;if(O(a))o=E[a.key]();else if(P(a))o=T(a.contextProperty,a.moduleSpecifier,a.shardBinding);else continue;const d=a.contextProperty;t.push(...o.importLines),s+=o.configField,u+=o.stub,a.tier==="every"?(i+=o.build,c+=`
|
|
153
|
+
${d},`):(n+=o.build,r.push(d))}return{actionBuild:n,actionFields:r,configFields:s,everyBuild:i,everyFields:c,importLines:t,stubs:u}},z=(e,r)=>{if(e.length===0)return"";const t=r?`, ${JSON.stringify(r)}`:"",n=e.map(o=>{l(o.exportName,`container export "${o.exportName}"`),l(o.className,`container class "${o.className}"`);const d=o.sandbox===!0?"LunoraSandboxContainer":"LunoraContainer";return`/** Container DO for the \`${o.exportName}\` definition (binding \`${o.bindingName}\`). */
|
|
154
154
|
export class ${o.className} extends ${d} {
|
|
155
155
|
public constructor(ctx: ConstructorParameters<typeof ${d}>[0], env: Record<string, unknown>) {
|
|
156
156
|
super(ctx, env, ${o.exportName}, "${o.exportName}"${t});
|
|
@@ -182,7 +182,7 @@ ${i?`
|
|
|
182
182
|
*/
|
|
183
183
|
export { DirectoryBackupGateway, S3Gateway } from "@lunora/container/sandbox";
|
|
184
184
|
`:""}
|
|
185
|
-
${n}`},
|
|
185
|
+
${n}`},X=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)l(n.exportName,`container export "${n.exportName}"`),l(n.bindingName,`container binding "${n.bindingName}"`);const t=e.map(n=>{const s=n.schedulingPolicy!==void 0||n.maxInstances===void 0?"":`, maxInstances: ${String(n.maxInstances)}`;return` { binding: "${n.bindingName}", exportName: "${n.exportName}"${s} },`}).join(`
|
|
186
186
|
`);return{build:`
|
|
187
187
|
const containers = createContainerContext(env, LUNORA_CONTAINERS, ${r?JSON.stringify(r):"undefined"}, this.getCurrentTraceparent(), this.getCurrentSampleErrors());
|
|
188
188
|
`,contextField:`
|
|
@@ -191,7 +191,7 @@ ${n}`},z=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],
|
|
|
191
191
|
const LUNORA_CONTAINERS: ReadonlyArray<ContainerBindingSpec> = [
|
|
192
192
|
${t}
|
|
193
193
|
];
|
|
194
|
-
`}},
|
|
194
|
+
`}},Z=(e,r={})=>{if(e.length===0)return"";const t=r.lazy===!0,n=e.map(i=>{l(i.exportName,`workflow export "${i.exportName}"`),l(i.className,`workflow class "${i.className}"`);const c=t?`async () => (await import("../workflows.js")).${i.exportName}`:i.exportName;return`/** WorkflowEntrypoint for the \`${i.exportName}\` definition, reached as \`ctx.exports.${i.className}\`. */
|
|
195
195
|
export class ${i.className} extends LunoraWorkflow<WorkflowParamsOf<typeof ${i.exportName}>, WorkflowOutputOf<typeof ${i.exportName}>> {
|
|
196
196
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
197
197
|
super(ctx, env, ${c}, "${i.exportName}");
|
|
@@ -219,7 +219,7 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
|
|
|
219
219
|
/** Output type carried by a \`defineWorkflow\` definition (its phantom \`__output\`), so each entrypoint keeps the authored return type. */
|
|
220
220
|
type WorkflowOutputOf<Definition> = Definition extends { __output?: infer Output } ? Output : unknown;
|
|
221
221
|
|
|
222
|
-
${n}`},
|
|
222
|
+
${n}`},ee=(e,r={})=>{if(e.length===0)return"";const n=e.filter(o=>o.voice).length>0,s=r.lazy===!0&&!n,i=e.map(o=>{l(o.exportName,`agent export "${o.exportName}"`),l(o.className,`agent class "${o.className}"`);const d=`/** WorkflowEntrypoint for the \`${o.exportName}\` agent, reached as \`ctx.exports.${o.className}\`. */
|
|
223
223
|
export class ${o.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult> {
|
|
224
224
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
225
225
|
super(ctx, env, ${s?`async () => {
|
|
@@ -229,14 +229,14 @@ export class ${o.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult
|
|
|
229
229
|
}`:`compileAgentWorkflow(${o.exportName}, "${o.exportName}")`}, "${o.exportName}");
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
`;if(!o.voice)return d;const p=o.voiceClassName??"",g=o.voiceBindingName??"";l(p,`agent voice class "${p}"`);const
|
|
232
|
+
`;if(!o.voice)return d;const p=o.voiceClassName??"",g=o.voiceBindingName??"";l(p,`agent voice class "${p}"`);const k=`
|
|
233
233
|
/** Voice-session Durable Object for the \`${o.exportName}\` agent (binding \`${g}\`). */
|
|
234
234
|
export class ${p} extends VoiceSessionDO {
|
|
235
235
|
public constructor(ctx: ConstructorParameters<typeof VoiceSessionDO>[0], env: Record<string, unknown>) {
|
|
236
236
|
super(ctx, env, ${o.exportName}, "${o.exportName}");
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
`;return`${d}${
|
|
239
|
+
`;return`${d}${k}`}).join(`
|
|
240
240
|
`),c=e.map(o=>o.exportName).join(", ");let u='import { compileAgentWorkflow } from "@lunora/agent/core";';return n?u=`import { compileAgentWorkflow } from "@lunora/agent/core";
|
|
241
241
|
import { VoiceSessionDO } from "@lunora/agent";`:s&&(u=""),`${f}/**
|
|
242
242
|
* WorkflowEntrypoint classes for the agents declared in \`lunora/agents.ts\`.
|
|
@@ -252,8 +252,8 @@ ${u===""?"":`${u}
|
|
|
252
252
|
${s?"":`
|
|
253
253
|
import { ${c} } from "../agents.js";
|
|
254
254
|
`}
|
|
255
|
-
${i}`},h=e=>e.env===void 0?"the top level":`env.${e.env}
|
|
256
|
-
`),{routes:s}
|
|
255
|
+
${i}`},h=e=>e.env===void 0?"the top level":`env.${e.env}`,v=(e,r)=>{const t=e.filter(a=>a.mode==="push"),n=new Map(t.map(a=>[a.bindingName,a])),s=new Map(e.map(a=>[a.name,a])),i=new Map(t.map(a=>[a.name,a])),c=new Map,u=[];for(const a of r){const o=n.get(a.binding);if(o===void 0||a.queue===o.name)continue;const d=s.get(a.queue);if(d!==void 0){u.push(`${h(a)} maps \`${a.binding}\` to "${a.queue}", the declared name of queue \`${d.exportName}\` — batches for "${a.queue}" go to \`${d.exportName}\`, never \`${o.exportName}\`.`);continue}const p=i.get(a.queue);if(p===void 0)i.set(a.queue,o),c.set(a.queue,a);else if(p!==o){const g=c.get(a.queue);u.push(`"${a.queue}" is aliased to \`${p.exportName}\` by ${g===void 0?"an earlier producer":h(g)} and to \`${o.exportName}\` by ${h(a)} — batches for it go to \`${p.exportName}\`.`)}}return{conflicts:u,routes:i}},te=(e,r)=>v(e,r).conflicts.map(t=>({cacheKey:`queue_alias_conflict:${t}`,categories:["SCHEMA"],description:"Codegen routes a delivered batch by its queue name. A wrangler.jsonc producer that maps a queue's binding to another name adds that name as a route, so it must not be another queue's declared name or an alias another scope gives a different queue.",detail:t,facing:"INTERNAL",level:"WARN",metadata:{},name:"queue_alias_conflict",remediation:"Give each queue a distinct name in every `env.<name>` block of wrangler.jsonc, then rerun codegen.",title:"Queue name routes to a different handler than wrangler.jsonc implies"})),ne=(e,r=[])=>{const t=e.filter(c=>c.mode==="push");if(t.length===0)return"";for(const c of t)l(c.exportName,`queue export "${c.exportName}"`);const n=[...Map.groupBy(t,c=>c.filePath)].map(([c,u])=>`import { ${u.map(a=>a.exportName).join(", ")} } from "../${c}.js";`).join(`
|
|
256
|
+
`),{routes:s}=v(e,r),i=[...s].map(([c,u])=>` ${JSON.stringify(c)}: { binding: ${JSON.stringify(u.bindingName)}, definition: ${u.exportName}, exportName: ${JSON.stringify(u.exportName)} },`).join(`
|
|
257
257
|
`);return`${f}/**
|
|
258
258
|
* Push-consumer registry for the queues declared in \`lunora/queues.ts\`. The
|
|
259
259
|
* composed worker's \`queue(batch, env, ctx)\` entry routes each delivered batch
|
|
@@ -268,7 +268,7 @@ ${n}
|
|
|
268
268
|
export const LUNORA_QUEUE_REGISTRY: QueueRegistry = {
|
|
269
269
|
${i}
|
|
270
270
|
};
|
|
271
|
-
`},
|
|
271
|
+
`},re=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const t of e)l(t.exportName,`workflow export "${t.exportName}"`),l(t.className,`workflow class "${t.className}"`);const r=e.map(t=>` { className: "${t.className}", exportName: "${t.exportName}" },`).join(`
|
|
272
272
|
`);return{build:`
|
|
273
273
|
const workflows = createWorkflowContext(env, LUNORA_WORKFLOWS, this.state.exports);
|
|
274
274
|
`,contextField:`
|
|
@@ -277,7 +277,7 @@ ${i}
|
|
|
277
277
|
const LUNORA_WORKFLOWS: ReadonlyArray<WorkflowBindingSpec> = [
|
|
278
278
|
${r}
|
|
279
279
|
];
|
|
280
|
-
`}},
|
|
280
|
+
`}},oe=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const t of e)l(t.exportName,`queue export "${t.exportName}"`),l(t.bindingName,`queue binding "${t.bindingName}"`);const r=e.map(t=>` { binding: "${t.bindingName}", exportName: "${t.exportName}", name: ${JSON.stringify(t.name)} },`).join(`
|
|
281
281
|
`);return{build:`
|
|
282
282
|
const queues = createQueueContext(env, LUNORA_QUEUES);
|
|
283
283
|
`,contextField:`
|
|
@@ -286,7 +286,7 @@ ${r}
|
|
|
286
286
|
const LUNORA_QUEUES: ReadonlyArray<QueueBindingSpec> = [
|
|
287
287
|
${r}
|
|
288
288
|
];
|
|
289
|
-
`}},
|
|
289
|
+
`}},se=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};const t=e.map(n=>{l(n.exportName,`topic export "${n.exportName}"`);const s=L(r,n.exportName).map(i=>`{ binding: "${i.bindingName}", exportName: "${i.exportName}" }`).join(", ");return` { exportName: "${n.exportName}", subscriptions: [${s}] },`}).join(`
|
|
290
290
|
`);return{build:`
|
|
291
291
|
const topics = createTopicContext(env, LUNORA_TOPICS);
|
|
292
292
|
`,contextField:`
|
|
@@ -295,7 +295,7 @@ ${r}
|
|
|
295
295
|
const LUNORA_TOPICS: ReadonlyArray<TopicBindingSpec> = [
|
|
296
296
|
${t}
|
|
297
297
|
];
|
|
298
|
-
`}},
|
|
298
|
+
`}},ae=(e,r)=>{if(e.length===0)return{build:"",importLines:[],specs:""};const t=e.map(n=>(l(n.name,`service "${n.name}"`),l(n.binding,`service binding "${n.binding}"`),` { binding: "${n.binding}", name: "${n.name}"${n.rpcEntrypoint===void 0?"":", rpc: true"} },`)).join(`
|
|
299
299
|
`);return{build:`
|
|
300
300
|
const services = createServices(env, LUNORA_SERVICES);
|
|
301
301
|
`,importLines:[`import type { ServiceBindingSpec } from "${r}";`,`import { createServices } from "${r}";`],specs:`
|
|
@@ -303,25 +303,25 @@ ${t}
|
|
|
303
303
|
const LUNORA_SERVICES: ReadonlyArray<ServiceBindingSpec> = [
|
|
304
304
|
${t}
|
|
305
305
|
];
|
|
306
|
-
`}},
|
|
306
|
+
`}},b="(config.scheduler?.(env) ?? schedulerStub) as SchedulerLike",ie=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],schedulerSource:b,specs:"",stampsOutbox:!1};for(const n of e)l(n.exportName,`agent export "${n.exportName}"`),l(n.className,`agent class "${n.className}"`);const t=e.map(n=>` { className: "${n.className}", exportName: "${n.exportName}"${n.publicRun===!0?", publicRun: true":""} },`).join(`
|
|
307
307
|
`);return{build:`
|
|
308
|
-
const agents = createAgentContext(env, LUNORA_AGENTS, { exports: this.state.exports });
|
|
308
|
+
const agents = createAgentContext(env, LUNORA_AGENTS, { exports: this.state.exports, shardKey: this.currentShardKey() });
|
|
309
309
|
`,contextField:r?`
|
|
310
310
|
agents,
|
|
311
311
|
agentSecrets: this.secretValues,`:`
|
|
312
|
-
agents,`,importLines:['import { createAgentContext } from "@lunora/agent/core";','import type { AgentBindingSpec } from "@lunora/agent/core";'],specs:`
|
|
312
|
+
agents,`,importLines:['import { createAgentContext } from "@lunora/agent/core";','import { withAgentScheduleShard } from "@lunora/agent/core";','import type { AgentBindingSpec } from "@lunora/agent/core";'],schedulerSource:`withAgentScheduleShard(${b}, LUNORA_AGENTS, this.currentShardKey())`,stampsOutbox:!0,specs:`
|
|
313
313
|
/** Wiring specs for \`ctx.agents\` (codegen-derived from \`lunora/agents.ts\`). */
|
|
314
314
|
const LUNORA_AGENTS: ReadonlyArray<AgentBindingSpec> = [
|
|
315
315
|
${t}
|
|
316
316
|
];
|
|
317
|
-
`}},
|
|
317
|
+
`}},N=(e,r,t,n,s)=>({constant:`
|
|
318
318
|
${s}
|
|
319
|
-
const ${e} = ${
|
|
319
|
+
const ${e} = ${$(n,r)};
|
|
320
320
|
`,override:`
|
|
321
321
|
protected override ${t}(): ${r} {
|
|
322
322
|
return ${e};
|
|
323
323
|
}
|
|
324
|
-
`}),
|
|
324
|
+
`}),ce=(e,r)=>{if(e.length===0)return{constant:"",override:""};const t={...r.length===0?{}:{eventTypes:r.map(n=>n.type)},workflows:e.map(n=>({className:n.className,exportName:n.exportName,name:n.name}))};return N("LUNORA_WORKFLOWS_INFO","WorkflowsResult","workflowsMetadata",t,"/** Read-only declared-workflow metadata (discovered from `lunora/workflows.ts`) served via `__lunora_admin__:listWorkflows` for the studio's workflows view. */")},ue=(e,r)=>{if(e.length===0||r.length===0)return{constant:"",override:""};for(const t of r)if(l(t.exportName,"workflow event export name"),!w.test(t.filePath))throw new R("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe workflow event file path: ${JSON.stringify(t.filePath)}`);return{constant:`
|
|
325
325
|
/** Declared workflow events (\`defineWorkflowEvent\` exports), loaded by type when an admin \`sendWorkflowEvent\` parses its payload. */
|
|
326
326
|
const LUNORA_WORKFLOW_EVENTS: ReadonlyMap<string, () => Promise<{ payload: { parse: (value: unknown) => unknown } }>> = new Map([
|
|
327
327
|
${r.map(t=>` [${JSON.stringify(t.type)}, () => import("../${t.filePath}.js").then((module) => module.${t.exportName})],`).join(`
|
|
@@ -331,7 +331,7 @@ ${r.map(t=>` [${JSON.stringify(t.type)}, () => import("../${t.filePath}.js").
|
|
|
331
331
|
protected override async workflowEvent(type: string): Promise<{ payload: { parse: (value: unknown) => unknown } } | undefined> {
|
|
332
332
|
return LUNORA_WORKFLOW_EVENTS.get(type)?.();
|
|
333
333
|
}
|
|
334
|
-
`}},
|
|
334
|
+
`}},le=e=>{if(e.length===0)return{constant:"",override:""};const r={queues:e.map(t=>({binding:t.bindingName,...t.tuning.deadLetterQueue===void 0?{}:{deadLetterQueue:t.tuning.deadLetterQueue},exportName:t.exportName,mode:t.mode,name:t.name,...t.topic===void 0?{}:{topic:t.topic}}))};return N("LUNORA_QUEUES_INFO","QueuesResult","queuesMetadata",r,"/** Read-only declared-queue metadata (discovered from `lunora/queues.ts`) served via `__lunora_admin__:listQueues` for the studio's queues view. */")},I=["attach","cancelPayment","cancelSubscription","capturePayment","check","createCheckout","createPortalSession","handleWebhook","listBalances","listSubscriptions","refundPayment","track"],de=e=>e?{imports:['import type { LunoraDatabaseLike as LunoraPaymentDbLike, LunoraPayment, PaymentsFromContextOptions } from "@lunora/payment";','import { paymentsFromContext } from "@lunora/payment";'],build:`
|
|
335
335
|
const paymentsByContext = new WeakMap<object, LunoraPayment>();
|
|
336
336
|
`,configField:`
|
|
337
337
|
payment?: (env: Record<string, unknown>) => PaymentsFromContextOptions;`,contextField:`
|
|
@@ -346,4 +346,4 @@ ${r.map(t=>` [${JSON.stringify(t.type)}, () => import("../${t.filePath}.js").
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
return payments;
|
|
349
|
-
},`,stub:y("paymentStub: LunoraPayment","ctx.payments: no payment configured. Pass `payment` to createShardDO().",
|
|
349
|
+
},`,stub:y("paymentStub: LunoraPayment","ctx.payments: no payment configured. Pass `payment` to createShardDO().",I,{cast:" as unknown as LunoraPayment",sync:!0})}:{build:"",configField:"",contextField:"",imports:[],stub:""},me=(e,r,t,n,s)=>["AdvisorProcedure","AdvisoryFinding","DatabaseWriterLike","DataMigrationLike","DispatchBookmark","ExportRow",...n?["FlagsResult"]:[],"ImportShardResult","KeyRange","MaskPoliciesResult","MigrationRunResult","QueryReadScope",...t?["QueuesResult"]:[],"RelatedPage","RunShardApplyCdcArgs","RunShardExportArgs","RunShardFindRelatedArgs","RunShardImportArgs","RunShardMigrationArgs","RlsPoliciesResult","RunShardRankBeforeArgs","RunShardRankPageArgs","RunShardWriteArgs","RunShardWriteResult","SchedulerLike","SensitiveScope",...s?["SearchBackfillProgress"]:[],"TransactionHeadroomTracker","SchemaLike","ShardDOState","DeliveryAuthorization","ShardRankPageResult","SqlExec","StorageRulesResult","StudioFeaturesResult","SubscriptionIdentity","SystemReaderStorageLike","TelemetrySink",...e?["VectorBackfillProgress"]:[],...r?["WorkflowsResult"]:[],...e?["WriteHook"]:[]];export{H as a,J as b,V as c,oe as d,Y as e,se as f,ae as g,X as h,re as i,ie as j,de as k,ce as l,ue as m,le as n,K as o,me as p,M as q,y as r,G as s,ee as t,z as u,Z as v,te as w,ne as x};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/codegen",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.394",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@lunora/advisor": "1.0.0-alpha.284",
|
|
54
|
-
"@lunora/agent": "1.0.0-alpha.
|
|
54
|
+
"@lunora/agent": "1.0.0-alpha.278",
|
|
55
55
|
"@lunora/container": "1.0.0-alpha.108",
|
|
56
56
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
57
57
|
"@lunora/platform": "1.0.0-alpha.79",
|