@lunora/codegen 1.0.0-alpha.423 → 1.0.0-alpha.425
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.
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AGENTS_FILENAME-C4tHmiZZ.mjs → AGENTS_FILENAME-BSW65Q9R.mjs} +1 -1
- package/dist/packem_shared/{ALL_NOTIFY_CHANNELS-BgkkvuUe.mjs → ALL_NOTIFY_CHANNELS-DI0zmZGs.mjs} +1 -1
- package/dist/packem_shared/{CONTAINERS_FILENAME-d3XTFcqV.mjs → CONTAINERS_FILENAME-Dy3qWGfI.mjs} +1 -1
- package/dist/packem_shared/{ENV_FILENAME-DJ11PXN5.mjs → ENV_FILENAME-DFx_jlpa.mjs} +1 -1
- package/dist/packem_shared/{FLAGS_FILENAME-DeSjFBWq.mjs → FLAGS_FILENAME-CDaIBL6L.mjs} +1 -1
- package/dist/packem_shared/{MUTATORS_FILENAME-C0ZV0hh6.mjs → MUTATORS_FILENAME-SLAN2VXq.mjs} +1 -1
- package/dist/packem_shared/{OPENRPC_VERSION-BOBo0zdQ.mjs → OPENRPC_VERSION-DkWde9eh.mjs} +1 -1
- package/dist/packem_shared/{QUEUES_FILENAME-DbuJZnrY.mjs → QUEUES_FILENAME-CVkpGqoY.mjs} +1 -1
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-CdN_q7ja.mjs → SCHEMA_SNAPSHOT_FILENAME-DamKv-D7.mjs} +15 -15
- package/dist/packem_shared/{SHAPES_FILENAME-DTJKanSz.mjs → SHAPES_FILENAME-Cf4sum4C.mjs} +1 -1
- package/dist/packem_shared/{WORKFLOWS_FILENAME-7FysJsMZ.mjs → WORKFLOWS_FILENAME-Dtxo_XBw.mjs} +1 -1
- package/dist/packem_shared/attribution-B8xa6AeK.mjs +1 -0
- package/dist/packem_shared/{buildOpenApiDocument-DmV_PBFv.mjs → buildOpenApiDocument-C3zlve6K.mjs} +1 -1
- package/dist/packem_shared/{capabilitiesUsedBy-BNvoiCu1.mjs → capabilitiesUsedBy-BcDkRoOu.mjs} +1 -1
- package/dist/packem_shared/{classify-procedure-call-BmEirzc_.mjs → classify-procedure-call-BK_MMoue.mjs} +1 -1
- package/dist/packem_shared/{context-property-calls-BT1J7BqY.mjs → context-property-calls-As5I0QR6.mjs} +1 -1
- package/dist/packem_shared/context-root-CO8PbZi5.mjs +1 -0
- package/dist/packem_shared/{createCodegenProject-dC6oJh5H.mjs → createCodegenProject-C4XuJSap.mjs} +1 -1
- package/dist/packem_shared/{database-calls-d-Sssc-3.mjs → database-calls-Cug60vT9.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-CuqaLRa0.mjs → discoverAuthApiCalls-DcvsgL5u.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-BlL_VbIv.mjs → discoverCrons-MpIC14pg.mjs} +1 -1
- package/dist/packem_shared/discoverFunctions-CGwHnz_a.mjs +1 -0
- package/dist/packem_shared/{discoverHttpRoutes-CesuhqW1.mjs → discoverHttpRoutes-BtMgsfzG.mjs} +1 -1
- package/dist/packem_shared/discoverHyperdriveCalls-B--Nvx36.mjs +1 -0
- package/dist/packem_shared/{discoverInserts-DIarYU2P.mjs → discoverInserts-Dx7Lxey3.mjs} +1 -1
- package/dist/packem_shared/discoverMaskProcedures-Dj_hkZz2.mjs +1 -0
- package/dist/packem_shared/{discoverMigrations-C9AlZYFi.mjs → discoverMigrations-DaBdK1Bv.mjs} +1 -1
- package/dist/packem_shared/{discoverNondeterministicCalls-ZeZDQJAI.mjs → discoverNondeterministicCalls-MeKjo_UX.mjs} +1 -1
- package/dist/packem_shared/{discoverQueries-DLZHcDzB.mjs → discoverQueries-BlhMsXuk.mjs} +1 -1
- package/dist/packem_shared/discoverR2sqlCalls-DHvclvkv.mjs +1 -0
- package/dist/packem_shared/{discoverRlsMetadata-C0UkQkWd.mjs → discoverRlsMetadata-CO-pRHOx.mjs} +1 -1
- package/dist/packem_shared/{discoverRlsProcedures-BbSdCvmA.mjs → discoverRlsProcedures-CUfhUqfY.mjs} +1 -1
- package/dist/packem_shared/{discoverSandboxUsage-Dgvv6F_7.mjs → discoverSandboxUsage-CdrJNRFd.mjs} +1 -1
- package/dist/packem_shared/{discoverSchema-BLTROO8Z.mjs → discoverSchema-CL9PLdOu.mjs} +1 -1
- package/dist/packem_shared/{discoverStorageRulesMetadata-DeBgC7po.mjs → discoverStorageRulesMetadata-D_pYyr1i.mjs} +1 -1
- package/dist/packem_shared/{exported-procedure-chains-CfH5jrzD.mjs → exported-procedure-chains-ej9ozyZB.mjs} +1 -1
- package/dist/packem_shared/{fingerprintSchemaSources-TN-rU6Of.mjs → fingerprintSchemaSources-BqPD3mw0.mjs} +1 -1
- package/dist/packem_shared/{handler-reference-BkOkxxg8.mjs → handler-reference-_zhtPddp.mjs} +1 -1
- package/dist/packem_shared/{index-M4HwQ4Jr.mjs → index-BwLaIVqA.mjs} +1 -1
- package/dist/packem_shared/{index-CfSmiylg.mjs → index-CQuAXbal.mjs} +1 -1
- package/dist/packem_shared/ip-reads-D8rPYtZ6.mjs +1 -0
- package/dist/packem_shared/{isTestPath-Uwb5a6Kq.mjs → isTestPath-DJeZ18i9.mjs} +1 -1
- package/dist/packem_shared/{modules-DdOd-7Wp.mjs → modules-isOWiSYI.mjs} +1 -1
- package/dist/packem_shared/{policies-Dn_tuTZd.mjs → policies-CrNWTJQi.mjs} +1 -1
- package/dist/packem_shared/{unwrap-handler-return-DvbyiLjc.mjs → unwrap-handler-return-BnsKyz9W.mjs} +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/attribution-Cwt30DDJ.mjs +0 -1
- package/dist/packem_shared/context-root-BpDEhvNE.mjs +0 -1
- package/dist/packem_shared/discoverFunctions-CGrAezsY.mjs +0 -1
- package/dist/packem_shared/discoverHyperdriveCalls-BmAoOGGq.mjs +0 -1
- package/dist/packem_shared/discoverMaskProcedures-jkRrWS86.mjs +0 -1
- package/dist/packem_shared/discoverR2sqlCalls-D_HWbbky.mjs +0 -1
- package/dist/packem_shared/ip-reads-By7tJdyu.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as d}from"node:fs";import{join as l}from"node:path";import{SyntaxKind as m,Node as n}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as u}from"./module-specifiers-BctA0m_p.mjs";import{p as h}from"./parse-validator-BisfC8bR.mjs";import{declarationLineOf as x,findObjectProperty as c}from"./isTestPath-
|
|
1
|
+
import{existsSync as d}from"node:fs";import{join as l}from"node:path";import{SyntaxKind as m,Node as n}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as u}from"./module-specifiers-BctA0m_p.mjs";import{p as h}from"./parse-validator-BisfC8bR.mjs";import{declarationLineOf as x,findObjectProperty as c}from"./isTestPath-DJeZ18i9.mjs";import{a as S}from"./attribution-B8xa6AeK.mjs";import{m as f}from"./ip-reads-D8rPYtZ6.mjs";const b="shapes.ts",y=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineShape";for(const e of t.getDeclarations())if(n.isImportSpecifier(e))return u(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineShape":!1;return!1},I=r=>{const t=r.getSymbol();if(!t)return!1;for(const e of t.getDeclarations()){if(!n.isNamespaceImport(e))continue;const i=e.getFirstAncestorByKind(m.ImportDeclaration);return i!==void 0&&u(i.getModuleSpecifierValue())}return!1},N=r=>{if(n.isIdentifier(r))return y(r);if(n.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineShape"&&n.isIdentifier(t)&&I(t)}return!1},A=r=>{const[t]=r.getArguments();if(!t||!n.isObjectLiteralExpression(t))return;const e=c(t,"table");if(!e||!n.isPropertyAssignment(e))return;const i=e.getInitializer();return i&&n.isStringLiteral(i)?i.getLiteralValue():void 0},E=r=>{const[t]=r.getArguments();if(!t||!n.isObjectLiteralExpression(t))return{};const e=c(t,"args");if(!e||!n.isPropertyAssignment(e))return{};const i=e.getInitializer();return!i||!n.isObjectLiteralExpression(i)?{}:h(i)},P=r=>{const[t]=r.getArguments(),e=n.isObjectLiteralExpression(t)?c(t,"where"):void 0,i=n.isPropertyAssignment(e)?e.getInitializer():void 0;if(e===void 0)return f(r);if(!n.isArrowFunction(i)&&!n.isFunctionExpression(i))return!0;const o=i.getParameters()[0]?.getNameNode();return n.isIdentifier(o)&&o.getText()!=="ctx"&&o.findReferencesAsNodes().length>0||f(r)},v=r=>{const t=[];for(const e of r.getVariableDeclarations()){const i=e.getInitializer();if(i?.getKind()!==m.CallExpression)continue;const o=i,s=o.getExpression();if(!N(s))continue;const a=e.getNameNode();if(!n.isIdentifier(a)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw g(a,"defineShape exports must be plain named exports (no destructuring)")}const p=S(e,"binding");p!==void 0&&t.push({args:E(o),exportName:p,filePath:"shapes",line:x(e),...P(o)?{readsIp:!0}:{},table:A(o)})}return t},K=(r,t)=>{const e=l(t,b);if(!d(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),o=v(i);return o.sort((s,a)=>s.exportName.localeCompare(a.exportName)),o};export{b as SHAPES_FILENAME,K as discoverShapes};
|
package/dist/packem_shared/{WORKFLOWS_FILENAME-7FysJsMZ.mjs → WORKFLOWS_FILENAME-Dtxo_XBw.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as b}from"node:fs";import{join as k}from"node:path";import{LunoraError as w}from"@lunora/errors";import y from"@lunora/scheduler/validate";import{workflowDefaultName as E,workflowClassName as v}from"@lunora/workflow";import{Node as n,VariableDeclarationKind as S,SyntaxKind as P}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as x,declarationLineOf as L,lunoraRelativePath as N,findObjectProperty as d,stringPropertyFor as $}from"./isTestPath-
|
|
1
|
+
import{existsSync as b}from"node:fs";import{join as k}from"node:path";import{LunoraError as w}from"@lunora/errors";import y from"@lunora/scheduler/validate";import{workflowDefaultName as E,workflowClassName as v}from"@lunora/workflow";import{Node as n,VariableDeclarationKind as S,SyntaxKind as P}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as x,declarationLineOf as L,lunoraRelativePath as N,findObjectProperty as d,stringPropertyFor as $}from"./isTestPath-DJeZ18i9.mjs";import{a as A}from"./attribution-B8xa6AeK.mjs";import{r as O}from"./handler-reference-_zhtPddp.mjs";const W="workflows.ts",C=new Set(["do","sleep","sleepUntil","waitForEvent"]),F=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=$("workflow"),I=(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(!y(r))throw c(t,`workflow "${e}": schedule "${r}" is not a valid cron expression`);return r})},R=(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=I(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},T=o=>{const e=o.getExpression();if(!n.isPropertyAccessExpression(e)||!C.has(e.getName()))return!1;const t=e.getExpression();return n.isPropertyAccessExpression(t)&&t.getName()==="step"?!0:n.isIdentifier(t)&&t.getText()==="step"},j=o=>{if(!o)return[];const e=[];for(const t of o.getDescendantsOfKind(P.CallExpression)){if(!T(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},K=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}},V=(o,e)=>{const t=d(o,"handler"),r=O(t,e);return r!==void 0?r:{body:t!==void 0&&n.isPropertyAssignment(t)?t.getInitializer():t}},z=(o,e,t)=>{const r=K(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=V(r,t),a={className:v(e),exportName:e,file:N(t,o.getSourceFile().getFilePath()),line:L(o),name:E(e),steps:j(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,...R(r,e)}},M=(o,e)=>{const t=[];for(const r of o.getVariableDeclarations()){const s=x(r.getInitializer());if(!s)continue;const a=s.getExpression();if(!n.isIdentifier(a)||!F(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=A(r,"binding");l!==void 0&&t.push(z(s,l,e))}return t},_=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)}},ee=(o,e)=>{const t=k(e,W);if(!b(t))return[];const r=o.getSourceFile(t)??o.addSourceFileAtPath(t),s=M(r,e);return s.sort((a,i)=>a.exportName.localeCompare(i.exportName)),_(s),s};export{W as WORKFLOWS_FILENAME,ee as discoverWorkflows};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{callSiteCallers as b,byCodepoint as k}from"@lunora/advisor";import{Node as n,SyntaxKind as p,VariableDeclarationKind as O,ts as F}from"ts-morph";import{i as T}from"./reserved-words-CW1QFbTd.mjs";import{isWriteTarget as M,descendantsOfKind as V,unwrapExpression as P}from"./isTestPath-DJeZ18i9.mjs";const N=new WeakMap,A=e=>e.getStatements().flatMap(t=>n.isFunctionDeclaration(t)?[t]:n.isVariableStatement(t)?t.getDeclarations().filter(o=>n.isIdentifier(o.getNameNode())):[]),x=e=>n.isStringLiteral(e)?e.getLiteralValue():e.getText(),C=e=>{if(n.isFunctionDeclaration(e)||n.isClassDeclaration(e)){const t=e.getName();return e.hasExportKeyword()?[[t??"default",e.hasDefaultKeyword()?"default":t??"default"]]:[]}return!n.isVariableStatement(e)||!e.hasExportKeyword()?[]:e.getDeclarations().flatMap(t=>{const o=t.getNameNode();return n.isIdentifier(o)?[[o.getText(),o.getText()]]:o.getDescendantsOfKind(p.BindingElement).flatMap(r=>n.isIdentifier(r.getNameNode())?[[r.getName(),r.getName()]]:[])})},I=e=>{if(n.isExportDeclaration(e))return e.hasModuleSpecifier()||e.isTypeOnly()?[]:e.getNamedExports().filter(o=>!o.isTypeOnly()).map(o=>{const r=x(o.getNameNode()),s=o.getAliasNode();return[r,s===void 0?r:x(s)]});const t=n.isExportAssignment(e)&&!e.isExportEquals()?e.getExpression():void 0;return n.isIdentifier(t)?[[t.getText(),"default"]]:C(e)},h=new WeakMap,K=e=>{const t=h.get(e.compilerNode);if(t!==void 0)return t;const o=new Map;for(const[s,i]of e.getStatements().flatMap(c=>I(c)))o.set(s,(o.get(s)??new Set).add(i));const r=new Map([...o].map(([s,i])=>[s,[...i].toSorted(Z)]));return h.set(e.compilerNode,r),r},g=e=>{const t=n.isBindingElement(e)?e.getFirstAncestorByKind(p.VariableStatement):void 0,o=n.isVariableDeclaration(e)?e.getVariableStatement():void 0,r=n.isFunctionDeclaration(e)?e:t??o;if(r===void 0||!n.isSourceFile(r.getParent()))return[];const s=n.isFunctionDeclaration(e)?e.getName()??"default":e.getName();return K(e.getSourceFile()).get(s)??[]},L=e=>new Map(e.flatMap(t=>{const o=g(t);return o.length===0?[]:[[t.compilerNode,o]]})),B=e=>{const t=P(e);return t!==void 0&&(n.isArrowFunction(t)||n.isFunctionExpression(t))},y=(e,t)=>{for(const o of e.getAncestors()){if(n.isExportAssignment(o)&&!o.isExportEquals())return{kind:"export",name:"default"};if((n.isFunctionDeclaration(o)&&n.isSourceFile(o.getParent())||n.isVariableDeclaration(o)&&n.isSourceFile(o.getVariableStatement()?.getParent())&&n.isIdentifier(o.getNameNode()))&&(n.isFunctionDeclaration(o)||n.isVariableDeclaration(o))){const s=t.get(o.compilerNode)?.[0];return s!==void 0?{kind:"export",name:s}:n.isFunctionDeclaration(o)||B(o.getInitializer())?{declaration:o,kind:"helper"}:{kind:"untracked"}}}return{kind:"untracked"}},E=e=>{for(const t of e.getAncestors()){if(n.isExpressionWithTypeArguments(t)){const o=t.getParent();return!(n.isHeritageClause(o)&&o.getToken()===p.ExtendsKeyword&&(n.isClassDeclaration(o.getParent())||n.isClassExpression(o.getParent())))}if(F.isTypeNode(t.compilerNode))return!0}return!1},te=e=>{const t=e.getParent(),o=n.isPropertyAccessExpression(t)&&t.getNameNode()===e,r=(n.isPropertyAssignment(t)||n.isMethodDeclaration(t))&&t.getNameNode()===e;return!o&&!r&&!E(e)},v=e=>{const t=e.getParent();return n.isShorthandPropertyAssignment(t)&&t.getNameNode()===e?t.getValueSymbol():e.getSymbol()},R=e=>{const t=v(e);return t?.getValueDeclaration()??t?.getDeclarations()[0]},S=new WeakMap,$=/\/typescript\/lib\/lib\.[^/]+\.d\.ts$/u,_=e=>{const t=e.getFilePath();return e.isDeclarationFile()&&($.test(t)||t.includes("/@types/node/"))},W=e=>{let t=e;for(;n.isBindingElement(t);)t=t.getParentOrThrow().getParentOrThrow();const o=n.isVariableDeclaration(t)?t.getParent():void 0;return n.isVariableDeclarationList(o)?o:void 0},oe=e=>{const t=e.getNameNode();if(!n.isIdentifier(t)||W(e)?.getDeclarationKind()===O.Const||_(e.getSourceFile()))return!1;let o=S.get(e.compilerNode);if(o===void 0){const r=n.isFunctionDeclaration(e)?e.getSourceFile():e.getFirstAncestor(i=>n.isFunctionLikeDeclaration(i)||n.isArrowFunction(i))??e.getSourceFile(),s=t.getText();o=r.getDescendantsOfKind(p.Identifier).some(i=>i!==t&&i.getText()===s&&M(i)&&R(i)?.compilerNode===e.compilerNode),S.set(e.compilerNode,o)}return o},z=e=>{const t=new Map,o=new Set,r=new Set;for(const s of e){const i=s.getNameNode(),c=i?.getSymbol()?.compilerSymbol;i!==void 0&&c!==void 0&&(t.set(c,s.compilerNode),o.add(i.compilerNode),r.add(i.getText()))}return{bySymbol:t,nameNodes:o,spellings:r}},H=(e,t,o)=>{const{bySymbol:r,nameNodes:s,spellings:i}=z(t),c=new Map;for(const a of V(e,p.Identifier)){if(!i.has(a.getText())||s.has(a.compilerNode)||E(a))continue;const l=v(a)?.compilerSymbol,d=l===void 0?void 0:r.get(l);d!==void 0&&c.set(d,[...c.get(d)??[],y(a,o)])}return c},q=(e,t)=>{const o=new Map(e.map(a=>[a.compilerNode,new Set])),r=new Set,s=a=>(o.get(a)?.size??0)+(r.has(a)?1:0),i=(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&&r.has(m))&&r.add(a),s(a)!==d};let c=!0;for(;c;){c=!1;for(const[a,l]of t)for(const d of l)c=i(a,d)||c}return new Map([...o].map(([a,l])=>[a,{callers:[...l].toSorted((d,u)=>d.localeCompare(u)),untracked:r.has(a)}]))},X=e=>{const t=N.get(e.compilerNode);if(t!==void 0)return t;const o=A(e),r=L(o),s=o.filter(c=>!r.has(c.compilerNode)),i={exportNames:r,helperReach:s.length===0?new Map:q(s,H(e,s,r))};return N.set(e.compilerNode,i),i},re=e=>{const t=X(e.getSourceFile()),o=y(e,t.exportNames);switch(o.kind){case"export":return{kind:"export",name:o.name};case"helper":{const r=o.declaration.getName(),s=t.helperReach.get(o.declaration.compilerNode);if(r===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:r,...s.untracked?{untracked:!0}:{}}}default:return{kind:"module"}}},j=e=>{if(e.kind==="helper"&&e.untracked===!0)return;const t=b(e);return t.length===0?void 0:t},G=(e,t)=>{const o=new Set(b(e).map(r=>t(r)));return o.has("public")?"public":j(e)===void 0||o.has(void 0)?void 0:"internal"},ne=(e,t)=>{const o=new Map(t.map(r=>[`${r.filePath}:${r.exportName}`,r.visibility]));return e.map(r=>{const s=G(r.scope,i=>o.get(`${r.file}:${i}`));return s===void 0?r:{...r,visibility:s}})},f=/^[$A-Z_a-z][\w$]*$/u,D=e=>f.test(e),Y=e=>{const t=g(e);return t.length===0?n.isVariableDeclaration(e)&&e.getVariableStatement()?.hasExportKeyword()===!0?e.getName():void 0:t.find(o=>D(o))??e.getName()},se=e=>e.getVariableStatements().flatMap(t=>t.getDeclarations()).filter(t=>Y(t)!==void 0),ie=(e,t)=>{if(n.isIdentifier(e.getNameNode()))return e.getVariableStatement()?.hasExportKeyword()===!0?e.getName():g(e).find(o=>t==="binding"?T(o):D(o))},Z=(e,t)=>Number(f.test(t))-Number(f.test(e))||k(e,t);export{ie as a,oe as b,re as c,R as d,K as e,te as f,g,Y as h,D as i,se as j,E as k,_ as l,j as m,v as r,ne as w};
|
package/dist/packem_shared/{buildOpenApiDocument-DmV_PBFv.mjs → buildOpenApiDocument-C3zlve6K.mjs}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{m as b}from"./modules-
|
|
1
|
+
import{m as b}from"./modules-isOWiSYI.mjs";import{r as E}from"./json-data-Chfs2Cz5.mjs";import{LUNORA_ERROR_CODES as P,objectSchema as g,validatorIrToJsonSchema as l}from"./LUNORA_ERROR_CODES-D7AVT7qF.mjs";import{G as A}from"./shared-Cn7dMQ_u.mjs";import{s as m}from"./dispatch-namespace-DwTjD7BU.mjs";const T="/_lunora/rest",x=["authorization","cf-access-jwt-assertion","cookie","payment-signature","x-payment"],v=["x-d1-bookmark","x-lunora-shard-key"],j=e=>[...x,...(e.credentialHeaders??[]).map(t=>t.toLowerCase())],O=e=>Number.isFinite(e)?Math.max(0,Math.floor(e)):0,$=(...e)=>{const t=[];for(const r of e)for(const n of r?.split(",")??[]){const s=n.trim().toLowerCase();s!==""&&!t.includes(s)&&t.push(s)}return t.length===0?void 0:t.join(", ")},k=(e,t)=>{const r=[t,`max-age=${String(O(e.maxAge))}`];return e.staleWhileRevalidate!==void 0&&r.push(`stale-while-revalidate=${String(O(e.staleWhileRevalidate))}`),r.join(", ")},N=e=>e.scope==="public"?$(e.vary,...j(e),...v):$(e.vary,...v),q=e=>{const t=e.indexOf(":");if(!(t<=0||t>=e.length-1||e.indexOf(":",t+1)!==-1))return{name:e.slice(t+1),namespace:e.slice(0,t)}},_=e=>{const t=q(e);if(t!==void 0)return`${T}/${t.namespace}/${t.name}`},C=e=>e==="query"?"GET":"POST",y="#/components/responses/LunoraError",R=/:([A-Za-z_$][\w$]*)/gu,w=e=>[...e.matchAll(R)].map(t=>t[1]),D=e=>e.replaceAll(R,"{$1}"),f=e=>e.kind==="optional"?e.inner??e:e,I=e=>{const t=new Set(w(e.path)),r=[];for(const[n,s]of Object.entries(e.searchParams)){const c=f(s);r.push({description:`Query parameter \`${n}\``,in:"query",name:n,required:s.kind!=="optional",schema:l(c)})}for(const[n,s]of Object.entries(e.params)){const c=f(s);r.push({description:`Path parameter \`${n}\``,in:t.has(n)?"path":"query",name:n,required:t.has(n)?!0:s.kind!=="optional",schema:l(c)})}return r},S=e=>e?{content:{"application/json":{schema:l(e)}},description:"Successful response."}:{content:{"application/json":{schema:{description:"Return shape is TS-inferred (no `.output()` declared); best-effort — any JSON."}}},description:"Successful response. The return shape is TypeScript-inferred and not declared via `.output()`, so it is documented best-effort."},L=(e,t)=>{const r=I(e),n={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${m(e.path)}`,responses:{200:S(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:y}},summary:`${e.method} ${e.path}`,tags:[t]};return r.length>0&&(n.parameters=r),Object.keys(e.body).length>0&&(n.requestBody={content:{"application/json":{schema:g(e.body)}},required:!0}),e.stream&&(n["x-lunora-stream"]="text/event-stream"),n},F=(e,t)=>{const r=`${m(e.filePath)}:${e.exportName}`,n={additionalProperties:!1,properties:{args:g(e.args),functionPath:{const:r,type:"string"},shardKey:{description:"Optional shard key; omitted routes to the default shard.",type:"string"}},required:["functionPath"],type:"object"};return{operation:{description:`Invoke the \`${e.kind}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc).`,operationId:r,requestBody:{content:{"application/json":{schema:n}},required:!0},responses:{200:S(e.output),default:{$ref:y}},summary:`${e.kind}: ${r}`,tags:[t],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${r}`}},H=(e,t)=>{if(e===void 0||t!=="get"||e.scope===void 0||e.maxAge===void 0)return{};const r={maxAge:e.maxAge,scope:e.scope,...e.staleWhileRevalidate===void 0?{}:{staleWhileRevalidate:e.staleWhileRevalidate},...e.tag===void 0?{}:{tag:e.tag},...e.vary===void 0?{}:{vary:e.vary}},n={"Cache-Control":{description:r.scope==="public"?"Caching policy. `public` applies only to an uncredentialed request — a request carrying `Authorization` or `Cookie` is always answered `private`.":"Caching policy. Restricted to the caller's own cache; never stored by a shared/edge cache.",schema:{example:k(r,r.scope),type:"string"}}};r.tag!==void 0&&(n["Cache-Tag"]={description:"Purge tag for `ctx.cache.purge({ tags: [...] })`.",schema:{example:r.tag,type:"string"}});const s=N(r);return s!==void 0&&(n.Vary={description:"Request headers this response varies by. The endpoint's own negotiated headers are merged in at runtime.",schema:{example:s,type:"string"}}),{headers:n}},M=(e,t)=>{const r=`${m(e.filePath)}:${e.exportName}`,n=_(r);if(n===void 0)return;const s=C(e.kind),c=s==="GET",i={description:`Public REST endpoint for the \`${e.kind}\` \`${r}\` (opt-in via \`.expose({ rest: true })\`). Routed through the procedure, so auth / RLS / validators are enforced.`,operationId:`rest_${m(n)}`,responses:{200:{content:{"application/json":{schema:{description:"Procedure result. The shape is TS-inferred from the return type; best-effort — any JSON."}}},description:"Successful result (TypeScript-inferred return shape, documented best-effort).",...H(e.expose?.cache,c?"get":"post")},default:{$ref:y}},summary:`${s} ${n}`,tags:[t],"x-lunora-function-kind":e.kind};if(c){const d=Object.entries(e.args).map(([u,h])=>{const o=f(h);return{description:`Argument \`${u}\` (JSON-encoded for non-string values).`,in:"query",name:u,required:h.kind!=="optional",schema:l(o)}});return d.length>0&&(i.parameters=d),{method:"get",operation:i,path:n}}return i.requestBody={content:{"application/json":{schema:g(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:i,path:n}},J=e=>{const t=e.version??"0.0.0",r=Object.create(null),n=o=>r[o]??Object.create(null),s=new Set,c=e.modules??[],i=o=>b(c,o);for(const o of e.httpRoutes){const a=D(o.path),p=n(a);p[o.method.toLowerCase()]=L(o,i(o.filePath)),r[a]=p,s.add(i(o.filePath))}const d=e.functions.filter(o=>o.visibility!=="internal"&&o.kind!=="stream");for(const o of d){const{operation:a,pathKey:p}=F(o,i(o.filePath));r[p]={post:a},s.add(i(o.filePath))}for(const o of d){if(o.expose?.rest!==!0)continue;const a=M(o,i(o.filePath));if(a===void 0)continue;const p=n(a.path);p[a.method]=a.operation,r[a.path]=p}const u=[...s].toSorted((o,a)=>o.localeCompare(a)).map(o=>({description:c.find(p=>p.name===o)?.description??`Operations declared in \`lunora/${o}\`.`,name:o}));return{components:{responses:{LunoraError:{content:{"application/json":{schema:{additionalProperties:!1,description:"Standard Lunora error envelope.",properties:{error:{additionalProperties:!1,properties:{code:{description:"Machine-readable error code. Clients switch on this value.",enum:P,type:"string"},message:{description:"Human-readable error message (never echoes internal details).",type:"string"}},required:["code","message"],type:"object"}},required:["error"],type:"object"}}},description:"A Lunora error response. The HTTP status reflects the error code (e.g. BAD_REQUEST→400, UNAUTHORIZED→401, FORBIDDEN→403, NOT_FOUND→404)."}}},info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora API",version:t},openapi:"3.1.0",paths:Object.fromEntries(Object.entries(r).map(([o,a])=>[o,{...a}])),tags:u}},z=e=>`${JSON.stringify(J(e),void 0,2)}
|
|
2
2
|
`,K=e=>`${A}export const openApiSpec = ${E(e,"Record<string, unknown>")};
|
|
3
3
|
`;export{J as buildOpenApiDocument,z as emitOpenApi,K as emitOpenApiModule};
|
package/dist/packem_shared/{capabilitiesUsedBy-BNvoiCu1.mjs → capabilitiesUsedBy-BcDkRoOu.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SyntaxKind as g,Node as m,ts as D,Project as M}from"ts-morph";import{CAPABILITIES as u}from"./CAPABILITY_PROBES-DCzOjTN7.mjs";import{descendantsOfKind as l,bindingKeyName as v,listLunoraSourceFiles as P}from"./isTestPath-
|
|
1
|
+
import{SyntaxKind as g,Node as m,ts as D,Project as M}from"ts-morph";import{CAPABILITIES as u}from"./CAPABILITY_PROBES-DCzOjTN7.mjs";import{descendantsOfKind as l,bindingKeyName as v,listLunoraSourceFiles as P}from"./isTestPath-DJeZ18i9.mjs";import{scanImportDeclaration as A,noSandboxUsage as I}from"./discoverSandboxUsage-CdrJNRFd.mjs";const f="ctx",L=(e,t,s)=>{for(const o of l(e,g.ElementAccessExpression)){const r=o.getArgumentExpression();t(o.getExpression())&&r!==void 0&&(m.isStringLiteral(r)||m.isNoSubstitutionTemplateLiteral(r))&&s.add(r.getLiteralValue())}},C=e=>{const t=new Set,s=new Set,o=new Set(l(e,g.Parameter).map(n=>n.getName())),r=l(e,g.VariableDeclaration).some(n=>{const c=n.getInitializer();return n.getName()===f&&m.isIdentifier(c)&&o.has(c.getText())});(o.has(f)||r)&&s.add(f);const i=n=>{if(m.isObjectBindingPattern(n))for(const c of n.getElements()){const d=v(c);d&&t.add(d)}};for(const n of l(e,g.BindingElement)){if(v(n)!==f)continue;const c=n.getNameNode();m.isIdentifier(c)?s.add(c.getText()):i(c)}const a=n=>m.isIdentifier(n)&&s.has(n.getText());for(const n of l(e,g.PropertyAccessExpression))a(n.getExpression())&&t.add(n.getName());L(e,a,t);for(const n of l(e,g.VariableDeclaration)){const c=n.getInitializer();c!==void 0&&a(c)&&i(n.getNameNode())}return t},V=e=>{if(e.isTypeOnly())return!0;if(m.isExportDeclaration(e)){const s=e.getNamedExports();return!e.isNamespaceExport()&&s.length>0&&s.every(o=>o.isTypeOnly())}const t=e.getNamedImports();return e.getDefaultImport()===void 0&&e.getNamespaceImport()===void 0&&t.length>0&&t.every(s=>s.isTypeOnly())},z=new Map(u.flatMap(({bindingFreeExports:e,moduleSpecifier:t})=>e===void 0?[]:[[t,new Set(e)]])),F=(e,t)=>{const s=z.get(t);if(s===void 0||m.isImportDeclaration(e)&&(e.getDefaultImport()!==void 0||e.getNamespaceImport()!==void 0))return!1;const o=m.isExportDeclaration(e)?e.getNamedExports():e.getNamedImports();return o.length>0&&o.every(r=>r.isTypeOnly()||s.has(r.getName()))},_=e=>{const t=new Set;for(const s of l(e,g.CallExpression)){const[o]=s.getArguments();s.getExpression().getKind()===g.ImportKeyword&&(m.isStringLiteral(o)||m.isNoSubstitutionTemplateLiteral(o))&&t.add(o.getLiteralValue())}return t},T="@lunora/agent",E="requestSecretTool",b=e=>e.startsWith("./")||e.startsWith("../"),S=e=>e.getAliasNode()?.getText()??e.getNameNode().getText(),h=(e,t)=>{const s=e!==void 0&&m.isCallExpression(e)?e.getExpression():e;return s!==void 0&&m.isIdentifier(s)&&t.has(s.getText())},k=e=>{const t=new Set;for(const s of e.getImportDeclarations())if(!(s.getModuleSpecifierValue()!==T||s.isTypeOnly()))for(const o of s.getNamedImports())!o.isTypeOnly()&&o.getNameNode().getText()===E&&t.add(S(o));for(const s of e.getVariableStatements())for(const o of s.getDeclarations())h(o.getInitializer(),t)&&t.add(o.getName());return t},p=e=>({names:new Set(e),namespaces:new Map}),x=new WeakMap,y=()=>{const e=Object.freeze({});return x.set(e,{projects:new Map,origins:new Map}),e},B=(e,t)=>{const s=x.get(e);if(s.origins.has(t))return t;let o=s.projects.get(t);return o===void 0&&(o=new M({compilerOptions:{...t.getCompilerOptions(),allowJs:!0},fileSystem:t.getFileSystem(),skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0,skipLoadingLibFiles:!0}),s.projects.set(t,o),s.origins.set(o,t)),o},O=(e,t,s)=>{const o=t.getSourceFile(),r=o.getProject(),i=x.get(e)?.origins.get(r)??r,{resolvedModule:a}=D.resolveModuleName(s,o.getFilePath(),i.getCompilerOptions(),i.getModuleResolutionHost()),n=a?.resolvedFileName;if(n===void 0)return;const c=i.getSourceFile(n)??r.getSourceFile(n);if(c!==void 0)return c;const d=B(e,r);return d.getSourceFile(n)??d.addSourceFileAtPath(n)},K=(e,t,s)=>{const o=e.getNamespaceExport();if(o!==void 0){const r=new Set(t.names);t.namespaces.forEach((i,a)=>{i.forEach(n=>{r.add(`${a}.${n}`)})}),r.size>0&&s.namespaces.set(o.getName(),r);return}if(!e.hasNamedExports()){t.names.forEach(r=>s.names.add(r)),t.namespaces.forEach((r,i)=>s.namespaces.set(i,r));return}for(const r of e.getNamedExports()){if(r.isTypeOnly())continue;const i=r.getNameNode().getText(),a=S(r);t.names.has(i)&&s.names.add(a);const n=t.namespaces.get(i);n!==void 0&&s.namespaces.set(a,n)}},W=(e,t,s,o)=>{const r=t.getModuleSpecifierValue();if(r===void 0)return p(s);if(r===T)return p([E]);const i=b(r)?O(e,t,r):void 0;return i===void 0?p([]):o(i)},w=(e,t,s)=>{const o=p([]),r=e.getFilePath();if(t.has(r))return o;t.add(r);const i=k(e);for(const a of e.getExportDeclarations())a.isTypeOnly()||K(a,W(s,a,i,n=>w(n,t,s)),o);for(const a of e.getVariableStatements())if(a.hasExportKeyword())for(const n of a.getDeclarations())h(n.getInitializer(),i)&&o.names.add(n.getName());return t.delete(r),o},j=(e,t,s)=>{const o=e.getModuleSpecifierValue();if(o===T)return p([E]);const r=b(o)?O(s,e,o):void 0;return r===void 0?p([]):w(r,new Set([t.getFilePath()]),s)},$=e=>{const t=e.getPropertyNameNode();return t===void 0?e.getName():m.isStringLiteral(t)?t.getLiteralValue():t.getText()},N=(e,t,s)=>{const o=(n,c)=>n===t?s.has(c):n.startsWith(`${t}.`)&&s.has(`${n.slice(t.length+1)}.${c}`),r=e.getDescendantsOfKind(g.PropertyAccessExpression).some(n=>o(n.getExpression().getText(),n.getName())),i=l(e,g.ElementAccessExpression).some(n=>{const c=n.getArgumentExpression();return m.isStringLiteral(c)&&o(n.getExpression().getText(),c.getLiteralValue())}),a=l(e,g.VariableDeclaration).some(n=>{const c=n.getInitializer(),d=n.getNameNode();return c!==void 0&&m.isObjectBindingPattern(d)&&d.getElements().some(R=>o(c.getText(),$(R)))});return r||i||a},q=(e,t,s)=>{if(s.names.has(t.getNameNode().getText()))return!0;const o=s.namespaces.get(t.getNameNode().getText());return o!==void 0&&N(e,S(t),o)},U=(e,t=y())=>e.getImportDeclarations().some(s=>{if(s.isTypeOnly())return!1;const o=j(s,e,t);if(o.names.size===0&&o.namespaces.size===0)return!1;const r=s.getDefaultImport(),i=s.getNamespaceImport();return r!==void 0&&(o.names.has("default")||N(e,r.getText(),o.namespaces.get("default")??new Set))||s.getNamedImports().some(n=>!n.isTypeOnly()&&q(e,n,o))||i!==void 0&&N(e,i.getText(),o.names)}),X=(e,t=y())=>{const s=e.getImportDeclarations(),o=I();for(const r of s){const i=A(r);for(const a of Object.keys(o))o[a]||=i[a]}return{contextReads:C(e),dynamicImports:_(e),requestSecretTool:U(e,t),sandboxTools:o,valueImports:new Set([...s,...e.getExportDeclarations()].flatMap(r=>{const i=r.getModuleSpecifierValue();return i===void 0||V(r)||F(r,i)?[]:[i]}))}},G=e=>{const t=new Set,s=new Set,o=I(),r=new Set;let i=!1;for(const a of e){i||=a.requestSecretTool;for(const n of a.contextReads)t.add(n);for(const n of a.dynamicImports)s.add(n);for(const n of a.valueImports)r.add(n);for(const n of Object.keys(o))o[n]||=a.sandboxTools[n]}return{contextReads:t,dynamicImports:s,requestSecretTool:i,sandboxTools:o,valueImports:r}},H=e=>new Set(u.filter(({contextProperty:t,moduleSpecifier:s})=>e.valueImports.has(s)||t!==void 0&&e.contextReads.has(t)).map(({key:t})=>t)),J=new RegExp(String.raw`\b${f}\b`,"u"),Q=new RegExp(String.raw`\b(?:${u.flatMap(({contextProperty:e})=>e===void 0?[]:[e]).join("|")})\b`,"u"),se=e=>J.test(e)&&Q.test(e),oe=(e,t)=>{const s=y(),o=G(P(t).map(i=>X(e.getSourceFile(i)??e.addSourceFileAtPath(i),s))),r=H(o);return Object.fromEntries(u.map(({key:i})=>[i,r.has(i)]))};export{H as capabilitiesUsedBy,C as contextPropertiesRead,y as createTargetScope,oe as discoverFeatureUsage,U as fileWiresRequestSecretTool,G as foldCapabilitySignals,se as mayReadCapabilityContext,X as sourceCapabilitySignals};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as o,VariableDeclarationKind as b,SyntaxKind as h}from"ts-morph";import{a as y,b as l}from"./module-specifiers-BctA0m_p.mjs";import{unwrapExpression as c,symbolConstInitializer as F,isConstDeclaration as z}from"./isTestPath-
|
|
1
|
+
import{Node as o,VariableDeclarationKind as b,SyntaxKind as h}from"ts-morph";import{a as y,b as l}from"./module-specifiers-BctA0m_p.mjs";import{unwrapExpression as c,symbolConstInitializer as F,isConstDeclaration as z}from"./isTestPath-DJeZ18i9.mjs";const ee=e=>o.isIdentifier(e)?e.getText():o.isPropertyAccessExpression(e)?e.getName():void 0,N=(e,t,r=l)=>{const i=new Set;for(const n of e.getImportDeclarations())if(r(n.getModuleSpecifierValue()))for(const s of n.getNamedImports())s.getNameNode().getText()===t&&i.add(s.getAliasNode()?.getText()??s.getName());return i},K=(e,t)=>{if(o.isPropertyAccessExpression(e))return e.getName()===t;if(!o.isIdentifier(e))return!1;const r=e.getText();return r===t||N(e.getSourceFile(),t).has(r)},x=e=>{for(const t of e.getSymbol()?.getDeclarations()??[])if(o.isImportSpecifier(t)&&l(t.getImportDeclaration().getModuleSpecifierValue()))return t.getNameNode().getText()},C=e=>e.getSymbol()?x(e):e.getText(),R=(e,t)=>o.isIdentifier(e)&&x(e)===t,te=(e,t)=>{const r=e.getExpression(),i=e.getSourceFile();if(o.isIdentifier(r))return N(i,t,y).has(r.getText());if(!o.isPropertyAccessExpression(r)||r.getName()!==t)return!1;const n=r.getExpression().getText();return i.getImportDeclarations().some(s=>s.getNamespaceImport()?.getText()===n&&y(s.getModuleSpecifierValue()))},_=3,B=e=>{if(!e||!o.isIdentifier(e))return;const t=e.getSymbol()?.getValueDeclaration();if(!z(t))return;const r=c(t.getInitializer());return r&&o.isCallExpression(r)?r:void 0},d=e=>{const t=[];let r=c(e),i=0;for(;;){for(;r&&o.isCallExpression(r);){const s=c(r.getExpression());if(!s||!o.isPropertyAccessExpression(s))return{root:void 0,steps:t};t.push({call:r,name:s.getName()}),r=c(s.getExpression())}const n=i<_?B(r):void 0;if(!n)return{root:r,steps:t};i+=1,r=n}},E=e=>d(e).steps,L=e=>{if(o.isCallExpression(e))return e;if(!o.isIdentifier(e))return;const t=c(F(e.getSymbol()));return t&&o.isCallExpression(t)?t:void 0},D=(e,t,r)=>E(e).filter(i=>i.name===t).map(i=>i.call.getArguments()[0]).map(i=>i===void 0?void 0:L(i)).filter(i=>i!==void 0&&r(i.getExpression())),j=(e,t,r)=>D(e,t,i=>K(i,r)),ie=(e,t)=>E(e).some(r=>r.name===t),re=(e,t,r)=>j(e,t,r).length>0,A=new Set(["action","internalAction","internalMutation","internalQuery","mutation","query","stream"]),T=e=>{if(o.isIdentifier(e)){for(const t of e.getSymbol()?.getDeclarations()??[])if(o.isImportSpecifier(t)&&l(t.getImportDeclaration().getModuleSpecifierValue()))return t.getName()}if(o.isPropertyAccessExpression(e)){const t=e.getExpression();if(o.isIdentifier(t))return t.getSymbol()?.getDeclarations().some(i=>o.isNamespaceImport(i)&&l(i.getFirstAncestorByKindOrThrow(h.ImportDeclaration).getModuleSpecifierValue()))?e.getName():void 0}},W=e=>{const t=e.getParent(),r=t.getParent(),i=e.getPropertyNameNode()??e.getNameNode();if(!o.isObjectBindingPattern(t)||!o.isVariableDeclaration(r)||r.getVariableStatement()?.getDeclarationKind()!==b.Const||e.getDotDotDotToken()||e.getInitializer()||!o.isIdentifier(i)||!A.has(i.getText())||i.getText()==="stream")return;const n=r.getInitializer();if(!n)return;const{root:s,steps:a}=d(n);return s&&T(s)==="initLunora"&&a.length===2&&a[0]?.name==="create"&&a[1]?.name==="dataModel"?i.getText():void 0},U=e=>{const t=T(e);if(t)return A.has(t)?{factory:t}:{};if(!o.isIdentifier(e))return{};const r=e.getSymbol(),i=(r?.isAlias()?r.getAliasedSymbol():r)?.getValueDeclaration();return i&&o.isBindingElement(i)?{factory:W(i)}:i&&o.isVariableDeclaration(i)&&i.getVariableStatement()?.getDeclarationKind()===b.Const?{initializer:i.getInitializer()}:{}},q=e=>{const t=[],r=new Set;let i=e;for(;i!==void 0&&!r.has(i);){r.add(i);const n=d(i);if(t.push(...n.steps),!n.root)break;const{factory:s,initializer:a}=U(n.root);if(s)return{factory:s,steps:t};i=a}return{steps:t}},g=new Set(["action","mutation","query","stream"]),w={internalAction:"action",internalMutation:"mutation",internalQuery:"query"},f={onConnect:"connect",onDisconnect:"disconnect",onQueryChange:"reactor",onShardInit:"init",onWhisper:"whisper",defineWebSocket:"socket"},p={defineRoom:"room"},H=e=>e==="whisper"?"query":"mutation",O=e=>{const{root:t}=d(e);return t&&o.isIdentifier(t)?t:void 0},k=(e,t=!1)=>{const r=O(e);if(!r)return;const i=C(r);if(i===void 0){if(t)return;const n=r.getSymbol()?.getValueDeclaration();if(n&&o.isVariableDeclaration(n)){const s=n.getInitializer();return s?k(s,!0):void 0}return}return g.has(i)?"public":w[i]?"internal":void 0},V=(e,t=!1)=>{if(D(e,"use",s=>R(s,"platformAdmin")).length>0)return!0;if(t)return!1;const r=O(e)?.getSymbol(),i=(r?.isAlias()?r.getAliasedSymbol():r)?.getValueDeclaration(),n=i&&o.isVariableDeclaration(i)?i.getInitializer():void 0;return n!==void 0&&V(n,!0)},v=e=>V(e)?{adminOnly:!0}:{},Q=(e,t)=>{const r=e.getName();if(!g.has(r))return;const i=e.getExpression(),n=c(i)??i,s=i===n?[n]:[i,n];if(s.some(u=>u.getType().getProperty("__lunoraProcedure"))){const u=s.some(M=>M.getType().getProperty("__lunoraVisibility"));return{kind:r,receiver:n,visibility:u?"internal":"public",...v(n)}}const a=t?q(n).factory:void 0,P=a?.startsWith("internal")?"internal":"public",m=a?P:k(n);if(m)return{kind:r,receiver:n,visibility:m,...v(n)}},X=e=>(e.getSymbol()?.getDeclarations()??[]).some(t=>o.isNamespaceImport(t)&&l(t.getFirstAncestorByKind(h.ImportDeclaration)?.getModuleSpecifierValue()??"")),Y=e=>Object.hasOwn(p,e)||Object.hasOwn(f,e),I=e=>{if(Object.hasOwn(p,e))return{channel:p[e],kind:"mutation",visibility:"internal"};const t=Object.hasOwn(f,e)?f[e]:void 0;return t?{kind:H(t),lifecycle:t,visibility:"internal"}:void 0},G=(e,t)=>{const r=e.getExpression();if(o.isPropertyAccessExpression(r)){const s=r.getExpression(),a=r.getName();return Y(a)&&o.isIdentifier(s)&&X(s)?I(a):Q(r,t)}if(!o.isIdentifier(r))return;const i=C(r);if(!i)return;if(g.has(i))return{kind:i,visibility:"public"};const n=w[i];return n?{kind:n,visibility:"internal"}:I(i)},S=new WeakMap,ne=(e,t=!1)=>{const r=e.getProject().getTypeChecker().compilerObject;let i=S.get(r);i===void 0&&(i=new WeakMap,S.set(r,i));let n=i.get(e.compilerNode);return n===void 0&&(n=new Map,i.set(e.compilerNode,n)),n.has(t)||n.set(t,G(e,t)),n.get(t)};export{ee as a,E as b,ne as c,te as d,re as e,R as f,L as g,ie as h,N as i,K as r,q as s,j as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as i}from"ts-morph";import{listLunoraSourceFiles as a,lunoraRelativePath as c,handlerOf as l}from"./isTestPath-
|
|
1
|
+
import{Node as i}from"ts-morph";import{listLunoraSourceFiles as a,lunoraRelativePath as c,handlerOf as l}from"./isTestPath-DJeZ18i9.mjs";import{j as d,h as f}from"./attribution-B8xa6AeK.mjs";import{b as u}from"./context-root-CO8PbZi5.mjs";import{c as m}from"./classify-procedure-call-BK_MMoue.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as o,SyntaxKind as d}from"ts-morph";import{unwrapExpression as l,memberAccessOf as C,descendantsOfKind as P,bindingKeyName as I,isConstDeclaration as D,findObjectProperty as E,walkChain as M}from"./isTestPath-DJeZ18i9.mjs";import{d as v,b as O,f as F}from"./attribution-B8xa6AeK.mjs";import{c as w}from"./classify-procedure-call-BK_MMoue.mjs";import{isDefineMutatorCallee as B}from"./MUTATORS_FILENAME-SLAN2VXq.mjs";const x=8,h=t=>{if(o.isMethodDeclaration(t))return t;const e=o.isPropertyAssignment(t)?l(t.getInitializer()):void 0,r=o.isShorthandPropertyAssignment(t)?t.getNameNode():e;if(o.isArrowFunction(r)||o.isFunctionExpression(r))return r;const i=o.isIdentifier(r)?v(r):void 0;if(o.isFunctionDeclaration(i))return i;const n=D(i)?l(i.getInitializer()):void 0;return o.isArrowFunction(n)||o.isFunctionExpression(n)?n:void 0},T=t=>{const e=l(t.getArguments()[0]),r=o.isObjectLiteralExpression(e)?e:void 0,i=E(r,"server"),n=E(r,"handler"),s=i!==void 0&&B(t.getExpression()),a=n===void 0?void 0:w(t),u=a!==void 0&&a.receiver===void 0;return[s?h(i):void 0,u?h(n):void 0].filter(f=>f!==void 0)},p=new WeakMap,S=t=>{const e=t.getSourceFile(),r=p.get(e.compilerNode);if(r!==void 0)return r;const i=new Set(e.getDescendantsOfKind(d.CallExpression).flatMap(n=>T(n)).map(n=>n.compilerNode));return p.set(e.compilerNode,i),i},A=t=>{const e=t.getParent();return(o.isArrowFunction(e)||o.isFunctionExpression(e)||o.isFunctionDeclaration(e)||o.isMethodDeclaration(e))&&e.getParameters()[0]===t&&S(t).has(e.compilerNode)},Y=t=>{const e=t.getParent();return(o.isArrowFunction(e)||o.isFunctionExpression(e)||o.isFunctionDeclaration(e)||o.isMethodDeclaration(e))&&e.getParameters()[1]===t&&S(t).has(e.compilerNode)},z=t=>t.getNameNode().getDescendantsOfKind(d.BindingElement).some(e=>e.getParent().getParent()===t&&["args","ctx"].includes(I(e))),b=(t,e,r)=>{const i=t.getInitializer();if(i===void 0)return e;const n=r>0?c(i,"trust",r-1):void 0;return n?.length===e.length&&n.every((s,a)=>s===e[a])?e:void 0},H=(t,e,r,i)=>{if(e==="ctx")return r==="trust"?b(t,[],i):[]},g=(t,e,r)=>{const i=t.getParent().getParent(),n=I(t);if(t.getDotDotDotToken()!==void 0||e==="trust"&&O(t))return;let s;if(o.isParameterDeclaration(i)){if(!A(i)||z(i))return H(t,n,e,r);s=[]}else o.isBindingElement(i)?s=g(i,e,r):o.isVariableDeclaration(i)&&r>0&&(s=c(i.getInitializer(),e,r-1));const a=s===void 0?void 0:[...s,n];return e==="trust"&&a!==void 0?b(t,a,r):a},c=(t,e="discover",r=x)=>{const i=l(t),n=C(i);if(n!==void 0){const s=c(n.object,e,r);return s===void 0?void 0:[...s,n.member]}return o.isIdentifier(i)?K(i,e,r):void 0},K=(t,e,r)=>{const i=t.getText()==="ctx",n=e==="trust"||!i?v(t):void 0;return i&&!o.isVariableDeclaration(n)?o.isBindingElement(n)?g(n,e,r):[]:o.isParameterDeclaration(n)?o.isIdentifier(n.getNameNode())&&A(n)?[]:void 0:o.isBindingElement(n)?g(n,e,r):!(o.isVariableDeclaration(n)&&o.isIdentifier(n.getNameNode())&&r>0)||e==="trust"&&O(n)?void 0:c(n.getInitializer(),e,r-1)},Z=t=>c(t,"discover"),$=t=>c(t,"trust"),U=t=>{const e=c(t);return e===void 0?void 0:["ctx",...e].join(".")},ee=(t,e)=>{if(e(t.getText()))return!0;const r=U(t);return r!==void 0&&e(r)},te=(t,e)=>{const r=l(t),i=C(r);if(i!==void 0&&i.member!==e.at(-1))return!1;const n=r===void 0?void 0:c(r);return n?.length===e.length&&n.every((s,a)=>s===e[a])},ne=(t,e)=>y(t).get(e)??[],k=t=>{const e=new Map;for(const i of P(t,d.BindingElement)){const n=o.isIdentifier(i.getNameNode())?g(i,"discover",x):void 0;n?.length===1&&n[0]!==void 0&&e.set(i.compilerNode,n[0])}const r=new Set([...e.keys()].map(i=>i.name.getText()));return P(t,d.Identifier).flatMap(i=>{const s=r.has(i.getText())&&!o.isBindingElement(i.getParent())?v(i):void 0,a=s===void 0?void 0:e.get(s.compilerNode);return a===void 0?[]:[[a,i]]})},N=new WeakMap,y=t=>{const e=N.get(t.compilerNode);if(e!==void 0)return e;const r=new Map;for(const[n,s]of[..._(t),...k(t)])r.set(n,[...r.get(n)??[],s]);const i=new Map([...r].map(([n,s])=>[n,s.toSorted((a,u)=>a.getPos()-u.getPos())]));return N.set(t.compilerNode,i),i},_=t=>t.getDescendantsOfKind(d.PropertyAccessExpression).flatMap(e=>R(e.getExpression())?[[e.getName(),e]]:[]),R=t=>o.isIdentifier(t)&&c(t)?.length===0,ie=t=>{const e=c(t);return e?.length===1&&e[0]==="db"},j=new Set(["asId","createMultipartUpload","fetch","generateUploadUrl","getPresignedUrl","getSignedUrl","getUrl","normalizeId","resumeMultipartUpload","runAction","runMutation","runQuery","store","upload"]),L=new Set(["catch","flatMap","map","reduce","reduceRight","then"]),V=t=>{for(let e=t;o.isBindingElement(e)||o.isObjectBindingPattern(e)||o.isArrayBindingPattern(e);e=e.getParent())if(o.isBindingElement(e)&&e.getInitializer()!==void 0)return!0;return!1},X=(t,e=x)=>{const r=M(t,u=>{const f=l(u.getExpression()),m=o.isPropertyAccessExpression(f)?f.getName():void 0;return m!==void 0&&(j.has(m)||L.has(m))?!1:void 0}),i=r.root;if(r.verdict!==void 0||!o.isIdentifier(i))return r.verdict??!1;if(c(i,"trust")!==void 0)return!0;const n=v(i),s=o.isBindingElement(n)?n.getFirstAncestorByKind(d.VariableDeclaration):n;if(o.isBindingElement(n)&&V(n))return!1;const a=D(s)&&e>0?s.getInitializer():void 0;return a!==void 0&&X(a,e-1)},re=t=>(o.isIdentifier(t)?[t]:t.getDescendantsOfKind(d.Identifier)).some(r=>F(r)&&c(r,"trust")!==void 0);export{L as C,j as E,R as a,ne as b,$ as c,ie as d,te as e,U as f,Z as g,X as h,Y as i,h as j,ee as m,re as r};
|
package/dist/packem_shared/{createCodegenProject-dC6oJh5H.mjs → createCodegenProject-C4XuJSap.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as R}from"node:crypto";import{readFileSync as F,existsSync as d,readdirSync as A,statSync as L}from"node:fs";import{dirname as h,join as g}from"node:path";import{Project as x,ts as i}from"ts-morph";import{listSecurityScanFiles as T,listLunoraSourceFiles as K}from"./isTestPath-
|
|
1
|
+
import{createHash as R}from"node:crypto";import{readFileSync as F,existsSync as d,readdirSync as A,statSync as L}from"node:fs";import{dirname as h,join as g}from"node:path";import{Project as x,ts as i}from"ts-morph";import{listSecurityScanFiles as T,listLunoraSourceFiles as K}from"./isTestPath-DJeZ18i9.mjs";import{projectConfigCandidatePaths as O}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";const m=e=>e.replaceAll("\\","/"),_=e=>{const t=K(e),s=g(e,"schema.ts");return d(s)&&t.push(s),t},$=e=>{const t=g(e,"_generated");return d(t)?A(t,{encoding:"utf8",recursive:!0}).filter(s=>s.endsWith(".ts")).map(s=>g(t,s)).filter(s=>L(s).isFile()):[]},D=/\.d\.(?:ts|mts|cts)$/,W=/\.[cm]?jsx?$/,G=/\bdeclare\b|\/\/\//,J=e=>{const t=i.createScanner(i.ScriptTarget.Latest,!0,i.LanguageVariant.Standard,e),s=t.scan();if(s===i.SyntaxKind.ExportKeyword)return!0;if(s!==i.SyntaxKind.ImportKeyword)return!1;const n=t.scan();return n===i.SyntaxKind.OpenBraceToken||n===i.SyntaxKind.AsteriskToken||n===i.SyntaxKind.StringLiteral},U=e=>i.isCallExpression(e)?i.isIdentifier(e.expression)&&e.expression.text==="require":i.isPropertyAccessExpression(e)&&i.isIdentifier(e.expression)?e.expression.text==="exports"||e.expression.text==="module"&&e.name.text==="exports":!1,P=e=>U(e)||i.forEachChild(e,P)===!0,V=e=>i.isModuleDeclaration(e)&&i.isIdentifier(e.name)&&e.name.text==="global",C=new Map,q=(e,t,s)=>{if(!G.test(t)&&(s||J(t)))return{augments:[],hasGlobal:!1,isModule:!0};const n=i.createSourceFile(e,t,i.ScriptTarget.Latest,!1),r=n.referencedFiles.length>0||n.typeReferenceDirectives.length>0||n.libReferenceDirectives.length>0;return{augments:n.statements.flatMap(o=>i.isModuleDeclaration(o)&&i.isStringLiteral(o.name)?[o.name.text]:[]),hasGlobal:r||n.statements.some(o=>V(o)),isModule:s||i.isExternalModule(n)||W.test(e)&&P(n)}},z=(e,t,s)=>{const n=`${s?"force":"auto"}:${R("sha256").update(t).digest("hex")}`,r=C.get(e);if(r?.key===n)return r.analysis;const o=q(e,t,s);return C.set(e,{analysis:o,key:n}),o},w=e=>{const t={...i.sys,onUnRecoverableConfigFileDiagnostic:()=>{}},s=i.getParsedCommandLineOfConfigFile(e,void 0,t);return{fileNames:s?.fileNames??[],forceModules:s?.options.moduleDetection===i.ModuleDetectionKind.Force}},N=new WeakMap,E=(e,t)=>{const{fileNames:s=[],forceModules:n=!1}=t??{},r=`${m(e)}/`,o=[],l=[],f=[];for(const c of s){if(!d(c))continue;if(D.test(c)){o.push(c);continue}if(m(c).startsWith(r))continue;const a=z(c,F(c,"utf8"),n);!a.isModule||a.hasGlobal?l.push(c):a.augments.length>0&&f.push({augments:a.augments,path:c})}return{augmentations:f,files:[...new Set([..._(e),...T(e).map(({filePath:c})=>c),...$(e),...o,...l,...O(e).filter(c=>d(c))])]}},b=(e,t,s)=>i.resolveModuleName(e,t,s,i.sys).resolvedModule?.resolvedFileName??e,B=(e,t)=>{const s=e.getCompilerOptions(),n=new Set;for(const r of t){const o=e.getSourceFile(r);if(o!==void 0)for(const{fileName:l}of i.preProcessFile(o.getFullText(),!0,!1).importedFiles)n.add(b(l,o.getFilePath(),s))}return n},M=new WeakMap,H=(e,t)=>{const s=e.getCompilerOptions(),n=new Map,r=new Set,o=[...t],l=f=>{const c=f.fileName,a=h(c);let u=M.get(f);u===void 0&&(u=i.preProcessFile(f.text,!0,!0),M.set(f,u));const y=u.referencedFiles.map(({fileName:p})=>g(a,p));for(const{fileName:p}of u.importedFiles){const S=`${a}\0${p}`;n.has(S)||n.set(S,i.resolveModuleName(p,c,s,i.sys).resolvedModule?.resolvedFileName);const v=n.get(S);v!==void 0&&y.push(v)}return y};for(;o.length>0;){const f=o.pop();if(f===void 0||m(f).includes("/node_modules/")||r.has(m(f)))continue;r.add(m(f));const c=e.getSourceFile(f);c!==void 0&&o.push(...l(c.compilerNode))}return r},k=(e,t,s)=>{const n=e.getCompilerOptions(),r=[];let o;for(;;){e.resolveSourceFileDependencies(),o=H(e,[...t,...r]);const l=s.filter(a=>!r.includes(a.path));if(l.length===0)break;const f=B(e,o),c=l.filter(a=>a.augments.some(u=>f.has(b(u,a.path,n))));if(c.length===0)break;for(const a of c)e.getSourceFile(a.path)===void 0&&e.createSourceFile(a.path,F(a.path,"utf8"),{overwrite:!0});r.push(...c.map(a=>a.path))}for(const l of e.getSourceFiles())!l.isInNodeModules()&&!o.has(l.getFilePath())&&e.removeSourceFile(l)},I=e=>{let t=d(e)?e:h(e);for(;t&&t!==h(t);){const s=g(t,"tsconfig.json");if(d(s))return s;t=h(t)}},se=e=>{const t={...i.sys,onUnRecoverableConfigFileDiagnostic:()=>{}},s=i.getParsedCommandLineOfConfigFile(e,{},t);return s===void 0?"":JSON.stringify({fileNames:s.fileNames,options:s.options})},te=e=>{const t=I(e);if(t===void 0)return new x({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});const s=new x({skipAddingFilesFromTsConfig:!0,tsConfigFilePath:t,useInMemoryFileSystem:!1}),n=w(t);N.set(s,n);const r=E(e,n);for(const o of r.files)s.createSourceFile(o,F(o,"utf8"),{overwrite:!0});return k(s,r.files,r.augmentations),s},oe=(e,t)=>{const s=I(t),n=E(t,N.get(e)??(s===void 0?void 0:w(s)));for(const o of n.files){const l=e.getSourceFile(o);l===void 0?e.createSourceFile(o,F(o,"utf8"),{overwrite:!0}):l.refreshFromFileSystemSync()}const r=new Set(n.files);for(const o of e.getSourceFiles())if(!(r.has(o.getFilePath())||o.isInNodeModules()))try{o.refreshFromFileSystemSync()}catch{e.removeSourceFile(o)}k(e,n.files,n.augmentations)};export{te as createCodegenProject,I as findTsconfig,oe as refreshCodegenProject,se as tsconfigFingerprint};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SyntaxKind as g,Node as n}from"ts-morph";import{descendantsOfKind as p}from"./isTestPath-
|
|
1
|
+
import{SyntaxKind as g,Node as n}from"ts-morph";import{descendantsOfKind as p}from"./isTestPath-DJeZ18i9.mjs";import{d as l}from"./context-root-CO8PbZi5.mjs";const c=e=>n.isPropertyAccessExpression(e)&&e.getName()==="db"||n.isIdentifier(e)&&e.getText()==="db"||l(e),b=new Set(["findFirst","findFirstOrThrow","findMany","findUnique"]),E=e=>{const t=e.getExpression();if(!n.isPropertyAccessExpression(t)||!b.has(t.getName()))return;const s=t.getExpression();if(c(s))return{options:e.getArguments()[1],table:d(e)};if(n.isPropertyAccessExpression(s)){const o=s.getExpression();if(c(o))return{options:e.getArguments()[0],table:s.getName()}}},f=(e,t)=>{const s=e.getExpression();return!n.isPropertyAccessExpression(s)||!t.has(s.getName())?!1:c(s.getExpression())},d=e=>{const t=e.getArguments()[0];return t&&n.isStringLiteral(t)?t.getLiteralText():""},A=(e,t,s)=>{const o=new Set,i=new Set;for(const a of p(e,g.CallExpression))if(f(a,t)){const r=d(a);r!==""&&o.add(r)}else if(f(a,s)){const r=d(a);r!==""&&i.add(r)}return{tablesRead:[...o],tablesWritten:[...i]}};export{c as i,E as r,A as t};
|
package/dist/packem_shared/{discoverAuthApiCalls-CuqaLRa0.mjs → discoverAuthApiCalls-DcvsgL5u.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as t}from"ts-morph";import{collectCallRows as n}from"./isTestPath-
|
|
1
|
+
import{Node as t}from"ts-morph";import{collectCallRows as n}from"./isTestPath-DJeZ18i9.mjs";import{c as p}from"./attribution-B8xa6AeK.mjs";import{a}from"./property-name-7cBlgK_O.mjs";const c=s=>{const r=s.getExpression();if(!t.isPropertyAccessExpression(r))return!1;const e=r.getExpression();return t.isPropertyAccessExpression(e)?e.getName()==="authApi":t.isIdentifier(e)&&e.getText()==="authApi"},u=s=>{const r=s.getArguments()[0];if(r===void 0)return!1;if(!t.isObjectLiteralExpression(r))return!0;for(const e of r.getProperties())if((t.isPropertyAssignment(e)||t.isShorthandPropertyAssignment(e))&&a(e)==="headers"||t.isSpreadAssignment(e))return!0;return!1},d=(s,r)=>n(s,r,(e,o)=>{if(!c(e))return;const i=e.getExpression();return{file:o,hasHeaders:u(e),line:e.getStartLineNumber(),method:t.isPropertyAccessExpression(i)?i.getName():"",scope:p(e)}});export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as x}from"@lunora/errors";import{CRON_SCHEDULE_KINDS as A,warnIfSecondsLeading as O,compileCronSchedule as S}from"@lunora/scheduler";import I from"@lunora/scheduler/validate";import{SyntaxKind as p,Node as i}from"ts-morph";import{diagnosticAt as f,CodegenDiagnosticError as R}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{i as b}from"./module-specifiers-BctA0m_p.mjs";import{listLunoraSourceFiles as y,declarationLineOf as $,lunoraRelativePath as P,functionKeyOf as v}from"./isTestPath-
|
|
1
|
+
import{LunoraError as x}from"@lunora/errors";import{CRON_SCHEDULE_KINDS as A,warnIfSecondsLeading as O,compileCronSchedule as S}from"@lunora/scheduler";import I from"@lunora/scheduler/validate";import{SyntaxKind as p,Node as i}from"ts-morph";import{diagnosticAt as f,CodegenDiagnosticError as R}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{i as b}from"./module-specifiers-BctA0m_p.mjs";import{listLunoraSourceFiles as y,declarationLineOf as $,lunoraRelativePath as P,functionKeyOf as v}from"./isTestPath-DJeZ18i9.mjs";import{a as D}from"./property-name-7cBlgK_O.mjs";const F=new Set([...A,"cron"]),V=e=>{const t=e.getSymbol();if(!t)return e.getText()==="cronJobs";for(const r of t.getDeclarations())if(i.isImportSpecifier(r))return b(r.getImportDeclaration().getModuleSpecifierValue())?r.getNameNode().getText()==="cronJobs":!1;return!1},k=e=>{const t=new Set;for(const r of e.getVariableDeclarations()){const n=r.getInitializer();if(n?.getKind()!==p.CallExpression)continue;const s=n.getExpression();i.isIdentifier(s)&&V(s)&&t.add(r.getName())}return t},j=e=>{let t=e;for(;i.isCallExpression(t)||i.isPropertyAccessExpression(t);)t=t.getExpression();return i.isIdentifier(t)?t.getText():void 0},L=(e,t)=>{const r=e.getArguments()[t];return r&&(i.isStringLiteral(r)||i.isNoSubstitutionTemplateLiteral(r))?r.getLiteralValue():void 0},_=(e,t)=>{if(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e)||i.isNumericLiteral(e))return e.getLiteralValue();if(i.isTrueLiteral(e))return!0;if(i.isFalseLiteral(e))return!1;if(i.isPrefixUnaryExpression(e)&&e.getOperatorToken()===p.MinusToken){const r=e.getOperand();if(i.isNumericLiteral(r))return-r.getLiteralValue()}if(i.isObjectLiteralExpression(e))return d(e,t);if(i.isArrayLiteralExpression(e))return e.getElements().map(r=>_(r,t));throw f(e,`Cron job "${t}" passes a non-static value where a literal is required; codegen can only read literals.`,{code:"CRON_NON_STATIC_VALUE",name:"LunoraError",status:500})},d=(e,t)=>{const r={};for(const n of e.getProperties()){if(!i.isPropertyAssignment(n))throw f(n,`Cron job "${t}" uses an unsupported object property (shorthand/spread/method) where a static literal is required.`,{code:"CRON_NON_STATIC_VALUE",name:"LunoraError",status:500});const s=n.getInitializer();s&&(r[D(n)]=_(s,t))}return r},C=(e,t,r)=>{const n=e.getArguments()[t];if(!n||!i.isPropertyAccessExpression(n))throw f(e,`Cron job "${r}" must reference a function statically (e.g. internal.email.digest); codegen cannot resolve a dynamic reference.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});const s=v(n);if(s===void 0)throw f(n,`Cron job "${r}" function reference must be of the form internal.<…path>.fn (or api.<…path>.fn).`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});return s},h=e=>({workflow:{className:e.className,exportName:e.exportName}}),w=e=>({workflow:{className:e.className,exportName:e.exportName}}),T=(e,t,r,n,s,o)=>{const a=e.getExpression();if(!i.isIdentifier(a)||a.getText()!==t)return;const c=r.get(e.getName());if(c)return o(c);throw f(e,`Cron job "${n}" targets ${t}.${e.getName()}, but no such ${s} is declared in lunora/${s}s.ts.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500})},U=(e,t,r,n,s)=>{const o=e.getArguments()[t];if(o&&i.isPropertyAccessExpression(o)){const a=T(o,"workflows",n,r,"workflow",h);if(a)return a;const c=T(o,"agents",s,r,"agent",w);return c||{functionPath:C(e,t,r)}}if(o&&i.isIdentifier(o)){const a=n.get(o.getText()),c=s.get(o.getText());if(a&&c)throw f(o,`Cron job "${r}" references "${o.getText()}", which is ambiguous: a workflow and an agent are both declared under that name.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});if(a)return h(a);if(c)return w(c);throw f(o,`Cron job "${r}" references "${o.getText()}", which is neither a function (internal.file.fn / api.file.fn) nor a declared workflow in lunora/workflows.ts nor a declared agent in lunora/agents.ts.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500})}return{functionPath:C(e,t,r)}},M=/^@lunora\/scheduler:\s*/u,K=(e,t)=>{const r=L(e,1);if(r===void 0)throw f(e,`Cron job "${t}" must pass a string-literal cron expression to ".cron(...)".`,{code:"CRON_EXPR_NOT_STATIC",name:"LunoraError",status:500});if(!I(r))throw f(e,`Cron job "${t}" has an invalid cron expression "${r}" — expected 5 or 6 space-separated fields that occur on at least one date.`,{code:"CRON_EXPR_INVALID",name:"LunoraError",status:500});return O(r,`cron expression for job "${t}"`),r},z=(e,t,r)=>{const n=e.getArguments()[1];if(!n||!i.isObjectLiteralExpression(n))throw f(e,`Cron job "${r}" must pass an object-literal schedule to ".${t}(...)".`,{code:"CRON_SCHEDULE_NOT_STATIC",name:"LunoraError",status:500});try{return S(t,d(n,r),r)}catch(s){if(s instanceof R)throw s;const o=s instanceof Error?s.message.replace(M,""):String(s);throw f(e,o,{code:"CRON_SCHEDULE_INVALID",name:"LunoraError",status:500})}},H=(e,t,r,n,s)=>{const o=t.getName();if(!F.has(o)||!r.has(j(t.getExpression())??""))return;const a=L(e,0);if(a===void 0||a.trim()==="")throw f(e,`A cron ".${o}(...)" registration must pass a non-empty string-literal name as its first argument.`,{code:"CRON_NAME_NOT_STATIC",name:"LunoraError",status:500});const c=o==="cron"?K(e,a):z(e,o,a),u=U(e,2,a,n,s),l=e.getArguments()[3];return{args:l&&i.isObjectLiteralExpression(l)?d(l,a):{},cron:c,name:a,...u}},q=e=>{const t=new Set;for(const r of e){if(t.has(r.name))throw new x("DUPLICATE_CRON_NAME",`Duplicate cron job name "${r.name}": cron names must be unique across the project.`,{status:500});t.add(r.name)}},ee=(e,t,r=[],n=[])=>{const s=y(t),o=[],a=new Map(r.map(u=>[u.exportName,u])),c=new Map(n.map(u=>[u.exportName,u]));for(const u of s){const l=e.getSourceFile(u)??e.addSourceFileAtPath(u),g=k(l);if(g.size!==0)for(const m of l.getDescendantsOfKind(p.CallExpression)){const N=m.getExpression();if(!i.isPropertyAccessExpression(N))continue;const E=H(m,N,g,a,c);E&&o.push({...E,file:P(t,u),line:$(m)})}}return o.sort((u,l)=>u.name.localeCompare(l.name)),q(o),o};export{ee as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./declared-output-Iaar469J.mjs";import"./isTestPath-DJeZ18i9.mjs";import"./attribution-B8xa6AeK.mjs";import"./unwrap-handler-return-BnsKyz9W.mjs";import"./ip-reads-D8rPYtZ6.mjs";import"./classify-procedure-call-BK_MMoue.mjs";import{d as f}from"./index-BwLaIVqA.mjs";import"./dispatch-namespace-DwTjD7BU.mjs";export{f as default};
|
package/dist/packem_shared/{discoverHttpRoutes-CesuhqW1.mjs → discoverHttpRoutes-BtMgsfzG.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as n}from"ts-morph";import{a as m,p as l}from"./parse-validator-BisfC8bR.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./isTestPath-
|
|
1
|
+
import{Node as n}from"ts-morph";import{a as m,p as l}from"./parse-validator-BisfC8bR.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./isTestPath-DJeZ18i9.mjs";import{j as f,h as g}from"./attribution-B8xa6AeK.mjs";import{u as x}from"./unwrap-handler-return-BnsKyz9W.mjs";const u=new Set(["delete","get","head","options","patch","post","put"]),E=new Set(["body","params","searchParams"]),v=new Set(["handler","stream"]),P=s=>{const e=s.getArguments()[0];if(e&&n.isStringLiteral(e))return e.getLiteralValue()},S=s=>{const e=s.getArguments()[0];return e&&n.isObjectLiteralExpression(e)?l(e):{}},A=s=>{if(!n.isCallExpression(s))return;const e=s.getExpression();if(!n.isPropertyAccessExpression(e))return;const o=e.getName();if(!u.has(o))return;const a=e.getExpression();if(!n.isIdentifier(a)||a.getText()!=="httpRoute")return;const t=P(s);return t===void 0?void 0:{method:o.toUpperCase(),path:t}},T=(s,e)=>{const o={body:{},params:{},searchParams:{},stream:e==="stream"},a=s.getExpression();if(!n.isPropertyAccessExpression(a))return;let t=a.getExpression();for(;n.isCallExpression(t);){const i=t.getExpression();if(!n.isPropertyAccessExpression(i))break;const c=i.getName();if(u.has(c))break;if(E.has(c)){const p=S(t);o[c]={...p,...o[c]}}else if(c==="output"&&o.output===void 0){const p=t.getArguments()[0];p&&n.isExpression(p)&&(o.output=m(p))}t=i.getExpression()}const r=A(t);if(r)return o.method=r.method,o.path=r.path,o},b=s=>{const e=s.getArguments()[0];return!e||!(n.isArrowFunction(e)||n.isFunctionExpression(e))?"unknown":x(e,!0)},y=(s,e,o,a)=>{const t=e.getName();if(!v.has(t))return;const r=T(s,t);if(!(r?.method===void 0||r.path===void 0))return{body:r.body,exportName:o,filePath:a,method:r.method,params:r.params,path:r.path,searchParams:r.searchParams,stream:r.stream,...r.stream?{chunkType:b(s)}:{},...r.output?{output:r.output}:{}}},R=(s,e)=>{const o=[];for(const a of f(s)){const t=a.getInitializer();if(!t||!n.isCallExpression(t))continue;const r=t.getExpression();if(!n.isPropertyAccessExpression(r))continue;const i=y(t,r,g(a)??a.getName(),e);i&&o.push(i)}return o},L=(s,e)=>{const o=d(e),a=[];for(const t of o){const r=s.getSourceFile(t)??s.addSourceFileAtPath(t),i=h(e,t);a.push(...R(r,i))}return a.sort((t,r)=>`${t.method} ${t.path}`.localeCompare(`${r.method} ${r.path}`)||t.filePath.localeCompare(r.filePath)),a};export{L as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as o}from"./context-property-calls-As5I0QR6.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-
|
|
1
|
+
import{Node as i}from"ts-morph";import{collectCallRows as n}from"./isTestPath-DJeZ18i9.mjs";import{c as a}from"./attribution-B8xa6AeK.mjs";import{i as c}from"./database-calls-Cug60vT9.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-DJeZ18i9.mjs";import"./attribution-B8xa6AeK.mjs";import"./database-calls-Cug60vT9.mjs";import"./classify-procedure-call-BK_MMoue.mjs";import{d as a}from"./index-CQuAXbal.mjs";export{a as default};
|
package/dist/packem_shared/{discoverMigrations-C9AlZYFi.mjs → discoverMigrations-DaBdK1Bv.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SyntaxKind as p,Node as n}from"ts-morph";import{diagnosticAt as h}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as I}from"./module-specifiers-BctA0m_p.mjs";import{listLunoraSourceFiles as P,lunoraRelativePath as b,findObjectProperty as d}from"./isTestPath-
|
|
1
|
+
import{SyntaxKind as p,Node as n}from"ts-morph";import{diagnosticAt as h}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as I}from"./module-specifiers-BctA0m_p.mjs";import{listLunoraSourceFiles as P,lunoraRelativePath as b,findObjectProperty as d}from"./isTestPath-DJeZ18i9.mjs";import{j as x,a as A}from"./attribution-B8xa6AeK.mjs";const S=i=>{const r=i.getSymbol();if(!r)return i.getText()==="defineMigration";for(const t of r.getDeclarations())if(n.isImportSpecifier(t))return I(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMigration":!1;return!1},u=(i,r)=>{const t=d(i,r);if(!t||!n.isPropertyAssignment(t))return;const e=t.getInitializer();return e&&n.isStringLiteral(e)?e.getLiteralValue():void 0},z=i=>{const r=n.isPropertyAssignment(i)?i.getInitializer():void 0;if(r===void 0||!n.isObjectLiteralExpression(r))return;const t=u(r,"field"),e=d(r,"after"),o=n.isPropertyAssignment(e)?e.getInitializer():void 0;if(!(t===void 0||e!==void 0&&!(o!==void 0&&n.isNumericLiteral(o))))return{...o!==void 0&&n.isNumericLiteral(o)?{after:o.getLiteralValue()}:{},field:t}},E=i=>{const r=d(i,"covers"),t=n.isPropertyAssignment(r)?r.getInitializer():void 0;if(t===void 0||!n.isObjectLiteralExpression(t))return;const e={};for(const s of["jurisdiction","shardMode","table"]){const c=u(t,s);c!==void 0&&(e[s]=c)}const o=z(d(t,"ttl"));o!==void 0&&(e.ttl=o);const a=d(t,"memory");return n.isPropertyAssignment(a)&&a.getInitializer()?.getKind()===p.TrueKeyword&&(e.memory=!0),Object.keys(e).length===0?void 0:e},g=i=>n.isParenthesizedExpression(i)?g(i.getExpression()):i,v=i=>n.isArrowFunction(i)||n.isFunctionExpression(i)||n.isMethodDeclaration(i)||n.isFunctionDeclaration(i),y=(i,r=4)=>{const t=g(i);if(v(t))return t;if(r===0||!n.isIdentifier(t))return;const e=t.getParent(),o=n.isShorthandPropertyAssignment(e)?e.getValueSymbol():t.getSymbol(),a=o?.getAliasedSymbol()??o,s=a?.getValueDeclaration()??a?.getDeclarations()[0];if(s!==void 0){if(n.isVariableDeclaration(s)){const c=s.getInitializer();return c===void 0?void 0:y(c,r-1)}return v(s)?s:void 0}},N=i=>{const r=d(i,"up");let t=r;n.isPropertyAssignment(r)?t=r.getInitializer():n.isShorthandPropertyAssignment(r)&&(t=r.getNameNode());const e=t===void 0?void 0:y(t);if(e===void 0)return!1;const o=e.getParameters()[0]?.getNameNode();if(o===void 0||!n.isIdentifier(o))return!1;const a=m=>{const f=m===void 0?void 0:g(m);return f!==void 0&&n.isIdentifier(f)&&f.getText()===o.getText()},s=e.getBody();if(s===void 0)return!1;if(!n.isBlock(s))return a(s);const[c,...l]=s.getStatements();return l.length===0&&c!==void 0&&n.isReturnStatement(c)&&a(c.getExpression())},D=(i,r)=>{const t=i.getInitializer();if(t?.getKind()!==p.CallExpression)return;const e=t.getExpression();if(!n.isIdentifier(e)||!S(e))return;const o=t.getArguments()[0];if(!o||!n.isObjectLiteralExpression(o))return;const a=u(o,"id"),s=A(i,"member");if(s===void 0)return;if(a===void 0||a.trim()==="")throw h(o,`Migration "${s}" in "${r}" must declare \`id\` as a non-empty string literal so codegen can key the registry.`,{code:"MIGRATION_ID_NOT_STATIC",name:"LunoraError",status:500});const c=E(o);return{...c===void 0?{}:{covers:c},exportName:s,filePath:r,id:a,...N(o)?{identity:!0}:{},table:u(o,"table")??""}},M=i=>{const r=new Map;for(const t of i){const e=r.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});r.set(t.id,t.filePath)}},V=(i,r)=>{const t=P(r),e=[];for(const o of t){const a=i.getSourceFile(o)??i.addSourceFileAtPath(o),s=b(r,o);for(const c of x(a)){const l=D(c,s);l&&e.push(l)}}return e.sort((o,a)=>o.id.localeCompare(a.id)),M(e),e};export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as s,SyntaxKind as d}from"ts-morph";import{listLunoraSourceFiles as m,lunoraRelativePath as g,handlerOf as u,descendantsOfKind as l}from"./isTestPath-
|
|
1
|
+
import{Node as s,SyntaxKind as d}from"ts-morph";import{listLunoraSourceFiles as m,lunoraRelativePath as g,handlerOf as u,descendantsOfKind as l}from"./isTestPath-DJeZ18i9.mjs";import{j as N,h as x}from"./attribution-B8xa6AeK.mjs";import{c as p}from"./classify-procedure-call-BK_MMoue.mjs";const h={"crypto.getRandomValues":"crypto.getRandomValues","crypto.randomUUID":"crypto.randomUUID","Date.now":"Date.now","Math.random":"Math.random"},E=new Set(["globalThis","self"]),v=new Set(["globalThis","self","window"]),I=e=>{if(s.isIdentifier(e))return e.getText();if(s.isPropertyAccessExpression(e)){const t=e.getExpression();if(s.isIdentifier(t)&&v.has(t.getText()))return e.getName()}},S=e=>{const t=e.getExpression();if(s.isIdentifier(t)){const o=t.getText();return o==="fetch"||o==="Date"?o:void 0}if(!s.isPropertyAccessExpression(t))return;const n=t.getName(),i=I(t.getExpression());if(i!==void 0)return n==="fetch"&&E.has(i)?"fetch":h[`${i}.${n}`]},T=e=>{const t=e.getExpression();if(!s.isIdentifier(t)||t.getText()!=="Date")return;const n=e.getArguments(),i=n.every(o=>s.isNumericLiteral(o)||s.isStringLiteral(o)||s.isNoSubstitutionTemplateLiteral(o));return n.length>0&&i?void 0:"new Date"},y=e=>{const t=e.getInitializer();if(!t||!s.isCallExpression(t))return;const n=p(t);if(!n||n.kind!=="query"&&n.kind!=="mutation")return;const i=u(t,n.receiver);return i?{exportName:x(e)??e.getName(),handler:i,kind:n.kind}:void 0},L=e=>{const t=new Set(["ctx"]),n=r=>{if(s.isObjectBindingPattern(r))for(const a of r.getElements()){const c=a.getPropertyNameNode()?.getText()??a.getNameNode().getText(),f=a.getNameNode();c==="ctx"&&s.isIdentifier(f)&&t.add(f.getText())}},[i]=s.isParametered(e)?e.getParameters():[],o=i!==void 0&&s.isIdentifier(i.getNameNode())?i.getNameNode().getText():void 0;if(i!==void 0){const r=i.getNameNode();s.isIdentifier(r)?t.add(r.getText()):n(r)}for(const r of l(e,d.VariableDeclaration)){const a=r.getInitializer();o!==void 0&&a!==void 0&&s.isIdentifier(a)&&a.getText()===o&&n(r.getNameNode())}return t},P=(e,t,n)=>{const i=e.getExpression();if(!s.isPropertyAccessExpression(i)||i.getName()!=="random")return!1;const o=i.getExpression();return!s.isIdentifier(o)||!t.has(o.getText())?!1:o.getSymbol()?.getDeclarations()[0]?.getFirstAncestor(c=>s.isFunctionLikeDeclaration(c))===n},w=(e,t)=>{const n=[],i=L(e.handler);for(const o of l(e.handler,d.CallExpression)){const r=e.kind==="query"&&P(o,i,e.handler)?"ctx.random":S(o);r!==void 0&&n.push({callee:r,exportName:e.exportName,file:t,kind:e.kind,line:o.getStartLineNumber()})}for(const o of l(e.handler,d.NewExpression)){const r=T(o);r!==void 0&&n.push({callee:r,exportName:e.exportName,file:t,kind:e.kind,line:o.getStartLineNumber()})}return n},O=(e,t)=>{const n=[];for(const i of N(e)){const o=y(i);o&&n.push(...w(o,t))}return n},A=(e,t)=>{const n=[];for(const i of m(t)){const o=e.getSourceFile(i)??e.addSourceFileAtPath(i);n.push(...O(o,g(t,i)))}return n};export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as i,SyntaxKind as u}from"ts-morph";import{collectCallRows as x}from"./isTestPath-
|
|
1
|
+
import{Node as i,SyntaxKind as u}from"ts-morph";import{collectCallRows as x}from"./isTestPath-DJeZ18i9.mjs";import{w as E,c as h}from"./attribution-B8xa6AeK.mjs";import{i as v}from"./database-calls-Cug60vT9.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-As5I0QR6.mjs";const t=(s,o)=>r(s,o,"r2sql");export{t as default};
|
package/dist/packem_shared/{discoverRlsMetadata-C0UkQkWd.mjs → discoverRlsMetadata-CO-pRHOx.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as o}from"ts-morph";import{listLunoraSourceFiles as h,lunoraRelativePath as x,findObjectProperty as m,stringPropertyOf as a}from"./isTestPath-
|
|
1
|
+
import{Node as o}from"ts-morph";import{listLunoraSourceFiles as h,lunoraRelativePath as x,findObjectProperty as m,stringPropertyOf as a}from"./isTestPath-DJeZ18i9.mjs";import{e as L}from"./exported-procedure-chains-ej9ozyZB.mjs";import{r as P,p as A}from"./policies-CrNWTJQi.mjs";const v=new Set(["delete","insert","read","update"]),E=(e,t,s)=>{const i=[];for(const r of A(e)){const n=a(r,"on");n===void 0||!v.has(n)||i.push({file:t,on:n,procedure:s,table:a(r,"table")??""})}return i},f=e=>{if(!o.isObjectLiteralExpression(e))return[];const t=m(e,"permissions");if(!t||!o.isPropertyAssignment(t))return[];const s=t.getInitializer();if(!s||!o.isArrayLiteralExpression(s))return[];const i=[];for(const r of s.getElements()){if(o.isStringLiteral(r)){i.push(r.getLiteralText());continue}if(o.isCallExpression(r)){const n=r.getArguments()[0];n&&o.isStringLiteral(n)&&i.push(n.getLiteralText())}}return i},u=(e,t)=>t===void 0?e:{...e,description:t},y=e=>{if(o.isCallExpression(e)){const t=e.getArguments()[0];if(!t||!o.isStringLiteral(t))return;const s=e.getArguments()[1],i=s?a(s,"description"):void 0,r=s?f(s):[];return u({name:t.getLiteralText(),permissions:r},i)}if(o.isObjectLiteralExpression(e)){const t=a(e,"name");return t===void 0?void 0:u({name:t,permissions:f(e)},a(e,"description"))}},O=e=>{const t=e.getArguments()[1];if(!t||!o.isObjectLiteralExpression(t))return[];const s=m(t,"roles");if(!s||!o.isPropertyAssignment(s))return[];const i=s.getInitializer();if(!i||!o.isArrayLiteralExpression(i))return[];const r=[];for(const n of i.getElements()){const c=y(n);c&&r.push(c)}return r},S=(e,t,s)=>{const i=P(e);return{policies:i.flatMap(r=>E(r,t,s)),roles:i.flatMap(r=>O(r))}},M=(e,t)=>{const s=[],i=new Map;for(const r of h(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),c=x(t,r);for(const{name:g,receiver:d}of L(n)){const p=S(d,c,g);s.push(...p.policies);for(const l of p.roles)i.has(l.name)||i.set(l.name,l)}}return{policies:s,roles:[...i.values()]}};export{M as default};
|
package/dist/packem_shared/{discoverRlsProcedures-BbSdCvmA.mjs → discoverRlsProcedures-CUfhUqfY.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as l}from"ts-morph";import{listLunoraSourceFiles as c,lunoraRelativePath as f,declarationLineOf as u,findObjectProperty as p}from"./isTestPath-
|
|
1
|
+
import{Node as l}from"ts-morph";import{listLunoraSourceFiles as c,lunoraRelativePath as f,declarationLineOf as u,findObjectProperty as p}from"./isTestPath-DJeZ18i9.mjs";import{j as d,h as m}from"./attribution-B8xa6AeK.mjs";import{t as b}from"./database-calls-Cug60vT9.mjs";import{c as h}from"./classify-procedure-call-BK_MMoue.mjs";import{r as y,p as v}from"./policies-CrNWTJQi.mjs";const P=e=>{const s=[];for(const r of v(e)){const t=p(r,"table");if(!t||!l.isPropertyAssignment(t))continue;const i=t.getInitializer();i&&l.isStringLiteral(i)&&s.push(i.getLiteralText())}return s},T=e=>{const s=y(e);return{rlsTables:s.flatMap(r=>P(r)),usesRls:s.length>0}},g=new Set(["explain","findFirst","findFirstOrThrow","findMany","get","query"]),R=new Set(["delete","deleteMany","insert","insertMany","patch","patchIf","patchMany","replace"]),x=(e,s)=>{if(!l.isVariableDeclaration(e))return;const r=e.getInitializer();if(!r||!l.isCallExpression(r))return;const t=h(r);if(!t)return;const i=t.receiver?T(t.receiver):{rlsTables:[],usesRls:!1},{tablesRead:o,tablesWritten:a}=b(e,g,R);return{exportName:m(e)??e.getName(),file:s,line:u(e),rlsTables:i.rlsTables,tablesRead:o,tablesWritten:a,usesRls:i.usesRls,visibility:t.visibility}},D=(e,s)=>{const r=[];for(const t of c(s)){const i=e.getSourceFile(t)??e.addSourceFileAtPath(t),o=f(s,t);for(const a of d(i)){const n=x(a,o);n&&r.push(n)}}return r};export{D as default};
|
package/dist/packem_shared/{discoverSandboxUsage-Dgvv6F_7.mjs → discoverSandboxUsage-CdrJNRFd.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listLunoraSourceFiles as d}from"./isTestPath-
|
|
1
|
+
import{listLunoraSourceFiles as d}from"./isTestPath-DJeZ18i9.mjs";const f=new Set(["@lunora/agent","@lunora/agent/sandbox"]),t={browserTool:"usesSandboxBrowser",containerFsTool:"usesSandboxContainer",containerTool:"usesSandboxContainer",fsTool:"usesSandboxFs",jsCodeTool:"usesSandboxLoader"},u=()=>({usesSandboxBrowser:!1,usesSandboxContainer:!1,usesSandboxFs:!1,usesSandboxLoader:!1}),i=o=>{const s=u();if(!f.has(o.getModuleSpecifierValue())||o.isTypeOnly())return s;for(const e of o.getNamedImports()){if(e.isTypeOnly())continue;const n=t[e.getNameNode().getText()];n!==void 0&&(s[n]=!0)}return s},b=(o,s)=>{const e=u();for(const n of d(s)){const c=o.getSourceFile(n)??o.addSourceFileAtPath(n);for(const a of c.getImportDeclarations()){const l=i(a);for(const r of Object.values(t))e[r]||=l[r]}if(Object.values(t).every(a=>e[a]))break}return e};export{b as discoverSandboxUsage,u as noSandboxUsage,i as scanImportDeclaration};
|