arkormx 2.0.0-next.1 → 2.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -13
- package/dist/cli.mjs +109 -35
- package/dist/index.cjs +1308 -72
- package/dist/index.d.cts +392 -20
- package/dist/index.d.mts +392 -20
- package/dist/index.mjs +1307 -73
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -22,11 +22,26 @@ interface PrismaTransactionCapableClient {
|
|
|
22
22
|
$transaction: <TResult>(callback: PrismaTransactionCallback<TResult>, options?: PrismaTransactionOptions) => Promise<TResult>;
|
|
23
23
|
}
|
|
24
24
|
type ClientResolver = PrismaClientLike | (() => PrismaClientLike);
|
|
25
|
+
interface AdapterBindableModel {
|
|
26
|
+
setAdapter: (adapter?: DatabaseAdapter) => void;
|
|
27
|
+
}
|
|
28
|
+
interface ArkormBootContext {
|
|
29
|
+
prisma?: PrismaClientLike;
|
|
30
|
+
bindAdapter: (adapter: DatabaseAdapter, models: AdapterBindableModel[]) => DatabaseAdapter;
|
|
31
|
+
}
|
|
25
32
|
interface ArkormConfig {
|
|
26
33
|
/**
|
|
27
|
-
* @property prisma
|
|
34
|
+
* @property prisma Optional Prisma client instance or resolver used for compatibility, CLI flows, and Prisma-backed transactions.
|
|
35
|
+
*/
|
|
36
|
+
prisma?: ClientResolver;
|
|
37
|
+
/**
|
|
38
|
+
* @property adapter Optional global adapter applied automatically to models that do not define a model-specific adapter.
|
|
28
39
|
*/
|
|
29
|
-
|
|
40
|
+
adapter?: DatabaseAdapter;
|
|
41
|
+
/**
|
|
42
|
+
* @property boot Optional synchronous runtime boot hook for central adapter binding.
|
|
43
|
+
*/
|
|
44
|
+
boot?: (context: ArkormBootContext) => void;
|
|
30
45
|
/**
|
|
31
46
|
* @property pagination Configuration options related to pagination behavior and URL generation.
|
|
32
47
|
*/
|
|
@@ -398,6 +413,13 @@ interface RelationMetadataProvider {
|
|
|
398
413
|
}
|
|
399
414
|
//#endregion
|
|
400
415
|
//#region src/relationship/RelationTableLoader.d.ts
|
|
416
|
+
/**
|
|
417
|
+
* Utility class responsible for loading data from relation tables, which are used to
|
|
418
|
+
* manage relationships between models in Arkorm.
|
|
419
|
+
*
|
|
420
|
+
* @author Legacy (3m1n3nc3)
|
|
421
|
+
* @since 2.0.0-next.0
|
|
422
|
+
*/
|
|
401
423
|
declare class RelationTableLoader {
|
|
402
424
|
private readonly adapter;
|
|
403
425
|
constructor(adapter: DatabaseAdapter);
|
|
@@ -986,6 +1008,7 @@ declare const defineFactory: <TModel, TAttributes extends FactoryAttributes = Pa
|
|
|
986
1008
|
*/
|
|
987
1009
|
declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string, unknown> | string = Record<string, any>, TAttributes extends Record<string, unknown> = ModelAttributesOf<TSchema>> {
|
|
988
1010
|
private static readonly lifecycleStates;
|
|
1011
|
+
private static readonly emittedDeprecationWarnings;
|
|
989
1012
|
private static eventsSuppressed;
|
|
990
1013
|
protected static factoryClass?: new () => ModelFactory<any, any>;
|
|
991
1014
|
protected static adapter?: DatabaseAdapter;
|
|
@@ -1008,9 +1031,13 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
1008
1031
|
protected changes: Record<string, unknown>;
|
|
1009
1032
|
protected readonly touchedAttributes: Set<string>;
|
|
1010
1033
|
constructor(attributes?: Record<string, unknown>);
|
|
1034
|
+
private static emitDeprecationWarning;
|
|
1011
1035
|
/**
|
|
1012
1036
|
* Set the Prisma client delegates for all models.
|
|
1013
1037
|
*
|
|
1038
|
+
* @deprecated Use Model.setAdapter(createPrismaDatabaseAdapter(...)) or another
|
|
1039
|
+
* adapter-first bootstrap path instead.
|
|
1040
|
+
*
|
|
1014
1041
|
* @param client
|
|
1015
1042
|
*/
|
|
1016
1043
|
protected static setClient(client: Record<string, unknown>): void;
|
|
@@ -1118,7 +1145,7 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
1118
1145
|
* @param this
|
|
1119
1146
|
* @returns
|
|
1120
1147
|
*/
|
|
1121
|
-
static query<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema> ? TSchema : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
|
|
1148
|
+
static query<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
|
|
1122
1149
|
/**
|
|
1123
1150
|
* Boot hook for subclasses to register scopes or perform one-time setup.
|
|
1124
1151
|
*/
|
|
@@ -1133,14 +1160,14 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
1133
1160
|
* @param this
|
|
1134
1161
|
* @returns
|
|
1135
1162
|
*/
|
|
1136
|
-
static withTrashed<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema> ? TSchema : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
|
|
1163
|
+
static withTrashed<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
|
|
1137
1164
|
/**
|
|
1138
1165
|
* Get a query builder instance that only includes soft-deleted records.
|
|
1139
1166
|
*
|
|
1140
1167
|
* @param this
|
|
1141
1168
|
* @returns
|
|
1142
1169
|
*/
|
|
1143
|
-
static onlyTrashed<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema> ? TSchema : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
|
|
1170
|
+
static onlyTrashed<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
|
|
1144
1171
|
/**
|
|
1145
1172
|
* Get a query builder instance that excludes soft-deleted records.
|
|
1146
1173
|
* This is the default behavior of the query builder, but this method can be used
|
|
@@ -1151,7 +1178,7 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
1151
1178
|
* @param args
|
|
1152
1179
|
* @returns
|
|
1153
1180
|
*/
|
|
1154
|
-
static scope<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema> ? TSchema : Record<string, any>>>(this: TThis, name: string, ...args: unknown[]): QueryBuilder<TModel, TDelegate>;
|
|
1181
|
+
static scope<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis, name: string, ...args: unknown[]): QueryBuilder<TModel, TDelegate>;
|
|
1155
1182
|
/**
|
|
1156
1183
|
* Get the soft delete configuration for the model, including whether
|
|
1157
1184
|
* soft deletes are enabled and the name of the deleted at column.
|
|
@@ -1278,6 +1305,7 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
1278
1305
|
* @returns
|
|
1279
1306
|
*/
|
|
1280
1307
|
load(relations: string | string[] | EagerLoadMap): Promise<this>;
|
|
1308
|
+
setLoadedRelation(name: string, value: unknown): this;
|
|
1281
1309
|
/**
|
|
1282
1310
|
* Get the raw attributes of the model without applying any mutators or casts.
|
|
1283
1311
|
*
|
|
@@ -1572,13 +1600,75 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
1572
1600
|
//#endregion
|
|
1573
1601
|
//#region src/types/model.d.ts
|
|
1574
1602
|
type LowercaseString<T extends string> = Lowercase<T>;
|
|
1603
|
+
type Simplify<TValue> = { [TKey in keyof TValue]: TValue[TKey] } & {};
|
|
1604
|
+
type ConventionalAutoManagedKeys = 'id' | 'createdAt' | 'updatedAt' | 'deletedAt';
|
|
1575
1605
|
type SingularKey<T extends string> = LowercaseString<T> extends `${infer Base}s` ? Base : LowercaseString<T>;
|
|
1576
1606
|
type PluralKey<T extends string> = `${SingularKey<T>}s`;
|
|
1577
1607
|
type PrismaClientDelegates = { [TKey in keyof PrismaClient as PrismaClient[TKey] extends PrismaDelegateLike ? TKey : never]: PrismaClient[TKey] };
|
|
1578
1608
|
type DelegateFromPrismaClient<TKey extends string> = LowercaseString<TKey> extends keyof PrismaClientDelegates ? PrismaClientDelegates[LowercaseString<TKey>] : SingularKey<TKey> extends keyof PrismaClientDelegates ? PrismaClientDelegates[SingularKey<TKey>] : PluralKey<TKey> extends keyof PrismaClientDelegates ? PrismaClientDelegates[PluralKey<TKey>] : never;
|
|
1579
|
-
type
|
|
1609
|
+
type AttributeScalarFilter<TValue> = Omit<PrismaLikeScalarFilter, 'equals' | 'not' | 'in' | 'notIn' | 'lt' | 'lte' | 'gt' | 'gte' | 'contains' | 'startsWith' | 'endsWith'> & {
|
|
1610
|
+
equals?: TValue;
|
|
1611
|
+
not?: TValue | AttributeScalarFilter<TValue>;
|
|
1612
|
+
in?: TValue[];
|
|
1613
|
+
notIn?: TValue[];
|
|
1614
|
+
lt?: TValue;
|
|
1615
|
+
lte?: TValue;
|
|
1616
|
+
gt?: TValue;
|
|
1617
|
+
gte?: TValue;
|
|
1618
|
+
contains?: Extract<TValue, string>;
|
|
1619
|
+
startsWith?: Extract<TValue, string>;
|
|
1620
|
+
endsWith?: Extract<TValue, string>;
|
|
1621
|
+
};
|
|
1622
|
+
type AttributeWhereInput<TAttributes extends Record<string, unknown>> = {
|
|
1623
|
+
AND?: AttributeWhereInput<TAttributes>[];
|
|
1624
|
+
OR?: AttributeWhereInput<TAttributes>[];
|
|
1625
|
+
NOT?: AttributeWhereInput<TAttributes> | AttributeWhereInput<TAttributes>[];
|
|
1626
|
+
} & { [TKey in keyof TAttributes]?: TAttributes[TKey] | AttributeScalarFilter<NonNullable<TAttributes[TKey]>> | null };
|
|
1627
|
+
type AttributeOrderBy<TAttributes extends Record<string, unknown>> = Partial<Record<keyof TAttributes & string, PrismaLikeSortOrder>> | Array<Partial<Record<keyof TAttributes & string, PrismaLikeSortOrder>>>;
|
|
1628
|
+
type AttributeSelect<TAttributes extends Record<string, unknown>> = { [TKey in keyof TAttributes]?: boolean };
|
|
1629
|
+
type RequiredCreateKeys<TAttributes extends Record<string, unknown>> = Exclude<{ [TKey in keyof TAttributes]-?: undefined extends TAttributes[TKey] ? never : null extends TAttributes[TKey] ? never : TKey }[keyof TAttributes], ConventionalAutoManagedKeys>;
|
|
1630
|
+
type AtLeastOne<TValue extends Record<string, unknown>> = { [TKey in keyof TValue]-?: Required<Pick<TValue, TKey>> & Partial<Omit<TValue, TKey>> }[keyof TValue];
|
|
1631
|
+
type AttributeCreateInput<TAttributes extends Record<string, unknown>> = Simplify<Pick<TAttributes, RequiredCreateKeys<TAttributes>> & Partial<Omit<TAttributes, RequiredCreateKeys<TAttributes>>>>;
|
|
1632
|
+
type AttributeUpdateInput<TAttributes extends Record<string, unknown>> = AtLeastOne<Partial<TAttributes>>;
|
|
1633
|
+
interface AttributeSchemaDelegate<TAttributes extends Record<string, unknown>> extends PrismaDelegateLike {
|
|
1634
|
+
findMany: (args?: {
|
|
1635
|
+
where?: AttributeWhereInput<TAttributes>;
|
|
1636
|
+
include?: PrismaLikeInclude;
|
|
1637
|
+
orderBy?: AttributeOrderBy<TAttributes>;
|
|
1638
|
+
select?: AttributeSelect<TAttributes>;
|
|
1639
|
+
skip?: number;
|
|
1640
|
+
take?: number;
|
|
1641
|
+
}) => Promise<TAttributes[]>;
|
|
1642
|
+
findFirst: (args?: {
|
|
1643
|
+
where?: AttributeWhereInput<TAttributes>;
|
|
1644
|
+
include?: PrismaLikeInclude;
|
|
1645
|
+
orderBy?: AttributeOrderBy<TAttributes>;
|
|
1646
|
+
select?: AttributeSelect<TAttributes>;
|
|
1647
|
+
skip?: number;
|
|
1648
|
+
take?: number;
|
|
1649
|
+
}) => Promise<TAttributes | null>;
|
|
1650
|
+
create: (args: {
|
|
1651
|
+
data: AttributeCreateInput<TAttributes>;
|
|
1652
|
+
select?: PrismaLikeSelect;
|
|
1653
|
+
}) => Promise<TAttributes>;
|
|
1654
|
+
update: (args: {
|
|
1655
|
+
where: Partial<TAttributes>;
|
|
1656
|
+
data: AttributeUpdateInput<TAttributes>;
|
|
1657
|
+
select?: PrismaLikeSelect;
|
|
1658
|
+
}) => Promise<TAttributes>;
|
|
1659
|
+
delete: (args: {
|
|
1660
|
+
where: Partial<TAttributes>;
|
|
1661
|
+
select?: PrismaLikeSelect;
|
|
1662
|
+
}) => Promise<TAttributes>;
|
|
1663
|
+
count: (args?: {
|
|
1664
|
+
where?: AttributeWhereInput<TAttributes>;
|
|
1665
|
+
}) => Promise<number>;
|
|
1666
|
+
}
|
|
1667
|
+
type DelegateForModelSchema<TSchema extends PrismaDelegateLike | Record<string, unknown> | string, TAttributes extends Record<string, unknown> = ModelAttributesOf<TSchema>> = TSchema extends PrismaDelegateLike ? TSchema : TSchema extends string ? DelegateFromPrismaClient<TSchema> extends PrismaDelegateLike ? DelegateFromPrismaClient<TSchema> : PrismaDelegateLike : AttributeSchemaDelegate<TAttributes>;
|
|
1580
1668
|
type ModelAttributesOf<TSchema extends PrismaDelegateLike | Record<string, unknown> | string> = TSchema extends PrismaDelegateLike ? DelegateRow<TSchema> extends Record<string, unknown> ? DelegateRow<TSchema> : Record<string, any> : TSchema extends string ? DelegateFromPrismaClient<TSchema> extends PrismaDelegateLike ? DelegateRow<DelegateFromPrismaClient<TSchema>> extends Record<string, unknown> ? DelegateRow<DelegateFromPrismaClient<TSchema>> : Record<string, any> : Record<string, any> : TSchema extends Record<string, unknown> ? TSchema : Record<string, any>;
|
|
1581
|
-
type ModelAttributes<TModel> = TModel extends Model<infer
|
|
1669
|
+
type ModelAttributes<TModel> = TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>;
|
|
1670
|
+
type ModelCreateData<TModel, TDelegate extends PrismaDelegateLike> = TModel extends Model<any, infer TAttributes> ? TDelegate extends AttributeSchemaDelegate<TAttributes> ? AttributeCreateInput<TAttributes> : DelegateCreateData<TDelegate> : DelegateCreateData<TDelegate>;
|
|
1671
|
+
type ModelUpdateData<TModel, TDelegate extends PrismaDelegateLike> = TModel extends Model<any, infer TAttributes> ? TDelegate extends AttributeSchemaDelegate<TAttributes> ? AttributeUpdateInput<TAttributes> : DelegateUpdateData<TDelegate> : DelegateUpdateData<TDelegate>;
|
|
1582
1672
|
type RelatedModelClass<TInstance = unknown> = (abstract new (attributes?: Record<string, unknown>) => TInstance) & RelationshipModelStatic;
|
|
1583
1673
|
type GlobalScope = (query: QueryBuilder<any, any>) => QueryBuilder<any, any> | void;
|
|
1584
1674
|
type ModelEventName = 'retrieved' | 'saving' | 'saved' | 'creating' | 'created' | 'updating' | 'updated' | 'deleting' | 'deleted' | 'restoring' | 'restored' | 'forceDeleting' | 'forceDeleted';
|
|
@@ -2191,28 +2281,28 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2191
2281
|
* @param data
|
|
2192
2282
|
* @returns
|
|
2193
2283
|
*/
|
|
2194
|
-
create(data:
|
|
2284
|
+
create(data: ModelCreateData<TModel, TDelegate>): Promise<TModel>;
|
|
2195
2285
|
/**
|
|
2196
2286
|
* Creates multiple records and returns hydrated model instances.
|
|
2197
2287
|
*
|
|
2198
2288
|
* @param values
|
|
2199
2289
|
* @returns
|
|
2200
2290
|
*/
|
|
2201
|
-
createMany(values:
|
|
2291
|
+
createMany(values: ModelCreateData<TModel, TDelegate>[]): Promise<TModel[]>;
|
|
2202
2292
|
/**
|
|
2203
2293
|
* Insert one or more records.
|
|
2204
2294
|
*
|
|
2205
2295
|
* @param values
|
|
2206
2296
|
* @returns
|
|
2207
2297
|
*/
|
|
2208
|
-
insert(values:
|
|
2298
|
+
insert(values: ModelCreateData<TModel, TDelegate> | ModelCreateData<TModel, TDelegate>[]): Promise<boolean>;
|
|
2209
2299
|
/**
|
|
2210
2300
|
* Insert one or more records while ignoring insertion errors.
|
|
2211
2301
|
*
|
|
2212
2302
|
* @param values
|
|
2213
2303
|
* @returns
|
|
2214
2304
|
*/
|
|
2215
|
-
insertOrIgnore(values:
|
|
2305
|
+
insertOrIgnore(values: ModelCreateData<TModel, TDelegate> | ModelCreateData<TModel, TDelegate>[]): Promise<number>;
|
|
2216
2306
|
/**
|
|
2217
2307
|
* Insert a record and return its primary key value.
|
|
2218
2308
|
*
|
|
@@ -2220,7 +2310,7 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2220
2310
|
* @param sequence
|
|
2221
2311
|
* @returns
|
|
2222
2312
|
*/
|
|
2223
|
-
insertGetId(values:
|
|
2313
|
+
insertGetId(values: ModelCreateData<TModel, TDelegate>, sequence?: string | null): Promise<unknown>;
|
|
2224
2314
|
/**
|
|
2225
2315
|
* Insert records using values produced by another query/source.
|
|
2226
2316
|
*
|
|
@@ -2244,14 +2334,14 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2244
2334
|
* @param data
|
|
2245
2335
|
* @returns
|
|
2246
2336
|
*/
|
|
2247
|
-
update(data:
|
|
2337
|
+
update(data: ModelUpdateData<TModel, TDelegate>): Promise<TModel>;
|
|
2248
2338
|
/**
|
|
2249
2339
|
* Update records using update-many semantics when available.
|
|
2250
2340
|
*
|
|
2251
2341
|
* @param data
|
|
2252
2342
|
* @returns
|
|
2253
2343
|
*/
|
|
2254
|
-
updateFrom(data:
|
|
2344
|
+
updateFrom(data: ModelUpdateData<TModel, TDelegate>): Promise<number>;
|
|
2255
2345
|
/**
|
|
2256
2346
|
* Insert a record when no match exists, otherwise update the matching record.
|
|
2257
2347
|
*
|
|
@@ -2278,6 +2368,7 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2278
2368
|
delete(): Promise<TModel>;
|
|
2279
2369
|
private tryBuildInsertSpec;
|
|
2280
2370
|
private tryBuildInsertManySpec;
|
|
2371
|
+
private tryBuildUpsertSpec;
|
|
2281
2372
|
private tryBuildInsertOrIgnoreManySpec;
|
|
2282
2373
|
private tryBuildUpdateSpec;
|
|
2283
2374
|
private tryBuildUpdateManySpec;
|
|
@@ -2398,6 +2489,7 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2398
2489
|
private normalizeQuerySelect;
|
|
2399
2490
|
private normalizeQueryOrderBy;
|
|
2400
2491
|
private cloneRelationLoads;
|
|
2492
|
+
private eagerLoadModels;
|
|
2401
2493
|
private normalizeRelationLoadSelect;
|
|
2402
2494
|
private normalizeRelationLoadOrderBy;
|
|
2403
2495
|
private normalizeRelationLoads;
|
|
@@ -2418,6 +2510,7 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2418
2510
|
private executeReadExists;
|
|
2419
2511
|
private executeInsertRow;
|
|
2420
2512
|
private executeInsertManyRows;
|
|
2513
|
+
private executeUpsertRows;
|
|
2421
2514
|
private executeUpdateRow;
|
|
2422
2515
|
private executeUpdateManyRows;
|
|
2423
2516
|
private executeDeleteRow;
|
|
@@ -2452,6 +2545,13 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
|
|
|
2452
2545
|
private hasRelationFilters;
|
|
2453
2546
|
private hasOrRelationFilters;
|
|
2454
2547
|
private hasRelationAggregates;
|
|
2548
|
+
private canExecuteRelationFiltersInAdapter;
|
|
2549
|
+
private canExecuteRelationAggregatesInAdapter;
|
|
2550
|
+
private canExecuteRelationFeaturesInAdapter;
|
|
2551
|
+
private tryBuildRelationFilterSpecs;
|
|
2552
|
+
private tryBuildRelationAggregateSpecs;
|
|
2553
|
+
private tryBuildRelationConstraintWhere;
|
|
2554
|
+
private isSqlRelationFeatureMetadata;
|
|
2455
2555
|
private filterModelsByRelationConstraints;
|
|
2456
2556
|
private getModelId;
|
|
2457
2557
|
private buildSoftDeleteOnlyWhere;
|
|
@@ -2501,7 +2601,7 @@ type DatabasePrimitive = string | number | boolean | bigint | Date | null;
|
|
|
2501
2601
|
type DatabaseValue = DatabasePrimitive | DatabaseRow | DatabaseValue[];
|
|
2502
2602
|
type DatabaseRow = Record<string, unknown>;
|
|
2503
2603
|
type DatabaseRows = DatabaseRow[];
|
|
2504
|
-
type AdapterCapability = 'transactions' | 'returning' | 'insertMany' | 'updateMany' | 'deleteMany' | 'exists' | 'relationLoads' | 'relationAggregates' | 'relationFilters' | 'rawWhere';
|
|
2604
|
+
type AdapterCapability = 'transactions' | 'returning' | 'insertMany' | 'upsert' | 'updateMany' | 'deleteMany' | 'exists' | 'relationLoads' | 'relationAggregates' | 'relationFilters' | 'rawWhere';
|
|
2505
2605
|
type AdapterCapabilities = Partial<Record<AdapterCapability, boolean>>;
|
|
2506
2606
|
type QueryLogicalOperator = 'and' | 'or';
|
|
2507
2607
|
type QueryComparisonOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'in' | 'not-in' | 'contains' | 'starts-with' | 'ends-with' | 'is-null' | 'is-not-null';
|
|
@@ -2597,6 +2697,12 @@ interface InsertManySpec<TModel = unknown> {
|
|
|
2597
2697
|
values: DatabaseRow[];
|
|
2598
2698
|
ignoreDuplicates?: boolean;
|
|
2599
2699
|
}
|
|
2700
|
+
interface UpsertSpec<TModel = unknown> {
|
|
2701
|
+
target: QueryTarget<TModel>;
|
|
2702
|
+
values: DatabaseRow[];
|
|
2703
|
+
uniqueBy: string[];
|
|
2704
|
+
updateColumns?: string[];
|
|
2705
|
+
}
|
|
2600
2706
|
interface UpdateSpec<TModel = unknown> {
|
|
2601
2707
|
target: QueryTarget<TModel>;
|
|
2602
2708
|
where: QueryCondition;
|
|
@@ -2620,6 +2726,7 @@ interface DeleteManySpec<TModel = unknown> {
|
|
|
2620
2726
|
interface AggregateSpec<TModel = unknown> {
|
|
2621
2727
|
target: QueryTarget<TModel>;
|
|
2622
2728
|
where?: QueryCondition;
|
|
2729
|
+
relationFilters?: RelationFilterSpec[];
|
|
2623
2730
|
aggregate: AggregateSelection;
|
|
2624
2731
|
softDeleteMode?: SoftDeleteQueryMode;
|
|
2625
2732
|
}
|
|
@@ -2634,28 +2741,55 @@ interface AdapterTransactionContext {
|
|
|
2634
2741
|
maxWait?: number;
|
|
2635
2742
|
timeout?: number;
|
|
2636
2743
|
}
|
|
2744
|
+
interface AdapterModelFieldStructure {
|
|
2745
|
+
name: string;
|
|
2746
|
+
type: string;
|
|
2747
|
+
nullable: boolean;
|
|
2748
|
+
}
|
|
2749
|
+
interface AdapterModelStructure {
|
|
2750
|
+
name?: string;
|
|
2751
|
+
table: string;
|
|
2752
|
+
fields: AdapterModelFieldStructure[];
|
|
2753
|
+
}
|
|
2754
|
+
interface AdapterModelIntrospectionOptions {
|
|
2755
|
+
tables?: string[];
|
|
2756
|
+
}
|
|
2637
2757
|
interface DatabaseAdapter {
|
|
2638
2758
|
readonly capabilities?: AdapterCapabilities;
|
|
2639
2759
|
select: <TModel = unknown>(spec: SelectSpec<TModel>) => Promise<DatabaseRows>;
|
|
2640
2760
|
selectOne: <TModel = unknown>(spec: SelectSpec<TModel>) => Promise<DatabaseRow | null>;
|
|
2641
2761
|
insert: <TModel = unknown>(spec: InsertSpec<TModel>) => Promise<DatabaseRow>;
|
|
2642
2762
|
insertMany?: <TModel = unknown>(spec: InsertManySpec<TModel>) => Promise<number>;
|
|
2763
|
+
upsert?: <TModel = unknown>(spec: UpsertSpec<TModel>) => Promise<number>;
|
|
2643
2764
|
update: <TModel = unknown>(spec: UpdateSpec<TModel>) => Promise<DatabaseRow | null>;
|
|
2765
|
+
updateFirst?: <TModel = unknown>(spec: UpdateSpec<TModel>) => Promise<DatabaseRow | null>;
|
|
2644
2766
|
updateMany?: <TModel = unknown>(spec: UpdateManySpec<TModel>) => Promise<number>;
|
|
2645
2767
|
delete: <TModel = unknown>(spec: DeleteSpec<TModel>) => Promise<DatabaseRow | null>;
|
|
2768
|
+
deleteFirst?: <TModel = unknown>(spec: DeleteSpec<TModel>) => Promise<DatabaseRow | null>;
|
|
2646
2769
|
deleteMany?: <TModel = unknown>(spec: DeleteManySpec<TModel>) => Promise<number>;
|
|
2647
2770
|
count: <TModel = unknown>(spec: AggregateSpec<TModel>) => Promise<number>;
|
|
2648
2771
|
exists?: <TModel = unknown>(spec: SelectSpec<TModel>) => Promise<boolean>;
|
|
2649
2772
|
loadRelations?: <TModel = unknown>(spec: RelationLoadSpec<TModel>) => Promise<void>;
|
|
2773
|
+
introspectModels?: (options?: AdapterModelIntrospectionOptions) => Promise<AdapterModelStructure[]>;
|
|
2650
2774
|
transaction: <TResult = unknown>(callback: (adapter: DatabaseAdapter) => TResult | Promise<TResult>, context?: AdapterTransactionContext) => Promise<TResult>;
|
|
2651
2775
|
}
|
|
2652
2776
|
//#endregion
|
|
2653
2777
|
//#region src/adapters/KyselyDatabaseAdapter.d.ts
|
|
2654
2778
|
type KyselyExecutor = Kysely<any> | Transaction<any>;
|
|
2779
|
+
type KyselyTableMapping = Record<string, string>;
|
|
2780
|
+
/**
|
|
2781
|
+
* Database adapter implementation for Kysely, allowing Arkorm to execute queries using Kysely
|
|
2782
|
+
* as the underlying query builder and executor.
|
|
2783
|
+
*
|
|
2784
|
+
* @author Legacy (3m1n3nc3)
|
|
2785
|
+
* @since 2.0.0-next.0
|
|
2786
|
+
*/
|
|
2655
2787
|
declare class KyselyDatabaseAdapter implements DatabaseAdapter {
|
|
2656
2788
|
private readonly db;
|
|
2789
|
+
private readonly mapping;
|
|
2657
2790
|
readonly capabilities: AdapterCapabilities;
|
|
2658
|
-
constructor(db: KyselyExecutor);
|
|
2791
|
+
constructor(db: KyselyExecutor, mapping?: KyselyTableMapping);
|
|
2792
|
+
private introspectionTypeToTs;
|
|
2659
2793
|
private resolveTable;
|
|
2660
2794
|
private resolvePrimaryKey;
|
|
2661
2795
|
private mapColumn;
|
|
@@ -2670,23 +2804,146 @@ declare class KyselyDatabaseAdapter implements DatabaseAdapter {
|
|
|
2670
2804
|
private buildWhereCondition;
|
|
2671
2805
|
private buildWhereClause;
|
|
2672
2806
|
private buildPaginationClause;
|
|
2807
|
+
private buildColumnReference;
|
|
2808
|
+
private buildRelatedTargetFromRelation;
|
|
2809
|
+
private resolveMappedTable;
|
|
2810
|
+
private buildBelongsToManyJoinSource;
|
|
2811
|
+
private buildThroughJoinSource;
|
|
2812
|
+
private buildRelatedJoinCondition;
|
|
2813
|
+
private combineConditions;
|
|
2814
|
+
private buildRelationFilterExpression;
|
|
2815
|
+
private buildRelationFilterCondition;
|
|
2816
|
+
private buildQueryFilterCondition;
|
|
2817
|
+
private buildRelationAggregateSelectList;
|
|
2818
|
+
private buildCombinedWhereClause;
|
|
2819
|
+
private buildSingleRowTargetCte;
|
|
2673
2820
|
private assertNoRelationLoads;
|
|
2821
|
+
/**
|
|
2822
|
+
* Selects records from the database matching the specified criteria and returns
|
|
2823
|
+
* them as an array of database rows.
|
|
2824
|
+
*
|
|
2825
|
+
* @param spec The specification defining the selection criteria.
|
|
2826
|
+
* @returns A promise that resolves to an array of database rows.
|
|
2827
|
+
*/
|
|
2674
2828
|
select<TModel = unknown>(spec: SelectSpec<TModel>): Promise<DatabaseRow[]>;
|
|
2829
|
+
/**
|
|
2830
|
+
* Selects a single record from the database matching the specified criteria and returns it as
|
|
2831
|
+
* a database row. If multiple records match the criteria, only the first one is returned.
|
|
2832
|
+
* If no records match, null is returned.
|
|
2833
|
+
*
|
|
2834
|
+
* @param spec The specification defining the selection criteria.
|
|
2835
|
+
* @returns A promise that resolves to a database row or null if no records match.
|
|
2836
|
+
*/
|
|
2675
2837
|
selectOne<TModel = unknown>(spec: SelectSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2838
|
+
/**
|
|
2839
|
+
* Inserts a new record into the database with the specified values and returns the
|
|
2840
|
+
* inserted record as a database row.
|
|
2841
|
+
*
|
|
2842
|
+
* @param spec
|
|
2843
|
+
* @returns
|
|
2844
|
+
*/
|
|
2676
2845
|
insert<TModel = unknown>(spec: InsertSpec<TModel>): Promise<DatabaseRow>;
|
|
2846
|
+
/**
|
|
2847
|
+
* Inserts multiple records into the database with the specified values and returns the number
|
|
2848
|
+
* of records successfully inserted.
|
|
2849
|
+
*
|
|
2850
|
+
* @param spec The specification defining the values to be inserted.
|
|
2851
|
+
* @returns A promise that resolves to the number of records successfully inserted.
|
|
2852
|
+
*/
|
|
2677
2853
|
insertMany<TModel = unknown>(spec: InsertManySpec<TModel>): Promise<number>;
|
|
2854
|
+
upsert<TModel = unknown>(spec: UpsertSpec<TModel>): Promise<number>;
|
|
2855
|
+
/**
|
|
2856
|
+
* Updates records in the database matching the specified criteria with the given values
|
|
2857
|
+
* and returns the updated record as a database row.
|
|
2858
|
+
*
|
|
2859
|
+
* @param spec The specification defining the update criteria and values.
|
|
2860
|
+
* @returns A promise that resolves to the updated record as a database row, or null if no records match the criteria.
|
|
2861
|
+
*/
|
|
2678
2862
|
update<TModel = unknown>(spec: UpdateSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2863
|
+
/**
|
|
2864
|
+
* Updates a single record in the database matching the specified criteria with the given values.
|
|
2865
|
+
*
|
|
2866
|
+
* @param spec
|
|
2867
|
+
* @returns
|
|
2868
|
+
*/
|
|
2869
|
+
updateFirst<TModel = unknown>(spec: UpdateSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2870
|
+
/**
|
|
2871
|
+
* Updates multiple records in the database matching the specified criteria with the
|
|
2872
|
+
* given values and returns the number of records successfully updated.
|
|
2873
|
+
*
|
|
2874
|
+
* @param spec The specification defining the update criteria and values.
|
|
2875
|
+
* @returns A promise that resolves to the number of records successfully updated.
|
|
2876
|
+
*/
|
|
2679
2877
|
updateMany<TModel = unknown>(spec: UpdateManySpec<TModel>): Promise<number>;
|
|
2878
|
+
/**
|
|
2879
|
+
* Deletes records from the database matching the specified criteria and returns the
|
|
2880
|
+
* deleted record as a database row.
|
|
2881
|
+
*
|
|
2882
|
+
* @param spec The specification defining the delete criteria.
|
|
2883
|
+
* @returns A promise that resolves to the deleted record as a database row, or null if no records match the criteria.
|
|
2884
|
+
*/
|
|
2680
2885
|
delete<TModel = unknown>(spec: DeleteSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2886
|
+
/**
|
|
2887
|
+
* Deletes a single record from the database matching the specified criteria and returns it as a database row.
|
|
2888
|
+
*
|
|
2889
|
+
* @param spec
|
|
2890
|
+
* @returns
|
|
2891
|
+
*/
|
|
2892
|
+
deleteFirst<TModel = unknown>(spec: DeleteSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2893
|
+
/**
|
|
2894
|
+
* Deletes multiple records from the database matching the specified criteria and
|
|
2895
|
+
* returns the number of records successfully deleted.
|
|
2896
|
+
*
|
|
2897
|
+
* @param spec The specification defining the delete criteria.
|
|
2898
|
+
* @returns A promise that resolves to the number of records successfully deleted.
|
|
2899
|
+
*/
|
|
2681
2900
|
deleteMany<TModel = unknown>(spec: DeleteManySpec<TModel>): Promise<number>;
|
|
2901
|
+
/**
|
|
2902
|
+
* Counts the number of records in the database matching the specified criteria and returns
|
|
2903
|
+
* the count as a number.
|
|
2904
|
+
*
|
|
2905
|
+
* @param spec The specification defining the count criteria.
|
|
2906
|
+
* @returns A promise that resolves to the number of records matching the criteria.
|
|
2907
|
+
*/
|
|
2682
2908
|
count<TModel = unknown>(spec: AggregateSpec<TModel>): Promise<number>;
|
|
2909
|
+
/**
|
|
2910
|
+
* Checks for the existence of records matching the specified criteria.
|
|
2911
|
+
*
|
|
2912
|
+
* @param spec The specification defining the existence criteria.
|
|
2913
|
+
* @returns A promise that resolves to a boolean indicating whether any records match the criteria.
|
|
2914
|
+
*/
|
|
2683
2915
|
exists<TModel = unknown>(spec: SelectSpec<TModel>): Promise<boolean>;
|
|
2916
|
+
introspectModels(options?: AdapterModelIntrospectionOptions): Promise<AdapterModelStructure[]>;
|
|
2917
|
+
/**
|
|
2918
|
+
* Executes a series of database operations within a transaction.
|
|
2919
|
+
* The provided callback function is called with a new instance of the
|
|
2920
|
+
* KyselyDatabaseAdapter that is bound to the transaction context.
|
|
2921
|
+
*
|
|
2922
|
+
* @param callback The callback function containing the database operations to be executed within the transaction.
|
|
2923
|
+
* @param context The transaction context specifying options such as read-only mode and isolation level.
|
|
2924
|
+
* @returns A promise that resolves to the result of the callback function.
|
|
2925
|
+
*/
|
|
2684
2926
|
transaction<TResult = unknown>(callback: (adapter: DatabaseAdapter) => TResult | Promise<TResult>, context?: AdapterTransactionContext): Promise<TResult>;
|
|
2685
2927
|
}
|
|
2686
|
-
|
|
2928
|
+
/**
|
|
2929
|
+
* Factory function to create a KyselyDatabaseAdapter instance with the given Kysely executor
|
|
2930
|
+
* and optional table name mapping.
|
|
2931
|
+
*
|
|
2932
|
+
* @param db The Kysely executor to be used by the adapter.
|
|
2933
|
+
* @param mapping Optional table name mapping for the adapter.
|
|
2934
|
+
* @returns A new instance of KyselyDatabaseAdapter.
|
|
2935
|
+
*/
|
|
2936
|
+
declare const createKyselyAdapter: (db: KyselyExecutor, mapping?: KyselyTableMapping) => KyselyDatabaseAdapter;
|
|
2687
2937
|
//#endregion
|
|
2688
2938
|
//#region src/adapters/PrismaDatabaseAdapter.d.ts
|
|
2689
2939
|
type PrismaDelegateNameMapping = Record<string, string>;
|
|
2940
|
+
/**
|
|
2941
|
+
* Database adapter implementation for Prisma, allowing Arkorm to execute queries using Prisma
|
|
2942
|
+
* as the underlying query builder and executor.
|
|
2943
|
+
*
|
|
2944
|
+
* @author Legacy (3m1n3nc3)
|
|
2945
|
+
* @since 2.0.0-next.0
|
|
2946
|
+
*/
|
|
2690
2947
|
declare class PrismaDatabaseAdapter implements DatabaseAdapter {
|
|
2691
2948
|
private readonly prisma;
|
|
2692
2949
|
private readonly mapping;
|
|
@@ -2696,27 +2953,121 @@ declare class PrismaDatabaseAdapter implements DatabaseAdapter {
|
|
|
2696
2953
|
private hasTransactionSupport;
|
|
2697
2954
|
private normalizeCandidate;
|
|
2698
2955
|
private unique;
|
|
2956
|
+
private runtimeModelTypeToTs;
|
|
2957
|
+
private getRuntimeDataModel;
|
|
2699
2958
|
private toQuerySelect;
|
|
2700
2959
|
private toQueryOrderBy;
|
|
2701
2960
|
private toComparisonWhere;
|
|
2702
2961
|
private toQueryWhere;
|
|
2703
2962
|
private buildFindArgs;
|
|
2704
2963
|
private toQueryInclude;
|
|
2964
|
+
introspectModels(options?: AdapterModelIntrospectionOptions): Promise<AdapterModelStructure[]>;
|
|
2705
2965
|
private resolveDelegate;
|
|
2966
|
+
/**
|
|
2967
|
+
* @todo Implement relationLoads by performing separate queries and merging results
|
|
2968
|
+
* in-memory, since Prisma does not support nested reads with constraints, ordering, or
|
|
2969
|
+
* pagination on related models as of now.
|
|
2970
|
+
*
|
|
2971
|
+
* @param spec
|
|
2972
|
+
* @returns
|
|
2973
|
+
*/
|
|
2706
2974
|
select<TModel = unknown>(spec: SelectSpec<TModel>): Promise<DatabaseRow[]>;
|
|
2975
|
+
/**
|
|
2976
|
+
* Selects a single record matching the specified criteria.
|
|
2977
|
+
*
|
|
2978
|
+
* @param spec
|
|
2979
|
+
* @returns
|
|
2980
|
+
*/
|
|
2707
2981
|
selectOne<TModel = unknown>(spec: SelectSpec<TModel>): Promise<DatabaseRow | null>;
|
|
2982
|
+
/**
|
|
2983
|
+
* Inserts a single record into the database and returns the created record.
|
|
2984
|
+
*
|
|
2985
|
+
* @param spec
|
|
2986
|
+
* @returns
|
|
2987
|
+
*/
|
|
2708
2988
|
insert<TModel = unknown>(spec: InsertSpec<TModel>): Promise<DatabaseRow>;
|
|
2989
|
+
/**
|
|
2990
|
+
* Inserts multiple records into the database.
|
|
2991
|
+
*
|
|
2992
|
+
* @param spec
|
|
2993
|
+
* @returns
|
|
2994
|
+
*/
|
|
2709
2995
|
insertMany<TModel = unknown>(spec: InsertManySpec<TModel>): Promise<number>;
|
|
2996
|
+
/**
|
|
2997
|
+
* Updates a single record matching the specified criteria and returns the updated record.
|
|
2998
|
+
*
|
|
2999
|
+
* @param spec
|
|
3000
|
+
* @returns
|
|
3001
|
+
*/
|
|
2710
3002
|
update<TModel = unknown>(spec: UpdateSpec<TModel>): Promise<DatabaseRow | null>;
|
|
3003
|
+
/**
|
|
3004
|
+
* Updates multiple records matching the specified criteria.
|
|
3005
|
+
*
|
|
3006
|
+
* @param spec
|
|
3007
|
+
* @returns
|
|
3008
|
+
*/
|
|
2711
3009
|
updateMany<TModel = unknown>(spec: UpdateManySpec<TModel>): Promise<number>;
|
|
3010
|
+
/**
|
|
3011
|
+
* Deletes a single record matching the specified criteria and returns the deleted record.
|
|
3012
|
+
*
|
|
3013
|
+
* @param spec
|
|
3014
|
+
* @returns
|
|
3015
|
+
*/
|
|
2712
3016
|
delete<TModel = unknown>(spec: DeleteSpec<TModel>): Promise<DatabaseRow | null>;
|
|
3017
|
+
/**
|
|
3018
|
+
* Deletes multiple records matching the specified criteria.
|
|
3019
|
+
*
|
|
3020
|
+
* @param spec
|
|
3021
|
+
* @returns
|
|
3022
|
+
*/
|
|
2713
3023
|
deleteMany<TModel = unknown>(spec: DeleteManySpec<TModel>): Promise<number>;
|
|
3024
|
+
/**
|
|
3025
|
+
* Counts the number of records matching the specified criteria.
|
|
3026
|
+
*
|
|
3027
|
+
* @param spec
|
|
3028
|
+
* @returns
|
|
3029
|
+
*/
|
|
2714
3030
|
count<TModel = unknown>(spec: AggregateSpec<TModel>): Promise<number>;
|
|
3031
|
+
/**
|
|
3032
|
+
* Checks for the existence of records matching the specified criteria.
|
|
3033
|
+
*
|
|
3034
|
+
* @param spec
|
|
3035
|
+
* @returns
|
|
3036
|
+
*/
|
|
2715
3037
|
exists<TModel = unknown>(spec: SelectSpec<TModel>): Promise<boolean>;
|
|
3038
|
+
/**
|
|
3039
|
+
* Loads related models for a batch of parent records based on the specified relation load plans.
|
|
3040
|
+
*
|
|
3041
|
+
* @param _spec
|
|
3042
|
+
*/
|
|
2716
3043
|
loadRelations<TModel = unknown>(_spec: RelationLoadSpec<TModel>): Promise<void>;
|
|
3044
|
+
/**
|
|
3045
|
+
* Executes a series of database operations within a transaction.
|
|
3046
|
+
* If the underlying Prisma client does not support transactions, an exception is thrown.
|
|
3047
|
+
*
|
|
3048
|
+
* @param callback
|
|
3049
|
+
* @param context
|
|
3050
|
+
* @returns
|
|
3051
|
+
*/
|
|
2717
3052
|
transaction<TResult = unknown>(callback: (adapter: DatabaseAdapter) => TResult | Promise<TResult>, context?: AdapterTransactionContext): Promise<TResult>;
|
|
2718
3053
|
}
|
|
3054
|
+
/**
|
|
3055
|
+
* Factory function to create a PrismaDatabaseAdapter instance with the given
|
|
3056
|
+
* Prisma client and optional delegate name mapping.
|
|
3057
|
+
*
|
|
3058
|
+
* @param prisma The Prisma client instance to be used by the adapter.
|
|
3059
|
+
* @param mapping Optional mapping of delegate names.
|
|
3060
|
+
* @returns A new instance of PrismaDatabaseAdapter.
|
|
3061
|
+
*/
|
|
2719
3062
|
declare const createPrismaDatabaseAdapter: (prisma: PrismaClientLike, mapping?: PrismaDelegateNameMapping) => PrismaDatabaseAdapter;
|
|
3063
|
+
/**
|
|
3064
|
+
* Alias for createPrismaDatabaseAdapter to maintain backward compatibility with
|
|
3065
|
+
* previous versions of Arkorm that exported the adapter factory under a different name.
|
|
3066
|
+
*
|
|
3067
|
+
* @param prisma The Prisma client instance to be used by the adapter.
|
|
3068
|
+
* @param mapping Optional mapping of delegate names.
|
|
3069
|
+
* @returns A new instance of PrismaDatabaseAdapter.
|
|
3070
|
+
*/
|
|
2720
3071
|
declare const createPrismaCompatibilityAdapter: (prisma: PrismaClientLike, mapping?: PrismaDelegateNameMapping) => PrismaDatabaseAdapter;
|
|
2721
3072
|
//#endregion
|
|
2722
3073
|
//#region src/Attribute.d.ts
|
|
@@ -2736,6 +3087,14 @@ declare class Attribute<TGet = unknown, TSet = unknown> {
|
|
|
2736
3087
|
declare function resolveCast(definition: CastDefinition): CastHandler;
|
|
2737
3088
|
//#endregion
|
|
2738
3089
|
//#region src/cli/CliApp.d.ts
|
|
3090
|
+
type SyncedModelsResult = {
|
|
3091
|
+
source: 'adapter' | 'prisma';
|
|
3092
|
+
schemaPath?: string;
|
|
3093
|
+
modelsDir: string;
|
|
3094
|
+
total: number;
|
|
3095
|
+
updated: string[];
|
|
3096
|
+
skipped: string[];
|
|
3097
|
+
};
|
|
2739
3098
|
/**
|
|
2740
3099
|
* Main application class for the Arkormˣ CLI.
|
|
2741
3100
|
*
|
|
@@ -2918,6 +3277,8 @@ declare class CliApp {
|
|
|
2918
3277
|
private collectEnumReferencesFromNode;
|
|
2919
3278
|
private collectEnumReferences;
|
|
2920
3279
|
private syncPrismaEnumImports;
|
|
3280
|
+
private parseModelSyncSource;
|
|
3281
|
+
private syncModelFiles;
|
|
2921
3282
|
/**
|
|
2922
3283
|
* Parse Prisma enum definitions from a schema and return their member names.
|
|
2923
3284
|
*
|
|
@@ -2953,6 +3314,10 @@ declare class CliApp {
|
|
|
2953
3314
|
* @returns An object containing the updated content and a flag indicating if it was updated.
|
|
2954
3315
|
*/
|
|
2955
3316
|
private syncModelDeclarations;
|
|
3317
|
+
syncModels(options?: {
|
|
3318
|
+
schemaPath?: string;
|
|
3319
|
+
modelsDir?: string;
|
|
3320
|
+
}): Promise<SyncedModelsResult>;
|
|
2956
3321
|
/**
|
|
2957
3322
|
* Sync model attribute declarations in model files based on the Prisma schema.
|
|
2958
3323
|
* This method reads the Prisma schema to extract model definitions and their
|
|
@@ -4055,6 +4420,7 @@ declare const runMigrationWithPrisma: (migration: Migration | (new () => Migrati
|
|
|
4055
4420
|
* @returns The same configuration object.
|
|
4056
4421
|
*/
|
|
4057
4422
|
declare const defineConfig: (config: ArkormConfig) => ArkormConfig;
|
|
4423
|
+
declare const bindAdapterToModels: (adapter: DatabaseAdapter, models: AdapterBindableModel[]) => DatabaseAdapter;
|
|
4058
4424
|
/**
|
|
4059
4425
|
* Get the user-provided ArkORM configuration.
|
|
4060
4426
|
*
|
|
@@ -4068,7 +4434,7 @@ declare const getUserConfig: GetUserConfig;
|
|
|
4068
4434
|
* @param prisma
|
|
4069
4435
|
* @param mapping
|
|
4070
4436
|
*/
|
|
4071
|
-
declare const configureArkormRuntime: (prisma
|
|
4437
|
+
declare const configureArkormRuntime: (prisma?: ClientResolver, options?: Omit<ArkormConfig, "prisma">) => void;
|
|
4072
4438
|
/**
|
|
4073
4439
|
* Reset the ArkORM runtime configuration.
|
|
4074
4440
|
* This is primarily intended for testing purposes.
|
|
@@ -4097,6 +4463,7 @@ declare const getDefaultStubsPath: () => string;
|
|
|
4097
4463
|
* @returns
|
|
4098
4464
|
*/
|
|
4099
4465
|
declare const getRuntimePrismaClient: () => PrismaClientLike | undefined;
|
|
4466
|
+
declare const getRuntimeAdapter: () => DatabaseAdapter | undefined;
|
|
4100
4467
|
declare const getActiveTransactionClient: () => PrismaClientLike | undefined;
|
|
4101
4468
|
declare const isTransactionCapableClient: (value: unknown) => value is PrismaTransactionCapableClient;
|
|
4102
4469
|
declare const runArkormTransaction: <TResult>(callback: PrismaTransactionCallback<TResult>, options?: PrismaTransactionOptions) => Promise<TResult>;
|
|
@@ -4127,6 +4494,8 @@ type PrismaDelegateMap<TClient extends PrismaClientLike> = { [K in keyof TClient
|
|
|
4127
4494
|
* Create an adapter to convert a Prisma client instance into a format
|
|
4128
4495
|
* compatible with ArkORM's expectations.
|
|
4129
4496
|
*
|
|
4497
|
+
* @deprecated Prefer createPrismaDatabaseAdapter(prisma) for runtime usage.
|
|
4498
|
+
*
|
|
4130
4499
|
* @param prisma The Prisma client instance to adapt.
|
|
4131
4500
|
* @param mapping An optional mapping of Prisma delegate names to ArkORM delegate names.
|
|
4132
4501
|
* @returns A record of adapted Prisma delegates compatible with ArkORM.
|
|
@@ -4135,6 +4504,9 @@ declare function createPrismaAdapter(prisma: PrismaClientLike): Record<string, P
|
|
|
4135
4504
|
/**
|
|
4136
4505
|
* Create a delegate mapping record for Model.setClient() from a Prisma client.
|
|
4137
4506
|
*
|
|
4507
|
+
* @deprecated Prefer createPrismaDatabaseAdapter(prisma, mapping) and bind the
|
|
4508
|
+
* resulting adapter with Model.setAdapter(...).
|
|
4509
|
+
*
|
|
4138
4510
|
* @param prisma The Prisma client instance.
|
|
4139
4511
|
* @param mapping Optional mapping of Arkormˣ delegate names to Prisma delegate names.
|
|
4140
4512
|
* @returns A delegate map keyed by Arkormˣ delegate names.
|
|
@@ -4171,4 +4543,4 @@ declare class URLDriver {
|
|
|
4171
4543
|
url(page: number): string;
|
|
4172
4544
|
}
|
|
4173
4545
|
//#endregion
|
|
4174
|
-
export { AdapterCapabilities, AdapterCapability, AdapterTransactionContext, AggregateOperation, AggregateSelection, AggregateSpec, AppliedMigrationEntry, AppliedMigrationRun, AppliedMigrationsState, ArkormCollection, ArkormConfig, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, BelongsToManyRelationMetadata, BelongsToRelationMetadata, CastDefinition, CastHandler, CastMap, CastType, CliApp, ClientResolver, ColumnMap, DatabaseAdapter, DatabasePrimitive, DatabaseRow, DatabaseRows, DatabaseValue, DelegateCreateData, DelegateFindManyArgs, DelegateForModelSchema, DelegateInclude, DelegateOrderBy, DelegateRow, DelegateRows, DelegateSelect, DelegateUniqueWhere, DelegateUpdateArgs, DelegateUpdateData, DelegateWhere, DeleteManySpec, DeleteSpec, EagerLoadConstraint, EagerLoadMap, EnumBuilder, FactoryAttributes, FactoryDefinition, FactoryModelConstructor, FactoryState, ForeignKeyBuilder, GenerateMigrationOptions, GeneratedMigrationFile, GetUserConfig, GlobalScope, HasManyRelationMetadata, HasManyThroughRelationMetadata, HasOneRelationMetadata, HasOneThroughRelationMetadata, InitCommand, InlineFactory, InsertManySpec, InsertSpec, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationClass, MigrationHistoryCommand, MigrationInstanceLike, MissingDelegateException, Model, ModelAttributes, ModelAttributesOf, ModelEventDispatcher, ModelEventHandler, ModelEventHandlerConstructor, ModelEventListener, ModelEventName, ModelFactory, ModelLifecycleState, ModelMetadata, ModelNotFoundException, ModelStatic, ModelsSyncCommand, MorphManyRelationMetadata, MorphOneRelationMetadata, MorphToManyRelationMetadata, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, PaginationCurrentPageResolver, PaginationMeta, PaginationOptions, PaginationURLDriver, PaginationURLDriverFactory, Paginator, PrismaClientLike, PrismaDatabaseAdapter, PrismaDelegateLike, PrismaDelegateMap, PrismaDelegateNameMapping, PrismaFindManyArgsLike, PrismaLikeInclude, PrismaLikeOrderBy, PrismaLikeScalarFilter, PrismaLikeSelect, PrismaLikeSortOrder, PrismaLikeWhereInput, PrismaMigrationWorkflowOptions, PrismaSchemaSyncOptions, PrismaTransactionCallback, PrismaTransactionCapableClient, PrismaTransactionOptions, QueryBuilder, QueryComparisonCondition, QueryComparisonOperator, QueryCondition, QueryConstraintException, QueryGroupCondition, QueryLogicalOperator, QueryNotCondition, QueryOrderBy, QueryRawCondition, QuerySelectColumn, QueryTarget, RelatedModelClass, RelationAggregateSpec, RelationColumnLookupSpec, RelationConstraint, RelationDefaultResolver, RelationDefaultValue, RelationFilterSpec, RelationLoadPlan, RelationLoadSpec, RelationMetadata, RelationMetadataProvider, RelationMetadataType, RelationResolutionException, RelationTableLookupSpec, RelationshipModelStatic, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, SchemaColumn, SchemaColumnType, SchemaForeignKey, SchemaForeignKeyAction, SchemaIndex, SchemaOperation, SchemaTableAlterOperation, SchemaTableCreateOperation, SchemaTableDropOperation, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, SelectSpec, Serializable, SimplePaginationMeta, SoftDeleteConfig, SoftDeleteQueryMode, SortDirection, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, UpdateManySpec, UpdateSpec, 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 };
|
|
4546
|
+
export { AdapterBindableModel, AdapterCapabilities, AdapterCapability, AdapterModelFieldStructure, AdapterModelIntrospectionOptions, AdapterModelStructure, AdapterTransactionContext, AggregateOperation, AggregateSelection, AggregateSpec, AppliedMigrationEntry, AppliedMigrationRun, AppliedMigrationsState, ArkormBootContext, ArkormCollection, ArkormConfig, ArkormErrorContext, ArkormException, Attribute, AttributeCreateInput, AttributeOptions, AttributeOrderBy, AttributeSchemaDelegate, AttributeSelect, AttributeUpdateInput, AttributeWhereInput, BelongsToManyRelationMetadata, BelongsToRelationMetadata, CastDefinition, CastHandler, CastMap, CastType, CliApp, ClientResolver, ColumnMap, DatabaseAdapter, DatabasePrimitive, DatabaseRow, DatabaseRows, DatabaseValue, DelegateCreateData, DelegateFindManyArgs, DelegateForModelSchema, DelegateInclude, DelegateOrderBy, DelegateRow, DelegateRows, DelegateSelect, DelegateUniqueWhere, DelegateUpdateArgs, DelegateUpdateData, DelegateWhere, DeleteManySpec, DeleteSpec, EagerLoadConstraint, EagerLoadMap, EnumBuilder, FactoryAttributes, FactoryDefinition, FactoryModelConstructor, FactoryState, ForeignKeyBuilder, GenerateMigrationOptions, GeneratedMigrationFile, GetUserConfig, GlobalScope, HasManyRelationMetadata, HasManyThroughRelationMetadata, HasOneRelationMetadata, HasOneThroughRelationMetadata, InitCommand, InlineFactory, InsertManySpec, InsertSpec, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationClass, MigrationHistoryCommand, MigrationInstanceLike, MissingDelegateException, Model, ModelAttributes, ModelAttributesOf, ModelCreateData, ModelEventDispatcher, ModelEventHandler, ModelEventHandlerConstructor, ModelEventListener, ModelEventName, ModelFactory, ModelLifecycleState, ModelMetadata, ModelNotFoundException, ModelStatic, ModelUpdateData, ModelsSyncCommand, MorphManyRelationMetadata, MorphOneRelationMetadata, MorphToManyRelationMetadata, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, PaginationCurrentPageResolver, PaginationMeta, PaginationOptions, PaginationURLDriver, PaginationURLDriverFactory, Paginator, PrismaClientLike, PrismaDatabaseAdapter, PrismaDelegateLike, PrismaDelegateMap, PrismaDelegateNameMapping, PrismaFindManyArgsLike, PrismaLikeInclude, PrismaLikeOrderBy, PrismaLikeScalarFilter, PrismaLikeSelect, PrismaLikeSortOrder, PrismaLikeWhereInput, PrismaMigrationWorkflowOptions, PrismaSchemaSyncOptions, PrismaTransactionCallback, PrismaTransactionCapableClient, PrismaTransactionOptions, QueryBuilder, QueryComparisonCondition, QueryComparisonOperator, QueryCondition, QueryConstraintException, QueryGroupCondition, QueryLogicalOperator, QueryNotCondition, QueryOrderBy, QueryRawCondition, QuerySelectColumn, QueryTarget, RelatedModelClass, RelationAggregateSpec, RelationColumnLookupSpec, RelationConstraint, RelationDefaultResolver, RelationDefaultValue, RelationFilterSpec, RelationLoadPlan, RelationLoadSpec, RelationMetadata, RelationMetadataProvider, RelationMetadataType, RelationResolutionException, RelationTableLookupSpec, RelationshipModelStatic, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, SchemaColumn, SchemaColumnType, SchemaForeignKey, SchemaForeignKeyAction, SchemaIndex, SchemaOperation, SchemaTableAlterOperation, SchemaTableCreateOperation, SchemaTableDropOperation, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, SelectSpec, Serializable, SimplePaginationMeta, SoftDeleteConfig, SoftDeleteQueryMode, SortDirection, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, UpdateManySpec, UpdateSpec, UpsertSpec, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, bindAdapterToModels, 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, getRuntimeAdapter, 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 };
|