@h3ravel/database 11.5.0-alpha.9 → 11.15.0-alpha.12
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/dist/index.cjs +127 -437
- package/dist/index.d.ts +3 -5
- package/dist/index.js +43 -378
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
9
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
20
16
|
}
|
|
21
17
|
return to;
|
|
22
18
|
};
|
|
@@ -24,19 +20,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
20
|
value: mod,
|
|
25
21
|
enumerable: true
|
|
26
22
|
}) : target, mod));
|
|
27
|
-
|
|
28
23
|
//#endregion
|
|
29
|
-
let
|
|
24
|
+
let _h3ravel_shared = require("@h3ravel/shared");
|
|
30
25
|
let node_fs_promises = require("node:fs/promises");
|
|
31
|
-
let
|
|
32
|
-
let
|
|
26
|
+
let _h3ravel_musket = require("@h3ravel/musket");
|
|
27
|
+
let _h3ravel_support = require("@h3ravel/support");
|
|
28
|
+
let dayjs = require("dayjs");
|
|
29
|
+
dayjs = __toESM(dayjs, 1);
|
|
33
30
|
let node_path = require("node:path");
|
|
34
|
-
node_path = __toESM(node_path);
|
|
35
|
-
let
|
|
36
|
-
let
|
|
37
|
-
let
|
|
38
|
-
let
|
|
39
|
-
|
|
31
|
+
node_path = __toESM(node_path, 1);
|
|
32
|
+
let _h3ravel_arquebus_migrations = require("@h3ravel/arquebus/migrations");
|
|
33
|
+
let _h3ravel_arquebus_relations = require("@h3ravel/arquebus/relations");
|
|
34
|
+
let _h3ravel_arquebus = require("@h3ravel/arquebus");
|
|
35
|
+
let _h3ravel_contracts = require("@h3ravel/contracts");
|
|
40
36
|
//#region src/Utils/TableGuesser.ts
|
|
41
37
|
var TableGuesser = class TableGuesser {
|
|
42
38
|
static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
|
|
@@ -53,310 +49,9 @@ var TableGuesser = class TableGuesser {
|
|
|
53
49
|
return [];
|
|
54
50
|
}
|
|
55
51
|
};
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region ../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js
|
|
59
|
-
var require_dayjs_min = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
60
|
-
(function(t, e) {
|
|
61
|
-
"object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
|
|
62
|
-
})(exports, (function() {
|
|
63
|
-
"use strict";
|
|
64
|
-
var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = {
|
|
65
|
-
name: "en",
|
|
66
|
-
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
|
67
|
-
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
|
68
|
-
ordinal: function(t$1) {
|
|
69
|
-
var e$1 = [
|
|
70
|
-
"th",
|
|
71
|
-
"st",
|
|
72
|
-
"nd",
|
|
73
|
-
"rd"
|
|
74
|
-
], n$1 = t$1 % 100;
|
|
75
|
-
return "[" + t$1 + (e$1[(n$1 - 20) % 10] || e$1[n$1] || e$1[0]) + "]";
|
|
76
|
-
}
|
|
77
|
-
}, m = function(t$1, e$1, n$1) {
|
|
78
|
-
var r$1 = String(t$1);
|
|
79
|
-
return !r$1 || r$1.length >= e$1 ? t$1 : "" + Array(e$1 + 1 - r$1.length).join(n$1) + t$1;
|
|
80
|
-
}, v = {
|
|
81
|
-
s: m,
|
|
82
|
-
z: function(t$1) {
|
|
83
|
-
var e$1 = -t$1.utcOffset(), n$1 = Math.abs(e$1), r$1 = Math.floor(n$1 / 60), i$1 = n$1 % 60;
|
|
84
|
-
return (e$1 <= 0 ? "+" : "-") + m(r$1, 2, "0") + ":" + m(i$1, 2, "0");
|
|
85
|
-
},
|
|
86
|
-
m: function t$1(e$1, n$1) {
|
|
87
|
-
if (e$1.date() < n$1.date()) return -t$1(n$1, e$1);
|
|
88
|
-
var r$1 = 12 * (n$1.year() - e$1.year()) + (n$1.month() - e$1.month()), i$1 = e$1.clone().add(r$1, c), s$1 = n$1 - i$1 < 0, u$1 = e$1.clone().add(r$1 + (s$1 ? -1 : 1), c);
|
|
89
|
-
return +(-(r$1 + (n$1 - i$1) / (s$1 ? i$1 - u$1 : u$1 - i$1)) || 0);
|
|
90
|
-
},
|
|
91
|
-
a: function(t$1) {
|
|
92
|
-
return t$1 < 0 ? Math.ceil(t$1) || 0 : Math.floor(t$1);
|
|
93
|
-
},
|
|
94
|
-
p: function(t$1) {
|
|
95
|
-
return {
|
|
96
|
-
M: c,
|
|
97
|
-
y: h,
|
|
98
|
-
w: o,
|
|
99
|
-
d: a,
|
|
100
|
-
D: d,
|
|
101
|
-
h: u,
|
|
102
|
-
m: s,
|
|
103
|
-
s: i,
|
|
104
|
-
ms: r,
|
|
105
|
-
Q: f
|
|
106
|
-
}[t$1] || String(t$1 || "").toLowerCase().replace(/s$/, "");
|
|
107
|
-
},
|
|
108
|
-
u: function(t$1) {
|
|
109
|
-
return void 0 === t$1;
|
|
110
|
-
}
|
|
111
|
-
}, g = "en", D = {};
|
|
112
|
-
D[g] = M;
|
|
113
|
-
var p = "$isDayjsObject", S = function(t$1) {
|
|
114
|
-
return t$1 instanceof _ || !(!t$1 || !t$1[p]);
|
|
115
|
-
}, w = function t$1(e$1, n$1, r$1) {
|
|
116
|
-
var i$1;
|
|
117
|
-
if (!e$1) return g;
|
|
118
|
-
if ("string" == typeof e$1) {
|
|
119
|
-
var s$1 = e$1.toLowerCase();
|
|
120
|
-
D[s$1] && (i$1 = s$1), n$1 && (D[s$1] = n$1, i$1 = s$1);
|
|
121
|
-
var u$1 = e$1.split("-");
|
|
122
|
-
if (!i$1 && u$1.length > 1) return t$1(u$1[0]);
|
|
123
|
-
} else {
|
|
124
|
-
var a$1 = e$1.name;
|
|
125
|
-
D[a$1] = e$1, i$1 = a$1;
|
|
126
|
-
}
|
|
127
|
-
return !r$1 && i$1 && (g = i$1), i$1 || !r$1 && g;
|
|
128
|
-
}, O = function(t$1, e$1) {
|
|
129
|
-
if (S(t$1)) return t$1.clone();
|
|
130
|
-
var n$1 = "object" == typeof e$1 ? e$1 : {};
|
|
131
|
-
return n$1.date = t$1, n$1.args = arguments, new _(n$1);
|
|
132
|
-
}, b = v;
|
|
133
|
-
b.l = w, b.i = S, b.w = function(t$1, e$1) {
|
|
134
|
-
return O(t$1, {
|
|
135
|
-
locale: e$1.$L,
|
|
136
|
-
utc: e$1.$u,
|
|
137
|
-
x: e$1.$x,
|
|
138
|
-
$offset: e$1.$offset
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
var _ = function() {
|
|
142
|
-
function M$1(t$1) {
|
|
143
|
-
this.$L = w(t$1.locale, null, !0), this.parse(t$1), this.$x = this.$x || t$1.x || {}, this[p] = !0;
|
|
144
|
-
}
|
|
145
|
-
var m$1 = M$1.prototype;
|
|
146
|
-
return m$1.parse = function(t$1) {
|
|
147
|
-
this.$d = function(t$2) {
|
|
148
|
-
var e$1 = t$2.date, n$1 = t$2.utc;
|
|
149
|
-
if (null === e$1) return /* @__PURE__ */ new Date(NaN);
|
|
150
|
-
if (b.u(e$1)) return /* @__PURE__ */ new Date();
|
|
151
|
-
if (e$1 instanceof Date) return new Date(e$1);
|
|
152
|
-
if ("string" == typeof e$1 && !/Z$/i.test(e$1)) {
|
|
153
|
-
var r$1 = e$1.match($);
|
|
154
|
-
if (r$1) {
|
|
155
|
-
var i$1 = r$1[2] - 1 || 0, s$1 = (r$1[7] || "0").substring(0, 3);
|
|
156
|
-
return n$1 ? new Date(Date.UTC(r$1[1], i$1, r$1[3] || 1, r$1[4] || 0, r$1[5] || 0, r$1[6] || 0, s$1)) : new Date(r$1[1], i$1, r$1[3] || 1, r$1[4] || 0, r$1[5] || 0, r$1[6] || 0, s$1);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return new Date(e$1);
|
|
160
|
-
}(t$1), this.init();
|
|
161
|
-
}, m$1.init = function() {
|
|
162
|
-
var t$1 = this.$d;
|
|
163
|
-
this.$y = t$1.getFullYear(), this.$M = t$1.getMonth(), this.$D = t$1.getDate(), this.$W = t$1.getDay(), this.$H = t$1.getHours(), this.$m = t$1.getMinutes(), this.$s = t$1.getSeconds(), this.$ms = t$1.getMilliseconds();
|
|
164
|
-
}, m$1.$utils = function() {
|
|
165
|
-
return b;
|
|
166
|
-
}, m$1.isValid = function() {
|
|
167
|
-
return !(this.$d.toString() === l);
|
|
168
|
-
}, m$1.isSame = function(t$1, e$1) {
|
|
169
|
-
var n$1 = O(t$1);
|
|
170
|
-
return this.startOf(e$1) <= n$1 && n$1 <= this.endOf(e$1);
|
|
171
|
-
}, m$1.isAfter = function(t$1, e$1) {
|
|
172
|
-
return O(t$1) < this.startOf(e$1);
|
|
173
|
-
}, m$1.isBefore = function(t$1, e$1) {
|
|
174
|
-
return this.endOf(e$1) < O(t$1);
|
|
175
|
-
}, m$1.$g = function(t$1, e$1, n$1) {
|
|
176
|
-
return b.u(t$1) ? this[e$1] : this.set(n$1, t$1);
|
|
177
|
-
}, m$1.unix = function() {
|
|
178
|
-
return Math.floor(this.valueOf() / 1e3);
|
|
179
|
-
}, m$1.valueOf = function() {
|
|
180
|
-
return this.$d.getTime();
|
|
181
|
-
}, m$1.startOf = function(t$1, e$1) {
|
|
182
|
-
var n$1 = this, r$1 = !!b.u(e$1) || e$1, f$1 = b.p(t$1), l$1 = function(t$2, e$2) {
|
|
183
|
-
var i$1 = b.w(n$1.$u ? Date.UTC(n$1.$y, e$2, t$2) : new Date(n$1.$y, e$2, t$2), n$1);
|
|
184
|
-
return r$1 ? i$1 : i$1.endOf(a);
|
|
185
|
-
}, $$1 = function(t$2, e$2) {
|
|
186
|
-
return b.w(n$1.toDate()[t$2].apply(n$1.toDate("s"), (r$1 ? [
|
|
187
|
-
0,
|
|
188
|
-
0,
|
|
189
|
-
0,
|
|
190
|
-
0
|
|
191
|
-
] : [
|
|
192
|
-
23,
|
|
193
|
-
59,
|
|
194
|
-
59,
|
|
195
|
-
999
|
|
196
|
-
]).slice(e$2)), n$1);
|
|
197
|
-
}, y$1 = this.$W, M$2 = this.$M, m$2 = this.$D, v$1 = "set" + (this.$u ? "UTC" : "");
|
|
198
|
-
switch (f$1) {
|
|
199
|
-
case h: return r$1 ? l$1(1, 0) : l$1(31, 11);
|
|
200
|
-
case c: return r$1 ? l$1(1, M$2) : l$1(0, M$2 + 1);
|
|
201
|
-
case o:
|
|
202
|
-
var g$1 = this.$locale().weekStart || 0, D$1 = (y$1 < g$1 ? y$1 + 7 : y$1) - g$1;
|
|
203
|
-
return l$1(r$1 ? m$2 - D$1 : m$2 + (6 - D$1), M$2);
|
|
204
|
-
case a:
|
|
205
|
-
case d: return $$1(v$1 + "Hours", 0);
|
|
206
|
-
case u: return $$1(v$1 + "Minutes", 1);
|
|
207
|
-
case s: return $$1(v$1 + "Seconds", 2);
|
|
208
|
-
case i: return $$1(v$1 + "Milliseconds", 3);
|
|
209
|
-
default: return this.clone();
|
|
210
|
-
}
|
|
211
|
-
}, m$1.endOf = function(t$1) {
|
|
212
|
-
return this.startOf(t$1, !1);
|
|
213
|
-
}, m$1.$set = function(t$1, e$1) {
|
|
214
|
-
var n$1, o$1 = b.p(t$1), f$1 = "set" + (this.$u ? "UTC" : ""), l$1 = (n$1 = {}, n$1[a] = f$1 + "Date", n$1[d] = f$1 + "Date", n$1[c] = f$1 + "Month", n$1[h] = f$1 + "FullYear", n$1[u] = f$1 + "Hours", n$1[s] = f$1 + "Minutes", n$1[i] = f$1 + "Seconds", n$1[r] = f$1 + "Milliseconds", n$1)[o$1], $$1 = o$1 === a ? this.$D + (e$1 - this.$W) : e$1;
|
|
215
|
-
if (o$1 === c || o$1 === h) {
|
|
216
|
-
var y$1 = this.clone().set(d, 1);
|
|
217
|
-
y$1.$d[l$1]($$1), y$1.init(), this.$d = y$1.set(d, Math.min(this.$D, y$1.daysInMonth())).$d;
|
|
218
|
-
} else l$1 && this.$d[l$1]($$1);
|
|
219
|
-
return this.init(), this;
|
|
220
|
-
}, m$1.set = function(t$1, e$1) {
|
|
221
|
-
return this.clone().$set(t$1, e$1);
|
|
222
|
-
}, m$1.get = function(t$1) {
|
|
223
|
-
return this[b.p(t$1)]();
|
|
224
|
-
}, m$1.add = function(r$1, f$1) {
|
|
225
|
-
var d$1, l$1 = this;
|
|
226
|
-
r$1 = Number(r$1);
|
|
227
|
-
var $$1 = b.p(f$1), y$1 = function(t$1) {
|
|
228
|
-
var e$1 = O(l$1);
|
|
229
|
-
return b.w(e$1.date(e$1.date() + Math.round(t$1 * r$1)), l$1);
|
|
230
|
-
};
|
|
231
|
-
if ($$1 === c) return this.set(c, this.$M + r$1);
|
|
232
|
-
if ($$1 === h) return this.set(h, this.$y + r$1);
|
|
233
|
-
if ($$1 === a) return y$1(1);
|
|
234
|
-
if ($$1 === o) return y$1(7);
|
|
235
|
-
var M$2 = (d$1 = {}, d$1[s] = e, d$1[u] = n, d$1[i] = t, d$1)[$$1] || 1, m$2 = this.$d.getTime() + r$1 * M$2;
|
|
236
|
-
return b.w(m$2, this);
|
|
237
|
-
}, m$1.subtract = function(t$1, e$1) {
|
|
238
|
-
return this.add(-1 * t$1, e$1);
|
|
239
|
-
}, m$1.format = function(t$1) {
|
|
240
|
-
var e$1 = this, n$1 = this.$locale();
|
|
241
|
-
if (!this.isValid()) return n$1.invalidDate || l;
|
|
242
|
-
var r$1 = t$1 || "YYYY-MM-DDTHH:mm:ssZ", i$1 = b.z(this), s$1 = this.$H, u$1 = this.$m, a$1 = this.$M, o$1 = n$1.weekdays, c$1 = n$1.months, f$1 = n$1.meridiem, h$1 = function(t$2, n$2, i$2, s$2) {
|
|
243
|
-
return t$2 && (t$2[n$2] || t$2(e$1, r$1)) || i$2[n$2].slice(0, s$2);
|
|
244
|
-
}, d$1 = function(t$2) {
|
|
245
|
-
return b.s(s$1 % 12 || 12, t$2, "0");
|
|
246
|
-
}, $$1 = f$1 || function(t$2, e$2, n$2) {
|
|
247
|
-
var r$2 = t$2 < 12 ? "AM" : "PM";
|
|
248
|
-
return n$2 ? r$2.toLowerCase() : r$2;
|
|
249
|
-
};
|
|
250
|
-
return r$1.replace(y, (function(t$2, r$2) {
|
|
251
|
-
return r$2 || function(t$3) {
|
|
252
|
-
switch (t$3) {
|
|
253
|
-
case "YY": return String(e$1.$y).slice(-2);
|
|
254
|
-
case "YYYY": return b.s(e$1.$y, 4, "0");
|
|
255
|
-
case "M": return a$1 + 1;
|
|
256
|
-
case "MM": return b.s(a$1 + 1, 2, "0");
|
|
257
|
-
case "MMM": return h$1(n$1.monthsShort, a$1, c$1, 3);
|
|
258
|
-
case "MMMM": return h$1(c$1, a$1);
|
|
259
|
-
case "D": return e$1.$D;
|
|
260
|
-
case "DD": return b.s(e$1.$D, 2, "0");
|
|
261
|
-
case "d": return String(e$1.$W);
|
|
262
|
-
case "dd": return h$1(n$1.weekdaysMin, e$1.$W, o$1, 2);
|
|
263
|
-
case "ddd": return h$1(n$1.weekdaysShort, e$1.$W, o$1, 3);
|
|
264
|
-
case "dddd": return o$1[e$1.$W];
|
|
265
|
-
case "H": return String(s$1);
|
|
266
|
-
case "HH": return b.s(s$1, 2, "0");
|
|
267
|
-
case "h": return d$1(1);
|
|
268
|
-
case "hh": return d$1(2);
|
|
269
|
-
case "a": return $$1(s$1, u$1, !0);
|
|
270
|
-
case "A": return $$1(s$1, u$1, !1);
|
|
271
|
-
case "m": return String(u$1);
|
|
272
|
-
case "mm": return b.s(u$1, 2, "0");
|
|
273
|
-
case "s": return String(e$1.$s);
|
|
274
|
-
case "ss": return b.s(e$1.$s, 2, "0");
|
|
275
|
-
case "SSS": return b.s(e$1.$ms, 3, "0");
|
|
276
|
-
case "Z": return i$1;
|
|
277
|
-
}
|
|
278
|
-
return null;
|
|
279
|
-
}(t$2) || i$1.replace(":", "");
|
|
280
|
-
}));
|
|
281
|
-
}, m$1.utcOffset = function() {
|
|
282
|
-
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
283
|
-
}, m$1.diff = function(r$1, d$1, l$1) {
|
|
284
|
-
var $$1, y$1 = this, M$2 = b.p(d$1), m$2 = O(r$1), v$1 = (m$2.utcOffset() - this.utcOffset()) * e, g$1 = this - m$2, D$1 = function() {
|
|
285
|
-
return b.m(y$1, m$2);
|
|
286
|
-
};
|
|
287
|
-
switch (M$2) {
|
|
288
|
-
case h:
|
|
289
|
-
$$1 = D$1() / 12;
|
|
290
|
-
break;
|
|
291
|
-
case c:
|
|
292
|
-
$$1 = D$1();
|
|
293
|
-
break;
|
|
294
|
-
case f:
|
|
295
|
-
$$1 = D$1() / 3;
|
|
296
|
-
break;
|
|
297
|
-
case o:
|
|
298
|
-
$$1 = (g$1 - v$1) / 6048e5;
|
|
299
|
-
break;
|
|
300
|
-
case a:
|
|
301
|
-
$$1 = (g$1 - v$1) / 864e5;
|
|
302
|
-
break;
|
|
303
|
-
case u:
|
|
304
|
-
$$1 = g$1 / n;
|
|
305
|
-
break;
|
|
306
|
-
case s:
|
|
307
|
-
$$1 = g$1 / e;
|
|
308
|
-
break;
|
|
309
|
-
case i:
|
|
310
|
-
$$1 = g$1 / t;
|
|
311
|
-
break;
|
|
312
|
-
default: $$1 = g$1;
|
|
313
|
-
}
|
|
314
|
-
return l$1 ? $$1 : b.a($$1);
|
|
315
|
-
}, m$1.daysInMonth = function() {
|
|
316
|
-
return this.endOf(c).$D;
|
|
317
|
-
}, m$1.$locale = function() {
|
|
318
|
-
return D[this.$L];
|
|
319
|
-
}, m$1.locale = function(t$1, e$1) {
|
|
320
|
-
if (!t$1) return this.$L;
|
|
321
|
-
var n$1 = this.clone(), r$1 = w(t$1, e$1, !0);
|
|
322
|
-
return r$1 && (n$1.$L = r$1), n$1;
|
|
323
|
-
}, m$1.clone = function() {
|
|
324
|
-
return b.w(this.$d, this);
|
|
325
|
-
}, m$1.toDate = function() {
|
|
326
|
-
return new Date(this.valueOf());
|
|
327
|
-
}, m$1.toJSON = function() {
|
|
328
|
-
return this.isValid() ? this.toISOString() : null;
|
|
329
|
-
}, m$1.toISOString = function() {
|
|
330
|
-
return this.$d.toISOString();
|
|
331
|
-
}, m$1.toString = function() {
|
|
332
|
-
return this.$d.toUTCString();
|
|
333
|
-
}, M$1;
|
|
334
|
-
}(), k = _.prototype;
|
|
335
|
-
return O.prototype = k, [
|
|
336
|
-
["$ms", r],
|
|
337
|
-
["$s", i],
|
|
338
|
-
["$m", s],
|
|
339
|
-
["$H", u],
|
|
340
|
-
["$W", a],
|
|
341
|
-
["$M", c],
|
|
342
|
-
["$y", h],
|
|
343
|
-
["$D", d]
|
|
344
|
-
].forEach((function(t$1) {
|
|
345
|
-
k[t$1[1]] = function(e$1) {
|
|
346
|
-
return this.$g(e$1, t$1[0], t$1[1]);
|
|
347
|
-
};
|
|
348
|
-
})), O.extend = function(t$1, e$1) {
|
|
349
|
-
return t$1.$i || (t$1(e$1, _, O), t$1.$i = !0), O;
|
|
350
|
-
}, O.locale = w, O.isDayjs = S, O.unix = function(t$1) {
|
|
351
|
-
return O(1e3 * t$1);
|
|
352
|
-
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
353
|
-
}));
|
|
354
|
-
}));
|
|
355
|
-
|
|
356
52
|
//#endregion
|
|
357
53
|
//#region src/Commands/MakeCommand.ts
|
|
358
|
-
var
|
|
359
|
-
var MakeCommand = class extends __h3ravel_musket.Command {
|
|
54
|
+
var MakeCommand = class extends _h3ravel_musket.Command {
|
|
360
55
|
/**
|
|
361
56
|
* The name and signature of the console command.
|
|
362
57
|
*
|
|
@@ -413,9 +108,9 @@ var MakeCommand = class extends __h3ravel_musket.Command {
|
|
|
413
108
|
async makeMigration() {
|
|
414
109
|
const type = this.option("type", "ts");
|
|
415
110
|
const name = this.argument("name");
|
|
416
|
-
const datePrefix = (0,
|
|
417
|
-
const path
|
|
418
|
-
const dbPkgPath =
|
|
111
|
+
const datePrefix = (0, dayjs.default)().format("YYYY_MM_DD_HHmmss");
|
|
112
|
+
const path = database_path(`migrations/${datePrefix}_${name}.${type}`);
|
|
113
|
+
const dbPkgPath = _h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
419
114
|
let create = this.option("create", false);
|
|
420
115
|
let table = this.option("table");
|
|
421
116
|
if (!table && typeof create === "string") {
|
|
@@ -432,16 +127,16 @@ var MakeCommand = class extends __h3ravel_musket.Command {
|
|
|
432
127
|
create
|
|
433
128
|
})), "utf-8");
|
|
434
129
|
if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
|
|
435
|
-
|
|
436
|
-
await this.kernel.ensureDirectoryExists(node_path.default.dirname(path
|
|
437
|
-
await (0, node_fs_promises.writeFile)(path
|
|
438
|
-
|
|
130
|
+
_h3ravel_shared.Logger.info("INFO: Creating Migration");
|
|
131
|
+
await this.kernel.ensureDirectoryExists(node_path.default.dirname(path));
|
|
132
|
+
await (0, node_fs_promises.writeFile)(path, stub);
|
|
133
|
+
_h3ravel_shared.Logger.split("INFO: Migration Created", _h3ravel_shared.Logger.log(node_path.default.basename(path), "gray", false));
|
|
439
134
|
}
|
|
440
135
|
/**
|
|
441
136
|
* Create a new model factory
|
|
442
137
|
*/
|
|
443
138
|
makeFactory() {
|
|
444
|
-
|
|
139
|
+
_h3ravel_shared.Logger.success("Factory support is not yet available");
|
|
445
140
|
}
|
|
446
141
|
/**
|
|
447
142
|
* Create a new seeder class
|
|
@@ -450,14 +145,14 @@ var MakeCommand = class extends __h3ravel_musket.Command {
|
|
|
450
145
|
const type = this.option("type", "ts");
|
|
451
146
|
const name = this.argument("name");
|
|
452
147
|
const force = this.option("force");
|
|
453
|
-
const path
|
|
148
|
+
const path = database_path(`seeders/${_h3ravel_support.Str.snake(name)}.${type}`);
|
|
454
149
|
/** Check if the model already exists */
|
|
455
|
-
if (!force && await
|
|
456
|
-
const dbPkgPath =
|
|
150
|
+
if (!force && await _h3ravel_shared.FileSystem.fileExists(path)) _h3ravel_shared.Logger.error(`ERORR: ${name} already exists`);
|
|
151
|
+
const dbPkgPath = _h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
457
152
|
let stub = await (0, node_fs_promises.readFile)(node_path.default.join(dbPkgPath, this.getStubName("seeder", type)), "utf-8");
|
|
458
153
|
stub = stub.replace(/{{ name }}/g, name);
|
|
459
|
-
await (0, node_fs_promises.writeFile)(path
|
|
460
|
-
|
|
154
|
+
await (0, node_fs_promises.writeFile)(path, stub);
|
|
155
|
+
_h3ravel_shared.Logger.info(`INFO: Seeder ${_h3ravel_shared.Logger.log(`[${node_path.default.relative(process.cwd(), path)}]`, "bold", false)} created successfully.`);
|
|
461
156
|
}
|
|
462
157
|
/**
|
|
463
158
|
* Generate a new Arquebus model class
|
|
@@ -466,16 +161,16 @@ var MakeCommand = class extends __h3ravel_musket.Command {
|
|
|
466
161
|
const type = this.option("type", "ts");
|
|
467
162
|
const name = this.argument("name");
|
|
468
163
|
const force = this.option("force");
|
|
469
|
-
const path
|
|
164
|
+
const path = app_path(`Models/${_h3ravel_support.Str.lower(name)}.${type}`);
|
|
470
165
|
/** The model is scoped to a path make sure to create the associated directories */
|
|
471
|
-
if (name.includes("/")) await (0, node_fs_promises.mkdir)(
|
|
166
|
+
if (name.includes("/")) await (0, node_fs_promises.mkdir)(_h3ravel_support.Str.beforeLast(path, "/"), { recursive: true });
|
|
472
167
|
/** Check if the model already exists */
|
|
473
|
-
if (!force && await
|
|
474
|
-
const dbPkgPath =
|
|
168
|
+
if (!force && await _h3ravel_shared.FileSystem.fileExists(path)) _h3ravel_shared.Logger.error(`ERORR: ${name} model already exists`);
|
|
169
|
+
const dbPkgPath = _h3ravel_shared.FileSystem.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
|
|
475
170
|
let stub = await (0, node_fs_promises.readFile)(node_path.default.join(dbPkgPath, `dist/stubs/model-${type}.stub`), "utf-8");
|
|
476
171
|
stub = stub.replace(/{{ name }}/g, name);
|
|
477
|
-
await (0, node_fs_promises.writeFile)(path
|
|
478
|
-
|
|
172
|
+
await (0, node_fs_promises.writeFile)(path, stub);
|
|
173
|
+
_h3ravel_shared.Logger.info(`INFO: Model ${_h3ravel_shared.Logger.log(`[${node_path.default.relative(process.cwd(), path)}]`, "bold", false)} created successfully.`);
|
|
479
174
|
}
|
|
480
175
|
/**
|
|
481
176
|
* Ge the database migration file name
|
|
@@ -495,10 +190,9 @@ var MakeCommand = class extends __h3ravel_musket.Command {
|
|
|
495
190
|
} else return `dist/stubs/${type}-${ext}.stub`;
|
|
496
191
|
}
|
|
497
192
|
};
|
|
498
|
-
|
|
499
193
|
//#endregion
|
|
500
194
|
//#region src/Commands/MigrateCommand.ts
|
|
501
|
-
var MigrateCommand = class extends
|
|
195
|
+
var MigrateCommand = class extends _h3ravel_musket.Command {
|
|
502
196
|
/**
|
|
503
197
|
* The current database connection
|
|
504
198
|
*/
|
|
@@ -559,10 +253,10 @@ var MigrateCommand = class extends __h3ravel_musket.Command {
|
|
|
559
253
|
*/
|
|
560
254
|
async migrateRun() {
|
|
561
255
|
try {
|
|
562
|
-
await new
|
|
256
|
+
await new _h3ravel_arquebus_migrations.Migrate(this.databasePath).run(this.connection, this.options(), true);
|
|
563
257
|
if (this.option("seed")) await this.runSeeders();
|
|
564
258
|
} catch (e) {
|
|
565
|
-
|
|
259
|
+
_h3ravel_shared.Logger.error("ERROR: " + e);
|
|
566
260
|
}
|
|
567
261
|
}
|
|
568
262
|
/**
|
|
@@ -570,10 +264,10 @@ var MigrateCommand = class extends __h3ravel_musket.Command {
|
|
|
570
264
|
*/
|
|
571
265
|
async migrateFresh() {
|
|
572
266
|
try {
|
|
573
|
-
await new
|
|
267
|
+
await new _h3ravel_arquebus_migrations.Migrate(this.databasePath).fresh(this.connection, this.options(), true);
|
|
574
268
|
if (this.option("seed")) await this.runSeeders();
|
|
575
269
|
} catch (e) {
|
|
576
|
-
|
|
270
|
+
_h3ravel_shared.Logger.error("ERROR: " + e);
|
|
577
271
|
}
|
|
578
272
|
}
|
|
579
273
|
/**
|
|
@@ -581,10 +275,10 @@ var MigrateCommand = class extends __h3ravel_musket.Command {
|
|
|
581
275
|
*/
|
|
582
276
|
async migrateRefresh() {
|
|
583
277
|
try {
|
|
584
|
-
await new
|
|
278
|
+
await new _h3ravel_arquebus_migrations.Migrate(this.databasePath).refresh(this.connection, this.options(), true);
|
|
585
279
|
if (this.option("seed")) await this.runSeeders();
|
|
586
280
|
} catch (e) {
|
|
587
|
-
|
|
281
|
+
_h3ravel_shared.Logger.error("ERROR: " + e);
|
|
588
282
|
}
|
|
589
283
|
}
|
|
590
284
|
/**
|
|
@@ -592,12 +286,12 @@ var MigrateCommand = class extends __h3ravel_musket.Command {
|
|
|
592
286
|
*/
|
|
593
287
|
async migrateInstall() {
|
|
594
288
|
try {
|
|
595
|
-
const migrate = new
|
|
289
|
+
const migrate = new _h3ravel_arquebus_migrations.Migrate(this.databasePath);
|
|
596
290
|
const { migrator } = await migrate.setupConnection(this.connection);
|
|
597
291
|
await migrate.prepareDatabase(migrator);
|
|
598
|
-
|
|
292
|
+
_h3ravel_shared.Logger.success("Migration repository installed.");
|
|
599
293
|
} catch (e) {
|
|
600
|
-
|
|
294
|
+
_h3ravel_shared.Logger.error("ERROR: " + e);
|
|
601
295
|
}
|
|
602
296
|
}
|
|
603
297
|
/**
|
|
@@ -605,9 +299,9 @@ var MigrateCommand = class extends __h3ravel_musket.Command {
|
|
|
605
299
|
*/
|
|
606
300
|
async migrateReset() {
|
|
607
301
|
try {
|
|
608
|
-
await new
|
|
302
|
+
await new _h3ravel_arquebus_migrations.Migrate(this.databasePath).reset(this.connection, this.options(), true);
|
|
609
303
|
} catch (e) {
|
|
610
|
-
|
|
304
|
+
_h3ravel_shared.Logger.error("ERROR: " + e);
|
|
611
305
|
}
|
|
612
306
|
}
|
|
613
307
|
/**
|
|
@@ -615,29 +309,29 @@ var MigrateCommand = class extends __h3ravel_musket.Command {
|
|
|
615
309
|
*/
|
|
616
310
|
async migrateRollback() {
|
|
617
311
|
try {
|
|
618
|
-
await new
|
|
312
|
+
await new _h3ravel_arquebus_migrations.Migrate(this.databasePath).rollback(this.connection, this.options(), true);
|
|
619
313
|
} catch (e) {
|
|
620
|
-
|
|
314
|
+
_h3ravel_shared.Logger.error("ERROR: " + e);
|
|
621
315
|
}
|
|
622
316
|
}
|
|
623
317
|
/**
|
|
624
318
|
* Show the status of each migration.
|
|
625
319
|
*/
|
|
626
320
|
async migrateStatus() {
|
|
627
|
-
const migrations = await new
|
|
628
|
-
const hint =
|
|
629
|
-
if (sts)
|
|
321
|
+
const migrations = await new _h3ravel_arquebus_migrations.Migrate(this.databasePath, void 0, (msg, sts) => {
|
|
322
|
+
const hint = _h3ravel_shared.Logger.parse([[" Did you forget to run", "white"], ["`musket migrate:install`?", "grey"]], " ", false);
|
|
323
|
+
if (sts) _h3ravel_shared.Logger[sts](msg + hint, sts === "error", true);
|
|
630
324
|
}).status(this.connection, this.options(), true);
|
|
631
325
|
try {
|
|
632
326
|
if (migrations.length > 0) {
|
|
633
|
-
|
|
327
|
+
_h3ravel_shared.Logger.twoColumnDetail("Migration name", "Batch / Status");
|
|
634
328
|
migrations.forEach((migration) => {
|
|
635
|
-
const status = migration.ran ?
|
|
636
|
-
|
|
329
|
+
const status = migration.ran ? _h3ravel_shared.Logger.parse([[`[${migration.batch}]`, "white"], ["Ran", "green"]], " ", false) : _h3ravel_shared.Logger.parse([["Pending", "yellow"]], "", false);
|
|
330
|
+
_h3ravel_shared.Logger.twoColumnDetail(migration.name, status);
|
|
637
331
|
});
|
|
638
|
-
} else
|
|
332
|
+
} else _h3ravel_shared.Logger.info("No migrations found");
|
|
639
333
|
} catch (e) {
|
|
640
|
-
|
|
334
|
+
_h3ravel_shared.Logger.error(["ERROR: " + e, "Did you run musket migrate:install"]);
|
|
641
335
|
}
|
|
642
336
|
}
|
|
643
337
|
/**
|
|
@@ -647,29 +341,29 @@ var MigrateCommand = class extends __h3ravel_musket.Command {
|
|
|
647
341
|
const name = this.argument("package");
|
|
648
342
|
try {
|
|
649
343
|
/** Find the requested package */
|
|
650
|
-
const packagePath =
|
|
344
|
+
const packagePath = _h3ravel_shared.FileSystem.findModulePkg(name) ?? null;
|
|
651
345
|
if (!packagePath) throw new Error("Package not found");
|
|
652
346
|
/** Get the package,json and instanciate the migration creator */
|
|
653
347
|
const pkgJson = await import(node_path.default.join(packagePath, "package.json"));
|
|
654
|
-
const creator = new
|
|
655
|
-
const info =
|
|
656
|
-
|
|
348
|
+
const creator = new _h3ravel_arquebus_migrations.MigrationCreator(node_path.default.join(packagePath, pkgJson.migrations ?? "migrations"));
|
|
349
|
+
const info = _h3ravel_shared.Logger.parse([[" Publishing migrations from", "white"], [`${pkgJson.name}@${pkgJson.version}`, ["italic", "gray"]]], " ", false);
|
|
350
|
+
_h3ravel_shared.Logger.info(`INFO: ${info}`);
|
|
657
351
|
try {
|
|
658
352
|
/** Publish any existing migrations */
|
|
659
353
|
await creator.publish(this.databasePath, (fileName) => {
|
|
660
|
-
|
|
354
|
+
_h3ravel_shared.Logger.twoColumnDetail(fileName, _h3ravel_shared.Logger.parse([["PUBLISHED", "green"]], "", false));
|
|
661
355
|
});
|
|
662
356
|
} catch {
|
|
663
|
-
|
|
357
|
+
_h3ravel_shared.Logger.error([`ERROR: ${name} has no publishable migrations.`]);
|
|
664
358
|
}
|
|
665
359
|
} catch (e) {
|
|
666
|
-
const hint =
|
|
667
|
-
const error =
|
|
360
|
+
const hint = _h3ravel_shared.Logger.parse([[" Did you forget to run", "white"], [`\`${await _h3ravel_shared.Resolver.getPakageInstallCommand(name)}\``, "grey"]], " ", false);
|
|
361
|
+
const error = _h3ravel_shared.Logger.parse([
|
|
668
362
|
["Package `", "white"],
|
|
669
363
|
[name, "grey"],
|
|
670
364
|
["` not found", "white"]
|
|
671
365
|
], "", false);
|
|
672
|
-
|
|
366
|
+
_h3ravel_shared.Logger.error([
|
|
673
367
|
"ERROR: " + error,
|
|
674
368
|
hint + "?",
|
|
675
369
|
String(e)
|
|
@@ -686,10 +380,9 @@ var MigrateCommand = class extends __h3ravel_musket.Command {
|
|
|
686
380
|
}, [], [], {}, this.program).handle();
|
|
687
381
|
}
|
|
688
382
|
};
|
|
689
|
-
|
|
690
383
|
//#endregion
|
|
691
384
|
//#region src/Commands/SeedCommand.ts
|
|
692
|
-
var SeedCommand = class extends
|
|
385
|
+
var SeedCommand = class extends _h3ravel_musket.Command {
|
|
693
386
|
/**
|
|
694
387
|
* The current query builder instance
|
|
695
388
|
*/
|
|
@@ -726,19 +419,19 @@ var SeedCommand = class extends __h3ravel_musket.Command {
|
|
|
726
419
|
this.connection = database ?? config("database.default");
|
|
727
420
|
this.queryBuilder = DB.instance(this.connection);
|
|
728
421
|
if (!this.connection) this.error("ERROR: Unknown database connection.");
|
|
729
|
-
let path
|
|
730
|
-
const [f1, f2] = [
|
|
422
|
+
let path = node_path.default.join(process.cwd(), file);
|
|
423
|
+
const [f1, f2] = [_h3ravel_shared.FileSystem.resolveFileUp(_h3ravel_support.Str.snake(file), ["js", "ts"], database_path("seeders")), _h3ravel_shared.FileSystem.resolveFileUp(_h3ravel_support.Str.studly(file), ["js", "ts"], database_path("seeders"))];
|
|
731
424
|
if (!f1 && !f2) {
|
|
732
425
|
/**
|
|
733
426
|
* Try to find the path assuming it's relative to cwd
|
|
734
427
|
*/
|
|
735
|
-
if (!await
|
|
428
|
+
if (!await _h3ravel_shared.FileSystem.fileExists(path)) path = database_path(node_path.default.join("seeders", file));
|
|
736
429
|
/**
|
|
737
430
|
* Now try to find the path knowing it's relative to database_path
|
|
738
431
|
*/
|
|
739
|
-
if (!await
|
|
740
|
-
} else path
|
|
741
|
-
const { default: seeder } = await import(path
|
|
432
|
+
if (!await _h3ravel_shared.FileSystem.fileExists(path)) this.error(`ERROR: Seeder ${_h3ravel_shared.Logger.log(`[${file}]`, "bold", false)} not found.`);
|
|
433
|
+
} else path = String(f1 ?? f2);
|
|
434
|
+
const { default: seeder } = await import(path);
|
|
742
435
|
if (seeder) {
|
|
743
436
|
this.info("INFO: Seeding database.");
|
|
744
437
|
this.newLine();
|
|
@@ -746,68 +439,67 @@ var SeedCommand = class extends __h3ravel_musket.Command {
|
|
|
746
439
|
}
|
|
747
440
|
}
|
|
748
441
|
};
|
|
749
|
-
|
|
750
442
|
//#endregion
|
|
751
443
|
//#region src/Configuration.ts
|
|
752
|
-
const arquebusConfig = (config
|
|
444
|
+
const arquebusConfig = (config) => {
|
|
445
|
+
const sqliteDatabase = config.connections.sqlite.database;
|
|
753
446
|
return {
|
|
754
447
|
sqlite: {
|
|
755
|
-
client: config
|
|
448
|
+
client: config.connections.sqlite.driver,
|
|
756
449
|
connection: {
|
|
757
|
-
filename: database_path(
|
|
758
|
-
debug: config
|
|
759
|
-
flags: config
|
|
760
|
-
options: config
|
|
761
|
-
expirationChecker: config
|
|
450
|
+
filename: sqliteDatabase === ":memory:" ? sqliteDatabase : database_path(sqliteDatabase),
|
|
451
|
+
debug: config.connections.sqlite.debug,
|
|
452
|
+
flags: config.connections.sqlite.flags,
|
|
453
|
+
options: config.connections.sqlite.options,
|
|
454
|
+
expirationChecker: config.connections.sqlite.expirationChecker
|
|
762
455
|
},
|
|
763
|
-
useNullAsDefault: config
|
|
456
|
+
useNullAsDefault: config.connections.sqlite.useNullAsDefault
|
|
764
457
|
},
|
|
765
458
|
mysql: {
|
|
766
|
-
client: config
|
|
459
|
+
client: config.connections.mysql.driver,
|
|
767
460
|
connection: {
|
|
768
|
-
host: config
|
|
769
|
-
port: config
|
|
770
|
-
user: config
|
|
771
|
-
password: config
|
|
772
|
-
database: config
|
|
773
|
-
charset: config
|
|
774
|
-
socketPath: config
|
|
775
|
-
localAddress: config
|
|
461
|
+
host: config.connections.mysql.host ?? "localhost",
|
|
462
|
+
port: config.connections.mysql.port ?? 3306,
|
|
463
|
+
user: config.connections.mysql.username ?? "root",
|
|
464
|
+
password: config.connections.mysql.password,
|
|
465
|
+
database: config.connections.mysql.database,
|
|
466
|
+
charset: config.connections.mysql.charset,
|
|
467
|
+
socketPath: config.connections.mysql.unix_socket,
|
|
468
|
+
localAddress: config.connections.mysql.url
|
|
776
469
|
}
|
|
777
470
|
},
|
|
778
471
|
mariadb: {
|
|
779
|
-
client: config
|
|
472
|
+
client: config.connections.mariadb.driver,
|
|
780
473
|
connection: {
|
|
781
|
-
host: config
|
|
782
|
-
port: config
|
|
783
|
-
user: config
|
|
784
|
-
password: config
|
|
785
|
-
database: config
|
|
786
|
-
charset: config
|
|
787
|
-
socketPath: config
|
|
788
|
-
localAddress: config
|
|
789
|
-
expirationChecker: config
|
|
474
|
+
host: config.connections.mariadb.host ?? "localhost",
|
|
475
|
+
port: config.connections.mariadb.port ?? 3306,
|
|
476
|
+
user: config.connections.mariadb.username ?? "root",
|
|
477
|
+
password: config.connections.mariadb.password,
|
|
478
|
+
database: config.connections.mariadb.database,
|
|
479
|
+
charset: config.connections.mariadb.charset,
|
|
480
|
+
socketPath: config.connections.mariadb.unix_socket,
|
|
481
|
+
localAddress: config.connections.mariadb.url,
|
|
482
|
+
expirationChecker: config.connections.mariadb.expirationChecker
|
|
790
483
|
}
|
|
791
484
|
},
|
|
792
485
|
pgsql: {
|
|
793
486
|
client: "pg",
|
|
794
487
|
connection: {
|
|
795
|
-
host: config
|
|
796
|
-
port: config
|
|
797
|
-
user: config
|
|
798
|
-
password: config
|
|
799
|
-
database: config
|
|
800
|
-
charset: config
|
|
801
|
-
connectionString: config
|
|
802
|
-
expirationChecker: config
|
|
488
|
+
host: config.connections.pgsql.host ?? "localhost",
|
|
489
|
+
port: config.connections.pgsql.port ?? 3306,
|
|
490
|
+
user: config.connections.pgsql.username ?? "root",
|
|
491
|
+
password: config.connections.pgsql.password,
|
|
492
|
+
database: config.connections.pgsql.database,
|
|
493
|
+
charset: config.connections.mysql.charset,
|
|
494
|
+
connectionString: config.connections.pgsql.url,
|
|
495
|
+
expirationChecker: config.connections.pgsql.expirationChecker
|
|
803
496
|
}
|
|
804
497
|
}
|
|
805
498
|
};
|
|
806
499
|
};
|
|
807
|
-
|
|
808
500
|
//#endregion
|
|
809
501
|
//#region src/Model.ts
|
|
810
|
-
var Model = class Model extends (0,
|
|
502
|
+
var Model = class Model extends (0, _h3ravel_shared.mix)(_h3ravel_contracts.UrlRoutable, _h3ravel_arquebus.Model) {
|
|
811
503
|
/**
|
|
812
504
|
* Retrieve the model for a bound value.
|
|
813
505
|
*
|
|
@@ -866,7 +558,7 @@ var Model = class Model extends (0, __h3ravel_shared.mix)(__h3ravel_contracts.Ur
|
|
|
866
558
|
resolveChildRouteBindingQuery(childType, value, field) {
|
|
867
559
|
const relationship = this[this.childRouteBindingRelationshipName(childType)]();
|
|
868
560
|
field = field || relationship.getRelated().getRouteKeyName();
|
|
869
|
-
if (relationship instanceof
|
|
561
|
+
if (relationship instanceof _h3ravel_arquebus_relations.HasManyThrough || relationship instanceof _h3ravel_arquebus_relations.BelongsToMany) field = relationship.getRelated().qualifyColumn(field);
|
|
870
562
|
return relationship instanceof Model ? relationship.resolveRouteBindingQuery(relationship.newQuery(), value, field) : relationship.getRelated().resolveRouteBindingQuery(relationship, value, field);
|
|
871
563
|
}
|
|
872
564
|
/**
|
|
@@ -875,7 +567,7 @@ var Model = class Model extends (0, __h3ravel_shared.mix)(__h3ravel_contracts.Ur
|
|
|
875
567
|
* @param childType
|
|
876
568
|
*/
|
|
877
569
|
childRouteBindingRelationshipName(childType) {
|
|
878
|
-
return
|
|
570
|
+
return _h3ravel_support.Str.plural(_h3ravel_support.Str.camel(childType));
|
|
879
571
|
}
|
|
880
572
|
/**
|
|
881
573
|
* Get the value of the model's route key.
|
|
@@ -890,7 +582,6 @@ var Model = class Model extends (0, __h3ravel_shared.mix)(__h3ravel_contracts.Ur
|
|
|
890
582
|
return this.getKeyName();
|
|
891
583
|
}
|
|
892
584
|
};
|
|
893
|
-
|
|
894
585
|
//#endregion
|
|
895
586
|
//#region src/Providers/DatabaseServiceProvider.ts
|
|
896
587
|
/**
|
|
@@ -901,13 +592,13 @@ var Model = class Model extends (0, __h3ravel_shared.mix)(__h3ravel_contracts.Ur
|
|
|
901
592
|
* Register migration and seeder commands.
|
|
902
593
|
*
|
|
903
594
|
*/
|
|
904
|
-
var DatabaseServiceProvider = class extends
|
|
595
|
+
var DatabaseServiceProvider = class extends _h3ravel_support.ServiceProvider {
|
|
905
596
|
static priority = 994;
|
|
906
597
|
register() {
|
|
907
|
-
const config
|
|
908
|
-
const connection = Object.entries(arquebusConfig(config
|
|
909
|
-
if (connection)
|
|
910
|
-
this.app.singleton("db", () =>
|
|
598
|
+
const config = this.app.make("config");
|
|
599
|
+
const connection = Object.entries(arquebusConfig(config.get("database"))).find(([client]) => client === config.get("database.default"))?.at(1);
|
|
600
|
+
if (connection) _h3ravel_arquebus.arquebus.addConnection(connection);
|
|
601
|
+
this.app.singleton("db", () => _h3ravel_arquebus.arquebus.fire());
|
|
911
602
|
/** Register Musket Commands */
|
|
912
603
|
this.registerCommands([
|
|
913
604
|
MigrateCommand,
|
|
@@ -916,7 +607,6 @@ var DatabaseServiceProvider = class extends __h3ravel_support.ServiceProvider {
|
|
|
916
607
|
]);
|
|
917
608
|
}
|
|
918
609
|
};
|
|
919
|
-
|
|
920
610
|
//#endregion
|
|
921
611
|
//#region src/Query/DB.ts
|
|
922
612
|
var DB = class DB {
|
|
@@ -943,13 +633,14 @@ var DB = class DB {
|
|
|
943
633
|
return new DB().builder().transaction(callback);
|
|
944
634
|
}
|
|
945
635
|
builder() {
|
|
946
|
-
return
|
|
636
|
+
return _h3ravel_arquebus.arquebus.getInstance().connection(this.connection);
|
|
947
637
|
}
|
|
948
638
|
};
|
|
949
|
-
|
|
950
639
|
//#endregion
|
|
951
640
|
//#region src/Seeder.ts
|
|
952
|
-
var Seeder = class Seeder extends
|
|
641
|
+
var Seeder = class Seeder extends _h3ravel_arquebus.Seeder {
|
|
642
|
+
app;
|
|
643
|
+
command;
|
|
953
644
|
/**
|
|
954
645
|
* Seeders that have been called at least one time.
|
|
955
646
|
*/
|
|
@@ -970,11 +661,11 @@ var Seeder = class Seeder extends __h3ravel_arquebus.Seeder {
|
|
|
970
661
|
* @return this
|
|
971
662
|
*/
|
|
972
663
|
async call(className, silent = false, parameters = []) {
|
|
973
|
-
const classes =
|
|
664
|
+
const classes = _h3ravel_support.Arr.wrap(className);
|
|
974
665
|
for (let i = 0; i < classes.length; i++) {
|
|
975
666
|
const instance = this.resolve(classes[i]);
|
|
976
667
|
const name = instance.constructor.name;
|
|
977
|
-
if (silent === false) await
|
|
668
|
+
if (silent === false) await _h3ravel_shared.TaskManager.advancedTaskRunner([[name, "RUNNING"], [name, "DONE"]], async () => await instance.run(this.command.queryBuilder, ...parameters));
|
|
978
669
|
else await instance.run(this.command.queryBuilder, ...parameters);
|
|
979
670
|
Seeder.called.push(instance);
|
|
980
671
|
}
|
|
@@ -1027,7 +718,6 @@ var Seeder = class Seeder extends __h3ravel_arquebus.Seeder {
|
|
|
1027
718
|
return this;
|
|
1028
719
|
}
|
|
1029
720
|
};
|
|
1030
|
-
|
|
1031
721
|
//#endregion
|
|
1032
722
|
exports.DB = DB;
|
|
1033
723
|
exports.DatabaseServiceProvider = DatabaseServiceProvider;
|
|
@@ -1037,4 +727,4 @@ exports.Model = Model;
|
|
|
1037
727
|
exports.SeedCommand = SeedCommand;
|
|
1038
728
|
exports.Seeder = Seeder;
|
|
1039
729
|
exports.TableGuesser = TableGuesser;
|
|
1040
|
-
exports.arquebusConfig = arquebusConfig;
|
|
730
|
+
exports.arquebusConfig = arquebusConfig;
|