@lunora/codegen 1.0.0-alpha.296 → 1.0.0-alpha.298

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
@@ -111,12 +111,22 @@ interface IndexSnapshot {
111
111
  fields: ReadonlyArray<string>;
112
112
  unique: boolean;
113
113
  }
114
- /** A single relation's structural shape. */
115
- interface RelationSnapshot {
114
+ /** A single relation's structural shape: a foreign-key relation, or a many-to-many one through a join table. */
115
+ type RelationSnapshot = {
116
116
  field: string;
117
117
  kind: "many" | "one";
118
118
  table: string;
119
- }
119
+ through?: never;
120
+ } | {
121
+ field?: never;
122
+ kind: "many";
123
+ table: string;
124
+ through: {
125
+ from: string;
126
+ table: string;
127
+ to: string;
128
+ };
129
+ };
120
130
  /** A table's declarative `.ttl(field, { after })` auto-expiry policy. */
121
131
  interface TtlSnapshot {
122
132
  /** Millisecond offset added to `field` to derive the expiry; absent ⇒ `field` IS the absolute expiry (an offset of zero). */
@@ -283,7 +293,7 @@ type CallSiteScope = AdvisorCallSiteScope;
283
293
  interface CallEdgeIR {
284
294
  /**
285
295
  * `true` when the hop may not take effect on every pass of its function —
286
- * see `isConditionalSite` in `discover/call-edges.ts` for the rules. Set
296
+ * see `conditionOf` in `discover/call-edges.ts` for the rules. Set
287
297
  * only, never `false`. The `dispatch_cycle` lint's false-positive gate.
288
298
  */
289
299
  conditional?: true;
@@ -292,6 +302,14 @@ interface CallEdgeIR {
292
302
  kind: "call" | "enqueue" | "invoke" | "publish" | "schedule";
293
303
  /** 1-based line of the call. */
294
304
  line: number;
305
+ /**
306
+ * `true` alongside `conditional` when a loop's body or update clause is the
307
+ * ONLY thing that may stop the hop — the loop may run zero times, but a
308
+ * queue consumer's `for (const message of batch.messages)` always has a
309
+ * message. Set only, never `false`. The queue cycle lint reads it; the
310
+ * scheduler lints still treat the hop as conditional.
311
+ */
312
+ loopOnly?: true;
295
313
  reason?: string;
296
314
  /**
297
315
  * The facts of a scheduled dispatch, present on `schedule` edges only. `delayMs`
@@ -345,6 +363,25 @@ interface WorkflowCallIR {
345
363
  /** The referenced workflow export name, or `""` when the argument is not a string literal. */
346
364
  workflow: string;
347
365
  }
366
+ /**
367
+ * A `ctx.db.count("table", …)` or `ctx.db.<table>.count(…)` call discovered in a
368
+ * function body. `count()` is answered from a counter only when the table declares an
369
+ * aggregate index (`TableIR.aggregateIndexed`); otherwise it runs `COUNT(*)` over the
370
+ * table. `indexed` is `false` exactly for that scan, so the `count_without_index` lint
371
+ * reports only those; an unknown table or a dynamic name reads as `indexed: true`.
372
+ */
373
+ interface CountReadIR {
374
+ /** Source file relative to `<projectRoot>/lunora/`, without extension. */
375
+ file: string;
376
+ /** `false` only when the table is known and declares no aggregate index. */
377
+ indexed: boolean;
378
+ /** 1-based line of the `count(...)` call. */
379
+ line: number;
380
+ /** Who the call runs on behalf of. */
381
+ scope: CallSiteScope;
382
+ /** Counted table name, or `""` when the table argument is not a string literal. */
383
+ table: string;
384
+ }
348
385
  /**
349
386
  * A `ctx.db.query("table")…` read discovered in a function body, reduced to what
350
387
  * the query advisor lints need: which table, whether the chain narrows with an
@@ -1154,7 +1191,8 @@ interface RankIndexIR {
1154
1191
  /** Ordered sort keys driving the rank. */
1155
1192
  sortBy: ReadonlyArray<RankSortKeyIR>;
1156
1193
  }
1157
- interface RelationIR {
1194
+ /** A `one` / `many` relation backed by one foreign-key column. */
1195
+ interface KeyedRelationIR {
1158
1196
  /** FK column: on this table for `one`, on the target table for `many`. */
1159
1197
  field: string;
1160
1198
  kind: "many" | "one";
@@ -1166,7 +1204,23 @@ interface RelationIR {
1166
1204
  references: string;
1167
1205
  /** Target table name. */
1168
1206
  table: string;
1207
+ through?: never;
1208
+ }
1209
+ /** A many-to-many relation: `r.many(target, { through: { table, from, to } })`. */
1210
+ interface ThroughRelationIR {
1211
+ kind: "many";
1212
+ /** Accessor name the relation is loaded under (the `with` key). */
1213
+ name: string;
1214
+ /** Target table name. */
1215
+ table: string;
1216
+ /** The join table and its two keys: `from` points at the declaring table, `to` at `table`. */
1217
+ through: {
1218
+ from: string;
1219
+ table: string;
1220
+ to: string;
1221
+ };
1169
1222
  }
1223
+ type RelationIR = KeyedRelationIR | ThroughRelationIR;
1170
1224
  /**
1171
1225
  * Statically-discovered `.source(...)` config (plan 077). Only the bits the
1172
1226
  * advisor lints + DO wiring need are captured; `map`/`tenantBy` are functions and
@@ -1200,6 +1254,13 @@ interface ExternalSourceIR {
1200
1254
  unanalyzable?: boolean;
1201
1255
  }
1202
1256
  interface TableIR {
1257
+ /**
1258
+ * `true` when the table declares an aggregate index that can answer a `count()`
1259
+ * without a scan: an inline `.aggregateIndex(…)`, a standalone `defineAggregateIndex`
1260
+ * naming it, or every table when the standalone argument cannot be read. Optional:
1261
+ * absent means no such index was found.
1262
+ */
1263
+ aggregateIndexed?: true;
1203
1264
  /**
1204
1265
  * `true` when the table chain carried `.commitOrdered()` — every row carries
1205
1266
  * `_commitSeq`, a per-shard integer allocated once per mutation and strictly
@@ -1873,6 +1934,11 @@ interface ContainerIRBase {
1873
1934
  enableInternet?: boolean;
1874
1935
  /** The `lunora/containers.ts` export name, e.g. `transcoder`. */
1875
1936
  exportName: string;
1937
+ /**
1938
+ * The static `hardTimeout` value, when it was a literal. It caps total lifetime,
1939
+ * so it also bounds how long an idle instance can run. Lifted for the advisor.
1940
+ */
1941
+ hardTimeout?: number | string;
1876
1942
  /** Static `instanceType`, when declared (the default size, under `durable_object`). */
1877
1943
  instanceType?: string | {
1878
1944
  diskMb?: number;
@@ -2570,6 +2636,7 @@ interface LintSchemaOptions {
2570
2636
  containerKeyAccesses?: ReadonlyArray<ContainerKeyAccessIR>;
2571
2637
  containerOverrides?: ReadonlyArray<ContainerOverrideIR>;
2572
2638
  containers?: ReadonlyArray<ContainerIR>;
2639
+ countReads?: ReadonlyArray<CountReadIR>;
2573
2640
  cronTargets?: ReadonlyArray<string>;
2574
2641
  exportSinks?: ReadonlyArray<AdvisorExportSink>;
2575
2642
  failOpenGuards?: ReadonlyArray<FailOpenGuardIR>;
package/dist/index.d.ts CHANGED
@@ -111,12 +111,22 @@ interface IndexSnapshot {
111
111
  fields: ReadonlyArray<string>;
112
112
  unique: boolean;
113
113
  }
114
- /** A single relation's structural shape. */
115
- interface RelationSnapshot {
114
+ /** A single relation's structural shape: a foreign-key relation, or a many-to-many one through a join table. */
115
+ type RelationSnapshot = {
116
116
  field: string;
117
117
  kind: "many" | "one";
118
118
  table: string;
119
- }
119
+ through?: never;
120
+ } | {
121
+ field?: never;
122
+ kind: "many";
123
+ table: string;
124
+ through: {
125
+ from: string;
126
+ table: string;
127
+ to: string;
128
+ };
129
+ };
120
130
  /** A table's declarative `.ttl(field, { after })` auto-expiry policy. */
121
131
  interface TtlSnapshot {
122
132
  /** Millisecond offset added to `field` to derive the expiry; absent ⇒ `field` IS the absolute expiry (an offset of zero). */
@@ -283,7 +293,7 @@ type CallSiteScope = AdvisorCallSiteScope;
283
293
  interface CallEdgeIR {
284
294
  /**
285
295
  * `true` when the hop may not take effect on every pass of its function —
286
- * see `isConditionalSite` in `discover/call-edges.ts` for the rules. Set
296
+ * see `conditionOf` in `discover/call-edges.ts` for the rules. Set
287
297
  * only, never `false`. The `dispatch_cycle` lint's false-positive gate.
288
298
  */
289
299
  conditional?: true;
@@ -292,6 +302,14 @@ interface CallEdgeIR {
292
302
  kind: "call" | "enqueue" | "invoke" | "publish" | "schedule";
293
303
  /** 1-based line of the call. */
294
304
  line: number;
305
+ /**
306
+ * `true` alongside `conditional` when a loop's body or update clause is the
307
+ * ONLY thing that may stop the hop — the loop may run zero times, but a
308
+ * queue consumer's `for (const message of batch.messages)` always has a
309
+ * message. Set only, never `false`. The queue cycle lint reads it; the
310
+ * scheduler lints still treat the hop as conditional.
311
+ */
312
+ loopOnly?: true;
295
313
  reason?: string;
296
314
  /**
297
315
  * The facts of a scheduled dispatch, present on `schedule` edges only. `delayMs`
@@ -345,6 +363,25 @@ interface WorkflowCallIR {
345
363
  /** The referenced workflow export name, or `""` when the argument is not a string literal. */
346
364
  workflow: string;
347
365
  }
366
+ /**
367
+ * A `ctx.db.count("table", …)` or `ctx.db.<table>.count(…)` call discovered in a
368
+ * function body. `count()` is answered from a counter only when the table declares an
369
+ * aggregate index (`TableIR.aggregateIndexed`); otherwise it runs `COUNT(*)` over the
370
+ * table. `indexed` is `false` exactly for that scan, so the `count_without_index` lint
371
+ * reports only those; an unknown table or a dynamic name reads as `indexed: true`.
372
+ */
373
+ interface CountReadIR {
374
+ /** Source file relative to `<projectRoot>/lunora/`, without extension. */
375
+ file: string;
376
+ /** `false` only when the table is known and declares no aggregate index. */
377
+ indexed: boolean;
378
+ /** 1-based line of the `count(...)` call. */
379
+ line: number;
380
+ /** Who the call runs on behalf of. */
381
+ scope: CallSiteScope;
382
+ /** Counted table name, or `""` when the table argument is not a string literal. */
383
+ table: string;
384
+ }
348
385
  /**
349
386
  * A `ctx.db.query("table")…` read discovered in a function body, reduced to what
350
387
  * the query advisor lints need: which table, whether the chain narrows with an
@@ -1154,7 +1191,8 @@ interface RankIndexIR {
1154
1191
  /** Ordered sort keys driving the rank. */
1155
1192
  sortBy: ReadonlyArray<RankSortKeyIR>;
1156
1193
  }
1157
- interface RelationIR {
1194
+ /** A `one` / `many` relation backed by one foreign-key column. */
1195
+ interface KeyedRelationIR {
1158
1196
  /** FK column: on this table for `one`, on the target table for `many`. */
1159
1197
  field: string;
1160
1198
  kind: "many" | "one";
@@ -1166,7 +1204,23 @@ interface RelationIR {
1166
1204
  references: string;
1167
1205
  /** Target table name. */
1168
1206
  table: string;
1207
+ through?: never;
1208
+ }
1209
+ /** A many-to-many relation: `r.many(target, { through: { table, from, to } })`. */
1210
+ interface ThroughRelationIR {
1211
+ kind: "many";
1212
+ /** Accessor name the relation is loaded under (the `with` key). */
1213
+ name: string;
1214
+ /** Target table name. */
1215
+ table: string;
1216
+ /** The join table and its two keys: `from` points at the declaring table, `to` at `table`. */
1217
+ through: {
1218
+ from: string;
1219
+ table: string;
1220
+ to: string;
1221
+ };
1169
1222
  }
1223
+ type RelationIR = KeyedRelationIR | ThroughRelationIR;
1170
1224
  /**
1171
1225
  * Statically-discovered `.source(...)` config (plan 077). Only the bits the
1172
1226
  * advisor lints + DO wiring need are captured; `map`/`tenantBy` are functions and
@@ -1200,6 +1254,13 @@ interface ExternalSourceIR {
1200
1254
  unanalyzable?: boolean;
1201
1255
  }
1202
1256
  interface TableIR {
1257
+ /**
1258
+ * `true` when the table declares an aggregate index that can answer a `count()`
1259
+ * without a scan: an inline `.aggregateIndex(…)`, a standalone `defineAggregateIndex`
1260
+ * naming it, or every table when the standalone argument cannot be read. Optional:
1261
+ * absent means no such index was found.
1262
+ */
1263
+ aggregateIndexed?: true;
1203
1264
  /**
1204
1265
  * `true` when the table chain carried `.commitOrdered()` — every row carries
1205
1266
  * `_commitSeq`, a per-shard integer allocated once per mutation and strictly
@@ -1873,6 +1934,11 @@ interface ContainerIRBase {
1873
1934
  enableInternet?: boolean;
1874
1935
  /** The `lunora/containers.ts` export name, e.g. `transcoder`. */
1875
1936
  exportName: string;
1937
+ /**
1938
+ * The static `hardTimeout` value, when it was a literal. It caps total lifetime,
1939
+ * so it also bounds how long an idle instance can run. Lifted for the advisor.
1940
+ */
1941
+ hardTimeout?: number | string;
1876
1942
  /** Static `instanceType`, when declared (the default size, under `durable_object`). */
1877
1943
  instanceType?: string | {
1878
1944
  diskMb?: number;
@@ -2570,6 +2636,7 @@ interface LintSchemaOptions {
2570
2636
  containerKeyAccesses?: ReadonlyArray<ContainerKeyAccessIR>;
2571
2637
  containerOverrides?: ReadonlyArray<ContainerOverrideIR>;
2572
2638
  containers?: ReadonlyArray<ContainerIR>;
2639
+ countReads?: ReadonlyArray<CountReadIR>;
2573
2640
  cronTargets?: ReadonlyArray<string>;
2574
2641
  exportSinks?: ReadonlyArray<AdvisorExportSink>;
2575
2642
  failOpenGuards?: ReadonlyArray<FailOpenGuardIR>;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as l,errorPlatformDiagnosticNames as c,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-brcmKenl.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as N,discoverAgents as g}from"./packem_shared/AGENTS_FILENAME-B6-kjzM3.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-B81lOULB.mjs";import{default as I}from"./packem_shared/discoverAuthApiCalls-xs0ONfI-.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-Bk0u9QUu.mjs";import{default as P}from"./packem_shared/discoverCrons-DF7dOP9x.mjs";import{capabilitiesUsedBy as b,foldCapabilitySignals as y,mayReadCapabilityContext as U,sourceCapabilitySignals as G}from"./packem_shared/capabilitiesUsedBy-QgSZyE0T.mjs";import{FLAGS_FILENAME as j,discoverFlags as B}from"./packem_shared/FLAGS_FILENAME-Bf0MSlHH.mjs";import{default as W}from"./packem_shared/discoverFunctions-DaEZl3uE.mjs";import{default as V}from"./packem_shared/discoverHttpRoutes-C_u9YiFb.mjs";import{default as Q}from"./packem_shared/discoverHyperdriveCalls-BUrA_96X.mjs";import{default as w}from"./packem_shared/discoverInserts-OT_fiEGq.mjs";import{d as Y}from"./packem_shared/index-DZZpHXMv.mjs";import{default as Z}from"./packem_shared/discoverMigrations-C9mLIhGZ.mjs";import{MUTATORS_FILENAME as ee,discoverMutators as re}from"./packem_shared/MUTATORS_FILENAME-Bw0YtaO8.mjs";import{default as te}from"./packem_shared/discoverNondeterministicCalls-9ZDpRptb.mjs";import{NOTIFY_FILENAME as ae,discoverNotifyCalls as ie,discoverNotifyChannels as me,discoverNotifyConfig as fe}from"./packem_shared/NOTIFY_FILENAME-CPjbiHQl.mjs";import{default as pe}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-C8V4cMIP.mjs";import{QUEUES_FILENAME as xe,discoverQueues as Se}from"./packem_shared/QUEUES_FILENAME-CsRy4VTF.mjs";import{default as ue}from"./packem_shared/discoverR2sqlCalls-COKmDnih.mjs";import{default as ve}from"./packem_shared/discoverRlsProcedures-BlUd32bU.mjs";import{default as Ne}from"./packem_shared/discoverRlsMetadata-Cb8JR1b4.mjs";import{discoverSandboxUsage as Oe}from"./packem_shared/discoverSandboxUsage-w6Q3RvxZ.mjs";import{default as Te}from"./packem_shared/discoverSchema-rxbrQztG.mjs";import{readServiceBindings as Ie,resolveServiceBindings as _e}from"./packem_shared/readServiceBindings-DvqIThzd.mjs";import{SHAPES_FILENAME as Me,discoverShapes as Fe}from"./packem_shared/SHAPES_FILENAME-DkBUN9dK.mjs";import{default as De}from"./packem_shared/discoverStorageRulesMetadata-BPJplDfz.mjs";import{WORKFLOWS_FILENAME as ye,discoverWorkflows as Ue}from"./packem_shared/WORKFLOWS_FILENAME-CQR8fE9B.mjs";import{emitApp as He}from"./packem_shared/emitApp-DAZCUDbr.mjs";import{isD1GlobalTable as Be,isHyperdriveGlobalTable as ke}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ke,emitOpenApi as Ve,emitOpenApiModule as ze}from"./packem_shared/buildOpenApiDocument-DFv-RYZU.mjs";import{OPENRPC_VERSION as qe,buildOpenRpcDocument as we,emitOpenRpc as Je,emitOpenRpcModule as Ye}from"./packem_shared/OPENRPC_VERSION-CCY7xqSL.mjs";import{DEFAULT_TARGET as Ze,platformMatrixIds as $e,readProjectTarget as er,resolveCodegenTarget as rr}from"./packem_shared/DEFAULT_TARGET-BnQiNNKu.mjs";import{l as tr,r as sr}from"./packem_shared/project-config-file-BV7RR-l6.mjs";import{SCHEMA_SNAPSHOT_FILENAME as ir,runCodegen as mr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-D9fd22gh.mjs";import{SchemaSnapshotParseError as dr,buildSchemaSnapshot as pr,evaluateSchemaDrift as nr,parseSchemaSnapshot as lr}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as xr}from"./packem_shared/fingerprintSchemaSources-eVG9aVt0.mjs";import{schemaFromIr as Er}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as Ar,validatorIrToJsonSchema as vr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Nr,SDK_TARGETS as gr,generateSdk as Or}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as Tr,secretKindOf as hr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as _r}from"./packem_shared/emitDrizzleSchema-DitcRZ1a.mjs";import{default as Mr}from"./packem_shared/emitFunctions-BeKgL3dl.mjs";import{e as Pr}from"./packem_shared/server-DAvi_bv_.mjs";import{e as br}from"./packem_shared/shard-BWVyL-4A.mjs";import{G as Ur}from"./packem_shared/shared-DnCokNcE.mjs";import{MESSAGE_SOLUTIONS as Hr,findSolutionByMessage as jr}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as kr,findProjectConfigFile as Wr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{createCodegenProject as Vr,findTsconfig as zr,refreshCodegenProject as Qr}from"./packem_shared/createCodegenProject-V51_yBw3.mjs";import{s as wr,t as Jr,u as Yr}from"./packem_shared/shard-runtime-BX0xmo0P.mjs";import{emitApi as Zr,emitCollections as $r,emitInternalApi as eo}from"./packem_shared/emitApi-Zx6VPN-7.mjs";import{emitCrons as oo,emitScheduler as to,emitVectors as so,emitWranglerCronTriggers as ao}from"./packem_shared/emitCrons-BQW2lviZ.mjs";import{emitDataModel as mo}from"./packem_shared/emitDataModel-BskFt9Wv.mjs";import{isTypedSchema as po}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{N as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,Ze as DEFAULT_TARGET,j as FLAGS_FILENAME,Ur as GENERATED_HEADER,Ar as LUNORA_ERROR_CODES,Hr as LUNORA_SOLUTION_RULES,ee as MUTATORS_FILENAME,ae as NOTIFY_FILENAME,qe as OPENRPC_VERSION,kr as PROJECT_CONFIG_FILENAMES,xe as QUEUES_FILENAME,ir as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Nr as SDK_LANGUAGES,gr as SDK_TARGETS,Me as SHAPES_FILENAME,dr as SchemaSnapshotParseError,e as VERSION,ye as WORKFLOWS_FILENAME,Ke as buildOpenApiDocument,we as buildOpenRpcDocument,pr as buildSchemaSnapshot,b as capabilitiesUsedBy,Vr as createCodegenProject,n as describeErrorLevelFindings,v as diagnosticAt,s as diffSchemaSnapshots,g as discoverAgents,I as discoverAuthApiCalls,M as discoverContainers,P as discoverCrons,B as discoverFlags,W as discoverFunctions,V as discoverHttpRoutes,Q as discoverHyperdriveCalls,w as discoverInserts,Y as discoverMaskProcedures,Z as discoverMigrations,re as discoverMutators,te as discoverNondeterministicCalls,ie as discoverNotifyCalls,me as discoverNotifyChannels,fe as discoverNotifyConfig,le as discoverQueries,Se as discoverQueues,ue as discoverR2sqlCalls,Ne as discoverRlsMetadata,ve as discoverRlsProcedures,Oe as discoverSandboxUsage,Te as discoverSchema,Fe as discoverShapes,De as discoverStorageRulesMetadata,Ue as discoverWorkflows,wr as emitAgents,Zr as emitApi,He as emitApp,$r as emitCollections,Jr as emitContainers,oo as emitCrons,mo as emitDataModel,_r as emitDrizzleSchema,Mr as emitFunctions,eo as emitInternalApi,Ve as emitOpenApi,ze as emitOpenApiModule,Je as emitOpenRpc,Ye as emitOpenRpcModule,to as emitScheduler,Pr as emitServer,br as emitShard,so as emitVectors,Yr as emitWorkflows,ao as emitWranglerCronTriggers,l as errorAdvisoryNames,c as errorPlatformDiagnosticNames,nr as evaluateSchemaDrift,jr as findLunoraSolution,Wr as findProjectConfigFile,zr as findTsconfig,xr as fingerprintSchemaSources,y as foldCapabilitySignals,m as formatAdvisories,Or as generateSdk,Be as isD1GlobalTable,ke as isHyperdriveGlobalTable,R as isTestPath,po as isTypedSchema,f as lintSchema,T as listLunoraSourceFiles,tr as loadProjectConfig,U as mayReadCapabilityContext,lr as parseSchemaSnapshot,$e as platformMatrixIds,pe as readPackageDependencies,sr as readProjectConfigLiterals,er as readProjectTarget,Ie as readServiceBindings,Tr as redact,Qr as refreshCodegenProject,rr as resolveCodegenTarget,_e as resolveServiceBindings,mr as runCodegen,Er as schemaFromIr,hr as secretKindOf,a as serializeSchemaSnapshot,x as sortedUniqueNames,G as sourceCapabilitySignals,d as toAdvisorContext,vr as validatorIrToJsonSchema};
1
+ import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as l,errorPlatformDiagnosticNames as c,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-brcmKenl.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as N,discoverAgents as g}from"./packem_shared/AGENTS_FILENAME-B6-kjzM3.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-B81lOULB.mjs";import{default as I}from"./packem_shared/discoverAuthApiCalls-xs0ONfI-.mjs";import{CONTAINERS_FILENAME as L,discoverContainers as M}from"./packem_shared/CONTAINERS_FILENAME-dFRtAyIe.mjs";import{default as P}from"./packem_shared/discoverCrons-DF7dOP9x.mjs";import{capabilitiesUsedBy as b,foldCapabilitySignals as y,mayReadCapabilityContext as U,sourceCapabilitySignals as G}from"./packem_shared/capabilitiesUsedBy-QgSZyE0T.mjs";import{FLAGS_FILENAME as j,discoverFlags as B}from"./packem_shared/FLAGS_FILENAME-Bf0MSlHH.mjs";import{default as W}from"./packem_shared/discoverFunctions-DaEZl3uE.mjs";import{default as V}from"./packem_shared/discoverHttpRoutes-C_u9YiFb.mjs";import{default as Q}from"./packem_shared/discoverHyperdriveCalls-BUrA_96X.mjs";import{default as w}from"./packem_shared/discoverInserts-OT_fiEGq.mjs";import{d as Y}from"./packem_shared/index-DZZpHXMv.mjs";import{default as Z}from"./packem_shared/discoverMigrations-C9mLIhGZ.mjs";import{MUTATORS_FILENAME as ee,discoverMutators as re}from"./packem_shared/MUTATORS_FILENAME-Bw0YtaO8.mjs";import{default as te}from"./packem_shared/discoverNondeterministicCalls-9ZDpRptb.mjs";import{NOTIFY_FILENAME as ae,discoverNotifyCalls as ie,discoverNotifyChannels as me,discoverNotifyConfig as fe}from"./packem_shared/NOTIFY_FILENAME-CPjbiHQl.mjs";import{default as pe}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-C8V4cMIP.mjs";import{QUEUES_FILENAME as xe,discoverQueues as Se}from"./packem_shared/QUEUES_FILENAME-CsRy4VTF.mjs";import{default as ue}from"./packem_shared/discoverR2sqlCalls-COKmDnih.mjs";import{default as ve}from"./packem_shared/discoverRlsProcedures-BlUd32bU.mjs";import{default as Ne}from"./packem_shared/discoverRlsMetadata-Cb8JR1b4.mjs";import{discoverSandboxUsage as Oe}from"./packem_shared/discoverSandboxUsage-w6Q3RvxZ.mjs";import{default as Te}from"./packem_shared/discoverSchema-CRBUNY3s.mjs";import{readServiceBindings as Ie,resolveServiceBindings as _e}from"./packem_shared/readServiceBindings-DvqIThzd.mjs";import{SHAPES_FILENAME as Me,discoverShapes as Fe}from"./packem_shared/SHAPES_FILENAME-DkBUN9dK.mjs";import{default as De}from"./packem_shared/discoverStorageRulesMetadata-BPJplDfz.mjs";import{WORKFLOWS_FILENAME as ye,discoverWorkflows as Ue}from"./packem_shared/WORKFLOWS_FILENAME-CQR8fE9B.mjs";import{emitApp as He}from"./packem_shared/emitApp-DAZCUDbr.mjs";import{isD1GlobalTable as Be,isHyperdriveGlobalTable as ke}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ke,emitOpenApi as Ve,emitOpenApiModule as ze}from"./packem_shared/buildOpenApiDocument-DFv-RYZU.mjs";import{OPENRPC_VERSION as qe,buildOpenRpcDocument as we,emitOpenRpc as Je,emitOpenRpcModule as Ye}from"./packem_shared/OPENRPC_VERSION-CCY7xqSL.mjs";import{DEFAULT_TARGET as Ze,platformMatrixIds as $e,readProjectTarget as er,resolveCodegenTarget as rr}from"./packem_shared/DEFAULT_TARGET-BnQiNNKu.mjs";import{l as tr,r as sr}from"./packem_shared/project-config-file-BV7RR-l6.mjs";import{SCHEMA_SNAPSHOT_FILENAME as ir,runCodegen as mr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-DOce48yt.mjs";import{SchemaSnapshotParseError as dr,buildSchemaSnapshot as pr,evaluateSchemaDrift as nr,parseSchemaSnapshot as lr}from"./packem_shared/SchemaSnapshotParseError-BRJT7c2k.mjs";import{default as xr}from"./packem_shared/fingerprintSchemaSources-eVG9aVt0.mjs";import{schemaFromIr as Er}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as Ar,validatorIrToJsonSchema as vr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Nr,SDK_TARGETS as gr,generateSdk as Or}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as Tr,secretKindOf as hr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as _r}from"./packem_shared/emitDrizzleSchema-DitcRZ1a.mjs";import{default as Mr}from"./packem_shared/emitFunctions-BeKgL3dl.mjs";import{e as Pr}from"./packem_shared/server-DAvi_bv_.mjs";import{e as br}from"./packem_shared/shard-BTj5Z44S.mjs";import{G as Ur}from"./packem_shared/shared-DnCokNcE.mjs";import{MESSAGE_SOLUTIONS as Hr,findSolutionByMessage as jr}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as kr,findProjectConfigFile as Wr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{createCodegenProject as Vr,findTsconfig as zr,refreshCodegenProject as Qr}from"./packem_shared/createCodegenProject-V51_yBw3.mjs";import{s as wr,t as Jr,u as Yr}from"./packem_shared/shard-runtime-BX0xmo0P.mjs";import{emitApi as Zr,emitCollections as $r,emitInternalApi as eo}from"./packem_shared/emitApi-Zx6VPN-7.mjs";import{emitCrons as oo,emitScheduler as to,emitVectors as so,emitWranglerCronTriggers as ao}from"./packem_shared/emitCrons-BQW2lviZ.mjs";import{emitDataModel as mo}from"./packem_shared/emitDataModel-BskFt9Wv.mjs";import{isTypedSchema as po}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{N as AGENTS_FILENAME,E as CAPABILITY_PROBES,L as CONTAINERS_FILENAME,A as CodegenDiagnosticError,Ze as DEFAULT_TARGET,j as FLAGS_FILENAME,Ur as GENERATED_HEADER,Ar as LUNORA_ERROR_CODES,Hr as LUNORA_SOLUTION_RULES,ee as MUTATORS_FILENAME,ae as NOTIFY_FILENAME,qe as OPENRPC_VERSION,kr as PROJECT_CONFIG_FILENAMES,xe as QUEUES_FILENAME,ir as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Nr as SDK_LANGUAGES,gr as SDK_TARGETS,Me as SHAPES_FILENAME,dr as SchemaSnapshotParseError,e as VERSION,ye as WORKFLOWS_FILENAME,Ke as buildOpenApiDocument,we as buildOpenRpcDocument,pr as buildSchemaSnapshot,b as capabilitiesUsedBy,Vr as createCodegenProject,n as describeErrorLevelFindings,v as diagnosticAt,s as diffSchemaSnapshots,g as discoverAgents,I as discoverAuthApiCalls,M as discoverContainers,P as discoverCrons,B as discoverFlags,W as discoverFunctions,V as discoverHttpRoutes,Q as discoverHyperdriveCalls,w as discoverInserts,Y as discoverMaskProcedures,Z as discoverMigrations,re as discoverMutators,te as discoverNondeterministicCalls,ie as discoverNotifyCalls,me as discoverNotifyChannels,fe as discoverNotifyConfig,le as discoverQueries,Se as discoverQueues,ue as discoverR2sqlCalls,Ne as discoverRlsMetadata,ve as discoverRlsProcedures,Oe as discoverSandboxUsage,Te as discoverSchema,Fe as discoverShapes,De as discoverStorageRulesMetadata,Ue as discoverWorkflows,wr as emitAgents,Zr as emitApi,He as emitApp,$r as emitCollections,Jr as emitContainers,oo as emitCrons,mo as emitDataModel,_r as emitDrizzleSchema,Mr as emitFunctions,eo as emitInternalApi,Ve as emitOpenApi,ze as emitOpenApiModule,Je as emitOpenRpc,Ye as emitOpenRpcModule,to as emitScheduler,Pr as emitServer,br as emitShard,so as emitVectors,Yr as emitWorkflows,ao as emitWranglerCronTriggers,l as errorAdvisoryNames,c as errorPlatformDiagnosticNames,nr as evaluateSchemaDrift,jr as findLunoraSolution,Wr as findProjectConfigFile,zr as findTsconfig,xr as fingerprintSchemaSources,y as foldCapabilitySignals,m as formatAdvisories,Or as generateSdk,Be as isD1GlobalTable,ke as isHyperdriveGlobalTable,R as isTestPath,po as isTypedSchema,f as lintSchema,T as listLunoraSourceFiles,tr as loadProjectConfig,U as mayReadCapabilityContext,lr as parseSchemaSnapshot,$e as platformMatrixIds,pe as readPackageDependencies,sr as readProjectConfigLiterals,er as readProjectTarget,Ie as readServiceBindings,Tr as redact,Qr as refreshCodegenProject,rr as resolveCodegenTarget,_e as resolveServiceBindings,mr as runCodegen,Er as schemaFromIr,hr as secretKindOf,a as serializeSchemaSnapshot,x as sortedUniqueNames,G as sourceCapabilitySignals,d as toAdvisorContext,vr as validatorIrToJsonSchema};
@@ -0,0 +1 @@
1
+ import{existsSync as j}from"node:fs";import{join as I}from"node:path";import{containerClassName as A,containerBindingName as O,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as k,isManagedImage as C,isCloudflareRegistryDigest as _,normalizeContainerImage as f}from"@lunora/container";import{SyntaxKind as $,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{stringPropertyFor as D,findObjectProperty as p,symbolConstInitializer as M,outermostValueWrapper as w,isWriteTarget as F}from"./isTestPath-B81lOULB.mjs";import{a as V}from"./attribution-hVBriwzy.mjs";import{a as b}from"./project-config-file-BV7RR-l6.mjs";const K="containers.ts",B=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const r of e.getDeclarations())if(s.isImportSpecifier(r))return r.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:r.getNameNode().getText()==="defineContainer";return!1},d=D("container"),y=(t,e,r)=>{if(s.isNumericLiteral(t))return t.getLiteralValue();throw a(t,`container "${e}": \`${r}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},E=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return f(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const r=p(t,"registry");if(r&&s.isPropertyAssignment(r)){const i=r.getInitializerOrThrow();return f({registry:d(i,e,"image.registry")})}const n=p(t,"build");if(n&&s.isPropertyAssignment(n)){const i=n.getInitializerOrThrow();return f({build:d(i,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},R=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),U=new Set(["gracePeriodSeconds","stepPercentage"]),L=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},N=(t,e)=>e.getDescendantsOfKind($.Identifier).some(r=>{if(r.getSymbol()!==t)return!1;let n=w(r),i=n.getParent();if(s.isCallExpression(i)&&i.getExpression().getText()==="Object.assign")return i.getArguments()[0]===n;for(;(s.isPropertyAccessExpression(i)||s.isElementAccessExpression(i))&&i.getExpression()===n;){if(F(i))return!0;n=w(i),i=n.getParent()}return!1}),Y=16,T=(t,e,r,n)=>{let i={name:r,symbol:t},o;for(let c=0;c<Y;c+=1){const l=M(i.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=L(l),s.isObjectLiteralExpression(o)&&i.symbol!==void 0&&N(i.symbol,e.getSourceFile()))throw a(e,`${n}: \`${i.name}\` is a const object that is written to elsewhere in this file, so its initializer is not the value the container runs with. Declare the settings where they are final.`);if(!s.isIdentifier(o))return o;i={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const r=L(t);return s.isIdentifier(r)?T(r.getSymbol(),r,r.getText(),e)??r:r},z=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(i=>i.getName()))},W=(t,e,r)=>{const n=t.getExpression().getType(),i=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(z(n))].filter(o=>e.has(o)).map(o=>`\`${o}\``);if(i.length>0)throw a(t,`${r}: this spread can set ${i.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},q=(t,e,r)=>{const n=b(t),i=s.isShorthandPropertyAssignment(t)?T(t.getValueSymbol(),t,n,r):void 0;if(i!==void 0)return[n,i];if(e==="every"||e.has(n))throw a(t,`${r}: \`${n}\` is deploy configuration codegen writes into wrangler.jsonc, so it must be a static literal — inline it, or name a module-scope \`const\` initialized with one.`)},m=(t,e,r,n=new Set)=>{const i=[],o=new Set(n).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))i.push([b(c),P(c.getInitializerOrThrow(),r)]);else if(s.isSpreadAssignment(c))i.push(...x(c,e,r,o));else{const l=q(c,e,r);l!==void 0&&i.push(l)}return i},x=(t,e,r,n)=>{const i=P(t.getExpression(),r);if(!s.isObjectLiteralExpression(i))return W(t,e,r),[];if(n.has(i))throw a(t,`${r}: this spread refers back to an object it is part of, so it has no static value.`);return m(i,e,r,n)},H=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`buildArgs\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const r={};for(const[n,i]of m(t,"every",`container "${e}" buildArgs`))r[n]=d(i,e,`buildArgs.${n}`);return Object.keys(r).length>0?r:void 0},J=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`rollout\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const r={};for(const[n,i]of m(t,U,`container "${e}" rollout`))(n==="gracePeriodSeconds"||n==="stepPercentage")&&(r[n]=y(i,e,`rollout.${n}`));return r.gracePeriodSeconds===void 0&&r.stepPercentage===void 0?void 0:r},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},S=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},X=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const r={};for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))throw a(n,`container "${e}": \`instanceType\` must be an object of static number literals`);const i=b(n);if(i!=="diskMb"&&i!=="memoryMib"&&i!=="vcpu")throw a(n,`container "${e}": unknown \`instanceType\` field "${i}" — expected vcpu, memoryMib, or diskMb`);r[i]=y(n.getInitializerOrThrow(),e,`instanceType.${i}`)}return r}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},G=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`images\` must be a static object literal — codegen writes it into wrangler.jsonc`);const r={};for(const[n,i]of m(t,"every",`container "${e}" images`)){const o=E(i,e);if(o.kind==="build")throw a(i,`container "${e}": \`images["${n}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!_(o.reference))throw a(i,`container "${e}": \`images["${n}"].registry\` must be a digest-pinned (@sha256) reference under registry.cloudflare.com — push other registries' images there first`);r[n]=o}return r},Q=(t,e)=>{const r=t.findLast(([i])=>i==="schedulingPolicy");if(r===void 0)return;const n=d(r[1],e,"schedulingPolicy");if(n!=="default"&&n!=="durable_object")throw a(r[1],`container "${e}": unknown \`schedulingPolicy\` "${n}" — use "default" or "durable_object"`);return n==="durable_object"?n:void 0},Z=(t,e,r,n)=>{if(r!==void 0&&k.includes(t))throw a(e,`container "${n}": \`${t}\` is not supported with schedulingPolicy "durable_object"`);if(r===void 0&&t==="images")throw a(e,`container "${n}": \`images\` needs schedulingPolicy "durable_object"`)},ee=(t,e,r,n)=>{const{base:i,policy:o}=r;switch(t){case"buildArgs":{i.buildArgs=H(e,n);break}case"enableInternet":{i.enableInternet=v(e);break}case"hardTimeout":{i.hardTimeout=S(e);break}case"image":{r.scheduled||(o.image=E(e,n));break}case"images":{o.images=G(e,n);break}case"instanceType":{i.instanceType=X(e,n);break}case"maxInstances":{o.maxInstances=y(e,n,"maxInstances");break}case"name":{i.name=d(e,n,"name");break}case"rollout":{o.rollout=J(e,n);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${n}": \`sandbox\` must be a static true/false literal`);i.sandbox=c;break}case"sleepAfter":{i.sleepAfter=S(e);break}}},te=(t,e,r)=>{const n=t.findLast(([o])=>o==="image")?.[1];if(n===void 0||!(s.isStringLiteral(n)||s.isNoSubstitutionTemplateLiteral(n)))return;const i=n.getLiteralValue();if(!Object.hasOwn(e??{},i)&&!C(i))throw a(n,`container "${r}": \`image\` "${i}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ne=(t,e)=>{const r=t.getArguments()[0];if(!r||!s.isObjectLiteralExpression(r))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const n=m(r,R,`container "${e}"`),i=Q(n,e),o={base:{bindingName:O(e),className:A(e),exportName:e},policy:{},scheduled:i!==void 0};for(const[g,u]of n)Z(g,u,i,e),ee(g,u,o,e);const{base:c,policy:l}=o;if(i==="durable_object")return te(n,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:i};if(l.image===void 0)throw a(r,`container "${e}": defineContainer requires a static \`image\` property`);return{...c,image:l.image,...l.maxInstances===void 0?{}:{maxInstances:l.maxInstances},...l.rollout===void 0?{}:{rollout:l.rollout}}},ie=t=>{const e=[],r=new Map;for(const n of t.getVariableDeclarations()){const i=n.getInitializer();if(i?.getKind()!==$.CallExpression)continue;const o=i,c=o.getExpression();if(!s.isIdentifier(c)||!B(c))continue;const l=n.getNameNode();if(!s.isIdentifier(l)){if(n.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=V(n,"binding");if(g===void 0)continue;const u=ne(o,g),h=r.get(u.bindingName);if(h!==void 0)throw a(l,`containers "${h}" and "${u.exportName}" both map to the binding ${u.bindingName} — rename one so each container gets its own Durable Object binding`);r.set(u.bindingName,u.exportName),e.push(u)}return e},de=(t,e)=>{const r=I(e,K);if(!j(r))return[];const n=t.getSourceFile(r)??t.addSourceFileAtPath(r),i=ie(n);return i.sort((o,c)=>o.exportName.localeCompare(c.exportName)),i};export{K as CONTAINERS_FILENAME,de as discoverContainers};