sonamu 0.14.1 → 0.15.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 (80) hide show
  1. package/dist/auth/better-auth-entities.d.ts.map +1 -1
  2. package/dist/auth/better-auth-entities.js +35 -35
  3. package/dist/auth/plugins/entity-definitions/admin.js +6 -6
  4. package/dist/auth/plugins/entity-definitions/anonymous.js +2 -2
  5. package/dist/auth/plugins/entity-definitions/api-key.d.ts.map +1 -1
  6. package/dist/auth/plugins/entity-definitions/api-key.js +23 -23
  7. package/dist/auth/plugins/entity-definitions/audit-log.d.ts.map +1 -1
  8. package/dist/auth/plugins/entity-definitions/audit-log.js +28 -28
  9. package/dist/auth/plugins/entity-definitions/jwt.js +6 -6
  10. package/dist/auth/plugins/entity-definitions/organization.js +32 -32
  11. package/dist/auth/plugins/entity-definitions/passkey.js +12 -12
  12. package/dist/auth/plugins/entity-definitions/phone-number.js +3 -3
  13. package/dist/auth/plugins/entity-definitions/sso.js +9 -9
  14. package/dist/auth/plugins/entity-definitions/two-factor.js +11 -11
  15. package/dist/auth/plugins/entity-definitions/username.js +3 -3
  16. package/dist/dict/sonamu-dictionary.js +9 -9
  17. package/dist/dict/types.d.ts +1 -1
  18. package/dist/dict/types.d.ts.map +1 -1
  19. package/dist/entity/entity-codegen-safety.d.ts +2 -1
  20. package/dist/entity/entity-codegen-safety.d.ts.map +1 -1
  21. package/dist/entity/entity-codegen-safety.js +3 -2
  22. package/dist/entity/entity-manager.d.ts +40 -20
  23. package/dist/entity/entity-manager.d.ts.map +1 -1
  24. package/dist/entity/entity.d.ts.map +1 -1
  25. package/dist/entity/entity.js +4 -2
  26. package/dist/index.js +2 -2
  27. package/dist/template/helpers.js +3 -3
  28. package/dist/template/implementations/entity.template.js +4 -4
  29. package/dist/template/implementations/generated.template.d.ts.map +1 -1
  30. package/dist/template/implementations/generated.template.js +3 -4
  31. package/dist/template/implementations/sd.template.js +3 -3
  32. package/dist/template/implementations/view_form.template.js +2 -2
  33. package/dist/template/zod-converter.d.ts +12 -2
  34. package/dist/template/zod-converter.d.ts.map +1 -1
  35. package/dist/template/zod-converter.js +31 -18
  36. package/dist/types/types.d.ts +153 -64
  37. package/dist/types/types.d.ts.map +1 -1
  38. package/dist/types/types.js +19 -7
  39. package/dist/ui/ai-client.js +3 -3
  40. package/dist/ui/api.js +2 -2
  41. package/dist/ui/migrations-api.d.ts.map +1 -1
  42. package/dist/ui/migrations-api.js +2 -2
  43. package/dist/ui-web/assets/{index-BPqP-tug.js → index-CdZtV4yt.js} +46 -46
  44. package/dist/ui-web/assets/index-DbecN7yE.css +1 -0
  45. package/dist/ui-web/index.html +2 -2
  46. package/package.json +3 -1
  47. package/src/auth/better-auth-entities.ts +40 -34
  48. package/src/auth/plugins/entity-definitions/admin.ts +5 -5
  49. package/src/auth/plugins/entity-definitions/anonymous.ts +1 -1
  50. package/src/auth/plugins/entity-definitions/api-key.ts +28 -22
  51. package/src/auth/plugins/entity-definitions/audit-log.ts +34 -27
  52. package/src/auth/plugins/entity-definitions/jwt.ts +5 -5
  53. package/src/auth/plugins/entity-definitions/organization.ts +31 -31
  54. package/src/auth/plugins/entity-definitions/passkey.ts +11 -11
  55. package/src/auth/plugins/entity-definitions/phone-number.ts +2 -2
  56. package/src/auth/plugins/entity-definitions/sso.ts +8 -8
  57. package/src/auth/plugins/entity-definitions/two-factor.ts +10 -10
  58. package/src/auth/plugins/entity-definitions/username.ts +2 -2
  59. package/src/bin/__tests__/zod-compiler-build.test.ts +2 -1
  60. package/src/dict/sonamu-dictionary.ts +6 -6
  61. package/src/dict/types.ts +1 -1
  62. package/src/entity/__tests__/entity-codegen-safety.test.ts +44 -12
  63. package/src/entity/__tests__/entity-subset-query.test.ts +35 -7
  64. package/src/entity/entity-codegen-safety.ts +2 -1
  65. package/src/entity/entity.ts +3 -0
  66. package/src/shared/app.shared.ts.txt +1 -2
  67. package/src/shared/web.shared.ts.txt +1 -2
  68. package/src/template/helpers.ts +3 -3
  69. package/src/template/implementations/entity.template.ts +3 -3
  70. package/src/template/implementations/generated.template.ts +4 -3
  71. package/src/template/implementations/sd.template.ts +2 -2
  72. package/src/template/implementations/view_form.template.ts +1 -1
  73. package/src/template/zod-converter.ts +84 -19
  74. package/src/types/types.ts +42 -8
  75. package/src/ui/__tests__/migrations-api.test.ts +90 -0
  76. package/src/ui/ai-client.ts +2 -2
  77. package/src/ui/api.ts +2 -2
  78. package/src/ui/entity.instructions.md +45 -43
  79. package/src/ui/migrations-api.ts +6 -3
  80. package/dist/ui-web/assets/index-dV7akMFB.css +0 -1
@@ -77,7 +77,10 @@ export type CommonProp = {
77
77
  name: string;
78
78
  nullable?: boolean;
79
79
  toFilter?: true;
80
- desc?: string;
80
+ /** 칸의 표시 이름입니다. 서브셋 스키마에 zod 메타 `title`로 실립니다. */
81
+ title?: string;
82
+ /** 칸이 무슨 뜻인지 적는 설명입니다. 서브셋 스키마에 zod `description`으로 실립니다. */
83
+ description?: string;
81
84
  dbDefault?: string;
82
85
  generated?: GeneratedColumn;
83
86
  /**
@@ -91,10 +94,10 @@ export type CommonProp = {
91
94
  /**
92
95
  * prop의 설명을 반환합니다.
93
96
  *
94
- * cone.note가 있으면 우선 사용하고, 없으면 prop.desc를 사용합니다.
97
+ * cone.note가 있으면 우선 사용하고, 없으면 prop.title을 사용합니다.
95
98
  */
96
- export function getDescription(item: { desc?: string; cone?: Cone }): string | undefined {
97
- return item.cone?.note || item.desc;
99
+ export function getDescription(item: { title?: string; cone?: Cone }): string | undefined {
100
+ return item.cone?.note || item.title;
98
101
  }
99
102
  export type IntegerProp = CommonProp & {
100
103
  type: "integer";
@@ -248,7 +251,10 @@ type _RelationProp = {
248
251
  with: string;
249
252
  nullable?: boolean; // DEFAULT: false
250
253
  toFilter?: true; // DEFAULT: false
251
- desc?: string;
254
+ /** 칸의 표시 이름입니다. */
255
+ title?: string;
256
+ /** 칸이 무슨 뜻인지 적는 설명입니다. */
257
+ description?: string;
252
258
  /** true이면 생성되는 `{Entity}BaseSaveParams`에서 FK 컬럼(`{name}_id`)을 제외합니다. */
253
259
  readonly?: boolean;
254
260
  cone?: Cone; // cone 메타데이터
@@ -346,6 +352,33 @@ export interface SonamuFile extends SonamuFileBase, SonamuFileExtend {}
346
352
  */
347
353
  export interface UploadParams {}
348
354
 
355
+ declare module "zod" {
356
+ /**
357
+ * Sonamu가 zod 기본 레지스트리 메타에 평평한 키로 싣는 표식입니다.
358
+ * zod 메타는 키별로 합쳐지므로 사용자가 `title`·`description`을 더해도 표식이 남습니다.
359
+ */
360
+ interface GlobalMeta {
361
+ /** 칸 종류 표식. 내장 타입(`SonamuFile`, `SonamuFile[]`)이나 사용자 JSON 타입 이름입니다. */
362
+ SonamuType?: string;
363
+ /** 생성된 enum의 ID. 필터 UI가 `enum.{EnumId}.{값}` 라벨 키를 만들 때 읽습니다. */
364
+ SonamuEnumId?: string;
365
+ /** numeric 칸 표시. 필터 UI가 읽습니다. */
366
+ SonamuPropType?: "numeric";
367
+ }
368
+ }
369
+
370
+ /**
371
+ * 스키마의 zod 기본 레지스트리 메타에서 Sonamu 타입 표식(`SonamuType`)을 읽습니다.
372
+ *
373
+ * 표식은 `.meta({ SonamuType: "..." })`로 겁니다. `title`·`description` 같은 zod 표준 메타와
374
+ * 같은 레지스트리에 평평한 키로 두므로, 사용자가 `.describe()`·`.meta()`로 메타를 더해도 키별로 합쳐져
375
+ * 표식이 지워지지 않습니다. `.optional()`·`.nullable()`·`z.array()`로 감싼 스키마는 메타를 물려받지
376
+ * 않으므로 감싼 스키마는 벗겨서 넘겨야 합니다.
377
+ */
378
+ export function getSonamuType(schema: z.core.$ZodType): string | undefined {
379
+ return z.globalRegistry.get(schema)?.SonamuType;
380
+ }
381
+
349
382
  export const SonamuFileSchema: z.ZodType<SonamuFile> = z
350
383
  .looseObject({
351
384
  name: z.string(),
@@ -353,9 +386,9 @@ export const SonamuFileSchema: z.ZodType<SonamuFile> = z
353
386
  mime_type: z.string(),
354
387
  size: z.number(),
355
388
  })
356
- .describe("SonamuFile");
389
+ .meta({ SonamuType: "SonamuFile" });
357
390
 
358
- export const SonamuFileArraySchema = z.array(SonamuFileSchema).describe("SonamuFile[]");
391
+ export const SonamuFileArraySchema = z.array(SonamuFileSchema).meta({ SonamuType: "SonamuFile[]" });
359
392
 
360
393
  /**
361
394
  * Sonamu 코어에서 제공하는 내장 JSON 타입 ID 목록
@@ -1172,7 +1205,8 @@ const GeneratedColumnSchema = z.object({
1172
1205
 
1173
1206
  const BasePropFields = {
1174
1207
  name: z.string(),
1175
- desc: z.string().optional(),
1208
+ title: z.string().optional(),
1209
+ description: z.string().optional(),
1176
1210
  nullable: z.boolean().optional(),
1177
1211
  toFilter: z.boolean().default(false).optional(),
1178
1212
  dbDefault: z.union([z.string(), z.number(), z.boolean()]).optional(),
@@ -349,4 +349,94 @@ describe("Sonamu UI 마이그레이션 API", () => {
349
349
  expect(slack.posted()[0]).toContain("롤백 승인 요청");
350
350
  });
351
351
  });
352
+
353
+ describe("--deploy 모드(SONAMU_DEPLOY=yes)", () => {
354
+ const originalDeployEnv = process.env.SONAMU_DEPLOY;
355
+
356
+ afterEach(() => {
357
+ if (originalDeployEnv === undefined) {
358
+ delete process.env.SONAMU_DEPLOY;
359
+ } else {
360
+ process.env.SONAMU_DEPLOY = originalDeployEnv;
361
+ }
362
+ });
363
+
364
+ it("연결 목록에 staging·production을 노출하고 readonly는 계속 제외한다", async () => {
365
+ process.env.SONAMU_DEPLOY = "yes";
366
+ await start({});
367
+
368
+ const res = await app.inject({ method: "GET", url: "/api/migrations/connections" });
369
+
370
+ expect(res.statusCode).toBe(200);
371
+ expect(res.json().connections.map(({ connKey }: { connKey: string }) => connKey)).toEqual([
372
+ "test",
373
+ "fixture",
374
+ "development",
375
+ "staging",
376
+ "production",
377
+ ]);
378
+ });
379
+
380
+ it("staging과 production 대상의 apply·rollback을 허용한다", async () => {
381
+ process.env.SONAMU_DEPLOY = "yes";
382
+ await start({});
383
+
384
+ const applyRes = await app.inject({
385
+ method: "POST",
386
+ url: "/api/migrations/apply",
387
+ payload: { targets: ["staging", "production"] },
388
+ });
389
+ const rollbackRes = await app.inject({
390
+ method: "POST",
391
+ url: "/api/migrations/rollback",
392
+ payload: { targets: ["staging"] },
393
+ });
394
+
395
+ expect(applyRes.statusCode).toBe(200);
396
+ expect(applyRes.body).toContain('"type":"complete"');
397
+ expect(applySpy).toHaveBeenCalledWith(["staging", "production"], expect.anything());
398
+ expect(rollbackRes.statusCode).toBe(200);
399
+ expect(rollbackRes.body).toContain('"type":"complete"');
400
+ expect(rollbackSpy).toHaveBeenCalledWith(["staging"], expect.anything());
401
+ });
402
+
403
+ it("deploy 모드에서도 원격 production 승인 설정이 있으면 승인 없이 실행할 수 없다", async () => {
404
+ process.env.SONAMU_DEPLOY = "yes";
405
+ // production은 createDBConfig에서 로컬이므로 원격 호스트를 지정해 승인 경로를 검증합니다.
406
+ ({ cleanup } = await setupSonamu(
407
+ createConfig(["production"]),
408
+ createDBConfig({ production: "prod-db.internal.example" }),
409
+ ));
410
+ app = Fastify();
411
+ await registerMigrationsApi(app);
412
+ const slack = stubSlack();
413
+
414
+ const res = await app.inject({
415
+ method: "POST",
416
+ url: "/api/migrations/apply",
417
+ payload: { targets: ["production"] },
418
+ });
419
+
420
+ expect(res.statusCode).toBe(400);
421
+ expect(applySpy).not.toHaveBeenCalled();
422
+ expect(slack.calls).toHaveLength(0);
423
+ });
424
+
425
+ it.each(["", "no", "true", "1"])(
426
+ "SONAMU_DEPLOY=%j 는 deploy 모드로 인정하지 않아 staging·production을 숨긴다",
427
+ async (value) => {
428
+ process.env.SONAMU_DEPLOY = value;
429
+ await start({});
430
+
431
+ const res = await app.inject({ method: "GET", url: "/api/migrations/connections" });
432
+
433
+ expect(res.statusCode).toBe(200);
434
+ expect(res.json().connections.map(({ connKey }: { connKey: string }) => connKey)).toEqual([
435
+ "test",
436
+ "fixture",
437
+ "development",
438
+ ]);
439
+ },
440
+ );
441
+ });
352
442
  });
@@ -281,7 +281,7 @@ class AIClient {
281
281
  props: entity.props.map((p) => ({
282
282
  name: p.name,
283
283
  type: p.type,
284
- desc: p.desc,
284
+ title: p.title,
285
285
  })),
286
286
  };
287
287
  });
@@ -327,7 +327,7 @@ ${JSON.stringify(existingEntities, null, 2)}
327
327
  updateEntity({ entityId: "Employee", updates: { enumLabels: { "EmployeeRole": { "admin": "관리자", "user": "일반" } } } })
328
328
 
329
329
  예시: Project에 새 프로퍼티 추가
330
- updateEntity({ entityId: "Project", updates: { props: [{ name: "priority", type: "integer", desc: "우선순위" }] } })
330
+ updateEntity({ entityId: "Project", updates: { props: [{ name: "priority", type: "integer", title: "우선순위" }] } })
331
331
 
332
332
  ## 필수 사항
333
333
  - Entity의 props에는 최소한 id(integer, unsigned), created_at(timestamp)가 포함되어야 합니다.
package/src/ui/api.ts CHANGED
@@ -202,10 +202,10 @@ export async function sonamuUIApiPlugin(fastify: FastifyInstance) {
202
202
  if (glossary.has(prop.name)) {
203
203
  return;
204
204
  }
205
- if (prop.desc) {
205
+ if (prop.title) {
206
206
  glossary.set(
207
207
  prop.name,
208
- prop.desc.replace(glossaryEntity.title ?? "", "{EntityID}"),
208
+ prop.title.replace(glossaryEntity.title ?? "", "{EntityID}"),
209
209
  );
210
210
  }
211
211
  });
@@ -8,11 +8,11 @@
8
8
  "table": "table_name",
9
9
  "title": "엔티티 제목",
10
10
  "props": [
11
- { "name": "id", "type": "integer", "desc": "ID" },
11
+ { "name": "id", "type": "integer", "title": "ID" },
12
12
  {
13
13
  "name": "created_at",
14
14
  "type": "date",
15
- "desc": "등록일시",
15
+ "title": "등록일시",
16
16
  "dbDefault": "CURRENT_TIMESTAMP"
17
17
  }
18
18
  // Additional property definitions go here
@@ -35,7 +35,7 @@
35
35
  1. **id** - 기본키
36
36
 
37
37
  ```json
38
- { "name": "id", "type": "integer", "desc": "ID" }
38
+ { "name": "id", "type": "integer", "title": "ID" }
39
39
  ```
40
40
 
41
41
  2. **created_at** - 등록일시
@@ -43,7 +43,7 @@
43
43
  {
44
44
  "name": "created_at",
45
45
  "type": "date",
46
- "desc": "등록일시",
46
+ "title": "등록일시",
47
47
  "dbDefault": "CURRENT_TIMESTAMP"
48
48
  }
49
49
  ```
@@ -72,7 +72,8 @@
72
72
  | 필드 | 타입 | 필수 | 설명 |
73
73
  | --------- | --------------------------- | ---- | ------------------------------ |
74
74
  | name | string | ✓ | 프로퍼티 이름 |
75
- | desc | string | | 설명 |
75
+ | title | string | | 표시 이름 (화면·사전·API 명세의 title) |
76
+ | description | string | | 칸 설명 (API 명세의 description) |
76
77
  | nullable | boolean | | null 허용 여부 (기본값: false) |
77
78
  | toFilter | boolean | | 필터 조건으로 사용 여부 |
78
79
  | dbDefault | string \| number \| boolean | | DB 기본값 |
@@ -97,22 +98,22 @@
97
98
  ### 1. Integer / Integer[]
98
99
 
99
100
  ```json
100
- { "name": "count", "type": "integer", "desc": "수량" }
101
- { "name": "scores", "type": "integer[]", "desc": "점수 목록" }
101
+ { "name": "count", "type": "integer", "title": "수량" }
102
+ { "name": "scores", "type": "integer[]", "title": "점수 목록" }
102
103
  ```
103
104
 
104
105
  ### 2. BigInteger / BigInteger[]
105
106
 
106
107
  ```json
107
- { "name": "total_amount", "type": "bigInteger", "desc": "총액" }
108
- { "name": "big_numbers", "type": "bigInteger[]", "desc": "큰 숫자 목록" }
108
+ { "name": "total_amount", "type": "bigInteger", "title": "총액" }
109
+ { "name": "big_numbers", "type": "bigInteger[]", "title": "큰 숫자 목록" }
109
110
  ```
110
111
 
111
112
  ### 3. String / String[]
112
113
 
113
114
  ```json
114
- { "name": "title", "type": "string", "desc": "제목", "length": 255 }
115
- { "name": "tags", "type": "string[]", "desc": "태그 목록" }
115
+ { "name": "title", "type": "string", "title": "제목", "length": 255 }
116
+ { "name": "tags", "type": "string[]", "title": "태그 목록" }
116
117
  ```
117
118
 
118
119
  - `length`: 최대 길이 (Optional, 생략 시 text)
@@ -120,15 +121,15 @@
120
121
  ### 4. Boolean / Boolean[]
121
122
 
122
123
  ```json
123
- { "name": "is_active", "type": "boolean", "desc": "활성여부", "dbDefault": false }
124
- { "name": "flags", "type": "boolean[]", "desc": "플래그 목록" }
124
+ { "name": "is_active", "type": "boolean", "title": "활성여부", "dbDefault": false }
125
+ { "name": "flags", "type": "boolean[]", "title": "플래그 목록" }
125
126
  ```
126
127
 
127
128
  ### 5. Date / Date[]
128
129
 
129
130
  ```json
130
- { "name": "created_at", "type": "date", "desc": "등록일시", "dbDefault": "CURRENT_TIMESTAMP" }
131
- { "name": "holidays", "type": "date[]", "desc": "휴일 목록" }
131
+ { "name": "created_at", "type": "date", "title": "등록일시", "dbDefault": "CURRENT_TIMESTAMP" }
132
+ { "name": "holidays", "type": "date[]", "title": "휴일 목록" }
132
133
  ```
133
134
 
134
135
  - PostgreSQL의 `timestamptz` 타입으로 매핑됨
@@ -139,12 +140,12 @@
139
140
  {
140
141
  "name": "price",
141
142
  "type": "number",
142
- "desc": "가격",
143
+ "title": "가격",
143
144
  "precision": 10,
144
145
  "scale": 2,
145
146
  "numberType": "numeric"
146
147
  }
147
- { "name": "rates", "type": "number[]", "desc": "비율 목록" }
148
+ { "name": "rates", "type": "number[]", "title": "비율 목록" }
148
149
  ```
149
150
 
150
151
  - `precision`: 전체 자릿수 (Optional)
@@ -154,8 +155,8 @@
154
155
  ### 7. Numeric / Numeric[]
155
156
 
156
157
  ```json
157
- { "name": "exact_value", "type": "numeric", "desc": "정밀값", "precision": 20, "scale": 8 }
158
- { "name": "exact_values", "type": "numeric[]", "desc": "정밀값 목록" }
158
+ { "name": "exact_value", "type": "numeric", "title": "정밀값", "precision": 20, "scale": 8 }
159
+ { "name": "exact_values", "type": "numeric[]", "title": "정밀값 목록" }
159
160
  ```
160
161
 
161
162
  - `precision`: 전체 자릿수 (Optional)
@@ -165,8 +166,8 @@
165
166
  ### 8. UUID / UUID[]
166
167
 
167
168
  ```json
168
- { "name": "external_id", "type": "uuid", "desc": "외부 ID" }
169
- { "name": "reference_ids", "type": "uuid[]", "desc": "참조 ID 목록" }
169
+ { "name": "external_id", "type": "uuid", "title": "외부 ID" }
170
+ { "name": "reference_ids", "type": "uuid[]", "title": "참조 ID 목록" }
170
171
  ```
171
172
 
172
173
  ### 9. Enum / Enum[] (Required: id)
@@ -176,11 +177,11 @@
176
177
  "name": "status",
177
178
  "type": "enum",
178
179
  "id": "ProductStatus",
179
- "desc": "상태",
180
+ "title": "상태",
180
181
  "length": 16,
181
182
  "dbDefault": "\"active\""
182
183
  }
183
- { "name": "categories", "type": "enum[]", "id": "ProductCategory", "desc": "카테고리 목록" }
184
+ { "name": "categories", "type": "enum[]", "id": "ProductCategory", "title": "카테고리 목록" }
184
185
  ```
185
186
 
186
187
  - `id`: enums에 정의된 Enum ID (Required)
@@ -195,7 +196,7 @@
195
196
  "name": "metadata",
196
197
  "type": "json",
197
198
  "id": "ProductMetadata",
198
- "desc": "메타데이터",
199
+ "title": "메타데이터",
199
200
  "dbDefault": "{}"
200
201
  }
201
202
  ```
@@ -209,7 +210,7 @@
209
210
  "name": "full_name",
210
211
  "type": "virtual",
211
212
  "id": "string",
212
- "desc": "전체 이름"
213
+ "title": "전체 이름"
213
214
  }
214
215
  ```
215
216
 
@@ -223,9 +224,9 @@
223
224
  "name": "embedding",
224
225
  "type": "vector",
225
226
  "dimensions": 1536,
226
- "desc": "임베딩 벡터"
227
+ "title": "임베딩 벡터"
227
228
  }
228
- { "name": "embeddings", "type": "vector[]", "dimensions": 768, "desc": "임베딩 목록" }
229
+ { "name": "embeddings", "type": "vector[]", "dimensions": 768, "title": "임베딩 목록" }
229
230
  ```
230
231
 
231
232
  - `dimensions`: 벡터 차원 수 (Required)
@@ -237,7 +238,7 @@
237
238
  {
238
239
  "name": "search_vector",
239
240
  "type": "tsvector",
240
- "desc": "검색 벡터",
241
+ "title": "검색 벡터",
241
242
  "generated": {
242
243
  "type": "STORED",
243
244
  "expression": "to_tsvector('korean', coalesce(title, '') || ' ' || coalesce(content, ''))"
@@ -257,7 +258,7 @@
257
258
  "type": "relation",
258
259
  "with": "User",
259
260
  "relationType": "BelongsToOne",
260
- "desc": "작성자",
261
+ "title": "작성자",
261
262
  "nullable": true, // Optional
262
263
  "customJoinClause": "...", // Optional
263
264
  "useConstraint": true, // Optional (기본값: true)
@@ -276,7 +277,7 @@
276
277
  "relationType": "HasMany",
277
278
  "joinColumn": "post_id", // Required: 상대 엔티티의 FK 컬럼명
278
279
  "fromColumn": "id", // Optional: 이 엔티티의 참조 컬럼 (기본값: id)
279
- "desc": "댓글 목록"
280
+ "title": "댓글 목록"
280
281
  }
281
282
  ```
282
283
 
@@ -291,7 +292,7 @@
291
292
  "joinTable": "posts__tags", // Required: "테이블명__테이블명" 형식
292
293
  "onUpdate": "CASCADE", // Required
293
294
  "onDelete": "CASCADE", // Required
294
- "desc": "태그 목록"
295
+ "title": "태그 목록"
295
296
  }
296
297
  ```
297
298
 
@@ -310,7 +311,7 @@
310
311
  "useConstraint": true, // Optional (기본값: true)
311
312
  "onUpdate": "CASCADE", // Optional (기본값: RESTRICT)
312
313
  "onDelete": "CASCADE", // Optional (기본값: RESTRICT)
313
- "desc": "프로필"
314
+ "title": "프로필"
314
315
  }
315
316
  ```
316
317
 
@@ -324,7 +325,7 @@
324
325
  "relationType": "OneToOne",
325
326
  "hasJoinColumn": false,
326
327
  "customJoinClause": "ON users.id = user_profiles.user_id", // Optional
327
- "desc": "프로필"
328
+ "title": "프로필"
328
329
  }
329
330
  ```
330
331
 
@@ -346,8 +347,9 @@
346
347
 
347
348
  1. `nullable`이 false(기본값)인 경우 생략합니다.
348
349
  2. `dbDefault`가 필요 없는 경우 생략합니다.
349
- 3. `desc`가 엔티티 제목과 중복되는 경우 생략할 수 있습니다.
350
- 4. 단수형은 단일 값, 복수형은 배열 값에 사용합니다. (예: tag vs tags)
350
+ 3. `title`이 엔티티 제목과 중복되는 경우 생략할 수 있습니다.
351
+ 4. `description`은 이름과 `title`만으로 뜻이 드러나지 않을 때만 적고, 아니면 생략합니다.
352
+ 5. 단수형은 단일 값, 복수형은 배열 값에 사용합니다. (예: tag vs tags)
351
353
 
352
354
  ### Type-specific Required Fields Summary
353
355
 
@@ -457,32 +459,32 @@
457
459
  "table": "products",
458
460
  "title": "상품",
459
461
  "props": [
460
- { "name": "id", "type": "integer", "desc": "ID" },
462
+ { "name": "id", "type": "integer", "title": "ID" },
461
463
  {
462
464
  "name": "created_at",
463
465
  "type": "date",
464
- "desc": "등록일시",
466
+ "title": "등록일시",
465
467
  "dbDefault": "CURRENT_TIMESTAMP"
466
468
  },
467
- { "name": "name", "type": "string", "desc": "상품명", "length": 255 },
469
+ { "name": "name", "type": "string", "title": "상품명", "length": 255 },
468
470
  {
469
471
  "name": "price",
470
472
  "type": "number",
471
- "desc": "가격",
473
+ "title": "가격",
472
474
  "precision": 10,
473
475
  "scale": 2
474
476
  },
475
477
  {
476
478
  "name": "description",
477
479
  "type": "string",
478
- "desc": "설명",
480
+ "title": "설명",
479
481
  "nullable": true
480
482
  },
481
483
  {
482
484
  "name": "status",
483
485
  "type": "enum",
484
486
  "id": "ProductStatus",
485
- "desc": "상태",
487
+ "title": "상태",
486
488
  "dbDefault": "\"active\""
487
489
  },
488
490
  {
@@ -492,7 +494,7 @@
492
494
  "relationType": "BelongsToOne",
493
495
  "onUpdate": "CASCADE",
494
496
  "onDelete": "CASCADE",
495
- "desc": "카테고리"
497
+ "title": "카테고리"
496
498
  },
497
499
  {
498
500
  "name": "tags",
@@ -502,7 +504,7 @@
502
504
  "joinTable": "products__tags",
503
505
  "onUpdate": "CASCADE",
504
506
  "onDelete": "CASCADE",
505
- "desc": "태그 목록"
507
+ "title": "태그 목록"
506
508
  }
507
509
  ],
508
510
  "indexes": [
@@ -340,9 +340,12 @@ function sendMigrationStream(
340
340
  }
341
341
 
342
342
  export async function registerMigrationsApi(server: FastifyInstance) {
343
- // dev 서버 UI는 브라우저에서 호출되므로 개발용 DB(development·test·fixture와 그 readonly)만 대상으로 받습니다.
344
- // production 제외는 허용 목록과 별개로 한 번 더 막아 두는 방어선입니다.
345
- const migrator = new Migrator({ excludedTargets: ["production"], targetFilter: isUIDBPreset });
343
+ // dev 서버 UI는 기본적으로 개발용 DB(development·test·fixture와 그 readonly)만 대상으로 받습니다.
344
+ // `sonamu dev --deploy`(SONAMU_DEPLOY=yes)로 띄운 경우에만 staging·production 대상을 엽니다.
345
+ const deployMode = process.env.SONAMU_DEPLOY === "yes";
346
+ const migrator = deployMode
347
+ ? new Migrator()
348
+ : new Migrator({ excludedTargets: ["production"], targetFilter: isUIDBPreset });
346
349
 
347
350
  server.get("/api/migrations/connections", async () => ({
348
351
  connections: migrator.getConnections(),