arkormx 1.3.4 → 2.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/cli.mjs +16 -2
- package/dist/index.cjs +2767 -1504
- package/dist/index.d.cts +579 -174
- package/dist/index.d.mts +579 -174
- package/dist/index.mjs +2454 -1196
- package/package.json +7 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,258 @@
|
|
|
1
|
+
import { Kysely, Transaction } from "kysely";
|
|
1
2
|
import { Command } from "@h3ravel/musket";
|
|
2
3
|
import { Collection } from "@h3ravel/collect.js";
|
|
3
4
|
import { PrismaClient } from "@prisma/client";
|
|
4
5
|
|
|
5
|
-
//#region src/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
//#region src/types/core.d.ts
|
|
7
|
+
type CastType = 'string' | 'number' | 'boolean' | 'date' | 'json' | 'array';
|
|
8
|
+
interface CastHandler<T = unknown> {
|
|
9
|
+
get: (value: unknown) => T;
|
|
10
|
+
set: (value: unknown) => unknown;
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
type CastDefinition = CastType | CastHandler;
|
|
13
|
+
type CastMap = Record<string, CastDefinition>;
|
|
14
|
+
type PrismaClientLike = PrismaClient | Record<string, unknown>;
|
|
15
|
+
interface PrismaTransactionOptions {
|
|
16
|
+
maxWait?: number;
|
|
17
|
+
timeout?: number;
|
|
18
|
+
isolationLevel?: string;
|
|
19
|
+
}
|
|
20
|
+
type PrismaTransactionCallback<TResult = unknown> = (client: PrismaClientLike) => TResult | Promise<TResult>;
|
|
21
|
+
interface PrismaTransactionCapableClient {
|
|
22
|
+
$transaction: <TResult>(callback: PrismaTransactionCallback<TResult>, options?: PrismaTransactionOptions) => Promise<TResult>;
|
|
23
|
+
}
|
|
24
|
+
type ClientResolver = PrismaClientLike | (() => PrismaClientLike);
|
|
25
|
+
interface ArkormConfig {
|
|
26
|
+
/**
|
|
27
|
+
* @property prisma A Prisma client instance or a function that returns a Prisma client instance.
|
|
28
|
+
*/
|
|
29
|
+
prisma: ClientResolver;
|
|
30
|
+
/**
|
|
31
|
+
* @property pagination Configuration options related to pagination behavior and URL generation.
|
|
32
|
+
*/
|
|
33
|
+
pagination?: {
|
|
34
|
+
urlDriver?: PaginationURLDriverFactory;
|
|
35
|
+
resolveCurrentPage?: PaginationCurrentPageResolver;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @property paths Optional custom paths for various generated files.
|
|
39
|
+
*/
|
|
40
|
+
paths?: {
|
|
41
|
+
/**
|
|
42
|
+
* @property stubs Optional custom path for stub files used in code generation.
|
|
43
|
+
*/
|
|
44
|
+
stubs?: string;
|
|
45
|
+
/**
|
|
46
|
+
* @property seeders Optional custom path for seeder files.
|
|
47
|
+
*/
|
|
48
|
+
seeders?: string;
|
|
49
|
+
/**
|
|
50
|
+
* @property models Optional custom path for model files.
|
|
51
|
+
*/
|
|
52
|
+
models?: string;
|
|
53
|
+
/**
|
|
54
|
+
* @property migrations Optional custom path for migration files.
|
|
55
|
+
*/
|
|
56
|
+
migrations?: string;
|
|
57
|
+
/**
|
|
58
|
+
* @property factories Optional custom path for factory files.
|
|
59
|
+
*/
|
|
60
|
+
factories?: string;
|
|
61
|
+
/**
|
|
62
|
+
* @property buildOutput Optional custom path for the development output directory.
|
|
63
|
+
*/
|
|
64
|
+
buildOutput?: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @property outputExt Optional file extension for generated files, either 'ts' or 'js'.
|
|
68
|
+
*/
|
|
69
|
+
outputExt?: 'ts' | 'js';
|
|
16
70
|
}
|
|
71
|
+
interface GetUserConfig {
|
|
72
|
+
/**
|
|
73
|
+
* Get the user-provided ArkORM configuration.
|
|
74
|
+
*/
|
|
75
|
+
(): Partial<ArkormConfig>;
|
|
76
|
+
/**
|
|
77
|
+
* Get a specific user configuration value
|
|
78
|
+
* @param key Optional specific configuration key to retrieve
|
|
79
|
+
*/
|
|
80
|
+
<K extends keyof ArkormConfig>(key: K): Partial<ArkormConfig>[K];
|
|
81
|
+
}
|
|
82
|
+
interface PaginationMeta {
|
|
83
|
+
total: number;
|
|
84
|
+
perPage: number;
|
|
85
|
+
currentPage: number;
|
|
86
|
+
lastPage: number;
|
|
87
|
+
from: number | null;
|
|
88
|
+
to: number | null;
|
|
89
|
+
}
|
|
90
|
+
interface SimplePaginationMeta {
|
|
91
|
+
perPage: number;
|
|
92
|
+
currentPage: number;
|
|
93
|
+
from: number | null;
|
|
94
|
+
to: number | null;
|
|
95
|
+
hasMorePages: boolean;
|
|
96
|
+
}
|
|
97
|
+
interface PaginationOptions {
|
|
98
|
+
path?: string;
|
|
99
|
+
query?: Record<string, string | number | boolean | null | undefined>;
|
|
100
|
+
fragment?: string;
|
|
101
|
+
pageName?: string;
|
|
102
|
+
}
|
|
103
|
+
type PaginationCurrentPageResolver = (pageName: string, options: PaginationOptions) => number | undefined;
|
|
104
|
+
interface PaginationURLDriver {
|
|
105
|
+
getPageName: () => string;
|
|
106
|
+
url: (page: number) => string;
|
|
107
|
+
}
|
|
108
|
+
type PaginationURLDriverFactory = (options: PaginationOptions) => PaginationURLDriver;
|
|
109
|
+
interface PrismaFindManyArgsLike {
|
|
110
|
+
where?: unknown;
|
|
111
|
+
include?: unknown;
|
|
112
|
+
orderBy?: unknown;
|
|
113
|
+
select?: unknown;
|
|
114
|
+
skip?: number;
|
|
115
|
+
take?: number;
|
|
116
|
+
}
|
|
117
|
+
type PrismaLikeSortOrder = 'asc' | 'desc';
|
|
118
|
+
interface PrismaLikeWhereInput {
|
|
119
|
+
AND?: PrismaLikeWhereInput[];
|
|
120
|
+
OR?: PrismaLikeWhereInput[];
|
|
121
|
+
NOT?: PrismaLikeWhereInput | PrismaLikeWhereInput[];
|
|
122
|
+
[key: string]: unknown;
|
|
123
|
+
}
|
|
124
|
+
type PrismaLikeOrderBy = Record<string, PrismaLikeSortOrder> | Record<string, PrismaLikeSortOrder>[];
|
|
125
|
+
interface PrismaLikeSelect {
|
|
126
|
+
[key: string]: boolean | {
|
|
127
|
+
select?: PrismaLikeSelect;
|
|
128
|
+
include?: PrismaLikeInclude;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
interface PrismaLikeInclude {
|
|
132
|
+
[key: string]: boolean | {
|
|
133
|
+
where?: PrismaLikeWhereInput;
|
|
134
|
+
orderBy?: PrismaLikeOrderBy;
|
|
135
|
+
select?: PrismaLikeSelect;
|
|
136
|
+
include?: PrismaLikeInclude;
|
|
137
|
+
skip?: number;
|
|
138
|
+
take?: number;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
type EagerLoadConstraint = (query: unknown) => unknown;
|
|
142
|
+
type EagerLoadMap = Record<string, EagerLoadConstraint | undefined>;
|
|
143
|
+
interface SoftDeleteConfig {
|
|
144
|
+
enabled: boolean;
|
|
145
|
+
column: string;
|
|
146
|
+
}
|
|
147
|
+
interface PrismaDelegateLike {
|
|
148
|
+
findMany: (args?: any) => Promise<unknown[]>;
|
|
149
|
+
findFirst: (args?: any) => Promise<unknown | null>;
|
|
150
|
+
create: (args: any) => Promise<unknown>;
|
|
151
|
+
update: (args: any) => Promise<unknown>;
|
|
152
|
+
delete: (args: any) => Promise<unknown>;
|
|
153
|
+
count: (args?: any) => Promise<number>;
|
|
154
|
+
}
|
|
155
|
+
type FallbackIfUnknownOrNever<TValue, TFallback> = [TValue] extends [never] ? TFallback : unknown extends TValue ? TFallback : TValue;
|
|
156
|
+
type DelegateFindManyArgs<TDelegate extends PrismaDelegateLike> = FallbackIfUnknownOrNever<NonNullable<Parameters<TDelegate['findMany']>[0]>, PrismaFindManyArgsLike>;
|
|
157
|
+
type DelegateWhere<TDelegate extends PrismaDelegateLike> = DelegateFindManyArgs<TDelegate> extends {
|
|
158
|
+
where?: infer TWhere;
|
|
159
|
+
} ? FallbackIfUnknownOrNever<TWhere, PrismaLikeWhereInput> : PrismaLikeWhereInput;
|
|
160
|
+
type DelegateInclude<TDelegate extends PrismaDelegateLike> = DelegateFindManyArgs<TDelegate> extends {
|
|
161
|
+
include?: infer TInclude;
|
|
162
|
+
} ? FallbackIfUnknownOrNever<TInclude, PrismaLikeInclude> : PrismaLikeInclude;
|
|
163
|
+
type DelegateOrderBy<TDelegate extends PrismaDelegateLike> = DelegateFindManyArgs<TDelegate> extends {
|
|
164
|
+
orderBy?: infer TOrderBy;
|
|
165
|
+
} ? FallbackIfUnknownOrNever<TOrderBy, PrismaLikeOrderBy> : PrismaLikeOrderBy;
|
|
166
|
+
type DelegateSelect<TDelegate extends PrismaDelegateLike> = DelegateFindManyArgs<TDelegate> extends {
|
|
167
|
+
select?: infer TSelect;
|
|
168
|
+
} ? FallbackIfUnknownOrNever<TSelect, PrismaLikeSelect> : PrismaLikeSelect;
|
|
169
|
+
type DelegateCreateData<TDelegate extends PrismaDelegateLike> = Parameters<TDelegate['create']>[0] extends {
|
|
170
|
+
data: infer TData;
|
|
171
|
+
} ? TData : Record<string, unknown>;
|
|
172
|
+
type DelegateUpdateArgs<TDelegate extends PrismaDelegateLike> = Parameters<TDelegate['update']>[0];
|
|
173
|
+
type DelegateUpdateData<TDelegate extends PrismaDelegateLike> = DelegateUpdateArgs<TDelegate> extends {
|
|
174
|
+
data: infer TData;
|
|
175
|
+
} ? FallbackIfUnknownOrNever<TData, Record<string, unknown>> : Record<string, unknown>;
|
|
176
|
+
type DelegateRow<TDelegate extends PrismaDelegateLike> = Exclude<Awaited<ReturnType<TDelegate['findFirst']>>, null>;
|
|
177
|
+
type Serializable = Record<string, unknown>;
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/types/metadata.d.ts
|
|
180
|
+
type ColumnMap = Record<string, string>;
|
|
181
|
+
interface ModelMetadata {
|
|
182
|
+
table: string;
|
|
183
|
+
primaryKey: string;
|
|
184
|
+
columns: ColumnMap;
|
|
185
|
+
softDelete: SoftDeleteConfig;
|
|
186
|
+
}
|
|
187
|
+
type RelationMetadataType = 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany' | 'hasOneThrough' | 'hasManyThrough' | 'morphOne' | 'morphMany' | 'morphToMany';
|
|
188
|
+
interface BaseRelationMetadata {
|
|
189
|
+
type: RelationMetadataType;
|
|
190
|
+
relatedModel: RelationshipModelStatic;
|
|
191
|
+
}
|
|
192
|
+
interface HasOneRelationMetadata extends BaseRelationMetadata {
|
|
193
|
+
type: 'hasOne';
|
|
194
|
+
foreignKey: string;
|
|
195
|
+
localKey: string;
|
|
196
|
+
}
|
|
197
|
+
interface HasManyRelationMetadata extends BaseRelationMetadata {
|
|
198
|
+
type: 'hasMany';
|
|
199
|
+
foreignKey: string;
|
|
200
|
+
localKey: string;
|
|
201
|
+
}
|
|
202
|
+
interface BelongsToRelationMetadata extends BaseRelationMetadata {
|
|
203
|
+
type: 'belongsTo';
|
|
204
|
+
foreignKey: string;
|
|
205
|
+
ownerKey: string;
|
|
206
|
+
}
|
|
207
|
+
interface BelongsToManyRelationMetadata extends BaseRelationMetadata {
|
|
208
|
+
type: 'belongsToMany';
|
|
209
|
+
throughTable: string;
|
|
210
|
+
foreignPivotKey: string;
|
|
211
|
+
relatedPivotKey: string;
|
|
212
|
+
parentKey: string;
|
|
213
|
+
relatedKey: string;
|
|
214
|
+
}
|
|
215
|
+
interface HasOneThroughRelationMetadata extends BaseRelationMetadata {
|
|
216
|
+
type: 'hasOneThrough';
|
|
217
|
+
throughTable: string;
|
|
218
|
+
firstKey: string;
|
|
219
|
+
secondKey: string;
|
|
220
|
+
localKey: string;
|
|
221
|
+
secondLocalKey: string;
|
|
222
|
+
}
|
|
223
|
+
interface HasManyThroughRelationMetadata extends BaseRelationMetadata {
|
|
224
|
+
type: 'hasManyThrough';
|
|
225
|
+
throughTable: string;
|
|
226
|
+
firstKey: string;
|
|
227
|
+
secondKey: string;
|
|
228
|
+
localKey: string;
|
|
229
|
+
secondLocalKey: string;
|
|
230
|
+
}
|
|
231
|
+
interface MorphOneRelationMetadata extends BaseRelationMetadata {
|
|
232
|
+
type: 'morphOne';
|
|
233
|
+
morphName: string;
|
|
234
|
+
morphIdColumn: string;
|
|
235
|
+
morphTypeColumn: string;
|
|
236
|
+
localKey: string;
|
|
237
|
+
}
|
|
238
|
+
interface MorphManyRelationMetadata extends BaseRelationMetadata {
|
|
239
|
+
type: 'morphMany';
|
|
240
|
+
morphName: string;
|
|
241
|
+
morphIdColumn: string;
|
|
242
|
+
morphTypeColumn: string;
|
|
243
|
+
localKey: string;
|
|
244
|
+
}
|
|
245
|
+
interface MorphToManyRelationMetadata extends BaseRelationMetadata {
|
|
246
|
+
type: 'morphToMany';
|
|
247
|
+
throughTable: string;
|
|
248
|
+
morphName: string;
|
|
249
|
+
morphIdColumn: string;
|
|
250
|
+
morphTypeColumn: string;
|
|
251
|
+
relatedPivotKey: string;
|
|
252
|
+
parentKey: string;
|
|
253
|
+
relatedKey: string;
|
|
254
|
+
}
|
|
255
|
+
type RelationMetadata = HasOneRelationMetadata | HasManyRelationMetadata | BelongsToRelationMetadata | BelongsToManyRelationMetadata | HasOneThroughRelationMetadata | HasManyThroughRelationMetadata | MorphOneRelationMetadata | MorphManyRelationMetadata | MorphToManyRelationMetadata;
|
|
17
256
|
//#endregion
|
|
18
257
|
//#region src/types/factories.d.ts
|
|
19
258
|
type FactoryAttributes = Record<string, unknown>;
|
|
@@ -119,6 +358,28 @@ declare class ArkormCollection<T = any, X = T[]> extends Collection<T, X> {}
|
|
|
119
358
|
//#region src/types/relationship.d.ts
|
|
120
359
|
type RelationConstraint<TModel> = (query: QueryBuilder<TModel>) => QueryBuilder<TModel> | void;
|
|
121
360
|
type RelationDefaultValue<TParent, TRelated> = Partial<ModelAttributes<TRelated>> | TRelated | ((parent: TParent) => Partial<ModelAttributes<TRelated>> | TRelated);
|
|
361
|
+
interface RelationTableLookupSpec {
|
|
362
|
+
table: string;
|
|
363
|
+
where?: QueryCondition;
|
|
364
|
+
columns?: QuerySelectColumn[];
|
|
365
|
+
orderBy?: QueryOrderBy[];
|
|
366
|
+
limit?: number;
|
|
367
|
+
offset?: number;
|
|
368
|
+
}
|
|
369
|
+
interface RelationColumnLookupSpec {
|
|
370
|
+
lookup: RelationTableLookupSpec;
|
|
371
|
+
column: string;
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/relationship/RelationTableLoader.d.ts
|
|
375
|
+
declare class RelationTableLoader {
|
|
376
|
+
private readonly adapter;
|
|
377
|
+
constructor(adapter: DatabaseAdapter);
|
|
378
|
+
selectRows(spec: RelationTableLookupSpec): Promise<DatabaseRow[]>;
|
|
379
|
+
selectRow(spec: RelationTableLookupSpec): Promise<DatabaseRow | null>;
|
|
380
|
+
selectColumnValues(spec: RelationColumnLookupSpec): Promise<unknown[]>;
|
|
381
|
+
selectColumnValue(spec: RelationColumnLookupSpec): Promise<unknown | null>;
|
|
382
|
+
}
|
|
122
383
|
//#endregion
|
|
123
384
|
//#region src/relationship/Relation.d.ts
|
|
124
385
|
/**
|
|
@@ -129,6 +390,12 @@ type RelationDefaultValue<TParent, TRelated> = Partial<ModelAttributes<TRelated>
|
|
|
129
390
|
*/
|
|
130
391
|
declare abstract class Relation<TModel> {
|
|
131
392
|
protected constraint: RelationConstraint<TModel> | null;
|
|
393
|
+
protected getRelationAdapter(): DatabaseAdapter;
|
|
394
|
+
protected getRelatedModel(): {
|
|
395
|
+
getAdapter: () => DatabaseAdapter | undefined;
|
|
396
|
+
query: () => QueryBuilder<TModel>;
|
|
397
|
+
};
|
|
398
|
+
protected createRelationTableLoader(): RelationTableLoader;
|
|
132
399
|
/**
|
|
133
400
|
* Apply a constraint to the relationship query.
|
|
134
401
|
*
|
|
@@ -235,6 +502,7 @@ declare abstract class Relation<TModel> {
|
|
|
235
502
|
* @returns The query builder instance with the constraint applied, if any.
|
|
236
503
|
*/
|
|
237
504
|
protected applyConstraint(query: QueryBuilder<TModel>): QueryBuilder<TModel>;
|
|
505
|
+
abstract getMetadata(): RelationMetadata;
|
|
238
506
|
/**
|
|
239
507
|
* Build the underlying query for the relationship.
|
|
240
508
|
*
|
|
@@ -303,6 +571,7 @@ declare class BelongsToManyRelation<TParent, TRelated> extends Relation<TRelated
|
|
|
303
571
|
* @returns
|
|
304
572
|
*/
|
|
305
573
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
574
|
+
getMetadata(): BelongsToManyRelationMetadata;
|
|
306
575
|
/**
|
|
307
576
|
* Fetches the related models for this relationship.
|
|
308
577
|
*
|
|
@@ -354,6 +623,7 @@ declare class BelongsToRelation<TParent, TRelated> extends SingleResultRelation<
|
|
|
354
623
|
* @returns
|
|
355
624
|
*/
|
|
356
625
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
626
|
+
getMetadata(): BelongsToRelationMetadata;
|
|
357
627
|
/**
|
|
358
628
|
* Fetches the related models for this relationship.
|
|
359
629
|
*
|
|
@@ -383,6 +653,7 @@ declare class HasManyRelation<TParent, TRelated> extends Relation<TRelated> {
|
|
|
383
653
|
* @returns
|
|
384
654
|
*/
|
|
385
655
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
656
|
+
getMetadata(): HasManyRelationMetadata;
|
|
386
657
|
/**
|
|
387
658
|
* Fetches the related models for this relationship.
|
|
388
659
|
*
|
|
@@ -416,6 +687,7 @@ declare class HasManyThroughRelation<TParent, TRelated> extends Relation<TRelate
|
|
|
416
687
|
* @returns
|
|
417
688
|
*/
|
|
418
689
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
690
|
+
getMetadata(): HasManyThroughRelationMetadata;
|
|
419
691
|
/**
|
|
420
692
|
* Fetches the related models for this relationship.
|
|
421
693
|
*
|
|
@@ -445,6 +717,7 @@ declare class HasOneRelation<TParent, TRelated> extends SingleResultRelation<TPa
|
|
|
445
717
|
* @returns
|
|
446
718
|
*/
|
|
447
719
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
720
|
+
getMetadata(): HasOneRelationMetadata;
|
|
448
721
|
/**
|
|
449
722
|
* Fetches the related models for this relationship.
|
|
450
723
|
*
|
|
@@ -478,6 +751,7 @@ declare class HasOneThroughRelation<TParent, TRelated> extends SingleResultRelat
|
|
|
478
751
|
* @returns
|
|
479
752
|
*/
|
|
480
753
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
754
|
+
getMetadata(): HasOneThroughRelationMetadata;
|
|
481
755
|
/**
|
|
482
756
|
* Fetches the related models for this relationship.
|
|
483
757
|
*
|
|
@@ -507,6 +781,7 @@ declare class MorphManyRelation<TParent, TRelated> extends Relation<TRelated> {
|
|
|
507
781
|
* @returns
|
|
508
782
|
*/
|
|
509
783
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
784
|
+
getMetadata(): MorphManyRelationMetadata;
|
|
510
785
|
/**
|
|
511
786
|
* Fetches the related models for this relationship.
|
|
512
787
|
*
|
|
@@ -536,6 +811,7 @@ declare class MorphOneRelation<TParent, TRelated> extends SingleResultRelation<T
|
|
|
536
811
|
* @returns
|
|
537
812
|
*/
|
|
538
813
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
814
|
+
getMetadata(): MorphOneRelationMetadata;
|
|
539
815
|
/**
|
|
540
816
|
* Fetches the related models for this relationship.
|
|
541
817
|
*
|
|
@@ -568,6 +844,7 @@ declare class MorphToManyRelation<TParent, TRelated> extends Relation<TRelated>
|
|
|
568
844
|
* @returns
|
|
569
845
|
*/
|
|
570
846
|
getQuery(): Promise<QueryBuilder<TRelated>>;
|
|
847
|
+
getMetadata(): MorphToManyRelationMetadata;
|
|
571
848
|
/**
|
|
572
849
|
* Fetches the related models for this relationship.
|
|
573
850
|
*
|
|
@@ -685,8 +962,12 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
685
962
|
private static readonly lifecycleStates;
|
|
686
963
|
private static eventsSuppressed;
|
|
687
964
|
protected static factoryClass?: new () => ModelFactory<any, any>;
|
|
965
|
+
protected static adapter?: DatabaseAdapter;
|
|
688
966
|
protected static client: Record<string, unknown>;
|
|
689
967
|
protected static delegate: string;
|
|
968
|
+
protected static table?: string;
|
|
969
|
+
protected static primaryKey: string;
|
|
970
|
+
protected static columns: Record<string, string>;
|
|
690
971
|
protected static softDeletes: boolean;
|
|
691
972
|
protected static deletedAtColumn: string;
|
|
692
973
|
protected static globalScopes: Record<string, GlobalScope>;
|
|
@@ -707,6 +988,13 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
707
988
|
* @param client
|
|
708
989
|
*/
|
|
709
990
|
protected static setClient(client: Record<string, unknown>): void;
|
|
991
|
+
static setAdapter(adapter?: DatabaseAdapter): void;
|
|
992
|
+
static getTable(): string;
|
|
993
|
+
static getPrimaryKey(): string;
|
|
994
|
+
static getColumnMap(): Record<string, string>;
|
|
995
|
+
static getColumnName(attribute: string): string;
|
|
996
|
+
static getModelMetadata(): ModelMetadata;
|
|
997
|
+
static getRelationMetadata(name: string): RelationMetadata | null;
|
|
710
998
|
static setFactory<TFactory extends ModelFactory<any, any>>(factoryClass: new () => TFactory): void;
|
|
711
999
|
static factory<TFactory extends ModelFactory<any, any>>(count?: number): TFactory;
|
|
712
1000
|
/**
|
|
@@ -797,6 +1085,7 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
797
1085
|
* @returns
|
|
798
1086
|
*/
|
|
799
1087
|
static getDelegate<TDelegate extends PrismaDelegateLike = PrismaDelegateLike>(delegate?: string): TDelegate;
|
|
1088
|
+
static getAdapter(): DatabaseAdapter | undefined;
|
|
800
1089
|
/**
|
|
801
1090
|
* Get a new query builder instance for the model.
|
|
802
1091
|
*
|
|
@@ -1362,9 +1651,15 @@ declare class Paginator<T> {
|
|
|
1362
1651
|
* @since 0.1.0
|
|
1363
1652
|
*/
|
|
1364
1653
|
declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = PrismaDelegateLike> {
|
|
1365
|
-
private readonly delegate;
|
|
1366
1654
|
private readonly model;
|
|
1367
|
-
private readonly
|
|
1655
|
+
private readonly adapter?;
|
|
1656
|
+
private queryWhere?;
|
|
1657
|
+
private legacyWhere?;
|
|
1658
|
+
private queryRelationLoads?;
|
|
1659
|
+
private queryOrderBy?;
|
|
1660
|
+
private querySelect?;
|
|
1661
|
+
private offsetValue?;
|
|
1662
|
+
private limitValue?;
|
|
1368
1663
|
private readonly eagerLoads;
|
|
1369
1664
|
private includeTrashed;
|
|
1370
1665
|
private onlyTrashedRecords;
|
|
@@ -1374,10 +1669,9 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
1374
1669
|
/**
|
|
1375
1670
|
* Creates a new QueryBuilder instance.
|
|
1376
1671
|
*
|
|
1377
|
-
* @param delegate
|
|
1378
1672
|
* @param model
|
|
1379
1673
|
*/
|
|
1380
|
-
constructor(
|
|
1674
|
+
constructor(model: ModelStatic<TModel, TDelegate>, adapter?: DatabaseAdapter | undefined);
|
|
1381
1675
|
private resolvePaginationPage;
|
|
1382
1676
|
/**
|
|
1383
1677
|
* Adds a where clause to the query. Multiple calls to where will combine
|
|
@@ -1951,6 +2245,12 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
1951
2245
|
* @returns
|
|
1952
2246
|
*/
|
|
1953
2247
|
delete(): Promise<TModel>;
|
|
2248
|
+
private tryBuildInsertSpec;
|
|
2249
|
+
private tryBuildInsertManySpec;
|
|
2250
|
+
private tryBuildInsertOrIgnoreManySpec;
|
|
2251
|
+
private tryBuildUpdateSpec;
|
|
2252
|
+
private tryBuildUpdateManySpec;
|
|
2253
|
+
private tryBuildDeleteSpec;
|
|
1954
2254
|
/**
|
|
1955
2255
|
* Counts the number of records matching the current query constraints.
|
|
1956
2256
|
*
|
|
@@ -2062,6 +2362,34 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2062
2362
|
* @returns
|
|
2063
2363
|
*/
|
|
2064
2364
|
private normalizeWith;
|
|
2365
|
+
private buildQueryTarget;
|
|
2366
|
+
private hasBaseWhereConstraints;
|
|
2367
|
+
private normalizeQuerySelect;
|
|
2368
|
+
private normalizeQueryOrderBy;
|
|
2369
|
+
private cloneRelationLoads;
|
|
2370
|
+
private normalizeRelationLoadSelect;
|
|
2371
|
+
private normalizeRelationLoadOrderBy;
|
|
2372
|
+
private normalizeRelationLoads;
|
|
2373
|
+
private appendQueryCondition;
|
|
2374
|
+
private toDelegateWhere;
|
|
2375
|
+
private buildSoftDeleteQueryCondition;
|
|
2376
|
+
private buildQueryWhereCondition;
|
|
2377
|
+
private tryBuildQuerySelectColumns;
|
|
2378
|
+
private tryBuildQueryOrderBy;
|
|
2379
|
+
private tryBuildFieldCondition;
|
|
2380
|
+
private tryBuildQueryCondition;
|
|
2381
|
+
private tryBuildSelectSpec;
|
|
2382
|
+
private tryBuildAggregateSpec;
|
|
2383
|
+
private requireAdapter;
|
|
2384
|
+
private executeReadRows;
|
|
2385
|
+
private executeReadRow;
|
|
2386
|
+
private executeReadCount;
|
|
2387
|
+
private executeReadExists;
|
|
2388
|
+
private executeInsertRow;
|
|
2389
|
+
private executeInsertManyRows;
|
|
2390
|
+
private executeUpdateRow;
|
|
2391
|
+
private executeUpdateManyRows;
|
|
2392
|
+
private executeDeleteRow;
|
|
2065
2393
|
/**
|
|
2066
2394
|
* Builds the where clause for the query, taking into account soft delete
|
|
2067
2395
|
* settings if applicable.
|
|
@@ -2074,7 +2402,6 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2074
2402
|
*
|
|
2075
2403
|
* @returns
|
|
2076
2404
|
*/
|
|
2077
|
-
private buildFindArgs;
|
|
2078
2405
|
/**
|
|
2079
2406
|
* Resolves a unique where clause for update and delete operations.
|
|
2080
2407
|
*
|
|
@@ -2113,188 +2440,266 @@ interface ModelStatic<TModel, TDelegate extends PrismaDelegateLike = PrismaDeleg
|
|
|
2113
2440
|
hydrateMany: (attributes: (DelegateRow<TDelegate> extends Record<string, unknown> ? DelegateRow<TDelegate> : Record<string, unknown>)[]) => TModel[];
|
|
2114
2441
|
hydrateRetrieved: (attributes: DelegateRow<TDelegate> extends Record<string, unknown> ? DelegateRow<TDelegate> : Record<string, unknown>) => Promise<TModel>;
|
|
2115
2442
|
hydrateManyRetrieved: (attributes: (DelegateRow<TDelegate> extends Record<string, unknown> ? DelegateRow<TDelegate> : Record<string, unknown>)[]) => Promise<TModel[]>;
|
|
2443
|
+
getAdapter: () => DatabaseAdapter | undefined;
|
|
2444
|
+
getColumnMap: () => Record<string, string>;
|
|
2445
|
+
getColumnName: (attribute: string) => string;
|
|
2116
2446
|
getDelegate: (delegate?: string) => TDelegate;
|
|
2447
|
+
getModelMetadata: () => ModelMetadata;
|
|
2448
|
+
getPrimaryKey: () => string;
|
|
2449
|
+
getRelationMetadata: (name: string) => RelationMetadata | null;
|
|
2450
|
+
setAdapter: (adapter?: DatabaseAdapter) => void;
|
|
2117
2451
|
getSoftDeleteConfig: () => SoftDeleteConfig;
|
|
2452
|
+
getTable: () => string;
|
|
2118
2453
|
}
|
|
2119
2454
|
interface RelationshipModelStatic {
|
|
2120
2455
|
new (attributes?: Record<string, unknown>): any;
|
|
2121
2456
|
query: () => QueryBuilder<any, any>;
|
|
2122
2457
|
hydrate: (attributes: Record<string, unknown>) => any;
|
|
2458
|
+
getAdapter: () => DatabaseAdapter | undefined;
|
|
2459
|
+
getColumnMap: () => Record<string, string>;
|
|
2460
|
+
getColumnName: (attribute: string) => string;
|
|
2123
2461
|
getDelegate: (delegate?: string) => PrismaDelegateLike;
|
|
2462
|
+
getModelMetadata: () => ModelMetadata;
|
|
2463
|
+
getPrimaryKey: () => string;
|
|
2464
|
+
getRelationMetadata: (name: string) => RelationMetadata | null;
|
|
2465
|
+
getTable: () => string;
|
|
2124
2466
|
}
|
|
2125
2467
|
//#endregion
|
|
2126
|
-
//#region src/types/
|
|
2127
|
-
type
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2468
|
+
//#region src/types/adapter.d.ts
|
|
2469
|
+
type DatabasePrimitive = string | number | boolean | bigint | Date | null;
|
|
2470
|
+
type DatabaseValue = DatabasePrimitive | DatabaseRow | DatabaseValue[];
|
|
2471
|
+
type DatabaseRow = Record<string, unknown>;
|
|
2472
|
+
type DatabaseRows = DatabaseRow[];
|
|
2473
|
+
type AdapterCapability = 'transactions' | 'returning' | 'insertMany' | 'updateMany' | 'deleteMany' | 'exists' | 'relationLoads' | 'relationAggregates' | 'relationFilters' | 'rawWhere';
|
|
2474
|
+
type AdapterCapabilities = Partial<Record<AdapterCapability, boolean>>;
|
|
2475
|
+
type QueryLogicalOperator = 'and' | 'or';
|
|
2476
|
+
type QueryComparisonOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'in' | 'not-in' | 'contains' | 'starts-with' | 'ends-with' | 'is-null' | 'is-not-null';
|
|
2477
|
+
type SortDirection = 'asc' | 'desc';
|
|
2478
|
+
type AggregateOperation = 'count' | 'exists' | 'sum' | 'avg' | 'min' | 'max';
|
|
2479
|
+
type SoftDeleteQueryMode = 'exclude' | 'include' | 'only';
|
|
2480
|
+
interface QueryTarget<TModel = unknown> {
|
|
2481
|
+
model?: ModelStatic<TModel, any>;
|
|
2482
|
+
modelName?: string;
|
|
2483
|
+
table?: string;
|
|
2484
|
+
primaryKey?: string;
|
|
2485
|
+
columns?: Record<string, string>;
|
|
2486
|
+
softDelete?: SoftDeleteConfig;
|
|
2487
|
+
alias?: string;
|
|
2131
2488
|
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
interface PrismaTransactionOptions {
|
|
2136
|
-
maxWait?: number;
|
|
2137
|
-
timeout?: number;
|
|
2138
|
-
isolationLevel?: string;
|
|
2489
|
+
interface QuerySelectColumn {
|
|
2490
|
+
column: string;
|
|
2491
|
+
alias?: string;
|
|
2139
2492
|
}
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2493
|
+
interface QueryOrderBy {
|
|
2494
|
+
column: string;
|
|
2495
|
+
direction: SortDirection;
|
|
2143
2496
|
}
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
prisma: ClientResolver;
|
|
2150
|
-
/**
|
|
2151
|
-
* @property pagination Configuration options related to pagination behavior and URL generation.
|
|
2152
|
-
*/
|
|
2153
|
-
pagination?: {
|
|
2154
|
-
urlDriver?: PaginationURLDriverFactory;
|
|
2155
|
-
resolveCurrentPage?: PaginationCurrentPageResolver;
|
|
2156
|
-
};
|
|
2157
|
-
/**
|
|
2158
|
-
* @property paths Optional custom paths for various generated files.
|
|
2159
|
-
*/
|
|
2160
|
-
paths?: {
|
|
2161
|
-
/**
|
|
2162
|
-
* @property stubs Optional custom path for stub files used in code generation.
|
|
2163
|
-
*/
|
|
2164
|
-
stubs?: string;
|
|
2165
|
-
/**
|
|
2166
|
-
* @property seeders Optional custom path for seeder files.
|
|
2167
|
-
*/
|
|
2168
|
-
seeders?: string;
|
|
2169
|
-
/**
|
|
2170
|
-
* @property models Optional custom path for model files.
|
|
2171
|
-
*/
|
|
2172
|
-
models?: string;
|
|
2173
|
-
/**
|
|
2174
|
-
* @property migrations Optional custom path for migration files.
|
|
2175
|
-
*/
|
|
2176
|
-
migrations?: string;
|
|
2177
|
-
/**
|
|
2178
|
-
* @property factories Optional custom path for factory files.
|
|
2179
|
-
*/
|
|
2180
|
-
factories?: string;
|
|
2181
|
-
/**
|
|
2182
|
-
* @property buildOutput Optional custom path for the development output directory.
|
|
2183
|
-
*/
|
|
2184
|
-
buildOutput?: string;
|
|
2185
|
-
};
|
|
2186
|
-
/**
|
|
2187
|
-
* @property outputExt Optional file extension for generated files, either 'ts' or 'js'.
|
|
2188
|
-
*/
|
|
2189
|
-
outputExt?: 'ts' | 'js';
|
|
2497
|
+
interface QueryComparisonCondition {
|
|
2498
|
+
type: 'comparison';
|
|
2499
|
+
column: string;
|
|
2500
|
+
operator: QueryComparisonOperator;
|
|
2501
|
+
value?: DatabaseValue | DatabaseValue[];
|
|
2190
2502
|
}
|
|
2191
|
-
interface
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
(): Partial<ArkormConfig>;
|
|
2196
|
-
/**
|
|
2197
|
-
* Get a specific user configuration value
|
|
2198
|
-
* @param key Optional specific configuration key to retrieve
|
|
2199
|
-
*/
|
|
2200
|
-
<K extends keyof ArkormConfig>(key: K): Partial<ArkormConfig>[K];
|
|
2503
|
+
interface QueryGroupCondition {
|
|
2504
|
+
type: 'group';
|
|
2505
|
+
operator: QueryLogicalOperator;
|
|
2506
|
+
conditions: QueryCondition[];
|
|
2201
2507
|
}
|
|
2202
|
-
interface
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
currentPage: number;
|
|
2206
|
-
lastPage: number;
|
|
2207
|
-
from: number | null;
|
|
2208
|
-
to: number | null;
|
|
2508
|
+
interface QueryNotCondition {
|
|
2509
|
+
type: 'not';
|
|
2510
|
+
condition: QueryCondition;
|
|
2209
2511
|
}
|
|
2210
|
-
interface
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
to: number | null;
|
|
2215
|
-
hasMorePages: boolean;
|
|
2512
|
+
interface QueryRawCondition {
|
|
2513
|
+
type: 'raw';
|
|
2514
|
+
sql: string;
|
|
2515
|
+
bindings?: DatabaseValue[];
|
|
2216
2516
|
}
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2517
|
+
type QueryCondition = QueryComparisonCondition | QueryGroupCondition | QueryNotCondition | QueryRawCondition;
|
|
2518
|
+
interface AggregateSelection {
|
|
2519
|
+
type: AggregateOperation;
|
|
2520
|
+
column?: string;
|
|
2521
|
+
alias?: string;
|
|
2222
2522
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2523
|
+
interface RelationAggregateSpec {
|
|
2524
|
+
relation: string;
|
|
2525
|
+
type: AggregateOperation;
|
|
2526
|
+
column?: string;
|
|
2527
|
+
alias?: string;
|
|
2528
|
+
where?: QueryCondition;
|
|
2227
2529
|
}
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
skip?: number;
|
|
2235
|
-
take?: number;
|
|
2530
|
+
interface RelationFilterSpec {
|
|
2531
|
+
relation: string;
|
|
2532
|
+
operator: '>=' | '>' | '=' | '!=' | '<=' | '<';
|
|
2533
|
+
count: number;
|
|
2534
|
+
boolean?: 'AND' | 'OR';
|
|
2535
|
+
where?: QueryCondition;
|
|
2236
2536
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2537
|
+
interface RelationLoadPlan {
|
|
2538
|
+
relation: string;
|
|
2539
|
+
constraint?: QueryCondition;
|
|
2540
|
+
orderBy?: QueryOrderBy[];
|
|
2541
|
+
limit?: number;
|
|
2542
|
+
offset?: number;
|
|
2543
|
+
columns?: QuerySelectColumn[];
|
|
2544
|
+
relationLoads?: RelationLoadPlan[];
|
|
2243
2545
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
[
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2546
|
+
interface SelectSpec<TModel = unknown> {
|
|
2547
|
+
target: QueryTarget<TModel>;
|
|
2548
|
+
columns?: QuerySelectColumn[];
|
|
2549
|
+
where?: QueryCondition;
|
|
2550
|
+
orderBy?: QueryOrderBy[];
|
|
2551
|
+
limit?: number;
|
|
2552
|
+
offset?: number;
|
|
2553
|
+
softDeleteMode?: SoftDeleteQueryMode;
|
|
2554
|
+
relationLoads?: RelationLoadPlan[];
|
|
2555
|
+
relationAggregates?: RelationAggregateSpec[];
|
|
2556
|
+
relationFilters?: RelationFilterSpec[];
|
|
2557
|
+
aggregates?: AggregateSelection[];
|
|
2250
2558
|
}
|
|
2251
|
-
interface
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
select?: PrismaLikeSelect;
|
|
2256
|
-
include?: PrismaLikeInclude;
|
|
2257
|
-
skip?: number;
|
|
2258
|
-
take?: number;
|
|
2259
|
-
};
|
|
2559
|
+
interface InsertSpec<TModel = unknown> {
|
|
2560
|
+
target: QueryTarget<TModel>;
|
|
2561
|
+
values: DatabaseRow;
|
|
2562
|
+
returning?: QuerySelectColumn[];
|
|
2260
2563
|
}
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
column: string;
|
|
2564
|
+
interface InsertManySpec<TModel = unknown> {
|
|
2565
|
+
target: QueryTarget<TModel>;
|
|
2566
|
+
values: DatabaseRow[];
|
|
2567
|
+
ignoreDuplicates?: boolean;
|
|
2266
2568
|
}
|
|
2267
|
-
interface
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2569
|
+
interface UpdateSpec<TModel = unknown> {
|
|
2570
|
+
target: QueryTarget<TModel>;
|
|
2571
|
+
where: QueryCondition;
|
|
2572
|
+
values: DatabaseRow;
|
|
2573
|
+
returning?: QuerySelectColumn[];
|
|
2574
|
+
}
|
|
2575
|
+
interface UpdateManySpec<TModel = unknown> {
|
|
2576
|
+
target: QueryTarget<TModel>;
|
|
2577
|
+
where?: QueryCondition;
|
|
2578
|
+
values: DatabaseRow;
|
|
2579
|
+
}
|
|
2580
|
+
interface DeleteSpec<TModel = unknown> {
|
|
2581
|
+
target: QueryTarget<TModel>;
|
|
2582
|
+
where: QueryCondition;
|
|
2583
|
+
returning?: QuerySelectColumn[];
|
|
2584
|
+
}
|
|
2585
|
+
interface DeleteManySpec<TModel = unknown> {
|
|
2586
|
+
target: QueryTarget<TModel>;
|
|
2587
|
+
where?: QueryCondition;
|
|
2588
|
+
}
|
|
2589
|
+
interface AggregateSpec<TModel = unknown> {
|
|
2590
|
+
target: QueryTarget<TModel>;
|
|
2591
|
+
where?: QueryCondition;
|
|
2592
|
+
aggregate: AggregateSelection;
|
|
2593
|
+
softDeleteMode?: SoftDeleteQueryMode;
|
|
2594
|
+
}
|
|
2595
|
+
interface RelationLoadSpec<TModel = unknown> {
|
|
2596
|
+
target: QueryTarget<TModel>;
|
|
2597
|
+
models: TModel[];
|
|
2598
|
+
relations: RelationLoadPlan[];
|
|
2599
|
+
}
|
|
2600
|
+
interface AdapterTransactionContext {
|
|
2601
|
+
isolationLevel?: string;
|
|
2602
|
+
readOnly?: boolean;
|
|
2603
|
+
maxWait?: number;
|
|
2604
|
+
timeout?: number;
|
|
2605
|
+
}
|
|
2606
|
+
interface DatabaseAdapter {
|
|
2607
|
+
readonly capabilities?: AdapterCapabilities;
|
|
2608
|
+
select: <TModel = unknown>(spec: SelectSpec<TModel>) => Promise<DatabaseRows>;
|
|
2609
|
+
selectOne: <TModel = unknown>(spec: SelectSpec<TModel>) => Promise<DatabaseRow | null>;
|
|
2610
|
+
insert: <TModel = unknown>(spec: InsertSpec<TModel>) => Promise<DatabaseRow>;
|
|
2611
|
+
insertMany?: <TModel = unknown>(spec: InsertManySpec<TModel>) => Promise<number>;
|
|
2612
|
+
update: <TModel = unknown>(spec: UpdateSpec<TModel>) => Promise<DatabaseRow | null>;
|
|
2613
|
+
updateMany?: <TModel = unknown>(spec: UpdateManySpec<TModel>) => Promise<number>;
|
|
2614
|
+
delete: <TModel = unknown>(spec: DeleteSpec<TModel>) => Promise<DatabaseRow | null>;
|
|
2615
|
+
deleteMany?: <TModel = unknown>(spec: DeleteManySpec<TModel>) => Promise<number>;
|
|
2616
|
+
count: <TModel = unknown>(spec: AggregateSpec<TModel>) => Promise<number>;
|
|
2617
|
+
exists?: <TModel = unknown>(spec: SelectSpec<TModel>) => Promise<boolean>;
|
|
2618
|
+
loadRelations?: <TModel = unknown>(spec: RelationLoadSpec<TModel>) => Promise<void>;
|
|
2619
|
+
transaction: <TResult = unknown>(callback: (adapter: DatabaseAdapter) => TResult | Promise<TResult>, context?: AdapterTransactionContext) => Promise<TResult>;
|
|
2620
|
+
}
|
|
2621
|
+
//#endregion
|
|
2622
|
+
//#region src/adapters/KyselyDatabaseAdapter.d.ts
|
|
2623
|
+
type KyselyExecutor = Kysely<any> | Transaction<any>;
|
|
2624
|
+
declare class KyselyDatabaseAdapter implements DatabaseAdapter {
|
|
2625
|
+
private readonly db;
|
|
2626
|
+
readonly capabilities: AdapterCapabilities;
|
|
2627
|
+
constructor(db: KyselyExecutor);
|
|
2628
|
+
private resolveTable;
|
|
2629
|
+
private resolvePrimaryKey;
|
|
2630
|
+
private mapColumn;
|
|
2631
|
+
private reverseColumnMap;
|
|
2632
|
+
private mapRow;
|
|
2633
|
+
private mapRows;
|
|
2634
|
+
private mapValues;
|
|
2635
|
+
private buildSelectList;
|
|
2636
|
+
private buildOrderBy;
|
|
2637
|
+
private buildConditionValueList;
|
|
2638
|
+
private buildComparisonCondition;
|
|
2639
|
+
private buildWhereCondition;
|
|
2640
|
+
private buildWhereClause;
|
|
2641
|
+
private buildPaginationClause;
|
|
2642
|
+
private assertNoRelationLoads;
|
|
2643
|
+
select<TModel = unknown>(spec: SelectSpec<TModel>): Promise<DatabaseRow[]>;
|
|
2644
|
+
selectOne<TModel = unknown>(spec: SelectSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2645
|
+
insert<TModel = unknown>(spec: InsertSpec<TModel>): Promise<DatabaseRow>;
|
|
2646
|
+
insertMany<TModel = unknown>(spec: InsertManySpec<TModel>): Promise<number>;
|
|
2647
|
+
update<TModel = unknown>(spec: UpdateSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2648
|
+
updateMany<TModel = unknown>(spec: UpdateManySpec<TModel>): Promise<number>;
|
|
2649
|
+
delete<TModel = unknown>(spec: DeleteSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2650
|
+
deleteMany<TModel = unknown>(spec: DeleteManySpec<TModel>): Promise<number>;
|
|
2651
|
+
count<TModel = unknown>(spec: AggregateSpec<TModel>): Promise<number>;
|
|
2652
|
+
exists<TModel = unknown>(spec: SelectSpec<TModel>): Promise<boolean>;
|
|
2653
|
+
transaction<TResult = unknown>(callback: (adapter: DatabaseAdapter) => TResult | Promise<TResult>, context?: AdapterTransactionContext): Promise<TResult>;
|
|
2654
|
+
}
|
|
2655
|
+
declare const createKyselyAdapter: (db: KyselyExecutor) => KyselyDatabaseAdapter;
|
|
2656
|
+
//#endregion
|
|
2657
|
+
//#region src/adapters/PrismaDatabaseAdapter.d.ts
|
|
2658
|
+
type PrismaDelegateNameMapping = Record<string, string>;
|
|
2659
|
+
declare class PrismaDatabaseAdapter implements DatabaseAdapter {
|
|
2660
|
+
private readonly prisma;
|
|
2661
|
+
private readonly mapping;
|
|
2662
|
+
readonly capabilities: AdapterCapabilities;
|
|
2663
|
+
private readonly delegates;
|
|
2664
|
+
constructor(prisma: PrismaClientLike, mapping?: PrismaDelegateNameMapping);
|
|
2665
|
+
private hasTransactionSupport;
|
|
2666
|
+
private normalizeCandidate;
|
|
2667
|
+
private unique;
|
|
2668
|
+
private toQuerySelect;
|
|
2669
|
+
private toQueryOrderBy;
|
|
2670
|
+
private toComparisonWhere;
|
|
2671
|
+
private toQueryWhere;
|
|
2672
|
+
private buildFindArgs;
|
|
2673
|
+
private toQueryInclude;
|
|
2674
|
+
private resolveDelegate;
|
|
2675
|
+
select<TModel = unknown>(spec: SelectSpec<TModel>): Promise<DatabaseRow[]>;
|
|
2676
|
+
selectOne<TModel = unknown>(spec: SelectSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2677
|
+
insert<TModel = unknown>(spec: InsertSpec<TModel>): Promise<DatabaseRow>;
|
|
2678
|
+
insertMany<TModel = unknown>(spec: InsertManySpec<TModel>): Promise<number>;
|
|
2679
|
+
update<TModel = unknown>(spec: UpdateSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2680
|
+
updateMany<TModel = unknown>(spec: UpdateManySpec<TModel>): Promise<number>;
|
|
2681
|
+
delete<TModel = unknown>(spec: DeleteSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2682
|
+
deleteMany<TModel = unknown>(spec: DeleteManySpec<TModel>): Promise<number>;
|
|
2683
|
+
count<TModel = unknown>(spec: AggregateSpec<TModel>): Promise<number>;
|
|
2684
|
+
exists<TModel = unknown>(spec: SelectSpec<TModel>): Promise<boolean>;
|
|
2685
|
+
loadRelations<TModel = unknown>(_spec: RelationLoadSpec<TModel>): Promise<void>;
|
|
2686
|
+
transaction<TResult = unknown>(callback: (adapter: DatabaseAdapter) => TResult | Promise<TResult>, context?: AdapterTransactionContext): Promise<TResult>;
|
|
2687
|
+
}
|
|
2688
|
+
declare const createPrismaDatabaseAdapter: (prisma: PrismaClientLike, mapping?: PrismaDelegateNameMapping) => PrismaDatabaseAdapter;
|
|
2689
|
+
declare const createPrismaCompatibilityAdapter: (prisma: PrismaClientLike, mapping?: PrismaDelegateNameMapping) => PrismaDatabaseAdapter;
|
|
2690
|
+
//#endregion
|
|
2691
|
+
//#region src/Attribute.d.ts
|
|
2692
|
+
interface AttributeOptions<TGet = unknown, TSet = unknown> {
|
|
2693
|
+
get?: (value: unknown) => TGet;
|
|
2694
|
+
set?: (value: TSet) => unknown;
|
|
2695
|
+
}
|
|
2696
|
+
declare class Attribute<TGet = unknown, TSet = unknown> {
|
|
2697
|
+
readonly get?: (value: unknown) => TGet;
|
|
2698
|
+
readonly set?: (value: TSet) => unknown;
|
|
2699
|
+
constructor(options?: AttributeOptions<TGet, TSet>);
|
|
2700
|
+
static make<TGet = unknown, TSet = unknown>(options: AttributeOptions<TGet, TSet>): Attribute<TGet, TSet>;
|
|
2701
|
+
static isAttribute(value: unknown): value is Attribute;
|
|
2274
2702
|
}
|
|
2275
|
-
type FallbackIfUnknownOrNever<TValue, TFallback> = [TValue] extends [never] ? TFallback : unknown extends TValue ? TFallback : TValue;
|
|
2276
|
-
type DelegateFindManyArgs<TDelegate extends PrismaDelegateLike> = FallbackIfUnknownOrNever<NonNullable<Parameters<TDelegate['findMany']>[0]>, PrismaFindManyArgsLike>;
|
|
2277
|
-
type DelegateWhere<TDelegate extends PrismaDelegateLike> = DelegateFindManyArgs<TDelegate> extends {
|
|
2278
|
-
where?: infer TWhere;
|
|
2279
|
-
} ? FallbackIfUnknownOrNever<TWhere, PrismaLikeWhereInput> : PrismaLikeWhereInput;
|
|
2280
|
-
type DelegateInclude<TDelegate extends PrismaDelegateLike> = DelegateFindManyArgs<TDelegate> extends {
|
|
2281
|
-
include?: infer TInclude;
|
|
2282
|
-
} ? FallbackIfUnknownOrNever<TInclude, PrismaLikeInclude> : PrismaLikeInclude;
|
|
2283
|
-
type DelegateOrderBy<TDelegate extends PrismaDelegateLike> = DelegateFindManyArgs<TDelegate> extends {
|
|
2284
|
-
orderBy?: infer TOrderBy;
|
|
2285
|
-
} ? FallbackIfUnknownOrNever<TOrderBy, PrismaLikeOrderBy> : PrismaLikeOrderBy;
|
|
2286
|
-
type DelegateSelect<TDelegate extends PrismaDelegateLike> = DelegateFindManyArgs<TDelegate> extends {
|
|
2287
|
-
select?: infer TSelect;
|
|
2288
|
-
} ? FallbackIfUnknownOrNever<TSelect, PrismaLikeSelect> : PrismaLikeSelect;
|
|
2289
|
-
type DelegateCreateData<TDelegate extends PrismaDelegateLike> = Parameters<TDelegate['create']>[0] extends {
|
|
2290
|
-
data: infer TData;
|
|
2291
|
-
} ? TData : Record<string, unknown>;
|
|
2292
|
-
type DelegateUpdateArgs<TDelegate extends PrismaDelegateLike> = Parameters<TDelegate['update']>[0];
|
|
2293
|
-
type DelegateUpdateData<TDelegate extends PrismaDelegateLike> = DelegateUpdateArgs<TDelegate> extends {
|
|
2294
|
-
data: infer TData;
|
|
2295
|
-
} ? FallbackIfUnknownOrNever<TData, Record<string, unknown>> : Record<string, unknown>;
|
|
2296
|
-
type DelegateRow<TDelegate extends PrismaDelegateLike> = Exclude<Awaited<ReturnType<TDelegate['findFirst']>>, null>;
|
|
2297
|
-
type Serializable = Record<string, unknown>;
|
|
2298
2703
|
//#endregion
|
|
2299
2704
|
//#region src/casts.d.ts
|
|
2300
2705
|
declare function resolveCast(definition: CastDefinition): CastHandler;
|
|
@@ -3703,7 +4108,7 @@ declare function createPrismaAdapter(prisma: PrismaClientLike): Record<string, P
|
|
|
3703
4108
|
* @param mapping Optional mapping of Arkormˣ delegate names to Prisma delegate names.
|
|
3704
4109
|
* @returns A delegate map keyed by Arkormˣ delegate names.
|
|
3705
4110
|
*/
|
|
3706
|
-
declare function createPrismaDelegateMap(prisma: PrismaClientLike): Record<string, PrismaDelegateLike>;
|
|
4111
|
+
declare function createPrismaDelegateMap(prisma: PrismaClientLike, mapping?: PrismaDelegateNameMapping): Record<string, PrismaDelegateLike>;
|
|
3707
4112
|
/**
|
|
3708
4113
|
* Infer the Prisma delegate name for a given model name using a simple convention.
|
|
3709
4114
|
*
|
|
@@ -3735,4 +4140,4 @@ declare class URLDriver {
|
|
|
3735
4140
|
url(page: number): string;
|
|
3736
4141
|
}
|
|
3737
4142
|
//#endregion
|
|
3738
|
-
export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };
|
|
4143
|
+
export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDatabaseAdapter, PrismaDelegateMap, PrismaDelegateNameMapping, QueryBuilder, QueryConstraintException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };
|