@lunora/codegen 1.0.0-alpha.382 → 1.0.0-alpha.384
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 +207 -94
- package/dist/index.d.ts +207 -94
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AGENTS_FILENAME-BedyJsOT.mjs → AGENTS_FILENAME-5mDMAMWy.mjs} +1 -1
- package/dist/packem_shared/{CONTAINERS_FILENAME-T1v8pyHN.mjs → CONTAINERS_FILENAME-BJYrxnq2.mjs} +1 -1
- package/dist/packem_shared/{GENERATED_HEADER-DPEvCN8Z.mjs → GENERATED_HEADER-Bzf6ZJ9r.mjs} +1 -1
- package/dist/packem_shared/{MUTATORS_FILENAME-Ipxibja6.mjs → MUTATORS_FILENAME-DlSftsvY.mjs} +1 -1
- package/dist/packem_shared/{NOTIFY_FILENAME-B-t7jQSm.mjs → NOTIFY_FILENAME-SKk8x0VM.mjs} +1 -1
- package/dist/packem_shared/{OPENRPC_VERSION-DA0ZNkhl.mjs → OPENRPC_VERSION-CSjT8wJW.mjs} +1 -1
- package/dist/packem_shared/{QUEUES_FILENAME-Dt5RG_P0.mjs → QUEUES_FILENAME-BeGwgqcw.mjs} +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-Dle_pfr9.mjs +31 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-BdxZuSxk.mjs +2 -0
- package/dist/packem_shared/SHAPES_FILENAME-rSSihffV.mjs +1 -0
- package/dist/packem_shared/SchemaSnapshotParseError-ycDz8gOB.mjs +17 -0
- package/dist/packem_shared/{WORKFLOWS_FILENAME-VAXgqqP-.mjs → WORKFLOWS_FILENAME--RWiu_Vy.mjs} +1 -1
- package/dist/packem_shared/{attribution-DUbGYT4N.mjs → attribution-CTMkuBkn.mjs} +1 -1
- package/dist/packem_shared/{buildOpenApiDocument-Ct2wK_Tj.mjs → buildOpenApiDocument-afHH7rN5.mjs} +1 -1
- package/dist/packem_shared/{context-property-calls-DKMO9ShK.mjs → context-property-calls-CYaejv5r.mjs} +1 -1
- package/dist/packem_shared/{context-root-BPfMNAJM.mjs → context-root-TiLodrRO.mjs} +1 -1
- package/dist/packem_shared/{database-calls-hLzaOquW.mjs → database-calls-QqsrkDMs.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-Ce3BdKQr.mjs → discoverAuthApiCalls-DZMYREsq.mjs} +1 -1
- package/dist/packem_shared/discoverFunctions-DdHysjy1.mjs +1 -0
- package/dist/packem_shared/{discoverHttpRoutes-DHDfKLoa.mjs → discoverHttpRoutes-5iA7gI_Q.mjs} +1 -1
- package/dist/packem_shared/discoverHyperdriveCalls-BJRaIvLx.mjs +1 -0
- package/dist/packem_shared/{discoverInserts-IAa3lRR4.mjs → discoverInserts-Dw7fvL7s.mjs} +1 -1
- package/dist/packem_shared/discoverMaskProcedures-BLKjuD-A.mjs +1 -0
- package/dist/packem_shared/discoverMigrations-C649uAWL.mjs +1 -0
- package/dist/packem_shared/{discoverNondeterministicCalls-DZ_kIie5.mjs → discoverNondeterministicCalls-DQgVTcLv.mjs} +1 -1
- package/dist/packem_shared/{discoverQueries-DZOGiEPs.mjs → discoverQueries-DVFZJER7.mjs} +1 -1
- package/dist/packem_shared/discoverR2sqlCalls-BEBdqXi_.mjs +1 -0
- package/dist/packem_shared/{discoverRlsMetadata-Dq6iSXnC.mjs → discoverRlsMetadata-DqZpiGts.mjs} +1 -1
- package/dist/packem_shared/discoverRlsProcedures-C2lkSLPn.mjs +1 -0
- package/dist/packem_shared/{discoverSchema-DmkjooXZ.mjs → discoverSchema-Cycd1-H0.mjs} +1 -1
- package/dist/packem_shared/{discoverStorageRulesMetadata-CJ7h6SPK.mjs → discoverStorageRulesMetadata-H3RJzkH_.mjs} +1 -1
- package/dist/packem_shared/{emitAgents-D8TkTpNh.mjs → emitAgents-BeM6PZv4.mjs} +1 -1
- package/dist/packem_shared/{emitApi-D6uqyYd_.mjs → emitApi-GFmStqmq.mjs} +1 -1
- package/dist/packem_shared/{emitApp-D9kGG9Mu.mjs → emitApp-D-6FIpYb.mjs} +10 -6
- package/dist/packem_shared/{emitCrons-C3RiGYk7.mjs → emitCrons-Drdn8Mjn.mjs} +1 -1
- package/dist/packem_shared/{emitDataModel-BMMht_iZ.mjs → emitDataModel-LTnwnhV6.mjs} +1 -1
- package/dist/packem_shared/{emitDrizzleSchema-BmCxM6tO.mjs → emitDrizzleSchema-CM9jh_F0.mjs} +1 -1
- package/dist/packem_shared/{emitFunctions-NGByI1FZ.mjs → emitFunctions-DRAuiKPv.mjs} +90 -83
- package/dist/packem_shared/{emitServer-4NV3vaOg.mjs → emitServer-4l7MPmK0.mjs} +1 -1
- package/dist/packem_shared/emitShard-DqEvyZPZ.mjs +1 -0
- package/dist/packem_shared/{exported-procedure-chains-BaCIhnJ7.mjs → exported-procedure-chains-CRM-MVfP.mjs} +1 -1
- package/dist/packem_shared/handler-reference-90LXJART.mjs +1 -0
- package/dist/packem_shared/index-BhsJzv9r.mjs +1 -0
- package/dist/packem_shared/{index-BjDVAPNW.mjs → index-iw3axJ5Y.mjs} +1 -1
- package/dist/packem_shared/ip-reads-BVXbFgzV.mjs +1 -0
- package/dist/packem_shared/parse-validator-BisfC8bR.mjs +1 -0
- package/dist/packem_shared/{qualifiers-CPQCkXC4.mjs → qualifiers-D1Q_3wo2.mjs} +1 -1
- package/dist/packem_shared/{server-BY1v1bTx.mjs → server-D69SOfX8.mjs} +1 -1
- package/dist/packem_shared/{shard-DNXF9VZ5.mjs → shard-L3gYZnC9.mjs} +94 -91
- package/dist/packem_shared/{shard-runtime-Bg8MOBzw.mjs → shard-runtime-lkQU8trx.mjs} +1 -1
- package/dist/packem_shared/{shared-BErjtci3.mjs → shared-A1XHcT4t.mjs} +1 -1
- package/package.json +8 -8
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-CQyAtphV.mjs +0 -31
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs +0 -2
- package/dist/packem_shared/SHAPES_FILENAME-mgEi072Z.mjs +0 -1
- package/dist/packem_shared/SchemaSnapshotParseError-CjKSMuex.mjs +0 -18
- package/dist/packem_shared/discoverFunctions-a0IT8OSb.mjs +0 -1
- package/dist/packem_shared/discoverHyperdriveCalls-i8Zcf64H.mjs +0 -1
- package/dist/packem_shared/discoverMaskProcedures-Bj6fPF4u.mjs +0 -1
- package/dist/packem_shared/discoverMigrations-Bv8kNIgy.mjs +0 -1
- package/dist/packem_shared/discoverR2sqlCalls-Lq6G--TZ.mjs +0 -1
- package/dist/packem_shared/discoverRlsProcedures-B0DYk-gW.mjs +0 -1
- package/dist/packem_shared/emitShard-9NVueN79.mjs +0 -1
- package/dist/packem_shared/handler-reference-D1wpw_qR.mjs +0 -1
- package/dist/packem_shared/parse-validator-CP5CL6Q7.mjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -219,11 +219,12 @@ type DriftScope = "schema" | "table";
|
|
|
219
219
|
* - `"backfill"` — a `defineMigration` transform rewrites the affected rows.
|
|
220
220
|
* The ONLY value for which a data migration is the answer.
|
|
221
221
|
* - `"rehome"` — the rows' physical storage moves (a different Durable Object,
|
|
222
|
-
* or a different region)
|
|
223
|
-
* the shard it was handed, so
|
|
224
|
-
* export/import round trip
|
|
222
|
+
* or a different region), or a table is emptied on cold start. The per-shard
|
|
223
|
+
* runner only ever replaces a row inside the shard it was handed, so the move
|
|
224
|
+
* itself is an export/import round trip; the change clears once a new migration
|
|
225
|
+
* on the table accompanies it (to give each row what its new home needs).
|
|
225
226
|
* - `"code"` — nothing happens to stored data; a query or a call site has to
|
|
226
|
-
* change (a dropped index
|
|
227
|
+
* change (a dropped index a query still names).
|
|
227
228
|
* - `"none"` — additive, nothing to do.
|
|
228
229
|
*
|
|
229
230
|
* This lives HERE, next to the change union, for the same reason {@link DriftScope}
|
|
@@ -234,6 +235,22 @@ type DriftScope = "schema" | "table";
|
|
|
234
235
|
* sends the operator to a tool that cannot work.
|
|
235
236
|
*/
|
|
236
237
|
type DriftRemediation = "backfill" | "code" | "none" | "rehome";
|
|
238
|
+
/**
|
|
239
|
+
* What a migration's `covers` must say for it to clear a change that moves or empties data: the table (when one is involved) and the
|
|
240
|
+
* target of the change. A `shardMode` is the snapshot's spelling (`root`, `global:d1`, `global:hyperdrive`, `shardBy:<field>`) and
|
|
241
|
+
* `global` stands for any global backend; a `jurisdiction` is the one the schema moves to, `none` when it is removed.
|
|
242
|
+
*/
|
|
243
|
+
interface DriftCoverage {
|
|
244
|
+
jurisdiction?: string;
|
|
245
|
+
memory?: true;
|
|
246
|
+
shardMode?: string;
|
|
247
|
+
table?: string;
|
|
248
|
+
/** The TTL policy a table moves to: the column and the offset (`after`, milliseconds; absent is 0). */
|
|
249
|
+
ttl?: {
|
|
250
|
+
after?: number;
|
|
251
|
+
field: string;
|
|
252
|
+
};
|
|
253
|
+
}
|
|
237
254
|
/** One classified structural change between two snapshots. */
|
|
238
255
|
interface DriftChange {
|
|
239
256
|
/** What fixes this change — see {@link DriftRemediation}. `"none"` for every `safe` change. */
|
|
@@ -248,8 +265,41 @@ interface DriftChange {
|
|
|
248
265
|
severity: "breaking" | "safe";
|
|
249
266
|
/** Human-readable, actionable description (used in the gate message). */
|
|
250
267
|
summary: string;
|
|
268
|
+
/**
|
|
269
|
+
* The field this change belongs to, for a change to one field (its kind, shape,
|
|
270
|
+
* optionality, a constraint, or the field being added or removed).
|
|
271
|
+
*/
|
|
272
|
+
field?: string;
|
|
251
273
|
/** The table this change belongs to. Always set when `scope` is `"table"`. */
|
|
252
274
|
table?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Set on a change that is safe for the stored data but that the operator must hear about: what happens to data the schema
|
|
277
|
+
* no longer describes, or which rows a new TTL will sweep. The gate logs it as a warning when the run proceeds.
|
|
278
|
+
*/
|
|
279
|
+
warning?: true;
|
|
280
|
+
/** Set on a change whose backfill a migration returning each row unchanged performs, because rewriting the row is what does it. */
|
|
281
|
+
identityRewrites?: true;
|
|
282
|
+
/** The TTL a change installs, and the one it replaces, so a caller that can read rows can count what the next sweep deletes. */
|
|
283
|
+
expiry?: {
|
|
284
|
+
after?: number;
|
|
285
|
+
field: string;
|
|
286
|
+
previous?: {
|
|
287
|
+
after?: number;
|
|
288
|
+
field: string;
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Set on a change that moves or empties data (a shard-mode flip, a table turned `.memory()`, a jurisdiction change): the `covers`
|
|
293
|
+
* a new migration must declare to clear it. Absent when no migration can name the change.
|
|
294
|
+
*/
|
|
295
|
+
coverage?: DriftCoverage;
|
|
296
|
+
/** The index a change is about, set on a removed index so a caller can check whether a query still names it. */
|
|
297
|
+
index?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Set when the change adds a uniqueness constraint: the fields whose combined value must not repeat among a table's stored rows.
|
|
300
|
+
* Rows can settle it, so a caller that can read them checks for duplicates instead of asking for a migration.
|
|
301
|
+
*/
|
|
302
|
+
uniqueOn?: ReadonlyArray<string>;
|
|
253
303
|
/** A machine-readable change discriminator. */
|
|
254
304
|
type: "addedFieldConstraint" | "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedCommitOrdering" | "changedFieldKind" | "changedFieldShape" | "changedIndex" | "changedJurisdiction" | "changedMemoryMode" | "changedShardMode" | "changedTtlPolicy" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "relaxedFieldConstraint" | "removedField" | "removedIndex" | "removedRelation" | "removedTable" | "widenedFieldShape";
|
|
255
305
|
}
|
|
@@ -1144,6 +1194,12 @@ interface ValidatorIR {
|
|
|
1144
1194
|
* flag, because compiling it would silently skip the predicate.
|
|
1145
1195
|
*/
|
|
1146
1196
|
unmodelledRefinement?: boolean;
|
|
1197
|
+
/**
|
|
1198
|
+
* `true` on a `v.object(...)` whose `shape` is not the whole validator: the
|
|
1199
|
+
* argument is built at runtime, spreads something unreadable, or is absent. An
|
|
1200
|
+
* empty `shape` then stands for "unknown", not "no properties".
|
|
1201
|
+
*/
|
|
1202
|
+
unresolvedShape?: boolean;
|
|
1147
1203
|
valueType?: ValidatorIR;
|
|
1148
1204
|
}
|
|
1149
1205
|
interface IndexIR {
|
|
@@ -1415,12 +1471,32 @@ interface ExposeCacheIR {
|
|
|
1415
1471
|
* tables with breaking drift, so a migration left at `""` covers nothing.
|
|
1416
1472
|
*/
|
|
1417
1473
|
interface MigrationIR {
|
|
1474
|
+
/**
|
|
1475
|
+
* The change this migration declares it accounts for, read from `covers: { … }` when every value is a literal. The drift gate
|
|
1476
|
+
* clears a shard-mode flip, a table turned `.memory()` or a jurisdiction change only for a migration naming exactly that change.
|
|
1477
|
+
*/
|
|
1478
|
+
covers?: {
|
|
1479
|
+
jurisdiction?: string;
|
|
1480
|
+
memory?: true;
|
|
1481
|
+
shardMode?: string;
|
|
1482
|
+
table?: string;
|
|
1483
|
+
ttl?: {
|
|
1484
|
+
after?: number;
|
|
1485
|
+
field: string;
|
|
1486
|
+
};
|
|
1487
|
+
};
|
|
1418
1488
|
/** Export binding name, used to reference the module member in generated imports. */
|
|
1419
1489
|
exportName: string;
|
|
1420
1490
|
/** Path relative to `<projectRoot>/lunora/` without extension, e.g. "migrations". */
|
|
1421
1491
|
filePath: string;
|
|
1422
1492
|
/** Stable migration id — the registry key and per-shard run-state key. */
|
|
1423
1493
|
id: string;
|
|
1494
|
+
/**
|
|
1495
|
+
* `true` when `up` returns its document unchanged (`(document) => document`, the
|
|
1496
|
+
* shape `lunora migrate create` scaffolds). Such a migration rewrites no row, so it
|
|
1497
|
+
* cannot by itself account for a schema change on its table.
|
|
1498
|
+
*/
|
|
1499
|
+
identity?: true;
|
|
1424
1500
|
/** Table the migration iterates; `""` when not a static string literal. */
|
|
1425
1501
|
table: string;
|
|
1426
1502
|
}
|
|
@@ -1552,6 +1628,11 @@ interface FunctionIR {
|
|
|
1552
1628
|
* ts-morph cannot resolve the type (typically because the consuming
|
|
1553
1629
|
* project lacks a tsconfig that can reach `@lunora/server`).
|
|
1554
1630
|
*/
|
|
1631
|
+
/**
|
|
1632
|
+
* Set on a query that may read `ctx.ip`, decided statically and failing closed: the shard never resumes it
|
|
1633
|
+
* warm, whatever fingerprint a client presents, because its rows can depend on the address the cursor was read at.
|
|
1634
|
+
*/
|
|
1635
|
+
readsIp?: true;
|
|
1555
1636
|
returnType: string;
|
|
1556
1637
|
/**
|
|
1557
1638
|
* A `defineWebSocket` route: the literal URL `path` it serves and whether it requires a session (`auth`). Read at
|
|
@@ -1597,6 +1678,11 @@ interface ShapeIR {
|
|
|
1597
1678
|
exportName: string;
|
|
1598
1679
|
/** Path relative to `<projectRoot>/lunora/` without extension — always `"shapes"`. */
|
|
1599
1680
|
filePath: string;
|
|
1681
|
+
/**
|
|
1682
|
+
* The shape's `where` may read `ctx.ip`, decided statically and failing closed (same rule as {@link FunctionIR.readsIp}),
|
|
1683
|
+
* so the shard never resumes it warm.
|
|
1684
|
+
*/
|
|
1685
|
+
readsIp?: true;
|
|
1600
1686
|
/**
|
|
1601
1687
|
* The `table` string literal from the `defineShape({ table })` call, lifted
|
|
1602
1688
|
* only for static advisor lints (the runtime object stays authoritative).
|
|
@@ -3286,6 +3372,108 @@ interface PlatformDiagnostic {
|
|
|
3286
3372
|
/** The requested deploy target. */
|
|
3287
3373
|
target: string;
|
|
3288
3374
|
}
|
|
3375
|
+
/**
|
|
3376
|
+
* Build a {@link SchemaSnapshot} from a parsed {@link SchemaIR} and the set of
|
|
3377
|
+
* declared migration ids. Tables and migration ids are sorted so the emitted
|
|
3378
|
+
* JSON is byte-stable across runs AND across machines (no spurious diffs /
|
|
3379
|
+
* churn) — see `sortKeys` in `shared/schema-snapshot.ts` for why that ordering
|
|
3380
|
+
* must not be locale-aware.
|
|
3381
|
+
*
|
|
3382
|
+
* Field / index / relation keys are sorted the same way, by `tableSnapshotOf` —
|
|
3383
|
+
* see there for why declaration order was the wrong default for a hashed file.
|
|
3384
|
+
*/
|
|
3385
|
+
declare const buildSchemaSnapshot: (schema: SchemaIR, migrationIds: ReadonlyArray<string>) => SchemaSnapshot;
|
|
3386
|
+
/**
|
|
3387
|
+
* Thrown by {@link parseSchemaSnapshot} when the baseline file exists but is
|
|
3388
|
+
* malformed (bad JSON / wrong version / invalid table shape). Lets the CLI gate
|
|
3389
|
+
* treat a corrupt baseline as a hard error rather than silently degrading to a
|
|
3390
|
+
* "first capture" that would mask drift and then overwrite the bad file.
|
|
3391
|
+
*/
|
|
3392
|
+
declare class SchemaSnapshotParseError extends LunoraError {
|
|
3393
|
+
constructor(message: string);
|
|
3394
|
+
}
|
|
3395
|
+
/**
|
|
3396
|
+
* Parse a committed snapshot file. Returns `undefined` ONLY when the content is
|
|
3397
|
+
* absent/empty; throws {@link SchemaSnapshotParseError} when content is present
|
|
3398
|
+
* but malformed (bad JSON, wrong version, or structurally-invalid tables) so the
|
|
3399
|
+
* caller can distinguish "no baseline yet" (a legitimate first capture) from "a
|
|
3400
|
+
* corrupt baseline" (which must not be silently treated as a first capture).
|
|
3401
|
+
*
|
|
3402
|
+
* The parsing itself lives in `shared/schema-snapshot.ts` (the Studio reads the
|
|
3403
|
+
* same JSON out of the DO ledger); this wrapper only applies the CLI's policy of
|
|
3404
|
+
* treating a malformed baseline as fatal.
|
|
3405
|
+
*/
|
|
3406
|
+
declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
|
|
3407
|
+
/**
|
|
3408
|
+
* A `.withIndex(name)` the application's own functions make: the table read, the index named (`undefined` when the name is not a
|
|
3409
|
+
* string literal, so any index of the table may be the one), and where. The drift gate refuses to drop an index one of these names.
|
|
3410
|
+
*/
|
|
3411
|
+
interface IndexReference {
|
|
3412
|
+
file: string;
|
|
3413
|
+
/** The exported function (or helper, or `<module>`) containing the read. */
|
|
3414
|
+
function: string;
|
|
3415
|
+
index: string | undefined;
|
|
3416
|
+
line: number;
|
|
3417
|
+
/** `""` when the table is not a string literal, so any table may be the one. */
|
|
3418
|
+
table: string;
|
|
3419
|
+
}
|
|
3420
|
+
/** The `.withIndex` reads among a run's discovered queries, reduced to what the index check needs. */
|
|
3421
|
+
declare const indexReferencesOf: (queries: ReadonlyArray<QueryReadIR>) => IndexReference[];
|
|
3422
|
+
/** The decision the pre-deploy gate returns. */
|
|
3423
|
+
interface SchemaDriftDecision {
|
|
3424
|
+
/** True when the deploy must be blocked (breaking drift no new migration covers, and no override). */
|
|
3425
|
+
blocked: boolean;
|
|
3426
|
+
/** Every classified change (both severities), for reporting. */
|
|
3427
|
+
changes: ReadonlyArray<DriftChange>;
|
|
3428
|
+
/**
|
|
3429
|
+
* Migration ids declared now but absent from the baseline. Reported for
|
|
3430
|
+
* context; the gate acts on which of them cover an affected TABLE, not on how
|
|
3431
|
+
* many there are.
|
|
3432
|
+
*/
|
|
3433
|
+
newMigrationIds: ReadonlyArray<string>;
|
|
3434
|
+
/**
|
|
3435
|
+
* A multi-line, actionable explanation. Always present; empty string when
|
|
3436
|
+
* there is no drift at all. Mirrors the D1-placeholder guard's message style.
|
|
3437
|
+
*/
|
|
3438
|
+
reason: string;
|
|
3439
|
+
/**
|
|
3440
|
+
* The breaking changes no new migration accounts for. Non-empty exactly when
|
|
3441
|
+
* the run blocks or an override waved it through; a caller that can read the
|
|
3442
|
+
* stored rows checks these.
|
|
3443
|
+
*/
|
|
3444
|
+
uncovered: ReadonlyArray<DriftChange>;
|
|
3445
|
+
}
|
|
3446
|
+
/**
|
|
3447
|
+
* Decide whether breaking schema drift should block a deploy.
|
|
3448
|
+
*
|
|
3449
|
+
* Blocks only when the baseline exists (a first-ever capture is never blocking),
|
|
3450
|
+
* there is at least one `breaking` change, no new migration COVERS it, and the
|
|
3451
|
+
* `allowDrift` override is not set. Safe-only drift passes.
|
|
3452
|
+
*
|
|
3453
|
+
* "Covers" is per-table, not per-run: a new migration excuses breaking drift on
|
|
3454
|
+
* the table it iterates, and nothing else. Counting new ids alone let a backfill
|
|
3455
|
+
* on `messages` unblock a required field added to `users` — the gate reported
|
|
3456
|
+
* "accompanied by a migration" for a change that migration would never visit.
|
|
3457
|
+
* The shard-mode diff cites this block to justify the studio not shipping a
|
|
3458
|
+
* stranded-rows detector (see `shared/schema-snapshot.ts`), and that claim only
|
|
3459
|
+
* holds if an unrelated migration cannot wave it through.
|
|
3460
|
+
*
|
|
3461
|
+
* Only a `"backfill"` or `"rehome"` change is coverable. A `"code"` change breaks
|
|
3462
|
+
* a call site (a dropped index a query still names); rewriting rows fixes neither,
|
|
3463
|
+
* so a migration must not excuse it however well its table matches. It is cleared
|
|
3464
|
+
* by fixing the code (`--allow-schema-drift` skips it for one run).
|
|
3465
|
+
*/
|
|
3466
|
+
declare const evaluateSchemaDrift: (options: {
|
|
3467
|
+
allowDrift?: boolean;
|
|
3468
|
+
baseline: SchemaSnapshot | undefined;
|
|
3469
|
+
/** The command printing the remediation, so it names only flags that command accepts. */
|
|
3470
|
+
command?: string;
|
|
3471
|
+
current: SchemaSnapshot;
|
|
3472
|
+
/** The `.withIndex` reads the application makes, so a dropped index a query still names is refused. */
|
|
3473
|
+
indexReferences?: ReadonlyArray<IndexReference>;
|
|
3474
|
+
/** This run's declared migrations, so a new one is matched to the table it iterates. */
|
|
3475
|
+
migrations: ReadonlyArray<Pick<MigrationIR, "covers" | "id" | "identity" | "table">>;
|
|
3476
|
+
}) => SchemaDriftDecision;
|
|
3289
3477
|
interface CodegenOptions {
|
|
3290
3478
|
/**
|
|
3291
3479
|
* Which machine-readable API spec(s) to emit into `_generated/`.
|
|
@@ -3342,14 +3530,6 @@ interface CodegenOptions {
|
|
|
3342
3530
|
* `platform_unknown_target` diagnostic.
|
|
3343
3531
|
*/
|
|
3344
3532
|
target?: string;
|
|
3345
|
-
/**
|
|
3346
|
-
* Re-bless the committed schema-drift baseline (`lunora/.lunora-schema.json`)
|
|
3347
|
-
* with the current structural snapshot. The baseline is ALWAYS written on
|
|
3348
|
-
* first capture (when the file is absent); set this to overwrite an existing
|
|
3349
|
-
* one — e.g. after the developer has added the data migration that justifies
|
|
3350
|
-
* a breaking change. Ignored when `dryRun` is true.
|
|
3351
|
-
*/
|
|
3352
|
-
updateSchemaBaseline?: boolean;
|
|
3353
3533
|
/**
|
|
3354
3534
|
* Every `queues.producers[]` entry of `wrangler.jsonc`, top level and each
|
|
3355
3535
|
* `env.<name>` block. A producer naming a push queue's binding with another
|
|
@@ -3466,6 +3646,11 @@ interface CodegenResult {
|
|
|
3466
3646
|
/** WorkflowEntrypoint classes (`_generated/workflows.ts`); `""` (and not written) when no workflows are declared. */
|
|
3467
3647
|
workflows: string;
|
|
3468
3648
|
};
|
|
3649
|
+
/**
|
|
3650
|
+
* Every `.withIndex(name)` the application's functions make, so the drift gate can refuse to drop an index a
|
|
3651
|
+
* query still names. Computed on every run, lint or not: the gate must not depend on an advisory opt-out.
|
|
3652
|
+
*/
|
|
3653
|
+
indexReferences: ReadonlyArray<IndexReference>;
|
|
3469
3654
|
/**
|
|
3470
3655
|
* Data migrations discovered from `defineMigration` exports under `lunora/`,
|
|
3471
3656
|
* each with the table it iterates. The drift gate matches a NEW id against
|
|
@@ -3499,6 +3684,12 @@ interface CodegenResult {
|
|
|
3499
3684
|
schemaSnapshot: SchemaSnapshot;
|
|
3500
3685
|
/** Absolute path of the committed baseline file (`lunora/.lunora-schema.json`). */
|
|
3501
3686
|
schemaSnapshotPath: string;
|
|
3687
|
+
/**
|
|
3688
|
+
* The parsed tables this run's snapshot was built from. The snapshot keeps a
|
|
3689
|
+
* field's kind but not whether its validator was resolvable, so a caller that
|
|
3690
|
+
* checks stored rows against the schema reads the validators here.
|
|
3691
|
+
*/
|
|
3692
|
+
schemaTables: ReadonlyArray<TableIR>;
|
|
3502
3693
|
/**
|
|
3503
3694
|
* Workflows discovered from `defineWorkflow` exports in
|
|
3504
3695
|
* `lunora/workflows.ts` — the list the config layer reconciles into
|
|
@@ -4135,6 +4326,8 @@ interface EmitShardOptions {
|
|
|
4135
4326
|
}>;
|
|
4136
4327
|
/** The project declares `lunora/flags.ts` — wires `ctx.flags` (OpenFeature) onto every ctx. */
|
|
4137
4328
|
hasFlags?: boolean;
|
|
4329
|
+
/** Whether some query may read `ctx.ip` (see `LUNORA_IP_READER_PATHS`), so the shard seeds its address-keyed set from it. */
|
|
4330
|
+
hasIpReaders?: boolean;
|
|
4138
4331
|
/** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
|
|
4139
4332
|
hasNotify?: boolean;
|
|
4140
4333
|
/** The project declares at least one `defineRoom` — wires the `LUNORA_ROOMS` topic→path resolution in the `roomHandlerPath` override. */
|
|
@@ -4200,7 +4393,7 @@ interface EmitShardOptions {
|
|
|
4200
4393
|
workflowEvents?: ReadonlyArray<WorkflowEventIR>;
|
|
4201
4394
|
workflows?: ReadonlyArray<WorkflowIR>;
|
|
4202
4395
|
}
|
|
4203
|
-
declare const emitShard: ({ advisories, advisorProcedures, agents, capabilities, containers, env, flagKeys, hasFlags, hasNotify, hasRooms, hasSecretValues, hasSensitiveArgs, hasSockets, lazyFunctions, hasVectors, liveStreamDeclarations, liveStreams, maskMetadata, mutators, queues, rlsMetadata, schema, schemaSnapshot, shapes, storageRules, studioFeatures, services, topics, useUmbrella, workflowEvents, workflows }: EmitShardOptions) => string;
|
|
4396
|
+
declare const emitShard: ({ advisories, advisorProcedures, agents, capabilities, containers, env, flagKeys, hasFlags, hasNotify, hasRooms, hasSecretValues, hasSensitiveArgs, hasSockets, lazyFunctions, hasVectors, liveStreamDeclarations, liveStreams, maskMetadata, mutators, queues, rlsMetadata, schema, schemaSnapshot, shapes, storageRules, studioFeatures, hasIpReaders, services, topics, useUmbrella, workflowEvents, workflows }: EmitShardOptions) => string;
|
|
4204
4397
|
/**
|
|
4205
4398
|
* Emit `_generated/containers.ts` — one container-enabled Durable Object class
|
|
4206
4399
|
* per `defineContainer` export, each a thin subclass of `LunoraContainer`
|
|
@@ -4664,86 +4857,6 @@ declare const loadProjectConfig: (projectRoot: string) => Promise<LoadedProjectC
|
|
|
4664
4857
|
* module header for what this can and cannot see, and why.
|
|
4665
4858
|
*/
|
|
4666
4859
|
declare const readProjectConfigLiterals: (projectRoot: string) => ProjectConfigLiterals;
|
|
4667
|
-
/**
|
|
4668
|
-
* Build a {@link SchemaSnapshot} from a parsed {@link SchemaIR} and the set of
|
|
4669
|
-
* declared migration ids. Tables and migration ids are sorted so the emitted
|
|
4670
|
-
* JSON is byte-stable across runs AND across machines (no spurious diffs /
|
|
4671
|
-
* churn) — see `sortKeys` in `shared/schema-snapshot.ts` for why that ordering
|
|
4672
|
-
* must not be locale-aware.
|
|
4673
|
-
*
|
|
4674
|
-
* Field / index / relation keys are sorted the same way, by `tableSnapshotOf` —
|
|
4675
|
-
* see there for why declaration order was the wrong default for a hashed file.
|
|
4676
|
-
*/
|
|
4677
|
-
declare const buildSchemaSnapshot: (schema: SchemaIR, migrationIds: ReadonlyArray<string>) => SchemaSnapshot;
|
|
4678
|
-
/**
|
|
4679
|
-
* Thrown by {@link parseSchemaSnapshot} when the baseline file exists but is
|
|
4680
|
-
* malformed (bad JSON / wrong version / invalid table shape). Lets the CLI gate
|
|
4681
|
-
* treat a corrupt baseline as a hard error rather than silently degrading to a
|
|
4682
|
-
* "first capture" that would mask drift and then overwrite the bad file.
|
|
4683
|
-
*/
|
|
4684
|
-
declare class SchemaSnapshotParseError extends LunoraError {
|
|
4685
|
-
constructor(message: string);
|
|
4686
|
-
}
|
|
4687
|
-
/**
|
|
4688
|
-
* Parse a committed snapshot file. Returns `undefined` ONLY when the content is
|
|
4689
|
-
* absent/empty; throws {@link SchemaSnapshotParseError} when content is present
|
|
4690
|
-
* but malformed (bad JSON, wrong version, or structurally-invalid tables) so the
|
|
4691
|
-
* caller can distinguish "no baseline yet" (a legitimate first capture) from "a
|
|
4692
|
-
* corrupt baseline" (which must not be silently treated as a first capture).
|
|
4693
|
-
*
|
|
4694
|
-
* The parsing itself lives in `shared/schema-snapshot.ts` (the Studio reads the
|
|
4695
|
-
* same JSON out of the DO ledger); this wrapper only applies the CLI's policy of
|
|
4696
|
-
* treating a malformed baseline as fatal.
|
|
4697
|
-
*/
|
|
4698
|
-
declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
|
|
4699
|
-
/** The decision the pre-deploy gate returns. */
|
|
4700
|
-
interface SchemaDriftDecision {
|
|
4701
|
-
/** True when the deploy must be blocked (breaking drift no new migration covers, and no override). */
|
|
4702
|
-
blocked: boolean;
|
|
4703
|
-
/** Every classified change (both severities), for reporting. */
|
|
4704
|
-
changes: ReadonlyArray<DriftChange>;
|
|
4705
|
-
/**
|
|
4706
|
-
* Migration ids declared now but absent from the baseline. Reported for
|
|
4707
|
-
* context; the gate acts on which of them cover an affected TABLE, not on how
|
|
4708
|
-
* many there are.
|
|
4709
|
-
*/
|
|
4710
|
-
newMigrationIds: ReadonlyArray<string>;
|
|
4711
|
-
/**
|
|
4712
|
-
* A multi-line, actionable explanation. Always present; empty string when
|
|
4713
|
-
* there is no drift at all. Mirrors the D1-placeholder guard's message style.
|
|
4714
|
-
*/
|
|
4715
|
-
reason: string;
|
|
4716
|
-
}
|
|
4717
|
-
/**
|
|
4718
|
-
* Decide whether breaking schema drift should block a deploy.
|
|
4719
|
-
*
|
|
4720
|
-
* Blocks only when the baseline exists (a first-ever capture is never blocking),
|
|
4721
|
-
* there is at least one `breaking` change, no new migration COVERS it, and the
|
|
4722
|
-
* `allowDrift` override is not set. Safe-only drift passes.
|
|
4723
|
-
*
|
|
4724
|
-
* "Covers" is per-table, not per-run: a new migration excuses breaking drift on
|
|
4725
|
-
* the table it iterates, and nothing else. Counting new ids alone let a backfill
|
|
4726
|
-
* on `messages` unblock a required field added to `users` — the gate reported
|
|
4727
|
-
* "accompanied by a migration" for a change that migration would never visit.
|
|
4728
|
-
* The shard-mode diff cites this block to justify the studio not shipping a
|
|
4729
|
-
* stranded-rows detector (see `shared/schema-snapshot.ts`), and that claim only
|
|
4730
|
-
* holds if an unrelated migration cannot wave it through.
|
|
4731
|
-
*
|
|
4732
|
-
* Only a `"backfill"` change is coverable at all. A `"rehome"` change moves rows
|
|
4733
|
-
* to another Durable Object or region and a `"code"` change breaks a call site;
|
|
4734
|
-
* rewriting rows fixes neither, so a migration must not excuse them however well
|
|
4735
|
-
* its table matches. Those are cleared by fixing the code or accepting the new
|
|
4736
|
-
* shape (`--allow-schema-drift` / `--update-schema-baseline`).
|
|
4737
|
-
*/
|
|
4738
|
-
declare const evaluateSchemaDrift: (options: {
|
|
4739
|
-
allowDrift?: boolean;
|
|
4740
|
-
baseline: SchemaSnapshot | undefined;
|
|
4741
|
-
/** The command printing the remediation, so it names only flags that command accepts. */
|
|
4742
|
-
command?: string;
|
|
4743
|
-
current: SchemaSnapshot;
|
|
4744
|
-
/** This run's declared migrations, so a new one is matched to the table it iterates. */
|
|
4745
|
-
migrations: ReadonlyArray<Pick<MigrationIR, "id" | "table">>;
|
|
4746
|
-
}) => SchemaDriftDecision;
|
|
4747
4860
|
/**
|
|
4748
4861
|
* Content hash of the schema directory's TypeScript sources — everything codegen
|
|
4749
4862
|
* reads, minus its own `_generated/` output.
|
|
@@ -4802,4 +4915,4 @@ declare const secretKindOf: (value: string) => string | undefined;
|
|
|
4802
4915
|
/** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
|
|
4803
4916
|
declare const redact: (value: string) => string;
|
|
4804
4917
|
declare const VERSION = "0.0.0";
|
|
4805
|
-
export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
|
|
4918
|
+
export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as
|
|
1
|
+
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as i,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-BdxZuSxk.mjs";import{formatAdvisories as f,lintSchema as m,toAdvisorContext as d}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as n,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-DKYJ2K4t.mjs";import{CodegenDiagnosticError as A,diagnosticAt as v}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as C,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-5mDMAMWy.mjs";import{isTestPath as R,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-JdN4KXhV.mjs";import{default as I}from"./packem_shared/discoverAuthApiCalls-DZMYREsq.mjs";import{CONTAINERS_FILENAME as F,discoverContainers as L}from"./packem_shared/CONTAINERS_FILENAME-BJYrxnq2.mjs";import{default as P}from"./packem_shared/discoverCrons-D-vJXsgx.mjs";import{capabilitiesUsedBy as b,createTargetScope as y,foldCapabilitySignals as U,mayReadCapabilityContext as G,sourceCapabilitySignals as H}from"./packem_shared/capabilitiesUsedBy-CN8HACEL.mjs";import{FLAGS_FILENAME as B,discoverFlags as k}from"./packem_shared/FLAGS_FILENAME-BEMyglH0.mjs";import{d as K}from"./packem_shared/index-BhsJzv9r.mjs";import{default as z}from"./packem_shared/discoverHttpRoutes-5iA7gI_Q.mjs";import{default as q}from"./packem_shared/discoverHyperdriveCalls-BJRaIvLx.mjs";import{default as J}from"./packem_shared/discoverInserts-Dw7fvL7s.mjs";import{d as X}from"./packem_shared/index-iw3axJ5Y.mjs";import{default as $}from"./packem_shared/discoverMigrations-C649uAWL.mjs";import{MUTATORS_FILENAME as re,discoverMutators as oe}from"./packem_shared/MUTATORS_FILENAME-DlSftsvY.mjs";import{default as ie}from"./packem_shared/discoverNondeterministicCalls-DQgVTcLv.mjs";import{NOTIFY_FILENAME as se,discoverNotifyCalls as fe,discoverNotifyChannels as me,discoverNotifyConfig as de}from"./packem_shared/NOTIFY_FILENAME-SKk8x0VM.mjs";import{default as ne}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as le}from"./packem_shared/discoverQueries-DVFZJER7.mjs";import{QUEUES_FILENAME as Se,discoverQueues as Ee}from"./packem_shared/QUEUES_FILENAME-BeGwgqcw.mjs";import{default as Ae}from"./packem_shared/discoverR2sqlCalls-BEBdqXi_.mjs";import{default as ge}from"./packem_shared/discoverRlsProcedures-C2lkSLPn.mjs";import{default as Ne}from"./packem_shared/discoverRlsMetadata-DqZpiGts.mjs";import{discoverSandboxUsage as Re}from"./packem_shared/discoverSandboxUsage-CdGRnVU2.mjs";import{default as he}from"./packem_shared/discoverSchema-Cycd1-H0.mjs";import{readServiceBindings as _e,resolveServiceBindings as Fe}from"./packem_shared/readServiceBindings-BA49C6aN.mjs";import{SHAPES_FILENAME as Me,discoverShapes as Pe}from"./packem_shared/SHAPES_FILENAME-rSSihffV.mjs";import{default as be}from"./packem_shared/discoverStorageRulesMetadata-H3RJzkH_.mjs";import{WORKFLOWS_FILENAME as Ue,discoverWorkflows as Ge}from"./packem_shared/WORKFLOWS_FILENAME--RWiu_Vy.mjs";import{emitApp as je}from"./packem_shared/emitApp-D-6FIpYb.mjs";import{isD1GlobalTable as ke,isHyperdriveGlobalTable as We}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ve,emitOpenApi as ze,emitOpenApiModule as Qe}from"./packem_shared/buildOpenApiDocument-afHH7rN5.mjs";import{OPENRPC_VERSION as we,buildOpenRpcDocument as Je,emitOpenRpc as Ye,emitOpenRpcModule as Xe}from"./packem_shared/OPENRPC_VERSION-CSjT8wJW.mjs";import{DEFAULT_TARGET as $e,platformMatrixIds as er,readProjectTarget as rr,resolveCodegenTarget as or}from"./packem_shared/DEFAULT_TARGET-3OLdJhTj.mjs";import{loadProjectConfig as ir,readProjectConfigLiterals as ar}from"./packem_shared/loadProjectConfig-B7RmxIeD.mjs";import{PROJECT_CONFIG_FILENAMES as fr,findCodegenConfigFile as mr,findProjectConfigFile as dr,projectConfigCandidatePaths as pr}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as cr,runCodegen as lr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-Dle_pfr9.mjs";import{SchemaSnapshotParseError as Sr,buildSchemaSnapshot as Er,evaluateSchemaDrift as ur,indexReferencesOf as Ar,parseSchemaSnapshot as vr}from"./packem_shared/SchemaSnapshotParseError-ycDz8gOB.mjs";import{default as Cr}from"./packem_shared/fingerprintSchemaSources-DIYx5eO0.mjs";import{schemaFromIr as Or}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as Tr,validatorIrToJsonSchema as hr}from"./packem_shared/LUNORA_ERROR_CODES-CjACC-MQ.mjs";import{SDK_LANGUAGES as _r,SDK_TARGETS as Fr,generateSdk as Lr}from"./sdk/index.mjs";import{redact as Pr,secretKindOf as Dr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as yr}from"./packem_shared/emitDrizzleSchema-CM9jh_F0.mjs";import{e as Gr}from"./packem_shared/server-D69SOfX8.mjs";import{e as jr}from"./packem_shared/shard-L3gYZnC9.mjs";import{G as kr}from"./packem_shared/shared-A1XHcT4t.mjs";import{MESSAGE_SOLUTIONS as Kr,findSolutionByMessage as Vr}from"@lunora/errors";import{createCodegenProject as Qr,findTsconfig as qr,refreshCodegenProject as wr,tsconfigFingerprint as Jr}from"./packem_shared/createCodegenProject-DmXl8m_P.mjs";import{t as Xr,u as Zr,v as $r}from"./packem_shared/shard-runtime-lkQU8trx.mjs";import{emitApi as ro,emitCollections as oo,emitInternalApi as to}from"./packem_shared/emitApi-GFmStqmq.mjs";import{emitCrons as ao,emitScheduler as so,emitVectors as fo,emitWranglerCronTriggers as mo}from"./packem_shared/emitCrons-Drdn8Mjn.mjs";import{emitDataModel as no}from"./packem_shared/emitDataModel-LTnwnhV6.mjs";import{emitFunctions as lo}from"./packem_shared/emitFunctions-DRAuiKPv.mjs";import{isTypedSchema as So}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{C as AGENTS_FILENAME,E as CAPABILITY_PROBES,F as CONTAINERS_FILENAME,A as CodegenDiagnosticError,$e as DEFAULT_TARGET,B as FLAGS_FILENAME,kr as GENERATED_HEADER,Tr as LUNORA_ERROR_CODES,Kr as LUNORA_SOLUTION_RULES,re as MUTATORS_FILENAME,se as NOTIFY_FILENAME,we as OPENRPC_VERSION,fr as PROJECT_CONFIG_FILENAMES,Se as QUEUES_FILENAME,cr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,_r as SDK_LANGUAGES,Fr as SDK_TARGETS,Me as SHAPES_FILENAME,Sr as SchemaSnapshotParseError,e as VERSION,Ue as WORKFLOWS_FILENAME,Ve as buildOpenApiDocument,Je as buildOpenRpcDocument,Er as buildSchemaSnapshot,b as capabilitiesUsedBy,Qr as createCodegenProject,y as createTargetScope,n as describeErrorLevelFindings,v as diagnosticAt,i as diffSchemaSnapshots,N as discoverAgents,I as discoverAuthApiCalls,L as discoverContainers,P as discoverCrons,k as discoverFlags,K as discoverFunctions,z as discoverHttpRoutes,q as discoverHyperdriveCalls,J as discoverInserts,X as discoverMaskProcedures,$ as discoverMigrations,oe as discoverMutators,ie as discoverNondeterministicCalls,fe as discoverNotifyCalls,me as discoverNotifyChannels,de as discoverNotifyConfig,le as discoverQueries,Ee as discoverQueues,Ae as discoverR2sqlCalls,Ne as discoverRlsMetadata,ge as discoverRlsProcedures,Re as discoverSandboxUsage,he as discoverSchema,Pe as discoverShapes,be as discoverStorageRulesMetadata,Ge as discoverWorkflows,Xr as emitAgents,ro as emitApi,je as emitApp,oo as emitCollections,Zr as emitContainers,ao as emitCrons,no as emitDataModel,yr as emitDrizzleSchema,lo as emitFunctions,to as emitInternalApi,ze as emitOpenApi,Qe as emitOpenApiModule,Ye as emitOpenRpc,Xe as emitOpenRpcModule,so as emitScheduler,Gr as emitServer,jr as emitShard,fo as emitVectors,$r as emitWorkflows,mo as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,ur as evaluateSchemaDrift,mr as findCodegenConfigFile,Vr as findLunoraSolution,dr as findProjectConfigFile,qr as findTsconfig,Cr as fingerprintSchemaSources,U as foldCapabilitySignals,f as formatAdvisories,Lr as generateSdk,Ar as indexReferencesOf,ke as isD1GlobalTable,We as isHyperdriveGlobalTable,R as isTestPath,So as isTypedSchema,m as lintSchema,T as listLunoraSourceFiles,ir as loadProjectConfig,G as mayReadCapabilityContext,vr as parseSchemaSnapshot,er as platformMatrixIds,pr as projectConfigCandidatePaths,ne as readPackageDependencies,ar as readProjectConfigLiterals,rr as readProjectTarget,_e as readServiceBindings,Pr as redact,wr as refreshCodegenProject,or as resolveCodegenTarget,Fe as resolveServiceBindings,lr as runCodegen,Or as schemaFromIr,Dr as secretKindOf,a as serializeSchemaSnapshot,x as sortedUniqueNames,H as sourceCapabilitySignals,d as toAdvisorContext,Jr as tsconfigFingerprint,hr as validatorIrToJsonSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as g}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as w}from"./isTestPath-JdN4KXhV.mjs";import{a as h}from"./attribution-
|
|
1
|
+
import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as g}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as w}from"./isTestPath-JdN4KXhV.mjs";import{a as h}from"./attribution-CTMkuBkn.mjs";const E="agents.ts",v=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const e of n.getDeclarations())if(a.isImportSpecifier(e))return e.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/agent"?!1:e.getNameNode().getText()==="defineAgent";return!1},P=w("agent"),x=(o,n,e)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${e}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},I=(o,n)=>{const e=o.getArguments()[0];if(!e||!a.isObjectLiteralExpression(e))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const t={className:b(n),exportName:n,name:d(n)},i=c(e,"name");i&&a.isPropertyAssignment(i)&&(t.name=P(i.getInitializerOrThrow(),n,"name"));const r=c(e,"publicRun");r&&a.isPropertyAssignment(r)&&x(r.getInitializerOrThrow(),n,"publicRun")&&(t.publicRun=!0);const s=c(e,"voice");if(s&&a.isPropertyAssignment(s)){const m=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(m))throw l(m,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);t.voice=!0,t.voiceBindingName=N(n),t.voiceClassName=y(n)}return c(e,"onEmail")&&(t.onEmail=!0),t},S=o=>{const n=[];for(const e of o.getVariableDeclarations()){const t=A(e.getInitializer());if(!t)continue;const i=t.getExpression();if(!a.isIdentifier(i)||!v(i))continue;const r=e.getNameNode();if(!a.isIdentifier(r)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw l(r,"defineAgent exports must be plain named exports (no destructuring)")}const s=h(e,"binding");s!==void 0&&n.push(I(t,s))}return n},T=o=>{const n=new Map,e=new Map;for(const t of o){const i=n.get(t.name);if(i!==void 0)throw new g("DUPLICATE_AGENT_NAME",`Duplicate agent name "${t.name}": produced by both "${i}" and "${t.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(t.name,t.exportName);const r=e.get(t.className);if(r!==void 0)throw new g("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${t.className}": produced by both "${r}" and "${t.exportName}". Agent export names must yield unique generated class names.`,{status:500});e.set(t.className,t.exportName)}},z=(o,n)=>{const e=f(n,E);if(!p(e))return[];const t=o.getSourceFile(e)??o.addSourceFileAtPath(e),i=S(t);return i.sort((r,s)=>r.exportName.localeCompare(s.exportName)),T(i),i};export{E as AGENTS_FILENAME,z as discoverAgents};
|
package/dist/packem_shared/{CONTAINERS_FILENAME-T1v8pyHN.mjs → CONTAINERS_FILENAME-BJYrxnq2.mjs}
RENAMED
|
@@ -1 +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,descendantsOfKind as F,outermostValueWrapper as w,isWriteTarget as V}from"./isTestPath-JdN4KXhV.mjs";import{a as K}from"./attribution-
|
|
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,descendantsOfKind as F,outermostValueWrapper as w,isWriteTarget as V}from"./isTestPath-JdN4KXhV.mjs";import{a as K}from"./attribution-CTMkuBkn.mjs";import{a as b}from"./property-name-7cBlgK_O.mjs";const B="containers.ts",R=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`)},U=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),N=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},Y=(t,e)=>F(e,$.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(V(i))return!0;n=w(i),i=n.getParent()}return!1}),z=16,T=(t,e,r,n)=>{let i={name:r,symbol:t},o;for(let c=0;c<z;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&&Y(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},W=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(i=>i.getName()))},q=(t,e,r)=>{const n=t.getExpression().getType(),i=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(W(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.`)},x=(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(...H(c,e,r,o));else{const l=x(c,e,r);l!==void 0&&i.push(l)}return i},H=(t,e,r,n)=>{const i=P(t.getExpression(),r);if(!s.isObjectLiteralExpression(i))return q(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)},J=(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},X=(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,N,`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()},G=(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`)},Q=(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},Z=(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},ee=(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"`)},te=(t,e,r,n)=>{const{base:i,policy:o}=r;switch(t){case"buildArgs":{i.buildArgs=J(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=Q(e,n);break}case"instanceType":{i.instanceType=G(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=X(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}}},ne=(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`)},ie=(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,U,`container "${e}"`),i=Z(n,e),o={base:{bindingName:O(e),className:A(e),exportName:e},policy:{},scheduled:i!==void 0};for(const[g,u]of n)ee(g,u,i,e),te(g,u,o,e);const{base:c,policy:l}=o;if(i==="durable_object")return ne(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}}},re=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)||!R(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=K(n,"binding");if(g===void 0)continue;const u=ie(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},me=(t,e)=>{const r=I(e,B);if(!j(r))return[];const n=t.getSourceFile(r)??t.addSourceFileAtPath(r),i=re(n);return i.sort((o,c)=>o.exportName.localeCompare(c.exportName)),i};export{B as CONTAINERS_FILENAME,me as discoverContainers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as n,I as p,a as o,g as d,d as c,h as f,i as m,p as I,r as T,f as y,b as E,c as O,e as A,s as l,u as v,v as P}from"./shared-
|
|
1
|
+
import{G as n,I as p,a as o,g as d,d as c,h as f,i as m,p as I,r as T,f as y,b as E,c as O,e as A,s as l,u as v,v as P}from"./shared-A1XHcT4t.mjs";import"./parse-validator-BisfC8bR.mjs";import"./reserved-words-CW1QFbTd.mjs";import"./LUNORA_ERROR_CODES-CjACC-MQ.mjs";import"./dispatch-namespace-DwTjD7BU.mjs";export{n as GENERATED_HEADER,p as IMPORT_PATH_RE,o as assertIdentifier,d as assertPropertyIdentifier,c as baseSpecifiers,f as isOptionalOnInsert,m as isSensitiveFunction,I as pascalCase,T as renderArgsType,y as renderInsertInterface,E as renderNamespaceTree,O as renderObjectKey,A as renderPropertyKey,l as sensitiveArgNamesOf,v as unwrapOptional,P as validatorToType};
|
package/dist/packem_shared/{MUTATORS_FILENAME-Ipxibja6.mjs → MUTATORS_FILENAME-DlSftsvY.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as E}from"node:fs";import{join as y}from"node:path";import{Node as o,SyntaxKind as l}from"ts-morph";import{diagnosticAt as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as M}from"./module-specifiers-BctA0m_p.mjs";import{p as A}from"./parse-validator-
|
|
1
|
+
import{existsSync as E}from"node:fs";import{join as y}from"node:path";import{Node as o,SyntaxKind as l}from"ts-morph";import{diagnosticAt as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as M}from"./module-specifiers-BctA0m_p.mjs";import{p as A}from"./parse-validator-BisfC8bR.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-JdN4KXhV.mjs";import{g as b,i as D,d as g,h as O}from"./attribution-CTMkuBkn.mjs";import{u as h}from"./unwrap-handler-return-eQRIZSOX.mjs";const w="mutators.ts",x=M,z=r=>{const e=r.getSymbol();if(!e)return r.getText()==="defineMutator";for(const t of e.getDeclarations())if(o.isImportSpecifier(t))return x(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMutator":!1;return!1},C=r=>{const e=r.getSymbol();if(!e)return!1;for(const t of e.getDeclarations()){if(!o.isNamespaceImport(t))continue;const i=t.getFirstAncestorByKind(l.ImportDeclaration);return i!==void 0&&x(i.getModuleSpecifierValue())}return!1},N=r=>{if(o.isIdentifier(r))return z(r);if(o.isPropertyAccessExpression(r)){const e=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(e)&&C(e)}return!1},S=r=>{const e=r.getArguments()[0];return e&&o.isObjectLiteralExpression(e)?e:void 0},m=new WeakMap,p=r=>{let e=m.get(r.compilerNode);if(e===void 0){const t=r.getNameNode(),i=t?.getText();e=r.getSourceFile().getDescendantsOfKind(l.Identifier).filter(s=>s!==t&&s.getText()===i&&g(s)?.compilerNode===r.compilerNode).length===1&&O(r)===void 0,m.set(r.compilerNode,e)}return e},f=r=>{const e=o.isIdentifier(r)?g(r):void 0,t=o.isSourceFile(e?.getParent())||o.isSourceFile(e?.getParent()?.getParent()?.getParent());if(e===void 0||e.getSourceFile()!==r?.getSourceFile()||!t)return;if(o.isFunctionDeclaration(e))return e.hasBody()&&p(e)?e:void 0;const i=P(e)?d(e.getInitializer()):void 0;return(o.isArrowFunction(i)||o.isFunctionExpression(i))&&o.isVariableDeclaration(e)&&p(e)?i:void 0},G=r=>{const e=r.getInitializer();if(!o.isCallExpression(e)||!N(e.getExpression()))return;const t=c(S(e),"server");if(o.isMethodDeclaration(t))return t;if(o.isShorthandPropertyAssignment(t))return f(t.getNameNode());const i=o.isPropertyAssignment(t)?d(t.getInitializer()):void 0;return o.isArrowFunction(i)||o.isFunctionExpression(i)?i:f(i)},T=r=>{const e=c(r,"args");if(!e||!o.isPropertyAssignment(e))return{};const t=e.getInitializer();return t&&o.isObjectLiteralExpression(t)?A(t):{}},L=r=>{const e=c(r,"server");if(!e||!o.isPropertyAssignment(e))return"unknown";const t=e.getInitializer();return!t||!(o.isArrowFunction(t)||o.isFunctionExpression(t))?"unknown":h(t)},j=r=>{const e=c(r,"owner");if(!e||!o.isPropertyAssignment(e))return;const t=e.getInitializer();return t&&o.isStringLiteral(t)?t.getLiteralValue():void 0},R=r=>{const e=[];for(const t of r.getVariableDeclarations()){if(!t.isExported())continue;const i=t.getInitializer();if(i?.getKind()!==l.CallExpression)continue;const n=i,s=n.getExpression();if(!N(s))continue;const a=t.getNameNode();if(!o.isIdentifier(a))throw I(a,"defineMutator exports must be plain named exports (no destructuring)");const u=S(n);for(const v of b(t).filter(F=>D(F)))e.push({args:T(u),exportName:v,filePath:"mutators",line:n.getStartLineNumber(),owner:j(u),returnType:L(u)})}return e},J=(r,e)=>{const t=y(e,w);if(!E(t))return[];const i=r.getSourceFile(t)??r.addSourceFileAtPath(t),n=R(i);return n.sort((s,a)=>s.exportName.localeCompare(a.exportName)),n};export{w as MUTATORS_FILENAME,J as discoverMutators,N as isDefineMutatorCallee,S as mutatorLiteral,G as mutatorServerImplOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as N}from"node:fs";import{join as F}from"node:path";import{SyntaxKind as u,Node as r,VariableDeclarationKind as O}from"ts-morph";import{listLunoraSourceFiles as m,lunoraRelativePath as A,descendantsOfKind as h,findObjectProperty as g,defaultExportExpression as D,handlerOf as I}from"./isTestPath-JdN4KXhV.mjs";import{
|
|
1
|
+
import{existsSync as N}from"node:fs";import{join as F}from"node:path";import{SyntaxKind as u,Node as r,VariableDeclarationKind as O}from"ts-morph";import{listLunoraSourceFiles as m,lunoraRelativePath as A,descendantsOfKind as h,findObjectProperty as g,defaultExportExpression as D,handlerOf as I}from"./isTestPath-JdN4KXhV.mjs";import{j as T,h as C}from"./attribution-CTMkuBkn.mjs";import{a as l}from"./context-root-TiLodrRO.mjs";import{c as k}from"./classify-procedure-call-DtqiTjPg.mjs";const L="notify.ts",M=new Set(["chat","inApp","send","webhook"]),x=new Set(["broadcast","send"]),w=e=>{const s=e.getInitializer();if(!s||!r.isCallExpression(s))return;const t=k(s);if(!t)return;const i=I(s,t.receiver);return i?{exportName:C(e)??e.getName(),handler:i,kind:t.kind}:void 0},y=e=>{const s=[];for(const t of T(e)){const i=w(t);i&&s.push(i)}return s},E=e=>l(e,["notify"])?"notify":l(e,["push"])||l(e,["notify","push"])?"push":void 0,_=e=>{if(!r.isPropertyAccessExpression(e))return;const s=e.getName(),t=E(e.getExpression());if(t==="notify"&&M.has(s))return`ctx.notify.${s}`;if(t==="push"&&x.has(s))return`ctx.push.${s}`},j=e=>r.isPropertyAccessExpression(e)?E(e.getExpression())==="push"&&x.has(e.getName()):!1,ee=(e,s)=>{const t=[];for(const i of m(s)){const o=e.getSourceFile(i)??e.addSourceFileAtPath(i),n=A(s,i);for(const c of y(o))if(!(c.kind!=="query"&&c.kind!=="mutation"))for(const a of h(c.handler,u.PropertyAccessExpression)){const f=_(a);f!==void 0&&t.push({callee:f,exportName:c.exportName,file:n,kind:c.kind,line:a.getStartLineNumber()})}}return t},R=(e,s)=>{for(const t of m(s)){const i=e.getSourceFile(t)??e.addSourceFileAtPath(t);for(const o of y(i))for(const n of h(o.handler,u.PropertyAccessExpression))if(j(n))return!0}return!1},U=new Set(["@lunora/notify"]),V=e=>{const s=e.getSymbol();if(!s)return e.getText()==="defineNotify";for(const t of s.getDeclarations())if(r.isImportSpecifier(t))return U.has(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineNotify":!1;return!1},P=(e,s=new Set)=>{const t=D(e);if(!t)return;if(!r.isIdentifier(t))return t;const i=t.getSymbol();if(!i?.isAlias())return t;const o=i.getAliasedSymbol();if(!o)return t;const n=o.getDeclarations().find(a=>r.isExportAssignment(a));if(!n)return t;const c=n.getSourceFile();if(!s.has(c.getFilePath()))return P(c,s.add(c.getFilePath()))},z=new Set(["%=","&&=","&=","**=","+=","-=","/=","<<=","=",">>=",">>>=","??=","^=","|=","||="]),p=e=>{const s=e.getSymbol();return s?.getAliasedSymbol()?.getDeclarations()[0]??s?.getDeclarations()[0]},S=e=>{if(r.isIdentifier(e))return e;if(r.isPropertyAccessExpression(e)||r.isElementAccessExpression(e))return S(e.getExpression())},d=(e,s)=>{const t=S(e);return t!==void 0&&p(t)===s},H=(e,s)=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return!1;const i=t.getName(),o=t.getExpression(),n=r.isIdentifier(o)?o.getText():"";if(!((i==="assign"||i==="defineProperty"||i==="defineProperties")&&n==="Object"||i==="set"&&n==="Reflect"))return!1;const a=e.getArguments()[0];return a!==void 0&&r.isIdentifier(a)&&p(a)===s},K=(e,s)=>{if(r.isBinaryExpression(e))return z.has(e.getOperatorToken().getText())&&d(e.getLeft(),s);if(r.isDeleteExpression(e))return d(e.getExpression(),s);if(r.isPrefixUnaryExpression(e)||r.isPostfixUnaryExpression(e)){const t=e.getOperatorToken();return(t===u.PlusPlusToken||t===u.MinusMinusToken)&&d(e.getOperand(),s)}return r.isCallExpression(e)?H(e,s):!1},W=(e,s)=>{const t=p(e);return t===void 0?!0:s.some(i=>i.getDescendants().some(o=>K(o,t)))},Y=e=>{if(r.isObjectLiteralExpression(e))return e;if(!r.isIdentifier(e))return;const s=e.getSymbol(),t=s?.getAliasedSymbol()?.getDeclarations()??s?.getDeclarations()??[];for(const i of t){if(!r.isVariableDeclaration(i))continue;const o=i.getInitializer();if(!o||!r.isObjectLiteralExpression(o))continue;const n=i.getParent();if(!r.isVariableDeclarationList(n)||n.getDeclarationKind()!==O.Const)continue;const c=[i.getSourceFile(),e.getSourceFile()].filter((a,f,b)=>b.findIndex(v=>v.getFilePath()===a.getFilePath())===f);if(!W(e,c))return o}},B=(e,s)=>{const t=F(s,L);if(!N(t))return;const i=e.getSourceFile(t)??e.addSourceFileAtPath(t),o=P(i);if(!o||!r.isCallExpression(o))return{hasFcm:!0,hasWebPush:!0};const n=o.getExpression(),c=r.isIdentifier(n)&&V(n)?o.getArguments()[0]:void 0,a=c===void 0?void 0:Y(c);return!a||a.getProperties().some(f=>r.isSpreadAssignment(f))?{hasFcm:!0,hasWebPush:!0}:{hasFcm:g(a,"fcm")!==void 0,hasWebPush:g(a,"webPush")!==void 0}},te=(e,s)=>{const t=B(e,s);return t===void 0?void 0:{...t,usesPush:R(e,s)}};export{L as NOTIFY_FILENAME,ee as discoverNotifyCalls,B as discoverNotifyChannels,te as discoverNotifyConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{m}from"./modules-DEBCI7Gm.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-CjACC-MQ.mjs";import{G as h}from"./shared-
|
|
1
|
+
import{m}from"./modules-DEBCI7Gm.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-CjACC-MQ.mjs";import{G as h}from"./shared-A1XHcT4t.mjs";import{s as i}from"./dispatch-namespace-DwTjD7BU.mjs";const R="1.3.2",g={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},O=(e,r)=>e==="stream"?`Open the \`stream\` \`${r}\` over the Lunora WebSocket. It yields chunks rather than one result, so its \`result\` schema is a placeholder.`:`Invoke the \`${e}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${r}", "args": { … } }\`).`,S=(e,r)=>{const o=`${i(e.filePath)}:${e.exportName}`;return{description:O(e.kind,o),errors:d.map((s,a)=>({code:-32e3-a,data:{code:s},message:s})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:l(e.args)}],result:{name:"result",schema:e.output&&e.kind!=="stream"?p(e.output):g},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,...e.description?{"x-lunora-description":e.description}:{},"x-tags":[{name:r}]}},v=e=>{const r=e.version??"0.0.0",n=e.functions.filter(t=>t.visibility!=="internal"),o=e.modules??[],s=n.map(t=>S(t,m(o,t.filePath))).toSorted((t,c)=>t.name.localeCompare(c.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:r},methods:s,openrpc:R}},E=e=>`${JSON.stringify(v(e),void 0,2)}
|
|
2
2
|
`,N=e=>`${h}export const openRpcSpec = ${u(e,"Record<string, unknown>")};
|
|
3
3
|
`;export{R as OPENRPC_VERSION,v as buildOpenRpcDocument,E as emitOpenRpc,N as emitOpenRpcModule};
|