@lunora/codegen 1.0.0-alpha.384 → 1.0.0-alpha.385

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 (52) hide show
  1. package/dist/index.d.mts +32 -6
  2. package/dist/index.d.ts +32 -6
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{GENERATED_HEADER-Bzf6ZJ9r.mjs → GENERATED_HEADER-B-tYRlRG.mjs} +1 -1
  5. package/dist/packem_shared/{MUTATORS_FILENAME-DlSftsvY.mjs → MUTATORS_FILENAME-D9WbOFm7.mjs} +1 -1
  6. package/dist/packem_shared/{NOTIFY_FILENAME-SKk8x0VM.mjs → NOTIFY_FILENAME-CRU_TEKs.mjs} +1 -1
  7. package/dist/packem_shared/{OPENRPC_VERSION-CSjT8wJW.mjs → OPENRPC_VERSION-CT_E2DcI.mjs} +1 -1
  8. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DXilYf6b.mjs +31 -0
  9. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs +2 -0
  10. package/dist/packem_shared/{SHAPES_FILENAME-rSSihffV.mjs → SHAPES_FILENAME-D9beIrs1.mjs} +1 -1
  11. package/dist/packem_shared/{SchemaSnapshotParseError-ycDz8gOB.mjs → SchemaSnapshotParseError-DnAuFdpl.mjs} +8 -8
  12. package/dist/packem_shared/{buildOpenApiDocument-afHH7rN5.mjs → buildOpenApiDocument-67-fasdW.mjs} +1 -1
  13. package/dist/packem_shared/{context-property-calls-CYaejv5r.mjs → context-property-calls-ZK1UcTQR.mjs} +1 -1
  14. package/dist/packem_shared/{context-root-TiLodrRO.mjs → context-root-DtpwprsY.mjs} +1 -1
  15. package/dist/packem_shared/{database-calls-QqsrkDMs.mjs → database-calls-Cn47SfSU.mjs} +1 -1
  16. package/dist/packem_shared/{discoverFunctions-DdHysjy1.mjs → discoverFunctions-DU5ylqVC.mjs} +1 -1
  17. package/dist/packem_shared/{discoverHttpRoutes-5iA7gI_Q.mjs → discoverHttpRoutes-D9Q0lBBb.mjs} +1 -1
  18. package/dist/packem_shared/discoverHyperdriveCalls-DlyCZKX3.mjs +1 -0
  19. package/dist/packem_shared/{discoverInserts-Dw7fvL7s.mjs → discoverInserts-7Xdawmuk.mjs} +1 -1
  20. package/dist/packem_shared/discoverMaskProcedures-D6kAKDZG.mjs +1 -0
  21. package/dist/packem_shared/{discoverQueries-DVFZJER7.mjs → discoverQueries-C75OdGHl.mjs} +1 -1
  22. package/dist/packem_shared/discoverR2sqlCalls-BrDIti5c.mjs +1 -0
  23. package/dist/packem_shared/{discoverRlsProcedures-C2lkSLPn.mjs → discoverRlsProcedures-BiyDg2ej.mjs} +1 -1
  24. package/dist/packem_shared/discoverSchema-Bs5JUiOE.mjs +1 -0
  25. package/dist/packem_shared/{emitAgents-BeM6PZv4.mjs → emitAgents-iTKWSKan.mjs} +1 -1
  26. package/dist/packem_shared/{emitApi-GFmStqmq.mjs → emitApi-DWJW8Vu9.mjs} +1 -1
  27. package/dist/packem_shared/{emitApp-D-6FIpYb.mjs → emitApp-L7PnfjJK.mjs} +1 -1
  28. package/dist/packem_shared/{emitCrons-Drdn8Mjn.mjs → emitCrons-BvqxeNRr.mjs} +1 -1
  29. package/dist/packem_shared/{emitDataModel-LTnwnhV6.mjs → emitDataModel-MjAOi3KM.mjs} +1 -1
  30. package/dist/packem_shared/{emitDrizzleSchema-CM9jh_F0.mjs → emitDrizzleSchema-Dszoyymv.mjs} +1 -1
  31. package/dist/packem_shared/{emitFunctions-DRAuiKPv.mjs → emitFunctions-CvMrX_cX.mjs} +50 -50
  32. package/dist/packem_shared/{emitServer-4l7MPmK0.mjs → emitServer-BgI9yXW1.mjs} +1 -1
  33. package/dist/packem_shared/emitShard-D4sAFu7Z.mjs +1 -0
  34. package/dist/packem_shared/{index-iw3axJ5Y.mjs → index-CNI4vSyc.mjs} +1 -1
  35. package/dist/packem_shared/index-o449rQLQ.mjs +1 -0
  36. package/dist/packem_shared/{ip-reads-BVXbFgzV.mjs → ip-reads-Dotjify6.mjs} +1 -1
  37. package/dist/packem_shared/{qualifiers-D1Q_3wo2.mjs → qualifiers-ClaCHu0X.mjs} +1 -1
  38. package/dist/packem_shared/{server-D69SOfX8.mjs → server-qWq5nN-R.mjs} +1 -1
  39. package/dist/packem_shared/{shard-L3gYZnC9.mjs → shard-BqfSKnmG.mjs} +1 -1
  40. package/dist/packem_shared/{shard-runtime-lkQU8trx.mjs → shard-runtime-C1P_uVye.mjs} +1 -1
  41. package/dist/packem_shared/{shared-A1XHcT4t.mjs → shared-DhqnD5R3.mjs} +6 -6
  42. package/dist/packem_shared/static-literal-BwDHHjEJ.mjs +1 -0
  43. package/dist/packem_shared/{unwrap-handler-return-eQRIZSOX.mjs → unwrap-handler-return-c2s2-nk9.mjs} +1 -1
  44. package/package.json +8 -8
  45. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-Dle_pfr9.mjs +0 -31
  46. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-BdxZuSxk.mjs +0 -2
  47. package/dist/packem_shared/discoverHyperdriveCalls-BJRaIvLx.mjs +0 -1
  48. package/dist/packem_shared/discoverMaskProcedures-BLKjuD-A.mjs +0 -1
  49. package/dist/packem_shared/discoverR2sqlCalls-BEBdqXi_.mjs +0 -1
  50. package/dist/packem_shared/discoverSchema-Cycd1-H0.mjs +0 -1
  51. package/dist/packem_shared/emitShard-DqEvyZPZ.mjs +0 -1
  52. package/dist/packem_shared/index-BhsJzv9r.mjs +0 -1
@@ -1,3 +1,3 @@
1
- import{m as b}from"./modules-DEBCI7Gm.mjs";import{r as E}from"./json-data-Chfs2Cz5.mjs";import{LUNORA_ERROR_CODES as P,objectSchema as g,validatorIrToJsonSchema as l}from"./LUNORA_ERROR_CODES-CjACC-MQ.mjs";import{G as A}from"./shared-A1XHcT4t.mjs";import{s as m}from"./dispatch-namespace-DwTjD7BU.mjs";const T="/_lunora/rest",x=["authorization","cf-access-jwt-assertion","cookie","payment-signature","x-payment"],v=["x-d1-bookmark","x-lunora-shard-key"],j=e=>[...x,...(e.credentialHeaders??[]).map(t=>t.toLowerCase())],O=e=>Number.isFinite(e)?Math.max(0,Math.floor(e)):0,$=(...e)=>{const t=[];for(const r of e)for(const n of r?.split(",")??[]){const s=n.trim().toLowerCase();s!==""&&!t.includes(s)&&t.push(s)}return t.length===0?void 0:t.join(", ")},k=(e,t)=>{const r=[t,`max-age=${String(O(e.maxAge))}`];return e.staleWhileRevalidate!==void 0&&r.push(`stale-while-revalidate=${String(O(e.staleWhileRevalidate))}`),r.join(", ")},N=e=>e.scope==="public"?$(e.vary,...j(e),...v):$(e.vary,...v),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)}},_=e=>{const t=q(e);if(t!==void 0)return`${T}/${t.namespace}/${t.name}`},C=e=>e==="query"?"GET":"POST",y="#/components/responses/LunoraError",R=/:([A-Za-z_$][\w$]*)/gu,w=e=>[...e.matchAll(R)].map(t=>t[1]),D=e=>e.replaceAll(R,"{$1}"),f=e=>e.kind==="optional"?e.inner??e:e,I=e=>{const t=new Set(w(e.path)),r=[];for(const[n,s]of Object.entries(e.searchParams)){const c=f(s);r.push({description:`Query parameter \`${n}\``,in:"query",name:n,required:s.kind!=="optional",schema:l(c)})}for(const[n,s]of Object.entries(e.params)){const c=f(s);r.push({description:`Path parameter \`${n}\``,in:t.has(n)?"path":"query",name:n,required:t.has(n)?!0:s.kind!=="optional",schema:l(c)})}return r},S=e=>e?{content:{"application/json":{schema:l(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."},L=(e,t)=>{const r=I(e),n={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${m(e.path)}`,responses:{200:S(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:y}},summary:`${e.method} ${e.path}`,tags:[t]};return r.length>0&&(n.parameters=r),Object.keys(e.body).length>0&&(n.requestBody={content:{"application/json":{schema:g(e.body)}},required:!0}),e.stream&&(n["x-lunora-stream"]="text/event-stream"),n},F=(e,t)=>{const r=`${m(e.filePath)}:${e.exportName}`,n={additionalProperties:!1,properties:{args:g(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:n}},required:!0},responses:{200:S(e.output),default:{$ref:y}},summary:`${e.kind}: ${r}`,tags:[t],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${r}`}},H=(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}},n={"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:k(r,r.scope),type:"string"}}};r.tag!==void 0&&(n["Cache-Tag"]={description:"Purge tag for `ctx.cache.purge({ tags: [...] })`.",schema:{example:r.tag,type:"string"}});const s=N(r);return s!==void 0&&(n.Vary={description:"Request headers this response varies by. The endpoint's own negotiated headers are merged in at runtime.",schema:{example:s,type:"string"}}),{headers:n}},M=(e,t)=>{const r=`${m(e.filePath)}:${e.exportName}`,n=_(r);if(n===void 0)return;const s=C(e.kind),c=s==="GET",i={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_${m(n)}`,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).",...H(e.expose?.cache,c?"get":"post")},default:{$ref:y}},summary:`${s} ${n}`,tags:[t],"x-lunora-function-kind":e.kind};if(c){const d=Object.entries(e.args).map(([u,h])=>{const o=f(h);return{description:`Argument \`${u}\` (JSON-encoded for non-string values).`,in:"query",name:u,required:h.kind!=="optional",schema:l(o)}});return d.length>0&&(i.parameters=d),{method:"get",operation:i,path:n}}return i.requestBody={content:{"application/json":{schema:g(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:i,path:n}},J=e=>{const t=e.version??"0.0.0",r=Object.create(null),n=o=>r[o]??Object.create(null),s=new Set,c=e.modules??[],i=o=>b(c,o);for(const o of e.httpRoutes){const a=D(o.path),p=n(a);p[o.method.toLowerCase()]=L(o,i(o.filePath)),r[a]=p,s.add(i(o.filePath))}const d=e.functions.filter(o=>o.visibility!=="internal"&&o.kind!=="stream");for(const o of d){const{operation:a,pathKey:p}=F(o,i(o.filePath));r[p]={post:a},s.add(i(o.filePath))}for(const o of d){if(o.expose?.rest!==!0)continue;const a=M(o,i(o.filePath));if(a===void 0)continue;const p=n(a.path);p[a.method]=a.operation,r[a.path]=p}const u=[...s].toSorted((o,a)=>o.localeCompare(a)).map(o=>({description:c.find(p=>p.name===o)?.description??`Operations declared in \`lunora/${o}\`.`,name:o}));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:P,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:Object.fromEntries(Object.entries(r).map(([o,a])=>[o,{...a}])),tags:u}},z=e=>`${JSON.stringify(J(e),void 0,2)}
1
+ import{m as b}from"./modules-DEBCI7Gm.mjs";import{r as E}from"./json-data-Chfs2Cz5.mjs";import{LUNORA_ERROR_CODES as P,objectSchema as g,validatorIrToJsonSchema as l}from"./LUNORA_ERROR_CODES-CjACC-MQ.mjs";import{G as A}from"./shared-DhqnD5R3.mjs";import{s as m}from"./dispatch-namespace-DwTjD7BU.mjs";const T="/_lunora/rest",x=["authorization","cf-access-jwt-assertion","cookie","payment-signature","x-payment"],v=["x-d1-bookmark","x-lunora-shard-key"],j=e=>[...x,...(e.credentialHeaders??[]).map(t=>t.toLowerCase())],O=e=>Number.isFinite(e)?Math.max(0,Math.floor(e)):0,$=(...e)=>{const t=[];for(const r of e)for(const n of r?.split(",")??[]){const s=n.trim().toLowerCase();s!==""&&!t.includes(s)&&t.push(s)}return t.length===0?void 0:t.join(", ")},k=(e,t)=>{const r=[t,`max-age=${String(O(e.maxAge))}`];return e.staleWhileRevalidate!==void 0&&r.push(`stale-while-revalidate=${String(O(e.staleWhileRevalidate))}`),r.join(", ")},N=e=>e.scope==="public"?$(e.vary,...j(e),...v):$(e.vary,...v),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)}},_=e=>{const t=q(e);if(t!==void 0)return`${T}/${t.namespace}/${t.name}`},C=e=>e==="query"?"GET":"POST",y="#/components/responses/LunoraError",R=/:([A-Za-z_$][\w$]*)/gu,w=e=>[...e.matchAll(R)].map(t=>t[1]),D=e=>e.replaceAll(R,"{$1}"),f=e=>e.kind==="optional"?e.inner??e:e,I=e=>{const t=new Set(w(e.path)),r=[];for(const[n,s]of Object.entries(e.searchParams)){const c=f(s);r.push({description:`Query parameter \`${n}\``,in:"query",name:n,required:s.kind!=="optional",schema:l(c)})}for(const[n,s]of Object.entries(e.params)){const c=f(s);r.push({description:`Path parameter \`${n}\``,in:t.has(n)?"path":"query",name:n,required:t.has(n)?!0:s.kind!=="optional",schema:l(c)})}return r},S=e=>e?{content:{"application/json":{schema:l(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."},L=(e,t)=>{const r=I(e),n={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${m(e.path)}`,responses:{200:S(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:y}},summary:`${e.method} ${e.path}`,tags:[t]};return r.length>0&&(n.parameters=r),Object.keys(e.body).length>0&&(n.requestBody={content:{"application/json":{schema:g(e.body)}},required:!0}),e.stream&&(n["x-lunora-stream"]="text/event-stream"),n},F=(e,t)=>{const r=`${m(e.filePath)}:${e.exportName}`,n={additionalProperties:!1,properties:{args:g(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:n}},required:!0},responses:{200:S(e.output),default:{$ref:y}},summary:`${e.kind}: ${r}`,tags:[t],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${r}`}},H=(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}},n={"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:k(r,r.scope),type:"string"}}};r.tag!==void 0&&(n["Cache-Tag"]={description:"Purge tag for `ctx.cache.purge({ tags: [...] })`.",schema:{example:r.tag,type:"string"}});const s=N(r);return s!==void 0&&(n.Vary={description:"Request headers this response varies by. The endpoint's own negotiated headers are merged in at runtime.",schema:{example:s,type:"string"}}),{headers:n}},M=(e,t)=>{const r=`${m(e.filePath)}:${e.exportName}`,n=_(r);if(n===void 0)return;const s=C(e.kind),c=s==="GET",i={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_${m(n)}`,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).",...H(e.expose?.cache,c?"get":"post")},default:{$ref:y}},summary:`${s} ${n}`,tags:[t],"x-lunora-function-kind":e.kind};if(c){const d=Object.entries(e.args).map(([u,h])=>{const o=f(h);return{description:`Argument \`${u}\` (JSON-encoded for non-string values).`,in:"query",name:u,required:h.kind!=="optional",schema:l(o)}});return d.length>0&&(i.parameters=d),{method:"get",operation:i,path:n}}return i.requestBody={content:{"application/json":{schema:g(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:i,path:n}},J=e=>{const t=e.version??"0.0.0",r=Object.create(null),n=o=>r[o]??Object.create(null),s=new Set,c=e.modules??[],i=o=>b(c,o);for(const o of e.httpRoutes){const a=D(o.path),p=n(a);p[o.method.toLowerCase()]=L(o,i(o.filePath)),r[a]=p,s.add(i(o.filePath))}const d=e.functions.filter(o=>o.visibility!=="internal"&&o.kind!=="stream");for(const o of d){const{operation:a,pathKey:p}=F(o,i(o.filePath));r[p]={post:a},s.add(i(o.filePath))}for(const o of d){if(o.expose?.rest!==!0)continue;const a=M(o,i(o.filePath));if(a===void 0)continue;const p=n(a.path);p[a.method]=a.operation,r[a.path]=p}const u=[...s].toSorted((o,a)=>o.localeCompare(a)).map(o=>({description:c.find(p=>p.name===o)?.description??`Operations declared in \`lunora/${o}\`.`,name:o}));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:P,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:Object.fromEntries(Object.entries(r).map(([o,a])=>[o,{...a}])),tags:u}},z=e=>`${JSON.stringify(J(e),void 0,2)}
2
2
  `,K=e=>`${A}export const openApiSpec = ${E(e,"Record<string, unknown>")};
3
3
  `;export{J as buildOpenApiDocument,z as emitOpenApi,K as emitOpenApiModule};
@@ -1 +1 @@
1
- import{Node as i}from"ts-morph";import{listLunoraSourceFiles as a,lunoraRelativePath as c,handlerOf as l}from"./isTestPath-JdN4KXhV.mjs";import{j as d,h as f}from"./attribution-CTMkuBkn.mjs";import{c as u}from"./context-root-TiLodrRO.mjs";import{c as m}from"./classify-procedure-call-DtqiTjPg.mjs";const p=t=>{const r=t.getInitializer();if(!r||!i.isCallExpression(r))return;const e=m(r);if(!e||e.kind!=="query"&&e.kind!=="mutation")return;const o=l(r,e.receiver);return o?{exportName:f(t)??t.getName(),handler:o,kind:e.kind}:void 0},x=(t,r)=>{const e=t.getParent();return e&&i.isPropertyAccessExpression(e)&&e.getExpression()===t?`ctx.${r}.${e.getName()}`:`ctx.${r}`},h=(t,r,e)=>{const o=[];for(const n of u(t.handler,e))o.push({callee:x(n,e),exportName:t.exportName,file:r,kind:t.kind,line:n.getStartLineNumber()});return o},N=(t,r,e)=>{const o=[];for(const n of d(t)){const s=p(n);s&&o.push(...h(s,r,e))}return o},F=(t,r,e)=>{const o=[];for(const n of a(r)){const s=t.getSourceFile(n)??t.addSourceFileAtPath(n);o.push(...N(s,c(r,n),e))}return o};export{F as d};
1
+ import{Node as i}from"ts-morph";import{listLunoraSourceFiles as a,lunoraRelativePath as c,handlerOf as l}from"./isTestPath-JdN4KXhV.mjs";import{j as d,h as f}from"./attribution-CTMkuBkn.mjs";import{c as u}from"./context-root-DtpwprsY.mjs";import{c as m}from"./classify-procedure-call-DtqiTjPg.mjs";const p=t=>{const r=t.getInitializer();if(!r||!i.isCallExpression(r))return;const e=m(r);if(!e||e.kind!=="query"&&e.kind!=="mutation")return;const o=l(r,e.receiver);return o?{exportName:f(t)??t.getName(),handler:o,kind:e.kind}:void 0},x=(t,r)=>{const e=t.getParent();return e&&i.isPropertyAccessExpression(e)&&e.getExpression()===t?`ctx.${r}.${e.getName()}`:`ctx.${r}`},h=(t,r,e)=>{const o=[];for(const n of u(t.handler,e))o.push({callee:x(n,e),exportName:t.exportName,file:r,kind:t.kind,line:n.getStartLineNumber()});return o},N=(t,r,e)=>{const o=[];for(const n of d(t)){const s=p(n);s&&o.push(...h(s,r,e))}return o},F=(t,r,e)=>{const o=[];for(const n of a(r)){const s=t.getSourceFile(n)??t.addSourceFileAtPath(n);o.push(...N(s,c(r,n),e))}return o};export{F as d};
@@ -1 +1 @@
1
- import{Node as r,SyntaxKind as d}from"ts-morph";import{unwrapExpression as l,memberAccessOf as C,descendantsOfKind as p,bindingKeyName as I,findObjectProperty as E,isConstDeclaration as D,walkChain as M}from"./isTestPath-JdN4KXhV.mjs";import{d as v,b as S,f as F}from"./attribution-CTMkuBkn.mjs";import{c as b}from"./classify-procedure-call-DtqiTjPg.mjs";import{isDefineMutatorCallee as w}from"./MUTATORS_FILENAME-DlSftsvY.mjs";const x=8,N=t=>{if(r.isMethodDeclaration(t))return t;const e=r.isPropertyAssignment(t)?l(t.getInitializer()):void 0,o=r.isShorthandPropertyAssignment(t)?t.getNameNode():e;if(r.isArrowFunction(o)||r.isFunctionExpression(o))return o;const i=r.isIdentifier(o)?v(o):void 0;if(r.isFunctionDeclaration(i))return i;const n=D(i)?l(i.getInitializer()):void 0;return r.isArrowFunction(n)||r.isFunctionExpression(n)?n:void 0},T=t=>{const e=l(t.getArguments()[0]),o=r.isObjectLiteralExpression(e)?e:void 0,i=E(o,"server"),n=E(o,"handler"),s=i!==void 0&&w(t.getExpression()),a=n===void 0?void 0:b(t),u=a!==void 0&&a.receiver===void 0;return[s?N(i):void 0,u?N(n):void 0].filter(f=>f!==void 0)},P=new WeakMap,O=t=>{const e=t.getSourceFile(),o=P.get(e.compilerNode);if(o!==void 0)return o;const i=new Set(e.getDescendantsOfKind(d.CallExpression).flatMap(n=>T(n)).map(n=>n.compilerNode));return P.set(e.compilerNode,i),i},A=t=>{const e=t.getParent();return(r.isArrowFunction(e)||r.isFunctionExpression(e)||r.isFunctionDeclaration(e)||r.isMethodDeclaration(e))&&e.getParameters()[0]===t&&O(t).has(e.compilerNode)},Q=t=>{const e=t.getParent();return(r.isArrowFunction(e)||r.isFunctionExpression(e)||r.isFunctionDeclaration(e)||r.isMethodDeclaration(e))&&e.getParameters()[1]===t&&O(t).has(e.compilerNode)},B=t=>t.getNameNode().getDescendantsOfKind(d.BindingElement).some(e=>e.getParent().getParent()===t&&["args","ctx"].includes(I(e))),g=(t,e,o)=>{const i=t.getParent().getParent(),n=I(t);if(t.getDotDotDotToken()!==void 0||e==="trust"&&S(t))return;let s;if(r.isParameterDeclaration(i)){if(!A(i)||B(i))return n==="ctx"?[]:void 0;s=[]}else r.isBindingElement(i)?s=g(i,e,o):r.isVariableDeclaration(i)&&o>0&&(s=c(i.getInitializer(),e,o-1));return s===void 0?void 0:[...s,n]},c=(t,e="discover",o=x)=>{const i=l(t),n=C(i);if(n!==void 0){const s=c(n.object,e,o);return s===void 0?void 0:[...s,n.member]}return r.isIdentifier(i)?H(i,e,o):void 0},H=(t,e,o)=>{const i=t.getText()==="ctx",n=e==="trust"||!i?v(t):void 0;return i&&!r.isVariableDeclaration(n)?r.isBindingElement(n)?g(n,e,o):[]:r.isParameterDeclaration(n)?r.isIdentifier(n.getNameNode())&&A(n)?[]:void 0:r.isBindingElement(n)?g(n,e,o):!(r.isVariableDeclaration(n)&&r.isIdentifier(n.getNameNode())&&o>0)||e==="trust"&&S(n)?void 0:c(n.getInitializer(),e,o-1)},q=t=>c(t,"discover"),K=t=>{const e=c(t);return e===void 0?void 0:["ctx",...e].join(".")},J=(t,e)=>{if(e(t.getText()))return!0;const o=K(t);return o!==void 0&&e(o)},Y=(t,e)=>{const o=l(t),i=C(o);if(i!==void 0&&i.member!==e.at(-1))return!1;const n=o===void 0?void 0:c(o);return n?.length===e.length&&n.every((s,a)=>s===e[a])},Z=(t,e)=>y(t).get(e)??[],U=t=>{const e=new Map;for(const i of p(t,d.BindingElement)){const n=r.isIdentifier(i.getNameNode())?g(i,"discover",x):void 0;n?.length===1&&n[0]!==void 0&&e.set(i.compilerNode,n[0])}const o=new Set([...e.keys()].map(i=>i.name.getText()));return p(t,d.Identifier).flatMap(i=>{const s=o.has(i.getText())&&!r.isBindingElement(i.getParent())?v(i):void 0,a=s===void 0?void 0:e.get(s.compilerNode);return a===void 0?[]:[[a,i]]})},h=new WeakMap,y=t=>{const e=h.get(t.compilerNode);if(e!==void 0)return e;const o=new Map;for(const[n,s]of[...z(t),...U(t)])o.set(n,[...o.get(n)??[],s]);const i=new Map([...o].map(([n,s])=>[n,s.toSorted((a,u)=>a.getPos()-u.getPos())]));return h.set(t.compilerNode,i),i},z=t=>t.getDescendantsOfKind(d.PropertyAccessExpression).flatMap(e=>_(e.getExpression())?[[e.getName(),e]]:[]),_=t=>r.isIdentifier(t)&&c(t)?.length===0,$=t=>{const e=c(t);return e?.length===1&&e[0]==="db"},R=new Set(["asId","createMultipartUpload","fetch","generateUploadUrl","getPresignedUrl","getSignedUrl","getUrl","normalizeId","resumeMultipartUpload","runAction","runMutation","runQuery","store","upload"]),k=new Set(["catch","flatMap","map","reduce","reduceRight","then"]),L=(t,e=x)=>{const o=M(t,u=>{const f=l(u.getExpression()),m=r.isPropertyAccessExpression(f)?f.getName():void 0;return m!==void 0&&(R.has(m)||k.has(m))?!1:void 0}),i=o.root;if(o.verdict!==void 0||!r.isIdentifier(i))return o.verdict??!1;if(c(i,"trust")!==void 0)return!0;const n=v(i),s=r.isBindingElement(n)?n.getFirstAncestorByKind(d.VariableDeclaration):n,a=D(s)&&e>0?s.getInitializer():void 0;return a!==void 0&&L(a,e-1)},ee=t=>(r.isIdentifier(t)?[t]:t.getDescendantsOfKind(d.Identifier)).some(o=>F(o)&&c(o,"trust")!==void 0);export{k as C,R as E,Y as a,Q as b,Z as c,$ as d,K as e,q as f,L as g,_ as i,J as m,ee as r};
1
+ import{Node as r,SyntaxKind as d}from"ts-morph";import{unwrapExpression as l,memberAccessOf as C,descendantsOfKind as p,bindingKeyName as I,findObjectProperty as E,isConstDeclaration as D,walkChain as M}from"./isTestPath-JdN4KXhV.mjs";import{d as v,b as S,f as F}from"./attribution-CTMkuBkn.mjs";import{c as b}from"./classify-procedure-call-DtqiTjPg.mjs";import{isDefineMutatorCallee as w}from"./MUTATORS_FILENAME-D9WbOFm7.mjs";const x=8,N=t=>{if(r.isMethodDeclaration(t))return t;const e=r.isPropertyAssignment(t)?l(t.getInitializer()):void 0,o=r.isShorthandPropertyAssignment(t)?t.getNameNode():e;if(r.isArrowFunction(o)||r.isFunctionExpression(o))return o;const i=r.isIdentifier(o)?v(o):void 0;if(r.isFunctionDeclaration(i))return i;const n=D(i)?l(i.getInitializer()):void 0;return r.isArrowFunction(n)||r.isFunctionExpression(n)?n:void 0},T=t=>{const e=l(t.getArguments()[0]),o=r.isObjectLiteralExpression(e)?e:void 0,i=E(o,"server"),n=E(o,"handler"),s=i!==void 0&&w(t.getExpression()),a=n===void 0?void 0:b(t),u=a!==void 0&&a.receiver===void 0;return[s?N(i):void 0,u?N(n):void 0].filter(f=>f!==void 0)},P=new WeakMap,O=t=>{const e=t.getSourceFile(),o=P.get(e.compilerNode);if(o!==void 0)return o;const i=new Set(e.getDescendantsOfKind(d.CallExpression).flatMap(n=>T(n)).map(n=>n.compilerNode));return P.set(e.compilerNode,i),i},A=t=>{const e=t.getParent();return(r.isArrowFunction(e)||r.isFunctionExpression(e)||r.isFunctionDeclaration(e)||r.isMethodDeclaration(e))&&e.getParameters()[0]===t&&O(t).has(e.compilerNode)},Q=t=>{const e=t.getParent();return(r.isArrowFunction(e)||r.isFunctionExpression(e)||r.isFunctionDeclaration(e)||r.isMethodDeclaration(e))&&e.getParameters()[1]===t&&O(t).has(e.compilerNode)},B=t=>t.getNameNode().getDescendantsOfKind(d.BindingElement).some(e=>e.getParent().getParent()===t&&["args","ctx"].includes(I(e))),g=(t,e,o)=>{const i=t.getParent().getParent(),n=I(t);if(t.getDotDotDotToken()!==void 0||e==="trust"&&S(t))return;let s;if(r.isParameterDeclaration(i)){if(!A(i)||B(i))return n==="ctx"?[]:void 0;s=[]}else r.isBindingElement(i)?s=g(i,e,o):r.isVariableDeclaration(i)&&o>0&&(s=c(i.getInitializer(),e,o-1));return s===void 0?void 0:[...s,n]},c=(t,e="discover",o=x)=>{const i=l(t),n=C(i);if(n!==void 0){const s=c(n.object,e,o);return s===void 0?void 0:[...s,n.member]}return r.isIdentifier(i)?H(i,e,o):void 0},H=(t,e,o)=>{const i=t.getText()==="ctx",n=e==="trust"||!i?v(t):void 0;return i&&!r.isVariableDeclaration(n)?r.isBindingElement(n)?g(n,e,o):[]:r.isParameterDeclaration(n)?r.isIdentifier(n.getNameNode())&&A(n)?[]:void 0:r.isBindingElement(n)?g(n,e,o):!(r.isVariableDeclaration(n)&&r.isIdentifier(n.getNameNode())&&o>0)||e==="trust"&&S(n)?void 0:c(n.getInitializer(),e,o-1)},q=t=>c(t,"discover"),K=t=>{const e=c(t);return e===void 0?void 0:["ctx",...e].join(".")},J=(t,e)=>{if(e(t.getText()))return!0;const o=K(t);return o!==void 0&&e(o)},Y=(t,e)=>{const o=l(t),i=C(o);if(i!==void 0&&i.member!==e.at(-1))return!1;const n=o===void 0?void 0:c(o);return n?.length===e.length&&n.every((s,a)=>s===e[a])},Z=(t,e)=>y(t).get(e)??[],U=t=>{const e=new Map;for(const i of p(t,d.BindingElement)){const n=r.isIdentifier(i.getNameNode())?g(i,"discover",x):void 0;n?.length===1&&n[0]!==void 0&&e.set(i.compilerNode,n[0])}const o=new Set([...e.keys()].map(i=>i.name.getText()));return p(t,d.Identifier).flatMap(i=>{const s=o.has(i.getText())&&!r.isBindingElement(i.getParent())?v(i):void 0,a=s===void 0?void 0:e.get(s.compilerNode);return a===void 0?[]:[[a,i]]})},h=new WeakMap,y=t=>{const e=h.get(t.compilerNode);if(e!==void 0)return e;const o=new Map;for(const[n,s]of[...z(t),...U(t)])o.set(n,[...o.get(n)??[],s]);const i=new Map([...o].map(([n,s])=>[n,s.toSorted((a,u)=>a.getPos()-u.getPos())]));return h.set(t.compilerNode,i),i},z=t=>t.getDescendantsOfKind(d.PropertyAccessExpression).flatMap(e=>_(e.getExpression())?[[e.getName(),e]]:[]),_=t=>r.isIdentifier(t)&&c(t)?.length===0,$=t=>{const e=c(t);return e?.length===1&&e[0]==="db"},R=new Set(["asId","createMultipartUpload","fetch","generateUploadUrl","getPresignedUrl","getSignedUrl","getUrl","normalizeId","resumeMultipartUpload","runAction","runMutation","runQuery","store","upload"]),k=new Set(["catch","flatMap","map","reduce","reduceRight","then"]),L=(t,e=x)=>{const o=M(t,u=>{const f=l(u.getExpression()),m=r.isPropertyAccessExpression(f)?f.getName():void 0;return m!==void 0&&(R.has(m)||k.has(m))?!1:void 0}),i=o.root;if(o.verdict!==void 0||!r.isIdentifier(i))return o.verdict??!1;if(c(i,"trust")!==void 0)return!0;const n=v(i),s=r.isBindingElement(n)?n.getFirstAncestorByKind(d.VariableDeclaration):n,a=D(s)&&e>0?s.getInitializer():void 0;return a!==void 0&&L(a,e-1)},ee=t=>(r.isIdentifier(t)?[t]:t.getDescendantsOfKind(d.Identifier)).some(o=>F(o)&&c(o,"trust")!==void 0);export{k as C,R as E,Y as a,Q as b,Z as c,$ as d,K as e,q as f,L as g,_ as i,J as m,ee as r};
@@ -1 +1 @@
1
- import{SyntaxKind as g,Node as n}from"ts-morph";import{descendantsOfKind as p}from"./isTestPath-JdN4KXhV.mjs";import{d as l}from"./context-root-TiLodrRO.mjs";const c=e=>n.isPropertyAccessExpression(e)&&e.getName()==="db"||n.isIdentifier(e)&&e.getText()==="db"||l(e),b=new Set(["findFirst","findFirstOrThrow","findMany","findUnique"]),E=e=>{const t=e.getExpression();if(!n.isPropertyAccessExpression(t)||!b.has(t.getName()))return;const s=t.getExpression();if(c(s))return{options:e.getArguments()[1],table:d(e)};if(n.isPropertyAccessExpression(s)){const o=s.getExpression();if(c(o))return{options:e.getArguments()[0],table:s.getName()}}},f=(e,t)=>{const s=e.getExpression();return!n.isPropertyAccessExpression(s)||!t.has(s.getName())?!1:c(s.getExpression())},d=e=>{const t=e.getArguments()[0];return t&&n.isStringLiteral(t)?t.getLiteralText():""},A=(e,t,s)=>{const o=new Set,i=new Set;for(const a of p(e,g.CallExpression))if(f(a,t)){const r=d(a);r!==""&&o.add(r)}else if(f(a,s)){const r=d(a);r!==""&&i.add(r)}return{tablesRead:[...o],tablesWritten:[...i]}};export{c as i,E as r,A as t};
1
+ import{SyntaxKind as g,Node as n}from"ts-morph";import{descendantsOfKind as p}from"./isTestPath-JdN4KXhV.mjs";import{d as l}from"./context-root-DtpwprsY.mjs";const c=e=>n.isPropertyAccessExpression(e)&&e.getName()==="db"||n.isIdentifier(e)&&e.getText()==="db"||l(e),b=new Set(["findFirst","findFirstOrThrow","findMany","findUnique"]),E=e=>{const t=e.getExpression();if(!n.isPropertyAccessExpression(t)||!b.has(t.getName()))return;const s=t.getExpression();if(c(s))return{options:e.getArguments()[1],table:d(e)};if(n.isPropertyAccessExpression(s)){const o=s.getExpression();if(c(o))return{options:e.getArguments()[0],table:s.getName()}}},f=(e,t)=>{const s=e.getExpression();return!n.isPropertyAccessExpression(s)||!t.has(s.getName())?!1:c(s.getExpression())},d=e=>{const t=e.getArguments()[0];return t&&n.isStringLiteral(t)?t.getLiteralText():""},A=(e,t,s)=>{const o=new Set,i=new Set;for(const a of p(e,g.CallExpression))if(f(a,t)){const r=d(a);r!==""&&o.add(r)}else if(f(a,s)){const r=d(a);r!==""&&i.add(r)}return{tablesRead:[...o],tablesWritten:[...i]}};export{c as i,E as r,A as t};
@@ -1 +1 @@
1
- import"./declared-output-Iaar469J.mjs";import"./isTestPath-JdN4KXhV.mjs";import"./attribution-CTMkuBkn.mjs";import"./unwrap-handler-return-eQRIZSOX.mjs";import"./ip-reads-BVXbFgzV.mjs";import"./classify-procedure-call-DtqiTjPg.mjs";import{d as f}from"./index-BhsJzv9r.mjs";import"./dispatch-namespace-DwTjD7BU.mjs";export{f as default};
1
+ import"./declared-output-Iaar469J.mjs";import"./isTestPath-JdN4KXhV.mjs";import"./attribution-CTMkuBkn.mjs";import"./unwrap-handler-return-c2s2-nk9.mjs";import"./ip-reads-Dotjify6.mjs";import"./classify-procedure-call-DtqiTjPg.mjs";import{d as f}from"./index-o449rQLQ.mjs";import"./dispatch-namespace-DwTjD7BU.mjs";export{f as default};
@@ -1 +1 @@
1
- import{Node as n}from"ts-morph";import{a as m,p as l}from"./parse-validator-BisfC8bR.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./isTestPath-JdN4KXhV.mjs";import{j as f,h as g}from"./attribution-CTMkuBkn.mjs";import{u as x}from"./unwrap-handler-return-eQRIZSOX.mjs";const u=new Set(["delete","get","head","options","patch","post","put"]),E=new Set(["body","params","searchParams"]),v=new Set(["handler","stream"]),P=s=>{const e=s.getArguments()[0];if(e&&n.isStringLiteral(e))return e.getLiteralValue()},S=s=>{const e=s.getArguments()[0];return e&&n.isObjectLiteralExpression(e)?l(e):{}},A=s=>{if(!n.isCallExpression(s))return;const e=s.getExpression();if(!n.isPropertyAccessExpression(e))return;const o=e.getName();if(!u.has(o))return;const a=e.getExpression();if(!n.isIdentifier(a)||a.getText()!=="httpRoute")return;const t=P(s);return t===void 0?void 0:{method:o.toUpperCase(),path:t}},T=(s,e)=>{const o={body:{},params:{},searchParams:{},stream:e==="stream"},a=s.getExpression();if(!n.isPropertyAccessExpression(a))return;let t=a.getExpression();for(;n.isCallExpression(t);){const i=t.getExpression();if(!n.isPropertyAccessExpression(i))break;const c=i.getName();if(u.has(c))break;if(E.has(c)){const p=S(t);o[c]={...p,...o[c]}}else if(c==="output"&&o.output===void 0){const p=t.getArguments()[0];p&&n.isExpression(p)&&(o.output=m(p))}t=i.getExpression()}const r=A(t);if(r)return o.method=r.method,o.path=r.path,o},b=s=>{const e=s.getArguments()[0];return!e||!(n.isArrowFunction(e)||n.isFunctionExpression(e))?"unknown":x(e,!0)},y=(s,e,o,a)=>{const t=e.getName();if(!v.has(t))return;const r=T(s,t);if(!(r?.method===void 0||r.path===void 0))return{body:r.body,exportName:o,filePath:a,method:r.method,params:r.params,path:r.path,searchParams:r.searchParams,stream:r.stream,...r.stream?{chunkType:b(s)}:{},...r.output?{output:r.output}:{}}},R=(s,e)=>{const o=[];for(const a of f(s)){const t=a.getInitializer();if(!t||!n.isCallExpression(t))continue;const r=t.getExpression();if(!n.isPropertyAccessExpression(r))continue;const i=y(t,r,g(a)??a.getName(),e);i&&o.push(i)}return o},L=(s,e)=>{const o=d(e),a=[];for(const t of o){const r=s.getSourceFile(t)??s.addSourceFileAtPath(t),i=h(e,t);a.push(...R(r,i))}return a.sort((t,r)=>`${t.method} ${t.path}`.localeCompare(`${r.method} ${r.path}`)||t.filePath.localeCompare(r.filePath)),a};export{L as default};
1
+ import{Node as n}from"ts-morph";import{a as m,p as l}from"./parse-validator-BisfC8bR.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./isTestPath-JdN4KXhV.mjs";import{j as f,h as g}from"./attribution-CTMkuBkn.mjs";import{u as x}from"./unwrap-handler-return-c2s2-nk9.mjs";const u=new Set(["delete","get","head","options","patch","post","put"]),E=new Set(["body","params","searchParams"]),v=new Set(["handler","stream"]),P=s=>{const e=s.getArguments()[0];if(e&&n.isStringLiteral(e))return e.getLiteralValue()},S=s=>{const e=s.getArguments()[0];return e&&n.isObjectLiteralExpression(e)?l(e):{}},A=s=>{if(!n.isCallExpression(s))return;const e=s.getExpression();if(!n.isPropertyAccessExpression(e))return;const o=e.getName();if(!u.has(o))return;const a=e.getExpression();if(!n.isIdentifier(a)||a.getText()!=="httpRoute")return;const t=P(s);return t===void 0?void 0:{method:o.toUpperCase(),path:t}},T=(s,e)=>{const o={body:{},params:{},searchParams:{},stream:e==="stream"},a=s.getExpression();if(!n.isPropertyAccessExpression(a))return;let t=a.getExpression();for(;n.isCallExpression(t);){const i=t.getExpression();if(!n.isPropertyAccessExpression(i))break;const c=i.getName();if(u.has(c))break;if(E.has(c)){const p=S(t);o[c]={...p,...o[c]}}else if(c==="output"&&o.output===void 0){const p=t.getArguments()[0];p&&n.isExpression(p)&&(o.output=m(p))}t=i.getExpression()}const r=A(t);if(r)return o.method=r.method,o.path=r.path,o},b=s=>{const e=s.getArguments()[0];return!e||!(n.isArrowFunction(e)||n.isFunctionExpression(e))?"unknown":x(e,!0)},y=(s,e,o,a)=>{const t=e.getName();if(!v.has(t))return;const r=T(s,t);if(!(r?.method===void 0||r.path===void 0))return{body:r.body,exportName:o,filePath:a,method:r.method,params:r.params,path:r.path,searchParams:r.searchParams,stream:r.stream,...r.stream?{chunkType:b(s)}:{},...r.output?{output:r.output}:{}}},R=(s,e)=>{const o=[];for(const a of f(s)){const t=a.getInitializer();if(!t||!n.isCallExpression(t))continue;const r=t.getExpression();if(!n.isPropertyAccessExpression(r))continue;const i=y(t,r,g(a)??a.getName(),e);i&&o.push(i)}return o},L=(s,e)=>{const o=d(e),a=[];for(const t of o){const r=s.getSourceFile(t)??s.addSourceFileAtPath(t),i=h(e,t);a.push(...R(r,i))}return a.sort((t,r)=>`${t.method} ${t.path}`.localeCompare(`${r.method} ${r.path}`)||t.filePath.localeCompare(r.filePath)),a};export{L as default};
@@ -0,0 +1 @@
1
+ import{d as o}from"./context-property-calls-ZK1UcTQR.mjs";const t=(r,e)=>o(r,e,"sql");export{t as default};
@@ -1 +1 @@
1
- import{Node as i}from"ts-morph";import{collectCallRows as n}from"./isTestPath-JdN4KXhV.mjs";import{c as a}from"./attribution-CTMkuBkn.mjs";import{i as c}from"./database-calls-QqsrkDMs.mjs";const l=t=>{const e=t.getExpression();if(!i.isPropertyAccessExpression(e)||e.getName()!=="insert")return!1;const r=e.getExpression();return c(r)},g=t=>{if(!i.isIdentifier(t))return;const e=t.getSymbol(),r=e?.getAliasedSymbol()?.getDeclarations()??e?.getDeclarations()??[];for(const s of r)if(i.isVariableDeclaration(s)){const o=s.getInitializer();if(o&&i.isStringLiteral(o))return o.getLiteralText()}},f=t=>{const e=t.getArguments()[0];return e?i.isStringLiteral(e)?e.getLiteralText():g(e)??"":""},d=(t,e)=>n(t,e,(r,s)=>l(r)?{file:s,line:r.getStartLineNumber(),scope:a(r),table:f(r)}:void 0);export{d as default};
1
+ import{Node as i}from"ts-morph";import{collectCallRows as n}from"./isTestPath-JdN4KXhV.mjs";import{c as a}from"./attribution-CTMkuBkn.mjs";import{i as c}from"./database-calls-Cn47SfSU.mjs";const l=t=>{const e=t.getExpression();if(!i.isPropertyAccessExpression(e)||e.getName()!=="insert")return!1;const r=e.getExpression();return c(r)},g=t=>{if(!i.isIdentifier(t))return;const e=t.getSymbol(),r=e?.getAliasedSymbol()?.getDeclarations()??e?.getDeclarations()??[];for(const s of r)if(i.isVariableDeclaration(s)){const o=s.getInitializer();if(o&&i.isStringLiteral(o))return o.getLiteralText()}},f=t=>{const e=t.getArguments()[0];return e?i.isStringLiteral(e)?e.getLiteralText():g(e)??"":""},d=(t,e)=>n(t,e,(r,s)=>l(r)?{file:s,line:r.getStartLineNumber(),scope:a(r),table:f(r)}:void 0);export{d as default};
@@ -0,0 +1 @@
1
+ import"./isTestPath-JdN4KXhV.mjs";import"./attribution-CTMkuBkn.mjs";import"./database-calls-Cn47SfSU.mjs";import"./classify-procedure-call-DtqiTjPg.mjs";import{d as a}from"./index-CNI4vSyc.mjs";export{a as default};
@@ -1 +1 @@
1
- import{Node as i,SyntaxKind as u}from"ts-morph";import{collectCallRows as x}from"./isTestPath-JdN4KXhV.mjs";import{w as E,c as h}from"./attribution-CTMkuBkn.mjs";import{i as v}from"./database-calls-QqsrkDMs.mjs";const A=new Set(["withGeoIndex","withIndex","withSearchIndex"]),S=new Set(["collect","collectWithScores","first","paginate","take","unique"]),w=t=>{const e=t.getExpression();if(!i.isPropertyAccessExpression(e)||e.getName()!=="query")return!1;const n=e.getExpression();return v(n)},y=t=>{const e=[];let n=t;for(;;){const s=n.getParent();if(!s||!i.isPropertyAccessExpression(s))break;const r=s.getParent();if(!r||!i.isCallExpression(r))break;e.push(r),n=r}return e},l=t=>{const e=t.getExpression();return i.isPropertyAccessExpression(e)?e.getName():""},m=t=>{if(t===void 0||!(i.isArrowFunction(t)||i.isFunctionExpression(t)))return;const e=t.getParameters()[0]?.getNameNode();return e!==void 0&&i.isIdentifier(e)?e.getText():void 0},O=t=>{let e=t;for(;i.isCallExpression(e)||i.isPropertyAccessExpression(e);)e=e.getExpression();return e},P=(t,e)=>{const n=new Set,s=[t,...t.getDescendantsOfKind(u.CallExpression)].filter(r=>i.isCallExpression(r));for(const r of s){const c=r.getExpression();if(i.isPropertyAccessExpression(c)){const o=O(c);i.isIdentifier(o)&&o.getText()===e&&n.add(c.getName())}}return n},f=(t,e)=>{if(i.isParenthesizedExpression(t))return f(t.getExpression(),e);if(i.isConditionalExpression(t)){const n=f(t.getWhenFalse(),e);return new Set([...f(t.getWhenTrue(),e)].filter(s=>n.has(s)))}return P(t,e)},C=t=>{if(!(i.isArrowFunction(t)||i.isFunctionExpression(t)))return;const e=t.getBody();if(!i.isBlock(e))return i.isExpression(e)?[e]:void 0;const n=e.getDescendantsOfKind(u.ReturnStatement).filter(s=>s.getFirstAncestor(r=>i.isArrowFunction(r)||i.isFunctionExpression(r))?.compilerNode===t.compilerNode).map(s=>s.getExpression()).filter(s=>s!==void 0);return n.length===0?void 0:n},F=(t,e)=>{const n=C(t);if(n===void 0)return;const[s,...r]=n.map(o=>f(o,e));return[...s??new Set].filter(o=>r.every(d=>d.has(o))).toSorted((o,d)=>o.localeCompare(d))},I=(t,e)=>{const n=new Set;for(const s of t.getDescendantsOfKind(u.PropertyAccessExpression)){const r=s.getExpression();i.isIdentifier(r)&&r.getText()===e&&n.add(s.getName())}for(const s of t.getDescendantsOfKind(u.ElementAccessExpression)){const r=s.getExpression(),c=s.getArgumentExpression();i.isIdentifier(r)&&r.getText()===e&&c!==void 0&&i.isStringLiteral(c)&&n.add(c.getLiteralText())}return[...n]},N=t=>{if(t===void 0)return;const[e,n]=t.getArguments(),s=m(n),r=e!==void 0&&i.isStringLiteral(e)?e.getLiteralText():void 0;return n===void 0?{bounds:[],name:r}:{bounds:s===void 0?void 0:F(n,s),name:r}},T=t=>{const e=t.flatMap(n=>{const s=n.getArguments()[0],r=m(s);return s===void 0||r===void 0?[]:I(s,r)});if(e.length!==0)return[...new Set(e)].toSorted((n,s)=>n.localeCompare(s))},b=/\b[A-Za-z_$][\w$]*\._id\s*===?[^=]/u,D=t=>t.some(e=>l(e)==="filter"&&b.test(e.getArguments()[0]?.getText()??"")),L=t=>{const e=t.getArguments()[0];return e&&i.isStringLiteral(e)?e.getLiteralText():""},k=(t,e,n=[])=>{const s=x(t,e,(r,c)=>{if(!w(r))return;const o=y(r),d=o.map(a=>l(a)),p=o.filter(a=>l(a)==="filter"),g=p.length>0;return{file:c,filterFields:g?T(p):void 0,filtersPrimaryKey:g&&D(o),hasFilter:g,hasIndex:d.some(a=>A.has(a)),index:N(o.find(a=>l(a)==="withIndex")),line:r.getStartLineNumber(),scope:h(r),table:L(r),terminal:d.findLast(a=>S.has(a))}});return E(s,n)};export{k as default};
1
+ import{Node as i,SyntaxKind as u}from"ts-morph";import{collectCallRows as x}from"./isTestPath-JdN4KXhV.mjs";import{w as E,c as h}from"./attribution-CTMkuBkn.mjs";import{i as v}from"./database-calls-Cn47SfSU.mjs";const A=new Set(["withGeoIndex","withIndex","withSearchIndex"]),S=new Set(["collect","collectWithScores","first","paginate","take","unique"]),w=t=>{const e=t.getExpression();if(!i.isPropertyAccessExpression(e)||e.getName()!=="query")return!1;const n=e.getExpression();return v(n)},y=t=>{const e=[];let n=t;for(;;){const s=n.getParent();if(!s||!i.isPropertyAccessExpression(s))break;const r=s.getParent();if(!r||!i.isCallExpression(r))break;e.push(r),n=r}return e},l=t=>{const e=t.getExpression();return i.isPropertyAccessExpression(e)?e.getName():""},m=t=>{if(t===void 0||!(i.isArrowFunction(t)||i.isFunctionExpression(t)))return;const e=t.getParameters()[0]?.getNameNode();return e!==void 0&&i.isIdentifier(e)?e.getText():void 0},O=t=>{let e=t;for(;i.isCallExpression(e)||i.isPropertyAccessExpression(e);)e=e.getExpression();return e},P=(t,e)=>{const n=new Set,s=[t,...t.getDescendantsOfKind(u.CallExpression)].filter(r=>i.isCallExpression(r));for(const r of s){const c=r.getExpression();if(i.isPropertyAccessExpression(c)){const o=O(c);i.isIdentifier(o)&&o.getText()===e&&n.add(c.getName())}}return n},f=(t,e)=>{if(i.isParenthesizedExpression(t))return f(t.getExpression(),e);if(i.isConditionalExpression(t)){const n=f(t.getWhenFalse(),e);return new Set([...f(t.getWhenTrue(),e)].filter(s=>n.has(s)))}return P(t,e)},C=t=>{if(!(i.isArrowFunction(t)||i.isFunctionExpression(t)))return;const e=t.getBody();if(!i.isBlock(e))return i.isExpression(e)?[e]:void 0;const n=e.getDescendantsOfKind(u.ReturnStatement).filter(s=>s.getFirstAncestor(r=>i.isArrowFunction(r)||i.isFunctionExpression(r))?.compilerNode===t.compilerNode).map(s=>s.getExpression()).filter(s=>s!==void 0);return n.length===0?void 0:n},F=(t,e)=>{const n=C(t);if(n===void 0)return;const[s,...r]=n.map(o=>f(o,e));return[...s??new Set].filter(o=>r.every(d=>d.has(o))).toSorted((o,d)=>o.localeCompare(d))},I=(t,e)=>{const n=new Set;for(const s of t.getDescendantsOfKind(u.PropertyAccessExpression)){const r=s.getExpression();i.isIdentifier(r)&&r.getText()===e&&n.add(s.getName())}for(const s of t.getDescendantsOfKind(u.ElementAccessExpression)){const r=s.getExpression(),c=s.getArgumentExpression();i.isIdentifier(r)&&r.getText()===e&&c!==void 0&&i.isStringLiteral(c)&&n.add(c.getLiteralText())}return[...n]},N=t=>{if(t===void 0)return;const[e,n]=t.getArguments(),s=m(n),r=e!==void 0&&i.isStringLiteral(e)?e.getLiteralText():void 0;return n===void 0?{bounds:[],name:r}:{bounds:s===void 0?void 0:F(n,s),name:r}},T=t=>{const e=t.flatMap(n=>{const s=n.getArguments()[0],r=m(s);return s===void 0||r===void 0?[]:I(s,r)});if(e.length!==0)return[...new Set(e)].toSorted((n,s)=>n.localeCompare(s))},b=/\b[A-Za-z_$][\w$]*\._id\s*===?[^=]/u,D=t=>t.some(e=>l(e)==="filter"&&b.test(e.getArguments()[0]?.getText()??"")),L=t=>{const e=t.getArguments()[0];return e&&i.isStringLiteral(e)?e.getLiteralText():""},k=(t,e,n=[])=>{const s=x(t,e,(r,c)=>{if(!w(r))return;const o=y(r),d=o.map(a=>l(a)),p=o.filter(a=>l(a)==="filter"),g=p.length>0;return{file:c,filterFields:g?T(p):void 0,filtersPrimaryKey:g&&D(o),hasFilter:g,hasIndex:d.some(a=>A.has(a)),index:N(o.find(a=>l(a)==="withIndex")),line:r.getStartLineNumber(),scope:h(r),table:L(r),terminal:d.findLast(a=>S.has(a))}});return E(s,n)};export{k as default};
@@ -0,0 +1 @@
1
+ import{d as r}from"./context-property-calls-ZK1UcTQR.mjs";const t=(s,o)=>r(s,o,"r2sql");export{t as default};
@@ -1 +1 @@
1
- import{Node as o}from"ts-morph";import{listLunoraSourceFiles as c,lunoraRelativePath as f,findObjectProperty as u}from"./isTestPath-JdN4KXhV.mjs";import{j as p,h as m}from"./attribution-CTMkuBkn.mjs";import{t as d}from"./database-calls-QqsrkDMs.mjs";import{c as b}from"./classify-procedure-call-DtqiTjPg.mjs";import{r as h}from"./chain-DuEHFGVW.mjs";const g=e=>{const t=e.getArguments()[0];if(!t||!o.isArrayLiteralExpression(t))return[];const r=[];for(const s of t.getElements()){if(!o.isObjectLiteralExpression(s))continue;const i=u(s,"table");if(!i||!o.isPropertyAssignment(i))continue;const n=i.getInitializer();n&&o.isStringLiteral(n)&&r.push(n.getLiteralText())}return r},y=e=>{const t=h(e);return{rlsTables:t.flatMap(r=>g(r)),usesRls:t.length>0}},v=new Set(["explain","findFirst","findFirstOrThrow","findMany","get","query"]),x=new Set(["delete","deleteMany","insert","insertMany","patch","patchIf","patchMany","replace"]),P=(e,t)=>{if(!o.isVariableDeclaration(e))return;const r=e.getInitializer();if(!r||!o.isCallExpression(r))return;const s=b(r);if(!s)return;const i=s.receiver?y(s.receiver):{rlsTables:[],usesRls:!1},{tablesRead:n,tablesWritten:a}=d(e,v,x);return{exportName:m(e)??e.getName(),file:t,rlsTables:i.rlsTables,tablesRead:n,tablesWritten:a,usesRls:i.usesRls,visibility:s.visibility}},M=(e,t)=>{const r=[];for(const s of c(t)){const i=e.getSourceFile(s)??e.addSourceFileAtPath(s),n=f(t,s);for(const a of p(i)){const l=P(a,n);l&&r.push(l)}}return r};export{M as default};
1
+ import{Node as o}from"ts-morph";import{listLunoraSourceFiles as c,lunoraRelativePath as f,findObjectProperty as u}from"./isTestPath-JdN4KXhV.mjs";import{j as p,h as m}from"./attribution-CTMkuBkn.mjs";import{t as d}from"./database-calls-Cn47SfSU.mjs";import{c as b}from"./classify-procedure-call-DtqiTjPg.mjs";import{r as h}from"./chain-DuEHFGVW.mjs";const g=e=>{const t=e.getArguments()[0];if(!t||!o.isArrayLiteralExpression(t))return[];const r=[];for(const s of t.getElements()){if(!o.isObjectLiteralExpression(s))continue;const i=u(s,"table");if(!i||!o.isPropertyAssignment(i))continue;const n=i.getInitializer();n&&o.isStringLiteral(n)&&r.push(n.getLiteralText())}return r},y=e=>{const t=h(e);return{rlsTables:t.flatMap(r=>g(r)),usesRls:t.length>0}},v=new Set(["explain","findFirst","findFirstOrThrow","findMany","get","query"]),x=new Set(["delete","deleteMany","insert","insertMany","patch","patchIf","patchMany","replace"]),P=(e,t)=>{if(!o.isVariableDeclaration(e))return;const r=e.getInitializer();if(!r||!o.isCallExpression(r))return;const s=b(r);if(!s)return;const i=s.receiver?y(s.receiver):{rlsTables:[],usesRls:!1},{tablesRead:n,tablesWritten:a}=d(e,v,x);return{exportName:m(e)??e.getName(),file:t,rlsTables:i.rlsTables,tablesRead:n,tablesWritten:a,usesRls:i.usesRls,visibility:s.visibility}},M=(e,t)=>{const r=[];for(const s of c(t)){const i=e.getSourceFile(s)??e.addSourceFileAtPath(s),n=f(t,s);for(const a of p(i)){const l=P(a,n);l&&r.push(l)}}return r};export{M as default};
@@ -0,0 +1 @@
1
+ import{LunoraError as q}from"@lunora/errors";import{Node as a,SyntaxKind as J}from"ts-morph";import{diagnosticAt as d}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{findObjectProperty as m,descendantsOfKind as U}from"./isTestPath-JdN4KXhV.mjs";import{createRequire as W}from"node:module";import{join as N}from"node:path";import{fileURLToPath as K}from"node:url";import{createJiti as H}from"jiti";import{l as X,N as Z}from"./static-literal-BwDHHjEJ.mjs";import{r as G,p as Q}from"./parse-validator-BisfC8bR.mjs";import{R as Y}from"./reserved-words-CW1QFbTd.mjs";import{a as k}from"./property-name-7cBlgK_O.mjs";const ee=(e,t)=>`table "${e}" is .global() and declares vector index "${t}". Vector sync runs on the shard write path, which a global (D1/Hyperdrive) table's writes never take — the index would stay empty. Drop .global(), or keep the index yourself with ctx.vectors.upsert/deleteByIds.`,te=e=>{switch(typeof e){case"bigint":return e.toString();case"boolean":case"number":return String(e);case"string":return JSON.stringify(e);default:return e===null?"null":void 0}},ne=e=>({...e?.defaultValue!==void 0||e?.defaultFn!==void 0||e?.serverDefault!==void 0?{hasDefault:!0}:{},...e?.onUpdateFn===void 0?{}:{hasOnUpdate:!0},notNull:e?.notNull??!0,...e?.unique===!0?{unique:!0}:{}}),p=e=>{const t=e?._meta??{},n=e?.kind??"unknown",r={column:ne(t.column),kind:n,...t.sensitive===!0?{sensitive:!0}:{}};switch(n){case"array":case"optional":{r.inner=p(t.inner);break}case"from":break;case"id":{r.tableName=t.tableName;break}case"literal":{r.literalValue=te(t.value);break}case"object":{const i=t.shape??{};r.shape=Object.fromEntries(Object.entries(i).map(([o,l])=>[o,p(l)]));break}case"record":{r.valueType=p(t.valueValidator),t.keyValidator!==void 0&&(r.keyType=p(t.keyValidator));break}case"storage":{typeof t.bucket=="string"&&(r.bucket=t.bucket);break}case"union":{const i=t.members??[];r.members=i.map(o=>p(o));break}}const s=t.constraints;return s!==void 0&&Object.keys(s).length>0&&(r.hasRefinement=!0,n==="string"&&typeof s.maxLength=="number"&&(r.stringMaxLength=s.maxLength)),r},re=e=>e?.kind==="global"?"global":e?.kind==="shardBy"&&typeof e.field=="string"?{field:e.field,kind:"shardBy"}:"root",se=e=>{const t=r=>typeof e[r]=="string"?e[r]:void 0,n=Array.isArray(e.columns)?e.columns.filter(r=>typeof r=="string"):void 0;return{binding:t("binding")??"",...n===void 0?{}:{columns:n},hasReconcile:e.reconcileEveryMs!==void 0,hasSoftDelete:e.softDeleteColumn!==void 0,hasTenantBy:e.tenantBy!==void 0,...t("idColumn")===void 0?{}:{idColumn:t("idColumn")},...t("mode")===void 0?{}:{mode:t("mode")},...t("query")===void 0?{}:{query:t("query")}}},ie=(e,t)=>{const n=e.shape??{},r=(e.indexes??[]).map(i=>({fields:i.fields,name:i.name,...i.unique?{unique:!0}:{}})),s=re(e.shardMode);return{...e.aggregateIndexes&&e.aggregateIndexes.length>0?{aggregateIndexed:!0}:{},...e.commitOrderedMode===!0?{commitOrdered:!0}:{},...e.isExternallyManaged?{externallyManaged:!0}:{},...e.externalSource?{externalSource:se(e.externalSource)}:{},...e.isPublic===!0?{isPublic:!0}:{},geoIndexes:(e.geoIndexes??[]).map(({field:i,name:o,precision:l})=>({field:i,name:o,...l===void 0?{}:{precision:l}})),...s==="global"?{globalBackend:e.shardMode?.backend==="hyperdrive"?"hyperdrive":"d1"}:{},indexes:r,...e.memoryMode===!0?{memory:!0}:{},name:t,rankIndexes:(e.rankIndexes??[]).map(({name:i,partitionBy:o,sortBy:l})=>({name:i,...o===void 0?{}:{partitionBy:o},sortBy:l.map(({direction:c,field:u})=>({direction:c,field:u}))})),relations:Object.entries(e.relationMap??{}).map(([i,o])=>o.through!==void 0?{kind:"many",name:i,table:o.table,through:{...o.through}}:{field:o.field,kind:o.kind,name:i,...o.onDelete===void 0?{}:{onDelete:o.onDelete},references:o.references,table:o.table}),searchIndexes:(e.searchIndexes??[]).map(i=>({field:i.field,...i.filterFields?{filterFields:i.filterFields}:{},...i.language===void 0?{}:{language:i.language},...i.staged===void 0?{}:{staged:i.staged},...i.strategy===void 0?{}:{strategy:i.strategy},name:i.name})),shape:Object.fromEntries(Object.entries(n).map(([i,o])=>[i,p(o)])),shardMode:s,...e.softDeleteMode?{softDelete:{field:e.softDeleteMode.field}}:{},...e.ttlPolicy?{ttl:{field:e.ttlPolicy.field,...e.ttlPolicy.after===void 0?{}:{after:e.ttlPolicy.after}}}:{},vectorIndexes:(e.vectorIndexes??[]).map(i=>({...i.dimensions===void 0?{}:{dimensions:i.dimensions},field:i.field,...i.metadata===void 0?{}:{metadata:i.metadata},...i.metric===void 0?{}:{metric:i.metric},name:i.name,table:t}))}},oe=e=>{const{key:t,tables:n}=e;if(typeof t!="string"||typeof n!="object"||n===null)return;const r=Object.entries(n).map(([o,l])=>ie(l,o)),s=e.vectorIndexes??{},i=Object.entries(s??{}).map(([o,l])=>({...l.dimensions===void 0?{}:{dimensions:l.dimensions},...l.field===void 0?{}:{field:l.field},...l.metadata===void 0?{}:{metadata:l.metadata},...l.metric===void 0?{}:{metric:l.metric},name:o,table:l.table??""}));return{bareTables:r,bareVectorIndexes:i,key:t}},ae=e=>{if(a.isIdentifier(e))return e.getText();if(a.isPropertyAccessExpression(e)){const t=e.getExpression();return a.isIdentifier(t)?t.getText():void 0}},le=e=>{const t=ae(e);if(t===void 0)return;const n=a.isPropertyAccessExpression(e)?e.getName():void 0,r=n===void 0?[]:[n];for(const s of e.getSourceFile().getImportDeclarations()){const i=s.getModuleSpecifierValue();for(const o of s.getNamedImports())if((o.getAliasNode()?.getText()??o.getName())===t)return{importedName:o.getName(),moduleSpecifier:i,propertyPath:r};if(s.getDefaultImport()?.getText()===t)return{importedName:"default",moduleSpecifier:i,propertyPath:r};if(s.getNamespaceImport()?.getText()===t&&n!==void 0)return{importedName:n,moduleSpecifier:i,propertyPath:[]}}},j=e=>a.isCallExpression(e)?e:a.isParenthesizedExpression(e)||a.isAsExpression(e)||a.isSatisfiesExpression(e)?j(e.getExpression()):void 0,ce=(e,t,n)=>{const r=n.getSymbol()?.compilerSymbol,s=i=>r!==void 0&&i?.getSymbol()?.compilerSymbol===r;return a.isPropertyAccessExpression(t)?s(e.getNamespaceImport())?t.getName():void 0:s(e.getDefaultImport())?"default":e.getNamedImports().find(i=>s(i.getAliasNode()??i.getNameNode()))?.getName()},de=e=>{if(!a.isPropertyAccessExpression(e)||!a.isIdentifier(e.getExpression()))return;const t=e.getExpression().getSymbol(),n=(t?.getAliasedSymbol()??t)?.getValueDeclaration(),r=a.isVariableDeclaration(n)?n.getInitializer():void 0,s=r===void 0?void 0:j(r),i=s?.getExpression(),o=i!==void 0&&a.isPropertyAccessExpression(i)?i.getExpression():i;if(s===void 0||i===void 0||o===void 0||!a.isIdentifier(o))return;const l=s.getArguments().map(u=>X(u)),c=s.getReturnType().getProperty(e.getName())?.getTypeAtLocation(s).getNonNullableType();if(!(l.includes(Z)||c?.getProperty("tables")===void 0))for(const u of s.getSourceFile().getImportDeclarations()){const h=u.getModuleSpecifierValue();if(h.startsWith("."))continue;const y=ce(u,i,o);if(y!==void 0)return{args:l,importedName:y,moduleSpecifier:h,propertyPath:[e.getName()]}}},$=(e,t)=>{let n=e;for(const r of t){if(typeof n!="object"||n===null)return;n=n[r]}return n},fe=(e,t)=>$(e[t.importedName],t.propertyPath),P=(e,t)=>{const n=H(N(t,"noop.js")).esmResolve(e);return W(N(t,"noop.cjs"))(n.startsWith("file:")?K(n):n)},ue=(e,t)=>{const n=le(e);if(n&&!n.moduleSpecifier.startsWith("."))return fe(P(n.moduleSpecifier,t),n);const r=de(e);if(!r)return;const s=P(r.moduleSpecifier,t)[r.importedName];return typeof s=="function"?$(s(...r.args),r.propertyPath):void 0},me=(e,t)=>{try{const n=ue(e,t);return typeof n!="object"||n===null?void 0:oe(n)}catch{return}},ge=new Set(["cosine","dot-product","euclidean"]),x=(e,t)=>{const n=m(e,t);if(n&&a.isPropertyAssignment(n))return n.getInitializer()},f=(e,t)=>{const n=x(e,t);if(n&&a.isStringLiteral(n))return n.getLiteralText()},E=(e,t)=>{const n=x(e,t);if(n&&a.isNumericLiteral(n))return Number(n.getLiteralText())},D=(e,t)=>{const n=x(e,t);if(n&&(a.isTrueLiteral(n)||a.isFalseLiteral(n)))return n.getLiteralValue()},I=(e,t)=>{const n=x(e,t);if(n&&a.isArrayLiteralExpression(n))return n.getElements().filter(r=>a.isStringLiteral(r)).map(r=>r.getLiteralText())},z=e=>e&&ge.has(e)?e:void 0,S=e=>e&&a.isStringLiteral(e)?e.getLiteralText():"_unnamed_",pe=(e,t)=>{const n=I(e,t);return n!==void 0&&n.length>0?n:void 0},M=(e,t,n,r,s)=>{let i=e;for(;;){const o=i.getParent();if(!o||!a.isPropertyAccessExpression(o))break;const l=o.getParent();if(!l||!a.isCallExpression(l))break;if(o.getName()===t){const c=l.getArguments()[0];if(!c||!a.isStringLiteral(c))throw d(l,`\`.${t}(...)\` expects a string literal (${s})`);const u=c.getLiteralText();if(!r.has(u))throw d(c,`unknown ${n} ${JSON.stringify(u)} — expected ${s}`);return u}i=l}},he=e=>`table "${e}" is both .global() and .ttl(). The TTL sweep is a shard's alarm deleting from that shard's own SQLite, and a global (D1/Hyperdrive) table's rows live outside every shard — so expired rows would never be deleted. Drop .ttl() and expire the rows from a cron, or keep the table shard-local.`,be=/^(?:sqlite_|_cf_|__)/u,xe=/__(?:agg|rank|geo|fts)_/u,ye=e=>be.test(e)||xe.test(e),ve=new Set(["cascade","restrict","set null"]),Ee=new Set(["aggregate","asId","assertPatchAllowed","cdcChangedTables","count","delete","deleteAll","deleteMany","deleteRereadTables","deleteWhere","explain","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","insertMany","insertManyUnsafe","inTransaction","lookupById","normalizeId","patch","patchIf","patchMany","patchWhere","query","rank","rankBefore","rankPage","rankPageRows","related","relationEdges","relationWrites","replace","restore","softDeleteFields","system","wipeShard"]),R=/^[A-Za-z_$][\w$]*$/u,T=(e,t)=>{if(Ee.has(e))throw d(t,`table name "${e}" is reserved — the generated shard binds each table's facade onto the same object that carries \`ctx.db\`'s own members, so this table would overwrite \`ctx.db.${e}\` and every use of it would break. Rename the table.`);if(Y.has(e))throw d(t,`table name "${e}" is a reserved JavaScript word — codegen interpolates table names into a bare \`const ${e} = sqliteTable(...)\` binding in the generated Drizzle module, which is a syntax error for a keyword. Rename the table.`);if(!R.test(e))throw d(t,`table name ${JSON.stringify(e)} is not a valid JS identifier — table names are used in generated type names (Doc_<name>) and must match [A-Za-z_$][A-Za-z0-9_$]*. Rename the table.`);if(ye(e))throw d(t,`table name ${JSON.stringify(e)} is reserved for framework tables — a leading \`__\` and the \`__agg_\`/\`__rank_\`/\`__geo_\`/\`__fts_\` infixes name Lunora's own bookkeeping and index companions, so the Studio and the admin API hide and refuse such a table. Rename the table.`)},Ie=e=>e&&ve.has(e)?e:void 0,Se=e=>{if(!a.isArrowFunction(e))return;let t=e.getBody();if(a.isParenthesizedExpression(t))t=t.getExpression();else if(a.isBlock(t)){const n=t.getStatements().find(r=>a.isReturnStatement(r));t=n&&a.isReturnStatement(n)?n.getExpression()??t:t}return a.isObjectLiteralExpression(t)?t:void 0},we=(e,t,n)=>{const r=a.isPropertyAssignment(e)?e.getInitializer():void 0;if(!r||!a.isObjectLiteralExpression(r))throw d(e,"relation `through` must be an object literal `{ table, from, to }` — codegen resolves it statically.");const[s,i,o]=["table","from","to"].map(l=>f(r,l));if(s===void 0||i===void 0||o===void 0)throw d(r,"relation `through` needs string-literal `table`, `from` and `to` — codegen resolves them statically.");if(i===o)throw d(r,`relation \`through\` has \`from\` and \`to\` both set to "${i}"; a link needs two different columns.`);return{kind:"many",name:t,table:n,through:{from:i,table:s,to:o}}},ke=(e,t,n,r)=>{const s=r&&a.isObjectLiteralExpression(r)?r:void 0,i=e==="many"?s?.getProperty("through"):void 0;return i?we(i,t,n):{field:(s&&f(s,"field"))??"_unknown_",kind:e,name:t,onDelete:e==="one"&&s?Ie(f(s,"onDelete")):void 0,references:(s&&f(s,"references"))??"_id",table:n}},Te=e=>{if(!a.isPropertyAssignment(e))return;const t=e.getInitializer();if(!t||!a.isCallExpression(t))return;const n=t.getExpression();if(!a.isPropertyAccessExpression(n))return;const r=n.getName();if(r!=="one"&&r!=="many")return;const[s,i]=t.getArguments();if(!s||!a.isStringLiteral(s))throw d(s??t,`relation target table must be a string literal — codegen resolves relation targets statically. Got ${s?s.getText():"no argument"}.`);const o=s.getLiteralText();return ke(r,k(e),o,i)},Ae=e=>{const t=Se(e);if(!t)return[];const n=[];for(const r of t.getProperties()){const s=Te(r);s&&n.push(s)}return n},Oe=(e,t,n)=>{if(!t.includes("."))return;const[r="",...s]=t.split("."),i=`${r}${s.map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("")}`;throw d(e,`index "${n}" indexes the nested path ${JSON.stringify(t)} — Lunora indexes only top-level columns. Denormalise the value into its own column (e.g. \`${i}\`), index that instead, and keep it in sync with a table \`.triggers()\` beforeInsert/beforeUpdate.`,{code:"INDEX_FIELD_NESTED_PATH",name:"LunoraError",status:500})},Ne=e=>{if(!e||!a.isObjectLiteralExpression(e))return!1;const t=m(e,"unique");if(!t||!a.isPropertyAssignment(t))return!1;const n=t.getInitializer();if(n===void 0)return!1;if(!a.isTrueLiteral(n)&&!a.isFalseLiteral(n))throw d(n,`\`unique\` must be a literal \`true\` or \`false\`, got ${JSON.stringify(n.getText())}`);return a.isTrueLiteral(n)},Pe=e=>{const[t,n,r]=e,s=Ne(r),i=S(t),o=n&&a.isArrayLiteralExpression(n)?n.getElements():[];for(const c of o)if(!a.isStringLiteral(c))throw d(c,`index "${i}" lists a non-literal field (${JSON.stringify(c.getText())}); codegen reads index fields statically, so every entry must be a string literal.`);const l=o.filter(c=>a.isStringLiteral(c));for(const c of l)Oe(c,c.getLiteralText(),i);return{fields:l.map(c=>c.getLiteralText()),name:i,unique:s}},_e=e=>{const[t,n]=e;let r="_unknown_",s,i,o,l;return n&&a.isObjectLiteralExpression(n)&&(r=f(n,"field")??r,s=I(n,"filterFields"),i=f(n,"language"),o=D(n,"staged"),l=f(n,"strategy")),{field:r,filterFields:s,language:i,name:S(t),staged:o,strategy:l}},Le=e=>{const[t,n]=e;let r="_unknown_",s;return n&&a.isObjectLiteralExpression(n)&&(r=f(n,"field")??r,s=E(n,"precision")),{field:r,name:S(t),precision:s}},je=e=>{const[t,n]=e,r=t&&a.isStringLiteral(t)?t.getLiteralText():"_unknown_";let s;return n&&a.isObjectLiteralExpression(n)&&(s=E(n,"after")),{after:s,field:r}},$e=e=>{if(!a.isObjectLiteralExpression(e))return;const t=f(e,"field");return t===void 0?void 0:{direction:f(e,"direction")==="desc"?"desc":"asc",field:t}},De=e=>{const[t,n]=e;let r=[],s;if(n&&a.isObjectLiteralExpression(n)){const i=m(n,"sortBy");if(i&&a.isPropertyAssignment(i)){const o=i.getInitializer();o&&a.isArrayLiteralExpression(o)&&(r=o.getElements().map(l=>$e(l)).filter(l=>l!==void 0))}s=I(n,"partitionBy")}return{name:S(t),partitionBy:s,sortBy:r}},ze=(e,t)=>{const[n,r]=e,s=n&&a.isStringLiteral(n)?n.getLiteralText():"_unknown_";if(!(!r||!a.isObjectLiteralExpression(r)))return{dimensions:E(r,"dimensions"),field:s,metadata:I(r,"metadata"),metric:z(f(r,"metric")),name:f(r,"index")??"_unnamed_",table:t}},Me=e=>{const t=e[0];return t&&a.isObjectLiteralExpression(t)&&f(t,"backend")==="hyperdrive"?"hyperdrive":"d1"},_=(e,t)=>{if(e===void 0)return t;if(!a.isObjectLiteralExpression(e))throw d(e,"the options must be an object literal — codegen reads the column name from the source and cannot evaluate a variable or an expression here.");const n=m(e,"field");if(n===void 0)return t;const r=a.isPropertyAssignment(n)?n.getInitializer():void 0;if(r&&a.isStringLiteral(r))return r.getLiteralText();throw d(n,"`field` must be a string literal — codegen reads the column name from the source and cannot evaluate a constant or an expression here.")},Re=e=>{const t=e[0];return!t||!a.isObjectLiteralExpression(t)?{binding:"",hasTenantBy:!1,unanalyzable:!0}:{binding:f(t,"binding")??"",columns:pe(t,"columns"),hasReconcile:m(t,"reconcileEveryMs")!==void 0,hasSoftDelete:m(t,"softDeleteColumn")!==void 0,hasTenantBy:m(t,"tenantBy")!==void 0,idColumn:f(t,"idColumn"),mode:f(t,"mode"),query:f(t,"query")}},Ce=(e,t,n,r)=>{switch(t){case"aggregateIndex":{e.aggregateIndexed=!0;break}case"commitOrdered":{e.commitOrdered=!0;break}case"externallyManaged":{e.externallyManaged=!0;break}case"geoIndex":{e.geoIndexes.push(Le(n));break}case"global":{e.shardMode="global",e.globalBackend=Me(n);break}case"index":{e.indexes.unshift(Pe(n));break}case"memory":{e.memory=!0;break}case"public":{e.isPublic=!0;break}case"rankIndex":{e.rankIndexes.push(De(n));break}case"relations":{const s=n[0];s&&e.relations.push(...Ae(s));break}case"searchIndex":{e.searchIndexes.push(_e(n));break}case"shardBy":{const s=n[0];e.shardMode={field:s&&a.isStringLiteral(s)?s.getLiteralText():"_unknown_",kind:"shardBy"};break}case"softDelete":{e.softDelete={field:_(n[0],"deletedAt")};break}case"source":{e.externalSource=Re(n),e.externallyManaged=!0;break}case"timestamps":{e.timestampsFields.push(_(n[0],"updatedAt"));break}case"ttl":{e.ttl=je(n);break}case"vectorize":{const s=ze(n,r);s&&e.vectorIndexes.push(s);break}}},L=["__vocab","_config","_content","_data","_docsize","_idx"],Fe=(e,t,n)=>{const r=new Set(n.map(s=>s.name));for(const s of n)for(const i of L){const o=`${s.name}${i}`;if(!r.has(o))continue;const l=i==="__vocab"?`the \`fts5vocab\` companion for "${o}" is created \`IF NOT EXISTS\`, so it silently resolves to "${s.name}"'s — the second index then reads the wrong vocabulary and returns wrong results, with no error`:`creating "${o}" is rejected (\`object name reserved for internal use: SQLITE_ERROR\`), which aborts the shard migration and leaves every sharded table unreadable`;throw d(e,`table "${t}" declares search indexes "${s.name}" and "${o}", whose generated FTS5 tables collide: "${s.name}" already owns "${t}__fts_${o}" as its "${i}" companion, so ${l}. Rename one of them so neither ends with another's name plus ${L.join(", ")}.`)}},Be=(e,t,n)=>{if(n.ttl!==void 0&&n.shardMode==="global")throw d(e,he(t))},Ve=(e,t,n)=>{const{softDelete:r,timestampsFields:s}=n,i={};r&&!(r.field in t)&&(i[r.field]={inner:{column:{notNull:!1},kind:"number"},kind:"optional"});const[o]=s;if(o===void 0)return{...t,...i};if(s.length>1)throw d(e,"`.timestamps()` was called more than once; one table tracks one last-change column.");if(o===r?.field)throw d(e,`\`.softDelete()\` and \`.timestamps()\` both use "${o}"; give one of them another field.`);const l=t[o];if(l===void 0)i[o]={column:{hasDefault:!0,hasOnUpdate:!0,notNull:!0},kind:"timestamp"};else if(l.kind!=="timestamp"||l.column?.hasOnUpdate!==!0||l.column.hasDefault!==!0)throw d(e,`\`.timestamps()\` would add "${o}", but the table already declares it as something other than \`v.timestamp().defaultNow().$onUpdateFn(() => Date.now())\`; remove the column or declare it that way.`);return{...t,...i}},C=(e,t)=>{const n={aggregateIndexed:!1,commitOrdered:!1,externallyManaged:!1,geoIndexes:[],indexes:[],isPublic:!1,memory:!1,rankIndexes:[],relations:[],searchIndexes:[],shardMode:"root",timestampsFields:[],vectorIndexes:[]};let r={},s=e;for(;a.isCallExpression(s);){const i=s.getExpression(),o=s.getArguments();if(a.isPropertyAccessExpression(i))Ce(n,i.getName(),o,t),s=i.getExpression();else if(a.isIdentifier(i)&&i.getText()==="defineTable"){const l=o[0];if(l&&a.isObjectLiteralExpression(l))r=Q(l);else if(l)throw d(l,`table "${t}" calls defineTable(${JSON.stringify(l.getText())}), but codegen reads the field map syntactically and can only read an object literal. Inline the fields into the defineTable(...) call. To reuse them in an \`.input()\`, derive from the generated \`Doc_${t}\` / \`Insert_${t}\` type instead of sharing the runtime value.`);break}else break}return r=Ve(e,r,n),Fe(e,t,n.searchIndexes),Be(e,t,n),{...n.aggregateIndexed?{aggregateIndexed:!0}:{},commitOrdered:n.commitOrdered,externallyManaged:n.externallyManaged,externalSource:n.externalSource,geoIndexes:n.geoIndexes,globalBackend:n.shardMode==="global"?n.globalBackend??"d1":void 0,indexes:n.indexes,isPublic:n.isPublic,memory:n.memory,name:t,rankIndexes:n.rankIndexes,relations:n.relations,searchIndexes:n.searchIndexes,shape:r,shardMode:n.shardMode,softDelete:n.softDelete,ttl:n.ttl,vectorIndexes:n.vectorIndexes}},F=(e,t=[],n=new Set,r=new Set)=>{r.add(e);for(const s of e.getProperties()){if(a.isSpreadAssignment(s)){const o=G(s.getExpression());o!==void 0&&!r.has(o)&&F(o,t,n,r);continue}if(!a.isPropertyAssignment(s))continue;const i=s.getInitializer();if(i){const o=k(s);if(T(o,s.getNameNode()),n.has(o))throw d(s.getNameNode(),`defineSchema({...}): table "${o}" is declared more than once — the earlier declaration would be silently discarded. Remove the duplicate.`);n.add(o),t.push(C(i,o))}}return t},qe=e=>{const t=m(e,"source");if(t&&a.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&a.isObjectLiteralExpression(n))return f(n,"table")??"_unknown_"}return"_unknown_"},Je=e=>{if(!a.isPropertyAssignment(e))return;const t=e.getInitializer();if(!t||!a.isCallExpression(t))return;const n=t.getExpression();if(!a.isIdentifier(n)||n.getText()!=="defineVectorIndex")return;const r=t.getArguments()[0];if(!r||!a.isObjectLiteralExpression(r))return;const s=e.getNameNode(),i=a.isStringLiteral(s)?s.getLiteralText():s.getText();return{dimensions:E(r,"dimensions"),metric:z(f(r,"metric")),name:i,table:qe(r)}},B=e=>{const t=[];for(const n of e.getProperties()){const r=Je(n);r&&t.push(r)}return t},A=(e,t)=>`${e}_${t}`,Ue=(e,t)=>{if(!R.test(e))throw d(t,`defineSchemaExtension key ${JSON.stringify(e)} is not a valid JS identifier — it is prefixed onto every table the extension contributes (\`${e}_<table>\`), and table names are used in generated type names (Doc_<name>) and must match [A-Za-z_$][A-Za-z0-9_$]*. Rename the extension key.`)},b=(e,t,n)=>n.has(e)?A(t,e):e,v=(e,t)=>{const n=r=>r===void 0?void 0:v(r,t);return{...e,...e.tableName===void 0?{}:{tableName:t(e.tableName)},...e.inner===void 0?{}:{inner:n(e.inner)},...e.keyType===void 0?{}:{keyType:n(e.keyType)},...e.valueType===void 0?{}:{valueType:n(e.valueType)},...e.members===void 0?{}:{members:e.members.map(r=>v(r,t))},...e.shape===void 0?{}:{shape:Object.fromEntries(Object.entries(e.shape).map(([r,s])=>[r,v(s,t)]))}}},We=(e,t,n,r)=>{const s=A(t,e.name);return{...e,extensionKey:t,...r?{extensionFromPackage:!0}:{},name:s,shape:Object.fromEntries(Object.entries(e.shape).map(([i,o])=>[i,v(o,l=>b(l,t,n))])),relations:e.relations.map(i=>{const o=b(i.table,t,n);return i.through===void 0?{...i,table:o}:{...i,table:o,through:{...i.through,table:b(i.through.table,t,n)}}}),vectorIndexes:e.vectorIndexes.map(i=>({...i,table:b(i.table,t,n)}))}},Ke=e=>{if(a.isVariableDeclaration(e)||a.isPropertyAssignment(e))return e.getInitializer();if(a.isShorthandPropertyAssignment(e))return e.getNameNode()},He=e=>{if(!a.isCallExpression(e))return!1;const t=e.getExpression();return a.isIdentifier(t)&&t.getText()==="defineSchemaExtension"},Xe=e=>{if(a.isIdentifier(e))return e;if(a.isPropertyAccessExpression(e)){const t=e.getExpression();return a.isIdentifier(t)?t:void 0}},Ze=e=>{if(a.isObjectLiteralExpression(e))return e;if(a.isCallExpression(e)){const t=e.getExpression();let n;if(a.isIdentifier(t)?n=t.getText():a.isPropertyAccessExpression(t)&&(n=t.getName()),n==="definePlugin"){const r=e.getArguments()[1];return r&&a.isObjectLiteralExpression(r)?r:void 0}}},Ge=(e,t)=>{const n=Ke(e);if(n){if(a.isPropertyAccessExpression(t)){const r=Ze(n);return r?x(r,t.getName()):void 0}return n}},Qe=e=>{let t=e,n=0;for(;t&&n<32;){if(n+=1,He(t))return t;const r=Xe(t),s=r&&a.isIdentifier(r)?r.getSymbol():void 0,o=(s?.getAliasedSymbol()?.getDeclarations()??s?.getDeclarations()??[])[0];if(!o)return;const l=o.getSourceFile();if(l.isInNodeModules()||l.isDeclarationFile())return;t=Ge(o,t)}},Ye=e=>{const[t,n]=e.getArguments();if(!(!t||!a.isStringLiteral(t))&&!(!n||!a.isObjectLiteralExpression(n)))return{key:t.getLiteralText(),keyNode:t,options:n}},et=e=>{const t=m(e,"tables");if(!t||!a.isPropertyAssignment(t))return[];const n=t.getInitializer();if(!n||!a.isObjectLiteralExpression(n))return[];const r=[];for(const s of n.getProperties()){if(!a.isPropertyAssignment(s))continue;const i=s.getInitializer();if(!i)continue;const o=k(s);T(o,s.getNameNode()),r.push(C(i,o))}return r},tt=e=>{const t=m(e,"vectorIndexes");if(!t||!a.isPropertyAssignment(t))return[];const n=t.getInitializer();return!n||!a.isObjectLiteralExpression(n)?[]:B(n)},V=(e,t,n,r,s)=>{Ue(e,r);const i=new Set(t.map(c=>c.name)),o=t.map(c=>We(c,e,i,s)),l=n.map(c=>({...c,name:A(e,c.name),table:b(c.table,e,i)}));return{tables:o,vectorIndexes:l}},nt=(e,t,n)=>V(e,et(n),tt(n),t,t.getSourceFile().getFilePath().includes("/node_modules/")),rt=(e,t)=>{const n=e.getArguments()[0];if(!n)return;let r=n;for(;a.isParenthesizedExpression(r)||a.isAsExpression(r)||a.isSatisfiesExpression(r);)r=r.getExpression();const s=Qe(r);if(!s){if(t!==void 0){const o=me(r,t);if(o){for(const l of o.bareTables)T(l.name,r);return V(o.key,o.bareTables,o.bareVectorIndexes,r,!0)}}console.warn(`@lunora/codegen: skipping \`.extend(${r.getText()})\` — its \`defineSchemaExtension(...)\` could not be resolved from local sources, and ${t===void 0?"no project root was available to resolve the package":"the package could not be imported/introspected"}. Extension tables will be absent from the generated types. If the receiver is a component built with options codegen cannot evaluate (a function, a variable), extend with the standalone extension the package exports instead (e.g. \`presenceExtension\`, \`actionCacheExtension\` or \`documentHistoryExtension\` from \`@lunora/server\`).`);return}const i=Ye(s);if(!i){console.warn("@lunora/codegen: skipping `.extend(...)` — `defineSchemaExtension` requires a string `key` and an options object literal.");return}return nt(i.key,i.keyNode,i.options)},st=e=>{const t=[];let n=e;for(;;){const r=n.getParent();if(!r||!a.isPropertyAccessExpression(r))break;const s=r.getParent();if(!s||!a.isCallExpression(s))break;r.getName()==="extend"&&t.push(s),n=s}return t},it=(e,t,n)=>{const r=new Set(t.map(i=>i.name)),s=[];for(const i of st(e)){const o=rt(i,n);if(o){for(const l of o.tables){if(r.has(l.name))throw d(i,`defineSchema(...).extend(...): table "${l.name}" already exists — another extension with the same key already contributed it.`);r.add(l.name),t.push(l)}s.push(...o.vectorIndexes)}}return s},ot=new Set(["eu","fedramp","us"]),at=e=>M(e,"jurisdiction","jurisdiction",ot,'"eu", "us", or "fedramp"'),lt=e=>{let t=e;for(;;){const n=t.getParent(),r=n?.getParent();if(!n||!a.isPropertyAccessExpression(n)||!r||!a.isCallExpression(r))return!1;if(n.getName()==="jurisdiction"){const s=r.getArguments()[1];return s!==void 0&&a.isObjectLiteralExpression(s)&&D(s,"pinAuth")===!0}t=r}},ct=new Set(["required"]),dt=e=>M(e,"rls","rls mode",ct,'"required"'),ft=e=>{if(!a.isObjectLiteralExpression(e))return;const t=new Set;for(const n of e.getProperties()){const r=a.isPropertyAssignment(n)?n.getInitializer():void 0;if(!r||!a.isCallExpression(r))return;const s=r.getExpression(),i=r.getArguments()[1],o=i&&a.isObjectLiteralExpression(i)?f(i,"on"):void 0;if(!a.isIdentifier(s)||s.getText()!=="defineAggregateIndex"||o===void 0)return;t.add(o)}return t},ut=(e,t)=>{if(t===void 0)return;const n=ft(t);for(const r of e)(n===void 0||n.has(r.name))&&(r.aggregateIndexed=!0)},kt=(e,t,n)=>{const r=e.addSourceFileAtPath(t),s=U(r,J.CallExpression).find(g=>{const O=g.getExpression();return a.isIdentifier(O)&&O.getText()==="defineSchema"});if(!s)throw new q("INTERNAL",`defineSchema() not found in ${t}`);const i=s.getArguments()[0];if(!i||!a.isObjectLiteralExpression(i))throw d(s,"defineSchema() expects an object literal");const o=F(i),l=s.getArguments()[1],c=l&&a.isObjectLiteralExpression(l)?B(l):[],u=it(s,o,n);ut(o,s.getArguments()[2]);const h=[...o.flatMap(g=>g.vectorIndexes),...c,...u],y=new Set(o.filter(g=>g.shardMode==="global").map(g=>g.name)),w=h.find(g=>y.has(g.table));if(w)throw d(s,ee(w.table,w.name));return{jurisdiction:at(s),...lt(s)?{jurisdictionPinsAuth:!0}:{},rlsMode:dt(s),tables:o,vectorIndexes:h}};export{kt as default};
@@ -1 +1 @@
1
- import"./json-data-Chfs2Cz5.mjs";import{p as i,j as r,t as n,h as o,u as g,k as F,d as u,x as p,n as l,g as f,f as d,m as k,i as w,v as W,l as v,w as A}from"./shard-runtime-lkQU8trx.mjs";import"./shared-A1XHcT4t.mjs";import"./platform-8oj7iXQy.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,n as emitAgents,o as emitContainerFragments,g as emitContainers,F as emitPaymentFragments,u as emitQueueFragments,p as emitQueues,l as emitQueuesMetadataFragments,f as emitServiceFragments,d as emitTopicFragments,k as emitWorkflowEventFragments,w as emitWorkflowFragments,W as emitWorkflows,v as emitWorkflowsMetadataFragments,A as queueAliasFindings};
1
+ import"./json-data-Chfs2Cz5.mjs";import{p as i,j as r,t as n,h as o,u as g,k as F,d as u,x as p,n as l,g as f,f as d,m as k,i as w,v as W,l as v,w as A}from"./shard-runtime-C1P_uVye.mjs";import"./shared-DhqnD5R3.mjs";import"./platform-8oj7iXQy.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,n as emitAgents,o as emitContainerFragments,g as emitContainers,F as emitPaymentFragments,u as emitQueueFragments,p as emitQueues,l as emitQueuesMetadataFragments,f as emitServiceFragments,d as emitTopicFragments,k as emitWorkflowEventFragments,w as emitWorkflowFragments,W as emitWorkflows,v as emitWorkflowsMetadataFragments,A as queueAliasFindings};
@@ -1,4 +1,4 @@
1
- import{AGENT_RUNTIME_FUNCTIONS as N}from"@lunora/agent/naming";import{LunoraError as R}from"@lunora/errors";import{r as d,a as w,b as P,c as L}from"./qualifiers-D1Q_3wo2.mjs";import{a as A,r as y,p as $,G as x,b as k,c as m,d as S,e as O,i as T}from"./shared-A1XHcT4t.mjs";import{s as g}from"./dispatch-namespace-DwTjD7BU.mjs";const j=t=>k(t,e=>{const s=d(y(e.args),e.filePath),n=d(L(e),e.filePath),o=`FunctionReference<"${e.kind}", ${s}, ${n}>`;return`${e.exportName}: ${T(e)?`${o} & { readonly sensitive: true }`:o};`},"type"),I=(t,e)=>{if(t.length===0&&e.length===0)return{block:"",importLine:""};const s=[];let n="";if(t.length>0&&(n+="\n/** Params type carried by a `defineWorkflow` definition (its phantom `__params`). */\ntype WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params } ? (unknown extends Params ? Record<string, unknown> : Params) : Record<string, unknown>;\n"),n+=`
1
+ import{AGENT_RUNTIME_FUNCTIONS as N}from"@lunora/agent/naming";import{LunoraError as R}from"@lunora/errors";import{r as d,a as w,b as P,c as L}from"./qualifiers-ClaCHu0X.mjs";import{a as A,r as y,p as $,G as x,b as k,c as m,d as S,e as O,i as T}from"./shared-DhqnD5R3.mjs";import{s as g}from"./dispatch-namespace-DwTjD7BU.mjs";const j=t=>k(t,e=>{const s=d(y(e.args),e.filePath),n=d(L(e),e.filePath),o=`FunctionReference<"${e.kind}", ${s}, ${n}>`;return`${e.exportName}: ${T(e)?`${o} & { readonly sensitive: true }`:o};`},"type"),I=(t,e)=>{if(t.length===0&&e.length===0)return{block:"",importLine:""};const s=[];let n="";if(t.length>0&&(n+="\n/** Params type carried by a `defineWorkflow` definition (its phantom `__params`). */\ntype WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params } ? (unknown extends Params ? Record<string, unknown> : Params) : Record<string, unknown>;\n"),n+=`
2
2
  /** A typed reference to a durable workflow, addressable for \`cronJobs()\` targets. Mirrors \`@lunora/scheduler\`'s \`WorkflowReference\` structurally. */
3
3
  export interface WorkflowReference<Params = Record<string, unknown>> {
4
4
  readonly isLunoraWorkflow: true;
@@ -1,4 +1,4 @@
1
- import{APP_METHOD_CAPABILITIES as q}from"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{i as I}from"./schema-BgM8A3XV.mjs";import{a as N,I as L,G as y}from"./shared-A1XHcT4t.mjs";const j={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},f=e=>[...q.filter(({key:r})=>e.capabilities.has(r)).map(({appMethod:r})=>r),...e.hasVectors?[j]:[]],w=e=>f(e).length>0,k=e=>(e.emailAgents?.length??0)>0,c=e=>e.tables.some(r=>I(r)),p=e=>e.liveStreams===!0&&(e.liveStreamDeclarations?.length??0)>0,$=e=>e.hasScheduler?`
1
+ import{APP_METHOD_CAPABILITIES as q}from"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{i as I}from"./schema-BgM8A3XV.mjs";import{a as N,I as L,G as y}from"./shared-DhqnD5R3.mjs";const j={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},f=e=>[...q.filter(({key:r})=>e.capabilities.has(r)).map(({appMethod:r})=>r),...e.hasVectors?[j]:[]],w=e=>f(e).length>0,k=e=>(e.emailAgents?.length??0)>0,c=e=>e.tables.some(r=>I(r)),p=e=>e.liveStreams===!0&&(e.liveStreamDeclarations?.length??0)>0,$=e=>e.hasScheduler?`
2
2
  /** Resolve the \`SchedulerDO\`-backed scheduler for this env; \`undefined\` until the namespace is wired. */
3
3
  private resolveScheduler(env: Env): ReturnType<typeof createScheduler> | undefined {
4
4
  const namespace = this.schedulerDeclaration?.namespace(env);
@@ -1,4 +1,4 @@
1
- import{G as a,d as c}from"./shared-A1XHcT4t.mjs";import{i as y}from"./schema-BgM8A3XV.mjs";const f=s=>s?`${a}/**
1
+ import{G as a,d as c}from"./shared-DhqnD5R3.mjs";import{i as y}from"./schema-BgM8A3XV.mjs";const f=s=>s?`${a}/**
2
2
  * The \`SchedulerDO\` Durable Object class, re-exported so a worker entry can
3
3
  * forward it — wrangler binds only what the entry exports:
4
4
  *
@@ -1,4 +1,4 @@
1
- import{r as k}from"./qualifiers-D1Q_3wo2.mjs";import{a as i,e as o,v as d,f as v,G as M}from"./shared-A1XHcT4t.mjs";const _="schema",w=a=>{for(const e of a.tables)i(e.name,"table name");const l=a.tables.map(e=>`"${e.name}"`).join(" | ")||"never",m=a.tables.filter(e=>e.extensionKey===void 0).map(e=>`"${e.name}"`).join(" | ")||"never",p=a.tables.map(e=>{const t=Object.entries(e.shape).map(([g,r])=>{const s=o(g);if(r.kind==="optional"){const h=r.inner?d(r.inner):"unknown";return` ${s}?: ${h};`}return` ${s}: ${d(r)};`}).join(`
1
+ import{r as k}from"./qualifiers-ClaCHu0X.mjs";import{a as i,e as o,v as d,f as v,G as M}from"./shared-DhqnD5R3.mjs";const _="schema",w=a=>{for(const e of a.tables)i(e.name,"table name");const l=a.tables.map(e=>`"${e.name}"`).join(" | ")||"never",m=a.tables.filter(e=>e.extensionKey===void 0).map(e=>`"${e.name}"`).join(" | ")||"never",p=a.tables.map(e=>{const t=Object.entries(e.shape).map(([g,r])=>{const s=o(g);if(r.kind==="optional"){const h=r.inner?d(r.inner):"unknown";return` ${s}?: ${h};`}return` ${s}: ${d(r)};`}).join(`
2
2
  `),n=t?`
3
3
  ${t}
4
4
  `:"",N=e.commitOrdered===!0?`
@@ -1,4 +1,4 @@
1
- import{SCHEMA_MODULE_PATH as c}from"./emitDataModel-LTnwnhV6.mjs";import{r as m}from"./qualifiers-D1Q_3wo2.mjs";import{G as b,a as z,d as T,v as f,u as A,g as x,c as h}from"./shared-A1XHcT4t.mjs";const d=e=>{switch(e.kind){case"array":case"object":case"record":case"union":return{builder:"text",mode:"json",notNull:!0,typeAnnotation:f(e)};case"bigint":return{builder:"blob",mode:"bigint",notNull:!0};case"boolean":return{builder:"integer",mode:"boolean",notNull:!0};case"bytes":return{builder:"blob",mode:"buffer",notNull:!0};case"date":case"timestamp":return{builder:"integer",notNull:!0};case"from":return{builder:"text",notNull:!0,typeAnnotation:f(e)};case"id":return{builder:"text",notNull:!0};case"literal":{const t=e.literalValue??"";return t.startsWith('"')||t.startsWith("'")?{builder:"text",notNull:!0}:t==="true"||t==="false"?{builder:"integer",mode:"boolean",notNull:!0}:t==="null"?{builder:"text",notNull:!0}:{builder:"real",notNull:!0}}case"null":return{builder:"text",notNull:!0};case"number":return{builder:"real",notNull:!0};case"optional":return{...e.inner?d(e.inner):{builder:"text",notNull:!1},notNull:!1};case"storage":case"string":return{builder:"text",notNull:!0};default:return{builder:"text",notNull:!0}}},N=(e,t)=>{const r=A(e);return r.kind==="id"&&r.tableName!==void 0&&t.has(r.tableName)?r.tableName:void 0},j=(e,t,r)=>{x(e,"drizzle column name");const n=d(t),o=n.mode?`, { mode: "${n.mode}" }`:"";let l=`${n.builder}("${e}"${o})`;n.typeAnnotation&&(l+=`.$type<${n.typeAnnotation}>()`);const s=N(t,r);return s!==void 0&&(l+=`.references((): AnySQLiteColumn => ${s}._id)`),n.notNull&&t.column?.notNull!==!1&&(l+=".notNull()"),l},I=e=>{const t=e.unique?"uniqueIndex":"index",r=e.fields.map(n=>(x(n,"drizzle index field"),`t.${n}`)).join(", ");return` ${h(e.name)}: ${t}(${JSON.stringify(e.name)}).on(${r}),`},S=(e,t)=>{z(e.name,"table name");const r=[' _id: text("_id").primaryKey(),',' _creationTime: integer("_creationTime").notNull(),',...Object.entries(e.shape).map(([o,l])=>` ${o}: ${j(o,l,t)},`)].join(`
1
+ import{SCHEMA_MODULE_PATH as c}from"./emitDataModel-MjAOi3KM.mjs";import{r as m}from"./qualifiers-ClaCHu0X.mjs";import{G as b,a as z,d as T,v as f,u as A,g as x,c as h}from"./shared-DhqnD5R3.mjs";const d=e=>{switch(e.kind){case"array":case"object":case"record":case"union":return{builder:"text",mode:"json",notNull:!0,typeAnnotation:f(e)};case"bigint":return{builder:"blob",mode:"bigint",notNull:!0};case"boolean":return{builder:"integer",mode:"boolean",notNull:!0};case"bytes":return{builder:"blob",mode:"buffer",notNull:!0};case"date":case"timestamp":return{builder:"integer",notNull:!0};case"from":return{builder:"text",notNull:!0,typeAnnotation:f(e)};case"id":return{builder:"text",notNull:!0};case"literal":{const t=e.literalValue??"";return t.startsWith('"')||t.startsWith("'")?{builder:"text",notNull:!0}:t==="true"||t==="false"?{builder:"integer",mode:"boolean",notNull:!0}:t==="null"?{builder:"text",notNull:!0}:{builder:"real",notNull:!0}}case"null":return{builder:"text",notNull:!0};case"number":return{builder:"real",notNull:!0};case"optional":return{...e.inner?d(e.inner):{builder:"text",notNull:!1},notNull:!1};case"storage":case"string":return{builder:"text",notNull:!0};default:return{builder:"text",notNull:!0}}},N=(e,t)=>{const r=A(e);return r.kind==="id"&&r.tableName!==void 0&&t.has(r.tableName)?r.tableName:void 0},j=(e,t,r)=>{x(e,"drizzle column name");const n=d(t),o=n.mode?`, { mode: "${n.mode}" }`:"";let l=`${n.builder}("${e}"${o})`;n.typeAnnotation&&(l+=`.$type<${n.typeAnnotation}>()`);const s=N(t,r);return s!==void 0&&(l+=`.references((): AnySQLiteColumn => ${s}._id)`),n.notNull&&t.column?.notNull!==!1&&(l+=".notNull()"),l},I=e=>{const t=e.unique?"uniqueIndex":"index",r=e.fields.map(n=>(x(n,"drizzle index field"),`t.${n}`)).join(", ");return` ${h(e.name)}: ${t}(${JSON.stringify(e.name)}).on(${r}),`},S=(e,t)=>{z(e.name,"table name");const r=[' _id: text("_id").primaryKey(),',' _creationTime: integer("_creationTime").notNull(),',...Object.entries(e.shape).map(([o,l])=>` ${o}: ${j(o,l,t)},`)].join(`
2
2
  `),n=e.indexes.length>0?`, (t) => ({
3
3
  ${e.indexes.map(o=>I(o)).join(`
4
4
  `)}
@@ -1,30 +1,30 @@
1
- import{LunoraError as L}from"@lunora/errors";import{L as pe,s as j,G as U,d as J,I as E,b as I,r as me,c as ge}from"./shared-A1XHcT4t.mjs";import{v as fe}from"./parse-validator-BisfC8bR.mjs";import{renderAgentFunctionRegistry as ye,renderSandboxFunctionRegistry as $e}from"./emitApi-GFmStqmq.mjs";import{b as we,a as Re,r as C,c as ke}from"./qualifiers-D1Q_3wo2.mjs";import{s as g}from"./dispatch-namespace-DwTjD7BU.mjs";const be=new Set(["any","bigint","boolean","date","id","null","number","storage","string","timestamp"]),B=r=>r.column!==void 0,ve=(r,t)=>{switch(r){case"bigint":return`if (typeof ${t} !== "bigint") return DEFER;
2
- `;case"boolean":return`if (typeof ${t} !== "boolean") return DEFER;
3
- `;case"date":case"number":case"timestamp":return`if (typeof ${t} !== "number" || !Number.isFinite(${t})) return DEFER;
4
- `;case"null":return`if (${t} !== null) return DEFER;
5
- `;default:return`if (typeof ${t} !== "string") return DEFER;
6
- `}},Ne=(r,t)=>r.stringMaxLength===void 0?"":`if (${t}.length > ${String(r.stringMaxLength)}) return DEFER;
7
- `,Oe=(r,t)=>{const n=r.literalValue?.trim();if(!(n===void 0||!pe.test(n)))return{out:t,pre:`if (${t} !== ${n}) return DEFER;
8
- `}},_=(r,t,n)=>{if(!B(r)&&!(r.unmodelledRefinement||r.sourceText!==void 0)){if(be.has(r.kind))return r.kind==="any"?{out:t,pre:""}:{out:t,pre:ve(r.kind,t)+Ne(r,t)};switch(r.kind){case"array":return Se(r,t,n);case"literal":return Oe(r,t);case"object":return Ae(r,t,n);default:return}}},Se=(r,t,n)=>{const{inner:o}=r;if(!o)return;const a=n.next(),i=`__arr${String(a)}`,s=`__i${String(a)}`,c=`__e${String(a)}`,u=_(o,c,n);if(!u)return;const l=`if (!Array.isArray(${t})) return DEFER;
9
- const ${i} = new Array(${t}.length);
10
- for (let ${s} = 0; ${s} < ${t}.length; ${s}++) {
11
- const ${c} = ${t}[${s}];
12
- ${u.pre}${i}[${s}] = ${u.out};
1
+ import{LunoraError as L}from"@lunora/errors";import{L as pe,i as me,G as U,d as J,I as F,s as ge,b as C,r as fe,c as ye}from"./shared-DhqnD5R3.mjs";import{v as $e}from"./parse-validator-BisfC8bR.mjs";import{renderAgentFunctionRegistry as we,renderSandboxFunctionRegistry as Re}from"./emitApi-DWJW8Vu9.mjs";import{b as ke,a as be,r as j,c as Ne}from"./qualifiers-ClaCHu0X.mjs";import{s as g}from"./dispatch-namespace-DwTjD7BU.mjs";const ve=new Set(["any","bigint","boolean","date","id","null","number","storage","string","timestamp"]),B=t=>t.column!==void 0,Oe=(t,r)=>{switch(t){case"bigint":return`if (typeof ${r} !== "bigint") return DEFER;
2
+ `;case"boolean":return`if (typeof ${r} !== "boolean") return DEFER;
3
+ `;case"date":case"number":case"timestamp":return`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return DEFER;
4
+ `;case"null":return`if (${r} !== null) return DEFER;
5
+ `;default:return`if (typeof ${r} !== "string") return DEFER;
6
+ `}},Se=(t,r)=>t.stringMaxLength===void 0?"":`if (${r}.length > ${String(t.stringMaxLength)}) return DEFER;
7
+ `,Pe=(t,r)=>{const n=t.literalValue?.trim();if(!(n===void 0||!pe.test(n)))return{out:r,pre:`if (${r} !== ${n}) return DEFER;
8
+ `}},E=(t,r,n)=>{if(!B(t)&&!(t.unmodelledRefinement||t.sourceText!==void 0)){if(ve.has(t.kind))return t.kind==="any"?{out:r,pre:""}:{out:r,pre:Oe(t.kind,r)+Se(t,r)};switch(t.kind){case"array":return xe(t,r,n);case"literal":return Pe(t,r);case"object":return Te(t,r,n);default:return}}},xe=(t,r,n)=>{const{inner:o}=t;if(!o)return;const s=n.next(),i=`__arr${String(s)}`,a=`__i${String(s)}`,c=`__e${String(s)}`,u=E(o,c,n);if(!u)return;const l=`if (!Array.isArray(${r})) return DEFER;
9
+ const ${i} = new Array(${r}.length);
10
+ for (let ${a} = 0; ${a} < ${r}.length; ${a}++) {
11
+ const ${c} = ${r}[${a}];
12
+ ${u.pre}${i}[${a}] = ${u.out};
13
13
  }
14
- `;return{out:i,pre:l}},Pe=(r,t,n,o)=>{const a=JSON.stringify(r);if(t.kind==="optional"){if(t.hasRefinement||t.sourceText!==void 0||B(t))return;const{inner:s}=t;if(!s)return;const c=_(s,n,o);if(!c)return;const u=o.next(),l=`__has${String(u)}`,d=`__val${String(u)}`,f=`let ${l} = false;
14
+ `;return{out:i,pre:l}},Ae=(t,r,n,o)=>{const s=JSON.stringify(t);if(r.kind==="optional"){if(r.hasRefinement||r.sourceText!==void 0||B(r))return;const{inner:a}=r;if(!a)return;const c=E(a,n,o);if(!c)return;const u=o.next(),l=`__has${String(u)}`,d=`__val${String(u)}`,f=`let ${l} = false;
15
15
  let ${d};
16
16
  if (${n} !== undefined) {
17
17
  ${c.pre}${d} = ${c.out};
18
18
  ${l} = true;
19
19
  }
20
- `;return{entry:`...(${l} ? { ${a}: ${d} } : {})`,pre:f}}const i=_(t,n,o);if(i)return{entry:`${a}: ${i.out}`,pre:i.pre}},xe=new Set(Object.getOwnPropertyNames(Object.prototype)),q=(r,t,n)=>{let o="";const a=[];for(const i of Object.keys(r)){const s=r[i];if(!s)return;const c=JSON.stringify(i);let u=`${t}[${c}]`;if(xe.has(i)){const d=`__f${String(n.next())}`;o+=`const ${d} = Object.hasOwn(${t}, ${c}) ? ${t}[${c}] : undefined;
21
- `,u=d}const l=Pe(i,s,u,n);if(!l)return;o+=l.pre,a.push(l.entry)}return{entries:a.join(", "),pre:o}},H=r=>{const t=`Object.getPrototypeOf(${r})`;return`if (${t} !== Object.prototype && ${t} !== null) return DEFER;
22
- `},Ae=(r,t,n)=>{const o=r.shape??{},a=q(o,t,n);if(!a)return;const i=n.next(),s=`__obj${String(i)}`,c=`if (typeof ${t} !== "object" || ${t} === null || Array.isArray(${t})) return DEFER;
23
- ${H(t)}${a.pre}const ${s} = { ${a.entries} };
24
- `;return{out:s,pre:c}},z=r=>{let t=0;const o=q(r,"source",{next:()=>(t+=1,t)});if(o)return`(source) => {
20
+ `;return{entry:`...(${l} ? { ${s}: ${d} } : {})`,pre:f}}const i=E(r,n,o);if(i)return{entry:`${s}: ${i.out}`,pre:i.pre}},Le=new Set(Object.getOwnPropertyNames(Object.prototype)),q=(t,r,n)=>{let o="";const s=[];for(const i of Object.keys(t)){const a=t[i];if(!a)return;const c=JSON.stringify(i);let u=`${r}[${c}]`;if(Le.has(i)){const d=`__f${String(n.next())}`;o+=`const ${d} = Object.hasOwn(${r}, ${c}) ? ${r}[${c}] : undefined;
21
+ `,u=d}const l=Ae(i,a,u,n);if(!l)return;o+=l.pre,s.push(l.entry)}return{entries:s.join(", "),pre:o}},H=t=>{const r=`Object.getPrototypeOf(${t})`;return`if (${r} !== Object.prototype && ${r} !== null) return DEFER;
22
+ `},Te=(t,r,n)=>{const o=t.shape??{},s=q(o,r,n);if(!s)return;const i=n.next(),a=`__obj${String(i)}`,c=`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) return DEFER;
23
+ ${H(r)}${s.pre}const ${a} = { ${s.entries} };
24
+ `;return{out:a,pre:c}},z=t=>{let r=0;const o=q(t,"source",{next:()=>(r+=1,r)});if(o)return`(source) => {
25
25
  if (typeof source !== "object" || source === null || Array.isArray(source)) return DEFER;
26
26
  ${H("source")}${o.pre}return { ${o.entries} };
27
- }`},Le=(r,t)=>`lunora_${g(r)}_${String(t)}`,D=r=>JSON.stringify(Object.entries(r).toSorted(([t],[n])=>t.localeCompare(n)).map(([t,n])=>{const o=n.kind==="optional",a=o?n.inner??{kind:"unknown"}:n,i=a.kind==="array"?a.inner?.kind:void 0,s=a.kind==="id"?a.tableName:void 0;return{kind:a.kind,name:t,optional:o,...fe(n)?{sensitive:!0}:{},...s===void 0?{}:{table:s},...i===void 0||i==="unknown"?{}:{element:i}}})),W=(r,t,n,o)=>{const a=new Map,i=s=>{a.has(s)||a.set(s,Le(s,a.size))};for(const s of r)i(s.filePath);for(const s of t)i(s.filePath);for(const s of n)i(s.filePath);for(const s of o)i(s.filePath);return a},Q=(r,t,n)=>new Set([...r.map(o=>o.filePath),...t.map(o=>o.filePath),...n.map(o=>o.filePath)]),S=r=>`${r}[functionPath]`,Te=`const callRegistered = async <R>(context: CallerCtx, functionPath: string, args: Record<string, unknown> | undefined): Promise<R> => {
27
+ }`},Fe=(t,r)=>`lunora_${g(t)}_${String(r)}`,D=t=>JSON.stringify(Object.entries(t).toSorted(([r],[n])=>r.localeCompare(n)).map(([r,n])=>{const o=n.kind==="optional",s=o?n.inner??{kind:"unknown"}:n,i=s.kind==="array"?s.inner?.kind:void 0,a=s.kind==="id"?s.tableName:void 0;return{kind:s.kind,name:r,optional:o,...$e(n)?{sensitive:!0}:{},...a===void 0?{}:{table:a},...i===void 0||i==="unknown"?{}:{element:i}}})),W=(t,r,n,o)=>{const s=new Map,i=a=>{s.has(a)||s.set(a,Fe(a,s.size))};for(const a of t)i(a.filePath);for(const a of r)i(a.filePath);for(const a of n)i(a.filePath);for(const a of o)i(a.filePath);return s},Q=(t,r,n,o)=>new Set([...t.filter(s=>s.typeDerivedArgs).map(s=>s.filePath),...r.map(s=>s.filePath),...n.map(s=>s.filePath),...o.map(s=>s.filePath)]),_=t=>Array.isArray(t)?`Object.freeze([${t.map(r=>_(r)).join(", ")}])`:t!==null&&typeof t=="object"?`Object.freeze({ ${Object.entries(t).map(([n,o])=>`${JSON.stringify(n)}: ${_(o)}`).join(", ")} })`:typeof t=="number"&&(!Number.isFinite(t)||Object.is(t,-0))?Object.is(t,-0)?"-0":String(t):JSON.stringify(t),S=t=>`${t}[functionPath]`,Ee=`const callRegistered = async <R>(context: CallerCtx, functionPath: string, args: Record<string, unknown> | undefined): Promise<R> => {
28
28
  const registered = await loadFunction(functionPath);
29
29
 
30
30
  if (!registered) {
@@ -57,16 +57,16 @@ ${H("source")}${o.pre}return { ${o.entries} };
57
57
  }
58
58
 
59
59
  return (await registered.handler(context, args ?? {})) as R;
60
- };`,Ee=(r,t,n=[],o=[],a=!1)=>{const i=W(r,t,n,o),s=Q(t,n,o),c=[...i.entries()].filter(([e])=>!a||s.has(e)?!0:r.some(m=>m.filePath===e&&m.channel?.kind==="room")).map(([e,m])=>{if(!E.test(e))throw new L("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(e)}`);return`import ${a&&!s.has(e)?"type ":""}* as ${m} from "../${e}.js";`}).join(`
61
- `),u=r.map(e=>{if(!a||s.has(e.filePath))return` "${g(e.filePath)}:${e.exportName}": ${i.get(e.filePath)??""}.${e.exportName} as unknown as RegisteredLunoraFunction,`;const m=j(e.args);return` "${g(e.filePath)}:${e.exportName}": { args: {}, handler: unloadedFunctionHandler, ...${JSON.stringify({argumentDescriptors:JSON.parse(D(e.args)),kind:e.kind,...m.length===0?{}:{sensitiveArgs:m},...e.channel?{channel:e.channel}:{},...e.expose?{expose:e.expose}:{},...e.lifecycle?{lifecycle:e.lifecycle}:{},...e.visibility?{visibility:e.visibility}:{},...e.x402?.price===void 0?{}:{x402:{price:e.x402.price}},...e.socket===void 0?{}:{auth:e.socket.auth,socketPath:e.socket.path}})} } satisfies RegisteredLunoraFunction & Pick<FunctionManifestEntry, "argumentDescriptors" | "channel" | "expose">,`}).join(`
62
- `),l=t.map(e=>` ${JSON.stringify(e.id)}: ${i.get(e.filePath)??""}.${e.exportName} as unknown as RegisteredDataMigration,`).join(`
60
+ };`,_e=(t,r,n=[],o=[],s=!1)=>{const i=W(t,r,n,o),a=Q(t,r,n,o),c=[...i.entries()].filter(([e])=>!s||a.has(e)?!0:t.some(m=>m.filePath===e&&m.channel?.kind==="room")).map(([e,m])=>{if(!F.test(e))throw new L("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(e)}`);return`import ${s&&!a.has(e)?"type ":""}* as ${m} from "../${e}.js";`}).join(`
61
+ `),u=t.map(e=>{if(!s||a.has(e.filePath))return` "${g(e.filePath)}:${e.exportName}": ${i.get(e.filePath)??""}.${e.exportName} as unknown as RegisteredLunoraFunction,`;const m=ge(e.args);return` "${g(e.filePath)}:${e.exportName}": { args: {}, handler: unloadedFunctionHandler, ...${JSON.stringify({argumentDescriptors:JSON.parse(D(e.args)),kind:e.kind,...m.length===0?{}:{sensitiveArgs:m},...e.channel?{channel:e.channel}:{},...e.expose?{expose:e.expose}:{},...e.lifecycle?{lifecycle:e.lifecycle}:{},...e.visibility?{visibility:e.visibility}:{},...e.x402?.price===void 0?{}:{x402:{price:e.x402.price}},...e.socket===void 0?{}:{auth:e.socket.auth,socketPath:e.socket.path}})}${e.meta===void 0?"":`, [Symbol.for("lunora.procedure.meta")]: ${_(e.meta)}`} } satisfies RegisteredLunoraFunction & Pick<FunctionManifestEntry, "argumentDescriptors" | "channel" | "expose">,`}).join(`
62
+ `),l=r.map(e=>` ${JSON.stringify(e.id)}: ${i.get(e.filePath)??""}.${e.exportName} as unknown as RegisteredDataMigration,`).join(`
63
63
  `),d=n.map(e=>` "${g(e.filePath)}:${e.exportName}": ${i.get(e.filePath)??""}.${e.exportName} as unknown as RegisteredLunoraFunction,`).join(`
64
64
  `),f=o.map(e=>` "${e.exportName}": ${i.get(e.filePath)??""}.${e.exportName} as unknown as RegisteredShape,`).join(`
65
- `),y=n.map(e=>`${g(e.filePath)}:${e.exportName}`),$=[...r.filter(e=>e.readsIp===!0).map(e=>`${g(e.filePath)}:${e.exportName}`),...o.filter(e=>e.readsIp===!0).map(e=>e.exportName)],R=[u,d].filter(e=>e.length>0).join(`
66
- `),P=r.filter(e=>!a||s.has(e.filePath)).map(e=>{if(e.lifecycle||Object.keys(e.args).length===0)return;const m=z(e.args);return m===void 0?void 0:`installCompiledValidatorMap(${i.get(e.filePath)??""}.${e.exportName}.args, ${m});`}).filter(e=>e!==void 0).join(`
67
- `),x=r.filter(e=>e.channel?.kind==="room").map(e=>` ${JSON.stringify(e.channel?.name??"")}: RoomMessageOf<typeof ${i.get(e.filePath)??""}[${JSON.stringify(e.exportName)}]>;`).join(`
68
- `),v=[...r.map(e=>({args:e.args,definition:e,path:`${g(e.filePath)}:${e.exportName}`})),...n.map(e=>({args:e.args,definition:{...e,expose:void 0,kind:"mutation",lifecycle:void 0,visibility:void 0,x402:void 0},path:`${g(e.filePath)}:${e.exportName}`}))],N=a?v.filter(({definition:e})=>!s.has(e.filePath)):[];for(const{definition:e}of v)if(a&&e.x402&&e.x402.price===void 0)throw new L("INTERNAL",`@lunora/codegen: lazy function registry needs a literal \`.x402({ price })\` value in ${e.filePath}:${e.exportName}`);const p=a?N.map(({definition:e,path:m})=>{const k=i.get(e.filePath)??"",A="channel"in e?e.channel:void 0,b={argumentDescriptors:JSON.parse(D(e.args)),exportName:e.exportName,kind:e.kind,moduleId:k,...A?{channel:A}:{},...e.expose?{expose:e.expose}:{},...e.lifecycle?{lifecycle:e.lifecycle}:{},...e.visibility?{visibility:e.visibility}:{},...e.x402?.price===void 0?{}:{x402:{price:e.x402.price}}};return` ${JSON.stringify(m)}: ${JSON.stringify(b)},`}).join(`
69
- `):"",w=[...new Set(N.map(({definition:e})=>e.filePath))],O=a?w.map(e=>{if(!E.test(e))throw new L("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(e)}`);const m=i.get(e)??"";return` ${JSON.stringify(m)}: () => import(${JSON.stringify(`./fn/${m}.js`)}),`}).join(`
65
+ `),y=n.map(e=>`${g(e.filePath)}:${e.exportName}`),$=[...t.filter(e=>e.readsIp===!0).map(e=>`${g(e.filePath)}:${e.exportName}`),...o.filter(e=>e.readsIp===!0).map(e=>e.exportName)],R=[u,d].filter(e=>e.length>0).join(`
66
+ `),P=t.filter(e=>!s||a.has(e.filePath)).map(e=>{if(e.lifecycle||e.typeDerivedArgs||Object.keys(e.args).length===0)return;const m=z(e.args);return m===void 0?void 0:`installCompiledValidatorMap(${i.get(e.filePath)??""}.${e.exportName}.args, ${m});`}).filter(e=>e!==void 0).join(`
67
+ `),x=t.filter(e=>e.channel?.kind==="room").map(e=>` ${JSON.stringify(e.channel?.name??"")}: RoomMessageOf<typeof ${i.get(e.filePath)??""}[${JSON.stringify(e.exportName)}]>;`).join(`
68
+ `),N=[...t.map(e=>({args:e.args,definition:e,path:`${g(e.filePath)}:${e.exportName}`})),...n.map(e=>({args:e.args,definition:{...e,expose:void 0,kind:"mutation",lifecycle:void 0,visibility:void 0,x402:void 0},path:`${g(e.filePath)}:${e.exportName}`}))],v=s?N.filter(({definition:e})=>!a.has(e.filePath)):[];for(const{definition:e}of N)if(s&&e.x402&&e.x402.price===void 0)throw new L("INTERNAL",`@lunora/codegen: lazy function registry needs a literal \`.x402({ price })\` value in ${e.filePath}:${e.exportName}`);const p=s?v.map(({definition:e,path:m})=>{const k=i.get(e.filePath)??"",A="channel"in e?e.channel:void 0,b={argumentDescriptors:JSON.parse(D(e.args)),exportName:e.exportName,kind:e.kind,moduleId:k,...A?{channel:A}:{},...e.expose?{expose:e.expose}:{},...e.lifecycle?{lifecycle:e.lifecycle}:{},...e.visibility?{visibility:e.visibility}:{},...e.x402?.price===void 0?{}:{x402:{price:e.x402.price}}};return` ${JSON.stringify(m)}: ${JSON.stringify(b)},`}).join(`
69
+ `):"",w=[...new Set(v.map(({definition:e})=>e.filePath))],O=s?w.map(e=>{if(!F.test(e))throw new L("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(e)}`);const m=i.get(e)??"";return` ${JSON.stringify(m)}: () => import(${JSON.stringify(`./fn/${m}.js`)}),`}).join(`
70
70
  `):"";return{dispatchBody:R.length>0?`
71
71
  ${R}
72
72
  `:"",importBlock:c.length>0?`${c}
@@ -79,7 +79,7 @@ ${l}
79
79
  ${O}
80
80
  `:"",ipReaderPaths:$,mutatorPaths:y,roomMessagesBody:x,shapeBody:f.length>0?`
81
81
  ${f}
82
- `:""}},_e=r=>{const t=I(r,o=>{const a=C(me(o.args),o.filePath),i=a==="{}"?"?":"",s=C(ke(o),o.filePath);return o.kind==="stream"?`${o.exportName}: (args${i}: ${a}) => Promise<AsyncIterable<${s}>>;`:`${o.exportName}: (args${i}: ${a}) => Promise<${s}>;`},"type");return{implementation:I(r,o=>`${ge(o.exportName)}: (args) => callRegistered(context, "${g(o.filePath)}:${o.exportName}", args),`,"value"),types:t}},Fe=r=>{const t={connect:[],disconnect:[],init:[],reactor:[],whisper:[]};for(const n of r)!n.lifecycle||n.lifecycle==="socket"||t[n.lifecycle].push(`${g(n.filePath)}:${n.exportName}`);return t},Me=r=>{const t=new Map,n=[];for(const o of r){if(o.lifecycle!=="socket"||o.socket===void 0)continue;const{auth:a,origin:i,path:s}=o.socket,c=`${g(o.filePath)}:${o.exportName}`,u=t.get(s);if(!(u?.origin!==void 0&&u.origin===i)){if(u!==void 0)throw new L("DUPLICATE_SOCKET_PATH",`two defineWebSocket routes serve "${s}" (${u.functionPath} and ${c}); socket paths must be unique.`);t.set(s,{functionPath:c,origin:i}),n.push(` ${JSON.stringify(s)}: { auth: ${String(a)}, functionPath: ${JSON.stringify(c)} },`)}}return`
82
+ `:""}},Me=t=>{const r=C(t,o=>{const s=j(fe(o.args),o.filePath),i=s==="{}"?"?":"",a=j(Ne(o),o.filePath);return o.kind==="stream"?`${o.exportName}: (args${i}: ${s}) => Promise<AsyncIterable<${a}>>;`:`${o.exportName}: (args${i}: ${s}) => Promise<${a}>;`},"type");return{implementation:C(t,o=>`${ye(o.exportName)}: (args) => callRegistered(context, "${g(o.filePath)}:${o.exportName}", args),`,"value"),types:r}},Ie=t=>{const r={connect:[],disconnect:[],init:[],reactor:[],whisper:[]};for(const n of t)!n.lifecycle||n.lifecycle==="socket"||r[n.lifecycle].push(`${g(n.filePath)}:${n.exportName}`);return r},Ce=t=>{const r=new Map,n=[];for(const o of t){if(o.lifecycle!=="socket"||o.socket===void 0)continue;const{auth:s,origin:i,path:a}=o.socket,c=`${g(o.filePath)}:${o.exportName}`,u=r.get(a);if(!(u?.origin!==void 0&&u.origin===i)){if(u!==void 0)throw new L("DUPLICATE_SOCKET_PATH",`two defineWebSocket routes serve "${a}" (${u.functionPath} and ${c}); socket paths must be unique.`);r.set(a,{functionPath:c,origin:i}),n.push(` ${JSON.stringify(a)}: { auth: ${String(s)}, functionPath: ${JSON.stringify(c)} },`)}}return`
83
83
  /**
84
84
  * Socket registry: the URL path of each \`defineWebSocket\` route → its function path + auth requirement.
85
85
  * Static, so building the worker never evaluates a route's module. The generated ShardDO's \`socketRoute\` override
@@ -89,7 +89,7 @@ export const LUNORA_SOCKETS: Readonly<Record<string, { auth: boolean; functionPa
89
89
  ${n.join(`
90
90
  `)}
91
91
  };
92
- `},Ie=(r,t)=>{const n=r.some(c=>c.lifecycle==="socket"),a=n&&t?Me(r):n&&!t?`
92
+ `},je=(t,r)=>{const n=t.some(c=>c.lifecycle==="socket"),s=n&&r?Ce(t):n&&!r?`
93
93
  /**
94
94
  * Socket registry: the URL path of each \`defineWebSocket\` route → its function
95
95
  * path + auth requirement. The generated ShardDO's \`socketRoute\` override
@@ -133,7 +133,7 @@ export const LUNORA_SOCKETS: Readonly<Record<string, { auth: boolean; functionPa
133
133
  * Set on a \`defineWebSocket\` registration: whether the route refuses an
134
134
  * anonymous upgrade. Read into \`LUNORA_SOCKETS\` alongside \`socketPath\`.
135
135
  */
136
- auth?: boolean;`:"",lifecycleMember:n?' | "socket"':"",registry:a}},Ce=(r,t,n)=>r?{channelField:` /**
136
+ auth?: boolean;`:"",lifecycleMember:n?' | "socket"':"",registry:s}},De=(t,r,n)=>t?{channelField:` /**
137
137
  * Set on a \`defineRoom\` registration: the room's name (without the \`room:\`
138
138
  * topic prefix). The generated \`LUNORA_ROOMS\` map keys it on the room's
139
139
  * \`room:<name>\` whisper topic so the ShardDO resolves a room topic to this
@@ -147,8 +147,8 @@ export const LUNORA_SOCKETS: Readonly<Record<string, { auth: boolean; functionPa
147
147
  export type LunoraRoomMessages = {
148
148
  ${n}
149
149
  };
150
- `,typeImport:`import type { RoomMessageOf } from "${t}";
151
- `}:{channelField:"",messagesBlock:"",typeImport:""},De=(r,t,n)=>r?t?`
150
+ `,typeImport:`import type { RoomMessageOf } from "${r}";
151
+ `}:{channelField:"",messagesBlock:"",typeImport:""},Ue=(t,r,n)=>t?r?`
152
152
  /**
153
153
  * Room routes are static metadata so building the worker never evaluates user handlers.
154
154
  */
@@ -208,14 +208,14 @@ export const LUNORA_ROOMS: Readonly<Record<string, string>> = (() => {
208
208
 
209
209
  return registry;
210
210
  })();
211
- `:"",je=(r,t)=>{const n=_e(r),o=n.types?`
211
+ `:"",Je=(t,r)=>{const n=Me(t),o=n.types?`
212
212
  ${n.types}
213
- `:"",a=n.implementation?`
213
+ `:"",s=n.implementation?`
214
214
  ${n.implementation}
215
- `:"",i=Re(n.types),s=i.length>0?`import type { ${i.join(", ")} } from "./dataModel.js";
216
- `:"",c=r.length>0?"context":"_context";let u="";if(r.length>0){let l=Te;t||(l=l.replace("await loadFunction(functionPath)",S("LUNORA_FUNCTIONS"))),u=`${l}
215
+ `:"",i=be(n.types),a=i.length>0?`import type { ${i.join(", ")} } from "./dataModel.js";
216
+ `:"",c=t.length>0?"context":"_context";let u="";if(t.length>0){let l=Ee;r||(l=l.replace("await loadFunction(functionPath)",S("LUNORA_FUNCTIONS"))),u=`${l}
217
217
 
218
- `}return{callRegisteredHelper:u,dataModelImport:s,implementation:a,parameter:c,types:o}},We=r=>{const{agents:t=[],functions:n,lazyFunctions:o=!1,migrations:a=[],mutators:i=[],shapes:s=[],useUmbrella:c=!1,usesSandbox:u=!1}=r,l=J(c),{dispatchBody:d,importBlock:f,installBlock:y,ipReaderPaths:$,manifestBody:R,migrationBody:P,moduleLoaders:x,mutatorPaths:v,roomMessagesBody:N,shapeBody:p}=Ee(n,a,i,s,o),w=ye(t,n),O=$e(u,n),m=t.length>0||n.some(h=>j(h.args).length>0)?` /**
218
+ `}return{callRegisteredHelper:u,dataModelImport:a,implementation:s,parameter:c,types:o}},Ge=t=>{const{agents:r=[],functions:n,lazyFunctions:o=!1,migrations:s=[],mutators:i=[],shapes:a=[],useUmbrella:c=!1,usesSandbox:u=!1}=t,l=J(c),{dispatchBody:d,importBlock:f,installBlock:y,ipReaderPaths:$,manifestBody:R,migrationBody:P,moduleLoaders:x,mutatorPaths:N,roomMessagesBody:v,shapeBody:p}=_e(n,s,i,a,o),w=we(r,n),O=Re(u,n),m=r.length>0||n.some(h=>me(h))?` /**
219
219
  * Names of the arguments whose validators carry a \`v.sensitive\` marker. Read by the
220
220
  * shard before any validator is loaded, so a lazy function's secret args are
221
221
  * masked even on a dispatch that fails before its module evaluates.
@@ -226,12 +226,12 @@ ${n.implementation}
226
226
  ${k}
227
227
  `:`
228
228
  ${k}
229
- `);const b=Fe(n),G=o?"await loadFunction(functionPath)":S("LUNORA_FUNCTIONS"),V=o?` if (${S("LUNORA_FUNCTION_MANIFEST")}?.visibility === "internal") {
229
+ `);const b=Ie(n),G=o?"await loadFunction(functionPath)":S("LUNORA_FUNCTIONS"),V=o?` if (${S("LUNORA_FUNCTION_MANIFEST")}?.visibility === "internal") {
230
230
  throw new LunoraError("FUNCTION_NOT_FOUND", \`function not registered: \${functionPath}\`);
231
231
  }
232
232
 
233
- `:"",K=s.length>0?`import type { RegisteredShape } from "${l.server}";
234
- `:"",F=n.some(h=>h.channel?.kind==="room"),T=Ce(F,l.server,N),Y=s.length>0?`
233
+ `:"",K=a.length>0?`import type { RegisteredShape } from "${l.server}";
234
+ `:"",M=n.some(h=>h.channel?.kind==="room"),T=De(M,l.server,v),Y=a.length>0?`
235
235
  /**
236
236
  * Replication-shape registry — one entry per \`defineShape\` in \`lunora/shapes.ts\`.
237
237
  * The generated ShardDO's \`resolveShape\` override looks a shape up by name and
@@ -239,13 +239,13 @@ ${k}
239
239
  * \`shape_subscribe\` (reads-as-permissions).
240
240
  */
241
241
  export const LUNORA_SHAPES: Record<string, RegisteredShape> = {${p}};
242
- `:"",Z=v.length>0?`
242
+ `:"",Z=N.length>0?`
243
243
  /**
244
244
  * Custom-mutator function paths — the \`LUNORA_FUNCTIONS\` keys the generated
245
245
  * ShardDO's \`isCustomMutator\` override routes through the client-watermark push
246
246
  * protocol (\`x-lunora-client-id\`/\`x-lunora-client-seq\` ordering).
247
247
  */
248
- export const LUNORA_MUTATOR_PATHS: ReadonlySet<string> = new Set([${v.map(h=>JSON.stringify(h)).join(", ")}]);
248
+ export const LUNORA_MUTATOR_PATHS: ReadonlySet<string> = new Set([${N.map(h=>JSON.stringify(h)).join(", ")}]);
249
249
  `:"",X=$.length>0?`
250
250
  /**
251
251
  * Queries and shapes that may read \`ctx.ip\`, decided statically (failing closed). The generated ShardDO marks them
@@ -253,7 +253,7 @@ export const LUNORA_MUTATOR_PATHS: ReadonlySet<string> = new Set([${v.map(h=>JSO
253
253
  * was read at, which a claims fingerprint leaves out.
254
254
  */
255
255
  export const LUNORA_IP_READER_PATHS: ReadonlySet<string> = new Set([${$.map(h=>JSON.stringify(h)).join(", ")}]);
256
- `:"",ee=De(F,o,n),{fields:te,lifecycleMember:M,registry:re}=Ie(n,o),ne=y.length>0?`import { DEFER_VALIDATION as DEFER, installCompiledValidatorMap } from "${l.values}";
256
+ `:"",ee=Ue(M,o,n),{fields:te,lifecycleMember:I,registry:re}=je(n,o),ne=y.length>0?`import { DEFER_VALIDATION as DEFER, installCompiledValidatorMap } from "${l.values}";
257
257
  `:"",oe=y.length>0?`
258
258
  /**
259
259
  * AOT-compiled argument validators (Worker-safe, no \`eval\`). Each is installed
@@ -261,14 +261,14 @@ export const LUNORA_IP_READER_PATHS: ReadonlySet<string> = new Set([${$.map(h=>J
261
261
  * parser as a zero-allocation fast path; anything it can't model is deferred.
262
262
  */
263
263
  ${y}
264
- `:"",se=je(n,o),{callRegisteredHelper:ae,dataModelImport:ie,implementation:ce,parameter:le,types:de}=se,ue=o?`
264
+ `:"",se=Je(n,o),{callRegisteredHelper:ae,dataModelImport:ie,implementation:ce,parameter:le,types:de}=se,ue=o?`
265
265
  export interface FunctionManifestEntry {
266
266
  argumentDescriptors: ReadonlyArray<{ element?: string; kind: string; name: string; optional: boolean; table?: string }>;
267
267
  channel?: { kind: "room"; name: string };
268
268
  exportName: string;
269
269
  expose?: { cache?: { credentialHeaders?: ReadonlyArray<string>; maxAge?: number; scope?: "private" | "public"; staleWhileRevalidate?: number; tag?: string; vary?: string }; rest?: boolean };
270
270
  kind: "action" | "mutation" | "query" | "stream";
271
- lifecycle?: "connect" | "disconnect" | "init" | "reactor" | "whisper"${M};
271
+ lifecycle?: "connect" | "disconnect" | "init" | "reactor" | "whisper"${I};
272
272
  moduleId: string;
273
273
  visibility?: "internal" | "public";
274
274
  x402?: { readonly price: number | string };
@@ -372,7 +372,7 @@ export const loadAllFunctions = async (): Promise<{ checked: number; failures: R
372
372
 
373
373
  return { checked: functionPaths.length, failures };
374
374
  };
375
- `:"";return we(`${U}${f}${w.importLine}${O.importLine}${ne}${K}${T.typeImport}import { LunoraError } from "${l.server}";
375
+ `:"";return ke(`${U}${f}${w.importLine}${O.importLine}${ne}${K}${T.typeImport}import { LunoraError } from "${l.server}";
376
376
  import type { ActionCtx, MutationCtx, QueryCtx } from "./server.js";
377
377
  ${ie}
378
378
  /**
@@ -403,7 +403,7 @@ export interface RegisteredLunoraFunction {
403
403
  * \`init\` and \`reactor\` have no caller identity, so RLS has no user to scope
404
404
  * to. \`whisper\` does have one — it runs under the asking socket's identity.
405
405
  */
406
- lifecycle?: "connect" | "disconnect" | "init" | "reactor" | "whisper"${M};${te}
406
+ lifecycle?: "connect" | "disconnect" | "init" | "reactor" | "whisper"${I};${te}
407
407
  ${T.channelField} /**
408
408
  * Hoisted by the builder when the \`.use()\` chain carries a step with a
409
409
  * per-dispatch effect — \`rateLimit(...)\` consuming budget, a single-use
@@ -502,12 +502,12 @@ export interface RegisteredDataMigration {
502
502
  * shard DO's admin RPC and the CLI resolve migrations to run through this map.
503
503
  */
504
504
  export const LUNORA_MIGRATIONS: Record<string, RegisteredDataMigration> = {${P}};
505
- `,c)},Qe="fn",Ge=r=>{if(r.lazyFunctions!==!0)return{};const{functions:t}=r,n=r.migrations??[],o=r.mutators??[],a=r.shapes??[],i=W(t,n,o,a),s=Q(n,o,a),c=[...new Set(t.filter(d=>!s.has(d.filePath)).map(d=>d.filePath))],u=J(r.useUmbrella??!1),l={};for(const d of c){if(!E.test(d))throw new L("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(d)}`);const f=i.get(d)??"",y=`../../${d}.js`,$=t.filter(p=>p.filePath===d&&!p.lifecycle&&Object.keys(p.args).length>0).flatMap(p=>{const w=z(p.args);return w===void 0?[]:[`installCompiledValidatorMap(${f}.${p.exportName}.args, ${w});`]}),R=$.length>0?`import { DEFER_VALIDATION as DEFER, installCompiledValidatorMap } from "${u.values}";
505
+ `,c)},Ve="fn",Ke=t=>{if(t.lazyFunctions!==!0)return{};const{functions:r}=t,n=t.migrations??[],o=t.mutators??[],s=t.shapes??[],i=W(r,n,o,s),a=Q(r,n,o,s),c=[...new Set(r.filter(d=>!a.has(d.filePath)).map(d=>d.filePath))],u=J(t.useUmbrella??!1),l={};for(const d of c){if(!F.test(d))throw new L("INTERNAL",`@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(d)}`);const f=i.get(d)??"",y=`../../${d}.js`,$=r.filter(p=>p.filePath===d&&!p.lifecycle&&Object.keys(p.args).length>0).flatMap(p=>{const w=z(p.args);return w===void 0?[]:[`installCompiledValidatorMap(${f}.${p.exportName}.args, ${w});`]}),R=$.length>0?`import { DEFER_VALIDATION as DEFER, installCompiledValidatorMap } from "${u.values}";
506
506
  `:"",P=$.length>0?`import * as ${f} from "${y}";
507
507
  `:"",x=$.length>0?`
508
508
  /** Install the precompiled argument parsers before the module is dispatched. */
509
509
  ${$.join(`
510
510
  `)}
511
- `:"",N=t.some(p=>p.filePath===d&&p.exportName==="default")||n.some(p=>p.filePath===d&&p.exportName==="default")?`export { default } from "${y}";
511
+ `:"",v=r.some(p=>p.filePath===d&&p.exportName==="default")||n.some(p=>p.filePath===d&&p.exportName==="default")?`export { default } from "${y}";
512
512
  `:"";l[`${f}.ts`]=`${U}${R}${P}${x}export * from "${y}";
513
- ${N}`}return l};export{Qe as LAZY_FUNCTION_DIRECTORY,We as emitFunctions,Ge as emitLazyFunctionModules};
513
+ ${v}`}return l};export{Ve as LAZY_FUNCTION_DIRECTORY,Ge as emitFunctions,Ke as emitLazyFunctionModules};
@@ -1 +1 @@
1
- import"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{e}from"./server-D69SOfX8.mjs";import"./shared-A1XHcT4t.mjs";import"./platform-8oj7iXQy.mjs";export{e as default};
1
+ import"./CAPABILITY_PROBES-DKYJ2K4t.mjs";import{e}from"./server-qWq5nN-R.mjs";import"./shared-DhqnD5R3.mjs";import"./platform-8oj7iXQy.mjs";export{e as default};
@@ -0,0 +1 @@
1
+ import"./SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as d}from"./shard-BqfSKnmG.mjs";import"./shard-runtime-C1P_uVye.mjs";import"./shared-DhqnD5R3.mjs";import"./platform-8oj7iXQy.mjs";import"./schema-BgM8A3XV.mjs";export{d as default};