@lunora/codegen 1.0.0-alpha.335 → 1.0.0-alpha.336

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 (86) hide show
  1. package/dist/index.d.mts +20 -1
  2. package/dist/index.d.ts +20 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AGENTS_FILENAME-8zoeGNsB.mjs → AGENTS_FILENAME-isdHqPIt.mjs} +1 -1
  5. package/dist/packem_shared/CONTAINERS_FILENAME-mK4cZpcz.mjs +1 -0
  6. package/dist/packem_shared/{DEFAULT_TARGET-CDksdcYc.mjs → DEFAULT_TARGET-3OLdJhTj.mjs} +1 -1
  7. package/dist/packem_shared/{FLAGS_FILENAME-Cwq0B2Nl.mjs → FLAGS_FILENAME-BQk3SX8D.mjs} +1 -1
  8. package/dist/packem_shared/GENERATED_HEADER-BXK9A_wP.mjs +1 -0
  9. package/dist/packem_shared/LUNORA_ERROR_CODES-CIAJQeKB.mjs +1 -0
  10. package/dist/packem_shared/{MUTATORS_FILENAME-DZFH7a9G.mjs → MUTATORS_FILENAME-Cy9h3EVW.mjs} +1 -1
  11. package/dist/packem_shared/{NOTIFY_FILENAME-DZIt-rb0.mjs → NOTIFY_FILENAME-9to_l_Kh.mjs} +1 -1
  12. package/dist/packem_shared/{OPENRPC_VERSION-CeEGdAZ9.mjs → OPENRPC_VERSION-l4HD4osw.mjs} +1 -1
  13. package/dist/packem_shared/{QUEUES_FILENAME-EvfCmmv6.mjs → QUEUES_FILENAME-Civ-7SiI.mjs} +1 -1
  14. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DcWyFDv9.mjs +31 -0
  15. package/dist/packem_shared/{SHAPES_FILENAME-Ciu5tx7B.mjs → SHAPES_FILENAME-DVJbfDZ8.mjs} +1 -1
  16. package/dist/packem_shared/{WORKFLOWS_FILENAME-C5tz9gMh.mjs → WORKFLOWS_FILENAME-kXq07aGl.mjs} +1 -1
  17. package/dist/packem_shared/{attribution-RI-H1KPm.mjs → attribution-CG8-kUcl.mjs} +1 -1
  18. package/dist/packem_shared/{buildOpenApiDocument-BBao-3vL.mjs → buildOpenApiDocument-DWdj2jvW.mjs} +1 -1
  19. package/dist/packem_shared/capabilitiesUsedBy-C-7D7vlH.mjs +1 -0
  20. package/dist/packem_shared/chain-74gjwZMP.mjs +1 -0
  21. package/dist/packem_shared/{classify-procedure-call-C5JY2w5V.mjs → classify-procedure-call-BkaeM9Ej.mjs} +1 -1
  22. package/dist/packem_shared/{context-property-calls-M6Oo1xQT.mjs → context-property-calls-dFjpeIlP.mjs} +1 -1
  23. package/dist/packem_shared/{context-root-DQd48e1F.mjs → context-root-CNR6TAsP.mjs} +1 -1
  24. package/dist/packem_shared/{createCodegenProject-C-fKC9h4.mjs → createCodegenProject-R4so-yTU.mjs} +1 -1
  25. package/dist/packem_shared/{database-calls-BNoSJRFy.mjs → database-calls-UPlhi3Ks.mjs} +1 -1
  26. package/dist/packem_shared/discoverAuthApiCalls-CScPrUD-.mjs +1 -0
  27. package/dist/packem_shared/discoverCrons-B1_NUt19.mjs +1 -0
  28. package/dist/packem_shared/{discoverFunctions-CJu5EH_G.mjs → discoverFunctions-DkPOc8b9.mjs} +1 -1
  29. package/dist/packem_shared/{discoverHttpRoutes-MrMxIY66.mjs → discoverHttpRoutes-DCDgDIYv.mjs} +1 -1
  30. package/dist/packem_shared/discoverHyperdriveCalls-CL-d0IVo.mjs +1 -0
  31. package/dist/packem_shared/{discoverInserts-Boh6WAYw.mjs → discoverInserts-BcoTjXqI.mjs} +1 -1
  32. package/dist/packem_shared/discoverMaskProcedures-Bw-BOIbA.mjs +1 -0
  33. package/dist/packem_shared/{discoverMigrations-BMdGxHeq.mjs → discoverMigrations-BWxx8Wv9.mjs} +1 -1
  34. package/dist/packem_shared/{discoverNondeterministicCalls-c9xenrIN.mjs → discoverNondeterministicCalls-3INW8oqs.mjs} +1 -1
  35. package/dist/packem_shared/{discoverQueries-o_00HnBB.mjs → discoverQueries-CxQRVuIV.mjs} +1 -1
  36. package/dist/packem_shared/discoverR2sqlCalls-B4oeTYEM.mjs +1 -0
  37. package/dist/packem_shared/{discoverRlsMetadata-C7J8dgVz.mjs → discoverRlsMetadata-D0B4nCmG.mjs} +1 -1
  38. package/dist/packem_shared/{discoverRlsProcedures-Di3VEk-D.mjs → discoverRlsProcedures-Cl6UKT7L.mjs} +1 -1
  39. package/dist/packem_shared/{discoverSandboxUsage-CrhZZJZS.mjs → discoverSandboxUsage--Z1vx7GM.mjs} +1 -1
  40. package/dist/packem_shared/discoverSchema-Cwt-DQgh.mjs +1 -0
  41. package/dist/packem_shared/{discoverStorageRulesMetadata-BFCmbsIN.mjs → discoverStorageRulesMetadata-CitX6ziW.mjs} +1 -1
  42. package/dist/packem_shared/{emitAgents-CR2_X_ov.mjs → emitAgents-C9JRmvrC.mjs} +1 -1
  43. package/dist/packem_shared/{emitApi-CDgIPAG2.mjs → emitApi-c14__tie.mjs} +24 -24
  44. package/dist/packem_shared/{emitApp-DuJW6LKD.mjs → emitApp-BL16wvE9.mjs} +1 -1
  45. package/dist/packem_shared/{emitCrons-BQW2lviZ.mjs → emitCrons-lc-hnJYn.mjs} +1 -1
  46. package/dist/packem_shared/{emitDataModel-BskFt9Wv.mjs → emitDataModel-CuFqq97x.mjs} +1 -1
  47. package/dist/packem_shared/{emitDrizzleSchema-DitcRZ1a.mjs → emitDrizzleSchema-bct1OuH5.mjs} +1 -1
  48. package/dist/packem_shared/{emitFunctions-Cd0Tuw73.mjs → emitFunctions-CkBPtGDF.mjs} +71 -65
  49. package/dist/packem_shared/{emitServer-D1vA5_X1.mjs → emitServer-CGUhLmlG.mjs} +1 -1
  50. package/dist/packem_shared/{emitShard-DtfjUgjj.mjs → emitShard-FJhdFx9H.mjs} +1 -1
  51. package/dist/packem_shared/{exported-procedure-chains-Bol_VtzO.mjs → exported-procedure-chains-D1WlRfqJ.mjs} +1 -1
  52. package/dist/packem_shared/{fingerprintSchemaSources-BdFj8vPc.mjs → fingerprintSchemaSources-BKXkgkj4.mjs} +1 -1
  53. package/dist/packem_shared/{handler-reference-8w_VU4XY.mjs → handler-reference-CClSR4bi.mjs} +1 -1
  54. package/dist/packem_shared/index-CN8FVvr-.mjs +1 -0
  55. package/dist/packem_shared/{isTestPath-Cdv_LoVU.mjs → isTestPath-C3QumE88.mjs} +1 -1
  56. package/dist/packem_shared/loadProjectConfig-B7RmxIeD.mjs +1 -0
  57. package/dist/packem_shared/{modules-DDIIcM7P.mjs → modules-l-Db0C4S.mjs} +1 -1
  58. package/dist/packem_shared/parse-validator-iVTounLK.mjs +1 -0
  59. package/dist/packem_shared/property-name-7cBlgK_O.mjs +1 -0
  60. package/dist/packem_shared/{qualifiers-DEdXn5wP.mjs → qualifiers-Bl5fSmav.mjs} +1 -1
  61. package/dist/packem_shared/readServiceBindings-BA49C6aN.mjs +1 -0
  62. package/dist/packem_shared/{server-DAvi_bv_.mjs → server-B6VhYK7m.mjs} +1 -1
  63. package/dist/packem_shared/{shard-CsfiXxV0.mjs → shard-B6afe1Uh.mjs} +170 -122
  64. package/dist/packem_shared/{shard-runtime-BpoCV-aM.mjs → shard-runtime-BW1kffN4.mjs} +9 -7
  65. package/dist/packem_shared/shared-8vTRkL2-.mjs +13 -0
  66. package/dist/packem_shared/{unwrap-handler-return-Bfz7lH0C.mjs → unwrap-handler-return-CGdJGvGh.mjs} +1 -1
  67. package/dist/sdk/index.mjs +15 -15
  68. package/package.json +9 -9
  69. package/dist/packem_shared/CONTAINERS_FILENAME-QiNt84QA.mjs +0 -1
  70. package/dist/packem_shared/GENERATED_HEADER-Ck_WOHzE.mjs +0 -1
  71. package/dist/packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs +0 -1
  72. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-V7LYutDl.mjs +0 -31
  73. package/dist/packem_shared/capabilitiesUsedBy-BC7ldWJI.mjs +0 -1
  74. package/dist/packem_shared/chain-C9qZxjM_.mjs +0 -1
  75. package/dist/packem_shared/discoverAuthApiCalls-GPzUN_-_.mjs +0 -1
  76. package/dist/packem_shared/discoverCrons-C1fKEf4g.mjs +0 -1
  77. package/dist/packem_shared/discoverHyperdriveCalls-VVJGsgxj.mjs +0 -1
  78. package/dist/packem_shared/discoverMaskProcedures-D3Tu8Q8Y.mjs +0 -1
  79. package/dist/packem_shared/discoverR2sqlCalls-D_H1v-UD.mjs +0 -1
  80. package/dist/packem_shared/discoverSchema-Bdmw34_P.mjs +0 -1
  81. package/dist/packem_shared/index-BMMBKqsT.mjs +0 -1
  82. package/dist/packem_shared/loadProjectConfig-B0uxUGF-.mjs +0 -1
  83. package/dist/packem_shared/parse-validator-BqDQLzDZ.mjs +0 -1
  84. package/dist/packem_shared/project-config-file-CBY6llht.mjs +0 -1
  85. package/dist/packem_shared/readServiceBindings-4xlUucKw.mjs +0 -1
  86. package/dist/packem_shared/shared-DnCokNcE.mjs +0 -13
@@ -1,4 +1,4 @@
1
- import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as N}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{a as l,G as g}from"./shared-DnCokNcE.mjs";import{s as k}from"./platform-8oj7iXQy.mjs";const I=e=>e?{importFragment:"serveRelationFanout, ",override:`
1
+ import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as N}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{a as l,G as g}from"./shared-8vTRkL2-.mjs";import{s as k}from"./platform-8oj7iXQy.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
 
@@ -190,7 +190,7 @@ ${n}`},H=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],
190
190
  const LUNORA_CONTAINERS: ReadonlyArray<ContainerBindingSpec> = [
191
191
  ${t}
192
192
  ];
193
- `}},J=e=>{if(e.length===0)return"";const r=e.map(n=>(l(n.exportName,`workflow export "${n.exportName}"`),l(n.className,`workflow class "${n.className}"`),`/** WorkflowEntrypoint for the \`${n.exportName}\` definition, reached as \`ctx.exports.${n.className}\`. */
193
+ `}},V=e=>{if(e.length===0)return"";const r=e.map(n=>(l(n.exportName,`workflow export "${n.exportName}"`),l(n.className,`workflow class "${n.className}"`),`/** WorkflowEntrypoint for the \`${n.exportName}\` definition, reached as \`ctx.exports.${n.className}\`. */
194
194
  export class ${n.className} extends LunoraWorkflow<WorkflowParamsOf<typeof ${n.exportName}>, WorkflowOutputOf<typeof ${n.exportName}>> {
195
195
  public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
196
196
  super(ctx, env, ${n.exportName}, "${n.exportName}");
@@ -218,7 +218,7 @@ 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}`},V=e=>{if(e.length===0)return"";const t=e.filter(s=>s.voice).length>0,n=e.map(s=>{l(s.exportName,`agent export "${s.exportName}"`),l(s.className,`agent class "${s.className}"`);const o=`/** WorkflowEntrypoint for the \`${s.exportName}\` agent, reached as \`ctx.exports.${s.className}\`. */
221
+ ${r}`},J=e=>{if(e.length===0)return"";const t=e.filter(s=>s.voice).length>0,n=e.map(s=>{l(s.exportName,`agent export "${s.exportName}"`),l(s.className,`agent class "${s.className}"`);const o=`/** WorkflowEntrypoint for the \`${s.exportName}\` agent, reached as \`ctx.exports.${s.className}\`. */
222
222
  export class ${s.className} extends LunoraWorkflow<AgentRunInput, AgentRunResult> {
223
223
  public constructor(ctx: ConstructorParameters<typeof LunoraWorkflow>[0], env: Record<string, unknown>) {
224
224
  super(ctx, env, compileAgentWorkflow(${s.exportName}, "${s.exportName}"), "${s.exportName}");
@@ -297,14 +297,16 @@ ${t}
297
297
  const LUNORA_SERVICES: ReadonlyArray<ServiceBindingSpec> = [
298
298
  ${t}
299
299
  ];
300
- `}},ne=e=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const t of e)l(t.exportName,`agent export "${t.exportName}"`),l(t.className,`agent class "${t.className}"`);const r=e.map(t=>` { className: "${t.className}", exportName: "${t.exportName}"${t.publicRun===!0?", publicRun: true":""} },`).join(`
300
+ `}},ne=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};for(const n of e)l(n.exportName,`agent export "${n.exportName}"`),l(n.className,`agent class "${n.className}"`);const t=e.map(n=>` { className: "${n.className}", exportName: "${n.exportName}"${n.publicRun===!0?", publicRun: true":""} },`).join(`
301
301
  `);return{build:`
302
302
  const agents = createAgentContext(env, LUNORA_AGENTS, { exports: this.state.exports });
303
- `,contextField:`
303
+ `,contextField:r?`
304
+ agents,
305
+ agentSecrets: this.secretValues,`:`
304
306
  agents,`,importLines:['import { createAgentContext } from "@lunora/agent";','import type { AgentBindingSpec } from "@lunora/agent";'],specs:`
305
307
  /** Wiring specs for \`ctx.agents\` (codegen-derived from \`lunora/agents.ts\`). */
306
308
  const LUNORA_AGENTS: ReadonlyArray<AgentBindingSpec> = [
307
- ${r}
309
+ ${t}
308
310
  ];
309
311
  `}},v=(e,r,t,n,a)=>({constant:`
310
312
  ${a}
@@ -328,4 +330,4 @@ const ${e} = ${b(n,r)};
328
330
  }
329
331
 
330
332
  return payments;
331
- },`,stub:f("paymentStub: LunoraPayment","ctx.payments: no payment configured. Pass `payment` to createShardDO().",P,{cast:" as unknown as LunoraPayment",sync:!0})}:{build:"",configField:"",contextField:"",imports:[],stub:""},ae=(e,r,t,n,a)=>["AdvisorProcedure","AdvisoryFinding","DatabaseWriterLike","DataMigrationLike","DispatchBookmark","ExportRow",...n?["FlagsResult"]:[],"ImportShardResult","KeyRange","MaskPoliciesResult","MigrationRunResult","QueryReadScope",...t?["QueuesResult"]:[],"RelatedPage","RunShardApplyCdcArgs","RunShardExportArgs","RunShardFindRelatedArgs","RunShardImportArgs","RunShardMigrationArgs","RlsPoliciesResult","RunShardRankBeforeArgs","RunShardRankPageArgs","RunShardWriteArgs","RunShardWriteResult","SchedulerLike",...a?["SearchBackfillProgress"]:[],"TransactionHeadroomTracker","SchemaLike","ShardDOState","DeliveryAuthorization","ShardRankPageResult","SqlExec","StorageRulesResult","StudioFeaturesResult","SubscriptionIdentity","SystemReaderStorageLike","TelemetrySink",...e?["VectorBackfillProgress"]:[],...r?["WorkflowsResult"]:[],...e?["WriteHook"]:[]];export{j as a,M as b,Q as c,Z as d,K as e,ee as f,te as g,H as h,z as i,ne as j,se as k,re as l,oe as m,D as n,ae as o,I as p,U as q,f as r,V as s,G as t,J as u,Y as v,X as w};
333
+ },`,stub:f("paymentStub: LunoraPayment","ctx.payments: no payment configured. Pass `payment` to createShardDO().",P,{cast:" as unknown as LunoraPayment",sync:!0})}:{build:"",configField:"",contextField:"",imports:[],stub:""},ae=(e,r,t,n,a)=>["AdvisorProcedure","AdvisoryFinding","DatabaseWriterLike","DataMigrationLike","DispatchBookmark","ExportRow",...n?["FlagsResult"]:[],"ImportShardResult","KeyRange","MaskPoliciesResult","MigrationRunResult","QueryReadScope",...t?["QueuesResult"]:[],"RelatedPage","RunShardApplyCdcArgs","RunShardExportArgs","RunShardFindRelatedArgs","RunShardImportArgs","RunShardMigrationArgs","RlsPoliciesResult","RunShardRankBeforeArgs","RunShardRankPageArgs","RunShardWriteArgs","RunShardWriteResult","SchedulerLike","SensitiveScope",...a?["SearchBackfillProgress"]:[],"TransactionHeadroomTracker","SchemaLike","ShardDOState","DeliveryAuthorization","ShardRankPageResult","SqlExec","StorageRulesResult","StudioFeaturesResult","SubscriptionIdentity","SystemReaderStorageLike","TelemetrySink",...e?["VectorBackfillProgress"]:[],...r?["WorkflowsResult"]:[],...e?["WriteHook"]:[]];export{j as a,M as b,Q as c,Z as d,K as e,ee as f,te as g,H as h,z as i,ne as j,se as k,re as l,oe as m,D as n,ae as o,I as p,U as q,f as r,J as s,G as t,V as u,Y as v,X as w};
@@ -0,0 +1,13 @@
1
+ import{LunoraError as y}from"@lunora/errors";import{v as A}from"./parse-validator-iVTounLK.mjs";import{R as I}from"./reserved-words-CW1QFbTd.mjs";import{acceptsAbsentIr as R}from"./LUNORA_ERROR_CODES-CIAJQeKB.mjs";import{n as E}from"./dispatch-namespace-DwTjD7BU.mjs";const k=/^(?:"(?:[^"\\]|\\(?:["\\/bfnrt]|u[0-9A-Fa-f]{4}))*"|'[^'\\]*'|-?\d+(?:\.\d+)?|true|false|null)$/u,O=e=>Object.keys(e).filter(n=>A(e[n])),B=e=>O(e.args).length>0,F=`// GENERATED by @lunora/codegen — do not edit.
2
+ // Run \`lunora codegen\` to regenerate.
3
+
4
+ `,G=(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,U=/^[\w./-]+$/u,w=(e,n)=>{if(!b.test(e)||I.has(e))throw new y("INTERNAL",`@lunora/codegen: ${n} is not a valid JS identifier: ${JSON.stringify(e)}`)},V=(e,n)=>{if(!b.test(e))throw new y("INTERNAL",`@lunora/codegen: ${n} is not a valid JS identifier: ${JSON.stringify(e)}`)},H=e=>e.charAt(0).toUpperCase()+e.slice(1),g=e=>b.test(e)?e:JSON.stringify(e),j=e=>e==="__proto__"?`[${JSON.stringify(e)}]`:g(e),D=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))},Y=(e,n,r)=>{const[t,l]=r==="type"?[g,";"]:[j,","],d={children:new Map};for(const[o,h]of D(e)){let a=d;for(const m of E(o)){let c=a.children.get(m);c===void 0&&(c={children:new Map},a.children.set(m,c)),a=c}a.file={entries:h,path:o}}const u=o=>o.file?.path??u(o.children.values().next().value),p=(o,h)=>{const a=" ".repeat(h),{entries:m=[],path:c=""}=o.file??{},$=m.find(s=>o.children.has(s.exportName));if($!==void 0){const s=u(o.children.get($.exportName));throw new y("NAMESPACE_COLLISION",`Namespace collision: the export "${$.exportName}" of "${c}" and "${s}" both resolve to api.${[...E(c),$.exportName].join(".")}. Rename the export or the folder.`)}const S=m.toSorted((s,f)=>s.exportName.localeCompare(f.exportName)).map(s=>`${a}${n(s)}`),_=[...o.children.entries()].toSorted(([s],[f])=>s.localeCompare(f)).map(([s,f])=>`${a}${t(s)}: {
5
+ ${p(f,h+1).join(`
6
+ `)}
7
+ ${a}}${l}`);return[...S,..._]};return p(d,1).join(`
8
+ `)},x={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"},L=e=>{if(e===void 0)return"unknown";if(!k.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=x[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 L(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 R(n)?`${r}?: ${i(n)}`:`${r}: ${i(n)}`},W=e=>{const n=Object.entries(e);return n.length===0?"{}":`{ ${n.map(([r,t])=>N(r,t)).join("; ")} }`},z=e=>e.kind==="optional"||!!e.column?.hasDefault,C=e=>e.kind==="optional"&&e.inner?e.inner:e,Z=e=>{w(e.name,"table name");const n=Object.entries(e.shape).map(([t,l])=>{const d=C(l),u=i(d),p=g(t);return z(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{F as G,U as I,k as L,w as a,Y as b,j as c,G as d,g as e,Z as f,V as g,z as h,B as i,H as p,W as r,O as s,C as u,i as v};
@@ -1 +1 @@
1
- import{posix as h,dirname as w,join as F}from"node:path";import{Node as l,SyntaxKind as g,DiagnosticCategory as K}from"ts-morph";import{lunoraRelativePath as B}from"./isTestPath-Cdv_LoVU.mjs";let v,S;const Oe=e=>{const t=v,n=[];v=n;try{return{erased:n,value:e()}}finally{v=t}},Ue=e=>{v?.push(...e)},V=e=>{for(const t of e.getAncestors())if(l.isVariableDeclaration(t))return t.getName()},y=(e,t)=>{v?.push({exportName:V(e),filePath:e.getSourceFile().getFilePath(),line:e.getStartLineNumber(),rendered:t})},Pe=e=>{S!==void 0&&y(S,e)},Le=(e,t)=>{const n=S;S=e;try{return t()}finally{S=n}},W=(e,t)=>{const n=e.exportName??`line ${e.line.toString()}`;return{cacheKey:`procedure_return_type_erased:${t}:${n}`,categories:["SCHEMA"],description:"Codegen renders a procedure's return type into `_generated/`, where only names that resolve from that directory may appear. A type it can neither name nor reproduce structurally — a class instance, a call or index signature, a recursive or very deeply nested shape — is emitted as `unknown` instead, so callers lose the shape while the runtime still returns it.",detail:`\`${n}\` in \`${t}\` (line ${e.line.toString()}) returns \`${e.rendered}\`, which codegen could not reproduce — its generated type is \`unknown\`.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:e.exportName,filePath:t,line:e.line,rendered:e.rendered},name:"procedure_return_type_erased",remediation:"Declare the shape explicitly with `.output(...)`, or export the type from the module that declares it so codegen can name it. A class instance cannot cross the wire at all — return a plain object.",title:"Procedure return type is missing from the generated type"}},Fe=(e,t)=>{const n=new Map;for(const r of e){const s=W(r,B(t,r.filePath));n.set(s.cacheKey,s)}return[...n.values()].toSorted((r,s)=>r.cacheKey.localeCompare(s.cacheKey))},q=/\bany\b(?!\s*(?:\?\s*)?:)/u,G=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/gu,X=e=>q.test(e.replaceAll(G,"")),H="/_generated/",J=e=>{const t=[e.getSymbol(),e.getAliasSymbol()].flatMap(n=>n?.getDeclarations()??[]);return t.length>0&&t.every(n=>n.getSourceFile().getSymbol()===void 0)},Y=/^(?<quote>["'])(?<specifier>.*)\k<quote>$/su,x=e=>{for(const t of e.getAncestors())if(l.isModuleDeclaration(t)){const n=Y.exec(t.getName());if(n?.groups?.specifier!==void 0)return n.groups.specifier}},M=new WeakMap,z=(e,t)=>{const n=e.getSymbol();if(n===void 0)return;let r=M.get(n.compilerSymbol);return r===void 0&&(r=new Map,M.set(n.compilerSymbol,r)),r.has(t)||r.set(t,n.getExport(t)??e.getExportSymbols().find(s=>s.getName()===t)),r.get(t)},C=(e,t)=>e.getNamespaceImport()!==void 0||e.getNamedImports().some(n=>n.getName()===t),Q=(e,t,n)=>e.getModuleSpecifierValue()===t&&C(e,n)?n:void 0,Z=(e,t)=>{const n=e.getDefaultImport();if(n===void 0)return;const r=n.getSymbol();return(r?.getAliasedSymbol()??r)?.getDeclarations().includes(t)===!0?"default":void 0},ee=(e,t,n)=>{if(!C(e,n))return;const r=e.getModuleSpecifierSourceFile(),s=r===void 0?void 0:z(r,n);return(s?.getAliasedSymbol()??s)?.getDeclarations().includes(t)===!0?n:void 0},te=/^\.\.?(?:$|\/)/u,ne=new Map([[".cjs",".cjs"],[".cts",".cjs"],[".d.ts",".js"],[".js",".js"],[".jsx",".jsx"],[".mjs",".mjs"],[".mts",".mjs"],[".ts",".js"],[".tsx",".js"]]),re=(e,t)=>{const n=t.getModuleSpecifierValue();if(!te.test(n))return;const r=t.getModuleSpecifierSourceFile(),s=r===void 0?void 0:ne.get(r.getExtension());if(r===void 0||s===void 0)return;const i=`${h.join(r.getDirectoryPath(),r.getBaseNameWithoutExtension())}${s}`,o=h.relative(e.getDirectoryPath(),i);return o.startsWith(".")?o:`./${o}`},se=(e,t,n)=>{const r=x(t);for(const s of e.getImportDeclarations()){const i=r===void 0?Z(s,t)??ee(s,t,n):Q(s,r,n);if(i!==void 0)return{exportName:i,specifier:re(e,s)??s.getModuleSpecifierValue()}}},oe=(e,t)=>Object.keys(t.getProject().getCompilerOptions().paths??{}).some(n=>{const r=n.indexOf("*");return r===-1?e===n:e.startsWith(n.slice(0,r))&&e.endsWith(n.slice(r+1))}),f={kind:"verbatim"},p={kind:"expand"},ie=new Set([g.ClassDeclaration,g.EnumDeclaration,g.EnumMember,g.InterfaceDeclaration,g.TypeAliasDeclaration]),ae=e=>x(e)!==void 0||l.isExportable(e)&&e.isExported(),ce=(e,t)=>new RegExp(String.raw`(?<![$\w])${t.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`)}(?![$\w])`,"u").test(e),O=(e,t,n,r)=>{const s=e.getSourceFile();if(s.getSymbol()===void 0&&x(e)===void 0||!ie.has(e.getKind()))return f;const i=s.getFilePath();if(i.includes(H))return f;if(i===n)return p;const o=l.isEnumMember(e)?e.getParent():e;if(!l.hasName(o))return p;const c=se(t.getSourceFile(),o,o.getName());return c===void 0?ae(o)||!ce(r(),o.getName())?f:p:oe(c.specifier,t)?p:{kind:"qualify",qualified:c}},ue=new Set([g.ClassDeclaration,g.EnumDeclaration,g.FunctionDeclaration,g.ModuleDeclaration]),_=e=>{const t=e?.getDeclarations()??[];return t.length>0&&t.every(n=>n.getSourceFile().getSymbol()===void 0)},le=e=>{for(const t of e.getDeclarations()){const n=t.getFirstChildByKind(g.ComputedPropertyName);if(n!==void 0){let r=n.getExpression();for(;l.isPropertyAccessExpression(r);)r=r.getExpression();return r}}},ge=(e,t)=>{if(e.getProperties().some(s=>{if(!s.getName().startsWith("__@"))return!1;const i=le(s);return i===void 0||!_(i.getSymbol())}))return!0;const r=e.getSymbol();return r!==void 0&&r.getDeclarations().some(s=>ue.has(s.getKind()))&&!_(r)&&t().startsWith("typeof ")},U=(e,t,n)=>{const r=e.getAliasSymbol(),s=e.getSymbol(),i=new Set((r??s)?.getDeclarations());let o=!1,c;const a=()=>(c??=e.getText(t),c);for(const u of[s,r].flatMap(d=>d?.getDeclarations()??[])){const d=O(u,t,n,a);if(d.kind==="qualify"&&i.has(u))return d;o||=d.kind!=="verbatim"}return o||ge(e,a)?p:f},de=(e,t,n)=>{const r=l.isPropertySignature(e)||l.isPropertyDeclaration(e)?e.getTypeNode():void 0;if(r===void 0)return f;let s=!1;for(const i of[r,...r.getDescendantsOfKind(g.TypeReference)].filter(o=>l.isTypeReference(o))){const o=i.getTypeName().getSymbol();for(const c of(o?.getAliasedSymbol()??o)?.getDeclarations()??[]){const a=O(c,t,n,()=>i.getText());if(a.kind==="qualify")return a;s||=a.kind!=="verbatim"}}return s?p:f},fe=/^[A-Za-z_$][\w$]*$/u,me=e=>fe.test(e)?e:JSON.stringify(e),P=e=>{const t=[...e.getTypeArguments()];return e.isUnion()&&t.push(...e.getUnionTypes()),e.isIntersection()&&t.push(...e.getIntersectionTypes()),t},A=e=>!e.isObject()||e.isArray()||e.isTuple()||e.getCallSignatures().length>0||e.getConstructSignatures().length>0?!1:e.getStringIndexType()===void 0&&e.getNumberIndexType()===void 0&&!e.getProperties().some(t=>t.getName().startsWith("__@")),T=(e,t,n,r=new Set)=>r.has(e)?!1:(r.add(e),U(e,t,n).kind!=="verbatim"||P(e).some(s=>T(s,t,n,r))?!0:A(e)?e.getProperties().some(s=>s.getDeclarations().some(i=>de(i,t,n).kind!=="verbatim")?!0:T(s.getTypeAtLocation(t),t,n,r)):!1),pe=(e,t)=>{const n=e.getValueDeclaration()??e.getDeclarations()[0];return n&&(l.isPropertySignature(n)||l.isPropertyDeclaration(n))&&n.hasQuestionToken()?!0:t.isUnion()&&t.getUnionTypes().some(r=>r.isUndefined())},L=(e,t)=>e!==void 0&&(A(e)||e.isString()||e.isNumber()||e.isBigInt()||e.isBoolean()||e.isLiteral()||e.isBooleanLiteral()||e.isEnumLiteral()||e.isTemplateLiteral()||e.isNull()||e.isUndefined()||e.isAny()||e.isUnknown()||e.isNever()||e.isVoid())?t:`(${t})`,ve=32,Se=8,ye=(e,t,n,r,s,i)=>{const o=e.getArrayElementType(),c=o?i(o,t,n,r,s):void 0;if(c!==void 0)return`${L(o,c)}[]`},Ee=(e,t,n,r,s,i)=>{const o=[];for(const c of e.getUnionTypes()){const a=i(c,t,n,r,s);if(a===void 0)return;o.push(a)}return o.join(" | ")},be=(e,t,n,r,s,i)=>{const o=[];for(const c of e.getIntersectionTypes()){const a=i(c,t,n,r,s);if(a===void 0)return;o.push(L(c,a))}return o.join(" & ")},Te=(e,t,n,r,s,i)=>{if(!A(e))return;const o=[];for(const c of e.getProperties()){const a=c.getTypeAtLocation(t),u=pe(c,a),d=u&&a.isUnion()?a.getUnionTypes().filter(N=>!N.isUndefined()):[a],D=[];for(const N of d){const I=i(N,t,n,r+1,s);if(I===void 0)return;D.push(I)}o.push(`${me(c.getName())}${u?"?":""}: ${D.join(" | ")}`)}return o.length>0?`{ ${o.join("; ")} }`:"{}"},Ae=e=>{const t=e.getLiteralValue();return typeof t=="string"?JSON.stringify(t):typeof t=="number"?String(t):void 0},Ne=e=>[e.getSymbol(),e.getAliasSymbol()].flatMap(t=>t?.getDeclarations()??[]).some(t=>l.isClassDeclaration(t)||l.isClassExpression(t)),E=(e,t,n,r,s=new Set)=>{if(r.has(e)||s.has(e))return!1;if(n>ve)return!0;const i=new Set(r).add(e);if(P(e).some(u=>E(u,t,n+1,i,s)))return!0;const o=e.getArrayElementType();if(o!==void 0)return E(o,t,n+1,i,s);if(J(e))return s.add(e),!1;if(e.getCallSignatures().length>0||e.getConstructSignatures().length>0||[e.getSymbol(),e.getAliasSymbol()].flatMap(u=>u?.getDeclarations()??[]).some(u=>l.isClassDeclaration(u)||l.isClassExpression(u)))return!0;const a=A(e)&&e.getProperties().some(u=>E(u.getTypeAtLocation(t),t,n+1,i,s));return a||s.add(e),a},xe=(e,t,n,r,s,i,o)=>{const c=[];for(const a of t.getAliasSymbol()===void 0?t.getTypeArguments():t.getAliasTypeArguments()){const u=o(a,n,r,s+1,i);if(u===void 0)return;c.push(u)}return`import("${e.specifier}").${e.exportName}${c.length>0?`<${c.join(", ")}>`:""}`},De=e=>[e.getSymbol(),e.getAliasSymbol()].flatMap(t=>t?.getDeclarations()??[]).some(t=>l.isEnumDeclaration(t)||l.isEnumMember(t)),m=(e,t,n,r,s)=>{if(r>Se||s.has(e))return;const i=U(e,t,n);if(i.kind==="verbatim"&&!T(e,t,n))return e.getText(t);const o=new Set(s).add(e);if(!Ne(e)){if(e.isEnumLiteral())return Ae(e);if(i.kind==="qualify"&&!De(e)){const c=xe(i.qualified,e,t,n,r,o,m);if(c!==void 0)return c}return e.isArray()?ye(e,t,n,r,o,m):e.isUnion()?Ee(e,t,n,r,o,m):e.isIntersection()?be(e,t,n,r,o,m):Te(e,t,n,r,o,m)}},R=new WeakMap,Ie=e=>{const t=R.get(e.compilerNode);if(t)return t;const n=e.getPreEmitDiagnostics().filter(r=>r.getCategory()===K.Error);return R.set(e.compilerNode,n),n},b=e=>{const t=e.getMessageText();return typeof t=="string"?t:t.getMessageText()},he=/is of type 'unknown'|on type '\{\}'/,we=e=>he.test(e),Me=/has no exported member '([^']+)'/,_e=(e,t,n,r)=>{const s=e.getSourceFile();for(const i of e.getDescendantsOfKind(g.Identifier))for(const o of i.getSymbol()?.getDeclarations()??[]){const c=o.getStart();if(o.getSourceFile()!==s||c>=n&&c<=r)continue;const a=t.find(u=>{const d=u.getStart();return d!==void 0&&d>=o.getStart()&&d<=o.getEnd()});if(a!==void 0)return b(a)}},$=e=>{const t=e.getStart(),n=e.getEnd(),r=Ie(e.getSourceFile()),s=r.find(a=>{const u=a.getStart();return u!==void 0&&u>=t&&u<=n});if(s===void 0){const a=_e(e,r,t,n);return a===void 0?void 0:{derivative:!0,message:a}}const i=b(s);if(!we(i))return{derivative:!1,message:i};const o=new Set(e.getDescendantsOfKind(g.Identifier).map(a=>a.getText())),c=r.find(a=>{const u=Me.exec(b(a))?.[1];return u!==void 0&&o.has(u)});return{derivative:!0,message:c?`${i}; caused by: ${b(c)}`:i}},Re=e=>{const t=e.getProject().getFileSystem();let n=w(e.getFilePath());for(;;){const r=F(n,"package.json");if(t.fileExistsSync(r)){let i;try{i=JSON.parse(t.readFileSync(r))}catch{return}const o=typeof i=="object"&&i!==null?i.name:void 0;return typeof o=="string"?o:void 0}const s=w(n);if(s===n)return;n=s}},k=e=>{const t=e.getSymbol()??e.getAliasSymbol(),n=t?.getName()==="SseEvent"?t.getDeclarations()[0]:void 0;return n!==void 0&&Re(n.getSourceFile())==="@lunora/server"},$e=e=>{const t=e.isUnion()?e.getUnionTypes():[e];if(t.some(n=>k(n)))return t.flatMap(n=>{const r=k(n)?n.getTypeArguments()[0]??n:n;return r.isUnion()?r.getUnionTypes():[r]})},j=(e,t)=>{const n=e.getText(t);if(!n||n==="any"||n==="never"||n==="unknown"){const s=$(t);return s!==void 0&&(n!=="unknown"||s.derivative)&&y(t,`${n||"any"} (${s.message})`),"unknown"}if(X(n)){const s=$(t);return s!==void 0&&y(t,`${n} (${s.message})`),"unknown"}if(E(e,t,0,new Set))return"unknown";const r=t.getSourceFile().getFilePath();if(T(e,t,r)){const s=m(e,t,r,0,new Set);return s===void 0&&y(t,n),s??"unknown"}return n},Ke=(e,t=!1)=>{const n=e.getType().getCallSignatures()[0];if(!n)return"unknown";let r=n.getReturnType();const i=(r.getSymbol()??r.getAliasSymbol())?.getName();if(i==="Promise"||i==="AsyncIterable"||i==="AsyncIterableIterator"||i==="AsyncGenerator"){const a=r.getTypeArguments()[0];a&&(r=a)}const o=t?$e(r):void 0;if(o===void 0)return j(r,e);const c=o.map(a=>j(a,e));return c.includes("unknown")?"unknown":[...new Set(c)].join(" | ")};export{T as a,Pe as b,Oe as c,Fe as d,m as e,X as i,Le as p,Ue as r,Ke as u};
1
+ import{posix as h,dirname as w,join as F}from"node:path";import{Node as l,SyntaxKind as g,DiagnosticCategory as K}from"ts-morph";import{lunoraRelativePath as B}from"./isTestPath-C3QumE88.mjs";let v,S;const Oe=e=>{const t=v,n=[];v=n;try{return{erased:n,value:e()}}finally{v=t}},Ue=e=>{v?.push(...e)},V=e=>{for(const t of e.getAncestors())if(l.isVariableDeclaration(t))return t.getName()},y=(e,t)=>{v?.push({exportName:V(e),filePath:e.getSourceFile().getFilePath(),line:e.getStartLineNumber(),rendered:t})},Pe=e=>{S!==void 0&&y(S,e)},Le=(e,t)=>{const n=S;S=e;try{return t()}finally{S=n}},W=(e,t)=>{const n=e.exportName??`line ${e.line.toString()}`;return{cacheKey:`procedure_return_type_erased:${t}:${n}`,categories:["SCHEMA"],description:"Codegen renders a procedure's return type into `_generated/`, where only names that resolve from that directory may appear. A type it can neither name nor reproduce structurally — a class instance, a call or index signature, a recursive or very deeply nested shape — is emitted as `unknown` instead, so callers lose the shape while the runtime still returns it.",detail:`\`${n}\` in \`${t}\` (line ${e.line.toString()}) returns \`${e.rendered}\`, which codegen could not reproduce — its generated type is \`unknown\`.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:e.exportName,filePath:t,line:e.line,rendered:e.rendered},name:"procedure_return_type_erased",remediation:"Declare the shape explicitly with `.output(...)`, or export the type from the module that declares it so codegen can name it. A class instance cannot cross the wire at all — return a plain object.",title:"Procedure return type is missing from the generated type"}},Fe=(e,t)=>{const n=new Map;for(const r of e){const s=W(r,B(t,r.filePath));n.set(s.cacheKey,s)}return[...n.values()].toSorted((r,s)=>r.cacheKey.localeCompare(s.cacheKey))},q=/\bany\b(?!\s*(?:\?\s*)?:)/u,G=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/gu,X=e=>q.test(e.replaceAll(G,"")),H="/_generated/",J=e=>{const t=[e.getSymbol(),e.getAliasSymbol()].flatMap(n=>n?.getDeclarations()??[]);return t.length>0&&t.every(n=>n.getSourceFile().getSymbol()===void 0)},Y=/^(?<quote>["'])(?<specifier>.*)\k<quote>$/su,x=e=>{for(const t of e.getAncestors())if(l.isModuleDeclaration(t)){const n=Y.exec(t.getName());if(n?.groups?.specifier!==void 0)return n.groups.specifier}},M=new WeakMap,z=(e,t)=>{const n=e.getSymbol();if(n===void 0)return;let r=M.get(n.compilerSymbol);return r===void 0&&(r=new Map,M.set(n.compilerSymbol,r)),r.has(t)||r.set(t,n.getExport(t)??e.getExportSymbols().find(s=>s.getName()===t)),r.get(t)},C=(e,t)=>e.getNamespaceImport()!==void 0||e.getNamedImports().some(n=>n.getName()===t),Q=(e,t,n)=>e.getModuleSpecifierValue()===t&&C(e,n)?n:void 0,Z=(e,t)=>{const n=e.getDefaultImport();if(n===void 0)return;const r=n.getSymbol();return(r?.getAliasedSymbol()??r)?.getDeclarations().includes(t)===!0?"default":void 0},ee=(e,t,n)=>{if(!C(e,n))return;const r=e.getModuleSpecifierSourceFile(),s=r===void 0?void 0:z(r,n);return(s?.getAliasedSymbol()??s)?.getDeclarations().includes(t)===!0?n:void 0},te=/^\.\.?(?:$|\/)/u,ne=new Map([[".cjs",".cjs"],[".cts",".cjs"],[".d.ts",".js"],[".js",".js"],[".jsx",".jsx"],[".mjs",".mjs"],[".mts",".mjs"],[".ts",".js"],[".tsx",".js"]]),re=(e,t)=>{const n=t.getModuleSpecifierValue();if(!te.test(n))return;const r=t.getModuleSpecifierSourceFile(),s=r===void 0?void 0:ne.get(r.getExtension());if(r===void 0||s===void 0)return;const i=`${h.join(r.getDirectoryPath(),r.getBaseNameWithoutExtension())}${s}`,o=h.relative(e.getDirectoryPath(),i);return o.startsWith(".")?o:`./${o}`},se=(e,t,n)=>{const r=x(t);for(const s of e.getImportDeclarations()){const i=r===void 0?Z(s,t)??ee(s,t,n):Q(s,r,n);if(i!==void 0)return{exportName:i,specifier:re(e,s)??s.getModuleSpecifierValue()}}},oe=(e,t)=>Object.keys(t.getProject().getCompilerOptions().paths??{}).some(n=>{const r=n.indexOf("*");return r===-1?e===n:e.startsWith(n.slice(0,r))&&e.endsWith(n.slice(r+1))}),f={kind:"verbatim"},p={kind:"expand"},ie=new Set([g.ClassDeclaration,g.EnumDeclaration,g.EnumMember,g.InterfaceDeclaration,g.TypeAliasDeclaration]),ae=e=>x(e)!==void 0||l.isExportable(e)&&e.isExported(),ce=(e,t)=>new RegExp(String.raw`(?<![$\w])${t.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`)}(?![$\w])`,"u").test(e),O=(e,t,n,r)=>{const s=e.getSourceFile();if(s.getSymbol()===void 0&&x(e)===void 0||!ie.has(e.getKind()))return f;const i=s.getFilePath();if(i.includes(H))return f;if(i===n)return p;const o=l.isEnumMember(e)?e.getParent():e;if(!l.hasName(o))return p;const c=se(t.getSourceFile(),o,o.getName());return c===void 0?ae(o)||!ce(r(),o.getName())?f:p:oe(c.specifier,t)?p:{kind:"qualify",qualified:c}},ue=new Set([g.ClassDeclaration,g.EnumDeclaration,g.FunctionDeclaration,g.ModuleDeclaration]),_=e=>{const t=e?.getDeclarations()??[];return t.length>0&&t.every(n=>n.getSourceFile().getSymbol()===void 0)},le=e=>{for(const t of e.getDeclarations()){const n=t.getFirstChildByKind(g.ComputedPropertyName);if(n!==void 0){let r=n.getExpression();for(;l.isPropertyAccessExpression(r);)r=r.getExpression();return r}}},ge=(e,t)=>{if(e.getProperties().some(s=>{if(!s.getName().startsWith("__@"))return!1;const i=le(s);return i===void 0||!_(i.getSymbol())}))return!0;const r=e.getSymbol();return r!==void 0&&r.getDeclarations().some(s=>ue.has(s.getKind()))&&!_(r)&&t().startsWith("typeof ")},U=(e,t,n)=>{const r=e.getAliasSymbol(),s=e.getSymbol(),i=new Set((r??s)?.getDeclarations());let o=!1,c;const a=()=>(c??=e.getText(t),c);for(const u of[s,r].flatMap(d=>d?.getDeclarations()??[])){const d=O(u,t,n,a);if(d.kind==="qualify"&&i.has(u))return d;o||=d.kind!=="verbatim"}return o||ge(e,a)?p:f},de=(e,t,n)=>{const r=l.isPropertySignature(e)||l.isPropertyDeclaration(e)?e.getTypeNode():void 0;if(r===void 0)return f;let s=!1;for(const i of[r,...r.getDescendantsOfKind(g.TypeReference)].filter(o=>l.isTypeReference(o))){const o=i.getTypeName().getSymbol();for(const c of(o?.getAliasedSymbol()??o)?.getDeclarations()??[]){const a=O(c,t,n,()=>i.getText());if(a.kind==="qualify")return a;s||=a.kind!=="verbatim"}}return s?p:f},fe=/^[A-Za-z_$][\w$]*$/u,me=e=>fe.test(e)?e:JSON.stringify(e),P=e=>{const t=[...e.getTypeArguments()];return e.isUnion()&&t.push(...e.getUnionTypes()),e.isIntersection()&&t.push(...e.getIntersectionTypes()),t},A=e=>!e.isObject()||e.isArray()||e.isTuple()||e.getCallSignatures().length>0||e.getConstructSignatures().length>0?!1:e.getStringIndexType()===void 0&&e.getNumberIndexType()===void 0&&!e.getProperties().some(t=>t.getName().startsWith("__@")),T=(e,t,n,r=new Set)=>r.has(e)?!1:(r.add(e),U(e,t,n).kind!=="verbatim"||P(e).some(s=>T(s,t,n,r))?!0:A(e)?e.getProperties().some(s=>s.getDeclarations().some(i=>de(i,t,n).kind!=="verbatim")?!0:T(s.getTypeAtLocation(t),t,n,r)):!1),pe=(e,t)=>{const n=e.getValueDeclaration()??e.getDeclarations()[0];return n&&(l.isPropertySignature(n)||l.isPropertyDeclaration(n))&&n.hasQuestionToken()?!0:t.isUnion()&&t.getUnionTypes().some(r=>r.isUndefined())},L=(e,t)=>e!==void 0&&(A(e)||e.isString()||e.isNumber()||e.isBigInt()||e.isBoolean()||e.isLiteral()||e.isBooleanLiteral()||e.isEnumLiteral()||e.isTemplateLiteral()||e.isNull()||e.isUndefined()||e.isAny()||e.isUnknown()||e.isNever()||e.isVoid())?t:`(${t})`,ve=32,Se=8,ye=(e,t,n,r,s,i)=>{const o=e.getArrayElementType(),c=o?i(o,t,n,r,s):void 0;if(c!==void 0)return`${L(o,c)}[]`},Ee=(e,t,n,r,s,i)=>{const o=[];for(const c of e.getUnionTypes()){const a=i(c,t,n,r,s);if(a===void 0)return;o.push(a)}return o.join(" | ")},be=(e,t,n,r,s,i)=>{const o=[];for(const c of e.getIntersectionTypes()){const a=i(c,t,n,r,s);if(a===void 0)return;o.push(L(c,a))}return o.join(" & ")},Te=(e,t,n,r,s,i)=>{if(!A(e))return;const o=[];for(const c of e.getProperties()){const a=c.getTypeAtLocation(t),u=pe(c,a),d=u&&a.isUnion()?a.getUnionTypes().filter(N=>!N.isUndefined()):[a],D=[];for(const N of d){const I=i(N,t,n,r+1,s);if(I===void 0)return;D.push(I)}o.push(`${me(c.getName())}${u?"?":""}: ${D.join(" | ")}`)}return o.length>0?`{ ${o.join("; ")} }`:"{}"},Ae=e=>{const t=e.getLiteralValue();return typeof t=="string"?JSON.stringify(t):typeof t=="number"?String(t):void 0},Ne=e=>[e.getSymbol(),e.getAliasSymbol()].flatMap(t=>t?.getDeclarations()??[]).some(t=>l.isClassDeclaration(t)||l.isClassExpression(t)),E=(e,t,n,r,s=new Set)=>{if(r.has(e)||s.has(e))return!1;if(n>ve)return!0;const i=new Set(r).add(e);if(P(e).some(u=>E(u,t,n+1,i,s)))return!0;const o=e.getArrayElementType();if(o!==void 0)return E(o,t,n+1,i,s);if(J(e))return s.add(e),!1;if(e.getCallSignatures().length>0||e.getConstructSignatures().length>0||[e.getSymbol(),e.getAliasSymbol()].flatMap(u=>u?.getDeclarations()??[]).some(u=>l.isClassDeclaration(u)||l.isClassExpression(u)))return!0;const a=A(e)&&e.getProperties().some(u=>E(u.getTypeAtLocation(t),t,n+1,i,s));return a||s.add(e),a},xe=(e,t,n,r,s,i,o)=>{const c=[];for(const a of t.getAliasSymbol()===void 0?t.getTypeArguments():t.getAliasTypeArguments()){const u=o(a,n,r,s+1,i);if(u===void 0)return;c.push(u)}return`import("${e.specifier}").${e.exportName}${c.length>0?`<${c.join(", ")}>`:""}`},De=e=>[e.getSymbol(),e.getAliasSymbol()].flatMap(t=>t?.getDeclarations()??[]).some(t=>l.isEnumDeclaration(t)||l.isEnumMember(t)),m=(e,t,n,r,s)=>{if(r>Se||s.has(e))return;const i=U(e,t,n);if(i.kind==="verbatim"&&!T(e,t,n))return e.getText(t);const o=new Set(s).add(e);if(!Ne(e)){if(e.isEnumLiteral())return Ae(e);if(i.kind==="qualify"&&!De(e)){const c=xe(i.qualified,e,t,n,r,o,m);if(c!==void 0)return c}return e.isArray()?ye(e,t,n,r,o,m):e.isUnion()?Ee(e,t,n,r,o,m):e.isIntersection()?be(e,t,n,r,o,m):Te(e,t,n,r,o,m)}},R=new WeakMap,Ie=e=>{const t=R.get(e.compilerNode);if(t)return t;const n=e.getPreEmitDiagnostics().filter(r=>r.getCategory()===K.Error);return R.set(e.compilerNode,n),n},b=e=>{const t=e.getMessageText();return typeof t=="string"?t:t.getMessageText()},he=/is of type 'unknown'|on type '\{\}'/,we=e=>he.test(e),Me=/has no exported member '([^']+)'/,_e=(e,t,n,r)=>{const s=e.getSourceFile();for(const i of e.getDescendantsOfKind(g.Identifier))for(const o of i.getSymbol()?.getDeclarations()??[]){const c=o.getStart();if(o.getSourceFile()!==s||c>=n&&c<=r)continue;const a=t.find(u=>{const d=u.getStart();return d!==void 0&&d>=o.getStart()&&d<=o.getEnd()});if(a!==void 0)return b(a)}},$=e=>{const t=e.getStart(),n=e.getEnd(),r=Ie(e.getSourceFile()),s=r.find(a=>{const u=a.getStart();return u!==void 0&&u>=t&&u<=n});if(s===void 0){const a=_e(e,r,t,n);return a===void 0?void 0:{derivative:!0,message:a}}const i=b(s);if(!we(i))return{derivative:!1,message:i};const o=new Set(e.getDescendantsOfKind(g.Identifier).map(a=>a.getText())),c=r.find(a=>{const u=Me.exec(b(a))?.[1];return u!==void 0&&o.has(u)});return{derivative:!0,message:c?`${i}; caused by: ${b(c)}`:i}},Re=e=>{const t=e.getProject().getFileSystem();let n=w(e.getFilePath());for(;;){const r=F(n,"package.json");if(t.fileExistsSync(r)){let i;try{i=JSON.parse(t.readFileSync(r))}catch{return}const o=typeof i=="object"&&i!==null?i.name:void 0;return typeof o=="string"?o:void 0}const s=w(n);if(s===n)return;n=s}},k=e=>{const t=e.getSymbol()??e.getAliasSymbol(),n=t?.getName()==="SseEvent"?t.getDeclarations()[0]:void 0;return n!==void 0&&Re(n.getSourceFile())==="@lunora/server"},$e=e=>{const t=e.isUnion()?e.getUnionTypes():[e];if(t.some(n=>k(n)))return t.flatMap(n=>{const r=k(n)?n.getTypeArguments()[0]??n:n;return r.isUnion()?r.getUnionTypes():[r]})},j=(e,t)=>{const n=e.getText(t);if(!n||n==="any"||n==="never"||n==="unknown"){const s=$(t);return s!==void 0&&(n!=="unknown"||s.derivative)&&y(t,`${n||"any"} (${s.message})`),"unknown"}if(X(n)){const s=$(t);return s!==void 0&&y(t,`${n} (${s.message})`),"unknown"}if(E(e,t,0,new Set))return"unknown";const r=t.getSourceFile().getFilePath();if(T(e,t,r)){const s=m(e,t,r,0,new Set);return s===void 0&&y(t,n),s??"unknown"}return n},Ke=(e,t=!1)=>{const n=e.getType().getCallSignatures()[0];if(!n)return"unknown";let r=n.getReturnType();const i=(r.getSymbol()??r.getAliasSymbol())?.getName();if(i==="Promise"||i==="AsyncIterable"||i==="AsyncIterableIterator"||i==="AsyncGenerator"){const a=r.getTypeArguments()[0];a&&(r=a)}const o=t?$e(r):void 0;if(o===void 0)return j(r,e);const c=o.map(a=>j(a,e));return c.includes("unknown")?"unknown":[...new Set(c)].join(" | ")};export{T as a,Pe as b,Oe as c,Fe as d,m as e,X as i,Le as p,Ue as r,Ke as u};
@@ -1,4 +1,4 @@
1
- import{modelSources as pe,assertDistinctMembers as T,toPascalCase as l,referencedModels as W,generatedHeaderLines as f,commentText as p,argsChoice as $,stringLiteral as m,kotlinLiteral as w,allMethods as x,toSnakeCase as E,parseSpec as Ne,assertGeneratable as Oe,withDeclaredModels as Ce,unrepresentableFunctions as Le,undeclaredModels as Re}from"../packem_shared/isTypedSchema-CKzc3ioR.mjs";import{isTypedSchema as St}from"../packem_shared/isTypedSchema-CKzc3ioR.mjs";const We=async(e,n)=>{if(n.quicktype===void 0)return"";const t=pe(e);if(t.length===0)return"";const{InputData:r,JSONSchemaInput:a,JSONSchemaStore:i,quicktype:o}=await import("quicktype-core");class s extends i{fetch(){return Promise.resolve(void 0)}}const d=new a(new s);for(const g of t)await d.addSource({name:g.name,schema:JSON.stringify(g.schema)});const c=new r;c.addInput(d);const{lines:u}=await o({inputData:c,lang:n.quicktype.lang,rendererOptions:n.quicktype.rendererOptions??{}});return u.join(`
1
+ import{modelSources as pe,assertDistinctMembers as T,toPascalCase as l,referencedModels as W,generatedHeaderLines as f,commentText as p,argsChoice as $,stringLiteral as m,kotlinLiteral as w,allMethods as x,toSnakeCase as E,parseSpec as Oe,assertGeneratable as Ne,withDeclaredModels as Ce,unrepresentableFunctions as Le,undeclaredModels as Re}from"../packem_shared/isTypedSchema-CKzc3ioR.mjs";import{isTypedSchema as St}from"../packem_shared/isTypedSchema-CKzc3ioR.mjs";const We=async(e,n)=>{if(n.quicktype===void 0)return"";const t=pe(e);if(t.length===0)return"";const{InputData:r,JSONSchemaInput:a,JSONSchemaStore:i,quicktype:o}=await import("quicktype-core");class s extends i{fetch(){return Promise.resolve(void 0)}}const d=new a(new s);for(const g of t)await d.addSource({name:g.name,schema:JSON.stringify(g.schema)});const c=new r;c.addInput(d);const{lines:u}=await o({inputData:c,lang:n.quicktype.lang,rendererOptions:n.quicktype.rendererOptions??{}});return u.join(`
2
2
  `)},D=`${f("dart").map(e=>`// ${e}`).join(`
3
3
  `)}
4
4
 
@@ -21,7 +21,7 @@ publish_to: none
21
21
 
22
22
  environment:
23
23
  sdk: ^3.6.0
24
- `,De=new Set(["assert","break","case","catch","class","const","continue","default","do","else","enum","extends","false","final","finally","for","if","in","is","new","null","rethrow","return","super","switch","this","throw","true","try","var","void","while","with"]),j=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1);return De.has(t)?`${t}_`:t},de=e=>m(e).replaceAll("$",String.raw`\$`),Pe=e=>e.replaceAll(" == null ? [] : List<"," == null ? null : List<").replaceAll(/Map\.from\((?<source>[^()]*?)!\)/gu,"$<source> == null ? null : Map.from($<source>!)"),Z=" ".repeat(8),Ve=/^class (\w+) \{/u,Ke=/^class \w+ \{\n[\s\S]*?\n\}$/gmu,Ie=/^ {4}\w+\(\{\n([\s\S]*?)^ {4}\}\);$/mu,xe=/^ {8}(?:required )?this\.\w+,$/gmu,Fe=/^ {4}Map<String, dynamic> toJson\(\) => \{\n([\s\S]*?)^ {4}\};$/mu,qe=/^ {8}"(?:[^\\"]|\\.)*": .*,$/gmu,Ue=e=>e.replaceAll(Ke,n=>{const[,t]=Ie.exec(n)??[],[,r]=Fe.exec(n)??[];if(t===void 0||r===void 0)return n;const a=[...t.matchAll(xe)].map(d=>{const c=d[0].trim();return{field:c.slice(c.indexOf("this.")+5,-1),optional:!c.startsWith("required ")}}),i=[...r.matchAll(qe)],o=a.filter(d=>d.optional);if(a.length!==i.length){if(o.length===0)return n;throw new Error(`dart models: cannot place the optional-field guards in ${Ve.exec(n)?.[1]??"a generated class"} — ${String(a.length)} constructor parameter(s) against ${String(i.length)} toJson entr(ies). quicktype's Dart output has changed shape; \`guardOptionalFields\` in targets/dart.ts must be updated to match.`)}let s=r;for(const[d,c]of i.entries()){const u=a[d];if(!u?.optional)continue;const g=c[0],ke=g.slice(Z.length).replace(`${u.field} == null ? null : `,"");s=s.replace(g,`${Z}if (${u.field} != null) ${ke}`)}return n.replace(r,s)}),$e=e=>$(e,{none:"null",typed:()=>"LunoraClient.wireValue(args)",untyped:"args"}),me={declaration:"LunoraOptimistic? optimistic, LunoraOptimisticUpdate? optimisticUpdate, bool Function()? precondition",forward:"optimistic: optimistic, optimisticUpdate: optimisticUpdate, precondition: precondition"},X=e=>{const n=e.verb==="mutation"?`{String? shardKey, ${me.declaration}}`:"{String? shardKey}";return $(e,{none:n,typed:t=>`${t} args, ${n}`,untyped:`Object? args, ${n}`})},ye=(e,n)=>`${e}.fromJson(${n} as Map<String, dynamic>)`,Q=e=>{const n=e.verb==="mutation"?`, ${me.forward}`:"",t=`_client.${e.verb}("${de(e.functionPath)}", args: ${$e(e)}, shardKey: shardKey${n})`;return e.resultType===void 0?[` /// ${p(e.summary)}`,` Future<Object?> ${j(e.functionName)}(${X(e)}) => ${t};`].join(`
24
+ `,De=new Set(["assert","break","case","catch","class","const","continue","default","do","else","enum","extends","false","final","finally","for","if","in","is","new","null","rethrow","return","super","switch","this","throw","true","try","var","void","while","with"]),j=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1);return De.has(t)?`${t}_`:t},de=e=>m(e).replaceAll("$",String.raw`\$`),Pe=e=>e.replaceAll(" == null ? [] : List<"," == null ? null : List<").replaceAll(/Map\.from\((?<source>[^()]*?)!\)/gu,"$<source> == null ? null : Map.from($<source>!)"),Z=" ".repeat(8),Ve=/^class (\w+) \{/u,Ke=/^class \w+ \{\n[\s\S]*?\n\}$/gmu,Ie=/^ {4}\w+\(\{\n([\s\S]*?)^ {4}\}\);$/mu,xe=/^ {8}(?:required )?this\.\w+,$/gmu,Fe=/^ {4}Map<String, dynamic> toJson\(\) => \{\n([\s\S]*?)^ {4}\};$/mu,qe=/^ {8}"(?:[^\\"]|\\.)*": .*,$/gmu,Ue=e=>e.replaceAll(Ke,n=>{const[,t]=Ie.exec(n)??[],[,r]=Fe.exec(n)??[];if(t===void 0||r===void 0)return n;const a=[...t.matchAll(xe)].map(d=>{const c=d[0].trim();return{field:c.slice(c.indexOf("this.")+5,-1),optional:!c.startsWith("required ")}}),i=[...r.matchAll(qe)],o=a.filter(d=>d.optional);if(a.length!==i.length){if(o.length===0)return n;throw new Error(`dart models: cannot place the optional-field guards in ${Ve.exec(n)?.[1]??"a generated class"} — ${String(a.length)} constructor parameter(s) against ${String(i.length)} toJson entr(ies). quicktype's Dart output has changed shape; \`guardOptionalFields\` in targets/dart.ts must be updated to match.`)}let s=r;for(const[d,c]of i.entries()){const u=a[d];if(!u?.optional)continue;const g=c[0],ke=g.slice(Z.length).replace(`${u.field} == null ? null : `,"");s=s.replace(g,`${Z}if (${u.field} != null) ${ke}`)}return n.replace(r,s)}),$e=e=>$(e,{none:"null",typed:()=>"LunoraClient.wireValue(args)",untyped:"args"}),me={declaration:"LunoraOptimistic? optimistic, LunoraOptimisticUpdate? optimisticUpdate, bool Function()? precondition, bool onlineOnly = false",forward:"optimistic: optimistic, optimisticUpdate: optimisticUpdate, precondition: precondition, onlineOnly: onlineOnly"},X=e=>{const n=e.verb==="mutation"?`{String? shardKey, ${me.declaration}}`:"{String? shardKey}";return $(e,{none:n,typed:t=>`${t} args, ${n}`,untyped:`Object? args, ${n}`})},ye=(e,n)=>`${e}.fromJson(${n} as Map<String, dynamic>)`,Q=e=>{const n=e.verb==="mutation"?`, ${me.forward}`:"",t=`_client.${e.verb}("${de(e.functionPath)}", args: ${$e(e)}, shardKey: shardKey${n})`;return e.resultType===void 0?[` /// ${p(e.summary)}`,` Future<Object?> ${j(e.functionName)}(${X(e)}) => ${t};`].join(`
25
25
  `):[` /// ${p(e.summary)}`,` Future<${e.resultType}> ${j(e.functionName)}(${X(e)}) async =>`,` ${ye(e.resultType,`await ${t}`)};`].join(`
26
26
  `)},He=e=>{const n=$(e,{none:"",typed:o=>`${o} args`,untyped:"Object? args"}),t=n===""?"":`${n}, `,r=$e(e),a=`"${de(e.functionPath)}"`,i=`_client.watch(${a}, args: ${r})`;return[` /// live ${p(e.summary)} — re-runs on every write to the tables it reads.`,` LunoraUnsubscribe subscribe${l(e.functionName)}(`,` ${t}{LunoraDataCallback? onData, LunoraErrorCallback? onError}`,` ) => _client.subscribe(${a}, args: ${r}, onData: onData, onError: onError);`,"",` /// live ${p(e.summary)}, as a Stream — bind it with StreamBuilder.`,e.resultType===void 0?` Stream<Object?> watch${l(e.functionName)}(${n}) => ${i};`:[` Stream<${e.resultType}> watch${l(e.functionName)}(${n}) =>`,` ${i}.map((raw) => ${ye(e.resultType,"raw")});`].join(`
27
27
  `)].join(`
@@ -58,7 +58,7 @@ ${r}
58
58
  `,"pubspec.yaml":Me}},Ye={id:"dart",quicktype:{lang:"dart"},render:Je,requires:[],vendor:[{from:"lib",to:"lib"}]},P=`${f("go").map(e=>`// ${e}`).join(`
59
59
  `)}
60
60
 
61
- `,b="lunoraapi",N="lunorasdk",ze=`${N}/lunora`,Ze="1.22",F=e=>l(e),ee=(e,n)=>{const t=$(n,{none:"",typed:s=>`args ${s}, `,untyped:"args any, "}),r=$(n,{none:"nil",typed:()=>"args",untyped:"args"}),a=n.resultType??"any",i=`lunora.Verb${n.verb.charAt(0).toUpperCase()}${n.verb.slice(1)}`,o=`lunora.Call[${a}](a.client, ${i}, "${m(n.functionPath)}", ${r}, shardKey)`;return[`// ${F(n.functionName)} invokes ${p(n.summary)}.`,`func (a *${e}) ${F(n.functionName)}(${t}shardKey string) (${a}, error) {`,` return ${o}`,"}"].join(`
61
+ `,b="lunoraapi",O="lunorasdk",ze=`${O}/lunora`,Ze="1.22",F=e=>l(e),ee=(e,n)=>{const t=$(n,{none:"",typed:s=>`args ${s}, `,untyped:"args any, "}),r=$(n,{none:"nil",typed:()=>"args",untyped:"args"}),a=n.resultType??"any",i=`lunora.Verb${n.verb.charAt(0).toUpperCase()}${n.verb.slice(1)}`,o=`lunora.Call[${a}](a.client, ${i}, "${m(n.functionPath)}", ${r}, shardKey)`;return[`// ${F(n.functionName)} invokes ${p(n.summary)}.`,`func (a *${e}) ${F(n.functionName)}(${t}shardKey string) (${a}, error) {`,` return ${o}`,"}"].join(`
62
62
  `)},Xe=(e,n)=>{const t=$(n,{none:"",typed:i=>`args ${i}, `,untyped:"args any, "}),r=$(n,{none:"nil",typed:()=>"args",untyped:"args"}),a=`Subscribe${F(n.functionName)}`;return[`// ${a} opens a live ${p(n.functionPath)}; it re-runs on every write to the tables it reads.`,`func (a *${e}) ${a}(${t}onData lunora.DataHandler, onError lunora.ErrorHandler, shardKey string) lunora.Unsubscribe {`,` return a.client.Subscribe("${m(n.functionPath)}", ${r}, onData, onError, shardKey)`,"}"].join(`
63
63
  `)},Qe=e=>{const n=`${l(e.name)}API`,t=e.methods.map(r=>r.verb==="query"?`${ee(n,r)}
64
64
 
@@ -97,9 +97,9 @@ ${e}
97
97
  `,`//
98
98
  `,`// A consuming module wires it in without a network fetch:
99
99
  `,`//
100
- `,`// require ${N} v0.0.0
101
- `,`// replace ${N} => ./path/to/this/directory
102
- `,`module ${N}
100
+ `,`// require ${O} v0.0.0
101
+ `,`// replace ${O} => ./path/to/this/directory
102
+ `,`module ${O}
103
103
  `,`
104
104
  `,`go ${Ze}
105
105
  `].join("")}},tn={id:"go",quicktype:{lang:"go",rendererOptions:{"just-types":"true",package:b}},render:nn,requires:[],vendor:[{from:"lunora",to:"lunora"}]},h="lunoraapi.models",q="lunoraapi/models",rn=24,an=new Set(["abstract","as","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","fromWire","fun","goto","if","implements","import","in","instanceof","int","interface","is","long","native","new","null","object","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","toWire","transient","true","try","typealias","typeof","val","var","void","volatile","when","while","wireValue"]),sn=/[^A-Za-z0-9]+/gu,on=/([a-z0-9])([A-Z])/gu,ln=/^[A-Za-z]/u,cn=/^[A-Z]/u;class fe extends Error{}const y=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0,un=e=>{const n=e.anyOf??e.oneOf;if(!Array.isArray(n)||n.length===0)return;const t=n.map(r=>y(r)?.const);if(t.every(r=>typeof r=="string"))return[...new Set(t)].toSorted((r,a)=>r.localeCompare(a))},ge=e=>{const n=e.anyOf??e.oneOf;if(!Array.isArray(n)||n.length!==2)return e;const t=n.filter(r=>y(r)?.type!=="null");return t.length===1?y(t[0])??e:e},pn=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1),r=ln.test(t)?t:`value${n}`;return an.has(r)?`${r}_`:r},dn=e=>{const n=e.replaceAll(on,"$1_$2").replaceAll(sn,"_").toUpperCase().split("_").filter(t=>t.length>0).join("_");return cn.test(n)?n:`VALUE_${n}`},be=(e,n)=>{if(!n.has(e))return n.add(e),e;let t=2;for(;n.has(`${e}${String(t)}`);)t+=1;return n.add(`${e}${String(t)}`),`${e}${String(t)}`},ne=(e,n)=>{if(e.has(n.name))throw new fe(`sdk: two schemas both produce the JVM model "${n.name}"`);e.set(n.name,n)},$n=(e,n,t,r,a)=>{const i=new Set(Array.isArray(n)?n.filter(s=>typeof s=="string"):[]),o=new Set;return Object.entries(e).map(([s,d])=>{const c=y(d)??{},u=!i.has(s);return{name:be(pn(s),o),nullable:!u&&ge(c)!==c,optional:u,type:A(c,`${t}${l(s)}`,r+1,a),wireKey:s}})},A=(e,n,t,r)=>{if(t>=rn)return{kind:"unknown"};const a=un(e);if(a!==void 0){const c=new Set;return ne(r,{constants:a.map(u=>({name:be(dn(u),c),wireValue:u})),kind:"enum",name:n}),{kind:"enum",name:n}}const i=ge(e);if(i!==e)return A(i,n,t+1,r);const o=y(e.properties);if(o!==void 0)return ne(r,{fields:$n(o,e.required,n,t,r),kind:"class",name:n}),{kind:"class",name:n};const s=y(e.additionalProperties);if(s!==void 0)return{kind:"record",value:A(s,`${n}Value`,t+1,r)};const d=y(e.items);if(d!==void 0)return{item:A(d,`${n}Item`,t+1,r),kind:"list"};switch(e.type){case"boolean":return{kind:"boolean"};case"integer":case"number":return{kind:"number"};case"string":return{kind:"string"};default:return{kind:"unknown"}}},ve=e=>{const n=new Map;for(const t of pe(e)){if(y(t.schema.properties)===void 0)continue;const r=new Map;try{A(t.schema,t.name,0,r)}catch(a){if(a instanceof fe)continue;throw a}if(![...r.keys()].some(a=>n.has(a)))for(const[a,i]of r)n.set(a,i)}return[...n.values()].toSorted((t,r)=>t.name.localeCompare(r.name))},M=e=>[`// GENERATED by \`lunora sdk generate --lang ${e}\` — do not edit.`,"// Run the command again to regenerate."],L=e=>{switch(e.kind){case"boolean":return"Boolean";case"class":case"enum":return e.name;case"list":return`java.util.List<${L(e.item)}>`;case"number":return"Double";case"record":return`java.util.Map<String, ${L(e.value)}>`;case"string":return"String";default:return"Object"}},U=e=>{switch(e.kind){case"class":case"enum":return!0;case"list":return U(e.item);case"record":return U(e.value);default:return!1}},H=(e,n,t)=>{if(!U(e))return n;const r=`item${String(t)}`;switch(e.kind){case"class":return`${n} == null ? null : ${n}.toWire()`;case"enum":return`${n} == null ? null : ${n}.toValue()`;case"list":return`ModelWire.writeList(${n}, ${r} -> ${H(e.item,r,t+1)})`;case"record":return`ModelWire.writeRecord(${n}, ${r} -> ${H(e.value,r,t+1)})`;default:return n}},G=(e,n,t)=>{const r=`item${String(t)}`;switch(e.kind){case"boolean":return`ModelWire.flag(${n})`;case"class":return`ModelWire.readObject(${n}, ${e.name}::fromWire)`;case"enum":return`ModelWire.readEnum(${n}, ${e.name}::forValue)`;case"list":return`ModelWire.readList(${n}, ${r} -> ${G(e.item,r,t+1)})`;case"number":return`ModelWire.number(${n})`;case"record":return`ModelWire.readRecord(${n}, ${r} -> ${G(e.value,r,t+1)})`;case"string":return`ModelWire.text(${n})`;default:return n}},mn=e=>{const n=p(e.wireKey);return e.optional?[" /**",` * Wire key {@code ${n}} — OPTIONAL: null omits the key entirely, because`," * `v.optional` accepts the value or `undefined` and rejects an explicit null."," */"]:[` /** Wire key {@code ${n}}.${e.nullable?" Nullable: null is sent as an explicit null.":""} */`]},yn=100,fn=e=>{const n=e.fields.map(r=>`${L(r.type)} ${r.name}`),t=` public ${e.name}(${n.join(", ")}) {`;return t.length<=yn?[t]:[` public ${e.name}(`,...n.map((r,a)=>` ${r}${a===n.length-1?") {":","}`)]},gn=e=>{const n=e.fields.flatMap(r=>{const a=`wire.put("${m(r.wireKey)}", ${H(r.type,`this.${r.name}`,0)});`;return r.optional?[` if (this.${r.name} != null) {`,` ${a}`," }"]:[` ${a}`]}),t=e.fields.map(r=>` ${G(r.type,`wire.get("${m(r.wireKey)}")`,0)}`);return[...M("java"),"",`package ${h};`,"","/**",` * The \`${e.name}\` model.`," *"," * <p>Field names are local; the keys {@link #toWire()} and {@link #fromWire(Object)} use are"," * the schema's own, emitted verbatim, so a renamed field cannot reach the wire."," */",`public final class ${e.name} {`,...e.fields.flatMap(r=>[...mn(r),` public final ${L(r.type)} ${r.name};`,""]),...fn(e),...e.fields.map(r=>` this.${r.name} = ${r.name};`)," }",""," /** This model as the wire-shaped map the transport encodes. */"," public java.util.Map<String, Object> toWire() {"," java.util.Map<String, Object> wire = new java.util.LinkedHashMap<>();",...n,""," return wire;"," }",""," /** Rebuild from a decoded wire value. */",` public static ${e.name} fromWire(Object value) {`," java.util.Map<String, Object> wire = ModelWire.object(value);","",...t.length===0?[` return new ${e.name}();`]:[` return new ${e.name}(`,`${t.join(`,
@@ -111,16 +111,16 @@ ${e}
111
111
  `);return{[`${q}/Models.kt`]:i}},Tn=`${f("java").map(e=>`// ${e}`).join(`
112
112
  `)}
113
113
 
114
- `,te="lunoraapi",En=new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"]),O=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1);return En.has(t)?`${t}_`:t},kn=e=>`Client.Verb.${e.toUpperCase()}`,he=e=>e.argsType===void 0?{payload:"args",type:"java.util.Map<String, Object>"}:{payload:"args == null ? null : args.toWire()",type:e.argsType},re=e=>{const n=he(e),t=`client.call(
115
- ${kn(e.verb)}, "${m(e.functionPath)}", ${n.payload}, shardKey)`;return[` /** ${p(e.summary)} */`,` public ${e.resultType??"Object"} ${O(e.functionName)}(${n.type} args, String shardKey) {`,` return ${e.resultType===void 0?t:`${e.resultType}.fromWire(${t})`};`," }"].join(`
116
- `)},Nn=e=>{const n=he(e);return[` /** live ${p(e.summary)} — re-runs on every write to the tables it reads. */`,` public Runnable subscribe${l(e.functionName)}(`,` ${n.type} args,`," java.util.function.Consumer<Object> onData,"," java.util.function.Consumer<Client.SubscriptionError> onError,"," String shardKey) {"," return client.subscribe(",` "${m(e.functionPath)}", ${n.payload}, onData, onError, shardKey);`," }"].join(`
117
- `)},On=e=>{const n=`${l(e.name)}Api`,t=e.methods.map(r=>r.verb==="query"?`${re(r)}
114
+ `,te="lunoraapi",En=new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"]),N=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1);return En.has(t)?`${t}_`:t},kn=e=>`Client.Verb.${e.toUpperCase()}`,he=e=>e.argsType===void 0?{payload:"args",type:"java.util.Map<String, Object>"}:{payload:"args == null ? null : args.toWire()",type:e.argsType},re=e=>{const n=he(e),t=`client.call(
115
+ ${kn(e.verb)}, "${m(e.functionPath)}", ${n.payload}, shardKey)`;return[` /** ${p(e.summary)} */`,` public ${e.resultType??"Object"} ${N(e.functionName)}(${n.type} args, String shardKey) {`,` return ${e.resultType===void 0?t:`${e.resultType}.fromWire(${t})`};`," }"].join(`
116
+ `)},On=e=>{const n=he(e);return[` /** live ${p(e.summary)} — re-runs on every write to the tables it reads. */`,` public Runnable subscribe${l(e.functionName)}(`,` ${n.type} args,`," java.util.function.Consumer<Object> onData,"," java.util.function.Consumer<Client.SubscriptionError> onError,"," String shardKey) {"," return client.subscribe(",` "${m(e.functionPath)}", ${n.payload}, onData, onError, shardKey);`," }"].join(`
117
+ `)},Nn=e=>{const n=`${l(e.name)}Api`,t=e.methods.map(r=>r.verb==="query"?`${re(r)}
118
118
 
119
- ${Nn(r)}`:re(r)).join(`
119
+ ${On(r)}`:re(r)).join(`
120
120
 
121
121
  `);return[` /** Functions declared in \`${p(e.name)}\`. */`,` public static final class ${n} {`," private final Client client;","",` ${n}(Client client) {`," this.client = client;"," }","",t.replaceAll(/^ {4}/gmu," ")," }"].join(`
122
- `)},Cn=({namespaces:e})=>{T(e,"Java",i=>[O(i.functionName)]);const n=e.map(i=>` public final ${l(i.name)}Api ${O(i.name)};`).join(`
123
- `),t=e.map(i=>` this.${O(i.name)} = new ${l(i.name)}Api(client);`).join(`
122
+ `)},Cn=({namespaces:e})=>{T(e,"Java",i=>[N(i.functionName)]);const n=e.map(i=>` public final ${l(i.name)}Api ${N(i.name)};`).join(`
123
+ `),t=e.map(i=>` this.${N(i.name)} = new ${l(i.name)}Api(client);`).join(`
124
124
  `),r=W(e).map(i=>`import ${h}.${i};
125
125
  `),a=[Tn,`package ${te};
126
126
  `,`
@@ -134,7 +134,7 @@ ${Nn(r)}`:re(r)).join(`
134
134
  `:` // No functions in this deployment.
135
135
  `,` }
136
136
  `,`
137
- `,e.map(i=>On(i)).join(`
137
+ `,e.map(i=>Nn(i)).join(`
138
138
 
139
139
  `),`
140
140
  }
@@ -368,5 +368,5 @@ ${mt(r)}`:ue(r)).join(`
368
368
  `:`${I}import Foundation
369
369
 
370
370
  // No typed argument or result schemas in this deployment.
371
- `}},gt={id:"swift",quicktype:{lang:"swift",rendererOptions:{"access-level":"public",initializers:"false"}},render:ft,requires:[],vendor:[{from:"Sources/Lunora",to:"Sources/Lunora"}]},bt={dart:Ye,go:tn,java:Ln,kotlin:Kn,python:Gn,ruby:nt,rust:ut,swift:gt},wt=Object.keys(bt).toSorted((e,n)=>e.localeCompare(n)),ht=async(e,n)=>{const t=Ne(e);Oe(t);const r=n.renderModels?.(e),a=r===void 0?await We(e,n):Object.values(r).join(`
371
+ `}},gt={id:"swift",quicktype:{lang:"swift",rendererOptions:{"access-level":"public",initializers:"false"}},render:ft,requires:[],vendor:[{from:"Sources/Lunora",to:"Sources/Lunora"}]},bt={dart:Ye,go:tn,java:Ln,kotlin:Kn,python:Gn,ruby:nt,rust:ut,swift:gt},wt=Object.keys(bt).toSorted((e,n)=>e.localeCompare(n)),ht=async(e,n)=>{const t=Oe(e);Ne(t);const r=n.renderModels?.(e),a=r===void 0?await We(e,n):Object.values(r).join(`
372
372
  `),i=Ce(t,a);return{files:{...r,...n.render({models:a,namespaces:i})},undeclared:Re(t,a),unrepresentable:Le(e)}};export{wt as SDK_LANGUAGES,bt as SDK_TARGETS,ht as generateSdk,St as isTypedSchema};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/codegen",
3
- "version": "1.0.0-alpha.335",
3
+ "version": "1.0.0-alpha.336",
4
4
  "description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -50,15 +50,15 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@lunora/advisor": "1.0.0-alpha.242",
54
- "@lunora/agent": "1.0.0-alpha.232",
55
- "@lunora/container": "1.0.0-alpha.86",
53
+ "@lunora/advisor": "1.0.0-alpha.243",
54
+ "@lunora/agent": "1.0.0-alpha.233",
55
+ "@lunora/container": "1.0.0-alpha.87",
56
56
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
57
- "@lunora/platform": "1.0.0-alpha.71",
58
- "@lunora/queue": "1.0.0-alpha.119",
59
- "@lunora/scheduler": "1.0.0-alpha.141",
60
- "@lunora/values": "1.0.0-alpha.76",
61
- "@lunora/workflow": "1.0.0-alpha.89",
57
+ "@lunora/platform": "1.0.0-alpha.72",
58
+ "@lunora/queue": "1.0.0-alpha.120",
59
+ "@lunora/scheduler": "1.0.0-alpha.142",
60
+ "@lunora/values": "1.0.0-alpha.77",
61
+ "@lunora/workflow": "1.0.0-alpha.90",
62
62
  "@visulima/fs": "6.0.29",
63
63
  "jiti": "^2.7.0",
64
64
  "quicktype-core": "^26.0.0",
@@ -1 +0,0 @@
1
- import{existsSync as j}from"node:fs";import{join as I}from"node:path";import{containerClassName as A,containerBindingName as O,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as k,isManagedImage as C,isCloudflareRegistryDigest as _,normalizeContainerImage as f}from"@lunora/container";import{SyntaxKind as $,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{stringPropertyFor as D,findObjectProperty as p,symbolConstInitializer as M,outermostValueWrapper as w,isWriteTarget as F}from"./isTestPath-Cdv_LoVU.mjs";import{a as V}from"./attribution-RI-H1KPm.mjs";import{a as b}from"./project-config-file-CBY6llht.mjs";const K="containers.ts",B=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const r of e.getDeclarations())if(s.isImportSpecifier(r))return r.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:r.getNameNode().getText()==="defineContainer";return!1},d=D("container"),y=(t,e,r)=>{if(s.isNumericLiteral(t))return t.getLiteralValue();throw a(t,`container "${e}": \`${r}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},E=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return f(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const r=p(t,"registry");if(r&&s.isPropertyAssignment(r)){const i=r.getInitializerOrThrow();return f({registry:d(i,e,"image.registry")})}const n=p(t,"build");if(n&&s.isPropertyAssignment(n)){const i=n.getInitializerOrThrow();return f({build:d(i,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},R=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),U=new Set(["gracePeriodSeconds","stepPercentage"]),L=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},N=(t,e)=>e.getDescendantsOfKind($.Identifier).some(r=>{if(r.getSymbol()!==t)return!1;let n=w(r),i=n.getParent();if(s.isCallExpression(i)&&i.getExpression().getText()==="Object.assign")return i.getArguments()[0]===n;for(;(s.isPropertyAccessExpression(i)||s.isElementAccessExpression(i))&&i.getExpression()===n;){if(F(i))return!0;n=w(i),i=n.getParent()}return!1}),Y=16,T=(t,e,r,n)=>{let i={name:r,symbol:t},o;for(let c=0;c<Y;c+=1){const l=M(i.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=L(l),s.isObjectLiteralExpression(o)&&i.symbol!==void 0&&N(i.symbol,e.getSourceFile()))throw a(e,`${n}: \`${i.name}\` is a const object that is written to elsewhere in this file, so its initializer is not the value the container runs with. Declare the settings where they are final.`);if(!s.isIdentifier(o))return o;i={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const r=L(t);return s.isIdentifier(r)?T(r.getSymbol(),r,r.getText(),e)??r:r},z=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(i=>i.getName()))},W=(t,e,r)=>{const n=t.getExpression().getType(),i=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(z(n))].filter(o=>e.has(o)).map(o=>`\`${o}\``);if(i.length>0)throw a(t,`${r}: this spread can set ${i.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},q=(t,e,r)=>{const n=b(t),i=s.isShorthandPropertyAssignment(t)?T(t.getValueSymbol(),t,n,r):void 0;if(i!==void 0)return[n,i];if(e==="every"||e.has(n))throw a(t,`${r}: \`${n}\` is deploy configuration codegen writes into wrangler.jsonc, so it must be a static literal — inline it, or name a module-scope \`const\` initialized with one.`)},m=(t,e,r,n=new Set)=>{const i=[],o=new Set(n).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))i.push([b(c),P(c.getInitializerOrThrow(),r)]);else if(s.isSpreadAssignment(c))i.push(...x(c,e,r,o));else{const l=q(c,e,r);l!==void 0&&i.push(l)}return i},x=(t,e,r,n)=>{const i=P(t.getExpression(),r);if(!s.isObjectLiteralExpression(i))return W(t,e,r),[];if(n.has(i))throw a(t,`${r}: this spread refers back to an object it is part of, so it has no static value.`);return m(i,e,r,n)},H=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`buildArgs\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const r={};for(const[n,i]of m(t,"every",`container "${e}" buildArgs`))r[n]=d(i,e,`buildArgs.${n}`);return Object.keys(r).length>0?r:void 0},J=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`rollout\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const r={};for(const[n,i]of m(t,U,`container "${e}" rollout`))(n==="gracePeriodSeconds"||n==="stepPercentage")&&(r[n]=y(i,e,`rollout.${n}`));return r.gracePeriodSeconds===void 0&&r.stepPercentage===void 0?void 0:r},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},S=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},X=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const r={};for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))throw a(n,`container "${e}": \`instanceType\` must be an object of static number literals`);const i=b(n);if(i!=="diskMb"&&i!=="memoryMib"&&i!=="vcpu")throw a(n,`container "${e}": unknown \`instanceType\` field "${i}" — expected vcpu, memoryMib, or diskMb`);r[i]=y(n.getInitializerOrThrow(),e,`instanceType.${i}`)}return r}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},G=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`images\` must be a static object literal — codegen writes it into wrangler.jsonc`);const r={};for(const[n,i]of m(t,"every",`container "${e}" images`)){const o=E(i,e);if(o.kind==="build")throw a(i,`container "${e}": \`images["${n}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!_(o.reference))throw a(i,`container "${e}": \`images["${n}"].registry\` must be a digest-pinned (@sha256) reference under registry.cloudflare.com — push other registries' images there first`);r[n]=o}return r},Q=(t,e)=>{const r=t.findLast(([i])=>i==="schedulingPolicy");if(r===void 0)return;const n=d(r[1],e,"schedulingPolicy");if(n!=="default"&&n!=="durable_object")throw a(r[1],`container "${e}": unknown \`schedulingPolicy\` "${n}" — use "default" or "durable_object"`);return n==="durable_object"?n:void 0},Z=(t,e,r,n)=>{if(r!==void 0&&k.includes(t))throw a(e,`container "${n}": \`${t}\` is not supported with schedulingPolicy "durable_object"`);if(r===void 0&&t==="images")throw a(e,`container "${n}": \`images\` needs schedulingPolicy "durable_object"`)},ee=(t,e,r,n)=>{const{base:i,policy:o}=r;switch(t){case"buildArgs":{i.buildArgs=H(e,n);break}case"enableInternet":{i.enableInternet=v(e);break}case"hardTimeout":{i.hardTimeout=S(e);break}case"image":{r.scheduled||(o.image=E(e,n));break}case"images":{o.images=G(e,n);break}case"instanceType":{i.instanceType=X(e,n);break}case"maxInstances":{o.maxInstances=y(e,n,"maxInstances");break}case"name":{i.name=d(e,n,"name");break}case"rollout":{o.rollout=J(e,n);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${n}": \`sandbox\` must be a static true/false literal`);i.sandbox=c;break}case"sleepAfter":{i.sleepAfter=S(e);break}}},te=(t,e,r)=>{const n=t.findLast(([o])=>o==="image")?.[1];if(n===void 0||!(s.isStringLiteral(n)||s.isNoSubstitutionTemplateLiteral(n)))return;const i=n.getLiteralValue();if(!Object.hasOwn(e??{},i)&&!C(i))throw a(n,`container "${r}": \`image\` "${i}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ne=(t,e)=>{const r=t.getArguments()[0];if(!r||!s.isObjectLiteralExpression(r))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const n=m(r,R,`container "${e}"`),i=Q(n,e),o={base:{bindingName:O(e),className:A(e),exportName:e},policy:{},scheduled:i!==void 0};for(const[g,u]of n)Z(g,u,i,e),ee(g,u,o,e);const{base:c,policy:l}=o;if(i==="durable_object")return te(n,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:i};if(l.image===void 0)throw a(r,`container "${e}": defineContainer requires a static \`image\` property`);return{...c,image:l.image,...l.maxInstances===void 0?{}:{maxInstances:l.maxInstances},...l.rollout===void 0?{}:{rollout:l.rollout}}},ie=t=>{const e=[],r=new Map;for(const n of t.getVariableDeclarations()){const i=n.getInitializer();if(i?.getKind()!==$.CallExpression)continue;const o=i,c=o.getExpression();if(!s.isIdentifier(c)||!B(c))continue;const l=n.getNameNode();if(!s.isIdentifier(l)){if(n.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=V(n,"binding");if(g===void 0)continue;const u=ne(o,g),h=r.get(u.bindingName);if(h!==void 0)throw a(l,`containers "${h}" and "${u.exportName}" both map to the binding ${u.bindingName} — rename one so each container gets its own Durable Object binding`);r.set(u.bindingName,u.exportName),e.push(u)}return e},de=(t,e)=>{const r=I(e,K);if(!j(r))return[];const n=t.getSourceFile(r)??t.addSourceFileAtPath(r),i=ie(n);return i.sort((o,c)=>o.exportName.localeCompare(c.exportName)),i};export{K as CONTAINERS_FILENAME,de as discoverContainers};
@@ -1 +0,0 @@
1
- import{G as p,I as i,a as n,g as o,d,i as I,p as T,r as c,f,b as y,c as E,e as m,u as O,v as l}from"./shared-DnCokNcE.mjs";import"./reserved-words-CW1QFbTd.mjs";import"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";import"./dispatch-namespace-DwTjD7BU.mjs";export{p as GENERATED_HEADER,i as IMPORT_PATH_RE,n as assertIdentifier,o as assertPropertyIdentifier,d as baseSpecifiers,I as isOptionalOnInsert,T as pascalCase,c as renderArgsType,f as renderInsertInterface,y as renderNamespaceTree,E as renderObjectKey,m as renderPropertyKey,O as unwrapOptional,l as validatorToType};
@@ -1 +0,0 @@
1
- import{jsonSchemaFromNode as s,acceptsAbsent as i,objectSchemaFromNodes as o}from"@lunora/values";const c=/^-?\d+n$/u,N=t=>{if(t===void 0)return{};const e=t.trim();if(e==="true")return{const:!0};if(e==="false")return{const:!1};if(e==="null")return{const:null,type:"null"};if(e.startsWith('"')&&e.endsWith('"'))try{return{const:JSON.parse(e),type:"string"}}catch{return{const:e.slice(1,-1),type:"string"}}if(e.startsWith("'")&&e.endsWith("'"))return{const:e.slice(1,-1),type:"string"};if(c.test(e))return{const:e.slice(0,-1),format:"int64",type:"string"};const r=Number(e);return Number.isNaN(r)?{const:e}:{const:r}},n={constraints:()=>{},inner:t=>t.inner,isNullable:t=>t.column?.notNull===!1,keyChild:t=>t.keyType,kind:t=>t.kind,literalSchema:t=>N(t.literalValue),members:t=>t.members??[],shape:t=>t.shape??{},tableName:t=>t.tableName,valueChild:t=>t.valueType},O=t=>s(t,n),m=t=>o(t,n),a={...n,kind:t=>t.sourceText===void 0?n.kind(t):"from"},u=t=>i(t,a),R=["BAD_REQUEST","CONFLICT","COUNT_RLS_UNSUPPORTED","FORBIDDEN","FUNCTION_NOT_FOUND","INTERNAL","INTERNAL_SERVER_ERROR","METHOD_NOT_ALLOWED","NOT_FOUND","NOT_IMPLEMENTED","PAYLOAD_TOO_LARGE","TOO_MANY_REQUESTS","UNAUTHORIZED","UNPROCESSABLE","VALIDATION_ERROR"];export{R as LUNORA_ERROR_CODES,u as acceptsAbsentIr,N as literalConst,m as objectSchema,O as validatorIrToJsonSchema};