@lunora/codegen 1.0.0-alpha.43 → 1.0.0-alpha.430

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 (131) hide show
  1. package/LICENSE.md +201 -104
  2. package/README.md +4 -4
  3. package/dist/index.d.mts +4575 -2150
  4. package/dist/index.d.ts +4575 -2150
  5. package/dist/index.mjs +1 -36
  6. package/dist/packem_shared/AGENTS_FILENAME-BSW65Q9R.mjs +1 -0
  7. package/dist/packem_shared/ALL_NOTIFY_CHANNELS-DI0zmZGs.mjs +1 -0
  8. package/dist/packem_shared/CAPABILITY_PROBES-DCzOjTN7.mjs +25 -0
  9. package/dist/packem_shared/COMPANION_BINDING-Da_v9XpC.mjs +1 -0
  10. package/dist/packem_shared/CONTAINERS_FILENAME-Dy3qWGfI.mjs +1 -0
  11. package/dist/packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs +1 -0
  12. package/dist/packem_shared/DEFAULT_TARGET-CnglMKg_.mjs +1 -0
  13. package/dist/packem_shared/ENV_FILENAME-DFx_jlpa.mjs +1 -0
  14. package/dist/packem_shared/FLAGS_FILENAME-CDaIBL6L.mjs +1 -0
  15. package/dist/packem_shared/GENERATED_HEADER-DgrhC3Iv.mjs +1 -0
  16. package/dist/packem_shared/LUNORA_ERROR_CODES-D7AVT7qF.mjs +1 -0
  17. package/dist/packem_shared/MUTATORS_FILENAME-SLAN2VXq.mjs +1 -0
  18. package/dist/packem_shared/OPENRPC_VERSION-DkWde9eh.mjs +3 -0
  19. package/dist/packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs +1 -0
  20. package/dist/packem_shared/QUEUES_FILENAME-CVkpGqoY.mjs +1 -0
  21. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-C0ZU8cQz.mjs +57 -0
  22. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs +2 -0
  23. package/dist/packem_shared/SHAPES_FILENAME-Cf4sum4C.mjs +1 -0
  24. package/dist/packem_shared/SchemaSnapshotParseError-CV7mmuPi.mjs +17 -0
  25. package/dist/packem_shared/WORKFLOWS_FILENAME-Dtxo_XBw.mjs +1 -0
  26. package/dist/packem_shared/attribution-B8xa6AeK.mjs +1 -0
  27. package/dist/packem_shared/buildOpenApiDocument-C3zlve6K.mjs +3 -0
  28. package/dist/packem_shared/capabilitiesUsedBy-BcDkRoOu.mjs +1 -0
  29. package/dist/packem_shared/classify-procedure-call-BK_MMoue.mjs +1 -0
  30. package/dist/packem_shared/companionServiceBinding-BZjm486n.mjs +1 -0
  31. package/dist/packem_shared/context-property-calls-As5I0QR6.mjs +1 -0
  32. package/dist/packem_shared/context-root-CO8PbZi5.mjs +1 -0
  33. package/dist/packem_shared/createCodegenProject-C4XuJSap.mjs +1 -0
  34. package/dist/packem_shared/database-calls-Cug60vT9.mjs +1 -0
  35. package/dist/packem_shared/declared-output-Iaar469J.mjs +1 -0
  36. package/dist/packem_shared/describeErrorLevelFindings-DlkgCw8a.mjs +1 -0
  37. package/dist/packem_shared/discoverAuthApiCalls-DcvsgL5u.mjs +1 -0
  38. package/dist/packem_shared/discoverCrons-MpIC14pg.mjs +1 -0
  39. package/dist/packem_shared/discoverFunctions-CGwHnz_a.mjs +1 -0
  40. package/dist/packem_shared/discoverHttpRoutes-BtMgsfzG.mjs +1 -0
  41. package/dist/packem_shared/discoverHyperdriveCalls-B--Nvx36.mjs +1 -0
  42. package/dist/packem_shared/discoverInserts-Dx7Lxey3.mjs +1 -0
  43. package/dist/packem_shared/discoverMaskProcedures-Dj_hkZz2.mjs +1 -0
  44. package/dist/packem_shared/discoverMigrations-DaBdK1Bv.mjs +1 -0
  45. package/dist/packem_shared/discoverNondeterministicCalls-MeKjo_UX.mjs +1 -0
  46. package/dist/packem_shared/discoverQueries-BlhMsXuk.mjs +1 -0
  47. package/dist/packem_shared/discoverR2sqlCalls-DHvclvkv.mjs +1 -0
  48. package/dist/packem_shared/discoverRlsMetadata-CO-pRHOx.mjs +1 -0
  49. package/dist/packem_shared/discoverRlsProcedures-CUfhUqfY.mjs +1 -0
  50. package/dist/packem_shared/discoverSandboxUsage-CdrJNRFd.mjs +1 -0
  51. package/dist/packem_shared/discoverSchema-CL9PLdOu.mjs +1 -0
  52. package/dist/packem_shared/discoverStorageRulesMetadata-D_pYyr1i.mjs +1 -0
  53. package/dist/packem_shared/dispatch-namespace-DwTjD7BU.mjs +1 -0
  54. package/dist/packem_shared/emitAgents-vWoT8-Yb.mjs +1 -0
  55. package/dist/packem_shared/emitApi-lwadq5G7.mjs +147 -0
  56. package/dist/packem_shared/emitApp-_YbbmtTw.mjs +1207 -0
  57. package/dist/packem_shared/emitCrons-CCRKs482.mjs +138 -0
  58. package/dist/packem_shared/emitDataModel-Cen7mAmM.mjs +114 -0
  59. package/dist/packem_shared/emitDrizzleSchema-lRoq3OJs.mjs +15 -0
  60. package/dist/packem_shared/emitFunctions-ppMX7E3X.mjs +528 -0
  61. package/dist/packem_shared/emitServer-CGRV_uIq.mjs +1 -0
  62. package/dist/packem_shared/emitShard-DhgRjlEf.mjs +1 -0
  63. package/dist/packem_shared/exported-procedure-chains-ej9ozyZB.mjs +1 -0
  64. package/dist/packem_shared/fingerprintSchemaSources-BqPD3mw0.mjs +1 -0
  65. package/dist/packem_shared/formatAdvisories-Bue5tbp6.mjs +2 -0
  66. package/dist/packem_shared/handler-reference-_zhtPddp.mjs +1 -0
  67. package/dist/packem_shared/index-BwLaIVqA.mjs +1 -0
  68. package/dist/packem_shared/index-CQuAXbal.mjs +1 -0
  69. package/dist/packem_shared/ip-reads-D8rPYtZ6.mjs +1 -0
  70. package/dist/packem_shared/isD1GlobalTable-udvHAAzD.mjs +1 -0
  71. package/dist/packem_shared/isTestPath-DJeZ18i9.mjs +1 -0
  72. package/dist/packem_shared/isTypedSchema-CDv3pJB6.mjs +4 -0
  73. package/dist/packem_shared/json-data-Chfs2Cz5.mjs +1 -0
  74. package/dist/packem_shared/loadProjectConfig-BXwH3_gn.mjs +1 -0
  75. package/dist/packem_shared/module-specifiers-BctA0m_p.mjs +1 -0
  76. package/dist/packem_shared/modules-isOWiSYI.mjs +1 -0
  77. package/dist/packem_shared/parse-validator-BisfC8bR.mjs +1 -0
  78. package/dist/packem_shared/platform-8oj7iXQy.mjs +1 -0
  79. package/dist/packem_shared/policies-CrNWTJQi.mjs +1 -0
  80. package/dist/packem_shared/project-config-file-DR7xrrNB.mjs +1 -0
  81. package/dist/packem_shared/property-name-7cBlgK_O.mjs +1 -0
  82. package/dist/packem_shared/qualifiers-qqH8fRTo.mjs +1 -0
  83. package/dist/packem_shared/readPackageDependencies-RHhGiz0k.mjs +1 -0
  84. package/dist/packem_shared/redact-Cy14LEnc.mjs +1 -0
  85. package/dist/packem_shared/reserved-words-CW1QFbTd.mjs +1 -0
  86. package/dist/packem_shared/schema-BgM8A3XV.mjs +1 -0
  87. package/dist/packem_shared/schemaFromIr-CByOxuZb.mjs +1 -0
  88. package/dist/packem_shared/server-Dfxmm5Zw.mjs +377 -0
  89. package/dist/packem_shared/shard-WWiw5i1B.mjs +1922 -0
  90. package/dist/packem_shared/shard-runtime-G5mZQjY0.mjs +351 -0
  91. package/dist/packem_shared/shared-Cn7dMQ_u.mjs +13 -0
  92. package/dist/packem_shared/unwrap-handler-return-BnsKyz9W.mjs +1 -0
  93. package/dist/sdk/index.d.mts +288 -0
  94. package/dist/sdk/index.d.ts +288 -0
  95. package/dist/sdk/index.mjs +394 -0
  96. package/package.json +32 -10
  97. package/dist/packem_shared/AGENTS_FILENAME-BksnAJgx.mjs +0 -116
  98. package/dist/packem_shared/CONTAINERS_FILENAME-DjpXMqhp.mjs +0 -224
  99. package/dist/packem_shared/CodegenDiagnosticError-DyQ5FwkM.mjs +0 -24
  100. package/dist/packem_shared/FLAGS_FILENAME-fEZtzWXi.mjs +0 -139
  101. package/dist/packem_shared/GENERATED_HEADER-B-FzJ297.mjs +0 -4
  102. package/dist/packem_shared/LUNORA_ERROR_CODES-DvTLozCu.mjs +0 -68
  103. package/dist/packem_shared/MUTATORS_FILENAME-BZOfUhlY.mjs +0 -81
  104. package/dist/packem_shared/OPENRPC_VERSION-DqTYxQ22.mjs +0 -60
  105. package/dist/packem_shared/QUEUES_FILENAME-Xv6Vy-Ku.mjs +0 -145
  106. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BbF69nj9.mjs +0 -3497
  107. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs +0 -249
  108. package/dist/packem_shared/SHAPES_FILENAME-DOhPGi-6.mjs +0 -94
  109. package/dist/packem_shared/WORKFLOWS_FILENAME-B2By8S4s.mjs +0 -152
  110. package/dist/packem_shared/buildOpenApiDocument-BrN41JMl.mjs +0 -183
  111. package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
  112. package/dist/packem_shared/discoverAuthApiCalls-WMx8L2FG.mjs +0 -62
  113. package/dist/packem_shared/discoverCrons-DJJ3ZE5F.mjs +0 -271
  114. package/dist/packem_shared/discoverFunctions-CZ91aenA.mjs +0 -518
  115. package/dist/packem_shared/discoverHttpRoutes-DNZLDCmm.mjs +0 -131
  116. package/dist/packem_shared/discoverInserts-DFRJhmCv.mjs +0 -61
  117. package/dist/packem_shared/discoverMaskProcedures-B5iFnZ-X.mjs +0 -273
  118. package/dist/packem_shared/discoverMigrations-CdKtMlBc.mjs +0 -97
  119. package/dist/packem_shared/discoverNondeterministicCalls-C_PrQPkA.mjs +0 -122
  120. package/dist/packem_shared/discoverQueries-B8W9UPrt.mjs +0 -62
  121. package/dist/packem_shared/discoverR2sqlCalls-Bm7Rfnf4.mjs +0 -80
  122. package/dist/packem_shared/discoverRlsMetadata-B4GL4ZKm.mjs +0 -280
  123. package/dist/packem_shared/discoverSchema-DFWVgU5o.mjs +0 -874
  124. package/dist/packem_shared/discoverStorageRulesMetadata-nosjYcvN.mjs +0 -97
  125. package/dist/packem_shared/emit-DtherCpQ.mjs +0 -3727
  126. package/dist/packem_shared/emitApp-D7daY94X.mjs +0 -691
  127. package/dist/packem_shared/formatAdvisories-DRhEiJUz.mjs +0 -114
  128. package/dist/packem_shared/parse-validator-BSJo1HGP.mjs +0 -144
  129. package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
  130. package/dist/packem_shared/redact-oTmsol5A.mjs +0 -33
  131. package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
@@ -0,0 +1,394 @@
1
+ import{modelSources as ge,assertDistinctMembers as T,toPascalCase as l,referencedModels as P,generatedHeaderLines as b,commentText as c,argsChoice as $,stringLiteral as y,kotlinLiteral as w,allMethods as N,toSnakeCase as h,parseSpec as Ne,assertGeneratable as Oe,withDeclaredModels as Ce,unrepresentableFunctions as We,undeclaredModels as Le}from"../packem_shared/isTypedSchema-CDv3pJB6.mjs";import{isTypedSchema as Ct}from"../packem_shared/isTypedSchema-CDv3pJB6.mjs";const Re=async(e,n)=>{if(n.quicktype===void 0)return"";const t=ge(e);if(t.length===0)return"";const{InputData:r,JSONSchemaInput:a,JSONSchemaStore:s,quicktype:o}=await import("quicktype-core");class i extends s{fetch(){return Promise.resolve(void 0)}}const p=new a(new i);for(const d of t)await p.addSource({name:d.name,schema:JSON.stringify(d.schema)});const u=new r;u.addInput(p);const{lines:m}=await o({inputData:u,lang:n.quicktype.lang,rendererOptions:n.quicktype.rendererOptions??{}});return m.join(`
2
+ `)},K=`${b("dart").map(e=>`// ${e}`).join(`
3
+ `)}
4
+
5
+ `,Me=`# GENERATED by \`lunora sdk generate --lang dart\` — do not edit.
6
+ #
7
+ # The transport is vendored under lib/, so this package has no dependencies and
8
+ # nothing to fetch. Add it to a consuming app as a path dependency — pub takes a
9
+ # path dependency's identity from the "name" below, NOT from the directory, so
10
+ # this is the name you write no matter where you generated into:
11
+ #
12
+ # dependencies:
13
+ # lunora_sdk:
14
+ # path: sdk/dart
15
+ #
16
+ # import 'package:lunora_sdk/lunora_api.dart';
17
+ name: lunora_sdk
18
+ description: Generated Lunora SDK, transport included.
19
+ version: 0.0.0
20
+ publish_to: none
21
+
22
+ environment:
23
+ sdk: ^3.6.0
24
+ `,Pe=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"]),A=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1);return Pe.has(t)?`${t}_`:t},be=e=>y(e).replaceAll("$",String.raw`\$`),De=e=>e.replaceAll(" == null ? [] : List<"," == null ? null : List<").replaceAll(/Map\.from\((?<source>[^()]*?)!\)/gu,"$<source> == null ? null : Map.from($<source>!)"),re=" ".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(p=>{const u=p[0].trim();return{field:u.slice(u.indexOf("this.")+5,-1),optional:!u.startsWith("required ")}}),s=[...r.matchAll(qe)],o=a.filter(p=>p.optional);if(a.length!==s.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(s.length)} toJson entr(ies). quicktype's Dart output has changed shape; \`guardOptionalFields\` in targets/dart.ts must be updated to match.`)}let i=r;for(const[p,u]of s.entries()){const m=a[p];if(!m?.optional)continue;const d=u[0],ke=d.slice(re.length).replace(`${m.field} == null ? null : `,"");i=i.replace(d,`${re}if (${m.field} != null) ${ke}`)}return n.replace(r,i)}),ve=e=>$(e,{none:"null",typed:()=>"LunoraClient.wireValue(args)",untyped:"args"}),we={declaration:"LunoraOptimistic? optimistic, LunoraOptimisticUpdate? optimisticUpdate, bool Function()? precondition, bool onlineOnly = false",forward:"optimistic: optimistic, optimisticUpdate: optimisticUpdate, precondition: precondition, onlineOnly: onlineOnly"},ae=e=>{const n=e.verb==="mutation"?`{String? shardKey, ${we.declaration}}`:"{String? shardKey}";return $(e,{none:n,typed:t=>`${t} args, ${n}`,untyped:`Object? args, ${n}`})},he=(e,n)=>`${e}.fromJson(${n} as Map<String, dynamic>)`,se=e=>{const n=e.verb==="mutation"?`, ${we.forward}`:"",t=`_client.${e.verb}("${be(e.functionPath)}", args: ${ve(e)}, shardKey: shardKey${n})`;return e.resultType===void 0?[` /// ${c(e.summary)}`,` Future<Object?> ${A(e.functionName)}(${ae(e)}) => ${t};`].join(`
25
+ `):[` /// ${c(e.summary)}`,` Future<${e.resultType}> ${A(e.functionName)}(${ae(e)}) async =>`,` ${he(e.resultType,`await ${t}`)};`].join(`
26
+ `)},He=e=>{const n=$(e,{none:"",typed:o=>`${o} args`,untyped:"Object? args"}),t=n===""?"":`${n}, `,r=ve(e),a=`"${be(e.functionPath)}"`,s=`_client.watch(${a}, args: ${r})`;return[` /// live ${c(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 ${c(e.summary)}, as a Stream — bind it with StreamBuilder.`,e.resultType===void 0?` Stream<Object?> watch${l(e.functionName)}(${n}) => ${s};`:[` Stream<${e.resultType}> watch${l(e.functionName)}(${n}) =>`,` ${s}.map((raw) => ${he(e.resultType,"raw")});`].join(`
27
+ `)].join(`
28
+ `)},Ge=e=>{const n=`${l(e.name)}Api`,t=e.methods.map(r=>r.verb==="query"?`${se(r)}
29
+
30
+ ${He(r)}`:se(r)).join(`
31
+
32
+ `);return[`/// Functions declared in \`${c(e.name)}\`.`,`class ${n} {`,` const ${n}(this._client);`,""," final LunoraClient _client;","",t,"}"].join(`
33
+ `)},Be=(e,n)=>{const t=r=>{if(r===void 0)return;const a=`${r.charAt(0).toLowerCase()}${r.slice(1)}FromJson`;if(!new RegExp(String.raw`^\S+ ${a}\(String str\) =>`,"mu").test(n))throw new Error(`sdk: the dart models declare "${r}" but no top-level decoder "${a}" — quicktype's Dart naming has changed; update objectResultsOnly in targets/dart.ts.`);return new RegExp(String.raw`^${r} ${a}\(String str\) => ${r}\.fromJson\(`,"mu").test(n)?r:void 0};return e.map(r=>({methods:r.methods.map(a=>({...a,resultType:t(a.resultType)})),name:r.name}))},Je=({models:e,namespaces:n})=>{T(n,"Dart",i=>[A(i.functionName)]);const t=Be(n,e),r=t.map(i=>` final ${l(i.name)}Api ${A(i.name)};`).join(`
34
+ `),a=t.map(i=>` ${A(i.name)} = ${l(i.name)}Api(client)`).join(`,
35
+ `),s=P(t).length>0?`import 'models.dart';
36
+ `:"";return{"lib/lunora_api.dart":[K,`/// The generated Lunora surface. Re-exports the vendored transport, so one
37
+ `,`/// import gives a consumer the client, the wire types and the models.
38
+ `,`library;
39
+ `,`
40
+ `,`export 'lunora.dart';
41
+ `,`export 'models.dart';
42
+ `,`
43
+ `,`import 'lunora.dart';
44
+ `,s,`
45
+ `,t.map(i=>Ge(i)).join(`
46
+
47
+ `),t.length>0?`
48
+
49
+ `:"","/// Typed entry point: `Api(client).<namespace>.<function>(args)`.\n",`class Api {
50
+ `,t.length>0?` Api(LunoraClient client)
51
+ : ${a.trimStart()};
52
+
53
+ ${r}
54
+ `:` const Api(LunoraClient client);
55
+ `,`}
56
+ `].join(""),"lib/models.dart":e.length>0?`${K}${Ue(De(e))}
57
+ `:`${K}// No typed argument or result schemas in this deployment.
58
+ `,"pubspec.yaml":Me}},Ye={id:"dart",quicktype:{lang:"dart"},render:Je,requires:[],vendor:[{from:"lib",to:"lib"}]},I=`${b("go").map(e=>`// ${e}`).join(`
59
+ `)}
60
+
61
+ `,j="lunoraapi",O="lunorasdk",ze=`${O}/lunora`,Ze="1.22",L=e=>l(e),ie=(e,n)=>{const t=$(n,{none:"",typed:i=>`args ${i}, `,untyped:"args any, "}),r=$(n,{none:"nil",typed:()=>"args",untyped:"args"}),a=n.resultType??"any",s=`lunora.Verb${n.verb.charAt(0).toUpperCase()}${n.verb.slice(1)}`,o=`lunora.Call[${a}](a.client, ${s}, "${y(n.functionPath)}", ${r}, shardKey)`;return[`// ${L(n.functionName)} invokes ${c(n.summary)}.`,`func (a *${e}) ${L(n.functionName)}(${t}shardKey string) (${a}, error) {`,` return ${o}`,"}"].join(`
62
+ `)},Xe=(e,n)=>{const t=$(n,{none:"",typed:s=>`args ${s}, `,untyped:"args any, "}),r=$(n,{none:"nil",typed:()=>"args",untyped:"args"}),a=`Subscribe${L(n.functionName)}`;return[`// ${a} opens a live ${c(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("${y(n.functionPath)}", ${r}, onData, onError, shardKey)`,"}"].join(`
63
+ `)},Qe=(e,n)=>{const t=$(n,{none:"",typed:s=>`args ${s}, `,untyped:"args any, "}),r=$(n,{none:"nil",typed:()=>"args",untyped:"args"}),a=`Watch${L(n.functionName)}`;return[`// ${a} opens a live ${c(n.functionPath)} as a channel; the returned Unsubscribe closes it.`,`func (a *${e}) ${a}(${t}shardKey string) (<-chan lunora.WatchEvent, lunora.Unsubscribe) {`,` return a.client.Watch("${y(n.functionPath)}", ${r}, shardKey)`,"}"].join(`
64
+ `)},en=e=>{const n=`${l(e.name)}API`,t=e.methods.map(r=>r.verb==="query"?`${ie(n,r)}
65
+
66
+ ${Xe(n,r)}
67
+
68
+ ${Qe(n,r)}`:ie(n,r)).join(`
69
+
70
+ `);return[`// ${n} groups the functions declared in ${c(e.name)}.`,`type ${n} struct{ client *lunora.Client }`,"",t].join(`
71
+ `)},nn=e=>{const n=new Map;for(const a of e.matchAll(/^type (\w+) (struct \{\n[\s\S]*?^\}|.*)$/gmu))n.set(a[1],a[2]);const t=new Set([...n].filter(([,a])=>a.startsWith(`struct {
72
+ `)&&!a.includes("`")).map(([a])=>a));let r=!0;for(;r;){r=!1;for(const[a,s]of n)!t.has(a)&&[...t].some(o=>new RegExp(String.raw`\b${o}\b`,"u").test(s))&&(t.add(a),r=!0)}return t},tn=({models:e,namespaces:n})=>{const t=nn(e),r=u=>u!==void 0&&t.has(u)?void 0:u,a=n.map(u=>({methods:u.methods.map(m=>({...m,argsType:r(m.argsType),resultType:r(m.resultType)})),name:u.name})),s=a.map(u=>` ${l(u.name)} *${l(u.name)}API`).join(`
73
+ `),o=a.map(u=>` ${l(u.name)}: &${l(u.name)}API{client: client},`).join(`
74
+ `),i=[I,`package ${j}
75
+ `,`
76
+ `,`import "${ze}"
77
+ `,`
78
+ `,`// API is the typed entry point: api.<Namespace>.<Function>(args, shardKey).
79
+ `,`type API struct {
80
+ `,`${s}
81
+ `,`}
82
+ `,`
83
+ `,`// NewAPI binds the generated surface to a client.
84
+ `,`func NewAPI(client *lunora.Client) *API {
85
+ `,` return &API{
86
+ `,`${o}
87
+ `,` }
88
+ `,`}
89
+ `,`
90
+ `,a.map(u=>en(u)).join(`
91
+
92
+ `),`
93
+ `].join(""),p=e.length>0?`${I}package ${j}
94
+
95
+ ${e}
96
+ `:`${I}package ${j}
97
+
98
+ // No typed argument or result schemas in this deployment.
99
+ `;return{[`${j}/api.go`]:i,[`${j}/models.go`]:p,"go.mod":[`// The generated Lunora Go SDK, with the transport vendored under ./lunora.
100
+ `,`//
101
+ `,`// A consuming module wires it in without a network fetch:
102
+ `,`//
103
+ `,`// require ${O} v0.0.0
104
+ `,`// replace ${O} => ./path/to/this/directory
105
+ `,`module ${O}
106
+ `,`
107
+ `,`go ${Ze}
108
+ `].join("")}},rn={id:"go",quicktype:{lang:"go",rendererOptions:{"just-types":"true",package:j}},render:tn,requires:[],vendor:[{from:"lunora",to:"lunora"}]},_="lunoraapi.models",U="lunoraapi/models",an=24,sn=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"]),on=/[^A-Za-z0-9]+/gu,ln=/([a-z0-9])([A-Z])/gu,cn=/^[A-Za-z]/u,un=/^[A-Z]/u;class je extends Error{}const g=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0,pn=e=>{const n=e.anyOf??e.oneOf;if(!Array.isArray(n)||n.length===0)return;const t=n.map(r=>g(r)?.const);if(t.every(r=>typeof r=="string"))return[...new Set(t)].toSorted((r,a)=>r.localeCompare(a))},_e=e=>{const n=e.anyOf??e.oneOf;if(!Array.isArray(n)||n.length!==2)return e;const t=n.filter(r=>g(r)?.type!=="null");return t.length===1?g(t[0])??e:e},dn=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1),r=cn.test(t)?t:`value${n}`;return sn.has(r)?`${r}_`:r},$n=e=>{const n=e.replaceAll(ln,"$1_$2").replaceAll(on,"_").toUpperCase().split("_").filter(t=>t.length>0).join("_");return un.test(n)?n:`VALUE_${n}`},Ae=(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)}`},oe=(e,n)=>{if(e.has(n.name))throw new je(`sdk: two schemas both produce the JVM model "${n.name}"`);e.set(n.name,n)},yn=(e,n,t,r,a)=>{const s=new Set(Array.isArray(n)?n.filter(i=>typeof i=="string"):[]),o=new Set;return Object.entries(e).map(([i,p])=>{const u=g(p)??{},m=!s.has(i);return{name:Ae(dn(i),o),nullable:!m&&_e(u)!==u,optional:m,type:S(u,`${t}${l(i)}`,r+1,a),wireKey:i}})},S=(e,n,t,r)=>{if(t>=an)return{kind:"unknown"};const a=pn(e);if(a!==void 0){const u=new Set;return oe(r,{constants:a.map(m=>({name:Ae($n(m),u),wireValue:m})),kind:"enum",name:n}),{kind:"enum",name:n}}const s=_e(e);if(s!==e)return S(s,n,t+1,r);const o=g(e.properties);if(o!==void 0)return oe(r,{fields:yn(o,e.required,n,t,r),kind:"class",name:n}),{kind:"class",name:n};const i=g(e.additionalProperties);if(i!==void 0)return{kind:"record",value:S(i,`${n}Value`,t+1,r)};const p=g(e.items);if(p!==void 0)return{item:S(p,`${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"}}},Se=e=>{const n=new Map;for(const t of ge(e)){if(g(t.schema.properties)===void 0)continue;const r=new Map;try{S(t.schema,t.name,0,r)}catch(a){if(a instanceof je)continue;throw a}if(![...r.keys()].some(a=>n.has(a)))for(const[a,s]of r)n.set(a,s)}return[...n.values()].toSorted((t,r)=>t.name.localeCompare(r.name))},D=e=>[`// GENERATED by \`lunora sdk generate --lang ${e}\` — do not edit.`,"// Run the command again to regenerate."],R=e=>{switch(e.kind){case"boolean":return"Boolean";case"class":case"enum":return e.name;case"list":return`java.util.List<${R(e.item)}>`;case"number":return"Double";case"record":return`java.util.Map<String, ${R(e.value)}>`;case"string":return"String";default:return"Object"}},H=e=>{switch(e.kind){case"class":case"enum":return!0;case"list":return H(e.item);case"record":return H(e.value);default:return!1}},G=(e,n,t)=>{if(!H(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} -> ${G(e.item,r,t+1)})`;case"record":return`ModelWire.writeRecord(${n}, ${r} -> ${G(e.value,r,t+1)})`;default:return n}},B=(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} -> ${B(e.item,r,t+1)})`;case"number":return`ModelWire.number(${n})`;case"record":return`ModelWire.readRecord(${n}, ${r} -> ${B(e.value,r,t+1)})`;case"string":return`ModelWire.text(${n})`;default:return n}},mn=e=>{const n=c(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.":""} */`]},fn=100,gn=e=>{const n=e.fields.map(r=>`${R(r.type)} ${r.name}`),t=` public ${e.name}(${n.join(", ")}) {`;return t.length<=fn?[t]:[` public ${e.name}(`,...n.map((r,a)=>` ${r}${a===n.length-1?") {":","}`)]},bn=e=>{const n=e.fields.flatMap(r=>{const a=`wire.put("${y(r.wireKey)}", ${G(r.type,`this.${r.name}`,0)});`;return r.optional?[` if (this.${r.name} != null) {`,` ${a}`," }"]:[` ${a}`]}),t=e.fields.map(r=>` ${B(r.type,`wire.get("${y(r.wireKey)}")`,0)}`);return[...D("java"),"",`package ${_};`,"","/**",` * 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 ${R(r.type)} ${r.name};`,""]),...gn(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(`,
109
+ `)});`]," }","}",""].join(`
110
+ `)},vn=e=>[...D("java"),"",`package ${_};`,"",`/** The \`${e.name}\` union. Each constant keeps the wire string it encodes to. */`,`public enum ${e.name} {`,...e.constants.map((n,t)=>` ${n.name}("${y(n.wireValue)}")${t===e.constants.length-1?";":","}`),""," private final String value;","",` ${e.name}(String value) {`," this.value = value;"," }",""," /** The wire string this constant encodes to. */"," public String toValue() {"," return this.value;"," }",""," /** The constant a wire string decodes to. */",` public static ${e.name} forValue(String value) {`,` for (${e.name} candidate : values()) {`," if (candidate.value.equals(value)) {"," return candidate;"," }"," }","",` throw new IllegalArgumentException("${e.name}: unknown wire value " + value);`," }","}",""].join(`
111
+ `),wn=[{lines:[' @SuppressWarnings("unchecked")'," static java.util.Map<String, Object> object(Object value) {"," return value instanceof java.util.Map"," ? (java.util.Map<String, Object>) value"," : new java.util.LinkedHashMap<String, Object>();"," }"],name:"object"},{lines:[" static String text(Object value) {"," return value instanceof String ? (String) value : null;"," }"],name:"text"},{lines:[" static Double number(Object value) {"," return value instanceof Number ? ((Number) value).doubleValue() : null;"," }"],name:"number"},{lines:[" static Boolean flag(Object value) {"," return value instanceof Boolean ? (Boolean) value : null;"," }"],name:"flag"},{lines:[" /** A nested model, or null when the payload carried no object there. */"," static <T> T readObject(Object value, java.util.function.Function<Object, T> read) {"," return value instanceof java.util.Map ? read.apply(value) : null;"," }"],name:"readObject"},{lines:[" /** An enum constant, or null when the payload carried no string there. */"," static <T> T readEnum(Object value, java.util.function.Function<String, T> read) {"," return value instanceof String ? read.apply((String) value) : null;"," }"],name:"readEnum"},{lines:[" static <T> java.util.List<T> readList("," Object value, java.util.function.Function<Object, T> read) {"," if (!(value instanceof java.util.List)) {"," return null;"," }",""," java.util.List<T> items = new java.util.ArrayList<T>();",""," for (Object item : (java.util.List<?>) value) {"," items.add(read.apply(item));"," }",""," return items;"," }"],name:"readList"},{lines:[" static <T> java.util.Map<String, T> readRecord("," Object value, java.util.function.Function<Object, T> read) {"," if (!(value instanceof java.util.Map)) {"," return null;"," }",""," java.util.Map<String, T> entries = new java.util.LinkedHashMap<String, T>();",""," for (java.util.Map.Entry<?, ?> entry : ((java.util.Map<?, ?>) value).entrySet()) {"," entries.put(String.valueOf(entry.getKey()), read.apply(entry.getValue()));"," }",""," return entries;"," }"],name:"readRecord"},{lines:[" static <T> java.util.List<Object> writeList("," java.util.List<T> items, java.util.function.Function<T, Object> write) {"," if (items == null) {"," return null;"," }",""," java.util.List<Object> encoded = new java.util.ArrayList<Object>(items.size());",""," for (T item : items) {"," encoded.add(write.apply(item));"," }",""," return encoded;"," }"],name:"writeList"},{lines:[" static <T> java.util.Map<String, Object> writeRecord("," java.util.Map<String, T> entries, java.util.function.Function<T, Object> write) {"," if (entries == null) {"," return null;"," }",""," java.util.Map<String, Object> encoded = new java.util.LinkedHashMap<String, Object>();",""," for (java.util.Map.Entry<String, T> entry : entries.entrySet()) {"," encoded.put(entry.getKey(), write.apply(entry.getValue()));"," }",""," return encoded;"," }"],name:"writeRecord"}],hn=e=>{const n=wn.filter(t=>e.includes(`ModelWire.${t.name}(`));return[...D("java"),"",`package ${_};`,"","/** Wire readers and writers shared by the generated models. */","final class ModelWire {"," private ModelWire() {}",...n.flatMap(t=>["",...t.lines]),"}",""].join(`
112
+ `)},jn=e=>{const n=Se(e);if(n.length===0)return{};const t={};for(const r of n)t[`${U}/${r.name}.java`]=r.kind==="enum"?vn(r):bn(r);return{[`${U}/ModelWire.java`]:hn(Object.values(t).join(`
113
+ `)),...t}},J=e=>{switch(e.kind){case"boolean":return"Boolean";case"class":case"enum":return e.name;case"list":return`List<${J(e.item)}>`;case"number":return"Double";case"record":return`Map<String, ${J(e.value)}>`;case"string":return"String";default:return"WireValue"}},E=(e,n,t)=>{const r=`item${String(t)}`,a=`entry${String(t)}`;switch(e.kind){case"boolean":return`WireValue.Bool(${n})`;case"class":return`${n}.toWire()`;case"enum":return`WireValue.Text(${n}.wireValue)`;case"list":return`WireValue.Arr(${n}.map { ${r} -> ${E(e.item,r,t+1)} })`;case"number":return`WireValue.Num(${n})`;case"record":return`WireValue.Obj(${n}.map { ${a} -> ${a}.key to ${E(e.value,`${a}.value`,t+1)} })`;case"string":return`WireValue.Text(${n})`;default:return n}},Y=(e,n,t,r)=>`wireNeed(${Ee(e,n,t,r)}, "${w(r)}")`,Ee=(e,n,t,r)=>{const a=`item${String(t)}`,s=`entry${String(t)}`;switch(e.kind){case"boolean":return`wireBool(${n})`;case"class":return`wireObj(${n})?.let { ${a} -> ${e.name}.fromWire(${a}) }`;case"enum":return`wireText(${n})?.let { ${a} -> ${e.name}.forValue(${a}) }`;case"list":return`wireArr(${n})?.items?.map { ${a} -> ${Y(e.item,a,t+1,`${r}[]`)} }`;case"number":return`wireNum(${n})`;case"record":return`wireObj(${n})?.fields?.associate { ${s} -> ${s}.first to ${Y(e.value,`${s}.second`,t+1,`${r}{}`)} }`;case"string":return`wireText(${n})`;default:return n}},_n=e=>{const n=e.fields.map(a=>{const s=c(a.wireKey);return[...a.optional?[" /**",` * Wire key \`${s}\` — OPTIONAL: null omits the key entirely, because`," * `v.optional` accepts the value or `undefined` and rejects an explicit null."," */"]:[` /** Wire key \`${s}\`.${a.nullable?" Nullable: null is sent as an explicit null.":""} */`],` val ${a.name}: ${J(a.type)}${a.optional||a.nullable?"?":""}${a.optional?" = null":""},`]}),t=e.fields.map(a=>{const s=w(a.wireKey),o=`this@${e.name}.${a.name}`;return a.optional?` ${o}?.let { add("${s}" to ${E(a.type,"it",0)}) }`:a.nullable?` add("${s}" to (${o}?.let { ${E(a.type,"it",0)} } ?: WireValue.Null))`:` add("${s}" to ${E(a.type,o,0)})`}),r=e.fields.map(a=>{const s=`wireField(value, "${w(a.wireKey)}")`,o=a.optional||a.nullable?Ee(a.type,s,0,a.wireKey):Y(a.type,s,0,a.wireKey);return` ${a.name} = ${o},`});return["/**",` * The \`${e.name}\` model.`," *"," * Property names are local; the keys [toWire] and [fromWire] use are the schema's own,"," * emitted verbatim, so a renamed property cannot reach the wire."," */",`class ${e.name}(`,...n.flat(),") {"," /** This model as the wire-shaped object the transport encodes. */"," fun toWire(): WireValue ="," WireValue.Obj("," buildList {",...t," },"," )",""," companion object {"," /** Rebuild from a decoded wire value. */",` fun fromWire(value: WireValue): ${e.name} =`,` ${e.name}(`,...r," )"," }","}"]},An=e=>[`/** The \`${e.name}\` union. Each entry keeps the wire string it encodes to. */`,`enum class ${e.name}(val wireValue: String) {`,...e.constants.map(n=>` ${n.name}("${w(n.wireValue)}"),`)," ;",""," companion object {"," /** The entry a wire string decodes to. */",` fun forValue(value: String): ${e.name} =`," entries.firstOrNull { it.wireValue == value }",` ?: throw IllegalArgumentException("${e.name}: unknown wire value " + value)`," }","}"],Sn=[{lines:["private fun wireField(value: WireValue, key: String): WireValue? ="," (value as? WireValue.Obj)?.fields?.firstOrNull { it.first == key }?.second"],name:"wireField"},{lines:["private fun wireText(value: WireValue?): String? = (value as? WireValue.Text)?.value"],name:"wireText"},{lines:["private fun wireNum(value: WireValue?): Double? = (value as? WireValue.Num)?.value"],name:"wireNum"},{lines:["private fun wireBool(value: WireValue?): Boolean? = (value as? WireValue.Bool)?.value"],name:"wireBool"},{lines:["private fun wireArr(value: WireValue?): WireValue.Arr? = value as? WireValue.Arr"],name:"wireArr"},{lines:["private fun wireObj(value: WireValue?): WireValue.Obj? = value as? WireValue.Obj"],name:"wireObj"},{lines:["/** A required field the payload omitted or mistyped is a contract violation, not a null. */","private fun <T> wireNeed(read: T?, label: String): T =",' read ?: throw WireFormatException("lunora: the wire payload is missing or mistyped " + label)'],name:"wireNeed"}],En=e=>{const n=Se(e);if(n.length===0)return{};const t=n.flatMap(o=>[...o.kind==="enum"?An(o):_n(o),""]),r=Sn.filter(o=>t.some(i=>i.includes(`${o.name}(`))),a=r.flatMap((o,i)=>i===0?[...o.lines]:["",...o.lines]),s=[...D("kotlin"),"",`package ${_}`,"",...r.some(o=>o.name==="wireNeed")?["import dev.lunora.WireFormatException"]:[],"import dev.lunora.WireValue","",...t,...a,""].join(`
114
+ `);return{[`${U}/Models.kt`]:s}},Tn=`${b("java").map(e=>`// ${e}`).join(`
115
+ `)}
116
+
117
+ `,le="lunoraapi",kn=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"]),C=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1);return kn.has(t)?`${t}_`:t},Nn=e=>`Client.Verb.${e.toUpperCase()}`,Z=e=>e.argsType===void 0?{payload:"args",type:"java.util.Map<String, Object>"}:{payload:"args == null ? null : args.toWire()",type:e.argsType},ce=e=>{const n=Z(e),t=`client.call(
118
+ ${Nn(e.verb)}, "${y(e.functionPath)}", ${n.payload}, shardKey)`;return[` /** ${c(e.summary)} */`,` public ${e.resultType??"Object"} ${C(e.functionName)}(${n.type} args, String shardKey) {`,` return ${e.resultType===void 0?t:`${e.resultType}.fromWire(${t})`};`," }"].join(`
119
+ `)},On=e=>{const n=Z(e);return[` /** live ${c(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(",` "${y(e.functionPath)}", ${n.payload}, onData, onError, shardKey);`," }"].join(`
120
+ `)},Cn=e=>{const n=Z(e);return[` /** live ${c(e.summary)}, as a \`Client.Watch\` — close it to unsubscribe. */`,` public Client.Watch watch${l(e.functionName)}(`,` ${n.type} args,`," String shardKey) {",` return client.watch("${y(e.functionPath)}", ${n.payload}, shardKey);`," }"].join(`
121
+ `)},Wn=e=>{const n=`${l(e.name)}Api`,t=e.methods.map(r=>r.verb==="query"?`${ce(r)}
122
+
123
+ ${On(r)}
124
+
125
+ ${Cn(r)}`:ce(r)).join(`
126
+
127
+ `);return[` /** Functions declared in \`${c(e.name)}\`. */`,` public static final class ${n} {`," private final Client client;","",` ${n}(Client client) {`," this.client = client;"," }","",t.replaceAll(/^ {4}/gmu," ")," }"].join(`
128
+ `)},Ln=({namespaces:e})=>{T(e,"Java",s=>[C(s.functionName)]);const n=e.map(s=>` public final ${l(s.name)}Api ${C(s.name)};`).join(`
129
+ `),t=e.map(s=>` this.${C(s.name)} = new ${l(s.name)}Api(client);`).join(`
130
+ `),r=P(e).map(s=>`import ${_}.${s};
131
+ `),a=[Tn,`package ${le};
132
+ `,`
133
+ `,`import dev.lunora.Client;
134
+ `,...r,`
135
+ `,"/** Typed entry point: `new Api(client).<namespace>.<function>(args, shardKey)`. */\n",`public final class Api {
136
+ `,n.length>0?`${n}
137
+
138
+ `:"",` public Api(Client client) {
139
+ `,t.length>0?`${t}
140
+ `:` // No functions in this deployment.
141
+ `,` }
142
+ `,`
143
+ `,e.map(s=>Wn(s)).join(`
144
+
145
+ `),`
146
+ }
147
+ `].join("");return{[`${le}/Api.java`]:a}},Rn={id:"java",render:Ln,renderModels:jn,requires:[],vendor:[{from:"src/dev/lunora",to:"dev/lunora"}]},Mn=`${b("kotlin").map(e=>`// ${e}`).join(`
148
+ `)}
149
+
150
+ `,ue="lunoraapi",Pn=new Set(["as","break","class","continue","do","else","false","for","fun","if","in","interface","is","null","object","package","return","super","this","throw","true","try","typealias","typeof","val","var","when","while"]),Te=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1);return Pn.has(t)?`\`${t}\``:t},Dn=e=>`Verb.${e.toUpperCase()}`,X=e=>e.argsType===void 0?{declaration:"args: WireValue? = null",payload:"args"}:{declaration:`args: ${e.argsType}`,payload:"args.toWire()"},pe=e=>{const n=X(e),t=`client.call(${Dn(e.verb)}, "${w(e.functionPath)}", ${n.payload}, shardKey)`;return[` /** ${c(e.summary)} */`,` fun ${Te(e.functionName)}(${n.declaration}, shardKey: String? = null): ${e.resultType??"WireValue"} =`,` ${e.resultType===void 0?t:`${e.resultType}.fromWire(${t})`}`].join(`
151
+ `)},Vn=e=>{const n=X(e);return[` /** live ${c(e.summary)} — re-runs on every write to the tables it reads. */`,` fun subscribe${l(e.functionName)}(`,` ${n.declaration},`," onData: ((WireValue) -> Unit)?,"," onError: ((SubscriptionError) -> Unit)? = null,"," shardKey: String? = null,"," ): () -> Unit =",` client.subscribe("${w(e.functionPath)}", ${n.payload}, onData, onError, shardKey)`].join(`
152
+ `)},Kn=e=>{const n=X(e);return[` /** live ${c(e.summary)}, as a \`Client.Watch\` — close it to unsubscribe. */`,` fun watch${l(e.functionName)}(`,` ${n.declaration},`," shardKey: String? = null,"," ): Client.Watch =",` client.watch("${w(e.functionPath)}", ${n.payload}, shardKey)`].join(`
153
+ `)},In=e=>{const n=`${l(e.name)}Api`,t=e.methods.map(r=>r.verb==="query"?`${pe(r)}
154
+
155
+ ${Vn(r)}
156
+
157
+ ${Kn(r)}`:pe(r)).join(`
158
+
159
+ `);return[`/** Functions declared in \`${c(e.name)}\`. */`,`class ${n}(private val client: Client) {`,t,"}"].join(`
160
+ `)},xn=({namespaces:e})=>{const n=e.map(s=>` val ${Te(s.name)}: ${l(s.name)}Api = ${l(s.name)}Api(client)`).join(`
161
+ `),t=e.flatMap(s=>s.methods),r=[`import dev.lunora.Client
162
+ `,...t.some(s=>s.verb==="query")?[`import dev.lunora.SubscriptionError
163
+ `]:[],`import dev.lunora.Verb
164
+ `,...t.some(s=>s.argsType===void 0||s.resultType===void 0)?[`import dev.lunora.WireValue
165
+ `]:[],...P(e).map(s=>`import ${_}.${s}
166
+ `)],a=[Mn,`package ${ue}
167
+ `,`
168
+ `,...r,`
169
+ `,e.map(s=>In(s)).join(`
170
+
171
+ `),`
172
+
173
+ `,"/** Typed entry point: `Api(client).<namespace>.<function>(args)`. */\n",`class Api(client: Client) {
174
+ `,n.length>0?`${n}
175
+ `:` init { require(true) { client } }
176
+ `,`}
177
+ `].join("");return{[`${ue}/Api.kt`]:a}},Fn={id:"kotlin",render:xn,renderModels:En,requires:[],vendor:[{from:"src",to:"dev/lunora"}]},qn=new Set(["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","False","finally","for","from","global","if","import","in","is","lambda","None","nonlocal","not","or","pass","raise","return","True","try","while","with","yield"]),k=`"""${b("python").join(`
178
+
179
+ `)}
180
+ """
181
+
182
+ `,x="lunora_api",v=e=>{const n=h(e);return qn.has(n)?`${n}_`:n},Q=e=>$(e,{none:"{}",typed:()=>"args.to_dict()",untyped:"args"}),Un=(e,n,t,r)=>$(e,{none:n,typed:t,untyped:r}),de=e=>{const n=e.resultType??"Any",t=Un(e,"self",s=>`self, args: ${s}`,"self, args: Any"),r=Q(e),a=`await self._client.${e.verb}("${y(e.functionPath)}", ${r}, shard_key)`;return[` async def ${v(e.functionName)}(${t}, *, shard_key: Optional[str] = None) -> ${n}:`,` """${c(e.summary)}"""`,` ${e.resultType===void 0?`return ${a}`:`return ${e.resultType}.from_dict(${a})`}`].join(`
183
+ `)},Hn=e=>{const n=Q(e),t=["self",...$(e,{none:[],typed:r=>[`args: ${r}`],untyped:["args: Any"]}),"on_data: Callback","on_error: Optional[ErrorCallback] = None","*","shard_key: Optional[str] = None"];return[` def subscribe_${v(e.functionName)}(`,...t.map(r=>` ${r},`)," ) -> Unsubscribe:",` """live ${c(e.summary)} — re-runs on every write to the tables it reads."""`,` return self._client.subscribe("${y(e.functionPath)}", ${n}, on_data, on_error, shard_key)`].join(`
184
+ `)},Gn=e=>{const n=Q(e),t=["self",...$(e,{none:[],typed:r=>[`args: ${r}`],untyped:["args: Any"]}),"*","shard_key: Optional[str] = None"];return[` def watch_${v(e.functionName)}(`,...t.map(r=>` ${r},`)," ) -> AsyncIterator:",` """live ${c(e.summary)} as an async iterator — \`async for\` over it; \`aclose()\` unsubscribes, and a watch the loop never started is released only by it."""`,` return self._client.watch("${y(e.functionPath)}", ${n}, shard_key)`].join(`
185
+ `)},Bn=e=>{const n=e.methods.map(t=>t.verb==="query"?`${de(t)}
186
+
187
+ ${Hn(t)}
188
+
189
+ ${Gn(t)}`:de(t)).join(`
190
+
191
+ `);return[`class ${l(e.name)}Api:`,` """Functions declared in \`${c(e.name)}\`."""`,""," def __init__(self, client: LunoraClient) -> None:"," self._client = client","",n].join(`
192
+ `)},Jn=e=>e.replaceAll(/^([ \t]*)except:$/gmu,"$1except Exception:"),Yn=({models:e,namespaces:n})=>{T(n,"Python",d=>[v(d.functionName),`subscribe_${v(d.functionName)}`,`watch_${v(d.functionName)}`]);const t=P(n),r=t.length>0?`from .models import ${t.join(", ")}
193
+ `:"",s=N(n).some(d=>d.verb==="query")?"Callback, ErrorCallback, LunoraClient, Unsubscribe":"LunoraClient",o=N(n).some(d=>d.resultType===void 0),i=N(n).some(d=>d.verb==="query"),p=n.map(d=>` self.${v(d.name)} = ${l(d.name)}Api(client)`).join(`
194
+ `),u=[k,`from typing import ${[...o?["Any"]:[],...i?["AsyncIterator"]:[],"Optional"].join(", ")}
195
+ `,`
196
+ `,`from lunora.client import ${s}
197
+ `,r,`
198
+
199
+ `,n.map(d=>Bn(d)).join(`
200
+
201
+
202
+ `),`
203
+
204
+
205
+ `,`class Api:
206
+ `,' """Typed entry point: `Api(client).<namespace>.<function>(args)`."""\n',`
207
+ `,` def __init__(self, client: LunoraClient) -> None:
208
+ `,p.length>0?`${p}
209
+ `:` pass
210
+ `].join(""),m=["Api",...n.map(d=>`${l(d.name)}Api`)];return{[`${x}/__init__.py`]:[k,`from .api import ${m.join(", ")}
211
+ `,`
212
+ `,`__all__ = [${m.map(d=>`"${d}"`).join(", ")}]
213
+ `].join(""),[`${x}/api.py`]:u,[`${x}/models.py`]:e.length>0?`${k}${Jn(e)}
214
+ `:`${k}# No typed argument or result schemas in this deployment.
215
+ `}},zn={id:"python",quicktype:{lang:"python",rendererOptions:{"python-version":"3.7"}},render:Yn,requires:[],vendor:[{from:"lunora",to:"lunora"}]},F=`${b("ruby").map(e=>`# ${e}`).join(`
216
+ `)}
217
+
218
+ `,Zn=new Set(["alias","and","begin","break","case","class","def","defined?","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield"]),V=e=>y(e).replaceAll("#","\\#"),f=e=>{const n=h(e);return Zn.has(n)?`${n}_`:n},Xn=` # Delegates to the transport, which owns the projection and its tests — see
219
+ # \`Lunora.wire_args\`. The path list is generated per model because only the
220
+ # schema knows which nils may be dropped.
221
+ def self.wire_args(model, optional_paths = [])
222
+ Lunora.wire_args(model, optional_paths)
223
+ end
224
+
225
+ `,Qn=e=>`[${e.map(n=>`[${n.map(t=>`"${V(t)}"`).join(", ")}]`).join(", ")}]`,ee=e=>$(e,{none:"{}",typed:()=>`LunoraApi.wire_args(args, ${Qn(e.argsNullPaths.optional)})`,untyped:"args"}),$e=e=>{const n=e.argsType===void 0&&!e.takesArgs?"shard_key: nil":"args, shard_key: nil",t=ee(e),r=`@client.${e.verb}("${V(e.functionPath)}", ${t}, shard_key)`,a=e.resultType===void 0?r:`${e.resultType}.from_dynamic!(${r})`;return[` # ${c(e.summary)}`,` def ${f(e.functionName)}(${n})`,` ${a}`," end"].join(`
226
+ `)},et=e=>{const n=e.argsType===void 0&&!e.takesArgs?"on_data, on_error = nil, shard_key: nil":"args, on_data, on_error = nil, shard_key: nil",t=ee(e);return[` # live ${c(e.summary)} — re-runs on every write to the tables it reads.`,` def subscribe_${f(e.functionName)}(${n})`,` @client.subscribe("${V(e.functionPath)}", ${t}, on_data, on_error, shard_key)`," end"].join(`
227
+ `)},nt=e=>{const n=e.argsType===void 0&&!e.takesArgs?"shard_key: nil":"args, shard_key: nil",t=ee(e);return[` # live ${c(e.summary)}, as an Enumerator — call \`stop\` on the pair to unsubscribe.`,` def watch_${f(e.functionName)}(${n})`,` @client.watch("${V(e.functionPath)}", ${t}, shard_key)`," end"].join(`
228
+ `)},tt=e=>{const n=e.methods.map(t=>t.verb==="query"?`${$e(t)}
229
+
230
+ ${et(t)}
231
+
232
+ ${nt(t)}`:$e(t)).join(`
233
+
234
+ `);return[` # Functions declared in \`${c(e.name)}\`.`,` class ${l(e.name)}Api`," def initialize(client)"," @client = client"," end","",n," end"].join(`
235
+ `)},rt=/^class \w+ < Dry::Struct\n[\s\S]*?def self\.from_dynamic!\(d\)\n\s*d = Types::Hash\[d\]/u,at=(e,n)=>{const t=new Map;for(const i of n.matchAll(/^class (\w+)\b[^\n]*\n[\s\S]*?^end$/gmu))t.set(i[1],i[0]);const r=i=>rt.test(i),a=new Set([...t].filter(([,i])=>i.includes("< Dry::Struct")&&!r(i)).map(([i])=>i));let s=!0;for(;s;){s=!1;for(const[i,p]of t)!a.has(i)&&[...a].some(u=>new RegExp(String.raw`\b${u}\b`,"u").test(p))&&(a.add(i),s=!0)}const o=i=>{const p=i===void 0?void 0:t.get(i);return p!==void 0&&r(p)&&!a.has(i)?i:void 0};return e.map(i=>({methods:i.methods.map(p=>({...p,argsType:o(p.argsType),resultType:o(p.resultType)})),name:i.name}))},st=({models:e,namespaces:n})=>{T(n,"Ruby",o=>[f(o.functionName),`subscribe_${f(o.functionName)}`,`watch_${f(o.functionName)}`]);const t=at(n,e),r=t.map(o=>`:${f(o.name)}`).join(", "),a=t.map(o=>` @${f(o.name)} = ${l(o.name)}Api.new(client)`).join(`
236
+ `);return{"api.rb":[`# frozen_string_literal: true
237
+
238
+ `,F,`require_relative "models"
239
+ `,`
240
+ `,`module LunoraApi
241
+ `,N(t).some(o=>o.argsType!==void 0)?Xn:"",t.map(o=>tt(o)).join(`
242
+
243
+ `),`
244
+
245
+ `," # Typed entry point: `Api.new(client).<namespace>.<function>(args)`.\n",` class Api
246
+ `,r.length>0?` attr_reader ${r}
247
+
248
+ `:"",` def initialize(client)
249
+ `,a.length>0?`${a}
250
+ `:` @client = client
251
+ `,` end
252
+ `,` end
253
+ `,`end
254
+ `].join(""),"models.rb":e.length>0?`# frozen_string_literal: true
255
+
256
+ ${F}${e}
257
+ `:`# frozen_string_literal: true
258
+
259
+ ${F}# No typed argument or result schemas in this deployment.
260
+ `}},it={id:"ruby",quicktype:{lang:"ruby",rendererOptions:{}},render:st,requires:["dry-struct + dry-types (gems, required by the generated models)"],vendor:[{from:"lib/lunora.rb",to:"lunora.rb"},{from:"lib/lunora",to:"lunora"}]},W=`${b("rust").map(e=>`// ${e}`).join(`
261
+ `)}
262
+
263
+ `,ot=`${W}pub mod api;
264
+ pub mod models;
265
+ `,lt=`# The generated Lunora Rust SDK, with the transport vendored under ./lunora.
266
+ #
267
+ # Add to a consuming crate:
268
+ #
269
+ # lunora-api = { path = "sdk/rust" }
270
+
271
+ [package]
272
+ name = "lunora-api"
273
+ version = "0.1.0"
274
+ edition = "2021"
275
+ publish = false
276
+
277
+ # Its own workspace root, so a consumer whose project IS a workspace does not
278
+ # adopt this directory as a member (which then fails to build on its own).
279
+ [workspace]
280
+
281
+ [dependencies]
282
+ lunora = { path = "lunora" }
283
+ serde = { version = "1", features = ["derive"] }
284
+ serde_json = "1"
285
+ `,ct=new Set(["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","static","struct","super","trait","true","try","type","typeof","unsafe","unsized","use","virtual","where","while","yield"]),ut=new Set(["crate","self","Self","super"]),M=e=>{const n=h(e);return ut.has(n)?`${n}_`:ct.has(n)?`r#${n}`:n},pt=e=>`Verb::${l(e)}`,ne=e=>e.length===0?"&[]":`&[${e.map(n=>`&["${n.map(t=>y(t)).join('", "')}"][..]`).join(", ")}]`,ye=e=>{const n=$(e,{none:"&self, shard_key: Option<&str>",typed:a=>`&self, args: &${a}, shard_key: Option<&str>`,untyped:"&self, args: &WireValue, shard_key: Option<&str>"}),t=$(e,{none:"&WireValue::Object(Vec::new())",typed:()=>`&from_model_json(&serde_json::to_value(args).map_err(|error| ClientError::Transport(error.to_string()))?, ${ne(e.argsNullPaths.optional)})`,untyped:"args"}),r=`self.client.call(${pt(e.verb)}, "${y(e.functionPath)}", ${t}, shard_key)`;return e.resultType===void 0?[` /// ${c(e.summary)}`,` pub fn ${M(e.functionName)}(${n}) -> Result<WireValue, ClientError> {`,` ${r}`," }"].join(`
286
+ `):[` /// ${c(e.summary)}`,` pub fn ${M(e.functionName)}(${n}) -> Result<${e.resultType}, ClientError> {`,` let raw = ${r}?;`," let json = encode_wire(&raw).map_err(ClientError::Wire)?;"," serde_json::from_value(json).map_err(|error| ClientError::Transport(error.to_string()))"," }"].join(`
287
+ `)},dt=e=>{const n=$(e,{none:"",typed:r=>`args: &${r}, `,untyped:"args: &WireValue, "}),t=$(e,{none:"WireValue::Object(Vec::new())",typed:()=>`from_model_json(&serde_json::to_value(args).map_err(|error| ClientError::Transport(error.to_string()))?, ${ne(e.argsNullPaths.optional)})`,untyped:"args.clone()"});return[` /// live ${c(e.summary)} — re-runs on every write to the tables it reads.`,` pub fn subscribe_${h(e.functionName)}(`," &mut self,",` ${n}on_data: DataHandler,`," on_error: ErrorHandler,"," shard_key: Option<&str>,"," ) -> Result<String, ClientError> {",` Ok(self.client.subscribe_on_shard("${y(e.functionPath)}", ${t}, on_data, on_error, shard_key))`," }"].join(`
288
+ `)},$t=e=>{const n=$(e,{none:"",typed:r=>`args: &${r}, `,untyped:"args: &WireValue, "}),t=$(e,{none:"WireValue::Object(Vec::new())",typed:()=>`from_model_json(&serde_json::to_value(args).map_err(|error| ClientError::Transport(error.to_string()))?, ${ne(e.argsNullPaths.optional)})`,untyped:"args.clone()"});return[` /// live ${c(e.summary)}, as a receiver — each event arrives on it; \`unsubscribe\` the id to stop.`,` pub fn watch_${h(e.functionName)}(`," &mut self,",` ${n}shard_key: Option<&str>,`," ) -> Result<(Receiver<WatchEvent>, String), ClientError> {",` Ok(self.client.watch("${y(e.functionPath)}", ${t}, shard_key))`," }"].join(`
289
+ `)},yt=e=>{const n=`${l(e.name)}Api`,t=e.methods.map(r=>r.verb==="query"?`${ye(r)}
290
+
291
+ ${dt(r)}
292
+
293
+ ${$t(r)}`:ye(r)).join(`
294
+
295
+ `);return[`/// Functions declared in \`${c(e.name)}\`.`,`pub struct ${n}<'client> {`," client: &'client mut Client,","}","",`impl<'client> ${n}<'client> {`,t,"}"].join(`
296
+ `)},mt=({models:e,namespaces:n})=>{T(n,"Rust",a=>[M(a.functionName),`subscribe_${h(a.functionName)}`,`watch_${h(a.functionName)}`]);const t=n.map(a=>[` /// Functions declared in \`${c(a.name)}\`.`,` pub fn ${M(a.name)}(&mut self) -> ${l(a.name)}Api<'_> {`,` ${l(a.name)}Api { client: self.client }`," }"].join(`
297
+ `)).join(`
298
+
299
+ `),r=[W,`#![allow(dead_code, unused_imports)]
300
+ `,`
301
+ `,`use lunora::client::{Client, ClientError, DataHandler, ErrorHandler, WatchEvent, Verb};
302
+ `,`use std::sync::mpsc::Receiver;
303
+ `,`use lunora::wire::{encode_wire, from_model_json, WireValue};
304
+ `,`
305
+ `,`use crate::models::*;
306
+ `,`
307
+ `,n.map(a=>yt(a)).join(`
308
+
309
+ `),`
310
+
311
+ `,"/// Typed entry point: `Api::new(&client).<namespace>().<function>(args)`.\n",`pub struct Api<'client> {
312
+ `,` client: &'client mut Client,
313
+ `,`}
314
+ `,`
315
+ `,`impl<'client> Api<'client> {
316
+ `,` pub fn new(client: &'client mut Client) -> Self {
317
+ `,` Self { client }
318
+ `,` }
319
+ `,t.length>0?`
320
+ ${t}
321
+ `:"",`}
322
+ `].join("");return{"Cargo.toml":lt,"src/api.rs":r,"src/lib.rs":ot,"src/models.rs":e.length>0?`${W}#![allow(dead_code)]
323
+
324
+ ${e}
325
+ `:`${W}#![allow(dead_code)]
326
+
327
+ // No typed argument or result schemas in this deployment.
328
+ `}},ft={id:"rust",quicktype:{lang:"rust",rendererOptions:{"just-types":"true"}},render:mt,requires:["serde (derive) + serde_json — declared in the emitted Cargo.toml, fetched by cargo"],vendor:[{from:"Cargo.toml",to:"lunora/Cargo.toml"},{from:"src",to:"lunora/src"}]},q=`${b("swift").map(e=>`// ${e}`).join(`
329
+ `)}
330
+
331
+ `,me="Sources/LunoraApi",gt=`// swift-tools-version:5.9
332
+
333
+ import PackageDescription
334
+
335
+ // The generated Lunora Swift SDK, with the transport vendored under
336
+ // Sources/Lunora. Add to a consuming package — where "swift" below is the NAME OF
337
+ // THE DIRECTORY THIS FILE IS IN, which is how SwiftPM identifies a local path
338
+ // dependency. It ignores the "name:" field for that, and a bare product name in a
339
+ // target's dependencies does not resolve at all, so the directory name is the one
340
+ // spelling that works:
341
+ //
342
+ // dependencies: [.package(path: "sdk/swift")],
343
+ // targets: [
344
+ // .target(
345
+ // name: "YourTarget",
346
+ // dependencies: [.product(name: "LunoraApi", package: "swift")]
347
+ // )
348
+ // ]
349
+ let package = Package(
350
+ name: "LunoraSdk",
351
+ platforms: [.macOS(.v12), .iOS(.v15)],
352
+ products: [
353
+ .library(name: "LunoraApi", targets: ["LunoraApi"]),
354
+ .library(name: "Lunora", targets: ["Lunora"]),
355
+ ],
356
+ targets: [
357
+ .target(name: "Lunora"),
358
+ .target(name: "LunoraApi", dependencies: ["Lunora"]),
359
+ ]
360
+ )
361
+ `,bt=new Set(["as","associatedtype","borrowing","break","case","catch","class","consuming","continue","default","defer","deinit","do","else","enum","extension","fallthrough","false","fileprivate","for","func","guard","if","import","in","init","inout","internal","is","let","nil","nonisolated","open","operator","precedencegroup","private","protocol","public","repeat","rethrows","return","self","static","struct","subscript","super","switch","throw","throws","true","try","typealias","var","where","while"]),z=e=>{const n=l(e),t=n.charAt(0).toLowerCase()+n.slice(1);return bt.has(t)?`\`${t}\``:t},vt=e=>`[${e.map(n=>`["${n.map(t=>y(t)).join('", "')}"]`).join(", ")}]`,te=e=>$(e,{none:"nil",typed:()=>{const{nullable:n}=e.argsNullPaths;return n.length===0?"try LunoraClient.wireValue(args)":`try LunoraClient.wireValue(args, nullablePaths: ${vt(n)})`},untyped:"args"}),fe=e=>{const n=$(e,{none:"shardKey: String? = nil",typed:o=>`_ args: ${o}, shardKey: String? = nil`,untyped:"_ args: Any, shardKey: String? = nil"}),t=te(e),r=e.resultType??"Any",a=`try client.${e.verb}("${y(e.functionPath)}", args: ${t}, shardKey: shardKey)`,s=e.resultType===void 0?`return ${a}`:[`let raw = ${a}`," let data = Data(Wire.stableStringify(raw).utf8)",` return try JSONDecoder().decode(${e.resultType}.self, from: data)`].join(`
362
+ `);return[` /// ${c(e.summary)}`,` public func ${z(e.functionName)}(${n}) throws -> ${r} {`,` ${s}`," }"].join(`
363
+ `)},wt=e=>{const n=$(e,{none:"",typed:r=>`_ args: ${r}, `,untyped:"_ args: Any, "}),t=te(e);return[` /// live ${c(e.summary)} — re-runs on every write to the tables it reads.`," @discardableResult",` public func subscribe${l(e.functionName)}(`,` ${n}onData: ((Any) -> Void)?,`," onError: ((LunoraSubscriptionError) -> Void)? = nil,"," shardKey: String? = nil"," ) throws -> LunoraUnsubscribe {",` client.subscribe("${y(e.functionPath)}", args: ${t}, onData: onData, onError: onError, shardKey: shardKey)`," }"].join(`
364
+ `)},ht=e=>{const n=$(e,{none:"",typed:r=>`_ args: ${r}, `,untyped:"_ args: Any, "}),t=$(e,{none:"nil",typed:()=>te(e),untyped:"try Wire.encode(args)"});return[` /// live ${c(e.summary)}, as a \`LunoraWatch\` — \`for await\` over it; \`cancel()\` unsubscribes, since leaving the loop does not.`,` public func watch${l(e.functionName)}(`,` ${n}shardKey: String? = nil`," ) throws -> LunoraClient.LunoraWatch {",` client.watch("${y(e.functionPath)}", args: ${t}, shardKey: shardKey)`," }"].join(`
365
+ `)},jt=e=>{const n=`${l(e.name)}API`,t=e.methods.map(r=>r.verb==="query"?`${fe(r)}
366
+
367
+ ${wt(r)}
368
+
369
+ ${ht(r)}`:fe(r)).join(`
370
+
371
+ `);return[`/// Functions declared in \`${c(e.name)}\`.`,`public struct ${n} {`," let client: LunoraClient","",t,"}"].join(`
372
+ `)},_t=({models:e,namespaces:n})=>{const t=n.map(s=>` public let ${z(s.name)}: ${l(s.name)}API`).join(`
373
+ `),r=n.map(s=>` ${z(s.name)} = ${l(s.name)}API(client: client)`).join(`
374
+ `),a=[q,`import Foundation
375
+ `,`import Lunora
376
+ `,`
377
+ `,n.map(s=>jt(s)).join(`
378
+
379
+ `),`
380
+
381
+ `,"/// Typed entry point: `API(client:).<namespace>.<function>(args)`.\n",`public struct API {
382
+ `,t.length>0?`${t}
383
+
384
+ `:"",` public init(client: LunoraClient) {
385
+ `,r.length>0?`${r}
386
+ `:` _ = client
387
+ `,` }
388
+ `,`}
389
+ `].join("");return{"Package.swift":gt,[`${me}/Api.swift`]:a,[`${me}/Models.swift`]:e.length>0?`${q}${e}
390
+ `:`${q}import Foundation
391
+
392
+ // No typed argument or result schemas in this deployment.
393
+ `}},At={id:"swift",quicktype:{lang:"swift",rendererOptions:{"access-level":"public",initializers:"false"}},render:_t,requires:[],vendor:[{from:"Sources/Lunora",to:"Sources/Lunora"}]},St={dart:Ye,go:rn,java:Rn,kotlin:Fn,python:zn,ruby:it,rust:ft,swift:At},Tt=Object.keys(St).toSorted((e,n)=>e.localeCompare(n)),kt=async(e,n)=>{const t=Ne(e);Oe(t);const r=n.renderModels?.(e),a=r===void 0?await Re(e,n):Object.values(r).join(`
394
+ `),s=Ce(t,a);return{files:{...r,...n.render({models:a,namespaces:s})},undeclared:Le(t,a),unrepresentable:We(e)}};export{Tt as SDK_LANGUAGES,St as SDK_TARGETS,kt as generateSdk,Ct as isTypedSchema};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/codegen",
3
- "version": "1.0.0-alpha.43",
3
+ "version": "1.0.0-alpha.430",
4
4
  "description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "homepage": "https://lunora.sh",
16
16
  "bugs": "https://github.com/anolilab/lunora/issues",
17
- "license": "FSL-1.1-Apache-2.0",
17
+ "license": "Apache-2.0",
18
18
  "author": {
19
19
  "name": "Daniel Bannert",
20
20
  "email": "d.bannert@anolilab.de"
@@ -40,22 +40,44 @@
40
40
  "types": "./dist/index.d.ts",
41
41
  "import": "./dist/index.mjs"
42
42
  },
43
+ "./sdk": {
44
+ "types": "./dist/sdk/index.d.ts",
45
+ "import": "./dist/sdk/index.mjs"
46
+ },
43
47
  "./package.json": "./package.json"
44
48
  },
45
49
  "publishConfig": {
46
50
  "access": "public"
47
51
  },
48
52
  "dependencies": {
49
- "@lunora/advisor": "1.0.0-alpha.27",
50
- "@lunora/agent": "1.0.0-alpha.1",
51
- "@lunora/container": "1.0.0-alpha.11",
52
- "@lunora/errors": "1.0.0-alpha.4",
53
- "@lunora/queue": "1.0.0-alpha.7",
54
- "@lunora/scheduler": "1.0.0-alpha.9",
55
- "@lunora/values": "1.0.0-alpha.7",
56
- "@lunora/workflow": "1.0.0-alpha.9",
53
+ "@lunora/advisor": "^1.0.0-alpha.295",
54
+ "@lunora/agent": "^1.0.0-alpha.284",
55
+ "@lunora/container": "1.0.0-alpha.108",
56
+ "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
57
+ "@lunora/platform": "^1.0.0-alpha.83",
58
+ "@lunora/queue": "^1.0.0-alpha.145",
59
+ "@lunora/scheduler": "^1.0.0-alpha.171",
60
+ "@lunora/values": "^1.0.0-alpha.95",
61
+ "@lunora/workflow": "^1.0.0-alpha.111",
62
+ "@visulima/fs": "7.0.0",
63
+ "jiti": "^2.7.0",
64
+ "quicktype-core": "^26.0.0",
57
65
  "ts-morph": "^28.0.0"
58
66
  },
67
+ "peerDependencies": {
68
+ "@lunora/auth": ">=1.0.0-alpha.267 <2.0.0-0",
69
+ "@lunora/d1": ">=1.0.0-alpha.236 <2.0.0-0",
70
+ "@lunora/server": ">=1.0.0-alpha.91 <2.0.0-0",
71
+ "@lunora/shard-engine": ">=1.0.0-alpha.45 <2.0.0-0"
72
+ },
73
+ "peerDependenciesMeta": {
74
+ "@lunora/auth": {
75
+ "optional": true
76
+ },
77
+ "@lunora/d1": {
78
+ "optional": true
79
+ }
80
+ },
59
81
  "engines": {
60
82
  "node": "^22.15.0 || >=24.11.0"
61
83
  }