lakutata 2.0.77 → 2.0.79

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.
Files changed (50) hide show
  1. package/com/cacher.cjs +1 -1
  2. package/com/cacher.mjs +1 -1
  3. package/com/docker.cjs +2 -2
  4. package/com/docker.mjs +2 -2
  5. package/com/logger.cjs +2 -2
  6. package/com/logger.mjs +2 -2
  7. package/com/monitor.cjs +1 -1
  8. package/com/monitor.mjs +1 -1
  9. package/helper.cjs +1 -1
  10. package/helper.mjs +1 -1
  11. package/lakutata.cjs +47 -47
  12. package/lakutata.mjs +39 -39
  13. package/package.json +1 -1
  14. package/src/components/Logger.cjs +2 -2
  15. package/src/components/Logger.mjs +2 -2
  16. package/src/components/cacher/Cacher.cjs +1 -1
  17. package/src/components/cacher/Cacher.mjs +1 -1
  18. package/src/components/cacher/adapters/CreateFileCacheAdapter.cjs +1 -1
  19. package/src/components/cacher/adapters/CreateFileCacheAdapter.mjs +1 -1
  20. package/src/components/docker/ConnectionOptionsBuilder.cjs +2 -2
  21. package/src/components/docker/ConnectionOptionsBuilder.mjs +2 -2
  22. package/src/components/docker/Docker.cjs +2 -2
  23. package/src/components/docker/Docker.mjs +2 -2
  24. package/src/components/docker/lib/DockerContainer.cjs +2 -2
  25. package/src/components/docker/lib/DockerContainer.mjs +2 -2
  26. package/src/components/docker/lib/DockerContainerTTY.cjs +2 -2
  27. package/src/components/docker/lib/DockerContainerTTY.mjs +2 -2
  28. package/src/components/monitor/CpuMonitor.cjs +1 -1
  29. package/src/components/monitor/CpuMonitor.mjs +1 -1
  30. package/src/components/monitor/HttpRequestMonitor.cjs +1 -1
  31. package/src/components/monitor/HttpRequestMonitor.mjs +1 -1
  32. package/src/components/monitor/MemoryMonitor.cjs +1 -1
  33. package/src/components/monitor/MemoryMonitor.mjs +1 -1
  34. package/src/lib/base/internal/ControllerEntrypoint.mjs +1 -1
  35. package/src/lib/core/Application.cjs +333 -98
  36. package/src/lib/core/Application.mjs +339 -108
  37. package/src/lib/helpers/Statistics.cjs +1 -1
  38. package/src/lib/helpers/Statistics.mjs +1 -1
  39. package/src/lib/helpers/UUID.mjs +1 -1
  40. package/src/providers/migration/GenerateMigration.cjs +122 -246
  41. package/src/providers/migration/GenerateMigration.mjs +123 -246
  42. package/vendor/Package.14.cjs +13702 -1892
  43. package/vendor/Package.14.mjs +13744 -1852
  44. package/vendor/Package.15.cjs +1 -14057
  45. package/vendor/Package.15.mjs +1 -14031
  46. package/vendor/Package.16.cjs +2247 -1
  47. package/vendor/Package.16.mjs +2139 -1
  48. package/vendor/Package.17.cjs +3 -3
  49. package/vendor/Package.17.mjs +3 -3
  50. 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 { Module as o, MODULE_INITIALIZED as i, MODULE_INITIALIZE_ERROR as s } from "./Module.mjs";
3
+ import { Provider as o } from "./Provider.mjs";
4
4
 
5
- import { Singleton as r } from "../../decorators/di/Lifetime.mjs";
5
+ import { Configurable as r } from "../../decorators/di/Configurable.mjs";
6
6
 
7
- import { C as n } from "../../../vendor/Package.3.mjs";
7
+ import { D as i } from "../../../vendor/Package.2.mjs";
8
8
 
9
- import { ApplicationConfigLoader as a } from "../base/internal/ApplicationConfigLoader.mjs";
9
+ import n from "path";
10
10
 
11
- import { ApplicationOptions as p } from "../../options/ApplicationOptions.mjs";
11
+ import { D as s } from "../../../vendor/Package.10.mjs";
12
12
 
13
- import { Alias as m } from "./Alias.mjs";
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 { GetBasicInfo as c } from "../base/internal/BasicInfo.mjs";
15
+ import { g as d } from "../../../vendor/Package.5.mjs";
16
16
 
17
- import { Entrypoint as l } from "../../components/entrypoint/Entrypoint.mjs";
17
+ import { r as g } from "../../../vendor/Package.12.mjs";
18
18
 
19
- import { L as j } from "../../../vendor/Package.15.mjs";
19
+ import "../../../vendor/Package.8.mjs";
20
20
 
21
- import { Accept as d } from "../../decorators/dto/Accept.mjs";
21
+ import j from "fs/promises";
22
22
 
23
- import { D as h } from "../../../vendor/Package.2.mjs";
23
+ import { Singleton as f, Transient as y } from "../../decorators/di/Lifetime.mjs";
24
24
 
25
- import { mkdirSync as u } from "fs";
25
+ import { Module as b, MODULE_INITIALIZED as v, MODULE_INITIALIZE_ERROR as x } from "./Module.mjs";
26
26
 
27
- import g from "node:path";
27
+ import { C as E } from "../../../vendor/Package.3.mjs";
28
28
 
29
- import { existsSync as b } from "node:fs";
29
+ import { ApplicationConfigLoader as w } from "../base/internal/ApplicationConfigLoader.mjs";
30
30
 
31
- import { As as x } from "../helpers/As.mjs";
31
+ import { ApplicationOptions as O } from "../../options/ApplicationOptions.mjs";
32
32
 
33
- import { EventEmitter as f } from "../base/EventEmitter.mjs";
33
+ import { Alias as P } from "./Alias.mjs";
34
34
 
35
- import { DatabaseSymbol as E } from "../base/internal/DatabaseSymbol.mjs";
35
+ import { GetBasicInfo as C } from "../base/internal/BasicInfo.mjs";
36
36
 
37
- import { GenerateMigration as v } from "../../providers/migration/GenerateMigration.mjs";
37
+ import { Entrypoint as S } from "../../components/entrypoint/Entrypoint.mjs";
38
38
 
39
- import "./Component.mjs";
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 "./Provider.mjs";
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.11.mjs";
285
+ import "../../../vendor/Package.15.mjs";
254
286
 
255
- import "../../../vendor/Package.122.mjs";
287
+ import "assert";
256
288
 
257
- import "buffer";
289
+ import "string_decoder";
258
290
 
259
- import "module";
291
+ var L = {};
260
292
 
261
- import "tty";
293
+ "use strict";
262
294
 
263
- import "../../../vendor/Package.16.mjs";
295
+ Object.defineProperty(L, "__esModule", {
296
+ value: true
297
+ });
264
298
 
265
- import "assert";
299
+ var q = L.CommandUtils = void 0;
266
300
 
267
- import "string_decoder";
301
+ const F = g;
268
302
 
269
- import "node:stream";
303
+ const $ = F.__importDefault(j);
270
304
 
271
- import "../../../vendor/Package.10.mjs";
305
+ const U = F.__importDefault(n);
272
306
 
273
- import "../../../vendor/Package.102.mjs";
307
+ const G = a;
274
308
 
275
- import "../../../vendor/Package.12.mjs";
309
+ const Q = c;
276
310
 
277
- import "../../../vendor/Package.62.mjs";
311
+ const _ = p();
278
312
 
279
- import "fs/promises";
280
-
281
- import "../../../vendor/Package.63.mjs";
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 r = e[t];
330
+ const i = await r;
331
+ if (Q.InstanceChecker.isDataSource(i)) {
332
+ o.push(i);
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
- import "node:url";
375
+ q = L.CommandUtils = CommandUtils;
284
376
 
285
- import "node:fs/promises";
377
+ var J = m();
286
378
 
287
- import "node:events";
379
+ const V = d(J);
288
380
 
289
- import "node:string_decoder";
381
+ const {Ansis: H, ansi256: z, fg: W, bgAnsi256: K, bg: X, rgb: Y, bgRgb: Z, hex: tt, bgHex: et, reset: ot, inverse: rt, hidden: it, 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 y;
383
+ var zt;
292
384
 
293
- var O;
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
- })(O || (O = {}));
392
+ })(Wt || (Wt = {}));
301
393
 
302
- let P = class Application extends o {
394
+ let Kt = class Application extends b {
303
395
  constructor() {
304
396
  super(...arguments);
305
- this.ConfigLoader = a;
397
+ this.ConfigLoader = w;
306
398
  this.options = {
307
399
  components: {
308
400
  log: {
309
- class: j
401
+ class: k
310
402
  },
311
403
  entrypoint: {
312
- class: l
404
+ class: S
313
405
  }
314
406
  },
315
407
  bootstrap: [ "log" ]
316
408
  };
317
409
  }
318
410
  static {
319
- y = this;
411
+ zt = this;
320
412
  }
321
413
  static {
322
- this.eventEmitter = new f;
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 n).set(j);
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,26 +434,26 @@ let P = class Application extends o {
342
434
  return this.launch();
343
435
  }
344
436
  static onLaunched(t) {
345
- this.eventEmitter.once(O.Launched, (async e => t(e, await e.getObject("log"))));
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(O.Done, (async e => t(e, await e.getObject("log"))));
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(O.UncaughtException, (async e => {
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(O.FatalException, (async e => {
452
+ this.eventEmitter.once(Wt.FatalException, (async e => {
361
453
  const o = await this.getLogger();
362
- let i = await t(e, o);
363
- if (typeof i !== "number") i = 1;
364
- return process.exit(i);
454
+ let r = await t(e, o);
455
+ if (typeof r !== "number") r = 1;
456
+ return process.exit(r);
365
457
  }));
366
458
  return this.launch();
367
459
  }
@@ -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(O.UncaughtException)) return this.eventEmitter.emit(O.UncaughtException, t);
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(O.FatalException)) {
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(O.FatalException, t);
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(O.Done, t);
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,16 +501,16 @@ let P = class Application extends o {
409
501
  }
410
502
  }));
411
503
  this.environmentVariableMap.forEach(((t, e) => process.env[e] = t));
412
- const t = m.getAliasInstance();
504
+ const t = P.getAliasInstance();
413
505
  t.set("@runtime", process.cwd());
414
506
  this.aliasDeclarations.forEach((e => {
415
507
  const o = e.alias;
416
- const i = e.createIfNotExist;
508
+ const r = e.createIfNotExist;
417
509
  Object.keys(o).forEach((e => {
418
510
  t.set(e, o[e]);
419
- if (i) {
420
- const t = g.resolve(e);
421
- if (!b(t)) u(g.resolve(e), {
511
+ if (r) {
512
+ const t = D.resolve(e);
513
+ if (!R(t)) A(D.resolve(e), {
422
514
  recursive: true
423
515
  });
424
516
  }
@@ -430,66 +522,66 @@ let P = class Application extends o {
430
522
  case "MIGRATION_GENERATE":
431
523
  {
432
524
  const o = process.env[t];
433
- const i = t => {
525
+ const r = 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 === E) {
437
- const i = t[o].options;
438
- if (!i) continue;
439
- Reflect.set(i, "dataSourceName", o);
440
- e.push(i);
528
+ if (t[o] && t[o].class && t[o].class.databaseSymbol && t[o].class.databaseSymbol === M) {
529
+ const r = t[o].options;
530
+ if (!r) continue;
531
+ Reflect.set(r, "dataSourceName", o);
532
+ e.push(r);
441
533
  }
442
534
  }
443
535
  return e;
444
536
  };
445
- const s = [ ...e.components ? i(e.components) : [], ...e.providers ? i(e.providers) : [] ];
446
- if (!s.length) process.exit(0);
537
+ const i = [ ...e.components ? r(e.components) : [], ...e.providers ? r(e.providers) : [] ];
538
+ if (!i.length) process.exit(0);
447
539
  e.bootstrap = [];
448
- s.forEach(((t, i) => {
449
- const r = `GenerateMigration${i}${Date.now()}`;
540
+ i.forEach(((t, r) => {
541
+ const n = `GenerateMigration${r}${Date.now()}`;
450
542
  if (!e.providers) e.providers = {};
451
- e.providers[r] = {
452
- class: v,
543
+ e.providers[n] = {
544
+ class: Yt,
453
545
  path: o,
454
546
  outputJs: false,
455
- exitProcess: i === s.length - 1,
547
+ exitProcess: r === i.length - 1,
456
548
  dataSourceName: Reflect.get(t, "dataSourceName"),
457
549
  dataSource: t
458
550
  };
459
- e.bootstrap.push(r);
551
+ e.bootstrap.push(n);
460
552
  }));
461
553
  }
462
554
  break;
463
555
  }
464
556
  }
465
- const o = new n;
557
+ const o = new E;
466
558
  return new Promise(((t, r) => {
467
- p.validateAsync(e).then((e => {
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
- x(Reflect.getOwnMetadata("#bootstrap", this))?.pop();
563
+ N(Reflect.getOwnMetadata("#bootstrap", this))?.pop();
472
564
  };
473
- e.bind(x(t))();
474
- this.eventEmitter.emit(O.Launched, x(t));
565
+ e.bind(N(t))();
566
+ this.eventEmitter.emit(Wt.Launched, N(t));
475
567
  }));
476
- o.set(y, {
568
+ o.set(zt, {
477
569
  options: e
478
- }).then((e => e.once(i, (() => t(e))).once(s, (t => this.processFatalException(t))))).catch(r);
570
+ }).then((e => e.once(v, (() => t(e))).once(x, (t => this.processFatalException(t))))).catch(r);
479
571
  })).catch(r);
480
572
  }));
481
573
  }
482
574
  get alias() {
483
- return m.getAliasInstance();
575
+ return P.getAliasInstance();
484
576
  }
485
577
  get appId() {
486
- return c().appId;
578
+ return C().appId;
487
579
  }
488
580
  get appName() {
489
- return c().appName;
581
+ return C().appName;
490
582
  }
491
583
  get timezone() {
492
- return c().timezone;
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
- y.eventEmitter.emit("exit", this, t ? t : 0);
593
+ zt.eventEmitter.emit("exit", this, t ? t : 0);
502
594
  }
503
595
  }
504
596
  };
505
597
 
506
- t([ d(h.Object().pattern(h.String(), h.String()).required()), e("design:type", Function), e("design:paramtypes", [ Object ]), e("design:returntype", Object) ], P, "env", null);
598
+ t([ I(i.Object().pattern(i.String(), i.String()).required()), e("design:type", Function), e("design:paramtypes", [ Object ]), e("design:returntype", Object) ], Kt, "env", null);
599
+
600
+ t([ I(i.Object().pattern(i.String(), i.String()).required(), i.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
+ return 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
+ return 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
+ return 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
+ return 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
+ return this.app.exit(0);
687
+ } else {
688
+ return;
689
+ }
690
+ }
691
+ } catch (t) {
692
+ l.PlatformTools.logCmdErr("Error during migration generation:", t);
693
+ return 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, r) {
703
+ const i = `${u(t, true)}${e}`;
704
+ return `import { MigrationInterface, QueryRunner } from "lakutata/orm";\n\nexport class ${i} implements MigrationInterface {\n name = '${i}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${o.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${r.join(`\n`)}\n }\n\n}\n`;
705
+ }
706
+ static getJavascriptTemplate(t, e, o, r, i) {
707
+ const n = `${u(t, true)}${e}`;
708
+ const s = i ? "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${r.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([ r(i.String().required()), e("design:type", String) ], Yt.prototype, "path", void 0);
722
+
723
+ t([ r(i.String().allow("").optional().default("")), e("design:type", String) ], Yt.prototype, "dataSourceName", void 0);
724
+
725
+ t([ r(), e("design:type", Object) ], Yt.prototype, "dataSource", void 0);
726
+
727
+ t([ r(i.Boolean().optional().default(true)), e("design:type", Boolean) ], Yt.prototype, "pretty", void 0);
728
+
729
+ t([ r(i.Boolean().optional().default(false)), e("design:type", Boolean) ], Yt.prototype, "outputJs", void 0);
730
+
731
+ t([ r(i.Boolean().optional().default(false)), e("design:type", Boolean) ], Yt.prototype, "esm", void 0);
732
+
733
+ t([ r(i.Boolean().optional().default(false)), e("design:type", Boolean) ], Yt.prototype, "dryRun", void 0);
734
+
735
+ t([ r(i.Boolean().optional().default(false)), e("design:type", Boolean) ], Yt.prototype, "check", void 0);
736
+
737
+ t([ r(i.Number().optional().default((() => Date.now()))), e("design:type", Number) ], Yt.prototype, "timestamp", void 0);
507
738
 
508
- t([ d(h.Object().pattern(h.String(), h.String()).required(), h.Boolean().optional().default(false)), e("design:type", Function), e("design:paramtypes", [ Object, Boolean ]), e("design:returntype", Object) ], P, "alias", null);
739
+ t([ r(i.Boolean().optional().default(true)), e("design:type", Boolean) ], Yt.prototype, "exitProcess", void 0);
509
740
 
510
- P = y = t([ r(true) ], P);
741
+ Yt = Xt = t([ y() ], Yt);
511
742
 
512
- export { P as Application, O as ApplicationState };
743
+ export { Kt as Application, Wt as ApplicationState, Yt as G };
@@ -4,7 +4,7 @@ Object.defineProperty(exports, Symbol.toStringTag, {
4
4
  value: "Module"
5
5
  });
6
6
 
7
- const t = require("../../../vendor/Package.14.cjs");
7
+ const t = require("../../../vendor/Package.16.cjs");
8
8
 
9
9
  class Statistics {
10
10
  static {