@lunora/codegen 1.0.0-alpha.253 → 1.0.0-alpha.255
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 +77 -47
- package/dist/index.d.ts +77 -47
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{CAPABILITY_PROBES-BPeV994T.mjs → CAPABILITY_PROBES-DFsutD7g.mjs} +3 -2
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-CVtSBGXP.mjs → SCHEMA_SNAPSHOT_FILENAME-D0ZAEgkE.mjs} +1 -1
- package/dist/packem_shared/capabilitiesUsedBy-DqrbgTKV.mjs +1 -0
- package/dist/packem_shared/{discoverSandboxUsage-BnsPld5I.mjs → discoverSandboxUsage-DC6q7rZy.mjs} +1 -1
- package/dist/packem_shared/{emitAgents-QaI2dB2T.mjs → emitAgents-BD_IUs4I.mjs} +1 -1
- package/dist/packem_shared/{emitApp-CokyctXT.mjs → emitApp-0rC4g46B.mjs} +394 -394
- package/dist/packem_shared/{emitServer-DThb0DLe.mjs → emitServer-mdlKhXYb.mjs} +44 -46
- package/dist/packem_shared/{emitShard-BF9yqSKI.mjs → emitShard-JmiNbWa4.mjs} +1 -1
- package/dist/packem_shared/{shard-CBwweXGB.mjs → shard-Do57J5-c.mjs} +3 -3
- package/dist/packem_shared/{shard-runtime-DTSpJxxd.mjs → shard-runtime-B8rucwkF.mjs} +47 -47
- package/package.json +7 -7
- package/dist/packem_shared/sourceCapabilitySignals-NsxX0VDV.mjs +0 -1
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import{relative as
|
|
2
|
-
`:"",Y=
|
|
3
|
-
readonly payments: LunoraPayment;`:"",A=e=>e.sandbox===!0?"SandboxContainerAccessor":"ContainerAccessor",X=[...new Set(r.map(e=>A(e)))].toSorted((e,a)=>e.localeCompare(a)),Z=r.length>0?`import type { ${X.join(", ")} } from "@lunora/container";
|
|
4
|
-
`:"",ee=r.length>0?`
|
|
1
|
+
import{relative as ve,isAbsolute as ke,sep as we}from"node:path";import{LunoraError as V}from"@lunora/errors";import{CAPABILITIES as Ie}from"./CAPABILITY_PROBES-DFsutD7g.mjs";import{p as $e}from"./ir-DBSvhNa-.mjs";import{a as p,G as Be,u as Re,d as Oe}from"./shared-DjUziztz.mjs";const Ne=/\.([cm]?)tsx?$/u,Me=(d,l=[])=>{const r=new Set;for(const t of d.tables)for(const i of Object.values(t.shape)){const n=Re(i);n.kind==="storage"&&typeof n.bucket=="string"&&n.bucket!==""&&r.add(n.bucket)}for(const t of l)t!==""&&t!=="default"&&r.add(t);return["default",...[...r].toSorted((t,i)=>t.localeCompare(i))]},Qe=({agents:d=[],capabilities:l=new Set,containers:r=[],env:t,hasVectors:i=!0,hasFlags:n=!1,hasNotify:_=!1,identity:s,queues:R=[],schema:O,generatedDirectory:N="",services:y=[],storageRuleBuckets:H=[],topics:M=[],useUmbrella:z=!1,workflows:C=[]}={})=>{const o=Oe(z),U=Me(O??{tables:[]},H).map(e=>JSON.stringify(e)).join(" | "),D=e=>e.sandbox===!0?"SandboxContainerAccessor":"ContainerAccessor",J=[...new Set(r.map(e=>D(e)))].toSorted((e,a)=>e.localeCompare(a)),K=r.length>0?`import type { ${J.join(", ")} } from "@lunora/container";
|
|
2
|
+
`:"",Y=r.length>0?`
|
|
5
3
|
readonly containers: {${r.map(e=>`
|
|
6
|
-
readonly ${e.exportName}: ${
|
|
7
|
-
};`:"",
|
|
4
|
+
readonly ${e.exportName}: ${D(e)};`).join("")}
|
|
5
|
+
};`:"",A=[...l.has("ai")?[" /** Workers AI binding (the conventional `env.AI`), narrowing `ctx.ai`. */\n readonly AI?: unknown;"]:[],...r.map(e=>(p(e.bindingName,`container binding "${e.bindingName}"`),` /** Durable Object namespace for the \`${e.exportName}\` container. */
|
|
8
6
|
readonly ${e.bindingName}?: unknown;`)),...R.map(e=>(p(e.bindingName,`queue binding "${e.bindingName}"`),` /** Queue producer binding for the \`${e.exportName}\` queue. */
|
|
9
7
|
readonly ${e.bindingName}?: unknown;`))].join(`
|
|
10
|
-
`),
|
|
8
|
+
`),X=`
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* This project's Cloudflare bindings, as far as codegen can discover them from
|
|
@@ -20,24 +18,24 @@ import{relative as Ie,isAbsolute as $e,sep as Be}from"node:path";import{LunoraEr
|
|
|
20
18
|
* surface, so treat them as \`Fetcher\`/\`Service<unknown>\` and cast.
|
|
21
19
|
*/
|
|
22
20
|
export interface CloudflareBindings {
|
|
23
|
-
readonly [binding: string]: unknown;${
|
|
24
|
-
${
|
|
21
|
+
readonly [binding: string]: unknown;${A?`
|
|
22
|
+
${A}`:""}
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
/** Alias for {@link CloudflareBindings} — the typed shape of \`env\`. */
|
|
28
|
-
export type Env = CloudflareBindings;`,
|
|
29
|
-
readonly vectors: VectorSearch<VectorIndexName>;`:"",
|
|
30
|
-
readonly vectors: VectorSearchReader<VectorIndexName>;`:"",
|
|
26
|
+
export type Env = CloudflareBindings;`,S=e=>Ie.map(a=>a.tier!==void 0&&e.includes(a.tier)&&l.has(a.key)?a.serverCtxField:"").join(""),W=S(["every"]),Z=S(["every","action"]),c=i&&(O?.vectorIndexes.length??0)>0,m=c?' | "vectors"':"",F=c?`
|
|
27
|
+
readonly vectors: VectorSearch<VectorIndexName>;`:"",ee=c?`
|
|
28
|
+
readonly vectors: VectorSearchReader<VectorIndexName>;`:"",te=c?`import type { VectorSearch, VectorSearchReader } from "${o.server}";
|
|
31
29
|
import type { VectorIndexName } from "./dataModel.js";
|
|
32
30
|
`:"",h=n?`
|
|
33
31
|
/** Feature-flag evaluation (OpenFeature). Reads are memoized per request; evaluations never throw — a provider error resolves to the supplied default. */
|
|
34
|
-
readonly flags: import("${o.flags}").LunoraFlags;`:"",b=
|
|
32
|
+
readonly flags: import("${o.flags}").LunoraFlags;`:"",b=_?`
|
|
35
33
|
/** Multi-channel notifications (@lunora/notify): send / chat / inApp / webhook plus the push device sub-facade. Sends are external I/O — confine them to action handlers. */
|
|
36
34
|
readonly notify: import("@lunora/notify").LunoraNotify;
|
|
37
35
|
/** Device push sub-facade — the same object as ctx.notify.push (register / send / broadcast). Sends belong in action handlers. */
|
|
38
|
-
readonly push: import("@lunora/notify").LunoraPush;`:"",u=
|
|
36
|
+
readonly push: import("@lunora/notify").LunoraPush;`:"",u=C.length>0,ae=u?`import type { WorkflowHandle } from "@lunora/workflow";
|
|
39
37
|
import type * as lunoraWorkflowDefinitions from "../workflows.js";
|
|
40
|
-
`:"",
|
|
38
|
+
`:"",re=u?`
|
|
41
39
|
|
|
42
40
|
/** Params type carried by a \`defineWorkflow\` definition (its phantom \`__params\`). */
|
|
43
41
|
type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params }
|
|
@@ -48,56 +46,56 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
|
|
|
48
46
|
|
|
49
47
|
/** This project's declared workflows, addressable from \`ctx.workflows\` by their \`lunora/workflows.ts\` export name. */
|
|
50
48
|
export interface LunoraWorkflows {
|
|
51
|
-
${
|
|
49
|
+
${C.map(e=>` get(name: ${JSON.stringify(e.exportName)}): WorkflowHandle<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${e.exportName}>>;`).join(`
|
|
52
50
|
`)}
|
|
53
|
-
}`:"",
|
|
54
|
-
readonly workflows: LunoraWorkflows;`:"",
|
|
51
|
+
}`:"",Q=u?' | "workflows"':"",j=u?`
|
|
52
|
+
readonly workflows: LunoraWorkflows;`:"",P=$e(R),f=P.length>0,x=M.length>0,g=[...f?["QueueProducer"]:[],...x?["TopicPublisher"]:[]],oe=g.length>0?`import type { ${g.join(", ")} } from "@lunora/queue";
|
|
55
53
|
import type * as lunoraQueueDefinitions from "../queues.js";
|
|
56
|
-
`:"",
|
|
54
|
+
`:"",ne=g.length>0?"\n\n/** Message body type carried by a `defineQueue` / `defineTopic` definition (its phantom `__lunoraBody`). */\ntype QueueBodyOf<Definition> = Definition extends { __lunoraBody?: infer Body } ? (unknown extends Body ? unknown : NonNullable<Body>) : unknown;":"",se=f?`
|
|
57
55
|
|
|
58
56
|
/** This project's declared queues, addressable from \`ctx.queues\` by their \`lunora/queues.ts\` export name. */
|
|
59
57
|
export interface LunoraQueues {
|
|
60
|
-
${
|
|
58
|
+
${P.map(e=>` readonly ${e.exportName}: QueueProducer<QueueBodyOf<typeof lunoraQueueDefinitions.${e.exportName}>>;`).join(`
|
|
61
59
|
`)}
|
|
62
|
-
}`:"",
|
|
60
|
+
}`:"",ie=x?`
|
|
63
61
|
|
|
64
62
|
/** This project's declared topics, addressable from \`ctx.topics\` by their \`lunora/queues.ts\` export name. */
|
|
65
63
|
export interface LunoraTopics {
|
|
66
|
-
${
|
|
64
|
+
${M.map(e=>` readonly ${e.exportName}: TopicPublisher<QueueBodyOf<typeof lunoraQueueDefinitions.${e.exportName}>>;`).join(`
|
|
67
65
|
`)}
|
|
68
|
-
}`:"",
|
|
69
|
-
readonly queues: LunoraQueues;`:"",
|
|
70
|
-
readonly topics: LunoraTopics;`:"",T=y.length>0,
|
|
71
|
-
${
|
|
72
|
-
`).join("")}`:"",
|
|
66
|
+
}`:"",de=`${ne}${se}${ie}`,E=f?`
|
|
67
|
+
readonly queues: LunoraQueues;`:"",q=x?`
|
|
68
|
+
readonly topics: LunoraTopics;`:"",T=y.length>0,le=e=>{if(N==="")throw new V("INTERNAL","@lunora/codegen: emitServer needs `generatedDirectory` to import an RPC service's types");const a=ve(N,e);if(ke(a))throw new V("INTERNAL",`@lunora/codegen: an RPC service's entry (${e}) must be on the same drive as the app`);const B=a.split(we).join("/").replace(Ne,".$1js");return B.startsWith(".")?B:`./${B}`},L=y.filter(e=>e.rpcEntrypoint!==void 0),ce=L.length>0?"ServiceFetcher, ServiceRpc":"ServiceFetcher",ue=T?`import type { ${ce} } from "${o.server}";
|
|
69
|
+
${L.map(e=>`import type * as lunoraService_${e.name} from ${JSON.stringify(le(e.main))};
|
|
70
|
+
`).join("")}`:"",pe=T?`
|
|
73
71
|
|
|
74
72
|
/** This project's service bindings (\`lunora.config\` \`services\`), addressable from \`ctx.services\` in actions. */
|
|
75
73
|
export interface LunoraServices {
|
|
76
74
|
${y.map(e=>{p(e.name,`service "${e.name}"`);const a=e.rpcEntrypoint===void 0?"ServiceFetcher":`ServiceRpc<typeof lunoraService_${e.name}.${e.rpcEntrypoint}>`;return` readonly ${e.name}: ${a};`}).join(`
|
|
77
75
|
`)}
|
|
78
|
-
}`:"",
|
|
79
|
-
readonly services: LunoraServices;`:"",v=
|
|
80
|
-
`:"",
|
|
76
|
+
}`:"",ye=T?`
|
|
77
|
+
readonly services: LunoraServices;`:"",v=d.length>0,me=v?`import type { AgentHandle } from "@lunora/agent";
|
|
78
|
+
`:"",he=v?`
|
|
81
79
|
|
|
82
80
|
/** This project's declared agents, addressable from \`ctx.agents\` by their \`lunora/agents.ts\` export name. */
|
|
83
81
|
export interface LunoraAgents {
|
|
84
|
-
${
|
|
82
|
+
${d.map(e=>(p(e.exportName,`agent export "${e.exportName}"`),` readonly ${e.exportName}: AgentHandle;`)).join(`
|
|
85
83
|
`)}
|
|
86
|
-
}`:"",
|
|
87
|
-
readonly agents: LunoraAgents;`:"",
|
|
84
|
+
}`:"",G=v?`
|
|
85
|
+
readonly agents: LunoraAgents;`:"",be=s?`import type { InferIdentity } from "${o.server}";
|
|
88
86
|
import type * as lunoraIdentityContract from "../identity.js";
|
|
89
|
-
`:"",
|
|
87
|
+
`:"",fe=s?`
|
|
90
88
|
|
|
91
89
|
/** This app's declared identity claim contract (\`defineIdentity\` in \`lunora/identity.ts\`) — the typed shape of \`ctx.auth.getIdentity()\`, the RLS policy \`ctx.auth.identity\`, and the \`authorizeShard\`/\`authorizeFanOut\` identity argument. */
|
|
92
90
|
export type Identity = InferIdentity<typeof lunoraIdentityContract.${s.exportName}>;
|
|
93
91
|
|
|
94
92
|
/** \`ctx.auth\` narrowed so \`getIdentity()\` resolves the declared {@link Identity} contract instead of the untyped claim bag. */
|
|
95
93
|
type NarrowedAuth = Omit<QueryCtxBase["auth"], "getIdentity"> & { getIdentity: () => Promise<Identity | null> };`:"",k=s?' | "auth"':"",w=s?`
|
|
96
|
-
readonly auth: NarrowedAuth;`:"",
|
|
97
|
-
`:"",
|
|
94
|
+
readonly auth: NarrowedAuth;`:"",xe=s?", Identity":"",ge=t?`import type * as lunoraEnvContract from "../env.js";
|
|
95
|
+
`:"",Te=t?`
|
|
98
96
|
|
|
99
97
|
/** This app's declared env contract (\`defineEnv\` in \`lunora/env.ts\`) — the validated, coercion-aware shape of \`ctx.env\`. */
|
|
100
|
-
export type LunoraEnv = ReturnType<typeof lunoraEnvContract.${t.exportName}>;`:"",I=t?' | "env"':"",$=t?"\n /** Validated, typed environment declared by `defineEnv` in `lunora/env.ts` — parsed & coercion-aware config values (`ctx.env.STRIPE_KEY`); a missing or invalid value throws at read time. */\n readonly env: LunoraEnv;":"";return`${
|
|
98
|
+
export type LunoraEnv = ReturnType<typeof lunoraEnvContract.${t.exportName}>;`:"",I=t?' | "env"':"",$=t?"\n /** Validated, typed environment declared by `defineEnv` in `lunora/env.ts` — parsed & coercion-aware config values (`ctx.env.STRIPE_KEY`); a missing or invalid value throws at read time. */\n readonly env: LunoraEnv;":"";return`${Be}import { createPolicyDsl, defineMutator as defineMutatorBase, initLunora, v as vBase } from "${o.server}";
|
|
101
99
|
import type {
|
|
102
100
|
ActionBuilder,
|
|
103
101
|
ActionCtx as ActionCtxBase,
|
|
@@ -154,7 +152,7 @@ export type {
|
|
|
154
152
|
} from "${o.serverDataModel}";
|
|
155
153
|
|
|
156
154
|
import type { DataModel, Doc, GeoIndexNamesByTable, Id as IdOfTable, IndexNamesByTable, Insert, InsertModel, RankIndexNamesByTable, Relations, SearchIndexNamesByTable, TableName } from "./dataModel.js";
|
|
157
|
-
${
|
|
155
|
+
${te}${K}${ae}${oe}${ue}${me}${be}${ge}
|
|
158
156
|
export type { AppTableName, DataModel, Doc, Id, TableName } from "./dataModel.js";
|
|
159
157
|
|
|
160
158
|
/**
|
|
@@ -214,7 +212,7 @@ export interface OrmWriter extends OrmReader {
|
|
|
214
212
|
}
|
|
215
213
|
|
|
216
214
|
/** Storage buckets this schema declares (\`v.storage("name")\`), narrowing \`ctx.storage.bucket(name)\`. */
|
|
217
|
-
export type StorageBucketName = ${
|
|
215
|
+
export type StorageBucketName = ${U};${X}${re}${de}${pe}${he}${fe}${Te}
|
|
218
216
|
|
|
219
217
|
/**
|
|
220
218
|
* Project-typed contexts. The base contexts from \`@lunora/server\` are
|
|
@@ -280,19 +278,19 @@ type TypedAsId = <T extends string>(tableName: AsIdTable<T>, id: string) => IdOf
|
|
|
280
278
|
export interface QueryCtx extends Omit<QueryCtxBase, "db" | "storage"${m}${k}${I}> {
|
|
281
279
|
readonly db: Omit<DatabaseReader, "asId" | "query" | "get"> & DatabaseReaderFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
|
|
282
280
|
readonly orm: OrmReader;
|
|
283
|
-
readonly storage: ReadOnlyStorage<StorageBucketName>;${
|
|
281
|
+
readonly storage: ReadOnlyStorage<StorageBucketName>;${ee}${W}${h}${b}${$}${w}
|
|
284
282
|
}
|
|
285
283
|
|
|
286
|
-
export interface MutationCtx extends Omit<MutationCtxBase, "db" | "storage"${m}${
|
|
284
|
+
export interface MutationCtx extends Omit<MutationCtxBase, "db" | "storage"${m}${Q}${k}${I}> {
|
|
287
285
|
readonly db: Omit<DatabaseWriter, "asId" | "query" | "get"> & DatabaseWriterFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
|
|
288
286
|
readonly orm: OrmWriter;
|
|
289
|
-
readonly storage: MutationStorage<StorageBucketName>;${
|
|
287
|
+
readonly storage: MutationStorage<StorageBucketName>;${F}${W}${h}${b}${$}${j}${E}${q}${G}${w}
|
|
290
288
|
}
|
|
291
289
|
|
|
292
|
-
export interface ActionCtx extends Omit<ActionCtxBase, "db" | "storage"${m}${
|
|
290
|
+
export interface ActionCtx extends Omit<ActionCtxBase, "db" | "storage"${m}${Q}${k}${I}> {
|
|
293
291
|
readonly db: Omit<DatabaseWriter, "asId" | "query" | "get"> & DatabaseWriterFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
|
|
294
292
|
readonly orm: OrmWriter;
|
|
295
|
-
readonly storage: StorageBase<StorageBucketName>;${
|
|
293
|
+
readonly storage: StorageBase<StorageBucketName>;${F}${Z}${Y}${h}${b}${ye}${$}${j}${E}${q}${G}${w}
|
|
296
294
|
}
|
|
297
295
|
|
|
298
296
|
/**
|
|
@@ -350,7 +348,7 @@ export const defineMutator = defineMutatorBase as unknown as <Args extends Recor
|
|
|
350
348
|
* Runtime-identical to \`@lunora/server\`'s \`definePolicy\`; only the types narrow,
|
|
351
349
|
* so the \`rls()\` chain discovers a policy authored either way the same.
|
|
352
350
|
*/
|
|
353
|
-
export const definePolicy = createPolicyDsl<DataModel, Relations${
|
|
351
|
+
export const definePolicy = createPolicyDsl<DataModel, Relations${xe}>();
|
|
354
352
|
|
|
355
353
|
/**
|
|
356
354
|
* The validator builder \`v\`, with \`v.id(...)\` constrained to THIS schema's
|
|
@@ -367,4 +365,4 @@ export const definePolicy = createPolicyDsl<DataModel, Relations${ve}>();
|
|
|
367
365
|
export const v = vBase as unknown as Omit<typeof vBase, "id"> & {
|
|
368
366
|
id: <T extends TableName>(table: T) => ColumnValidator<IdOfTable<T>, IdOfTable<T>>;
|
|
369
367
|
};
|
|
370
|
-
`};export{
|
|
368
|
+
`};export{Qe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./ir-DBSvhNa-.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as f}from"./shard-
|
|
1
|
+
import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./ir-DBSvhNa-.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as f}from"./shard-Do57J5-c.mjs";import"./shard-runtime-B8rucwkF.mjs";import"./shared-DjUziztz.mjs";export{f as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LunoraError as vt}from"@lunora/errors";import{serializeSchemaSnapshot as kt,hashSchemaSnapshot as St}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{isHyperdriveGlobalTable as Rt,isD1GlobalTable as xt}from"./isD1GlobalTable-udvHAAzD.mjs";import{p as At,i as Dt}from"./ir-DBSvhNa-.mjs";import{r as h}from"./json-data-Chfs2Cz5.mjs";import{r as C,e as Ot,a as Tt,b as Et,c as Ct,d as Lt,f as It,g as _t,h as Mt,i as Pt,j as qt,k as Nt,l as $t,m as Ft,n as Ut,o as Bt,p as Wt,q as jt}from"./shard-runtime-
|
|
1
|
+
import{LunoraError as vt}from"@lunora/errors";import{serializeSchemaSnapshot as kt,hashSchemaSnapshot as St}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{isHyperdriveGlobalTable as Rt,isD1GlobalTable as xt}from"./isD1GlobalTable-udvHAAzD.mjs";import{p as At,i as Dt}from"./ir-DBSvhNa-.mjs";import{r as h}from"./json-data-Chfs2Cz5.mjs";import{r as C,e as Ot,a as Tt,b as Et,c as Ct,d as Lt,f as It,g as _t,h as Mt,i as Pt,j as qt,k as Nt,l as $t,m as Ft,n as Ut,o as Bt,p as Wt,q as jt}from"./shard-runtime-B8rucwkF.mjs";import{u as K,i as Ht,G as Vt,d as Kt}from"./shared-DjUziztz.mjs";const Gt=` /**
|
|
2
2
|
* The bare writer every admin/maintenance entry point writes through.
|
|
3
3
|
*
|
|
4
4
|
* Admin and maintenance writes go through the SAME reactive-cache hooks as a
|
|
@@ -1061,7 +1061,7 @@ assertShapesDeclareReadPolicies(LUNORA_SHAPES, ${JSON.stringify(t)}, (schema as
|
|
|
1061
1061
|
`:"",sourceClientCacheConst:a?`
|
|
1062
1062
|
const sourceClientCache = new WeakMap<object, Map<string, SourceClientLike>>();
|
|
1063
1063
|
const sourcePollAtCache = new WeakMap<object, Map<string, number>>();
|
|
1064
|
-
`:""}),cr=(a,r)=>{const e=r.length>0,t=a?C("vectorsStub: VectorSearchLike",
|
|
1064
|
+
`:""}),cr=(a,r)=>{const e=r.length>0,t=a?C("vectorsStub: VectorSearchLike","ctx.vectors: no vectors configured. Pass `vectors` to createShardDO().",["deleteByIds","getByIds","query","upsert","upsertNow"]):"",o=e?` const vectorShardKey = this.currentShardKey();
|
|
1065
1065
|
`:"",d=e?"namespace: vectorShardKey === ROOT_SHARD_NAME ? undefined : vectorShardKey, ":"",f=`, { ${["deferAfterCommit: (work) => this.deferAfterCommit(work)",...e?["namespace: vectorShardKey === ROOT_SHARD_NAME ? undefined : vectorShardKey",`shardedIndexNames: [${r.map(S=>JSON.stringify(S)).join(", ")}]`]:[]].join(", ")} }`,c=a?`
|
|
1066
1066
|
const vectorSync = this.vectorSync(env);
|
|
1067
1067
|
// Vectorize lives outside this shard's SQLite, so a query whose result
|
|
@@ -1112,7 +1112,7 @@ const LUNORA_SCHEMA_SNAPSHOT: { hash: string; json: string } = { hash: ${JSON.st
|
|
|
1112
1112
|
vectors?: (env: Record<string, unknown>) => Record<string, VectorizeIndexLike>;`:"",Ge=z?`
|
|
1113
1113
|
d1?: (env: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown>; onBookmark?: (bookmark: string | undefined) => void; userId?: string }) => DatabaseWriterLike | undefined;`:"",Qe=j?`
|
|
1114
1114
|
hyperdriveGlobal?: (env: Record<string, unknown>, request?: { cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown>; userId?: string }) => DatabaseWriterLike | undefined;`:"",ze=T?`
|
|
1115
|
-
sourceClient?: (env: Record<string, unknown>, binding: string) => { query: <Row = Record<string, unknown>>(text: string, params?: readonly unknown[]) => Promise<Row[]> } | undefined;`:"",Xe=
|
|
1115
|
+
sourceClient?: (env: Record<string, unknown>, binding: string) => { query: <Row = Record<string, unknown>>(text: string, params?: readonly unknown[]) => Promise<Row[]> } | undefined;`:"",Xe="ctx.db.<globalTable>: no global backend configured. Pass `d1` or `hyperdriveGlobal` to createShardDO().",Je="ctx.scheduler: no scheduler configured. Pass `scheduler` to createShardDO().",Ye="ctx.storage: no storage configured. Pass `storage` to createShardDO().",Ze=x?C("globalDbStub: DatabaseWriterLike",Xe,["aggregate","count","delete","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","normalizeId","patch","query","rank","rankPage","replace"],{sync:["normalizeId","query"]}):"",{vectorSyncMethod:et,vectorsBuild:tt,vectorsStub:rt}=cr(u,Q?i.vectorIndexes.filter(s=>B.has(s.table)).map(s=>s.name):[]),at=`{
|
|
1116
1116
|
...this.ctxDbTuning(),
|
|
1117
1117
|
auth: { identity: identity ?? null, userId: userId ?? null },
|
|
1118
1118
|
broadcast: (delta) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as
|
|
1
|
+
import{s as b}from"./ir-DBSvhNa-.mjs";import{r as y}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as $}from"./CAPABILITY_PROBES-DFsutD7g.mjs";import{a as c,G as p}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,14 +6,14 @@ import{s as $}from"./ir-DBSvhNa-.mjs";import{r as x}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
|
-
${
|
|
9
|
+
`}:{importFragment:"",override:""},g=(e,r,t,{cast:n="",sync:o=[]}={})=>{const i=`throw new Error(${JSON.stringify(r)});`,u=t.map(a=>` ${a}: ${o.includes(a)?"":"async "}() => {
|
|
10
|
+
${i}
|
|
11
11
|
},`).join(`
|
|
12
12
|
`);return`
|
|
13
13
|
const ${e} = {
|
|
14
|
-
${
|
|
14
|
+
${u}
|
|
15
15
|
}${n};
|
|
16
|
-
`},
|
|
16
|
+
`},f={build:"",configField:"",contextField:"",importLines:[],stub:""},I=e=>e.size===0?{configField:"",constant:"",override:""}:{configField:"\n /** The `ShardRegistryDO` namespace (typically `env.SHARD_REGISTRY`). This shard registers its key for each `.shardBy()` table it writes, so cross-shard export, sync and migrations reach it. */\n shardRegistry?: (env: Record<string, unknown>) => unknown;",constant:`
|
|
17
17
|
/** The \`.shardBy()\` tables this shard registers with the shard registry when it writes them. */
|
|
18
18
|
const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(r=>JSON.stringify(r)).join(", ")}]);
|
|
19
19
|
`,override:`
|
|
@@ -22,28 +22,28 @@ const SHARDED_TABLES: ReadonlySet<string> = new Set([${[...e].map(r=>JSON.string
|
|
|
22
22
|
|
|
23
23
|
return namespace === undefined ? undefined : { namespace, shardedTables: SHARDED_TABLES };
|
|
24
24
|
}
|
|
25
|
-
`},
|
|
25
|
+
`},T=(e,r)=>e?{build:`
|
|
26
26
|
const flags: import("${r}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
27
27
|
provider: () => config.flags?.(env),
|
|
28
28
|
targetingKey: () => flagsConfig.identify?.({ identity: identity ?? null, userId: userId ?? null }),
|
|
29
29
|
});
|
|
30
30
|
`,configField:`
|
|
31
31
|
flags?: (env: Record<string, unknown>) => import("${r}").Provider;`,contextField:`
|
|
32
|
-
flags,`,importLines:[`import { createFlags } from "${r}";`,'import flagsConfig from "../flags.js";'],stub:""}:
|
|
32
|
+
flags,`,importLines:[`import { createFlags } from "${r}";`,'import flagsConfig from "../flags.js";'],stub:""}:f,q=e=>e?{build:`
|
|
33
33
|
const { notify, push } = createNotify(notifyConfig, env, { log, metrics });
|
|
34
34
|
`,configField:"",contextField:`
|
|
35
35
|
notify,
|
|
36
|
-
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:
|
|
36
|
+
push,`,importLines:['import { createNotify } from "@lunora/notify";','import notifyConfig from "../notify.js";'],stub:""}:f,B=e=>e?{build:`
|
|
37
37
|
const envConfig = lunoraEnvContract.${e.exportName}(env);
|
|
38
38
|
`,configField:"",contextField:`
|
|
39
|
-
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:
|
|
39
|
+
env: envConfig,`,importLines:['import * as lunoraEnvContract from "../env.js";'],stub:""}:f,D=(e,r,t)=>{if(!r)return{constant:"",evaluateOverride:"",subscriptionOverride:""};const n=a=>`
|
|
40
40
|
const env = (this.env ?? {}) as Record<string, unknown>;
|
|
41
41
|
const flags: import("${t}").LunoraFlags = createFlags(flagsConfig, env, {
|
|
42
42
|
provider: () => config.flags?.(env),
|
|
43
|
-
targetingKey: ${
|
|
43
|
+
targetingKey: ${a},
|
|
44
44
|
});`,o=`
|
|
45
45
|
/** Statically-discovered feature flags (\`ctx.flags.<type>("key")\` reads) served via \`__lunora_admin__:listFlags\` + the reactive \`__lunora_flags__:\` channel. */
|
|
46
|
-
const LUNORA_FLAG_KEYS = ${
|
|
46
|
+
const LUNORA_FLAG_KEYS = ${y(e,'ReadonlyArray<{ key: string; type: "boolean" | "number" | "object" | "string" }>')};
|
|
47
47
|
`,i=`
|
|
48
48
|
protected override async evaluateFlags(context?: Record<string, unknown>): Promise<FlagsResult> {${n("undefined")}
|
|
49
49
|
const evalContext = context as import("${t}").EvaluationContext | undefined;
|
|
@@ -98,7 +98,7 @@ const LUNORA_FLAG_KEYS = ${x(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
98
98
|
|
|
99
99
|
return flags.boolean(key, typeof args.default === "boolean" ? args.default : false, context);
|
|
100
100
|
}
|
|
101
|
-
`;return{constant:o,evaluateOverride:i,subscriptionOverride:u}},
|
|
101
|
+
`;return{constant:o,evaluateOverride:i,subscriptionOverride:u}},v=()=>({build:`
|
|
102
102
|
const aiBinding = config.ai?.(env) ?? (env as Record<string, unknown>).AI;
|
|
103
103
|
// Correlate AI-Gateway-routed calls with the Lunora trace: thread the
|
|
104
104
|
// function path + trace id into createAi, which folds them into the
|
|
@@ -115,9 +115,9 @@ const LUNORA_FLAG_KEYS = ${x(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
115
115
|
telemetry: { metrics, trace },
|
|
116
116
|
});
|
|
117
117
|
`,configField:`
|
|
118
|
-
ai?: (env: Record<string, unknown>) => AiBindingLike;`,importLines:['import type { AiBindingLike, LunoraAi } from "@lunora/ai";','import { createAi } from "@lunora/ai";'],stub:""}),
|
|
118
|
+
ai?: (env: Record<string, unknown>) => AiBindingLike;`,importLines:['import type { AiBindingLike, LunoraAi } from "@lunora/ai";','import { createAi } from "@lunora/ai";'],stub:""}),k=()=>({build:`
|
|
119
119
|
const access = accessFacade(identity, userId);
|
|
120
|
-
`,configField:"",importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}),
|
|
120
|
+
`,configField:"",importLines:['import { accessFacade } from "@lunora/cloudflare-access/context";'],stub:""}),R=()=>({build:`
|
|
121
121
|
const r2sqlEnv = env as Record<string, unknown>;
|
|
122
122
|
const r2sqlAccountId = (r2sqlEnv.R2_SQL_ACCOUNT_ID ?? r2sqlEnv.CLOUDFLARE_ACCOUNT_ID) as string | undefined;
|
|
123
123
|
const r2sqlToken = r2sqlEnv.R2_SQL_TOKEN as string | undefined;
|
|
@@ -128,12 +128,12 @@ const LUNORA_FLAG_KEYS = ${x(e,'ReadonlyArray<{ key: string; type: "boolean" | "
|
|
|
128
128
|
? createR2Sql({ accountId: r2sqlAccountId, apiToken: r2sqlToken, bucket: r2sqlBucket })
|
|
129
129
|
: r2sqlStub;
|
|
130
130
|
`,configField:`
|
|
131
|
-
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:
|
|
131
|
+
r2sql?: (env: Record<string, unknown>) => R2SqlClient;`,importLines:['import type { R2SqlClient } from "@lunora/bindings/r2sql";','import { createR2Sql } from "@lunora/bindings/r2sql";'],stub:g("r2sqlStub: R2SqlClient","ctx.r2sql: no R2 SQL credentials found. Set `R2_SQL_TOKEN`, `R2_SQL_ACCOUNT_ID` (or `CLOUDFLARE_ACCOUNT_ID`), and `R2_SQL_BUCKET` in your env/.dev.vars, or pass an `r2sql` config thunk to createShardDO().",["describe","explain","from","query","showDatabases","showTables"],{sync:["from"]})}),N=()=>({build:`
|
|
132
132
|
const x402: X402Pay = config.x402
|
|
133
133
|
? lazyX402Pay(config.x402(env), { getSecret: (name: string) => secrets.get(name) })
|
|
134
134
|
: x402Stub;
|
|
135
135
|
`,configField:`
|
|
136
|
-
x402?: (env: Record<string, unknown>) => X402PayConfig;`,importLines:['import type { X402Pay, X402PayConfig } from "@lunora/x402/pay";','import { lazyX402Pay } from "@lunora/x402/pay";'],stub:
|
|
136
|
+
x402?: (env: Record<string, unknown>) => X402PayConfig;`,importLines:['import type { X402Pay, X402PayConfig } from "@lunora/x402/pay";','import { lazyX402Pay } from "@lunora/x402/pay";'],stub:g("x402Stub: X402Pay","ctx.x402: no pay rail configured. Pass `x402` to createShardDO().",["fetch"],{cast:" as unknown as X402Pay",sync:["fetch"]})}),S={access:k,ai:v,r2sql:R,x402:N},w=e=>e.shardBinding==="bespoke",L=e=>typeof e.shardBinding=="object",d=" ",A=(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`},C=(e,r,t)=>{const n=A(e,r,t),o=`${d}const ${e}Binding = config.${e}?.(env) ?? (env as Record<string, unknown>).${t.envName};
|
|
137
137
|
`,i=t.unvouchableReads??[];return i.length===0?`
|
|
138
138
|
${o}${d}const ${e}: ${r} = ${n};
|
|
139
139
|
`:`
|
|
@@ -144,20 +144,20 @@ ${d}const ${e}: ${r} = markUnvouchableReads(${n}, options.onRead, [
|
|
|
144
144
|
${i.map(u=>`${d} ${JSON.stringify(u)},`).join(`
|
|
145
145
|
`)}
|
|
146
146
|
${d}]);
|
|
147
|
-
`},
|
|
147
|
+
`},F=(e,r,t)=>{const{binding:n,clientType:o}=t,i=g(`${e}Stub: ${o}`,t.missingMessage,t.stubMethods,{sync:t.syncStubMethods});if(n===void 0){const l=t.instrument===void 0?`config.${e}(env)`:`this.${t.instrument}(config.${e}(env), logFunctionPath, traceAnchor, observability)`;return{build:`
|
|
148
148
|
${d}const ${e}: ${o} = config.${e} ? ${l} : ${e}Stub;
|
|
149
149
|
`,configField:`
|
|
150
|
-
${e}?: (env: Record<string, unknown>) => ${o};`,importLines:[`import type { ${o} } from "${r}";`],stub:i}}const u=n.bindingType??o,
|
|
151
|
-
${e}?: (env: Record<string, unknown>) => ${u};`,importLines:[`import type { ${
|
|
152
|
-
${
|
|
153
|
-
export class ${
|
|
150
|
+
${e}?: (env: Record<string, unknown>) => ${o};`,importLines:[`import type { ${o} } from "${r}";`],stub:i}}const u=n.bindingType??o,a=[...new Set([u,o])].toSorted((l,s)=>l.localeCompare(s));return{build:C(e,o,n),configField:`
|
|
151
|
+
${e}?: (env: Record<string, unknown>) => ${u};`,importLines:[`import type { ${a.join(", ")} } from "${r}";`,...n.factory===void 0?[]:[`import { ${n.factory.name} } from "${r}";`]],stub:i}},U=e=>{const r=[],t=[];let n="",o="",i="",u="",a="";for(const l of $.filter(({key:s})=>e.has(s))){let s;if(w(l))s=S[l.key]();else if(L(l))s=F(l.contextProperty,l.moduleSpecifier,l.shardBinding);else continue;const m=l.contextProperty;t.push(...s.importLines),o+=s.configField,a+=s.stub,l.tier==="every"?(i+=s.build,u+=`
|
|
152
|
+
${m},`):(n+=s.build,r.push(m))}return{actionBuild:n,actionFields:r,configFields:o,everyBuild:i,everyFields:u,importLines:t,stubs:a}},j=(e,r)=>{if(e.length===0)return"";const t=r?`, ${JSON.stringify(r)}`:"",n=e.map(s=>{c(s.exportName,`container export "${s.exportName}"`),c(s.className,`container class "${s.className}"`);const m=s.sandbox===!0?"LunoraSandboxContainer":"LunoraContainer";return`/** Container DO for the \`${s.exportName}\` definition (binding \`${s.bindingName}\`). */
|
|
153
|
+
export class ${s.className} extends ${m} {
|
|
154
154
|
public constructor(ctx: ConstructorParameters<typeof ${m}>[0], env: Record<string, unknown>) {
|
|
155
|
-
super(ctx, env, ${
|
|
155
|
+
super(ctx, env, ${s.exportName}, "${s.exportName}"${t});
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
`}).join(`
|
|
159
|
-
`),o=e.map(
|
|
160
|
-
`:"";return`${
|
|
159
|
+
`),o=e.map(s=>s.exportName).join(", "),i=e.some(s=>s.sandbox===!0),u=e.some(s=>s.sandbox!==!0)?`import { LunoraContainer } from "@lunora/container/do";
|
|
160
|
+
`:"";return`${p}/**
|
|
161
161
|
* Container-enabled Durable Object classes for the containers declared in
|
|
162
162
|
* \`lunora/containers.ts\`. Re-export them from your worker entry — wrangler
|
|
163
163
|
* requires each \`containers[].class_name\` to be exported by the worker:
|
|
@@ -181,7 +181,7 @@ ${i?`
|
|
|
181
181
|
*/
|
|
182
182
|
export { DirectoryBackupGateway, S3Gateway } from "@lunora/container/sandbox";
|
|
183
183
|
`:""}
|
|
184
|
-
${n}`},
|
|
184
|
+
${n}`},Q=(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(`
|
|
185
185
|
`);return{build:`
|
|
186
186
|
const containers = createContainerContext(env, LUNORA_CONTAINERS, ${r?JSON.stringify(r):"undefined"}, this.getCurrentTraceparent(), this.getCurrentSampleErrors());
|
|
187
187
|
`,contextField:`
|
|
@@ -190,14 +190,14 @@ ${n}`},j=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],
|
|
|
190
190
|
const LUNORA_CONTAINERS: ReadonlyArray<ContainerBindingSpec> = [
|
|
191
191
|
${t}
|
|
192
192
|
];
|
|
193
|
-
`}},
|
|
193
|
+
`}},M=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}\`. */
|
|
194
194
|
export class ${n.className} extends LunoraWorkflow<WorkflowParamsOf<typeof ${n.exportName}>, WorkflowOutputOf<typeof ${n.exportName}>> {
|
|
195
195
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
196
196
|
super(ctx, env, ${n.exportName}, "${n.exportName}");
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
`)).join(`
|
|
200
|
-
`),t=e.map(n=>n.exportName).join(", ");return`${
|
|
200
|
+
`),t=e.map(n=>n.exportName).join(", ");return`${p}/**
|
|
201
201
|
* WorkflowEntrypoint classes for the workflows declared in
|
|
202
202
|
* \`lunora/workflows.ts\`. Re-export them from your worker entry — wrangler
|
|
203
203
|
* requires each \`workflows[].class_name\` to be exported by the worker:
|
|
@@ -218,21 +218,21 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
|
|
|
218
218
|
/** Output type carried by a \`defineWorkflow\` definition (its phantom \`__output\`), so each entrypoint keeps the authored return type. */
|
|
219
219
|
type WorkflowOutputOf<Definition> = Definition extends { __output?: infer Output } ? Output : unknown;
|
|
220
220
|
|
|
221
|
-
${r}`},
|
|
222
|
-
export class ${
|
|
221
|
+
${r}`},K=e=>{if(e.length===0)return"";const t=e.filter(a=>a.voice).length>0,n=e.map(a=>{c(a.exportName,`agent export "${a.exportName}"`),c(a.className,`agent class "${a.className}"`);const l=`/** WorkflowEntrypoint for the \`${a.exportName}\` agent, reached as \`ctx.exports.${a.className}\`. */
|
|
222
|
+
export class ${a.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult> {
|
|
223
223
|
public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
|
|
224
|
-
super(ctx, env, compileAgentWorkflow(${
|
|
224
|
+
super(ctx, env, compileAgentWorkflow(${a.exportName}, "${a.exportName}"), "${a.exportName}");
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
`;if(!
|
|
228
|
-
/** Voice-session Durable Object for the \`${
|
|
229
|
-
export class ${
|
|
227
|
+
`;if(!a.voice)return l;const s=a.voiceClassName??"",m=a.voiceBindingName??"";c(s,`agent voice class "${s}"`);const x=`
|
|
228
|
+
/** Voice-session Durable Object for the \`${a.exportName}\` agent (binding \`${m}\`). */
|
|
229
|
+
export class ${s} extends VoiceSessionDO {
|
|
230
230
|
public constructor(ctx: ConstructorParameters<typeof VoiceSessionDO>[0], env: Record<string, unknown>) {
|
|
231
|
-
super(ctx, env, ${
|
|
231
|
+
super(ctx, env, ${a.exportName}, "${a.exportName}");
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
`;return`${l}${
|
|
235
|
-
`),o=e.map(
|
|
234
|
+
`;return`${l}${x}`}).join(`
|
|
235
|
+
`),o=e.map(a=>a.exportName).join(", ");return`${p}/**
|
|
236
236
|
* WorkflowEntrypoint classes for the agents declared in \`lunora/agents.ts\`.
|
|
237
237
|
* Each \`defineAgent\` compiles a replay-safe tool-loop onto a Cloudflare
|
|
238
238
|
* Workflow. Re-export them from your worker entry — wrangler requires each
|
|
@@ -246,8 +246,8 @@ import type { AgentRunInput, AgentRunResult } from "@lunora/agent";
|
|
|
246
246
|
|
|
247
247
|
import { ${o} } from "../agents.js";
|
|
248
248
|
|
|
249
|
-
${n}`},
|
|
250
|
-
`);return`${
|
|
249
|
+
${n}`},G=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(`
|
|
250
|
+
`);return`${p}/**
|
|
251
251
|
* Push-consumer registry for the queues declared in \`lunora/queues.ts\`. The
|
|
252
252
|
* composed worker's \`queue(batch, env, ctx)\` entry routes each delivered batch
|
|
253
253
|
* by \`batch.queue\` to the matching \`defineQueue\` handler. Wired automatically
|
|
@@ -261,7 +261,7 @@ import { ${t} } from "../queues.js";
|
|
|
261
261
|
export const LUNORA_QUEUE_REGISTRY: QueueRegistry = {
|
|
262
262
|
${n}
|
|
263
263
|
};
|
|
264
|
-
`},
|
|
264
|
+
`},H=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(`
|
|
265
265
|
`);return{build:`
|
|
266
266
|
const workflows = createWorkflowContext(env, LUNORA_WORKFLOWS, this.state.exports);
|
|
267
267
|
`,contextField:`
|
|
@@ -270,7 +270,7 @@ ${n}
|
|
|
270
270
|
const LUNORA_WORKFLOWS: ReadonlyArray<WorkflowBindingSpec> = [
|
|
271
271
|
${r}
|
|
272
272
|
];
|
|
273
|
-
`}},
|
|
273
|
+
`}},J=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(`
|
|
274
274
|
`);return{build:`
|
|
275
275
|
const queues = createQueueContext(env, LUNORA_QUEUES);
|
|
276
276
|
`,contextField:`
|
|
@@ -279,7 +279,7 @@ ${r}
|
|
|
279
279
|
const LUNORA_QUEUES: ReadonlyArray<QueueBindingSpec> = [
|
|
280
280
|
${r}
|
|
281
281
|
];
|
|
282
|
-
`}},
|
|
282
|
+
`}},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=b(r,n.exportName).map(i=>`{ binding: "${i.bindingName}", exportName: "${i.exportName}" }`).join(", ");return` { exportName: "${n.exportName}", subscriptions: [${o}] },`}).join(`
|
|
283
283
|
`);return{build:`
|
|
284
284
|
const topics = createTopicContext(env, LUNORA_TOPICS);
|
|
285
285
|
`,contextField:`
|
|
@@ -288,7 +288,7 @@ ${r}
|
|
|
288
288
|
const LUNORA_TOPICS: ReadonlyArray<TopicBindingSpec> = [
|
|
289
289
|
${t}
|
|
290
290
|
];
|
|
291
|
-
`}},
|
|
291
|
+
`}},Y=(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(`
|
|
292
292
|
`);return{build:`
|
|
293
293
|
const services = createServices(env, LUNORA_SERVICES);
|
|
294
294
|
`,importLines:[`import type { ServiceBindingSpec } from "${r}";`,`import { createServices } from "${r}";`],specs:`
|
|
@@ -296,7 +296,7 @@ ${t}
|
|
|
296
296
|
const LUNORA_SERVICES: ReadonlyArray<ServiceBindingSpec> = [
|
|
297
297
|
${t}
|
|
298
298
|
];
|
|
299
|
-
`}},
|
|
299
|
+
`}},X=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(`
|
|
300
300
|
`);return{build:`
|
|
301
301
|
const agents = createAgentContext(env, LUNORA_AGENTS, { exports: this.state.exports });
|
|
302
302
|
`,contextField:`
|
|
@@ -305,17 +305,17 @@ ${t}
|
|
|
305
305
|
const LUNORA_AGENTS: ReadonlyArray<AgentBindingSpec> = [
|
|
306
306
|
${r}
|
|
307
307
|
];
|
|
308
|
-
`}},
|
|
308
|
+
`}},h=(e,r,t,n,o)=>({constant:`
|
|
309
309
|
${o}
|
|
310
|
-
const ${e} = ${
|
|
310
|
+
const ${e} = ${y(n,r)};
|
|
311
311
|
`,override:`
|
|
312
312
|
protected override ${t}(): ${r} {
|
|
313
313
|
return ${e};
|
|
314
314
|
}
|
|
315
|
-
`}),
|
|
315
|
+
`}),z=e=>{if(e.length===0)return{constant:"",override:""};const r={workflows:e.map(t=>({className:t.className,exportName:t.exportName,name:t.name}))};return h("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 h("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. */")},ee=e=>e?{imports:['import type { LunoraDatabaseLike as LunoraPaymentDbLike, LunoraPayment, PaymentsFromContextOptions } from "@lunora/payment";','import { paymentsFromContext } from "@lunora/payment";'],build:`
|
|
316
316
|
const payments: LunoraPayment = config.payment
|
|
317
317
|
? paymentsFromContext({ auth: { userId: userId ?? null }, db: db as unknown as LunoraPaymentDbLike }, config.payment(env))
|
|
318
318
|
: paymentStub;
|
|
319
319
|
`,configField:`
|
|
320
320
|
payment?: (env: Record<string, unknown>) => PaymentsFromContextOptions;`,contextField:`
|
|
321
|
-
payments,`,stub:
|
|
321
|
+
payments,`,stub:g("paymentStub: LunoraPayment","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:""},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{T as a,D as b,B as c,J as d,U as e,V as f,Y as g,Q as h,H as i,X as j,ee as k,z as l,Z as m,I as n,te as o,W as p,q,g as r,K as s,j as t,M as u,G as v};
|
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.255",
|
|
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.
|
|
51
|
-
"@lunora/container": "1.0.0-alpha.
|
|
49
|
+
"@lunora/advisor": "1.0.0-alpha.185",
|
|
50
|
+
"@lunora/agent": "1.0.0-alpha.168",
|
|
51
|
+
"@lunora/container": "1.0.0-alpha.69",
|
|
52
52
|
"@lunora/errors": "1.0.0-alpha.50",
|
|
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.54",
|
|
54
|
+
"@lunora/queue": "1.0.0-alpha.90",
|
|
55
|
+
"@lunora/scheduler": "1.0.0-alpha.108",
|
|
56
56
|
"@lunora/values": "1.0.0-alpha.60",
|
|
57
57
|
"@lunora/workflow": "1.0.0-alpha.71",
|
|
58
58
|
"jiti": "^2.7.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{SyntaxKind as c,Node as f}from"ts-morph";import{CAPABILITIES as d}from"./CAPABILITY_PROBES-BPeV994T.mjs";import{bindingKeyName as m,listLunoraSourceFiles as p}from"./listLunoraSourceFiles-CSlcBYlo.mjs";const l="ctx",g=t=>{const n=new Set,i=new Set([l]),r=e=>{if(f.isObjectBindingPattern(e))for(const s of e.getElements()){const o=m(s);o&&n.add(o)}};for(const e of t.getDescendantsOfKind(c.BindingElement)){if(m(e)!==l)continue;const s=e.getNameNode();f.isIdentifier(s)?i.add(s.getText()):r(s)}const a=e=>f.isIdentifier(e)&&i.has(e.getText());for(const e of t.getDescendantsOfKind(c.PropertyAccessExpression))a(e.getExpression())&&n.add(e.getName());for(const e of t.getDescendantsOfKind(c.VariableDeclaration)){const s=e.getInitializer();s!==void 0&&a(s)&&r(e.getNameNode())}return n},u=t=>{if(t.isTypeOnly())return!0;const n=t.getNamedImports();return t.getDefaultImport()===void 0&&t.getNamespaceImport()===void 0&&n.length>0&&n.every(i=>i.isTypeOnly())},y=t=>({contextReads:g(t),valueImports:new Set(t.getImportDeclarations().filter(n=>!u(n)).map(n=>n.getModuleSpecifierValue()))}),P=(t,n)=>{const i=Object.fromEntries(d.map(r=>[r.key,!1]));for(const r of p(n)){const a=t.getSourceFile(r)??t.addSourceFileAtPath(r),{contextReads:e,valueImports:s}=y(a);for(const o of d)if(!i[o.key]){if(s.has(o.moduleSpecifier)){i[o.key]=!0;continue}o.contextProperty!==void 0&&e.has(o.contextProperty)&&(i[o.key]=!0)}if(d.every(o=>i[o.key]))break}return i};export{g as contextPropertiesRead,P as discoverFeatureUsage,y as sourceCapabilitySignals};
|