@lunora/codegen 1.0.0-alpha.150 → 1.0.0-alpha.152
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.d.mts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/AGENTS_FILENAME-CRdh_pOr.mjs +1 -0
- package/dist/packem_shared/CONTAINERS_FILENAME-BssQL6eI.mjs +1 -0
- package/dist/packem_shared/FLAGS_FILENAME-Bn_wWM4d.mjs +1 -0
- package/dist/packem_shared/{GENERATED_HEADER--PCtJMQc.mjs → GENERATED_HEADER-w7DB5GZI.mjs} +1 -1
- package/dist/packem_shared/NOTIFY_FILENAME-BH0djo6F.mjs +1 -0
- package/dist/packem_shared/{OPENRPC_VERSION-C4UXIUyy.mjs → OPENRPC_VERSION-BAgBIsQM.mjs} +1 -1
- package/dist/packem_shared/QUEUES_FILENAME-CIfuMMG3.mjs +1 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-S3Ey8df4.mjs +9 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-CWESEYLi.mjs +2 -0
- package/dist/packem_shared/{SchemaSnapshotParseError-yZc-1mxR.mjs → SchemaSnapshotParseError-yrVM8bTa.mjs} +1 -1
- package/dist/packem_shared/WORKFLOWS_FILENAME-CSqONfHS.mjs +1 -0
- package/dist/packem_shared/{buildOpenApiDocument-D5xOB07T.mjs → buildOpenApiDocument-ZdoDQXmt.mjs} +1 -1
- package/dist/packem_shared/chain-DboeOxBl.mjs +1 -0
- package/dist/packem_shared/classify-procedure-call-CRm5Etni.mjs +1 -0
- package/dist/packem_shared/context-property-calls-CBUh7oAY.mjs +1 -0
- package/dist/packem_shared/discoverAuthApiCalls-B5Qmjmyk.mjs +1 -0
- package/dist/packem_shared/discoverCrons-c0ig327z.mjs +1 -0
- package/dist/packem_shared/discoverFunctions-DeuEs6Ce.mjs +1 -0
- package/dist/packem_shared/discoverHttpRoutes-zWSSyyOj.mjs +1 -0
- package/dist/packem_shared/discoverHyperdriveCalls-C6kV2CPz.mjs +1 -0
- package/dist/packem_shared/discoverInserts-BB7o_8pU.mjs +1 -0
- package/dist/packem_shared/discoverMaskProcedures-CNqwOwXv.mjs +1 -0
- package/dist/packem_shared/discoverMigrations-CQjGLKW-.mjs +1 -0
- package/dist/packem_shared/discoverNondeterministicCalls-B07wjsd2.mjs +1 -0
- package/dist/packem_shared/discoverQueries-Dz2vDpE9.mjs +1 -0
- package/dist/packem_shared/discoverR2sqlCalls-CuHe5smg.mjs +1 -0
- package/dist/packem_shared/discoverRlsMetadata-CXWVNLk4.mjs +1 -0
- package/dist/packem_shared/discoverRlsProcedures-DXdr9YHi.mjs +1 -0
- package/dist/packem_shared/discoverSandboxUsage-BJHLHZR_.mjs +1 -0
- package/dist/packem_shared/discoverStorageRulesMetadata-CUa2Dtb4.mjs +1 -0
- package/dist/packem_shared/{emit-CXfWb_pY.mjs → emit-Dsr5DNpc.mjs} +291 -129
- package/dist/packem_shared/{emitApp-DcrQNgaz.mjs → emitApp-kFg_xYlc.mjs} +10 -2
- package/dist/packem_shared/{exported-procedure-chains-M40rbSYM.mjs → exported-procedure-chains-Cmt3Pr92.mjs} +1 -1
- package/dist/packem_shared/index-BsVoa-4F.mjs +1 -0
- package/dist/packem_shared/listLunoraSourceFiles-BvqYMy81.mjs +1 -0
- package/dist/packem_shared/queries-D8DheHbi.mjs +1 -0
- package/package.json +10 -10
- package/dist/packem_shared/AGENTS_FILENAME-B1Abt3Gl.mjs +0 -1
- package/dist/packem_shared/CONTAINERS_FILENAME-CtcysaKS.mjs +0 -1
- package/dist/packem_shared/FLAGS_FILENAME-B3VZ6vTw.mjs +0 -1
- package/dist/packem_shared/NOTIFY_FILENAME-CKO5gtGe.mjs +0 -1
- package/dist/packem_shared/QUEUES_FILENAME-C-pzLGy4.mjs +0 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DazENDSB.mjs +0 -9
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-B1BUjuG5.mjs +0 -2
- package/dist/packem_shared/WORKFLOWS_FILENAME-BfvqsG9Z.mjs +0 -1
- package/dist/packem_shared/ast-BYoSZlae.mjs +0 -1
- package/dist/packem_shared/chain-Dygm2apY.mjs +0 -1
- package/dist/packem_shared/classify-procedure-call-Ib2EMtFH.mjs +0 -1
- package/dist/packem_shared/context-property-calls-Br0sVv8E.mjs +0 -1
- package/dist/packem_shared/discoverAuthApiCalls-DoNQSgso.mjs +0 -1
- package/dist/packem_shared/discoverCrons-DCxl4hty.mjs +0 -1
- package/dist/packem_shared/discoverFunctions-CXURzTDU.mjs +0 -1
- package/dist/packem_shared/discoverHttpRoutes-2XhMbeh5.mjs +0 -1
- package/dist/packem_shared/discoverHyperdriveCalls-DTq4PKT5.mjs +0 -1
- package/dist/packem_shared/discoverInserts-qU5F4W4g.mjs +0 -1
- package/dist/packem_shared/discoverMaskProcedures-BZsC5dHd.mjs +0 -1
- package/dist/packem_shared/discoverMigrations-BFkJQ8Sy.mjs +0 -1
- package/dist/packem_shared/discoverNondeterministicCalls-B-NNzzPW.mjs +0 -1
- package/dist/packem_shared/discoverQueries-B4emAFn5.mjs +0 -1
- package/dist/packem_shared/discoverR2sqlCalls-C2GtrFnl.mjs +0 -1
- package/dist/packem_shared/discoverRlsMetadata-BKcUnSNr.mjs +0 -1
- package/dist/packem_shared/discoverRlsProcedures-fAhxiIyD.mjs +0 -1
- package/dist/packem_shared/discoverSandboxUsage-CJhnKA0_.mjs +0 -1
- package/dist/packem_shared/discoverStorageRulesMetadata-C7XmORWp.mjs +0 -1
- package/dist/packem_shared/index-xGhyK9J_.mjs +0 -1
- package/dist/packem_shared/queries-Ddvo5dCs.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as i}from"ts-morph";import{p as m,a as l}from"./parse-validator-CMV0eq2a.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./listLunoraSourceFiles-BvqYMy81.mjs";import{u as f}from"./unwrap-handler-return-CmIWbykC.mjs";const u=new Set(["delete","get","head","options","patch","post","put"]),g=new Set(["body","params","searchParams"]),E=new Set(["handler","stream"]),v=r=>{const e=r.getArguments()[0];if(e&&i.isStringLiteral(e))return e.getLiteralValue()},x=r=>{const e=r.getArguments()[0];return e&&i.isObjectLiteralExpression(e)?l(e):{}},P=r=>{if(!i.isCallExpression(r))return;const e=r.getExpression();if(!i.isPropertyAccessExpression(e))return;const o=e.getName();if(!u.has(o))return;const n=e.getExpression();if(!i.isIdentifier(n)||n.getText()!=="httpRoute")return;const s=v(r);return s===void 0?void 0:{method:o.toUpperCase(),path:s}},S=(r,e)=>{const o={body:{},params:{},searchParams:{},stream:e==="stream"},n=r.getExpression();if(!i.isPropertyAccessExpression(n))return;let s=n.getExpression();for(;i.isCallExpression(s);){const a=s.getExpression();if(!i.isPropertyAccessExpression(a))break;const c=a.getName();if(u.has(c))break;if(g.has(c)){const p=x(s);o[c]={...p,...o[c]}}else if(c==="output"&&o.output===void 0){const p=s.getArguments()[0];p&&i.isExpression(p)&&(o.output=m(p))}s=a.getExpression()}const t=P(s);if(t)return o.method=t.method,o.path=t.path,o},A=r=>{const e=r.getArguments()[0];return!e||!(i.isArrowFunction(e)||i.isFunctionExpression(e))?"unknown":f(e)},T=(r,e,o,n)=>{const s=e.getName();if(!E.has(s))return;const t=S(r,s);if(!(t?.method===void 0||t.path===void 0))return{body:t.body,exportName:o,filePath:n,method:t.method,params:t.params,path:t.path,searchParams:t.searchParams,stream:t.stream,...t.stream?{chunkType:A(r)}:{},...t.output?{output:t.output}:{}}},b=(r,e)=>{const o=[];for(const n of r.getVariableStatements())if(n.isExported())for(const s of n.getDeclarations()){const t=s.getInitializer();if(!t||!i.isCallExpression(t))continue;const a=t.getExpression();if(!i.isPropertyAccessExpression(a))continue;const c=T(t,a,s.getName(),e);c&&o.push(c)}return o},F=(r,e)=>{const o=d(e),n=[];for(const s of o){const t=r.getSourceFile(s)??r.addSourceFileAtPath(s),a=h(e,s);n.push(...b(t,a))}return n.sort((s,t)=>`${s.method} ${s.path}`.localeCompare(`${t.method} ${t.path}`)||s.filePath.localeCompare(t.filePath)),n};export{F as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as o}from"./context-property-calls-CBUh7oAY.mjs";const t=(r,e)=>o(r,e,"sql");export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SyntaxKind as c,Node as n}from"ts-morph";import{listLunoraSourceFiles as f,lunoraRelativePath as u,enclosingExportName as g,isDatabaseAccessor as d}from"./listLunoraSourceFiles-BvqYMy81.mjs";const m=t=>{const e=t.getExpression();if(!n.isPropertyAccessExpression(e)||e.getName()!=="insert")return!1;const r=e.getExpression();return d(r)},p=t=>{if(!n.isIdentifier(t))return;const e=t.getSymbol(),r=e?.getAliasedSymbol()?.getDeclarations()??e?.getDeclarations()??[];for(const i of r)if(n.isVariableDeclaration(i)){const s=i.getInitializer();if(s&&n.isStringLiteral(s))return s.getLiteralText()}},x=t=>{const e=t.getArguments()[0];return e?n.isStringLiteral(e)?e.getLiteralText():p(e)??"":""},v=(t,e)=>{const r=[];for(const i of f(e)){const s=t.getSourceFile(i)??t.addSourceFileAtPath(i),l=u(e,i);for(const o of s.getDescendantsOfKind(c.CallExpression)){if(!m(o))continue;const a=g(o);a!==""&&r.push({exportName:a,file:l,line:o.getStartLineNumber(),table:x(o)})}}return r};export{v as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./listLunoraSourceFiles-BvqYMy81.mjs";import"./classify-procedure-call-CRm5Etni.mjs";import{d as p}from"./index-BsVoa-4F.mjs";export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SyntaxKind as f,Node as s}from"ts-morph";import{diagnosticAt as u}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as m}from"./module-specifiers-WF8iAydP.mjs";import{listLunoraSourceFiles as p,lunoraRelativePath as h}from"./listLunoraSourceFiles-BvqYMy81.mjs";const I=r=>{const i=r.getSymbol();if(!i)return r.getText()==="defineMigration";for(const t of i.getDeclarations())if(s.isImportSpecifier(t))return m(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMigration":!1;return!1},d=(r,i)=>{const t=r.getProperty(i);if(!t||!s.isPropertyAssignment(t))return;const e=t.getInitializer();return e&&s.isStringLiteral(e)?e.getLiteralValue():void 0},P=(r,i)=>{const t=r.getInitializer();if(t?.getKind()!==f.CallExpression)return;const e=t.getExpression();if(!s.isIdentifier(e)||!I(e))return;const o=t.getArguments()[0];if(!o||!s.isObjectLiteralExpression(o))return;const n=d(o,"id"),a=r.getName();if(n===void 0||n.trim()==="")throw u(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)}},y=(r,i)=>{const t=p(i),e=[];for(const o of t){const n=r.getSourceFile(o)??r.addSourceFileAtPath(o),a=h(i,o);for(const c of n.getVariableStatements())if(c.isExported())for(const g of c.getDeclarations()){const l=P(g,a);l&&e.push(l)}}return e.sort((o,n)=>o.id.localeCompare(n.id)),M(e),e};export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as s,SyntaxKind as a}from"ts-morph";import{listLunoraSourceFiles as c,lunoraRelativePath as l,handlerOf as d}from"./listLunoraSourceFiles-BvqYMy81.mjs";import{c as f}from"./classify-procedure-call-CRm5Etni.mjs";const u={"crypto.getRandomValues":"crypto.getRandomValues","crypto.randomUUID":"crypto.randomUUID","Date.now":"Date.now","Math.random":"Math.random"},m=new Set(["globalThis","self"]),g=new Set(["globalThis","self","window"]),p=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()}},h=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=p(t.getExpression());if(i!==void 0)return n==="fetch"&&m.has(i)?"fetch":u[`${i}.${n}`]},x=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"},N=e=>{const t=e.getInitializer();if(!t||!s.isCallExpression(t))return;const n=f(t);if(!n||n.kind!=="query"&&n.kind!=="mutation")return;const i=d(t,n.receiver);return i?{exportName:e.getName(),handler:i,kind:n.kind}:void 0},E=(e,t)=>{const n=[];for(const i of e.handler.getDescendantsOfKind(a.CallExpression)){const o=h(i);o!==void 0&&n.push({callee:o,exportName:e.exportName,file:t,kind:e.kind,line:i.getStartLineNumber()})}for(const i of e.handler.getDescendantsOfKind(a.NewExpression)){const o=x(i);o!==void 0&&n.push({callee:o,exportName:e.exportName,file:t,kind:e.kind,line:i.getStartLineNumber()})}return n},S=(e,t)=>{const n=[];for(const i of e.getVariableStatements())if(i.isExported())for(const o of i.getDeclarations()){const r=N(o);r&&n.push(...E(r,t))}return n},w=(e,t)=>{const n=[];for(const i of c(t)){const o=e.getSourceFile(i)??e.addSourceFileAtPath(i);n.push(...S(o,l(t,i)))}return n};export{w as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as a}from"./queries-D8DheHbi.mjs";import"./listLunoraSourceFiles-BvqYMy81.mjs";export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as r}from"./context-property-calls-CBUh7oAY.mjs";const t=(s,o)=>r(s,o,"r2sql");export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as o}from"ts-morph";import{listLunoraSourceFiles as d,lunoraRelativePath as x,stringPropertyOf as c}from"./listLunoraSourceFiles-BvqYMy81.mjs";import{e as h}from"./exported-procedure-chains-Cmt3Pr92.mjs";import{r as A}from"./chain-DboeOxBl.mjs";const L=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||!L.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=e.getProperty("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},E=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"))}},v=e=>{const t=e.getArguments()[1];if(!t||!o.isObjectLiteralExpression(t))return[];const i=t.getProperty("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=E(n);a&&s.push(a)}return s},y=(e,t,i)=>{const r=A(e);return{policies:r.flatMap(s=>P(s,t,i)),roles:r.flatMap(s=>v(s))}},F=(e,t)=>{const i=[],r=new Map;for(const s of d(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),a=x(t,s);for(const{name:m,receiver:g}of h(n)){const p=y(g,a,m);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{F as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as o}from"ts-morph";import{listLunoraSourceFiles as f,lunoraRelativePath as u,tablesAccessedIn as d}from"./listLunoraSourceFiles-BvqYMy81.mjs";import{c as p}from"./classify-procedure-call-CRm5Etni.mjs";import{r as m}from"./chain-DboeOxBl.mjs";const b=e=>{const t=e.getArguments()[0];if(!t||!o.isArrayLiteralExpression(t))return[];const s=[];for(const r of t.getElements()){if(!o.isObjectLiteralExpression(r))continue;const i=r.getProperty("table");if(!i||!o.isPropertyAssignment(i))continue;const n=i.getInitializer();n&&o.isStringLiteral(n)&&s.push(n.getLiteralText())}return s},g=e=>{const t=m(e);return{rlsTables:t.flatMap(s=>b(s)),usesRls:t.length>0}},h=new Set(["findFirst","findFirstOrThrow","findMany","get","query"]),y=new Set(["delete","deleteMany","insert","insertMany","patch","patchMany","replace"]),v=(e,t)=>{if(!o.isVariableDeclaration(e))return;const s=e.getInitializer();if(!s||!o.isCallExpression(s))return;const r=p(s);if(!r)return;const i=r.receiver?g(r.receiver):{rlsTables:[],usesRls:!1},{tablesRead:n,tablesWritten:l}=d(e,h,y);return{exportName:e.getName(),file:t,rlsTables:i.rlsTables,tablesRead:n,tablesWritten:l,usesRls:i.usesRls,visibility:r.visibility}},S=(e,t)=>{const s=[];for(const r of f(t)){const i=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=u(t,r);for(const l of i.getVariableStatements())if(l.isExported())for(const c of l.getDeclarations()){const a=v(c,n);a&&s.push(a)}}return s};export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{listLunoraSourceFiles as l}from"./listLunoraSourceFiles-BvqYMy81.mjs";const i=new Set(["@lunora/agent","@lunora/agent/sandbox"]),a={browserTool:"usesSandboxBrowser",containerTool:"usesSandboxContainer",fsTool:"usesSandboxFs"},u=()=>({usesSandboxBrowser:!1,usesSandboxContainer:!1,usesSandboxFs:!1}),d=o=>{const s=u();if(!i.has(o.getModuleSpecifierValue())||o.isTypeOnly())return s;for(const e of o.getNamedImports()){if(e.isTypeOnly())continue;const n=a[e.getNameNode().getText()];n!==void 0&&(s[n]=!0)}return s},b=(o,s)=>{const e=u();for(const n of l(s)){const c=o.getSourceFile(n)??o.addSourceFileAtPath(n);for(const t of c.getImportDeclarations()){const f=d(t);for(const r of Object.values(a))e[r]||=f[r]}if(Object.values(a).every(t=>e[t]))break}return e};export{b as discoverSandboxUsage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Node as u}from"ts-morph";import{listLunoraSourceFiles as f,lunoraRelativePath as p,stringPropertyOf as l}from"./listLunoraSourceFiles-BvqYMy81.mjs";import{w as d}from"./classify-procedure-call-CRm5Etni.mjs";import{e as m}from"./exported-procedure-chains-Cmt3Pr92.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};
|