sonamu 0.4.2 → 0.4.3

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 (32) hide show
  1. package/dist/bin/cli.js +51 -51
  2. package/dist/bin/cli.mjs +2 -2
  3. package/dist/{chunk-FLPD24HS.mjs → chunk-4K2F3SOM.mjs} +2 -2
  4. package/dist/{chunk-S6FYTR3V.mjs → chunk-HIUT56RE.mjs} +3 -3
  5. package/dist/chunk-HIUT56RE.mjs.map +1 -0
  6. package/dist/{chunk-QK5XXJUX.mjs → chunk-HVVCQLAU.mjs} +2 -2
  7. package/dist/{chunk-6HSW7OS3.js → chunk-JBKIW5LD.js} +101 -101
  8. package/dist/chunk-JBKIW5LD.js.map +1 -0
  9. package/dist/{chunk-U636LQJJ.js → chunk-N6N3LENC.js} +4 -4
  10. package/dist/{chunk-W7KDVJLQ.js → chunk-UAG3SKFM.js} +7 -7
  11. package/dist/{chunk-XT6LHCX5.js → chunk-WJGRXAXE.js} +12 -4
  12. package/dist/chunk-WJGRXAXE.js.map +1 -0
  13. package/dist/{chunk-PP2PSSAG.mjs → chunk-ZFLQLW37.mjs} +12 -4
  14. package/dist/{chunk-PP2PSSAG.mjs.map → chunk-ZFLQLW37.mjs.map} +1 -1
  15. package/dist/database/drivers/knex/base-model.js +8 -8
  16. package/dist/database/drivers/knex/base-model.mjs +3 -3
  17. package/dist/database/drivers/kysely/base-model.js +9 -9
  18. package/dist/database/drivers/kysely/base-model.mjs +3 -3
  19. package/dist/index.d.mts +2 -1
  20. package/dist/index.d.ts +2 -1
  21. package/dist/index.js +7 -7
  22. package/dist/index.mjs +3 -3
  23. package/package.json +1 -1
  24. package/src/api/sonamu.ts +17 -4
  25. package/src/entity/migrator.ts +1 -1
  26. package/dist/chunk-6HSW7OS3.js.map +0 -1
  27. package/dist/chunk-S6FYTR3V.mjs.map +0 -1
  28. package/dist/chunk-XT6LHCX5.js.map +0 -1
  29. /package/dist/{chunk-FLPD24HS.mjs.map → chunk-4K2F3SOM.mjs.map} +0 -0
  30. /package/dist/{chunk-QK5XXJUX.mjs.map → chunk-HVVCQLAU.mjs.map} +0 -0
  31. /package/dist/{chunk-U636LQJJ.js.map → chunk-N6N3LENC.js.map} +0 -0
  32. /package/dist/{chunk-W7KDVJLQ.js.map → chunk-UAG3SKFM.js.map} +0 -0
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
 
19
- var _chunkXT6LHCX5js = require('./chunk-XT6LHCX5.js');
19
+ var _chunkWJGRXAXEjs = require('./chunk-WJGRXAXE.js');
20
20
 
21
21
  // src/entity/migrator.ts
22
22
  var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
@@ -34,10 +34,10 @@ var Migrator = class {
34
34
  constructor(options) {
35
35
  this.mode = options.mode;
36
36
  if (this.mode === "dev") {
37
- const devDB = _chunkXT6LHCX5js.DB.getClient("development_master");
38
- const testDB = _chunkXT6LHCX5js.DB.getClient("test");
39
- const fixtureLocalDB = _chunkXT6LHCX5js.DB.getClient("fixture_local");
40
- const uniqConfigs = _chunkXT6LHCX5js.DB.getUniqueConfigs([
37
+ const devDB = _chunkWJGRXAXEjs.DB.getClient("development_master");
38
+ const testDB = _chunkWJGRXAXEjs.DB.getClient("test");
39
+ const fixtureLocalDB = _chunkWJGRXAXEjs.DB.getClient("fixture_local");
40
+ const uniqConfigs = _chunkWJGRXAXEjs.DB.getUniqueConfigs([
41
41
  "development_master",
42
42
  "test",
43
43
  "fixture_local",
@@ -45,7 +45,7 @@ var Migrator = class {
45
45
  ]);
46
46
  const applyDBs = [devDB, testDB, fixtureLocalDB];
47
47
  if (uniqConfigs.length === 4) {
48
- const fixtureRemoteDB = _chunkXT6LHCX5js.DB.getClient("fixture_remote");
48
+ const fixtureRemoteDB = _chunkWJGRXAXEjs.DB.getClient("fixture_remote");
49
49
  applyDBs.push(fixtureRemoteDB);
50
50
  }
51
51
  this.targets = {
@@ -55,8 +55,8 @@ var Migrator = class {
55
55
  apply: applyDBs
56
56
  };
57
57
  } else if (this.mode === "deploy") {
58
- const productionDB = _chunkXT6LHCX5js.DB.getClient("production_master");
59
- const testDB = _chunkXT6LHCX5js.DB.getClient("test");
58
+ const productionDB = _chunkWJGRXAXEjs.DB.getClient("production_master");
59
+ const testDB = _chunkWJGRXAXEjs.DB.getClient("test");
60
60
  this.targets = {
61
61
  pending: productionDB,
62
62
  shadow: testDB,
@@ -67,8 +67,8 @@ var Migrator = class {
67
67
  }
68
68
  }
69
69
  async getMigrationCodes() {
70
- const srcMigrationsDir = `${_chunkXT6LHCX5js.Sonamu.apiRootPath}/src/migrations`;
71
- const distMigrationsDir = `${_chunkXT6LHCX5js.Sonamu.apiRootPath}/dist/migrations`;
70
+ const srcMigrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
71
+ const distMigrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/dist/migrations`;
72
72
  if (_fsextra2.default.existsSync(srcMigrationsDir) === false) {
73
73
  _fsextra2.default.mkdirSync(srcMigrationsDir, {
74
74
  recursive: true
@@ -113,8 +113,8 @@ var Migrator = class {
113
113
  const { normal, onlyTs, onlyJs } = await this.getMigrationCodes();
114
114
  if (onlyTs.length > 0) {
115
115
  console.debug({ onlyTs });
116
- throw new (0, _chunkXT6LHCX5js.ServiceUnavailableException)(
117
- `There is an un-compiled TS migration files.
116
+ throw new (0, _chunkWJGRXAXEjs.ServiceUnavailableException)(
117
+ `There are un-compiled TS migration files.
118
118
  Please compile them first.
119
119
 
120
120
  ${onlyTs.map((f) => f.name).join("\n")}`
@@ -130,12 +130,12 @@ ${onlyTs.map((f) => f.name).join("\n")}`
130
130
  })
131
131
  );
132
132
  }
133
- const connKeys = Object.keys(_chunkXT6LHCX5js.DB.fullConfig).filter(
133
+ const connKeys = Object.keys(_chunkWJGRXAXEjs.DB.fullConfig).filter(
134
134
  (key) => key.endsWith("_slave") === false
135
135
  );
136
136
  const statuses = await Promise.all(
137
137
  connKeys.map(async (connKey) => {
138
- const tConn = _chunkXT6LHCX5js.DB.getClient(connKey);
138
+ const tConn = _chunkWJGRXAXEjs.DB.getClient(connKey);
139
139
  const status = await (async () => {
140
140
  try {
141
141
  return await tConn.status();
@@ -172,7 +172,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
172
172
  if (status0conn === void 0) {
173
173
  return [];
174
174
  }
175
- const compareDBconn = _chunkXT6LHCX5js.DB.getClient(status0conn.connKey);
175
+ const compareDBconn = _chunkWJGRXAXEjs.DB.getClient(status0conn.connKey);
176
176
  const genCodes = await this.compareMigrations(compareDBconn);
177
177
  await compareDBconn.destroy();
178
178
  return genCodes;
@@ -184,11 +184,11 @@ ${onlyTs.map((f) => f.name).join("\n")}`
184
184
  };
185
185
  }
186
186
  async runAction(action, targets) {
187
- const configs = _chunkXT6LHCX5js.DB.getUniqueConfigs(targets);
187
+ const configs = _chunkWJGRXAXEjs.DB.getUniqueConfigs(targets);
188
188
  const conns = await Promise.all(
189
189
  configs.map(async (config) => ({
190
190
  connKey: config.connKey,
191
- db: _chunkXT6LHCX5js.DB.getClient(config.connKey)
191
+ db: _chunkWJGRXAXEjs.DB.getClient(config.connKey)
192
192
  }))
193
193
  );
194
194
  const result = await (async () => {
@@ -236,8 +236,8 @@ ${onlyTs.map((f) => f.name).join("\n")}`
236
236
  );
237
237
  }
238
238
  const delFiles = codeNames.map((codeName) => [
239
- `${_chunkXT6LHCX5js.Sonamu.apiRootPath}/src/migrations/${codeName}.ts`,
240
- `${_chunkXT6LHCX5js.Sonamu.apiRootPath}/dist/migrations/${codeName}.js`
239
+ `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations/${codeName}.ts`,
240
+ `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/dist/migrations/${codeName}.js`
241
241
  ]).flat();
242
242
  const res = await Promise.all(
243
243
  delFiles.map((delFile) => {
@@ -257,7 +257,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
257
257
  console.log(_chalk2.default.green("\n\uD604\uC7AC \uBAA8\uB450 \uC2F1\uD06C\uB41C \uC0C1\uD0DC\uC785\uB2C8\uB2E4."));
258
258
  return 0;
259
259
  }
260
- const migrationsDir = `${_chunkXT6LHCX5js.Sonamu.apiRootPath}/src/migrations`;
260
+ const migrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
261
261
  preparedCodes.filter((pcode) => pcode.formatted).map((pcode, index) => {
262
262
  const dateTag = _luxon.DateTime.local().plus({ seconds: index }).toFormat("yyyyMMddHHmmss");
263
263
  const filePath = `${migrationsDir}/${dateTag}_${pcode.title}.ts`;
@@ -268,7 +268,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
268
268
  }
269
269
  async clearPendingList() {
270
270
  const pendingList = await this.targets.pending.getMigrations();
271
- const migrationsDir = `${_chunkXT6LHCX5js.Sonamu.apiRootPath}/src/migrations`;
271
+ const migrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
272
272
  const delList = pendingList.map((df) => {
273
273
  return _path2.default.join(migrationsDir, `${df}.ts`);
274
274
  });
@@ -332,7 +332,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
332
332
  if (answer.value === false) {
333
333
  return;
334
334
  }
335
- const migrationsDir = `${_chunkXT6LHCX5js.Sonamu.apiRootPath}/src/migrations`;
335
+ const migrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
336
336
  codes.filter((code) => code.formatted).map((code, index) => {
337
337
  const dateTag = _luxon.DateTime.local().plus({ seconds: index }).toFormat("yyyyMMddHHmmss");
338
338
  const filePath = `${migrationsDir}/${dateTag}_${code.title}.ts`;
@@ -354,7 +354,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
354
354
  const files = ["src", "dist"].reduce(
355
355
  (r, which) => {
356
356
  const migrationPath = _path2.default.join(
357
- _chunkXT6LHCX5js.Sonamu.apiRootPath,
357
+ _chunkWJGRXAXEjs.Sonamu.apiRootPath,
358
358
  which,
359
359
  "migrations"
360
360
  );
@@ -402,7 +402,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
402
402
  }
403
403
  }
404
404
  const filesToRm = diffOnDist.map((filename) => {
405
- return _path2.default.join(_chunkXT6LHCX5js.Sonamu.apiRootPath, "dist", "migrations", filename);
405
+ return _path2.default.join(_chunkWJGRXAXEjs.Sonamu.apiRootPath, "dist", "migrations", filename);
406
406
  });
407
407
  filesToRm.map((filePath) => {
408
408
  _fsextra2.default.unlinkSync(filePath);
@@ -411,7 +411,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
411
411
  }
412
412
  }
413
413
  async runShadowTest() {
414
- const tdb = _chunkXT6LHCX5js.DB.getClient("test");
414
+ const tdb = _chunkWJGRXAXEjs.DB.getClient("test");
415
415
  const tdbConn = tdb.connectionInfo;
416
416
  const shadowDatabase = tdbConn.database + "__migration_shadow";
417
417
  const tmpSqlPath = `/tmp/${shadowDatabase}.sql`;
@@ -449,7 +449,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
449
449
  ];
450
450
  } catch (e) {
451
451
  console.error(e);
452
- throw new (0, _chunkXT6LHCX5js.ServiceUnavailableException)("Shadow DB \uD14C\uC2A4\uD2B8 \uC9C4\uD589 \uC911 \uC5D0\uB7EC");
452
+ throw new (0, _chunkWJGRXAXEjs.ServiceUnavailableException)("Shadow DB \uD14C\uC2A4\uD2B8 \uC9C4\uD589 \uC911 \uC5D0\uB7EC");
453
453
  } finally {
454
454
  await tdb.destroy();
455
455
  }
@@ -472,19 +472,19 @@ ${onlyTs.map((f) => f.name).join("\n")}`
472
472
  );
473
473
  console.log({ rollbackAllResult });
474
474
  console.timeEnd(_chalk2.default.red("rollback-all:"));
475
- const migrationsDir = `${_chunkXT6LHCX5js.Sonamu.apiRootPath}/src/migrations`;
475
+ const migrationsDir = `${_chunkWJGRXAXEjs.Sonamu.apiRootPath}/src/migrations`;
476
476
  console.time(_chalk2.default.red("delete migration files"));
477
477
  _child_process.execSync.call(void 0, `rm -f ${migrationsDir}/*`);
478
478
  _child_process.execSync.call(void 0, `rm -f ${migrationsDir.replace("/src/", "/dist/")}/*`);
479
479
  console.timeEnd(_chalk2.default.red("delete migration files"));
480
480
  }
481
481
  async compareMigrations(compareDB) {
482
- const entityIds = _chunkXT6LHCX5js.EntityManager.getAllIds();
482
+ const entityIds = _chunkWJGRXAXEjs.EntityManager.getAllIds();
483
483
  const entitySetsWithJoinTable = entityIds.filter((entityId) => {
484
- const entity = _chunkXT6LHCX5js.EntityManager.get(entityId);
484
+ const entity = _chunkWJGRXAXEjs.EntityManager.get(entityId);
485
485
  return entity.props.length > 0;
486
486
  }).map((entityId) => {
487
- const entity = _chunkXT6LHCX5js.EntityManager.get(entityId);
487
+ const entity = _chunkWJGRXAXEjs.EntityManager.get(entityId);
488
488
  return this.getMigrationSetFromEntity(entity);
489
489
  });
490
490
  const joinTablesWithDup = entitySetsWithJoinTable.map((entitySet) => entitySet.joinTables).flat();
@@ -514,12 +514,12 @@ ${onlyTs.map((f) => f.name).join("\n")}`
514
514
  );
515
515
  if (dbSet === null) {
516
516
  return [
517
- await _chunkXT6LHCX5js.DB.generator.generateCreateCode_ColumnAndIndexes(
517
+ await _chunkWJGRXAXEjs.DB.generator.generateCreateCode_ColumnAndIndexes(
518
518
  entitySet.table,
519
519
  entitySet.columns,
520
520
  entitySet.indexes
521
521
  ),
522
- ...await _chunkXT6LHCX5js.DB.generator.generateCreateCode_Foreign(
522
+ ...await _chunkWJGRXAXEjs.DB.generator.generateCreateCode_Foreign(
523
523
  entitySet.table,
524
524
  entitySet.foreigns
525
525
  )
@@ -565,7 +565,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
565
565
  if (isEqualColumns && isEqualIndexes) {
566
566
  return null;
567
567
  } else {
568
- return _chunkXT6LHCX5js.DB.generator.generateAlterCode_ColumnAndIndexes(
568
+ return _chunkWJGRXAXEjs.DB.generator.generateAlterCode_ColumnAndIndexes(
569
569
  entitySet.table,
570
570
  entityColumns,
571
571
  entityIndexes,
@@ -591,7 +591,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
591
591
  (a) => [a.to, ...a.columns].join("-")
592
592
  ).map((f) => replaceNoActionOnMySQL(f));
593
593
  if (_fastdeepequal2.default.call(void 0, entityForeigns, dbForeigns) === false) {
594
- return _chunkXT6LHCX5js.DB.generator.generateAlterCode_Foreigns(
594
+ return _chunkWJGRXAXEjs.DB.generator.generateAlterCode_Foreigns(
595
595
  entitySet.table,
596
596
  entityForeigns,
597
597
  dbForeigns
@@ -630,7 +630,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
630
630
  table
631
631
  );
632
632
  } catch (e) {
633
- if (_chunkXT6LHCX5js.isKnexError.call(void 0, e) && e.code === "ER_NO_SUCH_TABLE") {
633
+ if (_chunkWJGRXAXEjs.isKnexError.call(void 0, e) && e.code === "ER_NO_SUCH_TABLE") {
634
634
  return null;
635
635
  }
636
636
  console.error(e);
@@ -807,17 +807,17 @@ ${onlyTs.map((f) => f.name).join("\n")}`
807
807
  getMigrationSetFromEntity(entity) {
808
808
  const migrationSet = entity.props.reduce(
809
809
  (r, prop) => {
810
- if (_chunkXT6LHCX5js.isVirtualProp.call(void 0, prop)) {
810
+ if (_chunkWJGRXAXEjs.isVirtualProp.call(void 0, prop)) {
811
811
  return r;
812
812
  }
813
- if (_chunkXT6LHCX5js.isHasManyRelationProp.call(void 0, prop)) {
813
+ if (_chunkWJGRXAXEjs.isHasManyRelationProp.call(void 0, prop)) {
814
814
  return r;
815
815
  }
816
- if (!_chunkXT6LHCX5js.isRelationProp.call(void 0, prop)) {
816
+ if (!_chunkWJGRXAXEjs.isRelationProp.call(void 0, prop)) {
817
817
  let type;
818
- if (_chunkXT6LHCX5js.isTextProp.call(void 0, prop)) {
818
+ if (_chunkWJGRXAXEjs.isTextProp.call(void 0, prop)) {
819
819
  type = prop.textType;
820
- } else if (_chunkXT6LHCX5js.isEnumProp.call(void 0, prop)) {
820
+ } else if (_chunkWJGRXAXEjs.isEnumProp.call(void 0, prop)) {
821
821
  type = "string";
822
822
  } else {
823
823
  type = prop.type;
@@ -825,8 +825,8 @@ ${onlyTs.map((f) => f.name).join("\n")}`
825
825
  const column = {
826
826
  name: prop.name,
827
827
  type,
828
- ..._chunkXT6LHCX5js.isIntegerProp.call(void 0, prop) && { unsigned: prop.unsigned === true },
829
- ...(_chunkXT6LHCX5js.isStringProp.call(void 0, prop) || _chunkXT6LHCX5js.isEnumProp.call(void 0, prop)) && {
828
+ ..._chunkWJGRXAXEjs.isIntegerProp.call(void 0, prop) && { unsigned: prop.unsigned === true },
829
+ ...(_chunkWJGRXAXEjs.isStringProp.call(void 0, prop) || _chunkWJGRXAXEjs.isEnumProp.call(void 0, prop)) && {
830
830
  length: prop.length
831
831
  },
832
832
  nullable: prop.nullable === true,
@@ -840,15 +840,15 @@ ${onlyTs.map((f) => f.name).join("\n")}`
840
840
  })(),
841
841
  // FIXME: float(N, M) deprecated
842
842
  // Decimal, Float 타입의 경우 precision, scale 추가
843
- ...(_chunkXT6LHCX5js.isDecimalProp.call(void 0, prop) || _chunkXT6LHCX5js.isFloatProp.call(void 0, prop)) && {
843
+ ...(_chunkWJGRXAXEjs.isDecimalProp.call(void 0, prop) || _chunkWJGRXAXEjs.isFloatProp.call(void 0, prop)) && {
844
844
  precision: _nullishCoalesce(prop.precision, () => ( 8)),
845
845
  scale: _nullishCoalesce(prop.scale, () => ( 2))
846
846
  }
847
847
  };
848
848
  r.columns.push(column);
849
849
  }
850
- if (_chunkXT6LHCX5js.isManyToManyRelationProp.call(void 0, prop)) {
851
- const relMd = _chunkXT6LHCX5js.EntityManager.get(prop.with);
850
+ if (_chunkWJGRXAXEjs.isManyToManyRelationProp.call(void 0, prop)) {
851
+ const relMd = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
852
852
  const [table1, table2] = prop.joinTable.split("__");
853
853
  const join = {
854
854
  from: `${entity.table}.id`,
@@ -920,7 +920,7 @@ ${onlyTs.map((f) => f.name).join("\n")}`
920
920
  })
921
921
  });
922
922
  return r;
923
- } else if (_chunkXT6LHCX5js.isBelongsToOneRelationProp.call(void 0, prop) || _chunkXT6LHCX5js.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
923
+ } else if (_chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
924
924
  const idColumnName = prop.name + "_id";
925
925
  r.columns.push({
926
926
  name: idColumnName,
@@ -1056,13 +1056,13 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
1056
1056
  const node = this.graph.get(fixture.fixtureId);
1057
1057
  for (const [, column] of Object.entries(fixture.columns)) {
1058
1058
  const prop = column.prop;
1059
- if (_chunkXT6LHCX5js.isRelationProp.call(void 0, prop)) {
1060
- if (_chunkXT6LHCX5js.isBelongsToOneRelationProp.call(void 0, prop) || _chunkXT6LHCX5js.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
1059
+ if (_chunkWJGRXAXEjs.isRelationProp.call(void 0, prop)) {
1060
+ if (_chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
1061
1061
  const relatedFixtureId = `${prop.with}#${column.value}`;
1062
1062
  if (this.graph.has(relatedFixtureId)) {
1063
1063
  node.related.add(relatedFixtureId);
1064
1064
  }
1065
- } else if (_chunkXT6LHCX5js.isManyToManyRelationProp.call(void 0, prop)) {
1065
+ } else if (_chunkWJGRXAXEjs.isManyToManyRelationProp.call(void 0, prop)) {
1066
1066
  const relatedIds = column.value;
1067
1067
  for (const relatedId of relatedIds) {
1068
1068
  const relatedFixtureId = `${prop.with}#${relatedId}`;
@@ -1088,11 +1088,11 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
1088
1088
  }
1089
1089
  tempVisited.add(fixtureId);
1090
1090
  const node = this.graph.get(fixtureId);
1091
- const entity = _chunkXT6LHCX5js.EntityManager.get(node.entityId);
1091
+ const entity = _chunkWJGRXAXEjs.EntityManager.get(node.entityId);
1092
1092
  for (const depId of node.related) {
1093
1093
  const depNode = this.graph.get(depId);
1094
1094
  const relationProp = entity.props.find(
1095
- (prop) => _chunkXT6LHCX5js.isRelationProp.call(void 0, prop) && (_chunkXT6LHCX5js.isBelongsToOneRelationProp.call(void 0, prop) || _chunkXT6LHCX5js.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) && prop.with === depNode.entityId
1095
+ (prop) => _chunkWJGRXAXEjs.isRelationProp.call(void 0, prop) && (_chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) && prop.with === depNode.entityId
1096
1096
  );
1097
1097
  if (relationProp && !relationProp.nullable) {
1098
1098
  visit(depId);
@@ -1118,39 +1118,39 @@ var RelationGraph = (_class = class {constructor() { _class.prototype.__init.cal
1118
1118
  var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__init2.call(this); }
1119
1119
  __init2() {this.relationGraph = new RelationGraph()}
1120
1120
  init() {
1121
- _chunkXT6LHCX5js.DB.testInit();
1121
+ _chunkWJGRXAXEjs.DB.testInit();
1122
1122
  }
1123
1123
  async cleanAndSeed(usingTables) {
1124
1124
  const tableNames = await (async () => {
1125
1125
  if (usingTables) {
1126
1126
  return usingTables;
1127
1127
  }
1128
- const tables = await _chunkXT6LHCX5js.DB.tdb.raw(
1128
+ const tables = await _chunkWJGRXAXEjs.DB.tdb.raw(
1129
1129
  `SHOW TABLE STATUS WHERE Engine IS NOT NULL`
1130
1130
  );
1131
1131
  return tables.map((tableInfo) => tableInfo["Name"]);
1132
1132
  })();
1133
- await _chunkXT6LHCX5js.DB.tdb.raw(`SET FOREIGN_KEY_CHECKS = 0`);
1133
+ await _chunkWJGRXAXEjs.DB.tdb.raw(`SET FOREIGN_KEY_CHECKS = 0`);
1134
1134
  for await (let tableName of tableNames) {
1135
1135
  if (tableName == "migrations") {
1136
1136
  continue;
1137
1137
  }
1138
- const [fdbChecksumRow] = await _chunkXT6LHCX5js.DB.fdb.raw(
1138
+ const [fdbChecksumRow] = await _chunkWJGRXAXEjs.DB.fdb.raw(
1139
1139
  `CHECKSUM TABLE ${tableName}`
1140
1140
  );
1141
1141
  const fdbChecksum = fdbChecksumRow["Checksum"];
1142
- const [tdbChecksumRow] = await _chunkXT6LHCX5js.DB.tdb.raw(
1142
+ const [tdbChecksumRow] = await _chunkWJGRXAXEjs.DB.tdb.raw(
1143
1143
  `CHECKSUM TABLE ${tableName}`
1144
1144
  );
1145
1145
  const tdbChecksum = tdbChecksumRow["Checksum"];
1146
1146
  if (fdbChecksum !== tdbChecksum) {
1147
- await _chunkXT6LHCX5js.DB.tdb.truncate(tableName);
1148
- const rawQuery = `INSERT INTO ${_chunkXT6LHCX5js.DB.connectionInfo.test.database}.${tableName}
1149
- SELECT * FROM ${_chunkXT6LHCX5js.DB.connectionInfo.fixture_local.database}.${tableName}`;
1150
- await _chunkXT6LHCX5js.DB.tdb.raw(rawQuery);
1147
+ await _chunkWJGRXAXEjs.DB.tdb.truncate(tableName);
1148
+ const rawQuery = `INSERT INTO ${_chunkWJGRXAXEjs.DB.connectionInfo.test.database}.${tableName}
1149
+ SELECT * FROM ${_chunkWJGRXAXEjs.DB.connectionInfo.fixture_local.database}.${tableName}`;
1150
+ await _chunkWJGRXAXEjs.DB.tdb.raw(rawQuery);
1151
1151
  }
1152
1152
  }
1153
- await _chunkXT6LHCX5js.DB.tdb.raw(`SET FOREIGN_KEY_CHECKS = 1`);
1153
+ await _chunkWJGRXAXEjs.DB.tdb.raw(`SET FOREIGN_KEY_CHECKS = 1`);
1154
1154
  }
1155
1155
  async getChecksum(db, tableName) {
1156
1156
  const [checksumRow] = await db.raw(
@@ -1159,8 +1159,8 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1159
1159
  return checksumRow.Checksum;
1160
1160
  }
1161
1161
  async sync() {
1162
- const frdb = _chunkXT6LHCX5js.DB.getClient("fixture_remote");
1163
- const tables = await _chunkXT6LHCX5js.DB.fdb.raw(
1162
+ const frdb = _chunkWJGRXAXEjs.DB.getClient("fixture_remote");
1163
+ const tables = await _chunkWJGRXAXEjs.DB.fdb.raw(
1164
1164
  "SHOW TABLE STATUS WHERE Engine IS NOT NULL"
1165
1165
  );
1166
1166
  const tableNames = tables.map(
@@ -1169,13 +1169,13 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1169
1169
  console.log(_chalk2.default.magenta("SYNC..."));
1170
1170
  await Promise.all(
1171
1171
  tableNames.map(async (tableName) => {
1172
- if (tableName.startsWith(_chunkXT6LHCX5js.DB.migrationTable)) {
1172
+ if (tableName.startsWith(_chunkWJGRXAXEjs.DB.migrationTable)) {
1173
1173
  return;
1174
1174
  }
1175
1175
  const remoteChecksum = await this.getChecksum(frdb, tableName);
1176
- const localChecksum = await this.getChecksum(_chunkXT6LHCX5js.DB.fdb, tableName);
1176
+ const localChecksum = await this.getChecksum(_chunkWJGRXAXEjs.DB.fdb, tableName);
1177
1177
  if (remoteChecksum !== localChecksum) {
1178
- await _chunkXT6LHCX5js.DB.fdb.trx(async (transaction) => {
1178
+ await _chunkWJGRXAXEjs.DB.fdb.trx(async (transaction) => {
1179
1179
  await transaction.raw(`SET FOREIGN_KEY_CHECKS = 0`);
1180
1180
  await transaction.truncate(tableName);
1181
1181
  const rows = await frdb.raw(`SELECT * FROM ${tableName}`);
@@ -1206,7 +1206,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1206
1206
  })
1207
1207
  )).flat()
1208
1208
  );
1209
- const wdb = _chunkXT6LHCX5js.DB.toClient(_chunkXT6LHCX5js.DB.getDB("w"));
1209
+ const wdb = _chunkWJGRXAXEjs.DB.toClient(_chunkWJGRXAXEjs.DB.getDB("w"));
1210
1210
  for (let query of queries) {
1211
1211
  const [rsh] = await wdb.raw(query);
1212
1212
  console.log({
@@ -1217,23 +1217,23 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1217
1217
  }
1218
1218
  async getImportQueries(entityId, field, id) {
1219
1219
  console.log({ entityId, field, id });
1220
- const entity = _chunkXT6LHCX5js.EntityManager.get(entityId);
1221
- const wdb = _chunkXT6LHCX5js.DB.toClient(_chunkXT6LHCX5js.DB.getDB("w"));
1220
+ const entity = _chunkWJGRXAXEjs.EntityManager.get(entityId);
1221
+ const wdb = _chunkWJGRXAXEjs.DB.toClient(_chunkWJGRXAXEjs.DB.getDB("w"));
1222
1222
  const [row] = await wdb.raw(
1223
1223
  `SELECT * FROM ${entity.table} WHERE ${field} = ${id} LIMIT 1`
1224
1224
  );
1225
1225
  if (row === void 0) {
1226
1226
  throw new Error(`${entityId}#${id} row\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.`);
1227
1227
  }
1228
- const fixtureDatabase = _chunkXT6LHCX5js.DB.connectionInfo.fixture_remote.database;
1229
- const realDatabase = _chunkXT6LHCX5js.DB.connectionInfo.production_master.database;
1228
+ const fixtureDatabase = _chunkWJGRXAXEjs.DB.connectionInfo.fixture_remote.database;
1229
+ const realDatabase = _chunkWJGRXAXEjs.DB.connectionInfo.production_master.database;
1230
1230
  const selfQuery = `INSERT IGNORE INTO \`${fixtureDatabase}\`.\`${entity.table}\` (SELECT * FROM \`${realDatabase}\`.\`${entity.table}\` WHERE \`id\` = ${id})`;
1231
1231
  const args = Object.entries(entity.relations).filter(
1232
- ([, relation]) => _chunkXT6LHCX5js.isBelongsToOneRelationProp.call(void 0, relation) || _chunkXT6LHCX5js.isOneToOneRelationProp.call(void 0, relation) && relation.customJoinClause === void 0
1232
+ ([, relation]) => _chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, relation) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, relation) && relation.customJoinClause === void 0
1233
1233
  ).map(([, relation]) => {
1234
1234
  let field2;
1235
1235
  let id2;
1236
- if (_chunkXT6LHCX5js.isOneToOneRelationProp.call(void 0, relation) && !relation.hasJoinColumn) {
1236
+ if (_chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, relation) && !relation.hasJoinColumn) {
1237
1237
  field2 = `${relation.name}_id`;
1238
1238
  id2 = row["id"];
1239
1239
  } else {
@@ -1254,14 +1254,14 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1254
1254
  return [..._lodash2.default.uniq(relQueries.reverse().flat()), selfQuery];
1255
1255
  }
1256
1256
  async destory() {
1257
- await _chunkXT6LHCX5js.DB.testDestroy();
1258
- await _chunkXT6LHCX5js.DB.destroy();
1257
+ await _chunkWJGRXAXEjs.DB.testDestroy();
1258
+ await _chunkWJGRXAXEjs.DB.destroy();
1259
1259
  }
1260
1260
  async getFixtures(sourceDBName, targetDBName, searchOptions) {
1261
- const sourceDB = _chunkXT6LHCX5js.DB.getClient(sourceDBName);
1262
- const targetDB = _chunkXT6LHCX5js.DB.getClient(targetDBName);
1261
+ const sourceDB = _chunkWJGRXAXEjs.DB.getClient(sourceDBName);
1262
+ const targetDB = _chunkWJGRXAXEjs.DB.getClient(targetDBName);
1263
1263
  const { entityId, field, value, searchType } = searchOptions;
1264
- const entity = _chunkXT6LHCX5js.EntityManager.get(entityId);
1264
+ const entity = _chunkWJGRXAXEjs.EntityManager.get(entityId);
1265
1265
  const column = _optionalChain([entity, 'access', _10 => _10.props, 'access', _11 => _11.find, 'call', _12 => _12((prop) => prop.name === field), 'optionalAccess', _13 => _13.type]) === "relation" ? `${field}_id` : field;
1266
1266
  let query = sourceDB.from(entity.table).selectAll();
1267
1267
  if (searchType === "equals") {
@@ -1286,7 +1286,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1286
1286
  }
1287
1287
  }
1288
1288
  for await (const fixture of fixtures) {
1289
- const entity2 = _chunkXT6LHCX5js.EntityManager.get(fixture.entityId);
1289
+ const entity2 = _chunkWJGRXAXEjs.EntityManager.get(fixture.entityId);
1290
1290
  const [row] = await targetDB.from(entity2.table).selectAll().where(["id", "=", fixture.id]).first().execute();
1291
1291
  if (row) {
1292
1292
  const [record] = await this.createFixtureRecord(entity2, row, {
@@ -1329,43 +1329,43 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1329
1329
  belongsRecords: []
1330
1330
  };
1331
1331
  for (const prop of entity2.props) {
1332
- if (_chunkXT6LHCX5js.isVirtualProp.call(void 0, prop)) {
1332
+ if (_chunkWJGRXAXEjs.isVirtualProp.call(void 0, prop)) {
1333
1333
  continue;
1334
1334
  }
1335
1335
  record.columns[prop.name] = {
1336
1336
  prop,
1337
1337
  value: row2[prop.name]
1338
1338
  };
1339
- const db = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _14 => _14._db]), () => ( _chunkXT6LHCX5js.DB.toClient(_chunkXT6LHCX5js.DB.getDB("w"))));
1340
- if (_chunkXT6LHCX5js.isManyToManyRelationProp.call(void 0, prop)) {
1341
- const relatedEntity = _chunkXT6LHCX5js.EntityManager.get(prop.with);
1339
+ const db = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _14 => _14._db]), () => ( _chunkWJGRXAXEjs.DB.toClient(_chunkWJGRXAXEjs.DB.getDB("w"))));
1340
+ if (_chunkWJGRXAXEjs.isManyToManyRelationProp.call(void 0, prop)) {
1341
+ const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
1342
1342
  const throughTable = prop.joinTable;
1343
1343
  const fromColumn = `${_inflection2.default.singularize(entity2.table)}_id`;
1344
1344
  const toColumn = `${_inflection2.default.singularize(relatedEntity.table)}_id`;
1345
1345
  const _relatedIds = await db.from(throughTable).select(toColumn).where([fromColumn, "=", row2.id]).execute();
1346
1346
  const relatedIds = _relatedIds.map((r) => parseInt(r[toColumn]));
1347
1347
  record.columns[prop.name].value = relatedIds;
1348
- } else if (_chunkXT6LHCX5js.isHasManyRelationProp.call(void 0, prop)) {
1349
- const relatedEntity = _chunkXT6LHCX5js.EntityManager.get(prop.with);
1348
+ } else if (_chunkWJGRXAXEjs.isHasManyRelationProp.call(void 0, prop)) {
1349
+ const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
1350
1350
  const relatedIds = await db.from(relatedEntity.table).select("id").where([prop.joinColumn, "=", row2.id]).pluck("id");
1351
1351
  record.columns[prop.name].value = relatedIds;
1352
- } else if (_chunkXT6LHCX5js.isOneToOneRelationProp.call(void 0, prop) && !prop.hasJoinColumn) {
1353
- const relatedEntity = _chunkXT6LHCX5js.EntityManager.get(prop.with);
1352
+ } else if (_chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && !prop.hasJoinColumn) {
1353
+ const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
1354
1354
  const relatedProp = relatedEntity.props.find(
1355
- (p) => _chunkXT6LHCX5js.isRelationProp.call(void 0, p) && p.with === entity2.id
1355
+ (p) => _chunkWJGRXAXEjs.isRelationProp.call(void 0, p) && p.with === entity2.id
1356
1356
  );
1357
1357
  if (relatedProp) {
1358
1358
  const [relatedRow] = await db.from(relatedEntity.table).select("id").where([relatedProp.name, "=", row2.id]).first().execute();
1359
1359
  record.columns[prop.name].value = _optionalChain([relatedRow, 'optionalAccess', _15 => _15.id]);
1360
1360
  }
1361
- } else if (_chunkXT6LHCX5js.isRelationProp.call(void 0, prop)) {
1361
+ } else if (_chunkWJGRXAXEjs.isRelationProp.call(void 0, prop)) {
1362
1362
  const relatedId = row2[`${prop.name}_id`];
1363
1363
  record.columns[prop.name].value = relatedId;
1364
1364
  if (relatedId) {
1365
1365
  record.belongsRecords.push(`${prop.with}#${relatedId}`);
1366
1366
  }
1367
1367
  if (!_optionalChain([options, 'optionalAccess', _16 => _16.singleRecord]) && relatedId) {
1368
- const relatedEntity = _chunkXT6LHCX5js.EntityManager.get(prop.with);
1368
+ const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
1369
1369
  const [relatedRow] = await db.from(relatedEntity.table).selectAll().where(["id", "=", relatedId]).first().execute();
1370
1370
  if (relatedRow) {
1371
1371
  await create(relatedEntity, relatedRow);
@@ -1382,7 +1382,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1382
1382
  const fixtures = _lodash2.default.uniqBy(_fixtures, (f) => f.fixtureId);
1383
1383
  this.relationGraph.buildGraph(fixtures);
1384
1384
  const insertionOrder = this.relationGraph.getInsertionOrder();
1385
- const db = _chunkXT6LHCX5js.DB.getClient(dbName);
1385
+ const db = _chunkWJGRXAXEjs.DB.getClient(dbName);
1386
1386
  await db.trx(async (trx) => {
1387
1387
  await trx.raw(`SET FOREIGN_KEY_CHECKS = 0`);
1388
1388
  for (const fixtureId of insertionOrder) {
@@ -1412,7 +1412,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1412
1412
  });
1413
1413
  const records = [];
1414
1414
  for await (const r of fixtures) {
1415
- const entity = _chunkXT6LHCX5js.EntityManager.get(r.entityId);
1415
+ const entity = _chunkWJGRXAXEjs.EntityManager.get(r.entityId);
1416
1416
  const [record] = await db.from(entity.table).selectAll().where(["id", "=", r.id]).first().execute();
1417
1417
  records.push({
1418
1418
  entityId: r.entityId,
@@ -1424,17 +1424,17 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1424
1424
  prepareInsertData(fixture) {
1425
1425
  const insertData = {};
1426
1426
  for (const [propName, column] of Object.entries(fixture.columns)) {
1427
- if (_chunkXT6LHCX5js.isVirtualProp.call(void 0, column.prop)) {
1427
+ if (_chunkWJGRXAXEjs.isVirtualProp.call(void 0, column.prop)) {
1428
1428
  continue;
1429
1429
  }
1430
1430
  const prop = column.prop;
1431
- if (!_chunkXT6LHCX5js.isRelationProp.call(void 0, prop)) {
1431
+ if (!_chunkWJGRXAXEjs.isRelationProp.call(void 0, prop)) {
1432
1432
  if (prop.type === "json") {
1433
1433
  insertData[propName] = JSON.stringify(column.value);
1434
1434
  } else {
1435
1435
  insertData[propName] = column.value;
1436
1436
  }
1437
- } else if (_chunkXT6LHCX5js.isBelongsToOneRelationProp.call(void 0, prop) || _chunkXT6LHCX5js.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
1437
+ } else if (_chunkWJGRXAXEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkWJGRXAXEjs.isOneToOneRelationProp.call(void 0, prop) && prop.hasJoinColumn) {
1438
1438
  insertData[`${propName}_id`] = column.value;
1439
1439
  }
1440
1440
  }
@@ -1442,7 +1442,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1442
1442
  }
1443
1443
  async insertFixture(db, fixture) {
1444
1444
  const insertData = this.prepareInsertData(fixture);
1445
- const entity = _chunkXT6LHCX5js.EntityManager.get(fixture.entityId);
1445
+ const entity = _chunkWJGRXAXEjs.EntityManager.get(fixture.entityId);
1446
1446
  try {
1447
1447
  const uniqueFound = await this.checkUniqueViolation(db, entity, fixture);
1448
1448
  if (uniqueFound) {
@@ -1471,15 +1471,15 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1471
1471
  async handleManyToManyRelations(db, fixture, fixtures) {
1472
1472
  for (const [, column] of Object.entries(fixture.columns)) {
1473
1473
  const prop = column.prop;
1474
- if (_chunkXT6LHCX5js.isManyToManyRelationProp.call(void 0, prop)) {
1474
+ if (_chunkWJGRXAXEjs.isManyToManyRelationProp.call(void 0, prop)) {
1475
1475
  const joinTable = prop.joinTable;
1476
1476
  const relatedIds = column.value;
1477
1477
  for (const relatedId of relatedIds) {
1478
1478
  if (!fixtures.find((f) => f.fixtureId === `${prop.with}#${relatedId}`)) {
1479
1479
  continue;
1480
1480
  }
1481
- const entity = _chunkXT6LHCX5js.EntityManager.get(fixture.entityId);
1482
- const relatedEntity = _chunkXT6LHCX5js.EntityManager.get(prop.with);
1481
+ const entity = _chunkWJGRXAXEjs.EntityManager.get(fixture.entityId);
1482
+ const relatedEntity = _chunkWJGRXAXEjs.EntityManager.get(prop.with);
1483
1483
  if (!entity || !relatedEntity) {
1484
1484
  throw new Error(
1485
1485
  `Entity not found: ${fixture.entityId}, ${prop.with}`
@@ -1512,7 +1512,7 @@ var FixtureManagerClass = (_class2 = class {constructor() { _class2.prototype.__
1512
1512
  }
1513
1513
  }
1514
1514
  async addFixtureLoader(code) {
1515
- const path2 = _chunkXT6LHCX5js.Sonamu.apiRootPath + "/src/testing/fixture.ts";
1515
+ const path2 = _chunkWJGRXAXEjs.Sonamu.apiRootPath + "/src/testing/fixture.ts";
1516
1516
  let content = _fs.readFileSync.call(void 0, path2).toString();
1517
1517
  const fixtureLoaderStart = content.indexOf("const fixtureLoader = {");
1518
1518
  const fixtureLoaderEnd = content.indexOf("};", fixtureLoaderStart);
@@ -1564,4 +1564,4 @@ var FixtureManager = new FixtureManagerClass();
1564
1564
 
1565
1565
 
1566
1566
  exports.Migrator = Migrator; exports.FixtureManagerClass = FixtureManagerClass; exports.FixtureManager = FixtureManager;
1567
- //# sourceMappingURL=chunk-6HSW7OS3.js.map
1567
+ //# sourceMappingURL=chunk-JBKIW5LD.js.map