@lunora/codegen 1.0.0-alpha.273 → 1.0.0-alpha.275

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.
Files changed (71) hide show
  1. package/dist/index.d.mts +79 -12
  2. package/dist/index.d.ts +79 -12
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AGENTS_FILENAME-lBe4g_sU.mjs → AGENTS_FILENAME-NQIB6wh3.mjs} +1 -1
  5. package/dist/packem_shared/{CONTAINERS_FILENAME-CY43AXXN.mjs → CONTAINERS_FILENAME-CK3xJGwm.mjs} +1 -1
  6. package/dist/packem_shared/{FLAGS_FILENAME-DXltN9DD.mjs → FLAGS_FILENAME-DYMd1xqw.mjs} +1 -1
  7. package/dist/packem_shared/GENERATED_HEADER-D-P7ii4H.mjs +1 -0
  8. package/dist/packem_shared/{MUTATORS_FILENAME-BxRrG_s-.mjs → MUTATORS_FILENAME-BrEGrcPU.mjs} +1 -1
  9. package/dist/packem_shared/{NOTIFY_FILENAME-J5MGAkca.mjs → NOTIFY_FILENAME-B42rW2NJ.mjs} +1 -1
  10. package/dist/packem_shared/{OPENRPC_VERSION-B8RT1JYn.mjs → OPENRPC_VERSION-BaD2A2YR.mjs} +1 -1
  11. package/dist/packem_shared/{QUEUES_FILENAME-DeJw5eqU.mjs → QUEUES_FILENAME-Dj5yK34Z.mjs} +1 -1
  12. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DWriXOYw.mjs +11 -0
  13. package/dist/packem_shared/{SHAPES_FILENAME-CeBFuc8M.mjs → SHAPES_FILENAME-CVc2VCnS.mjs} +1 -1
  14. package/dist/packem_shared/{WORKFLOWS_FILENAME-B47AB5pc.mjs → WORKFLOWS_FILENAME-Ze98LsB3.mjs} +1 -1
  15. package/dist/packem_shared/{attribution-NRssTEkk.mjs → attribution-Dw35rOaJ.mjs} +1 -1
  16. package/dist/packem_shared/{buildOpenApiDocument-6VJGU6fU.mjs → buildOpenApiDocument-BjHdW7b2.mjs} +1 -1
  17. package/dist/packem_shared/{capabilitiesUsedBy-DARbl-4Z.mjs → capabilitiesUsedBy-FnnYmnSl.mjs} +1 -1
  18. package/dist/packem_shared/chain-nWiSr1yy.mjs +1 -0
  19. package/dist/packem_shared/{classify-procedure-call-BBKuBvKg.mjs → classify-procedure-call-DxuPQkJA.mjs} +1 -1
  20. package/dist/packem_shared/{context-property-calls-tlnXE-wv.mjs → context-property-calls-BLTVj9HH.mjs} +1 -1
  21. package/dist/packem_shared/{context-root-IuI71QkK.mjs → context-root-B04bYCE-.mjs} +1 -1
  22. package/dist/packem_shared/{database-calls-BFY_pIUf.mjs → database-calls-DWDtdDbS.mjs} +1 -1
  23. package/dist/packem_shared/{discoverAuthApiCalls-TA2a8bZI.mjs → discoverAuthApiCalls-XK_WCMDG.mjs} +1 -1
  24. package/dist/packem_shared/discoverCrons-B5bVCaNF.mjs +1 -0
  25. package/dist/packem_shared/{discoverFunctions-4sef11AC.mjs → discoverFunctions-Be-XuuSW.mjs} +1 -1
  26. package/dist/packem_shared/{discoverHttpRoutes-CLGXL19M.mjs → discoverHttpRoutes-CMOxt2Y9.mjs} +1 -1
  27. package/dist/packem_shared/discoverHyperdriveCalls-mrho5AnY.mjs +1 -0
  28. package/dist/packem_shared/{discoverInserts-CKEO1mZZ.mjs → discoverInserts-BhIpUWXN.mjs} +1 -1
  29. package/dist/packem_shared/discoverMaskProcedures-DCw165tP.mjs +1 -0
  30. package/dist/packem_shared/{discoverMigrations-DYQbnqow.mjs → discoverMigrations-dVVZtuJa.mjs} +1 -1
  31. package/dist/packem_shared/{discoverNondeterministicCalls-BfdM93-8.mjs → discoverNondeterministicCalls-Dtb1aoGV.mjs} +1 -1
  32. package/dist/packem_shared/{discoverQueries-DEkIMaBP.mjs → discoverQueries-BSOjEsk3.mjs} +1 -1
  33. package/dist/packem_shared/discoverR2sqlCalls-KONCqZr2.mjs +1 -0
  34. package/dist/packem_shared/{discoverRlsMetadata-rpiO4wSi.mjs → discoverRlsMetadata-9YDlDDoh.mjs} +1 -1
  35. package/dist/packem_shared/{discoverRlsProcedures-BtT8-r93.mjs → discoverRlsProcedures-c0DnIR4z.mjs} +1 -1
  36. package/dist/packem_shared/{discoverSandboxUsage-B8P9QjWZ.mjs → discoverSandboxUsage-CfEU2hM-.mjs} +1 -1
  37. package/dist/packem_shared/{discoverSchema-BdmC-kO2.mjs → discoverSchema-BTFFWy3i.mjs} +1 -1
  38. package/dist/packem_shared/{discoverStorageRulesMetadata-C2hYksmI.mjs → discoverStorageRulesMetadata-f89BWody.mjs} +1 -1
  39. package/dist/packem_shared/{emitAgents-CzxW-qj5.mjs → emitAgents-CG2R-Zz6.mjs} +1 -1
  40. package/dist/packem_shared/{emitApi-xDIHPRPH.mjs → emitApi-zY6egN77.mjs} +44 -63
  41. package/dist/packem_shared/{emitApp-BdVXkH7A.mjs → emitApp-DUGS6Ve2.mjs} +1 -1
  42. package/dist/packem_shared/{emitCrons-DKeoaeqU.mjs → emitCrons-B8TBAOZ4.mjs} +1 -1
  43. package/dist/packem_shared/{emitDataModel-DSk9AkJe.mjs → emitDataModel-B68T_eX6.mjs} +5 -5
  44. package/dist/packem_shared/{emitDrizzleSchema-DohtnI8c.mjs → emitDrizzleSchema-DLtfKTI4.mjs} +2 -2
  45. package/dist/packem_shared/{emitFunctions-evl8Mx1a.mjs → emitFunctions-DkkcTDqh.mjs} +39 -47
  46. package/dist/packem_shared/emitServer-BbjIwe2-.mjs +1 -0
  47. package/dist/packem_shared/{emitShard-tQej36w1.mjs → emitShard-CSLqD-Hr.mjs} +1 -1
  48. package/dist/packem_shared/{exported-procedure-chains-DqU-ZCbG.mjs → exported-procedure-chains-C5VKkd9T.mjs} +1 -1
  49. package/dist/packem_shared/{fingerprintSchemaSources-ChYfrghz.mjs → fingerprintSchemaSources-BJSIxwhY.mjs} +1 -1
  50. package/dist/packem_shared/{handler-reference-B3coD2YR.mjs → handler-reference-2Hs4WKnz.mjs} +1 -1
  51. package/dist/packem_shared/{index-CRO3TRxd.mjs → index-CefI-Sba.mjs} +1 -1
  52. package/dist/packem_shared/isTestPath-CgyyLk8U.mjs +1 -0
  53. package/dist/packem_shared/{modules-6EEBTEDo.mjs → modules-BIpFLz3Z.mjs} +1 -1
  54. package/dist/packem_shared/paths-DwTjD7BU.mjs +1 -0
  55. package/dist/packem_shared/{qualifiers-Cw8dEDbh.mjs → qualifiers-COHdrghK.mjs} +1 -1
  56. package/dist/packem_shared/{emitServer-BSMUAt0o.mjs → server-BmY5wwKY.mjs} +56 -56
  57. package/dist/packem_shared/{shard-C1ZGdOG1.mjs → shard-Dr5gMNyz.mjs} +1 -1
  58. package/dist/packem_shared/{shard-runtime-DGrBvQWg.mjs → shard-runtime-BI2SZ54Z.mjs} +1 -1
  59. package/dist/packem_shared/shared-Be3TGzxM.mjs +13 -0
  60. package/dist/packem_shared/{unwrap-handler-return-Dy8h5-I6.mjs → unwrap-handler-return-T5sJhEss.mjs} +1 -1
  61. package/package.json +4 -4
  62. package/dist/packem_shared/GENERATED_HEADER-dFyrHgQ0.mjs +0 -1
  63. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DHYzuzTc.mjs +0 -11
  64. package/dist/packem_shared/chain-6qc9c0JF.mjs +0 -1
  65. package/dist/packem_shared/discoverCrons-PQeDYVPc.mjs +0 -1
  66. package/dist/packem_shared/discoverHyperdriveCalls-imtma-ic.mjs +0 -1
  67. package/dist/packem_shared/discoverMaskProcedures-Cr6hDinL.mjs +0 -1
  68. package/dist/packem_shared/discoverR2sqlCalls-BRIyb8Cl.mjs +0 -1
  69. package/dist/packem_shared/isTestPath-DCyIyPa7.mjs +0 -1
  70. package/dist/packem_shared/paths-C-9fwEgQ.mjs +0 -1
  71. package/dist/packem_shared/shared-BXUKWh7t.mjs +0 -9
@@ -1,30 +1,30 @@
1
- import{LunoraError as B}from"@lunora/errors";import{L as H,G as q,I as J,d as Q,r as G,b as z,c as x}from"./shared-BXUKWh7t.mjs";import{s as p}from"./paths-C-9fwEgQ.mjs";import{renderAgentFunctionRegistry as V,renderSandboxFunctionRegistry as W,groupByFileSorted as K}from"./emitApi-xDIHPRPH.mjs";import{r as Y,a as X,b as O,c as Z}from"./qualifiers-Cw8dEDbh.mjs";const ee=new Set(["any","bigint","boolean","date","id","null","number","storage","string","timestamp"]),A=n=>n.column!==void 0,te=(n,e)=>{switch(n){case"bigint":return`if (typeof ${e} !== "bigint") return DEFER;
1
+ import{LunoraError as B}from"@lunora/errors";import{L as H,G as q,I as J,d as Q,b as S,r as G,c as z}from"./shared-Be3TGzxM.mjs";import{s as g}from"./paths-DwTjD7BU.mjs";import{renderAgentFunctionRegistry as V,renderSandboxFunctionRegistry as W}from"./emitApi-zY6egN77.mjs";import{a as K,b as Y,r as O,c as X}from"./qualifiers-COHdrghK.mjs";const Z=new Set(["any","bigint","boolean","date","id","null","number","storage","string","timestamp"]),A=n=>n.column!==void 0,ee=(n,e)=>{switch(n){case"bigint":return`if (typeof ${e} !== "bigint") return DEFER;
2
2
  `;case"boolean":return`if (typeof ${e} !== "boolean") return DEFER;
3
3
  `;case"date":case"number":case"timestamp":return`if (typeof ${e} !== "number" || !Number.isFinite(${e})) return DEFER;
4
4
  `;case"null":return`if (${e} !== null) return DEFER;
5
5
  `;default:return`if (typeof ${e} !== "string") return DEFER;
6
- `}},ne=(n,e)=>n.stringMaxLength===void 0?"":`if (${e}.length > ${String(n.stringMaxLength)}) return DEFER;
7
- `,re=(n,e)=>{const r=n.literalValue?.trim();if(!(r===void 0||!H.test(r)))return{out:e,pre:`if (${e} !== ${r}) return DEFER;
8
- `}},v=(n,e,r)=>{if(!A(n)&&!(n.unmodelledRefinement||n.sourceText!==void 0)){if(ee.has(n.kind))return n.kind==="any"?{out:e,pre:""}:{out:e,pre:te(n.kind,e)+ne(n,e)};switch(n.kind){case"array":return oe(n,e,r);case"literal":return re(n,e);case"object":return ie(n,e,r);default:return}}},oe=(n,e,r)=>{const{inner:c}=n;if(!c)return;const o=r.next(),a=`__arr${String(o)}`,i=`__i${String(o)}`,s=`__e${String(o)}`,l=v(c,s,r);if(!l)return;const u=`if (!Array.isArray(${e})) return DEFER;
9
- const ${a} = new Array(${e}.length);
6
+ `}},te=(n,e)=>n.stringMaxLength===void 0?"":`if (${e}.length > ${String(n.stringMaxLength)}) return DEFER;
7
+ `,ne=(n,e)=>{const r=n.literalValue?.trim();if(!(r===void 0||!H.test(r)))return{out:e,pre:`if (${e} !== ${r}) return DEFER;
8
+ `}},v=(n,e,r)=>{if(!A(n)&&!(n.unmodelledRefinement||n.sourceText!==void 0)){if(Z.has(n.kind))return n.kind==="any"?{out:e,pre:""}:{out:e,pre:ee(n.kind,e)+te(n,e)};switch(n.kind){case"array":return re(n,e,r);case"literal":return ne(n,e);case"object":return se(n,e,r);default:return}}},re=(n,e,r)=>{const{inner:o}=n;if(!o)return;const a=r.next(),s=`__arr${String(a)}`,i=`__i${String(a)}`,c=`__e${String(a)}`,l=v(o,c,r);if(!l)return;const u=`if (!Array.isArray(${e})) return DEFER;
9
+ const ${s} = new Array(${e}.length);
10
10
  for (let ${i} = 0; ${i} < ${e}.length; ${i}++) {
11
- const ${s} = ${e}[${i}];
12
- ${l.pre}${a}[${i}] = ${l.out};
11
+ const ${c} = ${e}[${i}];
12
+ ${l.pre}${s}[${i}] = ${l.out};
13
13
  }
14
- `;return{out:a,pre:u}},ae=(n,e,r,c)=>{const o=JSON.stringify(n);if(e.kind==="optional"){if(e.hasRefinement||e.sourceText!==void 0||A(e))return;const{inner:i}=e;if(!i)return;const s=v(i,r,c);if(!s)return;const l=c.next(),u=`__has${String(l)}`,d=`__val${String(l)}`,f=`let ${u} = false;
14
+ `;return{out:s,pre:u}},oe=(n,e,r,o)=>{const a=JSON.stringify(n);if(e.kind==="optional"){if(e.hasRefinement||e.sourceText!==void 0||A(e))return;const{inner:i}=e;if(!i)return;const c=v(i,r,o);if(!c)return;const l=o.next(),u=`__has${String(l)}`,d=`__val${String(l)}`,f=`let ${u} = false;
15
15
  let ${d};
16
16
  if (${r} !== undefined) {
17
- ${s.pre}${d} = ${s.out};
17
+ ${c.pre}${d} = ${c.out};
18
18
  ${u} = true;
19
19
  }
20
- `;return{entry:`...(${u} ? { ${o}: ${d} } : {})`,pre:f}}const a=v(e,r,c);if(a)return{entry:`${o}: ${a.out}`,pre:a.pre}},se=new Set(Object.getOwnPropertyNames(Object.prototype)),_=(n,e,r)=>{let c="";const o=[];for(const a of Object.keys(n)){const i=n[a];if(!i)return;const s=JSON.stringify(a);let l=`${e}[${s}]`;if(se.has(a)){const d=`__f${String(r.next())}`;c+=`const ${d} = Object.hasOwn(${e}, ${s}) ? ${e}[${s}] : undefined;
21
- `,l=d}const u=ae(a,i,l,r);if(!u)return;c+=u.pre,o.push(u.entry)}return{entries:o.join(", "),pre:c}},T=n=>{const e=`Object.getPrototypeOf(${n})`;return`if (${e} !== Object.prototype && ${e} !== null) return DEFER;
22
- `},ie=(n,e,r)=>{const c=n.shape??{},o=_(c,e,r);if(!o)return;const a=r.next(),i=`__obj${String(a)}`,s=`if (typeof ${e} !== "object" || ${e} === null || Array.isArray(${e})) return DEFER;
23
- ${T(e)}${o.pre}const ${i} = { ${o.entries} };
24
- `;return{out:i,pre:s}},ce=n=>{let e=0;const c=_(n,"source",{next:()=>(e+=1,e)});if(c)return`(source) => {
20
+ `;return{entry:`...(${u} ? { ${a}: ${d} } : {})`,pre:f}}const s=v(e,r,o);if(s)return{entry:`${a}: ${s.out}`,pre:s.pre}},ae=new Set(Object.getOwnPropertyNames(Object.prototype)),_=(n,e,r)=>{let o="";const a=[];for(const s of Object.keys(n)){const i=n[s];if(!i)return;const c=JSON.stringify(s);let l=`${e}[${c}]`;if(ae.has(s)){const d=`__f${String(r.next())}`;o+=`const ${d} = Object.hasOwn(${e}, ${c}) ? ${e}[${c}] : undefined;
21
+ `,l=d}const u=oe(s,i,l,r);if(!u)return;o+=u.pre,a.push(u.entry)}return{entries:a.join(", "),pre:o}},T=n=>{const e=`Object.getPrototypeOf(${n})`;return`if (${e} !== Object.prototype && ${e} !== null) return DEFER;
22
+ `},se=(n,e,r)=>{const o=n.shape??{},a=_(o,e,r);if(!a)return;const s=r.next(),i=`__obj${String(s)}`,c=`if (typeof ${e} !== "object" || ${e} === null || Array.isArray(${e})) return DEFER;
23
+ ${T(e)}${a.pre}const ${i} = { ${a.entries} };
24
+ `;return{out:i,pre:c}},ie=n=>{let e=0;const o=_(n,"source",{next:()=>(e+=1,e)});if(o)return`(source) => {
25
25
  if (typeof source !== "object" || source === null || Array.isArray(source)) return DEFER;
26
- ${T("source")}${c.pre}return { ${c.entries} };
27
- }`},le=(n,e)=>`lunora_${p(n)}_${String(e)}`,ue=`const callRegistered = async <R>(context: CallerCtx, functionPath: string, args: Record<string, unknown> | undefined): Promise<R> => {
26
+ ${T("source")}${o.pre}return { ${o.entries} };
27
+ }`},ce=(n,e)=>`lunora_${g(n)}_${String(e)}`,le=`const callRegistered = async <R>(context: CallerCtx, functionPath: string, args: Record<string, unknown> | undefined): Promise<R> => {
28
28
  const registered = LUNORA_FUNCTIONS[functionPath];
29
29
 
30
30
  if (!registered) {
@@ -57,66 +57,58 @@ ${T("source")}${c.pre}return { ${c.entries} };
57
57
  }
58
58
 
59
59
  return (await registered.handler(context, args ?? {})) as R;
60
- };`,de=(n,e,r=[],c=[])=>{const o=new Map,a=t=>{o.has(t)||o.set(t,le(t,o.size))};for(const t of n)a(t.filePath);for(const t of e)a(t.filePath);for(const t of r)a(t.filePath);for(const t of c)a(t.filePath);const i=[...o.entries()].map(([t,g])=>{if(!J.test(t))throw new B("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(t)}`);return`import * as ${g} from "../${t}.js";`}).join(`
61
- `),s=n.map(t=>` "${p(t.filePath)}:${t.exportName}": ${o.get(t.filePath)??""}.${t.exportName} as unknown as RegisteredLunoraFunction,`).join(`
62
- `),l=e.map(t=>` ${JSON.stringify(t.id)}: ${o.get(t.filePath)??""}.${t.exportName} as unknown as RegisteredDataMigration,`).join(`
63
- `),u=r.map(t=>` "${p(t.filePath)}:${t.exportName}": ${o.get(t.filePath)??""}.${t.exportName} as unknown as RegisteredLunoraFunction,`).join(`
64
- `),d=c.map(t=>` "${t.exportName}": ${o.get(t.filePath)??""}.${t.exportName} as unknown as RegisteredShape,`).join(`
65
- `),f=r.map(t=>`${p(t.filePath)}:${t.exportName}`),m=[s,u].filter(t=>t.length>0).join(`
66
- `),R=n.map(t=>{if(t.lifecycle||Object.keys(t.args).length===0)return;const g=ce(t.args);return g===void 0?void 0:`installCompiledValidatorMap(${o.get(t.filePath)??""}.${t.exportName}.args, ${g});`}).filter(t=>t!==void 0).join(`
67
- `);return{dispatchBody:m.length>0?`
68
- ${m}
60
+ };`,ue=(n,e,r=[],o=[])=>{const a=new Map,s=t=>{a.has(t)||a.set(t,ce(t,a.size))};for(const t of n)s(t.filePath);for(const t of e)s(t.filePath);for(const t of r)s(t.filePath);for(const t of o)s(t.filePath);const i=[...a.entries()].map(([t,m])=>{if(!J.test(t))throw new B("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(t)}`);return`import * as ${m} from "../${t}.js";`}).join(`
61
+ `),c=n.map(t=>` "${g(t.filePath)}:${t.exportName}": ${a.get(t.filePath)??""}.${t.exportName} as unknown as RegisteredLunoraFunction,`).join(`
62
+ `),l=e.map(t=>` ${JSON.stringify(t.id)}: ${a.get(t.filePath)??""}.${t.exportName} as unknown as RegisteredDataMigration,`).join(`
63
+ `),u=r.map(t=>` "${g(t.filePath)}:${t.exportName}": ${a.get(t.filePath)??""}.${t.exportName} as unknown as RegisteredLunoraFunction,`).join(`
64
+ `),d=o.map(t=>` "${t.exportName}": ${a.get(t.filePath)??""}.${t.exportName} as unknown as RegisteredShape,`).join(`
65
+ `),f=r.map(t=>`${g(t.filePath)}:${t.exportName}`),p=[c,u].filter(t=>t.length>0).join(`
66
+ `),R=n.map(t=>{if(t.lifecycle||Object.keys(t.args).length===0)return;const m=ie(t.args);return m===void 0?void 0:`installCompiledValidatorMap(${a.get(t.filePath)??""}.${t.exportName}.args, ${m});`}).filter(t=>t!==void 0).join(`
67
+ `);return{dispatchBody:p.length>0?`
68
+ ${p}
69
69
  `:"",importBlock:i.length>0?`${i}
70
70
 
71
71
  `:"",installBlock:R,migrationBody:l.length>0?`
72
72
  ${l}
73
73
  `:"",mutatorPaths:f,shapeBody:d.length>0?`
74
74
  ${d}
75
- `:""}},he=n=>{const e=K(n),r=e.map(([o,a])=>{const i=a.map(s=>{const l=O(G(s.args),s.filePath),u=l==="{}"?"?":"",d=O(Z(s),s.filePath);return s.kind==="stream"?` ${s.exportName}: (args${u}: ${l}) => Promise<AsyncIterable<${d}>>;`:` ${s.exportName}: (args${u}: ${l}) => Promise<${d}>;`}).join(`
76
- `);return` ${z(p(o))}: {
77
- ${i}
78
- };`}).join(`
79
- `);return{implementation:e.map(([o,a])=>{const i=p(o),s=a.map(l=>` ${x(l.exportName)}: (args) => callRegistered(context, "${i}:${l.exportName}", args),`).join(`
80
- `);return` ${x(i)}: {
81
- ${s}
82
- },`}).join(`
83
- `),types:r}},pe=n=>{const e={connect:[],disconnect:[],init:[],reactor:[],whisper:[]};for(const r of n)r.lifecycle&&e[r.lifecycle].push(`${p(r.filePath)}:${r.exportName}`);return e},be=n=>{const{agents:e=[],functions:r,migrations:c=[],mutators:o=[],shapes:a=[],useUmbrella:i=!1,usesSandbox:s=!1}=n,l=r.length>0,u=Q(i),{dispatchBody:d,importBlock:f,installBlock:m,migrationBody:R,mutatorPaths:t,shapeBody:g}=de(r,c,o,a),b=V(e,r),w=W(s,r),k=[b.lines,w.lines].filter(h=>h.length>0).join(`
75
+ `:""}},de=n=>{const e=S(n,o=>{const a=O(G(o.args),o.filePath),s=a==="{}"?"?":"",i=O(X(o),o.filePath);return o.kind==="stream"?`${o.exportName}: (args${s}: ${a}) => Promise<AsyncIterable<${i}>>;`:`${o.exportName}: (args${s}: ${a}) => Promise<${i}>;`},"type");return{implementation:S(n,o=>`${z(o.exportName)}: (args) => callRegistered(context, "${g(o.filePath)}:${o.exportName}", args),`,"value"),types:e}},he=n=>{const e={connect:[],disconnect:[],init:[],reactor:[],whisper:[]};for(const r of n)r.lifecycle&&e[r.lifecycle].push(`${g(r.filePath)}:${r.exportName}`);return e},$e=n=>{const{agents:e=[],functions:r,migrations:o=[],mutators:a=[],shapes:s=[],useUmbrella:i=!1,usesSandbox:c=!1}=n,l=r.length>0,u=Q(i),{dispatchBody:d,importBlock:f,installBlock:p,migrationBody:R,mutatorPaths:t,shapeBody:m}=ue(r,o,a,s),b=V(e,r),w=W(c,r),k=[b.lines,w.lines].filter(h=>h.length>0).join(`
84
76
  `);let N=d;k.length>0&&(N=d.length>0?`${d.trimEnd()}
85
77
  ${k}
86
78
  `:`
87
79
  ${k}
88
- `);const y=pe(r),P=a.length>0?`import type { RegisteredShape } from "${u.server}";
89
- `:"",L=a.length>0?`
80
+ `);const y=he(r),P=s.length>0?`import type { RegisteredShape } from "${u.server}";
81
+ `:"",L=s.length>0?`
90
82
  /**
91
83
  * Replication-shape registry — one entry per \`defineShape\` in \`lunora/shapes.ts\`.
92
84
  * The generated ShardDO's \`resolveShape\` override looks a shape up by name and
93
85
  * evaluates its trusted \`compileWhere(ctx, args)\` to authorize + scope a
94
86
  * \`shape_subscribe\` (reads-as-permissions).
95
87
  */
96
- export const LUNORA_SHAPES: Record<string, RegisteredShape> = {${g}};
97
- `:"",j=t.length>0?`
88
+ export const LUNORA_SHAPES: Record<string, RegisteredShape> = {${m}};
89
+ `:"",E=t.length>0?`
98
90
  /**
99
91
  * Custom-mutator function paths — the \`LUNORA_FUNCTIONS\` keys the generated
100
92
  * ShardDO's \`isCustomMutator\` override routes through the client-watermark push
101
93
  * protocol (\`x-lunora-client-id\`/\`x-lunora-client-seq\` ordering).
102
94
  */
103
95
  export const LUNORA_MUTATOR_PATHS: ReadonlySet<string> = new Set([${t.map(h=>JSON.stringify(h)).join(", ")}]);
104
- `:"",E=m.length>0?`import { DEFER_VALIDATION as DEFER, installCompiledValidatorMap } from "${u.values}";
105
- `:"",C=m.length>0?`
96
+ `:"",C=p.length>0?`import { DEFER_VALIDATION as DEFER, installCompiledValidatorMap } from "${u.values}";
97
+ `:"",j=p.length>0?`
106
98
  /**
107
99
  * AOT-compiled argument validators (Worker-safe, no \`eval\`). Each is installed
108
100
  * onto its function's live \`.args\` object and consulted by the interpreted
109
101
  * parser as a zero-allocation fast path; anything it can't model is deferred.
110
102
  */
111
- ${m}
112
- `:"",$=he(r),F=$.types?`
103
+ ${p}
104
+ `:"",$=de(r),F=$.types?`
113
105
  ${$.types}
114
106
  `:"",M=$.implementation?`
115
107
  ${$.implementation}
116
- `:"",S=Y($.types),D=S.length>0?`import type { ${S.join(", ")} } from "./dataModel.js";
117
- `:"",I=l?"context":"_context",U=l?`${ue}
108
+ `:"",x=K($.types),D=x.length>0?`import type { ${x.join(", ")} } from "./dataModel.js";
109
+ `:"",I=l?"context":"_context",U=l?`${le}
118
110
 
119
- `:"";return X(`${q}${f}${b.importLine}${w.importLine}${E}${P}import { LunoraError } from "${u.server}";
111
+ `:"";return Y(`${q}${f}${b.importLine}${w.importLine}${C}${P}import { LunoraError } from "${u.server}";
120
112
  import type { ActionCtx, MutationCtx, QueryCtx } from "./server.js";
121
113
  ${D}
122
114
  /**
@@ -170,7 +162,7 @@ ${b.prelude}${w.prelude}
170
162
  * emits (\`api[namespace][fn].__lunoraRef === "namespace:fn"\`).
171
163
  */
172
164
  export const LUNORA_FUNCTIONS: Record<string, RegisteredLunoraFunction> = {${N}};
173
- ${C}${L}${j}
165
+ ${j}${L}${E}
174
166
  /**
175
167
  * Lifecycle manifest: the function paths the generated ShardDO dispatches when a
176
168
  * client's WebSocket connects (\`connect\`) or disconnects (\`disconnect\`), once
@@ -246,4 +238,4 @@ export interface RegisteredDataMigration {
246
238
  * shard DO's admin RPC and the CLI resolve migrations to run through this map.
247
239
  */
248
240
  export const LUNORA_MIGRATIONS: Record<string, RegisteredDataMigration> = {${R}};
249
- `,i)};export{be as default};
241
+ `,i)};export{$e as default};
@@ -0,0 +1 @@
1
+ import"./CAPABILITY_PROBES-brcmKenl.mjs";import"./ir-DBSvhNa-.mjs";import{e}from"./server-BmY5wwKY.mjs";import"./shared-Be3TGzxM.mjs";export{e 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-C1ZGdOG1.mjs";import"./shard-runtime-DGrBvQWg.mjs";import"./shared-BXUKWh7t.mjs";export{f as default};
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-Dr5gMNyz.mjs";import"./shard-runtime-BI2SZ54Z.mjs";import"./shared-Be3TGzxM.mjs";export{f as default};
@@ -1 +1 @@
1
- import{Node as s}from"ts-morph";import{b as t,d as c}from"./attribution-NRssTEkk.mjs";import{c as n}from"./classify-procedure-call-BBKuBvKg.mjs";const m=a=>{const i=[];for(const e of t(a)){const r=e.getInitializer(),o=r&&s.isCallExpression(r)?n(r):void 0;o?.receiver&&i.push({name:c(e)??e.getName(),receiver:o.receiver})}return i};export{m as e};
1
+ import{Node as s}from"ts-morph";import{b as t,d as c}from"./attribution-Dw35rOaJ.mjs";import{c as n}from"./classify-procedure-call-DxuPQkJA.mjs";const m=a=>{const i=[];for(const e of t(a)){const r=e.getInitializer(),o=r&&s.isCallExpression(r)?n(r):void 0;o?.receiver&&i.push({name:c(e)??e.getName(),receiver:o.receiver})}return i};export{m as e};
@@ -1 +1 @@
1
- import{createHash as i}from"node:crypto";import{existsSync as s,readFileSync as c}from"node:fs";import{join as u}from"node:path";import{listLunoraSourceFiles as h}from"./isTestPath-DCyIyPa7.mjs";const S=t=>{if(!s(t))return"unreadable";const e=h(t,{includeSkipped:!0}),o=u(t,"schema.ts");s(o)&&e.push(o);const r=i("sha256");for(const a of e.toSorted((n,p)=>n.localeCompare(p)))try{r.update(a).update("\0").update(c(a))}catch{}return r.digest("hex")};export{S as default};
1
+ import{createHash as i}from"node:crypto";import{existsSync as s,readFileSync as c}from"node:fs";import{join as u}from"node:path";import{listLunoraSourceFiles as h}from"./isTestPath-CgyyLk8U.mjs";const S=t=>{if(!s(t))return"unreadable";const e=h(t,{includeSkipped:!0}),o=u(t,"schema.ts");s(o)&&e.push(o);const r=i("sha256");for(const a of e.toSorted((n,p)=>n.localeCompare(p)))try{r.update(a).update("\0").update(c(a))}catch{}return r.digest("hex")};export{S as default};
@@ -1 +1 @@
1
- import{dirname as F}from"node:path";import{Node as e}from"ts-morph";import{unwrapExpression as m,lunoraRelativePath as u}from"./isTestPath-DCyIyPa7.mjs";import{r as v,d as b}from"./attribution-NRssTEkk.mjs";const h=i=>e.isPropertyAssignment(i)?m(i.getInitializer()):e.isShorthandPropertyAssignment(i)?i.getNameNode():void 0,A=(i,s)=>{const o=i===void 0?void 0:h(i);if(o===void 0||!e.isIdentifier(o))return;const a=v(o),g=a?.getAliasedSymbol()??a;for(const t of g?.getDeclarations()??[]){const n=e.isVariableDeclaration(t)?m(t.getInitializer()):t;if(!(e.isFunctionDeclaration(n)||e.isArrowFunction(n)||e.isFunctionExpression(n))||!(e.isFunctionDeclaration(t)||e.isVariableDeclaration(t)))continue;const r=t.getSourceFile(),c=u(s,r.getFilePath()),l=!c.startsWith("../"),d=l?c:u(F(s),r.getFilePath()),f=b(t);return{body:n,...r===o.getSourceFile()?{}:{file:d},...l&&f!==void 0?{site:{exportName:f,file:d}}:{}}}};export{A as r};
1
+ import{dirname as F}from"node:path";import{Node as e}from"ts-morph";import{unwrapExpression as m,lunoraRelativePath as u}from"./isTestPath-CgyyLk8U.mjs";import{r as v,d as b}from"./attribution-Dw35rOaJ.mjs";const h=i=>e.isPropertyAssignment(i)?m(i.getInitializer()):e.isShorthandPropertyAssignment(i)?i.getNameNode():void 0,A=(i,s)=>{const o=i===void 0?void 0:h(i);if(o===void 0||!e.isIdentifier(o))return;const a=v(o),g=a?.getAliasedSymbol()??a;for(const t of g?.getDeclarations()??[]){const n=e.isVariableDeclaration(t)?m(t.getInitializer()):t;if(!(e.isFunctionDeclaration(n)||e.isArrowFunction(n)||e.isFunctionExpression(n))||!(e.isFunctionDeclaration(t)||e.isVariableDeclaration(t)))continue;const r=t.getSourceFile(),c=u(s,r.getFilePath()),l=!c.startsWith("../"),d=l?c:u(F(s),r.getFilePath()),f=b(t);return{body:n,...r===o.getSourceFile()?{}:{file:d},...l&&f!==void 0?{site:{exportName:f,file:d}}:{}}}};export{A as r};
@@ -1 +1 @@
1
- import{Node as i}from"ts-morph";import{listLunoraSourceFiles as u,lunoraRelativePath as f}from"./isTestPath-DCyIyPa7.mjs";import{b as m,d as p}from"./attribution-NRssTEkk.mjs";import{t as d}from"./database-calls-BFY_pIUf.mjs";import{w as g,c as h}from"./classify-procedure-call-BBKuBvKg.mjs";import{a as k}from"./project-config-file-Bv2l-Kmm.mjs";const l=e=>{if(!(!i.isPropertyAssignment(e)&&!i.isShorthandPropertyAssignment(e)&&!i.isMethodDeclaration(e)&&!i.isGetAccessorDeclaration(e)))return k(e)},v=e=>g(e,"use","mask"),D=e=>{if(i.isPropertyAssignment(e)){const s=e.getInitializer();if(s&&i.isStringLiteral(s)){const t=s.getLiteralText();if(t==="redact"||t==="hash")return t}}return"custom"},P=e=>{const s=e.getArguments()[0];if(!s||!i.isObjectLiteralExpression(s))return[];const t=[];for(const r of s.getProperties()){const o=l(r);if(o===void 0||!i.isPropertyAssignment(r))continue;const n=r.getInitializer();if(!(!n||!i.isObjectLiteralExpression(n)))for(const a of n.getProperties()){const c=l(a);c!==void 0&&t.push({column:c,table:o})}}return t},y=e=>{const s=v(e);return{maskColumns:s.flatMap(t=>P(t)),usesMask:s.length>0}},C=new Set(["findFirst","findFirstOrThrow","findMany","get","query"]),M=new Set(["delete","insert","patch","replace"]),b=(e,s)=>{if(!i.isVariableDeclaration(e))return;const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const r=h(t);if(!r)return;const o=r.receiver?y(r.receiver):{maskColumns:[],usesMask:!1},{tablesRead:n,tablesWritten:a}=d(e,C,M);return{exportName:p(e)??e.getName(),file:s,maskColumns:o.maskColumns,tablesRead:n,tablesWritten:a,usesMask:o.usesMask,visibility:r.visibility}},E=(e,s)=>{const t=[];for(const r of u(s)){const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=f(s,r);for(const a of m(o)){const c=b(a,n);c&&t.push(c)}}return t};export{l as a,E as d,v as m,D as s};
1
+ import{Node as i}from"ts-morph";import{listLunoraSourceFiles as u,lunoraRelativePath as f}from"./isTestPath-CgyyLk8U.mjs";import{b as m,d as p}from"./attribution-Dw35rOaJ.mjs";import{t as d}from"./database-calls-DWDtdDbS.mjs";import{w as g,c as h}from"./classify-procedure-call-DxuPQkJA.mjs";import{a as k}from"./project-config-file-Bv2l-Kmm.mjs";const l=e=>{if(!(!i.isPropertyAssignment(e)&&!i.isShorthandPropertyAssignment(e)&&!i.isMethodDeclaration(e)&&!i.isGetAccessorDeclaration(e)))return k(e)},v=e=>g(e,"use","mask"),D=e=>{if(i.isPropertyAssignment(e)){const s=e.getInitializer();if(s&&i.isStringLiteral(s)){const t=s.getLiteralText();if(t==="redact"||t==="hash")return t}}return"custom"},P=e=>{const s=e.getArguments()[0];if(!s||!i.isObjectLiteralExpression(s))return[];const t=[];for(const r of s.getProperties()){const o=l(r);if(o===void 0||!i.isPropertyAssignment(r))continue;const n=r.getInitializer();if(!(!n||!i.isObjectLiteralExpression(n)))for(const a of n.getProperties()){const c=l(a);c!==void 0&&t.push({column:c,table:o})}}return t},y=e=>{const s=v(e);return{maskColumns:s.flatMap(t=>P(t)),usesMask:s.length>0}},C=new Set(["findFirst","findFirstOrThrow","findMany","get","query"]),M=new Set(["delete","insert","patch","replace"]),b=(e,s)=>{if(!i.isVariableDeclaration(e))return;const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const r=h(t);if(!r)return;const o=r.receiver?y(r.receiver):{maskColumns:[],usesMask:!1},{tablesRead:n,tablesWritten:a}=d(e,C,M);return{exportName:p(e)??e.getName(),file:s,maskColumns:o.maskColumns,tablesRead:n,tablesWritten:a,usesMask:o.usesMask,visibility:r.visibility}},E=(e,s)=>{const t=[];for(const r of u(s)){const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=f(s,r);for(const a of m(o)){const c=b(a,n);c&&t.push(c)}}return t};export{l as a,E as d,v as m,D as s};
@@ -0,0 +1 @@
1
+ import{existsSync as h,statSync as P,readdirSync as A,realpathSync as C,lstatSync as j}from"node:fs";import{dirname as d,join as g,relative as w,sep as O,resolve as k,extname as F,basename as D}from"node:path";import{findUpSync as z,FIND_UP_STOP as V,matcher as K}from"@visulima/fs";import{SyntaxKind as p,Node as i,VariableDeclarationKind as $}from"ts-morph";import{diagnosticAt as M}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{p as U,a as B,r as W}from"./project-config-file-Bv2l-Kmm.mjs";import{findProjectConfigFile as N}from"./PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";const X=/\.ts$/u,f=(t,e)=>w(t,e).split(O).join("/").replace(X,""),H=new Set(["_generated","node_modules"]),_=new Set(["__fixtures__","__mocks__","__snapshots__","__tests__"]),L=/\.(?:bench|e2e|e2e-spec|spec|spec-d|test|test-d)(?:\.tsx?)?$/u,Se=t=>{const e=t.split("/");return L.test(e.at(-1)??"")||e.slice(0,-1).some(s=>_.has(s))},E=(t,e,s)=>e?H.has(t)||!s&&_.has(t):!s&&L.test(t),v=new Map,m=()=>!1,Y=t=>{const e=z(c=>N(c)??(h(g(c,"package.json"))||h(g(c,".git"))?V:void 0),{cwd:d(k(t))}),s=e===void 0?void 0:P(e,{throwIfNoEntry:!1});if(e===void 0||s===void 0)return m;const n=`${String(s.mtimeMs)}:${String(s.size)}`,r=v.get(e);if(r?.key===n)return r.isExcluded;const{codegen:o}=W(d(e));o?.unreadable&&console.warn("@lunora/codegen: `codegen.exclude` in lunora.config is not an array of string literals without `!` negations — ignoring it.");const a=o?.exclude?.length?K(o.exclude):m;return v.set(e,{isExcluded:a,key:n}),a},q=(t,e,s)=>t==="schema.ts"&&e===s,G=t=>{try{return P(t)}catch{console.warn(`@lunora/codegen: skipping ${t} — it is a symlink that does not resolve (or vanished mid-scan).`);return}},R=(t,e,s,n,r)=>{let o,a;try{o=A(t),a=C(t)}catch{return e}if(n.has(a))return e;n.add(a);for(const c of o){const u=g(t,c),l=G(u);l===void 0||r(c,w(s,u).split(O).join("/"),l.isDirectory())||(l.isDirectory()?R(u,e,s,n,r):l.isFile()&&F(c)===".ts"&&!q(c,t,s)&&e.push(u))}return e},T=(t,e={})=>{const s=e.includeSkipped??!1,n=s?m:Y(t);return R(t,[],t,new Set,(r,o,a)=>E(r,a,s)||n(o))},Q=["src/server","src/index.ts","src/worker.ts"],J=new Set([".ts",".tsx"]),b=(t,e=[])=>{let s;try{s=j(t)}catch{return e}if(s.isFile())return J.has(F(t))&&!E(D(t),!1,!1)&&e.push(t),e;if(!s.isDirectory())return e;for(const n of A(t))E(n,!0,!1)||b(g(t,n),e);return e},Z=t=>{const e=d(t),s=T(t).map(o=>({displayPath:f(t,o),filePath:o})),n=new Set(s.map(o=>o.filePath)),r=N(e);for(const o of[...Q.flatMap(a=>b(g(e,a))),...r===void 0?[]:[r]])n.has(o)||(n.add(o),s.push({displayPath:f(e,o),filePath:o}));return s},ee=t=>Array.isArray(t),I=(t,e,s,n)=>{const r=[];for(const{displayPath:o,filePath:a}of e){const c=t.getSourceFile(a)??t.addSourceFileAtPath(a);for(const u of c.getDescendantsOfKind(s)){const l=n(u,o);ee(l)?r.push(...l):l!==void 0&&r.push(l)}}return r},te=t=>T(t).map(e=>({displayPath:f(t,e),filePath:e})),se=(t,e,s,n)=>I(t,te(e),s,n),he=(t,e,s)=>se(t,e,p.CallExpression,s),ve=(t,e,s)=>I(t,Z(e),p.CallExpression,s),ye=t=>U(t.getPropertyNameNode()??t.getNameNode()),S=(t,e)=>t?.getProperties().find(s=>!i.isSpreadAssignment(s)&&B(s)===e),Pe=(t,e)=>{if(e){const o=t.getArguments()[0];return o&&(i.isArrowFunction(o)||i.isFunctionExpression(o))?o:void 0}const s=t.getArguments()[0];if(!s||!i.isObjectLiteralExpression(s))return;const n=S(s,"handler");if(!n||!i.isPropertyAssignment(n))return;const r=n.getInitializer();return r&&(i.isArrowFunction(r)||i.isFunctionExpression(r))?r:void 0},Ae=(t,e)=>{if(!t||!i.isObjectLiteralExpression(t))return;const s=S(t,e);return s&&i.isPropertyAssignment(s)?s.getInitializer():void 0},ie=t=>{const e=t?.getParent();return i.isVariableDeclaration(t)&&i.isVariableDeclarationList(e)&&e.getDeclarationKind()===$.Const},ne=t=>{let e=t,s=e.getParent();for(;s!==void 0&&(i.isParenthesizedExpression(s)||i.isAsExpression(s)||i.isSatisfiesExpression(s)||i.isTypeAssertion(s)||i.isNonNullExpression(s));)e=s,s=e.getParent();return e},y=t=>{const e=ne(t),s=e.getParent();if(s===void 0)return!1;if(i.isBinaryExpression(s)){const r=s.getOperatorToken().getKind();return s.getLeft()===e&&r>=p.FirstAssignment&&r<=p.LastAssignment}if(i.isPrefixUnaryExpression(s)||i.isPostfixUnaryExpression(s)){const r=s.getOperatorToken();return r===p.PlusPlusToken||r===p.MinusMinusToken}return i.isDeleteExpression(s)?!0:i.isForOfStatement(s)||i.isForInStatement(s)?s.getInitializer()===e:i.isPropertyAssignment(s)?s.getInitializer()===e&&y(s):(i.isShorthandPropertyAssignment(s)||i.isSpreadAssignment(s)||i.isSpreadElement(s)||i.isObjectLiteralExpression(s)||i.isArrayLiteralExpression(s))&&y(s)},re=t=>{const e=t?.getDeclarations().find(n=>i.isVariableDeclaration(n));if(!ie(e))return;const s=e.getParent().getParent();return i.isVariableStatement(s)&&i.isSourceFile(s.getParent())?e.getInitializer():void 0},oe=t=>re(t.getSymbol()),we=t=>{if(!t)return;if(i.isObjectLiteralExpression(t))return t;if(!i.isIdentifier(t))return;const e=oe(t);return e!==void 0&&i.isObjectLiteralExpression(e)?e:void 0},x=t=>{let e=t;for(;e&&(i.isAsExpression(e)||i.isSatisfiesExpression(e)||i.isParenthesizedExpression(e)||i.isNonNullExpression(e));)e=e.getExpression();return e},ae=(t,e)=>{let s=x(t);for(;i.isAwaitExpression(s)||i.isPropertyAccessExpression(s)||i.isElementAccessExpression(s)||i.isCallExpression(s);){const n=i.isCallExpression(s)?e?.(s):void 0;if(n!==void 0)return{verdict:n};s=x(s.getExpression())}return{root:s}},Oe=t=>ae(t).root,Fe=(t,e)=>t?.compilerNode===e.compilerNode,Ne=t=>{if(i.isPropertyAccessExpression(t))return{member:t.getName(),object:t.getExpression()};const e=i.isElementAccessExpression(t)?t.getArgumentExpression():void 0;return i.isElementAccessExpression(t)&&i.isStringLiteral(e)?{member:e.getLiteralValue(),object:t.getExpression()}:void 0},_e=t=>{const e=t.getParent();return i.isReturnStatement(e)||i.isArrowFunction(e)&&e.getBody()===t?t.getFirstAncestor(n=>i.isFunctionLikeDeclaration(n)||i.isArrowFunction(n)):void 0},Le=t=>{const e=x(t);return e&&i.isCallExpression(e)?e:void 0},Re=t=>{const e=t.getExportAssignment(r=>!r.isExportEquals());if(!e)return;const s=e.getExpression();if(!i.isIdentifier(s))return s;const n=s.getSymbol()?.getValueDeclaration();return n&&i.isVariableDeclaration(n)?n.getInitializer():s},Te=t=>{const e=t.getArguments()[1];return e&&i.isStringLiteral(e)?e.getLiteralValue():""},be=(t,e)=>{if(!i.isObjectLiteralExpression(t))return;const s=S(t,e);if(!s||!i.isPropertyAssignment(s))return;const n=s.getInitializer();return n&&i.isStringLiteral(n)?n.getLiteralText():void 0},ce=t=>{const e=t.getStatements(),[s]=e;if(e.length!==1||s===void 0||!i.isReturnStatement(s))return;const n=s.getExpression();return n!==void 0&&i.isObjectLiteralExpression(n)?n:void 0},Ie=t=>{if(i.isObjectLiteralExpression(t))return t;if(i.isParenthesizedExpression(t)){const e=t.getExpression();return i.isObjectLiteralExpression(e)?e:void 0}return i.isBlock(t)?ce(t):void 0},Ce=t=>(e,s,n)=>{if(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))return e.getLiteralValue();throw M(e,`${t} "${s}": \`${n}\` must be a static string literal — it is deploy configuration codegen writes into wrangler.jsonc`)},le=new Set(["api","internal"]),je=new Set(["run","runAction","runMutation","runQuery"]),ue=t=>{if(t===void 0||!i.isPropertyAccessExpression(t))return;const e=[];let s=t;for(;i.isPropertyAccessExpression(s);)e.unshift(s.getName()),s=s.getExpression();return i.isIdentifier(s)&&le.has(s.getText())&&e.length>=2?e:void 0},ke=t=>{const e=ue(t);return e===void 0?void 0:`${e.slice(0,-1).join("_")}:${String(e.at(-1))}`};export{je as RUN_METHODS,X as TS_EXTENSION_RE,ye as bindingKeyName,Oe as chainRootOf,he as collectCallRows,se as collectNodeRows,ve as collectSecurityCallRows,Re as defaultExportExpression,S as findObjectProperty,ke as functionKeyOf,ue as functionReferenceSegments,Pe as handlerOf,ie as isConstDeclaration,Fe as isSameNode,Se as isTestPath,y as isWriteTarget,Te as limitNameOf,T as listLunoraSourceFiles,Z as listSecurityScanFiles,f as lunoraRelativePath,Ne as memberAccessOf,Ie as objectLiteralFromCallbackBody,we as optionsObjectLiteral,ne as outermostValueWrapper,Ae as propertyInitializer,B as propertyKeyName,U as propertyNameText,_e as returningFunctionOf,Ce as stringPropertyFor,be as stringPropertyOf,re as symbolConstInitializer,x as unwrapExpression,Le as unwrapToCallExpression,ae as walkChain};
@@ -1 +1 @@
1
- import{basename as b}from"node:path";import{Node as d}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{s as g}from"./paths-C-9fwEgQ.mjs";import{listLunoraSourceFiles as $,lunoraRelativePath as v,unwrapToCallExpression as E,defaultExportExpression as S,findObjectProperty as M}from"./isTestPath-DCyIyPa7.mjs";const h=(e,o)=>e.find(t=>t.ownsFolder!==!1&&o.startsWith(`${t.name}/`))?.name,F="module.ts",w=(e,o,t)=>{if(d.isStringLiteral(e)||d.isNoSubstitutionTemplateLiteral(e))return e.getLiteralValue();throw c(e,`module "${o}": \`${t}\` must be a static string literal — codegen reads it without running the file`)},L=(e,o,t)=>{if(!d.isArrayLiteralExpression(e))throw c(e,`module "${o}": \`${t}\` must be an inline array of table names`);return e.getElements().map(n=>w(n,o,t))},p=(e,o,t)=>{const n=M(e,o);if(n!==void 0){if(!d.isPropertyAssignment(n))throw c(n,`module "${t}": write \`${o}\` inline as \`${o}: …\` — codegen reads it without running the file`);return n.getInitializerOrThrow()}},A=(e,o,t)=>{const n=e.getSourceFile(o)??e.addSourceFileAtPath(o),s=E(S(n)),a=s?.getExpression();if(!s||!a||!d.isIdentifier(a)||a.getText()!=="defineModule")return;if(t==="")throw c(s,"defineModule: lunora/module.ts would make the whole app one module — move it into the folder it describes (lunora/<module>/module.ts)");const i=s.getArguments()[0],m={name:t,tables:[]};if(i===void 0)return m;if(!d.isObjectLiteralExpression(i))throw c(i,`module "${t}": defineModule must be passed an inline object literal`);const r=p(i,"description",t);r!==void 0&&(m.description=w(r,t,"description"));const l=p(i,"tables",t);return l!==void 0&&(m.tables=L(l,t,"tables")),m},k=(e,o)=>{const t=[];for(const n of $(o)){if(b(n)!==F)continue;const s=v(o,n),a=A(e,n,s==="module"?"":s.slice(0,-7));a&&t.push(a)}return t.toSorted((n,s)=>n.name.localeCompare(s.name))},T=(e,o)=>{const t=new Set(e.map(r=>r.name)),n=new Set(e.flatMap(r=>r.tables)),s=o.tables.filter(r=>r.extensionKey!==void 0&&!n.has(r.name)),a=Map.groupBy(s,r=>String(r.extensionKey)),i=e.map(r=>{const l=a.get(r.name);return l===void 0?r:{...r,tables:[...r.tables,...l.map(u=>u.name)]}}),m=[...a].filter(([r])=>!t.has(r)).map(([r,l])=>{const u=l.every(f=>f.extensionFromPackage===!0);return{installed:!0,name:r,...u?{ownsFolder:!1}:{},tables:l.map(f=>f.name)}});return[...i,...m].toSorted((r,l)=>r.name.localeCompare(l.name))},x=e=>{for(const o of e){const t=e.find(n=>n.name.startsWith(`${o.name}/`));if(t)throw new Error(`@lunora/codegen: module "${t.name}" is nested inside ${o.installed===!0?"installed component":"module"} "${o.name}" — a file can belong to one module only, so move one of the two`)}},y=(e,o)=>{const t=new Set(o.tables.map(s=>s.name)),n=new Map;for(const s of e)for(const a of s.tables){if(!t.has(a))throw new Error(`@lunora/codegen: module "${s.name}" declares table "${a}", which lunora/schema.ts does not define`);const i=n.get(a);if(i!==void 0)throw new Error(`@lunora/codegen: table "${a}" is claimed by both module "${i}" and module "${s.name}" — a table has one owner`);n.set(a,s.name)}},C=(e,o,t)=>{if(e.length===0)return;const n=new Set(o.map(s=>s.name));for(const s of t){const a=g(s);if(h(o,s)===void 0&&n.has(a))throw new Error(`@lunora/codegen: lunora/${s}.ts sits beside module "${a}" and shares its name — move it into lunora/${a}/ or rename one of them`)}},z=(e,o,t)=>{const n=T(e,o);return x(n),y(n,o),C(e,n,t),n},K=(e,o)=>h(e,o)??g(o);export{h as a,k as d,K as m,z as r};
1
+ import{basename as b}from"node:path";import{Node as d}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{s as g}from"./paths-DwTjD7BU.mjs";import{listLunoraSourceFiles as $,lunoraRelativePath as v,unwrapToCallExpression as E,defaultExportExpression as S,findObjectProperty as M}from"./isTestPath-CgyyLk8U.mjs";const h=(e,o)=>e.find(t=>t.ownsFolder!==!1&&o.startsWith(`${t.name}/`))?.name,F="module.ts",w=(e,o,t)=>{if(d.isStringLiteral(e)||d.isNoSubstitutionTemplateLiteral(e))return e.getLiteralValue();throw c(e,`module "${o}": \`${t}\` must be a static string literal — codegen reads it without running the file`)},L=(e,o,t)=>{if(!d.isArrayLiteralExpression(e))throw c(e,`module "${o}": \`${t}\` must be an inline array of table names`);return e.getElements().map(n=>w(n,o,t))},p=(e,o,t)=>{const n=M(e,o);if(n!==void 0){if(!d.isPropertyAssignment(n))throw c(n,`module "${t}": write \`${o}\` inline as \`${o}: …\` — codegen reads it without running the file`);return n.getInitializerOrThrow()}},A=(e,o,t)=>{const n=e.getSourceFile(o)??e.addSourceFileAtPath(o),s=E(S(n)),a=s?.getExpression();if(!s||!a||!d.isIdentifier(a)||a.getText()!=="defineModule")return;if(t==="")throw c(s,"defineModule: lunora/module.ts would make the whole app one module — move it into the folder it describes (lunora/<module>/module.ts)");const i=s.getArguments()[0],m={name:t,tables:[]};if(i===void 0)return m;if(!d.isObjectLiteralExpression(i))throw c(i,`module "${t}": defineModule must be passed an inline object literal`);const r=p(i,"description",t);r!==void 0&&(m.description=w(r,t,"description"));const l=p(i,"tables",t);return l!==void 0&&(m.tables=L(l,t,"tables")),m},k=(e,o)=>{const t=[];for(const n of $(o)){if(b(n)!==F)continue;const s=v(o,n),a=A(e,n,s==="module"?"":s.slice(0,-7));a&&t.push(a)}return t.toSorted((n,s)=>n.name.localeCompare(s.name))},T=(e,o)=>{const t=new Set(e.map(r=>r.name)),n=new Set(e.flatMap(r=>r.tables)),s=o.tables.filter(r=>r.extensionKey!==void 0&&!n.has(r.name)),a=Map.groupBy(s,r=>String(r.extensionKey)),i=e.map(r=>{const l=a.get(r.name);return l===void 0?r:{...r,tables:[...r.tables,...l.map(u=>u.name)]}}),m=[...a].filter(([r])=>!t.has(r)).map(([r,l])=>{const u=l.every(f=>f.extensionFromPackage===!0);return{installed:!0,name:r,...u?{ownsFolder:!1}:{},tables:l.map(f=>f.name)}});return[...i,...m].toSorted((r,l)=>r.name.localeCompare(l.name))},x=e=>{for(const o of e){const t=e.find(n=>n.name.startsWith(`${o.name}/`));if(t)throw new Error(`@lunora/codegen: module "${t.name}" is nested inside ${o.installed===!0?"installed component":"module"} "${o.name}" — a file can belong to one module only, so move one of the two`)}},y=(e,o)=>{const t=new Set(o.tables.map(s=>s.name)),n=new Map;for(const s of e)for(const a of s.tables){if(!t.has(a))throw new Error(`@lunora/codegen: module "${s.name}" declares table "${a}", which lunora/schema.ts does not define`);const i=n.get(a);if(i!==void 0)throw new Error(`@lunora/codegen: table "${a}" is claimed by both module "${i}" and module "${s.name}" — a table has one owner`);n.set(a,s.name)}},C=(e,o,t)=>{if(e.length===0)return;const n=new Set(o.map(s=>s.name));for(const s of t){const a=g(s);if(h(o,s)===void 0&&n.has(a))throw new Error(`@lunora/codegen: lunora/${s}.ts sits beside module "${a}" and shares its name — move it into lunora/${a}/ or rename one of them`)}},z=(e,o,t)=>{const n=T(e,o);return x(n),y(n,o),C(e,n,t),n},K=(e,o)=>h(e,o)??g(o);export{h as a,k as d,K as m,z as r};
@@ -0,0 +1 @@
1
+ const a=/\/index$/u,n=/[^\dA-Za-z]/gu,c=e=>e.replace(a,"").split("/").map(s=>s.replaceAll(n,"_")),t=e=>c(e).join("_");export{c as n,t as s};
@@ -1 +1 @@
1
- import{d as E}from"./declared-output-Iaar469J.mjs";import{v as u}from"./shared-BXUKWh7t.mjs";const p=/import\("(?<spec>(?:\.\.?\/)*_generated\/[^"]+)"\)/gu,l=/^(?:\.\.?\/)*_generated\//u,i=/\.[A-Za-z]\w*$/u,R=t=>t.replaceAll(p,(e,r)=>{const o=r.replace(l,"./");return`import("${i.test(o)?o:`${o}.js`}")`}),_=/import\("(?<spec>[^"]+)"\)/gu,a="node_modules/",m=/^@types\//u,A=t=>t.replaceAll(_,(e,r)=>{const o=r.lastIndexOf(a);if(o===-1||o>0&&r[o-1]!=="/")return e;const s=r.slice(o+a.length);return s===""||m.test(s)?e:`import("${s}")`}),I=/import\("(?<spec>\.\.?\/[^"]+)"\)/gu,f=/^(?:\.\.?\/)+/u,g=t=>{const e=[];for(const r of t.split("/"))if(!(r===""||r===".")){if(r===".."&&e.length>0&&e.at(-1)!==".."){e.pop();continue}e.push(r)}return e.join("/")},S=(t,e)=>t.replaceAll(I,(r,o)=>{if(l.test(o.replace(f,"")))return r;const s=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",c=`../${g(`${s}/${o}`)}`;return`import("${i.test(c)?c:`${c}.js`}")`}),v=(t,e)=>R(S(A(t),e)),d=["client","do","errors","flags","observability","platform","ratelimit","runtime","server","values"],L=new RegExp(String.raw`import\("@lunora/(?<pkg>${d.join("|")})(?<subpath>/[^"]*)?"\)`,"gu"),T={flags:new Set(["/web"]),platform:new Set},M=(t,e)=>e?t.replaceAll(L,(r,o,s)=>{const n=T[o];return s&&n&&!n.has(s)?r:`import("lunorash/${o}${s??""}")`}):t,O=t=>["Doc","Id"].filter(e=>new RegExp(String.raw`(?<![.$\w])${e}<`,"u").test(t)),U=t=>E(t)?u(t.output):t.returnType;export{M as a,v as b,U as c,O as r};
1
+ import{d as E}from"./declared-output-Iaar469J.mjs";import{v as u}from"./shared-Be3TGzxM.mjs";const p=/import\("(?<spec>(?:\.\.?\/)*_generated\/[^"]+)"\)/gu,l=/^(?:\.\.?\/)*_generated\//u,i=/\.[A-Za-z]\w*$/u,R=t=>t.replaceAll(p,(e,r)=>{const o=r.replace(l,"./");return`import("${i.test(o)?o:`${o}.js`}")`}),_=/import\("(?<spec>[^"]+)"\)/gu,a="node_modules/",m=/^@types\//u,A=t=>t.replaceAll(_,(e,r)=>{const o=r.lastIndexOf(a);if(o===-1||o>0&&r[o-1]!=="/")return e;const s=r.slice(o+a.length);return s===""||m.test(s)?e:`import("${s}")`}),I=/import\("(?<spec>\.\.?\/[^"]+)"\)/gu,f=/^(?:\.\.?\/)+/u,g=t=>{const e=[];for(const r of t.split("/"))if(!(r===""||r===".")){if(r===".."&&e.length>0&&e.at(-1)!==".."){e.pop();continue}e.push(r)}return e.join("/")},S=(t,e)=>t.replaceAll(I,(r,o)=>{if(l.test(o.replace(f,"")))return r;const s=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",c=`../${g(`${s}/${o}`)}`;return`import("${i.test(c)?c:`${c}.js`}")`}),v=(t,e)=>R(S(A(t),e)),d=["client","do","errors","flags","observability","platform","ratelimit","runtime","server","values"],L=new RegExp(String.raw`import\("@lunora/(?<pkg>${d.join("|")})(?<subpath>/[^"]*)?"\)`,"gu"),T={flags:new Set(["/web"]),platform:new Set},M=(t,e)=>e?t.replaceAll(L,(r,o,s)=>{const n=T[o];return s&&n&&!n.has(s)?r:`import("lunorash/${o}${s??""}")`}):t,O=t=>["Doc","Id"].filter(e=>new RegExp(String.raw`(?<![.$\w])${e}<`,"u").test(t)),U=t=>E(t)?u(t.output):t.returnType;export{O as a,M as b,U as c,v as r};
@@ -1,11 +1,11 @@
1
- import{relative as we,isAbsolute as Ie,sep as $e}from"node:path";import{LunoraError as H}from"@lunora/errors";import{CAPABILITIES as Be}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{p as Re}from"./ir-DBSvhNa-.mjs";import{a as p,G as Oe,u as Ne,d as Ce}from"./shared-BXUKWh7t.mjs";const Me=/\.([cm]?)tsx?$/u,De=(d,l=[])=>{const r=new Set;for(const a of d.tables)for(const i of Object.values(a.shape)){const n=Ne(i);n.kind==="storage"&&typeof n.bucket=="string"&&n.bucket!==""&&r.add(n.bucket)}for(const a of l)a!==""&&a!=="default"&&r.add(a);return["default",...[...r].toSorted((a,i)=>a.localeCompare(i))]},Pe=({agents:d=[],capabilities:l=new Set,containers:r=[],env:a,hasVectors:i=!0,hasFlags:n=!1,hasNotify:z=!1,identity:s,queues:C=[],schema:M,generatedDirectory:D="",services:y=[],storageRuleBuckets:U=[],topics:m=[],useUmbrella:J=!1,workflows:S=[]}={})=>{const o=Ce(J),K=De(M??{tables:[]},U).map(e=>JSON.stringify(e)).join(" | "),A=e=>e.sandbox===!0?"SandboxContainerAccessor":"ContainerAccessor",Y=[...new Set(r.map(e=>A(e)))].toSorted((e,t)=>e.localeCompare(t)),X=r.length>0?`import type { ${Y.join(", ")} } from "@lunora/container";
2
- `:"",Z=r.length>0?`
3
- readonly containers: {${r.map(e=>`
4
- readonly ${e.exportName}: ${A(e)};`).join("")}
5
- };`:"",F=[...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. */
6
- readonly ${e.bindingName}?: unknown;`)),...C.map(e=>(p(e.bindingName,`queue binding "${e.bindingName}"`),` /** Queue producer binding for the \`${e.exportName}\` queue. */
1
+ import{CAPABILITIES as Re}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{p as Se}from"./ir-DBSvhNa-.mjs";import{join as q,relative as m,dirname as Q,isAbsolute as De,sep as Me}from"node:path";import{ts as i,Project as Ce}from"ts-morph";import{G as Z,a as $,u as Ne,d as Ae}from"./shared-Be3TGzxM.mjs";const ee=/(?:\.d)?\.([cm]?)tsx?$/u,Fe=t=>t.replace(ee,".d.$1ts"),te=(t,n)=>{const a=m(t,n).split(Me).join("/").replace(ee,".$1js");return a.startsWith(".")?a:`./${a}`},ae=t=>t.replaceAll("\\","/"),E=(t,n,a)=>ae(q(t,Fe(m(n,a)))),Pe=t=>te(".",q("services",t.name,m(Q(t.wranglerPath),t.main))),We=t=>{const n=[],a=r=>{(i.isImportDeclaration(r)||i.isExportDeclaration(r))&&r.moduleSpecifier!==void 0&&i.isStringLiteral(r.moduleSpecifier)?n.push(r.moduleSpecifier):i.isImportTypeNode(r)&&i.isLiteralTypeNode(r.argument)&&i.isStringLiteral(r.argument.literal)&&n.push(r.argument.literal),i.forEachChild(r,a)};return a(t),n},Ge=(t,n)=>{const a=Q(t.wranglerPath),r=m(a,t.main);if(r.startsWith("..")||De(r))throw new Error(`@lunora/codegen: service "${t.name}": its entry module (${t.main}) must be inside ${a} to be typed as RPC`);const d=q(n,"services",t.name),c=i.findConfigFile(a,o=>i.sys.fileExists(o)),p=new Ce({compilerOptions:{composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!1,outDir:d,rootDir:a},skipAddingFilesFromTsConfig:!0,...c===void 0?{}:{tsConfigFilePath:c}});p.addSourceFileAtPath(t.main),p.resolveSourceFileDependencies();const u={...p.getCompilerOptions(),preserveSymlinks:!0},x=new Map(p.getSourceFiles().map(o=>o.getFilePath()).filter(o=>!o.endsWith(".d.ts")&&!m(a,o).startsWith("..")).map(o=>[E(d,a,o),o])),y={};for(const o of p.emitToMemory({emitOnlyDtsFiles:!0}).getFiles()){const g=x.get(ae(o.filePath));if(g===void 0)continue;const h=i.createSourceFile(o.filePath,o.text,i.ScriptTarget.Latest,!1);let{text:f}=o;for(const b of We(h).toReversed()){const s=i.resolveModuleName(b.text,g,u,i.sys).resolvedModule?.resolvedFileName;if(s===void 0)continue;const T=E(d,a,s),v=x.has(T)?T:s;f=`${f.slice(0,b.getStart(h))}${JSON.stringify(te(Q(o.filePath),v))}${f.slice(b.getEnd())}`}y[m(n,o.filePath)]=`${Z}${f}`}if(y[m(n,E(d,a,t.main))]===void 0)throw new Error(`@lunora/codegen: service "${t.name}": TypeScript emitted no declaration for its entry module ${t.main}`);return y},je=(t,n=[])=>{const a=new Set;for(const r of t.tables)for(const d of Object.values(r.shape)){const c=Ne(d);c.kind==="storage"&&typeof c.bucket=="string"&&c.bucket!==""&&a.add(c.bucket)}for(const r of n)r!==""&&r!=="default"&&a.add(r);return["default",...[...a].toSorted((r,d)=>r.localeCompare(d))]},He=({agents:t=[],capabilities:n=new Set,containers:a=[],env:r,hasVectors:d=!0,hasFlags:c=!1,hasNotify:p=!1,identity:u,queues:x=[],schema:y,services:o=[],storageRuleBuckets:g=[],topics:h=[],useUmbrella:f=!1,workflows:b=[]}={})=>{const s=Ae(f),T=je(y??{tables:[]},g).map(e=>JSON.stringify(e)).join(" | "),v=e=>e.sandbox===!0?"SandboxContainerAccessor":"ContainerAccessor",re=[...new Set(a.map(e=>v(e)))].toSorted((e,l)=>e.localeCompare(l)),oe=a.length>0?`import type { ${re.join(", ")} } from "@lunora/container";
2
+ `:"",ne=a.length>0?`
3
+ readonly containers: {${a.map(e=>`
4
+ readonly ${e.exportName}: ${v(e)};`).join("")}
5
+ };`:"",L=[...n.has("ai")?[" /** Workers AI binding (the conventional `env.AI`), narrowing `ctx.ai`. */\n readonly AI?: unknown;"]:[],...a.map(e=>($(e.bindingName,`container binding "${e.bindingName}"`),` /** Durable Object namespace for the \`${e.exportName}\` container. */
6
+ readonly ${e.bindingName}?: unknown;`)),...x.map(e=>($(e.bindingName,`queue binding "${e.bindingName}"`),` /** Queue producer binding for the \`${e.exportName}\` queue. */
7
7
  readonly ${e.bindingName}?: unknown;`))].join(`
8
- `),ee=`
8
+ `),se=`
9
9
 
10
10
  /**
11
11
  * This project's Cloudflare bindings, as far as codegen can discover them from
@@ -18,24 +18,24 @@ import{relative as we,isAbsolute as Ie,sep as $e}from"node:path";import{LunoraEr
18
18
  * surface, so treat them as \`Fetcher\`/\`Service<unknown>\` and cast.
19
19
  */
20
20
  export interface CloudflareBindings {
21
- readonly [binding: string]: unknown;${F?`
22
- ${F}`:""}
21
+ readonly [binding: string]: unknown;${L?`
22
+ ${L}`:""}
23
23
  }
24
24
 
25
25
  /** Alias for {@link CloudflareBindings} — the typed shape of \`env\`. */
26
- export type Env = CloudflareBindings;`,W=e=>Be.map(t=>t.tier!==void 0&&e.includes(t.tier)&&l.has(t.key)?t.serverCtxField:"").join(""),Q=W(["every"]),te=W(["every","action"]),c=i&&(M?.vectorIndexes.length??0)>0,h=c?' | "vectors"':"",j=c?`
27
- readonly vectors: VectorSearch<VectorIndexName>;`:"",ae=c?`
28
- readonly vectors: VectorSearchReader<VectorIndexName>;`:"",re=c?`import type { VectorSearch, VectorSearchReader } from "${o.server}";
26
+ export type Env = CloudflareBindings;`,V=e=>Re.map(l=>l.tier!==void 0&&e.includes(l.tier)&&n.has(l.key)?l.serverCtxField:"").join(""),_=V(["every"]),ie=V(["every","action"]),k=d&&(y?.vectorIndexes.length??0)>0,I=k?' | "vectors"':"",G=k?`
27
+ readonly vectors: VectorSearch<VectorIndexName>;`:"",le=k?`
28
+ readonly vectors: VectorSearchReader<VectorIndexName>;`:"",de=k?`import type { VectorSearch, VectorSearchReader } from "${s.server}";
29
29
  import type { VectorIndexName } from "./dataModel.js";
30
- `:"",b=n?`
30
+ `:"",O=c?`
31
31
  /** Feature-flag evaluation (OpenFeature). Reads are memoized per request; evaluations never throw — a provider error resolves to the supplied default. */
32
- readonly flags: import("${o.flags}").LunoraFlags;`:"",f=z?`
32
+ readonly flags: import("${s.flags}").LunoraFlags;`:"",B=p?`
33
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. */
34
34
  readonly notify: import("@lunora/notify").LunoraNotify;
35
35
  /** Device push sub-facade — the same object as ctx.notify.push (register / send / broadcast). Sends belong in action handlers. */
36
- readonly push: import("@lunora/notify").LunoraPush;`:"",u=S.length>0,oe=u?`import type { WorkflowHandle } from "@lunora/workflow";
36
+ readonly push: import("@lunora/notify").LunoraPush;`:"",w=b.length>0,ce=w?`import type { WorkflowHandle } from "@lunora/workflow";
37
37
  import type * as lunoraWorkflowDefinitions from "../workflows.js";
38
- `:"",ne=u?`
38
+ `:"",ue=w?`
39
39
 
40
40
  /** Params type carried by a \`defineWorkflow\` definition (its phantom \`__params\`). */
41
41
  type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params }
@@ -46,56 +46,56 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
46
46
 
47
47
  /** This project's declared workflows, addressable from \`ctx.workflows\` by their \`lunora/workflows.ts\` export name. */
48
48
  export interface LunoraWorkflows {
49
- ${S.map(e=>` get(name: ${JSON.stringify(e.exportName)}): WorkflowHandle<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${e.exportName}>>;`).join(`
49
+ ${b.map(e=>` get(name: ${JSON.stringify(e.exportName)}): WorkflowHandle<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${e.exportName}>>;`).join(`
50
50
  `)}
51
- }`:"",P=u?' | "workflows"':"",E=u?`
52
- readonly workflows: LunoraWorkflows;`:"",x=Re(C),g=x.length>0,T=m.length>0,v=[...g?["QueueProducer"]:[],...T?["TopicPublisher"]:[]],q=[...new Set([...x,...m].map(e=>e.filePath))].toSorted((e,t)=>+(t==="queues")-+(e==="queues")||e.localeCompare(t)),k=e=>e==="queues"?"lunoraQueueDefinitions":`lunoraQueueDefinitions${String(q.indexOf(e))}`,se=v.length>0?`import type { ${v.join(", ")} } from "@lunora/queue";
53
- ${q.map(e=>`import type * as ${k(e)} from "../${e}.js";
54
- `).join("")}`:"",ie=v.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;":"",de=g?`
51
+ }`:"",H=w?' | "workflows"':"",U=w?`
52
+ readonly workflows: LunoraWorkflows;`:"",R=Se(x),S=R.length>0,D=h.length>0,M=[...S?["QueueProducer"]:[],...D?["TopicPublisher"]:[]],z=[...new Set([...R,...h].map(e=>e.filePath))].toSorted((e,l)=>+(l==="queues")-+(e==="queues")||e.localeCompare(l)),C=e=>e==="queues"?"lunoraQueueDefinitions":`lunoraQueueDefinitions${String(z.indexOf(e))}`,pe=M.length>0?`import type { ${M.join(", ")} } from "@lunora/queue";
53
+ ${z.map(e=>`import type * as ${C(e)} from "../${e}.js";
54
+ `).join("")}`:"",me=M.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;":"",ye=S?`
55
55
 
56
56
  /** This project's declared queues, addressable from \`ctx.queues\` by their \`lunora/queues.ts\` export name. */
57
57
  export interface LunoraQueues {
58
- ${x.map(e=>` readonly ${e.exportName}: QueueProducer<QueueBodyOf<typeof ${k(e.filePath)}.${e.exportName}>>;`).join(`
58
+ ${R.map(e=>` readonly ${e.exportName}: QueueProducer<QueueBodyOf<typeof ${C(e.filePath)}.${e.exportName}>>;`).join(`
59
59
  `)}
60
- }`:"",le=T?`
60
+ }`:"",he=D?`
61
61
 
62
62
  /** This project's declared topics, addressable from \`ctx.topics\` by their \`lunora/queues.ts\` export name. */
63
63
  export interface LunoraTopics {
64
- ${m.map(e=>` readonly ${e.exportName}: TopicPublisher<QueueBodyOf<typeof ${k(e.filePath)}.${e.exportName}>>;`).join(`
64
+ ${h.map(e=>` readonly ${e.exportName}: TopicPublisher<QueueBodyOf<typeof ${C(e.filePath)}.${e.exportName}>>;`).join(`
65
65
  `)}
66
- }`:"",ce=`${ie}${de}${le}`,L=g?`
67
- readonly queues: LunoraQueues;`:"",G=T?`
68
- readonly topics: LunoraTopics;`:"",w=y.length>0,ue=e=>{if(D==="")throw new H("INTERNAL","@lunora/codegen: emitServer needs `generatedDirectory` to import an RPC service's types");const t=we(D,e);if(Ie(t))throw new H("INTERNAL",`@lunora/codegen: an RPC service's entry (${e}) must be on the same drive as the app`);const N=t.split($e).join("/").replace(Me,".$1js");return N.startsWith(".")?N:`./${N}`},V=y.filter(e=>e.rpcEntrypoint!==void 0),pe=V.length>0?"ServiceFetcher, ServiceRpc":"ServiceFetcher",ye=w?`import type { ${pe} } from "${o.server}";
69
- ${V.map(e=>`import type * as lunoraService_${e.name} from ${JSON.stringify(ue(e.main))};
70
- `).join("")}`:"",me=w?`
66
+ }`:"",fe=`${me}${ye}${he}`,J=S?`
67
+ readonly queues: LunoraQueues;`:"",K=D?`
68
+ readonly topics: LunoraTopics;`:"",N=o.length>0,Y=o.filter(e=>e.rpcEntrypoint!==void 0),be=Y.length>0?"ServiceFetcher, ServiceRpc":"ServiceFetcher",xe=N?`import type { ${be} } from "${s.server}";
69
+ ${Y.map(e=>`import type * as lunoraService_${e.name} from ${JSON.stringify(Pe(e))};
70
+ `).join("")}`:"",ge=N?`
71
71
 
72
72
  /** This project's service bindings (\`lunora.config\` \`services\`), addressable from \`ctx.services\` in actions. */
73
73
  export interface LunoraServices {
74
- ${y.map(e=>{p(e.name,`service "${e.name}"`);const t=e.rpcEntrypoint===void 0?"ServiceFetcher":`ServiceRpc<typeof lunoraService_${e.name}.${e.rpcEntrypoint}>`;return` readonly ${e.name}: ${t};`}).join(`
74
+ ${o.map(e=>{$(e.name,`service "${e.name}"`);const l=e.rpcEntrypoint===void 0?"ServiceFetcher":`ServiceRpc<typeof lunoraService_${e.name}.${e.rpcEntrypoint}>`;return` readonly ${e.name}: ${l};`}).join(`
75
75
  `)}
76
- }`:"",he=w?`
77
- readonly services: LunoraServices;`:"",I=d.length>0,be=I?`import type { AgentHandle } from "@lunora/agent";
78
- `:"",fe=I?`
76
+ }`:"",Te=N?`
77
+ readonly services: LunoraServices;`:"",A=t.length>0,ve=A?`import type { AgentHandle } from "@lunora/agent";
78
+ `:"",ke=A?`
79
79
 
80
80
  /** This project's declared agents, addressable from \`ctx.agents\` by their \`lunora/agents.ts\` export name. */
81
81
  export interface LunoraAgents {
82
- ${d.map(e=>(p(e.exportName,`agent export "${e.exportName}"`),` readonly ${e.exportName}: AgentHandle;`)).join(`
82
+ ${t.map(e=>($(e.exportName,`agent export "${e.exportName}"`),` readonly ${e.exportName}: AgentHandle;`)).join(`
83
83
  `)}
84
- }`:"",_=I?`
85
- readonly agents: LunoraAgents;`:"",xe=s?`import type { InferIdentity } from "${o.server}";
84
+ }`:"",X=A?`
85
+ readonly agents: LunoraAgents;`:"",we=u?`import type { InferIdentity } from "${s.server}";
86
86
  import type * as lunoraIdentityContract from "../identity.js";
87
- `:"",ge=s?`
87
+ `:"",$e=u?`
88
88
 
89
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. */
90
- export type Identity = InferIdentity<typeof lunoraIdentityContract.${s.exportName}>;
90
+ export type Identity = InferIdentity<typeof lunoraIdentityContract.${u.exportName}>;
91
91
 
92
92
  /** \`ctx.auth\` narrowed so \`getIdentity()\` resolves the declared {@link Identity} contract instead of the untyped claim bag. */
93
- type NarrowedAuth = Omit<QueryCtxBase["auth"], "getIdentity"> & { getIdentity: () => Promise<Identity | null> };`:"",$=s?' | "auth"':"",B=s?`
94
- readonly auth: NarrowedAuth;`:"",Te=s?", Identity":"",ve=a?`import type * as lunoraEnvContract from "../env.js";
95
- `:"",ke=a?`
93
+ type NarrowedAuth = Omit<QueryCtxBase["auth"], "getIdentity"> & { getIdentity: () => Promise<Identity | null> };`:"",F=u?' | "auth"':"",P=u?`
94
+ readonly auth: NarrowedAuth;`:"",Ie=u?", Identity":"",Oe=r?`import type * as lunoraEnvContract from "../env.js";
95
+ `:"",Be=r?`
96
96
 
97
97
  /** This app's declared env contract (\`defineEnv\` in \`lunora/env.ts\`) — the validated, coercion-aware shape of \`ctx.env\`. */
98
- export type LunoraEnv = ReturnType<typeof lunoraEnvContract.${a.exportName}>;`:"",R=a?' | "env"':"",O=a?"\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`${Oe}import { createPolicyDsl, defineMutator as defineMutatorBase, initLunora, v as vBase } from "${o.server}";
98
+ export type LunoraEnv = ReturnType<typeof lunoraEnvContract.${r.exportName}>;`:"",W=r?' | "env"':"",j=r?"\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`${Z}import { createPolicyDsl, defineMutator as defineMutatorBase, initLunora, v as vBase } from "${s.server}";
99
99
  import type {
100
100
  ActionBuilder,
101
101
  ActionCtx as ActionCtxBase,
@@ -117,7 +117,7 @@ import type {
117
117
  Storage as StorageBase,
118
118
  TableReader,
119
119
  Validator,
120
- } from "${o.server}";
120
+ } from "${s.server}";
121
121
 
122
122
  import type {
123
123
  DatabaseReaderFacade as DatabaseReaderFacadeOf,
@@ -126,7 +126,7 @@ import type {
126
126
  TableReaderFacade as TableReaderFacadeOf,
127
127
  TableWriterFacade as TableWriterFacadeOf,
128
128
  WithArg as WithArgOf,
129
- } from "${o.serverDataModel}";
129
+ } from "${s.serverDataModel}";
130
130
 
131
131
  export type {
132
132
  AggregateOp,
@@ -149,10 +149,10 @@ export type {
149
149
  Where,
150
150
  WhereOf,
151
151
  WhereOperators,
152
- } from "${o.serverDataModel}";
152
+ } from "${s.serverDataModel}";
153
153
 
154
154
  import type { DataModel, Doc, GeoIndexNamesByTable, Id as IdOfTable, IndexNamesByTable, Insert, InsertModel, RankIndexNamesByTable, Relations, SearchIndexNamesByTable, TableName } from "./dataModel.js";
155
- ${re}${X}${oe}${se}${ye}${be}${xe}${ve}
155
+ ${de}${oe}${ce}${pe}${xe}${ve}${we}${Oe}
156
156
  export type { AppTableName, DataModel, Doc, Id, TableName } from "./dataModel.js";
157
157
 
158
158
  /**
@@ -212,7 +212,7 @@ export interface OrmWriter extends OrmReader {
212
212
  }
213
213
 
214
214
  /** Storage buckets this schema declares (\`v.storage("name")\`), narrowing \`ctx.storage.bucket(name)\`. */
215
- export type StorageBucketName = ${K};${ee}${ne}${ce}${me}${fe}${ge}${ke}
215
+ export type StorageBucketName = ${T};${se}${ue}${fe}${ge}${ke}${$e}${Be}
216
216
 
217
217
  /**
218
218
  * Project-typed contexts. The base contexts from \`@lunora/server\` are
@@ -275,22 +275,22 @@ type AsIdTable<T extends string> = T extends TableName ? T : string extends T ?
275
275
  */
276
276
  type TypedAsId = <T extends string>(tableName: AsIdTable<T>, id: string) => IdOfTable<T & TableName>;
277
277
 
278
- export interface QueryCtx extends Omit<QueryCtxBase, "db" | "storage"${h}${$}${R}> {
278
+ export interface QueryCtx extends Omit<QueryCtxBase, "db" | "storage"${I}${F}${W}> {
279
279
  readonly db: Omit<DatabaseReader, "asId" | "query" | "get"> & DatabaseReaderFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
280
280
  readonly orm: OrmReader;
281
- readonly storage: ReadOnlyStorage<StorageBucketName>;${ae}${Q}${b}${f}${O}${B}
281
+ readonly storage: ReadOnlyStorage<StorageBucketName>;${le}${_}${O}${B}${j}${P}
282
282
  }
283
283
 
284
- export interface MutationCtx extends Omit<MutationCtxBase, "db" | "storage"${h}${P}${$}${R}> {
284
+ export interface MutationCtx extends Omit<MutationCtxBase, "db" | "storage"${I}${H}${F}${W}> {
285
285
  readonly db: Omit<DatabaseWriter, "asId" | "query" | "get"> & DatabaseWriterFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
286
286
  readonly orm: OrmWriter;
287
- readonly storage: MutationStorage<StorageBucketName>;${j}${Q}${b}${f}${O}${E}${L}${G}${_}${B}
287
+ readonly storage: MutationStorage<StorageBucketName>;${G}${_}${O}${B}${j}${U}${J}${K}${X}${P}
288
288
  }
289
289
 
290
- export interface ActionCtx extends Omit<ActionCtxBase, "db" | "storage"${h}${P}${$}${R}> {
290
+ export interface ActionCtx extends Omit<ActionCtxBase, "db" | "storage"${I}${H}${F}${W}> {
291
291
  readonly db: Omit<DatabaseWriter, "asId" | "query" | "get"> & DatabaseWriterFacade & { asId: TypedAsId; query: TypedTableQuery; get: TypedTableGet };
292
292
  readonly orm: OrmWriter;
293
- readonly storage: StorageBase<StorageBucketName>;${j}${te}${Z}${b}${f}${he}${O}${E}${L}${G}${_}${B}
293
+ readonly storage: StorageBase<StorageBucketName>;${G}${ie}${ne}${O}${B}${Te}${j}${U}${J}${K}${X}${P}
294
294
  }
295
295
 
296
296
  /**
@@ -323,7 +323,7 @@ export const internalAction = lunoraBuilders.internalAction as unknown as Intern
323
323
  /**
324
324
  * \`defineMutator\` bound to this project's typed {@link MutationCtx} — declare
325
325
  * custom mutators (\`lunora/mutators.ts\`) with it instead of importing from
326
- * \`${o.server}\`, and the authoritative \`server\` impl's \`ctx\` carries the
326
+ * \`${s.server}\`, and the authoritative \`server\` impl's \`ctx\` carries the
327
327
  * schema-typed \`ctx.db\` (\`ctx.db.query("nodes")\` resolves \`Doc<"nodes">\`,
328
328
  * \`ctx.db.patch(id, …)\` takes an \`Id<"nodes">\`) with no hand-written ctx type and
329
329
  * no \`as unknown as\` cast. Runtime-identical to the package export; only the
@@ -348,7 +348,7 @@ export const defineMutator = defineMutatorBase as unknown as <Args extends Recor
348
348
  * Runtime-identical to \`@lunora/server\`'s \`definePolicy\`; only the types narrow,
349
349
  * so the \`rls()\` chain discovers a policy authored either way the same.
350
350
  */
351
- export const definePolicy = createPolicyDsl<DataModel, Relations${Te}>();
351
+ export const definePolicy = createPolicyDsl<DataModel, Relations${Ie}>();
352
352
 
353
353
  /**
354
354
  * The validator builder \`v\`, with \`v.id(...)\` constrained to THIS schema's
@@ -365,4 +365,4 @@ export const definePolicy = createPolicyDsl<DataModel, Relations${Te}>();
365
365
  export const v = vBase as unknown as Omit<typeof vBase, "id"> & {
366
366
  id: <T extends TableName>(table: T) => ColumnValidator<IdOfTable<T>, IdOfTable<T>>;
367
367
  };
368
- `};export{Pe as default};
368
+ `};export{Ge as a,He as e};
@@ -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 Tt,a as Ot,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-DGrBvQWg.mjs";import{u as K,i as Ht,G as Vt,d as Kt}from"./shared-BXUKWh7t.mjs";const Gt=` /**
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 Tt,a as Ot,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-BI2SZ54Z.mjs";import{u as K,i as Ht,G as Vt,d as Kt}from"./shared-Be3TGzxM.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
@@ -1,4 +1,4 @@
1
- import{s as b}from"./ir-DBSvhNa-.mjs";import{r as y}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as $}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{a as u,G as p}from"./shared-BXUKWh7t.mjs";const I=e=>e?{importFragment:"serveRelationFanout, ",override:`
1
+ import{s as b}from"./ir-DBSvhNa-.mjs";import{r as y}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as $}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{a as u,G as p}from"./shared-Be3TGzxM.mjs";const I=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
 
@@ -0,0 +1,13 @@
1
+ import{LunoraError as y}from"@lunora/errors";import{n as E}from"./paths-DwTjD7BU.mjs";import{R}from"./reserved-words-CW1QFbTd.mjs";import{acceptsAbsentIr as A}from"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";const S=/^(?:"(?:[^"\\]|\\(?:["\\/bfnrt]|u[0-9A-Fa-f]{4}))*"|'[^'\\]*'|-?\d+(?:\.\d+)?|true|false|null)$/u,M=`// GENERATED by @lunora/codegen — do not edit.
2
+ // Run \`lunora codegen\` to regenerate.
3
+
4
+ `,K=(e=!1)=>e?{client:"lunorash/client",do:"lunorash/do",flags:"lunorash/flags",server:"lunorash/server",serverDataModel:"lunorash/server/data-model",serverDrizzle:"lunorash/server/drizzle",serverTypes:"lunorash/server/types",values:"lunorash/values"}:{client:"@lunora/client",do:"@lunora/do",flags:"@lunora/flags",server:"@lunora/server",serverDataModel:"@lunora/server/data-model",serverDrizzle:"@lunora/server/drizzle",serverTypes:"@lunora/server/types",values:"@lunora/values"},b=/^[A-Za-z_$][\w$]*$/u,B=/^[\w./-]+$/u,w=(e,n)=>{if(!b.test(e)||R.has(e))throw new y("INTERNAL",`@lunora/codegen: ${n} is not a valid JS identifier: ${JSON.stringify(e)}`)},F=(e,n)=>{if(!b.test(e))throw new y("INTERNAL",`@lunora/codegen: ${n} is not a valid JS identifier: ${JSON.stringify(e)}`)},G=e=>e.charAt(0).toUpperCase()+e.slice(1),g=e=>b.test(e)?e:JSON.stringify(e),k=e=>e==="__proto__"?`[${JSON.stringify(e)}]`:g(e),O=e=>{const n=new Map;for(const r of e){const t=n.get(r.filePath)??[];t.push(r),n.set(r.filePath,t)}return[...n.entries()].toSorted(([r],[t])=>r.localeCompare(t))},U=(e,n,r)=>{const[t,l]=r==="type"?[g,";"]:[k,","],d={children:new Map};for(const[o,$]of O(e)){let a=d;for(const f of E(o)){let c=a.children.get(f);c===void 0&&(c={children:new Map},a.children.set(f,c)),a=c}a.file={entries:$,path:o}}const u=o=>o.file?.path??u(o.children.values().next().value),p=(o,$)=>{const a=" ".repeat($),{entries:f=[],path:c=""}=o.file??{},h=f.find(s=>o.children.has(s.exportName));if(h!==void 0){const s=u(o.children.get(h.exportName));throw new y("NAMESPACE_COLLISION",`Namespace collision: the export "${h.exportName}" of "${c}" and "${s}" both resolve to api.${[...E(c),h.exportName].join(".")}. Rename the export or the folder.`)}const _=f.toSorted((s,m)=>s.exportName.localeCompare(m.exportName)).map(s=>`${a}${n(s)}`),I=[...o.children.entries()].toSorted(([s],[m])=>s.localeCompare(m)).map(([s,m])=>`${a}${t(s)}: {
5
+ ${p(m,$+1).join(`
6
+ `)}
7
+ ${a}}${l}`);return[..._,...I]};return p(d,1).join(`
8
+ `)},j={any:"unknown",bigint:"bigint",boolean:"boolean",bytes:"ArrayBuffer",date:"number",geoPoint:"{ lat: number; lng: number }",null:"null",number:"number",storage:"string",string:"string",timestamp:"number"},D=e=>{if(e===void 0)return"unknown";if(!S.test(e))throw new y("INTERNAL",`@lunora/codegen: v.literal() argument is not a parseable string/number/boolean/null literal: ${JSON.stringify(e)}`);return e},i=e=>e.column?.notNull===!1?`${T(e)} | null`:T(e),T=e=>{const n=j[e.kind];if(n!==void 0)return n;switch(e.kind){case"array":return`Array<${e.inner?i(e.inner):"unknown"}>`;case"from":return e.tsType??"unknown";case"id":{const r=e.tableName??"_unknown_";return w(r,"v.id() table name"),`Id<"${r}">`}case"literal":return D(e.literalValue);case"object":return e.shape?`{ ${Object.entries(e.shape).map(([t,l])=>N(t,l)).join("; ")} }`:"Record<string, unknown>";case"optional":return`${e.inner?i(e.inner):"unknown"} | undefined`;case"record":{const r=e.keyType?i(e.keyType):"string",t=e.valueType?i(e.valueType):"unknown";return`Record<${r}, ${t}>`}case"union":return e.members&&e.members.length>0?e.members.map(r=>i(r)).join(" | "):"never";default:return"unknown"}},N=(e,n)=>{const r=g(e);if(n.kind==="optional"){const t=n.inner?i(n.inner):"unknown";return`${r}?: ${t}`}return A(n)?`${r}?: ${i(n)}`:`${r}: ${i(n)}`},V=e=>{const n=Object.entries(e);return n.length===0?"{}":`{ ${n.map(([r,t])=>N(r,t)).join("; ")} }`},x=e=>e.kind==="optional"||!!e.column?.hasDefault,L=e=>e.kind==="optional"&&e.inner?e.inner:e,v=e=>{w(e.name,"table name");const n=Object.entries(e.shape).map(([t,l])=>{const d=L(l),u=i(d),p=g(t);return x(l)?` ${p}?: ${u};`:` ${p}: ${u};`}).join(`
9
+ `),r=n?`
10
+ ${n}
11
+ `:"";return`export interface Insert_${e.name} {
12
+ _id?: Id<"${e.name}">;
13
+ _creationTime?: number;${r}}`};export{M as G,B as I,S as L,w as a,U as b,k as c,K as d,g as e,v as f,F as g,x as i,G as p,V as r,L as u,i as v};