lakutata 2.0.77 → 2.0.78
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/com/cacher.cjs +1 -1
- package/com/cacher.mjs +1 -1
- package/com/docker.cjs +2 -2
- package/com/docker.mjs +2 -2
- package/com/logger.cjs +2 -2
- package/com/logger.mjs +2 -2
- package/com/monitor.cjs +1 -1
- package/com/monitor.mjs +1 -1
- package/helper.cjs +1 -1
- package/helper.mjs +1 -1
- package/lakutata.cjs +47 -47
- package/lakutata.mjs +39 -39
- package/package.json +1 -1
- package/src/components/Logger.cjs +2 -2
- package/src/components/Logger.mjs +2 -2
- package/src/components/cacher/Cacher.cjs +1 -1
- package/src/components/cacher/Cacher.mjs +1 -1
- package/src/components/cacher/adapters/CreateFileCacheAdapter.cjs +1 -1
- package/src/components/cacher/adapters/CreateFileCacheAdapter.mjs +1 -1
- package/src/components/docker/ConnectionOptionsBuilder.cjs +2 -2
- package/src/components/docker/ConnectionOptionsBuilder.mjs +2 -2
- package/src/components/docker/Docker.cjs +2 -2
- package/src/components/docker/Docker.mjs +2 -2
- package/src/components/docker/lib/DockerContainer.cjs +2 -2
- package/src/components/docker/lib/DockerContainer.mjs +2 -2
- package/src/components/docker/lib/DockerContainerTTY.cjs +2 -2
- package/src/components/docker/lib/DockerContainerTTY.mjs +2 -2
- package/src/components/monitor/CpuMonitor.cjs +1 -1
- package/src/components/monitor/CpuMonitor.mjs +1 -1
- package/src/components/monitor/HttpRequestMonitor.cjs +1 -1
- package/src/components/monitor/HttpRequestMonitor.mjs +1 -1
- package/src/components/monitor/MemoryMonitor.cjs +1 -1
- package/src/components/monitor/MemoryMonitor.mjs +1 -1
- package/src/lib/base/internal/ControllerEntrypoint.mjs +1 -1
- package/src/lib/core/Application.cjs +333 -98
- package/src/lib/core/Application.mjs +331 -100
- package/src/lib/helpers/Statistics.cjs +1 -1
- package/src/lib/helpers/Statistics.mjs +1 -1
- package/src/lib/helpers/UUID.mjs +1 -1
- package/src/providers/migration/GenerateMigration.cjs +122 -246
- package/src/providers/migration/GenerateMigration.mjs +123 -246
- package/vendor/Package.14.cjs +13702 -1892
- package/vendor/Package.14.mjs +13744 -1852
- package/vendor/Package.15.cjs +1 -14057
- package/vendor/Package.15.mjs +1 -14031
- package/vendor/Package.16.cjs +2247 -1
- package/vendor/Package.16.mjs +2139 -1
- package/vendor/Package.17.cjs +3 -3
- package/vendor/Package.17.mjs +3 -3
- package/vendor/Package.64.mjs +1 -1
|
@@ -1,44 +1,58 @@
|
|
|
1
1
|
import { _ as t, a as e } from "../../../vendor/Package.1.mjs";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Provider as o } from "./Provider.mjs";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Configurable as i } from "../../decorators/di/Configurable.mjs";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { D as r } from "../../../vendor/Package.2.mjs";
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import n from "path";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { D as s } from "../../../vendor/Package.10.mjs";
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { e as a, I as c, a as p, b as m, P as l, c as u, s as h } from "../../../vendor/Package.102.mjs";
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { g as d } from "../../../vendor/Package.5.mjs";
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { r as g } from "../../../vendor/Package.12.mjs";
|
|
18
18
|
|
|
19
|
-
import
|
|
19
|
+
import "../../../vendor/Package.8.mjs";
|
|
20
20
|
|
|
21
|
-
import
|
|
21
|
+
import j from "fs/promises";
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import { Singleton as f, Transient as y } from "../../decorators/di/Lifetime.mjs";
|
|
24
24
|
|
|
25
|
-
import {
|
|
25
|
+
import { Module as b, MODULE_INITIALIZED as v, MODULE_INITIALIZE_ERROR as x } from "./Module.mjs";
|
|
26
26
|
|
|
27
|
-
import
|
|
27
|
+
import { C as E } from "../../../vendor/Package.3.mjs";
|
|
28
28
|
|
|
29
|
-
import {
|
|
29
|
+
import { ApplicationConfigLoader as w } from "../base/internal/ApplicationConfigLoader.mjs";
|
|
30
30
|
|
|
31
|
-
import {
|
|
31
|
+
import { ApplicationOptions as O } from "../../options/ApplicationOptions.mjs";
|
|
32
32
|
|
|
33
|
-
import {
|
|
33
|
+
import { Alias as P } from "./Alias.mjs";
|
|
34
34
|
|
|
35
|
-
import {
|
|
35
|
+
import { GetBasicInfo as C } from "../base/internal/BasicInfo.mjs";
|
|
36
36
|
|
|
37
|
-
import {
|
|
37
|
+
import { Entrypoint as S } from "../../components/entrypoint/Entrypoint.mjs";
|
|
38
38
|
|
|
39
|
-
import "
|
|
39
|
+
import { L as k } from "../../../vendor/Package.14.mjs";
|
|
40
|
+
|
|
41
|
+
import { Accept as I } from "../../decorators/dto/Accept.mjs";
|
|
42
|
+
|
|
43
|
+
import { mkdirSync as A } from "fs";
|
|
44
|
+
|
|
45
|
+
import D from "node:path";
|
|
46
|
+
|
|
47
|
+
import { existsSync as R } from "node:fs";
|
|
48
|
+
|
|
49
|
+
import { As as N } from "../helpers/As.mjs";
|
|
50
|
+
|
|
51
|
+
import { EventEmitter as B } from "../base/EventEmitter.mjs";
|
|
40
52
|
|
|
41
|
-
import "
|
|
53
|
+
import { DatabaseSymbol as M } from "../base/internal/DatabaseSymbol.mjs";
|
|
54
|
+
|
|
55
|
+
import { Inject as T } from "../../decorators/di/Inject.mjs";
|
|
42
56
|
|
|
43
57
|
import "../base/async-constructor/AsyncConstructor.mjs";
|
|
44
58
|
|
|
@@ -62,8 +76,6 @@ import "../helpers/NoCase.mjs";
|
|
|
62
76
|
|
|
63
77
|
import "../../../vendor/Package.6.mjs";
|
|
64
78
|
|
|
65
|
-
import "../../../vendor/Package.5.mjs";
|
|
66
|
-
|
|
67
79
|
import "../../../vendor/Package.7.mjs";
|
|
68
80
|
|
|
69
81
|
import "../base/internal/ThrowWarning.mjs";
|
|
@@ -116,12 +128,8 @@ import "../ioc/Lifetime.mjs";
|
|
|
116
128
|
|
|
117
129
|
import "../ioc/ListModules.mjs";
|
|
118
130
|
|
|
119
|
-
import "../../../vendor/Package.8.mjs";
|
|
120
|
-
|
|
121
131
|
import "os";
|
|
122
132
|
|
|
123
|
-
import "path";
|
|
124
|
-
|
|
125
133
|
import "stream";
|
|
126
134
|
|
|
127
135
|
import "events";
|
|
@@ -164,6 +172,36 @@ import "../../exceptions/dto/InvalidMethodReturnException.mjs";
|
|
|
164
172
|
|
|
165
173
|
import "../helpers/IsEmptyObject.mjs";
|
|
166
174
|
|
|
175
|
+
import "../../../vendor/Package.62.mjs";
|
|
176
|
+
|
|
177
|
+
import "../../../vendor/Package.11.mjs";
|
|
178
|
+
|
|
179
|
+
import "../../../vendor/Package.122.mjs";
|
|
180
|
+
|
|
181
|
+
import "buffer";
|
|
182
|
+
|
|
183
|
+
import "module";
|
|
184
|
+
|
|
185
|
+
import "tty";
|
|
186
|
+
|
|
187
|
+
import "../../../vendor/Package.13.mjs";
|
|
188
|
+
|
|
189
|
+
import "crypto";
|
|
190
|
+
|
|
191
|
+
import "../../../vendor/Package.63.mjs";
|
|
192
|
+
|
|
193
|
+
import "node:url";
|
|
194
|
+
|
|
195
|
+
import "node:fs/promises";
|
|
196
|
+
|
|
197
|
+
import "node:events";
|
|
198
|
+
|
|
199
|
+
import "node:stream";
|
|
200
|
+
|
|
201
|
+
import "node:string_decoder";
|
|
202
|
+
|
|
203
|
+
import "./Component.mjs";
|
|
204
|
+
|
|
167
205
|
import "../../options/ModuleOptions.mjs";
|
|
168
206
|
|
|
169
207
|
import "../../options/ModuleLoadObjectsOptions.mjs";
|
|
@@ -186,16 +224,10 @@ import "../helpers/ArrayToSet.mjs";
|
|
|
186
224
|
|
|
187
225
|
import "../helpers/SetToArray.mjs";
|
|
188
226
|
|
|
189
|
-
import "../../decorators/di/Configurable.mjs";
|
|
190
|
-
|
|
191
227
|
import "../helpers/NonceStr.mjs";
|
|
192
228
|
|
|
193
229
|
import "../helpers/RandomString.mjs";
|
|
194
230
|
|
|
195
|
-
import "../../../vendor/Package.13.mjs";
|
|
196
|
-
|
|
197
|
-
import "crypto";
|
|
198
|
-
|
|
199
231
|
import "../../exceptions/alias/InvalidAliasNameException.mjs";
|
|
200
232
|
|
|
201
233
|
import "../../exceptions/alias/AliasExistsException.mjs";
|
|
@@ -250,76 +282,136 @@ import "../../components/entrypoint/exceptions/InvalidActionGroupException.mjs";
|
|
|
250
282
|
|
|
251
283
|
import "worker_threads";
|
|
252
284
|
|
|
253
|
-
import "../../../vendor/Package.
|
|
285
|
+
import "../../../vendor/Package.15.mjs";
|
|
254
286
|
|
|
255
|
-
import "
|
|
287
|
+
import "assert";
|
|
256
288
|
|
|
257
|
-
import "
|
|
289
|
+
import "string_decoder";
|
|
258
290
|
|
|
259
|
-
|
|
291
|
+
var L = {};
|
|
260
292
|
|
|
261
|
-
|
|
293
|
+
"use strict";
|
|
262
294
|
|
|
263
|
-
|
|
295
|
+
Object.defineProperty(L, "__esModule", {
|
|
296
|
+
value: true
|
|
297
|
+
});
|
|
264
298
|
|
|
265
|
-
|
|
299
|
+
var q = L.CommandUtils = void 0;
|
|
266
300
|
|
|
267
|
-
|
|
301
|
+
const F = g;
|
|
268
302
|
|
|
269
|
-
|
|
303
|
+
const $ = F.__importDefault(j);
|
|
270
304
|
|
|
271
|
-
|
|
305
|
+
const U = F.__importDefault(n);
|
|
272
306
|
|
|
273
|
-
|
|
307
|
+
const G = a;
|
|
274
308
|
|
|
275
|
-
|
|
309
|
+
const Q = c;
|
|
276
310
|
|
|
277
|
-
|
|
311
|
+
const _ = p();
|
|
278
312
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
313
|
+
class CommandUtils {
|
|
314
|
+
static async loadDataSource(t) {
|
|
315
|
+
let e;
|
|
316
|
+
try {
|
|
317
|
+
[e] = await (0, _.importOrRequireFile)(t);
|
|
318
|
+
} catch (e) {
|
|
319
|
+
throw new Error(`Unable to open file: "${t}". ${e.message}`);
|
|
320
|
+
}
|
|
321
|
+
if (!e || typeof e !== "object") {
|
|
322
|
+
throw new Error(`Given data source file must contain export of a DataSource instance`);
|
|
323
|
+
}
|
|
324
|
+
if (Q.InstanceChecker.isDataSource(e)) {
|
|
325
|
+
return e;
|
|
326
|
+
}
|
|
327
|
+
const o = [];
|
|
328
|
+
for (const t in e) {
|
|
329
|
+
const i = e[t];
|
|
330
|
+
const r = await i;
|
|
331
|
+
if (Q.InstanceChecker.isDataSource(r)) {
|
|
332
|
+
o.push(r);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (o.length === 0) {
|
|
336
|
+
throw new Error(`Given data source file must contain export of a DataSource instance`);
|
|
337
|
+
}
|
|
338
|
+
if (o.length > 1) {
|
|
339
|
+
throw new Error(`Given data source file must contain only one export of DataSource instance`);
|
|
340
|
+
}
|
|
341
|
+
return o[0];
|
|
342
|
+
}
|
|
343
|
+
static async createDirectories(t) {
|
|
344
|
+
await $.default.mkdir(t, {
|
|
345
|
+
recursive: true
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
static async createFile(t, e, o = true) {
|
|
349
|
+
await CommandUtils.createDirectories(U.default.dirname(t));
|
|
350
|
+
if (o === false && await CommandUtils.fileExists(t)) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
await $.default.writeFile(t, e);
|
|
354
|
+
}
|
|
355
|
+
static async readFile(t) {
|
|
356
|
+
const e = await $.default.readFile(t);
|
|
357
|
+
return e.toString();
|
|
358
|
+
}
|
|
359
|
+
static async fileExists(t) {
|
|
360
|
+
try {
|
|
361
|
+
await $.default.access(t, $.default.constants.F_OK);
|
|
362
|
+
return true;
|
|
363
|
+
} catch {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
static getTimestamp(t) {
|
|
368
|
+
if (t && (isNaN(t) || t < 0)) {
|
|
369
|
+
throw new G.TypeORMError(`timestamp option should be a non-negative number. received: ${t}`);
|
|
370
|
+
}
|
|
371
|
+
return t ? new Date(Number(t)).getTime() : Date.now();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
282
374
|
|
|
283
|
-
|
|
375
|
+
q = L.CommandUtils = CommandUtils;
|
|
284
376
|
|
|
285
|
-
|
|
377
|
+
var J = m();
|
|
286
378
|
|
|
287
|
-
|
|
379
|
+
const V = d(J);
|
|
288
380
|
|
|
289
|
-
|
|
381
|
+
const {Ansis: H, ansi256: z, fg: W, bgAnsi256: K, bg: X, rgb: Y, bgRgb: Z, hex: tt, bgHex: et, reset: ot, inverse: it, hidden: rt, visible: nt, bold: st, dim: at, italic: ct, underline: pt, strikethrough: mt, strike: lt, black: ut, red: ht, green: dt, yellow: gt, blue: jt, magenta: ft, cyan: yt, white: bt, grey: vt, gray: xt, blackBright: Et, redBright: wt, greenBright: Ot, yellowBright: Pt, blueBright: Ct, magentaBright: St, cyanBright: kt, whiteBright: It, bgBlack: At, bgRed: Dt, bgGreen: Rt, bgYellow: Nt, bgBlue: Bt, bgMagenta: Mt, bgCyan: Tt, bgWhite: Lt, bgGrey: qt, bgGray: Ft, bgBlackBright: $t, bgRedBright: Ut, bgGreenBright: Gt, bgYellowBright: Qt, bgBlueBright: _t, bgMagentaBright: Jt, bgCyanBright: Vt, bgWhiteBright: Ht} = V;
|
|
290
382
|
|
|
291
|
-
var
|
|
383
|
+
var zt;
|
|
292
384
|
|
|
293
|
-
var
|
|
385
|
+
var Wt;
|
|
294
386
|
|
|
295
387
|
(function(t) {
|
|
296
388
|
t["Launched"] = "LAUNCHED";
|
|
297
389
|
t["Done"] = "DONE";
|
|
298
390
|
t["UncaughtException"] = "UNCAUGHT_EXCEPTION";
|
|
299
391
|
t["FatalException"] = "FATAL_EXCEPTION";
|
|
300
|
-
})(
|
|
392
|
+
})(Wt || (Wt = {}));
|
|
301
393
|
|
|
302
|
-
let
|
|
394
|
+
let Kt = class Application extends b {
|
|
303
395
|
constructor() {
|
|
304
396
|
super(...arguments);
|
|
305
|
-
this.ConfigLoader =
|
|
397
|
+
this.ConfigLoader = w;
|
|
306
398
|
this.options = {
|
|
307
399
|
components: {
|
|
308
400
|
log: {
|
|
309
|
-
class:
|
|
401
|
+
class: k
|
|
310
402
|
},
|
|
311
403
|
entrypoint: {
|
|
312
|
-
class:
|
|
404
|
+
class: S
|
|
313
405
|
}
|
|
314
406
|
},
|
|
315
407
|
bootstrap: [ "log" ]
|
|
316
408
|
};
|
|
317
409
|
}
|
|
318
410
|
static {
|
|
319
|
-
|
|
411
|
+
zt = this;
|
|
320
412
|
}
|
|
321
413
|
static {
|
|
322
|
-
this.eventEmitter = new
|
|
414
|
+
this.eventEmitter = new B;
|
|
323
415
|
}
|
|
324
416
|
static {
|
|
325
417
|
this.environmentVariableMap = new Map;
|
|
@@ -328,7 +420,7 @@ let P = class Application extends o {
|
|
|
328
420
|
this.aliasDeclarations = [];
|
|
329
421
|
}
|
|
330
422
|
static async getLogger() {
|
|
331
|
-
return this.appInstance ? await this.appInstance.getObject("log") : await (new
|
|
423
|
+
return this.appInstance ? await this.appInstance.getObject("log") : await (new E).set(k);
|
|
332
424
|
}
|
|
333
425
|
static env(t) {
|
|
334
426
|
Object.keys(t).forEach((e => this.environmentVariableMap.set(e, t[e])));
|
|
@@ -342,22 +434,22 @@ let P = class Application extends o {
|
|
|
342
434
|
return this.launch();
|
|
343
435
|
}
|
|
344
436
|
static onLaunched(t) {
|
|
345
|
-
this.eventEmitter.once(
|
|
437
|
+
this.eventEmitter.once(Wt.Launched, (async e => t(e, await e.getObject("log"))));
|
|
346
438
|
return this.launch();
|
|
347
439
|
}
|
|
348
440
|
static onDone(t) {
|
|
349
|
-
this.eventEmitter.once(
|
|
441
|
+
this.eventEmitter.once(Wt.Done, (async e => t(e, await e.getObject("log"))));
|
|
350
442
|
return this.launch();
|
|
351
443
|
}
|
|
352
444
|
static onUncaughtException(t) {
|
|
353
|
-
this.eventEmitter.on(
|
|
445
|
+
this.eventEmitter.on(Wt.UncaughtException, (async e => {
|
|
354
446
|
const o = await this.getLogger();
|
|
355
447
|
await t(e, o);
|
|
356
448
|
}));
|
|
357
449
|
return this.launch();
|
|
358
450
|
}
|
|
359
451
|
static onFatalException(t) {
|
|
360
|
-
this.eventEmitter.once(
|
|
452
|
+
this.eventEmitter.once(Wt.FatalException, (async e => {
|
|
361
453
|
const o = await this.getLogger();
|
|
362
454
|
let i = await t(e, o);
|
|
363
455
|
if (typeof i !== "number") i = 1;
|
|
@@ -373,7 +465,7 @@ let P = class Application extends o {
|
|
|
373
465
|
if (this.launchTimeout) clearTimeout(this.launchTimeout);
|
|
374
466
|
this.launchTimeout = setTimeout((async () => {
|
|
375
467
|
process.on("uncaughtException", (async t => {
|
|
376
|
-
if (this.eventEmitter.listenerCount(
|
|
468
|
+
if (this.eventEmitter.listenerCount(Wt.UncaughtException)) return this.eventEmitter.emit(Wt.UncaughtException, t);
|
|
377
469
|
const e = await this.getLogger();
|
|
378
470
|
return e.warn(new Error("UncaughtException", {
|
|
379
471
|
cause: t
|
|
@@ -388,7 +480,7 @@ let P = class Application extends o {
|
|
|
388
480
|
return this;
|
|
389
481
|
}
|
|
390
482
|
static processFatalException(t) {
|
|
391
|
-
if (!this.eventEmitter.listenerCount(
|
|
483
|
+
if (!this.eventEmitter.listenerCount(Wt.FatalException)) {
|
|
392
484
|
return process.nextTick((async () => {
|
|
393
485
|
const e = await this.getLogger();
|
|
394
486
|
e.error(new Error("FatalException", {
|
|
@@ -396,12 +488,12 @@ let P = class Application extends o {
|
|
|
396
488
|
}));
|
|
397
489
|
}));
|
|
398
490
|
}
|
|
399
|
-
this.eventEmitter.emit(
|
|
491
|
+
this.eventEmitter.emit(Wt.FatalException, t);
|
|
400
492
|
}
|
|
401
493
|
static async launchApplication() {
|
|
402
494
|
this.eventEmitter.once("exit", (async (t, e) => {
|
|
403
495
|
try {
|
|
404
|
-
await this.eventEmitter.emitRequest(
|
|
496
|
+
await this.eventEmitter.emitRequest(Wt.Done, t);
|
|
405
497
|
await o.destroy();
|
|
406
498
|
process.exit(e ? e : 0);
|
|
407
499
|
} catch (t) {
|
|
@@ -409,7 +501,7 @@ let P = class Application extends o {
|
|
|
409
501
|
}
|
|
410
502
|
}));
|
|
411
503
|
this.environmentVariableMap.forEach(((t, e) => process.env[e] = t));
|
|
412
|
-
const t =
|
|
504
|
+
const t = P.getAliasInstance();
|
|
413
505
|
t.set("@runtime", process.cwd());
|
|
414
506
|
this.aliasDeclarations.forEach((e => {
|
|
415
507
|
const o = e.alias;
|
|
@@ -417,8 +509,8 @@ let P = class Application extends o {
|
|
|
417
509
|
Object.keys(o).forEach((e => {
|
|
418
510
|
t.set(e, o[e]);
|
|
419
511
|
if (i) {
|
|
420
|
-
const t =
|
|
421
|
-
if (!
|
|
512
|
+
const t = D.resolve(e);
|
|
513
|
+
if (!R(t)) A(D.resolve(e), {
|
|
422
514
|
recursive: true
|
|
423
515
|
});
|
|
424
516
|
}
|
|
@@ -433,7 +525,7 @@ let P = class Application extends o {
|
|
|
433
525
|
const i = t => {
|
|
434
526
|
const e = [];
|
|
435
527
|
for (const o in t) {
|
|
436
|
-
if (t[o] && t[o].class && t[o].class.databaseSymbol && t[o].class.databaseSymbol ===
|
|
528
|
+
if (t[o] && t[o].class && t[o].class.databaseSymbol && t[o].class.databaseSymbol === M) {
|
|
437
529
|
const i = t[o].options;
|
|
438
530
|
if (!i) continue;
|
|
439
531
|
Reflect.set(i, "dataSourceName", o);
|
|
@@ -442,54 +534,54 @@ let P = class Application extends o {
|
|
|
442
534
|
}
|
|
443
535
|
return e;
|
|
444
536
|
};
|
|
445
|
-
const
|
|
446
|
-
if (!
|
|
537
|
+
const r = [ ...e.components ? i(e.components) : [], ...e.providers ? i(e.providers) : [] ];
|
|
538
|
+
if (!r.length) process.exit(0);
|
|
447
539
|
e.bootstrap = [];
|
|
448
|
-
|
|
449
|
-
const
|
|
540
|
+
r.forEach(((t, i) => {
|
|
541
|
+
const n = `GenerateMigration${i}${Date.now()}`;
|
|
450
542
|
if (!e.providers) e.providers = {};
|
|
451
|
-
e.providers[
|
|
452
|
-
class:
|
|
543
|
+
e.providers[n] = {
|
|
544
|
+
class: Yt,
|
|
453
545
|
path: o,
|
|
454
546
|
outputJs: false,
|
|
455
|
-
exitProcess: i ===
|
|
547
|
+
exitProcess: i === r.length - 1,
|
|
456
548
|
dataSourceName: Reflect.get(t, "dataSourceName"),
|
|
457
549
|
dataSource: t
|
|
458
550
|
};
|
|
459
|
-
e.bootstrap.push(
|
|
551
|
+
e.bootstrap.push(n);
|
|
460
552
|
}));
|
|
461
553
|
}
|
|
462
554
|
break;
|
|
463
555
|
}
|
|
464
556
|
}
|
|
465
|
-
const o = new
|
|
466
|
-
return new Promise(((t,
|
|
467
|
-
|
|
557
|
+
const o = new E;
|
|
558
|
+
return new Promise(((t, i) => {
|
|
559
|
+
O.validateAsync(e).then((e => {
|
|
468
560
|
e.bootstrap?.push((async t => {
|
|
469
561
|
const e = function() {
|
|
470
562
|
this.options.bootstrap?.pop();
|
|
471
|
-
|
|
563
|
+
N(Reflect.getOwnMetadata("#bootstrap", this))?.pop();
|
|
472
564
|
};
|
|
473
|
-
e.bind(
|
|
474
|
-
this.eventEmitter.emit(
|
|
565
|
+
e.bind(N(t))();
|
|
566
|
+
this.eventEmitter.emit(Wt.Launched, N(t));
|
|
475
567
|
}));
|
|
476
|
-
o.set(
|
|
568
|
+
o.set(zt, {
|
|
477
569
|
options: e
|
|
478
|
-
}).then((e => e.once(
|
|
479
|
-
})).catch(
|
|
570
|
+
}).then((e => e.once(v, (() => t(e))).once(x, (t => this.processFatalException(t))))).catch(i);
|
|
571
|
+
})).catch(i);
|
|
480
572
|
}));
|
|
481
573
|
}
|
|
482
574
|
get alias() {
|
|
483
|
-
return
|
|
575
|
+
return P.getAliasInstance();
|
|
484
576
|
}
|
|
485
577
|
get appId() {
|
|
486
|
-
return
|
|
578
|
+
return C().appId;
|
|
487
579
|
}
|
|
488
580
|
get appName() {
|
|
489
|
-
return
|
|
581
|
+
return C().appName;
|
|
490
582
|
}
|
|
491
583
|
get timezone() {
|
|
492
|
-
return
|
|
584
|
+
return C().timezone;
|
|
493
585
|
}
|
|
494
586
|
get uptime() {
|
|
495
587
|
return Math.floor(process.uptime());
|
|
@@ -498,15 +590,154 @@ let P = class Application extends o {
|
|
|
498
590
|
if (typeof t === "boolean" && t) {
|
|
499
591
|
return process.exit(2);
|
|
500
592
|
} else {
|
|
501
|
-
|
|
593
|
+
zt.eventEmitter.emit("exit", this, t ? t : 0);
|
|
502
594
|
}
|
|
503
595
|
}
|
|
504
596
|
};
|
|
505
597
|
|
|
506
|
-
t([
|
|
598
|
+
t([ I(r.Object().pattern(r.String(), r.String()).required()), e("design:type", Function), e("design:paramtypes", [ Object ]), e("design:returntype", Object) ], Kt, "env", null);
|
|
599
|
+
|
|
600
|
+
t([ I(r.Object().pattern(r.String(), r.String()).required(), r.Boolean().optional().default(false)), e("design:type", Function), e("design:paramtypes", [ Object, Boolean ]), e("design:returntype", Object) ], Kt, "alias", null);
|
|
601
|
+
|
|
602
|
+
Kt = zt = t([ f(true) ], Kt);
|
|
603
|
+
|
|
604
|
+
var Xt;
|
|
605
|
+
|
|
606
|
+
let Yt = Xt = class GenerateMigration extends o {
|
|
607
|
+
get extension() {
|
|
608
|
+
return this.outputJs ? ".js" : ".ts";
|
|
609
|
+
}
|
|
610
|
+
get filename() {
|
|
611
|
+
return this.timestamp + "-" + (this.dataSourceName ? this.dataSourceName : n.basename(this.path)) + this.extension;
|
|
612
|
+
}
|
|
613
|
+
#t;
|
|
614
|
+
async init() {
|
|
615
|
+
this.#t = new s.DataSource(this.dataSource);
|
|
616
|
+
this.#t.setOptions({
|
|
617
|
+
synchronize: false,
|
|
618
|
+
migrationsRun: false,
|
|
619
|
+
dropSchema: false,
|
|
620
|
+
logging: false
|
|
621
|
+
});
|
|
622
|
+
this.#t = await this.#t.initialize();
|
|
623
|
+
await this.handle();
|
|
624
|
+
}
|
|
625
|
+
async destroy() {
|
|
626
|
+
await (this.#t?.destroy());
|
|
627
|
+
}
|
|
628
|
+
async handle() {
|
|
629
|
+
try {
|
|
630
|
+
const t = [], e = [];
|
|
631
|
+
try {
|
|
632
|
+
const o = await this.#t.driver.createSchemaBuilder().log();
|
|
633
|
+
if (this.pretty) {
|
|
634
|
+
o.upQueries.forEach((t => {
|
|
635
|
+
t.query = Xt.prettifyQuery(t.query);
|
|
636
|
+
}));
|
|
637
|
+
o.downQueries.forEach((t => {
|
|
638
|
+
t.query = Xt.prettifyQuery(t.query);
|
|
639
|
+
}));
|
|
640
|
+
}
|
|
641
|
+
o.upQueries.forEach((e => {
|
|
642
|
+
t.push(" await queryRunner.query(`" + e.query.replaceAll("`", "\\`") + "`" + Xt.queryParams(e.parameters) + ");");
|
|
643
|
+
}));
|
|
644
|
+
o.downQueries.forEach((t => {
|
|
645
|
+
e.push(" await queryRunner.query(`" + t.query.replaceAll("`", "\\`") + "`" + Xt.queryParams(t.parameters) + ");");
|
|
646
|
+
}));
|
|
647
|
+
} finally {
|
|
648
|
+
await this.#t.destroy();
|
|
649
|
+
}
|
|
650
|
+
if (!t.length) {
|
|
651
|
+
if (this.check) {
|
|
652
|
+
console.log(V.green`No changes in database schema were found`);
|
|
653
|
+
if (this.exitProcess) {
|
|
654
|
+
this.app.exit(0);
|
|
655
|
+
} else {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
} else {
|
|
659
|
+
console.log(V.yellow`No changes in database schema were found`);
|
|
660
|
+
if (this.exitProcess) {
|
|
661
|
+
this.app.exit(1);
|
|
662
|
+
} else {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
} else if (!this.path) {
|
|
667
|
+
console.log(V.yellow`Please specify a migration path`);
|
|
668
|
+
this.app.exit(1);
|
|
669
|
+
}
|
|
670
|
+
const o = this.outputJs ? Xt.getJavascriptTemplate(n.basename(this.path), this.timestamp, t, e.reverse(), this.esm) : Xt.getTemplate(n.basename(this.path), this.timestamp, t, e.reverse());
|
|
671
|
+
if (this.check) {
|
|
672
|
+
console.log(V.yellow`Unexpected changes in database schema were found in check mode:\n\n${V.white(o)}`);
|
|
673
|
+
if (this.exitProcess) {
|
|
674
|
+
this.app.exit(0);
|
|
675
|
+
} else {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
if (this.dryRun) {
|
|
680
|
+
console.log(V.green(`Migration ${V.blue(this.path + this.extension)} has content:\n\n${V.white(o)}`));
|
|
681
|
+
} else {
|
|
682
|
+
const t = n.isAbsolute(this.path) ? n.join(this.path, this.filename) : n.join(process.cwd(), this.path, this.filename);
|
|
683
|
+
await q.createFile(t, o);
|
|
684
|
+
console.log(V.green`Migration ${V.blue(t)} has been generated successfully.`);
|
|
685
|
+
if (this.exitProcess) {
|
|
686
|
+
this.app.exit(0);
|
|
687
|
+
} else {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
} catch (t) {
|
|
692
|
+
l.PlatformTools.logCmdErr("Error during migration generation:", t);
|
|
693
|
+
this.app.exit(1);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
static queryParams(t) {
|
|
697
|
+
if (!t || !t.length) {
|
|
698
|
+
return "";
|
|
699
|
+
}
|
|
700
|
+
return `, ${JSON.stringify(t)}`;
|
|
701
|
+
}
|
|
702
|
+
static getTemplate(t, e, o, i) {
|
|
703
|
+
const r = `${u(t, true)}${e}`;
|
|
704
|
+
return `import { MigrationInterface, QueryRunner } from "lakutata/orm";\n\nexport class ${r} implements MigrationInterface {\n name = '${r}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${o.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${i.join(`\n`)}\n }\n\n}\n`;
|
|
705
|
+
}
|
|
706
|
+
static getJavascriptTemplate(t, e, o, i, r) {
|
|
707
|
+
const n = `${u(t, true)}${e}`;
|
|
708
|
+
const s = r ? "export" : "module.exports =";
|
|
709
|
+
return `/**\n * @typedef {import('lakutata/orm').MigrationInterface} MigrationInterface\n * @typedef {import('lakutata/orm').QueryRunner} QueryRunner\n */\n\n/**\n * @class\n * @implements {MigrationInterface}\n */\n${s} class ${n} {\n name = '${n}'\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async up(queryRunner) {\n${o.join(`\n`)}\n }\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async down(queryRunner) {\n${i.join(`\n`)}\n }\n}\n`;
|
|
710
|
+
}
|
|
711
|
+
static prettifyQuery(t) {
|
|
712
|
+
const e = h.format(t, {
|
|
713
|
+
indent: " "
|
|
714
|
+
});
|
|
715
|
+
return "\n" + e.replace(/^/gm, " ") + "\n ";
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
t([ T(Kt), e("design:type", Kt) ], Yt.prototype, "app", void 0);
|
|
720
|
+
|
|
721
|
+
t([ i(r.String().required()), e("design:type", String) ], Yt.prototype, "path", void 0);
|
|
722
|
+
|
|
723
|
+
t([ i(r.String().allow("").optional().default("")), e("design:type", String) ], Yt.prototype, "dataSourceName", void 0);
|
|
724
|
+
|
|
725
|
+
t([ i(), e("design:type", Object) ], Yt.prototype, "dataSource", void 0);
|
|
726
|
+
|
|
727
|
+
t([ i(r.Boolean().optional().default(true)), e("design:type", Boolean) ], Yt.prototype, "pretty", void 0);
|
|
728
|
+
|
|
729
|
+
t([ i(r.Boolean().optional().default(false)), e("design:type", Boolean) ], Yt.prototype, "outputJs", void 0);
|
|
730
|
+
|
|
731
|
+
t([ i(r.Boolean().optional().default(false)), e("design:type", Boolean) ], Yt.prototype, "esm", void 0);
|
|
732
|
+
|
|
733
|
+
t([ i(r.Boolean().optional().default(false)), e("design:type", Boolean) ], Yt.prototype, "dryRun", void 0);
|
|
734
|
+
|
|
735
|
+
t([ i(r.Boolean().optional().default(false)), e("design:type", Boolean) ], Yt.prototype, "check", void 0);
|
|
736
|
+
|
|
737
|
+
t([ i(r.Number().optional().default((() => Date.now()))), e("design:type", Number) ], Yt.prototype, "timestamp", void 0);
|
|
507
738
|
|
|
508
|
-
t([
|
|
739
|
+
t([ i(r.Boolean().optional().default(true)), e("design:type", Boolean) ], Yt.prototype, "exitProcess", void 0);
|
|
509
740
|
|
|
510
|
-
|
|
741
|
+
Yt = Xt = t([ y() ], Yt);
|
|
511
742
|
|
|
512
|
-
export {
|
|
743
|
+
export { Kt as Application, Wt as ApplicationState, Yt as G };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as t, m as a, a as s, s as r, q as e, p as i, b as n, c, d as u, f as o, h as m, g as l, r as p, i as d, v as b, j as g, k as v, l as h, n as S, o as k, t as M, z as R, u as f, w as q, x as D, y as P, A as T, B as x, C as A, D as w, E as L, F as V, G as j, H as y, I as F, J as O, K as z, L as C, M as E, N, O as W, P as B, Q as G, R as H, S as I, T as J, U as K, V as Q, W as U, X, Y, Z, _ as $, $ as _, a0 as tt } from "../../../vendor/Package.
|
|
1
|
+
import { e as t, m as a, a as s, s as r, q as e, p as i, b as n, c, d as u, f as o, h as m, g as l, r as p, i as d, v as b, j as g, k as v, l as h, n as S, o as k, t as M, z as R, u as f, w as q, x as D, y as P, A as T, B as x, C as A, D as w, E as L, F as V, G as j, H as y, I as F, J as O, K as z, L as C, M as E, N, O as W, P as B, Q as G, R as H, S as I, T as J, U as K, V as Q, W as U, X, Y, Z, _ as $, $ as _, a0 as tt } from "../../../vendor/Package.16.mjs";
|
|
2
2
|
|
|
3
3
|
class Statistics {
|
|
4
4
|
static {
|
package/src/lib/helpers/UUID.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as t, M as s, p as a, s as r,
|
|
1
|
+
import { N as t, M as s, p as a, s as r, a as i, b as e, c, v as n, d as u, e as v, f as o } from "../../../vendor/Package.64.mjs";
|
|
2
2
|
|
|
3
3
|
class UUID {
|
|
4
4
|
static {
|