@lunora/codegen 1.0.0-alpha.355 → 1.0.0-alpha.357

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 (45) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/packem_shared/{GENERATED_HEADER-BXK9A_wP.mjs → GENERATED_HEADER-BPc7maFN.mjs} +1 -1
  3. package/dist/packem_shared/{MUTATORS_FILENAME-Cy9h3EVW.mjs → MUTATORS_FILENAME-qrKFa1I1.mjs} +1 -1
  4. package/dist/packem_shared/{NOTIFY_FILENAME-9to_l_Kh.mjs → NOTIFY_FILENAME-Dj7fObvj.mjs} +1 -1
  5. package/dist/packem_shared/{OPENRPC_VERSION-DfSmacMR.mjs → OPENRPC_VERSION-CoJWSPHr.mjs} +1 -1
  6. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-Ia0lAKbR.mjs +31 -0
  7. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs +2 -0
  8. package/dist/packem_shared/{SHAPES_FILENAME-DVJbfDZ8.mjs → SHAPES_FILENAME-CFpyCOh2.mjs} +1 -1
  9. package/dist/packem_shared/{SchemaSnapshotParseError-H9eQX4ui.mjs → SchemaSnapshotParseError-CjKSMuex.mjs} +1 -1
  10. package/dist/packem_shared/{buildOpenApiDocument-DWdj2jvW.mjs → buildOpenApiDocument-ecVsBXVh.mjs} +1 -1
  11. package/dist/packem_shared/{context-property-calls-dFjpeIlP.mjs → context-property-calls-FpBfosw3.mjs} +1 -1
  12. package/dist/packem_shared/{context-root-CNR6TAsP.mjs → context-root-BAeDnkKU.mjs} +1 -1
  13. package/dist/packem_shared/{database-calls-UPlhi3Ks.mjs → database-calls-Dohiwd-7.mjs} +1 -1
  14. package/dist/packem_shared/{discoverFunctions-CJG4S6CK.mjs → discoverFunctions-C_Y8PWMi.mjs} +1 -1
  15. package/dist/packem_shared/{discoverHttpRoutes-DCDgDIYv.mjs → discoverHttpRoutes-D_b2SrdD.mjs} +1 -1
  16. package/dist/packem_shared/discoverHyperdriveCalls-CV6bPCIa.mjs +1 -0
  17. package/dist/packem_shared/{discoverInserts-BcoTjXqI.mjs → discoverInserts-C9DSRPCl.mjs} +1 -1
  18. package/dist/packem_shared/discoverMaskProcedures-rLz_2bHY.mjs +1 -0
  19. package/dist/packem_shared/{discoverQueries-CxQRVuIV.mjs → discoverQueries-BOuUa0Nl.mjs} +1 -1
  20. package/dist/packem_shared/discoverR2sqlCalls-BlnIOBxe.mjs +1 -0
  21. package/dist/packem_shared/{discoverRlsProcedures-Cl6UKT7L.mjs → discoverRlsProcedures-Dnl0WCtW.mjs} +1 -1
  22. package/dist/packem_shared/{discoverSchema-CGAFQxFU.mjs → discoverSchema-uxcH-Jy6.mjs} +1 -1
  23. package/dist/packem_shared/{emitAgents--VDKoet4.mjs → emitAgents-CwwzVPZe.mjs} +1 -1
  24. package/dist/packem_shared/{emitApi-zynTVppI.mjs → emitApi-DP9KFbgH.mjs} +1 -1
  25. package/dist/packem_shared/{emitApp-C0shqv7S.mjs → emitApp-CT7iAjam.mjs} +1 -1
  26. package/dist/packem_shared/{emitCrons-DF9vt_z_.mjs → emitCrons-CY8IQfAI.mjs} +1 -1
  27. package/dist/packem_shared/{emitDataModel-CuFqq97x.mjs → emitDataModel-Bba2y2yt.mjs} +1 -1
  28. package/dist/packem_shared/{emitDrizzleSchema-bct1OuH5.mjs → emitDrizzleSchema-CD4hPtUP.mjs} +1 -1
  29. package/dist/packem_shared/{emitFunctions-D7mopPiT.mjs → emitFunctions-D5ItlRW-.mjs} +1 -1
  30. package/dist/packem_shared/{emitServer-DqjvPPKJ.mjs → emitServer-cINjWPKS.mjs} +1 -1
  31. package/dist/packem_shared/emitShard-CPRV7dSh.mjs +1 -0
  32. package/dist/packem_shared/{index-CN8FVvr-.mjs → index-BaQeoSqB.mjs} +1 -1
  33. package/dist/packem_shared/{parse-validator-iVTounLK.mjs → parse-validator-CP5CL6Q7.mjs} +1 -1
  34. package/dist/packem_shared/{qualifiers-Bl5fSmav.mjs → qualifiers-vzi-FQv3.mjs} +1 -1
  35. package/dist/packem_shared/{server-DlEPJi5i.mjs → server-CMceLanP.mjs} +5 -5
  36. package/dist/packem_shared/{shard-ByB2lGh0.mjs → shard-gWobaDx2.mjs} +1 -1
  37. package/dist/packem_shared/{shard-runtime-ByYXjCKY.mjs → shard-runtime-DXlpfT3P.mjs} +1 -1
  38. package/dist/packem_shared/{shared-8vTRkL2-.mjs → shared-Br_OnErI.mjs} +1 -1
  39. package/package.json +3 -3
  40. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BQwNonnN.mjs +0 -31
  41. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-C7Um0EnM.mjs +0 -2
  42. package/dist/packem_shared/discoverHyperdriveCalls-CL-d0IVo.mjs +0 -1
  43. package/dist/packem_shared/discoverMaskProcedures-Bw-BOIbA.mjs +0 -1
  44. package/dist/packem_shared/discoverR2sqlCalls-B4oeTYEM.mjs +0 -1
  45. package/dist/packem_shared/emitShard-CYjlTMmT.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as i}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C7Um0EnM.mjs";import{formatAdvisories as f,lintSchema as m,toAdvisorContext as d}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-brcmKenl.mjs";import{CodegenDiagnosticError as A,diagnosticAt as g}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-isdHqPIt.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-C3QumE88.mjs";import{default as I}from"./packem_shared/discoverAuthApiCalls-CScPrUD-.mjs";import{CONTAINERS_FILENAME as F,discoverContainers as L}from"./packem_shared/CONTAINERS_FILENAME-mK4cZpcz.mjs";import{default as P}from"./packem_shared/discoverCrons-B1_NUt19.mjs";import{capabilitiesUsedBy as b,createTargetScope as y,foldCapabilitySignals as U,mayReadCapabilityContext as G,sourceCapabilitySignals as H}from"./packem_shared/capabilitiesUsedBy-DjRHg-Zk.mjs";import{FLAGS_FILENAME as B,discoverFlags as k}from"./packem_shared/FLAGS_FILENAME-BQk3SX8D.mjs";import{default as K}from"./packem_shared/discoverFunctions-CJG4S6CK.mjs";import{default as z}from"./packem_shared/discoverHttpRoutes-DCDgDIYv.mjs";import{default as q}from"./packem_shared/discoverHyperdriveCalls-CL-d0IVo.mjs";import{default as J}from"./packem_shared/discoverInserts-BcoTjXqI.mjs";import{d as X}from"./packem_shared/index-CN8FVvr-.mjs";import{default as $}from"./packem_shared/discoverMigrations-BWxx8Wv9.mjs";import{MUTATORS_FILENAME as re,discoverMutators as oe}from"./packem_shared/MUTATORS_FILENAME-Cy9h3EVW.mjs";import{default as ae}from"./packem_shared/discoverNondeterministicCalls-mFJNU8qY.mjs";import{NOTIFY_FILENAME as se,discoverNotifyCalls as fe,discoverNotifyChannels as me,discoverNotifyConfig as de}from"./packem_shared/NOTIFY_FILENAME-9to_l_Kh.mjs";import{default as ne}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-CxQRVuIV.mjs";import{QUEUES_FILENAME as Se,discoverQueues as Ee}from"./packem_shared/QUEUES_FILENAME-Civ-7SiI.mjs";import{default as Ae}from"./packem_shared/discoverR2sqlCalls-B4oeTYEM.mjs";import{default as ve}from"./packem_shared/discoverRlsProcedures-Cl6UKT7L.mjs";import{default as Ne}from"./packem_shared/discoverRlsMetadata-D0B4nCmG.mjs";import{discoverSandboxUsage as Re}from"./packem_shared/discoverSandboxUsage--Z1vx7GM.mjs";import{default as he}from"./packem_shared/discoverSchema-CGAFQxFU.mjs";import{readServiceBindings as _e,resolveServiceBindings as Fe}from"./packem_shared/readServiceBindings-BA49C6aN.mjs";import{SHAPES_FILENAME as Me,discoverShapes as Pe}from"./packem_shared/SHAPES_FILENAME-DVJbfDZ8.mjs";import{default as be}from"./packem_shared/discoverStorageRulesMetadata-CitX6ziW.mjs";import{WORKFLOWS_FILENAME as Ue,discoverWorkflows as Ge}from"./packem_shared/WORKFLOWS_FILENAME-kXq07aGl.mjs";import{emitApp as je}from"./packem_shared/emitApp-C0shqv7S.mjs";import{isD1GlobalTable as ke,isHyperdriveGlobalTable as We}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ve,emitOpenApi as ze,emitOpenApiModule as Qe}from"./packem_shared/buildOpenApiDocument-DWdj2jvW.mjs";import{OPENRPC_VERSION as we,buildOpenRpcDocument as Je,emitOpenRpc as Ye,emitOpenRpcModule as Xe}from"./packem_shared/OPENRPC_VERSION-DfSmacMR.mjs";import{DEFAULT_TARGET as $e,platformMatrixIds as er,readProjectTarget as rr,resolveCodegenTarget as or}from"./packem_shared/DEFAULT_TARGET-3OLdJhTj.mjs";import{loadProjectConfig as ar,readProjectConfigLiterals as ir}from"./packem_shared/loadProjectConfig-B7RmxIeD.mjs";import{PROJECT_CONFIG_FILENAMES as fr,findCodegenConfigFile as mr,findProjectConfigFile as dr,projectConfigCandidatePaths as pr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as cr,runCodegen as lr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-BQwNonnN.mjs";import{SchemaSnapshotParseError as Sr,buildSchemaSnapshot as Er,evaluateSchemaDrift as ur,parseSchemaSnapshot as Ar}from"./packem_shared/SchemaSnapshotParseError-H9eQX4ui.mjs";import{default as vr}from"./packem_shared/fingerprintSchemaSources-BKXkgkj4.mjs";import{schemaFromIr as Nr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as Rr,validatorIrToJsonSchema as Tr}from"./packem_shared/LUNORA_ERROR_CODES-CIAJQeKB.mjs";import{SDK_LANGUAGES as Ir,SDK_TARGETS as _r,generateSdk as Fr}from"./sdk/index.mjs";import{redact as Mr,secretKindOf as Pr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as br}from"./packem_shared/emitDrizzleSchema-bct1OuH5.mjs";import{e as Ur}from"./packem_shared/server-DlEPJi5i.mjs";import{e as Hr}from"./packem_shared/shard-ByB2lGh0.mjs";import{G as Br}from"./packem_shared/shared-8vTRkL2-.mjs";import{MESSAGE_SOLUTIONS as Wr,findSolutionByMessage as Kr}from"@lunora/errors";import{createCodegenProject as zr,findTsconfig as Qr,refreshCodegenProject as qr,tsconfigFingerprint as wr}from"./packem_shared/createCodegenProject-ClPr_MXM.mjs";import{s as Yr,t as Xr,u as Zr}from"./packem_shared/shard-runtime-ByYXjCKY.mjs";import{emitApi as eo,emitCollections as ro,emitInternalApi as oo}from"./packem_shared/emitApi-zynTVppI.mjs";import{emitCrons as ao,emitScheduler as io,emitVectors as so,emitWranglerCronTriggers as fo}from"./packem_shared/emitCrons-DF9vt_z_.mjs";import{emitDataModel as po}from"./packem_shared/emitDataModel-CuFqq97x.mjs";import{emitFunctions as co}from"./packem_shared/emitFunctions-D7mopPiT.mjs";import{isTypedSchema as xo}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,F as CONTAINERS_FILENAME,A as CodegenDiagnosticError,$e as DEFAULT_TARGET,B as FLAGS_FILENAME,Br as GENERATED_HEADER,Rr as LUNORA_ERROR_CODES,Wr as LUNORA_SOLUTION_RULES,re as MUTATORS_FILENAME,se as NOTIFY_FILENAME,we as OPENRPC_VERSION,fr as PROJECT_CONFIG_FILENAMES,Se as QUEUES_FILENAME,cr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Ir as SDK_LANGUAGES,_r as SDK_TARGETS,Me as SHAPES_FILENAME,Sr as SchemaSnapshotParseError,e as VERSION,Ue as WORKFLOWS_FILENAME,Ve as buildOpenApiDocument,Je as buildOpenRpcDocument,Er as buildSchemaSnapshot,b as capabilitiesUsedBy,zr as createCodegenProject,y as createTargetScope,n as describeErrorLevelFindings,g as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,I as discoverAuthApiCalls,L as discoverContainers,P as discoverCrons,k as discoverFlags,K as discoverFunctions,z as discoverHttpRoutes,q as discoverHyperdriveCalls,J as discoverInserts,X as discoverMaskProcedures,$ as discoverMigrations,oe as discoverMutators,ae as discoverNondeterministicCalls,fe as discoverNotifyCalls,me as discoverNotifyChannels,de as discoverNotifyConfig,le as discoverQueries,Ee as discoverQueues,Ae as discoverR2sqlCalls,Ne as discoverRlsMetadata,ve as discoverRlsProcedures,Re as discoverSandboxUsage,he as discoverSchema,Pe as discoverShapes,be as discoverStorageRulesMetadata,Ge as discoverWorkflows,Yr as emitAgents,eo as emitApi,je as emitApp,ro as emitCollections,Xr as emitContainers,ao as emitCrons,po as emitDataModel,br as emitDrizzleSchema,co as emitFunctions,oo as emitInternalApi,ze as emitOpenApi,Qe as emitOpenApiModule,Ye as emitOpenRpc,Xe as emitOpenRpcModule,io as emitScheduler,Ur as emitServer,Hr as emitShard,so as emitVectors,Zr as emitWorkflows,fo as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,ur as evaluateSchemaDrift,mr as findCodegenConfigFile,Kr as findLunoraSolution,dr as findProjectConfigFile,Qr as findTsconfig,vr as fingerprintSchemaSources,U as foldCapabilitySignals,f as formatAdvisories,Fr as generateSdk,ke as isD1GlobalTable,We as isHyperdriveGlobalTable,R as isTestPath,xo as isTypedSchema,m as lintSchema,T as listLunoraSourceFiles,ar as loadProjectConfig,G as mayReadCapabilityContext,Ar as parseSchemaSnapshot,er as platformMatrixIds,pr as projectConfigCandidatePaths,ne as readPackageDependencies,ir as readProjectConfigLiterals,rr as readProjectTarget,_e as readServiceBindings,Mr as redact,qr as refreshCodegenProject,or as resolveCodegenTarget,Fe as resolveServiceBindings,lr as runCodegen,Nr as schemaFromIr,Pr as secretKindOf,i as serializeSchemaSnapshot,x as sortedUniqueNames,H as sourceCapabilitySignals,d as toAdvisorContext,wr as tsconfigFingerprint,Tr as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as a,serializeSchemaSnapshot as i}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs";import{formatAdvisories as f,lintSchema as m,toAdvisorContext as d}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-brcmKenl.mjs";import{CodegenDiagnosticError as A,diagnosticAt as g}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-isdHqPIt.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-C3QumE88.mjs";import{default as I}from"./packem_shared/discoverAuthApiCalls-CScPrUD-.mjs";import{CONTAINERS_FILENAME as F,discoverContainers as L}from"./packem_shared/CONTAINERS_FILENAME-mK4cZpcz.mjs";import{default as P}from"./packem_shared/discoverCrons-B1_NUt19.mjs";import{capabilitiesUsedBy as b,createTargetScope as y,foldCapabilitySignals as U,mayReadCapabilityContext as G,sourceCapabilitySignals as H}from"./packem_shared/capabilitiesUsedBy-DjRHg-Zk.mjs";import{FLAGS_FILENAME as B,discoverFlags as k}from"./packem_shared/FLAGS_FILENAME-BQk3SX8D.mjs";import{default as K}from"./packem_shared/discoverFunctions-C_Y8PWMi.mjs";import{default as z}from"./packem_shared/discoverHttpRoutes-D_b2SrdD.mjs";import{default as q}from"./packem_shared/discoverHyperdriveCalls-CV6bPCIa.mjs";import{default as J}from"./packem_shared/discoverInserts-C9DSRPCl.mjs";import{d as X}from"./packem_shared/index-BaQeoSqB.mjs";import{default as $}from"./packem_shared/discoverMigrations-BWxx8Wv9.mjs";import{MUTATORS_FILENAME as re,discoverMutators as oe}from"./packem_shared/MUTATORS_FILENAME-qrKFa1I1.mjs";import{default as ae}from"./packem_shared/discoverNondeterministicCalls-mFJNU8qY.mjs";import{NOTIFY_FILENAME as se,discoverNotifyCalls as fe,discoverNotifyChannels as me,discoverNotifyConfig as de}from"./packem_shared/NOTIFY_FILENAME-Dj7fObvj.mjs";import{default as ne}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-BOuUa0Nl.mjs";import{QUEUES_FILENAME as Se,discoverQueues as Ee}from"./packem_shared/QUEUES_FILENAME-Civ-7SiI.mjs";import{default as Ae}from"./packem_shared/discoverR2sqlCalls-BlnIOBxe.mjs";import{default as ve}from"./packem_shared/discoverRlsProcedures-Dnl0WCtW.mjs";import{default as Ne}from"./packem_shared/discoverRlsMetadata-D0B4nCmG.mjs";import{discoverSandboxUsage as Re}from"./packem_shared/discoverSandboxUsage--Z1vx7GM.mjs";import{default as he}from"./packem_shared/discoverSchema-uxcH-Jy6.mjs";import{readServiceBindings as _e,resolveServiceBindings as Fe}from"./packem_shared/readServiceBindings-BA49C6aN.mjs";import{SHAPES_FILENAME as Me,discoverShapes as Pe}from"./packem_shared/SHAPES_FILENAME-CFpyCOh2.mjs";import{default as be}from"./packem_shared/discoverStorageRulesMetadata-CitX6ziW.mjs";import{WORKFLOWS_FILENAME as Ue,discoverWorkflows as Ge}from"./packem_shared/WORKFLOWS_FILENAME-kXq07aGl.mjs";import{emitApp as je}from"./packem_shared/emitApp-CT7iAjam.mjs";import{isD1GlobalTable as ke,isHyperdriveGlobalTable as We}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ve,emitOpenApi as ze,emitOpenApiModule as Qe}from"./packem_shared/buildOpenApiDocument-ecVsBXVh.mjs";import{OPENRPC_VERSION as we,buildOpenRpcDocument as Je,emitOpenRpc as Ye,emitOpenRpcModule as Xe}from"./packem_shared/OPENRPC_VERSION-CoJWSPHr.mjs";import{DEFAULT_TARGET as $e,platformMatrixIds as er,readProjectTarget as rr,resolveCodegenTarget as or}from"./packem_shared/DEFAULT_TARGET-3OLdJhTj.mjs";import{loadProjectConfig as ar,readProjectConfigLiterals as ir}from"./packem_shared/loadProjectConfig-B7RmxIeD.mjs";import{PROJECT_CONFIG_FILENAMES as fr,findCodegenConfigFile as mr,findProjectConfigFile as dr,projectConfigCandidatePaths as pr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as cr,runCodegen as lr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-Ia0lAKbR.mjs";import{SchemaSnapshotParseError as Sr,buildSchemaSnapshot as Er,evaluateSchemaDrift as ur,parseSchemaSnapshot as Ar}from"./packem_shared/SchemaSnapshotParseError-CjKSMuex.mjs";import{default as vr}from"./packem_shared/fingerprintSchemaSources-BKXkgkj4.mjs";import{schemaFromIr as Nr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as Rr,validatorIrToJsonSchema as Tr}from"./packem_shared/LUNORA_ERROR_CODES-CIAJQeKB.mjs";import{SDK_LANGUAGES as Ir,SDK_TARGETS as _r,generateSdk as Fr}from"./sdk/index.mjs";import{redact as Mr,secretKindOf as Pr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as br}from"./packem_shared/emitDrizzleSchema-CD4hPtUP.mjs";import{e as Ur}from"./packem_shared/server-CMceLanP.mjs";import{e as Hr}from"./packem_shared/shard-gWobaDx2.mjs";import{G as Br}from"./packem_shared/shared-Br_OnErI.mjs";import{MESSAGE_SOLUTIONS as Wr,findSolutionByMessage as Kr}from"@lunora/errors";import{createCodegenProject as zr,findTsconfig as Qr,refreshCodegenProject as qr,tsconfigFingerprint as wr}from"./packem_shared/createCodegenProject-ClPr_MXM.mjs";import{s as Yr,t as Xr,u as Zr}from"./packem_shared/shard-runtime-DXlpfT3P.mjs";import{emitApi as eo,emitCollections as ro,emitInternalApi as oo}from"./packem_shared/emitApi-DP9KFbgH.mjs";import{emitCrons as ao,emitScheduler as io,emitVectors as so,emitWranglerCronTriggers as fo}from"./packem_shared/emitCrons-CY8IQfAI.mjs";import{emitDataModel as po}from"./packem_shared/emitDataModel-Bba2y2yt.mjs";import{emitFunctions as co}from"./packem_shared/emitFunctions-D5ItlRW-.mjs";import{isTypedSchema as xo}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,F as CONTAINERS_FILENAME,A as CodegenDiagnosticError,$e as DEFAULT_TARGET,B as FLAGS_FILENAME,Br as GENERATED_HEADER,Rr as LUNORA_ERROR_CODES,Wr as LUNORA_SOLUTION_RULES,re as MUTATORS_FILENAME,se as NOTIFY_FILENAME,we as OPENRPC_VERSION,fr as PROJECT_CONFIG_FILENAMES,Se as QUEUES_FILENAME,cr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Ir as SDK_LANGUAGES,_r as SDK_TARGETS,Me as SHAPES_FILENAME,Sr as SchemaSnapshotParseError,e as VERSION,Ue as WORKFLOWS_FILENAME,Ve as buildOpenApiDocument,Je as buildOpenRpcDocument,Er as buildSchemaSnapshot,b as capabilitiesUsedBy,zr as createCodegenProject,y as createTargetScope,n as describeErrorLevelFindings,g as diagnosticAt,a as diffSchemaSnapshots,N as discoverAgents,I as discoverAuthApiCalls,L as discoverContainers,P as discoverCrons,k as discoverFlags,K as discoverFunctions,z as discoverHttpRoutes,q as discoverHyperdriveCalls,J as discoverInserts,X as discoverMaskProcedures,$ as discoverMigrations,oe as discoverMutators,ae as discoverNondeterministicCalls,fe as discoverNotifyCalls,me as discoverNotifyChannels,de as discoverNotifyConfig,le as discoverQueries,Ee as discoverQueues,Ae as discoverR2sqlCalls,Ne as discoverRlsMetadata,ve as discoverRlsProcedures,Re as discoverSandboxUsage,he as discoverSchema,Pe as discoverShapes,be as discoverStorageRulesMetadata,Ge as discoverWorkflows,Yr as emitAgents,eo as emitApi,je as emitApp,ro as emitCollections,Xr as emitContainers,ao as emitCrons,po as emitDataModel,br as emitDrizzleSchema,co as emitFunctions,oo as emitInternalApi,ze as emitOpenApi,Qe as emitOpenApiModule,Ye as emitOpenRpc,Xe as emitOpenRpcModule,io as emitScheduler,Ur as emitServer,Hr as emitShard,so as emitVectors,Zr as emitWorkflows,fo as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,ur as evaluateSchemaDrift,mr as findCodegenConfigFile,Kr as findLunoraSolution,dr as findProjectConfigFile,Qr as findTsconfig,vr as fingerprintSchemaSources,U as foldCapabilitySignals,f as formatAdvisories,Fr as generateSdk,ke as isD1GlobalTable,We as isHyperdriveGlobalTable,R as isTestPath,xo as isTypedSchema,m as lintSchema,T as listLunoraSourceFiles,ar as loadProjectConfig,G as mayReadCapabilityContext,Ar as parseSchemaSnapshot,er as platformMatrixIds,pr as projectConfigCandidatePaths,ne as readPackageDependencies,ir as readProjectConfigLiterals,rr as readProjectTarget,_e as readServiceBindings,Mr as redact,qr as refreshCodegenProject,or as resolveCodegenTarget,Fe as resolveServiceBindings,lr as runCodegen,Nr as schemaFromIr,Pr as secretKindOf,i as serializeSchemaSnapshot,x as sortedUniqueNames,H as sourceCapabilitySignals,d as toAdvisorContext,wr as tsconfigFingerprint,Tr as validatorIrToJsonSchema};
@@ -1 +1 @@
1
- import{G as n,I as p,a as o,g as d,d as c,h as f,i as m,p as I,r as T,f as y,b as E,c as O,e as A,s as l,u as v,v as P}from"./shared-8vTRkL2-.mjs";import"./parse-validator-iVTounLK.mjs";import"./reserved-words-CW1QFbTd.mjs";import"./LUNORA_ERROR_CODES-CIAJQeKB.mjs";import"./dispatch-namespace-DwTjD7BU.mjs";export{n as GENERATED_HEADER,p as IMPORT_PATH_RE,o as assertIdentifier,d as assertPropertyIdentifier,c as baseSpecifiers,f as isOptionalOnInsert,m as isSensitiveFunction,I as pascalCase,T as renderArgsType,y as renderInsertInterface,E as renderNamespaceTree,O as renderObjectKey,A as renderPropertyKey,l as sensitiveArgNamesOf,v as unwrapOptional,P as validatorToType};
1
+ import{G as n,I as p,a as o,g as d,d as c,h as f,i as m,p as I,r as T,f as y,b as E,c as O,e as A,s as l,u as v,v as P}from"./shared-Br_OnErI.mjs";import"./parse-validator-CP5CL6Q7.mjs";import"./reserved-words-CW1QFbTd.mjs";import"./LUNORA_ERROR_CODES-CIAJQeKB.mjs";import"./dispatch-namespace-DwTjD7BU.mjs";export{n as GENERATED_HEADER,p as IMPORT_PATH_RE,o as assertIdentifier,d as assertPropertyIdentifier,c as baseSpecifiers,f as isOptionalOnInsert,m as isSensitiveFunction,I as pascalCase,T as renderArgsType,y as renderInsertInterface,E as renderNamespaceTree,O as renderObjectKey,A as renderPropertyKey,l as sensitiveArgNamesOf,v as unwrapOptional,P as validatorToType};
@@ -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{b as M}from"./module-specifiers-BctA0m_p.mjs";import{p as A}from"./parse-validator-iVTounLK.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-C3QumE88.mjs";import{j as b,i as D,f as g,d as O}from"./attribution-CG8-kUcl.mjs";import{u as w}from"./unwrap-handler-return-CGdJGvGh.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 b(t).filter(F=>D(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{b as M}from"./module-specifiers-BctA0m_p.mjs";import{p as A}from"./parse-validator-CP5CL6Q7.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-C3QumE88.mjs";import{j as b,i as D,f as g,d as O}from"./attribution-CG8-kUcl.mjs";import{u as w}from"./unwrap-handler-return-CGdJGvGh.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 b(t).filter(F=>D(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 v}from"node:fs";import{join as N}from"node:path";import{SyntaxKind as u,Node as r,VariableDeclarationKind as F}from"ts-morph";import{listLunoraSourceFiles as m,lunoraRelativePath as O,findObjectProperty as g,defaultExportExpression as D,handlerOf as A}from"./isTestPath-C3QumE88.mjs";import{b as I,d as T}from"./attribution-CG8-kUcl.mjs";import{i as l}from"./context-root-CNR6TAsP.mjs";import{c as C}from"./classify-procedure-call-BkaeM9Ej.mjs";const k="notify.ts",L=new Set(["chat","inApp","send","webhook"]),h=new Set(["broadcast","send"]),M=e=>{const s=e.getInitializer();if(!s||!r.isCallExpression(s))return;const t=C(s);if(!t)return;const i=A(s,t.receiver);return i?{exportName:T(e)??e.getName(),handler:i,kind:t.kind}:void 0},x=e=>{const s=[];for(const t of I(e)){const i=M(t);i&&s.push(i)}return s},y=e=>l(e,["notify"])?"notify":l(e,["push"])||l(e,["notify","push"])?"push":void 0,w=e=>{if(!r.isPropertyAccessExpression(e))return;const s=e.getName(),t=y(e.getExpression());if(t==="notify"&&L.has(s))return`ctx.notify.${s}`;if(t==="push"&&h.has(s))return`ctx.push.${s}`},_=e=>r.isPropertyAccessExpression(e)?y(e.getExpression())==="push"&&h.has(e.getName()):!1,Z=(e,s)=>{const t=[];for(const i of m(s)){const n=e.getSourceFile(i)??e.addSourceFileAtPath(i),o=O(s,i);for(const c of x(n))if(!(c.kind!=="query"&&c.kind!=="mutation"))for(const a of c.handler.getDescendantsOfKind(u.PropertyAccessExpression)){const f=w(a);f!==void 0&&t.push({callee:f,exportName:c.exportName,file:o,kind:c.kind,line:a.getStartLineNumber()})}}return t},K=(e,s)=>{for(const t of m(s)){const i=e.getSourceFile(t)??e.addSourceFileAtPath(t);for(const n of x(i))for(const o of n.handler.getDescendantsOfKind(u.PropertyAccessExpression))if(_(o))return!0}return!1},R=new Set(["@lunora/notify"]),U=e=>{const s=e.getSymbol();if(!s)return e.getText()==="defineNotify";for(const t of s.getDeclarations())if(r.isImportSpecifier(t))return R.has(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineNotify":!1;return!1},E=(e,s=new Set)=>{const t=D(e);if(!t)return;if(!r.isIdentifier(t))return t;const i=t.getSymbol();if(!i?.isAlias())return t;const n=i.getAliasedSymbol();if(!n)return t;const o=n.getDeclarations().find(a=>r.isExportAssignment(a));if(!o)return t;const c=o.getSourceFile();if(!s.has(c.getFilePath()))return E(c,s.add(c.getFilePath()))},V=new Set(["%=","&&=","&=","**=","+=","-=","/=","<<=","=",">>=",">>>=","??=","^=","|=","||="]),p=e=>{const s=e.getSymbol();return s?.getAliasedSymbol()?.getDeclarations()[0]??s?.getDeclarations()[0]},P=e=>{if(r.isIdentifier(e))return e;if(r.isPropertyAccessExpression(e)||r.isElementAccessExpression(e))return P(e.getExpression())},d=(e,s)=>{const t=P(e);return t!==void 0&&p(t)===s},j=(e,s)=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return!1;const i=t.getName(),n=t.getExpression(),o=r.isIdentifier(n)?n.getText():"";if(!((i==="assign"||i==="defineProperty"||i==="defineProperties")&&o==="Object"||i==="set"&&o==="Reflect"))return!1;const a=e.getArguments()[0];return a!==void 0&&r.isIdentifier(a)&&p(a)===s},z=(e,s)=>{if(r.isBinaryExpression(e))return V.has(e.getOperatorToken().getText())&&d(e.getLeft(),s);if(r.isDeleteExpression(e))return d(e.getExpression(),s);if(r.isPrefixUnaryExpression(e)||r.isPostfixUnaryExpression(e)){const t=e.getOperatorToken();return(t===u.PlusPlusToken||t===u.MinusMinusToken)&&d(e.getOperand(),s)}return r.isCallExpression(e)?j(e,s):!1},H=(e,s)=>{const t=p(e);return t===void 0?!0:s.some(i=>i.getDescendants().some(n=>z(n,t)))},W=e=>{if(r.isObjectLiteralExpression(e))return e;if(!r.isIdentifier(e))return;const s=e.getSymbol(),t=s?.getAliasedSymbol()?.getDeclarations()??s?.getDeclarations()??[];for(const i of t){if(!r.isVariableDeclaration(i))continue;const n=i.getInitializer();if(!n||!r.isObjectLiteralExpression(n))continue;const o=i.getParent();if(!r.isVariableDeclarationList(o)||o.getDeclarationKind()!==F.Const)continue;const c=[i.getSourceFile(),e.getSourceFile()].filter((a,f,S)=>S.findIndex(b=>b.getFilePath()===a.getFilePath())===f);if(!H(e,c))return n}},Y=(e,s)=>{const t=N(s,k);if(!v(t))return;const i=e.getSourceFile(t)??e.addSourceFileAtPath(t),n=E(i);if(!n||!r.isCallExpression(n))return{hasFcm:!0,hasWebPush:!0};const o=n.getExpression(),c=r.isIdentifier(o)&&U(o)?n.getArguments()[0]:void 0,a=c===void 0?void 0:W(c);return!a||a.getProperties().some(f=>r.isSpreadAssignment(f))?{hasFcm:!0,hasWebPush:!0}:{hasFcm:g(a,"fcm")!==void 0,hasWebPush:g(a,"webPush")!==void 0}},ee=(e,s)=>{const t=Y(e,s);return t===void 0?void 0:{...t,usesPush:K(e,s)}};export{k as NOTIFY_FILENAME,Z as discoverNotifyCalls,Y as discoverNotifyChannels,ee as discoverNotifyConfig};
1
+ import{existsSync as v}from"node:fs";import{join as N}from"node:path";import{SyntaxKind as u,Node as r,VariableDeclarationKind as F}from"ts-morph";import{listLunoraSourceFiles as m,lunoraRelativePath as O,findObjectProperty as g,defaultExportExpression as D,handlerOf as A}from"./isTestPath-C3QumE88.mjs";import{b as I,d as T}from"./attribution-CG8-kUcl.mjs";import{i as l}from"./context-root-BAeDnkKU.mjs";import{c as C}from"./classify-procedure-call-BkaeM9Ej.mjs";const k="notify.ts",L=new Set(["chat","inApp","send","webhook"]),h=new Set(["broadcast","send"]),M=e=>{const s=e.getInitializer();if(!s||!r.isCallExpression(s))return;const t=C(s);if(!t)return;const i=A(s,t.receiver);return i?{exportName:T(e)??e.getName(),handler:i,kind:t.kind}:void 0},x=e=>{const s=[];for(const t of I(e)){const i=M(t);i&&s.push(i)}return s},y=e=>l(e,["notify"])?"notify":l(e,["push"])||l(e,["notify","push"])?"push":void 0,w=e=>{if(!r.isPropertyAccessExpression(e))return;const s=e.getName(),t=y(e.getExpression());if(t==="notify"&&L.has(s))return`ctx.notify.${s}`;if(t==="push"&&h.has(s))return`ctx.push.${s}`},_=e=>r.isPropertyAccessExpression(e)?y(e.getExpression())==="push"&&h.has(e.getName()):!1,Z=(e,s)=>{const t=[];for(const i of m(s)){const n=e.getSourceFile(i)??e.addSourceFileAtPath(i),o=O(s,i);for(const c of x(n))if(!(c.kind!=="query"&&c.kind!=="mutation"))for(const a of c.handler.getDescendantsOfKind(u.PropertyAccessExpression)){const f=w(a);f!==void 0&&t.push({callee:f,exportName:c.exportName,file:o,kind:c.kind,line:a.getStartLineNumber()})}}return t},K=(e,s)=>{for(const t of m(s)){const i=e.getSourceFile(t)??e.addSourceFileAtPath(t);for(const n of x(i))for(const o of n.handler.getDescendantsOfKind(u.PropertyAccessExpression))if(_(o))return!0}return!1},R=new Set(["@lunora/notify"]),U=e=>{const s=e.getSymbol();if(!s)return e.getText()==="defineNotify";for(const t of s.getDeclarations())if(r.isImportSpecifier(t))return R.has(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineNotify":!1;return!1},E=(e,s=new Set)=>{const t=D(e);if(!t)return;if(!r.isIdentifier(t))return t;const i=t.getSymbol();if(!i?.isAlias())return t;const n=i.getAliasedSymbol();if(!n)return t;const o=n.getDeclarations().find(a=>r.isExportAssignment(a));if(!o)return t;const c=o.getSourceFile();if(!s.has(c.getFilePath()))return E(c,s.add(c.getFilePath()))},V=new Set(["%=","&&=","&=","**=","+=","-=","/=","<<=","=",">>=",">>>=","??=","^=","|=","||="]),p=e=>{const s=e.getSymbol();return s?.getAliasedSymbol()?.getDeclarations()[0]??s?.getDeclarations()[0]},P=e=>{if(r.isIdentifier(e))return e;if(r.isPropertyAccessExpression(e)||r.isElementAccessExpression(e))return P(e.getExpression())},d=(e,s)=>{const t=P(e);return t!==void 0&&p(t)===s},j=(e,s)=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return!1;const i=t.getName(),n=t.getExpression(),o=r.isIdentifier(n)?n.getText():"";if(!((i==="assign"||i==="defineProperty"||i==="defineProperties")&&o==="Object"||i==="set"&&o==="Reflect"))return!1;const a=e.getArguments()[0];return a!==void 0&&r.isIdentifier(a)&&p(a)===s},z=(e,s)=>{if(r.isBinaryExpression(e))return V.has(e.getOperatorToken().getText())&&d(e.getLeft(),s);if(r.isDeleteExpression(e))return d(e.getExpression(),s);if(r.isPrefixUnaryExpression(e)||r.isPostfixUnaryExpression(e)){const t=e.getOperatorToken();return(t===u.PlusPlusToken||t===u.MinusMinusToken)&&d(e.getOperand(),s)}return r.isCallExpression(e)?j(e,s):!1},H=(e,s)=>{const t=p(e);return t===void 0?!0:s.some(i=>i.getDescendants().some(n=>z(n,t)))},W=e=>{if(r.isObjectLiteralExpression(e))return e;if(!r.isIdentifier(e))return;const s=e.getSymbol(),t=s?.getAliasedSymbol()?.getDeclarations()??s?.getDeclarations()??[];for(const i of t){if(!r.isVariableDeclaration(i))continue;const n=i.getInitializer();if(!n||!r.isObjectLiteralExpression(n))continue;const o=i.getParent();if(!r.isVariableDeclarationList(o)||o.getDeclarationKind()!==F.Const)continue;const c=[i.getSourceFile(),e.getSourceFile()].filter((a,f,S)=>S.findIndex(b=>b.getFilePath()===a.getFilePath())===f);if(!H(e,c))return n}},Y=(e,s)=>{const t=N(s,k);if(!v(t))return;const i=e.getSourceFile(t)??e.addSourceFileAtPath(t),n=E(i);if(!n||!r.isCallExpression(n))return{hasFcm:!0,hasWebPush:!0};const o=n.getExpression(),c=r.isIdentifier(o)&&U(o)?n.getArguments()[0]:void 0,a=c===void 0?void 0:W(c);return!a||a.getProperties().some(f=>r.isSpreadAssignment(f))?{hasFcm:!0,hasWebPush:!0}:{hasFcm:g(a,"fcm")!==void 0,hasWebPush:g(a,"webPush")!==void 0}},ee=(e,s)=>{const t=Y(e,s);return t===void 0?void 0:{...t,usesPush:K(e,s)}};export{k as NOTIFY_FILENAME,Z as discoverNotifyCalls,Y as discoverNotifyChannels,ee as discoverNotifyConfig};
@@ -1,3 +1,3 @@
1
- import{m}from"./modules-l-Db0C4S.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-CIAJQeKB.mjs";import{G as h}from"./shared-8vTRkL2-.mjs";import{s as i}from"./dispatch-namespace-DwTjD7BU.mjs";const R="1.3.2",g={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},O=(e,r)=>e==="stream"?`Open the \`stream\` \`${r}\` over the Lunora WebSocket. It yields chunks rather than one result, so its \`result\` schema is a placeholder.`:`Invoke the \`${e}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${r}", "args": { … } }\`).`,S=(e,r)=>{const o=`${i(e.filePath)}:${e.exportName}`;return{description:O(e.kind,o),errors:d.map((s,a)=>({code:-32e3-a,data:{code:s},message:s})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:l(e.args)}],result:{name:"result",schema:e.output&&e.kind!=="stream"?p(e.output):g},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,...e.description?{"x-lunora-description":e.description}:{},"x-tags":[{name:r}]}},v=e=>{const r=e.version??"0.0.0",n=e.functions.filter(t=>t.visibility!=="internal"),o=e.modules??[],s=n.map(t=>S(t,m(o,t.filePath))).toSorted((t,c)=>t.name.localeCompare(c.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:r},methods:s,openrpc:R}},E=e=>`${JSON.stringify(v(e),void 0,2)}
1
+ import{m}from"./modules-l-Db0C4S.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-CIAJQeKB.mjs";import{G as h}from"./shared-Br_OnErI.mjs";import{s as i}from"./dispatch-namespace-DwTjD7BU.mjs";const R="1.3.2",g={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},O=(e,r)=>e==="stream"?`Open the \`stream\` \`${r}\` over the Lunora WebSocket. It yields chunks rather than one result, so its \`result\` schema is a placeholder.`:`Invoke the \`${e}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${r}", "args": { … } }\`).`,S=(e,r)=>{const o=`${i(e.filePath)}:${e.exportName}`;return{description:O(e.kind,o),errors:d.map((s,a)=>({code:-32e3-a,data:{code:s},message:s})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:l(e.args)}],result:{name:"result",schema:e.output&&e.kind!=="stream"?p(e.output):g},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,...e.description?{"x-lunora-description":e.description}:{},"x-tags":[{name:r}]}},v=e=>{const r=e.version??"0.0.0",n=e.functions.filter(t=>t.visibility!=="internal"),o=e.modules??[],s=n.map(t=>S(t,m(o,t.filePath))).toSorted((t,c)=>t.name.localeCompare(c.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:r},methods:s,openrpc:R}},E=e=>`${JSON.stringify(v(e),void 0,2)}
2
2
  `,N=e=>`${h}export const openRpcSpec = ${u(e,"Record<string, unknown>")};
3
3
  `;export{R as OPENRPC_VERSION,v as buildOpenRpcDocument,E as emitOpenRpc,N as emitOpenRpcModule};
@@ -0,0 +1,31 @@
1
+ import{existsSync as M,readFileSync as Ye,mkdirSync as Bt,writeFileSync as mr,rmSync as be,readdirSync as Cn}from"node:fs";import{dirname as Vt,join as E,relative as On}from"node:path";import{performance as ht}from"node:perf_hooks";import{runAdvisor as hr}from"@lunora/advisor";import{LunoraError as _}from"@lunora/errors";import{serializeSchemaSnapshot as vr}from"./SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs";import{toAdvisorContext as Er}from"./formatAdvisories-BCVASH7N.mjs";import{Node as r,SyntaxKind as d,Project as Ut,ts as xr,VariableDeclarationKind as Sr}from"ts-morph";import{listLunoraSourceFiles as A,lunoraRelativePath as w,bindingKeyName as ce,collectCallRows as T,findObjectProperty as V,collectSecurityCallRows as Ar,propertyInitializer as R,listSecurityScanFiles as Qe,objectLiteralFromCallbackBody as kn,limitNameOf as Rn,optionsObjectLiteral as Fn,handlerOf as yr,collectNodeRows as ne,chainRootOf as Xe,outermostValueWrapper as I,isWriteTarget as Je,isSameNode as y,unwrapExpression as h,isConstDeclaration as ie,memberAccessOf as Wt,returningFunctionOf as wt,walkChain as br,RUN_METHODS as Ln,functionReferenceSegments as Nr,isTestPath as Pr,isFunctionLike as re,functionKeyOf as Dn}from"./isTestPath-C3QumE88.mjs";import{b as Q,d as j,f as L,g as qt,c as x,a as jt,w as Ht,k as wr,l as Ir,h as Tr,m as Cr,j as It,i as Or}from"./attribution-CG8-kUcl.mjs";import{a as Fs,r as vt,i as G,b as kr,m as Mn,c as Ze,e as Gt,E as _n,C as Kn,d as Rr,f as Fr,g as Lr}from"./context-root-BAeDnkKU.mjs";import{a as P,i as Dr,c as ee,d as zn,e as Mr,f as _r,g as $n}from"./classify-procedure-call-BkaeM9Ej.mjs";import{a as S,s as Kr}from"./property-name-7cBlgK_O.mjs";import{b as zr,a as et}from"./module-specifiers-BctA0m_p.mjs";import{r as tt,s as $r}from"./parse-validator-CP5CL6Q7.mjs";import Br from"./discoverAuthApiCalls-CScPrUD-.mjs";import{i as z,r as Bn}from"./database-calls-Dohiwd-7.mjs";import Vr from"./discoverHyperdriveCalls-CV6bPCIa.mjs";import{diagnosticAt as de}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{m as Yt,a as Ve,s as Vn,d as Ur}from"./index-BaQeoSqB.mjs";import{MUTATORS_FILENAME as Wr,isDefineMutatorCallee as qr,mutatorServerImplOf as jr,discoverMutators as Hr}from"./MUTATORS_FILENAME-qrKFa1I1.mjs";import Gr from"./discoverNondeterministicCalls-mFJNU8qY.mjs";import{discoverNotifyConfig as Yr,discoverNotifyCalls as Qr}from"./NOTIFY_FILENAME-Dj7fObvj.mjs";import Xr from"./discoverR2sqlCalls-BlnIOBxe.mjs";import Jr from"./discoverRlsProcedures-Dnl0WCtW.mjs";import{s as Qt,n as Zr}from"./dispatch-namespace-DwTjD7BU.mjs";import{secretKindOf as eo,redact as to,isHeuristicSecretKind as so,isSecretishName as no}from"./redact-Cy14LEnc.mjs";import{readProjectConfigLiterals as Un,readMergeDurableObjects as io}from"./loadProjectConfig-B7RmxIeD.mjs";import{a as De,d as ro,r as oo}from"./modules-l-Db0C4S.mjs";import{WORKFLOWS_FILENAME as ao,discoverWorkflows as co}from"./WORKFLOWS_FILENAME-kXq07aGl.mjs";import{r as lo}from"./json-data-Chfs2Cz5.mjs";import{a as uo,I as fo,g as go,G as Wn,d as po,i as mo}from"./shared-Br_OnErI.mjs";import{createCodegenProject as ho}from"./createCodegenProject-ClPr_MXM.mjs";import{findTsconfig as TE,refreshCodegenProject as CE,tsconfigFingerprint as OE}from"./createCodegenProject-ClPr_MXM.mjs";import{CAPABILITIES as vo,usedCapabilities as Eo}from"./CAPABILITY_PROBES-brcmKenl.mjs";import{isD1GlobalTable as qn,isHyperdriveGlobalTable as jn}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as xo}from"./AGENTS_FILENAME-isdHqPIt.mjs";import{discoverContainers as So}from"./CONTAINERS_FILENAME-mK4cZpcz.mjs";import Ao from"./discoverCrons-B1_NUt19.mjs";import{contextPropertiesRead as yo,fileWiresRequestSecretTool as bo,createTargetScope as No,discoverFeatureUsage as Po}from"./capabilitiesUsedBy-DjRHg-Zk.mjs";import Hn from"./readPackageDependencies-RHhGiz0k.mjs";import{PROJECT_CONFIG_FILENAMES as wo,findProjectConfigFile as Io}from"./PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{discoverQueueDeclarations as To}from"./QUEUES_FILENAME-Civ-7SiI.mjs";import{discoverSandboxUsage as Co}from"./discoverSandboxUsage--Z1vx7GM.mjs";import{resolveServiceBindings as Oo}from"./readServiceBindings-BA49C6aN.mjs";import ko from"./discoverStorageRulesMetadata-CitX6ziW.mjs";import{resolveCodegenTarget as Tt,gatePlatformFeatures as Ro,readTargetDiagnostics as Fo,vectorizeDimensionDiagnostics as Lo,liveStreamsDeliveryAuthorizationDiagnostic as Do,socketRoutesDeliveryAuthorizationDiagnostic as Mo,studioPlatformFor as _o,platformFeatureAvailable as Ko}from"./DEFAULT_TARGET-3OLdJhTj.mjs";import{i as zo}from"./schema-BgM8A3XV.mjs";import{b as Gn,e as $o}from"./shard-gWobaDx2.mjs";import{e as Bo,a as Vo}from"./server-CMceLanP.mjs";import{emitDataModel as Uo}from"./emitDataModel-Bba2y2yt.mjs";import{i as Wo,a as qo,e as jo,b as Ho,d as Go,c as Yo}from"./unwrap-handler-return-CGdJGvGh.mjs";import Qo from"./discoverFunctions-C_Y8PWMi.mjs";import Xo from"./discoverHttpRoutes-D_b2SrdD.mjs";import Jo from"./discoverInserts-C9DSRPCl.mjs";import{e as Yn}from"./exported-procedure-chains-D1WlRfqJ.mjs";import Zo from"./discoverMigrations-BWxx8Wv9.mjs";import ea from"./discoverQueries-BOuUa0Nl.mjs";import ta from"./discoverRlsMetadata-D0B4nCmG.mjs";import sa from"./discoverSchema-uxcH-Jy6.mjs";import{discoverShapes as na}from"./SHAPES_FILENAME-CFpyCOh2.mjs";import{i as ia}from"./reserved-words-CW1QFbTd.mjs";import{emitApp as ra}from"./emitApp-CT7iAjam.mjs";import{readJsonSync as oa}from"@visulima/fs";import{buildSchemaSnapshot as aa}from"./SchemaSnapshotParseError-CjKSMuex.mjs";import{buildOpenApiDocument as ca,emitOpenApiModule as la}from"./buildOpenApiDocument-ecVsBXVh.mjs";import{buildOpenRpcDocument as da,emitOpenRpcModule as ua}from"./OPENRPC_VERSION-CoJWSPHr.mjs";import{v as fa,t as ga,u as pa,s as ma,w as ha}from"./shard-runtime-DXlpfT3P.mjs";import{emitCollections as va,emitSeed as Ea,emitApi as xa,emitInternalApi as Sa}from"./emitApi-DP9KFbgH.mjs";import{emitCrons as Aa,emitScheduler as ya,emitShardRegistry as ba,emitDurableObjects as Na,emitVectors as Pa,emitWranglerCronTriggers as wa}from"./emitCrons-CY8IQfAI.mjs";import Ia from"./emitDrizzleSchema-CD4hPtUP.mjs";import{LAZY_FUNCTION_DIRECTORY as Qn,emitFunctions as Ta,emitLazyFunctionModules as Ca}from"./emitFunctions-D5ItlRW-.mjs";const Oa=(e,t=!1)=>{if(e.length===0)return"";const s=po(t),n=e.map(c=>{if(uo(c.exportName,"live stream export name"),!fo.test(c.filePath))throw new Error(`@lunora/codegen: live stream file path is not safe to import: ${JSON.stringify(c.filePath)}`);return`import type { ${c.exportName} as ${c.exportName}Stream } from "../${c.filePath}.js";`}),i=e.map(c=>{const l=c.topics.map(u=>{go(u.name,"live topic name");const f=`(typeof ${c.exportName}Stream)["topics"]["${u.name}"]`,g=`LiveTopicRef<LiveTopicPayload<${f}>>`,m=JSON.stringify(c.id);if(u.fields.length===0)return` ${u.name}: (): ${g} => ({ __lunoraLive: ${m}, topic: ${JSON.stringify(u.name)} }),`;const v=u.fields.map($=>`\${encodeURIComponent(key.${$})}`).join(":");return` ${u.name}: (key: LiveTopicKey<${f}>): ${g} => ({
2
+ __lunoraLive: ${m},
3
+ topic: \`${u.name}:${v}\`,
4
+ }),`});return` ${c.exportName}: {
5
+ ${l.join(`
6
+ `)}
7
+ },`}),a=e.some(c=>c.topics.some(l=>l.fields.length>0))?"LiveTopicKey, LiveTopicPayload, LiveTopicRef":"LiveTopicPayload, LiveTopicRef";return`${Wn}import type { ${a} } from "${s.server}";
8
+
9
+ ${n.join(`
10
+ `)}
11
+
12
+ /**
13
+ * A typed reference to each declared live topic, grouped by the stream's export name:
14
+ * \`live.posts.post({ postId })\`. Pass one to \`ctx.live.publish(ref, payload)\` on the server, or to a
15
+ * live-topic hook in the browser. A reference is plain data and carries no server code.
16
+ */
17
+ export const live = {
18
+ ${i.join(`
19
+ `)}
20
+ };
21
+ `},Xn=new Set(["delete","get","head","options","patch","post","put"]),ka=new Set(["handler","stream"]),Ra=/\/(?:_|admin|internal|superuser|sudo|root|debug)/iu,Ls=new Set(["ADMIN_TOKEN","adminToken","assertAdmin","assertAuth","auth","Authorization","getSession","identity","isAdmin","requireAdmin","requireAuth","requireRole","verifyAdmin"]),Fa=e=>{if(!r.isCallExpression(e))return;const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||!Xn.has(t.getName()))return;const s=t.getExpression();if(!r.isIdentifier(s)||s.getText()!=="httpRoute")return;const n=e.getArguments()[0];if(!(!n||!r.isStringLiteral(n)))return{method:t.getName().toUpperCase(),path:n.getLiteralValue()}},La=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return;let s=t.getExpression();for(;r.isCallExpression(s);){const n=s.getExpression();if(!r.isPropertyAccessExpression(n)||Xn.has(n.getName()))break;s=n.getExpression()}return Fa(s)},Da=e=>{for(const t of e.getDescendantsOfKind(d.PropertyAccessExpression))if(Ls.has(t.getName()))return!0;for(const t of e.getDescendantsOfKind(d.CallExpression)){const s=t.getExpression();if(r.isIdentifier(s)&&Ls.has(s.getText()))return!0}return!1},Ma=(e,t)=>{const s=e.getInitializer();if(!s||!r.isCallExpression(s))return;const n=s.getExpression();if(!r.isPropertyAccessExpression(n)||!ka.has(n.getName()))return;const i=La(s);if(!i||!Ra.test(i.path))return;const o=s.getArguments()[0],a=o!==void 0&&(r.isArrowFunction(o)||r.isFunctionExpression(o))&&Da(o);return{exportName:j(e)??e.getName(),file:t,method:i.method,path:i.path,usesGuard:a}},_a=(e,t)=>{const s=[];for(const n of Q(e)){const i=Ma(n,t);i&&s.push(i)}return s},Ka=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(..._a(i,w(t,n)))}return s},za=e=>{const t=e.getText(),s=n=>{const i=n.getNameNode();return r.isIdentifier(i)&&i.getText()===t};for(const n of e.getAncestors())if(!(!r.isArrowFunction(n)&&!r.isFunctionExpression(n)&&!r.isFunctionDeclaration(n)))for(const i of n.getParameters()){const o=i.getDescendantsOfKind(d.BindingElement).find(a=>s(a));if(o!==void 0)return o}},$a=e=>{let t=e;for(;;){const s=t.getParent();if(!r.isObjectBindingPattern(s))return;const n=s.getParent();if(r.isBindingElement(n)){t=n;continue}return r.isParameterDeclaration(n)?ce(t):void 0}},Ba=e=>{const t=e.getText();if(!e.getAncestors().some(o=>{const a=r.isFunctionLikeDeclaration(o)||r.isArrowFunction(o)?o.getParameters()[1]:void 0,c=a?.getNameNode();return a!==void 0&&(r.isIdentifier(c)?c.getText()===t:a.getDescendantsOfKind(d.BindingElement).some(l=>l.getName()===t))&&Fs(a)}))return!1;const n=L(e),i=r.isParameterDeclaration(n)?n:n?.getFirstAncestorByKind(d.Parameter);return i!==void 0&&(r.isParameterDeclaration(n)||r.isBindingElement(n))&&Fs(i)},Ds=(e,t)=>{const s=e.getParent();if(r.isPropertyAccessExpression(s)&&s.getNameNode()===e||r.isPropertyAssignment(s)&&s.getNameNode()===e)return!1;if(e.getText()===t)return!0;const n=za(e);return n!==void 0&&$a(n)===t?!0:t==="args"&&Ba(e)},Jn=(e,t)=>r.isIdentifier(e)?Ds(e,t):e.getDescendantsOfKind(d.Identifier).some(s=>Ds(s,t)),Va=e=>{let t=e;for(;r.isPropertyAccessExpression(t)||r.isElementAccessExpression(t)||r.isNonNullExpression(t);)t=t.getExpression();return r.isIdentifier(t)?t:void 0},Ms=e=>{const t=r.isIdentifier(e)?L(e):void 0;return r.isVariableDeclaration(t)&&r.isIdentifier(t.getNameNode())&&!qt(t)?t.getInitializer():void 0},Ct=e=>Jn(e,"args"),Y=e=>{if(!r.isIdentifier(e))return;const t=e.getText(),s=e.getFirstAncestor(a=>r.isArrowFunction(a)||r.isFunctionExpression(a)||r.isFunctionDeclaration(a));if(s===void 0)return;const n=e.getStart();let i,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&&(i=c,o=l)}return i},q=e=>{if(Ct(e))return!0;const t=Y(e);return t!==void 0&&Ct(t)},Ua=e=>{if(r.isCallExpression(e)||r.isNewExpression(e))return!1;const t=Y(e);return t===void 0||!(r.isCallExpression(t)||r.isNewExpression(t))},le=e=>{if(vt(e))return!0;const t=Ms(e);if(t!==void 0&&vt(t))return!0;const s=t??e;return(r.isIdentifier(s)?[s]:s.getDescendantsOfKind(d.Identifier)).some(i=>{const o=Ms(i);return o!==void 0&&vt(o)})},Me=(e,t)=>Jn(e,t),Wa=(e,t)=>{if(Me(e,t))return!0;const s=Y(e);if(s!==void 0&&Me(s,t))return!0;const n=Va(e);if(n!==void 0){const i=Y(n);return i!==void 0&&Me(i,t)}return!1},qa=e=>!r.isPropertyAccessExpression(e)||e.getName()!=="run"?!1:G(e.getExpression(),["ai"]),ja=(e,t)=>{if(!qa(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!q(s)||le(s)))return{scope:x(e),file:t,line:e.getStartLineNumber()}},Ha=(e,t)=>T(e,t,ja),Ga=new Set(["generateText","streamText"]),Ya=new Set(["messages","prompt","system"]),Qa=[{methods:new Set(["delete","insert","insertManyUnsafe","patch","patchIf","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"]}],Xa=(e,t)=>Qa.some(s=>s.methods.has(t)&&s.prefixes.some(n=>e===n||e.startsWith(`${n}.`))),Ja=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return;const s=t.getName(),n=[kr(t.getExpression()),t.getExpression().getText()].find(i=>i!==void 0&&Xa(i,s));return n===void 0?void 0:`${n}.${s}`},Za=e=>{for(const t of e.getDescendantsOfKind(d.CallExpression)){const s=Ja(t);if(s!==void 0)return s}},ec=e=>{const t=new Set,s=e.getFirstAncestor(o=>r.isArrowFunction(o)||r.isFunctionExpression(o)||r.isFunctionDeclaration(o)),[n]=s?.getParameters()??[],i=n?.getNameNode();if(i===void 0||!r.isObjectBindingPattern(i))return t;for(const o of i.getElements()){const a=ce(o),c=o.getNameNode();if(a==="args"&&r.isObjectBindingPattern(c))for(const l of c.getElements())t.add(l.getName())}return t},tc=e=>{if(Ct(e))return!0;const t=ec(e);return t.size===0?!1:e.getDescendantsOfKind(d.Identifier).some(s=>t.has(s.getText()))},sc=e=>{for(const t of e.getProperties()){if(!r.isPropertyAssignment(t)||!Ya.has(S(t)))continue;const s=t.getInitializer();if(s!==void 0&&tc(s))return!0}return!1},nc=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression)){const i=P(n.getExpression());if(i===void 0||!Ga.has(i))continue;const[o]=n.getArguments();if(o===void 0||!r.isObjectLiteralExpression(o))continue;let a;for(const c of o.getDescendantsOfKind(d.CallExpression))if(P(c.getExpression())==="tool"&&(a=Za(c),a!==void 0))break;a!==void 0&&s.push({scope:x(n),file:t,line:n.getStartLineNumber(),method:i,sideEffect:a,userInputDerived:sc(o)})}return s},ic=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...nc(i,w(t,n)))}return s},rc=e=>G(e,["fetch"]),oc=(e,t)=>{if(!rc(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!q(s)))return{scope:x(e),file:t,line:e.getStartLineNumber()}},ac=(e,t)=>T(e,t,oc),Xt=(e,t=new Set)=>{if(t.has(e))return!0;t.add(e);try{return e.getProperties().some(s=>{if(!r.isSpreadAssignment(s))return!1;const n=tt(s.getExpression());return n===void 0||Xt(n,t)})}finally{t.delete(e)}},cc=e=>{const t=e.getArguments()[0];if(!t||!r.isObjectLiteralExpression(t))return{objects:[],opaque:!0};const s=V(t,"args");if(!s)return{objects:[],opaque:!1};if(!r.isPropertyAssignment(s))return{objects:[],opaque:!0};const n=s.getInitializer(),i=n===void 0?void 0:tt(n);return i===void 0?{objects:[],opaque:!0}:{objects:[i],opaque:Xt(i)}},lc=e=>{const t=[];let s=!1,n=e;for(;r.isCallExpression(n);){const i=n.getExpression();if(!r.isPropertyAccessExpression(i))break;if(i.getName()==="input"){const o=n.getArguments()[0],a=o!==void 0&&r.isExpression(o)?tt(o):void 0;a===void 0?s=!0:(t.push(a),s||=Xt(a))}n=i.getExpression()}return{objects:t,opaque:s}},Jt=(e,t)=>t?lc(t):cc(e),Zn=(e,t)=>{if(t.has(e))return[];t.add(e);try{return e.getProperties().flatMap(s=>{if(r.isSpreadAssignment(s)){const n=tt(s.getExpression());return n===void 0?[]:Zn(n,t)}return r.isPropertyAssignment(s)||r.isShorthandPropertyAssignment(s)?[S(s)]:[]})}finally{t.delete(e)}},dc=e=>e.flatMap(t=>Zn(t,new Set)),uc=new Set(["check","length","max"]),Ot=e=>{let t=e;for(;;){const s=t.getParent();if(!s||!r.isPropertyAccessExpression(s)||s.getExpression()!==t)return!1;const n=s.getParent();if(!n||!r.isCallExpression(n)||n.getExpression()!==s)return!1;if(uc.has(s.getName()))return!0;t=n}},kt=e=>zr(e)||e==="@lunora/values",fc=e=>{const t=new Set(["v"]);for(const s of Dr(e,"v",kt))t.add(s);for(const s of e.getImportDeclarations()){const n=s.getNamespaceImport();n&&kt(s.getModuleSpecifierValue())&&t.add(`${n.getText()}.v`)}return t},gc=(e,t)=>{const s=new Map;for(const n of e.getVariableStatements())for(const i of n.getDeclarations()){const o=i.getNameNode(),a=i.getInitializer();if(!(!r.isObjectBindingPattern(o)||!a||!t.has(a.getText())))for(const c of o.getElements())c.getDotDotDotToken()||s.set(c.getName(),c.getPropertyNameNode()?.getText()??c.getName())}return s},pc=e=>(e.getSymbol()?.getDeclarations()??[]).some(t=>!t.getSourceFile().isDeclarationFile()&&!r.isImportSpecifier(t)&&!r.isNamespaceImport(t)&&!r.isImportClause(t)),mc=e=>(e.getSymbol()?.getDeclarations()??[]).some(t=>r.isNamespaceImport(t)&&kt(t.getFirstAncestorByKindOrThrow(d.ImportDeclaration).getModuleSpecifierValue())),Zt=(e,t)=>{if(!r.isCallExpression(e))return;const s=e.getExpression();if(r.isPropertyAccessExpression(s)){const n=s.getExpression();if(!t.namespaces.has(n.getText()))return;if(r.isIdentifier(n))return pc(n)?void 0:s.getName();const i=r.isPropertyAccessExpression(n)?n.getExpression():void 0;return r.isIdentifier(i)&&mc(i)?s.getName():void 0}if(r.isIdentifier(s))return t.destructured.get(s.getText())},hc=(e,t)=>{if(!r.isIdentifier(e))return;const s=e.getText(),n=t.getVariableDeclaration(s)?.getInitializer();return n&&(r.isArrowFunction(n)||r.isFunctionExpression(n))?n:t.getFunction(s)},vc=e=>{let t=e.getParent();for(;t&&!r.isFunctionLikeDeclaration(t);)t=t.getParent();return t},Ec=e=>r.isReturnStatement(e)?e.getExpression():void 0,xc=e=>r.isArrowFunction(e)&&!r.isBlock(e.getBody())?[e.getBody()]:e.getDescendantsOfKind(d.ReturnStatement).filter(t=>vc(t)?.compilerNode===e.compilerNode).flatMap(t=>{const s=Ec(t);return s?[s]:[]}),ei=(e,t)=>{if(Zt(e,t)!==void 0)return e;if(r.isCallExpression(e)||r.isPropertyAccessExpression(e))return ei(e.getExpression(),t)},Sc=(e,t)=>{const s=hc(e.getExpression(),e.getSourceFile());if(!s)return[];const n=Ot(e),i=new Set(xc(s).map(o=>ei(o,t)).filter(o=>o!==void 0));return[s,...s.getDescendants()].flatMap(o=>{const a=Zt(o,t);return a===void 0?[]:[{bounded:Ot(o)||n&&i.has(o),factory:a}]})},Ac=(e,t)=>[e,...e.getDescendants()].flatMap(s=>{const n=Zt(s,t),i=n===void 0?[]:[{bounded:Ot(s),factory:n}];return r.isCallExpression(s)?[...i,...Sc(s,t)]:i}),yc=(e,t)=>{const s=[],n=[];for(const i of e)for(const o of i.getProperties()){if(!r.isPropertyAssignment(o))continue;const a=o.getInitializer();if(!a)continue;const c=Ac(a,t),l=S(o);c.some(u=>u.factory==="any")?s.push(l):c.some(u=>u.factory==="string"&&!u.bounded)&&n.push(l)}return{anyArgs:s,unboundedStringArgs:n}},bc=(e,t,s)=>{const n=e.getInitializer();if(!n||!r.isCallExpression(n))return;const i=ee(n);if(i?.visibility!=="public")return;const{objects:o}=Jt(n,i.receiver),{anyArgs:a,unboundedStringArgs:c}=yc(o,s);if(!(a.length===0&&c.length===0))return{anyArgs:a,exportName:j(e)??e.getName(),file:t,line:n.getStartLineNumber(),unboundedStringArgs:c}},Nc=(e,t)=>{const s=[],n=fc(e),i={destructured:gc(e,n),namespaces:n};for(const o of Q(e)){const a=bc(o,t,i);a&&s.push(a)}return s},Pc=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Nc(i,w(t,n)))}return s},Et=e=>e?.getKind()===d.TrueKeyword,wc=e=>e?.getKind()===d.FalseKeyword,Ic=e=>e!==void 0&&r.isNumericLiteral(e)&&e.getLiteralValue()===0,Tc=new Set(["lunoraAuthAdapter","lunoraD1Adapter"]),Cc=e=>!e||!r.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>r.isCallExpression(t)&&P(t.getExpression())==="scim"),Oc=e=>e!==void 0&&r.isCallExpression(e)&&Tc.has(P(e.getExpression())??""),kc=e=>!e||!r.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>r.isStringLiteral(t)&&t.getLiteralText()==="*"),Rc=e=>{const t=R(e,"advanced"),s=R(e,"emailAndPassword"),n=R(e,"session");return{analyzable:!0,disableCsrfCheck:Et(R(t,"disableCSRFCheck")),emailPasswordEnabled:Et(R(s,"enabled")),requireEmailVerification:Et(R(s,"requireEmailVerification")),scimOnNonTransactionalAdapter:Cc(R(e,"plugins"))&&Oc(R(e,"database")),secureCookiesDisabled:wc(R(t,"useSecureCookies")),sessionFreshAgeZero:Ic(R(n,"freshAge")),trustedOriginsWildcard:kc(R(e,"trustedOrigins"))}},Fc=()=>({analyzable:!1,disableCsrfCheck:!1,emailPasswordEnabled:!1,requireEmailVerification:!1,scimOnNonTransactionalAdapter:!1,secureCookiesDisabled:!1,sessionFreshAgeZero:!1,trustedOriginsWildcard:!1}),Lc=(e,t)=>{if(P(e.getExpression())!=="createAuth")return;const s=e.getArguments()[0],n=s!==void 0&&r.isObjectLiteralExpression(s)&&s.getProperties().some(o=>r.isSpreadAssignment(o)),i=s!==void 0&&r.isObjectLiteralExpression(s)&&!n?Rc(s):Fc();return{scope:x(e),file:t,line:e.getStartLineNumber(),...i}},Dc=(e,t)=>Ar(e,t,Lc),Mc=(e,t)=>{if(!r.isPropertyAccessExpression(e))return;const s=e.getName();if(t.methods.has(s))return Mn(e.getExpression(),t.matchReceiver)?s:void 0},_c=(e,t,s)=>{const n=Mc(e.getExpression(),s);if(n===void 0)return;const i=e.getArguments()[s.argIndex];if(!(!i||!q(i)||le(i))&&!(s.requireUnmodifiedReach===!0&&!Ua(i)))return{scope:x(e),file:t,line:e.getStartLineNumber(),method:n}},st=(e,t,s)=>T(e,t,(n,i)=>_c(n,i,s)),Kc=new Set(["content","pdf","scrape","screenshot"]),zc=(e,t)=>st(e,t,{argIndex:0,matchReceiver:s=>s==="ctx.browser",methods:Kc}),$c=new Set(["createBrowser","createInboundEmailHandler","createPayment"]),Bc=new Set(["RateLimiter"]),Vc=new Set(["extend"]),_s="lunora",Uc=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],ti=e=>{const t=[],s=[];let n=!1;for(const i of e.getProperties()){if(r.isSpreadAssignment(i)){n=!0;continue}if(r.isPropertyAssignment(i)){const o=S(i);t.push(o),i.getInitializer()?.getKind()===d.TrueKeyword&&s.push(o);continue}(r.isShorthandPropertyAssignment(i)||r.isMethodDeclaration(i))&&t.push(S(i))}return{analyzable:!n,presentKeys:t,trueKeys:s}},Rt=e=>e&&r.isObjectLiteralExpression(e)?ti(e):{analyzable:!1,presentKeys:[],trueKeys:[]},Wc=e=>{const t=e&&(r.isArrowFunction(e)||r.isFunctionExpression(e))?e:void 0,s=t&&kn(t.getBody());return s?ti(s):{analyzable:!1,presentKeys:[],trueKeys:[]}},qc=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression)){const i=P(n.getExpression());i!==void 0&&($c.has(i)?s.push({callee:i,file:t,line:n.getStartLineNumber(),...Rt(n.getArguments()[0])}):Vc.has(i)&&s.push({callee:i,file:t,line:n.getStartLineNumber(),...Wc(n.getArguments()[0])}))}for(const n of e.getDescendantsOfKind(d.NewExpression)){const i=P(n.getExpression());i===void 0||!Bc.has(i)||s.push({callee:i,file:t,line:n.getStartLineNumber(),...Rt(n.getArguments()[0])})}return s},jc=e=>{for(const t of Uc){const s=E(e,t);if(!M(s))continue;const n=new Ut({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}).createSourceFile(t,Ye(s,"utf8")),i=[];for(const o of n.getDescendantsOfKind(d.CallExpression))P(o.getExpression())===_s&&i.push({callee:_s,file:t,line:o.getStartLineNumber(),...Rt(o.getArguments()[0])});return i}return[]},Hc=(e,t)=>{const s=[];for(const{displayPath:n,filePath:i}of Qe(t)){const o=e.getSourceFile(i)??e.addSourceFileAtPath(i);s.push(...qc(o,n))}return s.push(...jc(Vt(t))),s},Ks="ctx.containers.",Gc=e=>{if(!e.startsWith(Ks))return!1;const t=e.slice(Ks.length);return t.length>0&&!t.includes(".")},Yc=(e,t)=>st(e,t,{argIndex:0,matchReceiver:Gc,methods:new Set(["get"])}),Qc=new Set(["allow","deny","setAllowed"]),Xc=e=>{const t=e.getArguments()[0];if(!t||!r.isObjectLiteralExpression(t))return!1;const s=V(t,"enableInternet");return s!==void 0&&r.isPropertyAssignment(s)&&r.isTrueLiteral(s.getInitializerOrThrow())},Jc=(e,t)=>{const s=e.getExpression();if(!(!r.isPropertyAccessExpression(s)||s.getName()!=="start"||!Xc(e)))return{detail:"enableInternet: true",scope:x(e),file:t,kind:"enable_internet",line:e.getStartLineNumber()}},Zc=(e,t)=>{const s=e.getExpression();if(!r.isPropertyAccessExpression(s)||!Qc.has(s.getName()))return;const n=s.getExpression();if(!(!r.isPropertyAccessExpression(n)||n.getName()!=="egress"))return{detail:s.getName(),scope:x(e),file:t,kind:"egress_relaxation",line:e.getStartLineNumber()}},el=(e,t)=>Jc(e,t)??Zc(e,t),tl=(e,t)=>T(e,t,el),sl=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||t.getName()!=="count")return;const s=t.getExpression();if(z(s)){const n=e.getArguments()[0];return n&&r.isStringLiteral(n)?n.getLiteralText():""}return r.isPropertyAccessExpression(s)&&z(s.getExpression())?s.getName():void 0},nl=e=>{const t=e.getExpression(),s=r.isPropertyAccessExpression(t)?t.getExpression():void 0;return e.getArguments()[s!==void 0&&z(s)?1:0]},il=new Set(["baseWhere","relationBaseWhere","restrictsCounts","where"]),rl=e=>{if(e===void 0||!r.isObjectLiteralExpression(e))return;const t=[];for(const n of e.getProperties()){if(!r.isPropertyAssignment(n)&&!r.isShorthandPropertyAssignment(n))return;t.push(n.getName())}return t.length>0&&t.every(n=>il.has(n))||t.some(n=>n==="AND"||n==="OR"||n==="NOT")?void 0:t},ol=(e,t,s)=>{const n=new Map(s.map(i=>[i.name,i.aggregateIndexed===!0]));return T(e,t,(i,o)=>{const a=sl(i);if(a===void 0)return;const c=rl(nl(i));return{file:o,indexed:n.get(a)!==!1,...c===void 0?{}:{filterFields:c},line:i.getStartLineNumber(),scope:x(i),table:a}})},al=new Set(["defineExportSink","r2Sink","webhookExportSink"]),cl=e=>{const t=e.getExpression();if(!r.isIdentifier(t))return;const s=t.getText();return al.has(s)?s:void 0},ll=e=>{const t=[],s=[];for(const n of e.getProperties()){if(r.isSpreadAssignment(n))return{analyzable:!1,emptyKeys:[],presentKeys:[]};if(r.isPropertyAssignment(n)){const i=S(n);t.push(i);const o=n.getInitializer();o&&r.isStringLiteral(o)&&o.getLiteralText()===""&&s.push(i);continue}(r.isShorthandPropertyAssignment(n)||r.isMethodDeclaration(n)||r.isGetAccessorDeclaration(n))&&t.push(S(n))}return{analyzable:!0,emptyKeys:s,presentKeys:t}},dl=(e,t)=>{const s=[];for(const{displayPath:n,filePath:i}of Qe(t)){const o=e.getSourceFile(i)??e.addSourceFileAtPath(i);for(const a of o.getDescendantsOfKind(d.CallExpression)){const c=cl(a);if(c===void 0)continue;const l=a.getArguments()[0],u=l&&r.isObjectLiteralExpression(l)?ll(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},ul=new Map([["dbRateLimit",2],["rateLimit",2],["verifyTurnstileMiddleware",0]]),fl=new Set(["dbRateLimit","rateLimit"]),gl=e=>{const t=Fn(e);if(!t)return!1;const s=V(t,"failOpen");return s!==void 0&&r.isPropertyAssignment(s)&&s.getInitializer()?.getKind()===d.TrueKeyword},pl=(e,t)=>{const s=P(e.getExpression());if(s===void 0)return;const n=ul.get(s);if(n!==void 0)return{callee:s,scope:x(e),failOpen:gl(e.getArguments()[n]),file:t,limitName:fl.has(s)?Rn(e):"",line:e.getStartLineNumber()}},ml=(e,t)=>T(e,t,pl),hl=e=>{const t=e.getInitializer();if(!t||!r.isCallExpression(t))return;const s=ee(t);if(s?.kind!=="query")return;const n=yr(t,s.receiver);return n?{exportName:j(e)??e.getName(),handler:n}:void 0},zs=e=>{const t=e.getParent();return t&&r.isPropertyAccessExpression(t)&&t.getExpression()===e?t:void 0},vl=e=>{const t=zs(e);if(!t)return"ctx.flags";if(t.getName()==="details"){const s=zs(t);return s?`ctx.flags.details.${s.getName()}`:"ctx.flags.details"}return`ctx.flags.${t.getName()}`},El=(e,t)=>{const s=[];for(const n of Ze(e.handler,"flags"))s.push({callee:vl(n),exportName:e.exportName,file:t,line:n.getStartLineNumber()});return s},xl=(e,t)=>{const s=[];for(const n of Q(e)){const i=hl(n);i&&s.push(...El(i,t))}return s},Sl=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...xl(i,w(t,n)))}return s},Al=e=>!r.isPropertyAccessExpression(e)||e.getName()!=="boolean"?!1:G(e.getExpression(),["flags"]),yl=e=>{if(e?.getKind()===d.TrueKeyword)return!0;if(e?.getKind()===d.FalseKeyword)return!1},bl=(e,t)=>{if(!Al(e.getExpression()))return;const[s,n]=e.getArguments();if(!s||!(r.isStringLiteral(s)||r.isNoSubstitutionTemplateLiteral(s)))return;const i=s.getLiteralValue(),o=yl(n);if(!(i.length===0||o===void 0))return{defaultValue:o,scope:x(e),file:t,key:i,line:e.getStartLineNumber()}},Nl=(e,t)=>T(e,t,bl),Pl=e=>{const t=e.getExpression();return r.isPropertyAccessExpression(t)&&t.getName()==="withGeoIndex"},wl=e=>{const t=e.getArguments()[0];return t&&r.isStringLiteral(t)?t.getLiteralText():""},Il=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of i.getDescendantsOfKind(d.CallExpression))Pl(a)&&s.push({file:o,indexName:wl(a),line:a.getStartLineNumber()})}return s},Ne=e=>e!==void 0&&(r.isArrowFunction(e)||r.isFunctionExpression(e))?e:void 0,si=e=>{const t=e.getArguments()[0],s=Ne(t);if(s!==void 0)return s;if(t===void 0||!r.isObjectLiteralExpression(t))return;const n=V(t,"handler");return n!==void 0&&r.isPropertyAssignment(n)?Ne(n.getInitializer()):void 0},Tl=new Set(["delete","get","head","options","patch","post","put"]),Cl=new Set(["handler","stream"]),Ol=new Set(["runAction","runMutation"]),kl=new Set(["delete","insert","insertManyUnsafe","patch","patchIf","replace"]),Pe=(e,t)=>e!==void 0&&r.isIdentifier(e)&&e.getText()===t,ni=(e,t)=>{if(!(e===void 0||!r.isObjectBindingPattern(e))){for(const s of e.getElements())if(ce(s)===t){const i=s.getNameNode();return r.isIdentifier(i)?i.getText():void 0}}},$s=(e,t)=>{const s=e.getParameters()[0]?.getNameNode();if(s!==void 0)return t?r.isIdentifier(s)?s.getText():void 0:ni(s,"ctx")},Bs=(e,t)=>{const s=e.getParameters()[t?1:0]?.getNameNode();return t?s!==void 0&&r.isIdentifier(s)?s.getText():void 0:ni(s,"request")},Vs=(e,t)=>{const s=e.getBody(),n=s.getDescendantsOfKind(d.CallExpression);r.isCallExpression(s)&&n.unshift(s);for(const i of n){const o=i.getExpression();if(!r.isPropertyAccessExpression(o))continue;const a=o.getName(),c=o.getExpression();if(Ol.has(a)&&Pe(c,t))return a;if(kl.has(a)&&r.isPropertyAccessExpression(c)&&c.getName()==="db"&&Pe(c.getExpression(),t))return`db.${a}`}},Us=(e,t)=>{const s=e.getBody();for(const n of s.getDescendantsOfKind(d.PropertyAccessExpression))if(n.getName()==="auth"&&Pe(n.getExpression(),t))return!0;for(const n of s.getDescendantsOfKind(d.VariableDeclaration)){const i=n.getNameNode();if(!(!r.isObjectBindingPattern(i)||!Pe(n.getInitializer(),t))){for(const o of i.getElements())if(ce(o)==="auth")return!0}}return!1},Rl=/signature|hmac|digest|(?:^|[_-])sig(?:[_-]|$)/i,Fl=(e,t)=>{const s=e.getExpression();if(!r.isPropertyAccessExpression(s)||s.getName()!=="get"&&s.getName()!=="has")return!1;const n=s.getExpression();return r.isPropertyAccessExpression(n)&&n.getName()==="headers"&&Pe(n.getExpression(),t)},Ll=e=>[...r.isStringLiteral(e)?[e.getLiteralText()]:[],...e.getDescendantsOfKind(d.StringLiteral).map(t=>t.getLiteralText())],ii=(e,t)=>{const s=e.getVariableDeclaration(t)?.getInitializer();return s===void 0?[]:Ll(s)},Dl=(e,t)=>{const s=e.getText();for(let n=e.getParent();n!==void 0;n=n.getParent()){if(!r.isArrowFunction(n)&&!r.isFunctionExpression(n)||!n.getParameters().some(c=>c.getName()===s))continue;const i=n.getParent();if(!r.isCallExpression(i))return[];const o=i.getExpression();if(!r.isPropertyAccessExpression(o))return[];const a=o.getExpression();return r.isIdentifier(a)?ii(t,a.getText()):[]}return[]},Ml=e=>{const t=e.getArguments()[0];if(t===void 0)return[];if(r.isStringLiteral(t))return[t.getLiteralText()];if(!r.isIdentifier(t))return[];const s=e.getSourceFile(),n=ii(s,t.getText());return n.length>0?n:Dl(t,s)},Ws=(e,t)=>{if(t===void 0)return!1;const s=e.getBody(),n=s.getDescendantsOfKind(d.CallExpression);return r.isCallExpression(s)&&n.unshift(s),n.some(i=>Fl(i,t)&&Ml(i).some(o=>Rl.test(o)))},_l=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||!Cl.has(t.getName()))return;let s=t.getExpression();for(;r.isCallExpression(s);){const n=s.getExpression();if(!r.isPropertyAccessExpression(n))return;const i=n.getName();if(Tl.has(i)){const o=n.getExpression();return r.isIdentifier(o)&&o.getText()==="httpRoute"?i.toUpperCase():void 0}s=n.getExpression()}},Kl=(e,t)=>{const s=e.getExpression();if(r.isIdentifier(s)&&s.getText()==="httpAction"){const c=Ne(e.getArguments()[0]),l=c&&$s(c,!0);if(!c||l===void 0||Ws(c,Bs(c,!0)))return;const u=Vs(c,l);return u===void 0?void 0:{scope:x(e),file:t,kind:"httpAction",line:e.getStartLineNumber(),readsAuth:Us(c,l),sideEffect:u}}const n=_l(e);if(n===void 0)return;const i=Ne(e.getArguments()[0]),o=i&&$s(i,!1);if(!i||o===void 0||Ws(i,Bs(i,!1)))return;const a=Vs(i,o);return a===void 0?void 0:{scope:x(e),file:t,kind:"httpRoute",line:e.getStartLineNumber(),method:n,readsAuth:Us(i,o),sideEffect:a}},zl=(e,t)=>T(e,t,Kl),$l=new Set(["btoa","encodeURI","encodeURIComponent","isSafeHeaderValue","Number","parseFloat","parseInt"]),Bl=new Set(["append","set"]),ri=e=>e!==void 0&&(r.isStringLiteral(e)||r.isNoSubstitutionTemplateLiteral(e))?e.getLiteralText():"",qs=(e,t)=>(r.isCallExpression(e)?[e,...e.getDescendantsOfKind(d.CallExpression)]:e.getDescendantsOfKind(d.CallExpression)).some(n=>$l.has(P(n.getExpression())??"")&&Me(n,t)),Vl=(e,t)=>{if(qs(e,t))return!0;const s=Y(e);return s!==void 0&&qs(s,t)},Ft=(e,t)=>Wa(e,t)&&!Vl(e,t),Ul=e=>{if(r.isPropertyAccessExpression(e)&&e.getName()==="headers")return!0;const t=Y(e);return t!==void 0&&r.isNewExpression(t)&&P(t.getExpression())==="Headers"},Ue=e=>{if(e===void 0)return;if(r.isObjectLiteralExpression(e))return e;const t=Y(e);return t!==void 0&&r.isObjectLiteralExpression(t)?t:void 0},es=(e,t,s)=>{for(const n of e.getProperties())if(r.isPropertyAssignment(n)){const i=n.getInitializer();i!==void 0&&Ft(i,s.requestName)&&s.rows.push({scope:s.scope,file:s.relativePath,headerName:ri(n.getNameNode()),line:i.getStartLineNumber(),via:t})}else if(r.isShorthandPropertyAssignment(n)){const i=n.getNameNode();Ft(i,s.requestName)&&s.rows.push({scope:s.scope,file:s.relativePath,headerName:S(n),line:i.getStartLineNumber(),via:t})}else if(r.isSpreadAssignment(n)){const i=Ue(n.getExpression());i!==void 0&&es(i,t,s)}},oi=(e,t)=>{const s=Ue(e);if(s===void 0)return;const n=V(s,"headers");if(n===void 0||!r.isPropertyAssignment(n))return;const i=Ue(n.getInitializer());i!==void 0&&es(i,"response-init",t)},Wl=(e,t)=>{const s=P(e.getExpression());if(s==="Response")oi(e.getArguments()[1],t);else if(s==="Headers"){const n=Ue(e.getArguments()[0]);n!==void 0&&es(n,"headers-ctor",t)}},ql=(e,t)=>{const s=e.getExpression();if(!r.isPropertyAccessExpression(s))return;const n=s.getName(),i=s.getExpression();if(n==="json"&&r.isIdentifier(i)&&i.getText()==="Response"){oi(e.getArguments()[1],t);return}if(Bl.has(n)&&Ul(i)){const o=e.getArguments()[1];o!==void 0&&Ft(o,t.requestName)&&t.rows.push({scope:t.scope,file:t.relativePath,headerName:ri(e.getArguments()[0]),line:o.getStartLineNumber(),via:n==="set"?"headers-set":"headers-append"})}},jl=(e,t)=>{for(const s of e.getDescendantsOfKind(d.NewExpression))Wl(s,t);for(const s of e.getDescendantsOfKind(d.CallExpression))ql(s,t)},Hl=(e,t)=>{const s=e.getExpression();if(!r.isIdentifier(s)||s.getText()!=="httpAction")return[];const n=Ne(e.getArguments()[0]);if(n===void 0)return[];const i=n.getParameters()[1];if(i===void 0)return[];const o=i.getNameNode();if(!r.isIdentifier(o))return[];const a=[];return jl(n,{scope:x(e),relativePath:t,requestName:o.getText(),rows:a}),a},Gl=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression))s.push(...Hl(n,t));return s},Yl=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Gl(i,w(t,n)))}return s},ai="identity.ts",Ql=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineIdentity";for(const s of t.getDeclarations())if(r.isImportSpecifier(s))return et(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineIdentity":!1;return!1},Xl=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!r.isNamespaceImport(s))continue;const n=s.getFirstAncestorByKind(d.ImportDeclaration);return n!==void 0&&et(n.getModuleSpecifierValue())}return!1},Jl=e=>{if(r.isIdentifier(e))return Ql(e);if(r.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineIdentity"&&r.isIdentifier(t)&&Xl(t)}return!1},Zl=e=>{const t=[];for(const s of e.getVariableDeclarations()){const n=s.getInitializer();if(n?.getKind()!==d.CallExpression||!Jl(n.getExpression()))continue;const o=s.getNameNode();if(!r.isIdentifier(o)){if(s.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw de(o,"defineIdentity exports must be plain named exports (no destructuring)")}const a=jt(s,"member");a!==void 0&&t.push({exportName:a})}return t},ed=(e,t)=>{const s=E(t,ai);if(!M(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),i=Zl(n);if(i.length!==0){if(i.length>1)throw de(n,`lunora/identity.ts declares ${i.length.toString()} defineIdentity() contracts (${i.map(o=>o.exportName).join(", ")}); exactly one is allowed`);return i[0]}},td=new Set(["auth","context.auth"]),sd="userId",nd=e=>{const t=new Set;for(const s of e.getProperties()){if(r.isSpreadAssignment(s))return;(r.isPropertyAssignment(s)||r.isShorthandPropertyAssignment(s)||r.isMethodDeclaration(s))&&t.add(S(s))}return t},id=(e,t)=>{const s=E(t,ai);if(!M(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const i of n.getDescendantsOfKind(d.CallExpression)){if(P(i.getExpression())!=="defineIdentity")continue;const[o]=i.getArguments();return o&&r.isObjectLiteralExpression(o)?nd(o):void 0}},js=e=>{if(e===void 0||!r.isPropertyAccessExpression(e)||e.getName()!=="identity")return;const t=e.getExpression();return td.has(t.getText())||G(t,["auth"])?e:void 0},rd=e=>{if(r.isPropertyAccessExpression(e)&&js(e.getExpression())!==void 0)return e.getName();if(r.isElementAccessExpression(e)&&js(e.getExpression())!==void 0){const t=e.getArgumentExpression();return t&&r.isStringLiteral(t)?t.getLiteralValue():void 0}},Hs=(e,t,s)=>{const n=rd(e);return n===void 0?void 0:{declared:n===sd||s.has(n),file:t,key:n,line:e.getStartLineNumber(),scope:x(e)}},od=(e,t)=>{const s=id(e,t);return s===void 0?[]:[...ne(e,t,d.PropertyAccessExpression,(n,i)=>Hs(n,i,s)),...ne(e,t,d.ElementAccessExpression,(n,i)=>Hs(n,i,s))]},ad=(e,t)=>{if(P(e.getExpression())!=="buildImageDeliveryUrl")return;const s=e.getArguments()[0];if(!s)return;const n=R(s,"key");if(!(!n||!q(n)||le(n)))return{scope:x(e),file:t,line:e.getStartLineNumber()}},cd=(e,t)=>T(e,t,ad),ld=new Set(["delete","get","getRaw","getWithMetadata","put"]),dd=(e,t,s=[])=>{const n=st(e,t,{argIndex:0,matchReceiver:i=>i==="ctx.kv"||i.startsWith("ctx.kv."),methods:ld});return Ht(n,s)},ud=new Set(["queue","send"]),Gs=new Set(["bcc","cc","to"]),fd=e=>{if(!r.isPropertyAccessExpression(e))return;const t=e.getName();if(!ud.has(t))return;const s=e.getExpression();return G(s,["mail"])||G(s,["email"])?t:void 0},gd=e=>r.isObjectLiteralExpression(e)?e.getProperties().some(t=>{if(r.isShorthandPropertyAssignment(t)){const n=t.getNameNode();return Gs.has(S(t))&&q(n)&&!le(n)}if(!r.isPropertyAssignment(t)||!Gs.has(S(t)))return!1;const s=t.getInitializer();return s!==void 0&&q(s)&&!le(s)}):!1,pd=(e,t)=>{const s=fd(e.getExpression());if(s===void 0)return;const n=e.getArguments()[0];if(!(!n||!gd(n)))return{scope:x(e),file:t,line:e.getStartLineNumber(),method:s}},md=(e,t)=>T(e,t,pd),hd=(e,t,s)=>{const n=e.getArguments()[0];if(!n||!r.isObjectLiteralExpression(n))return[];const i=[];for(const o of n.getProperties()){const a=Ve(o);if(a===void 0||!r.isPropertyAssignment(o))continue;const c=o.getInitializer();if(!(!c||!r.isObjectLiteralExpression(c)))for(const l of c.getProperties()){const u=Ve(l);if(u===void 0)continue;const f=Vn(l);f!=="custom"&&i.push({column:u,exportName:t,file:s,line:l.getStartLineNumber(),strategy:f,table:a})}}return i},vd=(e,t)=>{if(!r.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&r.isCallExpression(s)?ee(s):void 0;return n?.receiver?Yt(n.receiver).flatMap(i=>hd(i,j(e)??e.getName(),t)):[]},Ed=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of Q(i))s.push(...vd(a,o))}return s},xd=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||t.getName()!=="replace")return!1;const s=t.getExpression();return z(s)},Sd=e=>{const t=e.getArguments()[0];if(t===void 0||!r.isObjectLiteralExpression(t))return;const s=V(t,"server");if(s!==void 0)return r.isPropertyAssignment(s)?s.getInitializer():s},Ad=e=>{if(!e.isExported())return;const t=e.getInitializer();if(t?.getKind()!==d.CallExpression)return;const s=t;return qr(s.getExpression())?s:void 0},yd=e=>{const t=Ad(e),s=t===void 0?void 0:Sd(t);if(s===void 0)return[];const n=e.getNameNode(),i=r.isIdentifier(n)?j(e)??n.getText():"";return s.getDescendantsOfKind(d.CallExpression).filter(o=>xd(o)).map(o=>({exportName:i,file:"lunora/mutators.ts",line:o.getStartLineNumber()}))},bd=e=>e.getVariableDeclarations().flatMap(t=>yd(t)),Nd=(e,t)=>{const s=E(t,Wr);if(!M(s))return[];const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);return bd(n)},Pd=new Set(["delete","get","patch"]),wd=new Set(["accountId","authorId","companyId","createdBy","createdById","customerId","groupId","memberId","organizationId","orgId","ownerId","projectId","teamId","tenantId","userId","workspaceId"]),Id=new Set(["auth","identity","session","user"]),Td=new Set([d.EqualsEqualsEqualsToken,d.EqualsEqualsToken,d.ExclamationEqualsEqualsToken,d.ExclamationEqualsToken]),Cd=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||t.getName()!=="normalizeId"||!z(t.getExpression()))return;const s=e.getArguments()[0];return s&&r.isStringLiteral(s)?s.getLiteralText():""},Od=e=>{let t=e,s=t.getParent();for(;s!==void 0&&(r.isAsExpression(s)||r.isParenthesizedExpression(s)||r.isNonNullExpression(s));)t=s,s=t.getParent();if(s===void 0||!r.isVariableDeclaration(s))return;const n=s.getNameNode();return r.isIdentifier(n)?n.getText():void 0},kd=(e,t)=>e.getDescendantsOfKind(d.Identifier).some(s=>s.getText()===t),Rd=e=>r.isThrowStatement(e)||r.isReturnStatement(e)||e.getDescendantsOfKind(d.ThrowStatement).length>0||e.getDescendantsOfKind(d.ReturnStatement).length>0,Fd=(e,t)=>e.getDescendantsOfKind(d.IfStatement).some(s=>kd(s.getExpression(),t)&&Rd(s.getThenStatement())),Ld=(e,t)=>{for(const s of e.getDescendantsOfKind(d.CallExpression)){const n=s.getExpression();if(!r.isPropertyAccessExpression(n))continue;const i=n.getName();if(!Pd.has(i))continue;const o=n.getExpression(),a=z(o);if(!(a||r.isPropertyAccessExpression(o)&&z(o.getExpression())))continue;const l=a&&i==="get"?2:1;if(s.getArguments().slice(0,l).some(f=>r.isIdentifier(f)&&f.getText()===t))return i}},Dd=e=>e.getDescendantsOfKind(d.CallExpression).some(t=>t.getArguments().some(s=>Gt(Xe(s))!==void 0)),Md=e=>e.getDescendantsOfKind(d.BinaryExpression).some(t=>Td.has(t.getOperatorToken().getKind())?r.isPropertyAccessExpression(t.getLeft())||r.isPropertyAccessExpression(t.getRight()):!1),_d=e=>{for(const t of e.getDescendantsOfKind(d.Identifier))if(wd.has(t.getText()))return!0;return[...Id].some(t=>Ze(e,t).length>0)?!0:Dd(e)||Md(e)},Kd=(e,t)=>{if(!r.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!r.isCallExpression(s))return[];const n=ee(s);if(n?.kind!=="query"&&n?.kind!=="mutation")return[];const i=si(s);if(i===void 0)return[];const o=n.receiver!==void 0&&zn(n.receiver,"use","rls"),a=_d(i),c=new Set,l=[];for(const u of i.getDescendantsOfKind(d.CallExpression)){const f=Cd(u);if(f===void 0)continue;const g=Od(u);if(g===void 0||c.has(g)||!Fd(i,g))continue;const m=Ld(i,g);m!==void 0&&(c.add(g),l.push({exportName:j(e)??e.getName(),file:t,line:u.getStartLineNumber(),mentionsOwnership:a,sinkMethod:m,table:f,usesRls:o,visibility:n.visibility}))}return l},zd=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of Q(i))s.push(...Kd(a,o))}return s},ci=(e,t)=>{const s=r.isIdentifier(e)&&t!==void 0?L(e):void 0;return s===void 0||t===void 0?!1:s.compilerNode===t.compilerNode?r.isIdentifier(t.getNameNode()):r.isBindingElement(s)&&s.getFirstAncestorByKind(d.Parameter)?.compilerNode===t.compilerNode},$d=e=>{const t=I(e),s=t.getParent();return(r.isPropertyAccessExpression(s)||r.isElementAccessExpression(s))&&s.getExpression()===t&&!Je(s)},Bd=e=>{const t=I(e).getParent();return r.isVariableDeclaration(t)&&r.isObjectBindingPattern(t.getNameNode())},Vd=e=>{const s=I(e).getParent();if(r.isSpreadAssignment(s)||r.isSpreadElement(s)){const n=s.getParent();return(r.isObjectLiteralExpression(n)||r.isArrayLiteralExpression(n))&&!Je(n)}return r.isTemplateSpan(s)&&!r.isTaggedTemplateExpression(s.getParent().getParent())},We=e=>{const t=L(e);return t===void 0||Ir(t.getSourceFile())},Lt=(e,t)=>{const s=I(e),n=s.getParent();if(!r.isCallExpression(n))return!1;const i=n.getArguments().indexOf(s),o=h(n.getExpression());if(i===-1||o===void 0)return!1;if(r.isIdentifier(o))return o.getText()==="structuredClone"&&We(o);if(ci(Xe(o),t))return!(r.isPropertyAccessExpression(o)&&_n.has(o.getName()))||r.isExpressionStatement(I(r.isAwaitExpression(n.getParent())?n.getParentOrThrow():n).getParent());if(!r.isPropertyAccessExpression(o))return!1;const a=o.getExpression();if(!r.isIdentifier(a)||!We(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"&&i>0;default:return!1}},_e={kind:"opaque"},Ud={kind:"unreached"},Wd=e=>{const t=e.getSymbol()?.getDeclarations()??[],s=t.filter(o=>r.isFunctionDeclaration(o)&&o.hasBody()),[n]=s;return t.every(o=>r.isFunctionDeclaration(o)&&o.getSourceFile()===e.getSourceFile())&&s.length===1&&r.isFunctionDeclaration(n)?n:void 0},Dt=e=>{const t=h(e);if(r.isArrowFunction(t)||r.isFunctionExpression(t))return t;const s=r.isIdentifier(t)?L(t):void 0;if(s?.getSourceFile()!==e.getSourceFile())return;if(r.isFunctionDeclaration(s)){const i=Wd(s);return i===void 0||qt(i)?void 0:i}const n=ie(s)?h(s.getInitializer()):void 0;return r.isArrowFunction(n)||r.isFunctionExpression(n)?n:void 0},li=(e,t,s)=>{const n=t.getArguments(),i=n.indexOf(s),o=i===-1||n.slice(0,i+1).some(l=>r.isSpreadElement(l))||e.getDescendantsOfKind(d.Identifier).some(l=>l.getText()==="arguments"),a=e.getParameters(),c=a[i];return o?_e:c===void 0?a.some(l=>l.isRestParameter())?_e:Ud:c.isRestParameter()?_e:{kind:"parameter",parameter:c}},qd=e=>{const t=I(e),s=t.getParent();if(!r.isCallExpression(s)||s.getExpression()===t)return;const n=Dt(s.getExpression());return n===void 0?_e:li(n,s,t)},jd=new Set(["__defineGetter__","__defineSetter__","__proto__"]),Hd=e=>r.isForInStatement(e)?e.getExpression():r.isConditionalExpression(e)?e.getCondition():r.isElementAccessExpression(e)?e.getArgumentExpression():void 0,di=e=>{const t=I(e),s=t.getParent();if(r.isIfStatement(s)||r.isWhileStatement(s)||r.isDoStatement(s)||r.isSwitchStatement(s)||r.isCaseClause(s)||r.isTypeOfExpression(s)||r.isVoidExpression(s)||r.isComputedPropertyName(s))return!0;if(r.isTemplateSpan(s))return!r.isTaggedTemplateExpression(s.getParent().getParent());const n=Hd(s);if(n!==void 0)return y(n,t);if(r.isPrefixUnaryExpression(s))return s.getOperatorToken()!==d.PlusPlusToken&&s.getOperatorToken()!==d.MinusMinusToken;if(!r.isBinaryExpression(s))return!1;const i=s.getOperatorToken().getKind(),o=i>=d.FirstAssignment&&i<=d.LastAssignment,a=i===d.QuestionQuestionToken||i===d.BarBarToken||i===d.AmpersandAmpersandToken;return!o&&!a},Gd=4,ui=(e,t,s=0)=>{if(wr(e))return!0;if($d(e)){const i=I(e).getParent(),o=r.isElementAccessExpression(i)?i.getArgumentExpression():void 0,a=r.isStringLiteral(o)?o.getLiteralValue():void 0,c=r.isPropertyAccessExpression(i)?i.getName():a;return c===void 0||!jd.has(c)}if(Bd(e)||Vd(e)||di(e)||Lt(e,t))return!0;const n=qd(e);return n?.kind==="unreached"||n?.kind==="parameter"&&Yd(n.parameter,s+1)},Ys=new WeakMap,Yd=(e,t=0)=>{const s=e.getNameNode();if(!r.isIdentifier(s))return!0;const n=Ys.get(e.compilerNode);if(n!==void 0)return n;if(t>Gd)return!1;const o=(s.getSymbol()?.getDeclarations().length??0)===1&&e.getParentOrThrow().getDescendantsOfKind(d.Identifier).every(a=>a===s||a.getText()!==s.getText()||L(a)?.compilerNode!==e.compilerNode||ui(a,void 0,t));return(o||t===0)&&Ys.set(e.compilerNode,o),o},Qs=new WeakMap,Qd=(e,t)=>{const s=r.isFunctionExpression(e)?e.getNameNode():void 0;if(!r.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(i=>{if(i===s||!n.has(i.getText()))return!1;const o=L(i)?.compilerNode;return o!==void 0&&(o===t.compilerNode||s!==void 0&&o===e.compilerNode)})},Xd=(e,t,s)=>{const{context:n,impl:i}=e,o=Qs.get(i.compilerNode);if(o!==void 0)return o;const a=t.getNameNode(),c=r.isIdentifier(a)?[a]:a.getDescendantsOfKind(d.BindingElement).flatMap(g=>{const m=g.getNameNode();return r.isIdentifier(m)?[m]:[]}),l=new Map(c.map(g=>[g.getText(),g.getParentOrThrow().compilerNode])),u=g=>r.isIdentifier(a)?ui(g,n):!Je(g),f=!Qd(i,s)&&c.every(g=>(g.getSymbol()?.getDeclarations().length??0)===1)&&i.getDescendantsOfKind(d.Identifier).every(g=>{const m=g.getText();if(m==="arguments")return!1;const v=l.get(m);return v===void 0||c.includes(g)||L(g)?.compilerNode!==v?!0:u(g)});return Qs.set(i.compilerNode,f),f},Xs=new WeakMap,Jd=e=>{let t=Xs.get(e.compilerNode);return t===void 0&&(t=new Map(e.getVariableDeclarations().flatMap(s=>{const n=jr(s);return n===void 0?[]:[[n.compilerNode,s]]})),Xs.set(e.compilerNode,t)),t},Zd=e=>{const t=Jd(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[i,o]=s.getParameters(),a=o===void 0||o.isRestParameter()?void 0:o,c={context:i,impl:s,mutatorName:j(n)??n.getName()};return a!==void 0&&Xd(c,a,n)?{...c,parameter:a,pristine:!0}:{...c,parameter:a,pristine:!1}},xt="args",xe=e=>{const t=Wt(e);if(t!==void 0){const c=h(t.object);return r.isIdentifier(c)&&c.getText()===xt?t.member:void 0}if(!r.isIdentifier(e))return;const s=L(e);if(!r.isBindingElement(s)||s.getDotDotDotToken()!==void 0)return;const n=s.getParent();if(!r.isObjectBindingPattern(n))return;const i=n.getParent(),o=ie(i)?h(i.getInitializer()):void 0;return r.isBindingElement(i)&&ce(i)===xt||r.isIdentifier(o)&&o.getText()===xt?ce(s):void 0},eu=new Set(["auth","identity","user"]),Mt=e=>{const t=i=>{const o=Gt(i);return o!==void 0&&o.length>0&&eu.has(o[0]??"")},s=h(e)??e;if(t(s))return!0;const n=Y(s);return n!==void 0&&t(n)},fi=(e,t=2)=>{const s=new Set;for(const n of[e,...e.getDescendants()]){const i=xe(n);i!==void 0&&s.add(i);const o=t>0&&r.isIdentifier(n)?Y(n):void 0;if(o!==void 0)for(const a of fi(o,t-1))s.add(a)}return s},Ke=e=>{const t=h(e)??e;if(!r.isBinaryExpression(t))return[];const s=t.getOperatorToken().getKind(),n=t.getLeft(),i=t.getRight();if(s===d.BarBarToken)return[...Ke(n),...Ke(i)];if(s===d.AmpersandAmpersandToken){const l=(u,f)=>{const g=xe(h(u)??u);return g===void 0?[]:Ke(f).filter(m=>m===g)};return[...l(n,i),...l(i,n)]}if(s!==d.ExclamationEqualsEqualsToken&&s!==d.ExclamationEqualsToken)return[];const o=[],a=xe(h(n)??n),c=xe(h(i)??i);return a!==void 0&&Mt(i)&&o.push(a),c!==void 0&&Mt(n)&&o.push(c),o},tu=e=>{const t=h(e)??e;if(!r.isIdentifier(t))return!1;const s=t.getSymbol(),n=s?.getAliasedSymbol()?.getValueDeclaration()??s?.getValueDeclaration();if(!r.isVariableDeclaration(n))return!1;const i=h(n.getInitializer());return r.isCallExpression(i)&&Mr(i.getExpression(),"defineIdentityGuard")},su=e=>{if(!tu(e.getExpression()))return[];const t=e.getArguments();return t.flatMap((s,n)=>{const i=xe(h(s)??s),o=t.some((a,c)=>c!==n&&Mt(a));return i!==void 0&&o?[i]:[]})},nu=e=>{if(r.isThrowStatement(e))return!0;if(!r.isBlock(e))return!1;const t=e.getStatements().at(-1);return t!==void 0&&r.isThrowStatement(t)},iu=e=>r.isArrowFunction(e)||r.isFunctionExpression(e)||r.isFunctionDeclaration(e)||r.isMethodDeclaration(e),Js=(e,t)=>{for(let s=e.getParent();s!==void 0;s=s.getParent()){if(s===t||s.compilerNode===t.compilerNode)return!0;if(!(r.isBlock(s)||r.isExpressionStatement(s)||r.isAwaitExpression(s)||r.isParenthesizedExpression(s)||r.isVariableStatement(s)||r.isVariableDeclarationList(s)||r.isVariableDeclaration(s)))return!1}return!1},ru=e=>r.isAwaitExpression(e.getParent())||e.getType().isVoid(),ou=(e,t)=>{const s=new Set;for(const n of e.getDescendantsOfKind(d.IfStatement))if(n.getEnd()<=t&&Js(n,e)&&nu(n.getThenStatement()))for(const i of Ke(n.getExpression()))s.add(i);for(const n of e.getDescendantsOfKind(d.CallExpression))if(n.getEnd()<=t&&ru(n)&&Js(n,e))for(const i of su(n))s.add(i);return s},au=(e,t)=>{const s=fi(t);if(s.size===0)return!1;const n=e.getFirstAncestor(iu);if(n===void 0)return!1;const i=ou(n,e.getStart());return[...s].every(o=>i.has(o))},cu=new Set(["at","concat","filter","find","findLast","flat","reverse","slice","sort","toReversed","toSorted"]),lu=new Map([["Array",new Set(["from","of"])],["Object",new Set(["entries","values"])]]),_t=new Set(["catch","every","filter","finally","find","findIndex","findLast","findLastIndex","flatMap","forEach","map","reduce","reduceRight","some","sort","then"]),gi=e=>e.getNameNode().getDescendantsOfKind(d.BindingElement).filter(t=>r.isIdentifier(t.getNameNode())),du=e=>{const t=I(e),s=t.getParent();if(r.isVariableDeclaration(s))return y(s.getInitializer(),t)?s:void 0;const n=r.isForOfStatement(s)&&s.getExpression()===t?s.getInitializer():void 0;return r.isVariableDeclarationList(n)?n.getDeclarations()[0]:void 0},uu=e=>{const t=du(e);return t===void 0?void 0:r.isIdentifier(t.getNameNode())?r.isForOfStatement(t.getParent().getParent())||ie(t)?[t]:void 0:gi(t)},Se=e=>e.isUnion()?e.getUnionTypes().every(t=>Se(t)):e.isIntersection()?e.getIntersectionTypes().some(t=>Se(t)):!e.isAny()&&!e.isUnknown()&&!e.isObject()&&!e.isTypeParameter(),qe=(e,t,s)=>{const n=r.isCallExpression(e)?h(e.getExpression()):void 0;return r.isPropertyAccessExpression(n)&&t.has(n.getName())&&(s===void 0||n.getExpression()===s)},ze=e=>{const t=h(e);if(!r.isArrowFunction(t)&&!r.isFunctionExpression(t))return;const s=t.getBody();return r.isBlock(s)?s.getDescendantsOfKind(d.ReturnStatement).filter(n=>n.getFirstAncestor(i=>r.isFunctionLikeDeclaration(i))===t).map(n=>n.getExpression()):[s]},fu=e=>{const t=r.isCallExpression(e)?h(e.getExpression()):void 0,s=r.isPropertyAccessExpression(t)?t.getExpression():void 0;return r.isPropertyAccessExpression(t)&&r.isIdentifier(s)&&lu.get(s.getText())?.has(t.getName())===!0&&We(s)},gu=e=>{const t=wt(e);if(!r.isArrowFunction(t)&&!r.isFunctionExpression(t))return;const s=I(t),n=s.getParent();return r.isCallExpression(n)&&n.getArguments().includes(s)&&qe(n,Kn)?n:void 0},pu=(e,t)=>{if(!(r.isPropertyAccessExpression(e)||r.isElementAccessExpression(e))||e.getExpression()!==t)return;const s=I(e),n=s.getParent();return!r.isCallExpression(n)||n.getExpression()!==s?e:qe(n,cu,t)?n:void 0},mu=(e,t)=>{if(r.isAwaitExpression(e))return e;if(r.isConditionalExpression(e))return e.getCondition()===t?void 0:e;const s=r.isBinaryExpression(e)?e.getOperatorToken().getKind():void 0;return s===d.QuestionQuestionToken||s===d.BarBarToken||s===d.AmpersandAmpersandToken?e:void 0},hu=(e,t)=>{if(r.isArrayLiteralExpression(e))return e;const n=r.isSpreadElement(e)||r.isSpreadAssignment(e)||r.isShorthandPropertyAssignment(e)||r.isPropertyAssignment(e)&&y(e.getInitializer(),t)?e.getParent():void 0;return r.isArrayLiteralExpression(n)||r.isObjectLiteralExpression(n)?n:void 0},Zs=e=>{const t=I(e),s=t.getParent();if(s===void 0)return;const n=r.isCallExpression(s)&&s.getArguments().includes(t)&&fu(s);return pu(s,t)??mu(s,t)??hu(s,t)??(n?s:gu(t))},vu=5e4,pi=()=>({inProgress:new Set,verdicts:new Map});class Eu{cuts=0;work=0;reset(){this.work=0}cut(){return this.cuts+=1,!0}spend(){return this.work+=1,this.work>vu&&this.cut()}memoized(t,s,n){const i=n.verdicts.get(t);if(i!==void 0)return i;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 xu=8,Su=8;class Au{budget;scope;taint;verdicts=pi();constructor(t,s,n){this.scope=t,this.budget=s,this.taint=n}isCompromised(t){return this.flowHasCompromisingUse(t)&&!Se(t.getType())}flowHasCompromisingUse(t){return this.budget.memoized(t.compilerNode,()=>{const s=this.budget.cuts,n=[],i=new Set,o=(c,l)=>{i.has(c.compilerNode)||(i.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 i)this.verdicts.verdicts.set(c,!1);return a},this.verdicts)}visitBinding({binding:t,hops:s},n,i){const o=t.getNameNode();if(!r.isIdentifier(o)){for(const l of r.isParameterDeclaration(t)?gi(t):[])i(l,s);return!1}if(this.budget.spend())return!0;const a=(l,u)=>u&&s>=xu?this.budget.cut():(i(l,u?s+1:s),!1);return this.taint.referencesTo(t,o.getText()).some(l=>this.valueCompromises(I(l),!0,a,0))&&(t===n||!Se(t.getType()))}valueCompromises(t,s,n,i){let o=t;for(let m=Zs(o);m!==void 0;m=Zs(o)){if(r.isCallExpression(m)&&this.callbackCompromises(m,n))return!0;o=I(m)}const a=o.getParent(),c=o===t&&s,l=()=>!c&&Se(o.getType());if(Je(o))return!c&&(!r.isBinaryExpression(a)||this.taint.isTaintedValue(a.getRight(),!1));const u=uu(o);if(u!==void 0)return u.some(m=>n(m,!0));const f=r.isPropertyAccessExpression(a)&&a.getExpression()===o?a.getParent():void 0;if(r.isCallExpression(f)&&f.getExpression()===a)return this.methodCallCompromises(f,n);const g=this.nestedReturningFunctionOf(o);return g!==void 0?this.resultCompromises(g,n,i)&&!l():this.positionCompromises(o,n)&&!l()}resultCompromises(t,s,n){const i=I(t).getParent();if(n>=Su)return this.budget.cut();if(r.isCallExpression(i))return i.getExpression()===I(t)?this.valueCompromises(i,!1,s,n+1):!qe(i,_t);const o=r.isFunctionDeclaration(t)?t:i,a=r.isFunctionDeclaration(o)||ie(o)?o.getNameNode():void 0;return o===void 0||!r.isIdentifier(a)?!0:this.taint.referencesTo(o,a.getText()).some(c=>{const l=I(c),u=l.getParent();return!r.isCallExpression(u)||u.getExpression()!==l||this.valueCompromises(u,!1,s,n+1)})}methodCallCompromises(t,s){return t.getArguments().filter(i=>ze(i)===void 0).some(i=>this.taint.isTaintedValue(i,!1))||this.callbackCompromises(t,s)}callbackCompromises(t,s){const n=qe(t,_t)?t.getArguments()[0]:void 0;if(n===void 0)return!1;const i=Dt(n);return i!==void 0&&this.taint.isInImpl(i)?i.getParameters().some(o=>s(o,!1)):this.taint.isTaintedValue(n,!1)}positionCompromises(t,s){const n=t.getParent();if(r.isCallExpression(n)&&n.getArguments().includes(t))return this.argumentCompromises(n,t,s);const i=r.isSpreadElement(n)?n.getParent():void 0;if(n!==void 0&&r.isCallExpression(i))return!Lt(n,this.scope.context)&&this.isOpaqueCallTainted(i.getExpression(),i.getArguments(),n);if(r.isNewExpression(n))return this.isOpaqueCallTainted(n.getExpression(),n.getArguments(),t);if(r.isTemplateSpan(n)){const o=n.getParent(),a=o.getParent(),c=o.getTemplateSpans().map(l=>l.getExpression());return r.isTaggedTemplateExpression(a)&&this.isOpaqueCallTainted(a.getTag(),c,t)}return!this.isReadPosition(t)}argumentCompromises(t,s,n){if(Lt(s,this.scope.context))return!1;const i=Dt(t.getExpression()),o=i===void 0?void 0:li(i,t,s);return o?.kind==="unreached"?!1:o?.kind==="parameter"&&i!==void 0&&this.taint.isInImpl(i)?n(o.parameter,!1):this.isOpaqueCallTainted(t.getExpression(),t.getArguments(),s)}isReadPosition(t){const s=t.getParent();return s===void 0||r.isExpressionStatement(s)||r.isForStatement(s)||r.isElementAccessExpression(s)||di(t)||y(wt(t),this.scope.impl)}isOpaqueCallTainted(t,s,n){const i=!r.isIdentifier(h(n));return this.taint.isTaintedValue(t,!1)||s.some(o=>(o!==n||i)&&this.taint.isTaintedValue(o,!1))}nestedReturningFunctionOf(t){const s=wt(t);return y(s,this.scope.impl)?void 0:s}}const yu=new Set(["at","every","filter","finally","find","findIndex","findLast","findLastIndex","forEach","order","slice","some","sort","withIndex","withSearchIndex"]),bu=e=>{const t=h(e);if(!r.isIdentifier(t))return r.isPropertyAccessExpression(t)||r.isElementAccessExpression(t);const s=L(t),n=r.isVariableDeclaration(s)?h(s.getInitializer()):void 0;return s===void 0||r.isFunctionDeclaration(s)||r.isParameterDeclaration(s)||r.isArrowFunction(n)||r.isFunctionExpression(n)},Nu=new Set(["all","allSettled","any","race"]),en=e=>r.isParameterDeclaration(e)?e:r.isBindingElement(e)?e.getFirstAncestorByKind(d.Parameter):void 0,St=8;class Pu{budget=new Eu;referencesByDeclaration=new Map;referencesByName=new Map;scope;verdicts=pi();walk;variableDepth=0;queryDepth=0;constructor(t){this.scope=t,this.walk=new Au(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,St)?!1:(r.isIdentifier(t)?[t]:t.getDescendantsOfKind(d.Identifier)).some(i=>Tr(i)&&this.isIdentifierTainted(i))}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 i of this.referencesByName.get(s)??[]){const o=L(i)?.compilerNode;o!==void 0&&n.set(o,[...n.get(o)??[],i])}this.referencesByDeclaration.set(s,n)}return(n.get(t.compilerNode)??[]).filter(i=>i.getParent()!==t)}flowsIntoTainted(t){if([t.getInitializer(),...t.getDescendantsOfKind(d.BindingElement).map(g=>g.getInitializer())].some(g=>g!==void 0&&this.isTaintedValue(g,!1)))return!0;const n=t.getParentOrThrow(),i=r.isFunctionLikeDeclaration(n)?n.getParameters().findIndex(g=>g.compilerNode===t.compilerNode):-1,o=I(n),a=o.getParent();if(i===-1)return!0;if(r.isCallExpression(a)){if(a.getExpression()===o)return this.isCallSiteTainted(a,i,t.isRestParameter());const g=h(a.getExpression());if(!r.isPropertyAccessExpression(g)||!_t.has(g.getName()))return!0;const m=a.getArguments().filter(v=>v!==o);return this.isTaintedValue(g.getExpression(),!0)||m.some(v=>this.isTaintedValue(v,!1))}const c=r.isVariableDeclaration(a)&&ie(a)?a:void 0,l=r.isFunctionDeclaration(n)?n:c,u=l?.getNameNode();if(l===void 0||!r.isIdentifier(u))return!0;const f=this.referencesTo(l,u.getText());return f.length===0||f.some(g=>{const m=I(g),v=m.getParent();return!r.isCallExpression(v)||v.getExpression()!==m||this.isCallSiteTainted(v,i,t.isRestParameter())})}isCallSiteTainted(t,s,n){const i=t.getArguments(),o=i.findIndex(c=>r.isSpreadElement(c)),a=c=>c===s||n&&c>s||o!==-1&&o<=s&&c>=o;return i.some((c,l)=>a(l)&&this.isTaintedValue(c,!1))}isContextRootedCombinator(t,s){const n=h(t.getExpression()),i=r.isPropertyAccessExpression(n)?n.getExpression():void 0,a=r.isPropertyAccessExpression(n)&&r.isIdentifier(i)&&i.getText()==="Promise"&&We(i)&&Nu.has(n.getName())?h(t.getArguments()[0]):void 0;if(r.isArrayLiteralExpression(a)){const f=a.getElements();return f.length>0&&f.every(g=>!r.isSpreadElement(g)&&this.isRootedInContext(g,s))}const c=r.isCallExpression(a)?h(a.getExpression()):void 0,l=r.isCallExpression(a)&&r.isPropertyAccessExpression(c)&&c.getName()==="map"?h(a.getArguments()[0]):void 0,u=l===void 0?void 0:ze(l);return u!==void 0&&u.length>0&&u.every(f=>f!==void 0&&this.isRootedInContext(f,s))}isIdentifierTainted(t){const s=t.getText();if(s==="arguments")return!0;const n=L(t),i=en(n);if(i!==void 0)return this.isSource(i);if(s==="args")return!0;if(n===void 0||!this.isInImpl(n))return!1;if(r.isFunctionDeclaration(n))return this.budget.memoized(n.compilerNode,()=>this.isTaintedValue(n,!1),this.verdicts);if(r.isBindingElement(n)&&this.walk.isCompromised(n))return!0;const o=r.isBindingElement(n)?n.getFirstAncestorByKind(d.VariableDeclaration):n;return r.isVariableDeclaration(o)&&this.isVariableTainted(o)}callChainVerdict(t,s){if(this.isContextRootedCombinator(t,s))return!0;const n=h(t.getExpression()),i=r.isPropertyAccessExpression(n)?n.getName():void 0;return i!==void 0&&_n.has(i)?!1:i!==void 0&&Kn.has(i)?this.isCallbackResultServerScoped(t,s)?void 0:!1:t.getArguments().some(a=>ze(a)!==void 0)&&(i===void 0||!yu.has(i))?!1:void 0}isCallbackResultServerScoped(t,s){const n=(i,o=[])=>{const a=Xe(i),c=r.isIdentifier(a)?en(L(a)):void 0;return c!==void 0&&o.includes(c)?!0:this.isRootedInContext(i,s)||!this.isTaintedValue(i,!1)};return t.getArguments().every(i=>{const o=ze(i);if(o===void 0)return!bu(i)&&n(i);const a=h(i),c=r.isArrowFunction(a)||r.isFunctionExpression(a)?a.getParameters():[];return o.every(l=>l===void 0||n(l,c))})}isRootedInContext(t,s){const n=br(t,u=>this.callChainVerdict(u,s)),i=n.root;if(n.verdict!==void 0)return n.verdict;if(ci(i,this.scope.context))return!0;const o=r.isIdentifier(i)?L(i):void 0,a=r.isBindingElement(o)?o.getFirstAncestorByKind(d.VariableDeclaration):o,c=ie(a)&&this.isInImpl(a)?a.getInitializer():void 0,l=r.isBindingElement(o)?o:a;return s>0&&c!==void 0&&(r.isBindingElement(l)||r.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(r.isCatchClause(t.getParent())||this.walk.isCompromised(t))return!0;if(r.isForOfStatement(s)||r.isForInStatement(s))return this.isTaintedValue(s.getExpression(),!0);const n=t.getInitializer(),i=qt(t);if(n===void 0||i)return!0;if(this.isRootedInContext(n,St))return!1;if(this.variableDepth>=St)return this.budget.cut();this.variableDepth+=1;try{return this.isTaintedValue(n,!1)}finally{this.variableDepth-=1}},this.verdicts)}}const tn=new WeakMap,wu=e=>{const t=tn.get(e.impl.compilerNode);if(t!==void 0)return t;const s=new Pu(e);return tn.set(e.impl.compilerNode,s),s},Iu=new Set(["accountId","authorId","createdBy","createdById","organizationId","orgId","ownerId","tenantId","updatedBy","userId","workspaceId"]),Tu=new Set(["insert","insertManyUnsafe","patch","replace"]),Cu=e=>{if(!r.isPropertyAccessExpression(e))return;const t=e.getName();return Tu.has(t)&&Rr(e.getExpression())?t:void 0},Ou=(e,t)=>{if(t!=="insertManyUnsafe")return r.isObjectLiteralExpression(e)?[e]:[];if(!r.isArrayLiteralExpression(e))return[];const s=[];for(const n of e.getElements())r.isObjectLiteralExpression(n)&&s.push(n);return s},ku=(e,t)=>{const s=Wt(e);return s?.member===t?h(s.object):void 0},sn=(e,t)=>r.isIdentifier(e)&&L(e)?.compilerNode===t.compilerNode,mi=(e,t,s,n=1)=>{const i=ku(e,s);if(i!==void 0)return sn(i,t);const o=r.isIdentifier(e)?L(e):void 0;if(r.isBindingElement(o)){const c=o.getParent(),l=c.getParent();return o.getDotDotDotToken()===void 0&&ce(o)===s&&r.isObjectBindingPattern(c)&&(l.compilerNode===t.compilerNode||ie(l)&&sn(h(l.getInitializer()),t))}const a=ie(o)?o.getInitializer():void 0;return n>0&&a!==void 0&&mi(a,t,s,n-1)},Kt=e=>{const t=h(e)??e;return r.isConditionalExpression(t)?[...Kt(t.getWhenTrue()),...Kt(t.getWhenFalse())]:[t]},Ru=(e,t,s)=>{const n=[],i=s===void 0?void 0:wu(s);for(const o of e.getProperties()){let a,c;if(r.isPropertyAssignment(o)?(a=S(o),c=o.getInitializer()):r.isShorthandPropertyAssignment(o)&&(a=S(o),c=o.getNameNode()),a===void 0||c===void 0||!Iu.has(a))continue;const l=Kt(c).filter(f=>i===void 0?q(f)&&!Fr(f):i.isTaintedValue(f,!0));if(l.length>0){const f=t.ownerField===a&&s?.pristine===!0&&mi(c,s.parameter,a),g=l.every(m=>au(t.call,m));n.push({field:a,file:t.relativePath,line:t.call.getStartLineNumber(),method:t.method,scope:t.scope,...f&&{ownerScoped:!0},...g&&{guarded:!0}})}}return n},Fu=(e,t,s)=>{const n=Cu(e.getExpression()),i=n===void 0?void 0:e.getArguments()[1];if(n===void 0||i===void 0)return[];const o=Ou(i,n);if(o.length===0)return[];const a=x(e),c=Zd(e),l={call:e,method:n,ownerField:c===void 0?void 0:s(c.mutatorName),relativePath:t,scope:a};return o.flatMap(u=>Ru(u,l,c))},Lu=(e,t,s=[],n=[])=>{const i=new Map(n.map(c=>[`${c.filePath}:${c.exportName}`,c.owner])),o=T(e,t,(c,l)=>Fu(c,l,u=>i.get(`${l}:${u}`))),a=new Map(s.map(c=>[`${c.filePath}:${c.exportName}`,c.adminOnly===!0]));return Ht(o,s).map(c=>Cr(c.scope)?.every(f=>a.get(`${c.file}:${f}`)===!0)===!0?{...c,adminOnly:!0}:c)},Du=new Set(["createAutumnAdapter","createDodoPaymentsAdapter","createPolarAdapter","createStripeAdapter"]),Mu=e=>e&&r.isNumericLiteral(e)?Number(e.getText()):void 0,_u=e=>{const t=V(e,"webhookToleranceSeconds");return t&&r.isPropertyAssignment(t)?Mu(t.getInitializer()):void 0},Ku=(e,t)=>{const s=P(e.getExpression());if(s===void 0||!Du.has(s))return;const[n]=e.getArguments(),i=n&&r.isObjectLiteralExpression(n)?_u(n):void 0;return{callee:s,scope:x(e),file:t,line:e.getStartLineNumber(),...i===void 0?{}:{toleranceSeconds:i}}},zu=(e,t)=>T(e,t,Ku),$u=new Map([["defineQueue",0],["defineSubscription",1],["defineWorkflow",0]]),Bu=e=>{const t=e.getExpression();return r.isIdentifier(t)?t.getText():void 0},Vu=(e,t)=>{const s=e.getArguments()[t];if(!s||!r.isObjectLiteralExpression(s))return;const n=V(s,"handler");if(n===void 0||!r.isPropertyAssignment(n))return;const i=n.getInitializer();if(i&&(r.isArrowFunction(i)||r.isFunctionExpression(i)))return i},hi=(e,t)=>{const s=e.getParameters()[t]?.getNameNode();return s&&r.isIdentifier(s)?s.getText():void 0},vi=(e,t)=>e===t||e.startsWith(`${t}.`),Ei=e=>{const t=e.getDescendantsOfKind(d.PropertyAccessExpression);return r.isPropertyAccessExpression(e)&&t.push(e),t},nn=e=>{const t=e.getParent();return r.isPropertyAccessExpression(t)&&t.getNameNode()===e||r.isPropertyAssignment(t)&&t.getNameNode()===e?!1:!(r.isBindingElement(t)&&t.getNameNode()===e)},xi=e=>{const t=e.getDescendantsOfKind(d.Identifier).filter(s=>nn(s));return r.isIdentifier(e)&&nn(e)&&t.push(e),t},Uu=e=>{if(!r.isVariableDeclaration(e))return[];const t=e.getNameNode();return r.isIdentifier(t)?[t.getText()]:t.getDescendantsOfKind(d.BindingElement).map(s=>s.getName())},Wu=e=>{const t=hi(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 i=n.getInitializer(),o=r.isVariableDeclarationList(i)?i.getDeclarations()[0]?.getNameNode():void 0;o&&r.isIdentifier(o)&&s.push(`${o.getText()}.body`)}return s},qu=(e,t,s)=>{const n=t==="workflow"?[`${s}.params`]:Wu(e),i=new Set,o=a=>Ei(a).some(c=>n.some(l=>vi(c.getText(),l)))?!0:xi(a).some(c=>i.has(c.getText()));for(const a of e.getDescendantsOfKind(d.VariableDeclaration)){const c=a.getInitializer();if(c&&o(c))for(const l of Uu(a))i.add(l)}return{names:i,prefixes:n}},ju=(e,t)=>Ei(e).some(s=>t.prefixes.some(n=>vi(s.getText(),n)))?!0:xi(e).some(s=>t.names.has(s.getText())),Hu=e=>{const t=Nr(e);return t===void 0?void 0:{exportName:String(t.at(-1)),file:t.slice(0,-1).join("/")}},Gu=(e,t,s)=>{const n=hi(e,0);if(n===void 0)return[];const i=qu(e,t,n),o=new Set([n,...i.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(!r.isPropertyAccessExpression(l)||!Ln.has(l.getName())||!o.has(l.getExpression().getText()))continue;const u=c.getArguments()[1];if(!u||!ju(u,i))continue;const f=Hu(c.getArguments()[0]);f!==void 0&&a.push({dispatchKind:t,file:s,scope:x(c),line:c.getStartLineNumber(),targetExport:f.exportName,targetFile:f.file})}return a},Yu=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression)){const i=Bu(n),o=i===void 0?void 0:$u.get(i);if(o===void 0)continue;const a=Vu(n,o);a!==void 0&&s.push(...Gu(a,i==="defineWorkflow"?"workflow":"queue",t))}return s},Qu=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Yu(i,w(t,n)))}return s},rn={dbRateLimit:"usesRateLimit",emailGateMiddleware:"usesEmailGate",mask:"usesMask",rateLimit:"usesRateLimit",rls:"usesRls",verifyTurnstileMiddleware:"usesCaptcha"},on=new Set(["account","credential","member","passkey","session","user"]),Xu=e=>e.replaceAll(/[-_]/gu," ").replaceAll(/([a-z0-9])([A-Z])/gu,"$1 $2").split(" ").filter(Boolean).map(t=>t.toLowerCase()),Ju=e=>{const s=Xu(e).at(-1);if(!s)return!1;const n=s.endsWith("s")?s.slice(0,-1):s;return on.has(s)||on.has(n)},Zu=e=>{const t=e.replaceAll(/[^a-z0-9]/giu,"").toLowerCase();return t.endsWith("email")||t.endsWith("emailaddress")},ef=(e,t)=>{const{objects:s,opaque:n}=Jt(e,t);return dc(s).some(i=>Zu(i))?!0:n?void 0:!1},tf=e=>{const t=e.getArguments()[0];return!t||!r.isObjectLiteralExpression(t)?{usesCaptcha:!1,usesRateLimit:!1}:{usesCaptcha:!!V(t,"captcha"),usesRateLimit:!!V(t,"rateLimit")}},sf=e=>{if(r.isCallExpression(e))return e;if(!r.isIdentifier(e))return;const s=e.getSourceFile().getVariableDeclaration(e.getText())?.getInitializer();return s&&r.isCallExpression(s)?s:void 0},$e={usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},nf=e=>{const t=sf(e),s=t?P(t.getExpression()):void 0;if(t&&s==="protectPublic"){const n=tf(t);return{...$e,usesCaptcha:n.usesCaptcha,usesRateLimit:n.usesRateLimit}}return s!==void 0&&s in rn?{...$e,[rn[s]]:!0}:$e},rf=e=>{const t={...$e};let s=e;for(;r.isCallExpression(s);){const n=s.getExpression();if(!r.isPropertyAccessExpression(n))break;const i=n.getName()==="use"?s.getArguments()[0]:void 0;if(i){const o=nf(i);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},of=new Set(["insert","insertMany","insertManyUnsafe","replace"]),af=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||!of.has(t.getName()))return!1;const s=t.getExpression();if(!z(s))return!1;const i=e.getArguments()[0];return!i||!(r.isStringLiteral(i)||r.isNoSubstitutionTemplateLiteral(i))?!1:Ju(i.getLiteralText())},cf=new Set(["create","publish","publishBatch","runAfter","runAt","send","sendBatch"]),an=new Set(["queues","scheduler","topics","workflows"]),lf=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||!cf.has(t.getName()))return!1;let s=t.getExpression();for(;r.isCallExpression(s)||r.isElementAccessExpression(s)||r.isPropertyAccessExpression(s);){if(r.isPropertyAccessExpression(s)&&an.has(s.getName())&&Lr(s.getExpression()))return!0;s=s.getExpression()}const n=Gt(s);return n?.length===1&&an.has(n[0]??"")},df=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||t.getName()!=="insertManyUnsafe")return!1;const s=t.getExpression();return z(s)},Si=new Set(["generateObject","generateText","streamObject","streamText"]),uf=e=>{const t=P(e.getExpression());return t!==void 0&&Si.has(t)},ff=e=>{const t=P(e.getExpression());if(t===void 0||!Si.has(t))return!1;const s=e.getArguments()[0];return!s||!r.isObjectLiteralExpression(s)||s.getProperties().some(n=>r.isSpreadAssignment(n))?!1:!V(s,"maxOutputTokens")},gf=new Set(["log","span","trace"]),pf=new Set(["ai"]),mf=new Set(["email","mail"]),hf=new Set(["ai","browser","fetch","mail","notify","queues","sql","storage","topics","workflows"]),At=(e,t)=>[...t].some(s=>Ze(e,s).length>0),Ai=new Set([d.ArrowFunction,d.FunctionDeclaration,d.FunctionExpression,d.GetAccessor,d.MethodDeclaration,d.SetAccessor]),vf=new Set(["every","filter","flatMap","forEach","map","some"]),Ef=new Set(["all","allSettled","race"]),yi=e=>{const t=e.getParent();if(!t||!r.isCallExpression(t)||!t.getArguments().includes(e))return;const s=t.getExpression();if(!r.isPropertyAccessExpression(s))return;const n=s.getName();if(vf.has(n))return t;const i=s.getExpression();if(r.isIdentifier(i)&&i.getText()==="Promise"&&Ef.has(n))return t},xf=e=>{let t=e.getParent();for(;t;){if(r.isTryStatement(t)){const s=t.getTryBlock();if(e.getPos()>=s.getPos()&&e.getEnd()<=s.getEnd())return!0}if(Ai.has(t.getKind())){const s=yi(t);if(!s)return!1;t=s;continue}t=t.getParent()}return!1},Sf=e=>{let t=e.getParent();for(;t!==void 0;){if(r.isCallExpression(t)&&t.getExpression().getText()==="Promise.allSettled")return!0;if(Ai.has(t.getKind())){if(t=yi(t),t===void 0)return!1;continue}t=t.getParent()}return!1},Af=e=>{const t=e.getFirstAncestor(u=>r.isArrowFunction(u)||r.isFunctionExpression(u)),s=t?.getParent();if(!t||!r.isCallExpression(s)||!s.getArguments().includes(t))return!1;const n=s.getExpression();if(!r.isIdentifier(n))return!1;const i=n.getSymbol(),o=i?.getAliasedSymbol()?.getValueDeclaration()??i?.getValueDeclaration(),a=r.isVariableDeclaration(o)?o.getInitializer():o;if(!r.isArrowFunction(a)&&!r.isFunctionExpression(a)&&!r.isFunctionDeclaration(a))return!1;const c=s.getArguments().indexOf(t),l=a.getParameters()[c]?.getName();return l===void 0?!1:a.getDescendantsOfKind(d.TryStatement).some(u=>{const f=u.getTryBlock().getDescendantsOfKind(d.CallExpression).some(m=>{const v=m.getExpression();return r.isIdentifier(v)&&v.getText()===l&&r.isAwaitExpression(m.getParent())}),g=u.getCatchClause();return f&&g!==void 0&&g.getDescendantsOfKind(d.ThrowStatement).length>0})},yf=e=>{let t=e;for(;;){const s=t.getParent();if(!r.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(!r.isCallExpression(n)||n.getExpression()!==s)return!1;t=n}},bf=e=>{let t=e;for(;;){const s=t.getParent();if(r.isPropertyAccessExpression(s)&&s.getExpression()===t){t=s;continue}return r.isCallExpression(s)&&s.getExpression()===t?s:void 0}},Nf=e=>{let t=!1,s=!0;for(const n of[...hf].flatMap(i=>Ze(e,i))){const i=bf(n);i&&(t=!0,!xf(i)&&!yf(i)&&!Af(i)&&!Sf(i)&&(s=!1))}return{handlesErrors:t&&s,reachesOutbound:t}},Pf=e=>e.getDescendantsOfKind(d.ThrowStatement).some(t=>{const s=t.getExpression();if(!r.isNewExpression(s))return!1;const n=s.getExpression();return r.isIdentifier(n)&&n.getText()==="Error"}),cn="lunora-advisor-exempt",wf=/^[\s*/]+/u,If=/[\w-]/u,Tf=e=>{const s=(e.getFirstAncestorByKind(d.VariableStatement)??e).getLeadingCommentRanges().map(n=>n.getText()).join(`
22
+ `);for(const n of s.split(`
23
+ `)){const i=n.replace(wf,"");if(!i.startsWith(cn))continue;const o=i.slice(cn.length);if(If.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:""}},Cf=e=>{const[t]=e.getArguments();if(t){if(r.isObjectLiteralExpression(t)){const s=V(t,"handler");return s?r.isPropertyAssignment(s)?s.getInitializer():r.isShorthandPropertyAssignment(s)?s.getNameNode():r.isMethodDeclaration(s)?s:void 0:void 0}return t}},Of=(e,t)=>{const s=Cf(t);if(!s)return;if(r.isArrowFunction(s)||r.isFunctionExpression(s)||r.isMethodDeclaration(s))return e;if(!r.isIdentifier(s))return;const n=s.getSourceFile(),i=s.getText(),o=n.getVariableDeclaration(i)?.getInitializer();return o&&(r.isArrowFunction(o)||r.isFunctionExpression(o))?o:n.getFunction(i)},kf=e=>{let t=!1,s=!1,n=!1,i=!1,o=!1;for(const l of e.getDescendantsOfKind(d.CallExpression))if(af(l)&&(o=!0),lf(l)&&(t=!0),df(l)&&(i=!0),uf(l)&&(s=!0),ff(l)&&(n=!0),o&&t&&i&&n)break;const{handlesErrors:a,reachesOutbound:c}=Nf(e);return{callsMail:At(e,mf),emitsEvent:At(e,gf),fanOut:t,handlesErrors:a,reachesOutbound:c,runsAiGeneration:s||At(e,pf),throwsBareError:Pf(e),unboundedAiGeneration:n,usesInsertManyUnsafe:i,writesUserTable:o}},Rf=(e,t)=>{const s=e.getInitializer();if(!s||!r.isCallExpression(s))return;const n=ee(s);if(!n||n.kind!=="query"&&n.kind!=="mutation"&&n.kind!=="action")return;const i=n.receiver?rf(n.receiver):{usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},o=Of(e,s);return{...o?kf(o):{},...Tf(e),...i,analyzableBody:o!==void 0,exportName:j(e)??e.getName(),file:t,hasEmailArg:ef(s,n.receiver),kind:n.kind,visibility:n.visibility}},Ff=(e,t)=>{const s=[];for(const n of Q(e)){const i=Rf(n,t);i&&s.push(i)}return s},Lf=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Ff(i,w(t,n)))}return s},Df=new Set(["dbRateLimit","rateLimit"]),Mf=e=>r.isArrowFunction(e)?e.getBody():e,_f=e=>{if(!r.isArrowFunction(e))return;const t=e.getParameters()[0]?.getNameNode();return t!==void 0&&r.isIdentifier(t)?t:void 0},bi=e=>{const t=e.getParent();return r.isPropertyAccessExpression(t)&&t.getExpression()===e&&t.getName()==="args"},Ni=(e,t)=>{const s=t.getSymbol();return s===void 0?[]:e.getDescendantsOfKind(d.Identifier).filter(n=>{if(n.getSymbol()!==s)return!1;const i=n.getParent();return!(r.isPropertyAccessExpression(i)&&i.getNameNode()===n)})},Kf=(e,t)=>q(e)||t!==void 0&&Ni(e,t).some(s=>bi(s)),zf=(e,t)=>t===void 0?le(e):Ni(e,t).some(s=>!bi(s)),$f=(e,t)=>{const s=P(e.getExpression());if(s===void 0||!Df.has(s))return;const n=R(Fn(e.getArguments()[2]),"key");if(!n)return;const i=Mf(n),o=_f(n);if(!(!Kf(i,o)||zf(i,o)))return{callee:s,scope:x(e),file:t,limitName:Rn(e),line:e.getStartLineNumber()}},Bf=(e,t)=>T(e,t,$f),Vf=new Set(["findFirst","findFirstOrThrow","findMany","findUnique","get"]),Uf=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||!Vf.has(t.getName()))return;const s=t.getExpression();if(z(s)){const n=e.getArguments()[0];return n&&r.isStringLiteral(n)?n.getLiteralText():""}if(r.isPropertyAccessExpression(s)&&z(s.getExpression()))return s.getName()},Wf=e=>{let t=e;for(;r.isCallExpression(t);){const s=t.getExpression();if(!r.isPropertyAccessExpression(s))return;if(s.getName()==="query"&&z(s.getExpression())){const n=t.getArguments()[0];return n&&r.isStringLiteral(n)?n.getLiteralText():""}t=s.getExpression()}},qf=e=>{let t=h(e)??e;for(;r.isAwaitExpression(t);)t=h(t.getExpression())??t.getExpression();return t},Pi=(e,t=!1)=>{const s=qf(e);if(r.isIdentifier(s)){if(t)return;const n=Y(s);return n===void 0?void 0:Pi(n,!0)}if(r.isCallExpression(s))return Uf(s)??Wf(s)},jf=e=>{const t=e.getBody();if(!r.isBlock(t))return[t];const s=[];for(const n of e.getDescendantsOfKind(d.ReturnStatement)){const i=n.getFirstAncestor(a=>r.isArrowFunction(a)||r.isFunctionExpression(a)||r.isFunctionDeclaration(a)),o=n.getExpression();i===e&&o!==void 0&&s.push(o)}return s},Hf=(e,t)=>{if(!r.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!r.isCallExpression(s))return[];const n=ee(s);if(n?.kind!=="query")return[];const i=si(s);if(i===void 0)return[];const o=n.receiver!==void 0&&_r(n.receiver,"output"),a=n.receiver!==void 0&&zn(n.receiver,"use","mask"),c=new Set,l=[];for(const u of jf(i)){const f=Pi(u);f===void 0||c.has(f)||(c.add(f),l.push({exportName:j(e)??e.getName(),file:t,line:u.getStartLineNumber(),table:f,usesMask:a,usesOutput:o,visibility:n.visibility}))}return l},Gf=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of Q(i))s.push(...Hf(a,o))}return s},Yf=e=>{if(!e||!r.isObjectLiteralExpression(e))return[];const t=[];for(const s of e.getProperties())(r.isPropertyAssignment(s)||r.isShorthandPropertyAssignment(s)||r.isMethodDeclaration(s)||r.isGetAccessorDeclaration(s))&&t.push(S(s));return t},Qf=(e,t)=>{if(!r.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&r.isCallExpression(s)?ee(s):void 0;if(!n)return[];const i=[];for(const o of e.getDescendantsOfKind(d.CallExpression)){const a=Bn(o);if(a===void 0)continue;const c=Yf(R(a.options,"with"));c.length!==0&&i.push({exportName:j(e)??e.getName(),file:t,line:o.getStartLineNumber(),parentTable:a.table,relations:c,visibility:n.visibility})}return i},Xf=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of Q(i))s.push(...Qf(a,o))}return s},W=(e,t)=>`${e}:${t}`,ln=(e,t,s,n)=>s===void 0?void 0:{endLine:e.getEndLineNumber(),exported:n,file:t,name:s,node:e,startLine:e.getStartLineNumber()},Jf=(e,t)=>[...ne(e,t,d.FunctionDeclaration,(s,n)=>s.getParent().getKind()===d.SourceFile?ln(s,n,s.getName(),s.isExported()):void 0),...ne(e,t,d.VariableDeclaration,(s,n)=>{const i=s.getVariableStatement();return i?.getParent().getKind()===d.SourceFile?ln(i,n,s.getName(),i.isExported()):void 0})],Zf=(e,t,s)=>{const n=e.getExpression();if(!r.isIdentifier(n))return;const i=n.getSymbol(),o=(i?.getAliasedSymbol()??i)?.getDeclarations()[0];if(o===void 0||!(r.isFunctionDeclaration(o)||r.isVariableDeclaration(o)))return;const a=o.getName(),c=w(s,o.getSourceFile().getFilePath());return a===void 0?void 0:t.get(W(c,a))},eg=e=>`${e.table}|${e.method}|${e.fields?.join(",")??"*"}`,tg=(e,t)=>{const s=new Map(e.map(n=>[W(n.file,n.name),new Map]));for(const n of t){const i=e.find(o=>o.file===n.file&&o.startLine<=n.line&&n.line<=o.endLine);i!==void 0&&n.table!==""&&s.get(W(i.file,i.name))?.set(eg(n),{fields:n.fields,method:n.method,table:n.table})}return s},sg=(e,t,s)=>e.node.getDescendantsOfKind(d.CallExpression).map(n=>Zf(n,t,s)).filter(n=>n!==void 0),ng=(e,t,s,n)=>{for(const i of e){const o=i.scope.kind==="module"?void 0:t.get(W(i.file,i.scope.name)),a=i.target===void 0?void 0:s.get(i.target);i.kind==="call"&&o!==void 0&&a!==void 0&&n.get(W(o.file,o.name))?.push(a)}},ig=(e,t,s)=>{const n=new Map(e.map(a=>[W(a.file,a.name),a])),i=new Map(e.map(a=>[`${Qt(a.file)}:${a.name}`,a])),o=new Map(e.map(a=>[W(a.file,a.name),sg(a,n,t)]));return ng(s,n,i,o),o},rg=(e,t)=>{let s=!1;for(const[n,i]of t??[])e!==void 0&&!e.has(n)&&(e.set(n,i),s=!0);return s},og=(e,t,s)=>{let n=!0;for(;n;){n=!1;for(const i of e)for(const o of s.get(W(i.file,i.name))??[])rg(t.get(W(i.file,i.name)),t.get(W(o.file,o.name)))&&(n=!0)}},ag=(e,t,s,n)=>{const i=Jf(e,t),o=tg(i,s);return og(i,o,ig(i,t,n)),i.filter(a=>a.exported).flatMap(a=>[...o.get(W(a.file,a.name))?.values()??[]].map(c=>({...c,exportName:a.name,file:a.file})))},je=e=>{if(r.isStringLiteral(e)||r.isNoSubstitutionTemplateLiteral(e))return e.getLiteralText();if(r.isBinaryExpression(e)&&e.getOperatorToken().getKind()===d.PlusToken){const t=je(e.getLeft()),s=je(e.getRight());return t!==void 0&&s!==void 0?t+s:void 0}},cg=e=>{let t=e,s=t.getParent();for(;s!==void 0&&r.isBinaryExpression(s)&&s.getOperatorToken().getKind()===d.PlusToken;)t=s,s=t.getParent();return t!==e&&je(t)!==void 0},lg=e=>{const t=e.getParent();if(t!==void 0){if(r.isVariableDeclaration(t)||r.isPropertyAssignment(t)||r.isPropertySignature(t))return S(t);if(r.isBinaryExpression(t)&&t.getOperatorToken().getKind()===d.EqualsToken)return t.getLeft().getText()}},dg=(e,t,s)=>so(e)?!Pr(s)&&no(lg(t)):!0,ug=(e,t)=>{const s=[],n=[...e.getDescendantsOfKind(d.BinaryExpression),...e.getDescendantsOfKind(d.StringLiteral),...e.getDescendantsOfKind(d.NoSubstitutionTemplateLiteral)],i=new Set;for(const o of n){if(cg(o))continue;const a=je(o);if(a===void 0)continue;const c=eo(a);if(c===void 0||!dg(c,o,t))continue;const l=o.getStartLineNumber(),u=`${String(l)}:${c}`;i.has(u)||(i.add(u),s.push({file:t,kind:c,line:l,preview:to(a)}))}return s},fg=(e,t)=>{const s=[],n=new Ut({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0});for(const i of A(t,{includeSkipped:!0})){const o=e.getSourceFile(i)??n.createSourceFile(i,Ye(i,"utf8"),{overwrite:!0});s.push(...ug(o,w(t,i)))}return s},gg=(e,t)=>{if(!r.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&r.isCallExpression(s)?ee(s):void 0;if(!n)return[];const i=[];for(const o of e.getDescendantsOfKind(d.CallExpression)){const a=Bn(o);if(a===void 0)continue;const c=R(a.options,"includeDeleted");if(c===void 0)continue;const l=r.isTrueLiteral(c),u=!l&&q(c);!l&&!u||i.push({exportName:j(e)??e.getName(),file:t,fromArgs:u,hardcodedTrue:l,line:o.getStartLineNumber(),table:a.table,visibility:n.visibility})}return i},pg=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),o=w(t,n);for(const a of Q(i))s.push(...gg(a,o))}return s},mg=new Set(["query","unsafe"]),hg=e=>!r.isPropertyAccessExpression(e)||!mg.has(e.getName())?!1:G(e.getExpression(),["sql"]),vg=e=>r.isBinaryExpression(e)||r.isTemplateExpression(e),Eg=(e,t)=>{if(!hg(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!vg(s)))return{file:t,line:s.getStartLineNumber(),scope:x(e)}},xg=(e,t)=>T(e,t,Eg),Sg=[["convex",["convex","@convex-dev/"]],["supabase",["@supabase/"]],["firebase",["firebase","@firebase/","firebase-admin"]]],Ag=e=>{for(const[t,s]of Sg)for(const n of s)if(e===n||e.startsWith(n.endsWith("/")?n:`${n}/`))return t},yg=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const o of i.getImportDeclarations()){const a=o.getModuleSpecifierValue(),c=Ag(a);c!==void 0&&s.push({file:w(t,n),line:o.getStartLineNumber(),moduleSpecifier:a,platform:c})}}return s},bg=new Set(["createMultipartUpload","delete","download","generateUploadUrl","get","getMetadata","getPresignedUrl","getSignedUrl","getUrl","head","put","resumeMultipartUpload","store","upload"]),Ng=(e,t,s=[])=>{const n=st(e,t,{argIndex:0,matchReceiver:i=>i==="ctx.storage"||i.startsWith("ctx.storage."),methods:bg,requireUnmodifiedReach:!0});return Ht(n,s)},Pg=new Map([["generateUploadUrl",1],["getPresignedUrl",1],["getSignedUrl",1],["store",2],["upload",2]]),wg=e=>e&&r.isNumericLiteral(e)?Number(e.getText()):void 0,Ig=e=>{if(e===void 0)return{analyzable:!0,presentKeys:[]};if(!r.isObjectLiteralExpression(e))return{analyzable:!1,presentKeys:[]};const t=[];let s,n=!1;for(const i of e.getProperties()){if(r.isSpreadAssignment(i)){n=!0;continue}if(r.isPropertyAssignment(i)){const o=S(i);t.push(o),o==="expiresInSeconds"&&(s=wg(i.getInitializer()));continue}(r.isShorthandPropertyAssignment(i)||r.isMethodDeclaration(i))&&t.push(S(i))}return{analyzable:!n,expiresInSeconds:s,presentKeys:t}},Tg=e=>{if(!r.isPropertyAccessExpression(e))return;const t=e.getName(),s=Pg.get(t);return s===void 0?void 0:Mn(e.getExpression(),i=>i==="ctx.storage"||i.startsWith("ctx.storage."))?{method:t,optionsIndex:s}:void 0},Cg=(e,t)=>{const s=Tg(e.getExpression());if(s!==void 0)return{scope:x(e),file:t,line:e.getStartLineNumber(),method:s.method,...Ig(e.getArguments()[s.optionsIndex])}},Og=(e,t)=>T(e,t,Cg),kg=e=>r.isDoStatement(e)||r.isForInStatement(e)||r.isForOfStatement(e)||r.isForStatement(e)||r.isWhileStatement(e),wi=e=>{const t=e.getLabel()?.getText(),s=i=>t!==void 0?r.isLabeledStatement(i)&&i.getLabel().getText()===t:kg(i)||r.isBreakStatement(e)&&r.isSwitchStatement(i);let n=e.getFirstAncestor(i=>re(i)||s(i));if(!(n===void 0||re(n))){for(;r.isContinueStatement(e)&&r.isLabeledStatement(n);)n=n.getStatement();return n}},ts=(e,t)=>y(e.getFirstAncestor(s=>y(s,t)||re(s)),t),Rg=(e,t)=>y(e,t)||e.getFirstAncestor(s=>y(s,t))!==void 0,Ii=(e,t)=>{if(r.isReturnStatement(e)||r.isThrowStatement(e))return y(e,t)||ts(e,t);if(r.isBreakStatement(e)||r.isContinueStatement(e)){const s=wi(e);return s!==void 0&&!Rg(s,t)}return!1},Ti=e=>[...r.isBreakStatement(e)||r.isContinueStatement(e)||r.isReturnStatement(e)||r.isThrowStatement(e)?[e]:[],...e.getDescendantsOfKind(d.BreakStatement),...e.getDescendantsOfKind(d.ContinueStatement),...e.getDescendantsOfKind(d.ReturnStatement),...e.getDescendantsOfKind(d.ThrowStatement)],Fg=e=>Ti(e).some(t=>Ii(t,e)),Lg=e=>{const t=r.isCallExpression(e)?e.getExpression():void 0;return r.isPropertyAccessExpression(t)&&t.getName()==="throwIfAborted"},Dg=e=>Ti(e).some(t=>Ii(t,e)||r.isBreakStatement(t)&&y(wi(t),e))||e.getDescendantsOfKind(d.CallExpression).some(t=>Lg(t)&&ts(t,e)),Mg=e=>e.getDescendantsOfKind(d.YieldExpression).some(t=>ts(t,e)),_g=e=>r.isDoStatement(e)||r.isWhileStatement(e)?e.getExpression():e.getCondition(),Kg=e=>r.isDoStatement(e)?"do":r.isWhileStatement(e)?"while":"for",yt=(e,t)=>{const s=_g(e);if(!(s===void 0||r.isTrueLiteral(h(s)))||Dg(e)||Mg(e))return;const i=x(e);if(!(i.kind==="module"&&e.getFirstAncestor(re)!==void 0))return{file:t,kind:Kg(e),line:e.getStartLineNumber(),scope:i}},zg=(e,t)=>[...ne(e,t,d.WhileStatement,yt),...ne(e,t,d.ForStatement,yt),...ne(e,t,d.DoStatement,yt)].toSorted((s,n)=>s.file.localeCompare(n.file)||s.line-n.line),$g=new Set(["when","where"]),bt=new Set(["definePolicy","defineShape"]),Bg=e=>{if(!r.isCallExpression(e))return;const t=e.getExpression();if(r.isPropertyAccessExpression(t)){const n=t.getName();return bt.has(n)?n:void 0}if(!r.isIdentifier(t))return;for(const n of t.getSymbol()?.getDeclarations()??[])if(r.isImportSpecifier(n)){const i=n.getNameNode().getText();return bt.has(i)?i:void 0}const s=t.getText();return bt.has(s)?s:void 0},Vg=e=>r.isObjectLiteralExpression(e)&&e.getProperties().length===0,Ci=e=>{if(e!==void 0){if(r.isReturnStatement(e)&&e.getExpression()===void 0||e.getKind()===d.UndefinedKeyword||e.getText()==="undefined")return"undefined";if(Vg(e))return"empty-object";if(r.isParenthesizedExpression(e))return Ci(e.getExpression())}},ss=e=>e.getAncestors().find(t=>r.isArrowFunction(t)||r.isFunctionExpression(t)||r.isFunctionDeclaration(t)),Ug=e=>e.getDescendantsOfKind(d.ReturnStatement).filter(t=>ss(t)===e),Oi=e=>e.getDescendantsOfKind(d.ConditionalExpression).filter(t=>ss(t)===e),Wg=e=>{const t=Ug(e);return t.length>1?!0:t.some(s=>s.getFirstAncestorByKind(d.IfStatement)!==void 0)||Oi(e).length>0},qg=e=>e.getDescendantsOfKind(d.IfStatement).filter(t=>ss(t)===e),zt=e=>e.getKind()===d.NullKeyword||e.getKind()===d.FalseKeyword||r.isIdentifier(e)&&e.getText()==="undefined"?!0:r.isNumericLiteral(e)?e.getLiteralValue()===0:r.isStringLiteral(e)&&e.getLiteralValue()==="",jg=(e,t)=>zt(e)||zt(t),Hg=new Map([[d.EqualsEqualsEqualsToken,"positive"],[d.EqualsEqualsToken,"positive"],[d.ExclamationEqualsEqualsToken,"negative"],[d.ExclamationEqualsToken,"negative"]]),dn=e=>!zt(e)&&(r.isLiteralExpression(e)||e.getKind()===d.TrueKeyword),Gg=(e,t,s)=>{const n=Hg.get(e);if(n!==void 0)return jg(t,s)?n==="positive"?"negative":"positive":dn(t)||dn(s)?void 0:n},Ae=e=>{if(r.isParenthesizedExpression(e))return Ae(e.getExpression());if(r.isPrefixUnaryExpression(e)&&e.getOperatorToken()===d.ExclamationToken)return"negative";if(r.isBinaryExpression(e)){const t=e.getOperatorToken().getKind(),s=Gg(t,e.getLeft(),e.getRight());if(s!==void 0)return s;if(t===d.AmpersandAmpersandToken||t===d.BarBarToken){const n=Ae(e.getLeft()),i=Ae(e.getRight());return n===i?n:"indeterminate"}}return r.isIdentifier(e)||r.isPropertyAccessExpression(e)||r.isElementAccessExpression(e)||r.isCallExpression(e)?"positive":"indeterminate"},un=e=>{if(e!==void 0){if(r.isReturnStatement(e))return e;if(r.isBlock(e)){const t=e.getStatements().at(-1);return t!==void 0&&r.isReturnStatement(t)?t:void 0}}},Yg=e=>{if(e.getElseStatement()!==void 0)return;const t=e.getNextSiblingIfKind(d.ReturnStatement);return t!==void 0&&t.getNextSibling()===void 0?t:void 0},Qg=e=>r.isReturnStatement(e)?e.getExpression()??e:e,Xg=e=>{const t=[];for(const s of Oi(e)){const n=Ae(s.getCondition());n==="positive"?t.push(s.getWhenFalse()):n==="negative"&&t.push(s.getWhenTrue())}for(const s of qg(e)){const n=Ae(s.getExpression());if(n==="indeterminate")continue;const i=n==="negative"?un(s.getThenStatement()):un(s.getElseStatement())??Yg(s);i!==void 0&&t.push(Qg(i))}return t},Jg=e=>{for(const t of e.getAncestors())if(r.isVariableDeclaration(t)){const s=t.getNameNode();if(r.isIdentifier(s))return s.getText()}return"<anonymous>"},Zg=(e,t,s)=>{if(!r.isCallExpression(e))return[];const[n]=e.getArguments();if(!n||!r.isObjectLiteralExpression(n))return[];const i=[];for(const o of n.getProperties()){if(!r.isPropertyAssignment(o)||!$g.has(S(o)))continue;const a=o.getInitializer();if(!(!a||!(r.isArrowFunction(a)||r.isFunctionExpression(a)))&&Wg(a))for(const c of Xg(a)){const l=Ci(c);l!==void 0&&i.push({exportName:Jg(e),file:s,form:l,key:S(o),line:c.getStartLineNumber(),owner:t})}}return i},ep=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(d.CallExpression)){const i=Bg(n);i!==void 0&&s.push(...Zg(n,i,t))}return s},tp=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...ep(i,w(t,n)))}return s},sp=new Set(["query","upsert","upsertMany","upsertNow"]),pe=new Set,np=e=>{if(!r.isPropertyAccessExpression(e))return;const t=e.getName();if(sp.has(t))return G(e.getExpression(),["vectors"])?t:void 0},ns=e=>{let t=e;for(;r.isParenthesizedExpression(t)||r.isAsExpression(t)||r.isSatisfiesExpression(t)||r.isNonNullExpression(t)||r.isTypeAssertion(t);)t=t.getExpression();return t},ki=e=>{const t=e.getParent();return r.isShorthandPropertyAssignment(t)&&t.getNameNode()===e?t.getValueSymbol():e.getSymbol()},Ri=e=>ki(e)?.getDeclarations()[0],ip=e=>{const t=e.getParent();return r.isBindingElement(t)||(r.isPropertyAccessExpression(t)||r.isPropertyAssignment(t)||r.isVariableDeclaration(t)||r.isParameterDeclaration(t)||r.isMethodDeclaration(t))&&t.getNameNode()===e?!1:!r.isQualifiedName(t)||t.getLeft()===e},Fi=e=>{let t=e;for(;t!==void 0&&(r.isBindingElement(t)||r.isObjectBindingPattern(t)||r.isArrayBindingPattern(t));)t=t.getParent();return t!==void 0&&r.isVariableDeclaration(t)?t:void 0},fn=(e,t,s)=>{const n=ki(e)?.compilerSymbol;if(n!==void 0&&t.has(n))return!0;if(s>0){const i=Fi(Ri(e)),o=i!==void 0&&r.isVariableDeclaration(i)?i.getInitializer():void 0;if(o!==void 0)return is(o,t,s-1)}return q(e)},is=(e,t,s)=>{const n=ns(e);return le(n)?!1:r.isIdentifier(n)?fn(n,t,s):q(n)?!0:n.getDescendantsOfKind(d.Identifier).some(i=>ip(i)&&fn(i,t,s))},Li=e=>{const t=Fi(Ri(e));return t!==void 0&&r.isVariableDeclaration(t)?t.getInitializer():void 0},Z=(e,t)=>{const s=ns(e);if(r.isObjectLiteralExpression(s))return[s];if(r.isConditionalExpression(s))return[...Z(s.getWhenTrue(),t),...Z(s.getWhenFalse(),t)];if(r.isBinaryExpression(s)){const n=s.getOperatorToken().getKind();if(n===d.BarBarToken||n===d.QuestionQuestionToken||n===d.AmpersandAmpersandToken)return[...Z(s.getLeft(),t),...Z(s.getRight(),t)]}if(r.isIdentifier(s)&&t){const n=Li(s);return n===void 0?[]:Z(n,!1)}return[]},rp=(e,t)=>{const s=Z(e,t);if(s.length===0)return{replaces:!0,sources:[e]};const n=s.map(o=>He(o,!1)),i=n.flat();if(i.length!==0)return{replaces:n.every(o=>o.length>0),sources:i}},op=e=>(r.isPropertyAssignment(e)||r.isShorthandPropertyAssignment(e))&&e.getName()==="namespace",ap=e=>r.isShorthandPropertyAssignment(e)?e.getNameNode():e.getInitializer()??e.getNameNode(),He=(e,t)=>{let s=[];for(const n of e.getProperties())if(r.isSpreadAssignment(n)){const i=rp(n.getExpression(),t);i!==void 0&&(s=i.replaces?i.sources:[...s,...i.sources])}else op(n)&&(s=[ap(n)]);return s},cp=e=>{if(!e||!(r.isArrowFunction(e)||r.isFunctionExpression(e)))return[];const t=e.getBody();return r.isBlock(t)?t.getDescendantsOfKind(d.ReturnStatement).filter(s=>s.getFirstAncestor(n=>r.isFunctionLikeDeclaration(n))===e).flatMap(s=>s.getExpression()??[]):[t]},lp=e=>{if(!e||!(r.isArrowFunction(e)||r.isFunctionExpression(e)))return pe;const t=e.getParameters()[0]?.getNameNode();if(t===void 0)return pe;const s=r.isIdentifier(t)?[t]:t.getDescendantsOfKind(d.BindingElement).map(n=>n.getNameNode());return new Set(s.flatMap(n=>r.isIdentifier(n)?n.getSymbol()?.compilerSymbol??[]:[]))},$t=(e,t=!0,s=pe)=>{const n=ns(e);if(r.isIdentifier(n)){const o=t?Li(n):void 0;return o===void 0?[{node:n,parameters:s}]:$t(o,!1,s)}if(r.isArrayLiteralExpression(n))return n.getElements().flatMap(o=>r.isSpreadElement(o)?$t(o.getExpression(),t,s):Z(o,!0).flatMap(a=>He(a,!0).map(c=>({node:c,parameters:s}))));const i=r.isCallExpression(n)?n.getExpression():void 0;if(r.isCallExpression(n)&&r.isPropertyAccessExpression(i)&&i.getName()==="map"){const o=n.getArguments()[0],a=is(i.getExpression(),pe,1)?lp(o):pe;return cp(o).flatMap(c=>Z(c,!0).flatMap(l=>He(l,!0).map(u=>({node:u,parameters:a}))))}return[{node:n,parameters:s}]},dp=(e,t)=>{const s=np(e.getExpression());if(s===void 0)return;const n=e.getArguments()[1];if(!(!n||!(s==="upsertMany"?$t(n):Z(n,!0).flatMap(o=>He(o,!0).map(a=>({node:a,parameters:pe})))).some(({node:o,parameters:a})=>is(o,a,1))))return{scope:x(e),file:t,line:e.getStartLineNumber(),method:s}},up=(e,t)=>T(e,t,dp),fp=(e,t,s)=>{const{callSites:n,containers:i,crons:o,functions:a,modules:c,mutators:l,queues:u,schema:f,shapes:g,wranglerVariables:m,workflows:v}=s;return Er({adminRoutes:Ka(e,t),aiRawRuns:Ha(e,t),aiToolSideEffects:ic(e,t),argumentDerivedFetches:ac(e,t),argumentValidators:Pc(e,t),authApiCalls:Br(e,t),authConfigs:Dc(e,t),browserUrlAccesses:zc(e,t),callEdges:n.callEdges,configCalls:Hc(e,t),containerKeyAccesses:Yc(e,t),containerOverrides:tl(e,t),containers:i,countReads:ol(e,t,f.tables),crons:o,cronTargets:o.flatMap($=>$.functionPath===void 0?[]:[$.functionPath]),exportSinks:dl(e,t),staleMigrationImports:yg(e,t),failOpenGuards:ml(e,t),flagReads:Sl(e,t),flagSecurityDefaults:Nl(e,t),geoIndexUsages:Il(e,t),httpActionGuards:zl(e,t),httpHeaderWrites:Yl(e,t),hyperdriveCalls:Vr(e,t),identityClaimReads:od(e,t),imageDeliveryUrlAccesses:cd(e,t),inserts:n.inserts,kvKeyAccesses:dd(e,t,a),mailRecipientAccesses:md(e,t),maskProcedures:Ur(e,t),maskStrategies:Ed(e,t),mutatorWrites:Nd(e,t),nondeterministicCalls:Gr(e,t),normalizeIdAuthorizations:zd(e,t),notifyCalls:Qr(e,t),notifyConfig:Yr(e,t),mutators:l,ownerFieldWrites:Lu(e,t,a,l),unrestrictedWhereBranches:tp(e,t),paymentWebhooks:zu(e,t),privilegedDispatches:Qu(e,t),procedureProtections:Lf(e,t),queries:n.queries,queues:u,r2sqlCalls:Xr(e,t),ratelimitKeySelectors:Bf(e,t),rawRowReturns:Gf(e,t),relationLoads:Xf(e,t),rlsProcedures:Jr(e,t),schema:f,secretLiterals:fg(e,t),modules:c,shapes:g,softDeleteReads:pg(e,t),sqlInterpolations:xg(e,t),storageKeyAccesses:Ng(e,t,a),storageUploads:Og(e,t),tableWrites:n.tableWrites,rowEffects:ag(e,t,n.tableWrites,n.callEdges),unboundedLoops:zg(e,t),vectorNamespaceAccesses:up(e,t),workflowCalls:n.workflowCalls,workflows:v,wranglerVariables:m})},gp=e=>({cacheKey:`advisor_accept_unused:${e.rule}:${e.file}:${e.exportName}`,categories:["SCHEMA"],description:"`advisor.accept` in `lunora.config.*` accepts a finding the advisor does not report as an error.",detail:`No ERROR \`${e.rule}\` in \`${e.file}\` for \`${e.exportName}\` — the acceptance no longer applies.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:e.exportName,file:e.file,rule:e.rule},name:"advisor_accept_unused",remediation:"Remove the entry, or correct the rule, file and export name it names.",title:"An accepted advisor finding matches no error"}),pp=(e,t)=>{const s=new Set;return[...e.map(i=>{if(i.level!=="ERROR")return i;const o=t.find(a=>a.rule===i.name&&a.file===i.metadata.file&&a.exportName===i.metadata.exportName);return o===void 0?i:(s.add(o),{...i,detail:`Accepted: ${o.reason}. ${i.detail}`,level:"INFO",metadata:{...i.metadata,accepted:o.reason}})}),...t.filter(i=>!s.has(i)).map(i=>gp(i))]},mp=()=>({cacheKey:"advisor_accept_invalid",categories:["SCHEMA"],description:"`advisor.accept` in `lunora.config.*` is read by parsing the file, so every entry must be a literal.",detail:"`advisor.accept` is not an array of literal `{ rule, file, exportName, reason }` objects with non-empty strings, so codegen ignored all of it and every ERROR still fails the gate.",facing:"INTERNAL",level:"WARN",metadata:{},name:"advisor_accept_invalid",remediation:'Write `advisor: { accept: [{ rule: "owner_field_from_args_not_auth", file: "lunora/auth/team.ts", exportName: "addTeamMember", reason: "…" }] }` as literals on the config\'s default export.',title:"`advisor.accept` is not a list codegen can read, so no acceptance applies"}),hp=e=>e.metadata.accepted!==void 0||e.name==="advisor_accept_unused"||e.name==="advisor_accept_invalid",gn={error:"ERROR",info:"INFO",warn:"WARN"},pn={ERROR:2,INFO:0,WARN:1},vp=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"}),Ep=(e,t)=>{const{advisor:s}=Un(e);if(s===void 0||s.minSeverity===void 0&&s.unreadable!==!0)return[...t];const{minSeverity:n}=s,i=n!==void 0&&Object.hasOwn(gn,n)?gn[n]:void 0;return i===void 0?[...t,vp(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=>hp(o)||pn[o.level]>=pn[i])},xp=(e,t)=>{const{advisor:s}=Un(e),n=pp(t,s?.accept??[]);return Ep(e,s?.acceptUnreadable===!0?[...n,mp()]:n)},Sp={call:"function",enqueue:"queue",invoke:"service",publish:"topic",schedule:"function"},Ap="crons",yp=ao.replace(/\.ts$/u,""),ge=(e,t)=>`${Qt(e)}:${t}`,Nt=(e,t,s)=>t===""?{reason:`the ${s} is not a string literal`}:{to:`${e}:${t}`},bp=e=>[...e.callEdges.map(t=>{const s=t.target===void 0?{reason:t.reason??"unreadable target"}:{to:`${Sp[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,...Nt("table",t.table,"table name")})),...[...e.inserts,...e.tableWrites].map(t=>({file:t.file,kind:"write",line:t.line,scope:t.scope,...Nt("table",t.table,"written table")})),...e.workflowCalls.map(t=>({file:t.file,kind:"start",line:t.line,scope:t.scope,...Nt("workflow",t.workflow,"workflow name")}))],Np=e=>e.untracked===!0?"inside a helper only code outside any export calls":"inside a non-exported helper",Pp=e=>{const{scope:t}=e;switch(t.kind){case"export":return[{...e,exportName:t.name}];case"helper":return t.callers.length===0?[{...e,unattributed:Np(t)}]:t.callers.map(s=>({...e,exportName:s}));default:return[{...e,unattributed:"at module scope"}]}},wp=e=>bp(e).flatMap(t=>Pp(t)),Ip=e=>[...e.queues.flatMap(t=>t.topic===void 0?[]:[{file:t.filePath,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}`,i=s??n;return{file:Ap,from:`cron:${t.name}`,kind:"trigger",line:0,...i===void 0?{reason:"the cron has no target"}:{to:i}}})],Tp=e=>new Map(e.flatMap(t=>t.tables.map(s=>[s,t.name]))),Ee=(e,t)=>t===void 0?e:{...e,module:t},Cp=e=>{const t=new Map,s=new Map,n=Tp(e.modules),i=(c,l)=>{s.set(c,[...s.get(c)??[],l])},o=(c,l)=>{t.set(c.id,c),l!==void 0&&i(l,c.id)},a=(c,l)=>{c!==void 0&&i(ge(c.file,c.exportName),l)};for(const c of e.functions){const l=ge(c.filePath,c.exportName),u=[...Zr(c.filePath),c.exportName].join(".");o(Ee({detail:c.kind,id:`function:${l}`,kind:"function",name:u},De(e.modules,c.filePath)),l)}for(const c of e.httpRoutes){const l=ge(c.filePath,c.exportName);o(Ee({id:`http:${l}`,kind:"http",name:`${c.method} ${c.path}`},De(e.modules,c.filePath)),l)}for(const c of e.schema.tables)o(Ee({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(Ee({...l,id:`queue:${c.exportName}`,kind:"queue",name:c.exportName},De(e.modules,c.filePath)),ge(c.filePath,c.exportName)),a(c.handlerSite,`queue:${c.exportName}`)}for(const c of e.topics)o(Ee({id:`topic:${c.exportName}`,kind:"topic",name:c.exportName},De(e.modules,c.filePath)));for(const c of e.workflows)o({id:`workflow:${c.exportName}`,kind:"workflow",name:c.exportName},ge(yp,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}},Op=e=>e==="default"?"the default export is not a registered function":`"${e}" is not a registered function`,kp=(e,t)=>"from"in e?[e.from]:"unattributed"in e?{reason:e.unattributed}:t.get(ge(e.file,e.exportName))??{reason:Op(e.exportName)},Rp=(e,t,s)=>{if("reason"in e)return{reason:e.reason};const n=kp(e,t);if("reason"in n)return n;const{to:i}=e;return s.has(i)?{drawn:n.map(o=>({from:o,kind:e.kind,to:i}))}:{reason:`${i} is not declared`}},Pt=e=>`${e.from}|${e.kind}|${e.to}`,Fp=e=>`${e.file}|${String(e.line)}|${e.kind}|${e.reason}`,Lp=e=>{const{nodes:t,sites:s}=Cp(e),n=new Map,i=new Map;for(const o of[...Ip(e),...wp(e)]){const a=Rp(o,s,t);if("drawn"in a)for(const c of a.drawn)n.set(Pt(c),c);else{const c={file:o.file,kind:o.kind,line:o.line,reason:a.reason};i.set(Fp(c),c)}}return{edges:[...n.values()].toSorted((o,a)=>Pt(o).localeCompare(Pt(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:[...i.values()].toSorted((o,a)=>o.file.localeCompare(a.file)||o.line-a.line),version:1}},Dp=e=>`${Wn}export const architecture = ${lo(e,"Record<string, unknown>")};
24
+ `,mn=(e,t="api")=>{const s=new Map;for(const n of e){const i=Qt(n),o=s.get(i);if(o===void 0){s.set(i,n);continue}if(o!==n){const a=t==="api"?`the generated api.ts would declare "${i}" twice and the dispatch key "${i}:<fn>" would be ambiguous`:`the generated api.ts would declare "${i}" twice in HttpStreamsRef and again in the httpStreams object literal`;throw new _("INTERNAL",`@lunora/codegen: "${o}" and "${n}" both map to the ${t} namespace "${i}" — ${a}. Rename one file so the two differ by more than a non-identifier character (\`-\`, \`.\`, \`/\` and \`_\` all sanitize to \`_\`).`,{status:500})}}},Mp=(e,t={})=>{const{hasVectors:s=!0,scheduler:n=!1,storage:i=!1,usage:o}=t,a=[];e.tables.some(c=>qn(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=>jn(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`"}),i&&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?[]:vo)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)},_p=(e,t,s={})=>{if(t===void 0)return;const n=Mp(e,s).filter(o=>!t.has(o.name));if(n.length===0)return;const i=n.map(o=>` - ${o.name} — ${o.reason}`).join(`
25
+ `);throw new _("INTERNAL",`@lunora/codegen: this schema's generated code imports packages the project does not declare:
26
+ ${i}
27
+
28
+ Install them with your package manager, then re-run codegen.`)},Kp="env.ts",zp=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineEnv";for(const s of t.getDeclarations())if(r.isImportSpecifier(s))return et(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineEnv":!1;return!1},$p=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!r.isNamespaceImport(s))continue;const n=s.getFirstAncestorByKind(d.ImportDeclaration);return n!==void 0&&et(n.getModuleSpecifierValue())}return!1},Bp=e=>{if(r.isIdentifier(e))return zp(e);if(r.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineEnv"&&r.isIdentifier(t)&&$p(t)}return!1},Vp=e=>{const t=[];for(const s of e.getVariableDeclarations()){const n=s.getInitializer();if(n?.getKind()!==d.CallExpression||!Bp(n.getExpression()))continue;const o=s.getNameNode();if(!r.isIdentifier(o)){if(s.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw de(o,"defineEnv exports must be plain named exports (no destructuring)")}const a=jt(s,"member");a!==void 0&&t.push({exportName:a})}return t},Up=(e,t)=>{const s=E(t,Kp);if(!M(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),i=Vp(n);if(i.length!==0){if(i.length>1)throw de(n,`lunora/env.ts declares ${i.length.toString()} defineEnv() contracts (${i.map(o=>o.exportName).join(", ")}); exactly one is allowed`);return i[0]}},Wp={defineLiveStream:"liveStreams",defineRoom:"typedWebSockets",defineWebSocket:"socketRoutes"},qp=new Set(["allowedHosts","deniedHosts","interceptHttps"]),jp=(e,t)=>{const s=h(t);if(s===void 0||!r.isIdentifier(s))return s;const n=s.getText();return h(e.getDescendantsOfKind(d.VariableDeclaration).find(i=>i.getName()===n)?.getInitializer())},Hp=(e,t)=>e!==void 0&&r.isObjectLiteralExpression(e)&&e.getProperties().some(s=>{if(r.isShorthandPropertyAssignment(s))return t.has(S(s));if(!r.isPropertyAssignment(s)||!t.has(S(s)))return!1;const n=h(s.getInitializer())?.getText();return n!=="false"&&n!=="undefined"}),Gp=new Set(["durable"]),Yp=new Set(["rollback"]),Di=e=>{const t=e.getExpression();return r.isPropertyAccessExpression(t)?t.getName():t.getText()},Qp="defineApp",ye="app",hn=(e,t)=>e.getDescendantsOfKind(d.PropertyAssignment).some(s=>S(s)===ye&&s.getInitializer()?.getText()===t)||t===ye&&e.getDescendantsOfKind(d.ShorthandPropertyAssignment).some(s=>S(s)===ye),Xp=e=>{if(e===void 0||!wo.includes(e.getSourceFile().getBaseName()))return!1;if(r.isMethodDeclaration(e))return r.isObjectLiteralExpression(e.getParent())&&S(e)===ye;if(!(r.isArrowFunction(e)||r.isFunctionExpression(e)||r.isFunctionDeclaration(e)))return!1;const t=e.getParent();if(r.isPropertyAssignment(t))return S(t)===ye;if(r.isVariableDeclaration(t))return hn(e.getSourceFile(),t.getName());const s=r.isFunctionDeclaration(e)?e.getName():void 0;return s!==void 0&&hn(e.getSourceFile(),s)},Jp="AppBuilder",Mi=e=>{const t=e.getSourceFile();return t.getBaseNameWithoutExtension()==="app"&&t.getDirectory().getBaseName()==="_generated"},Zp=e=>{const t=e.getType(),s=(t.getConstraint()??t).getSymbol();return s?.getName()===Jp&&s.getDeclarations().some(n=>Mi(n))},em=e=>e.getText()===Qp&&(e.getSymbol()?.getDeclarations()??[]).every(t=>r.isImportSpecifier(t)||r.isImportClause(t)||Mi(t)),_i=(e,t,s=new Set)=>{const n=Xe(t);if(n===void 0||!r.isIdentifier(n))return!1;if(em(n))return!0;const i=n.getText();if(s.has(i))return!1;s.add(i);for(const o of n.getAncestors()){if(r.isParametered(o)&&o.getParameters().some(a=>a.getName()===i))return Xp(o);if(r.isBlock(o)||r.isSourceFile(o)){const a=o.getVariableStatements().flatMap(c=>c.getDeclarations()).find(c=>c.getName()===i);if(a!==void 0)return _i(e,a.getInitializer(),s)}}return!1},Ki=(e,t)=>{const s=Wt(t.getExpression());return s?.member==="deliveryAuthorization"&&(_i(e,s.object)||Zp(s.object))},tm=new Map([["defineContainer",{keys:qp,signal:"containerEgressPolicy"}],["defineStep",{keys:Yp,signal:"workflowRollback"}],["stream",{keys:Gp,signal:"durableStreams"}]]),sm=(e,t)=>{const s=tm.get(Di(t));if(s!==void 0)return t.getArguments().some(n=>Hp(jp(e,n),s.keys))?s.signal:void 0},nm=(e,t)=>Wp[Di(t)]??(Ki(e,t)?"deliveryAuthorization":void 0),im=(e,t,s)=>{const n={containerEgressPolicy:!1,deliveryAuthorization:!1,durableStreams:!1,liveContext:!1,liveStreams:!1,secrets:!1,socketRoutes:!1,typedWebSockets:!1,workflowRollback:!1};for(const i of A(t)){const o=e.getSourceFile(i)??e.addSourceFileAtPath(i);if(!n.secrets||!n.liveContext){const c=yo(o);n.secrets=n.secrets||c.has("secrets"),n.liveContext=n.liveContext||c.has("live")}const a=o.getDescendantsOfKind(d.CallExpression);for(const c of a){const l=sm(o,c)??nm(o,c);l!==void 0&&(n[l]=!0)}if(n.liveStreams=n.liveStreams||o.getFullText().includes("defineLiveStream")&&a.some(c=>$n(c,"defineLiveStream")),Object.values(n).every(Boolean))break}if(n.typedWebSockets=n.typedWebSockets||n.socketRoutes,!n.deliveryAuthorization&&s!==void 0){const i=e.getSourceFile(s)??new Ut({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}).createSourceFile(s,Ye(s,"utf8"),{overwrite:!0});n.deliveryAuthorization=i.getDescendantsOfKind(d.CallExpression).some(o=>Ki(i,o))}return n},rm=(e,t)=>{const s=No();for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);if(bo(i,s))return!0}return!1},om="createWorker",am="extend",vn=e=>e!==void 0&&(r.isStringLiteral(e)||r.isNoSubstitutionTemplateLiteral(e))?e.getLiteralValue():void 0,En=e=>{const t=[],s=vn(R(e,"backupCron"));s!==void 0&&t.push(s);const n=R(e,"crons");if(n===void 0||!r.isObjectLiteralExpression(n))return t;for(const i of n.getProperties()){if(!r.isPropertyAssignment(i)&&!r.isMethodDeclaration(i))continue;const o=vn(i.getNameNode());o!==void 0&&t.push(o)}return t},cm=e=>{const t=P(e.getExpression()),[s]=e.getArguments();if(s===void 0)return[];if(t===om)return r.isObjectLiteralExpression(s)?En(s):[];if(t!==am||!(r.isArrowFunction(s)||r.isFunctionExpression(s)))return[];const n=kn(s.getBody());return n===void 0?[]:En(n)},lm=(e,t)=>{const s=[];for(const{filePath:n}of Qe(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const o of i.getDescendantsOfKind(d.CallExpression))s.push(...cm(o))}return[...new Set(s)]},zi=e=>{if(e.kind==="id")return e.tableName;if(!(e.kind!=="array"&&e.kind!=="optional"))return e.inner===void 0?void 0:zi(e.inner)},dm=e=>{const t=new Set(e.tables.map(s=>s.name));return e.tables.some(s=>Object.values(s.shape).some(n=>{const i=zi(n);return i!==void 0&&t.has(i)}))},um=(e,t)=>{const s=new Map,n=new Map;for(const i of e)s.set(i.name,`workflow "${i.exportName}"`),n.set(i.className,`workflow "${i.exportName}"`);for(const i of t){const o=s.get(i.name);if(o!==void 0)throw new _("DUPLICATE_WORKFLOW_NAME",`Duplicate deployed name "${i.name}": produced by both ${o} and agent "${i.exportName}". Workflow and agent names share one account-wide namespace and must be unique together.`,{status:500});const a=n.get(i.className);if(a!==void 0)throw new _("DUPLICATE_WORKFLOW_CLASS",`Duplicate generated class "${i.className}": produced by both ${a} and agent "${i.exportName}". Workflow and agent export names must yield unique generated class names.`,{status:500})}},fm=e=>{const{lunoraDirectory:t,project:s,projectRoot:n,schema:i}=e,o=ed(s,t),a=Up(s,t),c=co(s,t),{queues:l,topics:u}=To(s,t),f=Oo(n),g=xo(s,t);um(c,g);const m=So(s,t),v=ko(s,t),$=Ao(s,t,c,g),ue=lm(s,t),b=im(s,t,Io(n)),B=Co(s,t),H=rm(s,t),F=Po(s,t);F.browser=F.browser||B.usesSandboxBrowser;const k=Tt(n,e.target),C=Ro(F,k,{agents:g.length>0,commitOrderedTables:i.tables.some(D=>D.commitOrdered===!0),cronTriggers:$.length>0,crossShardFanout:i.tables.some(D=>zo(D)),containerEgressPolicy:b.containerEgressPolicy,containerRuntimeScheduling:m.some(D=>D.schedulingPolicy==="durable_object"),containerSandboxTools:m.some(D=>D.sandbox===!0),deliveryAuthorization:b.deliveryAuthorization,durableStreams:b.durableStreams,globalTables:i.tables.some(D=>D.shardMode==="global"),liveContext:b.liveContext,liveStreams:b.liveStreams,typedWebSockets:b.typedWebSockets,queues:l.length>0,relationGraph:dm(i),secretValues:H,secrets:b.secrets,services:f.length>0,topics:u.length>0,vectorStore:i.vectorIndexes.length>0,workerLoaders:B.usesSandboxLoader,workflowRollback:b.workflowRollback,workflowSchedules:c.some(D=>D.schedules!==void 0)}),U=C.usage,X=Eo(U),te=C.signals.vectorStore!==!1,se=C.signals.services===!1?[]:f,oe=Hn(n),K=oe??new Set,N=K.has("lunorash");_p(i,oe,{hasVectors:te,scheduler:U.scheduler||$.length>0,storage:U.storage||v.rules.length>0||Object.keys(Gn(i)).length>0,usage:U});const O=M(E(t,"flags.ts")),Te=M(E(t,"notify.ts"));return{agents:g,capabilities:X,containers:m,crons:$,dataModelContent:Uo(i),declaredDependencies:oe,dependencies:K,entryCronTriggers:ue,env:a,featureUsage:U,hasFlags:O,hasNotify:Te,identity:o,platformGate:{...C,diagnostics:[...Fo(n,e.target),...C.diagnostics,...Lo(k,i.vectorIndexes),...b.liveStreams&&b.deliveryAuthorization?[Do(k)]:[],...b.socketRoutes&&b.deliveryAuthorization?[Mo(k)]:[]]},queues:l,serverContent:Bo({agents:g,capabilities:X,containers:m,env:a,hasVectors:te,hasFlags:O,hasNotify:Te,identity:o,queues:l,schema:i,services:se,storageRuleBuckets:v.rules.map(D=>D.bucket),topics:u,useUmbrella:N,workflows:c}),services:se,storageRulesMetadata:v,topics:u,usesSandbox:B.usesSandboxBrowser||B.usesSandboxContainer||B.usesSandboxFs,useUmbrella:N,workflows:c}},$i=(e,t)=>{if(!r.isPropertyAccessExpression(e))return;const s=e.getExpression();if(!r.isPropertyAccessExpression(s))return;const n=s.getExpression();return r.isPropertyAccessExpression(n)&&n.getName()===t?s.getName():void 0},gm=e=>{if(!r.isPropertyAccessExpression(e))return!1;const t=e.getExpression();return r.isPropertyAccessExpression(t)&&t.getName()==="scheduler"||r.isIdentifier(t)&&t.getText()==="scheduler"},pm=new Map([["publish",{kind:"publish",surface:"topics"}],["publishBatch",{kind:"publish",surface:"topics"}],["send",{kind:"enqueue",surface:"queues"}],["sendBatch",{kind:"enqueue",surface:"queues"}]]),mm=/^[\w$]+:[\w$]+$/u,hm=(e,t)=>{const s=Dn(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 or a "namespace:export" key'}:void 0},xn=e=>{const t=[];for(const s of e.getProperties()){if(!r.isPropertyAssignment(s)&&!r.isShorthandPropertyAssignment(s))return;t.push(s.getName())}return t},vm=e=>{if(e===void 0)return[];if(r.isObjectLiteralExpression(e))return xn(e);if(r.isIdentifier(e)){const t=e.getSymbol()?.getDeclarations()[0];if(r.isVariableDeclaration(t)&&t.getVariableStatement()?.getDeclarationKind()===Sr.Const){const s=t.getInitializer();return r.isObjectLiteralExpression(s)?xn(s):void 0}}},Em=(e,t,s)=>({schedule:{argKeys:vm(s),...e==="runAfter"&&t!==void 0&&r.isNumericLiteral(t)?{delayMs:t.getLiteralValue()}:{}}}),xm=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return;const s=t.getName(),[n,i,o]=e.getArguments();if(Ln.has(s))return hm(s,n);if((s==="runAfter"||s==="runAt")&&gm(t)){const l=Dn(i)??(r.isStringLiteral(i)&&mm.test(i.getLiteralText())?i.getLiteralText():void 0);return l===void 0?{kind:"schedule",reason:'the scheduled function is not a static api.* / internal.* chain or a "namespace:export" key'}:{kind:"schedule",target:l,...Em(s,n,o)}}const a=pm.get(s),c=a===void 0?void 0:$i(t,a.surface);return a===void 0||c===void 0?void 0:{kind:a.kind,target:c}},Sm=new Set([d.AmpersandAmpersandEqualsToken,d.AmpersandAmpersandToken,d.BarBarEqualsToken,d.BarBarToken,d.QuestionQuestionEqualsToken,d.QuestionQuestionToken]),Bi=e=>xr.isOptionalChain(e.compilerNode),Am=(e,t)=>r.isIfStatement(t)?!y(e,t.getExpression()):r.isWhileStatement(t)||r.isForInStatement(t)||r.isForOfStatement(t)?y(e,t.getStatement()):r.isForStatement(t)?y(e,t.getStatement())||y(t.getIncrementor(),e):r.isCaseClause(t)||r.isDefaultClause(t)||r.isCatchClause(t)?!0:re(t)?t.getFirstAncestor(re)!==void 0:r.isConditionalExpression(t)?!y(e,t.getCondition()):r.isBinaryExpression(t)?!y(e,t.getLeft())&&Sm.has(t.getOperatorToken().getKind()):(r.isCallExpression(t)||r.isElementAccessExpression(t))&&Bi(t)?!y(e,t.getExpression()):r.isBlock(t)&&t.getStatements().some(s=>s.getEnd()<=e.getStart()&&Fg(s)),ym=e=>{let t=e,s=e.getParent();for(;s!==void 0&&(r.isAwaitExpression(s)||r.isParenthesizedExpression(s));)t=s,s=s.getParent();const n=r.isVariableDeclaration(s)||r.isBinaryExpression(s)&&y(t,s.getRight())&&s.getOperatorToken().getKind()===d.EqualsToken,i=e.getFirstAncestor(re);return n||i?.getDescendantsOfKind(d.ThrowStatement).some(o=>o.getStart()>=e.getEnd()&&y(o.getFirstAncestor(re),i))===!0},bm=(e,t)=>(r.isWhileStatement(t)||r.isForInStatement(t)||r.isForOfStatement(t))&&y(e,t.getStatement())||r.isForStatement(t)&&(y(e,t.getStatement())||y(t.getIncrementor(),e)),Nm=(e,t)=>{if(Bi(e)||t==="schedule"&&ym(e))return"guard";let s=e,n=!1;for(let i=s.getParent();i!==void 0&&!r.isSourceFile(i);i=i.getParent()){if(Am(s,i)){if(!bm(s,i))return"guard";n=!0}s=i}return n?"loop":void 0},Sn=(e,t,s)=>{if(s===void 0)return;const n=Nm(e,s.kind);return{...s,...n===void 0?{}:{conditional:!0},...n==="loop"?{loopOnly:!0}:{},file:t,line:e.getStartLineNumber(),scope:x(e)}},Pm=(e,t)=>[...T(e,t,(s,n)=>Sn(s,n,xm(s))),...ne(e,t,d.PropertyAccessExpression,(s,n)=>{const i=$i(s,"services");return Sn(s,n,i===void 0?void 0:{kind:"invoke",target:i})})],wm=new Set(["boolean","number","object","string"]),Im=e=>{const t=e.getName();if(!wm.has(t))return;const s=e.getExpression();return G(s,["flags"])||G(s,["flags","details"])?t:void 0},Tm=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return;const s=Im(t);if(s===void 0)return;const n=e.getArguments()[0];if(!n||!(r.isStringLiteral(n)||r.isNoSubstitutionTemplateLiteral(n)))return;const i=n.getLiteralValue();return i.length>0?{key:i,type:s}:void 0},Cm=(e,t)=>{const s=new Map;for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const o of i.getDescendantsOfKind(d.CallExpression)){const a=Tm(o);a&&!s.has(a.key)&&s.set(a.key,a.type)}}return[...s.entries()].map(([n,i])=>({key:n,type:i})).toSorted((n,i)=>n.key.localeCompare(i.key))},Om=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 i=n.getTypeAtLocation(e),o=i.getText(e);if(!o||o==="any"||o==="never"||Wo(o))return;const a=e.getSourceFile().getFilePath();if(qo(i,e,a)){const c=jo(i,e,a,0,new Set);return c===void 0&&Ho(o),c}return o},km=e=>e.getProperties().some(t=>{if(r.isSpreadAssignment(t))return!0;const s=Kr(t.getNameNode());return s===void 0||s==="namespace"}),Rm=(e,t)=>{for(const{filePath:s}of Qe(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const i of n.getDescendantsOfKind(d.CallExpression)){const o=i.getExpression(),[a]=i.getArguments();if(!(!r.isPropertyAccessExpression(o)||o.getName()!=="auth"||a===void 0)&&(!r.isObjectLiteralExpression(a)||km(a)))return i}}},Fm="https://lunora.sh/docs/concepts/data-residency#pinning-auth-and-voice",Lm=(e,t)=>{if(!(e.jurisdiction===void 0||e.jurisdictionPinsAuth===!0||t===void 0))throw de(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 (${Fm}). 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})},Dm="room:",Mm="__lunora_socket__:",_m=/^[A-Za-z]\w*$/u,An=e=>_m.test(e),Km=e=>`${e}:`.startsWith(Dm)||`${e}:`.startsWith(Mm),Vi=e=>e.getProperties().some(t=>r.isSpreadAssignment(t)||r.isComputedPropertyName(t.getNameNode())),Ui=e=>Vi(e)||e.getProperties().some(t=>r.isMethodDeclaration(t)||r.isGetAccessorDeclaration(t)||r.isSetAccessorDeclaration(t)),yn=e=>S(e),rs=(e,t)=>e.getProperties().find(s=>(r.isPropertyAssignment(s)||r.isShorthandPropertyAssignment(s))&&S(s)===t),ae=(e,t)=>{const s=de(e,`defineLiveStream ${t}`);return new _("LIVE_STREAM_NOT_LITERAL",s.message)},Wi=(e,t,s)=>{const n=rs(e,t),i=r.isPropertyAssignment(n)?n.getInitializer():void 0;if(i===void 0||!r.isObjectLiteralExpression(i))throw ae(n??e,`needs ${s} so codegen can read its topics`);if(Ui(i))throw ae(i,`cannot spread into or compute the keys of \`${t}\`: codegen must read every name as a literal`);return i},zm=(e,t)=>{const s=yn(t),n=r.isPropertyAssignment(t)?t.getInitializer():void 0;if(n===void 0||!r.isObjectLiteralExpression(n))throw ae(t,`needs an object literal for topic "${s}" ({ key?, payload }), not a reference to one`);if(Ui(n))throw ae(n,`cannot spread into or compute the keys of topic "${s}"`);if(!An(s)||Km(s))throw new _("LIVE_TOPIC_INVALID",`live stream "${e}": topic name "${s}" must be a plain identifier (letters, digits and "_", starting with a letter) that does not encode into the "room:" or socket topic prefix.`);if(rs(n,"key")===void 0)return{fields:[],name:s};const a=Wi(n,"key",`an object literal \`key\` for topic "${s}"`).getProperties().map(l=>yn(l)),c=a.find(l=>!An(l));if(c!==void 0)throw new _("LIVE_TOPIC_INVALID",`live stream "${e}": key field "${s}.${c}" must be a plain identifier (letters, digits and "_", starting with a letter).`);return{fields:a,name:s}},$m=(e,t,s)=>{const n=e.getArguments()[0];if(n===void 0||!r.isObjectLiteralExpression(n))throw ae(e,"needs an object-literal options argument so codegen can read its `id` and `topics`");if(Vi(n))throw ae(n,"cannot spread its options or use a computed key: codegen must read `id` and `topics` as literals");const i=rs(n,"id"),o=r.isPropertyAssignment(i)?i.getInitializer():void 0;if(o===void 0||!r.isStringLiteral(o))throw ae(i??n,'needs a string-literal `id` (e.g. `defineLiveStream({ id: "posts", … })`) so codegen can type its references');const a=o.getLiteralValue(),c=Wi(n,"topics","an object-literal `topics` map");return{exportName:t,filePath:w(s,e.getSourceFile().getFilePath()),id:a,topics:c.getProperties().map(l=>zm(a,l))}},Bm=e=>{const t=new Map;for(const s of e)for(const[n,i]of[["id",s.id],["export",s.exportName]]){const o=`${n}:${i}`,a=t.get(o);if(a!==void 0)throw new _("LIVE_STREAM_DUPLICATE",`live stream ${n} "${i}" is declared by both lunora/${a}.ts and lunora/${s.filePath}.ts; it must be unique across the app.`);t.set(o,s.filePath)}},Vm=e=>{let t=e.getParent();for(;r.isAsExpression(t)||r.isSatisfiesExpression(t)||r.isNonNullExpression(t)||r.isParenthesizedExpression(t);)t=t.getParent();return t},Um=(e,t)=>e.getDescendantsOfKind(d.CallExpression).filter(s=>$n(s,"defineLiveStream")).map(s=>{const n=Vm(s),i=r.isVariableDeclaration(n)?jt(n,"binding"):void 0;if(i===void 0)throw new _("LIVE_STREAM_NOT_EXPORTED",de(s,"defineLiveStream must be assigned to a named export (`export const posts = defineLiveStream({ … })`), not a default export, a local, or an inline call, so codegen can type its references").message);return $m(s,i,t)}),Wm=(e,t)=>{const s=A(t).flatMap(n=>Um(e.getSourceFile(n)??e.addSourceFileAtPath(n),t));return Bm(s),s},qm=e=>r.isPropertyAssignment(e)||r.isMethodDeclaration(e)||r.isGetAccessorDeclaration(e)?r.isComputedPropertyName(e.getNameNode()):!1,jm=e=>r.isPropertyAssignment(e)||r.isShorthandPropertyAssignment(e)||r.isMethodDeclaration(e)||r.isGetAccessorDeclaration(e)?qm(e):!0,qi=(e,t=!1)=>{for(const s of e.getProperties()){if(jm(s))return!0;if(t)continue;if(!r.isPropertyAssignment(s))return!0;const n=s.getInitializer();if(!n||!r.isObjectLiteralExpression(n)||qi(n,!0))return!0}return!1},Hm=(e,t)=>{for(const s of A(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const{receiver:i}of Yn(n))for(const o of Yt(i)){const a=o.getArguments()[0];if(a!==void 0&&(!r.isObjectLiteralExpression(a)||qi(a)))return!0}}return!1},Gm=e=>{const t=e.getArguments()[0];if(!t||!r.isObjectLiteralExpression(t))return[];const s=[];for(const n of t.getProperties()){const i=Ve(n);if(i===void 0||!r.isPropertyAssignment(n))continue;const o=n.getInitializer();if(!(!o||!r.isObjectLiteralExpression(o)))for(const a of o.getProperties()){const c=Ve(a);c!==void 0&&s.push({column:c,strategy:Vn(a),table:i})}}return s},Ym=(e,t)=>{const s=new Map;for(const n of A(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const{receiver:o}of Yn(i))for(const a of Yt(o))for(const c of Gm(a)){const l=`${c.table}\0${c.column}`;s.has(l)||s.set(l,c)}}return{columns:[...s.values()]}},Qm=["providerSubscriptionId","state"],Xm=["providerEventId","processedAt"],bn=(e,t)=>t.every(s=>s in e.shape),Jm=e=>{const t=e.find(n=>n.name==="payment_subscriptions"),s=e.find(n=>n.name==="payment_events");return t!==void 0&&s!==void 0&&bn(t,Qm)&&bn(s,Xm)},Zm=["account","apikey","member","passkey","session","teamMember","twoFactor","user"],eh=(e,t)=>{const s={};for(const[n,i]of e)s[n]={dataset:i};for(const[n,i]of t)s[n]={excluded:i};return s},th=(e,t)=>{const s=[];for(const n of e){const i=t[n];i===void 0?s.push({code:"unclassified",table:n}):"excluded"in i&&i.excluded.trim()===""&&s.push({code:"excluded_without_reason",table:n})}return s},sh="@lunora/privacy",ji="userId",Nn=new Set(["user","users"]),nh=e=>e.replaceAll("\\","/"),ih="privacy",rh=new Set(["actionCacheDataset","authDataset","documentHistoryDataset"]),nt=e=>e!==void 0&&(r.isStringLiteral(e)||r.isNoSubstitutionTemplateLiteral(e))?e.getLiteralText():void 0,we=e=>r.isPropertyAssignment(e)?e.getName().replaceAll(/^["']|["']$/gu,""):"",os=e=>e.getProperties().filter(t=>r.isPropertyAssignment(t)),oh=(e,t)=>{const s=e.getProperty(t),n=r.isPropertyAssignment(s)?s.getInitializer():void 0;return n!==void 0&&r.isObjectLiteralExpression(n)?n:void 0},it=e=>{const t=e.getExpression();return r.isIdentifier(t)?t.getText():void 0},ah=(e,t)=>{const s=e.getArguments()[1];if(s===void 0||!r.isObjectLiteralExpression(s))return;const n=oh(s,"tables"),i=nt(e.getArguments()[0])??"defineDataset";for(const o of n===void 0?[]:os(n).map(a=>we(a)))t.datasets.set(o,i)},as=8,me=(e,t=0)=>{if(t>as)return;if(r.isAsExpression(e)||r.isSatisfiesExpression(e)||r.isParenthesizedExpression(e))return me(e.getExpression(),t+1);if(!r.isIdentifier(e))return e;const s=e.getSymbol(),n=(s?.isAlias()===!0?s.getAliasedSymbol():s)?.getValueDeclaration(),i=r.isVariableDeclaration(n)?n.getInitializer():void 0;return i===void 0?void 0:me(i,t+1)},ch=(e,t)=>{const s=e.getArguments()[0],n=s===void 0?void 0:me(s),i=n!==void 0&&r.isObjectLiteralExpression(n)?os(n):[],o=new Set(i.map(a=>we(a)));for(const a of Zm)o.has(a)||t.datasets.set(a,"authDataset");for(const a of i){const c=r.isPropertyAssignment(a)?nt(a.getInitializer()):void 0;c!==void 0&&(t.datasets.set(c,"authDataset"),we(a)==="user"&&t.userTables.add(c))}},Pn=(e,t,s)=>{t.datasets.set(nt(e.getArguments()[0])??s,s)},lh=e=>{if(r.isPropertyAssignment(e)){const t=e.getInitializer();return t===void 0?void 0:[we(e),t]}if(r.isShorthandPropertyAssignment(e)){const t=e.getValueSymbol(),s=(t?.isAlias()===!0?t.getAliasedSymbol():t)?.getValueDeclaration(),n=r.isVariableDeclaration(s)?s.getInitializer():void 0;return[e.getName(),n??e.getNameNode()]}},Hi=(e,t=0)=>{const s=me(e,t);if(s===void 0||!r.isObjectLiteralExpression(s)||t>as)return;const n=new Map;for(const i of s.getProperties()){const o=r.isSpreadAssignment(i)?Hi(i.getExpression(),t+1):[lh(i)];if(o===void 0)return;for(const a of o)a!==void 0&&n.set(a[0],a[1])}return n},dh=e=>{const t=e.getArguments()[0];return t===void 0?void 0:Hi(t)},uh=(e,t)=>{const s=e?.get("exclude"),n=s===void 0?void 0:me(s);for(const i of n!==void 0&&r.isObjectLiteralExpression(n)?os(n):[])t.excluded.set(we(i),r.isPropertyAssignment(i)?nt(i.getInitializer())??"":"")},fh=(e,t)=>{switch(it(e)){case"actionCacheDataset":{Pn(e,t,"actionCache");break}case"authDataset":{ch(e,t);break}case"defineDataset":{ah(e,t);break}case"documentHistoryDataset":{Pn(e,t,"documentHistory");break}}},cs=e=>e!==void 0&&r.isCallExpression(e)&&it(e)==="defineDataset",Gi=e=>e!==void 0&&r.isCallExpression(e)&&rh.has(it(e)??""),gh=e=>{const t=e.getSymbol(),n=(t?.isAlias()===!0?t.getAliasedSymbol():t)?.getValueDeclaration(),i=r.isVariableDeclaration(n)?n.getInitializer():void 0;return r.isVariableDeclaration(n)&&(cs(i)||Gi(i))?n:void 0},Yi=(e,t,s=0)=>{const n=me(e,s);if(n===void 0||!r.isArrayLiteralExpression(n)||s>as)return!1;for(const i of n.getElements())if(r.isSpreadElement(i)){if(!Yi(i.getExpression(),t,s+1))return!1}else if(!cs(i)&&!Gi(i)){const o=r.isIdentifier(i)?gh(i):void 0;if(o===void 0)return!1;t.add(o)}return!0},ph=e=>{if(e===void 0)return;const t=e.get("datasets"),s=new Set;return t===void 0||Yi(t,s)?s:void 0},mh=(e,t)=>{const s=[];for(const i of e.getDescendantsOfKind(d.CallExpression))if(fh(i,t),it(i)==="definePrivacy"){const o=dh(i);uh(o,t),s.push({location:`${e.getFilePath()}:${String(i.getStartLineNumber())}`,passed:ph(o)})}return{declared:e.getDescendantsOfKind(d.VariableDeclaration).filter(i=>cs(i.getInitializer())).map(i=>({declaration:i,name:i.getName()})),privacyCalls:s}},hh=(e,t)=>{const s=E(t,"schema.ts"),n=[...A(t),...M(s)?[s]:[]];for(const o of n)e.getSourceFile(o)===void 0&&e.addSourceFileAtPath(o);const i=new Set(n.map(o=>nh(o)));return e.getSourceFiles().filter(o=>i.has(o.getFilePath()))},vh=(e,t,s)=>{if(s?.has(sh)!==!0)return{classifications:{},enabled:!1,unusedDatasets:[],userTables:Nn};const n={datasets:new Map,excluded:new Map,userTables:new Set(Nn)},i=[],o=[];for(const f of hh(e,t)){const g=mh(f,n);i.push(...g.declared),o.push(...g.privacyCalls)}const a=new Set;for(const f of o){for(const g of f.passed??[])a.add(g);f.passed===void 0&&console.warn(`@lunora/codegen: privacy_datasets_unresolved: the definePrivacy call at ${f.location} passes datasets codegen cannot read, so a defineDataset it leaves out is not reported. Pass an array of dataset constants, directly or through a spread of a config object literal.`)}const l=o.every(f=>f.passed!==void 0)?i.filter(f=>!a.has(f.declaration)).map(f=>f.name):[];return{classifications:eh(n.datasets,n.excluded),enabled:o.length>0,unusedDatasets:l,userTables:n.userTables}},Qi=(e,t)=>e.kind==="id"?t.has(e.tableName??""):[e.inner,e.keyType,e.valueType,...e.members??[],...Object.values(e.shape??{})].some(n=>n!==void 0&&Qi(n,t)),Eh=(e,t)=>e.extensionKey!==ih&&(ji in e.shape||Object.values(e.shape).some(s=>Qi(s,t))),xh=e=>e.code==="excluded_without_reason"?`privacy_exclusion_unexplained: "${e.table}" is excluded without a reason. Give one in definePrivacy({ exclude }).`:`privacy_table_unclassified: "${e.table}" holds user data (a "${ji}" column or a v.id of a user table) but no dataset exports it. Add it to a defineDataset, or exclude it in definePrivacy({ exclude }) with a reason.`,Sh=(e,t)=>{if(!t.enabled)return;const s=e.filter(o=>Eh(o,t.userTables)).map(o=>o.name),[n]=th(s,t.classifications);if(n!==void 0)throw new _("PRIVACY_COVERAGE",xh(n));const[i]=t.unusedDatasets;if(i!==void 0)throw new _("PRIVACY_COVERAGE",`privacy_dataset_unused: "${i}" is declared with defineDataset but never passed to definePrivacy({ datasets }). Pass it, or delete it.`)},Ah=(e,t)=>{const s=_o(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,privacy:t.dependencies.has("@lunora/privacy"),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")}},yh=new Set(["delete","hardDelete","patch","replace","restore"]),bh=new Set(["insertMany","insertManyUnsafe","patchIf","patchWhere"]),Nh=new Set(["delete","deleteMany","hardDelete","insert","insertMany","patch","patchMany","replace","restore","upsert","upsertMany"]),wn=(e,t)=>{const s=e.getNonNullableType().getProperty("__table")?.getTypeAtLocation(t);if(s===void 0)return[];const n=s.isUnion()?s.getUnionTypes():[s],i=n.map(o=>o.getLiteralValue()).filter(o=>typeof o=="string");return i.length===n.length?i:[]},Ph=(e,t)=>{const s=e.getType();if(t==="deleteMany"||t==="patchMany"){const n=s.getArrayElementType();if(n===void 0)return[];const i=t==="patchMany"?n.getProperty("id")?.getTypeAtLocation(e):n;return i===void 0?[]:wn(i,e)}return wn(s,e)},In="",wh=(e,t)=>{if(t!=="patch"&&t!=="patchMany")return;const s=e.getArguments()[1];if(s===void 0||!r.isObjectLiteralExpression(s))return;const n=[];for(const i of s.getProperties()){if(!r.isPropertyAssignment(i)&&!r.isShorthandPropertyAssignment(i))return;n.push(i.getName())}return n},Ih=(e,t)=>{if(bh.has(e))return{method:e,tables:[t!==void 0&&r.isStringLiteral(t)?t.getLiteralText():In]};if(yh.has(e)||e==="deleteMany"||e==="patchMany"){const s=t===void 0?[]:Ph(t,e);return{method:e,tables:s.length===0?[In]:s}}},Tn=(e,t)=>e===void 0?void 0:{...e,fields:wh(t,e.method)},Th=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return;const s=t.getName(),n=t.getExpression();if(z(n))return Tn(Ih(s,e.getArguments()[0]),e);if(Nh.has(s)&&r.isPropertyAccessExpression(n)&&z(n.getExpression()))return Tn({method:s,tables:[n.getName()]},e)},Ch=(e,t)=>T(e,t,(s,n)=>{const i=Th(s);if(i===void 0)return;const o=x(s),a=s.getStartLineNumber();return i.tables.map(c=>({...i.fields===void 0?{}:{fields:i.fields},file:n,line:a,method:i.method,scope:o,table:c}))}),Oh=(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"}),kh=(e,t)=>{if(t===void 0){const s=e.getArguments()[0];if(s===void 0||!r.isObjectLiteralExpression(s)||V(s,"args")===void 0)return!1}return Jt(e,t).opaque},Rh=(e,t)=>{const s=[],n=(i,o)=>{const a=i.getInitializer();if(a===void 0||!r.isCallExpression(a))return;const c=ee(a);c!==void 0&&kh(a,c.receiver)&&s.push(Oh(t,o,a.getStartLineNumber()))};for(const i of e.getVariableStatements().filter(o=>o.isExported()))for(const o of i.getDeclarations())n(o,o.getName());return s},Fh=(e,t)=>{const s=[];for(const n of A(t)){const i=e.getSourceFile(n);i!==void 0&&s.push(...Rh(i,w(t,n)))}return s.toSorted((n,i)=>n.cacheKey.localeCompare(i.cacheKey))},Lh=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."}],["RegisteredRoom",{call:"defineRoom({ … })",note:"A dropped room has no caller to fail — its whisper topic is never wired to a handler, so joins, messages and broadcasts are silently ignored."}],["RegisteredShape",{call:"defineShape({ … })",file:"shapes"}],["RegisteredStream",{call:"query.input({ … }).stream(handler)"}],["RegisteredWebSocket",{call:"defineWebSocket({ … })",note:"A dropped socket route has no caller to fail — its path is never recognised as an upgrade route, so connections fall through to the app router and the handler never runs."}],["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"}]]),Ge=({byName:e,byPath:t},s,n)=>t.has(`${s}:${n}`)||e.has(n),Xi=e=>!e.isAny(),Ji=e=>{const t=e.getType();if(!Xi(t))return;const s=t.getAliasSymbol()?.getName()??t.getSymbol()?.getName(),n=s===void 0?void 0:Lh.get(s);return n===void 0||s===void 0?void 0:{...n,typeName:s}},Dh=e=>{const t=e.getInitializer();return t===void 0?!1:r.isCallExpression(t)||r.isIdentifier(t)||r.isPropertyAccessExpression(t)},Zi={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."},Mh=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.`}),_h={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)."},Kh=new Set(["AgentDefinition","ContainerDefinition","QueueDefinition","RegisteredShape","SubscriptionDefinition","WorkflowDefinition"]),zh={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)."},$h=(e,t,s)=>{if(!t.some(i=>Or(i)))return _h;const n=e.getVariableStatement()?.hasExportKeyword()===!0;return Kh.has(s.typeName)&&!n&&!t.some(i=>ia(i))?zh:Zi},er=(e,t,s,n,i)=>{const{call:o,file:a,note:c,typeName:l}=s,u=a!==void 0&&e!==a?a:void 0,f=u===void 0?i:Mh(u),g=c===void 0?f.remediation:`${c} ${f.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 — ${f.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};\`. ${g}`:g,title:"Procedure exists at runtime but is missing from the generated API"}},Bh=(e,t,s)=>{const n=[];for(const i of Q(e)){const o=r.isIdentifier(i.getNameNode())?It(i):[i.getName()],c=o.some(u=>Ge(s,t,u))||!Dh(i)?void 0:Ji(i),[l=i.getName()]=o;c!==void 0&&n.push(er(t,l,c,i.getStartLineNumber(),$h(i,o,c)))}return n},Vh=(e,t,s)=>{if(Ge(s,t,"default"))return[];const n=[];for(const i of e.getExportAssignments().filter(o=>!o.isExportEquals()&&!r.isIdentifier(o.getExpression()))){const o=Ji(i.getExpression());o!==void 0&&n.push(er(t,"default",o,i.getStartLineNumber(),Zi))}return n},Uh=(e,t,s)=>[...Bh(e,t,s),...Vh(e,t,s)],Wh=(e,t,s)=>e.getVariableStatements().flatMap(n=>n.getDeclarations()).filter(n=>r.isIdentifier(n.getNameNode())).filter(n=>It(n).some(i=>Ge(s,t,i))).filter(n=>{const i=n.getInitializer();return i!==void 0&&r.isCallExpression(i)&&r.isPropertyAccessExpression(i.getExpression())}).map(n=>{const i=It(n).find(o=>Ge(s,t,o))??n.getName();return{declaration:n,exportName:i,relativePath:t}}),qh=({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"}),jh=(e,t,s)=>{const n=[],i=[];for(const a of A(t)){const c=e.getSourceFile(a);if(c===void 0)continue;const l=w(t,a);n.push(...Uh(c,l,s)),i.push(...Wh(c,l,s))}const[o]=i;return o!==void 0&&i.every(({declaration:a})=>!Xi(a.getType()))&&n.push(qh(o)),n.toSorted((a,c)=>a.cacheKey.localeCompare(c.cacheKey))},Hh=e=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t)||t.getName()!=="get")return!1;const s=t.getExpression();return r.isPropertyAccessExpression(s)?s.getName()==="workflows":r.isIdentifier(s)&&s.getText()==="workflows"},Gh=e=>{const t=e.getArguments()[0];return t&&r.isStringLiteral(t)?t.getLiteralText():""},Yh=(e,t)=>T(e,t,(s,n)=>Hh(s)?{file:n,line:s.getStartLineNumber(),scope:x(s),workflow:Gh(s)}:void 0),Ie=(e,t)=>{M(e)&&Ye(e,"utf8")===t||mr(e,t,"utf8")},Qh=(e,t)=>{if(t===""){be(e,{force:!0});return}Ie(e,t)},Xh=(e,t)=>{const s=E(e,"services");if(Object.keys(t).length===0){be(s,{force:!0,recursive:!0});return}if(M(s))for(const n of Cn(s,{recursive:!0,withFileTypes:!0})){const i=E(n.parentPath,n.name);n.isFile()&&t[On(e,i)]===void 0&&be(i)}for(const[n,i]of Object.entries(t))Bt(Vt(E(e,n)),{recursive:!0}),Ie(E(e,n),i)},Jh=(e,t,s)=>{const n=E(e,t);if(Object.keys(s).length===0){be(n,{force:!0,recursive:!0});return}if(M(n))for(const i of Cn(n,{recursive:!0,withFileTypes:!0})){const o=E(i.parentPath,i.name);i.isFile()&&s[On(n,o)]===void 0&&be(o)}for(const[i,o]of Object.entries(s)){const a=E(n,i);Bt(Vt(a),{recursive:!0}),Ie(a,o)}},Zh=e=>{try{const t=oa(E(e,"package.json"));return typeof t.version=="string"&&t.version!==""?t.version:void 0}catch{return}},Be=(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)},ev=(e,t,s)=>e.getSourceFile(t)?.getFullText()===s,tv=(e,t)=>{M(e)||Bt(e,{recursive:!0});const s=[];for(const n of t)switch(n.kind){case"always":{Ie(E(e,n.name),n.content),s.push(n.name);break}case"directory":{Jh(e,n.name,n.files),s.push(...Object.keys(n.files).map(i=>E(n.name,i)));break}case"services":{Xh(e,n.files),s.push(...Object.keys(n.files));break}default:Qh(E(e,n.name),n.content),n.content!==""&&s.push(n.name)}return s},sv=e=>{const t=Zh(e.projectRoot),s=e.wantsArchitecture?e.modules:[],n=ca({functions:e.functions,httpRoutes:e.httpRoutes,modules:s,version:t}),i=da({functions:e.functions,modules:s,version:t});return{openApiContent:`${JSON.stringify(n,void 0,2)}
29
+ `,openApiModuleContent:la(n),openRpcContent:`${JSON.stringify(i,void 0,2)}
30
+ `,openRpcModuleContent:ua(i)}},nv=".lunora-schema.json",iv=()=>{const e=process.env.LUNORA_CODEGEN_TIMING;return e!==void 0&&e!==""},rv=(e,t,s)=>{if(s&&e.length>0){const o=e.map(a=>`"${a.exportName}"`).join(", ");throw new _("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 i=t.columns.length>0;for(const o of e){if(o.table===void 0){if(i)throw new _("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 _("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})}},ov=8,av=e=>{const{agents:t,apiPath:s,generatedFunctionsPath:n,internalPath:i,lazyFunctions:o,lunoraDirectory:a,migrations:c,project:l,roomsSupported:u,shapes:f,usesSandbox:g,useUmbrella:m,workflows:v}=e,$=()=>Yo(()=>{const F=Qo(l,a,{lazyFunctions:o}),k=Hr(l,a);return{functions:F,httpRoutes:Xo(l,a),mutators:k}});let{erased:ue,value:{functions:b,httpRoutes:B,mutators:H}}=$();mn([...b,...H].map(F=>F.filePath)),mn(B.filter(F=>F.stream).map(F=>F.filePath),"http-stream");for(let F=1;;F+=1){const k=u?b:b.filter(N=>N.channel?.kind!=="room"&&N.lifecycle!=="socket"),C=xa({agents:t,functions:k,httpRoutes:B,mutators:H,useUmbrella:m,workflows:v}),U={agents:t,functions:k,lazyFunctions:o,migrations:c,mutators:H,shapes:f,useUmbrella:m,usesSandbox:g},X=Ta(U),te=Ca(U),se=Sa({functions:b,useUmbrella:m}),oe=E(a,"_generated",Qn),K=[[s,C],[i,se],[n,X],...Object.entries(te).map(([N,O])=>[E(oe,N),O])];if(F>=ov||K.every(([N,O])=>ev(l,N,O)))return{apiContent:C,erased:ue,functions:b,functionModulesContent:te,functionsContent:X,httpRoutes:B,internalContent:se,mutators:H};for(const[N,O]of K)Be(l,N,O);({erased:ue,value:{functions:b,httpRoutes:B,mutators:H}}=$())}},PE=e=>{const t=iv(),s=t?ht.now():0,n=E(e.projectRoot,e.lunoraDirectory??"lunora"),i=e.lazyFunctions===!0,o=E(n,"schema.ts");if(!M(o))throw new _("INTERNAL",`schema.ts not found at ${o}`);const a=e.project??ho(n);$r(Om);const c=sa(a,o,e.projectRoot);Sh(c.tables,vh(a,n,Hn(e.projectRoot)));const{agents:l,capabilities:u,containers:f,crons:g,dataModelContent:m,dependencies:v,entryCronTriggers:$,env:ue,featureUsage:b,hasFlags:B,hasNotify:H,identity:F,platformGate:k,queues:C,serverContent:U,services:X,storageRulesMetadata:te,topics:se,usesSandbox:oe,useUmbrella:K,workflows:N}=fm({lunoraDirectory:n,project:a,projectRoot:e.projectRoot,schema:c,target:e.target});Lm(c,c.jurisdiction===void 0?void 0:Rm(a,n));const O=E(n,"_generated"),Te=E(O,"dataModel.ts"),D=E(O,"server.ts"),tr=E(O,"api.ts"),sr=E(O,"internal.ts"),nr=E(O,"functions.ts");Be(a,Te,m),Be(a,D,U);const ls=Object.fromEntries(X.filter(p=>p.rpcEntrypoint!==void 0).flatMap(p=>Object.entries(Vo(p,O))));for(const[p,mt]of Object.entries(ls))Be(a,E(O,p),mt);const Ce=Zo(a,n),fe=na(a,n),rt=k.signals.typedWebSockets!==!1,{apiContent:ds,erased:ir,functions:J,functionModulesContent:us,functionsContent:fs,httpRoutes:ot,internalContent:gs,mutators:at}=av({agents:l,apiPath:tr,generatedFunctionsPath:nr,internalPath:sr,lazyFunctions:i,roomsSupported:rt,lunoraDirectory:n,migrations:Ce,project:a,shapes:fe,useUmbrella:K,usesSandbox:oe,workflows:N}),ps=ro(a,n),ct=oo(ps,c,[...J,...ot].map(p=>p.filePath)),Oe=ps.length>0,ke=e.lint===!1&&!Oe?void 0:{callEdges:Pm(a,n),inserts:Jo(a,n),queries:ea(a,n,J),tableWrites:Ch(a,n),workflowCalls:Yh(a,n)},Re=e.lint===!1||ke===void 0?void 0:fp(a,n,{callSites:ke,containers:f,crons:g,functions:J,modules:ct,mutators:at,queues:C,schema:c,shapes:fe,workflows:N,wranglerVariables:e.wranglerVariables}),ms=Re===void 0?[]:xp(e.projectRoot,[...hr(Re,{source:"static"}),...jh(a,n,{byName:new Set([...N,...C,...l,...f].map(p=>p.exportName)),byPath:new Set([...J,...at,...fe,...Ce].map(p=>`${p.filePath}:${p.exportName}`))}),...Fh(a,n),...Go(ir,n),...fa(C,e.wranglerQueueProducers)]),rr=ta(a,n),hs=Ym(a,n);rv(fe,hs,Hm(a,n));const or=B?Cm(a,n):[],lt=k.signals.vectorStore!==!1,ar=Ko(Tt(e.projectRoot,e.target),"deliveryAuthorization"),he=Ah(b,{containerCount:f.length,cronCount:g.length,dependencies:v,hasPaymentTables:Jm(c.tables),queueCount:C.length,storageColumnCount:Object.keys(Gn(c)).length,storageRuleCount:te.rules.length,vectorIndexCount:c.vectorIndexes.length,target:Tt(e.projectRoot,e.target),vectorStoreSupported:lt,workflowCount:N.length}),vs=t?ht.now():0,dt=aa(c,Ce.map(p=>p.id)),ut=Wm(a,n),Es=$o({advisories:ms.filter(p=>p.name!=="procedure_type_check_unavailable"),advisorProcedures:Re?.procedureProtections??[],agents:l,capabilities:u,containers:f,env:ue,flagKeys:or,hasFlags:B,hasNotify:H,hasRooms:rt&&J.some(p=>p.channel?.kind==="room"),hasSensitiveArgs:l.length>0||J.some(p=>mo(p)),hasSecretValues:k.signals.secretValues===!0,hasSockets:rt&&J.some(p=>p.lifecycle==="socket"),lazyFunctions:i,hasVectors:lt,liveStreamDeclarations:ut,liveStreams:k.signals.liveStreams===!0,maskMetadata:hs,mutators:at,queues:C,rlsMetadata:rr,schema:c,schemaSnapshot:dt,shapes:fe,services:X,storageRules:te,studioFeatures:he,topics:se,useUmbrella:K,workflows:N}),xs=va(fe,v.has("@lunora/db"),K),Ss=ga(f,c.jurisdiction),As=pa(N),ys=ma(l),bs=ha(C,e.wranglerQueueProducers),Ns=Oa(ut,K),Ps=Aa(g),cr=ya(he.scheduler),lr=ba(c.tables,K,c.jurisdiction),dr=io(e.projectRoot)?Na(K):"",ws=Pa(c.vectorIndexes),Fe=Ia(c,K),Is=Ea(v.has("@lunora/seed")),Le=e.apiSpec??"openapi",ft=Le==="openapi"||Le==="both",gt=Le==="openrpc"||Le==="both",Ts=ra({capabilities:u,emailAgents:l.filter(p=>p.onEmail===!0).map(p=>({className:p.className,exportName:p.exportName})),hasAccess:v.has("@lunora/cloudflare-access"),hasAuth:v.has("@lunora/auth"),hasFramework:v.has("@lunora/astro")||v.has("@lunora/svelte")||v.has("@lunora/vue")||M(E(e.projectRoot,"src","worker.ts")),hasGlobal:c.tables.some(p=>qn(p)),hasHyperdriveGlobal:c.tables.some(p=>jn(p)),hasKvIntrospector:he.kv,hasNotify:H,hasQueue:C.some(p=>p.mode==="push"),liveStreams:k.signals.liveStreams===!0,liveStreamsWithheld:k.liveStreamsWithheld,liveStreamDeclarations:ut,hasScheduler:he.scheduler,hasSourcedTables:c.tables.some(p=>p.externalSource!==void 0),hasStorage:he.storage,hasDeliveryAuthorization:ar,hasVectors:lt,hasWorkflow:N.length>0,identity:F,jurisdiction:c.jurisdiction,jurisdictionPinsAuth:c.jurisdictionPinsAuth===!0,tables:c.tables.map(p=>({name:p.name,shardMode:p.shardMode})),useUmbrella:K,vectorIndexCount:c.vectorIndexes.length,voiceAgents:l.filter(p=>p.voice===!0&&p.voiceBindingName!==void 0).map(p=>({bindingName:p.voiceBindingName,exportName:p.exportName})),wantsArchitecture:Oe,wantsOpenApi:ft,wantsOpenRpc:gt}),{openApiContent:Cs,openApiModuleContent:Os,openRpcContent:ks,openRpcModuleContent:Rs}=sv({functions:J,httpRoutes:ot,modules:ct,projectRoot:e.projectRoot,wantsArchitecture:Oe}),ve=Oe&&ke!==void 0?Lp({...ke,crons:g,functions:J,httpRoutes:ot,modules:ct,queues:C,schema:c,services:X,topics:se,workflows:N}):void 0,pt=E(n,nv),ur=M(pt),fr=e.dryRun?[]:tv(O,[{content:Ts,kind:"always",name:"app.ts"},{content:m,kind:"always",name:"dataModel.ts"},{content:ds,kind:"always",name:"api.ts"},{content:gs,kind:"always",name:"internal.ts"},{content:U,kind:"always",name:"server.ts"},{content:fs,kind:"always",name:"functions.ts"},{files:us,kind:"directory",name:Qn},{content:Es,kind:"always",name:"shard.ts"},{content:Ps,kind:"always",name:"crons.ts"},{content:ws,kind:"always",name:"vectors.ts"},{content:Fe.global,kind:"always",name:"drizzle.global.ts"},{content:Fe.shard,kind:"always",name:"drizzle.shard.ts"},{content:Ss,kind:"optional",name:"containers.ts"},{content:As,kind:"optional",name:"workflows.ts"},{content:ys,kind:"optional",name:"agents.ts"},{content:bs,kind:"optional",name:"queues.ts"},{content:Ns,kind:"optional",name:"live.ts"},{content:cr,kind:"optional",name:"scheduler.ts"},{content:lr,kind:"optional",name:"shardRegistry.ts"},{content:dr,kind:"optional",name:"durableObjects.ts"},{content:Is,kind:"optional",name:"seed.ts"},{content:xs,kind:"optional",name:"collections.ts"},{files:ls,kind:"services"},{content:ft?Cs:"",kind:"optional",name:"openapi.json"},{content:ft?Os:"",kind:"optional",name:"openapi.ts"},{content:gt?ks:"",kind:"optional",name:"openrpc.json"},{content:gt?Rs:"",kind:"optional",name:"openrpc.ts"},{content:ve===void 0?"":`${JSON.stringify(ve,void 0,2)}
31
+ `,kind:"optional",name:"architecture.json"},{content:ve===void 0?"":Dp(ve),kind:"optional",name:"architecture.ts"}]);if(!e.dryRun&&(!ur||e.updateSchemaBaseline===!0)&&Ie(pt,vr(dt)),t){const p=ht.now(),mt=Math.round(p-s),gr=Math.round(vs-s),pr=Math.round(p-vs);console.error(`@lunora/codegen: codegen took ${mt.toString()}ms (discovery ${gr.toString()}ms, emit ${pr.toString()}ms)`)}return{advisories:ms,advisorContext:Re,agents:l,architecture:ve,containers:f,cronTriggers:[...new Set([...wa(g),...$])],generated:{agents:ys,api:ds,app:Ts,collections:xs,containers:Ss,crons:Ps,dataModel:m,drizzleGlobal:Fe.global,drizzleShard:Fe.shard,functionModules:us,functions:fs,internal:gs,live:Ns,openApi:Cs,openApiModule:Os,openRpc:ks,openRpcModule:Rs,queues:bs,seed:Is,server:U,shard:Es,vectors:ws,workflows:As},migrations:Ce,outputDirectory:O,platformDiagnostics:k.diagnostics,queues:C,schemaSnapshot:dt,schemaSnapshotPath:pt,workflows:N,writtenFiles:fr}};export{nv as SCHEMA_SNAPSHOT_FILENAME,ho as createCodegenProject,TE as findTsconfig,CE as refreshCodegenProject,PE as runCodegen,OE as tsconfigFingerprint};