@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/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import fs, { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
2
6
|
import { assign, camel, dash, diff, flat, get, isArray, isEmpty, isEqual, isNullish, isString, omit, pick, set, snake, trim } from "radashi";
|
|
3
7
|
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
4
8
|
import dayjs from "dayjs";
|
|
5
9
|
import collect$1, { Collection, collect } from "collect.js";
|
|
6
10
|
import Knex$1 from "knex";
|
|
7
|
-
import path from "path";
|
|
8
11
|
import { existsSync } from "fs";
|
|
9
12
|
import { FileSystem, Logger, TaskManager } from "@h3ravel/shared";
|
|
10
13
|
import pluralize from "pluralize";
|
|
11
|
-
import fs, { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
12
14
|
import resolveFrom from "resolve-from";
|
|
13
|
-
import { dirname } from "node:path";
|
|
14
|
-
import { fileURLToPath } from "node:url";
|
|
15
15
|
|
|
16
16
|
//#region rolldown:runtime
|
|
17
17
|
var __defProp = Object.defineProperty;
|
|
@@ -24,6 +24,111 @@ var __export = (all) => {
|
|
|
24
24
|
return target;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/seeders/seeder.ts
|
|
29
|
+
var Seeder = class {};
|
|
30
|
+
var seeder_default = Seeder;
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/seeders/runner.ts
|
|
34
|
+
async function glob$1(folderPath) {
|
|
35
|
+
const { default: escalade } = await import("escalade");
|
|
36
|
+
const entries = [];
|
|
37
|
+
await escalade(folderPath, async (dir, names) => {
|
|
38
|
+
await Promise.all(names.map(async (name) => {
|
|
39
|
+
const p = path.join(dir, name);
|
|
40
|
+
try {
|
|
41
|
+
await access(p);
|
|
42
|
+
if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
|
|
43
|
+
} catch {}
|
|
44
|
+
}));
|
|
45
|
+
return "";
|
|
46
|
+
});
|
|
47
|
+
return entries;
|
|
48
|
+
}
|
|
49
|
+
var SeederRunner = class {
|
|
50
|
+
resolver;
|
|
51
|
+
connection;
|
|
52
|
+
paths = [];
|
|
53
|
+
constructor(resolver) {
|
|
54
|
+
this.resolver = resolver;
|
|
55
|
+
}
|
|
56
|
+
path(p) {
|
|
57
|
+
this.paths = Array.from(new Set([...this.paths, p]));
|
|
58
|
+
}
|
|
59
|
+
getPaths() {
|
|
60
|
+
return this.paths;
|
|
61
|
+
}
|
|
62
|
+
resolveConnection(connection) {
|
|
63
|
+
var _getInstance, _ref, _instance$connections;
|
|
64
|
+
const name = connection || this.connection || "default";
|
|
65
|
+
const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
|
|
66
|
+
if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
|
|
67
|
+
/** noop */
|
|
68
|
+
});
|
|
69
|
+
return this.resolver.fire(name);
|
|
70
|
+
}
|
|
71
|
+
setConnection(connection) {
|
|
72
|
+
this.connection = connection;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
async getSeederFiles(paths) {
|
|
76
|
+
const files = [];
|
|
77
|
+
for (const p of paths) {
|
|
78
|
+
if (p.endsWith(".js") || p.endsWith(".ts")) {
|
|
79
|
+
files.push(p);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
files.push(...await glob$1(p));
|
|
83
|
+
}
|
|
84
|
+
return files;
|
|
85
|
+
}
|
|
86
|
+
async resolvePath(filePath) {
|
|
87
|
+
try {
|
|
88
|
+
const mod = await import(filePath);
|
|
89
|
+
return new (mod.default ?? mod.Seeder)();
|
|
90
|
+
} catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async run(paths, connection) {
|
|
95
|
+
const files = await this.getSeederFiles(paths);
|
|
96
|
+
const conn = this.resolveConnection(connection);
|
|
97
|
+
for (const file of files) {
|
|
98
|
+
const seeder = await this.resolvePath(file);
|
|
99
|
+
if (seeder && typeof seeder.run === "function") await seeder.run(conn);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var runner_default = SeederRunner;
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/seeders/seeder-creator.ts
|
|
107
|
+
var SeederCreator = class {
|
|
108
|
+
constructor(customStubPath) {
|
|
109
|
+
this.customStubPath = customStubPath;
|
|
110
|
+
}
|
|
111
|
+
async create(dir, name, type = "js") {
|
|
112
|
+
await mkdir(dir, { recursive: true });
|
|
113
|
+
let stub = await readFile(this.getStubPath(type), "utf-8");
|
|
114
|
+
stub = stub.replace(/{{ name }}/g, name);
|
|
115
|
+
const filePath = path.join(dir, `${name}.${type}`);
|
|
116
|
+
await writeFile(filePath, stub);
|
|
117
|
+
return filePath;
|
|
118
|
+
}
|
|
119
|
+
getStubPath(type) {
|
|
120
|
+
if (this.customStubPath) return path.join(this.customStubPath, `seeder-${type}.stub`);
|
|
121
|
+
const __dirname$1 = this.getDirname(import.meta);
|
|
122
|
+
return path.join(__dirname$1, "stubs", `seeder-${type}.stub`);
|
|
123
|
+
}
|
|
124
|
+
getDirname(meta) {
|
|
125
|
+
if (typeof __dirname !== "undefined") return __dirname;
|
|
126
|
+
if (meta && meta.url) return dirname(fileURLToPath(meta.url));
|
|
127
|
+
throw new Error("Unable to determine dirname");
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var seeder_creator_default = SeederCreator;
|
|
131
|
+
|
|
27
132
|
//#endregion
|
|
28
133
|
//#region src/casts/attribute.ts
|
|
29
134
|
var Attribute = class Attribute {
|
|
@@ -4948,7 +5053,7 @@ var SchemaInspector = class {
|
|
|
4948
5053
|
|
|
4949
5054
|
//#endregion
|
|
4950
5055
|
//#region src/migrations/migrator.ts
|
|
4951
|
-
async function glob
|
|
5056
|
+
async function glob(folderPath) {
|
|
4952
5057
|
const files = await fs.readdir(folderPath);
|
|
4953
5058
|
const allFiles = [];
|
|
4954
5059
|
for (const file of files) {
|
|
@@ -4956,7 +5061,7 @@ async function glob$1(folderPath) {
|
|
|
4956
5061
|
const stats = await fs.stat(filePath);
|
|
4957
5062
|
if (stats.isFile()) allFiles.push(filePath);
|
|
4958
5063
|
else if (stats.isDirectory()) {
|
|
4959
|
-
const subFiles = await glob
|
|
5064
|
+
const subFiles = await glob(filePath);
|
|
4960
5065
|
allFiles.push(...subFiles);
|
|
4961
5066
|
}
|
|
4962
5067
|
}
|
|
@@ -5099,7 +5204,7 @@ var Migrator = class {
|
|
|
5099
5204
|
files.push(p);
|
|
5100
5205
|
continue;
|
|
5101
5206
|
}
|
|
5102
|
-
files.push(...await glob
|
|
5207
|
+
files.push(...await glob(p));
|
|
5103
5208
|
}
|
|
5104
5209
|
return files.filter(Boolean).reduce((result, file) => {
|
|
5105
5210
|
result[this.getMigrationName(file)] = file;
|
|
@@ -5326,111 +5431,6 @@ var Migration = class extends Inference {
|
|
|
5326
5431
|
};
|
|
5327
5432
|
var migration_default = Migration;
|
|
5328
5433
|
|
|
5329
|
-
//#endregion
|
|
5330
|
-
//#region src/seeders/seeder.ts
|
|
5331
|
-
var Seeder = class {};
|
|
5332
|
-
var seeder_default = Seeder;
|
|
5333
|
-
|
|
5334
|
-
//#endregion
|
|
5335
|
-
//#region src/seeders/runner.ts
|
|
5336
|
-
async function glob(folderPath) {
|
|
5337
|
-
const { default: escalade } = await import("escalade");
|
|
5338
|
-
const entries = [];
|
|
5339
|
-
await escalade(folderPath, async (dir, names) => {
|
|
5340
|
-
await Promise.all(names.map(async (name) => {
|
|
5341
|
-
const p = path.join(dir, name);
|
|
5342
|
-
try {
|
|
5343
|
-
await access(p);
|
|
5344
|
-
if (p.endsWith(".js") || p.endsWith(".ts")) entries.push(p);
|
|
5345
|
-
} catch {}
|
|
5346
|
-
}));
|
|
5347
|
-
return "";
|
|
5348
|
-
});
|
|
5349
|
-
return entries;
|
|
5350
|
-
}
|
|
5351
|
-
var SeederRunner = class {
|
|
5352
|
-
resolver;
|
|
5353
|
-
connection;
|
|
5354
|
-
paths = [];
|
|
5355
|
-
constructor(resolver) {
|
|
5356
|
-
this.resolver = resolver;
|
|
5357
|
-
}
|
|
5358
|
-
path(p) {
|
|
5359
|
-
this.paths = Array.from(new Set([...this.paths, p]));
|
|
5360
|
-
}
|
|
5361
|
-
getPaths() {
|
|
5362
|
-
return this.paths;
|
|
5363
|
-
}
|
|
5364
|
-
resolveConnection(connection) {
|
|
5365
|
-
var _getInstance, _ref, _instance$connections;
|
|
5366
|
-
const name = connection || this.connection || "default";
|
|
5367
|
-
const instance = ((_getInstance = (_ref = this.resolver).getInstance) === null || _getInstance === void 0 ? void 0 : _getInstance.call(_ref)) ?? null;
|
|
5368
|
-
if (!!!(instance === null || instance === void 0 || (_instance$connections = instance.connections) === null || _instance$connections === void 0 ? void 0 : _instance$connections[name])) this.resolver.autoLoad().catch(() => {
|
|
5369
|
-
/** noop */
|
|
5370
|
-
});
|
|
5371
|
-
return this.resolver.fire(name);
|
|
5372
|
-
}
|
|
5373
|
-
setConnection(connection) {
|
|
5374
|
-
this.connection = connection;
|
|
5375
|
-
return this;
|
|
5376
|
-
}
|
|
5377
|
-
async getSeederFiles(paths) {
|
|
5378
|
-
const files = [];
|
|
5379
|
-
for (const p of paths) {
|
|
5380
|
-
if (p.endsWith(".js") || p.endsWith(".ts")) {
|
|
5381
|
-
files.push(p);
|
|
5382
|
-
continue;
|
|
5383
|
-
}
|
|
5384
|
-
files.push(...await glob(p));
|
|
5385
|
-
}
|
|
5386
|
-
return files;
|
|
5387
|
-
}
|
|
5388
|
-
async resolvePath(filePath) {
|
|
5389
|
-
try {
|
|
5390
|
-
const mod = await import(filePath);
|
|
5391
|
-
return new (mod.default ?? mod.Seeder)();
|
|
5392
|
-
} catch {
|
|
5393
|
-
return null;
|
|
5394
|
-
}
|
|
5395
|
-
}
|
|
5396
|
-
async run(paths, connection) {
|
|
5397
|
-
const files = await this.getSeederFiles(paths);
|
|
5398
|
-
const conn = this.resolveConnection(connection);
|
|
5399
|
-
for (const file of files) {
|
|
5400
|
-
const seeder = await this.resolvePath(file);
|
|
5401
|
-
if (seeder && typeof seeder.run === "function") await seeder.run(conn);
|
|
5402
|
-
}
|
|
5403
|
-
}
|
|
5404
|
-
};
|
|
5405
|
-
var runner_default = SeederRunner;
|
|
5406
|
-
|
|
5407
|
-
//#endregion
|
|
5408
|
-
//#region src/seeders/seeder-creator.ts
|
|
5409
|
-
var SeederCreator = class {
|
|
5410
|
-
constructor(customStubPath) {
|
|
5411
|
-
this.customStubPath = customStubPath;
|
|
5412
|
-
}
|
|
5413
|
-
async create(dir, name, type = "js") {
|
|
5414
|
-
await mkdir(dir, { recursive: true });
|
|
5415
|
-
let stub = await readFile(this.getStubPath(type), "utf-8");
|
|
5416
|
-
stub = stub.replace(/{{ name }}/g, name);
|
|
5417
|
-
const filePath = path.join(dir, `${name}.${type}`);
|
|
5418
|
-
await writeFile(filePath, stub);
|
|
5419
|
-
return filePath;
|
|
5420
|
-
}
|
|
5421
|
-
getStubPath(type) {
|
|
5422
|
-
if (this.customStubPath) return path.join(this.customStubPath, `seeder-${type}.stub`);
|
|
5423
|
-
const __dirname$1 = this.getDirname(import.meta);
|
|
5424
|
-
return path.join(__dirname$1, "stubs", `seeder-${type}.stub`);
|
|
5425
|
-
}
|
|
5426
|
-
getDirname(meta) {
|
|
5427
|
-
if (typeof __dirname !== "undefined") return __dirname;
|
|
5428
|
-
if (meta && meta.url) return dirname(fileURLToPath(meta.url));
|
|
5429
|
-
throw new Error("Unable to determine dirname");
|
|
5430
|
-
}
|
|
5431
|
-
};
|
|
5432
|
-
var seeder_creator_default = SeederCreator;
|
|
5433
|
-
|
|
5434
5434
|
//#endregion
|
|
5435
5435
|
//#region src/pivot.ts
|
|
5436
5436
|
var pivot_default = Pivot;
|
|
@@ -5602,11 +5602,11 @@ var soft_deletes_default = softDeletes;
|
|
|
5602
5602
|
const make = (model, data, options = {}) => {
|
|
5603
5603
|
const { paginated } = options;
|
|
5604
5604
|
if (paginated) return new paginator_default(data.data.map((item) => model.make(item)), data.total, data.per_page, data.current_page);
|
|
5605
|
-
if (
|
|
5605
|
+
if (isArray(data)) return new collection_default(data.map((item) => model.make(item)));
|
|
5606
5606
|
return model.make(data);
|
|
5607
5607
|
};
|
|
5608
5608
|
const makeCollection = (model, data) => new collection_default(data.map((item) => model.make(item)));
|
|
5609
|
-
const makePaginator = (model, data
|
|
5609
|
+
const makePaginator = (model, data) => new paginator_default(data.data.map((item) => model.make(item)), data.total, data.per_page, data.current_page);
|
|
5610
5610
|
|
|
5611
5611
|
//#endregion
|
|
5612
5612
|
export { attribute_default as Attribute, builder_default as Builder, casts_attributes_default as CastsAttributes, collection_default as Collection, has_unique_ids_default as HasUniqueIds, InvalidArgumentError, Migrate, migration_default as Migration, model_default as Model, ModelNotFoundError, paginator_default as Paginator, pivot_default as Pivot, query_builder_default as QueryBuilder, RelationNotFoundError, scope_default as Scope, seeder_default as Seeder, seeder_creator_default as SeederCreator, runner_default as SeederRunner, soft_deletes_default as SoftDeletes, arquebus_default as arquebus, compose, defineConfig, flatten, flattenDeep, getAttrMethod, getAttrName, getGetterMethod, getRelationMethod, getRelationName, getScopeMethod, getScopeName, getSetterMethod, kebabCase, make, makeCollection, makePaginator, now, snakeCase, tap };
|
package/dist/inspector/index.cjs
CHANGED
|
@@ -29,6 +29,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
}) : target, mod));
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
|
+
require("node:fs/promises");
|
|
33
|
+
let path = require("path");
|
|
34
|
+
path = __toESM(path);
|
|
35
|
+
require("node:path");
|
|
36
|
+
require("node:url");
|
|
32
37
|
let radashi = require("radashi");
|
|
33
38
|
let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
|
|
34
39
|
dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js);
|
|
@@ -38,16 +43,11 @@ let collect_js = require("collect.js");
|
|
|
38
43
|
collect_js = __toESM(collect_js);
|
|
39
44
|
let knex = require("knex");
|
|
40
45
|
knex = __toESM(knex);
|
|
41
|
-
let path = require("path");
|
|
42
|
-
path = __toESM(path);
|
|
43
46
|
let fs = require("fs");
|
|
44
47
|
let __h3ravel_shared = require("@h3ravel/shared");
|
|
45
48
|
let pluralize = require("pluralize");
|
|
46
49
|
pluralize = __toESM(pluralize);
|
|
47
|
-
require("node:fs/promises");
|
|
48
50
|
require("resolve-from");
|
|
49
|
-
require("node:path");
|
|
50
|
-
require("node:url");
|
|
51
51
|
|
|
52
52
|
//#region src/inspector/utils/strip-quotes.ts
|
|
53
53
|
/**
|
package/dist/inspector/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import "node:fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import "node:path";
|
|
5
|
+
import "node:url";
|
|
2
6
|
import { assign, camel, diff, flat, get, isArray, isEmpty, isEqual, isString, omit, pick, set, snake, trim } from "radashi";
|
|
3
7
|
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
4
8
|
import dayjs from "dayjs";
|
|
5
9
|
import collect$1, { Collection, collect } from "collect.js";
|
|
6
10
|
import Knex$1 from "knex";
|
|
7
|
-
import path from "path";
|
|
8
11
|
import { existsSync } from "fs";
|
|
9
12
|
import { FileSystem } from "@h3ravel/shared";
|
|
10
13
|
import pluralize from "pluralize";
|
|
11
|
-
import "node:fs/promises";
|
|
12
14
|
import "resolve-from";
|
|
13
|
-
import "node:path";
|
|
14
|
-
import "node:url";
|
|
15
15
|
|
|
16
16
|
//#region rolldown:runtime
|
|
17
17
|
var __defProp = Object.defineProperty;
|
|
@@ -30,6 +30,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
let __h3ravel_shared = require("@h3ravel/shared");
|
|
33
|
+
let node_fs_promises = require("node:fs/promises");
|
|
34
|
+
node_fs_promises = __toESM(node_fs_promises);
|
|
35
|
+
let path = require("path");
|
|
36
|
+
path = __toESM(path);
|
|
37
|
+
let node_path = require("node:path");
|
|
38
|
+
let node_url = require("node:url");
|
|
33
39
|
let radashi = require("radashi");
|
|
34
40
|
let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
|
|
35
41
|
dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js);
|
|
@@ -39,15 +45,9 @@ let collect_js = require("collect.js");
|
|
|
39
45
|
collect_js = __toESM(collect_js);
|
|
40
46
|
let knex = require("knex");
|
|
41
47
|
knex = __toESM(knex);
|
|
42
|
-
let path = require("path");
|
|
43
|
-
path = __toESM(path);
|
|
44
48
|
let fs = require("fs");
|
|
45
49
|
let pluralize = require("pluralize");
|
|
46
50
|
pluralize = __toESM(pluralize);
|
|
47
|
-
let node_fs_promises = require("node:fs/promises");
|
|
48
|
-
node_fs_promises = __toESM(node_fs_promises);
|
|
49
|
-
let node_path = require("node:path");
|
|
50
|
-
let node_url = require("node:url");
|
|
51
51
|
let resolve_from = require("resolve-from");
|
|
52
52
|
resolve_from = __toESM(resolve_from);
|
|
53
53
|
|
|
@@ -471,6 +471,7 @@ interface IModel {
|
|
|
471
471
|
setAppends(appends: string[]): this;
|
|
472
472
|
append(key: string | string[]): this;
|
|
473
473
|
getRelation<T$1 extends Model$1>(relation: string): T$1 | ICollection<T$1> | null | undefined;
|
|
474
|
+
getRelation<T$1 extends Model$1, IsCollection extends boolean = false>(relation: string): IsCollection extends true ? ICollection<T$1> | undefined : T$1 | null | undefined;
|
|
474
475
|
setRelation<T$1 extends Model$1>(relation: string, value: T$1 | ICollection<T$1> | null): this;
|
|
475
476
|
unsetRelation(relation: string): this;
|
|
476
477
|
relationLoaded(relation: string): boolean;
|
|
@@ -1394,7 +1395,10 @@ declare const BaseModel$1: (new (...args: any[]) => any) & {
|
|
|
1394
1395
|
uniqueIds(): never[];
|
|
1395
1396
|
setUniqueIds(): void;
|
|
1396
1397
|
});
|
|
1397
|
-
getRelation:
|
|
1398
|
+
getRelation: {
|
|
1399
|
+
<T$1 extends Model$1>(relation: string): T$1 | ICollection<T$1> | null | undefined;
|
|
1400
|
+
<T$1 extends Model$1, IsCollection extends boolean = false>(relation: string): IsCollection extends true ? ICollection<T$1> | undefined : T$1 | null | undefined;
|
|
1401
|
+
};
|
|
1398
1402
|
setRelation: <T$1 extends Model$1>(relation: string, value: T$1 | ICollection<T$1> | null) => (new () => IModel) & IModel & {
|
|
1399
1403
|
[x: string]: any;
|
|
1400
1404
|
timestamps: boolean;
|
package/dist/migrations/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { t as __export } from "./chunk-Bop6jNiL.js";
|
|
2
2
|
import { FileSystem, Logger, TaskManager } from "@h3ravel/shared";
|
|
3
|
+
import fs, { copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import path$1, { dirname } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
3
7
|
import { assign, camel, diff, flat, get, isArray, isEmpty, isEqual, isString, omit, pick, set, snake, trim } from "radashi";
|
|
4
8
|
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
5
9
|
import dayjs from "dayjs";
|
|
6
10
|
import collect, { Collection, collect as collect$1 } from "collect.js";
|
|
7
11
|
import Knex$1 from "knex";
|
|
8
|
-
import path from "path";
|
|
9
12
|
import { existsSync } from "fs";
|
|
10
13
|
import pluralize from "pluralize";
|
|
11
|
-
import fs, { copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
12
|
-
import path$1, { dirname } from "node:path";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
14
14
|
import resolveFrom from "resolve-from";
|
|
15
15
|
|
|
16
16
|
//#region src/migrations/migration-repository.ts
|
|
@@ -1320,6 +1320,12 @@ function extractType(type) {
|
|
|
1320
1320
|
return type.replace(/[^a-zA-Z]/g, "").toLowerCase();
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
|
+
//#endregion
|
|
1324
|
+
//#region node_modules/.pnpm/tsdown@0.16.0_typescript@5.9.3/node_modules/tsdown/esm-shims.js
|
|
1325
|
+
const getFilename = () => fileURLToPath(import.meta.url);
|
|
1326
|
+
const getDirname = () => path$1.dirname(getFilename());
|
|
1327
|
+
const __dirname = /* @__PURE__ */ getDirname();
|
|
1328
|
+
|
|
1323
1329
|
//#endregion
|
|
1324
1330
|
//#region src/casts/attribute.ts
|
|
1325
1331
|
var Attribute = class Attribute {
|
|
@@ -4754,12 +4760,6 @@ var Migration = class extends Inference {
|
|
|
4754
4760
|
};
|
|
4755
4761
|
var migration_default = Migration;
|
|
4756
4762
|
|
|
4757
|
-
//#endregion
|
|
4758
|
-
//#region node_modules/.pnpm/tsdown@0.16.0_typescript@5.9.3/node_modules/tsdown/esm-shims.js
|
|
4759
|
-
const getFilename = () => fileURLToPath(import.meta.url);
|
|
4760
|
-
const getDirname = () => path$1.dirname(getFilename());
|
|
4761
|
-
const __dirname = /* @__PURE__ */ getDirname();
|
|
4762
|
-
|
|
4763
4763
|
//#endregion
|
|
4764
4764
|
//#region src/inspector/dialects/sqlite.ts
|
|
4765
4765
|
function parseDefaultValue(value) {
|
package/dist/relations/index.cjs
CHANGED
|
@@ -320,9 +320,8 @@ var collection_default = Collection;
|
|
|
320
320
|
|
|
321
321
|
//#endregion
|
|
322
322
|
//#region src/relations/concerns/interacts-with-pivot-table.ts
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return class extends Relation$1 {
|
|
323
|
+
const InteractsWithPivotTable$1 = (Relation$2) => {
|
|
324
|
+
return class extends Relation$2 {
|
|
326
325
|
newExistingPivot(attributes = []) {
|
|
327
326
|
return this.newPivot(attributes, true);
|
|
328
327
|
}
|
|
@@ -509,7 +508,7 @@ const InteractsWithPivotTable = (Relation$1) => {
|
|
|
509
508
|
}
|
|
510
509
|
};
|
|
511
510
|
};
|
|
512
|
-
var interacts_with_pivot_table_default = InteractsWithPivotTable;
|
|
511
|
+
var interacts_with_pivot_table_default = InteractsWithPivotTable$1;
|
|
513
512
|
|
|
514
513
|
//#endregion
|
|
515
514
|
//#region src/errors.ts
|
|
@@ -547,8 +546,7 @@ var InvalidArgumentError = class extends BaseError {};
|
|
|
547
546
|
|
|
548
547
|
//#endregion
|
|
549
548
|
//#region src/relations/relation.ts
|
|
550
|
-
var
|
|
551
|
-
var Relation = class {
|
|
549
|
+
var Relation$1 = class {
|
|
552
550
|
query;
|
|
553
551
|
parent;
|
|
554
552
|
related;
|
|
@@ -636,12 +634,11 @@ var Relation = class {
|
|
|
636
634
|
return (_this$getQualifiedFor = this.getQualifiedForeignKeyName) === null || _this$getQualifiedFor === void 0 ? void 0 : _this$getQualifiedFor.call(this);
|
|
637
635
|
}
|
|
638
636
|
};
|
|
639
|
-
var relation_default = Relation;
|
|
637
|
+
var relation_default = Relation$1;
|
|
640
638
|
|
|
641
639
|
//#endregion
|
|
642
640
|
//#region src/relations/belongs-to-many.ts
|
|
643
|
-
var
|
|
644
|
-
var BelongsToMany = class extends compose(relation_default, interacts_with_pivot_table_default) {
|
|
641
|
+
var BelongsToMany$1 = class extends compose(relation_default, interacts_with_pivot_table_default) {
|
|
645
642
|
table;
|
|
646
643
|
foreignPivotKey;
|
|
647
644
|
relatedPivotKey;
|
|
@@ -862,7 +859,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
862
859
|
return super.getRelationExistenceQuery(query, parentQuery, columns);
|
|
863
860
|
}
|
|
864
861
|
};
|
|
865
|
-
var belongs_to_many_default = BelongsToMany;
|
|
862
|
+
var belongs_to_many_default = BelongsToMany$1;
|
|
866
863
|
|
|
867
864
|
//#endregion
|
|
868
865
|
//#region src/paginator.ts
|
|
@@ -2005,9 +2002,8 @@ var has_hooks_default = HasHooks;
|
|
|
2005
2002
|
|
|
2006
2003
|
//#endregion
|
|
2007
2004
|
//#region src/relations/has-one-or-many.ts
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
return class extends Relation$1 {
|
|
2005
|
+
const HasOneOrMany$1 = (Relation$2) => {
|
|
2006
|
+
return class extends Relation$2 {
|
|
2011
2007
|
getRelationValue(dictionary, key, type) {
|
|
2012
2008
|
const value = dictionary[key];
|
|
2013
2009
|
return type === "one" ? value[0] : new collection_default(value);
|
|
@@ -2071,12 +2067,11 @@ const HasOneOrMany = (Relation$1) => {
|
|
|
2071
2067
|
}
|
|
2072
2068
|
};
|
|
2073
2069
|
};
|
|
2074
|
-
var has_one_or_many_default = HasOneOrMany;
|
|
2070
|
+
var has_one_or_many_default = HasOneOrMany$1;
|
|
2075
2071
|
|
|
2076
2072
|
//#endregion
|
|
2077
2073
|
//#region src/relations/has-many.ts
|
|
2078
|
-
var
|
|
2079
|
-
var HasMany = class extends compose(relation_default, has_one_or_many_default) {
|
|
2074
|
+
var HasMany$1 = class extends compose(relation_default, has_one_or_many_default) {
|
|
2080
2075
|
foreignKey;
|
|
2081
2076
|
localKey;
|
|
2082
2077
|
constructor(query, parent, foreignKey, localKey) {
|
|
@@ -2111,13 +2106,12 @@ var HasMany = class extends compose(relation_default, has_one_or_many_default) {
|
|
|
2111
2106
|
this.query.whereIn(this.foreignKey, this.getKeys(models, this.localKey));
|
|
2112
2107
|
}
|
|
2113
2108
|
};
|
|
2114
|
-
var has_many_default = HasMany;
|
|
2109
|
+
var has_many_default = HasMany$1;
|
|
2115
2110
|
|
|
2116
2111
|
//#endregion
|
|
2117
2112
|
//#region src/relations/concerns/supports-default-models.ts
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
return class extends Relation$1 {
|
|
2113
|
+
const SupportsDefaultModels$1 = (Relation$2) => {
|
|
2114
|
+
return class extends Relation$2 {
|
|
2121
2115
|
_withDefault;
|
|
2122
2116
|
withDefault(callback = true) {
|
|
2123
2117
|
this._withDefault = callback;
|
|
@@ -2132,12 +2126,11 @@ const SupportsDefaultModels = (Relation$1) => {
|
|
|
2132
2126
|
}
|
|
2133
2127
|
};
|
|
2134
2128
|
};
|
|
2135
|
-
var supports_default_models_default = SupportsDefaultModels;
|
|
2129
|
+
var supports_default_models_default = SupportsDefaultModels$1;
|
|
2136
2130
|
|
|
2137
2131
|
//#endregion
|
|
2138
2132
|
//#region src/relations/has-one.ts
|
|
2139
|
-
var
|
|
2140
|
-
var HasOne = class extends compose(relation_default, has_one_or_many_default, supports_default_models_default) {
|
|
2133
|
+
var HasOne$1 = class extends compose(relation_default, has_one_or_many_default, supports_default_models_default) {
|
|
2141
2134
|
foreignKey;
|
|
2142
2135
|
localKey;
|
|
2143
2136
|
constructor(query, parent, foreignKey, localKey) {
|
|
@@ -2175,12 +2168,11 @@ var HasOne = class extends compose(relation_default, has_one_or_many_default, su
|
|
|
2175
2168
|
return this.related.newInstance().setAttribute(this.getForeignKeyName(), parent[this.localKey]);
|
|
2176
2169
|
}
|
|
2177
2170
|
};
|
|
2178
|
-
var has_one_default = HasOne;
|
|
2171
|
+
var has_one_default = HasOne$1;
|
|
2179
2172
|
|
|
2180
2173
|
//#endregion
|
|
2181
2174
|
//#region src/relations/has-many-through.ts
|
|
2182
|
-
var
|
|
2183
|
-
var HasManyThrough = class extends relation_default {
|
|
2175
|
+
var HasManyThrough$1 = class extends relation_default {
|
|
2184
2176
|
throughParent;
|
|
2185
2177
|
farParent;
|
|
2186
2178
|
firstKey;
|
|
@@ -2358,12 +2350,11 @@ var HasManyThrough = class extends relation_default {
|
|
|
2358
2350
|
return this.secondLocalKey;
|
|
2359
2351
|
}
|
|
2360
2352
|
};
|
|
2361
|
-
var has_many_through_default = HasManyThrough;
|
|
2353
|
+
var has_many_through_default = HasManyThrough$1;
|
|
2362
2354
|
|
|
2363
2355
|
//#endregion
|
|
2364
2356
|
//#region src/relations/has-one-through.ts
|
|
2365
|
-
var
|
|
2366
|
-
var HasOneThrough = class extends compose(has_many_through_default, supports_default_models_default) {
|
|
2357
|
+
var HasOneThrough$1 = class extends compose(has_many_through_default, supports_default_models_default) {
|
|
2367
2358
|
async getResults() {
|
|
2368
2359
|
return await this.first() || this.getDefaultFor(this.farParent);
|
|
2369
2360
|
}
|
|
@@ -2386,7 +2377,7 @@ var HasOneThrough = class extends compose(has_many_through_default, supports_def
|
|
|
2386
2377
|
return this.related.newInstance();
|
|
2387
2378
|
}
|
|
2388
2379
|
};
|
|
2389
|
-
var has_one_through_default = HasOneThrough;
|
|
2380
|
+
var has_one_through_default = HasOneThrough$1;
|
|
2390
2381
|
|
|
2391
2382
|
//#endregion
|
|
2392
2383
|
//#region src/concerns/has-relations.ts
|
|
@@ -3383,8 +3374,7 @@ var model_default = Model;
|
|
|
3383
3374
|
|
|
3384
3375
|
//#endregion
|
|
3385
3376
|
//#region src/relations/belongs-to.ts
|
|
3386
|
-
var
|
|
3387
|
-
var BelongsTo = class extends compose(relation_default, supports_default_models_default) {
|
|
3377
|
+
var BelongsTo$1 = class extends compose(relation_default, supports_default_models_default) {
|
|
3388
3378
|
foreignKey;
|
|
3389
3379
|
ownerKey;
|
|
3390
3380
|
child;
|
|
@@ -3469,66 +3459,29 @@ var BelongsTo = class extends compose(relation_default, supports_default_models_
|
|
|
3469
3459
|
return this.related.newInstance();
|
|
3470
3460
|
}
|
|
3471
3461
|
};
|
|
3472
|
-
var belongs_to_default = BelongsTo;
|
|
3462
|
+
var belongs_to_default = BelongsTo$1;
|
|
3473
3463
|
|
|
3474
3464
|
//#endregion
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
});
|
|
3499
|
-
Object.defineProperty(exports, 'HasOne', {
|
|
3500
|
-
enumerable: true,
|
|
3501
|
-
get: function () {
|
|
3502
|
-
return has_one_exports;
|
|
3503
|
-
}
|
|
3504
|
-
});
|
|
3505
|
-
Object.defineProperty(exports, 'HasOneOrMany', {
|
|
3506
|
-
enumerable: true,
|
|
3507
|
-
get: function () {
|
|
3508
|
-
return has_one_or_many_exports;
|
|
3509
|
-
}
|
|
3510
|
-
});
|
|
3511
|
-
Object.defineProperty(exports, 'HasOneThrough', {
|
|
3512
|
-
enumerable: true,
|
|
3513
|
-
get: function () {
|
|
3514
|
-
return has_one_through_exports;
|
|
3515
|
-
}
|
|
3516
|
-
});
|
|
3517
|
-
Object.defineProperty(exports, 'InteractsWithPivotTable', {
|
|
3518
|
-
enumerable: true,
|
|
3519
|
-
get: function () {
|
|
3520
|
-
return interacts_with_pivot_table_exports;
|
|
3521
|
-
}
|
|
3522
|
-
});
|
|
3523
|
-
Object.defineProperty(exports, 'Relation', {
|
|
3524
|
-
enumerable: true,
|
|
3525
|
-
get: function () {
|
|
3526
|
-
return relation_exports;
|
|
3527
|
-
}
|
|
3528
|
-
});
|
|
3529
|
-
Object.defineProperty(exports, 'SupportsDefaultModels', {
|
|
3530
|
-
enumerable: true,
|
|
3531
|
-
get: function () {
|
|
3532
|
-
return supports_default_models_exports;
|
|
3533
|
-
}
|
|
3534
|
-
});
|
|
3465
|
+
//#region src/relations/index.ts
|
|
3466
|
+
const BelongsTo = belongs_to_default;
|
|
3467
|
+
const BelongsToMany = belongs_to_many_default;
|
|
3468
|
+
const InteractsWithPivotTable = interacts_with_pivot_table_default;
|
|
3469
|
+
const SupportsDefaultModels = supports_default_models_default;
|
|
3470
|
+
const HasMany = has_many_default;
|
|
3471
|
+
const HasManyThrough = has_many_through_default;
|
|
3472
|
+
const HasOne = has_one_default;
|
|
3473
|
+
const HasOneOrMany = has_one_or_many_default;
|
|
3474
|
+
const HasOneThrough = has_one_through_default;
|
|
3475
|
+
const Relation = relation_default;
|
|
3476
|
+
|
|
3477
|
+
//#endregion
|
|
3478
|
+
exports.BelongsTo = BelongsTo;
|
|
3479
|
+
exports.BelongsToMany = BelongsToMany;
|
|
3480
|
+
exports.HasMany = HasMany;
|
|
3481
|
+
exports.HasManyThrough = HasManyThrough;
|
|
3482
|
+
exports.HasOne = HasOne;
|
|
3483
|
+
exports.HasOneOrMany = HasOneOrMany;
|
|
3484
|
+
exports.HasOneThrough = HasOneThrough;
|
|
3485
|
+
exports.InteractsWithPivotTable = InteractsWithPivotTable;
|
|
3486
|
+
exports.Relation = Relation;
|
|
3487
|
+
exports.SupportsDefaultModels = SupportsDefaultModels;
|