sonamu 0.5.7 → 0.7.0

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 (529) hide show
  1. package/.swcrc.project-default +18 -0
  2. package/bin/cli.js +24 -0
  3. package/dist/ai/agents/agent.d.ts +11 -0
  4. package/dist/ai/agents/agent.d.ts.map +1 -0
  5. package/dist/ai/agents/agent.js +65 -0
  6. package/dist/ai/agents/index.d.ts +3 -0
  7. package/dist/ai/agents/index.d.ts.map +1 -0
  8. package/dist/ai/agents/index.js +4 -0
  9. package/dist/ai/agents/types.d.ts +43 -0
  10. package/dist/ai/agents/types.d.ts.map +1 -0
  11. package/dist/ai/agents/types.js +3 -0
  12. package/dist/ai/index.d.ts +2 -0
  13. package/dist/ai/index.d.ts.map +1 -0
  14. package/dist/ai/index.js +3 -0
  15. package/dist/ai/providers/rtzr/api.d.ts +22 -0
  16. package/dist/ai/providers/rtzr/api.d.ts.map +1 -0
  17. package/dist/ai/providers/rtzr/api.js +28 -0
  18. package/dist/ai/providers/rtzr/error.d.ts +18 -0
  19. package/dist/ai/providers/rtzr/error.d.ts.map +1 -0
  20. package/dist/ai/providers/rtzr/error.js +29 -0
  21. package/dist/ai/providers/rtzr/index.d.ts +5 -0
  22. package/dist/ai/providers/rtzr/index.d.ts.map +1 -0
  23. package/dist/ai/providers/rtzr/index.js +6 -0
  24. package/dist/ai/providers/rtzr/model.d.ts +52 -0
  25. package/dist/ai/providers/rtzr/model.d.ts.map +1 -0
  26. package/dist/ai/providers/rtzr/model.js +137 -0
  27. package/dist/ai/providers/rtzr/options.d.ts +7 -0
  28. package/dist/ai/providers/rtzr/options.d.ts.map +1 -0
  29. package/dist/ai/providers/rtzr/options.js +47 -0
  30. package/dist/ai/providers/rtzr/provider.d.ts +18 -0
  31. package/dist/ai/providers/rtzr/provider.d.ts.map +1 -0
  32. package/dist/ai/providers/rtzr/provider.js +54 -0
  33. package/dist/ai/providers/rtzr/utils.d.ts +19 -0
  34. package/dist/ai/providers/rtzr/utils.d.ts.map +1 -0
  35. package/dist/ai/providers/rtzr/utils.js +88 -0
  36. package/dist/api/base-frame.d.ts +2 -2
  37. package/dist/api/base-frame.d.ts.map +1 -1
  38. package/dist/api/base-frame.js +13 -2
  39. package/dist/api/caster.d.ts.map +1 -1
  40. package/dist/api/caster.js +71 -2
  41. package/dist/api/code-converters.d.ts +58 -14
  42. package/dist/api/code-converters.d.ts.map +1 -1
  43. package/dist/api/code-converters.js +258 -2
  44. package/dist/api/config.d.ts +90 -0
  45. package/dist/api/config.d.ts.map +1 -0
  46. package/dist/api/config.js +25 -0
  47. package/dist/api/context.d.ts +4 -2
  48. package/dist/api/context.d.ts.map +1 -1
  49. package/dist/api/context.js +3 -2
  50. package/dist/api/decorators.d.ts +20 -6
  51. package/dist/api/decorators.d.ts.map +1 -1
  52. package/dist/api/decorators.js +235 -2
  53. package/dist/api/index.d.ts +2 -2
  54. package/dist/api/index.d.ts.map +1 -1
  55. package/dist/api/index.js +9 -2
  56. package/dist/api/sonamu.d.ts +10 -24
  57. package/dist/api/sonamu.d.ts.map +1 -1
  58. package/dist/api/sonamu.js +514 -2
  59. package/dist/api/validator.d.ts +6 -0
  60. package/dist/api/validator.d.ts.map +1 -0
  61. package/dist/api/validator.js +81 -0
  62. package/dist/bin/build-config.d.ts +6 -1
  63. package/dist/bin/build-config.d.ts.map +1 -1
  64. package/dist/bin/build-config.js +15 -2
  65. package/dist/bin/cli.js +519 -2
  66. package/dist/bin/hot-hook-register.d.ts +11 -0
  67. package/dist/bin/hot-hook-register.d.ts.map +1 -0
  68. package/dist/bin/hot-hook-register.js +21 -0
  69. package/dist/bin/loader-register.d.ts +2 -0
  70. package/dist/bin/loader-register.d.ts.map +1 -0
  71. package/dist/bin/loader-register.js +34 -0
  72. package/dist/database/_batch_update.d.ts +5 -3
  73. package/dist/database/_batch_update.d.ts.map +1 -1
  74. package/dist/database/_batch_update.js +95 -2
  75. package/dist/database/base-model.d.ts +96 -10
  76. package/dist/database/base-model.d.ts.map +1 -1
  77. package/dist/database/base-model.js +390 -2
  78. package/dist/database/base-model.types.d.ts +93 -0
  79. package/dist/database/base-model.types.d.ts.map +1 -0
  80. package/dist/database/base-model.types.js +10 -0
  81. package/dist/database/code-generator.d.ts +1 -1
  82. package/dist/database/code-generator.d.ts.map +1 -1
  83. package/dist/database/code-generator.js +54 -2
  84. package/dist/database/db.d.ts +6 -21
  85. package/dist/database/db.d.ts.map +1 -1
  86. package/dist/database/db.js +129 -2
  87. package/dist/database/puri-subset.test-d.js +81 -0
  88. package/dist/database/puri-subset.types.d.ts +123 -0
  89. package/dist/database/puri-subset.types.d.ts.map +1 -0
  90. package/dist/database/puri-subset.types.js +16 -0
  91. package/dist/database/puri-wrapper.d.ts +13 -11
  92. package/dist/database/puri-wrapper.d.ts.map +1 -1
  93. package/dist/database/puri-wrapper.js +109 -2
  94. package/dist/database/puri.d.ts +41 -23
  95. package/dist/database/puri.d.ts.map +1 -1
  96. package/dist/database/puri.js +601 -2
  97. package/dist/database/puri.types.d.ts +25 -6
  98. package/dist/database/puri.types.d.ts.map +1 -1
  99. package/dist/database/puri.types.js +6 -2
  100. package/dist/database/transaction-context.d.ts +1 -1
  101. package/dist/database/transaction-context.d.ts.map +1 -1
  102. package/dist/database/transaction-context.js +14 -2
  103. package/dist/database/upsert-builder.d.ts +9 -3
  104. package/dist/database/upsert-builder.d.ts.map +1 -1
  105. package/dist/database/upsert-builder.js +365 -2
  106. package/dist/entity/entity-manager.d.ts +167 -2
  107. package/dist/entity/entity-manager.d.ts.map +1 -1
  108. package/dist/entity/entity-manager.js +130 -2
  109. package/dist/entity/entity.d.ts +5 -3
  110. package/dist/entity/entity.d.ts.map +1 -1
  111. package/dist/entity/entity.js +750 -2
  112. package/dist/exceptions/error-handler.d.ts +1 -1
  113. package/dist/exceptions/error-handler.d.ts.map +1 -1
  114. package/dist/exceptions/error-handler.js +29 -2
  115. package/dist/exceptions/so-exceptions.d.ts +1 -1
  116. package/dist/exceptions/so-exceptions.d.ts.map +1 -1
  117. package/dist/exceptions/so-exceptions.js +85 -2
  118. package/dist/file-storage/driver.d.ts +1 -1
  119. package/dist/file-storage/driver.d.ts.map +1 -1
  120. package/dist/file-storage/driver.js +79 -2
  121. package/dist/file-storage/file-storage.js +75 -2
  122. package/dist/index.d.ts +18 -9
  123. package/dist/index.d.ts.map +1 -1
  124. package/dist/index.js +34 -2
  125. package/dist/migration/code-generation.d.ts +1 -1
  126. package/dist/migration/code-generation.d.ts.map +1 -1
  127. package/dist/migration/code-generation.js +614 -2
  128. package/dist/migration/migration-set.d.ts +2 -10
  129. package/dist/migration/migration-set.d.ts.map +1 -1
  130. package/dist/migration/migration-set.js +213 -2
  131. package/dist/migration/migrator.d.ts +24 -82
  132. package/dist/migration/migrator.d.ts.map +1 -1
  133. package/dist/migration/migrator.js +330 -2
  134. package/dist/migration/postgresql-schema-reader.d.ts +51 -0
  135. package/dist/migration/postgresql-schema-reader.d.ts.map +1 -0
  136. package/dist/migration/postgresql-schema-reader.js +245 -0
  137. package/dist/migration/types.d.ts +6 -38
  138. package/dist/migration/types.d.ts.map +1 -1
  139. package/dist/migration/types.js +3 -2
  140. package/dist/naite/messaging-types.d.ts +43 -0
  141. package/dist/naite/messaging-types.d.ts.map +1 -0
  142. package/dist/naite/messaging-types.js +7 -0
  143. package/dist/naite/naite-reporter.d.ts +41 -0
  144. package/dist/naite/naite-reporter.d.ts.map +1 -0
  145. package/dist/naite/naite-reporter.js +102 -0
  146. package/dist/naite/naite.d.ts +95 -0
  147. package/dist/naite/naite.d.ts.map +1 -0
  148. package/dist/naite/naite.js +316 -0
  149. package/dist/stream/index.js +3 -2
  150. package/dist/stream/sse.d.ts +2 -2
  151. package/dist/stream/sse.d.ts.map +1 -1
  152. package/dist/stream/sse.js +38 -2
  153. package/dist/syncer/api-parser.d.ts +10 -0
  154. package/dist/syncer/api-parser.d.ts.map +1 -0
  155. package/dist/syncer/api-parser.js +240 -0
  156. package/dist/syncer/checksum.d.ts +21 -0
  157. package/dist/syncer/checksum.d.ts.map +1 -0
  158. package/dist/syncer/checksum.js +98 -0
  159. package/dist/syncer/code-generator.d.ts +20 -0
  160. package/dist/syncer/code-generator.d.ts.map +1 -0
  161. package/dist/syncer/code-generator.js +161 -0
  162. package/dist/syncer/entity-operations.d.ts +17 -0
  163. package/dist/syncer/entity-operations.d.ts.map +1 -0
  164. package/dist/syncer/entity-operations.js +59 -0
  165. package/dist/syncer/file-patterns.d.ts +29 -0
  166. package/dist/syncer/file-patterns.d.ts.map +1 -0
  167. package/dist/syncer/file-patterns.js +38 -0
  168. package/dist/syncer/index.d.ts +6 -0
  169. package/dist/syncer/index.d.ts.map +1 -1
  170. package/dist/syncer/index.js +9 -2
  171. package/dist/syncer/module-loader.d.ts +35 -0
  172. package/dist/syncer/module-loader.d.ts.map +1 -0
  173. package/dist/syncer/module-loader.js +87 -0
  174. package/dist/syncer/syncer.d.ts +98 -106
  175. package/dist/syncer/syncer.d.ts.map +1 -1
  176. package/dist/syncer/syncer.js +422 -2
  177. package/dist/template/entity-converter.d.ts +14 -0
  178. package/dist/template/entity-converter.d.ts.map +1 -0
  179. package/dist/template/entity-converter.js +108 -0
  180. package/dist/template/helpers.d.ts +23 -0
  181. package/dist/template/helpers.d.ts.map +1 -0
  182. package/dist/template/helpers.js +64 -0
  183. package/dist/{templates → template/implementations}/entity.template.d.ts +3 -3
  184. package/dist/template/implementations/entity.template.d.ts.map +1 -0
  185. package/dist/template/implementations/entity.template.js +86 -0
  186. package/dist/{templates → template/implementations}/generated.template.d.ts +3 -4
  187. package/dist/template/implementations/generated.template.d.ts.map +1 -0
  188. package/dist/template/implementations/generated.template.js +249 -0
  189. package/dist/{templates → template/implementations}/generated_http.template.d.ts +3 -4
  190. package/dist/template/implementations/generated_http.template.d.ts.map +1 -0
  191. package/dist/template/implementations/generated_http.template.js +131 -0
  192. package/dist/{templates → template/implementations}/generated_sso.template.d.ts +4 -5
  193. package/dist/template/implementations/generated_sso.template.d.ts.map +1 -0
  194. package/dist/template/implementations/generated_sso.template.js +134 -0
  195. package/dist/{templates → template/implementations}/init_types.template.d.ts +3 -3
  196. package/dist/template/implementations/init_types.template.d.ts.map +1 -0
  197. package/dist/template/implementations/init_types.template.js +38 -0
  198. package/dist/template/implementations/model.template.d.ts +17 -0
  199. package/dist/template/implementations/model.template.d.ts.map +1 -0
  200. package/dist/template/implementations/model.template.js +181 -0
  201. package/dist/{templates → template/implementations}/model_test.template.d.ts +3 -3
  202. package/dist/template/implementations/model_test.template.d.ts.map +1 -0
  203. package/dist/template/implementations/model_test.template.js +35 -0
  204. package/dist/{templates → template/implementations}/service.template.d.ts +6 -6
  205. package/dist/template/implementations/service.template.d.ts.map +1 -0
  206. package/dist/template/implementations/service.template.js +201 -0
  207. package/dist/{templates → template/implementations}/view_enums_buttonset.template.d.ts +3 -3
  208. package/dist/template/implementations/view_enums_buttonset.template.d.ts.map +1 -0
  209. package/dist/template/implementations/view_enums_buttonset.template.js +31 -0
  210. package/dist/{templates → template/implementations}/view_enums_dropdown.template.d.ts +3 -4
  211. package/dist/template/implementations/view_enums_dropdown.template.d.ts.map +1 -0
  212. package/dist/template/implementations/view_enums_dropdown.template.js +50 -0
  213. package/dist/{templates → template/implementations}/view_enums_select.template.d.ts +3 -3
  214. package/dist/template/implementations/view_enums_select.template.d.ts.map +1 -0
  215. package/dist/template/implementations/view_enums_select.template.js +55 -0
  216. package/dist/{templates → template/implementations}/view_form.template.d.ts +5 -5
  217. package/dist/template/implementations/view_form.template.d.ts.map +1 -0
  218. package/dist/template/implementations/view_form.template.js +337 -0
  219. package/dist/{templates → template/implementations}/view_id_all_select.template.d.ts +3 -3
  220. package/dist/template/implementations/view_id_all_select.template.d.ts.map +1 -0
  221. package/dist/template/implementations/view_id_all_select.template.js +31 -0
  222. package/dist/{templates → template/implementations}/view_id_async_select.template.d.ts +3 -3
  223. package/dist/template/implementations/view_id_async_select.template.d.ts.map +1 -0
  224. package/dist/template/implementations/view_id_async_select.template.js +105 -0
  225. package/dist/{templates → template/implementations}/view_list.template.d.ts +5 -13
  226. package/dist/template/implementations/view_list.template.d.ts.map +1 -0
  227. package/dist/template/implementations/view_list.template.js +475 -0
  228. package/dist/template/implementations/view_list_columns.template.d.ts +17 -0
  229. package/dist/template/implementations/view_list_columns.template.d.ts.map +1 -0
  230. package/dist/template/implementations/view_list_columns.template.js +49 -0
  231. package/dist/{templates → template/implementations}/view_search_input.template.d.ts +3 -3
  232. package/dist/template/implementations/view_search_input.template.d.ts.map +1 -0
  233. package/dist/template/implementations/view_search_input.template.js +64 -0
  234. package/dist/template/index.d.ts +7 -0
  235. package/dist/template/index.d.ts.map +1 -0
  236. package/dist/template/index.js +8 -0
  237. package/dist/template/template-manager.d.ts +56 -0
  238. package/dist/template/template-manager.d.ts.map +1 -0
  239. package/dist/template/template-manager.js +125 -0
  240. package/dist/template/template-types.d.ts +16 -0
  241. package/dist/template/template-types.d.ts.map +1 -0
  242. package/dist/template/template-types.js +7 -0
  243. package/dist/template/template.d.ts +49 -0
  244. package/dist/template/template.d.ts.map +1 -0
  245. package/dist/template/template.js +60 -0
  246. package/dist/template/zod-converter.d.ts +51 -0
  247. package/dist/template/zod-converter.d.ts.map +1 -0
  248. package/dist/template/zod-converter.js +449 -0
  249. package/dist/testing/_relation-graph.d.ts +1 -1
  250. package/dist/testing/_relation-graph.d.ts.map +1 -1
  251. package/dist/testing/_relation-graph.js +89 -2
  252. package/dist/testing/fixture-manager.d.ts +42 -11
  253. package/dist/testing/fixture-manager.d.ts.map +1 -1
  254. package/dist/testing/fixture-manager.js +623 -2
  255. package/dist/types/types.d.ts +747 -143
  256. package/dist/types/types.d.ts.map +1 -1
  257. package/dist/types/types.js +546 -2
  258. package/dist/typings/knex.d.js +3 -2
  259. package/dist/utils/async-utils.d.ts +7 -0
  260. package/dist/utils/async-utils.d.ts.map +1 -1
  261. package/dist/utils/async-utils.js +57 -2
  262. package/dist/utils/console-util.d.ts +2 -0
  263. package/dist/utils/console-util.d.ts.map +1 -0
  264. package/dist/utils/console-util.js +6 -0
  265. package/dist/utils/controller.d.ts +1 -0
  266. package/dist/utils/controller.d.ts.map +1 -1
  267. package/dist/utils/controller.js +29 -2
  268. package/dist/utils/esm-utils.d.ts +39 -0
  269. package/dist/utils/esm-utils.d.ts.map +1 -0
  270. package/dist/utils/esm-utils.js +49 -0
  271. package/dist/utils/formatter.d.ts +3 -0
  272. package/dist/utils/formatter.d.ts.map +1 -0
  273. package/dist/utils/formatter.js +110 -0
  274. package/dist/utils/fs-utils.d.ts +1 -1
  275. package/dist/utils/fs-utils.d.ts.map +1 -1
  276. package/dist/utils/fs-utils.js +17 -2
  277. package/dist/utils/lodash-able.d.ts.map +1 -1
  278. package/dist/utils/lodash-able.js +6 -2
  279. package/dist/utils/model.js +22 -2
  280. package/dist/utils/object-utils.d.ts +44 -0
  281. package/dist/utils/object-utils.d.ts.map +1 -0
  282. package/dist/utils/object-utils.js +191 -0
  283. package/dist/utils/path-utils.d.ts +89 -0
  284. package/dist/utils/path-utils.d.ts.map +1 -0
  285. package/dist/utils/path-utils.js +60 -0
  286. package/dist/utils/process-utils.d.ts +13 -0
  287. package/dist/utils/process-utils.d.ts.map +1 -0
  288. package/dist/utils/process-utils.js +36 -0
  289. package/dist/utils/sql-parser.d.ts +5 -1
  290. package/dist/utils/sql-parser.d.ts.map +1 -1
  291. package/dist/utils/sql-parser.js +46 -2
  292. package/dist/utils/type-utils.d.ts +23 -0
  293. package/dist/utils/type-utils.d.ts.map +1 -0
  294. package/dist/utils/type-utils.js +45 -0
  295. package/dist/utils/utils.d.ts +10 -7
  296. package/dist/utils/utils.d.ts.map +1 -1
  297. package/dist/utils/utils.js +72 -2
  298. package/dist/utils/zod-error.d.ts +1 -1
  299. package/dist/utils/zod-error.d.ts.map +1 -1
  300. package/dist/utils/zod-error.js +19 -2
  301. package/package.json +65 -27
  302. package/src/ai/agents/agent.ts +87 -0
  303. package/src/ai/agents/index.ts +2 -0
  304. package/src/ai/agents/types.ts +47 -0
  305. package/src/ai/index.ts +1 -0
  306. package/src/ai/providers/rtzr/api.ts +37 -0
  307. package/src/ai/providers/rtzr/error.ts +34 -0
  308. package/src/ai/providers/rtzr/index.ts +4 -0
  309. package/src/ai/providers/rtzr/model.ts +201 -0
  310. package/src/ai/providers/rtzr/options.ts +49 -0
  311. package/src/ai/providers/rtzr/provider.ts +91 -0
  312. package/src/ai/providers/rtzr/utils.ts +127 -0
  313. package/src/api/base-frame.ts +4 -2
  314. package/src/api/caster.ts +17 -23
  315. package/src/api/code-converters.ts +178 -535
  316. package/src/api/config.ts +125 -0
  317. package/src/api/context.ts +7 -17
  318. package/src/api/decorators.ts +176 -46
  319. package/src/api/index.ts +2 -2
  320. package/src/api/sonamu.ts +190 -167
  321. package/src/api/validator.ts +83 -0
  322. package/src/bin/build-config.ts +8 -1
  323. package/src/bin/cli.ts +258 -124
  324. package/src/bin/hot-hook-register.ts +22 -0
  325. package/src/bin/loader-register.ts +38 -0
  326. package/src/database/_batch_update.ts +46 -31
  327. package/src/database/base-model.ts +390 -182
  328. package/src/database/base-model.types.ts +155 -0
  329. package/src/database/code-generator.ts +13 -32
  330. package/src/database/db.ts +40 -96
  331. package/src/database/puri-subset.test-d.ts +471 -0
  332. package/src/database/puri-subset.types.ts +195 -0
  333. package/src/database/puri-wrapper.ts +58 -67
  334. package/src/database/puri.ts +229 -148
  335. package/src/database/puri.types.ts +76 -30
  336. package/src/database/transaction-context.ts +1 -1
  337. package/src/database/upsert-builder.ts +262 -132
  338. package/src/entity/entity-manager.ts +48 -36
  339. package/src/entity/entity.ts +330 -248
  340. package/src/exceptions/error-handler.ts +3 -3
  341. package/src/exceptions/so-exceptions.ts +11 -11
  342. package/src/file-storage/driver.ts +5 -5
  343. package/src/file-storage/file-storage.ts +2 -2
  344. package/src/index.ts +18 -10
  345. package/src/migration/code-generation.ts +185 -172
  346. package/src/migration/migration-set.ts +80 -293
  347. package/src/migration/migrator.ts +199 -571
  348. package/src/migration/mysql-schema-reader.ts.txt +272 -0
  349. package/src/migration/postgresql-schema-reader.ts +310 -0
  350. package/src/migration/types.ts +6 -39
  351. package/src/naite/messaging-types.ts +51 -0
  352. package/src/naite/naite-reporter.ts +128 -0
  353. package/src/naite/naite.ts +415 -0
  354. package/src/shared/web.shared.ts.txt +20 -24
  355. package/src/stream/sse.ts +5 -5
  356. package/src/syncer/api-parser.ts +282 -0
  357. package/src/syncer/checksum.ts +140 -0
  358. package/src/syncer/code-generator.ts +198 -0
  359. package/src/syncer/entity-operations.ts +65 -0
  360. package/src/syncer/file-patterns.ts +56 -0
  361. package/src/syncer/index.ts +6 -0
  362. package/src/syncer/module-loader.ts +128 -0
  363. package/src/syncer/syncer.ts +389 -1453
  364. package/src/template/entity-converter.ts +114 -0
  365. package/src/template/helpers.ts +81 -0
  366. package/src/{templates → template/implementations}/entity.template.ts +7 -7
  367. package/src/{templates → template/implementations}/generated.template.ts +101 -101
  368. package/src/{templates → template/implementations}/generated_http.template.ts +27 -57
  369. package/src/template/implementations/generated_sso.template.ts +151 -0
  370. package/src/{templates → template/implementations}/init_types.template.ts +5 -7
  371. package/src/{templates → template/implementations}/model.template.ts +52 -43
  372. package/src/{templates → template/implementations}/model_test.template.ts +5 -5
  373. package/src/{templates → template/implementations}/service.template.ts +66 -82
  374. package/src/{templates → template/implementations}/view_enums_buttonset.template.ts +3 -3
  375. package/src/{templates → template/implementations}/view_enums_dropdown.template.ts +4 -20
  376. package/src/{templates → template/implementations}/view_enums_select.template.ts +4 -4
  377. package/src/{templates → template/implementations}/view_form.template.ts +40 -83
  378. package/src/{templates → template/implementations}/view_id_all_select.template.ts +3 -3
  379. package/src/{templates → template/implementations}/view_id_async_select.template.ts +10 -24
  380. package/src/{templates → template/implementations}/view_list.template.ts +60 -152
  381. package/src/{templates → template/implementations}/view_list_columns.template.ts +5 -11
  382. package/src/{templates → template/implementations}/view_search_input.template.ts +3 -3
  383. package/src/template/index.ts +6 -0
  384. package/src/template/template-manager.ts +166 -0
  385. package/src/template/template-types.ts +16 -0
  386. package/src/template/template.ts +105 -0
  387. package/src/template/zod-converter.ts +525 -0
  388. package/src/testing/_relation-graph.ts +18 -11
  389. package/src/testing/fixture-manager.ts +472 -359
  390. package/src/types/types.ts +553 -308
  391. package/src/typings/knex.d.ts +7 -9
  392. package/src/utils/async-utils.ts +23 -10
  393. package/src/utils/console-util.ts +4 -0
  394. package/src/utils/controller.ts +3 -0
  395. package/src/utils/esm-utils.ts +59 -0
  396. package/src/utils/formatter.ts +109 -0
  397. package/src/utils/fs-utils.ts +1 -1
  398. package/src/utils/lodash-able.ts +1 -4
  399. package/src/utils/object-utils.ts +217 -0
  400. package/src/utils/path-utils.ts +99 -0
  401. package/src/utils/process-utils.ts +46 -0
  402. package/src/utils/sql-parser.ts +23 -5
  403. package/src/utils/type-utils.ts +83 -0
  404. package/src/utils/utils.ts +66 -43
  405. package/src/utils/zod-error.ts +3 -4
  406. package/dist/api/base-frame.js.map +0 -1
  407. package/dist/api/caster.js.map +0 -1
  408. package/dist/api/code-converters.js.map +0 -1
  409. package/dist/api/context.js.map +0 -1
  410. package/dist/api/decorators.js.map +0 -1
  411. package/dist/api/index.js.map +0 -1
  412. package/dist/api/sonamu.js.map +0 -1
  413. package/dist/bin/build-config.js.map +0 -1
  414. package/dist/bin/cli-wrapper.d.ts +0 -3
  415. package/dist/bin/cli-wrapper.d.ts.map +0 -1
  416. package/dist/bin/cli-wrapper.js +0 -3
  417. package/dist/bin/cli-wrapper.js.map +0 -1
  418. package/dist/bin/cli.js.map +0 -1
  419. package/dist/database/_batch_update.js.map +0 -1
  420. package/dist/database/base-model.js.map +0 -1
  421. package/dist/database/code-generator.js.map +0 -1
  422. package/dist/database/db.js.map +0 -1
  423. package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts +0 -2
  424. package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts.map +0 -1
  425. package/dist/database/knex-plugins/knex-on-duplicate-update.js +0 -2
  426. package/dist/database/knex-plugins/knex-on-duplicate-update.js.map +0 -1
  427. package/dist/database/puri-wrapper.js.map +0 -1
  428. package/dist/database/puri.js.map +0 -1
  429. package/dist/database/puri.types.js.map +0 -1
  430. package/dist/database/transaction-context.js.map +0 -1
  431. package/dist/database/upsert-builder.js.map +0 -1
  432. package/dist/entity/entity-manager.js.map +0 -1
  433. package/dist/entity/entity-utils.d.ts +0 -61
  434. package/dist/entity/entity-utils.d.ts.map +0 -1
  435. package/dist/entity/entity-utils.js +0 -2
  436. package/dist/entity/entity-utils.js.map +0 -1
  437. package/dist/entity/entity.js.map +0 -1
  438. package/dist/exceptions/error-handler.js.map +0 -1
  439. package/dist/exceptions/so-exceptions.js.map +0 -1
  440. package/dist/file-storage/driver.js.map +0 -1
  441. package/dist/file-storage/file-storage.js.map +0 -1
  442. package/dist/index.js.map +0 -1
  443. package/dist/migration/code-generation.js.map +0 -1
  444. package/dist/migration/migration-set.js.map +0 -1
  445. package/dist/migration/migrator.js.map +0 -1
  446. package/dist/migration/types.js.map +0 -1
  447. package/dist/stream/index.js.map +0 -1
  448. package/dist/stream/sse.js.map +0 -1
  449. package/dist/syncer/index.js.map +0 -1
  450. package/dist/syncer/syncer.js.map +0 -1
  451. package/dist/templates/base-template.d.ts +0 -13
  452. package/dist/templates/base-template.d.ts.map +0 -1
  453. package/dist/templates/base-template.js +0 -2
  454. package/dist/templates/base-template.js.map +0 -1
  455. package/dist/templates/entity.template.d.ts.map +0 -1
  456. package/dist/templates/entity.template.js +0 -2
  457. package/dist/templates/entity.template.js.map +0 -1
  458. package/dist/templates/generated.template.d.ts.map +0 -1
  459. package/dist/templates/generated.template.js +0 -2
  460. package/dist/templates/generated.template.js.map +0 -1
  461. package/dist/templates/generated_http.template.d.ts.map +0 -1
  462. package/dist/templates/generated_http.template.js +0 -2
  463. package/dist/templates/generated_http.template.js.map +0 -1
  464. package/dist/templates/generated_sso.template.d.ts.map +0 -1
  465. package/dist/templates/generated_sso.template.js +0 -2
  466. package/dist/templates/generated_sso.template.js.map +0 -1
  467. package/dist/templates/index.d.ts +0 -2
  468. package/dist/templates/index.d.ts.map +0 -1
  469. package/dist/templates/index.js +0 -2
  470. package/dist/templates/index.js.map +0 -1
  471. package/dist/templates/init_types.template.d.ts.map +0 -1
  472. package/dist/templates/init_types.template.js +0 -2
  473. package/dist/templates/init_types.template.js.map +0 -1
  474. package/dist/templates/model.template.d.ts +0 -17
  475. package/dist/templates/model.template.d.ts.map +0 -1
  476. package/dist/templates/model.template.js +0 -2
  477. package/dist/templates/model.template.js.map +0 -1
  478. package/dist/templates/model_test.template.d.ts.map +0 -1
  479. package/dist/templates/model_test.template.js +0 -2
  480. package/dist/templates/model_test.template.js.map +0 -1
  481. package/dist/templates/service.template.d.ts.map +0 -1
  482. package/dist/templates/service.template.js +0 -2
  483. package/dist/templates/service.template.js.map +0 -1
  484. package/dist/templates/view_enums_buttonset.template.d.ts.map +0 -1
  485. package/dist/templates/view_enums_buttonset.template.js +0 -2
  486. package/dist/templates/view_enums_buttonset.template.js.map +0 -1
  487. package/dist/templates/view_enums_dropdown.template.d.ts.map +0 -1
  488. package/dist/templates/view_enums_dropdown.template.js +0 -2
  489. package/dist/templates/view_enums_dropdown.template.js.map +0 -1
  490. package/dist/templates/view_enums_select.template.d.ts.map +0 -1
  491. package/dist/templates/view_enums_select.template.js +0 -2
  492. package/dist/templates/view_enums_select.template.js.map +0 -1
  493. package/dist/templates/view_form.template.d.ts.map +0 -1
  494. package/dist/templates/view_form.template.js +0 -2
  495. package/dist/templates/view_form.template.js.map +0 -1
  496. package/dist/templates/view_id_all_select.template.d.ts.map +0 -1
  497. package/dist/templates/view_id_all_select.template.js +0 -2
  498. package/dist/templates/view_id_all_select.template.js.map +0 -1
  499. package/dist/templates/view_id_async_select.template.d.ts.map +0 -1
  500. package/dist/templates/view_id_async_select.template.js +0 -2
  501. package/dist/templates/view_id_async_select.template.js.map +0 -1
  502. package/dist/templates/view_list.template.d.ts.map +0 -1
  503. package/dist/templates/view_list.template.js +0 -2
  504. package/dist/templates/view_list.template.js.map +0 -1
  505. package/dist/templates/view_list_columns.template.d.ts +0 -17
  506. package/dist/templates/view_list_columns.template.d.ts.map +0 -1
  507. package/dist/templates/view_list_columns.template.js +0 -2
  508. package/dist/templates/view_list_columns.template.js.map +0 -1
  509. package/dist/templates/view_search_input.template.d.ts.map +0 -1
  510. package/dist/templates/view_search_input.template.js +0 -2
  511. package/dist/templates/view_search_input.template.js.map +0 -1
  512. package/dist/testing/_relation-graph.js.map +0 -1
  513. package/dist/testing/fixture-manager.js.map +0 -1
  514. package/dist/types/types.js.map +0 -1
  515. package/dist/typings/knex.d.js.map +0 -1
  516. package/dist/utils/async-utils.js.map +0 -1
  517. package/dist/utils/controller.js.map +0 -1
  518. package/dist/utils/fs-utils.js.map +0 -1
  519. package/dist/utils/lodash-able.js.map +0 -1
  520. package/dist/utils/model.js.map +0 -1
  521. package/dist/utils/sql-parser.js.map +0 -1
  522. package/dist/utils/utils.js.map +0 -1
  523. package/dist/utils/zod-error.js.map +0 -1
  524. package/src/bin/cli-wrapper.ts +0 -75
  525. package/src/database/knex-plugins/knex-on-duplicate-update.ts +0 -45
  526. package/src/entity/entity-utils.ts +0 -291
  527. package/src/templates/base-template.ts +0 -19
  528. package/src/templates/generated_sso.template.ts +0 -138
  529. package/src/templates/index.ts +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/syncer/syncer.ts"],"sourcesContent":["import path, { dirname } from \"path\";\nimport { globAsync, importMultiple } from \"../utils/utils\";\nimport { createReadStream } from \"fs\";\nimport { mkdir, readFile, rm, writeFile } from \"fs/promises\";\nimport { exists } from \"../utils/fs-utils\";\nimport crypto from \"crypto\";\nimport equal from \"fast-deep-equal\";\nimport _, { chunk } from \"lodash\";\nimport inflection from \"inflection\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport ts from \"typescript\";\nimport {\n ApiParam,\n ApiParamType,\n EntityProp,\n EntityPropNode,\n isBelongsToOneRelationProp,\n isBigIntegerProp,\n isBooleanProp,\n isDateProp,\n isDateTimeProp,\n isDecimalProp,\n isDoubleProp,\n isEnumProp,\n isFloatProp,\n isIntegerProp,\n isJsonProp,\n isOneToOneRelationProp,\n isRelationProp,\n isStringProp,\n isTextProp,\n isTimeProp,\n isTimestampProp,\n isUuidProp,\n isVirtualProp,\n} from \"../types/types\";\nimport {\n ApiDecoratorOptions,\n registeredApis,\n ExtendedApi,\n} from \"../api/decorators\";\nimport { z } from \"zod\";\nimport chalk from \"chalk\";\nimport {\n TemplateKey,\n PathAndCode,\n TemplateOptions,\n GenerateOptions,\n RenderingNode,\n} from \"../types/types\";\nimport {\n AlreadyProcessedException,\n BadRequestException,\n ServiceUnavailableException,\n} from \"../exceptions/so-exceptions\";\nimport { wrapIf } from \"../utils/lodash-able\";\nimport { getTextTypeLength } from \"../api/code-converters\";\nimport { Template } from \"../templates/base-template\";\nimport { Template__generated } from \"../templates/generated.template\";\nimport { Template__init_types } from \"../templates/init_types.template\";\nimport { Template__entity } from \"../templates/entity.template\";\nimport { Template__model } from \"../templates/model.template\";\nimport { Template__model_test } from \"../templates/model_test.template\";\nimport { Template__service } from \"../templates/service.template\";\nimport { Template__view_form } from \"../templates/view_form.template\";\nimport { Template__view_list } from \"../templates/view_list.template\";\nimport prettier from \"prettier\";\nimport { Template__view_id_all_select } from \"../templates/view_id_all_select.template\";\nimport { Template__view_id_async_select } from \"../templates/view_id_async_select.template\";\nimport { Template__view_enums_dropdown } from \"../templates/view_enums_dropdown.template\";\nimport { Template__view_enums_select } from \"../templates/view_enums_select.template\";\nimport { Template__view_enums_buttonset } from \"../templates/view_enums_buttonset.template\";\nimport { Template__view_search_input } from \"../templates/view_search_input.template\";\nimport { Template__view_list_columns } from \"../templates/view_list_columns.template\";\nimport { Template__generated_http } from \"../templates/generated_http.template\";\nimport { Sonamu } from \"../api/sonamu\";\nimport { Template__generated_sso } from \"../templates/generated_sso.template\";\nimport { setTimeout as setTimeoutPromises } from \"timers/promises\";\nimport assert from \"assert\";\nimport * as swc from \"@swc/core\";\nimport { minimatch } from \"minimatch\";\nimport {\n everyAsync,\n filterAsync,\n mapAsync,\n reduceAsync,\n} from \"../utils/async-utils\";\n\ntype FileType =\n | \"model\"\n | \"types\"\n | \"functions\"\n | \"generated\"\n | \"entity\"\n | \"frame\";\ntype GlobPattern = {\n [key in FileType]: string;\n};\ntype PathAndChecksum = {\n path: string;\n checksum: string;\n};\ntype DiffGroups = {\n [key in FileType]: string[];\n};\nexport type RenderedTemplate = {\n target: string;\n path: string;\n body: string;\n importKeys: string[];\n customHeaders?: string[];\n preTemplates?: {\n key: TemplateKey;\n options: TemplateOptions[TemplateKey];\n }[];\n};\n\nexport class Syncer {\n apis: {\n typeParameters: ApiParamType.TypeParam[];\n parameters: ApiParam[];\n returnType: ApiParamType;\n modelName: string;\n methodName: string;\n path: string;\n options: ApiDecoratorOptions;\n }[] = [];\n types: { [typeName: string]: z.ZodObject<any> } = {};\n models: { [modelName: string]: unknown } = {};\n isSyncing: boolean = false;\n\n public checksumPatternGroup: GlobPattern = {\n /* 원본 체크 */\n entity: Sonamu.apiRootPath + \"/src/application/**/*.entity.json\",\n types: Sonamu.apiRootPath + \"/src/application/**/*.types.ts\",\n generated: Sonamu.apiRootPath + \"/src/application/sonamu.generated.ts\",\n functions: Sonamu.apiRootPath + \"/src/application/**/*.functions.ts\",\n /* compiled-JS 체크 */\n model: Sonamu.apiRootPath + \"/dist/application/**/*.model.js\",\n frame: Sonamu.apiRootPath + \"/dist/application/**/*.frame.js\",\n };\n\n get checksumsPath(): string {\n return path.join(Sonamu.apiRootPath, \"/sonamu.lock\");\n }\n public constructor() {}\n\n async sync(): Promise<void> {\n const { targets } = Sonamu.config.sync;\n\n // 번들러 여부에 따라 현재 디렉토리가 바뀌므로\n const currentDirname = __dirname.endsWith(\"/syncer\")\n ? __dirname\n : path.join(__dirname, \"./syncer\");\n\n // 트리거와 무관하게 shared 분배\n await Promise.all(\n targets.map(async (target) => {\n const srcCodePath = path\n .join(currentDirname, `../shared/${target}.shared.ts.txt`)\n .replace(\"/dist/\", \"/src/\");\n if (!(await exists(srcCodePath))) {\n return;\n }\n\n const dstCodePath = path.join(\n Sonamu.appRootPath,\n target,\n \"src/services/sonamu.shared.ts\"\n );\n\n const srcChecksum = await this.getChecksumOfFile(srcCodePath);\n const dstChecksum = await (async () => {\n if (!(await exists(dstCodePath))) {\n return \"\";\n }\n return this.getChecksumOfFile(dstCodePath);\n })();\n\n if (srcChecksum === dstChecksum) {\n return;\n }\n await writeFile(dstCodePath, await readFile(srcCodePath));\n console.log(chalk.blue(\"shared.ts is synced\"));\n })\n );\n\n // 현재 checksums\n let currentChecksums = await this.getCurrentChecksums();\n // 이전 checksums\n const previousChecksums = await this.getPreviousChecksums();\n\n // 비교\n const isSame = equal(currentChecksums, previousChecksums);\n if (isSame) {\n const msg = \"All files are synced!\";\n const margin = (process.stdout.columns - msg.length) / 2;\n console.log(\n chalk.black.bgGreen(\" \".repeat(margin) + msg + \" \".repeat(margin))\n );\n return;\n }\n\n const abc = new AbortController();\n this.isSyncing = true;\n const onSIGUSR2 = async () => {\n if (this.isSyncing === false) {\n process.exit(0);\n }\n console.log(chalk.magentaBright(`wait for syncing done....`));\n\n // 싱크 완료 대기\n try {\n await setTimeoutPromises(20000, \"waiting-sync\", { signal: abc.signal });\n } catch {}\n console.log(chalk.magentaBright(`Syncing DONE!`));\n process.exit(0);\n };\n process.on(\"SIGUSR2\", onSIGUSR2);\n\n // 변경된 파일 찾기\n const diff = _.differenceWith(\n currentChecksums,\n previousChecksums,\n _.isEqual\n );\n const diffFiles = diff.map((r) => r.path);\n console.log(\"Changed Files: \", diffFiles);\n\n const { changedChecksums } = await this.doSyncActions(\n diffFiles,\n currentChecksums\n );\n // checksum 오버라이드 (액션 실행 과정 중간에 체크섬이 바뀐 경우)\n currentChecksums = changedChecksums ?? currentChecksums;\n\n // 저장\n await this.saveChecksums(currentChecksums);\n\n // 싱크 종료\n this.isSyncing = false;\n abc.abort();\n process.off(\"SIGUSR2\", onSIGUSR2);\n }\n\n async doSyncActions(\n diffFiles: string[],\n currentChecksums?: PathAndChecksum[]\n ): Promise<{\n diffTypes: string[];\n changedChecksums?: PathAndChecksum[];\n }> {\n // 다른 부분 찾아 액션\n const diffGroups = _.groupBy(diffFiles, (r) => {\n const matched = r.match(\n /\\.(model|types|functions|entity|generated|frame)\\.[tj]s/\n );\n return matched?.[1] ?? \"unknown\";\n }) as unknown as DiffGroups;\n\n // 변경된 파일들을 타입별로 분리하여 각 타입별 액션 처리\n const diffTypes = Object.keys(diffGroups);\n\n // 트리거: entity, types\n // 액션: 스키마 생성\n if (diffTypes.includes(\"entity\") || diffTypes.includes(\"types\")) {\n await EntityManager.reload();\n\n await this.actionGenerateSchemas();\n\n // types 생성(entity 새로 추가된 경우)\n // parentId가 없고, types가 없는 경우에만 생성\n const entityId = this.getEntityIdFromPath([\n ...(diffGroups[\"entity\"] ?? []),\n ])[0];\n if (entityId) {\n const entity = EntityManager.get(entityId);\n const typeFilePath = path.join(\n Sonamu.apiRootPath,\n `src/application/${entity.names.fs}/${entity.names.fs}.types.ts`\n );\n if (entity.parentId === undefined && !(await exists(typeFilePath))) {\n await this.generateTemplate(\"init_types\", { entityId });\n }\n }\n\n // generated 싱크까지 동시에 처리 후 체크섬 갱신\n diffGroups[\"generated\"] = _.uniq([\n ...(diffGroups[\"generated\"] ?? []),\n \"/src/application/sonamu.generated.ts\",\n ]);\n diffTypes.push(\"generated\");\n\n // fullSync인 경우만 실행\n if (currentChecksums) {\n currentChecksums = await this.getCurrentChecksums();\n }\n }\n\n // 트리거: types, enums, generated 변경시\n // 액션: 파일 싱크 types, enums, generated\n if (\n diffTypes.includes(\"types\") ||\n diffTypes.includes(\"functions\") ||\n diffTypes.includes(\"generated\")\n ) {\n const tsPaths = _.uniq(\n [\n ...(diffGroups[\"types\"] ?? []),\n ...(diffGroups[\"functions\"] ?? []),\n ...(diffGroups[\"generated\"] ?? []),\n ].map((p) => p.replace(\"/dist/\", \"/src/\").replace(\".js\", \".ts\"))\n );\n await this.actionSyncFilesToTargets(tsPaths);\n }\n\n // 트리거: model\n if (diffTypes.includes(\"model\") || diffTypes.includes(\"frame\")) {\n const mergedGroup = [\n ...(diffGroups[\"model\"] ?? []),\n ...(diffGroups[\"frame\"] ?? []),\n ];\n\n // registeredApis 초기화\n await this.autoloadModels();\n\n // Syncer.apis 초기화\n await this.autoloadApis();\n\n const params: { namesRecord: EntityNamesRecord; modelTsPath: string }[] =\n mergedGroup.map((modelPath) => {\n if (modelPath.endsWith(\".model.js\")) {\n const entityId = this.getEntityIdFromPath([modelPath])[0];\n assert(entityId);\n return {\n namesRecord: EntityManager.getNamesFromId(entityId),\n modelTsPath: path.join(\n Sonamu.apiRootPath,\n modelPath\n .replace(\"/dist/\", \"/src/\")\n .replace(\".model.js\", \".model.ts\")\n ),\n };\n }\n if (modelPath.endsWith(\"frame.js\")) {\n const [, frameName] = modelPath.match(/.+\\/(.+)\\.frame.js$/) ?? [];\n assert(frameName);\n return {\n namesRecord: EntityManager.getNamesFromId(frameName),\n modelTsPath: path.join(\n Sonamu.apiRootPath,\n modelPath\n .replace(\"/dist/\", \"/src/\")\n .replace(\".frame.js\", \".frame.ts\")\n ),\n };\n }\n throw new Error(\"not reachable\");\n });\n await this.actionGenerateServices(params);\n\n await this.actionGenerateHttps();\n }\n\n return {\n diffTypes,\n changedChecksums: currentChecksums,\n };\n }\n\n async syncFromWatcher(diffFiles: string[]): Promise<void> {\n const tsFiles = diffFiles.filter((file) => file.endsWith(\".ts\"));\n const jsonFiles = diffFiles.filter((file) => file.endsWith(\".json\"));\n\n // transpile (성능 이슈를 고려하여 5개 동시 실행)\n const chunks = chunk(tsFiles, 5);\n let transpiledFilePaths: string[] = [];\n for (const chunk of chunks) {\n const _transpiledFilePaths = await Promise.all(\n chunk.map(async (diffFile) => {\n const { code, map } = await swc.transformFile(diffFile, {\n module: {\n type: \"commonjs\",\n },\n jsc: {\n parser: {\n syntax: \"typescript\",\n decorators: true,\n },\n target: \"es5\",\n },\n sourceMaps: true,\n });\n\n const jsPath = diffFile\n .replace(\"/src/\", \"/dist/\")\n .replace(\".ts\", \".js\");\n await mkdir(path.dirname(jsPath), { recursive: true }); // 파일 새로 추가된 경우 디렉토리 생성\n await writeFile(jsPath, code);\n\n if (map) {\n const mapPath = jsPath + \".map\";\n await mkdir(path.dirname(mapPath), { recursive: true });\n await writeFile(mapPath, map);\n\n const sourceMapComment =\n \"\\n//# sourceMappingURL=\" + path.basename(mapPath);\n await writeFile(jsPath, sourceMapComment, {\n flag: \"a\" /*파일 끝에 붙이기만 해요*/,\n });\n }\n\n console.log(\n chalk.bold(\"Transpiled: \") +\n chalk.blue(`${jsPath.replace(Sonamu.apiRootPath, \"api\")}`)\n );\n return jsPath;\n })\n );\n transpiledFilePaths.push(..._transpiledFilePaths);\n }\n\n // module reload - doSyncActions 전에 캐시 삭제\n function clearModuleAndDependents(filePath: string) {\n const resolved = require.resolve(filePath);\n const toDelete = new Set([resolved]);\n\n // 이 파일을 children으로 가진 모듈 찾기\n Object.keys(require.cache).forEach((key) => {\n const mod = require.cache[key];\n if (mod?.children?.some((child) => child.id === resolved)) {\n toDelete.add(key);\n }\n });\n\n toDelete.forEach((key) => {\n if (key.includes(\"dist/index.js\")) {\n process.kill(process.pid, \"SIGUSR2\");\n }\n delete require.cache[key];\n // console.debug(\n // chalk.bold(\"ModuleCleared: \") +\n // chalk.blue(`${key.replace(Sonamu.apiRootPath, \"api\")}`)\n // );\n });\n }\n transpiledFilePaths.map((filePath) => {\n clearModuleAndDependents(filePath);\n });\n\n // doSyncActions\n const allFilePaths = [...tsFiles, ...transpiledFilePaths, ...jsonFiles];\n const targetFilePaths = allFilePaths\n .filter((filePath) => {\n return Object.values(this.checksumPatternGroup).some((pattern) =>\n minimatch(filePath, pattern)\n );\n })\n .map((filePath) => \"/\" + path.relative(Sonamu.apiRootPath, filePath));\n await this.doSyncActions(targetFilePaths);\n\n this.apis = [];\n this.types = {};\n this.models = {};\n await this.autoloadTypes();\n await this.autoloadModels();\n await this.autoloadApis();\n\n this.syncUI();\n }\n\n getEntityIdFromPath(filePaths: string[]): string[] {\n return _.uniq(\n filePaths.map((p) => {\n const matched = p.match(/application\\/(.+)\\//);\n assert(matched && matched[1]);\n return inflection.camelize(matched[1].replace(/\\-/g, \"_\"));\n })\n );\n }\n\n async actionGenerateSchemas(): Promise<string[]> {\n return (\n await Promise.all([\n this.generateTemplate(\"generated_sso\", {}, { overwrite: true }),\n this.generateTemplate(\"generated\", {}, { overwrite: true }),\n ])\n )\n .flat()\n .flat();\n }\n\n async actionGenerateServices(\n paramsArray: {\n namesRecord: EntityNamesRecord;\n modelTsPath: string;\n }[]\n ): Promise<string[]> {\n return (\n await Promise.all(\n paramsArray.map(async (params) =>\n this.generateTemplate(\"service\", params, {\n overwrite: true,\n })\n )\n )\n )\n .flat()\n .flat();\n }\n\n async actionGenerateHttps(): Promise<string[]> {\n const [res] = await this.generateTemplate(\n \"generated_http\",\n {},\n { overwrite: true }\n );\n assert(res);\n return res;\n }\n\n async copyFileWithReplaceCoreToShared(fromPath: string, toPath: string) {\n if (!(await exists(fromPath))) {\n return;\n }\n\n const oldFileContent = (await readFile(fromPath)).toString();\n\n const newFileContent = (() => {\n const nfc = oldFileContent.replace(\n /from \"sonamu\"/g,\n `from \"src/services/sonamu.shared\"`\n );\n\n if (toPath.includes(\"/web/\")) {\n return nfc.replace(/from \"lodash\";/g, `from \"lodash-es\";`);\n } else {\n return nfc;\n }\n })();\n return writeFile(toPath, newFileContent);\n }\n\n async actionSyncFilesToTargets(tsPaths: string[]): Promise<string[]> {\n const { targets } = Sonamu.config.sync;\n const { dir: apiDir } = Sonamu.config.api;\n\n return (\n await Promise.all(\n targets.map(async (target) =>\n Promise.all(\n tsPaths.map(async (src) => {\n const realSrc = Sonamu.apiRootPath + src;\n const dst = realSrc\n .replace(`/${apiDir}/`, `/${target}/`)\n .replace(\"/application/\", \"/services/\");\n const dir = dirname(dst);\n if (!(await exists(dir))) {\n await mkdir(dir, { recursive: true });\n }\n console.log(\n chalk.bold(\"Copied: \") +\n chalk.blue(\n `Copied: ${dst.replace(Sonamu.appRootPath + \"/\", \"\")}`\n )\n );\n await this.copyFileWithReplaceCoreToShared(realSrc, dst);\n return dst;\n })\n )\n )\n )\n ).flat();\n }\n\n async getCurrentChecksums(): Promise<PathAndChecksum[]> {\n const filePaths = (\n await Promise.all(\n Object.entries(this.checksumPatternGroup).map(\n async ([_fileType, pattern]) => {\n return globAsync(pattern);\n }\n )\n )\n )\n .flat()\n .sort();\n\n const fileChecksums: {\n path: string;\n checksum: string;\n }[] = await Promise.all(\n filePaths.map(async (filePath) => {\n return {\n path: filePath.substring(Sonamu.apiRootPath.length),\n checksum: await this.getChecksumOfFile(filePath),\n };\n })\n );\n return fileChecksums;\n }\n\n async getPreviousChecksums(): Promise<PathAndChecksum[]> {\n if (!(await exists(this.checksumsPath))) {\n return [];\n }\n\n const previousChecksums = JSON.parse(\n (await readFile(this.checksumsPath, \"utf-8\"))\n ) as PathAndChecksum[];\n return previousChecksums;\n }\n\n async saveChecksums(checksums: PathAndChecksum[]): Promise<void> {\n await writeFile(\n this.checksumsPath,\n JSON.stringify(checksums, null, 2),\n \"utf-8\"\n );\n console.log(\"checksum saved\", this.checksumsPath);\n }\n\n async getChecksumOfFile(filePath: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n const hash = crypto.createHash(\"sha1\");\n const input = createReadStream(filePath);\n input.on(\"error\", reject);\n input.on(\"data\", function (chunk: any) {\n hash.update(chunk);\n });\n input.on(\"close\", function () {\n resolve(hash.digest(\"hex\"));\n });\n });\n }\n\n async readApisFromFile(filePath: string) {\n const sourceFile = ts.createSourceFile(\n filePath,\n (await readFile(filePath)).toString(),\n ts.ScriptTarget.Latest\n );\n\n const methods: Omit<ExtendedApi, \"path\" | \"options\">[] = [];\n let modelName: string = \"UnknownModel\";\n let methodName: string = \"unknownMethod\";\n const visitor = (node: ts.Node) => {\n if (ts.isClassDeclaration(node)) {\n if (node.name && ts.isIdentifier(node.name)) {\n modelName = node.name.escapedText.toString().replace(/Class$/, \"\");\n }\n }\n if (ts.isMethodDeclaration(node)) {\n if (ts.isIdentifier(node.name)) {\n methodName = node.name.escapedText.toString();\n }\n\n const typeParameters: ApiParamType.TypeParam[] = (\n node.typeParameters ?? []\n ).map((typeParam) => {\n const tp = typeParam as ts.TypeParameterDeclaration;\n\n return {\n t: \"type-param\",\n id: tp.name.escapedText.toString(),\n constraint: tp.constraint\n ? this.resolveTypeNode(tp.constraint)\n : undefined,\n };\n });\n const parameters: ApiParam[] = node.parameters.map(\n (paramDec, index) => {\n const defaultDef = this.printNode(paramDec.initializer, sourceFile);\n\n // 기본값이 있는 경우 paramDec.type가 undefined로 나옴\n\n return this.resolveParamDec(\n {\n name: paramDec.name,\n type: paramDec.type as ts.TypeNode,\n optional:\n paramDec.questionToken !== undefined ||\n paramDec.initializer !== undefined,\n defaultDef,\n },\n index\n );\n }\n );\n if (node.type === undefined) {\n throw new Error(\n `리턴 타입이 기재되지 않은 메소드 ${modelName}.${methodName}`\n );\n }\n const returnType = this.resolveTypeNode(node.type!);\n\n methods.push({\n modelName,\n methodName,\n typeParameters,\n parameters,\n returnType,\n });\n }\n ts.forEachChild(node, visitor);\n };\n visitor(sourceFile);\n\n if (methods.length === 0) {\n return [];\n }\n\n // 현재 파일의 등록된 API 필터\n const currentModelApis = registeredApis.filter((api) => {\n return methods.find(\n (method) =>\n method.modelName === api.modelName &&\n method.methodName === api.methodName\n );\n });\n if (currentModelApis.length === 0) {\n // const p = path.join(tmpdir(), \"sonamu-syncer-error.json\");\n // writeFileSync(p, JSON.stringify(registeredApis, null, 2));\n // execSync(`open ${p}`);\n throw new Error(`현재 파일에 사전 등록된 API가 없습니다. ${filePath}`);\n }\n\n // 등록된 API에 현재 메소드 타입 정보 확장\n const extendedApis = currentModelApis.map((api) => {\n const foundMethod = methods.find(\n (method) =>\n method.modelName === api.modelName &&\n method.methodName === api.methodName\n );\n return {\n ...api,\n typeParameters: foundMethod!.typeParameters,\n parameters: foundMethod!.parameters,\n returnType: foundMethod!.returnType,\n };\n });\n return extendedApis;\n }\n\n resolveTypeNode(typeNode: ts.TypeNode): ApiParamType {\n switch (typeNode?.kind) {\n case ts.SyntaxKind.AnyKeyword:\n return \"any\";\n case ts.SyntaxKind.UnknownKeyword:\n return \"unknown\";\n case ts.SyntaxKind.StringKeyword:\n return \"string\";\n case ts.SyntaxKind.NumberKeyword:\n return \"number\";\n case ts.SyntaxKind.BooleanKeyword:\n return \"boolean\";\n case ts.SyntaxKind.UndefinedKeyword:\n return \"undefined\";\n case ts.SyntaxKind.NullKeyword:\n return \"null\";\n case ts.SyntaxKind.VoidKeyword:\n return \"void\";\n case ts.SyntaxKind.LiteralType:\n const literal = (typeNode as ts.LiteralTypeNode).literal;\n if (ts.isStringLiteral(literal)) {\n return {\n t: \"string-literal\",\n value: literal.text,\n };\n } else if (ts.isNumericLiteral(literal)) {\n return {\n t: \"numeric-literal\",\n value: Number(literal.text),\n };\n } else {\n if (literal.kind === ts.SyntaxKind.NullKeyword) {\n return \"null\";\n } else if (literal.kind === ts.SyntaxKind.UndefinedKeyword) {\n return \"undefined\";\n } else if (literal.kind === ts.SyntaxKind.TrueKeyword) {\n return \"true\";\n } else if (literal.kind === ts.SyntaxKind.FalseKeyword) {\n return \"false\";\n }\n throw new Error(\"알 수 없는 리터럴\");\n }\n case ts.SyntaxKind.ArrayType:\n const arrNode = typeNode as ts.ArrayTypeNode;\n return {\n t: \"array\",\n elementsType: this.resolveTypeNode(arrNode.elementType),\n };\n case ts.SyntaxKind.TypeLiteral:\n const literalNode = typeNode as ts.TypeLiteralNode;\n return {\n t: \"object\",\n props: literalNode.members.map((member) => {\n if (ts.isIndexSignatureDeclaration(member)) {\n assert(member.parameters[0]);\n const res = this.resolveParamDec({\n name: member.parameters[0].name as ts.Identifier,\n type: member.parameters[0].type as ts.TypeNode,\n });\n\n return this.resolveParamDec({\n name: {\n escapedText: `[${res.name}${res.optional ? \"?\" : \"\"}: ${\n res.type\n }]`,\n } as ts.Identifier,\n type: member.type as ts.TypeNode,\n });\n } else {\n return this.resolveParamDec({\n name: (member as ts.PropertySignature).name as ts.Identifier,\n type: (member as ts.PropertySignature).type as ts.TypeNode,\n optional:\n (member as ts.PropertySignature).questionToken !== undefined,\n });\n }\n }),\n };\n case ts.SyntaxKind.TypeReference:\n return {\n t: \"ref\",\n id: (\n (typeNode as ts.TypeReferenceNode).typeName as ts.Identifier\n ).escapedText.toString(),\n args: (typeNode as ts.TypeReferenceNode).typeArguments?.map(\n (typeArg) => this.resolveTypeNode(typeArg)\n ),\n };\n case ts.SyntaxKind.UnionType:\n return {\n t: \"union\",\n types: (typeNode as ts.UnionTypeNode).types.map((type) =>\n this.resolveTypeNode(type)\n ),\n };\n case ts.SyntaxKind.IntersectionType:\n return {\n t: \"intersection\",\n types: (typeNode as ts.IntersectionTypeNode).types.map((type) =>\n this.resolveTypeNode(type)\n ),\n };\n case ts.SyntaxKind.IndexedAccessType:\n return {\n t: \"indexed-access\",\n object: this.resolveTypeNode(\n (typeNode as ts.IndexedAccessTypeNode).objectType\n ),\n index: this.resolveTypeNode(\n (typeNode as ts.IndexedAccessTypeNode).indexType\n ),\n };\n case ts.SyntaxKind.TupleType:\n if (ts.isTupleTypeNode(typeNode)) {\n return {\n t: \"tuple-type\",\n elements: typeNode.elements.map((elem) =>\n this.resolveTypeNode(elem)\n ),\n };\n }\n break;\n case undefined:\n throw new Error(`typeNode undefined`);\n }\n\n console.debug(typeNode);\n throw new Error(`알 수 없는 SyntaxKind ${typeNode.kind}`);\n }\n\n resolveParamDec = (\n paramDec: {\n name: ts.BindingName;\n type: ts.TypeNode;\n optional?: boolean;\n defaultDef?: string;\n },\n index: number = 0\n ): ApiParam => {\n const name = paramDec.name as ts.Identifier;\n const type = this.resolveTypeNode(paramDec.type);\n\n if (name === undefined) {\n console.debug({ name, type, paramDec });\n }\n\n const result: ApiParam = {\n name: name.escapedText ? name.escapedText.toString() : `nonameAt${index}`,\n type,\n optional: paramDec.optional === true,\n defaultDef: paramDec?.defaultDef,\n };\n\n // 구조분해할당의 경우 타입이름 사용\n if (\n ts.isObjectBindingPattern(name) &&\n ts.isTypeReferenceNode(paramDec.type) &&\n ts.isIdentifier(paramDec.type.typeName)\n ) {\n result.name = inflection.camelize(paramDec.type.typeName.text, true);\n }\n\n return result;\n };\n\n printNode(\n node: ts.Node | undefined,\n sourceFile: ts.SourceFile\n ): string | undefined {\n if (node === undefined) {\n return undefined;\n }\n\n const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });\n return printer.printNode(ts.EmitHint.Unspecified, node, sourceFile);\n }\n\n async autoloadApis() {\n const pathPattern = path.join(\n Sonamu.apiRootPath,\n \"/src/application/**/*.{model,frame}.ts\"\n );\n // console.debug(chalk.yellow(`autoload:APIs @ ${pathPattern}`));\n\n const filePaths = await globAsync(pathPattern);\n const result = await Promise.all(\n filePaths.map((filePath) => this.readApisFromFile(filePath))\n );\n this.apis = result.flat();\n return this.apis;\n }\n\n async autoloadModels(): Promise<{ [modelName: string]: unknown }> {\n const pathPattern = path.join(\n Sonamu.apiRootPath,\n \"dist/application/**/*.{model,frame}.js\"\n );\n // console.debug(chalk.yellow(`autoload:models @ ${pathPattern}`));\n\n const filePaths = await filterAsync(\n await globAsync(pathPattern),\n async (path) => {\n // src 디렉터리 내에 있는 해당 파일이 존재할 경우에만 로드\n // 삭제된 파일이지만 dist에 남아있는 경우 BaseSchema undefined 에러 방지\n const srcPath = path.replace(\"/dist/\", \"/src/\").replace(\".js\", \".ts\");\n return await exists(srcPath);\n }\n );\n const modules = await importMultiple(filePaths);\n const functions = modules\n .map(({ imported }) => Object.entries(imported))\n .flat();\n this.models = Object.fromEntries(\n functions.filter(\n ([name]) => name.endsWith(\"Model\") || name.endsWith(\"Frame\")\n )\n );\n return this.models;\n }\n\n async autoloadTypes(\n doRefresh: boolean = false\n ): Promise<{ [typeName: string]: z.ZodObject<any> }> {\n if (!doRefresh && Object.keys(this.types).length > 0) {\n return this.types;\n }\n\n const pathPatterns = [\n path.join(Sonamu.apiRootPath, \"/dist/application/**/*.types.js\"),\n path.join(Sonamu.apiRootPath, \"/dist/application/**/*.generated.js\"),\n ];\n // console.debug(chalk.magenta(`autoload:types @ ${pathPatterns.join(\"\\n\")}`));\n\n const filePaths = await filterAsync(\n (await mapAsync(pathPatterns, globAsync)).flat(),\n async (path) => {\n // src 디렉터리 내에 있는 해당 파일이 존재할 경우에만 로드\n // 삭제된 파일이지만 dist에 남아있는 경우 BaseSchema undefined 에러 방지\n const srcPath = path.replace(\"/dist/\", \"/src/\").replace(\".js\", \".ts\");\n return await exists(srcPath);\n }\n );\n const modules = await importMultiple(filePaths, doRefresh);\n const functions = modules\n .map(({ imported }) => Object.entries(imported))\n .flat();\n this.types = Object.fromEntries(\n functions.filter(([, f]) => f instanceof z.ZodType)\n ) as typeof this.types;\n return this.types;\n }\n\n getTemplate(key: TemplateKey): Template {\n if (key === \"entity\") {\n return new Template__entity();\n } else if (key === \"init_types\") {\n return new Template__init_types();\n } else if (key === \"generated\") {\n return new Template__generated();\n } else if (key === \"generated_sso\") {\n return new Template__generated_sso();\n } else if (key === \"generated_http\") {\n return new Template__generated_http();\n } else if (key === \"model\") {\n return new Template__model();\n } else if (key === \"model_test\") {\n return new Template__model_test();\n } else if (key === \"service\") {\n return new Template__service();\n } else if (key === \"view_list\") {\n return new Template__view_list();\n } else if (key === \"view_list_columns\") {\n return new Template__view_list_columns();\n } else if (key === \"view_search_input\") {\n return new Template__view_search_input();\n } else if (key === \"view_form\") {\n return new Template__view_form();\n } else if (key === \"view_id_all_select\") {\n return new Template__view_id_all_select();\n } else if (key === \"view_id_async_select\") {\n return new Template__view_id_async_select();\n } else if (key === \"view_enums_select\") {\n return new Template__view_enums_select();\n } else if (key === \"view_enums_dropdown\") {\n return new Template__view_enums_dropdown();\n } else if (key === \"view_enums_buttonset\") {\n return new Template__view_enums_buttonset();\n } else {\n throw new BadRequestException(`잘못된 템플릿 키 ${key}`);\n }\n }\n\n async renderTemplate<T extends keyof TemplateOptions>(\n key: T,\n options: TemplateOptions[T]\n ): Promise<PathAndCode[]> {\n const template: Template = this.getTemplate(key);\n\n let extra: unknown[] = [];\n if (key === \"service\") {\n // service 필요 정보 (API 리스트)\n const { modelTsPath } = options as TemplateOptions[\"service\"];\n extra = [await this.readApisFromFile(modelTsPath)];\n } else if ([\"model\", \"view_list\", \"view_form\"].includes(key)) {\n const entityId = (options as TemplateOptions[\"model\"]).entityId;\n if (key === \"view_list\" || key === \"model\") {\n // view_list 필요 정보 (컬럼 노드, 리스트파라미터 노드)\n const columnsNode = await this.getColumnsNode(entityId, \"A\");\n const listParamsZodType = await this.getZodTypeById(\n `${entityId}ListParams`\n );\n const listParamsNode = this.zodTypeToRenderingNode(listParamsZodType);\n extra = [columnsNode, listParamsNode];\n } else if (key === \"view_form\") {\n // view_form 필요 정보 (세이브파라미터 노드)\n const saveParamsZodType = await this.getZodTypeById(\n `${entityId}SaveParams`\n );\n const saveParamsNode = this.zodTypeToRenderingNode(saveParamsZodType);\n extra = [saveParamsNode];\n }\n }\n\n const rendered = await template.render(options, ...extra);\n const resolved = await this.resolveRenderedTemplate(key, rendered);\n\n let preTemplateResolved: PathAndCode[] = [];\n if (rendered.preTemplates) {\n preTemplateResolved = (\n await Promise.all(\n rendered.preTemplates.map(({ key, options }) => {\n return this.renderTemplate(key, options);\n })\n )\n ).flat();\n }\n\n return [resolved, ...preTemplateResolved];\n }\n\n async resolveRenderedTemplate(\n key: TemplateKey,\n result: RenderedTemplate\n ): Promise<PathAndCode> {\n const { target, path: filePath, body, importKeys, customHeaders } = result;\n\n // import 할 대상의 대상 path 추출\n const importDefs = importKeys\n .reduce(\n (r, importKey) => {\n const modulePath = EntityManager.getModulePath(importKey);\n let importPath = modulePath;\n if (modulePath.includes(\"/\") || modulePath.includes(\".\")) {\n importPath = wrapIf(\n path.relative(path.dirname(filePath), modulePath),\n (p) => [p.startsWith(\".\") === false, \"./\" + p]\n );\n }\n\n // 같은 파일에서 import 하는 경우 keys 로 나열 처리\n const existsOne = r.find(\n (importDef) => importDef.from === importPath\n );\n if (existsOne) {\n existsOne.keys = _.uniq(existsOne.keys.concat(importKey));\n } else {\n r.push({\n keys: [importKey],\n from: importPath,\n });\n }\n return r;\n },\n [] as {\n keys: string[];\n from: string;\n }[]\n )\n // 셀프 참조 방지\n .filter(\n (importDef) =>\n filePath.endsWith(importDef.from.replace(\"./\", \"\") + \".ts\") === false\n );\n\n // 커스텀 헤더 포함하여 헤더 생성\n const header = [\n ...(customHeaders ?? []),\n ...importDefs.map(\n (importDef) =>\n `import { ${importDef.keys.join(\", \")} } from '${importDef.from}'`\n ),\n ].join(\"\\n\");\n\n const formatted = await (async () => {\n if (key === \"generated_http\") {\n return [header, body].join(\"\\n\\n\");\n } else {\n return prettier.format([header, body].join(\"\\n\\n\"), {\n parser: key === \"entity\" ? \"json\" : \"typescript\",\n });\n }\n })();\n\n return {\n path: target + \"/\" + filePath,\n code: formatted,\n };\n }\n\n async writeCodeToPath(pathAndCode: PathAndCode): Promise<string[]> {\n const { targets } = Sonamu.config.sync;\n const { appRootPath } = Sonamu;\n const filePath = `${Sonamu.appRootPath}/${pathAndCode.path}`;\n\n const dstFilePaths = _.uniq(\n targets.map((target) => filePath.replace(\"/:target/\", `/${target}/`))\n );\n return await Promise.all(\n dstFilePaths.map(async (dstFilePath) => {\n const dir = path.dirname(dstFilePath);\n if (!(await exists(dir))) {\n await mkdir(dir, { recursive: true });\n }\n await writeFile(dstFilePath, pathAndCode.code);\n console.log(\n chalk.bold(\"Generated: \") +\n chalk.blue(`${dstFilePath.replace(appRootPath + \"/\", \"\")}`)\n );\n return dstFilePath;\n })\n );\n }\n\n async generateTemplate(\n key: TemplateKey,\n templateOptions: any,\n _generateOptions?: GenerateOptions\n ) {\n const generateOptions = {\n overwrite: false,\n ..._generateOptions,\n };\n\n // 키 children\n const keys: TemplateKey[] = [key];\n\n // 템플릿 렌더\n const pathAndCodes = (\n await Promise.all(\n keys.map(async (key) => {\n return await this.renderTemplate(key, templateOptions);\n })\n )\n ).flat();\n\n const filteredPathAndCodes: PathAndCode[] = await (async () => {\n if (generateOptions.overwrite === true) {\n return pathAndCodes;\n } else {\n return await filterAsync(pathAndCodes, async (pathAndCode) => {\n const { targets } = Sonamu.config.sync;\n const filePath = `${Sonamu.appRootPath}/${pathAndCode.path}`;\n const dstFilePaths = targets.map((target) =>\n filePath.replace(\"/:target/\", `/${target}/`)\n );\n return await everyAsync(\n dstFilePaths,\n async (dstPath) => !(await exists(dstPath))\n );\n });\n }\n })();\n if (filteredPathAndCodes.length === 0) {\n throw new AlreadyProcessedException(\n \"이미 경로에 모든 파일이 존재합니다.\"\n );\n }\n\n return Promise.all(\n filteredPathAndCodes.map((pathAndCode) =>\n this.writeCodeToPath(pathAndCode)\n )\n );\n }\n\n async checkExistsGenCode(\n entityId: string,\n templateKey: TemplateKey,\n enumId?: string\n ): Promise<{ subPath: string; fullPath: string; isExists: boolean }> {\n const { target, path: genPath } = this.getTemplate(\n templateKey\n ).getTargetAndPath(EntityManager.getNamesFromId(entityId), enumId);\n\n const fullPath = path.join(Sonamu.appRootPath, target, genPath);\n const subPath = path.join(target, genPath);\n return {\n subPath,\n fullPath,\n isExists: await exists(fullPath),\n };\n }\n\n async checkExists(\n entityId: string,\n enums: {\n [name: string]: z.ZodEnum<any>;\n }\n ): Promise<Record<`${TemplateKey}${string}`, boolean>> {\n const keys: TemplateKey[] = TemplateKey.options;\n const names = EntityManager.getNamesFromId(entityId);\n const enumsKeys = Object.keys(enums).filter(\n (name) => name !== names.constant\n );\n\n return await reduceAsync(\n keys,\n async (result, key) => {\n const tpl = this.getTemplate(key);\n if (key.startsWith(\"view_enums\")) {\n await mapAsync(enumsKeys, async (componentId) => {\n const { target, path: p } = tpl.getTargetAndPath(\n names,\n componentId\n );\n result[`${key}__${componentId}`] = await exists(\n path.join(Sonamu.appRootPath, target, p)\n );\n });\n return result;\n }\n\n const { target, path: p } = tpl.getTargetAndPath(names);\n const { targets } = Sonamu.config.sync;\n if (target.includes(\":target\")) {\n await mapAsync(targets, async (t) => {\n result[`${key}__${t}`] = await exists(\n path.join(Sonamu.appRootPath, target.replace(\":target\", t), p)\n );\n });\n } else {\n result[key] = await exists(path.join(Sonamu.appRootPath, target, p));\n }\n\n return result;\n },\n {} as Record<`${TemplateKey}${string}`, boolean>\n );\n }\n\n async getZodTypeById(zodTypeId: string): Promise<z.ZodTypeAny> {\n const modulePath = EntityManager.getModulePath(zodTypeId);\n const moduleAbsPath = path.join(\n Sonamu.apiRootPath,\n \"dist\",\n \"application\",\n modulePath + \".js\"\n );\n const importPath = \"./\" + path.relative(__dirname, moduleAbsPath);\n const imported = await import(importPath);\n\n if (!imported[zodTypeId]) {\n throw new Error(`존재하지 않는 zodTypeId ${zodTypeId}`);\n }\n return imported[zodTypeId].describe(zodTypeId);\n }\n\n async propNodeToZodType(propNode: EntityPropNode): Promise<z.ZodTypeAny> {\n if (propNode.nodeType === \"plain\") {\n return this.propToZodType(propNode.prop);\n } else if (propNode.nodeType === \"array\") {\n if (propNode.prop === undefined) {\n throw new Error();\n } else if (propNode.children.length > 0) {\n return (\n await this.propNodeToZodType({\n ...propNode,\n nodeType: \"object\",\n })\n ).array();\n } else {\n const innerType = await this.propToZodType(propNode.prop);\n if (propNode.prop.nullable === true) {\n return z.array(innerType).nullable();\n } else {\n return z.array(innerType);\n }\n }\n } else if (propNode.nodeType === \"object\") {\n const obj = await propNode.children.reduce(\n async (promise, childPropNode) => {\n const result = await promise;\n result[childPropNode.prop!.name] =\n await this.propNodeToZodType(childPropNode);\n return result;\n },\n {} as any\n );\n\n if (propNode.prop?.nullable === true) {\n return z.object(obj).nullable();\n } else {\n return z.object(obj);\n }\n } else {\n throw Error;\n }\n }\n async propToZodType(prop: EntityProp): Promise<z.ZodTypeAny> {\n let zodType: z.ZodTypeAny = z.unknown();\n if (isIntegerProp(prop)) {\n zodType = z.number().int();\n } else if (isBigIntegerProp(prop)) {\n zodType = z.bigint();\n } else if (isTextProp(prop)) {\n zodType = z.string().max(getTextTypeLength(prop.textType));\n } else if (isEnumProp(prop)) {\n zodType = await this.getZodTypeById(prop.id);\n } else if (isStringProp(prop)) {\n zodType = z.string().max(prop.length);\n } else if (isFloatProp(prop) || isDoubleProp(prop)) {\n zodType = z.number();\n } else if (isDecimalProp(prop)) {\n zodType = z.string();\n } else if (isBooleanProp(prop)) {\n zodType = z.boolean();\n } else if (isDateProp(prop)) {\n zodType = z.string().length(10);\n } else if (isTimeProp(prop)) {\n zodType = z.string().length(8);\n } else if (isDateTimeProp(prop)) {\n zodType = z.date();\n } else if (isTimestampProp(prop)) {\n zodType = z.date();\n } else if (isJsonProp(prop)) {\n zodType = await this.getZodTypeById(prop.id);\n } else if (isUuidProp(prop)) {\n zodType = z.uuid();\n } else if (isVirtualProp(prop)) {\n zodType = await this.getZodTypeById(prop.id);\n } else if (isRelationProp(prop)) {\n if (\n isBelongsToOneRelationProp(prop) ||\n (isOneToOneRelationProp(prop) && prop.hasJoinColumn)\n ) {\n zodType = z.number().int();\n }\n } else {\n throw new Error(`prop을 zodType으로 변환하는데 실패 ${prop}}`);\n }\n\n if ((prop as { unsigned?: boolean }).unsigned) {\n zodType = (zodType as z.ZodNumber).nonnegative();\n }\n if (prop.nullable) {\n zodType = zodType.nullable();\n }\n\n return zodType;\n }\n\n resolveRenderType(\n key: string,\n zodType: z.ZodTypeAny\n ): RenderingNode[\"renderType\"] {\n if (zodType instanceof z.ZodDate) {\n return \"datetime\";\n } else if (zodType instanceof z.ZodString) {\n if (key.includes(\"img\") || key.includes(\"image\")) {\n return \"string-image\";\n } else if (zodType.description === \"SQLDateTimeString\") {\n return \"string-datetime\";\n } else if (key.endsWith(\"date\")) {\n return \"string-date\";\n } else {\n return \"string-plain\";\n }\n } else if (zodType instanceof z.ZodNumber) {\n if (key === \"id\") {\n return \"number-id\";\n } else if (key.endsWith(\"_id\")) {\n return \"number-fk_id\";\n } else {\n return \"number-plain\";\n }\n } else if (zodType instanceof z.ZodBoolean) {\n return \"boolean\";\n } else if (zodType instanceof z.ZodEnum) {\n return \"enums\";\n } else if (zodType instanceof z.ZodRecord) {\n return \"record\";\n } else if (zodType instanceof z.ZodAny || zodType instanceof z.ZodUnknown) {\n return \"string-plain\";\n } else if (zodType instanceof z.ZodUnion) {\n return \"string-plain\";\n } else if (zodType instanceof z.ZodLiteral) {\n return \"string-plain\";\n } else {\n throw new Error(`타입 파싱 불가 ${key} ${zodType.def.type}`);\n }\n }\n\n zodTypeToRenderingNode(\n zodType: z.ZodType<any>,\n baseKey: string = \"root\"\n ): RenderingNode {\n const def = {\n name: baseKey,\n label: inflection.camelize(baseKey, false),\n zodType,\n };\n if (zodType instanceof z.ZodObject) {\n const columnKeys = Object.keys(zodType.shape);\n const children = columnKeys.map((key) => {\n const innerType = zodType.shape[key];\n return this.zodTypeToRenderingNode(innerType, key);\n });\n return {\n ...def,\n renderType: \"object\",\n children,\n };\n } else if (zodType instanceof z.ZodArray) {\n const innerType = (zodType as z.ZodArray<z.ZodType<any>>).def.element;\n if (innerType instanceof z.ZodString && baseKey.includes(\"images\")) {\n return {\n ...def,\n renderType: \"array-images\",\n };\n }\n return {\n ...def,\n renderType: \"array\",\n element: this.zodTypeToRenderingNode(innerType, baseKey),\n };\n } else if (zodType instanceof z.ZodUnion) {\n const optionNodes = (zodType as z.ZodUnion<z.ZodType[]>).def.options.map((opt) =>\n this.zodTypeToRenderingNode(opt, baseKey)\n );\n // TODO: ZodUnion이 들어있는 경우 핸들링\n return optionNodes[0];\n } else if (zodType instanceof z.ZodOptional) {\n return {\n ...this.zodTypeToRenderingNode((zodType as z.ZodOptional<z.ZodType>).def.innerType, baseKey),\n optional: true,\n };\n } else if (zodType instanceof z.ZodNullable) {\n return {\n ...this.zodTypeToRenderingNode((zodType as z.ZodNullable<z.ZodType>).def.innerType, baseKey),\n nullable: true,\n };\n } else {\n return {\n ...def,\n renderType: this.resolveRenderType(baseKey, zodType),\n };\n }\n }\n\n async getColumnsNode(\n entityId: string,\n subsetKey: string\n ): Promise<RenderingNode> {\n const entity = EntityManager.get(entityId);\n const subsetA = entity.subsets[subsetKey];\n if (subsetA === undefined) {\n throw new ServiceUnavailableException(\"SubsetA 가 없습니다.\");\n }\n const propNodes = entity.fieldExprsToPropNodes(subsetA);\n const rootPropNode: EntityPropNode = {\n nodeType: \"object\",\n children: propNodes,\n };\n\n const columnsZodType = (await this.propNodeToZodType(\n rootPropNode\n )) as z.ZodObject<any>;\n\n const columnsNode = this.zodTypeToRenderingNode(columnsZodType);\n columnsNode.children = columnsNode.children!.map((child) => {\n if (child.renderType === \"object\") {\n const pickedCol = child.children!.find((cc) =>\n [\"title\", \"name\"].includes(cc.name)\n );\n if (pickedCol) {\n return {\n ...child,\n renderType: \"object-pick\",\n config: {\n picked: pickedCol.name,\n },\n };\n } else {\n return child;\n }\n } else if (\n child.renderType === \"array\" &&\n child.element &&\n child.element.renderType === \"object\"\n ) {\n const pickedCol = child.element!.children!.find((cc) =>\n [\"title\", \"name\"].includes(cc.name)\n );\n if (pickedCol) {\n return {\n ...child,\n element: {\n ...child.element,\n renderType: \"object-pick\",\n config: {\n picked: pickedCol.name,\n },\n },\n };\n } else {\n return child;\n }\n }\n return child;\n });\n\n return columnsNode;\n }\n\n async createEntity(\n form: Omit<TemplateOptions[\"entity\"], \"title\"> & { title?: string }\n ) {\n if (!/^[A-Z][a-zA-Z0-9]*$/.test(form.entityId)) {\n throw new BadRequestException(\"entityId는 CamelCase 형식이어야 합니다.\");\n }\n\n await this.generateTemplate(\"entity\", form);\n\n // reload entities\n await EntityManager.reload();\n\n // syncFromWatcher에서 처리하므로 주석처리\n // this.actionGenerateSchemas();\n\n // // generate schemas, types\n // await Promise.all([\n // ...(form.parentId === undefined\n // ? [\n // this.generateTemplate(\"init_types\", {\n // entityId: form.entityId,\n // }),\n // ]\n // : []),\n // ]);\n }\n\n async delEntity(entityId: string): Promise<{ delPaths: string[] }> {\n const entity = EntityManager.get(entityId);\n\n const delPaths = (() => {\n if (entity.parentId) {\n return [\n `${Sonamu.apiRootPath}/src/application/${entity.names.parentFs}/${entity.names.fs}.entity.json`,\n ];\n } else {\n return [\n `${Sonamu.apiRootPath}/src/application/${entity.names.fs}`,\n `${Sonamu.apiRootPath}/dist/application/${entity.names.fs}`,\n ...Sonamu.config.sync.targets\n .map((target) => [\n `${Sonamu.appRootPath}/${target}/src/services/${entity.names.fs}`,\n ])\n .flat(),\n ];\n }\n })(); // iife\n\n for await (const delPath of delPaths) {\n if (await exists(delPath)) {\n console.log(chalk.red(`DELETE ${delPath}`));\n await rm(delPath, { recursive: true, force: true });\n } else {\n console.log(chalk.yellow(`NOT_EXISTS ${delPath}`));\n }\n }\n\n // reload entities\n await EntityManager.reload();\n\n return { delPaths };\n }\n\n syncUI() {\n const uiPort = Sonamu.config.ui?.port ?? 57000;\n\n fetch(`http://127.0.0.1:${uiPort}/api/reload`, {\n method: \"GET\",\n }).catch((e) =>\n console.log(chalk.dim(`Failed to reload Sonamu UI: ${e.message}`))\n );\n }\n}\n"],"names":["Syncer","apis","types","models","isSyncing","checksumPatternGroup","entity","Sonamu","apiRootPath","generated","functions","model","frame","resolveParamDec","paramDec","index","name","type","resolveTypeNode","undefined","console","debug","result","escapedText","toString","optional","defaultDef","ts","isObjectBindingPattern","isTypeReferenceNode","isIdentifier","typeName","inflection","camelize","text","checksumsPath","path","join","sync","targets","currentDirname","currentChecksums","previousChecksums","isSame","msg","margin","abc","onSIGUSR2","diff","diffFiles","changedChecksums","config","__dirname","endsWith","Promise","all","map","target","srcCodePath","dstCodePath","srcChecksum","dstChecksum","replace","exists","appRootPath","getChecksumOfFile","readFile","writeFile","log","chalk","blue","getCurrentChecksums","getPreviousChecksums","equal","process","stdout","columns","length","black","bgGreen","repeat","AbortController","exit","magentaBright","setTimeoutPromises","signal","on","_","differenceWith","isEqual","r","doSyncActions","saveChecksums","abort","off","diffGroups","diffTypes","entityId","typeFilePath","tsPaths","mergedGroup","params","groupBy","matched","match","Object","keys","includes","EntityManager","reload","actionGenerateSchemas","getEntityIdFromPath","get","names","fs","parentId","generateTemplate","uniq","push","p","actionSyncFilesToTargets","autoloadModels","autoloadApis","modelPath","assert","namesRecord","getNamesFromId","modelTsPath","frameName","Error","actionGenerateServices","actionGenerateHttps","syncFromWatcher","tsFiles","jsonFiles","chunks","transpiledFilePaths","chunk","_transpiledFilePaths","allFilePaths","targetFilePaths","clearModuleAndDependents","filePath","resolved","require","resolve","toDelete","Set","cache","forEach","key","mod","children","some","child","id","add","kill","pid","filter","file","diffFile","code","jsPath","mapPath","sourceMapComment","swc","transformFile","module","jsc","parser","syntax","decorators","sourceMaps","mkdir","dirname","recursive","basename","flag","bold","values","pattern","minimatch","relative","autoloadTypes","syncUI","filePaths","overwrite","flat","paramsArray","res","copyFileWithReplaceCoreToShared","fromPath","toPath","oldFileContent","newFileContent","nfc","apiDir","api","dir","src","realSrc","dst","fileChecksums","entries","_fileType","globAsync","sort","substring","checksum","JSON","parse","checksums","stringify","reject","hash","crypto","createHash","input","createReadStream","update","digest","readApisFromFile","sourceFile","methods","modelName","methodName","visitor","currentModelApis","extendedApis","createSourceFile","ScriptTarget","Latest","node","isClassDeclaration","isMethodDeclaration","typeParameters","typeParam","tp","t","constraint","parameters","printNode","initializer","questionToken","returnType","forEachChild","registeredApis","find","method","foundMethod","typeNode","kind","SyntaxKind","AnyKeyword","UnknownKeyword","StringKeyword","NumberKeyword","BooleanKeyword","UndefinedKeyword","NullKeyword","VoidKeyword","LiteralType","literal","isStringLiteral","value","isNumericLiteral","Number","TrueKeyword","FalseKeyword","ArrayType","arrNode","elementsType","elementType","TypeLiteral","literalNode","props","members","member","isIndexSignatureDeclaration","TypeReference","args","typeArguments","typeArg","UnionType","IntersectionType","IndexedAccessType","object","objectType","indexType","TupleType","isTupleTypeNode","elements","elem","printer","createPrinter","newLine","NewLineKind","LineFeed","EmitHint","Unspecified","pathPattern","modules","filterAsync","srcPath","importMultiple","imported","fromEntries","doRefresh","pathPatterns","mapAsync","f","z","ZodType","getTemplate","Template__entity","Template__init_types","Template__generated","Template__generated_sso","Template__generated_http","Template__model","Template__model_test","Template__service","Template__view_list","Template__view_list_columns","Template__view_search_input","Template__view_form","Template__view_id_all_select","Template__view_id_async_select","Template__view_enums_select","Template__view_enums_dropdown","Template__view_enums_buttonset","BadRequestException","renderTemplate","options","template","extra","columnsNode","listParamsZodType","listParamsNode","saveParamsZodType","saveParamsNode","rendered","preTemplateResolved","getColumnsNode","getZodTypeById","zodTypeToRenderingNode","render","resolveRenderedTemplate","preTemplates","body","importKeys","customHeaders","importDefs","header","formatted","reduce","importKey","modulePath","getModulePath","importPath","wrapIf","startsWith","existsOne","importDef","from","concat","prettier","format","writeCodeToPath","pathAndCode","dstFilePaths","dstFilePath","templateOptions","_generateOptions","generateOptions","pathAndCodes","filteredPathAndCodes","everyAsync","dstPath","AlreadyProcessedException","checkExistsGenCode","templateKey","enumId","genPath","fullPath","subPath","getTargetAndPath","isExists","checkExists","enums","enumsKeys","TemplateKey","constant","reduceAsync","tpl","componentId","zodTypeId","moduleAbsPath","describe","propNodeToZodType","propNode","innerType","obj","nodeType","propToZodType","prop","array","nullable","promise","childPropNode","zodType","unknown","isIntegerProp","number","int","isBigIntegerProp","bigint","isTextProp","string","max","getTextTypeLength","textType","isEnumProp","isStringProp","isFloatProp","isDoubleProp","isDecimalProp","isBooleanProp","boolean","isDateProp","isTimeProp","isDateTimeProp","date","isTimestampProp","isJsonProp","isUuidProp","uuid","isVirtualProp","isRelationProp","isBelongsToOneRelationProp","isOneToOneRelationProp","hasJoinColumn","unsigned","nonnegative","resolveRenderType","ZodDate","ZodString","description","ZodNumber","ZodBoolean","ZodEnum","ZodRecord","ZodAny","ZodUnknown","ZodUnion","ZodLiteral","def","baseKey","label","ZodObject","columnKeys","shape","renderType","ZodArray","element","optionNodes","opt","ZodOptional","ZodNullable","subsetKey","subsetA","propNodes","rootPropNode","columnsZodType","subsets","ServiceUnavailableException","fieldExprsToPropNodes","pickedCol","cc","picked","createEntity","form","test","delEntity","delPaths","delPath","parentFs","red","rm","force","yellow","uiPort","ui","port","fetch","catch","e","dim","message"],"mappings":"oGAqHaA,gDAAAA,mEArHiB,4BACY,kCACT,4BACc,oCACxB,+EACJ,4EACD,+EACO,yEACF,0CAC0B,0FAClC,kCAyBR,0CAKA,sCACW,gEACA,oCAYX,uDACgB,oDACW,yDAEE,mEACC,gEACJ,2DACD,+DACK,iEACH,gEACE,kEACA,+FACf,qDACwB,sFACE,uFACD,oFACF,qFACG,qFACH,kFACA,+EACH,4DAClB,oDACiB,8DACS,6EAC9B,oEACE,qCACK,qCAMnB,4+PA+BA,IAAA,AAAMA,oBAAN,iCAAMA,+CAAAA,QACXC,sBAAAA,OAQM,EAAE,EACRC,sBAAAA,QAAkD,CAAC,GACnDC,sBAAAA,SAA2C,CAAC,GAC5CC,sBAAAA,YAAqB,OAErB,sBAAOC,uBAAoC,CAEzCC,OAAQC,cAAM,CAACC,WAAW,CAAG,oCAC7BN,MAAOK,cAAM,CAACC,WAAW,CAAG,iCAC5BC,UAAWF,cAAM,CAACC,WAAW,CAAG,uCAChCE,UAAWH,cAAM,CAACC,WAAW,CAAG,qCAEhCG,MAAOJ,cAAM,CAACC,WAAW,CAAG,kCAC5BI,MAAOL,cAAM,CAACC,WAAW,CAAG,iCAC9B,GA8tBAK,sBAAAA,kBAAkB,SAChBC,cAMAC,6DAAgB,EAEhB,IAAMC,KAAOF,SAASE,IAAI,CAC1B,IAAMC,KAAO,MAAKC,eAAe,CAACJ,SAASG,IAAI,EAE/C,GAAID,OAASG,UAAW,CACtBC,QAAQC,KAAK,CAAC,CAAEL,KAAAA,KAAMC,KAAAA,KAAMH,SAAAA,QAAS,EACvC,CAEA,IAAMQ,OAAmB,CACvBN,KAAMA,KAAKO,WAAW,CAAGP,KAAKO,WAAW,CAACC,QAAQ,GAAK,AAAC,WAAgB,OAANT,OAClEE,KAAAA,KACAQ,SAAUX,SAASW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C,+BAAwC,OAAVD,EAAEE,OAAO,KAElE,YAl/CWnf"}
@@ -1,13 +0,0 @@
1
- import { TemplateKey, TemplateOptions } from "../types/types";
2
- import { EntityNamesRecord } from "../entity/entity-manager";
3
- import { RenderedTemplate } from "../syncer/syncer";
4
- export declare abstract class Template {
5
- key: TemplateKey;
6
- constructor(key: TemplateKey);
7
- abstract render(options: TemplateOptions[TemplateKey], ...extra: unknown[]): RenderedTemplate | Promise<RenderedTemplate>;
8
- abstract getTargetAndPath(names?: EntityNamesRecord, ...extra: unknown[]): {
9
- target: string;
10
- path: string;
11
- };
12
- }
13
- //# sourceMappingURL=base-template.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-template.d.ts","sourceRoot":"","sources":["../../src/templates/base-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,8BAAsB,QAAQ;IACT,GAAG,EAAE,WAAW;gBAAhB,GAAG,EAAE,WAAW;aACnB,MAAM,CACpB,OAAO,EAAE,eAAe,CAAC,WAAW,CAAC,EACrC,GAAG,KAAK,EAAE,OAAO,EAAE,GAClB,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;aAE/B,gBAAgB,CAC9B,KAAK,CAAC,EAAE,iBAAiB,EACzB,GAAG,KAAK,EAAE,OAAO,EAAE,GAClB;QACD,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd;CACF"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template",{enumerable:true,get:function(){return Template}});function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}var Template=function Template(key){"use strict";_class_call_check(this,Template);_define_property(this,"key",void 0);this.key=key};
2
- //# sourceMappingURL=base-template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/templates/base-template.ts"],"sourcesContent":["import { TemplateKey, TemplateOptions } from \"../types/types\";\nimport { EntityNamesRecord } from \"../entity/entity-manager\";\nimport { RenderedTemplate } from \"../syncer/syncer\";\n\nexport abstract class Template {\n constructor(public key: TemplateKey) {}\n public abstract render(\n options: TemplateOptions[TemplateKey],\n ...extra: unknown[]\n ): RenderedTemplate | Promise<RenderedTemplate>;\n\n public abstract getTargetAndPath(\n names?: EntityNamesRecord,\n ...extra: unknown[]\n ): {\n target: string;\n path: string;\n };\n}\n"],"names":["Template","key"],"mappings":"oGAIsBA,kDAAAA,kVAAf,IAAA,AAAeA,SAAf,SAAeA,SACR,AAAOC,GAAgB,sCADfD,mDACDC,IAAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity.template.d.ts","sourceRoot":"","sources":["../../src/templates/entity.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,gBAAiB,SAAQ,QAAQ;;IAK5C,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,WAAW,CAAC,EAAE,iBAAiB;;;;IAS1E,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC;;;;;;CAoE1C"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__entity",{enumerable:true,get:function(){return Template__entity}});var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _api=require("../api");function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__entity=/*#__PURE__*/function(Template){"use strict";_inherits(Template__entity,Template);function Template__entity(){_class_call_check(this,Template__entity);return _call_super(this,Template__entity,["entity"])}_create_class(Template__entity,[{key:"getTargetAndPath",value:function getTargetAndPath(names,parentNames){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"".concat((parentNames!==null&&parentNames!==void 0?parentNames:names).fs,"/").concat(names.fs,".entity.json")}}},{key:"render",value:function render(options){var _options_props;var entityId=options.entityId,title=options.title,parentId=options.parentId,table=options.table;var names=_entitymanager.EntityManager.getNamesFromId(entityId);var parent=function(){if(parentId){return{names:_entitymanager.EntityManager.getNamesFromId(parentId),entity:_entitymanager.EntityManager.get(parentId)}}else{return null}}();var _parent_names,_options_indexes,_options_subsets,_options_enums;var _obj;return _object_spread_props(_object_spread({},this.getTargetAndPath(names,(_parent_names=parent===null||parent===void 0?void 0:parent.names)!==null&&_parent_names!==void 0?_parent_names:names)),{body:JSON.stringify({id:entityId,title:title!==null&&title!==void 0?title:entityId,parentId:parentId,table:table!==null&&table!==void 0?table:names.fsPlural.replace(/\-/g,"_"),props:((_options_props=options.props)===null||_options_props===void 0?void 0:_options_props.length)?options.props:[{name:"id",type:"integer",unsigned:true,desc:"ID"}].concat(_to_consumable_array(parent?[{type:"relation",name:parent.names.camel,relationType:"BelongsToOne",with:parentId,onUpdate:"CASCADE",onDelete:"CASCADE",desc:parent.entity.title}]:[]),[{name:"created_at",type:"timestamp",desc:"등록일시",dbDefault:"CURRENT_TIMESTAMP"}]),indexes:_to_consumable_array((_options_indexes=options.indexes)!==null&&_options_indexes!==void 0?_options_indexes:[]),subsets:(_options_subsets=options.subsets)!==null&&_options_subsets!==void 0?_options_subsets:_object_spread({},parentId?{}:{A:["id","created_at"]}),enums:(_options_enums=options.enums)!==null&&_options_enums!==void 0?_options_enums:_object_spread({},parentId?{}:(_obj={},_define_property(_obj,"".concat(names.capital,"OrderBy"),{"id-desc":"ID최신순"}),_define_property(_obj,"".concat(names.capital,"SearchField"),{id:"ID"}),_obj))}).trim(),importKeys:[]})}}]);return Template__entity}(_basetemplate.Template);
2
- //# sourceMappingURL=entity.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/templates/entity.template.ts"],"sourcesContent":["import { TemplateOptions } from \"../types/types\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport { Sonamu } from \"../api\";\n\nexport class Template__entity extends Template {\n constructor() {\n super(\"entity\");\n }\n\n getTargetAndPath(names: EntityNamesRecord, parentNames?: EntityNamesRecord) {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `${(parentNames ?? names).fs}/${names.fs}.entity.json`,\n };\n }\n\n render(options: TemplateOptions[\"entity\"]) {\n const { entityId, title, parentId, table } = options;\n const names = EntityManager.getNamesFromId(entityId);\n\n const parent = (() => {\n if (parentId) {\n return {\n names: EntityManager.getNamesFromId(parentId),\n entity: EntityManager.get(parentId),\n };\n } else {\n return null;\n }\n })();\n\n return {\n ...this.getTargetAndPath(names, parent?.names ?? names),\n body: JSON.stringify({\n id: entityId,\n title: title ?? entityId,\n parentId,\n table: table ?? names.fsPlural.replace(/\\-/g, \"_\"),\n props: options.props?.length\n ? options.props\n : [\n { name: \"id\", type: \"integer\", unsigned: true, desc: \"ID\" },\n ...(parent\n ? [\n {\n type: \"relation\",\n name: parent.names.camel,\n relationType: \"BelongsToOne\",\n with: parentId,\n onUpdate: \"CASCADE\",\n onDelete: \"CASCADE\",\n desc: parent.entity.title,\n },\n ]\n : []),\n {\n name: \"created_at\",\n type: \"timestamp\",\n desc: \"등록일시\",\n dbDefault: \"CURRENT_TIMESTAMP\",\n },\n ],\n indexes: [...(options.indexes ?? [])],\n subsets: options.subsets ?? {\n ...(parentId\n ? {}\n : {\n A: [\"id\", \"created_at\"],\n }),\n },\n enums: options.enums ?? {\n ...(parentId\n ? {}\n : {\n [`${names.capital}OrderBy`]: {\n \"id-desc\": \"ID최신순\",\n },\n [`${names.capital}SearchField`]: { id: \"ID\" },\n }),\n },\n }).trim(),\n importKeys: [],\n };\n }\n}\n"],"names":["Template__entity","getTargetAndPath","names","parentNames","dir","Sonamu","config","api","target","path","fs","render","options","entityId","title","parentId","table","EntityManager","getNamesFromId","parent","entity","get","body","JSON","stringify","id","fsPlural","replace","props","length","name","type","unsigned","desc","camel","relationType","with","onUpdate","onDelete","dbDefault","indexes","subsets","A","enums","capital","trim","importKeys","Template"],"mappings":"oGAKaA,0DAAAA,+CAJoC,sDACxB,oCACF,ugJAEhB,IAAA,AAAMA,8BAAN,0CAAMA,oCAAAA,0CAAAA,kBAET,OAAA,iBAFSA,kBAEH,yBAFGA,mBAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,CAAEC,WAA+B,EACxE,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,AAAC,GAA+BP,OAA7B,AAACC,CAAAA,oBAAAA,qBAAAA,YAAeD,KAAI,EAAGQ,EAAE,CAAC,KAAY,OAATR,MAAMQ,EAAE,CAAC,eACjD,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAOC,OAAkC,MAsB5BA,eArBX,IAAQC,SAAqCD,QAArCC,SAAUC,MAA2BF,QAA3BE,MAAOC,SAAoBH,QAApBG,SAAUC,MAAUJ,QAAVI,MACnC,IAAMd,MAAQe,4BAAa,CAACC,cAAc,CAACL,UAE3C,IAAMM,OAAS,AAAC,WACd,GAAIJ,SAAU,CACZ,MAAO,CACLb,MAAOe,4BAAa,CAACC,cAAc,CAACH,UACpCK,OAAQH,4BAAa,CAACI,GAAG,CAACN,SAC5B,CACF,KAAO,CACL,OAAO,IACT,CACF,QAGkCI,cA8BhBP,iBACLA,iBAOFA,mBAGD,KA1CV,OAAO,uCACF,IAAI,CAACX,gBAAgB,CAACC,MAAOiB,CAAAA,cAAAA,eAAAA,uBAAAA,OAAQjB,KAAK,UAAbiB,uBAAAA,cAAiBjB,SACjDoB,KAAMC,KAAKC,SAAS,CAAC,CACnBC,GAAIZ,SACJC,MAAOA,cAAAA,eAAAA,MAASD,SAChBE,SAAAA,SACAC,MAAOA,cAAAA,eAAAA,MAASd,MAAMwB,QAAQ,CAACC,OAAO,CAAC,MAAO,KAC9CC,MAAOhB,EAAAA,eAAAA,QAAQgB,KAAK,UAAbhB,+BAAAA,eAAeiB,MAAM,EACxBjB,QAAQgB,KAAK,CACb,CACE,CAAEE,KAAM,KAAMC,KAAM,UAAWC,SAAU,KAAMC,KAAM,IAAK,EAoB3D,CArBD,OAEE,qBAAId,OACA,CACE,CACEY,KAAM,WACND,KAAMX,OAAOjB,KAAK,CAACgC,KAAK,CACxBC,aAAc,eACdC,KAAMrB,SACNsB,SAAU,UACVC,SAAU,UACVL,KAAMd,OAAOC,MAAM,CAACN,KAAK,AAC3B,EACD,CACD,EAAE,EAdR,CAeE,CACEgB,KAAM,aACNC,KAAM,YACNE,KAAM,OACNM,UAAW,mBACb,EACD,EACLC,QAAU,qBAAI5B,CAAAA,iBAAAA,QAAQ4B,OAAO,UAAf5B,0BAAAA,iBAAmB,EAAE,EACnC6B,QAAS7B,CAAAA,iBAAAA,QAAQ6B,OAAO,UAAf7B,0BAAAA,iBAAmB,kBACtBG,SACA,CAAC,EACD,CACE2B,EAAG,CAAC,KAAM,aAAa,AACzB,GAENC,MAAO/B,CAAAA,eAAAA,QAAQ+B,KAAK,UAAb/B,wBAAAA,eAAiB,kBAClBG,SACA,CAAC,GACD,QACE,iBADF,KACG,AAAC,GAAgB,OAAdb,MAAM0C,OAAO,CAAC,WAAW,CAC3B,UAAW,OACb,GACA,iBAJF,KAIG,AAAC,GAAgB,OAAd1C,MAAM0C,OAAO,CAAC,eAAe,CAAEnB,GAAI,IAAK,GAJ9C,MAOR,GAAGoB,IAAI,GACPC,WAAY,EAAE,EAElB,YAjFW9C,kBAAyB+C,sBAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated.template.d.ts","sourceRoot":"","sources":["../../src/templates/generated.template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AACF,qBAAa,mBAAoB,SAAQ,QAAQ;;IAK/C,gBAAgB;;;;IAShB,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,WAAW,CAAC;;;;;;;IAyGvC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAsBrD,uBAAuB,CACrB,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,MAAM,EAAO,GACxB,UAAU;IAsCb,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAiD9D,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;CAmDvD"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__generated",{enumerable:true,get:function(){return Template__generated}});var _lodash=/*#__PURE__*/_interop_require_default(require("lodash"));var _entitymanager=require("../entity/entity-manager");var _codeconverters=require("../api/code-converters");var _basetemplate=require("./base-template");var _utils=require("../utils/utils");var _api=require("../api");function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _interop_require_default(obj){return obj&&obj.__esModule?obj:{default:obj}}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_destructuring_empty(o){if(o===null||o===void 0)throw new TypeError("Cannot destructure "+o);return o}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__generated=/*#__PURE__*/function(Template){"use strict";_inherits(Template__generated,Template);function Template__generated(){_class_call_check(this,Template__generated);return _call_super(this,Template__generated,["generated"])}_create_class(Template__generated,[{key:"getTargetAndPath",value:function getTargetAndPath(){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"sonamu.generated.ts"}}},{key:"render",value:function render(param){var _this=this;var ref=_object_destructuring_empty(param);var entityIds=_entitymanager.EntityManager.getAllIds();var entities=entityIds.map(function(id){return _entitymanager.EntityManager.get(id)});var sourceCodes=entities.map(function(entity){return[_this.getEnumsSourceCode(entity),_this.getBaseSchemaSourceCode(entity),_this.getBaseListParamsSourceCode(entity),_this.getSubsetSourceCode(entity)].filter(_utils.nonNullable)}).flat();var LABEL_KEY_ORDER=["Enums","BaseSchema","BaseListParams","Subsets","SubsetQueries"];sourceCodes.sort(function(a,b){var _a_label_split=_sliced_to_array(a.label.split(":"),1),aKey=_a_label_split[0];var _b_label_split=_sliced_to_array(b.label.split(":"),1),bKey=_b_label_split[0];var aIndex=LABEL_KEY_ORDER.indexOf(aKey);var bIndex=LABEL_KEY_ORDER.indexOf(bKey);if(aIndex>bIndex){return 1}else if(aIndex<bIndex){return-1}else{return 0}});var sourceCode=sourceCodes.reduce(function(result,ts){if(ts===null){return result}return{lines:_to_consumable_array(result.lines).concat(["// ".concat(ts.label)],_to_consumable_array(ts.lines),[""]),importKeys:_lodash.default.uniq(_to_consumable_array(result.importKeys).concat(_to_consumable_array(ts.importKeys)).sort())}},{lines:[],importKeys:[]});var allTypeKeys=entities.map(function(entity){return Object.keys(entity.types)}).flat();var cdImportKeys=sourceCode.importKeys.filter(function(importKey){return allTypeKeys.includes(importKey)});if(cdImportKeys.length>0){var customScalarLines=cdImportKeys.map(function(importKey){var entity=entities.find(function(entity){return entity.types[importKey]});if(!entity){throw new Error("ZodType not found ".concat(importKey))}var zodType=entity.types[importKey];return["// CustomScalar: ".concat(importKey),"const ".concat(importKey," = ").concat((0,_codeconverters.zodTypeToZodCode)(zodType),";"),"type ".concat(importKey," = z.infer<typeof ").concat(importKey,">"),""]}).flat();sourceCode.lines=_to_consumable_array(customScalarLines).concat(_to_consumable_array(sourceCode.lines));sourceCode.importKeys=sourceCode.importKeys.filter(function(importKey){return!cdImportKeys.includes(importKey)})}var body=sourceCode.lines.join("\n");var sonamuImports=["zArrayable","SQLDateTimeString","SubsetQuery","SonamuQueryMode"].filter(function(mod){return body.includes(mod)});return _object_spread_props(_object_spread({},this.getTargetAndPath()),{body:body,importKeys:sourceCode.importKeys,customHeaders:["import { z } from 'zod';","import { ".concat(sonamuImports.join(","),' } from "sonamu";')]})}},{key:"getEnumsSourceCode",value:function getEnumsSourceCode(entity){if(Object.keys(entity.enumLabels).length===0){return null}return{label:"Enums: ".concat(entity.id),lines:_to_consumable_array(Object.entries(entity.enumLabels).filter(function(param){var _param=_sliced_to_array(param,2),_=_param[0],enumLabel=_param[1];return Object.keys(enumLabel).length>0}).map(function(param){var _param=_sliced_to_array(param,2),enumId=_param[0],enumLabel=_param[1];return["export const ".concat(enumId," = z.enum([").concat(Object.keys(enumLabel).map(function(el){return'"'.concat(el,'"')}),']).describe("').concat(enumId,'");'),"export type ".concat(enumId," = z.infer<typeof ").concat(enumId,">"),"export const ".concat(enumId,"Label = ").concat(JSON.stringify(enumLabel))]}).flat()),importKeys:[]}}},{key:"getBaseSchemaSourceCode",value:function getBaseSchemaSourceCode(entity){var importKeys=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];var schemaName="".concat(entity.names.module,"BaseSchema");var propNode={nodeType:"object",children:entity.props.map(function(prop){return{nodeType:"plain",prop:prop}})};var schemaBody=(0,_codeconverters.propNodeToZodTypeDef)(propNode,importKeys);var fulltextColumns=_lodash.default.uniq(entity.indexes.filter(function(index){return index.type==="fulltext"}).flatMap(function(index){return index.columns}));var lines=["export const ".concat(schemaName," = ").concat(schemaBody),"export type ".concat(schemaName," = z.infer<typeof ").concat(schemaName,">")+(fulltextColumns.length>0?" & { readonly __fulltext__: readonly [".concat(fulltextColumns.map(function(col){return'"'.concat(col,'"')}).join(", "),"] }"):"")];return{label:"BaseSchema: ".concat(entity.id),importKeys:importKeys,lines:lines}}},{key:"getBaseListParamsSourceCode",value:function getBaseListParamsSourceCode(entity){if(entity.props.length===0){return null}else if(entity.parentId!==undefined){return null}var schemaName="".concat(entity.names.module,"BaseListParams");var filterProps=entity.props.filter(function(prop){return prop.toFilter===true});var propNodes=filterProps.map(function(prop){return{nodeType:"plain",prop:prop,children:[]}});var importKeys=[];var filterBody=propNodes.map(function(propNode){return(0,_codeconverters.propNodeToZodTypeDef)(propNode,importKeys)}).join("\n");var schemaBody="\nz.object({\n num: z.number().int().nonnegative(),\n page: z.number().int().min(1),\n search: ".concat(entity.id,"SearchField,\n keyword: z.string(),\n orderBy: ").concat(entity.id,"OrderBy,\n queryMode: SonamuQueryMode,\n id: zArrayable(z.number().int().positive()),").concat(filterBody,"\n}).partial();\n").trim();var lines=["export const ".concat(schemaName," = ").concat(schemaBody),"export type ".concat(schemaName," = z.infer<typeof ").concat(schemaName,">")];return{label:"BaseListParams: ".concat(entity.id),importKeys:importKeys,lines:lines}}},{key:"getSubsetSourceCode",value:function getSubsetSourceCode(entity){if(Object.keys(entity.subsets).length==0){return null}else if(entity.parentId!==undefined){return null}var subsetKeys=Object.keys(entity.subsets);var importKeys=[];var lines=_to_consumable_array(subsetKeys.map(function(subsetKey){var fieldExprs=entity.subsets[subsetKey];var propNodes=entity.fieldExprsToPropNodes(fieldExprs);var schemaName="".concat(entity.names.module,"Subset").concat(subsetKey);var propNode={nodeType:"object",children:propNodes};var body=(0,_codeconverters.propNodeToZodTypeDef)(propNode,importKeys);return["export const ".concat(schemaName," = ").concat(body),"export type ".concat(schemaName," = z.infer<typeof ").concat(schemaName,">")]}).flat()).concat(["export type ".concat(entity.names.module,"SubsetMapping = {")],_to_consumable_array(subsetKeys.map(function(subsetKey){return" ".concat(subsetKey,": ").concat(entity.names.module,"Subset").concat(subsetKey,";")})),["}","export const ".concat(entity.names.module,"SubsetKey = z.enum([").concat(subsetKeys.map(function(k){return'"'.concat(k,'"')}).join(","),"]);"),"export type ".concat(entity.names.module,"SubsetKey = z.infer<typeof ").concat(entity.names.module,"SubsetKey>"),""]);return{label:"Subsets: ".concat(entity.id),lines:lines,importKeys:_lodash.default.uniq(importKeys)}}}]);return Template__generated}(_basetemplate.Template);
2
- //# sourceMappingURL=generated.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/templates/generated.template.ts"],"sourcesContent":["import _ from \"lodash\";\nimport { TemplateOptions } from \"../types/types\";\nimport { EntityManager } from \"../entity/entity-manager\";\nimport { Entity } from \"../entity/entity\";\nimport { EntityPropNode } from \"../types/types\";\nimport { propNodeToZodTypeDef, zodTypeToZodCode } from \"../api/code-converters\";\nimport { Template } from \"./base-template\";\nimport { nonNullable } from \"../utils/utils\";\nimport { Sonamu } from \"../api\";\n\nexport type SourceCode = {\n label: string;\n lines: string[];\n importKeys: string[];\n};\nexport class Template__generated extends Template {\n constructor() {\n super(\"generated\");\n }\n\n getTargetAndPath() {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `sonamu.generated.ts`,\n };\n }\n\n render({}: TemplateOptions[\"generated\"]) {\n const entityIds = EntityManager.getAllIds();\n const entities = entityIds.map((id) => EntityManager.get(id));\n\n // 전체 SourceCode 생성\n const sourceCodes = entities\n .map((entity) => {\n return [\n this.getEnumsSourceCode(entity),\n this.getBaseSchemaSourceCode(entity),\n this.getBaseListParamsSourceCode(entity),\n this.getSubsetSourceCode(entity),\n ].filter(nonNullable);\n })\n .flat();\n\n // Sort\n const LABEL_KEY_ORDER = [\n \"Enums\",\n \"BaseSchema\",\n \"BaseListParams\",\n \"Subsets\",\n \"SubsetQueries\",\n ];\n sourceCodes.sort((a, b) => {\n const [aKey] = a.label.split(\":\");\n const [bKey] = b.label.split(\":\");\n const aIndex = LABEL_KEY_ORDER.indexOf(aKey);\n const bIndex = LABEL_KEY_ORDER.indexOf(bKey);\n if (aIndex > bIndex) {\n return 1;\n } else if (aIndex < bIndex) {\n return -1;\n } else {\n return 0;\n }\n });\n\n const sourceCode = sourceCodes.reduce(\n (result, ts) => {\n if (ts === null) {\n return result;\n }\n return {\n lines: [...result!.lines, `// ${ts.label}`, ...ts.lines, \"\"],\n importKeys: _.uniq([...result!.importKeys, ...ts.importKeys].sort()),\n };\n },\n {\n lines: [],\n importKeys: [],\n } as Omit<SourceCode, \"label\">\n );\n\n // .types.ts의 타입을 참조하는 경우 순환참조(상호참조)가 발생하므로 타입을 가져와 인라인 처리\n const allTypeKeys = entities\n .map((entity) => Object.keys(entity.types))\n .flat();\n const cdImportKeys = sourceCode.importKeys.filter((importKey) =>\n allTypeKeys.includes(importKey)\n );\n if (cdImportKeys.length > 0) {\n const customScalarLines = cdImportKeys\n .map((importKey) => {\n const entity = entities.find((entity) => entity.types[importKey]);\n if (!entity) {\n throw new Error(`ZodType not found ${importKey}`);\n }\n const zodType = entity.types[importKey]!;\n\n return [\n `// CustomScalar: ${importKey}`,\n `const ${importKey} = ${zodTypeToZodCode(zodType)};`,\n `type ${importKey} = z.infer<typeof ${importKey}>`,\n \"\",\n ];\n })\n .flat();\n sourceCode.lines = [...customScalarLines, ...sourceCode.lines];\n sourceCode.importKeys = sourceCode.importKeys.filter(\n (importKey) => !cdImportKeys.includes(importKey)\n );\n }\n\n const body = sourceCode.lines.join(\"\\n\");\n\n // import\n const sonamuImports = [\n \"zArrayable\",\n \"SQLDateTimeString\",\n \"SubsetQuery\",\n \"SonamuQueryMode\",\n ].filter((mod) => body.includes(mod));\n\n return {\n ...this.getTargetAndPath(),\n body,\n importKeys: sourceCode.importKeys,\n customHeaders: [\n `import { z } from 'zod';`,\n `import { ${sonamuImports.join(\",\")} } from \"sonamu\";`,\n ],\n };\n }\n\n getEnumsSourceCode(entity: Entity): SourceCode | null {\n if (Object.keys(entity.enumLabels).length === 0) {\n return null;\n }\n return {\n label: `Enums: ${entity.id}`,\n lines: [\n ...Object.entries(entity.enumLabels)\n .filter(([_, enumLabel]) => Object.keys(enumLabel).length > 0)\n .map(([enumId, enumLabel]) => [\n `export const ${enumId} = z.enum([${Object.keys(enumLabel).map(\n (el) => `\"${el}\"`\n )}]).describe(\"${enumId}\");`,\n `export type ${enumId} = z.infer<typeof ${enumId}>`,\n `export const ${enumId}Label = ${JSON.stringify(enumLabel)}`,\n ])\n .flat(),\n ],\n importKeys: [],\n };\n }\n\n getBaseSchemaSourceCode(\n entity: Entity,\n importKeys: string[] = []\n ): SourceCode {\n const schemaName = `${entity.names.module}BaseSchema`;\n const propNode: EntityPropNode = {\n nodeType: \"object\",\n children: entity.props.map((prop) => {\n return {\n nodeType: \"plain\",\n prop,\n };\n }),\n };\n\n const schemaBody = propNodeToZodTypeDef(propNode, importKeys);\n\n // fulltext index에 포함된 컬럼들 추출\n const fulltextColumns = _.uniq(\n entity.indexes\n .filter((index) => index.type === \"fulltext\")\n .flatMap((index) => index.columns)\n );\n\n const lines = [\n `export const ${schemaName} = ${schemaBody}`,\n `export type ${schemaName} = z.infer<typeof ${schemaName}>` +\n (fulltextColumns.length > 0\n ? ` & { readonly __fulltext__: readonly [${fulltextColumns\n .map((col) => `\"${col}\"`)\n .join(\", \")}] }`\n : \"\"),\n ];\n\n return {\n label: `BaseSchema: ${entity.id}`,\n importKeys,\n lines,\n };\n }\n\n getBaseListParamsSourceCode(entity: Entity): SourceCode | null {\n // Prop 없는 MD인 경우 생성 제외\n if (entity.props.length === 0) {\n return null;\n } else if (entity.parentId !== undefined) {\n return null;\n }\n\n const schemaName = `${entity.names.module}BaseListParams`;\n\n const filterProps = entity.props.filter((prop) => prop.toFilter === true);\n\n const propNodes: EntityPropNode[] = filterProps.map((prop) => {\n return {\n nodeType: \"plain\" as const,\n prop,\n children: [],\n };\n });\n\n const importKeys: string[] = [];\n const filterBody = propNodes\n .map((propNode) => propNodeToZodTypeDef(propNode, importKeys))\n .join(\"\\n\");\n\n const schemaBody = `\nz.object({\n num: z.number().int().nonnegative(),\n page: z.number().int().min(1),\n search: ${entity.id}SearchField,\n keyword: z.string(),\n orderBy: ${entity.id}OrderBy,\n queryMode: SonamuQueryMode,\n id: zArrayable(z.number().int().positive()),${filterBody}\n}).partial();\n`.trim();\n\n const lines = [\n `export const ${schemaName} = ${schemaBody}`,\n `export type ${schemaName} = z.infer<typeof ${schemaName}>`,\n ];\n\n return {\n label: `BaseListParams: ${entity.id}`,\n importKeys,\n lines,\n };\n }\n\n getSubsetSourceCode(entity: Entity): SourceCode | null {\n if (Object.keys(entity.subsets).length == 0) {\n return null;\n } else if (entity.parentId !== undefined) {\n return null;\n }\n\n const subsetKeys = Object.keys(entity.subsets);\n const importKeys: string[] = [];\n const lines: string[] = [\n ...subsetKeys\n .map((subsetKey) => {\n // 서브셋에서 FieldExpr[] 가져옴\n const fieldExprs = entity.subsets[subsetKey];\n\n // FieldExpr[]로 EntityPropNode[] 가져옴\n const propNodes = entity.fieldExprsToPropNodes(fieldExprs);\n const schemaName = `${entity.names.module}Subset${subsetKey}`;\n const propNode: EntityPropNode = {\n nodeType: \"object\",\n children: propNodes,\n };\n\n // EntityPropNode[]로 ZodTypeDef(string)을 가져옴\n const body = propNodeToZodTypeDef(propNode, importKeys);\n\n return [\n `export const ${schemaName} = ${body}`,\n `export type ${schemaName} = z.infer<typeof ${schemaName}>`,\n ];\n })\n .flat(),\n `export type ${entity.names.module}SubsetMapping = {`,\n ...subsetKeys.map(\n (subsetKey) =>\n ` ${subsetKey}: ${entity.names.module}Subset${subsetKey};`\n ),\n \"}\",\n `export const ${entity.names.module}SubsetKey = z.enum([${subsetKeys\n .map((k) => `\"${k}\"`)\n .join(\",\")}]);`,\n `export type ${entity.names.module}SubsetKey = z.infer<typeof ${entity.names.module}SubsetKey>`,\n \"\",\n ];\n\n return {\n label: `Subsets: ${entity.id}`,\n lines,\n importKeys: _.uniq(importKeys),\n };\n }\n}\n"],"names":["Template__generated","getTargetAndPath","dir","Sonamu","config","api","target","path","render","entityIds","EntityManager","getAllIds","entities","map","id","get","sourceCodes","entity","getEnumsSourceCode","getBaseSchemaSourceCode","getBaseListParamsSourceCode","getSubsetSourceCode","filter","nonNullable","flat","LABEL_KEY_ORDER","sort","a","b","label","split","aKey","bKey","aIndex","indexOf","bIndex","sourceCode","reduce","result","ts","lines","importKeys","_","uniq","allTypeKeys","Object","keys","types","cdImportKeys","importKey","includes","length","customScalarLines","find","Error","zodType","zodTypeToZodCode","body","join","sonamuImports","mod","customHeaders","enumLabels","entries","enumLabel","enumId","el","JSON","stringify","schemaName","names","module","propNode","nodeType","children","props","prop","schemaBody","propNodeToZodTypeDef","fulltextColumns","indexes","index","type","flatMap","columns","col","parentId","undefined","filterProps","toFilter","propNodes","filterBody","trim","subsets","subsetKeys","subsetKey","fieldExprs","fieldExprsToPropNodes","k","Template"],"mappings":"oGAeaA,6DAAAA,iFAfC,sCAEgB,wDAGyB,oDAC9B,sCACG,mCACL,qhLAOhB,IAAA,AAAMA,iCAAN,0CAAMA,uCAAAA,6CAAAA,qBAET,OAAA,iBAFSA,qBAEH,4BAFGA,sBAKXC,IAAAA,yBAAAA,SAAAA,mBACE,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,qBACR,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAO,KAAgC,qBAAhC,gCAAA,OACL,IAAMC,UAAYC,4BAAa,CAACC,SAAS,GACzC,IAAMC,SAAWH,UAAUI,GAAG,CAAC,SAACC,WAAOJ,4BAAa,CAACK,GAAG,CAACD,M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AAK,CAACC,MAAM,CAAC,+BAAiD,OAApBtD,OAAOqD,KAAK,CAACC,MAAM,CAAC,cACpF,GACD,EAED,MAAO,CACL1C,MAAO,AAAC,YAAqB,OAAVZ,OAAOH,EAAE,EAC5B0B,MAAAA,MACAC,WAAYC,eAAC,CAACC,IAAI,CAACF,WACrB,CACF,YAzRWzC,qBAA4BmG,sBAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated_http.template.d.ts","sourceRoot":"","sources":["../../src/templates/generated_http.template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,qBAAa,wBAAyB,SAAQ,QAAQ;;IAKpD,gBAAgB;;;;IASV,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,gBAAgB,CAAC;;;;;;IAsDlD,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAoFvE,gBAAgB,CACd,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;KAAE,GACnD;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE;CAa9B"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__generated_http",{enumerable:true,get:function(){return Template__generated_http}});var _qs=/*#__PURE__*/_interop_require_default(require("qs"));var _zod=require("zod");var _codeconverters=require("../api/code-converters");var _basetemplate=require("./base-template");var _prettier=/*#__PURE__*/_interop_require_default(require("prettier"));var _sonamu=require("../api/sonamu");function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return!!right[Symbol.hasInstance](left)}else{return left instanceof right}}function _interop_require_default(obj){return obj&&obj.__esModule?obj:{default:obj}}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_destructuring_empty(o){if(o===null||o===void 0)throw new TypeError("Cannot destructure "+o);return o}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}var Template__generated_http=/*#__PURE__*/function(Template){"use strict";_inherits(Template__generated_http,Template);function Template__generated_http(){_class_call_check(this,Template__generated_http);return _call_super(this,Template__generated_http,["generated_http"])}_create_class(Template__generated_http,[{key:"getTargetAndPath",value:function getTargetAndPath(){var dir=_sonamu.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"sonamu.generated.http"}}},{key:"render",value:function render(_0){return _async_to_generator(function(param){var _this,ref,_Sonamu_syncer,types,apis,_Sonamu_config,prefix,lines;return _ts_generator(this,function(_state){switch(_state.label){case 0:_this=this;ref=_object_destructuring_empty(param);_Sonamu_syncer=_sonamu.Sonamu.syncer,types=_Sonamu_syncer.types,apis=_Sonamu_syncer.apis,_Sonamu_config=_sonamu.Sonamu.config,prefix=_Sonamu_config.route.prefix;return[4,Promise.all(apis.map(function(api){return _async_to_generator(function(){var reqObject,dataLines,_api_options_httpMethod,_api_options_contentType;return _ts_generator(this,function(_state){switch(_state.label){case 0:reqObject=this.resolveApiParams(api,types);return[4,function(){return _async_to_generator(function(){var _api_options_httpMethod,_tmp,_tmp1;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!(((_api_options_httpMethod=api.options.httpMethod)!==null&&_api_options_httpMethod!==void 0?_api_options_httpMethod:"GET")==="GET"))return[3,1];return[2,{querystring:[_qs.default.stringify(reqObject,{encode:false}).split("&").join("\n &")],body:[]}];case 1:_tmp={querystring:[]};_tmp1=[""];return[4,_prettier.default.format(JSON.stringify(reqObject),{parser:"json"})];case 2:return[2,(_tmp.body=_tmp1.concat([_state.sent()]),_tmp)];case 3:return[2]}})})()}()];case 1:dataLines=_state.sent();return[2,[["".concat((_api_options_httpMethod=api.options.httpMethod)!==null&&_api_options_httpMethod!==void 0?_api_options_httpMethod:"GET"," {{baseUrl}}").concat(prefix).concat(api.path)].concat(_to_consumable_array(dataLines.querystring)).join("\n ?"),"Content-Type: ".concat((_api_options_contentType=api.options.contentType)!==null&&_api_options_contentType!==void 0?_api_options_contentType:"application/json")].concat(_to_consumable_array(dataLines.body)).join("\n")]}})}).call(_this)}))];case 1:lines=_state.sent();return[2,_object_spread_props(_object_spread({},this.getTargetAndPath()),{body:lines.join("\n\n###\n\n"),importKeys:[]})]}})}).apply(this,arguments)}},{key:"zodTypeToReqDefault",value:function zodTypeToReqDefault(zodType,name){var _this=this;if(_instanceof(zodType,_zod.z.ZodObject)){return Object.fromEntries(Object.keys(zodType.shape).map(function(key){return[key,_this.zodTypeToReqDefault(zodType.shape[key],key)]}))}else if(_instanceof(zodType,_zod.z.ZodArray)){return[this.zodTypeToReqDefault(zodType.element,name)]}else if(_instanceof(zodType,_zod.z.ZodString)){if(name.endsWith("_at")||name.endsWith("_date")||name==="range"){return"2000-01-01"}else{return name.toUpperCase()}}else if(_instanceof(zodType,_zod.z.ZodNumber)){if(name==="num"){return 24}var _zodType_minValue;var minValue=(_zodType_minValue=zodType.minValue)!==null&&_zodType_minValue!==void 0?_zodType_minValue:0;return minValue>Number.MIN_SAFE_INTEGER?minValue:0}else if(_instanceof(zodType,_zod.z.ZodBoolean)){return false}else if(_instanceof(zodType,_zod.z.ZodEnum)){return zodType.options[0]}else if(_instanceof(zodType,_zod.z.ZodOptional)){return this.zodTypeToReqDefault(zodType.def.innerType,name)}else if(_instanceof(zodType,_zod.z.ZodNullable)){return null}else if(_instanceof(zodType,_zod.z.ZodUnion)){return this.zodTypeToReqDefault(zodType.def.options[0],name)}else if(_instanceof(zodType,_zod.z.ZodUnknown)){return"unknown"}else if(_instanceof(zodType,_zod.z.ZodTuple)){return zodType.def.items.map(function(item){return _this.zodTypeToReqDefault(item,name)})}else if(_instanceof(zodType,_zod.z.ZodDate)){return"2000-01-01"}else if(_instanceof(zodType,_zod.z.ZodLiteral)){return zodType.value}else if(_instanceof(zodType,_zod.z.ZodRecord)||_instanceof(zodType,_zod.z.ZodMap)){var kvDef=zodType.def;var key=this.zodTypeToReqDefault(kvDef.keyType,name);var value=this.zodTypeToReqDefault(kvDef.valueType,name);return _define_property({},key,value)}else if(_instanceof(zodType,_zod.z.ZodSet)){return[this.zodTypeToReqDefault(zodType.def.valueType,name)]}else if(_instanceof(zodType,_zod.z.ZodIntersection)){return this.zodTypeToReqDefault(zodType.def.right,name)}else if(_instanceof(zodType,_zod.z.ZodDefault)){return this.zodTypeToReqDefault(zodType.def.innerType,name)}else{return"unknown-".concat(zodType.type)}}},{key:"resolveApiParams",value:function resolveApiParams(api,references){var reqType=(0,_codeconverters.getZodObjectFromApi)(api,references);try{var def=this.zodTypeToReqDefault(reqType,"unknownName");return def}catch(error){throw new Error("Invalid zod type detected on ".concat(api.modelName,":").concat(api.methodName))}}}]);return Template__generated_http}(_basetemplate.Template);
2
- //# sourceMappingURL=generated_http.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/templates/generated_http.template.ts"],"sourcesContent":["import qs from \"qs\";\nimport { z } from \"zod\";\nimport { TemplateOptions } from \"../types/types\";\nimport { getZodObjectFromApi } from \"../api/code-converters\";\nimport { ExtendedApi } from \"../api/decorators\";\nimport { Template } from \"./base-template\";\nimport prettier from \"prettier\";\nimport { Sonamu } from \"../api/sonamu\";\n\nexport class Template__generated_http extends Template {\n constructor() {\n super(\"generated_http\");\n }\n\n getTargetAndPath() {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `sonamu.generated.http`,\n };\n }\n\n async render({}: TemplateOptions[\"generated_http\"]) {\n const {\n syncer: { types, apis },\n config: {\n route: { prefix },\n },\n } = Sonamu;\n\n const lines = await Promise.all(\n apis.map(async (api) => {\n const reqObject = this.resolveApiParams(api, types);\n\n const dataLines = await (async () => {\n if ((api.options.httpMethod ?? \"GET\") === \"GET\") {\n return {\n querystring: [\n qs\n .stringify(reqObject, { encode: false })\n .split(\"&\")\n .join(\"\\n\\t&\"),\n ],\n body: [],\n };\n } else {\n return {\n querystring: [],\n body: [\n \"\",\n await prettier.format(JSON.stringify(reqObject), {\n parser: \"json\",\n }),\n ],\n };\n }\n })();\n\n return [\n [\n `${api.options.httpMethod ?? \"GET\"} {{baseUrl}}${prefix}${api.path}`,\n ...dataLines.querystring,\n ].join(\"\\n\\t?\"),\n `Content-Type: ${api.options.contentType ?? \"application/json\"}`,\n ...dataLines.body,\n ].join(\"\\n\");\n })\n );\n\n return {\n ...this.getTargetAndPath(),\n body: lines.join(\"\\n\\n###\\n\\n\"),\n importKeys: [],\n };\n }\n\n zodTypeToReqDefault(zodType: z.ZodType<unknown>, name: string): unknown {\n if (zodType instanceof z.ZodObject) {\n return Object.fromEntries(\n Object.keys(zodType.shape).map((key) => [\n key,\n this.zodTypeToReqDefault(zodType.shape[key], key),\n ])\n );\n } else if (zodType instanceof z.ZodArray) {\n return [\n this.zodTypeToReqDefault(\n (zodType as z.ZodArray<z.ZodType>).element,\n name\n ),\n ];\n } else if (zodType instanceof z.ZodString) {\n if (name.endsWith(\"_at\") || name.endsWith(\"_date\") || name === \"range\") {\n return \"2000-01-01\";\n } else {\n return name.toUpperCase();\n }\n } else if (zodType instanceof z.ZodNumber) {\n if (name === \"num\") {\n return 24;\n }\n\n const minValue = zodType.minValue ?? 0;\n return minValue > Number.MIN_SAFE_INTEGER ? minValue : 0;\n } else if (zodType instanceof z.ZodBoolean) {\n return false;\n } else if (zodType instanceof z.ZodEnum) {\n return zodType.options[0];\n } else if (zodType instanceof z.ZodOptional) {\n return this.zodTypeToReqDefault(\n (zodType as z.ZodOptional<z.ZodType>).def.innerType,\n name\n );\n } else if (zodType instanceof z.ZodNullable) {\n return null;\n } else if (zodType instanceof z.ZodUnion) {\n return this.zodTypeToReqDefault(\n (zodType as z.ZodUnion<z.ZodType[]>).def.options[0],\n name\n );\n } else if (zodType instanceof z.ZodUnknown) {\n return \"unknown\";\n } else if (zodType instanceof z.ZodTuple) {\n return zodType.def.items.map((item: any) =>\n this.zodTypeToReqDefault(item, name)\n );\n } else if (zodType instanceof z.ZodDate) {\n return \"2000-01-01\";\n } else if (zodType instanceof z.ZodLiteral) {\n return zodType.value;\n } else if (zodType instanceof z.ZodRecord || zodType instanceof z.ZodMap) {\n const kvDef = (\n zodType as z.ZodRecord<any, z.ZodType> | z.ZodMap<z.ZodType, z.ZodType>\n ).def;\n const key = this.zodTypeToReqDefault(kvDef.keyType, name) as any;\n const value = this.zodTypeToReqDefault(kvDef.valueType, name);\n return { [key]: value };\n } else if (zodType instanceof z.ZodSet) {\n return [\n this.zodTypeToReqDefault(\n (zodType as z.ZodSet<z.ZodType>).def.valueType,\n name\n ),\n ];\n } else if (zodType instanceof z.ZodIntersection) {\n return this.zodTypeToReqDefault(\n (zodType as z.ZodIntersection<z.ZodType, z.ZodType>).def.right,\n name\n );\n } else if (zodType instanceof z.ZodDefault) {\n return this.zodTypeToReqDefault(\n (zodType as z.ZodDefault<z.ZodType>).def.innerType,\n name\n );\n } else {\n // console.log(zodType);\n return `unknown-${zodType.type}`;\n }\n }\n\n resolveApiParams(\n api: ExtendedApi,\n references: { [typeName: string]: z.ZodObject<any> }\n ): { [key: string]: unknown } {\n const reqType = getZodObjectFromApi(api, references);\n try {\n const def = this.zodTypeToReqDefault(reqType, \"unknownName\") as {\n [key: string]: unknown;\n };\n return def;\n } catch (error) {\n throw new Error(\n `Invalid zod type detected on ${api.modelName}:${api.methodName}`\n );\n }\n }\n}\n"],"names":["Template__generated_http","getTargetAndPath","dir","Sonamu","config","api","target","path","render","types","apis","prefix","lines","syncer","route","Promise","all","map","reqObject","dataLines","resolveApiParams","options","httpMethod","querystring","qs","stringify","encode","split","join","body","prettier","format","JSON","parser","contentType","importKeys","zodTypeToReqDefault","zodType","name","z","ZodObject","Object","fromEntries","keys","shape","key","ZodArray","element","ZodString","endsWith","toUpperCase","ZodNumber","minValue","Number","MIN_SAFE_INTEGER","ZodBoolean","ZodEnum","ZodOptional","def","innerType","ZodNullable","ZodUnion","ZodUnknown","ZodTuple","items","item","ZodDate","ZodLiteral","value","ZodRecord","ZodMap","kvDef","keyType","valueType","ZodSet","ZodIntersection","right","ZodDefault","type","references","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ACT,mBAAmB,CAACmC,MAAMC,OAAO,CAAElC,MACpD,IAAM8B,MAAQ,IAAI,CAAChC,mBAAmB,CAACmC,MAAME,SAAS,CAAEnC,MACxD,OAAS,oBAACO,IAAMuB,MAClB,MAAO,GAAI/B,AAAO,YAAPA,QAAmBE,MAAC,CAACmC,MAAM,EAAE,CACtC,MAAO,CACL,IAAI,CAACtC,mBAAmB,CACtB,AAACC,QAAgCqB,GAAG,CAACe,SAAS,CAC9CnC,MAEH,AACH,MAAO,GAAID,AAAO,YAAPA,QAAmBE,MAAC,CAACoC,eAAe,EAAE,CAC/C,OAAO,IAAI,CAACvC,mBAAmB,CAC7B,AAACC,QAAoDqB,GAAG,CAACkB,KAAK,CAC9DtC,KAEJ,MAAO,GAAID,AAAO,YAAPA,QAAmBE,MAAC,CAACsC,UAAU,EAAE,CAC1C,OAAO,IAAI,CAACzC,mBAAmB,CAC7B,AAACC,QAAoCqB,GAAG,CAACC,SAAS,CAClDrB,KAEJ,KAAO,CAEL,MAAO,AAAC,WAAuB,OAAbD,QAAQyC,IAAI,CAChC,CACF,IAEA1D,IAAAA,yBAAAA,SAAAA,iBACEf,GAAgB,CAChB0E,UAAoD,EAEpD,IAAMC,QAAUC,GAAAA,mCAAmB,EAAC5E,IAAK0E,YACzC,GAAI,CACF,IAAMrB,IAAM,IAAI,CAACtB,mBAAmB,CAAC4C,QAAS,eAG9C,OAAOtB,GACT,CAAE,MAAOwB,MAAO,CACd,MAAM,IAAIC,MACR,AAAC,gCAAgD9E,OAAjBA,IAAI+E,SAAS,CAAC,KAAkB,OAAf/E,IAAIgF,UAAU,EAEnE,CACF,YAvKWrF,0BAAiCsF,sBAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated_sso.template.d.ts","sourceRoot":"","sources":["../../src/templates/generated_sso.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,qBAAa,uBAAwB,SAAQ,QAAQ;;IAKnD,gBAAgB;;;;IAShB,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,eAAe,CAAC;;;;;;;IA2E3C,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,GAAG,IAAI;CAkCnE"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__generated_sso",{enumerable:true,get:function(){return Template__generated_sso}});var _types=require("../types/types");var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _inflection=/*#__PURE__*/_interop_require_default(require("inflection"));var _lodash=/*#__PURE__*/_interop_require_default(require("lodash"));var _utils=require("../utils/utils");var _api=require("../api");function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _interop_require_default(obj){return obj&&obj.__esModule?obj:{default:obj}}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_destructuring_empty(o){if(o===null||o===void 0)throw new TypeError("Cannot destructure "+o);return o}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__generated_sso=/*#__PURE__*/function(Template){"use strict";_inherits(Template__generated_sso,Template);function Template__generated_sso(){_class_call_check(this,Template__generated_sso);return _call_super(this,Template__generated_sso,["generated_sso"])}_create_class(Template__generated_sso,[{key:"getTargetAndPath",value:function getTargetAndPath(){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"sonamu.generated.sso.ts"}}},{key:"render",value:function render(param){var ref=_object_destructuring_empty(param);var entityIds=_entitymanager.EntityManager.getAllIds();var entities=entityIds.map(function(id){return _entitymanager.EntityManager.get(id)});var sourceCodes=entities.map(function(entity){if(entity.parentId!==undefined||Object.keys(entity.subsets).length===0){return null}var subsetKeys=Object.keys(entity.subsets);var subsetQueryObject=subsetKeys.reduce(function(r,subsetKey){var subsetQuery=entity.getSubsetQuery(subsetKey);r[subsetKey]=subsetQuery;return r},{});var subsetKeyTypeName="".concat(entity.names.module,"SubsetKey");return{label:"SubsetQuery: ".concat(entity.id),lines:["export const ".concat(_inflection.default.camelize(entity.id,true),"SubsetQueries:{ [key in ").concat(subsetKeyTypeName,"]: SubsetQuery} = ").concat(JSON.stringify(subsetQueryObject),";"),""],importKeys:[subsetKeyTypeName]}}).filter(_utils.nonNullable);var dbSchemaSourceCode=this.getDatabaseSchemaSourceCode(entities);if(dbSchemaSourceCode){sourceCodes.push(dbSchemaSourceCode)}var sourceCode=sourceCodes.reduce(function(result,ts){if(ts===null){return result}return{lines:_to_consumable_array(result.lines).concat(["// ".concat(ts.label)],_to_consumable_array(ts.lines),[""]),importKeys:_lodash.default.uniq(_to_consumable_array(result.importKeys).concat(_to_consumable_array(ts.importKeys)))}},{lines:[],importKeys:[]});var body=sourceCode.lines.join("\n");var isUsingManyToManyBaseSchema=body.includes("ManyToManyBaseSchema");return _object_spread_props(_object_spread({},this.getTargetAndPath()),{body:sourceCode.lines.join("\n"),importKeys:sourceCode.importKeys,customHeaders:["import { SubsetQuery, ".concat(isUsingManyToManyBaseSchema?"ManyToManyBaseSchema":"",' } from "sonamu";')]})}},{key:"getDatabaseSchemaSourceCode",value:function getDatabaseSchemaSourceCode(entities){if(entities.length===0){return null}var entitySchemaLines=entities.map(function(entity){return"".concat(entity.table,": ").concat(entity.id,"BaseSchema;")});var joinTableSchemaLines=_lodash.default.uniq(entities.flatMap(function(entity){return entity.props.filter(_types.isManyToManyRelationProp).map(function(prop){var fromTableKey=_inflection.default.singularize(entity.table);var toTableKey=_inflection.default.singularize(_entitymanager.EntityManager.get(prop.with).table);return"".concat(prop.joinTable,': ManyToManyBaseSchema<"').concat(fromTableKey,'", "').concat(toTableKey,'">;')})}));return{label:"DatabaseSchema",lines:['declare module "sonamu" {'," export interface DatabaseSchemaExtend {"].concat(_to_consumable_array(entitySchemaLines),_to_consumable_array(joinTableSchemaLines),[" }","}"]),importKeys:entities.map(function(entity){return"".concat(entity.id,"BaseSchema")})}}}]);return Template__generated_sso}(_basetemplate.Template);
2
- //# sourceMappingURL=generated_sso.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/templates/generated_sso.template.ts"],"sourcesContent":["import {\n isManyToManyRelationProp,\n SubsetQuery,\n TemplateOptions,\n} from \"../types/types\";\nimport { EntityManager } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport inflection from \"inflection\";\nimport { SourceCode } from \"./generated.template\";\nimport _ from \"lodash\";\nimport { nonNullable } from \"../utils/utils\";\nimport { Sonamu } from \"../api\";\nimport { Entity } from \"../entity/entity\";\n\nexport class Template__generated_sso extends Template {\n constructor() {\n super(\"generated_sso\");\n }\n\n getTargetAndPath() {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `sonamu.generated.sso.ts`,\n };\n }\n\n render({}: TemplateOptions[\"generated_sso\"]) {\n const entityIds = EntityManager.getAllIds();\n const entities = entityIds.map((id) => EntityManager.get(id));\n\n const sourceCodes: SourceCode[] = entities\n .map((entity) => {\n if (\n entity.parentId !== undefined ||\n Object.keys(entity.subsets).length === 0\n ) {\n return null;\n }\n const subsetKeys = Object.keys(entity.subsets);\n const subsetQueryObject = subsetKeys.reduce(\n (r, subsetKey) => {\n const subsetQuery = entity.getSubsetQuery(subsetKey);\n r[subsetKey] = subsetQuery;\n return r;\n },\n {} as {\n [key: string]: SubsetQuery;\n }\n );\n\n const subsetKeyTypeName = `${entity.names.module}SubsetKey`;\n return {\n label: `SubsetQuery: ${entity.id}`,\n lines: [\n `export const ${inflection.camelize(\n entity.id,\n true\n )}SubsetQueries:{ [key in ${subsetKeyTypeName}]: SubsetQuery} = ${JSON.stringify(\n subsetQueryObject\n )};`,\n \"\",\n ],\n importKeys: [subsetKeyTypeName],\n };\n })\n .filter(nonNullable);\n\n // DatabaseSchema 생성\n const dbSchemaSourceCode = this.getDatabaseSchemaSourceCode(entities);\n if (dbSchemaSourceCode) {\n sourceCodes.push(dbSchemaSourceCode);\n }\n\n const sourceCode = sourceCodes.reduce(\n (result, ts) => {\n if (ts === null) {\n return result;\n }\n return {\n lines: [...result!.lines, `// ${ts.label}`, ...ts.lines, \"\"],\n importKeys: _.uniq([...result!.importKeys, ...ts.importKeys]),\n };\n },\n {\n lines: [],\n importKeys: [],\n } as Omit<SourceCode, \"label\">\n );\n\n const body = sourceCode.lines.join(\"\\n\");\n const isUsingManyToManyBaseSchema = body.includes(\"ManyToManyBaseSchema\");\n return {\n ...this.getTargetAndPath(),\n body: sourceCode.lines.join(\"\\n\"),\n importKeys: sourceCode.importKeys,\n customHeaders: [\n `import { SubsetQuery, ${isUsingManyToManyBaseSchema ? \"ManyToManyBaseSchema\" : \"\"} } from \"sonamu\";`,\n ],\n };\n }\n\n getDatabaseSchemaSourceCode(entities: Entity[]): SourceCode | null {\n if (entities.length === 0) {\n return null;\n }\n\n const entitySchemaLines = entities.map(\n (entity) => `${entity.table}: ${entity.id}BaseSchema;`\n );\n\n const joinTableSchemaLines = _.uniq(\n entities.flatMap((entity) =>\n entity.props.filter(isManyToManyRelationProp).map((prop) => {\n const fromTableKey = inflection.singularize(entity.table);\n const toTableKey = inflection.singularize(\n EntityManager.get(prop.with).table\n );\n return `${prop.joinTable}: ManyToManyBaseSchema<\"${fromTableKey}\", \"${toTableKey}\">;`;\n })\n )\n );\n\n return {\n label: `DatabaseSchema`,\n lines: [\n `declare module \"sonamu\" {`,\n ` export interface DatabaseSchemaExtend {`,\n ...entitySchemaLines,\n ...joinTableSchemaLines,\n ` }`,\n `}`,\n ],\n importKeys: entities.map((entity) => `${entity.id}BaseSchema`),\n };\n }\n}\n"],"names":["Template__generated_sso","getTargetAndPath","dir","Sonamu","config","api","target","path","render","entityIds","EntityManager","getAllIds","entities","map","id","get","sourceCodes","entity","parentId","undefined","Object","keys","subsets","length","subsetKeys","subsetQueryObject","reduce","r","subsetKey","subsetQuery","getSubsetQuery","subsetKeyTypeName","names","module","label","lines","inflection","camelize","JSON","stringify","importKeys","filter","nonNullable","dbSchemaSourceCode","getDatabaseSchemaSourceCode","push","sourceCode","result","ts","_","uniq","body","join","isUsingManyToManyBaseSchema","includes","customHeaders","entitySchemaLines","table","joinTableSchemaLines","flatMap","props","isManyToManyRelationProp","prop","fromTableKey","singularize","toTableKey","with","joinTable","Template"],"mappings":"oGAcaA,iEAAAA,8CAVN,6CACuB,sDACL,iFACF,yEAET,8BACc,mCACL,itJAGhB,IAAA,AAAMA,qCAAN,0CAAMA,2CAAAA,iDAAAA,yBAET,OAAA,iBAFSA,yBAEH,gCAFGA,0BAKXC,IAAAA,yBAAAA,SAAAA,mBACE,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,yBACR,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAO,KAAoC,MAApC,gCAAA,OACL,IAAMC,UAAYC,4BAAa,CAACC,SAAS,GACzC,IAAMC,SAAWH,UAAUI,GAAG,CAAC,SAACC,WAAOJ,4BAAa,CAACK,GAAG,CAACD,MAEzD,IAAME,YAA4BJ,SAC/BC,GAAG,CAAC,SAACI,QACJ,GACEA,OAAOC,QAAQ,GAAKC,WACpBC,OAAOC,IAAI,CAACJ,OAAOK,OAAO,EAAEC,MAAM,GAAK,EACvC,CACA,OAAO,IACT,CACA,IAAMC,WAAaJ,OAAOC,IAAI,CAACJ,OAAOK,OAAO,EAC7C,IAAMG,kBAAoBD,WAAWE,MAAM,CACzC,SAACC,EAAGC,WACF,IAAMC,YAAcZ,OAAOa,cAAc,CAACF,UAC1CD,CAAAA,CAAC,CAACC,UAAU,CAAGC,YACf,OAAOF,CACT,EACA,CAAC,GAKH,IAAMI,kBAAoB,AAAC,GAAsB,OAApBd,OAAOe,KAAK,CAACC,MAAM,CAAC,aACjD,MAAO,CACLC,MAAO,AAAC,gBAAyB,OAAVjB,OAAOH,EAAE,EAChCqB,MAAO,CACL,AAAC,gBAG2BJ,OAHZK,mBAAU,CAACC,QAAQ,CACjCpB,OAAOH,EAAE,CACT,MACA,4BAAgEwB,OAAtCP,kBAAkB,sBAE5C,OA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,eAChBA,OAAO2C,KAAK,CAACnB,MAAM,CAACoB,+BAAwB,EAAEhD,GAAG,CAAC,SAACiD,MACjD,IAAMC,aAAe3B,mBAAU,CAAC4B,WAAW,CAAC/C,OAAOwC,KAAK,EACxD,IAAMQ,WAAa7B,mBAAU,CAAC4B,WAAW,CACvCtD,4BAAa,CAACK,GAAG,CAAC+C,KAAKI,IAAI,EAAET,KAAK,EAEpC,MAAO,AAAC,GAA2CM,OAAzCD,KAAKK,SAAS,CAAC,4BAA6CF,OAAnBF,aAAa,QAAiB,OAAXE,WAAW,MACnF,MAIJ,MAAO,CACL/B,MAAO,iBACPC,MAAO,CACL,4BACA,4CAKD,CAPM,OAGL,qBAAGqB,mBACH,qBAAGE,sBAJE,CAKL,MACA,IACD,EACDlB,WAAY5B,SAASC,GAAG,CAAC,SAACI,cAAW,AAAC,GAAY,OAAVA,OAAOH,EAAE,CAAC,eACpD,CACF,YA1HWd,yBAAgCoE,sBAAQ"}
@@ -1,2 +0,0 @@
1
- export * from "./base-template";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});_export_star(require("./base-template"),exports);function _export_star(from,to){Object.keys(from).forEach(function(k){if(k!=="default"&&!Object.prototype.hasOwnProperty.call(to,k)){Object.defineProperty(to,k,{enumerable:true,get:function(){return from[k]}})}});return from}
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/templates/index.ts"],"sourcesContent":["export * from \"./base-template\";\n"],"names":[],"mappings":"2FAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"init_types.template.d.ts","sourceRoot":"","sources":["../../src/templates/init_types.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,oBAAqB,SAAQ,QAAQ;;IAKhD,gBAAgB,CAAC,KAAK,EAAE,iBAAiB;;;;IASzC,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,CAAC,YAAY,CAAC;;;;;;CA4BnD"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__init_types",{enumerable:true,get:function(){return Template__init_types}});var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _api=require("../api");function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__init_types=/*#__PURE__*/function(Template){"use strict";_inherits(Template__init_types,Template);function Template__init_types(){_class_call_check(this,Template__init_types);return _call_super(this,Template__init_types,["init_types"])}_create_class(Template__init_types,[{key:"getTargetAndPath",value:function getTargetAndPath(names){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"".concat(names.fs,"/").concat(names.fs,".types.ts")}}},{key:"render",value:function render(param){var entityId=param.entityId;var names=_entitymanager.EntityManager.getNamesFromId(entityId);var hasCreatedAt=_entitymanager.EntityManager.get(entityId).props.find(function(prop){return prop.name==="created_at"})!==undefined;return _object_spread_props(_object_spread({},this.getTargetAndPath(names)),{body:'\nimport { z } from "zod";\nimport { '.concat(entityId,"BaseSchema, ").concat(entityId,'BaseListParams } from "../sonamu.generated";\n\n// ').concat(entityId," - ListParams\nexport const ").concat(entityId,"ListParams = ").concat(entityId,"BaseListParams;\nexport type ").concat(entityId,"ListParams = z.infer<typeof ").concat(entityId,"ListParams>;\n\n// ").concat(entityId," - SaveParams\nexport const ").concat(entityId,"SaveParams = ").concat(entityId,"BaseSchema.partial({ id: true").concat(hasCreatedAt?", created_at: true":""," });\nexport type ").concat(entityId,"SaveParams = z.infer<typeof ").concat(entityId,"SaveParams>;\n\n ").trim(),importKeys:[]})}}]);return Template__init_types}(_basetemplate.Template);
2
- //# sourceMappingURL=init_types.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/templates/init_types.template.ts"],"sourcesContent":["import { TemplateOptions } from \"../types/types\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport { Sonamu } from \"../api\";\n\nexport class Template__init_types extends Template {\n constructor() {\n super(\"init_types\");\n }\n\n getTargetAndPath(names: EntityNamesRecord) {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `${names.fs}/${names.fs}.types.ts`,\n };\n }\n\n render({ entityId }: TemplateOptions[\"init_types\"]) {\n const names = EntityManager.getNamesFromId(entityId);\n\n const hasCreatedAt =\n EntityManager.get(entityId).props.find(\n (prop) => prop.name === \"created_at\"\n ) !== undefined;\n\n return {\n ...this.getTargetAndPath(names),\n body: `\nimport { z } from \"zod\";\nimport { ${entityId}BaseSchema, ${entityId}BaseListParams } from \"../sonamu.generated\";\n\n// ${entityId} - ListParams\nexport const ${entityId}ListParams = ${entityId}BaseListParams;\nexport type ${entityId}ListParams = z.infer<typeof ${entityId}ListParams>;\n\n// ${entityId} - SaveParams\nexport const ${entityId}SaveParams = ${entityId}BaseSchema.partial({ id: true${\n hasCreatedAt ? \", created_at: true\" : \"\"\n } });\nexport type ${entityId}SaveParams = z.infer<typeof ${entityId}SaveParams>;\n\n `.trim(),\n importKeys: [],\n };\n }\n}\n"],"names":["Template__init_types","getTargetAndPath","names","dir","Sonamu","config","api","target","path","fs","render","entityId","EntityManager","getNamesFromId","hasCreatedAt","get","props","find","prop","name","undefined","body","trim","importKeys","Template"],"mappings":"oGAKaA,8DAAAA,mDAJoC,sDACxB,oCACF,g7GAEhB,IAAA,AAAMA,kCAAN,0CAAMA,wCAAAA,8CAAAA,sBAET,OAAA,iBAFSA,sBAEH,6BAFGA,uBAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,EACvC,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,AAAC,GAAcN,OAAZA,MAAMO,EAAE,CAAC,KAAY,OAATP,MAAMO,EAAE,CAAC,YAChC,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAO,KAA2C,MAA3C,AAAEC,SAAF,MAAEA,SACP,IAAMT,MAAQU,4BAAa,CAACC,cAAc,CAACF,UAE3C,IAAMG,aACJF,4BAAa,CAACG,GAAG,CAACJ,UAAUK,KAAK,CAACC,IAAI,CACpC,SAACC,aAASA,KAAKC,IAAI,GAAK,iBACpBC,UAER,OAAO,uCACF,IAAI,CAACnB,gBAAgB,CAACC,SACzBmB,KAAM,AAAC,wCAEqBV,OAAvBA,SAAS,gBAEfA,OAF6BA,SAAS,uDAG5BA,OADVA,SAAS,gCACyBA,OAAxBA,SAAS,iBACVA,OADyBA,SAAS,iCACKA,OAAvCA,SAAS,gCAElBA,OAFgDA,SAAS,uBAG/CA,OADVA,SAAS,gCACyBA,OAAxBA,SAAS,iBAChBG,OAD+BH,SAAS,iCAGlCA,OAFNG,aAAe,qBAAuB,GACvC,sBAC8CH,OAAvCA,SAAS,gCAAuC,OAATA,SAAS,0BAEtDW,IAAI,GACNC,WAAY,EAAE,EAElB,YAzCWvB,sBAA6BwB,sBAAQ"}