@prisma-next/sql-lane-query-builder 0.9.0 → 0.10.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/dist/index.d.mts CHANGED
@@ -298,11 +298,17 @@ declare abstract class IRNodeBase implements IRNode {
298
298
  * a target-native binding:
299
299
  *
300
300
  * - Postgres: a schema (`CREATE SCHEMA …`); rendered as `"<schema>"`.
301
- * - SQLite: the singleton `UNSPECIFIED_NAMESPACE_ID`; emitted SQL has no qualifier.
301
+ * - SQLite: the singleton `UNBOUND_NAMESPACE_ID`; emitted SQL has no qualifier.
302
302
  * - Mongo: the connection's `db` field; addressed as a database name.
303
303
  *
304
- * See `UNSPECIFIED_NAMESPACE_ID` above for the sentinel id and the
304
+ * See `UNBOUND_NAMESPACE_ID` above for the sentinel id and the
305
305
  * singleton-subclass pattern that materialises it.
306
+ *
307
+ * The framework promises only the coordinate (`id`) — the named storage
308
+ * entities a namespace contains are family-typed (SQL contributes
309
+ * `tables`, Mongo contributes `collections`, future families pick their
310
+ * own native idiom). Generic consumers walking "all named entries" go
311
+ * through a family-typed namespace, not the framework `Namespace`.
306
312
  */
307
313
  interface Namespace extends IRNode {
308
314
  readonly id: string;
@@ -341,7 +347,7 @@ interface Namespace extends IRNode {
341
347
  * envelope-shape assertion for each target, so the strip-vs-pass-through
342
348
  * choice is locked at test time rather than implied by the override
343
349
  * presence/absence. Earned by PR2's per-target namespace lift, when
344
- * `PostgresSchema` / `SqliteUnspecifiedDatabase` start carrying
350
+ * `PostgresSchema` / `SqliteUnboundDatabase` start carrying
345
351
  * target-specific fields.
346
352
  */
347
353
  interface Storage extends IRNode {
@@ -370,7 +376,7 @@ interface StorageType extends IRNode {
370
376
  readonly kind: string;
371
377
  } //#endregion
372
378
  //#endregion
373
- //#region ../../1-core/contract/dist/types-B0lbr9cb.d.mts
379
+ //#region ../../1-core/contract/dist/types-FVBrwvCz.d.mts
374
380
  //#region src/ir/sql-node.d.ts
375
381
  /**
376
382
  * SQL family IR node base. Carries the family-level `kind` discriminator
@@ -408,28 +414,30 @@ declare abstract class SqlNode extends IRNodeBase {
408
414
  readonly kind?: string;
409
415
  constructor();
410
416
  } //#endregion
411
- //#region src/ir/foreign-key-references.d.ts
412
- interface ForeignKeyReferencesInput {
413
- readonly table: string;
417
+ //#region src/ir/foreign-key-reference.d.ts
418
+ interface ForeignKeyReferenceInput {
419
+ readonly namespaceId: string;
420
+ readonly tableName: string;
414
421
  readonly columns: readonly string[];
415
422
  }
416
423
  /**
417
- * SQL Contract IR node for the referenced side of a foreign key.
424
+ * SQL Contract IR node for one side (source or target) of a foreign-key
425
+ * declaration. Carries the full coordinate: namespace, table, and columns.
418
426
  *
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.
427
+ * Use `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`
428
+ * as the sentinel `namespaceId` for single-namespace (unbound) references.
422
429
  */
423
- declare class ForeignKeyReferences extends SqlNode {
424
- readonly table: string;
430
+ declare class ForeignKeyReference extends SqlNode {
431
+ readonly namespaceId: string;
432
+ readonly tableName: string;
425
433
  readonly columns: readonly string[];
426
- constructor(input: ForeignKeyReferencesInput);
434
+ constructor(input: ForeignKeyReferenceInput);
427
435
  } //#endregion
428
436
  //#region src/ir/foreign-key.d.ts
429
437
  type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
430
438
  interface ForeignKeyInput {
431
- readonly columns: readonly string[];
432
- readonly references: ForeignKeyReferences | ForeignKeyReferencesInput;
439
+ readonly source: ForeignKeyReference | ForeignKeyReferenceInput;
440
+ readonly target: ForeignKeyReference | ForeignKeyReferenceInput;
433
441
  readonly name?: string;
434
442
  readonly onDelete?: ReferentialAction;
435
443
  readonly onUpdate?: ReferentialAction;
@@ -441,14 +449,18 @@ interface ForeignKeyInput {
441
449
  /**
442
450
  * SQL Contract IR node for a table-level foreign-key declaration.
443
451
  *
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.
452
+ * Each FK carries explicit `source` and `target` {@link ForeignKeyReference}
453
+ * coordinates (namespace, table, columns). For single-namespace contracts the
454
+ * sentinel `UNBOUND_NAMESPACE_ID` appears on both sides.
455
+ *
456
+ * The nested references are normalised to {@link ForeignKeyReference}
457
+ * instances inside the constructor so downstream walks see a uniform AST
458
+ * regardless of whether the input was a JSON literal or an already-constructed
459
+ * class instance.
448
460
  */
449
461
  declare class ForeignKey extends SqlNode {
450
- readonly columns: readonly string[];
451
- readonly references: ForeignKeyReferences;
462
+ readonly source: ForeignKeyReference;
463
+ readonly target: ForeignKeyReference;
452
464
  readonly constraint: boolean;
453
465
  readonly index: boolean;
454
466
  readonly name?: string;
@@ -603,7 +615,8 @@ interface StorageTableInput {
603
615
  readonly foreignKeys: ReadonlyArray<ForeignKey | ForeignKeyInput>;
604
616
  }
605
617
  /**
606
- * SQL Contract IR node for a single table entry in `SqlStorage.tables`.
618
+ * SQL Contract IR node for a single table entry in a namespace's
619
+ * `tables` map.
607
620
  *
608
621
  * The constructor normalises nested IR-class fields (columns, primary
609
622
  * key, uniques, indexes, foreign keys) into the appropriate class
@@ -611,10 +624,7 @@ interface StorageTableInput {
611
624
  * the input was a JSON literal or an already-constructed class.
612
625
  *
613
626
  * 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.
627
+ * the parent namespace's `tables: Record<string, StorageTable>` map.
618
628
  */
619
629
  declare class StorageTable extends SqlNode {
620
630
  readonly columns: Readonly<Record<string, StorageColumn>>;
@@ -665,41 +675,42 @@ interface StorageTypeInstanceInput {
665
675
  //#endregion
666
676
  //#region src/ir/sql-storage.d.ts
667
677
  /**
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.
678
+ * Polymorphic value type for document-scoped `SqlStorage.types` entries
679
+ * (codec aliases / parameterised native type registrations). Postgres
680
+ * native enum registrations live under
681
+ * `storage.namespaces[namespaceId].types` instead.
676
682
  */
677
- type SqlStorageTypeEntry = StorageTypeInstance | PostgresEnumStorageEntry | StorageTypeInstanceInput;
683
+ type SqlStorageTypeEntry = StorageTypeInstance | StorageTypeInstanceInput | PostgresEnumStorageEntry;
684
+ interface SqlNamespaceTablesInput {
685
+ readonly id: string;
686
+ readonly tables?: Record<string, StorageTable | StorageTableInput>;
687
+ readonly types?: Record<string, PostgresEnumStorageEntry>;
688
+ }
678
689
  interface SqlStorageInput<THash extends string = string> {
679
690
  readonly storageHash: StorageHashBase<THash>;
680
- readonly tables: Record<string, StorageTable | StorageTableInput>;
681
691
  readonly types?: Record<string, SqlStorageTypeEntry>;
682
- readonly namespaces?: Readonly<Record<string, Namespace>>;
692
+ readonly namespaces?: Readonly<Record<string, Namespace | SqlNamespaceTablesInput>>;
683
693
  }
684
694
  /**
685
695
  * SQL Contract IR root node for the `storage` field.
686
696
  *
687
697
  * Single concrete family-shared class — both Postgres and SQLite
688
- * consume this same class today. Per-target storage subclasses are
698
+ * consume this class today. Per-target storage subclasses are
689
699
  * introduced when each target's namespace shape earns its
690
700
  * target-specific concretion (target-specific derived fields,
691
701
  * target-specific storage extensions).
692
702
  *
693
703
  * Honours the framework `Storage` interface: every SQL IR carries a
694
704
  * `namespaces` map keyed by namespace id. The default singleton
695
- * (`{ [UNSPECIFIED_NAMESPACE_ID]: SqlUnspecifiedNamespace.instance }`)
705
+ * (`{ [UNBOUND_NAMESPACE_ID]: SqlUnboundNamespace.instance }`)
696
706
  * 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
707
+ * land; per-target namespace classes (`PostgresSchema.unbound`,
708
+ * `SqliteUnboundDatabase.instance`) earn their slots when each
699
709
  * target's namespace shape lands.
700
710
  *
701
- * The constructor normalises nested IR-class fields (`tables`, optional
702
- * `types`) into class instances so downstream walks see a uniform AST.
711
+ * The constructor normalises optional `types` into class instances and
712
+ * materialises plain namespace envelope objects into `Namespace` class
713
+ * instances so downstream walks see a uniform AST.
703
714
  * `types` is polymorphic per Decision 18 Option B: codec-triple inputs
704
715
  * are stamped with `kind: 'codec-instance'`; class-instance kinds
705
716
  * (e.g. Postgres-enum entries satisfying `PostgresEnumStorageEntry`)
@@ -708,27 +719,34 @@ interface SqlStorageInput<THash extends string = string> {
708
719
  * responsibility (so the family base does not import target-specific
709
720
  * subclasses).
710
721
  */
722
+ type SqlNamespace = Namespace & {
723
+ readonly tables: Readonly<Record<string, StorageTable>>;
724
+ readonly types?: Readonly<Record<string, PostgresEnumStorageEntry>>;
725
+ };
711
726
  declare class SqlStorage<THash extends string = string> extends SqlNode implements Storage {
712
727
  readonly storageHash: StorageHashBase<THash>;
713
- readonly tables: Readonly<Record<string, StorageTable>>;
714
- readonly namespaces: Readonly<Record<string, Namespace>>;
728
+ readonly namespaces: Readonly<Record<string, SqlNamespace>> & {
729
+ readonly __unbound__: SqlNamespace;
730
+ };
715
731
  readonly types?: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>;
716
732
  constructor(input: SqlStorageInput<THash>);
717
733
  } //#endregion
718
- //#region src/ir/sql-unspecified-namespace.d.ts
734
+ //#region src/ir/sql-unbound-namespace.d.ts
719
735
  /**
720
- * Family-layer placeholder for the SQL unspecified-namespace singleton.
736
+ * Family-layer placeholder for the SQL unbound-namespace singleton
737
+ * the late-bound slot whose binding the target resolves at connection
738
+ * time rather than at authoring time.
721
739
  *
722
740
  * SQL contracts honour the framework `Storage.namespaces` invariant from
723
741
  * the moment they appear in the IR. Today `SqlStorage` is family-shared
724
742
  * (Postgres + SQLite consume the same class); a per-target namespace
725
- * concretion (`PostgresSchema.unspecified`, `SqliteUnspecifiedDatabase.instance`)
743
+ * concretion (`PostgresSchema.unbound`, `SqliteUnboundDatabase.instance`)
726
744
  * earns its existence when each target's namespace shape lands. Until
727
745
  * then the family ships a single placeholder singleton so the JSON
728
746
  * envelope and runtime walk are honest at every layer.
729
747
  *
730
748
  * The `kind` discriminator is installed as a non-enumerable own property
731
- * so the JSON envelope reads `{ "id": "__unspecified__" }` — symmetric
749
+ * so the JSON envelope reads `{ "id": "__unbound__" }` — symmetric
732
750
  * with the family-level non-enumerable `kind` on `SqlNode` and bounded
733
751
  * to the minimum data the framework `Namespace` interface promises.
734
752
  *
@@ -760,49 +778,6 @@ type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';
760
778
  type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T ? NonNullable<T[TypeMapsPhantomKey & keyof T]> : never;
761
779
  type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;
762
780
  //#endregion
763
- //#region src/table-reference.d.ts
764
- /**
765
- * An object representing a reference to a table in the database.
766
- *
767
- * @template TName The name of the table. `string` is all tables, a union of string literals is a set of specific tables, a single string literal is a specific table.
768
- * @template THash The contract storage hash belonging to the database this table is in.
769
- */
770
- type TableReference<TName extends string = string, THash extends StorageHashBase<string> = StorageHashBase<string>> = {
771
- readonly '~name': TName;
772
- } & Brand<'[info] this table reference belongs to the contract with the following storage hash:', THash>;
773
- /**
774
- * An error type indicating that the provided table reference is out of the contract's scope.
775
- * To be used in reference creators, e.g. `createRef()`.
776
- *
777
- * @template TMessage The error message.
778
- */
779
- type TableReferenceOutOfContractError<TMessage extends ErrorMessage> = Brand<TMessage>;
780
- /**
781
- * An error type indicating that the provided table reference is too wide.
782
- * To be used as a `never` alternative in conditional types.
783
- *
784
- * @template TMessage The error message.
785
- */
786
- type TableReferenceTooWideError<TMessage extends ErrorMessage> = Brand<TMessage>;
787
- //#endregion
788
- //#region src/ref.d.ts
789
- /**
790
- * A fluent API representing references to tables and columns in a SQL contract.
791
- *
792
- * @template TContract The contract that describes the database.
793
- */
794
- type Ref<TContract extends Contract<SqlStorage>> = { readonly [TableName in keyof TContract['storage']['tables'] & string]: TableReference<TableName, TContract['storage']['storageHash']> & { readonly [ColumnName in Exclude<keyof TContract['storage']['tables'][TableName]['columns'], keyof TableReference> & string]: ColumnReference<ColumnName, TableName, TContract['storage']['storageHash']> } & {
795
- readonly ['*']: TableAsterisk<TableName, TContract['storage']['storageHash']>;
796
- } & Record<PropertyKey, ColumnReferenceOutOfContractError<`[error] reference to a non-existing column in the '${TableName}' table`>> } & {
797
- readonly ['*']: Asterisk;
798
- } & Record<PropertyKey, TableReferenceOutOfContractError<`[error] reference to a non-existing table in the contract`>>;
799
- /**
800
- * Creates a reference object for the given SQL contract.
801
- *
802
- * @template TContract The contract that describes the database.
803
- */
804
- declare function createRef<TContract extends Contract<SqlStorage>>(_contract: TContract): Ref<TContract>;
805
- //#endregion
806
781
  //#region src/type-atoms.d.ts
807
782
  /**
808
783
  * A utility type to drain outer generics from a type. A compiler micro-optimization.
@@ -837,6 +812,12 @@ type IsNever<TThing> = [TThing] extends [never] ? true : false;
837
812
  type Simplify<TObject extends object> = DrainOuterGeneric<{ [K in keyof TObject]: TObject[K] } & {}>;
838
813
  //#endregion
839
814
  //#region src/selection.d.ts
815
+ /**
816
+ * Resolves the tables in the late-binding (`__unbound__`) namespace of a SQL
817
+ * contract. Builder surfaces address tables by their unqualified name today;
818
+ * the unbound namespace is the slot the target resolves at connection time.
819
+ */
820
+ type UnboundTables<TContract extends Contract<SqlStorage>> = TContract['storage']['namespaces']['__unbound__']['tables'];
840
821
  /**
841
822
  * A utility type to extract the output type of a referenced column from a contract.
842
823
  * Uses the type-only codec channel (ExtractCodecTypes), not runtime mappings.
@@ -845,7 +826,7 @@ type Simplify<TObject extends object> = DrainOuterGeneric<{ [K in keyof TObject]
845
826
  * @template TTableName The name of the table containing the column.
846
827
  * @template TColumnName The name of the column whose output type is to be extracted.
847
828
  */
848
- type ExtractOutputType<TContract extends Contract<SqlStorage>, TTableName extends keyof TContract['storage']['tables'] & string, TColumnName extends keyof TContract['storage']['tables'][TTableName]['columns'] & string, _TColumn = TContract['storage']['tables'][TTableName]['columns'][TColumnName]> = _TColumn extends StorageColumn ? (_TColumn['nullable'] extends true ? null : never) | ExtractCodecTypes<TContract>[_TColumn['codecId']]['output'] : never;
829
+ type ExtractOutputType<TContract extends Contract<SqlStorage>, TTableName extends keyof UnboundTables<TContract> & string, TColumnName extends keyof UnboundTables<TContract>[TTableName]['columns'] & string, _TColumn = UnboundTables<TContract>[TTableName]['columns'][TColumnName]> = _TColumn extends StorageColumn ? (_TColumn['nullable'] extends true ? null : never) | ExtractCodecTypes<TContract>[_TColumn['codecId']]['output'] : never;
849
830
  /**
850
831
  * A type representing a selection of columns in a SQL `select` query in the
851
832
  * most generic form.
@@ -867,7 +848,50 @@ interface SelectionValue<TOutput, TDatatype extends string | unknown = unknown>
867
848
  * @template TContract The contract that describes the database.
868
849
  * @template TTableName The name of the table whose columns will be included in the selection.
869
850
  */
870
- type TableToSelection<TContract extends Contract<SqlStorage>, TTableName extends keyof TContract['storage']['tables'] & string> = DrainOuterGeneric<{ readonly [ColumnName in keyof TContract['storage']['tables'][TTableName]['columns'] & string]: SelectionValue<ExtractOutputType<TContract, TTableName, ColumnName>, TContract['storage']['tables'][TTableName]['columns'][ColumnName]['nativeType']> }>;
851
+ type TableToSelection<TContract extends Contract<SqlStorage>, TTableName extends keyof UnboundTables<TContract> & string> = DrainOuterGeneric<{ readonly [ColumnName in keyof UnboundTables<TContract>[TTableName]['columns'] & string]: SelectionValue<ExtractOutputType<TContract, TTableName, ColumnName>, UnboundTables<TContract>[TTableName]['columns'][ColumnName]['nativeType']> }>;
852
+ //#endregion
853
+ //#region src/table-reference.d.ts
854
+ /**
855
+ * An object representing a reference to a table in the database.
856
+ *
857
+ * @template TName The name of the table. `string` is all tables, a union of string literals is a set of specific tables, a single string literal is a specific table.
858
+ * @template THash The contract storage hash belonging to the database this table is in.
859
+ */
860
+ type TableReference<TName extends string = string, THash extends StorageHashBase<string> = StorageHashBase<string>> = {
861
+ readonly '~name': TName;
862
+ } & Brand<'[info] this table reference belongs to the contract with the following storage hash:', THash>;
863
+ /**
864
+ * An error type indicating that the provided table reference is out of the contract's scope.
865
+ * To be used in reference creators, e.g. `createRef()`.
866
+ *
867
+ * @template TMessage The error message.
868
+ */
869
+ type TableReferenceOutOfContractError<TMessage extends ErrorMessage> = Brand<TMessage>;
870
+ /**
871
+ * An error type indicating that the provided table reference is too wide.
872
+ * To be used as a `never` alternative in conditional types.
873
+ *
874
+ * @template TMessage The error message.
875
+ */
876
+ type TableReferenceTooWideError<TMessage extends ErrorMessage> = Brand<TMessage>;
877
+ //#endregion
878
+ //#region src/ref.d.ts
879
+ /**
880
+ * A fluent API representing references to tables and columns in a SQL contract.
881
+ *
882
+ * @template TContract The contract that describes the database.
883
+ */
884
+ type Ref<TContract extends Contract<SqlStorage>> = { readonly [TableName in keyof UnboundTables<TContract> & string]: TableReference<TableName, TContract['storage']['storageHash']> & { readonly [ColumnName in Exclude<keyof UnboundTables<TContract>[TableName]['columns'], keyof TableReference> & string]: ColumnReference<ColumnName, TableName, TContract['storage']['storageHash']> } & {
885
+ readonly ['*']: TableAsterisk<TableName, TContract['storage']['storageHash']>;
886
+ } & Record<PropertyKey, ColumnReferenceOutOfContractError<`[error] reference to a non-existing column in the '${TableName}' table`>> } & {
887
+ readonly ['*']: Asterisk;
888
+ } & Record<PropertyKey, TableReferenceOutOfContractError<`[error] reference to a non-existing table in the contract`>>;
889
+ /**
890
+ * Creates a reference object for the given SQL contract.
891
+ *
892
+ * @template TContract The contract that describes the database.
893
+ */
894
+ declare function createRef<TContract extends Contract<SqlStorage>>(_contract: TContract): Ref<TContract>;
871
895
  //#endregion
872
896
  //#region src/select-builder.d.ts
873
897
  /**
@@ -877,7 +901,7 @@ type TableToSelection<TContract extends Contract<SqlStorage>, TTableName extends
877
901
  * @template TTables The tables involved in the current `select` query.
878
902
  * @template TSelection The current selection of the `select` query.
879
903
  */
880
- declare class SelectBuilder<TContract extends Contract<SqlStorage>, TTables extends Contract<SqlStorage>['storage']['tables'], TSelection extends Selection = never> {
904
+ declare class SelectBuilder<TContract extends Contract<SqlStorage>, TTables extends UnboundTables<Contract<SqlStorage>>, TSelection extends Selection = never> {
881
905
  #private;
882
906
  constructor(contract: TContract);
883
907
  select(asterisk: Asterisk): ExactlyOneProperty<TTables> extends true ? SelectBuilder<TContract, TTables, MergeObjects<TSelection, TableToSelection<TContract, keyof TTables & string>>> : PreviousFunctionReceivedBadInputError<'[error] selecting all columns via `*` results in ambiguity when multiple tables are involved in the query'>;
@@ -904,7 +928,7 @@ declare class Root<TContract extends Contract<SqlStorage>> {
904
928
  /**
905
929
  * @template TName The name of the table to select from.
906
930
  */
907
- from<TName extends string>(table: string extends TName ? TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'> : TableReference<TName, TContract['storage']['storageHash']>): TName extends string ? SelectBuilder<TContract, Pick<TContract['storage']['tables'], TName>> : PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;
931
+ from<TName extends string>(table: string extends TName ? TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'> : TableReference<TName, TContract['storage']['storageHash']>): TName extends string ? SelectBuilder<TContract, Pick<UnboundTables<TContract>, TName>> : PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;
908
932
  from(table: TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'>): PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;
909
933
  }
910
934
  /**
@@ -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","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,KAENC,kBAAAA;EAAAA,SACMC,WAAAA;EAAAA,SACAC,YAAAA;AAAAA;AAAAA,KAENC,yBAAAA;EAAAA,SACMC,EAAAA;EAAAA,SACAC,WAAAA;EAAAA,SACAC,EAAAA,EAAIN,kBAAAA;AAAAA;AAAAA,KAEVO,qBAAAA;EAAAA,SACMH,EAAAA;EAAAA,SACAC,WAAAA;AAAAA;AAAAA,KAENG,gBAAAA,GAAmBL,yBAAAA,GAA4BI,qBAAAA;AAAAA,KAC/CE,qBAAAA;EAAAA,SACMC,KAAAA;AAAAA;AAAAA,KAENC,oBAAAA;EAAAA,SACMC,KAAAA;AAAAA;AAAAA,KAENC,mBAAAA;EAAAA,SACMC,MAAAA,EAAQ7B,MAAAA,SAAeU,aAAAA;AAAAA;AAAAA,KAE7BoB,gBAAAA,GAAmBC,QAAAA,CAAS/B,MAAAA;AAAAA,UACvBgC,iBAAAA,uBAAwCF,gBAAAA,GAAmBA,gBAAAA;EAAAA,SAC1DD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AAU,SAAA;EAItB,MAAA,CACE,QAAA,EAAU,QAAA,GACT,kBAAA,CAAmB,OAAA,iBAClB,aAAA,CACE,SAAA,EACA,OAAA,EACA,YAAA,CAAa,UAAA,EAAY,gBAAA,CAAiB,SAAA,QAAiB,OAAA,eAE7D,qCAAA;EACJ,MAAA,0BAAgC,OAAA,UAAA,CAC9B,QAAA,EAAU,aAAA,CAAc,UAAA,EAAY,SAAA,8BACnC,aAAA,CACD,SAAA,EACA,OAAA,EACA,YAAA,CAAa,UAAA,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;EVRnBlR;;;;;EUiBH,IAAA,CACE,KAAA,EAAO,cAAA,UACN,qCAAA;EVfc;;;EUmBjB,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","UNBOUND_NAMESPACE_ID","Namespace","id","NamespaceBase","Storage","Record","Readonly","namespaces","StorageType","IRNodeBase","Namespace","NamespaceBase","Storage","StorageType","ColumnDefault","StorageHashBase","CodecTrait","SqlNode","kind","constructor","ForeignKeyReferenceInput","namespaceId","tableName","columns","ForeignKeyReference","input","ReferentialAction","ForeignKeyInput","source","target","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","SqlNamespaceTablesInput","id","tables","types","SqlStorageInput","THash","storageHash","namespaces","SqlNamespace","SqlStorage","__unbound__","SqlUnboundNamespace","instance","ForeignKeyOptions","SqlModelFieldStorage","column","SqlModelStorage","table","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-FVBrwvCz.d.mts","../src/type-atoms.ts","../src/selection.ts","../src/table-reference.ts","../src/ref.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,SACM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AA,EAAA,CACpD,QAAA,EAAU,SAAA,GACT,IAAA,CAAK,SAAA"}
@@ -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 // 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"}
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 { UnboundTables } from './selection';\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 UnboundTables<TContract> & string]: TableReference<\n TableName,\n TContract['storage']['storageHash']\n > & {\n readonly [ColumnName in Exclude<\n keyof UnboundTables<TContract>[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, UnboundTables } 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 UnboundTables<Contract<SqlStorage>>,\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 { UnboundTables } from './selection';\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<UnboundTables<TContract>, 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":";;;;;;AA4CA,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;;;;;;;;;;;AC1DJ,IAAa,gBAAb,MAIE;CAGA;CAEA,YAAY,UAAqB;EAC/B,KAAKA,YAAY;;CAsBnB,OAAO,GAAG,OAA2B;EAEnC,OAAO;;CAKT,QAGyB;EAEvB,OAAO,EAAE;;;;;;;;;;AC9Cb,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.9.0",
3
+ "version": "0.10.0",
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.9.0",
10
- "@prisma-next/sql-contract": "0.9.0",
11
- "@prisma-next/tsconfig": "0.9.0",
12
- "@prisma-next/tsdown": "0.9.0",
9
+ "@prisma-next/contract": "0.10.0",
10
+ "@prisma-next/sql-contract": "0.10.0",
11
+ "@prisma-next/tsconfig": "0.10.0",
12
+ "@prisma-next/tsdown": "0.10.0",
13
13
  "tsdown": "0.22.0",
14
14
  "typescript": "5.9.3",
15
15
  "vitest": "4.1.6"
package/src/ref.ts CHANGED
@@ -6,6 +6,7 @@ import type {
6
6
  ColumnReferenceOutOfContractError,
7
7
  TableAsterisk,
8
8
  } from './column-reference';
9
+ import type { UnboundTables } from './selection';
9
10
  import type { TableReference, TableReferenceOutOfContractError } from './table-reference';
10
11
 
11
12
  /**
@@ -14,12 +15,12 @@ import type { TableReference, TableReferenceOutOfContractError } from './table-r
14
15
  * @template TContract The contract that describes the database.
15
16
  */
16
17
  export type Ref<TContract extends Contract<SqlStorage>> = {
17
- readonly [TableName in keyof TContract['storage']['tables'] & string]: TableReference<
18
+ readonly [TableName in keyof UnboundTables<TContract> & string]: TableReference<
18
19
  TableName,
19
20
  TContract['storage']['storageHash']
20
21
  > & {
21
22
  readonly [ColumnName in Exclude<
22
- keyof TContract['storage']['tables'][TableName]['columns'],
23
+ keyof UnboundTables<TContract>[TableName]['columns'],
23
24
  keyof TableReference
24
25
  > &
25
26
  string]: ColumnReference<ColumnName, TableName, TContract['storage']['storageHash']>;
package/src/root.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Contract } from '@prisma-next/contract/types';
2
2
  import type { SqlStorage } from '@prisma-next/sql-contract/types';
3
3
  import { SelectBuilder } from './select-builder';
4
+ import type { UnboundTables } from './selection';
4
5
  import type { TableReference, TableReferenceTooWideError } from './table-reference';
5
6
  import type { PreviousFunctionReceivedBadInputError } from './type-errors';
6
7
 
@@ -32,7 +33,7 @@ export class Root<TContract extends Contract<SqlStorage>> {
32
33
  ? TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'>
33
34
  : TableReference<TName, TContract['storage']['storageHash']>,
34
35
  ): TName extends string
35
- ? SelectBuilder<TContract, Pick<TContract['storage']['tables'], TName>>
36
+ ? SelectBuilder<TContract, Pick<UnboundTables<TContract>, TName>>
36
37
  : PreviousFunctionReceivedBadInputError<'[error] invalid table reference in previous `root.from()` call will probably cause runtime errors'>;
37
38
  from(
38
39
  table: TableReferenceTooWideError<'[error] `root.from()` call received a table reference without a specific table name'>,
@@ -1,7 +1,7 @@
1
1
  import type { Contract } from '@prisma-next/contract/types';
2
2
  import type { SqlStorage } from '@prisma-next/sql-contract/types';
3
3
  import type { Asterisk, TableAsterisk } from './column-reference';
4
- import type { Selection, TableToSelection } from './selection';
4
+ import type { Selection, TableToSelection, UnboundTables } from './selection';
5
5
  import type { ExactlyOneProperty, IsNever, MergeObjects, Simplify } from './type-atoms';
6
6
  import type { PreviousFunctionReceivedBadInputError } from './type-errors';
7
7
 
@@ -14,7 +14,7 @@ import type { PreviousFunctionReceivedBadInputError } from './type-errors';
14
14
  */
15
15
  export class SelectBuilder<
16
16
  TContract extends Contract<SqlStorage>,
17
- TTables extends Contract<SqlStorage>['storage']['tables'],
17
+ TTables extends UnboundTables<Contract<SqlStorage>>,
18
18
  TSelection extends Selection = never,
19
19
  > {
20
20
  // @ts-expect-error
package/src/selection.ts CHANGED
@@ -2,6 +2,14 @@ import type { Contract } from '@prisma-next/contract/types';
2
2
  import type { ExtractCodecTypes, SqlStorage, StorageColumn } from '@prisma-next/sql-contract/types';
3
3
  import type { DrainOuterGeneric } from './type-atoms';
4
4
 
5
+ /**
6
+ * Resolves the tables in the late-binding (`__unbound__`) namespace of a SQL
7
+ * contract. Builder surfaces address tables by their unqualified name today;
8
+ * the unbound namespace is the slot the target resolves at connection time.
9
+ */
10
+ export type UnboundTables<TContract extends Contract<SqlStorage>> =
11
+ TContract['storage']['namespaces']['__unbound__']['tables'];
12
+
5
13
  /**
6
14
  * A utility type to extract the output type of a referenced column from a contract.
7
15
  * Uses the type-only codec channel (ExtractCodecTypes), not runtime mappings.
@@ -12,9 +20,9 @@ import type { DrainOuterGeneric } from './type-atoms';
12
20
  */
13
21
  export type ExtractOutputType<
14
22
  TContract extends Contract<SqlStorage>,
15
- TTableName extends keyof TContract['storage']['tables'] & string,
16
- TColumnName extends keyof TContract['storage']['tables'][TTableName]['columns'] & string,
17
- _TColumn = TContract['storage']['tables'][TTableName]['columns'][TColumnName],
23
+ TTableName extends keyof UnboundTables<TContract> & string,
24
+ TColumnName extends keyof UnboundTables<TContract>[TTableName]['columns'] & string,
25
+ _TColumn = UnboundTables<TContract>[TTableName]['columns'][TColumnName],
18
26
  > = _TColumn extends StorageColumn
19
27
  ?
20
28
  | (_TColumn['nullable'] extends true ? null : never)
@@ -46,11 +54,11 @@ export interface SelectionValue<TOutput, TDatatype extends string | unknown = un
46
54
  */
47
55
  export type TableToSelection<
48
56
  TContract extends Contract<SqlStorage>,
49
- TTableName extends keyof TContract['storage']['tables'] & string,
57
+ TTableName extends keyof UnboundTables<TContract> & string,
50
58
  > = DrainOuterGeneric<{
51
- readonly [ColumnName in keyof TContract['storage']['tables'][TTableName]['columns'] &
59
+ readonly [ColumnName in keyof UnboundTables<TContract>[TTableName]['columns'] &
52
60
  string]: SelectionValue<
53
61
  ExtractOutputType<TContract, TTableName, ColumnName>,
54
- TContract['storage']['tables'][TTableName]['columns'][ColumnName]['nativeType']
62
+ UnboundTables<TContract>[TTableName]['columns'][ColumnName]['nativeType']
55
63
  >;
56
64
  }>;