@lunora/codegen 1.0.0-alpha.70 → 1.0.0-alpha.72

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 CHANGED
@@ -60,11 +60,17 @@ interface IndexIR {
60
60
  unique?: boolean;
61
61
  }
62
62
  interface SearchIndexIR {
63
- /** Primary text-search field. */
63
+ /** Primary text-search field; a dot-separated path reads a nested field. */
64
64
  field: string;
65
65
  /** Optional filter fields surfaced alongside the FTS column. */
66
66
  filterFields?: ReadonlyArray<string>;
67
+ /** Text-analysis profile (accent folding + that language's stopwords). */
68
+ language?: string;
67
69
  name: string;
70
+ /** Skip the migration-time backfill of the search companion (large tables index out-of-band). */
71
+ staged?: boolean;
72
+ /** `"native"` opts into the engine's own full-text index where it has one (Postgres). */
73
+ strategy?: string;
68
74
  }
69
75
  /** A `.geoIndex(name, { field, precision? })` declaration — a geohash companion over a `v.geoPoint()` column. */
70
76
  interface GeoIndexIR {
@@ -977,6 +983,17 @@ interface ProcedureMiddlewareIR {
977
983
  fanOut: boolean;
978
984
  /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
979
985
  file: string;
986
+ /**
987
+ * `true` when the procedure declares an email-shaped argument (`email`,
988
+ * `emailAddress`, `userEmail`, …), `false` when it provably declares none,
989
+ * and **absent** when the argument list can't be read statically (a
990
+ * `.input(sharedSchema)`, a spread, or a factory whose `args` comes from a
991
+ * variable). Feeds `signup_mutation_without_disposable_gating`, which can
992
+ * only be actioned when there is an address to gate — so "unreadable" must
993
+ * stay distinguishable from "none", or the lint would clear itself on a
994
+ * registration that may well expose one.
995
+ */
996
+ hasEmailArg?: boolean;
980
997
  /** Registration kind — only `mutation`/`action` are write-shaped; `query` is read-only. */
981
998
  kind: "action" | "mutation" | "query";
982
999
  /** `true` when the handler runs an AI generation (`generateText`/`streamText`/`generateObject`/`streamObject`) with no `maxOutputTokens` bound in its config literal. Feeds the `ai_unbounded_generation_public` lint. */
package/dist/index.d.ts CHANGED
@@ -60,11 +60,17 @@ interface IndexIR {
60
60
  unique?: boolean;
61
61
  }
62
62
  interface SearchIndexIR {
63
- /** Primary text-search field. */
63
+ /** Primary text-search field; a dot-separated path reads a nested field. */
64
64
  field: string;
65
65
  /** Optional filter fields surfaced alongside the FTS column. */
66
66
  filterFields?: ReadonlyArray<string>;
67
+ /** Text-analysis profile (accent folding + that language's stopwords). */
68
+ language?: string;
67
69
  name: string;
70
+ /** Skip the migration-time backfill of the search companion (large tables index out-of-band). */
71
+ staged?: boolean;
72
+ /** `"native"` opts into the engine's own full-text index where it has one (Postgres). */
73
+ strategy?: string;
68
74
  }
69
75
  /** A `.geoIndex(name, { field, precision? })` declaration — a geohash companion over a `v.geoPoint()` column. */
70
76
  interface GeoIndexIR {
@@ -977,6 +983,17 @@ interface ProcedureMiddlewareIR {
977
983
  fanOut: boolean;
978
984
  /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
979
985
  file: string;
986
+ /**
987
+ * `true` when the procedure declares an email-shaped argument (`email`,
988
+ * `emailAddress`, `userEmail`, …), `false` when it provably declares none,
989
+ * and **absent** when the argument list can't be read statically (a
990
+ * `.input(sharedSchema)`, a spread, or a factory whose `args` comes from a
991
+ * variable). Feeds `signup_mutation_without_disposable_gating`, which can
992
+ * only be actioned when there is an address to gate — so "unreadable" must
993
+ * stay distinguishable from "none", or the lint would clear itself on a
994
+ * registration that may well expose one.
995
+ */
996
+ hasEmailArg?: boolean;
980
997
  /** Registration kind — only `mutation`/`action` are write-shaped; `query` is read-only. */
981
998
  kind: "action" | "mutation" | "query";
982
999
  /** `true` when the handler runs an AI generation (`generateText`/`streamText`/`generateObject`/`streamObject`) with no `maxOutputTokens` bound in its config literal. Feeds the `ai_unbounded_generation_public` lint. */
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{formatAdvisories as t,lintSchema as s}from"./packem_shared/formatAdvisories-DZvv-0MG.mjs";import{CodegenDiagnosticError as i,diagnosticAt as m}from"./packem_shared/CodegenDiagnosticError-DPezpZTz.mjs";import{AGENTS_FILENAME as f,discoverAgents as p}from"./packem_shared/AGENTS_FILENAME-BesaDYkL.mjs";import{default as n}from"./packem_shared/discoverAuthApiCalls-Ba6W92HB.mjs";import{CONTAINERS_FILENAME as l,discoverContainers as E}from"./packem_shared/CONTAINERS_FILENAME-CFwdyaCI.mjs";import{default as u}from"./packem_shared/discoverCrons-2nUpw6do.mjs";import{FLAGS_FILENAME as v,discoverFlags as N}from"./packem_shared/FLAGS_FILENAME-C1GWerCB.mjs";import{discoverFunctions as M}from"./packem_shared/discoverFunctions-zrIQk7J8.mjs";import{default as h}from"./packem_shared/discoverHttpRoutes-Bf_T_03b.mjs";import{default as _}from"./packem_shared/discoverInserts-DveVeP5h.mjs";import{default as g}from"./packem_shared/discoverMaskProcedures-BkBquCFR.mjs";import{default as F}from"./packem_shared/discoverMigrations-T2xb-1rn.mjs";import{MUTATORS_FILENAME as P,discoverMutators as D}from"./packem_shared/MUTATORS_FILENAME-BWPAtQ2T.mjs";import{default as H}from"./packem_shared/discoverNondeterministicCalls-BymnOR9k.mjs";import{NOTIFY_FILENAME as W,discoverNotifyCalls as G,discoverNotifyConfig as V}from"./packem_shared/NOTIFY_FILENAME-DP6qvFBX.mjs";import{default as w}from"./packem_shared/discoverQueries-DNRA-G2a.mjs";import{QUEUES_FILENAME as z,discoverQueues as Q}from"./packem_shared/QUEUES_FILENAME-CSE6i-ld.mjs";import{default as B}from"./packem_shared/discoverR2sqlCalls-YEjvGcEq.mjs";import{discoverRlsMetadata as K,default as q}from"./packem_shared/discoverRlsMetadata-DO3qlLXX.mjs";import{discoverSandboxUsage as X}from"./packem_shared/discoverSandboxUsage-JwrmSN9l.mjs";import{default as $}from"./packem_shared/discoverSchema-m2voTncu.mjs";import{SHAPES_FILENAME as oe,discoverShapes as re}from"./packem_shared/SHAPES_FILENAME-maut3z1K.mjs";import{default as se}from"./packem_shared/discoverStorageRulesMetadata-CCztRKjw.mjs";import{WORKFLOWS_FILENAME as ie,discoverWorkflows as me}from"./packem_shared/WORKFLOWS_FILENAME-Bk5upkGM.mjs";import{w as fe,B as pe,s as ce,c as ne,_ as Se,t as le,H as Ee,e as xe,b as ue,h as Ae,J as ve,n as Ne,M as Oe,r as Me}from"./packem_shared/emit-Bp0nOR_O.mjs";import{emitApp as he}from"./packem_shared/emitApp-Cm9yVOpP.mjs";import{buildOpenApiDocument as _e,emitOpenApi as Ie,emitOpenApiModule as ge}from"./packem_shared/buildOpenApiDocument-BJudKDP_.mjs";import{OPENRPC_VERSION as Fe,buildOpenRpcDocument as Te,emitOpenRpc as Pe,emitOpenRpcModule as De}from"./packem_shared/OPENRPC_VERSION-BcivFYIX.mjs";import{SCHEMA_SNAPSHOT_FILENAME as He,createCodegenProject as be,refreshCodegenProject as We,runCodegen as Ge}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-DVjBK4ud.mjs";import{SCHEMA_SNAPSHOT_VERSION as ke,SchemaSnapshotParseError as we,buildSchemaSnapshot as ye,diffSchemaSnapshots as ze,evaluateSchemaDrift as Qe,parseSchemaSnapshot as je,serializeSchemaSnapshot as Be}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-Bpf1FGMG.mjs";import{schemaFromIr as Ke}from"./packem_shared/schemaFromIr-R1ZFzVyy.mjs";import{LUNORA_ERROR_CODES as Ye,validatorIrToJsonSchema as Xe}from"./packem_shared/LUNORA_ERROR_CODES-Um9hC1gr.mjs";import{redact as $e,secretKindOf as eo}from"./packem_shared/redact-CQ8-to6l.mjs";import{MESSAGE_SOLUTIONS as ro,findSolutionByMessage as to}from"@lunora/errors";const e="0.0.0";export{f as AGENTS_FILENAME,l as CONTAINERS_FILENAME,i as CodegenDiagnosticError,v as FLAGS_FILENAME,fe as GENERATED_HEADER,Ye as LUNORA_ERROR_CODES,ro as LUNORA_SOLUTION_RULES,P as MUTATORS_FILENAME,W as NOTIFY_FILENAME,Fe as OPENRPC_VERSION,z as QUEUES_FILENAME,He as SCHEMA_SNAPSHOT_FILENAME,ke as SCHEMA_SNAPSHOT_VERSION,oe as SHAPES_FILENAME,we as SchemaSnapshotParseError,e as VERSION,ie as WORKFLOWS_FILENAME,_e as buildOpenApiDocument,Te as buildOpenRpcDocument,ye as buildSchemaSnapshot,be as createCodegenProject,m as diagnosticAt,ze as diffSchemaSnapshots,p as discoverAgents,n as discoverAuthApiCalls,E as discoverContainers,u as discoverCrons,N as discoverFlags,M as discoverFunctions,h as discoverHttpRoutes,_ as discoverInserts,g as discoverMaskProcedures,F as discoverMigrations,D as discoverMutators,H as discoverNondeterministicCalls,G as discoverNotifyCalls,V as discoverNotifyConfig,w as discoverQueries,Q as discoverQueues,B as discoverR2sqlCalls,K as discoverRlsMetadata,q as discoverRlsProcedures,X as discoverSandboxUsage,$ as discoverSchema,re as discoverShapes,se as discoverStorageRulesMetadata,me as discoverWorkflows,pe as emitAgents,ce as emitApi,he as emitApp,ne as emitCollections,Se as emitContainers,le as emitCrons,Ee as emitDataModel,xe as emitDrizzleSchema,ue as emitFunctions,Ie as emitOpenApi,ge as emitOpenApiModule,Pe as emitOpenRpc,De as emitOpenRpcModule,Ae as emitServer,ve as emitShard,Ne as emitVectors,Oe as emitWorkflows,Me as emitWranglerCronTriggers,Qe as evaluateSchemaDrift,to as findLunoraSolution,t as formatAdvisories,s as lintSchema,je as parseSchemaSnapshot,$e as redact,We as refreshCodegenProject,Ge as runCodegen,Ke as schemaFromIr,eo as secretKindOf,Be as serializeSchemaSnapshot,Xe as validatorIrToJsonSchema};
1
+ import{formatAdvisories as t,lintSchema as s}from"./packem_shared/formatAdvisories-DZvv-0MG.mjs";import{CodegenDiagnosticError as i,diagnosticAt as m}from"./packem_shared/CodegenDiagnosticError-DPezpZTz.mjs";import{AGENTS_FILENAME as f,discoverAgents as p}from"./packem_shared/AGENTS_FILENAME-BesaDYkL.mjs";import{default as n}from"./packem_shared/discoverAuthApiCalls-Ba6W92HB.mjs";import{CONTAINERS_FILENAME as l,discoverContainers as E}from"./packem_shared/CONTAINERS_FILENAME-CFwdyaCI.mjs";import{default as u}from"./packem_shared/discoverCrons-2nUpw6do.mjs";import{FLAGS_FILENAME as v,discoverFlags as N}from"./packem_shared/FLAGS_FILENAME-C1GWerCB.mjs";import{discoverFunctions as M}from"./packem_shared/discoverFunctions-zrIQk7J8.mjs";import{default as h}from"./packem_shared/discoverHttpRoutes-Bf_T_03b.mjs";import{default as _}from"./packem_shared/discoverInserts-DveVeP5h.mjs";import{default as g}from"./packem_shared/discoverMaskProcedures-BkBquCFR.mjs";import{default as F}from"./packem_shared/discoverMigrations-T2xb-1rn.mjs";import{MUTATORS_FILENAME as P,discoverMutators as D}from"./packem_shared/MUTATORS_FILENAME-BWPAtQ2T.mjs";import{default as H}from"./packem_shared/discoverNondeterministicCalls-BymnOR9k.mjs";import{NOTIFY_FILENAME as G,discoverNotifyCalls as W,discoverNotifyConfig as V}from"./packem_shared/NOTIFY_FILENAME-DP6qvFBX.mjs";import{default as w}from"./packem_shared/discoverQueries-DNRA-G2a.mjs";import{QUEUES_FILENAME as z,discoverQueues as Q}from"./packem_shared/QUEUES_FILENAME-CSE6i-ld.mjs";import{default as B}from"./packem_shared/discoverR2sqlCalls-YEjvGcEq.mjs";import{discoverRlsMetadata as K,default as q}from"./packem_shared/discoverRlsMetadata-DO3qlLXX.mjs";import{discoverSandboxUsage as X}from"./packem_shared/discoverSandboxUsage-JwrmSN9l.mjs";import{default as $}from"./packem_shared/discoverSchema-Cy4OQ0Cu.mjs";import{SHAPES_FILENAME as oe,discoverShapes as re}from"./packem_shared/SHAPES_FILENAME-maut3z1K.mjs";import{default as se}from"./packem_shared/discoverStorageRulesMetadata-CCztRKjw.mjs";import{WORKFLOWS_FILENAME as ie,discoverWorkflows as me}from"./packem_shared/WORKFLOWS_FILENAME-Bk5upkGM.mjs";import{w as fe,B as pe,s as ce,c as ne,_ as Se,t as le,G as Ee,e as xe,b as ue,h as Ae,J as ve,n as Ne,M as Oe,r as Me}from"./packem_shared/emit-D7VIjvlm.mjs";import{emitApp as he}from"./packem_shared/emitApp-CAeIj6e_.mjs";import{buildOpenApiDocument as _e,emitOpenApi as Ie,emitOpenApiModule as ge}from"./packem_shared/buildOpenApiDocument-CXFC-wzM.mjs";import{OPENRPC_VERSION as Fe,buildOpenRpcDocument as Te,emitOpenRpc as Pe,emitOpenRpcModule as De}from"./packem_shared/OPENRPC_VERSION-CvVFqUlq.mjs";import{SCHEMA_SNAPSHOT_FILENAME as He,createCodegenProject as be,refreshCodegenProject as Ge,runCodegen as We}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-WQ1drzwI.mjs";import{SCHEMA_SNAPSHOT_VERSION as ke,SchemaSnapshotParseError as we,buildSchemaSnapshot as ye,diffSchemaSnapshots as ze,evaluateSchemaDrift as Qe,parseSchemaSnapshot as je,serializeSchemaSnapshot as Be}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-Bpf1FGMG.mjs";import{schemaFromIr as Ke}from"./packem_shared/schemaFromIr-R1ZFzVyy.mjs";import{LUNORA_ERROR_CODES as Ye,validatorIrToJsonSchema as Xe}from"./packem_shared/LUNORA_ERROR_CODES-Um9hC1gr.mjs";import{redact as $e,secretKindOf as eo}from"./packem_shared/redact-CQ8-to6l.mjs";import{MESSAGE_SOLUTIONS as ro,findSolutionByMessage as to}from"@lunora/errors";const e="0.0.0";export{f as AGENTS_FILENAME,l as CONTAINERS_FILENAME,i as CodegenDiagnosticError,v as FLAGS_FILENAME,fe as GENERATED_HEADER,Ye as LUNORA_ERROR_CODES,ro as LUNORA_SOLUTION_RULES,P as MUTATORS_FILENAME,G as NOTIFY_FILENAME,Fe as OPENRPC_VERSION,z as QUEUES_FILENAME,He as SCHEMA_SNAPSHOT_FILENAME,ke as SCHEMA_SNAPSHOT_VERSION,oe as SHAPES_FILENAME,we as SchemaSnapshotParseError,e as VERSION,ie as WORKFLOWS_FILENAME,_e as buildOpenApiDocument,Te as buildOpenRpcDocument,ye as buildSchemaSnapshot,be as createCodegenProject,m as diagnosticAt,ze as diffSchemaSnapshots,p as discoverAgents,n as discoverAuthApiCalls,E as discoverContainers,u as discoverCrons,N as discoverFlags,M as discoverFunctions,h as discoverHttpRoutes,_ as discoverInserts,g as discoverMaskProcedures,F as discoverMigrations,D as discoverMutators,H as discoverNondeterministicCalls,W as discoverNotifyCalls,V as discoverNotifyConfig,w as discoverQueries,Q as discoverQueues,B as discoverR2sqlCalls,K as discoverRlsMetadata,q as discoverRlsProcedures,X as discoverSandboxUsage,$ as discoverSchema,re as discoverShapes,se as discoverStorageRulesMetadata,me as discoverWorkflows,pe as emitAgents,ce as emitApi,he as emitApp,ne as emitCollections,Se as emitContainers,le as emitCrons,Ee as emitDataModel,xe as emitDrizzleSchema,ue as emitFunctions,Ie as emitOpenApi,ge as emitOpenApiModule,Pe as emitOpenRpc,De as emitOpenRpcModule,Ae as emitServer,ve as emitShard,Ne as emitVectors,Oe as emitWorkflows,Me as emitWranglerCronTriggers,Qe as evaluateSchemaDrift,to as findLunoraSolution,t as formatAdvisories,s as lintSchema,je as parseSchemaSnapshot,$e as redact,Ge as refreshCodegenProject,We as runCodegen,Ke as schemaFromIr,eo as secretKindOf,Be as serializeSchemaSnapshot,Xe as validatorIrToJsonSchema};
@@ -0,0 +1 @@
1
+ import"@lunora/agent/component";import"@lunora/errors";import{w as m,d as r,B as o,s as n,c as l,_ as c,t as d,G as g,e as p,b as u,j as C,l as E,h as S,J as A,n as D,M as h,r as b}from"./emit-D7VIjvlm.mjs";import"./paths-BmX5O1sG.mjs";export{m as GENERATED_HEADER,r as buildStorageColumns,o as emitAgents,n as emitApi,l as emitCollections,c as emitContainers,d as emitCrons,g as emitDataModel,p as emitDrizzleSchema,u as emitFunctions,C as emitQueues,E as emitSeed,S as emitServer,A as emitShard,D as emitVectors,h as emitWorkflows,b as emitWranglerCronTriggers};
@@ -1,3 +1,3 @@
1
- import{w as a}from"./emit-Bp0nOR_O.mjs";import{n as s}from"./paths-BmX5O1sG.mjs";import{argsObjectSchema as i,LUNORA_ERROR_CODES as c}from"./LUNORA_ERROR_CODES-Um9hC1gr.mjs";const m="1.3.2",p=()=>({description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."}),u=e=>{const n=s(e.filePath),t=`${n}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${t}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${t}", "args": { … } }\`).`,errors:c.map((r,o)=>({code:-32e3-o,data:{code:r},message:r})),name:t,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:i(e.args)}],result:{name:"result",schema:p()},summary:`${e.kind}: ${t}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:n}]}},d=e=>{const n=e.version??"0.0.0",t=e.functions.filter(r=>r.visibility!=="internal"&&r.kind!=="stream").map(r=>u(r)).toSorted((r,o)=>r.name.localeCompare(o.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:n},methods:t,openrpc:m}},R=e=>`${JSON.stringify(d(e),void 0,2)}
1
+ import{w as a}from"./emit-D7VIjvlm.mjs";import{n as s}from"./paths-BmX5O1sG.mjs";import{argsObjectSchema as i,LUNORA_ERROR_CODES as c}from"./LUNORA_ERROR_CODES-Um9hC1gr.mjs";const m="1.3.2",p=()=>({description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."}),u=e=>{const n=s(e.filePath),t=`${n}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${t}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${t}", "args": { … } }\`).`,errors:c.map((r,o)=>({code:-32e3-o,data:{code:r},message:r})),name:t,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:i(e.args)}],result:{name:"result",schema:p()},summary:`${e.kind}: ${t}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:n}]}},d=e=>{const n=e.version??"0.0.0",t=e.functions.filter(r=>r.visibility!=="internal"&&r.kind!=="stream").map(r=>u(r)).toSorted((r,o)=>r.name.localeCompare(o.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:n},methods:t,openrpc:m}},R=e=>`${JSON.stringify(d(e),void 0,2)}
2
2
  `,O=e=>`${a}export const openRpcSpec: Record<string, unknown> = ${JSON.stringify(e,void 0,4)};
3
3
  `;export{m as OPENRPC_VERSION,d as buildOpenRpcDocument,R as emitOpenRpc,O as emitOpenRpcModule};
@@ -0,0 +1,3 @@
1
+ import{existsSync as E,readFileSync as Ae,mkdirSync as Bt,writeFileSync as Vt,rmSync as Ut}from"node:fs";import{join as g,dirname as ge}from"node:path";import{performance as fe}from"node:perf_hooks";import{LunoraError as q}from"@lunora/errors";import{Node as i,SyntaxKind as u,Project as Xe}from"ts-morph";import{lintSchema as Wt}from"./formatAdvisories-DZvv-0MG.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as f,classifyProcedureCall as K,inlineHandler as Gt,procedureHandler as mt,chainUsesWrappedCall as xt,isDatabaseAccessor as k,chainHasStep as _t,discoverFunctions as Ht}from"./discoverFunctions-zrIQk7J8.mjs";import{discoverAgents as Jt}from"./AGENTS_FILENAME-BesaDYkL.mjs";import Qt from"./discoverAuthApiCalls-Ba6W92HB.mjs";import{discoverContainers as Xt}from"./CONTAINERS_FILENAME-CFwdyaCI.mjs";import Zt from"./discoverCrons-2nUpw6do.mjs";import{diagnosticAt as _}from"./CodegenDiagnosticError-DPezpZTz.mjs";import{o as H}from"./module-specifiers-8FEEiUcv.mjs";import{a as pe,d as Yt,G as es,s as ts,h as ss,b as rs,J as ns,c as is,_ as os,M as as,B as cs,j as us,t as ls,n as ds,e as gs,l as fs,r as ps}from"./emit-D7VIjvlm.mjs";import{discoverFlagKeys as ms}from"./FLAGS_FILENAME-C1GWerCB.mjs";import xs from"./discoverHttpRoutes-Bf_T_03b.mjs";import hs from"./discoverInserts-DveVeP5h.mjs";import Es,{discoverMaskStrategies as ys,discoverMaskMetadata as As}from"./discoverMaskProcedures-BkBquCFR.mjs";import $s from"./discoverMigrations-T2xb-1rn.mjs";import{MUTATORS_FILENAME as Ss,isDefineMutatorCallee as Ns,discoverMutators as vs}from"./MUTATORS_FILENAME-BWPAtQ2T.mjs";import bs from"./discoverNondeterministicCalls-BymnOR9k.mjs";import{discoverNotifyConfig as Ps,discoverNotifyCalls as ws}from"./NOTIFY_FILENAME-DP6qvFBX.mjs";import Is from"./discoverQueries-DNRA-G2a.mjs";import{discoverQueues as Os}from"./QUEUES_FILENAME-CSE6i-ld.mjs";import Ls from"./discoverR2sqlCalls-YEjvGcEq.mjs";import Fs,{discoverRlsMetadata as Ts}from"./discoverRlsMetadata-DO3qlLXX.mjs";import{discoverSandboxUsage as Ds}from"./discoverSandboxUsage-JwrmSN9l.mjs";import Cs from"./discoverSchema-Cy4OQ0Cu.mjs";import{secretKindOf as ks,redact as Ks}from"./redact-CQ8-to6l.mjs";import{discoverShapes as Rs}from"./SHAPES_FILENAME-maut3z1K.mjs";import Ms from"./discoverStorageRulesMetadata-CCztRKjw.mjs";import{e as js}from"./discover-ast-CezKqEhE.mjs";import{discoverWorkflows as zs}from"./WORKFLOWS_FILENAME-Bk5upkGM.mjs";import{emitApp as qs}from"./emitApp-CAeIj6e_.mjs";import{buildOpenApiDocument as Bs,emitOpenApiModule as Vs}from"./buildOpenApiDocument-CXFC-wzM.mjs";import{buildOpenRpcDocument as Us,emitOpenRpcModule as Ws}from"./OPENRPC_VERSION-CvVFqUlq.mjs";import{buildSchemaSnapshot as Gs,serializeSchemaSnapshot as _s}from"./SCHEMA_SNAPSHOT_VERSION-Bpf1FGMG.mjs";const ht=new Set(["delete","get","head","options","patch","post","put"]),Hs=new Set(["handler","stream"]),Js=/\/(?:_|admin|internal|superuser|sudo|root|debug)/iu,Ze=new Set(["ADMIN_TOKEN","adminToken","assertAdmin","assertAuth","auth","Authorization","getSession","identity","isAdmin","requireAdmin","requireAuth","requireRole","verifyAdmin"]),Qs=e=>{if(!i.isCallExpression(e))return;const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!ht.has(t.getName()))return;const s=t.getExpression();if(!i.isIdentifier(s)||s.getText()!=="httpRoute")return;const r=e.getArguments()[0];if(!(!r||!i.isStringLiteral(r)))return{method:t.getName().toUpperCase(),path:r.getLiteralValue()}},Xs=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;let s=t.getExpression();for(;i.isCallExpression(s);){const r=s.getExpression();if(!i.isPropertyAccessExpression(r)||ht.has(r.getName()))break;s=r.getExpression()}return Qs(s)},Zs=e=>{for(const t of e.getDescendantsOfKind(u.PropertyAccessExpression))if(Ze.has(t.getName()))return!0;for(const t of e.getDescendantsOfKind(u.CallExpression)){const s=t.getExpression();if(i.isIdentifier(s)&&Ze.has(s.getText()))return!0}return!1},Ys=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const r=s.getExpression();if(!i.isPropertyAccessExpression(r)||!Hs.has(r.getName()))return;const n=Xs(s);if(!n||!Js.test(n.path))return;const o=s.getArguments()[0],a=o!==void 0&&(i.isArrowFunction(o)||i.isFunctionExpression(o))&&Zs(o);return{exportName:e.getName(),file:t,method:n.method,path:n.path,usesGuard:a}},er=(e,t)=>{const s=[];for(const r of e.getVariableStatements())if(r.isExported())for(const n of r.getDeclarations()){const o=Ys(n,t);o&&s.push(o)}return s},tr=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...er(n,f(t,r)))}return s},Ye=e=>{if(e.getText()!=="args")return!1;const t=e.getParent();return i.isPropertyAccessExpression(t)&&t.getNameNode()===e?!1:!(i.isPropertyAssignment(t)&&t.getNameNode()===e)},et=e=>{if(e.getText()!=="ctx")return!1;const t=e.getParent();return i.isPropertyAccessExpression(t)&&t.getNameNode()===e?!1:!(i.isPropertyAssignment(t)&&t.getNameNode()===e)},me=e=>i.isIdentifier(e)?et(e):e.getDescendantsOfKind(u.Identifier).some(t=>et(t)),tt=(e,t)=>{if(e.getText()!==t)return!1;const s=e.getParent();return i.isPropertyAccessExpression(s)&&s.getNameNode()===e?!1:!(i.isPropertyAssignment(s)&&s.getNameNode()===e)},sr=e=>{let t=e;for(;i.isPropertyAccessExpression(t)||i.isElementAccessExpression(t)||i.isNonNullExpression(t);)t=t.getExpression();return i.isIdentifier(t)?t:void 0},S=e=>{if(i.isIdentifier(e))return e.getText();if(i.isPropertyAccessExpression(e))return e.getName()},Ee=e=>i.isIdentifier(e)?Ye(e):e.getDescendantsOfKind(u.Identifier).some(t=>Ye(t)),L=e=>{if(!i.isIdentifier(e))return;const t=e.getText(),s=e.getFirstAncestor(a=>i.isArrowFunction(a)||i.isFunctionExpression(a)||i.isFunctionDeclaration(a));if(s===void 0)return;const r=e.getStart();let n,o=-1;for(const a of s.getDescendantsOfKind(u.VariableDeclaration)){if(a.getName()!==t)continue;const c=a.getInitializer(),l=a.getStart();c!==void 0&&l<r&&l>o&&(n=c,o=l)}return n},w=e=>{if(Ee(e))return!0;const t=L(e);return t!==void 0&&Ee(t)},T=e=>{if(me(e))return!0;const t=L(e);if(t!==void 0&&me(t))return!0;const s=t??e;return(i.isIdentifier(s)?[s]:s.getDescendantsOfKind(u.Identifier)).some(r=>{const n=L(r);return n!==void 0&&me(n)})},B=(e,t)=>i.isIdentifier(e)?tt(e,t):e.getDescendantsOfKind(u.Identifier).some(s=>tt(s,t)),rr=(e,t)=>{if(B(e,t))return!0;const s=L(e);if(s!==void 0&&B(s,t))return!0;const r=sr(e);if(r!==void 0){const n=L(r);return n!==void 0&&B(n,t)}return!1},h=e=>{for(const t of e.getAncestors())if(i.isVariableDeclaration(t)&&t.getVariableStatement()?.hasExportKeyword()===!0)return t.getName();return"<module>"},nr=e=>!i.isPropertyAccessExpression(e)||e.getName()!=="run"?!1:e.getExpression().getText()==="ctx.ai",ir=(e,t)=>{if(!nr(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!w(s)||T(s)))return{exportName:h(e),file:t,line:e.getStartLineNumber()}},or=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=ir(r,t);n&&s.push(n)}return s},ar=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...or(n,f(t,r)))}return s},cr=new Set(["generateText","streamText"]),ur=new Set(["messages","prompt","system"]),lr=[{methods:new Set(["delete","insert","insertManyUnsafe","patch","replace"]),prefixes:["context.db","ctx.db"]},{methods:new Set(["run","runAction","runMutation"]),prefixes:["context","ctx"]},{methods:new Set(["fetch"]),prefixes:["context","ctx"]},{methods:new Set(["queue","send"]),prefixes:["context.email","context.mail","ctx.email","ctx.mail"]}],dr=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;const s=t.getName(),r=t.getExpression().getText();for(const n of lr)if(n.methods.has(s)&&n.prefixes.some(o=>r===o||r.startsWith(`${o}.`)))return`${r}.${s}`},gr=e=>{for(const t of e.getDescendantsOfKind(u.CallExpression)){const s=dr(t);if(s!==void 0)return s}},fr=e=>{const t=new Set,s=e.getFirstAncestor(o=>i.isArrowFunction(o)||i.isFunctionExpression(o)||i.isFunctionDeclaration(o)),[r]=s?.getParameters()??[],n=r?.getNameNode();if(n===void 0||!i.isObjectBindingPattern(n))return t;for(const o of n.getElements()){const a=o.getPropertyNameNode()?.getText()??o.getName(),c=o.getNameNode();if(a==="args"&&i.isObjectBindingPattern(c))for(const l of c.getElements())t.add(l.getName())}return t},pr=e=>{if(Ee(e))return!0;const t=fr(e);return t.size===0?!1:e.getDescendantsOfKind(u.Identifier).some(s=>t.has(s.getText()))},mr=e=>{for(const t of e.getProperties()){if(!i.isPropertyAssignment(t)||!ur.has(t.getName()))continue;const s=t.getInitializer();if(s!==void 0&&pr(s))return!0}return!1},xr=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=S(r.getExpression());if(n===void 0||!cr.has(n))continue;const[o]=r.getArguments();if(o===void 0||!i.isObjectLiteralExpression(o))continue;let a;for(const c of o.getDescendantsOfKind(u.CallExpression))if(S(c.getExpression())==="tool"&&(a=gr(c),a!==void 0))break;a!==void 0&&s.push({exportName:h(r),file:t,line:r.getStartLineNumber(),method:n,sideEffect:a,userInputDerived:mr(o)})}return s},hr=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...xr(n,f(t,r)))}return s},Er=e=>{if(!i.isPropertyAccessExpression(e)||e.getName()!=="fetch")return!1;const t=e.getExpression();return i.isIdentifier(t)&&t.getText()==="ctx"},yr=(e,t)=>{if(!Er(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!w(s)))return{exportName:h(e),file:t,line:e.getStartLineNumber()}},Ar=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=yr(r,t);n&&s.push(n)}return s},$r=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Ar(n,f(t,r)))}return s},Et=e=>e.getProperties().some(t=>i.isSpreadAssignment(t)),Sr=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return{objects:[],opaque:!0};const s=t.getProperty("args");if(!s)return{objects:[],opaque:!1};if(!i.isPropertyAssignment(s))return{objects:[],opaque:!0};const r=s.getInitializer();return!r||!i.isObjectLiteralExpression(r)?{objects:[],opaque:!0}:{objects:[r],opaque:Et(r)}},Nr=e=>{const t=[];let s=!1,r=e;for(;i.isCallExpression(r);){const n=r.getExpression();if(!i.isPropertyAccessExpression(n))break;if(n.getName()==="input"){const o=r.getArguments()[0];o&&i.isObjectLiteralExpression(o)?(t.push(o),s||=Et(o)):s=!0}r=n.getExpression()}return{objects:t,opaque:s}},yt=(e,t)=>t?Nr(t):Sr(e),vr=e=>e.flatMap(t=>t.getProperties().filter(s=>i.isPropertyAssignment(s)||i.isShorthandPropertyAssignment(s)).map(s=>s.getName())),br=/\.check\(|\.meta\(|length|max/iu,Pr=/\bv\.any\s*\(/u,wr=/\bv\.string\s*\(/u,Ir=e=>Pr.test(e),Or=e=>wr.test(e)&&!br.test(e),Lr=e=>{const t=[],s=[];for(const r of e)for(const n of r.getProperties()){if(!i.isPropertyAssignment(n))continue;const o=n.getInitializer();if(!o)continue;const a=o.getText(),c=n.getName();Ir(a)?t.push(c):Or(a)&&s.push(c)}return{anyArgs:t,unboundedStringArgs:s}},Fr=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const r=K(s);if(r?.visibility!=="public")return;const{objects:n}=yt(s,r.receiver),{anyArgs:o,unboundedStringArgs:a}=Lr(n);if(!(o.length===0&&a.length===0))return{anyArgs:o,exportName:e.getName(),file:t,line:s.getStartLineNumber(),unboundedStringArgs:a}},Tr=(e,t)=>{const s=[];for(const r of e.getVariableStatements())if(r.isExported())for(const n of r.getDeclarations()){const o=Fr(n,t);o&&s.push(o)}return s},Dr=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Tr(n,f(t,r)))}return s},N=(e,t)=>{if(!e||!i.isObjectLiteralExpression(e))return;const s=e.getProperty(t);return s&&i.isPropertyAssignment(s)?s.getInitializer():void 0},xe=e=>e?.getKind()===u.TrueKeyword,Cr=e=>e?.getKind()===u.FalseKeyword,kr=e=>e!==void 0&&i.isNumericLiteral(e)&&e.getLiteralValue()===0,Kr=new Set(["lunoraAuthAdapter","lunoraD1Adapter"]),Rr=e=>!e||!i.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>i.isCallExpression(t)&&S(t.getExpression())==="scim"),Mr=e=>e!==void 0&&i.isCallExpression(e)&&Kr.has(S(e.getExpression())??""),jr=e=>!e||!i.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>i.isStringLiteral(t)&&t.getLiteralText()==="*"),zr=e=>{const t=N(e,"advanced"),s=N(e,"emailAndPassword"),r=N(e,"session");return{analyzable:!0,disableCsrfCheck:xe(N(t,"disableCSRFCheck")),emailPasswordEnabled:xe(N(s,"enabled")),requireEmailVerification:xe(N(s,"requireEmailVerification")),scimOnNonTransactionalAdapter:Rr(N(e,"plugins"))&&Mr(N(e,"database")),secureCookiesDisabled:Cr(N(t,"useSecureCookies")),sessionFreshAgeZero:kr(N(r,"freshAge")),trustedOriginsWildcard:jr(N(e,"trustedOrigins"))}},qr=()=>({analyzable:!1,disableCsrfCheck:!1,emailPasswordEnabled:!1,requireEmailVerification:!1,scimOnNonTransactionalAdapter:!1,secureCookiesDisabled:!1,sessionFreshAgeZero:!1,trustedOriginsWildcard:!1}),Br=(e,t)=>{if(S(e.getExpression())!=="createAuth")return;const s=e.getArguments()[0],r=s!==void 0&&i.isObjectLiteralExpression(s)&&s.getProperties().some(o=>i.isSpreadAssignment(o)),n=s!==void 0&&i.isObjectLiteralExpression(s)&&!r?zr(s):qr();return{exportName:h(e),file:t,line:e.getStartLineNumber(),...n}},Vr=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=Br(r,t);n&&s.push(n)}return s},Ur=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Vr(n,f(t,r)))}return s},Wr=(e,t)=>{if(!i.isPropertyAccessExpression(e))return;const s=e.getName();if(t.methods.has(s))return t.matchReceiver(e.getExpression().getText())?s:void 0},Gr=(e,t,s)=>{const r=Wr(e.getExpression(),s);if(r===void 0)return;const n=e.getArguments()[s.argIndex];if(!(!n||!w(n)||T(n)))return{exportName:h(e),file:t,line:e.getStartLineNumber(),method:r}},_r=(e,t,s)=>{const r=[];for(const n of e.getDescendantsOfKind(u.CallExpression)){const o=Gr(n,t,s);o&&r.push(o)}return r},J=(e,t,s)=>{const r=[];for(const n of d(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);r.push(..._r(o,f(t,n),s))}return r},Hr=new Set(["content","pdf","scrape","screenshot"]),Jr=(e,t)=>J(e,t,{argIndex:0,matchReceiver:s=>s==="ctx.browser",methods:Hr}),Qr=new Set(["createBrowser","createInboundEmailHandler","createPayment"]),Xr=new Set(["RateLimiter"]),Zr=new Set(["extend"]),At=e=>{const t=[],s=[];let r=!1;for(const n of e.getProperties()){if(i.isSpreadAssignment(n)){r=!0;continue}if(i.isPropertyAssignment(n)){const o=n.getName();t.push(o),n.getInitializer()?.getKind()===u.TrueKeyword&&s.push(o);continue}(i.isShorthandPropertyAssignment(n)||i.isMethodDeclaration(n))&&t.push(n.getName())}return{analyzable:!r,presentKeys:t,trueKeys:s}},st=e=>e&&i.isObjectLiteralExpression(e)?At(e):{analyzable:!1,presentKeys:[],trueKeys:[]},Yr=e=>{const t=e.getStatements(),[s]=t;if(t.length!==1||s===void 0||!i.isReturnStatement(s))return;const r=s.getExpression();return r!==void 0&&i.isObjectLiteralExpression(r)?r:void 0},en=e=>{if(i.isObjectLiteralExpression(e))return e;if(i.isParenthesizedExpression(e)){const t=e.getExpression();return i.isObjectLiteralExpression(t)?t:void 0}return i.isBlock(e)?Yr(e):void 0},tn=e=>{const t=e&&(i.isArrowFunction(e)||i.isFunctionExpression(e))?e:void 0,s=t&&en(t.getBody());return s?At(s):{analyzable:!1,presentKeys:[],trueKeys:[]}},sn=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=S(r.getExpression());n!==void 0&&(Qr.has(n)?s.push({callee:n,file:t,line:r.getStartLineNumber(),...st(r.getArguments()[0])}):Zr.has(n)&&s.push({callee:n,file:t,line:r.getStartLineNumber(),...tn(r.getArguments()[0])}))}for(const r of e.getDescendantsOfKind(u.NewExpression)){const n=S(r.getExpression());n===void 0||!Xr.has(n)||s.push({callee:n,file:t,line:r.getStartLineNumber(),...st(r.getArguments()[0])})}return s},rn=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...sn(n,f(t,r)))}return s},rt="ctx.containers.",nn=e=>{if(!e.startsWith(rt))return!1;const t=e.slice(rt.length);return t.length>0&&!t.includes(".")},on=(e,t)=>J(e,t,{argIndex:0,matchReceiver:nn,methods:new Set(["get"])}),an=new Set(["allow","deny","setAllowed"]),cn=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return!1;const s=t.getProperty("enableInternet");return s!==void 0&&i.isPropertyAssignment(s)&&i.isTrueLiteral(s.getInitializerOrThrow())},un=(e,t)=>{const s=e.getExpression();if(!(!i.isPropertyAccessExpression(s)||s.getName()!=="start"||!cn(e)))return{detail:"enableInternet: true",exportName:h(e),file:t,kind:"enable_internet",line:e.getStartLineNumber()}},ln=(e,t)=>{const s=e.getExpression();if(!i.isPropertyAccessExpression(s)||!an.has(s.getName()))return;const r=s.getExpression();if(!(!i.isPropertyAccessExpression(r)||r.getName()!=="egress"))return{detail:s.getName(),exportName:h(e),file:t,kind:"egress_relaxation",line:e.getStartLineNumber()}},dn=(e,t)=>un(e,t)??ln(e,t),gn=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=dn(r,t);n&&s.push(n)}return s},fn=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...gn(n,f(t,r)))}return s},pn="env.ts",mn=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineEnv";for(const s of t.getDeclarations())if(i.isImportSpecifier(s))return H(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineEnv":!1;return!1},xn=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!i.isNamespaceImport(s))continue;const r=s.getFirstAncestorByKind(u.ImportDeclaration);return r!==void 0&&H(r.getModuleSpecifierValue())}return!1},hn=e=>{if(i.isIdentifier(e))return mn(e);if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineEnv"&&i.isIdentifier(t)&&xn(t)}return!1},En=e=>{const t=[];for(const s of e.getVariableDeclarations()){if(!s.isExported())continue;const r=s.getInitializer();if(r?.getKind()!==u.CallExpression||!hn(r.getExpression()))continue;const n=s.getNameNode();if(!i.isIdentifier(n))throw _(n,"defineEnv exports must be plain named exports (no destructuring)");t.push({exportName:n.getText()})}return t},yn=(e,t)=>{const s=g(t,pn);if(!E(s))return;const r=e.getSourceFile(s)??e.addSourceFileAtPath(s),n=En(r);if(n.length!==0){if(n.length>1)throw _(r,`lunora/env.ts declares ${n.length.toString()} defineEnv() contracts (${n.map(o=>o.exportName).join(", ")}); exactly one is allowed`);return n[0]}},An=new Set(["defineExportSink","r2Sink","webhookExportSink"]),$n=e=>{const t=e.getExpression();if(!i.isIdentifier(t))return;const s=t.getText();return An.has(s)?s:void 0},Sn=e=>{const t=[],s=[];for(const r of e.getProperties()){if(i.isSpreadAssignment(r))return{analyzable:!1,emptyKeys:[],presentKeys:[]};if(i.isPropertyAssignment(r)){const n=r.getName();t.push(n);const o=r.getInitializer();o&&i.isStringLiteral(o)&&o.getLiteralText()===""&&s.push(n);continue}(i.isShorthandPropertyAssignment(r)||i.isMethodDeclaration(r)||i.isGetAccessorDeclaration(r))&&t.push(r.getName())}return{analyzable:!0,emptyKeys:s,presentKeys:t}},Nn=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),o=f(t,r);for(const a of n.getDescendantsOfKind(u.CallExpression)){const c=$n(a);if(c===void 0)continue;const l=a.getArguments()[0],p=l&&i.isObjectLiteralExpression(l)?Sn(l):{analyzable:!1,emptyKeys:[],presentKeys:[]};s.push({analyzable:p.analyzable,emptyKeys:p.emptyKeys,factory:c,file:o,line:a.getStartLineNumber(),presentKeys:p.presentKeys})}}return s},vn=new Map([["dbRateLimit",2],["rateLimit",2],["verifyTurnstileMiddleware",0]]),bn=new Set(["dbRateLimit","rateLimit"]),Pn=e=>{if(!e||!i.isObjectLiteralExpression(e))return!1;const t=e.getProperty("failOpen");return t!==void 0&&i.isPropertyAssignment(t)&&t.getInitializer()?.getKind()===u.TrueKeyword},wn=e=>{const t=e.getArguments()[1];return t&&i.isStringLiteral(t)?t.getLiteralValue():""},In=(e,t)=>{const s=S(e.getExpression());if(s===void 0)return;const r=vn.get(s);if(r!==void 0)return{callee:s,exportName:h(e),failOpen:Pn(e.getArguments()[r]),file:t,limitName:bn.has(s)?wn(e):"",line:e.getStartLineNumber()}},On=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=In(r,t);n&&s.push(n)}return s},Ln=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...On(n,f(t,r)))}return s},Fn=e=>{const t=r=>i.isIdentifier(r)&&r.getText()==="ctx",s=new Set;for(const r of e.getDescendantsOfKind(u.PropertyAccessExpression))t(r.getExpression())&&s.add(r.getName());for(const r of e.getDescendantsOfKind(u.VariableDeclaration)){const n=r.getInitializer(),o=r.getNameNode();if(!(n===void 0||!t(n)||!i.isObjectBindingPattern(o)))for(const a of o.getElements()){const c=a.getPropertyNameNode()?.getText()??a.getName();c&&s.add(c)}}return s},Tn=(e,t)=>{const s=Object.fromEntries(pe.map(r=>[r.key,!1]));for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),o=new Set(n.getImportDeclarations().map(c=>c.getModuleSpecifierValue())),a=Fn(n);for(const c of pe)if(!s[c.key]){if(o.has(c.moduleSpecifier)){s[c.key]=!0;continue}c.contextProperty!==void 0&&a.has(c.contextProperty)&&(s[c.key]=!0)}if(pe.every(c=>s[c.key]))break}return s},Dn=["providerSubscriptionId","state"],Cn=["providerEventId","processedAt"],nt=(e,t)=>t.every(s=>s in e.shape),kn=e=>{const t=e.find(r=>r.name==="subscriptions"),s=e.find(r=>r.name==="events");return t!==void 0&&s!==void 0&&nt(t,Dn)&&nt(s,Cn)},Kn=(e,t)=>({analytics:e.analytics||t.dependencies.has("@lunora/bindings/analytics"),auth:t.dependencies.has("@lunora/auth"),containers:e.container||t.containerCount>0||t.dependencies.has("@lunora/container"),flags:e.flags||t.dependencies.has("@lunora/flags"),kv:e.kv||t.dependencies.has("@lunora/bindings/kv"),mail:e.mail||t.dependencies.has("@lunora/mail"),payments:e.payments||t.hasPaymentTables,queues:t.queueCount>0||t.dependencies.has("@lunora/queue"),scheduler:e.scheduler||t.cronCount>0||t.dependencies.has("@lunora/scheduler"),storage:e.storage||t.storageRuleCount>0||t.storageColumnCount>0||t.dependencies.has("@lunora/storage"),vectors:e.vectors||t.vectorIndexCount>0||t.dependencies.has("@lunora/bindings/vectors"),workflows:e.workflows||t.workflowCount>0||t.dependencies.has("@lunora/workflow")}),Rn=e=>i.isIdentifier(e)&&e.getText()==="ctx",Mn=e=>{if(!i.isPropertyAccessExpression(e)||e.getName()!=="boolean")return!1;const t=e.getExpression();return i.isPropertyAccessExpression(t)&&t.getName()==="flags"&&Rn(t.getExpression())},jn=e=>{if(e?.getKind()===u.TrueKeyword)return!0;if(e?.getKind()===u.FalseKeyword)return!1},zn=(e,t)=>{if(!Mn(e.getExpression()))return;const[s,r]=e.getArguments();if(!s||!(i.isStringLiteral(s)||i.isNoSubstitutionTemplateLiteral(s)))return;const n=s.getLiteralValue(),o=jn(r);if(!(n.length===0||o===void 0))return{defaultValue:o,exportName:h(e),file:t,key:n,line:e.getStartLineNumber()}},qn=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=zn(r,t);n&&s.push(n)}return s},Bn=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...qn(n,f(t,r)))}return s},Vn=e=>{const t=e.getExpression();return i.isPropertyAccessExpression(t)&&t.getName()==="withGeoIndex"},Un=e=>{const t=e.getArguments()[0];return t&&i.isStringLiteral(t)?t.getLiteralText():""},Wn=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),o=f(t,r);for(const a of n.getDescendantsOfKind(u.CallExpression))Vn(a)&&s.push({file:o,indexName:Un(a),line:a.getStartLineNumber()})}return s},Gn=new Set(["delete","get","head","options","patch","post","put"]),_n=new Set(["handler","stream"]),Hn=new Set(["runAction","runMutation"]),Jn=new Set(["delete","insert","insertManyUnsafe","patch","replace"]),U=(e,t)=>e!==void 0&&i.isIdentifier(e)&&e.getText()===t,it=e=>e!==void 0&&(i.isArrowFunction(e)||i.isFunctionExpression(e))?e:void 0,ot=(e,t)=>{const s=e.getParameters()[0];if(s===void 0)return;const r=s.getNameNode();if(t)return i.isIdentifier(r)?r.getText():void 0;if(i.isObjectBindingPattern(r)){for(const n of r.getElements())if((n.getPropertyNameNode()?.getText()??n.getNameNode().getText())==="ctx"){const o=n.getNameNode();return i.isIdentifier(o)?o.getText():void 0}}},at=(e,t)=>{const s=e.getBody(),r=s.getDescendantsOfKind(u.CallExpression);i.isCallExpression(s)&&r.unshift(s);for(const n of r){const o=n.getExpression();if(!i.isPropertyAccessExpression(o))continue;const a=o.getName(),c=o.getExpression();if(Hn.has(a)&&U(c,t))return a;if(Jn.has(a)&&i.isPropertyAccessExpression(c)&&c.getName()==="db"&&U(c.getExpression(),t))return`db.${a}`}},ct=(e,t)=>{const s=e.getBody();for(const r of s.getDescendantsOfKind(u.PropertyAccessExpression))if(r.getName()==="auth"&&U(r.getExpression(),t))return!0;for(const r of s.getDescendantsOfKind(u.VariableDeclaration)){const n=r.getNameNode();if(!(!i.isObjectBindingPattern(n)||!U(r.getInitializer(),t))){for(const o of n.getElements())if((o.getPropertyNameNode()?.getText()??o.getNameNode().getText())==="auth")return!0}}return!1},Qn=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!_n.has(t.getName()))return;let s=t.getExpression();for(;i.isCallExpression(s);){const r=s.getExpression();if(!i.isPropertyAccessExpression(r))return;const n=r.getName();if(Gn.has(n)){const o=r.getExpression();return i.isIdentifier(o)&&o.getText()==="httpRoute"?n.toUpperCase():void 0}s=r.getExpression()}},Xn=(e,t)=>{const s=e.getExpression();if(i.isIdentifier(s)&&s.getText()==="httpAction"){const c=it(e.getArguments()[0]),l=c&&ot(c,!0);if(!c||l===void 0)return;const p=at(c,l);return p===void 0?void 0:{exportName:h(e),file:t,kind:"httpAction",line:e.getStartLineNumber(),readsAuth:ct(c,l),sideEffect:p}}const r=Qn(e);if(r===void 0)return;const n=it(e.getArguments()[0]),o=n&&ot(n,!1);if(!n||o===void 0)return;const a=at(n,o);return a===void 0?void 0:{exportName:h(e),file:t,kind:"httpRoute",line:e.getStartLineNumber(),method:r,readsAuth:ct(n,o),sideEffect:a}},Zn=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=Xn(r,t);n&&s.push(n)}return s},Yn=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Zn(n,f(t,r)))}return s},ei=new Set(["btoa","encodeURI","encodeURIComponent","isSafeHeaderValue","Number","parseFloat","parseInt"]),ti=new Set(["append","set"]),$e=e=>i.isIdentifier(e)?e.getText():i.isPropertyAccessExpression(e)?e.getName():"",$t=e=>e!==void 0&&(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))?e.getLiteralText():"",ut=(e,t)=>(i.isCallExpression(e)?[e,...e.getDescendantsOfKind(u.CallExpression)]:e.getDescendantsOfKind(u.CallExpression)).some(s=>ei.has($e(s.getExpression()))&&B(s,t)),si=(e,t)=>{if(ut(e,t))return!0;const s=L(e);return s!==void 0&&ut(s,t)},ye=(e,t)=>rr(e,t)&&!si(e,t),ri=e=>{if(i.isPropertyAccessExpression(e)&&e.getName()==="headers")return!0;const t=L(e);return t!==void 0&&i.isNewExpression(t)&&$e(t.getExpression())==="Headers"},W=e=>{if(e===void 0)return;if(i.isObjectLiteralExpression(e))return e;const t=L(e);return t!==void 0&&i.isObjectLiteralExpression(t)?t:void 0},Se=(e,t,s)=>{for(const r of e.getProperties())if(i.isPropertyAssignment(r)){const n=r.getInitializer();n!==void 0&&ye(n,s.requestName)&&s.rows.push({exportName:s.exportName,file:s.relativePath,headerName:$t(r.getNameNode()),line:n.getStartLineNumber(),via:t})}else if(i.isShorthandPropertyAssignment(r)){const n=r.getNameNode();ye(n,s.requestName)&&s.rows.push({exportName:s.exportName,file:s.relativePath,headerName:r.getName(),line:n.getStartLineNumber(),via:t})}else if(i.isSpreadAssignment(r)){const n=W(r.getExpression());n!==void 0&&Se(n,t,s)}},St=(e,t)=>{const s=W(e);if(s===void 0)return;const r=s.getProperty("headers");if(r===void 0||!i.isPropertyAssignment(r))return;const n=W(r.getInitializer());n!==void 0&&Se(n,"response-init",t)},ni=(e,t)=>{const s=$e(e.getExpression());if(s==="Response")St(e.getArguments()[1],t);else if(s==="Headers"){const r=W(e.getArguments()[0]);r!==void 0&&Se(r,"headers-ctor",t)}},ii=(e,t)=>{const s=e.getExpression();if(!i.isPropertyAccessExpression(s))return;const r=s.getName(),n=s.getExpression();if(r==="json"&&i.isIdentifier(n)&&n.getText()==="Response"){St(e.getArguments()[1],t);return}if(ti.has(r)&&ri(n)){const o=e.getArguments()[1];o!==void 0&&ye(o,t.requestName)&&t.rows.push({exportName:t.exportName,file:t.relativePath,headerName:$t(e.getArguments()[0]),line:o.getStartLineNumber(),via:r==="set"?"headers-set":"headers-append"})}},oi=(e,t)=>{for(const s of e.getDescendantsOfKind(u.NewExpression))ni(s,t);for(const s of e.getDescendantsOfKind(u.CallExpression))ii(s,t)},ai=(e,t)=>{const s=e.getExpression();if(!i.isIdentifier(s)||s.getText()!=="httpAction")return[];const r=Gt(e.getArguments()[0]);if(r===void 0)return[];const n=r.getParameters()[1];if(n===void 0)return[];const o=n.getNameNode();if(!i.isIdentifier(o))return[];const a=[];return oi(r,{exportName:h(e),relativePath:t,requestName:o.getText(),rows:a}),a},ci=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression))s.push(...ai(r,t));return s},ui=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...ci(n,f(t,r)))}return s},Nt="identity.ts",li=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineIdentity";for(const s of t.getDeclarations())if(i.isImportSpecifier(s))return H(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineIdentity":!1;return!1},di=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!i.isNamespaceImport(s))continue;const r=s.getFirstAncestorByKind(u.ImportDeclaration);return r!==void 0&&H(r.getModuleSpecifierValue())}return!1},gi=e=>{if(i.isIdentifier(e))return li(e);if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineIdentity"&&i.isIdentifier(t)&&di(t)}return!1},fi=e=>{const t=[];for(const s of e.getVariableDeclarations()){if(!s.isExported())continue;const r=s.getInitializer();if(r?.getKind()!==u.CallExpression||!gi(r.getExpression()))continue;const n=s.getNameNode();if(!i.isIdentifier(n))throw _(n,"defineIdentity exports must be plain named exports (no destructuring)");t.push({exportName:n.getText()})}return t},pi=(e,t)=>{const s=g(t,Nt);if(!E(s))return;const r=e.getSourceFile(s)??e.addSourceFileAtPath(s),n=fi(r);if(n.length!==0){if(n.length>1)throw _(r,`lunora/identity.ts declares ${n.length.toString()} defineIdentity() contracts (${n.map(o=>o.exportName).join(", ")}); exactly one is allowed`);return n[0]}},mi=new Set(["auth","context.auth","ctx.auth"]),xi="userId",hi=e=>{const t=new Set;for(const s of e.getProperties()){if(i.isSpreadAssignment(s))return;(i.isPropertyAssignment(s)||i.isShorthandPropertyAssignment(s)||i.isMethodDeclaration(s))&&t.add(s.getName())}return t},Ei=(e,t)=>{const s=g(t,Nt);if(!E(s))return;const r=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const n of r.getDescendantsOfKind(u.CallExpression)){if(S(n.getExpression())!=="defineIdentity")continue;const[o]=n.getArguments();return o&&i.isObjectLiteralExpression(o)?hi(o):void 0}},lt=e=>{if(!(e===void 0||!i.isPropertyAccessExpression(e)||e.getName()!=="identity"))return mi.has(e.getExpression().getText())?e:void 0},yi=e=>{if(i.isPropertyAccessExpression(e)&&lt(e.getExpression())!==void 0)return e.getName();if(i.isElementAccessExpression(e)&&lt(e.getExpression())!==void 0){const t=e.getArgumentExpression();return t&&i.isStringLiteral(t)?t.getLiteralValue():void 0}},Ai=(e,t,s)=>{const r=[];for(const n of e.getDescendants()){const o=yi(n);o!==void 0&&r.push({declared:o===xi||s.has(o),exportName:h(n),file:t,key:o,line:n.getStartLineNumber()})}return r},$i=(e,t)=>{const s=Ei(e,t);if(s===void 0)return[];const r=[];for(const n of d(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);r.push(...Ai(o,f(t,n),s))}return r},Si=e=>{if(!i.isObjectLiteralExpression(e))return;const t=e.getProperty("key");return t&&i.isPropertyAssignment(t)?t.getInitializer():void 0},Ni=(e,t)=>{if(S(e.getExpression())!=="buildImageDeliveryUrl")return;const s=e.getArguments()[0];if(!s)return;const r=Si(s);if(!(!r||!w(r)||T(r)))return{exportName:h(e),file:t,line:e.getStartLineNumber()}},vi=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=Ni(r,t);n&&s.push(n)}return s},bi=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...vi(n,f(t,r)))}return s},Pi=new Set(["delete","get","getRaw","getWithMetadata","put"]),wi=(e,t)=>J(e,t,{argIndex:0,matchReceiver:s=>s==="ctx.kv"||s.startsWith("ctx.kv."),methods:Pi}),Ii=new Set(["queue","send"]),dt=new Set(["bcc","cc","to"]),Oi=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();if(!Ii.has(t))return;const s=e.getExpression().getText();return s==="ctx.mail"||s==="ctx.email"?t:void 0},Li=e=>i.isObjectLiteralExpression(e)?e.getProperties().some(t=>{if(i.isShorthandPropertyAssignment(t)){const r=t.getNameNode();return dt.has(t.getName())&&w(r)&&!T(r)}if(!i.isPropertyAssignment(t)||!dt.has(t.getName()))return!1;const s=t.getInitializer();return s!==void 0&&w(s)&&!T(s)}):!1,Fi=(e,t)=>{const s=Oi(e.getExpression());if(s===void 0)return;const r=e.getArguments()[0];if(!(!r||!Li(r)))return{exportName:h(e),file:t,line:e.getStartLineNumber(),method:s}},Ti=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=Fi(r,t);n&&s.push(n)}return s},Di=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Ti(n,f(t,r)))}return s},Ci=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="replace")return!1;const s=t.getExpression();return i.isPropertyAccessExpression(s)?s.getName()==="db":i.isIdentifier(s)&&s.getText()==="db"},ki=e=>{const t=e.getArguments()[0];if(t===void 0||!i.isObjectLiteralExpression(t))return;const s=t.getProperty("server");if(s!==void 0)return i.isPropertyAssignment(s)?s.getInitializer():s},Ki=e=>{if(!e.isExported())return;const t=e.getInitializer();if(t?.getKind()!==u.CallExpression)return;const s=t;return Ns(s.getExpression())?s:void 0},Ri=e=>{const t=Ki(e),s=t===void 0?void 0:ki(t);if(s===void 0)return[];const r=e.getNameNode(),n=i.isIdentifier(r)?r.getText():"";return s.getDescendantsOfKind(u.CallExpression).filter(o=>Ci(o)).map(o=>({exportName:n,file:"lunora/mutators.ts",line:o.getStartLineNumber()}))},Mi=e=>e.getVariableDeclarations().flatMap(t=>Ri(t)),ji=(e,t)=>{const s=g(t,Ss);if(!E(s))return[];const r=e.getSourceFile(s)??e.addSourceFileAtPath(s);return Mi(r)},zi=new Set(["delete","get","patch"]),qi=new Set(["accountId","authorId","companyId","createdBy","createdById","customerId","groupId","memberId","organizationId","orgId","ownerId","projectId","teamId","tenantId","userId","workspaceId"]),Bi=new Set(["auth","identity","session","user"]),Vi=new Set([u.EqualsEqualsEqualsToken,u.EqualsEqualsToken,u.ExclamationEqualsEqualsToken,u.ExclamationEqualsToken]),Ui=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="normalizeId"||!k(t.getExpression()))return;const s=e.getArguments()[0];return s&&i.isStringLiteral(s)?s.getLiteralText():""},Wi=e=>{let t=e,s=t.getParent();for(;s!==void 0&&(i.isAsExpression(s)||i.isParenthesizedExpression(s)||i.isNonNullExpression(s));)t=s,s=t.getParent();if(s===void 0||!i.isVariableDeclaration(s))return;const r=s.getNameNode();return i.isIdentifier(r)?r.getText():void 0},Gi=(e,t)=>e.getDescendantsOfKind(u.Identifier).some(s=>s.getText()===t),_i=e=>i.isThrowStatement(e)||i.isReturnStatement(e)||e.getDescendantsOfKind(u.ThrowStatement).length>0||e.getDescendantsOfKind(u.ReturnStatement).length>0,Hi=(e,t)=>e.getDescendantsOfKind(u.IfStatement).some(s=>Gi(s.getExpression(),t)&&_i(s.getThenStatement())),Ji=(e,t)=>{for(const s of e.getDescendantsOfKind(u.CallExpression)){const r=s.getExpression();if(!i.isPropertyAccessExpression(r))continue;const n=r.getName();if(!zi.has(n))continue;const o=r.getExpression();if(!(k(o)||i.isPropertyAccessExpression(o)&&k(o.getExpression())))continue;const a=s.getArguments()[0];if(a!==void 0&&i.isIdentifier(a)&&a.getText()===t)return n}},Qi=e=>{let t=e;for(;i.isPropertyAccessExpression(t)||i.isElementAccessExpression(t)||i.isNonNullExpression(t)||i.isParenthesizedExpression(t)||i.isAsExpression(t)||i.isAwaitExpression(t);)t=t.getExpression();return i.isIdentifier(t)?t.getText():void 0},Xi=e=>e.getDescendantsOfKind(u.CallExpression).some(t=>t.getArguments().some(s=>Qi(s)==="ctx")),Zi=e=>e.getDescendantsOfKind(u.BinaryExpression).some(t=>Vi.has(t.getOperatorToken().getKind())?i.isPropertyAccessExpression(t.getLeft())||i.isPropertyAccessExpression(t.getRight()):!1),Yi=e=>{for(const t of e.getDescendantsOfKind(u.Identifier))if(qi.has(t.getText()))return!0;for(const t of e.getDescendantsOfKind(u.PropertyAccessExpression)){const s=t.getExpression();if(i.isIdentifier(s)&&s.getText()==="ctx"&&Bi.has(t.getName()))return!0}return Xi(e)||Zi(e)},eo=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!i.isCallExpression(s))return[];const r=K(s);if(r?.kind!=="query"&&r?.kind!=="mutation")return[];const n=mt(s);if(n===void 0)return[];const o=r.receiver!==void 0&&xt(r.receiver,"use","rls"),a=Yi(n),c=new Set,l=[];for(const p of n.getDescendantsOfKind(u.CallExpression)){const y=Ui(p);if(y===void 0)continue;const I=Wi(p);if(I===void 0||c.has(I)||!Hi(n,I))continue;const R=Ji(n,I);R!==void 0&&(c.add(I),l.push({exportName:e.getName(),file:t,line:p.getStartLineNumber(),mentionsOwnership:a,sinkMethod:R,table:y,usesRls:o,visibility:r.visibility}))}return l},to=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),o=f(t,r);for(const a of n.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...eo(c,o))}return s},so=new Set(["accountId","authorId","createdBy","createdById","organizationId","orgId","ownerId","tenantId","updatedBy","userId","workspaceId"]),ro=new Set(["insert","insertManyUnsafe","patch","replace"]),no=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();if(!ro.has(t))return;const s=e.getExpression();if(!i.isPropertyAccessExpression(s)||s.getName()!=="db")return;const r=s.getExpression();return i.isIdentifier(r)&&r.getText()==="ctx"?t:void 0},io=(e,t)=>{if(t!=="insertManyUnsafe")return i.isObjectLiteralExpression(e)?[e]:[];if(!i.isArrayLiteralExpression(e))return[];const s=[];for(const r of e.getElements())i.isObjectLiteralExpression(r)&&s.push(r);return s},oo=(e,t,s,r)=>{const n=[];for(const o of e.getProperties()){let a,c;i.isPropertyAssignment(o)?(a=o.getName(),c=o.getInitializer()):i.isShorthandPropertyAssignment(o)&&(a=o.getName(),c=o.getNameNode()),!(a===void 0||c===void 0||!so.has(a))&&w(c)&&!T(c)&&n.push({exportName:h(s),field:a,file:r,line:s.getStartLineNumber(),method:t})}return n},ao=(e,t)=>{const s=no(e.getExpression());if(s===void 0)return[];const r=e.getArguments()[1];return r?io(r,s).flatMap(n=>oo(n,s,e,t)):[]},co=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression))s.push(...ao(r,t));return s},uo=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...co(n,f(t,r)))}return s},lo=e=>{const t=g(e,"package.json");if(!E(t))return new Set;try{const s=JSON.parse(Ae(t,"utf8")),r=new Set;for(const n of["dependencies","devDependencies","peerDependencies","optionalDependencies"]){const o=s[n];if(o!==null&&typeof o=="object")for(const a of Object.keys(o))r.add(a)}return r}catch{return new Set}},go=new Set(["createAutumnAdapter","createDodoPaymentsAdapter","createPolarAdapter","createStripeAdapter"]),fo=e=>e&&i.isNumericLiteral(e)?Number(e.getText()):void 0,po=e=>{const t=e.getProperty("webhookToleranceSeconds");return t&&i.isPropertyAssignment(t)?fo(t.getInitializer()):void 0},mo=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=S(r.getExpression());if(n===void 0||!go.has(n))continue;const[o]=r.getArguments(),a=o&&i.isObjectLiteralExpression(o)?po(o):void 0;s.push({callee:n,exportName:h(r),file:t,line:r.getStartLineNumber(),...a===void 0?{}:{toleranceSeconds:a}})}return s},xo=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...mo(n,f(t,r)))}return s},ho=new Set(["defineQueue","defineWorkflow"]),Eo=new Set(["run","runAction","runMutation","runQuery"]),yo=new Set(["api","internal"]),Ao=e=>{const t=e.getExpression();return i.isIdentifier(t)?t.getText():void 0},$o=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return;const s=t.getProperty("handler");if(s===void 0||!i.isPropertyAssignment(s))return;const r=s.getInitializer();if(r&&(i.isArrowFunction(r)||i.isFunctionExpression(r)))return r},vt=(e,t)=>{const s=e.getParameters()[t]?.getNameNode();return s&&i.isIdentifier(s)?s.getText():void 0},bt=(e,t)=>e===t||e.startsWith(`${t}.`),Pt=e=>{const t=e.getDescendantsOfKind(u.PropertyAccessExpression);return i.isPropertyAccessExpression(e)&&t.push(e),t},gt=e=>{const t=e.getParent();return i.isPropertyAccessExpression(t)&&t.getNameNode()===e||i.isPropertyAssignment(t)&&t.getNameNode()===e?!1:!(i.isBindingElement(t)&&t.getNameNode()===e)},wt=e=>{const t=e.getDescendantsOfKind(u.Identifier).filter(s=>gt(s));return i.isIdentifier(e)&&gt(e)&&t.push(e),t},So=e=>{if(!i.isVariableDeclaration(e))return[];const t=e.getNameNode();return i.isIdentifier(t)?[t.getText()]:t.getDescendantsOfKind(u.BindingElement).map(s=>s.getName())},No=e=>{const t=vt(e,1);if(t===void 0)return[];const s=[`${t}.messages`];for(const r of e.getDescendantsOfKind(u.ForOfStatement)){if(r.getExpression().getText()!==`${t}.messages`)continue;const n=r.getInitializer(),o=i.isVariableDeclarationList(n)?n.getDeclarations()[0]?.getNameNode():void 0;o&&i.isIdentifier(o)&&s.push(`${o.getText()}.body`)}return s},vo=(e,t,s)=>{const r=t==="workflow"?[`${s}.params`]:No(e),n=new Set,o=a=>Pt(a).some(c=>r.some(l=>bt(c.getText(),l)))?!0:wt(a).some(c=>n.has(c.getText()));for(const a of e.getDescendantsOfKind(u.VariableDeclaration)){const c=a.getInitializer();if(c&&o(c))for(const l of So(a))n.add(l)}return{names:n,prefixes:r}},bo=(e,t)=>Pt(e).some(s=>t.prefixes.some(r=>bt(s.getText(),r)))?!0:wt(e).some(s=>t.names.has(s.getText())),Po=e=>{if(e===void 0||!i.isPropertyAccessExpression(e))return;const t=[];let s=e;for(;i.isPropertyAccessExpression(s);)t.unshift(s.getName()),s=s.getExpression();const r=t.at(-1);if(!(r===void 0||!i.isIdentifier(s)||!yo.has(s.getText())||t.length<2))return{exportName:r,file:t.slice(0,-1).join("/")}},wo=(e,t,s)=>{const r=vt(e,0);if(r===void 0)return[];const n=vo(e,t,r),o=[];for(const a of e.getDescendantsOfKind(u.CallExpression)){const c=a.getExpression();if(!i.isPropertyAccessExpression(c)||!Eo.has(c.getName())||c.getExpression().getText()!==r)continue;const l=a.getArguments()[1];if(!l||!bo(l,n))continue;const p=Po(a.getArguments()[0]);p!==void 0&&o.push({dispatchKind:t,file:s,handlerExport:h(a),line:a.getStartLineNumber(),targetExport:p.exportName,targetFile:p.file})}return o},Io=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=Ao(r);if(n===void 0||!ho.has(n))continue;const o=$o(r);o!==void 0&&s.push(...wo(o,n==="defineQueue"?"queue":"workflow",t))}return s},Oo=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Io(n,f(t,r)))}return s},ft={dbRateLimit:"usesRateLimit",emailGateMiddleware:"usesEmailGate",mask:"usesMask",rateLimit:"usesRateLimit",rls:"usesRls",verifyTurnstile:"usesCaptcha",verifyTurnstileMiddleware:"usesCaptcha"},Lo=/account|credential|member|passkey|session|user/iu,Fo=e=>{const t=e.replaceAll(/[^a-z0-9]/giu,"").toLowerCase();return t.endsWith("email")||t.endsWith("emailaddress")},To=(e,t)=>{const{objects:s,opaque:r}=yt(e,t);return vr(s).some(n=>Fo(n))?!0:r?void 0:!1},It=e=>{const t=e.getExpression();if(i.isIdentifier(t))return t.getText();if(i.isPropertyAccessExpression(t))return t.getName()},Do=e=>{const t=e.getArguments()[0];return!t||!i.isObjectLiteralExpression(t)?{usesCaptcha:!1,usesRateLimit:!1}:{usesCaptcha:!!t.getProperty("captcha"),usesRateLimit:!!t.getProperty("rateLimit")}},Co=e=>{if(i.isCallExpression(e))return e;if(!i.isIdentifier(e))return;const t=e.getSourceFile().getVariableDeclaration(e.getText())?.getInitializer();return t&&i.isCallExpression(t)?t:void 0},V={usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},ko=e=>{const t=Co(e),s=t?It(t):void 0;if(t&&s==="protectPublic"){const r=Do(t);return{...V,usesCaptcha:r.usesCaptcha,usesRateLimit:r.usesRateLimit}}return s!==void 0&&s in ft?{...V,[ft[s]]:!0}:V},Ko=e=>{const t={...V};let s=e;for(;i.isCallExpression(s);){const r=s.getExpression();if(!i.isPropertyAccessExpression(r))break;const n=r.getName()==="use"?s.getArguments()[0]:void 0;if(n){const o=ko(n);t.usesCaptcha||=o.usesCaptcha,t.usesEmailGate||=o.usesEmailGate,t.usesMask||=o.usesMask,t.usesRateLimit||=o.usesRateLimit,t.usesRls||=o.usesRls}s=r.getExpression()}return t},Ro=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="insert")return!1;const s=t.getExpression();if(!(i.isPropertyAccessExpression(s)?s.getName()==="db":i.isIdentifier(s)&&s.getText()==="db"))return!1;const r=e.getArguments()[0];return!!(r&&i.isStringLiteral(r)&&Lo.test(r.getLiteralText()))},Mo=new Set(["create","runAfter","runAt","send","sendBatch"]),jo=new Set(["queues","scheduler","workflows"]),zo=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!Mo.has(t.getName()))return!1;let s=t.getExpression();for(;i.isCallExpression(s)||i.isElementAccessExpression(s)||i.isPropertyAccessExpression(s);){if(i.isPropertyAccessExpression(s)&&jo.has(s.getName())){const r=s.getExpression();if(i.isIdentifier(r)&&r.getText()==="ctx")return!0}s=s.getExpression()}return!1},qo=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="insertManyUnsafe")return!1;const s=t.getExpression();return i.isPropertyAccessExpression(s)?s.getName()==="db":i.isIdentifier(s)&&s.getText()==="db"},Bo=new Set(["generateObject","generateText","streamObject","streamText"]),Vo=e=>{const t=It(e);if(t===void 0||!Bo.has(t))return!1;const s=e.getArguments()[0];return!s||!i.isObjectLiteralExpression(s)||s.getProperties().some(r=>i.isSpreadAssignment(r))?!1:!s.getProperty("maxOutputTokens")},Uo=e=>e.getDescendantsOfKind(u.PropertyAccessExpression).some(t=>{const s=t.getName();if(s!=="mail"&&s!=="email")return!1;const r=t.getExpression();return i.isIdentifier(r)&&r.getText()==="ctx"}),Wo=e=>{let t=!1,s=!1,r=!1,n=!1;for(const o of e.getDescendantsOfKind(u.CallExpression))if(Ro(o)&&(n=!0),zo(o)&&(t=!0),qo(o)&&(r=!0),Vo(o)&&(s=!0),n&&t&&r&&s)break;return{callsMail:Uo(e),fanOut:t,unboundedAiGeneration:s,usesInsertManyUnsafe:r,writesUserTable:n}},Go=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const r=K(s);if(!r||r.kind!=="query"&&r.kind!=="mutation"&&r.kind!=="action")return;const n=r.receiver?Ko(r.receiver):{usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},{callsMail:o,fanOut:a,unboundedAiGeneration:c,usesInsertManyUnsafe:l,writesUserTable:p}=Wo(e);return{callsMail:o,exportName:e.getName(),fanOut:a,file:t,hasEmailArg:To(s,r.receiver),kind:r.kind,unboundedAiGeneration:c,usesCaptcha:n.usesCaptcha,usesEmailGate:n.usesEmailGate,usesInsertManyUnsafe:l,usesMask:n.usesMask,usesRateLimit:n.usesRateLimit,usesRls:n.usesRls,visibility:r.visibility,writesUserTable:p}},_o=(e,t)=>{const s=[];for(const r of e.getVariableStatements())if(r.isExported())for(const n of r.getDeclarations()){const o=Go(n,t);o&&s.push(o)}return s},Ho=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(..._o(n,f(t,r)))}return s},Jo=new Set(["dbRateLimit","rateLimit"]),Qo=e=>{if(!i.isObjectLiteralExpression(e))return;const t=e.getProperty("key");return t&&i.isPropertyAssignment(t)?t.getInitializer():void 0},Xo=e=>{const t=e.getArguments()[1];return t&&i.isStringLiteral(t)?t.getLiteralValue():""},Zo=e=>i.isArrowFunction(e)?e.getBody():e,Yo=(e,t)=>{const s=S(e.getExpression());if(s===void 0||!Jo.has(s))return;const r=e.getArguments()[2];if(!r)return;const n=Qo(r);if(!n)return;const o=Zo(n);if(!(!w(o)||T(o)))return{callee:s,exportName:h(e),file:t,limitName:Xo(e),line:e.getStartLineNumber()}},ea=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=Yo(r,t);n&&s.push(n)}return s},ta=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...ea(n,f(t,r)))}return s},sa=new Set(["findFirst","findFirstOrThrow","findMany","get"]),ra=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!sa.has(t.getName()))return;const s=t.getExpression();if(k(s)){const r=e.getArguments()[0];return r&&i.isStringLiteral(r)?r.getLiteralText():""}if(i.isPropertyAccessExpression(s)&&k(s.getExpression()))return s.getName()},na=e=>{let t=e;for(;i.isCallExpression(t);){const s=t.getExpression();if(!i.isPropertyAccessExpression(s))return;if(s.getName()==="query"&&k(s.getExpression())){const r=t.getArguments()[0];return r&&i.isStringLiteral(r)?r.getLiteralText():""}t=s.getExpression()}},ia=e=>{let t=e;for(;i.isAwaitExpression(t)||i.isParenthesizedExpression(t)||i.isNonNullExpression(t)||i.isAsExpression(t);)t=t.getExpression();return t},Ot=(e,t=!1)=>{const s=ia(e);if(i.isIdentifier(s)){if(t)return;const r=L(s);return r===void 0?void 0:Ot(r,!0)}if(i.isCallExpression(s))return ra(s)??na(s)},oa=e=>{const t=e.getBody();if(!i.isBlock(t))return[t];const s=[];for(const r of e.getDescendantsOfKind(u.ReturnStatement)){const n=r.getFirstAncestor(a=>i.isArrowFunction(a)||i.isFunctionExpression(a)||i.isFunctionDeclaration(a)),o=r.getExpression();n===e&&o!==void 0&&s.push(o)}return s},aa=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!i.isCallExpression(s))return[];const r=K(s);if(r?.kind!=="query")return[];const n=mt(s);if(n===void 0)return[];const o=r.receiver!==void 0&&_t(r.receiver,"output"),a=r.receiver!==void 0&&xt(r.receiver,"use","mask"),c=new Set,l=[];for(const p of oa(n)){const y=Ot(p);y===void 0||c.has(y)||(c.add(y),l.push({exportName:e.getName(),file:t,line:p.getStartLineNumber(),table:y,usesMask:a,usesOutput:o,visibility:r.visibility}))}return l},ca=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),o=f(t,r);for(const a of n.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...aa(c,o))}return s},ua=new Set(["findFirst","findFirstOrThrow","findMany"]),la=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!ua.has(t.getName()))return;const s=t.getExpression();if(i.isPropertyAccessExpression(s)&&s.getName()==="db"||i.isIdentifier(s)&&s.getText()==="db"){const r=e.getArguments()[0];return{options:e.getArguments()[1],table:r&&i.isStringLiteral(r)?r.getLiteralText():""}}if(i.isPropertyAccessExpression(s)){const r=s.getExpression();if(i.isPropertyAccessExpression(r)&&r.getName()==="db"||i.isIdentifier(r)&&r.getText()==="db")return{options:e.getArguments()[0],table:s.getName()}}},da=e=>{if(!e||!i.isObjectLiteralExpression(e))return[];const t=[];for(const s of e.getProperties())(i.isPropertyAssignment(s)||i.isShorthandPropertyAssignment(s)||i.isMethodDeclaration(s)||i.isGetAccessorDeclaration(s))&&t.push(s.getName());return t},ga=(e,t)=>{if(!e||!i.isObjectLiteralExpression(e))return;const s=e.getProperty(t);return s&&i.isPropertyAssignment(s)?s.getInitializer():void 0},fa=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer(),r=s&&i.isCallExpression(s)?K(s):void 0;if(!r)return[];const n=[];for(const o of e.getDescendantsOfKind(u.CallExpression)){const a=la(o);if(a===void 0)continue;const c=da(ga(a.options,"with"));c.length!==0&&n.push({exportName:e.getName(),file:t,line:o.getStartLineNumber(),parentTable:a.table,relations:c,visibility:r.visibility})}return n},pa=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),o=f(t,r);for(const a of n.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...fa(c,o))}return s},G=e=>{if(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))return e.getLiteralText();if(i.isBinaryExpression(e)&&e.getOperatorToken().getKind()===u.PlusToken){const t=G(e.getLeft()),s=G(e.getRight());return t!==void 0&&s!==void 0?t+s:void 0}},ma=e=>{let t=e,s=t.getParent();for(;s!==void 0&&i.isBinaryExpression(s)&&s.getOperatorToken().getKind()===u.PlusToken;)t=s,s=t.getParent();return t!==e&&G(t)!==void 0},xa=(e,t)=>{const s=[],r=[...e.getDescendantsOfKind(u.BinaryExpression),...e.getDescendantsOfKind(u.StringLiteral),...e.getDescendantsOfKind(u.NoSubstitutionTemplateLiteral)],n=new Set;for(const o of r){if(ma(o))continue;const a=G(o);if(a===void 0)continue;const c=ks(a);if(c===void 0)continue;const l=o.getStartLineNumber(),p=`${String(l)}:${c}`;n.has(p)||(n.add(p),s.push({file:t,kind:c,line:l,preview:Ks(a)}))}return s},ha=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...xa(n,f(t,r)))}return s},Ea=new Set(["findFirst","findFirstOrThrow","findMany"]),ya=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!Ea.has(t.getName()))return;const s=t.getExpression();if(i.isPropertyAccessExpression(s)&&s.getName()==="db"||i.isIdentifier(s)&&s.getText()==="db"){const r=e.getArguments()[0];return{options:e.getArguments()[1],table:r&&i.isStringLiteral(r)?r.getLiteralText():""}}if(i.isPropertyAccessExpression(s)){const r=s.getExpression();if(i.isPropertyAccessExpression(r)&&r.getName()==="db"||i.isIdentifier(r)&&r.getText()==="db")return{options:e.getArguments()[0],table:s.getName()}}},Aa=(e,t)=>{if(!e||!i.isObjectLiteralExpression(e))return;const s=e.getProperty(t);return s&&i.isPropertyAssignment(s)?s.getInitializer():void 0},$a=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer(),r=s&&i.isCallExpression(s)?K(s):void 0;if(!r)return[];const n=[];for(const o of e.getDescendantsOfKind(u.CallExpression)){const a=ya(o);if(a===void 0)continue;const c=Aa(a.options,"includeDeleted");if(c===void 0)continue;const l=i.isTrueLiteral(c),p=!l&&w(c);!l&&!p||n.push({exportName:e.getName(),file:t,fromArgs:p,hardcodedTrue:l,line:o.getStartLineNumber(),table:a.table,visibility:r.visibility})}return n},Sa=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),o=f(t,r);for(const a of n.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...$a(c,o))}return s},Na=new Set(["query","unsafe"]),va=e=>{if(!i.isPropertyAccessExpression(e)||!Na.has(e.getName()))return!1;const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="sql")return!1;const s=t.getExpression();return i.isIdentifier(s)&&s.getText()==="ctx"},ba=e=>i.isBinaryExpression(e)||i.isTemplateExpression(e),Pa=e=>e.getFirstAncestorByKind(u.VariableDeclaration)?.getName()??"<module>",wa=(e,t)=>{if(!va(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!ba(s)))return{exportName:Pa(e),file:t,line:s.getStartLineNumber()}},Ia=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=wa(r,t);n&&s.push(n)}return s},Oa=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Ia(n,f(t,r)))}return s},La=new Set(["createMultipartUpload","delete","download","generateUploadUrl","get","getMetadata","getPresignedUrl","getSignedUrl","getUrl","head","put","resumeMultipartUpload","store","upload"]),Fa=(e,t)=>J(e,t,{argIndex:0,matchReceiver:s=>s==="ctx.storage"||s.startsWith("ctx.storage."),methods:La}),Ta=new Map([["generateUploadUrl",1],["getPresignedUrl",1],["getSignedUrl",1],["store",2],["upload",2]]),Da=e=>e&&i.isNumericLiteral(e)?Number(e.getText()):void 0,Ca=e=>{if(e===void 0)return{analyzable:!0,presentKeys:[]};if(!i.isObjectLiteralExpression(e))return{analyzable:!1,presentKeys:[]};const t=[];let s,r=!1;for(const n of e.getProperties()){if(i.isSpreadAssignment(n)){r=!0;continue}if(i.isPropertyAssignment(n)){const o=n.getName();t.push(o),o==="expiresInSeconds"&&(s=Da(n.getInitializer()));continue}(i.isShorthandPropertyAssignment(n)||i.isMethodDeclaration(n))&&t.push(n.getName())}return{analyzable:!r,expiresInSeconds:s,presentKeys:t}},ka=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName(),s=Ta.get(t);if(s===void 0)return;const r=e.getExpression().getText();return r==="ctx.storage"||r.startsWith("ctx.storage.")?{method:t,optionsIndex:s}:void 0},Ka=(e,t)=>{const s=ka(e.getExpression());if(s!==void 0)return{exportName:h(e),file:t,line:e.getStartLineNumber(),method:s.method,...Ca(e.getArguments()[s.optionsIndex])}},Ra=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=Ka(r,t);n&&s.push(n)}return s},Ma=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Ra(n,f(t,r)))}return s},ja=new Set(["when","where"]),he=new Set(["definePolicy","defineShape"]),za=e=>{if(!i.isCallExpression(e))return;const t=e.getExpression();if(i.isPropertyAccessExpression(t)){const r=t.getName();return he.has(r)?r:void 0}if(!i.isIdentifier(t))return;for(const r of t.getSymbol()?.getDeclarations()??[])if(i.isImportSpecifier(r)){const n=r.getNameNode().getText();return he.has(n)?n:void 0}const s=t.getText();return he.has(s)?s:void 0},qa=e=>i.isObjectLiteralExpression(e)&&e.getProperties().length===0,Lt=e=>{if(e!==void 0){if(i.isReturnStatement(e)&&e.getExpression()===void 0||e.getKind()===u.UndefinedKeyword||e.getText()==="undefined")return"undefined";if(qa(e))return"empty-object";if(i.isParenthesizedExpression(e))return Lt(e.getExpression())}},Ft=e=>e.getAncestors().find(t=>i.isArrowFunction(t)||i.isFunctionExpression(t)||i.isFunctionDeclaration(t)),Tt=e=>e.getDescendantsOfKind(u.ReturnStatement).filter(t=>Ft(t)===e),Dt=e=>e.getDescendantsOfKind(u.ConditionalExpression).filter(t=>Ft(t)===e),Ba=e=>{const t=Tt(e);return t.length>1?!0:t.some(s=>s.getFirstAncestorByKind(u.IfStatement)!==void 0)||Dt(e).length>0},Va=e=>{const t=[],s=e.getBody();i.isBlock(s)||t.push(s);for(const r of Tt(e)){const n=i.isReturnStatement(r)?r.getExpression():void 0;t.push(n??r)}for(const r of Dt(e))t.push(r.getWhenTrue(),r.getWhenFalse());return t},Ua=e=>{for(const t of e.getAncestors())if(i.isVariableDeclaration(t)){const s=t.getNameNode();if(i.isIdentifier(s))return s.getText()}return"<anonymous>"},Wa=(e,t,s)=>{if(!i.isCallExpression(e))return[];const[r]=e.getArguments();if(!r||!i.isObjectLiteralExpression(r))return[];const n=[];for(const o of r.getProperties()){if(!i.isPropertyAssignment(o)||!ja.has(o.getName()))continue;const a=o.getInitializer();if(!(!a||!(i.isArrowFunction(a)||i.isFunctionExpression(a)))&&Ba(a))for(const c of Va(a)){const l=Lt(c);l!==void 0&&n.push({exportName:Ua(e),file:s,form:l,key:o.getName(),line:c.getStartLineNumber(),owner:t})}}return n},Ga=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=za(r);n!==void 0&&s.push(...Wa(r,n,t))}return s},_a=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Ga(n,f(t,r)))}return s},Ha=new Set(["query","upsert","upsertMany"]),Ja=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();if(Ha.has(t))return e.getExpression().getText()==="ctx.vectors"?t:void 0},Qa=e=>{if(!i.isObjectLiteralExpression(e))return;const t=e.getProperty("namespace");return t&&i.isPropertyAssignment(t)?t.getInitializer():void 0},Xa=(e,t)=>{const s=Ja(e.getExpression());if(s===void 0)return;const r=e.getArguments()[1];if(!r)return;const n=Qa(r);if(!(!n||!w(n)||T(n)))return{exportName:h(e),file:t,line:e.getStartLineNumber(),method:s}},Za=(e,t)=>{const s=[];for(const r of e.getDescendantsOfKind(u.CallExpression)){const n=Xa(r,t);n&&s.push(n)}return s},Ya=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Za(n,f(t,r)))}return s},ec=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="get")return!1;const s=t.getExpression();return i.isPropertyAccessExpression(s)?s.getName()==="workflows":i.isIdentifier(s)&&s.getText()==="workflows"},tc=e=>{const t=e.getArguments()[0];return t&&i.isStringLiteral(t)?t.getLiteralText():""},sc=(e,t)=>{const s=[];for(const r of d(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),o=f(t,r);for(const a of n.getDescendantsOfKind(u.CallExpression)){if(!ec(a))continue;const c=js(a);c!==""&&s.push({exportName:c,file:o,line:a.getStartLineNumber(),workflow:tc(a)})}}return s},rc=".lunora-schema.json",$=(e,t)=>{E(e)&&Ae(e,"utf8")===t||Vt(e,t,"utf8")},P=(e,t)=>{if(t===""){Ut(e,{force:!0});return}$(e,t)},nc=e=>{const t=g(e,"package.json");if(E(t))try{const s=JSON.parse(Ae(t,"utf8"));return typeof s.version=="string"&&s.version!==""?s.version:void 0}catch{return}},ic=()=>{const e=process.env.LUNORA_CODEGEN_TIMING;return e!==void 0&&e!==""},oc=e=>{let t=E(e)?e:ge(e);for(;t&&t!==ge(t);){const s=g(t,"tsconfig.json");if(E(s))return s;t=ge(t)}},pt=e=>e.replaceAll("\\","/"),ac=(e,t)=>{const s=new Map,r=new Map,n=new Map;for(const o of e)s.set(o.name,`workflow "${o.exportName}"`),r.set(o.bindingName,`workflow "${o.exportName}"`),n.set(o.className,`workflow "${o.exportName}"`);for(const o of t){const a=s.get(o.name);if(a!==void 0)throw new q("DUPLICATE_WORKFLOW_NAME",`Duplicate deployed name "${o.name}": produced by both ${a} and agent "${o.exportName}". Workflow and agent names share the same wrangler workflows[] array and must be unique together.`,{status:500});const c=r.get(o.bindingName);if(c!==void 0)throw new q("DUPLICATE_WORKFLOW_BINDING",`Duplicate binding "${o.bindingName}": produced by both ${c} and agent "${o.exportName}". Workflow and agent bindings share the same wrangler workflows[] array and must be unique together.`,{status:500});const l=n.get(o.className);if(l!==void 0)throw new q("DUPLICATE_WORKFLOW_CLASS",`Duplicate generated class "${o.className}": produced by both ${l} and agent "${o.exportName}". Workflow and agent export names must yield unique generated class names.`,{status:500})}},cc=e=>{const t=oc(e);return t?new Xe({skipAddingFilesFromTsConfig:!1,tsConfigFilePath:t,useInMemoryFileSystem:!1}):new Xe({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1})},Gc=(e,t)=>{const s=d(t),r=g(t,"schema.ts");E(r)&&s.push(r);for(const c of s){const l=e.getSourceFile(c);l===void 0?e.addSourceFileAtPath(c):l.refreshFromFileSystemSync()}const n=new Set(s.map(c=>pt(c))),o=pt(t),a=`${o}/`;for(const c of e.getSourceFiles()){const l=c.getFilePath();(l===o||l.startsWith(a))&&!n.has(l)&&e.removeSourceFile(c)}},_c=e=>{const t=ic(),s=t?fe.now():0,r=g(e.projectRoot,e.lunoraDirectory??"lunora"),n=g(r,"schema.ts");if(!E(n))throw new q("INTERNAL",`schema.ts not found at ${n}`);const o=e.project??cc(r),a=Cs(o,n,e.projectRoot),c=Ht(o,r),l=xs(o,r),p=$s(o,r),y=Rs(o,r),I=vs(o,r),R=pi(o,r),Ne=yn(o,r),v=zs(o,r),D=Os(o,r),b=Jt(o,r);ac(v,b);const Q=Zt(o,r,v,b),C=Xt(o,r),ve=e.lint===!1?[]:Wt({adminRoutes:tr(o,r),aiRawRuns:ar(o,r),aiToolSideEffects:hr(o,r),argumentDerivedFetches:$r(o,r),argumentValidators:Dr(o,r),authApiCalls:Qt(o,r),authConfigs:Ur(o,r),browserUrlAccesses:Jr(o,r),configCalls:rn(o,r),containerKeyAccesses:on(o,r),containerOverrides:fn(o,r),containers:C,exportSinks:Nn(o,r),failOpenGuards:Ln(o,r),flagSecurityDefaults:Bn(o,r),geoIndexUsages:Wn(o,r),httpActionGuards:Yn(o,r),httpHeaderWrites:ui(o,r),identityClaimReads:$i(o,r),imageDeliveryUrlAccesses:bi(o,r),inserts:hs(o,r),kvKeyAccesses:wi(o,r),mailRecipientAccesses:Di(o,r),maskProcedures:Es(o,r),maskStrategies:ys(o,r),mutatorWrites:ji(o,r),nondeterministicCalls:bs(o,r),normalizeIdAuthorizations:to(o,r),notifyCalls:ws(o,r),notifyConfig:Ps(o,r),ownerFieldWrites:uo(o,r),unrestrictedWhereBranches:_a(o,r),paymentWebhooks:xo(o,r),privilegedDispatches:Oo(o,r),procedureProtections:Ho(o,r),queries:Is(o,r),queues:D,r2sqlCalls:Ls(o,r),ratelimitKeySelectors:ta(o,r),rawRowReturns:ca(o,r),relationLoads:pa(o,r),rlsProcedures:Fs(o,r),schema:a,secretLiterals:ha(o,r),shapes:y,softDeleteReads:Sa(o,r),sqlInterpolations:Oa(o,r),storageKeyAccesses:Fa(o,r),storageUploads:Ma(o,r),vectorNamespaceAccesses:Ya(o,r),workflowCalls:sc(o,r),workflows:v,wranglerVariables:e.wranglerVariables}),Ct=Ts(o,r),kt=As(o,r),X=Ms(o,r),A=Tn(o,r),Z=A.ai,Y=A.payments,be=A.kv,Pe=A.access,ee=E(g(r,"flags.ts")),Kt=ee?ms(o,r):[],te=E(g(r,"notify.ts")),se=A.hyperdrive,re=Ds(o,r),Rt=re.usesSandboxBrowser||re.usesSandboxContainer,ne=A.browser||re.usesSandboxBrowser,ie=A.images,oe=A.analytics,we=A.pipelines,ae=A.r2sql,ce=A.x402,O=lo(e.projectRoot),M=Kn(A,{containerCount:C.length,cronCount:Q.length,dependencies:O,hasPaymentTables:kn(a.tables),queueCount:D.length,storageColumnCount:Object.keys(Yt(a)).length,storageRuleCount:X.rules.length,vectorIndexCount:a.vectorIndexes.length,workflowCount:v.length}),F=O.has("lunorash"),Ie=t?fe.now():0,Oe=es(a,F),Le=ts({agents:b,functions:c,httpRoutes:l,mutators:I,useUmbrella:F,workflows:v}),Fe=ss({agents:b,containers:C,env:Ne,hasAccessFacade:Pe,hasAi:Z,hasAnalytics:oe,hasBrowser:ne,hasFlags:ee,hasHyperdrive:se,hasImages:ie,hasKv:be,hasNotify:te,hasPayments:Y,hasPipelines:we,hasR2sql:ae,hasX402:ce,identity:R,queues:D,schema:a,storageRuleBuckets:X.rules.map(m=>m.bucket),useUmbrella:F,workflows:v}),Te=rs({agents:b,functions:c,migrations:p,mutators:I,shapes:y,useUmbrella:F,usesSandbox:Rt}),De=ns({advisories:ve,agents:b,containers:C,env:Ne,flagKeys:Kt,hasAccessFacade:Pe,hasAi:Z,hasAnalytics:oe,hasBrowser:ne,hasFlags:ee,hasHyperdrive:se,hasImages:ie,hasKv:be,hasNotify:te,hasPayments:Y,hasPipelines:we,hasR2sql:ae,hasX402:ce,maskMetadata:kt,mutators:I,queues:D,rlsMetadata:Ct,schema:a,shapes:y,storageRules:X,studioFeatures:M,useUmbrella:F,workflows:v}),Ce=is(y,O.has("@lunora/db"),F),ke=os(C,a.jurisdiction),Ke=as(v),Re=cs(b),Me=us(D),je=ls(Q),ze=ds(a.vectorIndexes),j=gs(a,F),qe=fs(O.has("@lunora/seed")),z=e.apiSpec??"openapi",ue=z==="openapi"||z==="both",le=z==="openrpc"||z==="both",Be=qs({emailAgents:b.filter(m=>m.onEmail===!0).map(m=>({bindingName:m.bindingName,exportName:m.exportName})),hasAccess:O.has("@lunora/cloudflare-access"),hasAi:Z,hasAnalytics:oe,hasAuth:O.has("@lunora/auth"),hasBrowser:ne,hasFramework:O.has("@lunora/astro")||O.has("@lunora/svelte")||O.has("@lunora/vue"),hasGlobal:a.tables.some(m=>m.shardMode==="global"&&m.globalBackend!=="hyperdrive"),hasHyperdrive:se,hasHyperdriveGlobal:a.tables.some(m=>m.shardMode==="global"&&m.globalBackend==="hyperdrive"),hasImages:ie,hasKv:M.kv,hasNotify:te,hasPayments:Y,hasR2sql:ae,hasQueue:D.some(m=>m.mode==="push"),hasScheduler:M.scheduler,hasStorage:M.storage,hasVectors:a.vectorIndexes.length>0,hasWorkflow:v.length>0,hasX402:ce,identity:R,jurisdiction:a.jurisdiction,useUmbrella:F,voiceAgents:b.filter(m=>m.voice===!0&&m.voiceBindingName!==void 0).map(m=>({bindingName:m.voiceBindingName,exportName:m.exportName})),wantsOpenApi:ue,wantsOpenRpc:le}),Ve=nc(e.projectRoot),Ue=Bs({functions:c,httpRoutes:l,version:Ve}),We=Us({functions:c,version:Ve}),Ge=`${JSON.stringify(Ue,void 0,2)}
2
+ `,_e=`${JSON.stringify(We,void 0,2)}
3
+ `,He=Vs(Ue),Je=Ws(We),Qe=Gs(a,p.map(m=>m.id)),de=g(r,rc),Mt=E(de),x=g(r,"_generated");if(e.dryRun||(E(x)||Bt(x,{recursive:!0}),$(g(x,"app.ts"),Be),$(g(x,"dataModel.ts"),Oe),$(g(x,"api.ts"),Le),$(g(x,"server.ts"),Fe),$(g(x,"functions.ts"),Te),$(g(x,"shard.ts"),De),$(g(x,"crons.ts"),je),$(g(x,"vectors.ts"),ze),$(g(x,"drizzle.global.ts"),j.global),$(g(x,"drizzle.shard.ts"),j.shard),P(g(x,"containers.ts"),ke),P(g(x,"workflows.ts"),Ke),P(g(x,"agents.ts"),Re),P(g(x,"queues.ts"),Me),P(g(x,"seed.ts"),qe),P(g(x,"collections.ts"),Ce),P(g(x,"openapi.json"),ue?Ge:""),P(g(x,"openapi.ts"),ue?He:""),P(g(x,"openrpc.json"),le?_e:""),P(g(x,"openrpc.ts"),le?Je:""),(!Mt||e.updateSchemaBaseline===!0)&&$(de,_s(Qe))),t){const m=fe.now(),jt=Math.round(m-s),zt=Math.round(Ie-s),qt=Math.round(m-Ie);console.error(`@lunora/codegen: codegen took ${jt.toString()}ms (discovery ${zt.toString()}ms, emit ${qt.toString()}ms)`)}return{advisories:ve,agents:b,containers:C,cronTriggers:ps(Q),generated:{agents:Re,api:Le,app:Be,collections:Ce,containers:ke,crons:je,dataModel:Oe,drizzleGlobal:j.global,drizzleShard:j.shard,functions:Te,openApi:Ge,openApiModule:He,openRpc:_e,openRpcModule:Je,queues:Me,seed:qe,server:Fe,shard:De,vectors:ze,workflows:Ke},outputDirectory:x,queues:D,schemaSnapshot:Qe,schemaSnapshotPath:de,workflows:v}};export{rc as SCHEMA_SNAPSHOT_FILENAME,cc as createCodegenProject,Gc as refreshCodegenProject,_c as runCodegen};
@@ -1,3 +1,3 @@
1
- import{w as $}from"./emit-Bp0nOR_O.mjs";import{n as p}from"./paths-BmX5O1sG.mjs";import{LUNORA_ERROR_CODES as y,objectSchema as g,argsObjectSchema as h,validatorIrToJsonSchema as u}from"./LUNORA_ERROR_CODES-Um9hC1gr.mjs";const S="/_lunora/rest",O=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)}},b=e=>{const t=O(e);if(t!==void 0)return`${S}/${t.namespace}/${t.name}`},P=e=>e==="query"?"GET":"POST",l="#/components/responses/LunoraError",f=/:([A-Za-z_$][\w$]*)/gu,T=e=>[...e.matchAll(f)].map(t=>t[1]),k=e=>e.replaceAll(f,"{$1}"),v=e=>{const t=new Set(T(e.path)),n=[];for(const[o,s]of Object.entries(e.searchParams)){const c=s.kind==="optional"?s.inner??s:s;n.push({description:`Query parameter \`${o}\``,in:"query",name:o,required:s.kind!=="optional",schema:u(c)})}for(const[o,s]of Object.entries(e.params)){const c=s.kind==="optional"?s.inner??s:s;n.push({description:`Path parameter \`${o}\``,in:t.has(o)?"path":"query",name:o,required:t.has(o)?!0:s.kind!=="optional",schema:u(c)})}return n},j=e=>e?{content:{"application/json":{schema:u(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."},N=e=>{const t=p(e.filePath),n=v(e),o={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${p(e.path)}`,responses:{200:j(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:l}},summary:`${e.method} ${e.path}`,tags:[t]};return n.length>0&&(o.parameters=n),Object.keys(e.body).length>0&&(o.requestBody={content:{"application/json":{schema:g(e.body)}},required:!0}),e.stream&&(o["x-lunora-stream"]="text/event-stream"),o},q=e=>{const t=`${p(e.filePath)}:${e.exportName}`,n=p(e.filePath),o={additionalProperties:!1,properties:{args:h(e.args),functionPath:{const:t,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}\` \`${t}\` over the Lunora RPC envelope (POST /_lunora/rpc).`,operationId:t,requestBody:{content:{"application/json":{schema:o}},required:!0},responses:{200:{content:{"application/json":{schema:{description:"RPC result. The shape is TS-inferred from the function's return type; best-effort — any JSON."}}},description:"Successful RPC result (TypeScript-inferred return shape, documented best-effort)."},default:{$ref:l}},summary:`${e.kind}: ${t}`,tags:[n],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${t}`}},R=e=>{const t=`${p(e.filePath)}:${e.exportName}`,n=b(t);if(n===void 0)return;const o=p(e.filePath),s=P(e.kind),c=s==="GET",r={description:`Public REST endpoint for the \`${e.kind}\` \`${t}\` (opt-in via \`.expose({ rest: true })\`). Routed through the procedure, so auth / RLS / validators are enforced.`,operationId:`rest_${p(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)."},default:{$ref:l}},summary:`${s} ${n}`,tags:[o],"x-lunora-function-kind":e.kind};if(c){const a=Object.entries(e.args).map(([i,d])=>{const m=d.kind==="optional"?d.inner??d:d;return{description:`Argument \`${i}\` (JSON-encoded for non-string values).`,in:"query",name:i,required:d.kind!=="optional",schema:u(m)}});return a.length>0&&(r.parameters=a),{method:"get",operation:r,path:n}}return r.requestBody={content:{"application/json":{schema:h(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:r,path:n}},A=e=>{const t=e.version??"0.0.0",n={},o=new Set;for(const r of e.httpRoutes){const a=k(r.path),i=n[a]??{};i[r.method.toLowerCase()]=N(r),n[a]=i,o.add(p(r.filePath))}const s=e.functions.filter(r=>r.visibility!=="internal"&&r.kind!=="stream");for(const r of s){const{operation:a,pathKey:i}=q(r);n[i]={post:a},o.add(p(r.filePath))}for(const r of s){if(r.expose?.rest!==!0)continue;const a=R(r);if(a===void 0)continue;const i=n[a.path]??{};i[a.method]=a.operation,n[a.path]=i,o.add(p(r.filePath))}const c=[...o].toSorted((r,a)=>r.localeCompare(a)).map(r=>({description:`Operations declared in \`lunora/${r}\`.`,name:r}));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:y,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:n,tags:c}},_=e=>`${JSON.stringify(A(e),void 0,2)}
1
+ import{w as $}from"./emit-D7VIjvlm.mjs";import{n as p}from"./paths-BmX5O1sG.mjs";import{LUNORA_ERROR_CODES as y,objectSchema as g,argsObjectSchema as h,validatorIrToJsonSchema as u}from"./LUNORA_ERROR_CODES-Um9hC1gr.mjs";const S="/_lunora/rest",O=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)}},b=e=>{const t=O(e);if(t!==void 0)return`${S}/${t.namespace}/${t.name}`},P=e=>e==="query"?"GET":"POST",l="#/components/responses/LunoraError",f=/:([A-Za-z_$][\w$]*)/gu,T=e=>[...e.matchAll(f)].map(t=>t[1]),k=e=>e.replaceAll(f,"{$1}"),v=e=>{const t=new Set(T(e.path)),n=[];for(const[o,s]of Object.entries(e.searchParams)){const c=s.kind==="optional"?s.inner??s:s;n.push({description:`Query parameter \`${o}\``,in:"query",name:o,required:s.kind!=="optional",schema:u(c)})}for(const[o,s]of Object.entries(e.params)){const c=s.kind==="optional"?s.inner??s:s;n.push({description:`Path parameter \`${o}\``,in:t.has(o)?"path":"query",name:o,required:t.has(o)?!0:s.kind!=="optional",schema:u(c)})}return n},j=e=>e?{content:{"application/json":{schema:u(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."},N=e=>{const t=p(e.filePath),n=v(e),o={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${p(e.path)}`,responses:{200:j(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:l}},summary:`${e.method} ${e.path}`,tags:[t]};return n.length>0&&(o.parameters=n),Object.keys(e.body).length>0&&(o.requestBody={content:{"application/json":{schema:g(e.body)}},required:!0}),e.stream&&(o["x-lunora-stream"]="text/event-stream"),o},q=e=>{const t=`${p(e.filePath)}:${e.exportName}`,n=p(e.filePath),o={additionalProperties:!1,properties:{args:h(e.args),functionPath:{const:t,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}\` \`${t}\` over the Lunora RPC envelope (POST /_lunora/rpc).`,operationId:t,requestBody:{content:{"application/json":{schema:o}},required:!0},responses:{200:{content:{"application/json":{schema:{description:"RPC result. The shape is TS-inferred from the function's return type; best-effort — any JSON."}}},description:"Successful RPC result (TypeScript-inferred return shape, documented best-effort)."},default:{$ref:l}},summary:`${e.kind}: ${t}`,tags:[n],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${t}`}},R=e=>{const t=`${p(e.filePath)}:${e.exportName}`,n=b(t);if(n===void 0)return;const o=p(e.filePath),s=P(e.kind),c=s==="GET",r={description:`Public REST endpoint for the \`${e.kind}\` \`${t}\` (opt-in via \`.expose({ rest: true })\`). Routed through the procedure, so auth / RLS / validators are enforced.`,operationId:`rest_${p(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)."},default:{$ref:l}},summary:`${s} ${n}`,tags:[o],"x-lunora-function-kind":e.kind};if(c){const a=Object.entries(e.args).map(([i,d])=>{const m=d.kind==="optional"?d.inner??d:d;return{description:`Argument \`${i}\` (JSON-encoded for non-string values).`,in:"query",name:i,required:d.kind!=="optional",schema:u(m)}});return a.length>0&&(r.parameters=a),{method:"get",operation:r,path:n}}return r.requestBody={content:{"application/json":{schema:h(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:r,path:n}},A=e=>{const t=e.version??"0.0.0",n={},o=new Set;for(const r of e.httpRoutes){const a=k(r.path),i=n[a]??{};i[r.method.toLowerCase()]=N(r),n[a]=i,o.add(p(r.filePath))}const s=e.functions.filter(r=>r.visibility!=="internal"&&r.kind!=="stream");for(const r of s){const{operation:a,pathKey:i}=q(r);n[i]={post:a},o.add(p(r.filePath))}for(const r of s){if(r.expose?.rest!==!0)continue;const a=R(r);if(a===void 0)continue;const i=n[a.path]??{};i[a.method]=a.operation,n[a.path]=i,o.add(p(r.filePath))}const c=[...o].toSorted((r,a)=>r.localeCompare(a)).map(r=>({description:`Operations declared in \`lunora/${r}\`.`,name:r}));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:y,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:n,tags:c}},_=e=>`${JSON.stringify(A(e),void 0,2)}
2
2
  `,I=e=>`${$}export const openApiSpec: Record<string, unknown> = ${JSON.stringify(e,void 0,4)};
3
3
  `;export{A as buildOpenApiDocument,_ as emitOpenApi,I as emitOpenApiModule};
@@ -0,0 +1 @@
1
+ import{LunoraError as j}from"@lunora/errors";import{Node as s,SyntaxKind as w}from"ts-morph";import{diagnosticAt as f}from"./CodegenDiagnosticError-DPezpZTz.mjs";import{d as T}from"./parse-validator-CSDlMEvE.mjs";import{createRequire as N}from"node:module";import{join as O}from"node:path";const _=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}},$=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 r=e?._meta??{},t=e?.kind??"unknown",n={column:$(r.column),kind:t};switch(t){case"array":case"optional":{n.inner=g(r.inner);break}case"id":{n.tableName=r.tableName;break}case"literal":{n.literalValue=_(r.value);break}case"object":{const i=r.shape??{};n.shape=Object.fromEntries(Object.entries(i).map(([o,a])=>[o,g(a)]));break}case"record":{n.valueType=g(r.valueValidator),r.keyValidator!==void 0&&(n.keyType=g(r.keyValidator));break}case"storage":{typeof r.bucket=="string"&&(n.bucket=r.bucket);break}case"union":{const i=r.members??[];n.members=i.map(o=>g(o));break}}return n},M=e=>e?.kind==="global"?"global":e?.kind==="shardBy"&&typeof e.field=="string"?{field:e.field,kind:"shardBy"}:"root",z=(e,r)=>{const t=[];e.relationMap&&Object.keys(e.relationMap).length>0&&t.push("relations"),e.rankIndexes&&e.rankIndexes.length>0&&t.push("rank indexes"),e.vectorIndexes&&e.vectorIndexes.length>0&&t.push("vector indexes"),t.length>0&&console.warn(`@lunora/codegen: package schema-extension table "${r}" declares ${t.join(" + ")}, which are not yet introspected from a node_modules extension — they will be absent from the generated types.`)},D=(e,r)=>{const t=e.shape??{},n=(e.indexes??[]).map(i=>({fields:i.fields,name:i.name,...i.unique?{unique:!0}:{}}));return z(e,r),{...e.isExternallyManaged?{externallyManaged:!0}:{},geoIndexes:[],indexes:n,name:r,rankIndexes:[],relations:[],searchIndexes:(e.searchIndexes??[]).map(i=>({field:i.field,...i.filterFields?{filterFields:i.filterFields}:{},...i.language===void 0?{}:{language:i.language},...i.staged===void 0?{}:{staged:i.staged},...i.strategy===void 0?{}:{strategy:i.strategy},name:i.name})),shape:Object.fromEntries(Object.entries(t).map(([i,o])=>[i,g(o)])),shardMode:M(e.shardMode),vectorIndexes:[]}},B=e=>{const{key:r,tables:t}=e;if(typeof r!="string"||typeof t!="object"||t===null)return;const n=Object.entries(t).map(([a,l])=>D(l,a)),i=e.vectorIndexes??{},o=Object.entries(i??{}).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:n,bareVectorIndexes:o,key:r}},q=e=>{if(s.isIdentifier(e))return e.getText();if(s.isPropertyAccessExpression(e)){const r=e.getExpression();return s.isIdentifier(r)?r.getText():void 0}},F=e=>{const r=q(e);if(r===void 0)return;const t=s.isPropertyAccessExpression(e)?e.getName():void 0,n=t===void 0?[]:[t];for(const i of e.getSourceFile().getImportDeclarations()){const o=i.getModuleSpecifierValue();for(const a of i.getNamedImports())if((a.getAliasNode()?.getText()??a.getName())===r)return{importedName:a.getName(),moduleSpecifier:o,propertyPath:n};if(i.getDefaultImport()?.getText()===r)return{importedName:"default",moduleSpecifier:o,propertyPath:n};if(i.getNamespaceImport()?.getText()===r&&t!==void 0)return{importedName:t,moduleSpecifier:o,propertyPath:[]}}},C=(e,r)=>{let t=e[r.importedName];for(const n of r.propertyPath){if(typeof t!="object"||t===null)return;t=t[n]}return t},V=(e,r)=>{const t=F(e);if(t)try{const n=N(O(r,"noop.cjs")),i=n.resolve(t.moduleSpecifier),o=n(i),a=C(o,t);return typeof a!="object"||a===null?void 0:B(a)}catch{return}},R=new Set(["cosine","dot-product","euclidean"]),J=new Set(["cascade","restrict","set null"]),E=new Set(["delete","get","insert","normalizeId","patch","query","replace","system"]),K=(e,r)=>{if(E.has(e))throw f(r,`table name "${e}" is reserved — it collides with a \`ctx.db\` member (one of ${[...E].map(t=>`"${t}"`).join(", ")}). Rename the table.`)},c=(e,r)=>{const t=e.getProperty(r);if(t&&s.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&s.isStringLiteral(n))return n.getLiteralText()}},m=(e,r)=>{const t=e.getProperty(r);if(t&&s.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&s.isNumericLiteral(n))return Number(n.getLiteralText())}},U=(e,r)=>{const t=e.getProperty(r);if(t&&s.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&(s.isTrueLiteral(n)||s.isFalseLiteral(n)))return n.getLiteralValue()}},h=(e,r)=>{const t=e.getProperty(r);if(t&&s.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&s.isArrayLiteralExpression(n))return n.getElements().filter(i=>s.isStringLiteral(i)).map(i=>i.getLiteralText())}},v=e=>e&&R.has(e)?e:void 0,G=e=>e&&J.has(e)?e:void 0,H=e=>{if(!s.isArrowFunction(e))return;let r=e.getBody();if(s.isParenthesizedExpression(r))r=r.getExpression();else if(s.isBlock(r)){const t=r.getStatements().find(n=>s.isReturnStatement(n));r=t&&s.isReturnStatement(t)?t.getExpression()??r:r}return s.isObjectLiteralExpression(r)?r:void 0},Q=e=>{if(!s.isPropertyAssignment(e))return;const r=e.getInitializer();if(!r||!s.isCallExpression(r))return;const t=r.getExpression();if(!s.isPropertyAccessExpression(t))return;const n=t.getName();if(n!=="one"&&n!=="many")return;const[i,o]=r.getArguments(),a=i&&s.isStringLiteral(i)?i.getLiteralText():"_unknown_";let l="_unknown_",d="_id",u;return o&&s.isObjectLiteralExpression(o)&&(l=c(o,"field")??l,d=c(o,"references")??d,u=n==="one"?G(c(o,"onDelete")):void 0),{field:l,kind:n,name:e.getName(),onDelete:u,references:d,table:a}},W=e=>{const r=H(e);if(!r)return[];const t=[];for(const n of r.getProperties()){const i=Q(n);i&&t.push(i)}return t},x=e=>e&&s.isStringLiteral(e)?e.getLiteralText():"_unnamed_",X=e=>{const[r,t,n]=e;let i=!1;if(n&&s.isObjectLiteralExpression(n)){const o=n.getProperty("unique");if(o&&s.isPropertyAssignment(o)){const a=o.getInitializer();if(a&&!s.isTrueLiteral(a)&&!s.isFalseLiteral(a))throw f(a,`\`unique\` must be a literal \`true\` or \`false\`, got ${JSON.stringify(a.getText())}`);i=a?s.isTrueLiteral(a):!1}}return{fields:t&&s.isArrayLiteralExpression(t)?t.getElements().filter(o=>s.isStringLiteral(o)).map(o=>o.getLiteralText()):[],name:x(r),unique:i}},Y=e=>{const[r,t]=e;let n="_unknown_",i,o,a,l;return t&&s.isObjectLiteralExpression(t)&&(n=c(t,"field")??n,i=h(t,"filterFields"),o=c(t,"language"),a=U(t,"staged"),l=c(t,"strategy")),{field:n,filterFields:i,language:o,name:x(r),staged:a,strategy:l}},Z=e=>{const[r,t]=e;let n="_unknown_",i;return t&&s.isObjectLiteralExpression(t)&&(n=c(t,"field")??n,i=m(t,"precision")),{field:n,name:x(r),precision:i}},ee=e=>{const[r,t]=e,n=r&&s.isStringLiteral(r)?r.getLiteralText():"_unknown_";let i;return t&&s.isObjectLiteralExpression(t)&&(i=m(t,"after")),{after:i,field:n}},te=e=>{if(!s.isObjectLiteralExpression(e))return;const r=c(e,"field");return r===void 0?void 0:{direction:c(e,"direction")==="desc"?"desc":"asc",field:r}},re=e=>{const[r,t]=e;let n=[],i;if(t&&s.isObjectLiteralExpression(t)){const o=t.getProperty("sortBy");if(o&&s.isPropertyAssignment(o)){const a=o.getInitializer();a&&s.isArrayLiteralExpression(a)&&(n=a.getElements().map(l=>te(l)).filter(l=>l!==void 0))}i=h(t,"partitionBy")}return{name:x(r),partitionBy:i,sortBy:n}},ne=(e,r)=>{const[t,n]=e,i=t&&s.isStringLiteral(t)?t.getLiteralText():"_unknown_";if(!(!n||!s.isObjectLiteralExpression(n)))return{dimensions:m(n,"dimensions"),field:i,metadata:h(n,"metadata"),metric:v(c(n,"metric")),name:c(n,"index")??"_unnamed_",table:r}},ie=e=>{const r=e[0];return r&&s.isObjectLiteralExpression(r)&&c(r,"backend")==="hyperdrive"?"hyperdrive":"d1"},se=e=>{if(e&&s.isObjectLiteralExpression(e)){const r=e.getProperty("field");if(r&&s.isPropertyAssignment(r)){const t=r.getInitializer();if(t&&s.isStringLiteral(t))return t.getLiteralText()}}return"deletedAt"},p=(e,r)=>{const t=e.getProperty(r);if(t&&s.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&s.isStringLiteral(n))return n.getLiteralText()}},oe=(e,r)=>{const t=e.getProperty(r);if(t&&s.isPropertyAssignment(t)){const n=t.getInitializer();if(n&&s.isArrayLiteralExpression(n)){const i=n.getElements().filter(o=>s.isStringLiteral(o)).map(o=>o.getLiteralText());return i.length>0?i:void 0}}},ae=e=>{const r=e[0];return!r||!s.isObjectLiteralExpression(r)?{binding:"",hasTenantBy:!1,unanalyzable:!0}:{binding:p(r,"binding")??"",columns:oe(r,"columns"),hasReconcile:r.getProperty("reconcileEveryMs")!==void 0,hasSoftDelete:r.getProperty("softDeleteColumn")!==void 0,hasTenantBy:r.getProperty("tenantBy")!==void 0,idColumn:p(r,"idColumn"),mode:p(r,"mode"),query:p(r,"query")}},le=(e,r,t,n)=>{switch(r){case"externallyManaged":{e.externallyManaged=!0;break}case"geoIndex":{e.geoIndexes.push(Z(t));break}case"global":{e.shardMode="global",e.globalBackend=ie(t);break}case"index":{e.indexes.push(X(t));break}case"public":{e.isPublic=!0;break}case"rankIndex":{e.rankIndexes.push(re(t));break}case"relations":{const i=t[0];i&&e.relations.push(...W(i));break}case"searchIndex":{e.searchIndexes.push(Y(t));break}case"shardBy":{const i=t[0];e.shardMode={field:i&&s.isStringLiteral(i)?i.getLiteralText():"_unknown_",kind:"shardBy"};break}case"softDelete":{e.softDelete={field:se(t[0])};break}case"source":{e.externalSource=ae(t),e.externallyManaged=!0;break}case"ttl":{e.ttl=ee(t);break}case"vectorize":{const i=ne(t,n);i&&e.vectorIndexes.push(i);break}}},L=(e,r)=>{const t={externallyManaged:!1,geoIndexes:[],indexes:[],isPublic:!1,rankIndexes:[],relations:[],searchIndexes:[],shardMode:"root",vectorIndexes:[]};let n={},i=e;for(;s.isCallExpression(i);){const o=i.getExpression(),a=i.getArguments();if(s.isPropertyAccessExpression(o))le(t,o.getName(),a,r),i=o.getExpression();else if(s.isIdentifier(o)&&o.getText()==="defineTable"){const l=a[0];l&&s.isObjectLiteralExpression(l)&&(n=T(l));break}else break}return t.softDelete&&!(t.softDelete.field in n)&&(n={...n,[t.softDelete.field]:{inner:{kind:"number"},kind:"optional"}}),{externallyManaged:t.externallyManaged,externalSource:t.externalSource,geoIndexes:t.geoIndexes,globalBackend:t.shardMode==="global"?t.globalBackend??"d1":void 0,indexes:t.indexes,isPublic:t.isPublic,name:r,rankIndexes:t.rankIndexes,relations:t.relations,searchIndexes:t.searchIndexes,shape:n,shardMode:t.shardMode,softDelete:t.softDelete,ttl:t.ttl,vectorIndexes:t.vectorIndexes}},ce=e=>{const r=e.getProperty("source");if(r&&s.isPropertyAssignment(r)){const t=r.getInitializer();if(t&&s.isObjectLiteralExpression(t))return c(t,"table")??"_unknown_"}return"_unknown_"},de=e=>{if(!s.isPropertyAssignment(e))return;const r=e.getInitializer();if(!r||!s.isCallExpression(r))return;const t=r.getExpression();if(!s.isIdentifier(t)||t.getText()!=="defineVectorIndex")return;const n=r.getArguments()[0];if(!n||!s.isObjectLiteralExpression(n))return;const i=e.getNameNode(),o=s.isStringLiteral(i)?i.getLiteralText():i.getText();return{dimensions:m(n,"dimensions"),metric:v(c(n,"metric")),name:o,table:ce(n)}},P=e=>{const r=[];for(const t of e.getProperties()){const n=de(t);n&&r.push(n)}return r},k=(e,r)=>`${e}_${r}`,y=(e,r,t)=>t.has(e)?k(r,e):e,ue=(e,r,t)=>{const n=k(r,e.name);return{...e,extensionKey:r,name:n,relations:e.relations.map(i=>({...i,table:y(i.table,r,t)})),vectorIndexes:e.vectorIndexes.map(i=>({...i,table:y(i.table,r,t)}))}},ge=e=>{if(s.isVariableDeclaration(e)||s.isPropertyAssignment(e))return e.getInitializer();if(s.isShorthandPropertyAssignment(e))return e.getNameNode()},fe=(e,r)=>{const t=e.getProperty(r);if(t&&s.isPropertyAssignment(t))return t.getInitializer()},pe=e=>{if(!s.isCallExpression(e))return!1;const r=e.getExpression();return s.isIdentifier(r)&&r.getText()==="defineSchemaExtension"},me=e=>{if(s.isIdentifier(e))return e;if(s.isPropertyAccessExpression(e)){const r=e.getExpression();return s.isIdentifier(r)?r:void 0}},xe=e=>{if(s.isObjectLiteralExpression(e))return e;if(s.isCallExpression(e)){const r=e.getExpression();let t;if(s.isIdentifier(r)?t=r.getText():s.isPropertyAccessExpression(r)&&(t=r.getName()),t==="definePlugin"){const n=e.getArguments()[1];return n&&s.isObjectLiteralExpression(n)?n:void 0}}},be=(e,r)=>{const t=ge(e);if(t){if(s.isPropertyAccessExpression(r)){const n=xe(t);return n?fe(n,r.getName()):void 0}return t}},ye=e=>{let r=e,t=0;for(;r&&t<32;){if(t+=1,pe(r))return r;const n=me(r),i=n&&s.isIdentifier(n)?n.getSymbol():void 0,o=(i?.getAliasedSymbol()?.getDeclarations()??i?.getDeclarations()??[])[0];if(!o)return;const a=o.getSourceFile();if(a.isInNodeModules()||a.isDeclarationFile())return;r=be(o,r)}},he=e=>{const[r,t]=e.getArguments();if(!(!r||!s.isStringLiteral(r))&&!(!t||!s.isObjectLiteralExpression(t)))return{key:r.getLiteralText(),options:t}},ke=e=>{const r=e.getProperty("tables");if(!r||!s.isPropertyAssignment(r))return[];const t=r.getInitializer();if(!t||!s.isObjectLiteralExpression(t))return[];const n=[];for(const i of t.getProperties()){if(!s.isPropertyAssignment(i))continue;const o=i.getInitializer();o&&n.push(L(o,i.getName()))}return n},Ie=e=>{const r=e.getProperty("vectorIndexes");if(!r||!s.isPropertyAssignment(r))return[];const t=r.getInitializer();return!t||!s.isObjectLiteralExpression(t)?[]:P(t)},S=(e,r,t)=>{const n=new Set(r.map(a=>a.name)),i=r.map(a=>ue(a,e,n)),o=t.map(a=>({...a,name:k(e,a.name),table:y(a.table,e,n)}));return{tables:i,vectorIndexes:o}},Ee=(e,r)=>S(e,ke(r),Ie(r)),ve=(e,r)=>{const t=e.getArguments()[0];if(!t)return;const n=ye(t);if(!n){if(r!==void 0){const o=V(t,r);if(o)return S(o.key,o.bareTables,o.bareVectorIndexes)}console.warn(`@lunora/codegen: skipping \`.extend(${t.getText()})\` — its \`defineSchemaExtension(...)\` could not be resolved from local sources, and ${r===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 i=he(n);if(!i){console.warn("@lunora/codegen: skipping `.extend(...)` — `defineSchemaExtension` requires a string `key` and an options object literal.");return}return Ee(i.key,i.options)},Le=e=>{const r=[];let t=e;for(;;){const n=t.getParent();if(!n||!s.isPropertyAccessExpression(n))break;const i=n.getParent();if(!i||!s.isCallExpression(i))break;n.getName()==="extend"&&r.push(i),t=i}return r},A=(e,r,t,n,i)=>{let o=e;for(;;){const a=o.getParent();if(!a||!s.isPropertyAccessExpression(a))break;const l=a.getParent();if(!l||!s.isCallExpression(l))break;if(a.getName()===r){const d=l.getArguments()[0];if(!d||!s.isStringLiteral(d))throw f(l,`\`.${r}(...)\` expects a string literal (${i})`);const u=d.getLiteralText();if(!n.has(u))throw f(d,`unknown ${t} ${JSON.stringify(u)} — expected ${i}`);return u}o=l}},Pe=new Set(["eu","fedramp","us"]),Se=e=>A(e,"jurisdiction","jurisdiction",Pe,'"eu", "us", or "fedramp"'),Ae=new Set(["required"]),je=e=>A(e,"rls","rls mode",Ae,'"required"'),we=e=>{const r=[];for(const t of e.getProperties()){if(!s.isPropertyAssignment(t))continue;const n=t.getInitializer();if(n){const i=t.getName();K(i,t.getNameNode()),r.push(L(n,i))}}return r},Te=(e,r,t)=>{const n=new Set(r.map(o=>o.name)),i=[];for(const o of Le(e)){const a=ve(o,t);if(a){for(const l of a.tables){if(n.has(l.name))throw f(o,`defineSchema(...).extend(...): table "${l.name}" already exists — another extension with the same key already contributed it.`);n.add(l.name),r.push(l)}i.push(...a.vectorIndexes)}}return i},De=(e,r,t)=>{const n=e.addSourceFileAtPath(r).getDescendantsOfKind(w.CallExpression).find(b=>{const I=b.getExpression();return s.isIdentifier(I)&&I.getText()==="defineSchema"});if(!n)throw new j("INTERNAL",`defineSchema() not found in ${r}`);const i=n.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))throw f(n,"defineSchema() expects an object literal");const o=we(i),a=n.getArguments()[1],l=a&&s.isObjectLiteralExpression(a)?P(a):[],d=Te(n,o,t),u=[...o.flatMap(b=>b.vectorIndexes),...l,...d];return{jurisdiction:Se(n),rlsMode:je(n),tables:o,vectorIndexes:u}};export{De as default};