@lunora/codegen 1.0.0-alpha.242 → 1.0.0-alpha.244
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 +83 -11
- package/dist/index.d.ts +83 -11
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AGENTS_FILENAME-Bb2jxbOa.mjs → AGENTS_FILENAME-D8SgT3OR.mjs} +1 -1
- package/dist/packem_shared/{CONTAINERS_FILENAME-CGB4bqUr.mjs → CONTAINERS_FILENAME-CBCG6g9n.mjs} +1 -1
- package/dist/packem_shared/DEFAULT_TARGET-BLYeFMMT.mjs +1 -0
- package/dist/packem_shared/{FLAGS_FILENAME-BedPDCsR.mjs → FLAGS_FILENAME-W5XQz_Po.mjs} +1 -1
- package/dist/packem_shared/{MUTATORS_FILENAME-B6cKrN_m.mjs → MUTATORS_FILENAME-DqWOgC5Z.mjs} +1 -1
- package/dist/packem_shared/{NOTIFY_FILENAME-Cri3NT5U.mjs → NOTIFY_FILENAME-C1J_47et.mjs} +1 -1
- package/dist/packem_shared/OPENRPC_VERSION-Cr7Zzp6s.mjs +3 -0
- package/dist/packem_shared/QUEUES_FILENAME-RGwht3Xu.mjs +1 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-D1zEPvOK.mjs +11 -0
- package/dist/packem_shared/{SHAPES_FILENAME-zJgzynXR.mjs → SHAPES_FILENAME-DRUFomCj.mjs} +1 -1
- package/dist/packem_shared/{WORKFLOWS_FILENAME-DNaUHGS8.mjs → WORKFLOWS_FILENAME-4-ib4HH-.mjs} +1 -1
- package/dist/packem_shared/buildOpenApiDocument-SxfElVzK.mjs +3 -0
- package/dist/packem_shared/chain-mte5djRJ.mjs +1 -0
- package/dist/packem_shared/{classify-procedure-call-BztLe76A.mjs → classify-procedure-call-CmcShAze.mjs} +1 -1
- package/dist/packem_shared/{context-property-calls-CjDzLU8p.mjs → context-property-calls-CWf9-6G5.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-FxrdBeVt.mjs → discoverAuthApiCalls-DoSN_yc3.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-0lNudk0S.mjs → discoverCrons-BEALHx1S.mjs} +1 -1
- package/dist/packem_shared/{discoverFunctions-BsmX-sEq.mjs → discoverFunctions-BcBzcG5x.mjs} +1 -1
- package/dist/packem_shared/{discoverHttpRoutes-BcXI9CNt.mjs → discoverHttpRoutes-CJHS4llq.mjs} +1 -1
- package/dist/packem_shared/discoverHyperdriveCalls-Bkbh4tG7.mjs +1 -0
- package/dist/packem_shared/{discoverInserts-CFJ3IVeI.mjs → discoverInserts-DpuLYPPd.mjs} +1 -1
- package/dist/packem_shared/discoverMaskProcedures-B0w8gM0S.mjs +1 -0
- package/dist/packem_shared/{discoverMigrations-DbrHwcGE.mjs → discoverMigrations-Dt7ywfZv.mjs} +1 -1
- package/dist/packem_shared/{discoverNondeterministicCalls-CSQ_GDcA.mjs → discoverNondeterministicCalls-CNJV2BiP.mjs} +1 -1
- package/dist/packem_shared/discoverQueries-BcdqjYky.mjs +1 -0
- package/dist/packem_shared/discoverR2sqlCalls-30Wtbc0P.mjs +1 -0
- package/dist/packem_shared/{discoverRlsMetadata-CPmAGL0W.mjs → discoverRlsMetadata-mXBmPOGj.mjs} +1 -1
- package/dist/packem_shared/{discoverRlsProcedures-BO4qC77y.mjs → discoverRlsProcedures-F4Cy-kSi.mjs} +1 -1
- package/dist/packem_shared/{discoverSandboxUsage-CrjZ6yNg.mjs → discoverSandboxUsage-DkbwwFvO.mjs} +1 -1
- package/dist/packem_shared/discoverSchema-D5R60b4F.mjs +1 -0
- package/dist/packem_shared/{discoverStorageRulesMetadata-D8VYflWt.mjs → discoverStorageRulesMetadata-D3Ot9g5f.mjs} +1 -1
- package/dist/packem_shared/emitAgents-C3ygr0M8.mjs +1 -0
- package/dist/packem_shared/{emitApp--W9G6MZd.mjs → emitApp-Cu0w-3vl.mjs} +2 -2
- package/dist/packem_shared/{emitCrons-Bop1FTEz.mjs → emitCrons-BRKXFGFu.mjs} +1 -1
- package/dist/packem_shared/{emitServer-B8t7Hzb1.mjs → emitServer-pF_fhA82.mjs} +53 -49
- package/dist/packem_shared/emitShard-DID_s1FK.mjs +1 -0
- package/dist/packem_shared/{exported-procedure-chains-CmCDiPBV.mjs → exported-procedure-chains-D48EXUVQ.mjs} +1 -1
- package/dist/packem_shared/{fingerprintSchemaSources-L3nGKDQt.mjs → fingerprintSchemaSources-Cl1CJFeh.mjs} +1 -1
- package/dist/packem_shared/{index-BoaHhVtM.mjs → index-D7dKfGPh.mjs} +1 -1
- package/dist/packem_shared/ir-DBSvhNa-.mjs +1 -0
- package/dist/packem_shared/listLunoraSourceFiles-CSlcBYlo.mjs +1 -0
- package/dist/packem_shared/{loadProjectConfig-CKsFNgn3.mjs → loadProjectConfig-CktK_il-.mjs} +1 -1
- package/dist/packem_shared/modules-DyCocr1e.mjs +1 -0
- package/dist/packem_shared/{parse-validator-C94Yiabo.mjs → parse-validator-C6fHL7OS.mjs} +1 -1
- package/dist/packem_shared/{shard-CCNl561P.mjs → shard-BVzXMtWg.mjs} +67 -67
- package/dist/packem_shared/{shard-runtime-B7xvdFPc.mjs → shard-runtime-oIXHEMU7.mjs} +39 -30
- package/dist/packem_shared/{unwrap-handler-return-CoV_GK33.mjs → unwrap-handler-return-DVY_kFF7.mjs} +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/DEFAULT_TARGET-B1zgC6k6.mjs +0 -1
- package/dist/packem_shared/OPENRPC_VERSION-Cl6P9WGv.mjs +0 -3
- package/dist/packem_shared/QUEUES_FILENAME-CxkPcMH1.mjs +0 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BHDnOBKJ.mjs +0 -9
- package/dist/packem_shared/buildOpenApiDocument-nYvBhjxu.mjs +0 -3
- package/dist/packem_shared/chain-H2N_uKgj.mjs +0 -1
- package/dist/packem_shared/discoverHyperdriveCalls-D9qXqTq3.mjs +0 -1
- package/dist/packem_shared/discoverMaskProcedures-CV_Cc2_g.mjs +0 -1
- package/dist/packem_shared/discoverQueries-C7y8i_Ga.mjs +0 -1
- package/dist/packem_shared/discoverR2sqlCalls-fu7fC0i_.mjs +0 -1
- package/dist/packem_shared/discoverSchema-D8DBDHEg.mjs +0 -1
- package/dist/packem_shared/emitAgents-Ddcr_r3B.mjs +0 -1
- package/dist/packem_shared/emitShard-RnNua5aR.mjs +0 -1
- package/dist/packem_shared/ir-BgM8A3XV.mjs +0 -1
- package/dist/packem_shared/listLunoraSourceFiles-DP-5e-RE.mjs +0 -1
- package/dist/packem_shared/queries-B-f4jO-x.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as
|
|
1
|
+
import{s as h}from"./ir-DBSvhNa-.mjs";import{r as g}from"./json-data-Chfs2Cz5.mjs";import{a,G as d}from"./shared-DjUziztz.mjs";const w=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,7 +6,7 @@ import{r as p}from"./json-data-Chfs2Cz5.mjs";import{a,G as d}from"./shared-DjUzi
|
|
|
6
6
|
|
|
7
7
|
return serveRelationFanout(schema as unknown as SchemaLike, db, functionPath, args);
|
|
8
8
|
}
|
|
9
|
-
`}:{importFragment:"",override:""},
|
|
9
|
+
`}:{importFragment:"",override:""},R=e=>e?{build:`
|
|
10
10
|
const aiBinding = config.ai?.(env) ?? (env as Record<string, unknown>).AI;
|
|
11
11
|
// Correlate AI-Gateway-routed calls with the Lunora trace: thread the
|
|
12
12
|
// function path + trace id into createAi, which folds them into the
|
|
@@ -30,7 +30,7 @@ import{r as p}from"./json-data-Chfs2Cz5.mjs";import{a,G as d}from"./shared-DjUzi
|
|
|
30
30
|
const ${e} = {
|
|
31
31
|
${i}
|
|
32
32
|
}${r};
|
|
33
|
-
`},c={build:"",configField:"",contextField:"",importLines:[],stub:""},
|
|
33
|
+
`},c={build:"",configField:"",contextField:"",importLines:[],stub:""},N=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
34
|
/** The \`.shardBy()\` tables this shard registers with the shard registry when it writes them. */
|
|
35
35
|
const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(t=>JSON.stringify(t)).join(", ")}]);
|
|
36
36
|
`,override:`
|
|
@@ -39,7 +39,7 @@ const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(t=>JSON.string
|
|
|
39
39
|
|
|
40
40
|
return namespace === undefined ? undefined : { namespace, shardedTables: SHARDED_TABLES };
|
|
41
41
|
}
|
|
42
|
-
`},
|
|
42
|
+
`},S=e=>e?{build:`
|
|
43
43
|
const kvBinding = config.kv?.(env) ?? (env as Record<string, unknown>).KV;
|
|
44
44
|
// KV is not this shard's SQLite, so nothing appends a \`__cdc_log\` entry
|
|
45
45
|
// when a value changes — a subscription that read one can never be proven
|
|
@@ -53,31 +53,31 @@ const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(t=>JSON.string
|
|
|
53
53
|
]);
|
|
54
54
|
`,configField:`
|
|
55
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:l("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,
|
|
56
|
+
kv,`,importLines:['import type { Kv, KVNamespaceLike } from "@lunora/bindings/kv";','import { createKv } from "@lunora/bindings/kv";'],stub:l("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,L=(e,t)=>e?{build:`
|
|
57
57
|
const flags: import("${t}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
58
58
|
provider: () => config.flags?.(env),
|
|
59
59
|
targetingKey: () => flagsConfig.identify?.({ identity: identity ?? null, userId: userId ?? null }),
|
|
60
60
|
});
|
|
61
61
|
`,configField:`
|
|
62
62
|
flags?: (env: Record<string, unknown>) => import("${t}").Provider;`,contextField:`
|
|
63
|
-
flags,`,importLines:[`import { createFlags } from "${t}";`,'import flagsConfig from "../flags.js";'],stub:""}:c
|
|
63
|
+
flags,`,importLines:[`import { createFlags } from "${t}";`,'import flagsConfig from "../flags.js";'],stub:""}:c,$=e=>e?{build:`
|
|
64
64
|
const { notify, push } = createNotify(notifyConfig, env, { log, metrics });
|
|
65
65
|
`,configField:"",contextField:`
|
|
66
66
|
notify,
|
|
67
|
-
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:c,
|
|
67
|
+
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:c,A=e=>e?{build:`
|
|
68
68
|
const envConfig = lunoraEnvContract.${e.exportName}(env);
|
|
69
69
|
`,configField:"",contextField:`
|
|
70
|
-
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:c,
|
|
70
|
+
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:c,F=e=>e?{build:`
|
|
71
71
|
const access = accessFacade(identity, userId);
|
|
72
72
|
`,configField:"",contextField:`
|
|
73
|
-
access,`,importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}:c,
|
|
73
|
+
access,`,importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}:c,C=(e,t,n)=>{if(!t)return{constant:"",evaluateOverride:"",subscriptionOverride:""};const r=s=>`
|
|
74
74
|
const env = (this.env ?? {}) as Record<string, unknown>;
|
|
75
75
|
const flags: import("${n}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
76
76
|
provider: () => config.flags?.(env),
|
|
77
77
|
targetingKey: ${s},
|
|
78
78
|
});`,o=`
|
|
79
79
|
/** Statically-discovered feature flags (\`ctx.flags.<type>("key")\` reads) served via \`__lunora_admin__:listFlags\` + the reactive \`__lunora_flags__:\` channel. */
|
|
80
|
-
const LUNORA_FLAG_KEYS = ${
|
|
80
|
+
const LUNORA_FLAG_KEYS = ${g(e,'ReadonlyArray<{ key: string; type: "boolean" | "number" | "object" | "string" }>')};
|
|
81
81
|
`,i=`
|
|
82
82
|
protected override async evaluateFlags(context?: Record<string, unknown>): Promise<FlagsResult> {${r("undefined")}
|
|
83
83
|
const evalContext = context as import("${n}").EvaluationContext | undefined;
|
|
@@ -132,25 +132,25 @@ const LUNORA_FLAG_KEYS = ${p(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
132
132
|
|
|
133
133
|
return flags.boolean(key, typeof args.default === "boolean" ? args.default : false, context);
|
|
134
134
|
}
|
|
135
|
-
`;return{constant:o,evaluateOverride:i,subscriptionOverride:u}}
|
|
135
|
+
`;return{constant:o,evaluateOverride:i,subscriptionOverride:u}},_=e=>e?{build:`
|
|
136
136
|
const analyticsBinding = config.analytics?.(env) ?? (env as Record<string, unknown>).ANALYTICS;
|
|
137
137
|
const analytics: AnalyticsClient = analyticsBinding ? createAnalytics(analyticsBinding as AnalyticsEngineDatasetLike) : analyticsStub;
|
|
138
138
|
`,configField:`
|
|
139
139
|
analytics?: (env: Record<string, unknown>) => AnalyticsEngineDatasetLike;`,contextField:`
|
|
140
|
-
analytics,`,importLines:['import type { AnalyticsClient, AnalyticsEngineDatasetLike } from "@lunora/bindings/analytics";','import { createAnalytics } from "@lunora/bindings/analytics";'],stub:l("analyticsStub: AnalyticsClient",'throw new Error("ctx.analytics: no Analytics Engine binding found. Add an \\`analytics_engine_datasets\\` binding (env.ANALYTICS) to wrangler.jsonc, or pass \\`analytics\\` to createShardDO().");',["track","writeDataPoint"],{sync:["track","writeDataPoint"]})}:c,
|
|
140
|
+
analytics,`,importLines:['import type { AnalyticsClient, AnalyticsEngineDatasetLike } from "@lunora/bindings/analytics";','import { createAnalytics } from "@lunora/bindings/analytics";'],stub:l("analyticsStub: AnalyticsClient",'throw new Error("ctx.analytics: no Analytics Engine binding found. Add an \\`analytics_engine_datasets\\` binding (env.ANALYTICS) to wrangler.jsonc, or pass \\`analytics\\` to createShardDO().");',["track","writeDataPoint"],{sync:["track","writeDataPoint"]})}:c,E=e=>e?{build:`
|
|
141
141
|
const imagesBinding = config.images?.(env) ?? (env as Record<string, unknown>).IMAGES;
|
|
142
142
|
const images: Images = imagesBinding ? createImages({ binding: imagesBinding as ImagesBindingLike }) : imagesStub;
|
|
143
143
|
`,configField:`
|
|
144
144
|
images?: (env: Record<string, unknown>) => ImagesBindingLike;`,contextField:`
|
|
145
|
-
images,`,importLines:['import type { Images, ImagesBindingLike } from "@lunora/bindings/images";','import { createImages } from "@lunora/bindings/images";'],stub:l("imagesStub: Images",'throw new Error("ctx.images: no Images binding found. Add an \\`images\\` binding (env.IMAGES) to wrangler.jsonc, or pass \\`images\\` to createShardDO().");',["info","transform"])}:c,
|
|
145
|
+
images,`,importLines:['import type { Images, ImagesBindingLike } from "@lunora/bindings/images";','import { createImages } from "@lunora/bindings/images";'],stub:l("imagesStub: Images",'throw new Error("ctx.images: no Images binding found. Add an \\`images\\` binding (env.IMAGES) to wrangler.jsonc, or pass \\`images\\` to createShardDO().");',["info","transform"])}:c,O=e=>e?{build:`
|
|
146
146
|
const sql: SqlClient = config.sql ? config.sql(env) : sqlStub;
|
|
147
147
|
`,configField:`
|
|
148
148
|
sql?: (env: Record<string, unknown>) => SqlClient;`,contextField:`
|
|
149
|
-
sql,`,importLines:['import type { SqlClient } from "@lunora/hyperdrive";'],stub:l("sqlStub: SqlClient",'throw new Error("ctx.sql: provide a \\`sql\\` config thunk that builds a SqlClient from your driver, e.g. \\`sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString))\\`.");',["query"])}:c,
|
|
149
|
+
sql,`,importLines:['import type { SqlClient } from "@lunora/hyperdrive";'],stub:l("sqlStub: SqlClient",'throw new Error("ctx.sql: provide a \\`sql\\` config thunk that builds a SqlClient from your driver, e.g. \\`sql: (env) => fromPostgresJs(postgres(env.HYPERDRIVE.connectionString))\\`.");',["query"])}:c,P=e=>e?{build:`
|
|
150
150
|
const browser: Browser = config.browser ? config.browser(env) : browserStub;
|
|
151
151
|
`,configField:`
|
|
152
152
|
browser?: (env: Record<string, unknown>) => Browser;`,contextField:`
|
|
153
|
-
browser,`,importLines:['import type { Browser } from "@lunora/browser";'],stub:l("browserStub: Browser","throw new Error(\"ctx.browser: provide a \\`browser\\` config thunk, e.g. \\`browser: (env) => createBrowser({ binding: env.BROWSER, launch })\\` with \\`import { launch } from '@cloudflare/playwright'\\`. Session reuse (connect/sessions) additionally needs those two exports passed the same way.\");",["cancelCrawl","connect","content","crawl","crawlResult","launch","pdf","quickAction","scrape","screenshot","sessions"])}:c,
|
|
153
|
+
browser,`,importLines:['import type { Browser } from "@lunora/browser";'],stub:l("browserStub: Browser","throw new Error(\"ctx.browser: provide a \\`browser\\` config thunk, e.g. \\`browser: (env) => createBrowser({ binding: env.BROWSER, launch })\\` with \\`import { launch } from '@cloudflare/playwright'\\`. Session reuse (connect/sessions) additionally needs those two exports passed the same way.\");",["cancelCrawl","connect","content","crawl","crawlResult","launch","pdf","quickAction","scrape","screenshot","sessions"])}:c,q=e=>e?{build:`
|
|
154
154
|
const r2sqlEnv = env as Record<string, unknown>;
|
|
155
155
|
const r2sqlAccountId = (r2sqlEnv.R2_SQL_ACCOUNT_ID ?? r2sqlEnv.CLOUDFLARE_ACCOUNT_ID) as string | undefined;
|
|
156
156
|
const r2sqlToken = r2sqlEnv.R2_SQL_TOKEN as string | undefined;
|
|
@@ -161,11 +161,11 @@ const LUNORA_FLAG_KEYS = ${p(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
161
161
|
? createR2Sql({ accountId: r2sqlAccountId, apiToken: r2sqlToken, bucket: r2sqlBucket })
|
|
162
162
|
: r2sqlStub;
|
|
163
163
|
`,configField:`
|
|
164
|
-
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,contextField:"",importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:l("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"]})}:c,
|
|
164
|
+
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,contextField:"",importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:l("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"]})}:c,I=e=>e?{build:`
|
|
165
165
|
const pipelinesBinding = config.pipelines?.(env) ?? (env as Record<string, unknown>).PIPELINES;
|
|
166
166
|
const pipelines: PipelineClient = pipelinesBinding ? createPipelines({ binding: pipelinesBinding as PipelineBindingLike }) : pipelinesStub;
|
|
167
167
|
`,configField:`
|
|
168
|
-
pipelines?: (env: Record<string, unknown>) => PipelineBindingLike;`,contextField:"",importLines:['import type { PipelineBindingLike, PipelineClient } from "@lunora/bindings/pipelines";','import { createPipelines } from "@lunora/bindings/pipelines";'],stub:l("pipelinesStub: PipelineClient",'throw new Error("ctx.pipelines: no Pipelines binding found. Add a \\`pipelines\\` binding (env.PIPELINES) to wrangler.jsonc, or pass \\`pipelines\\` to createShardDO().");',["send"])}:c,
|
|
168
|
+
pipelines?: (env: Record<string, unknown>) => PipelineBindingLike;`,contextField:"",importLines:['import type { PipelineBindingLike, PipelineClient } from "@lunora/bindings/pipelines";','import { createPipelines } from "@lunora/bindings/pipelines";'],stub:l("pipelinesStub: PipelineClient",'throw new Error("ctx.pipelines: no Pipelines binding found. Add a \\`pipelines\\` binding (env.PIPELINES) to wrangler.jsonc, or pass \\`pipelines\\` to createShardDO().");',["send"])}:c,B=(e,t)=>{if(e.length===0)return"";const n=t?`, ${JSON.stringify(t)}`:"",r=e.map(i=>(a(i.exportName,`container export "${i.exportName}"`),a(i.className,`container class "${i.className}"`),`/** Container DO for the \`${i.exportName}\` definition (binding \`${i.bindingName}\`). */
|
|
169
169
|
export class ${i.className} extends LunoraContainer {
|
|
170
170
|
public constructor(ctx: ConstructorParameters<typeof LunoraContainer>[0], env: Record<string, unknown>) {
|
|
171
171
|
super(ctx, env, ${i.exportName}, "${i.exportName}"${n});
|
|
@@ -190,7 +190,7 @@ import { ${o} } from "../containers.js";
|
|
|
190
190
|
|
|
191
191
|
export { ContainerProxy } from "@lunora/container/do";
|
|
192
192
|
|
|
193
|
-
${r}`},
|
|
193
|
+
${r}`},W=(e,t)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const r of e)a(r.exportName,`container export "${r.exportName}"`),a(r.bindingName,`container binding "${r.bindingName}"`);const n=e.map(r=>{const o=r.schedulingPolicy!==void 0||r.maxInstances===void 0?"":`, maxInstances: ${String(r.maxInstances)}`;return` { binding: "${r.bindingName}", exportName: "${r.exportName}"${o} },`}).join(`
|
|
194
194
|
`);return{build:`
|
|
195
195
|
const containers = createContainerContext(env, LUNORA_CONTAINERS, ${t?JSON.stringify(t):"undefined"}, this.getCurrentTraceparent(), this.getCurrentSampleErrors());
|
|
196
196
|
`,contextField:`
|
|
@@ -199,7 +199,7 @@ ${r}`},I=(e,t)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],
|
|
|
199
199
|
const LUNORA_CONTAINERS: ReadonlyArray<ContainerBindingSpec> = [
|
|
200
200
|
${n}
|
|
201
201
|
];
|
|
202
|
-
`}},
|
|
202
|
+
`}},D=e=>{if(e.length===0)return"";const t=e.map(r=>(a(r.exportName,`workflow export "${r.exportName}"`),a(r.className,`workflow class "${r.className}"`),`/** WorkflowEntrypoint for the \`${r.exportName}\` definition, reached as \`ctx.exports.${r.className}\`. */
|
|
203
203
|
export class ${r.className} extends LunoraWorkflow<WorkflowParamsOf<typeof ${r.exportName}>, WorkflowOutputOf<typeof ${r.exportName}>> {
|
|
204
204
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
205
205
|
super(ctx, env, ${r.exportName}, "${r.exportName}");
|
|
@@ -227,20 +227,20 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
|
|
|
227
227
|
/** Output type carried by a \`defineWorkflow\` definition (its phantom \`__output\`), so each entrypoint keeps the authored return type. */
|
|
228
228
|
type WorkflowOutputOf<Definition> = Definition extends { __output?: infer Output } ? Output : unknown;
|
|
229
229
|
|
|
230
|
-
${t}`},
|
|
230
|
+
${t}`},T=e=>{if(e.length===0)return"";const n=e.filter(s=>s.voice).length>0,r=e.map(s=>{a(s.exportName,`agent export "${s.exportName}"`),a(s.className,`agent class "${s.className}"`);const p=`/** WorkflowEntrypoint for the \`${s.exportName}\` agent, reached as \`ctx.exports.${s.className}\`. */
|
|
231
231
|
export class ${s.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult> {
|
|
232
232
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
233
233
|
super(ctx, env, compileAgentWorkflow(${s.exportName}, "${s.exportName}"), "${s.exportName}");
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
`;if(!s.voice)return
|
|
236
|
+
`;if(!s.voice)return p;const m=s.voiceClassName??"",y=s.voiceBindingName??"";a(m,`agent voice class "${m}"`);const b=`
|
|
237
237
|
/** Voice-session Durable Object for the \`${s.exportName}\` agent (binding \`${y}\`). */
|
|
238
238
|
export class ${m} extends VoiceSessionDO {
|
|
239
239
|
public constructor(ctx: ConstructorParameters<typeof VoiceSessionDO>[0], env: Record<string, unknown>) {
|
|
240
240
|
super(ctx, env, ${s.exportName}, "${s.exportName}");
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
`;return`${
|
|
243
|
+
`;return`${p}${b}`}).join(`
|
|
244
244
|
`),o=e.map(s=>s.exportName).join(", ");return`${d}/**
|
|
245
245
|
* WorkflowEntrypoint classes for the agents declared in \`lunora/agents.ts\`.
|
|
246
246
|
* Each \`defineAgent\` compiles a replay-safe tool-loop onto a Cloudflare
|
|
@@ -255,7 +255,7 @@ import type { AgentRunInput, AgentRunResult } from "@lunora/agent";
|
|
|
255
255
|
|
|
256
256
|
import { ${o} } from "../agents.js";
|
|
257
257
|
|
|
258
|
-
${r}`},
|
|
258
|
+
${r}`},j=e=>{const t=e.filter(o=>o.mode==="push");if(t.length===0)return"";for(const o of t)a(o.exportName,`queue export "${o.exportName}"`);const n=t.map(o=>o.exportName).join(", "),r=t.map(o=>` ${JSON.stringify(o.name)}: { binding: ${JSON.stringify(o.bindingName)}, definition: ${o.exportName}, exportName: ${JSON.stringify(o.exportName)} },`).join(`
|
|
259
259
|
`);return`${d}/**
|
|
260
260
|
* Push-consumer registry for the queues declared in \`lunora/queues.ts\`. The
|
|
261
261
|
* composed worker's \`queue(batch, env, ctx)\` entry routes each delivered batch
|
|
@@ -270,7 +270,7 @@ import { ${n} } from "../queues.js";
|
|
|
270
270
|
export const LUNORA_QUEUE_REGISTRY: QueueRegistry = {
|
|
271
271
|
${r}
|
|
272
272
|
};
|
|
273
|
-
`},
|
|
273
|
+
`},U=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)a(n.exportName,`workflow export "${n.exportName}"`),a(n.className,`workflow class "${n.className}"`);const t=e.map(n=>` { className: "${n.className}", exportName: "${n.exportName}" },`).join(`
|
|
274
274
|
`);return{build:`
|
|
275
275
|
const workflows = createWorkflowContext(env, LUNORA_WORKFLOWS, this.state.exports);
|
|
276
276
|
`,contextField:`
|
|
@@ -279,7 +279,7 @@ ${r}
|
|
|
279
279
|
const LUNORA_WORKFLOWS: ReadonlyArray<WorkflowBindingSpec> = [
|
|
280
280
|
${t}
|
|
281
281
|
];
|
|
282
|
-
`}},
|
|
282
|
+
`}},M=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)a(n.exportName,`queue export "${n.exportName}"`),a(n.bindingName,`queue binding "${n.bindingName}"`);const t=e.map(n=>` { binding: "${n.bindingName}", exportName: "${n.exportName}", name: ${JSON.stringify(n.name)} },`).join(`
|
|
283
283
|
`);return{build:`
|
|
284
284
|
const queues = createQueueContext(env, LUNORA_QUEUES);
|
|
285
285
|
`,contextField:`
|
|
@@ -288,7 +288,16 @@ ${t}
|
|
|
288
288
|
const LUNORA_QUEUES: ReadonlyArray<QueueBindingSpec> = [
|
|
289
289
|
${t}
|
|
290
290
|
];
|
|
291
|
-
`}},
|
|
291
|
+
`}},Q=(e,t)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};const n=e.map(r=>{a(r.exportName,`topic export "${r.exportName}"`);const o=h(t,r.exportName).map(i=>`{ binding: "${i.bindingName}", exportName: "${i.exportName}" }`).join(", ");return` { exportName: "${r.exportName}", subscriptions: [${o}] },`}).join(`
|
|
292
|
+
`);return{build:`
|
|
293
|
+
const topics = createTopicContext(env, LUNORA_TOPICS);
|
|
294
|
+
`,contextField:`
|
|
295
|
+
topics,`,importLines:['import type { TopicBindingSpec } from "@lunora/queue";','import { createTopicContext } from "@lunora/queue";'],specs:`
|
|
296
|
+
/** Wiring specs for \`ctx.topics\` (codegen-derived from \`lunora/queues.ts\`): each topic's subscription queues. */
|
|
297
|
+
const LUNORA_TOPICS: ReadonlyArray<TopicBindingSpec> = [
|
|
298
|
+
${n}
|
|
299
|
+
];
|
|
300
|
+
`}},K=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)a(n.exportName,`agent export "${n.exportName}"`),a(n.className,`agent class "${n.className}"`);const t=e.map(n=>` { className: "${n.className}", exportName: "${n.exportName}"${n.publicRun===!0?", publicRun: true":""} },`).join(`
|
|
292
301
|
`);return{build:`
|
|
293
302
|
const agents = createAgentContext(env, LUNORA_AGENTS, { exports: this.state.exports });
|
|
294
303
|
`,contextField:`
|
|
@@ -299,20 +308,20 @@ ${t}
|
|
|
299
308
|
];
|
|
300
309
|
`}},f=(e,t,n,r,o)=>({constant:`
|
|
301
310
|
${o}
|
|
302
|
-
const ${e} = ${
|
|
311
|
+
const ${e} = ${g(r,t)};
|
|
303
312
|
`,override:`
|
|
304
313
|
protected override ${n}(): ${t} {
|
|
305
314
|
return ${e};
|
|
306
315
|
}
|
|
307
|
-
`}),
|
|
316
|
+
`}),V=e=>{if(e.length===0)return{constant:"",override:""};const t={workflows:e.map(n=>({className:n.className,exportName:n.exportName,name:n.name}))};return f("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. */")},H=e=>{if(e.length===0)return{constant:"",override:""};const t={queues:e.map(n=>({binding:n.bindingName,...n.tuning.deadLetterQueue===void 0?{}:{deadLetterQueue:n.tuning.deadLetterQueue},exportName:n.exportName,mode:n.mode,name:n.name,...n.topic===void 0?{}:{topic:n.topic}}))};return f("LUNORA_QUEUES_INFO","QueuesResult","queuesMetadata",t,"/** Read-only declared-queue metadata (discovered from `lunora/queues.ts`) served via `__lunora_admin__:listQueues` for the studio's queues view. */")},G=e=>e?{imports:['import type { LunoraDatabaseLike as LunoraPaymentDbLike, LunoraPayment, PaymentsFromContextOptions } from "@lunora/payment";','import { paymentsFromContext } from "@lunora/payment";'],build:`
|
|
308
317
|
const payments: LunoraPayment = config.payment
|
|
309
318
|
? paymentsFromContext({ auth: { userId: userId ?? null }, db: db as unknown as LunoraPaymentDbLike }, config.payment(env))
|
|
310
319
|
: paymentStub;
|
|
311
320
|
`,configField:`
|
|
312
321
|
payment?: (env: Record<string, unknown>) => PaymentsFromContextOptions;`,contextField:`
|
|
313
|
-
payments,`,stub:l("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:""},
|
|
322
|
+
payments,`,stub:l("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:""},Y=e=>e?{imports:['import type { X402Pay, X402PayConfig } from "@lunora/x402/pay";','import { lazyX402Pay } from "@lunora/x402/pay";'],build:`
|
|
314
323
|
const x402: X402Pay = config.x402
|
|
315
324
|
? lazyX402Pay(config.x402(env), { getSecret: (name: string) => secrets.get(name) })
|
|
316
325
|
: x402Stub;
|
|
317
326
|
`,configField:`
|
|
318
|
-
x402?: (env: Record<string, unknown>) => X402PayConfig;`,stub:l("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:""},
|
|
327
|
+
x402?: (env: Record<string, unknown>) => X402PayConfig;`,stub:l("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:""},J=(e,t,n,r,o)=>["AdvisorProcedure","AdvisoryFinding","DatabaseWriterLike","DataMigrationLike","DispatchBookmark","ExportRow",...r?["FlagsResult"]:[],"ImportShardResult","KeyRange","MaskPoliciesResult","MigrationRunResult","QueryReadScope",...n?["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"]:[],...t?["WorkflowsResult"]:[],...e?["WriteHook"]:[]];export{T as A,B,D as C,j as D,S as a,L as b,C as c,A as d,R as e,_ as f,E as g,O as h,P as i,q as j,I as k,M as l,Q as m,W as n,U as o,K as p,G as q,l as r,Y as s,V as t,H as u,N as v,J as w,w as x,F as y,$ as z};
|
package/dist/packem_shared/{unwrap-handler-return-CoV_GK33.mjs → unwrap-handler-return-DVY_kFF7.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as l,SyntaxKind as g}from"ts-morph";import{lunoraRelativePath as L}from"./listLunoraSourceFiles-DP-5e-RE.mjs";import{posix as D}from"node:path";let S,v;const Ae=e=>{const t=S,n=[];S=n;try{return{erased:n,value:e()}}finally{S=t}},Te=e=>{S?.push(...e)},j=e=>{for(const t of e.getAncestors())if(l.isVariableDeclaration(t))return t.getName()},w=(e,t)=>{S?.push({exportName:j(e),filePath:e.getSourceFile().getFilePath(),line:e.getStartLineNumber(),rendered:t})},Ne=e=>{v!==void 0&&w(v,e)},xe=(e,t)=>{const n=v;v=e;try{return t()}finally{v=n}},k=(e,t)=>{const n=e.exportName??`line ${e.line.toString()}`;return{cacheKey:`procedure_return_type_erased:${t}:${n}`,categories:["SCHEMA"],description:"Codegen renders a procedure's return type into `_generated/`, where only names that resolve from that directory may appear. A type it can neither name nor reproduce structurally — a class instance, a call or index signature, a recursive or very deeply nested shape — is emitted as `unknown` instead, so callers lose the shape while the runtime still returns it.",detail:`\`${n}\` in \`${t}\` (line ${e.line.toString()}) returns \`${e.rendered}\`, which codegen could not reproduce — its generated type is \`unknown\`.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:e.exportName,filePath:t,line:e.line,rendered:e.rendered},name:"procedure_return_type_erased",remediation:"Declare the shape explicitly with `.output(...)`, or export the type from the module that declares it so codegen can name it. A class instance cannot cross the wire at all — return a plain object.",title:"Procedure return type is missing from the generated type"}},De=(e,t)=>{const n=new Map;for(const r of e){const s=k(r,L(t,r.filePath));n.set(s.cacheKey,s)}return[...n.values()].toSorted((r,s)=>r.cacheKey.localeCompare(s.cacheKey))},P=/\bany\b(?!\s*(?:\?\s*)?:)/u,U=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/gu,O=e=>P.test(e.replaceAll(U,"")),K="/_generated/",B=e=>{const t=[e.getSymbol(),e.getAliasSymbol()].flatMap(n=>n?.getDeclarations()??[]);return t.length>0&&t.every(n=>n.getSourceFile().getSymbol()===void 0)},F=/^(?<quote>["'])(?<specifier>.*)\k<quote>$/su,T=e=>{for(const t of e.getAncestors())if(l.isModuleDeclaration(t)){const n=F.exec(t.getName());if(n?.groups?.specifier!==void 0)return n.groups.specifier}},h=new WeakMap,V=(e,t)=>{const n=e.getSymbol();if(n===void 0)return;let r=h.get(n.compilerSymbol);return r===void 0&&(r=new Map,h.set(n.compilerSymbol,r)),r.has(t)||r.set(t,n.getExport(t)??e.getExportSymbols().find(s=>s.getName()===t)),r.get(t)},_=(e,t)=>e.getNamespaceImport()!==void 0||e.getNamedImports().some(n=>n.getName()===t),W=(e,t,n)=>e.getModuleSpecifierValue()===t&&_(e,n)?n:void 0,q=(e,t)=>{const n=e.getDefaultImport();if(n===void 0)return;const r=n.getSymbol();return(r?.getAliasedSymbol()??r)?.getDeclarations().includes(t)===!0?"default":void 0},G=(e,t,n)=>{if(!_(e,n))return;const r=e.getModuleSpecifierSourceFile(),s=r===void 0?void 0:V(r,n);return(s?.getAliasedSymbol()??s)?.getDeclarations().includes(t)===!0?n:void 0},X=/^\.\.?(?:$|\/)/u,H=new Map([[".cjs",".cjs"],[".cts",".cjs"],[".d.ts",".js"],[".js",".js"],[".jsx",".jsx"],[".mjs",".mjs"],[".mts",".mjs"],[".ts",".js"],[".tsx",".js"]]),Y=(e,t)=>{const n=t.getModuleSpecifierValue();if(!X.test(n))return;const r=t.getModuleSpecifierSourceFile(),s=r===void 0?void 0:H.get(r.getExtension());if(r===void 0||s===void 0)return;const i=`${D.join(r.getDirectoryPath(),r.getBaseNameWithoutExtension())}${s}`,o=D.relative(e.getDirectoryPath(),i);return o.startsWith(".")?o:`./${o}`},J=(e,t,n)=>{const r=T(t);for(const s of e.getImportDeclarations()){const i=r===void 0?q(s,t)??G(s,t,n):W(s,r,n);if(i!==void 0)return{exportName:i,specifier:Y(e,s)??s.getModuleSpecifierValue()}}},z=(e,t)=>Object.keys(t.getProject().getCompilerOptions().paths??{}).some(n=>{const r=n.indexOf("*");return r===-1?e===n:e.startsWith(n.slice(0,r))&&e.endsWith(n.slice(r+1))}),m={kind:"verbatim"},p={kind:"expand"},Q=new Set([g.ClassDeclaration,g.EnumDeclaration,g.EnumMember,g.InterfaceDeclaration,g.TypeAliasDeclaration]),Z=e=>T(e)!==void 0||l.isExportable(e)&&e.isExported(),ee=(e,t)=>new RegExp(String.raw`(?<![$\w])${t.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`)}(?![$\w])`,"u").test(e),M=(e,t,n,r)=>{const s=e.getSourceFile();if(s.getSymbol()===void 0&&T(e)===void 0||!Q.has(e.getKind()))return m;const i=s.getFilePath();if(i.includes(K))return m;if(i===n)return p;const o=l.isEnumMember(e)?e.getParent():e;if(!l.hasName(o))return p;const a=J(t.getSourceFile(),o,o.getName());return a===void 0?Z(o)||!ee(r(),o.getName())?m:p:z(a.specifier,t)?p:{kind:"qualify",qualified:a}},te=new Set([g.ClassDeclaration,g.EnumDeclaration,g.FunctionDeclaration,g.ModuleDeclaration]),I=e=>{const t=e?.getDeclarations()??[];return t.length>0&&t.every(n=>n.getSourceFile().getSymbol()===void 0)},ne=e=>{for(const t of e.getDeclarations()){const n=t.getFirstChildByKind(g.ComputedPropertyName);if(n!==void 0){let r=n.getExpression();for(;l.isPropertyAccessExpression(r);)r=r.getExpression();return r}}},re=(e,t)=>{if(e.getProperties().some(s=>{if(!s.getName().startsWith("__@"))return!1;const i=ne(s);return i===void 0||!I(i.getSymbol())}))return!0;const r=e.getSymbol();return r!==void 0&&r.getDeclarations().some(s=>te.has(s.getKind()))&&!I(r)&&t().startsWith("typeof ")},R=(e,t,n)=>{const r=e.getAliasSymbol(),s=e.getSymbol(),i=new Set((r??s)?.getDeclarations());let o=!1,a;const c=()=>(a??=e.getText(t),a);for(const u of[s,r].flatMap(d=>d?.getDeclarations()??[])){const d=M(u,t,n,c);if(d.kind==="qualify"&&i.has(u))return d;o||=d.kind!=="verbatim"}return o||re(e,c)?p:m},se=(e,t,n)=>{const r=l.isPropertySignature(e)||l.isPropertyDeclaration(e)?e.getTypeNode():void 0;if(r===void 0)return m;let s=!1;for(const i of[r,...r.getDescendantsOfKind(g.TypeReference)].filter(o=>l.isTypeReference(o))){const o=i.getTypeName().getSymbol();for(const a of(o?.getAliasedSymbol()??o)?.getDeclarations()??[]){const c=M(a,t,n,()=>i.getText());if(c.kind==="qualify")return c;s||=c.kind!=="verbatim"}}return s?p:m},oe=/^[A-Za-z_$][\w$]*$/u,ie=e=>oe.test(e)?e:JSON.stringify(e),$=e=>{const t=[...e.getTypeArguments()];return e.isUnion()&&t.push(...e.getUnionTypes()),e.isIntersection()&&t.push(...e.getIntersectionTypes()),t},y=e=>!e.isObject()||e.isArray()||e.isTuple()||e.getCallSignatures().length>0||e.getConstructSignatures().length>0?!1:e.getStringIndexType()===void 0&&e.getNumberIndexType()===void 0&&!e.getProperties().some(t=>t.getName().startsWith("__@")),E=(e,t,n,r=new Set)=>r.has(e)?!1:(r.add(e),R(e,t,n).kind!=="verbatim"||$(e).some(s=>E(s,t,n,r))?!0:y(e)?e.getProperties().some(s=>s.getDeclarations().some(i=>se(i,t,n).kind!=="verbatim")?!0:E(s.getTypeAtLocation(t),t,n,r)):!1),ae=(e,t)=>{const n=e.getValueDeclaration()??e.getDeclarations()[0];return n&&(l.isPropertySignature(n)||l.isPropertyDeclaration(n))&&n.hasQuestionToken()?!0:t.isUnion()&&t.getUnionTypes().some(r=>r.isUndefined())},C=(e,t)=>e!==void 0&&(y(e)||e.isString()||e.isNumber()||e.isBigInt()||e.isBoolean()||e.isLiteral()||e.isBooleanLiteral()||e.isEnumLiteral()||e.isTemplateLiteral()||e.isNull()||e.isUndefined()||e.isAny()||e.isUnknown()||e.isNever()||e.isVoid())?t:`(${t})`,ce=32,ue=8,le=(e,t,n,r,s,i)=>{const o=e.getArrayElementType(),a=o?i(o,t,n,r,s):void 0;if(a!==void 0)return`${C(o,a)}[]`},ge=(e,t,n,r,s,i)=>{const o=[];for(const a of e.getUnionTypes()){const c=i(a,t,n,r,s);if(c===void 0)return;o.push(c)}return o.join(" | ")},de=(e,t,n,r,s,i)=>{const o=[];for(const a of e.getIntersectionTypes()){const c=i(a,t,n,r,s);if(c===void 0)return;o.push(C(a,c))}return o.join(" & ")},me=(e,t,n,r,s,i)=>{if(!y(e))return;const o=[];for(const a of e.getProperties()){const c=a.getTypeAtLocation(t),u=ae(a,c),d=u&&c.isUnion()?c.getUnionTypes().filter(A=>!A.isUndefined()):[c],N=[];for(const A of d){const x=i(A,t,n,r+1,s);if(x===void 0)return;N.push(x)}o.push(`${ie(a.getName())}${u?"?":""}: ${N.join(" | ")}`)}return o.length>0?`{ ${o.join("; ")} }`:"{}"},fe=e=>{const t=e.getLiteralValue();return typeof t=="string"?JSON.stringify(t):typeof t=="number"?String(t):void 0},pe=e=>[e.getSymbol(),e.getAliasSymbol()].flatMap(t=>t?.getDeclarations()??[]).some(t=>l.isClassDeclaration(t)||l.isClassExpression(t)),b=(e,t,n,r,s=new Set)=>{if(r.has(e)||s.has(e))return!1;if(n>ce)return!0;const i=new Set(r).add(e);if($(e).some(u=>b(u,t,n+1,i,s)))return!0;const o=e.getArrayElementType();if(o!==void 0)return b(o,t,n+1,i,s);if(B(e))return s.add(e),!1;if(e.getCallSignatures().length>0||e.getConstructSignatures().length>0||[e.getSymbol(),e.getAliasSymbol()].flatMap(u=>u?.getDeclarations()??[]).some(u=>l.isClassDeclaration(u)||l.isClassExpression(u)))return!0;const c=y(e)&&e.getProperties().some(u=>b(u.getTypeAtLocation(t),t,n+1,i,s));return c||s.add(e),c},Se=(e,t,n,r,s,i,o)=>{const a=[];for(const c of t.getAliasSymbol()===void 0?t.getTypeArguments():t.getAliasTypeArguments()){const u=o(c,n,r,s+1,i);if(u===void 0)return;a.push(u)}return`import("${e.specifier}").${e.exportName}${a.length>0?`<${a.join(", ")}>`:""}`},ve=e=>[e.getSymbol(),e.getAliasSymbol()].flatMap(t=>t?.getDeclarations()??[]).some(t=>l.isEnumDeclaration(t)||l.isEnumMember(t)),f=(e,t,n,r,s)=>{if(r>ue||s.has(e))return;const i=R(e,t,n);if(i.kind==="verbatim"&&!E(e,t,n))return e.getText(t);const o=new Set(s).add(e);if(!pe(e)){if(e.isEnumLiteral())return fe(e);if(i.kind==="qualify"&&!ve(e)){const a=Se(i.qualified,e,t,n,r,o,f);if(a!==void 0)return a}return e.isArray()?le(e,t,n,r,o,f):e.isUnion()?ge(e,t,n,r,o,f):e.isIntersection()?de(e,t,n,r,o,f):me(e,t,n,r,o,f)}},he=e=>{const t=e.getType().getCallSignatures()[0];if(!t)return"unknown";let n=t.getReturnType();const s=(n.getSymbol()??n.getAliasSymbol())?.getName();if(s==="Promise"||s==="AsyncIterable"||s==="AsyncIterableIterator"||s==="AsyncGenerator"){const a=n.getTypeArguments()[0];a&&(n=a)}const i=n.getText(e);if(!i||i==="any"||i==="never"||O(i)||b(n,e,0,new Set))return"unknown";const o=e.getSourceFile().getFilePath();if(E(n,e,o)){const a=f(n,e,o,0,new Set);return a===void 0&&w(e,i),a??"unknown"}return i};export{E as a,Ne as b,Ae as c,De as d,f as e,O as i,xe as p,Te as r,he as u};
|
|
1
|
+
import{Node as l,SyntaxKind as g}from"ts-morph";import{lunoraRelativePath as L}from"./listLunoraSourceFiles-CSlcBYlo.mjs";import{posix as D}from"node:path";let S,v;const Ae=e=>{const t=S,n=[];S=n;try{return{erased:n,value:e()}}finally{S=t}},Te=e=>{S?.push(...e)},j=e=>{for(const t of e.getAncestors())if(l.isVariableDeclaration(t))return t.getName()},w=(e,t)=>{S?.push({exportName:j(e),filePath:e.getSourceFile().getFilePath(),line:e.getStartLineNumber(),rendered:t})},Ne=e=>{v!==void 0&&w(v,e)},xe=(e,t)=>{const n=v;v=e;try{return t()}finally{v=n}},k=(e,t)=>{const n=e.exportName??`line ${e.line.toString()}`;return{cacheKey:`procedure_return_type_erased:${t}:${n}`,categories:["SCHEMA"],description:"Codegen renders a procedure's return type into `_generated/`, where only names that resolve from that directory may appear. A type it can neither name nor reproduce structurally — a class instance, a call or index signature, a recursive or very deeply nested shape — is emitted as `unknown` instead, so callers lose the shape while the runtime still returns it.",detail:`\`${n}\` in \`${t}\` (line ${e.line.toString()}) returns \`${e.rendered}\`, which codegen could not reproduce — its generated type is \`unknown\`.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:e.exportName,filePath:t,line:e.line,rendered:e.rendered},name:"procedure_return_type_erased",remediation:"Declare the shape explicitly with `.output(...)`, or export the type from the module that declares it so codegen can name it. A class instance cannot cross the wire at all — return a plain object.",title:"Procedure return type is missing from the generated type"}},De=(e,t)=>{const n=new Map;for(const r of e){const s=k(r,L(t,r.filePath));n.set(s.cacheKey,s)}return[...n.values()].toSorted((r,s)=>r.cacheKey.localeCompare(s.cacheKey))},P=/\bany\b(?!\s*(?:\?\s*)?:)/u,U=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/gu,O=e=>P.test(e.replaceAll(U,"")),K="/_generated/",B=e=>{const t=[e.getSymbol(),e.getAliasSymbol()].flatMap(n=>n?.getDeclarations()??[]);return t.length>0&&t.every(n=>n.getSourceFile().getSymbol()===void 0)},F=/^(?<quote>["'])(?<specifier>.*)\k<quote>$/su,T=e=>{for(const t of e.getAncestors())if(l.isModuleDeclaration(t)){const n=F.exec(t.getName());if(n?.groups?.specifier!==void 0)return n.groups.specifier}},h=new WeakMap,V=(e,t)=>{const n=e.getSymbol();if(n===void 0)return;let r=h.get(n.compilerSymbol);return r===void 0&&(r=new Map,h.set(n.compilerSymbol,r)),r.has(t)||r.set(t,n.getExport(t)??e.getExportSymbols().find(s=>s.getName()===t)),r.get(t)},_=(e,t)=>e.getNamespaceImport()!==void 0||e.getNamedImports().some(n=>n.getName()===t),W=(e,t,n)=>e.getModuleSpecifierValue()===t&&_(e,n)?n:void 0,q=(e,t)=>{const n=e.getDefaultImport();if(n===void 0)return;const r=n.getSymbol();return(r?.getAliasedSymbol()??r)?.getDeclarations().includes(t)===!0?"default":void 0},G=(e,t,n)=>{if(!_(e,n))return;const r=e.getModuleSpecifierSourceFile(),s=r===void 0?void 0:V(r,n);return(s?.getAliasedSymbol()??s)?.getDeclarations().includes(t)===!0?n:void 0},X=/^\.\.?(?:$|\/)/u,H=new Map([[".cjs",".cjs"],[".cts",".cjs"],[".d.ts",".js"],[".js",".js"],[".jsx",".jsx"],[".mjs",".mjs"],[".mts",".mjs"],[".ts",".js"],[".tsx",".js"]]),Y=(e,t)=>{const n=t.getModuleSpecifierValue();if(!X.test(n))return;const r=t.getModuleSpecifierSourceFile(),s=r===void 0?void 0:H.get(r.getExtension());if(r===void 0||s===void 0)return;const i=`${D.join(r.getDirectoryPath(),r.getBaseNameWithoutExtension())}${s}`,o=D.relative(e.getDirectoryPath(),i);return o.startsWith(".")?o:`./${o}`},J=(e,t,n)=>{const r=T(t);for(const s of e.getImportDeclarations()){const i=r===void 0?q(s,t)??G(s,t,n):W(s,r,n);if(i!==void 0)return{exportName:i,specifier:Y(e,s)??s.getModuleSpecifierValue()}}},z=(e,t)=>Object.keys(t.getProject().getCompilerOptions().paths??{}).some(n=>{const r=n.indexOf("*");return r===-1?e===n:e.startsWith(n.slice(0,r))&&e.endsWith(n.slice(r+1))}),m={kind:"verbatim"},p={kind:"expand"},Q=new Set([g.ClassDeclaration,g.EnumDeclaration,g.EnumMember,g.InterfaceDeclaration,g.TypeAliasDeclaration]),Z=e=>T(e)!==void 0||l.isExportable(e)&&e.isExported(),ee=(e,t)=>new RegExp(String.raw`(?<![$\w])${t.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`)}(?![$\w])`,"u").test(e),M=(e,t,n,r)=>{const s=e.getSourceFile();if(s.getSymbol()===void 0&&T(e)===void 0||!Q.has(e.getKind()))return m;const i=s.getFilePath();if(i.includes(K))return m;if(i===n)return p;const o=l.isEnumMember(e)?e.getParent():e;if(!l.hasName(o))return p;const a=J(t.getSourceFile(),o,o.getName());return a===void 0?Z(o)||!ee(r(),o.getName())?m:p:z(a.specifier,t)?p:{kind:"qualify",qualified:a}},te=new Set([g.ClassDeclaration,g.EnumDeclaration,g.FunctionDeclaration,g.ModuleDeclaration]),I=e=>{const t=e?.getDeclarations()??[];return t.length>0&&t.every(n=>n.getSourceFile().getSymbol()===void 0)},ne=e=>{for(const t of e.getDeclarations()){const n=t.getFirstChildByKind(g.ComputedPropertyName);if(n!==void 0){let r=n.getExpression();for(;l.isPropertyAccessExpression(r);)r=r.getExpression();return r}}},re=(e,t)=>{if(e.getProperties().some(s=>{if(!s.getName().startsWith("__@"))return!1;const i=ne(s);return i===void 0||!I(i.getSymbol())}))return!0;const r=e.getSymbol();return r!==void 0&&r.getDeclarations().some(s=>te.has(s.getKind()))&&!I(r)&&t().startsWith("typeof ")},R=(e,t,n)=>{const r=e.getAliasSymbol(),s=e.getSymbol(),i=new Set((r??s)?.getDeclarations());let o=!1,a;const c=()=>(a??=e.getText(t),a);for(const u of[s,r].flatMap(d=>d?.getDeclarations()??[])){const d=M(u,t,n,c);if(d.kind==="qualify"&&i.has(u))return d;o||=d.kind!=="verbatim"}return o||re(e,c)?p:m},se=(e,t,n)=>{const r=l.isPropertySignature(e)||l.isPropertyDeclaration(e)?e.getTypeNode():void 0;if(r===void 0)return m;let s=!1;for(const i of[r,...r.getDescendantsOfKind(g.TypeReference)].filter(o=>l.isTypeReference(o))){const o=i.getTypeName().getSymbol();for(const a of(o?.getAliasedSymbol()??o)?.getDeclarations()??[]){const c=M(a,t,n,()=>i.getText());if(c.kind==="qualify")return c;s||=c.kind!=="verbatim"}}return s?p:m},oe=/^[A-Za-z_$][\w$]*$/u,ie=e=>oe.test(e)?e:JSON.stringify(e),$=e=>{const t=[...e.getTypeArguments()];return e.isUnion()&&t.push(...e.getUnionTypes()),e.isIntersection()&&t.push(...e.getIntersectionTypes()),t},y=e=>!e.isObject()||e.isArray()||e.isTuple()||e.getCallSignatures().length>0||e.getConstructSignatures().length>0?!1:e.getStringIndexType()===void 0&&e.getNumberIndexType()===void 0&&!e.getProperties().some(t=>t.getName().startsWith("__@")),E=(e,t,n,r=new Set)=>r.has(e)?!1:(r.add(e),R(e,t,n).kind!=="verbatim"||$(e).some(s=>E(s,t,n,r))?!0:y(e)?e.getProperties().some(s=>s.getDeclarations().some(i=>se(i,t,n).kind!=="verbatim")?!0:E(s.getTypeAtLocation(t),t,n,r)):!1),ae=(e,t)=>{const n=e.getValueDeclaration()??e.getDeclarations()[0];return n&&(l.isPropertySignature(n)||l.isPropertyDeclaration(n))&&n.hasQuestionToken()?!0:t.isUnion()&&t.getUnionTypes().some(r=>r.isUndefined())},C=(e,t)=>e!==void 0&&(y(e)||e.isString()||e.isNumber()||e.isBigInt()||e.isBoolean()||e.isLiteral()||e.isBooleanLiteral()||e.isEnumLiteral()||e.isTemplateLiteral()||e.isNull()||e.isUndefined()||e.isAny()||e.isUnknown()||e.isNever()||e.isVoid())?t:`(${t})`,ce=32,ue=8,le=(e,t,n,r,s,i)=>{const o=e.getArrayElementType(),a=o?i(o,t,n,r,s):void 0;if(a!==void 0)return`${C(o,a)}[]`},ge=(e,t,n,r,s,i)=>{const o=[];for(const a of e.getUnionTypes()){const c=i(a,t,n,r,s);if(c===void 0)return;o.push(c)}return o.join(" | ")},de=(e,t,n,r,s,i)=>{const o=[];for(const a of e.getIntersectionTypes()){const c=i(a,t,n,r,s);if(c===void 0)return;o.push(C(a,c))}return o.join(" & ")},me=(e,t,n,r,s,i)=>{if(!y(e))return;const o=[];for(const a of e.getProperties()){const c=a.getTypeAtLocation(t),u=ae(a,c),d=u&&c.isUnion()?c.getUnionTypes().filter(A=>!A.isUndefined()):[c],N=[];for(const A of d){const x=i(A,t,n,r+1,s);if(x===void 0)return;N.push(x)}o.push(`${ie(a.getName())}${u?"?":""}: ${N.join(" | ")}`)}return o.length>0?`{ ${o.join("; ")} }`:"{}"},fe=e=>{const t=e.getLiteralValue();return typeof t=="string"?JSON.stringify(t):typeof t=="number"?String(t):void 0},pe=e=>[e.getSymbol(),e.getAliasSymbol()].flatMap(t=>t?.getDeclarations()??[]).some(t=>l.isClassDeclaration(t)||l.isClassExpression(t)),b=(e,t,n,r,s=new Set)=>{if(r.has(e)||s.has(e))return!1;if(n>ce)return!0;const i=new Set(r).add(e);if($(e).some(u=>b(u,t,n+1,i,s)))return!0;const o=e.getArrayElementType();if(o!==void 0)return b(o,t,n+1,i,s);if(B(e))return s.add(e),!1;if(e.getCallSignatures().length>0||e.getConstructSignatures().length>0||[e.getSymbol(),e.getAliasSymbol()].flatMap(u=>u?.getDeclarations()??[]).some(u=>l.isClassDeclaration(u)||l.isClassExpression(u)))return!0;const c=y(e)&&e.getProperties().some(u=>b(u.getTypeAtLocation(t),t,n+1,i,s));return c||s.add(e),c},Se=(e,t,n,r,s,i,o)=>{const a=[];for(const c of t.getAliasSymbol()===void 0?t.getTypeArguments():t.getAliasTypeArguments()){const u=o(c,n,r,s+1,i);if(u===void 0)return;a.push(u)}return`import("${e.specifier}").${e.exportName}${a.length>0?`<${a.join(", ")}>`:""}`},ve=e=>[e.getSymbol(),e.getAliasSymbol()].flatMap(t=>t?.getDeclarations()??[]).some(t=>l.isEnumDeclaration(t)||l.isEnumMember(t)),f=(e,t,n,r,s)=>{if(r>ue||s.has(e))return;const i=R(e,t,n);if(i.kind==="verbatim"&&!E(e,t,n))return e.getText(t);const o=new Set(s).add(e);if(!pe(e)){if(e.isEnumLiteral())return fe(e);if(i.kind==="qualify"&&!ve(e)){const a=Se(i.qualified,e,t,n,r,o,f);if(a!==void 0)return a}return e.isArray()?le(e,t,n,r,o,f):e.isUnion()?ge(e,t,n,r,o,f):e.isIntersection()?de(e,t,n,r,o,f):me(e,t,n,r,o,f)}},he=e=>{const t=e.getType().getCallSignatures()[0];if(!t)return"unknown";let n=t.getReturnType();const s=(n.getSymbol()??n.getAliasSymbol())?.getName();if(s==="Promise"||s==="AsyncIterable"||s==="AsyncIterableIterator"||s==="AsyncGenerator"){const a=n.getTypeArguments()[0];a&&(n=a)}const i=n.getText(e);if(!i||i==="any"||i==="never"||O(i)||b(n,e,0,new Set))return"unknown";const o=e.getSourceFile().getFilePath();if(E(n,e,o)){const a=f(n,e,o,0,new Set);return a===void 0&&w(e,i),a??"unknown"}return i};export{E as a,Ne as b,Ae as c,De as d,f as e,O as i,xe as p,Te as r,he as u};
|
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.244",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
50
|
-
"@lunora/agent": "1.0.0-alpha.
|
|
49
|
+
"@lunora/advisor": "1.0.0-alpha.176",
|
|
50
|
+
"@lunora/agent": "1.0.0-alpha.158",
|
|
51
51
|
"@lunora/container": "1.0.0-alpha.64",
|
|
52
52
|
"@lunora/errors": "1.0.0-alpha.48",
|
|
53
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
54
|
-
"@lunora/queue": "1.0.0-alpha.
|
|
55
|
-
"@lunora/scheduler": "1.0.0-alpha.
|
|
53
|
+
"@lunora/platform": "1.0.0-alpha.47",
|
|
54
|
+
"@lunora/queue": "1.0.0-alpha.83",
|
|
55
|
+
"@lunora/scheduler": "1.0.0-alpha.101",
|
|
56
56
|
"@lunora/values": "1.0.0-alpha.58",
|
|
57
57
|
"@lunora/workflow": "1.0.0-alpha.69",
|
|
58
58
|
"jiti": "^2.7.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h,CELLD_CAPABILITIES as v}from"@lunora/platform";import{readProjectConfigLiterals as m}from"./loadProjectConfig-CKsFNgn3.mjs";const c="cloudflare",b=t=>{const{target:e}=m(t);return e!==void 0&&e.length>0?e:void 0},L=(t,e)=>e??b(t)??c,x=(t,e)=>{if(e!==void 0)return[];const{target:a,unreadable:r}=m(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:v,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},y=["agents","commitOrderedTables","containerEgressPolicy","containerRuntimeScheduling","cronTriggers","crossShardFanout","durableStreams","globalTables","queues","relationGraph","secrets","vectorStore","workerLoaders","workflowRollback","workflowSchedules"],g={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" })`)',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`)",vectorStore:"vector indexes (`.vectorize()`)",workerLoaders:"sandboxed agent scripts (`jsCodeTool`, on Worker Loaders)",workflowRollback:"workflow step rollback (`defineStep({ rollback })`)",workflowSchedules:"scheduled workflow instances (`defineWorkflow({ schedules })`)"},S=(t,e,a)=>({level:"error",message:`${e.name} does not support ${g[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 ${g[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:l}=t;for(const s of y){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"?S(s,r,l):T(s,r,l)))}},_=(t,e,a,r={})=>{const n={...t},d={...r},l=[],s=new Set;for(const[o,i]of Object.entries(w)){if(i===null||!t[o])continue;const p=e.features[i]?.level;p==="unsupported"?(n[o]=!1,s.add(i),l.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 "${i}" as native or emulated.`,target:a})):p===void 0&&(n[o]=!1,s.add(i),l.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 "${i}" 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:l,gatedSignals:d,matrix:e,reported:s,signals:r,target:a}),{diagnostics:l,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,b as readProjectTarget,x as readTargetDiagnostics,L as resolveCodegenTarget,I as studioPlatformFor};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as c}from"./json-data-Chfs2Cz5.mjs";import{s as u}from"./paths-C-9fwEgQ.mjs";import{validatorIrToJsonSchema as m,objectSchema as p,LUNORA_ERROR_CODES as i}from"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{G as l}from"./shared-DjUziztz.mjs";const d="1.3.2",R={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},h=e=>{const r=u(e.filePath),o=`${r}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${o}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${o}", "args": { … } }\`).`,errors:i.map((n,s)=>({code:-32e3-s,data:{code:n},message:n})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:p(e.args)}],result:{name:"result",schema:e.output?m(e.output):R},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:r}]}},g=e=>{const r=e.version??"0.0.0",n=e.functions.filter(t=>t.visibility!=="internal"&&t.kind!=="stream").map(t=>h(t)).toSorted((t,a)=>t.name.localeCompare(a.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:r},methods:n,openrpc:d}},$=e=>`${JSON.stringify(g(e),void 0,2)}
|
|
2
|
-
`,y=e=>`${l}export const openRpcSpec = ${c(e,"Record<string, unknown>")};
|
|
3
|
-
`;export{d as OPENRPC_VERSION,g as buildOpenRpcDocument,$ as emitOpenRpc,y as emitOpenRpcModule};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as g}from"node:fs";import{join as p}from"node:path";import{LunoraError as l}from"@lunora/errors";import{queueDefaultName as f,queueBindingName as y}from"@lunora/queue";import{SyntaxKind as h,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{findObjectProperty as m,stringPropertyFor as b}from"./listLunoraSourceFiles-DP-5e-RE.mjs";const q="queues.ts",N=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineQueue";for(const e of t.getDeclarations())if(s.isImportSpecifier(e))return e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/queue"?!1:e.getNameNode().getText()==="defineQueue";return!1},d=b("queue"),w=(r,t,e)=>{if(s.isNumericLiteral(r))return r.getLiteralValue();throw a(r,`queue "${t}": \`${e}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},E=(r,t)=>{const e=m(r,"name");if(!e||!s.isPropertyAssignment(e))return;const n=d(e.getInitializerOrThrow(),t,"name");if(n.length===0)throw a(e,`queue "${t}": \`name\` must be a non-empty string when provided`);return n},P=(r,t)=>{const e=r.getArguments()[0];if(!e||!s.isObjectLiteralExpression(e))throw a(r,`queue "${t}": defineQueue must be passed an inline object literal`);const n={bindingName:y(t),exportName:t,mode:"push",name:E(e,t)??f(t),tuning:{}},i=m(e,"mode");if(i&&s.isPropertyAssignment(i)){const o=d(i.getInitializerOrThrow(),t,"mode");if(o!=="push"&&o!=="pull")throw a(i,`queue "${t}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(o)})`);n.mode=o}const u=m(e,"deadLetterQueue");u&&s.isPropertyAssignment(u)&&(n.tuning.deadLetterQueue=d(u.getInitializerOrThrow(),t,"deadLetterQueue"));for(const o of["maxBatchSize","maxBatchTimeout","maxRetries","retryDelay"]){const c=m(e,o);c&&s.isPropertyAssignment(c)&&(n.tuning[o]=w(c.getInitializerOrThrow(),t,o))}return n},I=r=>{const t=[];for(const e of r.getVariableDeclarations()){if(!e.isExported())continue;const n=e.getInitializer();if(n?.getKind()!==h.CallExpression)continue;const i=n,u=i.getExpression();if(!s.isIdentifier(u)||!N(u))continue;const o=e.getNameNode();if(!s.isIdentifier(o))throw a(o,"defineQueue exports must be plain named exports (no destructuring)");t.push(P(i,o.getText()))}return t},Q=r=>{const t=new Map,e=new Map;for(const n of r){const i=t.get(n.name);if(i!==void 0)throw new l("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${n.name}": produced by both "${i}" and "${n.exportName}". Deployed queue names must be unique across the project.`,{status:500});t.set(n.name,n.exportName);const u=e.get(n.bindingName);if(u!==void 0)throw new l("DUPLICATE_QUEUE_BINDING",`Duplicate queue binding "${n.bindingName}": produced by both "${u}" and "${n.exportName}". Queue export names must yield unique binding names.`,{status:500});e.set(n.bindingName,n.exportName)}},U=(r,t)=>{const e=p(t,q);if(!g(e))return[];const n=r.getSourceFile(e)??r.addSourceFileAtPath(e),i=I(n);return i.sort((u,o)=>u.exportName.localeCompare(o.exportName)),Q(i),i};export{q as QUEUES_FILENAME,U as discoverQueues};
|