@lunora/codegen 1.0.0-alpha.261 → 1.0.0-alpha.262

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/packem_shared/{AGENTS_FILENAME-UhIaG4BZ.mjs → AGENTS_FILENAME-C-halsN9.mjs} +1 -1
  3. package/dist/packem_shared/{CONTAINERS_FILENAME-DhUL5rDc.mjs → CONTAINERS_FILENAME-DY4sWZYx.mjs} +1 -1
  4. package/dist/packem_shared/{MUTATORS_FILENAME-D1Q6EUII.mjs → MUTATORS_FILENAME-CuG6xLJ1.mjs} +1 -1
  5. package/dist/packem_shared/{NOTIFY_FILENAME-bbHHFQ_t.mjs → NOTIFY_FILENAME-C70ZrThq.mjs} +1 -1
  6. package/dist/packem_shared/{QUEUES_FILENAME-CSLmXUQA.mjs → QUEUES_FILENAME-16xcVWpo.mjs} +1 -1
  7. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BMzr0ydt.mjs +11 -0
  8. package/dist/packem_shared/{SHAPES_FILENAME-DuR5hLW1.mjs → SHAPES_FILENAME-e82UBLBE.mjs} +1 -1
  9. package/dist/packem_shared/{WORKFLOWS_FILENAME-IqUyMQgM.mjs → WORKFLOWS_FILENAME-Bcfd76Wf.mjs} +1 -1
  10. package/dist/packem_shared/attribution-JcwxPpyK.mjs +1 -0
  11. package/dist/packem_shared/{context-property-calls-BEBjylgc.mjs → context-property-calls-BqKN1GyT.mjs} +1 -1
  12. package/dist/packem_shared/{context-root-KWXRWlv6.mjs → context-root-Dlht00NP.mjs} +1 -1
  13. package/dist/packem_shared/{database-calls-rLPCL3-U.mjs → database-calls-Br5z7dZL.mjs} +1 -1
  14. package/dist/packem_shared/{discoverAuthApiCalls-CNj9-Jch.mjs → discoverAuthApiCalls-0t3X09mV.mjs} +1 -1
  15. package/dist/packem_shared/{discoverFunctions-DPH4drkg.mjs → discoverFunctions-B-hkqNPG.mjs} +1 -1
  16. package/dist/packem_shared/{discoverHttpRoutes-MRFziTCb.mjs → discoverHttpRoutes-8f8UnwQk.mjs} +1 -1
  17. package/dist/packem_shared/discoverHyperdriveCalls-BRbwJcK7.mjs +1 -0
  18. package/dist/packem_shared/{discoverInserts-Duz40u-s.mjs → discoverInserts-6RcjS-YR.mjs} +1 -1
  19. package/dist/packem_shared/{discoverMaskProcedures-DYJhbHF3.mjs → discoverMaskProcedures-B8LgCQ2X.mjs} +1 -1
  20. package/dist/packem_shared/{discoverMigrations-D2P2n7JE.mjs → discoverMigrations-De3uDJi0.mjs} +1 -1
  21. package/dist/packem_shared/{discoverNondeterministicCalls-Cxf6T2Oi.mjs → discoverNondeterministicCalls-XHRCA4rr.mjs} +1 -1
  22. package/dist/packem_shared/{discoverQueries-CWmNPVHm.mjs → discoverQueries-B0vvHwFI.mjs} +1 -1
  23. package/dist/packem_shared/discoverR2sqlCalls-BQ90jfu3.mjs +1 -0
  24. package/dist/packem_shared/{discoverRlsMetadata-BXXEFXjf.mjs → discoverRlsMetadata-BuGLdQWs.mjs} +1 -1
  25. package/dist/packem_shared/{discoverRlsProcedures-Des596JU.mjs → discoverRlsProcedures-Cy8-Q0AP.mjs} +1 -1
  26. package/dist/packem_shared/{discoverStorageRulesMetadata-DGFonj0I.mjs → discoverStorageRulesMetadata-C6sTEVS5.mjs} +1 -1
  27. package/dist/packem_shared/{exported-procedure-chains-58yS9zc8.mjs → exported-procedure-chains-CKLvyjfX.mjs} +1 -1
  28. package/dist/packem_shared/{handler-reference-C1oBljnl.mjs → handler-reference-Dzp5GZ5p.mjs} +1 -1
  29. package/dist/packem_shared/{index-BusOvbeQ.mjs → index-BxGykPbL.mjs} +1 -1
  30. package/package.json +2 -2
  31. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BVhRHIbS.mjs +0 -11
  32. package/dist/packem_shared/attribution-sW_DHmLO.mjs +0 -1
  33. package/dist/packem_shared/discoverHyperdriveCalls-BcVkR6nw.mjs +0 -1
  34. package/dist/packem_shared/discoverR2sqlCalls-DnKwop5c.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as s}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as l,errorAdvisoryNames as n,errorPlatformDiagnosticNames as c,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-DFsutD7g.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-UhIaG4BZ.mjs";import{listLunoraSourceFiles as R}from"./packem_shared/listLunoraSourceFiles-DRes9d5p.mjs";import{default as _}from"./packem_shared/discoverAuthApiCalls-CNj9-Jch.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-DhUL5rDc.mjs";import{default as F}from"./packem_shared/discoverCrons-BqTY53L5.mjs";import{capabilitiesUsedBy as D,foldCapabilitySignals as b,mayReadCapabilityContext as U,sourceCapabilitySignals as y}from"./packem_shared/capabilitiesUsedBy-CzqyN9dX.mjs";import{FLAGS_FILENAME as H,discoverFlags as j}from"./packem_shared/FLAGS_FILENAME-BINQ51Zq.mjs";import{default as k}from"./packem_shared/discoverFunctions-DPH4drkg.mjs";import{default as K}from"./packem_shared/discoverHttpRoutes-MRFziTCb.mjs";import{default as z}from"./packem_shared/discoverHyperdriveCalls-BcVkR6nw.mjs";import{default as q}from"./packem_shared/discoverInserts-Duz40u-s.mjs";import{d as J}from"./packem_shared/index-BusOvbeQ.mjs";import{default as X}from"./packem_shared/discoverMigrations-D2P2n7JE.mjs";import{MUTATORS_FILENAME as $,discoverMutators as ee}from"./packem_shared/MUTATORS_FILENAME-D1Q6EUII.mjs";import{default as oe}from"./packem_shared/discoverNondeterministicCalls-Cxf6T2Oi.mjs";import{NOTIFY_FILENAME as ae,discoverNotifyCalls as se,discoverNotifyConfig as ie}from"./packem_shared/NOTIFY_FILENAME-bbHHFQ_t.mjs";import{default as fe}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{default as pe}from"./packem_shared/discoverQueries-CWmNPVHm.mjs";import{QUEUES_FILENAME as ne,discoverQueues as ce}from"./packem_shared/QUEUES_FILENAME-CSLmXUQA.mjs";import{default as Se}from"./packem_shared/discoverR2sqlCalls-DnKwop5c.mjs";import{default as ue}from"./packem_shared/discoverRlsProcedures-Des596JU.mjs";import{default as ve}from"./packem_shared/discoverRlsMetadata-BXXEFXjf.mjs";import{discoverSandboxUsage as Ce}from"./packem_shared/discoverSandboxUsage-Bjl8A_hj.mjs";import{default as Oe}from"./packem_shared/discoverSchema-Cd3iH6q5.mjs";import{readServiceBindings as Te,resolveServiceBindings as _e}from"./packem_shared/readServiceBindings-CnvEGOir.mjs";import{SHAPES_FILENAME as Le,discoverShapes as Me}from"./packem_shared/SHAPES_FILENAME-DuR5hLW1.mjs";import{default as Fe}from"./packem_shared/discoverStorageRulesMetadata-DGFonj0I.mjs";import{WORKFLOWS_FILENAME as De,discoverWorkflows as be}from"./packem_shared/WORKFLOWS_FILENAME-IqUyMQgM.mjs";import{emitApp as ye}from"./packem_shared/emitApp-RNU41dtm.mjs";import{isD1GlobalTable as He,isHyperdriveGlobalTable as je}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as ke,emitOpenApi as We,emitOpenApiModule as Ke}from"./packem_shared/buildOpenApiDocument-DOsv1HEF.mjs";import{OPENRPC_VERSION as ze,buildOpenRpcDocument as Qe,emitOpenRpc as qe,emitOpenRpcModule as we}from"./packem_shared/OPENRPC_VERSION-CGu1_YK7.mjs";import{DEFAULT_TARGET as Ye,platformMatrixIds as Xe,readProjectTarget as Ze,resolveCodegenTarget as $e}from"./packem_shared/DEFAULT_TARGET-7sHexLjO.mjs";import{loadProjectConfig as rr,readProjectConfigLiterals as or}from"./packem_shared/loadProjectConfig-CuGQsqYS.mjs";import{SCHEMA_SNAPSHOT_FILENAME as ar,createCodegenProject as sr,findTsconfig as ir,refreshCodegenProject as mr,runCodegen as fr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-BVhRHIbS.mjs";import{SchemaSnapshotParseError as pr,buildSchemaSnapshot as lr,evaluateSchemaDrift as nr,parseSchemaSnapshot as cr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as Sr}from"./packem_shared/fingerprintSchemaSources-BzFVnBfa.mjs";import{schemaFromIr as ur}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as vr,validatorIrToJsonSchema as gr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Nr,SDK_TARGETS as Or,generateSdk as Rr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as _r,secretKindOf as Ir}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Mr}from"./packem_shared/emitDrizzleSchema-DohtnI8c.mjs";import{default as Fr}from"./packem_shared/emitFunctions-evl8Mx1a.mjs";import{default as Dr}from"./packem_shared/emitServer-DymRagL2.mjs";import{e as Ur}from"./packem_shared/shard-WXSIZRpD.mjs";import{G as Gr}from"./packem_shared/shared-BXUKWh7t.mjs";import{MESSAGE_SOLUTIONS as jr,findSolutionByMessage as Br}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Wr,findProjectConfigFile as Kr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{s as zr,t as Qr,u as qr}from"./packem_shared/shard-runtime-B1nU9CRa.mjs";import{emitApi as Jr,emitCollections as Yr}from"./packem_shared/emitApi-xDIHPRPH.mjs";import{emitCrons as Zr,emitScheduler as $r,emitVectors as eo,emitWranglerCronTriggers as ro}from"./packem_shared/emitCrons-DsXsg1uG.mjs";import{emitDataModel as to}from"./packem_shared/emitDataModel-DSk9AkJe.mjs";import{isTypedSchema as so}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,Ye as DEFAULT_TARGET,H as FLAGS_FILENAME,Gr as GENERATED_HEADER,vr as LUNORA_ERROR_CODES,jr as LUNORA_SOLUTION_RULES,$ as MUTATORS_FILENAME,ae as NOTIFY_FILENAME,ze as OPENRPC_VERSION,Wr as PROJECT_CONFIG_FILENAMES,ne as QUEUES_FILENAME,ar as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Nr as SDK_LANGUAGES,Or as SDK_TARGETS,Le as SHAPES_FILENAME,pr as SchemaSnapshotParseError,e as VERSION,De as WORKFLOWS_FILENAME,ke as buildOpenApiDocument,Qe as buildOpenRpcDocument,lr as buildSchemaSnapshot,D as capabilitiesUsedBy,sr as createCodegenProject,l as describeErrorLevelFindings,v as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,_ as discoverAuthApiCalls,M as discoverContainers,F as discoverCrons,j as discoverFlags,k as discoverFunctions,K as discoverHttpRoutes,z as discoverHyperdriveCalls,q as discoverInserts,J as discoverMaskProcedures,X as discoverMigrations,ee as discoverMutators,oe as discoverNondeterministicCalls,se as discoverNotifyCalls,ie as discoverNotifyConfig,pe as discoverQueries,ce as discoverQueues,Se as discoverR2sqlCalls,ve as discoverRlsMetadata,ue as discoverRlsProcedures,Ce as discoverSandboxUsage,Oe as discoverSchema,Me as discoverShapes,Fe as discoverStorageRulesMetadata,be as discoverWorkflows,zr as emitAgents,Jr as emitApi,ye as emitApp,Yr as emitCollections,Qr as emitContainers,Zr as emitCrons,to as emitDataModel,Mr as emitDrizzleSchema,Fr as emitFunctions,We as emitOpenApi,Ke as emitOpenApiModule,qe as emitOpenRpc,we as emitOpenRpcModule,$r as emitScheduler,Dr as emitServer,Ur as emitShard,eo as emitVectors,qr as emitWorkflows,ro as emitWranglerCronTriggers,n as errorAdvisoryNames,c as errorPlatformDiagnosticNames,nr as evaluateSchemaDrift,Br as findLunoraSolution,Kr as findProjectConfigFile,ir as findTsconfig,Sr as fingerprintSchemaSources,b as foldCapabilitySignals,m as formatAdvisories,Rr as generateSdk,He as isD1GlobalTable,je as isHyperdriveGlobalTable,so as isTypedSchema,f as lintSchema,R as listLunoraSourceFiles,rr as loadProjectConfig,U as mayReadCapabilityContext,cr as parseSchemaSnapshot,Xe as platformMatrixIds,fe as readPackageDependencies,or as readProjectConfigLiterals,Ze as readProjectTarget,Te as readServiceBindings,_r as redact,mr as refreshCodegenProject,$e as resolveCodegenTarget,_e as resolveServiceBindings,fr as runCodegen,ur as schemaFromIr,Ir as secretKindOf,s as serializeSchemaSnapshot,x as sortedUniqueNames,y as sourceCapabilitySignals,d as toAdvisorContext,gr as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as s}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as l,errorAdvisoryNames as n,errorPlatformDiagnosticNames as c,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-DFsutD7g.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-C-halsN9.mjs";import{listLunoraSourceFiles as R}from"./packem_shared/listLunoraSourceFiles-DRes9d5p.mjs";import{default as _}from"./packem_shared/discoverAuthApiCalls-0t3X09mV.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-DY4sWZYx.mjs";import{default as F}from"./packem_shared/discoverCrons-BqTY53L5.mjs";import{capabilitiesUsedBy as D,foldCapabilitySignals as b,mayReadCapabilityContext as U,sourceCapabilitySignals as y}from"./packem_shared/capabilitiesUsedBy-CzqyN9dX.mjs";import{FLAGS_FILENAME as H,discoverFlags as j}from"./packem_shared/FLAGS_FILENAME-BINQ51Zq.mjs";import{default as k}from"./packem_shared/discoverFunctions-B-hkqNPG.mjs";import{default as K}from"./packem_shared/discoverHttpRoutes-8f8UnwQk.mjs";import{default as z}from"./packem_shared/discoverHyperdriveCalls-BRbwJcK7.mjs";import{default as q}from"./packem_shared/discoverInserts-6RcjS-YR.mjs";import{d as J}from"./packem_shared/index-BxGykPbL.mjs";import{default as X}from"./packem_shared/discoverMigrations-De3uDJi0.mjs";import{MUTATORS_FILENAME as $,discoverMutators as ee}from"./packem_shared/MUTATORS_FILENAME-CuG6xLJ1.mjs";import{default as oe}from"./packem_shared/discoverNondeterministicCalls-XHRCA4rr.mjs";import{NOTIFY_FILENAME as ae,discoverNotifyCalls as se,discoverNotifyConfig as ie}from"./packem_shared/NOTIFY_FILENAME-C70ZrThq.mjs";import{default as fe}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{default as pe}from"./packem_shared/discoverQueries-B0vvHwFI.mjs";import{QUEUES_FILENAME as ne,discoverQueues as ce}from"./packem_shared/QUEUES_FILENAME-16xcVWpo.mjs";import{default as Se}from"./packem_shared/discoverR2sqlCalls-BQ90jfu3.mjs";import{default as ue}from"./packem_shared/discoverRlsProcedures-Cy8-Q0AP.mjs";import{default as ve}from"./packem_shared/discoverRlsMetadata-BuGLdQWs.mjs";import{discoverSandboxUsage as Ce}from"./packem_shared/discoverSandboxUsage-Bjl8A_hj.mjs";import{default as Oe}from"./packem_shared/discoverSchema-Cd3iH6q5.mjs";import{readServiceBindings as Te,resolveServiceBindings as _e}from"./packem_shared/readServiceBindings-CnvEGOir.mjs";import{SHAPES_FILENAME as Le,discoverShapes as Me}from"./packem_shared/SHAPES_FILENAME-e82UBLBE.mjs";import{default as Fe}from"./packem_shared/discoverStorageRulesMetadata-C6sTEVS5.mjs";import{WORKFLOWS_FILENAME as De,discoverWorkflows as be}from"./packem_shared/WORKFLOWS_FILENAME-Bcfd76Wf.mjs";import{emitApp as ye}from"./packem_shared/emitApp-RNU41dtm.mjs";import{isD1GlobalTable as He,isHyperdriveGlobalTable as je}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as ke,emitOpenApi as We,emitOpenApiModule as Ke}from"./packem_shared/buildOpenApiDocument-DOsv1HEF.mjs";import{OPENRPC_VERSION as ze,buildOpenRpcDocument as Qe,emitOpenRpc as qe,emitOpenRpcModule as we}from"./packem_shared/OPENRPC_VERSION-CGu1_YK7.mjs";import{DEFAULT_TARGET as Ye,platformMatrixIds as Xe,readProjectTarget as Ze,resolveCodegenTarget as $e}from"./packem_shared/DEFAULT_TARGET-7sHexLjO.mjs";import{loadProjectConfig as rr,readProjectConfigLiterals as or}from"./packem_shared/loadProjectConfig-CuGQsqYS.mjs";import{SCHEMA_SNAPSHOT_FILENAME as ar,createCodegenProject as sr,findTsconfig as ir,refreshCodegenProject as mr,runCodegen as fr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-BMzr0ydt.mjs";import{SchemaSnapshotParseError as pr,buildSchemaSnapshot as lr,evaluateSchemaDrift as nr,parseSchemaSnapshot as cr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as Sr}from"./packem_shared/fingerprintSchemaSources-BzFVnBfa.mjs";import{schemaFromIr as ur}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as vr,validatorIrToJsonSchema as gr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Nr,SDK_TARGETS as Or,generateSdk as Rr}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as _r,secretKindOf as Ir}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Mr}from"./packem_shared/emitDrizzleSchema-DohtnI8c.mjs";import{default as Fr}from"./packem_shared/emitFunctions-evl8Mx1a.mjs";import{default as Dr}from"./packem_shared/emitServer-DymRagL2.mjs";import{e as Ur}from"./packem_shared/shard-WXSIZRpD.mjs";import{G as Gr}from"./packem_shared/shared-BXUKWh7t.mjs";import{MESSAGE_SOLUTIONS as jr,findSolutionByMessage as Br}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Wr,findProjectConfigFile as Kr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{s as zr,t as Qr,u as qr}from"./packem_shared/shard-runtime-B1nU9CRa.mjs";import{emitApi as Jr,emitCollections as Yr}from"./packem_shared/emitApi-xDIHPRPH.mjs";import{emitCrons as Zr,emitScheduler as $r,emitVectors as eo,emitWranglerCronTriggers as ro}from"./packem_shared/emitCrons-DsXsg1uG.mjs";import{emitDataModel as to}from"./packem_shared/emitDataModel-DSk9AkJe.mjs";import{isTypedSchema as so}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,Ye as DEFAULT_TARGET,H as FLAGS_FILENAME,Gr as GENERATED_HEADER,vr as LUNORA_ERROR_CODES,jr as LUNORA_SOLUTION_RULES,$ as MUTATORS_FILENAME,ae as NOTIFY_FILENAME,ze as OPENRPC_VERSION,Wr as PROJECT_CONFIG_FILENAMES,ne as QUEUES_FILENAME,ar as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Nr as SDK_LANGUAGES,Or as SDK_TARGETS,Le as SHAPES_FILENAME,pr as SchemaSnapshotParseError,e as VERSION,De as WORKFLOWS_FILENAME,ke as buildOpenApiDocument,Qe as buildOpenRpcDocument,lr as buildSchemaSnapshot,D as capabilitiesUsedBy,sr as createCodegenProject,l as describeErrorLevelFindings,v as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,_ as discoverAuthApiCalls,M as discoverContainers,F as discoverCrons,j as discoverFlags,k as discoverFunctions,K as discoverHttpRoutes,z as discoverHyperdriveCalls,q as discoverInserts,J as discoverMaskProcedures,X as discoverMigrations,ee as discoverMutators,oe as discoverNondeterministicCalls,se as discoverNotifyCalls,ie as discoverNotifyConfig,pe as discoverQueries,ce as discoverQueues,Se as discoverR2sqlCalls,ve as discoverRlsMetadata,ue as discoverRlsProcedures,Ce as discoverSandboxUsage,Oe as discoverSchema,Me as discoverShapes,Fe as discoverStorageRulesMetadata,be as discoverWorkflows,zr as emitAgents,Jr as emitApi,ye as emitApp,Yr as emitCollections,Qr as emitContainers,Zr as emitCrons,to as emitDataModel,Mr as emitDrizzleSchema,Fr as emitFunctions,We as emitOpenApi,Ke as emitOpenApiModule,qe as emitOpenRpc,we as emitOpenRpcModule,$r as emitScheduler,Dr as emitServer,Ur as emitShard,eo as emitVectors,qr as emitWorkflows,ro as emitWranglerCronTriggers,n as errorAdvisoryNames,c as errorPlatformDiagnosticNames,nr as evaluateSchemaDrift,Br as findLunoraSolution,Kr as findProjectConfigFile,ir as findTsconfig,Sr as fingerprintSchemaSources,b as foldCapabilitySignals,m as formatAdvisories,Rr as generateSdk,He as isD1GlobalTable,je as isHyperdriveGlobalTable,so as isTypedSchema,f as lintSchema,R as listLunoraSourceFiles,rr as loadProjectConfig,U as mayReadCapabilityContext,cr as parseSchemaSnapshot,Xe as platformMatrixIds,fe as readPackageDependencies,or as readProjectConfigLiterals,Ze as readProjectTarget,Te as readServiceBindings,_r as redact,mr as refreshCodegenProject,$e as resolveCodegenTarget,_e as resolveServiceBindings,fr as runCodegen,ur as schemaFromIr,Ir as secretKindOf,s as serializeSchemaSnapshot,x as sortedUniqueNames,y as sourceCapabilitySignals,d as toAdvisorContext,gr as validatorIrToJsonSchema};
@@ -1 +1 @@
1
- import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as g}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as w}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as h}from"./attribution-sW_DHmLO.mjs";const E="agents.ts",v=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const e of n.getDeclarations())if(a.isImportSpecifier(e))return e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:e.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),x=(o,n,e)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${e}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},I=(o,n)=>{const e=o.getArguments()[0];if(!e||!a.isObjectLiteralExpression(e))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const t={className:b(n),exportName:n,name:d(n)},i=c(e,"name");i&&a.isPropertyAssignment(i)&&(t.name=P(i.getInitializerOrThrow(),n,"name"));const r=c(e,"publicRun");r&&a.isPropertyAssignment(r)&&x(r.getInitializerOrThrow(),n,"publicRun")&&(t.publicRun=!0);const s=c(e,"voice");if(s&&a.isPropertyAssignment(s)){const m=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(m))throw l(m,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);t.voice=!0,t.voiceBindingName=N(n),t.voiceClassName=y(n)}return c(e,"onEmail")&&(t.onEmail=!0),t},S=o=>{const n=[];for(const e of o.getVariableDeclarations()){const t=A(e.getInitializer());if(!t)continue;const i=t.getExpression();if(!a.isIdentifier(i)||!v(i))continue;const r=e.getNameNode();if(!a.isIdentifier(r)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw l(r,"defineAgent exports must be plain named exports (no destructuring)")}const s=h(e,"binding");s!==void 0&&n.push(I(t,s))}return n},T=o=>{const n=new Map,e=new Map;for(const t of o){const i=n.get(t.name);if(i!==void 0)throw new g("DUPLICATE_AGENT_NAME",`Duplicate agent name "${t.name}": produced by both "${i}" and "${t.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(t.name,t.exportName);const r=e.get(t.className);if(r!==void 0)throw new g("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${t.className}": produced by both "${r}" and "${t.exportName}". Agent export names must yield unique generated class names.`,{status:500});e.set(t.className,t.exportName)}},z=(o,n)=>{const e=f(n,E);if(!p(e))return[];const t=o.getSourceFile(e)??o.addSourceFileAtPath(e),i=S(t);return i.sort((r,s)=>r.exportName.localeCompare(s.exportName)),T(i),i};export{E as AGENTS_FILENAME,z as discoverAgents};
1
+ import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as g}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as w}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as h}from"./attribution-JcwxPpyK.mjs";const E="agents.ts",v=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const e of n.getDeclarations())if(a.isImportSpecifier(e))return e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:e.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),x=(o,n,e)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${e}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},I=(o,n)=>{const e=o.getArguments()[0];if(!e||!a.isObjectLiteralExpression(e))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const t={className:b(n),exportName:n,name:d(n)},i=c(e,"name");i&&a.isPropertyAssignment(i)&&(t.name=P(i.getInitializerOrThrow(),n,"name"));const r=c(e,"publicRun");r&&a.isPropertyAssignment(r)&&x(r.getInitializerOrThrow(),n,"publicRun")&&(t.publicRun=!0);const s=c(e,"voice");if(s&&a.isPropertyAssignment(s)){const m=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(m))throw l(m,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);t.voice=!0,t.voiceBindingName=N(n),t.voiceClassName=y(n)}return c(e,"onEmail")&&(t.onEmail=!0),t},S=o=>{const n=[];for(const e of o.getVariableDeclarations()){const t=A(e.getInitializer());if(!t)continue;const i=t.getExpression();if(!a.isIdentifier(i)||!v(i))continue;const r=e.getNameNode();if(!a.isIdentifier(r)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw l(r,"defineAgent exports must be plain named exports (no destructuring)")}const s=h(e,"binding");s!==void 0&&n.push(I(t,s))}return n},T=o=>{const n=new Map,e=new Map;for(const t of o){const i=n.get(t.name);if(i!==void 0)throw new g("DUPLICATE_AGENT_NAME",`Duplicate agent name "${t.name}": produced by both "${i}" and "${t.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(t.name,t.exportName);const r=e.get(t.className);if(r!==void 0)throw new g("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${t.className}": produced by both "${r}" and "${t.exportName}". Agent export names must yield unique generated class names.`,{status:500});e.set(t.className,t.exportName)}},z=(o,n)=>{const e=f(n,E);if(!p(e))return[];const t=o.getSourceFile(e)??o.addSourceFileAtPath(e),i=S(t);return i.sort((r,s)=>r.exportName.localeCompare(s.exportName)),T(i),i};export{E as AGENTS_FILENAME,z as discoverAgents};
@@ -1 +1 @@
1
- import{existsSync as T}from"node:fs";import{join as j}from"node:path";import{containerClassName as I,containerBindingName as A,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as O,isManagedImage as k,isCloudflareRegistryDigest as C,normalizeContainerImage as m}from"@lunora/container";import{SyntaxKind as S,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{propertyKeyName as b,stringPropertyFor as _,findObjectProperty as p,symbolConstInitializer as D,outermostValueWrapper as w,isWriteTarget as M}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as F}from"./attribution-sW_DHmLO.mjs";const V="containers.ts",K=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const i of e.getDeclarations())if(s.isImportSpecifier(i))return i.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:i.getNameNode().getText()==="defineContainer";return!1},d=_("container"),y=(t,e,i)=>{if(s.isNumericLiteral(t))return t.getLiteralValue();throw a(t,`container "${e}": \`${i}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},$=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return m(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const i=p(t,"registry");if(i&&s.isPropertyAssignment(i)){const r=i.getInitializerOrThrow();return m({registry:d(r,e,"image.registry")})}const n=p(t,"build");if(n&&s.isPropertyAssignment(n)){const r=n.getInitializerOrThrow();return m({build:d(r,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},B=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),R=new Set(["gracePeriodSeconds","stepPercentage"]),E=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},U=(t,e)=>e.getDescendantsOfKind(S.Identifier).some(i=>{if(i.getSymbol()!==t)return!1;let n=w(i),r=n.getParent();if(s.isCallExpression(r)&&r.getExpression().getText()==="Object.assign")return r.getArguments()[0]===n;for(;(s.isPropertyAccessExpression(r)||s.isElementAccessExpression(r))&&r.getExpression()===n;){if(M(r))return!0;n=w(r),r=n.getParent()}return!1}),z=16,L=(t,e,i,n)=>{let r={name:i,symbol:t},o;for(let c=0;c<z;c+=1){const l=D(r.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=E(l),s.isObjectLiteralExpression(o)&&r.symbol!==void 0&&U(r.symbol,e.getSourceFile()))throw a(e,`${n}: \`${r.name}\` is a const object that is written to elsewhere in this file, so its initializer is not the value the container runs with. Declare the settings where they are final.`);if(!s.isIdentifier(o))return o;r={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const i=E(t);return s.isIdentifier(i)?L(i.getSymbol(),i,i.getText(),e)??i:i},N=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(r=>r.getName()))},Y=(t,e,i)=>{const n=t.getExpression().getType(),r=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(N(n))].filter(o=>e.has(o)).map(o=>`\`${o}\``);if(r.length>0)throw a(t,`${i}: this spread can set ${r.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},W=(t,e,i)=>{const n=b(t),r=s.isShorthandPropertyAssignment(t)?L(t.getValueSymbol(),t,n,i):void 0;if(r!==void 0)return[n,r];if(e==="every"||e.has(n))throw a(t,`${i}: \`${n}\` is deploy configuration codegen writes into wrangler.jsonc, so it must be a static literal — inline it, or name a module-scope \`const\` initialized with one.`)},f=(t,e,i,n=new Set)=>{const r=[],o=new Set(n).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))r.push([b(c),P(c.getInitializerOrThrow(),i)]);else if(s.isSpreadAssignment(c))r.push(...q(c,e,i,o));else{const l=W(c,e,i);l!==void 0&&r.push(l)}return r},q=(t,e,i,n)=>{const r=P(t.getExpression(),i);if(!s.isObjectLiteralExpression(r))return Y(t,e,i),[];if(n.has(r))throw a(t,`${i}: this spread refers back to an object it is part of, so it has no static value.`);return f(r,e,i,n)},x=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`buildArgs\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const i={};for(const[n,r]of f(t,"every",`container "${e}" buildArgs`))i[n]=d(r,e,`buildArgs.${n}`);return Object.keys(i).length>0?i:void 0},H=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`rollout\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const i={};for(const[n,r]of f(t,R,`container "${e}" rollout`))(n==="gracePeriodSeconds"||n==="stepPercentage")&&(i[n]=y(r,e,`rollout.${n}`));return i.gracePeriodSeconds===void 0&&i.stepPercentage===void 0?void 0:i},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},J=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},X=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const i={};for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))throw a(n,`container "${e}": \`instanceType\` must be an object of static number literals`);const r=b(n);if(r!=="diskMb"&&r!=="memoryMib"&&r!=="vcpu")throw a(n,`container "${e}": unknown \`instanceType\` field "${r}" — expected vcpu, memoryMib, or diskMb`);i[r]=y(n.getInitializerOrThrow(),e,`instanceType.${r}`)}return i}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},G=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`images\` must be a static object literal — codegen writes it into wrangler.jsonc`);const i={};for(const[n,r]of f(t,"every",`container "${e}" images`)){const o=$(r,e);if(o.kind==="build")throw a(r,`container "${e}": \`images["${n}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!C(o.reference))throw a(r,`container "${e}": \`images["${n}"].registry\` must be a digest-pinned (@sha256) reference under registry.cloudflare.com — push other registries' images there first`);i[n]=o}return i},Q=(t,e)=>{const i=t.findLast(([r])=>r==="schedulingPolicy");if(i===void 0)return;const n=d(i[1],e,"schedulingPolicy");if(n!=="default"&&n!=="durable_object")throw a(i[1],`container "${e}": unknown \`schedulingPolicy\` "${n}" — use "default" or "durable_object"`);return n==="durable_object"?n:void 0},Z=(t,e,i,n)=>{if(i!==void 0&&O.includes(t))throw a(e,`container "${n}": \`${t}\` is not supported with schedulingPolicy "durable_object"`);if(i===void 0&&t==="images")throw a(e,`container "${n}": \`images\` needs schedulingPolicy "durable_object"`)},ee=(t,e,i,n)=>{const{base:r,policy:o}=i;switch(t){case"buildArgs":{r.buildArgs=x(e,n);break}case"enableInternet":{r.enableInternet=v(e);break}case"image":{i.scheduled||(o.image=$(e,n));break}case"images":{o.images=G(e,n);break}case"instanceType":{r.instanceType=X(e,n);break}case"maxInstances":{o.maxInstances=y(e,n,"maxInstances");break}case"name":{r.name=d(e,n,"name");break}case"rollout":{o.rollout=H(e,n);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${n}": \`sandbox\` must be a static true/false literal`);r.sandbox=c;break}case"sleepAfter":{r.sleepAfter=J(e);break}}},te=(t,e,i)=>{const n=t.findLast(([o])=>o==="image")?.[1];if(n===void 0||!(s.isStringLiteral(n)||s.isNoSubstitutionTemplateLiteral(n)))return;const r=n.getLiteralValue();if(!Object.hasOwn(e??{},r)&&!k(r))throw a(n,`container "${i}": \`image\` "${r}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ne=(t,e)=>{const i=t.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const n=f(i,B,`container "${e}"`),r=Q(n,e),o={base:{bindingName:A(e),className:I(e),exportName:e},policy:{},scheduled:r!==void 0};for(const[g,u]of n)Z(g,u,r,e),ee(g,u,o,e);const{base:c,policy:l}=o;if(r==="durable_object")return te(n,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:r};if(l.image===void 0)throw a(i,`container "${e}": defineContainer requires a static \`image\` property`);return{...c,image:l.image,...l.maxInstances===void 0?{}:{maxInstances:l.maxInstances},...l.rollout===void 0?{}:{rollout:l.rollout}}},ie=t=>{const e=[],i=new Map;for(const n of t.getVariableDeclarations()){const r=n.getInitializer();if(r?.getKind()!==S.CallExpression)continue;const o=r,c=o.getExpression();if(!s.isIdentifier(c)||!K(c))continue;const l=n.getNameNode();if(!s.isIdentifier(l)){if(n.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=F(n,"binding");if(g===void 0)continue;const u=ne(o,g),h=i.get(u.bindingName);if(h!==void 0)throw a(l,`containers "${h}" and "${u.exportName}" both map to the binding ${u.bindingName} — rename one so each container gets its own Durable Object binding`);i.set(u.bindingName,u.exportName),e.push(u)}return e},ge=(t,e)=>{const i=j(e,V);if(!T(i))return[];const n=t.getSourceFile(i)??t.addSourceFileAtPath(i),r=ie(n);return r.sort((o,c)=>o.exportName.localeCompare(c.exportName)),r};export{V as CONTAINERS_FILENAME,ge as discoverContainers};
1
+ import{existsSync as T}from"node:fs";import{join as j}from"node:path";import{containerClassName as I,containerBindingName as A,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as O,isManagedImage as k,isCloudflareRegistryDigest as C,normalizeContainerImage as m}from"@lunora/container";import{SyntaxKind as S,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{propertyKeyName as b,stringPropertyFor as _,findObjectProperty as p,symbolConstInitializer as D,outermostValueWrapper as w,isWriteTarget as M}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as F}from"./attribution-JcwxPpyK.mjs";const V="containers.ts",K=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const i of e.getDeclarations())if(s.isImportSpecifier(i))return i.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:i.getNameNode().getText()==="defineContainer";return!1},d=_("container"),y=(t,e,i)=>{if(s.isNumericLiteral(t))return t.getLiteralValue();throw a(t,`container "${e}": \`${i}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},$=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return m(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const i=p(t,"registry");if(i&&s.isPropertyAssignment(i)){const r=i.getInitializerOrThrow();return m({registry:d(r,e,"image.registry")})}const n=p(t,"build");if(n&&s.isPropertyAssignment(n)){const r=n.getInitializerOrThrow();return m({build:d(r,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},B=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),R=new Set(["gracePeriodSeconds","stepPercentage"]),E=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},U=(t,e)=>e.getDescendantsOfKind(S.Identifier).some(i=>{if(i.getSymbol()!==t)return!1;let n=w(i),r=n.getParent();if(s.isCallExpression(r)&&r.getExpression().getText()==="Object.assign")return r.getArguments()[0]===n;for(;(s.isPropertyAccessExpression(r)||s.isElementAccessExpression(r))&&r.getExpression()===n;){if(M(r))return!0;n=w(r),r=n.getParent()}return!1}),z=16,L=(t,e,i,n)=>{let r={name:i,symbol:t},o;for(let c=0;c<z;c+=1){const l=D(r.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=E(l),s.isObjectLiteralExpression(o)&&r.symbol!==void 0&&U(r.symbol,e.getSourceFile()))throw a(e,`${n}: \`${r.name}\` is a const object that is written to elsewhere in this file, so its initializer is not the value the container runs with. Declare the settings where they are final.`);if(!s.isIdentifier(o))return o;r={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const i=E(t);return s.isIdentifier(i)?L(i.getSymbol(),i,i.getText(),e)??i:i},N=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(r=>r.getName()))},Y=(t,e,i)=>{const n=t.getExpression().getType(),r=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(N(n))].filter(o=>e.has(o)).map(o=>`\`${o}\``);if(r.length>0)throw a(t,`${i}: this spread can set ${r.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},W=(t,e,i)=>{const n=b(t),r=s.isShorthandPropertyAssignment(t)?L(t.getValueSymbol(),t,n,i):void 0;if(r!==void 0)return[n,r];if(e==="every"||e.has(n))throw a(t,`${i}: \`${n}\` is deploy configuration codegen writes into wrangler.jsonc, so it must be a static literal — inline it, or name a module-scope \`const\` initialized with one.`)},f=(t,e,i,n=new Set)=>{const r=[],o=new Set(n).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))r.push([b(c),P(c.getInitializerOrThrow(),i)]);else if(s.isSpreadAssignment(c))r.push(...q(c,e,i,o));else{const l=W(c,e,i);l!==void 0&&r.push(l)}return r},q=(t,e,i,n)=>{const r=P(t.getExpression(),i);if(!s.isObjectLiteralExpression(r))return Y(t,e,i),[];if(n.has(r))throw a(t,`${i}: this spread refers back to an object it is part of, so it has no static value.`);return f(r,e,i,n)},x=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`buildArgs\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const i={};for(const[n,r]of f(t,"every",`container "${e}" buildArgs`))i[n]=d(r,e,`buildArgs.${n}`);return Object.keys(i).length>0?i:void 0},H=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`rollout\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const i={};for(const[n,r]of f(t,R,`container "${e}" rollout`))(n==="gracePeriodSeconds"||n==="stepPercentage")&&(i[n]=y(r,e,`rollout.${n}`));return i.gracePeriodSeconds===void 0&&i.stepPercentage===void 0?void 0:i},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},J=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},X=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const i={};for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))throw a(n,`container "${e}": \`instanceType\` must be an object of static number literals`);const r=b(n);if(r!=="diskMb"&&r!=="memoryMib"&&r!=="vcpu")throw a(n,`container "${e}": unknown \`instanceType\` field "${r}" — expected vcpu, memoryMib, or diskMb`);i[r]=y(n.getInitializerOrThrow(),e,`instanceType.${r}`)}return i}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},G=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`images\` must be a static object literal — codegen writes it into wrangler.jsonc`);const i={};for(const[n,r]of f(t,"every",`container "${e}" images`)){const o=$(r,e);if(o.kind==="build")throw a(r,`container "${e}": \`images["${n}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!C(o.reference))throw a(r,`container "${e}": \`images["${n}"].registry\` must be a digest-pinned (@sha256) reference under registry.cloudflare.com — push other registries' images there first`);i[n]=o}return i},Q=(t,e)=>{const i=t.findLast(([r])=>r==="schedulingPolicy");if(i===void 0)return;const n=d(i[1],e,"schedulingPolicy");if(n!=="default"&&n!=="durable_object")throw a(i[1],`container "${e}": unknown \`schedulingPolicy\` "${n}" — use "default" or "durable_object"`);return n==="durable_object"?n:void 0},Z=(t,e,i,n)=>{if(i!==void 0&&O.includes(t))throw a(e,`container "${n}": \`${t}\` is not supported with schedulingPolicy "durable_object"`);if(i===void 0&&t==="images")throw a(e,`container "${n}": \`images\` needs schedulingPolicy "durable_object"`)},ee=(t,e,i,n)=>{const{base:r,policy:o}=i;switch(t){case"buildArgs":{r.buildArgs=x(e,n);break}case"enableInternet":{r.enableInternet=v(e);break}case"image":{i.scheduled||(o.image=$(e,n));break}case"images":{o.images=G(e,n);break}case"instanceType":{r.instanceType=X(e,n);break}case"maxInstances":{o.maxInstances=y(e,n,"maxInstances");break}case"name":{r.name=d(e,n,"name");break}case"rollout":{o.rollout=H(e,n);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${n}": \`sandbox\` must be a static true/false literal`);r.sandbox=c;break}case"sleepAfter":{r.sleepAfter=J(e);break}}},te=(t,e,i)=>{const n=t.findLast(([o])=>o==="image")?.[1];if(n===void 0||!(s.isStringLiteral(n)||s.isNoSubstitutionTemplateLiteral(n)))return;const r=n.getLiteralValue();if(!Object.hasOwn(e??{},r)&&!k(r))throw a(n,`container "${i}": \`image\` "${r}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ne=(t,e)=>{const i=t.getArguments()[0];if(!i||!s.isObjectLiteralExpression(i))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const n=f(i,B,`container "${e}"`),r=Q(n,e),o={base:{bindingName:A(e),className:I(e),exportName:e},policy:{},scheduled:r!==void 0};for(const[g,u]of n)Z(g,u,r,e),ee(g,u,o,e);const{base:c,policy:l}=o;if(r==="durable_object")return te(n,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:r};if(l.image===void 0)throw a(i,`container "${e}": defineContainer requires a static \`image\` property`);return{...c,image:l.image,...l.maxInstances===void 0?{}:{maxInstances:l.maxInstances},...l.rollout===void 0?{}:{rollout:l.rollout}}},ie=t=>{const e=[],i=new Map;for(const n of t.getVariableDeclarations()){const r=n.getInitializer();if(r?.getKind()!==S.CallExpression)continue;const o=r,c=o.getExpression();if(!s.isIdentifier(c)||!K(c))continue;const l=n.getNameNode();if(!s.isIdentifier(l)){if(n.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=F(n,"binding");if(g===void 0)continue;const u=ne(o,g),h=i.get(u.bindingName);if(h!==void 0)throw a(l,`containers "${h}" and "${u.exportName}" both map to the binding ${u.bindingName} — rename one so each container gets its own Durable Object binding`);i.set(u.bindingName,u.exportName),e.push(u)}return e},ge=(t,e)=>{const i=j(e,V);if(!T(i))return[];const n=t.getSourceFile(i)??t.addSourceFileAtPath(i),r=ie(n);return r.sort((o,c)=>o.exportName.localeCompare(c.exportName)),r};export{V as CONTAINERS_FILENAME,ge as discoverContainers};
@@ -1 +1 @@
1
- import{existsSync as E}from"node:fs";import{join as y}from"node:path";import{Node as o,SyntaxKind as l}from"ts-morph";import{diagnosticAt as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as M}from"./module-specifiers-WF8iAydP.mjs";import{p as A}from"./parse-validator-B4mFs19C.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{j as D,i as b,f as g,d as O}from"./attribution-sW_DHmLO.mjs";import{u as w}from"./unwrap-handler-return-D7E2TKkS.mjs";const z="mutators.ts",x=M,h=r=>{const e=r.getSymbol();if(!e)return r.getText()==="defineMutator";for(const t of e.getDeclarations())if(o.isImportSpecifier(t))return x(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMutator":!1;return!1},C=r=>{const e=r.getSymbol();if(!e)return!1;for(const t of e.getDeclarations()){if(!o.isNamespaceImport(t))continue;const i=t.getFirstAncestorByKind(l.ImportDeclaration);return i!==void 0&&x(i.getModuleSpecifierValue())}return!1},N=r=>{if(o.isIdentifier(r))return h(r);if(o.isPropertyAccessExpression(r)){const e=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(e)&&C(e)}return!1},S=r=>{const e=r.getArguments()[0];return e&&o.isObjectLiteralExpression(e)?e:void 0},m=new WeakMap,p=r=>{let e=m.get(r.compilerNode);if(e===void 0){const t=r.getNameNode(),i=t?.getText();e=r.getSourceFile().getDescendantsOfKind(l.Identifier).filter(s=>s!==t&&s.getText()===i&&g(s)?.compilerNode===r.compilerNode).length===1&&O(r)===void 0,m.set(r.compilerNode,e)}return e},f=r=>{const e=o.isIdentifier(r)?g(r):void 0,t=o.isSourceFile(e?.getParent())||o.isSourceFile(e?.getParent()?.getParent()?.getParent());if(e===void 0||e.getSourceFile()!==r?.getSourceFile()||!t)return;if(o.isFunctionDeclaration(e))return e.hasBody()&&p(e)?e:void 0;const i=P(e)?d(e.getInitializer()):void 0;return(o.isArrowFunction(i)||o.isFunctionExpression(i))&&o.isVariableDeclaration(e)&&p(e)?i:void 0},G=r=>{const e=r.getInitializer();if(!o.isCallExpression(e)||!N(e.getExpression()))return;const t=c(S(e),"server");if(o.isMethodDeclaration(t))return t;if(o.isShorthandPropertyAssignment(t))return f(t.getNameNode());const i=o.isPropertyAssignment(t)?d(t.getInitializer()):void 0;return o.isArrowFunction(i)||o.isFunctionExpression(i)?i:f(i)},T=r=>{const e=c(r,"args");if(!e||!o.isPropertyAssignment(e))return{};const t=e.getInitializer();return t&&o.isObjectLiteralExpression(t)?A(t):{}},L=r=>{const e=c(r,"server");if(!e||!o.isPropertyAssignment(e))return"unknown";const t=e.getInitializer();return!t||!(o.isArrowFunction(t)||o.isFunctionExpression(t))?"unknown":w(t)},j=r=>{const e=c(r,"owner");if(!e||!o.isPropertyAssignment(e))return;const t=e.getInitializer();return t&&o.isStringLiteral(t)?t.getLiteralValue():void 0},R=r=>{const e=[];for(const t of r.getVariableDeclarations()){if(!t.isExported())continue;const i=t.getInitializer();if(i?.getKind()!==l.CallExpression)continue;const n=i,s=n.getExpression();if(!N(s))continue;const a=t.getNameNode();if(!o.isIdentifier(a))throw I(a,"defineMutator exports must be plain named exports (no destructuring)");const u=S(n);for(const v of D(t).filter(F=>b(F)))e.push({args:T(u),exportName:v,filePath:"mutators",line:n.getStartLineNumber(),owner:j(u),returnType:L(u)})}return e},J=(r,e)=>{const t=y(e,z);if(!E(t))return[];const i=r.getSourceFile(t)??r.addSourceFileAtPath(t),n=R(i);return n.sort((s,a)=>s.exportName.localeCompare(a.exportName)),n};export{z as MUTATORS_FILENAME,J as discoverMutators,N as isDefineMutatorCallee,S as mutatorLiteral,G as mutatorServerImplOf};
1
+ import{existsSync as E}from"node:fs";import{join as y}from"node:path";import{Node as o,SyntaxKind as l}from"ts-morph";import{diagnosticAt as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as M}from"./module-specifiers-WF8iAydP.mjs";import{p as A}from"./parse-validator-B4mFs19C.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{j as D,i as b,f as g,d as O}from"./attribution-JcwxPpyK.mjs";import{u as w}from"./unwrap-handler-return-D7E2TKkS.mjs";const z="mutators.ts",x=M,h=r=>{const e=r.getSymbol();if(!e)return r.getText()==="defineMutator";for(const t of e.getDeclarations())if(o.isImportSpecifier(t))return x(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMutator":!1;return!1},C=r=>{const e=r.getSymbol();if(!e)return!1;for(const t of e.getDeclarations()){if(!o.isNamespaceImport(t))continue;const i=t.getFirstAncestorByKind(l.ImportDeclaration);return i!==void 0&&x(i.getModuleSpecifierValue())}return!1},N=r=>{if(o.isIdentifier(r))return h(r);if(o.isPropertyAccessExpression(r)){const e=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(e)&&C(e)}return!1},S=r=>{const e=r.getArguments()[0];return e&&o.isObjectLiteralExpression(e)?e:void 0},m=new WeakMap,p=r=>{let e=m.get(r.compilerNode);if(e===void 0){const t=r.getNameNode(),i=t?.getText();e=r.getSourceFile().getDescendantsOfKind(l.Identifier).filter(s=>s!==t&&s.getText()===i&&g(s)?.compilerNode===r.compilerNode).length===1&&O(r)===void 0,m.set(r.compilerNode,e)}return e},f=r=>{const e=o.isIdentifier(r)?g(r):void 0,t=o.isSourceFile(e?.getParent())||o.isSourceFile(e?.getParent()?.getParent()?.getParent());if(e===void 0||e.getSourceFile()!==r?.getSourceFile()||!t)return;if(o.isFunctionDeclaration(e))return e.hasBody()&&p(e)?e:void 0;const i=P(e)?d(e.getInitializer()):void 0;return(o.isArrowFunction(i)||o.isFunctionExpression(i))&&o.isVariableDeclaration(e)&&p(e)?i:void 0},G=r=>{const e=r.getInitializer();if(!o.isCallExpression(e)||!N(e.getExpression()))return;const t=c(S(e),"server");if(o.isMethodDeclaration(t))return t;if(o.isShorthandPropertyAssignment(t))return f(t.getNameNode());const i=o.isPropertyAssignment(t)?d(t.getInitializer()):void 0;return o.isArrowFunction(i)||o.isFunctionExpression(i)?i:f(i)},T=r=>{const e=c(r,"args");if(!e||!o.isPropertyAssignment(e))return{};const t=e.getInitializer();return t&&o.isObjectLiteralExpression(t)?A(t):{}},L=r=>{const e=c(r,"server");if(!e||!o.isPropertyAssignment(e))return"unknown";const t=e.getInitializer();return!t||!(o.isArrowFunction(t)||o.isFunctionExpression(t))?"unknown":w(t)},j=r=>{const e=c(r,"owner");if(!e||!o.isPropertyAssignment(e))return;const t=e.getInitializer();return t&&o.isStringLiteral(t)?t.getLiteralValue():void 0},R=r=>{const e=[];for(const t of r.getVariableDeclarations()){if(!t.isExported())continue;const i=t.getInitializer();if(i?.getKind()!==l.CallExpression)continue;const n=i,s=n.getExpression();if(!N(s))continue;const a=t.getNameNode();if(!o.isIdentifier(a))throw I(a,"defineMutator exports must be plain named exports (no destructuring)");const u=S(n);for(const v of D(t).filter(F=>b(F)))e.push({args:T(u),exportName:v,filePath:"mutators",line:n.getStartLineNumber(),owner:j(u),returnType:L(u)})}return e},J=(r,e)=>{const t=y(e,z);if(!E(t))return[];const i=r.getSourceFile(t)??r.addSourceFileAtPath(t),n=R(i);return n.sort((s,a)=>s.exportName.localeCompare(a.exportName)),n};export{z as MUTATORS_FILENAME,J as discoverMutators,N as isDefineMutatorCallee,S as mutatorLiteral,G as mutatorServerImplOf};
@@ -1 +1 @@
1
- import{existsSync as P}from"node:fs";import{join as S}from"node:path";import{SyntaxKind as l,Node as f}from"ts-morph";import{listLunoraSourceFiles as p,lunoraRelativePath as y,defaultExportExpression as E,findObjectProperty as d,handlerOf as g}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{b as N,d as v}from"./attribution-sW_DHmLO.mjs";import{i as a}from"./context-root-KWXRWlv6.mjs";import{c as F}from"./classify-procedure-call-OnJoKgqu.mjs";const O="notify.ts",A=new Set(["chat","inApp","send","webhook"]),h=new Set(["broadcast","send"]),b=e=>{const t=e.getInitializer();if(!t||!f.isCallExpression(t))return;const o=F(t);if(!o)return;const r=g(t,o.receiver);return r?{exportName:v(e)??e.getName(),handler:r,kind:o.kind}:void 0},m=e=>{const t=[];for(const o of N(e)){const r=b(o);r&&t.push(r)}return t},x=e=>a(e,["notify"])?"notify":a(e,["push"])||a(e,["notify","push"])?"push":void 0,k=e=>{if(!f.isPropertyAccessExpression(e))return;const t=e.getName(),o=x(e.getExpression());if(o==="notify"&&A.has(t))return`ctx.notify.${t}`;if(o==="push"&&h.has(t))return`ctx.push.${t}`},C=e=>f.isPropertyAccessExpression(e)?x(e.getExpression())==="push"&&h.has(e.getName()):!1,M=(e,t)=>{const o=[];for(const r of p(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),c=y(t,r);for(const s of m(n))if(!(s.kind!=="query"&&s.kind!=="mutation"))for(const i of s.handler.getDescendantsOfKind(l.PropertyAccessExpression)){const u=k(i);u!==void 0&&o.push({callee:u,exportName:s.exportName,file:c,kind:s.kind,line:i.getStartLineNumber()})}}return o},D=(e,t)=>{for(const o of p(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o);for(const n of m(r))for(const c of n.handler.getDescendantsOfKind(l.PropertyAccessExpression))if(C(c))return!0}return!1},z=(e,t)=>{const o=S(t,O);if(!P(o))return;const r=e.getSourceFile(o)??e.addSourceFileAtPath(o),n=E(r);let c=!1,s=!1;if(n&&f.isCallExpression(n)){const i=n.getArguments()[0];i&&f.isObjectLiteralExpression(i)&&(c=d(i,"webPush")!==void 0,s=d(i,"fcm")!==void 0)}return{hasFcm:s,hasWebPush:c,usesPush:D(e,t)}};export{O as NOTIFY_FILENAME,M as discoverNotifyCalls,z as discoverNotifyConfig};
1
+ import{existsSync as P}from"node:fs";import{join as S}from"node:path";import{SyntaxKind as l,Node as f}from"ts-morph";import{listLunoraSourceFiles as p,lunoraRelativePath as y,defaultExportExpression as E,findObjectProperty as d,handlerOf as g}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{b as N,d as v}from"./attribution-JcwxPpyK.mjs";import{i as a}from"./context-root-Dlht00NP.mjs";import{c as F}from"./classify-procedure-call-OnJoKgqu.mjs";const O="notify.ts",A=new Set(["chat","inApp","send","webhook"]),h=new Set(["broadcast","send"]),b=e=>{const t=e.getInitializer();if(!t||!f.isCallExpression(t))return;const o=F(t);if(!o)return;const r=g(t,o.receiver);return r?{exportName:v(e)??e.getName(),handler:r,kind:o.kind}:void 0},m=e=>{const t=[];for(const o of N(e)){const r=b(o);r&&t.push(r)}return t},x=e=>a(e,["notify"])?"notify":a(e,["push"])||a(e,["notify","push"])?"push":void 0,k=e=>{if(!f.isPropertyAccessExpression(e))return;const t=e.getName(),o=x(e.getExpression());if(o==="notify"&&A.has(t))return`ctx.notify.${t}`;if(o==="push"&&h.has(t))return`ctx.push.${t}`},C=e=>f.isPropertyAccessExpression(e)?x(e.getExpression())==="push"&&h.has(e.getName()):!1,M=(e,t)=>{const o=[];for(const r of p(t)){const n=e.getSourceFile(r)??e.addSourceFileAtPath(r),c=y(t,r);for(const s of m(n))if(!(s.kind!=="query"&&s.kind!=="mutation"))for(const i of s.handler.getDescendantsOfKind(l.PropertyAccessExpression)){const u=k(i);u!==void 0&&o.push({callee:u,exportName:s.exportName,file:c,kind:s.kind,line:i.getStartLineNumber()})}}return o},D=(e,t)=>{for(const o of p(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o);for(const n of m(r))for(const c of n.handler.getDescendantsOfKind(l.PropertyAccessExpression))if(C(c))return!0}return!1},z=(e,t)=>{const o=S(t,O);if(!P(o))return;const r=e.getSourceFile(o)??e.addSourceFileAtPath(o),n=E(r);let c=!1,s=!1;if(n&&f.isCallExpression(n)){const i=n.getArguments()[0];i&&f.isObjectLiteralExpression(i)&&(c=d(i,"webPush")!==void 0,s=d(i,"fcm")!==void 0)}return{hasFcm:s,hasWebPush:c,usesPush:D(e,t)}};export{O as NOTIFY_FILENAME,M as discoverNotifyCalls,z as discoverNotifyConfig};
@@ -1 +1 @@
1
- import{existsSync as b}from"node:fs";import{join as h}from"node:path";import{LunoraError as f}from"@lunora/errors";import{queueDefaultName as y,queueBindingName as q}from"@lunora/queue";import{SyntaxKind as N,Node as c}from"ts-morph";import{diagnosticAt as d}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{findObjectProperty as m,stringPropertyFor as w}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as x}from"./attribution-sW_DHmLO.mjs";import{r as v}from"./handler-reference-C1oBljnl.mjs";const E="queues.ts",S=i=>{const t=e=>e==="defineQueue"||e==="defineSubscription"||e==="defineTopic",o=i.getSymbol();if(!o){const e=i.getText();return t(e)?e:void 0}for(const e of o.getDeclarations()){if(!c.isImportSpecifier(e))continue;if(e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/queue")return;const r=e.getNameNode().getText();return t(r)?r:void 0}},l=w("queue"),$=(i,t,o)=>{if(c.isNumericLiteral(i))return i.getLiteralValue();throw d(i,`queue "${t}": \`${o}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I=(i,t)=>{const o=m(i,"name");if(!o||!c.isPropertyAssignment(o))return;const e=l(o.getInitializerOrThrow(),t,"name");if(e.length===0)throw d(o,`queue "${t}": \`name\` must be a non-empty string when provided`);return e},g=(i,t,o,e)=>{const r=v(m(i,"handler"),e)?.site,s={bindingName:q(t),exportName:t,mode:"push",name:I(i,t)??y(t),...o===void 0?{}:{topic:o},...r===void 0?{}:{handlerSite:r},tuning:{}},n=m(i,"mode");if(n&&c.isPropertyAssignment(n)){if(o!==void 0)throw d(n,`subscription "${t}": \`mode\` is not allowed — a subscription is always a push consumer`);const u=l(n.getInitializerOrThrow(),t,"mode");if(u!=="push"&&u!=="pull")throw d(n,`queue "${t}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(u)})`);s.mode=u}const a=m(i,"deadLetterQueue");a&&c.isPropertyAssignment(a)&&(s.tuning.deadLetterQueue=l(a.getInitializerOrThrow(),t,"deadLetterQueue"));for(const u of["maxBatchSize","maxBatchTimeout","maxRetries","retryDelay"]){const p=m(i,u);p&&c.isPropertyAssignment(p)&&(s.tuning[u]=$(p.getInitializerOrThrow(),t,u))}return s},P=(i,t,o)=>{const e=i.getArguments()[0];if(!e||!c.isObjectLiteralExpression(e))throw d(i,`queue "${t}": defineQueue must be passed an inline object literal`);return g(e,t,void 0,o)},T=(i,t,o,e)=>{const[r,s]=i.getArguments();if(!r||!c.isIdentifier(r)||!o.has(r.getText()))throw d(r??i,`subscription "${t}": the first argument must name a \`defineTopic()\` export of lunora/queues.ts`);if(!s||!c.isObjectLiteralExpression(s))throw d(i,`subscription "${t}": defineSubscription must be passed an inline object literal`);return g(s,t,o.get(r.getText()),e)},A=i=>{const t=[];for(const o of i.getVariableDeclarations()){const e=o.getInitializer();if(e?.getKind()!==N.CallExpression)continue;const r=e,s=r.getExpression(),n=c.isIdentifier(s)?S(s):void 0;if(n===void 0)continue;const a=o.getNameNode();if(!c.isIdentifier(a)){if(o.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw d(a,`${n} exports must be plain named exports (no destructuring)`)}const u=x(o,"binding");u!==void 0&&t.push({call:r,exportName:u,factory:n,localName:a.getText()})}return t},Q=(i,t)=>{const o=A(i),e=new Map(o.filter(n=>n.factory==="defineTopic").map(n=>[n.localName,n.exportName])),r=[];for(const n of o)n.factory==="defineQueue"?r.push(P(n.call,n.exportName,t)):n.factory==="defineSubscription"&&r.push(T(n.call,n.exportName,e,t));const s=[...e.values()].map(n=>({exportName:n}));return{queues:r,topics:s}},L=i=>{const t=new Map,o=new Map;for(const e of i){const r=t.get(e.name);if(r!==void 0)throw new f("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${e.name}": produced by both "${r}" and "${e.exportName}". Deployed queue names must be unique across the project.`,{status:500});t.set(e.name,e.exportName);const s=o.get(e.bindingName);if(s!==void 0)throw new f("DUPLICATE_QUEUE_BINDING",`Duplicate queue binding "${e.bindingName}": produced by both "${s}" and "${e.exportName}". Queue export names must yield unique binding names.`,{status:500});o.set(e.bindingName,e.exportName)}},O=(i,t)=>{const o=h(t,E);if(!b(o))return{queues:[],topics:[]};const e=i.getSourceFile(o)??i.addSourceFileAtPath(o),{queues:r,topics:s}=Q(e,t),n=r.toSorted((a,u)=>a.exportName.localeCompare(u.exportName));return L(n),{queues:n,topics:s.toSorted((a,u)=>a.exportName.localeCompare(u.exportName))}},V=(i,t)=>O(i,t).queues;export{E as QUEUES_FILENAME,O as discoverQueueDeclarations,V as discoverQueues};
1
+ import{existsSync as b}from"node:fs";import{join as h}from"node:path";import{LunoraError as f}from"@lunora/errors";import{queueDefaultName as y,queueBindingName as q}from"@lunora/queue";import{SyntaxKind as N,Node as c}from"ts-morph";import{diagnosticAt as d}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{findObjectProperty as m,stringPropertyFor as w}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as x}from"./attribution-JcwxPpyK.mjs";import{r as v}from"./handler-reference-Dzp5GZ5p.mjs";const E="queues.ts",S=i=>{const t=e=>e==="defineQueue"||e==="defineSubscription"||e==="defineTopic",o=i.getSymbol();if(!o){const e=i.getText();return t(e)?e:void 0}for(const e of o.getDeclarations()){if(!c.isImportSpecifier(e))continue;if(e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/queue")return;const r=e.getNameNode().getText();return t(r)?r:void 0}},l=w("queue"),$=(i,t,o)=>{if(c.isNumericLiteral(i))return i.getLiteralValue();throw d(i,`queue "${t}": \`${o}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I=(i,t)=>{const o=m(i,"name");if(!o||!c.isPropertyAssignment(o))return;const e=l(o.getInitializerOrThrow(),t,"name");if(e.length===0)throw d(o,`queue "${t}": \`name\` must be a non-empty string when provided`);return e},g=(i,t,o,e)=>{const r=v(m(i,"handler"),e)?.site,s={bindingName:q(t),exportName:t,mode:"push",name:I(i,t)??y(t),...o===void 0?{}:{topic:o},...r===void 0?{}:{handlerSite:r},tuning:{}},n=m(i,"mode");if(n&&c.isPropertyAssignment(n)){if(o!==void 0)throw d(n,`subscription "${t}": \`mode\` is not allowed — a subscription is always a push consumer`);const u=l(n.getInitializerOrThrow(),t,"mode");if(u!=="push"&&u!=="pull")throw d(n,`queue "${t}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(u)})`);s.mode=u}const a=m(i,"deadLetterQueue");a&&c.isPropertyAssignment(a)&&(s.tuning.deadLetterQueue=l(a.getInitializerOrThrow(),t,"deadLetterQueue"));for(const u of["maxBatchSize","maxBatchTimeout","maxRetries","retryDelay"]){const p=m(i,u);p&&c.isPropertyAssignment(p)&&(s.tuning[u]=$(p.getInitializerOrThrow(),t,u))}return s},P=(i,t,o)=>{const e=i.getArguments()[0];if(!e||!c.isObjectLiteralExpression(e))throw d(i,`queue "${t}": defineQueue must be passed an inline object literal`);return g(e,t,void 0,o)},T=(i,t,o,e)=>{const[r,s]=i.getArguments();if(!r||!c.isIdentifier(r)||!o.has(r.getText()))throw d(r??i,`subscription "${t}": the first argument must name a \`defineTopic()\` export of lunora/queues.ts`);if(!s||!c.isObjectLiteralExpression(s))throw d(i,`subscription "${t}": defineSubscription must be passed an inline object literal`);return g(s,t,o.get(r.getText()),e)},A=i=>{const t=[];for(const o of i.getVariableDeclarations()){const e=o.getInitializer();if(e?.getKind()!==N.CallExpression)continue;const r=e,s=r.getExpression(),n=c.isIdentifier(s)?S(s):void 0;if(n===void 0)continue;const a=o.getNameNode();if(!c.isIdentifier(a)){if(o.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw d(a,`${n} exports must be plain named exports (no destructuring)`)}const u=x(o,"binding");u!==void 0&&t.push({call:r,exportName:u,factory:n,localName:a.getText()})}return t},Q=(i,t)=>{const o=A(i),e=new Map(o.filter(n=>n.factory==="defineTopic").map(n=>[n.localName,n.exportName])),r=[];for(const n of o)n.factory==="defineQueue"?r.push(P(n.call,n.exportName,t)):n.factory==="defineSubscription"&&r.push(T(n.call,n.exportName,e,t));const s=[...e.values()].map(n=>({exportName:n}));return{queues:r,topics:s}},L=i=>{const t=new Map,o=new Map;for(const e of i){const r=t.get(e.name);if(r!==void 0)throw new f("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${e.name}": produced by both "${r}" and "${e.exportName}". Deployed queue names must be unique across the project.`,{status:500});t.set(e.name,e.exportName);const s=o.get(e.bindingName);if(s!==void 0)throw new f("DUPLICATE_QUEUE_BINDING",`Duplicate queue binding "${e.bindingName}": produced by both "${s}" and "${e.exportName}". Queue export names must yield unique binding names.`,{status:500});o.set(e.bindingName,e.exportName)}},O=(i,t)=>{const o=h(t,E);if(!b(o))return{queues:[],topics:[]};const e=i.getSourceFile(o)??i.addSourceFileAtPath(o),{queues:r,topics:s}=Q(e,t),n=r.toSorted((a,u)=>a.exportName.localeCompare(u.exportName));return L(n),{queues:n,topics:s.toSorted((a,u)=>a.exportName.localeCompare(u.exportName))}},V=(i,t)=>O(i,t).queues;export{E as QUEUES_FILENAME,O as discoverQueueDeclarations,V as discoverQueues};
@@ -0,0 +1,11 @@
1
+ import{existsSync as T,mkdirSync as Qn,readFileSync as zs,writeFileSync as Xn,rmSync as Jn}from"node:fs";import{join as S,dirname as Ne}from"node:path";import{performance as Xe}from"node:perf_hooks";import{runAdvisor as Zn}from"@lunora/advisor";import{LunoraError as W}from"@lunora/errors";import{SyntaxKind as d,Node as i,Project as Qt}from"ts-morph";import{serializeSchemaSnapshot as er}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{toAdvisorContext as tr}from"./formatAdvisories-DwmUKYuc.mjs";import{readProjectConfigLiterals as sr}from"./loadProjectConfig-CuGQsqYS.mjs";import{a as Xt,d as nr,r as rr}from"./modules-CsA-QVJ6.mjs";import{QUEUES_FILENAME as ir,discoverQueueDeclarations as or}from"./QUEUES_FILENAME-16xcVWpo.mjs";import{WORKFLOWS_FILENAME as ar,discoverWorkflows as cr}from"./WORKFLOWS_FILENAME-Bcfd76Wf.mjs";import{r as lr}from"./json-data-Chfs2Cz5.mjs";import{s as Me}from"./paths-C-9fwEgQ.mjs";import{G as dr}from"./shared-BXUKWh7t.mjs";import{CAPABILITIES as ur,usedCapabilities as fr}from"./CAPABILITY_PROBES-DFsutD7g.mjs";import{isD1GlobalTable as Bs,isHyperdriveGlobalTable as $s}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as gr}from"./AGENTS_FILENAME-C-halsN9.mjs";import{discoverContainers as pr}from"./CONTAINERS_FILENAME-DY4sWZYx.mjs";import mr from"./discoverCrons-BqTY53L5.mjs";import{diagnosticAt as pe}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as _e}from"./module-specifiers-WF8iAydP.mjs";import{a as Us,b as V,d as K,f as R,g as Et,c as h,w as xt,k as hr,l as vr,h as Er,j as ot,i as xr}from"./attribution-JcwxPpyK.mjs";import{contextPropertiesRead as Sr,discoverFeatureUsage as yr}from"./capabilitiesUsedBy-CzqyN9dX.mjs";import Ar from"./readPackageDependencies-C6h6FZuP.mjs";import{listLunoraSourceFiles as E,propertyKeyName as y,unwrapExpression as v,listSecurityScanFiles as Ke,objectLiteralFromCallbackBody as Vs,propertyInitializer as P,lunoraRelativePath as w,bindingKeyName as me,collectCallRows as I,findObjectProperty as D,collectSecurityCallRows as br,collectNodeRows as at,RUN_METHODS as js,functionReferenceSegments as qs,limitNameOf as Ws,optionsObjectLiteral as Hs,handlerOf as Nr,chainRootOf as St,outermostValueWrapper as b,isWriteTarget as ze,isSameNode as ue,isConstDeclaration as Z,returningFunctionOf as ct,walkChain as Pr,memberAccessOf as wr}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{discoverSandboxUsage as Ir}from"./discoverSandboxUsage-Bjl8A_hj.mjs";import{resolveServiceBindings as Cr}from"./readServiceBindings-CnvEGOir.mjs";import Tr from"./discoverStorageRulesMetadata-C6sTEVS5.mjs";import{a as A,c as H,d as Gs,e as Or}from"./classify-procedure-call-OnJoKgqu.mjs";import{i as Rr}from"./ir-DBSvhNa-.mjs";import{gatePlatformFeatures as kr,resolveCodegenTarget as Ys,readTargetDiagnostics as Fr,studioPlatformFor as Dr}from"./DEFAULT_TARGET-7sHexLjO.mjs";import{b as Qs,e as Lr}from"./shard-WXSIZRpD.mjs";import Mr from"./emitServer-DymRagL2.mjs";import{emitDataModel as _r}from"./emitDataModel-DSk9AkJe.mjs";import{a as Jt,r as Je,i as $,b as Kr,m as Xs,c as Be,e as Js,E as Zs,C as en,d as zr,f as Br,g as $r}from"./context-root-Dlht00NP.mjs";import{r as $e,s as Ur}from"./parse-validator-B4mFs19C.mjs";import Vr from"./discoverAuthApiCalls-0t3X09mV.mjs";import{i as jr,a as qr,e as Wr,b as Hr,d as Gr,c as Yr}from"./unwrap-handler-return-D7E2TKkS.mjs";import Qr from"./discoverFunctions-B-hkqNPG.mjs";import Xr from"./discoverHttpRoutes-8f8UnwQk.mjs";import Jr from"./discoverHyperdriveCalls-BRbwJcK7.mjs";import Zr from"./discoverInserts-6RcjS-YR.mjs";import{m as yt,a as Te,s as tn,d as ei}from"./index-BxGykPbL.mjs";import{e as sn}from"./exported-procedure-chains-CKLvyjfX.mjs";import ti from"./discoverMigrations-De3uDJi0.mjs";import{i as _,r as nn}from"./database-calls-Br5z7dZL.mjs";import{MUTATORS_FILENAME as si,isDefineMutatorCallee as ni,mutatorServerImplOf as ri,discoverMutators as ii}from"./MUTATORS_FILENAME-CuG6xLJ1.mjs";import oi from"./discoverNondeterministicCalls-XHRCA4rr.mjs";import{discoverNotifyConfig as ai,discoverNotifyCalls as ci}from"./NOTIFY_FILENAME-C70ZrThq.mjs";import li from"./discoverQueries-B0vvHwFI.mjs";import di from"./discoverR2sqlCalls-BQ90jfu3.mjs";import ui from"./discoverRlsProcedures-Cy8-Q0AP.mjs";import fi from"./discoverRlsMetadata-BuGLdQWs.mjs";import gi from"./discoverSchema-Cd3iH6q5.mjs";import{secretKindOf as pi,redact as mi,isHeuristicSecretKind as hi,isSecretishName as vi}from"./redact-Cy14LEnc.mjs";import{discoverShapes as Ei}from"./SHAPES_FILENAME-e82UBLBE.mjs";import{i as xi}from"./reserved-words-CW1QFbTd.mjs";import{emitApp as Si}from"./emitApp-RNU41dtm.mjs";import{buildOpenApiDocument as yi,emitOpenApiModule as Ai}from"./buildOpenApiDocument-DOsv1HEF.mjs";import{buildOpenRpcDocument as bi,emitOpenRpcModule as Ni}from"./OPENRPC_VERSION-CGu1_YK7.mjs";import{buildSchemaSnapshot as Pi}from"./SchemaSnapshotParseError-CPOXlFhI.mjs";import{emitCollections as wi,emitSeed as Ii,emitApi as Ci}from"./emitApi-xDIHPRPH.mjs";import{t as Ti,u as Oi,s as Ri,v as ki}from"./shard-runtime-B1nU9CRa.mjs";import{emitCrons as Fi,emitScheduler as Di,emitShardRegistry as Li,emitVectors as Mi,emitWranglerCronTriggers as _i}from"./emitCrons-DsXsg1uG.mjs";import Ki from"./emitDrizzleSchema-DohtnI8c.mjs";import zi from"./emitFunctions-evl8Mx1a.mjs";const Zt={error:"ERROR",info:"INFO",warn:"WARN"},es={ERROR:2,INFO:0,WARN:1},Bi=e=>({cacheKey:"advisor_min_severity_invalid",categories:["SCHEMA"],description:"`advisor.minSeverity` in `lunora.config.*` sets the lowest advisory level codegen reports and writes into `_generated/shard.ts`. Codegen reads it by parsing the file, so it has to be a string literal.",detail:e,facing:"INTERNAL",level:"WARN",metadata:{},name:"advisor_min_severity_invalid",remediation:'Set `advisor: { minSeverity: "info" | "warn" | "error" }` as a literal on the config\'s default export.',title:"`advisor.minSeverity` is not a level codegen can read, so every advisory was reported"}),$i=(e,t)=>{const{advisor:s}=sr(e);if(s===void 0||s.minSeverity===void 0&&s.unreadable!==!0)return[...t];const{minSeverity:n}=s,r=n!==void 0&&Object.hasOwn(Zt,n)?Zt[n]:void 0;return r===void 0?[...t,Bi(n===void 0?"`advisor.minSeverity` is not a string literal codegen can read without evaluating the config: a computed value or key, or a spread that could set or override it.":`\`advisor.minSeverity\` is "${n}", which is not one of "info", "warn" or "error".`)]:t.filter(o=>es[o.level]>=es[r])},Ui={call:"function",enqueue:"queue",invoke:"service",publish:"topic",schedule:"function"},rn=ir.replace(/\.ts$/u,""),Vi="crons",ji=ar.replace(/\.ts$/u,""),ie=(e,t)=>`${Me(e)}:${t}`,Ze=(e,t,s)=>t===""?{reason:`the ${s} is not a string literal`}:{to:`${e}:${t}`},qi=e=>[...e.callEdges.map(t=>{const s=t.target===void 0?{reason:t.reason??"unreadable target"}:{to:`${Ui[t.kind]}:${t.target}`};return{file:t.file,kind:t.kind,line:t.line,scope:t.scope,...s}}),...e.queries.map(t=>({file:t.file,kind:"read",line:t.line,scope:t.scope,...Ze("table",t.table,"table name")})),...[...e.inserts,...e.tableWrites].map(t=>({file:t.file,kind:"write",line:t.line,scope:t.scope,...Ze("table",t.table,"written table")})),...e.workflowCalls.map(t=>({file:t.file,kind:"start",line:t.line,scope:t.scope,...Ze("workflow",t.workflow,"workflow name")}))],Wi=e=>e.untracked===!0?"inside a helper only code outside any export calls":"inside a non-exported helper",Hi=e=>{const{scope:t}=e;switch(t.kind){case"export":return[{...e,exportName:t.name}];case"helper":return t.callers.length===0?[{...e,unattributed:Wi(t)}]:t.callers.map(s=>({...e,exportName:s}));default:return[{...e,unattributed:"at module scope"}]}},Gi=e=>qi(e).flatMap(t=>Hi(t)),Yi=e=>[...e.queues.flatMap(t=>t.topic===void 0?[]:[{file:rn,from:`topic:${t.topic}`,kind:"subscribe",line:0,to:`queue:${t.exportName}`}]),...e.crons.map(t=>{const s=t.workflow===void 0?void 0:`workflow:${t.workflow.exportName}`,n=t.functionPath===void 0?void 0:`function:${t.functionPath}`,r=s??n;return{file:Vi,from:`cron:${t.name}`,kind:"trigger",line:0,...r===void 0?{reason:"the cron has no target"}:{to:r}}})],Qi=e=>new Map(e.flatMap(t=>t.tables.map(s=>[s,t.name]))),et=(e,t)=>t===void 0?e:{...e,module:t},Xi=e=>{const t=new Map,s=new Map,n=Qi(e.modules),r=(c,l)=>{s.set(c,[...s.get(c)??[],l])},o=(c,l)=>{t.set(c.id,c),l!==void 0&&r(l,c.id)},a=(c,l)=>{c!==void 0&&r(ie(c.file,c.exportName),l)};for(const c of e.functions){const l=ie(c.filePath,c.exportName),u=`${Me(c.filePath)}.${c.exportName}`;o(et({detail:c.kind,id:`function:${l}`,kind:"function",name:u},Xt(e.modules,c.filePath)),l)}for(const c of e.httpRoutes){const l=ie(c.filePath,c.exportName);o(et({id:`http:${l}`,kind:"http",name:`${c.method} ${c.path}`},Xt(e.modules,c.filePath)),l)}for(const c of e.schema.tables)o(et({id:`table:${c.name}`,kind:"table",name:c.name},n.get(c.name)));for(const c of e.queues){const l=c.topic===void 0?{}:{detail:"subscription"};o({...l,id:`queue:${c.exportName}`,kind:"queue",name:c.exportName},ie(rn,c.exportName)),a(c.handlerSite,`queue:${c.exportName}`)}for(const c of e.topics)o({id:`topic:${c.exportName}`,kind:"topic",name:c.exportName});for(const c of e.workflows)o({id:`workflow:${c.exportName}`,kind:"workflow",name:c.exportName},ie(ji,c.exportName)),a(c.handlerSite,`workflow:${c.exportName}`);for(const c of e.crons)o({detail:c.cron,id:`cron:${c.name}`,kind:"cron",name:c.name});for(const c of e.services){const l=c.rpcEntrypoint===void 0?"fetch":"rpc";o({detail:c.entrypoint===void 0?l:`${l} · ${c.entrypoint}`,id:`service:${c.name}`,kind:"service",name:c.worker})}return{nodes:t,sites:s}},Ji=e=>e==="default"?"the default export is not a registered function":`"${e}" is not a registered function`,Zi=(e,t)=>"from"in e?[e.from]:"unattributed"in e?{reason:e.unattributed}:t.get(ie(e.file,e.exportName))??{reason:Ji(e.exportName)},eo=(e,t,s)=>{if("reason"in e)return{reason:e.reason};const n=Zi(e,t);if("reason"in n)return n;const{to:r}=e;return s.has(r)?{drawn:n.map(o=>({from:o,kind:e.kind,to:r}))}:{reason:`${r} is not declared`}},tt=e=>`${e.from}|${e.kind}|${e.to}`,to=e=>`${e.file}|${String(e.line)}|${e.kind}|${e.reason}`,so=e=>{const{nodes:t,sites:s}=Xi(e),n=new Map,r=new Map;for(const o of[...Yi(e),...Gi(e)]){const a=eo(o,s,t);if("drawn"in a)for(const c of a.drawn)n.set(tt(c),c);else{const c={file:o.file,kind:o.kind,line:o.line,reason:a.reason};r.set(to(c),c)}}return{edges:[...n.values()].toSorted((o,a)=>tt(o).localeCompare(tt(a))),nodes:[...t.values()].toSorted((o,a)=>o.id.localeCompare(a.id)),modules:e.modules.map(o=>({...o.description===void 0?{}:{description:o.description},...o.installed===!0?{installed:!0}:{},...o.ownsFolder===!1?{ownsFolder:!1}:{},name:o.name,tables:[...o.tables]})),unresolved:[...r.values()].toSorted((o,a)=>o.file.localeCompare(a.file)||o.line-a.line),version:1}},no=e=>`${dr}export const architecture = ${lr(e,"Record<string, unknown>")};
2
+ `,ro=(e,t)=>{if(!(!t||e.jurisdiction!=="fedramp"))throw new W("CODEGEN_DIAGNOSTIC",'@lunora/codegen: the schema pins data to the "fedramp" jurisdiction, but this app uses Cloudflare Artifacts (`ctx.artifacts`), which supports only the "eu" and "us" jurisdictions. Repo data would be stored outside the declared residency. Remove the `ctx.artifacts` usage, or pin the schema to a jurisdiction Artifacts supports.')},ts=(e,t="api")=>{const s=new Map;for(const n of e){const r=Me(n),o=s.get(r);if(o===void 0){s.set(r,n);continue}if(o!==n){const a=t==="api"?`the generated api.ts would declare "${r}" twice and the dispatch key "${r}:<fn>" would be ambiguous`:`the generated api.ts would declare "${r}" twice in HttpStreamsRef and again in the httpStreams object literal`;throw new W("INTERNAL",`@lunora/codegen: "${o}" and "${n}" both map to the ${t} namespace "${r}" — ${a}. Rename one file so the two differ by more than a non-identifier character (\`-\`, \`.\`, \`/\` and \`_\` all sanitize to \`_\`).`,{status:500})}}},io=(e,t={})=>{const{hasVectors:s=!0,scheduler:n=!1,storage:r=!1,usage:o}=t,a=[];e.tables.some(c=>Bs(c))&&a.push({name:"@lunora/d1",reason:"`.global()` tables are D1-backed, so `_generated/app.ts` imports the D1 `ctx.db` adapter"}),e.tables.some(c=>$s(c))&&a.push({name:"@lunora/hyperdrive",reason:'`.global({ backend: "hyperdrive" })` tables route through `@lunora/hyperdrive/global`'},{name:"@lunora/sql-store",reason:'`.global({ backend: "hyperdrive" })` makes `_generated/app.ts` import the `SqlCtxDbOptions` / `SqlExec` types'}),n&&a.push({name:"@lunora/scheduler",reason:"a declared cron (or `ctx.scheduler` use) makes `_generated/app.ts` import `createScheduler`"}),r&&a.push({name:"@lunora/storage",reason:"a `v.storage()` column, a storage access rule (or `ctx.storage` use) makes `_generated/app.ts` import `createStorage`"}),e.vectorIndexes.length>0&&s&&a.push({name:"@lunora/bindings",reason:"`.vectorize()` indexes make `_generated/shard.ts` import `@lunora/bindings/vectors`"});for(const c of o===void 0?[]:ur)c.requiredPackage!==void 0&&o?.[c.key]===!0&&a.push({name:c.requiredPackage,reason:`\`ctx.${c.contextProperty??c.key}\` usage makes \`_generated/\` import \`${c.moduleSpecifier}\``});return a.filter((c,l)=>a.findIndex(u=>u.name===c.name)===l)},oo=(e,t,s={})=>{if(t===void 0)return;const n=io(e,s).filter(o=>!t.has(o.name));if(n.length===0)return;const r=n.map(o=>` - ${o.name} — ${o.reason}`).join(`
3
+ `);throw new W("INTERNAL",`@lunora/codegen: this schema's generated code imports packages the project does not declare:
4
+ ${r}
5
+
6
+ Install them with your package manager, then re-run codegen.`)},ao="env.ts",co=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineEnv";for(const s of t.getDeclarations())if(i.isImportSpecifier(s))return _e(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineEnv":!1;return!1},lo=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!i.isNamespaceImport(s))continue;const n=s.getFirstAncestorByKind(d.ImportDeclaration);return n!==void 0&&_e(n.getModuleSpecifierValue())}return!1},uo=e=>{if(i.isIdentifier(e))return co(e);if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineEnv"&&i.isIdentifier(t)&&lo(t)}return!1},fo=e=>{const t=[];for(const s of e.getVariableDeclarations()){const n=s.getInitializer();if(n?.getKind()!==d.CallExpression||!uo(n.getExpression()))continue;const o=s.getNameNode();if(!i.isIdentifier(o)){if(s.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw pe(o,"defineEnv exports must be plain named exports (no destructuring)")}const a=Us(s,"member");a!==void 0&&t.push({exportName:a})}return t},go=(e,t)=>{const s=S(t,ao);if(!T(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),r=fo(n);if(r.length!==0){if(r.length>1)throw pe(n,`lunora/env.ts declares ${r.length.toString()} defineEnv() contracts (${r.map(o=>o.exportName).join(", ")}); exactly one is allowed`);return r[0]}},on="identity.ts",po=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineIdentity";for(const s of t.getDeclarations())if(i.isImportSpecifier(s))return _e(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineIdentity":!1;return!1},mo=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!i.isNamespaceImport(s))continue;const n=s.getFirstAncestorByKind(d.ImportDeclaration);return n!==void 0&&_e(n.getModuleSpecifierValue())}return!1},ho=e=>{if(i.isIdentifier(e))return po(e);if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineIdentity"&&i.isIdentifier(t)&&mo(t)}return!1},vo=e=>{const t=[];for(const s of e.getVariableDeclarations()){const n=s.getInitializer();if(n?.getKind()!==d.CallExpression||!ho(n.getExpression()))continue;const o=s.getNameNode();if(!i.isIdentifier(o)){if(s.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw pe(o,"defineIdentity exports must be plain named exports (no destructuring)")}const a=Us(s,"member");a!==void 0&&t.push({exportName:a})}return t},Eo=(e,t)=>{const s=S(t,on);if(!T(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),r=vo(n);if(r.length!==0){if(r.length>1)throw pe(n,`lunora/identity.ts declares ${r.length.toString()} defineIdentity() contracts (${r.map(o=>o.exportName).join(", ")}); exactly one is allowed`);return r[0]}},xo=new Set(["allowedHosts","deniedHosts","interceptHttps"]),So=(e,t)=>{const s=v(t);if(s===void 0||!i.isIdentifier(s))return s;const n=s.getText();return v(e.getDescendantsOfKind(d.VariableDeclaration).find(r=>r.getName()===n)?.getInitializer())},yo=(e,t)=>e!==void 0&&i.isObjectLiteralExpression(e)&&e.getProperties().some(s=>{if(i.isShorthandPropertyAssignment(s))return t.has(y(s));if(!i.isPropertyAssignment(s)||!t.has(y(s)))return!1;const n=v(s.getInitializer())?.getText();return n!=="false"&&n!=="undefined"}),Ao=new Set(["durable"]),bo=new Set(["rollback"]),No=e=>{const t=e.getExpression();return i.isPropertyAccessExpression(t)?t.getName():t.getText()},Po=new Map([["defineContainer",{keys:xo,signal:"containerEgressPolicy"}],["defineStep",{keys:bo,signal:"workflowRollback"}],["stream",{keys:Ao,signal:"durableStreams"}]]),wo=(e,t)=>{const s=Po.get(No(t));if(s!==void 0)return t.getArguments().some(n=>yo(So(e,n),s.keys))?s.signal:void 0},Io=(e,t)=>{const s={containerEgressPolicy:!1,durableStreams:!1,secrets:!1,workflowRollback:!1};for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.secrets||(s.secrets=Sr(r).has("secrets"));for(const o of r.getDescendantsOfKind(d.CallExpression)){const a=wo(r,o);a!==void 0&&(s[a]=!0)}if(Object.values(s).every(Boolean))break}return s},Co="createWorker",To="extend",ss=e=>e!==void 0&&(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))?e.getLiteralValue():void 0,ns=e=>{const t=[],s=ss(P(e,"backupCron"));s!==void 0&&t.push(s);const n=P(e,"crons");if(n===void 0||!i.isObjectLiteralExpression(n))return t;for(const r of n.getProperties()){if(!i.isPropertyAssignment(r)&&!i.isMethodDeclaration(r))continue;const o=ss(r.getNameNode());o!==void 0&&t.push(o)}return t},Oo=e=>{const t=A(e.getExpression()),[s]=e.getArguments();if(s===void 0)return[];if(t===Co)return i.isObjectLiteralExpression(s)?ns(s):[];if(t!==To||!(i.isArrowFunction(s)||i.isFunctionExpression(s)))return[];const n=Vs(s.getBody());return n===void 0?[]:ns(n)},Ro=(e,t)=>{const s=[];for(const{filePath:n}of Ke(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const o of r.getDescendantsOfKind(d.CallExpression))s.push(...Oo(o))}return[...new Set(s)]},an=e=>{if(e.kind==="id")return e.tableName;if(!(e.kind!=="array"&&e.kind!=="optional"))return e.inner===void 0?void 0:an(e.inner)},ko=e=>{const t=new Set(e.tables.map(s=>s.name));return e.tables.some(s=>Object.values(s.shape).some(n=>{const r=an(n);return r!==void 0&&t.has(r)}))},Fo=(e,t)=>{const s=new Map,n=new Map;for(const r of e)s.set(r.name,`workflow "${r.exportName}"`),n.set(r.className,`workflow "${r.exportName}"`);for(const r of t){const o=s.get(r.name);if(o!==void 0)throw new W("DUPLICATE_WORKFLOW_NAME",`Duplicate deployed name "${r.name}": produced by both ${o} and agent "${r.exportName}". Workflow and agent names share one account-wide namespace and must be unique together.`,{status:500});const a=n.get(r.className);if(a!==void 0)throw new W("DUPLICATE_WORKFLOW_CLASS",`Duplicate generated class "${r.className}": produced by both ${a} and agent "${r.exportName}". Workflow and agent export names must yield unique generated class names.`,{status:500})}},Do=e=>{const{lunoraDirectory:t,project:s,projectRoot:n,schema:r}=e,o=Eo(s,t),a=go(s,t),c=cr(s,t),{queues:l,topics:u}=or(s,t),p=Cr(n),f=gr(s,t);Fo(c,f);const m=pr(s,t),x=Tr(s,t),z=mr(s,t,c,f),B=Ro(s,t),N=Io(s,t),k=Ir(s,t),j=yr(s,t);j.browser=j.browser||k.usesSandboxBrowser;const G=kr(j,Ys(n,e.target),{agents:f.length>0,commitOrderedTables:r.tables.some(O=>O.commitOrdered===!0),cronTriggers:z.length>0,crossShardFanout:r.tables.some(O=>Rr(O)),containerEgressPolicy:N.containerEgressPolicy,containerRuntimeScheduling:m.some(O=>O.schedulingPolicy==="durable_object"),containerSandboxTools:m.some(O=>O.sandbox===!0),durableStreams:N.durableStreams,globalTables:r.tables.some(O=>O.shardMode==="global"),queues:l.length>0,relationGraph:ko(r),secrets:N.secrets,services:p.length>0,topics:u.length>0,vectorStore:r.vectorIndexes.length>0,workerLoaders:k.usesSandboxLoader,workflowRollback:N.workflowRollback,workflowSchedules:c.some(O=>O.schedules!==void 0)}),F=G.usage,te=fr(F),oe=G.signals.vectorStore!==!1,ae=G.signals.services===!1?[]:p,se=Ar(n),he=se??new Set,q=he.has("lunorash");oo(r,se,{hasVectors:oe,scheduler:F.scheduler||z.length>0,storage:F.storage||x.rules.length>0||Object.keys(Qs(r)).length>0,usage:F});const L=T(S(t,"flags.ts")),M=T(S(t,"notify.ts"));return{agents:f,capabilities:te,containers:m,crons:z,dataModelContent:_r(r),declaredDependencies:se,dependencies:he,entryCronTriggers:B,env:a,featureUsage:F,hasFlags:L,hasNotify:M,identity:o,platformGate:{...G,diagnostics:[...Fr(n,e.target),...G.diagnostics]},queues:l,serverContent:Mr({agents:f,capabilities:te,containers:m,env:a,hasVectors:oe,hasFlags:L,hasNotify:M,identity:o,queues:l,schema:r,generatedDirectory:S(t,"_generated"),services:ae,storageRuleBuckets:x.rules.map(O=>O.bucket),topics:u,useUmbrella:q,workflows:c}),services:ae,storageRulesMetadata:x,topics:u,usesSandbox:k.usesSandboxBrowser||k.usesSandboxContainer||k.usesSandboxFs,useUmbrella:q,workflows:c}},cn=new Set(["delete","get","head","options","patch","post","put"]),Lo=new Set(["handler","stream"]),Mo=/\/(?:_|admin|internal|superuser|sudo|root|debug)/iu,rs=new Set(["ADMIN_TOKEN","adminToken","assertAdmin","assertAuth","auth","Authorization","getSession","identity","isAdmin","requireAdmin","requireAuth","requireRole","verifyAdmin"]),_o=e=>{if(!i.isCallExpression(e))return;const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!cn.has(t.getName()))return;const s=t.getExpression();if(!i.isIdentifier(s)||s.getText()!=="httpRoute")return;const n=e.getArguments()[0];if(!(!n||!i.isStringLiteral(n)))return{method:t.getName().toUpperCase(),path:n.getLiteralValue()}},Ko=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;let s=t.getExpression();for(;i.isCallExpression(s);){const n=s.getExpression();if(!i.isPropertyAccessExpression(n)||cn.has(n.getName()))break;s=n.getExpression()}return _o(s)},zo=e=>{for(const t of e.getDescendantsOfKind(d.PropertyAccessExpression))if(rs.has(t.getName()))return!0;for(const t of e.getDescendantsOfKind(d.CallExpression)){const s=t.getExpression();if(i.isIdentifier(s)&&rs.has(s.getText()))return!0}return!1},Bo=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const n=s.getExpression();if(!i.isPropertyAccessExpression(n)||!Lo.has(n.getName()))return;const r=Ko(s);if(!r||!Mo.test(r.path))return;const o=s.getArguments()[0],a=o!==void 0&&(i.isArrowFunction(o)||i.isFunctionExpression(o))&&zo(o);return{exportName:K(e)??e.getName(),file:t,method:r.method,path:r.path,usesGuard:a}},$o=(e,t)=>{const s=[];for(const n of V(e)){const r=Bo(n,t);r&&s.push(r)}return s},Uo=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...$o(r,w(t,n)))}return s},Vo=e=>{const t=e.getText(),s=n=>{const r=n.getNameNode();return i.isIdentifier(r)&&r.getText()===t};for(const n of e.getAncestors())if(!(!i.isArrowFunction(n)&&!i.isFunctionExpression(n)&&!i.isFunctionDeclaration(n)))for(const r of n.getParameters()){const o=r.getDescendantsOfKind(d.BindingElement).find(a=>s(a));if(o!==void 0)return o}},jo=e=>{let t=e;for(;;){const s=t.getParent();if(!i.isObjectBindingPattern(s))return;const n=s.getParent();if(i.isBindingElement(n)){t=n;continue}return i.isParameterDeclaration(n)?me(t):void 0}},qo=e=>{const t=e.getText();if(!e.getAncestors().some(o=>{const a=i.isFunctionLikeDeclaration(o)||i.isArrowFunction(o)?o.getParameters()[1]:void 0,c=a?.getNameNode();return a!==void 0&&(i.isIdentifier(c)?c.getText()===t:a.getDescendantsOfKind(d.BindingElement).some(l=>l.getName()===t))&&Jt(a)}))return!1;const n=R(e),r=i.isParameterDeclaration(n)?n:n?.getFirstAncestorByKind(d.Parameter);return r!==void 0&&(i.isParameterDeclaration(n)||i.isBindingElement(n))&&Jt(r)},is=(e,t)=>{const s=e.getParent();if(i.isPropertyAccessExpression(s)&&s.getNameNode()===e||i.isPropertyAssignment(s)&&s.getNameNode()===e)return!1;if(e.getText()===t)return!0;const n=Vo(e);return n!==void 0&&jo(n)===t?!0:t==="args"&&qo(e)},ln=(e,t)=>i.isIdentifier(e)?is(e,t):e.getDescendantsOfKind(d.Identifier).some(s=>is(s,t)),Wo=e=>{let t=e;for(;i.isPropertyAccessExpression(t)||i.isElementAccessExpression(t)||i.isNonNullExpression(t);)t=t.getExpression();return i.isIdentifier(t)?t:void 0},os=e=>{const t=i.isIdentifier(e)?R(e):void 0;return i.isVariableDeclaration(t)&&i.isIdentifier(t.getNameNode())&&!Et(t)?t.getInitializer():void 0},lt=e=>ln(e,"args"),Q=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 n=e.getStart();let r,o=-1;for(const a of s.getDescendantsOfKind(d.VariableDeclaration)){if(a.getName()!==t)continue;const c=a.getInitializer(),l=a.getStart();c!==void 0&&l<n&&l>o&&(r=c,o=l)}return r},U=e=>{if(lt(e))return!0;const t=Q(e);return t!==void 0&&lt(t)},Ho=e=>{if(i.isCallExpression(e)||i.isNewExpression(e))return!1;const t=Q(e);return t===void 0||!(i.isCallExpression(t)||i.isNewExpression(t))},ee=e=>{if(Je(e))return!0;const t=os(e);if(t!==void 0&&Je(t))return!0;const s=t??e;return(i.isIdentifier(s)?[s]:s.getDescendantsOfKind(d.Identifier)).some(r=>{const o=os(r);return o!==void 0&&Je(o)})},Pe=(e,t)=>ln(e,t),Go=(e,t)=>{if(Pe(e,t))return!0;const s=Q(e);if(s!==void 0&&Pe(s,t))return!0;const n=Wo(e);if(n!==void 0){const r=Q(n);return r!==void 0&&Pe(r,t)}return!1},Yo=e=>!i.isPropertyAccessExpression(e)||e.getName()!=="run"?!1:$(e.getExpression(),["ai"]),Qo=(e,t)=>{if(!Yo(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!U(s)||ee(s)))return{scope:h(e),file:t,line:e.getStartLineNumber()}},Xo=(e,t)=>I(e,t,Qo),Jo=new Set(["generateText","streamText"]),Zo=new Set(["messages","prompt","system"]),ea=[{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"]}],ta=(e,t)=>ea.some(s=>s.methods.has(t)&&s.prefixes.some(n=>e===n||e.startsWith(`${n}.`))),sa=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;const s=t.getName(),n=[Kr(t.getExpression()),t.getExpression().getText()].find(r=>r!==void 0&&ta(r,s));return n===void 0?void 0:`${n}.${s}`},na=e=>{for(const t of e.getDescendantsOfKind(d.CallExpression)){const s=sa(t);if(s!==void 0)return s}},ra=e=>{const t=new Set,s=e.getFirstAncestor(o=>i.isArrowFunction(o)||i.isFunctionExpression(o)||i.isFunctionDeclaration(o)),[n]=s?.getParameters()??[],r=n?.getNameNode();if(r===void 0||!i.isObjectBindingPattern(r))return t;for(const o of r.getElements()){const a=me(o),c=o.getNameNode();if(a==="args"&&i.isObjectBindingPattern(c))for(const l of c.getElements())t.add(l.getName())}return t},ia=e=>{if(lt(e))return!0;const t=ra(e);return t.size===0?!1:e.getDescendantsOfKind(d.Identifier).some(s=>t.has(s.getText()))},oa=e=>{for(const t of e.getProperties()){if(!i.isPropertyAssignment(t)||!Zo.has(y(t)))continue;const s=t.getInitializer();if(s!==void 0&&ia(s))return!0}return!1},aa=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression)){const r=A(n.getExpression());if(r===void 0||!Jo.has(r))continue;const[o]=n.getArguments();if(o===void 0||!i.isObjectLiteralExpression(o))continue;let a;for(const c of o.getDescendantsOfKind(d.CallExpression))if(A(c.getExpression())==="tool"&&(a=na(c),a!==void 0))break;a!==void 0&&s.push({scope:h(n),file:t,line:n.getStartLineNumber(),method:r,sideEffect:a,userInputDerived:oa(o)})}return s},ca=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...aa(r,w(t,n)))}return s},la=e=>$(e,["fetch"]),da=(e,t)=>{if(!la(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!U(s)))return{scope:h(e),file:t,line:e.getStartLineNumber()}},ua=(e,t)=>I(e,t,da),At=(e,t=new Set)=>{if(t.has(e))return!0;t.add(e);try{return e.getProperties().some(s=>{if(!i.isSpreadAssignment(s))return!1;const n=$e(s.getExpression());return n===void 0||At(n,t)})}finally{t.delete(e)}},fa=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return{objects:[],opaque:!0};const s=D(t,"args");if(!s)return{objects:[],opaque:!1};if(!i.isPropertyAssignment(s))return{objects:[],opaque:!0};const n=s.getInitializer(),r=n===void 0?void 0:$e(n);return r===void 0?{objects:[],opaque:!0}:{objects:[r],opaque:At(r)}},ga=e=>{const t=[];let s=!1,n=e;for(;i.isCallExpression(n);){const r=n.getExpression();if(!i.isPropertyAccessExpression(r))break;if(r.getName()==="input"){const o=n.getArguments()[0],a=o!==void 0&&i.isExpression(o)?$e(o):void 0;a===void 0?s=!0:(t.push(a),s||=At(a))}n=r.getExpression()}return{objects:t,opaque:s}},bt=(e,t)=>t?ga(t):fa(e),dn=(e,t)=>{if(t.has(e))return[];t.add(e);try{return e.getProperties().flatMap(s=>{if(i.isSpreadAssignment(s)){const n=$e(s.getExpression());return n===void 0?[]:dn(n,t)}return i.isPropertyAssignment(s)||i.isShorthandPropertyAssignment(s)?[y(s)]:[]})}finally{t.delete(e)}},pa=e=>e.flatMap(t=>dn(t,new Set)),ma=new Set(["check","length","max"]),dt=e=>{if(!i.isCallExpression(e))return;const t=e.getExpression();if(!(!i.isPropertyAccessExpression(t)||t.getExpression().getText()!=="v"))return t.getName()},ha=e=>[e,...e.getDescendants()].filter(t=>dt(t)!==void 0),va=e=>{let t=e;for(;;){const s=t.getParent();if(!s||!i.isPropertyAccessExpression(s)||s.getExpression()!==t)return!1;const n=s.getParent();if(!n||!i.isCallExpression(n)||n.getExpression()!==s)return!1;if(ma.has(s.getName()))return!0;t=n}},Ea=e=>{const t=[],s=[];for(const n of e)for(const r of n.getProperties()){if(!i.isPropertyAssignment(r))continue;const o=r.getInitializer();if(!o)continue;const a=ha(o),c=y(r);a.some(l=>dt(l)==="any")?t.push(c):a.some(l=>dt(l)==="string"&&!va(l))&&s.push(c)}return{anyArgs:t,unboundedStringArgs:s}},xa=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const n=H(s);if(n?.visibility!=="public")return;const{objects:r}=bt(s,n.receiver),{anyArgs:o,unboundedStringArgs:a}=Ea(r);if(!(o.length===0&&a.length===0))return{anyArgs:o,exportName:K(e)??e.getName(),file:t,line:s.getStartLineNumber(),unboundedStringArgs:a}},Sa=(e,t)=>{const s=[];for(const n of V(e)){const r=xa(n,t);r&&s.push(r)}return s},ya=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Sa(r,w(t,n)))}return s},st=e=>e?.getKind()===d.TrueKeyword,Aa=e=>e?.getKind()===d.FalseKeyword,ba=e=>e!==void 0&&i.isNumericLiteral(e)&&e.getLiteralValue()===0,Na=new Set(["lunoraAuthAdapter","lunoraD1Adapter"]),Pa=e=>!e||!i.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>i.isCallExpression(t)&&A(t.getExpression())==="scim"),wa=e=>e!==void 0&&i.isCallExpression(e)&&Na.has(A(e.getExpression())??""),Ia=e=>!e||!i.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>i.isStringLiteral(t)&&t.getLiteralText()==="*"),Ca=e=>{const t=P(e,"advanced"),s=P(e,"emailAndPassword"),n=P(e,"session");return{analyzable:!0,disableCsrfCheck:st(P(t,"disableCSRFCheck")),emailPasswordEnabled:st(P(s,"enabled")),requireEmailVerification:st(P(s,"requireEmailVerification")),scimOnNonTransactionalAdapter:Pa(P(e,"plugins"))&&wa(P(e,"database")),secureCookiesDisabled:Aa(P(t,"useSecureCookies")),sessionFreshAgeZero:ba(P(n,"freshAge")),trustedOriginsWildcard:Ia(P(e,"trustedOrigins"))}},Ta=()=>({analyzable:!1,disableCsrfCheck:!1,emailPasswordEnabled:!1,requireEmailVerification:!1,scimOnNonTransactionalAdapter:!1,secureCookiesDisabled:!1,sessionFreshAgeZero:!1,trustedOriginsWildcard:!1}),Oa=(e,t)=>{if(A(e.getExpression())!=="createAuth")return;const s=e.getArguments()[0],n=s!==void 0&&i.isObjectLiteralExpression(s)&&s.getProperties().some(o=>i.isSpreadAssignment(o)),r=s!==void 0&&i.isObjectLiteralExpression(s)&&!n?Ca(s):Ta();return{scope:h(e),file:t,line:e.getStartLineNumber(),...r}},Ra=(e,t)=>br(e,t,Oa),ka=(e,t)=>{if(!i.isPropertyAccessExpression(e))return;const s=e.getName();if(t.methods.has(s))return Xs(e.getExpression(),t.matchReceiver)?s:void 0},Fa=(e,t,s)=>{const n=ka(e.getExpression(),s);if(n===void 0)return;const r=e.getArguments()[s.argIndex];if(!(!r||!U(r)||ee(r))&&!(s.requireUnmodifiedReach===!0&&!Ho(r)))return{scope:h(e),file:t,line:e.getStartLineNumber(),method:n}},Ue=(e,t,s)=>I(e,t,(n,r)=>Fa(n,r,s)),Da=new Set(["content","pdf","scrape","screenshot"]),La=(e,t)=>Ue(e,t,{argIndex:0,matchReceiver:s=>s==="ctx.browser",methods:Da}),un=e=>{const t=qs(e);return t===void 0?void 0:`${Me(t.slice(0,-1).join("/"))}:${String(t.at(-1))}`},fn=(e,t)=>{if(!i.isPropertyAccessExpression(e))return;const s=e.getExpression();if(!i.isPropertyAccessExpression(s))return;const n=s.getExpression();return i.isPropertyAccessExpression(n)&&n.getName()===t?s.getName():void 0},Ma=e=>{if(!i.isPropertyAccessExpression(e))return!1;const t=e.getExpression();return i.isPropertyAccessExpression(t)&&t.getName()==="scheduler"||i.isIdentifier(t)&&t.getText()==="scheduler"},_a=new Map([["publish",{kind:"publish",surface:"topics"}],["publishBatch",{kind:"publish",surface:"topics"}],["send",{kind:"enqueue",surface:"queues"}],["sendBatch",{kind:"enqueue",surface:"queues"}]]),Ka=(e,t)=>{const s=un(t);return s!==void 0?{kind:"call",target:s}:e!=="run"&&t!==void 0?{kind:"call",reason:"the function reference is not a static api.* / internal.* chain"}:void 0},za=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;const s=t.getName(),[n,r]=e.getArguments();if(js.has(s))return Ka(s,n);if((s==="runAfter"||s==="runAt")&&Ma(t)){const c=un(r);return c===void 0?{kind:"schedule",reason:"the scheduled function is not a static api.* / internal.* chain"}:{kind:"schedule",target:c}}const o=_a.get(s),a=o===void 0?void 0:fn(t,o.surface);return o===void 0||a===void 0?void 0:{kind:o.kind,target:a}},as=(e,t,s)=>s===void 0?void 0:{...s,file:t,line:e.getStartLineNumber(),scope:h(e)},Ba=(e,t)=>[...I(e,t,(s,n)=>as(s,n,za(s))),...at(e,t,d.PropertyAccessExpression,(s,n)=>{const r=fn(s,"services");return as(s,n,r===void 0?void 0:{kind:"invoke",target:r})})],$a=new Set(["createBrowser","createInboundEmailHandler","createPayment"]),Ua=new Set(["RateLimiter"]),Va=new Set(["extend"]),cs="lunora",ja=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],gn=e=>{const t=[],s=[];let n=!1;for(const r of e.getProperties()){if(i.isSpreadAssignment(r)){n=!0;continue}if(i.isPropertyAssignment(r)){const o=y(r);t.push(o),r.getInitializer()?.getKind()===d.TrueKeyword&&s.push(o);continue}(i.isShorthandPropertyAssignment(r)||i.isMethodDeclaration(r))&&t.push(y(r))}return{analyzable:!n,presentKeys:t,trueKeys:s}},ut=e=>e&&i.isObjectLiteralExpression(e)?gn(e):{analyzable:!1,presentKeys:[],trueKeys:[]},qa=e=>{const t=e&&(i.isArrowFunction(e)||i.isFunctionExpression(e))?e:void 0,s=t&&Vs(t.getBody());return s?gn(s):{analyzable:!1,presentKeys:[],trueKeys:[]}},Wa=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression)){const r=A(n.getExpression());r!==void 0&&($a.has(r)?s.push({callee:r,file:t,line:n.getStartLineNumber(),...ut(n.getArguments()[0])}):Va.has(r)&&s.push({callee:r,file:t,line:n.getStartLineNumber(),...qa(n.getArguments()[0])}))}for(const n of e.getDescendantsOfKind(d.NewExpression)){const r=A(n.getExpression());r===void 0||!Ua.has(r)||s.push({callee:r,file:t,line:n.getStartLineNumber(),...ut(n.getArguments()[0])})}return s},Ha=(e,t)=>{for(const s of ja){const n=S(t,s);if(!T(n))continue;const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=[];for(const a of r.getDescendantsOfKind(d.CallExpression))A(a.getExpression())===cs&&o.push({callee:cs,file:s,line:a.getStartLineNumber(),...ut(a.getArguments()[0])});return o}return[]},Ga=(e,t)=>{const s=[];for(const{displayPath:n,filePath:r}of Ke(t)){const o=e.getSourceFile(r)??e.addSourceFileAtPath(r);s.push(...Wa(o,n))}return s.push(...Ha(e,Ne(t))),s},ls="ctx.containers.",Ya=e=>{if(!e.startsWith(ls))return!1;const t=e.slice(ls.length);return t.length>0&&!t.includes(".")},Qa=(e,t)=>Ue(e,t,{argIndex:0,matchReceiver:Ya,methods:new Set(["get"])}),Xa=new Set(["allow","deny","setAllowed"]),Ja=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return!1;const s=D(t,"enableInternet");return s!==void 0&&i.isPropertyAssignment(s)&&i.isTrueLiteral(s.getInitializerOrThrow())},Za=(e,t)=>{const s=e.getExpression();if(!(!i.isPropertyAccessExpression(s)||s.getName()!=="start"||!Ja(e)))return{detail:"enableInternet: true",scope:h(e),file:t,kind:"enable_internet",line:e.getStartLineNumber()}},ec=(e,t)=>{const s=e.getExpression();if(!i.isPropertyAccessExpression(s)||!Xa.has(s.getName()))return;const n=s.getExpression();if(!(!i.isPropertyAccessExpression(n)||n.getName()!=="egress"))return{detail:s.getName(),scope:h(e),file:t,kind:"egress_relaxation",line:e.getStartLineNumber()}},tc=(e,t)=>Za(e,t)??ec(e,t),sc=(e,t)=>I(e,t,tc),nc=new Set(["defineExportSink","r2Sink","webhookExportSink"]),rc=e=>{const t=e.getExpression();if(!i.isIdentifier(t))return;const s=t.getText();return nc.has(s)?s:void 0},ic=e=>{const t=[],s=[];for(const n of e.getProperties()){if(i.isSpreadAssignment(n))return{analyzable:!1,emptyKeys:[],presentKeys:[]};if(i.isPropertyAssignment(n)){const r=y(n);t.push(r);const o=n.getInitializer();o&&i.isStringLiteral(o)&&o.getLiteralText()===""&&s.push(r);continue}(i.isShorthandPropertyAssignment(n)||i.isMethodDeclaration(n)||i.isGetAccessorDeclaration(n))&&t.push(y(n))}return{analyzable:!0,emptyKeys:s,presentKeys:t}},oc=(e,t)=>{const s=[];for(const{displayPath:n,filePath:r}of Ke(t)){const o=e.getSourceFile(r)??e.addSourceFileAtPath(r);for(const a of o.getDescendantsOfKind(d.CallExpression)){const c=rc(a);if(c===void 0)continue;const l=a.getArguments()[0],u=l&&i.isObjectLiteralExpression(l)?ic(l):{analyzable:!1,emptyKeys:[],presentKeys:[]};s.push({analyzable:u.analyzable,emptyKeys:u.emptyKeys,factory:c,file:n,line:a.getStartLineNumber(),presentKeys:u.presentKeys})}}return s},ac=new Map([["dbRateLimit",2],["rateLimit",2],["verifyTurnstileMiddleware",0]]),cc=new Set(["dbRateLimit","rateLimit"]),lc=e=>{const t=Hs(e);if(!t)return!1;const s=D(t,"failOpen");return s!==void 0&&i.isPropertyAssignment(s)&&s.getInitializer()?.getKind()===d.TrueKeyword},dc=(e,t)=>{const s=A(e.getExpression());if(s===void 0)return;const n=ac.get(s);if(n!==void 0)return{callee:s,scope:h(e),failOpen:lc(e.getArguments()[n]),file:t,limitName:cc.has(s)?Ws(e):"",line:e.getStartLineNumber()}},uc=(e,t)=>I(e,t,dc),fc=new Set(["boolean","number","object","string"]),gc=e=>{const t=e.getName();if(!fc.has(t))return;const s=e.getExpression();return $(s,["flags"])||$(s,["flags","details"])?t:void 0},pc=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;const s=gc(t);if(s===void 0)return;const n=e.getArguments()[0];if(!n||!(i.isStringLiteral(n)||i.isNoSubstitutionTemplateLiteral(n)))return;const r=n.getLiteralValue();return r.length>0?{key:r,type:s}:void 0},mc=(e,t)=>{const s=new Map;for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const o of r.getDescendantsOfKind(d.CallExpression)){const a=pc(o);a&&!s.has(a.key)&&s.set(a.key,a.type)}}return[...s.entries()].map(([n,r])=>({key:n,type:r})).toSorted((n,r)=>n.key.localeCompare(r.key))},hc=e=>{const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const s=H(t);if(s?.kind!=="query")return;const n=Nr(t,s.receiver);return n?{exportName:K(e)??e.getName(),handler:n}:void 0},ds=e=>{const t=e.getParent();return t&&i.isPropertyAccessExpression(t)&&t.getExpression()===e?t:void 0},vc=e=>{const t=ds(e);if(!t)return"ctx.flags";if(t.getName()==="details"){const s=ds(t);return s?`ctx.flags.details.${s.getName()}`:"ctx.flags.details"}return`ctx.flags.${t.getName()}`},Ec=(e,t)=>{const s=[];for(const n of Be(e.handler,"flags"))s.push({callee:vc(n),exportName:e.exportName,file:t,line:n.getStartLineNumber()});return s},xc=(e,t)=>{const s=[];for(const n of V(e)){const r=hc(n);r&&s.push(...Ec(r,t))}return s},Sc=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...xc(r,w(t,n)))}return s},yc=e=>!i.isPropertyAccessExpression(e)||e.getName()!=="boolean"?!1:$(e.getExpression(),["flags"]),Ac=e=>{if(e?.getKind()===d.TrueKeyword)return!0;if(e?.getKind()===d.FalseKeyword)return!1},bc=(e,t)=>{if(!yc(e.getExpression()))return;const[s,n]=e.getArguments();if(!s||!(i.isStringLiteral(s)||i.isNoSubstitutionTemplateLiteral(s)))return;const r=s.getLiteralValue(),o=Ac(n);if(!(r.length===0||o===void 0))return{defaultValue:o,scope:h(e),file:t,key:r,line:e.getStartLineNumber()}},Nc=(e,t)=>I(e,t,bc),Pc=e=>{const t=e.getType().getProperty("~standard");if(!t)return;const s=t.getTypeAtLocation(e).getProperty("types");if(!s)return;const n=s.getTypeAtLocation(e).getNonNullableType().getProperty("output");if(!n)return;const r=n.getTypeAtLocation(e),o=r.getText(e);if(!o||o==="any"||o==="never"||jr(o))return;const a=e.getSourceFile().getFilePath();if(qr(r,e,a)){const c=Wr(r,e,a,0,new Set);return c===void 0&&Hr(o),c}return o},wc=e=>{const t=e.getExpression();return i.isPropertyAccessExpression(t)&&t.getName()==="withGeoIndex"},Ic=e=>{const t=e.getArguments()[0];return t&&i.isStringLiteral(t)?t.getLiteralText():""},Cc=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of r.getDescendantsOfKind(d.CallExpression))wc(a)&&s.push({file:o,indexName:Ic(a),line:a.getStartLineNumber()})}return s},fe=e=>e!==void 0&&(i.isArrowFunction(e)||i.isFunctionExpression(e))?e:void 0,pn=e=>{const t=e.getArguments()[0],s=fe(t);if(s!==void 0)return s;if(t===void 0||!i.isObjectLiteralExpression(t))return;const n=D(t,"handler");return n!==void 0&&i.isPropertyAssignment(n)?fe(n.getInitializer()):void 0},Tc=new Set(["delete","get","head","options","patch","post","put"]),Oc=new Set(["handler","stream"]),Rc=new Set(["runAction","runMutation"]),kc=new Set(["delete","insert","insertManyUnsafe","patch","replace"]),ge=(e,t)=>e!==void 0&&i.isIdentifier(e)&&e.getText()===t,mn=(e,t)=>{if(!(e===void 0||!i.isObjectBindingPattern(e))){for(const s of e.getElements())if(me(s)===t){const r=s.getNameNode();return i.isIdentifier(r)?r.getText():void 0}}},us=(e,t)=>{const s=e.getParameters()[0]?.getNameNode();if(s!==void 0)return t?i.isIdentifier(s)?s.getText():void 0:mn(s,"ctx")},fs=(e,t)=>{const s=e.getParameters()[t?1:0]?.getNameNode();return t?s!==void 0&&i.isIdentifier(s)?s.getText():void 0:mn(s,"request")},gs=(e,t)=>{const s=e.getBody(),n=s.getDescendantsOfKind(d.CallExpression);i.isCallExpression(s)&&n.unshift(s);for(const r of n){const o=r.getExpression();if(!i.isPropertyAccessExpression(o))continue;const a=o.getName(),c=o.getExpression();if(Rc.has(a)&&ge(c,t))return a;if(kc.has(a)&&i.isPropertyAccessExpression(c)&&c.getName()==="db"&&ge(c.getExpression(),t))return`db.${a}`}},ps=(e,t)=>{const s=e.getBody();for(const n of s.getDescendantsOfKind(d.PropertyAccessExpression))if(n.getName()==="auth"&&ge(n.getExpression(),t))return!0;for(const n of s.getDescendantsOfKind(d.VariableDeclaration)){const r=n.getNameNode();if(!(!i.isObjectBindingPattern(r)||!ge(n.getInitializer(),t))){for(const o of r.getElements())if(me(o)==="auth")return!0}}return!1},Fc=/signature|hmac|digest|(?:^|[_-])sig(?:[_-]|$)/i,Dc=(e,t)=>{const s=e.getExpression();if(!i.isPropertyAccessExpression(s)||s.getName()!=="get"&&s.getName()!=="has")return!1;const n=s.getExpression();return i.isPropertyAccessExpression(n)&&n.getName()==="headers"&&ge(n.getExpression(),t)},Lc=e=>[...i.isStringLiteral(e)?[e.getLiteralText()]:[],...e.getDescendantsOfKind(d.StringLiteral).map(t=>t.getLiteralText())],hn=(e,t)=>{const s=e.getVariableDeclaration(t)?.getInitializer();return s===void 0?[]:Lc(s)},Mc=(e,t)=>{const s=e.getText();for(let n=e.getParent();n!==void 0;n=n.getParent()){if(!i.isArrowFunction(n)&&!i.isFunctionExpression(n)||!n.getParameters().some(c=>c.getName()===s))continue;const r=n.getParent();if(!i.isCallExpression(r))return[];const o=r.getExpression();if(!i.isPropertyAccessExpression(o))return[];const a=o.getExpression();return i.isIdentifier(a)?hn(t,a.getText()):[]}return[]},_c=e=>{const t=e.getArguments()[0];if(t===void 0)return[];if(i.isStringLiteral(t))return[t.getLiteralText()];if(!i.isIdentifier(t))return[];const s=e.getSourceFile(),n=hn(s,t.getText());return n.length>0?n:Mc(t,s)},ms=(e,t)=>{if(t===void 0)return!1;const s=e.getBody(),n=s.getDescendantsOfKind(d.CallExpression);return i.isCallExpression(s)&&n.unshift(s),n.some(r=>Dc(r,t)&&_c(r).some(o=>Fc.test(o)))},Kc=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!Oc.has(t.getName()))return;let s=t.getExpression();for(;i.isCallExpression(s);){const n=s.getExpression();if(!i.isPropertyAccessExpression(n))return;const r=n.getName();if(Tc.has(r)){const o=n.getExpression();return i.isIdentifier(o)&&o.getText()==="httpRoute"?r.toUpperCase():void 0}s=n.getExpression()}},zc=(e,t)=>{const s=e.getExpression();if(i.isIdentifier(s)&&s.getText()==="httpAction"){const c=fe(e.getArguments()[0]),l=c&&us(c,!0);if(!c||l===void 0||ms(c,fs(c,!0)))return;const u=gs(c,l);return u===void 0?void 0:{scope:h(e),file:t,kind:"httpAction",line:e.getStartLineNumber(),readsAuth:ps(c,l),sideEffect:u}}const n=Kc(e);if(n===void 0)return;const r=fe(e.getArguments()[0]),o=r&&us(r,!1);if(!r||o===void 0||ms(r,fs(r,!1)))return;const a=gs(r,o);return a===void 0?void 0:{scope:h(e),file:t,kind:"httpRoute",line:e.getStartLineNumber(),method:n,readsAuth:ps(r,o),sideEffect:a}},Bc=(e,t)=>I(e,t,zc),$c=new Set(["btoa","encodeURI","encodeURIComponent","isSafeHeaderValue","Number","parseFloat","parseInt"]),Uc=new Set(["append","set"]),vn=e=>e!==void 0&&(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))?e.getLiteralText():"",hs=(e,t)=>(i.isCallExpression(e)?[e,...e.getDescendantsOfKind(d.CallExpression)]:e.getDescendantsOfKind(d.CallExpression)).some(n=>$c.has(A(n.getExpression())??"")&&Pe(n,t)),Vc=(e,t)=>{if(hs(e,t))return!0;const s=Q(e);return s!==void 0&&hs(s,t)},ft=(e,t)=>Go(e,t)&&!Vc(e,t),jc=e=>{if(i.isPropertyAccessExpression(e)&&e.getName()==="headers")return!0;const t=Q(e);return t!==void 0&&i.isNewExpression(t)&&A(t.getExpression())==="Headers"},Oe=e=>{if(e===void 0)return;if(i.isObjectLiteralExpression(e))return e;const t=Q(e);return t!==void 0&&i.isObjectLiteralExpression(t)?t:void 0},Nt=(e,t,s)=>{for(const n of e.getProperties())if(i.isPropertyAssignment(n)){const r=n.getInitializer();r!==void 0&&ft(r,s.requestName)&&s.rows.push({scope:s.scope,file:s.relativePath,headerName:vn(n.getNameNode()),line:r.getStartLineNumber(),via:t})}else if(i.isShorthandPropertyAssignment(n)){const r=n.getNameNode();ft(r,s.requestName)&&s.rows.push({scope:s.scope,file:s.relativePath,headerName:y(n),line:r.getStartLineNumber(),via:t})}else if(i.isSpreadAssignment(n)){const r=Oe(n.getExpression());r!==void 0&&Nt(r,t,s)}},En=(e,t)=>{const s=Oe(e);if(s===void 0)return;const n=D(s,"headers");if(n===void 0||!i.isPropertyAssignment(n))return;const r=Oe(n.getInitializer());r!==void 0&&Nt(r,"response-init",t)},qc=(e,t)=>{const s=A(e.getExpression());if(s==="Response")En(e.getArguments()[1],t);else if(s==="Headers"){const n=Oe(e.getArguments()[0]);n!==void 0&&Nt(n,"headers-ctor",t)}},Wc=(e,t)=>{const s=e.getExpression();if(!i.isPropertyAccessExpression(s))return;const n=s.getName(),r=s.getExpression();if(n==="json"&&i.isIdentifier(r)&&r.getText()==="Response"){En(e.getArguments()[1],t);return}if(Uc.has(n)&&jc(r)){const o=e.getArguments()[1];o!==void 0&&ft(o,t.requestName)&&t.rows.push({scope:t.scope,file:t.relativePath,headerName:vn(e.getArguments()[0]),line:o.getStartLineNumber(),via:n==="set"?"headers-set":"headers-append"})}},Hc=(e,t)=>{for(const s of e.getDescendantsOfKind(d.NewExpression))qc(s,t);for(const s of e.getDescendantsOfKind(d.CallExpression))Wc(s,t)},Gc=(e,t)=>{const s=e.getExpression();if(!i.isIdentifier(s)||s.getText()!=="httpAction")return[];const n=fe(e.getArguments()[0]);if(n===void 0)return[];const r=n.getParameters()[1];if(r===void 0)return[];const o=r.getNameNode();if(!i.isIdentifier(o))return[];const a=[];return Hc(n,{scope:h(e),relativePath:t,requestName:o.getText(),rows:a}),a},Yc=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression))s.push(...Gc(n,t));return s},Qc=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Yc(r,w(t,n)))}return s},Xc=new Set(["auth","context.auth"]),Jc="userId",Zc=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(y(s))}return t},el=(e,t)=>{const s=S(t,on);if(!T(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const r of n.getDescendantsOfKind(d.CallExpression)){if(A(r.getExpression())!=="defineIdentity")continue;const[o]=r.getArguments();return o&&i.isObjectLiteralExpression(o)?Zc(o):void 0}},vs=e=>{if(e===void 0||!i.isPropertyAccessExpression(e)||e.getName()!=="identity")return;const t=e.getExpression();return Xc.has(t.getText())||$(t,["auth"])?e:void 0},tl=e=>{if(i.isPropertyAccessExpression(e)&&vs(e.getExpression())!==void 0)return e.getName();if(i.isElementAccessExpression(e)&&vs(e.getExpression())!==void 0){const t=e.getArgumentExpression();return t&&i.isStringLiteral(t)?t.getLiteralValue():void 0}},Es=(e,t,s)=>{const n=tl(e);return n===void 0?void 0:{declared:n===Jc||s.has(n),file:t,key:n,line:e.getStartLineNumber(),scope:h(e)}},sl=(e,t)=>{const s=el(e,t);return s===void 0?[]:[...at(e,t,d.PropertyAccessExpression,(n,r)=>Es(n,r,s)),...at(e,t,d.ElementAccessExpression,(n,r)=>Es(n,r,s))]},nl=(e,t)=>{if(A(e.getExpression())!=="buildImageDeliveryUrl")return;const s=e.getArguments()[0];if(!s)return;const n=P(s,"key");if(!(!n||!U(n)||ee(n)))return{scope:h(e),file:t,line:e.getStartLineNumber()}},rl=(e,t)=>I(e,t,nl),il=e=>{if(i.isComputedPropertyName(e)){const t=e.getExpression();return i.isStringLiteral(t)||i.isNoSubstitutionTemplateLiteral(t)?t.getLiteralValue():void 0}return i.isStringLiteral(e)?e.getLiteralValue():e.getText()},ol=e=>e.getProperties().some(t=>{if(i.isSpreadAssignment(t))return!0;const s=il(t.getNameNode());return s===void 0||s==="namespace"}),al=(e,t)=>{for(const{filePath:s}of Ke(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const r of n.getDescendantsOfKind(d.CallExpression)){const o=r.getExpression(),[a]=r.getArguments();if(!(!i.isPropertyAccessExpression(o)||o.getName()!=="auth"||a===void 0)&&(!i.isObjectLiteralExpression(a)||ol(a)))return r}}},cl="https://lunora.sh/docs/concepts/data-residency#pinning-auth-and-voice",ll=(e,t)=>{if(!(e.jurisdiction===void 0||e.jurisdictionPinsAuth===!0||t===void 0))throw pe(t,`the schema pins Durable Objects to the "${e.jurisdiction}" jurisdiction, and this project also has DO-backed auth (users, sessions, accounts, credentials). Pinning the auth object resolves it to a NEW, EMPTY object: existing users stay in the unpinned one until you copy them across (${cl}). Acknowledge with \`.jurisdiction("${e.jurisdiction}", { pinAuth: true })\`, deploy, then run the copy. For D1-mode auth the acknowledgement changes nothing.`,{code:"JURISDICTION_MOVE",status:422})},dl=new Set(["delete","get","getRaw","getWithMetadata","put"]),ul=(e,t,s=[])=>{const n=Ue(e,t,{argIndex:0,matchReceiver:r=>r==="ctx.kv"||r.startsWith("ctx.kv."),methods:dl});return xt(n,s)},fl=new Set(["queue","send"]),xs=new Set(["bcc","cc","to"]),gl=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();if(!fl.has(t))return;const s=e.getExpression();return $(s,["mail"])||$(s,["email"])?t:void 0},pl=e=>i.isObjectLiteralExpression(e)?e.getProperties().some(t=>{if(i.isShorthandPropertyAssignment(t)){const n=t.getNameNode();return xs.has(y(t))&&U(n)&&!ee(n)}if(!i.isPropertyAssignment(t)||!xs.has(y(t)))return!1;const s=t.getInitializer();return s!==void 0&&U(s)&&!ee(s)}):!1,ml=(e,t)=>{const s=gl(e.getExpression());if(s===void 0)return;const n=e.getArguments()[0];if(!(!n||!pl(n)))return{scope:h(e),file:t,line:e.getStartLineNumber(),method:s}},hl=(e,t)=>I(e,t,ml),vl=e=>i.isPropertyAssignment(e)||i.isMethodDeclaration(e)||i.isGetAccessorDeclaration(e)?i.isComputedPropertyName(e.getNameNode()):!1,El=e=>i.isPropertyAssignment(e)||i.isShorthandPropertyAssignment(e)||i.isMethodDeclaration(e)||i.isGetAccessorDeclaration(e)?vl(e):!0,xn=(e,t=!1)=>{for(const s of e.getProperties()){if(El(s))return!0;if(t)continue;if(!i.isPropertyAssignment(s))return!0;const n=s.getInitializer();if(!n||!i.isObjectLiteralExpression(n)||xn(n,!0))return!0}return!1},xl=(e,t)=>{for(const s of E(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const{receiver:r}of sn(n))for(const o of yt(r)){const a=o.getArguments()[0];if(a!==void 0&&(!i.isObjectLiteralExpression(a)||xn(a)))return!0}}return!1},Sl=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return[];const s=[];for(const n of t.getProperties()){const r=Te(n);if(r===void 0||!i.isPropertyAssignment(n))continue;const o=n.getInitializer();if(!(!o||!i.isObjectLiteralExpression(o)))for(const a of o.getProperties()){const c=Te(a);c!==void 0&&s.push({column:c,strategy:tn(a),table:r})}}return s},yl=(e,t)=>{const s=new Map;for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const{receiver:o}of sn(r))for(const a of yt(o))for(const c of Sl(a)){const l=`${c.table}\0${c.column}`;s.has(l)||s.set(l,c)}}return{columns:[...s.values()]}},Al=(e,t,s)=>{const n=e.getArguments()[0];if(!n||!i.isObjectLiteralExpression(n))return[];const r=[];for(const o of n.getProperties()){const a=Te(o);if(a===void 0||!i.isPropertyAssignment(o))continue;const c=o.getInitializer();if(!(!c||!i.isObjectLiteralExpression(c)))for(const l of c.getProperties()){const u=Te(l);if(u===void 0)continue;const p=tn(l);p!=="custom"&&r.push({column:u,exportName:t,file:s,line:l.getStartLineNumber(),strategy:p,table:a})}}return r},bl=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&i.isCallExpression(s)?H(s):void 0;return n?.receiver?yt(n.receiver).flatMap(r=>Al(r,K(e)??e.getName(),t)):[]},Nl=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of V(r))s.push(...bl(a,o))}return s},Pl=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="replace")return!1;const s=t.getExpression();return _(s)},wl=e=>{const t=e.getArguments()[0];if(t===void 0||!i.isObjectLiteralExpression(t))return;const s=D(t,"server");if(s!==void 0)return i.isPropertyAssignment(s)?s.getInitializer():s},Il=e=>{if(!e.isExported())return;const t=e.getInitializer();if(t?.getKind()!==d.CallExpression)return;const s=t;return ni(s.getExpression())?s:void 0},Cl=e=>{const t=Il(e),s=t===void 0?void 0:wl(t);if(s===void 0)return[];const n=e.getNameNode(),r=i.isIdentifier(n)?K(e)??n.getText():"";return s.getDescendantsOfKind(d.CallExpression).filter(o=>Pl(o)).map(o=>({exportName:r,file:"lunora/mutators.ts",line:o.getStartLineNumber()}))},Tl=e=>e.getVariableDeclarations().flatMap(t=>Cl(t)),Ol=(e,t)=>{const s=S(t,si);if(!T(s))return[];const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);return Tl(n)},Rl=new Set(["delete","get","patch"]),kl=new Set(["accountId","authorId","companyId","createdBy","createdById","customerId","groupId","memberId","organizationId","orgId","ownerId","projectId","teamId","tenantId","userId","workspaceId"]),Fl=new Set(["auth","identity","session","user"]),Dl=new Set([d.EqualsEqualsEqualsToken,d.EqualsEqualsToken,d.ExclamationEqualsEqualsToken,d.ExclamationEqualsToken]),Ll=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="normalizeId"||!_(t.getExpression()))return;const s=e.getArguments()[0];return s&&i.isStringLiteral(s)?s.getLiteralText():""},Ml=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 n=s.getNameNode();return i.isIdentifier(n)?n.getText():void 0},_l=(e,t)=>e.getDescendantsOfKind(d.Identifier).some(s=>s.getText()===t),Kl=e=>i.isThrowStatement(e)||i.isReturnStatement(e)||e.getDescendantsOfKind(d.ThrowStatement).length>0||e.getDescendantsOfKind(d.ReturnStatement).length>0,zl=(e,t)=>e.getDescendantsOfKind(d.IfStatement).some(s=>_l(s.getExpression(),t)&&Kl(s.getThenStatement())),Bl=(e,t)=>{for(const s of e.getDescendantsOfKind(d.CallExpression)){const n=s.getExpression();if(!i.isPropertyAccessExpression(n))continue;const r=n.getName();if(!Rl.has(r))continue;const o=n.getExpression();if(!(_(o)||i.isPropertyAccessExpression(o)&&_(o.getExpression())))continue;const c=s.getArguments()[0];if(c!==void 0&&i.isIdentifier(c)&&c.getText()===t)return r}},$l=e=>e.getDescendantsOfKind(d.CallExpression).some(t=>t.getArguments().some(s=>Js(St(s))!==void 0)),Ul=e=>e.getDescendantsOfKind(d.BinaryExpression).some(t=>Dl.has(t.getOperatorToken().getKind())?i.isPropertyAccessExpression(t.getLeft())||i.isPropertyAccessExpression(t.getRight()):!1),Vl=e=>{for(const t of e.getDescendantsOfKind(d.Identifier))if(kl.has(t.getText()))return!0;return[...Fl].some(t=>Be(e,t).length>0)?!0:$l(e)||Ul(e)},jl=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!i.isCallExpression(s))return[];const n=H(s);if(n?.kind!=="query"&&n?.kind!=="mutation")return[];const r=pn(s);if(r===void 0)return[];const o=n.receiver!==void 0&&Gs(n.receiver,"use","rls"),a=Vl(r),c=new Set,l=[];for(const u of r.getDescendantsOfKind(d.CallExpression)){const p=Ll(u);if(p===void 0)continue;const f=Ml(u);if(f===void 0||c.has(f)||!zl(r,f))continue;const m=Bl(r,f);m!==void 0&&(c.add(f),l.push({exportName:K(e)??e.getName(),file:t,line:u.getStartLineNumber(),mentionsOwnership:a,sinkMethod:m,table:p,usesRls:o,visibility:n.visibility}))}return l},ql=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of V(r))s.push(...jl(a,o))}return s},Sn=(e,t)=>{const s=i.isIdentifier(e)&&t!==void 0?R(e):void 0;return s===void 0||t===void 0?!1:s.compilerNode===t.compilerNode?i.isIdentifier(t.getNameNode()):i.isBindingElement(s)&&s.getFirstAncestorByKind(d.Parameter)?.compilerNode===t.compilerNode},Wl=e=>{const t=b(e),s=t.getParent();return(i.isPropertyAccessExpression(s)||i.isElementAccessExpression(s))&&s.getExpression()===t&&!ze(s)},Hl=e=>{const t=b(e).getParent();return i.isVariableDeclaration(t)&&i.isObjectBindingPattern(t.getNameNode())},Gl=e=>{const s=b(e).getParent();if(i.isSpreadAssignment(s)||i.isSpreadElement(s)){const n=s.getParent();return(i.isObjectLiteralExpression(n)||i.isArrayLiteralExpression(n))&&!ze(n)}return i.isTemplateSpan(s)&&!i.isTaggedTemplateExpression(s.getParent().getParent())},Re=e=>{const t=R(e);return t===void 0||vr(t.getSourceFile())},gt=(e,t)=>{const s=b(e),n=s.getParent();if(!i.isCallExpression(n))return!1;const r=n.getArguments().indexOf(s),o=v(n.getExpression());if(r===-1||o===void 0)return!1;if(i.isIdentifier(o))return o.getText()==="structuredClone"&&Re(o);if(Sn(St(o),t))return!(i.isPropertyAccessExpression(o)&&Zs.has(o.getName()))||i.isExpressionStatement(b(i.isAwaitExpression(n.getParent())?n.getParentOrThrow():n).getParent());if(!i.isPropertyAccessExpression(o))return!1;const a=o.getExpression();if(!i.isIdentifier(a)||!Re(a))return!1;const c=a.getText(),l=o.getName();switch(c){case"console":return!0;case"JSON":return l==="stringify";case"Object":return["entries","freeze","isFrozen","keys","values"].includes(l)||l==="assign"&&r>0;default:return!1}},we={kind:"opaque"},Yl={kind:"unreached"},Ql=e=>{const t=e.getSymbol()?.getDeclarations()??[],s=t.filter(o=>i.isFunctionDeclaration(o)&&o.hasBody()),[n]=s;return t.every(o=>i.isFunctionDeclaration(o)&&o.getSourceFile()===e.getSourceFile())&&s.length===1&&i.isFunctionDeclaration(n)?n:void 0},pt=e=>{const t=v(e);if(i.isArrowFunction(t)||i.isFunctionExpression(t))return t;const s=i.isIdentifier(t)?R(t):void 0;if(s?.getSourceFile()!==e.getSourceFile())return;if(i.isFunctionDeclaration(s)){const r=Ql(s);return r===void 0||Et(r)?void 0:r}const n=Z(s)?v(s.getInitializer()):void 0;return i.isArrowFunction(n)||i.isFunctionExpression(n)?n:void 0},yn=(e,t,s)=>{const n=t.getArguments(),r=n.indexOf(s),o=r===-1||n.slice(0,r+1).some(l=>i.isSpreadElement(l))||e.getDescendantsOfKind(d.Identifier).some(l=>l.getText()==="arguments"),a=e.getParameters(),c=a[r];return o?we:c===void 0?a.some(l=>l.isRestParameter())?we:Yl:c.isRestParameter()?we:{kind:"parameter",parameter:c}},Xl=e=>{const t=b(e),s=t.getParent();if(!i.isCallExpression(s)||s.getExpression()===t)return;const n=pt(s.getExpression());return n===void 0?we:yn(n,s,t)},Jl=new Set(["__defineGetter__","__defineSetter__","__proto__"]),Zl=e=>i.isForInStatement(e)?e.getExpression():i.isConditionalExpression(e)?e.getCondition():i.isElementAccessExpression(e)?e.getArgumentExpression():void 0,An=e=>{const t=b(e),s=t.getParent();if(i.isIfStatement(s)||i.isWhileStatement(s)||i.isDoStatement(s)||i.isSwitchStatement(s)||i.isCaseClause(s)||i.isTypeOfExpression(s)||i.isVoidExpression(s)||i.isComputedPropertyName(s))return!0;if(i.isTemplateSpan(s))return!i.isTaggedTemplateExpression(s.getParent().getParent());const n=Zl(s);if(n!==void 0)return ue(n,t);if(i.isPrefixUnaryExpression(s))return s.getOperatorToken()!==d.PlusPlusToken&&s.getOperatorToken()!==d.MinusMinusToken;if(!i.isBinaryExpression(s))return!1;const r=s.getOperatorToken().getKind(),o=r>=d.FirstAssignment&&r<=d.LastAssignment,a=r===d.QuestionQuestionToken||r===d.BarBarToken||r===d.AmpersandAmpersandToken;return!o&&!a},ed=4,bn=(e,t,s=0)=>{if(hr(e))return!0;if(Wl(e)){const r=b(e).getParent(),o=i.isElementAccessExpression(r)?r.getArgumentExpression():void 0,a=i.isStringLiteral(o)?o.getLiteralValue():void 0,c=i.isPropertyAccessExpression(r)?r.getName():a;return c===void 0||!Jl.has(c)}if(Hl(e)||Gl(e)||An(e)||gt(e,t))return!0;const n=Xl(e);return n?.kind==="unreached"||n?.kind==="parameter"&&td(n.parameter,s+1)},Ss=new WeakMap,td=(e,t=0)=>{const s=e.getNameNode();if(!i.isIdentifier(s))return!0;const n=Ss.get(e.compilerNode);if(n!==void 0)return n;if(t>ed)return!1;const o=(s.getSymbol()?.getDeclarations().length??0)===1&&e.getParentOrThrow().getDescendantsOfKind(d.Identifier).every(a=>a===s||a.getText()!==s.getText()||R(a)?.compilerNode!==e.compilerNode||bn(a,void 0,t));return(o||t===0)&&Ss.set(e.compilerNode,o),o},ys=new WeakMap,sd=(e,t)=>{const s=i.isFunctionExpression(e)?e.getNameNode():void 0;if(!i.isArrowFunction(e)&&e.getFirstDescendantByKind(d.ThisKeyword)!==void 0)return!0;const n=new Set([t.getName(),...s===void 0?[]:[s.getText()]]);return e.getDescendantsOfKind(d.Identifier).some(r=>{if(r===s||!n.has(r.getText()))return!1;const o=R(r)?.compilerNode;return o!==void 0&&(o===t.compilerNode||s!==void 0&&o===e.compilerNode)})},nd=(e,t,s)=>{const{context:n,impl:r}=e,o=ys.get(r.compilerNode);if(o!==void 0)return o;const a=t.getNameNode(),c=i.isIdentifier(a)?[a]:a.getDescendantsOfKind(d.BindingElement).flatMap(f=>{const m=f.getNameNode();return i.isIdentifier(m)?[m]:[]}),l=new Map(c.map(f=>[f.getText(),f.getParentOrThrow().compilerNode])),u=f=>i.isIdentifier(a)?bn(f,n):!ze(f),p=!sd(r,s)&&c.every(f=>(f.getSymbol()?.getDeclarations().length??0)===1)&&r.getDescendantsOfKind(d.Identifier).every(f=>{const m=f.getText();if(m==="arguments")return!1;const x=l.get(m);return x===void 0||c.includes(f)||R(f)?.compilerNode!==x?!0:u(f)});return ys.set(r.compilerNode,p),p},As=new WeakMap,rd=e=>{let t=As.get(e.compilerNode);return t===void 0&&(t=new Map(e.getVariableDeclarations().flatMap(s=>{const n=ri(s);return n===void 0?[]:[[n.compilerNode,s]]})),As.set(e.compilerNode,t)),t},id=e=>{const t=rd(e.getSourceFile()),s=e.getAncestors().find(l=>t.has(l.compilerNode)),n=s===void 0?void 0:t.get(s.compilerNode);if(s===void 0||n===void 0)return;const[r,o]=s.getParameters(),a=o===void 0||o.isRestParameter()?void 0:o,c={context:r,impl:s,mutatorName:K(n)??n.getName()};return a!==void 0&&nd(c,a,n)?{...c,parameter:a,pristine:!0}:{...c,parameter:a,pristine:!1}},od=new Set(["at","concat","filter","find","findLast","flat","reverse","slice","sort","toReversed","toSorted"]),ad=new Map([["Array",new Set(["from","of"])],["Object",new Set(["entries","values"])]]),mt=new Set(["catch","every","filter","finally","find","findIndex","findLast","findLastIndex","flatMap","forEach","map","reduce","reduceRight","some","sort","then"]),Nn=e=>e.getNameNode().getDescendantsOfKind(d.BindingElement).filter(t=>i.isIdentifier(t.getNameNode())),cd=e=>{const t=b(e),s=t.getParent();if(i.isVariableDeclaration(s))return ue(s.getInitializer(),t)?s:void 0;const n=i.isForOfStatement(s)&&s.getExpression()===t?s.getInitializer():void 0;return i.isVariableDeclarationList(n)?n.getDeclarations()[0]:void 0},ld=e=>{const t=cd(e);return t===void 0?void 0:i.isIdentifier(t.getNameNode())?i.isForOfStatement(t.getParent().getParent())||Z(t)?[t]:void 0:Nn(t)},le=e=>e.isUnion()?e.getUnionTypes().every(t=>le(t)):e.isIntersection()?e.getIntersectionTypes().some(t=>le(t)):!e.isAny()&&!e.isUnknown()&&!e.isObject()&&!e.isTypeParameter(),ke=(e,t,s)=>{const n=i.isCallExpression(e)?v(e.getExpression()):void 0;return i.isPropertyAccessExpression(n)&&t.has(n.getName())&&(s===void 0||n.getExpression()===s)},Ie=e=>{const t=v(e);if(!i.isArrowFunction(t)&&!i.isFunctionExpression(t))return;const s=t.getBody();return i.isBlock(s)?s.getDescendantsOfKind(d.ReturnStatement).filter(n=>n.getFirstAncestor(r=>i.isFunctionLikeDeclaration(r))===t).map(n=>n.getExpression()):[s]},dd=e=>{const t=i.isCallExpression(e)?v(e.getExpression()):void 0,s=i.isPropertyAccessExpression(t)?t.getExpression():void 0;return i.isPropertyAccessExpression(t)&&i.isIdentifier(s)&&ad.get(s.getText())?.has(t.getName())===!0&&Re(s)},ud=e=>{const t=ct(e);if(!i.isArrowFunction(t)&&!i.isFunctionExpression(t))return;const s=b(t),n=s.getParent();return i.isCallExpression(n)&&n.getArguments().includes(s)&&ke(n,en)?n:void 0},fd=(e,t)=>{if(!(i.isPropertyAccessExpression(e)||i.isElementAccessExpression(e))||e.getExpression()!==t)return;const s=b(e),n=s.getParent();return!i.isCallExpression(n)||n.getExpression()!==s?e:ke(n,od,t)?n:void 0},gd=(e,t)=>{if(i.isAwaitExpression(e))return e;if(i.isConditionalExpression(e))return e.getCondition()===t?void 0:e;const s=i.isBinaryExpression(e)?e.getOperatorToken().getKind():void 0;return s===d.QuestionQuestionToken||s===d.BarBarToken||s===d.AmpersandAmpersandToken?e:void 0},pd=(e,t)=>{if(i.isArrayLiteralExpression(e))return e;const n=i.isSpreadElement(e)||i.isSpreadAssignment(e)||i.isShorthandPropertyAssignment(e)||i.isPropertyAssignment(e)&&ue(e.getInitializer(),t)?e.getParent():void 0;return i.isArrayLiteralExpression(n)||i.isObjectLiteralExpression(n)?n:void 0},bs=e=>{const t=b(e),s=t.getParent();if(s===void 0)return;const n=i.isCallExpression(s)&&s.getArguments().includes(t)&&dd(s);return fd(s,t)??gd(s,t)??pd(s,t)??(n?s:ud(t))},md=5e4,Pn=()=>({inProgress:new Set,verdicts:new Map});class hd{cuts=0;work=0;reset(){this.work=0}cut(){return this.cuts+=1,!0}spend(){return this.work+=1,this.work>md&&this.cut()}memoized(t,s,n){const r=n.verdicts.get(t);if(r!==void 0)return r;if(n.inProgress.has(t))return this.cuts+=1,!1;if(this.spend())return!0;const o=this.cuts;n.inProgress.add(t);let a;try{a=s()}finally{n.inProgress.delete(t)}return this.cuts===o&&n.verdicts.set(t,a),a}}const vd=8,Ed=8;class xd{budget;scope;taint;verdicts=Pn();constructor(t,s,n){this.scope=t,this.budget=s,this.taint=n}isCompromised(t){return this.flowHasCompromisingUse(t)&&!le(t.getType())}flowHasCompromisingUse(t){return this.budget.memoized(t.compilerNode,()=>{const s=this.budget.cuts,n=[],r=new Set,o=(c,l)=>{r.has(c.compilerNode)||(r.add(c.compilerNode),n.push({binding:c,hops:l}))};let a=!1;o(t,0);for(const c of n)if(a=(c.binding===t?void 0:this.verdicts.verdicts.get(c.binding.compilerNode))??this.visitBinding(c,t,o),a)break;if(!a&&this.budget.cuts===s)for(const c of r)this.verdicts.verdicts.set(c,!1);return a},this.verdicts)}visitBinding({binding:t,hops:s},n,r){const o=t.getNameNode();if(!i.isIdentifier(o)){for(const l of i.isParameterDeclaration(t)?Nn(t):[])r(l,s);return!1}if(this.budget.spend())return!0;const a=(l,u)=>u&&s>=vd?this.budget.cut():(r(l,u?s+1:s),!1);return this.taint.referencesTo(t,o.getText()).some(l=>this.valueCompromises(b(l),!0,a,0))&&(t===n||!le(t.getType()))}valueCompromises(t,s,n,r){let o=t;for(let m=bs(o);m!==void 0;m=bs(o)){if(i.isCallExpression(m)&&this.callbackCompromises(m,n))return!0;o=b(m)}const a=o.getParent(),c=o===t&&s,l=()=>!c&&le(o.getType());if(ze(o))return!c&&(!i.isBinaryExpression(a)||this.taint.isTaintedValue(a.getRight(),!1));const u=ld(o);if(u!==void 0)return u.some(m=>n(m,!0));const p=i.isPropertyAccessExpression(a)&&a.getExpression()===o?a.getParent():void 0;if(i.isCallExpression(p)&&p.getExpression()===a)return this.methodCallCompromises(p,n);const f=this.nestedReturningFunctionOf(o);return f!==void 0?this.resultCompromises(f,n,r)&&!l():this.positionCompromises(o,n)&&!l()}resultCompromises(t,s,n){const r=b(t).getParent();if(n>=Ed)return this.budget.cut();if(i.isCallExpression(r))return r.getExpression()===b(t)?this.valueCompromises(r,!1,s,n+1):!ke(r,mt);const o=i.isFunctionDeclaration(t)?t:r,a=i.isFunctionDeclaration(o)||Z(o)?o.getNameNode():void 0;return o===void 0||!i.isIdentifier(a)?!0:this.taint.referencesTo(o,a.getText()).some(c=>{const l=b(c),u=l.getParent();return!i.isCallExpression(u)||u.getExpression()!==l||this.valueCompromises(u,!1,s,n+1)})}methodCallCompromises(t,s){return t.getArguments().filter(r=>Ie(r)===void 0).some(r=>this.taint.isTaintedValue(r,!1))||this.callbackCompromises(t,s)}callbackCompromises(t,s){const n=ke(t,mt)?t.getArguments()[0]:void 0;if(n===void 0)return!1;const r=pt(n);return r!==void 0&&this.taint.isInImpl(r)?r.getParameters().some(o=>s(o,!1)):this.taint.isTaintedValue(n,!1)}positionCompromises(t,s){const n=t.getParent();if(i.isCallExpression(n)&&n.getArguments().includes(t))return this.argumentCompromises(n,t,s);const r=i.isSpreadElement(n)?n.getParent():void 0;if(n!==void 0&&i.isCallExpression(r))return!gt(n,this.scope.context)&&this.isOpaqueCallTainted(r.getExpression(),r.getArguments(),n);if(i.isNewExpression(n))return this.isOpaqueCallTainted(n.getExpression(),n.getArguments(),t);if(i.isTemplateSpan(n)){const o=n.getParent(),a=o.getParent(),c=o.getTemplateSpans().map(l=>l.getExpression());return i.isTaggedTemplateExpression(a)&&this.isOpaqueCallTainted(a.getTag(),c,t)}return!this.isReadPosition(t)}argumentCompromises(t,s,n){if(gt(s,this.scope.context))return!1;const r=pt(t.getExpression()),o=r===void 0?void 0:yn(r,t,s);return o?.kind==="unreached"?!1:o?.kind==="parameter"&&r!==void 0&&this.taint.isInImpl(r)?n(o.parameter,!1):this.isOpaqueCallTainted(t.getExpression(),t.getArguments(),s)}isReadPosition(t){const s=t.getParent();return s===void 0||i.isExpressionStatement(s)||i.isForStatement(s)||i.isElementAccessExpression(s)||An(t)||ue(ct(t),this.scope.impl)}isOpaqueCallTainted(t,s,n){const r=!i.isIdentifier(v(n));return this.taint.isTaintedValue(t,!1)||s.some(o=>(o!==n||r)&&this.taint.isTaintedValue(o,!1))}nestedReturningFunctionOf(t){const s=ct(t);return ue(s,this.scope.impl)?void 0:s}}const Sd=new Set(["at","every","filter","finally","find","findIndex","findLast","findLastIndex","forEach","order","slice","some","sort","withIndex","withSearchIndex"]),yd=e=>{const t=v(e);if(!i.isIdentifier(t))return i.isPropertyAccessExpression(t)||i.isElementAccessExpression(t);const s=R(t),n=i.isVariableDeclaration(s)?v(s.getInitializer()):void 0;return s===void 0||i.isFunctionDeclaration(s)||i.isParameterDeclaration(s)||i.isArrowFunction(n)||i.isFunctionExpression(n)},Ad=new Set(["all","allSettled","any","race"]),Ns=e=>i.isParameterDeclaration(e)?e:i.isBindingElement(e)?e.getFirstAncestorByKind(d.Parameter):void 0,nt=8;class bd{budget=new hd;referencesByDeclaration=new Map;referencesByName=new Map;scope;verdicts=Pn();walk;variableDepth=0;queryDepth=0;constructor(t){this.scope=t,this.walk=new xd(t,this.budget,this);for(const s of t.impl.getDescendantsOfKind(d.Identifier)){const n=s.getText();this.referencesByName.set(n,[...this.referencesByName.get(n)??[],s])}}isTaintedValue(t,s){this.queryDepth===0&&this.budget.reset(),this.queryDepth+=1;try{return s&&this.isRootedInContext(t,nt)?!1:(i.isIdentifier(t)?[t]:t.getDescendantsOfKind(d.Identifier)).some(r=>Er(r)&&this.isIdentifierTainted(r))}finally{this.queryDepth-=1}}isInImpl(t){const{impl:s}=this.scope;return t!==s&&s.getPos()<=t.getPos()&&t.getEnd()<=s.getEnd()}referencesTo(t,s){let n=this.referencesByDeclaration.get(s);if(n===void 0){n=new Map;for(const r of this.referencesByName.get(s)??[]){const o=R(r)?.compilerNode;o!==void 0&&n.set(o,[...n.get(o)??[],r])}this.referencesByDeclaration.set(s,n)}return(n.get(t.compilerNode)??[]).filter(r=>r.getParent()!==t)}flowsIntoTainted(t){if([t.getInitializer(),...t.getDescendantsOfKind(d.BindingElement).map(f=>f.getInitializer())].some(f=>f!==void 0&&this.isTaintedValue(f,!1)))return!0;const n=t.getParentOrThrow(),r=i.isFunctionLikeDeclaration(n)?n.getParameters().findIndex(f=>f.compilerNode===t.compilerNode):-1,o=b(n),a=o.getParent();if(r===-1)return!0;if(i.isCallExpression(a)){if(a.getExpression()===o)return this.isCallSiteTainted(a,r,t.isRestParameter());const f=v(a.getExpression());if(!i.isPropertyAccessExpression(f)||!mt.has(f.getName()))return!0;const m=a.getArguments().filter(x=>x!==o);return this.isTaintedValue(f.getExpression(),!0)||m.some(x=>this.isTaintedValue(x,!1))}const c=i.isVariableDeclaration(a)&&Z(a)?a:void 0,l=i.isFunctionDeclaration(n)?n:c,u=l?.getNameNode();if(l===void 0||!i.isIdentifier(u))return!0;const p=this.referencesTo(l,u.getText());return p.length===0||p.some(f=>{const m=b(f),x=m.getParent();return!i.isCallExpression(x)||x.getExpression()!==m||this.isCallSiteTainted(x,r,t.isRestParameter())})}isCallSiteTainted(t,s,n){const r=t.getArguments(),o=r.findIndex(c=>i.isSpreadElement(c)),a=c=>c===s||n&&c>s||o!==-1&&o<=s&&c>=o;return r.some((c,l)=>a(l)&&this.isTaintedValue(c,!1))}isContextRootedCombinator(t,s){const n=v(t.getExpression()),r=i.isPropertyAccessExpression(n)?n.getExpression():void 0,a=i.isPropertyAccessExpression(n)&&i.isIdentifier(r)&&r.getText()==="Promise"&&Re(r)&&Ad.has(n.getName())?v(t.getArguments()[0]):void 0;if(i.isArrayLiteralExpression(a)){const p=a.getElements();return p.length>0&&p.every(f=>!i.isSpreadElement(f)&&this.isRootedInContext(f,s))}const c=i.isCallExpression(a)?v(a.getExpression()):void 0,l=i.isCallExpression(a)&&i.isPropertyAccessExpression(c)&&c.getName()==="map"?v(a.getArguments()[0]):void 0,u=l===void 0?void 0:Ie(l);return u!==void 0&&u.length>0&&u.every(p=>p!==void 0&&this.isRootedInContext(p,s))}isIdentifierTainted(t){const s=t.getText();if(s==="arguments")return!0;const n=R(t),r=Ns(n);if(r!==void 0)return this.isSource(r);if(s==="args")return!0;if(n===void 0||!this.isInImpl(n))return!1;if(i.isFunctionDeclaration(n))return this.budget.memoized(n.compilerNode,()=>this.isTaintedValue(n,!1),this.verdicts);if(i.isBindingElement(n)&&this.walk.isCompromised(n))return!0;const o=i.isBindingElement(n)?n.getFirstAncestorByKind(d.VariableDeclaration):n;return i.isVariableDeclaration(o)&&this.isVariableTainted(o)}callChainVerdict(t,s){if(this.isContextRootedCombinator(t,s))return!0;const n=v(t.getExpression()),r=i.isPropertyAccessExpression(n)?n.getName():void 0;return r!==void 0&&Zs.has(r)?!1:r!==void 0&&en.has(r)?this.isCallbackResultServerScoped(t,s)?void 0:!1:t.getArguments().some(a=>Ie(a)!==void 0)&&(r===void 0||!Sd.has(r))?!1:void 0}isCallbackResultServerScoped(t,s){const n=(r,o=[])=>{const a=St(r),c=i.isIdentifier(a)?Ns(R(a)):void 0;return c!==void 0&&o.includes(c)?!0:this.isRootedInContext(r,s)||!this.isTaintedValue(r,!1)};return t.getArguments().every(r=>{const o=Ie(r);if(o===void 0)return!yd(r)&&n(r);const a=v(r),c=i.isArrowFunction(a)||i.isFunctionExpression(a)?a.getParameters():[];return o.every(l=>l===void 0||n(l,c))})}isRootedInContext(t,s){const n=Pr(t,u=>this.callChainVerdict(u,s)),r=n.root;if(n.verdict!==void 0)return n.verdict;if(Sn(r,this.scope.context))return!0;const o=i.isIdentifier(r)?R(r):void 0,a=i.isBindingElement(o)?o.getFirstAncestorByKind(d.VariableDeclaration):o,c=Z(a)&&this.isInImpl(a)?a.getInitializer():void 0,l=i.isBindingElement(o)?o:a;return s>0&&c!==void 0&&(i.isBindingElement(l)||i.isVariableDeclaration(l))&&!this.walk.isCompromised(l)&&this.isRootedInContext(c,s-1)}isSource(t){const{impl:s,parameter:n}=this.scope;return t.compilerNode===n?.compilerNode?!0:t.getParent()!==s&&this.isInImpl(t)&&(this.budget.memoized(t.compilerNode,()=>this.flowsIntoTainted(t),this.verdicts)||this.walk.isCompromised(t))}isVariableTainted(t){return this.budget.memoized(t.compilerNode,()=>{const s=t.getParent().getParent();if(i.isCatchClause(t.getParent())||this.walk.isCompromised(t))return!0;if(i.isForOfStatement(s)||i.isForInStatement(s))return this.isTaintedValue(s.getExpression(),!0);const n=t.getInitializer(),r=Et(t);if(n===void 0||r)return!0;if(this.isRootedInContext(n,nt))return!1;if(this.variableDepth>=nt)return this.budget.cut();this.variableDepth+=1;try{return this.isTaintedValue(n,!1)}finally{this.variableDepth-=1}},this.verdicts)}}const Ps=new WeakMap,Nd=e=>{const t=Ps.get(e.impl.compilerNode);if(t!==void 0)return t;const s=new bd(e);return Ps.set(e.impl.compilerNode,s),s},Pd=new Set(["accountId","authorId","createdBy","createdById","organizationId","orgId","ownerId","tenantId","updatedBy","userId","workspaceId"]),wd=new Set(["insert","insertManyUnsafe","patch","replace"]),Id=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();return wd.has(t)&&zr(e.getExpression())?t:void 0},Cd=(e,t)=>{if(t!=="insertManyUnsafe")return i.isObjectLiteralExpression(e)?[e]:[];if(!i.isArrayLiteralExpression(e))return[];const s=[];for(const n of e.getElements())i.isObjectLiteralExpression(n)&&s.push(n);return s},Td=(e,t)=>{const s=wr(e);return s?.member===t?v(s.object):void 0},ws=(e,t)=>i.isIdentifier(e)&&R(e)?.compilerNode===t.compilerNode,wn=(e,t,s,n=1)=>{const r=Td(e,s);if(r!==void 0)return ws(r,t);const o=i.isIdentifier(e)?R(e):void 0;if(i.isBindingElement(o)){const c=o.getParent(),l=c.getParent();return o.getDotDotDotToken()===void 0&&me(o)===s&&i.isObjectBindingPattern(c)&&(l.compilerNode===t.compilerNode||Z(l)&&ws(v(l.getInitializer()),t))}const a=Z(o)?o.getInitializer():void 0;return n>0&&a!==void 0&&wn(a,t,s,n-1)},Od=(e,t,s)=>{const n=[],r=s===void 0?void 0:Nd(s);for(const o of e.getProperties()){let a,c;if(i.isPropertyAssignment(o)?(a=y(o),c=o.getInitializer()):i.isShorthandPropertyAssignment(o)&&(a=y(o),c=o.getNameNode()),a===void 0||c===void 0||!Pd.has(a))continue;if(r===void 0?U(c)&&!Br(c):r.isTaintedValue(c,!0)){const u=t.ownerField===a&&s?.pristine===!0&&wn(c,s.parameter,a);n.push({field:a,file:t.relativePath,line:t.call.getStartLineNumber(),method:t.method,scope:t.scope,...u&&{ownerScoped:!0}})}}return n},Rd=(e,t,s)=>{const n=Id(e.getExpression()),r=n===void 0?void 0:e.getArguments()[1];if(n===void 0||r===void 0)return[];const o=Cd(r,n);if(o.length===0)return[];const a=h(e),c=id(e),l={call:e,method:n,ownerField:c===void 0?void 0:s(c.mutatorName),relativePath:t,scope:a};return o.flatMap(u=>Od(u,l,c))},kd=(e,t,s=[],n=[])=>{const r=new Map(n.map(a=>[`${a.filePath}:${a.exportName}`,a.owner])),o=I(e,t,(a,c)=>Rd(a,c,l=>r.get(`${c}:${l}`)));return xt(o,s)},Fd=["providerSubscriptionId","state"],Dd=["providerEventId","processedAt"],Is=(e,t)=>t.every(s=>s in e.shape),Ld=e=>{const t=e.find(n=>n.name==="subscriptions"),s=e.find(n=>n.name==="events");return t!==void 0&&s!==void 0&&Is(t,Fd)&&Is(s,Dd)},Md=new Set(["createAutumnAdapter","createDodoPaymentsAdapter","createPolarAdapter","createStripeAdapter"]),_d=e=>e&&i.isNumericLiteral(e)?Number(e.getText()):void 0,Kd=e=>{const t=D(e,"webhookToleranceSeconds");return t&&i.isPropertyAssignment(t)?_d(t.getInitializer()):void 0},zd=(e,t)=>{const s=A(e.getExpression());if(s===void 0||!Md.has(s))return;const[n]=e.getArguments(),r=n&&i.isObjectLiteralExpression(n)?Kd(n):void 0;return{callee:s,scope:h(e),file:t,line:e.getStartLineNumber(),...r===void 0?{}:{toleranceSeconds:r}}},Bd=(e,t)=>I(e,t,zd),$d=new Map([["defineQueue",0],["defineSubscription",1],["defineWorkflow",0]]),Ud=e=>{const t=e.getExpression();return i.isIdentifier(t)?t.getText():void 0},Vd=(e,t)=>{const s=e.getArguments()[t];if(!s||!i.isObjectLiteralExpression(s))return;const n=D(s,"handler");if(n===void 0||!i.isPropertyAssignment(n))return;const r=n.getInitializer();if(r&&(i.isArrowFunction(r)||i.isFunctionExpression(r)))return r},In=(e,t)=>{const s=e.getParameters()[t]?.getNameNode();return s&&i.isIdentifier(s)?s.getText():void 0},Cn=(e,t)=>e===t||e.startsWith(`${t}.`),Tn=e=>{const t=e.getDescendantsOfKind(d.PropertyAccessExpression);return i.isPropertyAccessExpression(e)&&t.push(e),t},Cs=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)},On=e=>{const t=e.getDescendantsOfKind(d.Identifier).filter(s=>Cs(s));return i.isIdentifier(e)&&Cs(e)&&t.push(e),t},jd=e=>{if(!i.isVariableDeclaration(e))return[];const t=e.getNameNode();return i.isIdentifier(t)?[t.getText()]:t.getDescendantsOfKind(d.BindingElement).map(s=>s.getName())},qd=e=>{const t=In(e,1);if(t===void 0)return[];const s=[`${t}.messages`];for(const n of e.getDescendantsOfKind(d.ForOfStatement)){if(n.getExpression().getText()!==`${t}.messages`)continue;const r=n.getInitializer(),o=i.isVariableDeclarationList(r)?r.getDeclarations()[0]?.getNameNode():void 0;o&&i.isIdentifier(o)&&s.push(`${o.getText()}.body`)}return s},Wd=(e,t,s)=>{const n=t==="workflow"?[`${s}.params`]:qd(e),r=new Set,o=a=>Tn(a).some(c=>n.some(l=>Cn(c.getText(),l)))?!0:On(a).some(c=>r.has(c.getText()));for(const a of e.getDescendantsOfKind(d.VariableDeclaration)){const c=a.getInitializer();if(c&&o(c))for(const l of jd(a))r.add(l)}return{names:r,prefixes:n}},Hd=(e,t)=>Tn(e).some(s=>t.prefixes.some(n=>Cn(s.getText(),n)))?!0:On(e).some(s=>t.names.has(s.getText())),Gd=e=>{const t=qs(e);return t===void 0?void 0:{exportName:String(t.at(-1)),file:t.slice(0,-1).join("/")}},Yd=(e,t,s)=>{const n=In(e,0);if(n===void 0)return[];const r=Wd(e,t,n),o=new Set([n,...r.prefixes.filter(c=>c.endsWith(".body")).map(c=>c.slice(0,-5))]),a=[];for(const c of e.getDescendantsOfKind(d.CallExpression)){const l=c.getExpression();if(!i.isPropertyAccessExpression(l)||!js.has(l.getName())||!o.has(l.getExpression().getText()))continue;const u=c.getArguments()[1];if(!u||!Hd(u,r))continue;const p=Gd(c.getArguments()[0]);p!==void 0&&a.push({dispatchKind:t,file:s,scope:h(c),line:c.getStartLineNumber(),targetExport:p.exportName,targetFile:p.file})}return a},Qd=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression)){const r=Ud(n),o=r===void 0?void 0:$d.get(r);if(o===void 0)continue;const a=Vd(n,o);a!==void 0&&s.push(...Yd(a,r==="defineWorkflow"?"workflow":"queue",t))}return s},Xd=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Qd(r,w(t,n)))}return s},Ts={dbRateLimit:"usesRateLimit",emailGateMiddleware:"usesEmailGate",mask:"usesMask",rateLimit:"usesRateLimit",rls:"usesRls",verifyTurnstileMiddleware:"usesCaptcha"},Os=new Set(["account","credential","member","passkey","session","user"]),Jd=e=>e.replaceAll(/[-_]/gu," ").replaceAll(/([a-z0-9])([A-Z])/gu,"$1 $2").split(" ").filter(Boolean).map(t=>t.toLowerCase()),Zd=e=>{const s=Jd(e).at(-1);if(!s)return!1;const n=s.endsWith("s")?s.slice(0,-1):s;return Os.has(s)||Os.has(n)},eu=e=>{const t=e.replaceAll(/[^a-z0-9]/giu,"").toLowerCase();return t.endsWith("email")||t.endsWith("emailaddress")},tu=(e,t)=>{const{objects:s,opaque:n}=bt(e,t);return pa(s).some(r=>eu(r))?!0:n?void 0:!1},su=e=>{const t=e.getArguments()[0];return!t||!i.isObjectLiteralExpression(t)?{usesCaptcha:!1,usesRateLimit:!1}:{usesCaptcha:!!D(t,"captcha"),usesRateLimit:!!D(t,"rateLimit")}},nu=e=>{if(i.isCallExpression(e))return e;if(!i.isIdentifier(e))return;const s=e.getSourceFile().getVariableDeclaration(e.getText())?.getInitializer();return s&&i.isCallExpression(s)?s:void 0},Ce={usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},ru=e=>{const t=nu(e),s=t?A(t.getExpression()):void 0;if(t&&s==="protectPublic"){const n=su(t);return{...Ce,usesCaptcha:n.usesCaptcha,usesRateLimit:n.usesRateLimit}}return s!==void 0&&s in Ts?{...Ce,[Ts[s]]:!0}:Ce},iu=e=>{const t={...Ce};let s=e;for(;i.isCallExpression(s);){const n=s.getExpression();if(!i.isPropertyAccessExpression(n))break;const r=n.getName()==="use"?s.getArguments()[0]:void 0;if(r){const o=ru(r);t.usesCaptcha||=o.usesCaptcha,t.usesEmailGate||=o.usesEmailGate,t.usesMask||=o.usesMask,t.usesRateLimit||=o.usesRateLimit,t.usesRls||=o.usesRls}s=n.getExpression()}return t},ou=new Set(["insert","insertMany","insertManyUnsafe","replace"]),au=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!ou.has(t.getName()))return!1;const s=t.getExpression();if(!_(s))return!1;const r=e.getArguments()[0];return!r||!(i.isStringLiteral(r)||i.isNoSubstitutionTemplateLiteral(r))?!1:Zd(r.getLiteralText())},cu=new Set(["create","publish","publishBatch","runAfter","runAt","send","sendBatch"]),Rs=new Set(["queues","scheduler","topics","workflows"]),lu=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!cu.has(t.getName()))return!1;let s=t.getExpression();for(;i.isCallExpression(s)||i.isElementAccessExpression(s)||i.isPropertyAccessExpression(s);){if(i.isPropertyAccessExpression(s)&&Rs.has(s.getName())&&$r(s.getExpression()))return!0;s=s.getExpression()}const n=Js(s);return n?.length===1&&Rs.has(n[0]??"")},du=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="insertManyUnsafe")return!1;const s=t.getExpression();return _(s)},Rn=new Set(["generateObject","generateText","streamObject","streamText"]),uu=e=>{const t=A(e.getExpression());return t!==void 0&&Rn.has(t)},fu=e=>{const t=A(e.getExpression());if(t===void 0||!Rn.has(t))return!1;const s=e.getArguments()[0];return!s||!i.isObjectLiteralExpression(s)||s.getProperties().some(n=>i.isSpreadAssignment(n))?!1:!D(s,"maxOutputTokens")},gu=new Set(["log","span","trace"]),pu=new Set(["ai"]),mu=new Set(["email","mail"]),hu=new Set(["ai","browser","fetch","mail","notify","queues","sql","storage","topics","workflows"]),rt=(e,t)=>[...t].some(s=>Be(e,s).length>0),vu=new Set([d.ArrowFunction,d.FunctionDeclaration,d.FunctionExpression,d.GetAccessor,d.MethodDeclaration,d.SetAccessor]),Eu=new Set(["every","filter","flatMap","forEach","map","some"]),xu=new Set(["all","allSettled","race"]),Su=e=>{const t=e.getParent();if(!t||!i.isCallExpression(t)||!t.getArguments().includes(e))return;const s=t.getExpression();if(!i.isPropertyAccessExpression(s))return;const n=s.getName();if(Eu.has(n))return t;const r=s.getExpression();if(i.isIdentifier(r)&&r.getText()==="Promise"&&xu.has(n))return t},yu=e=>{let t=e.getParent();for(;t;){if(i.isTryStatement(t)){const s=t.getTryBlock();if(e.getPos()>=s.getPos()&&e.getEnd()<=s.getEnd())return!0}if(vu.has(t.getKind())){const s=Su(t);if(!s)return!1;t=s;continue}t=t.getParent()}return!1},Au=e=>{let t=e;for(;;){const s=t.getParent();if(!i.isPropertyAccessExpression(s)||s.getExpression()!==t)return!1;if(s.getName()==="catch")return!0;if(s.getName()!=="then"&&s.getName()!=="finally")return!1;const n=s.getParent();if(!i.isCallExpression(n)||n.getExpression()!==s)return!1;t=n}},bu=e=>{let t=e;for(;;){const s=t.getParent();if(i.isPropertyAccessExpression(s)&&s.getExpression()===t){t=s;continue}return i.isCallExpression(s)&&s.getExpression()===t?s:void 0}},Nu=e=>{let t=!1,s=!0;for(const n of[...hu].flatMap(r=>Be(e,r))){const r=bu(n);r&&(t=!0,!yu(r)&&!Au(r)&&(s=!1))}return{handlesErrors:t&&s,reachesOutbound:t}},Pu=e=>e.getDescendantsOfKind(d.ThrowStatement).some(t=>{const s=t.getExpression();if(!i.isNewExpression(s))return!1;const n=s.getExpression();return i.isIdentifier(n)&&n.getText()==="Error"}),ks="lunora-advisor-exempt",wu=/^[\s*/]+/u,Iu=/[\w-]/u,Cu=e=>{const s=(e.getFirstAncestorByKind(d.VariableStatement)??e).getLeadingCommentRanges().map(n=>n.getText()).join(`
7
+ `);for(const n of s.split(`
8
+ `)){const r=n.replace(wu,"");if(!r.startsWith(ks))continue;const o=r.slice(ks.length);if(Iu.test(o.charAt(0)))continue;const a=o.indexOf("--");return{exempt:!0,exemptReason:(a===-1?"":o.slice(a+2).split("*")[0]??"").trim()}}return{exempt:!1,exemptReason:""}},Tu=e=>{const[t]=e.getArguments();if(t){if(i.isObjectLiteralExpression(t)){const s=D(t,"handler");return s?i.isPropertyAssignment(s)?s.getInitializer():i.isShorthandPropertyAssignment(s)?s.getNameNode():i.isMethodDeclaration(s)?s:void 0:void 0}return t}},Ou=(e,t)=>{const s=Tu(t);if(!s)return;if(i.isArrowFunction(s)||i.isFunctionExpression(s)||i.isMethodDeclaration(s))return e;if(!i.isIdentifier(s))return;const n=s.getSourceFile(),r=s.getText(),o=n.getVariableDeclaration(r)?.getInitializer();return o&&(i.isArrowFunction(o)||i.isFunctionExpression(o))?o:n.getFunction(r)},Ru=e=>{let t=!1,s=!1,n=!1,r=!1,o=!1;for(const l of e.getDescendantsOfKind(d.CallExpression))if(au(l)&&(o=!0),lu(l)&&(t=!0),du(l)&&(r=!0),uu(l)&&(s=!0),fu(l)&&(n=!0),o&&t&&r&&n)break;const{handlesErrors:a,reachesOutbound:c}=Nu(e);return{callsMail:rt(e,mu),emitsEvent:rt(e,gu),fanOut:t,handlesErrors:a,reachesOutbound:c,runsAiGeneration:s||rt(e,pu),throwsBareError:Pu(e),unboundedAiGeneration:n,usesInsertManyUnsafe:r,writesUserTable:o}},ku=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const n=H(s);if(!n||n.kind!=="query"&&n.kind!=="mutation"&&n.kind!=="action")return;const r=n.receiver?iu(n.receiver):{usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},o=Ou(e,s);return{...o?Ru(o):{},...Cu(e),...r,analyzableBody:o!==void 0,exportName:K(e)??e.getName(),file:t,hasEmailArg:tu(s,n.receiver),kind:n.kind,visibility:n.visibility}},Fu=(e,t)=>{const s=[];for(const n of V(e)){const r=ku(n,t);r&&s.push(r)}return s},Du=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Fu(r,w(t,n)))}return s},Lu=new Set(["dbRateLimit","rateLimit"]),Mu=e=>i.isArrowFunction(e)?e.getBody():e,_u=e=>{if(!i.isArrowFunction(e))return;const t=e.getParameters()[0]?.getNameNode();return t!==void 0&&i.isIdentifier(t)?t:void 0},kn=e=>{const t=e.getParent();return i.isPropertyAccessExpression(t)&&t.getExpression()===e&&t.getName()==="args"},Fn=(e,t)=>{const s=t.getSymbol();return s===void 0?[]:e.getDescendantsOfKind(d.Identifier).filter(n=>{if(n.getSymbol()!==s)return!1;const r=n.getParent();return!(i.isPropertyAccessExpression(r)&&r.getNameNode()===n)})},Ku=(e,t)=>U(e)||t!==void 0&&Fn(e,t).some(s=>kn(s)),zu=(e,t)=>t===void 0?ee(e):Fn(e,t).some(s=>!kn(s)),Bu=(e,t)=>{const s=A(e.getExpression());if(s===void 0||!Lu.has(s))return;const n=P(Hs(e.getArguments()[2]),"key");if(!n)return;const r=Mu(n),o=_u(n);if(!(!Ku(r,o)||zu(r,o)))return{callee:s,scope:h(e),file:t,limitName:Ws(e),line:e.getStartLineNumber()}},$u=(e,t)=>I(e,t,Bu),Uu=new Set(["findFirst","findFirstOrThrow","findMany","findUnique","get"]),Vu=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!Uu.has(t.getName()))return;const s=t.getExpression();if(_(s)){const n=e.getArguments()[0];return n&&i.isStringLiteral(n)?n.getLiteralText():""}if(i.isPropertyAccessExpression(s)&&_(s.getExpression()))return s.getName()},ju=e=>{let t=e;for(;i.isCallExpression(t);){const s=t.getExpression();if(!i.isPropertyAccessExpression(s))return;if(s.getName()==="query"&&_(s.getExpression())){const n=t.getArguments()[0];return n&&i.isStringLiteral(n)?n.getLiteralText():""}t=s.getExpression()}},qu=e=>{let t=v(e)??e;for(;i.isAwaitExpression(t);)t=v(t.getExpression())??t.getExpression();return t},Dn=(e,t=!1)=>{const s=qu(e);if(i.isIdentifier(s)){if(t)return;const n=Q(s);return n===void 0?void 0:Dn(n,!0)}if(i.isCallExpression(s))return Vu(s)??ju(s)},Wu=e=>{const t=e.getBody();if(!i.isBlock(t))return[t];const s=[];for(const n of e.getDescendantsOfKind(d.ReturnStatement)){const r=n.getFirstAncestor(a=>i.isArrowFunction(a)||i.isFunctionExpression(a)||i.isFunctionDeclaration(a)),o=n.getExpression();r===e&&o!==void 0&&s.push(o)}return s},Hu=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!i.isCallExpression(s))return[];const n=H(s);if(n?.kind!=="query")return[];const r=pn(s);if(r===void 0)return[];const o=n.receiver!==void 0&&Or(n.receiver,"output"),a=n.receiver!==void 0&&Gs(n.receiver,"use","mask"),c=new Set,l=[];for(const u of Wu(r)){const p=Dn(u);p===void 0||c.has(p)||(c.add(p),l.push({exportName:K(e)??e.getName(),file:t,line:u.getStartLineNumber(),table:p,usesMask:a,usesOutput:o,visibility:n.visibility}))}return l},Gu=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of V(r))s.push(...Hu(a,o))}return s},Yu=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(y(s));return t},Qu=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&i.isCallExpression(s)?H(s):void 0;if(!n)return[];const r=[];for(const o of e.getDescendantsOfKind(d.CallExpression)){const a=nn(o);if(a===void 0)continue;const c=Yu(P(a.options,"with"));c.length!==0&&r.push({exportName:K(e)??e.getName(),file:t,line:o.getStartLineNumber(),parentTable:a.table,relations:c,visibility:n.visibility})}return r},Xu=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of V(r))s.push(...Qu(a,o))}return s},Fe=e=>{if(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))return e.getLiteralText();if(i.isBinaryExpression(e)&&e.getOperatorToken().getKind()===d.PlusToken){const t=Fe(e.getLeft()),s=Fe(e.getRight());return t!==void 0&&s!==void 0?t+s:void 0}},Ju=e=>{let t=e,s=t.getParent();for(;s!==void 0&&i.isBinaryExpression(s)&&s.getOperatorToken().getKind()===d.PlusToken;)t=s,s=t.getParent();return t!==e&&Fe(t)!==void 0},Zu=/(?:^|\/)__tests__\//u,ef=/\.(?:spec|test)$/u,tf=e=>Zu.test(e)||ef.test(e),sf=e=>{const t=e.getParent();if(t!==void 0){if(i.isVariableDeclaration(t)||i.isPropertyAssignment(t)||i.isPropertySignature(t))return y(t);if(i.isBinaryExpression(t)&&t.getOperatorToken().getKind()===d.EqualsToken)return t.getLeft().getText()}},nf=(e,t,s)=>hi(e)?!tf(s)&&vi(sf(t)):!0,rf=(e,t)=>{const s=[],n=[...e.getDescendantsOfKind(d.BinaryExpression),...e.getDescendantsOfKind(d.StringLiteral),...e.getDescendantsOfKind(d.NoSubstitutionTemplateLiteral)],r=new Set;for(const o of n){if(Ju(o))continue;const a=Fe(o);if(a===void 0)continue;const c=pi(a);if(c===void 0||!nf(c,o,t))continue;const l=o.getStartLineNumber(),u=`${String(l)}:${c}`;r.has(u)||(r.add(u),s.push({file:t,kind:c,line:l,preview:mi(a)}))}return s},of=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...rf(r,w(t,n)))}return s},af=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&i.isCallExpression(s)?H(s):void 0;if(!n)return[];const r=[];for(const o of e.getDescendantsOfKind(d.CallExpression)){const a=nn(o);if(a===void 0)continue;const c=P(a.options,"includeDeleted");if(c===void 0)continue;const l=i.isTrueLiteral(c),u=!l&&U(c);!l&&!u||r.push({exportName:K(e)??e.getName(),file:t,fromArgs:u,hardcodedTrue:l,line:o.getStartLineNumber(),table:a.table,visibility:n.visibility})}return r},cf=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of V(r))s.push(...af(a,o))}return s},lf=new Set(["query","unsafe"]),df=e=>!i.isPropertyAccessExpression(e)||!lf.has(e.getName())?!1:$(e.getExpression(),["sql"]),uf=e=>i.isBinaryExpression(e)||i.isTemplateExpression(e),ff=(e,t)=>{if(!df(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!uf(s)))return{file:t,line:s.getStartLineNumber(),scope:h(e)}},gf=(e,t)=>I(e,t,ff),pf=[["convex",["convex","@convex-dev/"]],["supabase",["@supabase/"]],["firebase",["firebase","@firebase/","firebase-admin"]]],mf=e=>{for(const[t,s]of pf)for(const n of s)if(e===n||e.startsWith(n.endsWith("/")?n:`${n}/`))return t},hf=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const o of r.getImportDeclarations()){const a=o.getModuleSpecifierValue(),c=mf(a);c!==void 0&&s.push({file:w(t,n),line:o.getStartLineNumber(),moduleSpecifier:a,platform:c})}}return s},vf=new Set(["createMultipartUpload","delete","download","generateUploadUrl","get","getMetadata","getPresignedUrl","getSignedUrl","getUrl","head","put","resumeMultipartUpload","store","upload"]),Ef=(e,t,s=[])=>{const n=Ue(e,t,{argIndex:0,matchReceiver:r=>r==="ctx.storage"||r.startsWith("ctx.storage."),methods:vf,requireUnmodifiedReach:!0});return xt(n,s)},xf=new Map([["generateUploadUrl",1],["getPresignedUrl",1],["getSignedUrl",1],["store",2],["upload",2]]),Sf=e=>e&&i.isNumericLiteral(e)?Number(e.getText()):void 0,yf=e=>{if(e===void 0)return{analyzable:!0,presentKeys:[]};if(!i.isObjectLiteralExpression(e))return{analyzable:!1,presentKeys:[]};const t=[];let s,n=!1;for(const r of e.getProperties()){if(i.isSpreadAssignment(r)){n=!0;continue}if(i.isPropertyAssignment(r)){const o=y(r);t.push(o),o==="expiresInSeconds"&&(s=Sf(r.getInitializer()));continue}(i.isShorthandPropertyAssignment(r)||i.isMethodDeclaration(r))&&t.push(y(r))}return{analyzable:!n,expiresInSeconds:s,presentKeys:t}},Af=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName(),s=xf.get(t);return s===void 0?void 0:Xs(e.getExpression(),r=>r==="ctx.storage"||r.startsWith("ctx.storage."))?{method:t,optionsIndex:s}:void 0},bf=(e,t)=>{const s=Af(e.getExpression());if(s!==void 0)return{scope:h(e),file:t,line:e.getStartLineNumber(),method:s.method,...yf(e.getArguments()[s.optionsIndex])}},Nf=(e,t)=>I(e,t,bf),Pf=(e,t)=>{const s=Dr(t.target);return{...s===void 0?{}:{platform:s},analytics:e.analytics||t.dependencies.has("@lunora/bindings"),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"),mail:e.mail||t.dependencies.has("@lunora/mail"),notifications:e.notify||t.dependencies.has("@lunora/notify"),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:t.vectorStoreSupported&&t.vectorIndexCount>0,workflows:e.workflows||t.workflowCount>0||t.dependencies.has("@lunora/workflow")}},wf=new Set(["delete","hardDelete","patch","replace","restore"]),If=new Set(["insertMany","insertManyUnsafe","patchWhere"]),Cf=new Set(["delete","deleteMany","hardDelete","insert","insertMany","patch","patchMany","replace","restore","upsert","upsertMany"]),Fs=(e,t)=>{const s=e.getNonNullableType().getProperty("__table")?.getTypeAtLocation(t);if(s===void 0)return[];const n=s.isUnion()?s.getUnionTypes():[s],r=n.map(o=>o.getLiteralValue()).filter(o=>typeof o=="string");return r.length===n.length?r:[]},Tf=(e,t)=>{const s=e.getType();if(t==="deleteMany"||t==="patchMany"){const n=s.getArrayElementType();if(n===void 0)return[];const r=t==="patchMany"?n.getProperty("id")?.getTypeAtLocation(e):n;return r===void 0?[]:Fs(r,e)}return Fs(s,e)},Ds="",Of=(e,t)=>{if(If.has(e))return{method:e,tables:[t!==void 0&&i.isStringLiteral(t)?t.getLiteralText():Ds]};if(wf.has(e)||e==="deleteMany"||e==="patchMany"){const s=t===void 0?[]:Tf(t,e);return{method:e,tables:s.length===0?[Ds]:s}}},Rf=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;const s=t.getName(),n=t.getExpression();if(_(n))return Of(s,e.getArguments()[0]);if(Cf.has(s)&&i.isPropertyAccessExpression(n)&&_(n.getExpression()))return{method:s,tables:[n.getName()]}},kf=(e,t)=>I(e,t,(s,n)=>{const r=Rf(s);if(r===void 0)return;const o=h(s),a=s.getStartLineNumber();return r.tables.map(c=>({file:n,line:a,method:r.method,scope:o,table:c}))}),Ff=(e,t,s)=>({cacheKey:`procedure_arguments_unreadable:${e}:${t}`,categories:["SCHEMA"],description:"Codegen reads an argument record statically. One built at runtime — a factory call, or a property off a value it cannot follow — has no literal to read, so the generated `FunctionReference` carries only the arguments it could see while the runtime validator still enforces all of them.",detail:`\`${t}\` in \`${e}\` (line ${s.toString()}) declares arguments codegen could not read, so its generated type is missing some of them.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:t,filePath:e,line:s},name:"procedure_arguments_unreadable",remediation:`Declare the arguments as an object literal, or as a \`const\` object literal the chain names — \`const ${t}Args = { … };\` then \`.input(${t}Args)\`. Both resolve; a record returned by a call does not.`,title:"Procedure arguments are missing from the generated type"}),Df=(e,t)=>{if(t===void 0){const s=e.getArguments()[0];if(s===void 0||!i.isObjectLiteralExpression(s)||D(s,"args")===void 0)return!1}return bt(e,t).opaque},Lf=(e,t)=>{const s=[],n=(r,o)=>{const a=r.getInitializer();if(a===void 0||!i.isCallExpression(a))return;const c=H(a);c!==void 0&&Df(a,c.receiver)&&s.push(Ff(t,o,a.getStartLineNumber()))};for(const r of e.getVariableStatements().filter(o=>o.isExported()))for(const o of r.getDeclarations())n(o,o.getName());return s},Mf=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n);r!==void 0&&s.push(...Lf(r,w(t,n)))}return s.toSorted((n,r)=>n.cacheKey.localeCompare(r.cacheKey))},_f=new Map([["AgentDefinition",{call:"defineAgent({ … })",file:"agents"}],["ContainerDefinition",{call:"defineContainer({ … })",file:"containers"}],["QueueDefinition",{call:"defineQueue({ … })",file:"queues",note:"A dropped queue has no caller to fail — its consumer is simply never wired."}],["RegisteredAction",{call:"action.input({ … }).action(handler)"}],["RegisteredLifecycleHook",{call:"onConnect(handler)",note:"Substitute the hook you called: `onConnect`, `onDisconnect` and `onShardInit` share one type, so codegen cannot tell which you wrote. A dropped hook has no caller to fail — it silently never fires."}],["RegisteredMigration",{call:"defineMigration({ … })",note:"A dropped migration never runs, so `lunora migrate up` reports nothing to do."}],["RegisteredMutation",{call:"mutation.input({ … }).mutation(handler)"}],["RegisteredMutator",{call:"defineMutator({ … })",file:"mutators"}],["RegisteredQuery",{call:"query.input({ … }).query(handler)"}],["RegisteredReactor",{call:"onQueryChange(select, handler)",note:"A dropped reactor has no caller to fail — it silently never runs."}],["RegisteredShape",{call:"defineShape({ … })",file:"shapes"}],["RegisteredStream",{call:"query.input({ … }).stream(handler)"}],["RegisteredWhisperAuthorizer",{call:"onWhisper(handler)",note:"A dropped authorizer has no caller to fail — the whisper topics it was meant to gate silently stay open to every socket on the shard."}],["SubscriptionDefinition",{call:"defineSubscription(topic, { … })",file:"queues",note:"A dropped subscription is never published to — its topic's messages simply never reach it."}],["WorkflowDefinition",{call:"defineWorkflow({ … })",file:"workflows"}]]),De=({byName:e,byPath:t},s,n)=>t.has(`${s}:${n}`)||e.has(n),Ln=e=>!e.isAny(),Mn=e=>{const t=e.getType();if(!Ln(t))return;const s=t.getAliasSymbol()?.getName()??t.getSymbol()?.getName(),n=s===void 0?void 0:_f.get(s);return n===void 0||s===void 0?void 0:{...n,typeName:s}},Kf=e=>{const t=e.getInitializer();return t===void 0?!1:i.isCallExpression(t)||i.isIdentifier(t)||i.isPropertyAccessExpression(t)},_n={cause:"codegen recognises a registration only when the initializer is the registering call itself, and this one comes from a factory or an alias",remediation:"A factory that returns a registration cannot be read statically — inline it, or export what the factory builds."},zf=e=>({cause:`codegen reads this kind of registration only from \`lunora/${e}.ts\`, and this is a different module`,remediation:`Move it into \`lunora/${e}.ts\` — the declaration itself is fine.`}),Bf={cause:"it is exported only under a string name that is not an identifier, which the generated `api.ts` and dispatch table cannot address as `<module>.<name>`",remediation:"Export it under an identifier name as well (or instead)."},$f=new Set(["AgentDefinition","ContainerDefinition","QueueDefinition","RegisteredShape","SubscriptionDefinition","WorkflowDefinition"]),Uf={cause:"it is exported only as `default` or under a reserved word, and this kind's name becomes an import binding and a generated class / binding name, where that is a syntax error",remediation:"Export it under a plain identifier: `export const <name> = …` (an extra `export default <name>` is fine)."},Vf=(e,t,s)=>{if(!t.some(r=>xr(r)))return Bf;const n=e.getVariableStatement()?.hasExportKeyword()===!0;return $f.has(s.typeName)&&!n&&!t.some(r=>xi(r))?Uf:_n},Kn=(e,t,s,n,r)=>{const{call:o,file:a,note:c,typeName:l}=s,u=a!==void 0&&e!==a?a:void 0,p=u===void 0?r:zf(u),f=c===void 0?p.remediation:`${c} ${p.remediation}`;return{cacheKey:`procedure_not_registered:${e}:${t}`,categories:["SCHEMA"],description:"Codegen registers an export only when its initializer is literally the registering call and the module exports it under an identifier name — by the `export` keyword, a local `export { … }`, or `export default`. Written any other way it exists at runtime but never reaches the generated output — `_generated/api.ts` for a procedure, the lifecycle manifest for a hook or reactor — so a caller cannot address it and a hook never fires.",detail:`\`${t}\` in \`${e}\` (line ${n.toString()}) has type \`${l}\` but was not registered — ${p.cause}.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:t,filePath:e,line:n,typeName:l},name:"procedure_not_registered",remediation:u===void 0?`Assign the registration directly: \`export const ${t} = ${o};\`. ${f}`:f,title:"Procedure exists at runtime but is missing from the generated API"}},jf=(e,t,s)=>{const n=[];for(const r of V(e)){const o=i.isIdentifier(r.getNameNode())?ot(r):[r.getName()],c=o.some(u=>De(s,t,u))||!Kf(r)?void 0:Mn(r),[l=r.getName()]=o;c!==void 0&&n.push(Kn(t,l,c,r.getStartLineNumber(),Vf(r,o,c)))}return n},qf=(e,t,s)=>{if(De(s,t,"default"))return[];const n=[];for(const r of e.getExportAssignments().filter(o=>!o.isExportEquals()&&!i.isIdentifier(o.getExpression()))){const o=Mn(r.getExpression());o!==void 0&&n.push(Kn(t,"default",o,r.getStartLineNumber(),_n))}return n},Wf=(e,t,s)=>[...jf(e,t,s),...qf(e,t,s)],Hf=(e,t,s)=>e.getVariableStatements().flatMap(n=>n.getDeclarations()).filter(n=>i.isIdentifier(n.getNameNode())).filter(n=>ot(n).some(r=>De(s,t,r))).filter(n=>{const r=n.getInitializer();return r!==void 0&&i.isCallExpression(r)&&i.isPropertyAccessExpression(r.getExpression())}).map(n=>{const r=ot(n).find(o=>De(s,t,o))??n.getName();return{declaration:n,exportName:r,relativePath:t}}),Gf=({exportName:e,relativePath:t})=>({cacheKey:"procedure_type_check_unavailable",categories:["SCHEMA"],description:"Codegen cross-checks every export in `lunora/` against its TYPE to catch a procedure the syntactic scan dropped — a factory-assigned export, an alias, a separate `export { … }`. That check needs the type checker to resolve `@lunora/server`; when it cannot, the check reports nothing regardless of what the code does.",detail:`Type resolution for \`lunora/\` is unavailable — the registered procedure \`${e}\` in \`${t}\` types as \`any\`, as does every other one — so codegen cannot tell you when an export is dropped from \`_generated/api.ts\`. A dropped procedure will surface as \`Property '<name>' does not exist\` at its call site instead.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:e,filePath:t},name:"procedure_type_check_unavailable",remediation:`Check what codegen sees: \`${e}\` should have a procedure type, not \`any\`. It needs a \`tsconfig.json\` at or above \`lunora/\` — the one codegen finds walking up from there, which is not necessarily the one your editor uses — resolving \`lunorash\` / \`@lunora/server\` to declarations that exist on disk (a workspace dependency has to be built first).`,title:"Codegen cannot type-check `lunora/`, so dropped procedures go unreported"}),Yf=(e,t,s)=>{const n=[],r=[];for(const a of E(t)){const c=e.getSourceFile(a);if(c===void 0)continue;const l=w(t,a);n.push(...Wf(c,l,s)),r.push(...Hf(c,l,s))}const[o]=r;return o!==void 0&&r.every(({declaration:a})=>!Ln(a.getType()))&&n.push(Gf(o)),n.toSorted((a,c)=>a.cacheKey.localeCompare(c.cacheKey))},Qf=new Set(["when","where"]),it=new Set(["definePolicy","defineShape"]),Xf=e=>{if(!i.isCallExpression(e))return;const t=e.getExpression();if(i.isPropertyAccessExpression(t)){const n=t.getName();return it.has(n)?n:void 0}if(!i.isIdentifier(t))return;for(const n of t.getSymbol()?.getDeclarations()??[])if(i.isImportSpecifier(n)){const r=n.getNameNode().getText();return it.has(r)?r:void 0}const s=t.getText();return it.has(s)?s:void 0},Jf=e=>i.isObjectLiteralExpression(e)&&e.getProperties().length===0,zn=e=>{if(e!==void 0){if(i.isReturnStatement(e)&&e.getExpression()===void 0||e.getKind()===d.UndefinedKeyword||e.getText()==="undefined")return"undefined";if(Jf(e))return"empty-object";if(i.isParenthesizedExpression(e))return zn(e.getExpression())}},Pt=e=>e.getAncestors().find(t=>i.isArrowFunction(t)||i.isFunctionExpression(t)||i.isFunctionDeclaration(t)),Zf=e=>e.getDescendantsOfKind(d.ReturnStatement).filter(t=>Pt(t)===e),Bn=e=>e.getDescendantsOfKind(d.ConditionalExpression).filter(t=>Pt(t)===e),eg=e=>{const t=Zf(e);return t.length>1?!0:t.some(s=>s.getFirstAncestorByKind(d.IfStatement)!==void 0)||Bn(e).length>0},tg=e=>e.getDescendantsOfKind(d.IfStatement).filter(t=>Pt(t)===e),ht=e=>e.getKind()===d.NullKeyword||e.getKind()===d.FalseKeyword||i.isIdentifier(e)&&e.getText()==="undefined"?!0:i.isNumericLiteral(e)?e.getLiteralValue()===0:i.isStringLiteral(e)&&e.getLiteralValue()==="",sg=(e,t)=>ht(e)||ht(t),ng=new Map([[d.EqualsEqualsEqualsToken,"positive"],[d.EqualsEqualsToken,"positive"],[d.ExclamationEqualsEqualsToken,"negative"],[d.ExclamationEqualsToken,"negative"]]),Ls=e=>!ht(e)&&(i.isLiteralExpression(e)||e.getKind()===d.TrueKeyword),rg=(e,t,s)=>{const n=ng.get(e);if(n!==void 0)return sg(t,s)?n==="positive"?"negative":"positive":Ls(t)||Ls(s)?void 0:n},de=e=>{if(i.isParenthesizedExpression(e))return de(e.getExpression());if(i.isPrefixUnaryExpression(e)&&e.getOperatorToken()===d.ExclamationToken)return"negative";if(i.isBinaryExpression(e)){const t=e.getOperatorToken().getKind(),s=rg(t,e.getLeft(),e.getRight());if(s!==void 0)return s;if(t===d.AmpersandAmpersandToken||t===d.BarBarToken){const n=de(e.getLeft()),r=de(e.getRight());return n===r?n:"indeterminate"}}return i.isIdentifier(e)||i.isPropertyAccessExpression(e)||i.isElementAccessExpression(e)||i.isCallExpression(e)?"positive":"indeterminate"},Ms=e=>{if(e!==void 0){if(i.isReturnStatement(e))return e;if(i.isBlock(e)){const t=e.getStatements().at(-1);return t!==void 0&&i.isReturnStatement(t)?t:void 0}}},ig=e=>{if(e.getElseStatement()!==void 0)return;const t=e.getNextSiblingIfKind(d.ReturnStatement);return t!==void 0&&t.getNextSibling()===void 0?t:void 0},og=e=>i.isReturnStatement(e)?e.getExpression()??e:e,ag=e=>{const t=[];for(const s of Bn(e)){const n=de(s.getCondition());n==="positive"?t.push(s.getWhenFalse()):n==="negative"&&t.push(s.getWhenTrue())}for(const s of tg(e)){const n=de(s.getExpression());if(n==="indeterminate")continue;const r=n==="negative"?Ms(s.getThenStatement()):Ms(s.getElseStatement())??ig(s);r!==void 0&&t.push(og(r))}return t},cg=e=>{for(const t of e.getAncestors())if(i.isVariableDeclaration(t)){const s=t.getNameNode();if(i.isIdentifier(s))return s.getText()}return"<anonymous>"},lg=(e,t,s)=>{if(!i.isCallExpression(e))return[];const[n]=e.getArguments();if(!n||!i.isObjectLiteralExpression(n))return[];const r=[];for(const o of n.getProperties()){if(!i.isPropertyAssignment(o)||!Qf.has(y(o)))continue;const a=o.getInitializer();if(!(!a||!(i.isArrowFunction(a)||i.isFunctionExpression(a)))&&eg(a))for(const c of ag(a)){const l=zn(c);l!==void 0&&r.push({exportName:cg(e),file:s,form:l,key:y(o),line:c.getStartLineNumber(),owner:t})}}return r},dg=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression)){const r=Xf(n);r!==void 0&&s.push(...lg(n,r,t))}return s},ug=(e,t)=>{const s=[];for(const n of E(t)){const r=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...dg(r,w(t,n)))}return s},fg=new Set(["query","upsert","upsertNow"]),gg=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();if(fg.has(t))return $(e.getExpression(),["vectors"])?t:void 0},pg=(e,t)=>{const s=gg(e.getExpression());if(s===void 0)return;const n=e.getArguments()[1];if(!n)return;const r=P(n,"namespace");if(!(!r||!U(r)||ee(r)))return{scope:h(e),file:t,line:e.getStartLineNumber(),method:s}},mg=(e,t)=>I(e,t,pg),hg=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"},vg=e=>{const t=e.getArguments()[0];return t&&i.isStringLiteral(t)?t.getLiteralText():""},Eg=(e,t)=>I(e,t,(s,n)=>hg(s)?{file:n,line:s.getStartLineNumber(),scope:h(s),workflow:vg(s)}:void 0),xg=".lunora-schema.json",vt=(e,t)=>{T(e)&&zs(e,"utf8")===t||Xn(e,t,"utf8")},Sg=(e,t)=>{if(t===""){Jn(e,{force:!0});return}vt(e,t)},yg=e=>{const t=S(e,"package.json");if(T(t))try{const s=JSON.parse(zs(t,"utf8"));return typeof s.version=="string"&&s.version!==""?s.version:void 0}catch{return}},Ag=()=>{const e=process.env.LUNORA_CODEGEN_TIMING;return e!==void 0&&e!==""},bg=e=>{let t=T(e)?e:Ne(e);for(;t&&t!==Ne(t);){const s=S(t,"tsconfig.json");if(T(s))return s;t=Ne(t)}},_s=e=>e.replaceAll("\\","/"),Ng=(e,t,s)=>{if(s&&e.length>0){const o=e.map(a=>`"${a.exportName}"`).join(", ");throw new W("MASK_UNSUPPORTED",`This project declares a \`mask(...)\` policy whose argument isn't a plain object literal (e.g. \`mask(sharedPolicies)\` referencing a hoisted variable), or contains a spread (\`...shared\`) or computed key (\`[name]:\`) codegen can't enumerate, so codegen can't tell which columns it masks. Because the project also declares replication shape(s) (${o}), codegen can't verify none of them replicate a table that policy masks — inline every table and column as literal keys so codegen can verify it, or remove the affected shape(s).`,{status:422})}const n=new Map;for(const o of t.columns){const a=n.get(o.table)??[];a.push(o.column),n.set(o.table,a)}const r=t.columns.length>0;for(const o of e){if(o.table===void 0){if(r)throw new W("MASK_UNSUPPORTED",`defineShape "${o.exportName}" has a non-literal \`table\` (a variable or expression, not a string literal), so codegen can't statically verify it doesn't replicate a table that masks a column. This project masks at least one column elsewhere, so the combination can't be proven safe — change "${o.exportName}"'s \`table\` to a plain string literal so codegen can verify it, or remove the mask(s) on the table it targets.`,{status:422});continue}const a=n.get(o.table);if(a===void 0)continue;const c=a.map(l=>`"${l}"`).join(", ");throw new W("MASK_UNSUPPORTED",`defineShape "${o.exportName}" replicates table "${o.table}", which masks column(s) ${c} on at least one procedure. A shape runs no procedure, so \`.use(mask(...))\` never applies to its replicated rows — remove the shape, unmask the table, or wait for shape-masking support.`,{status:422})}},Le=(e,t,s)=>{const n=e.getSourceFile(t);if(n===void 0){e.createSourceFile(t,s,{overwrite:!0});return}n.getFullText()!==s&&n.replaceWithText(s)},Ks=(e,t,s)=>e.getSourceFile(t)?.getFullText()===s,Pg=8,wg=e=>{const{agents:t,apiPath:s,generatedFunctionsPath:n,lunoraDirectory:r,migrations:o,project:a,shapes:c,usesSandbox:l,useUmbrella:u,workflows:p}=e,f=()=>Yr(()=>{const N=Qr(a,r),k=ii(a,r);return{functions:N,httpRoutes:Xr(a,r),mutators:k}});let{erased:m,value:{functions:x,httpRoutes:z,mutators:B}}=f();ts([...x,...B].map(N=>N.filePath)),ts(z.filter(N=>N.stream).map(N=>N.filePath),"http-stream");for(let N=1;;N+=1){const k=Ci({agents:t,functions:x,httpRoutes:z,mutators:B,useUmbrella:u,workflows:p}),j=zi({agents:t,functions:x,migrations:o,mutators:B,shapes:c,useUmbrella:u,usesSandbox:l});if(N>=Pg||Ks(a,s,k)&&Ks(a,n,j))return{apiContent:k,erased:m,functions:x,functionsContent:j,httpRoutes:z,mutators:B};Le(a,s,k),Le(a,n,j),{erased:m,value:{functions:x,httpRoutes:z,mutators:B}}=f()}},Ig=e=>{const t=bg(e);return t?new Qt({skipAddingFilesFromTsConfig:!1,tsConfigFilePath:t,useInMemoryFileSystem:!1}):new Qt({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1})},$p=(e,t)=>{const s=E(t),n=S(t,"schema.ts");T(n)&&s.push(n);for(const c of s){const l=e.getSourceFile(c);l===void 0?e.addSourceFileAtPath(c):l.refreshFromFileSystemSync()}const r=new Set(s.map(c=>_s(c))),o=_s(t),a=`${o}/`;for(const c of e.getSourceFiles()){const l=c.getFilePath();(l===o||l.startsWith(a))&&!r.has(l)&&e.removeSourceFile(c)}for(const c of e.getSourceFiles()){const l=c.getFilePath();if(!(l===o||l.startsWith(a)||l.includes("/node_modules/")))try{c.refreshFromFileSystemSync()}catch{e.removeSourceFile(c)}}},Up=e=>{const t=Ag(),s=t?Xe.now():0,n=S(e.projectRoot,e.lunoraDirectory??"lunora"),r=S(n,"schema.ts");if(!T(r))throw new W("INTERNAL",`schema.ts not found at ${r}`);const o=e.project??Ig(n);Ur(Pc);const a=gi(o,r,e.projectRoot),{agents:c,capabilities:l,containers:u,crons:p,dataModelContent:f,dependencies:m,entryCronTriggers:x,env:z,featureUsage:B,hasFlags:N,hasNotify:k,identity:j,platformGate:G,queues:F,serverContent:te,services:oe,storageRulesMetadata:ae,topics:se,usesSandbox:he,useUmbrella:q,workflows:L}=Do({lunoraDirectory:n,project:o,projectRoot:e.projectRoot,schema:a,target:e.target});ll(a,a.jurisdiction===void 0?void 0:al(o,n)),ro(a,B.artifacts);const M=S(n,"_generated"),O=S(M,"dataModel.ts"),$n=S(M,"server.ts"),Un=S(M,"api.ts"),Vn=S(M,"functions.ts");Le(o,O,f),Le(o,$n,te);const ve=ti(o,n),ne=Ei(o,n),{apiContent:wt,erased:jn,functions:Y,functionsContent:It,httpRoutes:Ve,mutators:Ee}=wg({agents:c,apiPath:Un,generatedFunctionsPath:Vn,lunoraDirectory:n,migrations:ve,project:o,shapes:ne,useUmbrella:q,usesSandbox:he,workflows:L}),Ct=nr(o,n),je=rr(Ct,a,[...Y,...Ve].map(g=>g.filePath)),xe=Ct.length>0,X=e.lint===!1&&!xe?void 0:{inserts:Zr(o,n),queries:li(o,n),tableWrites:kf(o,n),workflowCalls:Eg(o,n)},Se=e.lint===!1||X===void 0?void 0:tr({adminRoutes:Uo(o,n),aiRawRuns:Xo(o,n),aiToolSideEffects:ca(o,n),argumentDerivedFetches:ua(o,n),argumentValidators:ya(o,n),authApiCalls:Vr(o,n),authConfigs:Ra(o,n),browserUrlAccesses:La(o,n),configCalls:Ga(o,n),containerKeyAccesses:Qa(o,n),containerOverrides:sc(o,n),containers:u,exportSinks:oc(o,n),staleMigrationImports:hf(o,n),failOpenGuards:uc(o,n),flagReads:Sc(o,n),flagSecurityDefaults:Nc(o,n),geoIndexUsages:Cc(o,n),httpActionGuards:Bc(o,n),httpHeaderWrites:Qc(o,n),hyperdriveCalls:Jr(o,n),identityClaimReads:sl(o,n),imageDeliveryUrlAccesses:rl(o,n),inserts:X.inserts,kvKeyAccesses:ul(o,n,Y),mailRecipientAccesses:hl(o,n),maskProcedures:ei(o,n),maskStrategies:Nl(o,n),mutatorWrites:Ol(o,n),nondeterministicCalls:oi(o,n),normalizeIdAuthorizations:ql(o,n),notifyCalls:ci(o,n),notifyConfig:ai(o,n),mutators:Ee,ownerFieldWrites:kd(o,n,Y,Ee),unrestrictedWhereBranches:ug(o,n),paymentWebhooks:Bd(o,n),privilegedDispatches:Xd(o,n),procedureProtections:Du(o,n),queries:X.queries,queues:F,r2sqlCalls:di(o,n),ratelimitKeySelectors:$u(o,n),rawRowReturns:Gu(o,n),relationLoads:Xu(o,n),rlsProcedures:ui(o,n),schema:a,secretLiterals:of(o,n),modules:je,shapes:ne,softDeleteReads:cf(o,n),sqlInterpolations:gf(o,n),storageKeyAccesses:Ef(o,n,Y),storageUploads:Nf(o,n),tableWrites:X.tableWrites,vectorNamespaceAccesses:mg(o,n),workflowCalls:X.workflowCalls,workflows:L,wranglerVariables:e.wranglerVariables}),Tt=Se===void 0?[]:$i(e.projectRoot,[...Zn(Se,{source:"static"}),...Yf(o,n,{byName:new Set([...L,...F,...c,...u].map(g=>g.exportName)),byPath:new Set([...Y,...Ee,...ne,...ve].map(g=>`${g.filePath}:${g.exportName}`))}),...Mf(o,n),...Gr(jn,n)]),qn=fi(o,n),Ot=yl(o,n);Ng(ne,Ot,xl(o,n));const Wn=N?mc(o,n):[],qe=G.signals.vectorStore!==!1,ce=Pf(B,{containerCount:u.length,cronCount:p.length,dependencies:m,hasPaymentTables:Ld(a.tables),queueCount:F.length,storageColumnCount:Object.keys(Qs(a)).length,storageRuleCount:ae.rules.length,vectorIndexCount:a.vectorIndexes.length,target:Ys(e.projectRoot,e.target),vectorStoreSupported:qe,workflowCount:L.length}),Rt=t?Xe.now():0,We=Pi(a,ve.map(g=>g.id)),kt=Lr({advisories:Tt.filter(g=>g.name!=="procedure_type_check_unavailable"),advisorProcedures:Se?.procedureProtections??[],agents:c,capabilities:l,containers:u,env:z,flagKeys:Wn,hasFlags:N,hasNotify:k,hasVectors:qe,maskMetadata:Ot,mutators:Ee,queues:F,rlsMetadata:qn,schema:a,schemaSnapshot:We,shapes:ne,services:oe,storageRules:ae,studioFeatures:ce,topics:se,useUmbrella:q,workflows:L}),Ft=wi(ne,m.has("@lunora/db"),q),Dt=Ti(u,a.jurisdiction),Lt=Oi(L),Mt=Ri(c),_t=ki(F),Kt=Fi(p),Hn=Di(ce.scheduler),Gn=Li(a.tables,q),zt=Mi(a.vectorIndexes),ye=Ki(a,q),Bt=Ii(m.has("@lunora/seed")),Ae=e.apiSpec??"openapi",He=Ae==="openapi"||Ae==="both",Ge=Ae==="openrpc"||Ae==="both",$t=Si({capabilities:l,emailAgents:c.filter(g=>g.onEmail===!0).map(g=>({className:g.className,exportName:g.exportName})),hasAccess:m.has("@lunora/cloudflare-access"),hasAuth:m.has("@lunora/auth"),hasFramework:m.has("@lunora/astro")||m.has("@lunora/svelte")||m.has("@lunora/vue")||T(S(e.projectRoot,"src","worker.ts")),hasGlobal:a.tables.some(g=>Bs(g)),hasHyperdriveGlobal:a.tables.some(g=>$s(g)),hasKvIntrospector:ce.kv,hasNotify:k,hasQueue:F.some(g=>g.mode==="push"),hasScheduler:ce.scheduler,hasSourcedTables:a.tables.some(g=>g.externalSource!==void 0),hasStorage:ce.storage,hasVectors:qe,hasWorkflow:L.length>0,identity:j,jurisdiction:a.jurisdiction,jurisdictionPinsAuth:a.jurisdictionPinsAuth===!0,tables:a.tables.map(g=>({name:g.name,shardMode:g.shardMode})),useUmbrella:q,vectorIndexCount:a.vectorIndexes.length,voiceAgents:c.filter(g=>g.voice===!0&&g.voiceBindingName!==void 0).map(g=>({bindingName:g.voiceBindingName,exportName:g.exportName})),wantsArchitecture:xe,wantsOpenApi:He,wantsOpenRpc:Ge}),Ut=yg(e.projectRoot),Vt=xe?je:[],jt=yi({functions:Y,httpRoutes:Ve,modules:Vt,version:Ut}),qt=bi({functions:Y,modules:Vt,version:Ut}),Wt=`${JSON.stringify(jt,void 0,2)}
9
+ `,Ht=`${JSON.stringify(qt,void 0,2)}
10
+ `,be=xe&&X!==void 0?so({...X,callEdges:Ba(o,n),crons:p,functions:Y,httpRoutes:Ve,modules:je,queues:F,schema:a,services:oe,topics:se,workflows:L}):void 0,Gt=Ai(jt),Yt=Ni(qt),Ye=S(n,xg),Yn=T(Ye),Qe=[];if(!e.dryRun){T(M)||Qn(M,{recursive:!0});const g=(J,re)=>{vt(S(M,J),re),Qe.push(J)},C=(J,re)=>{Sg(S(M,J),re),re!==""&&Qe.push(J)};g("app.ts",$t),g("dataModel.ts",f),g("api.ts",wt),g("server.ts",te),g("functions.ts",It),g("shard.ts",kt),g("crons.ts",Kt),g("vectors.ts",zt),g("drizzle.global.ts",ye.global),g("drizzle.shard.ts",ye.shard),C("containers.ts",Dt),C("workflows.ts",Lt),C("agents.ts",Mt),C("queues.ts",_t),C("scheduler.ts",Hn),C("shardRegistry.ts",Gn),C("seed.ts",Bt),C("collections.ts",Ft),C("openapi.json",He?Wt:""),C("openapi.ts",He?Gt:""),C("openrpc.json",Ge?Ht:""),C("openrpc.ts",Ge?Yt:""),C("architecture.json",be===void 0?"":`${JSON.stringify(be,void 0,2)}
11
+ `),C("architecture.ts",be===void 0?"":no(be)),(!Yn||e.updateSchemaBaseline===!0)&&vt(Ye,er(We))}if(t){const g=Xe.now(),C=Math.round(g-s),J=Math.round(Rt-s),re=Math.round(g-Rt);console.error(`@lunora/codegen: codegen took ${C.toString()}ms (discovery ${J.toString()}ms, emit ${re.toString()}ms)`)}return{advisories:Tt,advisorContext:Se,agents:c,containers:u,cronTriggers:[...new Set([..._i(p),...x])],generated:{agents:Mt,api:wt,app:$t,collections:Ft,containers:Dt,crons:Kt,dataModel:f,drizzleGlobal:ye.global,drizzleShard:ye.shard,functions:It,openApi:Wt,openApiModule:Gt,openRpc:Ht,openRpcModule:Yt,queues:_t,seed:Bt,server:te,shard:kt,vectors:zt,workflows:Lt},migrations:ve,outputDirectory:M,platformDiagnostics:G.diagnostics,queues:F,schemaSnapshot:We,schemaSnapshotPath:Ye,workflows:L,writtenFiles:Qe}};export{xg as SCHEMA_SNAPSHOT_FILENAME,Ig as createCodegenProject,bg as findTsconfig,$p as refreshCodegenProject,Up as runCodegen};
@@ -1 +1 @@
1
- import{existsSync as m}from"node:fs";import{join as u}from"node:path";import{SyntaxKind as p,Node as o}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as f}from"./module-specifiers-WF8iAydP.mjs";import{p as d}from"./parse-validator-B4mFs19C.mjs";import{findObjectProperty as l}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as S}from"./attribution-sW_DHmLO.mjs";const h="shapes.ts",b=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineShape";for(const e of t.getDeclarations())if(o.isImportSpecifier(e))return f(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineShape":!1;return!1},x=r=>{const t=r.getSymbol();if(!t)return!1;for(const e of t.getDeclarations()){if(!o.isNamespaceImport(e))continue;const i=e.getFirstAncestorByKind(p.ImportDeclaration);return i!==void 0&&f(i.getModuleSpecifierValue())}return!1},y=r=>{if(o.isIdentifier(r))return b(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineShape"&&o.isIdentifier(t)&&x(t)}return!1},N=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return;const e=l(t,"table");if(!e||!o.isPropertyAssignment(e))return;const i=e.getInitializer();return i&&o.isStringLiteral(i)?i.getLiteralValue():void 0},E=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return{};const e=l(t,"args");if(!e||!o.isPropertyAssignment(e))return{};const i=e.getInitializer();return!i||!o.isObjectLiteralExpression(i)?{}:d(i)},I=r=>{const t=[];for(const e of r.getVariableDeclarations()){const i=e.getInitializer();if(i?.getKind()!==p.CallExpression)continue;const s=i,a=s.getExpression();if(!y(a))continue;const n=e.getNameNode();if(!o.isIdentifier(n)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw g(n,"defineShape exports must be plain named exports (no destructuring)")}const c=S(e,"binding");c!==void 0&&t.push({args:E(s),exportName:c,filePath:"shapes",table:N(s)})}return t},z=(r,t)=>{const e=u(t,h);if(!m(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),s=I(i);return s.sort((a,n)=>a.exportName.localeCompare(n.exportName)),s};export{h as SHAPES_FILENAME,z as discoverShapes};
1
+ import{existsSync as m}from"node:fs";import{join as u}from"node:path";import{SyntaxKind as p,Node as o}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as f}from"./module-specifiers-WF8iAydP.mjs";import{p as d}from"./parse-validator-B4mFs19C.mjs";import{findObjectProperty as l}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as S}from"./attribution-JcwxPpyK.mjs";const h="shapes.ts",b=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineShape";for(const e of t.getDeclarations())if(o.isImportSpecifier(e))return f(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineShape":!1;return!1},x=r=>{const t=r.getSymbol();if(!t)return!1;for(const e of t.getDeclarations()){if(!o.isNamespaceImport(e))continue;const i=e.getFirstAncestorByKind(p.ImportDeclaration);return i!==void 0&&f(i.getModuleSpecifierValue())}return!1},y=r=>{if(o.isIdentifier(r))return b(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineShape"&&o.isIdentifier(t)&&x(t)}return!1},N=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return;const e=l(t,"table");if(!e||!o.isPropertyAssignment(e))return;const i=e.getInitializer();return i&&o.isStringLiteral(i)?i.getLiteralValue():void 0},E=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return{};const e=l(t,"args");if(!e||!o.isPropertyAssignment(e))return{};const i=e.getInitializer();return!i||!o.isObjectLiteralExpression(i)?{}:d(i)},I=r=>{const t=[];for(const e of r.getVariableDeclarations()){const i=e.getInitializer();if(i?.getKind()!==p.CallExpression)continue;const s=i,a=s.getExpression();if(!y(a))continue;const n=e.getNameNode();if(!o.isIdentifier(n)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw g(n,"defineShape exports must be plain named exports (no destructuring)")}const c=S(e,"binding");c!==void 0&&t.push({args:E(s),exportName:c,filePath:"shapes",table:N(s)})}return t},z=(r,t)=>{const e=u(t,h);if(!m(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),s=I(i);return s.sort((a,n)=>a.exportName.localeCompare(n.exportName)),s};export{h as SHAPES_FILENAME,z as discoverShapes};
@@ -1 +1 @@
1
- import{existsSync as b}from"node:fs";import{join as y}from"node:path";import{LunoraError as w}from"@lunora/errors";import{isValidCronExpression as k}from"@lunora/scheduler";import{workflowDefaultName as E,workflowClassName as v}from"@lunora/workflow";import{Node as n,VariableDeclarationKind as S,SyntaxKind as x}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as N,findObjectProperty as d,stringPropertyFor as L}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as P}from"./attribution-sW_DHmLO.mjs";import{r as $}from"./handler-reference-C1oBljnl.mjs";const A="workflows.ts",W=new Set(["do","sleep","sleepUntil","waitForEvent"]),C=o=>{const e=o.getSymbol();if(!e)return o.getText()==="defineWorkflow";for(const t of e.getDeclarations())if(n.isImportSpecifier(t))return t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/workflow"?!1:t.getNameNode().getText()==="defineWorkflow";return!1},m=L("workflow"),O=(o,e,t)=>{if(n.isNumericLiteral(o))return o.getLiteralValue();throw c(o,`workflow "${e}": \`${t}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},f=(o,e)=>{const t=d(o,e);return t&&n.isPropertyAssignment(t)?t.getInitializerOrThrow():void 0},g=(o,e,t)=>{if(n.isObjectLiteralExpression(o))return o;throw c(o,`workflow "${e}": \`${t}\` must be an inline object literal — it is deploy configuration codegen writes into wrangler.jsonc`)},D=(o,e)=>{if(!n.isArrayLiteralExpression(o)||o.getElements().length===0)throw c(o,`workflow "${e}": \`schedules\` must be a non-empty inline array of cron expression string literals`);return o.getElements().map(t=>{const r=m(t,e,"schedules[]");if(!k(r))throw c(t,`workflow "${e}": schedule "${r}" is not a valid cron expression`);return r})},I=(o,e)=>{const t={},r=f(o,"schedules");r!==void 0&&(t.schedules=D(r,e));const s=f(o,"limits");if(s!==void 0){const i=f(g(s,e,"limits"),"steps");if(i===void 0)t.limits={};else{const l=O(i,e,"limits.steps");if(!Number.isInteger(l)||l<=0)throw c(i,`workflow "${e}": \`limits.steps\` must be a positive integer (got ${String(l)})`);t.limits={steps:l}}}const a=f(o,"defaultRetention");if(a!==void 0){const i=g(a,e,"defaultRetention"),l={};for(const u of["errorRetention","successRetention"]){const p=f(i,u);p!==void 0&&(l[u]=m(p,e,`defaultRetention.${u}`))}t.defaultRetention=l}return t},F=o=>{const e=o.getExpression();if(!n.isPropertyAccessExpression(e)||!W.has(e.getName()))return!1;const t=e.getExpression();return n.isPropertyAccessExpression(t)&&t.getName()==="step"?!0:n.isIdentifier(t)&&t.getText()==="step"},T=o=>{if(!o)return[];const e=[];for(const t of o.getDescendantsOfKind(x.CallExpression)){if(!F(t))continue;const r=t.getArguments()[0];!r||!(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))||e.push({line:t.getStartLineNumber(),method:t.getExpression().getName(),name:r.getLiteralValue()})}return e},h=o=>{let e=o;for(;e&&(n.isAsExpression(e)||n.isSatisfiesExpression(e)||n.isParenthesizedExpression(e));)e=e.getExpression();return e},R=o=>{const e=h(o);if(e&&n.isObjectLiteralExpression(e))return e;if(!(!e||!n.isIdentifier(e)))for(const t of e.getSymbol()?.getDeclarations()??[]){const s=n.isVariableDeclaration(t)&&t.getVariableStatement()?.getDeclarationKind()===S.Const?h(t.getInitializer()):void 0;if(s&&n.isObjectLiteralExpression(s))return s}},j=(o,e)=>{const t=d(o,"handler"),r=$(t,e);return r!==void 0?r:{body:t!==void 0&&n.isPropertyAssignment(t)?t.getInitializer():t}},K=(o,e,t)=>{const r=R(o.getArguments()[0]);if(!r)throw c(o,`workflow "${e}": defineWorkflow's argument must be an object literal, or a local \`const\` holding one — codegen reads \`name\` and the \`ctx.step.*\` calls out of it statically. Keep the handler wherever you like and pass it through: \`const config = { handler: myHandler }; export const ${e} = defineWorkflow(config);\`.`);const s=j(r,t),a={className:v(e),exportName:e,name:E(e),steps:T(s.body),...s.file===void 0?{}:{handlerFile:s.file},...s.site===void 0?{}:{handlerSite:s.site}},i=d(r,"name");return i&&n.isPropertyAssignment(i)&&(a.name=m(i.getInitializerOrThrow(),e,"name")),{...a,...I(r,e)}},V=(o,e)=>{const t=[];for(const r of o.getVariableDeclarations()){const s=N(r.getInitializer());if(!s)continue;const a=s.getExpression();if(!n.isIdentifier(a)||!C(a))continue;const i=r.getNameNode();if(!n.isIdentifier(i)){if(r.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw c(i,"defineWorkflow exports must be plain named exports (no destructuring)")}const l=P(r,"binding");l!==void 0&&t.push(K(s,l,e))}return t},z=o=>{const e=new Map,t=new Map;for(const r of o){const s=e.get(r.name);if(s!==void 0)throw new w("DUPLICATE_WORKFLOW_NAME",`Duplicate workflow name "${r.name}": produced by both "${s}" and "${r.exportName}". Deployed workflow names must be unique across the project.`,{status:500});e.set(r.name,r.exportName);const a=t.get(r.className);if(a!==void 0)throw new w("DUPLICATE_WORKFLOW_CLASS",`Duplicate workflow class "${r.className}": produced by both "${a}" and "${r.exportName}". Workflow export names must yield unique generated class names.`,{status:500});t.set(r.className,r.exportName)}},Y=(o,e)=>{const t=y(e,A);if(!b(t))return[];const r=o.getSourceFile(t)??o.addSourceFileAtPath(t),s=V(r,e);return s.sort((a,i)=>a.exportName.localeCompare(i.exportName)),z(s),s};export{A as WORKFLOWS_FILENAME,Y as discoverWorkflows};
1
+ import{existsSync as b}from"node:fs";import{join as y}from"node:path";import{LunoraError as w}from"@lunora/errors";import{isValidCronExpression as k}from"@lunora/scheduler";import{workflowDefaultName as E,workflowClassName as v}from"@lunora/workflow";import{Node as n,VariableDeclarationKind as S,SyntaxKind as x}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as N,findObjectProperty as d,stringPropertyFor as L}from"./listLunoraSourceFiles-DRes9d5p.mjs";import{a as P}from"./attribution-JcwxPpyK.mjs";import{r as $}from"./handler-reference-Dzp5GZ5p.mjs";const A="workflows.ts",W=new Set(["do","sleep","sleepUntil","waitForEvent"]),C=o=>{const e=o.getSymbol();if(!e)return o.getText()==="defineWorkflow";for(const t of e.getDeclarations())if(n.isImportSpecifier(t))return t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/workflow"?!1:t.getNameNode().getText()==="defineWorkflow";return!1},m=L("workflow"),O=(o,e,t)=>{if(n.isNumericLiteral(o))return o.getLiteralValue();throw c(o,`workflow "${e}": \`${t}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},f=(o,e)=>{const t=d(o,e);return t&&n.isPropertyAssignment(t)?t.getInitializerOrThrow():void 0},g=(o,e,t)=>{if(n.isObjectLiteralExpression(o))return o;throw c(o,`workflow "${e}": \`${t}\` must be an inline object literal — it is deploy configuration codegen writes into wrangler.jsonc`)},D=(o,e)=>{if(!n.isArrayLiteralExpression(o)||o.getElements().length===0)throw c(o,`workflow "${e}": \`schedules\` must be a non-empty inline array of cron expression string literals`);return o.getElements().map(t=>{const r=m(t,e,"schedules[]");if(!k(r))throw c(t,`workflow "${e}": schedule "${r}" is not a valid cron expression`);return r})},I=(o,e)=>{const t={},r=f(o,"schedules");r!==void 0&&(t.schedules=D(r,e));const s=f(o,"limits");if(s!==void 0){const i=f(g(s,e,"limits"),"steps");if(i===void 0)t.limits={};else{const l=O(i,e,"limits.steps");if(!Number.isInteger(l)||l<=0)throw c(i,`workflow "${e}": \`limits.steps\` must be a positive integer (got ${String(l)})`);t.limits={steps:l}}}const a=f(o,"defaultRetention");if(a!==void 0){const i=g(a,e,"defaultRetention"),l={};for(const u of["errorRetention","successRetention"]){const p=f(i,u);p!==void 0&&(l[u]=m(p,e,`defaultRetention.${u}`))}t.defaultRetention=l}return t},F=o=>{const e=o.getExpression();if(!n.isPropertyAccessExpression(e)||!W.has(e.getName()))return!1;const t=e.getExpression();return n.isPropertyAccessExpression(t)&&t.getName()==="step"?!0:n.isIdentifier(t)&&t.getText()==="step"},T=o=>{if(!o)return[];const e=[];for(const t of o.getDescendantsOfKind(x.CallExpression)){if(!F(t))continue;const r=t.getArguments()[0];!r||!(n.isStringLiteral(r)||n.isNoSubstitutionTemplateLiteral(r))||e.push({line:t.getStartLineNumber(),method:t.getExpression().getName(),name:r.getLiteralValue()})}return e},h=o=>{let e=o;for(;e&&(n.isAsExpression(e)||n.isSatisfiesExpression(e)||n.isParenthesizedExpression(e));)e=e.getExpression();return e},R=o=>{const e=h(o);if(e&&n.isObjectLiteralExpression(e))return e;if(!(!e||!n.isIdentifier(e)))for(const t of e.getSymbol()?.getDeclarations()??[]){const s=n.isVariableDeclaration(t)&&t.getVariableStatement()?.getDeclarationKind()===S.Const?h(t.getInitializer()):void 0;if(s&&n.isObjectLiteralExpression(s))return s}},j=(o,e)=>{const t=d(o,"handler"),r=$(t,e);return r!==void 0?r:{body:t!==void 0&&n.isPropertyAssignment(t)?t.getInitializer():t}},K=(o,e,t)=>{const r=R(o.getArguments()[0]);if(!r)throw c(o,`workflow "${e}": defineWorkflow's argument must be an object literal, or a local \`const\` holding one — codegen reads \`name\` and the \`ctx.step.*\` calls out of it statically. Keep the handler wherever you like and pass it through: \`const config = { handler: myHandler }; export const ${e} = defineWorkflow(config);\`.`);const s=j(r,t),a={className:v(e),exportName:e,name:E(e),steps:T(s.body),...s.file===void 0?{}:{handlerFile:s.file},...s.site===void 0?{}:{handlerSite:s.site}},i=d(r,"name");return i&&n.isPropertyAssignment(i)&&(a.name=m(i.getInitializerOrThrow(),e,"name")),{...a,...I(r,e)}},V=(o,e)=>{const t=[];for(const r of o.getVariableDeclarations()){const s=N(r.getInitializer());if(!s)continue;const a=s.getExpression();if(!n.isIdentifier(a)||!C(a))continue;const i=r.getNameNode();if(!n.isIdentifier(i)){if(r.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw c(i,"defineWorkflow exports must be plain named exports (no destructuring)")}const l=P(r,"binding");l!==void 0&&t.push(K(s,l,e))}return t},z=o=>{const e=new Map,t=new Map;for(const r of o){const s=e.get(r.name);if(s!==void 0)throw new w("DUPLICATE_WORKFLOW_NAME",`Duplicate workflow name "${r.name}": produced by both "${s}" and "${r.exportName}". Deployed workflow names must be unique across the project.`,{status:500});e.set(r.name,r.exportName);const a=t.get(r.className);if(a!==void 0)throw new w("DUPLICATE_WORKFLOW_CLASS",`Duplicate workflow class "${r.className}": produced by both "${a}" and "${r.exportName}". Workflow export names must yield unique generated class names.`,{status:500});t.set(r.className,r.exportName)}},Y=(o,e)=>{const t=y(e,A);if(!b(t))return[];const r=o.getSourceFile(t)??o.addSourceFileAtPath(t),s=V(r,e);return s.sort((a,i)=>a.exportName.localeCompare(i.exportName)),z(s),s};export{A as WORKFLOWS_FILENAME,Y as discoverWorkflows};
@@ -0,0 +1 @@
1
+ import{byCodepoint as w,callSiteCallers as k}from"@lunora/advisor";import{Node as r,SyntaxKind as p,VariableDeclarationKind as M,ts as O}from"ts-morph";import{i as F}from"./reserved-words-CW1QFbTd.mjs";import{isWriteTarget as T}from"./listLunoraSourceFiles-DRes9d5p.mjs";const N=new WeakMap,A=e=>e.getStatements().flatMap(t=>r.isFunctionDeclaration(t)?[t]:r.isVariableStatement(t)?t.getDeclarations().filter(o=>r.isIdentifier(o.getNameNode())):[]),x=e=>r.isStringLiteral(e)?e.getLiteralValue():e.getText(),V=e=>{if(r.isFunctionDeclaration(e)||r.isClassDeclaration(e)){const t=e.getName();return e.hasExportKeyword()?[[t??"default",e.hasDefaultKeyword()?"default":t??"default"]]:[]}return!r.isVariableStatement(e)||!e.hasExportKeyword()?[]:e.getDeclarations().flatMap(t=>{const o=t.getNameNode();return r.isIdentifier(o)?[[o.getText(),o.getText()]]:o.getDescendantsOfKind(p.BindingElement).flatMap(n=>r.isIdentifier(n.getNameNode())?[[n.getName(),n.getName()]]:[])})},P=e=>{if(r.isExportDeclaration(e))return e.hasModuleSpecifier()||e.isTypeOnly()?[]:e.getNamedExports().filter(o=>!o.isTypeOnly()).map(o=>{const n=x(o.getNameNode()),s=o.getAliasNode();return[n,s===void 0?n:x(s)]});const t=r.isExportAssignment(e)&&!e.isExportEquals()?e.getExpression():void 0;return r.isIdentifier(t)?[[t.getText(),"default"]]:V(e)},h=new WeakMap,C=e=>{const t=h.get(e.compilerNode);if(t!==void 0)return t;const o=new Map;for(const[s,c]of e.getStatements().flatMap(i=>P(i)))o.set(s,(o.get(s)??new Set).add(c));const n=new Map([...o].map(([s,c])=>[s,[...c].toSorted(q)]));return h.set(e.compilerNode,n),n},g=e=>{const t=r.isBindingElement(e)?e.getFirstAncestorByKind(p.VariableStatement):void 0,o=r.isVariableDeclaration(e)?e.getVariableStatement():void 0,n=r.isFunctionDeclaration(e)?e:t??o;if(n===void 0||!r.isSourceFile(n.getParent()))return[];const s=r.isFunctionDeclaration(e)?e.getName()??"default":e.getName();return C(e.getSourceFile()).get(s)??[]},I=e=>new Map(e.flatMap(t=>{const o=g(t);return o.length===0?[]:[[t.compilerNode,o]]})),y=(e,t)=>{for(const o of e.getAncestors()){if(r.isExportAssignment(o)&&!o.isExportEquals())return{kind:"export",name:"default"};if((r.isFunctionDeclaration(o)&&r.isSourceFile(o.getParent())||r.isVariableDeclaration(o)&&r.isSourceFile(o.getVariableStatement()?.getParent())&&r.isIdentifier(o.getNameNode()))&&(r.isFunctionDeclaration(o)||r.isVariableDeclaration(o))){const s=t.get(o.compilerNode)?.[0];return s===void 0?{declaration:o,kind:"helper"}:{kind:"export",name:s}}}return{kind:"untracked"}},b=e=>{for(const t of e.getAncestors()){if(r.isExpressionWithTypeArguments(t)){const o=t.getParent();return!(r.isHeritageClause(o)&&o.getToken()===p.ExtendsKeyword&&(r.isClassDeclaration(o.getParent())||r.isClassExpression(o.getParent())))}if(O.isTypeNode(t.compilerNode))return!0}return!1},Z=e=>{const t=e.getParent(),o=r.isPropertyAccessExpression(t)&&t.getNameNode()===e,n=(r.isPropertyAssignment(t)||r.isMethodDeclaration(t))&&t.getNameNode()===e;return!o&&!n&&!b(e)},E=e=>{const t=e.getParent();return r.isShorthandPropertyAssignment(t)&&t.getNameNode()===e?t.getValueSymbol():e.getSymbol()},K=e=>{const t=E(e);return t?.getValueDeclaration()??t?.getDeclarations()[0]},S=new WeakMap,L=/\/typescript\/lib\/lib\.[^/]+\.d\.ts$/u,B=e=>{const t=e.getFilePath();return e.isDeclarationFile()&&(L.test(t)||t.includes("/@types/node/"))},J=e=>{const t=e.getNameNode(),o=r.isFunctionDeclaration(e)?void 0:e.getFirstAncestorByKind(p.VariableDeclarationList);if(!r.isIdentifier(t)||o?.getDeclarationKind()===M.Const||B(e.getSourceFile()))return!1;let n=S.get(e.compilerNode);if(n===void 0){const s=r.isFunctionDeclaration(e)?e.getSourceFile():e.getFirstAncestor(i=>r.isFunctionLikeDeclaration(i)||r.isArrowFunction(i))??e.getSourceFile(),c=t.getText();n=s.getDescendantsOfKind(p.Identifier).some(i=>i!==t&&i.getText()===c&&T(i)&&K(i)?.compilerNode===e.compilerNode),S.set(e.compilerNode,n)}return n},R=e=>{const t=new Map,o=new Set,n=new Set;for(const s of e){const c=s.getNameNode(),i=c?.getSymbol()?.compilerSymbol;c!==void 0&&i!==void 0&&(t.set(i,s.compilerNode),o.add(c.compilerNode),n.add(c.getText()))}return{bySymbol:t,nameNodes:o,spellings:n}},$=(e,t,o)=>{const{bySymbol:n,nameNodes:s,spellings:c}=R(t),i=new Map;for(const a of e.getDescendantsOfKind(p.Identifier)){if(!c.has(a.getText())||s.has(a.compilerNode)||b(a))continue;const l=E(a)?.compilerSymbol,d=l===void 0?void 0:n.get(l);d!==void 0&&i.set(d,[...i.get(d)??[],y(a,o)])}return i},_=(e,t)=>{const o=new Map(e.map(a=>[a.compilerNode,new Set])),n=new Set,s=a=>(o.get(a)?.size??0)+(n.has(a)?1:0),c=(a,l)=>{const d=s(a),m=o.get(a),u=l.kind==="helper"?l.declaration.compilerNode:void 0;l.kind==="export"&&m?.add(l.name);for(const v of u===void 0?[]:o.get(u)??[])m?.add(v);return(l.kind==="untracked"||u!==void 0&&n.has(u))&&n.add(a),s(a)!==d};let i=!0;for(;i;){i=!1;for(const[a,l]of t)for(const d of l)i=c(a,d)||i}return new Map([...o].map(([a,l])=>[a,{callers:[...l].toSorted((d,m)=>d.localeCompare(m)),untracked:n.has(a)}]))},W=e=>{const t=N.get(e.compilerNode);if(t!==void 0)return t;const o=A(e),n=I(o),s=o.filter(i=>!n.has(i.compilerNode)),c={exportNames:n,helperReach:s.length===0?new Map:_(s,$(e,s,n))};return N.set(e.compilerNode,c),c},Q=e=>{const t=W(e.getSourceFile()),o=y(e,t.exportNames);switch(o.kind){case"export":return{kind:"export",name:o.name};case"helper":{const n=o.declaration.getName(),s=t.helperReach.get(o.declaration.compilerNode);if(n===void 0||s===void 0)throw new Error(`call-site attribution: helper at ${o.declaration.getSourceFile().getFilePath()} is not indexed`);return{callers:s.callers,kind:"helper",name:n,...s.untracked?{untracked:!0}:{}}}default:return{kind:"module"}}},H=(e,t)=>{const o=k(e).map(s=>t(s));return o.includes("public")?"public":o.length===0||o.includes(void 0)||e.kind==="helper"&&e.untracked===!0?void 0:"internal"},U=(e,t)=>{const o=new Map(t.map(n=>[`${n.filePath}:${n.exportName}`,n.visibility]));return e.map(n=>{const s=H(n.scope,c=>o.get(`${n.file}:${c}`));return s===void 0?n:{...n,visibility:s}})},f=/^[$A-Z_a-z][\w$]*$/u,D=e=>f.test(e),z=e=>{const t=g(e);return t.length===0?r.isVariableDeclaration(e)&&e.getVariableStatement()?.hasExportKeyword()===!0?e.getName():void 0:t.find(o=>D(o))??e.getName()},ee=e=>e.getVariableStatements().flatMap(t=>t.getDeclarations()).filter(t=>z(t)!==void 0),te=(e,t)=>{if(r.isIdentifier(e.getNameNode()))return e.getVariableStatement()?.hasExportKeyword()===!0?e.getName():g(e).find(o=>t==="binding"?F(o):D(o))},q=(e,t)=>Number(f.test(t))-Number(f.test(e))||w(e,t);export{te as a,ee as b,Q as c,z as d,C as e,K as f,J as g,Z as h,D as i,g as j,b as k,B as l,E as r,U as w};