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