@h3ravel/arquebus 0.7.1 → 0.7.3
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/bin/index.cjs +76 -76
- package/bin/index.js +76 -76
- package/dist/browser/index.cjs +14 -3
- package/dist/browser/index.d.ts +17 -10
- package/dist/browser/index.js +14 -3
- package/dist/concerns/index.cjs +35 -72
- package/dist/concerns/index.d.ts +214 -236
- package/dist/concerns/index.js +41 -26
- package/dist/index.cjs +116 -116
- package/dist/index.d.ts +51 -42
- package/dist/index.js +114 -114
- package/dist/inspector/index.cjs +5 -5
- package/dist/inspector/index.js +4 -4
- package/dist/migrations/index.cjs +6 -6
- package/dist/migrations/index.d.ts +5 -1
- package/dist/migrations/index.js +10 -10
- package/dist/relations/index.cjs +46 -93
- package/dist/relations/index.d.ts +98 -104
- package/dist/relations/index.js +50 -35
- package/dist/seeders/index.d.ts +5 -1
- package/package.json +1 -1
- package/types/modeling.ts +129 -126
- package/dist/concerns/chunk-Bop6jNiL.js +0 -15
- package/dist/relations/chunk-Bop6jNiL.js +0 -15
package/bin/index.cjs
CHANGED
|
@@ -38,6 +38,8 @@ let resolve_from = require("resolve-from");
|
|
|
38
38
|
resolve_from = __toESM(resolve_from);
|
|
39
39
|
let node_fs_promises = require("node:fs/promises");
|
|
40
40
|
node_fs_promises = __toESM(node_fs_promises);
|
|
41
|
+
let node_path = require("node:path");
|
|
42
|
+
let node_url = require("node:url");
|
|
41
43
|
let radashi = require("radashi");
|
|
42
44
|
let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
|
|
43
45
|
dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js);
|
|
@@ -50,8 +52,6 @@ knex = __toESM(knex);
|
|
|
50
52
|
let fs = require("fs");
|
|
51
53
|
let pluralize = require("pluralize");
|
|
52
54
|
pluralize = __toESM(pluralize);
|
|
53
|
-
let node_path = require("node:path");
|
|
54
|
-
let node_url = require("node:url");
|
|
55
55
|
let __h3ravel_support = require("@h3ravel/support");
|
|
56
56
|
let dotenv = require("dotenv");
|
|
57
57
|
|
|
@@ -1397,6 +1397,79 @@ function extractType(type) {
|
|
|
1397
1397
|
return type.replace(/[^a-zA-Z]/g, "").toLowerCase();
|
|
1398
1398
|
}
|
|
1399
1399
|
|
|
1400
|
+
//#endregion
|
|
1401
|
+
//#region src/seeders/runner.ts
|
|
1402
|
+
async function glob$1(folderPath) {
|
|
1403
|
+
const { default: escalade } = await import("escalade");
|
|
1404
|
+
const entries = [];
|
|
1405
|
+
await escalade(folderPath, async (dir, names) => {
|
|
1406
|
+
await Promise.all(names.map(async (name) => {
|
|
1407
|
+
const p = path.default.join(dir, name);
|
|
1408
|
+
try {
|
|
1409
|
+
await (0, node_fs_promises.access)(p);
|
|
1410
|
+
if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
|
|
1411
|
+
} catch {}
|
|
1412
|
+
}));
|
|
1413
|
+
return "";
|
|
1414
|
+
});
|
|
1415
|
+
return entries;
|
|
1416
|
+
}
|
|
1417
|
+
var SeederRunner = class {
|
|
1418
|
+
resolver;
|
|
1419
|
+
connection;
|
|
1420
|
+
paths = [];
|
|
1421
|
+
constructor(resolver) {
|
|
1422
|
+
this.resolver = resolver;
|
|
1423
|
+
}
|
|
1424
|
+
path(p) {
|
|
1425
|
+
this.paths = Array.from(new Set([...this.paths, p]));
|
|
1426
|
+
}
|
|
1427
|
+
getPaths() {
|
|
1428
|
+
return this.paths;
|
|
1429
|
+
}
|
|
1430
|
+
resolveConnection(connection) {
|
|
1431
|
+
var _getInstance, _ref, _instance$connections;
|
|
1432
|
+
const name = connection || this.connection || "default";
|
|
1433
|
+
const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
|
|
1434
|
+
if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
|
|
1435
|
+
/** noop */
|
|
1436
|
+
});
|
|
1437
|
+
return this.resolver.fire(name);
|
|
1438
|
+
}
|
|
1439
|
+
setConnection(connection) {
|
|
1440
|
+
this.connection = connection;
|
|
1441
|
+
return this;
|
|
1442
|
+
}
|
|
1443
|
+
async getSeederFiles(paths) {
|
|
1444
|
+
const files = [];
|
|
1445
|
+
for (const p of paths) {
|
|
1446
|
+
if (p.endsWith(".js") || p.endsWith(".ts")) {
|
|
1447
|
+
files.push(p);
|
|
1448
|
+
continue;
|
|
1449
|
+
}
|
|
1450
|
+
files.push(...await glob$1(p));
|
|
1451
|
+
}
|
|
1452
|
+
return files;
|
|
1453
|
+
}
|
|
1454
|
+
async resolvePath(filePath) {
|
|
1455
|
+
try {
|
|
1456
|
+
const mod = await import(filePath);
|
|
1457
|
+
return new (mod.default ?? mod.Seeder)();
|
|
1458
|
+
} catch {
|
|
1459
|
+
return null;
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
async run(paths, connection) {
|
|
1463
|
+
const files = await this.getSeederFiles(paths);
|
|
1464
|
+
const conn = this.resolveConnection(connection);
|
|
1465
|
+
for (const file of files) {
|
|
1466
|
+
const seeder = await this.resolvePath(file);
|
|
1467
|
+
if (seeder && typeof seeder.run === "function") await seeder.run(conn);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
var runner_default = SeederRunner;
|
|
1472
|
+
|
|
1400
1473
|
//#endregion
|
|
1401
1474
|
//#region src/casts/attribute.ts
|
|
1402
1475
|
var Attribute = class Attribute {
|
|
@@ -4815,79 +4888,6 @@ var Builder = class Builder extends Inference {
|
|
|
4815
4888
|
};
|
|
4816
4889
|
var builder_default = Builder;
|
|
4817
4890
|
|
|
4818
|
-
//#endregion
|
|
4819
|
-
//#region src/seeders/runner.ts
|
|
4820
|
-
async function glob$1(folderPath) {
|
|
4821
|
-
const { default: escalade } = await import("escalade");
|
|
4822
|
-
const entries = [];
|
|
4823
|
-
await escalade(folderPath, async (dir, names) => {
|
|
4824
|
-
await Promise.all(names.map(async (name) => {
|
|
4825
|
-
const p = path.default.join(dir, name);
|
|
4826
|
-
try {
|
|
4827
|
-
await (0, node_fs_promises.access)(p);
|
|
4828
|
-
if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
|
|
4829
|
-
} catch {}
|
|
4830
|
-
}));
|
|
4831
|
-
return "";
|
|
4832
|
-
});
|
|
4833
|
-
return entries;
|
|
4834
|
-
}
|
|
4835
|
-
var SeederRunner = class {
|
|
4836
|
-
resolver;
|
|
4837
|
-
connection;
|
|
4838
|
-
paths = [];
|
|
4839
|
-
constructor(resolver) {
|
|
4840
|
-
this.resolver = resolver;
|
|
4841
|
-
}
|
|
4842
|
-
path(p) {
|
|
4843
|
-
this.paths = Array.from(new Set([...this.paths, p]));
|
|
4844
|
-
}
|
|
4845
|
-
getPaths() {
|
|
4846
|
-
return this.paths;
|
|
4847
|
-
}
|
|
4848
|
-
resolveConnection(connection) {
|
|
4849
|
-
var _getInstance, _ref, _instance$connections;
|
|
4850
|
-
const name = connection || this.connection || "default";
|
|
4851
|
-
const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
|
|
4852
|
-
if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
|
|
4853
|
-
/** noop */
|
|
4854
|
-
});
|
|
4855
|
-
return this.resolver.fire(name);
|
|
4856
|
-
}
|
|
4857
|
-
setConnection(connection) {
|
|
4858
|
-
this.connection = connection;
|
|
4859
|
-
return this;
|
|
4860
|
-
}
|
|
4861
|
-
async getSeederFiles(paths) {
|
|
4862
|
-
const files = [];
|
|
4863
|
-
for (const p of paths) {
|
|
4864
|
-
if (p.endsWith(".js") || p.endsWith(".ts")) {
|
|
4865
|
-
files.push(p);
|
|
4866
|
-
continue;
|
|
4867
|
-
}
|
|
4868
|
-
files.push(...await glob$1(p));
|
|
4869
|
-
}
|
|
4870
|
-
return files;
|
|
4871
|
-
}
|
|
4872
|
-
async resolvePath(filePath) {
|
|
4873
|
-
try {
|
|
4874
|
-
const mod = await import(filePath);
|
|
4875
|
-
return new (mod.default ?? mod.Seeder)();
|
|
4876
|
-
} catch {
|
|
4877
|
-
return null;
|
|
4878
|
-
}
|
|
4879
|
-
}
|
|
4880
|
-
async run(paths, connection) {
|
|
4881
|
-
const files = await this.getSeederFiles(paths);
|
|
4882
|
-
const conn = this.resolveConnection(connection);
|
|
4883
|
-
for (const file of files) {
|
|
4884
|
-
const seeder = await this.resolvePath(file);
|
|
4885
|
-
if (seeder && typeof seeder.run === "function") await seeder.run(conn);
|
|
4886
|
-
}
|
|
4887
|
-
}
|
|
4888
|
-
};
|
|
4889
|
-
var runner_default = SeederRunner;
|
|
4890
|
-
|
|
4891
4891
|
//#endregion
|
|
4892
4892
|
//#region src/inspector/dialects/sqlite.ts
|
|
4893
4893
|
function parseDefaultValue(value) {
|
|
@@ -5490,7 +5490,7 @@ var MigrationCreator = class {
|
|
|
5490
5490
|
|
|
5491
5491
|
//#endregion
|
|
5492
5492
|
//#region package.json
|
|
5493
|
-
var version = "0.7.
|
|
5493
|
+
var version = "0.7.3";
|
|
5494
5494
|
|
|
5495
5495
|
//#endregion
|
|
5496
5496
|
//#region src/cli/cli.ts
|
package/bin/index.js
CHANGED
|
@@ -5,6 +5,8 @@ import { FileSystem, Logger, TaskManager } from "@h3ravel/shared";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import resolveFrom from "resolve-from";
|
|
7
7
|
import fs, { access, copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
8
|
+
import { dirname } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
8
10
|
import { assign, camel, diff, flat, get, isArray, isEmpty, isEqual, isString, omit, pick, set, snake, trim } from "radashi";
|
|
9
11
|
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
10
12
|
import dayjs from "dayjs";
|
|
@@ -12,8 +14,6 @@ import collect, { Collection, collect as collect$1 } from "collect.js";
|
|
|
12
14
|
import Knex from "knex";
|
|
13
15
|
import { existsSync } from "fs";
|
|
14
16
|
import pluralize from "pluralize";
|
|
15
|
-
import { dirname } from "node:path";
|
|
16
|
-
import { fileURLToPath } from "node:url";
|
|
17
17
|
import { Str } from "@h3ravel/support";
|
|
18
18
|
import { config } from "dotenv";
|
|
19
19
|
|
|
@@ -1371,6 +1371,79 @@ function extractType(type) {
|
|
|
1371
1371
|
return type.replace(/[^a-zA-Z]/g, "").toLowerCase();
|
|
1372
1372
|
}
|
|
1373
1373
|
|
|
1374
|
+
//#endregion
|
|
1375
|
+
//#region src/seeders/runner.ts
|
|
1376
|
+
async function glob$1(folderPath) {
|
|
1377
|
+
const { default: escalade } = await import("escalade");
|
|
1378
|
+
const entries = [];
|
|
1379
|
+
await escalade(folderPath, async (dir, names) => {
|
|
1380
|
+
await Promise.all(names.map(async (name) => {
|
|
1381
|
+
const p = path.join(dir, name);
|
|
1382
|
+
try {
|
|
1383
|
+
await access(p);
|
|
1384
|
+
if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
|
|
1385
|
+
} catch {}
|
|
1386
|
+
}));
|
|
1387
|
+
return "";
|
|
1388
|
+
});
|
|
1389
|
+
return entries;
|
|
1390
|
+
}
|
|
1391
|
+
var SeederRunner = class {
|
|
1392
|
+
resolver;
|
|
1393
|
+
connection;
|
|
1394
|
+
paths = [];
|
|
1395
|
+
constructor(resolver) {
|
|
1396
|
+
this.resolver = resolver;
|
|
1397
|
+
}
|
|
1398
|
+
path(p) {
|
|
1399
|
+
this.paths = Array.from(new Set([...this.paths, p]));
|
|
1400
|
+
}
|
|
1401
|
+
getPaths() {
|
|
1402
|
+
return this.paths;
|
|
1403
|
+
}
|
|
1404
|
+
resolveConnection(connection) {
|
|
1405
|
+
var _getInstance, _ref, _instance$connections;
|
|
1406
|
+
const name = connection || this.connection || "default";
|
|
1407
|
+
const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
|
|
1408
|
+
if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
|
|
1409
|
+
/** noop */
|
|
1410
|
+
});
|
|
1411
|
+
return this.resolver.fire(name);
|
|
1412
|
+
}
|
|
1413
|
+
setConnection(connection) {
|
|
1414
|
+
this.connection = connection;
|
|
1415
|
+
return this;
|
|
1416
|
+
}
|
|
1417
|
+
async getSeederFiles(paths) {
|
|
1418
|
+
const files = [];
|
|
1419
|
+
for (const p of paths) {
|
|
1420
|
+
if (p.endsWith(".js") || p.endsWith(".ts")) {
|
|
1421
|
+
files.push(p);
|
|
1422
|
+
continue;
|
|
1423
|
+
}
|
|
1424
|
+
files.push(...await glob$1(p));
|
|
1425
|
+
}
|
|
1426
|
+
return files;
|
|
1427
|
+
}
|
|
1428
|
+
async resolvePath(filePath) {
|
|
1429
|
+
try {
|
|
1430
|
+
const mod = await import(filePath);
|
|
1431
|
+
return new (mod.default ?? mod.Seeder)();
|
|
1432
|
+
} catch {
|
|
1433
|
+
return null;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
async run(paths, connection) {
|
|
1437
|
+
const files = await this.getSeederFiles(paths);
|
|
1438
|
+
const conn = this.resolveConnection(connection);
|
|
1439
|
+
for (const file of files) {
|
|
1440
|
+
const seeder = await this.resolvePath(file);
|
|
1441
|
+
if (seeder && typeof seeder.run === "function") await seeder.run(conn);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
var runner_default = SeederRunner;
|
|
1446
|
+
|
|
1374
1447
|
//#endregion
|
|
1375
1448
|
//#region src/casts/attribute.ts
|
|
1376
1449
|
var Attribute = class Attribute {
|
|
@@ -4789,79 +4862,6 @@ var Builder = class Builder extends Inference {
|
|
|
4789
4862
|
};
|
|
4790
4863
|
var builder_default = Builder;
|
|
4791
4864
|
|
|
4792
|
-
//#endregion
|
|
4793
|
-
//#region src/seeders/runner.ts
|
|
4794
|
-
async function glob$1(folderPath) {
|
|
4795
|
-
const { default: escalade } = await import("escalade");
|
|
4796
|
-
const entries = [];
|
|
4797
|
-
await escalade(folderPath, async (dir, names) => {
|
|
4798
|
-
await Promise.all(names.map(async (name) => {
|
|
4799
|
-
const p = path.join(dir, name);
|
|
4800
|
-
try {
|
|
4801
|
-
await access(p);
|
|
4802
|
-
if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
|
|
4803
|
-
} catch {}
|
|
4804
|
-
}));
|
|
4805
|
-
return "";
|
|
4806
|
-
});
|
|
4807
|
-
return entries;
|
|
4808
|
-
}
|
|
4809
|
-
var SeederRunner = class {
|
|
4810
|
-
resolver;
|
|
4811
|
-
connection;
|
|
4812
|
-
paths = [];
|
|
4813
|
-
constructor(resolver) {
|
|
4814
|
-
this.resolver = resolver;
|
|
4815
|
-
}
|
|
4816
|
-
path(p) {
|
|
4817
|
-
this.paths = Array.from(new Set([...this.paths, p]));
|
|
4818
|
-
}
|
|
4819
|
-
getPaths() {
|
|
4820
|
-
return this.paths;
|
|
4821
|
-
}
|
|
4822
|
-
resolveConnection(connection) {
|
|
4823
|
-
var _getInstance, _ref, _instance$connections;
|
|
4824
|
-
const name = connection || this.connection || "default";
|
|
4825
|
-
const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
|
|
4826
|
-
if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
|
|
4827
|
-
/** noop */
|
|
4828
|
-
});
|
|
4829
|
-
return this.resolver.fire(name);
|
|
4830
|
-
}
|
|
4831
|
-
setConnection(connection) {
|
|
4832
|
-
this.connection = connection;
|
|
4833
|
-
return this;
|
|
4834
|
-
}
|
|
4835
|
-
async getSeederFiles(paths) {
|
|
4836
|
-
const files = [];
|
|
4837
|
-
for (const p of paths) {
|
|
4838
|
-
if (p.endsWith(".js") || p.endsWith(".ts")) {
|
|
4839
|
-
files.push(p);
|
|
4840
|
-
continue;
|
|
4841
|
-
}
|
|
4842
|
-
files.push(...await glob$1(p));
|
|
4843
|
-
}
|
|
4844
|
-
return files;
|
|
4845
|
-
}
|
|
4846
|
-
async resolvePath(filePath) {
|
|
4847
|
-
try {
|
|
4848
|
-
const mod = await import(filePath);
|
|
4849
|
-
return new (mod.default ?? mod.Seeder)();
|
|
4850
|
-
} catch {
|
|
4851
|
-
return null;
|
|
4852
|
-
}
|
|
4853
|
-
}
|
|
4854
|
-
async run(paths, connection) {
|
|
4855
|
-
const files = await this.getSeederFiles(paths);
|
|
4856
|
-
const conn = this.resolveConnection(connection);
|
|
4857
|
-
for (const file of files) {
|
|
4858
|
-
const seeder = await this.resolvePath(file);
|
|
4859
|
-
if (seeder && typeof seeder.run === "function") await seeder.run(conn);
|
|
4860
|
-
}
|
|
4861
|
-
}
|
|
4862
|
-
};
|
|
4863
|
-
var runner_default = SeederRunner;
|
|
4864
|
-
|
|
4865
4865
|
//#endregion
|
|
4866
4866
|
//#region src/inspector/dialects/sqlite.ts
|
|
4867
4867
|
function parseDefaultValue(value) {
|
|
@@ -5464,7 +5464,7 @@ var MigrationCreator = class {
|
|
|
5464
5464
|
|
|
5465
5465
|
//#endregion
|
|
5466
5466
|
//#region package.json
|
|
5467
|
-
var version = "0.7.
|
|
5467
|
+
var version = "0.7.3";
|
|
5468
5468
|
|
|
5469
5469
|
//#endregion
|
|
5470
5470
|
//#region src/cli/cli.ts
|
package/dist/browser/index.cjs
CHANGED
|
@@ -653,9 +653,20 @@ const HasRelations = (Instance) => {
|
|
|
653
653
|
return data;
|
|
654
654
|
}
|
|
655
655
|
guessBelongsToRelation() {
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
|
|
656
|
+
const e = /* @__PURE__ */ new Error();
|
|
657
|
+
const stack = e.stack || e.stackTrace;
|
|
658
|
+
if (!stack) return getRelationName("unknown");
|
|
659
|
+
const frames = stack.split("\n");
|
|
660
|
+
const frame = frames[2] || frames[1] || frames[0];
|
|
661
|
+
let functionName = "anonymous";
|
|
662
|
+
if (frame.includes("@")) functionName = frame.split("@")[0].trim();
|
|
663
|
+
else if (frame.includes("at ")) {
|
|
664
|
+
const match = frame.match(/at\s+([^(]+)\s*\(/);
|
|
665
|
+
functionName = match ? match[1].trim() : "anonymous";
|
|
666
|
+
if (functionName === null || functionName === void 0 ? void 0 : functionName.includes(".")) functionName = functionName.split(".").pop();
|
|
667
|
+
}
|
|
668
|
+
functionName = functionName === null || functionName === void 0 ? void 0 : functionName.replace(/^</, "").replace(/>$/, "").trim();
|
|
669
|
+
return getRelationName(functionName || "anonymous");
|
|
659
670
|
}
|
|
660
671
|
joiningTable(related, instance = null) {
|
|
661
672
|
return [instance ? instance.joiningTableSegment() : snakeCase(related.name), this.joiningTableSegment()].sort().join("_").toLocaleLowerCase();
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ interface IModel {
|
|
|
140
140
|
setAppends(appends: string[]): this;
|
|
141
141
|
append(key: string | string[]): this;
|
|
142
142
|
getRelation<T$1 extends Model$2>(relation: string): T$1 | ICollection<T$1> | null | undefined;
|
|
143
|
+
getRelation<T$1 extends Model$2, IsCollection extends boolean = false>(relation: string): IsCollection extends true ? ICollection<T$1> | undefined : T$1 | null | undefined;
|
|
143
144
|
setRelation<T$1 extends Model$2>(relation: string, value: T$1 | ICollection<T$1> | null): this;
|
|
144
145
|
unsetRelation(relation: string): this;
|
|
145
146
|
relationLoaded(relation: string): boolean;
|
|
@@ -2176,7 +2177,10 @@ declare const BaseModel: (new (...args: any[]) => any) & {
|
|
|
2176
2177
|
uniqueIds(): never[];
|
|
2177
2178
|
setUniqueIds(): void;
|
|
2178
2179
|
});
|
|
2179
|
-
getRelation:
|
|
2180
|
+
getRelation: {
|
|
2181
|
+
<T$1 extends Model$2>(relation: string): T$1 | ICollection<T$1> | null | undefined;
|
|
2182
|
+
<T$1 extends Model$2, IsCollection extends boolean = false>(relation: string): IsCollection extends true ? ICollection<T$1> | undefined : T$1 | null | undefined;
|
|
2183
|
+
};
|
|
2180
2184
|
setRelation: <T$1 extends Model$2>(relation: string, value: T$1 | ICollection<T$1> | null) => (new () => IModel) & IModel & {
|
|
2181
2185
|
[x: string]: any;
|
|
2182
2186
|
timestamps: boolean;
|
|
@@ -4900,10 +4904,15 @@ declare class Paginator<T$1 extends Model$1, K$1 extends IPaginatorParams = IPag
|
|
|
4900
4904
|
}
|
|
4901
4905
|
//#endregion
|
|
4902
4906
|
//#region src/browser/index.d.ts
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
+
interface IMake {
|
|
4908
|
+
<T$1 extends Model$1>(model: T$1, data: TGeneric): T$1;
|
|
4909
|
+
<T$1 extends Model$1>(model: T$1, data: Array<TGeneric>): Collection<T$1>;
|
|
4910
|
+
<T$1 extends Model$1>(model: T$1, data: TGeneric, options: {
|
|
4911
|
+
paginated?: IPaginatorParams;
|
|
4912
|
+
}): Paginator<T$1>;
|
|
4913
|
+
}
|
|
4914
|
+
declare const make: IMake;
|
|
4915
|
+
declare const makeCollection: <T$1 extends Model$1>(model: T$1, data: TGeneric) => Collection<Model$1>;
|
|
4907
4916
|
declare const isBrowser = true;
|
|
4908
4917
|
declare const _default: {
|
|
4909
4918
|
isBrowser: boolean;
|
|
@@ -4922,11 +4931,9 @@ declare const _default: {
|
|
|
4922
4931
|
getIncrementing(): any;
|
|
4923
4932
|
};
|
|
4924
4933
|
} & TBase;
|
|
4925
|
-
make:
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
makeCollection: (model: Model$1, data: TGeneric) => Collection<Model$1>;
|
|
4929
|
-
makePaginator: (model: Model$1, data: TGeneric) => Paginator<Model$1, IPaginatorParams>;
|
|
4934
|
+
make: IMake;
|
|
4935
|
+
makeCollection: <T$1 extends Model$1>(model: T$1, data: TGeneric) => Collection<Model$1>;
|
|
4936
|
+
makePaginator: <T$1 extends Model$1>(model: T$1, data: TGeneric) => Paginator<T$1, IPaginatorParams>;
|
|
4930
4937
|
};
|
|
4931
4938
|
//#endregion
|
|
4932
4939
|
export { Attribute, CastsAttributes, Collection, HasUniqueIds, InvalidArgumentError, Model$1 as Model, ModelNotFoundError, Paginator, Pivot, RelationNotFoundError, compose, _default as default, defineConfig, flatten, flattenDeep, getAttrMethod, getAttrName, getGetterMethod, getRelationMethod, getRelationName, getScopeMethod, getScopeName, getSetterMethod, isBrowser, kebabCase, make, makeCollection, now, snakeCase, tap };
|
package/dist/browser/index.js
CHANGED
|
@@ -630,9 +630,20 @@ const HasRelations = (Instance) => {
|
|
|
630
630
|
return data;
|
|
631
631
|
}
|
|
632
632
|
guessBelongsToRelation() {
|
|
633
|
-
|
|
634
|
-
const
|
|
635
|
-
|
|
633
|
+
const e = /* @__PURE__ */ new Error();
|
|
634
|
+
const stack = e.stack || e.stackTrace;
|
|
635
|
+
if (!stack) return getRelationName("unknown");
|
|
636
|
+
const frames = stack.split("\n");
|
|
637
|
+
const frame = frames[2] || frames[1] || frames[0];
|
|
638
|
+
let functionName = "anonymous";
|
|
639
|
+
if (frame.includes("@")) functionName = frame.split("@")[0].trim();
|
|
640
|
+
else if (frame.includes("at ")) {
|
|
641
|
+
const match = frame.match(/at\s+([^(]+)\s*\(/);
|
|
642
|
+
functionName = match ? match[1].trim() : "anonymous";
|
|
643
|
+
if (functionName === null || functionName === void 0 ? void 0 : functionName.includes(".")) functionName = functionName.split(".").pop();
|
|
644
|
+
}
|
|
645
|
+
functionName = functionName === null || functionName === void 0 ? void 0 : functionName.replace(/^</, "").replace(/>$/, "").trim();
|
|
646
|
+
return getRelationName(functionName || "anonymous");
|
|
636
647
|
}
|
|
637
648
|
joiningTable(related, instance = null) {
|
|
638
649
|
return [instance ? instance.joiningTableSegment() : snakeCase(related.name), this.joiningTableSegment()].sort().join("_").toLocaleLowerCase();
|
package/dist/concerns/index.cjs
CHANGED
|
@@ -173,8 +173,7 @@ var casts_attributes_default = CastsAttributes;
|
|
|
173
173
|
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/concerns/has-attributes.ts
|
|
176
|
-
|
|
177
|
-
const HasAttributes = (Model$1) => {
|
|
176
|
+
const HasAttributes$1 = (Model$1) => {
|
|
178
177
|
return class extends Model$1 {
|
|
179
178
|
static castTypeCache = {};
|
|
180
179
|
attributes = {};
|
|
@@ -416,7 +415,7 @@ const HasAttributes = (Model$1) => {
|
|
|
416
415
|
}
|
|
417
416
|
};
|
|
418
417
|
};
|
|
419
|
-
var has_attributes_default = HasAttributes;
|
|
418
|
+
var has_attributes_default = HasAttributes$1;
|
|
420
419
|
|
|
421
420
|
//#endregion
|
|
422
421
|
//#region src/errors.ts
|
|
@@ -466,8 +465,7 @@ var scope_default = Scope;
|
|
|
466
465
|
|
|
467
466
|
//#endregion
|
|
468
467
|
//#region src/concerns/has-global-scopes.ts
|
|
469
|
-
|
|
470
|
-
const HasGlobalScopes = (Model$1) => {
|
|
468
|
+
const HasGlobalScopes$1 = (Model$1) => {
|
|
471
469
|
return class extends Model$1 {
|
|
472
470
|
static globalScopes;
|
|
473
471
|
static addGlobalScope(scope, implementation = null) {
|
|
@@ -498,7 +496,7 @@ const HasGlobalScopes = (Model$1) => {
|
|
|
498
496
|
}
|
|
499
497
|
};
|
|
500
498
|
};
|
|
501
|
-
var has_global_scopes_default = HasGlobalScopes;
|
|
499
|
+
var has_global_scopes_default = HasGlobalScopes$1;
|
|
502
500
|
|
|
503
501
|
//#endregion
|
|
504
502
|
//#region src/hooks.ts
|
|
@@ -531,8 +529,7 @@ var hooks_default = Hooks;
|
|
|
531
529
|
|
|
532
530
|
//#endregion
|
|
533
531
|
//#region src/concerns/has-hooks.ts
|
|
534
|
-
|
|
535
|
-
const HasHooks = (Model$1) => {
|
|
532
|
+
const HasHooks$1 = (Model$1) => {
|
|
536
533
|
return class extends Model$1 {
|
|
537
534
|
static hooks = null;
|
|
538
535
|
static addHook(hook, callback) {
|
|
@@ -581,7 +578,7 @@ const HasHooks = (Model$1) => {
|
|
|
581
578
|
}
|
|
582
579
|
};
|
|
583
580
|
};
|
|
584
|
-
var has_hooks_default = HasHooks;
|
|
581
|
+
var has_hooks_default = HasHooks$1;
|
|
585
582
|
|
|
586
583
|
//#endregion
|
|
587
584
|
//#region src/collection.ts
|
|
@@ -2175,8 +2172,7 @@ var has_one_default = HasOne;
|
|
|
2175
2172
|
|
|
2176
2173
|
//#endregion
|
|
2177
2174
|
//#region src/concerns/has-timestamps.ts
|
|
2178
|
-
|
|
2179
|
-
const HasTimestamps = (Model$1) => {
|
|
2175
|
+
const HasTimestamps$1 = (Model$1) => {
|
|
2180
2176
|
return class extends Model$1 {
|
|
2181
2177
|
static CREATED_AT = "created_at";
|
|
2182
2178
|
static UPDATED_AT = "updated_at";
|
|
@@ -2218,12 +2214,11 @@ const HasTimestamps = (Model$1) => {
|
|
|
2218
2214
|
}
|
|
2219
2215
|
};
|
|
2220
2216
|
};
|
|
2221
|
-
var has_timestamps_default = HasTimestamps;
|
|
2217
|
+
var has_timestamps_default = HasTimestamps$1;
|
|
2222
2218
|
|
|
2223
2219
|
//#endregion
|
|
2224
2220
|
//#region src/concerns/hides-attributes.ts
|
|
2225
|
-
|
|
2226
|
-
const HidesAttributes = (Model$1) => {
|
|
2221
|
+
const HidesAttributes$1 = (Model$1) => {
|
|
2227
2222
|
return class extends Model$1 {
|
|
2228
2223
|
hidden = [];
|
|
2229
2224
|
visible = [];
|
|
@@ -2254,12 +2249,11 @@ const HidesAttributes = (Model$1) => {
|
|
|
2254
2249
|
}
|
|
2255
2250
|
};
|
|
2256
2251
|
};
|
|
2257
|
-
var hides_attributes_default = HidesAttributes;
|
|
2252
|
+
var hides_attributes_default = HidesAttributes$1;
|
|
2258
2253
|
|
|
2259
2254
|
//#endregion
|
|
2260
2255
|
//#region src/concerns/unique-ids.ts
|
|
2261
|
-
|
|
2262
|
-
const UniqueIds = (Model$1) => {
|
|
2256
|
+
const UniqueIds$1 = (Model$1) => {
|
|
2263
2257
|
return class extends Model$1 {
|
|
2264
2258
|
useUniqueIds = false;
|
|
2265
2259
|
usesUniqueIds() {
|
|
@@ -2274,7 +2268,7 @@ const UniqueIds = (Model$1) => {
|
|
|
2274
2268
|
}
|
|
2275
2269
|
};
|
|
2276
2270
|
};
|
|
2277
|
-
var unique_ids_default = UniqueIds;
|
|
2271
|
+
var unique_ids_default = UniqueIds$1;
|
|
2278
2272
|
|
|
2279
2273
|
//#endregion
|
|
2280
2274
|
//#region src/casts/attribute.ts
|
|
@@ -3373,8 +3367,7 @@ var has_one_through_default = HasOneThrough;
|
|
|
3373
3367
|
|
|
3374
3368
|
//#endregion
|
|
3375
3369
|
//#region src/concerns/has-relations.ts
|
|
3376
|
-
|
|
3377
|
-
const HasRelations = (Model$1) => {
|
|
3370
|
+
const HasRelations$1 = (Model$1) => {
|
|
3378
3371
|
return class extends Model$1 {
|
|
3379
3372
|
relations = {};
|
|
3380
3373
|
getRelation(relation) {
|
|
@@ -3466,12 +3459,11 @@ const HasRelations = (Model$1) => {
|
|
|
3466
3459
|
}
|
|
3467
3460
|
};
|
|
3468
3461
|
};
|
|
3469
|
-
var has_relations_default = HasRelations;
|
|
3462
|
+
var has_relations_default = HasRelations$1;
|
|
3470
3463
|
|
|
3471
3464
|
//#endregion
|
|
3472
3465
|
//#region src/concerns/has-unique-ids.ts
|
|
3473
|
-
|
|
3474
|
-
const HasUniqueIds = (Model$1) => {
|
|
3466
|
+
const HasUniqueIds$1 = (Model$1) => {
|
|
3475
3467
|
return class extends Model$1 {
|
|
3476
3468
|
useUniqueIds = true;
|
|
3477
3469
|
uniqueIds() {
|
|
@@ -3487,54 +3479,25 @@ const HasUniqueIds = (Model$1) => {
|
|
|
3487
3479
|
}
|
|
3488
3480
|
};
|
|
3489
3481
|
};
|
|
3490
|
-
var has_unique_ids_default = HasUniqueIds;
|
|
3482
|
+
var has_unique_ids_default = HasUniqueIds$1;
|
|
3491
3483
|
|
|
3492
3484
|
//#endregion
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
enumerable: true,
|
|
3513
|
-
get: function () {
|
|
3514
|
-
return has_relations_exports;
|
|
3515
|
-
}
|
|
3516
|
-
});
|
|
3517
|
-
Object.defineProperty(exports, 'HasTimestamps', {
|
|
3518
|
-
enumerable: true,
|
|
3519
|
-
get: function () {
|
|
3520
|
-
return has_timestamps_exports;
|
|
3521
|
-
}
|
|
3522
|
-
});
|
|
3523
|
-
Object.defineProperty(exports, 'HasUniqueIds', {
|
|
3524
|
-
enumerable: true,
|
|
3525
|
-
get: function () {
|
|
3526
|
-
return has_unique_ids_exports;
|
|
3527
|
-
}
|
|
3528
|
-
});
|
|
3529
|
-
Object.defineProperty(exports, 'HidesAttributes', {
|
|
3530
|
-
enumerable: true,
|
|
3531
|
-
get: function () {
|
|
3532
|
-
return hides_attributes_exports;
|
|
3533
|
-
}
|
|
3534
|
-
});
|
|
3535
|
-
Object.defineProperty(exports, 'UniqueIds', {
|
|
3536
|
-
enumerable: true,
|
|
3537
|
-
get: function () {
|
|
3538
|
-
return unique_ids_exports;
|
|
3539
|
-
}
|
|
3540
|
-
});
|
|
3485
|
+
//#region src/concerns/index.ts
|
|
3486
|
+
const HasAttributes = has_attributes_default;
|
|
3487
|
+
const HasGlobalScopes = has_global_scopes_default;
|
|
3488
|
+
const HasHooks = has_hooks_default;
|
|
3489
|
+
const HasRelations = has_relations_default;
|
|
3490
|
+
const HasTimestamps = has_timestamps_default;
|
|
3491
|
+
const HasUniqueIds = has_unique_ids_default;
|
|
3492
|
+
const HidesAttributes = hides_attributes_default;
|
|
3493
|
+
const UniqueIds = unique_ids_default;
|
|
3494
|
+
|
|
3495
|
+
//#endregion
|
|
3496
|
+
exports.HasAttributes = HasAttributes;
|
|
3497
|
+
exports.HasGlobalScopes = HasGlobalScopes;
|
|
3498
|
+
exports.HasHooks = HasHooks;
|
|
3499
|
+
exports.HasRelations = HasRelations;
|
|
3500
|
+
exports.HasTimestamps = HasTimestamps;
|
|
3501
|
+
exports.HasUniqueIds = HasUniqueIds;
|
|
3502
|
+
exports.HidesAttributes = HidesAttributes;
|
|
3503
|
+
exports.UniqueIds = UniqueIds;
|