@lunora/codegen 1.0.0-alpha.1 → 1.0.0-alpha.100
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/LICENSE.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +2756 -884
- package/dist/index.d.ts +2756 -884
- package/dist/index.mjs +1 -28
- package/dist/packem_shared/AGENTS_FILENAME-Dk-k250h.mjs +1 -0
- package/dist/packem_shared/CONTAINERS_FILENAME-DQpyhY6c.mjs +1 -0
- package/dist/packem_shared/CodegenDiagnosticError-DPezpZTz.mjs +1 -0
- package/dist/packem_shared/DEFAULT_TARGET-CH5disA3.mjs +1 -0
- package/dist/packem_shared/FLAGS_FILENAME-Boqm0YCP.mjs +1 -0
- package/dist/packem_shared/GENERATED_HEADER-C5Dapn_Y.mjs +1 -0
- package/dist/packem_shared/LUNORA_ERROR_CODES-zfAI2OFs.mjs +1 -0
- package/dist/packem_shared/MUTATORS_FILENAME-Cp_JxLSz.mjs +1 -0
- package/dist/packem_shared/NOTIFY_FILENAME-DwyJ5I4Q.mjs +1 -0
- package/dist/packem_shared/OPENRPC_VERSION-DkNdVeNM.mjs +3 -0
- package/dist/packem_shared/QUEUES_FILENAME-QpMZsde0.mjs +1 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-hQUs7FJj.mjs +9 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-CFhF_hmg.mjs +2 -0
- package/dist/packem_shared/SHAPES_FILENAME-WxXOsYfe.mjs +1 -0
- package/dist/packem_shared/SchemaSnapshotParseError-BkgxjBPQ.mjs +16 -0
- package/dist/packem_shared/WORKFLOWS_FILENAME-Dz80zqeT.mjs +1 -0
- package/dist/packem_shared/buildOpenApiDocument-DcpvOBMi.mjs +3 -0
- package/dist/packem_shared/describeErrorLevelFindings-IhNx9gPr.mjs +1 -0
- package/dist/packem_shared/discover-ast-7ABwvTVn.mjs +1 -0
- package/dist/packem_shared/discover-queries-i4Vd2si7.mjs +1 -0
- package/dist/packem_shared/discoverAuthApiCalls-XfNbxqlq.mjs +1 -0
- package/dist/packem_shared/discoverCrons-RlATa0_t.mjs +1 -0
- package/dist/packem_shared/discoverFunctions-4TNKUv7P.mjs +1 -0
- package/dist/packem_shared/discoverHttpRoutes-DQivLBqT.mjs +1 -0
- package/dist/packem_shared/discoverInserts-D6szWzrV.mjs +1 -0
- package/dist/packem_shared/discoverMaskProcedures-BBPqLXA5.mjs +1 -0
- package/dist/packem_shared/discoverMigrations-rbjxflR8.mjs +1 -0
- package/dist/packem_shared/discoverNondeterministicCalls-Bxr652Rz.mjs +1 -0
- package/dist/packem_shared/discoverQueries-uFtLDmn_.mjs +1 -0
- package/dist/packem_shared/discoverR2sqlCalls-DMxG6gHr.mjs +1 -0
- package/dist/packem_shared/discoverRlsMetadata-B63ARnKG.mjs +1 -0
- package/dist/packem_shared/discoverSandboxUsage-DBM98vVh.mjs +1 -0
- package/dist/packem_shared/discoverSchema-BNr7PVcZ.mjs +1 -0
- package/dist/packem_shared/discoverStorageRulesMetadata-_40MGqRX.mjs +1 -0
- package/dist/packem_shared/emit-B8FxCABN.mjs +2054 -0
- package/dist/packem_shared/emitApp-Dg-jOuj6.mjs +526 -0
- package/dist/packem_shared/formatAdvisories-CQvIhQ04.mjs +2 -0
- package/dist/packem_shared/module-specifiers-8FEEiUcv.mjs +1 -0
- package/dist/packem_shared/parse-validator-CusS8QwU.mjs +1 -0
- package/dist/packem_shared/paths-BmX5O1sG.mjs +1 -0
- package/dist/packem_shared/readPackageDependencies-CogJX1Ia.mjs +1 -0
- package/dist/packem_shared/redact-6jD4lAhq.mjs +1 -0
- package/dist/packem_shared/schemaFromIr-R1ZFzVyy.mjs +1 -0
- package/package.json +12 -7
- package/dist/packem_shared/CONTAINERS_FILENAME-0K-pjNb8.mjs +0 -224
- package/dist/packem_shared/CodegenDiagnosticError-54jWDxA9.mjs +0 -22
- package/dist/packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs +0 -61
- package/dist/packem_shared/buildOpenApiDocument-yHVN66Xd.mjs +0 -183
- package/dist/packem_shared/buildOpenRpcDocument-BZGY1-jT.mjs +0 -60
- package/dist/packem_shared/buildSchemaSnapshot-DzLDbWk3.mjs +0 -233
- package/dist/packem_shared/createCodegenProject-DGJm0_Pk.mjs +0 -895
- package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
- package/dist/packem_shared/discoverAuthApiCalls-C35R6z0T.mjs +0 -62
- package/dist/packem_shared/discoverCrons-BL6iGuJ3.mjs +0 -254
- package/dist/packem_shared/discoverFunctions-DEgAcRuD.mjs +0 -460
- package/dist/packem_shared/discoverHttpRoutes-C978pBiG.mjs +0 -131
- package/dist/packem_shared/discoverInserts-CRQdXvHO.mjs +0 -39
- package/dist/packem_shared/discoverMaskProcedures-B64zA740.mjs +0 -217
- package/dist/packem_shared/discoverMigrations-Doj_-BAA.mjs +0 -91
- package/dist/packem_shared/discoverNondeterministicCalls-4KiPQxQU.mjs +0 -122
- package/dist/packem_shared/discoverQueries-BkIi0dBD.mjs +0 -62
- package/dist/packem_shared/discoverRlsMetadata-DpRB1HMe.mjs +0 -280
- package/dist/packem_shared/discoverSchema-BBulgGbH.mjs +0 -542
- package/dist/packem_shared/discoverStorageRulesMetadata-DAqJUxUv.mjs +0 -97
- package/dist/packem_shared/discoverWorkflows-DRDQdhfq.mjs +0 -84
- package/dist/packem_shared/emitApi-hRVC-kE7.mjs +0 -2426
- package/dist/packem_shared/emitApp-CzZ6GbrD.mjs +0 -593
- package/dist/packem_shared/lintSchema-DicbOHvH.mjs +0 -68
- package/dist/packem_shared/parse-validator-tuQtHrsr.mjs +0 -132
- package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
- package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,137 @@
|
|
|
1
|
-
import { Finding } from '@lunora/advisor';
|
|
1
|
+
import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext, AdvisorProcedureProtection } from '@lunora/advisor';
|
|
2
2
|
export type { Finding } from '@lunora/advisor';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import '@lunora/platform';
|
|
4
|
+
import { Project, Node } from 'ts-morph';
|
|
5
|
+
import { LunoraError } from '@lunora/errors';
|
|
6
|
+
export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
|
|
7
|
+
import { StudioFeaturesResult } from '@lunora/shard-engine';
|
|
5
8
|
import { Schema } from '@lunora/server';
|
|
6
9
|
import { JsonSchema } from '@lunora/values';
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
11
|
+
* The structural schema-snapshot format and its diff, shared by `@lunora/codegen`
|
|
12
|
+
* (which builds snapshots from the parsed schema IR and gates deploys on the
|
|
13
|
+
* diff) and `@lunora/studio` (which renders the same diff as a visual migration
|
|
14
|
+
* history).
|
|
15
|
+
*
|
|
16
|
+
* Having ONE diff is the point: the Studio's schema-history view and the
|
|
17
|
+
* pre-deploy drift gate must classify a change identically, or the UI will say a
|
|
18
|
+
* change is safe while `lunora deploy` refuses it. `@lunora/codegen` is a
|
|
19
|
+
* build-time package the browser bundle cannot import, and neither package sits
|
|
20
|
+
* below the other, so — like `shared/quote-identifier.ts` — this lives outside
|
|
21
|
+
* both and is bundler-inlined into each. Keep it genuinely zero-dependency
|
|
22
|
+
* (relative/built-in imports only) or inlining breaks. Consumers must drop
|
|
23
|
+
* `outDir`/`rootDir` from their `tsconfig.json` (a set `rootDir` raises TS6059
|
|
24
|
+
* for this out-of-package file under `tsc --noEmit`).
|
|
25
|
+
*
|
|
26
|
+
* What stays in `@lunora/codegen`: building a snapshot from `SchemaIR`, the
|
|
27
|
+
* `SchemaSnapshotParseError` class (it extends `LunoraError`), and the deploy
|
|
28
|
+
* gate's policy (`evaluateSchemaDrift`). What lives here: the format, the diff,
|
|
29
|
+
* the severity classification, and the content hash.
|
|
30
|
+
*/
|
|
31
|
+
/** Current snapshot format version. Bumped if the structural shape below changes. */
|
|
32
|
+
declare const SCHEMA_SNAPSHOT_VERSION: 1;
|
|
33
|
+
/** A single field's structural shape: its value kind and whether it is optional. */
|
|
34
|
+
interface FieldSnapshot {
|
|
35
|
+
/** The validator kind (`string`, `number`, `id`, `object`, …) after unwrapping `v.optional`. */
|
|
36
|
+
kind: string;
|
|
37
|
+
/** True when declared `v.optional(...)` — accepts `undefined` / absent on insert. */
|
|
38
|
+
optional: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** A single secondary index's structural shape. */
|
|
41
|
+
interface IndexSnapshot {
|
|
42
|
+
fields: ReadonlyArray<string>;
|
|
43
|
+
unique: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** A single relation's structural shape. */
|
|
46
|
+
interface RelationSnapshot {
|
|
47
|
+
field: string;
|
|
48
|
+
kind: "many" | "one";
|
|
49
|
+
table: string;
|
|
50
|
+
}
|
|
51
|
+
/** Structural snapshot of one table. */
|
|
52
|
+
interface TableSnapshot {
|
|
53
|
+
/** Field name → {@link FieldSnapshot}, in declared order. */
|
|
54
|
+
fields: Record<string, FieldSnapshot>;
|
|
55
|
+
/** Index name → {@link IndexSnapshot}. */
|
|
56
|
+
indexes: Record<string, IndexSnapshot>;
|
|
57
|
+
/** Relation accessor name → {@link RelationSnapshot}. */
|
|
58
|
+
relations: Record<string, RelationSnapshot>;
|
|
59
|
+
/**
|
|
60
|
+
* `"root"` (default single-DO), `"global"` (D1-replicated), or
|
|
61
|
+
* `"shardBy:<field>"` (partitioned). Encoded as a string so the snapshot
|
|
62
|
+
* stays a plain JSON-stable value.
|
|
63
|
+
*/
|
|
64
|
+
shardMode: string;
|
|
65
|
+
}
|
|
66
|
+
/** A deterministic structural view of the whole schema at one point in time. */
|
|
67
|
+
interface SchemaSnapshot {
|
|
68
|
+
/**
|
|
69
|
+
* Cloudflare DO data-residency jurisdiction declared via `.jurisdiction("…")`,
|
|
70
|
+
* or absent. Tracked because changing it strands all existing Durable Object
|
|
71
|
+
* data (a DO name maps to a different ID per jurisdiction). Optional, so old
|
|
72
|
+
* baselines written before this field parse cleanly (absent ⇒ undefined).
|
|
73
|
+
*
|
|
74
|
+
* Typed as a plain `string` (not the authoring union) on purpose: this is
|
|
75
|
+
* STORED data that a newer Lunora may have written with a jurisdiction this
|
|
76
|
+
* version doesn't yet know. Preserving the raw value keeps the breaking
|
|
77
|
+
* `changedJurisdiction` diff correct under a downgrade — coercing an unknown
|
|
78
|
+
* value to `undefined` would fail OPEN and hide the most destructive change.
|
|
79
|
+
*/
|
|
80
|
+
jurisdiction?: string;
|
|
81
|
+
/** Sorted list of every declared `defineMigration` id at capture time. */
|
|
82
|
+
migrationIds: ReadonlyArray<string>;
|
|
83
|
+
/** Table name → {@link TableSnapshot}, keys sorted for stable serialization. */
|
|
84
|
+
tables: Record<string, TableSnapshot>;
|
|
85
|
+
version: typeof SCHEMA_SNAPSHOT_VERSION;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Whether a change is anchored to one table's own shape, or to the schema as a
|
|
89
|
+
* whole.
|
|
90
|
+
*
|
|
91
|
+
* This is the signal a UI needs to decide which tables to mark as changed, and
|
|
92
|
+
* it lives HERE — next to the change union it classifies — rather than as a
|
|
93
|
+
* hand-maintained set of type names in the consumer. A set in the consumer gives
|
|
94
|
+
* zero compile-time pressure: adding a variant to `DriftChange["type"]` would
|
|
95
|
+
* silently render an affected table as untouched, which is exactly the
|
|
96
|
+
* UI-disagrees-with-the-deploy-gate divergence this module exists to prevent.
|
|
97
|
+
*/
|
|
98
|
+
type DriftScope = "schema" | "table";
|
|
99
|
+
/** One classified structural change between two snapshots. */
|
|
100
|
+
interface DriftChange {
|
|
101
|
+
/**
|
|
102
|
+
* `"table"` means this table's own DDL moved (fields, indexes, shard mode) —
|
|
103
|
+
* a relation whose foreign key lives on the OTHER table stays `"schema"`, so
|
|
104
|
+
* the "changed" signal keeps meaning "this table's shape moved".
|
|
105
|
+
*/
|
|
106
|
+
scope: DriftScope;
|
|
107
|
+
/** `"breaking"` changes need a data migration; `"safe"` changes are additive. */
|
|
108
|
+
severity: "breaking" | "safe";
|
|
109
|
+
/** Human-readable, actionable description (used in the gate message). */
|
|
110
|
+
summary: string;
|
|
111
|
+
/** The table this change belongs to. Always set when `scope` is `"table"`. */
|
|
112
|
+
table?: string;
|
|
113
|
+
/** A machine-readable change discriminator. */
|
|
114
|
+
type: "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedFieldKind" | "changedIndex" | "changedJurisdiction" | "changedShardMode" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "removedField" | "removedIndex" | "removedRelation" | "removedTable";
|
|
115
|
+
}
|
|
116
|
+
/** The result of diffing two snapshots: every classified change. */
|
|
117
|
+
interface SchemaDrift {
|
|
118
|
+
/** Every classified change, in a stable order (added/changed per table, then removals). */
|
|
119
|
+
changes: ReadonlyArray<DriftChange>;
|
|
120
|
+
}
|
|
121
|
+
/** Serialize a snapshot to the exact bytes written to `lunora/.lunora-schema.json` (trailing newline). */
|
|
122
|
+
declare const serializeSchemaSnapshot: (snapshot: SchemaSnapshot) => string;
|
|
123
|
+
/**
|
|
124
|
+
* Diff the current snapshot against a baseline and classify every structural
|
|
125
|
+
* change. Pure — no I/O. When `baseline` is `undefined` (no snapshot yet) there
|
|
126
|
+
* is no drift to report: every table is treated as a fresh additive
|
|
127
|
+
* `addedTable`, so a first deploy is never blocked.
|
|
128
|
+
*/
|
|
129
|
+
declare const diffSchemaSnapshots: (baseline: SchemaSnapshot | undefined, current: SchemaSnapshot) => SchemaDrift;
|
|
130
|
+
/**
|
|
131
|
+
* AST-observable subset of a column's modifier chain (`.unique()`, `.default()`,
|
|
132
|
+
* …). Function-valued modifiers (`.$defaultFn`/`.$onUpdateFn`) can't be
|
|
133
|
+
* serialized, so only their *presence* is recorded.
|
|
134
|
+
*/
|
|
12
135
|
interface ColumnMetaIR {
|
|
13
136
|
/** `.default(...)` or `.$defaultFn(...)` present — field is optional on insert. */
|
|
14
137
|
hasDefault?: boolean;
|
|
@@ -25,6 +148,15 @@ interface ValidatorIR {
|
|
|
25
148
|
bucket?: string;
|
|
26
149
|
/** Column modifiers (`.unique()`, `.default()`, `.nullable()`, …) when present. */
|
|
27
150
|
column?: ColumnMetaIR;
|
|
151
|
+
/**
|
|
152
|
+
* `true` when this validator carries a `.check(...)` refinement. The predicate
|
|
153
|
+
* is a runtime closure the AST→IR step can't represent, so the node keeps its
|
|
154
|
+
* base `kind` but records the refinement's presence here. The AOT args-validator
|
|
155
|
+
* compiler declines any node with this flag (compiling it would silently skip
|
|
156
|
+
* the predicate). `.meta(...)` is pure metadata with no parse effect and does
|
|
157
|
+
* NOT set this.
|
|
158
|
+
*/
|
|
159
|
+
hasRefinement?: boolean;
|
|
28
160
|
/** For `v.optional(inner)` / `v.array(inner)`. */
|
|
29
161
|
inner?: ValidatorIR;
|
|
30
162
|
/** For `v.record(key, value)`. */
|
|
@@ -41,6 +173,14 @@ interface ValidatorIR {
|
|
|
41
173
|
sourceText?: string;
|
|
42
174
|
/** For `v.id("table")` — the table name. */
|
|
43
175
|
tableName?: string;
|
|
176
|
+
/**
|
|
177
|
+
* For `v.from(externalSchema)` — the wrapped Standard Schema's inferred type,
|
|
178
|
+
* rendered as TS source. Recovered through the type checker from
|
|
179
|
+
* `~standard.types.output`, mirroring the runtime's `InferStandardOutput`.
|
|
180
|
+
* Absent when it could not be recovered safely, in which case the emitted
|
|
181
|
+
* type falls back to `unknown`.
|
|
182
|
+
*/
|
|
183
|
+
tsType?: string;
|
|
44
184
|
valueType?: ValidatorIR;
|
|
45
185
|
}
|
|
46
186
|
interface IndexIR {
|
|
@@ -49,11 +189,32 @@ interface IndexIR {
|
|
|
49
189
|
unique?: boolean;
|
|
50
190
|
}
|
|
51
191
|
interface SearchIndexIR {
|
|
52
|
-
/** Primary text-search field. */
|
|
192
|
+
/** Primary text-search field; a dot-separated path reads a nested field. */
|
|
53
193
|
field: string;
|
|
54
194
|
/** Optional filter fields surfaced alongside the FTS column. */
|
|
55
195
|
filterFields?: ReadonlyArray<string>;
|
|
196
|
+
/** Text-analysis profile (accent folding + that language's stopwords). */
|
|
197
|
+
language?: string;
|
|
56
198
|
name: string;
|
|
199
|
+
/** Skip the migration-time backfill of the search companion (large tables index out-of-band). */
|
|
200
|
+
staged?: boolean;
|
|
201
|
+
/** `"native"` opts into the engine's own full-text index where it has one (Postgres). */
|
|
202
|
+
strategy?: string;
|
|
203
|
+
}
|
|
204
|
+
/** A `.geoIndex(name, { field, precision? })` declaration — a geohash companion over a `v.geoPoint()` column. */
|
|
205
|
+
interface GeoIndexIR {
|
|
206
|
+
/** The `v.geoPoint()` column feeding the geohash. */
|
|
207
|
+
field: string;
|
|
208
|
+
name: string;
|
|
209
|
+
/** Geohash precision (characters) maintained on the companion; omitted ⇒ the runtime default. */
|
|
210
|
+
precision?: number;
|
|
211
|
+
}
|
|
212
|
+
/** A `.ttl(field, { after? })` declaration — declarative table-level auto-expiry. */
|
|
213
|
+
interface TtlIR {
|
|
214
|
+
/** Millisecond offset added to `field` to derive the expiry (`field + after`); omitted ⇒ `field` is the absolute expiry. */
|
|
215
|
+
after?: number;
|
|
216
|
+
/** The epoch-millisecond expiry column. */
|
|
217
|
+
field: string;
|
|
57
218
|
}
|
|
58
219
|
interface VectorIndexIR {
|
|
59
220
|
dimensions?: number;
|
|
@@ -67,19 +228,19 @@ interface VectorIndexIR {
|
|
|
67
228
|
table: string;
|
|
68
229
|
}
|
|
69
230
|
/**
|
|
70
|
-
* One ordering key on a rank index's `sortBy`: the column and direction.
|
|
71
|
-
* Mirrors the runtime `RankSortKey` (defaults `direction` to `"asc"`).
|
|
72
|
-
*/
|
|
231
|
+
* One ordering key on a rank index's `sortBy`: the column and direction.
|
|
232
|
+
* Mirrors the runtime `RankSortKey` (defaults `direction` to `"asc"`).
|
|
233
|
+
*/
|
|
73
234
|
interface RankSortKeyIR {
|
|
74
235
|
direction: "asc" | "desc";
|
|
75
236
|
field: string;
|
|
76
237
|
}
|
|
77
238
|
/**
|
|
78
|
-
* A `.rankIndex(name, { sortBy, partitionBy?, where? })` declaration. The owning
|
|
79
|
-
* table is always the table the index is declared on, so — unlike a vector index
|
|
80
|
-
* — there is no separate `on`/`table` reference to carry: it rides along on its
|
|
81
|
-
* {@link TableIR}. Only the fields needed for type emission are captured.
|
|
82
|
-
*/
|
|
239
|
+
* A `.rankIndex(name, { sortBy, partitionBy?, where? })` declaration. The owning
|
|
240
|
+
* table is always the table the index is declared on, so — unlike a vector index
|
|
241
|
+
* — there is no separate `on`/`table` reference to carry: it rides along on its
|
|
242
|
+
* {@link TableIR}. Only the fields needed for type emission are captured.
|
|
243
|
+
*/
|
|
83
244
|
interface RankIndexIR {
|
|
84
245
|
name: string;
|
|
85
246
|
/** Columns scoping each ranking; omitted ⇒ one global rank over the table. */
|
|
@@ -100,21 +261,79 @@ interface RelationIR {
|
|
|
100
261
|
/** Target table name. */
|
|
101
262
|
table: string;
|
|
102
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Statically-discovered `.source(...)` config (plan 077). Only the bits the
|
|
266
|
+
* advisor lints + DO wiring need are captured; `map`/`tenantBy` are functions and
|
|
267
|
+
* cannot be serialized, so their presence is recorded as `hasTenantBy` rather than
|
|
268
|
+
* the function itself.
|
|
269
|
+
*/
|
|
270
|
+
interface ExternalSourceIR {
|
|
271
|
+
/** The wrangler Hyperdrive binding name. */
|
|
272
|
+
binding: string;
|
|
273
|
+
/** Whether a `columns` projection allow-list was given. */
|
|
274
|
+
columns?: ReadonlyArray<string>;
|
|
275
|
+
/** `true` when a `reconcileEveryMs` was given — one of the two incremental delete-visibility paths the `external_source_incremental_no_delete_path` lint checks. */
|
|
276
|
+
hasReconcile?: boolean;
|
|
277
|
+
/** `true` when a `softDeleteColumn` was given — the other incremental delete-visibility path. */
|
|
278
|
+
hasSoftDelete?: boolean;
|
|
279
|
+
/** `true` when a `tenantBy` mapper was given — the tenant-isolation boundary the `external_source_unscoped` lint checks. */
|
|
280
|
+
hasTenantBy: boolean;
|
|
281
|
+
/** The `idColumn` literal, when given (defaults to `"id"` at runtime). */
|
|
282
|
+
idColumn?: string;
|
|
283
|
+
/** Delete-detection mode literal, when given (`"full-pull"` today). */
|
|
284
|
+
mode?: string;
|
|
285
|
+
/** The membership query literal, when statically knowable. */
|
|
286
|
+
query?: string;
|
|
287
|
+
/**
|
|
288
|
+
* `true` when `.source(...)` was present but its argument was **not** a static
|
|
289
|
+
* object literal (e.g. `.source(buildConfig())`), so none of the fields above
|
|
290
|
+
* could be read. The source still exists — this flag lets `hasSourcedTables`
|
|
291
|
+
* (codegen) and the `external_source_*` lints treat it as a source that can't be
|
|
292
|
+
* verified, instead of mistaking it for no `.source()` at all.
|
|
293
|
+
*/
|
|
294
|
+
unanalyzable?: boolean;
|
|
295
|
+
}
|
|
103
296
|
interface TableIR {
|
|
104
297
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
298
|
+
* The `defineSchemaExtension` key that contributed this table, set when it
|
|
299
|
+
* arrived through `defineSchema(...).extend(...)`. Absent for a table the app
|
|
300
|
+
* declared itself.
|
|
301
|
+
*
|
|
302
|
+
* Drives the generated `AppTableName` union: an add-on's tables
|
|
303
|
+
* (`ratelimit_buckets`, …) are real tables and stay in `TableName`, but an app
|
|
304
|
+
* enumerating "my tables" should not have to know about them.
|
|
305
|
+
*/
|
|
306
|
+
extensionKey?: string;
|
|
307
|
+
/**
|
|
308
|
+
* `true` when the table chain carried `.externallyManaged()` — its rows are
|
|
309
|
+
* written outside Lunora's discoverable insert path (adapter/migration/
|
|
310
|
+
* middleware), so advisor insert-path lints skip it. Optional: hand-built
|
|
311
|
+
* IR and the runtime `fromServerSchema` path default it to `false`.
|
|
312
|
+
*/
|
|
110
313
|
externallyManaged?: boolean;
|
|
111
314
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
315
|
+
* Set when the chain carried `.source(...)` — the table is materialized from an
|
|
316
|
+
* external Hyperdrive-backed database by a system poll loop (plan 077). Carries
|
|
317
|
+
* the statically-knowable bits the advisor lints read; the functions (`map`,
|
|
318
|
+
* `tenantBy`) are not serialized, only their presence (`hasTenantBy`).
|
|
319
|
+
*/
|
|
320
|
+
externalSource?: ExternalSourceIR;
|
|
321
|
+
/**
|
|
322
|
+
* Storage backend for a `.global()` table: `"d1"` (default) or
|
|
323
|
+
* `"hyperdrive"` (a Postgres/MySQL database via Cloudflare Hyperdrive). Only
|
|
324
|
+
* meaningful when `shardMode === "global"`; absent for sharded/root tables.
|
|
325
|
+
*/
|
|
326
|
+
/** Geospatial indexes declared inline via `.geoIndex(name, …)`. Optional so hand-built IR may omit it (discovery always sets it). */
|
|
327
|
+
geoIndexes?: ReadonlyArray<GeoIndexIR>;
|
|
116
328
|
globalBackend?: "d1" | "hyperdrive";
|
|
117
329
|
indexes: ReadonlyArray<IndexIR>;
|
|
330
|
+
/**
|
|
331
|
+
* `true` when the table chain carried `.public()` — an explicit opt-OUT of
|
|
332
|
+
* the schema's `.rls("required")` enforcement for this one table. Optional:
|
|
333
|
+
* hand-built IR and tables that never called `.public()` default it to
|
|
334
|
+
* `false`.
|
|
335
|
+
*/
|
|
336
|
+
isPublic?: boolean;
|
|
118
337
|
name: string;
|
|
119
338
|
/** Rank indexes declared inline via `.rankIndex(name, …)`. */
|
|
120
339
|
rankIndexes: ReadonlyArray<RankIndexIR>;
|
|
@@ -126,52 +345,111 @@ interface TableIR {
|
|
|
126
345
|
field: string;
|
|
127
346
|
kind: "shardBy";
|
|
128
347
|
};
|
|
348
|
+
/** Set when the chain carried `.softDelete()` — the marker column's name (default `deletedAt`). The column is injected into `shape` so `Doc_*` carries it. */
|
|
349
|
+
softDelete?: {
|
|
350
|
+
field: string;
|
|
351
|
+
};
|
|
352
|
+
/** Set when the chain carried `.ttl(field, { after? })` — the declarative auto-expiry policy read by the DO alarm sweep. */
|
|
353
|
+
ttl?: TtlIR;
|
|
129
354
|
/** Vector indexes declared inline via `.vectorize()` (DSL Shape A). */
|
|
130
355
|
vectorIndexes: ReadonlyArray<VectorIndexIR>;
|
|
131
356
|
}
|
|
357
|
+
/** The Cloudflare DO data-residency jurisdictions the schema may declare. Canonical literal set for the codegen package. */
|
|
358
|
+
type JurisdictionIR = "eu" | "fedramp" | "us";
|
|
132
359
|
interface SchemaIR {
|
|
360
|
+
/**
|
|
361
|
+
* Cloudflare data-residency jurisdiction declared via
|
|
362
|
+
* `defineSchema(...).jurisdiction("…")`. Emitted into the generated worker's
|
|
363
|
+
* `createWorker({ jurisdiction })` (and `ctx.scheduler` / `ctx.containers`).
|
|
364
|
+
* Absent ⇒ un-pinned.
|
|
365
|
+
*/
|
|
366
|
+
jurisdiction?: JurisdictionIR;
|
|
367
|
+
/**
|
|
368
|
+
* Set when `defineSchema(...).rls("required")` was chained onto the schema —
|
|
369
|
+
* every table's `ctx.db` write path is denied without an RLS-covering
|
|
370
|
+
* procedure unless the table itself is `.public()` (see {@link TableIR.isPublic}).
|
|
371
|
+
* Absent when the schema never called `.rls("required")`.
|
|
372
|
+
*/
|
|
373
|
+
rlsMode?: "required";
|
|
133
374
|
tables: ReadonlyArray<TableIR>;
|
|
134
375
|
/** All vector indexes (inline Shape A hoisted + standalone Shape B), flattened. */
|
|
135
376
|
vectorIndexes: ReadonlyArray<VectorIndexIR>;
|
|
136
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Statically-read mirror of `@lunora/server`'s `RestCacheConfig`. Every field is
|
|
380
|
+
* optional because discovery only records literals it could actually read off the
|
|
381
|
+
* `.expose({ cache: … })` object.
|
|
382
|
+
*/
|
|
383
|
+
interface ExposeCacheIR {
|
|
384
|
+
maxAge?: number;
|
|
385
|
+
scope?: "private" | "public";
|
|
386
|
+
staleWhileRevalidate?: number;
|
|
387
|
+
tag?: string;
|
|
388
|
+
vary?: string;
|
|
389
|
+
}
|
|
137
390
|
interface FunctionIR {
|
|
138
391
|
args: Record<string, ValidatorIR>;
|
|
139
392
|
exportName: string;
|
|
140
|
-
/**
|
|
393
|
+
/**
|
|
394
|
+
* Set by the `.expose({ rest: true })` builder modifier (plan 167). When
|
|
395
|
+
* `rest` is `true` the function is published on the public REST surface, so the
|
|
396
|
+
* OpenAPI emitter describes it as a real `/_lunora/rest/<namespace>/<fn>` path
|
|
397
|
+
* (the single source of truth the runtime router also derives from). Absent →
|
|
398
|
+
* RPC-only (the default; not on the REST surface).
|
|
399
|
+
*
|
|
400
|
+
* `cache` mirrors the `RestCacheConfig` the runtime turns into response
|
|
401
|
+
* headers, so the emitted spec can document the `Cache-Control` a caller will
|
|
402
|
+
* actually observe. Only statically-readable literal fields are carried; a
|
|
403
|
+
* computed value is simply absent (the spec under-documents rather than lies).
|
|
404
|
+
*/
|
|
405
|
+
expose?: {
|
|
406
|
+
cache?: ExposeCacheIR;
|
|
407
|
+
rest?: boolean;
|
|
408
|
+
};
|
|
409
|
+
/** Path relative to `<projectRoot>/lunora/` without extension, e.g. "messages". */
|
|
141
410
|
filePath: string;
|
|
142
411
|
kind: "action" | "mutation" | "query" | "stream";
|
|
143
412
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
413
|
+
* Set on connection-lifecycle hooks (`onConnect`/`onDisconnect`): the socket
|
|
414
|
+
* side the hook fires on. Such a function is also an internal mutation (so it
|
|
415
|
+
* lands in `LUNORA_FUNCTIONS` for path dispatch); emit additionally collects
|
|
416
|
+
* it into the `LUNORA_LIFECYCLE_HOOKS` manifest keyed by this side. Absent on
|
|
417
|
+
* ordinary functions.
|
|
418
|
+
*/
|
|
150
419
|
lifecycle?: "connect" | "disconnect";
|
|
151
420
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
421
|
+
* The `.output(validator)` declaration, when the chain has one.
|
|
422
|
+
*
|
|
423
|
+
* Takes precedence over {@link FunctionIR.returnType} (the handler's
|
|
424
|
+
* inferred type) for the emitted `FunctionReference`. `.output()` is what
|
|
425
|
+
* validates at runtime and what a reader takes as the contract, so the two
|
|
426
|
+
* must agree — see the emit-side note for what went wrong when they did not.
|
|
427
|
+
*/
|
|
428
|
+
output?: ValidatorIR;
|
|
429
|
+
/**
|
|
430
|
+
* Serialized TS source for the handler's return type, with `Promise<T>`
|
|
431
|
+
* unwrapped so callers see `T` directly. Defaults to `"unknown"` when
|
|
432
|
+
* ts-morph cannot resolve the type (typically because the consuming
|
|
433
|
+
* project lacks a tsconfig that can reach `@lunora/server`).
|
|
434
|
+
*/
|
|
157
435
|
returnType: string;
|
|
158
436
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
437
|
+
* Call surface the function is exposed on. Absent (or `"public"`) means it
|
|
438
|
+
* lands in the generated `api`; `"internal"` routes it to the separate
|
|
439
|
+
* `internal` object and is rejected by the DO's external RPC path.
|
|
440
|
+
*/
|
|
163
441
|
visibility?: "internal" | "public";
|
|
164
442
|
}
|
|
165
443
|
/**
|
|
166
|
-
* A `defineMigration({...})` declaration discovered in the user's lunora
|
|
167
|
-
* sources. The emitted `LUNORA_MIGRATIONS` registry keys on {@link MigrationIR.id}; the
|
|
168
|
-
* import wiring needs {@link MigrationIR.exportName}/{@link MigrationIR.filePath}. {@link MigrationIR.table} is
|
|
169
|
-
* informational (the runtime object carries the authoritative value).
|
|
170
|
-
*/
|
|
444
|
+
* A `defineMigration({...})` declaration discovered in the user's lunora
|
|
445
|
+
* sources. The emitted `LUNORA_MIGRATIONS` registry keys on {@link MigrationIR.id}; the
|
|
446
|
+
* import wiring needs {@link MigrationIR.exportName}/{@link MigrationIR.filePath}. {@link MigrationIR.table} is
|
|
447
|
+
* informational (the runtime object carries the authoritative value).
|
|
448
|
+
*/
|
|
171
449
|
interface MigrationIR {
|
|
172
450
|
/** Export binding name, used to reference the module member in generated imports. */
|
|
173
451
|
exportName: string;
|
|
174
|
-
/** Path relative to
|
|
452
|
+
/** Path relative to `<projectRoot>/lunora/` without extension, e.g. "migrations". */
|
|
175
453
|
filePath: string;
|
|
176
454
|
/** Stable migration id — the registry key and per-shard run-state key. */
|
|
177
455
|
id: string;
|
|
@@ -179,12 +457,109 @@ interface MigrationIR {
|
|
|
179
457
|
table: string;
|
|
180
458
|
}
|
|
181
459
|
/**
|
|
182
|
-
* A
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
|
|
460
|
+
* A `defineShape({...})` declaration discovered in `lunora/shapes.ts`
|
|
461
|
+
* (local-first sync engine, Phase 7). The emitted `LUNORA_SHAPES` registry keys
|
|
462
|
+
* on {@link ShapeIR.exportName}; the generated DO's `resolveShape` override
|
|
463
|
+
* dispatches a `shape_subscribe` to the matching registered shape. Discovery is
|
|
464
|
+
* marker-driven (the `__lunoraShape` brand) — no field metadata is lifted here
|
|
465
|
+
* because the runtime object (`columns`/`compileWhere`) carries the authority.
|
|
466
|
+
*/
|
|
467
|
+
interface ShapeIR {
|
|
468
|
+
/**
|
|
469
|
+
* The shape's `args` validator map — its partition selector. Lifted so
|
|
470
|
+
* `_generated/collections.ts` can type the selector a caller passes instead of
|
|
471
|
+
* widening it to `Record<string, unknown>`. `{}` for a parameterless shape.
|
|
472
|
+
*/
|
|
473
|
+
args: Record<string, ValidatorIR>;
|
|
474
|
+
/** Export binding name — the shape's registry key and import member. */
|
|
475
|
+
exportName: string;
|
|
476
|
+
/** Path relative to `<projectRoot>/lunora/` without extension — always `"shapes"`. */
|
|
477
|
+
filePath: string;
|
|
478
|
+
/**
|
|
479
|
+
* The `table` string literal from the `defineShape({ table })` call, lifted
|
|
480
|
+
* only for static advisor lints (the runtime object stays authoritative).
|
|
481
|
+
* `undefined` when `table` is not a plain string literal — lints skip those.
|
|
482
|
+
*/
|
|
483
|
+
table?: string;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* The single `defineIdentity({...})` claim contract discovered in
|
|
487
|
+
* `lunora/identity.ts`. Discovery is **marker-driven** (the `__lunoraIdentity`
|
|
488
|
+
* brand, exactly like {@link ShapeIR}) — no claim metadata is lifted here
|
|
489
|
+
* because the emitted `_generated/server.ts` recovers the claim *type* from the
|
|
490
|
+
* declaration itself (`InferIdentity` over the contract's `typeof`), and the
|
|
491
|
+
* runtime object (`validate`/`onInvalid`) carries the authority at the boundary.
|
|
492
|
+
* Exactly one per app; absent ⇒ generated output is byte-identical to today.
|
|
493
|
+
*/
|
|
494
|
+
interface IdentityIR {
|
|
495
|
+
/** Export binding name — the namespace member `_generated/server.ts` reads via `typeof`. */
|
|
496
|
+
exportName: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* The single `defineEnv({...})` contract discovered in `lunora/env.ts`. Like
|
|
500
|
+
* {@link IdentityIR}, only the export binding is lifted — the emitted
|
|
501
|
+
* `_generated/server.ts` recovers the validated shape from the declaration
|
|
502
|
+
* itself (`ReturnType` over the accessor's `typeof`), and the generated ShardDO
|
|
503
|
+
* applies the same accessor to the worker `env` at ctx-build time to populate
|
|
504
|
+
* `ctx.env`. Exactly one per app; absent ⇒ generated output is byte-identical.
|
|
505
|
+
*/
|
|
506
|
+
interface EnvIR {
|
|
507
|
+
/** Export binding name — the namespace member `_generated/server.ts` reads via `typeof`. */
|
|
508
|
+
exportName: string;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* A `defineMutator({...})` declaration discovered in `lunora/mutators.ts`
|
|
512
|
+
* (local-first sync engine, Phase 7). The emitted registry registers the
|
|
513
|
+
* authoritative `server` impl into the DO's `LUNORA_FUNCTIONS` table (so
|
|
514
|
+
* `handleRpc` transaction-wraps it) and records its path in
|
|
515
|
+
* `LUNORA_MUTATOR_PATHS` so the DO's `isCustomMutator` override routes the
|
|
516
|
+
* client-watermark push protocol. The client `client` impl is split into the
|
|
517
|
+
* browser bundle separately — only the path crosses to the server side.
|
|
518
|
+
*/
|
|
519
|
+
interface MutatorIR {
|
|
520
|
+
/**
|
|
521
|
+
* The mutator's `args` validator map, parsed exactly as a procedure's is, so
|
|
522
|
+
* the emitted `api.mutators.<name>` reference carries the arg type a client
|
|
523
|
+
* `defineMutator` infers instead of restating. `{}` for a parameterless
|
|
524
|
+
* mutator (or one whose `args` isn't an inline object literal).
|
|
525
|
+
*/
|
|
526
|
+
args: Record<string, ValidatorIR>;
|
|
527
|
+
/** Export binding name — the mutator's registry key and import member. */
|
|
528
|
+
exportName: string;
|
|
529
|
+
/** Path relative to `<projectRoot>/lunora/` without extension — always `"mutators"`. */
|
|
530
|
+
filePath: string;
|
|
531
|
+
/**
|
|
532
|
+
* Serialized TS source for the authoritative `server` impl's return type,
|
|
533
|
+
* `Promise<T>` unwrapped. `"unknown"` when ts-morph can't resolve it — same
|
|
534
|
+
* contract as {@link FunctionIR.returnType}.
|
|
535
|
+
*/
|
|
536
|
+
returnType: string;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* A whole-row `ctx.db.replace(id, document)` write discovered inside a custom
|
|
540
|
+
* mutator's inline `server` impl (`lunora/mutators.ts`) — the input the
|
|
541
|
+
* `mutator_full_row_replace` advisor lint consumes. A `replace` overwrites the
|
|
542
|
+
* entire row, so a concurrent edit to a different column on a synced table is
|
|
543
|
+
* clobbered; `ctx.db.patch(id, { field })` merges at the column level instead.
|
|
544
|
+
* Structurally identical to `AdvisorMutatorWrite` so it passes straight through
|
|
545
|
+
* to the advisor without conversion, exactly as `InsertWriteIR` does for
|
|
546
|
+
* `AdvisorInsertWrite`.
|
|
547
|
+
*/
|
|
548
|
+
interface MutatorWriteIR {
|
|
549
|
+
/** The mutator export whose `server` impl performs the replace, e.g. `renameChannel`. */
|
|
550
|
+
exportName: string;
|
|
551
|
+
/** Openable source path the replace appears in — always `lunora/mutators.ts`. */
|
|
552
|
+
file: string;
|
|
553
|
+
/** 1-based line of the `replace(...)` call. */
|
|
554
|
+
line: number;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* A single cron job lifted from a `cronJobs()` builder in `lunora/crons.ts`.
|
|
558
|
+
* Mirrors `@lunora/scheduler`'s `CronJob`: {@link CronJobIR.cron} is the compiled
|
|
559
|
+
* standard cron expression, {@link CronJobIR.functionPath} is the target
|
|
560
|
+
* `__lunoraRef` (`namespace:fn`), and {@link CronJobIR.args} is the static
|
|
561
|
+
* argument object passed at registration.
|
|
562
|
+
*/
|
|
188
563
|
interface CronJobIR {
|
|
189
564
|
/** Static args object (source-text JSON), defaults to `{}`. */
|
|
190
565
|
args: Record<string, unknown>;
|
|
@@ -195,25 +570,25 @@ interface CronJobIR {
|
|
|
195
570
|
/** Unique, human-readable job name. */
|
|
196
571
|
name: string;
|
|
197
572
|
/**
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
573
|
+
* Set when the job targets a durable workflow (a `lunora/workflows.ts`
|
|
574
|
+
* export) instead of a function: the workflow's `WORKFLOW_*` binding name
|
|
575
|
+
* plus its export name. On each fire the worker starts a new workflow
|
|
576
|
+
* INSTANCE (the {@link CronJobIR.args} become its `params`) rather than
|
|
577
|
+
* dispatching a one-shot function.
|
|
578
|
+
*/
|
|
204
579
|
workflow?: {
|
|
205
580
|
binding: string;
|
|
206
581
|
exportName: string;
|
|
207
582
|
};
|
|
208
583
|
}
|
|
209
584
|
/**
|
|
210
|
-
* A container lifted from a `defineContainer()` export in
|
|
211
|
-
* `lunora/containers.ts`. Carries everything the emitters and the config layer
|
|
212
|
-
* need to wire wrangler (`containers[]` + the Durable Object binding +
|
|
213
|
-
* migration class) and the generated `_generated/containers.ts` DO class.
|
|
214
|
-
* Names are derived via `@lunora/container`'s shared helpers so codegen and
|
|
215
|
-
* the config layer can never disagree.
|
|
216
|
-
*/
|
|
585
|
+
* A container lifted from a `defineContainer()` export in
|
|
586
|
+
* `lunora/containers.ts`. Carries everything the emitters and the config layer
|
|
587
|
+
* need to wire wrangler (`containers[]` + the Durable Object binding +
|
|
588
|
+
* migration class) and the generated `_generated/containers.ts` DO class.
|
|
589
|
+
* Names are derived via `@lunora/container`'s shared helpers so codegen and
|
|
590
|
+
* the config layer can never disagree.
|
|
591
|
+
*/
|
|
217
592
|
interface ContainerIR {
|
|
218
593
|
/** Durable Object binding name, e.g. `CONTAINER_TRANSCODER`. */
|
|
219
594
|
bindingName: string;
|
|
@@ -222,18 +597,18 @@ interface ContainerIR {
|
|
|
222
597
|
/** Generated DO class name, e.g. `TranscoderContainer`. */
|
|
223
598
|
className: string;
|
|
224
599
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
600
|
+
* Whether the container may open outbound internet connections, when the
|
|
601
|
+
* value was a static literal. `undefined` means the field was omitted (the
|
|
602
|
+
* platform default is `true`) or wasn't a literal. Lifted for the advisor.
|
|
603
|
+
*/
|
|
229
604
|
enableInternet?: boolean;
|
|
230
605
|
/** The `lunora/containers.ts` export name, e.g. `transcoder`. */
|
|
231
606
|
exportName: string;
|
|
232
607
|
/**
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
608
|
+
* Normalized image source: a local Dockerfile (`dockerfile`), a pre-built
|
|
609
|
+
* registry reference (`registry`), or a Railpack source directory (`build`)
|
|
610
|
+
* that the deploy step builds and pushes before wrangler runs.
|
|
611
|
+
*/
|
|
237
612
|
image: {
|
|
238
613
|
buildContext: string;
|
|
239
614
|
dockerfilePath: string;
|
|
@@ -261,20 +636,20 @@ interface ContainerIR {
|
|
|
261
636
|
stepPercentage?: number;
|
|
262
637
|
};
|
|
263
638
|
/**
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
639
|
+
* The static `sleepAfter` value, when it was a literal. `undefined` means
|
|
640
|
+
* omitted (platform default `"10m"`) or non-literal. Lifted for the advisor.
|
|
641
|
+
*/
|
|
267
642
|
sleepAfter?: number | string;
|
|
268
643
|
}
|
|
269
644
|
/**
|
|
270
|
-
* A workflow lifted from a `defineWorkflow()` export in `lunora/workflows.ts`.
|
|
271
|
-
* Carries what the emitters and the config layer need to wire the wrangler
|
|
272
|
-
* `workflows[]` entry and the generated `_generated/workflows.ts`
|
|
273
|
-
* `WorkflowEntrypoint` class. Unlike containers, workflows are NOT Durable
|
|
274
|
-
* Objects — wrangler gets only a `workflows[]` entry, never a `durable_objects`
|
|
275
|
-
* binding or a migration class. Names are derived via `@lunora/workflow`'s
|
|
276
|
-
* shared helpers so codegen and the config layer can never disagree.
|
|
277
|
-
*/
|
|
645
|
+
* A workflow lifted from a `defineWorkflow()` export in `lunora/workflows.ts`.
|
|
646
|
+
* Carries what the emitters and the config layer need to wire the wrangler
|
|
647
|
+
* `workflows[]` entry and the generated `_generated/workflows.ts`
|
|
648
|
+
* `WorkflowEntrypoint` class. Unlike containers, workflows are NOT Durable
|
|
649
|
+
* Objects — wrangler gets only a `workflows[]` entry, never a `durable_objects`
|
|
650
|
+
* binding or a migration class. Names are derived via `@lunora/workflow`'s
|
|
651
|
+
* shared helpers so codegen and the config layer can never disagree.
|
|
652
|
+
*/
|
|
278
653
|
interface WorkflowIR {
|
|
279
654
|
/** The Cloudflare `Workflow` binding name, e.g. `WORKFLOW_ORDER_PIPELINE`. */
|
|
280
655
|
bindingName: string;
|
|
@@ -283,25 +658,156 @@ interface WorkflowIR {
|
|
|
283
658
|
/** The `lunora/workflows.ts` export name, e.g. `orderPipeline`. */
|
|
284
659
|
exportName: string;
|
|
285
660
|
/**
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
661
|
+
* The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
|
|
662
|
+
* name (`orderPipeline` → `order-pipeline`); a static `name:` literal in the
|
|
663
|
+
* definition overrides it.
|
|
664
|
+
*/
|
|
665
|
+
name: string;
|
|
666
|
+
/**
|
|
667
|
+
* Durable step labels lifted from the handler body — the first string-literal
|
|
668
|
+
* argument of every `ctx.step.do` / `.sleep` / `.sleepUntil` / `.waitForEvent`
|
|
669
|
+
* call. Feeds the duplicate-step-name lint, which flags a name used twice
|
|
670
|
+
* (Cloudflare memoizes by name, so the second call silently returns the
|
|
671
|
+
* first's cached result). Calls with a non-literal name are omitted (not
|
|
672
|
+
* statically comparable).
|
|
673
|
+
*/
|
|
674
|
+
steps: ReadonlyArray<WorkflowStepIR>;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* An agent lifted from a `defineAgent()` export in `lunora/agents.ts`. A
|
|
678
|
+
* `defineAgent` compiles its durable tool-loop onto a Cloudflare Workflow, so —
|
|
679
|
+
* like {@link WorkflowIR} — an agent is NOT a Durable Object: wrangler gets only
|
|
680
|
+
* a `workflows[]` entry, never a `durable_objects` binding or a migration class.
|
|
681
|
+
* Carries what the emitters and the config layer need to wire the generated
|
|
682
|
+
* agent `WorkflowEntrypoint` class (e.g. `SupportAgentWorkflow`), the typed
|
|
683
|
+
* per-agent `ctx.agents` producer, and the reconciled wrangler `workflows[]`
|
|
684
|
+
* entry. Names are derived via `@lunora/agent`'s shared helpers so codegen and
|
|
685
|
+
* the config layer can never disagree.
|
|
686
|
+
*/
|
|
687
|
+
interface AgentIR {
|
|
688
|
+
/** The Cloudflare `Workflow` binding name, e.g. `AGENT_SUPPORT`. */
|
|
689
|
+
bindingName: string;
|
|
690
|
+
/** Generated `WorkflowEntrypoint` class name, e.g. `SupportAgentWorkflow`. */
|
|
691
|
+
className: string;
|
|
692
|
+
/** The `lunora/agents.ts` export name, e.g. `support`. */
|
|
693
|
+
exportName: string;
|
|
694
|
+
/**
|
|
695
|
+
* The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
|
|
696
|
+
* name (`support` → `agent-support`); a static `name:` literal in the
|
|
697
|
+
* definition overrides it.
|
|
698
|
+
*/
|
|
699
|
+
name: string;
|
|
700
|
+
/**
|
|
701
|
+
* Whether the definition declares an `onEmail` mapper on
|
|
702
|
+
* `defineAgent({ onEmail: … })`. When `true` the emitter wires this agent
|
|
703
|
+
* onto the worker's top-level `email()` handler (via `@lunora/agent/inbound`)
|
|
704
|
+
* so inbound mail starts a durable run. Detected by AST PRESENCE — the
|
|
705
|
+
* closure is never evaluated — and written to IR only when present, so
|
|
706
|
+
* email-free agents (and agent-free projects) stay byte-identical.
|
|
707
|
+
*/
|
|
708
|
+
onEmail?: boolean;
|
|
709
|
+
/**
|
|
710
|
+
* Whether the definition opted into public run-starts via
|
|
711
|
+
* `defineAgent({ publicRun: true })` — emitted into the `ctx.agents` wiring
|
|
712
|
+
* spec so the public `agents:agentRun` mutation can gate on it fail-closed.
|
|
713
|
+
* Absent (falsy) means server-side starts only; the field is written to IR
|
|
714
|
+
* only when the literal is `true`, so agent-free and non-opted-in output is
|
|
715
|
+
* byte-identical.
|
|
716
|
+
*/
|
|
717
|
+
publicRun?: boolean;
|
|
718
|
+
/**
|
|
719
|
+
* Whether the definition opted into a real-time voice session via a `voice`
|
|
720
|
+
* block on `defineAgent({ voice: … })`. Unlike the durable loop (a Workflow),
|
|
721
|
+
* the voice path IS a Durable Object — so when this is `true` the emitter
|
|
722
|
+
* generates the `voiceClassName` `VoiceSessionDO` subclass and the
|
|
723
|
+
* `api.agents.{name}Voice` client reference, and the config layer reconciles
|
|
724
|
+
* a `durable_objects` binding (`voiceBindingName`) + `new_sqlite_classes`
|
|
725
|
+
* migration. Written to IR only when the literal is present, so voice-free
|
|
726
|
+
* agents (and agent-free projects) stay byte-identical.
|
|
727
|
+
*/
|
|
728
|
+
voice?: boolean;
|
|
729
|
+
/** The voice DO's Cloudflare `DurableObjectNamespace` binding name, e.g. `VOICE_SUPPORT`. Present only when `voice`. */
|
|
730
|
+
voiceBindingName?: string;
|
|
731
|
+
/** Generated `VoiceSessionDO` subclass name, e.g. `SupportVoiceDO`. Present only when `voice`. */
|
|
732
|
+
voiceClassName?: string;
|
|
733
|
+
}
|
|
734
|
+
/** One durable step call lifted from a workflow handler body (the use side of {@link WorkflowIR.steps}). */
|
|
735
|
+
interface WorkflowStepIR {
|
|
736
|
+
/** 1-based line of the durable step call. */
|
|
737
|
+
line: number;
|
|
738
|
+
/** The native step method invoked: `do` / `sleep` / `sleepUntil` / `waitForEvent`. */
|
|
739
|
+
method: string;
|
|
740
|
+
/** The step's static label (the first string-literal argument). */
|
|
741
|
+
name: string;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* A queue lifted from a `defineQueue()` export in `lunora/queues.ts`. Carries
|
|
745
|
+
* what the emitters and the config layer need to wire the typed `ctx.queues`
|
|
746
|
+
* producer, the generated worker `queue()` dispatch, and the wrangler
|
|
747
|
+
* `queues.producers[]` / `queues.consumers[]` entries. Like workflows, a queue
|
|
748
|
+
* is NOT a Durable Object — wrangler gets only `queues.*` entries. Names are
|
|
749
|
+
* derived via `@lunora/queue`'s shared helpers so codegen and the config layer
|
|
750
|
+
* can never disagree.
|
|
751
|
+
*/
|
|
752
|
+
interface QueueIR {
|
|
753
|
+
/** The Cloudflare `Queue` producer binding name, e.g. `QUEUE_EMAIL`. */
|
|
754
|
+
bindingName: string;
|
|
755
|
+
/** The `lunora/queues.ts` export name, e.g. `emailQueue`. */
|
|
756
|
+
exportName: string;
|
|
757
|
+
/** How the queue is consumed: `"push"` (a worker `queue()` handler) or `"pull"` (external HTTP). */
|
|
758
|
+
mode: "pull" | "push";
|
|
759
|
+
/**
|
|
760
|
+
* The stable wrangler queue name (`queues.producers[].queue`). Defaults to
|
|
761
|
+
* the kebab-cased export name (`emailQueue` → `email-queue`); a static
|
|
762
|
+
* `name:` literal in the definition overrides it.
|
|
763
|
+
*/
|
|
290
764
|
name: string;
|
|
765
|
+
/** Push-consumer batch/retry tuning, mirrored onto the wrangler `queues.consumers[]` entry. */
|
|
766
|
+
tuning: {
|
|
767
|
+
deadLetterQueue?: string;
|
|
768
|
+
maxBatchSize?: number;
|
|
769
|
+
maxBatchTimeout?: number;
|
|
770
|
+
maxRetries?: number;
|
|
771
|
+
retryDelay?: number;
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* The feature-flag provider declared by the default export of `lunora/flags.ts`
|
|
776
|
+
* (`defineFlags({ provider, … })`). Discovery is **metadata-only** — codegen
|
|
777
|
+
* imports the real module at runtime for the provider value; this IR exists so
|
|
778
|
+
* the config layer can reconcile/validate the wrangler `flagship` binding when
|
|
779
|
+
* the app uses Flagship in binding mode. A `custom` provider (any other
|
|
780
|
+
* OpenFeature factory) carries no binding to reconcile.
|
|
781
|
+
*/
|
|
782
|
+
interface FlagsIR {
|
|
783
|
+
/**
|
|
784
|
+
* The wrangler `flagship[].binding` name — set **only** for a flagship
|
|
785
|
+
* `provider` in binding mode (`flagshipProvider({ binding: "FLAGS" })`). The
|
|
786
|
+
* config layer hints/validates a matching `flagship` binding from this.
|
|
787
|
+
*/
|
|
788
|
+
bindingName?: string;
|
|
789
|
+
/**
|
|
790
|
+
* Flagship operating mode — `"binding"` (wrangler binding, needs a
|
|
791
|
+
* `flagship` entry) or `"http"` (no binding); `undefined` for a `custom`
|
|
792
|
+
* provider or when the mode can't be read statically.
|
|
793
|
+
*/
|
|
794
|
+
mode?: "binding" | "http";
|
|
795
|
+
/** `"flagship"` when the provider is `flagshipProvider(...)`, else `"custom"` (any other OpenFeature provider factory). */
|
|
796
|
+
provider: "custom" | "flagship";
|
|
291
797
|
}
|
|
292
798
|
/**
|
|
293
|
-
* A `ctx.workflows.get("name")…` call discovered in a function body — the
|
|
294
|
-
* use-site analog of {@link WorkflowIR} (which is the declaration side). Feeds
|
|
295
|
-
* the `workflow_unused` lint (a declared workflow with zero call sites) and the
|
|
296
|
-
* `workflow_unknown_target` lint (a `.get("x")` whose `x` isn't declared — a
|
|
297
|
-
* typo catcher). {@link WorkflowCallIR.workflow} is `""` when the `get(...)`
|
|
298
|
-
* argument is not a string literal (a dynamic name — which suppresses the
|
|
299
|
-
* unused-workflow heuristic rather than producing a false positive).
|
|
300
|
-
*/
|
|
799
|
+
* A `ctx.workflows.get("name")…` call discovered in a function body — the
|
|
800
|
+
* use-site analog of {@link WorkflowIR} (which is the declaration side). Feeds
|
|
801
|
+
* the `workflow_unused` lint (a declared workflow with zero call sites) and the
|
|
802
|
+
* `workflow_unknown_target` lint (a `.get("x")` whose `x` isn't declared — a
|
|
803
|
+
* typo catcher). {@link WorkflowCallIR.workflow} is `""` when the `get(...)`
|
|
804
|
+
* argument is not a string literal (a dynamic name — which suppresses the
|
|
805
|
+
* unused-workflow heuristic rather than producing a false positive).
|
|
806
|
+
*/
|
|
301
807
|
interface WorkflowCallIR {
|
|
302
808
|
/** Export binding name of the function performing the call, e.g. `create`. */
|
|
303
809
|
exportName: string;
|
|
304
|
-
/** Source file relative to
|
|
810
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension (the api namespace). */
|
|
305
811
|
file: string;
|
|
306
812
|
/** 1-based line of the `get(...)` call. */
|
|
307
813
|
line: number;
|
|
@@ -309,14 +815,23 @@ interface WorkflowCallIR {
|
|
|
309
815
|
workflow: string;
|
|
310
816
|
}
|
|
311
817
|
/**
|
|
312
|
-
* A `ctx.db.query("table")…` read discovered in a function body, reduced to what
|
|
313
|
-
* the `filter_without_index` advisor lint needs: which table, whether the chain
|
|
314
|
-
* narrows with an index, and whether it filters. `table` is `""` when the
|
|
315
|
-
* `query(...)` argument is not a string literal (a dynamic table — not lintable).
|
|
316
|
-
*/
|
|
818
|
+
* A `ctx.db.query("table")…` read discovered in a function body, reduced to what
|
|
819
|
+
* the `filter_without_index` advisor lint needs: which table, whether the chain
|
|
820
|
+
* narrows with an index, and whether it filters. `table` is `""` when the
|
|
821
|
+
* `query(...)` argument is not a string literal (a dynamic table — not lintable).
|
|
822
|
+
*/
|
|
317
823
|
interface QueryReadIR {
|
|
318
|
-
/**
|
|
824
|
+
/** Exported procedure the read sits in, or `""` at module scope. */
|
|
825
|
+
exportName: string;
|
|
826
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
319
827
|
file: string;
|
|
828
|
+
/**
|
|
829
|
+
* True when the chain's `.filter()` predicate compares `_id`
|
|
830
|
+
* (`(d) => d._id === args.id`) — a full scan for a row that `ctx.db.get`
|
|
831
|
+
* addresses directly. Optional so a feeder predating this field still
|
|
832
|
+
* typechecks; absent is treated as "not a primary-key filter".
|
|
833
|
+
*/
|
|
834
|
+
filtersPrimaryKey?: boolean;
|
|
320
835
|
/** The chain calls `.filter(...)`. */
|
|
321
836
|
hasFilter: boolean;
|
|
322
837
|
/** The chain narrows with `.withIndex(...)` or `.withSearchIndex(...)`. */
|
|
@@ -327,16 +842,16 @@ interface QueryReadIR {
|
|
|
327
842
|
table: string;
|
|
328
843
|
}
|
|
329
844
|
/**
|
|
330
|
-
* A `ctx.authApi
|
|
331
|
-
* to the exported function (and its file = api namespace) that performs it.
|
|
332
|
-
* Structurally identical to `AdvisorAuthApiCall` so it passes straight through
|
|
333
|
-
* to the advisor lint without conversion, exactly as `InsertWriteIR` does for
|
|
334
|
-
* `AdvisorInsertWrite`.
|
|
335
|
-
*/
|
|
845
|
+
* A `ctx.authApi.<method>(...)` call discovered in a function body, attributed
|
|
846
|
+
* to the exported function (and its file = api namespace) that performs it.
|
|
847
|
+
* Structurally identical to `AdvisorAuthApiCall` so it passes straight through
|
|
848
|
+
* to the advisor lint without conversion, exactly as `InsertWriteIR` does for
|
|
849
|
+
* `AdvisorInsertWrite`.
|
|
850
|
+
*/
|
|
336
851
|
interface AuthApiCallIR {
|
|
337
852
|
/** Export binding name of the function performing the call, e.g. "createOrg". */
|
|
338
853
|
exportName: string;
|
|
339
|
-
/** Source file relative to
|
|
854
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
340
855
|
file: string;
|
|
341
856
|
/** True when the call's argument object includes a `headers` property. */
|
|
342
857
|
hasHeaders: boolean;
|
|
@@ -346,16 +861,16 @@ interface AuthApiCallIR {
|
|
|
346
861
|
method: string;
|
|
347
862
|
}
|
|
348
863
|
/**
|
|
349
|
-
* A `ctx.db.insert("table", …)` write discovered in a function body, attributed
|
|
350
|
-
* to the exported function (and its file = api namespace) that performs it — the
|
|
351
|
-
* write-side analog of {@link QueryReadIR}. Lets tooling wire a table's write
|
|
352
|
-
* action by behavior (which function inserts into it) rather than by naming.
|
|
353
|
-
* {@link InsertWriteIR.table} is `""` when the argument is not a string literal.
|
|
354
|
-
*/
|
|
864
|
+
* A `ctx.db.insert("table", …)` write discovered in a function body, attributed
|
|
865
|
+
* to the exported function (and its file = api namespace) that performs it — the
|
|
866
|
+
* write-side analog of {@link QueryReadIR}. Lets tooling wire a table's write
|
|
867
|
+
* action by behavior (which function inserts into it) rather than by naming.
|
|
868
|
+
* {@link InsertWriteIR.table} is `""` when the argument is not a string literal.
|
|
869
|
+
*/
|
|
355
870
|
interface InsertWriteIR {
|
|
356
871
|
/** Export binding name of the function performing the insert, e.g. "send". */
|
|
357
872
|
exportName: string;
|
|
358
|
-
/** Source file relative to
|
|
873
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension (the api namespace). */
|
|
359
874
|
file: string;
|
|
360
875
|
/** 1-based line of the `insert(...)` call. */
|
|
361
876
|
line: number;
|
|
@@ -363,20 +878,20 @@ interface InsertWriteIR {
|
|
|
363
878
|
table: string;
|
|
364
879
|
}
|
|
365
880
|
/**
|
|
366
|
-
* A non-deterministic API call (`Date.now`, `Math.random`, `crypto.randomUUID`,
|
|
367
|
-
* `crypto.getRandomValues`, `fetch`) discovered lexically inside a `query(...)`
|
|
368
|
-
* or `mutation(...)` handler body — the `nondeterministic_query_mutation` lint
|
|
369
|
-
* input. Structurally identical to `AdvisorNondeterministicCall` so values pass
|
|
370
|
-
* straight through to the advisor without conversion, exactly as `AuthApiCallIR`
|
|
371
|
-
* does for `AdvisorAuthApiCall`. `action(...)` handlers are never recorded —
|
|
372
|
-
* actions are the determinism escape hatch.
|
|
373
|
-
*/
|
|
881
|
+
* A non-deterministic API call (`Date.now`, `Math.random`, `crypto.randomUUID`,
|
|
882
|
+
* `crypto.getRandomValues`, `fetch`) discovered lexically inside a `query(...)`
|
|
883
|
+
* or `mutation(...)` handler body — the `nondeterministic_query_mutation` lint
|
|
884
|
+
* input. Structurally identical to `AdvisorNondeterministicCall` so values pass
|
|
885
|
+
* straight through to the advisor without conversion, exactly as `AuthApiCallIR`
|
|
886
|
+
* does for `AdvisorAuthApiCall`. `action(...)` handlers are never recorded —
|
|
887
|
+
* actions are the determinism escape hatch.
|
|
888
|
+
*/
|
|
374
889
|
interface NondeterministicCallIR {
|
|
375
890
|
/** The non-deterministic API invoked, e.g. `Date.now` / `Math.random` / `crypto.randomUUID` / `fetch`. */
|
|
376
891
|
callee: string;
|
|
377
892
|
/** Export binding name of the function performing the call, e.g. `sendMessage`. */
|
|
378
893
|
exportName: string;
|
|
379
|
-
/** Source file relative to
|
|
894
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension (the api namespace). */
|
|
380
895
|
file: string;
|
|
381
896
|
/** Which procedure kind the call lives in — only `query`/`mutation` handlers are recorded. */
|
|
382
897
|
kind: "mutation" | "query";
|
|
@@ -384,21 +899,41 @@ interface NondeterministicCallIR {
|
|
|
384
899
|
line: number;
|
|
385
900
|
}
|
|
386
901
|
/**
|
|
387
|
-
*
|
|
388
|
-
* `
|
|
389
|
-
* `
|
|
390
|
-
*
|
|
391
|
-
* `
|
|
392
|
-
|
|
902
|
+
* One `ctx.r2sql` access lexically inside a `query`/`mutation` handler — the
|
|
903
|
+
* `r2sql_outside_action` advisor lint input. Structurally identical to the
|
|
904
|
+
* advisor's `AdvisorR2sqlCall` (same field set) so values pass straight through
|
|
905
|
+
* `lintSchema` without conversion, exactly as `NondeterministicCallIR` does.
|
|
906
|
+
* Only `query`/`mutation` handlers are recorded; `action(...)` is the intended
|
|
907
|
+
* home for `ctx.r2sql` and is skipped.
|
|
908
|
+
*/
|
|
909
|
+
interface R2sqlCallIR {
|
|
910
|
+
/** The accessed `ctx.r2sql` surface, e.g. `ctx.r2sql.query` / `ctx.r2sql.from`. */
|
|
911
|
+
callee: string;
|
|
912
|
+
/** Export binding name of the function performing the access. */
|
|
913
|
+
exportName: string;
|
|
914
|
+
/** Source file relative to the lunora dir, without extension (the api namespace). */
|
|
915
|
+
file: string;
|
|
916
|
+
/** Which procedure kind the access lives in — only `query`/`mutation` handlers are recorded. */
|
|
917
|
+
kind: "mutation" | "query";
|
|
918
|
+
/** 1-based line of the access, or `0` when unknown. */
|
|
919
|
+
line: number;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Per-procedure RLS usage snapshot, produced by `discoverRlsProcedures` for the
|
|
923
|
+
* `rls_uncovered_table` advisor lint. Structurally identical to
|
|
924
|
+
* `AdvisorRlsProcedure` (they share the same field set) so values pass straight
|
|
925
|
+
* through to the advisor without conversion, exactly as `AuthApiCallIR` does for
|
|
926
|
+
* `AdvisorAuthApiCall`.
|
|
927
|
+
*/
|
|
393
928
|
interface RlsProcedureIR {
|
|
394
929
|
/** Export binding name of the procedure (e.g. `listDocuments`). */
|
|
395
930
|
exportName: string;
|
|
396
|
-
/** Source file relative to
|
|
931
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
397
932
|
file: string;
|
|
398
933
|
/**
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
934
|
+
* Table names extracted from the `rls(policies)` array literal. Empty when the
|
|
935
|
+
* policies argument is not a statically-readable array literal.
|
|
936
|
+
*/
|
|
402
937
|
rlsTables: string[];
|
|
403
938
|
/** Tables read by the procedure via `ctx.db.query/findMany/findFirst/…`. */
|
|
404
939
|
tablesRead: string[];
|
|
@@ -410,22 +945,22 @@ interface RlsProcedureIR {
|
|
|
410
945
|
visibility: "internal" | "public";
|
|
411
946
|
}
|
|
412
947
|
/**
|
|
413
|
-
* One procedure reduced to the facts the `mask_uncovered_pii_column` lint needs:
|
|
414
|
-
* whether its builder chain includes `.use(mask(...))`, which `(table, column)`
|
|
415
|
-
* pairs that mask declares, and which tables the procedure reads/writes. The
|
|
416
|
-
* column-level analogue of {@link RlsProcedureIR}. Structurally identical to
|
|
417
|
-
* `AdvisorMaskProcedure` so values pass straight through without conversion.
|
|
418
|
-
*/
|
|
948
|
+
* One procedure reduced to the facts the `mask_uncovered_pii_column` lint needs:
|
|
949
|
+
* whether its builder chain includes `.use(mask(...))`, which `(table, column)`
|
|
950
|
+
* pairs that mask declares, and which tables the procedure reads/writes. The
|
|
951
|
+
* column-level analogue of {@link RlsProcedureIR}. Structurally identical to
|
|
952
|
+
* `AdvisorMaskProcedure` so values pass straight through without conversion.
|
|
953
|
+
*/
|
|
419
954
|
interface MaskProcedureIR {
|
|
420
955
|
/** Export binding name of the procedure (e.g. `listUsers`). */
|
|
421
956
|
exportName: string;
|
|
422
|
-
/** Source file relative to
|
|
957
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
423
958
|
file: string;
|
|
424
959
|
/**
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
960
|
+
* `(table, column)` pairs this procedure's `mask(policies)` object literal
|
|
961
|
+
* declares. Empty when the policies argument is not a statically-readable
|
|
962
|
+
* object literal (conservative: `usesMask` is still `true`).
|
|
963
|
+
*/
|
|
429
964
|
maskColumns: {
|
|
430
965
|
column: string;
|
|
431
966
|
table: string;
|
|
@@ -440,14 +975,14 @@ interface MaskProcedureIR {
|
|
|
440
975
|
visibility: "internal" | "public";
|
|
441
976
|
}
|
|
442
977
|
/**
|
|
443
|
-
* One masked column surfaced to the studio's data-browser mask preview: a
|
|
444
|
-
* `(table, column)` pair plus the declared {@link MaskProcedureIR} strategy so
|
|
445
|
-
* the preview can pick redact-vs-hash-vs-custom rendering. Aggregated across the
|
|
446
|
-
* project's `.use(mask(...))` chains by `discoverMaskMetadata`; the descriptive
|
|
447
|
-
* twin of {@link RlsPolicyIR}. `"custom"` covers any non-string strategy (a
|
|
448
|
-
* `(value, ctx) => …` function) — its logic is an opaque closure, never read by
|
|
449
|
-
* the UI; the preview renders a fixed sentinel for it.
|
|
450
|
-
*/
|
|
978
|
+
* One masked column surfaced to the studio's data-browser mask preview: a
|
|
979
|
+
* `(table, column)` pair plus the declared {@link MaskProcedureIR} strategy so
|
|
980
|
+
* the preview can pick redact-vs-hash-vs-custom rendering. Aggregated across the
|
|
981
|
+
* project's `.use(mask(...))` chains by `discoverMaskMetadata`; the descriptive
|
|
982
|
+
* twin of {@link RlsPolicyIR}. `"custom"` covers any non-string strategy (a
|
|
983
|
+
* `(value, ctx) => …` function) — its logic is an opaque closure, never read by
|
|
984
|
+
* the UI; the preview renders a fixed sentinel for it.
|
|
985
|
+
*/
|
|
451
986
|
interface MaskColumnMetadataIR {
|
|
452
987
|
/** Column the mask policy redacts. */
|
|
453
988
|
column: string;
|
|
@@ -457,24 +992,48 @@ interface MaskColumnMetadataIR {
|
|
|
457
992
|
table: string;
|
|
458
993
|
}
|
|
459
994
|
/**
|
|
460
|
-
* Schema-wide masking metadata the codegen emits into the generated ShardDO so
|
|
461
|
-
* the studio's data-browser mask toggle can preview what a non-privileged caller
|
|
462
|
-
* would see. Aggregated across every `.use(mask(...))` chain in the project —
|
|
463
|
-
* purely descriptive (table + column + strategy), never the masking closure. The
|
|
464
|
-
* column-level analogue of {@link RlsMetadataIR}.
|
|
465
|
-
*/
|
|
995
|
+
* Schema-wide masking metadata the codegen emits into the generated ShardDO so
|
|
996
|
+
* the studio's data-browser mask toggle can preview what a non-privileged caller
|
|
997
|
+
* would see. Aggregated across every `.use(mask(...))` chain in the project —
|
|
998
|
+
* purely descriptive (table + column + strategy), never the masking closure. The
|
|
999
|
+
* column-level analogue of {@link RlsMetadataIR}.
|
|
1000
|
+
*/
|
|
466
1001
|
interface MaskMetadataIR {
|
|
467
1002
|
/** Every statically-discovered masked column, deduped by `(table, column)` (first declaration wins). */
|
|
468
1003
|
columns: MaskColumnMetadataIR[];
|
|
469
1004
|
}
|
|
470
1005
|
/**
|
|
471
|
-
* One
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
* `
|
|
477
|
-
|
|
1006
|
+
* One masked column whose `mask(policies)` strategy is a statically-known
|
|
1007
|
+
* literal (`"hash"` or `"redact"`) — the `mask_weak_hash_strategy_on_pii` lint
|
|
1008
|
+
* input. Unlike {@link MaskColumnMetadataIR} (app-wide, deduped by `(table,
|
|
1009
|
+
* column)`, studio-preview evidence), this is per declaration site (file + line
|
|
1010
|
+
* + enclosing export), undeduped, so the lint can point at the exact
|
|
1011
|
+
* `mask(...)` call that applies a weak strategy. A `MaskFn` (custom, non-literal)
|
|
1012
|
+
* strategy carries no lint-relevant signal and is never recorded here.
|
|
1013
|
+
* Structurally identical to `AdvisorMaskStrategy`.
|
|
1014
|
+
*/
|
|
1015
|
+
interface MaskStrategyIR {
|
|
1016
|
+
/** Masked column name. */
|
|
1017
|
+
column: string;
|
|
1018
|
+
/** Export binding name of the procedure whose `.use(mask(...))` chain declared this column, or `"<module>"` when declared at file scope. */
|
|
1019
|
+
exportName: string;
|
|
1020
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1021
|
+
file: string;
|
|
1022
|
+
/** 1-based line of the masked column's strategy property. */
|
|
1023
|
+
line: number;
|
|
1024
|
+
/** The statically-known strategy literal: `"hash"` or `"redact"`. */
|
|
1025
|
+
strategy: string;
|
|
1026
|
+
/** Logical table the masked column belongs to. */
|
|
1027
|
+
table: string;
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* One statically-readable policy entry from an `rls([...])` array literal,
|
|
1031
|
+
* surfaced to the studio's read-only RLS inspector via the generated
|
|
1032
|
+
* `rlsPolicies()` hook. Captures the policy's `table` + `on` operation and the
|
|
1033
|
+
* procedure it guards — never the `when` predicate, which is an opaque JS
|
|
1034
|
+
* closure (its logic stays in code, not the UI). Produced by
|
|
1035
|
+
* `discoverRlsProcedures` alongside the lint IR.
|
|
1036
|
+
*/
|
|
478
1037
|
interface RlsPolicyIR {
|
|
479
1038
|
/** Source file (relative to `lunora/`, without extension) the policy is declared in. */
|
|
480
1039
|
file: string;
|
|
@@ -486,12 +1045,12 @@ interface RlsPolicyIR {
|
|
|
486
1045
|
table: string;
|
|
487
1046
|
}
|
|
488
1047
|
/**
|
|
489
|
-
* One statically-readable role entry from an `rls(policies, { roles: [...] })`
|
|
490
|
-
* call, surfaced to the studio's RLS inspector. Captures the role's `name`,
|
|
491
|
-
* optional `description`, and the names of the permissions it grants (string
|
|
492
|
-
* literals or `definePermission("name")` calls). Produced by
|
|
493
|
-
* `discoverRlsProcedures`.
|
|
494
|
-
*/
|
|
1048
|
+
* One statically-readable role entry from an `rls(policies, { roles: [...] })`
|
|
1049
|
+
* call, surfaced to the studio's RLS inspector. Captures the role's `name`,
|
|
1050
|
+
* optional `description`, and the names of the permissions it grants (string
|
|
1051
|
+
* literals or `definePermission("name")` calls). Produced by
|
|
1052
|
+
* `discoverRlsProcedures`.
|
|
1053
|
+
*/
|
|
495
1054
|
interface RlsRoleIR {
|
|
496
1055
|
/** Optional human-readable description from `defineRole(name, { description })`. */
|
|
497
1056
|
description?: string;
|
|
@@ -501,11 +1060,11 @@ interface RlsRoleIR {
|
|
|
501
1060
|
permissions: string[];
|
|
502
1061
|
}
|
|
503
1062
|
/**
|
|
504
|
-
* Schema-wide RLS metadata the codegen emits into the generated ShardDO so the
|
|
505
|
-
* studio's read-only inspector can list, per table, which policies guard it and
|
|
506
|
-
* what roles are defined. Aggregated across every `.use(rls(...))` chain in the
|
|
507
|
-
* project — purely descriptive, never the predicate logic.
|
|
508
|
-
*/
|
|
1063
|
+
* Schema-wide RLS metadata the codegen emits into the generated ShardDO so the
|
|
1064
|
+
* studio's read-only inspector can list, per table, which policies guard it and
|
|
1065
|
+
* what roles are defined. Aggregated across every `.use(rls(...))` chain in the
|
|
1066
|
+
* project — purely descriptive, never the predicate logic.
|
|
1067
|
+
*/
|
|
509
1068
|
interface RlsMetadataIR {
|
|
510
1069
|
/** Every statically-discovered policy `(table, on, procedure)` entry. */
|
|
511
1070
|
policies: RlsPolicyIR[];
|
|
@@ -524,27 +1083,36 @@ interface StorageRuleIR {
|
|
|
524
1083
|
procedure: string;
|
|
525
1084
|
}
|
|
526
1085
|
/**
|
|
527
|
-
* Schema-wide storage-access-rule metadata emitted into the generated ShardDO so
|
|
528
|
-
* the studio's read-only inspector can list, per bucket, which operations are
|
|
529
|
-
* gated and under what key prefix. Aggregated across every
|
|
530
|
-
* `.use(storageRules(...))` chain — descriptive only, never the predicate logic.
|
|
531
|
-
*/
|
|
1086
|
+
* Schema-wide storage-access-rule metadata emitted into the generated ShardDO so
|
|
1087
|
+
* the studio's read-only inspector can list, per bucket, which operations are
|
|
1088
|
+
* gated and under what key prefix. Aggregated across every
|
|
1089
|
+
* `.use(storageRules(...))` chain — descriptive only, never the predicate logic.
|
|
1090
|
+
*/
|
|
532
1091
|
interface StorageRulesMetadataIR {
|
|
533
1092
|
rules: StorageRuleIR[];
|
|
534
1093
|
}
|
|
535
1094
|
/**
|
|
536
|
-
* A typed REST route declared with the `httpRoute
|
|
537
|
-
* `@lunora/server` and mounted on `httpRouter()`. Captured statically from the
|
|
538
|
-
* builder chain so the OpenAPI emitter can render a real `paths` entry: the verb
|
|
539
|
-
* + path become the operation's method + URL, and the accumulated validator maps
|
|
540
|
-
* become its query parameters, path parameters, and request body.
|
|
541
|
-
*/
|
|
1095
|
+
* A typed REST route declared with the `httpRoute.<verb>("/path")…` builder in
|
|
1096
|
+
* `@lunora/server` and mounted on `httpRouter()`. Captured statically from the
|
|
1097
|
+
* builder chain so the OpenAPI emitter can render a real `paths` entry: the verb
|
|
1098
|
+
* + path become the operation's method + URL, and the accumulated validator maps
|
|
1099
|
+
* become its query parameters, path parameters, and request body.
|
|
1100
|
+
*/
|
|
542
1101
|
interface HttpRouteIR {
|
|
543
1102
|
/** `v.*` validators decoding the JSON request body (`.body({...})`), keyed by field. */
|
|
544
1103
|
body: Record<string, ValidatorIR>;
|
|
1104
|
+
/**
|
|
1105
|
+
* Rendered TS type of one SSE chunk — the `R` the `.stream(handler)`
|
|
1106
|
+
* handler yields — inferred from the handler via the type checker. Present
|
|
1107
|
+
* only when {@link HttpRouteIR.stream} is `true`; `"unknown"` when the
|
|
1108
|
+
* checker can't resolve enough context. Feeds the emitted
|
|
1109
|
+
* `HttpStreamRef<Chunk, …>` so the chunk type flows to the client.
|
|
1110
|
+
* @experimental Part of the HTTP-SSE stream surface (the `httpStreams.*` emission).
|
|
1111
|
+
*/
|
|
1112
|
+
chunkType?: string;
|
|
545
1113
|
/** Export binding name of the route handler (used only for diagnostics / dedupe). */
|
|
546
1114
|
exportName: string;
|
|
547
|
-
/** Path relative to
|
|
1115
|
+
/** Path relative to `<projectRoot>/lunora/` without extension, e.g. "http". */
|
|
548
1116
|
filePath: string;
|
|
549
1117
|
/** HTTP verb the route binds to (uppercased), e.g. `"GET"`. */
|
|
550
1118
|
method: string;
|
|
@@ -552,7 +1120,7 @@ interface HttpRouteIR {
|
|
|
552
1120
|
output?: ValidatorIR;
|
|
553
1121
|
/** `v.*` validators decoding the hono path params (`.params({...})`), keyed by `:name`. */
|
|
554
1122
|
params: Record<string, ValidatorIR>;
|
|
555
|
-
/** The route path passed to `httpRoute
|
|
1123
|
+
/** The route path passed to `httpRoute.<verb>(path)`, e.g. `/api/todos/:id`. */
|
|
556
1124
|
path: string;
|
|
557
1125
|
/** `v.*` validators decoding the URL query string (`.searchParams({...})`), keyed by name. */
|
|
558
1126
|
searchParams: Record<string, ValidatorIR>;
|
|
@@ -560,28 +1128,69 @@ interface HttpRouteIR {
|
|
|
560
1128
|
stream: boolean;
|
|
561
1129
|
}
|
|
562
1130
|
/**
|
|
563
|
-
* Per-procedure protective-middleware snapshot, produced by
|
|
564
|
-
* `discoverProcedureMiddleware` for the security lints
|
|
565
|
-
* (`public_mutation_without_ratelimit`, `user_creating_mutation_without_captcha`).
|
|
566
|
-
* Records which `.use(...)` guards a procedure's builder chain carries plus the
|
|
567
|
-
* behavioural facts that decide whether a guard is *expected* (does it write a
|
|
568
|
-
* user/session table, does it send mail). `protectPublic({ rateLimit, captcha })`
|
|
569
|
-
* is unwrapped: the bundle's object-literal keys set `usesRateLimit`/`usesCaptcha`
|
|
570
|
-
* exactly as the individual `.use(rateLimit(...))` / `.use(verifyTurnstile(...))`
|
|
571
|
-
* steps would. Structurally identical to `AdvisorProcedureProtection` so values
|
|
572
|
-
* pass straight through to the advisor without conversion.
|
|
573
|
-
*/
|
|
1131
|
+
* Per-procedure protective-middleware snapshot, produced by
|
|
1132
|
+
* `discoverProcedureMiddleware` for the security lints
|
|
1133
|
+
* (`public_mutation_without_ratelimit`, `user_creating_mutation_without_captcha`).
|
|
1134
|
+
* Records which `.use(...)` guards a procedure's builder chain carries plus the
|
|
1135
|
+
* behavioural facts that decide whether a guard is *expected* (does it write a
|
|
1136
|
+
* user/session table, does it send mail). `protectPublic({ rateLimit, captcha })`
|
|
1137
|
+
* is unwrapped: the bundle's object-literal keys set `usesRateLimit`/`usesCaptcha`
|
|
1138
|
+
* exactly as the individual `.use(rateLimit(...))` / `.use(verifyTurnstile(...))`
|
|
1139
|
+
* steps would. Structurally identical to `AdvisorProcedureProtection` so values
|
|
1140
|
+
* pass straight through to the advisor without conversion.
|
|
1141
|
+
*/
|
|
574
1142
|
interface ProcedureMiddlewareIR {
|
|
575
|
-
/**
|
|
576
|
-
|
|
1143
|
+
/**
|
|
1144
|
+
* `true` when the handler body could be read statically — an inline function
|
|
1145
|
+
* expression/arrow, or a same-file identifier resolved to one. `false` for a
|
|
1146
|
+
* genuinely cross-file handler (an imported function, or an identifier that
|
|
1147
|
+
* doesn't resolve in this file), in which case every behavioural fact below
|
|
1148
|
+
* is `undefined` rather than a false "not observed" — the feeder never saw
|
|
1149
|
+
* the body, so it has nothing to report.
|
|
1150
|
+
*/
|
|
1151
|
+
analyzableBody: boolean;
|
|
1152
|
+
/** `true` when the handler (or a helper inside it) references `ctx.mail` / `ctx.email`. `undefined` when `analyzableBody` is `false`. */
|
|
1153
|
+
callsMail?: boolean;
|
|
1154
|
+
/** `true` when the handler emits a structured observability event (`ctx.log` / `ctx.span` / `ctx.trace`). */
|
|
1155
|
+
emitsEvent?: boolean;
|
|
1156
|
+
/** `true` when a `// lunora-advisor-exempt` directive sits above the export. */
|
|
1157
|
+
exempt: boolean;
|
|
1158
|
+
/** The `-- reason` from that directive, or `""`. */
|
|
1159
|
+
exemptReason: string;
|
|
577
1160
|
/** Export binding name of the procedure (e.g. `signUp`). */
|
|
578
1161
|
exportName: string;
|
|
579
|
-
/**
|
|
1162
|
+
/** `true` when the handler fans work out to a privileged, cost-bearing dispatch surface (scheduler `runAfter`/`runAt`, a queue producer send, or a workflow create). Feeds the privileged-fanout lint. `undefined` when `analyzableBody` is `false`. */
|
|
1163
|
+
fanOut?: boolean;
|
|
1164
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
580
1165
|
file: string;
|
|
581
|
-
/**
|
|
1166
|
+
/** `true` when the handler wraps work in `try`/`catch`. */
|
|
1167
|
+
handlesErrors?: boolean;
|
|
1168
|
+
/**
|
|
1169
|
+
* `true` when the procedure declares an email-shaped argument (`email`,
|
|
1170
|
+
* `emailAddress`, `userEmail`, …), `false` when it provably declares none,
|
|
1171
|
+
* and **absent** when the argument list can't be read statically (a
|
|
1172
|
+
* `.input(sharedSchema)`, a spread, or a factory whose `args` comes from a
|
|
1173
|
+
* variable). Feeds `signup_mutation_without_disposable_gating`, which can
|
|
1174
|
+
* only be actioned when there is an address to gate — so "unreadable" must
|
|
1175
|
+
* stay distinguishable from "none", or the lint would clear itself on a
|
|
1176
|
+
* registration that may well expose one.
|
|
1177
|
+
*/
|
|
1178
|
+
hasEmailArg?: boolean;
|
|
582
1179
|
kind: "action" | "mutation" | "query";
|
|
1180
|
+
/** `true` when the handler reaches an outbound surface (`ctx.fetch`, mail, queues, storage, sql, ai, …) that can fail. */
|
|
1181
|
+
reachesOutbound?: boolean;
|
|
1182
|
+
/** `true` when the handler runs any AI generation, bounded or not. */
|
|
1183
|
+
runsAiGeneration?: boolean;
|
|
1184
|
+
/** `true` when the handler throws a bare `new Error(...)` rather than a coded `LunoraError`. */
|
|
1185
|
+
throwsBareError?: boolean;
|
|
1186
|
+
/** `true` when the handler runs an AI generation (`generateText`/`streamText`/`generateObject`/`streamObject`) with no `maxOutputTokens` bound in its config literal. Feeds the `ai_unbounded_generation_public` lint. `undefined` when `analyzableBody` is `false`. */
|
|
1187
|
+
unboundedAiGeneration?: boolean;
|
|
583
1188
|
/** `true` when the chain carries `.use(verifyTurnstile(...))` or a `protectPublic({ captcha })` bundle. */
|
|
584
1189
|
usesCaptcha: boolean;
|
|
1190
|
+
/** `true` when the chain carries `.use(emailGateMiddleware(...))` (`@lunora/auth`). Feeds the `signup_mutation_without_disposable_gating` lint. */
|
|
1191
|
+
usesEmailGate: boolean;
|
|
1192
|
+
/** `true` when the handler calls `ctx.db.insertManyUnsafe(...)`, bypassing validators and triggers. Feeds the `insert_many_unsafe_user_data` lint. `undefined` when `analyzableBody` is `false`. */
|
|
1193
|
+
usesInsertManyUnsafe?: boolean;
|
|
585
1194
|
/** `true` when the chain carries `.use(mask(...))`. */
|
|
586
1195
|
usesMask: boolean;
|
|
587
1196
|
/** `true` when the chain carries `.use(rateLimit(...))` or a `protectPublic({ rateLimit })` bundle. */
|
|
@@ -590,23 +1199,23 @@ interface ProcedureMiddlewareIR {
|
|
|
590
1199
|
usesRls: boolean;
|
|
591
1200
|
/** `"internal"` for `internalQuery` / `internalMutation` / `internalAction`. */
|
|
592
1201
|
visibility: "internal" | "public";
|
|
593
|
-
/** `true` when the handler inserts into a user/session/account-shaped table. */
|
|
594
|
-
writesUserTable
|
|
1202
|
+
/** `true` when the handler inserts into a user/session/account-shaped table. `undefined` when `analyzableBody` is `false`. */
|
|
1203
|
+
writesUserTable?: boolean;
|
|
595
1204
|
}
|
|
596
1205
|
/**
|
|
597
|
-
* Per-procedure argument-validator snapshot, produced by the
|
|
598
|
-
* argument-validator discoverer for the input-hardening lints
|
|
599
|
-
* (`public_arg_uses_any`, `unbounded_string_arg`). Only public procedures are
|
|
600
|
-
* recorded — internal functions take server-trusted input. Structurally identical
|
|
601
|
-
* to `AdvisorArgumentValidator` so it passes straight through to the advisor
|
|
602
|
-
* without conversion.
|
|
603
|
-
*/
|
|
1206
|
+
* Per-procedure argument-validator snapshot, produced by the
|
|
1207
|
+
* argument-validator discoverer for the input-hardening lints
|
|
1208
|
+
* (`public_arg_uses_any`, `unbounded_string_arg`). Only public procedures are
|
|
1209
|
+
* recorded — internal functions take server-trusted input. Structurally identical
|
|
1210
|
+
* to `AdvisorArgumentValidator` so it passes straight through to the advisor
|
|
1211
|
+
* without conversion.
|
|
1212
|
+
*/
|
|
604
1213
|
interface ArgumentValidatorIR {
|
|
605
1214
|
/** Arg names declared as `v.any()` (unvalidated, untyped input). */
|
|
606
1215
|
anyArgs: string[];
|
|
607
1216
|
/** Export binding name of the procedure (e.g. `updateProfile`). */
|
|
608
1217
|
exportName: string;
|
|
609
|
-
/** Source file relative to
|
|
1218
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
610
1219
|
file: string;
|
|
611
1220
|
/** 1-based line of the registration call, or `0` when unknown. */
|
|
612
1221
|
line: number;
|
|
@@ -614,13 +1223,34 @@ interface ArgumentValidatorIR {
|
|
|
614
1223
|
unboundedStringArgs: string[];
|
|
615
1224
|
}
|
|
616
1225
|
/**
|
|
617
|
-
* One
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* Structurally identical to `
|
|
621
|
-
|
|
1226
|
+
* One factory/constructor call in `lunora/` whose config object literal a
|
|
1227
|
+
* security lint inspects for a present-or-absent key — the shared input for the
|
|
1228
|
+
* config-call security lints (payment authorize, inbound-mail verify, rate-limit
|
|
1229
|
+
* store, browser private-targets). Structurally identical to `AdvisorConfigCall`
|
|
1230
|
+
* so it passes straight through to the advisor without conversion.
|
|
1231
|
+
*/
|
|
1232
|
+
interface ConfigCallIR {
|
|
1233
|
+
/** `true` when the config argument was a static object literal the feeder could read. */
|
|
1234
|
+
analyzable: boolean;
|
|
1235
|
+
/** The factory function or constructor name at the call site, e.g. `createPayment` / `RateLimiter`. */
|
|
1236
|
+
callee: string;
|
|
1237
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1238
|
+
file: string;
|
|
1239
|
+
/** 1-based line of the call site, or `0` when unknown. */
|
|
1240
|
+
line: number;
|
|
1241
|
+
/** Keys present in the config object literal (empty when not `analyzable`). */
|
|
1242
|
+
presentKeys: string[];
|
|
1243
|
+
/** Keys in the config object literal explicitly assigned the literal `true`. */
|
|
1244
|
+
trueKeys: string[];
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* One secret-shaped string literal discovered in `lunora/` source — the
|
|
1248
|
+
* `hardcoded_secret` lint input. Complements the pre-commit `vis secrets` scan by
|
|
1249
|
+
* surfacing the same class of finding in-IDE via the studio Advisors table.
|
|
1250
|
+
* Structurally identical to `AdvisorSecretLiteral`.
|
|
1251
|
+
*/
|
|
622
1252
|
interface SecretLiteralIR {
|
|
623
|
-
/** Source file relative to
|
|
1253
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
624
1254
|
file: string;
|
|
625
1255
|
/** Heuristic that matched, e.g. `stripe_live_key` / `aws_access_key` / `pem_private_key` / `high_entropy`. */
|
|
626
1256
|
kind: string;
|
|
@@ -630,406 +1260,1840 @@ interface SecretLiteralIR {
|
|
|
630
1260
|
preview: string;
|
|
631
1261
|
}
|
|
632
1262
|
/**
|
|
633
|
-
* One `ctx.sql.query(text, …)` / `ctx.sql.unsafe(text, …)` call whose `text`
|
|
634
|
-
* argument is built in place rather than passed as a fixed statement — the
|
|
635
|
-
* `sql_injection_risk` lint input. The Hyperdrive driver binds ONLY the `params`
|
|
636
|
-
* array; the `text` string is spliced verbatim into the SQL, so a `text` assembled
|
|
637
|
-
* from a string concatenation or a substitution template literal is an injection
|
|
638
|
-
* vector. A fixed string literal / no-substitution template is safe. Structurally
|
|
639
|
-
* identical to `AdvisorSqlInterpolation`.
|
|
640
|
-
*/
|
|
1263
|
+
* One `ctx.sql.query(text, …)` / `ctx.sql.unsafe(text, …)` call whose `text`
|
|
1264
|
+
* argument is built in place rather than passed as a fixed statement — the
|
|
1265
|
+
* `sql_injection_risk` lint input. The Hyperdrive driver binds ONLY the `params`
|
|
1266
|
+
* array; the `text` string is spliced verbatim into the SQL, so a `text` assembled
|
|
1267
|
+
* from a string concatenation or a substitution template literal is an injection
|
|
1268
|
+
* vector. A fixed string literal / no-substitution template is safe. Structurally
|
|
1269
|
+
* identical to `AdvisorSqlInterpolation`.
|
|
1270
|
+
*/
|
|
641
1271
|
interface SqlInterpolationIR {
|
|
642
1272
|
/** Export binding name of the procedure performing the `ctx.sql` call. */
|
|
643
1273
|
exportName: string;
|
|
644
|
-
/** Source file relative to
|
|
1274
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
645
1275
|
file: string;
|
|
646
1276
|
/** 1-based line of the interpolation, or `0` when unknown. */
|
|
647
1277
|
line: number;
|
|
648
1278
|
}
|
|
649
1279
|
/**
|
|
650
|
-
* One
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
1280
|
+
* One `ctx.fetch(url, …)` call inside an action whose URL argument is derived
|
|
1281
|
+
* from the handler's `args` — the `action_fetch_ssrf` lint input. `ctx.fetch` is
|
|
1282
|
+
* the action-only outbound-request escape hatch with no host allowlist, so a URL
|
|
1283
|
+
* assembled from request input is a server-side request forgery vector (cloud
|
|
1284
|
+
* metadata endpoints, internal services). Only arg-derived URLs reach here; a
|
|
1285
|
+
* fixed literal or a URL built from config/`ctx.*` is not recorded. Structurally
|
|
1286
|
+
* identical to `AdvisorArgumentDerivedFetch`.
|
|
1287
|
+
*/
|
|
1288
|
+
interface ArgumentDerivedFetchIR {
|
|
1289
|
+
/** Export binding name of the action performing the `ctx.fetch` call. */
|
|
657
1290
|
exportName: string;
|
|
658
|
-
/** Source file relative to
|
|
1291
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
659
1292
|
file: string;
|
|
660
|
-
/**
|
|
1293
|
+
/** 1-based line of the `ctx.fetch` call, or `0` when unknown. */
|
|
1294
|
+
line: number;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* One `ctx.kv.<method>(key, …)` call whose namespace key is derived from the
|
|
1298
|
+
* handler's `args` with no server-side scoping — the `kv_unscoped_user_key_idor`
|
|
1299
|
+
* lint input. Workers KV is a single flat namespace, so a key taken straight from
|
|
1300
|
+
* request input lets any caller read, overwrite, or delete another user's entry
|
|
1301
|
+
* (IDOR). Only arg-derived, unscoped keys reach here; a fixed literal, or a key
|
|
1302
|
+
* prefixed with a server-trusted identity (`${ctx.auth.userId}:…` — references
|
|
1303
|
+
* `ctx`, so treated as scoped), is not recorded. `list` is excluded (it takes a
|
|
1304
|
+
* prefix, not a per-entry key). Structurally identical to `AdvisorKvKeyAccess`.
|
|
1305
|
+
*/
|
|
1306
|
+
interface KvKeyAccessIR {
|
|
1307
|
+
/** Export binding name of the procedure performing the `ctx.kv` access. */
|
|
1308
|
+
exportName: string;
|
|
1309
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1310
|
+
file: string;
|
|
1311
|
+
/** 1-based line of the `ctx.kv` call, or `0` when unknown. */
|
|
1312
|
+
line: number;
|
|
1313
|
+
/** The `ctx.kv` method invoked: `get` / `getRaw` / `getWithMetadata` / `put` / `delete`. */
|
|
661
1314
|
method: string;
|
|
662
|
-
/** The route path, e.g. `/admin/users`. */
|
|
663
|
-
path: string;
|
|
664
|
-
/** `true` when the handler body references an auth/session/admin guard (`ctx.auth`, `getSession`, `requireAdmin`, …). */
|
|
665
|
-
usesGuard: boolean;
|
|
666
1315
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
1316
|
+
/**
|
|
1317
|
+
* One `ctx.db` write (`insert` / `replace` / `patch` / `insertManyUnsafe`) that sets
|
|
1318
|
+
* an ownership / identity column — `userId`, `ownerId`, `tenantId`, and the like —
|
|
1319
|
+
* from the handler's `args` instead of the server-trusted identity. The
|
|
1320
|
+
* `owner_field_from_args_not_auth` lint input: the ownership column decides who a
|
|
1321
|
+
* row belongs to, so a value taken from request input lets any caller write rows
|
|
1322
|
+
* owned by another user or tenant (the act-as-any-user / cross-tenant IDOR vector).
|
|
1323
|
+
* A column stamped from `ctx.*`, or set to a fixed literal, is not recorded; only an
|
|
1324
|
+
* arg-derived identity write reaches here. Structurally identical to
|
|
1325
|
+
* `AdvisorOwnerFieldWrite`.
|
|
1326
|
+
*/
|
|
1327
|
+
/**
|
|
1328
|
+
* One branching `defineShape({ where })` / `definePolicy({ when })` predicate arm
|
|
1329
|
+
* that returns an unrestricted predicate — the `unrestricted_where_branch` lint
|
|
1330
|
+
* input. A denial arm must match NO rows (`deny()` / `{ OR: [] }`); `{}` matches
|
|
1331
|
+
* every row, so the near-miss silently replicates the whole table.
|
|
1332
|
+
*/
|
|
1333
|
+
interface UnrestrictedWhereBranchIR {
|
|
1334
|
+
/** Export binding name of the shape / policy the predicate belongs to. */
|
|
1335
|
+
exportName: string;
|
|
1336
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1337
|
+
file: string;
|
|
1338
|
+
/** Which unrestricted form was returned. */
|
|
1339
|
+
form: "empty-object" | "undefined";
|
|
1340
|
+
/** The config key carrying the predicate (`where` for a shape, `when` for a policy). */
|
|
1341
|
+
key: string;
|
|
1342
|
+
/** 1-based line of the offending returned expression. */
|
|
1343
|
+
line: number;
|
|
1344
|
+
/** The declaring call (`defineShape` / `definePolicy`). */
|
|
1345
|
+
owner: string;
|
|
1346
|
+
}
|
|
1347
|
+
interface OwnerFieldWriteIR {
|
|
1348
|
+
/** Export binding name of the procedure performing the write. */
|
|
1349
|
+
exportName: string;
|
|
1350
|
+
/** The identity column being written from `args` (e.g. `userId`). */
|
|
1351
|
+
field: string;
|
|
1352
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1353
|
+
file: string;
|
|
1354
|
+
/** 1-based line of the `ctx.db` write call, or `0` when unknown. */
|
|
1355
|
+
line: number;
|
|
1356
|
+
/** The `ctx.db` write method (`insert` / `replace` / `patch` / `insertManyUnsafe`). */
|
|
1357
|
+
method: string;
|
|
1358
|
+
/**
|
|
1359
|
+
* Visibility of the enclosing procedure. `internal` procedures are not
|
|
1360
|
+
* reachable by a caller, so the lint's premise ("any caller can write rows
|
|
1361
|
+
* owned by another user") does not hold there — see
|
|
1362
|
+
* `owner_field_from_args_not_auth`. `undefined` when the write sits outside
|
|
1363
|
+
* any recognised procedure (a bare helper).
|
|
1364
|
+
*/
|
|
1365
|
+
visibility?: "internal" | "public";
|
|
674
1366
|
}
|
|
675
1367
|
/**
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
*/
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
1368
|
+
* One `ctx.storage.<bucket>.<method>(key, …)` call whose R2 object key is derived
|
|
1369
|
+
* from the handler's `args` with no server-side scoping — the
|
|
1370
|
+
* `storage_key_from_user_args` lint input. The bucket read/write/URL/delete methods
|
|
1371
|
+
* key by their first argument, so an object key taken straight from request input is
|
|
1372
|
+
* object-level IDOR (read/overwrite/delete anyone's object). A key referencing a
|
|
1373
|
+
* server-trusted `ctx.*` value (e.g. `${ctx.auth.userId}/…`) is treated as scoped
|
|
1374
|
+
* and is not recorded; only an arg-derived, `ctx`-free key reaches here.
|
|
1375
|
+
* Structurally identical to `AdvisorStorageKeyAccess`.
|
|
1376
|
+
*/
|
|
1377
|
+
interface StorageKeyAccessIR {
|
|
1378
|
+
/** Export binding name of the procedure performing the storage call. */
|
|
1379
|
+
exportName: string;
|
|
1380
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1381
|
+
file: string;
|
|
1382
|
+
/** 1-based line of the storage call, or `0` when unknown. */
|
|
1383
|
+
line: number;
|
|
1384
|
+
/** The bucket method invoked with the arg-derived key, e.g. `get` / `put` / `delete` / `download`. */
|
|
1385
|
+
method: string;
|
|
1386
|
+
/**
|
|
1387
|
+
* Visibility of the enclosing procedure. `internal` procedures have no
|
|
1388
|
+
* untrusted caller by construction — see `owner_field_from_args_not_auth`'s
|
|
1389
|
+
* identical split — so `storage_key_from_user_args` drops the finding to
|
|
1390
|
+
* INFO rather than ERROR there. `undefined` when the access sits outside any
|
|
1391
|
+
* registered procedure the feeder could attribute it to.
|
|
1392
|
+
*/
|
|
1393
|
+
visibility?: "internal" | "public";
|
|
1394
|
+
}
|
|
696
1395
|
/**
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
1396
|
+
* One `ctx.containers.<exportName>.get(name, …)` call whose instance key is derived
|
|
1397
|
+
* from the handler's `args` with no server-side scoping — the
|
|
1398
|
+
* `container_instance_key_from_user_input` lint input. Each container definition's
|
|
1399
|
+
* `.get(name)` accessor routes to one instance per `name`, so a key taken straight from
|
|
1400
|
+
* request input lets any caller reach another tenant's container (a cross-tenant IDOR). A
|
|
1401
|
+
* fixed literal key, or one derived from a server-trusted identity (`${ctx.auth.userId}` —
|
|
1402
|
+
* references `ctx`, so treated as scoped), is not recorded; only an arg-derived, unscoped
|
|
1403
|
+
* key reaches here. `.any()`/`.pool()` take no key and are not sinks. Structurally
|
|
1404
|
+
* identical to `AdvisorContainerKeyAccess`.
|
|
1405
|
+
*/
|
|
1406
|
+
interface ContainerKeyAccessIR {
|
|
1407
|
+
/** Export binding name of the procedure performing the `ctx.containers` access. */
|
|
1408
|
+
exportName: string;
|
|
1409
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1410
|
+
file: string;
|
|
1411
|
+
/** 1-based line of the `ctx.containers.*.get` call, or `0` when unknown. */
|
|
1412
|
+
line: number;
|
|
1413
|
+
/** The container accessor method invoked — always `get`. */
|
|
1414
|
+
method: string;
|
|
707
1415
|
}
|
|
708
1416
|
/**
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
|
|
715
|
-
|
|
1417
|
+
* One `ctx.ai.run(model, …)` call whose model-id argument is derived from the handler's
|
|
1418
|
+
* `args` with no server-side scoping — the `ai_raw_run_escape_hatch` lint input.
|
|
1419
|
+
* `ctx.ai.run` is the raw Workers AI binding passthrough, bypassing the typed
|
|
1420
|
+
* `ctx.ai.model(...)` + AI-SDK layer (`generateText`/`streamText`/…) that caps output and
|
|
1421
|
+
* enforces a schema, so an arg-derived model id lets any caller select an arbitrary model.
|
|
1422
|
+
* A fixed literal model, or one scoped by a server-trusted `ctx.*` value, is not recorded;
|
|
1423
|
+
* only an arg-derived, unscoped model id reaches here (an arg-derived `inputs` argument is
|
|
1424
|
+
* normal usage and is never inspected). Structurally identical to `AdvisorAiRawRun`.
|
|
1425
|
+
*/
|
|
1426
|
+
interface AiRawRunIR {
|
|
1427
|
+
/** Export binding name of the procedure performing the `ctx.ai.run` call. */
|
|
1428
|
+
exportName: string;
|
|
1429
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1430
|
+
file: string;
|
|
1431
|
+
/** 1-based line of the `ctx.ai.run` call, or `0` when unknown. */
|
|
1432
|
+
line: number;
|
|
1433
|
+
}
|
|
716
1434
|
/**
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
1435
|
+
* One `ctx.vectors.<method>(indexName, input)` call whose `input.namespace` is derived
|
|
1436
|
+
* from the handler's `args` with no server-side scoping — the
|
|
1437
|
+
* `vectors_namespace_from_user_input` lint input. A Vectorize namespace partitions one
|
|
1438
|
+
* index into isolated sub-collections, so a namespace taken straight from request input
|
|
1439
|
+
* lets any caller read or poison another tenant's vectors. A fixed literal namespace, or
|
|
1440
|
+
* one prefixed with a server-trusted identity (`${ctx.auth.orgId}` — references `ctx`, so
|
|
1441
|
+
* treated as scoped), is not recorded; only an arg-derived, unscoped namespace reaches
|
|
1442
|
+
* here. Structurally identical to `AdvisorVectorNamespaceAccess`.
|
|
1443
|
+
*/
|
|
1444
|
+
interface VectorNamespaceAccessIR {
|
|
1445
|
+
/** Export binding name of the procedure performing the `ctx.vectors` access. */
|
|
1446
|
+
exportName: string;
|
|
1447
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1448
|
+
file: string;
|
|
1449
|
+
/** 1-based line of the `ctx.vectors` call, or `0` when unknown. */
|
|
1450
|
+
line: number;
|
|
1451
|
+
/** The `ctx.vectors` method invoked: `query` / `upsert` / `upsertMany`. */
|
|
1452
|
+
method: string;
|
|
1453
|
+
}
|
|
724
1454
|
/**
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
*
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
|
|
731
|
-
|
|
1455
|
+
* One `ctx.mail`/`ctx.email` `send`/`queue` call whose recipient field (`to`/`cc`/`bcc`)
|
|
1456
|
+
* is derived from the handler's `args` with no server-side scoping — the
|
|
1457
|
+
* `mail_recipient_from_request_input` lint input. A recipient taken straight from request
|
|
1458
|
+
* input turns the deployment into an open relay / spam amplifier (any caller can direct
|
|
1459
|
+
* mail to an arbitrary address). A fixed literal recipient, or one scoped by a
|
|
1460
|
+
* server-trusted `ctx.*` value (e.g. `ctx.auth.user.email`), is not recorded; only an
|
|
1461
|
+
* arg-derived, unscoped recipient reaches here. Structurally identical to
|
|
1462
|
+
* `AdvisorMailRecipientAccess`.
|
|
1463
|
+
*/
|
|
1464
|
+
interface MailRecipientAccessIR {
|
|
1465
|
+
/** Export binding name of the procedure performing the `ctx.mail`/`ctx.email` call. */
|
|
1466
|
+
exportName: string;
|
|
1467
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1468
|
+
file: string;
|
|
1469
|
+
/** 1-based line of the `ctx.mail`/`ctx.email` call, or `0` when unknown. */
|
|
1470
|
+
line: number;
|
|
1471
|
+
/** The mailer method invoked: `send` / `queue`. */
|
|
1472
|
+
method: string;
|
|
1473
|
+
}
|
|
732
1474
|
/**
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*/
|
|
740
|
-
|
|
741
|
-
/**
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1475
|
+
* One `ctx.browser.<method>(url, …)` call whose navigation URL (`arguments[0]`)
|
|
1476
|
+
* is derived from the handler's `args` with no server-side scoping — the
|
|
1477
|
+
* `browser_user_url_without_allowlist` lint input. The lint additionally
|
|
1478
|
+
* cross-references `createBrowser` config-call evidence to suppress findings
|
|
1479
|
+
* when the browser is hardened with an `allowedHosts` allowlist or
|
|
1480
|
+
* `resolveDns`. Structurally identical to `AdvisorBrowserUrlAccess`.
|
|
1481
|
+
*/
|
|
1482
|
+
interface BrowserUrlAccessIR {
|
|
1483
|
+
/** Export binding name of the procedure performing the `ctx.browser` call. */
|
|
1484
|
+
exportName: string;
|
|
1485
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1486
|
+
file: string;
|
|
1487
|
+
/** 1-based line of the `ctx.browser` call, or `0` when unknown. */
|
|
1488
|
+
line: number;
|
|
1489
|
+
/** The browser method invoked: `content` / `pdf` / `scrape` / `screenshot`. */
|
|
1490
|
+
method: string;
|
|
1491
|
+
}
|
|
746
1492
|
/**
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
|
|
751
|
-
|
|
1493
|
+
* One runtime container-override call: a `<handle>.start({ enableInternet: true, … })`
|
|
1494
|
+
* launch override, or a `<handle>.egress.<method>(...)` runtime firewall mutation
|
|
1495
|
+
* (`allow` / `deny` / `setAllowed`) — the `container_start_enable_internet_override`
|
|
1496
|
+
* and `container_runtime_egress_relaxation` lint input. Both shapes re-open network
|
|
1497
|
+
* access the static `defineContainer` declaration (and its `container_public_internet`
|
|
1498
|
+
* lint) assumes is locked down. Matched structurally by call shape, independent of the
|
|
1499
|
+
* receiver's resolved type. Structurally identical to `AdvisorContainerOverride`.
|
|
1500
|
+
*/
|
|
1501
|
+
interface ContainerOverrideIR {
|
|
1502
|
+
/** e.g. the egress method name, or `"enableInternet: true"`. */
|
|
1503
|
+
detail: string;
|
|
1504
|
+
/** Export binding name of the procedure performing the call. */
|
|
1505
|
+
exportName: string;
|
|
1506
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1507
|
+
file: string;
|
|
1508
|
+
/** Which override shape matched. */
|
|
1509
|
+
kind: "egress_relaxation" | "enable_internet";
|
|
1510
|
+
/** 1-based line of the call, or `0` when unknown. */
|
|
1511
|
+
line: number;
|
|
1512
|
+
}
|
|
752
1513
|
/**
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
|
|
758
|
-
|
|
1514
|
+
* One `buildImageDeliveryUrl({ key, … })` call (`@lunora/bindings/images`) whose
|
|
1515
|
+
* `key` — the CDN transform's source image, an absolute URL or an
|
|
1516
|
+
* origin-relative key — is derived from the handler's `args` with no
|
|
1517
|
+
* server-side scoping — the `images_url_source_from_user_input` lint input.
|
|
1518
|
+
* `ctx.images.transform`/`info` take image *bytes*, never a URL, so they are not
|
|
1519
|
+
* sinks; only the `key` of `buildImageDeliveryUrl` accepts a URL-or-key source
|
|
1520
|
+
* and is inspected. An arg-derived `key` lets any caller point the CDN's
|
|
1521
|
+
* `/cdn-cgi/image/` transform at an attacker-chosen origin (SSRF / open proxy)
|
|
1522
|
+
* or at an arbitrary key under the account's own store. A fixed literal, or a
|
|
1523
|
+
* key scoped by a server-trusted `ctx.*` value, is not recorded. Structurally
|
|
1524
|
+
* identical to `AdvisorImageDeliveryUrlAccess`.
|
|
1525
|
+
*/
|
|
1526
|
+
interface ImageDeliveryUrlAccessIR {
|
|
1527
|
+
/** Export binding name of the procedure performing the `buildImageDeliveryUrl` call. */
|
|
1528
|
+
exportName: string;
|
|
1529
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1530
|
+
file: string;
|
|
1531
|
+
/** 1-based line of the `buildImageDeliveryUrl` call, or `0` when unknown. */
|
|
1532
|
+
line: number;
|
|
1533
|
+
}
|
|
759
1534
|
/**
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
|
|
766
|
-
|
|
1535
|
+
* One `createAuth({...})` call's configuration snapshot — the shared input for
|
|
1536
|
+
* the five `auth_*` security lints (trusted-origins wildcard, CSRF check
|
|
1537
|
+
* disabled, secure cookies disabled, email verification disabled, session
|
|
1538
|
+
* freshAge zero). Matched by callee NAME (an `import`-agnostic, fail-closed
|
|
1539
|
+
* convention the other feeders share), so a re-export or alias still resolves.
|
|
1540
|
+
* When the config argument isn't a statically-analyzable object literal (a
|
|
1541
|
+
* top-level spread, or not an object literal at all), `analyzable` is `false`
|
|
1542
|
+
* and every boolean fact defaults to its SAFE (not-flagged) value — an opaque
|
|
1543
|
+
* config can't be relied on either way. Structurally identical to
|
|
1544
|
+
* `AdvisorAuthConfig`.
|
|
1545
|
+
*/
|
|
1546
|
+
interface AuthConfigIR {
|
|
1547
|
+
/** `true` when the call's config argument was a static object literal the feeder could read. */
|
|
1548
|
+
analyzable: boolean;
|
|
1549
|
+
/** `advanced.disableCSRFCheck === true`. */
|
|
1550
|
+
disableCsrfCheck: boolean;
|
|
1551
|
+
/** `emailAndPassword.enabled === true`. */
|
|
1552
|
+
emailPasswordEnabled: boolean;
|
|
1553
|
+
/** Export binding name enclosing the `createAuth(...)` call. */
|
|
1554
|
+
exportName: string;
|
|
1555
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1556
|
+
file: string;
|
|
1557
|
+
/** 1-based line of the `createAuth(...)` call, or `0` when unknown. */
|
|
1558
|
+
line: number;
|
|
1559
|
+
/** `emailAndPassword.requireEmailVerification === true` present. */
|
|
1560
|
+
requireEmailVerification: boolean;
|
|
1561
|
+
/** `trustedOrigins` array literal contains a `"*"` element. */
|
|
1562
|
+
/** `plugins` includes `scim(...)` while `database` is a non-transactional Lunora adapter — a combination that throws at runtime. */
|
|
1563
|
+
scimOnNonTransactionalAdapter: boolean;
|
|
1564
|
+
/** `advanced.useSecureCookies === false`. */
|
|
1565
|
+
secureCookiesDisabled: boolean;
|
|
1566
|
+
/** `session.freshAge === 0` (explicit literal). */
|
|
1567
|
+
sessionFreshAgeZero: boolean;
|
|
1568
|
+
trustedOriginsWildcard: boolean;
|
|
1569
|
+
}
|
|
767
1570
|
/**
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
*
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
1571
|
+
* One `rateLimit`/`dbRateLimit` middleware call (`@lunora/ratelimit`) whose
|
|
1572
|
+
* `key` selector — the per-caller rate-limit sub-key, `(ctx) => string |
|
|
1573
|
+
* undefined` — is derived from the handler's `args` with no server-side
|
|
1574
|
+
* scoping (no reference to the trusted `ctx` binding anywhere in the selector)
|
|
1575
|
+
* — the `ratelimit_key_spoofable_or_global` lint input. A key an attacker
|
|
1576
|
+
* controls lets them rotate it per request and bypass the limit entirely,
|
|
1577
|
+
* defeating its purpose. A selector scoped by `ctx` (e.g. `ctx.auth.userId`,
|
|
1578
|
+
* `ctx.ip`), or one with no `args` reference at all (a fixed/global bucket —
|
|
1579
|
+
* the "no key" case this lint deliberately does not flag, to keep it low-FP),
|
|
1580
|
+
* is not recorded. Structurally identical to `AdvisorRatelimitKeySelector`.
|
|
1581
|
+
*/
|
|
1582
|
+
interface RatelimitKeySelectorIR {
|
|
1583
|
+
/** The `rateLimit`/`dbRateLimit` callee invoked. */
|
|
1584
|
+
callee: string;
|
|
1585
|
+
/** Export binding name of the procedure whose `.use(...)` chain carries the call. */
|
|
1586
|
+
exportName: string;
|
|
1587
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1588
|
+
file: string;
|
|
1589
|
+
/** The rate limit's `name` argument (the second positional argument), or `""` when not a string literal. */
|
|
1590
|
+
limitName: string;
|
|
1591
|
+
/** 1-based line of the `rateLimit`/`dbRateLimit` call, or `0` when unknown. */
|
|
1592
|
+
line: number;
|
|
1593
|
+
}
|
|
783
1594
|
/**
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
*/
|
|
798
|
-
|
|
1595
|
+
* One payload-derived privileged dispatch — a `ctx.run`/`context.run` back into a
|
|
1596
|
+
* Lunora function from inside a `defineQueue` push handler or a `defineWorkflow`
|
|
1597
|
+
* handler, whose args reference the handler's untrusted payload (`context.params`
|
|
1598
|
+
* for a workflow, a `for (… of batch.messages)` body for a queue) — the
|
|
1599
|
+
* `privileged_dispatch_unvalidated_payload` lint input. Both handler kinds run
|
|
1600
|
+
* under the **system identity** (RLS disabled), so forwarding attacker-influenced
|
|
1601
|
+
* payload into the dispatch bypasses the target's row policy. The resolved
|
|
1602
|
+
* `targetFile`/`targetExport` let the lint join RLS-procedure evidence and fire
|
|
1603
|
+
* only for RLS-gated targets. Structurally identical to `AdvisorPrivilegedDispatch`.
|
|
1604
|
+
*/
|
|
1605
|
+
interface PrivilegedDispatchIR {
|
|
1606
|
+
/** `"queue"` for a `defineQueue` handler, `"workflow"` for a `defineWorkflow` handler. */
|
|
1607
|
+
dispatchKind: "queue" | "workflow";
|
|
1608
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1609
|
+
file: string;
|
|
1610
|
+
/** Export binding name of the handler performing the dispatch. */
|
|
1611
|
+
handlerExport: string;
|
|
1612
|
+
/** 1-based line of the dispatch call, or `0` when unknown. */
|
|
1613
|
+
line: number;
|
|
1614
|
+
/** Export name of the dispatched target (`send` in `api.messages.send`). */
|
|
1615
|
+
targetExport: string;
|
|
1616
|
+
/** File path of the dispatched target relative to `lunora/` (`messages` in `api.messages.send`). */
|
|
1617
|
+
targetFile: string;
|
|
1618
|
+
}
|
|
799
1619
|
/**
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*/
|
|
805
|
-
|
|
1620
|
+
* One discovered `httpRoute.<verb>("/admin/…")` route on an admin/privileged-looking
|
|
1621
|
+
* path, with whether its builder chain references an auth/admin guard — the
|
|
1622
|
+
* `admin_route_without_guard` lint input. Structurally identical to
|
|
1623
|
+
* `AdvisorAdminRoute`.
|
|
1624
|
+
*/
|
|
1625
|
+
interface AdminRouteIR {
|
|
1626
|
+
/** Export binding name of the route handler. */
|
|
1627
|
+
exportName: string;
|
|
1628
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1629
|
+
file: string;
|
|
1630
|
+
/** HTTP verb the route binds to (uppercased), e.g. `"POST"`. */
|
|
1631
|
+
method: string;
|
|
1632
|
+
/** The route path, e.g. `/admin/users`. */
|
|
1633
|
+
path: string;
|
|
1634
|
+
/** `true` when the handler body references an auth/session/admin guard (`ctx.auth`, `getSession`, `requireAdmin`, …). */
|
|
1635
|
+
usesGuard: boolean;
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* One tracked `ctx.storage.<bucket>.<method>(...)` upload/signing call — the
|
|
1639
|
+
* shared input for the storage config-hygiene security lints
|
|
1640
|
+
* (`storage_upload_without_content_type_allowlist`, `storage_upload_without_max_size`,
|
|
1641
|
+
* `storage_generate_upload_url_no_content_type_pin`, `storage_presigned_url_for_private_content`).
|
|
1642
|
+
* `upload`/`store` carry the `UploadOptions` guards (`allowedContentTypes` /
|
|
1643
|
+
* `maxSize`); `generateUploadUrl` carries the signed-PUT `contentType` pin;
|
|
1644
|
+
* `getPresignedUrl`/`getSignedUrl` carry a statically-known `expiresInSeconds`
|
|
1645
|
+
* literal. `presentKeys` is empty (and `expiresInSeconds` unset) when the
|
|
1646
|
+
* options argument was absent, a non-literal, or a spread — see `analyzable`.
|
|
1647
|
+
* Structurally identical to `AdvisorStorageUpload`.
|
|
1648
|
+
*/
|
|
1649
|
+
interface StorageUploadIR {
|
|
1650
|
+
/** `true` when the call's options-object argument (or its deliberate absence) was statically resolvable. */
|
|
1651
|
+
analyzable: boolean;
|
|
1652
|
+
/** Numeric literal value of an `expiresInSeconds` option, when statically known (`getSignedUrl` / `getPresignedUrl` only). */
|
|
1653
|
+
expiresInSeconds?: number;
|
|
1654
|
+
/** Export binding name of the procedure performing the call. */
|
|
1655
|
+
exportName: string;
|
|
1656
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1657
|
+
file: string;
|
|
1658
|
+
/** 1-based line of the call, or `0` when unknown. */
|
|
1659
|
+
line: number;
|
|
1660
|
+
/** The `ctx.storage` method invoked. */
|
|
1661
|
+
method: "generateUploadUrl" | "getPresignedUrl" | "getSignedUrl" | "store" | "upload";
|
|
1662
|
+
/** Options-object keys present at the call site (empty when not `analyzable`, or when no options argument was passed). */
|
|
1663
|
+
presentKeys: string[];
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* One discovered `httpAction`/`httpRoute` handler in `lunora/` that performs a
|
|
1667
|
+
* side effect (`ctx.runMutation` / `ctx.runAction` / a `ctx.db.{insert,patch,
|
|
1668
|
+
* replace,delete,insertManyUnsafe}` write) from the HTTP edge, with whether it
|
|
1669
|
+
* reads `ctx.auth` — the `http_action_missing_auth_guard` lint input. A handler
|
|
1670
|
+
* that mutates state or dispatches an action without ever consulting the request
|
|
1671
|
+
* identity is an unauthenticated write bypassing identity/RLS. Only handlers with
|
|
1672
|
+
* a statically-resolvable inline body and `ctx` binding are recorded (fail-safe
|
|
1673
|
+
* under-report); read-only handlers are never recorded. Structurally identical to
|
|
1674
|
+
* `AdvisorHttpActionGuard`.
|
|
1675
|
+
*/
|
|
1676
|
+
interface HttpActionGuardIR {
|
|
1677
|
+
/** Export binding name of the handler (or `"<module>"` when mounted inline / not a named binding). */
|
|
1678
|
+
exportName: string;
|
|
1679
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1680
|
+
file: string;
|
|
1681
|
+
/** Which HTTP surface the handler is: a raw `httpAction` or a typed `httpRoute` route. */
|
|
1682
|
+
kind: "httpAction" | "httpRoute";
|
|
1683
|
+
/** 1-based line of the handler call, or `0` when unknown. */
|
|
1684
|
+
line: number;
|
|
1685
|
+
/** For an `httpRoute`, the uppercased verb (`"POST"`); absent for a raw `httpAction`. */
|
|
1686
|
+
method?: string;
|
|
1687
|
+
/** `true` when the handler reads `ctx.auth` (a direct member access or a `const { auth } = ctx` destructure). */
|
|
1688
|
+
readsAuth: boolean;
|
|
1689
|
+
/** The first side effect found, as a stable label: `runMutation`, `runAction`, or `db.<method>`. */
|
|
1690
|
+
sideEffect: string;
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* One response-header write, inside an `httpAction` handler, whose value is derived
|
|
1694
|
+
* from raw request input (`request.headers`, `request.url`/query, `await
|
|
1695
|
+
* request.json()`) with no CR/LF sanitizer — the
|
|
1696
|
+
* `http_action_response_header_injection` lint input. A `Request`-derived string
|
|
1697
|
+
* placed verbatim into a response header lets a caller smuggle `\r\n` and inject
|
|
1698
|
+
* extra headers or split the response (header injection / response splitting). Only
|
|
1699
|
+
* sites whose value is request-tainted AND unguarded are recorded: a value routed
|
|
1700
|
+
* through a CR/LF guard (`isSafeHeaderValue`), a URL/URI encoder
|
|
1701
|
+
* (`encodeURIComponent`/`encodeURI`), a numeric coercion (`Number`/`parseInt`/
|
|
1702
|
+
* `parseFloat`), or `btoa` is treated as safe and never recorded (`String(...)` /
|
|
1703
|
+
* `.toString()` are NOT sanitizers — they don't strip CR/LF). Structurally
|
|
1704
|
+
* identical to `AdvisorHttpHeaderWrite`.
|
|
1705
|
+
*/
|
|
1706
|
+
interface HttpHeaderWriteIR {
|
|
1707
|
+
/** Export binding name of the enclosing handler, or `"<module>"` when mounted inline. */
|
|
1708
|
+
exportName: string;
|
|
1709
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1710
|
+
file: string;
|
|
1711
|
+
/** The header name being written (`"location"`), or `""` when the key is not a string literal. */
|
|
1712
|
+
headerName: string;
|
|
1713
|
+
/** 1-based line of the request-tainted header value. */
|
|
1714
|
+
line: number;
|
|
1715
|
+
/** How the header was written. */
|
|
1716
|
+
via: "headers-append" | "headers-ctor" | "headers-set" | "response-init";
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* One rate-limit / Turnstile middleware call in `lunora/` — the
|
|
1720
|
+
* `ratelimit_middleware_fail_open` lint input. `rateLimit`/`dbRateLimit`
|
|
1721
|
+
* (`@lunora/ratelimit`) and `verifyTurnstileMiddleware` (`@lunora/auth`) each
|
|
1722
|
+
* accept a `failOpen` escape hatch that admits every request when the
|
|
1723
|
+
* limiter/siteverify is unavailable; `failOpen` is `true` only when the options
|
|
1724
|
+
* literal set it to the boolean literal `true` (anything else is fail-closed).
|
|
1725
|
+
* The lint escalates a fail-open guard to a finding when the guarded procedure
|
|
1726
|
+
* (`exportName`/`limitName`) looks auth/payment-sensitive. Structurally
|
|
1727
|
+
* identical to `AdvisorFailOpenGuard`.
|
|
1728
|
+
*/
|
|
1729
|
+
interface FailOpenGuardIR {
|
|
1730
|
+
/** The middleware factory at the call site: `rateLimit` / `dbRateLimit` / `verifyTurnstileMiddleware`. */
|
|
1731
|
+
callee: string;
|
|
1732
|
+
/** Export binding name of the procedure the guard is attached to, or `"<module>"` at file scope. */
|
|
1733
|
+
exportName: string;
|
|
1734
|
+
/** `true` only when the options literal set `failOpen: true` as a boolean literal; a non-literal or absent option is treated as fail-closed. */
|
|
1735
|
+
failOpen: boolean;
|
|
1736
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1737
|
+
file: string;
|
|
1738
|
+
/** The rate-limit `name` (second string argument) for `rateLimit`/`dbRateLimit`; `""` for `verifyTurnstileMiddleware`. */
|
|
1739
|
+
limitName: string;
|
|
1740
|
+
/** 1-based line of the middleware call, or `0` when unknown. */
|
|
1741
|
+
line: number;
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* One `ctx.flags.boolean("key", <boolean-literal>)` read in `lunora/` — the
|
|
1745
|
+
* `flag_gates_security_with_unsafe_default` lint input. OpenFeature returns the
|
|
1746
|
+
* `defaultValue` when the provider errors, so a fail-open default on a
|
|
1747
|
+
* security-shaped key silently opens access during an outage. Only reads with a
|
|
1748
|
+
* statically-known string key and boolean-literal default are recorded; the lint
|
|
1749
|
+
* owns the security-shape + polarity judgment. Structurally identical to
|
|
1750
|
+
* `AdvisorFlagSecurityDefault`.
|
|
1751
|
+
*/
|
|
1752
|
+
interface FlagSecurityDefaultIR {
|
|
1753
|
+
/** The boolean-literal default returned on a provider outage (fail-open value). */
|
|
1754
|
+
defaultValue: boolean;
|
|
1755
|
+
/** Export binding name of the procedure performing the flag read, or `"<module>"` at file scope. */
|
|
1756
|
+
exportName: string;
|
|
1757
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1758
|
+
file: string;
|
|
1759
|
+
/** The flag key — the first string-literal argument of `ctx.flags.boolean`. */
|
|
1760
|
+
key: string;
|
|
1761
|
+
/** 1-based line of the `ctx.flags.boolean` call, or `0` when unknown. */
|
|
1762
|
+
line: number;
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* One `generateText` / `streamText` call in `lunora/` whose `tools` reach a
|
|
1766
|
+
* privileged side effect (a DB write, function dispatch, or outbound
|
|
1767
|
+
* fetch/mail/queue send). `userInputDerived` records whether the model input
|
|
1768
|
+
* (`prompt`/`messages`/`system`) flows from the handler's `args`; the
|
|
1769
|
+
* `ai_tool_side_effect_prompt_injection` lint fires only when it does.
|
|
1770
|
+
* Structurally identical to `AdvisorAiToolSideEffect`.
|
|
1771
|
+
*/
|
|
1772
|
+
interface AiToolSideEffectIR {
|
|
1773
|
+
/** Export binding name of the procedure performing the call. */
|
|
1774
|
+
exportName: string;
|
|
1775
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1776
|
+
file: string;
|
|
1777
|
+
/** 1-based line of the generation call, or `0` when unknown. */
|
|
1778
|
+
line: number;
|
|
1779
|
+
/** The generation entrypoint invoked. */
|
|
1780
|
+
method: "generateText" | "streamText";
|
|
1781
|
+
/** The privileged side-effect sink a model-callable tool reaches (`ctx.db.insert`, `ctx.run`, `ctx.fetch`, …). */
|
|
1782
|
+
sideEffect: string;
|
|
1783
|
+
/** `true` when a model-input option is derived from the handler's `args` (a bare `args.x`, or a name destructured from `args`). */
|
|
1784
|
+
userInputDerived: boolean;
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* One `<receiver>.identity.<key>` claim read in `lunora/`, where `<receiver>` is
|
|
1788
|
+
* an RLS/mask policy `auth` (or `ctx.auth`/`context.auth`). `declared` records
|
|
1789
|
+
* whether `<key>` is in the app's `defineIdentity({ ... })` contract (or the
|
|
1790
|
+
* always-present `userId`); the `identity_undeclared_claim_trusted` lint fires on
|
|
1791
|
+
* the undeclared reads. Emitted only when a resolvable identity contract exists.
|
|
1792
|
+
* Structurally identical to `AdvisorIdentityClaimRead`.
|
|
1793
|
+
*/
|
|
1794
|
+
interface IdentityClaimReadIR {
|
|
1795
|
+
/** `true` when `key` is a declared claim (in the `defineIdentity` contract, or the always-present `userId`). */
|
|
1796
|
+
declared: boolean;
|
|
1797
|
+
/** Export binding name of the enclosing declaration (`<module>` at file scope). */
|
|
1798
|
+
exportName: string;
|
|
1799
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1800
|
+
file: string;
|
|
1801
|
+
/** The claim key read off the identity bag. */
|
|
1802
|
+
key: string;
|
|
1803
|
+
/** 1-based line of the read, or `0` when unknown. */
|
|
1804
|
+
line: number;
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* One payment webhook-adapter construction in `lunora/` (`createStripeAdapter` /
|
|
1808
|
+
* `createPolarAdapter` / `createAutumnAdapter` / `createDodoPaymentsAdapter`).
|
|
1809
|
+
* `toleranceSeconds` carries the statically-known `webhookToleranceSeconds`
|
|
1810
|
+
* replay window when it is a plain numeric literal; the payment-webhook
|
|
1811
|
+
* wide-tolerance lint fires when it exceeds a conservative ceiling. Structurally
|
|
1812
|
+
* identical to `AdvisorPaymentWebhook`.
|
|
1813
|
+
*/
|
|
1814
|
+
interface PaymentWebhookIR {
|
|
1815
|
+
/** The adapter factory invoked. */
|
|
1816
|
+
callee: "createAutumnAdapter" | "createDodoPaymentsAdapter" | "createPolarAdapter" | "createStripeAdapter";
|
|
1817
|
+
/** Export binding name of the enclosing declaration (`<module>` at file scope). */
|
|
1818
|
+
exportName: string;
|
|
1819
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1820
|
+
file: string;
|
|
1821
|
+
/** 1-based line of the construction, or `0` when unknown. */
|
|
1822
|
+
line: number;
|
|
1823
|
+
/** Statically-known `webhookToleranceSeconds` literal, when present and a plain numeric literal. */
|
|
1824
|
+
toleranceSeconds?: number;
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* One `ctx.db.<table>.findMany({ includeDeleted })` list read whose
|
|
1828
|
+
* `includeDeleted` is either a hardcoded `true` or derived from the handler's
|
|
1829
|
+
* `args` — the `soft_delete_include_deleted_from_args` lint input. The lint joins
|
|
1830
|
+
* `table` against the schema's soft-delete tables and `visibility` against
|
|
1831
|
+
* `.public()` before flagging. Structurally identical to `AdvisorSoftDeleteRead`
|
|
1832
|
+
* so values pass straight through without conversion.
|
|
1833
|
+
*/
|
|
1834
|
+
interface SoftDeleteReadIR {
|
|
1835
|
+
/** Export binding name of the procedure performing the read. */
|
|
1836
|
+
exportName: string;
|
|
1837
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1838
|
+
file: string;
|
|
1839
|
+
/** `true` when `includeDeleted` was derived from the handler's `args` (any caller can flip it). */
|
|
1840
|
+
fromArgs: boolean;
|
|
1841
|
+
/** `true` when `includeDeleted` was a hardcoded `true` literal (always resurfaces soft-deleted rows). */
|
|
1842
|
+
hardcodedTrue: boolean;
|
|
1843
|
+
/** 1-based line of the read call. */
|
|
1844
|
+
line: number;
|
|
1845
|
+
/** Table read, or `""` when the table-arg form's first argument wasn't a string literal. */
|
|
1846
|
+
table: string;
|
|
1847
|
+
/** `"internal"` for `internalQuery` / `internalMutation` / `internalAction`. */
|
|
1848
|
+
visibility: "internal" | "public";
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* One `ctx.db.<table>.findMany({ with: { <rel> } })` relation-hydrating list read
|
|
1852
|
+
* — the `masked_relation_leak_via_with` lint input. Column masking does not
|
|
1853
|
+
* descend into `with`-hydrated relations, so a masked table surfaced only through
|
|
1854
|
+
* a `with` on an unprotected parent read is returned in the clear. The lint
|
|
1855
|
+
* resolves each relation accessor to its target table and joins it against the
|
|
1856
|
+
* discovered mask evidence before flagging. Structurally identical to
|
|
1857
|
+
* `AdvisorRelationLoad` so values pass straight through without conversion.
|
|
1858
|
+
*/
|
|
1859
|
+
interface RelationLoadIR {
|
|
1860
|
+
/** Export binding name of the procedure performing the read. */
|
|
1861
|
+
exportName: string;
|
|
1862
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1863
|
+
file: string;
|
|
1864
|
+
/** 1-based line of the read call. */
|
|
1865
|
+
line: number;
|
|
1866
|
+
/** Parent table the read targets, or `""` when the table-arg form's first argument wasn't a string literal. */
|
|
1867
|
+
parentTable: string;
|
|
1868
|
+
/** Relation accessor names named in the read's `with: { … }` map — matched against the parent table's declared relations. */
|
|
1869
|
+
relations: string[];
|
|
1870
|
+
/** `"internal"` for `internalQuery` / `internalMutation` / `internalAction`. */
|
|
1871
|
+
visibility: "internal" | "public";
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* One `query` handler whose `return` hands back the raw rows of a table — the
|
|
1875
|
+
* result of a `ctx.db.<table>.findMany()` / `.findFirst()` / `.get()` read, or a
|
|
1876
|
+
* `ctx.db.query("<table>")…collect()` fluent chain — returned directly (or through
|
|
1877
|
+
* one local `const` hop) with no hand-built projection. The
|
|
1878
|
+
* `output_projection_missing_on_public_read` lint keeps only `visibility ===
|
|
1879
|
+
* "public"` rows with no `.output(...)` / `.use(mask(...))` on the chain, then
|
|
1880
|
+
* joins `table` against the schema and flags one whose columns are PII-named.
|
|
1881
|
+
* Structurally identical to `AdvisorRawRowReturn` so values pass straight through
|
|
1882
|
+
* without conversion.
|
|
1883
|
+
*/
|
|
1884
|
+
interface RawRowReturnIR {
|
|
1885
|
+
/** Export binding name of the query returning the raw rows. */
|
|
1886
|
+
exportName: string;
|
|
1887
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1888
|
+
file: string;
|
|
1889
|
+
/** 1-based line of the `return` (or concise-body) expression. */
|
|
1890
|
+
line: number;
|
|
1891
|
+
/** Table whose raw rows are returned, or `""` when the read's table wasn't a string literal. */
|
|
1892
|
+
table: string;
|
|
1893
|
+
/** `true` when the procedure's builder chain carries a `.use(mask(...))` step. */
|
|
1894
|
+
usesMask: boolean;
|
|
1895
|
+
/** `true` when the procedure's builder chain carries an `.output(...)` return-shape projection. */
|
|
1896
|
+
usesOutput: boolean;
|
|
1897
|
+
/** `"internal"` for `internalQuery`; `"public"` for `query`. */
|
|
1898
|
+
visibility: "internal" | "public";
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* One `query`/`mutation` handler that gates a `ctx.db.get`/`patch`/`delete` on a
|
|
1902
|
+
* null-checked `ctx.db.normalizeId(table, id)` result — the
|
|
1903
|
+
* `normalize_id_used_as_authorization` lint input. `normalizeId` validates an id's
|
|
1904
|
+
* structural shape only (it never reads the database), so a non-null result proves
|
|
1905
|
+
* the id is well-formed, never that the caller owns the row; gating access on it is
|
|
1906
|
+
* an IDOR. The lint owns the negative proof — it keeps only `visibility === "public"`
|
|
1907
|
+
* rows with no `.use(rls(...))` and no ownership/identity mention (`mentionsOwnership`),
|
|
1908
|
+
* then joins `table` against the schema's RLS mode before flagging. Structurally
|
|
1909
|
+
* identical to `AdvisorNormalizeIdAuthorization` so values pass straight through.
|
|
1910
|
+
*/
|
|
1911
|
+
interface NormalizeIdAuthorizationIR {
|
|
1912
|
+
/** Export binding name of the procedure performing the normalize-then-access. */
|
|
1913
|
+
exportName: string;
|
|
1914
|
+
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1915
|
+
file: string;
|
|
1916
|
+
/** 1-based line of the `ctx.db.normalizeId(...)` call the access is gated on. */
|
|
1917
|
+
line: number;
|
|
1918
|
+
/** `true` when the handler anywhere reads an ownership-named identifier or `ctx.auth`/`ctx.identity`/… — an intervening ownership signal. */
|
|
1919
|
+
mentionsOwnership: boolean;
|
|
1920
|
+
/** The id-first `ctx.db` sink the normalized id reaches. */
|
|
1921
|
+
sinkMethod: "delete" | "get" | "patch";
|
|
1922
|
+
/** Table named in the `normalizeId` call, or `""` when its table argument wasn't a string literal. */
|
|
1923
|
+
table: string;
|
|
1924
|
+
/** `true` when the procedure's builder chain carries a `.use(rls(...))` step. */
|
|
1925
|
+
usesRls: boolean;
|
|
1926
|
+
/** `"internal"` for `internalQuery`/`internalMutation`; `"public"` for `query`/`mutation`. */
|
|
1927
|
+
visibility: "internal" | "public";
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* One committed `wrangler.jsonc` `vars` entry whose value is a plaintext secret —
|
|
1931
|
+
* the `plaintext_secret_in_wrangler_vars` lint input. `vars` are baked into the
|
|
1932
|
+
* deployed Worker in cleartext and checked into source control, so a real API key
|
|
1933
|
+
* / token / private key there ships the secret to every reader of the repo and the
|
|
1934
|
+
* bundle; it belongs in a Secrets Store binding or `wrangler secret put`. Produced
|
|
1935
|
+
* by `@lunora/config` (which reads `wrangler.jsonc`), not a ts-morph feeder —
|
|
1936
|
+
* codegen only passes it through. Structurally identical to `AdvisorWranglerVariable`.
|
|
1937
|
+
*/
|
|
1938
|
+
interface WranglerVariableIR {
|
|
1939
|
+
/** The `wrangler.jsonc` file the var was read from, relative to the project root. */
|
|
1940
|
+
file: string;
|
|
1941
|
+
/** The offending `vars` key (e.g. `STRIPE_SECRET_KEY`). */
|
|
1942
|
+
key: string;
|
|
1943
|
+
/** Heuristic that matched, e.g. `stripe_live_key` / `private_key` / `secret_named_var`. */
|
|
1944
|
+
kind: string;
|
|
1945
|
+
/** Redacted preview of the value (first few chars + length) for the finding detail — never the full secret. */
|
|
1946
|
+
preview: string;
|
|
1947
|
+
}
|
|
1948
|
+
interface ProjectIR {
|
|
1949
|
+
crons: ReadonlyArray<CronJobIR>;
|
|
1950
|
+
functions: ReadonlyArray<FunctionIR>;
|
|
1951
|
+
/** Typed REST routes discovered from `httpRoute.<verb>(...)` builder chains. */
|
|
1952
|
+
httpRoutes: ReadonlyArray<HttpRouteIR>;
|
|
1953
|
+
migrations: ReadonlyArray<MigrationIR>;
|
|
1954
|
+
schema: SchemaIR;
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* One import of a migrated-away platform's SDK still present in `lunora/`
|
|
1958
|
+
* source. Structurally identical to the advisor's `AdvisorStaleMigrationImport`
|
|
1959
|
+
* so it passes through the feeder without conversion.
|
|
1960
|
+
*/
|
|
1961
|
+
interface StaleMigrationImportIR {
|
|
1962
|
+
/** Source file relative to the lunora dir, no extension. */
|
|
1963
|
+
file: string;
|
|
1964
|
+
/** 1-based line of the import, or `0` when unknown. */
|
|
1965
|
+
line: number;
|
|
1966
|
+
/** The imported module, e.g. `@supabase/supabase-js`. */
|
|
1967
|
+
moduleSpecifier: string;
|
|
1968
|
+
/** Which migration guide covers this platform. */
|
|
1969
|
+
platform: "convex" | "firebase" | "supabase";
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Named inputs for {@link lintSchema}. Every feeder is a discrete key rather than
|
|
1973
|
+
* a positional argument: the feeder list grows every few releases and many IR
|
|
1974
|
+
* types are structurally similar (`{file, exportName, line}`-shaped evidence),
|
|
1975
|
+
* so a positional call was a silent-transposition hazard — swapping two adjacent
|
|
1976
|
+
* arguments could typecheck yet feed the wrong evidence to the wrong lint and
|
|
1977
|
+
* corrupt a security advisory. `schema` is the only required field; every other
|
|
1978
|
+
* feeder defaults to "not analyzed" when omitted.
|
|
1979
|
+
*/
|
|
1980
|
+
interface LintSchemaOptions {
|
|
1981
|
+
adminRoutes?: ReadonlyArray<AdminRouteIR>;
|
|
1982
|
+
aiRawRuns?: ReadonlyArray<AiRawRunIR>;
|
|
1983
|
+
aiToolSideEffects?: ReadonlyArray<AiToolSideEffectIR>;
|
|
1984
|
+
argumentDerivedFetches?: ReadonlyArray<ArgumentDerivedFetchIR>;
|
|
1985
|
+
argumentValidators?: ReadonlyArray<ArgumentValidatorIR>;
|
|
1986
|
+
authApiCalls?: ReadonlyArray<AuthApiCallIR>;
|
|
1987
|
+
authConfigs?: ReadonlyArray<AuthConfigIR>;
|
|
1988
|
+
browserUrlAccesses?: ReadonlyArray<BrowserUrlAccessIR>;
|
|
1989
|
+
configCalls?: ReadonlyArray<ConfigCallIR>;
|
|
1990
|
+
containerKeyAccesses?: ReadonlyArray<ContainerKeyAccessIR>;
|
|
1991
|
+
containerOverrides?: ReadonlyArray<ContainerOverrideIR>;
|
|
1992
|
+
containers?: ReadonlyArray<ContainerIR>;
|
|
1993
|
+
exportSinks?: ReadonlyArray<AdvisorExportSink>;
|
|
1994
|
+
failOpenGuards?: ReadonlyArray<FailOpenGuardIR>;
|
|
1995
|
+
flagSecurityDefaults?: ReadonlyArray<FlagSecurityDefaultIR>;
|
|
1996
|
+
geoIndexUsages?: ReadonlyArray<AdvisorGeoIndexUsage>;
|
|
1997
|
+
httpActionGuards?: ReadonlyArray<HttpActionGuardIR>;
|
|
1998
|
+
httpHeaderWrites?: ReadonlyArray<HttpHeaderWriteIR>;
|
|
1999
|
+
identityClaimReads?: ReadonlyArray<IdentityClaimReadIR>;
|
|
2000
|
+
imageDeliveryUrlAccesses?: ReadonlyArray<ImageDeliveryUrlAccessIR>;
|
|
2001
|
+
inserts?: ReadonlyArray<InsertWriteIR>;
|
|
2002
|
+
kvKeyAccesses?: ReadonlyArray<KvKeyAccessIR>;
|
|
2003
|
+
mailRecipientAccesses?: ReadonlyArray<MailRecipientAccessIR>;
|
|
2004
|
+
maskProcedures?: ReadonlyArray<MaskProcedureIR>;
|
|
2005
|
+
maskStrategies?: ReadonlyArray<MaskStrategyIR>;
|
|
2006
|
+
mutatorWrites?: ReadonlyArray<MutatorWriteIR>;
|
|
2007
|
+
nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>;
|
|
2008
|
+
normalizeIdAuthorizations?: ReadonlyArray<NormalizeIdAuthorizationIR>;
|
|
2009
|
+
notifyCalls?: ReadonlyArray<AdvisorNotifyCall>;
|
|
2010
|
+
notifyConfig?: AdvisorNotifyConfig;
|
|
2011
|
+
ownerFieldWrites?: ReadonlyArray<OwnerFieldWriteIR>;
|
|
2012
|
+
paymentWebhooks?: ReadonlyArray<PaymentWebhookIR>;
|
|
2013
|
+
privilegedDispatches?: ReadonlyArray<PrivilegedDispatchIR>;
|
|
2014
|
+
procedureProtections?: ReadonlyArray<ProcedureMiddlewareIR>;
|
|
2015
|
+
queries?: ReadonlyArray<QueryReadIR>;
|
|
2016
|
+
queues?: ReadonlyArray<QueueIR>;
|
|
2017
|
+
r2sqlCalls?: ReadonlyArray<R2sqlCallIR>;
|
|
2018
|
+
ratelimitKeySelectors?: ReadonlyArray<RatelimitKeySelectorIR>;
|
|
2019
|
+
rawRowReturns?: ReadonlyArray<RawRowReturnIR>;
|
|
2020
|
+
relationLoads?: ReadonlyArray<RelationLoadIR>;
|
|
2021
|
+
rlsProcedures?: ReadonlyArray<RlsProcedureIR>;
|
|
2022
|
+
schema: SchemaIR;
|
|
2023
|
+
secretLiterals?: ReadonlyArray<SecretLiteralIR>;
|
|
2024
|
+
shapes?: ReadonlyArray<ShapeIR>;
|
|
2025
|
+
softDeleteReads?: ReadonlyArray<SoftDeleteReadIR>;
|
|
2026
|
+
sqlInterpolations?: ReadonlyArray<SqlInterpolationIR>;
|
|
2027
|
+
staleMigrationImports?: ReadonlyArray<StaleMigrationImportIR>;
|
|
2028
|
+
storageKeyAccesses?: ReadonlyArray<StorageKeyAccessIR>;
|
|
2029
|
+
storageUploads?: ReadonlyArray<StorageUploadIR>;
|
|
2030
|
+
unrestrictedWhereBranches?: ReadonlyArray<UnrestrictedWhereBranchIR>;
|
|
2031
|
+
vectorNamespaceAccesses?: ReadonlyArray<VectorNamespaceAccessIR>;
|
|
2032
|
+
workflowCalls?: ReadonlyArray<WorkflowCallIR>;
|
|
2033
|
+
workflows?: ReadonlyArray<WorkflowIR>;
|
|
2034
|
+
wranglerVariables?: ReadonlyArray<WranglerVariableIR>;
|
|
2035
|
+
}
|
|
2036
|
+
/**
|
|
2037
|
+
* Normalize feeder options into the advisor's {@link LintContext} — the input
|
|
2038
|
+
* both `runAdvisor` and `scoreAdvisor` take. Shared by {@link lintSchema} so the
|
|
2039
|
+
* lint run and the scored map always see byte-identical evidence.
|
|
2040
|
+
*
|
|
2041
|
+
* Exported instead of a `mapSchema(options)` convenience that lints *and* scores:
|
|
2042
|
+
* such a wrapper would either re-run every rule or need a `findings` escape hatch
|
|
2043
|
+
* nothing could validate against its `options`, so mismatched findings would
|
|
2044
|
+
* silently produce a wrong map. Two lines at the call site buys that away:
|
|
2045
|
+
*
|
|
2046
|
+
* ```ts
|
|
2047
|
+
* const context = toAdvisorContext(options);
|
|
2048
|
+
* const map = scoreAdvisor(context.procedureProtections ?? [], runAdvisor(context, { source: "static" }));
|
|
2049
|
+
* ```
|
|
2050
|
+
*/
|
|
2051
|
+
declare const toAdvisorContext: (options: LintSchemaOptions) => LintContext;
|
|
2052
|
+
/**
|
|
2053
|
+
* Run the static lints against a discovered {@link SchemaIR} and the reads/writes/calls
|
|
2054
|
+
* found in function bodies: query reads feed `filter_without_index`, insert writes
|
|
2055
|
+
* feed `table_without_insert`, authApi calls feed `auth_api_call_without_headers`,
|
|
2056
|
+
* rls procedure snapshots feed `rls_uncovered_table`, mask procedure
|
|
2057
|
+
* snapshots feed `mask_uncovered_pii_column`, and per-column mask strategies
|
|
2058
|
+
* feed `mask_weak_hash_strategy_on_pii`; declared containers
|
|
2059
|
+
* feed the `container_*` lints; declared workflows (with their durable step labels)
|
|
2060
|
+
* + `ctx.workflows.get(...)` call sites feed the `workflow_unused` /
|
|
2061
|
+
* `workflow_unknown_target` / duplicate-step-name lints; non-deterministic
|
|
2062
|
+
* calls inside query/mutation handlers feed the `nondeterministic_query_mutation` lint
|
|
2063
|
+
* (all default empty for callers that don't analyze functions/containers/workflows).
|
|
2064
|
+
* The IR types are structurally identical to the advisor's evidence types so they
|
|
2065
|
+
* pass straight through without conversion. Returns the findings; surfacing them
|
|
2066
|
+
* (console, error overlay, studio Advisors table) is the caller's choice.
|
|
2067
|
+
*/
|
|
2068
|
+
declare const lintSchema: (options: LintSchemaOptions) => Finding[];
|
|
2069
|
+
/**
|
|
2070
|
+
* Render advisor findings as a single multi-line string for console surfacing:
|
|
2071
|
+
* a one-line summary header followed by one `[LEVEL] name: detail` line per
|
|
2072
|
+
* finding. Returns `""` when there are no findings.
|
|
2073
|
+
*/
|
|
2074
|
+
declare const formatAdvisories: (findings: ReadonlyArray<Finding>) => string;
|
|
2075
|
+
/**
|
|
2076
|
+
* The canonical capability list. **Order is load-bearing** for the `emit-app.ts`
|
|
2077
|
+
* long-tail: the fluent methods are emitted in the order the `appMethod`-bearing
|
|
2078
|
+
* rows appear here, so this array is ordered to reproduce the original
|
|
2079
|
+
* `LONG_TAIL` sequence (ai, analytics, browser, hyperdrive, images, kv, payment,
|
|
2080
|
+
* r2sql, vectors). The `serverCtxField` rows are referenced by name in the ctx
|
|
2081
|
+
* interface templates, so their order here is not output-affecting.
|
|
2082
|
+
*/
|
|
2083
|
+
declare const CAPABILITY_ROWS: readonly [{
|
|
2084
|
+
readonly contextProperty: "access";
|
|
2085
|
+
readonly key: "access";
|
|
2086
|
+
readonly moduleSpecifier: "@lunora/cloudflare-access";
|
|
2087
|
+
}, {
|
|
2088
|
+
readonly appMethod: {
|
|
2089
|
+
readonly configKey: "ai";
|
|
2090
|
+
readonly doc: "Override the Workers AI binding backing `ctx.ai` (defaults to `env.AI`).";
|
|
2091
|
+
readonly method: "ai";
|
|
2092
|
+
};
|
|
2093
|
+
readonly contextProperty: "ai";
|
|
2094
|
+
readonly key: "ai";
|
|
2095
|
+
readonly moduleSpecifier: "@lunora/ai";
|
|
2096
|
+
}, {
|
|
2097
|
+
readonly appMethod: {
|
|
2098
|
+
readonly configKey: "analytics";
|
|
2099
|
+
readonly doc: "Override the Analytics Engine dataset backing `ctx.analytics` (defaults to `env.ANALYTICS`).";
|
|
2100
|
+
readonly method: "analytics";
|
|
2101
|
+
};
|
|
2102
|
+
readonly contextProperty: "analytics";
|
|
2103
|
+
readonly key: "analytics";
|
|
2104
|
+
readonly moduleSpecifier: "@lunora/bindings/analytics";
|
|
2105
|
+
readonly serverCtxField: {
|
|
2106
|
+
readonly field: "\n /** Analytics Engine telemetry sink. Fire-and-forget and sampled; do not read it back in-handler. */\n readonly analytics: import(\"@lunora/bindings/analytics\").AnalyticsClient;";
|
|
2107
|
+
readonly tier: "every";
|
|
2108
|
+
};
|
|
2109
|
+
}, {
|
|
2110
|
+
readonly appMethod: {
|
|
2111
|
+
readonly configKey: "browser";
|
|
2112
|
+
readonly doc: "Override the Browser Rendering binding backing `ctx.browser` (defaults to `env.BROWSER`).";
|
|
2113
|
+
readonly method: "browser";
|
|
2114
|
+
};
|
|
2115
|
+
readonly contextProperty: "browser";
|
|
2116
|
+
readonly key: "browser";
|
|
2117
|
+
readonly moduleSpecifier: "@lunora/browser";
|
|
2118
|
+
readonly serverCtxField: {
|
|
2119
|
+
readonly field: "\n /** Browser Rendering (screenshots/PDF/scrape). Non-deterministic — available only in actions. */\n readonly browser: import(\"@lunora/browser\").Browser;";
|
|
2120
|
+
readonly tier: "action";
|
|
2121
|
+
};
|
|
2122
|
+
}, {
|
|
2123
|
+
readonly contextProperty: "containers";
|
|
2124
|
+
readonly key: "container";
|
|
2125
|
+
readonly moduleSpecifier: "@lunora/container";
|
|
2126
|
+
}, {
|
|
2127
|
+
readonly contextProperty: "flags";
|
|
2128
|
+
readonly key: "flags";
|
|
2129
|
+
readonly moduleSpecifier: "@lunora/flags";
|
|
2130
|
+
}, {
|
|
2131
|
+
readonly appMethod: {
|
|
2132
|
+
readonly configKey: "sql";
|
|
2133
|
+
readonly doc: "Wire the Hyperdrive SQL client backing `ctx.sql` — build it with `createHyperdrive` + `fromPostgresJs`/`fromNodePg`/`fromMysql2`.";
|
|
2134
|
+
readonly method: "hyperdrive";
|
|
2135
|
+
};
|
|
2136
|
+
readonly contextProperty: "sql";
|
|
2137
|
+
readonly key: "hyperdrive";
|
|
2138
|
+
readonly moduleSpecifier: "@lunora/hyperdrive";
|
|
2139
|
+
readonly serverCtxField: {
|
|
2140
|
+
readonly field: "\n /**\n * External database access via Hyperdrive. Non-deterministic — available only in actions. Writes here are NOT tracked by Lunora live queries; subscriptions will not re-run on external DB changes.\n */\n readonly sql: import(\"@lunora/hyperdrive\").SqlClient;";
|
|
2141
|
+
readonly tier: "action";
|
|
2142
|
+
};
|
|
2143
|
+
}, {
|
|
2144
|
+
readonly appMethod: {
|
|
2145
|
+
readonly configKey: "images";
|
|
2146
|
+
readonly doc: "Override the Images binding backing `ctx.images` (defaults to `env.IMAGES`).";
|
|
2147
|
+
readonly method: "images";
|
|
2148
|
+
};
|
|
2149
|
+
readonly contextProperty: "images";
|
|
2150
|
+
readonly key: "images";
|
|
2151
|
+
readonly moduleSpecifier: "@lunora/bindings/images";
|
|
2152
|
+
readonly serverCtxField: {
|
|
2153
|
+
readonly field: "\n /** Cloudflare Images transforms (resize/format/optimize). Non-deterministic — available only in actions. */\n readonly images: import(\"@lunora/bindings/images\").Images;";
|
|
2154
|
+
readonly tier: "action";
|
|
2155
|
+
};
|
|
2156
|
+
}, {
|
|
2157
|
+
readonly appMethod: {
|
|
2158
|
+
readonly configKey: "kv";
|
|
2159
|
+
readonly doc: "Override the Workers KV binding backing `ctx.kv` (defaults to `env.KV`).";
|
|
2160
|
+
readonly method: "kv";
|
|
2161
|
+
};
|
|
2162
|
+
readonly contextProperty: "kv";
|
|
2163
|
+
readonly key: "kv";
|
|
2164
|
+
readonly moduleSpecifier: "@lunora/bindings/kv";
|
|
2165
|
+
readonly serverCtxField: {
|
|
2166
|
+
readonly field: "\n readonly kv: import(\"@lunora/bindings/kv\").Kv;";
|
|
2167
|
+
readonly tier: "every";
|
|
2168
|
+
};
|
|
2169
|
+
}, {
|
|
2170
|
+
readonly key: "mail";
|
|
2171
|
+
readonly moduleSpecifier: "@lunora/mail";
|
|
2172
|
+
}, {
|
|
2173
|
+
readonly contextProperty: "notify";
|
|
2174
|
+
readonly key: "notify";
|
|
2175
|
+
readonly moduleSpecifier: "@lunora/notify";
|
|
2176
|
+
}, {
|
|
2177
|
+
readonly appMethod: {
|
|
2178
|
+
readonly configKey: "payment";
|
|
2179
|
+
readonly doc: "Wire the payment options backing `ctx.payments`.";
|
|
2180
|
+
readonly method: "payment";
|
|
2181
|
+
};
|
|
2182
|
+
readonly contextProperty: "payments";
|
|
2183
|
+
readonly key: "payments";
|
|
2184
|
+
readonly moduleSpecifier: "@lunora/payment";
|
|
2185
|
+
}, {
|
|
2186
|
+
readonly appMethod: {
|
|
2187
|
+
readonly configKey: "x402";
|
|
2188
|
+
readonly doc: "Wire the x402 agent-wallet pay rail backing `ctx.x402` — a payment-enabled `fetch` that answers `402` challenges under a mandatory spend policy (ActionCtx-only; spends real funds).";
|
|
2189
|
+
readonly method: "x402";
|
|
2190
|
+
};
|
|
2191
|
+
readonly contextProperty: "x402";
|
|
2192
|
+
readonly key: "x402";
|
|
2193
|
+
readonly moduleSpecifier: "@lunora/x402/pay";
|
|
2194
|
+
}, {
|
|
2195
|
+
readonly contextProperty: "pipelines";
|
|
2196
|
+
readonly key: "pipelines";
|
|
2197
|
+
readonly moduleSpecifier: "@lunora/bindings/pipelines";
|
|
2198
|
+
readonly serverCtxField: {
|
|
2199
|
+
readonly field: "\n /** Pipelines ingestion sink (durable, R2-backed). Fire-and-forget and batched; do not read it back in-handler. */\n readonly pipelines: import(\"@lunora/bindings/pipelines\").PipelineClient;";
|
|
2200
|
+
readonly tier: "action";
|
|
2201
|
+
};
|
|
2202
|
+
}, {
|
|
2203
|
+
readonly appMethod: {
|
|
2204
|
+
readonly configKey: "r2sql";
|
|
2205
|
+
readonly doc: "Wire the R2 SQL client backing `ctx.r2sql` — build it with `createR2Sql({ accountId, apiToken, bucket })` (defaults to env `R2_SQL_TOKEN` / `R2_SQL_ACCOUNT_ID` / `R2_SQL_BUCKET`).";
|
|
2206
|
+
readonly method: "r2sql";
|
|
2207
|
+
};
|
|
2208
|
+
readonly contextProperty: "r2sql";
|
|
2209
|
+
readonly key: "r2sql";
|
|
2210
|
+
readonly moduleSpecifier: "@lunora/bindings/r2sql";
|
|
2211
|
+
readonly serverCtxField: {
|
|
2212
|
+
readonly field: "\n /**\n * R2 SQL over Apache Iceberg tables (window functions, DISTINCT, set operations). Non-deterministic — available only in actions. Reads here are NOT tracked by Lunora live queries.\n */\n readonly r2sql: import(\"@lunora/bindings/r2sql\").R2SqlClient;";
|
|
2213
|
+
readonly tier: "action";
|
|
2214
|
+
};
|
|
2215
|
+
}, {
|
|
2216
|
+
readonly contextProperty: "scheduler";
|
|
2217
|
+
readonly key: "scheduler";
|
|
2218
|
+
readonly moduleSpecifier: "@lunora/scheduler";
|
|
2219
|
+
}, {
|
|
2220
|
+
readonly contextProperty: "storage";
|
|
2221
|
+
readonly key: "storage";
|
|
2222
|
+
readonly moduleSpecifier: "@lunora/storage";
|
|
2223
|
+
}, {
|
|
2224
|
+
readonly appMethod: {
|
|
2225
|
+
readonly configKey: "vectors";
|
|
2226
|
+
readonly doc: "Wire the Vectorize index map backing `ctx.vectors`.";
|
|
2227
|
+
readonly method: "vectors";
|
|
2228
|
+
};
|
|
2229
|
+
readonly contextProperty: "vectors";
|
|
2230
|
+
readonly key: "vectors";
|
|
2231
|
+
readonly moduleSpecifier: "@lunora/bindings/vectors";
|
|
2232
|
+
}, {
|
|
2233
|
+
readonly contextProperty: "workflows";
|
|
2234
|
+
readonly key: "workflows";
|
|
2235
|
+
readonly moduleSpecifier: "@lunora/workflow";
|
|
2236
|
+
}];
|
|
2237
|
+
/** The literal union of every capability id — the single source of truth for `FeatureUsage`'s keys (so they cannot drift). */
|
|
2238
|
+
type CapabilityKey = (typeof CAPABILITY_ROWS)[number]["key"];
|
|
2239
|
+
/** The default codegen target — today's behavior, byte-identical goldens. */
|
|
2240
|
+
declare const DEFAULT_TARGET = "cloudflare";
|
|
2241
|
+
/**
|
|
2242
|
+
* Read `target` from `<projectRoot>/lunora.json`.
|
|
2243
|
+
*
|
|
2244
|
+
* This lives in `@lunora/codegen` rather than `@lunora/config` — where the rest
|
|
2245
|
+
* of the `lunora.json` reading lives — because `@lunora/config` depends on
|
|
2246
|
+
* `@lunora/codegen`, not the reverse. Putting it there and importing it here
|
|
2247
|
+
* would invert that edge, so config delegates to this instead and there is
|
|
2248
|
+
* still exactly one parser for the key.
|
|
2249
|
+
*
|
|
2250
|
+
* Best-effort and deliberately unvalidated: a missing file, malformed JSONC, or
|
|
2251
|
+
* a non-string value all collapse to `undefined`, because those are shape
|
|
2252
|
+
* errors rather than a name the user meant. An unrecognized *name* is returned
|
|
2253
|
+
* as-is so the caller's registry lookup rejects it — swallowing a typo into the
|
|
2254
|
+
* default would ship an app to the wrong provider.
|
|
2255
|
+
* @param projectRoot Directory containing `lunora.json`.
|
|
2256
|
+
* @returns the declared target, or `undefined` when none is usable.
|
|
2257
|
+
*/
|
|
2258
|
+
declare const readProjectTarget: (projectRoot: string) => string | undefined;
|
|
2259
|
+
/**
|
|
2260
|
+
* The target codegen should emit for: an explicit option wins, then
|
|
2261
|
+
* `lunora.json`, then the default.
|
|
2262
|
+
*
|
|
2263
|
+
* `runCodegen` applies this itself so a caller that forgets to pass a target
|
|
2264
|
+
* still emits the surface the project declared. That default matters more than
|
|
2265
|
+
* it looks: a call site that silently omits the target emits the *default*
|
|
2266
|
+
* surface with no diagnostic to notice, and the mismatch only shows up at
|
|
2267
|
+
* runtime on the deployed app.
|
|
2268
|
+
* @param projectRoot Directory containing `lunora.json`.
|
|
2269
|
+
* @param explicit A caller-supplied target, if any.
|
|
2270
|
+
* @returns the resolved target id — not guaranteed to be registered.
|
|
2271
|
+
*/
|
|
2272
|
+
declare const resolveCodegenTarget: (projectRoot: string, explicit?: string) => string;
|
|
2273
|
+
/**
|
|
2274
|
+
* The target ids codegen can gate against.
|
|
2275
|
+
*
|
|
2276
|
+
* `@lunora/config`'s driver registry (`deployTargetIds`) used to assert
|
|
2277
|
+
* equality against this — "two id spaces for one concept" — on the theory that
|
|
2278
|
+
* a target with a matrix but no driver "gates a surface nothing can deploy."
|
|
2279
|
+
* Plan 234 found that reasoning incomplete by registering `node` here: a
|
|
2280
|
+
* codegen-gateable target and a deployable target are genuinely different
|
|
2281
|
+
* questions, and a spike/dev-only host answers the first "yes" and the second
|
|
2282
|
+
* "not yet" without that being a bug in either registry. See
|
|
2283
|
+
* `plans/234-node-host-findings.md` for the finding and `@lunora/config`'s
|
|
2284
|
+
* `project-config.test.ts` for where the now-relaxed invariant lives.
|
|
2285
|
+
* @returns the registered matrix ids, sorted.
|
|
2286
|
+
*/
|
|
2287
|
+
declare const platformMatrixIds: () => ReadonlyArray<string>;
|
|
2288
|
+
/** An advisor-style diagnostic about a target's platform capabilities. */
|
|
2289
|
+
interface PlatformDiagnostic {
|
|
2290
|
+
/** The codegen capability this concerns, when it is feature-specific. */
|
|
2291
|
+
feature?: CapabilityKey;
|
|
2292
|
+
/** Severity. All three names are errors — each drops or misdirects an emitted surface. */
|
|
2293
|
+
level: "error" | "warn";
|
|
2294
|
+
/** Human-readable explanation of the gap. */
|
|
2295
|
+
message: string;
|
|
2296
|
+
/** The lint id: `platform_unsupported_feature`, `platform_undeclared_feature`, or `platform_unknown_target`. */
|
|
2297
|
+
name: "platform_undeclared_feature" | "platform_unknown_target" | "platform_unsupported_feature";
|
|
2298
|
+
/** How to resolve it. */
|
|
2299
|
+
remediation: string;
|
|
2300
|
+
/** The requested deploy target. */
|
|
2301
|
+
target: string;
|
|
2302
|
+
}
|
|
2303
|
+
/**
|
|
2304
|
+
* Committed, tracked baseline file holding the blessed structural schema
|
|
2305
|
+
* snapshot the pre-deploy drift gate diffs against. Lives in `lunora/` (NOT the
|
|
2306
|
+
* gitignored `_generated/`) so it is committed alongside `schema.ts`. Leading
|
|
2307
|
+
* dot keeps it tucked away next to the schema it describes.
|
|
2308
|
+
*/
|
|
2309
|
+
declare const SCHEMA_SNAPSHOT_FILENAME = ".lunora-schema.json";
|
|
2310
|
+
/**
|
|
2311
|
+
* Construct the ts-morph `Project` codegen discovers over. Prefers the user's
|
|
2312
|
+
* `tsconfig.json` (when one is found walking up from `lunoraDirectory`) so
|
|
2313
|
+
* cross-file type resolution and path aliases work; falls back to an isolated
|
|
2314
|
+
* project otherwise. This is the exact construction {@link runCodegen} uses
|
|
2315
|
+
* when no `project` is injected — exported so a long-lived caller (the Vite
|
|
2316
|
+
* dev-loop) can build one once and reuse it across runs via
|
|
2317
|
+
* {@link refreshCodegenProject} instead of re-parsing the user's whole TS
|
|
2318
|
+
* program on every save.
|
|
2319
|
+
*/
|
|
2320
|
+
declare const createCodegenProject: (lunoraDirectory: string) => Project;
|
|
2321
|
+
/**
|
|
2322
|
+
* Synchronise a reused {@link createCodegenProject} Project with the current
|
|
2323
|
+
* on-disk state of `lunoraDirectory`, so the next {@link runCodegen} sees the
|
|
2324
|
+
* same files a freshly-constructed Project would — without re-parsing the whole
|
|
2325
|
+
* TS program. Adds any on-disk source file the Project doesn't yet have, and
|
|
2326
|
+
* `refreshFromFileSystemSync()`es the ones it does (picking up edits); then
|
|
2327
|
+
* removes Project source files under `lunoraDirectory` that no longer exist on
|
|
2328
|
+
* disk (the classic stale-deleted-file cache bug).
|
|
2329
|
+
*
|
|
2330
|
+
* Files outside `lunoraDirectory` (e.g. those pulled in by the user's tsconfig)
|
|
2331
|
+
* are left untouched — they back type resolution and rarely change in the
|
|
2332
|
+
* dev-loop; a tsconfig change invalidates the whole cached Project upstream.
|
|
2333
|
+
*/
|
|
2334
|
+
declare const refreshCodegenProject: (project: Project, lunoraDirectory: string) => void;
|
|
2335
|
+
/**
|
|
2336
|
+
* Top-level codegen entry. Parses `<projectRoot>/lunora/schema.ts` and every
|
|
2337
|
+
* function file under `<projectRoot>/lunora/`, then writes
|
|
2338
|
+
* `_generated/{api,server,dataModel}.ts` next to them.
|
|
2339
|
+
*
|
|
2340
|
+
* When `LUNORA_CODEGEN_TIMING` is set (truthy), a single diagnostic summary
|
|
2341
|
+
* line is written to stderr with the total wall time and the discovery-vs-emit
|
|
2342
|
+
* split — opt-in instrumentation that is otherwise zero-cost and side-effect-free
|
|
2343
|
+
* on the returned {@link CodegenResult}.
|
|
2344
|
+
*/
|
|
2345
|
+
declare const runCodegen: (options: CodegenOptions) => CodegenResult;
|
|
2346
|
+
interface CodegenOptions {
|
|
2347
|
+
/**
|
|
2348
|
+
* Which machine-readable API spec(s) to emit into `_generated/`.
|
|
2349
|
+
*
|
|
2350
|
+
* `"openapi"` (the default) writes only `openapi.json` (OpenAPI 3.1; covers
|
|
2351
|
+
* both the RPC functions and `httpRouter()` REST routes). `"openrpc"` writes
|
|
2352
|
+
* only `openrpc.json` (OpenRPC 1.x; the RPC functions only — OpenRPC cannot
|
|
2353
|
+
* represent REST routes). `"both"` writes both files; `"none"` writes neither.
|
|
2354
|
+
*
|
|
2355
|
+
* Regardless of the choice, `CodegenResult.generated.openApi` and `.openRpc`
|
|
2356
|
+
* always carry the rendered string (computation is cheap and pure); only the
|
|
2357
|
+
* on-disk write is gated by this option.
|
|
2358
|
+
*/
|
|
2359
|
+
apiSpec?: "both" | "none" | "openapi" | "openrpc";
|
|
2360
|
+
/**
|
|
2361
|
+
* When true, run discovery + emit (so any schema/function parse error
|
|
2362
|
+
* surfaces) but skip writing files to `_generated/`. The returned
|
|
2363
|
+
* `outputDirectory` is still the path that *would* have been written.
|
|
2364
|
+
*/
|
|
2365
|
+
dryRun?: boolean;
|
|
2366
|
+
/**
|
|
2367
|
+
* Run the static schema advisor (unindexed FKs, …) during codegen.
|
|
2368
|
+
* Defaults to `true`. When `false`, `CodegenResult.advisories` is empty.
|
|
2369
|
+
* Computed regardless of `dryRun`; codegen never prints them — see
|
|
2370
|
+
* {@link CodegenResult.advisories}.
|
|
2371
|
+
*/
|
|
2372
|
+
lint?: boolean;
|
|
2373
|
+
/** Override the lunora subdirectory name. Defaults to `"lunora"`. */
|
|
2374
|
+
lunoraDirectory?: string;
|
|
2375
|
+
/**
|
|
2376
|
+
* Reuse a previously-constructed ts-morph {@link Project} instead of building
|
|
2377
|
+
* a fresh one each run. The caller owns refreshing its source files from disk
|
|
2378
|
+
* (see {@link refreshCodegenProject}) — codegen does not re-read changed files
|
|
2379
|
+
* off an injected Project. Built via {@link createCodegenProject} when absent.
|
|
2380
|
+
* Used by the Vite dev-loop to avoid re-parsing the whole TS program on every
|
|
2381
|
+
* save; omit it (CLI one-shot path) to get the default fresh-Project behaviour.
|
|
2382
|
+
*/
|
|
2383
|
+
project?: Project;
|
|
2384
|
+
/** Project root containing the `lunora/` directory. */
|
|
2385
|
+
projectRoot: string;
|
|
2386
|
+
/**
|
|
2387
|
+
* The deploy target codegen tailors the emitted `ctx.*` surface to.
|
|
2388
|
+
* Defaults to `"cloudflare"` — whose capability matrix marks every feature
|
|
2389
|
+
* native or emulated, so the default output is unchanged (byte-identical
|
|
2390
|
+
* goldens). A target that marks a used feature unsupported omits its
|
|
2391
|
+
* `ctx.*` surface and reports it in {@link CodegenResult.platformDiagnostics}.
|
|
2392
|
+
* Only `"cloudflare"` is registered until other per-target `@lunora/platform`
|
|
2393
|
+
* matrices land; an unknown target emits the full surface un-gated and a
|
|
2394
|
+
* `platform_unknown_target` diagnostic.
|
|
2395
|
+
*/
|
|
2396
|
+
target?: string;
|
|
2397
|
+
/**
|
|
2398
|
+
* Re-bless the committed schema-drift baseline (`lunora/.lunora-schema.json`)
|
|
2399
|
+
* with the current structural snapshot. The baseline is ALWAYS written on
|
|
2400
|
+
* first capture (when the file is absent); set this to overwrite an existing
|
|
2401
|
+
* one — e.g. after the developer has added the data migration that justifies
|
|
2402
|
+
* a breaking change. Ignored when `dryRun` is true.
|
|
2403
|
+
*/
|
|
2404
|
+
updateSchemaBaseline?: boolean;
|
|
2405
|
+
/**
|
|
2406
|
+
* Committed `wrangler.jsonc` `vars` entries that hold plaintext secrets — the
|
|
2407
|
+
* `plaintext_secret_in_wrangler_vars` lint input. Produced by `@lunora/config`
|
|
2408
|
+
* (which reads `wrangler.jsonc`) and threaded through by the CLI / Vite plugin;
|
|
2409
|
+
* codegen only forwards it to the advisor. Absent when no wrangler config is
|
|
2410
|
+
* present or the caller doesn't scan it.
|
|
2411
|
+
*/
|
|
2412
|
+
wranglerVariables?: ReadonlyArray<WranglerVariableIR>;
|
|
2413
|
+
}
|
|
2414
|
+
interface CodegenResult {
|
|
2415
|
+
/**
|
|
2416
|
+
* The normalized advisor evidence the findings were produced from, so a
|
|
2417
|
+
* caller can score it into a health map (`scoreAdvisor`) without re-running
|
|
2418
|
+
* discovery. `undefined` under `lint: false`.
|
|
2419
|
+
*
|
|
2420
|
+
* Deliberately not scored here: the map carries a `generatedAt` stamp, and
|
|
2421
|
+
* codegen's result stays a pure function of the sources.
|
|
2422
|
+
*/
|
|
2423
|
+
advisorContext?: LintContext;
|
|
2424
|
+
/**
|
|
2425
|
+
* Static schema advisor findings (e.g. unindexed foreign keys) produced
|
|
2426
|
+
* this run. Empty when `lint` is `false` or the schema is clean. Codegen
|
|
2427
|
+
* does not print these itself — each caller presents them through its own
|
|
2428
|
+
* channel (the CLI logger, the vite overlay, the studio Advisors table).
|
|
2429
|
+
* `formatAdvisories` is exported for a plain multi-line rendering.
|
|
2430
|
+
*/
|
|
2431
|
+
advisories: ReadonlyArray<Finding>;
|
|
2432
|
+
/**
|
|
2433
|
+
* Agents discovered from `defineAgent` exports in `lunora/agents.ts` — the
|
|
2434
|
+
* list the config layer reconciles into wrangler's `workflows[]` array (an
|
|
2435
|
+
* agent compiles onto a Cloudflare Workflow). Agents are NOT Durable Objects,
|
|
2436
|
+
* so this adds no binding or migration. Empty when the project declares none.
|
|
2437
|
+
*/
|
|
2438
|
+
agents: ReadonlyArray<AgentIR>;
|
|
2439
|
+
/**
|
|
2440
|
+
* Containers discovered from `defineContainer` exports in
|
|
2441
|
+
* `lunora/containers.ts` — the list the config layer reconciles into
|
|
2442
|
+
* wrangler's `containers[]`, `CONTAINER_*` Durable Object bindings, and
|
|
2443
|
+
* migration classes. Empty when the project declares no containers.
|
|
2444
|
+
*/
|
|
2445
|
+
containers: ReadonlyArray<ContainerIR>;
|
|
2446
|
+
/**
|
|
2447
|
+
* Deduplicated cron schedules discovered from `cronJobs()` definitions —
|
|
2448
|
+
* the array the vite plugin reconciles into `wrangler.jsonc`'s
|
|
2449
|
+
* `triggers.crons`. Empty when the project declares no crons.
|
|
2450
|
+
*/
|
|
2451
|
+
cronTriggers: ReadonlyArray<string>;
|
|
2452
|
+
generated: {
|
|
2453
|
+
/** WorkflowEntrypoint classes for declared agents (`_generated/agents.ts`); `""` (and not written) when no agents are declared. */
|
|
2454
|
+
agents: string;
|
|
2455
|
+
api: string;
|
|
2456
|
+
/** Fluent worker-composition builder (`_generated/app.ts`) — `defineApp()`. Always written. */
|
|
2457
|
+
app: string;
|
|
2458
|
+
/** Partial-replication collection factories (`_generated/collections.ts`); `""` (and not written) unless the project declares shapes and installs `@lunora/db`. */
|
|
2459
|
+
collections: string;
|
|
2460
|
+
/** Container DO classes (`_generated/containers.ts`); `""` (and not written) when no containers are declared. */
|
|
2461
|
+
containers: string;
|
|
2462
|
+
crons: string;
|
|
2463
|
+
dataModel: string;
|
|
2464
|
+
drizzleGlobal: string;
|
|
2465
|
+
drizzleShard: string;
|
|
2466
|
+
functions: string;
|
|
2467
|
+
/** OpenAPI 3.1.0 document (`_generated/openapi.json`), pretty-printed JSON. */
|
|
2468
|
+
openApi: string;
|
|
2469
|
+
/**
|
|
2470
|
+
* OpenAPI document as an importable TS module (`_generated/openapi.ts`) —
|
|
2471
|
+
* `export const openApiSpec`, the worker imports it for
|
|
2472
|
+
* `createWorker({ openApiSpec })`. Same document as `openApi`. Written
|
|
2473
|
+
* alongside `openapi.json` whenever `apiSpec` includes `openapi`.
|
|
2474
|
+
*/
|
|
2475
|
+
openApiModule: string;
|
|
2476
|
+
/** OpenRPC 1.x document (`_generated/openrpc.json`), pretty-printed JSON. Always computed; written only when `apiSpec` includes `openrpc`. */
|
|
2477
|
+
openRpc: string;
|
|
2478
|
+
/**
|
|
2479
|
+
* OpenRPC document as an importable TS module (`_generated/openrpc.ts`) —
|
|
2480
|
+
* `export const openRpcSpec`, for `createWorker({ openRpcSpec })`. Same
|
|
2481
|
+
* document as `openRpc`. Written alongside `openrpc.json` whenever
|
|
2482
|
+
* `apiSpec` includes `openrpc`.
|
|
2483
|
+
*/
|
|
2484
|
+
openRpcModule: string;
|
|
2485
|
+
/** Push-consumer queue registry (`_generated/queues.ts`); `""` (and not written) when no push queues are declared. */
|
|
2486
|
+
queues: string;
|
|
2487
|
+
/** Project-bound seed client (`_generated/seed.ts`); `""` (and not written) when `@lunora/seed` is not a declared dependency. */
|
|
2488
|
+
seed: string;
|
|
2489
|
+
server: string;
|
|
2490
|
+
shard: string;
|
|
2491
|
+
/** Static vector-index registry (`_generated/vectors.ts`) — `LUNORA_VECTOR_INDEXES`. Empty array body when the schema declares none. */
|
|
2492
|
+
vectors: string;
|
|
2493
|
+
/** WorkflowEntrypoint classes (`_generated/workflows.ts`); `""` (and not written) when no workflows are declared. */
|
|
2494
|
+
workflows: string;
|
|
2495
|
+
};
|
|
2496
|
+
outputDirectory: string;
|
|
2497
|
+
/**
|
|
2498
|
+
* Portability diagnostics for the requested {@link CodegenOptions.target}:
|
|
2499
|
+
* `ctx.*` features the app uses that the target does not support (omitted
|
|
2500
|
+
* from the emitted surface), or an unknown target. Empty for a
|
|
2501
|
+
* fully-supported app on the default Cloudflare target. Presentation is the
|
|
2502
|
+
* caller's job, like {@link CodegenResult.advisories}.
|
|
2503
|
+
*/
|
|
2504
|
+
platformDiagnostics: ReadonlyArray<PlatformDiagnostic>;
|
|
2505
|
+
/**
|
|
2506
|
+
* Queues discovered from `defineQueue` exports in `lunora/queues.ts` — the
|
|
2507
|
+
* list the config layer reconciles into wrangler's `queues.producers[]` /
|
|
2508
|
+
* `queues.consumers[]`. Queues are NOT Durable Objects, so this adds no
|
|
2509
|
+
* binding or migration. Empty when the project declares no queues.
|
|
2510
|
+
*/
|
|
2511
|
+
queues: ReadonlyArray<QueueIR>;
|
|
2512
|
+
/**
|
|
2513
|
+
* The CURRENT structural schema snapshot computed this run (tables + field
|
|
2514
|
+
* kinds/optionality + indexes/relations/shard mode + declared migration ids).
|
|
2515
|
+
* The pre-deploy drift gate diffs this against the committed baseline read
|
|
2516
|
+
* from {@link CodegenResult.schemaSnapshotPath}. Always present, even on a
|
|
2517
|
+
* `dryRun`.
|
|
2518
|
+
*/
|
|
2519
|
+
schemaSnapshot: SchemaSnapshot;
|
|
2520
|
+
/** Absolute path of the committed baseline file (`lunora/.lunora-schema.json`). */
|
|
2521
|
+
schemaSnapshotPath: string;
|
|
2522
|
+
/**
|
|
2523
|
+
* Workflows discovered from `defineWorkflow` exports in
|
|
2524
|
+
* `lunora/workflows.ts` — the list the config layer reconciles into
|
|
2525
|
+
* wrangler's `workflows[]` array. Workflows are NOT Durable Objects, so this
|
|
2526
|
+
* adds no binding or migration. Empty when the project declares no workflows.
|
|
2527
|
+
*/
|
|
2528
|
+
workflows: ReadonlyArray<WorkflowIR>;
|
|
2529
|
+
}
|
|
2530
|
+
/** Deduplicated, sorted names of every ERROR-level advisory in `advisories`. */
|
|
2531
|
+
declare const errorAdvisoryNames: (advisories: ReadonlyArray<Pick<Finding, "level" | "name">>) => ReadonlyArray<string>;
|
|
2532
|
+
/** Deduplicated, sorted names of every error-level platform diagnostic in `platformDiagnostics`. */
|
|
2533
|
+
declare const errorPlatformDiagnosticNames: (platformDiagnostics: ReadonlyArray<Pick<PlatformDiagnostic, "level" | "name">>) => ReadonlyArray<string>;
|
|
2534
|
+
/**
|
|
2535
|
+
* Convenience read combining both categories from a full {@link CodegenResult}
|
|
2536
|
+
* — the shape the Vite plugin's `buildBlockingMessage` needs, which (unlike
|
|
2537
|
+
* the CLI's `lunora codegen`/`lunora deploy`) folds ERROR-level advisories and
|
|
2538
|
+
* platform diagnostics into a single blocking message with no strict/CI
|
|
2539
|
+
* opt-out.
|
|
2540
|
+
*/
|
|
2541
|
+
declare const describeErrorLevelFindings: (result: Pick<CodegenResult, "advisories" | "platformDiagnostics">) => {
|
|
2542
|
+
advisoryNames: ReadonlyArray<string>;
|
|
2543
|
+
platformDiagnosticNames: ReadonlyArray<string>;
|
|
2544
|
+
};
|
|
2545
|
+
/**
|
|
2546
|
+
* An error thrown by codegen discovery when the user's schema or function
|
|
2547
|
+
* source has a structural problem that can be pinpointed to a specific source
|
|
2548
|
+
* location. A `LunoraError` subclass (`code: "CODEGEN_DIAGNOSTIC"`); the `file`,
|
|
2549
|
+
* `line`, and `column` properties (also passed through as the base `loc`) mirror
|
|
2550
|
+
* what Vite's error-overlay `loc` field expects so the browser can display the
|
|
2551
|
+
* exact spot.
|
|
2552
|
+
*/
|
|
2553
|
+
declare class CodegenDiagnosticError extends LunoraError {
|
|
2554
|
+
readonly column: number;
|
|
2555
|
+
readonly file: string;
|
|
2556
|
+
readonly line: number;
|
|
2557
|
+
constructor(message: string, file: string, line: number, column: number);
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Build a {@link CodegenDiagnosticError} whose message includes the source
|
|
2561
|
+
* location and whose `file`/`line`/`column` properties are set from the
|
|
2562
|
+
* ts-morph `Node`'s position in its source file.
|
|
2563
|
+
*
|
|
2564
|
+
* Message format: `@lunora/codegen: <detail> (<file>:<line>:<column>)`
|
|
2565
|
+
*
|
|
2566
|
+
* `meta` is merged onto the returned error for callers that also carry the
|
|
2567
|
+
* project-wide `LunoraError` envelope (`code`/`name`/`status`) — it never
|
|
2568
|
+
* touches `file`/`line`/`column`, and the error stays an instance of
|
|
2569
|
+
* {@link CodegenDiagnosticError} so the Vite overlay's `instanceof` location
|
|
2570
|
+
* lookup is unaffected.
|
|
2571
|
+
*/
|
|
2572
|
+
declare const diagnosticAt: (node: Node, detail: string, meta?: Record<string, unknown>) => CodegenDiagnosticError;
|
|
2573
|
+
/** The only file agents may be declared in — mirrors `lunora/workflows.ts`. */
|
|
2574
|
+
declare const AGENTS_FILENAME = "agents.ts";
|
|
2575
|
+
/**
|
|
2576
|
+
* Discover every agent the project declares: exported `defineAgent()` calls in
|
|
2577
|
+
* `lunora/agents.ts`. Returns `[]` when the file doesn't exist. Only four things
|
|
2578
|
+
* are read statically — the optional `name` override (wrangler `workflows[].name`),
|
|
2579
|
+
* the optional `publicRun` opt-in (the `agents:agentRun` capability gate), the
|
|
2580
|
+
* presence of a `voice` block (which turns on the voice-session Durable Object),
|
|
2581
|
+
* and the presence of an `onEmail` mapper (which wires the worker `email()`
|
|
2582
|
+
* handler); the rest of the agent config (model / tools / memory / voice models /
|
|
2583
|
+
* the `onEmail` closure body) is runtime-only, so codegen never evaluates it.
|
|
2584
|
+
*/
|
|
2585
|
+
declare const discoverAgents: (project: Project, lunoraDirectory: string) => AgentIR[];
|
|
2586
|
+
/**
|
|
2587
|
+
* Discover `ctx.authApi.<method>(...)` (and bare `authApi.<method>(...)`) calls
|
|
2588
|
+
* under the lunora source directory and attribute each to the exported function
|
|
2589
|
+
* (and file) performing it. Calls outside an exported declaration are dropped.
|
|
2590
|
+
*/
|
|
2591
|
+
declare const discoverAuthApiCalls: (project: Project, lunoraDirectory: string) => AuthApiCallIR[];
|
|
2592
|
+
/** The only file containers may be declared in — mirrors `lunora/crons.ts`. */
|
|
2593
|
+
declare const CONTAINERS_FILENAME = "containers.ts";
|
|
2594
|
+
/**
|
|
2595
|
+
* Discover every container the project declares: exported `defineContainer()`
|
|
2596
|
+
* calls in `lunora/containers.ts`. Returns `[]` when the file doesn't exist.
|
|
2597
|
+
* Wrangler-relevant fields (`image`, `instanceType`, `maxInstances`, `name`)
|
|
2598
|
+
* must be static literals; runtime-only fields (`env`, `sleepAfter`, …) may be
|
|
2599
|
+
* any expression since the generated class imports the definition object.
|
|
2600
|
+
*/
|
|
2601
|
+
declare const discoverContainers: (project: Project, lunoraDirectory: string) => ContainerIR[];
|
|
2602
|
+
/**
|
|
2603
|
+
* Scan every `.ts` file under `lunoraDir` for `cronJobs()` builder registrations
|
|
2604
|
+
* (`crons.interval(...)`, `crons.daily(...)`, `crons.cron(...)`, …) and lift them
|
|
2605
|
+
* into {@link CronJobIR}. Schedules are compiled to standard cron expressions;
|
|
2606
|
+
* function references are resolved to their `namespace:fn` dispatch path, while a
|
|
2607
|
+
* `workflows.NAME` / `agents.NAME` reference (or a bare identifier naming a
|
|
2608
|
+
* declared workflow) resolves to a durable workflow start. Names must be unique
|
|
2609
|
+
* across the project.
|
|
2610
|
+
*/
|
|
2611
|
+
declare const discoverCrons: (project: Project, lunoraDirectory: string, workflows?: ReadonlyArray<WorkflowIR>, agents?: ReadonlyArray<AgentIR>) => CronJobIR[];
|
|
2612
|
+
/** The only file a feature-flag provider may be declared in — mirrors `lunora/queues.ts`. */
|
|
2613
|
+
declare const FLAGS_FILENAME = "flags.ts";
|
|
2614
|
+
/**
|
|
2615
|
+
* Discover the feature-flag provider a project declares in `lunora/flags.ts`.
|
|
2616
|
+
* Returns `undefined` when the file doesn't exist (the app has no flags). The
|
|
2617
|
+
* read is metadata-only and lenient: codegen wires `ctx.flags` purely from the
|
|
2618
|
+
* file's *existence* (`run-codegen.ts`) and imports the real module for the
|
|
2619
|
+
* provider value — this IR exists solely so the config layer can reconcile the
|
|
2620
|
+
* wrangler `flagship` binding for the Flagship binding-mode provider. Anything
|
|
2621
|
+
* it can't read statically degrades to a `custom` provider (no binding), never
|
|
2622
|
+
* a thrown error.
|
|
2623
|
+
*/
|
|
2624
|
+
declare const discoverFlags: (project: Project, lunoraDirectory: string) => FlagsIR | undefined;
|
|
2625
|
+
/**
|
|
2626
|
+
* Scan all .ts files under `lunoraDir` (skipping `_generated/` and `schema.ts`)
|
|
2627
|
+
* for top-level `export const x = query/mutation/action({...})` registrations.
|
|
2628
|
+
*/
|
|
2629
|
+
declare const discoverFunctions: (project: Project, lunoraDirectory: string) => FunctionIR[];
|
|
2630
|
+
/**
|
|
2631
|
+
* Scan all `.ts` files under `lunoraDir` (skipping `_generated/` and `schema.ts`)
|
|
2632
|
+
* for `export const x = httpRoute.<verb>(...)…handler(...)` typed REST routes.
|
|
2633
|
+
* These are the headline OpenAPI target: each becomes a real `paths` entry.
|
|
2634
|
+
*/
|
|
2635
|
+
declare const discoverHttpRoutes: (project: Project, lunoraDirectory: string) => HttpRouteIR[];
|
|
2636
|
+
/**
|
|
2637
|
+
* Discover `ctx.db.insert("table", …)` writes under the lunora source directory
|
|
2638
|
+
* and attribute each to the exported function (and file) performing it. Calls
|
|
2639
|
+
* with a non-literal table argument, or outside an exported declaration, are
|
|
2640
|
+
* dropped (`table === ""` / no enclosing export).
|
|
2641
|
+
*/
|
|
2642
|
+
declare const discoverInserts: (project: Project, lunoraDirectory: string) => InsertWriteIR[];
|
|
2643
|
+
/**
|
|
2644
|
+
* Discover masking usage for every exported Lunora procedure under the lunora
|
|
2645
|
+
* source directory — the column-level twin of `discoverRlsProcedures`. For each
|
|
2646
|
+
* procedure, records whether its builder chain includes `.use(mask(...))`, which
|
|
2647
|
+
* `(table, column)` pairs that mask declares, and which tables it reads/writes
|
|
2648
|
+
* through `ctx.db`. Feeds the `mask_uncovered_pii_column` advisor lint.
|
|
2649
|
+
*/
|
|
2650
|
+
declare const discoverMaskProcedures: (project: Project, lunoraDirectory: string) => MaskProcedureIR[];
|
|
2651
|
+
/**
|
|
2652
|
+
* Scan all `.ts` files under `lunoraDir` for top-level
|
|
2653
|
+
* `export const x = defineMigration({...})` declarations and lift them into
|
|
2654
|
+
* {@link MigrationIR}. `id` must be a static string literal (it's the registry
|
|
2655
|
+
* key); `table` is best-effort and left `""` when not a literal.
|
|
2656
|
+
*/
|
|
2657
|
+
declare const discoverMigrations: (project: Project, lunoraDirectory: string) => MigrationIR[];
|
|
2658
|
+
/** The only file custom mutators may be declared in — mirrors `lunora/queues.ts`. */
|
|
2659
|
+
declare const MUTATORS_FILENAME = "mutators.ts";
|
|
2660
|
+
/**
|
|
2661
|
+
* Discover every custom mutator the project declares: exported
|
|
2662
|
+
* `defineMutator()` calls in `lunora/mutators.ts`. Returns `[]` when the file
|
|
2663
|
+
* doesn't exist. The export binding plus the declared `args` / `server` return
|
|
2664
|
+
* type are lifted — enough to emit a typed `api.mutators.<name>` reference —
|
|
2665
|
+
* while the runtime object still carries the authoritative `server` impl +
|
|
2666
|
+
* `handler`, so codegen never evaluates the body. The client `client` impl is
|
|
2667
|
+
* split into the browser bundle separately.
|
|
2668
|
+
*/
|
|
2669
|
+
declare const discoverMutators: (project: Project, lunoraDirectory: string) => MutatorIR[];
|
|
2670
|
+
/**
|
|
2671
|
+
* Discover non-deterministic API calls (`Date.now`, `new Date()`, `Date()`,
|
|
2672
|
+
* `Math.random`, `crypto.randomUUID`, `crypto.getRandomValues` — including
|
|
2673
|
+
* `globalThis`/`self`/`window`-prefixed receivers — and `fetch`) lexically inside
|
|
2674
|
+
* the handler body of every exported `query(...)` / `mutation(...)` registration
|
|
2675
|
+
* under the lunora source directory — the `nondeterministic_query_mutation` lint
|
|
2676
|
+
* input. `action(...)` (and `stream(...)`) registrations are intentionally
|
|
2677
|
+
* skipped: actions run exactly once and may use ambient APIs freely.
|
|
2678
|
+
*
|
|
2679
|
+
* Traversal is scoped to the handler node (not the whole declaration), mirroring
|
|
2680
|
+
* how the auth-api / insert feeders attribute calls — so a call in a sibling
|
|
2681
|
+
* helper outside the handler, or in a nested `action(...)` passed elsewhere, is
|
|
2682
|
+
* not attributed to the query/mutation. One {@link NondeterministicCallIR} is
|
|
2683
|
+
* produced per call site.
|
|
2684
|
+
*/
|
|
2685
|
+
declare const discoverNondeterministicCalls: (project: Project, lunoraDirectory: string) => NondeterministicCallIR[];
|
|
2686
|
+
/** The only file a `@lunora/notify` provider may be declared in — mirrors `lunora/flags.ts`. */
|
|
2687
|
+
declare const NOTIFY_FILENAME = "notify.ts";
|
|
2688
|
+
/**
|
|
2689
|
+
* Discover `ctx.notify` / `ctx.push` sends lexically inside the handler body of
|
|
2690
|
+
* every exported `query(...)` / `mutation(...)` registration under the lunora
|
|
2691
|
+
* source directory — the `notify_send_outside_action` lint input. `action(...)`
|
|
2692
|
+
* (and `stream(...)`) registrations are intentionally skipped: a notification
|
|
2693
|
+
* send is external I/O that belongs in actions. One {@link AdvisorNotifyCall} is
|
|
2694
|
+
* produced per send site.
|
|
2695
|
+
*/
|
|
2696
|
+
declare const discoverNotifyCalls: (project: Project, lunoraDirectory: string) => AdvisorNotifyCall[];
|
|
2697
|
+
/**
|
|
2698
|
+
* Discover which push channels the project's `lunora/notify.ts` default export
|
|
2699
|
+
* (`defineNotify({...})`) wires plus whether any handler sends a push — the
|
|
2700
|
+
* `notify_missing_push_config` lint input. Returns `undefined` when the file is
|
|
2701
|
+
* absent (the app declares no notify config). The read is metadata-only and
|
|
2702
|
+
* lenient (like `discoverFlags`): a `webPush`/`fcm` property's mere presence
|
|
2703
|
+
* counts as the channel being wired; a non-literal config degrades to "unwired"
|
|
2704
|
+
* rather than throwing.
|
|
2705
|
+
*/
|
|
2706
|
+
declare const discoverNotifyConfig: (project: Project, lunoraDirectory: string) => AdvisorNotifyConfig | undefined;
|
|
2707
|
+
/**
|
|
2708
|
+
* Every package name the project declares a dependency on, read from the
|
|
2709
|
+
* `package.json` at the project root across all four dependency fields
|
|
2710
|
+
* (`dependencies`, `devDependencies`, `peerDependencies`,
|
|
2711
|
+
* `optionalDependencies`).
|
|
2712
|
+
*
|
|
2713
|
+
* Returns `undefined` — NOT an empty set — when the manifest is absent or
|
|
2714
|
+
* unparseable, which is the whole reason this exists. Studio nav gating can
|
|
2715
|
+
* treat "declares nothing" and "cannot tell" the same way, but a check that
|
|
2716
|
+
* errors on a missing package cannot: conflating them makes it fire on every
|
|
2717
|
+
* project without a root `package.json` (the codegen fixtures, an embedded
|
|
2718
|
+
* schema, a tool driving `runCodegen` directly).
|
|
2719
|
+
*/
|
|
2720
|
+
declare const readPackageDependencies: (projectRoot: string) => Set<string> | undefined;
|
|
2721
|
+
/**
|
|
2722
|
+
* Discover `ctx.db.query("table")…` reads under the lunora source directory and
|
|
2723
|
+
* reduce each to a {@link QueryReadIR}. Only reads that call `.filter()` are
|
|
2724
|
+
* returned — an unfiltered read is never a `filter_without_index` candidate, so
|
|
2725
|
+
* dropping the rest keeps the lint input small.
|
|
2726
|
+
*/
|
|
2727
|
+
declare const discoverQueries: (project: Project, lunoraDirectory: string) => QueryReadIR[];
|
|
2728
|
+
/** The only file queues may be declared in — mirrors `lunora/workflows.ts`. */
|
|
2729
|
+
declare const QUEUES_FILENAME = "queues.ts";
|
|
2730
|
+
/**
|
|
2731
|
+
* Discover every queue the project declares: exported `defineQueue()` calls in
|
|
2732
|
+
* `lunora/queues.ts`. Returns `[]` when the file doesn't exist. Only the
|
|
2733
|
+
* wrangler-relevant literals (`name`/`mode`/batch tuning) are read; the handler
|
|
2734
|
+
* body is runtime-only, so codegen never evaluates it.
|
|
2735
|
+
*/
|
|
2736
|
+
declare const discoverQueues: (project: Project, lunoraDirectory: string) => QueueIR[];
|
|
2737
|
+
/**
|
|
2738
|
+
* Discover `ctx.r2sql` accesses lexically inside the handler body of every
|
|
2739
|
+
* exported `query(...)` / `mutation(...)` registration under the lunora source
|
|
2740
|
+
* directory — the `r2sql_outside_action` lint input. `action(...)` (and
|
|
2741
|
+
* `stream(...)`) registrations are intentionally skipped: R2 SQL is the
|
|
2742
|
+
* external, non-reactive surface that belongs in actions.
|
|
2743
|
+
*
|
|
2744
|
+
* Traversal is scoped to the handler node (not the whole declaration), mirroring
|
|
2745
|
+
* `discoverNondeterministicCalls` — so a `ctx.r2sql` touch in a sibling helper
|
|
2746
|
+
* outside the handler is not attributed to the query/mutation. One
|
|
2747
|
+
* {@link R2sqlCallIR} is produced per access site.
|
|
2748
|
+
*/
|
|
2749
|
+
declare const discoverR2sqlCalls: (project: Project, lunoraDirectory: string) => R2sqlCallIR[];
|
|
806
2750
|
declare const discoverRlsProcedures: (project: Project, lunoraDirectory: string) => RlsProcedureIR[];
|
|
807
2751
|
/**
|
|
808
|
-
* Aggregate the schema-wide RLS metadata the studio's read-only inspector reads:
|
|
809
|
-
* every statically-discovered `(table, on, procedure)` policy entry plus every
|
|
810
|
-
* role declared via `rls(policies, { roles })`. Walks the same builder chains as
|
|
811
|
-
* {@link discoverRlsProcedures} but extracts the richer `{ on }` operation +
|
|
812
|
-
* role/permission shape rather than the lint's table-name set.
|
|
813
|
-
*
|
|
814
|
-
* Only the **builder** form (`c.use(rls(...)).query(...)`) can declare policies,
|
|
815
|
-
* so bare-factory procedures contribute nothing. The `when` predicate is never
|
|
816
|
-
* read — it's an opaque JS closure whose logic belongs in code, not the UI.
|
|
817
|
-
* Roles are deduped by name (first declaration wins) so a role registered on
|
|
818
|
-
* several procedures lists once.
|
|
819
|
-
*/
|
|
2752
|
+
* Aggregate the schema-wide RLS metadata the studio's read-only inspector reads:
|
|
2753
|
+
* every statically-discovered `(table, on, procedure)` policy entry plus every
|
|
2754
|
+
* role declared via `rls(policies, { roles })`. Walks the same builder chains as
|
|
2755
|
+
* {@link discoverRlsProcedures} but extracts the richer `{ on }` operation +
|
|
2756
|
+
* role/permission shape rather than the lint's table-name set.
|
|
2757
|
+
*
|
|
2758
|
+
* Only the **builder** form (`c.use(rls(...)).query(...)`) can declare policies,
|
|
2759
|
+
* so bare-factory procedures contribute nothing. The `when` predicate is never
|
|
2760
|
+
* read — it's an opaque JS closure whose logic belongs in code, not the UI.
|
|
2761
|
+
* Roles are deduped by name (first declaration wins) so a role registered on
|
|
2762
|
+
* several procedures lists once.
|
|
2763
|
+
*/
|
|
820
2764
|
declare const discoverRlsMetadata: (project: Project, lunoraDirectory: string) => RlsMetadataIR;
|
|
821
2765
|
/**
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
*/
|
|
2766
|
+
* Which sandbox tools a project imports from `@lunora/agent` (main entry or the
|
|
2767
|
+
* `/sandbox` subpath), detected by NAMED value import. Drives two things:
|
|
2768
|
+
* registering the `sandbox:invoke` dispatcher (either tool) and provisioning the
|
|
2769
|
+
* `BROWSER` wrangler binding (`browserTool` — the browser op runs on
|
|
2770
|
+
* `ctx.browser` inside the dispatcher).
|
|
2771
|
+
*/
|
|
2772
|
+
interface SandboxUsage {
|
|
2773
|
+
/** `import { browserTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
|
|
2774
|
+
usesSandboxBrowser: boolean;
|
|
2775
|
+
/** `import { containerTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
|
|
2776
|
+
usesSandboxContainer: boolean;
|
|
2777
|
+
}
|
|
2778
|
+
declare const discoverSandboxUsage: (project: Project, lunoraDirectory: string) => SandboxUsage;
|
|
2779
|
+
/**
|
|
2780
|
+
* Load `<projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
|
|
2781
|
+
* return a structural IR. Throws if the file or call cannot be found.
|
|
2782
|
+
*/
|
|
2783
|
+
declare const discoverSchema: (project: Project, schemaPath: string, projectRoot?: string) => SchemaIR;
|
|
2784
|
+
/** The only file shapes may be declared in — mirrors `lunora/queues.ts`. */
|
|
2785
|
+
declare const SHAPES_FILENAME = "shapes.ts";
|
|
2786
|
+
/**
|
|
2787
|
+
* Discover every replication shape the project declares: exported
|
|
2788
|
+
* `defineShape()` calls in `lunora/shapes.ts`. Returns `[]` when the file
|
|
2789
|
+
* doesn't exist. Only the export binding is lifted — the runtime object carries
|
|
2790
|
+
* the authoritative `table`/`columns`/`compileWhere`, so codegen never
|
|
2791
|
+
* evaluates the predicate.
|
|
2792
|
+
*/
|
|
2793
|
+
declare const discoverShapes: (project: Project, lunoraDirectory: string) => ShapeIR[];
|
|
2794
|
+
/**
|
|
2795
|
+
* Aggregate the schema-wide storage-rule metadata the studio's inspector reads:
|
|
2796
|
+
* every statically-discovered `(bucket, on, prefix, procedure)` entry across all
|
|
2797
|
+
* `.use(storageRules(...))` chains. Only the builder form can declare rules, so
|
|
2798
|
+
* bare-factory procedures contribute nothing.
|
|
2799
|
+
*/
|
|
832
2800
|
declare const discoverStorageRulesMetadata: (project: Project, lunoraDirectory: string) => StorageRulesMetadataIR;
|
|
833
2801
|
/** The only file workflows may be declared in — mirrors `lunora/containers.ts`. */
|
|
834
2802
|
declare const WORKFLOWS_FILENAME = "workflows.ts";
|
|
835
2803
|
/**
|
|
836
|
-
* Discover every workflow the project declares: exported `defineWorkflow()`
|
|
837
|
-
* calls in `lunora/workflows.ts`. Returns `[]` when the file doesn't exist. The
|
|
838
|
-
* only wrangler-relevant literal is the optional `name` override; the workflow
|
|
839
|
-
* body is runtime-only, so codegen never evaluates it.
|
|
840
|
-
*/
|
|
2804
|
+
* Discover every workflow the project declares: exported `defineWorkflow()`
|
|
2805
|
+
* calls in `lunora/workflows.ts`. Returns `[]` when the file doesn't exist. The
|
|
2806
|
+
* only wrangler-relevant literal is the optional `name` override; the workflow
|
|
2807
|
+
* body is runtime-only, so codegen never evaluates it.
|
|
2808
|
+
*/
|
|
841
2809
|
declare const discoverWorkflows: (project: Project, lunoraDirectory: string) => WorkflowIR[];
|
|
842
2810
|
declare const GENERATED_HEADER = "// GENERATED by @lunora/codegen — do not edit.\n// Run `lunora codegen` to regenerate.\n\n";
|
|
843
|
-
/** Emit `_generated/dataModel.ts` — `Doc
|
|
844
|
-
declare const emitDataModel: (schema: SchemaIR
|
|
845
|
-
/**
|
|
846
|
-
* Emit `_generated/api.ts` — the typed `api.*` registry (public functions), the
|
|
847
|
-
* `internal.*` registry, and (when the project declares
|
|
848
|
-
* `workflows.*` reference
|
|
849
|
-
* at runtime (the `__lunoraRef` is identical); visibility is enforced
|
|
850
|
-
* server-side at dispatch, not in the reference. Splitting the *types* keeps
|
|
851
|
-
* internal functions off the client-facing `api` surface.
|
|
852
|
-
*/
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
2811
|
+
/** Emit `_generated/dataModel.ts` — `Doc<"name">` + `Id<"name">` for every table. */
|
|
2812
|
+
declare const emitDataModel: (schema: SchemaIR) => string;
|
|
2813
|
+
/**
|
|
2814
|
+
* Emit `_generated/api.ts` — the typed `api.*` registry (public functions), the
|
|
2815
|
+
* `internal.*` registry, and (when the project declares them) the typed
|
|
2816
|
+
* `workflows.*` / `agents.*` scheduler-target reference objects. `api`/`internal` are the same `anyApi` proxy
|
|
2817
|
+
* at runtime (the `__lunoraRef` is identical); visibility is enforced
|
|
2818
|
+
* server-side at dispatch, not in the reference. Splitting the *types* keeps
|
|
2819
|
+
* internal functions off the client-facing `api` surface.
|
|
2820
|
+
*/
|
|
2821
|
+
interface EmitApiOptions {
|
|
2822
|
+
agents?: ReadonlyArray<AgentIR>;
|
|
2823
|
+
functions: ReadonlyArray<FunctionIR>;
|
|
2824
|
+
/** Typed REST routes; only `.stream()` (SSE) routes emit a `httpStreams.*` reference. */
|
|
2825
|
+
httpRoutes?: ReadonlyArray<HttpRouteIR>;
|
|
2826
|
+
/** Custom mutators (`lunora/mutators.ts`) — emitted as `api.mutators.*` so a client `serverRef` is compile-checked. */
|
|
2827
|
+
mutators?: ReadonlyArray<MutatorIR>;
|
|
2828
|
+
useUmbrella?: boolean;
|
|
2829
|
+
workflows?: ReadonlyArray<WorkflowIR>;
|
|
2830
|
+
}
|
|
2831
|
+
declare const emitApi: (options: EmitApiOptions) => string;
|
|
2832
|
+
/**
|
|
2833
|
+
* Emit `_generated/collections.ts` — a typed TanStack DB binding per `defineShape`
|
|
2834
|
+
* in `lunora/shapes.ts` (the local-first partial-replication surface).
|
|
2835
|
+
*
|
|
2836
|
+
* Each shape emits **two** entry points.
|
|
2837
|
+
*
|
|
2838
|
+
* `<shape>CollectionOptions(options)` is the composable form: it returns the full
|
|
2839
|
+
* `LunoraCollectionOptions` — `config` for `createCollection`, plus `checkpoints`
|
|
2840
|
+
* (which `bindMutators` gates optimistic overlays on) and `scope`. This is what an app
|
|
2841
|
+
* with custom mutators needs, and what the old single-factory form made impossible: it
|
|
2842
|
+
* built the collection internally and dropped `checkpoints` on the floor, so there was
|
|
2843
|
+
* no way to wire mutators to the collection codegen produced.
|
|
2844
|
+
*
|
|
2845
|
+
* `<shape>Collection(options)` is the convenience form for a read-only collection: it
|
|
2846
|
+
* returns `{ checkpoints, collection, scope }` rather than a bare `Collection`, so the
|
|
2847
|
+
* sync controls stay reachable even from the short path.
|
|
2848
|
+
*
|
|
2849
|
+
* Both are typed: `args` comes from the shape's own validators (a parameterless
|
|
2850
|
+
* shape takes none), rows resolve to `Doc<"table">` when the shape names its table
|
|
2851
|
+
* with a literal, and `shardKey` / `getKey` / `load` / `onError` / `checkpoints` are
|
|
2852
|
+
* all threadable — a sharded table needs `shardKey` for its watermark to land in the
|
|
2853
|
+
* right bucket, and a server-minted `_id` that differs from the app's natural key
|
|
2854
|
+
* needs `getKey`.
|
|
2855
|
+
*
|
|
2856
|
+
* Returns `""` (so `writeIfPresent` skips the file) unless the project both
|
|
2857
|
+
* declares shapes AND installs `@lunora/db` — the add-on that ships
|
|
2858
|
+
* `lunoraCollectionOptions`. `@lunora/db` stays a scoped install even under the
|
|
2859
|
+
* `lunorash` umbrella (an opt-in add-on, like `@lunora/auth`), so its import is
|
|
2860
|
+
* always `@lunora/db/collections`; only the in-umbrella `@lunora/client` import
|
|
2861
|
+
* is remapped to `lunorash/client`.
|
|
2862
|
+
*/
|
|
2863
|
+
declare const emitCollections: (shapes: ReadonlyArray<ShapeIR>, hasDatabase: boolean, useUmbrella?: boolean) => string;
|
|
864
2864
|
interface EmitServerOptions {
|
|
2865
|
+
/** Agents declared via `defineAgent` exports — wires the typed `ctx.agents` producers onto Mutation/Action contexts. */
|
|
2866
|
+
agents?: ReadonlyArray<AgentIR>;
|
|
865
2867
|
containers?: ReadonlyArray<ContainerIR>;
|
|
2868
|
+
/**
|
|
2869
|
+
* The single `defineEnv(...)` contract declared in `lunora/env.ts`. When
|
|
2870
|
+
* present, `ctx.env` is typed as the validated `InferEnv` shape (recovered
|
|
2871
|
+
* via `ReturnType` over the accessor's `typeof`). `undefined` leaves `ctx.env`
|
|
2872
|
+
* the base optional binding record — byte-identical to today.
|
|
2873
|
+
*/
|
|
2874
|
+
env?: EnvIR;
|
|
2875
|
+
/**
|
|
2876
|
+
* A `lunora/` source reads `ctx.access` — wires the verified Cloudflare Access
|
|
2877
|
+
* facade (`@lunora/cloudflare-access/context`) onto every ctx. Distinct from
|
|
2878
|
+
* `emitApp`'s `hasAccess` (which gates the worker's `.access()` resolveIdentity
|
|
2879
|
+
* method); this one gates the per-request `ctx.access` read surface.
|
|
2880
|
+
*/
|
|
2881
|
+
hasAccessFacade?: boolean;
|
|
866
2882
|
hasAi?: boolean;
|
|
867
|
-
/** A `lunora/` source uses `@lunora/analytics` / `ctx.analytics` — wires the write helper onto every ctx. */
|
|
2883
|
+
/** A `lunora/` source uses `@lunora/bindings/analytics` / `ctx.analytics` — wires the write helper onto every ctx. */
|
|
868
2884
|
hasAnalytics?: boolean;
|
|
869
2885
|
/** A `lunora/` source uses `@lunora/browser` / `ctx.browser` — wires `ctx.browser` onto ActionCtx only. */
|
|
870
2886
|
hasBrowser?: boolean;
|
|
2887
|
+
/** The project declares `lunora/flags.ts` — wires `ctx.flags` (OpenFeature) onto every ctx. */
|
|
2888
|
+
hasFlags?: boolean;
|
|
871
2889
|
/** A `lunora/` source uses `@lunora/hyperdrive` / `ctx.sql` — wires `ctx.sql` onto ActionCtx only. */
|
|
872
2890
|
hasHyperdrive?: boolean;
|
|
873
|
-
/** A `lunora/` source uses `@lunora/images` / `ctx.images` — wires `ctx.images` onto ActionCtx only. */
|
|
2891
|
+
/** A `lunora/` source uses `@lunora/bindings/images` / `ctx.images` — wires `ctx.images` onto ActionCtx only. */
|
|
874
2892
|
hasImages?: boolean;
|
|
875
|
-
/** A `lunora/` source uses `@lunora/kv` / `ctx.kv` — wires `ctx.kv` onto every ctx. */
|
|
2893
|
+
/** A `lunora/` source uses `@lunora/bindings/kv` / `ctx.kv` — wires `ctx.kv` onto every ctx. */
|
|
876
2894
|
hasKv?: boolean;
|
|
2895
|
+
/** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
|
|
2896
|
+
hasNotify?: boolean;
|
|
877
2897
|
hasPayments?: boolean;
|
|
878
|
-
/** A `lunora/` source uses `@lunora/pipelines` / `ctx.pipelines` — wires `ctx.pipelines` onto ActionCtx only. */
|
|
2898
|
+
/** A `lunora/` source uses `@lunora/bindings/pipelines` / `ctx.pipelines` — wires `ctx.pipelines` onto ActionCtx only. */
|
|
879
2899
|
hasPipelines?: boolean;
|
|
2900
|
+
/** A `lunora/` source uses `@lunora/bindings/r2sql` / `ctx.r2sql` — wires `ctx.r2sql` onto ActionCtx only. */
|
|
2901
|
+
hasR2sql?: boolean;
|
|
2902
|
+
/** A `lunora/` source uses `@lunora/x402/pay` / `ctx.x402` — wires the agent-wallet pay rail onto ActionCtx only. */
|
|
2903
|
+
hasX402?: boolean;
|
|
2904
|
+
/**
|
|
2905
|
+
* The single `defineIdentity(...)` claim contract declared in
|
|
2906
|
+
* `lunora/identity.ts` (Plan 080). When present, `ctx.auth.getIdentity()`,
|
|
2907
|
+
* the RLS policy `ctx.auth.identity`, and the shard-authorization hooks
|
|
2908
|
+
* narrow to the declared shape (recovered via `InferIdentity` over the
|
|
2909
|
+
* contract's `typeof`). `undefined` keeps the identity an untyped bag —
|
|
2910
|
+
* byte-identical to today.
|
|
2911
|
+
*/
|
|
2912
|
+
identity?: IdentityIR;
|
|
2913
|
+
/** Queues declared via `defineQueue` exports — wires the typed `ctx.queues` producers onto Mutation/Action contexts. */
|
|
2914
|
+
queues?: ReadonlyArray<QueueIR>;
|
|
880
2915
|
schema?: SchemaIR;
|
|
881
2916
|
storageRuleBuckets?: ReadonlyArray<string>;
|
|
882
2917
|
/** The project depends on the `lunora` umbrella — import base packages via its subpaths. */
|
|
883
2918
|
useUmbrella?: boolean;
|
|
884
2919
|
workflows?: ReadonlyArray<WorkflowIR>;
|
|
885
2920
|
}
|
|
886
|
-
declare const emitServer: ({
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
*
|
|
909
|
-
*
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
*
|
|
913
|
-
*
|
|
914
|
-
|
|
915
|
-
* worker entry must re-export these classes: wrangler requires every
|
|
916
|
-
* `containers[].class_name` to be exported by the deployed worker. Returns ""
|
|
917
|
-
* when the project declares no containers (the file is not written then).
|
|
918
|
-
*/
|
|
919
|
-
declare const emitContainers: (containers: ReadonlyArray<ContainerIR>) => string;
|
|
920
|
-
/**
|
|
921
|
-
* Emit `_generated/workflows.ts` — one `WorkflowEntrypoint` class per
|
|
922
|
-
* `defineWorkflow` export, each a thin subclass of `LunoraWorkflow`
|
|
923
|
-
* (`@lunora/workflow/do`) constructed with the user's definition object. The
|
|
924
|
-
* worker entry must re-export these classes: wrangler requires every
|
|
925
|
-
* `workflows[].class_name` to be exported by the deployed worker. Returns ""
|
|
926
|
-
* when the project declares no workflows (the file is not written then).
|
|
927
|
-
*/
|
|
2921
|
+
declare const emitServer: ({ agents, containers, env, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, identity, queues, schema, storageRuleBuckets, useUmbrella, workflows }?: EmitServerOptions) => string;
|
|
2922
|
+
interface EmitFunctionsOptions {
|
|
2923
|
+
agents?: ReadonlyArray<AgentIR>;
|
|
2924
|
+
functions: ReadonlyArray<FunctionIR>;
|
|
2925
|
+
migrations?: ReadonlyArray<MigrationIR>;
|
|
2926
|
+
mutators?: ReadonlyArray<MutatorIR>;
|
|
2927
|
+
shapes?: ReadonlyArray<ShapeIR>;
|
|
2928
|
+
/** Import of a sandbox tool (`browserTool`/`containerTool`) auto-registers the `sandbox:invoke` action. */
|
|
2929
|
+
usesSandbox?: boolean;
|
|
2930
|
+
useUmbrella?: boolean;
|
|
2931
|
+
}
|
|
2932
|
+
declare const emitFunctions: (options: EmitFunctionsOptions) => string;
|
|
2933
|
+
/**
|
|
2934
|
+
* Emit `_generated/containers.ts` — one container-enabled Durable Object class
|
|
2935
|
+
* per `defineContainer` export, each a thin subclass of `LunoraContainer`
|
|
2936
|
+
* (`@lunora/container/do`) constructed with the user's definition object. The
|
|
2937
|
+
* worker entry must re-export these classes: wrangler requires every
|
|
2938
|
+
* `containers[].class_name` to be exported by the deployed worker. Returns ""
|
|
2939
|
+
* when the project declares no containers (the file is not written then).
|
|
2940
|
+
*/
|
|
2941
|
+
declare const emitContainers: (containers: ReadonlyArray<ContainerIR>, jurisdiction?: JurisdictionIR) => string;
|
|
2942
|
+
/**
|
|
2943
|
+
* Emit `_generated/workflows.ts` — one `WorkflowEntrypoint` class per
|
|
2944
|
+
* `defineWorkflow` export, each a thin subclass of `LunoraWorkflow`
|
|
2945
|
+
* (`@lunora/workflow/do`) constructed with the user's definition object. The
|
|
2946
|
+
* worker entry must re-export these classes: wrangler requires every
|
|
2947
|
+
* `workflows[].class_name` to be exported by the deployed worker. Returns ""
|
|
2948
|
+
* when the project declares no workflows (the file is not written then).
|
|
2949
|
+
*/
|
|
928
2950
|
declare const emitWorkflows: (workflows: ReadonlyArray<WorkflowIR>) => string;
|
|
2951
|
+
/**
|
|
2952
|
+
* Emit `_generated/agents.ts` — one `WorkflowEntrypoint` class per `defineAgent`
|
|
2953
|
+
* export, each a thin subclass of `LunoraWorkflow` (`@lunora/workflow/do`)
|
|
2954
|
+
* constructed with the compiled agent tool-loop (`compileAgentWorkflow`). Like
|
|
2955
|
+
* `_generated/workflows.ts`, the worker entry must re-export these classes:
|
|
2956
|
+
* wrangler requires every `workflows[].class_name` to be exported by the
|
|
2957
|
+
* deployed worker. Returns "" when the project declares no agents (the file is
|
|
2958
|
+
* not written then).
|
|
2959
|
+
*/
|
|
2960
|
+
declare const emitAgents: (agents: ReadonlyArray<AgentIR>) => string;
|
|
929
2961
|
interface EmitShardOptions {
|
|
930
2962
|
advisories?: ReadonlyArray<Finding>;
|
|
2963
|
+
/** Every declared procedure — the health map's denominator, served via `getAdvisorProcedures`. */
|
|
2964
|
+
advisorProcedures?: ReadonlyArray<AdvisorProcedureProtection>;
|
|
2965
|
+
/** Agents declared via `defineAgent` exports in `lunora/agents.ts` — wires the typed `ctx.agents` producers. */
|
|
2966
|
+
agents?: ReadonlyArray<AgentIR>;
|
|
931
2967
|
containers?: ReadonlyArray<ContainerIR>;
|
|
2968
|
+
/** The single `defineEnv(...)` contract declared in `lunora/env.ts` — applies the accessor to the worker `env` to populate `ctx.env`. */
|
|
2969
|
+
env?: EnvIR;
|
|
2970
|
+
/** Statically-discovered `ctx.flags.<type>("key")` reads — the studio Flags page + reactive evaluation iterate these. */
|
|
2971
|
+
flagKeys?: ReadonlyArray<{
|
|
2972
|
+
key: string;
|
|
2973
|
+
type: "boolean" | "number" | "object" | "string";
|
|
2974
|
+
}>;
|
|
2975
|
+
/** A `lunora/` source reads `ctx.access` — wires the verified Cloudflare Access facade onto every ctx. */
|
|
2976
|
+
hasAccessFacade?: boolean;
|
|
932
2977
|
hasAi?: boolean;
|
|
933
2978
|
/** A `lunora/` source reads `ctx.analytics` — wires the Analytics Engine write helper onto every ctx. */
|
|
934
2979
|
hasAnalytics?: boolean;
|
|
935
2980
|
/** A `lunora/` source reads `ctx.browser` — wires `ctx.browser` onto the ActionCtx only. */
|
|
936
2981
|
hasBrowser?: boolean;
|
|
2982
|
+
/** The project declares `lunora/flags.ts` — wires `ctx.flags` (OpenFeature) onto every ctx. */
|
|
2983
|
+
hasFlags?: boolean;
|
|
937
2984
|
/** A `lunora/` source reads `ctx.sql` (Hyperdrive) — wires `ctx.sql` onto the ActionCtx only. */
|
|
938
2985
|
hasHyperdrive?: boolean;
|
|
939
2986
|
/** A `lunora/` source reads `ctx.images` — wires `ctx.images` onto the ActionCtx only. */
|
|
940
2987
|
hasImages?: boolean;
|
|
941
2988
|
/** A `lunora/` source reads `ctx.kv` — wires `ctx.kv` onto every ctx. */
|
|
942
2989
|
hasKv?: boolean;
|
|
2990
|
+
/** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
|
|
2991
|
+
hasNotify?: boolean;
|
|
943
2992
|
hasPayments?: boolean;
|
|
2993
|
+
/** A `lunora/` source reads `ctx.pipelines` — wires `ctx.pipelines` onto the ActionCtx only. */
|
|
2994
|
+
hasPipelines?: boolean;
|
|
2995
|
+
/** A `lunora/` source reads `ctx.r2sql` (R2 SQL) — wires `ctx.r2sql` onto the ActionCtx only. */
|
|
2996
|
+
hasR2sql?: boolean;
|
|
2997
|
+
/** A `lunora/` source reads `ctx.x402` — wires the agent-wallet pay rail onto the ActionCtx only. */
|
|
2998
|
+
hasX402?: boolean;
|
|
944
2999
|
maskMetadata?: MaskMetadataIR;
|
|
3000
|
+
/** Custom mutators declared via `defineMutator` in `lunora/mutators.ts` — wires the `isCustomMutator` push-protocol override. */
|
|
3001
|
+
mutators?: ReadonlyArray<MutatorIR>;
|
|
3002
|
+
/** Queues declared via `defineQueue` exports in `lunora/queues.ts` — wires the typed `ctx.queues` producers. */
|
|
3003
|
+
queues?: ReadonlyArray<QueueIR>;
|
|
945
3004
|
rlsMetadata?: RlsMetadataIR;
|
|
946
3005
|
schema: SchemaIR;
|
|
3006
|
+
/**
|
|
3007
|
+
* The structural snapshot the pre-deploy drift gate diffs against, threaded
|
|
3008
|
+
* in so the emitted DO records it in `__lunora_schema_history` on cold start
|
|
3009
|
+
* (plan 200 — the Studio's schema-version timeline). Optional so an emitter
|
|
3010
|
+
* caller that has no snapshot (tests, fixtures) emits the pre-ledger shape
|
|
3011
|
+
* unchanged.
|
|
3012
|
+
*/
|
|
3013
|
+
schemaSnapshot?: SchemaSnapshot;
|
|
3014
|
+
/** Replication shapes declared via `defineShape` in `lunora/shapes.ts` — wires the `resolveShape` subscription override. */
|
|
3015
|
+
shapes?: ReadonlyArray<ShapeIR>;
|
|
947
3016
|
storageRules?: StorageRulesMetadataIR;
|
|
948
3017
|
studioFeatures?: StudioFeaturesResult;
|
|
949
3018
|
/** The project depends on the `lunora` umbrella — import base packages via its subpaths. */
|
|
950
3019
|
useUmbrella?: boolean;
|
|
951
3020
|
workflows?: ReadonlyArray<WorkflowIR>;
|
|
952
3021
|
}
|
|
953
|
-
declare const emitShard: ({
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
rlsMetadata,
|
|
965
|
-
schema,
|
|
966
|
-
storageRules,
|
|
967
|
-
studioFeatures,
|
|
968
|
-
useUmbrella,
|
|
969
|
-
workflows
|
|
970
|
-
}: EmitShardOptions) => string;
|
|
971
|
-
/**
|
|
972
|
-
* Emit drizzle `sqliteTable` definitions for the project schema, split into
|
|
973
|
-
* `global` (D1-backed) and `shard` (DO-SQLite-backed) buckets. Tables marked
|
|
974
|
-
* `.global()` go in the global file; everything else (default root + `.shardBy()`)
|
|
975
|
-
* goes in the shard file.
|
|
976
|
-
*
|
|
977
|
-
* `searchIndexes` are intentionally not emitted — drizzle has no `sqliteTable`
|
|
978
|
-
* abstraction for FTS5 virtual tables. FTS plumbing is handled by the runtime
|
|
979
|
-
* outside of drizzle.
|
|
980
|
-
*/
|
|
3022
|
+
declare const emitShard: ({ advisories, advisorProcedures, agents, containers, env, flagKeys, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, maskMetadata, mutators, queues, rlsMetadata, schema, schemaSnapshot, shapes, storageRules, studioFeatures, useUmbrella, workflows }: EmitShardOptions) => string;
|
|
3023
|
+
/**
|
|
3024
|
+
* Emit drizzle `sqliteTable` definitions for the project schema, split into
|
|
3025
|
+
* `global` (D1-backed) and `shard` (DO-SQLite-backed) buckets. Tables marked
|
|
3026
|
+
* `.global()` go in the global file; everything else (default root + `.shardBy()`)
|
|
3027
|
+
* goes in the shard file.
|
|
3028
|
+
*
|
|
3029
|
+
* `searchIndexes` are intentionally not emitted — drizzle has no `sqliteTable`
|
|
3030
|
+
* abstraction for FTS5 virtual tables. FTS plumbing is handled by the runtime
|
|
3031
|
+
* outside of drizzle.
|
|
3032
|
+
*/
|
|
981
3033
|
declare const emitDrizzleSchema: (schema: SchemaIR, useUmbrella?: boolean) => {
|
|
982
3034
|
global: string;
|
|
983
3035
|
shard: string;
|
|
984
3036
|
};
|
|
985
3037
|
/**
|
|
986
|
-
* Emit `_generated/crons.ts` from the discovered cron jobs.
|
|
987
|
-
*
|
|
988
|
-
* `LUNORA_CRON_TRIGGERS` is the deduplicated schedule array — what lands in
|
|
989
|
-
* wrangler's `triggers.crons` (the vite plugin reconciles it into
|
|
990
|
-
* `wrangler.jsonc`, and {@link emitWranglerCronTriggers} renders the same list
|
|
991
|
-
* for the CLI / docs).
|
|
992
|
-
*
|
|
993
|
-
* `LUNORA_CRONS` is the dispatcher map keyed by cron expression, each value a
|
|
994
|
-
* list of `{ name, functionPath, args }`. Cloudflare's `scheduled()` handler
|
|
995
|
-
* receives only the cron string, so multiple jobs sharing one expression must
|
|
996
|
-
* all fire — hence a list per key rather than a single entry.
|
|
997
|
-
*
|
|
998
|
-
* Jobs arrive pre-sorted by name (deterministic output); the trigger array
|
|
999
|
-
* preserves first-seen order of distinct expressions.
|
|
1000
|
-
*
|
|
1001
|
-
* Cloudflare caps a Worker at **3 Cron Triggers** (i.e. 3 distinct cron
|
|
1002
|
-
* expressions). Because the dispatcher fires every job sharing an expression,
|
|
1003
|
-
* many jobs can ride a single trigger — only the count of *distinct* schedules
|
|
1004
|
-
* matters. `lunora codegen` warns when that count exceeds the limit; for
|
|
1005
|
-
* finer-grained scheduling use Durable Object alarms (`@lunora/scheduler`),
|
|
1006
|
-
* which have no such cap.
|
|
1007
|
-
*/
|
|
3038
|
+
* Emit `_generated/crons.ts` from the discovered cron jobs.
|
|
3039
|
+
*
|
|
3040
|
+
* `LUNORA_CRON_TRIGGERS` is the deduplicated schedule array — what lands in
|
|
3041
|
+
* wrangler's `triggers.crons` (the vite plugin reconciles it into
|
|
3042
|
+
* `wrangler.jsonc`, and {@link emitWranglerCronTriggers} renders the same list
|
|
3043
|
+
* for the CLI / docs).
|
|
3044
|
+
*
|
|
3045
|
+
* `LUNORA_CRONS` is the dispatcher map keyed by cron expression, each value a
|
|
3046
|
+
* list of `{ name, functionPath, args }`. Cloudflare's `scheduled()` handler
|
|
3047
|
+
* receives only the cron string, so multiple jobs sharing one expression must
|
|
3048
|
+
* all fire — hence a list per key rather than a single entry.
|
|
3049
|
+
*
|
|
3050
|
+
* Jobs arrive pre-sorted by name (deterministic output); the trigger array
|
|
3051
|
+
* preserves first-seen order of distinct expressions.
|
|
3052
|
+
*
|
|
3053
|
+
* Cloudflare caps a Worker at **3 Cron Triggers** (i.e. 3 distinct cron
|
|
3054
|
+
* expressions). Because the dispatcher fires every job sharing an expression,
|
|
3055
|
+
* many jobs can ride a single trigger — only the count of *distinct* schedules
|
|
3056
|
+
* matters. `lunora codegen` warns when that count exceeds the limit; for
|
|
3057
|
+
* finer-grained scheduling use Durable Object alarms (`@lunora/scheduler`),
|
|
3058
|
+
* which have no such cap.
|
|
3059
|
+
*/
|
|
1008
3060
|
declare const emitCrons: (crons: ReadonlyArray<CronJobIR>) => string;
|
|
1009
3061
|
/**
|
|
1010
|
-
* Render `_generated/vectors.ts` — the static registry of every vector index
|
|
1011
|
-
* declared in `schema.ts` (inline `.vectorize()` columns + standalone
|
|
1012
|
-
* `defineVectorIndex()` definitions).
|
|
1013
|
-
*
|
|
1014
|
-
* Cloudflare Vectorize exposes no way to enumerate an account's indexes at
|
|
1015
|
-
* runtime — a binding can `describe()` itself but the worker can't ask "which
|
|
1016
|
-
* indexes exist". So this generated array is the source of truth the studio's
|
|
1017
|
-
* vector browser lists, and the worker's admin route pairs each entry with its
|
|
1018
|
-
* live `describe()` stats. Entries are sorted by name for deterministic output.
|
|
1019
|
-
*/
|
|
3062
|
+
* Render `_generated/vectors.ts` — the static registry of every vector index
|
|
3063
|
+
* declared in `schema.ts` (inline `.vectorize()` columns + standalone
|
|
3064
|
+
* `defineVectorIndex()` definitions).
|
|
3065
|
+
*
|
|
3066
|
+
* Cloudflare Vectorize exposes no way to enumerate an account's indexes at
|
|
3067
|
+
* runtime — a binding can `describe()` itself but the worker can't ask "which
|
|
3068
|
+
* indexes exist". So this generated array is the source of truth the studio's
|
|
3069
|
+
* vector browser lists, and the worker's admin route pairs each entry with its
|
|
3070
|
+
* live `describe()` stats. Entries are sorted by name for deterministic output.
|
|
3071
|
+
*/
|
|
1020
3072
|
declare const emitVectors: (vectorIndexes: ReadonlyArray<VectorIndexIR>) => string;
|
|
1021
3073
|
/**
|
|
1022
|
-
* Render the deduplicated cron schedules as a JSON fragment suitable for
|
|
1023
|
-
* splicing into `wrangler.jsonc`'s `triggers.crons`. The vite plugin uses this
|
|
1024
|
-
* (plus the parsed wrangler config) to reconcile generated triggers without the
|
|
1025
|
-
* user hand-editing the file.
|
|
1026
|
-
*/
|
|
3074
|
+
* Render the deduplicated cron schedules as a JSON fragment suitable for
|
|
3075
|
+
* splicing into `wrangler.jsonc`'s `triggers.crons`. The vite plugin uses this
|
|
3076
|
+
* (plus the parsed wrangler config) to reconcile generated triggers without the
|
|
3077
|
+
* user hand-editing the file.
|
|
3078
|
+
*/
|
|
1027
3079
|
declare const emitWranglerCronTriggers: (crons: ReadonlyArray<CronJobIR>) => string[];
|
|
1028
3080
|
/** Which capability methods the generated `defineApp` builder exposes — one flag per package-backed feature the app actually uses. */
|
|
1029
3081
|
interface EmitAppOptions {
|
|
3082
|
+
/**
|
|
3083
|
+
* Inbound-email agents (`defineAgent({ onEmail })`) → wire the worker's
|
|
3084
|
+
* top-level `email()` handler to `dispatchAgentEmail(...)` (from
|
|
3085
|
+
* `@lunora/agent/inbound`), so received mail starts a durable run. Empty/absent
|
|
3086
|
+
* ⇒ no wiring, byte-identical output for email-free (and agent-free) projects.
|
|
3087
|
+
*/
|
|
3088
|
+
emailAgents?: ReadonlyArray<{
|
|
3089
|
+
bindingName: string;
|
|
3090
|
+
exportName: string;
|
|
3091
|
+
}>;
|
|
3092
|
+
/** App depends on `@lunora/cloudflare-access` → emit `.access()` (wire the Cloudflare Access `resolveIdentity`, composed ahead of `@lunora/auth` when both are present). */
|
|
3093
|
+
hasAccess: boolean;
|
|
1030
3094
|
/** App uses `@lunora/ai` / `ctx.ai` → emit `.ai()` (override the Workers AI binding backing `ctx.ai`). */
|
|
1031
3095
|
hasAi: boolean;
|
|
1032
|
-
/** App uses `@lunora/analytics` / `ctx.analytics` → emit `.analytics()` (override the dataset backing `ctx.analytics`). */
|
|
3096
|
+
/** App uses `@lunora/bindings/analytics` / `ctx.analytics` → emit `.analytics()` (override the dataset backing `ctx.analytics`). */
|
|
1033
3097
|
hasAnalytics: boolean;
|
|
1034
3098
|
/** App depends on `@lunora/auth` → emit `.auth()` + the lazy build/migrate dance. */
|
|
1035
3099
|
hasAuth: boolean;
|
|
@@ -1043,12 +3107,18 @@ interface EmitAppOptions {
|
|
|
1043
3107
|
hasHyperdrive: boolean;
|
|
1044
3108
|
/** Schema declares **Hyperdrive-backed** `.global({ backend: "hyperdrive" })` tables → emit `.hyperdriveGlobal()` (reactive Postgres/MySQL ctx-db over Hyperdrive). */
|
|
1045
3109
|
hasHyperdriveGlobal: boolean;
|
|
1046
|
-
/** App uses `@lunora/images` / `ctx.images` → emit `.images()`. */
|
|
3110
|
+
/** App uses `@lunora/bindings/images` / `ctx.images` → emit `.images()`. */
|
|
1047
3111
|
hasImages: boolean;
|
|
1048
|
-
/** App uses `@lunora/kv` / `ctx.kv` → emit `.kv()`. */
|
|
3112
|
+
/** App uses `@lunora/bindings/kv` / `ctx.kv` → emit `.kv()`. */
|
|
1049
3113
|
hasKv: boolean;
|
|
3114
|
+
/** App declares `lunora/notify.ts` (`@lunora/notify`) → wire `options.notifySubscriptionStore` so the studio Notifications page can read registered devices. */
|
|
3115
|
+
hasNotify: boolean;
|
|
1050
3116
|
/** App uses `@lunora/payment` / `ctx.payments` → emit `.payment()`. */
|
|
1051
3117
|
hasPayments: boolean;
|
|
3118
|
+
/** App declares push queues (`defineQueue`) → wire `LUNORA_QUEUE_REGISTRY` into the worker's `queue()` consumer entry. */
|
|
3119
|
+
hasQueue: boolean;
|
|
3120
|
+
/** App uses `@lunora/bindings/r2sql` / `ctx.r2sql` → emit `.r2sql()`. */
|
|
3121
|
+
hasR2sql: boolean;
|
|
1052
3122
|
/** App imports `@lunora/scheduler` / declares crons → emit `.scheduler()`. */
|
|
1053
3123
|
hasScheduler: boolean;
|
|
1054
3124
|
/** App uses `@lunora/storage` → emit `.storage()` (DO `ctx.storage` + studio file browser). */
|
|
@@ -1057,28 +3127,45 @@ interface EmitAppOptions {
|
|
|
1057
3127
|
hasVectors: boolean;
|
|
1058
3128
|
/** App declares Cloudflare Workflows (`defineWorkflow`) → wire `options.workflowsClient` so the studio's workflow-instance proxy can reach the CF REST API. */
|
|
1059
3129
|
hasWorkflow: boolean;
|
|
3130
|
+
/** App uses `@lunora/x402/pay` / `ctx.x402` → emit `.x402()` (wire the agent-wallet pay rail). */
|
|
3131
|
+
hasX402: boolean;
|
|
3132
|
+
/** The single `defineIdentity(...)` contract in `lunora/identity.ts` (Plan 080) → import it as a VALUE and wire `options.identity`, so the runtime trust boundary validates every resolved identity before it becomes `ctx.auth`. `undefined` ⇒ no wiring, byte-identical output. */
|
|
3133
|
+
identity?: IdentityIR;
|
|
3134
|
+
/** Schema declares `.jurisdiction("…")` → pin every DO the worker reaches (shards, fan-out, scheduler, containers) to the Cloudflare data-residency jurisdiction. */
|
|
3135
|
+
jurisdiction?: JurisdictionIR;
|
|
1060
3136
|
/** Project depends on the unscoped `lunorash` umbrella → import the runtime via `lunorash/runtime` instead of `@lunora/runtime`. */
|
|
1061
3137
|
useUmbrella: boolean;
|
|
3138
|
+
/**
|
|
3139
|
+
* Voice-enabled agents (`defineAgent({ voice: … })`) → wire
|
|
3140
|
+
* `options.voiceAgents`, mapping each agent's export name to its `VOICE_*`
|
|
3141
|
+
* Durable Object namespace binding so the runtime exposes
|
|
3142
|
+
* `/_lunora/voice/<exportName>`. Empty/absent ⇒ no wiring, byte-identical
|
|
3143
|
+
* output for voice-free (and agent-free) projects.
|
|
3144
|
+
*/
|
|
3145
|
+
voiceAgents?: ReadonlyArray<{
|
|
3146
|
+
bindingName: string;
|
|
3147
|
+
exportName: string;
|
|
3148
|
+
}>;
|
|
1062
3149
|
/** An OpenAPI spec is emitted (`openapi.ts`) → wire `openApiSpec` into the worker. */
|
|
1063
3150
|
wantsOpenApi: boolean;
|
|
1064
3151
|
/** An OpenRPC spec is emitted (`openrpc.ts`) → wire `openRpcSpec` into the worker. */
|
|
1065
3152
|
wantsOpenRpc: boolean;
|
|
1066
3153
|
}
|
|
1067
3154
|
/**
|
|
1068
|
-
* Emit `_generated/app.ts` — a fluent, feature-specialized worker-composition
|
|
1069
|
-
* builder. Only the methods for capabilities THIS app uses are emitted, so the
|
|
1070
|
-
* builder's type surface (IntelliSense) lists exactly what can be configured.
|
|
1071
|
-
*
|
|
1072
|
-
* Each capability declaration is fanned into BOTH runtime surfaces: the DO-side
|
|
1073
|
-
* `createShardDO(...)` factory that backs `ctx.*`, and the worker-side
|
|
1074
|
-
* `createWorker(...)` options that back the studio/admin endpoints — so storage
|
|
1075
|
-
* / scheduler / global are declared once instead of twice. The builder is pure
|
|
1076
|
-
* sugar over the public `createWorker` / `createShardDO`; both stay usable.
|
|
1077
|
-
*
|
|
1078
|
-
* Lives in generated code (not `@lunora/runtime`, which is dependency-free) so
|
|
1079
|
-
* it can import the add-on packages the app installed (`@lunora/auth`,
|
|
1080
|
-
* `@lunora/storage`, …) directly.
|
|
1081
|
-
*/
|
|
3155
|
+
* Emit `_generated/app.ts` — a fluent, feature-specialized worker-composition
|
|
3156
|
+
* builder. Only the methods for capabilities THIS app uses are emitted, so the
|
|
3157
|
+
* builder's type surface (IntelliSense) lists exactly what can be configured.
|
|
3158
|
+
*
|
|
3159
|
+
* Each capability declaration is fanned into BOTH runtime surfaces: the DO-side
|
|
3160
|
+
* `createShardDO(...)` factory that backs `ctx.*`, and the worker-side
|
|
3161
|
+
* `createWorker(...)` options that back the studio/admin endpoints — so storage
|
|
3162
|
+
* / scheduler / global are declared once instead of twice. The builder is pure
|
|
3163
|
+
* sugar over the public `createWorker` / `createShardDO`; both stay usable.
|
|
3164
|
+
*
|
|
3165
|
+
* Lives in generated code (not `@lunora/runtime`, which is dependency-free) so
|
|
3166
|
+
* it can import the add-on packages the app installed (`@lunora/auth`,
|
|
3167
|
+
* `@lunora/storage`, …) directly.
|
|
3168
|
+
*/
|
|
1082
3169
|
declare const emitApp: (options: EmitAppOptions) => string;
|
|
1083
3170
|
/** Inputs the OpenAPI emitter needs from a codegen run. */
|
|
1084
3171
|
interface OpenApiEmitInput {
|
|
@@ -1088,40 +3175,40 @@ interface OpenApiEmitInput {
|
|
|
1088
3175
|
version?: string;
|
|
1089
3176
|
}
|
|
1090
3177
|
/**
|
|
1091
|
-
* Emit an OpenAPI 3.1.0 document covering both Lunora function surfaces.
|
|
1092
|
-
*
|
|
1093
|
-
* `httpRouter()` typed REST routes become real `paths` keyed by their method +
|
|
1094
|
-
* URL, with query/path parameters and JSON request bodies derived from their
|
|
1095
|
-
* `v.*` validators, and a response schema from `.output()` when declared.
|
|
1096
|
-
*
|
|
1097
|
-
* RPC `query`/`mutation`/`action` functions become one operation each on
|
|
1098
|
-
* `POST /_lunora/rpc` (disambiguated by a `#functionPath` path fragment), with a
|
|
1099
|
-
* requestBody pinning `functionPath` + typed `args`. `internal`/`stream`
|
|
1100
|
-
* functions are excluded (unreachable / not invocable on the external RPC path).
|
|
1101
|
-
*
|
|
1102
|
-
* Operations are grouped into `tags` by file namespace, and every operation
|
|
1103
|
-
* references a reusable `LunoraError` error-response component enumerating the
|
|
1104
|
-
* standard error codes. Borrows oRPC's per-procedure-operation + tag-grouping +
|
|
1105
|
-
* internal-filtering structure; the JSON Schema dialect matches `@lunora/values`
|
|
1106
|
-
* (Draft 2020-12). Returns the document as a plain object (the single source of
|
|
1107
|
-
* truth `emitOpenApi` stringifies and `emitOpenApiModule` inlines, so the
|
|
1108
|
-
* `.json` and `.ts` artifacts can never drift).
|
|
1109
|
-
*/
|
|
3178
|
+
* Emit an OpenAPI 3.1.0 document covering both Lunora function surfaces.
|
|
3179
|
+
*
|
|
3180
|
+
* `httpRouter()` typed REST routes become real `paths` keyed by their method +
|
|
3181
|
+
* URL, with query/path parameters and JSON request bodies derived from their
|
|
3182
|
+
* `v.*` validators, and a response schema from `.output()` when declared.
|
|
3183
|
+
*
|
|
3184
|
+
* RPC `query`/`mutation`/`action` functions become one operation each on
|
|
3185
|
+
* `POST /_lunora/rpc` (disambiguated by a `#functionPath` path fragment), with a
|
|
3186
|
+
* requestBody pinning `functionPath` + typed `args`. `internal`/`stream`
|
|
3187
|
+
* functions are excluded (unreachable / not invocable on the external RPC path).
|
|
3188
|
+
*
|
|
3189
|
+
* Operations are grouped into `tags` by file namespace, and every operation
|
|
3190
|
+
* references a reusable `LunoraError` error-response component enumerating the
|
|
3191
|
+
* standard error codes. Borrows oRPC's per-procedure-operation + tag-grouping +
|
|
3192
|
+
* internal-filtering structure; the JSON Schema dialect matches `@lunora/values`
|
|
3193
|
+
* (Draft 2020-12). Returns the document as a plain object (the single source of
|
|
3194
|
+
* truth `emitOpenApi` stringifies and `emitOpenApiModule` inlines, so the
|
|
3195
|
+
* `.json` and `.ts` artifacts can never drift).
|
|
3196
|
+
*/
|
|
1110
3197
|
declare const buildOpenApiDocument: (input: OpenApiEmitInput) => Record<string, unknown>;
|
|
1111
3198
|
/**
|
|
1112
|
-
* Emit the OpenAPI 3.1 document as a pretty-printed JSON string
|
|
1113
|
-
* (`_generated/openapi.json`) — the portable artifact for external tooling.
|
|
1114
|
-
*/
|
|
3199
|
+
* Emit the OpenAPI 3.1 document as a pretty-printed JSON string
|
|
3200
|
+
* (`_generated/openapi.json`) — the portable artifact for external tooling.
|
|
3201
|
+
*/
|
|
1115
3202
|
declare const emitOpenApi: (input: OpenApiEmitInput) => string;
|
|
1116
3203
|
/**
|
|
1117
|
-
* Emit the OpenAPI document as an importable TS module
|
|
1118
|
-
* (`_generated/openapi.ts`) the worker entry imports and passes to
|
|
1119
|
-
* `createWorker({ openApiSpec })`. The document object literal is inlined
|
|
1120
|
-
* verbatim (same `JSON.stringify` form the `.json` uses), so the `.ts` and
|
|
1121
|
-
* `.json` are byte-identical content and regenerate together — closing the gap
|
|
1122
|
-
* where a Worker cannot read the JSON file at runtime. `document_` is the object
|
|
1123
|
-
* returned by {@link buildOpenApiDocument} (reused, never recomputed).
|
|
1124
|
-
*/
|
|
3204
|
+
* Emit the OpenAPI document as an importable TS module
|
|
3205
|
+
* (`_generated/openapi.ts`) the worker entry imports and passes to
|
|
3206
|
+
* `createWorker({ openApiSpec })`. The document object literal is inlined
|
|
3207
|
+
* verbatim (same `JSON.stringify` form the `.json` uses), so the `.ts` and
|
|
3208
|
+
* `.json` are byte-identical content and regenerate together — closing the gap
|
|
3209
|
+
* where a Worker cannot read the JSON file at runtime. `document_` is the object
|
|
3210
|
+
* returned by {@link buildOpenApiDocument} (reused, never recomputed).
|
|
3211
|
+
*/
|
|
1125
3212
|
declare const emitOpenApiModule: (document_: Record<string, unknown>) => string;
|
|
1126
3213
|
/** The OpenRPC dialect version this emitter targets. */
|
|
1127
3214
|
declare const OPENRPC_VERSION = "1.3.2";
|
|
@@ -1132,127 +3219,71 @@ interface OpenRpcEmitInput {
|
|
|
1132
3219
|
version?: string;
|
|
1133
3220
|
}
|
|
1134
3221
|
/**
|
|
1135
|
-
* Emit an OpenRPC 1.x document describing Lunora's JSON-RPC surface.
|
|
1136
|
-
*
|
|
1137
|
-
* Only the RPC `query`/`mutation`/`action` functions become `methods` — one per
|
|
1138
|
-
* function, `name` = `file:fn`. `internal` (off the external RPC path) and
|
|
1139
|
-
* `stream` (not invocable over the RPC envelope) are excluded, the same filter
|
|
1140
|
-
* the OpenAPI emitter applies. Each method's single `args` param is typed from
|
|
1141
|
-
* the function's `v.*` validators (`argsObjectSchema`); `result` is the
|
|
1142
|
-
* `.output()` schema when declared, else a best-effort inferred schema. The
|
|
1143
|
-
* standard `LunoraError` codes ride along under each method's `errors`.
|
|
1144
|
-
*
|
|
1145
|
-
* `httpRouter()` typed REST routes are deliberately omitted — OpenRPC is
|
|
1146
|
-
* RPC-only and cannot represent REST paths; the OpenAPI document is the spec
|
|
1147
|
-
* that covers the REST surface. Methods are sorted by name for stable output.
|
|
1148
|
-
* Returns the document as a plain object (the single source of truth
|
|
1149
|
-
* `emitOpenRpc` stringifies and `emitOpenRpcModule` inlines, so the `.json` and
|
|
1150
|
-
* `.ts` artifacts can never drift).
|
|
1151
|
-
*/
|
|
3222
|
+
* Emit an OpenRPC 1.x document describing Lunora's JSON-RPC surface.
|
|
3223
|
+
*
|
|
3224
|
+
* Only the RPC `query`/`mutation`/`action` functions become `methods` — one per
|
|
3225
|
+
* function, `name` = `file:fn`. `internal` (off the external RPC path) and
|
|
3226
|
+
* `stream` (not invocable over the RPC envelope) are excluded, the same filter
|
|
3227
|
+
* the OpenAPI emitter applies. Each method's single `args` param is typed from
|
|
3228
|
+
* the function's `v.*` validators (`argsObjectSchema`); `result` is the
|
|
3229
|
+
* `.output()` schema when declared, else a best-effort inferred schema. The
|
|
3230
|
+
* standard `LunoraError` codes ride along under each method's `errors`.
|
|
3231
|
+
*
|
|
3232
|
+
* `httpRouter()` typed REST routes are deliberately omitted — OpenRPC is
|
|
3233
|
+
* RPC-only and cannot represent REST paths; the OpenAPI document is the spec
|
|
3234
|
+
* that covers the REST surface. Methods are sorted by name for stable output.
|
|
3235
|
+
* Returns the document as a plain object (the single source of truth
|
|
3236
|
+
* `emitOpenRpc` stringifies and `emitOpenRpcModule` inlines, so the `.json` and
|
|
3237
|
+
* `.ts` artifacts can never drift).
|
|
3238
|
+
*/
|
|
1152
3239
|
declare const buildOpenRpcDocument: (input: OpenRpcEmitInput) => Record<string, unknown>;
|
|
1153
3240
|
/**
|
|
1154
|
-
* Emit the OpenRPC 1.x document as a pretty-printed JSON string
|
|
1155
|
-
* (`_generated/openrpc.json`) — the portable artifact for external tooling.
|
|
1156
|
-
*/
|
|
3241
|
+
* Emit the OpenRPC 1.x document as a pretty-printed JSON string
|
|
3242
|
+
* (`_generated/openrpc.json`) — the portable artifact for external tooling.
|
|
3243
|
+
*/
|
|
1157
3244
|
declare const emitOpenRpc: (input: OpenRpcEmitInput) => string;
|
|
1158
3245
|
/**
|
|
1159
|
-
* Emit the OpenRPC document as an importable TS module
|
|
1160
|
-
* (`_generated/openrpc.ts`) the worker entry imports and passes to
|
|
1161
|
-
* `createWorker({ openRpcSpec })`. The document object literal is inlined
|
|
1162
|
-
* verbatim (same `JSON.stringify` form the `.json` uses), so the `.ts` and
|
|
1163
|
-
* `.json` are byte-identical content and regenerate together. `document_` is
|
|
1164
|
-
* the object returned by {@link buildOpenRpcDocument} (reused, never recomputed).
|
|
1165
|
-
*/
|
|
3246
|
+
* Emit the OpenRPC document as an importable TS module
|
|
3247
|
+
* (`_generated/openrpc.ts`) the worker entry imports and passes to
|
|
3248
|
+
* `createWorker({ openRpcSpec })`. The document object literal is inlined
|
|
3249
|
+
* verbatim (same `JSON.stringify` form the `.json` uses), so the `.ts` and
|
|
3250
|
+
* `.json` are byte-identical content and regenerate together. `document_` is
|
|
3251
|
+
* the object returned by {@link buildOpenRpcDocument} (reused, never recomputed).
|
|
3252
|
+
*/
|
|
1166
3253
|
declare const emitOpenRpcModule: (document_: Record<string, unknown>) => string;
|
|
1167
|
-
/** Current snapshot format version. Bumped if the structural shape below changes. */
|
|
1168
|
-
declare const SCHEMA_SNAPSHOT_VERSION: 1;
|
|
1169
|
-
/** A single field's structural shape: its value kind and whether it is optional. */
|
|
1170
|
-
interface FieldSnapshot {
|
|
1171
|
-
/** The validator kind (`string`, `number`, `id`, `object`, …) after unwrapping `v.optional`. */
|
|
1172
|
-
kind: string;
|
|
1173
|
-
/** True when declared `v.optional(...)` — accepts `undefined` / absent on insert. */
|
|
1174
|
-
optional: boolean;
|
|
1175
|
-
}
|
|
1176
|
-
/** A single secondary index's structural shape. */
|
|
1177
|
-
interface IndexSnapshot {
|
|
1178
|
-
fields: ReadonlyArray<string>;
|
|
1179
|
-
unique: boolean;
|
|
1180
|
-
}
|
|
1181
|
-
/** A single relation's structural shape. */
|
|
1182
|
-
interface RelationSnapshot {
|
|
1183
|
-
field: string;
|
|
1184
|
-
kind: "many" | "one";
|
|
1185
|
-
table: string;
|
|
1186
|
-
}
|
|
1187
|
-
/** Structural snapshot of one table. */
|
|
1188
|
-
interface TableSnapshot {
|
|
1189
|
-
/** Field name → {@link FieldSnapshot}, in declared order. */
|
|
1190
|
-
fields: Record<string, FieldSnapshot>;
|
|
1191
|
-
/** Index name → {@link IndexSnapshot}. */
|
|
1192
|
-
indexes: Record<string, IndexSnapshot>;
|
|
1193
|
-
/** Relation accessor name → {@link RelationSnapshot}. */
|
|
1194
|
-
relations: Record<string, RelationSnapshot>;
|
|
1195
|
-
/**
|
|
1196
|
-
* `"root"` (default single-DO), `"global"` (D1-replicated), or
|
|
1197
|
-
* `"shardBy:<field>"` (partitioned). Encoded as a string so the snapshot
|
|
1198
|
-
* stays a plain JSON-stable value.
|
|
1199
|
-
*/
|
|
1200
|
-
shardMode: string;
|
|
1201
|
-
}
|
|
1202
|
-
/** The committed baseline — a deterministic structural view of the whole schema. */
|
|
1203
|
-
interface SchemaSnapshot {
|
|
1204
|
-
/** Sorted list of every declared `defineMigration` id at capture time. */
|
|
1205
|
-
migrationIds: ReadonlyArray<string>;
|
|
1206
|
-
/** Table name → {@link TableSnapshot}, keys sorted for stable serialization. */
|
|
1207
|
-
tables: Record<string, TableSnapshot>;
|
|
1208
|
-
version: typeof SCHEMA_SNAPSHOT_VERSION;
|
|
1209
|
-
}
|
|
1210
|
-
/** One classified structural change between the baseline and the current schema. */
|
|
1211
|
-
interface DriftChange {
|
|
1212
|
-
/** `"breaking"` changes need a data migration; `"safe"` changes are additive. */
|
|
1213
|
-
severity: "breaking" | "safe";
|
|
1214
|
-
/** Human-readable, actionable description (used in the gate message). */
|
|
1215
|
-
summary: string;
|
|
1216
|
-
/** A machine-readable change discriminator. */
|
|
1217
|
-
type: "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedFieldKind" | "changedIndex" | "changedShardMode" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "removedField" | "removedIndex" | "removedRelation" | "removedTable";
|
|
1218
|
-
}
|
|
1219
|
-
/** The result of diffing two snapshots: every classified change. */
|
|
1220
|
-
interface SchemaDrift {
|
|
1221
|
-
/** Every classified change, in a stable order (added/changed per table, then removals). */
|
|
1222
|
-
changes: ReadonlyArray<DriftChange>;
|
|
1223
|
-
}
|
|
1224
3254
|
/**
|
|
1225
|
-
* Build a {@link SchemaSnapshot} from a parsed {@link SchemaIR} and the set of
|
|
1226
|
-
* declared migration ids. Tables and migration ids are sorted so the emitted
|
|
1227
|
-
* JSON is byte-stable across runs (no spurious diffs /
|
|
1228
|
-
|
|
3255
|
+
* Build a {@link SchemaSnapshot} from a parsed {@link SchemaIR} and the set of
|
|
3256
|
+
* declared migration ids. Tables and migration ids are sorted so the emitted
|
|
3257
|
+
* JSON is byte-stable across runs AND across machines (no spurious diffs /
|
|
3258
|
+
* churn) — see `sortKeys` in `shared/schema-snapshot.ts` for why that ordering
|
|
3259
|
+
* must not be locale-aware.
|
|
3260
|
+
*
|
|
3261
|
+
* Field / index / relation keys are deliberately NOT sorted: they are emitted in
|
|
3262
|
+
* declaration order from the schema source, which is already deterministic for a
|
|
3263
|
+
* given source file and keeps the snapshot readable next to the schema it mirrors.
|
|
3264
|
+
*/
|
|
1229
3265
|
declare const buildSchemaSnapshot: (schema: SchemaIR, migrationIds: ReadonlyArray<string>) => SchemaSnapshot;
|
|
1230
|
-
/** Serialize a snapshot to the exact bytes written to `lunora/.lunora-schema.json` (trailing newline). */
|
|
1231
|
-
declare const serializeSchemaSnapshot: (snapshot: SchemaSnapshot) => string;
|
|
1232
3266
|
/**
|
|
1233
|
-
* Thrown by {@link parseSchemaSnapshot} when the baseline file exists but is
|
|
1234
|
-
* malformed (bad JSON / wrong version / invalid table shape). Lets the CLI gate
|
|
1235
|
-
* treat a corrupt baseline as a hard error rather than silently degrading to a
|
|
1236
|
-
* "first capture" that would mask drift and then overwrite the bad file.
|
|
1237
|
-
*/
|
|
1238
|
-
declare class SchemaSnapshotParseError extends
|
|
1239
|
-
|
|
1240
|
-
}
|
|
1241
|
-
/**
|
|
1242
|
-
* Parse a committed snapshot file. Returns `undefined` ONLY when the content is
|
|
1243
|
-
* absent/empty; throws {@link SchemaSnapshotParseError} when content is present
|
|
1244
|
-
* but malformed (bad JSON, wrong version, or structurally-invalid tables) so the
|
|
1245
|
-
* caller can distinguish "no baseline yet" (a legitimate first capture) from "a
|
|
1246
|
-
* corrupt baseline" (which must not be silently treated as a first capture).
|
|
1247
|
-
*/
|
|
1248
|
-
declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
|
|
3267
|
+
* Thrown by {@link parseSchemaSnapshot} when the baseline file exists but is
|
|
3268
|
+
* malformed (bad JSON / wrong version / invalid table shape). Lets the CLI gate
|
|
3269
|
+
* treat a corrupt baseline as a hard error rather than silently degrading to a
|
|
3270
|
+
* "first capture" that would mask drift and then overwrite the bad file.
|
|
3271
|
+
*/
|
|
3272
|
+
declare class SchemaSnapshotParseError extends LunoraError {
|
|
3273
|
+
constructor(message: string);
|
|
3274
|
+
}
|
|
1249
3275
|
/**
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
|
|
1255
|
-
|
|
3276
|
+
* Parse a committed snapshot file. Returns `undefined` ONLY when the content is
|
|
3277
|
+
* absent/empty; throws {@link SchemaSnapshotParseError} when content is present
|
|
3278
|
+
* but malformed (bad JSON, wrong version, or structurally-invalid tables) so the
|
|
3279
|
+
* caller can distinguish "no baseline yet" (a legitimate first capture) from "a
|
|
3280
|
+
* corrupt baseline" (which must not be silently treated as a first capture).
|
|
3281
|
+
*
|
|
3282
|
+
* The parsing itself lives in `shared/schema-snapshot.ts` (the Studio reads the
|
|
3283
|
+
* same JSON out of the DO ledger); this wrapper only applies the CLI's policy of
|
|
3284
|
+
* treating a malformed baseline as fatal.
|
|
3285
|
+
*/
|
|
3286
|
+
declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
|
|
1256
3287
|
/** The decision the pre-deploy gate returns. */
|
|
1257
3288
|
interface SchemaDriftDecision {
|
|
1258
3289
|
/** True when the deploy must be blocked (breaking drift with no new migration, and no override). */
|
|
@@ -1262,212 +3293,53 @@ interface SchemaDriftDecision {
|
|
|
1262
3293
|
/** Migration ids declared now but absent from the baseline — proof a migration was added. */
|
|
1263
3294
|
newMigrationIds: ReadonlyArray<string>;
|
|
1264
3295
|
/**
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
3296
|
+
* A multi-line, actionable explanation. Always present; empty string when
|
|
3297
|
+
* there is no drift at all. Mirrors the D1-placeholder guard's message style.
|
|
3298
|
+
*/
|
|
1268
3299
|
reason: string;
|
|
1269
3300
|
}
|
|
1270
3301
|
/**
|
|
1271
|
-
* Decide whether breaking schema drift should block a deploy.
|
|
1272
|
-
*
|
|
1273
|
-
* Blocks only when the baseline exists (a first-ever capture is never blocking),
|
|
1274
|
-
* there is at least one `breaking` change, no NEW migration id was added since
|
|
1275
|
-
* the baseline, and the `allowDrift` override is not set. Safe-only drift (or
|
|
1276
|
-
* breaking drift accompanied by a new migration id) passes.
|
|
1277
|
-
*/
|
|
3302
|
+
* Decide whether breaking schema drift should block a deploy.
|
|
3303
|
+
*
|
|
3304
|
+
* Blocks only when the baseline exists (a first-ever capture is never blocking),
|
|
3305
|
+
* there is at least one `breaking` change, no NEW migration id was added since
|
|
3306
|
+
* the baseline, and the `allowDrift` override is not set. Safe-only drift (or
|
|
3307
|
+
* breaking drift accompanied by a new migration id) passes.
|
|
3308
|
+
*/
|
|
1278
3309
|
declare const evaluateSchemaDrift: (options: {
|
|
1279
3310
|
allowDrift?: boolean;
|
|
1280
3311
|
baseline: SchemaSnapshot | undefined;
|
|
3312
|
+
/** The command printing the remediation, so it names only flags that command accepts. */
|
|
3313
|
+
command?: string;
|
|
1281
3314
|
current: SchemaSnapshot;
|
|
1282
3315
|
}) => SchemaDriftDecision;
|
|
1283
3316
|
/**
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1288
|
-
*/
|
|
1289
|
-
declare const SCHEMA_SNAPSHOT_FILENAME = ".lunora-schema.json";
|
|
1290
|
-
/**
|
|
1291
|
-
* Construct the ts-morph `Project` codegen discovers over. Prefers the user's
|
|
1292
|
-
* `tsconfig.json` (when one is found walking up from `lunoraDirectory`) so
|
|
1293
|
-
* cross-file type resolution and path aliases work; falls back to an isolated
|
|
1294
|
-
* project otherwise. This is the exact construction {@link runCodegen} uses
|
|
1295
|
-
* when no `project` is injected — exported so a long-lived caller (the Vite
|
|
1296
|
-
* dev-loop) can build one once and reuse it across runs via
|
|
1297
|
-
* {@link refreshCodegenProject} instead of re-parsing the user's whole TS
|
|
1298
|
-
* program on every save.
|
|
1299
|
-
*/
|
|
1300
|
-
declare const createCodegenProject: (lunoraDirectory: string) => Project;
|
|
1301
|
-
/**
|
|
1302
|
-
* Synchronise a reused {@link createCodegenProject} Project with the current
|
|
1303
|
-
* on-disk state of `lunoraDirectory`, so the next {@link runCodegen} sees the
|
|
1304
|
-
* same files a freshly-constructed Project would — without re-parsing the whole
|
|
1305
|
-
* TS program. Adds any on-disk source file the Project doesn't yet have, and
|
|
1306
|
-
* `refreshFromFileSystemSync()`es the ones it does (picking up edits); then
|
|
1307
|
-
* removes Project source files under `lunoraDirectory` that no longer exist on
|
|
1308
|
-
* disk (the classic stale-deleted-file cache bug).
|
|
1309
|
-
*
|
|
1310
|
-
* Files outside `lunoraDirectory` (e.g. those pulled in by the user's tsconfig)
|
|
1311
|
-
* are left untouched — they back type resolution and rarely change in the
|
|
1312
|
-
* dev-loop; a tsconfig change invalidates the whole cached Project upstream.
|
|
1313
|
-
*/
|
|
1314
|
-
declare const refreshCodegenProject: (project: Project, lunoraDirectory: string) => void;
|
|
1315
|
-
/**
|
|
1316
|
-
* Top-level codegen entry. Parses `<projectRoot>/lunora/schema.ts` and every
|
|
1317
|
-
* function file under `<projectRoot>/lunora/`, then writes
|
|
1318
|
-
* `_generated/{api,server,dataModel}.ts` next to them.
|
|
1319
|
-
*/
|
|
1320
|
-
declare const runCodegen: (options: CodegenOptions) => CodegenResult;
|
|
1321
|
-
interface CodegenOptions {
|
|
1322
|
-
/**
|
|
1323
|
-
* Which machine-readable API spec(s) to emit into `_generated/`.
|
|
1324
|
-
*
|
|
1325
|
-
* `"openapi"` (the default) writes only `openapi.json` (OpenAPI 3.1; covers
|
|
1326
|
-
* both the RPC functions and `httpRouter()` REST routes). `"openrpc"` writes
|
|
1327
|
-
* only `openrpc.json` (OpenRPC 1.x; the RPC functions only — OpenRPC cannot
|
|
1328
|
-
* represent REST routes). `"both"` writes both files; `"none"` writes neither.
|
|
1329
|
-
*
|
|
1330
|
-
* Regardless of the choice, `CodegenResult.generated.openApi` and `.openRpc`
|
|
1331
|
-
* always carry the rendered string (computation is cheap and pure); only the
|
|
1332
|
-
* on-disk write is gated by this option.
|
|
1333
|
-
*/
|
|
1334
|
-
apiSpec?: "both" | "none" | "openapi" | "openrpc";
|
|
1335
|
-
/**
|
|
1336
|
-
* When true, run discovery + emit (so any schema/function parse error
|
|
1337
|
-
* surfaces) but skip writing files to `_generated/`. The returned
|
|
1338
|
-
* `outputDirectory` is still the path that *would* have been written.
|
|
1339
|
-
*/
|
|
1340
|
-
dryRun?: boolean;
|
|
1341
|
-
/**
|
|
1342
|
-
* Run the static schema advisor (unindexed FKs, …) during codegen.
|
|
1343
|
-
* Defaults to `true`. When `false`, `CodegenResult.advisories` is empty.
|
|
1344
|
-
* Computed regardless of `dryRun`; codegen never prints them — see
|
|
1345
|
-
* {@link CodegenResult.advisories}.
|
|
1346
|
-
*/
|
|
1347
|
-
lint?: boolean;
|
|
1348
|
-
/** Override the lunora subdirectory name. Defaults to `"lunora"`. */
|
|
1349
|
-
lunoraDirectory?: string;
|
|
1350
|
-
/**
|
|
1351
|
-
* Reuse a previously-constructed ts-morph {@link Project} instead of building
|
|
1352
|
-
* a fresh one each run. The caller owns refreshing its source files from disk
|
|
1353
|
-
* (see {@link refreshCodegenProject}) — codegen does not re-read changed files
|
|
1354
|
-
* off an injected Project. Built via {@link createCodegenProject} when absent.
|
|
1355
|
-
* Used by the Vite dev-loop to avoid re-parsing the whole TS program on every
|
|
1356
|
-
* save; omit it (CLI one-shot path) to get the default fresh-Project behaviour.
|
|
1357
|
-
*/
|
|
1358
|
-
project?: Project;
|
|
1359
|
-
/** Project root containing the `lunora/` directory. */
|
|
1360
|
-
projectRoot: string;
|
|
1361
|
-
/**
|
|
1362
|
-
* Re-bless the committed schema-drift baseline (`lunora/.lunora-schema.json`)
|
|
1363
|
-
* with the current structural snapshot. The baseline is ALWAYS written on
|
|
1364
|
-
* first capture (when the file is absent); set this to overwrite an existing
|
|
1365
|
-
* one — e.g. after the developer has added the data migration that justifies
|
|
1366
|
-
* a breaking change. Ignored when `dryRun` is true.
|
|
1367
|
-
*/
|
|
1368
|
-
updateSchemaBaseline?: boolean;
|
|
1369
|
-
}
|
|
1370
|
-
interface CodegenResult {
|
|
1371
|
-
/**
|
|
1372
|
-
* Static schema advisor findings (e.g. unindexed foreign keys) produced
|
|
1373
|
-
* this run. Empty when `lint` is `false` or the schema is clean. Codegen
|
|
1374
|
-
* does not print these itself — each caller presents them through its own
|
|
1375
|
-
* channel (the CLI logger, the vite overlay, the studio Advisors table).
|
|
1376
|
-
* `formatAdvisories` is exported for a plain multi-line rendering.
|
|
1377
|
-
*/
|
|
1378
|
-
advisories: ReadonlyArray<Finding>;
|
|
1379
|
-
/**
|
|
1380
|
-
* Containers discovered from `defineContainer` exports in
|
|
1381
|
-
* `lunora/containers.ts` — the list the config layer reconciles into
|
|
1382
|
-
* wrangler's `containers[]`, `CONTAINER_*` Durable Object bindings, and
|
|
1383
|
-
* migration classes. Empty when the project declares no containers.
|
|
1384
|
-
*/
|
|
1385
|
-
containers: ReadonlyArray<ContainerIR>;
|
|
1386
|
-
/**
|
|
1387
|
-
* Deduplicated cron schedules discovered from `cronJobs()` definitions —
|
|
1388
|
-
* the array the vite plugin reconciles into `wrangler.jsonc`'s
|
|
1389
|
-
* `triggers.crons`. Empty when the project declares no crons.
|
|
1390
|
-
*/
|
|
1391
|
-
cronTriggers: ReadonlyArray<string>;
|
|
1392
|
-
generated: {
|
|
1393
|
-
api: string; /** Fluent worker-composition builder (`_generated/app.ts`) — `defineApp()`. Always written. */
|
|
1394
|
-
app: string;
|
|
1395
|
-
/** Container DO classes (`_generated/containers.ts`); `""` (and not written) when no containers are declared. */
|
|
1396
|
-
containers: string;
|
|
1397
|
-
crons: string;
|
|
1398
|
-
dataModel: string;
|
|
1399
|
-
drizzleGlobal: string;
|
|
1400
|
-
drizzleShard: string;
|
|
1401
|
-
functions: string; /** OpenAPI 3.1.0 document (`_generated/openapi.json`), pretty-printed JSON. */
|
|
1402
|
-
openApi: string;
|
|
1403
|
-
/**
|
|
1404
|
-
* OpenAPI document as an importable TS module (`_generated/openapi.ts`) —
|
|
1405
|
-
* `export const openApiSpec`, the worker imports it for
|
|
1406
|
-
* `createWorker({ openApiSpec })`. Same document as `openApi`. Written
|
|
1407
|
-
* alongside `openapi.json` whenever `apiSpec` includes `openapi`.
|
|
1408
|
-
*/
|
|
1409
|
-
openApiModule: string;
|
|
1410
|
-
/** OpenRPC 1.x document (`_generated/openrpc.json`), pretty-printed JSON. Always computed; written only when `apiSpec` includes `openrpc`. */
|
|
1411
|
-
openRpc: string;
|
|
1412
|
-
/**
|
|
1413
|
-
* OpenRPC document as an importable TS module (`_generated/openrpc.ts`) —
|
|
1414
|
-
* `export const openRpcSpec`, for `createWorker({ openRpcSpec })`. Same
|
|
1415
|
-
* document as `openRpc`. Written alongside `openrpc.json` whenever
|
|
1416
|
-
* `apiSpec` includes `openrpc`.
|
|
1417
|
-
*/
|
|
1418
|
-
openRpcModule: string;
|
|
1419
|
-
/** Project-bound seed client (`_generated/seed.ts`); `""` (and not written) when `@lunora/seed` is not a declared dependency. */
|
|
1420
|
-
seed: string;
|
|
1421
|
-
server: string;
|
|
1422
|
-
shard: string; /** Static vector-index registry (`_generated/vectors.ts`) — `LUNORA_VECTOR_INDEXES`. Empty array body when the schema declares none. */
|
|
1423
|
-
vectors: string;
|
|
1424
|
-
/** WorkflowEntrypoint classes (`_generated/workflows.ts`); `""` (and not written) when no workflows are declared. */
|
|
1425
|
-
workflows: string;
|
|
1426
|
-
};
|
|
1427
|
-
outputDirectory: string;
|
|
1428
|
-
/**
|
|
1429
|
-
* The CURRENT structural schema snapshot computed this run (tables + field
|
|
1430
|
-
* kinds/optionality + indexes/relations/shard mode + declared migration ids).
|
|
1431
|
-
* The pre-deploy drift gate diffs this against the committed baseline read
|
|
1432
|
-
* from {@link CodegenResult.schemaSnapshotPath}. Always present, even on a
|
|
1433
|
-
* `dryRun`.
|
|
1434
|
-
*/
|
|
1435
|
-
schemaSnapshot: SchemaSnapshot;
|
|
1436
|
-
/** Absolute path of the committed baseline file (`lunora/.lunora-schema.json`). */
|
|
1437
|
-
schemaSnapshotPath: string;
|
|
1438
|
-
/**
|
|
1439
|
-
* Workflows discovered from `defineWorkflow` exports in
|
|
1440
|
-
* `lunora/workflows.ts` — the list the config layer reconciles into
|
|
1441
|
-
* wrangler's `workflows[]` array. Workflows are NOT Durable Objects, so this
|
|
1442
|
-
* adds no binding or migration. Empty when the project declares no workflows.
|
|
1443
|
-
*/
|
|
1444
|
-
workflows: ReadonlyArray<WorkflowIR>;
|
|
1445
|
-
}
|
|
1446
|
-
/**
|
|
1447
|
-
* Convert a {@link SchemaIR} into a synthetic runtime {@link Schema} carrying just
|
|
1448
|
-
* the `tables[name].shape` surface `@lunora/seed` introspects. System columns
|
|
1449
|
-
* (`_id`, `_creationTime`) are absent from the IR shape, exactly as the seed
|
|
1450
|
-
* engine expects (it assigns `_id` itself).
|
|
1451
|
-
*/
|
|
3317
|
+
* Convert a {@link SchemaIR} into a synthetic runtime {@link Schema} carrying just
|
|
3318
|
+
* the `tables[name].shape` surface `@lunora/seed` introspects. System columns
|
|
3319
|
+
* (`_id`, `_creationTime`) are absent from the IR shape, exactly as the seed
|
|
3320
|
+
* engine expects (it assigns `_id` itself).
|
|
3321
|
+
*/
|
|
1452
3322
|
declare const schemaFromIr: (ir: SchemaIR) => Schema;
|
|
1453
3323
|
/**
|
|
1454
|
-
* Convert a codegen {@link ValidatorIR} into a JSON Schema node. A thin wrapper
|
|
1455
|
-
* over the shared {@link jsonSchemaFromNode} core (from `@lunora/values`) with the
|
|
1456
|
-
* IR-backed {@link irReader}, so the kind→schema mapping is the *same* algorithm
|
|
1457
|
-
* `@lunora/values`' `toJsonSchema` runs — codegen never instantiates the runtime
|
|
1458
|
-
* `v.*` objects, it only holds the reflected IR. Shared by the OpenAPI and
|
|
1459
|
-
* OpenRPC emitters so both surfaces speak one JSON Schema dialect.
|
|
1460
|
-
*/
|
|
3324
|
+
* Convert a codegen {@link ValidatorIR} into a JSON Schema node. A thin wrapper
|
|
3325
|
+
* over the shared {@link jsonSchemaFromNode} core (from `@lunora/values`) with the
|
|
3326
|
+
* IR-backed {@link irReader}, so the kind→schema mapping is the *same* algorithm
|
|
3327
|
+
* `@lunora/values`' `toJsonSchema` runs — codegen never instantiates the runtime
|
|
3328
|
+
* `v.*` objects, it only holds the reflected IR. Shared by the OpenAPI and
|
|
3329
|
+
* OpenRPC emitters so both surfaces speak one JSON Schema dialect.
|
|
3330
|
+
*/
|
|
1461
3331
|
declare const validatorIrToJsonSchema: (validator: ValidatorIR) => JsonSchema;
|
|
1462
|
-
/**
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1467
|
-
*
|
|
1468
|
-
|
|
1469
|
-
* the contract; clients switch on `error.code`. Kept sorted for stable output.
|
|
1470
|
-
*/
|
|
3332
|
+
/**
|
|
3333
|
+
* The machine-readable `LunoraError` codes Lunora emits on the RPC + REST
|
|
3334
|
+
* surfaces, enumerated from `@lunora/server`'s `CODE_STATUS` map plus the
|
|
3335
|
+
* runtime/DO dispatch codes (`FUNCTION_NOT_FOUND`, `PAYLOAD_TOO_LARGE`,
|
|
3336
|
+
* `METHOD_NOT_ALLOWED`, the `*_NOT_CONFIGURED` admin gates, …). The list documents
|
|
3337
|
+
* the contract; clients switch on `error.code`. Kept sorted for stable output.
|
|
3338
|
+
*/
|
|
1471
3339
|
declare const LUNORA_ERROR_CODES: ReadonlyArray<string>;
|
|
3340
|
+
/** The matching secret rule's `kind` for a string value, or `undefined` when none matches. */
|
|
3341
|
+
declare const secretKindOf: (value: string) => string | undefined;
|
|
3342
|
+
/** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
|
|
3343
|
+
declare const redact: (value: string) => string;
|
|
1472
3344
|
declare const VERSION = "0.0.0";
|
|
1473
|
-
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, type FieldSnapshot, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type MaskProcedureIR, type MigrationIR, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, type QueryReadIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverNondeterministicCalls, discoverQueries, discoverRlsMetadata, discoverRlsProcedures, discoverSchema, discoverStorageRulesMetadata, discoverWorkflows, emitApi, emitApp, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, refreshCodegenProject, runCodegen, schemaFromIr, serializeSchemaSnapshot, validatorIrToJsonSchema };
|
|
3345
|
+
export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, DEFAULT_TARGET, type DriftChange, type DriftScope, 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, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type PlatformDiagnostic, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type R2sqlCallIR, 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 ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, platformMatrixIds, readPackageDependencies, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, toAdvisorContext, validatorIrToJsonSchema };
|