@lunora/codegen 1.0.0-alpha.364 → 1.0.0-alpha.366
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 +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-HhpbVApk.mjs → SCHEMA_SNAPSHOT_FILENAME-CVAC4R90.mjs} +10 -10
- package/dist/packem_shared/emitAgents-BIvfaobb.mjs +1 -0
- package/dist/packem_shared/{emitApp-BOunDt8g.mjs → emitApp-CFkLyCIO.mjs} +64 -19
- package/dist/packem_shared/{emitShard-vmtwryKT.mjs → emitShard-tyWbUrjj.mjs} +1 -1
- package/dist/packem_shared/{shard-DyIoujoy.mjs → shard-DOqocTdL.mjs} +104 -104
- package/dist/packem_shared/{shard-runtime-DXlpfT3P.mjs → shard-runtime-Dad_kcaX.mjs} +54 -44
- package/package.json +8 -8
- package/dist/packem_shared/emitAgents-CwwzVPZe.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as
|
|
1
|
+
import{LunoraError as N}from"@lunora/errors";import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as k}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{a as l,G as g,I as R}from"./shared-Br_OnErI.mjs";import{s as w}from"./platform-8oj7iXQy.mjs";const U=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
|
|
|
@@ -6,37 +6,37 @@ import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as N}from"./CAP
|
|
|
6
6
|
|
|
7
7
|
return serveRelationFanout(schema as unknown as SchemaLike, db, functionPath, args);
|
|
8
8
|
}
|
|
9
|
-
`}:{importFragment:"",override:""},f=(e,
|
|
9
|
+
`}:{importFragment:"",override:""},f=(e,o,t,{cast:n="",sync:a=[]}={})=>{const u=`throw new Error(${JSON.stringify(o)});`,c=t.map(s=>` ${s}: ${a===!0||a.includes(s)?"":"async "}() => {
|
|
10
10
|
${u}
|
|
11
11
|
},`).join(`
|
|
12
12
|
`);return`
|
|
13
13
|
const ${e} = {
|
|
14
14
|
${c}
|
|
15
15
|
}${n};
|
|
16
|
-
`},h={build:"",configField:"",contextField:"",importLines:[],stub:""},
|
|
16
|
+
`},h={build:"",configField:"",contextField:"",importLines:[],stub:""},Q=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
|
-
const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(
|
|
18
|
+
const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(o=>JSON.stringify(o)).join(", ")}]);
|
|
19
19
|
`,override:`
|
|
20
20
|
protected override shardRegistry(): undefined | { namespace: unknown; shardedTables: ReadonlySet<string> } {
|
|
21
21
|
const namespace = config.shardRegistry?.((this.env ?? {}) as Record<string, unknown>);
|
|
22
22
|
|
|
23
23
|
return namespace === undefined ? undefined : { namespace, shardedTables: SHARDED_TABLES };
|
|
24
24
|
}
|
|
25
|
-
`},
|
|
26
|
-
const flags: import("${
|
|
25
|
+
`},M=(e,o)=>e?{build:`
|
|
26
|
+
const flags: import("${o}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
27
27
|
provider: () => config.flags?.(env),
|
|
28
28
|
targetingKey: () => flagsConfig.identify?.({ identity: identity ?? null, userId: userId ?? null }),
|
|
29
29
|
});
|
|
30
30
|
`,configField:`
|
|
31
|
-
flags?: (env: Record<string, unknown>) => import("${
|
|
32
|
-
flags,`,importLines:[`import { createFlags } from "${
|
|
31
|
+
flags?: (env: Record<string, unknown>) => import("${o}").Provider;`,contextField:`
|
|
32
|
+
flags,`,importLines:[`import { createFlags } from "${o}";`,'import flagsConfig from "../flags.js";'],stub:""}:h,K=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:""}:h,
|
|
36
|
+
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:h,H=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:""}:h,
|
|
39
|
+
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:h,G=(e,o,t)=>{if(!o)return{constant:"",evaluateOverride:"",subscriptionOverride:""};const n=s=>`
|
|
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),
|
|
@@ -98,7 +98,7 @@ const LUNORA_FLAG_KEYS = ${b(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
98
98
|
|
|
99
99
|
return flags.boolean(key, typeof args.default === "boolean" ? args.default : false, context);
|
|
100
100
|
}
|
|
101
|
-
`;return{constant:a,evaluateOverride:u,subscriptionOverride:c}},
|
|
101
|
+
`;return{constant:a,evaluateOverride:u,subscriptionOverride:c}},S=()=>({build:`
|
|
102
102
|
const aiBinding = config.ai?.(env) ?? (env as Record<string, unknown>).AI;
|
|
103
103
|
// Correlate AI-Gateway-routed calls with the Lunora trace: thread the
|
|
104
104
|
// function path + trace id into createAi, which folds them into the
|
|
@@ -115,9 +115,9 @@ const LUNORA_FLAG_KEYS = ${b(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
115
115
|
telemetry: { metrics, trace },
|
|
116
116
|
});
|
|
117
117
|
`,configField:`
|
|
118
|
-
ai?: (env: Record<string, unknown>) => AiBindingLike;`,importLines:['import type { AiBindingLike, LunoraAi } from "@lunora/ai/create";','import { createAi } from "@lunora/ai/create";'],stub:""}),
|
|
118
|
+
ai?: (env: Record<string, unknown>) => AiBindingLike;`,importLines:['import type { AiBindingLike, LunoraAi } from "@lunora/ai/create";','import { createAi } from "@lunora/ai/create";'],stub:""}),L=()=>({build:`
|
|
119
119
|
const access = accessFacade(identity, userId);
|
|
120
|
-
`,configField:"",importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}),
|
|
120
|
+
`,configField:"",importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}),A=()=>({build:`
|
|
121
121
|
const r2sqlEnv = env as Record<string, unknown>;
|
|
122
122
|
const r2sqlAccountId = (r2sqlEnv.R2_SQL_ACCOUNT_ID ?? r2sqlEnv.CLOUDFLARE_ACCOUNT_ID) as string | undefined;
|
|
123
123
|
const r2sqlToken = r2sqlEnv.R2_SQL_TOKEN as string | undefined;
|
|
@@ -128,28 +128,28 @@ const LUNORA_FLAG_KEYS = ${b(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
128
128
|
? createR2Sql({ accountId: r2sqlAccountId, apiToken: r2sqlToken, bucket: r2sqlBucket })
|
|
129
129
|
: r2sqlStub;
|
|
130
130
|
`,configField:`
|
|
131
|
-
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:f("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"]})}),
|
|
131
|
+
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:f("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"]})}),_=()=>({build:`
|
|
132
132
|
const x402: X402Pay = config.x402
|
|
133
133
|
? lazyX402Pay(config.x402(env), { getSecret: (name: string) => secrets.get(name) })
|
|
134
134
|
: x402Stub;
|
|
135
135
|
`,configField:`
|
|
136
|
-
x402?: (env: Record<string, unknown>) => X402PayConfig;`,importLines:['import type { X402Pay, X402PayConfig } from "@lunora/x402/pay";','import { lazyX402Pay } from "@lunora/x402/pay";'],stub:f("x402Stub: X402Pay","ctx.x402: no pay rail configured. Pass `x402` to createShardDO().",["fetch"],{cast:" as unknown as X402Pay",sync:["fetch"]})}),
|
|
136
|
+
x402?: (env: Record<string, unknown>) => X402PayConfig;`,importLines:['import type { X402Pay, X402PayConfig } from "@lunora/x402/pay";','import { lazyX402Pay } from "@lunora/x402/pay";'],stub:f("x402Stub: X402Pay","ctx.x402: no pay rail configured. Pass `x402` to createShardDO().",["fetch"],{cast:" as unknown as X402Pay",sync:["fetch"]})}),C={access:L,ai:S,r2sql:A,x402:_},F=e=>e.shardBinding==="bespoke",E=e=>typeof e.shardBinding=="object",m=" ",O=(e,o,t)=>{const n=`${e}Binding`,{factory:a}=t;let u=`(${n} as ${o})`;if(a!==void 0){const c=`${n} as ${t.bindingType??o}`;u=a.option===void 0?`${a.name}(${c})`:`${a.name}({ ${a.option}: ${c} })`}return`${n} ? ${u} : ${e}Stub`},P=(e,o,t)=>{const n=O(e,o,t),a=`${m}const ${e}Binding = config.${e}?.(env) ?? (env as Record<string, unknown>).${t.envName};
|
|
137
137
|
`,u=t.unvouchableReads??[];return u.length===0?`
|
|
138
|
-
${a}${m}const ${e}: ${
|
|
138
|
+
${a}${m}const ${e}: ${o} = ${n};
|
|
139
139
|
`:`
|
|
140
140
|
${a}${m}// ${t.envName} is not this shard's SQLite, so nothing appends a \`__cdc_log\` entry
|
|
141
141
|
${m}// when a value changes — a subscription that read one can never be proven
|
|
142
142
|
${m}// current on reconnect and must re-snapshot. Reads only; writes stay unstamped.
|
|
143
|
-
${m}const ${e}: ${
|
|
143
|
+
${m}const ${e}: ${o} = markUnvouchableReads(${n}, options.onRead, [
|
|
144
144
|
${u.map(c=>`${m} ${JSON.stringify(c)},`).join(`
|
|
145
145
|
`)}
|
|
146
146
|
${m}]);
|
|
147
|
-
`},
|
|
148
|
-
${m}const ${e}: ${a} = config.${e} ? ${
|
|
147
|
+
`},q=(e,o,t)=>{const{binding:n,clientType:a}=t,u=f(`${e}Stub: ${a}`,t.missingMessage,t.stubMethods,{sync:t.syncStubMethods});if(n===void 0){const r=t.instrument===void 0?`config.${e}(env)`:`this.${t.instrument}(config.${e}(env), logFunctionPath, traceAnchor, observability)`;return{build:`
|
|
148
|
+
${m}const ${e}: ${a} = config.${e} ? ${r} : ${e}Stub;
|
|
149
149
|
`,configField:`
|
|
150
|
-
${e}?: (env: Record<string, unknown>) => ${a};`,importLines:[`import type { ${a} } from "${
|
|
151
|
-
${e}?: (env: Record<string, unknown>) => ${c};`,importLines:[`import type { ${s.join(", ")} } from "${
|
|
152
|
-
${d},`):(n+=i.build,
|
|
150
|
+
${e}?: (env: Record<string, unknown>) => ${a};`,importLines:[`import type { ${a} } from "${o}";`],stub:u}}const c=n.bindingType??a,s=[...new Set([c,a])].toSorted((r,i)=>r.localeCompare(i));return{build:P(e,a,n),configField:`
|
|
151
|
+
${e}?: (env: Record<string, unknown>) => ${c};`,importLines:[`import type { ${s.join(", ")} } from "${o}";`,...n.factory===void 0?[]:[`import { ${n.factory.name} } from "${o}";`]],stub:u}},V=e=>{const o=[],t=[];let n="",a="",u="",c="",s="";for(const r of k.filter(({key:i})=>e.has(i))){let i;if(F(r))i=C[r.key]();else if(E(r))i=q(r.contextProperty,r.moduleSpecifier,r.shardBinding);else continue;const d=r.contextProperty;t.push(...i.importLines),a+=i.configField,s+=i.stub,r.tier==="every"?(u+=i.build,c+=`
|
|
152
|
+
${d},`):(n+=i.build,o.push(d))}return{actionBuild:n,actionFields:o,configFields:a,everyBuild:u,everyFields:c,importLines:t,stubs:s}},J=(e,o)=>{if(e.length===0)return"";const t=o?`, ${JSON.stringify(o)}`:"",n=e.map(i=>{l(i.exportName,`container export "${i.exportName}"`),l(i.className,`container class "${i.className}"`);const d=i.sandbox===!0?"LunoraSandboxContainer":"LunoraContainer";return`/** Container DO for the \`${i.exportName}\` definition (binding \`${i.bindingName}\`). */
|
|
153
153
|
export class ${i.className} extends ${d} {
|
|
154
154
|
public constructor(ctx: ConstructorParameters<typeof ${d}>[0], env: Record<string, unknown>) {
|
|
155
155
|
super(ctx, env, ${i.exportName}, "${i.exportName}"${t});
|
|
@@ -181,16 +181,16 @@ ${u?`
|
|
|
181
181
|
*/
|
|
182
182
|
export { DirectoryBackupGateway, S3Gateway } from "@lunora/container/sandbox";
|
|
183
183
|
`:""}
|
|
184
|
-
${n}`},
|
|
184
|
+
${n}`},Y=(e,o)=>{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 a=n.schedulingPolicy!==void 0||n.maxInstances===void 0?"":`, maxInstances: ${String(n.maxInstances)}`;return` { binding: "${n.bindingName}", exportName: "${n.exportName}"${a} },`}).join(`
|
|
185
185
|
`);return{build:`
|
|
186
|
-
const containers = createContainerContext(env, LUNORA_CONTAINERS, ${
|
|
186
|
+
const containers = createContainerContext(env, LUNORA_CONTAINERS, ${o?JSON.stringify(o):"undefined"}, this.getCurrentTraceparent(), this.getCurrentSampleErrors());
|
|
187
187
|
`,contextField:`
|
|
188
188
|
containers,`,importLines:['import type { ContainerBindingSpec } from "@lunora/container";','import { createContainerContext } from "@lunora/container";'],specs:`
|
|
189
189
|
/** Wiring specs for \`ctx.containers\` (codegen-derived from \`lunora/containers.ts\`). */
|
|
190
190
|
const LUNORA_CONTAINERS: ReadonlyArray<ContainerBindingSpec> = [
|
|
191
191
|
${t}
|
|
192
192
|
];
|
|
193
|
-
`}},
|
|
193
|
+
`}},X=e=>{if(e.length===0)return"";const o=e.map(n=>(l(n.exportName,`workflow export "${n.exportName}"`),l(n.className,`workflow class "${n.className}"`),`/** WorkflowEntrypoint for the \`${n.exportName}\` definition, reached as \`ctx.exports.${n.className}\`. */
|
|
194
194
|
export class ${n.className} extends LunoraWorkflow<WorkflowParamsOf<typeof ${n.exportName}>, WorkflowOutputOf<typeof ${n.exportName}>> {
|
|
195
195
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
196
196
|
super(ctx, env, ${n.exportName}, "${n.exportName}");
|
|
@@ -218,20 +218,20 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
|
|
|
218
218
|
/** Output type carried by a \`defineWorkflow\` definition (its phantom \`__output\`), so each entrypoint keeps the authored return type. */
|
|
219
219
|
type WorkflowOutputOf<Definition> = Definition extends { __output?: infer Output } ? Output : unknown;
|
|
220
220
|
|
|
221
|
-
${
|
|
221
|
+
${o}`},z=e=>{if(e.length===0)return"";const t=e.filter(s=>s.voice).length>0,n=e.map(s=>{l(s.exportName,`agent export "${s.exportName}"`),l(s.className,`agent class "${s.className}"`);const r=`/** WorkflowEntrypoint for the \`${s.exportName}\` agent, reached as \`ctx.exports.${s.className}\`. */
|
|
222
222
|
export class ${s.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult> {
|
|
223
223
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
224
224
|
super(ctx, env, compileAgentWorkflow(${s.exportName}, "${s.exportName}"), "${s.exportName}");
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
`;if(!s.voice)return
|
|
227
|
+
`;if(!s.voice)return r;const i=s.voiceClassName??"",d=s.voiceBindingName??"";l(i,`agent voice class "${i}"`);const p=`
|
|
228
228
|
/** Voice-session Durable Object for the \`${s.exportName}\` agent (binding \`${d}\`). */
|
|
229
229
|
export class ${i} extends VoiceSessionDO {
|
|
230
230
|
public constructor(ctx: ConstructorParameters<typeof VoiceSessionDO>[0], env: Record<string, unknown>) {
|
|
231
231
|
super(ctx, env, ${s.exportName}, "${s.exportName}");
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
`;return`${
|
|
234
|
+
`;return`${r}${p}`}).join(`
|
|
235
235
|
`),a=e.map(s=>s.exportName).join(", ");return`${g}/**
|
|
236
236
|
* WorkflowEntrypoint classes for the agents declared in \`lunora/agents.ts\`.
|
|
237
237
|
* Each \`defineAgent\` compiles a replay-safe tool-loop onto a Cloudflare
|
|
@@ -246,8 +246,8 @@ import type { AgentRunInput, AgentRunResult } from "@lunora/agent";
|
|
|
246
246
|
|
|
247
247
|
import { ${a} } from "../agents.js";
|
|
248
248
|
|
|
249
|
-
${n}`},y=e=>e.env===void 0?"the top level":`env.${e.env}
|
|
250
|
-
`),{routes:a}
|
|
249
|
+
${n}`},y=e=>e.env===void 0?"the top level":`env.${e.env}`,v=(e,o)=>{const t=e.filter(r=>r.mode==="push"),n=new Map(t.map(r=>[r.bindingName,r])),a=new Map(e.map(r=>[r.name,r])),u=new Map(t.map(r=>[r.name,r])),c=new Map,s=[];for(const r of o){const i=n.get(r.binding);if(i===void 0||r.queue===i.name)continue;const d=a.get(r.queue);if(d!==void 0){s.push(`${y(r)} maps \`${r.binding}\` to "${r.queue}", the declared name of queue \`${d.exportName}\` — batches for "${r.queue}" go to \`${d.exportName}\`, never \`${i.exportName}\`.`);continue}const p=u.get(r.queue);if(p===void 0)u.set(r.queue,i),c.set(r.queue,r);else if(p!==i){const x=c.get(r.queue);s.push(`"${r.queue}" is aliased to \`${p.exportName}\` by ${x===void 0?"an earlier producer":y(x)} and to \`${i.exportName}\` by ${y(r)} — batches for it go to \`${p.exportName}\`.`)}}return{conflicts:s,routes:u}},Z=(e,o)=>v(e,o).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"})),ee=(e,o=[])=>{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,s])=>`import { ${s.map(r=>r.exportName).join(", ")} } from "../${c}.js";`).join(`
|
|
250
|
+
`),{routes:a}=v(e,o),u=[...a].map(([c,s])=>` ${JSON.stringify(c)}: { binding: ${JSON.stringify(s.bindingName)}, definition: ${s.exportName}, exportName: ${JSON.stringify(s.exportName)} },`).join(`
|
|
251
251
|
`);return`${g}/**
|
|
252
252
|
* Push-consumer registry for the queues declared in \`lunora/queues.ts\`. The
|
|
253
253
|
* composed worker's \`queue(batch, env, ctx)\` entry routes each delivered batch
|
|
@@ -262,25 +262,25 @@ ${n}
|
|
|
262
262
|
export const LUNORA_QUEUE_REGISTRY: QueueRegistry = {
|
|
263
263
|
${u}
|
|
264
264
|
};
|
|
265
|
-
`},
|
|
265
|
+
`},te=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 o=e.map(t=>` { className: "${t.className}", exportName: "${t.exportName}" },`).join(`
|
|
266
266
|
`);return{build:`
|
|
267
267
|
const workflows = createWorkflowContext(env, LUNORA_WORKFLOWS, this.state.exports);
|
|
268
268
|
`,contextField:`
|
|
269
269
|
workflows,`,importLines:['import type { WorkflowBindingSpec } from "@lunora/workflow";','import { createWorkflowContext } from "@lunora/workflow";'],specs:`
|
|
270
270
|
/** Wiring specs for \`ctx.workflows\` (codegen-derived from \`lunora/workflows.ts\`). */
|
|
271
271
|
const LUNORA_WORKFLOWS: ReadonlyArray<WorkflowBindingSpec> = [
|
|
272
|
-
${
|
|
272
|
+
${o}
|
|
273
273
|
];
|
|
274
|
-
`}},
|
|
274
|
+
`}},ne=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 o=e.map(t=>` { binding: "${t.bindingName}", exportName: "${t.exportName}", name: ${JSON.stringify(t.name)} },`).join(`
|
|
275
275
|
`);return{build:`
|
|
276
276
|
const queues = createQueueContext(env, LUNORA_QUEUES);
|
|
277
277
|
`,contextField:`
|
|
278
278
|
queues,`,importLines:['import type { QueueBindingSpec } from "@lunora/queue";','import { createQueueContext } from "@lunora/queue";'],specs:`
|
|
279
279
|
/** Wiring specs for \`ctx.queues\` (codegen-derived from \`lunora/queues.ts\`). */
|
|
280
280
|
const LUNORA_QUEUES: ReadonlyArray<QueueBindingSpec> = [
|
|
281
|
-
${
|
|
281
|
+
${o}
|
|
282
282
|
];
|
|
283
|
-
`}},
|
|
283
|
+
`}},oe=(e,o)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};const t=e.map(n=>{l(n.exportName,`topic export "${n.exportName}"`);const a=w(o,n.exportName).map(u=>`{ binding: "${u.bindingName}", exportName: "${u.exportName}" }`).join(", ");return` { exportName: "${n.exportName}", subscriptions: [${a}] },`}).join(`
|
|
284
284
|
`);return{build:`
|
|
285
285
|
const topics = createTopicContext(env, LUNORA_TOPICS);
|
|
286
286
|
`,contextField:`
|
|
@@ -289,18 +289,18 @@ ${r}
|
|
|
289
289
|
const LUNORA_TOPICS: ReadonlyArray<TopicBindingSpec> = [
|
|
290
290
|
${t}
|
|
291
291
|
];
|
|
292
|
-
`}},
|
|
292
|
+
`}},re=(e,o)=>{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(`
|
|
293
293
|
`);return{build:`
|
|
294
294
|
const services = createServices(env, LUNORA_SERVICES);
|
|
295
|
-
`,importLines:[`import type { ServiceBindingSpec } from "${
|
|
295
|
+
`,importLines:[`import type { ServiceBindingSpec } from "${o}";`,`import { createServices } from "${o}";`],specs:`
|
|
296
296
|
/** Wiring specs for \`ctx.services\` (codegen-derived from \`lunora.config\` \`services\`). */
|
|
297
297
|
const LUNORA_SERVICES: ReadonlyArray<ServiceBindingSpec> = [
|
|
298
298
|
${t}
|
|
299
299
|
];
|
|
300
|
-
`}},
|
|
300
|
+
`}},se=(e,o)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};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(`
|
|
301
301
|
`);return{build:`
|
|
302
302
|
const agents = createAgentContext(env, LUNORA_AGENTS, { exports: this.state.exports });
|
|
303
|
-
`,contextField:
|
|
303
|
+
`,contextField:o?`
|
|
304
304
|
agents,
|
|
305
305
|
agentSecrets: this.secretValues,`:`
|
|
306
306
|
agents,`,importLines:['import { createAgentContext } from "@lunora/agent";','import type { AgentBindingSpec } from "@lunora/agent";'],specs:`
|
|
@@ -308,14 +308,24 @@ ${t}
|
|
|
308
308
|
const LUNORA_AGENTS: ReadonlyArray<AgentBindingSpec> = [
|
|
309
309
|
${t}
|
|
310
310
|
];
|
|
311
|
-
`}}
|
|
311
|
+
`}},$=(e,o,t,n,a)=>({constant:`
|
|
312
312
|
${a}
|
|
313
|
-
const ${e} = ${b(n,
|
|
313
|
+
const ${e} = ${b(n,o)};
|
|
314
314
|
`,override:`
|
|
315
|
-
protected override ${t}(): ${
|
|
315
|
+
protected override ${t}(): ${o} {
|
|
316
316
|
return ${e};
|
|
317
317
|
}
|
|
318
|
-
`}),
|
|
318
|
+
`}),ae=(e,o)=>{if(e.length===0)return{constant:"",override:""};const t={...o.length===0?{}:{eventTypes:o.map(n=>n.type)},workflows:e.map(n=>({className:n.className,exportName:n.exportName,name:n.name}))};return $("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. */")},ie=(e,o)=>{if(e.length===0||o.length===0)return{constant:"",override:""};for(const t of o)if(l(t.exportName,"workflow event export name"),!R.test(t.filePath))throw new N("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe workflow event file path: ${JSON.stringify(t.filePath)}`);return{constant:`
|
|
319
|
+
/** Declared workflow events (\`defineWorkflowEvent\` exports), loaded by type when an admin \`sendWorkflowEvent\` parses its payload. */
|
|
320
|
+
const LUNORA_WORKFLOW_EVENTS: ReadonlyMap<string, () => Promise<{ payload: { parse: (value: unknown) => unknown } }>> = new Map([
|
|
321
|
+
${o.map(t=>` [${JSON.stringify(t.type)}, () => import("../${t.filePath}.js").then((module) => module.${t.exportName})],`).join(`
|
|
322
|
+
`)}
|
|
323
|
+
]);
|
|
324
|
+
`,override:`
|
|
325
|
+
protected override async workflowEvent(type: string): Promise<{ payload: { parse: (value: unknown) => unknown } } | undefined> {
|
|
326
|
+
return LUNORA_WORKFLOW_EVENTS.get(type)?.();
|
|
327
|
+
}
|
|
328
|
+
`}},ce=e=>{if(e.length===0)return{constant:"",override:""};const o={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 $("LUNORA_QUEUES_INFO","QueuesResult","queuesMetadata",o,"/** Read-only declared-queue metadata (discovered from `lunora/queues.ts`) served via `__lunora_admin__:listQueues` for the studio's queues view. */")},W=["attach","cancelPayment","cancelSubscription","capturePayment","check","createCheckout","createPortalSession","handleWebhook","listBalances","listSubscriptions","refundPayment","track"],ue=e=>e?{imports:['import type { LunoraDatabaseLike as LunoraPaymentDbLike, LunoraPayment, PaymentsFromContextOptions } from "@lunora/payment";','import { paymentsFromContext } from "@lunora/payment";'],build:`
|
|
319
329
|
const paymentsByContext = new WeakMap<object, LunoraPayment>();
|
|
320
330
|
`,configField:`
|
|
321
331
|
payment?: (env: Record<string, unknown>) => PaymentsFromContextOptions;`,contextField:`
|
|
@@ -330,4 +340,4 @@ const ${e} = ${b(n,r)};
|
|
|
330
340
|
}
|
|
331
341
|
|
|
332
342
|
return payments;
|
|
333
|
-
},`,stub:f("paymentStub: LunoraPayment","ctx.payments: no payment configured. Pass `payment` to createShardDO().",
|
|
343
|
+
},`,stub:f("paymentStub: LunoraPayment","ctx.payments: no payment configured. Pass `payment` to createShardDO().",W,{cast:" as unknown as LunoraPayment",sync:!0})}:{build:"",configField:"",contextField:"",imports:[],stub:""},le=(e,o,t,n,a)=>["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",...a?["SearchBackfillProgress"]:[],"TransactionHeadroomTracker","SchemaLike","ShardDOState","DeliveryAuthorization","ShardRankPageResult","SqlExec","StorageRulesResult","StudioFeaturesResult","SubscriptionIdentity","SystemReaderStorageLike","TelemetrySink",...e?["VectorBackfillProgress"]:[],...o?["WorkflowsResult"]:[],...e?["WriteHook"]:[]];export{M as a,G as b,H as c,ne as d,V as e,oe as f,re as g,Y as h,te as i,se as j,ue as k,ae as l,ie as m,ce as n,Q as o,le as p,U as q,f as r,K as s,z as t,J as u,X as v,Z as w,ee 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.366",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
54
|
-
"@lunora/agent": "1.0.0-alpha.
|
|
55
|
-
"@lunora/container": "1.0.0-alpha.
|
|
53
|
+
"@lunora/advisor": "1.0.0-alpha.266",
|
|
54
|
+
"@lunora/agent": "1.0.0-alpha.257",
|
|
55
|
+
"@lunora/container": "1.0.0-alpha.96",
|
|
56
56
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
57
57
|
"@lunora/platform": "1.0.0-alpha.75",
|
|
58
|
-
"@lunora/queue": "1.0.0-alpha.
|
|
59
|
-
"@lunora/scheduler": "1.0.0-alpha.
|
|
60
|
-
"@lunora/values": "1.0.0-alpha.
|
|
61
|
-
"@lunora/workflow": "1.0.0-alpha.
|
|
58
|
+
"@lunora/queue": "1.0.0-alpha.131",
|
|
59
|
+
"@lunora/scheduler": "1.0.0-alpha.154",
|
|
60
|
+
"@lunora/values": "1.0.0-alpha.85",
|
|
61
|
+
"@lunora/workflow": "1.0.0-alpha.99",
|
|
62
62
|
"@visulima/fs": "7.0.0",
|
|
63
63
|
"jiti": "^2.7.0",
|
|
64
64
|
"quicktype-core": "^26.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./json-data-Chfs2Cz5.mjs";import{o as i,j as r,s as n,h as o,t as g,k as u,d as F,w as p,m as l,g as d,f,i as k,u as w,l as A,v as Q}from"./shard-runtime-DXlpfT3P.mjs";import"./shared-Br_OnErI.mjs";import"./platform-8oj7iXQy.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,n as emitAgents,o as emitContainerFragments,g as emitContainers,u as emitPaymentFragments,F as emitQueueFragments,p as emitQueues,l as emitQueuesMetadataFragments,d as emitServiceFragments,f as emitTopicFragments,k as emitWorkflowFragments,w as emitWorkflows,A as emitWorkflowsMetadataFragments,Q as queueAliasFindings};
|