sonamu 0.2.38 → 0.2.40

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 (265) hide show
  1. package/dist/bin/cli-wrapper.d.mts +1 -0
  2. package/dist/bin/cli-wrapper.d.ts +0 -2
  3. package/dist/bin/cli-wrapper.js +26 -23
  4. package/dist/bin/cli-wrapper.js.map +1 -1
  5. package/dist/bin/cli-wrapper.mjs +34 -0
  6. package/dist/bin/cli-wrapper.mjs.map +1 -0
  7. package/dist/bin/cli.d.mts +2 -0
  8. package/dist/bin/cli.d.ts +2 -2
  9. package/dist/bin/cli.js +856 -407
  10. package/dist/bin/cli.js.map +1 -1
  11. package/dist/bin/cli.mjs +887 -0
  12. package/dist/bin/cli.mjs.map +1 -0
  13. package/dist/chunk-BPT5ZXMX.js +7444 -0
  14. package/dist/chunk-BPT5ZXMX.js.map +1 -0
  15. package/dist/chunk-JXJTFHF7.mjs +20 -0
  16. package/dist/chunk-JXJTFHF7.mjs.map +1 -0
  17. package/dist/chunk-OTFO46SP.mjs +7443 -0
  18. package/dist/chunk-OTFO46SP.mjs.map +1 -0
  19. package/dist/index.d.mts +1419 -0
  20. package/dist/index.d.ts +1419 -19
  21. package/dist/index.js +422 -32
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +427 -0
  24. package/dist/index.mjs.map +1 -0
  25. package/package.json +1 -1
  26. package/tsup.config.js +8 -0
  27. package/dist/api/caster.d.ts +0 -10
  28. package/dist/api/caster.d.ts.map +0 -1
  29. package/dist/api/caster.js +0 -81
  30. package/dist/api/caster.js.map +0 -1
  31. package/dist/api/code-converters.d.ts +0 -22
  32. package/dist/api/code-converters.d.ts.map +0 -1
  33. package/dist/api/code-converters.js +0 -507
  34. package/dist/api/code-converters.js.map +0 -1
  35. package/dist/api/context.d.ts +0 -11
  36. package/dist/api/context.d.ts.map +0 -1
  37. package/dist/api/context.js +0 -3
  38. package/dist/api/context.js.map +0 -1
  39. package/dist/api/decorators.d.ts +0 -29
  40. package/dist/api/decorators.d.ts.map +0 -1
  41. package/dist/api/decorators.js +0 -26
  42. package/dist/api/decorators.js.map +0 -1
  43. package/dist/api/index.d.ts +0 -6
  44. package/dist/api/index.d.ts.map +0 -1
  45. package/dist/api/index.js +0 -22
  46. package/dist/api/index.js.map +0 -1
  47. package/dist/api/init.d.ts +0 -42
  48. package/dist/api/init.d.ts.map +0 -1
  49. package/dist/api/init.js +0 -175
  50. package/dist/api/init.js.map +0 -1
  51. package/dist/api/sonamu.d.ts +0 -66
  52. package/dist/api/sonamu.d.ts.map +0 -1
  53. package/dist/api/sonamu.js +0 -204
  54. package/dist/api/sonamu.js.map +0 -1
  55. package/dist/bin/cli-wrapper.d.ts.map +0 -1
  56. package/dist/bin/cli.d.ts.map +0 -1
  57. package/dist/database/_batch_update.d.ts +0 -15
  58. package/dist/database/_batch_update.d.ts.map +0 -1
  59. package/dist/database/_batch_update.js +0 -89
  60. package/dist/database/_batch_update.js.map +0 -1
  61. package/dist/database/base-model.d.ts +0 -39
  62. package/dist/database/base-model.d.ts.map +0 -1
  63. package/dist/database/base-model.js +0 -270
  64. package/dist/database/base-model.js.map +0 -1
  65. package/dist/database/db.d.ts +0 -21
  66. package/dist/database/db.d.ts.map +0 -1
  67. package/dist/database/db.js +0 -99
  68. package/dist/database/db.js.map +0 -1
  69. package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts +0 -2
  70. package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts.map +0 -1
  71. package/dist/database/knex-plugins/knex-on-duplicate-update.js +0 -37
  72. package/dist/database/knex-plugins/knex-on-duplicate-update.js.map +0 -1
  73. package/dist/database/upsert-builder.d.ts +0 -34
  74. package/dist/database/upsert-builder.d.ts.map +0 -1
  75. package/dist/database/upsert-builder.js +0 -240
  76. package/dist/database/upsert-builder.js.map +0 -1
  77. package/dist/entity/entity-manager.d.ts +0 -32
  78. package/dist/entity/entity-manager.d.ts.map +0 -1
  79. package/dist/entity/entity-manager.js +0 -135
  80. package/dist/entity/entity-manager.js.map +0 -1
  81. package/dist/entity/entity-utils.d.ts +0 -61
  82. package/dist/entity/entity-utils.d.ts.map +0 -1
  83. package/dist/entity/entity-utils.js +0 -124
  84. package/dist/entity/entity-utils.js.map +0 -1
  85. package/dist/entity/entity.d.ts +0 -59
  86. package/dist/entity/entity.d.ts.map +0 -1
  87. package/dist/entity/entity.js +0 -697
  88. package/dist/entity/entity.js.map +0 -1
  89. package/dist/entity/migrator.d.ts +0 -143
  90. package/dist/entity/migrator.d.ts.map +0 -1
  91. package/dist/entity/migrator.js +0 -1434
  92. package/dist/entity/migrator.js.map +0 -1
  93. package/dist/entity/smd-utils.d.ts +0 -61
  94. package/dist/entity/smd-utils.d.ts.map +0 -1
  95. package/dist/entity/smd-utils.js +0 -121
  96. package/dist/entity/smd-utils.js.map +0 -1
  97. package/dist/exceptions/error-handler.d.ts +0 -3
  98. package/dist/exceptions/error-handler.d.ts.map +0 -1
  99. package/dist/exceptions/error-handler.js +0 -34
  100. package/dist/exceptions/error-handler.js.map +0 -1
  101. package/dist/exceptions/so-exceptions.d.ts +0 -48
  102. package/dist/exceptions/so-exceptions.d.ts.map +0 -1
  103. package/dist/exceptions/so-exceptions.js +0 -105
  104. package/dist/exceptions/so-exceptions.js.map +0 -1
  105. package/dist/index.d.ts.map +0 -1
  106. package/dist/smd/entity-manager.d.ts +0 -28
  107. package/dist/smd/entity-manager.d.ts.map +0 -1
  108. package/dist/smd/entity-manager.js +0 -119
  109. package/dist/smd/entity-manager.js.map +0 -1
  110. package/dist/smd/entity.d.ts +0 -40
  111. package/dist/smd/entity.d.ts.map +0 -1
  112. package/dist/smd/entity.js +0 -430
  113. package/dist/smd/entity.js.map +0 -1
  114. package/dist/smd/migrator.d.ts +0 -109
  115. package/dist/smd/migrator.d.ts.map +0 -1
  116. package/dist/smd/migrator.js +0 -1164
  117. package/dist/smd/migrator.js.map +0 -1
  118. package/dist/smd/smd-manager.d.ts +0 -28
  119. package/dist/smd/smd-manager.d.ts.map +0 -1
  120. package/dist/smd/smd-manager.js +0 -146
  121. package/dist/smd/smd-manager.js.map +0 -1
  122. package/dist/smd/smd-utils.d.ts +0 -61
  123. package/dist/smd/smd-utils.d.ts.map +0 -1
  124. package/dist/smd/smd-utils.js +0 -121
  125. package/dist/smd/smd-utils.js.map +0 -1
  126. package/dist/smd/smd.d.ts +0 -40
  127. package/dist/smd/smd.d.ts.map +0 -1
  128. package/dist/smd/smd.js +0 -429
  129. package/dist/smd/smd.js.map +0 -1
  130. package/dist/syncer/index.d.ts +0 -2
  131. package/dist/syncer/index.d.ts.map +0 -1
  132. package/dist/syncer/index.js +0 -18
  133. package/dist/syncer/index.js.map +0 -1
  134. package/dist/syncer/syncer.d.ts +0 -108
  135. package/dist/syncer/syncer.d.ts.map +0 -1
  136. package/dist/syncer/syncer.js +0 -1119
  137. package/dist/syncer/syncer.js.map +0 -1
  138. package/dist/templates/base-template.d.ts +0 -13
  139. package/dist/templates/base-template.d.ts.map +0 -1
  140. package/dist/templates/base-template.js +0 -10
  141. package/dist/templates/base-template.js.map +0 -1
  142. package/dist/templates/entity.template.d.ts +0 -17
  143. package/dist/templates/entity.template.d.ts.map +0 -1
  144. package/dist/templates/entity.template.js +0 -78
  145. package/dist/templates/entity.template.js.map +0 -1
  146. package/dist/templates/generated.template.d.ts +0 -27
  147. package/dist/templates/generated.template.d.ts.map +0 -1
  148. package/dist/templates/generated.template.js +0 -239
  149. package/dist/templates/generated.template.js.map +0 -1
  150. package/dist/templates/generated_http.template.d.ts +0 -24
  151. package/dist/templates/generated_http.template.d.ts.map +0 -1
  152. package/dist/templates/generated_http.template.js +0 -133
  153. package/dist/templates/generated_http.template.js.map +0 -1
  154. package/dist/templates/generated_sso.template.d.ts +0 -17
  155. package/dist/templates/generated_sso.template.d.ts.map +0 -1
  156. package/dist/templates/generated_sso.template.js +0 -66
  157. package/dist/templates/generated_sso.template.js.map +0 -1
  158. package/dist/templates/index.d.ts +0 -2
  159. package/dist/templates/index.d.ts.map +0 -1
  160. package/dist/templates/index.js +0 -18
  161. package/dist/templates/index.js.map +0 -1
  162. package/dist/templates/init_enums.template.d.ts +0 -17
  163. package/dist/templates/init_enums.template.d.ts.map +0 -1
  164. package/dist/templates/init_enums.template.js +0 -54
  165. package/dist/templates/init_enums.template.js.map +0 -1
  166. package/dist/templates/init_generated.template.d.ts +0 -17
  167. package/dist/templates/init_generated.template.d.ts.map +0 -1
  168. package/dist/templates/init_generated.template.js +0 -46
  169. package/dist/templates/init_generated.template.js.map +0 -1
  170. package/dist/templates/init_types.template.d.ts +0 -17
  171. package/dist/templates/init_types.template.d.ts.map +0 -1
  172. package/dist/templates/init_types.template.js +0 -37
  173. package/dist/templates/init_types.template.js.map +0 -1
  174. package/dist/templates/model.template.d.ts +0 -17
  175. package/dist/templates/model.template.d.ts.map +0 -1
  176. package/dist/templates/model.template.js +0 -168
  177. package/dist/templates/model.template.js.map +0 -1
  178. package/dist/templates/model_test.template.d.ts +0 -17
  179. package/dist/templates/model_test.template.d.ts.map +0 -1
  180. package/dist/templates/model_test.template.js +0 -34
  181. package/dist/templates/model_test.template.js.map +0 -1
  182. package/dist/templates/service.template.d.ts +0 -28
  183. package/dist/templates/service.template.d.ts.map +0 -1
  184. package/dist/templates/service.template.js +0 -167
  185. package/dist/templates/service.template.js.map +0 -1
  186. package/dist/templates/smd.template.d.ts +0 -17
  187. package/dist/templates/smd.template.d.ts.map +0 -1
  188. package/dist/templates/smd.template.js +0 -49
  189. package/dist/templates/smd.template.js.map +0 -1
  190. package/dist/templates/view_enums_buttonset.template.d.ts +0 -17
  191. package/dist/templates/view_enums_buttonset.template.d.ts.map +0 -1
  192. package/dist/templates/view_enums_buttonset.template.js +0 -30
  193. package/dist/templates/view_enums_buttonset.template.js.map +0 -1
  194. package/dist/templates/view_enums_dropdown.template.d.ts +0 -18
  195. package/dist/templates/view_enums_dropdown.template.d.ts.map +0 -1
  196. package/dist/templates/view_enums_dropdown.template.js +0 -68
  197. package/dist/templates/view_enums_dropdown.template.js.map +0 -1
  198. package/dist/templates/view_enums_select.template.d.ts +0 -17
  199. package/dist/templates/view_enums_select.template.d.ts.map +0 -1
  200. package/dist/templates/view_enums_select.template.js +0 -54
  201. package/dist/templates/view_enums_select.template.js.map +0 -1
  202. package/dist/templates/view_form.template.d.ts +0 -74
  203. package/dist/templates/view_form.template.d.ts.map +0 -1
  204. package/dist/templates/view_form.template.js +0 -368
  205. package/dist/templates/view_form.template.js.map +0 -1
  206. package/dist/templates/view_id_all_select.template.d.ts +0 -17
  207. package/dist/templates/view_id_all_select.template.d.ts.map +0 -1
  208. package/dist/templates/view_id_all_select.template.js +0 -30
  209. package/dist/templates/view_id_all_select.template.js.map +0 -1
  210. package/dist/templates/view_id_async_select.template.d.ts +0 -17
  211. package/dist/templates/view_id_async_select.template.d.ts.map +0 -1
  212. package/dist/templates/view_id_async_select.template.js +0 -104
  213. package/dist/templates/view_id_async_select.template.js.map +0 -1
  214. package/dist/templates/view_list.template.d.ts +0 -86
  215. package/dist/templates/view_list.template.d.ts.map +0 -1
  216. package/dist/templates/view_list.template.js +0 -526
  217. package/dist/templates/view_list.template.js.map +0 -1
  218. package/dist/templates/view_list_columns.template.d.ts +0 -17
  219. package/dist/templates/view_list_columns.template.d.ts.map +0 -1
  220. package/dist/templates/view_list_columns.template.js +0 -47
  221. package/dist/templates/view_list_columns.template.js.map +0 -1
  222. package/dist/templates/view_search_input.template.d.ts +0 -17
  223. package/dist/templates/view_search_input.template.d.ts.map +0 -1
  224. package/dist/templates/view_search_input.template.js +0 -63
  225. package/dist/templates/view_search_input.template.js.map +0 -1
  226. package/dist/testing/fixture-manager.d.ts +0 -18
  227. package/dist/testing/fixture-manager.d.ts.map +0 -1
  228. package/dist/testing/fixture-manager.js +0 -238
  229. package/dist/testing/fixture-manager.js.map +0 -1
  230. package/dist/types/smd.types.d.ts +0 -741
  231. package/dist/types/smd.types.d.ts.map +0 -1
  232. package/dist/types/smd.types.js +0 -292
  233. package/dist/types/smd.types.js.map +0 -1
  234. package/dist/types/types.d.ts +0 -721
  235. package/dist/types/types.d.ts.map +0 -1
  236. package/dist/types/types.js +0 -287
  237. package/dist/types/types.js.map +0 -1
  238. package/dist/ui/index.d.ts +0 -4
  239. package/dist/ui/index.d.ts.map +0 -1
  240. package/dist/ui/index.js +0 -14
  241. package/dist/ui/index.js.map +0 -1
  242. package/dist/ui/main.d.ts +0 -4
  243. package/dist/ui/main.d.ts.map +0 -1
  244. package/dist/ui/main.js +0 -15
  245. package/dist/ui/main.js.map +0 -1
  246. package/dist/utils/controller.d.ts +0 -9
  247. package/dist/utils/controller.d.ts.map +0 -1
  248. package/dist/utils/controller.js +0 -36
  249. package/dist/utils/controller.js.map +0 -1
  250. package/dist/utils/lodash-able.d.ts +0 -2
  251. package/dist/utils/lodash-able.d.ts.map +0 -1
  252. package/dist/utils/lodash-able.js +0 -9
  253. package/dist/utils/lodash-able.js.map +0 -1
  254. package/dist/utils/model.d.ts +0 -17
  255. package/dist/utils/model.d.ts.map +0 -1
  256. package/dist/utils/model.js +0 -23
  257. package/dist/utils/model.js.map +0 -1
  258. package/dist/utils/sql-parser.d.ts +0 -4
  259. package/dist/utils/sql-parser.d.ts.map +0 -1
  260. package/dist/utils/sql-parser.js +0 -40
  261. package/dist/utils/sql-parser.js.map +0 -1
  262. package/dist/utils/utils.d.ts +0 -9
  263. package/dist/utils/utils.d.ts.map +0 -1
  264. package/dist/utils/utils.js +0 -100
  265. package/dist/utils/utils.js.map +0 -1
package/dist/bin/cli.js CHANGED
@@ -1,434 +1,883 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
1
+ "use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ var _chunkBPT5ZXMXjs = require('../chunk-BPT5ZXMX.js');
15
+
16
+ // src/bin/cli.ts
17
+ var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
18
+ var _dotenv = require('dotenv'); var _dotenv2 = _interopRequireDefault(_dotenv);
19
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
20
+ var _tsicli = require('tsicli');
21
+ var _child_process = require('child_process');
22
+ var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
23
+ var _knex = require('knex'); var _knex2 = _interopRequireDefault(_knex);
24
+ var _inflection = require('inflection'); var _inflection2 = _interopRequireDefault(_inflection);
25
+ var _prettier = require('prettier'); var _prettier2 = _interopRequireDefault(_prettier);
26
+
27
+ // src/smd/smd-manager.ts
28
+
29
+ var _glob = require('glob'); var _glob2 = _interopRequireDefault(_glob);
30
+
31
+
32
+
33
+ // src/smd/smd.ts
34
+ var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
35
+
36
+
37
+
38
+ var SMD = class {
39
+ constructor({
40
+ id,
41
+ parentId,
42
+ table,
43
+ title,
44
+ props,
45
+ indexes,
46
+ subsets
47
+ }) {
48
+ this.types = {};
49
+ this.enums = {};
50
+ this.enumLabels = {};
51
+ this.id = id;
52
+ this.parentId = parentId;
53
+ this.title = _nullishCoalesce(title, () => ( this.id));
54
+ this.table = _nullishCoalesce(table, () => ( _inflection2.default.underscore(_inflection2.default.pluralize(id))));
55
+ if (props) {
56
+ this.props = props.map((prop) => {
57
+ if (_chunkBPT5ZXMXjs.isEnumProp.call(void 0, prop)) {
58
+ if (prop.id.includes("$Model")) {
59
+ prop.id = prop.id.replace("$Model", id);
60
+ }
61
+ }
62
+ return prop;
63
+ });
64
+ this.propsDict = props.reduce((result, prop) => {
65
+ return {
66
+ ...result,
67
+ [prop.name]: prop
68
+ };
69
+ }, {});
70
+ this.relations = props.filter((prop) => _chunkBPT5ZXMXjs.isRelationProp.call(void 0, prop)).reduce((result, prop) => {
71
+ return {
72
+ ...result,
73
+ [prop.name]: prop
74
+ };
75
+ }, {});
76
+ } else {
77
+ this.props = [];
78
+ this.propsDict = {};
79
+ this.relations = {};
7
80
  }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
81
+ this.indexes = _nullishCoalesce(indexes, () => ( []));
82
+ this.subsets = _nullishCoalesce(subsets, () => ( {}));
83
+ this.names = {
84
+ fs: parentId === void 0 ? _inflection2.default.dasherize(_inflection2.default.underscore(id)).toLowerCase() : _inflection2.default.dasherize(parentId).toLowerCase(),
85
+ module: id
86
+ };
87
+ this.registerModulePaths();
88
+ this.registerTableSpecs();
89
+ }
90
+ /*
91
+ subset SELECT/JOIN/LOADER 결과 리턴
92
+ */
93
+ getSubsetQuery(subsetKey) {
94
+ const subset = this.subsets[subsetKey];
95
+ const result = this.resolveSubsetQuery("", subset);
23
96
  return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
97
+ }
98
+ /*
99
+ */
100
+ resolveSubsetQuery(prefix, fields, isAlreadyOuterJoined = false) {
101
+ prefix = prefix.replace(/\./g, "__");
102
+ const subsetGroup = _lodash2.default.groupBy(fields, (field) => {
103
+ if (field.includes(".")) {
104
+ const [rel] = field.split(".");
105
+ return rel;
106
+ } else {
107
+ return "";
108
+ }
32
109
  });
33
- };
34
- var __asyncValues = (this && this.__asyncValues) || function (o) {
35
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
36
- var m = o[Symbol.asyncIterator], i;
37
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
38
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
39
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
40
- };
41
- var __importDefault = (this && this.__importDefault) || function (mod) {
42
- return (mod && mod.__esModule) ? mod : { "default": mod };
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- /* Global Begin */
46
- const chalk_1 = __importDefault(require("chalk"));
47
- console.log(chalk_1.default.bgBlue(`BEGIN ${new Date()}`));
48
- const dotenv_1 = __importDefault(require("dotenv"));
49
- dotenv_1.default.config();
50
- const path_1 = __importDefault(require("path"));
51
- const base_model_1 = require("../database/base-model");
52
- const entity_manager_1 = require("../entity/entity-manager");
53
- const migrator_1 = require("../entity/migrator");
54
- const fixture_manager_1 = require("../testing/fixture-manager");
55
- const tsicli_1 = require("tsicli");
56
- const child_process_1 = require("child_process");
57
- const fs_extra_1 = __importDefault(require("fs-extra"));
58
- const api_1 = require("../api");
59
- const knex_1 = __importDefault(require("knex"));
60
- const inflection_1 = __importDefault(require("inflection"));
61
- const prettier_1 = __importDefault(require("prettier"));
62
- const smd_manager_1 = require("../smd/smd-manager");
63
- const process_1 = __importDefault(require("process"));
64
- let migrator;
65
- function bootstrap() {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- yield api_1.Sonamu.init(false, false);
68
- yield (0, tsicli_1.tsicli)(process_1.default.argv, {
69
- types: {
70
- "#entityId": {
71
- type: "autocomplete",
72
- name: "#entityId",
73
- message: "Please input #entityId",
74
- choices: entity_manager_1.EntityManager.getAllParentIds().map((entityId) => ({
75
- title: entityId,
76
- value: entityId,
77
- })),
78
- },
79
- "#recordIds": "number[]",
80
- "#name": "string",
81
- },
82
- args: [
83
- ["fixture", "init"],
84
- ["fixture", "import", "#entityId", "#recordIds"],
85
- ["fixture", "sync"],
86
- ["migrate", "run"],
87
- ["migrate", "check"],
88
- ["migrate", "rollback"],
89
- ["migrate", "reset"],
90
- ["migrate", "clear"],
91
- ["stub", "practice", "#name"],
92
- ["stub", "entity", "#name"],
93
- ["scaffold", "model", "#entityId"],
94
- ["scaffold", "model_test", "#entityId"],
95
- ["scaffold", "view_list", "#entityId"],
96
- ["scaffold", "view_form", "#entityId"],
97
- ["ui"],
98
- ["smd_migration"],
99
- ],
100
- runners: {
101
- migrate_run,
102
- migrate_check,
103
- migrate_rollback,
104
- migrate_clear,
105
- migrate_reset,
106
- fixture_init,
107
- fixture_import,
108
- fixture_sync,
109
- stub_practice,
110
- stub_entity,
111
- scaffold_model,
112
- scaffold_model_test,
113
- ui,
114
- // scaffold_view_list,
115
- // scaffold_view_form,
116
- smd_migration,
117
- },
110
+ const result = Object.keys(subsetGroup).reduce(
111
+ (r, groupKey) => {
112
+ const fields2 = subsetGroup[groupKey];
113
+ if (groupKey === "") {
114
+ const realFields = fields2.filter(
115
+ (field) => !_chunkBPT5ZXMXjs.isVirtualProp.call(void 0, this.propsDict[field])
116
+ );
117
+ const virtualFields = fields2.filter(
118
+ (field) => _chunkBPT5ZXMXjs.isVirtualProp.call(void 0, this.propsDict[field])
119
+ );
120
+ if (prefix === "") {
121
+ r.select = r.select.concat(
122
+ realFields.map((field) => `${this.table}.${field}`)
123
+ );
124
+ r.virtual = r.virtual.concat(virtualFields);
125
+ } else {
126
+ r.select = r.select.concat(
127
+ realFields.map(
128
+ (field) => `${prefix}.${field} as ${prefix}__${field}`
129
+ )
130
+ );
131
+ }
132
+ return r;
133
+ }
134
+ const relation = this.relations[groupKey];
135
+ if (relation === void 0) {
136
+ throw new Error(`\uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 relation \uCC38\uC870 ${groupKey}`);
137
+ }
138
+ const relSMD = SMDManager.get(relation.with);
139
+ if (_chunkBPT5ZXMXjs.isOneToOneRelationProp.call(void 0, relation) || _chunkBPT5ZXMXjs.isBelongsToOneRelationProp.call(void 0, relation)) {
140
+ const relFields = fields2.map(
141
+ (field) => field.split(".").slice(1).join(".")
142
+ );
143
+ if (relFields.length === 1 && relFields[0] === "id") {
144
+ if (prefix === "") {
145
+ r.select = r.select.concat(`${this.table}.${groupKey}_id`);
146
+ } else {
147
+ r.select = r.select.concat(
148
+ `${prefix}.${groupKey}_id as ${prefix}__${groupKey}_id`
149
+ );
150
+ }
151
+ return r;
152
+ }
153
+ const innerOrOuter = (() => {
154
+ if (isAlreadyOuterJoined) {
155
+ return "outer";
156
+ }
157
+ if (_chunkBPT5ZXMXjs.isOneToOneRelationProp.call(void 0, relation)) {
158
+ if (relation.hasJoinColumn === true && (_nullishCoalesce(relation.nullable, () => ( false))) === false) {
159
+ return "inner";
160
+ } else {
161
+ return "outer";
162
+ }
163
+ } else {
164
+ if (relation.nullable) {
165
+ return "outer";
166
+ } else {
167
+ return "inner";
168
+ }
169
+ }
170
+ })();
171
+ const relSubsetQuery = relSMD.resolveSubsetQuery(
172
+ `${prefix !== "" ? prefix + "." : ""}${groupKey}`,
173
+ relFields,
174
+ innerOrOuter === "outer"
175
+ );
176
+ r.select = r.select.concat(relSubsetQuery.select);
177
+ r.virtual = r.virtual.concat(relSubsetQuery.virtual);
178
+ const joinAs = prefix === "" ? groupKey : prefix + "__" + groupKey;
179
+ const fromTable = prefix === "" ? this.table : prefix;
180
+ let joinClause;
181
+ if (relation.customJoinClause) {
182
+ joinClause = {
183
+ custom: relation.customJoinClause
184
+ };
185
+ } else {
186
+ let from, to;
187
+ if (_chunkBPT5ZXMXjs.isOneToOneRelationProp.call(void 0, relation)) {
188
+ if (relation.hasJoinColumn) {
189
+ from = `${fromTable}.${relation.name}_id`;
190
+ to = `${joinAs}.id`;
191
+ } else {
192
+ from = `${fromTable}.id`;
193
+ to = `${joinAs}.${_inflection2.default.underscore(
194
+ this.names.fs.replace(/\-/g, "_")
195
+ )}_id`;
196
+ }
197
+ } else {
198
+ from = `${fromTable}.${relation.name}_id`;
199
+ to = `${joinAs}.id`;
200
+ }
201
+ joinClause = {
202
+ from,
203
+ to
204
+ };
205
+ }
206
+ r.joins.push({
207
+ as: joinAs,
208
+ join: innerOrOuter,
209
+ table: relSMD.table,
210
+ ...joinClause
211
+ });
212
+ if (relSubsetQuery.loaders.length > 0) {
213
+ const convertedLoaders = relSubsetQuery.loaders.map((loader) => {
214
+ const newAs = [groupKey, loader.as].join("__");
215
+ return {
216
+ as: newAs,
217
+ table: loader.table,
218
+ manyJoin: loader.manyJoin,
219
+ oneJoins: loader.oneJoins,
220
+ select: loader.select
221
+ };
222
+ });
223
+ r.loaders = [...r.loaders, ...convertedLoaders];
224
+ }
225
+ r.joins = r.joins.concat(relSubsetQuery.joins);
226
+ } else if (_chunkBPT5ZXMXjs.isHasManyRelationProp.call(void 0, relation) || _chunkBPT5ZXMXjs.isManyToManyRelationProp.call(void 0, relation)) {
227
+ const relFields = fields2.map(
228
+ (field) => field.split(".").slice(1).join(".")
229
+ );
230
+ const relSubsetQuery = relSMD.resolveSubsetQuery("", relFields);
231
+ let manyJoin;
232
+ if (_chunkBPT5ZXMXjs.isHasManyRelationProp.call(void 0, relation)) {
233
+ manyJoin = {
234
+ fromTable: this.table,
235
+ fromCol: "id",
236
+ idField: prefix === "" ? `id` : `${prefix}__id`,
237
+ toTable: relSMD.table,
238
+ toCol: relation.joinColumn
239
+ };
240
+ } else if (_chunkBPT5ZXMXjs.isManyToManyRelationProp.call(void 0, relation)) {
241
+ const [table1, table2] = relation.joinTable.split("__");
242
+ manyJoin = {
243
+ fromTable: this.table,
244
+ fromCol: "id",
245
+ idField: prefix === "" ? `id` : `${prefix}__id`,
246
+ through: {
247
+ table: relation.joinTable,
248
+ fromCol: `${_inflection2.default.singularize(table1)}_id`,
249
+ toCol: `${_inflection2.default.singularize(table2)}_id`
250
+ },
251
+ toTable: relSMD.table,
252
+ toCol: "id"
253
+ };
254
+ } else {
255
+ throw new Error();
256
+ }
257
+ r.loaders.push({
258
+ as: groupKey,
259
+ table: relSMD.table,
260
+ manyJoin,
261
+ oneJoins: relSubsetQuery.joins,
262
+ select: relSubsetQuery.select,
263
+ loaders: relSubsetQuery.loaders
264
+ });
265
+ }
266
+ return r;
267
+ },
268
+ {
269
+ select: [],
270
+ virtual: [],
271
+ joins: [],
272
+ loaders: []
273
+ }
274
+ );
275
+ return result;
276
+ }
277
+ /*
278
+ FieldExpr[] 을 SMDPropNode[] 로 변환
279
+ */
280
+ fieldExprsToPropNodes(fieldExprs, smd = this) {
281
+ const groups = fieldExprs.reduce(
282
+ (result, fieldExpr) => {
283
+ let key, value, elseExpr;
284
+ if (fieldExpr.includes(".")) {
285
+ [key, ...elseExpr] = fieldExpr.split(".");
286
+ value = elseExpr.join(".");
287
+ } else {
288
+ key = "";
289
+ value = fieldExpr;
290
+ }
291
+ result[key] = (_nullishCoalesce(result[key], () => ( []))).concat(value);
292
+ return result;
293
+ },
294
+ {}
295
+ );
296
+ return Object.keys(groups).map((key) => {
297
+ const group = groups[key];
298
+ if (key === "") {
299
+ return group.map((propName) => {
300
+ if (propName === "uuid") {
301
+ return {
302
+ nodeType: "plain",
303
+ prop: {
304
+ type: "string",
305
+ name: "uuid",
306
+ length: 128
307
+ },
308
+ children: []
309
+ };
310
+ }
311
+ const prop2 = smd.propsDict[propName];
312
+ if (prop2 === void 0) {
313
+ throw new Error(`${this.id} -- \uC798\uBABB\uB41C FieldExpr ${propName}`);
314
+ }
315
+ return {
316
+ nodeType: "plain",
317
+ prop: prop2,
318
+ children: []
319
+ };
118
320
  });
321
+ }
322
+ const prop = smd.propsDict[key];
323
+ if (!_chunkBPT5ZXMXjs.isRelationProp.call(void 0, prop)) {
324
+ throw new Error(`\uC798\uBABB\uB41C FieldExpr ${key}.${group[0]}`);
325
+ }
326
+ const relSMD = SMDManager.get(prop.with);
327
+ if (_chunkBPT5ZXMXjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkBPT5ZXMXjs.isOneToOneRelationProp.call(void 0, prop)) {
328
+ if (group.length == 1 && (group[0] === "id" || group[0] == "id?")) {
329
+ const idProp = relSMD.propsDict.id;
330
+ return {
331
+ nodeType: "plain",
332
+ prop: {
333
+ ...idProp,
334
+ name: key + "_id",
335
+ nullable: prop.nullable
336
+ },
337
+ children: []
338
+ };
339
+ }
340
+ }
341
+ const children = this.fieldExprsToPropNodes(group, relSMD);
342
+ const nodeType = _chunkBPT5ZXMXjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkBPT5ZXMXjs.isOneToOneRelationProp.call(void 0, prop) ? "object" : "array";
343
+ return {
344
+ prop,
345
+ children,
346
+ nodeType
347
+ };
348
+ }).flat();
349
+ }
350
+ getFieldExprs(prefix = "", maxDepth = 3, froms = []) {
351
+ return this.props.map((prop) => {
352
+ const propName = [prefix, prop.name].filter((v) => v !== "").join(".");
353
+ if (propName === prefix) {
354
+ return null;
355
+ }
356
+ if (_chunkBPT5ZXMXjs.isRelationProp.call(void 0, prop)) {
357
+ if (maxDepth < 0) {
358
+ return null;
359
+ }
360
+ if (froms.includes(prop.with)) {
361
+ return null;
362
+ }
363
+ const relMd = SMDManager.get(prop.with);
364
+ return relMd.getFieldExprs(propName, maxDepth - 1, [
365
+ ...froms,
366
+ this.id
367
+ ]);
368
+ }
369
+ return propName;
370
+ }).flat().filter((f) => f !== null);
371
+ }
372
+ registerModulePaths() {
373
+ const basePath = `${this.names.fs}`;
374
+ SMDManager.setModulePath(
375
+ `${this.id}BaseSchema`,
376
+ `${basePath}/${this.names.fs}.generated`
377
+ );
378
+ if (Object.keys(this.subsets).length > 0) {
379
+ SMDManager.setModulePath(
380
+ `${this.id}SubsetKey`,
381
+ `${basePath}/${this.names.fs}.generated`
382
+ );
383
+ SMDManager.setModulePath(
384
+ `${this.id}SubsetMapping`,
385
+ `${basePath}/${this.names.fs}.generated`
386
+ );
387
+ Object.keys(this.subsets).map((subsetKey) => {
388
+ SMDManager.setModulePath(
389
+ `${this.id}Subset${subsetKey.toUpperCase()}`,
390
+ `${basePath}/${this.names.fs}.generated`
391
+ );
392
+ });
393
+ }
394
+ const typesModulePath = `${basePath}/${this.names.fs}.types`;
395
+ const typesFileDistPath = _path2.default.join(
396
+ _chunkBPT5ZXMXjs.Sonamu.apiRootPath,
397
+ `dist/application/${typesModulePath}.js`
398
+ );
399
+ if (_fsextra2.default.existsSync(typesFileDistPath)) {
400
+ const importPath = _path2.default.relative(__dirname, typesFileDistPath);
401
+ Promise.resolve().then(() => _interopRequireWildcard(require(importPath))).then((t) => {
402
+ this.types = Object.keys(t).reduce((result, key) => {
403
+ SMDManager.setModulePath(key, typesModulePath);
404
+ return {
405
+ ...result,
406
+ [key]: t[key]
407
+ };
408
+ }, {});
409
+ });
410
+ }
411
+ const enumsModulePath = `${basePath}/${this.names.fs}.enums`;
412
+ const enumsFileDistPath = _path2.default.join(
413
+ _chunkBPT5ZXMXjs.Sonamu.apiRootPath,
414
+ `/dist/application/${enumsModulePath}.js`
415
+ );
416
+ if (_fsextra2.default.existsSync(enumsFileDistPath)) {
417
+ const importPath = _path2.default.relative(__dirname, enumsFileDistPath);
418
+ Promise.resolve().then(() => _interopRequireWildcard(require(importPath))).then((t) => {
419
+ this.enums = Object.keys(t).reduce((result, key) => {
420
+ SMDManager.setModulePath(key, enumsModulePath);
421
+ if (key === _inflection2.default.underscore(this.id).toUpperCase()) {
422
+ this.enumLabels = t[key];
423
+ }
424
+ return {
425
+ ...result,
426
+ [key]: t[key]
427
+ };
428
+ }, {});
429
+ });
430
+ }
431
+ }
432
+ registerTableSpecs() {
433
+ const uniqueColumns = _lodash2.default.uniq(
434
+ this.indexes.filter((idx) => idx.type === "unique").map((idx) => idx.columns).flat()
435
+ );
436
+ SMDManager.setTableSpec({
437
+ name: this.table,
438
+ uniqueColumns
119
439
  });
120
- }
121
- bootstrap().finally(() => __awaiter(void 0, void 0, void 0, function* () {
122
- if (migrator) {
123
- yield migrator.destroy();
440
+ }
441
+ };
442
+
443
+ // src/smd/smd-manager.ts
444
+ var SMDManagerClass = class {
445
+ constructor() {
446
+ this.SMDs = /* @__PURE__ */ new Map();
447
+ this.modulePaths = /* @__PURE__ */ new Map();
448
+ this.tableSpecs = /* @__PURE__ */ new Map();
449
+ this.isAutoloaded = false;
450
+ }
451
+ // 경로 전달받아 모든 SMD 파일 로드
452
+ async autoload(doSilent = false) {
453
+ if (this.isAutoloaded) {
454
+ return;
124
455
  }
125
- yield fixture_manager_1.FixtureManager.destory();
126
- yield base_model_1.BaseModel.destroy();
127
- /* Global End */
128
- console.log(chalk_1.default.bgBlue(`END ${new Date()}\n`));
129
- }));
130
- function setupMigrator() {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- // migrator
133
- migrator = new migrator_1.Migrator({
134
- mode: "dev",
456
+ const pathPattern = _path2.default.join(
457
+ _chunkBPT5ZXMXjs.Sonamu.apiRootPath,
458
+ "/dist/application/**/*.smd.js"
459
+ );
460
+ !doSilent && console.log(_chalk2.default.yellow(`autoload ${pathPattern}`));
461
+ return new Promise((resolve) => {
462
+ _glob2.default.glob(_path2.default.resolve(pathPattern), (_err, files) => {
463
+ const importPaths = files.map(
464
+ (filePath) => _path2.default.relative(__dirname, filePath)
465
+ );
466
+ Promise.all(
467
+ importPaths.map(async (importPath) => {
468
+ const imported = await Promise.resolve().then(() => _interopRequireWildcard(require(importPath)));
469
+ Object.values(imported).map(
470
+ (smdInput) => this.register(smdInput)
471
+ );
472
+ return imported;
473
+ })
474
+ ).then(() => {
475
+ resolve("ok");
476
+ this.isAutoloaded = true;
135
477
  });
478
+ });
136
479
  });
137
- }
138
- function setupFixtureManager() {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- fixture_manager_1.FixtureManager.init();
480
+ }
481
+ register(smdInput) {
482
+ const smd = new SMD(smdInput);
483
+ this.SMDs.set(smdInput.id, smd);
484
+ }
485
+ get(smdId) {
486
+ const smd = this.SMDs.get(smdId);
487
+ if (smd === void 0) {
488
+ throw new Error(`\uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 SMD \uC694\uCCAD ${smdId}`);
489
+ }
490
+ return smd;
491
+ }
492
+ exists(smdId) {
493
+ const smd = this.SMDs.get(smdId);
494
+ return smd !== void 0;
495
+ }
496
+ getAllIds() {
497
+ return Array.from(SMDManager.SMDs.keys());
498
+ }
499
+ getAllParentIds() {
500
+ return this.getAllIds().filter((smdId) => {
501
+ const smd = this.get(smdId);
502
+ return smd.parentId === void 0;
141
503
  });
142
- }
143
- function migrate_run() {
144
- return __awaiter(this, void 0, void 0, function* () {
145
- yield setupMigrator();
146
- yield migrator.cleanUpDist();
147
- yield migrator.run();
504
+ }
505
+ getChildrenIds(parentId) {
506
+ return this.getAllIds().filter((smdId) => {
507
+ const smd = this.get(smdId);
508
+ return smd.parentId === parentId;
148
509
  });
510
+ }
511
+ setModulePath(key, modulePath) {
512
+ this.modulePaths.set(key, modulePath);
513
+ }
514
+ getModulePath(key) {
515
+ const modulePath = this.modulePaths.get(key);
516
+ if (modulePath === void 0) {
517
+ throw new Error(`\uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uBAA8\uB4C8 \uD328\uC2A4 \uC694\uCCAD ${key}`);
518
+ }
519
+ return modulePath;
520
+ }
521
+ setTableSpec(tableSpec) {
522
+ this.tableSpecs.set(tableSpec.name, tableSpec);
523
+ }
524
+ getTableSpec(key) {
525
+ const tableSpec = this.tableSpecs.get(key);
526
+ if (tableSpec === void 0) {
527
+ throw new Error(`\uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uD14C\uC774\uBE14 \uC2A4\uD399 \uC694\uCCAD ${key}`);
528
+ }
529
+ return tableSpec;
530
+ }
531
+ getNamesFromId(smdId) {
532
+ const pluralized = _inflection2.default.pluralize(smdId) === smdId ? `${smdId}List` : _inflection2.default.pluralize(smdId);
533
+ return {
534
+ fs: _inflection2.default.dasherize(_inflection2.default.underscore(smdId)).toLowerCase(),
535
+ fsPlural: _inflection2.default.dasherize(_inflection2.default.underscore(pluralized)).toLowerCase(),
536
+ camel: _inflection2.default.camelize(smdId, true),
537
+ camelPlural: _inflection2.default.camelize(pluralized, true),
538
+ capital: smdId,
539
+ capitalPlural: pluralized,
540
+ upper: smdId.toUpperCase(),
541
+ constant: _inflection2.default.underscore(smdId).toUpperCase()
542
+ };
543
+ }
544
+ };
545
+ var SMDManager = new SMDManagerClass();
546
+
547
+ // src/bin/cli.ts
548
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
549
+ console.log(_chalk2.default.bgBlue(`BEGIN ${/* @__PURE__ */ new Date()}`));
550
+ _dotenv2.default.config();
551
+ var migrator;
552
+ async function bootstrap() {
553
+ await _chunkBPT5ZXMXjs.Sonamu.init(false, false);
554
+ await _tsicli.tsicli.call(void 0, _process2.default.argv, {
555
+ types: {
556
+ "#entityId": {
557
+ type: "autocomplete",
558
+ name: "#entityId",
559
+ message: "Please input #entityId",
560
+ choices: _chunkBPT5ZXMXjs.EntityManager.getAllParentIds().map((entityId) => ({
561
+ title: entityId,
562
+ value: entityId
563
+ }))
564
+ },
565
+ "#recordIds": "number[]",
566
+ "#name": "string"
567
+ },
568
+ args: [
569
+ ["fixture", "init"],
570
+ ["fixture", "import", "#entityId", "#recordIds"],
571
+ ["fixture", "sync"],
572
+ ["migrate", "run"],
573
+ ["migrate", "check"],
574
+ ["migrate", "rollback"],
575
+ ["migrate", "reset"],
576
+ ["migrate", "clear"],
577
+ ["stub", "practice", "#name"],
578
+ ["stub", "entity", "#name"],
579
+ ["scaffold", "model", "#entityId"],
580
+ ["scaffold", "model_test", "#entityId"],
581
+ ["scaffold", "view_list", "#entityId"],
582
+ ["scaffold", "view_form", "#entityId"],
583
+ ["ui"],
584
+ ["smd_migration"]
585
+ ],
586
+ runners: {
587
+ migrate_run,
588
+ migrate_check,
589
+ migrate_rollback,
590
+ migrate_clear,
591
+ migrate_reset,
592
+ fixture_init,
593
+ fixture_import,
594
+ fixture_sync,
595
+ stub_practice,
596
+ stub_entity,
597
+ scaffold_model,
598
+ scaffold_model_test,
599
+ ui,
600
+ // scaffold_view_list,
601
+ // scaffold_view_form,
602
+ smd_migration
603
+ }
604
+ });
149
605
  }
150
- function migrate_check() {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- yield setupMigrator();
153
- yield migrator.cleanUpDist();
154
- yield migrator.check();
155
- });
606
+ bootstrap().finally(async () => {
607
+ if (migrator) {
608
+ await migrator.destroy();
609
+ }
610
+ await _chunkBPT5ZXMXjs.FixtureManager.destory();
611
+ await _chunkBPT5ZXMXjs.BaseModel.destroy();
612
+ console.log(_chalk2.default.bgBlue(`END ${/* @__PURE__ */ new Date()}
613
+ `));
614
+ });
615
+ async function setupMigrator() {
616
+ migrator = new (0, _chunkBPT5ZXMXjs.Migrator)({
617
+ mode: "dev"
618
+ });
156
619
  }
157
- function migrate_rollback() {
158
- return __awaiter(this, void 0, void 0, function* () {
159
- yield setupMigrator();
160
- yield migrator.rollback();
161
- });
620
+ async function setupFixtureManager() {
621
+ _chunkBPT5ZXMXjs.FixtureManager.init();
162
622
  }
163
- function migrate_clear() {
164
- return __awaiter(this, void 0, void 0, function* () {
165
- yield setupMigrator();
166
- yield migrator.clearPendingList();
167
- });
623
+ async function migrate_run() {
624
+ await setupMigrator();
625
+ await migrator.cleanUpDist();
626
+ await migrator.run();
168
627
  }
169
- function migrate_reset() {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- yield setupMigrator();
172
- yield migrator.resetAll();
173
- });
628
+ async function migrate_check() {
629
+ await setupMigrator();
630
+ await migrator.cleanUpDist();
631
+ await migrator.check();
174
632
  }
175
- function fixture_init() {
176
- var _a, e_1, _b, _c;
177
- var _d;
178
- return __awaiter(this, void 0, void 0, function* () {
179
- const srcConfig = api_1.Sonamu.dbConfig.development_master;
180
- const targets = [
181
- {
182
- label: "(REMOTE) Fixture DB",
183
- config: api_1.Sonamu.dbConfig.fixture_remote,
184
- },
185
- {
186
- label: "(LOCAL) Fixture DB",
187
- config: api_1.Sonamu.dbConfig.fixture_local,
188
- toSkip: (() => {
189
- const remoteConn = api_1.Sonamu.dbConfig.fixture_remote
190
- .connection;
191
- const localConn = api_1.Sonamu.dbConfig.fixture_local
192
- .connection;
193
- return (remoteConn.host === localConn.host &&
194
- remoteConn.database === localConn.database);
195
- })(),
196
- },
197
- {
198
- label: "(LOCAL) Testing DB",
199
- config: api_1.Sonamu.dbConfig.test,
200
- },
201
- ];
202
- // 1. 기준DB 스키마를 덤프
203
- console.log("DUMP...");
204
- const dumpFilename = `/tmp/sonamu-fixture-init-${Date.now()}.sql`;
205
- const srcConn = srcConfig.connection;
206
- (0, child_process_1.execSync)(`mysqldump -h${srcConn.host} -u${srcConn.user} -p${srcConn.password} --single-transaction -d --no-create-db --triggers ${srcConn.database} > ${dumpFilename}`);
207
- try {
208
- // 2. 대상DB 각각에 대하여 존재여부 확인 후 붓기
209
- for (var _e = true, targets_1 = __asyncValues(targets), targets_1_1; targets_1_1 = yield targets_1.next(), _a = targets_1_1.done, !_a; _e = true) {
210
- _c = targets_1_1.value;
211
- _e = false;
212
- const { label, config, toSkip } = _c;
213
- const conn = config.connection;
214
- if (toSkip === true) {
215
- console.log(chalk_1.default.red(`${label}: Skipped!`));
216
- continue;
217
- }
218
- const db = (0, knex_1.default)(Object.assign(Object.assign({}, config), { connection: Object.assign(Object.assign({}, ((_d = config.connection) !== null && _d !== void 0 ? _d : {})), { database: undefined }) }));
219
- const [[row]] = yield db.raw(`SHOW DATABASES LIKE "${conn.database}"`);
220
- if (row) {
221
- console.log(chalk_1.default.yellow(`${label}: Database "${conn.database}" Already exists`));
222
- yield db.destroy();
223
- continue;
224
- }
225
- console.log(`SYNC to ${label}...`);
226
- const mysqlCmd = `mysql -h${conn.host} -u${conn.user} -p${conn.password}`;
227
- (0, child_process_1.execSync)(`${mysqlCmd} -e 'DROP DATABASE IF EXISTS \`${conn.database}\`'`);
228
- (0, child_process_1.execSync)(`${mysqlCmd} -e 'CREATE DATABASE \`${conn.database}\`'`);
229
- (0, child_process_1.execSync)(`${mysqlCmd} ${conn.database} < ${dumpFilename}`);
230
- // 3. knex migration 정보 복사
231
- yield Promise.all(["knex_migrations", "knex_migrations_lock"].map((tableName) => __awaiter(this, void 0, void 0, function* () {
232
- const [table] = yield db.raw(`SHOW TABLES FROM \`${srcConn.database}\` LIKE '${tableName}'`);
233
- if (table === null || table === void 0 ? void 0 : table.length) {
234
- yield db.raw(`INSERT INTO \`${conn.database}\`.${tableName}
235
- SELECT * FROM \`${srcConn.database}\`.${tableName}`);
236
- }
237
- })));
238
- yield db.destroy();
239
- }
240
- }
241
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
242
- finally {
243
- try {
244
- if (!_e && !_a && (_b = targets_1.return)) yield _b.call(targets_1);
245
- }
246
- finally { if (e_1) throw e_1.error; }
247
- }
248
- });
633
+ async function migrate_rollback() {
634
+ await setupMigrator();
635
+ await migrator.rollback();
249
636
  }
250
- function fixture_import(entityId, recordIds) {
251
- return __awaiter(this, void 0, void 0, function* () {
252
- yield setupFixtureManager();
253
- yield fixture_manager_1.FixtureManager.importFixture(entityId, recordIds);
254
- yield fixture_manager_1.FixtureManager.sync();
255
- });
637
+ async function migrate_clear() {
638
+ await setupMigrator();
639
+ await migrator.clearPendingList();
256
640
  }
257
- function fixture_sync() {
258
- return __awaiter(this, void 0, void 0, function* () {
259
- yield setupFixtureManager();
260
- yield fixture_manager_1.FixtureManager.sync();
261
- });
641
+ async function migrate_reset() {
642
+ await setupMigrator();
643
+ await migrator.resetAll();
262
644
  }
263
- function stub_practice(name) {
264
- return __awaiter(this, void 0, void 0, function* () {
265
- const practiceDir = path_1.default.join(api_1.Sonamu.apiRootPath, "src", "practices");
266
- const fileNames = fs_extra_1.default.readdirSync(practiceDir);
267
- const maxSeqNo = (() => {
268
- if (fs_extra_1.default.existsSync(practiceDir) === false) {
269
- fs_extra_1.default.mkdirSync(practiceDir, { recursive: true });
270
- }
271
- const filteredSeqs = fileNames
272
- .filter((fileName) => fileName.startsWith("p") && fileName.endsWith(".ts"))
273
- .map((fileName) => {
274
- var _a;
275
- const [, seqNo] = (_a = fileName.match(/^p([0-9]+)\-/)) !== null && _a !== void 0 ? _a : ["0", "0"];
276
- return parseInt(seqNo);
277
- })
278
- .sort((a, b) => b - a);
279
- if (filteredSeqs.length > 0) {
280
- return filteredSeqs[0];
281
- }
282
- return 0;
283
- })();
284
- const currentSeqNo = maxSeqNo + 1;
285
- const fileName = `p${currentSeqNo}-${name}.ts`;
286
- const dstPath = path_1.default.join(practiceDir, fileName);
287
- const code = [
288
- `import { BaseModel } from "sonamu";`,
289
- "",
290
- `console.clear();`,
291
- `console.log("${fileName}");`,
292
- "",
293
- `async function bootstrap() {`,
294
- ` // TODO`,
295
- `}`,
296
- `bootstrap().finally(async () => {`,
297
- `await BaseModel.destroy();`,
298
- `});`,
299
- ].join("\n");
300
- fs_extra_1.default.writeFileSync(dstPath, code);
301
- (0, child_process_1.execSync)(`code ${dstPath}`);
302
- const runCode = `yarn node -r source-map-support/register dist/practices/${fileName.replace(".ts", ".js")}`;
303
- console.log(`${chalk_1.default.blue(runCode)} copied to clipboard.`);
304
- (0, child_process_1.execSync)(`echo "${runCode}" | pbcopy`);
645
+ async function fixture_init() {
646
+ const srcConfig = _chunkBPT5ZXMXjs.Sonamu.dbConfig.development_master;
647
+ const targets = [
648
+ {
649
+ label: "(REMOTE) Fixture DB",
650
+ config: _chunkBPT5ZXMXjs.Sonamu.dbConfig.fixture_remote
651
+ },
652
+ {
653
+ label: "(LOCAL) Fixture DB",
654
+ config: _chunkBPT5ZXMXjs.Sonamu.dbConfig.fixture_local,
655
+ toSkip: (() => {
656
+ const remoteConn = _chunkBPT5ZXMXjs.Sonamu.dbConfig.fixture_remote.connection;
657
+ const localConn = _chunkBPT5ZXMXjs.Sonamu.dbConfig.fixture_local.connection;
658
+ return remoteConn.host === localConn.host && remoteConn.database === localConn.database;
659
+ })()
660
+ },
661
+ {
662
+ label: "(LOCAL) Testing DB",
663
+ config: _chunkBPT5ZXMXjs.Sonamu.dbConfig.test
664
+ }
665
+ ];
666
+ console.log("DUMP...");
667
+ const dumpFilename = `/tmp/sonamu-fixture-init-${Date.now()}.sql`;
668
+ const srcConn = srcConfig.connection;
669
+ _child_process.execSync.call(void 0,
670
+ `mysqldump -h${srcConn.host} -u${srcConn.user} -p${srcConn.password} --single-transaction -d --no-create-db --triggers ${srcConn.database} > ${dumpFilename}`
671
+ );
672
+ for await (const { label, config, toSkip } of targets) {
673
+ const conn = config.connection;
674
+ if (toSkip === true) {
675
+ console.log(_chalk2.default.red(`${label}: Skipped!`));
676
+ continue;
677
+ }
678
+ const db = _knex2.default.call(void 0, {
679
+ ...config,
680
+ connection: {
681
+ ..._nullishCoalesce(config.connection, () => ( {})),
682
+ database: void 0
683
+ }
305
684
  });
685
+ const [[row]] = await db.raw(`SHOW DATABASES LIKE "${conn.database}"`);
686
+ if (row) {
687
+ console.log(
688
+ _chalk2.default.yellow(`${label}: Database "${conn.database}" Already exists`)
689
+ );
690
+ await db.destroy();
691
+ continue;
692
+ }
693
+ console.log(`SYNC to ${label}...`);
694
+ const mysqlCmd = `mysql -h${conn.host} -u${conn.user} -p${conn.password}`;
695
+ _child_process.execSync.call(void 0, `${mysqlCmd} -e 'DROP DATABASE IF EXISTS \`${conn.database}\`'`);
696
+ _child_process.execSync.call(void 0, `${mysqlCmd} -e 'CREATE DATABASE \`${conn.database}\`'`);
697
+ _child_process.execSync.call(void 0, `${mysqlCmd} ${conn.database} < ${dumpFilename}`);
698
+ await Promise.all(
699
+ ["knex_migrations", "knex_migrations_lock"].map(async (tableName) => {
700
+ const [table] = await db.raw(
701
+ `SHOW TABLES FROM \`${srcConn.database}\` LIKE '${tableName}'`
702
+ );
703
+ if (_optionalChain([table, 'optionalAccess', _2 => _2.length])) {
704
+ await db.raw(
705
+ `INSERT INTO \`${conn.database}\`.${tableName}
706
+ SELECT * FROM \`${srcConn.database}\`.${tableName}`
707
+ );
708
+ }
709
+ })
710
+ );
711
+ await db.destroy();
712
+ }
306
713
  }
307
- function stub_entity(entityId) {
308
- return __awaiter(this, void 0, void 0, function* () {
309
- yield api_1.Sonamu.syncer.createEntity(entityId);
310
- });
714
+ async function fixture_import(entityId, recordIds) {
715
+ await setupFixtureManager();
716
+ await _chunkBPT5ZXMXjs.FixtureManager.importFixture(entityId, recordIds);
717
+ await _chunkBPT5ZXMXjs.FixtureManager.sync();
311
718
  }
312
- function scaffold_model(entityId) {
313
- return __awaiter(this, void 0, void 0, function* () {
314
- yield api_1.Sonamu.syncer.generateTemplate("model", {
315
- entityId,
316
- });
317
- });
719
+ async function fixture_sync() {
720
+ await setupFixtureManager();
721
+ await _chunkBPT5ZXMXjs.FixtureManager.sync();
318
722
  }
319
- function scaffold_model_test(entityId) {
320
- return __awaiter(this, void 0, void 0, function* () {
321
- yield api_1.Sonamu.syncer.generateTemplate("model_test", {
322
- entityId,
323
- });
324
- });
723
+ async function stub_practice(name) {
724
+ const practiceDir = _path2.default.join(_chunkBPT5ZXMXjs.Sonamu.apiRootPath, "src", "practices");
725
+ const fileNames = _fsextra2.default.readdirSync(practiceDir);
726
+ const maxSeqNo = (() => {
727
+ if (_fsextra2.default.existsSync(practiceDir) === false) {
728
+ _fsextra2.default.mkdirSync(practiceDir, { recursive: true });
729
+ }
730
+ const filteredSeqs = fileNames.filter(
731
+ (fileName2) => fileName2.startsWith("p") && fileName2.endsWith(".ts")
732
+ ).map((fileName2) => {
733
+ const [, seqNo] = _nullishCoalesce(fileName2.match(/^p([0-9]+)\-/), () => ( ["0", "0"]));
734
+ return parseInt(seqNo);
735
+ }).sort((a, b) => b - a);
736
+ if (filteredSeqs.length > 0) {
737
+ return filteredSeqs[0];
738
+ }
739
+ return 0;
740
+ })();
741
+ const currentSeqNo = maxSeqNo + 1;
742
+ const fileName = `p${currentSeqNo}-${name}.ts`;
743
+ const dstPath = _path2.default.join(practiceDir, fileName);
744
+ const code = [
745
+ `import { BaseModel } from "sonamu";`,
746
+ "",
747
+ `console.clear();`,
748
+ `console.log("${fileName}");`,
749
+ "",
750
+ `async function bootstrap() {`,
751
+ ` // TODO`,
752
+ `}`,
753
+ `bootstrap().finally(async () => {`,
754
+ `await BaseModel.destroy();`,
755
+ `});`
756
+ ].join("\n");
757
+ _fsextra2.default.writeFileSync(dstPath, code);
758
+ _child_process.execSync.call(void 0, `code ${dstPath}`);
759
+ const runCode = `yarn node -r source-map-support/register dist/practices/${fileName.replace(
760
+ ".ts",
761
+ ".js"
762
+ )}`;
763
+ console.log(`${_chalk2.default.blue(runCode)} copied to clipboard.`);
764
+ _child_process.execSync.call(void 0, `echo "${runCode}" | pbcopy`);
325
765
  }
326
- function ui() {
327
- return __awaiter(this, void 0, void 0, function* () {
328
- try {
329
- const sonamuUI = yield Promise.resolve(`${"@sonamu-kit/ui"}`).then(s => __importStar(require(s)));
330
- sonamuUI.startServers(api_1.Sonamu.apiRootPath);
331
- }
332
- catch (e) {
333
- if (e instanceof Error && e.message.includes("isn't declared")) {
334
- console.log(`You need to install ${chalk_1.default.blue(`@sonamu-kit/ui`)} first.`);
335
- return;
336
- }
337
- throw e;
338
- }
339
- });
766
+ async function stub_entity(entityId) {
767
+ await _chunkBPT5ZXMXjs.Sonamu.syncer.createEntity(entityId);
340
768
  }
341
- function smd_migration() {
342
- var _a, e_2, _b, _c, _d, e_3, _e, _f;
343
- var _g;
344
- return __awaiter(this, void 0, void 0, function* () {
345
- yield smd_manager_1.SMDManager.autoload();
346
- const smdIds = smd_manager_1.SMDManager.getAllIds();
347
- function enumLabelsToEntityEnums(entityId, enumLabels) {
348
- return Object.fromEntries(Object.entries(enumLabels).map(([enumLabelName, enumLabel]) => {
349
- const enumName = entityId + inflection_1.default.camelize(enumLabelName.toLowerCase(), false);
350
- return [
351
- enumName,
352
- Object.fromEntries(Object.entries(enumLabel).map(([name, { ko }]) => [name, ko])),
353
- ];
354
- }));
355
- }
356
- try {
357
- for (var _h = true, smdIds_1 = __asyncValues(smdIds), smdIds_1_1; smdIds_1_1 = yield smdIds_1.next(), _a = smdIds_1_1.done, !_a; _h = true) {
358
- _c = smdIds_1_1.value;
359
- _h = false;
360
- const smdId = _c;
361
- const smd = smd_manager_1.SMDManager.get(smdId);
362
- const entityJson = Object.assign(Object.assign({ id: smd.id }, (smd.parentId && { parentId: smd.parentId })), { title: smd.title, props: smd.props, indexes: smd.indexes, subsets: smd.subsets, enums: enumLabelsToEntityEnums(smd.id, smd.enumLabels) });
363
- const parentNames = smd_manager_1.SMDManager.getNamesFromId((_g = smd.parentId) !== null && _g !== void 0 ? _g : smd.id);
364
- const names = smd_manager_1.SMDManager.getNamesFromId(smd.id);
365
- const dstPath = path_1.default.join(api_1.Sonamu.apiRootPath, "src", "application", parentNames.fs, `${names.fs}.entity.json`);
366
- const formatted = yield prettier_1.default.format(JSON.stringify(entityJson), {
367
- parser: "json",
368
- });
369
- fs_extra_1.default.writeFileSync(dstPath, formatted);
370
- console.log(chalk_1.default.blue(`CREATED: ${dstPath}`));
371
- // smd.ts, enums.ts, genereated.ts 삭제 (트랜스파일 된 js파일도 삭제)
372
- const srcSmdPath = path_1.default.join(api_1.Sonamu.apiRootPath, "src", "application", parentNames.fs, `${names.fs}.smd.ts`);
373
- const dstSmdPath = srcSmdPath
374
- .replace("/src/", "/dist/")
375
- .replace(/\.ts$/, ".js");
376
- const srcEnumsPath = path_1.default.join(api_1.Sonamu.apiRootPath, "src", "application", parentNames.fs, `${names.fs}.enums.ts`);
377
- const dstEnumsPath = srcEnumsPath
378
- .replace("/src/", "/dist/")
379
- .replace(/\.ts$/, ".js");
380
- const srcGeneratedPath = path_1.default.join(api_1.Sonamu.apiRootPath, "src", "application", parentNames.fs, `${names.fs}.generated.ts`);
381
- const dstGeneratedPath = srcGeneratedPath
382
- .replace("/src/", "/dist/")
383
- .replace(/\.ts$/, ".js");
384
- [
385
- srcSmdPath,
386
- dstSmdPath,
387
- srcEnumsPath,
388
- dstEnumsPath,
389
- ...api_1.Sonamu.config.sync.targets.map((target) => srcEnumsPath
390
- .replace(api_1.Sonamu.apiRootPath, path_1.default.join(api_1.Sonamu.appRootPath, target))
391
- .replace("/src/application/", "/src/services/")),
392
- srcGeneratedPath,
393
- dstGeneratedPath,
394
- ].map((p) => {
395
- if (fs_extra_1.default.existsSync(p) === false) {
396
- console.log(chalk_1.default.yellow(`NOT FOUND: ${p}`));
397
- return;
398
- }
399
- fs_extra_1.default.unlinkSync(p);
400
- console.log(chalk_1.default.red(`DELETED: ${p}`));
401
- });
402
- }
403
- }
404
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
405
- finally {
406
- try {
407
- if (!_h && !_a && (_b = smdIds_1.return)) yield _b.call(smdIds_1);
408
- }
409
- finally { if (e_2) throw e_2.error; }
410
- }
411
- // Entity로 reload
412
- console.log("Entity로 다시 로드합니다.");
413
- entity_manager_1.EntityManager.isAutoloaded = false;
414
- yield entity_manager_1.EntityManager.autoload();
415
- // Entity를 통해 generated.ts 재생성
416
- const entityIds = entity_manager_1.EntityManager.getAllParentIds();
417
- try {
418
- for (var _j = true, entityIds_1 = __asyncValues(entityIds), entityIds_1_1; entityIds_1_1 = yield entityIds_1.next(), _d = entityIds_1_1.done, !_d; _j = true) {
419
- _f = entityIds_1_1.value;
420
- _j = false;
421
- const entityId = _f;
422
- yield api_1.Sonamu.syncer.generateTemplate("generated", { entityId });
423
- }
424
- }
425
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
426
- finally {
427
- try {
428
- if (!_j && !_d && (_e = entityIds_1.return)) yield _e.call(entityIds_1);
429
- }
430
- finally { if (e_3) throw e_3.error; }
431
- }
769
+ async function scaffold_model(entityId) {
770
+ await _chunkBPT5ZXMXjs.Sonamu.syncer.generateTemplate("model", {
771
+ entityId
772
+ });
773
+ }
774
+ async function scaffold_model_test(entityId) {
775
+ await _chunkBPT5ZXMXjs.Sonamu.syncer.generateTemplate("model_test", {
776
+ entityId
777
+ });
778
+ }
779
+ async function ui() {
780
+ try {
781
+ const sonamuUI = await Promise.resolve().then(() => _interopRequireWildcard(require("@sonamu-kit/ui")));
782
+ sonamuUI.startServers(_chunkBPT5ZXMXjs.Sonamu.apiRootPath);
783
+ } catch (e) {
784
+ if (e instanceof Error && e.message.includes("isn't declared")) {
785
+ console.log(`You need to install ${_chalk2.default.blue(`@sonamu-kit/ui`)} first.`);
786
+ return;
787
+ }
788
+ throw e;
789
+ }
790
+ }
791
+ async function smd_migration() {
792
+ await SMDManager.autoload();
793
+ const smdIds = SMDManager.getAllIds();
794
+ function enumLabelsToEntityEnums(entityId, enumLabels) {
795
+ return Object.fromEntries(
796
+ Object.entries(enumLabels).map(([enumLabelName, enumLabel]) => {
797
+ const enumName = entityId + _inflection2.default.camelize(enumLabelName.toLowerCase(), false);
798
+ return [
799
+ enumName,
800
+ Object.fromEntries(
801
+ Object.entries(enumLabel).map(([name, { ko }]) => [name, ko])
802
+ )
803
+ ];
804
+ })
805
+ );
806
+ }
807
+ for await (const smdId of smdIds) {
808
+ const smd = SMDManager.get(smdId);
809
+ const entityJson = {
810
+ id: smd.id,
811
+ ...smd.parentId && { parentId: smd.parentId },
812
+ title: smd.title,
813
+ props: smd.props,
814
+ indexes: smd.indexes,
815
+ subsets: smd.subsets,
816
+ enums: enumLabelsToEntityEnums(smd.id, smd.enumLabels)
817
+ };
818
+ const parentNames = SMDManager.getNamesFromId(_nullishCoalesce(smd.parentId, () => ( smd.id)));
819
+ const names = SMDManager.getNamesFromId(smd.id);
820
+ const dstPath = _path2.default.join(
821
+ _chunkBPT5ZXMXjs.Sonamu.apiRootPath,
822
+ "src",
823
+ "application",
824
+ parentNames.fs,
825
+ `${names.fs}.entity.json`
826
+ );
827
+ const formatted = await _prettier2.default.format(JSON.stringify(entityJson), {
828
+ parser: "json"
829
+ });
830
+ _fsextra2.default.writeFileSync(dstPath, formatted);
831
+ console.log(_chalk2.default.blue(`CREATED: ${dstPath}`));
832
+ const srcSmdPath = _path2.default.join(
833
+ _chunkBPT5ZXMXjs.Sonamu.apiRootPath,
834
+ "src",
835
+ "application",
836
+ parentNames.fs,
837
+ `${names.fs}.smd.ts`
838
+ );
839
+ const dstSmdPath = srcSmdPath.replace("/src/", "/dist/").replace(/\.ts$/, ".js");
840
+ const srcEnumsPath = _path2.default.join(
841
+ _chunkBPT5ZXMXjs.Sonamu.apiRootPath,
842
+ "src",
843
+ "application",
844
+ parentNames.fs,
845
+ `${names.fs}.enums.ts`
846
+ );
847
+ const dstEnumsPath = srcEnumsPath.replace("/src/", "/dist/").replace(/\.ts$/, ".js");
848
+ const srcGeneratedPath = _path2.default.join(
849
+ _chunkBPT5ZXMXjs.Sonamu.apiRootPath,
850
+ "src",
851
+ "application",
852
+ parentNames.fs,
853
+ `${names.fs}.generated.ts`
854
+ );
855
+ const dstGeneratedPath = srcGeneratedPath.replace("/src/", "/dist/").replace(/\.ts$/, ".js");
856
+ [
857
+ srcSmdPath,
858
+ dstSmdPath,
859
+ srcEnumsPath,
860
+ dstEnumsPath,
861
+ ..._chunkBPT5ZXMXjs.Sonamu.config.sync.targets.map(
862
+ (target) => srcEnumsPath.replace(_chunkBPT5ZXMXjs.Sonamu.apiRootPath, _path2.default.join(_chunkBPT5ZXMXjs.Sonamu.appRootPath, target)).replace("/src/application/", "/src/services/")
863
+ ),
864
+ srcGeneratedPath,
865
+ dstGeneratedPath
866
+ ].map((p) => {
867
+ if (_fsextra2.default.existsSync(p) === false) {
868
+ console.log(_chalk2.default.yellow(`NOT FOUND: ${p}`));
869
+ return;
870
+ }
871
+ _fsextra2.default.unlinkSync(p);
872
+ console.log(_chalk2.default.red(`DELETED: ${p}`));
432
873
  });
874
+ }
875
+ console.log("Entity\uB85C \uB2E4\uC2DC \uB85C\uB4DC\uD569\uB2C8\uB2E4.");
876
+ _chunkBPT5ZXMXjs.EntityManager.isAutoloaded = false;
877
+ await _chunkBPT5ZXMXjs.EntityManager.autoload();
878
+ const entityIds = _chunkBPT5ZXMXjs.EntityManager.getAllParentIds();
879
+ for await (const entityId of entityIds) {
880
+ await _chunkBPT5ZXMXjs.Sonamu.syncer.generateTemplate("generated", { entityId });
881
+ }
433
882
  }
434
883
  //# sourceMappingURL=cli.js.map