@prisma-next/sql-lane-query-builder 0.8.0 → 0.9.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +485 -63
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -7
- package/src/root.ts +7 -1
package/dist/index.d.mts
CHANGED
|
@@ -234,94 +234,516 @@ type TableAsterisk<TTableName extends string = string, THash extends StorageHash
|
|
|
234
234
|
readonly '~table': TTableName;
|
|
235
235
|
} & Brand<'[info] referencing all columns that belong to the following table reference:', `${TTableName}@${THash}`>;
|
|
236
236
|
//#endregion
|
|
237
|
-
//#region
|
|
238
|
-
//#region src/
|
|
237
|
+
//#region ../../../1-framework/1-core/framework-components/dist/ir.d.mts
|
|
238
|
+
//#region src/ir/ir-node.d.ts
|
|
239
|
+
/**
|
|
240
|
+
* Framework-level IR alphabet.
|
|
241
|
+
*
|
|
242
|
+
* The framework's contribution to Contract IR / Schema IR is a common
|
|
243
|
+
* root for the IR class hierarchy and a freeze affordance. Family
|
|
244
|
+
* abstract bases (e.g. `SqlNode`, `MongoSchemaIRNode`) refine the alphabet
|
|
245
|
+
* for their family shape; targets ship the concrete classes.
|
|
246
|
+
*
|
|
247
|
+
* `kind` is an optional discriminator on the base. Families and leaves
|
|
248
|
+
* that benefit from discriminated-union dispatch declare their own
|
|
249
|
+
* literal `kind` at the level that earns it — Mongo leaves carry
|
|
250
|
+
* per-class literals (`readonly kind = 'mongo-collection' as const`)
|
|
251
|
+
* because Mongo IR has polymorphic walkers; SQL declares a single
|
|
252
|
+
* family-level `kind = 'sql'` on `SqlNode` because SQL IR has no
|
|
253
|
+
* polymorphic dispatch today. No framework consumer dispatches on
|
|
254
|
+
* `IRNode.kind` at the BASE type — every dispatch site narrows
|
|
255
|
+
* through a union of leaves where each leaf carries a literal kind, so
|
|
256
|
+
* requiring `kind` at the base would be unearned. Future leaves that
|
|
257
|
+
* earn polymorphic dispatch override with a required literal at that
|
|
258
|
+
* leaf (e.g. `override readonly kind = 'postgres-enum' as const`).
|
|
259
|
+
*
|
|
260
|
+
* `IRNodeBase` carries no methods: the freeze-and-assign affordance
|
|
261
|
+
* lives in the free `freezeNode` helper below. Keeping `freezeNode` out
|
|
262
|
+
* of the class type means an emitted contract literal type
|
|
263
|
+
* (`{ readonly kind: 'mongo-collection', ... }` or an unkeyed literal
|
|
264
|
+
* like `{ nativeType, codecId, nullable }`) is structurally assignable
|
|
265
|
+
* to its class type — a `protected freeze()` instance method would
|
|
266
|
+
* otherwise leak into the public type surface and require the literal
|
|
267
|
+
* to carry it too.
|
|
268
|
+
*
|
|
269
|
+
* Subclasses construct fields then call `freezeNode(this)` to seal the
|
|
270
|
+
* instance. Frozen instances + plain readonly fields keep IR nodes
|
|
271
|
+
* JSON-clean by construction, so `JSON.stringify(node)` produces canonical
|
|
272
|
+
* JSON without a `toJSON()` method. The `ContractSerializer` SPI handles
|
|
273
|
+
* round-trip from canonical JSON back to typed class instances.
|
|
274
|
+
*
|
|
275
|
+
* The name (`IRNode` / `IRNodeBase`) reflects the dual-hierarchy reality:
|
|
276
|
+
* this base is the common root for both Contract IR and Schema IR class
|
|
277
|
+
* hierarchies, not a Schema-IR-specific alphabet.
|
|
278
|
+
*/
|
|
279
|
+
interface IRNode {
|
|
280
|
+
readonly kind?: string;
|
|
281
|
+
}
|
|
282
|
+
declare abstract class IRNodeBase implements IRNode {
|
|
283
|
+
abstract readonly kind?: string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Seal an IR class instance after its constructor has assigned all
|
|
287
|
+
* fields. The free-helper form (rather than a `protected freeze()`
|
|
288
|
+
* instance method) keeps the class type structurally narrow so emitted
|
|
289
|
+
* contract literal types remain assignable to their class types.
|
|
290
|
+
*
|
|
291
|
+
* The helper name stays `freezeNode` — it operates on IR nodes
|
|
292
|
+
* regardless of root naming.
|
|
293
|
+
*/
|
|
294
|
+
/**
|
|
295
|
+
* Framework-level building block for a "namespace" — the database-level
|
|
296
|
+
* grouping under which storage objects (tables, collections, enums, …)
|
|
297
|
+
* reside. Each target's namespace concretion maps the framework concept to
|
|
298
|
+
* a target-native binding:
|
|
299
|
+
*
|
|
300
|
+
* - Postgres: a schema (`CREATE SCHEMA …`); rendered as `"<schema>"`.
|
|
301
|
+
* - SQLite: the singleton `UNSPECIFIED_NAMESPACE_ID`; emitted SQL has no qualifier.
|
|
302
|
+
* - Mongo: the connection's `db` field; addressed as a database name.
|
|
303
|
+
*
|
|
304
|
+
* See `UNSPECIFIED_NAMESPACE_ID` above for the sentinel id and the
|
|
305
|
+
* singleton-subclass pattern that materialises it.
|
|
306
|
+
*/
|
|
307
|
+
interface Namespace extends IRNode {
|
|
308
|
+
readonly id: string;
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/ir/storage.d.ts
|
|
312
|
+
/**
|
|
313
|
+
* Framework-level promise that every Contract IR / Schema IR carries a
|
|
314
|
+
* collection of namespaces keyed by namespace id. Family storage
|
|
315
|
+
* concretions (`SqlStorage`, `MongoStorage`) refine the shape with
|
|
316
|
+
* family-specific fields (tables, collections, enums, …); target
|
|
317
|
+
* concretions add target fields where the family vocabulary doesn't
|
|
318
|
+
* reach.
|
|
319
|
+
*
|
|
320
|
+
* Keeping `namespaces` at the framework layer enforces that every storage
|
|
321
|
+
* object — across any target — is namespace-scoped. The framework can
|
|
322
|
+
* therefore walk the namespace map without knowing the family alphabet, and
|
|
323
|
+
* the `(namespace.id, name)` keying that the verifier and planner depend on
|
|
324
|
+
* is honest at every layer.
|
|
325
|
+
*
|
|
326
|
+
* Extends `IRNode` so the framework's IR-walking surfaces (verifiers,
|
|
327
|
+
* serializers) can dispatch on `Storage`-typed slots through the same
|
|
328
|
+
* IR-node alphabet as every other node — the structural dual already
|
|
329
|
+
* holds in code (every concrete storage class extends an IR-node base);
|
|
330
|
+
* the interface promotion makes the typing honest.
|
|
331
|
+
*
|
|
332
|
+
* **Persisted envelope shape is target-owned, not framework-promised.**
|
|
333
|
+
* Whether the `namespaces` map appears in the on-disk JSON envelope is
|
|
334
|
+
* a per-target decision made by `ContractSerializer.serializeContract`.
|
|
335
|
+
* Some targets emit a JSON-clean namespace shape that round-trips
|
|
336
|
+
* through `JSON.stringify` cleanly (SQL today via the family-layer
|
|
337
|
+
* identity serializer); others ship runtime-only fields on their
|
|
338
|
+
* namespace concretions and override `serializeContract` to strip
|
|
339
|
+
* them (Mongo). Future open (F16): extend the per-target
|
|
340
|
+
* `ContractSerializer` integration-test surface with an explicit
|
|
341
|
+
* envelope-shape assertion for each target, so the strip-vs-pass-through
|
|
342
|
+
* choice is locked at test time rather than implied by the override
|
|
343
|
+
* presence/absence. Earned by PR2's per-target namespace lift, when
|
|
344
|
+
* `PostgresSchema` / `SqliteUnspecifiedDatabase` start carrying
|
|
345
|
+
* target-specific fields.
|
|
346
|
+
*/
|
|
347
|
+
interface Storage extends IRNode {
|
|
348
|
+
readonly namespaces: Readonly<Record<string, Namespace>>;
|
|
349
|
+
} //#endregion
|
|
350
|
+
//#region src/ir/storage-type.d.ts
|
|
351
|
+
/**
|
|
352
|
+
* Framework-level alphabet for entries in a storage `types` slot.
|
|
353
|
+
*
|
|
354
|
+
* The slot is polymorphic at the framework level: a family or target can
|
|
355
|
+
* persist either a JSON-clean codec-triple object literal (carrying
|
|
356
|
+
* `kind: 'codec-instance'`) or a class-instance IR node with a narrower
|
|
357
|
+
* kind discriminator (e.g. `'postgres-enum'`). Hydration walkers,
|
|
358
|
+
* verifiers, and planners dispatch on the `kind` literal to recover the
|
|
359
|
+
* precise variant.
|
|
360
|
+
*
|
|
361
|
+
* The `kind` field is required at this layer (in contrast with
|
|
362
|
+
* `IRNode.kind` which is optional) because the slot's downstream
|
|
363
|
+
* consumers dispatch on it — without a guaranteed discriminator the
|
|
364
|
+
* polymorphic walk cannot pick the right reader. Concrete variants
|
|
365
|
+
* narrow `kind` to their literal and add their own field set;
|
|
366
|
+
* downstream consumers use `kind`-discriminator helpers to recover
|
|
367
|
+
* the precise shape.
|
|
368
|
+
*/
|
|
369
|
+
interface StorageType extends IRNode {
|
|
370
|
+
readonly kind: string;
|
|
371
|
+
} //#endregion
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region ../../1-core/contract/dist/types-B0lbr9cb.d.mts
|
|
374
|
+
//#region src/ir/sql-node.d.ts
|
|
375
|
+
/**
|
|
376
|
+
* SQL family IR node base. Carries the family-level `kind` discriminator
|
|
377
|
+
* `'sql'` and inherits the framework's `freezeNode` affordance.
|
|
378
|
+
*
|
|
379
|
+
* Single family-level discriminator (not per-leaf) reflects the fact that
|
|
380
|
+
* SQL IR has no polymorphic dispatch today — verifiers and serializers
|
|
381
|
+
* walk by structural position (`storage.tables[name].columns[name]`),
|
|
382
|
+
* not by inspecting `kind`. The abstract bar for per-leaf discriminators
|
|
383
|
+
* isn't earned until a future polymorphic consumer arrives.
|
|
384
|
+
*
|
|
385
|
+
* `kind` is installed as a non-enumerable own property on every instance,
|
|
386
|
+
* which keeps three things clean simultaneously:
|
|
387
|
+
*
|
|
388
|
+
* - `JSON.stringify(node)` produces the canonical pre-lift JSON envelope
|
|
389
|
+
* shape (no `kind` field), so emitted contract.json files and the
|
|
390
|
+
* `validateSqlContractFully` arktype schemas stay unchanged.
|
|
391
|
+
* - Test assertions that use `toEqual({...})` against the pre-lift flat
|
|
392
|
+
* shape continue to pass — only enumerable own properties are
|
|
393
|
+
* compared.
|
|
394
|
+
* - Direct access (`node.kind`) and runtime narrowing
|
|
395
|
+
* (`if (node.kind === 'sql')`) still work, so future polymorphic
|
|
396
|
+
* dispatch can begin reading `kind` without a runtime change.
|
|
397
|
+
*
|
|
398
|
+
* Future per-leaf overrides land cleanly: a class that gains a
|
|
399
|
+
* polymorphic-dispatch consumer (e.g. an enum type instance walked
|
|
400
|
+
* alongside other types) overrides `kind` with its narrower literal
|
|
401
|
+
* at that leaf level. Per-leaf overrides will use enumerable kind
|
|
402
|
+
* (matching the Mongo per-class-discriminator precedent) because they
|
|
403
|
+
* encode dispatch-relevant information that callers need to see in
|
|
404
|
+
* JSON envelopes; the family-level `'sql'` is uniform across all SQL
|
|
405
|
+
* IR and carries no dispatch-relevant information.
|
|
406
|
+
*/
|
|
407
|
+
declare abstract class SqlNode extends IRNodeBase {
|
|
408
|
+
readonly kind?: string;
|
|
409
|
+
constructor();
|
|
410
|
+
} //#endregion
|
|
411
|
+
//#region src/ir/foreign-key-references.d.ts
|
|
412
|
+
interface ForeignKeyReferencesInput {
|
|
413
|
+
readonly table: string;
|
|
414
|
+
readonly columns: readonly string[];
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* SQL Contract IR node for the referenced side of a foreign key.
|
|
418
|
+
*
|
|
419
|
+
* The class is shaped around single-namespace references today; a
|
|
420
|
+
* future milestone introduces a cross-namespace coordinate on top of
|
|
421
|
+
* `(table, columns)` when namespace-keyed storage lands.
|
|
422
|
+
*/
|
|
423
|
+
declare class ForeignKeyReferences extends SqlNode {
|
|
424
|
+
readonly table: string;
|
|
425
|
+
readonly columns: readonly string[];
|
|
426
|
+
constructor(input: ForeignKeyReferencesInput);
|
|
427
|
+
} //#endregion
|
|
428
|
+
//#region src/ir/foreign-key.d.ts
|
|
429
|
+
type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
|
|
430
|
+
interface ForeignKeyInput {
|
|
431
|
+
readonly columns: readonly string[];
|
|
432
|
+
readonly references: ForeignKeyReferences | ForeignKeyReferencesInput;
|
|
433
|
+
readonly name?: string;
|
|
434
|
+
readonly onDelete?: ReferentialAction;
|
|
435
|
+
readonly onUpdate?: ReferentialAction;
|
|
436
|
+
/** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */
|
|
437
|
+
readonly constraint: boolean;
|
|
438
|
+
/** Whether to emit a backing index for the FK columns. */
|
|
439
|
+
readonly index: boolean;
|
|
440
|
+
}
|
|
239
441
|
/**
|
|
240
|
-
*
|
|
442
|
+
* SQL Contract IR node for a table-level foreign-key declaration.
|
|
241
443
|
*
|
|
242
|
-
* `
|
|
243
|
-
*
|
|
244
|
-
* a
|
|
444
|
+
* The nested `references` field is normalised to a
|
|
445
|
+
* {@link ForeignKeyReferences} instance inside the constructor so
|
|
446
|
+
* downstream walks see a uniform AST regardless of whether the input
|
|
447
|
+
* was a JSON literal or an already-constructed class instance.
|
|
245
448
|
*/
|
|
246
|
-
|
|
449
|
+
declare class ForeignKey extends SqlNode {
|
|
450
|
+
readonly columns: readonly string[];
|
|
451
|
+
readonly references: ForeignKeyReferences;
|
|
452
|
+
readonly constraint: boolean;
|
|
453
|
+
readonly index: boolean;
|
|
454
|
+
readonly name?: string;
|
|
455
|
+
readonly onDelete?: ReferentialAction;
|
|
456
|
+
readonly onUpdate?: ReferentialAction;
|
|
457
|
+
constructor(input: ForeignKeyInput);
|
|
458
|
+
} //#endregion
|
|
459
|
+
//#region src/ir/postgres-enum-storage-entry.d.ts
|
|
460
|
+
/**
|
|
461
|
+
* Discriminator literal for the Postgres-enum variant on the polymorphic
|
|
462
|
+
* `SqlStorage.types` slot.
|
|
463
|
+
*
|
|
464
|
+
* Enums are a target-level concept: Postgres ships native
|
|
465
|
+
* `CREATE TYPE … AS ENUM` while other SQL targets approximate enums via
|
|
466
|
+
* constraints. The literal lives at the SQL family layer because every
|
|
467
|
+
* SQL-family consumer (verifier, planner, lowering, …) needs to
|
|
468
|
+
* discriminate enum-typed slot entries from codec-typed ones. The
|
|
469
|
+
* concrete IR class (`PostgresEnumType`) lives in the target-postgres
|
|
470
|
+
* package and implements this structural contract; cross-domain
|
|
471
|
+
* layering rules forbid the SQL family from importing the concrete
|
|
472
|
+
* target class directly, so the discriminator and structural interface
|
|
473
|
+
* carry the dispatch.
|
|
474
|
+
*/
|
|
475
|
+
declare const POSTGRES_ENUM_KIND: "postgres-enum";
|
|
476
|
+
/**
|
|
477
|
+
* Structural contract every Postgres-enum slot entry honours — both
|
|
478
|
+
* the live `PostgresEnumType` IR-class instance and the raw JSON
|
|
479
|
+
* envelope shape that survives `JSON.stringify` round-trips. SQL
|
|
480
|
+
* family-layer dispatch narrows polymorphic `StorageType` slot
|
|
481
|
+
* entries to this shape via `isPostgresEnumStorageEntry`.
|
|
482
|
+
*
|
|
483
|
+
* The `codecBinding` field is accessor-shaped (live class instance) on
|
|
484
|
+
* the IR class and undefined on the raw JSON envelope; consumers that
|
|
485
|
+
* need it must guard for its presence (the JSON path synthesises an
|
|
486
|
+
* equivalent shape from `codecId` + `values`).
|
|
487
|
+
*/
|
|
488
|
+
interface PostgresEnumStorageEntry extends StorageType {
|
|
489
|
+
readonly kind: typeof POSTGRES_ENUM_KIND;
|
|
490
|
+
readonly name: string;
|
|
247
491
|
readonly nativeType: string;
|
|
248
|
-
readonly
|
|
249
|
-
readonly nullable: boolean;
|
|
250
|
-
/**
|
|
251
|
-
* Opaque, codec-owned JS/type parameters.
|
|
252
|
-
* The codec that owns `codecId` defines the shape and semantics.
|
|
253
|
-
* Mutually exclusive with `typeRef`.
|
|
254
|
-
*/
|
|
255
|
-
readonly typeParams?: Record<string, unknown>;
|
|
256
|
-
/**
|
|
257
|
-
* Reference to a named type instance in `storage.types`.
|
|
258
|
-
* Mutually exclusive with `typeParams`.
|
|
259
|
-
*/
|
|
260
|
-
readonly typeRef?: string;
|
|
492
|
+
readonly values: readonly string[];
|
|
261
493
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
494
|
+
* Enumerable own property on the persisted JSON envelope; the live
|
|
495
|
+
* IR-class instance carries it too. Family-shared dispatch sites
|
|
496
|
+
* read `codecId` directly rather than going through the IR-class
|
|
497
|
+
* `codecBinding` accessor (which lives on the prototype and isn't
|
|
498
|
+
* present on raw JSON envelopes).
|
|
264
499
|
*/
|
|
265
|
-
readonly
|
|
266
|
-
}
|
|
267
|
-
|
|
500
|
+
readonly codecId: string;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Narrow a polymorphic `StorageType` entry to the Postgres-enum shape
|
|
504
|
+
* via its enumerable `kind` discriminator. Type guard returns true for
|
|
505
|
+
* both live `PostgresEnumType` instances and raw JSON envelopes.
|
|
506
|
+
*/
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/ir/primary-key.d.ts
|
|
509
|
+
interface PrimaryKeyInput {
|
|
268
510
|
readonly columns: readonly string[];
|
|
269
511
|
readonly name?: string;
|
|
270
|
-
}
|
|
271
|
-
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* SQL Contract IR node for a table's primary-key constraint.
|
|
515
|
+
*/
|
|
516
|
+
declare class PrimaryKey extends SqlNode {
|
|
272
517
|
readonly columns: readonly string[];
|
|
273
518
|
readonly name?: string;
|
|
274
|
-
|
|
275
|
-
|
|
519
|
+
constructor(input: PrimaryKeyInput);
|
|
520
|
+
} //#endregion
|
|
521
|
+
//#region src/ir/sql-index.d.ts
|
|
522
|
+
interface IndexInput {
|
|
276
523
|
readonly columns: readonly string[];
|
|
277
524
|
readonly name?: string;
|
|
278
525
|
readonly type?: string;
|
|
279
526
|
readonly options?: Record<string, unknown>;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* SQL Contract IR node for a table-level secondary index.
|
|
530
|
+
*
|
|
531
|
+
* Note that this class shadows the global TypeScript `Index` lib type
|
|
532
|
+
* at the family-shared name; consumer files that need both should
|
|
533
|
+
* alias one (e.g.
|
|
534
|
+
* `import { Index as SqlIndexNode } from '@prisma-next/sql-contract/types'`).
|
|
535
|
+
*/
|
|
536
|
+
declare class Index extends SqlNode {
|
|
283
537
|
readonly columns: readonly string[];
|
|
284
|
-
|
|
285
|
-
type
|
|
286
|
-
|
|
538
|
+
readonly name?: string;
|
|
539
|
+
readonly type?: string;
|
|
540
|
+
readonly options?: Record<string, unknown>;
|
|
541
|
+
constructor(input: IndexInput);
|
|
542
|
+
} //#endregion
|
|
543
|
+
//#region src/ir/storage-column.d.ts
|
|
544
|
+
/**
|
|
545
|
+
* Hydration / construction input shape for {@link StorageColumn}. Mirrors
|
|
546
|
+
* the on-disk storage JSON envelope exactly so the family-base
|
|
547
|
+
* serializer's hydration walker can hand an arktype-validated literal
|
|
548
|
+
* straight to `new`.
|
|
549
|
+
*
|
|
550
|
+
* `typeParams` and `typeRef` remain mutually exclusive (one or the
|
|
551
|
+
* other, not both); the constructor preserves whichever caller-side
|
|
552
|
+
* choice the input encodes.
|
|
553
|
+
*/
|
|
554
|
+
interface StorageColumnInput {
|
|
555
|
+
readonly nativeType: string;
|
|
556
|
+
readonly codecId: string;
|
|
557
|
+
readonly nullable: boolean;
|
|
558
|
+
readonly typeParams?: Record<string, unknown>;
|
|
559
|
+
readonly typeRef?: string;
|
|
560
|
+
readonly default?: ColumnDefault;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* SQL Contract IR node for a single column entry in `StorageTable.columns`.
|
|
564
|
+
*
|
|
565
|
+
* Single concrete family-shared class — every SQL target reads the
|
|
566
|
+
* same column shape today, so there is no per-target subclass. The
|
|
567
|
+
* class type accepts any caller that constructs via
|
|
568
|
+
* `new StorageColumn(input)`; literal construction sites must pass
|
|
569
|
+
* through the constructor or the family-base hydration walker.
|
|
570
|
+
*
|
|
571
|
+
* The column's `name` is not on the class — columns are keyed by name
|
|
572
|
+
* in the parent `StorageTable.columns: Record<string, StorageColumn>`
|
|
573
|
+
* map, so a `name` field would be redundant with the key.
|
|
574
|
+
*/
|
|
575
|
+
declare class StorageColumn extends SqlNode {
|
|
576
|
+
readonly nativeType: string;
|
|
577
|
+
readonly codecId: string;
|
|
578
|
+
readonly nullable: boolean;
|
|
579
|
+
readonly typeParams?: Record<string, unknown>;
|
|
580
|
+
readonly typeRef?: string;
|
|
581
|
+
readonly default?: ColumnDefault;
|
|
582
|
+
constructor(input: StorageColumnInput);
|
|
583
|
+
} //#endregion
|
|
584
|
+
//#region src/ir/unique-constraint.d.ts
|
|
585
|
+
interface UniqueConstraintInput {
|
|
287
586
|
readonly columns: readonly string[];
|
|
288
|
-
readonly references: ForeignKeyReferences;
|
|
289
587
|
readonly name?: string;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
readonly
|
|
297
|
-
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* SQL Contract IR node for a table-level unique constraint.
|
|
591
|
+
*/
|
|
592
|
+
declare class UniqueConstraint extends SqlNode {
|
|
593
|
+
readonly columns: readonly string[];
|
|
594
|
+
readonly name?: string;
|
|
595
|
+
constructor(input: UniqueConstraintInput);
|
|
596
|
+
} //#endregion
|
|
597
|
+
//#region src/ir/storage-table.d.ts
|
|
598
|
+
interface StorageTableInput {
|
|
599
|
+
readonly columns: Record<string, StorageColumn | StorageColumnInput>;
|
|
600
|
+
readonly primaryKey?: PrimaryKey | PrimaryKeyInput;
|
|
601
|
+
readonly uniques: ReadonlyArray<UniqueConstraint | UniqueConstraintInput>;
|
|
602
|
+
readonly indexes: ReadonlyArray<Index | IndexInput>;
|
|
603
|
+
readonly foreignKeys: ReadonlyArray<ForeignKey | ForeignKeyInput>;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* SQL Contract IR node for a single table entry in `SqlStorage.tables`.
|
|
607
|
+
*
|
|
608
|
+
* The constructor normalises nested IR-class fields (columns, primary
|
|
609
|
+
* key, uniques, indexes, foreign keys) into the appropriate class
|
|
610
|
+
* instances so downstream walks see a uniform AST regardless of whether
|
|
611
|
+
* the input was a JSON literal or an already-constructed class.
|
|
612
|
+
*
|
|
613
|
+
* The table's `name` is not on the class — tables are keyed by name in
|
|
614
|
+
* the parent `SqlStorage.tables: Record<string, StorageTable>` map.
|
|
615
|
+
* A future namespace-aware milestone will add a `namespaceId` field
|
|
616
|
+
* when namespace-keyed storage lands; today's single-namespace shape
|
|
617
|
+
* needs neither field.
|
|
618
|
+
*/
|
|
619
|
+
declare class StorageTable extends SqlNode {
|
|
620
|
+
readonly columns: Readonly<Record<string, StorageColumn>>;
|
|
298
621
|
readonly uniques: ReadonlyArray<UniqueConstraint>;
|
|
299
622
|
readonly indexes: ReadonlyArray<Index>;
|
|
300
623
|
readonly foreignKeys: ReadonlyArray<ForeignKey>;
|
|
301
|
-
|
|
624
|
+
readonly primaryKey?: PrimaryKey;
|
|
625
|
+
constructor(input: StorageTableInput);
|
|
626
|
+
} //#endregion
|
|
627
|
+
//#region src/ir/storage-type-instance.d.ts
|
|
302
628
|
/**
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
629
|
+
* Sentinel kind for the legacy codec-triple shape persisted under
|
|
630
|
+
* `SqlStorage.types`. Plain JSON-clean object literals carry this
|
|
631
|
+
* discriminator so the polymorphic slot dispatch can route them down
|
|
632
|
+
* the codec path while target-specific IR class instances (e.g. the
|
|
633
|
+
* Postgres enum class) keep their own narrower `kind` literal.
|
|
634
|
+
*/
|
|
635
|
+
declare const CODEC_INSTANCE_KIND: "codec-instance";
|
|
636
|
+
/**
|
|
637
|
+
* Structural sub-interface of {@link StorageType} for codec-typed entries
|
|
638
|
+
* in `SqlStorage.types`. These are plain object literals — there is no
|
|
639
|
+
* runtime IR class, the JSON envelope round-trips through the slot
|
|
640
|
+
* unchanged. The `kind: 'codec-instance'` discriminator is the dispatch
|
|
641
|
+
* key that distinguishes codec-typed entries from class-instance entries
|
|
642
|
+
* (e.g. `PostgresEnumType`) sharing the polymorphic slot.
|
|
311
643
|
*/
|
|
312
|
-
|
|
644
|
+
interface StorageTypeInstance extends StorageType {
|
|
645
|
+
readonly kind: typeof CODEC_INSTANCE_KIND;
|
|
313
646
|
readonly codecId: string;
|
|
314
647
|
readonly nativeType: string;
|
|
315
648
|
readonly typeParams: Record<string, unknown>;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
readonly
|
|
324
|
-
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Construction-time input for a codec-triple entry. Symmetric with the
|
|
652
|
+
* structural runtime shape minus the `kind` discriminator — callers may
|
|
653
|
+
* omit `kind`; the helper {@link toStorageTypeInstance} stamps it on.
|
|
654
|
+
*/
|
|
655
|
+
interface StorageTypeInstanceInput {
|
|
656
|
+
readonly codecId: string;
|
|
657
|
+
readonly nativeType: string;
|
|
658
|
+
readonly typeParams: Record<string, unknown>;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Stamp the codec-instance `kind` discriminator on a caller-supplied
|
|
662
|
+
* codec triple. Idempotent: input that already carries the discriminator
|
|
663
|
+
* passes through unchanged.
|
|
664
|
+
*/
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/ir/sql-storage.d.ts
|
|
667
|
+
/**
|
|
668
|
+
* Polymorphic value type for `SqlStorage.types` entries (Decision 18,
|
|
669
|
+
* Option B). The slot's framework alphabet is `StorageType` — codec
|
|
670
|
+
* triples (`StorageTypeInstance` with `kind: 'codec-instance'`) and
|
|
671
|
+
* target-specific IR class instances structurally satisfying
|
|
672
|
+
* `PostgresEnumStorageEntry` (with `kind: 'postgres-enum'`) are the
|
|
673
|
+
* two variants the SQL family ships today. The construction side also
|
|
674
|
+
* accepts {@link StorageTypeInstanceInput} so callers can pass raw
|
|
675
|
+
* codec triples; the constructor stamps the discriminator.
|
|
676
|
+
*/
|
|
677
|
+
type SqlStorageTypeEntry = StorageTypeInstance | PostgresEnumStorageEntry | StorageTypeInstanceInput;
|
|
678
|
+
interface SqlStorageInput<THash extends string = string> {
|
|
679
|
+
readonly storageHash: StorageHashBase<THash>;
|
|
680
|
+
readonly tables: Record<string, StorageTable | StorageTableInput>;
|
|
681
|
+
readonly types?: Record<string, SqlStorageTypeEntry>;
|
|
682
|
+
readonly namespaces?: Readonly<Record<string, Namespace>>;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* SQL Contract IR root node for the `storage` field.
|
|
686
|
+
*
|
|
687
|
+
* Single concrete family-shared class — both Postgres and SQLite
|
|
688
|
+
* consume this same class today. Per-target storage subclasses are
|
|
689
|
+
* introduced when each target's namespace shape earns its
|
|
690
|
+
* target-specific concretion (target-specific derived fields,
|
|
691
|
+
* target-specific storage extensions).
|
|
692
|
+
*
|
|
693
|
+
* Honours the framework `Storage` interface: every SQL IR carries a
|
|
694
|
+
* `namespaces` map keyed by namespace id. The default singleton
|
|
695
|
+
* (`{ [UNSPECIFIED_NAMESPACE_ID]: SqlUnspecifiedNamespace.instance }`)
|
|
696
|
+
* binds every contract authored before per-target namespace concretions
|
|
697
|
+
* land; per-target namespace classes (`PostgresSchema.unspecified`,
|
|
698
|
+
* `SqliteUnspecifiedDatabase.instance`) earn their slots when each
|
|
699
|
+
* target's namespace shape lands.
|
|
700
|
+
*
|
|
701
|
+
* The constructor normalises nested IR-class fields (`tables`, optional
|
|
702
|
+
* `types`) into class instances so downstream walks see a uniform AST.
|
|
703
|
+
* `types` is polymorphic per Decision 18 Option B: codec-triple inputs
|
|
704
|
+
* are stamped with `kind: 'codec-instance'`; class-instance kinds
|
|
705
|
+
* (e.g. Postgres-enum entries satisfying `PostgresEnumStorageEntry`)
|
|
706
|
+
* pass through; hydration of raw JSON class-instance entries (carrying
|
|
707
|
+
* their narrower `kind` literal) is the per-target serializer's
|
|
708
|
+
* responsibility (so the family base does not import target-specific
|
|
709
|
+
* subclasses).
|
|
710
|
+
*/
|
|
711
|
+
declare class SqlStorage<THash extends string = string> extends SqlNode implements Storage {
|
|
712
|
+
readonly storageHash: StorageHashBase<THash>;
|
|
713
|
+
readonly tables: Readonly<Record<string, StorageTable>>;
|
|
714
|
+
readonly namespaces: Readonly<Record<string, Namespace>>;
|
|
715
|
+
readonly types?: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>;
|
|
716
|
+
constructor(input: SqlStorageInput<THash>);
|
|
717
|
+
} //#endregion
|
|
718
|
+
//#region src/ir/sql-unspecified-namespace.d.ts
|
|
719
|
+
/**
|
|
720
|
+
* Family-layer placeholder for the SQL unspecified-namespace singleton.
|
|
721
|
+
*
|
|
722
|
+
* SQL contracts honour the framework `Storage.namespaces` invariant from
|
|
723
|
+
* the moment they appear in the IR. Today `SqlStorage` is family-shared
|
|
724
|
+
* (Postgres + SQLite consume the same class); a per-target namespace
|
|
725
|
+
* concretion (`PostgresSchema.unspecified`, `SqliteUnspecifiedDatabase.instance`)
|
|
726
|
+
* earns its existence when each target's namespace shape lands. Until
|
|
727
|
+
* then the family ships a single placeholder singleton so the JSON
|
|
728
|
+
* envelope and runtime walk are honest at every layer.
|
|
729
|
+
*
|
|
730
|
+
* The `kind` discriminator is installed as a non-enumerable own property
|
|
731
|
+
* so the JSON envelope reads `{ "id": "__unspecified__" }` — symmetric
|
|
732
|
+
* with the family-level non-enumerable `kind` on `SqlNode` and bounded
|
|
733
|
+
* to the minimum data the framework `Namespace` interface promises.
|
|
734
|
+
*
|
|
735
|
+
* **Freeze-trap warning.** The leaf constructor calls
|
|
736
|
+
* `freezeNode(this)` after installing `kind`. The leaf-class shape
|
|
737
|
+
* works today only because `NamespaceBase` does NOT freeze in its
|
|
738
|
+
* constructor — the `Object.defineProperty(this, 'kind', …)` call after
|
|
739
|
+
* `super()` succeeds because the instance is still mutable at that
|
|
740
|
+
* point. Subclasses that add instance fields will still hit the freeze
|
|
741
|
+
* trap once leaf-class `freezeNode(this)` runs; and if a future
|
|
742
|
+
* framework change lifts the freeze to `NamespaceBase`, even the
|
|
743
|
+
* `defineProperty` here would silently fail. To add subclass instance
|
|
744
|
+
* fields safely, lift `freezeNode` to a leaf-class `seal()` hook each
|
|
745
|
+
* leaf calls explicitly at the end of its own constructor.
|
|
746
|
+
*/
|
|
325
747
|
type CodecTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
|
|
326
748
|
readonly codecTypes: infer C;
|
|
327
749
|
} ? C extends Record<string, {
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["ScalarFieldType","Record","kind","codecId","typeParams","ValueObjectFieldType","name","UnionFieldType","ReadonlyArray","members","ContractFieldType","ContractField","nullable","type","many","dict","ContractRelationOn","localFields","targetFields","ContractReferenceRelation","to","cardinality","on","ContractEmbedRelation","ContractRelation","ContractDiscriminator","field","ContractVariantEntry","value","ContractValueObject","fields","ModelStorageBase","Readonly","ContractModelBase","TModelStorage","relations","storage","discriminator","variants","base","owner","ContractModel","HasModelsWithRelations","models","ReferenceRelationKeys","TContract","ModelName","K","EmbedRelationKeys","$","Brand","TKey","TValue","StorageHashBase","THash","ExecutionHashBase","executionHash","T","coreHash","ProfileHashBase","profileHash","StorageBase","storageHash","FieldType","items","properties","GeneratedValueSpec","id","params","JsonPrimitive","JsonValue","key","ColumnDefaultLiteralValue","ColumnDefaultLiteralInputValue","Date","isColumnDefaultLiteralInputValue","ColumnDefault","expression","isColumnDefault","ExecutionMutationDefaultValue","isExecutionMutationDefaultValue","ExecutionMutationDefault","ref","table","column","onCreate","onUpdate","ExecutionMutationDefaultPhases","Omit","ExecutionSection","mutations","defaults","Source","readOnly","projection","origin","capabilities","DocIndex","Expr","keys","unique","where","path","DocCollection","strategy","indexes","PlanMeta","target","targetFamily","lane","annotations","ContractMarkerRecord","contractJson","canonicalVersion","updatedAt","appTag","meta","invariants","ContractExecutionSection","Contract","TStorage","TModels","roots","valueObjects","extensionPacks","execution","A","B","C","D","E","F","G","H","I","J","L","M","N","O","P","R","S","U","V","W","_","a","b","c","d","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","ColumnDefault","StorageBase","CodecTrait","StorageColumn","Record","nativeType","codecId","nullable","typeParams","typeRef","default","PrimaryKey","columns","name","UniqueConstraint","Index","type","options","ForeignKeyReferences","table","ReferentialAction","ForeignKeyOptions","onDelete","onUpdate","ForeignKey","references","constraint","index","StorageTable","ReadonlyArray","primaryKey","uniques","indexes","foreignKeys","StorageTypeInstance","SqlStorage","THash","tables","types","SqlModelFieldStorage","column","SqlModelStorage","fields","DEFAULT_FK_CONSTRAINT","DEFAULT_FK_INDEX","applyFkDefaults","fk","overrideDefaults","TypeMaps","TCodecTypes","TQueryOperationTypes","TFieldOutputTypes","TFieldInputTypes","output","codecTypes","queryOperationTypes","fieldOutputTypes","fieldInputTypes","CodecTypesOf","T","C","QueryOperationSelfSpec","traits","QueryOperationReturn","returnType","QueryOperationTypeEntry","self","impl","args","SqlQueryOperationTypes","_CT","input","QueryOperationTypesBase","QueryOperationTypesOf","Q","TypeMapsPhantomKey","ContractWithTypeMaps","TContract","TTypeMaps","K","ExtractTypeMapsFromContract","NonNullable","FieldOutputTypesOf","F","FieldInputTypesOf","ExtractCodecTypes","ExtractQueryOperationTypes","ExtractFieldOutputTypes","ExtractFieldInputTypes","ResolveCodecTypes","A","D","E","M","N","O","P","S","_","a","b","c","d","f","g","h","i","j","k","l","m","n","o","p","r","s","t","u","v","w","x","y"],"sources":["../../../../1-framework/0-foundation/contract/dist/contract-types-Kl86EaEa.d.mts","../src/type-errors.ts","../src/column-reference.ts","../../../1-core/contract/dist/types-njsiV-Ck.d.mts","../src/table-reference.ts","../src/ref.ts","../src/type-atoms.ts","../src/selection.ts","../src/select-builder.ts","../src/root.ts"],"mappings":";;KACKA,eAAAA;EAAAA,SACME,IAAAA;EAAAA,SACAC,OAAAA;EAAAA,SACAC,UAAAA,GAAaH,MAAAA;AAAAA;AAAAA,KAEnBI,oBAAAA;EAAAA,SACMH,IAAAA;EAAAA,SACAI,IAAAA;AAAAA;AAAAA,KAENC,cAAAA;EAAAA,SACML,IAAAA;EAAAA,SACAO,OAAAA,EAASD,aAAAA,CAAcR,eAAAA,GAAkBK,oBAAAA;AAAAA;AAAAA,KAE/CK,iBAAAA,GAAoBV,eAAAA,GAAkBK,oBAAAA,GAAuBE,cAAAA;AAAAA,KAC7DI,aAAAA;EAAAA,SACMC,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EAAY,gBAAA,CAAiB,SAAA,EAAW,UAAA;EAEvD,MAAA,CACE,GAAA,UACC,qCAAA;EAQH,KAAA,CAAA,GAAS,OAAA,CAAQ,UAAA,yBAGb,QAAA,CAAS,UAAA;AAAA;;;;;;;;cC7CF,IAAA,mBAAuB,QAAA,CAAS,UAAA;EAAA;cAG/B,QAAA,EAAU,SAAA;ETRnBlO;;;;;ESiBH,IAAA,CACE,KAAA,EAAO,cAAA,UACN,qCAAA;ETfc;;;ESmBjB,IAAA,sBAAA,CACE,KAAA,iBAAsB,KAAA,GAClB,0BAAA,0FACA,cAAA,CAAe,KAAA,EAAO,SAAA,8BACzB,KAAA,kBACC,aAAA,CAAc,SAAA,EAAW,IAAA,CAAK,SAAA,uBAAgC,KAAA,KAC9D,qCAAA;EACJ,IAAA,CACE,KAAA,EAAO,0BAAA,0FACN,qCAAA;AAAA;;;;iBAaW,UAAA,CACd,QAAA,UACC,qCAAA;;;;iBAIa,UAAA,mBAA6B,QAAA,CAAS,UAAA,EAAA,CACpD,QAAA,EAAU,SAAA,GACT,IAAA,CAAK,SAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["ScalarFieldType","Record","kind","codecId","typeParams","ValueObjectFieldType","name","UnionFieldType","ReadonlyArray","members","ContractFieldType","ContractField","nullable","type","many","dict","ContractRelationOn","localFields","targetFields","ContractReferenceRelation","to","cardinality","on","ContractEmbedRelation","ContractRelation","ContractDiscriminator","field","ContractVariantEntry","value","ContractValueObject","fields","ModelStorageBase","Readonly","ContractModelBase","TModelStorage","relations","storage","discriminator","variants","base","owner","ContractModel","HasModelsWithRelations","models","ReferenceRelationKeys","TContract","ModelName","K","EmbedRelationKeys","$","Brand","TKey","TValue","StorageHashBase","THash","ExecutionHashBase","executionHash","T","coreHash","ProfileHashBase","profileHash","StorageBase","storageHash","FieldType","items","properties","GeneratedValueSpec","id","params","JsonPrimitive","JsonValue","key","ColumnDefaultLiteralValue","ColumnDefaultLiteralInputValue","Date","isColumnDefaultLiteralInputValue","ColumnDefault","expression","isColumnDefault","ExecutionMutationDefaultValue","isExecutionMutationDefaultValue","ExecutionMutationDefault","ref","table","column","onCreate","onUpdate","ExecutionMutationDefaultPhases","Omit","ExecutionSection","mutations","defaults","Source","readOnly","projection","origin","capabilities","DocIndex","Expr","keys","unique","where","path","DocCollection","strategy","indexes","PlanMeta","target","targetFamily","lane","annotations","ContractMarkerRecord","contractJson","canonicalVersion","updatedAt","appTag","meta","invariants","ContractExecutionSection","Contract","TStorage","TModels","roots","valueObjects","extensionPacks","execution","A","B","C","D","E","F","G","H","I","J","L","M","N","O","P","R","S","U","V","W","_","a","b","c","d","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","IRNode","kind","IRNodeBase","freezeNode","T","node","UNSPECIFIED_NAMESPACE_ID","Namespace","id","NamespaceBase","Storage","Record","Readonly","namespaces","StorageType","IRNodeBase","Namespace","NamespaceBase","Storage","StorageType","ColumnDefault","StorageHashBase","CodecTrait","SqlNode","kind","constructor","ForeignKeyReferencesInput","table","columns","ForeignKeyReferences","input","ReferentialAction","ForeignKeyInput","references","name","onDelete","onUpdate","constraint","index","ForeignKey","POSTGRES_ENUM_KIND","PostgresEnumStorageEntry","nativeType","values","codecId","isPostgresEnumStorageEntry","value","PrimaryKeyInput","PrimaryKey","IndexInput","Record","type","options","Index","StorageColumnInput","nullable","typeParams","typeRef","default","StorageColumn","UniqueConstraintInput","UniqueConstraint","StorageTableInput","ReadonlyArray","primaryKey","uniques","indexes","foreignKeys","StorageTable","Readonly","CODEC_INSTANCE_KIND","StorageTypeInstance","StorageTypeInstanceInput","toStorageTypeInstance","isStorageTypeInstance","SqlStorageTypeEntry","SqlStorageInput","THash","storageHash","tables","types","namespaces","SqlStorage","SqlUnspecifiedNamespace","instance","id","ForeignKeyOptions","SqlModelFieldStorage","column","SqlModelStorage","fields","DEFAULT_FK_CONSTRAINT","DEFAULT_FK_INDEX","applyFkDefaults","fk","overrideDefaults","TypeMaps","TCodecTypes","TQueryOperationTypes","TFieldOutputTypes","TFieldInputTypes","output","codecTypes","queryOperationTypes","fieldOutputTypes","fieldInputTypes","CodecTypesOf","T","C","QueryOperationSelfSpec","traits","QueryOperationReturn","returnType","QueryOperationTypeEntry","self","impl","args","SqlQueryOperationTypes","_CT","QueryOperationTypesBase","QueryOperationTypesOf","Q","TypeMapsPhantomKey","ContractWithTypeMaps","TContract","TTypeMaps","K","ExtractTypeMapsFromContract","NonNullable","FieldOutputTypesOf","F","FieldInputTypesOf","ExtractCodecTypes","ExtractQueryOperationTypes","ExtractFieldOutputTypes","ExtractFieldInputTypes","ResolveCodecTypes","A","B","D","E","G","H","I","J","L","M","N","O","P","R","S","U","V","W","X","Y","Z","_","a","b","c","d","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],"sources":["../../../../1-framework/0-foundation/contract/dist/contract-types-Kl86EaEa.d.mts","../src/type-errors.ts","../src/column-reference.ts","../../../../1-framework/1-core/framework-components/dist/ir.d.mts","../../../1-core/contract/dist/types-B0lbr9cb.d.mts","../src/table-reference.ts","../src/ref.ts","../src/type-atoms.ts","../src/selection.ts","../src/select-builder.ts","../src/root.ts"],"mappings":";;KACKA,eAAAA;EAAAA,SACME,IAAAA;EAAAA,SACAC,OAAAA;EAAAA,SACAC,UAAAA,GAAaH,MAAAA;AAAAA;AAAAA,KAEnBI,oBAAAA;EAAAA,SACMH,IAAAA;EAAAA,SACAI,IAAAA;AAAAA;AAAAA,KAENC,cAAAA;EAAAA,SACML,IAAAA;EAAAA,SACAO,OAAAA,EAASD,aAAAA,CAAcR,eAAAA,GAAkBK,oBAAAA;AAAAA;AAAAA,KAE/CK,iBAAAA,GAAoBV,eAAAA,GAAkBK,oBAAAA,GAAuBE,cAAAA;AAAAA,KAC7DI,aAAAA;EAAAA,SACMC,QAAAA;EAAAA,SACAC,IAAAA,EAAMH,iBAAAA;EAAAA,SACNI,IAAAA;EAAAA,SACAC,IAAAA;AAAAA;AAAAA,K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jB,IAAA,sBAAA,CACE,KAAA,iBAAsB,KAAA,GAClB,0BAAA,0FACA,cAAA,CAAe,KAAA,EAAO,SAAA,8BACzB,KAAA,kBACC,aAAA,CAAc,SAAA,EAAW,IAAA,CAAK,SAAA,uBAAgC,KAAA,KAC9D,qCAAA;EACJ,IAAA,CACE,KAAA,EAAO,0BAAA,0FACN,qCAAA;AAAA;;;;iBAaW,UAAA,CACd,QAAA,UACC,qCAAA;;;;iBAIa,UAAA,mBAA6B,QAAA,CAAS,UAAA,EAAA,CACpD,QAAA,EAAU,SAAA,GACT,IAAA,CAAK,SAAA"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["#contract","#contract"],"sources":["../src/ref.ts","../src/select-builder.ts","../src/root.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type {\n Asterisk,\n ColumnReference,\n ColumnReferenceOutOfContractError,\n TableAsterisk,\n} from './column-reference';\nimport type { TableReference, TableReferenceOutOfContractError } from './table-reference';\n\n/**\n * A fluent API representing references to tables and columns in a SQL contract.\n *\n * @template TContract The contract that describes the database.\n */\nexport type Ref<TContract extends Contract<SqlStorage>> = {\n readonly [TableName in keyof TContract['storage']['tables'] & string]: TableReference<\n TableName,\n TContract['storage']['storageHash']\n > & {\n readonly [ColumnName in Exclude<\n keyof TContract['storage']['tables'][TableName]['columns'],\n keyof TableReference\n > &\n string]: ColumnReference<ColumnName, TableName, TContract['storage']['storageHash']>;\n } & {\n readonly ['*']: TableAsterisk<TableName, TContract['storage']['storageHash']>;\n } & Record<\n PropertyKey,\n ColumnReferenceOutOfContractError<`[error] reference to a non-existing column in the '${TableName}' table`>\n >;\n} & {\n readonly ['*']: Asterisk;\n} & Record<\n PropertyKey,\n TableReferenceOutOfContractError<`[error] reference to a non-existing table in the contract`>\n >;\n\n/**\n * Creates a reference object for the given SQL contract.\n *\n * @template TContract The contract that describes the database.\n */\nexport function createRef<TContract extends Contract<SqlStorage>>(\n _contract: TContract,\n): Ref<TContract> {\n return new Proxy({} as Ref<TContract>, {\n get(_target, tableName) {\n if (tableName === '*') {\n return Object.freeze({\n '~name': tableName,\n '~table': null,\n });\n }\n\n return new Proxy(\n {},\n {\n get(_target, columnName) {\n if (columnName === '~name') {\n return tableName;\n }\n\n return Object.freeze({\n '~name': columnName,\n '~table': tableName,\n });\n },\n },\n );\n },\n });\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { Asterisk, TableAsterisk } from './column-reference';\nimport type { Selection, TableToSelection } from './selection';\nimport type { ExactlyOneProperty, IsNever, MergeObjects, Simplify } from './type-atoms';\nimport type { PreviousFunctionReceivedBadInputError } from './type-errors';\n\n/**\n * A builder for SQL `select` queries.\n *\n * @template TContract The contract that describes the database.\n * @template TTables The tables involved in the current `select` query.\n * @template TSelection The current selection of the `select` query.\n */\nexport class SelectBuilder<\n TContract extends Contract<SqlStorage>,\n TTables extends Contract<SqlStorage>['storage']['tables'],\n TSelection extends Selection = never,\n> {\n // @ts-expect-error\n // biome-ignore lint/correctness/noUnusedPrivateClassMembers: will be used soon.\n readonly #contract: TContract;\n\n constructor(contract: TContract) {\n this.#contract = contract;\n }\n\n select(\n asterisk: Asterisk,\n ): ExactlyOneProperty<TTables> extends true\n ? SelectBuilder<\n TContract,\n TTables,\n MergeObjects<TSelection, TableToSelection<TContract, keyof TTables & string>>\n >\n : PreviousFunctionReceivedBadInputError<'[error] selecting all columns via `*` results in ambiguity when multiple tables are involved in the query'>;\n select<TTableName extends keyof TTables & string>(\n asterisk: TableAsterisk<TTableName, TContract['storage']['storageHash']>,\n ): SelectBuilder<\n TContract,\n TTables,\n MergeObjects<TSelection, TableToSelection<TContract, TTableName>>\n >;\n select(\n arg: never,\n ): PreviousFunctionReceivedBadInputError<'[error] invalid input in previous `select()` call'>;\n select(..._args: unknown[]): unknown {\n // TODO: do runtime stuff.\n return this;\n }\n\n // TODO: the return type here is not the real one we'll use eventually.\n // I'm using something to test the selection stuff.\n build(): IsNever<TSelection> extends true\n ? // TODO: either split to two builders or provide a type-level error here.\n never\n : Simplify<TSelection> {\n // TODO: do runtime stuff.\n return {} as never;\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { SelectBuilder } from './select-builder';\nimport type { TableReference, TableReferenceTooWideError } from './table-reference';\nimport type { PreviousFunctionReceivedBadInputError } from './type-errors';\n\n/**\n * The root of all builder.\n *\n * @template TContract The contract that describes the database.\n */\nexport class Root<TContract extends Contract<SqlStorage>> {\n readonly #contract: TContract;\n\n constructor(contract: TContract) {\n this.#contract = contract;\n }\n\n /**\n * SQL's `from` clause, where all `select` queries actually start from.\n *\n * @param table The table to select from.\n */\n from(\n table: TableReference<never>,\n ): PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;\n /**\n * @template TName The name of the table to select from.\n */\n from<TName extends string>(\n table: string extends TName\n ? TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'>\n : TableReference<TName, TContract['storage']['storageHash']>,\n ): TName extends string\n ? SelectBuilder<TContract, Pick<TContract['storage']['tables'], TName>>\n : PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;\n from(\n table: TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'>,\n ): PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;\n /**\n * @internal\n */\n from(_table: unknown): unknown {\n // TODO: use runtime table reference value to do something \"AST\"-related.\n return new SelectBuilder(this.#contract);\n }\n}\n\n/**\n * Creates a new `Root` instance.\n */\nexport function createRoot(\n contract: never,\n): PreviousFunctionReceivedBadInputError<'[error] root creation will likely fail at runtime given the passed contract is not valid or verified'>;\n/**\n * @template TContract The contract that describes the database.\n */\nexport function createRoot<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n): Root<TContract>;\n/**\n * @internal\n */\nexport function createRoot(contract: unknown): unknown {\n return new Root(contract as Contract<SqlStorage>);\n}\n"],"mappings":";;;;;;AA2CA,SAAgB,UACd,WACgB;CAChB,OAAO,IAAI,MAAM,EAAE,EAAoB,EACrC,IAAI,SAAS,WAAW;EACtB,IAAI,cAAc,KAChB,OAAO,OAAO,OAAO;GACnB,SAAS;GACT,UAAU;GACX,CAAC;EAGJ,OAAO,IAAI,MACT,EAAE,EACF,EACE,IAAI,SAAS,YAAY;GACvB,IAAI,eAAe,SACjB,OAAO;GAGT,OAAO,OAAO,OAAO;IACnB,SAAS;IACT,UAAU;IACX,CAAC;KAEL,CACF;IAEJ,CAAC;;;;;;;;;;;ACzDJ,IAAa,gBAAb,MAIE;CAGA;CAEA,YAAY,UAAqB;EAC/B,KAAKA,YAAY;;CAsBnB,OAAO,GAAG,OAA2B;EAEnC,OAAO;;CAKT,QAGyB;EAEvB,OAAO,EAAE;;;;;;;;;;AC/Cb,IAAa,OAAb,MAA0D;CACxD;CAEA,YAAY,UAAqB;EAC/B,KAAKC,YAAY;;;;;CA2BnB,KAAK,QAA0B;EAE7B,OAAO,IAAI,cAAc,KAAKA,UAAU;;;;;;AAmB5C,SAAgB,WAAW,UAA4B;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#contract","#contract"],"sources":["../src/ref.ts","../src/select-builder.ts","../src/root.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type {\n Asterisk,\n ColumnReference,\n ColumnReferenceOutOfContractError,\n TableAsterisk,\n} from './column-reference';\nimport type { TableReference, TableReferenceOutOfContractError } from './table-reference';\n\n/**\n * A fluent API representing references to tables and columns in a SQL contract.\n *\n * @template TContract The contract that describes the database.\n */\nexport type Ref<TContract extends Contract<SqlStorage>> = {\n readonly [TableName in keyof TContract['storage']['tables'] & string]: TableReference<\n TableName,\n TContract['storage']['storageHash']\n > & {\n readonly [ColumnName in Exclude<\n keyof TContract['storage']['tables'][TableName]['columns'],\n keyof TableReference\n > &\n string]: ColumnReference<ColumnName, TableName, TContract['storage']['storageHash']>;\n } & {\n readonly ['*']: TableAsterisk<TableName, TContract['storage']['storageHash']>;\n } & Record<\n PropertyKey,\n ColumnReferenceOutOfContractError<`[error] reference to a non-existing column in the '${TableName}' table`>\n >;\n} & {\n readonly ['*']: Asterisk;\n} & Record<\n PropertyKey,\n TableReferenceOutOfContractError<`[error] reference to a non-existing table in the contract`>\n >;\n\n/**\n * Creates a reference object for the given SQL contract.\n *\n * @template TContract The contract that describes the database.\n */\nexport function createRef<TContract extends Contract<SqlStorage>>(\n _contract: TContract,\n): Ref<TContract> {\n return new Proxy({} as Ref<TContract>, {\n get(_target, tableName) {\n if (tableName === '*') {\n return Object.freeze({\n '~name': tableName,\n '~table': null,\n });\n }\n\n return new Proxy(\n {},\n {\n get(_target, columnName) {\n if (columnName === '~name') {\n return tableName;\n }\n\n return Object.freeze({\n '~name': columnName,\n '~table': tableName,\n });\n },\n },\n );\n },\n });\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { Asterisk, TableAsterisk } from './column-reference';\nimport type { Selection, TableToSelection } from './selection';\nimport type { ExactlyOneProperty, IsNever, MergeObjects, Simplify } from './type-atoms';\nimport type { PreviousFunctionReceivedBadInputError } from './type-errors';\n\n/**\n * A builder for SQL `select` queries.\n *\n * @template TContract The contract that describes the database.\n * @template TTables The tables involved in the current `select` query.\n * @template TSelection The current selection of the `select` query.\n */\nexport class SelectBuilder<\n TContract extends Contract<SqlStorage>,\n TTables extends Contract<SqlStorage>['storage']['tables'],\n TSelection extends Selection = never,\n> {\n // @ts-expect-error\n // biome-ignore lint/correctness/noUnusedPrivateClassMembers: will be used soon.\n readonly #contract: TContract;\n\n constructor(contract: TContract) {\n this.#contract = contract;\n }\n\n select(\n asterisk: Asterisk,\n ): ExactlyOneProperty<TTables> extends true\n ? SelectBuilder<\n TContract,\n TTables,\n MergeObjects<TSelection, TableToSelection<TContract, keyof TTables & string>>\n >\n : PreviousFunctionReceivedBadInputError<'[error] selecting all columns via `*` results in ambiguity when multiple tables are involved in the query'>;\n select<TTableName extends keyof TTables & string>(\n asterisk: TableAsterisk<TTableName, TContract['storage']['storageHash']>,\n ): SelectBuilder<\n TContract,\n TTables,\n MergeObjects<TSelection, TableToSelection<TContract, TTableName>>\n >;\n select(\n arg: never,\n ): PreviousFunctionReceivedBadInputError<'[error] invalid input in previous `select()` call'>;\n select(..._args: unknown[]): unknown {\n // TODO: do runtime stuff.\n return this;\n }\n\n // TODO: the return type here is not the real one we'll use eventually.\n // I'm using something to test the selection stuff.\n build(): IsNever<TSelection> extends true\n ? // TODO: either split to two builders or provide a type-level error here.\n never\n : Simplify<TSelection> {\n // TODO: do runtime stuff.\n return {} as never;\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { SelectBuilder } from './select-builder';\nimport type { TableReference, TableReferenceTooWideError } from './table-reference';\nimport type { PreviousFunctionReceivedBadInputError } from './type-errors';\n\n/**\n * The root of all builder.\n *\n * @template TContract The contract that describes the database.\n */\nexport class Root<TContract extends Contract<SqlStorage>> {\n readonly #contract: TContract;\n\n constructor(contract: TContract) {\n this.#contract = contract;\n }\n\n /**\n * SQL's `from` clause, where all `select` queries actually start from.\n *\n * @param table The table to select from.\n */\n from(\n table: TableReference<never>,\n ): PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;\n /**\n * @template TName The name of the table to select from.\n */\n from<TName extends string>(\n table: string extends TName\n ? TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'>\n : TableReference<TName, TContract['storage']['storageHash']>,\n ): TName extends string\n ? SelectBuilder<TContract, Pick<TContract['storage']['tables'], TName>>\n : PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;\n from(\n table: TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'>,\n ): PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;\n /**\n * @internal\n */\n from(_table: unknown): unknown {\n // TODO: use runtime table reference value to do something \"AST\"-related.\n return new SelectBuilder(this.#contract);\n }\n}\n\n/**\n * Creates a new `Root` instance.\n */\nexport function createRoot(\n contract: never,\n): PreviousFunctionReceivedBadInputError<'[error] root creation will likely fail at runtime given the passed contract is not valid or verified'>;\n/**\n * @template TContract The contract that describes the database.\n */\nexport function createRoot<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n): Root<TContract>;\n/**\n * @internal\n */\nexport function createRoot(contract: unknown): unknown {\n // Blind cast: the public overloads above (`createRoot(TContract)`)\n // statically constrain `contract` to `Contract<SqlStorage>` —\n // this internal `unknown` overload exists only to give the\n // implementation a single body. Any caller that reaches the\n // `unknown` form has already been narrowed by the matching\n // overload at compile time.\n return new Root(contract as unknown as Contract<SqlStorage>);\n}\n"],"mappings":";;;;;;AA2CA,SAAgB,UACd,WACgB;CAChB,OAAO,IAAI,MAAM,EAAE,EAAoB,EACrC,IAAI,SAAS,WAAW;EACtB,IAAI,cAAc,KAChB,OAAO,OAAO,OAAO;GACnB,SAAS;GACT,UAAU;GACX,CAAC;EAGJ,OAAO,IAAI,MACT,EAAE,EACF,EACE,IAAI,SAAS,YAAY;GACvB,IAAI,eAAe,SACjB,OAAO;GAGT,OAAO,OAAO,OAAO;IACnB,SAAS;IACT,UAAU;IACX,CAAC;KAEL,CACF;IAEJ,CAAC;;;;;;;;;;;ACzDJ,IAAa,gBAAb,MAIE;CAGA;CAEA,YAAY,UAAqB;EAC/B,KAAKA,YAAY;;CAsBnB,OAAO,GAAG,OAA2B;EAEnC,OAAO;;CAKT,QAGyB;EAEvB,OAAO,EAAE;;;;;;;;;;AC/Cb,IAAa,OAAb,MAA0D;CACxD;CAEA,YAAY,UAAqB;EAC/B,KAAKC,YAAY;;;;;CA2BnB,KAAK,QAA0B;EAE7B,OAAO,IAAI,cAAc,KAAKA,UAAU;;;;;;AAmB5C,SAAgB,WAAW,UAA4B;CAOrD,OAAO,IAAI,KAAK,SAA4C"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-lane-query-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-dev.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "SQL query builder lane for Prisma Next",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@prisma-next/contract": "0.
|
|
10
|
-
"@prisma-next/sql-contract": "0.
|
|
11
|
-
"@prisma-next/tsconfig": "0.
|
|
12
|
-
"@prisma-next/tsdown": "0.
|
|
9
|
+
"@prisma-next/contract": "0.9.0-dev.2",
|
|
10
|
+
"@prisma-next/sql-contract": "0.9.0-dev.2",
|
|
11
|
+
"@prisma-next/tsconfig": "0.9.0-dev.2",
|
|
12
|
+
"@prisma-next/tsdown": "0.9.0-dev.2",
|
|
13
13
|
"tsdown": "0.22.0",
|
|
14
14
|
"typescript": "5.9.3",
|
|
15
15
|
"vitest": "4.1.5"
|
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
".": "./dist/index.mjs",
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
|
-
"main": "./dist/index.mjs",
|
|
29
|
-
"module": "./dist/index.mjs",
|
|
30
28
|
"types": "./dist/index.d.mts",
|
|
31
29
|
"repository": {
|
|
32
30
|
"type": "git",
|
package/src/root.ts
CHANGED
|
@@ -62,5 +62,11 @@ export function createRoot<TContract extends Contract<SqlStorage>>(
|
|
|
62
62
|
* @internal
|
|
63
63
|
*/
|
|
64
64
|
export function createRoot(contract: unknown): unknown {
|
|
65
|
-
|
|
65
|
+
// Blind cast: the public overloads above (`createRoot(TContract)`)
|
|
66
|
+
// statically constrain `contract` to `Contract<SqlStorage>` —
|
|
67
|
+
// this internal `unknown` overload exists only to give the
|
|
68
|
+
// implementation a single body. Any caller that reaches the
|
|
69
|
+
// `unknown` form has already been narrowed by the matching
|
|
70
|
+
// overload at compile time.
|
|
71
|
+
return new Root(contract as unknown as Contract<SqlStorage>);
|
|
66
72
|
}
|