@lunora/codegen 1.0.0-alpha.42 → 1.0.0-alpha.420

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 (130) hide show
  1. package/LICENSE.md +201 -104
  2. package/README.md +4 -4
  3. package/dist/index.d.mts +4583 -2045
  4. package/dist/index.d.ts +4583 -2045
  5. package/dist/index.mjs +1 -35
  6. package/dist/packem_shared/AGENTS_FILENAME-C4tHmiZZ.mjs +1 -0
  7. package/dist/packem_shared/ALL_NOTIFY_CHANNELS-BgkkvuUe.mjs +1 -0
  8. package/dist/packem_shared/CAPABILITY_PROBES-DCzOjTN7.mjs +25 -0
  9. package/dist/packem_shared/COMPANION_BINDING-Da_v9XpC.mjs +1 -0
  10. package/dist/packem_shared/CONTAINERS_FILENAME-d3XTFcqV.mjs +1 -0
  11. package/dist/packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs +1 -0
  12. package/dist/packem_shared/DEFAULT_TARGET-CVYzxQ0y.mjs +1 -0
  13. package/dist/packem_shared/ENV_FILENAME-DJ11PXN5.mjs +1 -0
  14. package/dist/packem_shared/FLAGS_FILENAME-DeSjFBWq.mjs +1 -0
  15. package/dist/packem_shared/GENERATED_HEADER-DgrhC3Iv.mjs +1 -0
  16. package/dist/packem_shared/LUNORA_ERROR_CODES-D7AVT7qF.mjs +1 -0
  17. package/dist/packem_shared/MUTATORS_FILENAME-C0ZV0hh6.mjs +1 -0
  18. package/dist/packem_shared/OPENRPC_VERSION-BOBo0zdQ.mjs +3 -0
  19. package/dist/packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs +1 -0
  20. package/dist/packem_shared/QUEUES_FILENAME-DbuJZnrY.mjs +1 -0
  21. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BljJJD8u.mjs +56 -0
  22. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs +2 -0
  23. package/dist/packem_shared/SHAPES_FILENAME-C-hrGfJ2.mjs +1 -0
  24. package/dist/packem_shared/SchemaSnapshotParseError-CV7mmuPi.mjs +17 -0
  25. package/dist/packem_shared/WORKFLOWS_FILENAME-7FysJsMZ.mjs +1 -0
  26. package/dist/packem_shared/attribution-Cwt30DDJ.mjs +1 -0
  27. package/dist/packem_shared/buildOpenApiDocument-DmV_PBFv.mjs +3 -0
  28. package/dist/packem_shared/capabilitiesUsedBy-BNvoiCu1.mjs +1 -0
  29. package/dist/packem_shared/classify-procedure-call-BmEirzc_.mjs +1 -0
  30. package/dist/packem_shared/companionServiceBinding-BZjm486n.mjs +1 -0
  31. package/dist/packem_shared/context-property-calls-BT1J7BqY.mjs +1 -0
  32. package/dist/packem_shared/context-root-BpDEhvNE.mjs +1 -0
  33. package/dist/packem_shared/createCodegenProject-dC6oJh5H.mjs +1 -0
  34. package/dist/packem_shared/database-calls-d-Sssc-3.mjs +1 -0
  35. package/dist/packem_shared/declared-output-Iaar469J.mjs +1 -0
  36. package/dist/packem_shared/describeErrorLevelFindings-DlkgCw8a.mjs +1 -0
  37. package/dist/packem_shared/discoverAuthApiCalls-CuqaLRa0.mjs +1 -0
  38. package/dist/packem_shared/discoverCrons-bT8F5GyL.mjs +1 -0
  39. package/dist/packem_shared/discoverFunctions-C9HUlfiV.mjs +1 -0
  40. package/dist/packem_shared/discoverHttpRoutes-CesuhqW1.mjs +1 -0
  41. package/dist/packem_shared/discoverHyperdriveCalls-BmAoOGGq.mjs +1 -0
  42. package/dist/packem_shared/discoverInserts-DIarYU2P.mjs +1 -0
  43. package/dist/packem_shared/discoverMaskProcedures-jkRrWS86.mjs +1 -0
  44. package/dist/packem_shared/discoverMigrations-C9AlZYFi.mjs +1 -0
  45. package/dist/packem_shared/discoverNondeterministicCalls-ZeZDQJAI.mjs +1 -0
  46. package/dist/packem_shared/discoverQueries-DLZHcDzB.mjs +1 -0
  47. package/dist/packem_shared/discoverR2sqlCalls-D_HWbbky.mjs +1 -0
  48. package/dist/packem_shared/discoverRlsMetadata-C0UkQkWd.mjs +1 -0
  49. package/dist/packem_shared/discoverRlsProcedures-BbSdCvmA.mjs +1 -0
  50. package/dist/packem_shared/discoverSandboxUsage-Dgvv6F_7.mjs +1 -0
  51. package/dist/packem_shared/discoverSchema-BLTROO8Z.mjs +1 -0
  52. package/dist/packem_shared/discoverStorageRulesMetadata-DeBgC7po.mjs +1 -0
  53. package/dist/packem_shared/dispatch-namespace-DwTjD7BU.mjs +1 -0
  54. package/dist/packem_shared/emitAgents-vWoT8-Yb.mjs +1 -0
  55. package/dist/packem_shared/emitApi-lwadq5G7.mjs +147 -0
  56. package/dist/packem_shared/emitApp-LFKtDRYu.mjs +1162 -0
  57. package/dist/packem_shared/emitCrons-CCRKs482.mjs +138 -0
  58. package/dist/packem_shared/emitDataModel-BvCZS4Yq.mjs +114 -0
  59. package/dist/packem_shared/emitDrizzleSchema-BzOChEYW.mjs +15 -0
  60. package/dist/packem_shared/emitFunctions-ppMX7E3X.mjs +528 -0
  61. package/dist/packem_shared/emitServer-CGRV_uIq.mjs +1 -0
  62. package/dist/packem_shared/emitShard-CDWgekIG.mjs +1 -0
  63. package/dist/packem_shared/exported-procedure-chains-CfH5jrzD.mjs +1 -0
  64. package/dist/packem_shared/fingerprintSchemaSources-TN-rU6Of.mjs +1 -0
  65. package/dist/packem_shared/formatAdvisories-Bue5tbp6.mjs +2 -0
  66. package/dist/packem_shared/handler-reference-BkOkxxg8.mjs +1 -0
  67. package/dist/packem_shared/index-CfSmiylg.mjs +1 -0
  68. package/dist/packem_shared/index-DtJBMdZ4.mjs +1 -0
  69. package/dist/packem_shared/ip-reads-D2qhKEb6.mjs +1 -0
  70. package/dist/packem_shared/isD1GlobalTable-udvHAAzD.mjs +1 -0
  71. package/dist/packem_shared/isTestPath-Uwb5a6Kq.mjs +1 -0
  72. package/dist/packem_shared/isTypedSchema-CDv3pJB6.mjs +4 -0
  73. package/dist/packem_shared/json-data-Chfs2Cz5.mjs +1 -0
  74. package/dist/packem_shared/loadProjectConfig-BXwH3_gn.mjs +1 -0
  75. package/dist/packem_shared/module-specifiers-BctA0m_p.mjs +1 -0
  76. package/dist/packem_shared/modules-DdOd-7Wp.mjs +1 -0
  77. package/dist/packem_shared/parse-validator-BisfC8bR.mjs +1 -0
  78. package/dist/packem_shared/platform-8oj7iXQy.mjs +1 -0
  79. package/dist/packem_shared/policies-Dn_tuTZd.mjs +1 -0
  80. package/dist/packem_shared/project-config-file-DR7xrrNB.mjs +1 -0
  81. package/dist/packem_shared/property-name-7cBlgK_O.mjs +1 -0
  82. package/dist/packem_shared/qualifiers-qqH8fRTo.mjs +1 -0
  83. package/dist/packem_shared/readPackageDependencies-RHhGiz0k.mjs +1 -0
  84. package/dist/packem_shared/redact-Cy14LEnc.mjs +1 -0
  85. package/dist/packem_shared/reserved-words-CW1QFbTd.mjs +1 -0
  86. package/dist/packem_shared/schema-BgM8A3XV.mjs +1 -0
  87. package/dist/packem_shared/schemaFromIr-CByOxuZb.mjs +1 -0
  88. package/dist/packem_shared/server-Dfxmm5Zw.mjs +377 -0
  89. package/dist/packem_shared/shard-CWAD5mYy.mjs +1897 -0
  90. package/dist/packem_shared/shard-runtime-G5mZQjY0.mjs +351 -0
  91. package/dist/packem_shared/shared-Cn7dMQ_u.mjs +13 -0
  92. package/dist/packem_shared/unwrap-handler-return-DvbyiLjc.mjs +1 -0
  93. package/dist/sdk/index.d.mts +288 -0
  94. package/dist/sdk/index.d.ts +288 -0
  95. package/dist/sdk/index.mjs +394 -0
  96. package/package.json +22 -9
  97. package/dist/packem_shared/CONTAINERS_FILENAME-DjpXMqhp.mjs +0 -224
  98. package/dist/packem_shared/CodegenDiagnosticError-DyQ5FwkM.mjs +0 -24
  99. package/dist/packem_shared/FLAGS_FILENAME-fEZtzWXi.mjs +0 -139
  100. package/dist/packem_shared/GENERATED_HEADER-D6RK1WF1.mjs +0 -3
  101. package/dist/packem_shared/LUNORA_ERROR_CODES-DvTLozCu.mjs +0 -68
  102. package/dist/packem_shared/MUTATORS_FILENAME-BZOfUhlY.mjs +0 -81
  103. package/dist/packem_shared/OPENRPC_VERSION-CzhfvCIQ.mjs +0 -60
  104. package/dist/packem_shared/QUEUES_FILENAME-Xv6Vy-Ku.mjs +0 -145
  105. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-Cl1EBMdR.mjs +0 -3438
  106. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs +0 -249
  107. package/dist/packem_shared/SHAPES_FILENAME-DOhPGi-6.mjs +0 -94
  108. package/dist/packem_shared/WORKFLOWS_FILENAME-B2By8S4s.mjs +0 -152
  109. package/dist/packem_shared/buildOpenApiDocument-bg-NnLka.mjs +0 -183
  110. package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
  111. package/dist/packem_shared/discoverAuthApiCalls-WMx8L2FG.mjs +0 -62
  112. package/dist/packem_shared/discoverCrons-D-jrpm97.mjs +0 -256
  113. package/dist/packem_shared/discoverFunctions-CZ91aenA.mjs +0 -518
  114. package/dist/packem_shared/discoverHttpRoutes-DNZLDCmm.mjs +0 -131
  115. package/dist/packem_shared/discoverInserts-DFRJhmCv.mjs +0 -61
  116. package/dist/packem_shared/discoverMaskProcedures-B5iFnZ-X.mjs +0 -273
  117. package/dist/packem_shared/discoverMigrations-CdKtMlBc.mjs +0 -97
  118. package/dist/packem_shared/discoverNondeterministicCalls-C_PrQPkA.mjs +0 -122
  119. package/dist/packem_shared/discoverQueries-B8W9UPrt.mjs +0 -62
  120. package/dist/packem_shared/discoverR2sqlCalls-Bm7Rfnf4.mjs +0 -80
  121. package/dist/packem_shared/discoverRlsMetadata-B4GL4ZKm.mjs +0 -280
  122. package/dist/packem_shared/discoverSchema-DFWVgU5o.mjs +0 -874
  123. package/dist/packem_shared/discoverStorageRulesMetadata-nosjYcvN.mjs +0 -97
  124. package/dist/packem_shared/emit-31Yg1Ee5.mjs +0 -3474
  125. package/dist/packem_shared/emitApp-DCP7Pr6M.mjs +0 -668
  126. package/dist/packem_shared/formatAdvisories-DRhEiJUz.mjs +0 -114
  127. package/dist/packem_shared/parse-validator-BSJo1HGP.mjs +0 -144
  128. package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
  129. package/dist/packem_shared/redact-oTmsol5A.mjs +0 -33
  130. package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
@@ -0,0 +1 @@
1
+ import{Node as s,SyntaxKind as u,VariableDeclarationKind as re}from"ts-morph";import{isConstDeclaration as F,unwrapExpression as d,descendantsOfKind as oe,bindingKeyName as ae}from"./isTestPath-Uwb5a6Kq.mjs";import{r as ce,b as V,d as N}from"./attribution-Cwt30DDJ.mjs";import{i as _,r as C,c as m,a as le}from"./context-root-BpDEhvNE.mjs";const de=e=>{const t=e.getText(),i=n=>{const r=n.getNameNode();return s.isIdentifier(r)&&r.getText()===t};for(const n of e.getAncestors())if(!(!s.isArrowFunction(n)&&!s.isFunctionExpression(n)&&!s.isFunctionDeclaration(n)))for(const r of n.getParameters()){const o=r.getDescendantsOfKind(u.BindingElement).find(a=>i(a));if(o!==void 0)return o}},ue=e=>{let t=e;for(;;){const i=t.getParent();if(!s.isObjectBindingPattern(i))return;const n=i.getParent();if(s.isBindingElement(n)){t=n;continue}return s.isParameterDeclaration(n)?ae(t):void 0}},ge=e=>{const t=e.getText();if(!e.getAncestors().some(o=>{const a=s.isFunctionLikeDeclaration(o)||s.isArrowFunction(o)?o.getParameters()[1]:void 0,c=a?.getNameNode();return a!==void 0&&(s.isIdentifier(c)?c.getText()===t:a.getDescendantsOfKind(u.BindingElement).some(l=>l.getName()===t))&&_(a)}))return!1;const n=N(e),r=s.isParameterDeclaration(n)?n:n?.getFirstAncestorByKind(u.Parameter);return r!==void 0&&(s.isParameterDeclaration(n)||s.isBindingElement(n))&&_(r)},q=(e,t)=>{const i=e.getParent();if(s.isPropertyAccessExpression(i)&&i.getNameNode()===e||s.isPropertyAssignment(i)&&i.getNameNode()===e)return!1;if(e.getText()===t)return!0;const n=de(e);return n!==void 0&&ue(n)===t?!0:t==="args"&&ge(e)},T=(e,t)=>s.isIdentifier(e)?q(e,t):e.getDescendantsOfKind(u.Identifier).some(i=>q(i,t)),fe=e=>{let t=e;for(;s.isPropertyAccessExpression(t)||s.isElementAccessExpression(t)||s.isNonNullExpression(t);)t=t.getExpression();return s.isIdentifier(t)?t:void 0},f=e=>{const t=s.isIdentifier(e)?N(e):void 0;return s.isVariableDeclaration(t)&&s.isIdentifier(t.getNameNode())&&!V(t)?t.getInitializer():void 0},me=(e,t)=>{const i=e.getParent();if(s.isVariableDeclarationList(i)&&i.getDeclarationKind()===re.Var)return t;const n=i.getParent();return s.isVariableStatement(n)?n.getParent():n},pe=(e,t)=>{const i=e.getNameNode();return s.isIdentifier(i)?i.getText()===t:i.getDescendantsOfKind(u.BindingElement).some(n=>{const r=n.getNameNode();return s.isIdentifier(r)&&r.getText()===t})},M=e=>e.getDescendantsOfKind(u.Identifier).filter(t=>{const i=t.getParent();return!(s.isPropertyAccessExpression(i)&&i.getNameNode()===t)&&!(s.isPropertyAssignment(i)&&i.getNameNode()===t)}),y=e=>s.isIdentifier(e)?[e]:M(e),b=e=>{let t=e;for(;;){const i=t.getParent();if(!((s.isPropertyAccessExpression(i)||s.isElementAccessExpression(i)||s.isNonNullExpression(i))&&i.getExpression()===t))return t;t=i}},Ee=e=>{const t=e.getParent();return s.isCallExpression(t)&&t.getExpression()===e?t:void 0},ve=new Set(["find","findFirst","findFirstOrThrow","findMany","findUnique","first","get","unique"]),Z=e=>{const t=e.getExpression();return s.isPropertyAccessExpression(t)&&ve.has(t.getName())&&m(t)?.[0]==="db"},D=(e,t)=>{for(let i=e,n=e.getParent();n!==void 0&&i!==t;i=n,n=n.getParent()){if(s.isConditionalExpression(n))return!0;if(s.isBinaryExpression(n)){const r=n.getOperatorToken().getKind();if(i===n.getRight()&&(r===u.QuestionQuestionToken||r===u.BarBarToken)||i===n.getLeft()&&r===u.AmpersandAmpersandToken)return!0}}return!1},J=e=>y(e).some(t=>{if(D(t,e))return!1;if(m(b(t))?.[0]==="auth")return!0;const i=f(t);return i!==void 0&&y(i).some(n=>m(b(n))?.[0]==="auth"&&!D(n,i))}),xe=e=>Z(e)&&e.getArguments().some(t=>J(t)),X=(e,t)=>{for(let i=e.getParent();i!==void 0;i=i.getParent()){if(s.isCallExpression(i)&&m(i.getExpression())?.[0]==="db")return!0;if(i===t)return!1}return!1},R=e=>y(e).some(t=>{const i=b(t),n=m(i)?.[0];if(n==="auth")return!D(t,e)&&!X(t,e);const r=n==="db"&&!D(t,e)?Ee(i):void 0;return r!==void 0&&xe(r)}),k=e=>s.isArrowFunction(e)||s.isFunctionExpression(e)||s.isFunctionDeclaration(e)||s.isMethodDeclaration(e),K=e=>{const t=e.getFirstAncestor(i=>k(i));return k(t)?t:void 0},Ae=e=>{const t=d(e);return s.isAwaitExpression(t)?d(t.getExpression()):t},P=e=>{const t=[];let i=d(e);for(;i!==void 0;)if(s.isPropertyAccessExpression(i))t.unshift(i.getName()),i=d(i.getExpression());else if(s.isElementAccessExpression(i)){const n=i.getArgumentExpression();if(!s.isStringLiteral(n))return;t.unshift(n.getLiteralValue()),i=d(i.getExpression())}else return s.isIdentifier(i)?{path:t,root:i}:void 0},p=(e,t)=>N(e)?.compilerNode===t.compilerNode,Y=e=>{if(!s.isIdentifier(e))return;const t=ce(e),i=t?.isAlias()===!0?t.getAliasedSymbol():t,n=i?.getValueDeclaration()??i?.getDeclarations()[0];if(n===void 0)return;const r=n.getSourceFile();if(r.isDeclarationFile()||r.isInNodeModules())return;if(s.isFunctionDeclaration(n))return n.getBody()===void 0||n.isGenerator()||V(n)?void 0:n;if(!F(n))return;const o=d(n.getInitializer());return s.isArrowFunction(o)||s.isFunctionExpression(o)&&!o.isGenerator()?o:void 0},Ne=e=>e>=u.FirstAssignment&&e<=u.LastAssignment,H=e=>{const t=[],i=[];let n=d(e);for(;n!==void 0;)if(s.isCallExpression(n))t.push(n),n=d(n.getExpression());else if(s.isPropertyAccessExpression(n))i.unshift(n.getName()),n=d(n.getExpression());else if(s.isElementAccessExpression(n)){const r=n.getArgumentExpression();if(!s.isStringLiteral(r))return;i.unshift(r.getLiteralValue()),n=d(n.getExpression())}else return s.isIdentifier(n)&&t.length>0&&i.length>0?{calls:t,names:i,root:n}:void 0},j=new Set(["findFirst","findUnique","first","get","unique"]),U=e=>{const t=e.names[e.names.length-1]??"";if(j.has(t))return{selfEnforcing:!1};const i=t.endsWith("OrThrow")?t.slice(0,-7):void 0;return i!==void 0&&j.has(i)?{selfEnforcing:!0}:void 0},Ie=e=>{const t=d(e),i=s.isIdentifier(t)?d(f(t))??t:t,n=P(i);if(n===void 0||n.path.length===0)return;const r=N(n.root);if(!F(r)||!s.isIdentifier(r.getNameNode()))return;const o=Ae(r.getInitializer()),a=s.isCallExpression(o)&&m(o.getExpression())?.[0]==="db"?H(o):void 0;return a!==void 0&&U(a)!==void 0?r:void 0},$=e=>e.calls.flatMap(t=>t.getArguments().flatMap(i=>[i,...i.getDescendants()])),he=(e,t)=>{const i=s.isIdentifier(e)?N(e):void 0;if(!s.isBindingElement(i)||i.getDotDotDotToken()!==void 0||i.getInitializer()!==void 0)return!1;const n=i.getParent(),r=s.isObjectBindingPattern(n)?n.getParent():void 0;if(!F(r))return!1;const o=P(r.getInitializer());return o?.path[0]==="auth"&&p(o.root,t)},De=(e,t)=>{const i=P(e);if(i!==void 0&&i.path.length>0)return i.path[0]==="auth"&&p(i.root,t);const n=P(f(e));return n?.path[0]==="auth"&&p(n.root,t)?!0:he(e,t)},ee=e=>{if(!s.isVariableStatement(e))return;const t=e.getDeclarations(),i=t.length===1?t[0]:void 0;return i!==void 0&&F(i)&&s.isIdentifier(i.getNameNode())?i:void 0},Pe=(e,t)=>{const i=d(e),n=a=>s.isIdentifier(a)&&p(a,t);if(s.isPrefixUnaryExpression(i))return i.getOperatorToken()===u.ExclamationToken&&n(d(i.getOperand()));if(!s.isBinaryExpression(i)||i.getOperatorToken().getKind()!==u.EqualsEqualsToken)return!1;const r=d(i.getLeft()),o=d(i.getRight());return n(r)&&s.isNullLiteral(o)||n(o)&&s.isNullLiteral(r)},ye=(e,t)=>{const i=s.isBlock(e)?e.getStatements():void 0,n=i===void 0?e:i[i.length-1];return s.isThrowStatement(n)||!t&&s.isReturnStatement(n)},te=(e,t,i)=>s.isIfStatement(e)&&e.getElseStatement()===void 0&&Pe(e.getExpression(),t)&&ye(e.getThenStatement(),i),Se=(e,t,i)=>{const n=e.getBody();if(!s.isBlock(n))return!1;const r=n.getStatements();return r.some((o,a)=>{const c=ee(o),l=d(c?.getInitializer()),g=s.isAwaitExpression(l)?H(l.getExpression()):void 0,x=g===void 0?void 0:U(g);if(c===void 0||g===void 0||x===void 0||g.names[0]!=="db"||!p(g.root,t))return!1;const E=$(g),I=E.some(v=>De(v,t)),S=i.some(v=>E.some(W=>s.isIdentifier(W)&&p(W,v)));if(!I||!S)return!1;const h=x.selfEnforcing?o:r.slice(a+1).find(v=>te(v,c,!0));return h!==void 0&&!e.getDescendantsOfKind(u.ReturnStatement).some(v=>K(v)?.compilerNode===e.compilerNode&&v.getStart()<h.getEnd())})},Oe=(e,t,i)=>{const n=Y(e.getExpression()),r=e.getArguments();if(n===void 0||r.some(E=>s.isSpreadElement(E)))return!1;const o=r.flatMap((E,I)=>m(E)?.length===0?[I]:[]),a=o.length===1?o[0]:void 0,c=a===void 0?void 0:n.getParameters()[a];if(a===void 0||c===void 0||c.isRestParameter()||!s.isIdentifier(c.getNameNode()))return!1;const l=[];r.forEach((E,I)=>{const S=P(d(E)),h=I===a||S===void 0||!p(S.root,t)?void 0:n.getParameters()[I];h!==void 0&&s.isIdentifier(h.getNameNode())&&l.push(h)});const g=n.getReturnType(),x=n.isAsync()||g.isAny()||g.isUnknown()||g.getText().includes("Promise");return l.length===0||!i&&x?!1:Se(n,c,l)},Te=(e,t)=>{const i=ee(e),n=d(i?.getInitializer()),r=s.isAwaitExpression(n)?H(n.getExpression()):void 0,o=r===void 0?void 0:U(r);if(i===void 0||r===void 0||o===void 0||r.names[0]!=="db"||m(r.root)?.length!==0)return;const a=r.calls.some(l=>l.getArguments().some(g=>J(g))),c=$(r).some(l=>s.isIdentifier(l)&&p(l,t));return a&&c?{declaration:i,selfEnforcing:o.selfEnforcing}:void 0},be=(e,t,i)=>{const n=(r,o)=>o.getStart()<=r.getStart()&&r.getEnd()<=o.getEnd();for(let r=e.getParent();r!==void 0&&r.compilerNode!==t.compilerNode;r=r.getParent()){if(k(r)||s.isIfStatement(r)||s.isIterationStatement(r)||s.isCaseClause(r)||s.isDefaultClause(r)||s.isCatchClause(r))return!1;if(s.isTryStatement(r)&&r.getCatchClause()!==void 0){const o=r.getTryBlock();if(!n(e,o)||!n(i,o))return!1}}return!0},Be=(e,t,i,n,r)=>e.slice(0,t).some((o,a)=>{if(!be(o,n,r))return!1;if(s.isExpressionStatement(o)){const l=d(o.getExpression()),g=s.isAwaitExpression(l),x=g?d(l.getExpression()):l;if(s.isCallExpression(x)&&Oe(x,i,g))return!0}const c=Te(o,i);return c!==void 0&&(c.selfEnforcing||a+1<t&&te(e[a+1],c.declaration,!1))}),G=e=>{let t=d(e)??e;for(;s.isAwaitExpression(t);)t=d(t.getExpression())??t.getExpression();return t},O=e=>{const t=G(e);return s.isCallExpression(t)||s.isNewExpression(t)},we=e=>{const t=G(e);return s.isCallExpression(t)&&m(t.getExpression())?.[0]==="db"},ie=e=>{const t=G(e);return s.isCallExpression(t)&&Z(t)},ne=e=>T(e,"args")||y(e).some(t=>{const i=f(t);return i!==void 0&&T(i,"args")}),B=(e,t)=>{const i=e?.getNameNode().getDescendantsOfKind(u.BindingElement).find(n=>s.isIdentifier(n.getNameNode())&&n.getNameNode().getText()===t);return i===void 0?[]:[i,...i.getAncestors().filter(n=>s.isBindingElement(n))].map(n=>s.isBindingElement(n)?n.getInitializer():void 0).filter(n=>n!==void 0)},Q=e=>{const t=s.isIdentifier(e)?N(e):void 0;if(!s.isBindingElement(t)||V(t))return;const i=t.getFirstAncestorByKind(u.VariableDeclaration),n=i?.getInitializer();if(!B(i,e.getText()).some(r=>ne(r)))return n!==void 0&&ie(n)?n:void 0},A=e=>T(e,"args"),w=e=>{if(!s.isIdentifier(e))return;const t=e.getText(),i=e.getFirstAncestor(a=>s.isArrowFunction(a)||s.isFunctionExpression(a)||s.isFunctionDeclaration(a));if(i===void 0)return;const n=e.getStart();let r,o=-1;for(const a of oe(i,u.VariableDeclaration)){if(!pe(a,t))continue;const c=me(a,i);if(c===void 0||n<c.getStart()||n>=c.getEnd())continue;const l=a.getInitializer(),g=a.getStart();l!==void 0&&g<n&&g>o&&(r=a,o=g)}return r},L=e=>w(e)?.getInitializer(),je=e=>{if(A(e))return!0;const t=i=>{const n=w(i),r=n?.getInitializer();return r!==void 0&&A(r)||B(n,i.getText()).some(o=>A(o))};return t(e)||M(e).some(i=>t(i))},Qe=e=>{if(O(e))return!1;if(B(w(e),e.getText()).some(n=>A(n)&&!O(n)))return!0;const t=L(e);if(t!==void 0&&O(t)&&!(ie(t)&&A(t)))return!1;const i=t??e;return A(i)?!0:M(i).some(n=>{if(n.getFirstAncestor(c=>c===i||s.isCallExpression(c)||s.isNewExpression(c))!==i)return!1;const o=w(n),a=c=>c!==void 0&&A(c)&&(!O(c)||we(c));return a(o?.getInitializer())||B(o,n.getText()).some(c=>a(c))})},Ze=e=>{if(C(e))return!0;const t=f(e);if(t!==void 0&&C(t))return!0;const i=t??e;return(s.isIdentifier(i)?[i]:i.getDescendantsOfKind(u.Identifier)).some(r=>{const o=f(r);return o!==void 0&&C(o)})},Je=e=>{const t=f(e)??e;if(y(t).some(o=>D(o,t)&&ne(b(o))))return!1;if(R(e))return!0;const i=f(e)??Q(e);if(i!==void 0&&R(i))return!0;const n=i??e;return(s.isIdentifier(n)?[n]:n.getDescendantsOfKind(u.Identifier)).some(o=>{if(D(o,n)||X(o,n))return!1;const a=f(o)??Q(o);return a!==void 0&&R(a)})},z=(e,t)=>T(e,t),Xe=(e,t)=>{if(z(e,t))return!0;const i=L(e);if(i!==void 0&&z(i,t))return!0;const n=fe(e);if(n!==void 0){const r=L(n);return r!==void 0&&z(r,t)}return!1},Ye=(e,t)=>{const i=K(e),n=Ie(t);if(i===void 0||n===void 0||K(n)?.compilerNode!==i.compilerNode||i.getDescendantsOfKind(u.BinaryExpression).some(c=>{const l=P(c.getLeft());return Ne(c.getOperatorToken().getKind())&&l!==void 0&&p(l.root,n)}))return!1;let o=e,a=e.getParent();for(;a!==void 0&&a.compilerNode!==i.compilerNode;){if(s.isBlock(a)){const c=a.getStatements(),l=c.findIndex(g=>g.compilerNode===o.compilerNode);if(l>0&&Be(c,l,n,i,e))return!0}o=a,a=a.getParent()}return!1},Fe=/rate|limit|\bip\b|geo|throttle/iu,Ce=/^run[A-Z]/u,Re=e=>s.isIdentifier(e)?(e.getSymbol()?.getDeclarations()??[]).some(i=>i.getFirstAncestorByKind(u.ImportDeclaration)?.getModuleSpecifierValue().startsWith("@lunora/")===!0):!1,ze=e=>{const t=s.isCallExpression(e)?e.getExpression():e;let i;return s.isIdentifier(t)?i=t:s.isPropertyAccessExpression(t)&&(i=t.getNameNode()),i!==void 0&&Re(s.isPropertyAccessExpression(t)?t.getExpression():i)&&!Fe.test(i.getText())},ke=e=>{const t=s.isCallExpression(e)?e.getExpression():void 0;if(s.isElementAccessExpression(t)){const i=t.getArgumentExpression();return(s.isStringLiteral(i)||s.isNoSubstitutionTemplateLiteral(i))&&i.getLiteralText()==="use"}return s.isPropertyAccessExpression(t)&&t.getName()==="use"},Ke=e=>{const t=e.getParent();return s.isPropertyAccessExpression(t)&&t.getExpression()===e?!Ce.test(t.getName()):s.isElementAccessExpression(t)&&t.getExpression()===e?s.isStringLiteral(t.getArgumentExpression())||s.isNoSubstitutionTemplateLiteral(t.getArgumentExpression()):s.isVariableDeclaration(t)&&t.getInitializer()?.getText()===e.getText()},Le=e=>{if(s.isPropertyAccessExpression(e))return e.getName()==="ip";if(s.isElementAccessExpression(e)){const t=e.getArgumentExpression();return(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))&&t.getLiteralText()==="ip"}return s.isBindingElement(e)?e.getDotDotDotToken()!==void 0||(e.getPropertyNameNode()?.getText()??e.getName())==="ip":s.isShorthandPropertyAssignment(e)&&e.getName()==="ip"},Ve=(e,t)=>{const i=e.getParent();if(!s.isCallExpression(i)||i.getExpression()===e)return!1;const n=i.getArguments().indexOf(e),r=Y(i.getExpression()),o=n===-1||r===void 0?void 0:r.getParameters()[n];return r===void 0||o===void 0||o.isRestParameter()||!s.isIdentifier(o.getNameNode())?!1:t.has(r.compilerNode)?!0:(t.add(r.compilerNode),!se(r,o,t))},Me=(e,t)=>t!==void 0&&s.isIdentifier(e)&&N(e)?.compilerNode===t.compilerNode,He=e=>s.isArrowFunction(e)||s.isFunctionExpression(e)||s.isFunctionDeclaration(e)||s.isMethodDeclaration(e),Ue=(e,t)=>!s.isBindingElement(e)||e.getDotDotDotToken()===void 0?!1:e.getFirstAncestorByKind(u.Parameter)?.getParent()?.getAncestors().some(r=>r!==t&&He(r)&&r.getAncestors().includes(t))===!0,se=(e,t,i)=>{for(const n of e.getDescendants()){if(Le(n)&&!Ue(n,e)||ke(n)&&!ze(n.getArguments()[0]))return!0;if(s.isIdentifier(n)&&(le(n)||Me(n,t))&&!Ke(n)){const r=n.getParent();if(!(s.isParameterDeclaration(r)||s.isBindingElement(r)||s.isVariableDeclaration(r))&&!Ve(n,i))return!0}}return!1},$e=e=>se(e,void 0,new Set);export{Ze as a,Qe as b,Je as c,Ye as d,Xe as e,z as f,w as g,je as i,$e as m,A as r,L as s};
@@ -0,0 +1 @@
1
+ const e=l=>l.shardMode==="global"&&l.globalBackend!=="hyperdrive",o=l=>l.shardMode==="global"&&l.globalBackend==="hyperdrive";export{e as isD1GlobalTable,o as isHyperdriveGlobalTable};
@@ -0,0 +1 @@
1
+ import{statSync as F,readdirSync as P,realpathSync as D,lstatSync as I}from"node:fs";import{dirname as w,join as S,relative as N,sep as L,extname as O,basename as z}from"node:path";import{matcher as j}from"@visulima/fs";import{SyntaxKind as l,Node as s,VariableDeclarationKind as M}from"ts-morph";import{diagnosticAt as V}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{r as K}from"./project-config-file-DR7xrrNB.mjs";import{findProjectConfigFile as $,findCodegenConfigFile as B}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{p as U,a as W}from"./property-name-7cBlgK_O.mjs";const H=/\.ts$/u,E=(e,t)=>N(e,t).split(L).join("/").replace(H,""),he=e=>{const t=s.isFunctionDeclaration(e)?e:e.getFirstAncestor(i=>s.isVariableStatement(i)||s.isFunctionDeclaration(i)||s.isExpressionStatement(i)||s.isReturnStatement(i)||s.isArrowFunction(i)||s.isFunctionExpression(i));return(t===void 0||s.isArrowFunction(t)||s.isFunctionExpression(t)?e:t).getStartLineNumber()},X=new Set(["_generated","node_modules"]),T=new Set(["__fixtures__","__mocks__","__snapshots__","__tests__"]),R=/\.(?:bench|e2e|e2e-spec|spec|spec-d|test|test-d)(?:\.tsx?)?$/u,ye=e=>{const t=e.split("/");return R.test(t.at(-1)??"")||t.slice(0,-1).some(i=>T.has(i))},m=(e,t,i)=>t?X.has(e)||!i&&T.has(e):!i&&R.test(e),h=new Map,x=()=>!1;let f;const G=e=>{const t=B(e),i=t===void 0?void 0:F(t,{throwIfNoEntry:!1});if(t===void 0||i===void 0)return x;const n=`${String(i.mtimeMs)}:${String(i.size)}`,r=h.get(t);if(r?.key===n)return r.isExcluded;const{codegen:o}=K(w(t));o?.unreadable&&console.warn("@lunora/codegen: `codegen.exclude` in lunora.config is not an array of string literals without `!` negations — ignoring it.");const c=o?.exclude?.length?j(o.exclude):x;return h.set(t,{isExcluded:c,key:n}),c},Y=(e,t,i)=>e==="schema.ts"&&t===i,q=e=>{try{return F(e)}catch{console.warn(`@lunora/codegen: skipping ${e} — it is a symlink that does not resolve (or vanished mid-scan).`);return}},_=(e,t,i,n,r)=>{let o,c;try{o=P(e),c=D(e)}catch{return t}if(n.has(c))return t;n.add(c);for(const u of o){const p=S(e,u),a=q(p);a===void 0||r(u,N(i,p).split(L).join("/"),a.isDirectory())||(a.isDirectory()?_(p,t,i,n,r):a.isFile()&&O(u)===".ts"&&!Y(u,e,i)&&t.push(p))}return t},b=(e,t={})=>{const i=t.includeSkipped??!1,n=`${String(i)}\0${e}`,r=f?.get(n);if(r!==void 0)return[...r];const o=i?x:G(e),c=_(e,[],e,new Set,(u,p,a)=>m(u,a,i)||o(p));return f?.set(n,c),[...c]},Ae=e=>{if(f!==void 0)return e();f=new Map;try{return e()}finally{f=void 0}},Q=["src/server","src/index.ts","src/worker.ts"],J=new Set([".ts",".tsx"]),k=(e,t=[])=>{let i;try{i=I(e)}catch{return t}if(i.isFile())return J.has(O(e))&&!m(z(e),!1,!1)&&t.push(e),t;if(!i.isDirectory())return t;for(const n of P(e))m(n,!0,!1)||k(S(e,n),t);return t},Z=e=>{const t=w(e),i=b(e).map(o=>({displayPath:E(e,o),filePath:o})),n=new Set(i.map(o=>o.filePath)),r=$(t);for(const o of[...Q.flatMap(c=>k(S(t,c))),...r===void 0?[]:[r]])n.has(o)||(n.add(o),i.push({displayPath:E(t,o),filePath:o}));return i},ee=e=>Array.isArray(e),y=new WeakMap,te=(e,t)=>{let i=y.get(e.compilerNode);i===void 0&&(i=new Map,y.set(e.compilerNode,i));let n=i.get(t);return n===void 0&&(n=e.getDescendantsOfKind(t),i.set(t,n)),n},C=(e,t,i,n)=>{const r=[];for(const{displayPath:o,filePath:c}of t){const u=e.getSourceFile(c)??e.addSourceFileAtPath(c);for(const p of te(u,i)){const a=n(p,o);ee(a)?r.push(...a):a!==void 0&&r.push(a)}}return r},ie=e=>b(e).map(t=>({displayPath:E(e,t),filePath:t})),se=(e,t,i,n)=>C(e,ie(t),i,n),Fe=(e,t,i)=>se(e,t,l.CallExpression,i),Pe=(e,t,i)=>C(e,Z(t),l.CallExpression,i),we=e=>U(e.getPropertyNameNode()??e.getNameNode()),v=(e,t)=>e?.getProperties().find(i=>!s.isSpreadAssignment(i)&&W(i)===t),Ne=(e,t)=>{if(t){const o=e.getArguments()[0];return o&&(s.isArrowFunction(o)||s.isFunctionExpression(o))?o:void 0}const i=e.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))return;const n=v(i,"handler");if(!n||!s.isPropertyAssignment(n))return;const r=n.getInitializer();return r&&(s.isArrowFunction(r)||s.isFunctionExpression(r))?r:void 0},Le=(e,t)=>{if(!e||!s.isObjectLiteralExpression(e))return;const i=v(e,t);return i&&s.isPropertyAssignment(i)?i.getInitializer():void 0},ne=e=>{const t=e?.getParent();return s.isVariableDeclaration(e)&&s.isVariableDeclarationList(t)&&t.getDeclarationKind()===M.Const},re=e=>{let t=e,i=t.getParent();for(;i!==void 0&&(s.isParenthesizedExpression(i)||s.isAsExpression(i)||s.isSatisfiesExpression(i)||s.isTypeAssertion(i)||s.isNonNullExpression(i));)t=i,i=t.getParent();return t},A=e=>{const t=re(e),i=t.getParent();if(i===void 0)return!1;if(s.isBinaryExpression(i)){const r=i.getOperatorToken().getKind();return i.getLeft()===t&&r>=l.FirstAssignment&&r<=l.LastAssignment}if(s.isPrefixUnaryExpression(i)||s.isPostfixUnaryExpression(i)){const r=i.getOperatorToken();return r===l.PlusPlusToken||r===l.MinusMinusToken}return s.isDeleteExpression(i)?!0:s.isForOfStatement(i)||s.isForInStatement(i)?i.getInitializer()===t:s.isPropertyAssignment(i)?i.getInitializer()===t&&A(i):(s.isShorthandPropertyAssignment(i)||s.isSpreadAssignment(i)||s.isSpreadElement(i)||s.isObjectLiteralExpression(i)||s.isArrayLiteralExpression(i))&&A(i)},oe=e=>{const t=e?.getDeclarations().find(n=>s.isVariableDeclaration(n));if(!ne(t))return;const i=t.getParent().getParent();return s.isVariableStatement(i)&&s.isSourceFile(i.getParent())?t.getInitializer():void 0},ce=e=>oe(e.getSymbol()),Oe=e=>{if(!e)return;if(s.isObjectLiteralExpression(e))return e;if(!s.isIdentifier(e))return;const t=ce(e);return t!==void 0&&s.isObjectLiteralExpression(t)?t:void 0},g=e=>{let t=e;for(;t&&(s.isAsExpression(t)||s.isSatisfiesExpression(t)||s.isParenthesizedExpression(t)||s.isNonNullExpression(t));)t=t.getExpression();return t},d=e=>{const t=g(e);if(t!==void 0){if(s.isNumericLiteral(t))return t.getLiteralValue();if(s.isPrefixUnaryExpression(t)){const i=d(t.getOperand());if(i===void 0)return;const n=t.getOperatorToken();return n===l.MinusToken?-i:n===l.PlusToken?i:void 0}if(s.isBinaryExpression(t)){const i=d(t.getLeft()),n=d(t.getRight());if(i===void 0||n===void 0)return;switch(t.getOperatorToken().getKind()){case l.AsteriskToken:return i*n;case l.MinusToken:return i-n;case l.PlusToken:return i+n;default:return}}}},ae=(e,t)=>{let i=g(e);for(;s.isAwaitExpression(i)||s.isPropertyAccessExpression(i)||s.isElementAccessExpression(i)||s.isCallExpression(i);){const n=s.isCallExpression(i)?t?.(i):void 0;if(n!==void 0)return{verdict:n};i=g(i.getExpression())}return{root:i}},Te=e=>ae(e).root,Re=e=>s.isArrowFunction(e)||s.isConstructorDeclaration(e)||s.isFunctionDeclaration(e)||s.isFunctionExpression(e)||s.isGetAccessorDeclaration(e)||s.isMethodDeclaration(e)||s.isSetAccessorDeclaration(e),_e=(e,t)=>e?.compilerNode===t.compilerNode,be=e=>{if(s.isPropertyAccessExpression(e))return{member:e.getName(),object:e.getExpression()};const t=s.isElementAccessExpression(e)?e.getArgumentExpression():void 0;return s.isElementAccessExpression(e)&&s.isStringLiteral(t)?{member:t.getLiteralValue(),object:e.getExpression()}:void 0},ke=e=>{const t=e.getParent();return s.isReturnStatement(t)||s.isArrowFunction(t)&&t.getBody()===e?e.getFirstAncestor(n=>s.isFunctionLikeDeclaration(n)||s.isArrowFunction(n)):void 0},Ce=e=>{const t=g(e);return t&&s.isCallExpression(t)?t:void 0},De=e=>{const t=e.getExportAssignment(r=>!r.isExportEquals());if(!t)return;const i=t.getExpression();if(!s.isIdentifier(i))return i;const n=i.getSymbol()?.getValueDeclaration();return n&&s.isVariableDeclaration(n)?n.getInitializer():i},Ie=e=>{const t=e.getArguments()[1];return t&&s.isStringLiteral(t)?t.getLiteralValue():""},ze=(e,t)=>{if(!s.isObjectLiteralExpression(e))return;const i=v(e,t);if(!i||!s.isPropertyAssignment(i))return;const n=i.getInitializer();return n&&s.isStringLiteral(n)?n.getLiteralText():void 0},le=e=>{const t=e.getStatements(),[i]=t;if(t.length!==1||i===void 0||!s.isReturnStatement(i))return;const n=i.getExpression();return n!==void 0&&s.isObjectLiteralExpression(n)?n:void 0},je=e=>{if(s.isObjectLiteralExpression(e))return e;if(s.isParenthesizedExpression(e)){const t=e.getExpression();return s.isObjectLiteralExpression(t)?t:void 0}return s.isBlock(e)?le(e):void 0},Me=e=>(t,i,n)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return t.getLiteralValue();throw V(t,`${e} "${i}": \`${n}\` must be a static string literal — it is deploy configuration codegen writes into wrangler.jsonc`)},ue=new Set(["api","internal"]),Ve=new Set(["run","runAction","runMutation","runQuery"]),pe=e=>{if(e===void 0||!s.isPropertyAccessExpression(e))return;const t=[];let i=e;for(;s.isPropertyAccessExpression(i);)t.unshift(i.getName()),i=i.getExpression();return s.isIdentifier(i)&&ue.has(i.getText())&&t.length>=2?t:void 0},Ke=e=>{const t=pe(e);return t===void 0?void 0:`${t.slice(0,-1).join("_")}:${String(t.at(-1))}`};export{Ve as RUN_METHODS,H as TS_EXTENSION_RE,we as bindingKeyName,Te as chainRootOf,Fe as collectCallRows,se as collectNodeRows,Pe as collectSecurityCallRows,he as declarationLineOf,De as defaultExportExpression,te as descendantsOfKind,v as findObjectProperty,Ke as functionKeyOf,pe as functionReferenceSegments,Ne as handlerOf,ne as isConstDeclaration,Re as isFunctionLike,_e as isSameNode,ye as isTestPath,A as isWriteTarget,Ie as limitNameOf,b as listLunoraSourceFiles,Z as listSecurityScanFiles,E as lunoraRelativePath,be as memberAccessOf,je as objectLiteralFromCallbackBody,Oe as optionsObjectLiteral,re as outermostValueWrapper,Le as propertyInitializer,W as propertyKeyName,U as propertyNameText,ke as returningFunctionOf,d as staticNumberValue,Me as stringPropertyFor,ze as stringPropertyOf,oe as symbolConstInitializer,g as unwrapExpression,Ce as unwrapToCallExpression,ae as walkChain,Ae as withSourceListMemo};
@@ -0,0 +1,4 @@
1
+ const h=t=>t.methods.filter(e=>e["x-lunora-function-kind"]!=="stream"),b=/[^a-zA-Z0-9]+/gu,j=/([a-z0-9])([A-Z])/gu,p=t=>t.split(b).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(""),I=t=>t.replaceAll(j,"$1_$2").replaceAll(b,"_").toLowerCase(),d=t=>t===void 0?!1:["$ref","allOf","anyOf","enum","items","oneOf","properties","type"].some(e=>e in t),E=t=>t==="query"?"query":t==="action"?"action":"mutation",l=(t,e=0)=>{if(e>32||t===null||typeof t!="object")return!1;if(Array.isArray(t))return t.some(o=>l(o,e+1));const n=t;if(n.format==="int64"&&(n.type===void 0||n.type==="string")||n.type==="string"&&n.contentEncoding==="base64")return!0;const{properties:r}=n;return r!==null&&typeof r=="object"&&Object.values(r).some(o=>l(o,e+1))?!0:["additionalProperties","allOf","anyOf","items","oneOf"].some(o=>l(n[o],e+1))},x=t=>t.replaceAll(/[\n\r\u2028\u2029]+/gu," ").replaceAll("*/","* /").replaceAll('"""','" ""'),C=t=>t.replaceAll("\\","\\\\").replaceAll('"','\\"').replaceAll(`
2
+ `,"\\n").replaceAll("\r","\\r"),N=["$","{","'","$","'","}"].join(""),z=t=>C(t).split("$").join(N),H=(t,e)=>t.argsType!==void 0?e.typed(t.argsType):t.takesArgs?e.untyped:e.none,f=32,A=(t,e=0)=>{if(e>f||t===null||typeof t!="object")return!1;const n=t;return n.type==="null"||Array.isArray(n.type)&&n.type.includes("null")?!0:["anyOf","oneOf"].some(r=>{const o=n[r];return Array.isArray(o)&&o.some(s=>A(s,e+1))})},P=(t,e,n)=>e.length===0?n===0?[]:[t]:e.map(r=>({properties:{...t.properties,...r.properties},required:new Set([...t.required,...r.required])})),k=t=>{const{properties:e}=t;if(e===null||typeof e!="object")return[];const n=t.required;return[{properties:e,required:new Set(Array.isArray(n)?n.filter(r=>typeof r=="string"):[])}]},m=(t,e,n)=>{const r=t[e];return Array.isArray(r)?r.flatMap(o=>w(o,n+1)):[]},w=(t,e=0)=>{if(e>f||t===null||typeof t!="object")return[];const n=t,r=[...k(n),...m(n,"allOf",e)],o={properties:Object.assign({},...r.map(a=>a.properties)),required:new Set(r.flatMap(a=>[...a.required]))},s=[...m(n,"anyOf",e),...m(n,"oneOf",e)];return P(o,s,r.length)},$=(t,e=0)=>{if(e>f||t===null||typeof t!="object")return[];const n=t,r=[n];for(const o of["anyOf","oneOf","allOf"]){const s=n[o];if(Array.isArray(s))for(const a of s)r.push(...$(a,e+1))}return r},y=(t,e,n,r=0)=>{if(r>f||t===null||typeof t!="object")return;const o=w(t),s=[...new Set(o.flatMap(a=>Object.keys(a.properties)))].toSorted((a,c)=>a.localeCompare(c));for(const a of s){const c=[...e,a],u=o.every(i=>i.required.has(a)),g=o.map(i=>i.properties[a]).filter(i=>i!==void 0);u?g.some(i=>A(i))&&n.nullable.push(c):n.optional.push(c);for(const i of g)y(i,c,n,r+1)}for(const a of $(t))for(const c of["additionalProperties","items"]){const u=a[c];u!==null&&typeof u=="object"&&y(u,[...e,"*"],n,r+1)}},q=(t,e)=>t.join("\0").localeCompare(e.join("\0")),L=t=>{const e={nullable:[],optional:[]};y(t,[],e);const n=r=>[...new Map(r.map(o=>[o.join("\0"),o])).values()].toSorted(q);return{nullable:n(e.nullable),optional:n(e.optional)}},S=t=>{const[e="",n=""]=t.name.split(":"),r=`${p(e)}${p(n)}`,o=t.params?.[0]?.schema,s=t.result?.schema;return{argsNullPaths:L(o),argsType:d(o)&&!l(o)?`${r}Args`:void 0,takesArgs:d(o),functionName:n,functionPath:t.name,namespace:e,resultType:d(s)&&!l(s)?`${r}Result`:void 0,summary:t.summary??t.name,verb:E(t["x-lunora-function-kind"])}},U=t=>{const e=new Map;for(const n of h(t)){const r=S(n),o=e.get(r.namespace);o===void 0?e.set(r.namespace,[r]):o.push(r)}return[...e.entries()].toSorted(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({methods:r.toSorted((o,s)=>o.functionName.localeCompare(s.functionName)),name:n}))},W=t=>h(t).flatMap(e=>{const n=S(e);return[{name:n.argsType,schema:e.params?.[0]?.schema},{name:n.resultType,schema:e.result?.schema}]}).filter(e=>e.name!==void 0&&e.schema!==void 0).toSorted((e,n)=>e.name.localeCompare(n.name)),D=/^[A-Za-z][A-Za-z0-9]*$/u,M=t=>D.test(t),_=t=>{const e=new Map;for(const n of t.methods){const r=p(n.functionName);if(!M(r))throw new Error(`sdk: function "${n.functionPath}" produces the invalid identifier "${r}" — rename the export so it starts with a letter.`);const o=n.verb==="query"?[r,`Subscribe${r}`,`Watch${r}`]:[r];for(const s of o){const a=e.get(s);if(a!==void 0){const c=s.startsWith("Watch")?' (the Dart target emits a "watch" Stream member for every query)':"";throw new Error(`sdk: functions "${a}" and "${n.functionPath}" both generate "${s}"${c} — rename one so the generated methods stay distinct.`)}e.set(s,n.functionPath)}}},Z=t=>{const e=new Map;for(const n of t){const r=p(n.name);if(!M(r))throw new Error(`sdk: namespace "${n.name}" produces the invalid identifier "${r}" — rename the file so it starts with a letter.`);const o=e.get(r);if(o!==void 0)throw new Error(`sdk: namespaces "${o}" and "${n.name}" both generate "${r}" — rename one so the generated types stay distinct.`);e.set(r,n.name),_(n)}},F=(t,e,n)=>{for(const r of t){const o=new Map;for(const s of r.methods)for(const a of n(s)){const c=o.get(a);if(c!==void 0&&c!==s.functionPath)throw new Error(`sdk: functions "${c}" and "${s.functionPath}" both generate the ${e} member "${a}" — rename one so the generated methods stay distinct.`);o.set(a,s.functionPath)}}},v=t=>t.flatMap(e=>e.methods),G=t=>[`GENERATED by \`lunora sdk generate --lang ${t}\` — do not edit.`,"Run the command again to regenerate."],R=/^\s*(?:#|\/\/|\/\*|\*)/u,O=t=>t.split(`
3
+ `).filter(e=>!R.test(e)).join(`
4
+ `),T=(t,e)=>new RegExp(String.raw`\b${e}\b`,"u").test(t),B=(t,e)=>{const n=O(e),r=o=>o!==void 0&&T(n,o)?o:void 0;return t.map(o=>({methods:o.methods.map(s=>({...s,argsType:r(s.argsType),resultType:r(s.resultType)})),name:o.name}))},V=t=>h(t).filter(e=>l(e.params?.[0]?.schema)||l(e.result?.schema)).map(e=>e.name).toSorted((e,n)=>e.localeCompare(n)),K=(t,e)=>{const n=O(e);return[...new Set(v(t).flatMap(r=>[r.argsType,r.resultType]).filter(r=>r!==void 0&&!T(n,r)))].toSorted((r,o)=>r.localeCompare(o))},X=t=>[...new Set(v(t).flatMap(e=>[e.argsType,e.resultType]).filter(e=>e!==void 0))].toSorted((e,n)=>e.localeCompare(n));export{v as allMethods,H as argsChoice,F as assertDistinctMembers,Z as assertGeneratable,x as commentText,G as generatedHeaderLines,l as hasUnrepresentableWireType,d as isTypedSchema,z as kotlinLiteral,W as modelSources,L as nullPathsOf,S as parseMethod,U as parseSpec,X as referencedModels,C as stringLiteral,p as toPascalCase,I as toSnakeCase,K as undeclaredModels,V as unrepresentableFunctions,E as verbForKind,B as withDeclaredModels};
@@ -0,0 +1 @@
1
+ const a=(r,s)=>`JSON.parse(${JSON.stringify(JSON.stringify(r))}) as ${s}`;export{a as r};
@@ -0,0 +1 @@
1
+ import{b as a,p as t,e as i,r as s,c,d,a as n}from"./project-config-file-DR7xrrNB.mjs";import"./property-name-7cBlgK_O.mjs";import{PROJECT_CONFIG_FILENAMES as P,findProjectConfigFile as f}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";export{P as PROJECT_CONFIG_FILENAMES,f as findProjectConfigFile,a as loadProjectConfig,t as projectConfigProblems,i as readMergeDurableObjects,s as readProjectConfigLiterals,c as readProjectLazyFunctions,d as readProjectSecurityHeaders,n as readProjectStudioCompanion};
@@ -0,0 +1 @@
1
+ const r=/(?:^|\/)_generated\/server(?:\.js)?$/u,s=new Set(["@lunora/server","lunorash/server"]),o=e=>s.has(e),n=e=>r.test(e),t=e=>o(e)||n(e),a=new Set(["@lunora/scheduler",...s]),E=e=>a.has(e);export{o as a,t as b,E as i};
@@ -0,0 +1 @@
1
+ import{basename as b}from"node:path";import{Node as d}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{listLunoraSourceFiles as $,lunoraRelativePath as v,unwrapToCallExpression as E,defaultExportExpression as S,findObjectProperty as M}from"./isTestPath-Uwb5a6Kq.mjs";import{s as g}from"./dispatch-namespace-DwTjD7BU.mjs";const h=(e,o)=>e.find(t=>t.ownsFolder!==!1&&o.startsWith(`${t.name}/`))?.name,F="module.ts",w=(e,o,t)=>{if(d.isStringLiteral(e)||d.isNoSubstitutionTemplateLiteral(e))return e.getLiteralValue();throw c(e,`module "${o}": \`${t}\` must be a static string literal — codegen reads it without running the file`)},L=(e,o,t)=>{if(!d.isArrayLiteralExpression(e))throw c(e,`module "${o}": \`${t}\` must be an inline array of table names`);return e.getElements().map(n=>w(n,o,t))},p=(e,o,t)=>{const n=M(e,o);if(n!==void 0){if(!d.isPropertyAssignment(n))throw c(n,`module "${t}": write \`${o}\` inline as \`${o}: …\` — codegen reads it without running the file`);return n.getInitializerOrThrow()}},A=(e,o,t)=>{const n=e.getSourceFile(o)??e.addSourceFileAtPath(o),s=E(S(n)),a=s?.getExpression();if(!s||!a||!d.isIdentifier(a)||a.getText()!=="defineModule")return;if(t==="")throw c(s,"defineModule: lunora/module.ts would make the whole app one module — move it into the folder it describes (lunora/<module>/module.ts)");const i=s.getArguments()[0],m={name:t,tables:[]};if(i===void 0)return m;if(!d.isObjectLiteralExpression(i))throw c(i,`module "${t}": defineModule must be passed an inline object literal`);const r=p(i,"description",t);r!==void 0&&(m.description=w(r,t,"description"));const l=p(i,"tables",t);return l!==void 0&&(m.tables=L(l,t,"tables")),m},k=(e,o)=>{const t=[];for(const n of $(o)){if(b(n)!==F)continue;const s=v(o,n),a=A(e,n,s==="module"?"":s.slice(0,-7));a&&t.push(a)}return t.toSorted((n,s)=>n.name.localeCompare(s.name))},T=(e,o)=>{const t=new Set(e.map(r=>r.name)),n=new Set(e.flatMap(r=>r.tables)),s=o.tables.filter(r=>r.extensionKey!==void 0&&!n.has(r.name)),a=Map.groupBy(s,r=>String(r.extensionKey)),i=e.map(r=>{const l=a.get(r.name);return l===void 0?r:{...r,tables:[...r.tables,...l.map(u=>u.name)]}}),m=[...a].filter(([r])=>!t.has(r)).map(([r,l])=>{const u=l.every(f=>f.extensionFromPackage===!0);return{installed:!0,name:r,...u?{ownsFolder:!1}:{},tables:l.map(f=>f.name)}});return[...i,...m].toSorted((r,l)=>r.name.localeCompare(l.name))},x=e=>{for(const o of e){const t=e.find(n=>n.name.startsWith(`${o.name}/`));if(t)throw new Error(`@lunora/codegen: module "${t.name}" is nested inside ${o.installed===!0?"installed component":"module"} "${o.name}" — a file can belong to one module only, so move one of the two`)}},y=(e,o)=>{const t=new Set(o.tables.map(s=>s.name)),n=new Map;for(const s of e)for(const a of s.tables){if(!t.has(a))throw new Error(`@lunora/codegen: module "${s.name}" declares table "${a}", which lunora/schema.ts does not define`);const i=n.get(a);if(i!==void 0)throw new Error(`@lunora/codegen: table "${a}" is claimed by both module "${i}" and module "${s.name}" — a table has one owner`);n.set(a,s.name)}},C=(e,o,t)=>{if(e.length===0)return;const n=new Set(o.map(s=>s.name));for(const s of t){const a=g(s);if(h(o,s)===void 0&&n.has(a))throw new Error(`@lunora/codegen: lunora/${s}.ts sits beside module "${a}" and shares its name — move it into lunora/${a}/ or rename one of them`)}},z=(e,o,t)=>{const n=T(e,o);return x(n),y(n,o),C(e,n,t),n},K=(e,o)=>h(e,o)??g(o);export{h as a,k as d,K as m,z as r};
@@ -0,0 +1 @@
1
+ import{LunoraError as y}from"@lunora/errors";import{Node as i,VariableDeclarationKind as E}from"ts-morph";import{diagnosticAt as h}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{s as A}from"./property-name-7cBlgK_O.mjs";let g;const q=e=>{g=e},k=/^[A-Za-z_$][\w$]*$/u,p=new Set(["$defaultFn","$onUpdateFn","$type","default","defaultNow","nullable","serverDefault","unique"]),N=(e,t)=>{const r={notNull:!0,...e.column};switch(t){case"$defaultFn":case"default":case"defaultNow":case"serverDefault":{r.hasDefault=!0;break}case"$onUpdateFn":{r.hasOnUpdate=!0;break}case"$type":break;case"nullable":{r.notNull=!1;break}case"unique":{r.unique=!0;break}}return{...e,column:r}},T=new Set(["any","bigint","boolean","bytes","date","geoPoint","null","number","string","timestamp"]),m=new Set(["check","email","int","length","max","min","pattern","positive","url"]),I=new Set(["meta"]),L=new Set(["strip"]),l=new Set,f=new Set,v=e=>{const t=e.getSymbol();let r=(t?.getAliasedSymbol()??t)?.getValueDeclaration();if(r!==void 0&&i.isShorthandPropertyAssignment(r)){const n=r.getValueSymbol();r=(n?.getAliasedSymbol()??n)?.getValueDeclaration()}if(!(r===void 0||!i.isVariableDeclaration(r)))return r.getInitializer()},w=e=>{const t=e.getParent();return!i.isVariableDeclaration(t)||t.getVariableStatement()?.getDeclarationKind()===E.Const},u=e=>{if(i.isParenthesizedExpression(e)||i.isAsExpression(e)||i.isSatisfiesExpression(e))return u(e.getExpression());if(i.isObjectLiteralExpression(e))return e;if(i.isPropertyAccessExpression(e)){const r=e.getSymbol()?.getValueDeclaration(),n=r!==void 0&&i.isPropertyAssignment(r)?r.getInitializer():void 0;return n===void 0?void 0:u(n)}if(!i.isIdentifier(e)||l.has(e))return;const t=v(e);if(!(t===void 0||!w(t))){l.add(e);try{return u(t)}finally{l.delete(e)}}},D="v",R=e=>{if(i.isIdentifier(e))return!0;let t=e;for(;i.isCallExpression(t);){const r=t.getExpression();if(!i.isPropertyAccessExpression(r))return!1;t=r.getExpression()}return i.isIdentifier(t)&&t.getText()===D},d=e=>{if(i.isIdentifier(e)&&!l.has(e)){const t=v(e);if(t!==void 0&&R(t)){l.add(e);try{return d(t)}finally{l.delete(e)}}}return i.isCallExpression(e)?C(e):{kind:"any",sourceText:e.getText()}},S=e=>{const t=u(e);if(t===void 0||f.has(t))return{};f.add(t);try{return x(t)}finally{f.delete(t)}},b=(e,t=new Set)=>{const r=u(e);if(r===void 0||t.has(r))return!1;t.add(r);try{return r.getProperties().every(n=>i.isSpreadAssignment(n)?b(n.getExpression(),t):i.isPropertyAssignment(n)||i.isShorthandPropertyAssignment(n))}finally{t.delete(r)}},P=e=>{if(e===void 0||!i.isExpression(e))return{kind:"object",shape:{},unresolvedShape:!0};const t=S(e);return b(e)?{kind:"object",shape:t}:{kind:"object",shape:t,unresolvedShape:!0}},V=e=>{throw h(e,`computed property name ${e.getText()} must be a string literal — codegen resolves object keys statically.`)},x=e=>{const t={};for(const r of e.getProperties()){if(i.isSpreadAssignment(r)){Object.assign(t,S(r.getExpression()));continue}const n=i.isShorthandPropertyAssignment(r);if(!n&&!i.isPropertyAssignment(r))continue;const a=n?r.getNameNode():r.getInitializer();if(!a)continue;const s=r.getNameNode(),o=A(s)??V(s);if(!k.test(o))throw new y("INTERNAL",`@lunora/codegen: field name is not a valid JS identifier: ${JSON.stringify(o)}`);t[o]=d(a)}return t},c=(e,t)=>e&&i.isExpression(e)?d(e):t,O=e=>e.sensitive===!0?!0:[e.inner,e.keyType,e.valueType,...e.members??[],...Object.values(e.shape??{})].some(r=>r!==void 0&&O(r)),M=e=>e===void 0?"undefined":i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e)?JSON.stringify(e.getLiteralValue()):e.getText(),$=e=>{const t=e&&g?g(e):void 0;return t===void 0?{kind:"from"}:{kind:"from",tsType:t}},F=(e,t,r)=>{if(T.has(e))return{kind:e};const[n,a]=t;switch(e){case"array":return{inner:c(n,{kind:"any"}),kind:"array"};case"from":return $(n);case"id":{if(!n||!i.isStringLiteral(n))throw h(n??r,`v.id(...) target table must be a string literal — codegen resolves foreign-key targets statically. Got ${n?n.getText():"no argument"}.`);return{kind:"id",tableName:n.getLiteralText()}}case"literal":return{kind:"literal",literalValue:M(n)};case"object":return P(n);case"optional":return{inner:c(n,{kind:"any"}),kind:"optional"};case"record":return{keyType:c(n,{kind:"string"}),kind:"record",valueType:c(a,{kind:"any"})};case"sensitive":return{...c(n,{kind:"any"}),sensitive:!0};case"storage":return n&&i.isStringLiteral(n)?{bucket:n.getLiteralText(),kind:"storage"}:{kind:"storage"};case"union":return{kind:"union",members:t.filter(s=>i.isExpression(s)).map(s=>d(s))};default:throw new y("INTERNAL",`Unsupported validator kind: ${e}`)}},j=e=>{const[t]=e;if(e.length!==1||t===void 0||!i.isNumericLiteral(t))return;const r=Number(t.getText().replaceAll("_",""));return Number.isSafeInteger(r)&&r>=0?r:void 0},C=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return{kind:"any",sourceText:e.getText()};const r=t.getName(),n=e.getArguments();if(p.has(r)||m.has(r)||I.has(r)||L.has(r)){const a=t.getExpression(),s=i.isExpression(a)?d(a):{kind:"any"};if(p.has(r))return N(s,r);if(!m.has(r))return s;const o=r==="max"&&s.kind==="string"?j(n):void 0;return o!==void 0?{...s,hasRefinement:!0,stringMaxLength:Math.min(s.stringMaxLength??o,o)}:{...s,hasRefinement:!0,unmodelledRefinement:!0}}return F(r,n,e)};export{d as a,x as p,u as r,q as s,O as v};
@@ -0,0 +1 @@
1
+ const o=s=>s.filter(i=>i.topic===void 0),p=(s,i)=>s.filter(t=>t.topic===i);export{o as p,p as s};
@@ -0,0 +1 @@
1
+ import{w as a,r as l}from"./classify-procedure-call-BmEirzc_.mjs";import{Node as e}from"ts-morph";import{unwrapExpression as o,symbolConstInitializer as c}from"./isTestPath-Uwb5a6Kq.mjs";const E=r=>a(r,"use","rls"),t=r=>{const s=o(r);return!s||!e.isIdentifier(s)?s:o(c(s.getSymbol()))},u=r=>r&&e.isCallExpression(r)&&l(r.getExpression(),"definePolicies")?t(r.getArguments()[0]):r,f=r=>{if(r&&e.isObjectLiteralExpression(r))return r;if(r&&e.isCallExpression(r)&&l(r.getExpression(),"definePolicy")){const s=t(r.getArguments()[0]);return s&&e.isObjectLiteralExpression(s)?s:void 0}},b=r=>{const s=u(t(r.getArguments()[0]));if(!s||!e.isArrayLiteralExpression(s))return[];const i=[];for(const p of s.getElements()){const n=f(t(p));n&&i.push(n)}return i};export{b as p,E as r};
@@ -0,0 +1 @@
1
+ import{statSync as B,readFileSync as se}from"node:fs";import{basename as j}from"node:path";import{createJiti as ie}from"jiti";import{Node as s,SyntaxKind as p,VariableDeclarationKind as J,Project as oe}from"ts-morph";import{s as ae,a as h}from"./property-name-7cBlgK_O.mjs";import{findProjectConfigFile as W,findCodegenConfigFile as w}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";const q=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype},ce=/^[a-z][\d+.a-z-]*:\/\/(?:\*\.)?[\d.a-z-]+(?::\d{1,5})?$/iu,Q=e=>[...e].every(t=>t===" "||t>=" "&&t!==""&&t<="ÿ"),le=["same-origin","same-origin-allow-popups","unsafe-none"],ue=["DENY","SAMEORIGIN"],$=["includeSubDomains","maxAge","preload"],X=["csp","permissionsPolicy","referrerPolicy"],I=[...X,"crossOriginOpenerPolicy","frameAncestors","frameOptions","hsts"],M=e=>e.map(t=>JSON.stringify(t)).join(", "),de=(e,t)=>{if(typeof e=="boolean")return e;if(!q(e)){t.push("security.headers.hsts must be a boolean or an object { maxAge?, includeSubDomains?, preload? }");return}for(const o of Object.keys(e).filter(a=>!$.includes(a)))t.push(`security.headers.hsts.${o} is not an option (expected ${M($)})`);const{includeSubDomains:r,maxAge:n,preload:i}=e;n!==void 0&&!(typeof n=="number"&&Number.isSafeInteger(n)&&n>=0)&&t.push(`security.headers.hsts.maxAge must be a whole number of seconds (got ${JSON.stringify(n)})`);for(const[o,a]of[["includeSubDomains",r],["preload",i]])a!==void 0&&typeof a!="boolean"&&t.push(`security.headers.hsts.${o} must be a boolean`);return{...r===void 0?{}:{includeSubDomains:r},...n===void 0?{}:{maxAge:n},...i===void 0?{}:{preload:i}}},V=(e,t,r,n)=>{if(t===void 0||t===!1||r.includes(t))return t;n.push(`security.headers.${e} must be one of ${M(r)} or false (got ${JSON.stringify(t)})`)},fe=(e,t)=>{if(e!==void 0){if(!Array.isArray(e)){t.push('security.headers.frameAncestors must be an array of origins like ["https://partner.example"]');return}for(const r of e)(typeof r!="string"||!ce.test(r)||!Q(r))&&t.push(`security.headers.frameAncestors entry ${JSON.stringify(r)} is not an origin like "https://partner.example"`);return[...e]}},pe=e=>{if(e===void 0||typeof e=="boolean")return{ok:!0,value:e};if(!q(e))return{ok:!1,problems:[`security.headers must be a boolean or an object (got ${Array.isArray(e)?"an array":JSON.stringify(e)})`]};const t=Object.keys(e).filter(n=>!I.includes(n)).map(n=>`security.headers.${n} is not an option (expected ${M(I)})`),r={};for(const n of X){const i=e[n];i===void 0||i===!1?r[n]=i:typeof i!="string"?t.push(`security.headers.${n} must be a string or false`):Q(i)?r[n]=i:t.push(`security.headers.${n} contains a line break or control character`)}return r.crossOriginOpenerPolicy=V("crossOriginOpenerPolicy",e.crossOriginOpenerPolicy,le,t),r.frameOptions=V("frameOptions",e.frameOptions,ue,t),r.frameAncestors=fe(e.frameAncestors,t),r.hsts=e.hsts===void 0?void 0:de(e.hsts,t),r.frameAncestors!==void 0&&typeof r.csp=="string"&&t.push("security.headers.frameAncestors cannot be combined with a csp string: put the frame-ancestors directive in the csp"),r.frameAncestors!==void 0&&r.frameOptions==="DENY"&&t.push('security.headers.frameAncestors cannot be combined with frameOptions: "DENY"'),r.frameAncestors!==void 0&&r.csp===!1&&t.push("security.headers.frameAncestors needs the Content-Security-Policy that carries it; it cannot be combined with csp: false"),t.length>0?{ok:!1,problems:t}:{ok:!0,value:Object.fromEntries(Object.entries(r).filter(([,n])=>n!==void 0))}},ge=(e,t)=>{const r=Array.from({length:t.length+1},(n,i)=>i);for(let n=1;n<=e.length;n+=1){let i=r[0]??0;r[0]=n;for(let o=1;o<=t.length;o+=1){const a=r[o]??0,l=e[n-1]===t[o-1]?0:1;r[o]=Math.min((r[o-1]??0)+1,a+1,i+l),i=a}}return r[t.length]??0},me=(e,t)=>{let r,n=Number.POSITIVE_INFINITY;for(const o of t){const a=ge(e,o);a<n&&(n=a,r=o)}const i=Math.max(2,Math.ceil(e.length/3));return r!==void 0&&n<=i?r:void 0},g=Symbol("not-literal"),C=e=>Number(e.getText().replaceAll("_","")),b=e=>s.isTrueLiteral(e)||s.isFalseLiteral(e)?e.getLiteralValue():s.isPrefixUnaryExpression(e)&&e.getOperatorToken()===p.ExclamationToken&&s.isNumericLiteral(e.getOperand())?C(e.getOperand())===0:void 0,be=e=>{if(s.isStringLiteral(e)||s.isNoSubstitutionTemplateLiteral(e))return e.getLiteralValue();if(s.isNumericLiteral(e))return C(e);if(s.isPrefixUnaryExpression(e)&&e.getOperatorToken()===p.MinusToken&&s.isNumericLiteral(e.getOperand()))return-C(e.getOperand());const t=b(e);return t!==void 0?t:s.isBinaryExpression(e)?ve(e):s.isNullLiteral(e)?null:g},ye={[p.AsteriskAsteriskToken]:(e,t)=>e**t,[p.AsteriskToken]:(e,t)=>e*t,[p.MinusToken]:(e,t)=>e-t,[p.PercentToken]:(e,t)=>e%t,[p.PlusToken]:(e,t)=>e+t,[p.SlashToken]:(e,t)=>e/t},ve=e=>{const t=ye[e.getOperatorToken().getKind()],[r,n]=[S(e.getLeft()),S(e.getRight())];return t!==void 0&&typeof r=="number"&&typeof n=="number"&&Number.isFinite(r)&&Number.isFinite(n)?t(r,n):g},S=e=>{if(s.isParenthesizedExpression(e)||s.isAsExpression(e)||s.isSatisfiesExpression(e))return S(e.getExpression());if(s.isArrayLiteralExpression(e)){const t=e.getElements().map(r=>S(r));return t.includes(g)?g:t}return s.isObjectLiteralExpression(e)?he(e):be(e)},he=e=>{const t=[];for(const r of e.getProperties()){const n=s.isPropertyAssignment(r)?r.getNameNode():void 0,i=s.isPropertyAssignment(r)?r.getInitializer():void 0,o=i===void 0?g:S(i);if(n===void 0||o===g||!(s.isIdentifier(n)||s.isStringLiteral(n)))return g;const a=s.isStringLiteral(n)?n.getLiteralValue():n.getText();if(a==="__proto__")return g;t.push([a,o])}return Object.fromEntries(t)},N={accepts:["boolean"],expected:"a boolean"},xe={accepts:["function"],expected:"a function"},Oe={accepts:["number"],expected:"a number"},E={accepts:["string"],expected:"a string"},D={accepts:["array"],expected:"an array of strings",items:E},L={accepts:["boolean","string"],expected:"a string or `false`",literal:!1},v=(e,t)=>({accepts:["object"],expected:"an object",keys:e,...t===void 0?{}:{required:t}}),Ee={crossOriginOpenerPolicy:L,csp:L,frameAncestors:D,frameOptions:L,hsts:{accepts:["boolean","object"],expected:"a boolean or an object",keys:Object.fromEntries($.map(e=>[e,e==="maxAge"?Oe:N]))},permissionsPolicy:L,referrerPolicy:L},Se={accepts:["boolean","object"],expected:"a boolean or an object",keys:Object.fromEntries(I.toSorted((e,t)=>e.localeCompare(t)).map(e=>[e,Ee[e]]))},u=e=>{let t=e;for(;t!==void 0&&(s.isSatisfiesExpression(t)||s.isAsExpression(t)||s.isParenthesizedExpression(t));)t=t.getExpression();return t},Le=(e,t)=>e.getDescendants().some(r=>{if(s.isBinaryExpression(r)){const n=r.getOperatorToken().getKind(),i=r.getLeft();return n>=p.FirstAssignment&&n<=p.LastAssignment&&s.isIdentifier(i)&&i.getText()===t}return(s.isPrefixUnaryExpression(r)||s.isPostfixUnaryExpression(r))&&(r.getOperatorToken()===p.PlusPlusToken||r.getOperatorToken()===p.MinusMinusToken)&&r.getOperand().getText()===t}),T=(e,t)=>{const r=e.getVariableDeclaration(t);return r===void 0?void 0:r.getVariableStatement()?.getDeclarationKind()===J.Const||!Le(e,t)?r.getInitializer():void 0},Z=(e,t)=>{const r=u(e);return r!==void 0&&s.isIdentifier(r)?u(T(t,r.getText())):r},Ae=e=>{if(e!==void 0)return s.isStringLiteral(e)||s.isNoSubstitutionTemplateLiteral(e)||s.isTemplateExpression(e)?"string":b(e)!==void 0?"boolean":s.isBigIntLiteral(e)||s.isPrefixUnaryExpression(e)&&s.isBigIntLiteral(e.getOperand())?"bigint":s.isNumericLiteral(e)||s.isPrefixUnaryExpression(e)&&s.isNumericLiteral(e.getOperand())?"number":s.isNullLiteral(e)?"null":s.isObjectLiteralExpression(e)?"object":s.isArrayLiteralExpression(e)?"array":s.isArrowFunction(e)||s.isFunctionExpression(e)||s.isMethodDeclaration(e)?"function":void 0},Ne={array:"an array",bigint:"a bigint",boolean:"a boolean",function:"a function",null:"null",number:"a number",object:"an object",string:"a string"},_=e=>s.isPropertyAssignment(e)?e.getInitializer():s.isShorthandPropertyAssignment(e)?e.getNameNode():s.isMethodDeclaration(e)?e:void 0,je=(e,t,r)=>{const n=l=>t===""?l:`${t}.${l}`,i=me(e,r),o=i===void 0?"":` Did you mean \`${n(i)}\`?`,a=t===""?"":` of \`${t}\``;return`unknown key \`${n(e)}\`.${o} Valid keys${a}: ${r.join(", ")}.`},ee=(e,t,r,n)=>{const i=Z(e,n),o=Ae(i);if(i===void 0||o===void 0)return[];const a=i.getText(),l=a.length>40?`${a.slice(0,37)}...`:a;if(!t.accepts.includes(o))return[`\`${r}\` must be ${t.expected}, got ${Ne[o]} (${l}).`];if(t.literal!==void 0&&o==="boolean"&&b(i)!==t.literal)return[`\`${r}\` must be ${t.expected}, got \`${a}\`.${t.hint===void 0?"":` ${t.hint}`}`];if(t.items!==void 0&&s.isArrayLiteralExpression(i)){const{items:c}=t,d=i.getElements(),f=d.findIndex(O=>s.isSpreadElement(O));return(f===-1?d:d.slice(0,f)).flatMap((O,ne)=>ee(O,c,`${r}[${String(ne)}]`,n))}return s.isObjectLiteralExpression(i)&&(t.keys!==void 0||t.entries!==void 0)?R(i,t,r,n):[]},Pe=(e,t,r)=>{const n=(e.required??[]).filter(i=>!t.has(i));return n.length===0?[]:[`\`${r}\` is missing ${n.map(i=>`\`${i}\``).join(", ")}.`]},R=(e,t,r,n,i=!1)=>{const o=e.getProperties(),a=f=>s.isSpreadAssignment(f)?void 0:ae(f.getNameNode()),l=!i&&o.every(f=>a(f)!==void 0),c=[],d=new Map(o.map(f=>[a(f),f]));for(const f of o){const y=a(f);if(y===void 0)continue;const O=t.entries??(t.keys!==void 0&&Object.hasOwn(t.keys,y)?t.keys[y]:void 0);O===void 0?c.push(je(y,r,Object.keys(t.keys??{}))):c.push(...Te(f,O,r===""?y:`${r}.${y}`,n,l&&d.get(y)===f))}return l?[...c,...Pe(t,d,r)]:c},Te=(e,t,r,n,i)=>{if(s.isGetAccessorDeclaration(e)||s.isSetAccessorDeclaration(e))return[];if(i)return ee(_(e),t,r,n);const o=Z(_(e),n);return o!==void 0&&s.isObjectLiteralExpression(o)&&(t.keys!==void 0||t.entries!==void 0)?R(o,t,r,n,!0):[]},ke=e=>s.isInterfaceDeclaration(e)||s.isTypeAliasDeclaration(e)||s.isExportSpecifier(e)&&(e.isTypeOnly()||e.getExportDeclaration().isTypeOnly()),$e=e=>e.getExportSymbols().filter(t=>{const r=t.getDeclarations();return r.length===0||!r.every(n=>ke(n))}).map(t=>t.getName()),Ie=(e,t,r)=>{if(t.getExportSymbols().some(c=>c.getName()==="default"))return;const n=$e(t),i=t.getExportDeclarations().filter(c=>c.isNamespaceExport()&&c.getNamespaceExport()===void 0&&!c.isTypeOnly()).map(c=>c.getModuleSpecifierValue()).filter(c=>c!==void 0);if(n.length===0&&i.length===0)return;if(n.length===0)return`${e} has no default export, so none of its settings are read (it only re-exports ${i.map(c=>`\`${c}\``).join(", ")} with \`export *\`, which never forwards a default). Lunora reads only the default export, and codegen reads its settings from this file without loading the modules it imports: move them here as \`export default { … } satisfies LunoraConfig\`.`;const o=n.filter(c=>r.has(c)),a=n.filter(c=>{const d=u(T(t,c));return!r.has(c)&&d!==void 0&&s.isObjectLiteralExpression(d)});let l="`export default { … } satisfies LunoraConfig`";return o.length>0?l=`\`export default { ${o.join(", ")} } satisfies LunoraConfig\``:a.length===1&&(l=`\`export default ${String(a[0])};\` in place of the named export`),`${e} has no default export, so none of its settings are read (it exports ${n.map(c=>`\`${c}\``).join(", ")}). Lunora reads only the default export: ${l}.`},te=e=>{const t=e.getExportAssignments().find(i=>!i.isExportEquals()),r=e.getExportDeclarations().filter(i=>!i.hasModuleSpecifier()&&!i.isTypeOnly()).flatMap(i=>i.getNamedExports()).find(i=>(i.getAliasNode()?.getText()??i.getName())==="default"),n=t===void 0&&r!==void 0?r.getNameNode():u(t?.getExpression());return n!==void 0&&s.isIdentifier(n)?u(T(e,n.getText())):n},Ce=e=>{const t=te(e);return t!==void 0&&s.isObjectLiteralExpression(t)?t:void 0},De=e=>{const t=te(e);if(t!==void 0)return s.isArrayLiteralExpression(t)?"an array":s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isTemplateExpression(t)?"a string":s.isNumericLiteral(t)?"a number":b(t)!==void 0?"a boolean":s.isNullLiteral(t)?"null":void 0},m=(e,t)=>s.isPropertyAssignment(e)?e.getInitializer():T(t,h(e)),x=(e,t,r)=>{const n=u(e);if(n===void 0||!s.isObjectLiteralExpression(n))return{unreadable:!0};const i=n.getProperties(),o=i.filter(c=>s.isPropertyAssignment(c)&&!s.isComputedPropertyName(c.getNameNode())||s.isShorthandPropertyAssignment(c));if(o.length!==i.length)return{unreadable:!0};const a=o.findLast(c=>h(c)===r);if(a===void 0)return{absent:!0};const l=m(a,t);return l===void 0?{unreadable:!0}:{literal:l}},z=["exportName","file","reason","rule"],ze=e=>{const t=u(e);if(t===void 0||!s.isObjectLiteralExpression(t))return;const r={};for(const l of t.getProperties()){if(!s.isPropertyAssignment(l)||s.isComputedPropertyName(l.getNameNode()))return;const c=h(l),d=u(l.getInitializer());if(!z.includes(c)||d===void 0||!s.isStringLiteral(d)&&!s.isNoSubstitutionTemplateLiteral(d))return;r[c]=d.getLiteralValue()}const{exportName:n,file:i,reason:o,rule:a}=r;return n?.trim()&&i?.trim()&&o?.trim()&&a?.trim()?{exportName:n,file:i,reason:o,rule:a}:void 0},we=(e,t)=>{const r=x(e,t,"accept");if("absent"in r)return{};const n="literal"in r?u(r.literal):void 0;if(n===void 0||!s.isArrayLiteralExpression(n))return{acceptUnreadable:!0};const i=[];for(const o of n.getElements()){const a=ze(o);if(a===void 0)return{acceptUnreadable:!0};i.push(a)}return{accept:i}},Me=(e,t)=>{const r=x(e,t,"minSeverity"),n=we(e,t);return"absent"in r?{advisor:n}:"literal"in r&&s.isStringLiteral(r.literal)?{advisor:{...n,minSeverity:r.literal.getLiteralValue()}}:{advisor:{...n,unreadable:!0}}},Re=(e,t)=>{const r=x(e,t,"exclude");if("absent"in r)return{};if(!("literal"in r)||!s.isArrayLiteralExpression(r.literal))return{unreadable:!0};const n=[];for(const i of r.literal.getElements()){if(!s.isStringLiteral(i)&&!s.isNoSubstitutionTemplateLiteral(i)||i.getLiteralValue().startsWith("!"))return{unreadable:!0};n.push(i.getLiteralValue())}return{exclude:n}},Ve=(e,t,r)=>{const n=x(e,t,"lazyFunctions");if("absent"in n)return{};if("unreadable"in n)return e!==void 0&&(s.isIdentifier(e)||e.getText().includes("lazyFunctions")||r&&!s.isObjectLiteralExpression(e))?{lazyFunctionsUnreadable:!0}:{};const i="literal"in n?u(n.literal):void 0,o=i===void 0?void 0:b(i);return o===void 0?{lazyFunctionsUnreadable:!0}:{lazyFunctions:o}},_e=(e,t)=>{const r=u(e),n=r!==void 0&&s.isIdentifier(r),i=r!==void 0&&s.isIdentifier(r)?t.getVariableDeclaration(r.getText()):void 0,o=i?.getVariableStatement()?.getDeclarationKind()===J.Const,a=i?.getNameNode(),c=i!==void 0&&o&&a!==void 0&&s.isIdentifier(a)&&a.findReferencesAsNodes().length===1?u(i.getInitializer())??r:r;return{codegen:{...Re(c,t),...Ve(c,t,n)}}},Ue=(e,t)=>{const r=x(e,t,"merge");if("absent"in r)return{durableObjects:{}};const n="literal"in r?b(r.literal):void 0;return n===void 0?{durableObjects:{unreadable:!0}}:{durableObjects:{merge:n}}},Fe=(e,t)=>{const r=x(e,t,"companion");if("absent"in r)return{studio:{}};const n="literal"in r?b(r.literal):void 0;return n===void 0?{studio:{unreadable:!0}}:{studio:{companion:n}}},Ke=(e,t)=>{const r=x(e,t,"headers");if("absent"in r)return{security:{}};const n="literal"in r?S(r.literal):g;return n===g?{security:{unreadable:!0}}:{security:{headers:n}}},re=(e,t)=>{const r=e.getProperty(t);if(r!==void 0)return(s.isPropertyAssignment(r)?r.getInitializer():void 0)??"unreadable"},U=(e,t)=>{const r=re(e,t);if(r!==void 0)return r!=="unreadable"&&(s.isStringLiteral(r)||s.isNoSubstitutionTemplateLiteral(r))?r.getLiteralValue():!1},Ye=e=>{const t=re(e,"rpc");if(t!==void 0)return t!=="unreadable"&&b(t)===!1?!1:"unreadable"},He=e=>{const t=u(e);if(t===void 0||!s.isObjectLiteralExpression(t))return{services:{unreadable:!0}};const r={};for(const n of t.getProperties()){if(!s.isPropertyAssignment(n)||s.isComputedPropertyName(n.getNameNode()))return{services:{unreadable:!0}};const i=u(n.getInitializer());if(i===void 0||!s.isObjectLiteralExpression(i)||i.getProperties().some(c=>!s.isPropertyAssignment(c)))return{services:{unreadable:!0}};const o=U(i,"dir"),a=U(i,"entrypoint"),l=Ye(i);if(typeof o!="string"||a===!1||l==="unreadable")return{services:{unreadable:!0}};r[h(n)]={dir:o,...a===void 0?{}:{entrypoint:a},...l===void 0?{}:{rpc:l}}}return{services:{declared:r}}},Ge=(e,t)=>s.isShorthandPropertyAssignment(e)?e.getNameNode():m(e,t),Be=(e,t)=>{const r=m(e,t);return r!==void 0&&s.isStringLiteral(r)?{target:r.getLiteralValue()}:{unreadable:!0}},Je=(e,t)=>{const r=u(m(e,t)),n=r===void 0?void 0:b(r);return n!==void 0?{remote:n}:r!==void 0&&s.isNullLiteral(r)?{}:r!==void 0&&s.isObjectLiteralExpression(r)?{remote:!0}:{unreadable:!0}},A=new Map([["advisor",{read:(e,t)=>Me(m(e,t),t),shape:v({accept:{...D,expected:"an array of objects",items:v(Object.fromEntries(z.map(e=>[e,E])),z)},minSeverity:E}),unreadable:{advisor:{unreadable:!0}}}],["app",{read:()=>({}),shape:xe,unreadable:{}}],["codegen",{read:(e,t)=>_e(Ge(e,t),t),shape:v({exclude:D,lazyFunctions:N}),unreadable:{codegen:{lazyFunctionsUnreadable:!0,unreadable:!0}}}],["durableObjects",{read:(e,t)=>Ue(m(e,t),t),shape:v({merge:N}),unreadable:{durableObjects:{unreadable:!0}}}],["remote",{read:Je,shape:{accepts:["boolean","null","object"],expected:"a boolean"},unreadable:{unreadable:!0}}],["security",{read:(e,t)=>Ke(m(e,t),t),shape:v({headers:Se}),unreadable:{security:{unreadable:!0}}}],["services",{read:(e,t)=>He(m(e,t)),shape:{accepts:["object"],entries:v({dir:E,entrypoint:E,rpc:{accepts:["boolean"],expected:"`false`",hint:"Leave it out for an RPC binding.",literal:!1}},["dir"]),expected:"an object"},unreadable:{services:{unreadable:!0}}}],["studio",{read:(e,t)=>Fe(m(e,t),t),shape:v({companion:N}),unreadable:{studio:{unreadable:!0}}}],["target",{read:Be,shape:E,unreadable:{unreadable:!0}}]]),We=(e,t)=>s.isGetAccessorDeclaration(e)||s.isMethodDeclaration(e)?A.get(h(e))?.unreadable??{}:!s.isPropertyAssignment(e)&&!s.isShorthandPropertyAssignment(e)?{}:A.get(h(e))?.read(e,t)??{},qe=(e,t)=>new oe({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}).createSourceFile(j(e),t,{overwrite:!0}),Qe=(e,t)=>{if(e.getProperties().some(n=>s.isSpreadAssignment(n))){const n=o=>e.getProperties().some(a=>!s.isSpreadAssignment(a)&&h(a)===o);let i={unreadable:!0};for(const[o,a]of A)n(o)&&(i={...i,...a.unreadable});return i}let r={};for(const n of e.getProperties())r={...r,...We(n,t)};return r},Xe=(e,t)=>{const r=qe(e,t),n=Ce(r);if(n===void 0){const o=De(r),a=o===void 0?Ie(j(e),r,A):`${j(e)} exports ${o} as its default, so none of its settings are read. Lunora reads an object: \`export default { … } satisfies LunoraConfig\`.`;return{literals:{unreadable:!0},...o===void 0?{namedOnly:a}:{notObject:a},problems:a===void 0?[]:[a]}}const i=v(Object.fromEntries([...A].map(([o,a])=>[o,a.shape])));return{literals:Qe(n,r),problems:R(n,i,"",r)}},F=new Map,P=e=>{let t;try{t=se(e,"utf8")}catch{return{literals:{unreadable:!0},problems:[]}}const r=F.get(e);if(r?.source===t)return r.value;const n=Xe(e,t);return F.set(e,{source:t,value:n}),n},K=new Map,at=async e=>{const t=W(e);if(t===void 0)return{};let r;try{const o=B(t);r=`${String(o.mtimeMs)}:${String(o.size)}`}catch{return{}}const n=K.get(t);if(n?.key===r)return n.value;const i=(async()=>{try{const a=(await ie(t,{interopDefault:!1,moduleCache:!1}).import(t))?.default,l=a===void 0?P(t).namedOnly:void 0;return l!==void 0?{error:l}:a!==void 0&&(a===null||typeof a!="object"||Array.isArray(a))?{error:P(t).notObject??`${j(t)}'s default export is not an object, so none of its settings are read. Lunora reads an object: \`export default { … } satisfies LunoraConfig\`.`}:{config:a}}catch(o){return{error:o instanceof Error?o.message:String(o)}}})();return K.set(t,{key:r,value:i}),i},k=e=>P(e).literals,ct=e=>P(e).problems,Ze=e=>{const t=W(e);return t===void 0?{}:k(t)},lt=e=>{const{durableObjects:t}=Ze(e);return t?.unreadable&&console.warn("@lunora/codegen: `durableObjects.merge` in lunora.config is not a boolean literal — the Durable Object classes stay separate."),t?.merge===!0};let Y;const ut=e=>{const t=w(e),{codegen:r}=t===void 0?{}:k(t);if(r?.lazyFunctionsUnreadable){const n=t===void 0?void 0:B(t,{throwIfNoEntry:!1}),i=t===void 0||n===void 0?"":`${t}:${String(n.mtimeMs)}:${String(n.size)}`;i!==Y&&(Y=i,console.warn("@lunora/codegen: `codegen.lazyFunctions` in lunora.config is not a boolean literal, so the config does not turn the function registry lazy."))}return r?.lazyFunctions===!0},H=new Set,dt=e=>{const t=w(e),{studio:r}=t===void 0?{}:k(t);return r?.unreadable&&t!==void 0&&!H.has(t)&&(H.add(t),console.warn("@lunora/codegen: `studio.companion` in lunora.config is not a boolean literal, so the companion Worker is not generated.")),r?.companion===!0},G=new Set,et=(e,t,r)=>{let n;r!==void 0?{problems:n}=r:t.unreadable&&t.security===void 0?n=["is not an object literal codegen can read, so `security.headers` cannot be read either"]:n=["`security.headers` is not built from literals"];const i=`${e??""}:${n.join(";")}`;return G.has(i)||(G.add(i),console.warn(`@lunora/codegen: lunora.config ${n.join("; ")}, so the default security headers apply.`)),!0},ft=e=>{const t=w(e),r=t===void 0?{}:k(t),{security:n}=r,o=n?.unreadable===!0||r.unreadable===!0&&n===void 0?void 0:pe(n?.headers);return o?.ok?o.value:et(t,r,o)};export{g as N,dt as a,at as b,ut as c,ft as d,lt as e,S as l,ct as p,Ze as r};
@@ -0,0 +1 @@
1
+ import{Node as e}from"ts-morph";const i=t=>{if(e.isStringLiteral(t)||e.isNoSubstitutionTemplateLiteral(t)||e.isNumericLiteral(t))return t.getLiteralText();if(e.isComputedPropertyName(t)){const r=t.getExpression();return e.isStringLiteral(r)||e.isNoSubstitutionTemplateLiteral(r)?r.getLiteralText():void 0}return t.getText()},s=t=>i(t)??t.getText(),p=t=>s(t.getNameNode());export{p as a,s as p,i as s};
@@ -0,0 +1 @@
1
+ import{d as E}from"./declared-output-Iaar469J.mjs";import{v as u}from"./shared-Cn7dMQ_u.mjs";const p=/import\("(?<spec>(?:\.\.?\/)*_generated\/[^"]+)"\)/gu,l=/^(?:\.\.?\/)*_generated\//u,i=/\.[A-Za-z]\w*$/u,R=t=>t.replaceAll(p,(e,r)=>{const o=r.replace(l,"./");return`import("${i.test(o)?o:`${o}.js`}")`}),_=/import\("(?<spec>[^"]+)"\)/gu,a="node_modules/",m=/^@types\//u,A=t=>t.replaceAll(_,(e,r)=>{const o=r.lastIndexOf(a);if(o===-1||o>0&&r[o-1]!=="/")return e;const s=r.slice(o+a.length);return s===""||m.test(s)?e:`import("${s}")`}),I=/import\("(?<spec>\.\.?\/[^"]+)"\)/gu,f=/^(?:\.\.?\/)+/u,g=t=>{const e=[];for(const r of t.split("/"))if(!(r===""||r===".")){if(r===".."&&e.length>0&&e.at(-1)!==".."){e.pop();continue}e.push(r)}return e.join("/")},S=(t,e)=>t.replaceAll(I,(r,o)=>{if(l.test(o.replace(f,"")))return r;const s=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",c=`../${g(`${s}/${o}`)}`;return`import("${i.test(c)?c:`${c}.js`}")`}),v=(t,e)=>R(S(A(t),e)),d=["client","do","errors","flags","observability","platform","ratelimit","runtime","server","values"],L=new RegExp(String.raw`import\("@lunora/(?<pkg>${d.join("|")})(?<subpath>/[^"]*)?"\)`,"gu"),T={flags:new Set(["/web"]),platform:new Set},M=(t,e)=>e?t.replaceAll(L,(r,o,s)=>{const n=T[o];return s&&n&&!n.has(s)?r:`import("lunorash/${o}${s??""}")`}):t,O=t=>["Doc","Id"].filter(e=>new RegExp(String.raw`(?<![.$\w])${e}<`,"u").test(t)),U=t=>E(t)?u(t.output):t.returnType;export{O as a,M as b,U as c,v as r};
@@ -0,0 +1 @@
1
+ import{join as r}from"node:path";import{readJsonSync as a}from"@visulima/fs";const p=o=>{try{const t=a(r(o,"package.json")),n=new Set;for(const c of["dependencies","devDependencies","peerDependencies","optionalDependencies"]){const e=t[c];if(e!==null&&typeof e=="object")for(const s of Object.keys(e))n.add(s)}return n}catch{return}};export{p as default};
@@ -0,0 +1 @@
1
+ const s=/[\w+/=-]{40,}/u,n=/[a-z]/u,E=/[A-Z]/u,_=/\d/u,c=/\b(?:[\da-f]{32,}|[\dA-F]{32,})\b/u,o=t=>{const e=s.exec(t)?.[0];return e===void 0?!1:n.test(e)&&E.test(e)&&_.test(e)},i=t=>c.test(t),r=/\b(?:sk|rk)_live_[\dA-Za-z]{20,}/u,a=/\bAKIA[\dA-Z]{16}\b/u,R=/\bgh[posru]_[\dA-Za-z]{36,}/u,d=/\bsk-[\dA-Za-z]{32,}/u,A=/\bxox[abprs]-[\dA-Za-z-]{10,}/u,k=/-----BEGIN(?: [A-Z]+)? PRIVATE KEY-----/u,S=[{kind:"stripe_live_key",test:t=>r.test(t)},{kind:"aws_access_key",test:t=>a.test(t)},{kind:"github_token",test:t=>R.test(t)},{kind:"openai_key",test:t=>d.test(t)},{kind:"slack_token",test:t=>A.test(t)},{kind:"private_key",test:t=>k.test(t)},{kind:"high_entropy",test:o},{kind:"hex_secret",test:i}],u=new Set(["hex_secret","high_entropy"]),h=new Set(["auth","bearer","credential","credentials","hmac","key","keys","passphrase","password","private","secret","secrets","signature","signing","token"]),p=/([a-z\d])([A-Z])/gu,T=/[^A-Za-z\d]+/u,I=t=>t.replaceAll(p,"$1 $2").split(T).filter(Boolean).map(e=>e.toLowerCase()),l=t=>t!==void 0&&I(t).some(e=>h.has(e)),K=t=>S.find(e=>e.test(t))?.kind,b=t=>u.has(t),g=t=>`${t.slice(0,4)}…(${String(t.length)} chars)`;export{S as SECRET_RULES,b as isHeuristicSecretKind,l as isSecretishName,g as redact,K as secretKindOf};
@@ -0,0 +1 @@
1
+ const t=new Set(["arguments","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","eval","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),i=/^[$A-Z_a-z][\w$]*$/u,a=e=>i.test(e)&&!t.has(e);export{t as R,a as i};
@@ -0,0 +1 @@
1
+ const o=d=>typeof d.shardMode=="object"&&d.shardMode.kind==="shardBy";export{o as i};
@@ -0,0 +1 @@
1
+ const o=e=>{try{return JSON.parse(e)}catch{const t=e.trim();return t.length>=2&&(t.startsWith("'")||t.startsWith('"'))&&t.at(-1)===t[0]?t.slice(1,-1):t}},n=e=>{const t={};return e.column!==void 0&&(t.column={defaultValue:e.column.hasDefault===!0?null:void 0,notNull:e.column.notNull,unique:e.column.unique}),e.inner!==void 0&&(t.inner=n(e.inner)),e.members!==void 0&&(t.members=e.members.map(a=>n(a))),e.shape!==void 0&&(t.shape=Object.fromEntries(Object.entries(e.shape).map(([a,l])=>[a,n(l)]))),e.tableName!==void 0&&(t.tableName=e.tableName),e.literalValue!==void 0&&(t.value=o(e.literalValue)),e.keyType!==void 0&&(t.keyValidator=n(e.keyType)),e.valueType!==void 0&&(t.valueValidator=n(e.valueType)),{_meta:t,kind:e.kind}},m=e=>({tables:Object.fromEntries(e.tables.map(a=>[a.name,{indexes:a.indexes,shape:Object.fromEntries(Object.entries(a.shape).map(([l,s])=>[l,n(s)]))}]))});export{m as schemaFromIr};