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
|
@@ -10,7 +10,7 @@ import { GetObjectNestingDepth as r } from "../../helpers/GetObjectNestingDepth.
|
|
|
10
10
|
|
|
11
11
|
import { InvalidActionPatternDepthException as c } from "../../../exceptions/InvalidActionPatternDepthException.mjs";
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { v as a, N as s } from "../../../../vendor/Package.64.mjs";
|
|
14
14
|
|
|
15
15
|
import { StringifyPattern as i } from "./StringifyPattern.mjs";
|
|
16
16
|
|
|
@@ -6,45 +6,59 @@ Object.defineProperty(exports, Symbol.toStringTag, {
|
|
|
6
6
|
|
|
7
7
|
const e = require("../../../vendor/Package.1.cjs");
|
|
8
8
|
|
|
9
|
-
const t = require("./
|
|
9
|
+
const t = require("./Provider.cjs");
|
|
10
10
|
|
|
11
|
-
const r = require("../../decorators/di/
|
|
11
|
+
const r = require("../../decorators/di/Configurable.cjs");
|
|
12
12
|
|
|
13
|
-
const i = require("../../../vendor/Package.
|
|
13
|
+
const i = require("../../../vendor/Package.2.cjs");
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const n = require("path");
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const a = require("../../../vendor/Package.10.cjs");
|
|
18
18
|
|
|
19
|
-
const o = require("
|
|
19
|
+
const o = require("../../../vendor/Package.102.cjs");
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const s = require("../../../vendor/Package.5.cjs");
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const c = require("../../../vendor/Package.12.cjs");
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
require("../../../vendor/Package.8.cjs");
|
|
26
26
|
|
|
27
|
-
const u = require("
|
|
27
|
+
const u = require("fs/promises");
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const p = require("../../decorators/di/Lifetime.cjs");
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const l = require("./Module.cjs");
|
|
32
32
|
|
|
33
|
-
const d = require("
|
|
33
|
+
const d = require("../../../vendor/Package.3.cjs");
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const h = require("../base/internal/ApplicationConfigLoader.cjs");
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const g = require("../../options/ApplicationOptions.cjs");
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const m = require("./Alias.cjs");
|
|
40
40
|
|
|
41
|
-
const
|
|
41
|
+
const q = require("../base/internal/BasicInfo.cjs");
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const y = require("../../components/entrypoint/Entrypoint.cjs");
|
|
44
44
|
|
|
45
|
-
require("
|
|
45
|
+
const j = require("../../../vendor/Package.14.cjs");
|
|
46
|
+
|
|
47
|
+
const f = require("../../decorators/dto/Accept.cjs");
|
|
48
|
+
|
|
49
|
+
const b = require("fs");
|
|
50
|
+
|
|
51
|
+
const x = require("node:path");
|
|
52
|
+
|
|
53
|
+
const v = require("node:fs");
|
|
54
|
+
|
|
55
|
+
const E = require("../helpers/As.cjs");
|
|
56
|
+
|
|
57
|
+
const _ = require("../base/EventEmitter.cjs");
|
|
58
|
+
|
|
59
|
+
const w = require("../base/internal/DatabaseSymbol.cjs");
|
|
46
60
|
|
|
47
|
-
require("
|
|
61
|
+
const O = require("../../decorators/di/Inject.cjs");
|
|
48
62
|
|
|
49
63
|
require("../base/async-constructor/AsyncConstructor.cjs");
|
|
50
64
|
|
|
@@ -68,8 +82,6 @@ require("../helpers/NoCase.cjs");
|
|
|
68
82
|
|
|
69
83
|
require("../../../vendor/Package.6.cjs");
|
|
70
84
|
|
|
71
|
-
require("../../../vendor/Package.5.cjs");
|
|
72
|
-
|
|
73
85
|
require("../../../vendor/Package.7.cjs");
|
|
74
86
|
|
|
75
87
|
require("../base/internal/ThrowWarning.cjs");
|
|
@@ -122,12 +134,8 @@ require("../ioc/Lifetime.cjs");
|
|
|
122
134
|
|
|
123
135
|
require("../ioc/ListModules.cjs");
|
|
124
136
|
|
|
125
|
-
require("../../../vendor/Package.8.cjs");
|
|
126
|
-
|
|
127
137
|
require("os");
|
|
128
138
|
|
|
129
|
-
require("path");
|
|
130
|
-
|
|
131
139
|
require("stream");
|
|
132
140
|
|
|
133
141
|
require("events");
|
|
@@ -170,6 +178,36 @@ require("../../exceptions/dto/InvalidMethodReturnException.cjs");
|
|
|
170
178
|
|
|
171
179
|
require("../helpers/IsEmptyObject.cjs");
|
|
172
180
|
|
|
181
|
+
require("../../../vendor/Package.62.cjs");
|
|
182
|
+
|
|
183
|
+
require("../../../vendor/Package.11.cjs");
|
|
184
|
+
|
|
185
|
+
require("../../../vendor/Package.122.cjs");
|
|
186
|
+
|
|
187
|
+
require("buffer");
|
|
188
|
+
|
|
189
|
+
require("module");
|
|
190
|
+
|
|
191
|
+
require("tty");
|
|
192
|
+
|
|
193
|
+
require("../../../vendor/Package.13.cjs");
|
|
194
|
+
|
|
195
|
+
require("crypto");
|
|
196
|
+
|
|
197
|
+
require("../../../vendor/Package.63.cjs");
|
|
198
|
+
|
|
199
|
+
require("node:url");
|
|
200
|
+
|
|
201
|
+
require("node:fs/promises");
|
|
202
|
+
|
|
203
|
+
require("node:events");
|
|
204
|
+
|
|
205
|
+
require("node:stream");
|
|
206
|
+
|
|
207
|
+
require("node:string_decoder");
|
|
208
|
+
|
|
209
|
+
require("./Component.cjs");
|
|
210
|
+
|
|
173
211
|
require("../../options/ModuleOptions.cjs");
|
|
174
212
|
|
|
175
213
|
require("../../options/ModuleLoadObjectsOptions.cjs");
|
|
@@ -192,16 +230,10 @@ require("../helpers/ArrayToSet.cjs");
|
|
|
192
230
|
|
|
193
231
|
require("../helpers/SetToArray.cjs");
|
|
194
232
|
|
|
195
|
-
require("../../decorators/di/Configurable.cjs");
|
|
196
|
-
|
|
197
233
|
require("../helpers/NonceStr.cjs");
|
|
198
234
|
|
|
199
235
|
require("../helpers/RandomString.cjs");
|
|
200
236
|
|
|
201
|
-
require("../../../vendor/Package.13.cjs");
|
|
202
|
-
|
|
203
|
-
require("crypto");
|
|
204
|
-
|
|
205
237
|
require("../../exceptions/alias/InvalidAliasNameException.cjs");
|
|
206
238
|
|
|
207
239
|
require("../../exceptions/alias/AliasExistsException.cjs");
|
|
@@ -256,51 +288,115 @@ require("../../components/entrypoint/exceptions/InvalidActionGroupException.cjs"
|
|
|
256
288
|
|
|
257
289
|
require("worker_threads");
|
|
258
290
|
|
|
259
|
-
require("../../../vendor/Package.
|
|
291
|
+
require("../../../vendor/Package.15.cjs");
|
|
260
292
|
|
|
261
|
-
require("
|
|
293
|
+
require("assert");
|
|
262
294
|
|
|
263
|
-
require("
|
|
295
|
+
require("string_decoder");
|
|
264
296
|
|
|
265
|
-
|
|
297
|
+
const A = e => e && e.__esModule ? e : {
|
|
298
|
+
default: e
|
|
299
|
+
};
|
|
266
300
|
|
|
267
|
-
|
|
301
|
+
const S = A(n);
|
|
268
302
|
|
|
269
|
-
|
|
303
|
+
const C = A(u);
|
|
270
304
|
|
|
271
|
-
|
|
305
|
+
const D = A(x);
|
|
272
306
|
|
|
273
|
-
|
|
307
|
+
var I = {};
|
|
274
308
|
|
|
275
|
-
|
|
309
|
+
"use strict";
|
|
276
310
|
|
|
277
|
-
|
|
311
|
+
Object.defineProperty(I, "__esModule", {
|
|
312
|
+
value: true
|
|
313
|
+
});
|
|
278
314
|
|
|
279
|
-
|
|
315
|
+
var M = I.CommandUtils = void 0;
|
|
280
316
|
|
|
281
|
-
require
|
|
317
|
+
const P = c.require$$0;
|
|
282
318
|
|
|
283
|
-
|
|
319
|
+
const T = P.__importDefault(C.default);
|
|
284
320
|
|
|
285
|
-
|
|
321
|
+
const k = P.__importDefault(S.default);
|
|
286
322
|
|
|
287
|
-
|
|
323
|
+
const R = o.error;
|
|
288
324
|
|
|
289
|
-
|
|
325
|
+
const B = o.InstanceChecker;
|
|
290
326
|
|
|
291
|
-
|
|
327
|
+
const N = o.requireImportUtils();
|
|
292
328
|
|
|
293
|
-
|
|
329
|
+
class CommandUtils {
|
|
330
|
+
static async loadDataSource(e) {
|
|
331
|
+
let t;
|
|
332
|
+
try {
|
|
333
|
+
[t] = await (0, N.importOrRequireFile)(e);
|
|
334
|
+
} catch (t) {
|
|
335
|
+
throw new Error(`Unable to open file: "${e}". ${t.message}`);
|
|
336
|
+
}
|
|
337
|
+
if (!t || typeof t !== "object") {
|
|
338
|
+
throw new Error(`Given data source file must contain export of a DataSource instance`);
|
|
339
|
+
}
|
|
340
|
+
if (B.InstanceChecker.isDataSource(t)) {
|
|
341
|
+
return t;
|
|
342
|
+
}
|
|
343
|
+
const r = [];
|
|
344
|
+
for (const e in t) {
|
|
345
|
+
const i = t[e];
|
|
346
|
+
const n = await i;
|
|
347
|
+
if (B.InstanceChecker.isDataSource(n)) {
|
|
348
|
+
r.push(n);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (r.length === 0) {
|
|
352
|
+
throw new Error(`Given data source file must contain export of a DataSource instance`);
|
|
353
|
+
}
|
|
354
|
+
if (r.length > 1) {
|
|
355
|
+
throw new Error(`Given data source file must contain only one export of DataSource instance`);
|
|
356
|
+
}
|
|
357
|
+
return r[0];
|
|
358
|
+
}
|
|
359
|
+
static async createDirectories(e) {
|
|
360
|
+
await T.default.mkdir(e, {
|
|
361
|
+
recursive: true
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
static async createFile(e, t, r = true) {
|
|
365
|
+
await CommandUtils.createDirectories(k.default.dirname(e));
|
|
366
|
+
if (r === false && await CommandUtils.fileExists(e)) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
await T.default.writeFile(e, t);
|
|
370
|
+
}
|
|
371
|
+
static async readFile(e) {
|
|
372
|
+
const t = await T.default.readFile(e);
|
|
373
|
+
return t.toString();
|
|
374
|
+
}
|
|
375
|
+
static async fileExists(e) {
|
|
376
|
+
try {
|
|
377
|
+
await T.default.access(e, T.default.constants.F_OK);
|
|
378
|
+
return true;
|
|
379
|
+
} catch {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
static getTimestamp(e) {
|
|
384
|
+
if (e && (isNaN(e) || e < 0)) {
|
|
385
|
+
throw new R.TypeORMError(`timestamp option should be a non-negative number. received: ${e}`);
|
|
386
|
+
}
|
|
387
|
+
return e ? new Date(Number(e)).getTime() : Date.now();
|
|
388
|
+
}
|
|
389
|
+
}
|
|
294
390
|
|
|
295
|
-
|
|
391
|
+
M = I.CommandUtils = CommandUtils;
|
|
296
392
|
|
|
297
|
-
|
|
298
|
-
default: e
|
|
299
|
-
};
|
|
393
|
+
var L = o.requireAnsis();
|
|
300
394
|
|
|
301
|
-
const
|
|
395
|
+
const G = s.getDefaultExportFromCjs(L);
|
|
302
396
|
|
|
303
|
-
|
|
397
|
+
const {Ansis: F, ansi256: $, fg: U, bgAnsi256: Q, bg: J, rgb: V, bgRgb: H, hex: z, bgHex: W, reset: K, inverse: X, hidden: Y, visible: Z, bold: ee, dim: te, italic: re, underline: ie, strikethrough: ne, strike: ae, black: oe, red: se, green: ce, yellow: ue, blue: pe, magenta: le, cyan: de, white: he, grey: ge, gray: me, blackBright: qe, redBright: ye, greenBright: je, yellowBright: fe, blueBright: be, magentaBright: xe, cyanBright: ve, whiteBright: Ee, bgBlack: _e, bgRed: we, bgGreen: Oe, bgYellow: Ae, bgBlue: Se, bgMagenta: Ce, bgCyan: De, bgWhite: Ie, bgGrey: Me, bgGray: Pe, bgBlackBright: Te, bgRedBright: ke, bgGreenBright: Re, bgYellowBright: Be, bgBlueBright: Ne, bgMagentaBright: Le, bgCyanBright: Ge, bgWhiteBright: Fe} = G;
|
|
398
|
+
|
|
399
|
+
var $e;
|
|
304
400
|
|
|
305
401
|
exports.ApplicationState = void 0;
|
|
306
402
|
|
|
@@ -311,27 +407,27 @@ exports.ApplicationState = void 0;
|
|
|
311
407
|
e["FatalException"] = "FATAL_EXCEPTION";
|
|
312
408
|
})(exports.ApplicationState || (exports.ApplicationState = {}));
|
|
313
409
|
|
|
314
|
-
exports.Application = class Application extends
|
|
410
|
+
exports.Application = class Application extends l.Module {
|
|
315
411
|
constructor() {
|
|
316
412
|
super(...arguments);
|
|
317
|
-
this.ConfigLoader =
|
|
413
|
+
this.ConfigLoader = h.ApplicationConfigLoader;
|
|
318
414
|
this.options = {
|
|
319
415
|
components: {
|
|
320
416
|
log: {
|
|
321
|
-
class:
|
|
417
|
+
class: j.Logger
|
|
322
418
|
},
|
|
323
419
|
entrypoint: {
|
|
324
|
-
class:
|
|
420
|
+
class: y.Entrypoint
|
|
325
421
|
}
|
|
326
422
|
},
|
|
327
423
|
bootstrap: [ "log" ]
|
|
328
424
|
};
|
|
329
425
|
}
|
|
330
426
|
static {
|
|
331
|
-
|
|
427
|
+
$e = this;
|
|
332
428
|
}
|
|
333
429
|
static {
|
|
334
|
-
this.eventEmitter = new
|
|
430
|
+
this.eventEmitter = new _.EventEmitter;
|
|
335
431
|
}
|
|
336
432
|
static {
|
|
337
433
|
this.environmentVariableMap = new Map;
|
|
@@ -340,7 +436,7 @@ exports.Application = class Application extends t.Module {
|
|
|
340
436
|
this.aliasDeclarations = [];
|
|
341
437
|
}
|
|
342
438
|
static async getLogger() {
|
|
343
|
-
return this.appInstance ? await this.appInstance.getObject("log") : await (new
|
|
439
|
+
return this.appInstance ? await this.appInstance.getObject("log") : await (new d.Container).set(j.Logger);
|
|
344
440
|
}
|
|
345
441
|
static env(e) {
|
|
346
442
|
Object.keys(e).forEach((t => this.environmentVariableMap.set(t, e[t])));
|
|
@@ -414,14 +510,14 @@ exports.Application = class Application extends t.Module {
|
|
|
414
510
|
this.eventEmitter.once("exit", (async (e, t) => {
|
|
415
511
|
try {
|
|
416
512
|
await this.eventEmitter.emitRequest(exports.ApplicationState.Done, e);
|
|
417
|
-
await
|
|
513
|
+
await r.destroy();
|
|
418
514
|
process.exit(t ? t : 0);
|
|
419
515
|
} catch (e) {
|
|
420
516
|
process.exit(1);
|
|
421
517
|
}
|
|
422
518
|
}));
|
|
423
519
|
this.environmentVariableMap.forEach(((e, t) => process.env[t] = e));
|
|
424
|
-
const e =
|
|
520
|
+
const e = m.Alias.getAliasInstance();
|
|
425
521
|
e.set("@runtime", process.cwd());
|
|
426
522
|
this.aliasDeclarations.forEach((t => {
|
|
427
523
|
const r = t.alias;
|
|
@@ -429,23 +525,23 @@ exports.Application = class Application extends t.Module {
|
|
|
429
525
|
Object.keys(r).forEach((t => {
|
|
430
526
|
e.set(t, r[t]);
|
|
431
527
|
if (i) {
|
|
432
|
-
const e =
|
|
433
|
-
if (!
|
|
528
|
+
const e = D.default.resolve(t);
|
|
529
|
+
if (!v.existsSync(e)) b.mkdirSync(D.default.resolve(t), {
|
|
434
530
|
recursive: true
|
|
435
531
|
});
|
|
436
532
|
}
|
|
437
533
|
}));
|
|
438
534
|
}));
|
|
439
|
-
const
|
|
535
|
+
const t = typeof this.launchOptions === "object" ? this.launchOptions : await this.launchOptions();
|
|
440
536
|
for (const e in process.env) {
|
|
441
537
|
switch (e.toUpperCase()) {
|
|
442
538
|
case "MIGRATION_GENERATE":
|
|
443
539
|
{
|
|
444
|
-
const
|
|
540
|
+
const r = process.env[e];
|
|
445
541
|
const i = e => {
|
|
446
542
|
const t = [];
|
|
447
543
|
for (const r in e) {
|
|
448
|
-
if (e[r] && e[r].class && e[r].class.databaseSymbol && e[r].class.databaseSymbol ===
|
|
544
|
+
if (e[r] && e[r].class && e[r].class.databaseSymbol && e[r].class.databaseSymbol === w.DatabaseSymbol) {
|
|
449
545
|
const i = e[r].options;
|
|
450
546
|
if (!i) continue;
|
|
451
547
|
Reflect.set(i, "dataSourceName", r);
|
|
@@ -454,54 +550,54 @@ exports.Application = class Application extends t.Module {
|
|
|
454
550
|
}
|
|
455
551
|
return t;
|
|
456
552
|
};
|
|
457
|
-
const
|
|
458
|
-
if (!
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
if (!
|
|
463
|
-
|
|
464
|
-
class:
|
|
465
|
-
path:
|
|
553
|
+
const n = [ ...t.components ? i(t.components) : [], ...t.providers ? i(t.providers) : [] ];
|
|
554
|
+
if (!n.length) process.exit(0);
|
|
555
|
+
t.bootstrap = [];
|
|
556
|
+
n.forEach(((e, i) => {
|
|
557
|
+
const a = `GenerateMigration${i}${Date.now()}`;
|
|
558
|
+
if (!t.providers) t.providers = {};
|
|
559
|
+
t.providers[a] = {
|
|
560
|
+
class: exports.GenerateMigration,
|
|
561
|
+
path: r,
|
|
466
562
|
outputJs: false,
|
|
467
|
-
exitProcess: i ===
|
|
563
|
+
exitProcess: i === n.length - 1,
|
|
468
564
|
dataSourceName: Reflect.get(e, "dataSourceName"),
|
|
469
565
|
dataSource: e
|
|
470
566
|
};
|
|
471
|
-
|
|
567
|
+
t.bootstrap.push(a);
|
|
472
568
|
}));
|
|
473
569
|
}
|
|
474
570
|
break;
|
|
475
571
|
}
|
|
476
572
|
}
|
|
477
|
-
const
|
|
573
|
+
const r = new d.Container;
|
|
478
574
|
return new Promise(((e, i) => {
|
|
479
|
-
|
|
480
|
-
|
|
575
|
+
g.ApplicationOptions.validateAsync(t).then((t => {
|
|
576
|
+
t.bootstrap?.push((async e => {
|
|
481
577
|
const t = function() {
|
|
482
578
|
this.options.bootstrap?.pop();
|
|
483
|
-
|
|
579
|
+
E.As(Reflect.getOwnMetadata("#bootstrap", this))?.pop();
|
|
484
580
|
};
|
|
485
|
-
t.bind(
|
|
486
|
-
this.eventEmitter.emit(exports.ApplicationState.Launched,
|
|
581
|
+
t.bind(E.As(e))();
|
|
582
|
+
this.eventEmitter.emit(exports.ApplicationState.Launched, E.As(e));
|
|
487
583
|
}));
|
|
488
|
-
|
|
489
|
-
options:
|
|
490
|
-
}).then((
|
|
584
|
+
r.set($e, {
|
|
585
|
+
options: t
|
|
586
|
+
}).then((t => t.once(l.MODULE_INITIALIZED, (() => e(t))).once(l.MODULE_INITIALIZE_ERROR, (e => this.processFatalException(e))))).catch(i);
|
|
491
587
|
})).catch(i);
|
|
492
588
|
}));
|
|
493
589
|
}
|
|
494
590
|
get alias() {
|
|
495
|
-
return
|
|
591
|
+
return m.Alias.getAliasInstance();
|
|
496
592
|
}
|
|
497
593
|
get appId() {
|
|
498
|
-
return
|
|
594
|
+
return q.GetBasicInfo().appId;
|
|
499
595
|
}
|
|
500
596
|
get appName() {
|
|
501
|
-
return
|
|
597
|
+
return q.GetBasicInfo().appName;
|
|
502
598
|
}
|
|
503
599
|
get timezone() {
|
|
504
|
-
return
|
|
600
|
+
return q.GetBasicInfo().timezone;
|
|
505
601
|
}
|
|
506
602
|
get uptime() {
|
|
507
603
|
return Math.floor(process.uptime());
|
|
@@ -510,13 +606,152 @@ exports.Application = class Application extends t.Module {
|
|
|
510
606
|
if (typeof e === "boolean" && e) {
|
|
511
607
|
return process.exit(2);
|
|
512
608
|
} else {
|
|
513
|
-
|
|
609
|
+
$e.eventEmitter.emit("exit", this, e ? e : 0);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
e.__decorate([ f.Accept(i.DTO.Object().pattern(i.DTO.String(), i.DTO.String()).required()), e.__metadata("design:type", Function), e.__metadata("design:paramtypes", [ Object ]), e.__metadata("design:returntype", Object) ], exports.Application, "env", null);
|
|
615
|
+
|
|
616
|
+
e.__decorate([ f.Accept(i.DTO.Object().pattern(i.DTO.String(), i.DTO.String()).required(), i.DTO.Boolean().optional().default(false)), e.__metadata("design:type", Function), e.__metadata("design:paramtypes", [ Object, Boolean ]), e.__metadata("design:returntype", Object) ], exports.Application, "alias", null);
|
|
617
|
+
|
|
618
|
+
exports.Application = $e = e.__decorate([ p.Singleton(true) ], exports.Application);
|
|
619
|
+
|
|
620
|
+
var Ue;
|
|
621
|
+
|
|
622
|
+
exports.GenerateMigration = Ue = class GenerateMigration extends t.Provider {
|
|
623
|
+
get extension() {
|
|
624
|
+
return this.outputJs ? ".js" : ".ts";
|
|
625
|
+
}
|
|
626
|
+
get filename() {
|
|
627
|
+
return this.timestamp + "-" + (this.dataSourceName ? this.dataSourceName : S.default.basename(this.path)) + this.extension;
|
|
628
|
+
}
|
|
629
|
+
#e;
|
|
630
|
+
async init() {
|
|
631
|
+
this.#e = new a.DataSourceExports.DataSource(this.dataSource);
|
|
632
|
+
this.#e.setOptions({
|
|
633
|
+
synchronize: false,
|
|
634
|
+
migrationsRun: false,
|
|
635
|
+
dropSchema: false,
|
|
636
|
+
logging: false
|
|
637
|
+
});
|
|
638
|
+
this.#e = await this.#e.initialize();
|
|
639
|
+
await this.handle();
|
|
640
|
+
}
|
|
641
|
+
async destroy() {
|
|
642
|
+
await (this.#e?.destroy());
|
|
643
|
+
}
|
|
644
|
+
async handle() {
|
|
645
|
+
try {
|
|
646
|
+
const e = [], t = [];
|
|
647
|
+
try {
|
|
648
|
+
const r = await this.#e.driver.createSchemaBuilder().log();
|
|
649
|
+
if (this.pretty) {
|
|
650
|
+
r.upQueries.forEach((e => {
|
|
651
|
+
e.query = Ue.prettifyQuery(e.query);
|
|
652
|
+
}));
|
|
653
|
+
r.downQueries.forEach((e => {
|
|
654
|
+
e.query = Ue.prettifyQuery(e.query);
|
|
655
|
+
}));
|
|
656
|
+
}
|
|
657
|
+
r.upQueries.forEach((t => {
|
|
658
|
+
e.push(" await queryRunner.query(`" + t.query.replaceAll("`", "\\`") + "`" + Ue.queryParams(t.parameters) + ");");
|
|
659
|
+
}));
|
|
660
|
+
r.downQueries.forEach((e => {
|
|
661
|
+
t.push(" await queryRunner.query(`" + e.query.replaceAll("`", "\\`") + "`" + Ue.queryParams(e.parameters) + ");");
|
|
662
|
+
}));
|
|
663
|
+
} finally {
|
|
664
|
+
await this.#e.destroy();
|
|
665
|
+
}
|
|
666
|
+
if (!e.length) {
|
|
667
|
+
if (this.check) {
|
|
668
|
+
console.log(G.green`No changes in database schema were found`);
|
|
669
|
+
if (this.exitProcess) {
|
|
670
|
+
this.app.exit(0);
|
|
671
|
+
} else {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
} else {
|
|
675
|
+
console.log(G.yellow`No changes in database schema were found`);
|
|
676
|
+
if (this.exitProcess) {
|
|
677
|
+
this.app.exit(1);
|
|
678
|
+
} else {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
} else if (!this.path) {
|
|
683
|
+
console.log(G.yellow`Please specify a migration path`);
|
|
684
|
+
this.app.exit(1);
|
|
685
|
+
}
|
|
686
|
+
const r = this.outputJs ? Ue.getJavascriptTemplate(S.default.basename(this.path), this.timestamp, e, t.reverse(), this.esm) : Ue.getTemplate(S.default.basename(this.path), this.timestamp, e, t.reverse());
|
|
687
|
+
if (this.check) {
|
|
688
|
+
console.log(G.yellow`Unexpected changes in database schema were found in check mode:\n\n${G.white(r)}`);
|
|
689
|
+
if (this.exitProcess) {
|
|
690
|
+
this.app.exit(0);
|
|
691
|
+
} else {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
if (this.dryRun) {
|
|
696
|
+
console.log(G.green(`Migration ${G.blue(this.path + this.extension)} has content:\n\n${G.white(r)}`));
|
|
697
|
+
} else {
|
|
698
|
+
const e = S.default.isAbsolute(this.path) ? S.default.join(this.path, this.filename) : S.default.join(process.cwd(), this.path, this.filename);
|
|
699
|
+
await M.createFile(e, r);
|
|
700
|
+
console.log(G.green`Migration ${G.blue(e)} has been generated successfully.`);
|
|
701
|
+
if (this.exitProcess) {
|
|
702
|
+
this.app.exit(0);
|
|
703
|
+
} else {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
} catch (e) {
|
|
708
|
+
o.PlatformTools.PlatformTools.logCmdErr("Error during migration generation:", e);
|
|
709
|
+
this.app.exit(1);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
static queryParams(e) {
|
|
713
|
+
if (!e || !e.length) {
|
|
714
|
+
return "";
|
|
514
715
|
}
|
|
716
|
+
return `, ${JSON.stringify(e)}`;
|
|
717
|
+
}
|
|
718
|
+
static getTemplate(e, t, r, i) {
|
|
719
|
+
const n = `${o.camelCase_1(e, true)}${t}`;
|
|
720
|
+
return `import { MigrationInterface, QueryRunner } from "lakutata/orm";\n\nexport class ${n} implements MigrationInterface {\n name = '${n}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${r.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${i.join(`\n`)}\n }\n\n}\n`;
|
|
721
|
+
}
|
|
722
|
+
static getJavascriptTemplate(e, t, r, i, n) {
|
|
723
|
+
const a = `${o.camelCase_1(e, true)}${t}`;
|
|
724
|
+
const s = n ? "export" : "module.exports =";
|
|
725
|
+
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 ${a} {\n name = '${a}'\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async up(queryRunner) {\n${r.join(`\n`)}\n }\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async down(queryRunner) {\n${i.join(`\n`)}\n }\n}\n`;
|
|
726
|
+
}
|
|
727
|
+
static prettifyQuery(e) {
|
|
728
|
+
const t = o.sqlFormatter.format(e, {
|
|
729
|
+
indent: " "
|
|
730
|
+
});
|
|
731
|
+
return "\n" + t.replace(/^/gm, " ") + "\n ";
|
|
515
732
|
}
|
|
516
733
|
};
|
|
517
734
|
|
|
518
|
-
e.__decorate([
|
|
735
|
+
e.__decorate([ O.Inject(exports.Application), e.__metadata("design:type", exports.Application) ], exports.GenerateMigration.prototype, "app", void 0);
|
|
736
|
+
|
|
737
|
+
e.__decorate([ r.Configurable(i.DTO.String().required()), e.__metadata("design:type", String) ], exports.GenerateMigration.prototype, "path", void 0);
|
|
738
|
+
|
|
739
|
+
e.__decorate([ r.Configurable(i.DTO.String().allow("").optional().default("")), e.__metadata("design:type", String) ], exports.GenerateMigration.prototype, "dataSourceName", void 0);
|
|
740
|
+
|
|
741
|
+
e.__decorate([ r.Configurable(), e.__metadata("design:type", Object) ], exports.GenerateMigration.prototype, "dataSource", void 0);
|
|
742
|
+
|
|
743
|
+
e.__decorate([ r.Configurable(i.DTO.Boolean().optional().default(true)), e.__metadata("design:type", Boolean) ], exports.GenerateMigration.prototype, "pretty", void 0);
|
|
744
|
+
|
|
745
|
+
e.__decorate([ r.Configurable(i.DTO.Boolean().optional().default(false)), e.__metadata("design:type", Boolean) ], exports.GenerateMigration.prototype, "outputJs", void 0);
|
|
746
|
+
|
|
747
|
+
e.__decorate([ r.Configurable(i.DTO.Boolean().optional().default(false)), e.__metadata("design:type", Boolean) ], exports.GenerateMigration.prototype, "esm", void 0);
|
|
748
|
+
|
|
749
|
+
e.__decorate([ r.Configurable(i.DTO.Boolean().optional().default(false)), e.__metadata("design:type", Boolean) ], exports.GenerateMigration.prototype, "dryRun", void 0);
|
|
750
|
+
|
|
751
|
+
e.__decorate([ r.Configurable(i.DTO.Boolean().optional().default(false)), e.__metadata("design:type", Boolean) ], exports.GenerateMigration.prototype, "check", void 0);
|
|
752
|
+
|
|
753
|
+
e.__decorate([ r.Configurable(i.DTO.Number().optional().default((() => Date.now()))), e.__metadata("design:type", Number) ], exports.GenerateMigration.prototype, "timestamp", void 0);
|
|
519
754
|
|
|
520
|
-
e.__decorate([
|
|
755
|
+
e.__decorate([ r.Configurable(i.DTO.Boolean().optional().default(true)), e.__metadata("design:type", Boolean) ], exports.GenerateMigration.prototype, "exitProcess", void 0);
|
|
521
756
|
|
|
522
|
-
exports.
|
|
757
|
+
exports.GenerateMigration = Ue = e.__decorate([ p.Transient() ], exports.GenerateMigration);
|