@lunora/codegen 1.0.0-alpha.291 → 1.0.0-alpha.293

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 (59) hide show
  1. package/dist/index.d.mts +1993 -1926
  2. package/dist/index.d.ts +1993 -1926
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{AGENTS_FILENAME-CwwSEW6a.mjs → AGENTS_FILENAME-B6-kjzM3.mjs} +1 -1
  5. package/dist/packem_shared/{CONTAINERS_FILENAME-BtX5vWh8.mjs → CONTAINERS_FILENAME-Bk0u9QUu.mjs} +1 -1
  6. package/dist/packem_shared/{MUTATORS_FILENAME-Dl1tElqi.mjs → MUTATORS_FILENAME-Bw0YtaO8.mjs} +1 -1
  7. package/dist/packem_shared/{NOTIFY_FILENAME-BeTurUSC.mjs → NOTIFY_FILENAME-CPjbiHQl.mjs} +1 -1
  8. package/dist/packem_shared/{QUEUES_FILENAME-D588u733.mjs → QUEUES_FILENAME-CsRy4VTF.mjs} +1 -1
  9. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-2FV2pwdH.mjs +11 -0
  10. package/dist/packem_shared/{SHAPES_FILENAME-D-Q8lSEw.mjs → SHAPES_FILENAME-DkBUN9dK.mjs} +1 -1
  11. package/dist/packem_shared/{WORKFLOWS_FILENAME-BGMSNTDC.mjs → WORKFLOWS_FILENAME-CQR8fE9B.mjs} +1 -1
  12. package/dist/packem_shared/{attribution-BUciBs1M.mjs → attribution-hVBriwzy.mjs} +1 -1
  13. package/dist/packem_shared/chain-CRDaTj2c.mjs +1 -0
  14. package/dist/packem_shared/classify-procedure-call-BAj0D1u2.mjs +1 -0
  15. package/dist/packem_shared/{context-property-calls-DPnUYWSX.mjs → context-property-calls-DJ_A1R5i.mjs} +1 -1
  16. package/dist/packem_shared/{context-root-Dlo21ybw.mjs → context-root-wBahDTzk.mjs} +1 -1
  17. package/dist/packem_shared/createCodegenProject-V51_yBw3.mjs +1 -0
  18. package/dist/packem_shared/{database-calls-ONnjnkMd.mjs → database-calls-CHZbBUCZ.mjs} +1 -1
  19. package/dist/packem_shared/{discoverAuthApiCalls-DAaK0HUK.mjs → discoverAuthApiCalls-xs0ONfI-.mjs} +1 -1
  20. package/dist/packem_shared/{discoverFunctions-DsQwrwWq.mjs → discoverFunctions-DaEZl3uE.mjs} +1 -1
  21. package/dist/packem_shared/{discoverHttpRoutes-Cv-h-Yuc.mjs → discoverHttpRoutes-C_u9YiFb.mjs} +1 -1
  22. package/dist/packem_shared/discoverHyperdriveCalls-BUrA_96X.mjs +1 -0
  23. package/dist/packem_shared/{discoverInserts-CQsoloGk.mjs → discoverInserts-OT_fiEGq.mjs} +1 -1
  24. package/dist/packem_shared/discoverMaskProcedures--hMyCNud.mjs +1 -0
  25. package/dist/packem_shared/{discoverMigrations-uxm9qHrr.mjs → discoverMigrations-C9mLIhGZ.mjs} +1 -1
  26. package/dist/packem_shared/{discoverNondeterministicCalls-Dm7_PJoA.mjs → discoverNondeterministicCalls-9ZDpRptb.mjs} +1 -1
  27. package/dist/packem_shared/discoverQueries-C8V4cMIP.mjs +1 -0
  28. package/dist/packem_shared/discoverR2sqlCalls-COKmDnih.mjs +1 -0
  29. package/dist/packem_shared/{discoverRlsMetadata-Cu4bc5KZ.mjs → discoverRlsMetadata-Cb8JR1b4.mjs} +1 -1
  30. package/dist/packem_shared/discoverRlsProcedures-CuRLSnf9.mjs +1 -0
  31. package/dist/packem_shared/discoverSchema-Btu1KpBX.mjs +1 -0
  32. package/dist/packem_shared/{discoverStorageRulesMetadata-D6rjgKYC.mjs → discoverStorageRulesMetadata-BPJplDfz.mjs} +1 -1
  33. package/dist/packem_shared/emitAgents-D_UUdNe1.mjs +1 -0
  34. package/dist/packem_shared/{emitApp-D7G7gmV7.mjs → emitApp-DAZCUDbr.mjs} +1 -1
  35. package/dist/packem_shared/{emitCrons-Gd8jD8jF.mjs → emitCrons-BQW2lviZ.mjs} +1 -1
  36. package/dist/packem_shared/emitServer-D1vA5_X1.mjs +1 -0
  37. package/dist/packem_shared/emitShard-DY0iaXec.mjs +1 -0
  38. package/dist/packem_shared/{exported-procedure-chains-BZk1-hro.mjs → exported-procedure-chains-DKK5HoK3.mjs} +1 -1
  39. package/dist/packem_shared/{handler-reference-DXkpwoAq.mjs → handler-reference-vIeqkhV_.mjs} +1 -1
  40. package/dist/packem_shared/{index-BoPXSW7g.mjs → index-BW4hJ4Wm.mjs} +1 -1
  41. package/dist/packem_shared/platform-8oj7iXQy.mjs +1 -0
  42. package/dist/packem_shared/schema-BgM8A3XV.mjs +1 -0
  43. package/dist/packem_shared/{server-DSUfd6Tc.mjs → server-DAvi_bv_.mjs} +2 -2
  44. package/dist/packem_shared/{shard-BNhX5R-a.mjs → shard-DfBMIpi9.mjs} +6 -6
  45. package/dist/packem_shared/{shard-runtime-CkaEBSdL.mjs → shard-runtime-BX0xmo0P.mjs} +3 -3
  46. package/package.json +6 -6
  47. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-3FEkspbx.mjs +0 -11
  48. package/dist/packem_shared/chain-BUxIVIw_.mjs +0 -1
  49. package/dist/packem_shared/classify-procedure-call-BJdf_-M6.mjs +0 -1
  50. package/dist/packem_shared/discoverHyperdriveCalls-xy2G6igG.mjs +0 -1
  51. package/dist/packem_shared/discoverMaskProcedures-Dr1UccD6.mjs +0 -1
  52. package/dist/packem_shared/discoverQueries-BqECbkm9.mjs +0 -1
  53. package/dist/packem_shared/discoverR2sqlCalls-I9IqJFcy.mjs +0 -1
  54. package/dist/packem_shared/discoverRlsProcedures-Bkohn4ZR.mjs +0 -1
  55. package/dist/packem_shared/discoverSchema-BCxeD80d.mjs +0 -1
  56. package/dist/packem_shared/emitAgents-BedQefBj.mjs +0 -1
  57. package/dist/packem_shared/emitServer-DlOheWku.mjs +0 -1
  58. package/dist/packem_shared/emitShard-DguoZWGv.mjs +0 -1
  59. package/dist/packem_shared/ir-DBSvhNa-.mjs +0 -1
@@ -1 +1 @@
1
- import{existsSync as m}from"node:fs";import{join as u}from"node:path";import{SyntaxKind as p,Node as o}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as f}from"./module-specifiers-WF8iAydP.mjs";import{p as d}from"./parse-validator-IDBKIT7M.mjs";import{findObjectProperty as l}from"./isTestPath-B81lOULB.mjs";import{a as S}from"./attribution-BUciBs1M.mjs";const h="shapes.ts",b=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineShape";for(const e of t.getDeclarations())if(o.isImportSpecifier(e))return f(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineShape":!1;return!1},x=r=>{const t=r.getSymbol();if(!t)return!1;for(const e of t.getDeclarations()){if(!o.isNamespaceImport(e))continue;const i=e.getFirstAncestorByKind(p.ImportDeclaration);return i!==void 0&&f(i.getModuleSpecifierValue())}return!1},y=r=>{if(o.isIdentifier(r))return b(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineShape"&&o.isIdentifier(t)&&x(t)}return!1},N=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return;const e=l(t,"table");if(!e||!o.isPropertyAssignment(e))return;const i=e.getInitializer();return i&&o.isStringLiteral(i)?i.getLiteralValue():void 0},E=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return{};const e=l(t,"args");if(!e||!o.isPropertyAssignment(e))return{};const i=e.getInitializer();return!i||!o.isObjectLiteralExpression(i)?{}:d(i)},I=r=>{const t=[];for(const e of r.getVariableDeclarations()){const i=e.getInitializer();if(i?.getKind()!==p.CallExpression)continue;const s=i,a=s.getExpression();if(!y(a))continue;const n=e.getNameNode();if(!o.isIdentifier(n)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw g(n,"defineShape exports must be plain named exports (no destructuring)")}const c=S(e,"binding");c!==void 0&&t.push({args:E(s),exportName:c,filePath:"shapes",table:N(s)})}return t},z=(r,t)=>{const e=u(t,h);if(!m(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),s=I(i);return s.sort((a,n)=>a.exportName.localeCompare(n.exportName)),s};export{h as SHAPES_FILENAME,z as discoverShapes};
1
+ import{existsSync as m}from"node:fs";import{join as u}from"node:path";import{SyntaxKind as p,Node as o}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as f}from"./module-specifiers-WF8iAydP.mjs";import{p as d}from"./parse-validator-IDBKIT7M.mjs";import{findObjectProperty as l}from"./isTestPath-B81lOULB.mjs";import{a as S}from"./attribution-hVBriwzy.mjs";const h="shapes.ts",b=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineShape";for(const e of t.getDeclarations())if(o.isImportSpecifier(e))return f(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineShape":!1;return!1},x=r=>{const t=r.getSymbol();if(!t)return!1;for(const e of t.getDeclarations()){if(!o.isNamespaceImport(e))continue;const i=e.getFirstAncestorByKind(p.ImportDeclaration);return i!==void 0&&f(i.getModuleSpecifierValue())}return!1},y=r=>{if(o.isIdentifier(r))return b(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineShape"&&o.isIdentifier(t)&&x(t)}return!1},N=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return;const e=l(t,"table");if(!e||!o.isPropertyAssignment(e))return;const i=e.getInitializer();return i&&o.isStringLiteral(i)?i.getLiteralValue():void 0},E=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return{};const e=l(t,"args");if(!e||!o.isPropertyAssignment(e))return{};const i=e.getInitializer();return!i||!o.isObjectLiteralExpression(i)?{}:d(i)},I=r=>{const t=[];for(const e of r.getVariableDeclarations()){const i=e.getInitializer();if(i?.getKind()!==p.CallExpression)continue;const s=i,a=s.getExpression();if(!y(a))continue;const n=e.getNameNode();if(!o.isIdentifier(n)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw g(n,"defineShape exports must be plain named exports (no destructuring)")}const c=S(e,"binding");c!==void 0&&t.push({args:E(s),exportName:c,filePath:"shapes",table:N(s)})}return t},z=(r,t)=>{const e=u(t,h);if(!m(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),s=I(i);return s.sort((a,n)=>a.exportName.localeCompare(n.exportName)),s};export{h as SHAPES_FILENAME,z as discoverShapes};
@@ -1 +1 @@
1
- import{existsSync as b}from"node:fs";import{join as y}from"node:path";import{LunoraError as w}from"@lunora/errors";import{isValidCronExpression as k}from"@lunora/scheduler";import{workflowDefaultName as E,workflowClassName as v}from"@lunora/workflow";import{Node as n,VariableDeclarationKind as S,SyntaxKind as x}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as N,findObjectProperty as d,stringPropertyFor as L}from"./isTestPath-B81lOULB.mjs";import{a as P}from"./attribution-BUciBs1M.mjs";import{r as $}from"./handler-reference-DXkpwoAq.mjs";const A="workflows.ts",W=new Set(["do","sleep","sleepUntil","waitForEvent"]),C=o=>{const e=o.getSymbol();if(!e)return o.getText()==="defineWorkflow";for(const t of e.getDeclarations())if(n.isImportSpecifier(t))return t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/workflow"?!1:t.getNameNode().getText()==="defineWorkflow";return!1},m=L("workflow"),O=(o,e,t)=>{if(n.isNumericLiteral(o))return o.getLiteralValue();throw c(o,`workflow "${e}": \`${t}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},f=(o,e)=>{const t=d(o,e);return t&&n.isPropertyAssignment(t)?t.getInitializerOrThrow():void 0},g=(o,e,t)=>{if(n.isObjectLiteralExpression(o))return o;throw c(o,`workflow "${e}": \`${t}\` must be an inline object literal — it is deploy configuration codegen writes into wrangler.jsonc`)},D=(o,e)=>{if(!n.isArrayLiteralExpression(o)||o.getElements().length===0)throw c(o,`workflow "${e}": \`schedules\` must be a non-empty inline array of cron expression string literals`);return o.getElements().map(t=>{const r=m(t,e,"schedules[]");if(!k(r))throw c(t,`workflow "${e}": schedule "${r}" is not a valid cron expression`);return r})},I=(o,e)=>{const t={},r=f(o,"schedules");r!==void 0&&(t.schedules=D(r,e));const s=f(o,"limits");if(s!==void 0){const i=f(g(s,e,"limits"),"steps");if(i===void 0)t.limits={};else{const l=O(i,e,"limits.steps");if(!Number.isInteger(l)||l<=0)throw c(i,`workflow "${e}": \`limits.steps\` must be a positive integer (got ${String(l)})`);t.limits={steps:l}}}const a=f(o,"defaultRetention");if(a!==void 0){const i=g(a,e,"defaultRetention"),l={};for(const u of["errorRetention","successRetention"]){const p=f(i,u);p!==void 0&&(l[u]=m(p,e,`defaultRetention.${u}`))}t.defaultRetention=l}return t},F=o=>{const e=o.getExpression();if(!n.isPropertyAccessExpression(e)||!W.has(e.getName()))return!1;const t=e.getExpression();return n.isPropertyAccessExpression(t)&&t.getName()==="step"?!0:n.isIdentifier(t)&&t.getText()==="step"},T=o=>{if(!o)return[];const e=[];for(const t of o.getDescendantsOfKind(x.CallExpression)){if(!F(t))continue;const r=t.getArguments()[0];!r||!(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))||e.push({line:t.getStartLineNumber(),method:t.getExpression().getName(),name:r.getLiteralValue()})}return e},h=o=>{let e=o;for(;e&&(n.isAsExpression(e)||n.isSatisfiesExpression(e)||n.isParenthesizedExpression(e));)e=e.getExpression();return e},R=o=>{const e=h(o);if(e&&n.isObjectLiteralExpression(e))return e;if(!(!e||!n.isIdentifier(e)))for(const t of e.getSymbol()?.getDeclarations()??[]){const s=n.isVariableDeclaration(t)&&t.getVariableStatement()?.getDeclarationKind()===S.Const?h(t.getInitializer()):void 0;if(s&&n.isObjectLiteralExpression(s))return s}},j=(o,e)=>{const t=d(o,"handler"),r=$(t,e);return r!==void 0?r:{body:t!==void 0&&n.isPropertyAssignment(t)?t.getInitializer():t}},K=(o,e,t)=>{const r=R(o.getArguments()[0]);if(!r)throw c(o,`workflow "${e}": defineWorkflow's argument must be an object literal, or a local \`const\` holding one — codegen reads \`name\` and the \`ctx.step.*\` calls out of it statically. Keep the handler wherever you like and pass it through: \`const config = { handler: myHandler }; export const ${e} = defineWorkflow(config);\`.`);const s=j(r,t),a={className:v(e),exportName:e,name:E(e),steps:T(s.body),...s.file===void 0?{}:{handlerFile:s.file},...s.site===void 0?{}:{handlerSite:s.site}},i=d(r,"name");return i&&n.isPropertyAssignment(i)&&(a.name=m(i.getInitializerOrThrow(),e,"name")),{...a,...I(r,e)}},V=(o,e)=>{const t=[];for(const r of o.getVariableDeclarations()){const s=N(r.getInitializer());if(!s)continue;const a=s.getExpression();if(!n.isIdentifier(a)||!C(a))continue;const i=r.getNameNode();if(!n.isIdentifier(i)){if(r.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw c(i,"defineWorkflow exports must be plain named exports (no destructuring)")}const l=P(r,"binding");l!==void 0&&t.push(K(s,l,e))}return t},z=o=>{const e=new Map,t=new Map;for(const r of o){const s=e.get(r.name);if(s!==void 0)throw new w("DUPLICATE_WORKFLOW_NAME",`Duplicate workflow name "${r.name}": produced by both "${s}" and "${r.exportName}". Deployed workflow names must be unique across the project.`,{status:500});e.set(r.name,r.exportName);const a=t.get(r.className);if(a!==void 0)throw new w("DUPLICATE_WORKFLOW_CLASS",`Duplicate workflow class "${r.className}": produced by both "${a}" and "${r.exportName}". Workflow export names must yield unique generated class names.`,{status:500});t.set(r.className,r.exportName)}},Y=(o,e)=>{const t=y(e,A);if(!b(t))return[];const r=o.getSourceFile(t)??o.addSourceFileAtPath(t),s=V(r,e);return s.sort((a,i)=>a.exportName.localeCompare(i.exportName)),z(s),s};export{A as WORKFLOWS_FILENAME,Y as discoverWorkflows};
1
+ import{existsSync as b}from"node:fs";import{join as y}from"node:path";import{LunoraError as w}from"@lunora/errors";import{isValidCronExpression as k}from"@lunora/scheduler";import{workflowDefaultName as E,workflowClassName as v}from"@lunora/workflow";import{Node as n,VariableDeclarationKind as S,SyntaxKind as x}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as N,findObjectProperty as d,stringPropertyFor as L}from"./isTestPath-B81lOULB.mjs";import{a as P}from"./attribution-hVBriwzy.mjs";import{r as $}from"./handler-reference-vIeqkhV_.mjs";const A="workflows.ts",W=new Set(["do","sleep","sleepUntil","waitForEvent"]),C=o=>{const e=o.getSymbol();if(!e)return o.getText()==="defineWorkflow";for(const t of e.getDeclarations())if(n.isImportSpecifier(t))return t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/workflow"?!1:t.getNameNode().getText()==="defineWorkflow";return!1},m=L("workflow"),O=(o,e,t)=>{if(n.isNumericLiteral(o))return o.getLiteralValue();throw c(o,`workflow "${e}": \`${t}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},f=(o,e)=>{const t=d(o,e);return t&&n.isPropertyAssignment(t)?t.getInitializerOrThrow():void 0},g=(o,e,t)=>{if(n.isObjectLiteralExpression(o))return o;throw c(o,`workflow "${e}": \`${t}\` must be an inline object literal — it is deploy configuration codegen writes into wrangler.jsonc`)},D=(o,e)=>{if(!n.isArrayLiteralExpression(o)||o.getElements().length===0)throw c(o,`workflow "${e}": \`schedules\` must be a non-empty inline array of cron expression string literals`);return o.getElements().map(t=>{const r=m(t,e,"schedules[]");if(!k(r))throw c(t,`workflow "${e}": schedule "${r}" is not a valid cron expression`);return r})},I=(o,e)=>{const t={},r=f(o,"schedules");r!==void 0&&(t.schedules=D(r,e));const s=f(o,"limits");if(s!==void 0){const i=f(g(s,e,"limits"),"steps");if(i===void 0)t.limits={};else{const l=O(i,e,"limits.steps");if(!Number.isInteger(l)||l<=0)throw c(i,`workflow "${e}": \`limits.steps\` must be a positive integer (got ${String(l)})`);t.limits={steps:l}}}const a=f(o,"defaultRetention");if(a!==void 0){const i=g(a,e,"defaultRetention"),l={};for(const u of["errorRetention","successRetention"]){const p=f(i,u);p!==void 0&&(l[u]=m(p,e,`defaultRetention.${u}`))}t.defaultRetention=l}return t},F=o=>{const e=o.getExpression();if(!n.isPropertyAccessExpression(e)||!W.has(e.getName()))return!1;const t=e.getExpression();return n.isPropertyAccessExpression(t)&&t.getName()==="step"?!0:n.isIdentifier(t)&&t.getText()==="step"},T=o=>{if(!o)return[];const e=[];for(const t of o.getDescendantsOfKind(x.CallExpression)){if(!F(t))continue;const r=t.getArguments()[0];!r||!(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))||e.push({line:t.getStartLineNumber(),method:t.getExpression().getName(),name:r.getLiteralValue()})}return e},h=o=>{let e=o;for(;e&&(n.isAsExpression(e)||n.isSatisfiesExpression(e)||n.isParenthesizedExpression(e));)e=e.getExpression();return e},R=o=>{const e=h(o);if(e&&n.isObjectLiteralExpression(e))return e;if(!(!e||!n.isIdentifier(e)))for(const t of e.getSymbol()?.getDeclarations()??[]){const s=n.isVariableDeclaration(t)&&t.getVariableStatement()?.getDeclarationKind()===S.Const?h(t.getInitializer()):void 0;if(s&&n.isObjectLiteralExpression(s))return s}},j=(o,e)=>{const t=d(o,"handler"),r=$(t,e);return r!==void 0?r:{body:t!==void 0&&n.isPropertyAssignment(t)?t.getInitializer():t}},K=(o,e,t)=>{const r=R(o.getArguments()[0]);if(!r)throw c(o,`workflow "${e}": defineWorkflow's argument must be an object literal, or a local \`const\` holding one — codegen reads \`name\` and the \`ctx.step.*\` calls out of it statically. Keep the handler wherever you like and pass it through: \`const config = { handler: myHandler }; export const ${e} = defineWorkflow(config);\`.`);const s=j(r,t),a={className:v(e),exportName:e,name:E(e),steps:T(s.body),...s.file===void 0?{}:{handlerFile:s.file},...s.site===void 0?{}:{handlerSite:s.site}},i=d(r,"name");return i&&n.isPropertyAssignment(i)&&(a.name=m(i.getInitializerOrThrow(),e,"name")),{...a,...I(r,e)}},V=(o,e)=>{const t=[];for(const r of o.getVariableDeclarations()){const s=N(r.getInitializer());if(!s)continue;const a=s.getExpression();if(!n.isIdentifier(a)||!C(a))continue;const i=r.getNameNode();if(!n.isIdentifier(i)){if(r.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw c(i,"defineWorkflow exports must be plain named exports (no destructuring)")}const l=P(r,"binding");l!==void 0&&t.push(K(s,l,e))}return t},z=o=>{const e=new Map,t=new Map;for(const r of o){const s=e.get(r.name);if(s!==void 0)throw new w("DUPLICATE_WORKFLOW_NAME",`Duplicate workflow name "${r.name}": produced by both "${s}" and "${r.exportName}". Deployed workflow names must be unique across the project.`,{status:500});e.set(r.name,r.exportName);const a=t.get(r.className);if(a!==void 0)throw new w("DUPLICATE_WORKFLOW_CLASS",`Duplicate workflow class "${r.className}": produced by both "${a}" and "${r.exportName}". Workflow export names must yield unique generated class names.`,{status:500});t.set(r.className,r.exportName)}},Y=(o,e)=>{const t=y(e,A);if(!b(t))return[];const r=o.getSourceFile(t)??o.addSourceFileAtPath(t),s=V(r,e);return s.sort((a,i)=>a.exportName.localeCompare(i.exportName)),z(s),s};export{A as WORKFLOWS_FILENAME,Y as discoverWorkflows};
@@ -1 +1 @@
1
- import{callSiteCallers as y,byCodepoint as k}from"@lunora/advisor";import{Node as r,SyntaxKind as p,VariableDeclarationKind as F,ts as O}from"ts-morph";import{i as M}from"./reserved-words-CW1QFbTd.mjs";import{unwrapExpression as A,isWriteTarget as T}from"./isTestPath-B81lOULB.mjs";const N=new WeakMap,V=e=>e.getStatements().flatMap(t=>r.isFunctionDeclaration(t)?[t]:r.isVariableStatement(t)?t.getDeclarations().filter(o=>r.isIdentifier(o.getNameNode())):[]),x=e=>r.isStringLiteral(e)?e.getLiteralValue():e.getText(),C=e=>{if(r.isFunctionDeclaration(e)||r.isClassDeclaration(e)){const t=e.getName();return e.hasExportKeyword()?[[t??"default",e.hasDefaultKeyword()?"default":t??"default"]]:[]}return!r.isVariableStatement(e)||!e.hasExportKeyword()?[]:e.getDeclarations().flatMap(t=>{const o=t.getNameNode();return r.isIdentifier(o)?[[o.getText(),o.getText()]]:o.getDescendantsOfKind(p.BindingElement).flatMap(n=>r.isIdentifier(n.getNameNode())?[[n.getName(),n.getName()]]:[])})},I=e=>{if(r.isExportDeclaration(e))return e.hasModuleSpecifier()||e.isTypeOnly()?[]:e.getNamedExports().filter(o=>!o.isTypeOnly()).map(o=>{const n=x(o.getNameNode()),s=o.getAliasNode();return[n,s===void 0?n:x(s)]});const t=r.isExportAssignment(e)&&!e.isExportEquals()?e.getExpression():void 0;return r.isIdentifier(t)?[[t.getText(),"default"]]:C(e)},h=new WeakMap,P=e=>{const t=h.get(e.compilerNode);if(t!==void 0)return t;const o=new Map;for(const[s,c]of e.getStatements().flatMap(i=>I(i)))o.set(s,(o.get(s)??new Set).add(c));const n=new Map([...o].map(([s,c])=>[s,[...c].toSorted(G)]));return h.set(e.compilerNode,n),n},g=e=>{const t=r.isBindingElement(e)?e.getFirstAncestorByKind(p.VariableStatement):void 0,o=r.isVariableDeclaration(e)?e.getVariableStatement():void 0,n=r.isFunctionDeclaration(e)?e:t??o;if(n===void 0||!r.isSourceFile(n.getParent()))return[];const s=r.isFunctionDeclaration(e)?e.getName()??"default":e.getName();return P(e.getSourceFile()).get(s)??[]},K=e=>new Map(e.flatMap(t=>{const o=g(t);return o.length===0?[]:[[t.compilerNode,o]]})),L=e=>{const t=A(e);return t!==void 0&&(r.isArrowFunction(t)||r.isFunctionExpression(t))},b=(e,t)=>{for(const o of e.getAncestors()){if(r.isExportAssignment(o)&&!o.isExportEquals())return{kind:"export",name:"default"};if((r.isFunctionDeclaration(o)&&r.isSourceFile(o.getParent())||r.isVariableDeclaration(o)&&r.isSourceFile(o.getVariableStatement()?.getParent())&&r.isIdentifier(o.getNameNode()))&&(r.isFunctionDeclaration(o)||r.isVariableDeclaration(o))){const s=t.get(o.compilerNode)?.[0];return s!==void 0?{kind:"export",name:s}:r.isFunctionDeclaration(o)||L(o.getInitializer())?{declaration:o,kind:"helper"}:{kind:"untracked"}}}return{kind:"untracked"}},E=e=>{for(const t of e.getAncestors()){if(r.isExpressionWithTypeArguments(t)){const o=t.getParent();return!(r.isHeritageClause(o)&&o.getToken()===p.ExtendsKeyword&&(r.isClassDeclaration(o.getParent())||r.isClassExpression(o.getParent())))}if(O.isTypeNode(t.compilerNode))return!0}return!1},U=e=>{const t=e.getParent(),o=r.isPropertyAccessExpression(t)&&t.getNameNode()===e,n=(r.isPropertyAssignment(t)||r.isMethodDeclaration(t))&&t.getNameNode()===e;return!o&&!n&&!E(e)},v=e=>{const t=e.getParent();return r.isShorthandPropertyAssignment(t)&&t.getNameNode()===e?t.getValueSymbol():e.getSymbol()},B=e=>{const t=v(e);return t?.getValueDeclaration()??t?.getDeclarations()[0]},S=new WeakMap,R=/\/typescript\/lib\/lib\.[^/]+\.d\.ts$/u,$=e=>{const t=e.getFilePath();return e.isDeclarationFile()&&(R.test(t)||t.includes("/@types/node/"))},ee=e=>{const t=e.getNameNode(),o=r.isFunctionDeclaration(e)?void 0:e.getFirstAncestorByKind(p.VariableDeclarationList);if(!r.isIdentifier(t)||o?.getDeclarationKind()===F.Const||$(e.getSourceFile()))return!1;let n=S.get(e.compilerNode);if(n===void 0){const s=r.isFunctionDeclaration(e)?e.getSourceFile():e.getFirstAncestor(i=>r.isFunctionLikeDeclaration(i)||r.isArrowFunction(i))??e.getSourceFile(),c=t.getText();n=s.getDescendantsOfKind(p.Identifier).some(i=>i!==t&&i.getText()===c&&T(i)&&B(i)?.compilerNode===e.compilerNode),S.set(e.compilerNode,n)}return n},_=e=>{const t=new Map,o=new Set,n=new Set;for(const s of e){const c=s.getNameNode(),i=c?.getSymbol()?.compilerSymbol;c!==void 0&&i!==void 0&&(t.set(i,s.compilerNode),o.add(c.compilerNode),n.add(c.getText()))}return{bySymbol:t,nameNodes:o,spellings:n}},W=(e,t,o)=>{const{bySymbol:n,nameNodes:s,spellings:c}=_(t),i=new Map;for(const a of e.getDescendantsOfKind(p.Identifier)){if(!c.has(a.getText())||s.has(a.compilerNode)||E(a))continue;const l=v(a)?.compilerSymbol,d=l===void 0?void 0:n.get(l);d!==void 0&&i.set(d,[...i.get(d)??[],b(a,o)])}return i},z=(e,t)=>{const o=new Map(e.map(a=>[a.compilerNode,new Set])),n=new Set,s=a=>(o.get(a)?.size??0)+(n.has(a)?1:0),c=(a,l)=>{const d=s(a),u=o.get(a),m=l.kind==="helper"?l.declaration.compilerNode:void 0;l.kind==="export"&&u?.add(l.name);for(const w of m===void 0?[]:o.get(m)??[])u?.add(w);return(l.kind==="untracked"||m!==void 0&&n.has(m))&&n.add(a),s(a)!==d};let i=!0;for(;i;){i=!1;for(const[a,l]of t)for(const d of l)i=c(a,d)||i}return new Map([...o].map(([a,l])=>[a,{callers:[...l].toSorted((d,u)=>d.localeCompare(u)),untracked:n.has(a)}]))},H=e=>{const t=N.get(e.compilerNode);if(t!==void 0)return t;const o=V(e),n=K(o),s=o.filter(i=>!n.has(i.compilerNode)),c={exportNames:n,helperReach:s.length===0?new Map:z(s,W(e,s,n))};return N.set(e.compilerNode,c),c},te=e=>{const t=H(e.getSourceFile()),o=b(e,t.exportNames);switch(o.kind){case"export":return{kind:"export",name:o.name};case"helper":{const n=o.declaration.getName(),s=t.helperReach.get(o.declaration.compilerNode);if(n===void 0||s===void 0)throw new Error(`call-site attribution: helper at ${o.declaration.getSourceFile().getFilePath()} is not indexed`);return{callers:s.callers,kind:"helper",name:n,...s.untracked?{untracked:!0}:{}}}default:return{kind:"module"}}},q=e=>{if(e.kind==="helper"&&e.untracked===!0)return;const t=y(e);return t.length===0?void 0:t},X=(e,t)=>{const o=new Set(y(e).map(n=>t(n)));return o.has("public")?"public":q(e)===void 0||o.has(void 0)?void 0:"internal"},oe=(e,t)=>{const o=new Map(t.map(n=>[`${n.filePath}:${n.exportName}`,n.visibility]));return e.map(n=>{const s=X(n.scope,c=>o.get(`${n.file}:${c}`));return s===void 0?n:{...n,visibility:s}})},f=/^[$A-Z_a-z][\w$]*$/u,D=e=>f.test(e),j=e=>{const t=g(e);return t.length===0?r.isVariableDeclaration(e)&&e.getVariableStatement()?.hasExportKeyword()===!0?e.getName():void 0:t.find(o=>D(o))??e.getName()},ne=e=>e.getVariableStatements().flatMap(t=>t.getDeclarations()).filter(t=>j(t)!==void 0),re=(e,t)=>{if(r.isIdentifier(e.getNameNode()))return e.getVariableStatement()?.hasExportKeyword()===!0?e.getName():g(e).find(o=>t==="binding"?M(o):D(o))},G=(e,t)=>Number(f.test(t))-Number(f.test(e))||k(e,t);export{re as a,ne as b,te as c,j as d,P as e,B as f,ee as g,U as h,D as i,g as j,E as k,$ as l,q as m,v as r,oe as w};
1
+ import{callSiteCallers as y,byCodepoint as k}from"@lunora/advisor";import{Node as r,SyntaxKind as p,VariableDeclarationKind as F,ts as O}from"ts-morph";import{i as M}from"./reserved-words-CW1QFbTd.mjs";import{isWriteTarget as A,unwrapExpression as T}from"./isTestPath-B81lOULB.mjs";const N=new WeakMap,V=e=>e.getStatements().flatMap(t=>r.isFunctionDeclaration(t)?[t]:r.isVariableStatement(t)?t.getDeclarations().filter(o=>r.isIdentifier(o.getNameNode())):[]),x=e=>r.isStringLiteral(e)?e.getLiteralValue():e.getText(),C=e=>{if(r.isFunctionDeclaration(e)||r.isClassDeclaration(e)){const t=e.getName();return e.hasExportKeyword()?[[t??"default",e.hasDefaultKeyword()?"default":t??"default"]]:[]}return!r.isVariableStatement(e)||!e.hasExportKeyword()?[]:e.getDeclarations().flatMap(t=>{const o=t.getNameNode();return r.isIdentifier(o)?[[o.getText(),o.getText()]]:o.getDescendantsOfKind(p.BindingElement).flatMap(n=>r.isIdentifier(n.getNameNode())?[[n.getName(),n.getName()]]:[])})},I=e=>{if(r.isExportDeclaration(e))return e.hasModuleSpecifier()||e.isTypeOnly()?[]:e.getNamedExports().filter(o=>!o.isTypeOnly()).map(o=>{const n=x(o.getNameNode()),s=o.getAliasNode();return[n,s===void 0?n:x(s)]});const t=r.isExportAssignment(e)&&!e.isExportEquals()?e.getExpression():void 0;return r.isIdentifier(t)?[[t.getText(),"default"]]:C(e)},h=new WeakMap,P=e=>{const t=h.get(e.compilerNode);if(t!==void 0)return t;const o=new Map;for(const[s,c]of e.getStatements().flatMap(i=>I(i)))o.set(s,(o.get(s)??new Set).add(c));const n=new Map([...o].map(([s,c])=>[s,[...c].toSorted(G)]));return h.set(e.compilerNode,n),n},g=e=>{const t=r.isBindingElement(e)?e.getFirstAncestorByKind(p.VariableStatement):void 0,o=r.isVariableDeclaration(e)?e.getVariableStatement():void 0,n=r.isFunctionDeclaration(e)?e:t??o;if(n===void 0||!r.isSourceFile(n.getParent()))return[];const s=r.isFunctionDeclaration(e)?e.getName()??"default":e.getName();return P(e.getSourceFile()).get(s)??[]},K=e=>new Map(e.flatMap(t=>{const o=g(t);return o.length===0?[]:[[t.compilerNode,o]]})),L=e=>{const t=T(e);return t!==void 0&&(r.isArrowFunction(t)||r.isFunctionExpression(t))},b=(e,t)=>{for(const o of e.getAncestors()){if(r.isExportAssignment(o)&&!o.isExportEquals())return{kind:"export",name:"default"};if((r.isFunctionDeclaration(o)&&r.isSourceFile(o.getParent())||r.isVariableDeclaration(o)&&r.isSourceFile(o.getVariableStatement()?.getParent())&&r.isIdentifier(o.getNameNode()))&&(r.isFunctionDeclaration(o)||r.isVariableDeclaration(o))){const s=t.get(o.compilerNode)?.[0];return s!==void 0?{kind:"export",name:s}:r.isFunctionDeclaration(o)||L(o.getInitializer())?{declaration:o,kind:"helper"}:{kind:"untracked"}}}return{kind:"untracked"}},E=e=>{for(const t of e.getAncestors()){if(r.isExpressionWithTypeArguments(t)){const o=t.getParent();return!(r.isHeritageClause(o)&&o.getToken()===p.ExtendsKeyword&&(r.isClassDeclaration(o.getParent())||r.isClassExpression(o.getParent())))}if(O.isTypeNode(t.compilerNode))return!0}return!1},U=e=>{const t=e.getParent(),o=r.isPropertyAccessExpression(t)&&t.getNameNode()===e,n=(r.isPropertyAssignment(t)||r.isMethodDeclaration(t))&&t.getNameNode()===e;return!o&&!n&&!E(e)},v=e=>{const t=e.getParent();return r.isShorthandPropertyAssignment(t)&&t.getNameNode()===e?t.getValueSymbol():e.getSymbol()},B=e=>{const t=v(e);return t?.getValueDeclaration()??t?.getDeclarations()[0]},S=new WeakMap,R=/\/typescript\/lib\/lib\.[^/]+\.d\.ts$/u,$=e=>{const t=e.getFilePath();return e.isDeclarationFile()&&(R.test(t)||t.includes("/@types/node/"))},ee=e=>{const t=e.getNameNode(),o=r.isFunctionDeclaration(e)?void 0:e.getFirstAncestorByKind(p.VariableDeclarationList);if(!r.isIdentifier(t)||o?.getDeclarationKind()===F.Const||$(e.getSourceFile()))return!1;let n=S.get(e.compilerNode);if(n===void 0){const s=r.isFunctionDeclaration(e)?e.getSourceFile():e.getFirstAncestor(i=>r.isFunctionLikeDeclaration(i)||r.isArrowFunction(i))??e.getSourceFile(),c=t.getText();n=s.getDescendantsOfKind(p.Identifier).some(i=>i!==t&&i.getText()===c&&A(i)&&B(i)?.compilerNode===e.compilerNode),S.set(e.compilerNode,n)}return n},_=e=>{const t=new Map,o=new Set,n=new Set;for(const s of e){const c=s.getNameNode(),i=c?.getSymbol()?.compilerSymbol;c!==void 0&&i!==void 0&&(t.set(i,s.compilerNode),o.add(c.compilerNode),n.add(c.getText()))}return{bySymbol:t,nameNodes:o,spellings:n}},W=(e,t,o)=>{const{bySymbol:n,nameNodes:s,spellings:c}=_(t),i=new Map;for(const a of e.getDescendantsOfKind(p.Identifier)){if(!c.has(a.getText())||s.has(a.compilerNode)||E(a))continue;const l=v(a)?.compilerSymbol,d=l===void 0?void 0:n.get(l);d!==void 0&&i.set(d,[...i.get(d)??[],b(a,o)])}return i},z=(e,t)=>{const o=new Map(e.map(a=>[a.compilerNode,new Set])),n=new Set,s=a=>(o.get(a)?.size??0)+(n.has(a)?1:0),c=(a,l)=>{const d=s(a),u=o.get(a),m=l.kind==="helper"?l.declaration.compilerNode:void 0;l.kind==="export"&&u?.add(l.name);for(const w of m===void 0?[]:o.get(m)??[])u?.add(w);return(l.kind==="untracked"||m!==void 0&&n.has(m))&&n.add(a),s(a)!==d};let i=!0;for(;i;){i=!1;for(const[a,l]of t)for(const d of l)i=c(a,d)||i}return new Map([...o].map(([a,l])=>[a,{callers:[...l].toSorted((d,u)=>d.localeCompare(u)),untracked:n.has(a)}]))},H=e=>{const t=N.get(e.compilerNode);if(t!==void 0)return t;const o=V(e),n=K(o),s=o.filter(i=>!n.has(i.compilerNode)),c={exportNames:n,helperReach:s.length===0?new Map:z(s,W(e,s,n))};return N.set(e.compilerNode,c),c},te=e=>{const t=H(e.getSourceFile()),o=b(e,t.exportNames);switch(o.kind){case"export":return{kind:"export",name:o.name};case"helper":{const n=o.declaration.getName(),s=t.helperReach.get(o.declaration.compilerNode);if(n===void 0||s===void 0)throw new Error(`call-site attribution: helper at ${o.declaration.getSourceFile().getFilePath()} is not indexed`);return{callers:s.callers,kind:"helper",name:n,...s.untracked?{untracked:!0}:{}}}default:return{kind:"module"}}},q=e=>{if(e.kind==="helper"&&e.untracked===!0)return;const t=y(e);return t.length===0?void 0:t},X=(e,t)=>{const o=new Set(y(e).map(n=>t(n)));return o.has("public")?"public":q(e)===void 0||o.has(void 0)?void 0:"internal"},oe=(e,t)=>{const o=new Map(t.map(n=>[`${n.filePath}:${n.exportName}`,n.visibility]));return e.map(n=>{const s=X(n.scope,c=>o.get(`${n.file}:${c}`));return s===void 0?n:{...n,visibility:s}})},f=/^[$A-Z_a-z][\w$]*$/u,D=e=>f.test(e),j=e=>{const t=g(e);return t.length===0?r.isVariableDeclaration(e)&&e.getVariableStatement()?.hasExportKeyword()===!0?e.getName():void 0:t.find(o=>D(o))??e.getName()},ne=e=>e.getVariableStatements().flatMap(t=>t.getDeclarations()).filter(t=>j(t)!==void 0),re=(e,t)=>{if(r.isIdentifier(e.getNameNode()))return e.getVariableStatement()?.hasExportKeyword()===!0?e.getName():g(e).find(o=>t==="binding"?M(o):D(o))},G=(e,t)=>Number(f.test(t))-Number(f.test(e))||k(e,t);export{re as a,ne as b,te as c,j as d,P as e,B as f,ee as g,U as h,D as i,g as j,E as k,$ as l,q as m,v as r,oe as w};
@@ -0,0 +1 @@
1
+ import{w as a}from"./classify-procedure-call-BAj0D1u2.mjs";const l=s=>a(s,"use","rls");export{l as r};
@@ -0,0 +1 @@
1
+ import{Node as o}from"ts-morph";import{unwrapExpression as a}from"./isTestPath-B81lOULB.mjs";import{a as d}from"./module-specifiers-WF8iAydP.mjs";const V=e=>o.isIdentifier(e)?e.getText():o.isPropertyAccessExpression(e)?e.getName():void 0,S=(e,t,i=d)=>{const r=new Set;for(const n of e.getImportDeclarations())if(i(n.getModuleSpecifierValue()))for(const s of n.getNamedImports())s.getNameNode().getText()===t&&r.add(s.getAliasNode()?.getText()??s.getName());return r},x=(e,t)=>{if(o.isPropertyAccessExpression(e))return e.getName()===t;if(!o.isIdentifier(e))return!1;const i=e.getText();return i===t||S(e.getSourceFile(),t).has(i)},f=e=>{for(const t of e.getSymbol()?.getDeclarations()??[])if(o.isImportSpecifier(t)&&d(t.getImportDeclaration().getModuleSpecifierValue()))return t.getNameNode().getText()},p=e=>e.getSymbol()?f(e):e.getText(),C=(e,t)=>o.isIdentifier(e)&&f(e)===t,m=e=>{const t=[];let i=a(e);for(;i&&o.isCallExpression(i);){const r=a(i.getExpression());if(!r||!o.isPropertyAccessExpression(r))return{root:void 0,steps:t};t.push({call:i,name:r.getName()}),i=a(r.getExpression())}return{root:i,steps:t}},g=e=>m(e).steps,y=(e,t,i)=>g(e).filter(r=>r.name===t).map(r=>r.call.getArguments()[0]).filter(r=>r!==void 0&&o.isCallExpression(r)&&i(r.getExpression())),E=(e,t,i)=>y(e,t,r=>x(r,i)),_=(e,t)=>g(e).some(i=>i.name===t),K=(e,t,i)=>E(e,t,i).length>0,l=new Set(["action","mutation","query","stream"]),v={internalAction:"action",internalMutation:"mutation",internalQuery:"query"},A={onConnect:"connect",onDisconnect:"disconnect",onQueryChange:"reactor",onShardInit:"init",onWhisper:"whisper"},T=e=>e==="whisper"?"query":"mutation",I=e=>{const{root:t}=m(e);return t&&o.isIdentifier(t)?t:void 0},h=(e,t=!1)=>{const i=I(e);if(!i)return;const r=p(i);if(r===void 0){if(t)return;const n=i.getSymbol()?.getValueDeclaration();if(n&&o.isVariableDeclaration(n)){const s=n.getInitializer();return s?h(s,!0):void 0}return}return l.has(r)?"public":v[r]?"internal":void 0},b=(e,t=!1)=>{if(y(e,"use",s=>C(s,"platformAdmin")).length>0)return!0;if(t)return!1;const i=I(e)?.getSymbol(),r=(i?.isAlias()?i.getAliasedSymbol():i)?.getValueDeclaration(),n=r&&o.isVariableDeclaration(r)?r.getInitializer():void 0;return n!==void 0&&b(n,!0)},u=e=>b(e)?{adminOnly:!0}:{},w=e=>{const t=e.getName();if(!l.has(t))return;const i=e.getExpression(),r=a(i)??i,n=i===r?[r]:[i,r];if(n.some(c=>c.getType().getProperty("__lunoraProcedure"))){const c=n.some(N=>N.getType().getProperty("__lunoraVisibility"));return{kind:t,receiver:r,visibility:c?"internal":"public",...u(r)}}const s=h(r);if(s)return{kind:t,receiver:r,visibility:s,...u(r)}},O=e=>{const t=e.getExpression();if(o.isPropertyAccessExpression(t))return w(t);if(!o.isIdentifier(t))return;const i=p(t);if(!i)return;if(l.has(i))return{kind:i,visibility:"public"};const r=v[i];if(r)return{kind:r,visibility:"internal"};const n=A[i];if(n)return{kind:T(n),lifecycle:n,visibility:"internal"}};export{V as a,g as b,O as c,K as d,C as e,_ as f,S as i,E as w};
@@ -1 +1 @@
1
- import{Node as i}from"ts-morph";import{listLunoraSourceFiles as a,lunoraRelativePath as c,handlerOf as l}from"./isTestPath-B81lOULB.mjs";import{b as d,d as f}from"./attribution-BUciBs1M.mjs";import{c as u}from"./context-root-Dlo21ybw.mjs";import{c as m}from"./classify-procedure-call-BJdf_-M6.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-B81lOULB.mjs";import{b as d,d as f}from"./attribution-hVBriwzy.mjs";import{c as u}from"./context-root-wBahDTzk.mjs";import{c as m}from"./classify-procedure-call-BAj0D1u2.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-B81lOULB.mjs";import{f as v,g as I,h as M}from"./attribution-BUciBs1M.mjs";import{c as F}from"./classify-procedure-call-BJdf_-M6.mjs";import{isDefineMutatorCallee as b}from"./MUTATORS_FILENAME-Dl1tElqi.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-B81lOULB.mjs";import{f as v,g as I,h as M}from"./attribution-hVBriwzy.mjs";import{c as F}from"./classify-procedure-call-BAj0D1u2.mjs";import{isDefineMutatorCallee as b}from"./MUTATORS_FILENAME-Bw0YtaO8.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};
@@ -0,0 +1 @@
1
+ import{existsSync as c}from"node:fs";import{dirname as r,join as F}from"node:path";import{Project as m}from"ts-morph";import{listLunoraSourceFiles as u}from"./isTestPath-B81lOULB.mjs";const a=e=>e.replaceAll("\\","/"),d=e=>{let o=c(e)?e:r(e);for(;o&&o!==r(o);){const i=F(o,"tsconfig.json");if(c(i))return i;o=r(o)}},p=e=>{const o=d(e);return o?new m({skipAddingFilesFromTsConfig:!1,tsConfigFilePath:o,useInMemoryFileSystem:!1}):new m({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1})},x=(e,o)=>{const i=u(o),l=F(o,"schema.ts");c(l)&&i.push(l);for(const s of i){const t=e.getSourceFile(s);t===void 0?e.addSourceFileAtPath(s):t.refreshFromFileSystemSync()}const h=new Set(i.map(s=>a(s))),n=a(o),f=`${n}/`;for(const s of e.getSourceFiles()){const t=s.getFilePath();(t===n||t.startsWith(f))&&!h.has(t)&&e.removeSourceFile(s)}for(const s of e.getSourceFiles()){const t=s.getFilePath();if(!(t===n||t.startsWith(f)||t.includes("/node_modules/")))try{s.refreshFromFileSystemSync()}catch{e.removeSourceFile(s)}}};export{p as createCodegenProject,d as findTsconfig,x as refreshCodegenProject};
@@ -1 +1 @@
1
- import{SyntaxKind as g,Node as n}from"ts-morph";import{d as p}from"./context-root-Dlo21ybw.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-wBahDTzk.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 +1 @@
1
- import{Node as t}from"ts-morph";import{collectCallRows as n}from"./isTestPath-B81lOULB.mjs";import{c as p}from"./attribution-BUciBs1M.mjs";import{a}from"./project-config-file-BV7RR-l6.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};
1
+ import{Node as t}from"ts-morph";import{collectCallRows as n}from"./isTestPath-B81lOULB.mjs";import{c as p}from"./attribution-hVBriwzy.mjs";import{a}from"./project-config-file-BV7RR-l6.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};
@@ -1 +1 @@
1
- import{d as P}from"./declared-output-Iaar469J.mjs";import{findObjectProperty as c,bindingKeyName as b,listLunoraSourceFiles as N,lunoraRelativePath as A}from"./isTestPath-B81lOULB.mjs";import{e as O,i as F}from"./attribution-BUciBs1M.mjs";import{u as y,p as z,c as g,r as C}from"./unwrap-handler-return-B-jQde6M.mjs";import{b as d,c as S}from"./classify-procedure-call-BJdf_-M6.mjs";import{Node as n,SyntaxKind as L}from"ts-morph";import{r as h,p as x,a as k}from"./parse-validator-IDBKIT7M.mjs";import{s as I}from"./dispatch-namespace-DwTjD7BU.mjs";const T=i=>{const e=i.getArguments()[0];if(!e||!n.isObjectLiteralExpression(e))return"unknown";const t=c(e,"handler");if(!t||!n.isPropertyAssignment(t))return"unknown";const r=t.getInitializer();return!r||!(n.isArrowFunction(r)||n.isFunctionExpression(r))?"unknown":y(r)},w=i=>{const e=i.getArguments()[0];return!e||!(n.isArrowFunction(e)||n.isFunctionExpression(e))?"unknown":y(e)},V=i=>{let e={};for(const t of d(i)){if(t.name!=="input")continue;const r=t.call.getArguments()[0],s=r!==void 0&&n.isExpression(r)?h(r):void 0;s!==void 0&&(e={...x(s),...e})}return e},D=i=>{const e=d(i).find(r=>r.name==="output");if(!e)return;const t=e.call.getArguments()[0];return t&&n.isExpression(t)?z(e.call,()=>k(t)):void 0},p=(i,e)=>{const t=c(i,e);if(t===void 0||!n.isPropertyAssignment(t))return;const r=t.getInitializer();return r!==void 0&&n.isStringLiteral(r)?r.getLiteralValue():void 0},v=(i,e)=>{const t=c(i,e);if(t===void 0||!n.isPropertyAssignment(t))return;const r=t.getInitializer();return r!==void 0&&n.isNumericLiteral(r)?r.getLiteralValue():void 0},j=i=>{const e=c(i,"cache");if(e===void 0||!n.isPropertyAssignment(e))return;const t=e.getInitializer();if(t===void 0||!n.isObjectLiteralExpression(t))return;const r=p(t,"scope"),s=v(t,"maxAge"),o=v(t,"staleWhileRevalidate"),a=p(t,"tag"),l=p(t,"vary"),m={...s===void 0?{}:{maxAge:s},...r==="private"||r==="public"?{scope:r}:{},...o===void 0?{}:{staleWhileRevalidate:o},...a===void 0?{}:{tag:a},...l===void 0?{}:{vary:l}};return Object.keys(m).length===0?void 0:m},B=i=>{if(i===void 0||!n.isObjectLiteralExpression(i))return{};const e=j(i),t=c(i,"rest");return t!==void 0&&n.isPropertyAssignment(t)?{...e===void 0?{}:{cache:e},rest:t.getInitializer()?.getText()==="true"}:e===void 0?{}:{cache:e}},R=i=>{const e=d(i).find(t=>t.name==="expose");return e?B(e.call.getArguments()[0]):void 0},M=i=>{const e=i.getArguments()[0];if(!e||!n.isObjectLiteralExpression(e))return{};const t=c(e,"args");if(!t||!n.isPropertyAssignment(t))return{};const r=t.getInitializer(),s=r===void 0?void 0:h(r);return s===void 0?{}:x(s)},$=8,u=(i,e=0)=>{if(e>$)return;if(n.isCallExpression(i))return i;if(n.isParenthesizedExpression(i)||n.isAsExpression(i)||n.isSatisfiesExpression(i)||n.isNonNullExpression(i))return u(i.getExpression(),e+1);if(!n.isIdentifier(i)&&!n.isPropertyAccessExpression(i))return;const t=i.getSymbol()?.getValueDeclaration();return t?f(t,e+1):void 0},f=(i,e)=>{if(n.isVariableDeclaration(i)||n.isPropertyAssignment(i)){const t=i.getInitializer();return t?u(t,e):void 0}if(n.isShorthandPropertyAssignment(i)){const t=i.getValueSymbol()?.getValueDeclaration();return t?f(t,e+1):void 0}if(n.isBindingElement(i)){const t=b(i),o=i.getFirstAncestorByKind(L.VariableDeclaration)?.getInitializer()?.getType().getProperty(t)?.getValueDeclaration();return o?f(o,e+1):void 0}},W=(i,e=()=>!0)=>{const t=i.getNameNode();if(n.isObjectBindingPattern(t)){const o=[];for(const a of t.getElements().filter(l=>e(l.getName()))){const l=u(a.getNameNode());l&&o.push([a.getName(),l])}return o}if(!e(i.getName()))return[];const r=i.getInitializer(),s=r&&(n.isCallExpression(r)?r:u(r));return s?[[i.getName(),s]]:[]},_=i=>{const e=S(i);if(!e)return;const{receiver:t}=e;if(t){const r=R(t),s=g(()=>D(t)),o=g(()=>w(i)),a=P({kind:e.kind,output:s.value});return C(a?s.erased:o.erased),{args:V(t),...r?{expose:r}:{},...e.adminOnly?{adminOnly:!0}:{},kind:e.kind,...s.value?{output:s.value}:{},returnType:o.value,visibility:e.visibility}}return e.lifecycle?{args:{},kind:e.kind,lifecycle:e.lifecycle,returnType:"void",visibility:e.visibility}:{args:M(i),kind:e.kind,returnType:T(i),visibility:e.visibility}},E=(i,e,t)=>{const r=_(i);if(r)return{args:r.args,exportName:e,filePath:t,kind:r.kind,returnType:r.returnType,...r.output?{output:r.output}:{},visibility:r.visibility,...r.adminOnly?{adminOnly:!0}:{},...r.expose?{expose:r.expose}:{},...r.lifecycle?{lifecycle:r.lifecycle}:{}}},H=(i,e)=>{const t=[];for(const r of i.getExportAssignments()){if(r.isExportEquals())continue;const s=u(r.getExpression()),o=s?E(s,"default",e):void 0;o&&t.push(o)}return t},K=(i,e)=>{const t=O(i),r=i.getVariableStatements().flatMap(o=>o.getDeclarations()).flatMap(o=>W(o,a=>t.has(a))).flatMap(([o,a])=>(t.get(o)??[]).filter(l=>F(l)).flatMap(l=>E(a,l,e)??[])),s=new Set(r.map(o=>o.exportName));return r.push(...H(i,e).filter(o=>!s.has(o.exportName))),r},q=i=>{const e=new Map;for(const t of i){const r=I(t.filePath),s=e.get(r);if(s&&s!==t.filePath)throw Object.assign(new Error(`Namespace collision: "${s}" and "${t.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:[s,t.filePath],status:500});e.set(r,t.filePath)}},te=(i,e)=>{const t=N(e),r=[];for(const s of t){const o=i.getSourceFile(s)??i.addSourceFileAtPath(s),a=A(e,s);r.push(...K(o,a))}return r.sort((s,o)=>`${s.filePath}:${s.exportName}`.localeCompare(`${o.filePath}:${o.exportName}`)),q(r),r};export{te as default};
1
+ import{d as P}from"./declared-output-Iaar469J.mjs";import{findObjectProperty as c,bindingKeyName as b,listLunoraSourceFiles as N,lunoraRelativePath as A}from"./isTestPath-B81lOULB.mjs";import{e as O,i as F}from"./attribution-hVBriwzy.mjs";import{u as y,p as z,c as g,r as C}from"./unwrap-handler-return-B-jQde6M.mjs";import{b as d,c as S}from"./classify-procedure-call-BAj0D1u2.mjs";import{Node as n,SyntaxKind as L}from"ts-morph";import{r as h,p as x,a as k}from"./parse-validator-IDBKIT7M.mjs";import{s as I}from"./dispatch-namespace-DwTjD7BU.mjs";const T=i=>{const e=i.getArguments()[0];if(!e||!n.isObjectLiteralExpression(e))return"unknown";const t=c(e,"handler");if(!t||!n.isPropertyAssignment(t))return"unknown";const r=t.getInitializer();return!r||!(n.isArrowFunction(r)||n.isFunctionExpression(r))?"unknown":y(r)},w=i=>{const e=i.getArguments()[0];return!e||!(n.isArrowFunction(e)||n.isFunctionExpression(e))?"unknown":y(e)},V=i=>{let e={};for(const t of d(i)){if(t.name!=="input")continue;const r=t.call.getArguments()[0],s=r!==void 0&&n.isExpression(r)?h(r):void 0;s!==void 0&&(e={...x(s),...e})}return e},D=i=>{const e=d(i).find(r=>r.name==="output");if(!e)return;const t=e.call.getArguments()[0];return t&&n.isExpression(t)?z(e.call,()=>k(t)):void 0},p=(i,e)=>{const t=c(i,e);if(t===void 0||!n.isPropertyAssignment(t))return;const r=t.getInitializer();return r!==void 0&&n.isStringLiteral(r)?r.getLiteralValue():void 0},v=(i,e)=>{const t=c(i,e);if(t===void 0||!n.isPropertyAssignment(t))return;const r=t.getInitializer();return r!==void 0&&n.isNumericLiteral(r)?r.getLiteralValue():void 0},j=i=>{const e=c(i,"cache");if(e===void 0||!n.isPropertyAssignment(e))return;const t=e.getInitializer();if(t===void 0||!n.isObjectLiteralExpression(t))return;const r=p(t,"scope"),s=v(t,"maxAge"),o=v(t,"staleWhileRevalidate"),a=p(t,"tag"),l=p(t,"vary"),m={...s===void 0?{}:{maxAge:s},...r==="private"||r==="public"?{scope:r}:{},...o===void 0?{}:{staleWhileRevalidate:o},...a===void 0?{}:{tag:a},...l===void 0?{}:{vary:l}};return Object.keys(m).length===0?void 0:m},B=i=>{if(i===void 0||!n.isObjectLiteralExpression(i))return{};const e=j(i),t=c(i,"rest");return t!==void 0&&n.isPropertyAssignment(t)?{...e===void 0?{}:{cache:e},rest:t.getInitializer()?.getText()==="true"}:e===void 0?{}:{cache:e}},R=i=>{const e=d(i).find(t=>t.name==="expose");return e?B(e.call.getArguments()[0]):void 0},M=i=>{const e=i.getArguments()[0];if(!e||!n.isObjectLiteralExpression(e))return{};const t=c(e,"args");if(!t||!n.isPropertyAssignment(t))return{};const r=t.getInitializer(),s=r===void 0?void 0:h(r);return s===void 0?{}:x(s)},$=8,u=(i,e=0)=>{if(e>$)return;if(n.isCallExpression(i))return i;if(n.isParenthesizedExpression(i)||n.isAsExpression(i)||n.isSatisfiesExpression(i)||n.isNonNullExpression(i))return u(i.getExpression(),e+1);if(!n.isIdentifier(i)&&!n.isPropertyAccessExpression(i))return;const t=i.getSymbol()?.getValueDeclaration();return t?f(t,e+1):void 0},f=(i,e)=>{if(n.isVariableDeclaration(i)||n.isPropertyAssignment(i)){const t=i.getInitializer();return t?u(t,e):void 0}if(n.isShorthandPropertyAssignment(i)){const t=i.getValueSymbol()?.getValueDeclaration();return t?f(t,e+1):void 0}if(n.isBindingElement(i)){const t=b(i),o=i.getFirstAncestorByKind(L.VariableDeclaration)?.getInitializer()?.getType().getProperty(t)?.getValueDeclaration();return o?f(o,e+1):void 0}},W=(i,e=()=>!0)=>{const t=i.getNameNode();if(n.isObjectBindingPattern(t)){const o=[];for(const a of t.getElements().filter(l=>e(l.getName()))){const l=u(a.getNameNode());l&&o.push([a.getName(),l])}return o}if(!e(i.getName()))return[];const r=i.getInitializer(),s=r&&(n.isCallExpression(r)?r:u(r));return s?[[i.getName(),s]]:[]},_=i=>{const e=S(i);if(!e)return;const{receiver:t}=e;if(t){const r=R(t),s=g(()=>D(t)),o=g(()=>w(i)),a=P({kind:e.kind,output:s.value});return C(a?s.erased:o.erased),{args:V(t),...r?{expose:r}:{},...e.adminOnly?{adminOnly:!0}:{},kind:e.kind,...s.value?{output:s.value}:{},returnType:o.value,visibility:e.visibility}}return e.lifecycle?{args:{},kind:e.kind,lifecycle:e.lifecycle,returnType:"void",visibility:e.visibility}:{args:M(i),kind:e.kind,returnType:T(i),visibility:e.visibility}},E=(i,e,t)=>{const r=_(i);if(r)return{args:r.args,exportName:e,filePath:t,kind:r.kind,returnType:r.returnType,...r.output?{output:r.output}:{},visibility:r.visibility,...r.adminOnly?{adminOnly:!0}:{},...r.expose?{expose:r.expose}:{},...r.lifecycle?{lifecycle:r.lifecycle}:{}}},H=(i,e)=>{const t=[];for(const r of i.getExportAssignments()){if(r.isExportEquals())continue;const s=u(r.getExpression()),o=s?E(s,"default",e):void 0;o&&t.push(o)}return t},K=(i,e)=>{const t=O(i),r=i.getVariableStatements().flatMap(o=>o.getDeclarations()).flatMap(o=>W(o,a=>t.has(a))).flatMap(([o,a])=>(t.get(o)??[]).filter(l=>F(l)).flatMap(l=>E(a,l,e)??[])),s=new Set(r.map(o=>o.exportName));return r.push(...H(i,e).filter(o=>!s.has(o.exportName))),r},q=i=>{const e=new Map;for(const t of i){const r=I(t.filePath),s=e.get(r);if(s&&s!==t.filePath)throw Object.assign(new Error(`Namespace collision: "${s}" and "${t.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:[s,t.filePath],status:500});e.set(r,t.filePath)}},te=(i,e)=>{const t=N(e),r=[];for(const s of t){const o=i.getSourceFile(s)??i.addSourceFileAtPath(s),a=A(e,s);r.push(...K(o,a))}return r.sort((s,o)=>`${s.filePath}:${s.exportName}`.localeCompare(`${o.filePath}:${o.exportName}`)),q(r),r};export{te as default};
@@ -1 +1 @@
1
- import{Node as n}from"ts-morph";import{a as m,p as l}from"./parse-validator-IDBKIT7M.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./isTestPath-B81lOULB.mjs";import{b as f,d as g}from"./attribution-BUciBs1M.mjs";import{u as x}from"./unwrap-handler-return-B-jQde6M.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)},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-IDBKIT7M.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./isTestPath-B81lOULB.mjs";import{b as f,d as g}from"./attribution-hVBriwzy.mjs";import{u as x}from"./unwrap-handler-return-B-jQde6M.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)},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-DJ_A1R5i.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-B81lOULB.mjs";import{c as a}from"./attribution-BUciBs1M.mjs";import{i as c}from"./database-calls-ONnjnkMd.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-B81lOULB.mjs";import{c as a}from"./attribution-hVBriwzy.mjs";import{i as c}from"./database-calls-CHZbBUCZ.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-B81lOULB.mjs";import"./attribution-hVBriwzy.mjs";import"./database-calls-CHZbBUCZ.mjs";import"./classify-procedure-call-BAj0D1u2.mjs";import{d as a}from"./index-BW4hJ4Wm.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{b as u}from"./module-specifiers-WF8iAydP.mjs";import{listLunoraSourceFiles as m,lunoraRelativePath as p,findObjectProperty as h}from"./isTestPath-B81lOULB.mjs";import{b as I,a as b}from"./attribution-BUciBs1M.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{b as u}from"./module-specifiers-WF8iAydP.mjs";import{listLunoraSourceFiles as m,lunoraRelativePath as p,findObjectProperty as h}from"./isTestPath-B81lOULB.mjs";import{b as I,a as b}from"./attribution-hVBriwzy.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-B81lOULB.mjs";import{b as d,d as f}from"./attribution-BUciBs1M.mjs";import{c as u}from"./classify-procedure-call-BJdf_-M6.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-B81lOULB.mjs";import{b as d,d as f}from"./attribution-hVBriwzy.mjs";import{c as u}from"./classify-procedure-call-BAj0D1u2.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};
@@ -0,0 +1 @@
1
+ import{Node as i,SyntaxKind as u}from"ts-morph";import{collectCallRows as x}from"./isTestPath-B81lOULB.mjs";import{w as E,c as h}from"./attribution-hVBriwzy.mjs";import{i as v}from"./database-calls-CHZbBUCZ.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-DJ_A1R5i.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-B81lOULB.mjs";import{e as A}from"./exported-procedure-chains-BZk1-hro.mjs";import{r as L}from"./chain-BUxIVIw_.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-B81lOULB.mjs";import{e as A}from"./exported-procedure-chains-DKK5HoK3.mjs";import{r as L}from"./chain-CRDaTj2c.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};
@@ -0,0 +1 @@
1
+ import{Node as o}from"ts-morph";import{listLunoraSourceFiles as c,lunoraRelativePath as f,findObjectProperty as u}from"./isTestPath-B81lOULB.mjs";import{b as p,d}from"./attribution-hVBriwzy.mjs";import{t as m}from"./database-calls-CHZbBUCZ.mjs";import{c as b}from"./classify-procedure-call-BAj0D1u2.mjs";import{r as h}from"./chain-CRDaTj2c.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(["findFirst","findFirstOrThrow","findMany","get","query"]),P=new Set(["delete","deleteMany","insert","insertMany","patch","patchIf","patchMany","replace"]),T=(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,P);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=T(a,n);l&&r.push(l)}}return r};export{M as default};
@@ -0,0 +1 @@
1
+ import{LunoraError as R}from"@lunora/errors";import{Node as i,SyntaxKind as F}from"ts-morph";import{diagnosticAt as d}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{createRequire as C}from"node:module";import{join as _}from"node:path";import{fileURLToPath as B}from"node:url";import{createJiti as V}from"jiti";import{findObjectProperty as u}from"./isTestPath-B81lOULB.mjs";import{r as q,p as J}from"./parse-validator-IDBKIT7M.mjs";import{R as U}from"./reserved-words-CW1QFbTd.mjs";import{a as I}from"./project-config-file-BV7RR-l6.mjs";const K=(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.`,W=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}},Z=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}:{}}),m=e=>{const t=e?._meta??{},n=e?.kind??"unknown",s={column:Z(t.column),kind:n};switch(n){case"array":case"optional":{s.inner=m(t.inner);break}case"from":break;case"id":{s.tableName=t.tableName;break}case"literal":{s.literalValue=W(t.value);break}case"object":{const r=t.shape??{};s.shape=Object.fromEntries(Object.entries(r).map(([o,a])=>[o,m(a)]));break}case"record":{s.valueType=m(t.valueValidator),t.keyValidator!==void 0&&(s.keyType=m(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=>m(o));break}}return s},G=e=>e?.kind==="global"?"global":e?.kind==="shardBy"&&typeof e.field=="string"?{field:e.field,kind:"shardBy"}:"root",X=(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.`)},H=(e,t)=>{const n=e.shape??{},s=(e.indexes??[]).map(r=>({fields:r.fields,name:r.name,...r.unique?{unique:!0}:{}}));return X(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,m(o)])),shardMode:G(e.shardMode),vectorIndexes:[]}},Q=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])=>H(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}},Y=e=>{if(i.isIdentifier(e))return e.getText();if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return i.isIdentifier(t)?t.getText():void 0}},ee=e=>{const t=Y(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:[]}}},te=(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},ne=(e,t)=>{const n=ee(e);if(n)try{const s=V(_(t,"noop.js")).esmResolve(n.moduleSpecifier),r=C(_(t,"noop.cjs"))(s.startsWith("file:")?B(s):s),o=te(r,n);return typeof o!="object"||o===null?void 0:Q(o)}catch{return}},re=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()},x=(e,t)=>{const n=b(e,t);if(n&&i.isNumericLiteral(n))return Number(n.getLiteralText())},O=(e,t)=>{const n=b(e,t);if(n&&(i.isTrueLiteral(n)||i.isFalseLiteral(n)))return n.getLiteralValue()},h=(e,t)=>{const n=b(e,t);if(n&&i.isArrayLiteralExpression(n))return n.getElements().filter(s=>i.isStringLiteral(s)).map(s=>s.getLiteralText())},A=e=>e&&re.has(e)?e:void 0,y=e=>e&&i.isStringLiteral(e)?e.getLiteralText():"_unnamed_",se=(e,t)=>{const n=h(e,t);return n!==void 0&&n.length>0?n:void 0},N=(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 c=l.getArguments()[0];if(!c||!i.isStringLiteral(c))throw d(l,`\`.${t}(...)\` expects a string literal (${r})`);const g=c.getLiteralText();if(!s.has(g))throw d(c,`unknown ${n} ${JSON.stringify(g)} — expected ${r}`);return g}o=l}},ie=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.`,oe=/^(?:sqlite_|_cf_|__)/u,ae=/__(?:agg|rank|geo|fts)_/u,le=e=>oe.test(e)||ae.test(e),ce=new Set(["cascade","restrict","set null"]),de=new Set(["aggregate","asId","cdcChangedTables","count","delete","deleteAll","deleteMany","deleteWhere","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","insertMany","insertManyUnsafe","lookupById","normalizeId","patch","patchIf","patchMany","patchWhere","query","rank","rankBefore","rankPage","rankPageRows","related","relationEdges","replace","restore","system","wipeShard"]),P=/^[A-Za-z_$][\w$]*$/u,S=(e,t)=>{if(de.has(e))throw d(t,`table name "${e}" is reserved — the generated shard binds each table's facade onto the same object that carries \`ctx.db\`'s own members, so this table would overwrite \`ctx.db.${e}\` and every use of it would break. Rename the table.`);if(U.has(e))throw d(t,`table name "${e}" is a reserved JavaScript word — codegen interpolates table names into a bare \`const ${e} = sqliteTable(...)\` binding in the generated Drizzle module, which is a syntax error for a keyword. Rename the table.`);if(!P.test(e))throw d(t,`table name ${JSON.stringify(e)} is not a valid JS identifier — table names are used in generated type names (Doc_<name>) and must match [A-Za-z_$][A-Za-z0-9_$]*. Rename the table.`);if(le(e))throw d(t,`table name ${JSON.stringify(e)} is reserved for framework tables — a leading \`__\` and the \`__agg_\`/\`__rank_\`/\`__geo_\`/\`__fts_\` infixes name Lunora's own bookkeeping and index companions, so the Studio and the admin API hide and refuse such a table. Rename the table.`)},fe=e=>e&&ce.has(e)?e:void 0,ue=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},pe=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 d(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();let l="_unknown_",c="_id",g;return o&&i.isObjectLiteralExpression(o)&&(l=f(o,"field")??l,c=f(o,"references")??c,g=s==="one"?fe(f(o,"onDelete")):void 0),{field:l,kind:s,name:I(e),onDelete:g,references:c,table:a}},ge=e=>{const t=ue(e);if(!t)return[];const n=[];for(const s of t.getProperties()){const r=pe(s);r&&n.push(r)}return n},me=(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 d(e,`index "${n}" indexes the nested path ${JSON.stringify(t)} — Lunora indexes only top-level columns. Denormalise the value into its own column (e.g. \`${o}\`), index that instead, and keep it in sync with a table \`.triggers()\` beforeInsert/beforeUpdate.`)},be=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 d(n,`\`unique\` must be a literal \`true\` or \`false\`, got ${JSON.stringify(n.getText())}`);return i.isTrueLiteral(n)},xe=e=>{const[t,n,s]=e,r=be(s),o=y(t),a=n&&i.isArrayLiteralExpression(n)?n.getElements():[];for(const c of a)if(!i.isStringLiteral(c))throw d(c,`index "${o}" lists a non-literal field (${JSON.stringify(c.getText())}); codegen reads index fields statically, so every entry must be a string literal.`);const l=a.filter(c=>i.isStringLiteral(c));for(const c of l)me(c,c.getLiteralText(),o);return{fields:l.map(c=>c.getLiteralText()),name:o,unique:r}},he=e=>{const[t,n]=e;let s="_unknown_",r,o,a,l;return n&&i.isObjectLiteralExpression(n)&&(s=f(n,"field")??s,r=h(n,"filterFields"),o=f(n,"language"),a=O(n,"staged"),l=f(n,"strategy")),{field:s,filterFields:r,language:o,name:y(t),staged:a,strategy:l}},ye=e=>{const[t,n]=e;let s="_unknown_",r;return n&&i.isObjectLiteralExpression(n)&&(s=f(n,"field")??s,r=x(n,"precision")),{field:s,name:y(t),precision:r}},ve=e=>{const[t,n]=e,s=t&&i.isStringLiteral(t)?t.getLiteralText():"_unknown_";let r;return n&&i.isObjectLiteralExpression(n)&&(r=x(n,"after")),{after:r,field:s}},Ee=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}},Ie=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=>Ee(l)).filter(l=>l!==void 0))}r=h(n,"partitionBy")}return{name:y(t),partitionBy:r,sortBy:s}},Se=(e,t)=>{const[n,s]=e,r=n&&i.isStringLiteral(n)?n.getLiteralText():"_unknown_";if(!(!s||!i.isObjectLiteralExpression(s)))return{dimensions:x(s,"dimensions"),field:r,metadata:h(s,"metadata"),metric:A(f(s,"metric")),name:f(s,"index")??"_unnamed_",table:t}},ke=e=>{const t=e[0];return t&&i.isObjectLiteralExpression(t)&&f(t,"backend")==="hyperdrive"?"hyperdrive":"d1"},we=e=>{if(e&&i.isObjectLiteralExpression(e)){const t=u(e,"field");if(t&&i.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&i.isStringLiteral(n))return n.getLiteralText()}}return"deletedAt"},Te=e=>{const t=e[0];return!t||!i.isObjectLiteralExpression(t)?{binding:"",hasTenantBy:!1,unanalyzable:!0}:{binding:f(t,"binding")??"",columns:se(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")}},_e=(e,t,n,s)=>{switch(t){case"commitOrdered":{e.commitOrdered=!0;break}case"externallyManaged":{e.externallyManaged=!0;break}case"geoIndex":{e.geoIndexes.push(ye(n));break}case"global":{e.shardMode="global",e.globalBackend=ke(n);break}case"index":{e.indexes.push(xe(n));break}case"memory":{e.memory=!0;break}case"public":{e.isPublic=!0;break}case"rankIndex":{e.rankIndexes.push(Ie(n));break}case"relations":{const r=n[0];r&&e.relations.push(...ge(r));break}case"searchIndex":{e.searchIndexes.push(he(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:we(n[0])};break}case"source":{e.externalSource=Te(n),e.externallyManaged=!0;break}case"ttl":{e.ttl=ve(n);break}case"vectorize":{const r=Se(n,s);r&&e.vectorIndexes.push(r);break}}},L=["__vocab","_config","_content","_data","_docsize","_idx"],Le=(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 d(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(", ")}.`)}},Oe=(e,t,n)=>{if(n.ttl!==void 0&&n.shardMode==="global")throw d(e,ie(t))},$=(e,t)=>{const n={commitOrdered:!1,externallyManaged:!1,geoIndexes:[],indexes:[],isPublic:!1,memory:!1,rankIndexes:[],relations:[],searchIndexes:[],shardMode:"root",vectorIndexes:[]};let s={},r=e;for(;i.isCallExpression(r);){const o=r.getExpression(),a=r.getArguments();if(i.isPropertyAccessExpression(o))_e(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=J(l);else if(l)throw d(l,`table "${t}" calls defineTable(${JSON.stringify(l.getText())}), but codegen reads the field map syntactically and can only read an object literal. Inline the fields into the defineTable(...) call. To reuse them in an \`.input()\`, derive from the generated \`Doc_${t}\` / \`Insert_${t}\` type instead of sharing the runtime value.`);break}else break}return n.softDelete&&!(n.softDelete.field in s)&&(s={...s,[n.softDelete.field]:{inner:{column:{notNull:!1},kind:"number"},kind:"optional"}}),Le(e,t,n.searchIndexes),Oe(e,t,n),{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}},j=(e,t=[],n=new Set,s=new Set)=>{s.add(e);for(const r of e.getProperties()){if(i.isSpreadAssignment(r)){const a=q(r.getExpression());a!==void 0&&!s.has(a)&&j(a,t,n,s);continue}if(!i.isPropertyAssignment(r))continue;const o=r.getInitializer();if(o){const a=I(r);if(S(a,r.getNameNode()),n.has(a))throw d(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($(o,a))}}return t},Ae=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_"},Ne=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:x(s,"dimensions"),metric:A(f(s,"metric")),name:o,table:Ae(s)}},D=e=>{const t=[];for(const n of e.getProperties()){const s=Ne(n);s&&t.push(s)}return t},k=(e,t)=>`${e}_${t}`,Pe=(e,t)=>{if(!P.test(e))throw d(t,`defineSchemaExtension key ${JSON.stringify(e)} is not a valid JS identifier — it is prefixed onto every table the extension contributes (\`${e}_<table>\`), and table names are used in generated type names (Doc_<name>) and must match [A-Za-z_$][A-Za-z0-9_$]*. Rename the extension key.`)},E=(e,t,n)=>n.has(e)?k(t,e):e,$e=(e,t,n,s)=>{const r=k(t,e.name);return{...e,extensionKey:t,...s?{extensionFromPackage:!0}:{},name:r,relations:e.relations.map(o=>({...o,table:E(o.table,t,n)})),vectorIndexes:e.vectorIndexes.map(o=>({...o,table:E(o.table,t,n)}))}},je=e=>{if(i.isVariableDeclaration(e)||i.isPropertyAssignment(e))return e.getInitializer();if(i.isShorthandPropertyAssignment(e))return e.getNameNode()},De=e=>{if(!i.isCallExpression(e))return!1;const t=e.getExpression();return i.isIdentifier(t)&&t.getText()==="defineSchemaExtension"},ze=e=>{if(i.isIdentifier(e))return e;if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return i.isIdentifier(t)?t:void 0}},Me=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}}},Re=(e,t)=>{const n=je(e);if(n){if(i.isPropertyAccessExpression(t)){const s=Me(n);return s?b(s,t.getName()):void 0}return n}},Fe=e=>{let t=e,n=0;for(;t&&n<32;){if(n+=1,De(t))return t;const s=ze(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=Re(a,t)}},Ce=e=>{const[t,n]=e.getArguments();if(!(!t||!i.isStringLiteral(t))&&!(!n||!i.isObjectLiteralExpression(n)))return{key:t.getLiteralText(),keyNode:t,options:n}},Be=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=I(r);S(a,r.getNameNode()),s.push($(o,a))}return s},Ve=e=>{const t=u(e,"vectorIndexes");if(!t||!i.isPropertyAssignment(t))return[];const n=t.getInitializer();return!n||!i.isObjectLiteralExpression(n)?[]:D(n)},z=(e,t,n,s,r)=>{Pe(e,s);const o=new Set(t.map(c=>c.name)),a=t.map(c=>$e(c,e,o,r)),l=n.map(c=>({...c,name:k(e,c.name),table:E(c.table,e,o)}));return{tables:a,vectorIndexes:l}},qe=(e,t,n)=>z(e,Be(n),Ve(n),t,t.getSourceFile().getFilePath().includes("/node_modules/")),Je=(e,t)=>{const n=e.getArguments()[0];if(!n)return;const s=Fe(n);if(!s){if(t!==void 0){const o=ne(n,t);if(o){for(const a of o.bareTables)S(a.name,n);return z(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=Ce(s);if(!r){console.warn("@lunora/codegen: skipping `.extend(...)` — `defineSchemaExtension` requires a string `key` and an options object literal.");return}return qe(r.key,r.keyNode,r.options)},Ue=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},Ke=(e,t,n)=>{const s=new Set(t.map(o=>o.name)),r=[];for(const o of Ue(e)){const a=Je(o,n);if(a){for(const l of a.tables){if(s.has(l.name))throw d(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},We=new Set(["eu","fedramp","us"]),Ze=e=>N(e,"jurisdiction","jurisdiction",We,'"eu", "us", or "fedramp"'),Ge=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)&&O(r,"pinAuth")===!0}t=s}},Xe=new Set(["required"]),He=e=>N(e,"rls","rls mode",Xe,'"required"'),ct=(e,t,n)=>{const r=e.addSourceFileAtPath(t).getDescendantsOfKind(F.CallExpression).find(p=>{const T=p.getExpression();return i.isIdentifier(T)&&T.getText()==="defineSchema"});if(!r)throw new R("INTERNAL",`defineSchema() not found in ${t}`);const o=r.getArguments()[0];if(!o||!i.isObjectLiteralExpression(o))throw d(r,"defineSchema() expects an object literal");const a=j(o),l=r.getArguments()[1],c=l&&i.isObjectLiteralExpression(l)?D(l):[],g=Ke(r,a,n),w=[...a.flatMap(p=>p.vectorIndexes),...c,...g],M=new Set(a.filter(p=>p.shardMode==="global").map(p=>p.name)),v=w.find(p=>M.has(p.table));if(v)throw d(r,K(v.table,v.name));return{jurisdiction:Ze(r),...Ge(r)?{jurisdictionPinsAuth:!0}:{},rlsMode:He(r),tables:a,vectorIndexes:w}};export{ct as default};
@@ -1 +1 @@
1
- import{Node as u}from"ts-morph";import{listLunoraSourceFiles as f,lunoraRelativePath as p,stringPropertyOf as l}from"./isTestPath-B81lOULB.mjs";import{w as d}from"./classify-procedure-call-BJdf_-M6.mjs";import{e as m}from"./exported-procedure-chains-BZk1-hro.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-B81lOULB.mjs";import{w as d}from"./classify-procedure-call-BAj0D1u2.mjs";import{e as m}from"./exported-procedure-chains-DKK5HoK3.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};
@@ -0,0 +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-BX0xmo0P.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,4 +1,4 @@
1
- import{APP_METHOD_CAPABILITIES as k}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{i as S}from"./ir-DBSvhNa-.mjs";import{G as E}from"./shared-DnCokNcE.mjs";const D={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},g=e=>[...k.filter(({key:r})=>e.capabilities.has(r)).map(({appMethod:r})=>r),...e.hasVectors?[D]:[]],m=e=>g(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-DnCokNcE.mjs";const D={configKey:"vectors",doc:"Wire the Vectorize index map backing `ctx.vectors`.",method:"vectors"},g=e=>[...k.filter(({key:r})=>e.capabilities.has(r)).map(({appMethod:r})=>r),...e.hasVectors?[D]:[]],m=e=>g(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{i as m}from"./ir-DBSvhNa-.mjs";import{G as i,d as c}from"./shared-DnCokNcE.mjs";const u=r=>r?`${i}/**
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}/**
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
  *
@@ -0,0 +1 @@
1
+ import"./CAPABILITY_PROBES-brcmKenl.mjs";import{e}from"./server-DAvi_bv_.mjs";import"./shared-DnCokNcE.mjs";import"./platform-8oj7iXQy.mjs";export{e as default};
@@ -0,0 +1 @@
1
+ import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as d}from"./shard-DfBMIpi9.mjs";import"./shard-runtime-BX0xmo0P.mjs";import"./shared-DnCokNcE.mjs";import"./platform-8oj7iXQy.mjs";import"./schema-BgM8A3XV.mjs";export{d as default};
@@ -1 +1 @@
1
- import{Node as s}from"ts-morph";import{b as t,d as c}from"./attribution-BUciBs1M.mjs";import{c as n}from"./classify-procedure-call-BJdf_-M6.mjs";const m=a=>{const i=[];for(const e of t(a)){const r=e.getInitializer(),o=r&&s.isCallExpression(r)?n(r):void 0;o?.receiver&&i.push({name:c(e)??e.getName(),receiver:o.receiver})}return i};export{m as e};
1
+ import{Node as s}from"ts-morph";import{b as t,d as c}from"./attribution-hVBriwzy.mjs";import{c as n}from"./classify-procedure-call-BAj0D1u2.mjs";const m=a=>{const i=[];for(const e of t(a)){const r=e.getInitializer(),o=r&&s.isCallExpression(r)?n(r):void 0;o?.receiver&&i.push({name:c(e)??e.getName(),receiver:o.receiver})}return i};export{m as e};
@@ -1 +1 @@
1
- import{dirname as F}from"node:path";import{Node as e}from"ts-morph";import{unwrapExpression as m,lunoraRelativePath as u}from"./isTestPath-B81lOULB.mjs";import{r as v,d as b}from"./attribution-BUciBs1M.mjs";const h=i=>e.isPropertyAssignment(i)?m(i.getInitializer()):e.isShorthandPropertyAssignment(i)?i.getNameNode():void 0,A=(i,s)=>{const o=i===void 0?void 0:h(i);if(o===void 0||!e.isIdentifier(o))return;const a=v(o),g=a?.getAliasedSymbol()??a;for(const t of g?.getDeclarations()??[]){const n=e.isVariableDeclaration(t)?m(t.getInitializer()):t;if(!(e.isFunctionDeclaration(n)||e.isArrowFunction(n)||e.isFunctionExpression(n))||!(e.isFunctionDeclaration(t)||e.isVariableDeclaration(t)))continue;const r=t.getSourceFile(),c=u(s,r.getFilePath()),l=!c.startsWith("../"),d=l?c:u(F(s),r.getFilePath()),f=b(t);return{body:n,...r===o.getSourceFile()?{}:{file:d},...l&&f!==void 0?{site:{exportName:f,file:d}}:{}}}};export{A as r};
1
+ import{dirname as F}from"node:path";import{Node as e}from"ts-morph";import{unwrapExpression as m,lunoraRelativePath as u}from"./isTestPath-B81lOULB.mjs";import{r as v,d as b}from"./attribution-hVBriwzy.mjs";const h=i=>e.isPropertyAssignment(i)?m(i.getInitializer()):e.isShorthandPropertyAssignment(i)?i.getNameNode():void 0,A=(i,s)=>{const o=i===void 0?void 0:h(i);if(o===void 0||!e.isIdentifier(o))return;const a=v(o),g=a?.getAliasedSymbol()??a;for(const t of g?.getDeclarations()??[]){const n=e.isVariableDeclaration(t)?m(t.getInitializer()):t;if(!(e.isFunctionDeclaration(n)||e.isArrowFunction(n)||e.isFunctionExpression(n))||!(e.isFunctionDeclaration(t)||e.isVariableDeclaration(t)))continue;const r=t.getSourceFile(),c=u(s,r.getFilePath()),l=!c.startsWith("../"),d=l?c:u(F(s),r.getFilePath()),f=b(t);return{body:n,...r===o.getSourceFile()?{}:{file:d},...l&&f!==void 0?{site:{exportName:f,file:d}}:{}}}};export{A as r};
@@ -1 +1 @@
1
- import{Node as i}from"ts-morph";import{listLunoraSourceFiles as u,lunoraRelativePath as f}from"./isTestPath-B81lOULB.mjs";import{b as m,d as p}from"./attribution-BUciBs1M.mjs";import{t as d}from"./database-calls-ONnjnkMd.mjs";import{w as g,c as h}from"./classify-procedure-call-BJdf_-M6.mjs";import{a as k}from"./project-config-file-BV7RR-l6.mjs";const l=e=>{if(!(!i.isPropertyAssignment(e)&&!i.isShorthandPropertyAssignment(e)&&!i.isMethodDeclaration(e)&&!i.isGetAccessorDeclaration(e)))return k(e)},v=e=>g(e,"use","mask"),D=e=>{if(i.isPropertyAssignment(e)){const s=e.getInitializer();if(s&&i.isStringLiteral(s)){const t=s.getLiteralText();if(t==="redact"||t==="hash")return t}}return"custom"},P=e=>{const s=e.getArguments()[0];if(!s||!i.isObjectLiteralExpression(s))return[];const t=[];for(const r of s.getProperties()){const o=l(r);if(o===void 0||!i.isPropertyAssignment(r))continue;const n=r.getInitializer();if(!(!n||!i.isObjectLiteralExpression(n)))for(const a of n.getProperties()){const c=l(a);c!==void 0&&t.push({column:c,table:o})}}return t},y=e=>{const s=v(e);return{maskColumns:s.flatMap(t=>P(t)),usesMask:s.length>0}},C=new Set(["findFirst","findFirstOrThrow","findMany","get","query"]),M=new Set(["delete","insert","patch","replace"]),b=(e,s)=>{if(!i.isVariableDeclaration(e))return;const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const r=h(t);if(!r)return;const o=r.receiver?y(r.receiver):{maskColumns:[],usesMask:!1},{tablesRead:n,tablesWritten:a}=d(e,C,M);return{exportName:p(e)??e.getName(),file:s,maskColumns:o.maskColumns,tablesRead:n,tablesWritten:a,usesMask:o.usesMask,visibility:r.visibility}},E=(e,s)=>{const t=[];for(const r of u(s)){const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=f(s,r);for(const a of m(o)){const c=b(a,n);c&&t.push(c)}}return t};export{l as a,E as d,v as m,D as s};
1
+ import{Node as i}from"ts-morph";import{listLunoraSourceFiles as u,lunoraRelativePath as f}from"./isTestPath-B81lOULB.mjs";import{b as m,d as p}from"./attribution-hVBriwzy.mjs";import{t as d}from"./database-calls-CHZbBUCZ.mjs";import{w as g,c as h}from"./classify-procedure-call-BAj0D1u2.mjs";import{a as k}from"./project-config-file-BV7RR-l6.mjs";const l=e=>{if(!(!i.isPropertyAssignment(e)&&!i.isShorthandPropertyAssignment(e)&&!i.isMethodDeclaration(e)&&!i.isGetAccessorDeclaration(e)))return k(e)},v=e=>g(e,"use","mask"),D=e=>{if(i.isPropertyAssignment(e)){const s=e.getInitializer();if(s&&i.isStringLiteral(s)){const t=s.getLiteralText();if(t==="redact"||t==="hash")return t}}return"custom"},P=e=>{const s=e.getArguments()[0];if(!s||!i.isObjectLiteralExpression(s))return[];const t=[];for(const r of s.getProperties()){const o=l(r);if(o===void 0||!i.isPropertyAssignment(r))continue;const n=r.getInitializer();if(!(!n||!i.isObjectLiteralExpression(n)))for(const a of n.getProperties()){const c=l(a);c!==void 0&&t.push({column:c,table:o})}}return t},y=e=>{const s=v(e);return{maskColumns:s.flatMap(t=>P(t)),usesMask:s.length>0}},C=new Set(["findFirst","findFirstOrThrow","findMany","get","query"]),M=new Set(["delete","insert","patch","replace"]),b=(e,s)=>{if(!i.isVariableDeclaration(e))return;const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const r=h(t);if(!r)return;const o=r.receiver?y(r.receiver):{maskColumns:[],usesMask:!1},{tablesRead:n,tablesWritten:a}=d(e,C,M);return{exportName:p(e)??e.getName(),file:s,maskColumns:o.maskColumns,tablesRead:n,tablesWritten:a,usesMask:o.usesMask,visibility:r.visibility}},E=(e,s)=>{const t=[];for(const r of u(s)){const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=f(s,r);for(const a of m(o)){const c=b(a,n);c&&t.push(c)}}return t};export{l as a,E as d,v as m,D as s};
@@ -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
+ const o=d=>typeof d.shardMode=="object"&&d.shardMode.kind==="shardBy";export{o as i};
@@ -1,4 +1,4 @@
1
- import{CAPABILITIES as Re}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{p as Se}from"./ir-DBSvhNa-.mjs";import{join as q,relative as m,dirname as Q,isAbsolute as De,sep as Me}from"node:path";import{ts as i,Project as Ce}from"ts-morph";import{G as Z,a as $,u as Ne,d as Ae}from"./shared-DnCokNcE.mjs";const ee=/(?:\.d)?\.([cm]?)tsx?$/u,Fe=t=>t.replace(ee,".d.$1ts"),te=(t,n)=>{const a=m(t,n).split(Me).join("/").replace(ee,".$1js");return a.startsWith(".")?a:`./${a}`},ae=t=>t.replaceAll("\\","/"),E=(t,n,a)=>ae(q(t,Fe(m(n,a)))),Pe=t=>te(".",q("services",t.name,m(Q(t.wranglerPath),t.main))),We=t=>{const n=[],a=r=>{(i.isImportDeclaration(r)||i.isExportDeclaration(r))&&r.moduleSpecifier!==void 0&&i.isStringLiteral(r.moduleSpecifier)?n.push(r.moduleSpecifier):i.isImportTypeNode(r)&&i.isLiteralTypeNode(r.argument)&&i.isStringLiteral(r.argument.literal)&&n.push(r.argument.literal),i.forEachChild(r,a)};return a(t),n},Ge=(t,n)=>{const a=Q(t.wranglerPath),r=m(a,t.main);if(r.startsWith("..")||De(r))throw new Error(`@lunora/codegen: service "${t.name}": its entry module (${t.main}) must be inside ${a} to be typed as RPC`);const d=q(n,"services",t.name),c=i.findConfigFile(a,o=>i.sys.fileExists(o)),p=new Ce({compilerOptions:{composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!1,outDir:d,rootDir:a},skipAddingFilesFromTsConfig:!0,...c===void 0?{}:{tsConfigFilePath:c}});p.addSourceFileAtPath(t.main),p.resolveSourceFileDependencies();const u={...p.getCompilerOptions(),preserveSymlinks:!0},x=new Map(p.getSourceFiles().map(o=>o.getFilePath()).filter(o=>!o.endsWith(".d.ts")&&!m(a,o).startsWith("..")).map(o=>[E(d,a,o),o])),y={};for(const o of p.emitToMemory({emitOnlyDtsFiles:!0}).getFiles()){const g=x.get(ae(o.filePath));if(g===void 0)continue;const h=i.createSourceFile(o.filePath,o.text,i.ScriptTarget.Latest,!1);let{text:f}=o;for(const b of We(h).toReversed()){const s=i.resolveModuleName(b.text,g,u,i.sys).resolvedModule?.resolvedFileName;if(s===void 0)continue;const T=E(d,a,s),v=x.has(T)?T:s;f=`${f.slice(0,b.getStart(h))}${JSON.stringify(te(Q(o.filePath),v))}${f.slice(b.getEnd())}`}y[m(n,o.filePath)]=`${Z}${f}`}if(y[m(n,E(d,a,t.main))]===void 0)throw new Error(`@lunora/codegen: service "${t.name}": TypeScript emitted no declaration for its entry module ${t.main}`);return y},je=(t,n=[])=>{const a=new Set;for(const r of t.tables)for(const d of Object.values(r.shape)){const c=Ne(d);c.kind==="storage"&&typeof c.bucket=="string"&&c.bucket!==""&&a.add(c.bucket)}for(const r of n)r!==""&&r!=="default"&&a.add(r);return["default",...[...a].toSorted((r,d)=>r.localeCompare(d))]},He=({agents:t=[],capabilities:n=new Set,containers:a=[],env:r,hasVectors:d=!0,hasFlags:c=!1,hasNotify:p=!1,identity:u,queues:x=[],schema:y,services:o=[],storageRuleBuckets:g=[],topics:h=[],useUmbrella:f=!1,workflows:b=[]}={})=>{const s=Ae(f),T=je(y??{tables:[]},g).map(e=>JSON.stringify(e)).join(" | "),v=e=>e.sandbox===!0?"SandboxContainerAccessor":"ContainerAccessor",re=[...new Set(a.map(e=>v(e)))].toSorted((e,l)=>e.localeCompare(l)),oe=a.length>0?`import type { ${re.join(", ")} } from "@lunora/container";
1
+ import{CAPABILITIES as Re}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{join as q,relative as m,dirname as Q,isAbsolute as Se,sep as De}from"node:path";import{ts as i,Project as Me}from"ts-morph";import{G as Z,a as $,u as Ce,d as Ne}from"./shared-DnCokNcE.mjs";import{p as Ae}from"./platform-8oj7iXQy.mjs";const ee=/(?:\.d)?\.([cm]?)tsx?$/u,Fe=t=>t.replace(ee,".d.$1ts"),te=(t,n)=>{const a=m(t,n).split(De).join("/").replace(ee,".$1js");return a.startsWith(".")?a:`./${a}`},ae=t=>t.replaceAll("\\","/"),E=(t,n,a)=>ae(q(t,Fe(m(n,a)))),Pe=t=>te(".",q("services",t.name,m(Q(t.wranglerPath),t.main))),We=t=>{const n=[],a=r=>{(i.isImportDeclaration(r)||i.isExportDeclaration(r))&&r.moduleSpecifier!==void 0&&i.isStringLiteral(r.moduleSpecifier)?n.push(r.moduleSpecifier):i.isImportTypeNode(r)&&i.isLiteralTypeNode(r.argument)&&i.isStringLiteral(r.argument.literal)&&n.push(r.argument.literal),i.forEachChild(r,a)};return a(t),n},Ge=(t,n)=>{const a=Q(t.wranglerPath),r=m(a,t.main);if(r.startsWith("..")||Se(r))throw new Error(`@lunora/codegen: service "${t.name}": its entry module (${t.main}) must be inside ${a} to be typed as RPC`);const d=q(n,"services",t.name),c=i.findConfigFile(a,o=>i.sys.fileExists(o)),p=new Me({compilerOptions:{composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!1,outDir:d,rootDir:a},skipAddingFilesFromTsConfig:!0,...c===void 0?{}:{tsConfigFilePath:c}});p.addSourceFileAtPath(t.main),p.resolveSourceFileDependencies();const u={...p.getCompilerOptions(),preserveSymlinks:!0},x=new Map(p.getSourceFiles().map(o=>o.getFilePath()).filter(o=>!o.endsWith(".d.ts")&&!m(a,o).startsWith("..")).map(o=>[E(d,a,o),o])),y={};for(const o of p.emitToMemory({emitOnlyDtsFiles:!0}).getFiles()){const g=x.get(ae(o.filePath));if(g===void 0)continue;const h=i.createSourceFile(o.filePath,o.text,i.ScriptTarget.Latest,!1);let{text:f}=o;for(const b of We(h).toReversed()){const s=i.resolveModuleName(b.text,g,u,i.sys).resolvedModule?.resolvedFileName;if(s===void 0)continue;const T=E(d,a,s),v=x.has(T)?T:s;f=`${f.slice(0,b.getStart(h))}${JSON.stringify(te(Q(o.filePath),v))}${f.slice(b.getEnd())}`}y[m(n,o.filePath)]=`${Z}${f}`}if(y[m(n,E(d,a,t.main))]===void 0)throw new Error(`@lunora/codegen: service "${t.name}": TypeScript emitted no declaration for its entry module ${t.main}`);return y},je=(t,n=[])=>{const a=new Set;for(const r of t.tables)for(const d of Object.values(r.shape)){const c=Ce(d);c.kind==="storage"&&typeof c.bucket=="string"&&c.bucket!==""&&a.add(c.bucket)}for(const r of n)r!==""&&r!=="default"&&a.add(r);return["default",...[...a].toSorted((r,d)=>r.localeCompare(d))]},He=({agents:t=[],capabilities:n=new Set,containers:a=[],env:r,hasVectors:d=!0,hasFlags:c=!1,hasNotify:p=!1,identity:u,queues:x=[],schema:y,services:o=[],storageRuleBuckets:g=[],topics:h=[],useUmbrella:f=!1,workflows:b=[]}={})=>{const s=Ne(f),T=je(y??{tables:[]},g).map(e=>JSON.stringify(e)).join(" | "),v=e=>e.sandbox===!0?"SandboxContainerAccessor":"ContainerAccessor",re=[...new Set(a.map(e=>v(e)))].toSorted((e,l)=>e.localeCompare(l)),oe=a.length>0?`import type { ${re.join(", ")} } from "@lunora/container";
2
2
  `:"",ne=a.length>0?`
3
3
  readonly containers: {${a.map(e=>`
4
4
  readonly ${e.exportName}: ${v(e)};`).join("")}
@@ -49,7 +49,7 @@ export interface LunoraWorkflows {
49
49
  ${b.map(e=>` get(name: ${JSON.stringify(e.exportName)}): WorkflowHandle<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${e.exportName}>>;`).join(`
50
50
  `)}
51
51
  }`:"",H=w?' | "workflows"':"",U=w?`
52
- readonly workflows: LunoraWorkflows;`:"",R=Se(x),S=R.length>0,D=h.length>0,M=[...S?["QueueProducer"]:[],...D?["TopicPublisher"]:[]],z=[...new Set([...R,...h].map(e=>e.filePath))].toSorted((e,l)=>+(l==="queues")-+(e==="queues")||e.localeCompare(l)),C=e=>e==="queues"?"lunoraQueueDefinitions":`lunoraQueueDefinitions${String(z.indexOf(e))}`,pe=M.length>0?`import type { ${M.join(", ")} } from "@lunora/queue";
52
+ readonly workflows: LunoraWorkflows;`:"",R=Ae(x),S=R.length>0,D=h.length>0,M=[...S?["QueueProducer"]:[],...D?["TopicPublisher"]:[]],z=[...new Set([...R,...h].map(e=>e.filePath))].toSorted((e,l)=>+(l==="queues")-+(e==="queues")||e.localeCompare(l)),C=e=>e==="queues"?"lunoraQueueDefinitions":`lunoraQueueDefinitions${String(z.indexOf(e))}`,pe=M.length>0?`import type { ${M.join(", ")} } from "@lunora/queue";
53
53
  ${z.map(e=>`import type * as ${C(e)} from "../${e}.js";
54
54
  `).join("")}`:"",me=M.length>0?"\n\n/** Message body type carried by a `defineQueue` / `defineTopic` definition (its phantom `__lunoraBody`). */\ntype QueueBodyOf<Definition> = Definition extends { __lunoraBody?: infer Body } ? (unknown extends Body ? unknown : NonNullable<Body>) : unknown;":"",ye=S?`
55
55
 
@@ -1,4 +1,4 @@
1
- import{LunoraError as vt}from"@lunora/errors";import{serializeSchemaSnapshot as kt,hashSchemaSnapshot as St}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{isHyperdriveGlobalTable as Rt,isD1GlobalTable as xt}from"./isD1GlobalTable-udvHAAzD.mjs";import{p as At,i as Dt}from"./ir-DBSvhNa-.mjs";import{r as h}from"./json-data-Chfs2Cz5.mjs";import{r as C,e as Ot,a as Tt,b as Et,c as Ct,d as Lt,f as It,g as _t,h as Mt,i as Pt,j as Nt,k as qt,l as $t,m as Ft,n as Ut,o as Bt,p as Wt,q as jt}from"./shard-runtime-CkaEBSdL.mjs";import{u as K,i as Ht,G as Vt,d as Kt}from"./shared-DnCokNcE.mjs";const Gt=` /**
1
+ import{LunoraError as vt}from"@lunora/errors";import{serializeSchemaSnapshot as kt,hashSchemaSnapshot as St}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{isHyperdriveGlobalTable as Rt,isD1GlobalTable as xt}from"./isD1GlobalTable-udvHAAzD.mjs";import{r as h}from"./json-data-Chfs2Cz5.mjs";import{r as C,e as At,a as Dt,b as Ot,c as Tt,d as Et,f as Ct,g as Lt,h as It,i as _t,j as Mt,k as Pt,l as Nt,m as qt,n as $t,o as Ft,p as Ut,q as Bt}from"./shard-runtime-BX0xmo0P.mjs";import{u as K,i as Wt,G as jt,d as Ht}from"./shared-DnCokNcE.mjs";import{p as Vt}from"./platform-8oj7iXQy.mjs";import{i as Kt}from"./schema-BgM8A3XV.mjs";const Gt=` /**
2
2
  * The bare writer every admin/maintenance entry point writes through.
3
3
  *
4
4
  * Admin and maintenance writes go through the SAME reactive-cache hooks as a
@@ -786,7 +786,7 @@ const dispatchRun = async (
786
786
  // \`ctx.auth\` stream as nobody — or as a concurrent RPC's caller.
787
787
  iterator: (signal) => (registered.handler as (context: unknown, args: Record<string, unknown>, signal: AbortSignal) => AsyncIterable<unknown>)(this.buildCtx({ functionPath, identity }), args, signal),
788
788
  };
789
- }`,Zt=a=>{const r={};for(const e of a.tables){const n={};for(const[t,o]of Object.entries(e.shape)){const d=K(o);d.kind==="id"&&d.tableName!==void 0&&(n[t]=d.tableName)}Object.keys(n).length>0&&(r[e.name]=n)}return r},er=a=>{const r={};for(const e of a.tables){const n=[];for(const[t,o]of Object.entries(e.shape))K(o).kind==="storage"&&n.push(t);n.length>0&&(r[e.name]=n)}return r},tr=a=>{const r={};for(const e of a.tables){const n=[...e.indexes.map(t=>({fields:[...t.fields],name:t.name,type:"index",...t.unique===!0?{unique:!0}:{}})),...e.searchIndexes.map(t=>({fields:[t.field,...t.filterFields??[]],name:t.name,type:"search"})),...(e.geoIndexes??[]).map(t=>({fields:[t.field],name:t.name,type:"geo"})),...e.rankIndexes.map(t=>({fields:t.sortBy.map(o=>o.field),name:t.name,type:"rank"})),...e.vectorIndexes.map(t=>({fields:t.field===void 0?[]:[t.field],name:t.name,type:"vector"}))];n.length>0&&(r[e.name]=n)}return r},rr=a=>{const r=[];for(const e of a.tables)!e.ttl||e.shardMode==="global"||r.push({...e.ttl.after===void 0?{}:{after:e.ttl.after},field:e.ttl.field,...e.softDelete?{softDeleteField:e.softDelete.field}:{},table:e.name});return r},ar=a=>{if(a.kind!=="union"||a.members===void 0||a.members.length===0)return;const r=[];for(const e of a.members){if(e.kind!=="literal"||e.literalValue===void 0)return;try{const n=JSON.parse(e.literalValue);if(typeof n!="string")return;r.push(n)}catch{return}}return r},nr=(a,r,e)=>{const n=K(r),t={name:a,optional:Ht(r),type:n.kind};if(n.kind==="id"&&n.tableName!==void 0){t.ref=n.tableName;const d=e.get(a);d!==void 0&&(t.onDelete=d)}n.kind==="storage"&&(t.isStorage=!0,n.bucket!==void 0&&(t.bucket=n.bucket));const o=ar(n);return o!==void 0&&(t.enumValues=o),n.column?.notNull===!1&&(t.nullable=!0),t},sr=a=>{const r={};for(const e of a.tables){const n=[{name:"_id",optional:!1,pk:!0,type:"id"},{name:"_creationTime",optional:!1,type:"number"},...e.commitOrdered===!0?[{name:"_commitSeq",optional:!1,type:"number"}]:[]],t=new Map(e.relations.filter(o=>o.kind==="one").map(o=>[o.field,o.onDelete]));for(const[o,d]of Object.entries(e.shape))n.push(nr(o,d,t));r[e.name]=n}return r},or=({hasMutators:a,hasShapes:r,rlsData:e})=>{const n=r?`
789
+ }`,Zt=a=>{const r={};for(const e of a.tables){const n={};for(const[t,o]of Object.entries(e.shape)){const d=K(o);d.kind==="id"&&d.tableName!==void 0&&(n[t]=d.tableName)}Object.keys(n).length>0&&(r[e.name]=n)}return r},er=a=>{const r={};for(const e of a.tables){const n=[];for(const[t,o]of Object.entries(e.shape))K(o).kind==="storage"&&n.push(t);n.length>0&&(r[e.name]=n)}return r},tr=a=>{const r={};for(const e of a.tables){const n=[...e.indexes.map(t=>({fields:[...t.fields],name:t.name,type:"index",...t.unique===!0?{unique:!0}:{}})),...e.searchIndexes.map(t=>({fields:[t.field,...t.filterFields??[]],name:t.name,type:"search"})),...(e.geoIndexes??[]).map(t=>({fields:[t.field],name:t.name,type:"geo"})),...e.rankIndexes.map(t=>({fields:t.sortBy.map(o=>o.field),name:t.name,type:"rank"})),...e.vectorIndexes.map(t=>({fields:t.field===void 0?[]:[t.field],name:t.name,type:"vector"}))];n.length>0&&(r[e.name]=n)}return r},rr=a=>{const r=[];for(const e of a.tables)!e.ttl||e.shardMode==="global"||r.push({...e.ttl.after===void 0?{}:{after:e.ttl.after},field:e.ttl.field,...e.softDelete?{softDeleteField:e.softDelete.field}:{},table:e.name});return r},ar=a=>{if(a.kind!=="union"||a.members===void 0||a.members.length===0)return;const r=[];for(const e of a.members){if(e.kind!=="literal"||e.literalValue===void 0)return;try{const n=JSON.parse(e.literalValue);if(typeof n!="string")return;r.push(n)}catch{return}}return r},nr=(a,r,e)=>{const n=K(r),t={name:a,optional:Wt(r),type:n.kind};if(n.kind==="id"&&n.tableName!==void 0){t.ref=n.tableName;const d=e.get(a);d!==void 0&&(t.onDelete=d)}n.kind==="storage"&&(t.isStorage=!0,n.bucket!==void 0&&(t.bucket=n.bucket));const o=ar(n);return o!==void 0&&(t.enumValues=o),n.column?.notNull===!1&&(t.nullable=!0),t},sr=a=>{const r={};for(const e of a.tables){const n=[{name:"_id",optional:!1,pk:!0,type:"id"},{name:"_creationTime",optional:!1,type:"number"},...e.commitOrdered===!0?[{name:"_commitSeq",optional:!1,type:"number"}]:[]],t=new Map(e.relations.filter(o=>o.kind==="one").map(o=>[o.field,o.onDelete]));for(const[o,d]of Object.entries(e.shape))n.push(nr(o,d,t));r[e.name]=n}return r},or=({hasMutators:a,hasShapes:r,rlsData:e})=>{const n=r?`
790
790
  protected override resolveShape(name: string, args: Record<string, unknown>, identity?: SubscriptionIdentity): { columns?: readonly string[]; effectiveWhere?: WhereInput; global?: boolean; table: string } | undefined {
791
791
  const shape = LUNORA_SHAPES[name];
792
792
 
@@ -1113,10 +1113,10 @@ ${o} const vectors = createContextVectors(lunora${f});
1113
1113
  ordered: async (read, work) => this.runOrderedAfterWrites(read, work),
1114
1114
  });
1115
1115
  }
1116
- `:"",vectorsBuild:c,vectorsStub:t}},kr=({advisories:a=[],advisorProcedures:r=[],agents:e=[],capabilities:n=new Set,containers:t=[],env:o,flagKeys:d=[],hasFlags:m=!1,hasNotify:f=!1,hasVectors:c=!0,maskMetadata:w,mutators:S=[],queues:y=[],rlsMetadata:L,schema:i,schemaSnapshot:g,shapes:I=[],storageRules:_,studioFeatures:M,services:A=[],topics:P=[],useUmbrella:N=!1,workflows:R=[]})=>{const l=Kt(N),D=S.length>0,v=I.length>0,k=g===void 0?"":kt(g),te=g===void 0?"":`
1116
+ `:"",vectorsBuild:c,vectorsStub:t}},Sr=({advisories:a=[],advisorProcedures:r=[],agents:e=[],capabilities:n=new Set,containers:t=[],env:o,flagKeys:d=[],hasFlags:m=!1,hasNotify:f=!1,hasVectors:c=!0,maskMetadata:w,mutators:S=[],queues:y=[],rlsMetadata:L,schema:i,schemaSnapshot:g,shapes:I=[],storageRules:_,studioFeatures:M,services:A=[],topics:P=[],useUmbrella:N=!1,workflows:R=[]})=>{const l=Ht(N),D=S.length>0,v=I.length>0,k=g===void 0?"":kt(g),te=g===void 0?"":`
1117
1117
  /** Structural schema snapshot + its content hash, recorded in the shard's \`__lunora_schema_history\` ledger on cold start so the studio can show a schema-version timeline and diff any two versions. */
1118
1118
  const LUNORA_SCHEMA_SNAPSHOT: { hash: string; json: string } = { hash: ${JSON.stringify(St(g))}, json: ${JSON.stringify(k)} };
1119
- `,re=g===void 0?"":", schemaSnapshot: LUNORA_SCHEMA_SNAPSHOT",b=Ot(n),O=Tt(m,l.flags),q=Et(d,m,l.flags),$=jt(f),F=Ct(o),{build:ae,contextField:ne,importLines:se,specs:oe}=Lt(At(y)),{build:ie,contextField:de,importLines:ce,specs:le}=It(P,y),U=_t(A,l.server),{build:he,contextField:ue,importLines:pe,specs:me}=Mt(t,i.jurisdiction),{build:ge,contextField:be,importLines:fe,specs:we}=Pt(R),{build:ye,contextField:ve,importLines:ke,specs:Se}=Nt(e),{build:Re,configField:xe,contextField:Ae,imports:De,stub:Oe}=qt(n.has("payments")),Te=a,Ee=r,G=L??{policies:[],roles:[]},Ce=w??{columns:[]},Le=_??{rules:[]},Ie=M??{analytics:!1,auth:!1,containers:!1,flags:!1,kv:!1,mail:!1,notifications:!1,payments:!1,queues:!1,scheduler:!1,storage:!1,vectors:!1,workflows:!1},{constant:_e,override:Me}=$t(R),{constant:Pe,override:Ne}=Ft(y),u=c&&i.vectorIndexes.length>0,B=new Set(i.tables.filter(s=>Dt(s)).map(s=>s.name)),Q=u&&i.vectorIndexes.some(s=>B.has(s.table)),x=i.tables.some(s=>s.shardMode==="global"),W=Ut(B),j=i.tables.some(s=>Rt(s)),z=i.tables.some(s=>xt(s)),T=i.tables.some(s=>s.externalSource!==void 0),X=i.tables.some(s=>s.memory===!0),H=i.tables.some(s=>s.shardMode!=="global"&&s.searchIndexes.length>0);if(z&&j)throw new vt("INTERNAL",'lunora codegen: mixing `.global()` (D1) and `.global({ backend: "hyperdrive" })` tables in one app is not supported yet — use a single global backend.');const V=i.tables.length>0,qe=Zt(i),$e=tr(i),Fe=sr(i),Ue=er(i),J=rr(i),Y=Bt(u,R.length>0,y.length>0,m,H);v&&Y.push("WhereInput");const Z=Wt(x),{customMutatorOverride:Be,shapeGuardImport:We,shapeReadPolicyAssertion:je,shapeReadPolicyImport:He,shapeResolveOverride:Ve}=or({hasMutators:D,hasShapes:v,rlsData:G}),E=[`import type { ${Y.join(", ")} } from "${l.do}";`,`import { applyCdcChanges, createStableIdFactory, ${H?"backfillSearchIndexes, ":""}${u?"backfillVectorIndexes, ":""}buildReprojectionMigration, ${X?"clearMemoryTables, ":""}${We}createReadFootprint, createShardCtxDb, exportShardRows, importShardRows, ${T?"isSourceDue, pullExternalSourceIncrementalTick, pullExternalSourceTick, ":""}markUnvouchableReads, ${Q?"ROOT_SHARD_NAME, ":""}runDataMigration, runShardMigrations, ${Z.importFragment}ShardDO as ShardDOBase } from "${l.do}";`,...T?[`import type { ExternalSourceLike, SourceClientLike, TraceRefLike } from "${l.do}";`]:[],v?`import { asBucketStorage, ${He}beginDeferredDeletes, beginDeferredSchedules, composeShapeReadWhere, createSecrets, flushDeferredDeletes, LunoraError, withDeferredDeletes, withDeferredSchedules } from "${l.server}";`:`import { asBucketStorage, beginDeferredDeletes, beginDeferredSchedules, createSecrets, flushDeferredDeletes, LunoraError, withDeferredDeletes, withDeferredSchedules } from "${l.server}";`];V&&E.push(`import { bindOrm, bindTableFacade } from "${l.server}";`),u&&E.push('import type { SchemaLike as VectorSchemaLike, VectorBackfillSync, VectorizeIndexLike, VectorSearchLike } from "@lunora/bindings/vectors";','import { createContextVectors, createVectorBackfillSync, createVectors, createVectorSyncHook, vectorBackfillTargets } from "@lunora/bindings/vectors";'),E.push(...b.importLines,...O.importLines,...$.importLines,...F.importLines,...pe,...fe,...se,...ce,...U.importLines,...ke,...De,"",'import schema from "../schema.js";',`import { ${["LUNORA_FUNCTIONS","LUNORA_LIFECYCLE_HOOKS","LUNORA_MIGRATIONS",...D?["LUNORA_MUTATOR_PATHS"]:[],...v?["LUNORA_SHAPES"]:[]].join(", ")} } from "./functions.js";`);const Ke=u?`
1119
+ `,re=g===void 0?"":", schemaSnapshot: LUNORA_SCHEMA_SNAPSHOT",b=At(n),O=Dt(m,l.flags),q=Ot(d,m,l.flags),$=Bt(f),F=Tt(o),{build:ae,contextField:ne,importLines:se,specs:oe}=Et(Vt(y)),{build:ie,contextField:de,importLines:ce,specs:le}=Ct(P,y),U=Lt(A,l.server),{build:he,contextField:ue,importLines:pe,specs:me}=It(t,i.jurisdiction),{build:ge,contextField:be,importLines:fe,specs:we}=_t(R),{build:ye,contextField:ve,importLines:ke,specs:Se}=Mt(e),{build:Re,configField:xe,contextField:Ae,imports:De,stub:Oe}=Pt(n.has("payments")),Te=a,Ee=r,G=L??{policies:[],roles:[]},Ce=w??{columns:[]},Le=_??{rules:[]},Ie=M??{analytics:!1,auth:!1,containers:!1,flags:!1,kv:!1,mail:!1,notifications:!1,payments:!1,queues:!1,scheduler:!1,storage:!1,vectors:!1,workflows:!1},{constant:_e,override:Me}=Nt(R),{constant:Pe,override:Ne}=qt(y),u=c&&i.vectorIndexes.length>0,B=new Set(i.tables.filter(s=>Kt(s)).map(s=>s.name)),Q=u&&i.vectorIndexes.some(s=>B.has(s.table)),x=i.tables.some(s=>s.shardMode==="global"),W=$t(B),j=i.tables.some(s=>Rt(s)),z=i.tables.some(s=>xt(s)),T=i.tables.some(s=>s.externalSource!==void 0),X=i.tables.some(s=>s.memory===!0),H=i.tables.some(s=>s.shardMode!=="global"&&s.searchIndexes.length>0);if(z&&j)throw new vt("INTERNAL",'lunora codegen: mixing `.global()` (D1) and `.global({ backend: "hyperdrive" })` tables in one app is not supported yet — use a single global backend.');const V=i.tables.length>0,qe=Zt(i),$e=tr(i),Fe=sr(i),Ue=er(i),J=rr(i),Y=Ft(u,R.length>0,y.length>0,m,H);v&&Y.push("WhereInput");const Z=Ut(x),{customMutatorOverride:Be,shapeGuardImport:We,shapeReadPolicyAssertion:je,shapeReadPolicyImport:He,shapeResolveOverride:Ve}=or({hasMutators:D,hasShapes:v,rlsData:G}),E=[`import type { ${Y.join(", ")} } from "${l.do}";`,`import { applyCdcChanges, createStableIdFactory, ${H?"backfillSearchIndexes, ":""}${u?"backfillVectorIndexes, ":""}buildReprojectionMigration, ${X?"clearMemoryTables, ":""}${We}createReadFootprint, createShardCtxDb, exportShardRows, importShardRows, ${T?"isSourceDue, pullExternalSourceIncrementalTick, pullExternalSourceTick, ":""}markUnvouchableReads, ${Q?"ROOT_SHARD_NAME, ":""}runDataMigration, runShardMigrations, ${Z.importFragment}ShardDO as ShardDOBase } from "${l.do}";`,...T?[`import type { ExternalSourceLike, SourceClientLike, TraceRefLike } from "${l.do}";`]:[],v?`import { asBucketStorage, ${He}beginDeferredDeletes, beginDeferredSchedules, composeShapeReadWhere, createSecrets, flushDeferredDeletes, LunoraError, withDeferredDeletes, withDeferredSchedules } from "${l.server}";`:`import { asBucketStorage, beginDeferredDeletes, beginDeferredSchedules, createSecrets, flushDeferredDeletes, LunoraError, withDeferredDeletes, withDeferredSchedules } from "${l.server}";`];V&&E.push(`import { bindOrm, bindTableFacade } from "${l.server}";`),u&&E.push('import type { SchemaLike as VectorSchemaLike, VectorBackfillSync, VectorizeIndexLike, VectorSearchLike } from "@lunora/bindings/vectors";','import { createContextVectors, createVectorBackfillSync, createVectors, createVectorSyncHook, vectorBackfillTargets } from "@lunora/bindings/vectors";'),E.push(...b.importLines,...O.importLines,...$.importLines,...F.importLines,...pe,...fe,...se,...ce,...U.importLines,...ke,...De,"",'import schema from "../schema.js";',`import { ${["LUNORA_FUNCTIONS","LUNORA_LIFECYCLE_HOOKS","LUNORA_MIGRATIONS",...D?["LUNORA_MUTATOR_PATHS"]:[],...v?["LUNORA_SHAPES"]:[]].join(", ")} } from "./functions.js";`);const Ke=u?`
1120
1120
  vectors?: (env: Record<string, unknown>) => Record<string, VectorizeIndexLike>;`:"",Ge=z?`
1121
1121
  d1?: (env: Record<string, unknown>, request?: { bookmark?: string; cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown>; onBookmark?: (bookmark: string | undefined) => void; userId?: string }) => DatabaseWriterLike | undefined;`:"",Qe=j?`
1122
1122
  hyperdriveGlobal?: (env: Record<string, unknown>, request?: { cdc?: boolean; cdcRetentionMs?: number; identity?: Record<string, unknown>; userId?: string }) => DatabaseWriterLike | undefined;`:"",ze=T?`
@@ -1234,7 +1234,7 @@ ${i.tables.map(s=>` facade[${JSON.stringify(s.name)}] = bindTableFaca
1234
1234
  `:"",gt=`${b.everyBuild}${O.build}${F.build}
1235
1235
  const secrets = createSecrets(env);
1236
1236
  `,bt=`${b.everyFields}${O.contextField}${$.contextField}${F.contextField}
1237
- secrets,`,ft=$.build,wt=[...b.actionFields,...A.length>0?["services"]:[]],yt=`${b.actionBuild}${U.build}`;return`${Vt}${E.join(`
1237
+ secrets,`,ft=$.build,wt=[...b.actionFields,...A.length>0?["services"]:[]],yt=`${b.actionBuild}${U.build}`;return`${jt}${E.join(`
1238
1238
  `)}
1239
1239
 
1240
1240
  type FunctionKind = "action" | "mutation" | "query";
@@ -1443,4 +1443,4 @@ ${H?`
1443
1443
  `:""}${et}
1444
1444
  ${zt({actionOnlyFields:wt,agentsBuild:ye,agentsContextField:ve,containersBuild:he,containersContextField:ue,databaseOptions:at,everyContextBuild:gt,everyContextField:bt,facadeBlock:mt,globalDatabaseLine:ot,notifyBuild:ft,ormContextField:st,paymentsBuild:Re,paymentsContextField:Ae,queuesBuild:ae,queuesContextField:ne,topicsBuild:ie,topicsContextField:de,vectorsBuild:tt,vectorsContextField:nt,workflowsBuild:ge,workflowsContextField:be,actionOnlyBuild:yt})}
1445
1445
  };
1446
- `};export{er as b,kr as e};
1446
+ `};export{er as b,Sr as e};
@@ -1,4 +1,4 @@
1
- import{s as N}from"./ir-DBSvhNa-.mjs";import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as R}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{a as l,G as g}from"./shared-DnCokNcE.mjs";const I=e=>e?{importFragment:"serveRelationFanout, ",override:`
1
+ import{r as b}from"./json-data-Chfs2Cz5.mjs";import{CAPABILITIES as N}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{a as l,G as g}from"./shared-DnCokNcE.mjs";import{s as R}from"./platform-8oj7iXQy.mjs";const I=e=>e?{importFragment:"serveRelationFanout, ",override:`
2
2
  protected override async runRelationFanoutRead(functionPath: string, args: Record<string, unknown>): Promise<unknown> {
3
3
  this.ensureMigrated();
4
4
 
@@ -148,7 +148,7 @@ ${m}]);
148
148
  ${m}const ${e}: ${a} = config.${e} ? ${o} : ${e}Stub;
149
149
  `,configField:`
150
150
  ${e}?: (env: Record<string, unknown>) => ${a};`,importLines:[`import type { ${a} } from "${r}";`],stub:u}}const c=n.bindingType??a,s=[...new Set([c,a])].toSorted((o,i)=>o.localeCompare(i));return{build:O(e,a,n),configField:`
151
- ${e}?: (env: Record<string, unknown>) => ${c};`,importLines:[`import type { ${s.join(", ")} } from "${r}";`,...n.factory===void 0?[]:[`import { ${n.factory.name} } from "${r}";`]],stub:u}},K=e=>{const r=[],t=[];let n="",a="",u="",c="",s="";for(const o of R.filter(({key:i})=>e.has(i))){let i;if(C(o))i=A[o.key]();else if(_(o))i=E(o.contextProperty,o.moduleSpecifier,o.shardBinding);else continue;const d=o.contextProperty;t.push(...i.importLines),a+=i.configField,s+=i.stub,o.tier==="every"?(u+=i.build,c+=`
151
+ ${e}?: (env: Record<string, unknown>) => ${c};`,importLines:[`import type { ${s.join(", ")} } from "${r}";`,...n.factory===void 0?[]:[`import { ${n.factory.name} } from "${r}";`]],stub:u}},K=e=>{const r=[],t=[];let n="",a="",u="",c="",s="";for(const o of N.filter(({key:i})=>e.has(i))){let i;if(C(o))i=A[o.key]();else if(_(o))i=E(o.contextProperty,o.moduleSpecifier,o.shardBinding);else continue;const d=o.contextProperty;t.push(...i.importLines),a+=i.configField,s+=i.stub,o.tier==="every"?(u+=i.build,c+=`
152
152
  ${d},`):(n+=i.build,r.push(d))}return{actionBuild:n,actionFields:r,configFields:a,everyBuild:u,everyFields:c,importLines:t,stubs:s}},G=(e,r)=>{if(e.length===0)return"";const t=r?`, ${JSON.stringify(r)}`:"",n=e.map(i=>{l(i.exportName,`container export "${i.exportName}"`),l(i.className,`container class "${i.className}"`);const d=i.sandbox===!0?"LunoraSandboxContainer":"LunoraContainer";return`/** Container DO for the \`${i.exportName}\` definition (binding \`${i.bindingName}\`). */
153
153
  export class ${i.className} extends ${d} {
154
154
  public constructor(ctx: ConstructorParameters<typeof ${d}>[0], env: Record<string, unknown>) {
@@ -280,7 +280,7 @@ ${r}
280
280
  const LUNORA_QUEUES: ReadonlyArray<QueueBindingSpec> = [
281
281
  ${r}
282
282
  ];
283
- `}},ee=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};const t=e.map(n=>{l(n.exportName,`topic export "${n.exportName}"`);const a=N(r,n.exportName).map(u=>`{ binding: "${u.bindingName}", exportName: "${u.exportName}" }`).join(", ");return` { exportName: "${n.exportName}", subscriptions: [${a}] },`}).join(`
283
+ `}},ee=(e,r)=>{if(e.length===0)return{build:"",contextField:"",importLines:[],specs:""};const t=e.map(n=>{l(n.exportName,`topic export "${n.exportName}"`);const a=R(r,n.exportName).map(u=>`{ binding: "${u.bindingName}", exportName: "${u.exportName}" }`).join(", ");return` { exportName: "${n.exportName}", subscriptions: [${a}] },`}).join(`
284
284
  `);return{build:`
285
285
  const topics = createTopicContext(env, LUNORA_TOPICS);
286
286
  `,contextField:`