@lunora/codegen 1.0.0-alpha.164 → 1.0.0-alpha.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2207,6 +2207,7 @@ declare const CAPABILITY_ROWS: readonly [{
2207
2207
  readonly contextProperty: "access";
2208
2208
  readonly key: "access";
2209
2209
  readonly moduleSpecifier: "@lunora/cloudflare-access";
2210
+ readonly requiredPackage: "@lunora/cloudflare-access";
2210
2211
  }, {
2211
2212
  readonly appMethod: {
2212
2213
  readonly configKey: "ai";
@@ -2216,6 +2217,7 @@ declare const CAPABILITY_ROWS: readonly [{
2216
2217
  readonly contextProperty: "ai";
2217
2218
  readonly key: "ai";
2218
2219
  readonly moduleSpecifier: "@lunora/ai";
2220
+ readonly requiredPackage: "@lunora/ai";
2219
2221
  }, {
2220
2222
  readonly appMethod: {
2221
2223
  readonly configKey: "analytics";
@@ -2225,6 +2227,7 @@ declare const CAPABILITY_ROWS: readonly [{
2225
2227
  readonly contextProperty: "analytics";
2226
2228
  readonly key: "analytics";
2227
2229
  readonly moduleSpecifier: "@lunora/bindings/analytics";
2230
+ readonly requiredPackage: "@lunora/bindings";
2228
2231
  readonly serverCtxField: {
2229
2232
  readonly field: "\n /** Analytics Engine telemetry sink. Fire-and-forget and sampled; do not read it back in-handler. */\n readonly analytics: import(\"@lunora/bindings/analytics\").AnalyticsClient;";
2230
2233
  readonly tier: "every";
@@ -2238,6 +2241,7 @@ declare const CAPABILITY_ROWS: readonly [{
2238
2241
  readonly contextProperty: "browser";
2239
2242
  readonly key: "browser";
2240
2243
  readonly moduleSpecifier: "@lunora/browser";
2244
+ readonly requiredPackage: "@lunora/browser";
2241
2245
  readonly serverCtxField: {
2242
2246
  readonly field: "\n /** Browser Rendering (screenshots/PDF/scrape). Non-deterministic — available only in actions. */\n readonly browser: import(\"@lunora/browser\").Browser;";
2243
2247
  readonly tier: "action";
@@ -2259,6 +2263,7 @@ declare const CAPABILITY_ROWS: readonly [{
2259
2263
  readonly contextProperty: "sql";
2260
2264
  readonly key: "hyperdrive";
2261
2265
  readonly moduleSpecifier: "@lunora/hyperdrive";
2266
+ readonly requiredPackage: "@lunora/hyperdrive";
2262
2267
  readonly serverCtxField: {
2263
2268
  readonly field: "\n /**\n * External database access via Hyperdrive. Non-deterministic — available only in actions. Writes here are NOT tracked by Lunora live queries; subscriptions will not re-run on external DB changes.\n */\n readonly sql: import(\"@lunora/hyperdrive\").SqlClient;";
2264
2269
  readonly tier: "action";
@@ -2272,6 +2277,7 @@ declare const CAPABILITY_ROWS: readonly [{
2272
2277
  readonly contextProperty: "images";
2273
2278
  readonly key: "images";
2274
2279
  readonly moduleSpecifier: "@lunora/bindings/images";
2280
+ readonly requiredPackage: "@lunora/bindings";
2275
2281
  readonly serverCtxField: {
2276
2282
  readonly field: "\n /** Cloudflare Images transforms (resize/format/optimize). Non-deterministic — available only in actions. */\n readonly images: import(\"@lunora/bindings/images\").Images;";
2277
2283
  readonly tier: "action";
@@ -2285,6 +2291,7 @@ declare const CAPABILITY_ROWS: readonly [{
2285
2291
  readonly contextProperty: "kv";
2286
2292
  readonly key: "kv";
2287
2293
  readonly moduleSpecifier: "@lunora/bindings/kv";
2294
+ readonly requiredPackage: "@lunora/bindings";
2288
2295
  readonly serverCtxField: {
2289
2296
  readonly field: "\n readonly kv: import(\"@lunora/bindings/kv\").Kv;";
2290
2297
  readonly tier: "every";
@@ -2305,6 +2312,7 @@ declare const CAPABILITY_ROWS: readonly [{
2305
2312
  readonly contextProperty: "payments";
2306
2313
  readonly key: "payments";
2307
2314
  readonly moduleSpecifier: "@lunora/payment";
2315
+ readonly requiredPackage: "@lunora/payment";
2308
2316
  }, {
2309
2317
  readonly appMethod: {
2310
2318
  readonly configKey: "x402";
@@ -2314,10 +2322,12 @@ declare const CAPABILITY_ROWS: readonly [{
2314
2322
  readonly contextProperty: "x402";
2315
2323
  readonly key: "x402";
2316
2324
  readonly moduleSpecifier: "@lunora/x402/pay";
2325
+ readonly requiredPackage: "@lunora/x402";
2317
2326
  }, {
2318
2327
  readonly contextProperty: "pipelines";
2319
2328
  readonly key: "pipelines";
2320
2329
  readonly moduleSpecifier: "@lunora/bindings/pipelines";
2330
+ readonly requiredPackage: "@lunora/bindings";
2321
2331
  readonly serverCtxField: {
2322
2332
  readonly field: "\n /** Pipelines ingestion sink (durable, R2-backed). Fire-and-forget and batched; do not read it back in-handler. */\n readonly pipelines: import(\"@lunora/bindings/pipelines\").PipelineClient;";
2323
2333
  readonly tier: "action";
@@ -2331,6 +2341,7 @@ declare const CAPABILITY_ROWS: readonly [{
2331
2341
  readonly contextProperty: "r2sql";
2332
2342
  readonly key: "r2sql";
2333
2343
  readonly moduleSpecifier: "@lunora/bindings/r2sql";
2344
+ readonly requiredPackage: "@lunora/bindings";
2334
2345
  readonly serverCtxField: {
2335
2346
  readonly field: "\n /**\n * R2 SQL over Apache Iceberg tables (window functions, DISTINCT, set operations). Non-deterministic — available only in actions. Reads here are NOT tracked by Lunora live queries.\n */\n readonly r2sql: import(\"@lunora/bindings/r2sql\").R2SqlClient;";
2336
2347
  readonly tier: "action";
package/dist/index.d.ts CHANGED
@@ -2207,6 +2207,7 @@ declare const CAPABILITY_ROWS: readonly [{
2207
2207
  readonly contextProperty: "access";
2208
2208
  readonly key: "access";
2209
2209
  readonly moduleSpecifier: "@lunora/cloudflare-access";
2210
+ readonly requiredPackage: "@lunora/cloudflare-access";
2210
2211
  }, {
2211
2212
  readonly appMethod: {
2212
2213
  readonly configKey: "ai";
@@ -2216,6 +2217,7 @@ declare const CAPABILITY_ROWS: readonly [{
2216
2217
  readonly contextProperty: "ai";
2217
2218
  readonly key: "ai";
2218
2219
  readonly moduleSpecifier: "@lunora/ai";
2220
+ readonly requiredPackage: "@lunora/ai";
2219
2221
  }, {
2220
2222
  readonly appMethod: {
2221
2223
  readonly configKey: "analytics";
@@ -2225,6 +2227,7 @@ declare const CAPABILITY_ROWS: readonly [{
2225
2227
  readonly contextProperty: "analytics";
2226
2228
  readonly key: "analytics";
2227
2229
  readonly moduleSpecifier: "@lunora/bindings/analytics";
2230
+ readonly requiredPackage: "@lunora/bindings";
2228
2231
  readonly serverCtxField: {
2229
2232
  readonly field: "\n /** Analytics Engine telemetry sink. Fire-and-forget and sampled; do not read it back in-handler. */\n readonly analytics: import(\"@lunora/bindings/analytics\").AnalyticsClient;";
2230
2233
  readonly tier: "every";
@@ -2238,6 +2241,7 @@ declare const CAPABILITY_ROWS: readonly [{
2238
2241
  readonly contextProperty: "browser";
2239
2242
  readonly key: "browser";
2240
2243
  readonly moduleSpecifier: "@lunora/browser";
2244
+ readonly requiredPackage: "@lunora/browser";
2241
2245
  readonly serverCtxField: {
2242
2246
  readonly field: "\n /** Browser Rendering (screenshots/PDF/scrape). Non-deterministic — available only in actions. */\n readonly browser: import(\"@lunora/browser\").Browser;";
2243
2247
  readonly tier: "action";
@@ -2259,6 +2263,7 @@ declare const CAPABILITY_ROWS: readonly [{
2259
2263
  readonly contextProperty: "sql";
2260
2264
  readonly key: "hyperdrive";
2261
2265
  readonly moduleSpecifier: "@lunora/hyperdrive";
2266
+ readonly requiredPackage: "@lunora/hyperdrive";
2262
2267
  readonly serverCtxField: {
2263
2268
  readonly field: "\n /**\n * External database access via Hyperdrive. Non-deterministic — available only in actions. Writes here are NOT tracked by Lunora live queries; subscriptions will not re-run on external DB changes.\n */\n readonly sql: import(\"@lunora/hyperdrive\").SqlClient;";
2264
2269
  readonly tier: "action";
@@ -2272,6 +2277,7 @@ declare const CAPABILITY_ROWS: readonly [{
2272
2277
  readonly contextProperty: "images";
2273
2278
  readonly key: "images";
2274
2279
  readonly moduleSpecifier: "@lunora/bindings/images";
2280
+ readonly requiredPackage: "@lunora/bindings";
2275
2281
  readonly serverCtxField: {
2276
2282
  readonly field: "\n /** Cloudflare Images transforms (resize/format/optimize). Non-deterministic — available only in actions. */\n readonly images: import(\"@lunora/bindings/images\").Images;";
2277
2283
  readonly tier: "action";
@@ -2285,6 +2291,7 @@ declare const CAPABILITY_ROWS: readonly [{
2285
2291
  readonly contextProperty: "kv";
2286
2292
  readonly key: "kv";
2287
2293
  readonly moduleSpecifier: "@lunora/bindings/kv";
2294
+ readonly requiredPackage: "@lunora/bindings";
2288
2295
  readonly serverCtxField: {
2289
2296
  readonly field: "\n readonly kv: import(\"@lunora/bindings/kv\").Kv;";
2290
2297
  readonly tier: "every";
@@ -2305,6 +2312,7 @@ declare const CAPABILITY_ROWS: readonly [{
2305
2312
  readonly contextProperty: "payments";
2306
2313
  readonly key: "payments";
2307
2314
  readonly moduleSpecifier: "@lunora/payment";
2315
+ readonly requiredPackage: "@lunora/payment";
2308
2316
  }, {
2309
2317
  readonly appMethod: {
2310
2318
  readonly configKey: "x402";
@@ -2314,10 +2322,12 @@ declare const CAPABILITY_ROWS: readonly [{
2314
2322
  readonly contextProperty: "x402";
2315
2323
  readonly key: "x402";
2316
2324
  readonly moduleSpecifier: "@lunora/x402/pay";
2325
+ readonly requiredPackage: "@lunora/x402";
2317
2326
  }, {
2318
2327
  readonly contextProperty: "pipelines";
2319
2328
  readonly key: "pipelines";
2320
2329
  readonly moduleSpecifier: "@lunora/bindings/pipelines";
2330
+ readonly requiredPackage: "@lunora/bindings";
2321
2331
  readonly serverCtxField: {
2322
2332
  readonly field: "\n /** Pipelines ingestion sink (durable, R2-backed). Fire-and-forget and batched; do not read it back in-handler. */\n readonly pipelines: import(\"@lunora/bindings/pipelines\").PipelineClient;";
2323
2333
  readonly tier: "action";
@@ -2331,6 +2341,7 @@ declare const CAPABILITY_ROWS: readonly [{
2331
2341
  readonly contextProperty: "r2sql";
2332
2342
  readonly key: "r2sql";
2333
2343
  readonly moduleSpecifier: "@lunora/bindings/r2sql";
2344
+ readonly requiredPackage: "@lunora/bindings";
2334
2345
  readonly serverCtxField: {
2335
2346
  readonly field: "\n /**\n * R2 SQL over Apache Iceberg tables (window functions, DISTINCT, set operations). Non-deterministic — available only in actions. Reads here are NOT tracked by Lunora live queries.\n */\n readonly r2sql: import(\"@lunora/bindings/r2sql\").R2SqlClient;";
2336
2347
  readonly tier: "action";
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-CWESEYLi.mjs";import{formatAdvisories as m,lintSchema as d,toAdvisorContext as f}from"./packem_shared/formatAdvisories-CkEu1eye.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-DHk9gO3E.mjs";import{listLunoraSourceFiles as g}from"./packem_shared/listLunoraSourceFiles-lHrzFhbX.mjs";import{default as R}from"./packem_shared/discoverAuthApiCalls-mYYZYULR.mjs";import{CONTAINERS_FILENAME as M,discoverContainers as h}from"./packem_shared/CONTAINERS_FILENAME-CqSjcb1-.mjs";import{default as L}from"./packem_shared/discoverCrons-C-GrcmEj.mjs";import{FLAGS_FILENAME as I,discoverFlags as F}from"./packem_shared/FLAGS_FILENAME-Uzu2mD86.mjs";import{default as P}from"./packem_shared/discoverFunctions-BJQ_rvqv.mjs";import{default as G}from"./packem_shared/discoverHttpRoutes-Bsu4ctdh.mjs";import{default as b}from"./packem_shared/discoverHyperdriveCalls-jqn--Zkc.mjs";import{default as y}from"./packem_shared/discoverInserts-Bbw_Fkid.mjs";import{d as j}from"./packem_shared/index-D322boXY.mjs";import{default as V}from"./packem_shared/discoverMigrations-ChOwLUzQ.mjs";import{MUTATORS_FILENAME as Q,discoverMutators as w}from"./packem_shared/MUTATORS_FILENAME-DHX1qUP5.mjs";import{default as B}from"./packem_shared/discoverNondeterministicCalls-Cesk1Srg.mjs";import{NOTIFY_FILENAME as Y,discoverNotifyCalls as X,discoverNotifyConfig as Z}from"./packem_shared/NOTIFY_FILENAME-a3lg_dJ9.mjs";import{default as ee}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as oe}from"./packem_shared/queries-C3PDsG0y.mjs";import{QUEUES_FILENAME as se,discoverQueues as ae}from"./packem_shared/QUEUES_FILENAME-BZ6Ak3QY.mjs";import{default as me}from"./packem_shared/discoverR2sqlCalls-DW4RO223.mjs";import{default as fe}from"./packem_shared/discoverRlsProcedures-iPEyaH0Q.mjs";import{default as ce}from"./packem_shared/discoverRlsMetadata-pjWjG15I.mjs";import{discoverSandboxUsage as le}from"./packem_shared/discoverSandboxUsage-zLtQHdkg.mjs";import{default as xe}from"./packem_shared/discoverSchema-C4znXEB-.mjs";import{SHAPES_FILENAME as Ae,discoverShapes as ue}from"./packem_shared/SHAPES_FILENAME-DhZ3JkkH.mjs";import{default as Ne}from"./packem_shared/discoverStorageRulesMetadata-B1gekVBr.mjs";import{WORKFLOWS_FILENAME as Oe,discoverWorkflows as Re}from"./packem_shared/WORKFLOWS_FILENAME-CXgbWxbT.mjs";import{G as Me,e as he,a as _e,b as Le,c as Te,d as Ie,f as Fe,g as De,h as Pe,i as Ue,j as Ge,k as He,l as be,m as ke}from"./packem_shared/emit-BNdsZPcd.mjs";import{emitApp as We}from"./packem_shared/emitApp-CxmA4W3C.mjs";import{buildOpenApiDocument as Ke,emitOpenApi as Ve,emitOpenApiModule as ze}from"./packem_shared/buildOpenApiDocument-qYjkmRTX.mjs";import{OPENRPC_VERSION as we,buildOpenRpcDocument as qe,emitOpenRpc as Be,emitOpenRpcModule as Je}from"./packem_shared/OPENRPC_VERSION-BgLkvCYK.mjs";import{DEFAULT_TARGET as Xe,platformMatrixIds as Ze,readProjectTarget as $e,resolveCodegenTarget as er}from"./packem_shared/DEFAULT_TARGET-lPq34YeN.mjs";import{SCHEMA_SNAPSHOT_FILENAME as or,createCodegenProject as tr,findTsconfig as sr,refreshCodegenProject as ar,runCodegen as ir}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-C9nFNiHX.mjs";import{SchemaSnapshotParseError as dr,buildSchemaSnapshot as fr,evaluateSchemaDrift as pr,parseSchemaSnapshot as cr}from"./packem_shared/SchemaSnapshotParseError-yrVM8bTa.mjs";import{schemaFromIr as lr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as xr,validatorIrToJsonSchema as Er}from"./packem_shared/LUNORA_ERROR_CODES-CW7-uASH.mjs";import{SDK_LANGUAGES as ur,SDK_TARGETS as vr,generateSdk as Nr}from"./packem_shared/SDK_LANGUAGES-CFyux-74.mjs";import{redact as Or,secretKindOf as Rr}from"./packem_shared/redact-Cy14LEnc.mjs";import{MESSAGE_SOLUTIONS as Mr,findSolutionByMessage as hr}from"@lunora/errors";import{isTypedSchema as Lr}from"./packem_shared/isTypedSchema-B_qlBbE-.mjs";const e="0.0.0";export{u as AGENTS_FILENAME,M as CONTAINERS_FILENAME,x as CodegenDiagnosticError,Xe as DEFAULT_TARGET,I as FLAGS_FILENAME,Me as GENERATED_HEADER,xr as LUNORA_ERROR_CODES,Mr as LUNORA_SOLUTION_RULES,Q as MUTATORS_FILENAME,Y as NOTIFY_FILENAME,we as OPENRPC_VERSION,se as QUEUES_FILENAME,or as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,ur as SDK_LANGUAGES,vr as SDK_TARGETS,Ae as SHAPES_FILENAME,dr as SchemaSnapshotParseError,e as VERSION,Oe as WORKFLOWS_FILENAME,Ke as buildOpenApiDocument,qe as buildOpenRpcDocument,fr as buildSchemaSnapshot,tr as createCodegenProject,c as describeErrorLevelFindings,E as diagnosticAt,s as diffSchemaSnapshots,v as discoverAgents,R as discoverAuthApiCalls,h as discoverContainers,L as discoverCrons,F as discoverFlags,P as discoverFunctions,G as discoverHttpRoutes,b as discoverHyperdriveCalls,y as discoverInserts,j as discoverMaskProcedures,V as discoverMigrations,w as discoverMutators,B 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,Re as discoverWorkflows,he as emitAgents,_e as emitApi,We as emitApp,Le as emitCollections,Te as emitContainers,Ie as emitCrons,Fe as emitDataModel,De as emitDrizzleSchema,Pe as emitFunctions,Ve as emitOpenApi,ze as emitOpenApiModule,Be as emitOpenRpc,Je as emitOpenRpcModule,Ue as emitServer,Ge as emitShard,He as emitVectors,be as emitWorkflows,ke as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,pr as evaluateSchemaDrift,hr as findLunoraSolution,sr as findTsconfig,m as formatAdvisories,Nr as generateSdk,Lr as isTypedSchema,d as lintSchema,g as listLunoraSourceFiles,cr as parseSchemaSnapshot,Ze as platformMatrixIds,ee as readPackageDependencies,$e as readProjectTarget,Or as redact,ar as refreshCodegenProject,er as resolveCodegenTarget,ir as runCodegen,lr as schemaFromIr,Rr as secretKindOf,a as serializeSchemaSnapshot,f as toAdvisorContext,Er as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-CWESEYLi.mjs";import{formatAdvisories as m,lintSchema as d,toAdvisorContext as f}from"./packem_shared/formatAdvisories-CkEu1eye.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-DHk9gO3E.mjs";import{listLunoraSourceFiles as g}from"./packem_shared/listLunoraSourceFiles-lHrzFhbX.mjs";import{default as R}from"./packem_shared/discoverAuthApiCalls-mYYZYULR.mjs";import{CONTAINERS_FILENAME as M,discoverContainers as h}from"./packem_shared/CONTAINERS_FILENAME-CqSjcb1-.mjs";import{default as L}from"./packem_shared/discoverCrons-C-GrcmEj.mjs";import{FLAGS_FILENAME as I,discoverFlags as F}from"./packem_shared/FLAGS_FILENAME-Uzu2mD86.mjs";import{default as P}from"./packem_shared/discoverFunctions-DKq2c91M.mjs";import{default as G}from"./packem_shared/discoverHttpRoutes-BYTh2RPR.mjs";import{default as b}from"./packem_shared/discoverHyperdriveCalls-jqn--Zkc.mjs";import{default as y}from"./packem_shared/discoverInserts-Bbw_Fkid.mjs";import{d as j}from"./packem_shared/index-D322boXY.mjs";import{default as V}from"./packem_shared/discoverMigrations-ChOwLUzQ.mjs";import{MUTATORS_FILENAME as Q,discoverMutators as w}from"./packem_shared/MUTATORS_FILENAME-CTHlZ1j6.mjs";import{default as B}from"./packem_shared/discoverNondeterministicCalls-Cesk1Srg.mjs";import{NOTIFY_FILENAME as Y,discoverNotifyCalls as X,discoverNotifyConfig as Z}from"./packem_shared/NOTIFY_FILENAME-a3lg_dJ9.mjs";import{default as ee}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{d as oe}from"./packem_shared/queries-C3PDsG0y.mjs";import{QUEUES_FILENAME as se,discoverQueues as ae}from"./packem_shared/QUEUES_FILENAME-BZ6Ak3QY.mjs";import{default as me}from"./packem_shared/discoverR2sqlCalls-DW4RO223.mjs";import{default as fe}from"./packem_shared/discoverRlsProcedures-iPEyaH0Q.mjs";import{default as ce}from"./packem_shared/discoverRlsMetadata-pjWjG15I.mjs";import{discoverSandboxUsage as le}from"./packem_shared/discoverSandboxUsage-zLtQHdkg.mjs";import{default as xe}from"./packem_shared/discoverSchema-DoZtXwLg.mjs";import{SHAPES_FILENAME as Ae,discoverShapes as ue}from"./packem_shared/SHAPES_FILENAME-Bvd5kgsF.mjs";import{default as Ne}from"./packem_shared/discoverStorageRulesMetadata-B1gekVBr.mjs";import{WORKFLOWS_FILENAME as Oe,discoverWorkflows as Re}from"./packem_shared/WORKFLOWS_FILENAME-CXgbWxbT.mjs";import{G as Me,e as he,a as _e,b as Le,c as Te,d as Ie,f as Fe,g as De,h as Pe,i as Ue,j as Ge,k as He,l as be,m as ke}from"./packem_shared/emit-Lx7UkoGn.mjs";import{emitApp as We}from"./packem_shared/emitApp-9dMkNu6n.mjs";import{buildOpenApiDocument as Ke,emitOpenApi as Ve,emitOpenApiModule as ze}from"./packem_shared/buildOpenApiDocument-CE9SDrBg.mjs";import{OPENRPC_VERSION as we,buildOpenRpcDocument as qe,emitOpenRpc as Be,emitOpenRpcModule as Je}from"./packem_shared/OPENRPC_VERSION-DlF2XS7T.mjs";import{DEFAULT_TARGET as Xe,platformMatrixIds as Ze,readProjectTarget as $e,resolveCodegenTarget as er}from"./packem_shared/DEFAULT_TARGET-lPq34YeN.mjs";import{SCHEMA_SNAPSHOT_FILENAME as or,createCodegenProject as tr,findTsconfig as sr,refreshCodegenProject as ar,runCodegen as ir}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-CSSteiiq.mjs";import{SchemaSnapshotParseError as dr,buildSchemaSnapshot as fr,evaluateSchemaDrift as pr,parseSchemaSnapshot as cr}from"./packem_shared/SchemaSnapshotParseError-yrVM8bTa.mjs";import{schemaFromIr as lr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as xr,validatorIrToJsonSchema as Er}from"./packem_shared/LUNORA_ERROR_CODES-CW7-uASH.mjs";import{SDK_LANGUAGES as ur,SDK_TARGETS as vr,generateSdk as Nr}from"./packem_shared/SDK_LANGUAGES-CFyux-74.mjs";import{redact as Or,secretKindOf as Rr}from"./packem_shared/redact-Cy14LEnc.mjs";import{MESSAGE_SOLUTIONS as Mr,findSolutionByMessage as hr}from"@lunora/errors";import{isTypedSchema as Lr}from"./packem_shared/isTypedSchema-B_qlBbE-.mjs";const e="0.0.0";export{u as AGENTS_FILENAME,M as CONTAINERS_FILENAME,x as CodegenDiagnosticError,Xe as DEFAULT_TARGET,I as FLAGS_FILENAME,Me as GENERATED_HEADER,xr as LUNORA_ERROR_CODES,Mr as LUNORA_SOLUTION_RULES,Q as MUTATORS_FILENAME,Y as NOTIFY_FILENAME,we as OPENRPC_VERSION,se as QUEUES_FILENAME,or as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,ur as SDK_LANGUAGES,vr as SDK_TARGETS,Ae as SHAPES_FILENAME,dr as SchemaSnapshotParseError,e as VERSION,Oe as WORKFLOWS_FILENAME,Ke as buildOpenApiDocument,qe as buildOpenRpcDocument,fr as buildSchemaSnapshot,tr as createCodegenProject,c as describeErrorLevelFindings,E as diagnosticAt,s as diffSchemaSnapshots,v as discoverAgents,R as discoverAuthApiCalls,h as discoverContainers,L as discoverCrons,F as discoverFlags,P as discoverFunctions,G as discoverHttpRoutes,b as discoverHyperdriveCalls,y as discoverInserts,j as discoverMaskProcedures,V as discoverMigrations,w as discoverMutators,B 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,Re as discoverWorkflows,he as emitAgents,_e as emitApi,We as emitApp,Le as emitCollections,Te as emitContainers,Ie as emitCrons,Fe as emitDataModel,De as emitDrizzleSchema,Pe as emitFunctions,Ve as emitOpenApi,ze as emitOpenApiModule,Be as emitOpenRpc,Je as emitOpenRpcModule,Ue as emitServer,Ge as emitShard,He as emitVectors,be as emitWorkflows,ke as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,pr as evaluateSchemaDrift,hr as findLunoraSolution,sr as findTsconfig,m as formatAdvisories,Nr as generateSdk,Lr as isTypedSchema,d as lintSchema,g as listLunoraSourceFiles,cr as parseSchemaSnapshot,Ze as platformMatrixIds,ee as readPackageDependencies,$e as readProjectTarget,Or as redact,ar as refreshCodegenProject,er as resolveCodegenTarget,ir as runCodegen,lr as schemaFromIr,Rr as secretKindOf,a as serializeSchemaSnapshot,f as toAdvisorContext,Er as validatorIrToJsonSchema};
@@ -1 +1 @@
1
- import"./SCHEMA_SNAPSHOT_VERSION-CWESEYLi.mjs";import{G as t,U as m,n as r,e as o,a as n,b as l,c as A,d as E,f as S,g,h as C,o as c,p as d,i as p,j as u,k as D,l as f,m as h}from"./emit-BNdsZPcd.mjs";import"./paths-C-9fwEgQ.mjs";export{t as GENERATED_HEADER,m as UMBRELLA_BASE_PACKAGES,r as buildStorageColumns,o as emitAgents,n as emitApi,l as emitCollections,A as emitContainers,E as emitCrons,S as emitDataModel,g as emitDrizzleSchema,C as emitFunctions,c as emitQueues,d as emitSeed,p as emitServer,u as emitShard,D as emitVectors,f as emitWorkflows,h as emitWranglerCronTriggers};
1
+ import"./SCHEMA_SNAPSHOT_VERSION-CWESEYLi.mjs";import{G as t,U as m,n as r,e as o,a as n,b as l,c as A,d as E,f as S,g,h as C,o as c,p as d,i as p,j as u,k as D,l as f,m as h}from"./emit-Lx7UkoGn.mjs";import"./paths-C-9fwEgQ.mjs";export{t as GENERATED_HEADER,m as UMBRELLA_BASE_PACKAGES,r as buildStorageColumns,o as emitAgents,n as emitApi,l as emitCollections,A as emitContainers,E as emitCrons,S as emitDataModel,g as emitDrizzleSchema,C as emitFunctions,c as emitQueues,d as emitSeed,p as emitServer,u as emitShard,D as emitVectors,f as emitWorkflows,h as emitWranglerCronTriggers};
@@ -1 +1 @@
1
- import{existsSync as f}from"node:fs";import{join as p}from"node:path";import{Node as o,SyntaxKind as c}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as g}from"./module-specifiers-WF8iAydP.mjs";import{a as d}from"./parse-validator-CMV0eq2a.mjs";import{u as x}from"./unwrap-handler-return-CmIWbykC.mjs";const M="mutators.ts",m=g,y=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineMutator";for(const e of t.getDeclarations())if(o.isImportSpecifier(e))return m(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineMutator":!1;return!1},S=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&&m(i.getModuleSpecifierValue())}return!1},N=r=>{if(o.isIdentifier(r))return y(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(t)&&S(t)}return!1},I=r=>{const t=r.getArguments()[0];return t&&o.isObjectLiteralExpression(t)?t:void 0},b=r=>{const t=r?.getProperty("args");if(!t||!o.isPropertyAssignment(t))return{};const e=t.getInitializer();return e&&o.isObjectLiteralExpression(e)?d(e):{}},A=r=>{const t=r?.getProperty("server");if(!t||!o.isPropertyAssignment(t))return"unknown";const e=t.getInitializer();return!e||!(o.isArrowFunction(e)||o.isFunctionExpression(e))?"unknown":x(e)},E=r=>{const t=[];for(const e of r.getVariableDeclarations()){if(!e.isExported())continue;const i=e.getInitializer();if(i?.getKind()!==c.CallExpression)continue;const n=i,a=n.getExpression();if(!N(a))continue;const s=e.getNameNode();if(!o.isIdentifier(s))throw l(s,"defineMutator exports must be plain named exports (no destructuring)");const u=I(n);t.push({args:b(u),exportName:s.getText(),filePath:"mutators",returnType:A(u)})}return t},w=(r,t)=>{const e=p(t,M);if(!f(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),n=E(i);return n.sort((a,s)=>a.exportName.localeCompare(s.exportName)),n};export{M as MUTATORS_FILENAME,w as discoverMutators,N as isDefineMutatorCallee};
1
+ import{existsSync as f}from"node:fs";import{join as p}from"node:path";import{Node as o,SyntaxKind as c}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{a as g}from"./module-specifiers-WF8iAydP.mjs";import{a as d}from"./parse-validator-tdRHHDzh.mjs";import{u as x}from"./unwrap-handler-return-CmIWbykC.mjs";const M="mutators.ts",m=g,y=r=>{const t=r.getSymbol();if(!t)return r.getText()==="defineMutator";for(const e of t.getDeclarations())if(o.isImportSpecifier(e))return m(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineMutator":!1;return!1},S=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&&m(i.getModuleSpecifierValue())}return!1},N=r=>{if(o.isIdentifier(r))return y(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(t)&&S(t)}return!1},I=r=>{const t=r.getArguments()[0];return t&&o.isObjectLiteralExpression(t)?t:void 0},b=r=>{const t=r?.getProperty("args");if(!t||!o.isPropertyAssignment(t))return{};const e=t.getInitializer();return e&&o.isObjectLiteralExpression(e)?d(e):{}},A=r=>{const t=r?.getProperty("server");if(!t||!o.isPropertyAssignment(t))return"unknown";const e=t.getInitializer();return!e||!(o.isArrowFunction(e)||o.isFunctionExpression(e))?"unknown":x(e)},E=r=>{const t=[];for(const e of r.getVariableDeclarations()){if(!e.isExported())continue;const i=e.getInitializer();if(i?.getKind()!==c.CallExpression)continue;const n=i,a=n.getExpression();if(!N(a))continue;const s=e.getNameNode();if(!o.isIdentifier(s))throw l(s,"defineMutator exports must be plain named exports (no destructuring)");const u=I(n);t.push({args:b(u),exportName:s.getText(),filePath:"mutators",returnType:A(u)})}return t},w=(r,t)=>{const e=p(t,M);if(!f(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),n=E(i);return n.sort((a,s)=>a.exportName.localeCompare(s.exportName)),n};export{M as MUTATORS_FILENAME,w as discoverMutators,N as isDefineMutatorCallee};
@@ -1,3 +1,3 @@
1
- import{G as c}from"./emit-BNdsZPcd.mjs";import{s as u}from"./paths-C-9fwEgQ.mjs";import{validatorIrToJsonSchema as m,objectSchema as p,LUNORA_ERROR_CODES as i}from"./LUNORA_ERROR_CODES-CW7-uASH.mjs";const l="1.3.2",d={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},R=e=>{const n=u(e.filePath),o=`${n}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${o}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${o}", "args": { … } }\`).`,errors:i.map((r,s)=>({code:-32e3-s,data:{code:r},message:r})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:p(e.args)}],result:{name:"result",schema:e.output?m(e.output):d},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:n}]}},g=e=>{const n=e.version??"0.0.0",r=e.functions.filter(t=>t.visibility!=="internal"&&t.kind!=="stream").map(t=>R(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:n},methods:r,openrpc:l}},S=e=>`${JSON.stringify(g(e),void 0,2)}
1
+ import{G as c}from"./emit-Lx7UkoGn.mjs";import{s as u}from"./paths-C-9fwEgQ.mjs";import{validatorIrToJsonSchema as m,objectSchema as p,LUNORA_ERROR_CODES as i}from"./LUNORA_ERROR_CODES-CW7-uASH.mjs";const l="1.3.2",d={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},R=e=>{const n=u(e.filePath),o=`${n}:${e.exportName}`;return{description:`Invoke the \`${e.kind}\` \`${o}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${o}", "args": { … } }\`).`,errors:i.map((r,s)=>({code:-32e3-s,data:{code:r},message:r})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:p(e.args)}],result:{name:"result",schema:e.output?m(e.output):d},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,"x-tags":[{name:n}]}},g=e=>{const n=e.version??"0.0.0",r=e.functions.filter(t=>t.visibility!=="internal"&&t.kind!=="stream").map(t=>R(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:n},methods:r,openrpc:l}},S=e=>`${JSON.stringify(g(e),void 0,2)}
2
2
  `,v=e=>`${c}export const openRpcSpec: Record<string, unknown> = ${JSON.stringify(e,void 0,4)};
3
3
  `;export{l as OPENRPC_VERSION,g as buildOpenRpcDocument,S as emitOpenRpc,v as emitOpenRpcModule};
@@ -0,0 +1,9 @@
1
+ import{existsSync as b,mkdirSync as ms,readFileSync as Rt,writeFileSync as hs,rmSync as xs}from"node:fs";import{join as f,dirname as J}from"node:path";import{performance as Ee}from"node:perf_hooks";import{runAdvisor as Es}from"@lunora/advisor";import{LunoraError as D}from"@lunora/errors";import{SyntaxKind as l,Node as i,Project as ot}from"ts-morph";import{serializeSchemaSnapshot as vs}from"./SCHEMA_SNAPSHOT_VERSION-CWESEYLi.mjs";import{toAdvisorContext as Ss}from"./formatAdvisories-CkEu1eye.mjs";import{s as ys}from"./paths-C-9fwEgQ.mjs";import{C as ee,n as Lt,i as As,f as Ns,j as bs,b as Ps,c as Is,l as ws,e as Ts,o as Cs,d as Fs,k as Os,g as Rs,p as Ls,m as Ds,a as ks,h as Ms}from"./emit-Lx7UkoGn.mjs";import{discoverAgents as Ks}from"./AGENTS_FILENAME-DHk9gO3E.mjs";import{discoverContainers as _s}from"./CONTAINERS_FILENAME-CqSjcb1-.mjs";import zs from"./discoverCrons-C-GrcmEj.mjs";import{diagnosticAt as ae}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as ce}from"./module-specifiers-WF8iAydP.mjs";import{listLunoraSourceFiles as m,unwrapExpression as W,listSecurityScanFiles as we,objectLiteralFromCallbackBody as Dt,propertyInitializer as N,lunoraRelativePath as E,collectCallRows as I,collectSecurityCallRows as $s,limitNameOf as kt,isContextIdentifier as Ae,handlerOf as Us,isDatabaseAccessor as k,readTargetOf as Mt,enclosingExportName as Bs}from"./listLunoraSourceFiles-lHrzFhbX.mjs";import qs from"./readPackageDependencies-C6h6FZuP.mjs";import{discoverQueues as Vs}from"./QUEUES_FILENAME-BZ6Ak3QY.mjs";import{discoverSandboxUsage as js}from"./discoverSandboxUsage-zLtQHdkg.mjs";import Ws from"./discoverStorageRulesMetadata-B1gekVBr.mjs";import{a as y,c as M,d as Kt,e as Hs}from"./classify-procedure-call-C5BOBVM7.mjs";import{discoverWorkflows as Gs}from"./WORKFLOWS_FILENAME-CXgbWxbT.mjs";import{gatePlatformFeatures as Ys,resolveCodegenTarget as Xs}from"./DEFAULT_TARGET-lPq34YeN.mjs";import{i as R,a as z,e as S,r as Qs,b as Zs,s as le,c as Js,f as en,d as tn}from"./queries-C3PDsG0y.mjs";import{r as ue,s as sn}from"./parse-validator-tdRHHDzh.mjs";import nn from"./discoverAuthApiCalls-mYYZYULR.mjs";import it from"./discoverFunctions-DKq2c91M.mjs";import{i as rn,r as on,e as an}from"./unwrap-handler-return-CmIWbykC.mjs";import at from"./discoverHttpRoutes-BYTh2RPR.mjs";import cn from"./discoverHyperdriveCalls-jqn--Zkc.mjs";import ln from"./discoverInserts-Bbw_Fkid.mjs";import{m as Te,a as se,s as _t,d as un}from"./index-D322boXY.mjs";import{e as zt}from"./exported-procedure-chains-CH_Ce-wL.mjs";import dn from"./discoverMigrations-ChOwLUzQ.mjs";import{MUTATORS_FILENAME as fn,isDefineMutatorCallee as gn,discoverMutators as ct}from"./MUTATORS_FILENAME-CTHlZ1j6.mjs";import pn from"./discoverNondeterministicCalls-Cesk1Srg.mjs";import{discoverNotifyConfig as mn,discoverNotifyCalls as hn}from"./NOTIFY_FILENAME-a3lg_dJ9.mjs";import xn from"./discoverR2sqlCalls-DW4RO223.mjs";import En from"./discoverRlsProcedures-iPEyaH0Q.mjs";import vn from"./discoverRlsMetadata-pjWjG15I.mjs";import Sn from"./discoverSchema-DoZtXwLg.mjs";import{secretKindOf as yn,redact as An,isHeuristicSecretKind as Nn,isSecretishName as bn}from"./redact-Cy14LEnc.mjs";import{discoverShapes as Pn}from"./SHAPES_FILENAME-Bvd5kgsF.mjs";import{emitApp as In}from"./emitApp-9dMkNu6n.mjs";import{buildOpenApiDocument as wn,emitOpenApiModule as Tn}from"./buildOpenApiDocument-CE9SDrBg.mjs";import{buildOpenRpcDocument as Cn,emitOpenRpcModule as Fn}from"./OPENRPC_VERSION-DlF2XS7T.mjs";import{buildSchemaSnapshot as On}from"./SchemaSnapshotParseError-yrVM8bTa.mjs";const lt=(e,t="api")=>{const s=new Map;for(const n of e){const o=ys(n),r=s.get(o);if(r===void 0){s.set(o,n);continue}if(r!==n){const a=t==="api"?`the generated api.ts would declare "${o}" twice and the dispatch key "${o}:<fn>" would be ambiguous`:`the generated api.ts would declare "${o}" twice in HttpStreamsRef and again in the httpStreams object literal`;throw new D("INTERNAL",`@lunora/codegen: "${r}" and "${n}" both map to the ${t} namespace "${o}" — ${a}. Rename one file so the two differ by more than a non-identifier character (\`-\`, \`.\`, \`/\` and \`_\` all sanitize to \`_\`).`,{status:500})}}},Rn=(e,t={})=>{const{hasVectors:s=!0,scheduler:n=!1,storage:o=!1,usage:r}=t,a=[],c=e.tables.filter(u=>u.shardMode==="global");c.some(u=>u.globalBackend!=="hyperdrive")&&a.push({name:"@lunora/d1",reason:"`.global()` tables are D1-backed, so `_generated/app.ts` imports the D1 `ctx.db` adapter"}),c.some(u=>u.globalBackend==="hyperdrive")&&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`"}),o&&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 u of r===void 0?[]:ee)u.requiredPackage!==void 0&&r?.[u.key]===!0&&a.push({name:u.requiredPackage,reason:`\`ctx.${u.contextProperty??u.key}\` usage makes \`_generated/\` import \`${u.moduleSpecifier}\``});return a.filter((u,d)=>a.findIndex(v=>v.name===u.name)===d)},Ln=(e,t,s={})=>{if(t===void 0)return;const n=Rn(e,s).filter(r=>!t.has(r.name));if(n.length===0)return;const o=n.map(r=>` - ${r.name} — ${r.reason}`).join(`
2
+ `);throw new D("INTERNAL",`@lunora/codegen: this schema's generated code imports packages the project does not declare:
3
+ ${o}
4
+
5
+ Install them with your package manager, then re-run codegen.`)},Dn="env.ts",kn=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineEnv";for(const s of t.getDeclarations())if(i.isImportSpecifier(s))return ce(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineEnv":!1;return!1},Mn=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!i.isNamespaceImport(s))continue;const n=s.getFirstAncestorByKind(l.ImportDeclaration);return n!==void 0&&ce(n.getModuleSpecifierValue())}return!1},Kn=e=>{if(i.isIdentifier(e))return kn(e);if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineEnv"&&i.isIdentifier(t)&&Mn(t)}return!1},_n=e=>{const t=[];for(const s of e.getVariableDeclarations()){if(!s.isExported())continue;const n=s.getInitializer();if(n?.getKind()!==l.CallExpression||!Kn(n.getExpression()))continue;const r=s.getNameNode();if(!i.isIdentifier(r))throw ae(r,"defineEnv exports must be plain named exports (no destructuring)");t.push({exportName:r.getText()})}return t},zn=(e,t)=>{const s=f(t,Dn);if(!b(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),o=_n(n);if(o.length!==0){if(o.length>1)throw ae(n,`lunora/env.ts declares ${o.length.toString()} defineEnv() contracts (${o.map(r=>r.exportName).join(", ")}); exactly one is allowed`);return o[0]}},ut="ctx",$t=e=>{const t=new Set,s=new Set([ut]),n=r=>{if(i.isObjectBindingPattern(r))for(const a of r.getElements()){const c=a.getPropertyNameNode()?.getText()??a.getName();c&&t.add(c)}};for(const r of e.getDescendantsOfKind(l.BindingElement)){if((r.getPropertyNameNode()?.getText()??r.getName())!==ut)continue;const a=r.getNameNode();i.isIdentifier(a)?s.add(a.getText()):n(a)}const o=r=>i.isIdentifier(r)&&s.has(r.getText());for(const r of e.getDescendantsOfKind(l.PropertyAccessExpression))o(r.getExpression())&&t.add(r.getName());for(const r of e.getDescendantsOfKind(l.VariableDeclaration)){const a=r.getInitializer();a!==void 0&&o(a)&&n(r.getNameNode())}return t},$n=(e,t)=>{const s=Object.fromEntries(ee.map(n=>[n.key,!1]));for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=new Set(o.getImportDeclarations().map(c=>c.getModuleSpecifierValue())),a=$t(o);for(const c of ee)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(ee.every(c=>s[c.key]))break}return s},Ut="identity.ts",Un=e=>{const t=e.getSymbol();if(!t)return e.getText()==="defineIdentity";for(const s of t.getDeclarations())if(i.isImportSpecifier(s))return ce(s.getImportDeclaration().getModuleSpecifierValue())?s.getNameNode().getText()==="defineIdentity":!1;return!1},Bn=e=>{const t=e.getSymbol();if(!t)return!1;for(const s of t.getDeclarations()){if(!i.isNamespaceImport(s))continue;const n=s.getFirstAncestorByKind(l.ImportDeclaration);return n!==void 0&&ce(n.getModuleSpecifierValue())}return!1},qn=e=>{if(i.isIdentifier(e))return Un(e);if(i.isPropertyAccessExpression(e)){const t=e.getExpression();return e.getName()==="defineIdentity"&&i.isIdentifier(t)&&Bn(t)}return!1},Vn=e=>{const t=[];for(const s of e.getVariableDeclarations()){if(!s.isExported())continue;const n=s.getInitializer();if(n?.getKind()!==l.CallExpression||!qn(n.getExpression()))continue;const r=s.getNameNode();if(!i.isIdentifier(r))throw ae(r,"defineIdentity exports must be plain named exports (no destructuring)");t.push({exportName:r.getText()})}return t},jn=(e,t)=>{const s=f(t,Ut);if(!b(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s),o=Vn(n);if(o.length!==0){if(o.length>1)throw ae(n,`lunora/identity.ts declares ${o.length.toString()} defineIdentity() contracts (${o.map(r=>r.exportName).join(", ")}); exactly one is allowed`);return o[0]}},Wn=(e,t)=>{const s=W(t);if(s===void 0||!i.isIdentifier(s))return s;const n=s.getText();return W(e.getDescendantsOfKind(l.VariableDeclaration).find(o=>o.getName()===n)?.getInitializer())},Hn=e=>e!==void 0&&i.isObjectLiteralExpression(e)&&e.getProperties().some(t=>{if(i.isShorthandPropertyAssignment(t))return t.getName()==="durable";if(!i.isPropertyAssignment(t)||t.getName()!=="durable")return!1;const s=t.getInitializer();return s===void 0||W(s)?.getText()!=="false"}),Gn=(e,t)=>{const s={durableStreams:!1,secrets:!1};for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);if(s.secrets||(s.secrets=$t(o).has("secrets")),s.durableStreams||(s.durableStreams=o.getDescendantsOfKind(l.CallExpression).some(r=>{const a=r.getExpression();return(i.isPropertyAccessExpression(a)?a.getName():a.getText())==="stream"&&r.getArguments().some(u=>Hn(Wn(o,u)))})),s.durableStreams&&s.secrets)break}return s},Yn="createWorker",Xn="extend",dt=e=>e!==void 0&&(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))?e.getLiteralValue():void 0,ft=e=>{const t=[],s=dt(N(e,"backupCron"));s!==void 0&&t.push(s);const n=N(e,"crons");if(n===void 0||!i.isObjectLiteralExpression(n))return t;for(const o of n.getProperties()){if(!i.isPropertyAssignment(o)&&!i.isMethodDeclaration(o))continue;const r=dt(o.getNameNode());r!==void 0&&t.push(r)}return t},Qn=e=>{const t=y(e.getExpression()),[s]=e.getArguments();if(s===void 0)return[];if(t===Yn)return i.isObjectLiteralExpression(s)?ft(s):[];if(t!==Xn||!(i.isArrowFunction(s)||i.isFunctionExpression(s)))return[];const n=Dt(s.getBody());return n===void 0?[]:ft(n)},Zn=(e,t)=>{const s=[];for(const{filePath:n}of we(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const r of o.getDescendantsOfKind(l.CallExpression))s.push(...Qn(r))}return[...new Set(s)]},Jn=(e,t)=>{const s=new Map,n=new Map,o=new Map;for(const r of e)s.set(r.name,`workflow "${r.exportName}"`),n.set(r.bindingName,`workflow "${r.exportName}"`),o.set(r.className,`workflow "${r.exportName}"`);for(const r of t){const a=s.get(r.name);if(a!==void 0)throw new D("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 D("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=o.get(r.className);if(u!==void 0)throw new D("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})}},er=e=>{const{lunoraDirectory:t,project:s,projectRoot:n,schema:o}=e,r=jn(s,t),a=zn(s,t),c=Gs(s,t),u=Vs(s,t),d=Ks(s,t);Jn(c,d);const v=_s(s,t),x=Ws(s,t),P=zs(s,t,c,d),K=Zn(s,t),g=Gn(s,t),T=js(s,t),C=$n(s,t);C.browser=C.browser||T.usesSandboxBrowser;const B=Ys(C,Xs(n,e.target),{agents:d.length>0,commitOrderedTables:o.tables.some(p=>p.commitOrdered===!0),cronTriggers:P.length>0,crossShardFanout:o.tables.some(p=>typeof p.shardMode=="object"),durableStreams:g.durableStreams,globalTables:o.tables.some(p=>p.shardMode==="global"),queues:u.length>0,secrets:g.secrets,vectorStore:o.vectorIndexes.length>0}),A=B.usage,L=B.signals.vectorStore!==!1,$=qs(n),q=$??new Set,G=q.has("lunorash");Ln(o,$,{hasVectors:L,scheduler:A.scheduler||P.length>0,storage:A.storage||x.rules.length>0||Object.keys(Lt(o)).length>0,usage:A});const _=b(f(t,"flags.ts")),F=b(f(t,"notify.ts"));return{agents:d,containers:v,crons:P,dataModelContent:Ns(o),declaredDependencies:$,dependencies:q,entryCronTriggers:K,env:a,featureUsage:A,hasFlags:_,hasNotify:F,identity:r,platformGate:B,queues:u,serverContent:As({agents:d,containers:v,env:a,hasAccessFacade:A.access,hasAi:A.ai,hasAnalytics:A.analytics,hasBrowser:A.browser,hasVectors:L,hasFlags:_,hasHyperdrive:A.hyperdrive,hasImages:A.images,hasKv:A.kv,hasNotify:F,hasPayments:A.payments,hasPipelines:A.pipelines,hasR2sql:A.r2sql,hasX402:A.x402,identity:r,queues:u,schema:o,storageRuleBuckets:x.rules.map(p=>p.bucket),useUmbrella:G,workflows:c}),storageRulesMetadata:x,usesSandbox:T.usesSandboxBrowser||T.usesSandboxContainer||T.usesSandboxFs,useUmbrella:G,workflows:c}},Bt=new Set(["delete","get","head","options","patch","post","put"]),tr=new Set(["handler","stream"]),sr=/\/(?:_|admin|internal|superuser|sudo|root|debug)/iu,gt=new Set(["ADMIN_TOKEN","adminToken","assertAdmin","assertAuth","auth","Authorization","getSession","identity","isAdmin","requireAdmin","requireAuth","requireRole","verifyAdmin"]),nr=e=>{if(!i.isCallExpression(e))return;const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!Bt.has(t.getName()))return;const s=t.getExpression();if(!i.isIdentifier(s)||s.getText()!=="httpRoute")return;const n=e.getArguments()[0];if(!(!n||!i.isStringLiteral(n)))return{method:t.getName().toUpperCase(),path:n.getLiteralValue()}},rr=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;let s=t.getExpression();for(;i.isCallExpression(s);){const n=s.getExpression();if(!i.isPropertyAccessExpression(n)||Bt.has(n.getName()))break;s=n.getExpression()}return nr(s)},or=e=>{for(const t of e.getDescendantsOfKind(l.PropertyAccessExpression))if(gt.has(t.getName()))return!0;for(const t of e.getDescendantsOfKind(l.CallExpression)){const s=t.getExpression();if(i.isIdentifier(s)&&gt.has(s.getText()))return!0}return!1},ir=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const n=s.getExpression();if(!i.isPropertyAccessExpression(n)||!tr.has(n.getName()))return;const o=rr(s);if(!o||!sr.test(o.path))return;const r=s.getArguments()[0],a=r!==void 0&&(i.isArrowFunction(r)||i.isFunctionExpression(r))&&or(r);return{exportName:e.getName(),file:t,method:o.method,path:o.path,usesGuard:a}},ar=(e,t)=>{const s=[];for(const n of e.getVariableStatements())if(n.isExported())for(const o of n.getDeclarations()){const r=ir(o,t);r&&s.push(r)}return s},cr=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...ar(o,E(t,n)))}return s},lr=e=>!i.isPropertyAccessExpression(e)||e.getName()!=="run"?!1:e.getExpression().getText()==="ctx.ai",ur=(e,t)=>{if(!lr(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!R(s)||z(s)))return{exportName:S(e),file:t,line:e.getStartLineNumber()}},dr=(e,t)=>I(e,t,ur),fr=new Set(["generateText","streamText"]),gr=new Set(["messages","prompt","system"]),pr=[{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"]}],mr=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;const s=t.getName(),n=t.getExpression().getText();for(const o of pr)if(o.methods.has(s)&&o.prefixes.some(r=>n===r||n.startsWith(`${r}.`)))return`${n}.${s}`},hr=e=>{for(const t of e.getDescendantsOfKind(l.CallExpression)){const s=mr(t);if(s!==void 0)return s}},xr=e=>{const t=new Set,s=e.getFirstAncestor(r=>i.isArrowFunction(r)||i.isFunctionExpression(r)||i.isFunctionDeclaration(r)),[n]=s?.getParameters()??[],o=n?.getNameNode();if(o===void 0||!i.isObjectBindingPattern(o))return t;for(const r of o.getElements()){const a=r.getPropertyNameNode()?.getText()??r.getName(),c=r.getNameNode();if(a==="args"&&i.isObjectBindingPattern(c))for(const u of c.getElements())t.add(u.getName())}return t},Er=e=>{if(Qs(e))return!0;const t=xr(e);return t.size===0?!1:e.getDescendantsOfKind(l.Identifier).some(s=>t.has(s.getText()))},vr=e=>{for(const t of e.getProperties()){if(!i.isPropertyAssignment(t)||!gr.has(t.getName()))continue;const s=t.getInitializer();if(s!==void 0&&Er(s))return!0}return!1},Sr=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression)){const o=y(n.getExpression());if(o===void 0||!fr.has(o))continue;const[r]=n.getArguments();if(r===void 0||!i.isObjectLiteralExpression(r))continue;let a;for(const c of r.getDescendantsOfKind(l.CallExpression))if(y(c.getExpression())==="tool"&&(a=hr(c),a!==void 0))break;a!==void 0&&s.push({exportName:S(n),file:t,line:n.getStartLineNumber(),method:o,sideEffect:a,userInputDerived:vr(r)})}return s},yr=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Sr(o,E(t,n)))}return s},Ar=e=>{if(!i.isPropertyAccessExpression(e)||e.getName()!=="fetch")return!1;const t=e.getExpression();return i.isIdentifier(t)&&t.getText()==="ctx"},Nr=(e,t)=>{if(!Ar(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!R(s)))return{exportName:S(e),file:t,line:e.getStartLineNumber()}},br=(e,t)=>I(e,t,Nr),Ce=(e,t=new Set)=>{if(t.has(e))return!0;t.add(e);try{return e.getProperties().some(s=>{if(!i.isSpreadAssignment(s))return!1;const n=ue(s.getExpression());return n===void 0||Ce(n,t)})}finally{t.delete(e)}},Pr=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return{objects:[],opaque:!0};const s=t.getProperty("args");if(!s)return{objects:[],opaque:!1};if(!i.isPropertyAssignment(s))return{objects:[],opaque:!0};const n=s.getInitializer(),o=n===void 0?void 0:ue(n);return o===void 0?{objects:[],opaque:!0}:{objects:[o],opaque:Ce(o)}},Ir=e=>{const t=[];let s=!1,n=e;for(;i.isCallExpression(n);){const o=n.getExpression();if(!i.isPropertyAccessExpression(o))break;if(o.getName()==="input"){const r=n.getArguments()[0],a=r!==void 0&&i.isExpression(r)?ue(r):void 0;a===void 0?s=!0:(t.push(a),s||=Ce(a))}n=o.getExpression()}return{objects:t,opaque:s}},Fe=(e,t)=>t?Ir(t):Pr(e),qt=(e,t)=>{if(t.has(e))return[];t.add(e);try{return e.getProperties().flatMap(s=>{if(i.isSpreadAssignment(s)){const n=ue(s.getExpression());return n===void 0?[]:qt(n,t)}return i.isPropertyAssignment(s)||i.isShorthandPropertyAssignment(s)?[s.getName()]:[]})}finally{t.delete(e)}},wr=e=>e.flatMap(t=>qt(t,new Set)),Tr=new Set(["check","length","max"]),Ne=e=>{if(!i.isCallExpression(e))return;const t=e.getExpression();if(!(!i.isPropertyAccessExpression(t)||t.getExpression().getText()!=="v"))return t.getName()},Cr=e=>[e,...e.getDescendants()].filter(t=>Ne(t)!==void 0),Fr=e=>{let t=e;for(;;){const s=t.getParent();if(!s||!i.isPropertyAccessExpression(s)||s.getExpression()!==t)return!1;const n=s.getParent();if(!n||!i.isCallExpression(n)||n.getExpression()!==s)return!1;if(Tr.has(s.getName()))return!0;t=n}},Or=e=>{const t=[],s=[];for(const n of e)for(const o of n.getProperties()){if(!i.isPropertyAssignment(o))continue;const r=o.getInitializer();if(!r)continue;const a=Cr(r),c=o.getName();a.some(u=>Ne(u)==="any")?t.push(c):a.some(u=>Ne(u)==="string"&&!Fr(u))&&s.push(c)}return{anyArgs:t,unboundedStringArgs:s}},Rr=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const n=M(s);if(n?.visibility!=="public")return;const{objects:o}=Fe(s,n.receiver),{anyArgs:r,unboundedStringArgs:a}=Or(o);if(!(r.length===0&&a.length===0))return{anyArgs:r,exportName:e.getName(),file:t,line:s.getStartLineNumber(),unboundedStringArgs:a}},Lr=(e,t)=>{const s=[];for(const n of e.getVariableStatements())if(n.isExported())for(const o of n.getDeclarations()){const r=Rr(o,t);r&&s.push(r)}return s},Dr=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Lr(o,E(t,n)))}return s},ve=e=>e?.getKind()===l.TrueKeyword,kr=e=>e?.getKind()===l.FalseKeyword,Mr=e=>e!==void 0&&i.isNumericLiteral(e)&&e.getLiteralValue()===0,Kr=new Set(["lunoraAuthAdapter","lunoraD1Adapter"]),_r=e=>!e||!i.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>i.isCallExpression(t)&&y(t.getExpression())==="scim"),zr=e=>e!==void 0&&i.isCallExpression(e)&&Kr.has(y(e.getExpression())??""),$r=e=>!e||!i.isArrayLiteralExpression(e)?!1:e.getElements().some(t=>i.isStringLiteral(t)&&t.getLiteralText()==="*"),Ur=e=>{const t=N(e,"advanced"),s=N(e,"emailAndPassword"),n=N(e,"session");return{analyzable:!0,disableCsrfCheck:ve(N(t,"disableCSRFCheck")),emailPasswordEnabled:ve(N(s,"enabled")),requireEmailVerification:ve(N(s,"requireEmailVerification")),scimOnNonTransactionalAdapter:_r(N(e,"plugins"))&&zr(N(e,"database")),secureCookiesDisabled:kr(N(t,"useSecureCookies")),sessionFreshAgeZero:Mr(N(n,"freshAge")),trustedOriginsWildcard:$r(N(e,"trustedOrigins"))}},Br=()=>({analyzable:!1,disableCsrfCheck:!1,emailPasswordEnabled:!1,requireEmailVerification:!1,scimOnNonTransactionalAdapter:!1,secureCookiesDisabled:!1,sessionFreshAgeZero:!1,trustedOriginsWildcard:!1}),qr=(e,t)=>{if(y(e.getExpression())!=="createAuth")return;const s=e.getArguments()[0],n=s!==void 0&&i.isObjectLiteralExpression(s)&&s.getProperties().some(r=>i.isSpreadAssignment(r)),o=s!==void 0&&i.isObjectLiteralExpression(s)&&!n?Ur(s):Br();return{exportName:S(e),file:t,line:e.getStartLineNumber(),...o}},Vr=(e,t)=>$s(e,t,qr),jr=(e,t)=>{if(!i.isPropertyAccessExpression(e))return;const s=e.getName();if(t.methods.has(s))return t.matchReceiver(e.getExpression().getText())?s:void 0},Wr=(e,t,s)=>{const n=jr(e.getExpression(),s);if(n===void 0)return;const o=e.getArguments()[s.argIndex];if(!(!o||!R(o)||z(o))&&!(s.requireUnmodifiedReach===!0&&!Zs(o)))return{exportName:S(e),file:t,line:e.getStartLineNumber(),method:n}},Hr=(e,t,s)=>{const n=[];for(const o of e.getDescendantsOfKind(l.CallExpression)){const r=Wr(o,t,s);r&&n.push(r)}return n},de=(e,t,s)=>{const n=[];for(const o of m(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o);n.push(...Hr(r,E(t,o),s))}return n},Gr=new Set(["content","pdf","scrape","screenshot"]),Yr=(e,t)=>de(e,t,{argIndex:0,matchReceiver:s=>s==="ctx.browser",methods:Gr}),Xr=new Set(["createBrowser","createInboundEmailHandler","createPayment"]),Qr=new Set(["RateLimiter"]),Zr=new Set(["extend"]),pt="lunora",Jr=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],Vt=e=>{const t=[],s=[];let n=!1;for(const o of e.getProperties()){if(i.isSpreadAssignment(o)){n=!0;continue}if(i.isPropertyAssignment(o)){const r=o.getName();t.push(r),o.getInitializer()?.getKind()===l.TrueKeyword&&s.push(r);continue}(i.isShorthandPropertyAssignment(o)||i.isMethodDeclaration(o))&&t.push(o.getName())}return{analyzable:!n,presentKeys:t,trueKeys:s}},be=e=>e&&i.isObjectLiteralExpression(e)?Vt(e):{analyzable:!1,presentKeys:[],trueKeys:[]},eo=e=>{const t=e&&(i.isArrowFunction(e)||i.isFunctionExpression(e))?e:void 0,s=t&&Dt(t.getBody());return s?Vt(s):{analyzable:!1,presentKeys:[],trueKeys:[]}},to=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression)){const o=y(n.getExpression());o!==void 0&&(Xr.has(o)?s.push({callee:o,file:t,line:n.getStartLineNumber(),...be(n.getArguments()[0])}):Zr.has(o)&&s.push({callee:o,file:t,line:n.getStartLineNumber(),...eo(n.getArguments()[0])}))}for(const n of e.getDescendantsOfKind(l.NewExpression)){const o=y(n.getExpression());o===void 0||!Qr.has(o)||s.push({callee:o,file:t,line:n.getStartLineNumber(),...be(n.getArguments()[0])})}return s},so=(e,t)=>{for(const s of Jr){const n=f(t,s);if(!b(n))continue;const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=[];for(const a of o.getDescendantsOfKind(l.CallExpression))y(a.getExpression())===pt&&r.push({callee:pt,file:s,line:a.getStartLineNumber(),...be(a.getArguments()[0])});return r}return[]},no=(e,t)=>{const s=[];for(const{displayPath:n,filePath:o}of we(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o);s.push(...to(r,n))}return s.push(...so(e,J(t))),s},mt="ctx.containers.",ro=e=>{if(!e.startsWith(mt))return!1;const t=e.slice(mt.length);return t.length>0&&!t.includes(".")},oo=(e,t)=>de(e,t,{argIndex:0,matchReceiver:ro,methods:new Set(["get"])}),io=new Set(["allow","deny","setAllowed"]),ao=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return!1;const s=t.getProperty("enableInternet");return s!==void 0&&i.isPropertyAssignment(s)&&i.isTrueLiteral(s.getInitializerOrThrow())},co=(e,t)=>{const s=e.getExpression();if(!(!i.isPropertyAccessExpression(s)||s.getName()!=="start"||!ao(e)))return{detail:"enableInternet: true",exportName:S(e),file:t,kind:"enable_internet",line:e.getStartLineNumber()}},lo=(e,t)=>{const s=e.getExpression();if(!i.isPropertyAccessExpression(s)||!io.has(s.getName()))return;const n=s.getExpression();if(!(!i.isPropertyAccessExpression(n)||n.getName()!=="egress"))return{detail:s.getName(),exportName:S(e),file:t,kind:"egress_relaxation",line:e.getStartLineNumber()}},uo=(e,t)=>co(e,t)??lo(e,t),fo=(e,t)=>I(e,t,uo),go=new Set(["defineExportSink","r2Sink","webhookExportSink"]),po=e=>{const t=e.getExpression();if(!i.isIdentifier(t))return;const s=t.getText();return go.has(s)?s:void 0},mo=e=>{const t=[],s=[];for(const n of e.getProperties()){if(i.isSpreadAssignment(n))return{analyzable:!1,emptyKeys:[],presentKeys:[]};if(i.isPropertyAssignment(n)){const o=n.getName();t.push(o);const r=n.getInitializer();r&&i.isStringLiteral(r)&&r.getLiteralText()===""&&s.push(o);continue}(i.isShorthandPropertyAssignment(n)||i.isMethodDeclaration(n)||i.isGetAccessorDeclaration(n))&&t.push(n.getName())}return{analyzable:!0,emptyKeys:s,presentKeys:t}},ho=(e,t)=>{const s=[];for(const{displayPath:n,filePath:o}of we(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o);for(const a of r.getDescendantsOfKind(l.CallExpression)){const c=po(a);if(c===void 0)continue;const u=a.getArguments()[0],d=u&&i.isObjectLiteralExpression(u)?mo(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},xo=new Map([["dbRateLimit",2],["rateLimit",2],["verifyTurnstileMiddleware",0]]),Eo=new Set(["dbRateLimit","rateLimit"]),vo=e=>{if(!e||!i.isObjectLiteralExpression(e))return!1;const t=e.getProperty("failOpen");return t!==void 0&&i.isPropertyAssignment(t)&&t.getInitializer()?.getKind()===l.TrueKeyword},So=(e,t)=>{const s=y(e.getExpression());if(s===void 0)return;const n=xo.get(s);if(n!==void 0)return{callee:s,exportName:S(e),failOpen:vo(e.getArguments()[n]),file:t,limitName:Eo.has(s)?kt(e):"",line:e.getStartLineNumber()}},yo=(e,t)=>I(e,t,So),Ao=new Set(["boolean","number","object","string"]),No=e=>{const t=e.getName();if(!Ao.has(t))return;const s=e.getExpression();if(!i.isPropertyAccessExpression(s))return;if(s.getName()==="flags"&&Ae(s.getExpression()))return t;const n=s.getExpression();if(s.getName()==="details"&&i.isPropertyAccessExpression(n)&&n.getName()==="flags"&&Ae(n.getExpression()))return t},bo=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t))return;const s=No(t);if(s===void 0)return;const n=e.getArguments()[0];if(!n||!(i.isStringLiteral(n)||i.isNoSubstitutionTemplateLiteral(n)))return;const o=n.getLiteralValue();return o.length>0?{key:o,type:s}:void 0},Po=(e,t)=>{const s=new Map;for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const r of o.getDescendantsOfKind(l.CallExpression)){const a=bo(r);a&&!s.has(a.key)&&s.set(a.key,a.type)}}return[...s.entries()].map(([n,o])=>({key:n,type:o})).toSorted((n,o)=>n.key.localeCompare(o.key))},Io=e=>{const t=e.getInitializer();if(!t||!i.isCallExpression(t))return;const s=M(t);if(s?.kind!=="query")return;const n=Us(t,s.receiver);return n?{exportName:e.getName(),handler:n}:void 0},ht=e=>{const t=e.getParent();return t&&i.isPropertyAccessExpression(t)&&t.getExpression()===e?t:void 0},wo=e=>{if(!i.isPropertyAccessExpression(e)||e.getName()!=="flags")return;const t=e.getExpression();if(!i.isIdentifier(t)||t.getText()!=="ctx")return;const s=ht(e);if(!s)return"ctx.flags";if(s.getName()==="details"){const n=ht(s);return n?`ctx.flags.details.${n.getName()}`:"ctx.flags.details"}return`ctx.flags.${s.getName()}`},To=(e,t)=>{const s=[];for(const n of e.handler.getDescendantsOfKind(l.PropertyAccessExpression)){const o=wo(n);o!==void 0&&s.push({callee:o,exportName:e.exportName,file:t,line:n.getStartLineNumber()})}return s},Co=(e,t)=>{const s=[];for(const n of e.getVariableStatements())if(n.isExported())for(const o of n.getDeclarations()){const r=Io(o);r&&s.push(...To(r,t))}return s},Fo=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Co(o,E(t,n)))}return s},Oo=e=>{if(!i.isPropertyAccessExpression(e)||e.getName()!=="boolean")return!1;const t=e.getExpression();return i.isPropertyAccessExpression(t)&&t.getName()==="flags"&&Ae(t.getExpression())},Ro=e=>{if(e?.getKind()===l.TrueKeyword)return!0;if(e?.getKind()===l.FalseKeyword)return!1},Lo=(e,t)=>{if(!Oo(e.getExpression()))return;const[s,n]=e.getArguments();if(!s||!(i.isStringLiteral(s)||i.isNoSubstitutionTemplateLiteral(s)))return;const o=s.getLiteralValue(),r=Ro(n);if(!(o.length===0||r===void 0))return{defaultValue:r,exportName:S(e),file:t,key:o,line:e.getStartLineNumber()}},Do=(e,t)=>I(e,t,Lo),ko=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 o=n.getTypeAtLocation(e),r=o.getText(e);if(!r||r==="any"||r==="never"||rn(r))return;const a=e.getSourceFile().getFilePath();return on(o,e,a)?an(o,e,a,0,new Set):r},Mo=e=>{const t=e.getExpression();return i.isPropertyAccessExpression(t)&&t.getName()==="withGeoIndex"},Ko=e=>{const t=e.getArguments()[0];return t&&i.isStringLiteral(t)?t.getLiteralText():""},_o=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=E(t,n);for(const a of o.getDescendantsOfKind(l.CallExpression))Mo(a)&&s.push({file:r,indexName:Ko(a),line:a.getStartLineNumber()})}return s},H=e=>e!==void 0&&(i.isArrowFunction(e)||i.isFunctionExpression(e))?e:void 0,jt=e=>{const t=e.getArguments()[0],s=H(t);if(s!==void 0)return s;if(t===void 0||!i.isObjectLiteralExpression(t))return;const n=t.getProperty("handler");return n!==void 0&&i.isPropertyAssignment(n)?H(n.getInitializer()):void 0},zo=new Set(["delete","get","head","options","patch","post","put"]),$o=new Set(["handler","stream"]),Uo=new Set(["runAction","runMutation"]),Bo=new Set(["delete","insert","insertManyUnsafe","patch","replace"]),ne=(e,t)=>e!==void 0&&i.isIdentifier(e)&&e.getText()===t,xt=(e,t)=>{const s=e.getParameters()[0];if(s===void 0)return;const n=s.getNameNode();if(t)return i.isIdentifier(n)?n.getText():void 0;if(i.isObjectBindingPattern(n)){for(const o of n.getElements())if((o.getPropertyNameNode()?.getText()??o.getNameNode().getText())==="ctx"){const a=o.getNameNode();return i.isIdentifier(a)?a.getText():void 0}}},Et=(e,t)=>{const s=e.getBody(),n=s.getDescendantsOfKind(l.CallExpression);i.isCallExpression(s)&&n.unshift(s);for(const o of n){const r=o.getExpression();if(!i.isPropertyAccessExpression(r))continue;const a=r.getName(),c=r.getExpression();if(Uo.has(a)&&ne(c,t))return a;if(Bo.has(a)&&i.isPropertyAccessExpression(c)&&c.getName()==="db"&&ne(c.getExpression(),t))return`db.${a}`}},vt=(e,t)=>{const s=e.getBody();for(const n of s.getDescendantsOfKind(l.PropertyAccessExpression))if(n.getName()==="auth"&&ne(n.getExpression(),t))return!0;for(const n of s.getDescendantsOfKind(l.VariableDeclaration)){const o=n.getNameNode();if(!(!i.isObjectBindingPattern(o)||!ne(n.getInitializer(),t))){for(const r of o.getElements())if((r.getPropertyNameNode()?.getText()??r.getNameNode().getText())==="auth")return!0}}return!1},qo=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!$o.has(t.getName()))return;let s=t.getExpression();for(;i.isCallExpression(s);){const n=s.getExpression();if(!i.isPropertyAccessExpression(n))return;const o=n.getName();if(zo.has(o)){const r=n.getExpression();return i.isIdentifier(r)&&r.getText()==="httpRoute"?o.toUpperCase():void 0}s=n.getExpression()}},Vo=(e,t)=>{const s=e.getExpression();if(i.isIdentifier(s)&&s.getText()==="httpAction"){const c=H(e.getArguments()[0]),u=c&&xt(c,!0);if(!c||u===void 0)return;const d=Et(c,u);return d===void 0?void 0:{exportName:S(e),file:t,kind:"httpAction",line:e.getStartLineNumber(),readsAuth:vt(c,u),sideEffect:d}}const n=qo(e);if(n===void 0)return;const o=H(e.getArguments()[0]),r=o&&xt(o,!1);if(!o||r===void 0)return;const a=Et(o,r);return a===void 0?void 0:{exportName:S(e),file:t,kind:"httpRoute",line:e.getStartLineNumber(),method:n,readsAuth:vt(o,r),sideEffect:a}},jo=(e,t)=>I(e,t,Vo),Wo=new Set(["btoa","encodeURI","encodeURIComponent","isSafeHeaderValue","Number","parseFloat","parseInt"]),Ho=new Set(["append","set"]),Wt=e=>e!==void 0&&(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))?e.getLiteralText():"",St=(e,t)=>(i.isCallExpression(e)?[e,...e.getDescendantsOfKind(l.CallExpression)]:e.getDescendantsOfKind(l.CallExpression)).some(n=>Wo.has(y(n.getExpression())??"")&&en(n,t)),Go=(e,t)=>{if(St(e,t))return!0;const s=le(e);return s!==void 0&&St(s,t)},Pe=(e,t)=>Js(e,t)&&!Go(e,t),Yo=e=>{if(i.isPropertyAccessExpression(e)&&e.getName()==="headers")return!0;const t=le(e);return t!==void 0&&i.isNewExpression(t)&&y(t.getExpression())==="Headers"},re=e=>{if(e===void 0)return;if(i.isObjectLiteralExpression(e))return e;const t=le(e);return t!==void 0&&i.isObjectLiteralExpression(t)?t:void 0},Oe=(e,t,s)=>{for(const n of e.getProperties())if(i.isPropertyAssignment(n)){const o=n.getInitializer();o!==void 0&&Pe(o,s.requestName)&&s.rows.push({exportName:s.exportName,file:s.relativePath,headerName:Wt(n.getNameNode()),line:o.getStartLineNumber(),via:t})}else if(i.isShorthandPropertyAssignment(n)){const o=n.getNameNode();Pe(o,s.requestName)&&s.rows.push({exportName:s.exportName,file:s.relativePath,headerName:n.getName(),line:o.getStartLineNumber(),via:t})}else if(i.isSpreadAssignment(n)){const o=re(n.getExpression());o!==void 0&&Oe(o,t,s)}},Ht=(e,t)=>{const s=re(e);if(s===void 0)return;const n=s.getProperty("headers");if(n===void 0||!i.isPropertyAssignment(n))return;const o=re(n.getInitializer());o!==void 0&&Oe(o,"response-init",t)},Xo=(e,t)=>{const s=y(e.getExpression());if(s==="Response")Ht(e.getArguments()[1],t);else if(s==="Headers"){const n=re(e.getArguments()[0]);n!==void 0&&Oe(n,"headers-ctor",t)}},Qo=(e,t)=>{const s=e.getExpression();if(!i.isPropertyAccessExpression(s))return;const n=s.getName(),o=s.getExpression();if(n==="json"&&i.isIdentifier(o)&&o.getText()==="Response"){Ht(e.getArguments()[1],t);return}if(Ho.has(n)&&Yo(o)){const r=e.getArguments()[1];r!==void 0&&Pe(r,t.requestName)&&t.rows.push({exportName:t.exportName,file:t.relativePath,headerName:Wt(e.getArguments()[0]),line:r.getStartLineNumber(),via:n==="set"?"headers-set":"headers-append"})}},Zo=(e,t)=>{for(const s of e.getDescendantsOfKind(l.NewExpression))Xo(s,t);for(const s of e.getDescendantsOfKind(l.CallExpression))Qo(s,t)},Jo=(e,t)=>{const s=e.getExpression();if(!i.isIdentifier(s)||s.getText()!=="httpAction")return[];const n=H(e.getArguments()[0]);if(n===void 0)return[];const o=n.getParameters()[1];if(o===void 0)return[];const r=o.getNameNode();if(!i.isIdentifier(r))return[];const a=[];return Zo(n,{exportName:S(e),relativePath:t,requestName:r.getText(),rows:a}),a},ei=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression))s.push(...Jo(n,t));return s},ti=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...ei(o,E(t,n)))}return s},si=new Set(["auth","context.auth","ctx.auth"]),ni="userId",ri=e=>{const t=new Set;for(const s of e.getProperties()){if(i.isSpreadAssignment(s))return;(i.isPropertyAssignment(s)||i.isShorthandPropertyAssignment(s)||i.isMethodDeclaration(s))&&t.add(s.getName())}return t},oi=(e,t)=>{const s=f(t,Ut);if(!b(s))return;const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const o of n.getDescendantsOfKind(l.CallExpression)){if(y(o.getExpression())!=="defineIdentity")continue;const[r]=o.getArguments();return r&&i.isObjectLiteralExpression(r)?ri(r):void 0}},yt=e=>{if(!(e===void 0||!i.isPropertyAccessExpression(e)||e.getName()!=="identity"))return si.has(e.getExpression().getText())?e:void 0},ii=e=>{if(i.isPropertyAccessExpression(e)&&yt(e.getExpression())!==void 0)return e.getName();if(i.isElementAccessExpression(e)&&yt(e.getExpression())!==void 0){const t=e.getArgumentExpression();return t&&i.isStringLiteral(t)?t.getLiteralValue():void 0}},ai=(e,t,s)=>{const n=[];for(const o of e.getDescendants()){const r=ii(o);r!==void 0&&n.push({declared:r===ni||s.has(r),exportName:S(o),file:t,key:r,line:o.getStartLineNumber()})}return n},ci=(e,t)=>{const s=oi(e,t);if(s===void 0)return[];const n=[];for(const o of m(t)){const r=e.getSourceFile(o)??e.addSourceFileAtPath(o);n.push(...ai(r,E(t,o),s))}return n},li=(e,t)=>{if(y(e.getExpression())!=="buildImageDeliveryUrl")return;const s=e.getArguments()[0];if(!s)return;const n=N(s,"key");if(!(!n||!R(n)||z(n)))return{exportName:S(e),file:t,line:e.getStartLineNumber()}},ui=(e,t)=>I(e,t,li),di=new Set(["delete","get","getRaw","getWithMetadata","put"]),fi=(e,t,s=[])=>{const n=new Map(s.map(r=>[`${r.filePath}:${r.exportName}`,r.visibility]));return de(e,t,{argIndex:0,matchReceiver:r=>r==="ctx.kv"||r.startsWith("ctx.kv."),methods:di}).map(r=>{const a=n.get(`${r.file}:${r.exportName}`);return a===void 0?r:{...r,visibility:a}})},gi=new Set(["queue","send"]),At=new Set(["bcc","cc","to"]),pi=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();if(!gi.has(t))return;const s=e.getExpression().getText();return s==="ctx.mail"||s==="ctx.email"?t:void 0},mi=e=>i.isObjectLiteralExpression(e)?e.getProperties().some(t=>{if(i.isShorthandPropertyAssignment(t)){const n=t.getNameNode();return At.has(t.getName())&&R(n)&&!z(n)}if(!i.isPropertyAssignment(t)||!At.has(t.getName()))return!1;const s=t.getInitializer();return s!==void 0&&R(s)&&!z(s)}):!1,hi=(e,t)=>{const s=pi(e.getExpression());if(s===void 0)return;const n=e.getArguments()[0];if(!(!n||!mi(n)))return{exportName:S(e),file:t,line:e.getStartLineNumber(),method:s}},xi=(e,t)=>I(e,t,hi),Ei=e=>i.isPropertyAssignment(e)||i.isMethodDeclaration(e)||i.isGetAccessorDeclaration(e)?i.isComputedPropertyName(e.getNameNode()):!1,vi=e=>i.isPropertyAssignment(e)||i.isShorthandPropertyAssignment(e)||i.isMethodDeclaration(e)||i.isGetAccessorDeclaration(e)?Ei(e):!0,Gt=(e,t=!1)=>{for(const s of e.getProperties()){if(vi(s))return!0;if(t)continue;if(!i.isPropertyAssignment(s))return!0;const n=s.getInitializer();if(!n||!i.isObjectLiteralExpression(n)||Gt(n,!0))return!0}return!1},Si=(e,t)=>{for(const s of m(t)){const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);for(const{receiver:o}of zt(n))for(const r of Te(o)){const a=r.getArguments()[0];if(a!==void 0&&(!i.isObjectLiteralExpression(a)||Gt(a)))return!0}}return!1},yi=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return[];const s=[];for(const n of t.getProperties()){const o=se(n);if(o===void 0||!i.isPropertyAssignment(n))continue;const r=n.getInitializer();if(!(!r||!i.isObjectLiteralExpression(r)))for(const a of r.getProperties()){const c=se(a);c!==void 0&&s.push({column:c,strategy:_t(a),table:o})}}return s},Ai=(e,t)=>{const s=new Map;for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const{receiver:r}of zt(o))for(const a of Te(r))for(const c of yi(a)){const u=`${c.table}\0${c.column}`;s.has(u)||s.set(u,c)}}return{columns:[...s.values()]}},Ni=(e,t,s)=>{const n=e.getArguments()[0];if(!n||!i.isObjectLiteralExpression(n))return[];const o=[];for(const r of n.getProperties()){const a=se(r);if(a===void 0||!i.isPropertyAssignment(r))continue;const c=r.getInitializer();if(!(!c||!i.isObjectLiteralExpression(c)))for(const u of c.getProperties()){const d=se(u);if(d===void 0)continue;const v=_t(u);v!=="custom"&&o.push({column:d,exportName:t,file:s,line:u.getStartLineNumber(),strategy:v,table:a})}}return o},bi=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&i.isCallExpression(s)?M(s):void 0;return n?.receiver?Te(n.receiver).flatMap(o=>Ni(o,e.getName(),t)):[]},Pi=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=E(t,n);for(const a of o.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...bi(c,r))}return s},Ii=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="replace")return!1;const s=t.getExpression();return k(s)},wi=e=>{const t=e.getArguments()[0];if(t===void 0||!i.isObjectLiteralExpression(t))return;const s=t.getProperty("server");if(s!==void 0)return i.isPropertyAssignment(s)?s.getInitializer():s},Ti=e=>{if(!e.isExported())return;const t=e.getInitializer();if(t?.getKind()!==l.CallExpression)return;const s=t;return gn(s.getExpression())?s:void 0},Ci=e=>{const t=Ti(e),s=t===void 0?void 0:wi(t);if(s===void 0)return[];const n=e.getNameNode(),o=i.isIdentifier(n)?n.getText():"";return s.getDescendantsOfKind(l.CallExpression).filter(r=>Ii(r)).map(r=>({exportName:o,file:"lunora/mutators.ts",line:r.getStartLineNumber()}))},Fi=e=>e.getVariableDeclarations().flatMap(t=>Ci(t)),Oi=(e,t)=>{const s=f(t,fn);if(!b(s))return[];const n=e.getSourceFile(s)??e.addSourceFileAtPath(s);return Fi(n)},Ri=new Set(["delete","get","patch"]),Li=new Set(["accountId","authorId","companyId","createdBy","createdById","customerId","groupId","memberId","organizationId","orgId","ownerId","projectId","teamId","tenantId","userId","workspaceId"]),Di=new Set(["auth","identity","session","user"]),ki=new Set([l.EqualsEqualsEqualsToken,l.EqualsEqualsToken,l.ExclamationEqualsEqualsToken,l.ExclamationEqualsToken]),Mi=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="normalizeId"||!k(t.getExpression()))return;const s=e.getArguments()[0];return s&&i.isStringLiteral(s)?s.getLiteralText():""},Ki=e=>{let t=e,s=t.getParent();for(;s!==void 0&&(i.isAsExpression(s)||i.isParenthesizedExpression(s)||i.isNonNullExpression(s));)t=s,s=t.getParent();if(s===void 0||!i.isVariableDeclaration(s))return;const n=s.getNameNode();return i.isIdentifier(n)?n.getText():void 0},_i=(e,t)=>e.getDescendantsOfKind(l.Identifier).some(s=>s.getText()===t),zi=e=>i.isThrowStatement(e)||i.isReturnStatement(e)||e.getDescendantsOfKind(l.ThrowStatement).length>0||e.getDescendantsOfKind(l.ReturnStatement).length>0,$i=(e,t)=>e.getDescendantsOfKind(l.IfStatement).some(s=>_i(s.getExpression(),t)&&zi(s.getThenStatement())),Ui=(e,t)=>{for(const s of e.getDescendantsOfKind(l.CallExpression)){const n=s.getExpression();if(!i.isPropertyAccessExpression(n))continue;const o=n.getName();if(!Ri.has(o))continue;const r=n.getExpression();if(!(k(r)||i.isPropertyAccessExpression(r)&&k(r.getExpression())))continue;const c=s.getArguments()[0];if(c!==void 0&&i.isIdentifier(c)&&c.getText()===t)return o}},Bi=e=>{let t=e;for(;i.isPropertyAccessExpression(t)||i.isElementAccessExpression(t)||i.isNonNullExpression(t)||i.isParenthesizedExpression(t)||i.isAsExpression(t)||i.isAwaitExpression(t);)t=t.getExpression();return i.isIdentifier(t)?t.getText():void 0},qi=e=>e.getDescendantsOfKind(l.CallExpression).some(t=>t.getArguments().some(s=>Bi(s)==="ctx")),Vi=e=>e.getDescendantsOfKind(l.BinaryExpression).some(t=>ki.has(t.getOperatorToken().getKind())?i.isPropertyAccessExpression(t.getLeft())||i.isPropertyAccessExpression(t.getRight()):!1),ji=e=>{for(const t of e.getDescendantsOfKind(l.Identifier))if(Li.has(t.getText()))return!0;for(const t of e.getDescendantsOfKind(l.PropertyAccessExpression)){const s=t.getExpression();if(i.isIdentifier(s)&&s.getText()==="ctx"&&Di.has(t.getName()))return!0}return qi(e)||Vi(e)},Wi=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!i.isCallExpression(s))return[];const n=M(s);if(n?.kind!=="query"&&n?.kind!=="mutation")return[];const o=jt(s);if(o===void 0)return[];const r=n.receiver!==void 0&&Kt(n.receiver,"use","rls"),a=ji(o),c=new Set,u=[];for(const d of o.getDescendantsOfKind(l.CallExpression)){const v=Mi(d);if(v===void 0)continue;const x=Ki(d);if(x===void 0||c.has(x)||!$i(o,x))continue;const P=Ui(o,x);P!==void 0&&(c.add(x),u.push({exportName:e.getName(),file:t,line:d.getStartLineNumber(),mentionsOwnership:a,sinkMethod:P,table:v,usesRls:r,visibility:n.visibility}))}return u},Hi=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=E(t,n);for(const a of o.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...Wi(c,r))}return s},Gi=new Set(["accountId","authorId","createdBy","createdById","organizationId","orgId","ownerId","tenantId","updatedBy","userId","workspaceId"]),Yi=new Set(["insert","insertManyUnsafe","patch","replace"]),Xi=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();if(!Yi.has(t))return;const s=e.getExpression();if(!i.isPropertyAccessExpression(s)||s.getName()!=="db")return;const n=s.getExpression();return i.isIdentifier(n)&&n.getText()==="ctx"?t:void 0},Qi=(e,t)=>{if(t!=="insertManyUnsafe")return i.isObjectLiteralExpression(e)?[e]:[];if(!i.isArrayLiteralExpression(e))return[];const s=[];for(const n of e.getElements())i.isObjectLiteralExpression(n)&&s.push(n);return s},Zi=(e,t,s,n)=>{const o=[];for(const r of e.getProperties()){let a,c;i.isPropertyAssignment(r)?(a=r.getName(),c=r.getInitializer()):i.isShorthandPropertyAssignment(r)&&(a=r.getName(),c=r.getNameNode()),!(a===void 0||c===void 0||!Gi.has(a))&&R(c)&&!z(c)&&o.push({exportName:S(s),field:a,file:n,line:s.getStartLineNumber(),method:t})}return o},Ji=(e,t)=>{const s=Xi(e.getExpression());if(s===void 0)return[];const n=e.getArguments()[1];return n?Qi(n,s).flatMap(o=>Zi(o,s,e,t)):[]},ea=(e,t,s)=>{const n=[];for(const o of e.getDescendantsOfKind(l.CallExpression))for(const r of Ji(o,t)){const a=s(r.exportName);n.push(a===void 0?r:{...r,visibility:a})}return n},ta=(e,t,s=[])=>{const n=[],o=new Map(s.map(r=>[`${r.filePath}:${r.exportName}`,r.visibility]));for(const r of m(t)){const a=e.getSourceFile(r)??e.addSourceFileAtPath(r),c=E(t,r);n.push(...ea(a,c,u=>o.get(`${c}:${u}`)))}return n},sa=["providerSubscriptionId","state"],na=["providerEventId","processedAt"],Nt=(e,t)=>t.every(s=>s in e.shape),ra=e=>{const t=e.find(n=>n.name==="subscriptions"),s=e.find(n=>n.name==="events");return t!==void 0&&s!==void 0&&Nt(t,sa)&&Nt(s,na)},oa=new Set(["createAutumnAdapter","createDodoPaymentsAdapter","createPolarAdapter","createStripeAdapter"]),ia=e=>e&&i.isNumericLiteral(e)?Number(e.getText()):void 0,aa=e=>{const t=e.getProperty("webhookToleranceSeconds");return t&&i.isPropertyAssignment(t)?ia(t.getInitializer()):void 0},ca=(e,t)=>{const s=y(e.getExpression());if(s===void 0||!oa.has(s))return;const[n]=e.getArguments(),o=n&&i.isObjectLiteralExpression(n)?aa(n):void 0;return{callee:s,exportName:S(e),file:t,line:e.getStartLineNumber(),...o===void 0?{}:{toleranceSeconds:o}}},la=(e,t)=>I(e,t,ca),ua=new Set(["defineQueue","defineWorkflow"]),da=new Set(["run","runAction","runMutation","runQuery"]),fa=new Set(["api","internal"]),ga=e=>{const t=e.getExpression();return i.isIdentifier(t)?t.getText():void 0},pa=e=>{const t=e.getArguments()[0];if(!t||!i.isObjectLiteralExpression(t))return;const s=t.getProperty("handler");if(s===void 0||!i.isPropertyAssignment(s))return;const n=s.getInitializer();if(n&&(i.isArrowFunction(n)||i.isFunctionExpression(n)))return n},Yt=(e,t)=>{const s=e.getParameters()[t]?.getNameNode();return s&&i.isIdentifier(s)?s.getText():void 0},Xt=(e,t)=>e===t||e.startsWith(`${t}.`),Qt=e=>{const t=e.getDescendantsOfKind(l.PropertyAccessExpression);return i.isPropertyAccessExpression(e)&&t.push(e),t},bt=e=>{const t=e.getParent();return i.isPropertyAccessExpression(t)&&t.getNameNode()===e||i.isPropertyAssignment(t)&&t.getNameNode()===e?!1:!(i.isBindingElement(t)&&t.getNameNode()===e)},Zt=e=>{const t=e.getDescendantsOfKind(l.Identifier).filter(s=>bt(s));return i.isIdentifier(e)&&bt(e)&&t.push(e),t},ma=e=>{if(!i.isVariableDeclaration(e))return[];const t=e.getNameNode();return i.isIdentifier(t)?[t.getText()]:t.getDescendantsOfKind(l.BindingElement).map(s=>s.getName())},ha=e=>{const t=Yt(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 o=n.getInitializer(),r=i.isVariableDeclarationList(o)?o.getDeclarations()[0]?.getNameNode():void 0;r&&i.isIdentifier(r)&&s.push(`${r.getText()}.body`)}return s},xa=(e,t,s)=>{const n=t==="workflow"?[`${s}.params`]:ha(e),o=new Set,r=a=>Qt(a).some(c=>n.some(u=>Xt(c.getText(),u)))?!0:Zt(a).some(c=>o.has(c.getText()));for(const a of e.getDescendantsOfKind(l.VariableDeclaration)){const c=a.getInitializer();if(c&&r(c))for(const u of ma(a))o.add(u)}return{names:o,prefixes:n}},Ea=(e,t)=>Qt(e).some(s=>t.prefixes.some(n=>Xt(s.getText(),n)))?!0:Zt(e).some(s=>t.names.has(s.getText())),va=e=>{if(e===void 0||!i.isPropertyAccessExpression(e))return;const t=[];let s=e;for(;i.isPropertyAccessExpression(s);)t.unshift(s.getName()),s=s.getExpression();const n=t.at(-1);if(!(n===void 0||!i.isIdentifier(s)||!fa.has(s.getText())||t.length<2))return{exportName:n,file:t.slice(0,-1).join("/")}},Sa=(e,t,s)=>{const n=Yt(e,0);if(n===void 0)return[];const o=xa(e,t,n),r=[];for(const a of e.getDescendantsOfKind(l.CallExpression)){const c=a.getExpression();if(!i.isPropertyAccessExpression(c)||!da.has(c.getName())||c.getExpression().getText()!==n)continue;const u=a.getArguments()[1];if(!u||!Ea(u,o))continue;const d=va(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},ya=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression)){const o=ga(n);if(o===void 0||!ua.has(o))continue;const r=pa(n);r!==void 0&&s.push(...Sa(r,o==="defineQueue"?"queue":"workflow",t))}return s},Aa=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...ya(o,E(t,n)))}return s},Pt={dbRateLimit:"usesRateLimit",emailGateMiddleware:"usesEmailGate",mask:"usesMask",rateLimit:"usesRateLimit",rls:"usesRls",verifyTurnstileMiddleware:"usesCaptcha"},It=new Set(["account","credential","member","passkey","session","user"]),Na=e=>e.replaceAll(/[-_]/gu," ").replaceAll(/([a-z0-9])([A-Z])/gu,"$1 $2").split(" ").filter(Boolean).map(t=>t.toLowerCase()),ba=e=>{const s=Na(e).at(-1);if(!s)return!1;const n=s.endsWith("s")?s.slice(0,-1):s;return It.has(s)||It.has(n)},Pa=e=>{const t=e.replaceAll(/[^a-z0-9]/giu,"").toLowerCase();return t.endsWith("email")||t.endsWith("emailaddress")},Ia=(e,t)=>{const{objects:s,opaque:n}=Fe(e,t);return wr(s).some(o=>Pa(o))?!0:n?void 0:!1},wa=e=>{const t=e.getArguments()[0];return!t||!i.isObjectLiteralExpression(t)?{usesCaptcha:!1,usesRateLimit:!1}:{usesCaptcha:!!t.getProperty("captcha"),usesRateLimit:!!t.getProperty("rateLimit")}},Ta=e=>{if(i.isCallExpression(e))return e;if(!i.isIdentifier(e))return;const s=e.getSourceFile().getVariableDeclaration(e.getText())?.getInitializer();return s&&i.isCallExpression(s)?s:void 0},te={usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},Ca=e=>{const t=Ta(e),s=t?y(t.getExpression()):void 0;if(t&&s==="protectPublic"){const n=wa(t);return{...te,usesCaptcha:n.usesCaptcha,usesRateLimit:n.usesRateLimit}}return s!==void 0&&s in Pt?{...te,[Pt[s]]:!0}:te},Fa=e=>{const t={...te};let s=e;for(;i.isCallExpression(s);){const n=s.getExpression();if(!i.isPropertyAccessExpression(n))break;const o=n.getName()==="use"?s.getArguments()[0]:void 0;if(o){const r=Ca(o);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},Oa=new Set(["insert","insertMany","insertManyUnsafe","replace"]),Ra=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!Oa.has(t.getName()))return!1;const s=t.getExpression();if(!k(s))return!1;const o=e.getArguments()[0];return!o||!(i.isStringLiteral(o)||i.isNoSubstitutionTemplateLiteral(o))?!1:ba(o.getLiteralText())},La=new Set(["create","runAfter","runAt","send","sendBatch"]),Da=new Set(["queues","scheduler","workflows"]),ka=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!La.has(t.getName()))return!1;let s=t.getExpression();for(;i.isCallExpression(s)||i.isElementAccessExpression(s)||i.isPropertyAccessExpression(s);){if(i.isPropertyAccessExpression(s)&&Da.has(s.getName())){const n=s.getExpression();if(i.isIdentifier(n)&&n.getText()==="ctx")return!0}s=s.getExpression()}return!1},Ma=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="insertManyUnsafe")return!1;const s=t.getExpression();return k(s)},Jt=new Set(["generateObject","generateText","streamObject","streamText"]),Ka=e=>{const t=y(e.getExpression());return t!==void 0&&Jt.has(t)},_a=e=>{const t=y(e.getExpression());if(t===void 0||!Jt.has(t))return!1;const s=e.getArguments()[0];return!s||!i.isObjectLiteralExpression(s)||s.getProperties().some(n=>i.isSpreadAssignment(n))?!1:!s.getProperty("maxOutputTokens")},za=new Set(["log","span","trace"]),$a=new Set(["ai"]),Ua=new Set(["email","mail"]),Ba=new Set(["ai","browser","fetch","mail","notify","queues","sql","storage","workflows"]),Se=(e,t)=>e.getDescendantsOfKind(l.PropertyAccessExpression).some(s=>{if(!t.has(s.getName()))return!1;const n=s.getExpression();return i.isIdentifier(n)&&n.getText()==="ctx"}),qa=new Set([l.ArrowFunction,l.FunctionDeclaration,l.FunctionExpression,l.GetAccessor,l.MethodDeclaration,l.SetAccessor]),Va=new Set(["every","filter","flatMap","forEach","map","some"]),ja=new Set(["all","allSettled","race"]),Wa=e=>{const t=e.getParent();if(!t||!i.isCallExpression(t)||!t.getArguments().includes(e))return;const s=t.getExpression();if(!i.isPropertyAccessExpression(s))return;const n=s.getName();if(Va.has(n))return t;const o=s.getExpression();if(i.isIdentifier(o)&&o.getText()==="Promise"&&ja.has(n))return t},Ha=e=>{let t=e.getParent();for(;t;){if(i.isTryStatement(t)){const s=t.getTryBlock();if(e.getPos()>=s.getPos()&&e.getEnd()<=s.getEnd())return!0}if(qa.has(t.getKind())){const s=Wa(t);if(!s)return!1;t=s;continue}t=t.getParent()}return!1},Ga=e=>{let t=e;for(;;){const s=t.getParent();if(!i.isPropertyAccessExpression(s)||s.getExpression()!==t)return!1;if(s.getName()==="catch")return!0;if(s.getName()!=="then"&&s.getName()!=="finally")return!1;const n=s.getParent();if(!i.isCallExpression(n)||n.getExpression()!==s)return!1;t=n}},Ya=e=>{let t=e;for(;;){const s=t.getParent();if(i.isPropertyAccessExpression(s)&&s.getExpression()===t){t=s;continue}return i.isCallExpression(s)&&s.getExpression()===t?s:void 0}},Xa=e=>{let t=!1,s=!0;for(const n of e.getDescendantsOfKind(l.PropertyAccessExpression)){if(!Ba.has(n.getName()))continue;const o=n.getExpression();if(!i.isIdentifier(o)||o.getText()!=="ctx")continue;const r=Ya(n);r&&(t=!0,!Ha(r)&&!Ga(r)&&(s=!1))}return{handlesErrors:t&&s,reachesOutbound:t}},Qa=e=>e.getDescendantsOfKind(l.ThrowStatement).some(t=>{const s=t.getExpression();if(!i.isNewExpression(s))return!1;const n=s.getExpression();return i.isIdentifier(n)&&n.getText()==="Error"}),wt="lunora-advisor-exempt",Za=/^[\s*/]+/u,Ja=/[\w-]/u,ec=e=>{const s=(e.getFirstAncestorByKind(l.VariableStatement)??e).getLeadingCommentRanges().map(n=>n.getText()).join(`
6
+ `);for(const n of s.split(`
7
+ `)){const o=n.replace(Za,"");if(!o.startsWith(wt))continue;const r=o.slice(wt.length);if(Ja.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:""}},tc=e=>{const[t]=e.getArguments();if(t){if(i.isObjectLiteralExpression(t)){const s=t.getProperty("handler");return s?i.isPropertyAssignment(s)?s.getInitializer():i.isShorthandPropertyAssignment(s)?s.getNameNode():i.isMethodDeclaration(s)?s:void 0:void 0}return t}},sc=(e,t)=>{const s=tc(t);if(!s)return;if(i.isArrowFunction(s)||i.isFunctionExpression(s)||i.isMethodDeclaration(s))return e;if(!i.isIdentifier(s))return;const n=s.getSourceFile(),o=s.getText(),r=n.getVariableDeclaration(o)?.getInitializer();return r&&(i.isArrowFunction(r)||i.isFunctionExpression(r))?r:n.getFunction(o)},nc=e=>{let t=!1,s=!1,n=!1,o=!1,r=!1;for(const u of e.getDescendantsOfKind(l.CallExpression))if(Ra(u)&&(r=!0),ka(u)&&(t=!0),Ma(u)&&(o=!0),Ka(u)&&(s=!0),_a(u)&&(n=!0),r&&t&&o&&n)break;const{handlesErrors:a,reachesOutbound:c}=Xa(e);return{callsMail:Se(e,Ua),emitsEvent:Se(e,za),fanOut:t,handlesErrors:a,reachesOutbound:c,runsAiGeneration:s||Se(e,$a),throwsBareError:Qa(e),unboundedAiGeneration:n,usesInsertManyUnsafe:o,writesUserTable:r}},rc=(e,t)=>{const s=e.getInitializer();if(!s||!i.isCallExpression(s))return;const n=M(s);if(!n||n.kind!=="query"&&n.kind!=="mutation"&&n.kind!=="action")return;const o=n.receiver?Fa(n.receiver):{usesCaptcha:!1,usesEmailGate:!1,usesMask:!1,usesRateLimit:!1,usesRls:!1},r=sc(e,s);return{...r?nc(r):{},...ec(e),...o,analyzableBody:r!==void 0,exportName:e.getName(),file:t,hasEmailArg:Ia(s,n.receiver),kind:n.kind,visibility:n.visibility}},oc=(e,t)=>{const s=[];for(const n of e.getVariableStatements())if(n.isExported())for(const o of n.getDeclarations()){const r=rc(o,t);r&&s.push(r)}return s},ic=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...oc(o,E(t,n)))}return s},ac=new Set(["dbRateLimit","rateLimit"]),cc=e=>i.isArrowFunction(e)?e.getBody():e,lc=(e,t)=>{const s=y(e.getExpression());if(s===void 0||!ac.has(s))return;const n=e.getArguments()[2];if(!n)return;const o=N(n,"key");if(!o)return;const r=cc(o);if(!(!R(r)||z(r)))return{callee:s,exportName:S(e),file:t,limitName:kt(e),line:e.getStartLineNumber()}},uc=(e,t)=>I(e,t,lc),dc=new Set(["findFirst","findFirstOrThrow","findMany","get"]),fc=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||!dc.has(t.getName()))return;const s=t.getExpression();if(k(s)){const n=e.getArguments()[0];return n&&i.isStringLiteral(n)?n.getLiteralText():""}if(i.isPropertyAccessExpression(s)&&k(s.getExpression()))return s.getName()},gc=e=>{let t=e;for(;i.isCallExpression(t);){const s=t.getExpression();if(!i.isPropertyAccessExpression(s))return;if(s.getName()==="query"&&k(s.getExpression())){const n=t.getArguments()[0];return n&&i.isStringLiteral(n)?n.getLiteralText():""}t=s.getExpression()}},pc=e=>{let t=W(e)??e;for(;i.isAwaitExpression(t);)t=W(t.getExpression())??t.getExpression();return t},es=(e,t=!1)=>{const s=pc(e);if(i.isIdentifier(s)){if(t)return;const n=le(s);return n===void 0?void 0:es(n,!0)}if(i.isCallExpression(s))return fc(s)??gc(s)},mc=e=>{const t=e.getBody();if(!i.isBlock(t))return[t];const s=[];for(const n of e.getDescendantsOfKind(l.ReturnStatement)){const o=n.getFirstAncestor(a=>i.isArrowFunction(a)||i.isFunctionExpression(a)||i.isFunctionDeclaration(a)),r=n.getExpression();o===e&&r!==void 0&&s.push(r)}return s},hc=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer();if(s===void 0||!i.isCallExpression(s))return[];const n=M(s);if(n?.kind!=="query")return[];const o=jt(s);if(o===void 0)return[];const r=n.receiver!==void 0&&Hs(n.receiver,"output"),a=n.receiver!==void 0&&Kt(n.receiver,"use","mask"),c=new Set,u=[];for(const d of mc(o)){const v=es(d);v===void 0||c.has(v)||(c.add(v),u.push({exportName:e.getName(),file:t,line:d.getStartLineNumber(),table:v,usesMask:a,usesOutput:r,visibility:n.visibility}))}return u},xc=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=E(t,n);for(const a of o.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...hc(c,r))}return s},Ec=e=>{if(!e||!i.isObjectLiteralExpression(e))return[];const t=[];for(const s of e.getProperties())(i.isPropertyAssignment(s)||i.isShorthandPropertyAssignment(s)||i.isMethodDeclaration(s)||i.isGetAccessorDeclaration(s))&&t.push(s.getName());return t},vc=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&i.isCallExpression(s)?M(s):void 0;if(!n)return[];const o=[];for(const r of e.getDescendantsOfKind(l.CallExpression)){const a=Mt(r);if(a===void 0)continue;const c=Ec(N(a.options,"with"));c.length!==0&&o.push({exportName:e.getName(),file:t,line:r.getStartLineNumber(),parentTable:a.table,relations:c,visibility:n.visibility})}return o},Sc=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=E(t,n);for(const a of o.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...vc(c,r))}return s},oe=e=>{if(i.isStringLiteral(e)||i.isNoSubstitutionTemplateLiteral(e))return e.getLiteralText();if(i.isBinaryExpression(e)&&e.getOperatorToken().getKind()===l.PlusToken){const t=oe(e.getLeft()),s=oe(e.getRight());return t!==void 0&&s!==void 0?t+s:void 0}},yc=e=>{let t=e,s=t.getParent();for(;s!==void 0&&i.isBinaryExpression(s)&&s.getOperatorToken().getKind()===l.PlusToken;)t=s,s=t.getParent();return t!==e&&oe(t)!==void 0},Ac=/(?:^|\/)__tests__\//u,Nc=/\.(?:spec|test)$/u,bc=e=>Ac.test(e)||Nc.test(e),Pc=e=>{const t=e.getParent();if(t!==void 0){if(i.isVariableDeclaration(t)||i.isPropertyAssignment(t)||i.isPropertySignature(t))return t.getName();if(i.isBinaryExpression(t)&&t.getOperatorToken().getKind()===l.EqualsToken)return t.getLeft().getText()}},Ic=(e,t,s)=>Nn(e)?!bc(s)&&bn(Pc(t)):!0,wc=(e,t)=>{const s=[],n=[...e.getDescendantsOfKind(l.BinaryExpression),...e.getDescendantsOfKind(l.StringLiteral),...e.getDescendantsOfKind(l.NoSubstitutionTemplateLiteral)],o=new Set;for(const r of n){if(yc(r))continue;const a=oe(r);if(a===void 0)continue;const c=yn(a);if(c===void 0||!Ic(c,r,t))continue;const u=r.getStartLineNumber(),d=`${String(u)}:${c}`;o.has(d)||(o.add(d),s.push({file:t,kind:c,line:u,preview:An(a)}))}return s},Tc=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...wc(o,E(t,n)))}return s},Cc=(e,t)=>{if(!i.isVariableDeclaration(e))return[];const s=e.getInitializer(),n=s&&i.isCallExpression(s)?M(s):void 0;if(!n)return[];const o=[];for(const r of e.getDescendantsOfKind(l.CallExpression)){const a=Mt(r);if(a===void 0)continue;const c=N(a.options,"includeDeleted");if(c===void 0)continue;const u=i.isTrueLiteral(c),d=!u&&R(c);!u&&!d||o.push({exportName:e.getName(),file:t,fromArgs:d,hardcodedTrue:u,line:r.getStartLineNumber(),table:a.table,visibility:n.visibility})}return o},Fc=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=E(t,n);for(const a of o.getVariableStatements())if(a.isExported())for(const c of a.getDeclarations())s.push(...Cc(c,r))}return s},Oc=new Set(["query","unsafe"]),Rc=e=>{if(!i.isPropertyAccessExpression(e)||!Oc.has(e.getName()))return!1;const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="sql")return!1;const s=t.getExpression();return i.isIdentifier(s)&&s.getText()==="ctx"},Lc=e=>i.isBinaryExpression(e)||i.isTemplateExpression(e),Dc=e=>e.getFirstAncestorByKind(l.VariableDeclaration)?.getName()??"<module>",kc=(e,t)=>{if(!Rc(e.getExpression()))return;const s=e.getArguments()[0];if(!(!s||!Lc(s)))return{exportName:Dc(e),file:t,line:s.getStartLineNumber()}},Mc=(e,t)=>I(e,t,kc),Kc=[["convex",["convex","@convex-dev/"]],["supabase",["@supabase/"]],["firebase",["firebase","@firebase/","firebase-admin"]]],_c=e=>{for(const[t,s]of Kc)for(const n of s)if(e===n||e.startsWith(n.endsWith("/")?n:`${n}/`))return t},zc=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);for(const r of o.getImportDeclarations()){const a=r.getModuleSpecifierValue(),c=_c(a);c!==void 0&&s.push({file:E(t,n),line:r.getStartLineNumber(),moduleSpecifier:a,platform:c})}}return s},$c=new Set(["createMultipartUpload","delete","download","generateUploadUrl","get","getMetadata","getPresignedUrl","getSignedUrl","getUrl","head","put","resumeMultipartUpload","store","upload"]),Uc=(e,t,s=[])=>{const n=new Map(s.map(r=>[`${r.filePath}:${r.exportName}`,r.visibility]));return de(e,t,{argIndex:0,matchReceiver:r=>r==="ctx.storage"||r.startsWith("ctx.storage."),methods:$c,requireUnmodifiedReach:!0}).map(r=>{const a=n.get(`${r.file}:${r.exportName}`);return a===void 0?r:{...r,visibility:a}})},Bc=new Map([["generateUploadUrl",1],["getPresignedUrl",1],["getSignedUrl",1],["store",2],["upload",2]]),qc=e=>e&&i.isNumericLiteral(e)?Number(e.getText()):void 0,Vc=e=>{if(e===void 0)return{analyzable:!0,presentKeys:[]};if(!i.isObjectLiteralExpression(e))return{analyzable:!1,presentKeys:[]};const t=[];let s,n=!1;for(const o of e.getProperties()){if(i.isSpreadAssignment(o)){n=!0;continue}if(i.isPropertyAssignment(o)){const r=o.getName();t.push(r),r==="expiresInSeconds"&&(s=qc(o.getInitializer()));continue}(i.isShorthandPropertyAssignment(o)||i.isMethodDeclaration(o))&&t.push(o.getName())}return{analyzable:!n,expiresInSeconds:s,presentKeys:t}},jc=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName(),s=Bc.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},Wc=(e,t)=>{const s=jc(e.getExpression());if(s!==void 0)return{exportName:S(e),file:t,line:e.getStartLineNumber(),method:s.method,...Vc(e.getArguments()[s.optionsIndex])}},Hc=(e,t)=>I(e,t,Wc),Gc=(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")}),Yc=(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"}),Xc=(e,t)=>{if(t===void 0){const s=e.getArguments()[0];if(s===void 0||!i.isObjectLiteralExpression(s)||s.getProperty("args")===void 0)return!1}return Fe(e,t).opaque},Qc=(e,t)=>{const s=[],n=(o,r)=>{const a=o.getInitializer();if(a===void 0||!i.isCallExpression(a))return;const c=M(a);c!==void 0&&Xc(a,c.receiver)&&s.push(Yc(t,r,a.getStartLineNumber()))};for(const o of e.getVariableStatements().filter(r=>r.isExported()))for(const r of o.getDeclarations())n(r,r.getName());return s},Zc=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n);o!==void 0&&s.push(...Qc(o,E(t,n)))}return s.toSorted((n,o)=>n.cacheKey.localeCompare(o.cacheKey))},Jc=new Set(["RegisteredAction","RegisteredMutation","RegisteredQuery"]),Re=e=>{const t=e.getType(),s=t.getAliasSymbol()?.getName()??t.getSymbol()?.getName();return s!==void 0&&Jc.has(s)?s:void 0},ts=e=>{const t=e.getInitializer();return t===void 0?!1:i.isCallExpression(t)||i.isIdentifier(t)||i.isPropertyAccessExpression(t)},ss={cause:"codegen recognises a procedure only when the initializer is a builder chain, and this one is produced by a call or an alias",remediation:"A factory that returns a procedure cannot be read statically — inline it, or export the chain the factory builds."},el={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."},Le=(e,t,s,n,o)=>({cacheKey:`procedure_not_registered:${e}:${t}`,categories:["SCHEMA"],description:"Codegen registers an export only when the declaration carries `export` and its initializer is literally a builder chain. A procedure written any other way exists at runtime but never reaches `_generated/api.ts`, so no caller can address it.",detail:`\`${t}\` in \`${e}\` (line ${n.toString()}) has type \`${s}\` but was not registered — ${o.cause}.`,facing:"INTERNAL",level:"WARN",metadata:{exportName:t,filePath:e,line:n,typeName:s},name:"procedure_not_registered",remediation:`Assign the builder chain directly: \`export const ${t} = query.input({ … }).query(handler);\`. ${o.remediation}`,title:"Procedure exists at runtime but is missing from the generated API"}),tl=(e,t,s)=>{const n=[];for(const o of e.getVariableStatements().filter(r=>r.isExported()))for(const r of o.getDeclarations()){const a=r.getName();if(s.has(`${t}:${a}`)||!ts(r))continue;const c=Re(r);c!==void 0&&n.push(Le(t,a,c,r.getStartLineNumber(),ss))}return n},sl=(e,t,s)=>{if(s.has(`${t}:default`))return[];const n=[];for(const o of e.getExportAssignments().filter(r=>!r.isExportEquals())){const r=Re(o.getExpression());r!==void 0&&n.push(Le(t,"default",r,o.getStartLineNumber(),ss))}return n},nl=(e,t,s)=>{const n=[];for(const o of e.getExportDeclarations().filter(r=>r.getModuleSpecifier()===void 0))for(const r of o.getNamedExports()){const a=r.getAliasNode()?.getText()??r.getName();if(s.has(`${t}:${a}`))continue;const c=r.getLocalTargetDeclarations().find(d=>i.isVariableDeclaration(d));if(c===void 0||!ts(c))continue;const u=Re(c);u!==void 0&&n.push(Le(t,a,u,r.getStartLineNumber(),el))}return n},rl=(e,t,s)=>[...tl(e,t,s),...sl(e,t,s),...nl(e,t,s)],ol=(e,t,s)=>{const n=new Set(s.map(r=>`${r.filePath}:${r.exportName}`)),o=[];for(const r of m(t)){const a=e.getSourceFile(r);a!==void 0&&o.push(...rl(a,E(t,r),n))}return o.toSorted((r,a)=>r.cacheKey.localeCompare(a.cacheKey))},il=new Set(["when","where"]),ye=new Set(["definePolicy","defineShape"]),al=e=>{if(!i.isCallExpression(e))return;const t=e.getExpression();if(i.isPropertyAccessExpression(t)){const n=t.getName();return ye.has(n)?n:void 0}if(!i.isIdentifier(t))return;for(const n of t.getSymbol()?.getDeclarations()??[])if(i.isImportSpecifier(n)){const o=n.getNameNode().getText();return ye.has(o)?o:void 0}const s=t.getText();return ye.has(s)?s:void 0},cl=e=>i.isObjectLiteralExpression(e)&&e.getProperties().length===0,ns=e=>{if(e!==void 0){if(i.isReturnStatement(e)&&e.getExpression()===void 0||e.getKind()===l.UndefinedKeyword||e.getText()==="undefined")return"undefined";if(cl(e))return"empty-object";if(i.isParenthesizedExpression(e))return ns(e.getExpression())}},De=e=>e.getAncestors().find(t=>i.isArrowFunction(t)||i.isFunctionExpression(t)||i.isFunctionDeclaration(t)),ll=e=>e.getDescendantsOfKind(l.ReturnStatement).filter(t=>De(t)===e),rs=e=>e.getDescendantsOfKind(l.ConditionalExpression).filter(t=>De(t)===e),ul=e=>{const t=ll(e);return t.length>1?!0:t.some(s=>s.getFirstAncestorByKind(l.IfStatement)!==void 0)||rs(e).length>0},dl=e=>e.getDescendantsOfKind(l.IfStatement).filter(t=>De(t)===e),Ie=e=>e.getKind()===l.NullKeyword||e.getKind()===l.FalseKeyword||i.isIdentifier(e)&&e.getText()==="undefined"?!0:i.isNumericLiteral(e)?e.getLiteralValue()===0:i.isStringLiteral(e)&&e.getLiteralValue()==="",fl=(e,t)=>Ie(e)||Ie(t),gl=new Map([[l.EqualsEqualsEqualsToken,"positive"],[l.EqualsEqualsToken,"positive"],[l.ExclamationEqualsEqualsToken,"negative"],[l.ExclamationEqualsToken,"negative"]]),Tt=e=>!Ie(e)&&(i.isLiteralExpression(e)||e.getKind()===l.TrueKeyword),pl=(e,t,s)=>{const n=gl.get(e);if(n!==void 0)return fl(t,s)?n==="positive"?"negative":"positive":Tt(t)||Tt(s)?void 0:n},j=e=>{if(i.isParenthesizedExpression(e))return j(e.getExpression());if(i.isPrefixUnaryExpression(e)&&e.getOperatorToken()===l.ExclamationToken)return"negative";if(i.isBinaryExpression(e)){const t=e.getOperatorToken().getKind(),s=pl(t,e.getLeft(),e.getRight());if(s!==void 0)return s;if(t===l.AmpersandAmpersandToken||t===l.BarBarToken){const n=j(e.getLeft()),o=j(e.getRight());return n===o?n:"indeterminate"}}return i.isIdentifier(e)||i.isPropertyAccessExpression(e)||i.isElementAccessExpression(e)||i.isCallExpression(e)?"positive":"indeterminate"},Ct=e=>{if(e!==void 0){if(i.isReturnStatement(e))return e;if(i.isBlock(e)){const t=e.getStatements().at(-1);return t!==void 0&&i.isReturnStatement(t)?t:void 0}}},ml=e=>{if(e.getElseStatement()!==void 0)return;const t=e.getNextSiblingIfKind(l.ReturnStatement);return t!==void 0&&t.getNextSibling()===void 0?t:void 0},hl=e=>i.isReturnStatement(e)?e.getExpression()??e:e,xl=e=>{const t=[];for(const s of rs(e)){const n=j(s.getCondition());n==="positive"?t.push(s.getWhenFalse()):n==="negative"&&t.push(s.getWhenTrue())}for(const s of dl(e)){const n=j(s.getExpression());if(n==="indeterminate")continue;const o=n==="negative"?Ct(s.getThenStatement()):Ct(s.getElseStatement())??ml(s);o!==void 0&&t.push(hl(o))}return t},El=e=>{for(const t of e.getAncestors())if(i.isVariableDeclaration(t)){const s=t.getNameNode();if(i.isIdentifier(s))return s.getText()}return"<anonymous>"},vl=(e,t,s)=>{if(!i.isCallExpression(e))return[];const[n]=e.getArguments();if(!n||!i.isObjectLiteralExpression(n))return[];const o=[];for(const r of n.getProperties()){if(!i.isPropertyAssignment(r)||!il.has(r.getName()))continue;const a=r.getInitializer();if(!(!a||!(i.isArrowFunction(a)||i.isFunctionExpression(a)))&&ul(a))for(const c of xl(a)){const u=ns(c);u!==void 0&&o.push({exportName:El(e),file:s,form:u,key:r.getName(),line:c.getStartLineNumber(),owner:t})}}return o},Sl=(e,t)=>{const s=[];for(const n of e.getDescendantsOfKind(l.CallExpression)){const o=al(n);o!==void 0&&s.push(...vl(n,o,t))}return s},yl=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n);s.push(...Sl(o,E(t,n)))}return s},Al=new Set(["query","upsert","upsertMany"]),Nl=e=>{if(!i.isPropertyAccessExpression(e))return;const t=e.getName();if(Al.has(t))return e.getExpression().getText()==="ctx.vectors"?t:void 0},bl=(e,t)=>{const s=Nl(e.getExpression());if(s===void 0)return;const n=e.getArguments()[1];if(!n)return;const o=N(n,"namespace");if(!(!o||!R(o)||z(o)))return{exportName:S(e),file:t,line:e.getStartLineNumber(),method:s}},Pl=(e,t)=>I(e,t,bl),Il=e=>{const t=e.getExpression();if(!i.isPropertyAccessExpression(t)||t.getName()!=="get")return!1;const s=t.getExpression();return i.isPropertyAccessExpression(s)?s.getName()==="workflows":i.isIdentifier(s)&&s.getText()==="workflows"},wl=e=>{const t=e.getArguments()[0];return t&&i.isStringLiteral(t)?t.getLiteralText():""},Tl=(e,t)=>{const s=[];for(const n of m(t)){const o=e.getSourceFile(n)??e.addSourceFileAtPath(n),r=E(t,n);for(const a of o.getDescendantsOfKind(l.CallExpression)){if(!Il(a))continue;const c=Bs(a);c!==""&&s.push({exportName:c,file:r,line:a.getStartLineNumber(),workflow:wl(a)})}}return s},Cl=".lunora-schema.json",w=(e,t)=>{b(e)&&Rt(e,"utf8")===t||hs(e,t,"utf8")},O=(e,t)=>{if(t===""){xs(e,{force:!0});return}w(e,t)},Fl=e=>{const t=f(e,"package.json");if(b(t))try{const s=JSON.parse(Rt(t,"utf8"));return typeof s.version=="string"&&s.version!==""?s.version:void 0}catch{return}},Ol=()=>{const e=process.env.LUNORA_CODEGEN_TIMING;return e!==void 0&&e!==""},Rl=e=>{let t=b(e)?e:J(e);for(;t&&t!==J(t);){const s=f(t,"tsconfig.json");if(b(s))return s;t=J(t)}},Ft=e=>e.replaceAll("\\","/"),Ll=(e,t,s)=>{if(s&&e.length>0){const r=e.map(a=>`"${a.exportName}"`).join(", ");throw new D("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 o=t.columns.length>0;for(const r of e){if(r.table===void 0){if(o)throw new D("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 D("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})}},ie=(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)},Ot=(e,t,s)=>e.getSourceFile(t)?.getFullText()===s,Dl=8,kl=e=>{const{agents:t,apiPath:s,generatedFunctionsPath:n,lunoraDirectory:o,migrations:r,project:a,shapes:c,usesSandbox:u,useUmbrella:d,workflows:v}=e;let x=it(a,o),P=ct(a,o),K=at(a,o);lt([...x,...P].map(g=>g.filePath)),lt(K.filter(g=>g.stream).map(g=>g.filePath),"http-stream");for(let g=1;;g+=1){const T=ks({agents:t,functions:x,httpRoutes:K,mutators:P,useUmbrella:d,workflows:v}),C=Ms({agents:t,functions:x,migrations:r,mutators:P,shapes:c,useUmbrella:d,usesSandbox:u});if(g>=Dl||Ot(a,s,T)&&Ot(a,n,C))return{apiContent:T,functions:x,functionsContent:C,httpRoutes:K,mutators:P};ie(a,s,T),ie(a,n,C),x=it(a,o),P=ct(a,o),K=at(a,o)}},Ml=e=>{const t=Rl(e);return t?new ot({skipAddingFilesFromTsConfig:!1,tsConfigFilePath:t,useInMemoryFileSystem:!1}):new ot({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1})},Fu=(e,t)=>{const s=m(t),n=f(t,"schema.ts");b(n)&&s.push(n);for(const c of s){const u=e.getSourceFile(c);u===void 0?e.addSourceFileAtPath(c):u.refreshFromFileSystemSync()}const o=new Set(s.map(c=>Ft(c))),r=Ft(t),a=`${r}/`;for(const c of e.getSourceFiles()){const u=c.getFilePath();(u===r||u.startsWith(a))&&!o.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)}}},Ou=e=>{const t=Ol(),s=t?Ee.now():0,n=f(e.projectRoot,e.lunoraDirectory??"lunora"),o=f(n,"schema.ts");if(!b(o))throw new D("INTERNAL",`schema.ts not found at ${o}`);const r=e.project??Ml(n);sn(ko);const a=Sn(r,o,e.projectRoot),{agents:c,containers:u,crons:d,dataModelContent:v,dependencies:x,entryCronTriggers:P,env:K,featureUsage:g,hasFlags:T,hasNotify:C,identity:B,platformGate:A,queues:L,serverContent:$,storageRulesMetadata:q,usesSandbox:G,useUmbrella:_,workflows:F}=er({lunoraDirectory:n,project:r,projectRoot:e.projectRoot,schema:a,target:e.target}),p=f(n,"_generated"),ke=f(p,"dataModel.ts"),Me=f(p,"server.ts"),os=f(p,"api.ts"),is=f(p,"functions.ts");ie(r,ke,v),ie(r,Me,$);const fe=dn(r,n),V=Pn(r,n),{apiContent:Ke,functions:U,functionsContent:_e,httpRoutes:as,mutators:cs}=kl({agents:c,apiPath:os,generatedFunctionsPath:is,lunoraDirectory:n,migrations:fe,project:r,shapes:V,useUmbrella:_,usesSandbox:G,workflows:F}),Y=e.lint===!1?void 0:Ss({adminRoutes:cr(r,n),aiRawRuns:dr(r,n),aiToolSideEffects:yr(r,n),argumentDerivedFetches:br(r,n),argumentValidators:Dr(r,n),authApiCalls:nn(r,n),authConfigs:Vr(r,n),browserUrlAccesses:Yr(r,n),configCalls:no(r,n),containerKeyAccesses:oo(r,n),containerOverrides:fo(r,n),containers:u,exportSinks:ho(r,n),staleMigrationImports:zc(r,n),failOpenGuards:yo(r,n),flagReads:Fo(r,n),flagSecurityDefaults:Do(r,n),geoIndexUsages:_o(r,n),httpActionGuards:jo(r,n),httpHeaderWrites:ti(r,n),hyperdriveCalls:cn(r,n),identityClaimReads:ci(r,n),imageDeliveryUrlAccesses:ui(r,n),inserts:ln(r,n),kvKeyAccesses:fi(r,n,U),mailRecipientAccesses:xi(r,n),maskProcedures:un(r,n),maskStrategies:Pi(r,n),mutatorWrites:Oi(r,n),nondeterministicCalls:pn(r,n),normalizeIdAuthorizations:Hi(r,n),notifyCalls:hn(r,n),notifyConfig:mn(r,n),ownerFieldWrites:ta(r,n,U),unrestrictedWhereBranches:yl(r,n),paymentWebhooks:la(r,n),privilegedDispatches:Aa(r,n),procedureProtections:ic(r,n),queries:tn(r,n),queues:L,r2sqlCalls:xn(r,n),ratelimitKeySelectors:uc(r,n),rawRowReturns:xc(r,n),relationLoads:Sc(r,n),rlsProcedures:En(r,n),schema:a,secretLiterals:Tc(r,n),shapes:V,softDeleteReads:Fc(r,n),sqlInterpolations:Mc(r,n),storageKeyAccesses:Uc(r,n,U),storageUploads:Hc(r,n),vectorNamespaceAccesses:Pl(r,n),workflowCalls:Tl(r,n),workflows:F,wranglerVariables:e.wranglerVariables}),ze=Y===void 0?[]:[...Es(Y,{source:"static"}),...ol(r,n,U),...Zc(r,n)],ls=vn(r,n),$e=Ai(r,n);Ll(V,$e,Si(r,n));const us=T?Po(r,n):[],ge=A.signals.vectorStore!==!1,X=Gc(g,{containerCount:u.length,cronCount:d.length,dependencies:x,hasPaymentTables:ra(a.tables),queueCount:L.length,storageColumnCount:Object.keys(Lt(a)).length,storageRuleCount:q.rules.length,vectorIndexCount:a.vectorIndexes.length,vectorStoreSupported:ge,workflowCount:F.length}),Ue=t?Ee.now():0,pe=On(a,fe.map(h=>h.id)),Be=bs({advisories:ze,advisorProcedures:Y?.procedureProtections??[],agents:c,containers:u,env:K,flagKeys:us,hasAccessFacade:g.access,hasAi:g.ai,hasAnalytics:g.analytics,hasBrowser:g.browser,hasFlags:T,hasHyperdrive:g.hyperdrive,hasImages:g.images,hasKv:g.kv,hasNotify:C,hasPayments:g.payments,hasPipelines:g.pipelines,hasR2sql:g.r2sql,hasVectors:ge,hasX402:g.x402,maskMetadata:$e,mutators:cs,queues:L,rlsMetadata:ls,schema:a,schemaSnapshot:pe,shapes:V,storageRules:q,studioFeatures:X,useUmbrella:_,workflows:F}),qe=Ps(V,x.has("@lunora/db"),_),Ve=Is(u,a.jurisdiction),je=ws(F),We=Ts(c),He=Cs(L),Ge=Fs(d),Ye=Os(a.vectorIndexes),Q=Rs(a,_),Xe=Ls(x.has("@lunora/seed")),Z=e.apiSpec??"openapi",me=Z==="openapi"||Z==="both",he=Z==="openrpc"||Z==="both",Qe=In({emailAgents:c.filter(h=>h.onEmail===!0).map(h=>({bindingName:h.bindingName,exportName:h.exportName})),hasAccess:x.has("@lunora/cloudflare-access"),hasAi:g.ai,hasAnalytics:g.analytics,hasAuth:x.has("@lunora/auth"),hasBrowser:g.browser,hasFramework:x.has("@lunora/astro")||x.has("@lunora/svelte")||x.has("@lunora/vue"),hasGlobal:a.tables.some(h=>h.shardMode==="global"&&h.globalBackend!=="hyperdrive"),hasHyperdrive:g.hyperdrive,hasHyperdriveGlobal:a.tables.some(h=>h.shardMode==="global"&&h.globalBackend==="hyperdrive"),hasImages:g.images,hasKv:g.kv,hasKvIntrospector:X.kv,hasNotify:C,hasPayments:g.payments,hasR2sql:g.r2sql,hasQueue:L.some(h=>h.mode==="push"),hasScheduler:X.scheduler,hasStorage:X.storage,hasVectors:ge,hasWorkflow:F.length>0,hasX402:g.x402,identity:B,jurisdiction:a.jurisdiction,tableNames:a.tables.map(h=>h.name),useUmbrella:_,vectorIndexCount:a.vectorIndexes.length,voiceAgents:c.filter(h=>h.voice===!0&&h.voiceBindingName!==void 0).map(h=>({bindingName:h.voiceBindingName,exportName:h.exportName})),wantsOpenApi:me,wantsOpenRpc:he}),Ze=Fl(e.projectRoot),Je=wn({functions:U,httpRoutes:as,version:Ze}),et=Cn({functions:U,version:Ze}),tt=`${JSON.stringify(Je,void 0,2)}
8
+ `,st=`${JSON.stringify(et,void 0,2)}
9
+ `,nt=Tn(Je),rt=Fn(et),xe=f(n,Cl),ds=b(xe);if(e.dryRun||(b(p)||ms(p,{recursive:!0}),w(f(p,"app.ts"),Qe),w(ke,v),w(f(p,"api.ts"),Ke),w(Me,$),w(f(p,"functions.ts"),_e),w(f(p,"shard.ts"),Be),w(f(p,"crons.ts"),Ge),w(f(p,"vectors.ts"),Ye),w(f(p,"drizzle.global.ts"),Q.global),w(f(p,"drizzle.shard.ts"),Q.shard),O(f(p,"containers.ts"),Ve),O(f(p,"workflows.ts"),je),O(f(p,"agents.ts"),We),O(f(p,"queues.ts"),He),O(f(p,"seed.ts"),Xe),O(f(p,"collections.ts"),qe),O(f(p,"openapi.json"),me?tt:""),O(f(p,"openapi.ts"),me?nt:""),O(f(p,"openrpc.json"),he?st:""),O(f(p,"openrpc.ts"),he?rt:""),(!ds||e.updateSchemaBaseline===!0)&&w(xe,vs(pe))),t){const h=Ee.now(),fs=Math.round(h-s),gs=Math.round(Ue-s),ps=Math.round(h-Ue);console.error(`@lunora/codegen: codegen took ${fs.toString()}ms (discovery ${gs.toString()}ms, emit ${ps.toString()}ms)`)}return{advisories:ze,advisorContext:Y,agents:c,containers:u,cronTriggers:[...new Set([...Ds(d),...P])],generated:{agents:We,api:Ke,app:Qe,collections:qe,containers:Ve,crons:Ge,dataModel:v,drizzleGlobal:Q.global,drizzleShard:Q.shard,functions:_e,openApi:tt,openApiModule:nt,openRpc:st,openRpcModule:rt,queues:He,seed:Xe,server:$,shard:Be,vectors:Ye,workflows:je},migrations:fe,outputDirectory:p,platformDiagnostics:A.diagnostics,queues:L,schemaSnapshot:pe,schemaSnapshotPath:xe,workflows:F}};export{Cl as SCHEMA_SNAPSHOT_FILENAME,Ml as createCodegenProject,Rl as findTsconfig,Fu as refreshCodegenProject,Ou as runCodegen};
@@ -1 +1 @@
1
- import{existsSync as f}from"node:fs";import{join as l}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{a as g}from"./parse-validator-CMV0eq2a.mjs";const m="shapes.ts",d=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},S=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},h=r=>{if(o.isIdentifier(r))return d(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineShape"&&o.isIdentifier(t)&&S(t)}return!1},x=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return;const e=t.getProperty("table");if(!e||!o.isPropertyAssignment(e))return;const i=e.getInitializer();return i&&o.isStringLiteral(i)?i.getLiteralValue():void 0},b=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return{};const e=t.getProperty("args");if(!e||!o.isPropertyAssignment(e))return{};const i=e.getInitializer();return!i||!o.isObjectLiteralExpression(i)?{}:g(i)},y=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(!h(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:b(s),exportName:n.getText(),filePath:"shapes",table:x(s)})}return t},v=(r,t)=>{const e=l(t,m);if(!f(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),s=y(i);return s.sort((a,n)=>a.exportName.localeCompare(n.exportName)),s};export{m as SHAPES_FILENAME,v as discoverShapes};
1
+ import{existsSync as f}from"node:fs";import{join as l}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{a as g}from"./parse-validator-tdRHHDzh.mjs";const m="shapes.ts",d=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},S=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},h=r=>{if(o.isIdentifier(r))return d(r);if(o.isPropertyAccessExpression(r)){const t=r.getExpression();return r.getName()==="defineShape"&&o.isIdentifier(t)&&S(t)}return!1},x=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return;const e=t.getProperty("table");if(!e||!o.isPropertyAssignment(e))return;const i=e.getInitializer();return i&&o.isStringLiteral(i)?i.getLiteralValue():void 0},b=r=>{const[t]=r.getArguments();if(!t||!o.isObjectLiteralExpression(t))return{};const e=t.getProperty("args");if(!e||!o.isPropertyAssignment(e))return{};const i=e.getInitializer();return!i||!o.isObjectLiteralExpression(i)?{}:g(i)},y=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(!h(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:b(s),exportName:n.getText(),filePath:"shapes",table:x(s)})}return t},v=(r,t)=>{const e=l(t,m);if(!f(e))return[];const i=r.getSourceFile(e)??r.addSourceFileAtPath(e),s=y(i);return s.sort((a,n)=>a.exportName.localeCompare(n.exportName)),s};export{m as SHAPES_FILENAME,v as discoverShapes};
@@ -1,3 +1,3 @@
1
- import{G as S}from"./emit-BNdsZPcd.mjs";import{s as p}from"./paths-C-9fwEgQ.mjs";import{LUNORA_ERROR_CODES as O,objectSchema as h,validatorIrToJsonSchema as u}from"./LUNORA_ERROR_CODES-CW7-uASH.mjs";const E="/_lunora/rest",A=["authorization","cf-access-jwt-assertion","cookie","x-payment"],f=["x-d1-bookmark","x-lunora-shard-key"],P=e=>[...A,...(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(", ")},T=(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(", ")},b=e=>e.scope==="public"?y(e.vary,...P(e),...f):y(e.vary,...f),x=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=x(e);if(t!==void 0)return`${E}/${t.namespace}/${t.name}`},k=e=>e==="query"?"GET":"POST",m="#/components/responses/LunoraError",v=/:([A-Za-z_$][\w$]*)/gu,q=e=>[...e.matchAll(v)].map(t=>t[1]),_=e=>e.replaceAll(v,"{$1}"),l=e=>e.kind==="optional"?e.inner??e:e,j=e=>{const t=new Set(q(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."},C=e=>{const t=p(e.filePath),r=j(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},w=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}`}},D=(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:T(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=b(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}},L=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o=N(r);if(o===void 0)return;const s=k(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).",...D(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}},I=e=>{const t=e.version??"0.0.0",r={},o=new Set;for(const n of e.httpRoutes){const a=_(n.path),i=r[a]??{};i[n.method.toLowerCase()]=C(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}=w(n);r[i]={post:a},o.add(p(n.filePath))}for(const n of s){if(n.expose?.rest!==!0)continue;const a=L(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:O,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}},J=e=>`${JSON.stringify(I(e),void 0,2)}
1
+ import{G as S}from"./emit-Lx7UkoGn.mjs";import{s as p}from"./paths-C-9fwEgQ.mjs";import{LUNORA_ERROR_CODES as O,objectSchema as h,validatorIrToJsonSchema as u}from"./LUNORA_ERROR_CODES-CW7-uASH.mjs";const E="/_lunora/rest",A=["authorization","cf-access-jwt-assertion","cookie","x-payment"],f=["x-d1-bookmark","x-lunora-shard-key"],P=e=>[...A,...(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(", ")},T=(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(", ")},b=e=>e.scope==="public"?y(e.vary,...P(e),...f):y(e.vary,...f),x=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=x(e);if(t!==void 0)return`${E}/${t.namespace}/${t.name}`},k=e=>e==="query"?"GET":"POST",m="#/components/responses/LunoraError",v=/:([A-Za-z_$][\w$]*)/gu,q=e=>[...e.matchAll(v)].map(t=>t[1]),_=e=>e.replaceAll(v,"{$1}"),l=e=>e.kind==="optional"?e.inner??e:e,j=e=>{const t=new Set(q(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."},C=e=>{const t=p(e.filePath),r=j(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},w=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}`}},D=(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:T(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=b(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}},L=e=>{const t=p(e.filePath),r=`${t}:${e.exportName}`,o=N(r);if(o===void 0)return;const s=k(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).",...D(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}},I=e=>{const t=e.version??"0.0.0",r={},o=new Set;for(const n of e.httpRoutes){const a=_(n.path),i=r[a]??{};i[n.method.toLowerCase()]=C(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}=w(n);r[i]={post:a},o.add(p(n.filePath))}for(const n of s){if(n.expose?.rest!==!0)continue;const a=L(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:O,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}},J=e=>`${JSON.stringify(I(e),void 0,2)}
2
2
  `,U=e=>`${S}export const openApiSpec: Record<string, unknown> = ${JSON.stringify(e,void 0,4)};
3
3
  `;export{I as buildOpenApiDocument,J as emitOpenApi,U as emitOpenApiModule};
@@ -0,0 +1 @@
1
+ import{s as x}from"./paths-C-9fwEgQ.mjs";import{listLunoraSourceFiles as P,lunoraRelativePath as E}from"./listLunoraSourceFiles-lHrzFhbX.mjs";import{b as f,c as b}from"./classify-procedure-call-C5BOBVM7.mjs";import{Node as s,SyntaxKind as A}from"ts-morph";import{p as N,r as m,a as v}from"./parse-validator-tdRHHDzh.mjs";import{u as y}from"./unwrap-handler-return-CmIWbykC.mjs";const F=i=>{const e=i.getArguments()[0];if(!e||!s.isObjectLiteralExpression(e))return"unknown";const t=e.getProperty("handler");if(!t||!s.isPropertyAssignment(t))return"unknown";const r=t.getInitializer();return!r||!(s.isArrowFunction(r)||s.isFunctionExpression(r))?"unknown":y(r)},z=i=>{const e=i.getArguments()[0];return!e||!(s.isArrowFunction(e)||s.isFunctionExpression(e))?"unknown":y(e)},C=i=>{let e={};for(const t of f(i)){if(t.name!=="input")continue;const r=t.call.getArguments()[0],n=r!==void 0&&s.isExpression(r)?m(r):void 0;n!==void 0&&(e={...v(n),...e})}return e},S=i=>{const e=f(i).find(r=>r.name==="output");if(!e)return;const t=e.call.getArguments()[0];return t&&s.isExpression(t)?N(t):void 0},u=(i,e)=>{const t=i.getProperty(e);if(t===void 0||!s.isPropertyAssignment(t))return;const r=t.getInitializer();return r!==void 0&&s.isStringLiteral(r)?r.getLiteralValue():void 0},d=(i,e)=>{const t=i.getProperty(e);if(t===void 0||!s.isPropertyAssignment(t))return;const r=t.getInitializer();return r!==void 0&&s.isNumericLiteral(r)?r.getLiteralValue():void 0},O=i=>{const e=i.getProperty("cache");if(e===void 0||!s.isPropertyAssignment(e))return;const t=e.getInitializer();if(t===void 0||!s.isObjectLiteralExpression(t))return;const r=u(t,"scope"),n=d(t,"maxAge"),o=d(t,"staleWhileRevalidate"),a=u(t,"tag"),c=u(t,"vary"),g={...n===void 0?{}:{maxAge:n},...r==="private"||r==="public"?{scope:r}:{},...o===void 0?{}:{staleWhileRevalidate:o},...a===void 0?{}:{tag:a},...c===void 0?{}:{vary:c}};return Object.keys(g).length===0?void 0:g},L=i=>{if(i===void 0||!s.isObjectLiteralExpression(i))return{};const e=O(i),t=i.getProperty("rest");return t!==void 0&&s.isPropertyAssignment(t)?{...e===void 0?{}:{cache:e},rest:t.getInitializer()?.getText()==="true"}:e===void 0?{}:{cache:e}},I=i=>{const e=f(i).find(t=>t.name==="expose");return e?L(e.call.getArguments()[0]):void 0},T=i=>{const e=i.getArguments()[0];if(!e||!s.isObjectLiteralExpression(e))return{};const t=e.getProperty("args");if(!t||!s.isPropertyAssignment(t))return{};const r=t.getInitializer(),n=r===void 0?void 0:m(r);return n===void 0?{}:v(n)},k=8,l=(i,e=0)=>{if(e>k)return;if(s.isCallExpression(i))return i;if(s.isParenthesizedExpression(i)||s.isAsExpression(i)||s.isSatisfiesExpression(i)||s.isNonNullExpression(i))return l(i.getExpression(),e+1);if(!s.isIdentifier(i)&&!s.isPropertyAccessExpression(i))return;const t=i.getSymbol()?.getValueDeclaration();return t?p(t,e+1):void 0},p=(i,e)=>{if(s.isVariableDeclaration(i)||s.isPropertyAssignment(i)){const t=i.getInitializer();return t?l(t,e):void 0}if(s.isShorthandPropertyAssignment(i)){const t=i.getValueSymbol()?.getValueDeclaration();return t?p(t,e+1):void 0}if(s.isBindingElement(i)){const t=i.getPropertyNameNode()?.getText()??i.getName(),o=i.getFirstAncestorByKind(A.VariableDeclaration)?.getInitializer()?.getType().getProperty(t)?.getValueDeclaration();return o?p(o,e+1):void 0}},V=i=>{const e=i.getNameNode();if(s.isObjectBindingPattern(e)){const n=[];for(const o of e.getElements()){const a=l(o.getNameNode());a&&n.push([o.getName(),a])}return n}const t=i.getInitializer(),r=t&&(s.isCallExpression(t)?t:l(t));return r?[[i.getName(),r]]:[]},w=i=>{const e=b(i);if(e){if(e.receiver){const t=I(e.receiver),r=S(e.receiver);return{args:C(e.receiver),...t?{expose:t}:{},kind:e.kind,...r?{output:r}:{},returnType:z(i),visibility:e.visibility}}return e.lifecycle?{args:{},kind:e.kind,lifecycle:e.lifecycle,returnType:"void",visibility:e.visibility}:{args:T(i),kind:e.kind,returnType:F(i),visibility:e.visibility}}},h=(i,e,t)=>{const r=w(i);if(r)return{args:r.args,exportName:e,filePath:t,kind:r.kind,returnType:r.returnType,...r.output?{output:r.output}:{},visibility:r.visibility,...r.expose?{expose:r.expose}:{},...r.lifecycle?{lifecycle:r.lifecycle}:{}}},D=(i,e)=>{const t=[];for(const r of i.getExportAssignments()){if(r.isExportEquals())continue;const n=l(r.getExpression()),o=n?h(n,"default",e):void 0;o&&t.push(o)}return t},j=(i,e)=>{const t=[];for(const r of i.getVariableStatements())if(r.isExported())for(const n of r.getDeclarations())for(const[o,a]of V(n)){const c=h(a,o,e);c&&t.push(c)}return t.push(...D(i,e)),t},R=i=>{const e=new Map;for(const t of i){const r=x(t.filePath),n=e.get(r);if(n&&n!==t.filePath)throw Object.assign(new Error(`Namespace collision: "${n}" and "${t.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:[n,t.filePath],status:500});e.set(r,t.filePath)}},W=(i,e)=>{const t=P(e),r=[];for(const n of t){const o=i.getSourceFile(n)??i.addSourceFileAtPath(n),a=E(e,n);r.push(...j(o,a))}return r.sort((n,o)=>`${n.filePath}:${n.exportName}`.localeCompare(`${o.filePath}:${o.exportName}`)),R(r),r};export{W as default};
@@ -1 +1 @@
1
- import{Node as i}from"ts-morph";import{p as m,a as l}from"./parse-validator-CMV0eq2a.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./listLunoraSourceFiles-lHrzFhbX.mjs";import{u as f}from"./unwrap-handler-return-CmIWbykC.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{p as m,a as l}from"./parse-validator-tdRHHDzh.mjs";import{listLunoraSourceFiles as d,lunoraRelativePath as h}from"./listLunoraSourceFiles-lHrzFhbX.mjs";import{u as f}from"./unwrap-handler-return-CmIWbykC.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};