@lunora/codegen 1.0.0-alpha.218 → 1.0.0-alpha.219

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 (69) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/packem_shared/AGENTS_FILENAME-CXktfidB.mjs +1 -0
  3. package/dist/packem_shared/CONTAINERS_FILENAME-CtYUTuyn.mjs +1 -0
  4. package/dist/packem_shared/{DEFAULT_TARGET-lXUZWR6a.mjs → DEFAULT_TARGET-CwlCMxUf.mjs} +1 -1
  5. package/dist/packem_shared/FLAGS_FILENAME-qQuylR_O.mjs +1 -0
  6. package/dist/packem_shared/{GENERATED_HEADER-CHaKsSSS.mjs → GENERATED_HEADER-Dxg5tOEa.mjs} +1 -1
  7. package/dist/packem_shared/MUTATORS_FILENAME-DCsa5Ma-.mjs +1 -0
  8. package/dist/packem_shared/NOTIFY_FILENAME-D67sEwVX.mjs +1 -0
  9. package/dist/packem_shared/{OPENRPC_VERSION-CJU-lqTu.mjs → OPENRPC_VERSION-DAxS0CaZ.mjs} +1 -1
  10. package/dist/packem_shared/PROJECT_CONFIG_FILENAMES-DfD2MHzr.mjs +1 -0
  11. package/dist/packem_shared/QUEUES_FILENAME-BdgYKMU9.mjs +1 -0
  12. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-DPe7MX0x.mjs +9 -0
  13. package/dist/packem_shared/SHAPES_FILENAME-DTGoT04E.mjs +1 -0
  14. package/dist/packem_shared/WORKFLOWS_FILENAME-B6GW6JVZ.mjs +1 -0
  15. package/dist/packem_shared/{buildOpenApiDocument-DGps0I-b.mjs → buildOpenApiDocument-D1dd4rBh.mjs} +1 -1
  16. package/dist/packem_shared/chain-CjJF9d9k.mjs +1 -0
  17. package/dist/packem_shared/{classify-procedure-call-RjsZg8AH.mjs → classify-procedure-call-CZU6n3yF.mjs} +1 -1
  18. package/dist/packem_shared/{context-property-calls-DV-Pt4KS.mjs → context-property-calls-ClziPULs.mjs} +1 -1
  19. package/dist/packem_shared/discoverAuthApiCalls-GNVuIrUo.mjs +1 -0
  20. package/dist/packem_shared/discoverCrons-CV2EZ_vn.mjs +1 -0
  21. package/dist/packem_shared/discoverFunctions-Bk10Q2Zl.mjs +1 -0
  22. package/dist/packem_shared/{discoverHttpRoutes-HeBP7vhK.mjs → discoverHttpRoutes-DJ-y2q50.mjs} +1 -1
  23. package/dist/packem_shared/discoverHyperdriveCalls-C5he04zb.mjs +1 -0
  24. package/dist/packem_shared/{discoverInserts-BP0Gl37o.mjs → discoverInserts-gOn4B3o0.mjs} +1 -1
  25. package/dist/packem_shared/discoverMaskProcedures-GgXYEuuB.mjs +1 -0
  26. package/dist/packem_shared/discoverMigrations-DTv9qRcf.mjs +1 -0
  27. package/dist/packem_shared/{discoverNondeterministicCalls-CJYIXWPw.mjs → discoverNondeterministicCalls-CWAlKa4g.mjs} +1 -1
  28. package/dist/packem_shared/discoverQueries-CjxhCGm8.mjs +1 -0
  29. package/dist/packem_shared/discoverR2sqlCalls-BkoDbcXj.mjs +1 -0
  30. package/dist/packem_shared/discoverRlsMetadata-Cc-eoo9M.mjs +1 -0
  31. package/dist/packem_shared/discoverRlsProcedures-CsbCosUT.mjs +1 -0
  32. package/dist/packem_shared/{discoverSandboxUsage-pJ42YuvL.mjs → discoverSandboxUsage-5WJ5s2sM.mjs} +1 -1
  33. package/dist/packem_shared/discoverSchema-DvQyqT4W.mjs +1 -0
  34. package/dist/packem_shared/{discoverStorageRulesMetadata-BFiKUo5m.mjs → discoverStorageRulesMetadata-Bj6gg_lr.mjs} +1 -1
  35. package/dist/packem_shared/{emit-CBX_NHUL.mjs → emit-6YJU3YbV.mjs} +124 -124
  36. package/dist/packem_shared/{emitApp-Dd-mGXqR.mjs → emitApp-BewH-Jfe.mjs} +1 -1
  37. package/dist/packem_shared/{exported-procedure-chains-CjlBrFjo.mjs → exported-procedure-chains-DhKcj-hK.mjs} +1 -1
  38. package/dist/packem_shared/index-BGHtJQPU.mjs +1 -0
  39. package/dist/packem_shared/listLunoraSourceFiles-vjwjgpjd.mjs +1 -0
  40. package/dist/packem_shared/parse-validator-2u-Io0i5.mjs +1 -0
  41. package/dist/packem_shared/queries-C8MF4jMB.mjs +1 -0
  42. package/dist/packem_shared/{unwrap-handler-return-BEdusskg.mjs → unwrap-handler-return-C1OS0xP8.mjs} +1 -1
  43. package/package.json +5 -5
  44. package/dist/packem_shared/AGENTS_FILENAME-DPIMTD_h.mjs +0 -1
  45. package/dist/packem_shared/CONTAINERS_FILENAME-wDZs0S4p.mjs +0 -1
  46. package/dist/packem_shared/FLAGS_FILENAME-CQofXgIf.mjs +0 -1
  47. package/dist/packem_shared/MUTATORS_FILENAME-CE7K7DfT.mjs +0 -1
  48. package/dist/packem_shared/NOTIFY_FILENAME-DbuOgja2.mjs +0 -1
  49. package/dist/packem_shared/PROJECT_CONFIG_FILENAMES-BkkKjazl.mjs +0 -1
  50. package/dist/packem_shared/QUEUES_FILENAME-Dd781zOQ.mjs +0 -1
  51. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BByCXJyw.mjs +0 -9
  52. package/dist/packem_shared/SHAPES_FILENAME-BtuI2r7-.mjs +0 -1
  53. package/dist/packem_shared/WORKFLOWS_FILENAME-v3AJcUjy.mjs +0 -1
  54. package/dist/packem_shared/chain-u-8_P10m.mjs +0 -1
  55. package/dist/packem_shared/discoverAuthApiCalls-EHm1O8uG.mjs +0 -1
  56. package/dist/packem_shared/discoverCrons-B2GXsB-m.mjs +0 -1
  57. package/dist/packem_shared/discoverFunctions-7IsdPbJJ.mjs +0 -1
  58. package/dist/packem_shared/discoverHyperdriveCalls-CzRlqv_N.mjs +0 -1
  59. package/dist/packem_shared/discoverMaskProcedures-Cl2I3ycl.mjs +0 -1
  60. package/dist/packem_shared/discoverMigrations-BX86Fv9G.mjs +0 -1
  61. package/dist/packem_shared/discoverQueries-COGaQPE5.mjs +0 -1
  62. package/dist/packem_shared/discoverR2sqlCalls-emIgm3TF.mjs +0 -1
  63. package/dist/packem_shared/discoverRlsMetadata-3Gs8U3ng.mjs +0 -1
  64. package/dist/packem_shared/discoverRlsProcedures-CU7YMR3P.mjs +0 -1
  65. package/dist/packem_shared/discoverSchema-ClYGs0dx.mjs +0 -1
  66. package/dist/packem_shared/index-D6xfnMEE.mjs +0 -1
  67. package/dist/packem_shared/listLunoraSourceFiles-DsxeRYvh.mjs +0 -1
  68. package/dist/packem_shared/parse-validator-DW5RNi_6.mjs +0 -1
  69. package/dist/packem_shared/queries-TZaLWhWq.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as d,toAdvisorContext as f}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as l}from"./packem_shared/describeErrorLevelFindings-D23VSkFP.mjs";import{CodegenDiagnosticError as x,diagnosticAt as E}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as u,discoverAgents as v}from"./packem_shared/AGENTS_FILENAME-DPIMTD_h.mjs";import{listLunoraSourceFiles as g}from"./packem_shared/listLunoraSourceFiles-DsxeRYvh.mjs";import{default as O}from"./packem_shared/discoverAuthApiCalls-EHm1O8uG.mjs";import{CONTAINERS_FILENAME as M,discoverContainers as T}from"./packem_shared/CONTAINERS_FILENAME-wDZs0S4p.mjs";import{default as h}from"./packem_shared/discoverCrons-B2GXsB-m.mjs";import{FLAGS_FILENAME as F,discoverFlags as I}from"./packem_shared/FLAGS_FILENAME-CQofXgIf.mjs";import{default as D}from"./packem_shared/discoverFunctions-7IsdPbJJ.mjs";import{default as U}from"./packem_shared/discoverHttpRoutes-HeBP7vhK.mjs";import{default as H}from"./packem_shared/discoverHyperdriveCalls-CzRlqv_N.mjs";import{default as y}from"./packem_shared/discoverInserts-BP0Gl37o.mjs";import{d as W}from"./packem_shared/index-D6xfnMEE.mjs";import{default as V}from"./packem_shared/discoverMigrations-BX86Fv9G.mjs";import{MUTATORS_FILENAME as Q,discoverMutators as w}from"./packem_shared/MUTATORS_FILENAME-CE7K7DfT.mjs";import{default as q}from"./packem_shared/discoverNondeterministicCalls-CJYIXWPw.mjs";import{NOTIFY_FILENAME as Y,discoverNotifyCalls as X,discoverNotifyConfig as Z}from"./packem_shared/NOTIFY_FILENAME-DbuOgja2.mjs";import{default as ee}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as oe}from"./packem_shared/queries-TZaLWhWq.mjs";import{QUEUES_FILENAME as se,discoverQueues as ae}from"./packem_shared/QUEUES_FILENAME-Dd781zOQ.mjs";import{default as me}from"./packem_shared/discoverR2sqlCalls-emIgm3TF.mjs";import{default as fe}from"./packem_shared/discoverRlsProcedures-CU7YMR3P.mjs";import{default as ce}from"./packem_shared/discoverRlsMetadata-3Gs8U3ng.mjs";import{discoverSandboxUsage as le}from"./packem_shared/discoverSandboxUsage-pJ42YuvL.mjs";import{default as xe}from"./packem_shared/discoverSchema-ClYGs0dx.mjs";import{SHAPES_FILENAME as Ae,discoverShapes as ue}from"./packem_shared/SHAPES_FILENAME-BtuI2r7-.mjs";import{default as Ne}from"./packem_shared/discoverStorageRulesMetadata-BFiKUo5m.mjs";import{WORKFLOWS_FILENAME as Ce,discoverWorkflows as Oe}from"./packem_shared/WORKFLOWS_FILENAME-v3AJcUjy.mjs";import{G as Me,e as Te,a as _e,b as he,c as Le,d as Fe,f as Ie,g as Pe,h as De,i as Ge,j as Ue,k as be,l as He,m as je,n as ye}from"./packem_shared/emit-CBX_NHUL.mjs";import{emitApp as We}from"./packem_shared/emitApp-Dd-mGXqR.mjs";import{isD1GlobalTable as Ve,isHyperdriveGlobalTable as ze}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as we,emitOpenApi as Je,emitOpenApiModule as qe}from"./packem_shared/buildOpenApiDocument-DGps0I-b.mjs";import{OPENRPC_VERSION as Ye,buildOpenRpcDocument as Xe,emitOpenRpc as Ze,emitOpenRpcModule as $e}from"./packem_shared/OPENRPC_VERSION-CJU-lqTu.mjs";import{DEFAULT_TARGET as rr,platformMatrixIds as or,readProjectTarget as tr,resolveCodegenTarget as sr}from"./packem_shared/DEFAULT_TARGET-lXUZWR6a.mjs";import{PROJECT_CONFIG_FILENAMES as ir,findProjectConfigFile as mr,loadProjectConfig as dr,readProjectConfigLiterals as fr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-BkkKjazl.mjs";import{SCHEMA_SNAPSHOT_FILENAME as cr,createCodegenProject as nr,findTsconfig as lr,refreshCodegenProject as Sr,runCodegen as xr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-BByCXJyw.mjs";import{SchemaSnapshotParseError as Ar,buildSchemaSnapshot as ur,evaluateSchemaDrift as vr,parseSchemaSnapshot as Nr}from"./packem_shared/SchemaSnapshotParseError-lUWe6lPo.mjs";import{schemaFromIr as Cr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as Rr,validatorIrToJsonSchema as Mr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as _r,SDK_TARGETS as hr,generateSdk as Lr}from"./packem_shared/SDK_LANGUAGES-CFyux-74.mjs";import{redact as Ir,secretKindOf as Pr}from"./packem_shared/redact-Cy14LEnc.mjs";import{MESSAGE_SOLUTIONS as Gr,findSolutionByMessage as Ur}from"@lunora/errors";import{isTypedSchema as Hr}from"./packem_shared/isTypedSchema-B_qlBbE-.mjs";const e="0.0.0";export{u as AGENTS_FILENAME,M as CONTAINERS_FILENAME,x as CodegenDiagnosticError,rr as DEFAULT_TARGET,F as FLAGS_FILENAME,Me as GENERATED_HEADER,Rr as LUNORA_ERROR_CODES,Gr as LUNORA_SOLUTION_RULES,Q as MUTATORS_FILENAME,Y as NOTIFY_FILENAME,Ye as OPENRPC_VERSION,ir as PROJECT_CONFIG_FILENAMES,se as QUEUES_FILENAME,cr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,_r as SDK_LANGUAGES,hr as SDK_TARGETS,Ae as SHAPES_FILENAME,Ar as SchemaSnapshotParseError,e as VERSION,Ce as WORKFLOWS_FILENAME,we as buildOpenApiDocument,Xe as buildOpenRpcDocument,ur as buildSchemaSnapshot,nr as createCodegenProject,c as describeErrorLevelFindings,E as diagnosticAt,s as diffSchemaSnapshots,v as discoverAgents,O as discoverAuthApiCalls,T as discoverContainers,h as discoverCrons,I as discoverFlags,D as discoverFunctions,U as discoverHttpRoutes,H as discoverHyperdriveCalls,y as discoverInserts,W as discoverMaskProcedures,V as discoverMigrations,w as discoverMutators,q as discoverNondeterministicCalls,X as discoverNotifyCalls,Z as discoverNotifyConfig,oe as discoverQueries,ae as discoverQueues,me as discoverR2sqlCalls,ce as discoverRlsMetadata,fe as discoverRlsProcedures,le as discoverSandboxUsage,xe as discoverSchema,ue as discoverShapes,Ne as discoverStorageRulesMetadata,Oe as discoverWorkflows,Te as emitAgents,_e as emitApi,We as emitApp,he as emitCollections,Le as emitContainers,Fe as emitCrons,Ie as emitDataModel,Pe as emitDrizzleSchema,De as emitFunctions,Je as emitOpenApi,qe as emitOpenApiModule,Ze as emitOpenRpc,$e as emitOpenRpcModule,Ge as emitScheduler,Ue as emitServer,be as emitShard,He as emitVectors,je as emitWorkflows,ye as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,vr as evaluateSchemaDrift,Ur as findLunoraSolution,mr as findProjectConfigFile,lr as findTsconfig,m as formatAdvisories,Lr as generateSdk,Ve as isD1GlobalTable,ze as isHyperdriveGlobalTable,Hr as isTypedSchema,d as lintSchema,g as listLunoraSourceFiles,dr as loadProjectConfig,Nr as parseSchemaSnapshot,or as platformMatrixIds,ee as readPackageDependencies,fr as readProjectConfigLiterals,tr as readProjectTarget,Ir as redact,Sr as refreshCodegenProject,sr as resolveCodegenTarget,xr as runCodegen,Cr as schemaFromIr,Pr as secretKindOf,a as serializeSchemaSnapshot,f as toAdvisorContext,Mr as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as d,toAdvisorContext as f}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as l}from"./packem_shared/describeErrorLevelFindings-D23VSkFP.mjs";import{CodegenDiagnosticError as x,diagnosticAt as E}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as u,discoverAgents as v}from"./packem_shared/AGENTS_FILENAME-CXktfidB.mjs";import{listLunoraSourceFiles as g}from"./packem_shared/listLunoraSourceFiles-vjwjgpjd.mjs";import{default as O}from"./packem_shared/discoverAuthApiCalls-GNVuIrUo.mjs";import{CONTAINERS_FILENAME as M,discoverContainers as T}from"./packem_shared/CONTAINERS_FILENAME-CtYUTuyn.mjs";import{default as h}from"./packem_shared/discoverCrons-CV2EZ_vn.mjs";import{FLAGS_FILENAME as F,discoverFlags as I}from"./packem_shared/FLAGS_FILENAME-qQuylR_O.mjs";import{default as D}from"./packem_shared/discoverFunctions-Bk10Q2Zl.mjs";import{default as U}from"./packem_shared/discoverHttpRoutes-DJ-y2q50.mjs";import{default as H}from"./packem_shared/discoverHyperdriveCalls-C5he04zb.mjs";import{default as y}from"./packem_shared/discoverInserts-gOn4B3o0.mjs";import{d as W}from"./packem_shared/index-BGHtJQPU.mjs";import{default as V}from"./packem_shared/discoverMigrations-DTv9qRcf.mjs";import{MUTATORS_FILENAME as Q,discoverMutators as w}from"./packem_shared/MUTATORS_FILENAME-DCsa5Ma-.mjs";import{default as q}from"./packem_shared/discoverNondeterministicCalls-CWAlKa4g.mjs";import{NOTIFY_FILENAME as Y,discoverNotifyCalls as X,discoverNotifyConfig as Z}from"./packem_shared/NOTIFY_FILENAME-D67sEwVX.mjs";import{default as ee}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as oe}from"./packem_shared/queries-C8MF4jMB.mjs";import{QUEUES_FILENAME as se,discoverQueues as ae}from"./packem_shared/QUEUES_FILENAME-BdgYKMU9.mjs";import{default as me}from"./packem_shared/discoverR2sqlCalls-BkoDbcXj.mjs";import{default as fe}from"./packem_shared/discoverRlsProcedures-CsbCosUT.mjs";import{default as ce}from"./packem_shared/discoverRlsMetadata-Cc-eoo9M.mjs";import{discoverSandboxUsage as le}from"./packem_shared/discoverSandboxUsage-5WJ5s2sM.mjs";import{default as xe}from"./packem_shared/discoverSchema-DvQyqT4W.mjs";import{SHAPES_FILENAME as Ae,discoverShapes as ue}from"./packem_shared/SHAPES_FILENAME-DTGoT04E.mjs";import{default as Ne}from"./packem_shared/discoverStorageRulesMetadata-Bj6gg_lr.mjs";import{WORKFLOWS_FILENAME as Ce,discoverWorkflows as Oe}from"./packem_shared/WORKFLOWS_FILENAME-B6GW6JVZ.mjs";import{G as Me,e as Te,a as _e,b as he,c as Le,d as Fe,f as Ie,g as Pe,h as De,i as Ge,j as Ue,k as be,l as He,m as je,n as ye}from"./packem_shared/emit-6YJU3YbV.mjs";import{emitApp as We}from"./packem_shared/emitApp-BewH-Jfe.mjs";import{isD1GlobalTable as Ve,isHyperdriveGlobalTable as ze}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as we,emitOpenApi as Je,emitOpenApiModule as qe}from"./packem_shared/buildOpenApiDocument-D1dd4rBh.mjs";import{OPENRPC_VERSION as Ye,buildOpenRpcDocument as Xe,emitOpenRpc as Ze,emitOpenRpcModule as $e}from"./packem_shared/OPENRPC_VERSION-DAxS0CaZ.mjs";import{DEFAULT_TARGET as rr,platformMatrixIds as or,readProjectTarget as tr,resolveCodegenTarget as sr}from"./packem_shared/DEFAULT_TARGET-CwlCMxUf.mjs";import{PROJECT_CONFIG_FILENAMES as ir,findProjectConfigFile as mr,loadProjectConfig as dr,readProjectConfigLiterals as fr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DfD2MHzr.mjs";import{SCHEMA_SNAPSHOT_FILENAME as cr,createCodegenProject as nr,findTsconfig as lr,refreshCodegenProject as Sr,runCodegen as xr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-DPe7MX0x.mjs";import{SchemaSnapshotParseError as Ar,buildSchemaSnapshot as ur,evaluateSchemaDrift as vr,parseSchemaSnapshot as Nr}from"./packem_shared/SchemaSnapshotParseError-lUWe6lPo.mjs";import{schemaFromIr as Cr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as Rr,validatorIrToJsonSchema as Mr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as _r,SDK_TARGETS as hr,generateSdk as Lr}from"./packem_shared/SDK_LANGUAGES-CFyux-74.mjs";import{redact as Ir,secretKindOf as Pr}from"./packem_shared/redact-Cy14LEnc.mjs";import{MESSAGE_SOLUTIONS as Gr,findSolutionByMessage as Ur}from"@lunora/errors";import{isTypedSchema as Hr}from"./packem_shared/isTypedSchema-B_qlBbE-.mjs";const e="0.0.0";export{u as AGENTS_FILENAME,M as CONTAINERS_FILENAME,x as CodegenDiagnosticError,rr as DEFAULT_TARGET,F as FLAGS_FILENAME,Me as GENERATED_HEADER,Rr as LUNORA_ERROR_CODES,Gr as LUNORA_SOLUTION_RULES,Q as MUTATORS_FILENAME,Y as NOTIFY_FILENAME,Ye as OPENRPC_VERSION,ir as PROJECT_CONFIG_FILENAMES,se as QUEUES_FILENAME,cr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,_r as SDK_LANGUAGES,hr as SDK_TARGETS,Ae as SHAPES_FILENAME,Ar as SchemaSnapshotParseError,e as VERSION,Ce as WORKFLOWS_FILENAME,we as buildOpenApiDocument,Xe as buildOpenRpcDocument,ur as buildSchemaSnapshot,nr as createCodegenProject,c as describeErrorLevelFindings,E as diagnosticAt,s as diffSchemaSnapshots,v as discoverAgents,O as discoverAuthApiCalls,T as discoverContainers,h as discoverCrons,I as discoverFlags,D as discoverFunctions,U as discoverHttpRoutes,H as discoverHyperdriveCalls,y as discoverInserts,W as discoverMaskProcedures,V as discoverMigrations,w as discoverMutators,q as discoverNondeterministicCalls,X as discoverNotifyCalls,Z as discoverNotifyConfig,oe as discoverQueries,ae as discoverQueues,me as discoverR2sqlCalls,ce as discoverRlsMetadata,fe as discoverRlsProcedures,le as discoverSandboxUsage,xe as discoverSchema,ue as discoverShapes,Ne as discoverStorageRulesMetadata,Oe as discoverWorkflows,Te as emitAgents,_e as emitApi,We as emitApp,he as emitCollections,Le as emitContainers,Fe as emitCrons,Ie as emitDataModel,Pe as emitDrizzleSchema,De as emitFunctions,Je as emitOpenApi,qe as emitOpenApiModule,Ze as emitOpenRpc,$e as emitOpenRpcModule,Ge as emitScheduler,Ue as emitServer,be as emitShard,He as emitVectors,je as emitWorkflows,ye as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,vr as evaluateSchemaDrift,Ur as findLunoraSolution,mr as findProjectConfigFile,lr as findTsconfig,m as formatAdvisories,Lr as generateSdk,Ve as isD1GlobalTable,ze as isHyperdriveGlobalTable,Hr as isTypedSchema,d as lintSchema,g as listLunoraSourceFiles,dr as loadProjectConfig,Nr as parseSchemaSnapshot,or as platformMatrixIds,ee as readPackageDependencies,fr as readProjectConfigLiterals,tr as readProjectTarget,Ir as redact,Sr as refreshCodegenProject,sr as resolveCodegenTarget,xr as runCodegen,Cr as schemaFromIr,Pr as secretKindOf,a as serializeSchemaSnapshot,f as toAdvisorContext,Mr as validatorIrToJsonSchema};
@@ -0,0 +1 @@
1
+ import{existsSync as d}from"node:fs";import{join as p}from"node:path";import{agentDefaultName as f,agentClassName as b,agentBindingName as N,voiceBindingName as A,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as m}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as w,findObjectProperty as g,stringPropertyFor as h}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const E="agents.ts",I=i=>{const t=i.getSymbol();if(!t)return i.getText()==="defineAgent";for(const n of t.getDeclarations())if(a.isImportSpecifier(n))return n.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:n.getNameNode().getText()==="defineAgent";return!1},P=h("agent"),T=(i,t,n)=>{if(i.getKind()===u.TrueKeyword)return!0;if(i.getKind()===u.FalseKeyword)return!1;throw l(i,`agent "${t}": \`${n}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},v=(i,t)=>{const n=i.getArguments()[0];if(!n||!a.isObjectLiteralExpression(n))throw l(i,`agent "${t}": defineAgent must be passed an inline object literal`);const o={bindingName:N(t),className:b(t),exportName:t,name:f(t)},e=g(n,"name");e&&a.isPropertyAssignment(e)&&(o.name=P(e.getInitializerOrThrow(),t,"name"));const r=g(n,"publicRun");r&&a.isPropertyAssignment(r)&&T(r.getInitializerOrThrow(),t,"publicRun")&&(o.publicRun=!0);const s=g(n,"voice");if(s&&a.isPropertyAssignment(s)){const c=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(c))throw l(c,`agent "${t}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);o.voice=!0,o.voiceBindingName=A(t),o.voiceClassName=y(t)}return g(n,"onEmail")&&(o.onEmail=!0),o},D=i=>{const t=[];for(const n of i.getVariableDeclarations()){if(!n.isExported())continue;const o=w(n.getInitializer());if(!o)continue;const e=o.getExpression();if(!a.isIdentifier(e)||!I(e))continue;const r=n.getNameNode();if(!a.isIdentifier(r))throw l(r,"defineAgent exports must be plain named exports (no destructuring)");t.push(v(o,r.getText()))}return t},x=i=>{const t=new Map,n=new Map,o=new Map;for(const e of i){const r=t.get(e.name);if(r!==void 0)throw new m("DUPLICATE_AGENT_NAME",`Duplicate agent name "${e.name}": produced by both "${r}" and "${e.exportName}". Deployed agent names must be unique across the project.`,{status:500});t.set(e.name,e.exportName);const s=n.get(e.bindingName);if(s!==void 0)throw new m("DUPLICATE_AGENT_BINDING",`Duplicate agent binding "${e.bindingName}": produced by both "${s}" and "${e.exportName}". Agent export names must yield unique binding names.`,{status:500});n.set(e.bindingName,e.exportName);const c=o.get(e.className);if(c!==void 0)throw new m("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${e.className}": produced by both "${c}" and "${e.exportName}". Agent export names must yield unique generated class names.`,{status:500});o.set(e.className,e.exportName)}},_=(i,t)=>{const n=p(t,E);if(!d(n))return[];const o=i.getSourceFile(n)??i.addSourceFileAtPath(n),e=D(o);return e.sort((r,s)=>r.exportName.localeCompare(s.exportName)),x(e),e};export{E as AGENTS_FILENAME,_ as discoverAgents};
@@ -0,0 +1 @@
1
+ import{existsSync as T}from"node:fs";import{join as A}from"node:path";import{containerClassName as L,containerBindingName as k,normalizeContainerImage as d}from"@lunora/container";import{SyntaxKind as g,Node as s}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{propertyKeyName as b,stringPropertyFor as v,findObjectProperty as h,symbolConstInitializer as P}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const $="containers.ts",O=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineContainer";for(const n of t.getDeclarations())if(s.isImportSpecifier(n))return n.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:n.getNameNode().getText()==="defineContainer";return!1},f=v("container"),p=(e,t,n)=>{if(s.isNumericLiteral(e))return e.getLiteralValue();throw c(e,`container "${t}": \`${n}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I=(e,t)=>{if(s.isStringLiteral(e)||s.isNoSubstitutionTemplateLiteral(e))return d(e.getLiteralValue());if(s.isObjectLiteralExpression(e)){const n=h(e,"registry");if(n&&s.isPropertyAssignment(n)){const i=n.getInitializerOrThrow();return d({registry:f(i,t,"image.registry")})}const r=h(e,"build");if(r&&s.isPropertyAssignment(r)){const i=r.getInitializerOrThrow();return d({build:f(i,t,"image.build")})}}throw c(e,`container "${t}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},j=new Set(["buildArgs","image","instanceType","maxInstances","name","rollout"]),C=new Set(["gracePeriodSeconds","stepPercentage"]),w=e=>{let t=e;for(;s.isAsExpression(t)||s.isSatisfiesExpression(t)||s.isTypeAssertion(t)||s.isParenthesizedExpression(t);)t=t.getExpression();return t},z=(e,t)=>{const n=i=>{let o=i;for(;s.isPropertyAccessExpression(o)||s.isElementAccessExpression(o)||s.isParenthesizedExpression(o);)o=o.getExpression();return o===i?void 0:o},r=i=>i!==void 0&&s.isIdentifier(i)&&i.getSymbol()===e;return t.getDescendants().some(i=>{if(s.isBinaryExpression(i)){const o=i.getOperatorToken().getKind();return o>=g.FirstAssignment&&o<=g.LastAssignment&&r(n(i.getLeft()))}if(s.isPrefixUnaryExpression(i)||s.isPostfixUnaryExpression(i)){const o=i.getOperatorToken();return(o===g.PlusPlusToken||o===g.MinusMinusToken)&&r(n(i.getOperand()))}return s.isDeleteExpression(i)?r(n(i.getExpression())):s.isCallExpression(i)&&i.getExpression().getText()==="Object.assign"&&r(i.getArguments()[0])})},M=16,E=(e,t,n,r)=>{let i={name:n,symbol:e},o;for(let a=0;a<M;a+=1){const l=P(i.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=w(l),s.isObjectLiteralExpression(o)&&i.symbol!==void 0&&z(i.symbol,t.getSourceFile()))throw c(t,`${r}: \`${i.name}\` is a const object that is written to elsewhere in this file, so its initializer is not the value the container runs with. Declare the settings where they are final.`);if(!s.isIdentifier(o))return o;i={name:o.getText(),symbol:o.getSymbol()}}return o},S=(e,t)=>{const n=w(e);return s.isIdentifier(n)?E(n.getSymbol(),n,n.getText(),t)??n:n},x=e=>{const t=e.getNonNullableType();return(t.isUnion()?t.getUnionTypes():[t]).flatMap(r=>r.getApparentType().getProperties().map(i=>i.getName()))},N=(e,t,n)=>{const r=e.getExpression().getType(),i=t==="every"||r.isAny()||r.isUnknown()?["its keys"]:[...new Set(x(r))].filter(o=>t.has(o)).map(o=>`\`${o}\``);if(i.length>0)throw c(e,`${n}: this spread can set ${i.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},F=(e,t,n)=>{const r=b(e),i=s.isShorthandPropertyAssignment(e)?E(e.getValueSymbol(),e,r,n):void 0;if(i!==void 0)return[r,i];if(t==="every"||t.has(r))throw c(e,`${n}: \`${r}\` is deploy configuration codegen writes into wrangler.jsonc, so it must be a static literal — inline it, or name a module-scope \`const\` initialized with one.`)},m=(e,t,n,r=new Set)=>{const i=[],o=new Set(r).add(e);for(const a of e.getProperties())if(s.isPropertyAssignment(a))i.push([b(a),S(a.getInitializerOrThrow(),n)]);else if(s.isSpreadAssignment(a))i.push(...D(a,t,n,o));else{const l=F(a,t,n);l!==void 0&&i.push(l)}return i},D=(e,t,n,r)=>{const i=S(e.getExpression(),n);if(!s.isObjectLiteralExpression(i))return N(e,t,n),[];if(r.has(i))throw c(e,`${n}: this spread refers back to an object it is part of, so it has no static value.`);return m(i,t,n,r)},V=(e,t)=>{if(!s.isObjectLiteralExpression(e))throw c(e,`container "${t}": \`buildArgs\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const n={};for(const[r,i]of m(e,"every",`container "${t}" buildArgs`))n[r]=f(i,t,`buildArgs.${r}`);return Object.keys(n).length>0?n:void 0},B=(e,t)=>{if(!s.isObjectLiteralExpression(e))throw c(e,`container "${t}": \`rollout\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const n={};for(const[r,i]of m(e,C,`container "${t}" rollout`))(r==="gracePeriodSeconds"||r==="stepPercentage")&&(n[r]=p(i,t,`rollout.${r}`));return n.gracePeriodSeconds===void 0&&n.stepPercentage===void 0?void 0:n},K=e=>{if(s.isTrueLiteral(e))return!0;if(s.isFalseLiteral(e))return!1},U=e=>{if(s.isStringLiteral(e)||s.isNoSubstitutionTemplateLiteral(e)||s.isNumericLiteral(e))return e.getLiteralValue()},R=(e,t)=>{if(s.isStringLiteral(e))return e.getLiteralValue();if(s.isObjectLiteralExpression(e)){const n={};for(const r of e.getProperties()){if(!s.isPropertyAssignment(r))throw c(r,`container "${t}": \`instanceType\` must be an object of static number literals`);const i=b(r);if(i!=="diskMb"&&i!=="memoryMib"&&i!=="vcpu")throw c(r,`container "${t}": unknown \`instanceType\` field "${i}" — expected vcpu, memoryMib, or diskMb`);n[i]=p(r.getInitializerOrThrow(),t,`instanceType.${i}`)}return n}throw c(e,`container "${t}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},_=(e,t)=>{const n=e.getArguments()[0];if(!n||!s.isObjectLiteralExpression(n))throw c(e,`container "${t}": defineContainer must be passed an inline object literal`);const r={bindingName:k(t),className:L(t),exportName:t,image:{buildContext:".",dockerfilePath:"./Dockerfile",kind:"dockerfile"}};let i=!1;for(const[o,a]of m(n,j,`container "${t}"`))switch(o){case"buildArgs":{r.buildArgs=V(a,t);break}case"enableInternet":{r.enableInternet=K(a);break}case"image":{r.image=I(a,t),i=!0;break}case"instanceType":{r.instanceType=R(a,t);break}case"maxInstances":{r.maxInstances=p(a,t,"maxInstances");break}case"name":{r.name=f(a,t,"name");break}case"rollout":{r.rollout=B(a,t);break}case"sleepAfter":{r.sleepAfter=U(a);break}}if(!i)throw c(n,`container "${t}": defineContainer requires a static \`image\` property`);return r},q=e=>{const t=[],n=new Map;for(const r of e.getVariableDeclarations()){if(!r.isExported())continue;const i=r.getInitializer();if(i?.getKind()!==g.CallExpression)continue;const o=i,a=o.getExpression();if(!s.isIdentifier(a)||!O(a))continue;const l=r.getNameNode();if(!s.isIdentifier(l))throw c(l,"defineContainer exports must be plain named exports (no destructuring)");const u=_(o,l.getText()),y=n.get(u.bindingName);if(y!==void 0)throw c(l,`containers "${y}" and "${u.exportName}" both map to the binding ${u.bindingName} — rename one so each container gets its own Durable Object binding`);n.set(u.bindingName,u.exportName),t.push(u)}return t},Q=(e,t)=>{const n=A(t,$);if(!T(n))return[];const r=e.getSourceFile(n)??e.addSourceFileAtPath(n),i=q(r);return i.sort((o,a)=>o.exportName.localeCompare(a.exportName)),i};export{$ as CONTAINERS_FILENAME,Q as discoverContainers};
@@ -1 +1 @@
1
- import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h}from"@lunora/platform";import{readProjectConfigLiterals as m}from"./PROJECT_CONFIG_FILENAMES-BkkKjazl.mjs";const c="cloudflare",v=t=>{const{target:e}=m(t);return e!==void 0&&e.length>0?e:void 0},x=(t,e)=>e??v(t)??c,L=(t,e)=>{if(e!==void 0)return[];const{target:a,unreadable:o}=m(t);return o!==!0||a!==void 0?[]:[{level:"warn",message:`lunora.config declares a \`target\` that codegen cannot read without evaluating it, so the "${c}" surface was emitted. \`runCodegen\` resolves the target synchronously, which means it reads literals only.`,name:"platform_unreadable_target",remediation:`Write \`target\` as a string literal on the config's default export (\`export default { target: "${c}" }\`), or pass \`--target\`.`,target:c}]},u={cloudflare:h,node:f},I=()=>Object.keys(u).toSorted((t,e)=>t.localeCompare(e)),b={access:null,ai:"ai",analytics:"analytics",browser:"browser",container:"containers",flags:null,hyperdrive:"hyperdrive",images:"images",kv:"keyValueStore",mail:"mail",notify:null,payments:null,pipelines:"pipelines",r2sql:null,scheduler:"scheduler",storage:"objectStorage",vectors:"vectorStore",workflows:"workflows",x402:null},y=["agents","commitOrderedTables","cronTriggers","crossShardFanout","durableStreams","globalTables","queues","relationGraph","secrets","vectorStore"],g={agents:"durable agents (`defineAgent`)",commitOrderedTables:"commit-ordered tables (`.commitOrdered()`)",cronTriggers:"declared cron triggers (`cronJobs()`)",crossShardFanout:"cross-shard fan-out queries (a `.shardBy(...)` schema)",durableStreams:"durable streams (`.stream(handler, { durable: true })`)",globalTables:"global tables (`.global()`)",queues:"queues (`defineQueue`)",relationGraph:"relation-graph traversal (`ctx.db.related`, derived from `v.id(...)` columns)",secrets:"the secrets store (`ctx.secrets`)",vectorStore:"vector indexes (`.vectorize()`)"},S=(t,e,a)=>({level:"error",message:`${e.name} does not support ${g[t]}, which this app declares.`,name:"platform_unsupported_feature",remediation:`Remove the declaration, or deploy to a target whose capability matrix marks "${t}" as native or emulated.`,target:a}),T=(t,e,a)=>({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${g[t]}, which this app declares. Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${t}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than letting the app deploy onto a primitive the host may not provide.`,target:a}),_=t=>{const{diagnostics:e,gatedSignals:a,matrix:o,reported:i,signals:d,target:n}=t;for(const s of y){if(d[s]!==!0)continue;const r=o.features[s]?.level;r!=="unsupported"&&r!==void 0||(a[s]=!1,!i.has(s)&&e.push(r==="unsupported"?S(s,o,n):T(s,o,n)))}},$=(t,e,a,o={})=>{const i={...t},d={...o},n=[],s=new Set;for(const[r,l]of Object.entries(b)){if(l===null||!t[r])continue;const p=e.features[l]?.level;p==="unsupported"?(i[r]=!1,s.add(l),n.push({feature:r,level:"error",message:`${e.name} does not support "${r}" (ctx.${r}).`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${r} usage, or deploy to a target whose capability matrix marks "${l}" as native or emulated.`,target:a})):p===void 0&&(i[r]=!1,s.add(l),n.push({feature:r,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${r}" (ctx.${r}). Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${l}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than shipping a surface the host may not provide.`,target:a}))}return _({diagnostics:n,gatedSignals:d,matrix:e,reported:s,signals:o,target:a}),{diagnostics:n,signals:d,usage:i}},O=(t,e,a={})=>{const o=u[e];return o===void 0?{diagnostics:[{level:"error",message:`Unknown deploy target "${e}" — no capability matrix is registered for it. Codegen emitted the full Cloudflare surface un-gated.`,name:"platform_unknown_target",remediation:`Use a registered target (${Object.keys(u).join(", ")}) or install the target's @lunora/platform-${e} package.`,target:e}],signals:{...a},usage:{...t}}:$(t,o,e,a)};export{b as CAPABILITY_TO_FEATURE,c as DEFAULT_TARGET,$ as gateAgainstMatrix,O as gatePlatformFeatures,I as platformMatrixIds,v as readProjectTarget,L as readTargetDiagnostics,x as resolveCodegenTarget};
1
+ import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h}from"@lunora/platform";import{readProjectConfigLiterals as m}from"./PROJECT_CONFIG_FILENAMES-DfD2MHzr.mjs";const c="cloudflare",v=t=>{const{target:e}=m(t);return e!==void 0&&e.length>0?e:void 0},x=(t,e)=>e??v(t)??c,L=(t,e)=>{if(e!==void 0)return[];const{target:a,unreadable:o}=m(t);return o!==!0||a!==void 0?[]:[{level:"warn",message:`lunora.config declares a \`target\` that codegen cannot read without evaluating it, so the "${c}" surface was emitted. \`runCodegen\` resolves the target synchronously, which means it reads literals only.`,name:"platform_unreadable_target",remediation:`Write \`target\` as a string literal on the config's default export (\`export default { target: "${c}" }\`), or pass \`--target\`.`,target:c}]},u={cloudflare:h,node:f},I=()=>Object.keys(u).toSorted((t,e)=>t.localeCompare(e)),b={access:null,ai:"ai",analytics:"analytics",browser:"browser",container:"containers",flags:null,hyperdrive:"hyperdrive",images:"images",kv:"keyValueStore",mail:"mail",notify:null,payments:null,pipelines:"pipelines",r2sql:null,scheduler:"scheduler",storage:"objectStorage",vectors:"vectorStore",workflows:"workflows",x402:null},y=["agents","commitOrderedTables","cronTriggers","crossShardFanout","durableStreams","globalTables","queues","relationGraph","secrets","vectorStore"],g={agents:"durable agents (`defineAgent`)",commitOrderedTables:"commit-ordered tables (`.commitOrdered()`)",cronTriggers:"declared cron triggers (`cronJobs()`)",crossShardFanout:"cross-shard fan-out queries (a `.shardBy(...)` schema)",durableStreams:"durable streams (`.stream(handler, { durable: true })`)",globalTables:"global tables (`.global()`)",queues:"queues (`defineQueue`)",relationGraph:"relation-graph traversal (`ctx.db.related`, derived from `v.id(...)` columns)",secrets:"the secrets store (`ctx.secrets`)",vectorStore:"vector indexes (`.vectorize()`)"},S=(t,e,a)=>({level:"error",message:`${e.name} does not support ${g[t]}, which this app declares.`,name:"platform_unsupported_feature",remediation:`Remove the declaration, or deploy to a target whose capability matrix marks "${t}" as native or emulated.`,target:a}),T=(t,e,a)=>({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${g[t]}, which this app declares. Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${t}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than letting the app deploy onto a primitive the host may not provide.`,target:a}),_=t=>{const{diagnostics:e,gatedSignals:a,matrix:o,reported:i,signals:d,target:n}=t;for(const s of y){if(d[s]!==!0)continue;const r=o.features[s]?.level;r!=="unsupported"&&r!==void 0||(a[s]=!1,!i.has(s)&&e.push(r==="unsupported"?S(s,o,n):T(s,o,n)))}},$=(t,e,a,o={})=>{const i={...t},d={...o},n=[],s=new Set;for(const[r,l]of Object.entries(b)){if(l===null||!t[r])continue;const p=e.features[l]?.level;p==="unsupported"?(i[r]=!1,s.add(l),n.push({feature:r,level:"error",message:`${e.name} does not support "${r}" (ctx.${r}).`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${r} usage, or deploy to a target whose capability matrix marks "${l}" as native or emulated.`,target:a})):p===void 0&&(i[r]=!1,s.add(l),n.push({feature:r,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${r}" (ctx.${r}). Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${l}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than shipping a surface the host may not provide.`,target:a}))}return _({diagnostics:n,gatedSignals:d,matrix:e,reported:s,signals:o,target:a}),{diagnostics:n,signals:d,usage:i}},O=(t,e,a={})=>{const o=u[e];return o===void 0?{diagnostics:[{level:"error",message:`Unknown deploy target "${e}" — no capability matrix is registered for it. Codegen emitted the full Cloudflare surface un-gated.`,name:"platform_unknown_target",remediation:`Use a registered target (${Object.keys(u).join(", ")}) or install the target's @lunora/platform-${e} package.`,target:e}],signals:{...a},usage:{...t}}:$(t,o,e,a)};export{b as CAPABILITY_TO_FEATURE,c as DEFAULT_TARGET,$ as gateAgainstMatrix,O as gatePlatformFeatures,I as platformMatrixIds,v as readProjectTarget,L as readTargetDiagnostics,x as resolveCodegenTarget};
@@ -0,0 +1 @@
1
+ import{existsSync as l}from"node:fs";import{join as p}from"node:path";import{Node as t}from"ts-morph";import{defaultExportExpression as g,propertyInitializer as f,findObjectProperty as c}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const d="flags.ts",u=new Set(["@lunora/flags/providers/flagship","lunorash/flags/flagship"]),m=e=>{const i=e.getSymbol();if(!i)return e.getText()==="flagshipProvider";for(const r of i.getDeclarations())if(t.isImportSpecifier(r))return u.has(r.getImportDeclaration().getModuleSpecifierValue())?r.getNameNode().getText()==="flagshipProvider":!1;return!1},v=(e,i)=>{const r=c(e,i);if(!r||!t.isPropertyAssignment(r))return;const o=r.getInitializerOrThrow();if(t.isStringLiteral(o)||t.isNoSubstitutionTemplateLiteral(o))return o.getLiteralValue()},h=e=>{const i=e.getArguments()[0];if(i&&t.isObjectLiteralExpression(i)){const r=v(i,"binding");if(r!==void 0&&r.length>0)return{bindingName:r,mode:"binding",provider:"flagship"}}return{mode:"http",provider:"flagship"}},S=e=>f(e.getArguments()[0],"provider"),b=(e,i)=>{const r=p(i,d);if(!l(r))return;const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=g(o);if(!n||!t.isCallExpression(n))return{provider:"custom"};const s=S(n);if(s&&t.isCallExpression(s)){const a=s.getExpression();if(t.isIdentifier(a)&&m(a))return h(s)}return{provider:"custom"}};export{d as FLAGS_FILENAME,b as discoverFlags};
@@ -1 +1 @@
1
- import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{G as o,U as n,o as l,e as p,a as A,b as E,c as S,d as c,f as d,g,h as u,p as C,i as h,q as D,j as f,k as G,l as R,m as _,n as b}from"./emit-CBX_NHUL.mjs";import"./declared-output-Iaar469J.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./paths-C-9fwEgQ.mjs";import"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";export{o as GENERATED_HEADER,n as UMBRELLA_BASE_PACKAGES,l as buildStorageColumns,p as emitAgents,A as emitApi,E as emitCollections,S as emitContainers,c as emitCrons,d as emitDataModel,g as emitDrizzleSchema,u as emitFunctions,C as emitQueues,h as emitScheduler,D as emitSeed,f as emitServer,G as emitShard,R as emitVectors,_ as emitWorkflows,b as emitWranglerCronTriggers};
1
+ import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{G as o,U as n,o as l,e as p,a as A,b as E,c as S,d as c,f as d,g,h as u,p as C,i as h,q as D,j as f,k as G,l as R,m as _,n as b}from"./emit-6YJU3YbV.mjs";import"./declared-output-Iaar469J.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./paths-C-9fwEgQ.mjs";import"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";export{o as GENERATED_HEADER,n as UMBRELLA_BASE_PACKAGES,l as buildStorageColumns,p as emitAgents,A as emitApi,E as emitCollections,S as emitContainers,c as emitCrons,d as emitDataModel,g as emitDrizzleSchema,u as emitFunctions,C as emitQueues,h as emitScheduler,D as emitSeed,f as emitServer,G as emitShard,R as emitVectors,_ as emitWorkflows,b as emitWranglerCronTriggers};
@@ -0,0 +1 @@
1
+ import{existsSync as p}from"node:fs";import{join as l}from"node:path";import{Node as o,SyntaxKind as m}from"ts-morph";import{diagnosticAt as g}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as d}from"./module-specifiers-WF8iAydP.mjs";import{p as x}from"./parse-validator-2u-Io0i5.mjs";import{findObjectProperty as c}from"./listLunoraSourceFiles-vjwjgpjd.mjs";import{u as M}from"./unwrap-handler-return-C1OS0xP8.mjs";const y="mutators.ts",f=d,S=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineMutator";for(const e of t.getDeclarations())if(o.isImportSpecifier(e))return f(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineMutator":!1;return!1},N=r=>{const t=r.getSymbol();if(!t)return!1;for(const e of t.getDeclarations()){if(!o.isNamespaceImport(e))continue;const i=e.getFirstAncestorByKind(m.ImportDeclaration);return i!==void 0&&f(i.getModuleSpecifierValue())}return!1},I=r=>{if(o.isIdentifier(r))return S(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(t)&&N(t)}return!1},b=r=>{const t=r.getArguments()[0];return t&&o.isObjectLiteralExpression(t)?t:void 0},A=r=>{const t=c(r,"args");if(!t||!o.isPropertyAssignment(t))return{};const e=t.getInitializer();return e&&o.isObjectLiteralExpression(e)?x(e):{}},E=r=>{const t=c(r,"server");if(!t||!o.isPropertyAssignment(t))return"unknown";const e=t.getInitializer();return!e||!(o.isArrowFunction(e)||o.isFunctionExpression(e))?"unknown":M(e)},F=r=>{const t=c(r,"owner");if(!t||!o.isPropertyAssignment(t))return;const e=t.getInitializer();return e&&o.isStringLiteral(e)?e.getLiteralValue():void 0},P=r=>{const t=[];for(const e of r.getVariableDeclarations()){if(!e.isExported())continue;const i=e.getInitializer();if(i?.getKind()!==m.CallExpression)continue;const n=i,a=n.getExpression();if(!I(a))continue;const s=e.getNameNode();if(!o.isIdentifier(s))throw g(s,"defineMutator exports must be plain named exports (no destructuring)");const u=b(n);t.push({args:A(u),exportName:s.getText(),filePath:"mutators",line:n.getStartLineNumber(),owner:F(u),returnType:E(u)})}return t},O=(r,t)=>{const e=l(t,y);if(!p(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),n=P(i);return n.sort((a,s)=>a.exportName.localeCompare(s.exportName)),n};export{y as MUTATORS_FILENAME,O as discoverMutators,I as isDefineMutatorCallee};
@@ -0,0 +1 @@
1
+ import{existsSync as x}from"node:fs";import{join as P}from"node:path";import{SyntaxKind as l,Node as c}from"ts-morph";import{listLunoraSourceFiles as p,lunoraRelativePath as g,defaultExportExpression as E,findObjectProperty as d,handlerOf as S}from"./listLunoraSourceFiles-vjwjgpjd.mjs";import{c as v}from"./classify-procedure-call-CZU6n3yF.mjs";const y="notify.ts",N=new Set(["chat","inApp","send","webhook"]),h=new Set(["broadcast","send"]),F=e=>{const t=e.getInitializer();if(!t||!c.isCallExpression(t))return;const o=v(t);if(!o)return;const s=S(t,o.receiver);return s?{exportName:e.getName(),handler:s,kind:o.kind}:void 0},m=e=>{const t=[];for(const o of e.getVariableStatements())if(o.isExported())for(const s of o.getDeclarations()){const r=F(s);r&&t.push(r)}return t},a=e=>{if(!c.isPropertyAccessExpression(e))return;const t=e.getName(),o=e.getExpression();if((t==="notify"||t==="push")&&c.isIdentifier(o)&&o.getText()==="ctx")return t;if(t==="push"&&a(o)==="notify")return"push"},A=e=>{if(!c.isPropertyAccessExpression(e))return;const t=e.getName(),o=a(e.getExpression());if(o==="notify"&&N.has(t))return`ctx.notify.${t}`;if(o==="push"&&h.has(t))return`ctx.push.${t}`},O=e=>c.isPropertyAccessExpression(e)?a(e.getExpression())==="push"&&h.has(e.getName()):!1,_=(e,t)=>{const o=[];for(const s of p(t)){const r=e.getSourceFile(s)??e.addSourceFileAtPath(s),f=g(t,s);for(const n of m(r))if(!(n.kind!=="query"&&n.kind!=="mutation"))for(const i of n.handler.getDescendantsOfKind(l.PropertyAccessExpression)){const u=A(i);u!==void 0&&o.push({callee:u,exportName:n.exportName,file:f,kind:n.kind,line:i.getStartLineNumber()})}}return o},b=(e,t)=>{for(const o of p(t)){const s=e.getSourceFile(o)??e.addSourceFileAtPath(o);for(const r of m(s))for(const f of r.handler.getDescendantsOfKind(l.PropertyAccessExpression))if(O(f))return!0}return!1},w=(e,t)=>{const o=P(t,y);if(!x(o))return;const s=e.getSourceFile(o)??e.addSourceFileAtPath(o),r=E(s);let f=!1,n=!1;if(r&&c.isCallExpression(r)){const i=r.getArguments()[0];i&&c.isObjectLiteralExpression(i)&&(f=d(i,"webPush")!==void 0,n=d(i,"fcm")!==void 0)}return{hasFcm:n,hasWebPush:f,usesPush:b(e,t)}};export{y as NOTIFY_FILENAME,_ as discoverNotifyCalls,w as discoverNotifyConfig};
@@ -1,3 +1,3 @@
1
- import{G as c,r as u}from"./emit-CBX_NHUL.mjs";import{s as m}from"./paths-C-9fwEgQ.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";const i="1.3.2",R={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},h=e=>{const o=m(e.filePath),n=`${o}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${n}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${n}", "args": { … } }\`).`,errors:d.map((r,s)=>({code:-32e3-s,data:{code:r},message:r})),name:n,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?p(e.output):R},summary:`${e.kind}: ${n}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:o}]}},g=e=>{const o=e.version??"0.0.0",r=e.functions.filter(t=>t.visibility!=="internal"&&t.kind!=="stream").map(t=>h(t)).toSorted((t,a)=>t.name.localeCompare(a.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:o},methods:r,openrpc:i}},v=e=>`${JSON.stringify(g(e),void 0,2)}
1
+ import{G as c,r as u}from"./emit-6YJU3YbV.mjs";import{s as m}from"./paths-C-9fwEgQ.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";const i="1.3.2",R={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},h=e=>{const o=m(e.filePath),n=`${o}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${n}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${n}", "args": { … } }\`).`,errors:d.map((r,s)=>({code:-32e3-s,data:{code:r},message:r})),name:n,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?p(e.output):R},summary:`${e.kind}: ${n}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:o}]}},g=e=>{const o=e.version??"0.0.0",r=e.functions.filter(t=>t.visibility!=="internal"&&t.kind!=="stream").map(t=>h(t)).toSorted((t,a)=>t.name.localeCompare(a.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:o},methods:r,openrpc:i}},v=e=>`${JSON.stringify(g(e),void 0,2)}
2
2
  `,$=e=>`${c}export const openRpcSpec = ${u(e,"Record<string, unknown>")};
3
3
  `;export{i as OPENRPC_VERSION,g as buildOpenRpcDocument,v as emitOpenRpc,$ as emitOpenRpcModule};
@@ -0,0 +1 @@
1
+ import{existsSync as m,statSync as p,readFileSync as v}from"node:fs";import{resolve as E,basename as b}from"node:path";import{createJiti as x}from"jiti";import{Project as S,Node as r}from"ts-morph";import{propertyKeyName as u}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const h=["lunora.config.ts","lunora.config.mts","lunora.config.js","lunora.config.mjs"],f=t=>h.map(i=>E(t,i)).find(i=>m(i)),g=new Map,D=async t=>{const i=f(t);if(i===void 0)return{};let e;try{const n=p(i);e=`${String(n.mtimeMs)}:${String(n.size)}`}catch{return{}}const s=g.get(i);if(s?.key===e)return s.value;const l=(async()=>{try{const o=(await x(i,{interopDefault:!1,moduleCache:!1}).import(i))?.default;return{config:o!==null&&typeof o=="object"?o:void 0}}catch(n){return{error:n instanceof Error?n.message:String(n)}}})();return g.set(i,{key:e,value:l}),l},P=t=>{let e=t.getExportAssignments().find(s=>!s.isExportEquals())?.getExpression();for(;e!==void 0&&(r.isSatisfiesExpression(e)||r.isAsExpression(e)||r.isParenthesizedExpression(e));)e=e.getExpression();if(e!==void 0&&r.isIdentifier(e))for(e=t.getVariableDeclaration(e.getText())?.getInitializer();e!==void 0&&(r.isSatisfiesExpression(e)||r.isAsExpression(e));)e=e.getExpression();return e!==void 0&&r.isObjectLiteralExpression(e)?e:void 0},c=(t,i)=>r.isPropertyAssignment(t)?t.getInitializer():i.getVariableDeclaration(u(t))?.getInitializer(),y=(t,i)=>{let e=t;for(;e!==void 0&&(r.isSatisfiesExpression(e)||r.isAsExpression(e)||r.isParenthesizedExpression(e));)e=e.getExpression();if(e===void 0||!r.isObjectLiteralExpression(e))return{advisor:{unreadable:!0}};const s=e.getProperties(),l=s.filter(a=>r.isPropertyAssignment(a)&&!r.isComputedPropertyName(a.getNameNode())||r.isShorthandPropertyAssignment(a));if(l.length!==s.length)return{advisor:{unreadable:!0}};const n=l.find(a=>u(a)==="minSeverity");if(n===void 0)return{advisor:{}};const o=c(n,i);return o!==void 0&&r.isStringLiteral(o)?{advisor:{minSeverity:o.getLiteralValue()}}:{advisor:{unreadable:!0}}},A=new Map([["advisor",{advisor:{unreadable:!0}}],["remote",{unreadable:!0}],["target",{unreadable:!0}]]),L=(t,i)=>{if(r.isGetAccessorDeclaration(t)||r.isMethodDeclaration(t))return A.get(u(t))??{};if(!r.isPropertyAssignment(t)&&!r.isShorthandPropertyAssignment(t))return{};const e=u(t);if(e==="advisor")return y(c(t,i),i);if(e!=="target"&&e!=="remote")return{};const s=c(t,i);return s===void 0?{unreadable:!0}:e==="target"?r.isStringLiteral(s)?{target:s.getLiteralValue()}:{unreadable:!0}:r.isTrueLiteral(s)||r.isFalseLiteral(s)?{remote:s.getLiteralValue()}:r.isObjectLiteralExpression(s)?{remote:!0}:{unreadable:!0}},F=t=>{const i=f(t);if(i===void 0)return{};let e;try{e=v(i,"utf8")}catch{return{unreadable:!0}}const l=new S({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}).createSourceFile(b(i),e,{overwrite:!0}),n=P(l);if(n===void 0)return{unreadable:!0};if(n.getProperties().some(a=>r.isSpreadAssignment(a)))return n.getProperties().some(d=>!r.isSpreadAssignment(d)&&u(d)==="advisor")?{advisor:{unreadable:!0},unreadable:!0}:{unreadable:!0};let o={};for(const a of n.getProperties())o={...o,...L(a,l)};return o};export{h as PROJECT_CONFIG_FILENAMES,f as findProjectConfigFile,D as loadProjectConfig,F as readProjectConfigLiterals};
@@ -0,0 +1 @@
1
+ import{existsSync as g}from"node:fs";import{join as p}from"node:path";import{LunoraError as l}from"@lunora/errors";import{queueDefaultName as f,queueBindingName as y}from"@lunora/queue";import{SyntaxKind as h,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{findObjectProperty as m,stringPropertyFor as b}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const q="queues.ts",N=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineQueue";for(const e of t.getDeclarations())if(s.isImportSpecifier(e))return e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/queue"?!1:e.getNameNode().getText()==="defineQueue";return!1},d=b("queue"),w=(r,t,e)=>{if(s.isNumericLiteral(r))return r.getLiteralValue();throw a(r,`queue "${t}": \`${e}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},E=(r,t)=>{const e=m(r,"name");if(!e||!s.isPropertyAssignment(e))return;const n=d(e.getInitializerOrThrow(),t,"name");if(n.length===0)throw a(e,`queue "${t}": \`name\` must be a non-empty string when provided`);return n},P=(r,t)=>{const e=r.getArguments()[0];if(!e||!s.isObjectLiteralExpression(e))throw a(r,`queue "${t}": defineQueue must be passed an inline object literal`);const n={bindingName:y(t),exportName:t,mode:"push",name:E(e,t)??f(t),tuning:{}},i=m(e,"mode");if(i&&s.isPropertyAssignment(i)){const o=d(i.getInitializerOrThrow(),t,"mode");if(o!=="push"&&o!=="pull")throw a(i,`queue "${t}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(o)})`);n.mode=o}const u=m(e,"deadLetterQueue");u&&s.isPropertyAssignment(u)&&(n.tuning.deadLetterQueue=d(u.getInitializerOrThrow(),t,"deadLetterQueue"));for(const o of["maxBatchSize","maxBatchTimeout","maxRetries","retryDelay"]){const c=m(e,o);c&&s.isPropertyAssignment(c)&&(n.tuning[o]=w(c.getInitializerOrThrow(),t,o))}return n},I=r=>{const t=[];for(const e of r.getVariableDeclarations()){if(!e.isExported())continue;const n=e.getInitializer();if(n?.getKind()!==h.CallExpression)continue;const i=n,u=i.getExpression();if(!s.isIdentifier(u)||!N(u))continue;const o=e.getNameNode();if(!s.isIdentifier(o))throw a(o,"defineQueue exports must be plain named exports (no destructuring)");t.push(P(i,o.getText()))}return t},Q=r=>{const t=new Map,e=new Map;for(const n of r){const i=t.get(n.name);if(i!==void 0)throw new l("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${n.name}": produced by both "${i}" and "${n.exportName}". Deployed queue names must be unique across the project.`,{status:500});t.set(n.name,n.exportName);const u=e.get(n.bindingName);if(u!==void 0)throw new l("DUPLICATE_QUEUE_BINDING",`Duplicate queue binding "${n.bindingName}": produced by both "${u}" and "${n.exportName}". Queue export names must yield unique binding names.`,{status:500});e.set(n.bindingName,n.exportName)}},U=(r,t)=>{const e=p(t,q);if(!g(e))return[];const n=r.getSourceFile(e)??r.addSourceFileAtPath(e),i=I(n);return i.sort((u,o)=>u.exportName.localeCompare(o.exportName)),Q(i),i};export{q as QUEUES_FILENAME,U as discoverQueues};
@@ -0,0 +1,9 @@
1
+ import{existsSync as w,mkdirSync as Rs,readFileSync as $t,writeFileSync as Ls,rmSync as Ds}from"node:fs";import{join as y,dirname as oe}from"node:path";import{performance as Pe}from"node:perf_hooks";import{runAdvisor as ks}from"@lunora/advisor";import{LunoraError as K}from"@lunora/errors";import{SyntaxKind as l,Node as o,VariableDeclarationKind as Ms,Project as dt}from"ts-morph";import{serializeSchemaSnapshot as Ks}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{toAdvisorContext as _s}from"./formatAdvisories-DwmUKYuc.mjs";import{readProjectConfigLiterals as zs}from"./PROJECT_CONFIG_FILENAMES-DfD2MHzr.mjs";import{s as $s}from"./paths-C-9fwEgQ.mjs";import{C as ae,o as Ut,j as Us,f as qs,k as Bs,b as Vs,c as Ws,m as js,e as Hs,p as Gs,d as Ys,i as Qs,l as Xs,g as Zs,q as Js,n as en,a as tn,h as sn}from"./emit-6YJU3YbV.mjs";import{isD1GlobalTable as qt,isHyperdriveGlobalTable as Bt}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as nn}from"./AGENTS_FILENAME-CXktfidB.mjs";import{discoverContainers as rn}from"./CONTAINERS_FILENAME-CtYUTuyn.mjs";import on from"./discoverCrons-CV2EZ_vn.mjs";import{diagnosticAt as ge}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as pe}from"./module-specifiers-WF8iAydP.mjs";import{listLunoraSourceFiles as p,bindingKeyName as Q,propertyKeyName as E,unwrapExpression as X,listSecurityScanFiles as ke,objectLiteralFromCallbackBody as Vt,propertyInitializer as b,lunoraRelativePath as x,collectCallRows as F,findObjectProperty as C,collectSecurityCallRows as an,limitNameOf as Wt,optionsObjectLiteral as jt,isContextIdentifier as Ce,handlerOf as cn,isDatabaseAccessor as _,readTargetOf as Ht,enclosingExportName as ln}from"./listLunoraSourceFiles-vjwjgpjd.mjs";import un from"./readPackageDependencies-C6h6FZuP.mjs";import{discoverQueues as dn}from"./QUEUES_FILENAME-BdgYKMU9.mjs";import{discoverSandboxUsage as fn}from"./discoverSandboxUsage-5WJ5s2sM.mjs";import gn from"./discoverStorageRulesMetadata-Bj6gg_lr.mjs";import{a as A,c as z,d as Gt,e as pn}from"./classify-procedure-call-CZU6n3yF.mjs";import{discoverWorkflows as mn}from"./WORKFLOWS_FILENAME-B6GW6JVZ.mjs";import{gatePlatformFeatures as hn,resolveCodegenTarget as vn,readTargetDiagnostics as xn}from"./DEFAULT_TARGET-CwlCMxUf.mjs";import{i as k,a as U,e as S,r as En,b as Sn,s as me,c as yn,f as An,d as bn}from"./queries-C8MF4jMB.mjs";import{r as he,s as Nn}from"./parse-validator-2u-Io0i5.mjs";import Pn from"./discoverAuthApiCalls-GNVuIrUo.mjs";import{i as wn,a as In,e as Tn,b as Cn,d as Fn,c as On}from"./unwrap-handler-return-C1OS0xP8.mjs";import Rn from"./discoverFunctions-Bk10Q2Zl.mjs";import Ln from"./discoverHttpRoutes-DJ-y2q50.mjs";import Dn from"./discoverHyperdriveCalls-C5he04zb.mjs";import kn from"./discoverInserts-gOn4B3o0.mjs";import{m as Me,a as le,s as Yt,d as Mn}from"./index-BGHtJQPU.mjs";import{e as Qt}from"./exported-procedure-chains-DhKcj-hK.mjs";import Kn from"./discoverMigrations-DTv9qRcf.mjs";import{MUTATORS_FILENAME as _n,isDefineMutatorCallee as zn,discoverMutators as $n}from"./MUTATORS_FILENAME-DCsa5Ma-.mjs";import Un from"./discoverNondeterministicCalls-CWAlKa4g.mjs";import{discoverNotifyConfig as qn,discoverNotifyCalls as Bn}from"./NOTIFY_FILENAME-D67sEwVX.mjs";import Vn from"./discoverR2sqlCalls-BkoDbcXj.mjs";import Wn from"./discoverRlsProcedures-CsbCosUT.mjs";import jn from"./discoverRlsMetadata-Cc-eoo9M.mjs";import Hn from"./discoverSchema-DvQyqT4W.mjs";import{secretKindOf as Gn,redact as Yn,isHeuristicSecretKind as Qn,isSecretishName as Xn}from"./redact-Cy14LEnc.mjs";import{discoverShapes as Zn}from"./SHAPES_FILENAME-DTGoT04E.mjs";import{emitApp as Jn}from"./emitApp-BewH-Jfe.mjs";import{buildOpenApiDocument as er,emitOpenApiModule as tr}from"./buildOpenApiDocument-D1dd4rBh.mjs";import{buildOpenRpcDocument as sr,emitOpenRpcModule as nr}from"./OPENRPC_VERSION-DAxS0CaZ.mjs";import{buildSchemaSnapshot as rr}from"./SchemaSnapshotParseError-lUWe6lPo.mjs";const ft={error:"ERROR",info:"INFO",warn:"WARN"},gt={ERROR:2,INFO:0,WARN:1},ir=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"}),or=(e,t)=>{const{advisor:s}=zs(e);if(s===void 0||s.minSeverity===void 0&&s.unreadable!==!0)return[...t];const{minSeverity:n}=s,i=n!==void 0&&Object.hasOwn(ft,n)?ft[n]:void 0;return i===void 0?[...t,ir(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(r=>gt[r.level]>=gt[i])},pt=(e,t="api")=>{const s=new Map;for(const n of e){const i=$s(n),r=s.get(i);if(r===void 0){s.set(i,n);continue}if(r!==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 K("INTERNAL",`@lunora/codegen: "${r}" 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})}}},ar=(e,t={})=>{const{hasVectors:s=!0,scheduler:n=!1,storage:i=!1,usage:r}=t,a=[];e.tables.some(c=>qt(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=>Bt(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 r===void 0?[]:ae)c.requiredPackage!==void 0&&r?.[c.key]===!0&&a.push({name:c.requiredPackage,reason:`\`ctx.${c.contextProperty??c.key}\` usage makes \`_generated/\` import \`${c.moduleSpecifier}\``});return a.filter((c,u)=>a.findIndex(d=>d.name===c.name)===u)},cr=(e,t,s={})=>{if(t===void 0)return;const n=ar(e,s).filter(r=>!t.has(r.name));if(n.length===0)return;const i=n.map(r=>` - ${r.name} — ${r.reason}`).join(`
2
+ `);throw new K("INTERNAL",`@lunora/codegen: this schema's generated code imports packages the project does not declare:
3
+ ${i}
4
+
5
+ Install them with your package manager, then re-run codegen.`)},lr="env.ts",ur=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineEnv";for(const s of t.getDeclarations())if(o.isImportSpecifier(s))return pe(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineEnv":!1;return!1},dr=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!o.isNamespaceImport(s))continue;const n=s.getFirstAncestorByKind(l.ImportDeclaration);return n!==void 0&&pe(n.getModuleSpecifierValue())}return!1},fr=e=>{if(o.isIdentifier(e))return ur(e);if(o.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineEnv"&&o.isIdentifier(t)&&dr(t)}return!1},gr=e=>{const t=[];for(const s of e.getVariableDeclarations()){if(!s.isExported())continue;const n=s.getInitializer();if(n?.getKind()!==l.CallExpression||!fr(n.getExpression()))continue;const r=s.getNameNode();if(!o.isIdentifier(r))throw ge(r,"defineEnv exports must be plain named exports (no destructuring)");t.push({exportName:r.getText()})}return t},pr=(e,t)=>{const s=y(t,lr);if(!w(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),i=gr(n);if(i.length!==0){if(i.length>1)throw ge(n,`lunora/env.ts declares ${i.length.toString()} defineEnv() contracts (${i.map(r=>r.exportName).join(", ")}); exactly one is allowed`);return i[0]}},mt="ctx",Xt=e=>{const t=new Set,s=new Set([mt]),n=r=>{if(o.isObjectBindingPattern(r))for(const a of r.getElements()){const c=Q(a);c&&t.add(c)}};for(const r of e.getDescendantsOfKind(l.BindingElement)){if(Q(r)!==mt)continue;const a=r.getNameNode();o.isIdentifier(a)?s.add(a.getText()):n(a)}const i=r=>o.isIdentifier(r)&&s.has(r.getText());for(const r of e.getDescendantsOfKind(l.PropertyAccessExpression))i(r.getExpression())&&t.add(r.getName());for(const r of e.getDescendantsOfKind(l.VariableDeclaration)){const a=r.getInitializer();a!==void 0&&i(a)&&n(r.getNameNode())}return t},mr=(e,t)=>{const s=Object.fromEntries(ae.map(n=>[n.key,!1]));for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=new Set(i.getImportDeclarations().map(c=>c.getModuleSpecifierValue())),a=Xt(i);for(const c of ae)if(!s[c.key]){if(r.has(c.moduleSpecifier)){s[c.key]=!0;continue}c.contextProperty!==void 0&&a.has(c.contextProperty)&&(s[c.key]=!0)}if(ae.every(c=>s[c.key]))break}return s},Zt="identity.ts",hr=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineIdentity";for(const s of t.getDeclarations())if(o.isImportSpecifier(s))return pe(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineIdentity":!1;return!1},vr=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!o.isNamespaceImport(s))continue;const n=s.getFirstAncestorByKind(l.ImportDeclaration);return n!==void 0&&pe(n.getModuleSpecifierValue())}return!1},xr=e=>{if(o.isIdentifier(e))return hr(e);if(o.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineIdentity"&&o.isIdentifier(t)&&vr(t)}return!1},Er=e=>{const t=[];for(const s of e.getVariableDeclarations()){if(!s.isExported())continue;const n=s.getInitializer();if(n?.getKind()!==l.CallExpression||!xr(n.getExpression()))continue;const r=s.getNameNode();if(!o.isIdentifier(r))throw ge(r,"defineIdentity exports must be plain named exports (no destructuring)");t.push({exportName:r.getText()})}return t},Sr=(e,t)=>{const s=y(t,Zt);if(!w(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),i=Er(n);if(i.length!==0){if(i.length>1)throw ge(n,`lunora/identity.ts declares ${i.length.toString()} defineIdentity() contracts (${i.map(r=>r.exportName).join(", ")}); exactly one is allowed`);return i[0]}},yr=(e,t)=>{const s=X(t);if(s===void 0||!o.isIdentifier(s))return s;const n=s.getText();return X(e.getDescendantsOfKind(l.VariableDeclaration).find(i=>i.getName()===n)?.getInitializer())},Ar=e=>e!==void 0&&o.isObjectLiteralExpression(e)&&e.getProperties().some(t=>{if(o.isShorthandPropertyAssignment(t))return E(t)==="durable";if(!o.isPropertyAssignment(t)||E(t)!=="durable")return!1;const s=t.getInitializer();return s===void 0||X(s)?.getText()!=="false"}),br=(e,t)=>{const s={durableStreams:!1,secrets:!1};for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);if(s.secrets||(s.secrets=Xt(i).has("secrets")),s.durableStreams||(s.durableStreams=i.getDescendantsOfKind(l.CallExpression).some(r=>{const a=r.getExpression();return(o.isPropertyAccessExpression(a)?a.getName():a.getText())==="stream"&&r.getArguments().some(u=>Ar(yr(i,u)))})),s.durableStreams&&s.secrets)break}return s},Nr="createWorker",Pr="extend",ht=e=>e!==void 0&&(o.isStringLiteral(e)||o.isNoSubstitutionTemplateLiteral(e))?e.getLiteralValue():void 0,vt=e=>{const t=[],s=ht(b(e,"backupCron"));s!==void 0&&t.push(s);const n=b(e,"crons");if(n===void 0||!o.isObjectLiteralExpression(n))return t;for(const i of n.getProperties()){if(!o.isPropertyAssignment(i)&&!o.isMethodDeclaration(i))continue;const r=ht(i.getNameNode());r!==void 0&&t.push(r)}return t},wr=e=>{const t=A(e.getExpression()),[s]=e.getArguments();if(s===void 0)return[];if(t===Nr)return o.isObjectLiteralExpression(s)?vt(s):[];if(t!==Pr||!(o.isArrowFunction(s)||o.isFunctionExpression(s)))return[];const n=Vt(s.getBody());return n===void 0?[]:vt(n)},Ir=(e,t)=>{const s=[];for(const{filePath:n}of ke(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const r of i.getDescendantsOfKind(l.CallExpression))s.push(...wr(r))}return[...new Set(s)]},Jt=e=>{if(e.kind==="id")return e.tableName;if(!(e.kind!=="array"&&e.kind!=="optional"))return e.inner===void 0?void 0:Jt(e.inner)},Tr=e=>{const t=new Set(e.tables.map(s=>s.name));return e.tables.some(s=>Object.values(s.shape).some(n=>{const i=Jt(n);return i!==void 0&&t.has(i)}))},Cr=(e,t)=>{const s=new Map,n=new Map,i=new Map;for(const r of e)s.set(r.name,`workflow "${r.exportName}"`),n.set(r.bindingName,`workflow "${r.exportName}"`),i.set(r.className,`workflow "${r.exportName}"`);for(const r of t){const a=s.get(r.name);if(a!==void 0)throw new K("DUPLICATE_WORKFLOW_NAME",`Duplicate deployed name "${r.name}": produced by both ${a} and agent "${r.exportName}". Workflow and agent names share the same wrangler workflows[] array and must be unique together.`,{status:500});const c=n.get(r.bindingName);if(c!==void 0)throw new K("DUPLICATE_WORKFLOW_BINDING",`Duplicate binding "${r.bindingName}": produced by both ${c} and agent "${r.exportName}". Workflow and agent bindings share the same wrangler workflows[] array and must be unique together.`,{status:500});const u=i.get(r.className);if(u!==void 0)throw new K("DUPLICATE_WORKFLOW_CLASS",`Duplicate generated class "${r.className}": produced by both ${u} and agent "${r.exportName}". Workflow and agent export names must yield unique generated class names.`,{status:500})}},Fr=e=>{const{lunoraDirectory:t,project:s,projectRoot:n,schema:i}=e,r=Sr(s,t),a=pr(s,t),c=mn(s,t),u=dn(s,t),d=nn(s,t);Cr(c,d);const m=rn(s,t),h=gn(s,t),R=on(s,t,c,d),M=Ir(s,t),g=br(s,t),I=fn(s,t),N=mr(s,t);N.browser=N.browser||I.usesSandboxBrowser;const O=hn(N,vn(n,e.target),{agents:d.length>0,commitOrderedTables:i.tables.some(P=>P.commitOrdered===!0),cronTriggers:R.length>0,crossShardFanout:i.tables.some(P=>typeof P.shardMode=="object"),durableStreams:g.durableStreams,globalTables:i.tables.some(P=>P.shardMode==="global"),queues:u.length>0,relationGraph:Tr(i),secrets:g.secrets,vectorStore:i.vectorIndexes.length>0}),v=O.usage,D=O.signals.vectorStore!==!1,q=un(n),H=q??new Set,ee=H.has("lunorash");cr(i,q,{hasVectors:D,scheduler:v.scheduler||R.length>0,storage:v.storage||h.rules.length>0||Object.keys(Ut(i)).length>0,usage:v});const $=w(y(t,"flags.ts")),L=w(y(t,"notify.ts"));return{agents:d,containers:m,crons:R,dataModelContent:qs(i),declaredDependencies:q,dependencies:H,entryCronTriggers:M,env:a,featureUsage:v,hasFlags:$,hasNotify:L,identity:r,platformGate:{...O,diagnostics:[...xn(n,e.target),...O.diagnostics]},queues:u,serverContent:Us({agents:d,containers:m,env:a,hasAccessFacade:v.access,hasAi:v.ai,hasAnalytics:v.analytics,hasBrowser:v.browser,hasVectors:D,hasFlags:$,hasHyperdrive:v.hyperdrive,hasImages:v.images,hasKv:v.kv,hasNotify:L,hasPayments:v.payments,hasPipelines:v.pipelines,hasR2sql:v.r2sql,hasX402:v.x402,identity:r,queues:u,schema:i,storageRuleBuckets:h.rules.map(P=>P.bucket),useUmbrella:ee,workflows:c}),storageRulesMetadata:h,usesSandbox:I.usesSandboxBrowser||I.usesSandboxContainer||I.usesSandboxFs,useUmbrella:ee,workflows:c}},es=new Set(["delete","get","head","options","patch","post","put"]),Or=new Set(["handler","stream"]),Rr=/\/(?:_|admin|internal|superuser|sudo|root|debug)/iu,xt=new Set(["ADMIN_TOKEN","adminToken","assertAdmin","assertAuth","auth","Authorization","getSession","identity","isAdmin","requireAdmin","requireAuth","requireRole","verifyAdmin"]),Lr=e=>{if(!o.isCallExpression(e))return;const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||!es.has(t.getName()))return;const s=t.getExpression();if(!o.isIdentifier(s)||s.getText()!=="httpRoute")return;const n=e.getArguments()[0];if(!(!n||!o.isStringLiteral(n)))return{method:t.getName().toUpperCase(),path:n.getLiteralValue()}},Dr=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t))return;let s=t.getExpression();for(;o.isCallExpression(s);){const n=s.getExpression();if(!o.isPropertyAccessExpression(n)||es.has(n.getName()))break;s=n.getExpression()}return Lr(s)},kr=e=>{for(const t of e.getDescendantsOfKind(l.PropertyAccessExpression))if(xt.has(t.getName()))return!0;for(const t of e.getDescendantsOfKind(l.CallExpression)){const s=t.getExpression();if(o.isIdentifier(s)&&xt.has(s.getText()))return!0}return!1},Mr=(e,t)=>{const s=e.getInitializer();if(!s||!o.isCallExpression(s))return;const n=s.getExpression();if(!o.isPropertyAccessExpression(n)||!Or.has(n.getName()))return;const i=Dr(s);if(!i||!Rr.test(i.path))return;const r=s.getArguments()[0],a=r!==void 0&&(o.isArrowFunction(r)||o.isFunctionExpression(r))&&kr(r);return{exportName:e.getName(),file:t,method:i.method,path:i.path,usesGuard:a}},Kr=(e,t)=>{const s=[];for(const n of e.getVariableStatements())if(n.isExported())for(const i of n.getDeclarations()){const r=Mr(i,t);r&&s.push(r)}return s},_r=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Kr(i,x(t,n)))}return s},zr=e=>!o.isPropertyAccessExpression(e)||e.getName()!=="run"?!1:e.getExpression().getText()==="ctx.ai",$r=(e,t)=>{if(!zr(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!k(s)||U(s)))return{exportName:S(e),file:t,line:e.getStartLineNumber()}},Ur=(e,t)=>F(e,t,$r),qr=new Set(["generateText","streamText"]),Br=new Set(["messages","prompt","system"]),Vr=[{methods:new Set(["delete","insert","insertManyUnsafe","patch","replace"]),prefixes:["context.db","ctx.db"]},{methods:new Set(["run","runAction","runMutation"]),prefixes:["context","ctx"]},{methods:new Set(["fetch"]),prefixes:["context","ctx"]},{methods:new Set(["queue","send"]),prefixes:["context.email","context.mail","ctx.email","ctx.mail"]}],Wr=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t))return;const s=t.getName(),n=t.getExpression().getText();for(const i of Vr)if(i.methods.has(s)&&i.prefixes.some(r=>n===r||n.startsWith(`${r}.`)))return`${n}.${s}`},jr=e=>{for(const t of e.getDescendantsOfKind(l.CallExpression)){const s=Wr(t);if(s!==void 0)return s}},Hr=e=>{const t=new Set,s=e.getFirstAncestor(r=>o.isArrowFunction(r)||o.isFunctionExpression(r)||o.isFunctionDeclaration(r)),[n]=s?.getParameters()??[],i=n?.getNameNode();if(i===void 0||!o.isObjectBindingPattern(i))return t;for(const r of i.getElements()){const a=Q(r),c=r.getNameNode();if(a==="args"&&o.isObjectBindingPattern(c))for(const u of c.getElements())t.add(u.getName())}return t},Gr=e=>{if(En(e))return!0;const t=Hr(e);return t.size===0?!1:e.getDescendantsOfKind(l.Identifier).some(s=>t.has(s.getText()))},Yr=e=>{for(const t of e.getProperties()){if(!o.isPropertyAssignment(t)||!Br.has(E(t)))continue;const s=t.getInitializer();if(s!==void 0&&Gr(s))return!0}return!1},Qr=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression)){const i=A(n.getExpression());if(i===void 0||!qr.has(i))continue;const[r]=n.getArguments();if(r===void 0||!o.isObjectLiteralExpression(r))continue;let a;for(const c of r.getDescendantsOfKind(l.CallExpression))if(A(c.getExpression())==="tool"&&(a=jr(c),a!==void 0))break;a!==void 0&&s.push({exportName:S(n),file:t,line:n.getStartLineNumber(),method:i,sideEffect:a,userInputDerived:Yr(r)})}return s},Xr=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Qr(i,x(t,n)))}return s},Zr=e=>{if(!o.isPropertyAccessExpression(e)||e.getName()!=="fetch")return!1;const t=e.getExpression();return o.isIdentifier(t)&&t.getText()==="ctx"},Jr=(e,t)=>{if(!Zr(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!k(s)))return{exportName:S(e),file:t,line:e.getStartLineNumber()}},ei=(e,t)=>F(e,t,Jr),Ke=(e,t=new Set)=>{if(t.has(e))return!0;t.add(e);try{return e.getProperties().some(s=>{if(!o.isSpreadAssignment(s))return!1;const n=he(s.getExpression());return n===void 0||Ke(n,t)})}finally{t.delete(e)}},ti=e=>{const t=e.getArguments()[0];if(!t||!o.isObjectLiteralExpression(t))return{objects:[],opaque:!0};const s=C(t,"args");if(!s)return{objects:[],opaque:!1};if(!o.isPropertyAssignment(s))return{objects:[],opaque:!0};const n=s.getInitializer(),i=n===void 0?void 0:he(n);return i===void 0?{objects:[],opaque:!0}:{objects:[i],opaque:Ke(i)}},si=e=>{const t=[];let s=!1,n=e;for(;o.isCallExpression(n);){const i=n.getExpression();if(!o.isPropertyAccessExpression(i))break;if(i.getName()==="input"){const r=n.getArguments()[0],a=r!==void 0&&o.isExpression(r)?he(r):void 0;a===void 0?s=!0:(t.push(a),s||=Ke(a))}n=i.getExpression()}return{objects:t,opaque:s}},_e=(e,t)=>t?si(t):ti(e),ts=(e,t)=>{if(t.has(e))return[];t.add(e);try{return e.getProperties().flatMap(s=>{if(o.isSpreadAssignment(s)){const n=he(s.getExpression());return n===void 0?[]:ts(n,t)}return o.isPropertyAssignment(s)||o.isShorthandPropertyAssignment(s)?[E(s)]:[]})}finally{t.delete(e)}},ni=e=>e.flatMap(t=>ts(t,new Set)),ri=new Set(["check","length","max"]),Fe=e=>{if(!o.isCallExpression(e))return;const t=e.getExpression();if(!(!o.isPropertyAccessExpression(t)||t.getExpression().getText()!=="v"))return t.getName()},ii=e=>[e,...e.getDescendants()].filter(t=>Fe(t)!==void 0),oi=e=>{let t=e;for(;;){const s=t.getParent();if(!s||!o.isPropertyAccessExpression(s)||s.getExpression()!==t)return!1;const n=s.getParent();if(!n||!o.isCallExpression(n)||n.getExpression()!==s)return!1;if(ri.has(s.getName()))return!0;t=n}},ai=e=>{const t=[],s=[];for(const n of e)for(const i of n.getProperties()){if(!o.isPropertyAssignment(i))continue;const r=i.getInitializer();if(!r)continue;const a=ii(r),c=E(i);a.some(u=>Fe(u)==="any")?t.push(c):a.some(u=>Fe(u)==="string"&&!oi(u))&&s.push(c)}return{anyArgs:t,unboundedStringArgs:s}},ci=(e,t)=>{const s=e.getInitializer();if(!s||!o.isCallExpression(s))return;const n=z(s);if(n?.visibility!=="public")return;const{objects:i}=_e(s,n.receiver),{anyArgs:r,unboundedStringArgs:a}=ai(i);if(!(r.length===0&&a.length===0))return{anyArgs:r,exportName:e.getName(),file:t,line:s.getStartLineNumber(),unboundedStringArgs:a}},li=(e,t)=>{const s=[];for(const n of e.getVariableStatements())if(n.isExported())for(const i of n.getDeclarations()){const r=ci(i,t);r&&s.push(r)}return s},ui=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...li(i,x(t,n)))}return s},we=e=>e?.getKind()===l.TrueKeyword,di=e=>e?.getKind()===l.FalseKeyword,fi=e=>e!==void 0&&o.isNumericLiteral(e)&&e.getLiteralValue()===0,gi=new Set(["lunoraAuthAdapter","lunoraD1Adapter"]),pi=e=>!e||!o.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>o.isCallExpression(t)&&A(t.getExpression())==="scim"),mi=e=>e!==void 0&&o.isCallExpression(e)&&gi.has(A(e.getExpression())??""),hi=e=>!e||!o.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>o.isStringLiteral(t)&&t.getLiteralText()==="*"),vi=e=>{const t=b(e,"advanced"),s=b(e,"emailAndPassword"),n=b(e,"session");return{analyzable:!0,disableCsrfCheck:we(b(t,"disableCSRFCheck")),emailPasswordEnabled:we(b(s,"enabled")),requireEmailVerification:we(b(s,"requireEmailVerification")),scimOnNonTransactionalAdapter:pi(b(e,"plugins"))&&mi(b(e,"database")),secureCookiesDisabled:di(b(t,"useSecureCookies")),sessionFreshAgeZero:fi(b(n,"freshAge")),trustedOriginsWildcard:hi(b(e,"trustedOrigins"))}},xi=()=>({analyzable:!1,disableCsrfCheck:!1,emailPasswordEnabled:!1,requireEmailVerification:!1,scimOnNonTransactionalAdapter:!1,secureCookiesDisabled:!1,sessionFreshAgeZero:!1,trustedOriginsWildcard:!1}),Ei=(e,t)=>{if(A(e.getExpression())!=="createAuth")return;const s=e.getArguments()[0],n=s!==void 0&&o.isObjectLiteralExpression(s)&&s.getProperties().some(r=>o.isSpreadAssignment(r)),i=s!==void 0&&o.isObjectLiteralExpression(s)&&!n?vi(s):xi();return{exportName:S(e),file:t,line:e.getStartLineNumber(),...i}},Si=(e,t)=>an(e,t,Ei),yi=(e,t)=>{if(!o.isPropertyAccessExpression(e))return;const s=e.getName();if(t.methods.has(s))return t.matchReceiver(e.getExpression().getText())?s:void 0},Ai=(e,t,s)=>{const n=yi(e.getExpression(),s);if(n===void 0)return;const i=e.getArguments()[s.argIndex];if(!(!i||!k(i)||U(i))&&!(s.requireUnmodifiedReach===!0&&!Sn(i)))return{exportName:S(e),file:t,line:e.getStartLineNumber(),method:n}},bi=(e,t,s)=>{const n=[];for(const i of e.getDescendantsOfKind(l.CallExpression)){const r=Ai(i,t,s);r&&n.push(r)}return n},ve=(e,t,s)=>{const n=[];for(const i of p(t)){const r=e.getSourceFile(i)??e.addSourceFileAtPath(i);n.push(...bi(r,x(t,i),s))}return n},Ni=new Set(["content","pdf","scrape","screenshot"]),Pi=(e,t)=>ve(e,t,{argIndex:0,matchReceiver:s=>s==="ctx.browser",methods:Ni}),wi=new Set(["createBrowser","createInboundEmailHandler","createPayment"]),Ii=new Set(["RateLimiter"]),Ti=new Set(["extend"]),Et="lunora",Ci=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],ss=e=>{const t=[],s=[];let n=!1;for(const i of e.getProperties()){if(o.isSpreadAssignment(i)){n=!0;continue}if(o.isPropertyAssignment(i)){const r=E(i);t.push(r),i.getInitializer()?.getKind()===l.TrueKeyword&&s.push(r);continue}(o.isShorthandPropertyAssignment(i)||o.isMethodDeclaration(i))&&t.push(E(i))}return{analyzable:!n,presentKeys:t,trueKeys:s}},Oe=e=>e&&o.isObjectLiteralExpression(e)?ss(e):{analyzable:!1,presentKeys:[],trueKeys:[]},Fi=e=>{const t=e&&(o.isArrowFunction(e)||o.isFunctionExpression(e))?e:void 0,s=t&&Vt(t.getBody());return s?ss(s):{analyzable:!1,presentKeys:[],trueKeys:[]}},Oi=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression)){const i=A(n.getExpression());i!==void 0&&(wi.has(i)?s.push({callee:i,file:t,line:n.getStartLineNumber(),...Oe(n.getArguments()[0])}):Ti.has(i)&&s.push({callee:i,file:t,line:n.getStartLineNumber(),...Fi(n.getArguments()[0])}))}for(const n of e.getDescendantsOfKind(l.NewExpression)){const i=A(n.getExpression());i===void 0||!Ii.has(i)||s.push({callee:i,file:t,line:n.getStartLineNumber(),...Oe(n.getArguments()[0])})}return s},Ri=(e,t)=>{for(const s of Ci){const n=y(t,s);if(!w(n))continue;const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=[];for(const a of i.getDescendantsOfKind(l.CallExpression))A(a.getExpression())===Et&&r.push({callee:Et,file:s,line:a.getStartLineNumber(),...Oe(a.getArguments()[0])});return r}return[]},Li=(e,t)=>{const s=[];for(const{displayPath:n,filePath:i}of ke(t)){const r=e.getSourceFile(i)??e.addSourceFileAtPath(i);s.push(...Oi(r,n))}return s.push(...Ri(e,oe(t))),s},St="ctx.containers.",Di=e=>{if(!e.startsWith(St))return!1;const t=e.slice(St.length);return t.length>0&&!t.includes(".")},ki=(e,t)=>ve(e,t,{argIndex:0,matchReceiver:Di,methods:new Set(["get"])}),Mi=new Set(["allow","deny","setAllowed"]),Ki=e=>{const t=e.getArguments()[0];if(!t||!o.isObjectLiteralExpression(t))return!1;const s=C(t,"enableInternet");return s!==void 0&&o.isPropertyAssignment(s)&&o.isTrueLiteral(s.getInitializerOrThrow())},_i=(e,t)=>{const s=e.getExpression();if(!(!o.isPropertyAccessExpression(s)||s.getName()!=="start"||!Ki(e)))return{detail:"enableInternet: true",exportName:S(e),file:t,kind:"enable_internet",line:e.getStartLineNumber()}},zi=(e,t)=>{const s=e.getExpression();if(!o.isPropertyAccessExpression(s)||!Mi.has(s.getName()))return;const n=s.getExpression();if(!(!o.isPropertyAccessExpression(n)||n.getName()!=="egress"))return{detail:s.getName(),exportName:S(e),file:t,kind:"egress_relaxation",line:e.getStartLineNumber()}},$i=(e,t)=>_i(e,t)??zi(e,t),Ui=(e,t)=>F(e,t,$i),qi=new Set(["defineExportSink","r2Sink","webhookExportSink"]),Bi=e=>{const t=e.getExpression();if(!o.isIdentifier(t))return;const s=t.getText();return qi.has(s)?s:void 0},Vi=e=>{const t=[],s=[];for(const n of e.getProperties()){if(o.isSpreadAssignment(n))return{analyzable:!1,emptyKeys:[],presentKeys:[]};if(o.isPropertyAssignment(n)){const i=E(n);t.push(i);const r=n.getInitializer();r&&o.isStringLiteral(r)&&r.getLiteralText()===""&&s.push(i);continue}(o.isShorthandPropertyAssignment(n)||o.isMethodDeclaration(n)||o.isGetAccessorDeclaration(n))&&t.push(E(n))}return{analyzable:!0,emptyKeys:s,presentKeys:t}},Wi=(e,t)=>{const s=[];for(const{displayPath:n,filePath:i}of ke(t)){const r=e.getSourceFile(i)??e.addSourceFileAtPath(i);for(const a of r.getDescendantsOfKind(l.CallExpression)){const c=Bi(a);if(c===void 0)continue;const u=a.getArguments()[0],d=u&&o.isObjectLiteralExpression(u)?Vi(u):{analyzable:!1,emptyKeys:[],presentKeys:[]};s.push({analyzable:d.analyzable,emptyKeys:d.emptyKeys,factory:c,file:n,line:a.getStartLineNumber(),presentKeys:d.presentKeys})}}return s},ji=new Map([["dbRateLimit",2],["rateLimit",2],["verifyTurnstileMiddleware",0]]),Hi=new Set(["dbRateLimit","rateLimit"]),Gi=e=>{const t=jt(e);if(!t)return!1;const s=C(t,"failOpen");return s!==void 0&&o.isPropertyAssignment(s)&&s.getInitializer()?.getKind()===l.TrueKeyword},Yi=(e,t)=>{const s=A(e.getExpression());if(s===void 0)return;const n=ji.get(s);if(n!==void 0)return{callee:s,exportName:S(e),failOpen:Gi(e.getArguments()[n]),file:t,limitName:Hi.has(s)?Wt(e):"",line:e.getStartLineNumber()}},Qi=(e,t)=>F(e,t,Yi),Xi=new Set(["boolean","number","object","string"]),Zi=e=>{const t=e.getName();if(!Xi.has(t))return;const s=e.getExpression();if(!o.isPropertyAccessExpression(s))return;if(s.getName()==="flags"&&Ce(s.getExpression()))return t;const n=s.getExpression();if(s.getName()==="details"&&o.isPropertyAccessExpression(n)&&n.getName()==="flags"&&Ce(n.getExpression()))return t},Ji=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t))return;const s=Zi(t);if(s===void 0)return;const n=e.getArguments()[0];if(!n||!(o.isStringLiteral(n)||o.isNoSubstitutionTemplateLiteral(n)))return;const i=n.getLiteralValue();return i.length>0?{key:i,type:s}:void 0},eo=(e,t)=>{const s=new Map;for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const r of i.getDescendantsOfKind(l.CallExpression)){const a=Ji(r);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))},to=e=>{const t=e.getInitializer();if(!t||!o.isCallExpression(t))return;const s=z(t);if(s?.kind!=="query")return;const n=cn(t,s.receiver);return n?{exportName:e.getName(),handler:n}:void 0},yt=e=>{const t=e.getParent();return t&&o.isPropertyAccessExpression(t)&&t.getExpression()===e?t:void 0},so=e=>{if(!o.isPropertyAccessExpression(e)||e.getName()!=="flags")return;const t=e.getExpression();if(!o.isIdentifier(t)||t.getText()!=="ctx")return;const s=yt(e);if(!s)return"ctx.flags";if(s.getName()==="details"){const n=yt(s);return n?`ctx.flags.details.${n.getName()}`:"ctx.flags.details"}return`ctx.flags.${s.getName()}`},no=(e,t)=>{const s=[];for(const n of e.handler.getDescendantsOfKind(l.PropertyAccessExpression)){const i=so(n);i!==void 0&&s.push({callee:i,exportName:e.exportName,file:t,line:n.getStartLineNumber()})}return s},ro=(e,t)=>{const s=[];for(const n of e.getVariableStatements())if(n.isExported())for(const i of n.getDeclarations()){const r=to(i);r&&s.push(...no(r,t))}return s},io=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...ro(i,x(t,n)))}return s},oo=e=>{if(!o.isPropertyAccessExpression(e)||e.getName()!=="boolean")return!1;const t=e.getExpression();return o.isPropertyAccessExpression(t)&&t.getName()==="flags"&&Ce(t.getExpression())},ao=e=>{if(e?.getKind()===l.TrueKeyword)return!0;if(e?.getKind()===l.FalseKeyword)return!1},co=(e,t)=>{if(!oo(e.getExpression()))return;const[s,n]=e.getArguments();if(!s||!(o.isStringLiteral(s)||o.isNoSubstitutionTemplateLiteral(s)))return;const i=s.getLiteralValue(),r=ao(n);if(!(i.length===0||r===void 0))return{defaultValue:r,exportName:S(e),file:t,key:i,line:e.getStartLineNumber()}},lo=(e,t)=>F(e,t,co),uo=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),r=i.getText(e);if(!r||r==="any"||r==="never"||wn(r))return;const a=e.getSourceFile().getFilePath();if(In(i,e,a)){const c=Tn(i,e,a,0,new Set);return c===void 0&&Cn(r),c}return r},fo=e=>{const t=e.getExpression();return o.isPropertyAccessExpression(t)&&t.getName()==="withGeoIndex"},go=e=>{const t=e.getArguments()[0];return t&&o.isStringLiteral(t)?t.getLiteralText():""},po=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=x(t,n);for(const a of i.getDescendantsOfKind(l.CallExpression))fo(a)&&s.push({file:r,indexName:go(a),line:a.getStartLineNumber()})}return s},Z=e=>e!==void 0&&(o.isArrowFunction(e)||o.isFunctionExpression(e))?e:void 0,ns=e=>{const t=e.getArguments()[0],s=Z(t);if(s!==void 0)return s;if(t===void 0||!o.isObjectLiteralExpression(t))return;const n=C(t,"handler");return n!==void 0&&o.isPropertyAssignment(n)?Z(n.getInitializer()):void 0},mo=new Set(["delete","get","head","options","patch","post","put"]),ho=new Set(["handler","stream"]),vo=new Set(["runAction","runMutation"]),xo=new Set(["delete","insert","insertManyUnsafe","patch","replace"]),J=(e,t)=>e!==void 0&&o.isIdentifier(e)&&e.getText()===t,rs=(e,t)=>{if(!(e===void 0||!o.isObjectBindingPattern(e))){for(const s of e.getElements())if(Q(s)===t){const i=s.getNameNode();return o.isIdentifier(i)?i.getText():void 0}}},At=(e,t)=>{const s=e.getParameters()[0]?.getNameNode();if(s!==void 0)return t?o.isIdentifier(s)?s.getText():void 0:rs(s,"ctx")},bt=(e,t)=>{const s=e.getParameters()[t?1:0]?.getNameNode();return t?s!==void 0&&o.isIdentifier(s)?s.getText():void 0:rs(s,"request")},Nt=(e,t)=>{const s=e.getBody(),n=s.getDescendantsOfKind(l.CallExpression);o.isCallExpression(s)&&n.unshift(s);for(const i of n){const r=i.getExpression();if(!o.isPropertyAccessExpression(r))continue;const a=r.getName(),c=r.getExpression();if(vo.has(a)&&J(c,t))return a;if(xo.has(a)&&o.isPropertyAccessExpression(c)&&c.getName()==="db"&&J(c.getExpression(),t))return`db.${a}`}},Pt=(e,t)=>{const s=e.getBody();for(const n of s.getDescendantsOfKind(l.PropertyAccessExpression))if(n.getName()==="auth"&&J(n.getExpression(),t))return!0;for(const n of s.getDescendantsOfKind(l.VariableDeclaration)){const i=n.getNameNode();if(!(!o.isObjectBindingPattern(i)||!J(n.getInitializer(),t))){for(const r of i.getElements())if(Q(r)==="auth")return!0}}return!1},Eo=/signature|hmac|digest|(?:^|[_-])sig(?:[_-]|$)/i,So=(e,t)=>{const s=e.getExpression();if(!o.isPropertyAccessExpression(s)||s.getName()!=="get"&&s.getName()!=="has")return!1;const n=s.getExpression();return o.isPropertyAccessExpression(n)&&n.getName()==="headers"&&J(n.getExpression(),t)},yo=e=>[...o.isStringLiteral(e)?[e.getLiteralText()]:[],...e.getDescendantsOfKind(l.StringLiteral).map(t=>t.getLiteralText())],is=(e,t)=>{const s=e.getVariableDeclaration(t)?.getInitializer();return s===void 0?[]:yo(s)},Ao=(e,t)=>{const s=e.getText();for(let n=e.getParent();n!==void 0;n=n.getParent()){if(!o.isArrowFunction(n)&&!o.isFunctionExpression(n)||!n.getParameters().some(c=>c.getName()===s))continue;const i=n.getParent();if(!o.isCallExpression(i))return[];const r=i.getExpression();if(!o.isPropertyAccessExpression(r))return[];const a=r.getExpression();return o.isIdentifier(a)?is(t,a.getText()):[]}return[]},bo=e=>{const t=e.getArguments()[0];if(t===void 0)return[];if(o.isStringLiteral(t))return[t.getLiteralText()];if(!o.isIdentifier(t))return[];const s=e.getSourceFile(),n=is(s,t.getText());return n.length>0?n:Ao(t,s)},wt=(e,t)=>{if(t===void 0)return!1;const s=e.getBody(),n=s.getDescendantsOfKind(l.CallExpression);return o.isCallExpression(s)&&n.unshift(s),n.some(i=>So(i,t)&&bo(i).some(r=>Eo.test(r)))},No=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||!ho.has(t.getName()))return;let s=t.getExpression();for(;o.isCallExpression(s);){const n=s.getExpression();if(!o.isPropertyAccessExpression(n))return;const i=n.getName();if(mo.has(i)){const r=n.getExpression();return o.isIdentifier(r)&&r.getText()==="httpRoute"?i.toUpperCase():void 0}s=n.getExpression()}},Po=(e,t)=>{const s=e.getExpression();if(o.isIdentifier(s)&&s.getText()==="httpAction"){const c=Z(e.getArguments()[0]),u=c&&At(c,!0);if(!c||u===void 0||wt(c,bt(c,!0)))return;const d=Nt(c,u);return d===void 0?void 0:{exportName:S(e),file:t,kind:"httpAction",line:e.getStartLineNumber(),readsAuth:Pt(c,u),sideEffect:d}}const n=No(e);if(n===void 0)return;const i=Z(e.getArguments()[0]),r=i&&At(i,!1);if(!i||r===void 0||wt(i,bt(i,!1)))return;const a=Nt(i,r);return a===void 0?void 0:{exportName:S(e),file:t,kind:"httpRoute",line:e.getStartLineNumber(),method:n,readsAuth:Pt(i,r),sideEffect:a}},wo=(e,t)=>F(e,t,Po),Io=new Set(["btoa","encodeURI","encodeURIComponent","isSafeHeaderValue","Number","parseFloat","parseInt"]),To=new Set(["append","set"]),os=e=>e!==void 0&&(o.isStringLiteral(e)||o.isNoSubstitutionTemplateLiteral(e))?e.getLiteralText():"",It=(e,t)=>(o.isCallExpression(e)?[e,...e.getDescendantsOfKind(l.CallExpression)]:e.getDescendantsOfKind(l.CallExpression)).some(n=>Io.has(A(n.getExpression())??"")&&An(n,t)),Co=(e,t)=>{if(It(e,t))return!0;const s=me(e);return s!==void 0&&It(s,t)},Re=(e,t)=>yn(e,t)&&!Co(e,t),Fo=e=>{if(o.isPropertyAccessExpression(e)&&e.getName()==="headers")return!0;const t=me(e);return t!==void 0&&o.isNewExpression(t)&&A(t.getExpression())==="Headers"},ue=e=>{if(e===void 0)return;if(o.isObjectLiteralExpression(e))return e;const t=me(e);return t!==void 0&&o.isObjectLiteralExpression(t)?t:void 0},ze=(e,t,s)=>{for(const n of e.getProperties())if(o.isPropertyAssignment(n)){const i=n.getInitializer();i!==void 0&&Re(i,s.requestName)&&s.rows.push({exportName:s.exportName,file:s.relativePath,headerName:os(n.getNameNode()),line:i.getStartLineNumber(),via:t})}else if(o.isShorthandPropertyAssignment(n)){const i=n.getNameNode();Re(i,s.requestName)&&s.rows.push({exportName:s.exportName,file:s.relativePath,headerName:E(n),line:i.getStartLineNumber(),via:t})}else if(o.isSpreadAssignment(n)){const i=ue(n.getExpression());i!==void 0&&ze(i,t,s)}},as=(e,t)=>{const s=ue(e);if(s===void 0)return;const n=C(s,"headers");if(n===void 0||!o.isPropertyAssignment(n))return;const i=ue(n.getInitializer());i!==void 0&&ze(i,"response-init",t)},Oo=(e,t)=>{const s=A(e.getExpression());if(s==="Response")as(e.getArguments()[1],t);else if(s==="Headers"){const n=ue(e.getArguments()[0]);n!==void 0&&ze(n,"headers-ctor",t)}},Ro=(e,t)=>{const s=e.getExpression();if(!o.isPropertyAccessExpression(s))return;const n=s.getName(),i=s.getExpression();if(n==="json"&&o.isIdentifier(i)&&i.getText()==="Response"){as(e.getArguments()[1],t);return}if(To.has(n)&&Fo(i)){const r=e.getArguments()[1];r!==void 0&&Re(r,t.requestName)&&t.rows.push({exportName:t.exportName,file:t.relativePath,headerName:os(e.getArguments()[0]),line:r.getStartLineNumber(),via:n==="set"?"headers-set":"headers-append"})}},Lo=(e,t)=>{for(const s of e.getDescendantsOfKind(l.NewExpression))Oo(s,t);for(const s of e.getDescendantsOfKind(l.CallExpression))Ro(s,t)},Do=(e,t)=>{const s=e.getExpression();if(!o.isIdentifier(s)||s.getText()!=="httpAction")return[];const n=Z(e.getArguments()[0]);if(n===void 0)return[];const i=n.getParameters()[1];if(i===void 0)return[];const r=i.getNameNode();if(!o.isIdentifier(r))return[];const a=[];return Lo(n,{exportName:S(e),relativePath:t,requestName:r.getText(),rows:a}),a},ko=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression))s.push(...Do(n,t));return s},Mo=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...ko(i,x(t,n)))}return s},Ko=new Set(["auth","context.auth","ctx.auth"]),_o="userId",zo=e=>{const t=new Set;for(const s of e.getProperties()){if(o.isSpreadAssignment(s))return;(o.isPropertyAssignment(s)||o.isShorthandPropertyAssignment(s)||o.isMethodDeclaration(s))&&t.add(E(s))}return t},$o=(e,t)=>{const s=y(t,Zt);if(!w(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const i of n.getDescendantsOfKind(l.CallExpression)){if(A(i.getExpression())!=="defineIdentity")continue;const[r]=i.getArguments();return r&&o.isObjectLiteralExpression(r)?zo(r):void 0}},Tt=e=>{if(!(e===void 0||!o.isPropertyAccessExpression(e)||e.getName()!=="identity"))return Ko.has(e.getExpression().getText())?e:void 0},Uo=e=>{if(o.isPropertyAccessExpression(e)&&Tt(e.getExpression())!==void 0)return e.getName();if(o.isElementAccessExpression(e)&&Tt(e.getExpression())!==void 0){const t=e.getArgumentExpression();return t&&o.isStringLiteral(t)?t.getLiteralValue():void 0}},qo=(e,t,s)=>{const n=[];for(const i of e.getDescendants()){const r=Uo(i);r!==void 0&&n.push({declared:r===_o||s.has(r),exportName:S(i),file:t,key:r,line:i.getStartLineNumber()})}return n},Bo=(e,t)=>{const s=$o(e,t);if(s===void 0)return[];const n=[];for(const i of p(t)){const r=e.getSourceFile(i)??e.addSourceFileAtPath(i);n.push(...qo(r,x(t,i),s))}return n},Vo=(e,t)=>{if(A(e.getExpression())!=="buildImageDeliveryUrl")return;const s=e.getArguments()[0];if(!s)return;const n=b(s,"key");if(!(!n||!k(n)||U(n)))return{exportName:S(e),file:t,line:e.getStartLineNumber()}},Wo=(e,t)=>F(e,t,Vo),jo=new Set(["delete","get","getRaw","getWithMetadata","put"]),Ho=(e,t,s=[])=>{const n=new Map(s.map(r=>[`${r.filePath}:${r.exportName}`,r.visibility]));return ve(e,t,{argIndex:0,matchReceiver:r=>r==="ctx.kv"||r.startsWith("ctx.kv."),methods:jo}).map(r=>{const a=n.get(`${r.file}:${r.exportName}`);return a===void 0?r:{...r,visibility:a}})},Go=new Set(["queue","send"]),Ct=new Set(["bcc","cc","to"]),Yo=e=>{if(!o.isPropertyAccessExpression(e))return;const t=e.getName();if(!Go.has(t))return;const s=e.getExpression().getText();return s==="ctx.mail"||s==="ctx.email"?t:void 0},Qo=e=>o.isObjectLiteralExpression(e)?e.getProperties().some(t=>{if(o.isShorthandPropertyAssignment(t)){const n=t.getNameNode();return Ct.has(E(t))&&k(n)&&!U(n)}if(!o.isPropertyAssignment(t)||!Ct.has(E(t)))return!1;const s=t.getInitializer();return s!==void 0&&k(s)&&!U(s)}):!1,Xo=(e,t)=>{const s=Yo(e.getExpression());if(s===void 0)return;const n=e.getArguments()[0];if(!(!n||!Qo(n)))return{exportName:S(e),file:t,line:e.getStartLineNumber(),method:s}},Zo=(e,t)=>F(e,t,Xo),Jo=e=>o.isPropertyAssignment(e)||o.isMethodDeclaration(e)||o.isGetAccessorDeclaration(e)?o.isComputedPropertyName(e.getNameNode()):!1,ea=e=>o.isPropertyAssignment(e)||o.isShorthandPropertyAssignment(e)||o.isMethodDeclaration(e)||o.isGetAccessorDeclaration(e)?Jo(e):!0,cs=(e,t=!1)=>{for(const s of e.getProperties()){if(ea(s))return!0;if(t)continue;if(!o.isPropertyAssignment(s))return!0;const n=s.getInitializer();if(!n||!o.isObjectLiteralExpression(n)||cs(n,!0))return!0}return!1},ta=(e,t)=>{for(const s of p(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const{receiver:i}of Qt(n))for(const r of Me(i)){const a=r.getArguments()[0];if(a!==void 0&&(!o.isObjectLiteralExpression(a)||cs(a)))return!0}}return!1},sa=e=>{const t=e.getArguments()[0];if(!t||!o.isObjectLiteralExpression(t))return[];const s=[];for(const n of t.getProperties()){const i=le(n);if(i===void 0||!o.isPropertyAssignment(n))continue;const r=n.getInitializer();if(!(!r||!o.isObjectLiteralExpression(r)))for(const a of r.getProperties()){const c=le(a);c!==void 0&&s.push({column:c,strategy:Yt(a),table:i})}}return s},na=(e,t)=>{const s=new Map;for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const{receiver:r}of Qt(i))for(const a of Me(r))for(const c of sa(a)){const u=`${c.table}\0${c.column}`;s.has(u)||s.set(u,c)}}return{columns:[...s.values()]}},ra=(e,t,s)=>{const n=e.getArguments()[0];if(!n||!o.isObjectLiteralExpression(n))return[];const i=[];for(const r of n.getProperties()){const a=le(r);if(a===void 0||!o.isPropertyAssignment(r))continue;const c=r.getInitializer();if(!(!c||!o.isObjectLiteralExpression(c)))for(const u of c.getProperties()){const d=le(u);if(d===void 0)continue;const m=Yt(u);m!=="custom"&&i.push({column:d,exportName:t,file:s,line:u.getStartLineNumber(),strategy:m,table:a})}}return i},ia=(e,t)=>{if(!o.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&o.isCallExpression(s)?z(s):void 0;return n?.receiver?Me(n.receiver).flatMap(i=>ra(i,e.getName(),t)):[]},oa=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=x(t,n);for(const a of i.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...ia(c,r))}return s},aa=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||t.getName()!=="replace")return!1;const s=t.getExpression();return _(s)},ca=e=>{const t=e.getArguments()[0];if(t===void 0||!o.isObjectLiteralExpression(t))return;const s=C(t,"server");if(s!==void 0)return o.isPropertyAssignment(s)?s.getInitializer():s},la=e=>{if(!e.isExported())return;const t=e.getInitializer();if(t?.getKind()!==l.CallExpression)return;const s=t;return zn(s.getExpression())?s:void 0},ua=e=>{const t=la(e),s=t===void 0?void 0:ca(t);if(s===void 0)return[];const n=e.getNameNode(),i=o.isIdentifier(n)?n.getText():"";return s.getDescendantsOfKind(l.CallExpression).filter(r=>aa(r)).map(r=>({exportName:i,file:"lunora/mutators.ts",line:r.getStartLineNumber()}))},da=e=>e.getVariableDeclarations().flatMap(t=>ua(t)),fa=(e,t)=>{const s=y(t,_n);if(!w(s))return[];const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);return da(n)},ga=new Set(["delete","get","patch"]),pa=new Set(["accountId","authorId","companyId","createdBy","createdById","customerId","groupId","memberId","organizationId","orgId","ownerId","projectId","teamId","tenantId","userId","workspaceId"]),ma=new Set(["auth","identity","session","user"]),ha=new Set([l.EqualsEqualsEqualsToken,l.EqualsEqualsToken,l.ExclamationEqualsEqualsToken,l.ExclamationEqualsToken]),va=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||t.getName()!=="normalizeId"||!_(t.getExpression()))return;const s=e.getArguments()[0];return s&&o.isStringLiteral(s)?s.getLiteralText():""},xa=e=>{let t=e,s=t.getParent();for(;s!==void 0&&(o.isAsExpression(s)||o.isParenthesizedExpression(s)||o.isNonNullExpression(s));)t=s,s=t.getParent();if(s===void 0||!o.isVariableDeclaration(s))return;const n=s.getNameNode();return o.isIdentifier(n)?n.getText():void 0},Ea=(e,t)=>e.getDescendantsOfKind(l.Identifier).some(s=>s.getText()===t),Sa=e=>o.isThrowStatement(e)||o.isReturnStatement(e)||e.getDescendantsOfKind(l.ThrowStatement).length>0||e.getDescendantsOfKind(l.ReturnStatement).length>0,ya=(e,t)=>e.getDescendantsOfKind(l.IfStatement).some(s=>Ea(s.getExpression(),t)&&Sa(s.getThenStatement())),Aa=(e,t)=>{for(const s of e.getDescendantsOfKind(l.CallExpression)){const n=s.getExpression();if(!o.isPropertyAccessExpression(n))continue;const i=n.getName();if(!ga.has(i))continue;const r=n.getExpression();if(!(_(r)||o.isPropertyAccessExpression(r)&&_(r.getExpression())))continue;const c=s.getArguments()[0];if(c!==void 0&&o.isIdentifier(c)&&c.getText()===t)return i}},ba=e=>{let t=e;for(;o.isPropertyAccessExpression(t)||o.isElementAccessExpression(t)||o.isNonNullExpression(t)||o.isParenthesizedExpression(t)||o.isAsExpression(t)||o.isAwaitExpression(t);)t=t.getExpression();return o.isIdentifier(t)?t.getText():void 0},Na=e=>e.getDescendantsOfKind(l.CallExpression).some(t=>t.getArguments().some(s=>ba(s)==="ctx")),Pa=e=>e.getDescendantsOfKind(l.BinaryExpression).some(t=>ha.has(t.getOperatorToken().getKind())?o.isPropertyAccessExpression(t.getLeft())||o.isPropertyAccessExpression(t.getRight()):!1),wa=e=>{for(const t of e.getDescendantsOfKind(l.Identifier))if(pa.has(t.getText()))return!0;for(const t of e.getDescendantsOfKind(l.PropertyAccessExpression)){const s=t.getExpression();if(o.isIdentifier(s)&&s.getText()==="ctx"&&ma.has(t.getName()))return!0}return Na(e)||Pa(e)},Ia=(e,t)=>{if(!o.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!o.isCallExpression(s))return[];const n=z(s);if(n?.kind!=="query"&&n?.kind!=="mutation")return[];const i=ns(s);if(i===void 0)return[];const r=n.receiver!==void 0&&Gt(n.receiver,"use","rls"),a=wa(i),c=new Set,u=[];for(const d of i.getDescendantsOfKind(l.CallExpression)){const m=va(d);if(m===void 0)continue;const h=xa(d);if(h===void 0||c.has(h)||!ya(i,h))continue;const R=Aa(i,h);R!==void 0&&(c.add(h),u.push({exportName:e.getName(),file:t,line:d.getStartLineNumber(),mentionsOwnership:a,sinkMethod:R,table:m,usesRls:r,visibility:n.visibility}))}return u},Ta=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=x(t,n);for(const a of i.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...Ia(c,r))}return s},Ca=new Set(["accountId","authorId","createdBy","createdById","organizationId","orgId","ownerId","tenantId","updatedBy","userId","workspaceId"]),Fa=new Set(["insert","insertManyUnsafe","patch","replace"]),Oa=e=>{if(!o.isPropertyAccessExpression(e))return;const t=e.getName();if(!Fa.has(t))return;const s=e.getExpression();if(!o.isPropertyAccessExpression(s)||s.getName()!=="db")return;const n=s.getExpression();return o.isIdentifier(n)&&n.getText()==="ctx"?t:void 0},Ra=(e,t)=>{if(t!=="insertManyUnsafe")return o.isObjectLiteralExpression(e)?[e]:[];if(!o.isArrayLiteralExpression(e))return[];const s=[];for(const n of e.getElements())o.isObjectLiteralExpression(n)&&s.push(n);return s},Ft=(e,t)=>{if(o.isPropertyAccessExpression(e)){const s=e.getExpression();return o.isIdentifier(s)&&s.getText()==="args"&&e.getName()===t}if(o.isElementAccessExpression(e)){const s=e.getExpression(),n=e.getArgumentExpression();return o.isIdentifier(s)&&s.getText()==="args"&&n!==void 0&&o.isStringLiteral(n)&&n.getLiteralValue()===t}return!1},La=e=>{if(!o.isIdentifier(e))return;const t=e.getText(),s=e.getFirstAncestor(a=>o.isArrowFunction(a)||o.isFunctionExpression(a)||o.isFunctionDeclaration(a));if(s===void 0)return;for(const a of s.getDescendantsOfKind(l.BinaryExpression)){const c=a.getLeft();if(o.isIdentifier(c)&&c.getText()===t&&a.getOperatorToken().getText().endsWith("="))return}const n=e.getStart();let i,r=-1;for(const a of s.getDescendantsOfKind(l.VariableDeclaration)){if(a.getName()!==t)continue;const c=a.getParent();if(!o.isVariableDeclarationList(c)||c.getDeclarationKind()!==Ms.Const)continue;const u=a.getInitializer(),d=a.getStart();u!==void 0&&d<n&&d>r&&(i=u,r=d)}return i},Da=(e,t)=>{if(Ft(e,t))return!0;const s=La(e);return s!==void 0&&Ft(s,t)},ka=(e,t,s,n,i)=>{const r=[];for(const a of e.getProperties()){let c,u;if(o.isPropertyAssignment(a)?(c=E(a),u=a.getInitializer()):o.isShorthandPropertyAssignment(a)&&(c=E(a),u=a.getNameNode()),!(c===void 0||u===void 0||!Ca.has(c))&&k(u)&&!U(u)){const d=S(s),m=i(d)===c&&Da(u,c);r.push({exportName:d,field:c,file:n,line:s.getStartLineNumber(),method:t,...m&&{ownerScoped:!0}})}}return r},Ma=(e,t,s)=>{const n=Oa(e.getExpression());if(n===void 0)return[];const i=e.getArguments()[1];return i?Ra(i,n).flatMap(r=>ka(r,n,e,t,s)):[]},Ka=(e,t,s)=>{const n=[];for(const i of e.getDescendantsOfKind(l.CallExpression))for(const r of Ma(i,t,a=>s(a).owner)){const{visibility:a}=s(r.exportName);n.push(a===void 0?r:{...r,visibility:a})}return n},_a=(e,t,s=[],n=[])=>{const i=[],r=new Map;for(const a of s)r.set(`${a.filePath}:${a.exportName}`,{visibility:a.visibility});for(const a of n){const c=`${a.filePath}:${a.exportName}`;r.set(c,{...r.get(c),owner:a.owner})}for(const a of p(t)){const c=e.getSourceFile(a)??e.addSourceFileAtPath(a),u=x(t,a);i.push(...Ka(c,u,d=>r.get(`${u}:${d}`)??{}))}return i},za=["providerSubscriptionId","state"],$a=["providerEventId","processedAt"],Ot=(e,t)=>t.every(s=>s in e.shape),Ua=e=>{const t=e.find(n=>n.name==="subscriptions"),s=e.find(n=>n.name==="events");return t!==void 0&&s!==void 0&&Ot(t,za)&&Ot(s,$a)},qa=new Set(["createAutumnAdapter","createDodoPaymentsAdapter","createPolarAdapter","createStripeAdapter"]),Ba=e=>e&&o.isNumericLiteral(e)?Number(e.getText()):void 0,Va=e=>{const t=C(e,"webhookToleranceSeconds");return t&&o.isPropertyAssignment(t)?Ba(t.getInitializer()):void 0},Wa=(e,t)=>{const s=A(e.getExpression());if(s===void 0||!qa.has(s))return;const[n]=e.getArguments(),i=n&&o.isObjectLiteralExpression(n)?Va(n):void 0;return{callee:s,exportName:S(e),file:t,line:e.getStartLineNumber(),...i===void 0?{}:{toleranceSeconds:i}}},ja=(e,t)=>F(e,t,Wa),Ha=new Set(["defineQueue","defineWorkflow"]),Ga=new Set(["run","runAction","runMutation","runQuery"]),Ya=new Set(["api","internal"]),Qa=e=>{const t=e.getExpression();return o.isIdentifier(t)?t.getText():void 0},Xa=e=>{const t=e.getArguments()[0];if(!t||!o.isObjectLiteralExpression(t))return;const s=C(t,"handler");if(s===void 0||!o.isPropertyAssignment(s))return;const n=s.getInitializer();if(n&&(o.isArrowFunction(n)||o.isFunctionExpression(n)))return n},ls=(e,t)=>{const s=e.getParameters()[t]?.getNameNode();return s&&o.isIdentifier(s)?s.getText():void 0},us=(e,t)=>e===t||e.startsWith(`${t}.`),ds=e=>{const t=e.getDescendantsOfKind(l.PropertyAccessExpression);return o.isPropertyAccessExpression(e)&&t.push(e),t},Rt=e=>{const t=e.getParent();return o.isPropertyAccessExpression(t)&&t.getNameNode()===e||o.isPropertyAssignment(t)&&t.getNameNode()===e?!1:!(o.isBindingElement(t)&&t.getNameNode()===e)},fs=e=>{const t=e.getDescendantsOfKind(l.Identifier).filter(s=>Rt(s));return o.isIdentifier(e)&&Rt(e)&&t.push(e),t},Za=e=>{if(!o.isVariableDeclaration(e))return[];const t=e.getNameNode();return o.isIdentifier(t)?[t.getText()]:t.getDescendantsOfKind(l.BindingElement).map(s=>s.getName())},Ja=e=>{const t=ls(e,1);if(t===void 0)return[];const s=[`${t}.messages`];for(const n of e.getDescendantsOfKind(l.ForOfStatement)){if(n.getExpression().getText()!==`${t}.messages`)continue;const i=n.getInitializer(),r=o.isVariableDeclarationList(i)?i.getDeclarations()[0]?.getNameNode():void 0;r&&o.isIdentifier(r)&&s.push(`${r.getText()}.body`)}return s},ec=(e,t,s)=>{const n=t==="workflow"?[`${s}.params`]:Ja(e),i=new Set,r=a=>ds(a).some(c=>n.some(u=>us(c.getText(),u)))?!0:fs(a).some(c=>i.has(c.getText()));for(const a of e.getDescendantsOfKind(l.VariableDeclaration)){const c=a.getInitializer();if(c&&r(c))for(const u of Za(a))i.add(u)}return{names:i,prefixes:n}},tc=(e,t)=>ds(e).some(s=>t.prefixes.some(n=>us(s.getText(),n)))?!0:fs(e).some(s=>t.names.has(s.getText())),sc=e=>{if(e===void 0||!o.isPropertyAccessExpression(e))return;const t=[];let s=e;for(;o.isPropertyAccessExpression(s);)t.unshift(s.getName()),s=s.getExpression();const n=t.at(-1);if(!(n===void 0||!o.isIdentifier(s)||!Ya.has(s.getText())||t.length<2))return{exportName:n,file:t.slice(0,-1).join("/")}},nc=(e,t,s)=>{const n=ls(e,0);if(n===void 0)return[];const i=ec(e,t,n),r=[];for(const a of e.getDescendantsOfKind(l.CallExpression)){const c=a.getExpression();if(!o.isPropertyAccessExpression(c)||!Ga.has(c.getName())||c.getExpression().getText()!==n)continue;const u=a.getArguments()[1];if(!u||!tc(u,i))continue;const d=sc(a.getArguments()[0]);d!==void 0&&r.push({dispatchKind:t,file:s,handlerExport:S(a),line:a.getStartLineNumber(),targetExport:d.exportName,targetFile:d.file})}return r},rc=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression)){const i=Qa(n);if(i===void 0||!Ha.has(i))continue;const r=Xa(n);r!==void 0&&s.push(...nc(r,i==="defineQueue"?"queue":"workflow",t))}return s},ic=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...rc(i,x(t,n)))}return s},Lt={dbRateLimit:"usesRateLimit",emailGateMiddleware:"usesEmailGate",mask:"usesMask",rateLimit:"usesRateLimit",rls:"usesRls",verifyTurnstileMiddleware:"usesCaptcha"},Dt=new Set(["account","credential","member","passkey","session","user"]),oc=e=>e.replaceAll(/[-_]/gu," ").replaceAll(/([a-z0-9])([A-Z])/gu,"$1 $2").split(" ").filter(Boolean).map(t=>t.toLowerCase()),ac=e=>{const s=oc(e).at(-1);if(!s)return!1;const n=s.endsWith("s")?s.slice(0,-1):s;return Dt.has(s)||Dt.has(n)},cc=e=>{const t=e.replaceAll(/[^a-z0-9]/giu,"").toLowerCase();return t.endsWith("email")||t.endsWith("emailaddress")},lc=(e,t)=>{const{objects:s,opaque:n}=_e(e,t);return ni(s).some(i=>cc(i))?!0:n?void 0:!1},uc=e=>{const t=e.getArguments()[0];return!t||!o.isObjectLiteralExpression(t)?{usesCaptcha:!1,usesRateLimit:!1}:{usesCaptcha:!!C(t,"captcha"),usesRateLimit:!!C(t,"rateLimit")}},dc=e=>{if(o.isCallExpression(e))return e;if(!o.isIdentifier(e))return;const s=e.getSourceFile().getVariableDeclaration(e.getText())?.getInitializer();return s&&o.isCallExpression(s)?s:void 0},ce={usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},fc=e=>{const t=dc(e),s=t?A(t.getExpression()):void 0;if(t&&s==="protectPublic"){const n=uc(t);return{...ce,usesCaptcha:n.usesCaptcha,usesRateLimit:n.usesRateLimit}}return s!==void 0&&s in Lt?{...ce,[Lt[s]]:!0}:ce},gc=e=>{const t={...ce};let s=e;for(;o.isCallExpression(s);){const n=s.getExpression();if(!o.isPropertyAccessExpression(n))break;const i=n.getName()==="use"?s.getArguments()[0]:void 0;if(i){const r=fc(i);t.usesCaptcha||=r.usesCaptcha,t.usesEmailGate||=r.usesEmailGate,t.usesMask||=r.usesMask,t.usesRateLimit||=r.usesRateLimit,t.usesRls||=r.usesRls}s=n.getExpression()}return t},pc=new Set(["insert","insertMany","insertManyUnsafe","replace"]),mc=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||!pc.has(t.getName()))return!1;const s=t.getExpression();if(!_(s))return!1;const i=e.getArguments()[0];return!i||!(o.isStringLiteral(i)||o.isNoSubstitutionTemplateLiteral(i))?!1:ac(i.getLiteralText())},hc=new Set(["create","runAfter","runAt","send","sendBatch"]),vc=new Set(["queues","scheduler","workflows"]),xc=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||!hc.has(t.getName()))return!1;let s=t.getExpression();for(;o.isCallExpression(s)||o.isElementAccessExpression(s)||o.isPropertyAccessExpression(s);){if(o.isPropertyAccessExpression(s)&&vc.has(s.getName())){const n=s.getExpression();if(o.isIdentifier(n)&&n.getText()==="ctx")return!0}s=s.getExpression()}return!1},Ec=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||t.getName()!=="insertManyUnsafe")return!1;const s=t.getExpression();return _(s)},gs=new Set(["generateObject","generateText","streamObject","streamText"]),Sc=e=>{const t=A(e.getExpression());return t!==void 0&&gs.has(t)},yc=e=>{const t=A(e.getExpression());if(t===void 0||!gs.has(t))return!1;const s=e.getArguments()[0];return!s||!o.isObjectLiteralExpression(s)||s.getProperties().some(n=>o.isSpreadAssignment(n))?!1:!C(s,"maxOutputTokens")},Ac=new Set(["log","span","trace"]),bc=new Set(["ai"]),Nc=new Set(["email","mail"]),Pc=new Set(["ai","browser","fetch","mail","notify","queues","sql","storage","workflows"]),Ie=(e,t)=>e.getDescendantsOfKind(l.PropertyAccessExpression).some(s=>{if(!t.has(s.getName()))return!1;const n=s.getExpression();return o.isIdentifier(n)&&n.getText()==="ctx"}),wc=new Set([l.ArrowFunction,l.FunctionDeclaration,l.FunctionExpression,l.GetAccessor,l.MethodDeclaration,l.SetAccessor]),Ic=new Set(["every","filter","flatMap","forEach","map","some"]),Tc=new Set(["all","allSettled","race"]),Cc=e=>{const t=e.getParent();if(!t||!o.isCallExpression(t)||!t.getArguments().includes(e))return;const s=t.getExpression();if(!o.isPropertyAccessExpression(s))return;const n=s.getName();if(Ic.has(n))return t;const i=s.getExpression();if(o.isIdentifier(i)&&i.getText()==="Promise"&&Tc.has(n))return t},Fc=e=>{let t=e.getParent();for(;t;){if(o.isTryStatement(t)){const s=t.getTryBlock();if(e.getPos()>=s.getPos()&&e.getEnd()<=s.getEnd())return!0}if(wc.has(t.getKind())){const s=Cc(t);if(!s)return!1;t=s;continue}t=t.getParent()}return!1},Oc=e=>{let t=e;for(;;){const s=t.getParent();if(!o.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(!o.isCallExpression(n)||n.getExpression()!==s)return!1;t=n}},Rc=e=>{let t=e;for(;;){const s=t.getParent();if(o.isPropertyAccessExpression(s)&&s.getExpression()===t){t=s;continue}return o.isCallExpression(s)&&s.getExpression()===t?s:void 0}},Lc=e=>{let t=!1,s=!0;for(const n of e.getDescendantsOfKind(l.PropertyAccessExpression)){if(!Pc.has(n.getName()))continue;const i=n.getExpression();if(!o.isIdentifier(i)||i.getText()!=="ctx")continue;const r=Rc(n);r&&(t=!0,!Fc(r)&&!Oc(r)&&(s=!1))}return{handlesErrors:t&&s,reachesOutbound:t}},Dc=e=>e.getDescendantsOfKind(l.ThrowStatement).some(t=>{const s=t.getExpression();if(!o.isNewExpression(s))return!1;const n=s.getExpression();return o.isIdentifier(n)&&n.getText()==="Error"}),kt="lunora-advisor-exempt",kc=/^[\s*/]+/u,Mc=/[\w-]/u,Kc=e=>{const s=(e.getFirstAncestorByKind(l.VariableStatement)??e).getLeadingCommentRanges().map(n=>n.getText()).join(`
6
+ `);for(const n of s.split(`
7
+ `)){const i=n.replace(kc,"");if(!i.startsWith(kt))continue;const r=i.slice(kt.length);if(Mc.test(r.charAt(0)))continue;const a=r.indexOf("--");return{exempt:!0,exemptReason:(a===-1?"":r.slice(a+2).split("*")[0]??"").trim()}}return{exempt:!1,exemptReason:""}},_c=e=>{const[t]=e.getArguments();if(t){if(o.isObjectLiteralExpression(t)){const s=C(t,"handler");return s?o.isPropertyAssignment(s)?s.getInitializer():o.isShorthandPropertyAssignment(s)?s.getNameNode():o.isMethodDeclaration(s)?s:void 0:void 0}return t}},zc=(e,t)=>{const s=_c(t);if(!s)return;if(o.isArrowFunction(s)||o.isFunctionExpression(s)||o.isMethodDeclaration(s))return e;if(!o.isIdentifier(s))return;const n=s.getSourceFile(),i=s.getText(),r=n.getVariableDeclaration(i)?.getInitializer();return r&&(o.isArrowFunction(r)||o.isFunctionExpression(r))?r:n.getFunction(i)},$c=e=>{let t=!1,s=!1,n=!1,i=!1,r=!1;for(const u of e.getDescendantsOfKind(l.CallExpression))if(mc(u)&&(r=!0),xc(u)&&(t=!0),Ec(u)&&(i=!0),Sc(u)&&(s=!0),yc(u)&&(n=!0),r&&t&&i&&n)break;const{handlesErrors:a,reachesOutbound:c}=Lc(e);return{callsMail:Ie(e,Nc),emitsEvent:Ie(e,Ac),fanOut:t,handlesErrors:a,reachesOutbound:c,runsAiGeneration:s||Ie(e,bc),throwsBareError:Dc(e),unboundedAiGeneration:n,usesInsertManyUnsafe:i,writesUserTable:r}},Uc=(e,t)=>{const s=e.getInitializer();if(!s||!o.isCallExpression(s))return;const n=z(s);if(!n||n.kind!=="query"&&n.kind!=="mutation"&&n.kind!=="action")return;const i=n.receiver?gc(n.receiver):{usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},r=zc(e,s);return{...r?$c(r):{},...Kc(e),...i,analyzableBody:r!==void 0,exportName:e.getName(),file:t,hasEmailArg:lc(s,n.receiver),kind:n.kind,visibility:n.visibility}},qc=(e,t)=>{const s=[];for(const n of e.getVariableStatements())if(n.isExported())for(const i of n.getDeclarations()){const r=Uc(i,t);r&&s.push(r)}return s},Bc=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...qc(i,x(t,n)))}return s},Vc=new Set(["dbRateLimit","rateLimit"]),Wc=e=>o.isArrowFunction(e)?e.getBody():e,jc=e=>{if(!o.isArrowFunction(e))return;const t=e.getParameters()[0]?.getNameNode();return t!==void 0&&o.isIdentifier(t)?t:void 0},ps=e=>{const t=e.getParent();return o.isPropertyAccessExpression(t)&&t.getExpression()===e&&t.getName()==="args"},ms=(e,t)=>{const s=t.getSymbol();return s===void 0?[]:e.getDescendantsOfKind(l.Identifier).filter(n=>{if(n.getSymbol()!==s)return!1;const i=n.getParent();return!(o.isPropertyAccessExpression(i)&&i.getNameNode()===n)})},Hc=(e,t)=>k(e)||t!==void 0&&ms(e,t).some(s=>ps(s)),Gc=(e,t)=>t===void 0?U(e):ms(e,t).some(s=>!ps(s)),Yc=(e,t)=>{const s=A(e.getExpression());if(s===void 0||!Vc.has(s))return;const n=b(jt(e.getArguments()[2]),"key");if(!n)return;const i=Wc(n),r=jc(n);if(!(!Hc(i,r)||Gc(i,r)))return{callee:s,exportName:S(e),file:t,limitName:Wt(e),line:e.getStartLineNumber()}},Qc=(e,t)=>F(e,t,Yc),Xc=new Set(["findFirst","findFirstOrThrow","findMany","findUnique","get"]),Zc=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||!Xc.has(t.getName()))return;const s=t.getExpression();if(_(s)){const n=e.getArguments()[0];return n&&o.isStringLiteral(n)?n.getLiteralText():""}if(o.isPropertyAccessExpression(s)&&_(s.getExpression()))return s.getName()},Jc=e=>{let t=e;for(;o.isCallExpression(t);){const s=t.getExpression();if(!o.isPropertyAccessExpression(s))return;if(s.getName()==="query"&&_(s.getExpression())){const n=t.getArguments()[0];return n&&o.isStringLiteral(n)?n.getLiteralText():""}t=s.getExpression()}},el=e=>{let t=X(e)??e;for(;o.isAwaitExpression(t);)t=X(t.getExpression())??t.getExpression();return t},hs=(e,t=!1)=>{const s=el(e);if(o.isIdentifier(s)){if(t)return;const n=me(s);return n===void 0?void 0:hs(n,!0)}if(o.isCallExpression(s))return Zc(s)??Jc(s)},tl=e=>{const t=e.getBody();if(!o.isBlock(t))return[t];const s=[];for(const n of e.getDescendantsOfKind(l.ReturnStatement)){const i=n.getFirstAncestor(a=>o.isArrowFunction(a)||o.isFunctionExpression(a)||o.isFunctionDeclaration(a)),r=n.getExpression();i===e&&r!==void 0&&s.push(r)}return s},sl=(e,t)=>{if(!o.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!o.isCallExpression(s))return[];const n=z(s);if(n?.kind!=="query")return[];const i=ns(s);if(i===void 0)return[];const r=n.receiver!==void 0&&pn(n.receiver,"output"),a=n.receiver!==void 0&&Gt(n.receiver,"use","mask"),c=new Set,u=[];for(const d of tl(i)){const m=hs(d);m===void 0||c.has(m)||(c.add(m),u.push({exportName:e.getName(),file:t,line:d.getStartLineNumber(),table:m,usesMask:a,usesOutput:r,visibility:n.visibility}))}return u},nl=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=x(t,n);for(const a of i.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...sl(c,r))}return s},rl=e=>{if(!e||!o.isObjectLiteralExpression(e))return[];const t=[];for(const s of e.getProperties())(o.isPropertyAssignment(s)||o.isShorthandPropertyAssignment(s)||o.isMethodDeclaration(s)||o.isGetAccessorDeclaration(s))&&t.push(E(s));return t},il=(e,t)=>{if(!o.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&o.isCallExpression(s)?z(s):void 0;if(!n)return[];const i=[];for(const r of e.getDescendantsOfKind(l.CallExpression)){const a=Ht(r);if(a===void 0)continue;const c=rl(b(a.options,"with"));c.length!==0&&i.push({exportName:e.getName(),file:t,line:r.getStartLineNumber(),parentTable:a.table,relations:c,visibility:n.visibility})}return i},ol=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=x(t,n);for(const a of i.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...il(c,r))}return s},de=e=>{if(o.isStringLiteral(e)||o.isNoSubstitutionTemplateLiteral(e))return e.getLiteralText();if(o.isBinaryExpression(e)&&e.getOperatorToken().getKind()===l.PlusToken){const t=de(e.getLeft()),s=de(e.getRight());return t!==void 0&&s!==void 0?t+s:void 0}},al=e=>{let t=e,s=t.getParent();for(;s!==void 0&&o.isBinaryExpression(s)&&s.getOperatorToken().getKind()===l.PlusToken;)t=s,s=t.getParent();return t!==e&&de(t)!==void 0},cl=/(?:^|\/)__tests__\//u,ll=/\.(?:spec|test)$/u,ul=e=>cl.test(e)||ll.test(e),dl=e=>{const t=e.getParent();if(t!==void 0){if(o.isVariableDeclaration(t)||o.isPropertyAssignment(t)||o.isPropertySignature(t))return E(t);if(o.isBinaryExpression(t)&&t.getOperatorToken().getKind()===l.EqualsToken)return t.getLeft().getText()}},fl=(e,t,s)=>Qn(e)?!ul(s)&&Xn(dl(t)):!0,gl=(e,t)=>{const s=[],n=[...e.getDescendantsOfKind(l.BinaryExpression),...e.getDescendantsOfKind(l.StringLiteral),...e.getDescendantsOfKind(l.NoSubstitutionTemplateLiteral)],i=new Set;for(const r of n){if(al(r))continue;const a=de(r);if(a===void 0)continue;const c=Gn(a);if(c===void 0||!fl(c,r,t))continue;const u=r.getStartLineNumber(),d=`${String(u)}:${c}`;i.has(d)||(i.add(d),s.push({file:t,kind:c,line:u,preview:Yn(a)}))}return s},pl=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...gl(i,x(t,n)))}return s},ml=(e,t)=>{if(!o.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&o.isCallExpression(s)?z(s):void 0;if(!n)return[];const i=[];for(const r of e.getDescendantsOfKind(l.CallExpression)){const a=Ht(r);if(a===void 0)continue;const c=b(a.options,"includeDeleted");if(c===void 0)continue;const u=o.isTrueLiteral(c),d=!u&&k(c);!u&&!d||i.push({exportName:e.getName(),file:t,fromArgs:d,hardcodedTrue:u,line:r.getStartLineNumber(),table:a.table,visibility:n.visibility})}return i},hl=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=x(t,n);for(const a of i.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...ml(c,r))}return s},vl=new Set(["query","unsafe"]),xl=e=>{if(!o.isPropertyAccessExpression(e)||!vl.has(e.getName()))return!1;const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||t.getName()!=="sql")return!1;const s=t.getExpression();return o.isIdentifier(s)&&s.getText()==="ctx"},El=e=>o.isBinaryExpression(e)||o.isTemplateExpression(e),Sl=e=>e.getFirstAncestorByKind(l.VariableDeclaration)?.getName()??"<module>",yl=(e,t)=>{if(!xl(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!El(s)))return{exportName:Sl(e),file:t,line:s.getStartLineNumber()}},Al=(e,t)=>F(e,t,yl),bl=[["convex",["convex","@convex-dev/"]],["supabase",["@supabase/"]],["firebase",["firebase","@firebase/","firebase-admin"]]],Nl=e=>{for(const[t,s]of bl)for(const n of s)if(e===n||e.startsWith(n.endsWith("/")?n:`${n}/`))return t},Pl=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const r of i.getImportDeclarations()){const a=r.getModuleSpecifierValue(),c=Nl(a);c!==void 0&&s.push({file:x(t,n),line:r.getStartLineNumber(),moduleSpecifier:a,platform:c})}}return s},wl=new Set(["createMultipartUpload","delete","download","generateUploadUrl","get","getMetadata","getPresignedUrl","getSignedUrl","getUrl","head","put","resumeMultipartUpload","store","upload"]),Il=(e,t,s=[])=>{const n=new Map(s.map(r=>[`${r.filePath}:${r.exportName}`,r.visibility]));return ve(e,t,{argIndex:0,matchReceiver:r=>r==="ctx.storage"||r.startsWith("ctx.storage."),methods:wl,requireUnmodifiedReach:!0}).map(r=>{const a=n.get(`${r.file}:${r.exportName}`);return a===void 0?r:{...r,visibility:a}})},Tl=new Map([["generateUploadUrl",1],["getPresignedUrl",1],["getSignedUrl",1],["store",2],["upload",2]]),Cl=e=>e&&o.isNumericLiteral(e)?Number(e.getText()):void 0,Fl=e=>{if(e===void 0)return{analyzable:!0,presentKeys:[]};if(!o.isObjectLiteralExpression(e))return{analyzable:!1,presentKeys:[]};const t=[];let s,n=!1;for(const i of e.getProperties()){if(o.isSpreadAssignment(i)){n=!0;continue}if(o.isPropertyAssignment(i)){const r=E(i);t.push(r),r==="expiresInSeconds"&&(s=Cl(i.getInitializer()));continue}(o.isShorthandPropertyAssignment(i)||o.isMethodDeclaration(i))&&t.push(E(i))}return{analyzable:!n,expiresInSeconds:s,presentKeys:t}},Ol=e=>{if(!o.isPropertyAccessExpression(e))return;const t=e.getName(),s=Tl.get(t);if(s===void 0)return;const n=e.getExpression().getText();return n==="ctx.storage"||n.startsWith("ctx.storage.")?{method:t,optionsIndex:s}:void 0},Rl=(e,t)=>{const s=Ol(e.getExpression());if(s!==void 0)return{exportName:S(e),file:t,line:e.getStartLineNumber(),method:s.method,...Fl(e.getArguments()[s.optionsIndex])}},Ll=(e,t)=>F(e,t,Rl),Dl=(e,t)=>({analytics:e.analytics||t.dependencies.has("@lunora/bindings"),auth:t.dependencies.has("@lunora/auth"),containers:e.container||t.containerCount>0||t.dependencies.has("@lunora/container"),flags:e.flags||t.dependencies.has("@lunora/flags"),kv:e.kv||t.dependencies.has("@lunora/bindings"),mail:e.mail||t.dependencies.has("@lunora/mail"),notifications:e.notify||t.dependencies.has("@lunora/notify"),payments:e.payments||t.hasPaymentTables,queues:t.queueCount>0||t.dependencies.has("@lunora/queue"),scheduler:e.scheduler||t.cronCount>0||t.dependencies.has("@lunora/scheduler"),storage:e.storage||t.storageRuleCount>0||t.storageColumnCount>0||t.dependencies.has("@lunora/storage"),vectors:t.vectorStoreSupported&&t.vectorIndexCount>0,workflows:e.workflows||t.workflowCount>0||t.dependencies.has("@lunora/workflow")}),kl=(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"}),Ml=(e,t)=>{if(t===void 0){const s=e.getArguments()[0];if(s===void 0||!o.isObjectLiteralExpression(s)||C(s,"args")===void 0)return!1}return _e(e,t).opaque},Kl=(e,t)=>{const s=[],n=(i,r)=>{const a=i.getInitializer();if(a===void 0||!o.isCallExpression(a))return;const c=z(a);c!==void 0&&Ml(a,c.receiver)&&s.push(kl(t,r,a.getStartLineNumber()))};for(const i of e.getVariableStatements().filter(r=>r.isExported()))for(const r of i.getDeclarations())n(r,r.getName());return s},_l=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n);i!==void 0&&s.push(...Kl(i,x(t,n)))}return s.toSorted((n,i)=>n.cacheKey.localeCompare(i.cacheKey))},zl=new Map([["AgentDefinition",{call:"defineAgent({ … })",file:"agents"}],["ContainerDefinition",{call:"defineContainer({ … })",file:"containers"}],["QueueDefinition",{call:"defineQueue({ … })",file:"queues",note:"A dropped queue has no caller to fail — its consumer is simply never wired."}],["RegisteredAction",{call:"action.input({ … }).action(handler)"}],["RegisteredLifecycleHook",{call:"onConnect(handler)",note:"Substitute the hook you called: `onConnect`, `onDisconnect` and `onShardInit` share one type, so codegen cannot tell which you wrote. A dropped hook has no caller to fail — it silently never fires."}],["RegisteredMigration",{call:"defineMigration({ … })",note:"A dropped migration never runs, so `lunora migrate up` reports nothing to do."}],["RegisteredMutation",{call:"mutation.input({ … }).mutation(handler)"}],["RegisteredMutator",{call:"defineMutator({ … })",file:"mutators"}],["RegisteredQuery",{call:"query.input({ … }).query(handler)"}],["RegisteredReactor",{call:"onQueryChange(select, handler)",note:"A dropped reactor has no caller to fail — it silently never runs."}],["RegisteredShape",{call:"defineShape({ … })",file:"shapes"}],["RegisteredStream",{call:"query.input({ … }).stream(handler)"}],["RegisteredWhisperAuthorizer",{call:"onWhisper(handler)",note:"A dropped authorizer has no caller to fail — the whisper topics it was meant to gate silently stay open to every socket on the shard."}],["WorkflowDefinition",{call:"defineWorkflow({ … })",file:"workflows"}]]),xe=({byName:e,byPath:t},s,n)=>t.has(`${s}:${n}`)||e.has(n),vs=e=>!e.isAny(),$e=e=>{const t=e.getType();if(!vs(t))return;const s=t.getAliasSymbol()?.getName()??t.getSymbol()?.getName(),n=s===void 0?void 0:zl.get(s);return n===void 0||s===void 0?void 0:{...n,typeName:s}},xs=e=>{const t=e.getInitializer();return t===void 0?!1:o.isCallExpression(t)||o.isIdentifier(t)||o.isPropertyAccessExpression(t)},Es={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."},$l=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.`}),Ul={cause:"the binding is exported by a separate `export { … }` statement, and codegen reads the `export` keyword on the declaration itself",remediation:"Move the keyword onto the declaration and drop the separate export statement."},Ue=(e,t,s,n,i)=>{const{call:r,file:a,note:c,typeName:u}=s,d=a!==void 0&&e!==a?a:void 0,m=d===void 0?i:$l(d),h=c===void 0?m.remediation:`${c} ${m.remediation}`;return{cacheKey:`procedure_not_registered:${e}:${t}`,categories:["SCHEMA"],description:"Codegen registers an export only when the declaration carries `export` and its initializer is literally the registering call. 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 \`${u}\` but was not registered — ${m.cause}.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:t,filePath:e,line:n,typeName:u},name:"procedure_not_registered",remediation:d===void 0?`Assign the registration directly: \`export const ${t} = ${r};\`. ${h}`:h,title:"Procedure exists at runtime but is missing from the generated API"}},ql=(e,t,s)=>{const n=[];for(const i of e.getVariableStatements().filter(r=>r.isExported()))for(const r of i.getDeclarations()){const a=r.getName();if(xe(s,t,a)||!xs(r))continue;const c=$e(r);c!==void 0&&n.push(Ue(t,a,c,r.getStartLineNumber(),Es))}return n},Bl=(e,t,s)=>{if(xe(s,t,"default"))return[];const n=[];for(const i of e.getExportAssignments().filter(r=>!r.isExportEquals())){const r=$e(i.getExpression());r!==void 0&&n.push(Ue(t,"default",r,i.getStartLineNumber(),Es))}return n},Vl=(e,t,s)=>{const n=[];for(const i of e.getExportDeclarations().filter(r=>r.getModuleSpecifier()===void 0))for(const r of i.getNamedExports()){const a=r.getAliasNode()?.getText()??r.getName();if(xe(s,t,a))continue;const c=r.getLocalTargetDeclarations().find(d=>o.isVariableDeclaration(d));if(c===void 0||!xs(c))continue;const u=$e(c);u!==void 0&&n.push(Ue(t,a,u,r.getStartLineNumber(),Ul))}return n},Wl=(e,t,s)=>[...ql(e,t,s),...Bl(e,t,s),...Vl(e,t,s)],jl=(e,t,s)=>e.getVariableStatements().filter(n=>n.isExported()).flatMap(n=>n.getDeclarations()).filter(n=>xe(s,t,n.getName())).filter(n=>{const i=n.getInitializer();return i!==void 0&&o.isCallExpression(i)&&o.isPropertyAccessExpression(i.getExpression())}).map(n=>({declaration:n,exportName:n.getName(),relativePath:t})),Hl=({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"}),Gl=(e,t,s)=>{const n=[],i=[];for(const a of p(t)){const c=e.getSourceFile(a);if(c===void 0)continue;const u=x(t,a);n.push(...Wl(c,u,s)),i.push(...jl(c,u,s))}const[r]=i;return r!==void 0&&i.every(({declaration:a})=>!vs(a.getType()))&&n.push(Hl(r)),n.toSorted((a,c)=>a.cacheKey.localeCompare(c.cacheKey))},Yl=new Set(["when","where"]),Te=new Set(["definePolicy","defineShape"]),Ql=e=>{if(!o.isCallExpression(e))return;const t=e.getExpression();if(o.isPropertyAccessExpression(t)){const n=t.getName();return Te.has(n)?n:void 0}if(!o.isIdentifier(t))return;for(const n of t.getSymbol()?.getDeclarations()??[])if(o.isImportSpecifier(n)){const i=n.getNameNode().getText();return Te.has(i)?i:void 0}const s=t.getText();return Te.has(s)?s:void 0},Xl=e=>o.isObjectLiteralExpression(e)&&e.getProperties().length===0,Ss=e=>{if(e!==void 0){if(o.isReturnStatement(e)&&e.getExpression()===void 0||e.getKind()===l.UndefinedKeyword||e.getText()==="undefined")return"undefined";if(Xl(e))return"empty-object";if(o.isParenthesizedExpression(e))return Ss(e.getExpression())}},qe=e=>e.getAncestors().find(t=>o.isArrowFunction(t)||o.isFunctionExpression(t)||o.isFunctionDeclaration(t)),Zl=e=>e.getDescendantsOfKind(l.ReturnStatement).filter(t=>qe(t)===e),ys=e=>e.getDescendantsOfKind(l.ConditionalExpression).filter(t=>qe(t)===e),Jl=e=>{const t=Zl(e);return t.length>1?!0:t.some(s=>s.getFirstAncestorByKind(l.IfStatement)!==void 0)||ys(e).length>0},eu=e=>e.getDescendantsOfKind(l.IfStatement).filter(t=>qe(t)===e),Le=e=>e.getKind()===l.NullKeyword||e.getKind()===l.FalseKeyword||o.isIdentifier(e)&&e.getText()==="undefined"?!0:o.isNumericLiteral(e)?e.getLiteralValue()===0:o.isStringLiteral(e)&&e.getLiteralValue()==="",tu=(e,t)=>Le(e)||Le(t),su=new Map([[l.EqualsEqualsEqualsToken,"positive"],[l.EqualsEqualsToken,"positive"],[l.ExclamationEqualsEqualsToken,"negative"],[l.ExclamationEqualsToken,"negative"]]),Mt=e=>!Le(e)&&(o.isLiteralExpression(e)||e.getKind()===l.TrueKeyword),nu=(e,t,s)=>{const n=su.get(e);if(n!==void 0)return tu(t,s)?n==="positive"?"negative":"positive":Mt(t)||Mt(s)?void 0:n},Y=e=>{if(o.isParenthesizedExpression(e))return Y(e.getExpression());if(o.isPrefixUnaryExpression(e)&&e.getOperatorToken()===l.ExclamationToken)return"negative";if(o.isBinaryExpression(e)){const t=e.getOperatorToken().getKind(),s=nu(t,e.getLeft(),e.getRight());if(s!==void 0)return s;if(t===l.AmpersandAmpersandToken||t===l.BarBarToken){const n=Y(e.getLeft()),i=Y(e.getRight());return n===i?n:"indeterminate"}}return o.isIdentifier(e)||o.isPropertyAccessExpression(e)||o.isElementAccessExpression(e)||o.isCallExpression(e)?"positive":"indeterminate"},Kt=e=>{if(e!==void 0){if(o.isReturnStatement(e))return e;if(o.isBlock(e)){const t=e.getStatements().at(-1);return t!==void 0&&o.isReturnStatement(t)?t:void 0}}},ru=e=>{if(e.getElseStatement()!==void 0)return;const t=e.getNextSiblingIfKind(l.ReturnStatement);return t!==void 0&&t.getNextSibling()===void 0?t:void 0},iu=e=>o.isReturnStatement(e)?e.getExpression()??e:e,ou=e=>{const t=[];for(const s of ys(e)){const n=Y(s.getCondition());n==="positive"?t.push(s.getWhenFalse()):n==="negative"&&t.push(s.getWhenTrue())}for(const s of eu(e)){const n=Y(s.getExpression());if(n==="indeterminate")continue;const i=n==="negative"?Kt(s.getThenStatement()):Kt(s.getElseStatement())??ru(s);i!==void 0&&t.push(iu(i))}return t},au=e=>{for(const t of e.getAncestors())if(o.isVariableDeclaration(t)){const s=t.getNameNode();if(o.isIdentifier(s))return s.getText()}return"<anonymous>"},cu=(e,t,s)=>{if(!o.isCallExpression(e))return[];const[n]=e.getArguments();if(!n||!o.isObjectLiteralExpression(n))return[];const i=[];for(const r of n.getProperties()){if(!o.isPropertyAssignment(r)||!Yl.has(E(r)))continue;const a=r.getInitializer();if(!(!a||!(o.isArrowFunction(a)||o.isFunctionExpression(a)))&&Jl(a))for(const c of ou(a)){const u=Ss(c);u!==void 0&&i.push({exportName:au(e),file:s,form:u,key:E(r),line:c.getStartLineNumber(),owner:t})}}return i},lu=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression)){const i=Ql(n);i!==void 0&&s.push(...cu(n,i,t))}return s},uu=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...lu(i,x(t,n)))}return s},du=new Set(["query","upsert","upsertNow"]),fu=e=>{if(!o.isPropertyAccessExpression(e))return;const t=e.getName();if(du.has(t))return e.getExpression().getText()==="ctx.vectors"?t:void 0},gu=(e,t)=>{const s=fu(e.getExpression());if(s===void 0)return;const n=e.getArguments()[1];if(!n)return;const i=b(n,"namespace");if(!(!i||!k(i)||U(i)))return{exportName:S(e),file:t,line:e.getStartLineNumber(),method:s}},pu=(e,t)=>F(e,t,gu),mu=e=>{const t=e.getExpression();if(!o.isPropertyAccessExpression(t)||t.getName()!=="get")return!1;const s=t.getExpression();return o.isPropertyAccessExpression(s)?s.getName()==="workflows":o.isIdentifier(s)&&s.getText()==="workflows"},hu=e=>{const t=e.getArguments()[0];return t&&o.isStringLiteral(t)?t.getLiteralText():""},vu=(e,t)=>{const s=[];for(const n of p(t)){const i=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=x(t,n);for(const a of i.getDescendantsOfKind(l.CallExpression)){if(!mu(a))continue;const c=ln(a);c!==""&&s.push({exportName:c,file:r,line:a.getStartLineNumber(),workflow:hu(a)})}}return s},xu=".lunora-schema.json",De=(e,t)=>{w(e)&&$t(e,"utf8")===t||Ls(e,t,"utf8")},Eu=(e,t)=>{if(t===""){Ds(e,{force:!0});return}De(e,t)},Su=e=>{const t=y(e,"package.json");if(w(t))try{const s=JSON.parse($t(t,"utf8"));return typeof s.version=="string"&&s.version!==""?s.version:void 0}catch{return}},yu=()=>{const e=process.env.LUNORA_CODEGEN_TIMING;return e!==void 0&&e!==""},Au=e=>{let t=w(e)?e:oe(e);for(;t&&t!==oe(t);){const s=y(t,"tsconfig.json");if(w(s))return s;t=oe(t)}},_t=e=>e.replaceAll("\\","/"),bu=(e,t,s)=>{if(s&&e.length>0){const r=e.map(a=>`"${a.exportName}"`).join(", ");throw new K("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) (${r}), 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 r of t.columns){const a=n.get(r.table)??[];a.push(r.column),n.set(r.table,a)}const i=t.columns.length>0;for(const r of e){if(r.table===void 0){if(i)throw new K("MASK_UNSUPPORTED",`defineShape "${r.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 "${r.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(r.table);if(a===void 0)continue;const c=a.map(u=>`"${u}"`).join(", ");throw new K("MASK_UNSUPPORTED",`defineShape "${r.exportName}" replicates table "${r.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})}},fe=(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)},zt=(e,t,s)=>e.getSourceFile(t)?.getFullText()===s,Nu=8,Pu=e=>{const{agents:t,apiPath:s,generatedFunctionsPath:n,lunoraDirectory:i,migrations:r,project:a,shapes:c,usesSandbox:u,useUmbrella:d,workflows:m}=e,h=()=>On(()=>{const N=Rn(a,i),O=$n(a,i);return{functions:N,httpRoutes:Ln(a,i),mutators:O}});let{erased:R,value:{functions:M,httpRoutes:g,mutators:I}}=h();pt([...M,...I].map(N=>N.filePath)),pt(g.filter(N=>N.stream).map(N=>N.filePath),"http-stream");for(let N=1;;N+=1){const O=tn({agents:t,functions:M,httpRoutes:g,mutators:I,useUmbrella:d,workflows:m}),v=sn({agents:t,functions:M,migrations:r,mutators:I,shapes:c,useUmbrella:d,usesSandbox:u});if(N>=Nu||zt(a,s,O)&&zt(a,n,v))return{apiContent:O,erased:R,functions:M,functionsContent:v,httpRoutes:g,mutators:I};fe(a,s,O),fe(a,n,v),{erased:R,value:{functions:M,httpRoutes:g,mutators:I}}=h()}},wu=e=>{const t=Au(e);return t?new dt({skipAddingFilesFromTsConfig:!1,tsConfigFilePath:t,useInMemoryFileSystem:!1}):new dt({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1})},Ad=(e,t)=>{const s=p(t),n=y(t,"schema.ts");w(n)&&s.push(n);for(const c of s){const u=e.getSourceFile(c);u===void 0?e.addSourceFileAtPath(c):u.refreshFromFileSystemSync()}const i=new Set(s.map(c=>_t(c))),r=_t(t),a=`${r}/`;for(const c of e.getSourceFiles()){const u=c.getFilePath();(u===r||u.startsWith(a))&&!i.has(u)&&e.removeSourceFile(c)}for(const c of e.getSourceFiles()){const u=c.getFilePath();if(!(u===r||u.startsWith(a)||u.includes("/node_modules/")))try{c.refreshFromFileSystemSync()}catch{e.removeSourceFile(c)}}},bd=e=>{const t=yu(),s=t?Pe.now():0,n=y(e.projectRoot,e.lunoraDirectory??"lunora"),i=y(n,"schema.ts");if(!w(i))throw new K("INTERNAL",`schema.ts not found at ${i}`);const r=e.project??wu(n);Nn(uo);const a=Hn(r,i,e.projectRoot),{agents:c,containers:u,crons:d,dataModelContent:m,dependencies:h,entryCronTriggers:R,env:M,featureUsage:g,hasFlags:I,hasNotify:N,identity:O,platformGate:v,queues:D,serverContent:q,storageRulesMetadata:H,usesSandbox:ee,useUmbrella:$,workflows:L}=Fr({lunoraDirectory:n,project:r,projectRoot:e.projectRoot,schema:a,target:e.target}),P=y(n,"_generated"),As=y(P,"dataModel.ts"),bs=y(P,"server.ts"),Ns=y(P,"api.ts"),Ps=y(P,"functions.ts");fe(r,As,m),fe(r,bs,q);const te=Kn(r,n),V=Zn(r,n),{apiContent:Be,erased:ws,functions:W,functionsContent:Ve,httpRoutes:Is,mutators:se}=Pu({agents:c,apiPath:Ns,generatedFunctionsPath:Ps,lunoraDirectory:n,migrations:te,project:r,shapes:V,useUmbrella:$,usesSandbox:ee,workflows:L}),ne=e.lint===!1?void 0:_s({adminRoutes:_r(r,n),aiRawRuns:Ur(r,n),aiToolSideEffects:Xr(r,n),argumentDerivedFetches:ei(r,n),argumentValidators:ui(r,n),authApiCalls:Pn(r,n),authConfigs:Si(r,n),browserUrlAccesses:Pi(r,n),configCalls:Li(r,n),containerKeyAccesses:ki(r,n),containerOverrides:Ui(r,n),containers:u,exportSinks:Wi(r,n),staleMigrationImports:Pl(r,n),failOpenGuards:Qi(r,n),flagReads:io(r,n),flagSecurityDefaults:lo(r,n),geoIndexUsages:po(r,n),httpActionGuards:wo(r,n),httpHeaderWrites:Mo(r,n),hyperdriveCalls:Dn(r,n),identityClaimReads:Bo(r,n),imageDeliveryUrlAccesses:Wo(r,n),inserts:kn(r,n),kvKeyAccesses:Ho(r,n,W),mailRecipientAccesses:Zo(r,n),maskProcedures:Mn(r,n),maskStrategies:oa(r,n),mutatorWrites:fa(r,n),nondeterministicCalls:Un(r,n),normalizeIdAuthorizations:Ta(r,n),notifyCalls:Bn(r,n),notifyConfig:qn(r,n),mutators:se,ownerFieldWrites:_a(r,n,W,se),unrestrictedWhereBranches:uu(r,n),paymentWebhooks:ja(r,n),privilegedDispatches:ic(r,n),procedureProtections:Bc(r,n),queries:bn(r,n),queues:D,r2sqlCalls:Vn(r,n),ratelimitKeySelectors:Qc(r,n),rawRowReturns:nl(r,n),relationLoads:ol(r,n),rlsProcedures:Wn(r,n),schema:a,secretLiterals:pl(r,n),shapes:V,softDeleteReads:hl(r,n),sqlInterpolations:Al(r,n),storageKeyAccesses:Il(r,n,W),storageUploads:Ll(r,n),vectorNamespaceAccesses:pu(r,n),workflowCalls:vu(r,n),workflows:L,wranglerVariables:e.wranglerVariables}),We=ne===void 0?[]:or(e.projectRoot,[...ks(ne,{source:"static"}),...Gl(r,n,{byName:new Set([...L,...D,...c,...u].map(f=>f.exportName)),byPath:new Set([...W,...se,...V,...te].map(f=>`${f.filePath}:${f.exportName}`))}),..._l(r,n),...Fn(ws,n)]),Ts=jn(r,n),je=na(r,n);bu(V,je,ta(r,n));const Cs=I?eo(r,n):[],Ee=v.signals.vectorStore!==!1,G=Dl(g,{containerCount:u.length,cronCount:d.length,dependencies:h,hasPaymentTables:Ua(a.tables),queueCount:D.length,storageColumnCount:Object.keys(Ut(a)).length,storageRuleCount:H.rules.length,vectorIndexCount:a.vectorIndexes.length,vectorStoreSupported:Ee,workflowCount:L.length}),He=t?Pe.now():0,Se=rr(a,te.map(f=>f.id)),Ge=Bs({advisories:We.filter(f=>f.name!=="procedure_type_check_unavailable"),advisorProcedures:ne?.procedureProtections??[],agents:c,containers:u,env:M,flagKeys:Cs,hasAccessFacade:g.access,hasAi:g.ai,hasAnalytics:g.analytics,hasBrowser:g.browser,hasFlags:I,hasHyperdrive:g.hyperdrive,hasImages:g.images,hasKv:g.kv,hasNotify:N,hasPayments:g.payments,hasPipelines:g.pipelines,hasR2sql:g.r2sql,hasVectors:Ee,hasX402:g.x402,maskMetadata:je,mutators:se,queues:D,rlsMetadata:Ts,schema:a,schemaSnapshot:Se,shapes:V,storageRules:H,studioFeatures:G,useUmbrella:$,workflows:L}),Ye=Vs(V,h.has("@lunora/db"),$),Qe=Ws(u,a.jurisdiction),Xe=js(L),Ze=Hs(c),Je=Gs(D),et=Ys(d),Fs=Qs(G.scheduler),tt=Xs(a.vectorIndexes),re=Zs(a,$),st=Js(h.has("@lunora/seed")),ie=e.apiSpec??"openapi",ye=ie==="openapi"||ie==="both",Ae=ie==="openrpc"||ie==="both",nt=Jn({emailAgents:c.filter(f=>f.onEmail===!0).map(f=>({bindingName:f.bindingName,exportName:f.exportName})),hasAccess:h.has("@lunora/cloudflare-access"),hasAi:g.ai,hasAnalytics:g.analytics,hasAuth:h.has("@lunora/auth"),hasBrowser:g.browser,hasFramework:h.has("@lunora/astro")||h.has("@lunora/svelte")||h.has("@lunora/vue"),hasGlobal:a.tables.some(f=>qt(f)),hasHyperdrive:g.hyperdrive,hasHyperdriveGlobal:a.tables.some(f=>Bt(f)),hasImages:g.images,hasKv:g.kv,hasKvIntrospector:G.kv,hasNotify:N,hasPayments:g.payments,hasR2sql:g.r2sql,hasQueue:D.some(f=>f.mode==="push"),hasScheduler:G.scheduler,hasSourcedTables:a.tables.some(f=>f.externalSource!==void 0),hasStorage:G.storage,hasVectors:Ee,hasWorkflow:L.length>0,hasX402:g.x402,identity:O,jurisdiction:a.jurisdiction,tableNames:a.tables.map(f=>f.name),useUmbrella:$,vectorIndexCount:a.vectorIndexes.length,voiceAgents:c.filter(f=>f.voice===!0&&f.voiceBindingName!==void 0).map(f=>({bindingName:f.voiceBindingName,exportName:f.exportName})),wantsOpenApi:ye,wantsOpenRpc:Ae}),rt=Su(e.projectRoot),it=er({functions:W,httpRoutes:Is,version:rt}),ot=sr({functions:W,version:rt}),at=`${JSON.stringify(it,void 0,2)}
8
+ `,ct=`${JSON.stringify(ot,void 0,2)}
9
+ `,lt=tr(it),ut=nr(ot),be=y(n,xu),Os=w(be),Ne=[];if(!e.dryRun){w(P)||Rs(P,{recursive:!0});const f=(B,j)=>{De(y(P,B),j),Ne.push(B)},T=(B,j)=>{Eu(y(P,B),j),j!==""&&Ne.push(B)};f("app.ts",nt),f("dataModel.ts",m),f("api.ts",Be),f("server.ts",q),f("functions.ts",Ve),f("shard.ts",Ge),f("crons.ts",et),f("vectors.ts",tt),f("drizzle.global.ts",re.global),f("drizzle.shard.ts",re.shard),T("containers.ts",Qe),T("workflows.ts",Xe),T("agents.ts",Ze),T("queues.ts",Je),T("scheduler.ts",Fs),T("seed.ts",st),T("collections.ts",Ye),T("openapi.json",ye?at:""),T("openapi.ts",ye?lt:""),T("openrpc.json",Ae?ct:""),T("openrpc.ts",Ae?ut:""),(!Os||e.updateSchemaBaseline===!0)&&De(be,Ks(Se))}if(t){const f=Pe.now(),T=Math.round(f-s),B=Math.round(He-s),j=Math.round(f-He);console.error(`@lunora/codegen: codegen took ${T.toString()}ms (discovery ${B.toString()}ms, emit ${j.toString()}ms)`)}return{advisories:We,advisorContext:ne,agents:c,containers:u,cronTriggers:[...new Set([...en(d),...R])],generated:{agents:Ze,api:Be,app:nt,collections:Ye,containers:Qe,crons:et,dataModel:m,drizzleGlobal:re.global,drizzleShard:re.shard,functions:Ve,openApi:at,openApiModule:lt,openRpc:ct,openRpcModule:ut,queues:Je,seed:st,server:q,shard:Ge,vectors:tt,workflows:Xe},migrations:te,outputDirectory:P,platformDiagnostics:v.diagnostics,queues:D,schemaSnapshot:Se,schemaSnapshotPath:be,workflows:L,writtenFiles:Ne}};export{xu as SCHEMA_SNAPSHOT_FILENAME,wu as createCodegenProject,Au as findTsconfig,Ad as refreshCodegenProject,bd as runCodegen};
@@ -0,0 +1 @@
1
+ import{existsSync as l}from"node:fs";import{join as m}from"node:path";import{SyntaxKind as c,Node as o}from"ts-morph";import{diagnosticAt as u}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as p}from"./module-specifiers-WF8iAydP.mjs";import{p as g}from"./parse-validator-2u-Io0i5.mjs";import{findObjectProperty as f}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const d="shapes.ts",S=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineShape";for(const e of t.getDeclarations())if(o.isImportSpecifier(e))return p(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineShape":!1;return!1},h=r=>{const t=r.getSymbol();if(!t)return!1;for(const e of t.getDeclarations()){if(!o.isNamespaceImport(e))continue;const i=e.getFirstAncestorByKind(c.ImportDeclaration);return i!==void 0&&p(i.getModuleSpecifierValue())}return!1},x=r=>{if(o.isIdentifier(r))return S(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineShape"&&o.isIdentifier(t)&&h(t)}return!1},b=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return;const e=f(t,"table");if(!e||!o.isPropertyAssignment(e))return;const i=e.getInitializer();return i&&o.isStringLiteral(i)?i.getLiteralValue():void 0},y=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return{};const e=f(t,"args");if(!e||!o.isPropertyAssignment(e))return{};const i=e.getInitializer();return!i||!o.isObjectLiteralExpression(i)?{}:g(i)},N=r=>{const t=[];for(const e of r.getVariableDeclarations()){if(!e.isExported())continue;const i=e.getInitializer();if(i?.getKind()!==c.CallExpression)continue;const s=i,a=s.getExpression();if(!x(a))continue;const n=e.getNameNode();if(!o.isIdentifier(n))throw u(n,"defineShape exports must be plain named exports (no destructuring)");t.push({args:y(s),exportName:n.getText(),filePath:"shapes",table:b(s)})}return t},L=(r,t)=>{const e=m(t,d);if(!l(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),s=N(i);return s.sort((a,n)=>a.exportName.localeCompare(n.exportName)),s};export{d as SHAPES_FILENAME,L as discoverShapes};
@@ -0,0 +1 @@
1
+ import{existsSync as p}from"node:fs";import{join as u}from"node:path";import{LunoraError as a}from"@lunora/errors";import{workflowDefaultName as d,workflowClassName as g,workflowBindingName as w}from"@lunora/workflow";import{Node as i,VariableDeclarationKind as b,SyntaxKind as x}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as h,findObjectProperty as f,stringPropertyFor as k}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const N="workflows.ts",E=new Set(["do","sleep","sleepUntil","waitForEvent"]),y=n=>{const e=n.getSymbol();if(!e)return n.getText()==="defineWorkflow";for(const t of e.getDeclarations())if(i.isImportSpecifier(t))return t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/workflow"?!1:t.getNameNode().getText()==="defineWorkflow";return!1},S=k("workflow"),D=n=>{const e=n.getExpression();if(!i.isPropertyAccessExpression(e)||!E.has(e.getName()))return!1;const t=e.getExpression();return i.isPropertyAccessExpression(t)&&t.getName()==="step"?!0:i.isIdentifier(t)&&t.getText()==="step"},W=n=>{const e=f(n,"handler");if(!e)return[];const t=i.isPropertyAssignment(e)?e.getInitializer():e;if(!t)return[];const o=[];for(const r of t.getDescendantsOfKind(x.CallExpression)){if(!D(r))continue;const s=r.getArguments()[0];!s||!(i.isStringLiteral(s)||i.isNoSubstitutionTemplateLiteral(s))||o.push({line:r.getStartLineNumber(),method:r.getExpression().getName(),name:s.getLiteralValue()})}return o},l=n=>{let e=n;for(;e&&(i.isAsExpression(e)||i.isSatisfiesExpression(e)||i.isParenthesizedExpression(e));)e=e.getExpression();return e},I=n=>{const e=l(n);if(e&&i.isObjectLiteralExpression(e))return e;if(!(!e||!i.isIdentifier(e)))for(const t of e.getSymbol()?.getDeclarations()??[]){const r=i.isVariableDeclaration(t)&&t.getVariableStatement()?.getDeclarationKind()===b.Const?l(t.getInitializer()):void 0;if(r&&i.isObjectLiteralExpression(r))return r}},P=(n,e)=>{const t=I(n.getArguments()[0]);if(!t)throw c(n,`workflow "${e}": defineWorkflow's argument must be an object literal, or a local \`const\` holding one — codegen reads \`name\` and the \`ctx.step.*\` calls out of it statically. Keep the handler wherever you like and pass it through: \`const config = { handler: myHandler }; export const ${e} = defineWorkflow(config);\`.`);const o={bindingName:w(e),className:g(e),exportName:e,name:d(e),steps:W(t)},r=f(t,"name");return r&&i.isPropertyAssignment(r)&&(o.name=S(r.getInitializerOrThrow(),e,"name")),o},A=n=>{const e=[];for(const t of n.getVariableDeclarations()){if(!t.isExported())continue;const o=h(t.getInitializer());if(!o)continue;const r=o.getExpression();if(!i.isIdentifier(r)||!y(r))continue;const s=t.getNameNode();if(!i.isIdentifier(s))throw c(s,"defineWorkflow exports must be plain named exports (no destructuring)");e.push(P(o,s.getText()))}return e},L=n=>{const e=new Map,t=new Map;for(const o of n){const r=e.get(o.name);if(r!==void 0)throw new a("DUPLICATE_WORKFLOW_NAME",`Duplicate workflow name "${o.name}": produced by both "${r}" and "${o.exportName}". Deployed workflow names must be unique across the project.`,{status:500});e.set(o.name,o.exportName);const s=t.get(o.bindingName);if(s!==void 0)throw new a("DUPLICATE_WORKFLOW_BINDING",`Duplicate workflow binding "${o.bindingName}": produced by both "${s}" and "${o.exportName}". Workflow export names must yield unique binding names.`,{status:500});t.set(o.bindingName,o.exportName)}},z=(n,e)=>{const t=u(e,N);if(!p(t))return[];const o=n.getSourceFile(t)??n.addSourceFileAtPath(t),r=A(o);return r.sort((s,m)=>s.exportName.localeCompare(m.exportName)),L(r),r};export{N as WORKFLOWS_FILENAME,z as discoverWorkflows};
@@ -1,3 +1,3 @@
1
- import{G as S,r as O}from"./emit-CBX_NHUL.mjs";import{s as p}from"./paths-C-9fwEgQ.mjs";import{LUNORA_ERROR_CODES as E,objectSchema as h,validatorIrToJsonSchema as u}from"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";const A="/_lunora/rest",P=["authorization","cf-access-jwt-assertion","cookie","x-payment"],f=["x-d1-bookmark","x-lunora-shard-key"],T=e=>[...P,...(e.credentialHeaders??[]).map(t=>t.toLowerCase())],g=e=>Number.isFinite(e)?Math.max(0,Math.floor(e)):0,y=(...e)=>{const t=[];for(const r of e)for(const o of r?.split(",")??[]){const s=o.trim().toLowerCase();s!==""&&!t.includes(s)&&t.push(s)}return t.length===0?void 0:t.join(", ")},b=(e,t)=>{const r=[t,`max-age=${String(g(e.maxAge))}`];return e.staleWhileRevalidate!==void 0&&r.push(`stale-while-revalidate=${String(g(e.staleWhileRevalidate))}`),r.join(", ")},x=e=>e.scope==="public"?y(e.vary,...T(e),...f):y(e.vary,...f),k=e=>{const t=e.indexOf(":");if(!(t<=0||t>=e.length-1||e.indexOf(":",t+1)!==-1))return{name:e.slice(t+1),namespace:e.slice(0,t)}},N=e=>{const t=k(e);if(t!==void 0)return`${A}/${t.namespace}/${t.name}`},q=e=>e==="query"?"GET":"POST",m="#/components/responses/LunoraError",v=/:([A-Za-z_$][\w$]*)/gu,_=e=>[...e.matchAll(v)].map(t=>t[1]),j=e=>e.replaceAll(v,"{$1}"),l=e=>e.kind==="optional"?e.inner??e:e,C=e=>{const t=new Set(_(e.path)),r=[];for(const[o,s]of Object.entries(e.searchParams)){const c=l(s);r.push({description:`Query parameter \`${o}\``,in:"query",name:o,required:s.kind!=="optional",schema:u(c)})}for(const[o,s]of Object.entries(e.params)){const c=l(s);r.push({description:`Path parameter \`${o}\``,in:t.has(o)?"path":"query",name:o,required:t.has(o)?!0:s.kind!=="optional",schema:u(c)})}return r},$=e=>e?{content:{"application/json":{schema:u(e)}},description:"Successful response."}:{content:{"application/json":{schema:{description:"Return shape is TS-inferred (no `.output()` declared); best-effort — any JSON."}}},description:"Successful response. The return shape is TypeScript-inferred and not declared via `.output()`, so it is documented best-effort."},w=e=>{const t=p(e.filePath),r=C(e),o={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${p(e.path)}`,responses:{200:$(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:m}},summary:`${e.method} ${e.path}`,tags:[t]};return r.length>0&&(o.parameters=r),Object.keys(e.body).length>0&&(o.requestBody={content:{"application/json":{schema:h(e.body)}},required:!0}),e.stream&&(o["x-lunora-stream"]="text/event-stream"),o},D=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o={additionalProperties:!1,properties:{args:h(e.args),functionPath:{const:r,type:"string"},shardKey:{description:"Optional shard key; omitted routes to the default shard.",type:"string"}},required:["functionPath"],type:"object"};return{operation:{description:`Invoke the \`${e.kind}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc).`,operationId:r,requestBody:{content:{"application/json":{schema:o}},required:!0},responses:{200:$(e.output),default:{$ref:m}},summary:`${e.kind}: ${r}`,tags:[t],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${r}`}},L=(e,t)=>{if(e===void 0||t!=="get"||e.scope===void 0||e.maxAge===void 0)return{};const r={maxAge:e.maxAge,scope:e.scope,...e.staleWhileRevalidate===void 0?{}:{staleWhileRevalidate:e.staleWhileRevalidate},...e.tag===void 0?{}:{tag:e.tag},...e.vary===void 0?{}:{vary:e.vary}},o={"Cache-Control":{description:r.scope==="public"?"Caching policy. `public` applies only to an uncredentialed request — a request carrying `Authorization` or `Cookie` is always answered `private`.":"Caching policy. Restricted to the caller's own cache; never stored by a shared/edge cache.",schema:{example:b(r,r.scope),type:"string"}}};r.tag!==void 0&&(o["Cache-Tag"]={description:"Purge tag for `ctx.cache.purge({ tags: [...] })`.",schema:{example:r.tag,type:"string"}});const s=x(r);return s!==void 0&&(o.Vary={description:"Request headers this response varies by. The endpoint's own negotiated headers are merged in at runtime.",schema:{example:s,type:"string"}}),{headers:o}},I=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o=N(r);if(o===void 0)return;const s=q(e.kind),c=s==="GET",d={description:`Public REST endpoint for the \`${e.kind}\` \`${r}\` (opt-in via \`.expose({ rest: true })\`). Routed through the procedure, so auth / RLS / validators are enforced.`,operationId:`rest_${p(o)}`,responses:{200:{content:{"application/json":{schema:{description:"Procedure result. The shape is TS-inferred from the return type; best-effort — any JSON."}}},description:"Successful result (TypeScript-inferred return shape, documented best-effort).",...L(e.expose?.cache,c?"get":"post")},default:{$ref:m}},summary:`${s} ${o}`,tags:[t],"x-lunora-function-kind":e.kind};if(c){const n=Object.entries(e.args).map(([a,i])=>{const R=l(i);return{description:`Argument \`${a}\` (JSON-encoded for non-string values).`,in:"query",name:a,required:i.kind!=="optional",schema:u(R)}});return n.length>0&&(d.parameters=n),{method:"get",operation:d,path:o}}return d.requestBody={content:{"application/json":{schema:h(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:d,path:o}},F=e=>{const t=e.version??"0.0.0",r={},o=new Set;for(const n of e.httpRoutes){const a=j(n.path),i=r[a]??{};i[n.method.toLowerCase()]=w(n),r[a]=i,o.add(p(n.filePath))}const s=e.functions.filter(n=>n.visibility!=="internal"&&n.kind!=="stream");for(const n of s){const{operation:a,pathKey:i}=D(n);r[i]={post:a},o.add(p(n.filePath))}for(const n of s){if(n.expose?.rest!==!0)continue;const a=I(n);if(a===void 0)continue;const i=r[a.path]??{};i[a.method]=a.operation,r[a.path]=i}const c=[...o].toSorted((n,a)=>n.localeCompare(a)).map(n=>({description:`Operations declared in \`lunora/${n}\`.`,name:n}));return{components:{responses:{LunoraError:{content:{"application/json":{schema:{additionalProperties:!1,description:"Standard Lunora error envelope.",properties:{error:{additionalProperties:!1,properties:{code:{description:"Machine-readable error code. Clients switch on this value.",enum:E,type:"string"},message:{description:"Human-readable error message (never echoes internal details).",type:"string"}},required:["code","message"],type:"object"}},required:["error"],type:"object"}}},description:"A Lunora error response. The HTTP status reflects the error code (e.g. BAD_REQUEST→400, UNAUTHORIZED→401, FORBIDDEN→403, NOT_FOUND→404)."}}},info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora API",version:t},openapi:"3.1.0",paths:r,tags:c}},U=e=>`${JSON.stringify(F(e),void 0,2)}
1
+ import{G as S,r as O}from"./emit-6YJU3YbV.mjs";import{s as p}from"./paths-C-9fwEgQ.mjs";import{LUNORA_ERROR_CODES as E,objectSchema as h,validatorIrToJsonSchema as u}from"./LUNORA_ERROR_CODES-C2s0xWQD.mjs";const A="/_lunora/rest",P=["authorization","cf-access-jwt-assertion","cookie","x-payment"],f=["x-d1-bookmark","x-lunora-shard-key"],T=e=>[...P,...(e.credentialHeaders??[]).map(t=>t.toLowerCase())],g=e=>Number.isFinite(e)?Math.max(0,Math.floor(e)):0,y=(...e)=>{const t=[];for(const r of e)for(const o of r?.split(",")??[]){const s=o.trim().toLowerCase();s!==""&&!t.includes(s)&&t.push(s)}return t.length===0?void 0:t.join(", ")},b=(e,t)=>{const r=[t,`max-age=${String(g(e.maxAge))}`];return e.staleWhileRevalidate!==void 0&&r.push(`stale-while-revalidate=${String(g(e.staleWhileRevalidate))}`),r.join(", ")},x=e=>e.scope==="public"?y(e.vary,...T(e),...f):y(e.vary,...f),k=e=>{const t=e.indexOf(":");if(!(t<=0||t>=e.length-1||e.indexOf(":",t+1)!==-1))return{name:e.slice(t+1),namespace:e.slice(0,t)}},N=e=>{const t=k(e);if(t!==void 0)return`${A}/${t.namespace}/${t.name}`},q=e=>e==="query"?"GET":"POST",m="#/components/responses/LunoraError",v=/:([A-Za-z_$][\w$]*)/gu,_=e=>[...e.matchAll(v)].map(t=>t[1]),j=e=>e.replaceAll(v,"{$1}"),l=e=>e.kind==="optional"?e.inner??e:e,C=e=>{const t=new Set(_(e.path)),r=[];for(const[o,s]of Object.entries(e.searchParams)){const c=l(s);r.push({description:`Query parameter \`${o}\``,in:"query",name:o,required:s.kind!=="optional",schema:u(c)})}for(const[o,s]of Object.entries(e.params)){const c=l(s);r.push({description:`Path parameter \`${o}\``,in:t.has(o)?"path":"query",name:o,required:t.has(o)?!0:s.kind!=="optional",schema:u(c)})}return r},$=e=>e?{content:{"application/json":{schema:u(e)}},description:"Successful response."}:{content:{"application/json":{schema:{description:"Return shape is TS-inferred (no `.output()` declared); best-effort — any JSON."}}},description:"Successful response. The return shape is TypeScript-inferred and not declared via `.output()`, so it is documented best-effort."},w=e=>{const t=p(e.filePath),r=C(e),o={description:`${e.stream?"Streaming (SSE) ":""}HTTP route handler \`${e.exportName}\` (${e.method} ${e.path}).`,operationId:`${e.method.toLowerCase()}_${p(e.path)}`,responses:{200:$(e.output),204:{description:"No content (handler returned `undefined`)."},default:{$ref:m}},summary:`${e.method} ${e.path}`,tags:[t]};return r.length>0&&(o.parameters=r),Object.keys(e.body).length>0&&(o.requestBody={content:{"application/json":{schema:h(e.body)}},required:!0}),e.stream&&(o["x-lunora-stream"]="text/event-stream"),o},D=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o={additionalProperties:!1,properties:{args:h(e.args),functionPath:{const:r,type:"string"},shardKey:{description:"Optional shard key; omitted routes to the default shard.",type:"string"}},required:["functionPath"],type:"object"};return{operation:{description:`Invoke the \`${e.kind}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc).`,operationId:r,requestBody:{content:{"application/json":{schema:o}},required:!0},responses:{200:$(e.output),default:{$ref:m}},summary:`${e.kind}: ${r}`,tags:[t],"x-lunora-function-kind":e.kind},pathKey:`/_lunora/rpc#${r}`}},L=(e,t)=>{if(e===void 0||t!=="get"||e.scope===void 0||e.maxAge===void 0)return{};const r={maxAge:e.maxAge,scope:e.scope,...e.staleWhileRevalidate===void 0?{}:{staleWhileRevalidate:e.staleWhileRevalidate},...e.tag===void 0?{}:{tag:e.tag},...e.vary===void 0?{}:{vary:e.vary}},o={"Cache-Control":{description:r.scope==="public"?"Caching policy. `public` applies only to an uncredentialed request — a request carrying `Authorization` or `Cookie` is always answered `private`.":"Caching policy. Restricted to the caller's own cache; never stored by a shared/edge cache.",schema:{example:b(r,r.scope),type:"string"}}};r.tag!==void 0&&(o["Cache-Tag"]={description:"Purge tag for `ctx.cache.purge({ tags: [...] })`.",schema:{example:r.tag,type:"string"}});const s=x(r);return s!==void 0&&(o.Vary={description:"Request headers this response varies by. The endpoint's own negotiated headers are merged in at runtime.",schema:{example:s,type:"string"}}),{headers:o}},I=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o=N(r);if(o===void 0)return;const s=q(e.kind),c=s==="GET",d={description:`Public REST endpoint for the \`${e.kind}\` \`${r}\` (opt-in via \`.expose({ rest: true })\`). Routed through the procedure, so auth / RLS / validators are enforced.`,operationId:`rest_${p(o)}`,responses:{200:{content:{"application/json":{schema:{description:"Procedure result. The shape is TS-inferred from the return type; best-effort — any JSON."}}},description:"Successful result (TypeScript-inferred return shape, documented best-effort).",...L(e.expose?.cache,c?"get":"post")},default:{$ref:m}},summary:`${s} ${o}`,tags:[t],"x-lunora-function-kind":e.kind};if(c){const n=Object.entries(e.args).map(([a,i])=>{const R=l(i);return{description:`Argument \`${a}\` (JSON-encoded for non-string values).`,in:"query",name:a,required:i.kind!=="optional",schema:u(R)}});return n.length>0&&(d.parameters=n),{method:"get",operation:d,path:o}}return d.requestBody={content:{"application/json":{schema:h(e.args)}},required:Object.keys(e.args).length>0},{method:"post",operation:d,path:o}},F=e=>{const t=e.version??"0.0.0",r={},o=new Set;for(const n of e.httpRoutes){const a=j(n.path),i=r[a]??{};i[n.method.toLowerCase()]=w(n),r[a]=i,o.add(p(n.filePath))}const s=e.functions.filter(n=>n.visibility!=="internal"&&n.kind!=="stream");for(const n of s){const{operation:a,pathKey:i}=D(n);r[i]={post:a},o.add(p(n.filePath))}for(const n of s){if(n.expose?.rest!==!0)continue;const a=I(n);if(a===void 0)continue;const i=r[a.path]??{};i[a.method]=a.operation,r[a.path]=i}const c=[...o].toSorted((n,a)=>n.localeCompare(a)).map(n=>({description:`Operations declared in \`lunora/${n}\`.`,name:n}));return{components:{responses:{LunoraError:{content:{"application/json":{schema:{additionalProperties:!1,description:"Standard Lunora error envelope.",properties:{error:{additionalProperties:!1,properties:{code:{description:"Machine-readable error code. Clients switch on this value.",enum:E,type:"string"},message:{description:"Human-readable error message (never echoes internal details).",type:"string"}},required:["code","message"],type:"object"}},required:["error"],type:"object"}}},description:"A Lunora error response. The HTTP status reflects the error code (e.g. BAD_REQUEST→400, UNAUTHORIZED→401, FORBIDDEN→403, NOT_FOUND→404)."}}},info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora API",version:t},openapi:"3.1.0",paths:r,tags:c}},U=e=>`${JSON.stringify(F(e),void 0,2)}
2
2
  `,B=e=>`${S}export const openApiSpec = ${O(e,"Record<string, unknown>")};
3
3
  `;export{F as buildOpenApiDocument,U as emitOpenApi,B as emitOpenApiModule};
@@ -0,0 +1 @@
1
+ import{w as a}from"./classify-procedure-call-CZU6n3yF.mjs";const l=s=>a(s,"use","rls");export{l as r};
@@ -1 +1 @@
1
- import{Node as o}from"ts-morph";import{unwrapExpression as a}from"./listLunoraSourceFiles-DsxeRYvh.mjs";import{a as u}from"./module-specifiers-WF8iAydP.mjs";const A=t=>o.isIdentifier(t)?t.getText():o.isPropertyAccessExpression(t)?t.getName():void 0,y=(t,i)=>{const e=new Set;for(const r of t.getImportDeclarations())if(u(r.getModuleSpecifierValue()))for(const n of r.getNamedImports())n.getNameNode().getText()===i&&e.add(n.getAliasNode()?.getText()??n.getName());return e},h=(t,i)=>{if(o.isPropertyAccessExpression(t))return t.getName()===i;if(!o.isIdentifier(t))return!1;const e=t.getText();return e===i||y(t.getSourceFile(),i).has(e)},d=t=>{const i=t.getSymbol();if(!i)return t.getText();for(const e of i.getDeclarations())if(o.isImportSpecifier(e))return u(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText():void 0},p=t=>{const i=[];let e=a(t);for(;e&&o.isCallExpression(e);){const r=a(e.getExpression());if(!r||!o.isPropertyAccessExpression(r))return{root:void 0,steps:i};i.push({call:e,name:r.getName()}),e=a(r.getExpression())}return{root:e,steps:i}},f=t=>p(t).steps,x=(t,i,e)=>f(t).filter(r=>r.name===i).map(r=>r.call.getArguments()[0]).filter(r=>r!==void 0&&o.isCallExpression(r)&&h(r.getExpression(),e)),w=(t,i)=>f(t).some(e=>e.name===i),P=(t,i,e)=>x(t,i,e).length>0,l=new Set(["action","mutation","query","stream"]),m={internalAction:"action",internalMutation:"mutation",internalQuery:"query"},N={onConnect:"connect",onDisconnect:"disconnect",onQueryChange:"reactor",onShardInit:"init",onWhisper:"whisper"},I=t=>t==="whisper"?"query":"mutation",C=t=>{const{root:i}=p(t);return i&&o.isIdentifier(i)?i:void 0},g=(t,i=!1)=>{const e=C(t);if(!e)return;const r=d(e);if(r===void 0){if(i)return;const n=e.getSymbol()?.getValueDeclaration();if(n&&o.isVariableDeclaration(n)){const s=n.getInitializer();return s?g(s,!0):void 0}return}return l.has(r)?"public":m[r]?"internal":void 0},E=t=>{const i=t.getName();if(!l.has(i))return;const e=t.getExpression(),r=a(e)??e,n=e===r?[r]:[e,r];if(n.some(c=>c.getType().getProperty("__lunoraProcedure"))){const c=n.some(v=>v.getType().getProperty("__lunoraVisibility"));return{kind:i,receiver:r,visibility:c?"internal":"public"}}const s=g(r);if(s)return{kind:i,receiver:r,visibility:s}},D=t=>{const i=t.getExpression();if(o.isPropertyAccessExpression(i))return E(i);if(!o.isIdentifier(i))return;const e=d(i);if(!e)return;if(l.has(e))return{kind:e,visibility:"public"};const r=m[e];if(r)return{kind:r,visibility:"internal"};const n=N[e];if(n)return{kind:I(n),lifecycle:n,visibility:"internal"}};export{A as a,f as b,D as c,P as d,w as e,x as w};
1
+ import{Node as o}from"ts-morph";import{unwrapExpression as a}from"./listLunoraSourceFiles-vjwjgpjd.mjs";import{a as u}from"./module-specifiers-WF8iAydP.mjs";const A=t=>o.isIdentifier(t)?t.getText():o.isPropertyAccessExpression(t)?t.getName():void 0,y=(t,i)=>{const e=new Set;for(const r of t.getImportDeclarations())if(u(r.getModuleSpecifierValue()))for(const n of r.getNamedImports())n.getNameNode().getText()===i&&e.add(n.getAliasNode()?.getText()??n.getName());return e},h=(t,i)=>{if(o.isPropertyAccessExpression(t))return t.getName()===i;if(!o.isIdentifier(t))return!1;const e=t.getText();return e===i||y(t.getSourceFile(),i).has(e)},d=t=>{const i=t.getSymbol();if(!i)return t.getText();for(const e of i.getDeclarations())if(o.isImportSpecifier(e))return u(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText():void 0},p=t=>{const i=[];let e=a(t);for(;e&&o.isCallExpression(e);){const r=a(e.getExpression());if(!r||!o.isPropertyAccessExpression(r))return{root:void 0,steps:i};i.push({call:e,name:r.getName()}),e=a(r.getExpression())}return{root:e,steps:i}},f=t=>p(t).steps,x=(t,i,e)=>f(t).filter(r=>r.name===i).map(r=>r.call.getArguments()[0]).filter(r=>r!==void 0&&o.isCallExpression(r)&&h(r.getExpression(),e)),w=(t,i)=>f(t).some(e=>e.name===i),P=(t,i,e)=>x(t,i,e).length>0,l=new Set(["action","mutation","query","stream"]),m={internalAction:"action",internalMutation:"mutation",internalQuery:"query"},N={onConnect:"connect",onDisconnect:"disconnect",onQueryChange:"reactor",onShardInit:"init",onWhisper:"whisper"},I=t=>t==="whisper"?"query":"mutation",C=t=>{const{root:i}=p(t);return i&&o.isIdentifier(i)?i:void 0},g=(t,i=!1)=>{const e=C(t);if(!e)return;const r=d(e);if(r===void 0){if(i)return;const n=e.getSymbol()?.getValueDeclaration();if(n&&o.isVariableDeclaration(n)){const s=n.getInitializer();return s?g(s,!0):void 0}return}return l.has(r)?"public":m[r]?"internal":void 0},E=t=>{const i=t.getName();if(!l.has(i))return;const e=t.getExpression(),r=a(e)??e,n=e===r?[r]:[e,r];if(n.some(c=>c.getType().getProperty("__lunoraProcedure"))){const c=n.some(v=>v.getType().getProperty("__lunoraVisibility"));return{kind:i,receiver:r,visibility:c?"internal":"public"}}const s=g(r);if(s)return{kind:i,receiver:r,visibility:s}},D=t=>{const i=t.getExpression();if(o.isPropertyAccessExpression(i))return E(i);if(!o.isIdentifier(i))return;const e=d(i);if(!e)return;if(l.has(e))return{kind:e,visibility:"public"};const r=m[e];if(r)return{kind:r,visibility:"internal"};const n=N[e];if(n)return{kind:I(n),lifecycle:n,visibility:"internal"}};export{A as a,f as b,D as c,P as d,w as e,x as w};
@@ -1 +1 @@
1
- import{Node as s,SyntaxKind as a}from"ts-morph";import{listLunoraSourceFiles as d,lunoraRelativePath as l,handlerOf as f}from"./listLunoraSourceFiles-DsxeRYvh.mjs";import{c as u}from"./classify-procedure-call-RjsZg8AH.mjs";const x=e=>{const n=e.getInitializer();if(!n||!s.isCallExpression(n))return;const r=u(n);if(!r||r.kind!=="query"&&r.kind!=="mutation")return;const t=f(n,r.receiver);return t?{exportName:e.getName(),handler:t,kind:r.kind}:void 0},p=(e,n)=>{if(!s.isPropertyAccessExpression(e)||e.getName()!==n)return;const r=e.getExpression();if(!s.isIdentifier(r)||r.getText()!=="ctx")return;const t=e.getParent();return t&&s.isPropertyAccessExpression(t)&&t.getExpression()===e?`ctx.${n}.${t.getName()}`:`ctx.${n}`},m=(e,n,r)=>{const t=[];for(const o of e.handler.getDescendantsOfKind(a.PropertyAccessExpression)){const i=p(o,r);i!==void 0&&t.push({callee:i,exportName:e.exportName,file:n,kind:e.kind,line:o.getStartLineNumber()})}return t},g=(e,n,r)=>{const t=[];for(const o of e.getVariableStatements())if(o.isExported())for(const i of o.getDeclarations()){const c=x(i);c&&t.push(...m(c,n,r))}return t},N=(e,n,r)=>{const t=[];for(const o of d(n)){const i=e.getSourceFile(o)??e.addSourceFileAtPath(o);t.push(...g(i,l(n,o),r))}return t};export{N as d};
1
+ import{Node as s,SyntaxKind as a}from"ts-morph";import{listLunoraSourceFiles as d,lunoraRelativePath as l,handlerOf as f}from"./listLunoraSourceFiles-vjwjgpjd.mjs";import{c as u}from"./classify-procedure-call-CZU6n3yF.mjs";const x=e=>{const n=e.getInitializer();if(!n||!s.isCallExpression(n))return;const r=u(n);if(!r||r.kind!=="query"&&r.kind!=="mutation")return;const t=f(n,r.receiver);return t?{exportName:e.getName(),handler:t,kind:r.kind}:void 0},p=(e,n)=>{if(!s.isPropertyAccessExpression(e)||e.getName()!==n)return;const r=e.getExpression();if(!s.isIdentifier(r)||r.getText()!=="ctx")return;const t=e.getParent();return t&&s.isPropertyAccessExpression(t)&&t.getExpression()===e?`ctx.${n}.${t.getName()}`:`ctx.${n}`},m=(e,n,r)=>{const t=[];for(const o of e.handler.getDescendantsOfKind(a.PropertyAccessExpression)){const i=p(o,r);i!==void 0&&t.push({callee:i,exportName:e.exportName,file:n,kind:e.kind,line:o.getStartLineNumber()})}return t},g=(e,n,r)=>{const t=[];for(const o of e.getVariableStatements())if(o.isExported())for(const i of o.getDeclarations()){const c=x(i);c&&t.push(...m(c,n,r))}return t},N=(e,n,r)=>{const t=[];for(const o of d(n)){const i=e.getSourceFile(o)??e.addSourceFileAtPath(o);t.push(...g(i,l(n,o),r))}return t};export{N as d};
@@ -0,0 +1 @@
1
+ import{SyntaxKind as u,Node as r}from"ts-morph";import{listLunoraSourceFiles as f,lunoraRelativePath as g,enclosingExportName as d,propertyKeyName as m}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const h=s=>{const t=s.getExpression();if(!r.isPropertyAccessExpression(t))return!1;const e=t.getExpression();return r.isPropertyAccessExpression(e)?e.getName()==="authApi":r.isIdentifier(e)&&e.getText()==="authApi"},A=s=>{const t=s.getArguments()[0];if(t===void 0)return!1;if(!r.isObjectLiteralExpression(t))return!0;for(const e of t.getProperties())if((r.isPropertyAssignment(e)||r.isShorthandPropertyAssignment(e))&&m(e)==="headers"||r.isSpreadAssignment(e))return!0;return!1},E=(s,t)=>{const e=[];for(const n of f(t)){const c=s.getSourceFile(n)??s.addSourceFileAtPath(n),l=g(t,n);for(const i of c.getDescendantsOfKind(u.CallExpression)){if(!h(i))continue;const o=d(i);if(o==="")continue;const a=i.getExpression(),p=r.isPropertyAccessExpression(a)?a.getName():"";e.push({exportName:o,file:l,hasHeaders:A(i),line:i.getStartLineNumber(),method:p})}}return e};export{E as default};
@@ -0,0 +1 @@
1
+ import{LunoraError as L}from"@lunora/errors";import{CRON_SCHEDULE_KINDS as A,isValidCronExpression as O,warnIfSecondsLeading as S,compileCronSchedule as b}from"@lunora/scheduler";import{SyntaxKind as p,Node as s}from"ts-morph";import{diagnosticAt as f,CodegenDiagnosticError as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{i as R}from"./module-specifiers-WF8iAydP.mjs";import{s as $}from"./paths-C-9fwEgQ.mjs";import{listLunoraSourceFiles as y,propertyKeyName as P}from"./listLunoraSourceFiles-vjwjgpjd.mjs";const D=new Set([...A,"cron"]),v=e=>{const t=e.getSymbol();if(!t)return e.getText()==="cronJobs";for(const r of t.getDeclarations())if(s.isImportSpecifier(r))return R(r.getImportDeclaration().getModuleSpecifierValue())?r.getNameNode().getText()==="cronJobs":!1;return!1},F=e=>{const t=new Set;for(const r of e.getVariableDeclarations()){const n=r.getInitializer();if(n?.getKind()!==p.CallExpression)continue;const i=n.getExpression();s.isIdentifier(i)&&v(i)&&t.add(r.getName())}return t},V=e=>{let t=e;for(;s.isCallExpression(t)||s.isPropertyAccessExpression(t);)t=t.getExpression();return s.isIdentifier(t)?t.getText():void 0},x=(e,t)=>{const r=e.getArguments()[t];return r&&(s.isStringLiteral(r)||s.isNoSubstitutionTemplateLiteral(r))?r.getLiteralValue():void 0},_=(e,t)=>{if(s.isStringLiteral(e)||s.isNoSubstitutionTemplateLiteral(e)||s.isNumericLiteral(e))return e.getLiteralValue();if(s.isTrueLiteral(e))return!0;if(s.isFalseLiteral(e))return!1;if(s.isPrefixUnaryExpression(e)&&e.getOperatorToken()===p.MinusToken){const r=e.getOperand();if(s.isNumericLiteral(r))return-r.getLiteralValue()}if(s.isObjectLiteralExpression(e))return m(e,t);if(s.isArrayLiteralExpression(e))return e.getElements().map(r=>_(r,t));throw f(e,`Cron job "${t}" passes a non-static value where a literal is required; codegen can only read literals.`,{code:"CRON_NON_STATIC_VALUE",name:"LunoraError",status:500})},m=(e,t)=>{const r={};for(const n of e.getProperties()){if(!s.isPropertyAssignment(n))throw f(n,`Cron job "${t}" uses an unsupported object property (shorthand/spread/method) where a static literal is required.`,{code:"CRON_NON_STATIC_VALUE",name:"LunoraError",status:500});const i=n.getInitializer();i&&(r[P(n)]=_(i,t))}return r},C=(e,t,r)=>{const n=e.getArguments()[t];if(!n||!s.isPropertyAccessExpression(n))throw f(e,`Cron job "${r}" must reference a function statically (e.g. internal.email.digest); codegen cannot resolve a dynamic reference.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});const i=n.getName(),o=n.getExpression();if(!s.isPropertyAccessExpression(o))throw f(n,`Cron job "${r}" function reference must be of the form internal.file.fn (two property accesses).`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});const a=o.getName();return`${$(a)}:${i}`},h=e=>({workflow:{binding:e.bindingName,exportName:e.exportName}}),w=e=>({workflow:{binding:e.bindingName,exportName:e.exportName}}),T=(e,t,r,n,i,o)=>{const a=e.getExpression();if(!s.isIdentifier(a)||a.getText()!==t)return;const c=r.get(e.getName());if(c)return o(c);throw f(e,`Cron job "${n}" targets ${t}.${e.getName()}, but no such ${i} is declared in lunora/${i}s.ts.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500})},j=(e,t,r,n,i)=>{const o=e.getArguments()[t];if(o&&s.isPropertyAccessExpression(o)){const a=T(o,"workflows",n,r,"workflow",h);if(a)return a;const c=T(o,"agents",i,r,"agent",w);return c||{functionPath:C(e,t,r)}}if(o&&s.isIdentifier(o)){const a=n.get(o.getText()),c=i.get(o.getText());if(a&&c)throw f(o,`Cron job "${r}" references "${o.getText()}", which is ambiguous: a workflow and an agent are both declared under that name.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500});if(a)return h(a);if(c)return w(c);throw f(o,`Cron job "${r}" references "${o.getText()}", which is neither a function (internal.file.fn / api.file.fn) nor a declared workflow in lunora/workflows.ts nor a declared agent in lunora/agents.ts.`,{code:"CRON_NON_STATIC_FN",name:"LunoraError",status:500})}return{functionPath:C(e,t,r)}},k=/^@lunora\/scheduler:\s*/u,U=(e,t)=>{const r=x(e,1);if(r===void 0)throw f(e,`Cron job "${t}" must pass a string-literal cron expression to ".cron(...)".`,{code:"CRON_EXPR_NOT_STATIC",name:"LunoraError",status:500});if(!O(r))throw f(e,`Cron job "${t}" has an invalid cron expression "${r}" — expected 5 or 6 space-separated fields.`,{code:"CRON_EXPR_INVALID",name:"LunoraError",status:500});return S(r,`cron expression for job "${t}"`),r},M=(e,t,r)=>{const n=e.getArguments()[1];if(!n||!s.isObjectLiteralExpression(n))throw f(e,`Cron job "${r}" must pass an object-literal schedule to ".${t}(...)".`,{code:"CRON_SCHEDULE_NOT_STATIC",name:"LunoraError",status:500});try{return b(t,m(n,r),r)}catch(i){if(i instanceof I)throw i;const o=i instanceof Error?i.message.replace(k,""):String(i);throw f(e,o,{code:"CRON_SCHEDULE_INVALID",name:"LunoraError",status:500})}},z=(e,t,r,n,i)=>{const o=t.getName();if(!D.has(o)||!r.has(V(t.getExpression())??""))return;const a=x(e,0);if(a===void 0||a.trim()==="")throw f(e,`A cron ".${o}(...)" registration must pass a non-empty string-literal name as its first argument.`,{code:"CRON_NAME_NOT_STATIC",name:"LunoraError",status:500});const c=o==="cron"?U(e,a):M(e,o,a),u=j(e,2,a,n,i),l=e.getArguments()[3];return{args:l&&s.isObjectLiteralExpression(l)?m(l,a):{},cron:c,name:a,...u}},H=e=>{const t=new Set;for(const r of e){if(t.has(r.name))throw new L("DUPLICATE_CRON_NAME",`Duplicate cron job name "${r.name}": cron names must be unique across the project.`,{status:500});t.add(r.name)}},W=(e,t,r=[],n=[])=>{const i=y(t),o=[],a=new Map(r.map(u=>[u.exportName,u])),c=new Map(n.map(u=>[u.exportName,u]));for(const u of i){const l=e.getSourceFile(u)??e.addSourceFileAtPath(u),g=F(l);if(g.size!==0)for(const d of l.getDescendantsOfKind(p.CallExpression)){const N=d.getExpression();if(!s.isPropertyAccessExpression(N))continue;const E=z(d,N,g,a,c);E&&o.push(E)}}return o.sort((u,l)=>u.name.localeCompare(l.name)),H(o),o};export{W as default};
@@ -0,0 +1 @@
1
+ import{d as P}from"./declared-output-Iaar469J.mjs";import{s as b}from"./paths-C-9fwEgQ.mjs";import{findObjectProperty as c,bindingKeyName as A,listLunoraSourceFiles as F,lunoraRelativePath as N}from"./listLunoraSourceFiles-vjwjgpjd.mjs";import{u as y,p as O,c as m,r as z}from"./unwrap-handler-return-C1OS0xP8.mjs";import{b as d,c as C}from"./classify-procedure-call-CZU6n3yF.mjs";import{Node as n,SyntaxKind as S}from"ts-morph";import{r as h,p as x,a as L}from"./parse-validator-2u-Io0i5.mjs";const k=i=>{const t=i.getArguments()[0];if(!t||!n.isObjectLiteralExpression(t))return"unknown";const e=c(t,"handler");if(!e||!n.isPropertyAssignment(e))return"unknown";const r=e.getInitializer();return!r||!(n.isArrowFunction(r)||n.isFunctionExpression(r))?"unknown":y(r)},I=i=>{const t=i.getArguments()[0];return!t||!(n.isArrowFunction(t)||n.isFunctionExpression(t))?"unknown":y(t)},T=i=>{let t={};for(const e of d(i)){if(e.name!=="input")continue;const r=e.call.getArguments()[0],s=r!==void 0&&n.isExpression(r)?h(r):void 0;s!==void 0&&(t={...x(s),...t})}return t},V=i=>{const t=d(i).find(r=>r.name==="output");if(!t)return;const e=t.call.getArguments()[0];return e&&n.isExpression(e)?O(t.call,()=>L(e)):void 0},p=(i,t)=>{const e=c(i,t);if(e===void 0||!n.isPropertyAssignment(e))return;const r=e.getInitializer();return r!==void 0&&n.isStringLiteral(r)?r.getLiteralValue():void 0},v=(i,t)=>{const e=c(i,t);if(e===void 0||!n.isPropertyAssignment(e))return;const r=e.getInitializer();return r!==void 0&&n.isNumericLiteral(r)?r.getLiteralValue():void 0},w=i=>{const t=c(i,"cache");if(t===void 0||!n.isPropertyAssignment(t))return;const e=t.getInitializer();if(e===void 0||!n.isObjectLiteralExpression(e))return;const r=p(e,"scope"),s=v(e,"maxAge"),o=v(e,"staleWhileRevalidate"),a=p(e,"tag"),l=p(e,"vary"),g={...s===void 0?{}:{maxAge:s},...r==="private"||r==="public"?{scope:r}:{},...o===void 0?{}:{staleWhileRevalidate:o},...a===void 0?{}:{tag:a},...l===void 0?{}:{vary:l}};return Object.keys(g).length===0?void 0:g},D=i=>{if(i===void 0||!n.isObjectLiteralExpression(i))return{};const t=w(i),e=c(i,"rest");return e!==void 0&&n.isPropertyAssignment(e)?{...t===void 0?{}:{cache:t},rest:e.getInitializer()?.getText()==="true"}:t===void 0?{}:{cache:t}},j=i=>{const t=d(i).find(e=>e.name==="expose");return t?D(t.call.getArguments()[0]):void 0},R=i=>{const t=i.getArguments()[0];if(!t||!n.isObjectLiteralExpression(t))return{};const e=c(t,"args");if(!e||!n.isPropertyAssignment(e))return{};const r=e.getInitializer(),s=r===void 0?void 0:h(r);return s===void 0?{}:x(s)},B=8,u=(i,t=0)=>{if(t>B)return;if(n.isCallExpression(i))return i;if(n.isParenthesizedExpression(i)||n.isAsExpression(i)||n.isSatisfiesExpression(i)||n.isNonNullExpression(i))return u(i.getExpression(),t+1);if(!n.isIdentifier(i)&&!n.isPropertyAccessExpression(i))return;const e=i.getSymbol()?.getValueDeclaration();return e?f(e,t+1):void 0},f=(i,t)=>{if(n.isVariableDeclaration(i)||n.isPropertyAssignment(i)){const e=i.getInitializer();return e?u(e,t):void 0}if(n.isShorthandPropertyAssignment(i)){const e=i.getValueSymbol()?.getValueDeclaration();return e?f(e,t+1):void 0}if(n.isBindingElement(i)){const e=A(i),o=i.getFirstAncestorByKind(S.VariableDeclaration)?.getInitializer()?.getType().getProperty(e)?.getValueDeclaration();return o?f(o,t+1):void 0}},$=i=>{const t=i.getNameNode();if(n.isObjectBindingPattern(t)){const s=[];for(const o of t.getElements()){const a=u(o.getNameNode());a&&s.push([o.getName(),a])}return s}const e=i.getInitializer(),r=e&&(n.isCallExpression(e)?e:u(e));return r?[[i.getName(),r]]:[]},W=i=>{const t=C(i);if(!t)return;const{receiver:e}=t;if(e){const r=j(e),s=m(()=>V(e)),o=m(()=>I(i)),a=P({kind:t.kind,output:s.value});return z(a?s.erased:o.erased),{args:T(e),...r?{expose:r}:{},kind:t.kind,...s.value?{output:s.value}:{},returnType:o.value,visibility:t.visibility}}return t.lifecycle?{args:{},kind:t.kind,lifecycle:t.lifecycle,returnType:"void",visibility:t.visibility}:{args:R(i),kind:t.kind,returnType:k(i),visibility:t.visibility}},E=(i,t,e)=>{const r=W(i);if(r)return{args:r.args,exportName:t,filePath:e,kind:r.kind,returnType:r.returnType,...r.output?{output:r.output}:{},visibility:r.visibility,...r.expose?{expose:r.expose}:{},...r.lifecycle?{lifecycle:r.lifecycle}:{}}},_=(i,t)=>{const e=[];for(const r of i.getExportAssignments()){if(r.isExportEquals())continue;const s=u(r.getExpression()),o=s?E(s,"default",t):void 0;o&&e.push(o)}return e},H=(i,t)=>{const e=[];for(const r of i.getVariableStatements())if(r.isExported())for(const s of r.getDeclarations())for(const[o,a]of $(s)){const l=E(a,o,t);l&&e.push(l)}return e.push(..._(i,t)),e},K=i=>{const t=new Map;for(const e of i){const r=b(e.filePath),s=t.get(r);if(s&&s!==e.filePath)throw Object.assign(new Error(`Namespace collision: "${s}" and "${e.filePath}" both resolve to "${r}". Rename one of the files so the JS-identifier-sanitized names differ. (note: case-insensitive filesystems may also cause this — \`foo\` and \`FOO\` map to the same identifier)`),{code:"NAMESPACE_COLLISION",name:"LunoraError",paths:[s,e.filePath],status:500});t.set(r,e.filePath)}},Y=(i,t)=>{const e=F(t),r=[];for(const s of e){const o=i.getSourceFile(s)??i.addSourceFileAtPath(s),a=N(t,s);r.push(...H(o,a))}return r.sort((s,o)=>`${s.filePath}:${s.exportName}`.localeCompare(`${o.filePath}:${o.exportName}`)),K(r),r};export{Y as default};
@@ -1 +1 @@
1
- import{Node as i}from"ts-morph";import{a as m,p as l}from"./parse-validator-DW5RNi_6.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./listLunoraSourceFiles-DsxeRYvh.mjs";import{u as f}from"./unwrap-handler-return-BEdusskg.mjs";const u=new Set(["delete","get","head","options","patch","post","put"]),g=new Set(["body","params","searchParams"]),E=new Set(["handler","stream"]),v=r=>{const e=r.getArguments()[0];if(e&&i.isStringLiteral(e))return e.getLiteralValue()},x=r=>{const e=r.getArguments()[0];return e&&i.isObjectLiteralExpression(e)?l(e):{}},P=r=>{if(!i.isCallExpression(r))return;const e=r.getExpression();if(!i.isPropertyAccessExpression(e))return;const o=e.getName();if(!u.has(o))return;const n=e.getExpression();if(!i.isIdentifier(n)||n.getText()!=="httpRoute")return;const s=v(r);return s===void 0?void 0:{method:o.toUpperCase(),path:s}},S=(r,e)=>{const o={body:{},params:{},searchParams:{},stream:e==="stream"},n=r.getExpression();if(!i.isPropertyAccessExpression(n))return;let s=n.getExpression();for(;i.isCallExpression(s);){const a=s.getExpression();if(!i.isPropertyAccessExpression(a))break;const c=a.getName();if(u.has(c))break;if(g.has(c)){const p=x(s);o[c]={...p,...o[c]}}else if(c==="output"&&o.output===void 0){const p=s.getArguments()[0];p&&i.isExpression(p)&&(o.output=m(p))}s=a.getExpression()}const t=P(s);if(t)return o.method=t.method,o.path=t.path,o},A=r=>{const e=r.getArguments()[0];return!e||!(i.isArrowFunction(e)||i.isFunctionExpression(e))?"unknown":f(e)},T=(r,e,o,n)=>{const s=e.getName();if(!E.has(s))return;const t=S(r,s);if(!(t?.method===void 0||t.path===void 0))return{body:t.body,exportName:o,filePath:n,method:t.method,params:t.params,path:t.path,searchParams:t.searchParams,stream:t.stream,...t.stream?{chunkType:A(r)}:{},...t.output?{output:t.output}:{}}},b=(r,e)=>{const o=[];for(const n of r.getVariableStatements())if(n.isExported())for(const s of n.getDeclarations()){const t=s.getInitializer();if(!t||!i.isCallExpression(t))continue;const a=t.getExpression();if(!i.isPropertyAccessExpression(a))continue;const c=T(t,a,s.getName(),e);c&&o.push(c)}return o},F=(r,e)=>{const o=d(e),n=[];for(const s of o){const t=r.getSourceFile(s)??r.addSourceFileAtPath(s),a=h(e,s);n.push(...b(t,a))}return n.sort((s,t)=>`${s.method} ${s.path}`.localeCompare(`${t.method} ${t.path}`)||s.filePath.localeCompare(t.filePath)),n};export{F as default};
1
+ import{Node as i}from"ts-morph";import{a as m,p as l}from"./parse-validator-2u-Io0i5.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./listLunoraSourceFiles-vjwjgpjd.mjs";import{u as f}from"./unwrap-handler-return-C1OS0xP8.mjs";const u=new Set(["delete","get","head","options","patch","post","put"]),g=new Set(["body","params","searchParams"]),E=new Set(["handler","stream"]),v=r=>{const e=r.getArguments()[0];if(e&&i.isStringLiteral(e))return e.getLiteralValue()},x=r=>{const e=r.getArguments()[0];return e&&i.isObjectLiteralExpression(e)?l(e):{}},P=r=>{if(!i.isCallExpression(r))return;const e=r.getExpression();if(!i.isPropertyAccessExpression(e))return;const o=e.getName();if(!u.has(o))return;const n=e.getExpression();if(!i.isIdentifier(n)||n.getText()!=="httpRoute")return;const s=v(r);return s===void 0?void 0:{method:o.toUpperCase(),path:s}},S=(r,e)=>{const o={body:{},params:{},searchParams:{},stream:e==="stream"},n=r.getExpression();if(!i.isPropertyAccessExpression(n))return;let s=n.getExpression();for(;i.isCallExpression(s);){const a=s.getExpression();if(!i.isPropertyAccessExpression(a))break;const c=a.getName();if(u.has(c))break;if(g.has(c)){const p=x(s);o[c]={...p,...o[c]}}else if(c==="output"&&o.output===void 0){const p=s.getArguments()[0];p&&i.isExpression(p)&&(o.output=m(p))}s=a.getExpression()}const t=P(s);if(t)return o.method=t.method,o.path=t.path,o},A=r=>{const e=r.getArguments()[0];return!e||!(i.isArrowFunction(e)||i.isFunctionExpression(e))?"unknown":f(e)},T=(r,e,o,n)=>{const s=e.getName();if(!E.has(s))return;const t=S(r,s);if(!(t?.method===void 0||t.path===void 0))return{body:t.body,exportName:o,filePath:n,method:t.method,params:t.params,path:t.path,searchParams:t.searchParams,stream:t.stream,...t.stream?{chunkType:A(r)}:{},...t.output?{output:t.output}:{}}},b=(r,e)=>{const o=[];for(const n of r.getVariableStatements())if(n.isExported())for(const s of n.getDeclarations()){const t=s.getInitializer();if(!t||!i.isCallExpression(t))continue;const a=t.getExpression();if(!i.isPropertyAccessExpression(a))continue;const c=T(t,a,s.getName(),e);c&&o.push(c)}return o},F=(r,e)=>{const o=d(e),n=[];for(const s of o){const t=r.getSourceFile(s)??r.addSourceFileAtPath(s),a=h(e,s);n.push(...b(t,a))}return n.sort((s,t)=>`${s.method} ${s.path}`.localeCompare(`${t.method} ${t.path}`)||s.filePath.localeCompare(t.filePath)),n};export{F as default};
@@ -0,0 +1 @@
1
+ import{d as o}from"./context-property-calls-ClziPULs.mjs";const t=(r,e)=>o(r,e,"sql");export{t as default};