@prisma-next/sql-lane-query-builder 0.5.0-dev.9 → 0.5.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
@@ -1,8 +1,188 @@
1
- import { Brand, Contract, StorageHashBase } from "@prisma-next/contract/types";
2
- import { ExtractCodecTypes, SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
3
-
1
+ //#region ../../../1-framework/0-foundation/contract/dist/contract-types-Kl86EaEa.d.mts
2
+ //#region src/domain-types.d.ts
3
+ type ScalarFieldType = {
4
+ readonly kind: 'scalar';
5
+ readonly codecId: string;
6
+ readonly typeParams?: Record<string, unknown>;
7
+ };
8
+ type ValueObjectFieldType = {
9
+ readonly kind: 'valueObject';
10
+ readonly name: string;
11
+ };
12
+ type UnionFieldType = {
13
+ readonly kind: 'union';
14
+ readonly members: ReadonlyArray<ScalarFieldType | ValueObjectFieldType>;
15
+ };
16
+ type ContractFieldType = ScalarFieldType | ValueObjectFieldType | UnionFieldType;
17
+ type ContractField = {
18
+ readonly nullable: boolean;
19
+ readonly type: ContractFieldType;
20
+ readonly many?: true;
21
+ readonly dict?: true;
22
+ };
23
+ type ContractRelationOn = {
24
+ readonly localFields: readonly string[];
25
+ readonly targetFields: readonly string[];
26
+ };
27
+ type ContractReferenceRelation = {
28
+ readonly to: string;
29
+ readonly cardinality: '1:1' | '1:N' | 'N:1';
30
+ readonly on: ContractRelationOn;
31
+ };
32
+ type ContractEmbedRelation = {
33
+ readonly to: string;
34
+ readonly cardinality: '1:1' | '1:N';
35
+ };
36
+ type ContractRelation = ContractReferenceRelation | ContractEmbedRelation;
37
+ type ContractDiscriminator = {
38
+ readonly field: string;
39
+ };
40
+ type ContractVariantEntry = {
41
+ readonly value: string;
42
+ };
43
+ type ContractValueObject = {
44
+ readonly fields: Record<string, ContractField>;
45
+ };
46
+ type ModelStorageBase = Readonly<Record<string, unknown>>;
47
+ interface ContractModelBase<TModelStorage extends ModelStorageBase = ModelStorageBase> {
48
+ readonly fields: Record<string, ContractField>;
49
+ readonly relations: Record<string, ContractRelation>;
50
+ readonly storage: TModelStorage;
51
+ readonly discriminator?: ContractDiscriminator;
52
+ readonly variants?: Record<string, ContractVariantEntry>;
53
+ readonly base?: string;
54
+ readonly owner?: string;
55
+ }
56
+ //#endregion
57
+ //#region src/types.d.ts
58
+ /**
59
+ * Unique symbol used as the key for branding types.
60
+ */
61
+ declare const $: unique symbol;
62
+ /**
63
+ * A helper type to brand a given type with a unique identifier.
64
+ *
65
+ * @template TKey Text used as the brand key.
66
+ * @template TValue Optional value associated with the brand key. Defaults to `true`.
67
+ */
68
+ type Brand<TKey extends string | number | symbol, TValue = true> = {
69
+ [$]: { [K in TKey]: TValue };
70
+ };
71
+ /**
72
+ * Base type for storage contract hashes.
73
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
74
+ * `type StorageHash = StorageHashBase<'sha256:abc123...'>`
75
+ */
76
+ type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;
77
+ /**
78
+ * Base type for execution contract hashes.
79
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
80
+ * `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`
81
+ */
82
+ type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;
83
+ /**
84
+ * Base type for profile contract hashes.
85
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
86
+ * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`
87
+ */
88
+ type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;
89
+ /**
90
+ * Base type for family-specific storage blocks.
91
+ * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the
92
+ * storage hash alongside family-specific data (tables, collections, etc.).
93
+ */
94
+ interface StorageBase<THash extends string = string> {
95
+ readonly storageHash: StorageHashBase<THash>;
96
+ }
97
+ type GeneratedValueSpec = {
98
+ readonly id: string;
99
+ readonly params?: Record<string, unknown>;
100
+ };
101
+ type JsonPrimitive = string | number | boolean | null;
102
+ type JsonValue = JsonPrimitive | {
103
+ readonly [key: string]: JsonValue;
104
+ } | readonly JsonValue[];
105
+ type ColumnDefaultLiteralValue = JsonValue;
106
+ type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;
107
+ /**
108
+ * Runtime predicate for `ColumnDefaultLiteralInputValue`. Authoring layers
109
+ * resolve template values from caller-supplied args (typed `unknown` at the
110
+ * boundary) and need to validate before constructing a `ColumnDefault`.
111
+ * Accepts JSON primitives, plain arrays/objects of JSON values, and `Date`
112
+ * instances. Rejects functions, class instances (other than `Date`),
113
+ * `undefined`, `bigint`, `symbol`, and arrays/objects containing those.
114
+ */
115
+ type ColumnDefault = {
116
+ readonly kind: 'literal';
117
+ readonly value: ColumnDefaultLiteralInputValue;
118
+ } | {
119
+ readonly kind: 'function';
120
+ readonly expression: string;
121
+ };
122
+ type ExecutionMutationDefaultValue = {
123
+ readonly kind: 'generator';
124
+ readonly id: GeneratedValueSpec['id'];
125
+ readonly params?: Record<string, unknown>;
126
+ };
127
+ type ExecutionMutationDefault = {
128
+ readonly ref: {
129
+ readonly table: string;
130
+ readonly column: string;
131
+ };
132
+ readonly onCreate?: ExecutionMutationDefaultValue;
133
+ readonly onUpdate?: ExecutionMutationDefaultValue;
134
+ };
135
+ /**
136
+ * `ExecutionMutationDefault` minus its `ref` — the per-field phases value
137
+ * authoring layers attach to a column before the column ref is known.
138
+ */
139
+ //#endregion
140
+ //#region src/contract-types.d.ts
141
+ /**
142
+ * Execution section for the unified contract (ADR 182).
143
+ *
144
+ * Unlike the legacy {@link import('./types').ExecutionSection}, this type
145
+ * requires `executionHash` — when an execution section is present, its
146
+ * hash must be too (consistent with `StorageBase.storageHash`).
147
+ *
148
+ * @template THash Literal hash string type for type-safe hash tracking.
149
+ */
150
+ type ContractExecutionSection<THash extends string = string> = {
151
+ readonly executionHash: ExecutionHashBase<THash>;
152
+ readonly mutations: {
153
+ readonly defaults: ReadonlyArray<ExecutionMutationDefault>;
154
+ };
155
+ };
156
+ /**
157
+ * Unified contract representation (ADR 182).
158
+ *
159
+ * A `Contract` is the canonical in-memory representation of a data contract.
160
+ * It is model-first (domain models carry their own storage bridge) and
161
+ * family-parameterized (SQL, Mongo, etc. specialize via `TStorage` and model
162
+ * storage generics on `ContractModel`).
163
+ *
164
+ * JSON persistence fields (`schemaVersion`, `sources`) are not represented
165
+ * here — they are handled at the serialization boundary.
166
+ *
167
+ * @template TStorage Family-specific storage block (extends {@link StorageBase}).
168
+ * @template TModels Record of model name → {@link ContractModel} with
169
+ * family-specific model storage.
170
+ */
171
+ interface Contract<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
172
+ readonly target: string;
173
+ readonly targetFamily: string;
174
+ readonly roots: Record<string, string>;
175
+ readonly models: TModels;
176
+ readonly valueObjects?: Record<string, ContractValueObject>;
177
+ readonly storage: TStorage;
178
+ readonly capabilities: Record<string, Record<string, boolean>>;
179
+ readonly extensionPacks: Record<string, unknown>;
180
+ readonly execution?: ContractExecutionSection;
181
+ readonly profileHash: ProfileHashBase<string>;
182
+ readonly meta: Record<string, unknown>;
183
+ } //#endregion
184
+ //#endregion
4
185
  //#region src/type-errors.d.ts
5
-
6
186
  /**
7
187
  * An error message type, prefixed with `[error]`.
8
188
  *
@@ -54,6 +234,110 @@ type TableAsterisk<TTableName extends string = string, THash extends StorageHash
54
234
  readonly '~table': TTableName;
55
235
  } & Brand<'[info] referencing all columns that belong to the following table reference:', `${TTableName}@${THash}`>;
56
236
  //#endregion
237
+ //#region ../../1-core/contract/dist/types-njsiV-Ck.d.mts
238
+ //#region src/types.d.ts
239
+ /**
240
+ * A column definition in storage.
241
+ *
242
+ * `typeParams` is optional because most columns use non-parameterized types.
243
+ * Columns with parameterized types can either inline `typeParams` or reference
244
+ * a named {@link StorageTypeInstance} via `typeRef`.
245
+ */
246
+ type StorageColumn = {
247
+ readonly nativeType: string;
248
+ readonly codecId: string;
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;
261
+ /**
262
+ * Default value for the column.
263
+ * Can be a literal value or database function.
264
+ */
265
+ readonly default?: ColumnDefault;
266
+ };
267
+ type PrimaryKey = {
268
+ readonly columns: readonly string[];
269
+ readonly name?: string;
270
+ };
271
+ type UniqueConstraint = {
272
+ readonly columns: readonly string[];
273
+ readonly name?: string;
274
+ };
275
+ type Index = {
276
+ readonly columns: readonly string[];
277
+ readonly name?: string;
278
+ readonly type?: string;
279
+ readonly options?: Record<string, unknown>;
280
+ };
281
+ type ForeignKeyReferences = {
282
+ readonly table: string;
283
+ readonly columns: readonly string[];
284
+ };
285
+ type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
286
+ type ForeignKey = {
287
+ readonly columns: readonly string[];
288
+ readonly references: ForeignKeyReferences;
289
+ readonly name?: string;
290
+ readonly onDelete?: ReferentialAction;
291
+ readonly onUpdate?: ReferentialAction; /** Whether to emit FK constraint DDL (ALTER TABLE … ADD CONSTRAINT … FOREIGN KEY). */
292
+ readonly constraint: boolean; /** Whether to emit a backing index for the FK columns. */
293
+ readonly index: boolean;
294
+ };
295
+ type StorageTable = {
296
+ readonly columns: Record<string, StorageColumn>;
297
+ readonly primaryKey?: PrimaryKey;
298
+ readonly uniques: ReadonlyArray<UniqueConstraint>;
299
+ readonly indexes: ReadonlyArray<Index>;
300
+ readonly foreignKeys: ReadonlyArray<ForeignKey>;
301
+ };
302
+ /**
303
+ * A named, parameterized type instance.
304
+ * These are registered in `storage.types` for reuse across columns
305
+ * and to enable ergonomic schema surfaces like `schema.types.MyType`.
306
+ *
307
+ * Unlike {@link StorageColumn}, `typeParams` is required here because
308
+ * `StorageTypeInstance` exists specifically to define reusable parameterized types.
309
+ * A type instance without parameters would be redundant—columns can reference
310
+ * the codec directly via `codecId`.
311
+ */
312
+ type StorageTypeInstance = {
313
+ readonly codecId: string;
314
+ readonly nativeType: string;
315
+ readonly typeParams: Record<string, unknown>;
316
+ };
317
+ type SqlStorage<THash extends string = string> = StorageBase<THash> & {
318
+ readonly tables: Record<string, StorageTable>;
319
+ /**
320
+ * Named type instances for parameterized/custom types.
321
+ * Columns can reference these via `typeRef`.
322
+ */
323
+ readonly types?: Record<string, StorageTypeInstance>;
324
+ };
325
+ type CodecTypesOf<T> = [T] extends [never] ? Record<string, never> : T extends {
326
+ readonly codecTypes: infer C;
327
+ } ? C extends Record<string, {
328
+ output: unknown;
329
+ }> ? C : Record<string, never> : Record<string, never>;
330
+ /**
331
+ * Dispatch hint identifying the first-argument target of an operation.
332
+ *
333
+ * Used by ORM column helpers to decide whether an operation is reachable on a
334
+ * field. Either names a concrete codec identity or a set of capability traits
335
+ * that the field's codec must carry.
336
+ */
337
+ type TypeMapsPhantomKey = '__@prisma-next/sql-contract/typeMaps@__';
338
+ type ExtractTypeMapsFromContract<T> = TypeMapsPhantomKey extends keyof T ? NonNullable<T[TypeMapsPhantomKey & keyof T]> : never;
339
+ type ExtractCodecTypes<T> = CodecTypesOf<ExtractTypeMapsFromContract<T>>;
340
+ //#endregion
57
341
  //#region src/table-reference.d.ts
58
342
  /**
59
343
  * An object representing a reference to a table in the database.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/type-errors.ts","../src/column-reference.ts","../src/table-reference.ts","../src/ref.ts","../src/type-atoms.ts","../src/selection.ts","../src/select-builder.ts","../src/root.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAOA;AAQA;AAAmE,KARvD,YAAA,GAQuD,WAAA,MAAA,EAAA;;;;;;;ACLvD,KDKA,qCCLe,CAAA,iBDKwC,YCLxC,CAAA,GDKwD,KCLxD,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A,CAAA,CAAA,QAAA,CAAA,EMMuB,KNNvB,CAAA,CAAA,GMOvC,qCNPuC,CAAA,mGAAA,CAAA;EAAkB,IAAA,CAAA,KAAA,EMSpD,0BNToD,CAAA,qFAAA,CAAA,CAAA,EMU1D,qCNV0D,CAAA,mGAAA,CAAA;;;;AAK/D;AAWY,iBMOI,UAAA,CNPS,QAAA,EAAA,KAAA,CAAA,EMStB,qCNTsB,CAAA,sGAAA,CAAA;;;;AAQpB,iBMKW,UNLX,CAAA,kBMKwC,QNLxC,CMKiD,UNLjD,CAAA,CAAA,CAAA,QAAA,EMMO,SNNP,CAAA,EMOF,INPE,CMOG,SNPH,CAAA"}
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,IA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UAAA,2CACN,SAAA;EAAA;cAMP,QAAA,EAAU,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;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"}
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ function createRef(_contract) {
10
10
  "~name": tableName,
11
11
  "~table": null
12
12
  });
13
- return new Proxy({}, { get(_target$1, columnName) {
13
+ return new Proxy({}, { get(_target, columnName) {
14
14
  if (columnName === "~name") return tableName;
15
15
  return Object.freeze({
16
16
  "~name": columnName,
@@ -19,7 +19,6 @@ function createRef(_contract) {
19
19
  } });
20
20
  } });
21
21
  }
22
-
23
22
  //#endregion
24
23
  //#region src/select-builder.ts
25
24
  /**
@@ -41,7 +40,6 @@ var SelectBuilder = class {
41
40
  return {};
42
41
  }
43
42
  };
44
-
45
43
  //#endregion
46
44
  //#region src/root.ts
47
45
  /**
@@ -67,7 +65,7 @@ var Root = class {
67
65
  function createRoot(contract) {
68
66
  return new Root(contract);
69
67
  }
70
-
71
68
  //#endregion
72
69
  export { createRef, createRoot };
70
+
73
71
  //# sourceMappingURL=index.mjs.map
@@ -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;AAChB,QAAO,IAAI,MAAM,EAAE,EAAoB,EACrC,IAAI,SAAS,WAAW;AACtB,MAAI,cAAc,IAChB,QAAO,OAAO,OAAO;GACnB,SAAS;GACT,UAAU;GACX,CAAC;AAGJ,SAAO,IAAI,MACT,EAAE,EACF,EACE,IAAI,WAAS,YAAY;AACvB,OAAI,eAAe,QACjB,QAAO;AAGT,UAAO,OAAO,OAAO;IACnB,SAAS;IACT,UAAU;IACX,CAAC;KAEL,CACF;IAEJ,CAAC;;;;;;;;;;;;ACzDJ,IAAa,gBAAb,MAIE;CAGA,CAASA;CAET,YAAY,UAAqB;AAC/B,QAAKA,WAAY;;CAsBnB,OAAO,GAAG,OAA2B;AAEnC,SAAO;;CAKT,QAGyB;AAEvB,SAAO,EAAE;;;;;;;;;;;AC/Cb,IAAa,OAAb,MAA0D;CACxD,CAASC;CAET,YAAY,UAAqB;AAC/B,QAAKA,WAAY;;;;;CA2BnB,KAAK,QAA0B;AAE7B,SAAO,IAAI,cAAc,MAAKA,SAAU;;;;;;AAmB5C,SAAgB,WAAW,UAA4B;AACrD,QAAO,IAAI,KAAK,SAAiC"}
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;CACrD,OAAO,IAAI,KAAK,SAAiC"}
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@prisma-next/sql-lane-query-builder",
3
- "version": "0.5.0-dev.9",
3
+ "version": "0.5.0",
4
+ "license": "Apache-2.0",
4
5
  "type": "module",
5
6
  "sideEffects": false,
6
7
  "description": "SQL query builder lane for Prisma Next",
7
8
  "devDependencies": {
8
- "tsdown": "0.18.4",
9
+ "tsdown": "0.22.0",
9
10
  "typescript": "5.9.3",
10
- "vitest": "4.0.17",
11
- "@prisma-next/contract": "0.5.0-dev.9",
12
- "@prisma-next/sql-contract": "0.5.0-dev.9",
13
- "@prisma-next/tsconfig": "0.0.0",
14
- "@prisma-next/tsdown": "0.0.0"
11
+ "vitest": "4.1.5",
12
+ "@prisma-next/contract": "0.5.0",
13
+ "@prisma-next/sql-contract": "0.5.0",
14
+ "@prisma-next/tsdown": "0.0.0",
15
+ "@prisma-next/tsconfig": "0.0.0"
15
16
  },
16
17
  "files": [
17
18
  "dist",