sonamu 0.13.10 → 0.14.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 (330) hide show
  1. package/dist/api/caster.d.ts.map +1 -1
  2. package/dist/api/caster.js +2 -1
  3. package/dist/api/code-converters.d.ts +5 -1
  4. package/dist/api/code-converters.d.ts.map +1 -1
  5. package/dist/api/code-converters.js +24 -7
  6. package/dist/api/config.d.ts +7 -0
  7. package/dist/api/config.d.ts.map +1 -1
  8. package/dist/api/config.js +1 -1
  9. package/dist/api/decorators.d.ts +1 -0
  10. package/dist/api/decorators.d.ts.map +1 -1
  11. package/dist/api/decorators.js +1 -1
  12. package/dist/api/guards.d.ts +37 -0
  13. package/dist/api/guards.d.ts.map +1 -0
  14. package/dist/api/guards.js +96 -0
  15. package/dist/api/sonamu.d.ts +14 -1
  16. package/dist/api/sonamu.d.ts.map +1 -1
  17. package/dist/api/sonamu.js +121 -25
  18. package/dist/api/websocket-helpers.d.ts +6 -1
  19. package/dist/api/websocket-helpers.d.ts.map +1 -1
  20. package/dist/api/websocket-helpers.js +7 -4
  21. package/dist/auth/auth-entity-policy.d.ts +32 -0
  22. package/dist/auth/auth-entity-policy.d.ts.map +1 -0
  23. package/dist/auth/auth-entity-policy.js +44 -0
  24. package/dist/auth/auth-secret.d.ts +24 -0
  25. package/dist/auth/auth-secret.d.ts.map +1 -0
  26. package/dist/auth/auth-secret.js +46 -0
  27. package/dist/auth/base-url.d.ts +39 -0
  28. package/dist/auth/base-url.d.ts.map +1 -0
  29. package/dist/auth/base-url.js +84 -0
  30. package/dist/auth/better-auth-entities.js +20 -7
  31. package/dist/auth/better-auth-options.d.ts +15 -0
  32. package/dist/auth/better-auth-options.d.ts.map +1 -0
  33. package/dist/auth/better-auth-options.js +38 -0
  34. package/dist/auth/better-auth-request.d.ts +8 -1
  35. package/dist/auth/better-auth-request.d.ts.map +1 -1
  36. package/dist/auth/better-auth-request.js +26 -3
  37. package/dist/auth/plugins/entity-definitions/admin.d.ts.map +1 -1
  38. package/dist/auth/plugins/entity-definitions/admin.js +6 -1
  39. package/dist/auth/plugins/entity-definitions/anonymous.d.ts.map +1 -1
  40. package/dist/auth/plugins/entity-definitions/anonymous.js +2 -1
  41. package/dist/auth/plugins/entity-definitions/api-key.d.ts.map +1 -1
  42. package/dist/auth/plugins/entity-definitions/api-key.js +18 -2
  43. package/dist/auth/plugins/entity-definitions/audit-log.d.ts.map +1 -1
  44. package/dist/auth/plugins/entity-definitions/audit-log.js +27 -1
  45. package/dist/auth/plugins/entity-definitions/jwt.d.ts.map +1 -1
  46. package/dist/auth/plugins/entity-definitions/jwt.js +4 -2
  47. package/dist/auth/plugins/entity-definitions/organization.d.ts.map +1 -1
  48. package/dist/auth/plugins/entity-definitions/organization.js +15 -1
  49. package/dist/auth/plugins/entity-definitions/passkey.d.ts.map +1 -1
  50. package/dist/auth/plugins/entity-definitions/passkey.js +9 -1
  51. package/dist/auth/plugins/entity-definitions/phone-number.d.ts.map +1 -1
  52. package/dist/auth/plugins/entity-definitions/phone-number.js +2 -1
  53. package/dist/auth/plugins/entity-definitions/sso.d.ts.map +1 -1
  54. package/dist/auth/plugins/entity-definitions/sso.js +7 -3
  55. package/dist/auth/plugins/entity-definitions/two-factor.d.ts.map +1 -1
  56. package/dist/auth/plugins/entity-definitions/two-factor.js +8 -3
  57. package/dist/auth/verify-email-guard.d.ts +37 -0
  58. package/dist/auth/verify-email-guard.d.ts.map +1 -0
  59. package/dist/auth/verify-email-guard.js +48 -0
  60. package/dist/bin/build-config.d.ts.map +1 -1
  61. package/dist/bin/build-config.js +6 -2
  62. package/dist/bin/typecheck-web.js +1 -1
  63. package/dist/cache/decorator.d.ts +12 -0
  64. package/dist/cache/decorator.d.ts.map +1 -1
  65. package/dist/cache/decorator.js +86 -19
  66. package/dist/cache/index.d.ts +1 -1
  67. package/dist/cache/index.d.ts.map +1 -1
  68. package/dist/cache/index.js +3 -3
  69. package/dist/cache/types.d.ts +16 -0
  70. package/dist/cache/types.d.ts.map +1 -1
  71. package/dist/cli/plugin-loader.d.ts +17 -0
  72. package/dist/cli/plugin-loader.d.ts.map +1 -0
  73. package/dist/cli/plugin-loader.js +178 -0
  74. package/dist/cli/plugin.d.ts +65 -0
  75. package/dist/cli/plugin.d.ts.map +1 -0
  76. package/dist/cli/plugin.js +7 -0
  77. package/dist/code-formatting/oxfmt.js +1 -1
  78. package/dist/code-formatting/oxlint.js +1 -1
  79. package/dist/database/db.d.ts +35 -10
  80. package/dist/database/db.d.ts.map +1 -1
  81. package/dist/database/db.js +37 -4
  82. package/dist/database/puri.d.ts +8 -0
  83. package/dist/database/puri.d.ts.map +1 -1
  84. package/dist/database/puri.js +108 -171
  85. package/dist/database/puri.types.d.ts +2 -0
  86. package/dist/database/puri.types.d.ts.map +1 -1
  87. package/dist/database/puri.types.js +1 -1
  88. package/dist/database/sql-expression-brand.d.ts +10 -0
  89. package/dist/database/sql-expression-brand.d.ts.map +1 -0
  90. package/dist/database/sql-expression-brand.js +10 -0
  91. package/dist/dict/en.d.ts +1 -0
  92. package/dist/dict/en.d.ts.map +1 -1
  93. package/dist/dict/en.js +2 -1
  94. package/dist/dict/ko.d.ts +1 -0
  95. package/dist/dict/ko.d.ts.map +1 -1
  96. package/dist/dict/ko.js +2 -1
  97. package/dist/dict/sonamu-dictionary.d.ts +23 -1
  98. package/dist/dict/sonamu-dictionary.d.ts.map +1 -1
  99. package/dist/dict/sonamu-dictionary.js +187 -32
  100. package/dist/entity/entity-codegen-safety.d.ts +105 -0
  101. package/dist/entity/entity-codegen-safety.d.ts.map +1 -0
  102. package/dist/entity/entity-codegen-safety.js +70 -0
  103. package/dist/entity/entity-manager.d.ts +32 -0
  104. package/dist/entity/entity-manager.d.ts.map +1 -1
  105. package/dist/entity/entity-manager.js +21 -2
  106. package/dist/entity/entity.d.ts +5 -2
  107. package/dist/entity/entity.d.ts.map +1 -1
  108. package/dist/entity/entity.js +19 -8
  109. package/dist/env.d.ts +19 -0
  110. package/dist/env.d.ts.map +1 -1
  111. package/dist/env.js +31 -3
  112. package/dist/filter/utils.d.ts +2 -2
  113. package/dist/filter/utils.d.ts.map +1 -1
  114. package/dist/filter/utils.js +16 -11
  115. package/dist/index.d.ts +4 -3
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +7 -6
  118. package/dist/logger/configure.d.ts.map +1 -1
  119. package/dist/logger/configure.js +10 -3
  120. package/dist/migration/code-generation.d.ts.map +1 -1
  121. package/dist/migration/code-generation.js +177 -96
  122. package/dist/migration/migrator.d.ts +16 -0
  123. package/dist/migration/migrator.d.ts.map +1 -1
  124. package/dist/migration/migrator.js +28 -3
  125. package/dist/migration/slack-confirm.d.ts +6 -2
  126. package/dist/migration/slack-confirm.d.ts.map +1 -1
  127. package/dist/migration/slack-confirm.js +11 -9
  128. package/dist/ssr/errors.d.ts +13 -0
  129. package/dist/ssr/errors.d.ts.map +1 -0
  130. package/dist/ssr/errors.js +12 -0
  131. package/dist/ssr/index.d.ts +1 -0
  132. package/dist/ssr/index.d.ts.map +1 -1
  133. package/dist/ssr/index.js +5 -2
  134. package/dist/ssr/renderer.d.ts +6 -0
  135. package/dist/ssr/renderer.d.ts.map +1 -1
  136. package/dist/ssr/renderer.js +10 -1
  137. package/dist/storage/base-file.d.ts +6 -2
  138. package/dist/storage/base-file.d.ts.map +1 -1
  139. package/dist/storage/base-file.js +10 -5
  140. package/dist/storage/buffered-file.d.ts +1 -0
  141. package/dist/storage/buffered-file.d.ts.map +1 -1
  142. package/dist/storage/buffered-file.js +5 -2
  143. package/dist/storage/index.d.ts +1 -0
  144. package/dist/storage/index.d.ts.map +1 -1
  145. package/dist/storage/index.js +4 -2
  146. package/dist/storage/upload-safety.d.ts +47 -0
  147. package/dist/storage/upload-safety.d.ts.map +1 -0
  148. package/dist/storage/upload-safety.js +112 -0
  149. package/dist/stream/ws.d.ts +6 -0
  150. package/dist/stream/ws.d.ts.map +1 -1
  151. package/dist/stream/ws.js +52 -6
  152. package/dist/syncer/api-parser.js +6 -1
  153. package/dist/syncer/code-generator.d.ts +2 -0
  154. package/dist/syncer/code-generator.d.ts.map +1 -1
  155. package/dist/syncer/code-generator.js +21 -7
  156. package/dist/template/implementations/entity.template.d.ts.map +1 -1
  157. package/dist/template/implementations/entity.template.js +40 -35
  158. package/dist/template/implementations/generated.template.d.ts +10 -0
  159. package/dist/template/implementations/generated.template.d.ts.map +1 -1
  160. package/dist/template/implementations/generated.template.js +46 -7
  161. package/dist/template/implementations/generated_http.template.d.ts.map +1 -1
  162. package/dist/template/implementations/generated_http.template.js +3 -1
  163. package/dist/template/implementations/init_types.template.d.ts.map +1 -1
  164. package/dist/template/implementations/init_types.template.js +3 -8
  165. package/dist/template/implementations/model.template.d.ts.map +1 -1
  166. package/dist/template/implementations/model.template.js +9 -2
  167. package/dist/template/implementations/sd.template.d.ts +0 -1
  168. package/dist/template/implementations/sd.template.d.ts.map +1 -1
  169. package/dist/template/implementations/sd.template.js +2 -5
  170. package/dist/template/implementations/view_form.template.d.ts.map +1 -1
  171. package/dist/template/implementations/view_form.template.js +8 -6
  172. package/dist/template/implementations/view_list.template.d.ts.map +1 -1
  173. package/dist/template/implementations/view_list.template.js +8 -4
  174. package/dist/testing/dev-test-routes.d.ts.map +1 -1
  175. package/dist/testing/dev-test-routes.js +7 -4
  176. package/dist/tooling/__tests__/helpers/sonamu-test-root.js +1 -1
  177. package/dist/tooling/cdd-service.js +1 -1
  178. package/dist/tooling/index.d.ts +1 -0
  179. package/dist/tooling/index.d.ts.map +1 -1
  180. package/dist/tooling/index.js +3 -1
  181. package/dist/tsdown.api.config.js +1 -1
  182. package/dist/types/types.d.ts +81 -1
  183. package/dist/types/types.d.ts.map +1 -1
  184. package/dist/types/types.js +2 -1
  185. package/dist/ui/__tests__/ui-test-helpers.d.ts +10 -0
  186. package/dist/ui/__tests__/ui-test-helpers.d.ts.map +1 -0
  187. package/dist/ui/__tests__/ui-test-helpers.js +75 -0
  188. package/dist/ui/access-guard.d.ts +42 -0
  189. package/dist/ui/access-guard.d.ts.map +1 -0
  190. package/dist/ui/access-guard.js +94 -0
  191. package/dist/ui/api.d.ts.map +1 -1
  192. package/dist/ui/api.js +40 -95
  193. package/dist/ui/dev-host-guard.d.ts +28 -0
  194. package/dist/ui/dev-host-guard.d.ts.map +1 -0
  195. package/dist/ui/dev-host-guard.js +67 -0
  196. package/dist/ui/migrations-api.d.ts.map +1 -1
  197. package/dist/ui/migrations-api.js +72 -16
  198. package/dist/ui/open-vscode-api.d.ts +4 -0
  199. package/dist/ui/open-vscode-api.d.ts.map +1 -0
  200. package/dist/ui/open-vscode-api.js +65 -0
  201. package/dist/ui/scaffolding-api.d.ts +18 -0
  202. package/dist/ui/scaffolding-api.d.ts.map +1 -0
  203. package/dist/ui/scaffolding-api.js +111 -0
  204. package/dist/ui/ui-db-presets.d.ts +19 -0
  205. package/dist/ui/ui-db-presets.d.ts.map +1 -0
  206. package/dist/ui/ui-db-presets.js +34 -0
  207. package/dist/ui/ui-request-guard.d.ts +11 -0
  208. package/dist/ui/ui-request-guard.d.ts.map +1 -0
  209. package/dist/ui/ui-request-guard.js +38 -0
  210. package/dist/ui-web/assets/{index-QDMyy31K.js → index-BPqP-tug.js} +39 -39
  211. package/dist/ui-web/index.html +2 -1
  212. package/package.json +1 -1
  213. package/src/__tests__/env.test.ts +121 -2
  214. package/src/api/__tests__/code-converters.union.test.ts +97 -0
  215. package/src/api/__tests__/guards.test.ts +233 -0
  216. package/src/api/__tests__/sonamu.auth-secret.test.ts +77 -0
  217. package/src/api/__tests__/sonamu.dev-host-guard.test.ts +130 -0
  218. package/src/api/__tests__/sonamu.guards.test.ts +327 -0
  219. package/src/api/__tests__/sonamu.upload-limits.test.ts +156 -0
  220. package/src/api/__tests__/websocket-helpers.test.ts +101 -0
  221. package/src/api/caster.ts +7 -0
  222. package/src/api/code-converters.ts +44 -12
  223. package/src/api/config.ts +8 -0
  224. package/src/api/decorators.ts +1 -0
  225. package/src/api/guards.ts +130 -0
  226. package/src/api/sonamu.ts +195 -39
  227. package/src/api/websocket-helpers.ts +11 -6
  228. package/src/auth/__tests__/auth-entity-policy.test.ts +59 -0
  229. package/src/auth/__tests__/auth-secret.test.ts +133 -0
  230. package/src/auth/__tests__/base-url-host-poisoning.test.ts +193 -0
  231. package/src/auth/__tests__/base-url.test.ts +117 -0
  232. package/src/auth/__tests__/better-auth-options.test.ts +194 -0
  233. package/src/auth/__tests__/better-auth-request.test.ts +45 -0
  234. package/src/auth/__tests__/verify-email-guard.test.ts +228 -0
  235. package/src/auth/auth-entity-policy.ts +48 -0
  236. package/src/auth/auth-secret.ts +77 -0
  237. package/src/auth/base-url.ts +109 -0
  238. package/src/auth/better-auth-entities.ts +30 -30
  239. package/src/auth/better-auth-options.ts +39 -0
  240. package/src/auth/better-auth-request.ts +28 -1
  241. package/src/auth/plugins/entity-definitions/admin.ts +5 -0
  242. package/src/auth/plugins/entity-definitions/anonymous.ts +9 -1
  243. package/src/auth/plugins/entity-definitions/api-key.ts +53 -16
  244. package/src/auth/plugins/entity-definitions/audit-log.ts +122 -21
  245. package/src/auth/plugins/entity-definitions/jwt.ts +5 -4
  246. package/src/auth/plugins/entity-definitions/organization.ts +26 -6
  247. package/src/auth/plugins/entity-definitions/passkey.ts +8 -7
  248. package/src/auth/plugins/entity-definitions/phone-number.ts +1 -0
  249. package/src/auth/plugins/entity-definitions/sso.ts +20 -15
  250. package/src/auth/plugins/entity-definitions/two-factor.ts +21 -5
  251. package/src/auth/verify-email-guard.ts +82 -0
  252. package/src/bin/__tests__/build-web-command.test.ts +24 -0
  253. package/src/bin/build-config.ts +5 -0
  254. package/src/cache/decorator.ts +116 -21
  255. package/src/cache/index.ts +6 -1
  256. package/src/cache/types.ts +18 -0
  257. package/src/cli/plugin-loader.ts +238 -0
  258. package/src/cli/plugin.ts +82 -0
  259. package/src/database/__tests__/db.test.ts +64 -1
  260. package/src/database/__tests__/puri.test.ts +56 -0
  261. package/src/database/db.ts +56 -6
  262. package/src/database/puri.ts +135 -125
  263. package/src/database/puri.types.test-d.ts +12 -0
  264. package/src/database/puri.types.ts +3 -0
  265. package/src/database/sql-expression-brand.ts +9 -0
  266. package/src/dict/__tests__/sonamu-dictionary.test.ts +217 -0
  267. package/src/dict/en.ts +2 -0
  268. package/src/dict/ko.ts +2 -0
  269. package/src/dict/sonamu-dictionary.ts +298 -38
  270. package/src/entity/__tests__/entity-codegen-safety.test.ts +326 -0
  271. package/src/entity/entity-codegen-safety.ts +126 -0
  272. package/src/entity/entity-manager.ts +29 -1
  273. package/src/entity/entity.ts +26 -12
  274. package/src/env.ts +52 -1
  275. package/src/filter/utils.ts +19 -7
  276. package/src/index.ts +4 -3
  277. package/src/logger/__tests__/configure.test.ts +51 -1
  278. package/src/logger/configure.ts +14 -1
  279. package/src/migration/__tests__/code-generation.escape.test.ts +322 -0
  280. package/src/migration/__tests__/migrator.test.ts +76 -1
  281. package/src/migration/code-generation.ts +247 -117
  282. package/src/migration/migrator.ts +45 -4
  283. package/src/migration/slack-confirm.ts +19 -5
  284. package/src/ssr/__tests__/preload-guard.test.ts +274 -0
  285. package/src/ssr/errors.ts +11 -0
  286. package/src/ssr/index.ts +1 -0
  287. package/src/ssr/renderer.ts +12 -0
  288. package/src/storage/__tests__/upload-safety.test.ts +179 -0
  289. package/src/storage/base-file.ts +8 -4
  290. package/src/storage/buffered-file.ts +3 -1
  291. package/src/storage/index.ts +9 -0
  292. package/src/storage/upload-safety.ts +155 -0
  293. package/src/stream/__tests__/ws.test.ts +97 -0
  294. package/src/stream/ws.ts +67 -5
  295. package/src/syncer/__tests__/api-parser.readonly.test.ts +55 -0
  296. package/src/syncer/__tests__/code-generator-path-containment.test.ts +105 -0
  297. package/src/syncer/api-parser.ts +12 -0
  298. package/src/syncer/code-generator.ts +34 -6
  299. package/src/template/__tests__/generated.template.search-text.test.ts +5 -1
  300. package/src/template/__tests__/model.template.auth-entity.test.ts +42 -0
  301. package/src/template/__tests__/save-params.template.test.ts +219 -0
  302. package/src/template/implementations/entity.template.ts +53 -48
  303. package/src/template/implementations/generated.template.ts +87 -12
  304. package/src/template/implementations/generated_http.template.ts +5 -0
  305. package/src/template/implementations/init_types.template.ts +4 -22
  306. package/src/template/implementations/model.template.ts +15 -1
  307. package/src/template/implementations/sd.template.ts +4 -5
  308. package/src/template/implementations/view_form.template.ts +13 -5
  309. package/src/template/implementations/view_list.template.ts +12 -3
  310. package/src/testing/__tests__/dev-test-routes.test.ts +99 -0
  311. package/src/testing/dev-test-routes.ts +7 -3
  312. package/src/tooling/__tests__/cli-plugins.contract.test.ts +273 -0
  313. package/src/tooling/index.ts +1 -0
  314. package/src/types/types.ts +22 -1
  315. package/src/ui/__tests__/access-guard.test.ts +217 -0
  316. package/src/ui/__tests__/dev-host-guard.test.ts +161 -0
  317. package/src/ui/__tests__/fixture-api.test.ts +92 -0
  318. package/src/ui/__tests__/migrations-api.test.ts +352 -0
  319. package/src/ui/__tests__/open-vscode.test.ts +151 -0
  320. package/src/ui/__tests__/scaffolding-api.test.ts +232 -0
  321. package/src/ui/__tests__/ui-process-routes.test.ts +166 -0
  322. package/src/ui/__tests__/ui-test-helpers.ts +71 -0
  323. package/src/ui/access-guard.ts +115 -0
  324. package/src/ui/api.ts +65 -198
  325. package/src/ui/dev-host-guard.ts +109 -0
  326. package/src/ui/migrations-api.ts +130 -24
  327. package/src/ui/open-vscode-api.ts +82 -0
  328. package/src/ui/scaffolding-api.ts +177 -0
  329. package/src/ui/ui-db-presets.ts +41 -0
  330. package/src/ui/ui-request-guard.ts +53 -0
@@ -21,17 +21,26 @@ import {
21
21
  type MigrationTarget,
22
22
  } from "../migration/types";
23
23
  import { forwardAsyncErrors } from "./async-route";
24
+ import { isUIDBPreset } from "./ui-db-presets";
24
25
 
25
26
  type ApprovalReady = { type: "ready" };
26
27
  type ApprovalResult = ApprovalReady | SlackConfirmPendingResult;
28
+ type ApprovalAction = Exclude<MigrationAction, "shadow">;
27
29
  type ApplyBody = { targets: MigrationTarget[]; requestor?: string };
30
+ type ApprovalRequestBody = ApplyBody & { action?: ApprovalAction };
28
31
  type LegacyApplyBody = ApplyBody & { force?: boolean; forceReason?: string };
29
32
 
30
33
  const LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "0.0.0.0", "::1"]);
31
34
 
32
35
  function assertTargets(migrator: Migrator, targets: MigrationTarget[]): void {
36
+ // urlencoded 단일 값처럼 배열이 아닌 입력은 대상 판별 전에 거부합니다.
37
+ if (!Array.isArray(targets)) {
38
+ throw new BadRequestException(SD("error.badRequest"), {
39
+ message: "Invalid migration targets: (not an array)",
40
+ });
41
+ }
33
42
  const allowed = new Set(migrator.getConnections().map(({ connKey }) => connKey));
34
- const invalid = targets.filter((target) => !allowed.has(target));
43
+ const invalid = targets.filter((target) => !allowed.has(target)).map(String);
35
44
  if (targets.length === 0 || invalid.length > 0) {
36
45
  throw new BadRequestException(SD("error.badRequest"), {
37
46
  message: `Invalid migration targets: ${invalid.length === 0 ? "(empty)" : invalid.join(", ")}`,
@@ -64,11 +73,41 @@ function getPendingMigrations(statuses: MigrationConnectionStatus[]) {
64
73
  return [...new Set(statuses.flatMap(({ pending }) => pending))];
65
74
  }
66
75
 
67
- async function requestApproval(
76
+ /**
77
+ * 승인 요청을 식별하는 마이그레이션 목록을 만듭니다.
78
+ *
79
+ * apply는 pending 파일 이름을, rollback은 대상별 최신 batch 번호를 포함한 항목을 씁니다.
80
+ * rollback 항목은 apply 항목과 겹치지 않으므로 apply 승인으로 rollback을 실행할 수 없고,
81
+ * 다시 적용되어 batch 번호가 바뀌면 새 승인을 받아야 합니다.
82
+ */
83
+ async function getApprovalMigrations(
68
84
  migrator: Migrator,
85
+ action: ApprovalAction,
69
86
  targets: MigrationTarget[],
70
- requestor?: string,
87
+ statuses: MigrationConnectionStatus[],
88
+ ): Promise<string[]> {
89
+ if (action === "apply") {
90
+ return getPendingMigrations(statuses);
91
+ }
92
+ const batches = await Promise.all(
93
+ targets.map(async (target) => ({ target, ...(await migrator.getLatestAppliedBatch(target)) })),
94
+ );
95
+ return batches.flatMap(({ target, batchNo, files }) =>
96
+ files.map((file) => `[rollback:${String(target)}#${batchNo}] ${file}`),
97
+ );
98
+ }
99
+
100
+ async function requestApproval(
101
+ migrator: Migrator,
102
+ body: ApprovalRequestBody,
71
103
  ): Promise<ApprovalResult> {
104
+ const { targets, requestor } = body;
105
+ const action = body.action ?? "apply";
106
+ if (action !== "apply" && action !== "rollback") {
107
+ throw new BadRequestException(SD("error.badRequest"), {
108
+ message: `Invalid approval action: ${String(action)}`,
109
+ });
110
+ }
72
111
  assertTargets(migrator, targets);
73
112
  const statuses = await getAvailableTargetStatuses(migrator, targets);
74
113
  const slack = new SlackConfirm();
@@ -77,7 +116,7 @@ async function requestApproval(
77
116
  return { type: "ready" };
78
117
  }
79
118
 
80
- const pending = getPendingMigrations(statuses);
119
+ const pending = await getApprovalMigrations(migrator, action, targets, statuses);
81
120
  if (pending.length === 0) {
82
121
  return { type: "ready" };
83
122
  }
@@ -94,12 +133,18 @@ async function requestApproval(
94
133
  return { type: "pending", ...existing };
95
134
  }
96
135
 
97
- const created = await slack.postApprovalRequest(pending, targets, requestor);
136
+ const created = await slack.postApprovalRequest(pending, targets, requestor, action);
98
137
  await slack.saveRequest(pending, created.channel, created.ts);
99
138
  return { type: "pending", ...created };
100
139
  }
101
140
 
102
- async function requireApprovedApply(
141
+ /**
142
+ * apply·rollback 실행 직전에 Slack 승인이 끝났는지 확인합니다.
143
+ * 승인 대상이 아니면 null을, 승인된 요청이면 실행 로그를 남길 Slack 메시지를 반환합니다.
144
+ */
145
+ async function requireApproved(
146
+ migrator: Migrator,
147
+ action: ApprovalAction,
103
148
  body: ApplyBody,
104
149
  statuses: MigrationConnectionStatus[],
105
150
  ): Promise<{ channel: string; ts: string } | null> {
@@ -109,7 +154,7 @@ async function requireApprovedApply(
109
154
  return null;
110
155
  }
111
156
 
112
- const pending = getPendingMigrations(statuses);
157
+ const pending = await getApprovalMigrations(migrator, action, body.targets, statuses);
113
158
  if (pending.length === 0) {
114
159
  return null;
115
160
  }
@@ -179,6 +224,54 @@ async function runLegacyApply(
179
224
  return result;
180
225
  }
181
226
 
227
+ /**
228
+ * 이전 runAction 호출의 rollback 경로입니다.
229
+ * 승인 대상이면 apply와 같이 요청을 만들거나 기존 승인 상태를 따르며, force 생략은 허용하지 않습니다.
230
+ */
231
+ async function runLegacyRollback(
232
+ migrator: Migrator,
233
+ body: ApplyBody,
234
+ ): Promise<MigrationResult | SlackConfirmPendingResult> {
235
+ assertTargets(migrator, body.targets);
236
+ const statuses = await getAvailableTargetStatuses(migrator, body.targets);
237
+ const slack = new SlackConfirm();
238
+ const requiresApproval = body.targets.some((target) => targetRequiresApproval(slack, target));
239
+ if (!requiresApproval || !slack.isConfigured()) {
240
+ return migrator.rollback(body.targets);
241
+ }
242
+
243
+ const pending = await getApprovalMigrations(migrator, "rollback", body.targets, statuses);
244
+ if (pending.length === 0) {
245
+ return migrator.rollback(body.targets);
246
+ }
247
+
248
+ const existing = await slack.getExistingRequest(pending);
249
+ if (existing === null) {
250
+ const created = await slack.postApprovalRequest(
251
+ pending,
252
+ body.targets,
253
+ body.requestor,
254
+ "rollback",
255
+ );
256
+ await slack.saveRequest(pending, created.channel, created.ts);
257
+ return { type: "pending", ...created };
258
+ }
259
+
260
+ const approval = await slack.checkApproval(existing.channel, existing.ts);
261
+ if (approval.rejected) {
262
+ throw new BadRequestException(SD("sonamu.error.migrationRejected"));
263
+ }
264
+ if (!approval.approved) {
265
+ return { type: "pending", ...existing };
266
+ }
267
+
268
+ const result = await migrator.rollback(body.targets);
269
+ if (result.length > 0) {
270
+ await slack.logExecution(existing.channel, existing.ts, result, body.requestor, "rollback");
271
+ }
272
+ return result;
273
+ }
274
+
182
275
  function sendMigrationStream(
183
276
  reply: FastifyReply,
184
277
  action: MigrationAction,
@@ -247,7 +340,9 @@ function sendMigrationStream(
247
340
  }
248
341
 
249
342
  export async function registerMigrationsApi(server: FastifyInstance) {
250
- const migrator = new Migrator();
343
+ // dev 서버 UI는 브라우저에서 호출되므로 개발용 DB(development·test·fixture와 그 readonly)만 대상으로 받습니다.
344
+ // production 제외는 허용 목록과 별개로 한 번 더 막아 두는 방어선입니다.
345
+ const migrator = new Migrator({ excludedTargets: ["production"], targetFilter: isUIDBPreset });
251
346
 
252
347
  server.get("/api/migrations/connections", async () => ({
253
348
  connections: migrator.getConnections(),
@@ -280,9 +375,9 @@ export async function registerMigrationsApi(server: FastifyInstance) {
280
375
  })),
281
376
  );
282
377
 
283
- server.post<{ Body: ApplyBody }>("/api/migrations/request-approval", (request) =>
378
+ server.post<{ Body: ApprovalRequestBody }>("/api/migrations/request-approval", (request) =>
284
379
  forwardAsyncErrors(async () => {
285
- return requestApproval(migrator, request.body.targets, request.body.requestor);
380
+ return requestApproval(migrator, request.body);
286
381
  }),
287
382
  );
288
383
  server.post<{ Body: { channel: string; ts: string } }>(
@@ -321,7 +416,7 @@ export async function registerMigrationsApi(server: FastifyInstance) {
321
416
  server.post<{ Body: ApplyBody }>("/api/migrations/apply", async (request, reply) => {
322
417
  assertTargets(migrator, request.body.targets);
323
418
  const statuses = await getAvailableTargetStatuses(migrator, request.body.targets);
324
- const approval = await requireApprovedApply(request.body, statuses);
419
+ const approval = await requireApproved(migrator, "apply", request.body, statuses);
325
420
  return sendMigrationStream(
326
421
  reply,
327
422
  "apply",
@@ -339,16 +434,29 @@ export async function registerMigrationsApi(server: FastifyInstance) {
339
434
  },
340
435
  );
341
436
  });
342
- server.post<{ Body: { targets: MigrationTarget[] } }>(
343
- "/api/migrations/rollback",
344
- async (request, reply) => {
345
- assertTargets(migrator, request.body.targets);
346
- await getAvailableTargetStatuses(migrator, request.body.targets);
347
- return sendMigrationStream(reply, "rollback", request.body.targets, (onProgress) => {
348
- return migrator.rollback(request.body.targets, { onProgress });
349
- });
350
- },
351
- );
437
+ server.post<{ Body: ApplyBody }>("/api/migrations/rollback", async (request, reply) => {
438
+ assertTargets(migrator, request.body.targets);
439
+ const statuses = await getAvailableTargetStatuses(migrator, request.body.targets);
440
+ // rollback은 데이터를 지울 수 있으므로 apply와 같은 Slack 승인을 거칩니다.
441
+ const approval = await requireApproved(migrator, "rollback", request.body, statuses);
442
+ return sendMigrationStream(
443
+ reply,
444
+ "rollback",
445
+ request.body.targets,
446
+ (onProgress) => migrator.rollback(request.body.targets, { onProgress }),
447
+ approval === null
448
+ ? undefined
449
+ : async (result) => {
450
+ await new SlackConfirm().logExecution(
451
+ approval.channel,
452
+ approval.ts,
453
+ result,
454
+ request.body.requestor,
455
+ "rollback",
456
+ );
457
+ },
458
+ );
459
+ });
352
460
 
353
461
  server.post<{ Body: { compareConnKey?: MigrationTarget } }>(
354
462
  "/api/migrations/generatePreparedCodes",
@@ -373,9 +481,7 @@ export async function registerMigrationsApi(server: FastifyInstance) {
373
481
  if (request.body.action === "apply") {
374
482
  return runLegacyApply(migrator, request.body);
375
483
  }
376
- assertTargets(migrator, request.body.targets);
377
- await getAvailableTargetStatuses(migrator, request.body.targets);
378
- return migrator.rollback(request.body.targets);
484
+ return runLegacyRollback(migrator, request.body);
379
485
  }),
380
486
  );
381
487
  }
@@ -0,0 +1,82 @@
1
+ import { execFileSync } from "child_process";
2
+ import fs from "fs";
3
+ import path from "path";
4
+
5
+ import { type FastifyInstance } from "fastify";
6
+
7
+ import { Sonamu } from "../api/sonamu";
8
+ import { SD } from "../dict/sd";
9
+ import { EntityManager } from "../entity/entity-manager";
10
+ import { BadRequestException } from "../exceptions/so-exceptions";
11
+ import { forwardAsyncErrors } from "./async-route";
12
+ import { requireSameOriginUIRequest } from "./ui-request-guard";
13
+
14
+ /**
15
+ * openVscode가 받은 absPath를 앱 루트 아래에 실제로 있는 파일의 경로로 확정합니다.
16
+ * 심볼릭 링크나 `..`로 앱 루트를 벗어나는 경로, 없는 경로, 디렉터리는 거부합니다.
17
+ */
18
+ function resolveOpenVscodeAbsPath(absPath: string): string {
19
+ const appRootPath = fs.realpathSync(Sonamu.appRootPath);
20
+ const realPath = (() => {
21
+ try {
22
+ return fs.realpathSync(path.resolve(appRootPath, absPath));
23
+ } catch {
24
+ throw new BadRequestException(SD("error.badRequest"));
25
+ }
26
+ })();
27
+
28
+ const relativePath = path.relative(appRootPath, realPath);
29
+ const isInsideAppRoot =
30
+ relativePath !== "" &&
31
+ relativePath !== ".." &&
32
+ !relativePath.startsWith(`..${path.sep}`) &&
33
+ !path.isAbsolute(relativePath);
34
+ if (!isInsideAppRoot || !fs.statSync(realPath).isFile()) {
35
+ throw new BadRequestException(SD("error.badRequest"));
36
+ }
37
+ return realPath;
38
+ }
39
+
40
+ /** 엔티티 파일이나 지정한 경로를 VS Code로 여는 Sonamu UI 도구 API를 등록합니다. */
41
+ export async function registerOpenVscodeApi(server: FastifyInstance) {
42
+ // 프로세스를 실행하는 라우트는 동일 출처 JSON POST만 받습니다.
43
+ server.post<{
44
+ Body: {
45
+ entityId?: string;
46
+ preset?: "types" | "entity.json" | "generated";
47
+ absPath?: string;
48
+ };
49
+ }>("/api/tools/openVscode", { onRequest: requireSameOriginUIRequest }, (request) =>
50
+ forwardAsyncErrors(async () => {
51
+ const { entityId, preset, absPath } = request.body;
52
+
53
+ const targetPath = (() => {
54
+ if (entityId && preset) {
55
+ const entity = EntityManager.get(entityId);
56
+ const { names } = entity;
57
+
58
+ const { apiRootPath } = Sonamu;
59
+ const filename = (() => {
60
+ switch (preset) {
61
+ case "types":
62
+ return `${names.fs}.types.ts`;
63
+ case "entity.json":
64
+ return `${names.fs}.entity.json`;
65
+ case "generated":
66
+ return `${names.fs}.generated.ts`;
67
+ }
68
+ return undefined;
69
+ })();
70
+ return `${apiRootPath}/src/application/${entity.names.parentFs}/${filename}`;
71
+ } else {
72
+ if (!absPath) {
73
+ throw new BadRequestException(SD("sonamu.error.presetOrAbsPathRequired"));
74
+ }
75
+ return resolveOpenVscodeAbsPath(absPath);
76
+ }
77
+ })();
78
+ // 셸을 거치지 않고 경로를 `--` 뒤에 두어, 명령이나 code 옵션으로 해석되지 않도록 합니다.
79
+ execFileSync("code", ["--", targetPath]);
80
+ }),
81
+ );
82
+ }
@@ -0,0 +1,177 @@
1
+ import { type FastifyInstance } from "fastify";
2
+ import { z } from "zod";
3
+
4
+ import { Sonamu } from "../api/sonamu";
5
+ import { SD } from "../dict/sd";
6
+ import { sonamuDictionary } from "../dict/sonamu-dictionary";
7
+ import { EntityManager } from "../entity/entity-manager";
8
+ import {
9
+ BadRequestException,
10
+ isSoException,
11
+ ServiceUnavailableException,
12
+ } from "../exceptions/so-exceptions";
13
+ import { TemplateManager } from "../template/template-manager";
14
+ import { type PathAndCode } from "../types/types";
15
+ import { nonNullable } from "../utils/utils";
16
+ import { forwardAsyncErrors } from "./async-route";
17
+
18
+ /**
19
+ * Sonamu UI 스캐폴딩에서 생성할 수 있는 템플릿 키입니다.
20
+ * entity·generated 같은 동기화용 템플릿은 엔티티 정의나 생성 코드 전체를 덮어쓰므로 받지 않습니다.
21
+ */
22
+ export const ScaffoldingTemplateKey = z.enum([
23
+ "model",
24
+ "model_test",
25
+ "view_list",
26
+ "view_search_input",
27
+ "view_form",
28
+ "view_id_all_select",
29
+ ]);
30
+ export type ScaffoldingTemplateKey = z.infer<typeof ScaffoldingTemplateKey>;
31
+
32
+ /**
33
+ * createEntity와 같은 entityId 규칙입니다.
34
+ * 경로 구분자·`..`·따옴표가 생성 파일 경로나 생성 코드에 들어가지 않게 합니다.
35
+ */
36
+ const ScaffoldingEntityId = z.string().regex(/^[A-Z][a-zA-Z0-9]*$/);
37
+
38
+ const ScaffoldingOption = z.object({
39
+ entityId: ScaffoldingEntityId,
40
+ templateKey: ScaffoldingTemplateKey,
41
+ });
42
+
43
+ const ScaffoldingGetStatusBody = z.object({
44
+ entityIds: z.array(ScaffoldingEntityId),
45
+ templateKeys: z.array(ScaffoldingTemplateKey),
46
+ });
47
+
48
+ const ScaffoldingGenerateBody = z.object({
49
+ options: z.array(ScaffoldingOption.extend({ overwrite: z.boolean().optional() })),
50
+ });
51
+
52
+ const ScaffoldingPreviewBody = z.object({
53
+ option: ScaffoldingOption,
54
+ });
55
+
56
+ /** 요청 본문을 스키마로 검증하고, 형식이 어긋나면 어떤 파일도 건드리기 전에 400으로 거부합니다. */
57
+ function parseScaffoldingBody<Schema extends z.ZodType>(
58
+ schema: Schema,
59
+ body: Parameters<Schema["safeParse"]>[0],
60
+ ): z.infer<Schema> {
61
+ const result = schema.safeParse(body);
62
+ if (!result.success) {
63
+ throw new BadRequestException(SD("error.badRequest"), result.error.issues);
64
+ }
65
+ return result.data;
66
+ }
67
+
68
+ /** 등록되지 않은 엔티티로는 스캐폴딩 파일을 만들거나 경로를 조회하지 않습니다. */
69
+ function assertRegisteredEntity(entityId: string): void {
70
+ if (!EntityManager.exists(entityId)) {
71
+ throw new BadRequestException(SD("error.targetNotFound"));
72
+ }
73
+ }
74
+
75
+ /** Sonamu UI의 스캐폴딩(상태 조회·생성·미리보기) API를 등록합니다. */
76
+ export async function registerScaffoldingApi(server: FastifyInstance) {
77
+ server.post("/api/scaffolding/getStatus", (request) =>
78
+ forwardAsyncErrors(async () => {
79
+ const { entityIds, templateKeys: requestedTemplateKeys } = parseScaffoldingBody(
80
+ ScaffoldingGetStatusBody,
81
+ request.body,
82
+ );
83
+ if (entityIds.length === 0) {
84
+ throw new BadRequestException(SD("sonamu.error.entityIdsRequired"));
85
+ } else if (requestedTemplateKeys.length === 0) {
86
+ throw new BadRequestException(SD("sonamu.error.templateKeysRequired"));
87
+ }
88
+ entityIds.forEach(assertRegisteredEntity);
89
+
90
+ // sorting
91
+ entityIds.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
92
+ const templateKeys = ScaffoldingTemplateKey.options.filter((tk) =>
93
+ requestedTemplateKeys.includes(tk),
94
+ );
95
+
96
+ const combinations = entityIds.flatMap((entityId) => {
97
+ return templateKeys.map((templateKey) => [entityId, templateKey] as const);
98
+ });
99
+
100
+ const statuses = await Promise.all(
101
+ combinations.map(async ([entityId, templateKey]) => {
102
+ const { subPath, fullPath, isExists } = await Sonamu.syncer.checkExistsGenCode(
103
+ entityId,
104
+ templateKey,
105
+ );
106
+ return {
107
+ entityId,
108
+ templateKey,
109
+ subPath,
110
+ fullPath,
111
+ isExists,
112
+ };
113
+ }),
114
+ );
115
+ return { statuses };
116
+ }),
117
+ );
118
+
119
+ server.post("/api/scaffolding/generate", (request) =>
120
+ forwardAsyncErrors(async () => {
121
+ const { options } = parseScaffoldingBody(ScaffoldingGenerateBody, request.body);
122
+ if (options.length === 0) {
123
+ throw new BadRequestException(SD("sonamu.error.optionsRequired"));
124
+ }
125
+ // 하나라도 잘못된 항목이 있으면 아무 파일도 만들지 않도록 생성 전에 전부 확인한다.
126
+ options.forEach(({ entityId }) => assertRegisteredEntity(entityId));
127
+
128
+ // 1. 모든 템플릿에서 필요한 dict 키를 수집
129
+ const keys = options.flatMap(({ templateKey }) => {
130
+ const template = TemplateManager.get(templateKey);
131
+ return template.getRequiredDictKeys() ?? [];
132
+ });
133
+
134
+ // 2. target별로 ensureDictKeys 호출 (순차 처리)
135
+ await sonamuDictionary.ensureDictKeys([...new Set(keys)]);
136
+
137
+ // 3. 템플릿 생성 (병렬 처리)
138
+ const result = await Promise.all(
139
+ options.map(async ({ entityId, templateKey, overwrite }) => {
140
+ try {
141
+ return await Sonamu.syncer.generateTemplate(templateKey, { entityId }, { overwrite });
142
+ } catch (e) {
143
+ if (isSoException(e) && e.statusCode === 541) {
144
+ return null;
145
+ } else {
146
+ console.error(e);
147
+ throw e;
148
+ }
149
+ }
150
+ }),
151
+ );
152
+
153
+ if (result.filter(nonNullable).length === 0) {
154
+ throw new ServiceUnavailableException(SD("sonamu.error.allFilesGenerated"));
155
+ }
156
+ return result;
157
+ }),
158
+ );
159
+
160
+ server.post("/api/scaffolding/preview", (request): Promise<{ pathAndCodes: PathAndCode[] }> =>
161
+ forwardAsyncErrors(async () => {
162
+ const {
163
+ option: { entityId, templateKey },
164
+ } = parseScaffoldingBody(ScaffoldingPreviewBody, request.body);
165
+ assertRegisteredEntity(entityId);
166
+
167
+ try {
168
+ const pathAndCodes = await Sonamu.syncer.renderTemplate(templateKey, { entityId });
169
+
170
+ return { pathAndCodes };
171
+ } catch (e) {
172
+ console.error(e);
173
+ throw e;
174
+ }
175
+ }),
176
+ );
177
+ }
@@ -0,0 +1,41 @@
1
+ import { type SonamuDBConfig, type SonamuDBPreset } from "../database/db";
2
+ import { SD } from "../dict/sd";
3
+ import { BadRequestException } from "../exceptions/so-exceptions";
4
+
5
+ /**
6
+ * Sonamu UI(dev 서버) HTTP API가 다룰 수 있는 DB 프리셋입니다.
7
+ *
8
+ * dev 서버는 브라우저에서 호출되므로 staging·production 같은 운영 계열 프리셋은
9
+ * 마이그레이션·fixture 조회·저장 대상에서 제외하고, CLI로만 다루게 합니다.
10
+ */
11
+ export const UI_DB_PRESETS = [
12
+ "development",
13
+ "development_readonly",
14
+ "test",
15
+ "test_readonly",
16
+ "fixture",
17
+ ] as const satisfies readonly SonamuDBPreset[];
18
+
19
+ /**
20
+ * 주어진 값이 UI API에서 허용되는 DB 프리셋인지 확인합니다.
21
+ * 요청 본문이 배열 등 다른 형태여도 허용 목록과 일치하지 않으므로 거부됩니다.
22
+ */
23
+ export function isUIDBPreset(preset: string): preset is (typeof UI_DB_PRESETS)[number] {
24
+ return UI_DB_PRESETS.some((allowed) => allowed === preset);
25
+ }
26
+
27
+ /**
28
+ * UI API 요청의 DB 프리셋 값을 검증합니다.
29
+ * 허용 목록 밖이거나 현재 설정에 없는 프리셋이면 DB에 연결하기 전에 거부합니다.
30
+ */
31
+ export function assertUIDBPreset(
32
+ preset: string,
33
+ dbConfig: SonamuDBConfig,
34
+ field: string,
35
+ ): asserts preset is keyof SonamuDBConfig {
36
+ if (!isUIDBPreset(preset) || !Object.hasOwn(dbConfig, preset)) {
37
+ throw new BadRequestException(SD("error.badRequest"), {
38
+ message: `DB preset is not allowed in Sonamu UI (${field}): ${String(preset)}`,
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,53 @@
1
+ import { type FastifyReply, type FastifyRequest } from "fastify";
2
+
3
+ import { SD } from "../dict/sd";
4
+
5
+ /** Sonamu UI가 모든 요청에 붙이는 표식 헤더입니다. 커스텀 헤더라서 교차 출처 요청은 반드시 preflight를 거칩니다. */
6
+ export const SONAMU_UI_REQUEST_HEADER = "x-sonamu-ui";
7
+
8
+ const ALLOWED_FETCH_SITES = new Set(["same-origin", "none"]);
9
+
10
+ function isSameOriginUIRequest(request: FastifyRequest): boolean {
11
+ // form·no-cors fetch 같은 단순 요청은 application/json을 보낼 수 없습니다.
12
+ const contentType = request.headers["content-type"]?.split(";")[0]?.trim().toLowerCase();
13
+ if (contentType !== "application/json") {
14
+ return false;
15
+ }
16
+ if (request.headers[SONAMU_UI_REQUEST_HEADER] !== "1") {
17
+ return false;
18
+ }
19
+
20
+ // 앱이 CORS를 넓게 열어 preflight가 통과하더라도 브라우저가 붙인 출처 표시로 다시 거릅니다.
21
+ const fetchSite = request.headers["sec-fetch-site"];
22
+ if (fetchSite !== undefined) {
23
+ return ALLOWED_FETCH_SITES.has(fetchSite);
24
+ }
25
+
26
+ // Sec-Fetch-Site를 보내지 않는 브라우저는 Origin과 Host를 비교합니다.
27
+ const origin = request.headers.origin;
28
+ if (origin === undefined) {
29
+ return true;
30
+ }
31
+ try {
32
+ return new URL(origin).host === request.headers.host;
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+
38
+ /**
39
+ * 개발자 PC에서 프로세스를 실행하는 Sonamu UI 라우트용 onRequest 훅입니다.
40
+ *
41
+ * 동일 출처 Sonamu UI가 보낸 JSON 요청만 통과시키고, 다른 출처 웹페이지가 보낸
42
+ * form·no-cors fetch·교차 출처 요청은 본문을 파싱하기 전에 403으로 거부합니다.
43
+ */
44
+ export async function requireSameOriginUIRequest(
45
+ request: FastifyRequest,
46
+ reply: FastifyReply,
47
+ ): Promise<FastifyReply | undefined> {
48
+ if (!isSameOriginUIRequest(request)) {
49
+ // async 훅에서 응답을 끝낼 때는 reply를 반환해야 핸들러로 넘어가지 않습니다.
50
+ return reply.code(403).send({ message: SD("error.forbidden"), issues: [] });
51
+ }
52
+ return undefined;
53
+ }