prisma-ts-select 0.0.33

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.
@@ -0,0 +1,451 @@
1
+ import { Prisma } from '@prisma/client/extension';
2
+ import { PrismaClient } from '@prisma/client';
3
+
4
+ declare const DB: {
5
+ readonly User: {
6
+ readonly fields: {
7
+ readonly id: "Int";
8
+ readonly email: "String";
9
+ readonly name: "?String";
10
+ };
11
+ readonly relations: {
12
+ readonly Post: {
13
+ readonly id: ["authorId", "lastModifiedById"];
14
+ };
15
+ readonly LikedPosts: {
16
+ readonly id: ["authorId"];
17
+ };
18
+ };
19
+ };
20
+ readonly Post: {
21
+ readonly fields: {
22
+ readonly id: "Int";
23
+ readonly title: "String";
24
+ readonly content: "?String";
25
+ readonly published: "Boolean";
26
+ readonly authorId: "Int";
27
+ readonly lastModifiedById: "Int";
28
+ };
29
+ readonly relations: {
30
+ readonly User: {
31
+ readonly authorId: ["id"];
32
+ readonly lastModifiedById: ["id"];
33
+ };
34
+ readonly PostsImages: {
35
+ readonly id: ["postId"];
36
+ };
37
+ readonly LikedPosts: {
38
+ readonly id: ["postId"];
39
+ };
40
+ };
41
+ };
42
+ readonly PostsImages: {
43
+ readonly fields: {
44
+ readonly id: "Int";
45
+ readonly url: "String";
46
+ readonly postId: "Int";
47
+ };
48
+ readonly relations: {
49
+ readonly Post: {
50
+ readonly postId: ["id"];
51
+ };
52
+ };
53
+ };
54
+ readonly LikedPosts: {
55
+ readonly fields: {
56
+ readonly id: "Int";
57
+ readonly postId: "Int";
58
+ readonly authorId: "Int";
59
+ };
60
+ readonly relations: {
61
+ readonly Post: {
62
+ readonly postId: ["id"];
63
+ };
64
+ readonly User: {
65
+ readonly authorId: ["id"];
66
+ };
67
+ };
68
+ };
69
+ readonly MFId_Category: {
70
+ readonly fields: {
71
+ readonly id: "Int";
72
+ readonly name: "String";
73
+ };
74
+ readonly relations: {
75
+ readonly MFId_CategoryPost: {
76
+ readonly id: ["categoryId"];
77
+ };
78
+ };
79
+ };
80
+ readonly MFId_CategoryPost: {
81
+ readonly fields: {
82
+ readonly categoryId: "Int";
83
+ readonly postId: "Int";
84
+ };
85
+ readonly relations: {
86
+ readonly MFId_Category: {
87
+ readonly categoryId: ["id"];
88
+ };
89
+ readonly MFId_Post: {
90
+ readonly postId: ["id"];
91
+ };
92
+ };
93
+ };
94
+ readonly MFId_Post: {
95
+ readonly relations: {
96
+ readonly MFId_CategoryPost: {
97
+ readonly id: ["postId"];
98
+ };
99
+ };
100
+ readonly fields: {
101
+ readonly id: "Int";
102
+ readonly title: "String";
103
+ };
104
+ };
105
+ readonly M2M_Post: {
106
+ readonly fields: {
107
+ readonly id: "Int";
108
+ readonly title: "String";
109
+ };
110
+ readonly relations: {
111
+ readonly _M2M_CategoryToM2M_Post: {
112
+ readonly id: ["B"];
113
+ };
114
+ };
115
+ };
116
+ readonly _M2M_CategoryToM2M_Post: {
117
+ readonly fields: {
118
+ readonly A: "Int";
119
+ readonly B: "Int";
120
+ };
121
+ readonly relations: {
122
+ readonly M2M_Post: {
123
+ readonly B: ["id"];
124
+ };
125
+ readonly M2M_Category: {
126
+ readonly A: ["id"];
127
+ };
128
+ };
129
+ };
130
+ readonly M2M_Category: {
131
+ readonly fields: {
132
+ readonly id: "Int";
133
+ readonly name: "String";
134
+ };
135
+ readonly relations: {
136
+ readonly _M2M_CategoryToM2M_Post: {
137
+ readonly id: ["A"];
138
+ };
139
+ };
140
+ };
141
+ readonly M2M_NC_Category: {
142
+ readonly fields: {
143
+ readonly id: "Int";
144
+ readonly name: "String";
145
+ };
146
+ readonly relations: {
147
+ readonly _M2M_NC: {
148
+ readonly id: ["A"];
149
+ };
150
+ };
151
+ };
152
+ readonly _M2M_NC: {
153
+ readonly fields: {
154
+ readonly A: "Int";
155
+ readonly B: "Int";
156
+ };
157
+ readonly relations: {
158
+ readonly M2M_NC_Category: {
159
+ readonly A: ["id"];
160
+ };
161
+ readonly M2M_NC_Post: {
162
+ readonly B: ["id"];
163
+ };
164
+ };
165
+ };
166
+ readonly M2M_NC_Post: {
167
+ readonly fields: {
168
+ readonly id: "Int";
169
+ readonly title: "String";
170
+ };
171
+ readonly relations: {
172
+ readonly _M2M_NC: {
173
+ readonly id: ["B"];
174
+ };
175
+ };
176
+ };
177
+ readonly MMM_Category: {
178
+ readonly fields: {
179
+ readonly id: "Int";
180
+ readonly name: "String";
181
+ };
182
+ readonly relations: {
183
+ readonly _M2M_NC_M1: {
184
+ readonly id: ["A"];
185
+ };
186
+ readonly _M2M_NC_M2: {
187
+ readonly id: ["A"];
188
+ };
189
+ };
190
+ };
191
+ readonly _M2M_NC_M1: {
192
+ readonly fields: {
193
+ readonly A: "Int";
194
+ readonly B: "Int";
195
+ };
196
+ readonly relations: {
197
+ readonly MMM_Category: {
198
+ readonly A: ["id"];
199
+ };
200
+ readonly MMM_Post: {
201
+ readonly B: ["id"];
202
+ };
203
+ };
204
+ };
205
+ readonly _M2M_NC_M2: {
206
+ readonly fields: {
207
+ readonly A: "Int";
208
+ readonly B: "Int";
209
+ };
210
+ readonly relations: {
211
+ readonly MMM_Category: {
212
+ readonly A: ["id"];
213
+ };
214
+ readonly MMM_Post: {
215
+ readonly B: ["id"];
216
+ };
217
+ };
218
+ };
219
+ readonly MMM_Post: {
220
+ readonly fields: {
221
+ readonly id: "Int";
222
+ readonly title: "String";
223
+ };
224
+ readonly relations: {
225
+ readonly _M2M_NC_M1: {
226
+ readonly id: ["B"];
227
+ };
228
+ readonly _M2M_NC_M2: {
229
+ readonly id: ["B"];
230
+ };
231
+ };
232
+ };
233
+ };
234
+ type TDB = typeof DB;
235
+ type DeepWriteable<T> = {
236
+ -readonly [P in keyof T]: DeepWriteable<T[P]>;
237
+ };
238
+ type _db = DeepWriteable<TDB>;
239
+ type DATABASE = {
240
+ [k in keyof _db]: {
241
+ table: k;
242
+ fields: {
243
+ [f in keyof _db[k]["fields"]]: StrTypeToTSType<_db[k]["fields"][f]>;
244
+ };
245
+ relations: _db[k]["relations"];
246
+ };
247
+ }[keyof TDB];
248
+ type JSONPrimitive = string | number | boolean | null;
249
+ type JSONValue = JSONPrimitive | JSONObject | JSONArray;
250
+ type JSONObject = {
251
+ [member: string]: JSONValue;
252
+ };
253
+ type JSONArray = Array<JSONValue>;
254
+ type StrTypeToTSType<str> = str extends string ? (GetTSType<RemoveNullChar<str>> | IsNullable<str>) : never;
255
+ type GetTSType<str extends string> = str extends `String` ? string : str extends `BigInt` ? bigint : str extends `Int` ? number : str extends `Float` ? number : str extends `Decimal` ? number : str extends `Boolean` ? boolean : str extends `DateTime` ? Date : str extends `Bytes` ? Buffer : str extends `Json` ? JSONValue : "Unknown type";
256
+ type IsNullable<str extends string> = str extends `?${string}` ? null : never;
257
+ type RemoveNullChar<str extends string> = str extends `?${infer s}` ? s : str;
258
+ type DBType = Record<string, {
259
+ fields: Record<string, string>;
260
+ relations: Record<string, Record<string, Array<string>>>;
261
+ }>;
262
+ type Filter<a, b> = a extends b ? a : never;
263
+ type IsString<T> = T extends string ? T : never;
264
+ type ValidSelect<Tables extends Array<TTables>> = "*" | GetOtherColumns<Tables>;
265
+ type GetOtherColumns<Tables extends Array<TTables>> = Tables extends [infer T extends TTables, ...infer R extends Array<TTables>] ? GetColsBaseTable<T> | GetJoinCols<R[number]> : never;
266
+ type TTables = DATABASE["table"];
267
+ type TArrSources = [TTables, ...Array<TTables>];
268
+ type ClauseType = Array<string | WhereCriteria<TArrSources, Record<string, any>>>;
269
+ type Values = {
270
+ database: TTables;
271
+ selectDistinct?: true;
272
+ selects: Array<string>;
273
+ tables?: Array<{
274
+ table: TTables;
275
+ local: string;
276
+ remote: string;
277
+ }>;
278
+ limit?: number;
279
+ offset?: number;
280
+ where?: ClauseType;
281
+ having?: ClauseType;
282
+ groupBy?: Array<string>;
283
+ orderBy?: Array<`${string}${"" | " DESC" | " ASC"}`>;
284
+ };
285
+ declare class _fRun<TSources extends TArrSources, TFields extends TFieldsType, TSelectRT extends Record<string, any> = {}> {
286
+ protected db: PrismaClient;
287
+ protected values: Values;
288
+ constructor(db: PrismaClient, values: Values);
289
+ run(): Prisma.PrismaPromise<Array<TSelectRT>>;
290
+ getTables(): TSources;
291
+ getFields(): TFields;
292
+ getSQL(formatted?: boolean): string;
293
+ }
294
+ declare class _fOffset<TSources extends TArrSources, TFields extends TFieldsType, TSelectRT extends Record<string, any> = {}> extends _fRun<TSources, TFields, TSelectRT> {
295
+ offset(offset: number): _fRun<TSources, TFields, TSelectRT>;
296
+ }
297
+ declare class _fLimit<TSources extends TArrSources, TFields extends TFieldsType, TSelectRT extends Record<string, any> = {}> extends _fRun<TSources, TFields, TSelectRT> {
298
+ limit(limit: number): _fOffset<TSources, TFields, TSelectRT>;
299
+ }
300
+ type OrderBy<Tables extends TArrSources> = Tables extends [infer T extends TTables, ...infer R extends Array<TTables>] ? GetColsBaseTable<T> | GetJoinCols<R[number]> : never;
301
+ declare class _fOrderBy<TSources extends TArrSources, TFields extends TFieldsType, TSelectRT extends Record<string, any> = {}> extends _fLimit<TSources, TFields, TSelectRT> {
302
+ orderBy(orderBy: Array<`${OrderBy<TSources>}${"" | " DESC" | " ASC"}`>): _fLimit<TSources, TFields, TSelectRT>;
303
+ }
304
+ type MergeItems<Field extends string, TSources extends TArrSources, TFields extends TFieldsType, IncTName extends boolean = false, TTables = TSources[number]> = Field extends "*" ? Prettify<IterateTables<TSources, TFields, IncTName>> : Field extends `${infer T extends TTables}.${infer F extends string}` ? Pick<TFields[T], F> : Pick<TFields[TSources[0]], Field>;
305
+ type IterateTables<Tables extends Array<TTables>, TFields extends TFieldsType, IncTName extends boolean, acc extends Record<string, any> = {}> = Tables extends [infer T extends TTables, ...infer Rest extends Array<TTables>] ? [IncTName] extends [false] ? IterateTables<Rest, TFields, IncTName, acc & TFields[T]> : IterateTables<Rest, TFields, IncTName, acc & IterateTablesFromFields<T, TFields[T], IncTName>> : acc;
306
+ type GenName<T extends string, F extends unknown, IncName extends boolean> = F extends string ? [IncName] extends [false] ? F : `${T}.${F}` : never;
307
+ type IterateTablesFromFields<Table extends TTables, TFields extends Record<string, string>, IncTName extends boolean> = {
308
+ [f in keyof TFields as GenName<Table, f, IncTName>]: TFields[f];
309
+ };
310
+ declare class _fSelect<TSources extends TArrSources, TFields extends TFieldsType, TSelectRT extends Record<string, any> = {}> extends _fOrderBy<TSources, TFields, TSelectRT> {
311
+ select<TSelect extends ValidSelect<TSources>>(select: TSelect): _fSelect<TSources, TFields, TSelectRT & MergeItems<TSelect, TSources, TFields, false, TSources[number]> extends infer T ? { [K in keyof T]: (TSelectRT & MergeItems<TSelect, TSources, TFields, false, TSources[number]>)[K]; } : never>;
312
+ }
313
+ type CountKeys<T extends Array<string>, acc extends Array<true> = []> = T extends [string, ...infer R extends Array<string>] ? CountKeys<R, [...acc, true]> : acc["length"];
314
+ declare class _fSelectDistinct<TSources extends TArrSources, TFields extends TFieldsType, TSelectRT extends Record<string, any> = {}> extends _fSelect<TSources, TFields, TSelectRT> {
315
+ selectDistinct(): _fSelect<TSources, TFields, TSelectRT>;
316
+ selectAll<TableCount = CountKeys<TSources>>(): _fOrderBy<TSources, TFields, IterateTables<TSources, TFields, TableCount extends 1 ? false : true, {}> extends infer T ? { [K in keyof T]: IterateTables<TSources, TFields, TableCount extends 1 ? false : true, {}>[K]; } : never>;
317
+ }
318
+ declare class _fHaving<TSources extends TArrSources, TFields extends TFieldsType> extends _fSelectDistinct<TSources, TFields> {
319
+ having<const TCriteria extends WhereCriteria<TSources, TFields>>(criteria: TCriteria): _fSelectDistinct<TSources, TFields, {}>;
320
+ }
321
+ declare class _fGroupBy<TSources extends TArrSources, TFields extends TFieldsType> extends _fHaving<TSources, TFields> {
322
+ groupBy<TSelect extends GetOtherColumns<TSources>>(groupBy: Array<TSelect>): _fHaving<TSources, TFields>;
323
+ }
324
+ type OptionalRecord<K extends PropertyKey, V> = {
325
+ [key in K]?: V;
326
+ };
327
+ type OptionalObject<K extends Record<PropertyKey, unknown>> = {
328
+ [key in keyof K]?: K[key];
329
+ };
330
+ type COND_NUMERIC<key extends PropertyKey, keyType> = OptionalRecord<key, keyType> | OptionalRecord<key, {
331
+ op: 'IN' | 'NOT IN';
332
+ values: Array<keyType>;
333
+ }> | OptionalRecord<key, {
334
+ op: 'BETWEEN';
335
+ values: [keyType, keyType];
336
+ }> | OptionalRecord<key, {
337
+ op: '>' | '>=' | '<' | '<=' | '!=';
338
+ value: keyType;
339
+ }>;
340
+ type COND_STRING<key extends PropertyKey> = OptionalRecord<key, string> | OptionalRecord<key, {
341
+ op: 'IN' | 'NOT IN';
342
+ values: Array<string>;
343
+ }> | OptionalRecord<key, {
344
+ op: 'LIKE' | 'NOT LIKE';
345
+ value: string;
346
+ }> | OptionalRecord<key, {
347
+ op: '!=';
348
+ value: string;
349
+ }>;
350
+ type COND_DATETIME<key extends PropertyKey, keyType> = OptionalRecord<key, keyType> | OptionalRecord<key, {
351
+ op: 'IN' | 'NOT IN';
352
+ values: Array<keyType>;
353
+ }> | OptionalRecord<key, {
354
+ op: 'BETWEEN';
355
+ values: [keyType, keyType];
356
+ }> | OptionalRecord<key, {
357
+ op: '>' | '>=' | '<' | '<=' | '!=';
358
+ value: keyType;
359
+ }>;
360
+ type COND_BOOLEAN<key extends PropertyKey, keyType> = OptionalRecord<key, keyType> | OptionalRecord<key, {
361
+ op: '!=';
362
+ value: keyType;
363
+ }>;
364
+ type COND_NULL<key extends PropertyKey, keyType> = keyType extends null ? OptionalRecord<key, {
365
+ op: 'IS NULL' | 'IS NOT NULL';
366
+ }> : never;
367
+ type SQLCondition<T> = Prettify<{
368
+ [K in keyof T]?: (Exclude<T[K], null> extends number ? COND_NUMERIC<K, Exclude<T[K], null>> : Exclude<T[K], null> extends bigint ? COND_NUMERIC<K, Exclude<T[K], null>> : Exclude<T[K], null> extends string ? COND_STRING<K> : Exclude<T[K], null> extends boolean ? COND_BOOLEAN<K, Exclude<T[K], null>> : Exclude<T[K], null> extends Date ? COND_DATETIME<K, Exclude<T[K], null>> : "Unsupported Data Type") | COND_NULL<K, T[K]>;
369
+ }[keyof T]>;
370
+ type TableFieldType<Table extends string, Fields extends Record<string, any>> = {
371
+ [f in keyof Fields as CombineToString<f, Table>]: Fields[f];
372
+ };
373
+ type LogicalOperator = '$AND' | '$OR' | '$NOT' | "$NOR";
374
+ type WhereCriteria<T extends TArrSources, TFields extends TFieldsType, F = WhereCriteria_Fields<T, TFields>> = F & {
375
+ [k in LogicalOperator]?: [WhereCriteria<T, TFields, F>, ...Array<WhereCriteria<T, TFields, F>>];
376
+ };
377
+ type WhereCriteria_Fields<T extends Array<string>, TFields extends TFieldsType, acc = {}> = T extends readonly [infer HEAD, ...infer Rest] ? HEAD extends string ? Rest extends Array<string> ? WhereCriteria_Fields<Rest, TFields, OptionalObject<acc & (TableFieldType<HEAD, TFields[HEAD]> | SQLCondition<TableFieldType<HEAD, TFields[HEAD]>>)>> : WhereCriteria_Fields<[], TFields, OptionalObject<acc & (TableFieldType<HEAD, TFields[HEAD]> | SQLCondition<TableFieldType<HEAD, TFields[HEAD]>>)>> : never : acc;
378
+ type OnlyNull<T, R> = T extends null ? R : never;
379
+ type FindColsWithNull<TFields extends TFieldsType> = Prettify<{
380
+ [Table in keyof TFields]: {
381
+ [Field in keyof TFields[Table]]: OnlyNull<TFields[Table][Field], CombineToString<Field, Table>>;
382
+ }[keyof TFields[Table]];
383
+ }[keyof TFields]>;
384
+ type NO_START_WITH_WHERE<RAW extends string> = Uppercase<TRIM<RAW>> extends `WHERE ${string}` ? "Please do not start with `WHERE`" : RAW;
385
+ type TRIM<S extends string> = S extends ` ${infer S2}` ? TRIM<S2> : S;
386
+ declare class _fWhere<TSources extends TArrSources, TFields extends TFieldsType> extends _fGroupBy<TSources, TFields> {
387
+ whereNotNull<const TColWithNull extends FindColsWithNull<TFields>>(col: TColWithNull): _fWhere<TSources, TColWithNull extends `${infer table}.${infer col}` ? Omit<TFields, table> & (Record<table, Omit<Pick<TFields, table>[table], col> & Record<col, Exclude<Pick<TFields, table>[table][col], null>>> extends infer T_1 ? { [K_1 in keyof T_1]: Record<table, Omit<Pick<TFields, table>[table], col> & Record<col, Exclude<Pick<TFields, table>[table][col], null>>>[K_1]; } : never) extends infer T ? { [K in keyof T]: (Omit<TFields, table> & (Record<table, Omit<Pick<TFields, table>[table], col> & Record<col, Exclude<Pick<TFields, table>[table][col], null>>> extends infer T_1 ? { [K_1 in keyof T_1]: Record<table, Omit<Pick<TFields, table>[table], col> & Record<col, Exclude<Pick<TFields, table>[table][col], null>>>[K_1]; } : never))[K]; } : never : never>;
388
+ whereIsNull<const TColWithNull extends FindColsWithNull<TFields>>(col: TColWithNull): _fWhere<TSources, TColWithNull extends `${infer table}.${infer col}` ? Omit<TFields, table> & (Record<table, Omit<Pick<TFields, table>[table], col> & Record<col, null>> extends infer T_1 ? { [K_1 in keyof T_1]: Record<table, Omit<Pick<TFields, table>[table], col> & Record<col, null>>[K_1]; } : never) extends infer T ? { [K in keyof T]: (Omit<TFields, table> & (Record<table, Omit<Pick<TFields, table>[table], col> & Record<col, null>> extends infer T_1 ? { [K_1 in keyof T_1]: Record<table, Omit<Pick<TFields, table>[table], col> & Record<col, null>>[K_1]; } : never))[K]; } : never : never>;
389
+ where<const TCriteria extends WhereCriteria<TSources, TFields>>(criteria: TCriteria): _fGroupBy<TSources, TFields>;
390
+ whereRaw<RAW extends string>(where: NO_START_WITH_WHERE<RAW>): _fGroupBy<TSources, TFields>;
391
+ }
392
+ type GetFieldsFromTable<TDBBase extends TTables> = Extract<DATABASE, {
393
+ table: TDBBase;
394
+ }>["fields"];
395
+ type GetColsBaseTable<TDBBase extends TTables> = TDBBase extends any ? keyof GetFieldsFromTable<TDBBase> : never;
396
+ type GetJoinCols<TDBBase extends TTables> = TDBBase extends any ? IterateFields<TDBBase, IsString<GetColsBaseTable<TDBBase>>> : never;
397
+ type IterateFields<TDBBase extends TTables, F extends string> = `${TDBBase}.${F}`;
398
+ type Relations<Table extends TTables> = Extract<DATABASE, {
399
+ table: Table;
400
+ }>["relations"];
401
+ type AvailableJoins<Tables extends Array<TTables>, acc extends TTables = never> = Tables extends [infer T extends TTables, ...infer Rest extends Array<TTables>] ? AvailableJoins<Rest, acc | keyof Relations<T>> : acc;
402
+ type SafeJoins<TNewJoin extends TTables, TJoins extends Array<TTables>, TRelations = Relations<TNewJoin>> = {
403
+ [k in keyof TRelations as Filter<k, TJoins[number]>]: TRelations[k];
404
+ };
405
+ type CombineToString<A extends unknown, T extends unknown> = A extends string ? T extends string ? `${T}.${A}` : never : never;
406
+ type GetUnionOfRelations<TSafe> = {
407
+ [T in keyof TSafe]: {
408
+ [TLocal in keyof TSafe[T]]: [
409
+ TLocal,
410
+ T extends string ? TSafe[T][TLocal] extends Array<string> ? CombineToString<TSafe[T][TLocal][number], T> : never : never
411
+ ];
412
+ }[keyof TSafe[T]];
413
+ }[keyof TSafe];
414
+ type ValidStringTuple<T> = T extends [string, string] ? T : never;
415
+ type find<T extends [string, string], toFind extends string> = T extends [infer col1, infer col2] ? col1 extends toFind ? col2 : never : never;
416
+ type RemoveNullable<T extends string> = T extends `?${infer R}` ? R : T;
417
+ type SwapKeysAndValues<T extends Record<string, any>> = {
418
+ [K in keyof T as RemoveNullable<T[K]>]: K;
419
+ };
420
+ type Prettify<T> = {
421
+ [K in keyof T]: T[K];
422
+ } & {};
423
+ type FieldsByTableByType = Prettify<{
424
+ [Table in TTables]: SwapKeysAndValues<_db[Table]["fields"]>;
425
+ }>;
426
+ type GetTypes = {
427
+ [Type in keyof FieldsByTableByType as keyof FieldsByTableByType[Type]]: {};
428
+ };
429
+ type FieldsByTypeByTable = Prettify<{
430
+ [Type in keyof GetTypes]: {
431
+ [Table in keyof FieldsByTableByType as [FieldsByTableByType[Table][Filter<keyof FieldsByTableByType[Table], Type>]] extends [never] ? never : Table]: FieldsByTableByType[Table][Filter<keyof FieldsByTableByType[Table], Type>];
432
+ };
433
+ }>;
434
+ type GetColumnType<Table extends TTables, Col1 extends keyof _db[Table]["fields"]> = RemoveNullChar<IsString<_db[Table]["fields"][Col1]>>;
435
+ type GetJoinOnColsType<Type extends string, TSources extends Array<TTables>> = GetJoinColsType<TSources[number], Type>;
436
+ type GetColsFromTableType<TDBBase extends TTables, Type extends string> = FieldsByTypeByTable[Loop<keyof FieldsByTypeByTable, Type>][TDBBase];
437
+ type Loop<Keys extends string, Type extends string> = Keys extends Type ? Type : never;
438
+ type GetJoinColsType<TDBBase extends TTables, Type extends string> = IterateFields<TDBBase, IsString<GetColsFromTableType<TDBBase, Type>>>;
439
+ type TFieldsType = Record<string, Record<string, any>>;
440
+ declare class _fJoin<TSources extends TArrSources, TFields extends TFieldsType> extends _fWhere<TSources, TFields> {
441
+ join<Table extends AvailableJoins<TSources>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<SafeJoins<Table, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: Table, field: TCol1, reference: find<TJoinCols, TCol1>): _fJoin<[...TSources, Table], TFields & Record<Table, GetFieldsFromTable<Table>> extends infer T ? { [K in keyof T]: (TFields & Record<Table, GetFieldsFromTable<Table>>)[K]; } : never>;
442
+ joinUnsafeTypeEnforced<Table extends AvailableJoins<TSources>, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: Table, field: TCol1, reference: TCol2): _fJoin<[...TSources, Table], TFields & Record<Table, GetFieldsFromTable<Table>>>;
443
+ joinUnsafeIgnoreType<Table extends AvailableJoins<TSources>, TCol2 extends GetJoinCols<TSources[number]>>(table: Table, field: GetColsBaseTable<Table>, reference: TCol2): _fJoin<[...TSources, Table], TFields & Record<Table, GetFieldsFromTable<Table>>>;
444
+ }
445
+ declare const _default: {
446
+ client: {
447
+ $from<T extends TTables>(table: T): _fJoin<[T], Record<T, GetFieldsFromTable<T>>>;
448
+ };
449
+ };
450
+
451
+ export { type DBType, type GetUnionOfRelations, type JSONArray, type JSONObject, type JSONPrimitive, type JSONValue, type RemoveNullChar, type SafeJoins, type TTables, _default as default };