@lunora/codegen 1.0.0-alpha.356 → 1.0.0-alpha.358
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 +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AGENTS_FILENAME-isdHqPIt.mjs → AGENTS_FILENAME-MkkvnsUE.mjs} +1 -1
- package/dist/packem_shared/CONTAINERS_FILENAME-bE-y0B87.mjs +1 -0
- package/dist/packem_shared/{FLAGS_FILENAME-BQk3SX8D.mjs → FLAGS_FILENAME-_nmXVMje.mjs} +1 -1
- package/dist/packem_shared/{GENERATED_HEADER-BXK9A_wP.mjs → GENERATED_HEADER-BPc7maFN.mjs} +1 -1
- package/dist/packem_shared/{MUTATORS_FILENAME-Cy9h3EVW.mjs → MUTATORS_FILENAME-Y5_Dxk1E.mjs} +1 -1
- package/dist/packem_shared/{NOTIFY_FILENAME-9to_l_Kh.mjs → NOTIFY_FILENAME-BXAiPzbD.mjs} +1 -1
- package/dist/packem_shared/{OPENRPC_VERSION-DfSmacMR.mjs → OPENRPC_VERSION-TX2C_rJT.mjs} +1 -1
- package/dist/packem_shared/{QUEUES_FILENAME-Civ-7SiI.mjs → QUEUES_FILENAME-DEW3hmFm.mjs} +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-Z18YPqk_.mjs +31 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs +2 -0
- package/dist/packem_shared/{SHAPES_FILENAME-DVJbfDZ8.mjs → SHAPES_FILENAME-B40f_T6B.mjs} +1 -1
- package/dist/packem_shared/{SchemaSnapshotParseError-H9eQX4ui.mjs → SchemaSnapshotParseError-CjKSMuex.mjs} +1 -1
- package/dist/packem_shared/{WORKFLOWS_FILENAME-kXq07aGl.mjs → WORKFLOWS_FILENAME-WZhRFaoW.mjs} +1 -1
- package/dist/packem_shared/attribution-ILDWgo1x.mjs +1 -0
- package/dist/packem_shared/{buildOpenApiDocument-DWdj2jvW.mjs → buildOpenApiDocument-20bRusvI.mjs} +1 -1
- package/dist/packem_shared/capabilitiesUsedBy-CIms8agu.mjs +1 -0
- package/dist/packem_shared/chain-COp_5hZ4.mjs +1 -0
- package/dist/packem_shared/{classify-procedure-call-BkaeM9Ej.mjs → classify-procedure-call-CGyiEHy1.mjs} +1 -1
- package/dist/packem_shared/{context-property-calls-dFjpeIlP.mjs → context-property-calls-Bj3YOlL1.mjs} +1 -1
- package/dist/packem_shared/{context-root-CNR6TAsP.mjs → context-root-ChKZ81ma.mjs} +1 -1
- package/dist/packem_shared/{createCodegenProject-ClPr_MXM.mjs → createCodegenProject-BinzLGxq.mjs} +1 -1
- package/dist/packem_shared/{database-calls-UPlhi3Ks.mjs → database-calls-BklD-ffT.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-CScPrUD-.mjs → discoverAuthApiCalls-cxNhFbVB.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-B1_NUt19.mjs → discoverCrons-C5MhFDni.mjs} +1 -1
- package/dist/packem_shared/{discoverFunctions-CJG4S6CK.mjs → discoverFunctions-BCsT7GQS.mjs} +1 -1
- package/dist/packem_shared/{discoverHttpRoutes-DCDgDIYv.mjs → discoverHttpRoutes-DwbVREYV.mjs} +1 -1
- package/dist/packem_shared/discoverHyperdriveCalls-Ca9U-rY9.mjs +1 -0
- package/dist/packem_shared/{discoverInserts-BcoTjXqI.mjs → discoverInserts-6cgh3ZTP.mjs} +1 -1
- package/dist/packem_shared/discoverMaskProcedures-B5jXqwvB.mjs +1 -0
- package/dist/packem_shared/{discoverMigrations-BWxx8Wv9.mjs → discoverMigrations-PQUwbVwP.mjs} +1 -1
- package/dist/packem_shared/{discoverNondeterministicCalls-mFJNU8qY.mjs → discoverNondeterministicCalls-Br_sPo8Z.mjs} +1 -1
- package/dist/packem_shared/{discoverQueries-CxQRVuIV.mjs → discoverQueries-BJCIpowp.mjs} +1 -1
- package/dist/packem_shared/discoverR2sqlCalls-D2OK5ZWP.mjs +1 -0
- package/dist/packem_shared/{discoverRlsMetadata-D0B4nCmG.mjs → discoverRlsMetadata-DmzmJtoo.mjs} +1 -1
- package/dist/packem_shared/{discoverRlsProcedures-Cl6UKT7L.mjs → discoverRlsProcedures-DEwd3N-e.mjs} +1 -1
- package/dist/packem_shared/{discoverSandboxUsage--Z1vx7GM.mjs → discoverSandboxUsage-q0SIdjyQ.mjs} +1 -1
- package/dist/packem_shared/discoverSchema-BM_ZW7Z1.mjs +1 -0
- package/dist/packem_shared/{discoverStorageRulesMetadata-CitX6ziW.mjs → discoverStorageRulesMetadata-DFRtQeRb.mjs} +1 -1
- package/dist/packem_shared/{emitAgents--VDKoet4.mjs → emitAgents-CwwzVPZe.mjs} +1 -1
- package/dist/packem_shared/{emitApi-zynTVppI.mjs → emitApi-CCjh0ICg.mjs} +18 -18
- package/dist/packem_shared/{emitApp-C0shqv7S.mjs → emitApp-CT7iAjam.mjs} +1 -1
- package/dist/packem_shared/{emitCrons-DF9vt_z_.mjs → emitCrons-CY8IQfAI.mjs} +1 -1
- package/dist/packem_shared/{emitDataModel-CuFqq97x.mjs → emitDataModel-Bba2y2yt.mjs} +1 -1
- package/dist/packem_shared/{emitDrizzleSchema-bct1OuH5.mjs → emitDrizzleSchema-CD4hPtUP.mjs} +1 -1
- package/dist/packem_shared/{emitFunctions-D7mopPiT.mjs → emitFunctions-C3WOlVN0.mjs} +1 -1
- package/dist/packem_shared/{emitServer-RXgOOH_b.mjs → emitServer-C2zwuJvT.mjs} +1 -1
- package/dist/packem_shared/emitShard-CPRV7dSh.mjs +1 -0
- package/dist/packem_shared/{exported-procedure-chains-D1WlRfqJ.mjs → exported-procedure-chains-BX5nIQAe.mjs} +1 -1
- package/dist/packem_shared/{fingerprintSchemaSources-BKXkgkj4.mjs → fingerprintSchemaSources-C8hE4K08.mjs} +1 -1
- package/dist/packem_shared/{handler-reference-CClSR4bi.mjs → handler-reference-D5sW4xun.mjs} +1 -1
- package/dist/packem_shared/{index-CN8FVvr-.mjs → index-2eZFYBau.mjs} +1 -1
- package/dist/packem_shared/isTestPath-BrBtG0bz.mjs +1 -0
- package/dist/packem_shared/{module-specifiers-BctA0m_p.mjs → module-specifiers-WF8iAydP.mjs} +1 -1
- package/dist/packem_shared/{modules-l-Db0C4S.mjs → modules-CsEUB8s1.mjs} +1 -1
- package/dist/packem_shared/{parse-validator-iVTounLK.mjs → parse-validator-CP5CL6Q7.mjs} +1 -1
- package/dist/packem_shared/{qualifiers-Bl5fSmav.mjs → qualifiers-vzi-FQv3.mjs} +1 -1
- package/dist/packem_shared/{server-CeYggUIZ.mjs → server-DCjunXFf.mjs} +1 -1
- package/dist/packem_shared/{shard-ByB2lGh0.mjs → shard-gWobaDx2.mjs} +1 -1
- package/dist/packem_shared/{shard-runtime-ByYXjCKY.mjs → shard-runtime-DXlpfT3P.mjs} +1 -1
- package/dist/packem_shared/{shared-8vTRkL2-.mjs → shared-Br_OnErI.mjs} +1 -1
- package/dist/packem_shared/{unwrap-handler-return-CGdJGvGh.mjs → unwrap-handler-return-B79Rd7T0.mjs} +1 -1
- package/package.json +8 -8
- package/dist/packem_shared/CONTAINERS_FILENAME-mK4cZpcz.mjs +0 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DB8KkcgP.mjs +0 -31
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-C7Um0EnM.mjs +0 -2
- package/dist/packem_shared/attribution-CG8-kUcl.mjs +0 -1
- package/dist/packem_shared/capabilitiesUsedBy-DjRHg-Zk.mjs +0 -1
- package/dist/packem_shared/chain-74gjwZMP.mjs +0 -1
- package/dist/packem_shared/discoverHyperdriveCalls-CL-d0IVo.mjs +0 -1
- package/dist/packem_shared/discoverMaskProcedures-Bw-BOIbA.mjs +0 -1
- package/dist/packem_shared/discoverR2sqlCalls-B4oeTYEM.mjs +0 -1
- package/dist/packem_shared/discoverSchema-CGAFQxFU.mjs +0 -1
- package/dist/packem_shared/emitShard-CYjlTMmT.mjs +0 -1
- package/dist/packem_shared/isTestPath-C3QumE88.mjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as C}from"@lunora/errors";import{Node as i,SyntaxKind as B}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{createRequire as V}from"node:module";import{join as _}from"node:path";import{fileURLToPath as q}from"node:url";import{createJiti as J}from"jiti";import{findObjectProperty as u}from"./isTestPath-C3QumE88.mjs";import{r as U,p as K}from"./parse-validator-iVTounLK.mjs";import{R as W}from"./reserved-words-CW1QFbTd.mjs";import{a as w}from"./property-name-7cBlgK_O.mjs";const Z=(e,t)=>`table "${e}" is .global() and declares vector index "${t}". Vector sync runs on the shard write path, which a global (D1/Hyperdrive) table's writes never take — the index would stay empty. Drop .global(), or keep the index yourself with ctx.vectors.upsert/deleteByIds.`,G=e=>{switch(typeof e){case"bigint":return e.toString();case"boolean":case"number":return String(e);case"string":return JSON.stringify(e);default:return e===null?"null":void 0}},X=e=>({...e?.defaultValue!==void 0||e?.defaultFn!==void 0||e?.serverDefault!==void 0?{hasDefault:!0}:{},...e?.onUpdateFn===void 0?{}:{hasOnUpdate:!0},notNull:e?.notNull??!0,...e?.unique===!0?{unique:!0}:{}}),g=e=>{const t=e?._meta??{},n=e?.kind??"unknown",s={column:X(t.column),kind:n};switch(n){case"array":case"optional":{s.inner=g(t.inner);break}case"from":break;case"id":{s.tableName=t.tableName;break}case"literal":{s.literalValue=G(t.value);break}case"object":{const r=t.shape??{};s.shape=Object.fromEntries(Object.entries(r).map(([o,a])=>[o,g(a)]));break}case"record":{s.valueType=g(t.valueValidator),t.keyValidator!==void 0&&(s.keyType=g(t.keyValidator));break}case"storage":{typeof t.bucket=="string"&&(s.bucket=t.bucket);break}case"union":{const r=t.members??[];s.members=r.map(o=>g(o));break}}return s},H=e=>e?.kind==="global"?"global":e?.kind==="shardBy"&&typeof e.field=="string"?{field:e.field,kind:"shardBy"}:"root",Q=(e,t)=>{const n=[];e.relationMap&&Object.keys(e.relationMap).length>0&&n.push("relations"),e.rankIndexes&&e.rankIndexes.length>0&&n.push("rank indexes"),e.vectorIndexes&&e.vectorIndexes.length>0&&n.push("vector indexes"),n.length>0&&console.warn(`@lunora/codegen: package schema-extension table "${t}" declares ${n.join(" + ")}, which are not yet introspected from a node_modules extension — they will be absent from the generated types.`)},Y=(e,t)=>{const n=e.shape??{},s=(e.indexes??[]).map(r=>({fields:r.fields,name:r.name,...r.unique?{unique:!0}:{}}));return Q(e,t),{...e.isExternallyManaged?{externallyManaged:!0}:{},geoIndexes:[],indexes:s,name:t,rankIndexes:[],relations:[],searchIndexes:(e.searchIndexes??[]).map(r=>({field:r.field,...r.filterFields?{filterFields:r.filterFields}:{},...r.language===void 0?{}:{language:r.language},...r.staged===void 0?{}:{staged:r.staged},...r.strategy===void 0?{}:{strategy:r.strategy},name:r.name})),shape:Object.fromEntries(Object.entries(n).map(([r,o])=>[r,g(o)])),shardMode:H(e.shardMode),vectorIndexes:[]}},ee=e=>{const{key:t,tables:n}=e;if(typeof t!="string"||typeof n!="object"||n===null)return;const s=Object.entries(n).map(([a,l])=>Y(l,a)),r=e.vectorIndexes??{},o=Object.entries(r??{}).map(([a,l])=>({...l.dimensions===void 0?{}:{dimensions:l.dimensions},...l.field===void 0?{}:{field:l.field},...l.metadata===void 0?{}:{metadata:l.metadata},...l.metric===void 0?{}:{metric:l.metric},name:a,table:l.table??""}));return{bareTables:s,bareVectorIndexes:o,key:t}},te=e=>{if(i.isIdentifier(e))return e.getText();if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return i.isIdentifier(t)?t.getText():void 0}},ne=e=>{const t=te(e);if(t===void 0)return;const n=i.isPropertyAccessExpression(e)?e.getName():void 0,s=n===void 0?[]:[n];for(const r of e.getSourceFile().getImportDeclarations()){const o=r.getModuleSpecifierValue();for(const a of r.getNamedImports())if((a.getAliasNode()?.getText()??a.getName())===t)return{importedName:a.getName(),moduleSpecifier:o,propertyPath:s};if(r.getDefaultImport()?.getText()===t)return{importedName:"default",moduleSpecifier:o,propertyPath:s};if(r.getNamespaceImport()?.getText()===t&&n!==void 0)return{importedName:n,moduleSpecifier:o,propertyPath:[]}}},re=(e,t)=>{let n=e[t.importedName];for(const s of t.propertyPath){if(typeof n!="object"||n===null)return;n=n[s]}return n},se=(e,t)=>{const n=ne(e);if(n)try{const s=J(_(t,"noop.js")).esmResolve(n.moduleSpecifier),r=V(_(t,"noop.cjs"))(s.startsWith("file:")?q(s):s),o=re(r,n);return typeof o!="object"||o===null?void 0:ee(o)}catch{return}},ie=new Set(["cosine","dot-product","euclidean"]),b=(e,t)=>{const n=u(e,t);if(n&&i.isPropertyAssignment(n))return n.getInitializer()},f=(e,t)=>{const n=b(e,t);if(n&&i.isStringLiteral(n))return n.getLiteralText()},y=(e,t)=>{const n=b(e,t);if(n&&i.isNumericLiteral(n))return Number(n.getLiteralText())},N=(e,t)=>{const n=b(e,t);if(n&&(i.isTrueLiteral(n)||i.isFalseLiteral(n)))return n.getLiteralValue()},v=(e,t)=>{const n=b(e,t);if(n&&i.isArrayLiteralExpression(n))return n.getElements().filter(s=>i.isStringLiteral(s)).map(s=>s.getLiteralText())},P=e=>e&&ie.has(e)?e:void 0,E=e=>e&&i.isStringLiteral(e)?e.getLiteralText():"_unnamed_",oe=(e,t)=>{const n=v(e,t);return n!==void 0&&n.length>0?n:void 0},j=(e,t,n,s,r)=>{let o=e;for(;;){const a=o.getParent();if(!a||!i.isPropertyAccessExpression(a))break;const l=a.getParent();if(!l||!i.isCallExpression(l))break;if(a.getName()===t){const d=l.getArguments()[0];if(!d||!i.isStringLiteral(d))throw c(l,`\`.${t}(...)\` expects a string literal (${r})`);const m=d.getLiteralText();if(!s.has(m))throw c(d,`unknown ${n} ${JSON.stringify(m)} — expected ${r}`);return m}o=l}},ae=e=>`table "${e}" is both .global() and .ttl(). The TTL sweep is a shard's alarm deleting from that shard's own SQLite, and a global (D1/Hyperdrive) table's rows live outside every shard — so expired rows would never be deleted. Drop .ttl() and expire the rows from a cron, or keep the table shard-local.`,le=/^(?:sqlite_|_cf_|__)/u,ce=/__(?:agg|rank|geo|fts)_/u,de=e=>le.test(e)||ce.test(e),fe=new Set(["cascade","restrict","set null"]),ue=new Set(["aggregate","asId","assertPatchAllowed","cdcChangedTables","count","delete","deleteAll","deleteMany","deleteRereadTables","deleteWhere","explain","findFirst","findFirstOrThrow","findMany","get","groupBy","insert","insertMany","insertManyUnsafe","inTransaction","lookupById","normalizeId","patch","patchIf","patchMany","patchWhere","query","rank","rankBefore","rankPage","rankPageRows","related","relationEdges","relationWrites","replace","restore","softDeleteFields","system","wipeShard"]),$=/^[A-Za-z_$][\w$]*$/u,k=(e,t)=>{if(ue.has(e))throw c(t,`table name "${e}" is reserved — the generated shard binds each table's facade onto the same object that carries \`ctx.db\`'s own members, so this table would overwrite \`ctx.db.${e}\` and every use of it would break. Rename the table.`);if(W.has(e))throw c(t,`table name "${e}" is a reserved JavaScript word — codegen interpolates table names into a bare \`const ${e} = sqliteTable(...)\` binding in the generated Drizzle module, which is a syntax error for a keyword. Rename the table.`);if(!$.test(e))throw c(t,`table name ${JSON.stringify(e)} is not a valid JS identifier — table names are used in generated type names (Doc_<name>) and must match [A-Za-z_$][A-Za-z0-9_$]*. Rename the table.`);if(de(e))throw c(t,`table name ${JSON.stringify(e)} is reserved for framework tables — a leading \`__\` and the \`__agg_\`/\`__rank_\`/\`__geo_\`/\`__fts_\` infixes name Lunora's own bookkeeping and index companions, so the Studio and the admin API hide and refuse such a table. Rename the table.`)},pe=e=>e&&fe.has(e)?e:void 0,ge=e=>{if(!i.isArrowFunction(e))return;let t=e.getBody();if(i.isParenthesizedExpression(t))t=t.getExpression();else if(i.isBlock(t)){const n=t.getStatements().find(s=>i.isReturnStatement(s));t=n&&i.isReturnStatement(n)?n.getExpression()??t:t}return i.isObjectLiteralExpression(t)?t:void 0},me=(e,t,n)=>{const s=i.isPropertyAssignment(e)?e.getInitializer():void 0;if(!s||!i.isObjectLiteralExpression(s))throw c(e,"relation `through` must be an object literal `{ table, from, to }` — codegen resolves it statically.");const[r,o,a]=["table","from","to"].map(l=>f(s,l));if(r===void 0||o===void 0||a===void 0)throw c(s,"relation `through` needs string-literal `table`, `from` and `to` — codegen resolves them statically.");if(o===a)throw c(s,`relation \`through\` has \`from\` and \`to\` both set to "${o}"; a link needs two different columns.`);return{kind:"many",name:t,table:n,through:{from:o,table:r,to:a}}},he=(e,t,n,s)=>{const r=s&&i.isObjectLiteralExpression(s)?s:void 0,o=e==="many"?r?.getProperty("through"):void 0;return o?me(o,t,n):{field:(r&&f(r,"field"))??"_unknown_",kind:e,name:t,onDelete:e==="one"&&r?pe(f(r,"onDelete")):void 0,references:(r&&f(r,"references"))??"_id",table:n}},be=e=>{if(!i.isPropertyAssignment(e))return;const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const n=t.getExpression();if(!i.isPropertyAccessExpression(n))return;const s=n.getName();if(s!=="one"&&s!=="many")return;const[r,o]=t.getArguments();if(!r||!i.isStringLiteral(r))throw c(r??t,`relation target table must be a string literal — codegen resolves relation targets statically. Got ${r?r.getText():"no argument"}.`);const a=r.getLiteralText();return he(s,w(e),a,o)},xe=e=>{const t=ge(e);if(!t)return[];const n=[];for(const s of t.getProperties()){const r=be(s);r&&n.push(r)}return n},ye=(e,t,n)=>{if(!t.includes("."))return;const[s="",...r]=t.split("."),o=`${s}${r.map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join("")}`;throw c(e,`index "${n}" indexes the nested path ${JSON.stringify(t)} — Lunora indexes only top-level columns. Denormalise the value into its own column (e.g. \`${o}\`), index that instead, and keep it in sync with a table \`.triggers()\` beforeInsert/beforeUpdate.`)},ve=e=>{if(!e||!i.isObjectLiteralExpression(e))return!1;const t=u(e,"unique");if(!t||!i.isPropertyAssignment(t))return!1;const n=t.getInitializer();if(n===void 0)return!1;if(!i.isTrueLiteral(n)&&!i.isFalseLiteral(n))throw c(n,`\`unique\` must be a literal \`true\` or \`false\`, got ${JSON.stringify(n.getText())}`);return i.isTrueLiteral(n)},Ee=e=>{const[t,n,s]=e,r=ve(s),o=E(t),a=n&&i.isArrayLiteralExpression(n)?n.getElements():[];for(const d of a)if(!i.isStringLiteral(d))throw c(d,`index "${o}" lists a non-literal field (${JSON.stringify(d.getText())}); codegen reads index fields statically, so every entry must be a string literal.`);const l=a.filter(d=>i.isStringLiteral(d));for(const d of l)ye(d,d.getLiteralText(),o);return{fields:l.map(d=>d.getLiteralText()),name:o,unique:r}},Ie=e=>{const[t,n]=e;let s="_unknown_",r,o,a,l;return n&&i.isObjectLiteralExpression(n)&&(s=f(n,"field")??s,r=v(n,"filterFields"),o=f(n,"language"),a=N(n,"staged"),l=f(n,"strategy")),{field:s,filterFields:r,language:o,name:E(t),staged:a,strategy:l}},we=e=>{const[t,n]=e;let s="_unknown_",r;return n&&i.isObjectLiteralExpression(n)&&(s=f(n,"field")??s,r=y(n,"precision")),{field:s,name:E(t),precision:r}},ke=e=>{const[t,n]=e,s=t&&i.isStringLiteral(t)?t.getLiteralText():"_unknown_";let r;return n&&i.isObjectLiteralExpression(n)&&(r=y(n,"after")),{after:r,field:s}},Se=e=>{if(!i.isObjectLiteralExpression(e))return;const t=f(e,"field");return t===void 0?void 0:{direction:f(e,"direction")==="desc"?"desc":"asc",field:t}},Te=e=>{const[t,n]=e;let s=[],r;if(n&&i.isObjectLiteralExpression(n)){const o=u(n,"sortBy");if(o&&i.isPropertyAssignment(o)){const a=o.getInitializer();a&&i.isArrayLiteralExpression(a)&&(s=a.getElements().map(l=>Se(l)).filter(l=>l!==void 0))}r=v(n,"partitionBy")}return{name:E(t),partitionBy:r,sortBy:s}},Oe=(e,t)=>{const[n,s]=e,r=n&&i.isStringLiteral(n)?n.getLiteralText():"_unknown_";if(!(!s||!i.isObjectLiteralExpression(s)))return{dimensions:y(s,"dimensions"),field:r,metadata:v(s,"metadata"),metric:P(f(s,"metric")),name:f(s,"index")??"_unnamed_",table:t}},_e=e=>{const t=e[0];return t&&i.isObjectLiteralExpression(t)&&f(t,"backend")==="hyperdrive"?"hyperdrive":"d1"},A=(e,t)=>{if(e===void 0)return t;if(!i.isObjectLiteralExpression(e))throw c(e,"the options must be an object literal — codegen reads the column name from the source and cannot evaluate a variable or an expression here.");const n=u(e,"field");if(n===void 0)return t;const s=i.isPropertyAssignment(n)?n.getInitializer():void 0;if(s&&i.isStringLiteral(s))return s.getLiteralText();throw c(n,"`field` must be a string literal — codegen reads the column name from the source and cannot evaluate a constant or an expression here.")},Ae=e=>{const t=e[0];return!t||!i.isObjectLiteralExpression(t)?{binding:"",hasTenantBy:!1,unanalyzable:!0}:{binding:f(t,"binding")??"",columns:oe(t,"columns"),hasReconcile:u(t,"reconcileEveryMs")!==void 0,hasSoftDelete:u(t,"softDeleteColumn")!==void 0,hasTenantBy:u(t,"tenantBy")!==void 0,idColumn:f(t,"idColumn"),mode:f(t,"mode"),query:f(t,"query")}},Le=(e,t,n,s)=>{switch(t){case"aggregateIndex":{e.aggregateIndexed=!0;break}case"commitOrdered":{e.commitOrdered=!0;break}case"externallyManaged":{e.externallyManaged=!0;break}case"geoIndex":{e.geoIndexes.push(we(n));break}case"global":{e.shardMode="global",e.globalBackend=_e(n);break}case"index":{e.indexes.unshift(Ee(n));break}case"memory":{e.memory=!0;break}case"public":{e.isPublic=!0;break}case"rankIndex":{e.rankIndexes.push(Te(n));break}case"relations":{const r=n[0];r&&e.relations.push(...xe(r));break}case"searchIndex":{e.searchIndexes.push(Ie(n));break}case"shardBy":{const r=n[0];e.shardMode={field:r&&i.isStringLiteral(r)?r.getLiteralText():"_unknown_",kind:"shardBy"};break}case"softDelete":{e.softDelete={field:A(n[0],"deletedAt")};break}case"source":{e.externalSource=Ae(n),e.externallyManaged=!0;break}case"timestamps":{e.timestampsFields.push(A(n[0],"updatedAt"));break}case"ttl":{e.ttl=ke(n);break}case"vectorize":{const r=Oe(n,s);r&&e.vectorIndexes.push(r);break}}},L=["__vocab","_config","_content","_data","_docsize","_idx"],Ne=(e,t,n)=>{const s=new Set(n.map(r=>r.name));for(const r of n)for(const o of L){const a=`${r.name}${o}`;if(!s.has(a))continue;const l=o==="__vocab"?`the \`fts5vocab\` companion for "${a}" is created \`IF NOT EXISTS\`, so it silently resolves to "${r.name}"'s — the second index then reads the wrong vocabulary and returns wrong results, with no error`:`creating "${a}" is rejected (\`object name reserved for internal use: SQLITE_ERROR\`), which aborts the shard migration and leaves every sharded table unreadable`;throw c(e,`table "${t}" declares search indexes "${r.name}" and "${a}", whose generated FTS5 tables collide: "${r.name}" already owns "${t}__fts_${a}" as its "${o}" companion, so ${l}. Rename one of them so neither ends with another's name plus ${L.join(", ")}.`)}},Pe=(e,t,n)=>{if(n.ttl!==void 0&&n.shardMode==="global")throw c(e,ae(t))},je=(e,t,n)=>{const{softDelete:s,timestampsFields:r}=n,o={};s&&!(s.field in t)&&(o[s.field]={inner:{column:{notNull:!1},kind:"number"},kind:"optional"});const[a]=r;if(a===void 0)return{...t,...o};if(r.length>1)throw c(e,"`.timestamps()` was called more than once; one table tracks one last-change column.");if(a===s?.field)throw c(e,`\`.softDelete()\` and \`.timestamps()\` both use "${a}"; give one of them another field.`);const l=t[a];if(l===void 0)o[a]={column:{hasDefault:!0,hasOnUpdate:!0,notNull:!0},kind:"timestamp"};else if(l.kind!=="timestamp"||l.column?.hasOnUpdate!==!0||l.column.hasDefault!==!0)throw c(e,`\`.timestamps()\` would add "${a}", but the table already declares it as something other than \`v.timestamp().defaultNow().$onUpdateFn(() => Date.now())\`; remove the column or declare it that way.`);return{...t,...o}},D=(e,t)=>{const n={aggregateIndexed:!1,commitOrdered:!1,externallyManaged:!1,geoIndexes:[],indexes:[],isPublic:!1,memory:!1,rankIndexes:[],relations:[],searchIndexes:[],shardMode:"root",timestampsFields:[],vectorIndexes:[]};let s={},r=e;for(;i.isCallExpression(r);){const o=r.getExpression(),a=r.getArguments();if(i.isPropertyAccessExpression(o))Le(n,o.getName(),a,t),r=o.getExpression();else if(i.isIdentifier(o)&&o.getText()==="defineTable"){const l=a[0];if(l&&i.isObjectLiteralExpression(l))s=K(l);else if(l)throw c(l,`table "${t}" calls defineTable(${JSON.stringify(l.getText())}), but codegen reads the field map syntactically and can only read an object literal. Inline the fields into the defineTable(...) call. To reuse them in an \`.input()\`, derive from the generated \`Doc_${t}\` / \`Insert_${t}\` type instead of sharing the runtime value.`);break}else break}return s=je(e,s,n),Ne(e,t,n.searchIndexes),Pe(e,t,n),{...n.aggregateIndexed?{aggregateIndexed:!0}:{},commitOrdered:n.commitOrdered,externallyManaged:n.externallyManaged,externalSource:n.externalSource,geoIndexes:n.geoIndexes,globalBackend:n.shardMode==="global"?n.globalBackend??"d1":void 0,indexes:n.indexes,isPublic:n.isPublic,memory:n.memory,name:t,rankIndexes:n.rankIndexes,relations:n.relations,searchIndexes:n.searchIndexes,shape:s,shardMode:n.shardMode,softDelete:n.softDelete,ttl:n.ttl,vectorIndexes:n.vectorIndexes}},z=(e,t=[],n=new Set,s=new Set)=>{s.add(e);for(const r of e.getProperties()){if(i.isSpreadAssignment(r)){const a=U(r.getExpression());a!==void 0&&!s.has(a)&&z(a,t,n,s);continue}if(!i.isPropertyAssignment(r))continue;const o=r.getInitializer();if(o){const a=w(r);if(k(a,r.getNameNode()),n.has(a))throw c(r.getNameNode(),`defineSchema({...}): table "${a}" is declared more than once — the earlier declaration would be silently discarded. Remove the duplicate.`);n.add(a),t.push(D(o,a))}}return t},$e=e=>{const t=u(e,"source");if(t&&i.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&i.isObjectLiteralExpression(n))return f(n,"table")??"_unknown_"}return"_unknown_"},De=e=>{if(!i.isPropertyAssignment(e))return;const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const n=t.getExpression();if(!i.isIdentifier(n)||n.getText()!=="defineVectorIndex")return;const s=t.getArguments()[0];if(!s||!i.isObjectLiteralExpression(s))return;const r=e.getNameNode(),o=i.isStringLiteral(r)?r.getLiteralText():r.getText();return{dimensions:y(s,"dimensions"),metric:P(f(s,"metric")),name:o,table:$e(s)}},F=e=>{const t=[];for(const n of e.getProperties()){const s=De(n);s&&t.push(s)}return t},S=(e,t)=>`${e}_${t}`,ze=(e,t)=>{if(!$.test(e))throw c(t,`defineSchemaExtension key ${JSON.stringify(e)} is not a valid JS identifier — it is prefixed onto every table the extension contributes (\`${e}_<table>\`), and table names are used in generated type names (Doc_<name>) and must match [A-Za-z_$][A-Za-z0-9_$]*. Rename the extension key.`)},h=(e,t,n)=>n.has(e)?S(t,e):e,x=(e,t)=>{const n=s=>s===void 0?void 0:x(s,t);return{...e,...e.tableName===void 0?{}:{tableName:t(e.tableName)},...e.inner===void 0?{}:{inner:n(e.inner)},...e.keyType===void 0?{}:{keyType:n(e.keyType)},...e.valueType===void 0?{}:{valueType:n(e.valueType)},...e.members===void 0?{}:{members:e.members.map(s=>x(s,t))},...e.shape===void 0?{}:{shape:Object.fromEntries(Object.entries(e.shape).map(([s,r])=>[s,x(r,t)]))}}},Fe=(e,t,n,s)=>{const r=S(t,e.name);return{...e,extensionKey:t,...s?{extensionFromPackage:!0}:{},name:r,shape:Object.fromEntries(Object.entries(e.shape).map(([o,a])=>[o,x(a,l=>h(l,t,n))])),relations:e.relations.map(o=>{const a=h(o.table,t,n);return o.through===void 0?{...o,table:a}:{...o,table:a,through:{...o.through,table:h(o.through.table,t,n)}}}),vectorIndexes:e.vectorIndexes.map(o=>({...o,table:h(o.table,t,n)}))}},Me=e=>{if(i.isVariableDeclaration(e)||i.isPropertyAssignment(e))return e.getInitializer();if(i.isShorthandPropertyAssignment(e))return e.getNameNode()},Re=e=>{if(!i.isCallExpression(e))return!1;const t=e.getExpression();return i.isIdentifier(t)&&t.getText()==="defineSchemaExtension"},Ce=e=>{if(i.isIdentifier(e))return e;if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return i.isIdentifier(t)?t:void 0}},Be=e=>{if(i.isObjectLiteralExpression(e))return e;if(i.isCallExpression(e)){const t=e.getExpression();let n;if(i.isIdentifier(t)?n=t.getText():i.isPropertyAccessExpression(t)&&(n=t.getName()),n==="definePlugin"){const s=e.getArguments()[1];return s&&i.isObjectLiteralExpression(s)?s:void 0}}},Ve=(e,t)=>{const n=Me(e);if(n){if(i.isPropertyAccessExpression(t)){const s=Be(n);return s?b(s,t.getName()):void 0}return n}},qe=e=>{let t=e,n=0;for(;t&&n<32;){if(n+=1,Re(t))return t;const s=Ce(t),r=s&&i.isIdentifier(s)?s.getSymbol():void 0,a=(r?.getAliasedSymbol()?.getDeclarations()??r?.getDeclarations()??[])[0];if(!a)return;const l=a.getSourceFile();if(l.isInNodeModules()||l.isDeclarationFile())return;t=Ve(a,t)}},Je=e=>{const[t,n]=e.getArguments();if(!(!t||!i.isStringLiteral(t))&&!(!n||!i.isObjectLiteralExpression(n)))return{key:t.getLiteralText(),keyNode:t,options:n}},Ue=e=>{const t=u(e,"tables");if(!t||!i.isPropertyAssignment(t))return[];const n=t.getInitializer();if(!n||!i.isObjectLiteralExpression(n))return[];const s=[];for(const r of n.getProperties()){if(!i.isPropertyAssignment(r))continue;const o=r.getInitializer();if(!o)continue;const a=w(r);k(a,r.getNameNode()),s.push(D(o,a))}return s},Ke=e=>{const t=u(e,"vectorIndexes");if(!t||!i.isPropertyAssignment(t))return[];const n=t.getInitializer();return!n||!i.isObjectLiteralExpression(n)?[]:F(n)},M=(e,t,n,s,r)=>{ze(e,s);const o=new Set(t.map(d=>d.name)),a=t.map(d=>Fe(d,e,o,r)),l=n.map(d=>({...d,name:S(e,d.name),table:h(d.table,e,o)}));return{tables:a,vectorIndexes:l}},We=(e,t,n)=>M(e,Ue(n),Ke(n),t,t.getSourceFile().getFilePath().includes("/node_modules/")),Ze=(e,t)=>{const n=e.getArguments()[0];if(!n)return;const s=qe(n);if(!s){if(t!==void 0){const o=se(n,t);if(o){for(const a of o.bareTables)k(a.name,n);return M(o.key,o.bareTables,o.bareVectorIndexes,n,!0)}}console.warn(`@lunora/codegen: skipping \`.extend(${n.getText()})\` — its \`defineSchemaExtension(...)\` could not be resolved from local sources, and ${t===void 0?"no project root was available to resolve the package":"the package could not be imported/introspected"}. Extension tables will be absent from the generated types.`);return}const r=Je(s);if(!r){console.warn("@lunora/codegen: skipping `.extend(...)` — `defineSchemaExtension` requires a string `key` and an options object literal.");return}return We(r.key,r.keyNode,r.options)},Ge=e=>{const t=[];let n=e;for(;;){const s=n.getParent();if(!s||!i.isPropertyAccessExpression(s))break;const r=s.getParent();if(!r||!i.isCallExpression(r))break;s.getName()==="extend"&&t.push(r),n=r}return t},Xe=(e,t,n)=>{const s=new Set(t.map(o=>o.name)),r=[];for(const o of Ge(e)){const a=Ze(o,n);if(a){for(const l of a.tables){if(s.has(l.name))throw c(o,`defineSchema(...).extend(...): table "${l.name}" already exists — another extension with the same key already contributed it.`);s.add(l.name),t.push(l)}r.push(...a.vectorIndexes)}}return r},He=new Set(["eu","fedramp","us"]),Qe=e=>j(e,"jurisdiction","jurisdiction",He,'"eu", "us", or "fedramp"'),Ye=e=>{let t=e;for(;;){const n=t.getParent(),s=n?.getParent();if(!n||!i.isPropertyAccessExpression(n)||!s||!i.isCallExpression(s))return!1;if(n.getName()==="jurisdiction"){const r=s.getArguments()[1];return r!==void 0&&i.isObjectLiteralExpression(r)&&N(r,"pinAuth")===!0}t=s}},et=new Set(["required"]),tt=e=>j(e,"rls","rls mode",et,'"required"'),nt=e=>{if(!i.isObjectLiteralExpression(e))return;const t=new Set;for(const n of e.getProperties()){const s=i.isPropertyAssignment(n)?n.getInitializer():void 0;if(!s||!i.isCallExpression(s))return;const r=s.getExpression(),o=s.getArguments()[1],a=o&&i.isObjectLiteralExpression(o)?f(o,"on"):void 0;if(!i.isIdentifier(r)||r.getText()!=="defineAggregateIndex"||a===void 0)return;t.add(a)}return t},rt=(e,t)=>{if(t===void 0)return;const n=nt(t);for(const s of e)(n===void 0||n.has(s.name))&&(s.aggregateIndexed=!0)},mt=(e,t,n)=>{const r=e.addSourceFileAtPath(t).getDescendantsOfKind(B.CallExpression).find(p=>{const O=p.getExpression();return i.isIdentifier(O)&&O.getText()==="defineSchema"});if(!r)throw new C("INTERNAL",`defineSchema() not found in ${t}`);const o=r.getArguments()[0];if(!o||!i.isObjectLiteralExpression(o))throw c(r,"defineSchema() expects an object literal");const a=z(o),l=r.getArguments()[1],d=l&&i.isObjectLiteralExpression(l)?F(l):[],m=Xe(r,a,n);rt(a,r.getArguments()[2]);const T=[...a.flatMap(p=>p.vectorIndexes),...d,...m],R=new Set(a.filter(p=>p.shardMode==="global").map(p=>p.name)),I=T.find(p=>R.has(p.table));if(I)throw c(r,Z(I.table,I.name));return{jurisdiction:Qe(r),...Ye(r)?{jurisdictionPinsAuth:!0}:{},rlsMode:tt(r),tables:a,vectorIndexes:T}};export{mt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./SCHEMA_SNAPSHOT_VERSION-C7Um0EnM.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as d}from"./shard-ByB2lGh0.mjs";import"./shard-runtime-ByYXjCKY.mjs";import"./shared-8vTRkL2-.mjs";import"./platform-8oj7iXQy.mjs";import"./schema-BgM8A3XV.mjs";export{d as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{statSync as y,readdirSync as v,realpathSync as b,lstatSync as C}from"node:fs";import{dirname as P,join as m,relative as A,sep as F,extname as w,basename as I}from"node:path";import{matcher as D}from"@visulima/fs";import{SyntaxKind as p,Node as s,VariableDeclarationKind as k}from"ts-morph";import{diagnosticAt as j}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{readProjectConfigLiterals as z}from"./loadProjectConfig-B7RmxIeD.mjs";import{findProjectConfigFile as V,findCodegenConfigFile as K}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{p as $,a as M}from"./property-name-7cBlgK_O.mjs";const B=/\.ts$/u,g=(e,t)=>A(e,t).split(F).join("/").replace(B,""),U=new Set(["_generated","node_modules"]),O=new Set(["__fixtures__","__mocks__","__snapshots__","__tests__"]),N=/\.(?:bench|e2e|e2e-spec|spec|spec-d|test|test-d)(?:\.tsx?)?$/u,me=e=>{const t=e.split("/");return N.test(t.at(-1)??"")||t.slice(0,-1).some(i=>O.has(i))},f=(e,t,i)=>t?U.has(e)||!i&&O.has(e):!i&&N.test(e),S=new Map,d=()=>!1,W=e=>{const t=K(e),i=t===void 0?void 0:y(t,{throwIfNoEntry:!1});if(t===void 0||i===void 0)return d;const n=`${String(i.mtimeMs)}:${String(i.size)}`,r=S.get(t);if(r?.key===n)return r.isExcluded;const{codegen:o}=z(P(t));o?.unreadable&&console.warn("@lunora/codegen: `codegen.exclude` in lunora.config is not an array of string literals without `!` negations — ignoring it.");const c=o?.exclude?.length?D(o.exclude):d;return S.set(t,{isExcluded:c,key:n}),c},X=(e,t,i)=>e==="schema.ts"&&t===i,G=e=>{try{return y(e)}catch{console.warn(`@lunora/codegen: skipping ${e} — it is a symlink that does not resolve (or vanished mid-scan).`);return}},L=(e,t,i,n,r)=>{let o,c;try{o=v(e),c=b(e)}catch{return t}if(n.has(c))return t;n.add(c);for(const l of o){const u=m(e,l),a=G(u);a===void 0||r(l,A(i,u).split(F).join("/"),a.isDirectory())||(a.isDirectory()?L(u,t,i,n,r):a.isFile()&&w(l)===".ts"&&!X(l,e,i)&&t.push(u))}return t},_=(e,t={})=>{const i=t.includeSkipped??!1,n=i?d:W(e);return L(e,[],e,new Set,(r,o,c)=>f(r,c,i)||n(o))},H=["src/server","src/index.ts","src/worker.ts"],Y=new Set([".ts",".tsx"]),R=(e,t=[])=>{let i;try{i=C(e)}catch{return t}if(i.isFile())return Y.has(w(e))&&!f(I(e),!1,!1)&&t.push(e),t;if(!i.isDirectory())return t;for(const n of v(e))f(n,!0,!1)||R(m(e,n),t);return t},q=e=>{const t=P(e),i=_(e).map(o=>({displayPath:g(e,o),filePath:o})),n=new Set(i.map(o=>o.filePath)),r=V(t);for(const o of[...H.flatMap(c=>R(m(t,c))),...r===void 0?[]:[r]])n.has(o)||(n.add(o),i.push({displayPath:g(t,o),filePath:o}));return i},Q=e=>Array.isArray(e),T=(e,t,i,n)=>{const r=[];for(const{displayPath:o,filePath:c}of t){const l=e.getSourceFile(c)??e.addSourceFileAtPath(c);for(const u of l.getDescendantsOfKind(i)){const a=n(u,o);Q(a)?r.push(...a):a!==void 0&&r.push(a)}}return r},J=e=>_(e).map(t=>({displayPath:g(e,t),filePath:t})),Z=(e,t,i,n)=>T(e,J(t),i,n),xe=(e,t,i)=>Z(e,t,p.CallExpression,i),Se=(e,t,i)=>T(e,q(t),p.CallExpression,i),he=e=>$(e.getPropertyNameNode()??e.getNameNode()),x=(e,t)=>e?.getProperties().find(i=>!s.isSpreadAssignment(i)&&M(i)===t),ye=(e,t)=>{if(t){const o=e.getArguments()[0];return o&&(s.isArrowFunction(o)||s.isFunctionExpression(o))?o:void 0}const i=e.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))return;const n=x(i,"handler");if(!n||!s.isPropertyAssignment(n))return;const r=n.getInitializer();return r&&(s.isArrowFunction(r)||s.isFunctionExpression(r))?r:void 0},ve=(e,t)=>{if(!e||!s.isObjectLiteralExpression(e))return;const i=x(e,t);return i&&s.isPropertyAssignment(i)?i.getInitializer():void 0},ee=e=>{const t=e?.getParent();return s.isVariableDeclaration(e)&&s.isVariableDeclarationList(t)&&t.getDeclarationKind()===k.Const},te=e=>{let t=e,i=t.getParent();for(;i!==void 0&&(s.isParenthesizedExpression(i)||s.isAsExpression(i)||s.isSatisfiesExpression(i)||s.isTypeAssertion(i)||s.isNonNullExpression(i));)t=i,i=t.getParent();return t},h=e=>{const t=te(e),i=t.getParent();if(i===void 0)return!1;if(s.isBinaryExpression(i)){const r=i.getOperatorToken().getKind();return i.getLeft()===t&&r>=p.FirstAssignment&&r<=p.LastAssignment}if(s.isPrefixUnaryExpression(i)||s.isPostfixUnaryExpression(i)){const r=i.getOperatorToken();return r===p.PlusPlusToken||r===p.MinusMinusToken}return s.isDeleteExpression(i)?!0:s.isForOfStatement(i)||s.isForInStatement(i)?i.getInitializer()===t:s.isPropertyAssignment(i)?i.getInitializer()===t&&h(i):(s.isShorthandPropertyAssignment(i)||s.isSpreadAssignment(i)||s.isSpreadElement(i)||s.isObjectLiteralExpression(i)||s.isArrayLiteralExpression(i))&&h(i)},ie=e=>{const t=e?.getDeclarations().find(n=>s.isVariableDeclaration(n));if(!ee(t))return;const i=t.getParent().getParent();return s.isVariableStatement(i)&&s.isSourceFile(i.getParent())?t.getInitializer():void 0},se=e=>ie(e.getSymbol()),Pe=e=>{if(!e)return;if(s.isObjectLiteralExpression(e))return e;if(!s.isIdentifier(e))return;const t=se(e);return t!==void 0&&s.isObjectLiteralExpression(t)?t:void 0},E=e=>{let t=e;for(;t&&(s.isAsExpression(t)||s.isSatisfiesExpression(t)||s.isParenthesizedExpression(t)||s.isNonNullExpression(t));)t=t.getExpression();return t},ne=(e,t)=>{let i=E(e);for(;s.isAwaitExpression(i)||s.isPropertyAccessExpression(i)||s.isElementAccessExpression(i)||s.isCallExpression(i);){const n=s.isCallExpression(i)?t?.(i):void 0;if(n!==void 0)return{verdict:n};i=E(i.getExpression())}return{root:i}},Ae=e=>ne(e).root,Fe=e=>s.isArrowFunction(e)||s.isConstructorDeclaration(e)||s.isFunctionDeclaration(e)||s.isFunctionExpression(e)||s.isGetAccessorDeclaration(e)||s.isMethodDeclaration(e)||s.isSetAccessorDeclaration(e),we=(e,t)=>e?.compilerNode===t.compilerNode,Oe=e=>{if(s.isPropertyAccessExpression(e))return{member:e.getName(),object:e.getExpression()};const t=s.isElementAccessExpression(e)?e.getArgumentExpression():void 0;return s.isElementAccessExpression(e)&&s.isStringLiteral(t)?{member:t.getLiteralValue(),object:e.getExpression()}:void 0},Ne=e=>{const t=e.getParent();return s.isReturnStatement(t)||s.isArrowFunction(t)&&t.getBody()===e?e.getFirstAncestor(n=>s.isFunctionLikeDeclaration(n)||s.isArrowFunction(n)):void 0},Le=e=>{const t=E(e);return t&&s.isCallExpression(t)?t:void 0},_e=e=>{const t=e.getExportAssignment(r=>!r.isExportEquals());if(!t)return;const i=t.getExpression();if(!s.isIdentifier(i))return i;const n=i.getSymbol()?.getValueDeclaration();return n&&s.isVariableDeclaration(n)?n.getInitializer():i},Re=e=>{const t=e.getArguments()[1];return t&&s.isStringLiteral(t)?t.getLiteralValue():""},Te=(e,t)=>{if(!s.isObjectLiteralExpression(e))return;const i=x(e,t);if(!i||!s.isPropertyAssignment(i))return;const n=i.getInitializer();return n&&s.isStringLiteral(n)?n.getLiteralText():void 0},re=e=>{const t=e.getStatements(),[i]=t;if(t.length!==1||i===void 0||!s.isReturnStatement(i))return;const n=i.getExpression();return n!==void 0&&s.isObjectLiteralExpression(n)?n:void 0},be=e=>{if(s.isObjectLiteralExpression(e))return e;if(s.isParenthesizedExpression(e)){const t=e.getExpression();return s.isObjectLiteralExpression(t)?t:void 0}return s.isBlock(e)?re(e):void 0},Ce=e=>(t,i,n)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return t.getLiteralValue();throw j(t,`${e} "${i}": \`${n}\` must be a static string literal — it is deploy configuration codegen writes into wrangler.jsonc`)},oe=new Set(["api","internal"]),Ie=new Set(["run","runAction","runMutation","runQuery"]),ce=e=>{if(e===void 0||!s.isPropertyAccessExpression(e))return;const t=[];let i=e;for(;s.isPropertyAccessExpression(i);)t.unshift(i.getName()),i=i.getExpression();return s.isIdentifier(i)&&oe.has(i.getText())&&t.length>=2?t:void 0},De=e=>{const t=ce(e);return t===void 0?void 0:`${t.slice(0,-1).join("_")}:${String(t.at(-1))}`};export{Ie as RUN_METHODS,B as TS_EXTENSION_RE,he as bindingKeyName,Ae as chainRootOf,xe as collectCallRows,Z as collectNodeRows,Se as collectSecurityCallRows,_e as defaultExportExpression,x as findObjectProperty,De as functionKeyOf,ce as functionReferenceSegments,ye as handlerOf,ee as isConstDeclaration,Fe as isFunctionLike,we as isSameNode,me as isTestPath,h as isWriteTarget,Re as limitNameOf,_ as listLunoraSourceFiles,q as listSecurityScanFiles,g as lunoraRelativePath,Oe as memberAccessOf,be as objectLiteralFromCallbackBody,Pe as optionsObjectLiteral,te as outermostValueWrapper,ve as propertyInitializer,M as propertyKeyName,$ as propertyNameText,Ne as returningFunctionOf,Ce as stringPropertyFor,Te as stringPropertyOf,ie as symbolConstInitializer,E as unwrapExpression,Le as unwrapToCallExpression,ne as walkChain};
|