@sequenceholdings/orm 2.1.0 → 2.2.0
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/README.md +40 -1
- package/dist/authoring.cjs +1619 -121
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +252 -8
- package/dist/authoring.d.ts +252 -8
- package/dist/authoring.js +1607 -123
- package/dist/authoring.js.map +1 -1
- package/dist/canonical.cjs +713 -41
- package/dist/canonical.cjs.map +1 -1
- package/dist/canonical.d.cts +1520 -51
- package/dist/canonical.d.ts +1520 -51
- package/dist/canonical.js +693 -42
- package/dist/canonical.js.map +1 -1
- package/dist/cli.cjs +7103 -3901
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +7104 -3902
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +122 -40
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +85 -25
- package/dist/client.d.ts +85 -25
- package/dist/client.js +119 -41
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +2464 -450
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +79 -4
- package/dist/compiler.d.ts +79 -4
- package/dist/compiler.js +2457 -451
- package/dist/compiler.js.map +1 -1
- package/dist/constants-C6EG6Wq7.d.cts +99 -0
- package/dist/constants-C6EG6Wq7.d.ts +99 -0
- package/dist/definition-DjfC7Lll.d.cts +91 -0
- package/dist/definition-DjfC7Lll.d.ts +91 -0
- package/dist/dynamic-input.cjs +2 -1
- package/dist/dynamic-input.cjs.map +1 -1
- package/dist/dynamic-input.d.cts +9 -1
- package/dist/dynamic-input.d.ts +9 -1
- package/dist/dynamic-input.js +2 -1
- package/dist/dynamic-input.js.map +1 -1
- package/dist/index.cjs +2656 -418
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +693 -116
- package/dist/index.d.ts +693 -116
- package/dist/index.js +2622 -420
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +811 -48
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +670 -27
- package/dist/ir.d.ts +670 -27
- package/dist/ir.js +802 -49
- package/dist/ir.js.map +1 -1
- package/dist/{naming-DCn94LJ4.d.ts → naming-CPfx7EfF.d.ts} +14 -1
- package/dist/{naming-DPglwzkB.d.cts → naming-CU9ThP_E.d.cts} +14 -1
- package/dist/policy-1iZbGnZZ.d.cts +24 -0
- package/dist/policy-1iZbGnZZ.d.ts +24 -0
- package/dist/predicate-v2.cjs +804 -51
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.d.cts +2 -1
- package/dist/predicate-v2.d.ts +2 -1
- package/dist/predicate-v2.js +804 -51
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +1014 -75
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +14 -3
- package/dist/sdl.d.ts +14 -3
- package/dist/sdl.js +1012 -76
- package/dist/sdl.js.map +1 -1
- package/package.json +13 -7
- package/src/codegen-gql/server-fns.cjs +2 -2
- package/templates/orm-namespace/AGENTS.md +10 -0
- package/templates/orm-namespace/CLAUDE.md +1 -82
- package/templates/orm-namespace/codegen.preset.d.cts +7 -0
- package/templates/orm-namespace/codegen.ts +2 -1
- package/templates/orm-namespace/graphql/example/queries.ts +4 -3
- package/templates/orm-namespace/package.json +2 -1
- package/templates/orm-namespace/schema/tables.ts +3 -2
- package/templates/orm-namespace/sequence.config.ts +7 -11
package/dist/authoring.d.cts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { ColumnType, CanonicalColumn, CanonicalDefinition, CanonicalTable } from './canonical.cjs';
|
|
1
|
+
import { ColumnType, CanonicalColumn, ComparatorKind, CanonicalFunctionRef, CanonicalFetchShape, CanonicalDefinition, CanonicalTable } from './canonical.cjs';
|
|
2
|
+
import { b as CellPart } from './constants-C6EG6Wq7.cjs';
|
|
2
3
|
import { ColumnsSelection } from 'drizzle-orm';
|
|
3
4
|
import { TypedQueryBuilder } from 'drizzle-orm/query-builders/query-builder';
|
|
4
5
|
import { QueryBuilder, PgView, PgTable, AnyPgColumn } from 'drizzle-orm/pg-core';
|
|
6
|
+
export { S as SqlOperationDefinition, d as defineOperation } from './definition-DjfC7Lll.cjs';
|
|
5
7
|
import 'zod';
|
|
8
|
+
import './policy-1iZbGnZZ.cjs';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Fluent column builders for the v2 authoring surface — `t.uuid()`,
|
|
@@ -61,6 +64,8 @@ declare class ColumnBuilder {
|
|
|
61
64
|
cast(usingSql: string): this;
|
|
62
65
|
/** Emits `@deprecated` in the generated SDL; the column stays queryable. */
|
|
63
66
|
deprecated(): this;
|
|
67
|
+
/** @internal System cell-metadata part of logical column `of` (generated resolved views only). */
|
|
68
|
+
cellPart(of: string, part: CellPart): this;
|
|
64
69
|
/** Whether `.primaryKey()` was called — collected into the table-level PK. */
|
|
65
70
|
get isPrimaryKey(): boolean;
|
|
66
71
|
/** The enum name when this is an enum column, else undefined. */
|
|
@@ -117,7 +122,7 @@ interface CowMutationInput {
|
|
|
117
122
|
interface OverrideRowMutationInput<TOverlay extends OverlayTableRef = OverlayTableRef, TSynced extends SeqTable = SeqTable> {
|
|
118
123
|
/** Writable ORM overlay table (or `{ tableName, columns }` descriptor). */
|
|
119
124
|
overlay: TOverlay;
|
|
120
|
-
/** Read-only synced table reflecting
|
|
125
|
+
/** Read-only synced table reflecting its qualified source relation. */
|
|
121
126
|
synced: TSynced;
|
|
122
127
|
/**
|
|
123
128
|
* Property name of the single-column primary key shared by both tables.
|
|
@@ -179,6 +184,8 @@ interface RevertOverlayMutationInput<TOverlay extends OverlayTableRef = OverlayT
|
|
|
179
184
|
* ],
|
|
180
185
|
* })
|
|
181
186
|
* ```
|
|
187
|
+
*
|
|
188
|
+
* @deprecated Resolved tables write sparse cells directly (`defineResolvedTable`). Kept so existing definitions still compile.
|
|
182
189
|
*/
|
|
183
190
|
declare function overrideRowMutation<TOverlay extends OverlayTableRef, TSynced extends SeqTable>(input: OverrideRowMutationInput<TOverlay, TSynced>): CowMutationInput;
|
|
184
191
|
/**
|
|
@@ -187,9 +194,182 @@ declare function overrideRowMutation<TOverlay extends OverlayTableRef, TSynced e
|
|
|
187
194
|
*
|
|
188
195
|
* The DELETE is gated on a matching synced row — overlay-only creates (or rows
|
|
189
196
|
* whose synced source disappeared) are not deleted by revert.
|
|
197
|
+
*
|
|
198
|
+
* @deprecated Resolved tables write sparse cells directly (`defineResolvedTable`). Kept so existing definitions still compile.
|
|
190
199
|
*/
|
|
191
200
|
declare function revertOverlayMutation<TOverlay extends OverlayTableRef, TSynced extends SeqTable>(input: RevertOverlayMutationInput<TOverlay, TSynced>): CowMutationInput;
|
|
192
201
|
|
|
202
|
+
/**
|
|
203
|
+
* `defineResolvedTable` — one logical table backed by manual, etl and
|
|
204
|
+
* prefetch sources, with a SQL comparator per column.
|
|
205
|
+
*
|
|
206
|
+
* It expands into existing primitives so DDL, apply, SDL and policy
|
|
207
|
+
* compilation stay shared:
|
|
208
|
+
*
|
|
209
|
+
* - one internal table per manual/prefetch source (`<name>__<source>`,
|
|
210
|
+
* `cellMetadata: true`, sparse nullable columns),
|
|
211
|
+
* - the author's own synced tables for etl sources,
|
|
212
|
+
* - a managed view named `<name>` whose generated query unions every
|
|
213
|
+
* source's primary keys (so `pk = $1` pushes down into each source),
|
|
214
|
+
* left-joins each source back, and picks every column's winner with a
|
|
215
|
+
* CASE over typed per-cell timestamps (built-in comparators) or a small
|
|
216
|
+
* ORDER BY … LIMIT 1 lateral (custom).
|
|
217
|
+
*
|
|
218
|
+
* All comparators run in SQL — never app code — so reads stay one statement
|
|
219
|
+
* and filters/policies see resolved values.
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
/** A duration: milliseconds, or a string like `'1500ms'`, `'30s'`, `'5m'`. */
|
|
223
|
+
type DurationInput = number | `${number}ms` | `${number}s` | `${number}m`;
|
|
224
|
+
type FunctionRef = CanonicalFunctionRef;
|
|
225
|
+
/** A Managed Function (id or slug) that implements a prefetch source's fetch and writeback. */
|
|
226
|
+
declare function managedFn(id: string): FunctionRef;
|
|
227
|
+
interface ManualSourceInput {
|
|
228
|
+
readonly kind: 'manual';
|
|
229
|
+
}
|
|
230
|
+
interface EtlSourceInput {
|
|
231
|
+
readonly kind: 'etl';
|
|
232
|
+
/** A `defineSyncedTable` relation fed by a pipeline. */
|
|
233
|
+
readonly table: RelationRef;
|
|
234
|
+
/** Property on the synced table whose value timestamps every cell (e.g. an ingested_at column). */
|
|
235
|
+
readonly updatedAt?: string;
|
|
236
|
+
/** Resolved columns this source supplies; defaults to every column the synced table shares by name. */
|
|
237
|
+
readonly columns?: readonly string[];
|
|
238
|
+
}
|
|
239
|
+
interface PrefetchSourceInput {
|
|
240
|
+
readonly kind: 'prefetch';
|
|
241
|
+
readonly function: FunctionRef;
|
|
242
|
+
/** Resolved column holding the source system's key (may be the primary key). */
|
|
243
|
+
readonly key: string;
|
|
244
|
+
/** Resolved columns the function returns. */
|
|
245
|
+
readonly columns: readonly string[];
|
|
246
|
+
/** What the source API supports: one key per call, or batches. */
|
|
247
|
+
readonly fetch: 'single' | {
|
|
248
|
+
readonly batch: {
|
|
249
|
+
readonly maxKeys: number;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
readonly prefetchDefaults?: {
|
|
253
|
+
readonly maxStaleness?: DurationInput;
|
|
254
|
+
readonly timeout?: DurationInput;
|
|
255
|
+
readonly onError?: 'fallback' | 'fail';
|
|
256
|
+
};
|
|
257
|
+
readonly writeback?: {
|
|
258
|
+
readonly columns: readonly string[];
|
|
259
|
+
readonly defaultMode?: 'sync' | 'async';
|
|
260
|
+
readonly timeout?: DurationInput;
|
|
261
|
+
readonly clearManualOnConfirm?: boolean;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
type ResolvedSourceInput = ManualSourceInput | EtlSourceInput | PrefetchSourceInput;
|
|
265
|
+
declare function manualSource(): ManualSourceInput;
|
|
266
|
+
declare function etlSource(input: Omit<EtlSourceInput, 'kind'>): EtlSourceInput;
|
|
267
|
+
declare function prefetchSource(input: Omit<PrefetchSourceInput, 'kind'>): PrefetchSourceInput;
|
|
268
|
+
interface Comparator {
|
|
269
|
+
readonly kind: ComparatorKind;
|
|
270
|
+
readonly candidates: readonly string[];
|
|
271
|
+
readonly orderBy?: string;
|
|
272
|
+
}
|
|
273
|
+
/** Newest `updated_at` wins; source order breaks ties. */
|
|
274
|
+
declare const latest: (candidates: readonly string[]) => Comparator;
|
|
275
|
+
/** Largest value wins. */
|
|
276
|
+
declare const highest: (candidates: readonly string[]) => Comparator;
|
|
277
|
+
/** Smallest value wins. */
|
|
278
|
+
declare const lowest: (candidates: readonly string[]) => Comparator;
|
|
279
|
+
/** First candidate with an opinion (a cleared cell counts) wins. */
|
|
280
|
+
declare const priority: (candidates: readonly string[]) => Comparator;
|
|
281
|
+
/** First candidate with a non-null value wins. */
|
|
282
|
+
declare const nonNullFirst: (candidates: readonly string[]) => Comparator;
|
|
283
|
+
/**
|
|
284
|
+
* Author-defined SQL ORDER BY key over each candidate's `value`, `updated_at`,
|
|
285
|
+
* `source`, `actor` and `ord` (its position in `candidates`). The first row
|
|
286
|
+
* wins; `ord` is always appended as the final tie-break.
|
|
287
|
+
*
|
|
288
|
+
* ```ts
|
|
289
|
+
* custom(['edits', 'abrigo'], "CASE WHEN source = 'abrigo' AND value IS NOT NULL THEN 0 ELSE 1 END")
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
declare const custom: (candidates: readonly string[], orderBy: string) => Comparator;
|
|
293
|
+
interface ResolvedTablePoliciesInput {
|
|
294
|
+
read: PolicyInput;
|
|
295
|
+
write?: PolicyInput;
|
|
296
|
+
insert?: PolicyInput;
|
|
297
|
+
update?: PolicyInput;
|
|
298
|
+
}
|
|
299
|
+
interface ResolvedTableConfig {
|
|
300
|
+
description?: string;
|
|
301
|
+
sources: Record<string, ResolvedSourceInput>;
|
|
302
|
+
/** Per-column comparator; unlisted columns use `default`. */
|
|
303
|
+
resolve?: Record<string, Comparator>;
|
|
304
|
+
/** Fallback comparator; each column keeps only the candidates that supply it. Defaults to priority(manual, prefetch…, etl…). */
|
|
305
|
+
default?: Comparator;
|
|
306
|
+
rows?: {
|
|
307
|
+
deletedBy?: readonly string[];
|
|
308
|
+
};
|
|
309
|
+
links?: Record<string, SeqLink>;
|
|
310
|
+
/** Reads use `read`; writes are evaluated against the resolved row. */
|
|
311
|
+
policies: ResolvedTablePoliciesInput;
|
|
312
|
+
/**
|
|
313
|
+
* Store the resolved rows in an indexed internal table instead of
|
|
314
|
+
* computing them on every read, so filters and sorts on resolved values can
|
|
315
|
+
* use `indexes`. The data plane refreshes a row in the same transaction as
|
|
316
|
+
* any ORM write to its sources (edits, prefetch, writeback); ETL changes are
|
|
317
|
+
* picked up by a periodic reconcile. Every ETL source must have read policy
|
|
318
|
+
* `'true'` — the copy is shared by all callers.
|
|
319
|
+
*/
|
|
320
|
+
materialize?: true | {
|
|
321
|
+
indexes?: readonly IndexInput[];
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
/** Authoring-side resolved metadata carried on the generated view (serialized by namespace.ts). */
|
|
325
|
+
interface ResolvedViewConfig {
|
|
326
|
+
readonly internalTables: readonly SeqTable[];
|
|
327
|
+
/** A materialized table's compute view. */
|
|
328
|
+
readonly internalViews?: readonly SeqView[];
|
|
329
|
+
readonly materialized?: {
|
|
330
|
+
readonly table: string;
|
|
331
|
+
readonly compute: string;
|
|
332
|
+
};
|
|
333
|
+
readonly sources: ReadonlyArray<ResolvedSourcePlan>;
|
|
334
|
+
readonly rules: ReadonlyArray<{
|
|
335
|
+
column: string;
|
|
336
|
+
comparator: ComparatorKind;
|
|
337
|
+
candidates: string[];
|
|
338
|
+
orderBy?: string;
|
|
339
|
+
}>;
|
|
340
|
+
readonly deletedBy: readonly string[];
|
|
341
|
+
readonly policies: Omit<ResolvedTablePoliciesInput, 'read'>;
|
|
342
|
+
}
|
|
343
|
+
interface ResolvedSourcePlan {
|
|
344
|
+
readonly name: string;
|
|
345
|
+
readonly kind: ResolvedSourceInput['kind'];
|
|
346
|
+
readonly table: SeqTable;
|
|
347
|
+
readonly columns: readonly string[];
|
|
348
|
+
readonly updatedAt?: string;
|
|
349
|
+
readonly key?: string;
|
|
350
|
+
readonly fetch?: CanonicalFetchShape;
|
|
351
|
+
readonly function?: FunctionRef;
|
|
352
|
+
readonly prefetchDefaults?: {
|
|
353
|
+
maxStalenessMs: number;
|
|
354
|
+
timeoutMs: number;
|
|
355
|
+
onError: 'fallback' | 'fail';
|
|
356
|
+
};
|
|
357
|
+
readonly writeback?: {
|
|
358
|
+
columns: string[];
|
|
359
|
+
defaultMode: 'sync' | 'async';
|
|
360
|
+
timeoutMs: number;
|
|
361
|
+
clearManualOnConfirm: boolean;
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
declare const SYSTEM_VIEW_COLUMNS: {
|
|
365
|
+
readonly writebackStatus: () => ColumnBuilder;
|
|
366
|
+
readonly writebackError: () => ColumnBuilder;
|
|
367
|
+
};
|
|
368
|
+
type SystemViewColumns = {
|
|
369
|
+
[K in keyof typeof SYSTEM_VIEW_COLUMNS]: ColumnBuilder;
|
|
370
|
+
};
|
|
371
|
+
declare function defineResolvedTable<const TColumns extends Record<string, ColumnBuilder>>(name: string, columns: TColumns, config: ResolvedTableConfig): SeqView<TColumns & SystemViewColumns>;
|
|
372
|
+
|
|
193
373
|
/**
|
|
194
374
|
* Managed regular-view authoring. A view keeps its GraphQL contract in the
|
|
195
375
|
* Sequence column/policy DSL, while its SELECT is authored with Drizzle and
|
|
@@ -212,6 +392,10 @@ interface ViewConfig {
|
|
|
212
392
|
links?: Record<string, SeqLink>;
|
|
213
393
|
policies: ViewPoliciesInput;
|
|
214
394
|
query: (context: ViewQueryContext) => ViewSelectQuery;
|
|
395
|
+
/** Set by defineResolvedTable — multi-source metadata serialized onto the canonical view. */
|
|
396
|
+
resolved?: ResolvedViewConfig;
|
|
397
|
+
/** System-owned view (a materialized resolved table's compute view): no GraphQL surface. Set by defineResolvedTable. */
|
|
398
|
+
internal?: boolean;
|
|
215
399
|
}
|
|
216
400
|
interface SeqView<TColumns extends Record<string, ColumnBuilder> = Record<string, ColumnBuilder>> {
|
|
217
401
|
readonly kind: typeof VIEW_BRAND;
|
|
@@ -228,7 +412,7 @@ declare function defineView<const TColumns extends Record<string, ColumnBuilder>
|
|
|
228
412
|
interface OverlayWinsUnionInput<TOverlay extends SeqTable = SeqTable, TSynced extends SeqTable = SeqTable> {
|
|
229
413
|
/** The ORM overlay table (writable, has `tombstone` if soft-delete is used). */
|
|
230
414
|
overlay: TOverlay;
|
|
231
|
-
/** The synced (read-only) table reflecting
|
|
415
|
+
/** The synced (read-only) table reflecting its qualified source relation. */
|
|
232
416
|
synced: TSynced;
|
|
233
417
|
/**
|
|
234
418
|
* Property name of the single-column primary key shared by both tables.
|
|
@@ -258,6 +442,8 @@ interface OverlayWinsUnionInput<TOverlay extends SeqTable = SeqTable, TSynced ex
|
|
|
258
442
|
* policies: { read: 'true' },
|
|
259
443
|
* })
|
|
260
444
|
* ```
|
|
445
|
+
*
|
|
446
|
+
* @deprecated Use `defineResolvedTable` — per-cell comparators over manual/etl/prefetch sources. Kept so existing definitions still compile.
|
|
261
447
|
*/
|
|
262
448
|
declare function overlayWinsUnion<TOverlay extends SeqTable, TSynced extends SeqTable>(input: OverlayWinsUnionInput<TOverlay, TSynced>): ViewConfig['query'];
|
|
263
449
|
|
|
@@ -266,8 +452,16 @@ declare const LINK_BRAND: "seq-link";
|
|
|
266
452
|
/** A link target: a managed table/view, or a lazy thunk for forward/cyclic references. */
|
|
267
453
|
type RelationRef = SeqTable | SeqView | (() => SeqTable | SeqView);
|
|
268
454
|
/** Backward-compatible alias retained for existing consumers. */
|
|
269
|
-
type TableRef = RelationRef;
|
|
455
|
+
type TableRef = RelationRef | ExternalObjectRef;
|
|
456
|
+
interface ExternalObjectRef {
|
|
457
|
+
readonly kind: 'seq-external-object';
|
|
458
|
+
readonly namespace: string;
|
|
459
|
+
readonly table: string;
|
|
460
|
+
}
|
|
461
|
+
/** Qualified identity resolved against a pinned namespace contract at compile time. */
|
|
462
|
+
declare function objectRef(namespace: string, table: string): ExternalObjectRef;
|
|
270
463
|
type LinkKind = 'toOne' | 'toMany' | 'toPlatformUser';
|
|
464
|
+
type ReferentialAction = 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default';
|
|
271
465
|
interface SeqLink {
|
|
272
466
|
readonly kind: typeof LINK_BRAND;
|
|
273
467
|
readonly linkKind: LinkKind;
|
|
@@ -277,6 +471,8 @@ interface SeqLink {
|
|
|
277
471
|
readonly on: string;
|
|
278
472
|
readonly references: string | undefined;
|
|
279
473
|
readonly enforce: boolean;
|
|
474
|
+
readonly onDelete: ReferentialAction | undefined;
|
|
475
|
+
readonly onUpdate: ReferentialAction | undefined;
|
|
280
476
|
readonly description: string | undefined;
|
|
281
477
|
}
|
|
282
478
|
interface ToOneOptions {
|
|
@@ -284,6 +480,8 @@ interface ToOneOptions {
|
|
|
284
480
|
references?: string;
|
|
285
481
|
/** Emit a real FK constraint (same-namespace toOne only). */
|
|
286
482
|
enforce?: boolean;
|
|
483
|
+
onDelete?: ReferentialAction;
|
|
484
|
+
onUpdate?: ReferentialAction;
|
|
287
485
|
description?: string;
|
|
288
486
|
}
|
|
289
487
|
interface ToManyOptions {
|
|
@@ -330,6 +528,11 @@ interface IndexInput {
|
|
|
330
528
|
unique?: boolean;
|
|
331
529
|
name?: string;
|
|
332
530
|
}
|
|
531
|
+
/** Named PostgreSQL CHECK using the supported, validated predicate subset. */
|
|
532
|
+
interface CheckInput {
|
|
533
|
+
name: string;
|
|
534
|
+
expression: string;
|
|
535
|
+
}
|
|
333
536
|
/** Database integrity constraint; independent of GraphQL relationship traversal. */
|
|
334
537
|
interface ForeignKeyInput {
|
|
335
538
|
name: string;
|
|
@@ -338,14 +541,18 @@ interface ForeignKeyInput {
|
|
|
338
541
|
references: readonly string[];
|
|
339
542
|
/** Omit for immediate, non-deferrable PostgreSQL enforcement. */
|
|
340
543
|
deferrable?: 'initially-immediate' | 'initially-deferred';
|
|
544
|
+
onDelete?: ReferentialAction;
|
|
545
|
+
onUpdate?: ReferentialAction;
|
|
341
546
|
}
|
|
342
547
|
interface TableConfig {
|
|
548
|
+
displayName?: string;
|
|
343
549
|
description?: string;
|
|
344
550
|
/** Table-level migration rename hint (new in v2). */
|
|
345
551
|
renamedFrom?: string;
|
|
346
552
|
/** Composite primary key: property names (or column names). Mutually exclusive with column-level `.primaryKey()`. */
|
|
347
553
|
primaryKey?: readonly string[];
|
|
348
554
|
indexes?: readonly IndexInput[];
|
|
555
|
+
checks?: readonly CheckInput[];
|
|
349
556
|
foreignKeys?: readonly ForeignKeyInput[];
|
|
350
557
|
links?: Record<string, SeqLink>;
|
|
351
558
|
policies?: TablePoliciesInput;
|
|
@@ -356,13 +563,36 @@ interface TableConfig {
|
|
|
356
563
|
* mutation roots whose SQL the engine generates.
|
|
357
564
|
*/
|
|
358
565
|
cowMutations?: readonly CowMutationInput[];
|
|
566
|
+
/**
|
|
567
|
+
* Track per-cell edit metadata: every data column `c` gets typed system
|
|
568
|
+
* columns `c__at` (timestamptz) and `c__by` (text), stamped by each
|
|
569
|
+
* insert/update for exactly the columns it writes. Read through the typed
|
|
570
|
+
* GraphQL field `cells { c { at by } }`; never client-writable.
|
|
571
|
+
*/
|
|
572
|
+
cellMetadata?: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Internal (resolved-table manual source): also keep a `c__rev` uuid per
|
|
575
|
+
* cell identifying each edit. Set by defineResolvedTable.
|
|
576
|
+
*/
|
|
577
|
+
cellRevisions?: boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Internal: this table is the materialized copy of resolved table
|
|
580
|
+
* `materializes` (its columns mirror the view, cell parts included). Set by
|
|
581
|
+
* defineResolvedTable.
|
|
582
|
+
*/
|
|
583
|
+
materializes?: string;
|
|
584
|
+
/**
|
|
585
|
+
* System-owned backing table of a resolved table (set by
|
|
586
|
+
* defineResolvedTable). Gets DDL but no GraphQL surface.
|
|
587
|
+
*/
|
|
588
|
+
internal?: boolean;
|
|
359
589
|
}
|
|
360
590
|
interface SeqTable<TColumns extends Record<string, ColumnBuilder> = Record<string, ColumnBuilder>> {
|
|
361
591
|
readonly kind: typeof TABLE_BRAND;
|
|
362
592
|
readonly tableName: string;
|
|
363
593
|
readonly columns: Readonly<TColumns>;
|
|
364
594
|
readonly config: TableConfig;
|
|
365
|
-
/** Synced reflected source (`
|
|
595
|
+
/** Synced reflected source (`schema.table`) — set only by defineSyncedTable. */
|
|
366
596
|
readonly source: string | undefined;
|
|
367
597
|
/** Consumer file that defined the table (set when loaded via loadNamespaceFromDir). */
|
|
368
598
|
readonly file: string | undefined;
|
|
@@ -374,11 +604,11 @@ interface SyncedTablePoliciesInput {
|
|
|
374
604
|
read?: PolicyInput;
|
|
375
605
|
}
|
|
376
606
|
/**
|
|
377
|
-
* Config for a read-only
|
|
607
|
+
* Config for a read-only qualified-source reflection. Columns (typed overload) are a contract
|
|
378
608
|
* for views/clients — ORM does not own synced DDL.
|
|
379
609
|
*/
|
|
380
610
|
interface SyncedTableConfig {
|
|
381
|
-
/** Reflected read-only source
|
|
611
|
+
/** Reflected read-only source as a safe qualified identifier: `<schema>.<table>`. */
|
|
382
612
|
source: string;
|
|
383
613
|
description?: string;
|
|
384
614
|
/** Composite primary key: property names (or column names). Mutually exclusive with column-level `.primaryKey()`. */
|
|
@@ -411,12 +641,16 @@ interface NamespaceConfigInput {
|
|
|
411
641
|
namespace: string;
|
|
412
642
|
description?: string;
|
|
413
643
|
capabilities?: NamespaceCapabilitiesInput;
|
|
644
|
+
imports?: readonly unknown[];
|
|
645
|
+
exports?: CanonicalDefinition['exports'];
|
|
414
646
|
}
|
|
415
647
|
interface SeqNamespaceConfig {
|
|
416
648
|
readonly kind: typeof NAMESPACE_CONFIG_BRAND;
|
|
417
649
|
readonly namespace: string;
|
|
418
650
|
readonly description: string | undefined;
|
|
419
651
|
readonly capabilities: NamespaceCapabilitiesInput;
|
|
652
|
+
readonly imports?: readonly unknown[];
|
|
653
|
+
readonly exports?: CanonicalDefinition['exports'];
|
|
420
654
|
readonly file: string | undefined;
|
|
421
655
|
}
|
|
422
656
|
declare function isSeqNamespaceConfig(value: unknown): value is SeqNamespaceConfig;
|
|
@@ -553,4 +787,14 @@ declare function beginAuthoringContext(): AuthoringContext;
|
|
|
553
787
|
declare function endAuthoringContext(context: AuthoringContext): void;
|
|
554
788
|
declare function activeAuthoringContext(): AuthoringContext | undefined;
|
|
555
789
|
|
|
556
|
-
|
|
790
|
+
interface CatalogFolders {
|
|
791
|
+
[name: string]: CatalogFolders | null;
|
|
792
|
+
}
|
|
793
|
+
/** Presentation-only organization; never included in the canonical schema hash. */
|
|
794
|
+
interface NamespaceCatalog {
|
|
795
|
+
folders: CatalogFolders;
|
|
796
|
+
objects: Record<string, string>;
|
|
797
|
+
}
|
|
798
|
+
declare function validateNamespaceCatalog(catalog: NamespaceCatalog, file?: string): void;
|
|
799
|
+
|
|
800
|
+
export { type AuthoringContext, type AuthoringRegistration, COLUMN_BRAND, COLUMN_DEFAULT_FNS, type CatalogFolders, type CheckInput, ColumnBuilder, type ColumnDefaultFn, type ColumnDefaultLiteral, type ColumnTypeSpec, type Comparator, type CowMutationInput, type DrizzleRelation, type DurationInput, ENUM_BRAND, type EnumRef, type EtlSourceInput, type ExternalObjectRef, type ForeignKeyInput, type FunctionRef, type IndexInput, LINK_BRAND, type LinkKind, type LoadNamespaceOptions, type LoadedNamespaceV2, type ManualSourceInput, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, type NamespaceCapabilitiesInput, type NamespaceCatalog, type NamespaceConfigInput, ORM_TO_PIPELINE_TYPE, type OrmContractColumnMap, type OrmContractPipelineColumn, type OrmSyncedTableContract, type OrmToPipelineType, type OverlayTableRef, type OverlayWinsUnionInput, type OverrideRowMutationInput, type PolicyInput, type PolicyVariantInput, type PolicyWithVariantsInput, type PrefetchSourceInput, type ReferentialAction, type RelationRef, type ResolvedSourceInput, type ResolvedTableConfig, type ResolvedTablePoliciesInput, type RevertOverlayMutationInput, SCHEMA_DIR, SYNCED_CONTRACT_HASH_DOMAIN, type SeqLink, type SeqNamespaceConfig, type SeqTable, type SeqView, type SerializeNamespaceInput, type SyncedTableConfig, type SyncedTablePoliciesInput, TABLE_BRAND, type TableConfig, type TablePoliciesInput, type TableRef, type ToManyOptions, type ToOneOptions, type ToPlatformUserOptions, type TypedSyncedTableConfig, VIEW_BRAND, type ViewConfig, type ViewPoliciesInput, type ViewQueryContext, type ViewSelectQuery, activeAuthoringContext, beginAuthoringContext, computeCanonicalHash, computeSyncedContractHash, custom, defineEnum, defineNamespace, defineResolvedTable, defineSyncedTable, defineTable, defineView, deriveColumnName, endAuthoringContext, etlSource, extractOrmSyncedTableContract, highest, isColumnBuilder, isEnumRef, isSeqLink, isSeqNamespaceConfig, isSeqTable, isSeqView, latest, loadNamespaceFromDir, lowest, managedFn, manualSource, nonNullFirst, objectRef, overlayWinsUnion, overrideRowMutation, prefetchSource, priority, revertOverlayMutation, serializeNamespace, syncedContractSurface, t, toMany, toOne, toPlatformUser, validateNamespaceCatalog };
|