@lunora/codegen 1.0.0-alpha.104 → 1.0.0-alpha.106

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.
@@ -1,19 +1,19 @@
1
- import{modelSources as ne,toPascalCase as s,generatedHeaderLines as f,commentText as l,stringLiteral as d,kotlinLiteral as h,referencedModels as R,allMethods as C,toSnakeCase as H,parseSpec as me,assertGeneratable as $e,withDeclaredModels as fe,unrepresentableFunctions as ye,undeclaredModels as he}from"./isTypedSchema-C-UHYeJq.mjs";import{isTypedSchema as Ir}from"./isTypedSchema-C-UHYeJq.mjs";const ge=async(e,r)=>{if(r.quicktype===void 0)return"";const t=ne(e);if(t.length===0)return"";const{InputData:n,JSONSchemaInput:a,JSONSchemaStore:i,quicktype:o}=await import("quicktype-core");class c extends i{fetch(){return Promise.resolve(void 0)}}const p=new a(new c);for(const O of t)await p.addSource({name:O.name,schema:JSON.stringify(O.schema)});const u=new n;u.addInput(p);const{lines:$}=await o({inputData:u,lang:r.quicktype.lang,rendererOptions:r.quicktype.rendererOptions??{}});return $.join(`
2
- `)},W=`${f("go").map(e=>`// ${e}`).join(`
1
+ import{modelSources as ae,toPascalCase as s,generatedHeaderLines as y,commentText as l,argsChoice as d,stringLiteral as p,kotlinLiteral as g,referencedModels as H,allMethods as M,toSnakeCase as z,parseSpec as he,assertGeneratable as ge,withDeclaredModels as be,unrepresentableFunctions as ve,undeclaredModels as we}from"./isTypedSchema-9wiKtXr2.mjs";import{isTypedSchema as zr}from"./isTypedSchema-9wiKtXr2.mjs";const je=async(e,r)=>{if(r.quicktype===void 0)return"";const t=ae(e);if(t.length===0)return"";const{InputData:n,JSONSchemaInput:a,JSONSchemaStore:i,quicktype:o}=await import("quicktype-core");class c extends i{fetch(){return Promise.resolve(void 0)}}const $=new a(new c);for(const W of t)await $.addSource({name:W.name,schema:JSON.stringify(W.schema)});const u=new n;u.addInput($);const{lines:f}=await o({inputData:u,lang:r.quicktype.lang,rendererOptions:r.quicktype.rendererOptions??{}});return f.join(`
2
+ `)},V=`${y("go").map(e=>`// ${e}`).join(`
3
3
  `)}
4
4
 
5
- `,y="lunoraapi",j="lunorasdk",ve=`${j}/lunora`,be="1.22",M=e=>s(e),U=(e,r)=>{const t=r.argsType===void 0?"":`args ${r.argsType}, `,n=r.argsType===void 0?"nil":"args",a=r.resultType??"any",i=`lunora.Verb${r.verb.charAt(0).toUpperCase()}${r.verb.slice(1)}`,o=`lunora.Call[${a}](a.client, ${i}, "${d(r.functionPath)}", ${n}, shardKey)`;return[`// ${M(r.functionName)} invokes ${l(r.summary)}.`,`func (a *${e}) ${M(r.functionName)}(${t}shardKey string) (${a}, error) {`,` return ${o}`,"}"].join(`
6
- `)},we=(e,r)=>{const t=r.argsType===void 0?"":`args ${r.argsType}, `,n=r.argsType===void 0?"nil":"args",a=`Subscribe${M(r.functionName)}`;return[`// ${a} opens a live ${l(r.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("${d(r.functionPath)}", ${n}, onData, onError, shardKey)`,"}"].join(`
7
- `)},je=e=>{const r=`${s(e.name)}API`,t=e.methods.map(n=>n.verb==="query"?`${U(r,n)}
5
+ `,h="lunoraapi",k="lunorasdk",ke=`${k}/lunora`,_e="1.22",E=e=>s(e),B=(e,r)=>{const t=d(r,{none:"",typed:c=>`args ${c}, `,untyped:"args any, "}),n=d(r,{none:"nil",typed:()=>"args",untyped:"args"}),a=r.resultType??"any",i=`lunora.Verb${r.verb.charAt(0).toUpperCase()}${r.verb.slice(1)}`,o=`lunora.Call[${a}](a.client, ${i}, "${p(r.functionPath)}", ${n}, shardKey)`;return[`// ${E(r.functionName)} invokes ${l(r.summary)}.`,`func (a *${e}) ${E(r.functionName)}(${t}shardKey string) (${a}, error) {`,` return ${o}`,"}"].join(`
6
+ `)},Se=(e,r)=>{const t=d(r,{none:"",typed:i=>`args ${i}, `,untyped:"args any, "}),n=d(r,{none:"nil",typed:()=>"args",untyped:"args"}),a=`Subscribe${E(r.functionName)}`;return[`// ${a} opens a live ${l(r.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("${p(r.functionPath)}", ${n}, onData, onError, shardKey)`,"}"].join(`
7
+ `)},Ae=e=>{const r=`${s(e.name)}API`,t=e.methods.map(n=>n.verb==="query"?`${B(r,n)}
8
8
 
9
- ${we(r,n)}`:U(r,n)).join(`
9
+ ${Se(r,n)}`:B(r,n)).join(`
10
10
 
11
11
  `);return[`// ${r} groups the functions declared in ${l(e.name)}.`,`type ${r} struct{ client *lunora.Client }`,"",t].join(`
12
- `)},ke=({models:e,namespaces:r})=>{const t=r.map(o=>` ${s(o.name)} *${s(o.name)}API`).join(`
12
+ `)},Te=({models:e,namespaces:r})=>{const t=r.map(o=>` ${s(o.name)} *${s(o.name)}API`).join(`
13
13
  `),n=r.map(o=>` ${s(o.name)}: &${s(o.name)}API{client: client},`).join(`
14
- `),a=[W,`package ${y}
14
+ `),a=[V,`package ${h}
15
15
  `,`
16
- `,`import "${ve}"
16
+ `,`import "${ke}"
17
17
  `,`
18
18
  `,`// API is the typed entry point: api.<Namespace>.<Function>(args, shardKey).
19
19
  `,`type API struct {
@@ -27,45 +27,45 @@ ${we(r,n)}`:U(r,n)).join(`
27
27
  `,` }
28
28
  `,`}
29
29
  `,`
30
- `,r.map(o=>je(o)).join(`
30
+ `,r.map(o=>Ae(o)).join(`
31
31
 
32
32
  `),`
33
- `].join(""),i=e.length>0?`${W}package ${y}
33
+ `].join(""),i=e.length>0?`${V}package ${h}
34
34
 
35
35
  ${e}
36
- `:`${W}package ${y}
36
+ `:`${V}package ${h}
37
37
 
38
38
  // No typed argument or result schemas in this deployment.
39
- `;return{[`${y}/api.go`]:a,[`${y}/models.go`]:i,"go.mod":[`// The generated Lunora Go SDK, with the transport vendored under ./lunora.
39
+ `;return{[`${h}/api.go`]:a,[`${h}/models.go`]:i,"go.mod":[`// The generated Lunora Go SDK, with the transport vendored under ./lunora.
40
40
  `,`//
41
41
  `,`// A consuming module wires it in without a network fetch:
42
42
  `,`//
43
- `,`// require ${j} v0.0.0
44
- `,`// replace ${j} => ./path/to/this/directory
45
- `,`module ${j}
43
+ `,`// require ${k} v0.0.0
44
+ `,`// replace ${k} => ./path/to/this/directory
45
+ `,`module ${k}
46
46
  `,`
47
- `,`go ${be}
48
- `].join("")}},Te={id:"go",quicktype:{lang:"go",rendererOptions:{"just-types":"true",package:y}},render:ke,requires:[],vendor:[{from:"lunora",to:"lunora"}]},g="lunoraapi.models",E="lunoraapi/models",_e=24,Se=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"]),Ae=/[^A-Za-z0-9]+/gu,Oe=/([a-z0-9])([A-Z])/gu,We=/^[A-Za-z]/u,Ve=/^[A-Z]/u;let ae=class extends Error{};const m=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0,Le=e=>{const r=e.anyOf??e.oneOf;if(!Array.isArray(r)||r.length===0)return;const t=r.map(n=>m(n)?.const);if(t.every(n=>typeof n=="string"))return[...new Set(t)].toSorted((n,a)=>n.localeCompare(a))},ie=e=>{const r=e.anyOf??e.oneOf;if(!Array.isArray(r)||r.length!==2)return e;const t=r.filter(n=>m(n)?.type!=="null");return t.length===1?m(t[0])??e:e},Ne=e=>{const r=s(e),t=r.charAt(0).toLowerCase()+r.slice(1),n=We.test(t)?t:`value${r}`;return Se.has(n)?`${n}_`:n},Ce=e=>{const r=e.replaceAll(Oe,"$1_$2").replaceAll(Ae,"_").toUpperCase().split("_").filter(t=>t.length>0).join("_");return Ve.test(r)?r:`VALUE_${r}`},oe=(e,r)=>{if(!r.has(e))return r.add(e),e;let t=2;for(;r.has(`${e}${String(t)}`);)t+=1;return r.add(`${e}${String(t)}`),`${e}${String(t)}`},B=(e,r)=>{if(e.has(r.name))throw new ae(`sdk: two schemas both produce the JVM model "${r.name}"`);e.set(r.name,r)},Me=(e,r,t,n,a)=>{const i=new Set(Array.isArray(r)?r.filter(c=>typeof c=="string"):[]),o=new Set;return Object.entries(e).map(([c,p])=>{const u=m(p)??{},$=!i.has(c);return{name:oe(Ne(c),o),nullable:!$&&ie(u)!==u,optional:$,type:v(u,`${t}${s(c)}`,n+1,a),wireKey:c}})},v=(e,r,t,n)=>{if(t>=_e)return{kind:"unknown"};const a=Le(e);if(a!==void 0){const u=new Set;return B(n,{constants:a.map($=>({name:oe(Ce($),u),wireValue:$})),kind:"enum",name:r}),{kind:"enum",name:r}}const i=ie(e);if(i!==e)return v(i,r,t+1,n);const o=m(e.properties);if(o!==void 0)return B(n,{fields:Me(o,e.required,r,t,n),kind:"class",name:r}),{kind:"class",name:r};const c=m(e.additionalProperties);if(c!==void 0)return{kind:"record",value:v(c,`${r}Value`,t+1,n)};const p=m(e.items);if(p!==void 0)return{item:v(p,`${r}Item`,t+1,n),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 r=new Map;for(const t of ne(e)){if(m(t.schema.properties)===void 0)continue;const n=new Map;try{v(t.schema,t.name,0,n)}catch(a){if(a instanceof ae)continue;throw a}if(![...n.keys()].some(a=>r.has(a)))for(const[a,i]of n)r.set(a,i)}return[...r.values()].toSorted((t,n)=>t.name.localeCompare(n.name))},A=e=>[`// GENERATED by \`lunora sdk generate --lang ${e}\` — do not edit.`,"// Run the command again to regenerate."],T=e=>{switch(e.kind){case"boolean":return"Boolean";case"class":case"enum":return e.name;case"list":return`java.util.List<${T(e.item)}>`;case"number":return"Double";case"record":return`java.util.Map<String, ${T(e.value)}>`;case"string":return"String";default:return"Object"}},P=e=>{switch(e.kind){case"class":case"enum":return!0;case"list":return P(e.item);case"record":return P(e.value);default:return!1}},K=(e,r,t)=>{if(!P(e))return r;const n=`item${String(t)}`;switch(e.kind){case"class":return`${r} == null ? null : ${r}.toWire()`;case"enum":return`${r} == null ? null : ${r}.toValue()`;case"list":return`ModelWire.writeList(${r}, ${n} -> ${K(e.item,n,t+1)})`;case"record":return`ModelWire.writeRecord(${r}, ${n} -> ${K(e.value,n,t+1)})`;default:return r}},x=(e,r,t)=>{const n=`item${String(t)}`;switch(e.kind){case"boolean":return`ModelWire.flag(${r})`;case"class":return`ModelWire.readObject(${r}, ${e.name}::fromWire)`;case"enum":return`ModelWire.readEnum(${r}, ${e.name}::forValue)`;case"list":return`ModelWire.readList(${r}, ${n} -> ${x(e.item,n,t+1)})`;case"number":return`ModelWire.number(${r})`;case"record":return`ModelWire.readRecord(${r}, ${n} -> ${x(e.value,n,t+1)})`;case"string":return`ModelWire.text(${r})`;default:return r}},Ee=e=>{const r=l(e.wireKey);return e.optional?[" /**",` * Wire key {@code ${r}} — OPTIONAL: null omits the key entirely, because`," * `v.optional` accepts the value or `undefined` and rejects an explicit null."," */"]:[` /** Wire key {@code ${r}}.${e.nullable?" Nullable: null is sent as an explicit null.":""} */`]},Pe=100,Ke=e=>{const r=e.fields.map(n=>`${T(n.type)} ${n.name}`),t=` public ${e.name}(${r.join(", ")}) {`;return t.length<=Pe?[t]:[` public ${e.name}(`,...r.map((n,a)=>` ${n}${a===r.length-1?") {":","}`)]},xe=e=>{const r=e.fields.flatMap(n=>{const a=`wire.put("${d(n.wireKey)}", ${K(n.type,`this.${n.name}`,0)});`;return n.optional?[` if (this.${n.name} != null) {`,` ${a}`," }"]:[` ${a}`]}),t=e.fields.map(n=>` ${x(n.type,`wire.get("${d(n.wireKey)}")`,0)}`);return[...A("java"),"",`package ${g};`,"","/**",` * 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(n=>[...Ee(n),` public final ${T(n.type)} ${n.name};`,""]),...Ke(e),...e.fields.map(n=>` this.${n.name} = ${n.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<>();",...r,""," 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(`,
47
+ `,`go ${_e}
48
+ `].join("")}},Oe={id:"go",quicktype:{lang:"go",rendererOptions:{"just-types":"true",package:h}},render:Te,requires:[],vendor:[{from:"lunora",to:"lunora"}]},b="lunoraapi.models",P="lunoraapi/models",We=24,Ve=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"]),Le=/[^A-Za-z0-9]+/gu,Ne=/([a-z0-9])([A-Z])/gu,Ce=/^[A-Za-z]/u,Me=/^[A-Z]/u;let ie=class extends Error{};const m=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0,Ee=e=>{const r=e.anyOf??e.oneOf;if(!Array.isArray(r)||r.length===0)return;const t=r.map(n=>m(n)?.const);if(t.every(n=>typeof n=="string"))return[...new Set(t)].toSorted((n,a)=>n.localeCompare(a))},oe=e=>{const r=e.anyOf??e.oneOf;if(!Array.isArray(r)||r.length!==2)return e;const t=r.filter(n=>m(n)?.type!=="null");return t.length===1?m(t[0])??e:e},Pe=e=>{const r=s(e),t=r.charAt(0).toLowerCase()+r.slice(1),n=Ce.test(t)?t:`value${r}`;return Ve.has(n)?`${n}_`:n},Ke=e=>{const r=e.replaceAll(Ne,"$1_$2").replaceAll(Le,"_").toUpperCase().split("_").filter(t=>t.length>0).join("_");return Me.test(r)?r:`VALUE_${r}`},se=(e,r)=>{if(!r.has(e))return r.add(e),e;let t=2;for(;r.has(`${e}${String(t)}`);)t+=1;return r.add(`${e}${String(t)}`),`${e}${String(t)}`},J=(e,r)=>{if(e.has(r.name))throw new ie(`sdk: two schemas both produce the JVM model "${r.name}"`);e.set(r.name,r)},xe=(e,r,t,n,a)=>{const i=new Set(Array.isArray(r)?r.filter(c=>typeof c=="string"):[]),o=new Set;return Object.entries(e).map(([c,$])=>{const u=m($)??{},f=!i.has(c);return{name:se(Pe(c),o),nullable:!f&&oe(u)!==u,optional:f,type:v(u,`${t}${s(c)}`,n+1,a),wireKey:c}})},v=(e,r,t,n)=>{if(t>=We)return{kind:"unknown"};const a=Ee(e);if(a!==void 0){const u=new Set;return J(n,{constants:a.map(f=>({name:se(Ke(f),u),wireValue:f})),kind:"enum",name:r}),{kind:"enum",name:r}}const i=oe(e);if(i!==e)return v(i,r,t+1,n);const o=m(e.properties);if(o!==void 0)return J(n,{fields:xe(o,e.required,r,t,n),kind:"class",name:r}),{kind:"class",name:r};const c=m(e.additionalProperties);if(c!==void 0)return{kind:"record",value:v(c,`${r}Value`,t+1,n)};const $=m(e.items);if($!==void 0)return{item:v($,`${r}Item`,t+1,n),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"}}},le=e=>{const r=new Map;for(const t of ae(e)){if(m(t.schema.properties)===void 0)continue;const n=new Map;try{v(t.schema,t.name,0,n)}catch(a){if(a instanceof ie)continue;throw a}if(![...n.keys()].some(a=>r.has(a)))for(const[a,i]of n)r.set(a,i)}return[...r.values()].toSorted((t,n)=>t.name.localeCompare(n.name))},O=e=>[`// GENERATED by \`lunora sdk generate --lang ${e}\` — do not edit.`,"// Run the command again to regenerate."],S=e=>{switch(e.kind){case"boolean":return"Boolean";case"class":case"enum":return e.name;case"list":return`java.util.List<${S(e.item)}>`;case"number":return"Double";case"record":return`java.util.Map<String, ${S(e.value)}>`;case"string":return"String";default:return"Object"}},K=e=>{switch(e.kind){case"class":case"enum":return!0;case"list":return K(e.item);case"record":return K(e.value);default:return!1}},x=(e,r,t)=>{if(!K(e))return r;const n=`item${String(t)}`;switch(e.kind){case"class":return`${r} == null ? null : ${r}.toWire()`;case"enum":return`${r} == null ? null : ${r}.toValue()`;case"list":return`ModelWire.writeList(${r}, ${n} -> ${x(e.item,n,t+1)})`;case"record":return`ModelWire.writeRecord(${r}, ${n} -> ${x(e.value,n,t+1)})`;default:return r}},q=(e,r,t)=>{const n=`item${String(t)}`;switch(e.kind){case"boolean":return`ModelWire.flag(${r})`;case"class":return`ModelWire.readObject(${r}, ${e.name}::fromWire)`;case"enum":return`ModelWire.readEnum(${r}, ${e.name}::forValue)`;case"list":return`ModelWire.readList(${r}, ${n} -> ${q(e.item,n,t+1)})`;case"number":return`ModelWire.number(${r})`;case"record":return`ModelWire.readRecord(${r}, ${n} -> ${q(e.value,n,t+1)})`;case"string":return`ModelWire.text(${r})`;default:return r}},qe=e=>{const r=l(e.wireKey);return e.optional?[" /**",` * Wire key {@code ${r}} — OPTIONAL: null omits the key entirely, because`," * `v.optional` accepts the value or `undefined` and rejects an explicit null."," */"]:[` /** Wire key {@code ${r}}.${e.nullable?" Nullable: null is sent as an explicit null.":""} */`]},Ie=100,De=e=>{const r=e.fields.map(n=>`${S(n.type)} ${n.name}`),t=` public ${e.name}(${r.join(", ")}) {`;return t.length<=Ie?[t]:[` public ${e.name}(`,...r.map((n,a)=>` ${n}${a===r.length-1?") {":","}`)]},Fe=e=>{const r=e.fields.flatMap(n=>{const a=`wire.put("${p(n.wireKey)}", ${x(n.type,`this.${n.name}`,0)});`;return n.optional?[` if (this.${n.name} != null) {`,` ${a}`," }"]:[` ${a}`]}),t=e.fields.map(n=>` ${q(n.type,`wire.get("${p(n.wireKey)}")`,0)}`);return[...O("java"),"",`package ${b};`,"","/**",` * 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(n=>[...qe(n),` public final ${S(n.type)} ${n.name};`,""]),...De(e),...e.fields.map(n=>` this.${n.name} = ${n.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<>();",...r,""," 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(`,
49
49
  `)});`]," }","}",""].join(`
50
- `)},qe=e=>[...A("java"),"",`package ${g};`,"",`/** The \`${e.name}\` union. Each constant keeps the wire string it encodes to. */`,`public enum ${e.name} {`,...e.constants.map((r,t)=>` ${r.name}("${d(r.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(`
51
- `),Ie=[{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"}],De=e=>{const r=Ie.filter(t=>e.includes(`ModelWire.${t.name}(`));return[...A("java"),"",`package ${g};`,"","/** Wire readers and writers shared by the generated models. */","final class ModelWire {"," private ModelWire() {}",...r.flatMap(t=>["",...t.lines]),"}",""].join(`
52
- `)},Fe=e=>{const r=se(e);if(r.length===0)return{};const t={};for(const n of r)t[`${E}/${n.name}.java`]=n.kind==="enum"?qe(n):xe(n);return{[`${E}/ModelWire.java`]:De(Object.values(t).join(`
53
- `)),...t}},q=e=>{switch(e.kind){case"boolean":return"Boolean";case"class":case"enum":return e.name;case"list":return`List<${q(e.item)}>`;case"number":return"Double";case"record":return`Map<String, ${q(e.value)}>`;case"string":return"String";default:return"WireValue"}},b=(e,r,t)=>{const n=`item${String(t)}`,a=`entry${String(t)}`;switch(e.kind){case"boolean":return`WireValue.Bool(${r})`;case"class":return`${r}.toWire()`;case"enum":return`WireValue.Text(${r}.wireValue)`;case"list":return`WireValue.Arr(${r}.map { ${n} -> ${b(e.item,n,t+1)} })`;case"number":return`WireValue.Num(${r})`;case"record":return`WireValue.Obj(${r}.map { ${a} -> ${a}.key to ${b(e.value,`${a}.value`,t+1)} })`;case"string":return`WireValue.Text(${r})`;default:return r}},I=(e,r,t,n)=>`wireNeed(${le(e,r,t,n)}, "${h(n)}")`,le=(e,r,t,n)=>{const a=`item${String(t)}`,i=`entry${String(t)}`;switch(e.kind){case"boolean":return`wireBool(${r})`;case"class":return`wireObj(${r})?.let { ${a} -> ${e.name}.fromWire(${a}) }`;case"enum":return`wireText(${r})?.let { ${a} -> ${e.name}.forValue(${a}) }`;case"list":return`wireArr(${r})?.items?.map { ${a} -> ${I(e.item,a,t+1,`${n}[]`)} }`;case"number":return`wireNum(${r})`;case"record":return`wireObj(${r})?.fields?.associate { ${i} -> ${i}.first to ${I(e.value,`${i}.second`,t+1,`${n}{}`)} }`;case"string":return`wireText(${r})`;default:return r}},Re=e=>{const r=e.fields.map(a=>{const i=l(a.wireKey);return[...a.optional?[" /**",` * Wire key \`${i}\` — OPTIONAL: null omits the key entirely, because`," * `v.optional` accepts the value or `undefined` and rejects an explicit null."," */"]:[` /** Wire key \`${i}\`.${a.nullable?" Nullable: null is sent as an explicit null.":""} */`],` val ${a.name}: ${q(a.type)}${a.optional||a.nullable?"?":""}${a.optional?" = null":""},`]}),t=e.fields.map(a=>{const i=h(a.wireKey);return a.optional?` ${a.name}?.let { add("${i}" to ${b(a.type,"it",0)}) }`:a.nullable?` add("${i}" to (${a.name}?.let { ${b(a.type,"it",0)} } ?: WireValue.Null))`:` add("${i}" to ${b(a.type,a.name,0)})`}),n=e.fields.map(a=>{const i=`wireField(value, "${h(a.wireKey)}")`,o=a.optional||a.nullable?le(a.type,i,0,a.wireKey):I(a.type,i,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}(`,...r.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}(`,...n," )"," }","}"]},He=e=>[`/** The \`${e.name}\` union. Each entry keeps the wire string it encodes to. */`,`enum class ${e.name}(val wireValue: String) {`,...e.constants.map(r=>` ${r.name}("${h(r.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)`," }","}"],ze=[{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"}],Ue=e=>{const r=se(e);if(r.length===0)return{};const t=r.flatMap(o=>[...o.kind==="enum"?He(o):Re(o),""]),n=ze.filter(o=>t.some(c=>c.includes(`${o.name}(`))),a=n.flatMap((o,c)=>c===0?[...o.lines]:["",...o.lines]),i=[...A("kotlin"),"",`package ${g}`,"",...n.some(o=>o.name==="wireNeed")?["import dev.lunora.WireFormatException"]:[],"import dev.lunora.WireValue","",...t,...a,""].join(`
54
- `);return{[`${E}/Models.kt`]:i}},Be=`${f("java").map(e=>`// ${e}`).join(`
50
+ `)},Re=e=>[...O("java"),"",`package ${b};`,"",`/** The \`${e.name}\` union. Each constant keeps the wire string it encodes to. */`,`public enum ${e.name} {`,...e.constants.map((r,t)=>` ${r.name}("${p(r.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(`
51
+ `),He=[{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"}],ze=e=>{const r=He.filter(t=>e.includes(`ModelWire.${t.name}(`));return[...O("java"),"",`package ${b};`,"","/** Wire readers and writers shared by the generated models. */","final class ModelWire {"," private ModelWire() {}",...r.flatMap(t=>["",...t.lines]),"}",""].join(`
52
+ `)},Ue=e=>{const r=le(e);if(r.length===0)return{};const t={};for(const n of r)t[`${P}/${n.name}.java`]=n.kind==="enum"?Re(n):Fe(n);return{[`${P}/ModelWire.java`]:ze(Object.values(t).join(`
53
+ `)),...t}},I=e=>{switch(e.kind){case"boolean":return"Boolean";case"class":case"enum":return e.name;case"list":return`List<${I(e.item)}>`;case"number":return"Double";case"record":return`Map<String, ${I(e.value)}>`;case"string":return"String";default:return"WireValue"}},w=(e,r,t)=>{const n=`item${String(t)}`,a=`entry${String(t)}`;switch(e.kind){case"boolean":return`WireValue.Bool(${r})`;case"class":return`${r}.toWire()`;case"enum":return`WireValue.Text(${r}.wireValue)`;case"list":return`WireValue.Arr(${r}.map { ${n} -> ${w(e.item,n,t+1)} })`;case"number":return`WireValue.Num(${r})`;case"record":return`WireValue.Obj(${r}.map { ${a} -> ${a}.key to ${w(e.value,`${a}.value`,t+1)} })`;case"string":return`WireValue.Text(${r})`;default:return r}},D=(e,r,t,n)=>`wireNeed(${ue(e,r,t,n)}, "${g(n)}")`,ue=(e,r,t,n)=>{const a=`item${String(t)}`,i=`entry${String(t)}`;switch(e.kind){case"boolean":return`wireBool(${r})`;case"class":return`wireObj(${r})?.let { ${a} -> ${e.name}.fromWire(${a}) }`;case"enum":return`wireText(${r})?.let { ${a} -> ${e.name}.forValue(${a}) }`;case"list":return`wireArr(${r})?.items?.map { ${a} -> ${D(e.item,a,t+1,`${n}[]`)} }`;case"number":return`wireNum(${r})`;case"record":return`wireObj(${r})?.fields?.associate { ${i} -> ${i}.first to ${D(e.value,`${i}.second`,t+1,`${n}{}`)} }`;case"string":return`wireText(${r})`;default:return r}},Be=e=>{const r=e.fields.map(a=>{const i=l(a.wireKey);return[...a.optional?[" /**",` * Wire key \`${i}\` — OPTIONAL: null omits the key entirely, because`," * `v.optional` accepts the value or `undefined` and rejects an explicit null."," */"]:[` /** Wire key \`${i}\`.${a.nullable?" Nullable: null is sent as an explicit null.":""} */`],` val ${a.name}: ${I(a.type)}${a.optional||a.nullable?"?":""}${a.optional?" = null":""},`]}),t=e.fields.map(a=>{const i=g(a.wireKey);return a.optional?` ${a.name}?.let { add("${i}" to ${w(a.type,"it",0)}) }`:a.nullable?` add("${i}" to (${a.name}?.let { ${w(a.type,"it",0)} } ?: WireValue.Null))`:` add("${i}" to ${w(a.type,a.name,0)})`}),n=e.fields.map(a=>{const i=`wireField(value, "${g(a.wireKey)}")`,o=a.optional||a.nullable?ue(a.type,i,0,a.wireKey):D(a.type,i,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}(`,...r.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}(`,...n," )"," }","}"]},Je=e=>[`/** The \`${e.name}\` union. Each entry keeps the wire string it encodes to. */`,`enum class ${e.name}(val wireValue: String) {`,...e.constants.map(r=>` ${r.name}("${g(r.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)`," }","}"],Ge=[{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"}],Ze=e=>{const r=le(e);if(r.length===0)return{};const t=r.flatMap(o=>[...o.kind==="enum"?Je(o):Be(o),""]),n=Ge.filter(o=>t.some(c=>c.includes(`${o.name}(`))),a=n.flatMap((o,c)=>c===0?[...o.lines]:["",...o.lines]),i=[...O("kotlin"),"",`package ${b}`,"",...n.some(o=>o.name==="wireNeed")?["import dev.lunora.WireFormatException"]:[],"import dev.lunora.WireValue","",...t,...a,""].join(`
54
+ `);return{[`${P}/Models.kt`]:i}},Ye=`${y("java").map(e=>`// ${e}`).join(`
55
55
  `)}
56
56
 
57
- `,J="lunoraapi",Je=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"]),D=e=>{const r=s(e),t=r.charAt(0).toLowerCase()+r.slice(1);return Je.has(t)?`${t}_`:t},Ge=e=>`Client.Verb.${e.toUpperCase()}`,ue=e=>e.argsType===void 0?{payload:"args",type:"java.util.Map<String, Object>"}:{payload:"args == null ? null : args.toWire()",type:e.argsType},G=e=>{const r=ue(e),t=`client.call(
58
- ${Ge(e.verb)}, "${d(e.functionPath)}", ${r.payload}, shardKey)`;return[` /** ${l(e.summary)} */`,` public ${e.resultType??"Object"} ${D(e.functionName)}(${r.type} args, String shardKey) {`,` return ${e.resultType===void 0?t:`${e.resultType}.fromWire(${t})`};`," }"].join(`
59
- `)},Ze=e=>{const r=ue(e);return[` /** live ${l(e.summary)} — re-runs on every write to the tables it reads. */`,` public Runnable subscribe${s(e.functionName)}(`,` ${r.type} args,`," java.util.function.Consumer<Object> onData,"," java.util.function.Consumer<Client.SubscriptionError> onError,"," String shardKey) {"," return client.subscribe(",` "${d(e.functionPath)}", ${r.payload}, onData, onError, shardKey);`," }"].join(`
60
- `)},Ye=e=>{const r=`${s(e.name)}Api`,t=e.methods.map(n=>n.verb==="query"?`${G(n)}
57
+ `,G="lunoraapi",Qe=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"]),F=e=>{const r=s(e),t=r.charAt(0).toLowerCase()+r.slice(1);return Qe.has(t)?`${t}_`:t},Xe=e=>`Client.Verb.${e.toUpperCase()}`,ce=e=>e.argsType===void 0?{payload:"args",type:"java.util.Map<String, Object>"}:{payload:"args == null ? null : args.toWire()",type:e.argsType},Z=e=>{const r=ce(e),t=`client.call(
58
+ ${Xe(e.verb)}, "${p(e.functionPath)}", ${r.payload}, shardKey)`;return[` /** ${l(e.summary)} */`,` public ${e.resultType??"Object"} ${F(e.functionName)}(${r.type} args, String shardKey) {`,` return ${e.resultType===void 0?t:`${e.resultType}.fromWire(${t})`};`," }"].join(`
59
+ `)},er=e=>{const r=ce(e);return[` /** live ${l(e.summary)} — re-runs on every write to the tables it reads. */`,` public Runnable subscribe${s(e.functionName)}(`,` ${r.type} args,`," java.util.function.Consumer<Object> onData,"," java.util.function.Consumer<Client.SubscriptionError> onError,"," String shardKey) {"," return client.subscribe(",` "${p(e.functionPath)}", ${r.payload}, onData, onError, shardKey);`," }"].join(`
60
+ `)},rr=e=>{const r=`${s(e.name)}Api`,t=e.methods.map(n=>n.verb==="query"?`${Z(n)}
61
61
 
62
- ${Ze(n)}`:G(n)).join(`
62
+ ${er(n)}`:Z(n)).join(`
63
63
 
64
64
  `);return[` /** Functions declared in \`${l(e.name)}\`. */`,` public static final class ${r} {`," private final Client client;","",` ${r}(Client client) {`," this.client = client;"," }","",t.replaceAll(/^ {4}/gmu," ")," }"].join(`
65
- `)},Qe=({namespaces:e})=>{const r=e.map(i=>` public final ${s(i.name)}Api ${D(i.name)};`).join(`
66
- `),t=e.map(i=>` this.${D(i.name)} = new ${s(i.name)}Api(client);`).join(`
67
- `),n=R(e).map(i=>`import ${g}.${i};
68
- `),a=[Be,`package ${J};
65
+ `)},tr=({namespaces:e})=>{const r=e.map(i=>` public final ${s(i.name)}Api ${F(i.name)};`).join(`
66
+ `),t=e.map(i=>` this.${F(i.name)} = new ${s(i.name)}Api(client);`).join(`
67
+ `),n=H(e).map(i=>`import ${b}.${i};
68
+ `),a=[Ye,`package ${G};
69
69
  `,`
70
70
  `,`import dev.lunora.Client;
71
71
  `,...n,`
@@ -77,30 +77,30 @@ ${Ze(n)}`:G(n)).join(`
77
77
  `:` // No functions in this deployment.
78
78
  `,` }
79
79
  `,`
80
- `,e.map(i=>Ye(i)).join(`
80
+ `,e.map(i=>rr(i)).join(`
81
81
 
82
82
  `),`
83
83
  }
84
- `].join("");return{[`${J}/Api.java`]:a}},Xe={id:"java",render:Qe,renderModels:Fe,requires:[],vendor:[{from:"src/dev/lunora",to:"dev/lunora"}]},er=`${f("kotlin").map(e=>`// ${e}`).join(`
84
+ `].join("");return{[`${G}/Api.java`]:a}},nr={id:"java",render:tr,renderModels:Ue,requires:[],vendor:[{from:"src/dev/lunora",to:"dev/lunora"}]},ar=`${y("kotlin").map(e=>`// ${e}`).join(`
85
85
  `)}
86
86
 
87
- `,Z="lunoraapi",rr=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"]),ce=e=>{const r=s(e),t=r.charAt(0).toLowerCase()+r.slice(1);return rr.has(t)?`\`${t}\``:t},tr=e=>`Verb.${e.toUpperCase()}`,de=e=>e.argsType===void 0?{declaration:"args: WireValue? = null",payload:"args"}:{declaration:`args: ${e.argsType}`,payload:"args.toWire()"},Y=e=>{const r=de(e),t=`client.call(${tr(e.verb)}, "${h(e.functionPath)}", ${r.payload}, shardKey)`;return[` /** ${l(e.summary)} */`,` fun ${ce(e.functionName)}(${r.declaration}, shardKey: String? = null): ${e.resultType??"WireValue"} =`,` ${e.resultType===void 0?t:`${e.resultType}.fromWire(${t})`}`].join(`
88
- `)},nr=e=>{const r=de(e);return[` /** live ${l(e.summary)} — re-runs on every write to the tables it reads. */`,` fun subscribe${s(e.functionName)}(`,` ${r.declaration},`," onData: ((WireValue) -> Unit)?,"," onError: ((SubscriptionError) -> Unit)? = null,"," shardKey: String? = null,"," ): () -> Unit =",` client.subscribe("${h(e.functionPath)}", ${r.payload}, onData, onError, shardKey)`].join(`
89
- `)},ar=e=>{const r=`${s(e.name)}Api`,t=e.methods.map(n=>n.verb==="query"?`${Y(n)}
87
+ `,Y="lunoraapi",ir=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"]),de=e=>{const r=s(e),t=r.charAt(0).toLowerCase()+r.slice(1);return ir.has(t)?`\`${t}\``:t},or=e=>`Verb.${e.toUpperCase()}`,pe=e=>e.argsType===void 0?{declaration:"args: WireValue? = null",payload:"args"}:{declaration:`args: ${e.argsType}`,payload:"args.toWire()"},Q=e=>{const r=pe(e),t=`client.call(${or(e.verb)}, "${g(e.functionPath)}", ${r.payload}, shardKey)`;return[` /** ${l(e.summary)} */`,` fun ${de(e.functionName)}(${r.declaration}, shardKey: String? = null): ${e.resultType??"WireValue"} =`,` ${e.resultType===void 0?t:`${e.resultType}.fromWire(${t})`}`].join(`
88
+ `)},sr=e=>{const r=pe(e);return[` /** live ${l(e.summary)} — re-runs on every write to the tables it reads. */`,` fun subscribe${s(e.functionName)}(`,` ${r.declaration},`," onData: ((WireValue) -> Unit)?,"," onError: ((SubscriptionError) -> Unit)? = null,"," shardKey: String? = null,"," ): () -> Unit =",` client.subscribe("${g(e.functionPath)}", ${r.payload}, onData, onError, shardKey)`].join(`
89
+ `)},lr=e=>{const r=`${s(e.name)}Api`,t=e.methods.map(n=>n.verb==="query"?`${Q(n)}
90
90
 
91
- ${nr(n)}`:Y(n)).join(`
91
+ ${sr(n)}`:Q(n)).join(`
92
92
 
93
93
  `);return[`/** Functions declared in \`${l(e.name)}\`. */`,`class ${r}(private val client: Client) {`,t,"}"].join(`
94
- `)},ir=({namespaces:e})=>{const r=e.map(i=>` val ${ce(i.name)}: ${s(i.name)}Api = ${s(i.name)}Api(client)`).join(`
94
+ `)},ur=({namespaces:e})=>{const r=e.map(i=>` val ${de(i.name)}: ${s(i.name)}Api = ${s(i.name)}Api(client)`).join(`
95
95
  `),t=e.flatMap(i=>i.methods),n=[`import dev.lunora.Client
96
96
  `,...t.some(i=>i.verb==="query")?[`import dev.lunora.SubscriptionError
97
97
  `]:[],`import dev.lunora.Verb
98
98
  `,...t.some(i=>i.argsType===void 0||i.resultType===void 0)?[`import dev.lunora.WireValue
99
- `]:[],...R(e).map(i=>`import ${g}.${i}
100
- `)],a=[er,`package ${Z}
99
+ `]:[],...H(e).map(i=>`import ${b}.${i}
100
+ `)],a=[ar,`package ${Y}
101
101
  `,`
102
102
  `,...n,`
103
- `,e.map(i=>ar(i)).join(`
103
+ `,e.map(i=>lr(i)).join(`
104
104
 
105
105
  `),`
106
106
 
@@ -108,26 +108,26 @@ ${nr(n)}`:Y(n)).join(`
108
108
  `,r.length>0?`${r}
109
109
  `:` init { require(true) { client } }
110
110
  `,`}
111
- `].join("");return{[`${Z}/Api.kt`]:a}},or={id:"kotlin",render:ir,renderModels:Ue,requires:[],vendor:[{from:"src",to:"dev/lunora"}]},sr=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"]),w=`"""${f("python").join(`
111
+ `].join("");return{[`${Y}/Api.kt`]:a}},cr={id:"kotlin",render:ur,renderModels:Ze,requires:[],vendor:[{from:"src",to:"dev/lunora"}]},dr=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"]),j=`"""${y("python").join(`
112
112
 
113
113
  `)}
114
114
  """
115
115
 
116
- `,V="lunora_api",z=e=>{const r=H(e);return sr.has(r)?`${r}_`:r},Q=e=>{const r=e.resultType??"Any",t=e.argsType===void 0?"self":`self, args: ${e.argsType}`,n=e.argsType===void 0?"{}":"args.to_dict()",a=`await self._client.${e.verb}("${d(e.functionPath)}", ${n}, shard_key)`;return[` async def ${z(e.functionName)}(${t}, *, shard_key: Optional[str] = None) -> ${r}:`,` """${l(e.summary)}"""`,` ${e.resultType===void 0?`return ${a}`:`return ${e.resultType}.from_dict(${a})`}`].join(`
117
- `)},lr=e=>{const r=e.argsType===void 0?"{}":"args.to_dict()",t=["self",...e.argsType===void 0?[]:[`args: ${e.argsType}`],"on_data: Callback","on_error: Optional[ErrorCallback] = None","*","shard_key: Optional[str] = None"];return[` def subscribe_${z(e.functionName)}(`,...t.map(n=>` ${n},`)," ) -> Unsubscribe:",` """live ${l(e.summary)} — re-runs on every write to the tables it reads."""`,` return self._client.subscribe("${d(e.functionPath)}", ${r}, on_data, on_error, shard_key)`].join(`
118
- `)},ur=e=>{const r=e.methods.map(t=>t.verb==="query"?`${Q(t)}
116
+ `,L="lunora_api",U=e=>{const r=z(e);return dr.has(r)?`${r}_`:r},$e=e=>d(e,{none:"{}",typed:()=>"args.to_dict()",untyped:"args"}),pr=(e,r,t,n)=>d(e,{none:r,typed:t,untyped:n}),X=e=>{const r=e.resultType??"Any",t=pr(e,"self",i=>`self, args: ${i}`,"self, args: Any"),n=$e(e),a=`await self._client.${e.verb}("${p(e.functionPath)}", ${n}, shard_key)`;return[` async def ${U(e.functionName)}(${t}, *, shard_key: Optional[str] = None) -> ${r}:`,` """${l(e.summary)}"""`,` ${e.resultType===void 0?`return ${a}`:`return ${e.resultType}.from_dict(${a})`}`].join(`
117
+ `)},$r=e=>{const r=$e(e),t=["self",...d(e,{none:[],typed:n=>[`args: ${n}`],untyped:["args: Any"]}),"on_data: Callback","on_error: Optional[ErrorCallback] = None","*","shard_key: Optional[str] = None"];return[` def subscribe_${U(e.functionName)}(`,...t.map(n=>` ${n},`)," ) -> Unsubscribe:",` """live ${l(e.summary)} — re-runs on every write to the tables it reads."""`,` return self._client.subscribe("${p(e.functionPath)}", ${r}, on_data, on_error, shard_key)`].join(`
118
+ `)},mr=e=>{const r=e.methods.map(t=>t.verb==="query"?`${X(t)}
119
119
 
120
- ${lr(t)}`:Q(t)).join(`
120
+ ${$r(t)}`:X(t)).join(`
121
121
 
122
122
  `);return[`class ${s(e.name)}Api:`,` """Functions declared in \`${l(e.name)}\`."""`,""," def __init__(self, client: LunoraClient) -> None:"," self._client = client","",r].join(`
123
- `)},cr=e=>e.replaceAll(/^([ \t]*)except:$/gmu,"$1except Exception:"),dr=({models:e,namespaces:r})=>{const t=R(r),n=t.length>0?`from .models import ${t.join(", ")}
124
- `:"",a=C(r).some(u=>u.verb==="query")?"Callback, ErrorCallback, LunoraClient, Unsubscribe":"LunoraClient",i=C(r).some(u=>u.resultType===void 0),o=r.map(u=>` self.${z(u.name)} = ${s(u.name)}Api(client)`).join(`
125
- `),c=[w,`from typing import ${i?"Any, Optional":"Optional"}
123
+ `)},fr=e=>e.replaceAll(/^([ \t]*)except:$/gmu,"$1except Exception:"),yr=({models:e,namespaces:r})=>{const t=H(r),n=t.length>0?`from .models import ${t.join(", ")}
124
+ `:"",a=M(r).some(u=>u.verb==="query")?"Callback, ErrorCallback, LunoraClient, Unsubscribe":"LunoraClient",i=M(r).some(u=>u.resultType===void 0),o=r.map(u=>` self.${U(u.name)} = ${s(u.name)}Api(client)`).join(`
125
+ `),c=[j,`from typing import ${i?"Any, Optional":"Optional"}
126
126
  `,`
127
127
  `,`from lunora.client import ${a}
128
128
  `,n,`
129
129
 
130
- `,r.map(u=>ur(u)).join(`
130
+ `,r.map(u=>mr(u)).join(`
131
131
 
132
132
 
133
133
  `),`
@@ -138,15 +138,15 @@ ${lr(t)}`:Q(t)).join(`
138
138
  `,` def __init__(self, client: LunoraClient) -> None:
139
139
  `,o.length>0?`${o}
140
140
  `:` pass
141
- `].join(""),p=["Api",...r.map(u=>`${s(u.name)}Api`)];return{[`${V}/__init__.py`]:[w,`from .api import ${p.join(", ")}
141
+ `].join(""),$=["Api",...r.map(u=>`${s(u.name)}Api`)];return{[`${L}/__init__.py`]:[j,`from .api import ${$.join(", ")}
142
142
  `,`
143
- `,`__all__ = [${p.map(u=>`"${u}"`).join(", ")}]
144
- `].join(""),[`${V}/api.py`]:c,[`${V}/models.py`]:e.length>0?`${w}${cr(e)}
145
- `:`${w}# No typed argument or result schemas in this deployment.
146
- `}},pr={id:"python",quicktype:{lang:"python",rendererOptions:{"python-version":"3.7"}},render:dr,requires:[],vendor:[{from:"lunora",to:"lunora"}]},L=`${f("ruby").map(e=>`# ${e}`).join(`
143
+ `,`__all__ = [${$.map(u=>`"${u}"`).join(", ")}]
144
+ `].join(""),[`${L}/api.py`]:c,[`${L}/models.py`]:e.length>0?`${j}${fr(e)}
145
+ `:`${j}# No typed argument or result schemas in this deployment.
146
+ `}},hr={id:"python",quicktype:{lang:"python",rendererOptions:{"python-version":"3.7"}},render:yr,requires:[],vendor:[{from:"lunora",to:"lunora"}]},N=`${y("ruby").map(e=>`# ${e}`).join(`
147
147
  `)}
148
148
 
149
- `,mr=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"]),pe=e=>d(e).replaceAll("#","\\#"),_=e=>{const r=H(e);return mr.has(r)?`${r}_`:r},$r=` def self.wire_args(model)
149
+ `,gr=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"]),me=e=>p(e).replaceAll("#","\\#"),A=e=>{const r=z(e);return gr.has(r)?`${r}_`:r},br=` def self.wire_args(model)
150
150
  drop_nils(model.to_dynamic)
151
151
  end
152
152
 
@@ -158,20 +158,20 @@ ${lr(t)}`:Q(t)).join(`
158
158
  end
159
159
  end
160
160
 
161
- `,X=e=>{const r=e.argsType===void 0?"shard_key: nil":"args, shard_key: nil",t=e.argsType===void 0?"{}":"LunoraApi.wire_args(args)",n=`@client.${e.verb}("${pe(e.functionPath)}", ${t}, shard_key)`,a=e.resultType===void 0?n:`${e.resultType}.from_dynamic!(${n})`;return[` # ${l(e.summary)}`,` def ${_(e.functionName)}(${r})`,` ${a}`," end"].join(`
162
- `)},fr=e=>{const r=e.argsType===void 0?"on_data, on_error = nil, shard_key: nil":"args, on_data, on_error = nil, shard_key: nil",t=e.argsType===void 0?"{}":"LunoraApi.wire_args(args)";return[` # live ${l(e.summary)} — re-runs on every write to the tables it reads.`,` def subscribe_${_(e.functionName)}(${r})`,` @client.subscribe("${pe(e.functionPath)}", ${t}, on_data, on_error, shard_key)`," end"].join(`
163
- `)},yr=e=>{const r=e.methods.map(t=>t.verb==="query"?`${X(t)}
161
+ `,fe=e=>d(e,{none:"{}",typed:()=>"LunoraApi.wire_args(args)",untyped:"args"}),ee=e=>{const r=e.argsType===void 0&&!e.takesArgs?"shard_key: nil":"args, shard_key: nil",t=fe(e),n=`@client.${e.verb}("${me(e.functionPath)}", ${t}, shard_key)`,a=e.resultType===void 0?n:`${e.resultType}.from_dynamic!(${n})`;return[` # ${l(e.summary)}`,` def ${A(e.functionName)}(${r})`,` ${a}`," end"].join(`
162
+ `)},vr=e=>{const r=e.argsType===void 0&&!e.takesArgs?"on_data, on_error = nil, shard_key: nil":"args, on_data, on_error = nil, shard_key: nil",t=fe(e);return[` # live ${l(e.summary)} — re-runs on every write to the tables it reads.`,` def subscribe_${A(e.functionName)}(${r})`,` @client.subscribe("${me(e.functionPath)}", ${t}, on_data, on_error, shard_key)`," end"].join(`
163
+ `)},wr=e=>{const r=e.methods.map(t=>t.verb==="query"?`${ee(t)}
164
164
 
165
- ${fr(t)}`:X(t)).join(`
165
+ ${vr(t)}`:ee(t)).join(`
166
166
 
167
167
  `);return[` # Functions declared in \`${l(e.name)}\`.`,` class ${s(e.name)}Api`," def initialize(client)"," @client = client"," end","",r," end"].join(`
168
- `)},hr=({models:e,namespaces:r})=>{const t=r.map(a=>`:${_(a.name)}`).join(", "),n=r.map(a=>` @${_(a.name)} = ${s(a.name)}Api.new(client)`).join(`
168
+ `)},jr=({models:e,namespaces:r})=>{const t=r.map(a=>`:${A(a.name)}`).join(", "),n=r.map(a=>` @${A(a.name)} = ${s(a.name)}Api.new(client)`).join(`
169
169
  `);return{"api.rb":[`# frozen_string_literal: true
170
170
 
171
- `,L,`require_relative "models"
171
+ `,N,`require_relative "models"
172
172
  `,`
173
173
  `,`module LunoraApi
174
- `,C(r).some(a=>a.argsType!==void 0)?$r:"",r.map(a=>yr(a)).join(`
174
+ `,M(r).some(a=>a.argsType!==void 0)?br:"",r.map(a=>wr(a)).join(`
175
175
 
176
176
  `),`
177
177
 
@@ -186,16 +186,16 @@ ${fr(t)}`:X(t)).join(`
186
186
  `,`end
187
187
  `].join(""),"models.rb":e.length>0?`# frozen_string_literal: true
188
188
 
189
- ${L}${e}
189
+ ${N}${e}
190
190
  `:`# frozen_string_literal: true
191
191
 
192
- ${L}# No typed argument or result schemas in this deployment.
193
- `}},gr={id:"ruby",quicktype:{lang:"ruby",rendererOptions:{}},render:hr,requires:["dry-struct + dry-types (gems, required by the generated models)"],vendor:[{from:"lib/lunora.rb",to:"lunora.rb"},{from:"lib/lunora",to:"lunora"}]},k=`${f("rust").map(e=>`// ${e}`).join(`
192
+ ${N}# No typed argument or result schemas in this deployment.
193
+ `}},kr={id:"ruby",quicktype:{lang:"ruby",rendererOptions:{}},render:jr,requires:["dry-struct + dry-types (gems, required by the generated models)"],vendor:[{from:"lib/lunora.rb",to:"lunora.rb"},{from:"lib/lunora",to:"lunora"}]},_=`${y("rust").map(e=>`// ${e}`).join(`
194
194
  `)}
195
195
 
196
- `,vr=`${k}pub mod api;
196
+ `,_r=`${_}pub mod api;
197
197
  pub mod models;
198
- `,br=`# The generated Lunora Rust SDK, with the transport vendored under ./lunora.
198
+ `,Sr=`# The generated Lunora Rust SDK, with the transport vendored under ./lunora.
199
199
  #
200
200
  # Add to a consuming crate:
201
201
  #
@@ -215,25 +215,25 @@ publish = false
215
215
  lunora = { path = "lunora" }
216
216
  serde = { version = "1", features = ["derive"] }
217
217
  serde_json = "1"
218
- `,wr=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"]),S=e=>{const r=H(e);return wr.has(r)?`r#${r}`:r},jr=e=>`Verb::${s(e)}`,ee=e=>{const r=e.argsType===void 0?"&self, shard_key: Option<&str>":`&self, args: &${e.argsType}, shard_key: Option<&str>`,t=e.argsType===void 0?"&WireValue::Object(Vec::new())":"&from_model_json(&serde_json::to_value(args).map_err(|error| ClientError::Transport(error.to_string()))?)",n=`self.client.call(${jr(e.verb)}, "${d(e.functionPath)}", ${t}, shard_key)`;return e.resultType===void 0?[` /// ${l(e.summary)}`,` pub fn ${S(e.functionName)}(${r}) -> Result<WireValue, ClientError> {`,` ${n}`," }"].join(`
219
- `):[` /// ${l(e.summary)}`,` pub fn ${S(e.functionName)}(${r}) -> Result<${e.resultType}, ClientError> {`,` let raw = ${n}?;`," let json = encode_wire(&raw).map_err(ClientError::Wire)?;"," serde_json::from_value(json).map_err(|error| ClientError::Transport(error.to_string()))"," }"].join(`
220
- `)},kr=e=>{const r=e.argsType===void 0?"":`args: &${e.argsType}, `,t=e.argsType===void 0?"WireValue::Object(Vec::new())":"from_model_json(&serde_json::to_value(args).map_err(|error| ClientError::Transport(error.to_string()))?)";return[` /// live ${l(e.summary)} — re-runs on every write to the tables it reads.`,` pub fn subscribe_${S(e.functionName)}(`," &mut self,",` ${r}on_data: DataHandler,`," on_error: ErrorHandler,"," shard_key: Option<&str>,"," ) -> Result<String, ClientError> {"," let _ = shard_key;",` Ok(self.client.subscribe("${d(e.functionPath)}", ${t}, on_data, on_error))`," }"].join(`
221
- `)},Tr=e=>{const r=`${s(e.name)}Api`,t=e.methods.map(n=>n.verb==="query"?`${ee(n)}
218
+ `,Ar=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"]),T=e=>{const r=z(e);return Ar.has(r)?`r#${r}`:r},Tr=e=>`Verb::${s(e)}`,re=e=>{const r=d(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=d(e,{none:"&WireValue::Object(Vec::new())",typed:()=>"&from_model_json(&serde_json::to_value(args).map_err(|error| ClientError::Transport(error.to_string()))?)",untyped:"args"}),n=`self.client.call(${Tr(e.verb)}, "${p(e.functionPath)}", ${t}, shard_key)`;return e.resultType===void 0?[` /// ${l(e.summary)}`,` pub fn ${T(e.functionName)}(${r}) -> Result<WireValue, ClientError> {`,` ${n}`," }"].join(`
219
+ `):[` /// ${l(e.summary)}`,` pub fn ${T(e.functionName)}(${r}) -> Result<${e.resultType}, ClientError> {`,` let raw = ${n}?;`," let json = encode_wire(&raw).map_err(ClientError::Wire)?;"," serde_json::from_value(json).map_err(|error| ClientError::Transport(error.to_string()))"," }"].join(`
220
+ `)},Or=e=>{const r=d(e,{none:"",typed:n=>`args: &${n}, `,untyped:"args: &WireValue, "}),t=d(e,{none:"WireValue::Object(Vec::new())",typed:()=>"from_model_json(&serde_json::to_value(args).map_err(|error| ClientError::Transport(error.to_string()))?)",untyped:"args.clone()"});return[` /// live ${l(e.summary)} — re-runs on every write to the tables it reads.`,` pub fn subscribe_${T(e.functionName)}(`," &mut self,",` ${r}on_data: DataHandler,`," on_error: ErrorHandler,"," shard_key: Option<&str>,"," ) -> Result<String, ClientError> {"," let _ = shard_key;",` Ok(self.client.subscribe("${p(e.functionPath)}", ${t}, on_data, on_error))`," }"].join(`
221
+ `)},Wr=e=>{const r=`${s(e.name)}Api`,t=e.methods.map(n=>n.verb==="query"?`${re(n)}
222
222
 
223
- ${kr(n)}`:ee(n)).join(`
223
+ ${Or(n)}`:re(n)).join(`
224
224
 
225
225
  `);return[`/// Functions declared in \`${l(e.name)}\`.`,`pub struct ${r}<'client> {`," client: &'client mut Client,","}","",`impl<'client> ${r}<'client> {`,t,"}"].join(`
226
- `)},_r=({models:e,namespaces:r})=>{const t=r.map(a=>[` /// Functions declared in \`${l(a.name)}\`.`,` pub fn ${S(a.name)}(&mut self) -> ${s(a.name)}Api<'_> {`,` ${s(a.name)}Api { client: self.client }`," }"].join(`
226
+ `)},Vr=({models:e,namespaces:r})=>{const t=r.map(a=>[` /// Functions declared in \`${l(a.name)}\`.`,` pub fn ${T(a.name)}(&mut self) -> ${s(a.name)}Api<'_> {`,` ${s(a.name)}Api { client: self.client }`," }"].join(`
227
227
  `)).join(`
228
228
 
229
- `),n=[k,`#![allow(dead_code, unused_imports)]
229
+ `),n=[_,`#![allow(dead_code, unused_imports)]
230
230
  `,`
231
231
  `,`use lunora::client::{Client, ClientError, DataHandler, ErrorHandler, Verb};
232
232
  `,`use lunora::wire::{encode_wire, from_model_json, WireValue};
233
233
  `,`
234
234
  `,`use crate::models::*;
235
235
  `,`
236
- `,r.map(a=>Tr(a)).join(`
236
+ `,r.map(a=>Wr(a)).join(`
237
237
 
238
238
  `),`
239
239
 
@@ -248,16 +248,16 @@ ${kr(n)}`:ee(n)).join(`
248
248
  `,t.length>0?`
249
249
  ${t}
250
250
  `:"",`}
251
- `].join("");return{"Cargo.toml":br,"src/api.rs":n,"src/lib.rs":vr,"src/models.rs":e.length>0?`${k}#![allow(dead_code)]
251
+ `].join("");return{"Cargo.toml":Sr,"src/api.rs":n,"src/lib.rs":_r,"src/models.rs":e.length>0?`${_}#![allow(dead_code)]
252
252
 
253
253
  ${e}
254
- `:`${k}#![allow(dead_code)]
254
+ `:`${_}#![allow(dead_code)]
255
255
 
256
256
  // No typed argument or result schemas in this deployment.
257
- `}},Sr={id:"rust",quicktype:{lang:"rust",rendererOptions:{"just-types":"true"}},render:_r,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"}]},N=`${f("swift").map(e=>`// ${e}`).join(`
257
+ `}},Lr={id:"rust",quicktype:{lang:"rust",rendererOptions:{"just-types":"true"}},render:Vr,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"}]},C=`${y("swift").map(e=>`// ${e}`).join(`
258
258
  `)}
259
259
 
260
- `,re="Sources/LunoraApi",Ar=`// swift-tools-version:5.9
260
+ `,te="Sources/LunoraApi",Nr=`// swift-tools-version:5.9
261
261
 
262
262
  import PackageDescription
263
263
 
@@ -287,20 +287,20 @@ let package = Package(
287
287
  .target(name: "LunoraApi", dependencies: ["Lunora"]),
288
288
  ]
289
289
  )
290
- `,Or=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"]),F=e=>{const r=s(e),t=r.charAt(0).toLowerCase()+r.slice(1);return Or.has(t)?`\`${t}\``:t},te=e=>{const r=e.argsType===void 0?"shardKey: String? = nil":`_ args: ${e.argsType}, shardKey: String? = nil`,t=e.argsType===void 0?"nil":"try LunoraClient.wireValue(args)",n=e.resultType??"Any",a=`try client.${e.verb}("${d(e.functionPath)}", args: ${t}, shardKey: shardKey)`,i=e.resultType===void 0?`return ${a}`:[`let raw = ${a}`," let data = try JSONSerialization.data(withJSONObject: raw, options: [.fragmentsAllowed])",` return try JSONDecoder().decode(${e.resultType}.self, from: data)`].join(`
291
- `);return[` /// ${l(e.summary)}`,` public func ${F(e.functionName)}(${r}) throws -> ${n} {`,` ${i}`," }"].join(`
292
- `)},Wr=e=>{const r=e.argsType===void 0?"":`_ args: ${e.argsType}, `,t=e.argsType===void 0?"nil":"try LunoraClient.wireValue(args)";return[` /// live ${l(e.summary)} — re-runs on every write to the tables it reads.`," @discardableResult",` public func subscribe${s(e.functionName)}(`,` ${r}onData: ((Any) -> Void)?,`," onError: ((LunoraSubscriptionError) -> Void)? = nil,"," shardKey: String? = nil"," ) throws -> LunoraUnsubscribe {",` client.subscribe("${d(e.functionPath)}", args: ${t}, onData: onData, onError: onError, shardKey: shardKey)`," }"].join(`
293
- `)},Vr=e=>{const r=`${s(e.name)}API`,t=e.methods.map(n=>n.verb==="query"?`${te(n)}
290
+ `,Cr=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"]),R=e=>{const r=s(e),t=r.charAt(0).toLowerCase()+r.slice(1);return Cr.has(t)?`\`${t}\``:t},ye=e=>d(e,{none:"nil",typed:()=>"try LunoraClient.wireValue(args)",untyped:"args"}),ne=e=>{const r=d(e,{none:"shardKey: String? = nil",typed:o=>`_ args: ${o}, shardKey: String? = nil`,untyped:"_ args: Any, shardKey: String? = nil"}),t=ye(e),n=e.resultType??"Any",a=`try client.${e.verb}("${p(e.functionPath)}", args: ${t}, shardKey: shardKey)`,i=e.resultType===void 0?`return ${a}`:[`let raw = ${a}`," let data = try JSONSerialization.data(withJSONObject: raw, options: [.fragmentsAllowed])",` return try JSONDecoder().decode(${e.resultType}.self, from: data)`].join(`
291
+ `);return[` /// ${l(e.summary)}`,` public func ${R(e.functionName)}(${r}) throws -> ${n} {`,` ${i}`," }"].join(`
292
+ `)},Mr=e=>{const r=d(e,{none:"",typed:n=>`_ args: ${n}, `,untyped:"_ args: Any, "}),t=ye(e);return[` /// live ${l(e.summary)} — re-runs on every write to the tables it reads.`," @discardableResult",` public func subscribe${s(e.functionName)}(`,` ${r}onData: ((Any) -> Void)?,`," onError: ((LunoraSubscriptionError) -> Void)? = nil,"," shardKey: String? = nil"," ) throws -> LunoraUnsubscribe {",` client.subscribe("${p(e.functionPath)}", args: ${t}, onData: onData, onError: onError, shardKey: shardKey)`," }"].join(`
293
+ `)},Er=e=>{const r=`${s(e.name)}API`,t=e.methods.map(n=>n.verb==="query"?`${ne(n)}
294
294
 
295
- ${Wr(n)}`:te(n)).join(`
295
+ ${Mr(n)}`:ne(n)).join(`
296
296
 
297
297
  `);return[`/// Functions declared in \`${l(e.name)}\`.`,`public struct ${r} {`," let client: LunoraClient","",t,"}"].join(`
298
- `)},Lr=({models:e,namespaces:r})=>{const t=r.map(i=>` public let ${F(i.name)}: ${s(i.name)}API`).join(`
299
- `),n=r.map(i=>` ${F(i.name)} = ${s(i.name)}API(client: client)`).join(`
300
- `),a=[N,`import Foundation
298
+ `)},Pr=({models:e,namespaces:r})=>{const t=r.map(i=>` public let ${R(i.name)}: ${s(i.name)}API`).join(`
299
+ `),n=r.map(i=>` ${R(i.name)} = ${s(i.name)}API(client: client)`).join(`
300
+ `),a=[C,`import Foundation
301
301
  `,`import Lunora
302
302
  `,`
303
- `,r.map(i=>Vr(i)).join(`
303
+ `,r.map(i=>Er(i)).join(`
304
304
 
305
305
  `),`
306
306
 
@@ -312,9 +312,9 @@ ${Wr(n)}`:te(n)).join(`
312
312
  `:` _ = client
313
313
  `,` }
314
314
  `,`}
315
- `].join("");return{"Package.swift":Ar,[`${re}/Api.swift`]:a,[`${re}/Models.swift`]:e.length>0?`${N}${e}
316
- `:`${N}import Foundation
315
+ `].join("");return{"Package.swift":Nr,[`${te}/Api.swift`]:a,[`${te}/Models.swift`]:e.length>0?`${C}${e}
316
+ `:`${C}import Foundation
317
317
 
318
318
  // No typed argument or result schemas in this deployment.
319
- `}},Nr={id:"swift",quicktype:{lang:"swift",rendererOptions:{"access-level":"public"}},render:Lr,requires:[],vendor:[{from:"Sources/Lunora",to:"Sources/Lunora"}]},Cr={go:Te,java:Xe,kotlin:or,python:pr,ruby:gr,rust:Sr,swift:Nr},Pr=Object.keys(Cr).toSorted((e,r)=>e.localeCompare(r)),Kr=async(e,r)=>{const t=me(e);$e(t);const n=r.renderModels?.(e),a=n===void 0?await ge(e,r):Object.values(n).join(`
320
- `),i=fe(t,a);return{files:{...n,...r.render({models:a,namespaces:i})},undeclared:he(t,a),unrepresentable:ye(e)}};export{Pr as SDK_LANGUAGES,Cr as SDK_TARGETS,Kr as generateSdk,Ir as isTypedSchema};
319
+ `}},Kr={id:"swift",quicktype:{lang:"swift",rendererOptions:{"access-level":"public"}},render:Pr,requires:[],vendor:[{from:"Sources/Lunora",to:"Sources/Lunora"}]},xr={go:Oe,java:nr,kotlin:cr,python:hr,ruby:kr,rust:Lr,swift:Kr},Dr=Object.keys(xr).toSorted((e,r)=>e.localeCompare(r)),Fr=async(e,r)=>{const t=he(e);ge(t);const n=r.renderModels?.(e),a=n===void 0?await je(e,r):Object.values(n).join(`
320
+ `),i=be(t,a);return{files:{...n,...r.render({models:a,namespaces:i})},undeclared:we(t,a),unrepresentable:ve(e)}};export{Dr as SDK_LANGUAGES,xr as SDK_TARGETS,Fr as generateSdk,zr as isTypedSchema};
@@ -1,3 +1,3 @@
1
- import{S as b}from"./emit-B8FxCABN.mjs";import{n as p}from"./paths-BmX5O1sG.mjs";import{LUNORA_ERROR_CODES as x,objectSchema as l,validatorIrToJsonSchema as d}from"./LUNORA_ERROR_CODES-zfAI2OFs.mjs";const O="/_lunora/rest",k=["authorization","cf-access-jwt-assertion","cookie"],f=["x-d1-bookmark","x-lunora-shard-key"],T=e=>[...k,...(e.credentialHeaders??[]).map(t=>t.toLowerCase())],g=e=>Number.isFinite(e)?Math.max(0,Math.floor(e)):0,y=(...e)=>{const t=[];for(const r of e)for(const o of r?.split(",")??[]){const a=o.trim().toLowerCase();a!==""&&!t.includes(a)&&t.push(a)}return t.length===0?void 0:t.join(", ")},R=(e,t)=>{const r=[t,`max-age=${String(g(e.maxAge))}`];return e.staleWhileRevalidate!==void 0&&r.push(`stale-while-revalidate=${String(g(e.staleWhileRevalidate))}`),r.join(", ")},P=e=>e.scope==="public"?y(e.vary,...T(e),...f):y(e.vary,...f),q=e=>{const t=e.indexOf(":");if(!(t<=0||t>=e.length-1||e.indexOf(":",t+1)!==-1))return{name:e.slice(t+1),namespace:e.slice(0,t)}},j=e=>{const t=q(e);if(t!==void 0)return`${O}/${t.namespace}/${t.name}`},A=e=>e==="query"?"GET":"POST",h="#/components/responses/LunoraError",$=/:([A-Za-z_$][\w$]*)/gu,N=e=>[...e.matchAll($)].map(t=>t[1]),w=e=>e.replaceAll($,"{$1}"),u=e=>e.kind==="optional"?e.inner??e:e,C=e=>{const t=new Set(N(e.path)),r=[];for(const[o,a]of Object.entries(e.searchParams)){const c=u(a);r.push({description:`Query parameter \`${o}\``,in:"query",name:o,required:a.kind!=="optional",schema:d(c)})}for(const[o,a]of Object.entries(e.params)){const c=u(a);r.push({description:`Path parameter \`${o}\``,in:t.has(o)?"path":"query",name:o,required:t.has(o)?!0:a.kind!=="optional",schema:d(c)})}return r},v=e=>e?{content:{"application/json":{schema:d(e)}},description:"Successful response."}:{content:{"application/json":{schema:{description:"Return shape is TS-inferred (no `.output()` declared); best-effort — any JSON."}}},description:"Successful response. The return shape is TypeScript-inferred and not declared via `.output()`, so it is documented best-effort."},E=e=>{const t=p(e.filePath),r=C(e),o={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${p(e.path)}`,responses:{200:v(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:h}},summary:`${e.method} ${e.path}`,tags:[t]};return r.length>0&&(o.parameters=r),Object.keys(e.body).length>0&&(o.requestBody={content:{"application/json":{schema:l(e.body)}},required:!0}),e.stream&&(o["x-lunora-stream"]="text/event-stream"),o},L=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o={additionalProperties:!1,properties:{args:l(e.args),functionPath:{const:r,type:"string"},shardKey:{description:"Optional shard key; omitted routes to the default shard.",type:"string"}},required:["functionPath"],type:"object"};return{operation:{description:`Invoke the \`${e.kind}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc).`,operationId:r,requestBody:{content:{"application/json":{schema:o}},required:!0},responses:{200:v(e.output),default:{$ref:h}},summary:`${e.kind}: ${r}`,tags:[t],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${r}`}},_=(e,t)=>{if(e===void 0||t!=="get"||e.scope===void 0||e.maxAge===void 0)return{};const r={maxAge:e.maxAge,scope:e.scope,...e.staleWhileRevalidate===void 0?{}:{staleWhileRevalidate:e.staleWhileRevalidate},...e.tag===void 0?{}:{tag:e.tag},...e.vary===void 0?{}:{vary:e.vary}},o={"Cache-Control":{description:r.scope==="public"?"Caching policy. `public` applies only to an uncredentialed request — a request carrying `Authorization` or `Cookie` is always answered `private`.":"Caching policy. Restricted to the caller's own cache; never stored by a shared/edge cache.",schema:{example:R(r,r.scope),type:"string"}}};r.tag!==void 0&&(o["Cache-Tag"]={description:"Purge tag for `ctx.cache.purge({ tags: [...] })`.",schema:{example:r.tag,type:"string"}});const a=P(r);return a!==void 0&&(o.Vary={description:"Request headers this response varies by. The endpoint's own negotiated headers are merged in at runtime.",schema:{example:a,type:"string"}}),{headers:o}},I=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o=j(r);if(o===void 0)return;const a=A(e.kind),c=a==="GET",n={description:`Public REST endpoint for the \`${e.kind}\` \`${r}\` (opt-in via \`.expose({ rest: true })\`). Routed through the procedure, so auth / RLS / validators are enforced.`,operationId:`rest_${p(o)}`,responses:{200:{content:{"application/json":{schema:{description:"Procedure result. The shape is TS-inferred from the return type; best-effort — any JSON."}}},description:"Successful result (TypeScript-inferred return shape, documented best-effort).",..._(e.expose?.cache,c?"get":"post")},default:{$ref:h}},summary:`${a} ${o}`,tags:[t],"x-lunora-function-kind":e.kind};if(c){const s=Object.entries(e.args).map(([i,m])=>{const S=u(m);return{description:`Argument \`${i}\` (JSON-encoded for non-string values).`,in:"query",name:i,required:m.kind!=="optional",schema:d(S)}});return s.length>0&&(n.parameters=s),{method:"get",operation:n,path:o}}return n.requestBody={content:{"application/json":{schema:l(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:n,path:o}},D=e=>{const t=e.version??"0.0.0",r={},o=new Set;for(const n of e.httpRoutes){const s=w(n.path),i=r[s]??{};i[n.method.toLowerCase()]=E(n),r[s]=i,o.add(p(n.filePath))}const a=e.functions.filter(n=>n.visibility!=="internal"&&n.kind!=="stream");for(const n of a){const{operation:s,pathKey:i}=L(n);r[i]={post:s},o.add(p(n.filePath))}for(const n of a){if(n.expose?.rest!==!0)continue;const s=I(n);if(s===void 0)continue;const i=r[s.path]??{};i[s.method]=s.operation,r[s.path]=i}const c=[...o].toSorted((n,s)=>n.localeCompare(s)).map(n=>({description:`Operations declared in \`lunora/${n}\`.`,name:n}));return{components:{responses:{LunoraError:{content:{"application/json":{schema:{additionalProperties:!1,description:"Standard Lunora error envelope.",properties:{error:{additionalProperties:!1,properties:{code:{description:"Machine-readable error code. Clients switch on this value.",enum:x,type:"string"},message:{description:"Human-readable error message (never echoes internal details).",type:"string"}},required:["code","message"],type:"object"}},required:["error"],type:"object"}}},description:"A Lunora error response. The HTTP status reflects the error code (e.g. BAD_REQUEST→400, UNAUTHORIZED→401, FORBIDDEN→403, NOT_FOUND→404)."}}},info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora API",version:t},openapi:"3.1.0",paths:r,tags:c}},U=e=>`${JSON.stringify(D(e),void 0,2)}
1
+ import{S as b}from"./emit-BbLyaTLJ.mjs";import{n as p}from"./paths-BmX5O1sG.mjs";import{LUNORA_ERROR_CODES as x,objectSchema as l,validatorIrToJsonSchema as d}from"./LUNORA_ERROR_CODES-zfAI2OFs.mjs";const O="/_lunora/rest",k=["authorization","cf-access-jwt-assertion","cookie"],f=["x-d1-bookmark","x-lunora-shard-key"],T=e=>[...k,...(e.credentialHeaders??[]).map(t=>t.toLowerCase())],g=e=>Number.isFinite(e)?Math.max(0,Math.floor(e)):0,y=(...e)=>{const t=[];for(const r of e)for(const o of r?.split(",")??[]){const a=o.trim().toLowerCase();a!==""&&!t.includes(a)&&t.push(a)}return t.length===0?void 0:t.join(", ")},R=(e,t)=>{const r=[t,`max-age=${String(g(e.maxAge))}`];return e.staleWhileRevalidate!==void 0&&r.push(`stale-while-revalidate=${String(g(e.staleWhileRevalidate))}`),r.join(", ")},P=e=>e.scope==="public"?y(e.vary,...T(e),...f):y(e.vary,...f),q=e=>{const t=e.indexOf(":");if(!(t<=0||t>=e.length-1||e.indexOf(":",t+1)!==-1))return{name:e.slice(t+1),namespace:e.slice(0,t)}},j=e=>{const t=q(e);if(t!==void 0)return`${O}/${t.namespace}/${t.name}`},A=e=>e==="query"?"GET":"POST",h="#/components/responses/LunoraError",$=/:([A-Za-z_$][\w$]*)/gu,N=e=>[...e.matchAll($)].map(t=>t[1]),w=e=>e.replaceAll($,"{$1}"),u=e=>e.kind==="optional"?e.inner??e:e,C=e=>{const t=new Set(N(e.path)),r=[];for(const[o,a]of Object.entries(e.searchParams)){const c=u(a);r.push({description:`Query parameter \`${o}\``,in:"query",name:o,required:a.kind!=="optional",schema:d(c)})}for(const[o,a]of Object.entries(e.params)){const c=u(a);r.push({description:`Path parameter \`${o}\``,in:t.has(o)?"path":"query",name:o,required:t.has(o)?!0:a.kind!=="optional",schema:d(c)})}return r},v=e=>e?{content:{"application/json":{schema:d(e)}},description:"Successful response."}:{content:{"application/json":{schema:{description:"Return shape is TS-inferred (no `.output()` declared); best-effort — any JSON."}}},description:"Successful response. The return shape is TypeScript-inferred and not declared via `.output()`, so it is documented best-effort."},E=e=>{const t=p(e.filePath),r=C(e),o={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${p(e.path)}`,responses:{200:v(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:h}},summary:`${e.method} ${e.path}`,tags:[t]};return r.length>0&&(o.parameters=r),Object.keys(e.body).length>0&&(o.requestBody={content:{"application/json":{schema:l(e.body)}},required:!0}),e.stream&&(o["x-lunora-stream"]="text/event-stream"),o},L=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o={additionalProperties:!1,properties:{args:l(e.args),functionPath:{const:r,type:"string"},shardKey:{description:"Optional shard key; omitted routes to the default shard.",type:"string"}},required:["functionPath"],type:"object"};return{operation:{description:`Invoke the \`${e.kind}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc).`,operationId:r,requestBody:{content:{"application/json":{schema:o}},required:!0},responses:{200:v(e.output),default:{$ref:h}},summary:`${e.kind}: ${r}`,tags:[t],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${r}`}},_=(e,t)=>{if(e===void 0||t!=="get"||e.scope===void 0||e.maxAge===void 0)return{};const r={maxAge:e.maxAge,scope:e.scope,...e.staleWhileRevalidate===void 0?{}:{staleWhileRevalidate:e.staleWhileRevalidate},...e.tag===void 0?{}:{tag:e.tag},...e.vary===void 0?{}:{vary:e.vary}},o={"Cache-Control":{description:r.scope==="public"?"Caching policy. `public` applies only to an uncredentialed request — a request carrying `Authorization` or `Cookie` is always answered `private`.":"Caching policy. Restricted to the caller's own cache; never stored by a shared/edge cache.",schema:{example:R(r,r.scope),type:"string"}}};r.tag!==void 0&&(o["Cache-Tag"]={description:"Purge tag for `ctx.cache.purge({ tags: [...] })`.",schema:{example:r.tag,type:"string"}});const a=P(r);return a!==void 0&&(o.Vary={description:"Request headers this response varies by. The endpoint's own negotiated headers are merged in at runtime.",schema:{example:a,type:"string"}}),{headers:o}},I=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o=j(r);if(o===void 0)return;const a=A(e.kind),c=a==="GET",n={description:`Public REST endpoint for the \`${e.kind}\` \`${r}\` (opt-in via \`.expose({ rest: true })\`). Routed through the procedure, so auth / RLS / validators are enforced.`,operationId:`rest_${p(o)}`,responses:{200:{content:{"application/json":{schema:{description:"Procedure result. The shape is TS-inferred from the return type; best-effort — any JSON."}}},description:"Successful result (TypeScript-inferred return shape, documented best-effort).",..._(e.expose?.cache,c?"get":"post")},default:{$ref:h}},summary:`${a} ${o}`,tags:[t],"x-lunora-function-kind":e.kind};if(c){const s=Object.entries(e.args).map(([i,m])=>{const S=u(m);return{description:`Argument \`${i}\` (JSON-encoded for non-string values).`,in:"query",name:i,required:m.kind!=="optional",schema:d(S)}});return s.length>0&&(n.parameters=s),{method:"get",operation:n,path:o}}return n.requestBody={content:{"application/json":{schema:l(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:n,path:o}},D=e=>{const t=e.version??"0.0.0",r={},o=new Set;for(const n of e.httpRoutes){const s=w(n.path),i=r[s]??{};i[n.method.toLowerCase()]=E(n),r[s]=i,o.add(p(n.filePath))}const a=e.functions.filter(n=>n.visibility!=="internal"&&n.kind!=="stream");for(const n of a){const{operation:s,pathKey:i}=L(n);r[i]={post:s},o.add(p(n.filePath))}for(const n of a){if(n.expose?.rest!==!0)continue;const s=I(n);if(s===void 0)continue;const i=r[s.path]??{};i[s.method]=s.operation,r[s.path]=i}const c=[...o].toSorted((n,s)=>n.localeCompare(s)).map(n=>({description:`Operations declared in \`lunora/${n}\`.`,name:n}));return{components:{responses:{LunoraError:{content:{"application/json":{schema:{additionalProperties:!1,description:"Standard Lunora error envelope.",properties:{error:{additionalProperties:!1,properties:{code:{description:"Machine-readable error code. Clients switch on this value.",enum:x,type:"string"},message:{description:"Human-readable error message (never echoes internal details).",type:"string"}},required:["code","message"],type:"object"}},required:["error"],type:"object"}}},description:"A Lunora error response. The HTTP status reflects the error code (e.g. BAD_REQUEST→400, UNAUTHORIZED→401, FORBIDDEN→403, NOT_FOUND→404)."}}},info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora API",version:t},openapi:"3.1.0",paths:r,tags:c}},U=e=>`${JSON.stringify(D(e),void 0,2)}
2
2
  `,W=e=>`${b}export const openApiSpec: Record<string, unknown> = ${JSON.stringify(e,void 0,4)};
3
3
  `;export{D as buildOpenApiDocument,U as emitOpenApi,W as emitOpenApiModule};