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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/index.d.mts +20 -1
  2. package/dist/index.d.ts +20 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AGENTS_FILENAME-8zoeGNsB.mjs → AGENTS_FILENAME-isdHqPIt.mjs} +1 -1
  5. package/dist/packem_shared/CONTAINERS_FILENAME-mK4cZpcz.mjs +1 -0
  6. package/dist/packem_shared/{DEFAULT_TARGET-CDksdcYc.mjs → DEFAULT_TARGET-3OLdJhTj.mjs} +1 -1
  7. package/dist/packem_shared/{FLAGS_FILENAME-Cwq0B2Nl.mjs → FLAGS_FILENAME-BQk3SX8D.mjs} +1 -1
  8. package/dist/packem_shared/GENERATED_HEADER-BXK9A_wP.mjs +1 -0
  9. package/dist/packem_shared/LUNORA_ERROR_CODES-CIAJQeKB.mjs +1 -0
  10. package/dist/packem_shared/{MUTATORS_FILENAME-DZFH7a9G.mjs → MUTATORS_FILENAME-Cy9h3EVW.mjs} +1 -1
  11. package/dist/packem_shared/{NOTIFY_FILENAME-DZIt-rb0.mjs → NOTIFY_FILENAME-9to_l_Kh.mjs} +1 -1
  12. package/dist/packem_shared/{OPENRPC_VERSION-CeEGdAZ9.mjs → OPENRPC_VERSION-l4HD4osw.mjs} +1 -1
  13. package/dist/packem_shared/{QUEUES_FILENAME-EvfCmmv6.mjs → QUEUES_FILENAME-Civ-7SiI.mjs} +1 -1
  14. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DcWyFDv9.mjs +31 -0
  15. package/dist/packem_shared/{SHAPES_FILENAME-Ciu5tx7B.mjs → SHAPES_FILENAME-DVJbfDZ8.mjs} +1 -1
  16. package/dist/packem_shared/{WORKFLOWS_FILENAME-C5tz9gMh.mjs → WORKFLOWS_FILENAME-kXq07aGl.mjs} +1 -1
  17. package/dist/packem_shared/{attribution-RI-H1KPm.mjs → attribution-CG8-kUcl.mjs} +1 -1
  18. package/dist/packem_shared/{buildOpenApiDocument-BBao-3vL.mjs → buildOpenApiDocument-DWdj2jvW.mjs} +1 -1
  19. package/dist/packem_shared/capabilitiesUsedBy-C-7D7vlH.mjs +1 -0
  20. package/dist/packem_shared/chain-74gjwZMP.mjs +1 -0
  21. package/dist/packem_shared/{classify-procedure-call-C5JY2w5V.mjs → classify-procedure-call-BkaeM9Ej.mjs} +1 -1
  22. package/dist/packem_shared/{context-property-calls-M6Oo1xQT.mjs → context-property-calls-dFjpeIlP.mjs} +1 -1
  23. package/dist/packem_shared/{context-root-DQd48e1F.mjs → context-root-CNR6TAsP.mjs} +1 -1
  24. package/dist/packem_shared/{createCodegenProject-C-fKC9h4.mjs → createCodegenProject-R4so-yTU.mjs} +1 -1
  25. package/dist/packem_shared/{database-calls-BNoSJRFy.mjs → database-calls-UPlhi3Ks.mjs} +1 -1
  26. package/dist/packem_shared/discoverAuthApiCalls-CScPrUD-.mjs +1 -0
  27. package/dist/packem_shared/discoverCrons-B1_NUt19.mjs +1 -0
  28. package/dist/packem_shared/{discoverFunctions-CJu5EH_G.mjs → discoverFunctions-DkPOc8b9.mjs} +1 -1
  29. package/dist/packem_shared/{discoverHttpRoutes-MrMxIY66.mjs → discoverHttpRoutes-DCDgDIYv.mjs} +1 -1
  30. package/dist/packem_shared/discoverHyperdriveCalls-CL-d0IVo.mjs +1 -0
  31. package/dist/packem_shared/{discoverInserts-Boh6WAYw.mjs → discoverInserts-BcoTjXqI.mjs} +1 -1
  32. package/dist/packem_shared/discoverMaskProcedures-Bw-BOIbA.mjs +1 -0
  33. package/dist/packem_shared/{discoverMigrations-BMdGxHeq.mjs → discoverMigrations-BWxx8Wv9.mjs} +1 -1
  34. package/dist/packem_shared/{discoverNondeterministicCalls-c9xenrIN.mjs → discoverNondeterministicCalls-3INW8oqs.mjs} +1 -1
  35. package/dist/packem_shared/{discoverQueries-o_00HnBB.mjs → discoverQueries-CxQRVuIV.mjs} +1 -1
  36. package/dist/packem_shared/discoverR2sqlCalls-B4oeTYEM.mjs +1 -0
  37. package/dist/packem_shared/{discoverRlsMetadata-C7J8dgVz.mjs → discoverRlsMetadata-D0B4nCmG.mjs} +1 -1
  38. package/dist/packem_shared/{discoverRlsProcedures-Di3VEk-D.mjs → discoverRlsProcedures-Cl6UKT7L.mjs} +1 -1
  39. package/dist/packem_shared/{discoverSandboxUsage-CrhZZJZS.mjs → discoverSandboxUsage--Z1vx7GM.mjs} +1 -1
  40. package/dist/packem_shared/discoverSchema-Cwt-DQgh.mjs +1 -0
  41. package/dist/packem_shared/{discoverStorageRulesMetadata-BFCmbsIN.mjs → discoverStorageRulesMetadata-CitX6ziW.mjs} +1 -1
  42. package/dist/packem_shared/{emitAgents-CR2_X_ov.mjs → emitAgents-C9JRmvrC.mjs} +1 -1
  43. package/dist/packem_shared/{emitApi-CDgIPAG2.mjs → emitApi-c14__tie.mjs} +24 -24
  44. package/dist/packem_shared/{emitApp-DuJW6LKD.mjs → emitApp-BL16wvE9.mjs} +1 -1
  45. package/dist/packem_shared/{emitCrons-BQW2lviZ.mjs → emitCrons-lc-hnJYn.mjs} +1 -1
  46. package/dist/packem_shared/{emitDataModel-BskFt9Wv.mjs → emitDataModel-CuFqq97x.mjs} +1 -1
  47. package/dist/packem_shared/{emitDrizzleSchema-DitcRZ1a.mjs → emitDrizzleSchema-bct1OuH5.mjs} +1 -1
  48. package/dist/packem_shared/{emitFunctions-Cd0Tuw73.mjs → emitFunctions-CkBPtGDF.mjs} +71 -65
  49. package/dist/packem_shared/{emitServer-D1vA5_X1.mjs → emitServer-CGUhLmlG.mjs} +1 -1
  50. package/dist/packem_shared/{emitShard-DtfjUgjj.mjs → emitShard-FJhdFx9H.mjs} +1 -1
  51. package/dist/packem_shared/{exported-procedure-chains-Bol_VtzO.mjs → exported-procedure-chains-D1WlRfqJ.mjs} +1 -1
  52. package/dist/packem_shared/{fingerprintSchemaSources-BdFj8vPc.mjs → fingerprintSchemaSources-BKXkgkj4.mjs} +1 -1
  53. package/dist/packem_shared/{handler-reference-8w_VU4XY.mjs → handler-reference-CClSR4bi.mjs} +1 -1
  54. package/dist/packem_shared/index-CN8FVvr-.mjs +1 -0
  55. package/dist/packem_shared/{isTestPath-Cdv_LoVU.mjs → isTestPath-C3QumE88.mjs} +1 -1
  56. package/dist/packem_shared/loadProjectConfig-B7RmxIeD.mjs +1 -0
  57. package/dist/packem_shared/{modules-DDIIcM7P.mjs → modules-l-Db0C4S.mjs} +1 -1
  58. package/dist/packem_shared/parse-validator-iVTounLK.mjs +1 -0
  59. package/dist/packem_shared/property-name-7cBlgK_O.mjs +1 -0
  60. package/dist/packem_shared/{qualifiers-DEdXn5wP.mjs → qualifiers-Bl5fSmav.mjs} +1 -1
  61. package/dist/packem_shared/readServiceBindings-BA49C6aN.mjs +1 -0
  62. package/dist/packem_shared/{server-DAvi_bv_.mjs → server-B6VhYK7m.mjs} +1 -1
  63. package/dist/packem_shared/{shard-CsfiXxV0.mjs → shard-B6afe1Uh.mjs} +170 -122
  64. package/dist/packem_shared/{shard-runtime-BpoCV-aM.mjs → shard-runtime-BW1kffN4.mjs} +9 -7
  65. package/dist/packem_shared/shared-8vTRkL2-.mjs +13 -0
  66. package/dist/packem_shared/{unwrap-handler-return-Bfz7lH0C.mjs → unwrap-handler-return-CGdJGvGh.mjs} +1 -1
  67. package/dist/sdk/index.mjs +15 -15
  68. package/package.json +9 -9
  69. package/dist/packem_shared/CONTAINERS_FILENAME-QiNt84QA.mjs +0 -1
  70. package/dist/packem_shared/GENERATED_HEADER-Ck_WOHzE.mjs +0 -1
  71. package/dist/packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs +0 -1
  72. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-V7LYutDl.mjs +0 -31
  73. package/dist/packem_shared/capabilitiesUsedBy-BC7ldWJI.mjs +0 -1
  74. package/dist/packem_shared/chain-C9qZxjM_.mjs +0 -1
  75. package/dist/packem_shared/discoverAuthApiCalls-GPzUN_-_.mjs +0 -1
  76. package/dist/packem_shared/discoverCrons-C1fKEf4g.mjs +0 -1
  77. package/dist/packem_shared/discoverHyperdriveCalls-VVJGsgxj.mjs +0 -1
  78. package/dist/packem_shared/discoverMaskProcedures-D3Tu8Q8Y.mjs +0 -1
  79. package/dist/packem_shared/discoverR2sqlCalls-D_H1v-UD.mjs +0 -1
  80. package/dist/packem_shared/discoverSchema-Bdmw34_P.mjs +0 -1
  81. package/dist/packem_shared/index-BMMBKqsT.mjs +0 -1
  82. package/dist/packem_shared/loadProjectConfig-B0uxUGF-.mjs +0 -1
  83. package/dist/packem_shared/parse-validator-BqDQLzDZ.mjs +0 -1
  84. package/dist/packem_shared/project-config-file-CBY6llht.mjs +0 -1
  85. package/dist/packem_shared/readServiceBindings-4xlUucKw.mjs +0 -1
  86. package/dist/packem_shared/shared-DnCokNcE.mjs +0 -13
@@ -0,0 +1 @@
1
+ import{w as a}from"./classify-procedure-call-BkaeM9Ej.mjs";const l=s=>a(s,"use","rls");export{l as r};
@@ -1 +1 @@
1
- import{Node as o,VariableDeclarationKind as S,SyntaxKind as b}from"ts-morph";import{a as y,b as c}from"./module-specifiers-BctA0m_p.mjs";import{unwrapExpression as l}from"./isTestPath-Cdv_LoVU.mjs";const U=e=>o.isIdentifier(e)?e.getText():o.isPropertyAccessExpression(e)?e.getName():void 0,h=(e,t,r=c)=>{const i=new Set;for(const n of e.getImportDeclarations())if(r(n.getModuleSpecifierValue()))for(const s of n.getNamedImports())s.getNameNode().getText()===t&&i.add(s.getAliasNode()?.getText()??s.getName());return i},k=(e,t)=>{if(o.isPropertyAccessExpression(e))return e.getName()===t;if(!o.isIdentifier(e))return!1;const r=e.getText();return r===t||h(e.getSourceFile(),t).has(r)},N=e=>{for(const t of e.getSymbol()?.getDeclarations()??[])if(o.isImportSpecifier(t)&&c(t.getImportDeclaration().getModuleSpecifierValue()))return t.getNameNode().getText()},x=e=>e.getSymbol()?N(e):e.getText(),K=(e,t)=>o.isIdentifier(e)&&N(e)===t,Y=(e,t)=>{const r=e.getExpression(),i=e.getSourceFile();if(o.isIdentifier(r))return h(i,t,y).has(r.getText());if(!o.isPropertyAccessExpression(r)||r.getName()!==t)return!1;const n=r.getExpression().getText();return i.getImportDeclarations().some(s=>s.getNamespaceImport()?.getText()===n&&y(s.getModuleSpecifierValue()))},u=e=>{const t=[];let r=l(e);for(;r&&o.isCallExpression(r);){const i=l(r.getExpression());if(!i||!o.isPropertyAccessExpression(i))return{root:void 0,steps:t};t.push({call:r,name:i.getName()}),r=l(i.getExpression())}return{root:r,steps:t}},E=e=>u(e).steps,A=(e,t,r)=>E(e).filter(i=>i.name===t).map(i=>i.call.getArguments()[0]).filter(i=>i!==void 0&&o.isCallExpression(i)&&r(i.getExpression())),M=(e,t,r)=>A(e,t,i=>k(i,r)),G=(e,t)=>E(e).some(r=>r.name===t),J=(e,t,r)=>M(e,t,r).length>0,D=new Set(["action","internalAction","internalMutation","internalQuery","mutation","query","stream"]),C=e=>{if(o.isIdentifier(e)){for(const t of e.getSymbol()?.getDeclarations()??[])if(o.isImportSpecifier(t)&&c(t.getImportDeclaration().getModuleSpecifierValue()))return t.getName()}if(o.isPropertyAccessExpression(e)){const t=e.getExpression();if(o.isIdentifier(t))return t.getSymbol()?.getDeclarations().some(i=>o.isNamespaceImport(i)&&c(i.getFirstAncestorByKindOrThrow(b.ImportDeclaration).getModuleSpecifierValue()))?e.getName():void 0}},z=e=>{const t=e.getParent(),r=t.getParent(),i=e.getPropertyNameNode()??e.getNameNode();if(!o.isObjectBindingPattern(t)||!o.isVariableDeclaration(r)||r.getVariableStatement()?.getDeclarationKind()!==S.Const||e.getDotDotDotToken()||e.getInitializer()||!o.isIdentifier(i)||!D.has(i.getText())||i.getText()==="stream")return;const n=r.getInitializer();if(!n)return;const{root:s,steps:a}=u(n);return s&&C(s)==="initLunora"&&a.length===2&&a[0]?.name==="create"&&a[1]?.name==="dataModel"?i.getText():void 0},R=e=>{const t=C(e);if(t)return D.has(t)?{factory:t}:{};if(!o.isIdentifier(e))return{};const r=e.getSymbol(),i=(r?.isAlias()?r.getAliasedSymbol():r)?.getValueDeclaration();return i&&o.isBindingElement(i)?{factory:z(i)}:i&&o.isVariableDeclaration(i)&&i.getVariableStatement()?.getDeclarationKind()===S.Const?{initializer:i.getInitializer()}:{}},B=e=>{const t=[],r=new Set;let i=e;for(;i!==void 0&&!r.has(i);){r.add(i);const n=u(i);if(t.push(...n.steps),!n.root)break;const{factory:s,initializer:a}=R(n.root);if(s)return{factory:s,steps:t};i=a}return{steps:t}},m=new Set(["action","mutation","query","stream"]),T={internalAction:"action",internalMutation:"mutation",internalQuery:"query"},f={onConnect:"connect",onDisconnect:"disconnect",onQueryChange:"reactor",onShardInit:"init",onWhisper:"whisper",defineWebSocket:"socket"},p={defineRoom:"room"},_=e=>e==="whisper"?"query":"mutation",w=e=>{const{root:t}=u(e);return t&&o.isIdentifier(t)?t:void 0},O=(e,t=!1)=>{const r=w(e);if(!r)return;const i=x(r);if(i===void 0){if(t)return;const n=r.getSymbol()?.getValueDeclaration();if(n&&o.isVariableDeclaration(n)){const s=n.getInitializer();return s?O(s,!0):void 0}return}return m.has(i)?"public":T[i]?"internal":void 0},V=(e,t=!1)=>{if(A(e,"use",s=>K(s,"platformAdmin")).length>0)return!0;if(t)return!1;const r=w(e)?.getSymbol(),i=(r?.isAlias()?r.getAliasedSymbol():r)?.getValueDeclaration(),n=i&&o.isVariableDeclaration(i)?i.getInitializer():void 0;return n!==void 0&&V(n,!0)},v=e=>V(e)?{adminOnly:!0}:{},L=(e,t)=>{const r=e.getName();if(!m.has(r))return;const i=e.getExpression(),n=l(i)??i,s=i===n?[n]:[i,n];if(s.some(d=>d.getType().getProperty("__lunoraProcedure"))){const d=s.some(P=>P.getType().getProperty("__lunoraVisibility"));return{kind:r,receiver:n,visibility:d?"internal":"public",...v(n)}}const a=t?B(n).factory:void 0,F=a?.startsWith("internal")?"internal":"public",g=a?F:O(n);if(g)return{kind:r,receiver:n,visibility:g,...v(n)}},j=e=>(e.getSymbol()?.getDeclarations()??[]).some(t=>o.isNamespaceImport(t)&&c(t.getFirstAncestorByKind(b.ImportDeclaration)?.getModuleSpecifierValue()??"")),W=e=>Object.hasOwn(p,e)||Object.hasOwn(f,e),I=e=>{if(Object.hasOwn(p,e))return{channel:p[e],kind:"mutation",visibility:"internal"};const t=Object.hasOwn(f,e)?f[e]:void 0;return t?{kind:_(t),lifecycle:t,visibility:"internal"}:void 0},X=(e,t=!1)=>{const r=e.getExpression();if(o.isPropertyAccessExpression(r)){const s=r.getExpression(),a=r.getName();return W(a)&&o.isIdentifier(s)&&j(s)?I(a):L(r,t)}if(!o.isIdentifier(r))return;const i=x(r);if(!i)return;if(m.has(i))return{kind:i,visibility:"public"};const n=T[i];return n?{kind:n,visibility:"internal"}:I(i)};export{U as a,E as b,X as c,J as d,K as e,G as f,Y as g,h as i,B as s,M as w};
1
+ import{Node as o,VariableDeclarationKind as S,SyntaxKind as b}from"ts-morph";import{a as y,b as c}from"./module-specifiers-BctA0m_p.mjs";import{unwrapExpression as l}from"./isTestPath-C3QumE88.mjs";const U=e=>o.isIdentifier(e)?e.getText():o.isPropertyAccessExpression(e)?e.getName():void 0,h=(e,t,r=c)=>{const i=new Set;for(const n of e.getImportDeclarations())if(r(n.getModuleSpecifierValue()))for(const s of n.getNamedImports())s.getNameNode().getText()===t&&i.add(s.getAliasNode()?.getText()??s.getName());return i},k=(e,t)=>{if(o.isPropertyAccessExpression(e))return e.getName()===t;if(!o.isIdentifier(e))return!1;const r=e.getText();return r===t||h(e.getSourceFile(),t).has(r)},N=e=>{for(const t of e.getSymbol()?.getDeclarations()??[])if(o.isImportSpecifier(t)&&c(t.getImportDeclaration().getModuleSpecifierValue()))return t.getNameNode().getText()},x=e=>e.getSymbol()?N(e):e.getText(),K=(e,t)=>o.isIdentifier(e)&&N(e)===t,Y=(e,t)=>{const r=e.getExpression(),i=e.getSourceFile();if(o.isIdentifier(r))return h(i,t,y).has(r.getText());if(!o.isPropertyAccessExpression(r)||r.getName()!==t)return!1;const n=r.getExpression().getText();return i.getImportDeclarations().some(s=>s.getNamespaceImport()?.getText()===n&&y(s.getModuleSpecifierValue()))},u=e=>{const t=[];let r=l(e);for(;r&&o.isCallExpression(r);){const i=l(r.getExpression());if(!i||!o.isPropertyAccessExpression(i))return{root:void 0,steps:t};t.push({call:r,name:i.getName()}),r=l(i.getExpression())}return{root:r,steps:t}},E=e=>u(e).steps,A=(e,t,r)=>E(e).filter(i=>i.name===t).map(i=>i.call.getArguments()[0]).filter(i=>i!==void 0&&o.isCallExpression(i)&&r(i.getExpression())),M=(e,t,r)=>A(e,t,i=>k(i,r)),G=(e,t)=>E(e).some(r=>r.name===t),J=(e,t,r)=>M(e,t,r).length>0,D=new Set(["action","internalAction","internalMutation","internalQuery","mutation","query","stream"]),C=e=>{if(o.isIdentifier(e)){for(const t of e.getSymbol()?.getDeclarations()??[])if(o.isImportSpecifier(t)&&c(t.getImportDeclaration().getModuleSpecifierValue()))return t.getName()}if(o.isPropertyAccessExpression(e)){const t=e.getExpression();if(o.isIdentifier(t))return t.getSymbol()?.getDeclarations().some(i=>o.isNamespaceImport(i)&&c(i.getFirstAncestorByKindOrThrow(b.ImportDeclaration).getModuleSpecifierValue()))?e.getName():void 0}},z=e=>{const t=e.getParent(),r=t.getParent(),i=e.getPropertyNameNode()??e.getNameNode();if(!o.isObjectBindingPattern(t)||!o.isVariableDeclaration(r)||r.getVariableStatement()?.getDeclarationKind()!==S.Const||e.getDotDotDotToken()||e.getInitializer()||!o.isIdentifier(i)||!D.has(i.getText())||i.getText()==="stream")return;const n=r.getInitializer();if(!n)return;const{root:s,steps:a}=u(n);return s&&C(s)==="initLunora"&&a.length===2&&a[0]?.name==="create"&&a[1]?.name==="dataModel"?i.getText():void 0},R=e=>{const t=C(e);if(t)return D.has(t)?{factory:t}:{};if(!o.isIdentifier(e))return{};const r=e.getSymbol(),i=(r?.isAlias()?r.getAliasedSymbol():r)?.getValueDeclaration();return i&&o.isBindingElement(i)?{factory:z(i)}:i&&o.isVariableDeclaration(i)&&i.getVariableStatement()?.getDeclarationKind()===S.Const?{initializer:i.getInitializer()}:{}},B=e=>{const t=[],r=new Set;let i=e;for(;i!==void 0&&!r.has(i);){r.add(i);const n=u(i);if(t.push(...n.steps),!n.root)break;const{factory:s,initializer:a}=R(n.root);if(s)return{factory:s,steps:t};i=a}return{steps:t}},m=new Set(["action","mutation","query","stream"]),T={internalAction:"action",internalMutation:"mutation",internalQuery:"query"},f={onConnect:"connect",onDisconnect:"disconnect",onQueryChange:"reactor",onShardInit:"init",onWhisper:"whisper",defineWebSocket:"socket"},p={defineRoom:"room"},_=e=>e==="whisper"?"query":"mutation",w=e=>{const{root:t}=u(e);return t&&o.isIdentifier(t)?t:void 0},O=(e,t=!1)=>{const r=w(e);if(!r)return;const i=x(r);if(i===void 0){if(t)return;const n=r.getSymbol()?.getValueDeclaration();if(n&&o.isVariableDeclaration(n)){const s=n.getInitializer();return s?O(s,!0):void 0}return}return m.has(i)?"public":T[i]?"internal":void 0},V=(e,t=!1)=>{if(A(e,"use",s=>K(s,"platformAdmin")).length>0)return!0;if(t)return!1;const r=w(e)?.getSymbol(),i=(r?.isAlias()?r.getAliasedSymbol():r)?.getValueDeclaration(),n=i&&o.isVariableDeclaration(i)?i.getInitializer():void 0;return n!==void 0&&V(n,!0)},v=e=>V(e)?{adminOnly:!0}:{},L=(e,t)=>{const r=e.getName();if(!m.has(r))return;const i=e.getExpression(),n=l(i)??i,s=i===n?[n]:[i,n];if(s.some(d=>d.getType().getProperty("__lunoraProcedure"))){const d=s.some(P=>P.getType().getProperty("__lunoraVisibility"));return{kind:r,receiver:n,visibility:d?"internal":"public",...v(n)}}const a=t?B(n).factory:void 0,F=a?.startsWith("internal")?"internal":"public",g=a?F:O(n);if(g)return{kind:r,receiver:n,visibility:g,...v(n)}},j=e=>(e.getSymbol()?.getDeclarations()??[]).some(t=>o.isNamespaceImport(t)&&c(t.getFirstAncestorByKind(b.ImportDeclaration)?.getModuleSpecifierValue()??"")),W=e=>Object.hasOwn(p,e)||Object.hasOwn(f,e),I=e=>{if(Object.hasOwn(p,e))return{channel:p[e],kind:"mutation",visibility:"internal"};const t=Object.hasOwn(f,e)?f[e]:void 0;return t?{kind:_(t),lifecycle:t,visibility:"internal"}:void 0},X=(e,t=!1)=>{const r=e.getExpression();if(o.isPropertyAccessExpression(r)){const s=r.getExpression(),a=r.getName();return W(a)&&o.isIdentifier(s)&&j(s)?I(a):L(r,t)}if(!o.isIdentifier(r))return;const i=x(r);if(!i)return;if(m.has(i))return{kind:i,visibility:"public"};const n=T[i];return n?{kind:n,visibility:"internal"}:I(i)};export{U as a,E as b,X as c,J as d,K as e,G as f,Y as g,h as i,B as s,M as w};
@@ -1 +1 @@
1
- import{Node as i}from"ts-morph";import{listLunoraSourceFiles as a,lunoraRelativePath as c,handlerOf as l}from"./isTestPath-Cdv_LoVU.mjs";import{b as d,d as f}from"./attribution-RI-H1KPm.mjs";import{c as u}from"./context-root-DQd48e1F.mjs";import{c as m}from"./classify-procedure-call-C5JY2w5V.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-C3QumE88.mjs";import{b as d,d as f}from"./attribution-CG8-kUcl.mjs";import{c as u}from"./context-root-CNR6TAsP.mjs";import{c as m}from"./classify-procedure-call-BkaeM9Ej.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 s,SyntaxKind as d}from"ts-morph";import{unwrapExpression as l,memberAccessOf as P,bindingKeyName as C,findObjectProperty as p,isConstDeclaration as D,walkChain as A}from"./isTestPath-Cdv_LoVU.mjs";import{f as v,g as I,h as M}from"./attribution-RI-H1KPm.mjs";import{c as F}from"./classify-procedure-call-C5JY2w5V.mjs";import{isDefineMutatorCallee as b}from"./MUTATORS_FILENAME-DZFH7a9G.mjs";const x=8,E=t=>{if(s.isMethodDeclaration(t))return t;const e=s.isPropertyAssignment(t)?l(t.getInitializer()):void 0,o=s.isShorthandPropertyAssignment(t)?t.getNameNode():e;if(s.isArrowFunction(o)||s.isFunctionExpression(o))return o;const i=s.isIdentifier(o)?v(o):void 0;if(s.isFunctionDeclaration(i))return i;const n=D(i)?l(i.getInitializer()):void 0;return s.isArrowFunction(n)||s.isFunctionExpression(n)?n:void 0},w=t=>{const e=l(t.getArguments()[0]),o=s.isObjectLiteralExpression(e)?e:void 0,i=p(o,"server"),n=p(o,"handler"),r=i!==void 0&&b(t.getExpression()),a=n===void 0?void 0:F(t),u=a!==void 0&&a.receiver===void 0;return[r?E(i):void 0,u?E(n):void 0].filter(f=>f!==void 0)},h=new WeakMap,O=t=>{const e=t.getSourceFile(),o=h.get(e.compilerNode);if(o!==void 0)return o;const i=new Set(e.getDescendantsOfKind(d.CallExpression).flatMap(n=>w(n)).map(n=>n.compilerNode));return h.set(e.compilerNode,i),i},S=t=>{const e=t.getParent();return(s.isArrowFunction(e)||s.isFunctionExpression(e)||s.isFunctionDeclaration(e)||s.isMethodDeclaration(e))&&e.getParameters()[0]===t&&O(t).has(e.compilerNode)},G=t=>{const e=t.getParent();return(s.isArrowFunction(e)||s.isFunctionExpression(e)||s.isFunctionDeclaration(e)||s.isMethodDeclaration(e))&&e.getParameters()[1]===t&&O(t).has(e.compilerNode)},T=t=>t.getNameNode().getDescendantsOfKind(d.BindingElement).some(e=>e.getParent().getParent()===t&&["args","ctx"].includes(C(e))),g=(t,e,o)=>{const i=t.getParent().getParent(),n=C(t);if(t.getDotDotDotToken()!==void 0||e==="trust"&&I(t))return;let r;if(s.isParameterDeclaration(i)){if(!S(i)||T(i))return n==="ctx"?[]:void 0;r=[]}else s.isBindingElement(i)?r=g(i,e,o):s.isVariableDeclaration(i)&&o>0&&(r=c(i.getInitializer(),e,o-1));return r===void 0?void 0:[...r,n]},c=(t,e="discover",o=x)=>{const i=l(t),n=P(i);if(n!==void 0){const r=c(n.object,e,o);return r===void 0?void 0:[...r,n.member]}return s.isIdentifier(i)?B(i,e,o):void 0},B=(t,e,o)=>{const i=t.getText()==="ctx",n=e==="trust"||!i?v(t):void 0;return i&&!s.isVariableDeclaration(n)?s.isBindingElement(n)?g(n,e,o):[]:s.isParameterDeclaration(n)?s.isIdentifier(n.getNameNode())&&S(n)?[]:void 0:s.isBindingElement(n)?g(n,e,o):!(s.isVariableDeclaration(n)&&s.isIdentifier(n.getNameNode())&&o>0)||e==="trust"&&I(n)?void 0:c(n.getInitializer(),e,o-1)},Q=t=>c(t,"discover"),H=t=>{const e=c(t);return e===void 0?void 0:["ctx",...e].join(".")},q=(t,e)=>{if(e(t.getText()))return!0;const o=H(t);return o!==void 0&&e(o)},J=(t,e)=>{const o=l(t),i=P(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((r,a)=>r===e[a])},Y=(t,e)=>U(t).get(e)??[],K=t=>{const e=new Map;for(const i of t.getDescendantsOfKind(d.BindingElement)){const n=s.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 t.getDescendantsOfKind(d.Identifier).flatMap(i=>{const r=o.has(i.getText())&&!s.isBindingElement(i.getParent())?v(i):void 0,a=r===void 0?void 0:e.get(r.compilerNode);return a===void 0?[]:[[a,i]]})},N=new WeakMap,U=t=>{const e=N.get(t.compilerNode);if(e!==void 0)return e;const o=new Map;for(const[n,r]of[...y(t),...K(t)])o.set(n,[...o.get(n)??[],r]);const i=new Map([...o].map(([n,r])=>[n,r.toSorted((a,u)=>a.getPos()-u.getPos())]));return N.set(t.compilerNode,i),i},y=t=>t.getDescendantsOfKind(d.PropertyAccessExpression).flatMap(e=>z(e.getExpression())?[[e.getName(),e]]:[]),z=t=>s.isIdentifier(t)&&c(t)?.length===0,Z=t=>{const e=c(t);return e?.length===1&&e[0]==="db"},_=new Set(["asId","createMultipartUpload","fetch","generateUploadUrl","getPresignedUrl","getSignedUrl","getUrl","normalizeId","resumeMultipartUpload","runAction","runMutation","runQuery","store","upload"]),R=new Set(["catch","flatMap","map","reduce","reduceRight","then"]),k=(t,e=x)=>{const o=A(t,u=>{const f=l(u.getExpression()),m=s.isPropertyAccessExpression(f)?f.getName():void 0;return m!==void 0&&(_.has(m)||R.has(m))?!1:void 0}),i=o.root;if(o.verdict!==void 0||!s.isIdentifier(i))return o.verdict??!1;if(c(i,"trust")!==void 0)return!0;const n=v(i),r=s.isBindingElement(n)?n.getFirstAncestorByKind(d.VariableDeclaration):n,a=D(r)&&e>0?r.getInitializer():void 0;return a!==void 0&&k(a,e-1)},$=t=>(s.isIdentifier(t)?[t]:t.getDescendantsOfKind(d.Identifier)).some(o=>M(o)&&c(o,"trust")!==void 0);export{R as C,_ as E,G as a,H as b,Y as c,Z as d,Q as e,k as f,z as g,J as i,q as m,$ as r};
1
+ import{Node as s,SyntaxKind as d}from"ts-morph";import{unwrapExpression as l,memberAccessOf as P,bindingKeyName as C,findObjectProperty as p,isConstDeclaration as D,walkChain as A}from"./isTestPath-C3QumE88.mjs";import{f as v,g as I,h as M}from"./attribution-CG8-kUcl.mjs";import{c as F}from"./classify-procedure-call-BkaeM9Ej.mjs";import{isDefineMutatorCallee as b}from"./MUTATORS_FILENAME-Cy9h3EVW.mjs";const x=8,E=t=>{if(s.isMethodDeclaration(t))return t;const e=s.isPropertyAssignment(t)?l(t.getInitializer()):void 0,o=s.isShorthandPropertyAssignment(t)?t.getNameNode():e;if(s.isArrowFunction(o)||s.isFunctionExpression(o))return o;const i=s.isIdentifier(o)?v(o):void 0;if(s.isFunctionDeclaration(i))return i;const n=D(i)?l(i.getInitializer()):void 0;return s.isArrowFunction(n)||s.isFunctionExpression(n)?n:void 0},w=t=>{const e=l(t.getArguments()[0]),o=s.isObjectLiteralExpression(e)?e:void 0,i=p(o,"server"),n=p(o,"handler"),r=i!==void 0&&b(t.getExpression()),a=n===void 0?void 0:F(t),u=a!==void 0&&a.receiver===void 0;return[r?E(i):void 0,u?E(n):void 0].filter(f=>f!==void 0)},h=new WeakMap,O=t=>{const e=t.getSourceFile(),o=h.get(e.compilerNode);if(o!==void 0)return o;const i=new Set(e.getDescendantsOfKind(d.CallExpression).flatMap(n=>w(n)).map(n=>n.compilerNode));return h.set(e.compilerNode,i),i},S=t=>{const e=t.getParent();return(s.isArrowFunction(e)||s.isFunctionExpression(e)||s.isFunctionDeclaration(e)||s.isMethodDeclaration(e))&&e.getParameters()[0]===t&&O(t).has(e.compilerNode)},G=t=>{const e=t.getParent();return(s.isArrowFunction(e)||s.isFunctionExpression(e)||s.isFunctionDeclaration(e)||s.isMethodDeclaration(e))&&e.getParameters()[1]===t&&O(t).has(e.compilerNode)},T=t=>t.getNameNode().getDescendantsOfKind(d.BindingElement).some(e=>e.getParent().getParent()===t&&["args","ctx"].includes(C(e))),g=(t,e,o)=>{const i=t.getParent().getParent(),n=C(t);if(t.getDotDotDotToken()!==void 0||e==="trust"&&I(t))return;let r;if(s.isParameterDeclaration(i)){if(!S(i)||T(i))return n==="ctx"?[]:void 0;r=[]}else s.isBindingElement(i)?r=g(i,e,o):s.isVariableDeclaration(i)&&o>0&&(r=c(i.getInitializer(),e,o-1));return r===void 0?void 0:[...r,n]},c=(t,e="discover",o=x)=>{const i=l(t),n=P(i);if(n!==void 0){const r=c(n.object,e,o);return r===void 0?void 0:[...r,n.member]}return s.isIdentifier(i)?B(i,e,o):void 0},B=(t,e,o)=>{const i=t.getText()==="ctx",n=e==="trust"||!i?v(t):void 0;return i&&!s.isVariableDeclaration(n)?s.isBindingElement(n)?g(n,e,o):[]:s.isParameterDeclaration(n)?s.isIdentifier(n.getNameNode())&&S(n)?[]:void 0:s.isBindingElement(n)?g(n,e,o):!(s.isVariableDeclaration(n)&&s.isIdentifier(n.getNameNode())&&o>0)||e==="trust"&&I(n)?void 0:c(n.getInitializer(),e,o-1)},Q=t=>c(t,"discover"),H=t=>{const e=c(t);return e===void 0?void 0:["ctx",...e].join(".")},q=(t,e)=>{if(e(t.getText()))return!0;const o=H(t);return o!==void 0&&e(o)},J=(t,e)=>{const o=l(t),i=P(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((r,a)=>r===e[a])},Y=(t,e)=>U(t).get(e)??[],K=t=>{const e=new Map;for(const i of t.getDescendantsOfKind(d.BindingElement)){const n=s.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 t.getDescendantsOfKind(d.Identifier).flatMap(i=>{const r=o.has(i.getText())&&!s.isBindingElement(i.getParent())?v(i):void 0,a=r===void 0?void 0:e.get(r.compilerNode);return a===void 0?[]:[[a,i]]})},N=new WeakMap,U=t=>{const e=N.get(t.compilerNode);if(e!==void 0)return e;const o=new Map;for(const[n,r]of[...y(t),...K(t)])o.set(n,[...o.get(n)??[],r]);const i=new Map([...o].map(([n,r])=>[n,r.toSorted((a,u)=>a.getPos()-u.getPos())]));return N.set(t.compilerNode,i),i},y=t=>t.getDescendantsOfKind(d.PropertyAccessExpression).flatMap(e=>z(e.getExpression())?[[e.getName(),e]]:[]),z=t=>s.isIdentifier(t)&&c(t)?.length===0,Z=t=>{const e=c(t);return e?.length===1&&e[0]==="db"},_=new Set(["asId","createMultipartUpload","fetch","generateUploadUrl","getPresignedUrl","getSignedUrl","getUrl","normalizeId","resumeMultipartUpload","runAction","runMutation","runQuery","store","upload"]),R=new Set(["catch","flatMap","map","reduce","reduceRight","then"]),k=(t,e=x)=>{const o=A(t,u=>{const f=l(u.getExpression()),m=s.isPropertyAccessExpression(f)?f.getName():void 0;return m!==void 0&&(_.has(m)||R.has(m))?!1:void 0}),i=o.root;if(o.verdict!==void 0||!s.isIdentifier(i))return o.verdict??!1;if(c(i,"trust")!==void 0)return!0;const n=v(i),r=s.isBindingElement(n)?n.getFirstAncestorByKind(d.VariableDeclaration):n,a=D(r)&&e>0?r.getInitializer():void 0;return a!==void 0&&k(a,e-1)},$=t=>(s.isIdentifier(t)?[t]:t.getDescendantsOfKind(d.Identifier)).some(o=>M(o)&&c(o,"trust")!==void 0);export{R as C,_ as E,G as a,H as b,Y as c,Z as d,Q as e,k as f,z as g,J as i,q as m,$ as r};
@@ -1 +1 @@
1
- import{createHash as E}from"node:crypto";import{readFileSync as F,existsSync as f,readdirSync as N,statSync as T}from"node:fs";import{dirname as p,join as m}from"node:path";import{Project as x,ts as i}from"ts-morph";import{listSecurityScanFiles as L,listLunoraSourceFiles as R}from"./isTestPath-Cdv_LoVU.mjs";import{projectConfigCandidatePaths as K}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";const d=e=>e.replaceAll("\\","/"),_=e=>{const s=R(e),t=m(e,"schema.ts");return f(t)&&s.push(t),s},$=e=>{const s=m(e,"_generated");return f(s)?N(s,{encoding:"utf8",recursive:!0}).filter(t=>t.endsWith(".ts")).map(t=>m(s,t)).filter(t=>T(t).isFile()):[]},O=/\.d\.(?:ts|mts|cts)$/,D=/\.[cm]?jsx?$/,G=/\bdeclare\b|\/\/\//,W=e=>{const s=i.createScanner(i.ScriptTarget.Latest,!0,i.LanguageVariant.Standard,e),t=s.scan();if(t===i.SyntaxKind.ExportKeyword)return!0;if(t!==i.SyntaxKind.ImportKeyword)return!1;const n=s.scan();return n===i.SyntaxKind.OpenBraceToken||n===i.SyntaxKind.AsteriskToken||n===i.SyntaxKind.StringLiteral},J=e=>i.isCallExpression(e)?i.isIdentifier(e.expression)&&e.expression.text==="require":i.isPropertyAccessExpression(e)&&i.isIdentifier(e.expression)?e.expression.text==="exports"||e.expression.text==="module"&&e.name.text==="exports":!1,C=e=>J(e)||i.forEachChild(e,C)===!0,V=e=>i.isModuleDeclaration(e)&&i.isIdentifier(e.name)&&e.name.text==="global",M=new Map,q=(e,s,t)=>{if(!G.test(s)&&(t||W(s)))return{augments:[],hasGlobal:!1,isModule:!0};const n=i.createSourceFile(e,s,i.ScriptTarget.Latest,!1),r=n.referencedFiles.length>0||n.typeReferenceDirectives.length>0||n.libReferenceDirectives.length>0;return{augments:n.statements.flatMap(o=>i.isModuleDeclaration(o)&&i.isStringLiteral(o.name)?[o.name.text]:[]),hasGlobal:r||n.statements.some(o=>V(o)),isModule:t||i.isExternalModule(n)||D.test(e)&&C(n)}},z=(e,s,t)=>{const n=`${t?"force":"auto"}:${E("sha256").update(s).digest("hex")}`,r=M.get(e);if(r?.key===n)return r.analysis;const o=q(e,s,t);return M.set(e,{analysis:o,key:n}),o},P=e=>{const s={...i.sys,onUnRecoverableConfigFileDiagnostic:()=>{}},t=i.getParsedCommandLineOfConfigFile(e,void 0,s);return{fileNames:t?.fileNames??[],forceModules:t?.options.moduleDetection===i.ModuleDetectionKind.Force}},w=new WeakMap,I=(e,s)=>{const{fileNames:t=[],forceModules:n=!1}=s??{},r=`${d(e)}/`,o=[],l=[],u=[];for(const c of t){if(!f(c))continue;if(O.test(c)){o.push(c);continue}if(d(c).startsWith(r))continue;const a=z(c,F(c,"utf8"),n);!a.isModule||a.hasGlobal?l.push(c):a.augments.length>0&&u.push({augments:a.augments,path:c})}return{augmentations:u,files:[...new Set([..._(e),...L(e).map(({filePath:c})=>c),...$(e),...o,...l,...K(e).filter(c=>f(c))])]}},b=(e,s,t)=>i.resolveModuleName(e,s,t,i.sys).resolvedModule?.resolvedFileName??e,B=(e,s)=>{const t=e.getCompilerOptions(),n=new Set;for(const r of s){const o=e.getSourceFile(r);if(o!==void 0)for(const{fileName:l}of i.preProcessFile(o.getFullText(),!0,!1).importedFiles)n.add(b(l,o.getFilePath(),t))}return n},H=(e,s)=>{const t=e.getCompilerOptions(),n=new Map,r=new Set,o=[...s],l=(u,c)=>{const a=p(u),g=i.preProcessFile(c,!0,!0),y=g.referencedFiles.map(({fileName:h})=>m(a,h));for(const{fileName:h}of g.importedFiles){const S=`${a}\0${h}`;n.has(S)||n.set(S,i.resolveModuleName(h,u,t,i.sys).resolvedModule?.resolvedFileName);const v=n.get(S);v!==void 0&&y.push(v)}return y};for(;o.length>0;){const u=o.pop();if(u===void 0||d(u).includes("/node_modules/")||r.has(d(u)))continue;r.add(d(u));const c=e.getSourceFile(u);c!==void 0&&o.push(...l(c.getFilePath(),c.getFullText()))}return r},k=(e,s,t)=>{const n=e.getCompilerOptions(),r=[];let o;for(;;){e.resolveSourceFileDependencies(),o=H(e,[...s,...r]);const l=t.filter(a=>!r.includes(a.path));if(l.length===0)break;const u=B(e,o),c=l.filter(a=>a.augments.some(g=>u.has(b(g,a.path,n))));if(c.length===0)break;for(const a of c)e.getSourceFile(a.path)===void 0&&e.createSourceFile(a.path,F(a.path,"utf8"),{overwrite:!0});r.push(...c.map(a=>a.path))}for(const l of e.getSourceFiles())!l.isInNodeModules()&&!o.has(l.getFilePath())&&e.removeSourceFile(l)},A=e=>{let s=f(e)?e:p(e);for(;s&&s!==p(s);){const t=m(s,"tsconfig.json");if(f(t))return t;s=p(s)}},ee=e=>{const s=A(e);if(s===void 0)return new x({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});const t=new x({skipAddingFilesFromTsConfig:!0,tsConfigFilePath:s,useInMemoryFileSystem:!1}),n=P(s);w.set(t,n);const r=I(e,n);for(const o of r.files)t.createSourceFile(o,F(o,"utf8"),{overwrite:!0});return k(t,r.files,r.augmentations),t},se=(e,s)=>{const t=A(s),n=I(s,w.get(e)??(t===void 0?void 0:P(t)));for(const o of n.files){const l=e.getSourceFile(o);l===void 0?e.createSourceFile(o,F(o,"utf8"),{overwrite:!0}):l.refreshFromFileSystemSync()}const r=new Set(n.files);for(const o of e.getSourceFiles())if(!(r.has(o.getFilePath())||o.isInNodeModules()))try{o.refreshFromFileSystemSync()}catch{e.removeSourceFile(o)}k(e,n.files,n.augmentations)};export{ee as createCodegenProject,A as findTsconfig,se as refreshCodegenProject};
1
+ import{createHash as E}from"node:crypto";import{readFileSync as F,existsSync as f,readdirSync as N,statSync as T}from"node:fs";import{dirname as p,join as m}from"node:path";import{Project as x,ts as i}from"ts-morph";import{listSecurityScanFiles as L,listLunoraSourceFiles as R}from"./isTestPath-C3QumE88.mjs";import{projectConfigCandidatePaths as K}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";const d=e=>e.replaceAll("\\","/"),_=e=>{const s=R(e),t=m(e,"schema.ts");return f(t)&&s.push(t),s},$=e=>{const s=m(e,"_generated");return f(s)?N(s,{encoding:"utf8",recursive:!0}).filter(t=>t.endsWith(".ts")).map(t=>m(s,t)).filter(t=>T(t).isFile()):[]},O=/\.d\.(?:ts|mts|cts)$/,D=/\.[cm]?jsx?$/,G=/\bdeclare\b|\/\/\//,W=e=>{const s=i.createScanner(i.ScriptTarget.Latest,!0,i.LanguageVariant.Standard,e),t=s.scan();if(t===i.SyntaxKind.ExportKeyword)return!0;if(t!==i.SyntaxKind.ImportKeyword)return!1;const n=s.scan();return n===i.SyntaxKind.OpenBraceToken||n===i.SyntaxKind.AsteriskToken||n===i.SyntaxKind.StringLiteral},J=e=>i.isCallExpression(e)?i.isIdentifier(e.expression)&&e.expression.text==="require":i.isPropertyAccessExpression(e)&&i.isIdentifier(e.expression)?e.expression.text==="exports"||e.expression.text==="module"&&e.name.text==="exports":!1,C=e=>J(e)||i.forEachChild(e,C)===!0,V=e=>i.isModuleDeclaration(e)&&i.isIdentifier(e.name)&&e.name.text==="global",M=new Map,q=(e,s,t)=>{if(!G.test(s)&&(t||W(s)))return{augments:[],hasGlobal:!1,isModule:!0};const n=i.createSourceFile(e,s,i.ScriptTarget.Latest,!1),r=n.referencedFiles.length>0||n.typeReferenceDirectives.length>0||n.libReferenceDirectives.length>0;return{augments:n.statements.flatMap(o=>i.isModuleDeclaration(o)&&i.isStringLiteral(o.name)?[o.name.text]:[]),hasGlobal:r||n.statements.some(o=>V(o)),isModule:t||i.isExternalModule(n)||D.test(e)&&C(n)}},z=(e,s,t)=>{const n=`${t?"force":"auto"}:${E("sha256").update(s).digest("hex")}`,r=M.get(e);if(r?.key===n)return r.analysis;const o=q(e,s,t);return M.set(e,{analysis:o,key:n}),o},P=e=>{const s={...i.sys,onUnRecoverableConfigFileDiagnostic:()=>{}},t=i.getParsedCommandLineOfConfigFile(e,void 0,s);return{fileNames:t?.fileNames??[],forceModules:t?.options.moduleDetection===i.ModuleDetectionKind.Force}},w=new WeakMap,I=(e,s)=>{const{fileNames:t=[],forceModules:n=!1}=s??{},r=`${d(e)}/`,o=[],l=[],u=[];for(const c of t){if(!f(c))continue;if(O.test(c)){o.push(c);continue}if(d(c).startsWith(r))continue;const a=z(c,F(c,"utf8"),n);!a.isModule||a.hasGlobal?l.push(c):a.augments.length>0&&u.push({augments:a.augments,path:c})}return{augmentations:u,files:[...new Set([..._(e),...L(e).map(({filePath:c})=>c),...$(e),...o,...l,...K(e).filter(c=>f(c))])]}},b=(e,s,t)=>i.resolveModuleName(e,s,t,i.sys).resolvedModule?.resolvedFileName??e,B=(e,s)=>{const t=e.getCompilerOptions(),n=new Set;for(const r of s){const o=e.getSourceFile(r);if(o!==void 0)for(const{fileName:l}of i.preProcessFile(o.getFullText(),!0,!1).importedFiles)n.add(b(l,o.getFilePath(),t))}return n},H=(e,s)=>{const t=e.getCompilerOptions(),n=new Map,r=new Set,o=[...s],l=(u,c)=>{const a=p(u),g=i.preProcessFile(c,!0,!0),y=g.referencedFiles.map(({fileName:h})=>m(a,h));for(const{fileName:h}of g.importedFiles){const S=`${a}\0${h}`;n.has(S)||n.set(S,i.resolveModuleName(h,u,t,i.sys).resolvedModule?.resolvedFileName);const v=n.get(S);v!==void 0&&y.push(v)}return y};for(;o.length>0;){const u=o.pop();if(u===void 0||d(u).includes("/node_modules/")||r.has(d(u)))continue;r.add(d(u));const c=e.getSourceFile(u);c!==void 0&&o.push(...l(c.getFilePath(),c.getFullText()))}return r},k=(e,s,t)=>{const n=e.getCompilerOptions(),r=[];let o;for(;;){e.resolveSourceFileDependencies(),o=H(e,[...s,...r]);const l=t.filter(a=>!r.includes(a.path));if(l.length===0)break;const u=B(e,o),c=l.filter(a=>a.augments.some(g=>u.has(b(g,a.path,n))));if(c.length===0)break;for(const a of c)e.getSourceFile(a.path)===void 0&&e.createSourceFile(a.path,F(a.path,"utf8"),{overwrite:!0});r.push(...c.map(a=>a.path))}for(const l of e.getSourceFiles())!l.isInNodeModules()&&!o.has(l.getFilePath())&&e.removeSourceFile(l)},A=e=>{let s=f(e)?e:p(e);for(;s&&s!==p(s);){const t=m(s,"tsconfig.json");if(f(t))return t;s=p(s)}},ee=e=>{const s=A(e);if(s===void 0)return new x({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});const t=new x({skipAddingFilesFromTsConfig:!0,tsConfigFilePath:s,useInMemoryFileSystem:!1}),n=P(s);w.set(t,n);const r=I(e,n);for(const o of r.files)t.createSourceFile(o,F(o,"utf8"),{overwrite:!0});return k(t,r.files,r.augmentations),t},se=(e,s)=>{const t=A(s),n=I(s,w.get(e)??(t===void 0?void 0:P(t)));for(const o of n.files){const l=e.getSourceFile(o);l===void 0?e.createSourceFile(o,F(o,"utf8"),{overwrite:!0}):l.refreshFromFileSystemSync()}const r=new Set(n.files);for(const o of e.getSourceFiles())if(!(r.has(o.getFilePath())||o.isInNodeModules()))try{o.refreshFromFileSystemSync()}catch{e.removeSourceFile(o)}k(e,n.files,n.augmentations)};export{ee as createCodegenProject,A as findTsconfig,se as refreshCodegenProject};
@@ -1 +1 @@
1
- import{SyntaxKind as g,Node as n}from"ts-morph";import{d as p}from"./context-root-DQd48e1F.mjs";const c=e=>n.isPropertyAccessExpression(e)&&e.getName()==="db"||n.isIdentifier(e)&&e.getText()==="db"||p(e),l=new Set(["findFirst","findFirstOrThrow","findMany","findUnique"]),u=e=>{const t=e.getExpression();if(!n.isPropertyAccessExpression(t)||!l.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():""},m=(e,t,s)=>{const o=new Set,i=new Set;for(const a of e.getDescendantsOfKind(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,u as r,m as t};
1
+ import{SyntaxKind as g,Node as n}from"ts-morph";import{d as p}from"./context-root-CNR6TAsP.mjs";const c=e=>n.isPropertyAccessExpression(e)&&e.getName()==="db"||n.isIdentifier(e)&&e.getText()==="db"||p(e),l=new Set(["findFirst","findFirstOrThrow","findMany","findUnique"]),u=e=>{const t=e.getExpression();if(!n.isPropertyAccessExpression(t)||!l.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():""},m=(e,t,s)=>{const o=new Set,i=new Set;for(const a of e.getDescendantsOfKind(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,u as r,m as t};
@@ -0,0 +1 @@
1
+ import{Node as t}from"ts-morph";import{collectCallRows as n}from"./isTestPath-C3QumE88.mjs";import{c as p}from"./attribution-CG8-kUcl.mjs";import{a}from"./property-name-7cBlgK_O.mjs";const c=s=>{const r=s.getExpression();if(!t.isPropertyAccessExpression(r))return!1;const e=r.getExpression();return t.isPropertyAccessExpression(e)?e.getName()==="authApi":t.isIdentifier(e)&&e.getText()==="authApi"},u=s=>{const r=s.getArguments()[0];if(r===void 0)return!1;if(!t.isObjectLiteralExpression(r))return!0;for(const e of r.getProperties())if((t.isPropertyAssignment(e)||t.isShorthandPropertyAssignment(e))&&a(e)==="headers"||t.isSpreadAssignment(e))return!0;return!1},d=(s,r)=>n(s,r,(e,o)=>{if(!c(e))return;const i=e.getExpression();return{file:o,hasHeaders:u(e),line:e.getStartLineNumber(),method:t.isPropertyAccessExpression(i)?i.getName():"",scope:p(e)}});export{d as default};
@@ -0,0 +1 @@
1
+ import{LunoraError as x}from"@lunora/errors";import{CRON_SCHEDULE_KINDS as A,warnIfSecondsLeading as O,compileCronSchedule as S}from"@lunora/scheduler";import I from"@lunora/scheduler/validate";import{SyntaxKind as m,Node as i}from"ts-morph";import{diagnosticAt as f,CodegenDiagnosticError as R}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{i as b}from"./module-specifiers-BctA0m_p.mjs";import{listLunoraSourceFiles as y,functionKeyOf as $}from"./isTestPath-C3QumE88.mjs";import{a as P}from"./property-name-7cBlgK_O.mjs";const D=new Set([...A,"cron"]),v=e=>{const t=e.getSymbol();if(!t)return e.getText()==="cronJobs";for(const r of t.getDeclarations())if(i.isImportSpecifier(r))return b(r.getImportDeclaration().getModuleSpecifierValue())?r.getNameNode().getText()==="cronJobs":!1;return!1},F=e=>{const t=new Set;for(const r of e.getVariableDeclarations()){const n=r.getInitializer();if(n?.getKind()!==m.CallExpression)continue;const s=n.getExpression();i.isIdentifier(s)&&v(s)&&t.add(r.getName())}return t},V=e=>{let t=e;for(;i.isCallExpression(t)||i.isPropertyAccessExpression(t);)t=t.getExpression();return i.isIdentifier(t)?t.getText():void 0},_=(e,t)=>{const r=e.getArguments()[t];return r&&(i.isStringLiteral(r)||i.isNoSubstitutionTemplateLiteral(r))?r.getLiteralValue():void 0},L=(e,t)=>{if(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e)||i.isNumericLiteral(e))return e.getLiteralValue();if(i.isTrueLiteral(e))return!0;if(i.isFalseLiteral(e))return!1;if(i.isPrefixUnaryExpression(e)&&e.getOperatorToken()===m.MinusToken){const r=e.getOperand();if(i.isNumericLiteral(r))return-r.getLiteralValue()}if(i.isObjectLiteralExpression(e))return p(e,t);if(i.isArrayLiteralExpression(e))return e.getElements().map(r=>L(r,t));throw f(e,`Cron job "${t}" passes a non-static value where a literal is required; codegen can only read literals.`,{code:"CRON_NON_STATIC_VALUE",name:"LunoraError",status:500})},p=(e,t)=>{const r={};for(const n of e.getProperties()){if(!i.isPropertyAssignment(n))throw f(n,`Cron job "${t}" uses an unsupported object property (shorthand/spread/method) where a static literal is required.`,{code:"CRON_NON_STATIC_VALUE",name:"LunoraError",status:500});const s=n.getInitializer();s&&(r[P(n)]=L(s,t))}return r},C=(e,t,r)=>{const n=e.getArguments()[t];if(!n||!i.isPropertyAccessExpression(n))throw f(e,`Cron job "${r}" must reference a function statically (e.g. internal.email.digest); codegen cannot resolve a dynamic reference.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});const s=$(n);if(s===void 0)throw f(n,`Cron job "${r}" function reference must be of the form internal.<…path>.fn (or api.<…path>.fn).`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});return s},h=e=>({workflow:{className:e.className,exportName:e.exportName}}),w=e=>({workflow:{className:e.className,exportName:e.exportName}}),T=(e,t,r,n,s,o)=>{const a=e.getExpression();if(!i.isIdentifier(a)||a.getText()!==t)return;const c=r.get(e.getName());if(c)return o(c);throw f(e,`Cron job "${n}" targets ${t}.${e.getName()}, but no such ${s} is declared in lunora/${s}s.ts.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500})},k=(e,t,r,n,s)=>{const o=e.getArguments()[t];if(o&&i.isPropertyAccessExpression(o)){const a=T(o,"workflows",n,r,"workflow",h);if(a)return a;const c=T(o,"agents",s,r,"agent",w);return c||{functionPath:C(e,t,r)}}if(o&&i.isIdentifier(o)){const a=n.get(o.getText()),c=s.get(o.getText());if(a&&c)throw f(o,`Cron job "${r}" references "${o.getText()}", which is ambiguous: a workflow and an agent are both declared under that name.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});if(a)return h(a);if(c)return w(c);throw f(o,`Cron job "${r}" references "${o.getText()}", which is neither a function (internal.file.fn / api.file.fn) nor a declared workflow in lunora/workflows.ts nor a declared agent in lunora/agents.ts.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500})}return{functionPath:C(e,t,r)}},j=/^@lunora\/scheduler:\s*/u,U=(e,t)=>{const r=_(e,1);if(r===void 0)throw f(e,`Cron job "${t}" must pass a string-literal cron expression to ".cron(...)".`,{code:"CRON_EXPR_NOT_STATIC",name:"LunoraError",status:500});if(!I(r))throw f(e,`Cron job "${t}" has an invalid cron expression "${r}" — expected 5 or 6 space-separated fields.`,{code:"CRON_EXPR_INVALID",name:"LunoraError",status:500});return O(r,`cron expression for job "${t}"`),r},M=(e,t,r)=>{const n=e.getArguments()[1];if(!n||!i.isObjectLiteralExpression(n))throw f(e,`Cron job "${r}" must pass an object-literal schedule to ".${t}(...)".`,{code:"CRON_SCHEDULE_NOT_STATIC",name:"LunoraError",status:500});try{return S(t,p(n,r),r)}catch(s){if(s instanceof R)throw s;const o=s instanceof Error?s.message.replace(j,""):String(s);throw f(e,o,{code:"CRON_SCHEDULE_INVALID",name:"LunoraError",status:500})}},K=(e,t,r,n,s)=>{const o=t.getName();if(!D.has(o)||!r.has(V(t.getExpression())??""))return;const a=_(e,0);if(a===void 0||a.trim()==="")throw f(e,`A cron ".${o}(...)" registration must pass a non-empty string-literal name as its first argument.`,{code:"CRON_NAME_NOT_STATIC",name:"LunoraError",status:500});const c=o==="cron"?U(e,a):M(e,o,a),u=k(e,2,a,n,s),l=e.getArguments()[3];return{args:l&&i.isObjectLiteralExpression(l)?p(l,a):{},cron:c,name:a,...u}},z=e=>{const t=new Set;for(const r of e){if(t.has(r.name))throw new x("DUPLICATE_CRON_NAME",`Duplicate cron job name "${r.name}": cron names must be unique across the project.`,{status:500});t.add(r.name)}},Y=(e,t,r=[],n=[])=>{const s=y(t),o=[],a=new Map(r.map(u=>[u.exportName,u])),c=new Map(n.map(u=>[u.exportName,u]));for(const u of s){const l=e.getSourceFile(u)??e.addSourceFileAtPath(u),g=F(l);if(g.size!==0)for(const d of l.getDescendantsOfKind(m.CallExpression)){const N=d.getExpression();if(!i.isPropertyAccessExpression(N))continue;const E=K(d,N,g,a,c);E&&o.push(E)}}return o.sort((u,l)=>u.name.localeCompare(l.name)),z(o),o};export{Y as default};
@@ -1 +1 @@
1
- import{LunoraError as d}from"@lunora/errors";import{Node as s,SyntaxKind as T}from"ts-morph";import{d as w}from"./declared-output-Iaar469J.mjs";import{findObjectProperty as m,bindingKeyName as k,listLunoraSourceFiles as C,lunoraRelativePath as I}from"./isTestPath-Cdv_LoVU.mjs";import{e as R,i as F}from"./attribution-RI-H1KPm.mjs";import{u as E,p as _,c as A,r as z}from"./unwrap-handler-return-Bfz7lH0C.mjs";import{b as v,s as V,c as $}from"./classify-procedure-call-C5JY2w5V.mjs";import{r as N,p as O,a as j}from"./parse-validator-BqDQLzDZ.mjs";import{s as M}from"./dispatch-namespace-DwTjD7BU.mjs";const D=t=>{const i=t.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))return"unknown";const e=m(i,"handler");if(!e||!s.isPropertyAssignment(e))return"unknown";const r=e.getInitializer();return!r||!(s.isArrowFunction(r)||s.isFunctionExpression(r))?"unknown":E(r)},W=t=>{const i=t.getArguments()[0];return!i||!(s.isArrowFunction(i)||s.isFunctionExpression(i))?"unknown":E(i)},H=t=>{let i={};for(const e of v(t)){if(e.name!=="input")continue;const r=e.call.getArguments()[0],n=r!==void 0&&s.isExpression(r)?N(r):void 0;n!==void 0&&(i={...O(n),...i})}return i},B=t=>{const i=v(t).find(r=>r.name==="output");if(!i)return;const e=i.call.getArguments()[0];return e&&s.isExpression(e)?_(i.call,()=>j(e)):void 0},L=(t,i)=>{const e=m(t,i);if(e===void 0||!s.isPropertyAssignment(e))return;const r=e.getInitializer();return r!==void 0&&s.isStringLiteral(r)?r.getLiteralValue():void 0},P=(t,i)=>{const e=m(t,i);if(e===void 0||!s.isPropertyAssignment(e))return;const r=e.getInitializer();return r!==void 0&&s.isNumericLiteral(r)?r.getLiteralValue():void 0},K=t=>{const i=m(t,"cache");if(i===void 0||!s.isPropertyAssignment(i))return;const e=i.getInitializer();if(e===void 0||!s.isObjectLiteralExpression(e))return;const r=L(e,"scope"),n=P(e,"maxAge"),o=P(e,"staleWhileRevalidate"),a=L(e,"tag"),l=L(e,"vary"),c={...n===void 0?{}:{maxAge:n},...r==="private"||r==="public"?{scope:r}:{},...o===void 0?{}:{staleWhileRevalidate:o},...a===void 0?{}:{tag:a},...l===void 0?{}:{vary:l}};return Object.keys(c).length===0?void 0:c},U=t=>{if(t===void 0||!s.isObjectLiteralExpression(t))return{};const i=K(t),e=m(t,"rest");return e!==void 0&&s.isPropertyAssignment(e)?{...i===void 0?{}:{cache:i},rest:e.getInitializer()?.getText()==="true"}:i===void 0?{}:{cache:i}},q=t=>{const i=v(t).find(e=>e.name==="expose");return i?U(i.call.getArguments()[0]):void 0},J=t=>{const i=v(t).find(o=>o.name==="x402");if(!i)return;const e=i.call.getArguments()[0];if(e===void 0||!s.isObjectLiteralExpression(e))return{};const r=m(e,"price");if(r===void 0||!s.isPropertyAssignment(r))return{};const n=r.getInitializer();return n===void 0?{}:s.isStringLiteral(n)?{price:n.getLiteralValue()}:s.isNumericLiteral(n)?{price:n.getLiteralValue()}:{}},X=t=>{const i=t.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))return{};const e=m(i,"args");if(!e||!s.isPropertyAssignment(e))return{};const r=e.getInitializer(),n=r===void 0?void 0:N(r);return n===void 0?{}:O(n)},p=(t,i)=>{throw new d("INTERNAL",`@lunora/codegen: lazy function registry needs literal ${i} in ${t.getSourceFile().getFilePath()}:${String(t.getStartLineNumber())}`)},b=(t,i,e)=>{if(!t||!s.isObjectLiteralExpression(t))return p(i,"metadata objects");const r=new Set;for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))return p(n,"metadata fields without spreads, getters, or shorthand");const o=n.getNameNode(),a=s.isStringLiteral(o)?o.getLiteralValue():o.getText();if(!s.isIdentifier(o)&&!s.isStringLiteral(o)||!e.includes(a)||r.has(a))return p(n,"supported, unique metadata fields");r.add(a)}return t},f=(t,i)=>{const e=t.getProperty(i);return e&&s.isPropertyAssignment(e)?e.getInitializer():void 0},G=t=>{const i=b(t,t,["credentialHeaders","maxAge","scope","staleWhileRevalidate","tag","vary"]),e={};for(const o of["maxAge","staleWhileRevalidate"]){const a=f(i,o);if(!(a===void 0&&o!=="maxAge")){if(!a||!s.isNumericLiteral(a))return p(t,`cache.${o}`);e[o]=a.getLiteralValue()}}const r=f(i,"scope");if(!r||!s.isStringLiteral(r)||!["private","public"].includes(r.getLiteralValue()))return p(t,"cache.scope");e.scope=r.getLiteralValue();for(const o of["tag","vary"]){const a=f(i,o);if(a!==void 0){if(!s.isStringLiteral(a))return p(a,`cache.${o}`);e[o]=a.getLiteralValue()}}const n=f(i,"credentialHeaders");if(n!==void 0){if(!s.isArrayLiteralExpression(n))return p(n,"cache.credentialHeaders");e.credentialHeaders=n.getElements().map(o=>s.isStringLiteral(o)?o.getLiteralValue():p(o,"cache.credentialHeaders string entries"))}return e},Q=t=>{const i=b(t.getArguments()[0],t,["rest","cache"]),e=f(i,"rest"),r=f(i,"cache");return e!==void 0&&!s.isTrueLiteral(e)&&!s.isFalseLiteral(e)?p(e,".expose({ rest })"):{...e?{rest:s.isTrueLiteral(e)}:{},...r?{cache:G(r)}:{}}},Y=t=>{const i=b(t.getArguments()[0],t,["price"]),e=f(i,"price");return!e||!s.isStringLiteral(e)&&!s.isNumericLiteral(e)?p(t,"`.x402({ price })` value"):{price:e.getLiteralValue()}},Z=t=>{const{factory:i,steps:e}=V(t);if(!i)return p(t,"metadata from a resolvable Lunora factory root");const r={visibility:i.startsWith("internal")?"internal":"public"};for(const{call:n,name:o}of e){if(!["expose","input","meta","output","use","x402"].includes(o))return p(n,`known builder modifiers, got .${o}()`);o==="expose"&&r.expose===void 0&&(r.expose=Q(n)),o==="x402"&&r.x402===void 0&&(r.x402=Y(n))}return r},ee=8,h=(t,i=0)=>{if(i>ee)return;if(s.isCallExpression(t))return t;if(s.isParenthesizedExpression(t)||s.isAsExpression(t)||s.isSatisfiesExpression(t)||s.isNonNullExpression(t))return h(t.getExpression(),i+1);if(!s.isIdentifier(t)&&!s.isPropertyAccessExpression(t))return;const e=t.getSymbol()?.getValueDeclaration();return e?x(e,i+1):void 0},x=(t,i)=>{if(s.isVariableDeclaration(t)||s.isPropertyAssignment(t)){const e=t.getInitializer();return e?h(e,i):void 0}if(s.isShorthandPropertyAssignment(t)){const e=t.getValueSymbol()?.getValueDeclaration();return e?x(e,i+1):void 0}if(s.isBindingElement(t)){const e=k(t),o=t.getFirstAncestorByKind(T.VariableDeclaration)?.getInitializer()?.getType().getProperty(e)?.getValueDeclaration();return o?x(o,i+1):void 0}},te=(t,i=()=>!0)=>{const e=t.getNameNode();if(s.isObjectBindingPattern(e)){const o=[];for(const a of e.getElements().filter(l=>i(l.getName()))){const l=h(a.getNameNode());l&&o.push([a.getName(),l])}return o}if(!i(t.getName()))return[];const r=t.getInitializer(),n=r&&(s.isCallExpression(r)?r:h(r));return n?[[t.getName(),n]]:[]},ie=t=>{const i=t.getArguments()[0],e=s.isObjectLiteralExpression(i)?i.getProperty("name"):void 0,r=s.isPropertyAssignment(e)?e.getInitializer():void 0;if(!r||!s.isStringLiteral(r))throw new d("ROOM_NAME_NOT_LITERAL",'defineRoom needs a string-literal `name` (e.g. `defineRoom({ name: "chat", … })`) so codegen can type its reference.');return r.getLiteralValue()},re=t=>t.startsWith("/")&&new URL(t,"https://lunora.invalid").pathname===t&&t!=="/_lunora"&&!t.startsWith("/_lunora/"),ne=t=>{const i=t.getArguments()[0];if(!s.isObjectLiteralExpression(i))throw new d("SOCKET_PATH_NOT_LITERAL","defineWebSocket needs an object-literal options argument so codegen can read its `path` and `auth`.");const e=i.getProperty("path"),r=s.isPropertyAssignment(e)?e.getInitializer():void 0;if(!r||!s.isStringLiteral(r))throw new d("SOCKET_PATH_NOT_LITERAL",'defineWebSocket needs a string-literal `path` (e.g. `defineWebSocket({ path: "/chat", … })`) so codegen can route its upgrade.');const n=r.getLiteralValue();if(!re(n))throw new d("SOCKET_PATH_INVALID",`defineWebSocket path "${n}" must be a plain URL path starting with "/" (no "?", "#", ".." or unencoded characters) and not under "/_lunora".`);if(i.getProperties().some(c=>s.isSpreadAssignment(c)||s.isPropertyAssignment(c)&&s.isComputedPropertyName(c.getNameNode())))throw new d("SOCKET_AUTH_NOT_LITERAL","defineWebSocket cannot spread its options or use a computed key: codegen must read `auth` as a literal `auth: true` or `auth: false`.");const a=i.getProperty("auth");if(a===void 0)return{auth:!1,path:n};const l=s.isPropertyAssignment(a)?a.getInitializer():void 0;if(l===void 0||!(s.isTrueLiteral(l)||s.isFalseLiteral(l)))throw new d("SOCKET_AUTH_NOT_LITERAL","defineWebSocket needs a literal `auth: true` or `auth: false`, so codegen can read whether the route requires a session. A shorthand or a variable is not read.");return{auth:s.isTrueLiteral(l),path:n}},se=(t,i,e,r)=>{const n=r?Z(i):void 0,o=r?n?.expose:q(i),a=r?n?.x402:J(i),l=A(()=>B(i)),c=A(()=>W(t)),u=w({kind:e.kind,output:l.value});return z(u?l.erased:c.erased),{args:H(i),...o?{expose:o}:{},...a?{x402:a}:{},...e.adminOnly?{adminOnly:!0}:{},kind:e.kind,...l.value?{output:l.value}:{},returnType:c.value,visibility:n?.visibility==="internal"||e.visibility==="internal"?"internal":"public"}},oe=(t,i)=>{const e=$(t,i);if(!e)return;if(e.channel)return{args:{},channel:{kind:e.channel,name:ie(t)},kind:e.kind,returnType:"void",visibility:e.visibility};const{receiver:r}=e;return r?se(t,r,e,i):e.lifecycle?{args:{},kind:e.kind,lifecycle:e.lifecycle,returnType:"void",...e.lifecycle==="socket"?{socket:{...ne(t),origin:`${t.getSourceFile().getFilePath()}@${String(t.getStart())}`}}:{},visibility:e.visibility}:{args:X(t),kind:e.kind,returnType:D(t),visibility:e.visibility}},S=(t,i,e,r)=>{const n=oe(t,r);if(n)return{args:n.args,exportName:i,filePath:e,kind:n.kind,returnType:n.returnType,...n.output?{output:n.output}:{},visibility:n.visibility,...n.adminOnly?{adminOnly:!0}:{},...n.expose?{expose:n.expose}:{},...n.x402?{x402:n.x402}:{},...n.lifecycle?{lifecycle:n.lifecycle}:{},...n.channel?{channel:n.channel}:{},...n.socket?{socket:n.socket}:{}}},ae=(t,i,e)=>{const r=[];for(const n of t.getExportAssignments()){if(n.isExportEquals())continue;const o=h(n.getExpression()),a=o?S(o,"default",i,e):void 0;o&&a&&r.push({call:o,entry:a})}return r},ce=(t,i,e)=>{const r=R(t),n=new Map,o=(c,u)=>{if(c?.channel?.kind!=="room")return;const g=n.get(c.channel.name);if(g!==void 0&&g!==u)throw new d("DUPLICATE_ROOM_NAME",`Duplicate room name "${c.channel.name}" in ${i}: two defineRoom calls share it. Room names must be unique.`);n.set(c.channel.name,u)},a=t.getVariableStatements().flatMap(c=>c.getDeclarations()).flatMap(c=>te(c,u=>r.has(u))).flatMap(([c,u])=>(r.get(c)??[]).filter(g=>F(g)).flatMap(g=>{const y=S(u,g,i,e);return o(y,u),y?[y]:[]})),l=new Set(a.map(c=>c.exportName));for(const{call:c,entry:u}of ae(t,i,e))l.has(u.exportName)||(o(u,c),a.push(u));return a},le=t=>{const i=new Map;for(const e of t){if(e.channel?.kind!=="room")continue;const r=i.get(e.channel.name);if(r!==void 0&&r.file!==e.filePath)throw new d("DUPLICATE_ROOM_NAME",`Duplicate room name "${e.channel.name}": defined in ${r.origin} and ${e.filePath}:${e.exportName}. Room names must be unique across the project.`);r===void 0&&i.set(e.channel.name,{file:e.filePath,origin:`${e.filePath}:${e.exportName}`})}},ue=t=>{const i=new Map;for(const e of t){const r=M(e.filePath),n=i.get(r);if(n&&n!==e.filePath)throw Object.assign(new Error(`Namespace collision: "${n}" and "${e.filePath}" both resolve to "${r}". Rename one of the files so the JS-identifier-sanitized names differ. (note: case-insensitive filesystems may also cause this — \`foo\` and \`FOO\` map to the same identifier)`),{code:"NAMESPACE_COLLISION",name:"LunoraError",paths:[n,e.filePath],status:500});i.set(r,e.filePath)}},xe=(t,i,e={})=>{const r=C(i),n=[];for(const o of r){const a=t.getSourceFile(o)??t.addSourceFileAtPath(o),l=I(i,o);n.push(...ce(a,l,e.lazyFunctions===!0))}return n.sort((o,a)=>`${o.filePath}:${o.exportName}`.localeCompare(`${a.filePath}:${a.exportName}`)),ue(n),le(n),n};export{xe as default};
1
+ import{LunoraError as d}from"@lunora/errors";import{Node as s,SyntaxKind as T}from"ts-morph";import{d as w}from"./declared-output-Iaar469J.mjs";import{findObjectProperty as m,bindingKeyName as k,listLunoraSourceFiles as C,lunoraRelativePath as I}from"./isTestPath-C3QumE88.mjs";import{e as R,i as F}from"./attribution-CG8-kUcl.mjs";import{u as E,p as _,c as A,r as z}from"./unwrap-handler-return-CGdJGvGh.mjs";import{b as v,s as V,c as $}from"./classify-procedure-call-BkaeM9Ej.mjs";import{r as N,p as O,a as j}from"./parse-validator-iVTounLK.mjs";import{s as M}from"./dispatch-namespace-DwTjD7BU.mjs";const D=t=>{const i=t.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))return"unknown";const e=m(i,"handler");if(!e||!s.isPropertyAssignment(e))return"unknown";const r=e.getInitializer();return!r||!(s.isArrowFunction(r)||s.isFunctionExpression(r))?"unknown":E(r)},W=t=>{const i=t.getArguments()[0];return!i||!(s.isArrowFunction(i)||s.isFunctionExpression(i))?"unknown":E(i)},H=t=>{let i={};for(const e of v(t)){if(e.name!=="input")continue;const r=e.call.getArguments()[0],n=r!==void 0&&s.isExpression(r)?N(r):void 0;n!==void 0&&(i={...O(n),...i})}return i},B=t=>{const i=v(t).find(r=>r.name==="output");if(!i)return;const e=i.call.getArguments()[0];return e&&s.isExpression(e)?_(i.call,()=>j(e)):void 0},L=(t,i)=>{const e=m(t,i);if(e===void 0||!s.isPropertyAssignment(e))return;const r=e.getInitializer();return r!==void 0&&s.isStringLiteral(r)?r.getLiteralValue():void 0},P=(t,i)=>{const e=m(t,i);if(e===void 0||!s.isPropertyAssignment(e))return;const r=e.getInitializer();return r!==void 0&&s.isNumericLiteral(r)?r.getLiteralValue():void 0},K=t=>{const i=m(t,"cache");if(i===void 0||!s.isPropertyAssignment(i))return;const e=i.getInitializer();if(e===void 0||!s.isObjectLiteralExpression(e))return;const r=L(e,"scope"),n=P(e,"maxAge"),o=P(e,"staleWhileRevalidate"),a=L(e,"tag"),l=L(e,"vary"),c={...n===void 0?{}:{maxAge:n},...r==="private"||r==="public"?{scope:r}:{},...o===void 0?{}:{staleWhileRevalidate:o},...a===void 0?{}:{tag:a},...l===void 0?{}:{vary:l}};return Object.keys(c).length===0?void 0:c},U=t=>{if(t===void 0||!s.isObjectLiteralExpression(t))return{};const i=K(t),e=m(t,"rest");return e!==void 0&&s.isPropertyAssignment(e)?{...i===void 0?{}:{cache:i},rest:e.getInitializer()?.getText()==="true"}:i===void 0?{}:{cache:i}},q=t=>{const i=v(t).find(e=>e.name==="expose");return i?U(i.call.getArguments()[0]):void 0},J=t=>{const i=v(t).find(o=>o.name==="x402");if(!i)return;const e=i.call.getArguments()[0];if(e===void 0||!s.isObjectLiteralExpression(e))return{};const r=m(e,"price");if(r===void 0||!s.isPropertyAssignment(r))return{};const n=r.getInitializer();return n===void 0?{}:s.isStringLiteral(n)?{price:n.getLiteralValue()}:s.isNumericLiteral(n)?{price:n.getLiteralValue()}:{}},X=t=>{const i=t.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))return{};const e=m(i,"args");if(!e||!s.isPropertyAssignment(e))return{};const r=e.getInitializer(),n=r===void 0?void 0:N(r);return n===void 0?{}:O(n)},p=(t,i)=>{throw new d("INTERNAL",`@lunora/codegen: lazy function registry needs literal ${i} in ${t.getSourceFile().getFilePath()}:${String(t.getStartLineNumber())}`)},b=(t,i,e)=>{if(!t||!s.isObjectLiteralExpression(t))return p(i,"metadata objects");const r=new Set;for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))return p(n,"metadata fields without spreads, getters, or shorthand");const o=n.getNameNode(),a=s.isStringLiteral(o)?o.getLiteralValue():o.getText();if(!s.isIdentifier(o)&&!s.isStringLiteral(o)||!e.includes(a)||r.has(a))return p(n,"supported, unique metadata fields");r.add(a)}return t},f=(t,i)=>{const e=t.getProperty(i);return e&&s.isPropertyAssignment(e)?e.getInitializer():void 0},G=t=>{const i=b(t,t,["credentialHeaders","maxAge","scope","staleWhileRevalidate","tag","vary"]),e={};for(const o of["maxAge","staleWhileRevalidate"]){const a=f(i,o);if(!(a===void 0&&o!=="maxAge")){if(!a||!s.isNumericLiteral(a))return p(t,`cache.${o}`);e[o]=a.getLiteralValue()}}const r=f(i,"scope");if(!r||!s.isStringLiteral(r)||!["private","public"].includes(r.getLiteralValue()))return p(t,"cache.scope");e.scope=r.getLiteralValue();for(const o of["tag","vary"]){const a=f(i,o);if(a!==void 0){if(!s.isStringLiteral(a))return p(a,`cache.${o}`);e[o]=a.getLiteralValue()}}const n=f(i,"credentialHeaders");if(n!==void 0){if(!s.isArrayLiteralExpression(n))return p(n,"cache.credentialHeaders");e.credentialHeaders=n.getElements().map(o=>s.isStringLiteral(o)?o.getLiteralValue():p(o,"cache.credentialHeaders string entries"))}return e},Q=t=>{const i=b(t.getArguments()[0],t,["rest","cache"]),e=f(i,"rest"),r=f(i,"cache");return e!==void 0&&!s.isTrueLiteral(e)&&!s.isFalseLiteral(e)?p(e,".expose({ rest })"):{...e?{rest:s.isTrueLiteral(e)}:{},...r?{cache:G(r)}:{}}},Y=t=>{const i=b(t.getArguments()[0],t,["price"]),e=f(i,"price");return!e||!s.isStringLiteral(e)&&!s.isNumericLiteral(e)?p(t,"`.x402({ price })` value"):{price:e.getLiteralValue()}},Z=t=>{const{factory:i,steps:e}=V(t);if(!i)return p(t,"metadata from a resolvable Lunora factory root");const r={visibility:i.startsWith("internal")?"internal":"public"};for(const{call:n,name:o}of e){if(!["expose","input","meta","output","use","x402"].includes(o))return p(n,`known builder modifiers, got .${o}()`);o==="expose"&&r.expose===void 0&&(r.expose=Q(n)),o==="x402"&&r.x402===void 0&&(r.x402=Y(n))}return r},ee=8,h=(t,i=0)=>{if(i>ee)return;if(s.isCallExpression(t))return t;if(s.isParenthesizedExpression(t)||s.isAsExpression(t)||s.isSatisfiesExpression(t)||s.isNonNullExpression(t))return h(t.getExpression(),i+1);if(!s.isIdentifier(t)&&!s.isPropertyAccessExpression(t))return;const e=t.getSymbol()?.getValueDeclaration();return e?x(e,i+1):void 0},x=(t,i)=>{if(s.isVariableDeclaration(t)||s.isPropertyAssignment(t)){const e=t.getInitializer();return e?h(e,i):void 0}if(s.isShorthandPropertyAssignment(t)){const e=t.getValueSymbol()?.getValueDeclaration();return e?x(e,i+1):void 0}if(s.isBindingElement(t)){const e=k(t),o=t.getFirstAncestorByKind(T.VariableDeclaration)?.getInitializer()?.getType().getProperty(e)?.getValueDeclaration();return o?x(o,i+1):void 0}},te=(t,i=()=>!0)=>{const e=t.getNameNode();if(s.isObjectBindingPattern(e)){const o=[];for(const a of e.getElements().filter(l=>i(l.getName()))){const l=h(a.getNameNode());l&&o.push([a.getName(),l])}return o}if(!i(t.getName()))return[];const r=t.getInitializer(),n=r&&(s.isCallExpression(r)?r:h(r));return n?[[t.getName(),n]]:[]},ie=t=>{const i=t.getArguments()[0],e=s.isObjectLiteralExpression(i)?i.getProperty("name"):void 0,r=s.isPropertyAssignment(e)?e.getInitializer():void 0;if(!r||!s.isStringLiteral(r))throw new d("ROOM_NAME_NOT_LITERAL",'defineRoom needs a string-literal `name` (e.g. `defineRoom({ name: "chat", … })`) so codegen can type its reference.');return r.getLiteralValue()},re=t=>t.startsWith("/")&&new URL(t,"https://lunora.invalid").pathname===t&&t!=="/_lunora"&&!t.startsWith("/_lunora/"),ne=t=>{const i=t.getArguments()[0];if(!s.isObjectLiteralExpression(i))throw new d("SOCKET_PATH_NOT_LITERAL","defineWebSocket needs an object-literal options argument so codegen can read its `path` and `auth`.");const e=i.getProperty("path"),r=s.isPropertyAssignment(e)?e.getInitializer():void 0;if(!r||!s.isStringLiteral(r))throw new d("SOCKET_PATH_NOT_LITERAL",'defineWebSocket needs a string-literal `path` (e.g. `defineWebSocket({ path: "/chat", … })`) so codegen can route its upgrade.');const n=r.getLiteralValue();if(!re(n))throw new d("SOCKET_PATH_INVALID",`defineWebSocket path "${n}" must be a plain URL path starting with "/" (no "?", "#", ".." or unencoded characters) and not under "/_lunora".`);if(i.getProperties().some(c=>s.isSpreadAssignment(c)||s.isPropertyAssignment(c)&&s.isComputedPropertyName(c.getNameNode())))throw new d("SOCKET_AUTH_NOT_LITERAL","defineWebSocket cannot spread its options or use a computed key: codegen must read `auth` as a literal `auth: true` or `auth: false`.");const a=i.getProperty("auth");if(a===void 0)return{auth:!1,path:n};const l=s.isPropertyAssignment(a)?a.getInitializer():void 0;if(l===void 0||!(s.isTrueLiteral(l)||s.isFalseLiteral(l)))throw new d("SOCKET_AUTH_NOT_LITERAL","defineWebSocket needs a literal `auth: true` or `auth: false`, so codegen can read whether the route requires a session. A shorthand or a variable is not read.");return{auth:s.isTrueLiteral(l),path:n}},se=(t,i,e,r)=>{const n=r?Z(i):void 0,o=r?n?.expose:q(i),a=r?n?.x402:J(i),l=A(()=>B(i)),c=A(()=>W(t)),u=w({kind:e.kind,output:l.value});return z(u?l.erased:c.erased),{args:H(i),...o?{expose:o}:{},...a?{x402:a}:{},...e.adminOnly?{adminOnly:!0}:{},kind:e.kind,...l.value?{output:l.value}:{},returnType:c.value,visibility:n?.visibility==="internal"||e.visibility==="internal"?"internal":"public"}},oe=(t,i)=>{const e=$(t,i);if(!e)return;if(e.channel)return{args:{},channel:{kind:e.channel,name:ie(t)},kind:e.kind,returnType:"void",visibility:e.visibility};const{receiver:r}=e;return r?se(t,r,e,i):e.lifecycle?{args:{},kind:e.kind,lifecycle:e.lifecycle,returnType:"void",...e.lifecycle==="socket"?{socket:{...ne(t),origin:`${t.getSourceFile().getFilePath()}@${String(t.getStart())}`}}:{},visibility:e.visibility}:{args:X(t),kind:e.kind,returnType:D(t),visibility:e.visibility}},S=(t,i,e,r)=>{const n=oe(t,r);if(n)return{args:n.args,exportName:i,filePath:e,kind:n.kind,returnType:n.returnType,...n.output?{output:n.output}:{},visibility:n.visibility,...n.adminOnly?{adminOnly:!0}:{},...n.expose?{expose:n.expose}:{},...n.x402?{x402:n.x402}:{},...n.lifecycle?{lifecycle:n.lifecycle}:{},...n.channel?{channel:n.channel}:{},...n.socket?{socket:n.socket}:{}}},ae=(t,i,e)=>{const r=[];for(const n of t.getExportAssignments()){if(n.isExportEquals())continue;const o=h(n.getExpression()),a=o?S(o,"default",i,e):void 0;o&&a&&r.push({call:o,entry:a})}return r},ce=(t,i,e)=>{const r=R(t),n=new Map,o=(c,u)=>{if(c?.channel?.kind!=="room")return;const g=n.get(c.channel.name);if(g!==void 0&&g!==u)throw new d("DUPLICATE_ROOM_NAME",`Duplicate room name "${c.channel.name}" in ${i}: two defineRoom calls share it. Room names must be unique.`);n.set(c.channel.name,u)},a=t.getVariableStatements().flatMap(c=>c.getDeclarations()).flatMap(c=>te(c,u=>r.has(u))).flatMap(([c,u])=>(r.get(c)??[]).filter(g=>F(g)).flatMap(g=>{const y=S(u,g,i,e);return o(y,u),y?[y]:[]})),l=new Set(a.map(c=>c.exportName));for(const{call:c,entry:u}of ae(t,i,e))l.has(u.exportName)||(o(u,c),a.push(u));return a},le=t=>{const i=new Map;for(const e of t){if(e.channel?.kind!=="room")continue;const r=i.get(e.channel.name);if(r!==void 0&&r.file!==e.filePath)throw new d("DUPLICATE_ROOM_NAME",`Duplicate room name "${e.channel.name}": defined in ${r.origin} and ${e.filePath}:${e.exportName}. Room names must be unique across the project.`);r===void 0&&i.set(e.channel.name,{file:e.filePath,origin:`${e.filePath}:${e.exportName}`})}},ue=t=>{const i=new Map;for(const e of t){const r=M(e.filePath),n=i.get(r);if(n&&n!==e.filePath)throw Object.assign(new Error(`Namespace collision: "${n}" and "${e.filePath}" both resolve to "${r}". Rename one of the files so the JS-identifier-sanitized names differ. (note: case-insensitive filesystems may also cause this — \`foo\` and \`FOO\` map to the same identifier)`),{code:"NAMESPACE_COLLISION",name:"LunoraError",paths:[n,e.filePath],status:500});i.set(r,e.filePath)}},xe=(t,i,e={})=>{const r=C(i),n=[];for(const o of r){const a=t.getSourceFile(o)??t.addSourceFileAtPath(o),l=I(i,o);n.push(...ce(a,l,e.lazyFunctions===!0))}return n.sort((o,a)=>`${o.filePath}:${o.exportName}`.localeCompare(`${a.filePath}:${a.exportName}`)),ue(n),le(n),n};export{xe as default};
@@ -1 +1 @@
1
- import{Node as n}from"ts-morph";import{a as m,p as l}from"./parse-validator-BqDQLzDZ.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./isTestPath-Cdv_LoVU.mjs";import{b as f,d as g}from"./attribution-RI-H1KPm.mjs";import{u as x}from"./unwrap-handler-return-Bfz7lH0C.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}},b=(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},T=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=b(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:T(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-iVTounLK.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./isTestPath-C3QumE88.mjs";import{b as f,d as g}from"./attribution-CG8-kUcl.mjs";import{u as x}from"./unwrap-handler-return-CGdJGvGh.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}},b=(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},T=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=b(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:T(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-dFjpeIlP.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-Cdv_LoVU.mjs";import{c as a}from"./attribution-RI-H1KPm.mjs";import{i as c}from"./database-calls-BNoSJRFy.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-C3QumE88.mjs";import{c as a}from"./attribution-CG8-kUcl.mjs";import{i as c}from"./database-calls-UPlhi3Ks.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-C3QumE88.mjs";import"./attribution-CG8-kUcl.mjs";import"./database-calls-UPlhi3Ks.mjs";import"./classify-procedure-call-BkaeM9Ej.mjs";import{d as a}from"./index-CN8FVvr-.mjs";export{a as default};
@@ -1 +1 @@
1
- import{SyntaxKind as f,Node as s}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as u}from"./module-specifiers-BctA0m_p.mjs";import{listLunoraSourceFiles as m,lunoraRelativePath as p,findObjectProperty as h}from"./isTestPath-Cdv_LoVU.mjs";import{b as I,a as b}from"./attribution-RI-H1KPm.mjs";const P=r=>{const i=r.getSymbol();if(!i)return r.getText()==="defineMigration";for(const t of i.getDeclarations())if(s.isImportSpecifier(t))return u(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMigration":!1;return!1},d=(r,i)=>{const t=h(r,i);if(!t||!s.isPropertyAssignment(t))return;const e=t.getInitializer();return e&&s.isStringLiteral(e)?e.getLiteralValue():void 0},v=(r,i)=>{const t=r.getInitializer();if(t?.getKind()!==f.CallExpression)return;const e=t.getExpression();if(!s.isIdentifier(e)||!P(e))return;const o=t.getArguments()[0];if(!o||!s.isObjectLiteralExpression(o))return;const n=d(o,"id"),a=b(r,"member");if(a!==void 0){if(n===void 0||n.trim()==="")throw g(o,`Migration "${a}" in "${i}" must declare \`id\` as a non-empty string literal so codegen can key the registry.`,{code:"MIGRATION_ID_NOT_STATIC",name:"LunoraError",status:500});return{exportName:a,filePath:i,id:n,table:d(o,"table")??""}}},M=r=>{const i=new Map;for(const t of r){const e=i.get(t.id);if(e!==void 0)throw Object.assign(new Error(`Duplicate migration id "${t.id}": declared in both "${e}" and "${t.filePath}". Migration ids must be unique across the project.`),{code:"DUPLICATE_MIGRATION_ID",id:t.id,name:"LunoraError",paths:[e,t.filePath],status:500});i.set(t.id,t.filePath)}},E=(r,i)=>{const t=m(i),e=[];for(const o of t){const n=r.getSourceFile(o)??r.addSourceFileAtPath(o),a=p(i,o);for(const l of I(n)){const c=v(l,a);c&&e.push(c)}}return e.sort((o,n)=>o.id.localeCompare(n.id)),M(e),e};export{E as default};
1
+ import{SyntaxKind as f,Node as s}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as u}from"./module-specifiers-BctA0m_p.mjs";import{listLunoraSourceFiles as m,lunoraRelativePath as p,findObjectProperty as h}from"./isTestPath-C3QumE88.mjs";import{b as I,a as b}from"./attribution-CG8-kUcl.mjs";const P=r=>{const i=r.getSymbol();if(!i)return r.getText()==="defineMigration";for(const t of i.getDeclarations())if(s.isImportSpecifier(t))return u(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMigration":!1;return!1},d=(r,i)=>{const t=h(r,i);if(!t||!s.isPropertyAssignment(t))return;const e=t.getInitializer();return e&&s.isStringLiteral(e)?e.getLiteralValue():void 0},v=(r,i)=>{const t=r.getInitializer();if(t?.getKind()!==f.CallExpression)return;const e=t.getExpression();if(!s.isIdentifier(e)||!P(e))return;const o=t.getArguments()[0];if(!o||!s.isObjectLiteralExpression(o))return;const n=d(o,"id"),a=b(r,"member");if(a!==void 0){if(n===void 0||n.trim()==="")throw g(o,`Migration "${a}" in "${i}" must declare \`id\` as a non-empty string literal so codegen can key the registry.`,{code:"MIGRATION_ID_NOT_STATIC",name:"LunoraError",status:500});return{exportName:a,filePath:i,id:n,table:d(o,"table")??""}}},M=r=>{const i=new Map;for(const t of r){const e=i.get(t.id);if(e!==void 0)throw Object.assign(new Error(`Duplicate migration id "${t.id}": declared in both "${e}" and "${t.filePath}". Migration ids must be unique across the project.`),{code:"DUPLICATE_MIGRATION_ID",id:t.id,name:"LunoraError",paths:[e,t.filePath],status:500});i.set(t.id,t.filePath)}},E=(r,i)=>{const t=m(i),e=[];for(const o of t){const n=r.getSourceFile(o)??r.addSourceFileAtPath(o),a=p(i,o);for(const l of I(n)){const c=v(l,a);c&&e.push(c)}}return e.sort((o,n)=>o.id.localeCompare(n.id)),M(e),e};export{E as default};
@@ -1 +1 @@
1
- import{Node as s,SyntaxKind as r}from"ts-morph";import{listLunoraSourceFiles as a,lunoraRelativePath as l,handlerOf as c}from"./isTestPath-Cdv_LoVU.mjs";import{b as d,d as f}from"./attribution-RI-H1KPm.mjs";import{c as u}from"./classify-procedure-call-C5JY2w5V.mjs";const m={"crypto.getRandomValues":"crypto.getRandomValues","crypto.randomUUID":"crypto.randomUUID","Date.now":"Date.now","Math.random":"Math.random"},p=new Set(["globalThis","self"]),g=new Set(["globalThis","self","window"]),h=e=>{if(s.isIdentifier(e))return e.getText();if(s.isPropertyAccessExpression(e)){const t=e.getExpression();if(s.isIdentifier(t)&&g.has(t.getText()))return e.getName()}},x=e=>{const t=e.getExpression();if(s.isIdentifier(t)){const i=t.getText();return i==="fetch"||i==="Date"?i:void 0}if(!s.isPropertyAccessExpression(t))return;const n=t.getName(),o=h(t.getExpression());if(o!==void 0)return n==="fetch"&&p.has(o)?"fetch":m[`${o}.${n}`]},N=e=>{const t=e.getExpression();if(!s.isIdentifier(t)||t.getText()!=="Date")return;const n=e.getArguments(),o=n.every(i=>s.isNumericLiteral(i)||s.isStringLiteral(i)||s.isNoSubstitutionTemplateLiteral(i));return n.length>0&&o?void 0:"new Date"},E=e=>{const t=e.getInitializer();if(!t||!s.isCallExpression(t))return;const n=u(t);if(!n||n.kind!=="query"&&n.kind!=="mutation")return;const o=c(t,n.receiver);return o?{exportName:f(e)??e.getName(),handler:o,kind:n.kind}:void 0},S=(e,t)=>{const n=[];for(const o of e.handler.getDescendantsOfKind(r.CallExpression)){const i=x(o);i!==void 0&&n.push({callee:i,exportName:e.exportName,file:t,kind:e.kind,line:o.getStartLineNumber()})}for(const o of e.handler.getDescendantsOfKind(r.NewExpression)){const i=N(o);i!==void 0&&n.push({callee:i,exportName:e.exportName,file:t,kind:e.kind,line:o.getStartLineNumber()})}return n},v=(e,t)=>{const n=[];for(const o of d(e)){const i=E(o);i&&n.push(...S(i,t))}return n},T=(e,t)=>{const n=[];for(const o of a(t)){const i=e.getSourceFile(o)??e.addSourceFileAtPath(o);n.push(...v(i,l(t,o)))}return n};export{T as default};
1
+ import{Node as s,SyntaxKind as r}from"ts-morph";import{listLunoraSourceFiles as a,lunoraRelativePath as l,handlerOf as c}from"./isTestPath-C3QumE88.mjs";import{b as d,d as f}from"./attribution-CG8-kUcl.mjs";import{c as u}from"./classify-procedure-call-BkaeM9Ej.mjs";const m={"crypto.getRandomValues":"crypto.getRandomValues","crypto.randomUUID":"crypto.randomUUID","Date.now":"Date.now","Math.random":"Math.random"},p=new Set(["globalThis","self"]),g=new Set(["globalThis","self","window"]),h=e=>{if(s.isIdentifier(e))return e.getText();if(s.isPropertyAccessExpression(e)){const t=e.getExpression();if(s.isIdentifier(t)&&g.has(t.getText()))return e.getName()}},x=e=>{const t=e.getExpression();if(s.isIdentifier(t)){const i=t.getText();return i==="fetch"||i==="Date"?i:void 0}if(!s.isPropertyAccessExpression(t))return;const n=t.getName(),o=h(t.getExpression());if(o!==void 0)return n==="fetch"&&p.has(o)?"fetch":m[`${o}.${n}`]},N=e=>{const t=e.getExpression();if(!s.isIdentifier(t)||t.getText()!=="Date")return;const n=e.getArguments(),o=n.every(i=>s.isNumericLiteral(i)||s.isStringLiteral(i)||s.isNoSubstitutionTemplateLiteral(i));return n.length>0&&o?void 0:"new Date"},E=e=>{const t=e.getInitializer();if(!t||!s.isCallExpression(t))return;const n=u(t);if(!n||n.kind!=="query"&&n.kind!=="mutation")return;const o=c(t,n.receiver);return o?{exportName:f(e)??e.getName(),handler:o,kind:n.kind}:void 0},S=(e,t)=>{const n=[];for(const o of e.handler.getDescendantsOfKind(r.CallExpression)){const i=x(o);i!==void 0&&n.push({callee:i,exportName:e.exportName,file:t,kind:e.kind,line:o.getStartLineNumber()})}for(const o of e.handler.getDescendantsOfKind(r.NewExpression)){const i=N(o);i!==void 0&&n.push({callee:i,exportName:e.exportName,file:t,kind:e.kind,line:o.getStartLineNumber()})}return n},v=(e,t)=>{const n=[];for(const o of d(e)){const i=E(o);i&&n.push(...S(i,t))}return n},T=(e,t)=>{const n=[];for(const o of a(t)){const i=e.getSourceFile(o)??e.addSourceFileAtPath(o);n.push(...v(i,l(t,o)))}return n};export{T as default};
@@ -1 +1 @@
1
- import{Node as i,SyntaxKind as u}from"ts-morph";import{collectCallRows as x}from"./isTestPath-Cdv_LoVU.mjs";import{w as E,c as h}from"./attribution-RI-H1KPm.mjs";import{i as v}from"./database-calls-BNoSJRFy.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-C3QumE88.mjs";import{w as E,c as h}from"./attribution-CG8-kUcl.mjs";import{i as v}from"./database-calls-UPlhi3Ks.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-dFjpeIlP.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 x,lunoraRelativePath as h,findObjectProperty as m,stringPropertyOf as c}from"./isTestPath-Cdv_LoVU.mjs";import{e as A}from"./exported-procedure-chains-Bol_VtzO.mjs";import{r as L}from"./chain-C9qZxjM_.mjs";const E=new Set(["delete","insert","read","update"]),P=(e,t,i)=>{const r=e.getArguments()[0];if(!r||!o.isArrayLiteralExpression(r))return[];const s=[];for(const n of r.getElements()){if(!o.isObjectLiteralExpression(n))continue;const a=c(n,"on");a===void 0||!E.has(a)||s.push({file:t,on:a,procedure:i,table:c(n,"table")??""})}return s},u=e=>{if(!o.isObjectLiteralExpression(e))return[];const t=m(e,"permissions");if(!t||!o.isPropertyAssignment(t))return[];const i=t.getInitializer();if(!i||!o.isArrayLiteralExpression(i))return[];const r=[];for(const s of i.getElements()){if(o.isStringLiteral(s)){r.push(s.getLiteralText());continue}if(o.isCallExpression(s)){const n=s.getArguments()[0];n&&o.isStringLiteral(n)&&r.push(n.getLiteralText())}}return r},f=(e,t)=>t===void 0?e:{...e,description:t},v=e=>{if(o.isCallExpression(e)){const t=e.getArguments()[0];if(!t||!o.isStringLiteral(t))return;const i=e.getArguments()[1],r=i?c(i,"description"):void 0,s=i?u(i):[];return f({name:t.getLiteralText(),permissions:s},r)}if(o.isObjectLiteralExpression(e)){const t=c(e,"name");return t===void 0?void 0:f({name:t,permissions:u(e)},c(e,"description"))}},y=e=>{const t=e.getArguments()[1];if(!t||!o.isObjectLiteralExpression(t))return[];const i=m(t,"roles");if(!i||!o.isPropertyAssignment(i))return[];const r=i.getInitializer();if(!r||!o.isArrayLiteralExpression(r))return[];const s=[];for(const n of r.getElements()){const a=v(n);a&&s.push(a)}return s},O=(e,t,i)=>{const r=L(e);return{policies:r.flatMap(s=>P(s,t,i)),roles:r.flatMap(s=>y(s))}},I=(e,t)=>{const i=[],r=new Map;for(const s of x(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),a=h(t,s);for(const{name:g,receiver:d}of A(n)){const p=O(d,a,g);i.push(...p.policies);for(const l of p.roles)r.has(l.name)||r.set(l.name,l)}}return{policies:i,roles:[...r.values()]}};export{I as default};
1
+ import{Node as o}from"ts-morph";import{listLunoraSourceFiles as x,lunoraRelativePath as h,findObjectProperty as m,stringPropertyOf as c}from"./isTestPath-C3QumE88.mjs";import{e as A}from"./exported-procedure-chains-D1WlRfqJ.mjs";import{r as L}from"./chain-74gjwZMP.mjs";const E=new Set(["delete","insert","read","update"]),P=(e,t,i)=>{const r=e.getArguments()[0];if(!r||!o.isArrayLiteralExpression(r))return[];const s=[];for(const n of r.getElements()){if(!o.isObjectLiteralExpression(n))continue;const a=c(n,"on");a===void 0||!E.has(a)||s.push({file:t,on:a,procedure:i,table:c(n,"table")??""})}return s},u=e=>{if(!o.isObjectLiteralExpression(e))return[];const t=m(e,"permissions");if(!t||!o.isPropertyAssignment(t))return[];const i=t.getInitializer();if(!i||!o.isArrayLiteralExpression(i))return[];const r=[];for(const s of i.getElements()){if(o.isStringLiteral(s)){r.push(s.getLiteralText());continue}if(o.isCallExpression(s)){const n=s.getArguments()[0];n&&o.isStringLiteral(n)&&r.push(n.getLiteralText())}}return r},f=(e,t)=>t===void 0?e:{...e,description:t},v=e=>{if(o.isCallExpression(e)){const t=e.getArguments()[0];if(!t||!o.isStringLiteral(t))return;const i=e.getArguments()[1],r=i?c(i,"description"):void 0,s=i?u(i):[];return f({name:t.getLiteralText(),permissions:s},r)}if(o.isObjectLiteralExpression(e)){const t=c(e,"name");return t===void 0?void 0:f({name:t,permissions:u(e)},c(e,"description"))}},y=e=>{const t=e.getArguments()[1];if(!t||!o.isObjectLiteralExpression(t))return[];const i=m(t,"roles");if(!i||!o.isPropertyAssignment(i))return[];const r=i.getInitializer();if(!r||!o.isArrayLiteralExpression(r))return[];const s=[];for(const n of r.getElements()){const a=v(n);a&&s.push(a)}return s},O=(e,t,i)=>{const r=L(e);return{policies:r.flatMap(s=>P(s,t,i)),roles:r.flatMap(s=>y(s))}},I=(e,t)=>{const i=[],r=new Map;for(const s of x(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),a=h(t,s);for(const{name:g,receiver:d}of A(n)){const p=O(d,a,g);i.push(...p.policies);for(const l of p.roles)r.has(l.name)||r.set(l.name,l)}}return{policies:i,roles:[...r.values()]}};export{I as default};
@@ -1 +1 @@
1
- import{Node as o}from"ts-morph";import{listLunoraSourceFiles as c,lunoraRelativePath as f,findObjectProperty as u}from"./isTestPath-Cdv_LoVU.mjs";import{b as p,d}from"./attribution-RI-H1KPm.mjs";import{t as m}from"./database-calls-BNoSJRFy.mjs";import{c as b}from"./classify-procedure-call-C5JY2w5V.mjs";import{r as h}from"./chain-C9qZxjM_.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}=m(e,v,x);return{exportName:d(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-C3QumE88.mjs";import{b as p,d}from"./attribution-CG8-kUcl.mjs";import{t as m}from"./database-calls-UPlhi3Ks.mjs";import{c as b}from"./classify-procedure-call-BkaeM9Ej.mjs";import{r as h}from"./chain-74gjwZMP.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}=m(e,v,x);return{exportName:d(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 +1 @@
1
- import{listLunoraSourceFiles as d}from"./isTestPath-Cdv_LoVU.mjs";const f=new Set(["@lunora/agent","@lunora/agent/sandbox"]),t={browserTool:"usesSandboxBrowser",containerFsTool:"usesSandboxContainer",containerTool:"usesSandboxContainer",fsTool:"usesSandboxFs",jsCodeTool:"usesSandboxLoader"},u=()=>({usesSandboxBrowser:!1,usesSandboxContainer:!1,usesSandboxFs:!1,usesSandboxLoader:!1}),i=o=>{const s=u();if(!f.has(o.getModuleSpecifierValue())||o.isTypeOnly())return s;for(const e of o.getNamedImports()){if(e.isTypeOnly())continue;const n=t[e.getNameNode().getText()];n!==void 0&&(s[n]=!0)}return s},b=(o,s)=>{const e=u();for(const n of d(s)){const c=o.getSourceFile(n)??o.addSourceFileAtPath(n);for(const a of c.getImportDeclarations()){const l=i(a);for(const r of Object.values(t))e[r]||=l[r]}if(Object.values(t).every(a=>e[a]))break}return e};export{b as discoverSandboxUsage,u as noSandboxUsage,i as scanImportDeclaration};
1
+ import{listLunoraSourceFiles as d}from"./isTestPath-C3QumE88.mjs";const f=new Set(["@lunora/agent","@lunora/agent/sandbox"]),t={browserTool:"usesSandboxBrowser",containerFsTool:"usesSandboxContainer",containerTool:"usesSandboxContainer",fsTool:"usesSandboxFs",jsCodeTool:"usesSandboxLoader"},u=()=>({usesSandboxBrowser:!1,usesSandboxContainer:!1,usesSandboxFs:!1,usesSandboxLoader:!1}),i=o=>{const s=u();if(!f.has(o.getModuleSpecifierValue())||o.isTypeOnly())return s;for(const e of o.getNamedImports()){if(e.isTypeOnly())continue;const n=t[e.getNameNode().getText()];n!==void 0&&(s[n]=!0)}return s},b=(o,s)=>{const e=u();for(const n of d(s)){const c=o.getSourceFile(n)??o.addSourceFileAtPath(n);for(const a of c.getImportDeclarations()){const l=i(a);for(const r of Object.values(t))e[r]||=l[r]}if(Object.values(t).every(a=>e[a]))break}return e};export{b as discoverSandboxUsage,u as noSandboxUsage,i as scanImportDeclaration};
@@ -0,0 +1 @@
1
+ import{LunoraError as C}from"@lunora/errors";import{Node as i,SyntaxKind as B}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{createRequire as V}from"node:module";import{join as _}from"node:path";import{fileURLToPath as q}from"node:url";import{createJiti as J}from"jiti";import{findObjectProperty as u}from"./isTestPath-C3QumE88.mjs";import{r as U,p as K}from"./parse-validator-iVTounLK.mjs";import{R as W}from"./reserved-words-CW1QFbTd.mjs";import{a as w}from"./property-name-7cBlgK_O.mjs";const Z=(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.`,G=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}},X=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}:{}}),g=e=>{const t=e?._meta??{},n=e?.kind??"unknown",s={column:X(t.column),kind:n};switch(n){case"array":case"optional":{s.inner=g(t.inner);break}case"from":break;case"id":{s.tableName=t.tableName;break}case"literal":{s.literalValue=G(t.value);break}case"object":{const r=t.shape??{};s.shape=Object.fromEntries(Object.entries(r).map(([o,a])=>[o,g(a)]));break}case"record":{s.valueType=g(t.valueValidator),t.keyValidator!==void 0&&(s.keyType=g(t.keyValidator));break}case"storage":{typeof t.bucket=="string"&&(s.bucket=t.bucket);break}case"union":{const r=t.members??[];s.members=r.map(o=>g(o));break}}return s},H=e=>e?.kind==="global"?"global":e?.kind==="shardBy"&&typeof e.field=="string"?{field:e.field,kind:"shardBy"}:"root",Q=(e,t)=>{const n=[];e.relationMap&&Object.keys(e.relationMap).length>0&&n.push("relations"),e.rankIndexes&&e.rankIndexes.length>0&&n.push("rank indexes"),e.vectorIndexes&&e.vectorIndexes.length>0&&n.push("vector indexes"),n.length>0&&console.warn(`@lunora/codegen: package schema-extension table "${t}" declares ${n.join(" + ")}, which are not yet introspected from a node_modules extension — they will be absent from the generated types.`)},Y=(e,t)=>{const n=e.shape??{},s=(e.indexes??[]).map(r=>({fields:r.fields,name:r.name,...r.unique?{unique:!0}:{}}));return Q(e,t),{...e.isExternallyManaged?{externallyManaged:!0}:{},geoIndexes:[],indexes:s,name:t,rankIndexes:[],relations:[],searchIndexes:(e.searchIndexes??[]).map(r=>({field:r.field,...r.filterFields?{filterFields:r.filterFields}:{},...r.language===void 0?{}:{language:r.language},...r.staged===void 0?{}:{staged:r.staged},...r.strategy===void 0?{}:{strategy:r.strategy},name:r.name})),shape:Object.fromEntries(Object.entries(n).map(([r,o])=>[r,g(o)])),shardMode:H(e.shardMode),vectorIndexes:[]}},ee=e=>{const{key:t,tables:n}=e;if(typeof t!="string"||typeof n!="object"||n===null)return;const s=Object.entries(n).map(([a,l])=>Y(l,a)),r=e.vectorIndexes??{},o=Object.entries(r??{}).map(([a,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:a,table:l.table??""}));return{bareTables:s,bareVectorIndexes:o,key:t}},te=e=>{if(i.isIdentifier(e))return e.getText();if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return i.isIdentifier(t)?t.getText():void 0}},ne=e=>{const t=te(e);if(t===void 0)return;const n=i.isPropertyAccessExpression(e)?e.getName():void 0,s=n===void 0?[]:[n];for(const r of e.getSourceFile().getImportDeclarations()){const o=r.getModuleSpecifierValue();for(const a of r.getNamedImports())if((a.getAliasNode()?.getText()??a.getName())===t)return{importedName:a.getName(),moduleSpecifier:o,propertyPath:s};if(r.getDefaultImport()?.getText()===t)return{importedName:"default",moduleSpecifier:o,propertyPath:s};if(r.getNamespaceImport()?.getText()===t&&n!==void 0)return{importedName:n,moduleSpecifier:o,propertyPath:[]}}},re=(e,t)=>{let n=e[t.importedName];for(const s of t.propertyPath){if(typeof n!="object"||n===null)return;n=n[s]}return n},se=(e,t)=>{const n=ne(e);if(n)try{const s=J(_(t,"noop.js")).esmResolve(n.moduleSpecifier),r=V(_(t,"noop.cjs"))(s.startsWith("file:")?q(s):s),o=re(r,n);return typeof o!="object"||o===null?void 0:ee(o)}catch{return}},ie=new Set(["cosine","dot-product","euclidean"]),b=(e,t)=>{const n=u(e,t);if(n&&i.isPropertyAssignment(n))return n.getInitializer()},f=(e,t)=>{const n=b(e,t);if(n&&i.isStringLiteral(n))return n.getLiteralText()},y=(e,t)=>{const n=b(e,t);if(n&&i.isNumericLiteral(n))return Number(n.getLiteralText())},N=(e,t)=>{const n=b(e,t);if(n&&(i.isTrueLiteral(n)||i.isFalseLiteral(n)))return n.getLiteralValue()},v=(e,t)=>{const n=b(e,t);if(n&&i.isArrayLiteralExpression(n))return n.getElements().filter(s=>i.isStringLiteral(s)).map(s=>s.getLiteralText())},P=e=>e&&ie.has(e)?e:void 0,E=e=>e&&i.isStringLiteral(e)?e.getLiteralText():"_unnamed_",oe=(e,t)=>{const n=v(e,t);return n!==void 0&&n.length>0?n:void 0},j=(e,t,n,s,r)=>{let o=e;for(;;){const a=o.getParent();if(!a||!i.isPropertyAccessExpression(a))break;const l=a.getParent();if(!l||!i.isCallExpression(l))break;if(a.getName()===t){const d=l.getArguments()[0];if(!d||!i.isStringLiteral(d))throw c(l,`\`.${t}(...)\` expects a string literal (${r})`);const m=d.getLiteralText();if(!s.has(m))throw c(d,`unknown ${n} ${JSON.stringify(m)} — expected ${r}`);return m}o=l}},ae=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.`,le=/^(?:sqlite_|_cf_|__)/u,ce=/__(?:agg|rank|geo|fts)_/u,de=e=>le.test(e)||ce.test(e),fe=new Set(["cascade","restrict","set null"]),ue=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"]),$=/^[A-Za-z_$][\w$]*$/u,k=(e,t)=>{if(ue.has(e))throw c(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(W.has(e))throw c(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(!$.test(e))throw c(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(de(e))throw c(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.`)},pe=e=>e&&fe.has(e)?e:void 0,ge=e=>{if(!i.isArrowFunction(e))return;let t=e.getBody();if(i.isParenthesizedExpression(t))t=t.getExpression();else if(i.isBlock(t)){const n=t.getStatements().find(s=>i.isReturnStatement(s));t=n&&i.isReturnStatement(n)?n.getExpression()??t:t}return i.isObjectLiteralExpression(t)?t:void 0},me=(e,t,n)=>{const s=i.isPropertyAssignment(e)?e.getInitializer():void 0;if(!s||!i.isObjectLiteralExpression(s))throw c(e,"relation `through` must be an object literal `{ table, from, to }` — codegen resolves it statically.");const[r,o,a]=["table","from","to"].map(l=>f(s,l));if(r===void 0||o===void 0||a===void 0)throw c(s,"relation `through` needs string-literal `table`, `from` and `to` — codegen resolves them statically.");if(o===a)throw c(s,`relation \`through\` has \`from\` and \`to\` both set to "${o}"; a link needs two different columns.`);return{kind:"many",name:t,table:n,through:{from:o,table:r,to:a}}},he=(e,t,n,s)=>{const r=s&&i.isObjectLiteralExpression(s)?s:void 0,o=e==="many"?r?.getProperty("through"):void 0;return o?me(o,t,n):{field:(r&&f(r,"field"))??"_unknown_",kind:e,name:t,onDelete:e==="one"&&r?pe(f(r,"onDelete")):void 0,references:(r&&f(r,"references"))??"_id",table:n}},be=e=>{if(!i.isPropertyAssignment(e))return;const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const n=t.getExpression();if(!i.isPropertyAccessExpression(n))return;const s=n.getName();if(s!=="one"&&s!=="many")return;const[r,o]=t.getArguments();if(!r||!i.isStringLiteral(r))throw c(r??t,`relation target table must be a string literal — codegen resolves relation targets statically. Got ${r?r.getText():"no argument"}.`);const a=r.getLiteralText();return he(s,w(e),a,o)},xe=e=>{const t=ge(e);if(!t)return[];const n=[];for(const s of t.getProperties()){const r=be(s);r&&n.push(r)}return n},ye=(e,t,n)=>{if(!t.includes("."))return;const[s="",...r]=t.split("."),o=`${s}${r.map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join("")}`;throw c(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. \`${o}\`), index that instead, and keep it in sync with a table \`.triggers()\` beforeInsert/beforeUpdate.`)},ve=e=>{if(!e||!i.isObjectLiteralExpression(e))return!1;const t=u(e,"unique");if(!t||!i.isPropertyAssignment(t))return!1;const n=t.getInitializer();if(n===void 0)return!1;if(!i.isTrueLiteral(n)&&!i.isFalseLiteral(n))throw c(n,`\`unique\` must be a literal \`true\` or \`false\`, got ${JSON.stringify(n.getText())}`);return i.isTrueLiteral(n)},Ee=e=>{const[t,n,s]=e,r=ve(s),o=E(t),a=n&&i.isArrayLiteralExpression(n)?n.getElements():[];for(const d of a)if(!i.isStringLiteral(d))throw c(d,`index "${o}" lists a non-literal field (${JSON.stringify(d.getText())}); codegen reads index fields statically, so every entry must be a string literal.`);const l=a.filter(d=>i.isStringLiteral(d));for(const d of l)ye(d,d.getLiteralText(),o);return{fields:l.map(d=>d.getLiteralText()),name:o,unique:r}},Ie=e=>{const[t,n]=e;let s="_unknown_",r,o,a,l;return n&&i.isObjectLiteralExpression(n)&&(s=f(n,"field")??s,r=v(n,"filterFields"),o=f(n,"language"),a=N(n,"staged"),l=f(n,"strategy")),{field:s,filterFields:r,language:o,name:E(t),staged:a,strategy:l}},we=e=>{const[t,n]=e;let s="_unknown_",r;return n&&i.isObjectLiteralExpression(n)&&(s=f(n,"field")??s,r=y(n,"precision")),{field:s,name:E(t),precision:r}},ke=e=>{const[t,n]=e,s=t&&i.isStringLiteral(t)?t.getLiteralText():"_unknown_";let r;return n&&i.isObjectLiteralExpression(n)&&(r=y(n,"after")),{after:r,field:s}},Se=e=>{if(!i.isObjectLiteralExpression(e))return;const t=f(e,"field");return t===void 0?void 0:{direction:f(e,"direction")==="desc"?"desc":"asc",field:t}},Te=e=>{const[t,n]=e;let s=[],r;if(n&&i.isObjectLiteralExpression(n)){const o=u(n,"sortBy");if(o&&i.isPropertyAssignment(o)){const a=o.getInitializer();a&&i.isArrayLiteralExpression(a)&&(s=a.getElements().map(l=>Se(l)).filter(l=>l!==void 0))}r=v(n,"partitionBy")}return{name:E(t),partitionBy:r,sortBy:s}},Oe=(e,t)=>{const[n,s]=e,r=n&&i.isStringLiteral(n)?n.getLiteralText():"_unknown_";if(!(!s||!i.isObjectLiteralExpression(s)))return{dimensions:y(s,"dimensions"),field:r,metadata:v(s,"metadata"),metric:P(f(s,"metric")),name:f(s,"index")??"_unnamed_",table:t}},_e=e=>{const t=e[0];return t&&i.isObjectLiteralExpression(t)&&f(t,"backend")==="hyperdrive"?"hyperdrive":"d1"},A=(e,t)=>{if(e===void 0)return t;if(!i.isObjectLiteralExpression(e))throw c(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=u(e,"field");if(n===void 0)return t;const s=i.isPropertyAssignment(n)?n.getInitializer():void 0;if(s&&i.isStringLiteral(s))return s.getLiteralText();throw c(n,"`field` must be a string literal — codegen reads the column name from the source and cannot evaluate a constant or an expression here.")},Ae=e=>{const t=e[0];return!t||!i.isObjectLiteralExpression(t)?{binding:"",hasTenantBy:!1,unanalyzable:!0}:{binding:f(t,"binding")??"",columns:oe(t,"columns"),hasReconcile:u(t,"reconcileEveryMs")!==void 0,hasSoftDelete:u(t,"softDeleteColumn")!==void 0,hasTenantBy:u(t,"tenantBy")!==void 0,idColumn:f(t,"idColumn"),mode:f(t,"mode"),query:f(t,"query")}},Le=(e,t,n,s)=>{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(we(n));break}case"global":{e.shardMode="global",e.globalBackend=_e(n);break}case"index":{e.indexes.push(Ee(n));break}case"memory":{e.memory=!0;break}case"public":{e.isPublic=!0;break}case"rankIndex":{e.rankIndexes.push(Te(n));break}case"relations":{const r=n[0];r&&e.relations.push(...xe(r));break}case"searchIndex":{e.searchIndexes.push(Ie(n));break}case"shardBy":{const r=n[0];e.shardMode={field:r&&i.isStringLiteral(r)?r.getLiteralText():"_unknown_",kind:"shardBy"};break}case"softDelete":{e.softDelete={field:A(n[0],"deletedAt")};break}case"source":{e.externalSource=Ae(n),e.externallyManaged=!0;break}case"timestamps":{e.timestampsFields.push(A(n[0],"updatedAt"));break}case"ttl":{e.ttl=ke(n);break}case"vectorize":{const r=Oe(n,s);r&&e.vectorIndexes.push(r);break}}},L=["__vocab","_config","_content","_data","_docsize","_idx"],Ne=(e,t,n)=>{const s=new Set(n.map(r=>r.name));for(const r of n)for(const o of L){const a=`${r.name}${o}`;if(!s.has(a))continue;const l=o==="__vocab"?`the \`fts5vocab\` companion for "${a}" is created \`IF NOT EXISTS\`, so it silently resolves to "${r.name}"'s — the second index then reads the wrong vocabulary and returns wrong results, with no error`:`creating "${a}" is rejected (\`object name reserved for internal use: SQLITE_ERROR\`), which aborts the shard migration and leaves every sharded table unreadable`;throw c(e,`table "${t}" declares search indexes "${r.name}" and "${a}", whose generated FTS5 tables collide: "${r.name}" already owns "${t}__fts_${a}" as its "${o}" companion, so ${l}. Rename one of them so neither ends with another's name plus ${L.join(", ")}.`)}},Pe=(e,t,n)=>{if(n.ttl!==void 0&&n.shardMode==="global")throw c(e,ae(t))},je=(e,t,n)=>{const{softDelete:s,timestampsFields:r}=n,o={};s&&!(s.field in t)&&(o[s.field]={inner:{column:{notNull:!1},kind:"number"},kind:"optional"});const[a]=r;if(a===void 0)return{...t,...o};if(r.length>1)throw c(e,"`.timestamps()` was called more than once; one table tracks one last-change column.");if(a===s?.field)throw c(e,`\`.softDelete()\` and \`.timestamps()\` both use "${a}"; give one of them another field.`);const l=t[a];if(l===void 0)o[a]={column:{hasDefault:!0,hasOnUpdate:!0,notNull:!0},kind:"timestamp"};else if(l.kind!=="timestamp"||l.column?.hasOnUpdate!==!0||l.column.hasDefault!==!0)throw c(e,`\`.timestamps()\` would add "${a}", 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,...o}},D=(e,t)=>{const n={aggregateIndexed:!1,commitOrdered:!1,externallyManaged:!1,geoIndexes:[],indexes:[],isPublic:!1,memory:!1,rankIndexes:[],relations:[],searchIndexes:[],shardMode:"root",timestampsFields:[],vectorIndexes:[]};let s={},r=e;for(;i.isCallExpression(r);){const o=r.getExpression(),a=r.getArguments();if(i.isPropertyAccessExpression(o))Le(n,o.getName(),a,t),r=o.getExpression();else if(i.isIdentifier(o)&&o.getText()==="defineTable"){const l=a[0];if(l&&i.isObjectLiteralExpression(l))s=K(l);else if(l)throw c(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 s=je(e,s,n),Ne(e,t,n.searchIndexes),Pe(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:s,shardMode:n.shardMode,softDelete:n.softDelete,ttl:n.ttl,vectorIndexes:n.vectorIndexes}},z=(e,t=[],n=new Set,s=new Set)=>{s.add(e);for(const r of e.getProperties()){if(i.isSpreadAssignment(r)){const a=U(r.getExpression());a!==void 0&&!s.has(a)&&z(a,t,n,s);continue}if(!i.isPropertyAssignment(r))continue;const o=r.getInitializer();if(o){const a=w(r);if(k(a,r.getNameNode()),n.has(a))throw c(r.getNameNode(),`defineSchema({...}): table "${a}" is declared more than once — the earlier declaration would be silently discarded. Remove the duplicate.`);n.add(a),t.push(D(o,a))}}return t},$e=e=>{const t=u(e,"source");if(t&&i.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&i.isObjectLiteralExpression(n))return f(n,"table")??"_unknown_"}return"_unknown_"},De=e=>{if(!i.isPropertyAssignment(e))return;const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const n=t.getExpression();if(!i.isIdentifier(n)||n.getText()!=="defineVectorIndex")return;const s=t.getArguments()[0];if(!s||!i.isObjectLiteralExpression(s))return;const r=e.getNameNode(),o=i.isStringLiteral(r)?r.getLiteralText():r.getText();return{dimensions:y(s,"dimensions"),metric:P(f(s,"metric")),name:o,table:$e(s)}},F=e=>{const t=[];for(const n of e.getProperties()){const s=De(n);s&&t.push(s)}return t},S=(e,t)=>`${e}_${t}`,ze=(e,t)=>{if(!$.test(e))throw c(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.`)},h=(e,t,n)=>n.has(e)?S(t,e):e,x=(e,t)=>{const n=s=>s===void 0?void 0:x(s,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(s=>x(s,t))},...e.shape===void 0?{}:{shape:Object.fromEntries(Object.entries(e.shape).map(([s,r])=>[s,x(r,t)]))}}},Fe=(e,t,n,s)=>{const r=S(t,e.name);return{...e,extensionKey:t,...s?{extensionFromPackage:!0}:{},name:r,shape:Object.fromEntries(Object.entries(e.shape).map(([o,a])=>[o,x(a,l=>h(l,t,n))])),relations:e.relations.map(o=>{const a=h(o.table,t,n);return o.through===void 0?{...o,table:a}:{...o,table:a,through:{...o.through,table:h(o.through.table,t,n)}}}),vectorIndexes:e.vectorIndexes.map(o=>({...o,table:h(o.table,t,n)}))}},Me=e=>{if(i.isVariableDeclaration(e)||i.isPropertyAssignment(e))return e.getInitializer();if(i.isShorthandPropertyAssignment(e))return e.getNameNode()},Re=e=>{if(!i.isCallExpression(e))return!1;const t=e.getExpression();return i.isIdentifier(t)&&t.getText()==="defineSchemaExtension"},Ce=e=>{if(i.isIdentifier(e))return e;if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return i.isIdentifier(t)?t:void 0}},Be=e=>{if(i.isObjectLiteralExpression(e))return e;if(i.isCallExpression(e)){const t=e.getExpression();let n;if(i.isIdentifier(t)?n=t.getText():i.isPropertyAccessExpression(t)&&(n=t.getName()),n==="definePlugin"){const s=e.getArguments()[1];return s&&i.isObjectLiteralExpression(s)?s:void 0}}},Ve=(e,t)=>{const n=Me(e);if(n){if(i.isPropertyAccessExpression(t)){const s=Be(n);return s?b(s,t.getName()):void 0}return n}},qe=e=>{let t=e,n=0;for(;t&&n<32;){if(n+=1,Re(t))return t;const s=Ce(t),r=s&&i.isIdentifier(s)?s.getSymbol():void 0,a=(r?.getAliasedSymbol()?.getDeclarations()??r?.getDeclarations()??[])[0];if(!a)return;const l=a.getSourceFile();if(l.isInNodeModules()||l.isDeclarationFile())return;t=Ve(a,t)}},Je=e=>{const[t,n]=e.getArguments();if(!(!t||!i.isStringLiteral(t))&&!(!n||!i.isObjectLiteralExpression(n)))return{key:t.getLiteralText(),keyNode:t,options:n}},Ue=e=>{const t=u(e,"tables");if(!t||!i.isPropertyAssignment(t))return[];const n=t.getInitializer();if(!n||!i.isObjectLiteralExpression(n))return[];const s=[];for(const r of n.getProperties()){if(!i.isPropertyAssignment(r))continue;const o=r.getInitializer();if(!o)continue;const a=w(r);k(a,r.getNameNode()),s.push(D(o,a))}return s},Ke=e=>{const t=u(e,"vectorIndexes");if(!t||!i.isPropertyAssignment(t))return[];const n=t.getInitializer();return!n||!i.isObjectLiteralExpression(n)?[]:F(n)},M=(e,t,n,s,r)=>{ze(e,s);const o=new Set(t.map(d=>d.name)),a=t.map(d=>Fe(d,e,o,r)),l=n.map(d=>({...d,name:S(e,d.name),table:h(d.table,e,o)}));return{tables:a,vectorIndexes:l}},We=(e,t,n)=>M(e,Ue(n),Ke(n),t,t.getSourceFile().getFilePath().includes("/node_modules/")),Ze=(e,t)=>{const n=e.getArguments()[0];if(!n)return;const s=qe(n);if(!s){if(t!==void 0){const o=se(n,t);if(o){for(const a of o.bareTables)k(a.name,n);return M(o.key,o.bareTables,o.bareVectorIndexes,n,!0)}}console.warn(`@lunora/codegen: skipping \`.extend(${n.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.`);return}const r=Je(s);if(!r){console.warn("@lunora/codegen: skipping `.extend(...)` — `defineSchemaExtension` requires a string `key` and an options object literal.");return}return We(r.key,r.keyNode,r.options)},Ge=e=>{const t=[];let n=e;for(;;){const s=n.getParent();if(!s||!i.isPropertyAccessExpression(s))break;const r=s.getParent();if(!r||!i.isCallExpression(r))break;s.getName()==="extend"&&t.push(r),n=r}return t},Xe=(e,t,n)=>{const s=new Set(t.map(o=>o.name)),r=[];for(const o of Ge(e)){const a=Ze(o,n);if(a){for(const l of a.tables){if(s.has(l.name))throw c(o,`defineSchema(...).extend(...): table "${l.name}" already exists — another extension with the same key already contributed it.`);s.add(l.name),t.push(l)}r.push(...a.vectorIndexes)}}return r},He=new Set(["eu","fedramp","us"]),Qe=e=>j(e,"jurisdiction","jurisdiction",He,'"eu", "us", or "fedramp"'),Ye=e=>{let t=e;for(;;){const n=t.getParent(),s=n?.getParent();if(!n||!i.isPropertyAccessExpression(n)||!s||!i.isCallExpression(s))return!1;if(n.getName()==="jurisdiction"){const r=s.getArguments()[1];return r!==void 0&&i.isObjectLiteralExpression(r)&&N(r,"pinAuth")===!0}t=s}},et=new Set(["required"]),tt=e=>j(e,"rls","rls mode",et,'"required"'),nt=e=>{if(!i.isObjectLiteralExpression(e))return;const t=new Set;for(const n of e.getProperties()){const s=i.isPropertyAssignment(n)?n.getInitializer():void 0;if(!s||!i.isCallExpression(s))return;const r=s.getExpression(),o=s.getArguments()[1],a=o&&i.isObjectLiteralExpression(o)?f(o,"on"):void 0;if(!i.isIdentifier(r)||r.getText()!=="defineAggregateIndex"||a===void 0)return;t.add(a)}return t},rt=(e,t)=>{if(t===void 0)return;const n=nt(t);for(const s of e)(n===void 0||n.has(s.name))&&(s.aggregateIndexed=!0)},mt=(e,t,n)=>{const r=e.addSourceFileAtPath(t).getDescendantsOfKind(B.CallExpression).find(p=>{const O=p.getExpression();return i.isIdentifier(O)&&O.getText()==="defineSchema"});if(!r)throw new C("INTERNAL",`defineSchema() not found in ${t}`);const o=r.getArguments()[0];if(!o||!i.isObjectLiteralExpression(o))throw c(r,"defineSchema() expects an object literal");const a=z(o),l=r.getArguments()[1],d=l&&i.isObjectLiteralExpression(l)?F(l):[],m=Xe(r,a,n);rt(a,r.getArguments()[2]);const T=[...a.flatMap(p=>p.vectorIndexes),...d,...m],R=new Set(a.filter(p=>p.shardMode==="global").map(p=>p.name)),I=T.find(p=>R.has(p.table));if(I)throw c(r,Z(I.table,I.name));return{jurisdiction:Qe(r),...Ye(r)?{jurisdictionPinsAuth:!0}:{},rlsMode:tt(r),tables:a,vectorIndexes:T}};export{mt as default};
@@ -1 +1 @@
1
- import{Node as u}from"ts-morph";import{listLunoraSourceFiles as f,lunoraRelativePath as p,stringPropertyOf as l}from"./isTestPath-Cdv_LoVU.mjs";import{w as d}from"./classify-procedure-call-C5JY2w5V.mjs";import{e as m}from"./exported-procedure-chains-Bol_VtzO.mjs";const h=new Set(["delete","list","read","write"]),g=t=>d(t,"use","storageRules"),x=(t,s,n)=>{const e=t.getArguments()[0];if(!e||!u.isArrayLiteralExpression(e))return[];const i=[];for(const o of e.getElements()){if(!u.isObjectLiteralExpression(o))continue;const r=l(o,"on");if(r===void 0||!h.has(r))continue;const a=l(o,"prefix"),c={bucket:l(o,"bucket")??"",file:s,on:r,procedure:n};a!==void 0&&(c.prefix=a),i.push(c)}return i},A=(t,s)=>{const n=[];for(const e of f(s)){const i=t.getSourceFile(e)??t.addSourceFileAtPath(e),o=p(s,e);for(const{name:r,receiver:a}of m(i))for(const c of g(a))n.push(...x(c,o,r))}return{rules:n}};export{A as default};
1
+ import{Node as u}from"ts-morph";import{listLunoraSourceFiles as f,lunoraRelativePath as p,stringPropertyOf as l}from"./isTestPath-C3QumE88.mjs";import{w as d}from"./classify-procedure-call-BkaeM9Ej.mjs";import{e as m}from"./exported-procedure-chains-D1WlRfqJ.mjs";const h=new Set(["delete","list","read","write"]),g=t=>d(t,"use","storageRules"),x=(t,s,n)=>{const e=t.getArguments()[0];if(!e||!u.isArrayLiteralExpression(e))return[];const i=[];for(const o of e.getElements()){if(!u.isObjectLiteralExpression(o))continue;const r=l(o,"on");if(r===void 0||!h.has(r))continue;const a=l(o,"prefix"),c={bucket:l(o,"bucket")??"",file:s,on:r,procedure:n};a!==void 0&&(c.prefix=a),i.push(c)}return i},A=(t,s)=>{const n=[];for(const e of f(s)){const i=t.getSourceFile(e)??t.addSourceFileAtPath(e),o=p(s,e);for(const{name:r,receiver:a}of m(i))for(const c of g(a))n.push(...x(c,o,r))}return{rules:n}};export{A as default};
@@ -1 +1 @@
1
- import"./json-data-Chfs2Cz5.mjs";import{o as i,j as r,s as n,h as o,t as g,k as u,d as F,w as p,m as l,g as d,f,i as k,u as w,l as A,v as Q}from"./shard-runtime-BpoCV-aM.mjs";import"./shared-DnCokNcE.mjs";import"./platform-8oj7iXQy.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,n as emitAgents,o as emitContainerFragments,g as emitContainers,u as emitPaymentFragments,F as emitQueueFragments,p as emitQueues,l as emitQueuesMetadataFragments,d as emitServiceFragments,f as emitTopicFragments,k as emitWorkflowFragments,w as emitWorkflows,A as emitWorkflowsMetadataFragments,Q as queueAliasFindings};
1
+ import"./json-data-Chfs2Cz5.mjs";import{o as i,j as r,s as n,h as o,t as g,k as u,d as F,w as p,m as l,g as d,f,i as k,u as w,l as A,v as Q}from"./shard-runtime-BW1kffN4.mjs";import"./shared-8vTRkL2-.mjs";import"./platform-8oj7iXQy.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,n as emitAgents,o as emitContainerFragments,g as emitContainers,u as emitPaymentFragments,F as emitQueueFragments,p as emitQueues,l as emitQueuesMetadataFragments,d as emitServiceFragments,f as emitTopicFragments,k as emitWorkflowFragments,w as emitWorkflows,A as emitWorkflowsMetadataFragments,Q as queueAliasFindings};
@@ -1,4 +1,4 @@
1
- import{agentComponent as N}from"@lunora/agent/component";import{LunoraError as R}from"@lunora/errors";import{r as d,a as w,b as v,c as L}from"./qualifiers-DEdXn5wP.mjs";import{a as P,r as y,p as $,G as x,b,c as m,d as S,e as j}from"./shared-DnCokNcE.mjs";import{s as h}from"./dispatch-namespace-DwTjD7BU.mjs";const O=t=>b(t,e=>{const r=d(y(e.args),e.filePath),n=d(L(e),e.filePath);return`${e.exportName}: FunctionReference<"${e.kind}", ${r}, ${n}>;`},"type"),A=(t,e)=>{if(t.length===0&&e.length===0)return{block:"",importLine:""};const r=[];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{agentComponent as N}from"@lunora/agent/component";import{LunoraError as R}from"@lunora/errors";import{r as d,a as w,b as P,c as L}from"./qualifiers-Bl5fSmav.mjs";import{a as A,r as y,p as $,G as x,b as k,c as m,d as S,e as j,i as v}from"./shared-8vTRkL2-.mjs";import{s as g}from"./dispatch-namespace-DwTjD7BU.mjs";const O=t=>k(t,e=>{const s=d(y(e.args),e.filePath),n=d(L(e),e.filePath),r=`FunctionReference<"${e.kind}", ${s}, ${n}>`;return`${e.exportName}: ${v(e)?`${r} & { readonly sensitive: true }`:r};`},"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;
@@ -6,8 +6,8 @@ export interface WorkflowReference<Params = Record<string, unknown>> {
6
6
  readonly className: string;
7
7
  readonly name: string;
8
8
  }
9
- `,t.length>0){const s=[...t].toSorted((o,i)=>o.exportName.localeCompare(i.exportName)),a=s.map(o=>` ${o.exportName}: WorkflowReference<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${o.exportName}>>;`).join(`
10
- `),l=s.map(o=>` ${m(o.exportName)}: { isLunoraWorkflow: true, className: ${JSON.stringify(o.className)}, name: ${JSON.stringify(o.exportName)} },`).join(`
9
+ `,t.length>0){const r=[...t].toSorted((o,i)=>o.exportName.localeCompare(i.exportName)),a=r.map(o=>` ${o.exportName}: WorkflowReference<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${o.exportName}>>;`).join(`
10
+ `),l=r.map(o=>` ${m(o.exportName)}: { isLunoraWorkflow: true, className: ${JSON.stringify(o.className)}, name: ${JSON.stringify(o.exportName)} },`).join(`
11
11
  `);n+=`
12
12
  /** This project's durable workflows, addressable as typed references (e.g. \`crons.daily("digest", …, workflows.digestPipeline, params)\`). */
13
13
  export interface WorkflowsRef {
@@ -17,9 +17,9 @@ ${a}
17
17
  export const workflows: WorkflowsRef = {
18
18
  ${l}
19
19
  };
20
- `,r.push(`import type * as lunoraWorkflowDefinitions from "../workflows.js";
21
- `)}if(e.length>0){const s=[...e].toSorted((o,i)=>o.exportName.localeCompare(i.exportName)),a=s.map(o=>` ${o.exportName}: WorkflowReference<AgentRunInput>;`).join(`
22
- `),l=s.map(o=>` ${m(o.exportName)}: { isLunoraWorkflow: true, className: ${JSON.stringify(o.className)}, name: ${JSON.stringify(o.name)} },`).join(`
20
+ `,s.push(`import type * as lunoraWorkflowDefinitions from "../workflows.js";
21
+ `)}if(e.length>0){const r=[...e].toSorted((o,i)=>o.exportName.localeCompare(i.exportName)),a=r.map(o=>` ${o.exportName}: WorkflowReference<AgentRunInput>;`).join(`
22
+ `),l=r.map(o=>` ${m(o.exportName)}: { isLunoraWorkflow: true, className: ${JSON.stringify(o.className)}, name: ${JSON.stringify(o.name)} },`).join(`
23
23
  `);n+=`
24
24
  /** This project's durable agents, addressable as typed references for \`cronJobs()\` — each fire starts a fresh agent run (e.g. \`crons.daily("sweep", …, agents.support, { input, threadKey })\`). */
25
25
  export interface AgentsRef {
@@ -29,8 +29,8 @@ ${a}
29
29
  export const agents: AgentsRef = {
30
30
  ${l}
31
31
  };
32
- `,r.push(`import type { AgentRunInput } from "@lunora/agent";
33
- `)}return{block:n,importLine:r.join("")}},M=()=>Object.keys(N().functions).toSorted((t,e)=>t.localeCompare(e)),C=t=>new Set(t.filter(e=>h(e.filePath)==="agents").map(e=>e.exportName)),I=()=>new Set(Object.entries(N().functions).filter(([,t])=>t.visibility==="internal").map(([t])=>t)),U=(t,e)=>{const r={importLine:"",lines:"",prelude:""};if(t.length===0)return r;const n=C(e),s=I(),a=e.find(o=>h(o.filePath)==="agents"&&s.has(o.exportName));if(a)throw new R("INTERNAL",`@lunora/codegen: "agents:${a.exportName}" is reserved for the durable agent loop's internal dispatch — rename the "${a.exportName}" export in ${a.filePath}`);const l=M().filter(o=>!n.has(o));return l.length===0?r:{importLine:`import { agentComponent } from "@lunora/agent/component";
32
+ `,s.push(`import type { AgentRunInput } from "@lunora/agent";
33
+ `)}return{block:n,importLine:s.join("")}},M=()=>Object.keys(N().functions).toSorted((t,e)=>t.localeCompare(e)),T=t=>new Set(t.filter(e=>g(e.filePath)==="agents").map(e=>e.exportName)),K=()=>new Set(Object.entries(N().functions).filter(([,t])=>t.visibility==="internal").map(([t])=>t)),G=(t,e)=>{const s={importLine:"",lines:"",prelude:""};if(t.length===0)return s;const n=T(e),r=K(),a=e.find(o=>g(o.filePath)==="agents"&&r.has(o.exportName));if(a)throw new R("INTERNAL",`@lunora/codegen: "agents:${a.exportName}" is reserved for the durable agent loop's internal dispatch — rename the "${a.exportName}" export in ${a.filePath}`);const l=M().filter(o=>!n.has(o));return l.length===0?s:{importLine:`import { agentComponent } from "@lunora/agent/component";
34
34
  `,lines:l.map(o=>` "agents:${o}": lunoraAgentRuntimeFunctions.${o} as unknown as RegisteredLunoraFunction,`).join(`
35
35
  `),prelude:`
36
36
  /**
@@ -39,41 +39,41 @@ ${l}
39
39
  * subscribe to the public queries (\`agents:agentMessages\` is the live thread view).
40
40
  */
41
41
  const lunoraAgentRuntimeFunctions = agentComponent().functions;
42
- `}},V=(t,e)=>{if(!t)return{importLine:"",lines:"",prelude:""};const r=e.find(n=>h(n.filePath)==="sandbox"&&n.exportName==="invoke");if(r)throw new R("INTERNAL",`@lunora/codegen: "sandbox:invoke" is reserved for the batteries-included sandbox tool dispatcher (browserTool/containerTool) — rename the "invoke" export in ${r.filePath}`);return{importLine:`import { sandboxComponent } from "@lunora/agent/component";
43
- `,lines:' "sandbox:invoke": lunoraSandbox.invoke as unknown as RegisteredLunoraFunction,',prelude:"\n/**\n * The `@lunora/agent` sandbox dispatcher — auto-registered because `lunora/`\n * imports a sandbox tool (`browserTool`/`containerTool`). The batteries-included\n * tools dispatch to this internal action, which runs on an action ctx carrying\n * `ctx.browser` + `ctx.containers` (the durable tool step itself has neither).\n */\nconst lunoraSandbox = sandboxComponent();\n"}},K=(t,e)=>{if(t.length===0)return[];const r=C(e),n=[{args:{key:{kind:"string"},limit:{inner:{kind:"number"},kind:"optional"}},exportName:"agentMessages",filePath:"agents",kind:"query",returnType:"Record<string, unknown>[]"},{args:{decision:{kind:"union",members:[{kind:"literal",literalValue:'"approve"'},{kind:"literal",literalValue:'"reject"'}]},instanceId:{kind:"string"},note:{inner:{kind:"string"},kind:"optional"},threadKey:{kind:"string"},toolCallId:{kind:"string"}},exportName:"agentResolveApproval",filePath:"agents",kind:"mutation",returnType:"{ resolved: boolean }"},{args:{agent:{kind:"string"},input:{kind:"string"},threadKey:{kind:"string"},title:{inner:{kind:"string"},kind:"optional"}},exportName:"agentRun",filePath:"agents",kind:"mutation",returnType:"{ id: string; threadKey: string }"},{args:{key:{kind:"string"}},exportName:"agentState",filePath:"agents",kind:"query",returnType:"Record<string, unknown> | undefined"},{args:{key:{kind:"string"}},exportName:"agentThread",filePath:"agents",kind:"query",returnType:"Record<string, unknown> | undefined"}];for(const s of t)s.voice&&n.push({args:{threadKey:{kind:"string"}},exportName:`${s.exportName}Voice`,filePath:"agents",kind:"stream",returnType:"Record<string, unknown>"});return n.filter(s=>!r.has(s.exportName))},E=(t,e)=>{if(t.length===0)return[];const r=new Set(e.filter(n=>h(n.filePath)==="mutators").map(n=>n.exportName));return t.filter(n=>!r.has(n.exportName)).map(n=>({args:n.args,exportName:n.exportName,filePath:n.filePath,kind:"mutation",returnType:n.returnType}))},F=t=>{const e=t.flatMap(s=>s.channel?.kind==="room"?[s.channel.name]:[]);if(e.length===0)return{block:"",importLine:""};const r=e.map(s=>` ${m(s)}: RoomRef<LunoraRoomMessages[${JSON.stringify(s)}]>;`).join(`
44
- `),n=e.map(s=>` ${m(s)}: { name: ${JSON.stringify(s)} },`).join(`
42
+ `}},U=(t,e)=>{if(!t)return{importLine:"",lines:"",prelude:""};const s=e.find(n=>g(n.filePath)==="sandbox"&&n.exportName==="invoke");if(s)throw new R("INTERNAL",`@lunora/codegen: "sandbox:invoke" is reserved for the batteries-included sandbox tool dispatcher (browserTool/containerTool) — rename the "invoke" export in ${s.filePath}`);return{importLine:`import { sandboxComponent } from "@lunora/agent/component";
43
+ `,lines:' "sandbox:invoke": lunoraSandbox.invoke as unknown as RegisteredLunoraFunction,',prelude:"\n/**\n * The `@lunora/agent` sandbox dispatcher — auto-registered because `lunora/`\n * imports a sandbox tool (`browserTool`/`containerTool`). The batteries-included\n * tools dispatch to this internal action, which runs on an action ctx carrying\n * `ctx.browser` + `ctx.containers` (the durable tool step itself has neither).\n */\nconst lunoraSandbox = sandboxComponent();\n"}},F=(t,e)=>{if(t.length===0)return[];const s=T(e),n=[{args:{key:{kind:"string"},limit:{inner:{kind:"number"},kind:"optional"}},exportName:"agentMessages",filePath:"agents",kind:"query",returnType:"Record<string, unknown>[]"},{args:{decision:{kind:"union",members:[{kind:"literal",literalValue:'"approve"'},{kind:"literal",literalValue:'"approve_for_thread"'},{kind:"literal",literalValue:'"reject"'}]},instanceId:{kind:"string"},note:{inner:{kind:"string"},kind:"optional"},threadKey:{kind:"string"},toolCallId:{kind:"string"}},exportName:"agentResolveApproval",filePath:"agents",kind:"mutation",returnType:"{ resolved: boolean }"},{args:{secret:{kind:"string",sensitive:!0},threadKey:{kind:"string"},toolCallId:{kind:"string"}},exportName:"agentSupplySecret",filePath:"agents",kind:"mutation",returnType:"{ resolved: boolean }"},{args:{threadKey:{kind:"string"},toolCallId:{kind:"string"}},exportName:"agentDeclineSecret",filePath:"agents",kind:"mutation",returnType:"{ resolved: boolean }"},{args:{threadKey:{kind:"string"}},exportName:"agentSecretRequests",filePath:"agents",kind:"query",returnType:'{ createdAt: number; expiresAt: number; label?: string; status: "consumed" | "declined" | "expired" | "pending" | "supplied"; toolCallId: string; toolName: string }[]'},{args:{key:{kind:"string"}},exportName:"agentApprovalGrants",filePath:"agents",kind:"query",returnType:"{ createdAt: number; toolName: string }[]"},{args:{threadKey:{kind:"string"},toolName:{kind:"string"}},exportName:"agentRevokeApprovalGrant",filePath:"agents",kind:"mutation",returnType:"{ revoked: boolean }"},{args:{agent:{kind:"string"},input:{kind:"string"},threadKey:{kind:"string"},title:{inner:{kind:"string"},kind:"optional"}},exportName:"agentRun",filePath:"agents",kind:"mutation",returnType:"{ id: string; threadKey: string }"},{args:{key:{kind:"string"}},exportName:"agentState",filePath:"agents",kind:"query",returnType:"Record<string, unknown> | undefined"},{args:{key:{kind:"string"}},exportName:"agentThread",filePath:"agents",kind:"query",returnType:"Record<string, unknown> | undefined"}];for(const r of t)r.voice&&n.push({args:{threadKey:{kind:"string"}},exportName:`${r.exportName}Voice`,filePath:"agents",kind:"stream",returnType:"Record<string, unknown>"});return n.filter(r=>!s.has(r.exportName))},E=(t,e)=>{if(t.length===0)return[];const s=new Set(e.filter(n=>g(n.filePath)==="mutators").map(n=>n.exportName));return t.filter(n=>!s.has(n.exportName)).map(n=>({args:n.args,exportName:n.exportName,filePath:n.filePath,kind:"mutation",returnType:n.returnType}))},W=t=>{const e=t.flatMap(r=>r.channel?.kind==="room"?[r.channel.name]:[]);if(e.length===0)return{block:"",importLine:""};const s=e.map(r=>` ${m(r)}: RoomRef<LunoraRoomMessages[${JSON.stringify(r)}]>;`).join(`
44
+ `),n=e.map(r=>` ${m(r)}: { name: ${JSON.stringify(r)} },`).join(`
45
45
  `);return{block:`
46
46
  /** This project's \`defineRoom\` rooms, addressable as typed references for \`client.connectRoom\`. */
47
47
  export interface RoomsRef {
48
- ${r}
48
+ ${s}
49
49
  }
50
50
 
51
51
  export const rooms: RoomsRef = {
52
52
  ${n}
53
53
  };
54
54
  `,importLine:`import type { LunoraRoomMessages } from "./functions.js";
55
- `}},W=t=>{const e=t.filter(a=>a.stream);if(e.length===0)return{block:"",body:""};const r=b(e,a=>{const l=d(a.chunkType??"unknown",a.filePath),o=d(y(a.searchParams),a.filePath),i=d(y(a.params),a.filePath);return`${j(a.exportName)}: HttpStreamRef<${l}, ${o}, ${i}>;`},"type"),n=b(e,a=>`${m(a.exportName)}: { method: ${JSON.stringify(a.method)}, path: ${JSON.stringify(a.path)} },`,"value");return{block:`
55
+ `}},J=t=>{const e=t.filter(a=>a.stream);if(e.length===0)return{block:"",body:""};const s=k(e,a=>{const l=d(a.chunkType??"unknown",a.filePath),o=d(y(a.searchParams),a.filePath),i=d(y(a.params),a.filePath);return`${j(a.exportName)}: HttpStreamRef<${l}, ${o}, ${i}>;`},"type"),n=k(e,a=>`${m(a.exportName)}: { method: ${JSON.stringify(a.method)}, path: ${JSON.stringify(a.path)} },`,"value");return{block:`
56
56
  /** This project's HTTP-SSE stream routes (\`httpRoute.<verb>(path).stream()\`), addressable as typed references for \`client.httpStream\` / \`useHttpStream\`. */
57
57
  export interface HttpStreamsRef {
58
- ${r}
58
+ ${s}
59
59
  }
60
60
 
61
61
  export const httpStreams: HttpStreamsRef = {
62
62
  ${n}
63
63
  };
64
- `,body:r}},J=t=>b(t,e=>`${m(e.exportName)}: { __lunoraRef: ${JSON.stringify(`${h(e.filePath)}:${e.exportName}`)} },`,"value"),T=t=>{const{block:e="",constName:r,docComment:n="",functions:s,importLine:a="",typeName:l,typesBody:o="",useUmbrella:i}=t,c=O(s),p=J(s),u=w(`${c}
65
- ${o}`),k=u.length>0?`
64
+ `,body:s}},_=t=>k(t,e=>`${m(e.exportName)}: { __lunoraRef: ${JSON.stringify(`${g(e.filePath)}:${e.exportName}`)}${v(e)?", sensitive: true":""} },`,"value"),C=t=>{const{block:e="",constName:s,docComment:n="",functions:r,importLine:a="",typeName:l,typesBody:o="",useUmbrella:i}=t,c=O(r),p=_(r),u=w(`${c}
65
+ ${o}`),b=u.length>0?`
66
66
  import type { ${u.join(", ")} } from "./dataModel.js";
67
- `:"",g=[...c===""?[]:["FunctionReference"],...t.clientImports??[]],f=g.length>0?`import type { ${g.join(", ")} } from "${S(i).client}";
68
- `:"";return v(`${x}${f}${a}${k}
67
+ `:"",h=[...c===""?[]:["FunctionReference"],...t.clientImports??[]],f=h.length>0?`import type { ${h.join(", ")} } from "${S(i).client}";
68
+ `:"";return P(`${x}${f}${a}${b}
69
69
  ${n}export interface ${l} {${c?`
70
70
  ${c}
71
71
  `:""}}
72
72
 
73
- export const ${r}: ${l} = {${p?`
73
+ export const ${s}: ${l} = {${p?`
74
74
  ${p}
75
75
  `:""}};
76
- ${e}`,i)},z=t=>{const{agents:e=[],functions:r,httpRoutes:n=[],mutators:s=[],useUmbrella:a=!1,workflows:l=[]}=t,o=W(n),i=F(r),c=A(l,e);return T({block:`${c.block}${o.block}${i.block}`,clientImports:[...o.block===""?[]:["HttpStreamRef"],...i.block===""?[]:["RoomRef"]],constName:"api",functions:[...r.filter(p=>p.visibility!=="internal"),...K(e,r),...E(s,r)],importLine:`${c.importLine}${i.importLine}`,typeName:"ApiTypes",typesBody:o.body,useUmbrella:a})},G=t=>T({constName:"internal",docComment:"/** Internal functions — callable only server-side via `ctx.run*`, never from a client. */\n",functions:t.functions.filter(e=>e.visibility==="internal"),typeName:"InternalApiTypes",useUmbrella:t.useUmbrella??!1}),Q=t=>t?`${x}import { createSeedClient as createSeedClientBase } from "@lunora/seed";
76
+ ${e}`,i)},z=t=>{const{agents:e=[],functions:s,httpRoutes:n=[],mutators:r=[],useUmbrella:a=!1,workflows:l=[]}=t,o=J(n),i=W(s),c=I(l,e);return C({block:`${c.block}${o.block}${i.block}`,clientImports:[...o.block===""?[]:["HttpStreamRef"],...i.block===""?[]:["RoomRef"]],constName:"api",functions:[...s.filter(p=>p.visibility!=="internal"),...F(e,s),...E(r,s)],importLine:`${c.importLine}${i.importLine}`,typeName:"ApiTypes",typesBody:o.body,useUmbrella:a})},Q=t=>C({constName:"internal",docComment:"/** Internal functions — callable only server-side via `ctx.run*`, never from a client. */\n",functions:t.functions.filter(e=>e.visibility==="internal"),typeName:"InternalApiTypes",useUmbrella:t.useUmbrella??!1}),X=t=>t?`${x}import { createSeedClient as createSeedClientBase } from "@lunora/seed";
77
77
  import type { SeedClient, SeedClientOptions } from "@lunora/seed";
78
78
 
79
79
  import schema from "../schema.js";
@@ -90,9 +90,9 @@ import type { InsertModel } from "./dataModel.js";
90
90
  * const { posts } = await seed.posts((x) => x([10, 20]));
91
91
  */
92
92
  export const createSeedClient = (options?: SeedClientOptions): SeedClient<InsertModel> => createSeedClientBase<InsertModel>(schema, options);
93
- `:"",X=(t,e,r=!1)=>{if(t.length===0||!e)return"";const n=S(r),s=i=>i.table===void 0?"Row":`Doc<${JSON.stringify(i.table)}> & Row`,a=t.map(i=>{P(i.exportName,"shape export name");const c=s(i),p=d(y(i.args),i.filePath),u=Object.keys(i.args).length>0,k=u?` args: ${p};`:` args?: ${p};`,g=u?`(args: ${p}) => void`:`(args?: ${p}) => void`,f=`${i.exportName}CollectionOptions`;return`/** Options for the \`${i.exportName}\` shape binding. */
93
+ `:"",Y=(t,e,s=!1)=>{if(t.length===0||!e)return"";const n=S(s),r=i=>i.table===void 0?"Row":`Doc<${JSON.stringify(i.table)}> & Row`,a=t.map(i=>{A(i.exportName,"shape export name");const c=r(i),p=d(y(i.args),i.filePath),u=Object.keys(i.args).length>0,b=u?` args: ${p};`:` args?: ${p};`,h=u?`(args: ${p}) => void`:`(args?: ${p}) => void`,f=`${i.exportName}CollectionOptions`;return`/** Options for the \`${i.exportName}\` shape binding. */
94
94
  export interface ${$(f)} {
95
- ${k}
95
+ ${b}
96
96
  /**
97
97
  * Share the optimistic-overlay gate with other collections + mutators on this
98
98
  * shard. Defaults to the shared per-shard registry, which is almost always what
@@ -130,7 +130,7 @@ export const ${i.exportName}CollectionOptions = (options: ${$(f)}): LunoraCollec
130
130
  /** Live collection for the \`${i.exportName}\` shape, with its sync controls. */
131
131
  export const ${i.exportName}Collection = (
132
132
  options: ${$(f)},
133
- ): { checkpoints: CheckpointRegistry; collection: Collection<${c}, string>; scope: ${g} } => {
133
+ ): { checkpoints: CheckpointRegistry; collection: Collection<${c}, string>; scope: ${h} } => {
134
134
  const { checkpoints, config, scope } = ${i.exportName}CollectionOptions(options);
135
135
 
136
136
  return { checkpoints, collection: createCollection(config), scope };
@@ -144,4 +144,4 @@ import type { Collection } from "@tanstack/db";
144
144
  import { createCollection } from "@tanstack/db";
145
145
  ${o}
146
146
  ${a}
147
- `};export{z as emitApi,X as emitCollections,G as emitInternalApi,Q as emitSeed,U as renderAgentFunctionRegistry,V as renderSandboxFunctionRegistry};
147
+ `};export{z as emitApi,Y as emitCollections,Q as emitInternalApi,X as emitSeed,G as renderAgentFunctionRegistry,U as renderSandboxFunctionRegistry};
@@ -1,4 +1,4 @@
1
- import{APP_METHOD_CAPABILITIES as k}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{i as S}from"./schema-BgM8A3XV.mjs";import{G as E}from"./shared-DnCokNcE.mjs";const D={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},m=e=>[...k.filter(({key:r})=>e.capabilities.has(r)).map(({appMethod:r})=>r),...e.hasVectors?[D]:[]],g=e=>m(e).length>0,v=e=>(e.emailAgents?.length??0)>0,d=e=>e.tables.some(r=>S(r)),R=e=>e.hasScheduler?`
1
+ import{APP_METHOD_CAPABILITIES as k}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{i as S}from"./schema-BgM8A3XV.mjs";import{G as E}from"./shared-8vTRkL2-.mjs";const D={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},m=e=>[...k.filter(({key:r})=>e.capabilities.has(r)).map(({appMethod:r})=>r),...e.hasVectors?[D]:[]],g=e=>m(e).length>0,v=e=>(e.emailAgents?.length??0)>0,d=e=>e.tables.some(r=>S(r)),R=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 i,d as c}from"./shared-DnCokNcE.mjs";import{i as m}from"./schema-BgM8A3XV.mjs";const u=r=>r?`${i}/**
1
+ import{G as i,d as c}from"./shared-8vTRkL2-.mjs";import{i as m}from"./schema-BgM8A3XV.mjs";const u=r=>r?`${i}/**
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-DEdXn5wP.mjs";import{a as i,e as o,v as d,f as v,G as M}from"./shared-DnCokNcE.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-Bl5fSmav.mjs";import{a as i,e as o,v as d,f as v,G as M}from"./shared-8vTRkL2-.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?`