arkormx 2.9.2 → 2.9.4
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 +18 -24
- package/dist/cli.mjs +492 -338
- package/dist/{index-BDnvZR_9.d.cts → index-CJ7yJR43.d.mts} +80 -17
- package/dist/{index-CmVlF-_5.d.mts → index-CgzhC61F.d.cts} +80 -17
- package/dist/index.cjs +528 -515
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +529 -516
- package/dist/relationship/index.cjs +1 -1
- package/dist/relationship/index.d.cts +1 -1
- package/dist/relationship/index.d.mts +1 -1
- package/dist/relationship/index.mjs +1 -1
- package/dist/{relationship-DtNgcxxv.mjs → relationship-CmhzOlEo.mjs} +645 -550
- package/dist/{relationship-BVYP9lU2.cjs → relationship-DGOpcWA0.cjs} +645 -550
- package/package.json +6 -2
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as applyOperationsToPersistedColumnMappingsState, $t as resolvePrismaType, A as getRuntimePrismaClient, An as writeAppliedMigrationsStateToStore, At as buildInverseRelationLine, B as getRegisteredModels, Bt as deriveRelationFieldName, C as getActiveTransactionClient, Cn as markMigrationRun, Ct as applyMigrationRollbackToPrismaSchema, D as getRuntimeDebugHandler, Dn as resolveMigrationStateFilePath, Dt as buildEnumBlock, E as getRuntimeClient, En as removeAppliedMigration, Et as applyOperationsToPrismaSchema, F as loadArkormConfig, Fn as RelationResolutionException, Ft as buildUniqueConstraintLine, G as loadModelsFrom, Gt as formatDefaultValue, H as getRegisteredSeeders, Ht as escapeRegex, I as resetArkormRuntimeForTests, In as ArkormCollection, It as createMigrationTimestamp, J as registerMigrations, Jt as generateMigrationFile, K as loadSeedersFrom, Kt as formatEnumDefaultValue, L as runArkormTransaction, Ln as ArkormException, Lt as deriveCollectionFieldName, M as isDelegateLike, Mn as UnsupportedAdapterFeatureException, Mt as buildModelBlock, N as isQuerySchemaLike, Nn as SetBasedEagerLoader, Nt as buildPrimaryKeyLine, O as getRuntimePaginationCurrentPageResolver, On as supportsDatabaseMigrationState, Ot as buildFieldLine, P as isTransactionCapableClient, Pt as buildRelationLine, Q as resetRuntimeRegistryForTests, Qt as resolveMigrationClassName, R as getRegisteredFactories, Rt as deriveInverseRelationAlias, S as getActiveTransactionAdapter, Sn as markMigrationApplied, St as applyMigrationRollbackToDatabase, T as getRuntimeAdapter, Tn as readAppliedMigrationsStateFromStore, Tt as applyMigrationToPrismaSchema, U as loadFactoriesFrom, Ut as findEnumBlock, V as getRegisteredPaths, Vt as deriveSingularFieldName, W as loadMigrationsFrom, Wt as findModelBlock, X as registerPaths, Xt as pad, Y as registerModels, Yt as getMigrationPlan, Z as registerSeeders, Zt as resolveEnumName, _ as bindAdapterToModels, _n as deleteAppliedMigrationsStateFromStore, _t as PRISMA_ENUM_REGEX, a as HasOneThroughRelation, an as supportsDatabaseReset, at as getPersistedPrimaryKeyGeneration, b as emitRuntimeDebugEvent, bn as getLatestAppliedMigrations, bt as applyCreateTableOperation, c as HasManyRelation, cn as SchemaBuilder, ct as readPersistedColumnMappingsState, d as BelongsToManyRelation, dn as PrimaryKeyGenerationPlanner, dt as resolveColumnMappingsFilePath, en as runMigrationWithPrisma, et as createEmptyPersistedColumnMappingsState, f as Relation, fn as ForeignKeyBuilder, ft as resolvePersistedMetadataFeatures, g as awaitConfiguredModelsRegistration, gn as createEmptyAppliedMigrationsState, gt as PRISMA_ENUM_MEMBER_REGEX, h as URLDriver, hn as computeMigrationChecksum, ht as writePersistedColumnMappingsState, i as MorphManyRelation, in as supportsDatabaseMigrationExecution, it as getPersistedEnumTsType, j as getUserConfig, jn as RuntimeModuleLoader, jt as buildMigrationSource, k as getRuntimePaginationURLDriverFactory, kn as writeAppliedMigrationsState, kt as buildIndexLine, l as BelongsToRelation, ln as EnumBuilder, lt as rebuildPersistedColumnMappingsState, m as Paginator, mn as buildMigrationRunId, mt as validatePersistedMetadataFeaturesForMigrations, n as MorphToManyRelation, nn as stripPrismaSchemaModelsAndEnums, nt as getPersistedColumnMap, o as HasOneRelation, on as toMigrationFileSlug, ot as getPersistedTableMetadata, p as LengthAwarePaginator, pn as buildMigrationIdentity, pt as syncPersistedColumnMappingsFromState, q as registerFactories, qt as formatRelationAction, r as MorphOneRelation, rn as supportsDatabaseCreation, rt as getPersistedEnumMap, s as HasManyThroughRelation, sn as toModelName, st as getPersistedTimestampColumns, t as MorphToRelation, tn as runPrismaCommand, tt as deletePersistedColumnMappingsState, un as TableBuilder, ut as resetPersistedColumnMappingsCache, v as configureArkormRuntime, vn as findAppliedMigration, vt as PRISMA_MODEL_REGEX, w as getDefaultStubsPath, wn as readAppliedMigrationsState, wt as applyMigrationToDatabase, x as ensureArkormConfigLoading, xn as isMigrationApplied, xt as applyDropTableOperation, y as defineConfig, yn as getLastMigrationRun, yt as applyAlterTableOperation, z as getRegisteredMigrations, zt as deriveRelationAlias } from "./relationship-
|
|
1
|
+
import { $ as applyOperationsToPersistedColumnMappingsState, $t as resolvePrismaType, A as getRuntimePrismaClient, An as writeAppliedMigrationsStateToStore, At as buildInverseRelationLine, B as getRegisteredModels, Bt as deriveRelationFieldName, C as getActiveTransactionClient, Cn as markMigrationRun, Ct as applyMigrationRollbackToPrismaSchema, D as getRuntimeDebugHandler, Dn as resolveMigrationStateFilePath, Dt as buildEnumBlock, E as getRuntimeClient, En as removeAppliedMigration, Et as applyOperationsToPrismaSchema, F as loadArkormConfig, Fn as RelationResolutionException, Ft as buildUniqueConstraintLine, G as loadModelsFrom, Gt as formatDefaultValue, H as getRegisteredSeeders, Ht as escapeRegex, I as resetArkormRuntimeForTests, In as ArkormCollection, It as createMigrationTimestamp, J as registerMigrations, Jt as generateMigrationFile, K as loadSeedersFrom, Kt as formatEnumDefaultValue, L as runArkormTransaction, Ln as ArkormException, Lt as deriveCollectionFieldName, M as isDelegateLike, Mn as UnsupportedAdapterFeatureException, Mt as buildModelBlock, N as isQuerySchemaLike, Nn as SetBasedEagerLoader, Nt as buildPrimaryKeyLine, O as getRuntimePaginationCurrentPageResolver, On as supportsDatabaseMigrationState, Ot as buildFieldLine, P as isTransactionCapableClient, Pt as buildRelationLine, Q as resetRuntimeRegistryForTests, Qt as resolveMigrationClassName, R as getRegisteredFactories, Rt as deriveInverseRelationAlias, S as getActiveTransactionAdapter, Sn as markMigrationApplied, St as applyMigrationRollbackToDatabase, T as getRuntimeAdapter, Tn as readAppliedMigrationsStateFromStore, Tt as applyMigrationToPrismaSchema, U as loadFactoriesFrom, Ut as findEnumBlock, V as getRegisteredPaths, Vt as deriveSingularFieldName, W as loadMigrationsFrom, Wt as findModelBlock, X as registerPaths, Xt as pad, Y as registerModels, Yt as getMigrationPlan, Z as registerSeeders, Zt as resolveEnumName, _ as bindAdapterToModels, _n as deleteAppliedMigrationsStateFromStore, _t as PRISMA_ENUM_REGEX, a as HasOneThroughRelation, an as supportsDatabaseReset, at as getPersistedPrimaryKeyGeneration, b as emitRuntimeDebugEvent, bn as getLatestAppliedMigrations, bt as applyCreateTableOperation, c as HasManyRelation, cn as SchemaBuilder, ct as readPersistedColumnMappingsState, d as BelongsToManyRelation, dn as PrimaryKeyGenerationPlanner, dt as resolveColumnMappingsFilePath, en as runMigrationWithPrisma, et as createEmptyPersistedColumnMappingsState, f as Relation, fn as ForeignKeyBuilder, ft as resolvePersistedMetadataFeatures, g as awaitConfiguredModelsRegistration, gn as createEmptyAppliedMigrationsState, gt as PRISMA_ENUM_MEMBER_REGEX, h as URLDriver, hn as computeMigrationChecksum, ht as writePersistedColumnMappingsState, i as MorphManyRelation, in as supportsDatabaseMigrationExecution, it as getPersistedEnumTsType, j as getUserConfig, jn as RuntimeModuleLoader, jt as buildMigrationSource, k as getRuntimePaginationURLDriverFactory, kn as writeAppliedMigrationsState, kt as buildIndexLine, l as BelongsToRelation, ln as EnumBuilder, lt as rebuildPersistedColumnMappingsState, m as Paginator, mn as buildMigrationRunId, mt as validatePersistedMetadataFeaturesForMigrations, n as MorphToManyRelation, nn as stripPrismaSchemaModelsAndEnums, nt as getPersistedColumnMap, o as HasOneRelation, on as toMigrationFileSlug, ot as getPersistedTableMetadata, p as LengthAwarePaginator, pn as buildMigrationIdentity, pt as syncPersistedColumnMappingsFromState, q as registerFactories, qt as formatRelationAction, r as MorphOneRelation, rn as supportsDatabaseCreation, rt as getPersistedEnumMap, s as HasManyThroughRelation, sn as toModelName, st as getPersistedTimestampColumns, t as MorphToRelation, tn as runPrismaCommand, tt as deletePersistedColumnMappingsState, un as TableBuilder, ut as resetPersistedColumnMappingsCache, v as configureArkormRuntime, vn as findAppliedMigration, vt as PRISMA_MODEL_REGEX, w as getDefaultStubsPath, wn as readAppliedMigrationsState, wt as applyMigrationToDatabase, x as ensureArkormConfigLoading, xn as isMigrationApplied, xt as applyDropTableOperation, y as defineConfig, yn as getLastMigrationRun, yt as applyAlterTableOperation, z as getRegisteredMigrations, zt as deriveRelationAlias } from "./relationship-CmhzOlEo.mjs";
|
|
2
2
|
import { Pool } from "pg";
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
5
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "fs";
|
|
6
6
|
import { dirname as dirname$1, extname as extname$1, join as join$1, relative } from "path";
|
|
7
7
|
import { existsSync as existsSync$1, readFileSync as readFileSync$1, readdirSync as readdirSync$1, rmSync as rmSync$1, writeFileSync as writeFileSync$1 } from "node:fs";
|
|
8
|
-
import { str } from "@h3ravel/support";
|
|
8
|
+
import { DateTime, str } from "@h3ravel/support";
|
|
9
9
|
import { sql } from "kysely";
|
|
10
10
|
import { Logger } from "@h3ravel/shared";
|
|
11
11
|
import { Command } from "@h3ravel/musket";
|
|
@@ -33,9 +33,9 @@ var QueryExecutionException = class extends ArkormException {
|
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/adapters/KyselyDatabaseAdapter.ts
|
|
35
35
|
/**
|
|
36
|
-
* Database adapter implementation for Kysely, allowing Arkorm to execute queries using Kysely
|
|
36
|
+
* Database adapter implementation for Kysely, allowing Arkorm to execute queries using Kysely
|
|
37
37
|
* as the underlying query builder and executor.
|
|
38
|
-
*
|
|
38
|
+
*
|
|
39
39
|
* @author Legacy (3m1n3nc3)
|
|
40
40
|
* @since 2.0.0-next.0
|
|
41
41
|
*/
|
|
@@ -364,9 +364,11 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
364
364
|
if (column.type === "integer") return "integer";
|
|
365
365
|
if (column.type === "bigInteger") return "bigint";
|
|
366
366
|
if (column.type === "float") return "double precision";
|
|
367
|
+
if (column.type === "decimal") return `numeric(${column.precision ?? 8}, ${column.scale ?? 2})`;
|
|
367
368
|
if (column.type === "boolean") return "boolean";
|
|
368
369
|
if (column.type === "json") return "jsonb";
|
|
369
370
|
if (column.type === "date") return "date";
|
|
371
|
+
if (column.type === "dateTime") return "timestamp";
|
|
370
372
|
return "timestamptz";
|
|
371
373
|
}
|
|
372
374
|
resolveSchemaColumnDefault(column) {
|
|
@@ -1083,9 +1085,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1083
1085
|
}
|
|
1084
1086
|
}
|
|
1085
1087
|
/**
|
|
1086
|
-
* Selects records from the database matching the specified criteria and returns
|
|
1088
|
+
* Selects records from the database matching the specified criteria and returns
|
|
1087
1089
|
* them as an array of database rows.
|
|
1088
|
-
*
|
|
1090
|
+
*
|
|
1089
1091
|
* @param spec The specification defining the selection criteria.
|
|
1090
1092
|
* @returns A promise that resolves to an array of database rows.
|
|
1091
1093
|
*/
|
|
@@ -1103,10 +1105,10 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1103
1105
|
});
|
|
1104
1106
|
}
|
|
1105
1107
|
/**
|
|
1106
|
-
* Selects a single record from the database matching the specified criteria and returns it as
|
|
1107
|
-
* a database row. If multiple records match the criteria, only the first one is returned.
|
|
1108
|
+
* Selects a single record from the database matching the specified criteria and returns it as
|
|
1109
|
+
* a database row. If multiple records match the criteria, only the first one is returned.
|
|
1108
1110
|
* If no records match, null is returned.
|
|
1109
|
-
*
|
|
1111
|
+
*
|
|
1110
1112
|
* @param spec The specification defining the selection criteria.
|
|
1111
1113
|
* @returns A promise that resolves to a database row or null if no records match.
|
|
1112
1114
|
*/
|
|
@@ -1117,11 +1119,11 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1117
1119
|
}))[0] ?? null;
|
|
1118
1120
|
}
|
|
1119
1121
|
/**
|
|
1120
|
-
* Inserts a new record into the database with the specified values and returns the
|
|
1122
|
+
* Inserts a new record into the database with the specified values and returns the
|
|
1121
1123
|
* inserted record as a database row.
|
|
1122
|
-
*
|
|
1123
|
-
* @param spec
|
|
1124
|
-
* @returns
|
|
1124
|
+
*
|
|
1125
|
+
* @param spec
|
|
1126
|
+
* @returns
|
|
1125
1127
|
*/
|
|
1126
1128
|
async insert(spec) {
|
|
1127
1129
|
const values = this.mapValues(spec.target, spec.values);
|
|
@@ -1140,9 +1142,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1140
1142
|
}, { values: spec.values });
|
|
1141
1143
|
}
|
|
1142
1144
|
/**
|
|
1143
|
-
* Inserts multiple records into the database with the specified values and returns the number
|
|
1144
|
-
* of records successfully inserted.
|
|
1145
|
-
*
|
|
1145
|
+
* Inserts multiple records into the database with the specified values and returns the number
|
|
1146
|
+
* of records successfully inserted.
|
|
1147
|
+
*
|
|
1146
1148
|
* @param spec The specification defining the values to be inserted.
|
|
1147
1149
|
* @returns A promise that resolves to the number of records successfully inserted.
|
|
1148
1150
|
*/
|
|
@@ -1213,11 +1215,11 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1213
1215
|
return spec.values.length;
|
|
1214
1216
|
}
|
|
1215
1217
|
/**
|
|
1216
|
-
* Updates records in the database matching the specified criteria with the given values
|
|
1217
|
-
* and returns the updated record as a database row.
|
|
1218
|
-
*
|
|
1218
|
+
* Updates records in the database matching the specified criteria with the given values
|
|
1219
|
+
* and returns the updated record as a database row.
|
|
1220
|
+
*
|
|
1219
1221
|
* @param spec The specification defining the update criteria and values.
|
|
1220
|
-
* @returns A promise that resolves to the updated record as a database row, or null if no records match the criteria.
|
|
1222
|
+
* @returns A promise that resolves to the updated record as a database row, or null if no records match the criteria.
|
|
1221
1223
|
*/
|
|
1222
1224
|
async update(spec) {
|
|
1223
1225
|
const values = this.mapValues(spec.target, spec.values);
|
|
@@ -1244,9 +1246,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1244
1246
|
}
|
|
1245
1247
|
/**
|
|
1246
1248
|
* Updates a single record in the database matching the specified criteria with the given values.
|
|
1247
|
-
*
|
|
1248
|
-
* @param spec
|
|
1249
|
-
* @returns
|
|
1249
|
+
*
|
|
1250
|
+
* @param spec
|
|
1251
|
+
* @returns
|
|
1250
1252
|
*/
|
|
1251
1253
|
async updateFirst(spec) {
|
|
1252
1254
|
const values = this.mapValues(spec.target, spec.values);
|
|
@@ -1276,9 +1278,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1276
1278
|
});
|
|
1277
1279
|
}
|
|
1278
1280
|
/**
|
|
1279
|
-
* Updates multiple records in the database matching the specified criteria with the
|
|
1281
|
+
* Updates multiple records in the database matching the specified criteria with the
|
|
1280
1282
|
* given values and returns the number of records successfully updated.
|
|
1281
|
-
*
|
|
1283
|
+
*
|
|
1282
1284
|
* @param spec The specification defining the update criteria and values.
|
|
1283
1285
|
* @returns A promise that resolves to the number of records successfully updated.
|
|
1284
1286
|
*/
|
|
@@ -1300,9 +1302,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1300
1302
|
});
|
|
1301
1303
|
}
|
|
1302
1304
|
/**
|
|
1303
|
-
* Deletes records from the database matching the specified criteria and returns the
|
|
1305
|
+
* Deletes records from the database matching the specified criteria and returns the
|
|
1304
1306
|
* deleted record as a database row.
|
|
1305
|
-
*
|
|
1307
|
+
*
|
|
1306
1308
|
* @param spec The specification defining the delete criteria.
|
|
1307
1309
|
* @returns A promise that resolves to the deleted record as a database row, or null if no records match the criteria.
|
|
1308
1310
|
*/
|
|
@@ -1318,9 +1320,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1318
1320
|
}
|
|
1319
1321
|
/**
|
|
1320
1322
|
* Deletes a single record from the database matching the specified criteria and returns it as a database row.
|
|
1321
|
-
*
|
|
1322
|
-
* @param spec
|
|
1323
|
-
* @returns
|
|
1323
|
+
*
|
|
1324
|
+
* @param spec
|
|
1325
|
+
* @returns
|
|
1324
1326
|
*/
|
|
1325
1327
|
async deleteFirst(spec) {
|
|
1326
1328
|
const primaryKey = this.resolvePrimaryKey(spec.target);
|
|
@@ -1337,9 +1339,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1337
1339
|
}, { where: spec.where });
|
|
1338
1340
|
}
|
|
1339
1341
|
/**
|
|
1340
|
-
* Deletes multiple records from the database matching the specified criteria and
|
|
1342
|
+
* Deletes multiple records from the database matching the specified criteria and
|
|
1341
1343
|
* returns the number of records successfully deleted.
|
|
1342
|
-
*
|
|
1344
|
+
*
|
|
1343
1345
|
* @param spec The specification defining the delete criteria.
|
|
1344
1346
|
* @returns A promise that resolves to the number of records successfully deleted.
|
|
1345
1347
|
*/
|
|
@@ -1352,9 +1354,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1352
1354
|
return await this.executeWithDebug("deleteMany", spec.target, statement, (rows) => rows.length, { where: spec.where });
|
|
1353
1355
|
}
|
|
1354
1356
|
/**
|
|
1355
|
-
* Counts the number of records in the database matching the specified criteria and returns
|
|
1357
|
+
* Counts the number of records in the database matching the specified criteria and returns
|
|
1356
1358
|
* the count as a number.
|
|
1357
|
-
*
|
|
1359
|
+
*
|
|
1358
1360
|
* @param spec The specification defining the count criteria.
|
|
1359
1361
|
* @returns A promise that resolves to the number of records matching the criteria.
|
|
1360
1362
|
*/
|
|
@@ -1368,7 +1370,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1368
1370
|
}
|
|
1369
1371
|
/**
|
|
1370
1372
|
* Checks for the existence of records matching the specified criteria.
|
|
1371
|
-
*
|
|
1373
|
+
*
|
|
1372
1374
|
* @param spec The specification defining the existence criteria.
|
|
1373
1375
|
* @returns A promise that resolves to a boolean indicating whether any records match the criteria.
|
|
1374
1376
|
*/
|
|
@@ -1382,9 +1384,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1382
1384
|
}
|
|
1383
1385
|
/**
|
|
1384
1386
|
* Loads relations for the given models based on the specified relation load plans.
|
|
1385
|
-
*
|
|
1387
|
+
*
|
|
1386
1388
|
* @param spec The specification defining the models and their relations to be loaded.
|
|
1387
|
-
* @returns
|
|
1389
|
+
* @returns
|
|
1388
1390
|
*/
|
|
1389
1391
|
async loadRelations(spec) {
|
|
1390
1392
|
if (spec.models.length === 0 || spec.relations.length === 0) return;
|
|
@@ -1520,10 +1522,10 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1520
1522
|
});
|
|
1521
1523
|
}
|
|
1522
1524
|
/**
|
|
1523
|
-
* Executes a series of database operations within a transaction.
|
|
1524
|
-
* The provided callback function is called with a new instance of the
|
|
1525
|
+
* Executes a series of database operations within a transaction.
|
|
1526
|
+
* The provided callback function is called with a new instance of the
|
|
1525
1527
|
* KyselyDatabaseAdapter that is bound to the transaction context.
|
|
1526
|
-
*
|
|
1528
|
+
*
|
|
1527
1529
|
* @param callback The callback function containing the database operations to be executed within the transaction.
|
|
1528
1530
|
* @param context The transaction context specifying options such as read-only mode and isolation level.
|
|
1529
1531
|
* @returns A promise that resolves to the result of the callback function.
|
|
@@ -1538,12 +1540,12 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1538
1540
|
}
|
|
1539
1541
|
};
|
|
1540
1542
|
/**
|
|
1541
|
-
* Factory function to create a KyselyDatabaseAdapter instance with the given Kysely executor
|
|
1543
|
+
* Factory function to create a KyselyDatabaseAdapter instance with the given Kysely executor
|
|
1542
1544
|
* and optional table name mapping.
|
|
1543
|
-
*
|
|
1545
|
+
*
|
|
1544
1546
|
* @param db The Kysely executor to be used by the adapter.
|
|
1545
1547
|
* @param mapping Optional table name mapping for the adapter.
|
|
1546
|
-
* @returns A new instance of KyselyDatabaseAdapter.
|
|
1548
|
+
* @returns A new instance of KyselyDatabaseAdapter.
|
|
1547
1549
|
*/
|
|
1548
1550
|
const createKyselyAdapter = (db, mapping = {}) => {
|
|
1549
1551
|
return new KyselyDatabaseAdapter(db, mapping);
|
|
@@ -1602,7 +1604,7 @@ function createPrismaDelegateMap(prisma, mapping = {}) {
|
|
|
1602
1604
|
}
|
|
1603
1605
|
/**
|
|
1604
1606
|
* Infer the Prisma delegate name for a given model name using a simple convention.
|
|
1605
|
-
*
|
|
1607
|
+
*
|
|
1606
1608
|
* @param modelName The name of the model to infer the delegate name for.
|
|
1607
1609
|
* @returns The inferred Prisma delegate name.
|
|
1608
1610
|
*/
|
|
@@ -1613,9 +1615,9 @@ function inferDelegateName(modelName) {
|
|
|
1613
1615
|
//#endregion
|
|
1614
1616
|
//#region src/adapters/PrismaDatabaseAdapter.ts
|
|
1615
1617
|
/**
|
|
1616
|
-
* Database adapter implementation for Prisma, allowing Arkorm to execute queries using Prisma
|
|
1618
|
+
* Database adapter implementation for Prisma, allowing Arkorm to execute queries using Prisma
|
|
1617
1619
|
* as the underlying query builder and executor.
|
|
1618
|
-
*
|
|
1620
|
+
*
|
|
1619
1621
|
* @author Legacy (3m1n3nc3)
|
|
1620
1622
|
* @since 2.0.0-next.0
|
|
1621
1623
|
*/
|
|
@@ -1884,9 +1886,9 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
1884
1886
|
* Prisma include/select arguments, but the adapter does not advertise the
|
|
1885
1887
|
* adapter-owned batch relation load seam. QueryBuilder eager loads therefore stay
|
|
1886
1888
|
* on Arkorm's generic relation loader on the Prisma compatibility path.
|
|
1887
|
-
*
|
|
1888
|
-
* @param spec
|
|
1889
|
-
* @returns
|
|
1889
|
+
*
|
|
1890
|
+
* @param spec
|
|
1891
|
+
* @returns
|
|
1890
1892
|
*/
|
|
1891
1893
|
async select(spec) {
|
|
1892
1894
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -1896,10 +1898,10 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
1896
1898
|
}, { args });
|
|
1897
1899
|
}
|
|
1898
1900
|
/**
|
|
1899
|
-
* Selects a single record matching the specified criteria.
|
|
1900
|
-
*
|
|
1901
|
-
* @param spec
|
|
1902
|
-
* @returns
|
|
1901
|
+
* Selects a single record matching the specified criteria.
|
|
1902
|
+
*
|
|
1903
|
+
* @param spec
|
|
1904
|
+
* @returns
|
|
1903
1905
|
*/
|
|
1904
1906
|
async selectOne(spec) {
|
|
1905
1907
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -1910,9 +1912,9 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
1910
1912
|
}
|
|
1911
1913
|
/**
|
|
1912
1914
|
* Inserts a single record into the database and returns the created record.
|
|
1913
|
-
*
|
|
1914
|
-
* @param spec
|
|
1915
|
-
* @returns
|
|
1915
|
+
*
|
|
1916
|
+
* @param spec
|
|
1917
|
+
* @returns
|
|
1916
1918
|
*/
|
|
1917
1919
|
async insert(spec) {
|
|
1918
1920
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -1921,10 +1923,10 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
1921
1923
|
}, { values: spec.values });
|
|
1922
1924
|
}
|
|
1923
1925
|
/**
|
|
1924
|
-
* Inserts multiple records into the database.
|
|
1925
|
-
*
|
|
1926
|
-
* @param spec
|
|
1927
|
-
* @returns
|
|
1926
|
+
* Inserts multiple records into the database.
|
|
1927
|
+
*
|
|
1928
|
+
* @param spec
|
|
1929
|
+
* @returns
|
|
1928
1930
|
*/
|
|
1929
1931
|
async insertMany(spec) {
|
|
1930
1932
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -1953,9 +1955,9 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
1953
1955
|
}
|
|
1954
1956
|
/**
|
|
1955
1957
|
* Updates a single record matching the specified criteria and returns the updated record.
|
|
1956
|
-
*
|
|
1957
|
-
* @param spec
|
|
1958
|
-
* @returns
|
|
1958
|
+
*
|
|
1959
|
+
* @param spec
|
|
1960
|
+
* @returns
|
|
1959
1961
|
*/
|
|
1960
1962
|
async update(spec) {
|
|
1961
1963
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -1972,10 +1974,10 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
1972
1974
|
});
|
|
1973
1975
|
}
|
|
1974
1976
|
/**
|
|
1975
|
-
* Updates multiple records matching the specified criteria.
|
|
1976
|
-
*
|
|
1977
|
-
* @param spec
|
|
1978
|
-
* @returns
|
|
1977
|
+
* Updates multiple records matching the specified criteria.
|
|
1978
|
+
*
|
|
1979
|
+
* @param spec
|
|
1980
|
+
* @returns
|
|
1979
1981
|
*/
|
|
1980
1982
|
async updateMany(spec) {
|
|
1981
1983
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -2005,9 +2007,9 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
2005
2007
|
}
|
|
2006
2008
|
/**
|
|
2007
2009
|
* Deletes a single record matching the specified criteria and returns the deleted record.
|
|
2008
|
-
*
|
|
2009
|
-
* @param spec
|
|
2010
|
-
* @returns
|
|
2010
|
+
*
|
|
2011
|
+
* @param spec
|
|
2012
|
+
* @returns
|
|
2011
2013
|
*/
|
|
2012
2014
|
async delete(spec) {
|
|
2013
2015
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -2018,10 +2020,10 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
2018
2020
|
}, { where });
|
|
2019
2021
|
}
|
|
2020
2022
|
/**
|
|
2021
|
-
* Deletes multiple records matching the specified criteria.
|
|
2022
|
-
*
|
|
2023
|
-
* @param spec
|
|
2024
|
-
* @returns
|
|
2023
|
+
* Deletes multiple records matching the specified criteria.
|
|
2024
|
+
*
|
|
2025
|
+
* @param spec
|
|
2026
|
+
* @returns
|
|
2025
2027
|
*/
|
|
2026
2028
|
async deleteMany(spec) {
|
|
2027
2029
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -2036,9 +2038,9 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
2036
2038
|
}
|
|
2037
2039
|
/**
|
|
2038
2040
|
* Counts the number of records matching the specified criteria.
|
|
2039
|
-
*
|
|
2040
|
-
* @param spec
|
|
2041
|
-
* @returns
|
|
2041
|
+
*
|
|
2042
|
+
* @param spec
|
|
2043
|
+
* @returns
|
|
2042
2044
|
*/
|
|
2043
2045
|
async count(spec) {
|
|
2044
2046
|
const delegate = this.resolveDelegate(spec.target);
|
|
@@ -2049,9 +2051,9 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
2049
2051
|
}
|
|
2050
2052
|
/**
|
|
2051
2053
|
* Checks for the existence of records matching the specified criteria.
|
|
2052
|
-
*
|
|
2053
|
-
* @param spec
|
|
2054
|
-
* @returns
|
|
2054
|
+
*
|
|
2055
|
+
* @param spec
|
|
2056
|
+
* @returns
|
|
2055
2057
|
*/
|
|
2056
2058
|
async exists(spec) {
|
|
2057
2059
|
return await this.selectOne({
|
|
@@ -2061,8 +2063,8 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
2061
2063
|
}
|
|
2062
2064
|
/**
|
|
2063
2065
|
* Loads related models for a batch of parent records based on the specified relation load plans.
|
|
2064
|
-
*
|
|
2065
|
-
* @param _spec
|
|
2066
|
+
*
|
|
2067
|
+
* @param _spec
|
|
2066
2068
|
*/
|
|
2067
2069
|
async loadRelations(_spec) {
|
|
2068
2070
|
throw new UnsupportedAdapterFeatureException("Adapter-owned relation batch loading is intentionally unavailable on the Prisma compatibility adapter; eager loading stays on Arkorm's generic loader for this path.", {
|
|
@@ -2071,12 +2073,12 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
2071
2073
|
});
|
|
2072
2074
|
}
|
|
2073
2075
|
/**
|
|
2074
|
-
* Executes a series of database operations within a transaction.
|
|
2076
|
+
* Executes a series of database operations within a transaction.
|
|
2075
2077
|
* If the underlying Prisma client does not support transactions, an exception is thrown.
|
|
2076
|
-
*
|
|
2077
|
-
* @param callback
|
|
2078
|
-
* @param context
|
|
2079
|
-
* @returns
|
|
2078
|
+
*
|
|
2079
|
+
* @param callback
|
|
2080
|
+
* @param context
|
|
2081
|
+
* @returns
|
|
2080
2082
|
*/
|
|
2081
2083
|
async transaction(callback, context = {}) {
|
|
2082
2084
|
if (!this.hasTransactionSupport(this.prisma)) throw new UnsupportedAdapterFeatureException("Transactions are not supported by the Prisma compatibility adapter.", {
|
|
@@ -2093,9 +2095,9 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
|
|
|
2093
2095
|
}
|
|
2094
2096
|
};
|
|
2095
2097
|
/**
|
|
2096
|
-
* Factory function to create a PrismaDatabaseAdapter instance with the given
|
|
2098
|
+
* Factory function to create a PrismaDatabaseAdapter instance with the given
|
|
2097
2099
|
* Prisma client and optional delegate name mapping.
|
|
2098
|
-
*
|
|
2100
|
+
*
|
|
2099
2101
|
* @param prisma The Prisma client instance to be used by the adapter.
|
|
2100
2102
|
* @param mapping Optional mapping of delegate names.
|
|
2101
2103
|
* @returns A new instance of PrismaDatabaseAdapter.
|
|
@@ -2104,9 +2106,9 @@ const createPrismaDatabaseAdapter = (prisma, mapping = {}) => {
|
|
|
2104
2106
|
return new PrismaDatabaseAdapter(prisma, mapping);
|
|
2105
2107
|
};
|
|
2106
2108
|
/**
|
|
2107
|
-
* Alias for createPrismaDatabaseAdapter to maintain backward compatibility with
|
|
2109
|
+
* Alias for createPrismaDatabaseAdapter to maintain backward compatibility with
|
|
2108
2110
|
* previous versions of Arkorm that exported the adapter factory under a different name.
|
|
2109
|
-
*
|
|
2111
|
+
*
|
|
2110
2112
|
* @param prisma The Prisma client instance to be used by the adapter.
|
|
2111
2113
|
* @param mapping Optional mapping of delegate names.
|
|
2112
2114
|
* @returns A new instance of PrismaDatabaseAdapter.
|
|
@@ -2136,10 +2138,10 @@ var Arkorm = class Arkorm {
|
|
|
2136
2138
|
}
|
|
2137
2139
|
/**
|
|
2138
2140
|
* Configure the ArkORM runtime with the provided runtime client resolver and adapter-first options.
|
|
2139
|
-
*
|
|
2140
|
-
* @param client
|
|
2141
|
-
* @param options
|
|
2142
|
-
* @returns
|
|
2141
|
+
*
|
|
2142
|
+
* @param client
|
|
2143
|
+
* @param options
|
|
2144
|
+
* @returns
|
|
2143
2145
|
*/
|
|
2144
2146
|
static configure(options, client) {
|
|
2145
2147
|
return configureArkormRuntime(client, options);
|
|
@@ -2156,113 +2158,113 @@ var Arkorm = class Arkorm {
|
|
|
2156
2158
|
}
|
|
2157
2159
|
/**
|
|
2158
2160
|
* Register migration constructors directly without relying on runtime discovery.
|
|
2159
|
-
*
|
|
2160
|
-
* @param migrations
|
|
2161
|
-
* @returns
|
|
2161
|
+
*
|
|
2162
|
+
* @param migrations
|
|
2163
|
+
* @returns
|
|
2162
2164
|
*/
|
|
2163
2165
|
static registerMigrations(...migrations) {
|
|
2164
2166
|
return registerMigrations(...migrations);
|
|
2165
2167
|
}
|
|
2166
2168
|
/**
|
|
2167
2169
|
* Register seeder constructors directly without relying on runtime discovery.
|
|
2168
|
-
*
|
|
2169
|
-
* @param seeders
|
|
2170
|
-
* @returns
|
|
2170
|
+
*
|
|
2171
|
+
* @param seeders
|
|
2172
|
+
* @returns
|
|
2171
2173
|
*/
|
|
2172
2174
|
static registerSeeders(...seeders) {
|
|
2173
2175
|
return registerSeeders(...seeders);
|
|
2174
2176
|
}
|
|
2175
2177
|
/**
|
|
2176
2178
|
* Register model constructors directly without relying on runtime discovery.
|
|
2177
|
-
*
|
|
2178
|
-
* @param models
|
|
2179
|
-
* @returns
|
|
2179
|
+
*
|
|
2180
|
+
* @param models
|
|
2181
|
+
* @returns
|
|
2180
2182
|
*/
|
|
2181
2183
|
static registerModels(...models) {
|
|
2182
2184
|
return registerModels(...models);
|
|
2183
2185
|
}
|
|
2184
2186
|
/**
|
|
2185
2187
|
* Register factory constructors or instances directly without relying on runtime discovery.
|
|
2186
|
-
*
|
|
2187
|
-
* @param factories
|
|
2188
|
-
* @returns
|
|
2188
|
+
*
|
|
2189
|
+
* @param factories
|
|
2190
|
+
* @returns
|
|
2189
2191
|
*/
|
|
2190
2192
|
static registerFactories(...factories) {
|
|
2191
2193
|
return registerFactories(...factories);
|
|
2192
2194
|
}
|
|
2193
2195
|
/**
|
|
2194
2196
|
* Register additional runtime discovery paths for models without replacing configured paths.
|
|
2195
|
-
*
|
|
2196
|
-
* @param paths
|
|
2197
|
-
* @returns
|
|
2197
|
+
*
|
|
2198
|
+
* @param paths
|
|
2199
|
+
* @returns
|
|
2198
2200
|
*/
|
|
2199
2201
|
static loadModelsFrom(paths) {
|
|
2200
2202
|
return loadModelsFrom(paths);
|
|
2201
2203
|
}
|
|
2202
2204
|
/**
|
|
2203
2205
|
* Register additional runtime discovery paths for seeders without replacing configured paths.
|
|
2204
|
-
*
|
|
2205
|
-
* @param paths
|
|
2206
|
-
* @returns
|
|
2206
|
+
*
|
|
2207
|
+
* @param paths
|
|
2208
|
+
* @returns
|
|
2207
2209
|
*/
|
|
2208
2210
|
static loadSeedersFrom(paths) {
|
|
2209
2211
|
return loadSeedersFrom(paths);
|
|
2210
2212
|
}
|
|
2211
2213
|
/**
|
|
2212
2214
|
* Register additional runtime discovery paths for migrations without replacing configured paths.
|
|
2213
|
-
*
|
|
2214
|
-
* @param paths
|
|
2215
|
-
* @returns
|
|
2215
|
+
*
|
|
2216
|
+
* @param paths
|
|
2217
|
+
* @returns
|
|
2216
2218
|
*/
|
|
2217
2219
|
static loadMigrationsFrom(paths) {
|
|
2218
2220
|
return loadMigrationsFrom(paths);
|
|
2219
2221
|
}
|
|
2220
2222
|
/**
|
|
2221
2223
|
* Register additional runtime discovery paths for factories without replacing configured paths.
|
|
2222
|
-
*
|
|
2223
|
-
* @param paths
|
|
2224
|
-
* @returns
|
|
2224
|
+
*
|
|
2225
|
+
* @param paths
|
|
2226
|
+
* @returns
|
|
2225
2227
|
*/
|
|
2226
2228
|
static loadFactoriesFrom(paths) {
|
|
2227
2229
|
return loadFactoriesFrom(paths);
|
|
2228
2230
|
}
|
|
2229
2231
|
/**
|
|
2230
2232
|
* Get registered runtime discovery paths or registered constructors for a specific type.
|
|
2231
|
-
*
|
|
2232
|
-
* @param key
|
|
2233
|
-
* @returns
|
|
2233
|
+
*
|
|
2234
|
+
* @param key
|
|
2235
|
+
* @returns
|
|
2234
2236
|
*/
|
|
2235
2237
|
static getRegisteredPaths(key) {
|
|
2236
2238
|
return getRegisteredPaths(key);
|
|
2237
2239
|
}
|
|
2238
2240
|
/**
|
|
2239
2241
|
* Get registered migration constructors instances
|
|
2240
|
-
*
|
|
2241
|
-
* @returns
|
|
2242
|
+
*
|
|
2243
|
+
* @returns
|
|
2242
2244
|
*/
|
|
2243
2245
|
static getRegisteredMigrations() {
|
|
2244
2246
|
return getRegisteredMigrations();
|
|
2245
2247
|
}
|
|
2246
2248
|
/**
|
|
2247
2249
|
* Get registered seeder constructors instances.
|
|
2248
|
-
*
|
|
2249
|
-
* @returns
|
|
2250
|
+
*
|
|
2251
|
+
* @returns
|
|
2250
2252
|
*/
|
|
2251
2253
|
static getRegisteredSeeders() {
|
|
2252
2254
|
return getRegisteredSeeders();
|
|
2253
2255
|
}
|
|
2254
2256
|
/**
|
|
2255
2257
|
* Get registered model constructors instances.
|
|
2256
|
-
*
|
|
2257
|
-
* @returns
|
|
2258
|
+
*
|
|
2259
|
+
* @returns
|
|
2258
2260
|
*/
|
|
2259
2261
|
static getRegisteredModels() {
|
|
2260
2262
|
return getRegisteredModels();
|
|
2261
2263
|
}
|
|
2262
2264
|
/**
|
|
2263
2265
|
* Get registered factory constructors or instances.
|
|
2264
|
-
*
|
|
2265
|
-
* @returns
|
|
2266
|
+
*
|
|
2267
|
+
* @returns
|
|
2266
2268
|
*/
|
|
2267
2269
|
static getRegisteredFactories() {
|
|
2268
2270
|
return getRegisteredFactories();
|
|
@@ -2314,6 +2316,17 @@ const builtinCasts = {
|
|
|
2314
2316
|
return new Date(String(value));
|
|
2315
2317
|
}
|
|
2316
2318
|
},
|
|
2319
|
+
datetime: {
|
|
2320
|
+
get: (value) => {
|
|
2321
|
+
if (value == null || value instanceof DateTime) return value;
|
|
2322
|
+
return new DateTime(value);
|
|
2323
|
+
},
|
|
2324
|
+
set: (value) => {
|
|
2325
|
+
if (value == null || value instanceof Date) return value;
|
|
2326
|
+
if (value instanceof DateTime) return value.toDate();
|
|
2327
|
+
return new DateTime(value).toDate();
|
|
2328
|
+
}
|
|
2329
|
+
},
|
|
2317
2330
|
json: {
|
|
2318
2331
|
get: (value) => {
|
|
2319
2332
|
if (value == null || typeof value !== "string") return value;
|
|
@@ -2390,12 +2403,12 @@ var CliApp = class {
|
|
|
2390
2403
|
return relPath;
|
|
2391
2404
|
}
|
|
2392
2405
|
/**
|
|
2393
|
-
* Utility to format a value for logging, converting absolute paths under current
|
|
2406
|
+
* Utility to format a value for logging, converting absolute paths under current
|
|
2394
2407
|
* working directory into relative display paths.
|
|
2395
|
-
*
|
|
2396
|
-
* @param name
|
|
2397
|
-
* @param value
|
|
2398
|
-
* @returns
|
|
2408
|
+
*
|
|
2409
|
+
* @param name
|
|
2410
|
+
* @param value
|
|
2411
|
+
* @returns
|
|
2399
2412
|
*/
|
|
2400
2413
|
splitLogger(name, value) {
|
|
2401
2414
|
value = value.includes(process.cwd()) ? this.formatPathForLog(value) : value;
|
|
@@ -2484,7 +2497,7 @@ var CliApp = class {
|
|
|
2484
2497
|
}
|
|
2485
2498
|
/**
|
|
2486
2499
|
* Resolve a configuration path with a fallback default
|
|
2487
|
-
*
|
|
2500
|
+
*
|
|
2488
2501
|
* @param key The configuration key to resolve
|
|
2489
2502
|
* @param fallback The fallback value if the configuration key is not set
|
|
2490
2503
|
* @returns The resolved configuration path
|
|
@@ -2496,19 +2509,19 @@ var CliApp = class {
|
|
|
2496
2509
|
}
|
|
2497
2510
|
/**
|
|
2498
2511
|
* Resolve the path to a stub file based on configuration
|
|
2499
|
-
*
|
|
2500
|
-
* @param stubName
|
|
2501
|
-
* @returns
|
|
2512
|
+
*
|
|
2513
|
+
* @param stubName
|
|
2514
|
+
* @returns
|
|
2502
2515
|
*/
|
|
2503
2516
|
resolveStubPath(stubName) {
|
|
2504
2517
|
return join$1(this.resolveConfigPath("stubs", getDefaultStubsPath()), stubName);
|
|
2505
2518
|
}
|
|
2506
2519
|
/**
|
|
2507
2520
|
* Generate a factory file for a given model name.
|
|
2508
|
-
*
|
|
2509
|
-
* @param name
|
|
2510
|
-
* @param options
|
|
2511
|
-
* @returns
|
|
2521
|
+
*
|
|
2522
|
+
* @param name
|
|
2523
|
+
* @param options
|
|
2524
|
+
* @returns
|
|
2512
2525
|
*/
|
|
2513
2526
|
makeFactory(name, options = {}) {
|
|
2514
2527
|
const baseName = str(name.replace(/Factory$/, "")).pascal();
|
|
@@ -2530,10 +2543,10 @@ var CliApp = class {
|
|
|
2530
2543
|
}
|
|
2531
2544
|
/**
|
|
2532
2545
|
* Generate a seeder file for a given name.
|
|
2533
|
-
*
|
|
2534
|
-
* @param name
|
|
2535
|
-
* @param options
|
|
2536
|
-
* @returns
|
|
2546
|
+
*
|
|
2547
|
+
* @param name
|
|
2548
|
+
* @param options
|
|
2549
|
+
* @returns
|
|
2537
2550
|
*/
|
|
2538
2551
|
makeSeeder(name, options = {}) {
|
|
2539
2552
|
const seederName = `${str(name.replace(/Seeder$/, "")).pascal()}Seeder`;
|
|
@@ -2547,7 +2560,7 @@ var CliApp = class {
|
|
|
2547
2560
|
}
|
|
2548
2561
|
/**
|
|
2549
2562
|
* Generate a migration file for a given name.
|
|
2550
|
-
*
|
|
2563
|
+
*
|
|
2551
2564
|
* @param name The name of the migration.
|
|
2552
2565
|
* @returns An object containing the name and path of the generated migration file.
|
|
2553
2566
|
*/
|
|
@@ -2563,10 +2576,10 @@ var CliApp = class {
|
|
|
2563
2576
|
}
|
|
2564
2577
|
/**
|
|
2565
2578
|
* Generate a model file along with optional factory, seeder, and migration files.
|
|
2566
|
-
*
|
|
2567
|
-
* @param name
|
|
2568
|
-
* @param options
|
|
2569
|
-
* @returns
|
|
2579
|
+
*
|
|
2580
|
+
* @param name
|
|
2581
|
+
* @param options
|
|
2582
|
+
* @returns
|
|
2570
2583
|
*/
|
|
2571
2584
|
makeModel(name, options = {}) {
|
|
2572
2585
|
const baseName = str(name.replace(/Model$/, "")).pascal().toString();
|
|
@@ -2610,10 +2623,10 @@ var CliApp = class {
|
|
|
2610
2623
|
return created;
|
|
2611
2624
|
}
|
|
2612
2625
|
/**
|
|
2613
|
-
* Ensure that the Prisma schema has a model entry for the given model
|
|
2626
|
+
* Ensure that the Prisma schema has a model entry for the given model
|
|
2614
2627
|
* and table names.
|
|
2615
2628
|
* If the entry does not exist, it will be created with a default `id` field.
|
|
2616
|
-
*
|
|
2629
|
+
*
|
|
2617
2630
|
* @param modelName The name of the model to ensure in the Prisma schema.
|
|
2618
2631
|
* @param tableName The table name to ensure in the Prisma schema.
|
|
2619
2632
|
*/
|
|
@@ -2645,7 +2658,7 @@ var CliApp = class {
|
|
|
2645
2658
|
}
|
|
2646
2659
|
/**
|
|
2647
2660
|
* Convert a Prisma scalar type to its corresponding TypeScript type.
|
|
2648
|
-
*
|
|
2661
|
+
*
|
|
2649
2662
|
* @param value The Prisma scalar type.
|
|
2650
2663
|
* @returns The corresponding TypeScript type.
|
|
2651
2664
|
*/
|
|
@@ -2938,9 +2951,9 @@ var CliApp = class {
|
|
|
2938
2951
|
return isList ? `Array<${baseType}>` : baseType;
|
|
2939
2952
|
}
|
|
2940
2953
|
/**
|
|
2941
|
-
* Parse the Prisma schema to extract model definitions and their fields, focusing
|
|
2954
|
+
* Parse the Prisma schema to extract model definitions and their fields, focusing
|
|
2942
2955
|
* on scalar types.
|
|
2943
|
-
*
|
|
2956
|
+
*
|
|
2944
2957
|
* @param schema The Prisma schema as a string.
|
|
2945
2958
|
* @returns An array of model definitions with their fields.
|
|
2946
2959
|
*/
|
|
@@ -2988,11 +3001,11 @@ var CliApp = class {
|
|
|
2988
3001
|
return models;
|
|
2989
3002
|
}
|
|
2990
3003
|
/**
|
|
2991
|
-
* Sync model attribute declarations in a model file based on the
|
|
3004
|
+
* Sync model attribute declarations in a model file based on the
|
|
2992
3005
|
* provided declarations.
|
|
2993
|
-
* This method takes the source code of a model file and a list of
|
|
3006
|
+
* This method takes the source code of a model file and a list of
|
|
2994
3007
|
* attribute declarations,
|
|
2995
|
-
*
|
|
3008
|
+
*
|
|
2996
3009
|
* @param modelSource The source code of the model file.
|
|
2997
3010
|
* @param declarations A list of attribute declarations to sync.
|
|
2998
3011
|
* @returns An object containing the updated content and a flag indicating if it was updated.
|
|
@@ -3088,12 +3101,12 @@ var CliApp = class {
|
|
|
3088
3101
|
}
|
|
3089
3102
|
/**
|
|
3090
3103
|
* Sync model attribute declarations in model files based on the Prisma schema.
|
|
3091
|
-
* This method reads the Prisma schema to extract model definitions and their
|
|
3092
|
-
* scalar fields, then updates the corresponding model files to include `declare`
|
|
3104
|
+
* This method reads the Prisma schema to extract model definitions and their
|
|
3105
|
+
* scalar fields, then updates the corresponding model files to include `declare`
|
|
3093
3106
|
* statements for these fields. It returns an object containing the paths of the
|
|
3094
|
-
* schema and models, the total number of model files processed, and lists of
|
|
3107
|
+
* schema and models, the total number of model files processed, and lists of
|
|
3095
3108
|
* updated and skipped files.
|
|
3096
|
-
*
|
|
3109
|
+
*
|
|
3097
3110
|
* @param options Optional parameters to specify custom paths for the Prisma schema and models directory.
|
|
3098
3111
|
* @returns An object with details about the synchronization process, including updated and skipped files.
|
|
3099
3112
|
*/
|
|
@@ -3124,7 +3137,7 @@ var CliApp = class {
|
|
|
3124
3137
|
//#endregion
|
|
3125
3138
|
//#region src/cli/commands/InitCommand.ts
|
|
3126
3139
|
/**
|
|
3127
|
-
* The InitCommand class implements the CLI command for initializing Arkormˣ by creating
|
|
3140
|
+
* The InitCommand class implements the CLI command for initializing Arkormˣ by creating
|
|
3128
3141
|
* a default config file in the current directory.
|
|
3129
3142
|
*
|
|
3130
3143
|
* @author Legacy (3m1n3nc3)
|
|
@@ -3183,8 +3196,8 @@ var MakeFactoryCommand = class extends Command {
|
|
|
3183
3196
|
}
|
|
3184
3197
|
/**
|
|
3185
3198
|
* Command handler for the make:factory command.
|
|
3186
|
-
*
|
|
3187
|
-
* @returns
|
|
3199
|
+
*
|
|
3200
|
+
* @returns
|
|
3188
3201
|
*/
|
|
3189
3202
|
async handle() {
|
|
3190
3203
|
this.app.command = this;
|
|
@@ -3213,8 +3226,8 @@ var MakeMigrationCommand = class extends Command {
|
|
|
3213
3226
|
}
|
|
3214
3227
|
/**
|
|
3215
3228
|
* Command handler for the make:migration command.
|
|
3216
|
-
*
|
|
3217
|
-
* @returns
|
|
3229
|
+
*
|
|
3230
|
+
* @returns
|
|
3218
3231
|
*/
|
|
3219
3232
|
async handle() {
|
|
3220
3233
|
this.app.command = this;
|
|
@@ -3228,7 +3241,7 @@ var MakeMigrationCommand = class extends Command {
|
|
|
3228
3241
|
//#endregion
|
|
3229
3242
|
//#region src/cli/commands/MakeModelCommand.ts
|
|
3230
3243
|
/**
|
|
3231
|
-
* The MakeModelCommand class implements the CLI command for creating new model
|
|
3244
|
+
* The MakeModelCommand class implements the CLI command for creating new model
|
|
3232
3245
|
* classes along with optional linked resources such as factories, seeders, and migrations.
|
|
3233
3246
|
*
|
|
3234
3247
|
* @author Legacy (3m1n3nc3)
|
|
@@ -3250,8 +3263,8 @@ var MakeModelCommand = class extends Command {
|
|
|
3250
3263
|
}
|
|
3251
3264
|
/**
|
|
3252
3265
|
* Command handler for the make:model command.
|
|
3253
|
-
*
|
|
3254
|
-
* @returns
|
|
3266
|
+
*
|
|
3267
|
+
* @returns
|
|
3255
3268
|
*/
|
|
3256
3269
|
async handle() {
|
|
3257
3270
|
this.app.command = this;
|
|
@@ -3301,8 +3314,8 @@ var MakeSeederCommand = class extends Command {
|
|
|
3301
3314
|
//#region src/database/Migration.ts
|
|
3302
3315
|
const MIGRATION_BRAND = Symbol.for("arkormx.migration");
|
|
3303
3316
|
/**
|
|
3304
|
-
* The Migration class serves as a base for defining database migrations, requiring
|
|
3305
|
-
* the implementation of `up` and `down` methods to specify the changes to be
|
|
3317
|
+
* The Migration class serves as a base for defining database migrations, requiring
|
|
3318
|
+
* the implementation of `up` and `down` methods to specify the changes to be
|
|
3306
3319
|
* applied or reverted in the database schema.
|
|
3307
3320
|
*
|
|
3308
3321
|
* @author Legacy (3m1n3nc3)
|
|
@@ -3317,7 +3330,7 @@ var Migration = class {
|
|
|
3317
3330
|
//#endregion
|
|
3318
3331
|
//#region src/cli/commands/MigrateCommand.ts
|
|
3319
3332
|
/**
|
|
3320
|
-
* The MigrateCommand class implements the CLI command for applying migration
|
|
3333
|
+
* The MigrateCommand class implements the CLI command for applying migration
|
|
3321
3334
|
* classes to the Prisma schema and running the Prisma workflow.
|
|
3322
3335
|
*
|
|
3323
3336
|
* @author Legacy (3m1n3nc3)
|
|
@@ -3341,12 +3354,12 @@ var MigrateCommand = class extends Command {
|
|
|
3341
3354
|
}
|
|
3342
3355
|
/**
|
|
3343
3356
|
* Command handler for the migrate command.
|
|
3344
|
-
* This method is responsible for orchestrating the migration
|
|
3345
|
-
* process, including loading migration classes, applying them to
|
|
3346
|
-
* the Prisma schema, and running the appropriate Prisma commands
|
|
3357
|
+
* This method is responsible for orchestrating the migration
|
|
3358
|
+
* process, including loading migration classes, applying them to
|
|
3359
|
+
* the Prisma schema, and running the appropriate Prisma commands
|
|
3347
3360
|
* based on the provided options.
|
|
3348
|
-
*
|
|
3349
|
-
* @returns
|
|
3361
|
+
*
|
|
3362
|
+
* @returns
|
|
3350
3363
|
*/
|
|
3351
3364
|
async handle() {
|
|
3352
3365
|
this.app.command = this;
|
|
@@ -3461,10 +3474,10 @@ var MigrateCommand = class extends Command {
|
|
|
3461
3474
|
}
|
|
3462
3475
|
/**
|
|
3463
3476
|
* Load migration classes from a specific file or by class name.
|
|
3464
|
-
*
|
|
3465
|
-
* @param migrationsDir
|
|
3466
|
-
* @param name
|
|
3467
|
-
* @returns
|
|
3477
|
+
*
|
|
3478
|
+
* @param migrationsDir
|
|
3479
|
+
* @param name
|
|
3480
|
+
* @returns
|
|
3468
3481
|
*/
|
|
3469
3482
|
async loadNamedMigration(migrationsDirs, name) {
|
|
3470
3483
|
if (!name) return [[void 0, ""]];
|
|
@@ -3487,9 +3500,9 @@ var MigrateCommand = class extends Command {
|
|
|
3487
3500
|
}
|
|
3488
3501
|
/**
|
|
3489
3502
|
* Load migration classes from a given file path.
|
|
3490
|
-
*
|
|
3491
|
-
* @param filePath
|
|
3492
|
-
* @returns
|
|
3503
|
+
*
|
|
3504
|
+
* @param filePath
|
|
3505
|
+
* @returns
|
|
3493
3506
|
*/
|
|
3494
3507
|
async loadMigrationClassesFromFile(filePath) {
|
|
3495
3508
|
const imported = await RuntimeModuleLoader.load(filePath);
|
|
@@ -3908,7 +3921,7 @@ var ModelsSyncCommand = class extends Command {
|
|
|
3908
3921
|
//#region src/database/Seeder.ts
|
|
3909
3922
|
const SEEDER_BRAND = Symbol.for("arkormx.seeder");
|
|
3910
3923
|
/**
|
|
3911
|
-
* The Seeder class serves as a base for defining database seeders, which are
|
|
3924
|
+
* The Seeder class serves as a base for defining database seeders, which are
|
|
3912
3925
|
* used to populate the database with initial or test data.
|
|
3913
3926
|
*
|
|
3914
3927
|
* @author Legacy (3m1n3nc3)
|
|
@@ -3923,7 +3936,7 @@ var Seeder = class Seeder {
|
|
|
3923
3936
|
}
|
|
3924
3937
|
/**
|
|
3925
3938
|
* Runs one or more seeders.
|
|
3926
|
-
*
|
|
3939
|
+
*
|
|
3927
3940
|
* @param seeders The seeders to be run.
|
|
3928
3941
|
*/
|
|
3929
3942
|
async call(...seeders) {
|
|
@@ -3931,9 +3944,9 @@ var Seeder = class Seeder {
|
|
|
3931
3944
|
}
|
|
3932
3945
|
/**
|
|
3933
3946
|
* Run seeders and return every seeder class executed, including nested calls.
|
|
3934
|
-
*
|
|
3935
|
-
* @param seeders
|
|
3936
|
-
* @returns
|
|
3947
|
+
*
|
|
3948
|
+
* @param seeders
|
|
3949
|
+
* @returns
|
|
3937
3950
|
*/
|
|
3938
3951
|
static async runWithReport(...seeders) {
|
|
3939
3952
|
const report = [];
|
|
@@ -3943,8 +3956,8 @@ var Seeder = class Seeder {
|
|
|
3943
3956
|
return report;
|
|
3944
3957
|
}
|
|
3945
3958
|
/**
|
|
3946
|
-
* Converts a SeederInput into a Seeder instance.
|
|
3947
|
-
*
|
|
3959
|
+
* Converts a SeederInput into a Seeder instance.
|
|
3960
|
+
*
|
|
3948
3961
|
* @param input The SeederInput to convert.
|
|
3949
3962
|
* @returns A Seeder instance.
|
|
3950
3963
|
*/
|
|
@@ -3957,7 +3970,7 @@ var Seeder = class Seeder {
|
|
|
3957
3970
|
}
|
|
3958
3971
|
/**
|
|
3959
3972
|
* Runs the given seeders in sequence.
|
|
3960
|
-
*
|
|
3973
|
+
*
|
|
3961
3974
|
* @param seeders The seeders to be run.
|
|
3962
3975
|
*/
|
|
3963
3976
|
static async runSeeders(...seeders) {
|
|
@@ -3977,7 +3990,7 @@ var Seeder = class Seeder {
|
|
|
3977
3990
|
//#endregion
|
|
3978
3991
|
//#region src/cli/commands/SeedCommand.ts
|
|
3979
3992
|
/**
|
|
3980
|
-
* The SeedCommand class implements the CLI command for running seeder classes.
|
|
3993
|
+
* The SeedCommand class implements the CLI command for running seeder classes.
|
|
3981
3994
|
*
|
|
3982
3995
|
* @author Legacy (3m1n3nc3)
|
|
3983
3996
|
* @since 0.1.0
|
|
@@ -3993,8 +4006,8 @@ var SeedCommand = class extends Command {
|
|
|
3993
4006
|
}
|
|
3994
4007
|
/**
|
|
3995
4008
|
* Command handler for the seed command.
|
|
3996
|
-
*
|
|
3997
|
-
* @returns
|
|
4009
|
+
*
|
|
4010
|
+
* @returns
|
|
3998
4011
|
*/
|
|
3999
4012
|
async handle() {
|
|
4000
4013
|
this.app.command = this;
|
|
@@ -4010,9 +4023,9 @@ var SeedCommand = class extends Command {
|
|
|
4010
4023
|
}
|
|
4011
4024
|
/**
|
|
4012
4025
|
* Load all seeder classes from the specified directory.
|
|
4013
|
-
*
|
|
4014
|
-
* @param seedersDir
|
|
4015
|
-
* @returns
|
|
4026
|
+
*
|
|
4027
|
+
* @param seedersDir
|
|
4028
|
+
* @returns
|
|
4016
4029
|
*/
|
|
4017
4030
|
resolveSeederDirectories(configuredSeedersDir) {
|
|
4018
4031
|
return [this.app.resolveRuntimeDirectoryPath(configuredSeedersDir), ...getRegisteredPaths("seeders").map((directory) => this.app.resolveRuntimeDirectoryPath(directory))].filter((directory, index, all) => existsSync$1(directory) && all.indexOf(directory) === index);
|
|
@@ -4023,10 +4036,10 @@ var SeedCommand = class extends Command {
|
|
|
4023
4036
|
}
|
|
4024
4037
|
/**
|
|
4025
4038
|
* Load seeder classes from a specific file or by class name.
|
|
4026
|
-
*
|
|
4027
|
-
* @param seedersDir
|
|
4028
|
-
* @param name
|
|
4029
|
-
* @returns
|
|
4039
|
+
*
|
|
4040
|
+
* @param seedersDir
|
|
4041
|
+
* @param name
|
|
4042
|
+
* @returns
|
|
4030
4043
|
*/
|
|
4031
4044
|
async loadNamedSeeder(seedersDirs, name) {
|
|
4032
4045
|
const base = name.replace(/Seeder$/, "");
|
|
@@ -4048,7 +4061,7 @@ var SeedCommand = class extends Command {
|
|
|
4048
4061
|
}
|
|
4049
4062
|
/**
|
|
4050
4063
|
* Load seeder classes from a given file path.
|
|
4051
|
-
*
|
|
4064
|
+
*
|
|
4052
4065
|
* @param filePath The path to the file containing seeder classes.
|
|
4053
4066
|
* @returns An array of seeder classes.
|
|
4054
4067
|
*/
|
|
@@ -4314,9 +4327,9 @@ var JoinClause = class JoinClause {
|
|
|
4314
4327
|
//#endregion
|
|
4315
4328
|
//#region src/Exceptions/ModelNotFoundException.ts
|
|
4316
4329
|
/**
|
|
4317
|
-
* The ModelNotFoundException class is a custom error type for handling
|
|
4318
|
-
* cases where a requested model instance cannot be found in the database.
|
|
4319
|
-
*
|
|
4330
|
+
* The ModelNotFoundException class is a custom error type for handling
|
|
4331
|
+
* cases where a requested model instance cannot be found in the database.
|
|
4332
|
+
*
|
|
4320
4333
|
* @author Legacy (3m1n3nc3)
|
|
4321
4334
|
* @since 0.1.0
|
|
4322
4335
|
*/
|
|
@@ -4374,9 +4387,9 @@ var UniqueConstraintResolutionException = class extends ArkormException {
|
|
|
4374
4387
|
//#endregion
|
|
4375
4388
|
//#region src/QueryBuilder.ts
|
|
4376
4389
|
/**
|
|
4377
|
-
* The QueryBuilder class provides a fluent interface for building and
|
|
4390
|
+
* The QueryBuilder class provides a fluent interface for building and
|
|
4378
4391
|
* executing database queries.
|
|
4379
|
-
*
|
|
4392
|
+
*
|
|
4380
4393
|
* @template TModel The type of the model being queried.
|
|
4381
4394
|
* @author Legacy (3m1n3nc3)
|
|
4382
4395
|
* @since 0.1.0
|
|
@@ -4384,8 +4397,8 @@ var UniqueConstraintResolutionException = class extends ArkormException {
|
|
|
4384
4397
|
var QueryBuilder = class QueryBuilder {
|
|
4385
4398
|
/**
|
|
4386
4399
|
* Creates a new QueryBuilder instance.
|
|
4387
|
-
*
|
|
4388
|
-
* @param model
|
|
4400
|
+
*
|
|
4401
|
+
* @param model
|
|
4389
4402
|
*/
|
|
4390
4403
|
constructor(model, adapter) {
|
|
4391
4404
|
this.model = model;
|
|
@@ -4563,45 +4576,45 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4563
4576
|
}
|
|
4564
4577
|
/**
|
|
4565
4578
|
* Adds clause to determine if a column's value is in the past
|
|
4566
|
-
*
|
|
4567
|
-
* @param key
|
|
4568
|
-
* @returns
|
|
4579
|
+
*
|
|
4580
|
+
* @param key
|
|
4581
|
+
* @returns
|
|
4569
4582
|
*/
|
|
4570
4583
|
wherePast(key) {
|
|
4571
4584
|
return this.where({ [key]: { lt: /* @__PURE__ */ new Date() } });
|
|
4572
4585
|
}
|
|
4573
4586
|
/**
|
|
4574
4587
|
* Adds clause to determine if a column's value is in the future
|
|
4575
|
-
*
|
|
4576
|
-
* @param key
|
|
4577
|
-
* @returns
|
|
4588
|
+
*
|
|
4589
|
+
* @param key
|
|
4590
|
+
* @returns
|
|
4578
4591
|
*/
|
|
4579
4592
|
whereFuture(key) {
|
|
4580
4593
|
return this.where({ [key]: { gt: /* @__PURE__ */ new Date() } });
|
|
4581
4594
|
}
|
|
4582
4595
|
/**
|
|
4583
4596
|
* Adds clause to determine if a column's value is in the past, inclusive of the current date and time
|
|
4584
|
-
*
|
|
4585
|
-
* @param key
|
|
4586
|
-
* @returns
|
|
4597
|
+
*
|
|
4598
|
+
* @param key
|
|
4599
|
+
* @returns
|
|
4587
4600
|
*/
|
|
4588
4601
|
whereNowOrPast(key) {
|
|
4589
4602
|
return this.where({ [key]: { lte: /* @__PURE__ */ new Date() } });
|
|
4590
4603
|
}
|
|
4591
4604
|
/**
|
|
4592
4605
|
* Adds clause to determine if a column's value is in the future, inclusive of the current date and time
|
|
4593
|
-
*
|
|
4594
|
-
* @param key
|
|
4595
|
-
* @returns
|
|
4606
|
+
*
|
|
4607
|
+
* @param key
|
|
4608
|
+
* @returns
|
|
4596
4609
|
*/
|
|
4597
4610
|
whereNowOrFuture(key) {
|
|
4598
4611
|
return this.where({ [key]: { gte: /* @__PURE__ */ new Date() } });
|
|
4599
4612
|
}
|
|
4600
4613
|
/**
|
|
4601
4614
|
* Adds clause to determine if a column's value is today
|
|
4602
|
-
*
|
|
4603
|
-
* @param key
|
|
4604
|
-
* @returns
|
|
4615
|
+
*
|
|
4616
|
+
* @param key
|
|
4617
|
+
* @returns
|
|
4605
4618
|
*/
|
|
4606
4619
|
whereToday(key) {
|
|
4607
4620
|
const [start, end] = this.getUtcDayBounds();
|
|
@@ -4612,9 +4625,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4612
4625
|
}
|
|
4613
4626
|
/**
|
|
4614
4627
|
* Adds clause to determine if a column's value is before today
|
|
4615
|
-
*
|
|
4616
|
-
* @param key
|
|
4617
|
-
* @returns
|
|
4628
|
+
*
|
|
4629
|
+
* @param key
|
|
4630
|
+
* @returns
|
|
4618
4631
|
*/
|
|
4619
4632
|
whereBeforeToday(key) {
|
|
4620
4633
|
const [start] = this.getUtcDayBounds();
|
|
@@ -4622,9 +4635,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4622
4635
|
}
|
|
4623
4636
|
/**
|
|
4624
4637
|
* Adds clause to determine if a column's value is after today
|
|
4625
|
-
*
|
|
4626
|
-
* @param key
|
|
4627
|
-
* @returns
|
|
4638
|
+
*
|
|
4639
|
+
* @param key
|
|
4640
|
+
* @returns
|
|
4628
4641
|
*/
|
|
4629
4642
|
whereAfterToday(key) {
|
|
4630
4643
|
const [, end] = this.getUtcDayBounds();
|
|
@@ -4632,9 +4645,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4632
4645
|
}
|
|
4633
4646
|
/**
|
|
4634
4647
|
* Adds clause to determine if a column's value is today or before today
|
|
4635
|
-
*
|
|
4636
|
-
* @param key
|
|
4637
|
-
* @returns
|
|
4648
|
+
*
|
|
4649
|
+
* @param key
|
|
4650
|
+
* @returns
|
|
4638
4651
|
*/
|
|
4639
4652
|
whereTodayOrBefore(key) {
|
|
4640
4653
|
const [, end] = this.getUtcDayBounds();
|
|
@@ -4642,9 +4655,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4642
4655
|
}
|
|
4643
4656
|
/**
|
|
4644
4657
|
* Adds clause to determine if a column's value is today or after today
|
|
4645
|
-
*
|
|
4646
|
-
* @param key
|
|
4647
|
-
* @returns
|
|
4658
|
+
*
|
|
4659
|
+
* @param key
|
|
4660
|
+
* @returns
|
|
4648
4661
|
*/
|
|
4649
4662
|
whereTodayOrAfter(key) {
|
|
4650
4663
|
const [start] = this.getUtcDayBounds();
|
|
@@ -4661,9 +4674,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4661
4674
|
}
|
|
4662
4675
|
/**
|
|
4663
4676
|
* Adds "where exists" SQL clauses.
|
|
4664
|
-
*
|
|
4665
|
-
* @param queryOrCallback
|
|
4666
|
-
* @returns
|
|
4677
|
+
*
|
|
4678
|
+
* @param queryOrCallback
|
|
4679
|
+
* @returns
|
|
4667
4680
|
*/
|
|
4668
4681
|
whereExists(queryOrCallback) {
|
|
4669
4682
|
const baseQuery = new QueryBuilder(this.model, this.adapter);
|
|
@@ -4803,12 +4816,12 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4803
4816
|
/**
|
|
4804
4817
|
* Append a structured JSON predicate, splitting a `column->path->key`
|
|
4805
4818
|
* expression into its base column and nested path segments.
|
|
4806
|
-
*
|
|
4807
|
-
* @param boolean
|
|
4808
|
-
* @param kind
|
|
4809
|
-
* @param column
|
|
4810
|
-
* @param options
|
|
4811
|
-
* @returns
|
|
4819
|
+
*
|
|
4820
|
+
* @param boolean
|
|
4821
|
+
* @param kind
|
|
4822
|
+
* @param column
|
|
4823
|
+
* @param options
|
|
4824
|
+
* @returns
|
|
4812
4825
|
*/
|
|
4813
4826
|
appendJsonCondition(boolean, kind, column, options = {}) {
|
|
4814
4827
|
const [base, ...path] = column.split("->").map((segment) => segment.trim());
|
|
@@ -4837,10 +4850,10 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4837
4850
|
}
|
|
4838
4851
|
/**
|
|
4839
4852
|
* OR variant of whereJsonContains().
|
|
4840
|
-
*
|
|
4841
|
-
* @param column
|
|
4842
|
-
* @param value
|
|
4843
|
-
* @returns
|
|
4853
|
+
*
|
|
4854
|
+
* @param column
|
|
4855
|
+
* @param value
|
|
4856
|
+
* @returns
|
|
4844
4857
|
*/
|
|
4845
4858
|
orWhereJsonContains(column, value) {
|
|
4846
4859
|
return this.appendJsonCondition("OR", "contains", column, { value });
|
|
@@ -4860,10 +4873,10 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4860
4873
|
}
|
|
4861
4874
|
/**
|
|
4862
4875
|
* OR variant of whereJsonDoesntContain().
|
|
4863
|
-
*
|
|
4864
|
-
* @param column
|
|
4865
|
-
* @param value
|
|
4866
|
-
* @returns
|
|
4876
|
+
*
|
|
4877
|
+
* @param column
|
|
4878
|
+
* @param value
|
|
4879
|
+
* @returns
|
|
4867
4880
|
*/
|
|
4868
4881
|
orWhereJsonDoesntContain(column, value) {
|
|
4869
4882
|
return this.appendJsonCondition("OR", "contains", column, {
|
|
@@ -4882,9 +4895,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4882
4895
|
}
|
|
4883
4896
|
/**
|
|
4884
4897
|
* OR variant of whereJsonContainsKey().
|
|
4885
|
-
*
|
|
4886
|
-
* @param column
|
|
4887
|
-
* @returns
|
|
4898
|
+
*
|
|
4899
|
+
* @param column
|
|
4900
|
+
* @returns
|
|
4888
4901
|
*/
|
|
4889
4902
|
orWhereJsonContainsKey(column) {
|
|
4890
4903
|
return this.appendJsonCondition("OR", "contains-key", column);
|
|
@@ -4900,9 +4913,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4900
4913
|
}
|
|
4901
4914
|
/**
|
|
4902
4915
|
* OR variant of whereJsonDoesntContainKey().
|
|
4903
|
-
*
|
|
4904
|
-
* @param column
|
|
4905
|
-
* @returns
|
|
4916
|
+
*
|
|
4917
|
+
* @param column
|
|
4918
|
+
* @returns
|
|
4906
4919
|
*/
|
|
4907
4920
|
orWhereJsonDoesntContainKey(column) {
|
|
4908
4921
|
return this.appendJsonCondition("OR", "contains-key", column, { not: true });
|
|
@@ -4944,10 +4957,10 @@ var QueryBuilder = class QueryBuilder {
|
|
|
4944
4957
|
}
|
|
4945
4958
|
/**
|
|
4946
4959
|
* OR variant of whereJsonOverlaps().
|
|
4947
|
-
*
|
|
4948
|
-
* @param column
|
|
4949
|
-
* @param value
|
|
4950
|
-
* @returns
|
|
4960
|
+
*
|
|
4961
|
+
* @param column
|
|
4962
|
+
* @param value
|
|
4963
|
+
* @returns
|
|
4951
4964
|
*/
|
|
4952
4965
|
orWhereJsonOverlaps(column, value) {
|
|
4953
4966
|
return this.appendJsonCondition("OR", "overlaps", column, { value });
|
|
@@ -5065,9 +5078,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5065
5078
|
}
|
|
5066
5079
|
/**
|
|
5067
5080
|
* Adds an orderBy clause to the query. This will overwrite any existing orderBy clause.
|
|
5068
|
-
*
|
|
5069
|
-
* @param orderBy
|
|
5070
|
-
* @returns
|
|
5081
|
+
*
|
|
5082
|
+
* @param orderBy
|
|
5083
|
+
* @returns
|
|
5071
5084
|
*/
|
|
5072
5085
|
orderBy(orderBy) {
|
|
5073
5086
|
this.randomOrderEnabled = false;
|
|
@@ -5121,9 +5134,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5121
5134
|
}
|
|
5122
5135
|
/**
|
|
5123
5136
|
* Adds an include clause to the query. This will overwrite any existing include clause.
|
|
5124
|
-
*
|
|
5125
|
-
* @param include
|
|
5126
|
-
* @returns
|
|
5137
|
+
*
|
|
5138
|
+
* @param include
|
|
5139
|
+
* @returns
|
|
5127
5140
|
*/
|
|
5128
5141
|
include(include) {
|
|
5129
5142
|
const normalized = this.normalizeRelationLoads(include);
|
|
@@ -5136,11 +5149,11 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5136
5149
|
return this;
|
|
5137
5150
|
}
|
|
5138
5151
|
/**
|
|
5139
|
-
* Adds eager loading for the specified relations.
|
|
5152
|
+
* Adds eager loading for the specified relations.
|
|
5140
5153
|
* This will merge with any existing include clause.
|
|
5141
|
-
*
|
|
5142
|
-
* @param relations
|
|
5143
|
-
* @returns
|
|
5154
|
+
*
|
|
5155
|
+
* @param relations
|
|
5156
|
+
* @returns
|
|
5144
5157
|
*/
|
|
5145
5158
|
with(relations) {
|
|
5146
5159
|
const relationMap = this.normalizeWith(relations);
|
|
@@ -5342,10 +5355,10 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5342
5355
|
return this.withRelationAggregate("max", relation, column);
|
|
5343
5356
|
}
|
|
5344
5357
|
/**
|
|
5345
|
-
* Includes soft-deleted records in the query results.
|
|
5358
|
+
* Includes soft-deleted records in the query results.
|
|
5346
5359
|
* This method is only applicable if the model has soft delete enabled.
|
|
5347
|
-
*
|
|
5348
|
-
* @returns
|
|
5360
|
+
*
|
|
5361
|
+
* @returns
|
|
5349
5362
|
*/
|
|
5350
5363
|
withTrashed() {
|
|
5351
5364
|
this.includeTrashed = true;
|
|
@@ -5353,10 +5366,10 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5353
5366
|
return this;
|
|
5354
5367
|
}
|
|
5355
5368
|
/**
|
|
5356
|
-
* Limits the query results to only soft-deleted records.
|
|
5369
|
+
* Limits the query results to only soft-deleted records.
|
|
5357
5370
|
* This method is only applicable if the model has soft delete enabled.
|
|
5358
|
-
*
|
|
5359
|
-
* @returns
|
|
5371
|
+
*
|
|
5372
|
+
* @returns
|
|
5360
5373
|
*/
|
|
5361
5374
|
onlyTrashed() {
|
|
5362
5375
|
this.onlyTrashedRecords = true;
|
|
@@ -5364,11 +5377,11 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5364
5377
|
return this;
|
|
5365
5378
|
}
|
|
5366
5379
|
/**
|
|
5367
|
-
* Excludes soft-deleted records from the query results.
|
|
5368
|
-
* This is the default behavior, but this method can be used to explicitly
|
|
5380
|
+
* Excludes soft-deleted records from the query results.
|
|
5381
|
+
* This is the default behavior, but this method can be used to explicitly
|
|
5369
5382
|
* enforce it after using withTrashed or onlyTrashed.
|
|
5370
|
-
*
|
|
5371
|
-
* @returns
|
|
5383
|
+
*
|
|
5384
|
+
* @returns
|
|
5372
5385
|
*/
|
|
5373
5386
|
withoutTrashed() {
|
|
5374
5387
|
this.includeTrashed = false;
|
|
@@ -5377,14 +5390,14 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5377
5390
|
}
|
|
5378
5391
|
/**
|
|
5379
5392
|
* Applies a named scope to the query. A scope is a reusable query constraint
|
|
5380
|
-
* defined as a static method on the model. The scope method will look for a
|
|
5381
|
-
* method with the name `scope{Name}` on the model's prototype.
|
|
5382
|
-
* If found, it will call that method with the current query builder
|
|
5393
|
+
* defined as a static method on the model. The scope method will look for a
|
|
5394
|
+
* method with the name `scope{Name}` on the model's prototype.
|
|
5395
|
+
* If found, it will call that method with the current query builder
|
|
5383
5396
|
* instance and any additional arguments provided.
|
|
5384
|
-
*
|
|
5385
|
-
* @param name
|
|
5386
|
-
* @param args
|
|
5387
|
-
* @returns
|
|
5397
|
+
*
|
|
5398
|
+
* @param name
|
|
5399
|
+
* @param args
|
|
5400
|
+
* @returns
|
|
5388
5401
|
*/
|
|
5389
5402
|
scope(name, ...args) {
|
|
5390
5403
|
const methodName = `scope${name.charAt(0).toUpperCase()}${name.slice(1)}`;
|
|
@@ -5447,9 +5460,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5447
5460
|
}
|
|
5448
5461
|
/**
|
|
5449
5462
|
* Adds a select clause to the query. This will overwrite any existing select clause.
|
|
5450
|
-
*
|
|
5451
|
-
* @param select
|
|
5452
|
-
* @returns
|
|
5463
|
+
*
|
|
5464
|
+
* @param select
|
|
5465
|
+
* @returns
|
|
5453
5466
|
*/
|
|
5454
5467
|
select(select) {
|
|
5455
5468
|
const normalized = this.normalizeQuerySelect(select);
|
|
@@ -5800,9 +5813,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5800
5813
|
/**
|
|
5801
5814
|
* Adds a skip clause to the query for pagination.
|
|
5802
5815
|
* This will overwrite any existing skip clause.
|
|
5803
|
-
*
|
|
5804
|
-
* @param skip
|
|
5805
|
-
* @returns
|
|
5816
|
+
*
|
|
5817
|
+
* @param skip
|
|
5818
|
+
* @returns
|
|
5806
5819
|
*/
|
|
5807
5820
|
skip(skip) {
|
|
5808
5821
|
this.offsetValue = skip;
|
|
@@ -5819,9 +5832,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5819
5832
|
}
|
|
5820
5833
|
/**
|
|
5821
5834
|
* Adds a take clause to the query for pagination.
|
|
5822
|
-
*
|
|
5823
|
-
* @param take
|
|
5824
|
-
* @returns
|
|
5835
|
+
*
|
|
5836
|
+
* @param take
|
|
5837
|
+
* @returns
|
|
5825
5838
|
*/
|
|
5826
5839
|
take(take) {
|
|
5827
5840
|
this.limitValue = take;
|
|
@@ -5838,9 +5851,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5838
5851
|
}
|
|
5839
5852
|
/**
|
|
5840
5853
|
* Returns a representation of the query that can be used for debugging or logging purposes.
|
|
5841
|
-
*
|
|
5842
|
-
* @param operation
|
|
5843
|
-
* @returns
|
|
5854
|
+
*
|
|
5855
|
+
* @param operation
|
|
5856
|
+
* @returns
|
|
5844
5857
|
*/
|
|
5845
5858
|
inspect(operation = "select") {
|
|
5846
5859
|
const adapter = this.requireAdapter();
|
|
@@ -5887,8 +5900,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5887
5900
|
}
|
|
5888
5901
|
/**
|
|
5889
5902
|
* Executes the query and returns the results as a collection of model instances.
|
|
5890
|
-
*
|
|
5891
|
-
* @returns
|
|
5903
|
+
*
|
|
5904
|
+
* @returns
|
|
5892
5905
|
*/
|
|
5893
5906
|
async get() {
|
|
5894
5907
|
const useAdapterRelationFeatures = this.canExecuteRelationFeaturesInAdapter();
|
|
@@ -5909,10 +5922,10 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5909
5922
|
return new ArkormCollection(filteredModels);
|
|
5910
5923
|
}
|
|
5911
5924
|
/**
|
|
5912
|
-
* Executes the query and returns the first result as a model
|
|
5925
|
+
* Executes the query and returns the first result as a model
|
|
5913
5926
|
* instance, or null if no results are found.
|
|
5914
|
-
*
|
|
5915
|
-
* @returns
|
|
5927
|
+
*
|
|
5928
|
+
* @returns
|
|
5916
5929
|
*/
|
|
5917
5930
|
async first() {
|
|
5918
5931
|
if (this.shouldUseCompatibilityRelationFallback()) return (await this.get()).all()[0] ?? null;
|
|
@@ -5933,8 +5946,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5933
5946
|
}
|
|
5934
5947
|
/**
|
|
5935
5948
|
* Executes the query and returns the first result as a model instance.
|
|
5936
|
-
*
|
|
5937
|
-
* @returns
|
|
5949
|
+
*
|
|
5950
|
+
* @returns
|
|
5938
5951
|
*/
|
|
5939
5952
|
async firstOrFail() {
|
|
5940
5953
|
const model = await this.first();
|
|
@@ -6047,9 +6060,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6047
6060
|
}
|
|
6048
6061
|
/**
|
|
6049
6062
|
* Creates a new record with the specified data and returns it as a model instance.
|
|
6050
|
-
*
|
|
6051
|
-
* @param data
|
|
6052
|
-
* @returns
|
|
6063
|
+
*
|
|
6064
|
+
* @param data
|
|
6065
|
+
* @returns
|
|
6053
6066
|
*/
|
|
6054
6067
|
async create(data) {
|
|
6055
6068
|
const created = await this.executeInsertRow(data);
|
|
@@ -6135,11 +6148,11 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6135
6148
|
return this.insertOrIgnore(rows);
|
|
6136
6149
|
}
|
|
6137
6150
|
/**
|
|
6138
|
-
* Updates records matching the current query constraints with the
|
|
6151
|
+
* Updates records matching the current query constraints with the
|
|
6139
6152
|
* specified data and returns the updated record(s) as model instance(s).
|
|
6140
|
-
*
|
|
6141
|
-
* @param data
|
|
6142
|
-
* @returns
|
|
6153
|
+
*
|
|
6154
|
+
* @param data
|
|
6155
|
+
* @returns
|
|
6143
6156
|
*/
|
|
6144
6157
|
async update(data) {
|
|
6145
6158
|
const where = this.buildWhere();
|
|
@@ -6254,8 +6267,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6254
6267
|
/**
|
|
6255
6268
|
* Deletes the first record matching the current query constraints and returns
|
|
6256
6269
|
* it as a hydrated model instance. Returns null when no record matches.
|
|
6257
|
-
*
|
|
6258
|
-
* @returns
|
|
6270
|
+
*
|
|
6271
|
+
* @returns
|
|
6259
6272
|
*/
|
|
6260
6273
|
async delete() {
|
|
6261
6274
|
const where = this.buildWhere();
|
|
@@ -6353,8 +6366,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6353
6366
|
}
|
|
6354
6367
|
/**
|
|
6355
6368
|
* Counts the number of records matching the current query constraints.
|
|
6356
|
-
*
|
|
6357
|
-
* @returns
|
|
6369
|
+
*
|
|
6370
|
+
* @returns
|
|
6358
6371
|
*/
|
|
6359
6372
|
async count() {
|
|
6360
6373
|
if (this.hasRelationFilters() && this.shouldUseCompatibilityRelationFallback()) return (await this.get()).all().length;
|
|
@@ -6395,11 +6408,11 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6395
6408
|
return this.castForPersistence(nextPayload);
|
|
6396
6409
|
});
|
|
6397
6410
|
}
|
|
6398
|
-
/**
|
|
6399
|
-
* Apply the model's persistence casts when a real model backs the query.
|
|
6400
|
-
*
|
|
6401
|
-
* @param payload
|
|
6402
|
-
* @returns
|
|
6411
|
+
/**
|
|
6412
|
+
* Apply the model's persistence casts when a real model backs the query.
|
|
6413
|
+
*
|
|
6414
|
+
* @param payload
|
|
6415
|
+
* @returns
|
|
6403
6416
|
*/
|
|
6404
6417
|
castForPersistence(payload) {
|
|
6405
6418
|
return typeof this.model.castAttributesForPersistence === "function" ? this.model.castAttributesForPersistence(payload) : payload;
|
|
@@ -6561,13 +6574,13 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6561
6574
|
return this;
|
|
6562
6575
|
}
|
|
6563
6576
|
/**
|
|
6564
|
-
* Paginates the query results and returns a LengthAwarePaginator instance
|
|
6577
|
+
* Paginates the query results and returns a LengthAwarePaginator instance
|
|
6565
6578
|
* containing data and total-aware pagination metadata.
|
|
6566
|
-
*
|
|
6567
|
-
* @param page
|
|
6568
|
-
* @param perPage
|
|
6579
|
+
*
|
|
6580
|
+
* @param page
|
|
6581
|
+
* @param perPage
|
|
6569
6582
|
* @param options
|
|
6570
|
-
* @returns
|
|
6583
|
+
* @returns
|
|
6571
6584
|
*/
|
|
6572
6585
|
async paginate(perPage = 15, page = void 0, options = {}) {
|
|
6573
6586
|
const currentPage = this.resolvePaginationPage(page, options);
|
|
@@ -6605,8 +6618,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6605
6618
|
}
|
|
6606
6619
|
/**
|
|
6607
6620
|
* Creates a clone of the current query builder instance with the same state.
|
|
6608
|
-
*
|
|
6609
|
-
* @returns
|
|
6621
|
+
*
|
|
6622
|
+
* @returns
|
|
6610
6623
|
*/
|
|
6611
6624
|
clone() {
|
|
6612
6625
|
const builder = new QueryBuilder(this.model, this.adapter);
|
|
@@ -6636,9 +6649,9 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6636
6649
|
}
|
|
6637
6650
|
/**
|
|
6638
6651
|
* Normalizes the input for eager loading relations into a consistent format.
|
|
6639
|
-
*
|
|
6640
|
-
* @param relations
|
|
6641
|
-
* @returns
|
|
6652
|
+
*
|
|
6653
|
+
* @param relations
|
|
6654
|
+
* @returns
|
|
6642
6655
|
*/
|
|
6643
6656
|
normalizeWith(relations) {
|
|
6644
6657
|
if (typeof relations === "string") return { [relations]: void 0 };
|
|
@@ -6827,7 +6840,7 @@ var QueryBuilder = class QueryBuilder {
|
|
|
6827
6840
|
}
|
|
6828
6841
|
/**
|
|
6829
6842
|
* Attempts to build relation load plans for the adapter based on the eager loads specified in the query builder.
|
|
6830
|
-
*
|
|
6843
|
+
*
|
|
6831
6844
|
* @returns an array of RelationLoadPlan if successful, or null if the eager loads contain constraints that cannot be represented in a way compatible with adapter-based loading.
|
|
6832
6845
|
*/
|
|
6833
6846
|
tryBuildAdapterRelationLoadPlans() {
|
|
@@ -7295,10 +7308,10 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7295
7308
|
return deleted;
|
|
7296
7309
|
}
|
|
7297
7310
|
/**
|
|
7298
|
-
* Builds the where clause for the query, taking into account soft delete
|
|
7311
|
+
* Builds the where clause for the query, taking into account soft delete
|
|
7299
7312
|
* settings if applicable.
|
|
7300
|
-
*
|
|
7301
|
-
* @returns
|
|
7313
|
+
*
|
|
7314
|
+
* @returns
|
|
7302
7315
|
*/
|
|
7303
7316
|
buildWhere() {
|
|
7304
7317
|
const baseWhere = this.legacyWhere ?? this.toQuerySchemaWhere(this.queryWhere);
|
|
@@ -7311,14 +7324,14 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7311
7324
|
}
|
|
7312
7325
|
/**
|
|
7313
7326
|
* Builds the arguments for the findMany delegate method, including the where clause.
|
|
7314
|
-
*
|
|
7315
|
-
* @returns
|
|
7327
|
+
*
|
|
7328
|
+
* @returns
|
|
7316
7329
|
*/
|
|
7317
7330
|
/**
|
|
7318
|
-
* Resolves a unique where clause for update and delete operations.
|
|
7319
|
-
*
|
|
7320
|
-
* @param where
|
|
7321
|
-
* @returns
|
|
7331
|
+
* Resolves a unique where clause for update and delete operations.
|
|
7332
|
+
*
|
|
7333
|
+
* @param where
|
|
7334
|
+
* @returns
|
|
7322
7335
|
*/
|
|
7323
7336
|
async resolveUniqueWhere(where, failIfMissing = true) {
|
|
7324
7337
|
if (this.isUniqueWhere(where)) return where;
|
|
@@ -7349,11 +7362,11 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7349
7362
|
return { [primaryKey]: row[primaryKey] };
|
|
7350
7363
|
}
|
|
7351
7364
|
/**
|
|
7352
|
-
* Checks if the provided where clause is already a unique
|
|
7365
|
+
* Checks if the provided where clause is already a unique
|
|
7353
7366
|
* identifier (i.e., contains only an 'id' field).
|
|
7354
|
-
*
|
|
7355
|
-
* @param where
|
|
7356
|
-
* @returns
|
|
7367
|
+
*
|
|
7368
|
+
* @param where
|
|
7369
|
+
* @returns
|
|
7357
7370
|
*/
|
|
7358
7371
|
isUniqueWhere(where) {
|
|
7359
7372
|
const primaryKey = this.model.getPrimaryKey();
|
|
@@ -7623,10 +7636,10 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7623
7636
|
//#endregion
|
|
7624
7637
|
//#region src/Model.ts
|
|
7625
7638
|
/**
|
|
7626
|
-
* Base model class that all models should extend.
|
|
7627
|
-
*
|
|
7639
|
+
* Base model class that all models should extend.
|
|
7640
|
+
*
|
|
7628
7641
|
* @template TModel The type of the model extending this base class.
|
|
7629
|
-
*
|
|
7642
|
+
*
|
|
7630
7643
|
* @author Legacy (3m1n3nc3)
|
|
7631
7644
|
* @since 0.1.0
|
|
7632
7645
|
*/
|
|
@@ -7977,9 +7990,9 @@ var Model = class Model {
|
|
|
7977
7990
|
* If a delegate name is provided, it will attempt to resolve that delegate.
|
|
7978
7991
|
* Otherwise, it will attempt to resolve a compatibility schema based on the model's name or
|
|
7979
7992
|
* the static `delegate` property.
|
|
7980
|
-
*
|
|
7981
|
-
* @param delegate
|
|
7982
|
-
* @returns
|
|
7993
|
+
*
|
|
7994
|
+
* @param delegate
|
|
7995
|
+
* @returns
|
|
7983
7996
|
*/
|
|
7984
7997
|
static getDelegate(delegate) {
|
|
7985
7998
|
Model.emitDeprecationWarning("ARKORM_GET_DELEGATE_DEPRECATED", "Model.getDelegate() is deprecated and will be removed in Arkorm 3.0. Use Model.getAdapter() and adapter-backed execution instead.");
|
|
@@ -8001,9 +8014,9 @@ var Model = class Model {
|
|
|
8001
8014
|
}
|
|
8002
8015
|
/**
|
|
8003
8016
|
* Get a new query builder instance for the model.
|
|
8004
|
-
*
|
|
8005
|
-
* @param this
|
|
8006
|
-
* @returns
|
|
8017
|
+
*
|
|
8018
|
+
* @param this
|
|
8019
|
+
* @returns
|
|
8007
8020
|
*/
|
|
8008
8021
|
static query() {
|
|
8009
8022
|
Model.ensureModelBooted(this);
|
|
@@ -8029,31 +8042,31 @@ var Model = class Model {
|
|
|
8029
8042
|
static booted() {}
|
|
8030
8043
|
/**
|
|
8031
8044
|
* Get a query builder instance that includes soft-deleted records.
|
|
8032
|
-
*
|
|
8033
|
-
* @param this
|
|
8034
|
-
* @returns
|
|
8045
|
+
*
|
|
8046
|
+
* @param this
|
|
8047
|
+
* @returns
|
|
8035
8048
|
*/
|
|
8036
8049
|
static withTrashed() {
|
|
8037
8050
|
return this.query().withTrashed();
|
|
8038
8051
|
}
|
|
8039
8052
|
/**
|
|
8040
8053
|
* Get a query builder instance that only includes soft-deleted records.
|
|
8041
|
-
*
|
|
8042
|
-
* @param this
|
|
8043
|
-
* @returns
|
|
8054
|
+
*
|
|
8055
|
+
* @param this
|
|
8056
|
+
* @returns
|
|
8044
8057
|
*/
|
|
8045
8058
|
static onlyTrashed() {
|
|
8046
8059
|
return this.query().onlyTrashed();
|
|
8047
8060
|
}
|
|
8048
8061
|
/**
|
|
8049
|
-
* Get a query builder instance that excludes soft-deleted records.
|
|
8050
|
-
* This is the default behavior of the query builder, but this method can be used
|
|
8062
|
+
* Get a query builder instance that excludes soft-deleted records.
|
|
8063
|
+
* This is the default behavior of the query builder, but this method can be used
|
|
8051
8064
|
* to explicitly specify it after using `withTrashed` or `onlyTrashed`.
|
|
8052
|
-
*
|
|
8053
|
-
* @param this
|
|
8054
|
-
* @param name
|
|
8055
|
-
* @param args
|
|
8056
|
-
* @returns
|
|
8065
|
+
*
|
|
8066
|
+
* @param this
|
|
8067
|
+
* @param name
|
|
8068
|
+
* @param args
|
|
8069
|
+
* @returns
|
|
8057
8070
|
*/
|
|
8058
8071
|
static scope(name, ...args) {
|
|
8059
8072
|
return this.query().scope(name, ...args);
|
|
@@ -8121,10 +8134,10 @@ var Model = class Model {
|
|
|
8121
8134
|
return deleted;
|
|
8122
8135
|
}
|
|
8123
8136
|
/**
|
|
8124
|
-
* Get the soft delete configuration for the model, including whether
|
|
8137
|
+
* Get the soft delete configuration for the model, including whether
|
|
8125
8138
|
* soft deletes are enabled and the name of the deleted at column.
|
|
8126
|
-
*
|
|
8127
|
-
* @returns
|
|
8139
|
+
*
|
|
8140
|
+
* @returns
|
|
8128
8141
|
*/
|
|
8129
8142
|
static getSoftDeleteConfig() {
|
|
8130
8143
|
return {
|
|
@@ -8133,11 +8146,11 @@ var Model = class Model {
|
|
|
8133
8146
|
};
|
|
8134
8147
|
}
|
|
8135
8148
|
/**
|
|
8136
|
-
* Hydrate a model instance from a plain object of attributes.
|
|
8137
|
-
*
|
|
8138
|
-
* @param this
|
|
8139
|
-
* @param attributes
|
|
8140
|
-
* @returns
|
|
8149
|
+
* Hydrate a model instance from a plain object of attributes.
|
|
8150
|
+
*
|
|
8151
|
+
* @param this
|
|
8152
|
+
* @param attributes
|
|
8153
|
+
* @returns
|
|
8141
8154
|
*/
|
|
8142
8155
|
static hydrate(attributes) {
|
|
8143
8156
|
const model = new this(attributes);
|
|
@@ -8148,10 +8161,10 @@ var Model = class Model {
|
|
|
8148
8161
|
}
|
|
8149
8162
|
/**
|
|
8150
8163
|
* Hydrate multiple model instances from an array of plain objects of attributes.
|
|
8151
|
-
*
|
|
8152
|
-
* @param this
|
|
8153
|
-
* @param attributes
|
|
8154
|
-
* @returns
|
|
8164
|
+
*
|
|
8165
|
+
* @param this
|
|
8166
|
+
* @param attributes
|
|
8167
|
+
* @returns
|
|
8155
8168
|
*/
|
|
8156
8169
|
static hydrateMany(attributes) {
|
|
8157
8170
|
const constructor = this;
|
|
@@ -8291,12 +8304,12 @@ var Model = class Model {
|
|
|
8291
8304
|
return await this.constructor.transaction(async () => await this.save());
|
|
8292
8305
|
}
|
|
8293
8306
|
/**
|
|
8294
|
-
* Delete the model from the database.
|
|
8295
|
-
* If soft deletes are enabled, it will perform a soft delete by
|
|
8296
|
-
* setting the deleted at column to the current date.
|
|
8307
|
+
* Delete the model from the database.
|
|
8308
|
+
* If soft deletes are enabled, it will perform a soft delete by
|
|
8309
|
+
* setting the deleted at column to the current date.
|
|
8297
8310
|
* Otherwise, it will perform a hard delete.
|
|
8298
|
-
*
|
|
8299
|
-
* @returns
|
|
8311
|
+
*
|
|
8312
|
+
* @returns
|
|
8300
8313
|
*/
|
|
8301
8314
|
async delete() {
|
|
8302
8315
|
const constructor = this.constructor;
|
|
@@ -8340,10 +8353,10 @@ var Model = class Model {
|
|
|
8340
8353
|
return await this.constructor.transaction(async () => await this.delete());
|
|
8341
8354
|
}
|
|
8342
8355
|
/**
|
|
8343
|
-
* Permanently delete the model from the database, regardless of whether soft
|
|
8356
|
+
* Permanently delete the model from the database, regardless of whether soft
|
|
8344
8357
|
* deletes are enabled.
|
|
8345
|
-
*
|
|
8346
|
-
* @returns
|
|
8358
|
+
*
|
|
8359
|
+
* @returns
|
|
8347
8360
|
*/
|
|
8348
8361
|
async forceDelete() {
|
|
8349
8362
|
const constructor = this.constructor;
|
|
@@ -8372,8 +8385,8 @@ var Model = class Model {
|
|
|
8372
8385
|
}
|
|
8373
8386
|
/**
|
|
8374
8387
|
* Restore a soft-deleted model by setting the deleted at column to null.
|
|
8375
|
-
*
|
|
8376
|
-
* @returns
|
|
8388
|
+
*
|
|
8389
|
+
* @returns
|
|
8377
8390
|
*/
|
|
8378
8391
|
async restore() {
|
|
8379
8392
|
const constructor = this.constructor;
|
|
@@ -8401,9 +8414,9 @@ var Model = class Model {
|
|
|
8401
8414
|
}
|
|
8402
8415
|
/**
|
|
8403
8416
|
* Load related models onto the current model instance.
|
|
8404
|
-
*
|
|
8405
|
-
* @param relations
|
|
8406
|
-
* @returns
|
|
8417
|
+
*
|
|
8418
|
+
* @param relations
|
|
8419
|
+
* @returns
|
|
8407
8420
|
*/
|
|
8408
8421
|
async load(relations) {
|
|
8409
8422
|
const relationMap = this.normalizeRelationMap(relations);
|
|
@@ -8469,8 +8482,8 @@ var Model = class Model {
|
|
|
8469
8482
|
}
|
|
8470
8483
|
/**
|
|
8471
8484
|
* Get the raw attributes of the model without applying any mutators or casts.
|
|
8472
|
-
*
|
|
8473
|
-
* @returns
|
|
8485
|
+
*
|
|
8486
|
+
* @returns
|
|
8474
8487
|
*/
|
|
8475
8488
|
getRawAttributes() {
|
|
8476
8489
|
return { ...this.attributes };
|
|
@@ -8531,10 +8544,10 @@ var Model = class Model {
|
|
|
8531
8544
|
}, {});
|
|
8532
8545
|
}
|
|
8533
8546
|
/**
|
|
8534
|
-
* Convert the model instance to a plain object, applying visibility
|
|
8547
|
+
* Convert the model instance to a plain object, applying visibility
|
|
8535
8548
|
* rules, appends, and mutators.
|
|
8536
|
-
*
|
|
8537
|
-
* @returns
|
|
8549
|
+
*
|
|
8550
|
+
* @returns
|
|
8538
8551
|
*/
|
|
8539
8552
|
toObject() {
|
|
8540
8553
|
const object = (this.visible.length > 0 ? this.visible : Object.keys(this.attributes).filter((key) => !this.hidden.includes(key))).reduce((accumulator, key) => {
|
|
@@ -8550,8 +8563,8 @@ var Model = class Model {
|
|
|
8550
8563
|
}
|
|
8551
8564
|
/**
|
|
8552
8565
|
* Convert the model instance to JSON by first converting it to a plain object.
|
|
8553
|
-
*
|
|
8554
|
-
* @returns
|
|
8566
|
+
*
|
|
8567
|
+
* @returns
|
|
8555
8568
|
*/
|
|
8556
8569
|
toJSON() {
|
|
8557
8570
|
return this.toObject();
|
|
@@ -8600,11 +8613,11 @@ var Model = class Model {
|
|
|
8600
8613
|
}
|
|
8601
8614
|
/**
|
|
8602
8615
|
* Define a has one relationship.
|
|
8603
|
-
*
|
|
8604
|
-
* @param related
|
|
8605
|
-
* @param foreignKey
|
|
8606
|
-
* @param localKey
|
|
8607
|
-
* @returns
|
|
8616
|
+
*
|
|
8617
|
+
* @param related
|
|
8618
|
+
* @param foreignKey
|
|
8619
|
+
* @param localKey
|
|
8620
|
+
* @returns
|
|
8608
8621
|
*/
|
|
8609
8622
|
hasOne(related, foreignKey, localKey) {
|
|
8610
8623
|
const constructor = this.constructor;
|
|
@@ -8612,11 +8625,11 @@ var Model = class Model {
|
|
|
8612
8625
|
}
|
|
8613
8626
|
/**
|
|
8614
8627
|
* Define a has many relationship.
|
|
8615
|
-
*
|
|
8616
|
-
* @param related
|
|
8617
|
-
* @param foreignKey
|
|
8618
|
-
* @param localKey
|
|
8619
|
-
* @returns
|
|
8628
|
+
*
|
|
8629
|
+
* @param related
|
|
8630
|
+
* @param foreignKey
|
|
8631
|
+
* @param localKey
|
|
8632
|
+
* @returns
|
|
8620
8633
|
*/
|
|
8621
8634
|
hasMany(related, foreignKey, localKey) {
|
|
8622
8635
|
const constructor = this.constructor;
|
|
@@ -8624,25 +8637,25 @@ var Model = class Model {
|
|
|
8624
8637
|
}
|
|
8625
8638
|
/**
|
|
8626
8639
|
* Define a belongs to relationship.
|
|
8627
|
-
*
|
|
8628
|
-
* @param related
|
|
8629
|
-
* @param foreignKey
|
|
8630
|
-
* @param ownerKey
|
|
8631
|
-
* @returns
|
|
8640
|
+
*
|
|
8641
|
+
* @param related
|
|
8642
|
+
* @param foreignKey
|
|
8643
|
+
* @param ownerKey
|
|
8644
|
+
* @returns
|
|
8632
8645
|
*/
|
|
8633
8646
|
belongsTo(related, foreignKey, ownerKey) {
|
|
8634
8647
|
return new BelongsToRelation(this, related, foreignKey, ownerKey ?? related.getPrimaryKey());
|
|
8635
8648
|
}
|
|
8636
8649
|
/**
|
|
8637
8650
|
* Define a belongs to many relationship.
|
|
8638
|
-
*
|
|
8639
|
-
* @param related
|
|
8651
|
+
*
|
|
8652
|
+
* @param related
|
|
8640
8653
|
* @param throughTable
|
|
8641
|
-
* @param foreignPivotKey
|
|
8642
|
-
* @param relatedPivotKey
|
|
8643
|
-
* @param parentKey
|
|
8644
|
-
* @param relatedKey
|
|
8645
|
-
* @returns
|
|
8654
|
+
* @param foreignPivotKey
|
|
8655
|
+
* @param relatedPivotKey
|
|
8656
|
+
* @param parentKey
|
|
8657
|
+
* @param relatedKey
|
|
8658
|
+
* @returns
|
|
8646
8659
|
*/
|
|
8647
8660
|
belongsToMany(related, throughTable, foreignPivotKey, relatedPivotKey, parentKey, relatedKey) {
|
|
8648
8661
|
const constructor = this.constructor;
|
|
@@ -8650,14 +8663,14 @@ var Model = class Model {
|
|
|
8650
8663
|
}
|
|
8651
8664
|
/**
|
|
8652
8665
|
* Define a has one through relationship.
|
|
8653
|
-
*
|
|
8654
|
-
* @param related
|
|
8666
|
+
*
|
|
8667
|
+
* @param related
|
|
8655
8668
|
* @param throughTable
|
|
8656
|
-
* @param firstKey
|
|
8657
|
-
* @param secondKey
|
|
8658
|
-
* @param localKey
|
|
8659
|
-
* @param secondLocalKey
|
|
8660
|
-
* @returns
|
|
8669
|
+
* @param firstKey
|
|
8670
|
+
* @param secondKey
|
|
8671
|
+
* @param localKey
|
|
8672
|
+
* @param secondLocalKey
|
|
8673
|
+
* @returns
|
|
8661
8674
|
*/
|
|
8662
8675
|
hasOneThrough(related, throughTable, firstKey, secondKey, localKey, secondLocalKey = "id") {
|
|
8663
8676
|
const constructor = this.constructor;
|
|
@@ -8665,14 +8678,14 @@ var Model = class Model {
|
|
|
8665
8678
|
}
|
|
8666
8679
|
/**
|
|
8667
8680
|
* Define a has many through relationship.
|
|
8668
|
-
*
|
|
8669
|
-
* @param related
|
|
8681
|
+
*
|
|
8682
|
+
* @param related
|
|
8670
8683
|
* @param throughTable
|
|
8671
|
-
* @param firstKey
|
|
8672
|
-
* @param secondKey
|
|
8673
|
-
* @param localKey
|
|
8674
|
-
* @param secondLocalKey
|
|
8675
|
-
* @returns
|
|
8684
|
+
* @param firstKey
|
|
8685
|
+
* @param secondKey
|
|
8686
|
+
* @param localKey
|
|
8687
|
+
* @param secondLocalKey
|
|
8688
|
+
* @returns
|
|
8676
8689
|
*/
|
|
8677
8690
|
hasManyThrough(related, throughTable, firstKey, secondKey, localKey, secondLocalKey = "id") {
|
|
8678
8691
|
const constructor = this.constructor;
|
|
@@ -8680,13 +8693,13 @@ var Model = class Model {
|
|
|
8680
8693
|
}
|
|
8681
8694
|
/**
|
|
8682
8695
|
* Define a polymorphic one to one relationship.
|
|
8683
|
-
*
|
|
8684
|
-
* @param related
|
|
8696
|
+
*
|
|
8697
|
+
* @param related
|
|
8685
8698
|
* @param morphName
|
|
8686
8699
|
* @param idColumn
|
|
8687
8700
|
* @param typeColumn
|
|
8688
8701
|
* @param localKey
|
|
8689
|
-
* @returns
|
|
8702
|
+
* @returns
|
|
8690
8703
|
*/
|
|
8691
8704
|
morphOne(related, morphName, idColumn, typeColumn, localKey) {
|
|
8692
8705
|
const constructor = this.constructor;
|
|
@@ -8695,13 +8708,13 @@ var Model = class Model {
|
|
|
8695
8708
|
}
|
|
8696
8709
|
/**
|
|
8697
8710
|
* Define a polymorphic one to many relationship.
|
|
8698
|
-
*
|
|
8699
|
-
* @param related
|
|
8711
|
+
*
|
|
8712
|
+
* @param related
|
|
8700
8713
|
* @param morphName
|
|
8701
8714
|
* @param idColumn
|
|
8702
8715
|
* @param typeColumn
|
|
8703
8716
|
* @param localKey
|
|
8704
|
-
* @returns
|
|
8717
|
+
* @returns
|
|
8705
8718
|
*/
|
|
8706
8719
|
morphMany(related, morphName, idColumn, typeColumn, localKey) {
|
|
8707
8720
|
const constructor = this.constructor;
|
|
@@ -8716,7 +8729,7 @@ var Model = class Model {
|
|
|
8716
8729
|
}
|
|
8717
8730
|
/**
|
|
8718
8731
|
* Define a polymorphic many to many relationship.
|
|
8719
|
-
*
|
|
8732
|
+
*
|
|
8720
8733
|
* @param related
|
|
8721
8734
|
* @param morphName
|
|
8722
8735
|
* @param throughTable
|
|
@@ -8725,7 +8738,7 @@ var Model = class Model {
|
|
|
8725
8738
|
* @param relatedPivotKey
|
|
8726
8739
|
* @param parentKey
|
|
8727
8740
|
* @param relatedKey
|
|
8728
|
-
* @returns
|
|
8741
|
+
* @returns
|
|
8729
8742
|
*/
|
|
8730
8743
|
morphToMany(related, morphName, throughTable, foreignPivotKey, morphTypeColumn, relatedPivotKey, parentKey, relatedKey) {
|
|
8731
8744
|
const constructor = this.constructor;
|
|
@@ -8753,9 +8766,9 @@ var Model = class Model {
|
|
|
8753
8766
|
}
|
|
8754
8767
|
/**
|
|
8755
8768
|
* Resolve a get mutator method for a given attribute key, if it exists.
|
|
8756
|
-
*
|
|
8757
|
-
* @param key
|
|
8758
|
-
* @returns
|
|
8769
|
+
*
|
|
8770
|
+
* @param key
|
|
8771
|
+
* @returns
|
|
8759
8772
|
*/
|
|
8760
8773
|
resolveGetMutator(key) {
|
|
8761
8774
|
const methodName = `get${str(key).studly()}Attribute`;
|
|
@@ -8819,9 +8832,9 @@ var Model = class Model {
|
|
|
8819
8832
|
}
|
|
8820
8833
|
/**
|
|
8821
8834
|
* Resolve a set mutator method for a given attribute key, if it exists.
|
|
8822
|
-
*
|
|
8823
|
-
* @param key
|
|
8824
|
-
* @returns
|
|
8835
|
+
*
|
|
8836
|
+
* @param key
|
|
8837
|
+
* @returns
|
|
8825
8838
|
*/
|
|
8826
8839
|
resolveSetMutator(key) {
|
|
8827
8840
|
const methodName = `set${str(key).studly()}Attribute`;
|
|
@@ -9048,9 +9061,9 @@ var Model = class Model {
|
|
|
9048
9061
|
}
|
|
9049
9062
|
/**
|
|
9050
9063
|
* Normalize the relation map for eager loading.
|
|
9051
|
-
*
|
|
9052
|
-
* @param relations
|
|
9053
|
-
* @returns
|
|
9064
|
+
*
|
|
9065
|
+
* @param relations
|
|
9066
|
+
* @returns
|
|
9054
9067
|
*/
|
|
9055
9068
|
normalizeRelationMap(relations) {
|
|
9056
9069
|
if (typeof relations === "string") return { [relations]: void 0 };
|
|
@@ -9068,9 +9081,9 @@ var Model = class Model {
|
|
|
9068
9081
|
//#endregion
|
|
9069
9082
|
//#region src/database/factories.ts
|
|
9070
9083
|
/**
|
|
9071
|
-
* Base class for defining model factories.
|
|
9084
|
+
* Base class for defining model factories.
|
|
9072
9085
|
* Not meant to be used directly.
|
|
9073
|
-
*
|
|
9086
|
+
*
|
|
9074
9087
|
* @template TModel The type of model the factory creates.
|
|
9075
9088
|
* @template TAttributes The type of attributes used to create the model.
|
|
9076
9089
|
* @author Legacy (3m1n3nc3)
|
|
@@ -9096,9 +9109,9 @@ var ModelFactory = class ModelFactory {
|
|
|
9096
9109
|
configure() {}
|
|
9097
9110
|
/**
|
|
9098
9111
|
* Set the number of models to create.
|
|
9099
|
-
*
|
|
9100
|
-
* @param amount
|
|
9101
|
-
* @returns
|
|
9112
|
+
*
|
|
9113
|
+
* @param amount
|
|
9114
|
+
* @returns
|
|
9102
9115
|
*/
|
|
9103
9116
|
count(amount) {
|
|
9104
9117
|
this.ensureConfigured();
|
|
@@ -9106,9 +9119,9 @@ var ModelFactory = class ModelFactory {
|
|
|
9106
9119
|
return this;
|
|
9107
9120
|
}
|
|
9108
9121
|
/**
|
|
9109
|
-
* Define a state transformation for the factory.
|
|
9122
|
+
* Define a state transformation for the factory.
|
|
9110
9123
|
* States are applied in the order they were defined.
|
|
9111
|
-
*
|
|
9124
|
+
*
|
|
9112
9125
|
* @param resolver A function that takes the current attributes and sequence number, and returns the transformed attributes.
|
|
9113
9126
|
* @returns The factory instance for chaining.
|
|
9114
9127
|
*/
|
|
@@ -9119,9 +9132,9 @@ var ModelFactory = class ModelFactory {
|
|
|
9119
9132
|
}
|
|
9120
9133
|
/**
|
|
9121
9134
|
* Register a callback that runs after a model is made.
|
|
9122
|
-
*
|
|
9123
|
-
* @param callback
|
|
9124
|
-
* @returns
|
|
9135
|
+
*
|
|
9136
|
+
* @param callback
|
|
9137
|
+
* @returns
|
|
9125
9138
|
*/
|
|
9126
9139
|
afterMaking(callback) {
|
|
9127
9140
|
this.ensureConfigured();
|
|
@@ -9130,9 +9143,9 @@ var ModelFactory = class ModelFactory {
|
|
|
9130
9143
|
}
|
|
9131
9144
|
/**
|
|
9132
9145
|
* Register a callback that runs after a model is persisted.
|
|
9133
|
-
*
|
|
9134
|
-
* @param callback
|
|
9135
|
-
* @returns
|
|
9146
|
+
*
|
|
9147
|
+
* @param callback
|
|
9148
|
+
* @returns
|
|
9136
9149
|
*/
|
|
9137
9150
|
afterCreating(callback) {
|
|
9138
9151
|
this.ensureConfigured();
|
|
@@ -9141,9 +9154,9 @@ var ModelFactory = class ModelFactory {
|
|
|
9141
9154
|
}
|
|
9142
9155
|
/**
|
|
9143
9156
|
* Create a new model instance without saving it to the database.
|
|
9144
|
-
*
|
|
9145
|
-
* @param overrides
|
|
9146
|
-
* @returns
|
|
9157
|
+
*
|
|
9158
|
+
* @param overrides
|
|
9159
|
+
* @returns
|
|
9147
9160
|
*/
|
|
9148
9161
|
make(overrides = {}) {
|
|
9149
9162
|
this.ensureConfigured();
|
|
@@ -9168,10 +9181,10 @@ var ModelFactory = class ModelFactory {
|
|
|
9168
9181
|
}
|
|
9169
9182
|
/**
|
|
9170
9183
|
* Create multiple model instances without saving them to the database.
|
|
9171
|
-
*
|
|
9172
|
-
* @param amount
|
|
9173
|
-
* @param overrides
|
|
9174
|
-
* @returns
|
|
9184
|
+
*
|
|
9185
|
+
* @param amount
|
|
9186
|
+
* @param overrides
|
|
9187
|
+
* @returns
|
|
9175
9188
|
*/
|
|
9176
9189
|
makeMany(amount = this.amount, overrides = {}) {
|
|
9177
9190
|
const total = Math.max(1, Math.floor(amount));
|
|
@@ -9193,19 +9206,19 @@ var ModelFactory = class ModelFactory {
|
|
|
9193
9206
|
}
|
|
9194
9207
|
/**
|
|
9195
9208
|
* Create a new model instance and save it to the database.
|
|
9196
|
-
*
|
|
9197
|
-
* @param overrides
|
|
9198
|
-
* @returns
|
|
9209
|
+
*
|
|
9210
|
+
* @param overrides
|
|
9211
|
+
* @returns
|
|
9199
9212
|
*/
|
|
9200
9213
|
async create(overrides = {}) {
|
|
9201
9214
|
return await this.createPersisted(overrides);
|
|
9202
9215
|
}
|
|
9203
9216
|
/**
|
|
9204
9217
|
* Create multiple model instances and save them to the database.
|
|
9205
|
-
*
|
|
9206
|
-
* @param amount
|
|
9207
|
-
* @param overrides
|
|
9208
|
-
* @returns
|
|
9218
|
+
*
|
|
9219
|
+
* @param amount
|
|
9220
|
+
* @param overrides
|
|
9221
|
+
* @returns
|
|
9209
9222
|
*/
|
|
9210
9223
|
async createMany(amount = this.amount, overrides = {}) {
|
|
9211
9224
|
this.ensureConfigured();
|
|
@@ -9216,10 +9229,10 @@ var ModelFactory = class ModelFactory {
|
|
|
9216
9229
|
}
|
|
9217
9230
|
/**
|
|
9218
9231
|
* Create related models through a has-one or has-many relationship.
|
|
9219
|
-
*
|
|
9220
|
-
* @param factory
|
|
9221
|
-
* @param relationship
|
|
9222
|
-
* @returns
|
|
9232
|
+
*
|
|
9233
|
+
* @param factory
|
|
9234
|
+
* @param relationship
|
|
9235
|
+
* @returns
|
|
9223
9236
|
*/
|
|
9224
9237
|
has(factory, relationship) {
|
|
9225
9238
|
this.ensureConfigured();
|
|
@@ -9231,10 +9244,10 @@ var ModelFactory = class ModelFactory {
|
|
|
9231
9244
|
}
|
|
9232
9245
|
/**
|
|
9233
9246
|
* Associate the created model with a parent model or factory.
|
|
9234
|
-
*
|
|
9235
|
-
* @param related
|
|
9236
|
-
* @param relationship
|
|
9237
|
-
* @returns
|
|
9247
|
+
*
|
|
9248
|
+
* @param related
|
|
9249
|
+
* @param relationship
|
|
9250
|
+
* @returns
|
|
9238
9251
|
*/
|
|
9239
9252
|
for(related, relationship) {
|
|
9240
9253
|
this.ensureConfigured();
|
|
@@ -9246,11 +9259,11 @@ var ModelFactory = class ModelFactory {
|
|
|
9246
9259
|
}
|
|
9247
9260
|
/**
|
|
9248
9261
|
* Create or reuse related models and attach them through a many-to-many relationship.
|
|
9249
|
-
*
|
|
9250
|
-
* @param related
|
|
9251
|
-
* @param pivot
|
|
9252
|
-
* @param relationship
|
|
9253
|
-
* @returns
|
|
9262
|
+
*
|
|
9263
|
+
* @param related
|
|
9264
|
+
* @param pivot
|
|
9265
|
+
* @param relationship
|
|
9266
|
+
* @returns
|
|
9254
9267
|
*/
|
|
9255
9268
|
hasAttached(related, pivot = {}, relationship) {
|
|
9256
9269
|
this.ensureConfigured();
|
|
@@ -9263,9 +9276,9 @@ var ModelFactory = class ModelFactory {
|
|
|
9263
9276
|
}
|
|
9264
9277
|
/**
|
|
9265
9278
|
* Reuse existing models when resolving factory-backed relationships.
|
|
9266
|
-
*
|
|
9267
|
-
* @param models
|
|
9268
|
-
* @returns
|
|
9279
|
+
*
|
|
9280
|
+
* @param models
|
|
9281
|
+
* @returns
|
|
9269
9282
|
*/
|
|
9270
9283
|
recycle(models) {
|
|
9271
9284
|
this.ensureConfigured();
|
|
@@ -9279,18 +9292,18 @@ var ModelFactory = class ModelFactory {
|
|
|
9279
9292
|
}
|
|
9280
9293
|
/**
|
|
9281
9294
|
* Get the model contgructor
|
|
9282
|
-
*
|
|
9283
|
-
* @returns
|
|
9295
|
+
*
|
|
9296
|
+
* @returns
|
|
9284
9297
|
*/
|
|
9285
9298
|
getModelConstructor() {
|
|
9286
9299
|
return this.model;
|
|
9287
9300
|
}
|
|
9288
9301
|
/**
|
|
9289
|
-
* Build the attributes for a model instance, applying the factory
|
|
9302
|
+
* Build the attributes for a model instance, applying the factory
|
|
9290
9303
|
* definition and any defined states, and merging in any overrides.
|
|
9291
|
-
*
|
|
9292
|
-
* @param overrides
|
|
9293
|
-
* @returns
|
|
9304
|
+
*
|
|
9305
|
+
* @param overrides
|
|
9306
|
+
* @returns
|
|
9294
9307
|
*/
|
|
9295
9308
|
buildAttributes(overrides) {
|
|
9296
9309
|
const sequence = this.sequence;
|
|
@@ -9461,11 +9474,11 @@ var ModelFactory = class ModelFactory {
|
|
|
9461
9474
|
}
|
|
9462
9475
|
};
|
|
9463
9476
|
/**
|
|
9464
|
-
* A helper class for defining factories using an inline definition
|
|
9477
|
+
* A helper class for defining factories using an inline definition
|
|
9465
9478
|
* function, without needing to create a separate factory class.
|
|
9466
|
-
*
|
|
9479
|
+
*
|
|
9467
9480
|
* @template TModel
|
|
9468
|
-
* @template TAttributes
|
|
9481
|
+
* @template TAttributes
|
|
9469
9482
|
* @author Legacy (3m1n3nc3)
|
|
9470
9483
|
* @since 0.1.0
|
|
9471
9484
|
*/
|
|
@@ -9481,7 +9494,7 @@ var InlineFactory = class extends ModelFactory {
|
|
|
9481
9494
|
};
|
|
9482
9495
|
/**
|
|
9483
9496
|
* Define a factory for a given model using an inline definition function.
|
|
9484
|
-
*
|
|
9497
|
+
*
|
|
9485
9498
|
* @template TModel The type of model the factory creates.
|
|
9486
9499
|
* @template TAttributes The type of attributes used to create the model.
|
|
9487
9500
|
* @param model The model constructor.
|
|
@@ -9614,10 +9627,10 @@ var DB = class DB {
|
|
|
9614
9627
|
//#endregion
|
|
9615
9628
|
//#region src/PivotModel.ts
|
|
9616
9629
|
/**
|
|
9617
|
-
* Base pivot class that all pivot models should extend.
|
|
9618
|
-
*
|
|
9630
|
+
* Base pivot class that all pivot models should extend.
|
|
9631
|
+
*
|
|
9619
9632
|
* @template TModel The type of the model extending this base class.
|
|
9620
|
-
*
|
|
9633
|
+
*
|
|
9621
9634
|
* @author Legacy (3m1n3nc3)
|
|
9622
9635
|
* @since 2.0.0-next.18
|
|
9623
9636
|
*/
|