@lunora/codegen 1.0.0-alpha.249 → 1.0.0-alpha.250
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 +199 -97
- package/dist/index.d.ts +199 -97
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/DEFAULT_TARGET-vMWzRzRF.mjs +1 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-jefy8GTn.mjs +11 -0
- package/dist/packem_shared/capabilities-CqnIsyA9.mjs +20 -0
- package/dist/packem_shared/contextPropertiesRead-BGy4tGCY.mjs +1 -0
- package/dist/packem_shared/emitAgents-3XP5C-VJ.mjs +1 -0
- package/dist/packem_shared/{emitApp-D7U-51na.mjs → emitApp-T_My13i6.mjs} +57 -43
- package/dist/packem_shared/{emitServer-CptcZOTQ.mjs → emitServer-DQxwHVPM.mjs} +61 -63
- package/dist/packem_shared/{emitShard-Bo9uyTJF.mjs → emitShard-BDfiH_JF.mjs} +1 -1
- package/dist/packem_shared/{shard-C0OSxk7u.mjs → shard-f7coQFS9.mjs} +86 -86
- package/dist/packem_shared/{shard-runtime-DvqfDuYO.mjs → shard-runtime-CyEbIjPA.mjs} +98 -119
- package/package.json +10 -10
- package/dist/packem_shared/DEFAULT_TARGET-DmGPe3Uk.mjs +0 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-OKuFxV4v.mjs +0 -11
- package/dist/packem_shared/capabilities-DJJWVEtk.mjs +0 -18
- package/dist/packem_shared/emitAgents-DVgdbmYK.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as
|
|
1
|
+
import{s as v}from"./ir-DBSvhNa-.mjs";import{r as x}from"./json-data-Chfs2Cz5.mjs";import{C as k}from"./capabilities-CqnIsyA9.mjs";import{a as c,G as f}from"./shared-DjUziztz.mjs";const P=e=>e?{importFragment:"serveRelationFanout, ",override:`
|
|
2
2
|
protected override async runRelationFanoutRead(functionPath: string, args: Record<string, unknown>): Promise<unknown> {
|
|
3
3
|
this.ensureMigrated();
|
|
4
4
|
|
|
@@ -6,81 +6,47 @@ import{s as h}from"./ir-DBSvhNa-.mjs";import{r as f}from"./json-data-Chfs2Cz5.mj
|
|
|
6
6
|
|
|
7
7
|
return serveRelationFanout(schema as unknown as SchemaLike, db, functionPath, args);
|
|
8
8
|
}
|
|
9
|
-
`}:{importFragment:"",override:""},
|
|
10
|
-
|
|
11
|
-
// Correlate AI-Gateway-routed calls with the Lunora trace: thread the
|
|
12
|
-
// function path + trace id into createAi, which folds them into the
|
|
13
|
-
// gateway's \`metadata\`. Mirror the tracer's anchor guard — a deferred
|
|
14
|
-
// subscription re-run must not borrow a concurrent dispatch's trace, so
|
|
15
|
-
// read \`getCurrentTrace()\` only on the synchronous (non-threaded-identity) path.
|
|
16
|
-
const aiTrace = options.identity ? undefined : this.getCurrentTrace();
|
|
17
|
-
// \`telemetry\` gives every model call an \`ai.generate\` / \`ai.stream\` span
|
|
18
|
-
// and \`gen_ai.usage.*\` token + cost counters attributed to this function.
|
|
19
|
-
const ai: LunoraAi = createAi({
|
|
20
|
-
binding: aiBinding as AiBindingLike | undefined,
|
|
21
|
-
env: env as Record<string, unknown>,
|
|
22
|
-
metadata: { functionPath: options.functionPath, traceId: aiTrace?.traceId },
|
|
23
|
-
telemetry: { metrics, trace },
|
|
24
|
-
});
|
|
25
|
-
`,configField:`
|
|
26
|
-
ai?: (env: Record<string, unknown>) => AiBindingLike;`}:{build:"",configField:""},u=(e,t,n,{cast:r="",sync:o=[]}={})=>{const l=n.map(d=>` ${d}: ${o.includes(d)?"":"async "}() => {
|
|
27
|
-
${t}
|
|
9
|
+
`}:{importFragment:"",override:""},y=(e,r,t,{cast:n="",sync:o=[]}={})=>{const i=t.map(u=>` ${u}: ${o.includes(u)?"":"async "}() => {
|
|
10
|
+
${r}
|
|
28
11
|
},`).join(`
|
|
29
12
|
`);return`
|
|
30
13
|
const ${e} = {
|
|
31
|
-
${
|
|
32
|
-
}${
|
|
33
|
-
`},
|
|
14
|
+
${i}
|
|
15
|
+
}${n};
|
|
16
|
+
`},h={build:"",configField:"",contextField:"",importLines:[],stub:""},W=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:`
|
|
34
17
|
/** The \`.shardBy()\` tables this shard registers with the shard registry when it writes them. */
|
|
35
|
-
const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(
|
|
18
|
+
const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(r=>JSON.stringify(r)).join(", ")}]);
|
|
36
19
|
`,override:`
|
|
37
20
|
protected override shardRegistry(): undefined | { namespace: unknown; shardedTables: ReadonlySet<string> } {
|
|
38
21
|
const namespace = config.shardRegistry?.((this.env ?? {}) as Record<string, unknown>);
|
|
39
22
|
|
|
40
23
|
return namespace === undefined ? undefined : { namespace, shardedTables: SHARDED_TABLES };
|
|
41
24
|
}
|
|
42
|
-
`},
|
|
43
|
-
const
|
|
44
|
-
// KV is not this shard's SQLite, so nothing appends a \`__cdc_log\` entry
|
|
45
|
-
// when a value changes — a subscription that read one can never be proven
|
|
46
|
-
// current on reconnect and must re-snapshot. Reads only; \`put\`/\`delete\`
|
|
47
|
-
// are writes and stay unstamped.
|
|
48
|
-
const kv: Kv = markUnvouchableReads(kvBinding ? createKv({ namespace: kvBinding as KVNamespaceLike }) : kvStub, options.onRead, [
|
|
49
|
-
"get",
|
|
50
|
-
"getRaw",
|
|
51
|
-
"getWithMetadata",
|
|
52
|
-
"list",
|
|
53
|
-
]);
|
|
54
|
-
`,configField:`
|
|
55
|
-
kv?: (env: Record<string, unknown>) => KVNamespaceLike;`,contextField:`
|
|
56
|
-
kv,`,importLines:['import type { Kv, KVNamespaceLike } from "@lunora/bindings/kv";','import { createKv } from "@lunora/bindings/kv";'],stub:u("kvStub: Kv",'throw new Error("ctx.kv: no KV binding found. Add a \\`kv_namespaces\\` binding (env.KV) to wrangler.jsonc, or pass \\`kv\\` to createShardDO().");',["delete","get","getRaw","getWithMetadata","list","put"])}:c,$=(e,t)=>e?{build:`
|
|
57
|
-
const flags: import("${t}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
25
|
+
`},I=(e,r)=>e?{build:`
|
|
26
|
+
const flags: import("${r}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
58
27
|
provider: () => config.flags?.(env),
|
|
59
28
|
targetingKey: () => flagsConfig.identify?.({ identity: identity ?? null, userId: userId ?? null }),
|
|
60
29
|
});
|
|
61
30
|
`,configField:`
|
|
62
|
-
flags?: (env: Record<string, unknown>) => import("${
|
|
63
|
-
flags,`,importLines:[`import { createFlags } from "${
|
|
31
|
+
flags?: (env: Record<string, unknown>) => import("${r}").Provider;`,contextField:`
|
|
32
|
+
flags,`,importLines:[`import { createFlags } from "${r}";`,'import flagsConfig from "../flags.js";'],stub:""}:h,T=e=>e?{build:`
|
|
64
33
|
const { notify, push } = createNotify(notifyConfig, env, { log, metrics });
|
|
65
34
|
`,configField:"",contextField:`
|
|
66
35
|
notify,
|
|
67
|
-
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:
|
|
36
|
+
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:h,q=e=>e?{build:`
|
|
68
37
|
const envConfig = lunoraEnvContract.${e.exportName}(env);
|
|
69
38
|
`,configField:"",contextField:`
|
|
70
|
-
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:
|
|
71
|
-
const access = accessFacade(identity, userId);
|
|
72
|
-
`,configField:"",contextField:`
|
|
73
|
-
access,`,importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}:c,F=(e,t,n)=>{if(!t)return{constant:"",evaluateOverride:"",subscriptionOverride:""};const r=s=>`
|
|
39
|
+
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:h,B=(e,r,t)=>{if(!r)return{constant:"",evaluateOverride:"",subscriptionOverride:""};const n=s=>`
|
|
74
40
|
const env = (this.env ?? {}) as Record<string, unknown>;
|
|
75
|
-
const flags: import("${
|
|
41
|
+
const flags: import("${t}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
76
42
|
provider: () => config.flags?.(env),
|
|
77
43
|
targetingKey: ${s},
|
|
78
44
|
});`,o=`
|
|
79
45
|
/** Statically-discovered feature flags (\`ctx.flags.<type>("key")\` reads) served via \`__lunora_admin__:listFlags\` + the reactive \`__lunora_flags__:\` channel. */
|
|
80
|
-
const LUNORA_FLAG_KEYS = ${
|
|
81
|
-
`,
|
|
82
|
-
protected override async evaluateFlags(context?: Record<string, unknown>): Promise<FlagsResult> {${
|
|
83
|
-
const evalContext = context as import("${
|
|
46
|
+
const LUNORA_FLAG_KEYS = ${x(e,'ReadonlyArray<{ key: string; type: "boolean" | "number" | "object" | "string" }>')};
|
|
47
|
+
`,i=`
|
|
48
|
+
protected override async evaluateFlags(context?: Record<string, unknown>): Promise<FlagsResult> {${n("undefined")}
|
|
49
|
+
const evalContext = context as import("${t}").EvaluationContext | undefined;
|
|
84
50
|
const evaluations: FlagsResult["flags"] = [];
|
|
85
51
|
|
|
86
52
|
for (const entry of LUNORA_FLAG_KEYS) {
|
|
@@ -99,8 +65,8 @@ const LUNORA_FLAG_KEYS = ${f(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
99
65
|
|
|
100
66
|
return { configured: true, flags: evaluations };
|
|
101
67
|
}
|
|
102
|
-
`,
|
|
103
|
-
protected override runFlagSubscriptionRead(_functionPath: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): Promise<unknown> {${
|
|
68
|
+
`,u=`
|
|
69
|
+
protected override runFlagSubscriptionRead(_functionPath: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): Promise<unknown> {${n("() => flagsConfig.identify?.({ identity: identity?.identity ?? null, userId: identity?.userId ?? null })")}
|
|
104
70
|
const key = typeof args.key === "string" ? args.key : "";
|
|
105
71
|
|
|
106
72
|
// SECURITY: the reactive channel is public (any socket, no auth). Serve
|
|
@@ -127,30 +93,31 @@ const LUNORA_FLAG_KEYS = ${f(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
127
93
|
}
|
|
128
94
|
|
|
129
95
|
if (args.type === "object") {
|
|
130
|
-
return flags.object(key, (args.default ?? {}) as import("${
|
|
96
|
+
return flags.object(key, (args.default ?? {}) as import("${t}").JsonValue, context);
|
|
131
97
|
}
|
|
132
98
|
|
|
133
99
|
return flags.boolean(key, typeof args.default === "boolean" ? args.default : false, context);
|
|
134
100
|
}
|
|
135
|
-
`;return{constant:o,evaluateOverride:
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
101
|
+
`;return{constant:o,evaluateOverride:i,subscriptionOverride:u}},R=()=>({build:`
|
|
102
|
+
const aiBinding = config.ai?.(env) ?? (env as Record<string, unknown>).AI;
|
|
103
|
+
// Correlate AI-Gateway-routed calls with the Lunora trace: thread the
|
|
104
|
+
// function path + trace id into createAi, which folds them into the
|
|
105
|
+
// gateway's \`metadata\`. Mirror the tracer's anchor guard — a deferred
|
|
106
|
+
// subscription re-run must not borrow a concurrent dispatch's trace, so
|
|
107
|
+
// read \`getCurrentTrace()\` only on the synchronous (non-threaded-identity) path.
|
|
108
|
+
const aiTrace = options.identity ? undefined : this.getCurrentTrace();
|
|
109
|
+
// \`telemetry\` gives every model call an \`ai.generate\` / \`ai.stream\` span
|
|
110
|
+
// and \`gen_ai.usage.*\` token + cost counters attributed to this function.
|
|
111
|
+
const ai: LunoraAi = createAi({
|
|
112
|
+
binding: aiBinding as AiBindingLike | undefined,
|
|
113
|
+
env: env as Record<string, unknown>,
|
|
114
|
+
metadata: { functionPath: options.functionPath, traceId: aiTrace?.traceId },
|
|
115
|
+
telemetry: { metrics, trace },
|
|
116
|
+
});
|
|
151
117
|
`,configField:`
|
|
152
|
-
|
|
153
|
-
|
|
118
|
+
ai?: (env: Record<string, unknown>) => AiBindingLike;`,importLines:['import type { AiBindingLike, LunoraAi } from "@lunora/ai";','import { createAi } from "@lunora/ai";'],stub:""}),N=()=>({build:`
|
|
119
|
+
const access = accessFacade(identity, userId);
|
|
120
|
+
`,configField:"",importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}),S=()=>({build:`
|
|
154
121
|
const r2sqlEnv = env as Record<string, unknown>;
|
|
155
122
|
const r2sqlAccountId = (r2sqlEnv.R2_SQL_ACCOUNT_ID ?? r2sqlEnv.CLOUDFLARE_ACCOUNT_ID) as string | undefined;
|
|
156
123
|
const r2sqlToken = r2sqlEnv.R2_SQL_TOKEN as string | undefined;
|
|
@@ -161,19 +128,31 @@ const LUNORA_FLAG_KEYS = ${f(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
161
128
|
? createR2Sql({ accountId: r2sqlAccountId, apiToken: r2sqlToken, bucket: r2sqlBucket })
|
|
162
129
|
: r2sqlStub;
|
|
163
130
|
`,configField:`
|
|
164
|
-
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,
|
|
165
|
-
|
|
166
|
-
|
|
131
|
+
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:y("r2sqlStub: R2SqlClient",'throw new Error("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"]})}),b={access:N,ai:R,r2sql:S},d=" ",w=(e,r,t)=>{const n=`${e}Binding`,{factory:o}=t;let i=`(${n} as ${r})`;if(o!==void 0){const u=`${n} as ${t.bindingType??r}`;i=o.option===void 0?`${o.name}(${u})`:`${o.name}({ ${o.option}: ${u} })`}return`${n} ? ${i} : ${e}Stub`},L=(e,r,t)=>{const n=w(e,r,t),o=`${d}const ${e}Binding = config.${e}?.(env) ?? (env as Record<string, unknown>).${t.envName};
|
|
132
|
+
`,i=t.unvouchableReads??[];return i.length===0?`
|
|
133
|
+
${o}${d}const ${e}: ${r} = ${n};
|
|
134
|
+
`:`
|
|
135
|
+
${o}${d}// ${t.envName} is not this shard's SQLite, so nothing appends a \`__cdc_log\` entry
|
|
136
|
+
${d}// when a value changes — a subscription that read one can never be proven
|
|
137
|
+
${d}// current on reconnect and must re-snapshot. Reads only; writes stay unstamped.
|
|
138
|
+
${d}const ${e}: ${r} = markUnvouchableReads(${n}, options.onRead, [
|
|
139
|
+
${i.map(u=>`${d} ${JSON.stringify(u)},`).join(`
|
|
140
|
+
`)}
|
|
141
|
+
${d}]);
|
|
142
|
+
`},C=(e,r,t)=>{const{binding:n,clientType:o}=t,i=y(`${e}Stub: ${o}`,`throw new Error("${t.missingMessage}");`,t.stubMethods,{sync:t.syncStubMethods});if(n===void 0)return{build:`
|
|
143
|
+
${d}const ${e}: ${o} = config.${e} ? config.${e}(env) : ${e}Stub;
|
|
167
144
|
`,configField:`
|
|
168
|
-
|
|
169
|
-
|
|
145
|
+
${e}?: (env: Record<string, unknown>) => ${o};`,importLines:[`import type { ${o} } from "${r}";`],stub:i};const u=n.bindingType??o,s=[...new Set([u,o])].toSorted((l,a)=>l.localeCompare(a));return{build:L(e,o,n),configField:`
|
|
146
|
+
${e}?: (env: Record<string, unknown>) => ${u};`,importLines:[`import type { ${s.join(", ")} } from "${r}";`,...n.factory===void 0?[]:[`import { ${n.factory.name} } from "${r}";`]],stub:i}},A=e=>Object.hasOwn(b,e),D=e=>{const r=[],t=[];let n="",o="",i="",u="",s="";for(const l of k){const{key:a,shardBinding:m}=l;if(m===void 0||!e.has(a))continue;const g=l.contextProperty;let p;A(a)?p=b[a]():m!=="bespoke"&&(p=C(g,l.moduleSpecifier,m)),p!==void 0&&(t.push(...p.importLines),o+=p.configField,s+=p.stub,l.tier==="every"?(i+=p.build,u+=`
|
|
147
|
+
${g},`):(n+=p.build,r.push(g)))}return{actionBuild:n,actionFields:r,configFields:o,everyBuild:i,everyFields:u,importLines:t,stubs:s}},U=(e,r)=>{if(e.length===0)return"";const t=r?`, ${JSON.stringify(r)}`:"",n=e.map(a=>{c(a.exportName,`container export "${a.exportName}"`),c(a.className,`container class "${a.className}"`);const m=a.sandbox===!0?"LunoraSandboxContainer":"LunoraContainer";return`/** Container DO for the \`${a.exportName}\` definition (binding \`${a.bindingName}\`). */
|
|
148
|
+
export class ${a.className} extends ${m} {
|
|
170
149
|
public constructor(ctx: ConstructorParameters<typeof ${m}>[0], env: Record<string, unknown>) {
|
|
171
|
-
super(ctx, env, ${
|
|
150
|
+
super(ctx, env, ${a.exportName}, "${a.exportName}"${t});
|
|
172
151
|
}
|
|
173
152
|
}
|
|
174
153
|
`}).join(`
|
|
175
|
-
`),o=e.map(
|
|
176
|
-
`:"";return`${
|
|
154
|
+
`),o=e.map(a=>a.exportName).join(", "),i=e.some(a=>a.sandbox===!0),u=e.some(a=>a.sandbox!==!0)?`import { LunoraContainer } from "@lunora/container/do";
|
|
155
|
+
`:"";return`${f}/**
|
|
177
156
|
* Container-enabled Durable Object classes for the containers declared in
|
|
178
157
|
* \`lunora/containers.ts\`. Re-export them from your worker entry — wrangler
|
|
179
158
|
* requires each \`containers[].class_name\` to be exported by the worker:
|
|
@@ -185,35 +164,35 @@ export class ${i.className} extends ${m} {
|
|
|
185
164
|
* \`handle.egress\` controls) routes container outbound traffic through this
|
|
186
165
|
* WorkerEntrypoint, so it too must be exported by the deployed worker.
|
|
187
166
|
*/
|
|
188
|
-
${
|
|
167
|
+
${u}${i?`import { LunoraSandboxContainer } from "@lunora/container/sandbox";
|
|
189
168
|
`:""}
|
|
190
169
|
import { ${o} } from "../containers.js";
|
|
191
170
|
|
|
192
171
|
export { ContainerProxy } from "@lunora/container/do";
|
|
193
|
-
${
|
|
172
|
+
${i?`
|
|
194
173
|
/**
|
|
195
174
|
* \`DirectoryBackup\` and \`S3Mount\` route a \`sandbox: true\` container's storage
|
|
196
175
|
* traffic through these WorkerEntrypoints, so the deployed worker must export them.
|
|
197
176
|
*/
|
|
198
177
|
export { DirectoryBackupGateway, S3Gateway } from "@lunora/container/sandbox";
|
|
199
178
|
`:""}
|
|
200
|
-
${
|
|
179
|
+
${n}`},j=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)c(n.exportName,`container export "${n.exportName}"`),c(n.bindingName,`container binding "${n.bindingName}"`);const t=e.map(n=>{const o=n.schedulingPolicy!==void 0||n.maxInstances===void 0?"":`, maxInstances: ${String(n.maxInstances)}`;return` { binding: "${n.bindingName}", exportName: "${n.exportName}"${o} },`}).join(`
|
|
201
180
|
`);return{build:`
|
|
202
|
-
const containers = createContainerContext(env, LUNORA_CONTAINERS, ${
|
|
181
|
+
const containers = createContainerContext(env, LUNORA_CONTAINERS, ${r?JSON.stringify(r):"undefined"}, this.getCurrentTraceparent(), this.getCurrentSampleErrors());
|
|
203
182
|
`,contextField:`
|
|
204
183
|
containers,`,importLines:['import type { ContainerBindingSpec } from "@lunora/container";','import { createContainerContext } from "@lunora/container";'],specs:`
|
|
205
184
|
/** Wiring specs for \`ctx.containers\` (codegen-derived from \`lunora/containers.ts\`). */
|
|
206
185
|
const LUNORA_CONTAINERS: ReadonlyArray<ContainerBindingSpec> = [
|
|
207
|
-
${
|
|
186
|
+
${t}
|
|
208
187
|
];
|
|
209
|
-
`}},
|
|
210
|
-
export class ${
|
|
188
|
+
`}},Q=e=>{if(e.length===0)return"";const r=e.map(n=>(c(n.exportName,`workflow export "${n.exportName}"`),c(n.className,`workflow class "${n.className}"`),`/** WorkflowEntrypoint for the \`${n.exportName}\` definition, reached as \`ctx.exports.${n.className}\`. */
|
|
189
|
+
export class ${n.className} extends LunoraWorkflow<WorkflowParamsOf<typeof ${n.exportName}>, WorkflowOutputOf<typeof ${n.exportName}>> {
|
|
211
190
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
212
|
-
super(ctx, env, ${
|
|
191
|
+
super(ctx, env, ${n.exportName}, "${n.exportName}");
|
|
213
192
|
}
|
|
214
193
|
}
|
|
215
194
|
`)).join(`
|
|
216
|
-
`),
|
|
195
|
+
`),t=e.map(n=>n.exportName).join(", ");return`${f}/**
|
|
217
196
|
* WorkflowEntrypoint classes for the workflows declared in
|
|
218
197
|
* \`lunora/workflows.ts\`. Re-export them from your worker entry — wrangler
|
|
219
198
|
* requires each \`workflows[].class_name\` to be exported by the worker:
|
|
@@ -222,7 +201,7 @@ export class ${r.className} extends LunoraWorkflow<WorkflowParamsOf<typeof ${r.e
|
|
|
222
201
|
*/
|
|
223
202
|
import LunoraWorkflow from "@lunora/workflow/do";
|
|
224
203
|
|
|
225
|
-
import { ${
|
|
204
|
+
import { ${t} } from "../workflows.js";
|
|
226
205
|
|
|
227
206
|
/** Params type carried by a \`defineWorkflow\` definition (its phantom \`__params\`), so each entrypoint keeps the authored \`ctx.params\` type. */
|
|
228
207
|
type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params }
|
|
@@ -234,36 +213,36 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
|
|
|
234
213
|
/** Output type carried by a \`defineWorkflow\` definition (its phantom \`__output\`), so each entrypoint keeps the authored return type. */
|
|
235
214
|
type WorkflowOutputOf<Definition> = Definition extends { __output?: infer Output } ? Output : unknown;
|
|
236
215
|
|
|
237
|
-
${
|
|
216
|
+
${r}`},M=e=>{if(e.length===0)return"";const t=e.filter(s=>s.voice).length>0,n=e.map(s=>{c(s.exportName,`agent export "${s.exportName}"`),c(s.className,`agent class "${s.className}"`);const l=`/** WorkflowEntrypoint for the \`${s.exportName}\` agent, reached as \`ctx.exports.${s.className}\`. */
|
|
238
217
|
export class ${s.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult> {
|
|
239
218
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
240
219
|
super(ctx, env, compileAgentWorkflow(${s.exportName}, "${s.exportName}"), "${s.exportName}");
|
|
241
220
|
}
|
|
242
221
|
}
|
|
243
|
-
`;if(!s.voice)return
|
|
222
|
+
`;if(!s.voice)return l;const a=s.voiceClassName??"",m=s.voiceBindingName??"";c(a,`agent voice class "${a}"`);const g=`
|
|
244
223
|
/** Voice-session Durable Object for the \`${s.exportName}\` agent (binding \`${m}\`). */
|
|
245
|
-
export class ${
|
|
224
|
+
export class ${a} extends VoiceSessionDO {
|
|
246
225
|
public constructor(ctx: ConstructorParameters<typeof VoiceSessionDO>[0], env: Record<string, unknown>) {
|
|
247
226
|
super(ctx, env, ${s.exportName}, "${s.exportName}");
|
|
248
227
|
}
|
|
249
228
|
}
|
|
250
|
-
`;return`${
|
|
251
|
-
`),o=e.map(s=>s.exportName).join(", ");return`${
|
|
229
|
+
`;return`${l}${g}`}).join(`
|
|
230
|
+
`),o=e.map(s=>s.exportName).join(", ");return`${f}/**
|
|
252
231
|
* WorkflowEntrypoint classes for the agents declared in \`lunora/agents.ts\`.
|
|
253
232
|
* Each \`defineAgent\` compiles a replay-safe tool-loop onto a Cloudflare
|
|
254
233
|
* Workflow. Re-export them from your worker entry — wrangler requires each
|
|
255
234
|
* \`workflows[].class_name\` to be exported by the worker:
|
|
256
235
|
*
|
|
257
|
-
* \`export * from "./lunora/_generated/agents.js";\`${
|
|
236
|
+
* \`export * from "./lunora/_generated/agents.js";\`${t?"\n *\n * Voice-enabled agents ALSO get a `VoiceSessionDO` subclass here — a real\n * Durable Object (unlike the Workflow), so wrangler needs both its\n * `durable_objects` binding and its `class_name` export (the same re-export\n * line covers it).":""}
|
|
258
237
|
*/
|
|
259
238
|
import LunoraWorkflow from "@lunora/workflow/do";
|
|
260
|
-
${
|
|
239
|
+
${t?'import { compileAgentWorkflow, VoiceSessionDO } from "@lunora/agent";':'import { compileAgentWorkflow } from "@lunora/agent";'}
|
|
261
240
|
import type { AgentRunInput, AgentRunResult } from "@lunora/agent";
|
|
262
241
|
|
|
263
242
|
import { ${o} } from "../agents.js";
|
|
264
243
|
|
|
265
|
-
${
|
|
266
|
-
`);return`${
|
|
244
|
+
${n}`},K=e=>{const r=e.filter(o=>o.mode==="push");if(r.length===0)return"";for(const o of r)c(o.exportName,`queue export "${o.exportName}"`);const t=r.map(o=>o.exportName).join(", "),n=r.map(o=>` ${JSON.stringify(o.name)}: { binding: ${JSON.stringify(o.bindingName)}, definition: ${o.exportName}, exportName: ${JSON.stringify(o.exportName)} },`).join(`
|
|
245
|
+
`);return`${f}/**
|
|
267
246
|
* Push-consumer registry for the queues declared in \`lunora/queues.ts\`. The
|
|
268
247
|
* composed worker's \`queue(batch, env, ctx)\` entry routes each delivered batch
|
|
269
248
|
* by \`batch.queue\` to the matching \`defineQueue\` handler. Wired automatically
|
|
@@ -271,72 +250,72 @@ ${r}`},j=e=>{const t=e.filter(o=>o.mode==="push");if(t.length===0)return"";for(c
|
|
|
271
250
|
*/
|
|
272
251
|
import type { QueueRegistry } from "@lunora/queue";
|
|
273
252
|
|
|
274
|
-
import { ${
|
|
253
|
+
import { ${t} } from "../queues.js";
|
|
275
254
|
|
|
276
255
|
/** Stable wrangler queue name → { binding, definition, exportName } for batch routing. */
|
|
277
256
|
export const LUNORA_QUEUE_REGISTRY: QueueRegistry = {
|
|
278
|
-
${
|
|
257
|
+
${n}
|
|
279
258
|
};
|
|
280
|
-
`},
|
|
259
|
+
`},G=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const t of e)c(t.exportName,`workflow export "${t.exportName}"`),c(t.className,`workflow class "${t.className}"`);const r=e.map(t=>` { className: "${t.className}", exportName: "${t.exportName}" },`).join(`
|
|
281
260
|
`);return{build:`
|
|
282
261
|
const workflows = createWorkflowContext(env, LUNORA_WORKFLOWS, this.state.exports);
|
|
283
262
|
`,contextField:`
|
|
284
263
|
workflows,`,importLines:['import type { WorkflowBindingSpec } from "@lunora/workflow";','import { createWorkflowContext } from "@lunora/workflow";'],specs:`
|
|
285
264
|
/** Wiring specs for \`ctx.workflows\` (codegen-derived from \`lunora/workflows.ts\`). */
|
|
286
265
|
const LUNORA_WORKFLOWS: ReadonlyArray<WorkflowBindingSpec> = [
|
|
287
|
-
${
|
|
266
|
+
${r}
|
|
288
267
|
];
|
|
289
|
-
`}},
|
|
268
|
+
`}},H=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const t of e)c(t.exportName,`queue export "${t.exportName}"`),c(t.bindingName,`queue binding "${t.bindingName}"`);const r=e.map(t=>` { binding: "${t.bindingName}", exportName: "${t.exportName}", name: ${JSON.stringify(t.name)} },`).join(`
|
|
290
269
|
`);return{build:`
|
|
291
270
|
const queues = createQueueContext(env, LUNORA_QUEUES);
|
|
292
271
|
`,contextField:`
|
|
293
272
|
queues,`,importLines:['import type { QueueBindingSpec } from "@lunora/queue";','import { createQueueContext } from "@lunora/queue";'],specs:`
|
|
294
273
|
/** Wiring specs for \`ctx.queues\` (codegen-derived from \`lunora/queues.ts\`). */
|
|
295
274
|
const LUNORA_QUEUES: ReadonlyArray<QueueBindingSpec> = [
|
|
296
|
-
${
|
|
275
|
+
${r}
|
|
297
276
|
];
|
|
298
|
-
`}},
|
|
277
|
+
`}},V=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};const t=e.map(n=>{c(n.exportName,`topic export "${n.exportName}"`);const o=v(r,n.exportName).map(i=>`{ binding: "${i.bindingName}", exportName: "${i.exportName}" }`).join(", ");return` { exportName: "${n.exportName}", subscriptions: [${o}] },`}).join(`
|
|
299
278
|
`);return{build:`
|
|
300
279
|
const topics = createTopicContext(env, LUNORA_TOPICS);
|
|
301
280
|
`,contextField:`
|
|
302
281
|
topics,`,importLines:['import type { TopicBindingSpec } from "@lunora/queue";','import { createTopicContext } from "@lunora/queue";'],specs:`
|
|
303
282
|
/** Wiring specs for \`ctx.topics\` (codegen-derived from \`lunora/queues.ts\`): each topic's subscription queues. */
|
|
304
283
|
const LUNORA_TOPICS: ReadonlyArray<TopicBindingSpec> = [
|
|
305
|
-
${
|
|
284
|
+
${t}
|
|
306
285
|
];
|
|
307
|
-
`}},
|
|
286
|
+
`}},J=(e,r)=>{if(e.length===0)return{build:"",importLines:[],specs:""};const t=e.map(n=>(c(n.name,`service "${n.name}"`),c(n.binding,`service binding "${n.binding}"`),` { binding: "${n.binding}", name: "${n.name}"${n.rpcEntrypoint===void 0?"":", rpc: true"} },`)).join(`
|
|
308
287
|
`);return{build:`
|
|
309
288
|
const services = createServices(env, LUNORA_SERVICES);
|
|
310
|
-
`,importLines:[`import type { ServiceBindingSpec } from "${
|
|
289
|
+
`,importLines:[`import type { ServiceBindingSpec } from "${r}";`,`import { createServices } from "${r}";`],specs:`
|
|
311
290
|
/** Wiring specs for \`ctx.services\` (codegen-derived from \`lunora.config\` \`services\`). */
|
|
312
291
|
const LUNORA_SERVICES: ReadonlyArray<ServiceBindingSpec> = [
|
|
313
|
-
${
|
|
292
|
+
${t}
|
|
314
293
|
];
|
|
315
|
-
`}},
|
|
294
|
+
`}},Y=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const t of e)c(t.exportName,`agent export "${t.exportName}"`),c(t.className,`agent class "${t.className}"`);const r=e.map(t=>` { className: "${t.className}", exportName: "${t.exportName}"${t.publicRun===!0?", publicRun: true":""} },`).join(`
|
|
316
295
|
`);return{build:`
|
|
317
296
|
const agents = createAgentContext(env, LUNORA_AGENTS, { exports: this.state.exports });
|
|
318
297
|
`,contextField:`
|
|
319
298
|
agents,`,importLines:['import { createAgentContext } from "@lunora/agent";','import type { AgentBindingSpec } from "@lunora/agent";'],specs:`
|
|
320
299
|
/** Wiring specs for \`ctx.agents\` (codegen-derived from \`lunora/agents.ts\`). */
|
|
321
300
|
const LUNORA_AGENTS: ReadonlyArray<AgentBindingSpec> = [
|
|
322
|
-
${
|
|
301
|
+
${r}
|
|
323
302
|
];
|
|
324
|
-
`}}
|
|
303
|
+
`}},$=(e,r,t,n,o)=>({constant:`
|
|
325
304
|
${o}
|
|
326
|
-
const ${e} = ${
|
|
305
|
+
const ${e} = ${x(n,r)};
|
|
327
306
|
`,override:`
|
|
328
|
-
protected override ${
|
|
307
|
+
protected override ${t}(): ${r} {
|
|
329
308
|
return ${e};
|
|
330
309
|
}
|
|
331
|
-
`}),
|
|
310
|
+
`}),X=e=>{if(e.length===0)return{constant:"",override:""};const r={workflows:e.map(t=>({className:t.className,exportName:t.exportName,name:t.name}))};return $("LUNORA_WORKFLOWS_INFO","WorkflowsResult","workflowsMetadata",r,"/** Read-only declared-workflow metadata (discovered from `lunora/workflows.ts`) served via `__lunora_admin__:listWorkflows` for the studio's workflows view. */")},z=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 $("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. */")},Z=e=>e?{imports:['import type { LunoraDatabaseLike as LunoraPaymentDbLike, LunoraPayment, PaymentsFromContextOptions } from "@lunora/payment";','import { paymentsFromContext } from "@lunora/payment";'],build:`
|
|
332
311
|
const payments: LunoraPayment = config.payment
|
|
333
312
|
? paymentsFromContext({ auth: { userId: userId ?? null }, db: db as unknown as LunoraPaymentDbLike }, config.payment(env))
|
|
334
313
|
: paymentStub;
|
|
335
314
|
`,configField:`
|
|
336
315
|
payment?: (env: Record<string, unknown>) => PaymentsFromContextOptions;`,contextField:`
|
|
337
|
-
payments,`,stub:
|
|
316
|
+
payments,`,stub:y("paymentStub: LunoraPayment",'throw new Error("ctx.payments: no payment configured. Pass \\`payment\\` to createShardDO().");',["attach","cancelSubscription","check","createCheckout","createPortalSession","handleWebhook","listBalances","listSubscriptions","track"],{cast:" as unknown as LunoraPayment",sync:["attach","cancelSubscription","check","createCheckout","createPortalSession","handleWebhook","listBalances","listSubscriptions","track"]})}:{build:"",configField:"",contextField:"",imports:[],stub:""},ee=e=>e?{imports:['import type { X402Pay, X402PayConfig } from "@lunora/x402/pay";','import { lazyX402Pay } from "@lunora/x402/pay";'],build:`
|
|
338
317
|
const x402: X402Pay = config.x402
|
|
339
318
|
? lazyX402Pay(config.x402(env), { getSecret: (name: string) => secrets.get(name) })
|
|
340
319
|
: x402Stub;
|
|
341
320
|
`,configField:`
|
|
342
|
-
x402?: (env: Record<string, unknown>) => X402PayConfig;`,stub:
|
|
321
|
+
x402?: (env: Record<string, unknown>) => X402PayConfig;`,stub:y("x402Stub: X402Pay",'throw new Error("ctx.x402: no pay rail configured. Pass \\`x402\\` to createShardDO().");',["fetch"],{cast:" as unknown as X402Pay",sync:["fetch"]})}:{build:"",configField:"",imports:[],stub:""},te=(e,r,t,n,o)=>["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",...o?["SearchBackfillProgress"]:[],"TransactionHeadroomTracker","SchemaLike","ShardDOState","ShardRankPageResult","SqlExec","StorageRulesResult","StudioFeaturesResult","SubscriptionIdentity","SystemReaderStorageLike","TelemetrySink",...e?["VectorBackfillProgress"]:[],...r?["WorkflowsResult"]:[],...e?["WriteHook"]:[]];export{I as a,B as b,q as c,H as d,D as e,V as f,J as g,j as h,G as i,Y as j,Z as k,ee as l,X as m,z as n,W as o,te as p,P as q,y as r,T as s,M as t,U as u,Q as v,K as w};
|
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.250",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
50
|
-
"@lunora/agent": "1.0.0-alpha.
|
|
51
|
-
"@lunora/container": "1.0.0-alpha.
|
|
52
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
53
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
54
|
-
"@lunora/queue": "1.0.0-alpha.
|
|
55
|
-
"@lunora/scheduler": "1.0.0-alpha.
|
|
56
|
-
"@lunora/values": "1.0.0-alpha.
|
|
57
|
-
"@lunora/workflow": "1.0.0-alpha.
|
|
49
|
+
"@lunora/advisor": "1.0.0-alpha.181",
|
|
50
|
+
"@lunora/agent": "1.0.0-alpha.163",
|
|
51
|
+
"@lunora/container": "1.0.0-alpha.66",
|
|
52
|
+
"@lunora/errors": "1.0.0-alpha.49",
|
|
53
|
+
"@lunora/platform": "1.0.0-alpha.50",
|
|
54
|
+
"@lunora/queue": "1.0.0-alpha.86",
|
|
55
|
+
"@lunora/scheduler": "1.0.0-alpha.104",
|
|
56
|
+
"@lunora/values": "1.0.0-alpha.59",
|
|
57
|
+
"@lunora/workflow": "1.0.0-alpha.70",
|
|
58
58
|
"jiti": "^2.7.0",
|
|
59
59
|
"quicktype-core": "^26.0.0",
|
|
60
60
|
"ts-morph": "^28.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h,CELLD_CAPABILITIES as b}from"@lunora/platform";import{readProjectConfigLiterals as g}from"./loadProjectConfig-nNIDOrlR.mjs";const c="cloudflare",v=t=>{const{target:e}=g(t);return e!==void 0&&e.length>0?e:void 0},A=(t,e)=>e??v(t)??c,L=(t,e)=>{if(e!==void 0)return[];const{target:a,unreadable:r}=g(t);return r!==!0||a!==void 0?[]:[{level:"warn",message:`lunora.config declares a \`target\` that codegen cannot read without evaluating it, so the "${c}" surface was emitted. \`runCodegen\` resolves the target synchronously, which means it reads literals only.`,name:"platform_unreadable_target",remediation:`Write \`target\` as a string literal on the config's default export (\`export default { target: "${c}" }\`), or pass \`--target\`.`,target:c}]},u={celld:b,cloudflare:h,node:f},C=()=>Object.keys(u).toSorted((t,e)=>t.localeCompare(e)),w={access:null,ai:"ai",analytics:"analytics",browser:"browser",container:"containers",flags:null,hyperdrive:"hyperdrive",images:"images",kv:"keyValueStore",mail:"mail",notify:null,payments:null,pipelines:"pipelines",r2sql:null,scheduler:"scheduler",storage:"objectStorage",vectors:"vectorStore",workflows:"workflows",x402:null},S=["agents","commitOrderedTables","containerEgressPolicy","containerRuntimeScheduling","containerSandboxTools","cronTriggers","crossShardFanout","durableStreams","globalTables","queues","relationGraph","secrets","services","topics","vectorStore","workerLoaders","workflowRollback","workflowSchedules"],m={agents:"durable agents (`defineAgent`)",commitOrderedTables:"commit-ordered tables (`.commitOrdered()`)",containerEgressPolicy:"container egress policies (`defineContainer({ allowedHosts | deniedHosts | interceptHttps })`)",containerRuntimeScheduling:'per-instance container images and snapshots (`defineContainer({ schedulingPolicy: "durable_object" })`)',containerSandboxTools:"container sandbox helpers — files, directory backups, bucket mounts (`defineContainer({ sandbox: true })`)",cronTriggers:"declared cron triggers (`cronJobs()`)",crossShardFanout:"cross-shard fan-out queries (a `.shardBy(...)` schema)",durableStreams:"durable streams (`.stream(handler, { durable: true })`)",globalTables:"global tables (`.global()`)",queues:"queues (`defineQueue`)",relationGraph:"relation-graph traversal (`ctx.db.related`, derived from `v.id(...)` columns)",secrets:"the secrets store (`ctx.secrets`)",services:"service bindings to sibling Workers (`lunora.config` `services`)",topics:"pub/sub topics (`defineTopic` / `defineSubscription`)",vectorStore:"vector indexes (`.vectorize()`)",workerLoaders:"sandboxed agent scripts (`jsCodeTool`, on Worker Loaders)",workflowRollback:"workflow step rollback (`defineStep({ rollback })`)",workflowSchedules:"scheduled workflow instances (`defineWorkflow({ schedules })`)"},y=(t,e,a)=>({level:"error",message:`${e.name} does not support ${m[t]}, which this app declares.`,name:"platform_unsupported_feature",remediation:`Remove the declaration, or deploy to a target whose capability matrix marks "${t}" as native or emulated.`,target:a}),T=(t,e,a)=>({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${m[t]}, which this app declares. Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${t}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than letting the app deploy onto a primitive the host may not provide.`,target:a}),k=t=>{const{diagnostics:e,gatedSignals:a,matrix:r,reported:n,signals:d,target:i}=t;for(const s of S){if(d[s]!==!0)continue;const o=r.features[s]?.level;o!=="unsupported"&&o!==void 0||(a[s]=!1,!n.has(s)&&e.push(o==="unsupported"?y(s,r,i):T(s,r,i)))}},_=(t,e,a,r={})=>{const n={...t},d={...r},i=[],s=new Set;for(const[o,l]of Object.entries(w)){if(l===null||!t[o])continue;const p=e.features[l]?.level;p==="unsupported"?(n[o]=!1,s.add(l),i.push({feature:o,level:"error",message:`${e.name} does not support "${o}" (ctx.${o}).`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${o} usage, or deploy to a target whose capability matrix marks "${l}" as native or emulated.`,target:a})):p===void 0&&(n[o]=!1,s.add(l),i.push({feature:o,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${o}" (ctx.${o}). Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${l}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than shipping a surface the host may not provide.`,target:a}))}return k({diagnostics:i,gatedSignals:d,matrix:e,reported:s,signals:r,target:a}),{diagnostics:i,signals:d,usage:n}},E=(t,e,a={})=>{const r=u[e];return r===void 0?{diagnostics:[{level:"error",message:`Unknown deploy target "${e}" — no capability matrix is registered for it. Codegen emitted the full Cloudflare surface un-gated.`,name:"platform_unknown_target",remediation:`Use a registered target (${Object.keys(u).join(", ")}) or install the target's @lunora/platform-${e} package.`,target:e}],signals:{...a},usage:{...t}}:_(t,r,e,a)},I=t=>{const e=u[t];if(e===void 0)return;const a=Object.entries(e.features).filter(([,r])=>r.level==="unsupported").map(([r])=>r).toSorted((r,n)=>r.localeCompare(n));return{id:e.id,name:e.name,unsupported:a}};export{w as CAPABILITY_TO_FEATURE,c as DEFAULT_TARGET,_ as gateAgainstMatrix,E as gatePlatformFeatures,C as platformMatrixIds,v as readProjectTarget,L as readTargetDiagnostics,A as resolveCodegenTarget,I as studioPlatformFor};
|