@h3ravel/arquebus 0.4.1 → 0.5.0
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 +30 -28
- package/bin/index.js +32 -29
- package/dist/browser/index.d.cts +3648 -176
- package/dist/browser/index.d.ts +3648 -176
- package/dist/index.cjs +18 -14
- package/dist/index.d.cts +3757 -286
- package/dist/index.d.ts +3757 -286
- package/dist/index.js +18 -14
- package/dist/inspector/index.cjs +17 -13
- package/dist/inspector/index.js +17 -13
- package/dist/migrations/index.cjs +27 -25
- package/dist/migrations/index.d.cts +3500 -17
- package/dist/migrations/index.d.ts +3500 -17
- package/dist/migrations/index.js +40 -31
- package/package.json +3 -3
- package/types/builder.ts +21 -16
- package/types/generics.ts +1 -0
- package/types/modeling.ts +7 -7
- package/types/query-builder.ts +9 -2
- package/types/query-methods.ts +20 -0
- package/types/utils.ts +1 -0
package/bin/index.cjs
CHANGED
|
@@ -58,8 +58,6 @@ let fs = require("fs");
|
|
|
58
58
|
fs = __toESM(fs);
|
|
59
59
|
let pluralize = require("pluralize");
|
|
60
60
|
pluralize = __toESM(pluralize);
|
|
61
|
-
let node_fs = require("node:fs");
|
|
62
|
-
node_fs = __toESM(node_fs);
|
|
63
61
|
let node_path = require("node:path");
|
|
64
62
|
node_path = __toESM(node_path);
|
|
65
63
|
let node_url = require("node:url");
|
|
@@ -2459,8 +2457,8 @@ var HasManyThrough = class extends relation_default {
|
|
|
2459
2457
|
const results = await this.take(1).get(columns);
|
|
2460
2458
|
return results.count() > 0 ? results.first() : null;
|
|
2461
2459
|
}
|
|
2462
|
-
async firstOrFail(columns
|
|
2463
|
-
const model = await this.first(columns);
|
|
2460
|
+
async firstOrFail(...columns) {
|
|
2461
|
+
const model = await this.first(...columns);
|
|
2464
2462
|
if (model) return model;
|
|
2465
2463
|
throw new ModelNotFoundError().setModel(this.related.constructor);
|
|
2466
2464
|
}
|
|
@@ -2499,7 +2497,7 @@ var HasManyThrough = class extends relation_default {
|
|
|
2499
2497
|
}
|
|
2500
2498
|
async paginate(perPage = null, columns = ["*"], pageName = "page", page = null) {
|
|
2501
2499
|
this.query.addSelect(this.shouldSelect(columns));
|
|
2502
|
-
return await this.query.paginate(perPage, columns, pageName, page);
|
|
2500
|
+
return await this.query.paginate(perPage ?? 15, columns, pageName, page);
|
|
2503
2501
|
}
|
|
2504
2502
|
shouldSelect(columns = ["*"]) {
|
|
2505
2503
|
if ((columns === null || columns === void 0 ? void 0 : columns.at(0)) == "*") columns = [this.related.getTable() + ".*"];
|
|
@@ -2777,9 +2775,6 @@ const UniqueIds = (Model$1) => {
|
|
|
2777
2775
|
uniqueIds() {
|
|
2778
2776
|
return [];
|
|
2779
2777
|
}
|
|
2780
|
-
newUniqueId() {
|
|
2781
|
-
return null;
|
|
2782
|
-
}
|
|
2783
2778
|
setUniqueIds() {
|
|
2784
2779
|
const uniqueIds = this.uniqueIds();
|
|
2785
2780
|
for (const column of uniqueIds) if (this[column] === null || this[column] === void 0) this[column] = this.newUniqueId();
|
|
@@ -2801,6 +2796,7 @@ var Paginator = class {
|
|
|
2801
2796
|
options = {};
|
|
2802
2797
|
static setFormatter(formatter) {
|
|
2803
2798
|
if (typeof formatter !== "function" && formatter !== null && formatter !== void 0) throw new Error("Paginator formatter must be a function or null");
|
|
2799
|
+
if (!formatter) return;
|
|
2804
2800
|
this.formatter = formatter;
|
|
2805
2801
|
}
|
|
2806
2802
|
constructor(items, total, perPage, currentPage = 1, options = {}) {
|
|
@@ -2889,8 +2885,10 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
|
|
|
2889
2885
|
asProxy() {
|
|
2890
2886
|
return new Proxy(this, {
|
|
2891
2887
|
get: function(target, prop) {
|
|
2888
|
+
var _target$connector$cli;
|
|
2892
2889
|
if (typeof target[prop] !== "undefined") return target[prop];
|
|
2893
2890
|
if (["destroy", "schema"].includes(prop)) return target.connector.schema;
|
|
2891
|
+
const skipReturning = !!((_target$connector$cli = target.connector.client.config) === null || _target$connector$cli === void 0 || (_target$connector$cli = _target$connector$cli.client) === null || _target$connector$cli === void 0 ? void 0 : _target$connector$cli.includes("mysql")) && prop === "returning";
|
|
2894
2892
|
if ([
|
|
2895
2893
|
"select",
|
|
2896
2894
|
"from",
|
|
@@ -2953,7 +2951,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
|
|
|
2953
2951
|
"clearWhere",
|
|
2954
2952
|
"clearHaving",
|
|
2955
2953
|
"clearGroup"
|
|
2956
|
-
].includes(prop)) return (...args) => {
|
|
2954
|
+
].includes(prop) && !skipReturning) return (...args) => {
|
|
2957
2955
|
target.connector[prop](...args);
|
|
2958
2956
|
return target.asProxy();
|
|
2959
2957
|
};
|
|
@@ -3010,7 +3008,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
|
|
|
3010
3008
|
} while (countResults === count);
|
|
3011
3009
|
return true;
|
|
3012
3010
|
}
|
|
3013
|
-
async paginate(page = 1, perPage = 15) {
|
|
3011
|
+
async paginate(page = 1, perPage = 15, _pageName, _page) {
|
|
3014
3012
|
const total = await this.clone().clearOrder().count("*");
|
|
3015
3013
|
let results;
|
|
3016
3014
|
if (total > 0) {
|
|
@@ -3249,14 +3247,15 @@ var arquebus_default = arquebus;
|
|
|
3249
3247
|
|
|
3250
3248
|
//#endregion
|
|
3251
3249
|
//#region src/model.ts
|
|
3252
|
-
const
|
|
3250
|
+
const ModelClass = class {};
|
|
3251
|
+
const BaseModel = compose(ModelClass, has_attributes_default, hides_attributes_default, has_relations_default, has_timestamps_default, has_hooks_default, has_global_scopes_default, unique_ids_default);
|
|
3253
3252
|
var Model = class Model extends BaseModel {
|
|
3254
|
-
primaryKey = "id";
|
|
3255
3253
|
builder = null;
|
|
3256
3254
|
table = null;
|
|
3257
3255
|
keyType = "int";
|
|
3258
3256
|
incrementing = true;
|
|
3259
3257
|
withCount = [];
|
|
3258
|
+
primaryKey = "id";
|
|
3260
3259
|
perPage = 15;
|
|
3261
3260
|
static globalScopes = {};
|
|
3262
3261
|
static pluginInitializers = {};
|
|
@@ -3266,6 +3265,7 @@ var Model = class Model extends BaseModel {
|
|
|
3266
3265
|
eagerLoad = {};
|
|
3267
3266
|
exists = false;
|
|
3268
3267
|
with = [];
|
|
3268
|
+
name;
|
|
3269
3269
|
trx = null;
|
|
3270
3270
|
constructor(attributes = {}) {
|
|
3271
3271
|
super();
|
|
@@ -4037,8 +4037,8 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
4037
4037
|
const results = await this.take(1).get(columns);
|
|
4038
4038
|
return results.count() > 0 ? results.first() : null;
|
|
4039
4039
|
}
|
|
4040
|
-
async firstOrFail(columns
|
|
4041
|
-
const model = await this.first(columns);
|
|
4040
|
+
async firstOrFail(...columns) {
|
|
4041
|
+
const model = await this.first(...columns);
|
|
4042
4042
|
if (model !== null) return model;
|
|
4043
4043
|
throw new ModelNotFoundError().setModel(this.related.constructor);
|
|
4044
4044
|
}
|
|
@@ -4214,7 +4214,9 @@ var Builder = class Builder extends Inference {
|
|
|
4214
4214
|
}
|
|
4215
4215
|
asProxy() {
|
|
4216
4216
|
return new Proxy(this, { get(target, prop) {
|
|
4217
|
+
var _target$query$connect;
|
|
4217
4218
|
if (typeof target[prop] !== "undefined") return target[prop];
|
|
4219
|
+
const skipReturning = !!((_target$query$connect = target.query.connector) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client.config) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client) === null || _target$query$connect === void 0 ? void 0 : _target$query$connect.includes("mysql")) && prop === "returning";
|
|
4218
4220
|
if ([
|
|
4219
4221
|
"select",
|
|
4220
4222
|
"from",
|
|
@@ -4277,7 +4279,7 @@ var Builder = class Builder extends Inference {
|
|
|
4277
4279
|
"clearWhere",
|
|
4278
4280
|
"clearHaving",
|
|
4279
4281
|
"clearGroup"
|
|
4280
|
-
].includes(prop)) return (...args) => {
|
|
4282
|
+
].includes(prop) && !skipReturning) return (...args) => {
|
|
4281
4283
|
target.query[prop](...args);
|
|
4282
4284
|
return target.asProxy();
|
|
4283
4285
|
};
|
|
@@ -5402,10 +5404,10 @@ var MigrationCreator = class {
|
|
|
5402
5404
|
* @returns
|
|
5403
5405
|
*/
|
|
5404
5406
|
async create(name$1, dir, table, create = false) {
|
|
5405
|
-
const stub = this.getStub(table, create);
|
|
5407
|
+
const stub = await this.getStub(table, create);
|
|
5406
5408
|
const filePath = this.getPath(name$1, dir);
|
|
5407
5409
|
await this.ensureDirectoryExists(path.default.dirname(filePath));
|
|
5408
|
-
await node_fs_promises.
|
|
5410
|
+
await (0, node_fs_promises.writeFile)(filePath, this.populateStub(stub, table));
|
|
5409
5411
|
await this.firePostCreateHooks(table, filePath);
|
|
5410
5412
|
return filePath;
|
|
5411
5413
|
}
|
|
@@ -5416,29 +5418,29 @@ var MigrationCreator = class {
|
|
|
5416
5418
|
* @param callback
|
|
5417
5419
|
*/
|
|
5418
5420
|
async publish(dir, callback) {
|
|
5419
|
-
const migrationFiles = await node_fs_promises.
|
|
5421
|
+
const migrationFiles = await (0, node_fs_promises.readdir)(this.customStubPath ?? "");
|
|
5420
5422
|
await this.ensureDirectoryExists(dir);
|
|
5421
5423
|
for (const migrationFile of migrationFiles) {
|
|
5422
5424
|
const sourceFilePath = path.default.join(this.customStubPath ?? "", migrationFile);
|
|
5423
5425
|
const destinationFilePath = path.default.join(dir, migrationFile);
|
|
5424
|
-
await node_fs_promises.
|
|
5426
|
+
await (0, node_fs_promises.copyFile)(sourceFilePath, destinationFilePath);
|
|
5425
5427
|
if (callback) callback(migrationFile, sourceFilePath, destinationFilePath);
|
|
5426
5428
|
}
|
|
5427
5429
|
}
|
|
5428
|
-
getStub(table, create = false) {
|
|
5430
|
+
async getStub(table, create = false) {
|
|
5429
5431
|
let stub;
|
|
5430
5432
|
if (!table) {
|
|
5431
5433
|
const customPath = path.default.join(this.customStubPath ?? "", `migration-${this.type}.stub`);
|
|
5432
5434
|
console.log("\n", customPath, "---");
|
|
5433
|
-
stub =
|
|
5435
|
+
stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration-${this.type}.stub`);
|
|
5434
5436
|
} else if (create) {
|
|
5435
5437
|
const customPath = path.default.join(this.customStubPath ?? "", `migration.create-${this.type}.stub`);
|
|
5436
|
-
stub =
|
|
5438
|
+
stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.create-${this.type}.stub`);
|
|
5437
5439
|
} else {
|
|
5438
5440
|
const customPath = path.default.join(this.customStubPath ?? "", `migration.update-${this.type}.stub`);
|
|
5439
|
-
stub =
|
|
5441
|
+
stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.update-${this.type}.stub`);
|
|
5440
5442
|
}
|
|
5441
|
-
return (0,
|
|
5443
|
+
return await (0, node_fs_promises.readFile)(stub, "utf-8");
|
|
5442
5444
|
}
|
|
5443
5445
|
populateStub(stub, table) {
|
|
5444
5446
|
if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
|
|
@@ -5458,7 +5460,7 @@ var MigrationCreator = class {
|
|
|
5458
5460
|
this.postCreate.push(callback);
|
|
5459
5461
|
}
|
|
5460
5462
|
async ensureDirectoryExists(dir) {
|
|
5461
|
-
await node_fs_promises.
|
|
5463
|
+
await (0, node_fs_promises.mkdir)(dir, { recursive: true });
|
|
5462
5464
|
}
|
|
5463
5465
|
stubPath(stub = "") {
|
|
5464
5466
|
const __dirname$1 = this.getDirname({});
|
|
@@ -5474,7 +5476,7 @@ var MigrationCreator = class {
|
|
|
5474
5476
|
//#endregion
|
|
5475
5477
|
//#region package.json
|
|
5476
5478
|
var name = "@h3ravel/arquebus";
|
|
5477
|
-
var version = "0.
|
|
5479
|
+
var version = "0.5.0";
|
|
5478
5480
|
var packageManager = "pnpm@10.14.0";
|
|
5479
5481
|
var description = "Arquebus ORM is a Beautiful, expressive ORM inspired by Laravel's Eloquent, designed for TypeScript applications and for the H3ravel Framework.";
|
|
5480
5482
|
var homepage = "https://h3ravel.toneflix.net/arquebus";
|
|
@@ -5592,12 +5594,12 @@ var scripts = {
|
|
|
5592
5594
|
"test:postgres": "cross-env DB=postgres vitest --project node",
|
|
5593
5595
|
"test:sqlite": "cross-env DB=sqlite vitest --project node",
|
|
5594
5596
|
"test:browser": "vitest --project browser",
|
|
5595
|
-
"release:patch": "pnpm build && git add . && git commit -m \"version: bump version
|
|
5597
|
+
"release:patch": "pnpm build && git add . && git commit -m \"version: bump version\" && pnpm version patch && pnpm publish --tag latest"
|
|
5596
5598
|
};
|
|
5597
5599
|
var husky = { "hooks": { "pre-commit": "lint-staged" } };
|
|
5598
5600
|
var lint_staged = { "*.{js,json}": ["prettier --write", "git add"] };
|
|
5599
5601
|
var dependencies = {
|
|
5600
|
-
"@h3ravel/shared": "^0.
|
|
5602
|
+
"@h3ravel/shared": "^0.20.1",
|
|
5601
5603
|
"chalk": "^5.6.2",
|
|
5602
5604
|
"collect.js": "^4.36.1",
|
|
5603
5605
|
"commander": "^14.0.1",
|
package/bin/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import { access } from "fs/promises";
|
|
|
5
5
|
import escalade from "escalade/sync";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import resolveFrom from "resolve-from";
|
|
8
|
-
import fs, { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
9
|
-
import { Logger, TaskManager } from "@h3ravel/shared";
|
|
8
|
+
import fs, { copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
9
|
+
import { FileSystem, Logger, TaskManager } from "@h3ravel/shared";
|
|
10
10
|
import { assign, camel, diff, flat, get, isArray, isEmpty, isEqual, isString, omit, pick, set, snake, trim } from "radashi";
|
|
11
11
|
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
12
12
|
import dayjs from "dayjs";
|
|
@@ -14,7 +14,6 @@ import collect, { Collection, collect as collect$1 } from "collect.js";
|
|
|
14
14
|
import Knex from "knex";
|
|
15
15
|
import { existsSync } from "fs";
|
|
16
16
|
import pluralize from "pluralize";
|
|
17
|
-
import { existsSync as existsSync$1, readFileSync } from "node:fs";
|
|
18
17
|
import { dirname } from "node:path";
|
|
19
18
|
import { fileURLToPath } from "node:url";
|
|
20
19
|
import chalk from "chalk";
|
|
@@ -2422,8 +2421,8 @@ var HasManyThrough = class extends relation_default {
|
|
|
2422
2421
|
const results = await this.take(1).get(columns);
|
|
2423
2422
|
return results.count() > 0 ? results.first() : null;
|
|
2424
2423
|
}
|
|
2425
|
-
async firstOrFail(columns
|
|
2426
|
-
const model = await this.first(columns);
|
|
2424
|
+
async firstOrFail(...columns) {
|
|
2425
|
+
const model = await this.first(...columns);
|
|
2427
2426
|
if (model) return model;
|
|
2428
2427
|
throw new ModelNotFoundError().setModel(this.related.constructor);
|
|
2429
2428
|
}
|
|
@@ -2462,7 +2461,7 @@ var HasManyThrough = class extends relation_default {
|
|
|
2462
2461
|
}
|
|
2463
2462
|
async paginate(perPage = null, columns = ["*"], pageName = "page", page = null) {
|
|
2464
2463
|
this.query.addSelect(this.shouldSelect(columns));
|
|
2465
|
-
return await this.query.paginate(perPage, columns, pageName, page);
|
|
2464
|
+
return await this.query.paginate(perPage ?? 15, columns, pageName, page);
|
|
2466
2465
|
}
|
|
2467
2466
|
shouldSelect(columns = ["*"]) {
|
|
2468
2467
|
if ((columns === null || columns === void 0 ? void 0 : columns.at(0)) == "*") columns = [this.related.getTable() + ".*"];
|
|
@@ -2740,9 +2739,6 @@ const UniqueIds = (Model$1) => {
|
|
|
2740
2739
|
uniqueIds() {
|
|
2741
2740
|
return [];
|
|
2742
2741
|
}
|
|
2743
|
-
newUniqueId() {
|
|
2744
|
-
return null;
|
|
2745
|
-
}
|
|
2746
2742
|
setUniqueIds() {
|
|
2747
2743
|
const uniqueIds = this.uniqueIds();
|
|
2748
2744
|
for (const column of uniqueIds) if (this[column] === null || this[column] === void 0) this[column] = this.newUniqueId();
|
|
@@ -2764,6 +2760,7 @@ var Paginator = class {
|
|
|
2764
2760
|
options = {};
|
|
2765
2761
|
static setFormatter(formatter) {
|
|
2766
2762
|
if (typeof formatter !== "function" && formatter !== null && formatter !== void 0) throw new Error("Paginator formatter must be a function or null");
|
|
2763
|
+
if (!formatter) return;
|
|
2767
2764
|
this.formatter = formatter;
|
|
2768
2765
|
}
|
|
2769
2766
|
constructor(items, total, perPage, currentPage = 1, options = {}) {
|
|
@@ -2852,8 +2849,10 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
|
|
|
2852
2849
|
asProxy() {
|
|
2853
2850
|
return new Proxy(this, {
|
|
2854
2851
|
get: function(target, prop) {
|
|
2852
|
+
var _target$connector$cli;
|
|
2855
2853
|
if (typeof target[prop] !== "undefined") return target[prop];
|
|
2856
2854
|
if (["destroy", "schema"].includes(prop)) return target.connector.schema;
|
|
2855
|
+
const skipReturning = !!((_target$connector$cli = target.connector.client.config) === null || _target$connector$cli === void 0 || (_target$connector$cli = _target$connector$cli.client) === null || _target$connector$cli === void 0 ? void 0 : _target$connector$cli.includes("mysql")) && prop === "returning";
|
|
2857
2856
|
if ([
|
|
2858
2857
|
"select",
|
|
2859
2858
|
"from",
|
|
@@ -2916,7 +2915,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
|
|
|
2916
2915
|
"clearWhere",
|
|
2917
2916
|
"clearHaving",
|
|
2918
2917
|
"clearGroup"
|
|
2919
|
-
].includes(prop)) return (...args) => {
|
|
2918
|
+
].includes(prop) && !skipReturning) return (...args) => {
|
|
2920
2919
|
target.connector[prop](...args);
|
|
2921
2920
|
return target.asProxy();
|
|
2922
2921
|
};
|
|
@@ -2973,7 +2972,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
|
|
|
2973
2972
|
} while (countResults === count);
|
|
2974
2973
|
return true;
|
|
2975
2974
|
}
|
|
2976
|
-
async paginate(page = 1, perPage = 15) {
|
|
2975
|
+
async paginate(page = 1, perPage = 15, _pageName, _page) {
|
|
2977
2976
|
const total = await this.clone().clearOrder().count("*");
|
|
2978
2977
|
let results;
|
|
2979
2978
|
if (total > 0) {
|
|
@@ -3212,14 +3211,15 @@ var arquebus_default = arquebus;
|
|
|
3212
3211
|
|
|
3213
3212
|
//#endregion
|
|
3214
3213
|
//#region src/model.ts
|
|
3215
|
-
const
|
|
3214
|
+
const ModelClass = class {};
|
|
3215
|
+
const BaseModel = compose(ModelClass, has_attributes_default, hides_attributes_default, has_relations_default, has_timestamps_default, has_hooks_default, has_global_scopes_default, unique_ids_default);
|
|
3216
3216
|
var Model = class Model extends BaseModel {
|
|
3217
|
-
primaryKey = "id";
|
|
3218
3217
|
builder = null;
|
|
3219
3218
|
table = null;
|
|
3220
3219
|
keyType = "int";
|
|
3221
3220
|
incrementing = true;
|
|
3222
3221
|
withCount = [];
|
|
3222
|
+
primaryKey = "id";
|
|
3223
3223
|
perPage = 15;
|
|
3224
3224
|
static globalScopes = {};
|
|
3225
3225
|
static pluginInitializers = {};
|
|
@@ -3229,6 +3229,7 @@ var Model = class Model extends BaseModel {
|
|
|
3229
3229
|
eagerLoad = {};
|
|
3230
3230
|
exists = false;
|
|
3231
3231
|
with = [];
|
|
3232
|
+
name;
|
|
3232
3233
|
trx = null;
|
|
3233
3234
|
constructor(attributes = {}) {
|
|
3234
3235
|
super();
|
|
@@ -4000,8 +4001,8 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
4000
4001
|
const results = await this.take(1).get(columns);
|
|
4001
4002
|
return results.count() > 0 ? results.first() : null;
|
|
4002
4003
|
}
|
|
4003
|
-
async firstOrFail(columns
|
|
4004
|
-
const model = await this.first(columns);
|
|
4004
|
+
async firstOrFail(...columns) {
|
|
4005
|
+
const model = await this.first(...columns);
|
|
4005
4006
|
if (model !== null) return model;
|
|
4006
4007
|
throw new ModelNotFoundError().setModel(this.related.constructor);
|
|
4007
4008
|
}
|
|
@@ -4177,7 +4178,9 @@ var Builder = class Builder extends Inference {
|
|
|
4177
4178
|
}
|
|
4178
4179
|
asProxy() {
|
|
4179
4180
|
return new Proxy(this, { get(target, prop) {
|
|
4181
|
+
var _target$query$connect;
|
|
4180
4182
|
if (typeof target[prop] !== "undefined") return target[prop];
|
|
4183
|
+
const skipReturning = !!((_target$query$connect = target.query.connector) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client.config) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client) === null || _target$query$connect === void 0 ? void 0 : _target$query$connect.includes("mysql")) && prop === "returning";
|
|
4181
4184
|
if ([
|
|
4182
4185
|
"select",
|
|
4183
4186
|
"from",
|
|
@@ -4240,7 +4243,7 @@ var Builder = class Builder extends Inference {
|
|
|
4240
4243
|
"clearWhere",
|
|
4241
4244
|
"clearHaving",
|
|
4242
4245
|
"clearGroup"
|
|
4243
|
-
].includes(prop)) return (...args) => {
|
|
4246
|
+
].includes(prop) && !skipReturning) return (...args) => {
|
|
4244
4247
|
target.query[prop](...args);
|
|
4245
4248
|
return target.asProxy();
|
|
4246
4249
|
};
|
|
@@ -5365,10 +5368,10 @@ var MigrationCreator = class {
|
|
|
5365
5368
|
* @returns
|
|
5366
5369
|
*/
|
|
5367
5370
|
async create(name$1, dir, table, create = false) {
|
|
5368
|
-
const stub = this.getStub(table, create);
|
|
5371
|
+
const stub = await this.getStub(table, create);
|
|
5369
5372
|
const filePath = this.getPath(name$1, dir);
|
|
5370
5373
|
await this.ensureDirectoryExists(path.dirname(filePath));
|
|
5371
|
-
await
|
|
5374
|
+
await writeFile(filePath, this.populateStub(stub, table));
|
|
5372
5375
|
await this.firePostCreateHooks(table, filePath);
|
|
5373
5376
|
return filePath;
|
|
5374
5377
|
}
|
|
@@ -5379,29 +5382,29 @@ var MigrationCreator = class {
|
|
|
5379
5382
|
* @param callback
|
|
5380
5383
|
*/
|
|
5381
5384
|
async publish(dir, callback) {
|
|
5382
|
-
const migrationFiles = await
|
|
5385
|
+
const migrationFiles = await readdir(this.customStubPath ?? "");
|
|
5383
5386
|
await this.ensureDirectoryExists(dir);
|
|
5384
5387
|
for (const migrationFile of migrationFiles) {
|
|
5385
5388
|
const sourceFilePath = path.join(this.customStubPath ?? "", migrationFile);
|
|
5386
5389
|
const destinationFilePath = path.join(dir, migrationFile);
|
|
5387
|
-
await
|
|
5390
|
+
await copyFile(sourceFilePath, destinationFilePath);
|
|
5388
5391
|
if (callback) callback(migrationFile, sourceFilePath, destinationFilePath);
|
|
5389
5392
|
}
|
|
5390
5393
|
}
|
|
5391
|
-
getStub(table, create = false) {
|
|
5394
|
+
async getStub(table, create = false) {
|
|
5392
5395
|
let stub;
|
|
5393
5396
|
if (!table) {
|
|
5394
5397
|
const customPath = path.join(this.customStubPath ?? "", `migration-${this.type}.stub`);
|
|
5395
5398
|
console.log("\n", customPath, "---");
|
|
5396
|
-
stub =
|
|
5399
|
+
stub = await FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration-${this.type}.stub`);
|
|
5397
5400
|
} else if (create) {
|
|
5398
5401
|
const customPath = path.join(this.customStubPath ?? "", `migration.create-${this.type}.stub`);
|
|
5399
|
-
stub =
|
|
5402
|
+
stub = await FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.create-${this.type}.stub`);
|
|
5400
5403
|
} else {
|
|
5401
5404
|
const customPath = path.join(this.customStubPath ?? "", `migration.update-${this.type}.stub`);
|
|
5402
|
-
stub =
|
|
5405
|
+
stub = await FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.update-${this.type}.stub`);
|
|
5403
5406
|
}
|
|
5404
|
-
return
|
|
5407
|
+
return await readFile(stub, "utf-8");
|
|
5405
5408
|
}
|
|
5406
5409
|
populateStub(stub, table) {
|
|
5407
5410
|
if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
|
|
@@ -5421,7 +5424,7 @@ var MigrationCreator = class {
|
|
|
5421
5424
|
this.postCreate.push(callback);
|
|
5422
5425
|
}
|
|
5423
5426
|
async ensureDirectoryExists(dir) {
|
|
5424
|
-
await
|
|
5427
|
+
await mkdir(dir, { recursive: true });
|
|
5425
5428
|
}
|
|
5426
5429
|
stubPath(stub = "") {
|
|
5427
5430
|
const __dirname$1 = this.getDirname(import.meta);
|
|
@@ -5437,7 +5440,7 @@ var MigrationCreator = class {
|
|
|
5437
5440
|
//#endregion
|
|
5438
5441
|
//#region package.json
|
|
5439
5442
|
var name = "@h3ravel/arquebus";
|
|
5440
|
-
var version = "0.
|
|
5443
|
+
var version = "0.5.0";
|
|
5441
5444
|
var packageManager = "pnpm@10.14.0";
|
|
5442
5445
|
var description = "Arquebus ORM is a Beautiful, expressive ORM inspired by Laravel's Eloquent, designed for TypeScript applications and for the H3ravel Framework.";
|
|
5443
5446
|
var homepage = "https://h3ravel.toneflix.net/arquebus";
|
|
@@ -5555,12 +5558,12 @@ var scripts = {
|
|
|
5555
5558
|
"test:postgres": "cross-env DB=postgres vitest --project node",
|
|
5556
5559
|
"test:sqlite": "cross-env DB=sqlite vitest --project node",
|
|
5557
5560
|
"test:browser": "vitest --project browser",
|
|
5558
|
-
"release:patch": "pnpm build && git add . && git commit -m \"version: bump version
|
|
5561
|
+
"release:patch": "pnpm build && git add . && git commit -m \"version: bump version\" && pnpm version patch && pnpm publish --tag latest"
|
|
5559
5562
|
};
|
|
5560
5563
|
var husky = { "hooks": { "pre-commit": "lint-staged" } };
|
|
5561
5564
|
var lint_staged = { "*.{js,json}": ["prettier --write", "git add"] };
|
|
5562
5565
|
var dependencies = {
|
|
5563
|
-
"@h3ravel/shared": "^0.
|
|
5566
|
+
"@h3ravel/shared": "^0.20.1",
|
|
5564
5567
|
"chalk": "^5.6.2",
|
|
5565
5568
|
"collect.js": "^4.36.1",
|
|
5566
5569
|
"commander": "^14.0.1",
|