sonamu 0.14.2 → 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 (73) 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-web/assets/{index-ChMwt-QA.js → index-CdZtV4yt.js} +5 -5
  42. package/dist/ui-web/index.html +1 -1
  43. package/package.json +1 -1
  44. package/src/auth/better-auth-entities.ts +40 -34
  45. package/src/auth/plugins/entity-definitions/admin.ts +5 -5
  46. package/src/auth/plugins/entity-definitions/anonymous.ts +1 -1
  47. package/src/auth/plugins/entity-definitions/api-key.ts +28 -22
  48. package/src/auth/plugins/entity-definitions/audit-log.ts +34 -27
  49. package/src/auth/plugins/entity-definitions/jwt.ts +5 -5
  50. package/src/auth/plugins/entity-definitions/organization.ts +31 -31
  51. package/src/auth/plugins/entity-definitions/passkey.ts +11 -11
  52. package/src/auth/plugins/entity-definitions/phone-number.ts +2 -2
  53. package/src/auth/plugins/entity-definitions/sso.ts +8 -8
  54. package/src/auth/plugins/entity-definitions/two-factor.ts +10 -10
  55. package/src/auth/plugins/entity-definitions/username.ts +2 -2
  56. package/src/dict/sonamu-dictionary.ts +6 -6
  57. package/src/dict/types.ts +1 -1
  58. package/src/entity/__tests__/entity-codegen-safety.test.ts +44 -12
  59. package/src/entity/__tests__/entity-subset-query.test.ts +35 -7
  60. package/src/entity/entity-codegen-safety.ts +2 -1
  61. package/src/entity/entity.ts +3 -0
  62. package/src/shared/app.shared.ts.txt +1 -2
  63. package/src/shared/web.shared.ts.txt +1 -2
  64. package/src/template/helpers.ts +3 -3
  65. package/src/template/implementations/entity.template.ts +3 -3
  66. package/src/template/implementations/generated.template.ts +4 -3
  67. package/src/template/implementations/sd.template.ts +2 -2
  68. package/src/template/implementations/view_form.template.ts +1 -1
  69. package/src/template/zod-converter.ts +84 -19
  70. package/src/types/types.ts +42 -8
  71. package/src/ui/ai-client.ts +2 -2
  72. package/src/ui/api.ts +2 -2
  73. package/src/ui/entity.instructions.md +45 -43
@@ -16,12 +16,12 @@ export const organizationEntityDef: BetterAuthEntityDef = {
16
16
  table: "organizations",
17
17
  title: "조직",
18
18
  props: [
19
- { name: "id", type: "string", desc: "ID" },
20
- { name: "name", type: "string", desc: "조직명" },
21
- { name: "slug", type: "string", desc: "슬러그" },
22
- { name: "logo", type: "string", nullable: true, desc: "로고 URL" },
23
- { name: "metadata", type: "string", nullable: true, desc: "메타데이터 (JSON)" },
24
- { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
19
+ { name: "id", type: "string", title: "ID" },
20
+ { name: "name", type: "string", title: "조직명" },
21
+ { name: "slug", type: "string", title: "슬러그" },
22
+ { name: "logo", type: "string", nullable: true, title: "로고 URL" },
23
+ { name: "metadata", type: "string", nullable: true, title: "메타데이터 (JSON)" },
24
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "생성일시" },
25
25
  ],
26
26
  indexes: [{ type: "unique", name: "organizations_slug_unique", columns: [{ name: "slug" }] }],
27
27
  subsets: {
@@ -37,10 +37,10 @@ export const organizationEntityDef: BetterAuthEntityDef = {
37
37
  table: "teams",
38
38
  title: "팀",
39
39
  props: [
40
- { name: "id", type: "string", desc: "ID" },
41
- { name: "name", type: "string", desc: "팀명" },
42
- { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
43
- { name: "updated_at", type: "date", nullable: true, desc: "수정일시" },
40
+ { name: "id", type: "string", title: "ID" },
41
+ { name: "name", type: "string", title: "팀명" },
42
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "생성일시" },
43
+ { name: "updated_at", type: "date", nullable: true, title: "수정일시" },
44
44
  {
45
45
  type: "relation",
46
46
  name: "organization",
@@ -48,7 +48,7 @@ export const organizationEntityDef: BetterAuthEntityDef = {
48
48
  with: "Organization",
49
49
  relationType: "BelongsToOne",
50
50
  onDelete: "CASCADE",
51
- desc: "조직",
51
+ title: "조직",
52
52
  },
53
53
  ],
54
54
  indexes: [
@@ -71,9 +71,9 @@ export const organizationEntityDef: BetterAuthEntityDef = {
71
71
  table: "members",
72
72
  title: "멤버",
73
73
  props: [
74
- { name: "id", type: "string", desc: "ID" },
75
- { name: "role", type: "string", readonly: true, desc: "역할" },
76
- { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
74
+ { name: "id", type: "string", title: "ID" },
75
+ { name: "role", type: "string", readonly: true, title: "역할" },
76
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "생성일시" },
77
77
  {
78
78
  type: "relation",
79
79
  name: "user",
@@ -81,7 +81,7 @@ export const organizationEntityDef: BetterAuthEntityDef = {
81
81
  with: "User",
82
82
  relationType: "BelongsToOne",
83
83
  onDelete: "CASCADE",
84
- desc: "사용자",
84
+ title: "사용자",
85
85
  },
86
86
  {
87
87
  type: "relation",
@@ -90,7 +90,7 @@ export const organizationEntityDef: BetterAuthEntityDef = {
90
90
  with: "Organization",
91
91
  relationType: "BelongsToOne",
92
92
  onDelete: "CASCADE",
93
- desc: "조직",
93
+ title: "조직",
94
94
  },
95
95
  ],
96
96
  indexes: [
@@ -114,12 +114,12 @@ export const organizationEntityDef: BetterAuthEntityDef = {
114
114
  table: "invitations",
115
115
  title: "초대",
116
116
  props: [
117
- { name: "id", type: "string", desc: "ID" },
118
- { name: "email", type: "string", desc: "이메일" },
119
- { name: "role", type: "string", readonly: true, desc: "역할" },
120
- { name: "status", type: "string", readonly: true, desc: "상태" },
121
- { name: "expires_at", type: "date", readonly: true, desc: "만료일시" },
122
- { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
117
+ { name: "id", type: "string", title: "ID" },
118
+ { name: "email", type: "string", title: "이메일" },
119
+ { name: "role", type: "string", readonly: true, title: "역할" },
120
+ { name: "status", type: "string", readonly: true, title: "상태" },
121
+ { name: "expires_at", type: "date", readonly: true, title: "만료일시" },
122
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "생성일시" },
123
123
  {
124
124
  type: "relation",
125
125
  name: "inviter",
@@ -127,7 +127,7 @@ export const organizationEntityDef: BetterAuthEntityDef = {
127
127
  with: "User",
128
128
  relationType: "BelongsToOne",
129
129
  onDelete: "CASCADE",
130
- desc: "초대자",
130
+ title: "초대자",
131
131
  },
132
132
  {
133
133
  type: "relation",
@@ -136,7 +136,7 @@ export const organizationEntityDef: BetterAuthEntityDef = {
136
136
  with: "Organization",
137
137
  relationType: "BelongsToOne",
138
138
  onDelete: "CASCADE",
139
- desc: "조직",
139
+ title: "조직",
140
140
  },
141
141
  {
142
142
  type: "relation",
@@ -146,7 +146,7 @@ export const organizationEntityDef: BetterAuthEntityDef = {
146
146
  relationType: "BelongsToOne",
147
147
  onDelete: "SET NULL",
148
148
  nullable: true,
149
- desc: "팀",
149
+ title: "팀",
150
150
  },
151
151
  ],
152
152
  indexes: [
@@ -180,8 +180,8 @@ export const organizationEntityDef: BetterAuthEntityDef = {
180
180
  table: "team_members",
181
181
  title: "팀멤버",
182
182
  props: [
183
- { name: "id", type: "string", desc: "ID" },
184
- { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
183
+ { name: "id", type: "string", title: "ID" },
184
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "생성일시" },
185
185
  {
186
186
  type: "relation",
187
187
  name: "team",
@@ -189,7 +189,7 @@ export const organizationEntityDef: BetterAuthEntityDef = {
189
189
  with: "Team",
190
190
  relationType: "BelongsToOne",
191
191
  onDelete: "CASCADE",
192
- desc: "팀",
192
+ title: "팀",
193
193
  },
194
194
  {
195
195
  type: "relation",
@@ -198,7 +198,7 @@ export const organizationEntityDef: BetterAuthEntityDef = {
198
198
  with: "User",
199
199
  relationType: "BelongsToOne",
200
200
  onDelete: "CASCADE",
201
- desc: "사용자",
201
+ title: "사용자",
202
202
  },
203
203
  ],
204
204
  indexes: [
@@ -221,14 +221,14 @@ export const organizationEntityDef: BetterAuthEntityDef = {
221
221
  type: "string",
222
222
  nullable: true,
223
223
  readonly: true,
224
- desc: "활성 조직 ID",
224
+ title: "활성 조직 ID",
225
225
  },
226
226
  {
227
227
  name: "active_team_id",
228
228
  type: "string",
229
229
  nullable: true,
230
230
  readonly: true,
231
- desc: "활성 팀 ID",
231
+ title: "활성 팀 ID",
232
232
  },
233
233
  ],
234
234
  },
@@ -16,16 +16,16 @@ export const passkeyEntityDef: BetterAuthEntityDef = {
16
16
  table: "passkeys",
17
17
  title: "패스키",
18
18
  props: [
19
- { name: "id", type: "string", desc: "ID" },
20
- { name: "name", type: "string", nullable: true, desc: "패스키 이름" },
21
- { name: "public_key", type: "string", readonly: true, desc: "공개키" },
22
- { name: "credential_id", type: "string", readonly: true, desc: "자격 증명 ID" },
23
- { name: "counter", type: "integer", readonly: true, desc: "카운터" },
24
- { name: "device_type", type: "string", readonly: true, desc: "장치 유형" },
25
- { name: "backed_up", type: "boolean", readonly: true, desc: "백업 여부" },
26
- { name: "transports", type: "string", nullable: true, readonly: true, desc: "전송 방식" },
27
- { name: "aaguid", type: "string", nullable: true, readonly: true, desc: "AAGUID" },
28
- { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
19
+ { name: "id", type: "string", title: "ID" },
20
+ { name: "name", type: "string", nullable: true, title: "패스키 이름" },
21
+ { name: "public_key", type: "string", readonly: true, title: "공개키" },
22
+ { name: "credential_id", type: "string", readonly: true, title: "자격 증명 ID" },
23
+ { name: "counter", type: "integer", readonly: true, title: "카운터" },
24
+ { name: "device_type", type: "string", readonly: true, title: "장치 유형" },
25
+ { name: "backed_up", type: "boolean", readonly: true, title: "백업 여부" },
26
+ { name: "transports", type: "string", nullable: true, readonly: true, title: "전송 방식" },
27
+ { name: "aaguid", type: "string", nullable: true, readonly: true, title: "AAGUID" },
28
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "생성일시" },
29
29
  {
30
30
  type: "relation",
31
31
  name: "user",
@@ -33,7 +33,7 @@ export const passkeyEntityDef: BetterAuthEntityDef = {
33
33
  with: "User",
34
34
  relationType: "BelongsToOne",
35
35
  onDelete: "CASCADE",
36
- desc: "사용자",
36
+ title: "사용자",
37
37
  },
38
38
  ],
39
39
  indexes: [
@@ -18,14 +18,14 @@ export const phoneNumberEntityDef: BetterAuthEntityDef = {
18
18
  name: "phone_number",
19
19
  type: "string",
20
20
  nullable: true,
21
- desc: "전화번호",
21
+ title: "전화번호",
22
22
  },
23
23
  {
24
24
  name: "phone_number_verified",
25
25
  readonly: true,
26
26
  type: "boolean",
27
27
  nullable: true,
28
- desc: "전화번호 인증 여부",
28
+ title: "전화번호 인증 여부",
29
29
  },
30
30
  ],
31
31
  },
@@ -16,25 +16,25 @@ export const ssoEntityDef: BetterAuthEntityDef = {
16
16
  table: "sso_providers",
17
17
  title: "SSO 제공자",
18
18
  props: [
19
- { name: "id", type: "string", desc: "ID" },
20
- { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
21
- { name: "issuer", type: "string", readonly: true, desc: "발급자 URL" },
19
+ { name: "id", type: "string", title: "ID" },
20
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "생성일시" },
21
+ { name: "issuer", type: "string", readonly: true, title: "발급자 URL" },
22
22
  {
23
23
  name: "oidc_config",
24
24
  type: "string",
25
25
  nullable: true,
26
26
  readonly: true,
27
- desc: "OIDC 설정 (JSON)",
27
+ title: "OIDC 설정 (JSON)",
28
28
  },
29
29
  {
30
30
  name: "saml_config",
31
31
  type: "string",
32
32
  nullable: true,
33
33
  readonly: true,
34
- desc: "SAML 설정 (JSON)",
34
+ title: "SAML 설정 (JSON)",
35
35
  },
36
- { name: "provider_id", type: "string", readonly: true, desc: "제공자 ID" },
37
- { name: "domain", type: "string", nullable: true, readonly: true, desc: "도메인" },
36
+ { name: "provider_id", type: "string", readonly: true, title: "제공자 ID" },
37
+ { name: "domain", type: "string", nullable: true, readonly: true, title: "도메인" },
38
38
  {
39
39
  type: "relation",
40
40
  name: "user",
@@ -42,7 +42,7 @@ export const ssoEntityDef: BetterAuthEntityDef = {
42
42
  with: "User",
43
43
  relationType: "BelongsToOne",
44
44
  onDelete: "CASCADE",
45
- desc: "생성자",
45
+ title: "생성자",
46
46
  },
47
47
  ],
48
48
  indexes: [
@@ -16,32 +16,32 @@ export const twoFactorEntityDef: BetterAuthEntityDef = {
16
16
  table: "two_factors",
17
17
  title: "2FA 설정",
18
18
  props: [
19
- { name: "id", type: "string", desc: "ID" },
20
- { name: "secret", type: "string", readonly: true, desc: "비밀 키" },
21
- { name: "backup_codes", type: "string", readonly: true, desc: "백업 코드" },
19
+ { name: "id", type: "string", title: "ID" },
20
+ { name: "secret", type: "string", readonly: true, title: "비밀 키" },
21
+ { name: "backup_codes", type: "string", readonly: true, title: "백업 코드" },
22
22
  {
23
23
  name: "verified",
24
24
  type: "boolean",
25
25
  dbDefault: "true",
26
26
  readonly: true,
27
- desc: "TOTP 검증 여부",
27
+ title: "TOTP 검증 여부",
28
28
  },
29
29
  {
30
30
  name: "failed_verification_count",
31
31
  readonly: true,
32
32
  type: "integer",
33
33
  dbDefault: "0",
34
- desc: "연속 검증 실패 횟수",
34
+ title: "연속 검증 실패 횟수",
35
35
  },
36
36
  {
37
37
  name: "locked_until",
38
38
  type: "date",
39
39
  nullable: true,
40
40
  readonly: true,
41
- desc: "검증 잠금 해제 일시",
41
+ title: "검증 잠금 해제 일시",
42
42
  },
43
- { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
44
- { name: "updated_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "수정일시" },
43
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "생성일시" },
44
+ { name: "updated_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", title: "수정일시" },
45
45
  {
46
46
  type: "relation",
47
47
  name: "user",
@@ -49,7 +49,7 @@ export const twoFactorEntityDef: BetterAuthEntityDef = {
49
49
  with: "User",
50
50
  relationType: "BelongsToOne",
51
51
  onDelete: "CASCADE",
52
- desc: "사용자",
52
+ title: "사용자",
53
53
  },
54
54
  ],
55
55
  indexes: [{ type: "index", name: "two_factors_user_id_idx", columns: [{ name: "user_id" }] }],
@@ -70,7 +70,7 @@ export const twoFactorEntityDef: BetterAuthEntityDef = {
70
70
  readonly: true,
71
71
  type: "boolean",
72
72
  nullable: true,
73
- desc: "2FA 활성화 여부",
73
+ title: "2FA 활성화 여부",
74
74
  },
75
75
  ],
76
76
  },
@@ -18,13 +18,13 @@ export const usernameEntityDef: BetterAuthEntityDef = {
18
18
  name: "username",
19
19
  type: "string",
20
20
  nullable: true,
21
- desc: "사용자명 (정규화)",
21
+ title: "사용자명 (정규화)",
22
22
  },
23
23
  {
24
24
  name: "display_username",
25
25
  type: "string",
26
26
  nullable: true,
27
- desc: "표시용 사용자명",
27
+ title: "표시용 사용자명",
28
28
  },
29
29
  ],
30
30
  },
@@ -677,9 +677,9 @@ export class SonamuDictionary {
677
677
  }
678
678
 
679
679
  // entity.{EntityId}.{propName}
680
- const propDescMatch = key.match(/^entity\.([A-Z][a-zA-Z0-9]*)\.([a-z_][a-z0-9_]*)$/);
681
- if (propDescMatch) {
682
- return { type: "propDesc", entityId: propDescMatch[1], propName: propDescMatch[2] };
680
+ const propTitleMatch = key.match(/^entity\.([A-Z][a-zA-Z0-9]*)\.([a-z_][a-z0-9_]*)$/);
681
+ if (propTitleMatch) {
682
+ return { type: "propTitle", entityId: propTitleMatch[1], propName: propTitleMatch[2] };
683
683
  }
684
684
 
685
685
  // enum.{EnumId}.{value}
@@ -713,12 +713,12 @@ export class SonamuDictionary {
713
713
  return false;
714
714
  }
715
715
 
716
- case "propDesc": {
716
+ case "propTitle": {
717
717
  try {
718
718
  const entity = EntityManager.get(keyInfo.entityId);
719
719
  const propIndex = entity.props.findIndex((p) => p.name === keyInfo.propName);
720
- if (propIndex !== -1 && entity.props[propIndex].desc !== value) {
721
- entity.props[propIndex].desc = value;
720
+ if (propIndex !== -1 && entity.props[propIndex].title !== value) {
721
+ entity.props[propIndex].title = value;
722
722
  await entity.save();
723
723
  return true;
724
724
  }
package/src/dict/types.ts CHANGED
@@ -24,7 +24,7 @@ export type DictionaryRow = {
24
24
  */
25
25
  export type EntityKeyInfo =
26
26
  | { type: "entityTitle"; entityId: string }
27
- | { type: "propDesc"; entityId: string; propName: string }
27
+ | { type: "propTitle"; entityId: string; propName: string }
28
28
  | { type: "enumLabel"; enumId: string; enumValue: string }
29
29
  | { type: "other" };
30
30
 
@@ -28,10 +28,10 @@ function baseEntity(id = "SafetyTag"): EntityJson {
28
28
  title: "태그",
29
29
  table: "safety_tags",
30
30
  props: [
31
- { name: "id", type: "integer", desc: "ID" },
32
- { name: "name", type: "string", desc: "이름", length: 100 },
33
- { name: "kind", type: "enum", id: "SafetyTagKind", desc: "종류" },
34
- { name: "files", type: "json", id: "SonamuFile[]", desc: "파일" },
31
+ { name: "id", type: "integer", title: "ID" },
32
+ { name: "name", type: "string", title: "이름", length: 100 },
33
+ { name: "kind", type: "enum", id: "SafetyTagKind", title: "종류" },
34
+ { name: "files", type: "json", id: "SonamuFile[]", title: "파일" },
35
35
  ],
36
36
  indexes: [],
37
37
  subsets: { A: ["id", "name", "kind"] },
@@ -74,7 +74,7 @@ describe("assertEntityJsonCodegenSafe", () => {
74
74
 
75
75
  it("prop 이름에 따옴표·괄호가 들어가면 거부한다", () => {
76
76
  const json = baseEntity();
77
- json.props.push({ name: PROP_NAME_PAYLOAD, type: "string", desc: "x", nullable: true });
77
+ json.props.push({ name: PROP_NAME_PAYLOAD, type: "string", title: "x", nullable: true });
78
78
  expectRejected(json, "props.4.name");
79
79
  });
80
80
 
@@ -114,7 +114,7 @@ describe("assertEntityJsonCodegenSafe", () => {
114
114
  type: "relation",
115
115
  relationType: "BelongsToOne",
116
116
  with: "User\n evil()",
117
- desc: "소유자",
117
+ title: "소유자",
118
118
  }),
119
119
  "props.4.with",
120
120
  ],
@@ -127,7 +127,7 @@ describe("assertEntityJsonCodegenSafe", () => {
127
127
  relationType: "HasMany",
128
128
  with: "User",
129
129
  joinColumn: "tag_id",
130
- desc: "멤버",
130
+ title: "멤버",
131
131
  }) && Object.assign(json.props[4], { relationType: "HasMany\nevil()" }),
132
132
  "props.4.relationType",
133
133
  ],
@@ -164,7 +164,7 @@ describe("엔티티 쓰기·로드 경로의 강제 검증", () => {
164
164
 
165
165
  it("EntityManager.register는 prop 이름 주입을 거부하고 등록하지 않는다", async () => {
166
166
  const json = baseEntity("SafetyRegister");
167
- json.props.push({ name: PROP_NAME_PAYLOAD, type: "string", desc: "x" });
167
+ json.props.push({ name: PROP_NAME_PAYLOAD, type: "string", title: "x" });
168
168
 
169
169
  await expect(EntityManager.register(json)).rejects.toThrow("props.4.name");
170
170
  expect(EntityManager.exists("SafetyRegister")).toBe(false);
@@ -192,7 +192,7 @@ describe("엔티티 쓰기·로드 경로의 강제 검증", () => {
192
192
  EntityManager.get("SafetySaved").createProp({
193
193
  name: PROP_NAME_PAYLOAD,
194
194
  type: "string",
195
- desc: "x",
195
+ title: "x",
196
196
  nullable: true,
197
197
  }),
198
198
  ).rejects.toThrow("props.4.name");
@@ -283,8 +283,8 @@ describe("자유 문자열의 생성 코드 출력", () => {
283
283
  title: "소유자",
284
284
  table: "safety_owners",
285
285
  props: [
286
- { name: "id", type: "integer", desc: "ID" },
287
- { name: "name", type: "string", desc: "이름" },
286
+ { name: "id", type: "integer", title: "ID" },
287
+ { name: "name", type: "string", title: "이름" },
288
288
  ],
289
289
  indexes: [],
290
290
  subsets: {},
@@ -297,7 +297,7 @@ describe("자유 문자열의 생성 코드 출력", () => {
297
297
  relationType: "BelongsToOne",
298
298
  with: "SafetyOwner",
299
299
  customJoinClause: clause,
300
- desc: "소유자",
300
+ title: "소유자",
301
301
  });
302
302
  tagJson.subsets = { A: ["id", "owner.name"] };
303
303
  const owner = new Entity(ownerJson);
@@ -319,6 +319,38 @@ describe("자유 문자열의 생성 코드 출력", () => {
319
319
  statements.forEach(visit);
320
320
  expect(rawStrings).toEqual([clause]);
321
321
  });
322
+
323
+ it("서브셋 칸의 title·description은 메타 호출 인자의 문자열 리터럴로만 출력된다", () => {
324
+ const json = baseEntity();
325
+ Object.assign(json.props[1], { title: FREE_TEXT_PAYLOAD, description: "줄1\r줄2\u2028줄3\n" });
326
+ const entity = new Entity(json);
327
+ vi.spyOn(EntityManager, "get").mockReturnValue(entity);
328
+ const sourceCode = new Template__generated().getSubsetSourceCode(entity);
329
+
330
+ const statements = parseGenerated(sourceCode?.lines.join("\n") ?? "");
331
+ // 서브셋 A의 const·type, SubsetMapping, SubsetKey const·type 외에 주입된 문장이 없어야 한다.
332
+ expect(statements).toHaveLength(5);
333
+ const titles: string[] = [];
334
+ const descriptions: string[] = [];
335
+ const visit = (node: ts.Node) => {
336
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
337
+ const method = node.expression.name.text;
338
+ const [arg] = node.arguments;
339
+ if (method === "meta" && arg !== undefined && ts.isObjectLiteralExpression(arg)) {
340
+ for (const property of arg.properties) {
341
+ assert(ts.isPropertyAssignment(property) && ts.isIdentifier(property.name));
342
+ const key = property.name.text;
343
+ expect(["title", "description"]).toContain(key);
344
+ (key === "title" ? titles : descriptions).push(stringLiteralText(property.initializer));
345
+ }
346
+ }
347
+ }
348
+ ts.forEachChild(node, visit);
349
+ };
350
+ statements.forEach(visit);
351
+ expect(titles).toEqual(["ID", FREE_TEXT_PAYLOAD, "종류"]);
352
+ expect(descriptions).toEqual(["줄1\r줄2\u2028줄3\n"]);
353
+ });
322
354
  });
323
355
 
324
356
  function assert(condition: boolean): asserts condition {
@@ -8,16 +8,16 @@ const chatRoomJson: EntityJson = {
8
8
  id: "ChatRoom",
9
9
  table: "chat_rooms",
10
10
  props: [
11
- { name: "id", type: "integer", desc: "ID" },
12
- { name: "name", type: "string", desc: "이름" },
13
- { name: "case", type: "relation", relationType: "BelongsToOne", with: "Case", desc: "케이스" },
11
+ { name: "id", type: "integer", title: "ID" },
12
+ { name: "name", type: "string", title: "이름" },
13
+ { name: "case", type: "relation", relationType: "BelongsToOne", with: "Case", title: "케이스" },
14
14
  {
15
15
  name: "owned_cases",
16
16
  type: "relation",
17
17
  relationType: "HasMany",
18
18
  with: "Case",
19
19
  joinColumn: "owner_id",
20
- desc: "소유 케이스",
20
+ title: "소유 케이스",
21
21
  },
22
22
  ],
23
23
  indexes: [],
@@ -29,7 +29,7 @@ const caseJson: EntityJson = {
29
29
  id: "Case",
30
30
  table: "cases",
31
31
  props: [
32
- { name: "id", type: "integer", desc: "ID" },
32
+ { name: "id", type: "integer", title: "ID" },
33
33
  {
34
34
  name: "chat_room",
35
35
  type: "relation",
@@ -37,14 +37,14 @@ const caseJson: EntityJson = {
37
37
  with: "ChatRoom",
38
38
  hasJoinColumn: false,
39
39
  nullable: true,
40
- desc: "채팅방",
40
+ title: "채팅방",
41
41
  },
42
42
  {
43
43
  name: "owner",
44
44
  type: "relation",
45
45
  relationType: "BelongsToOne",
46
46
  with: "ChatRoom",
47
- desc: "소유 채팅방",
47
+ title: "소유 채팅방",
48
48
  },
49
49
  ],
50
50
  indexes: [],
@@ -116,3 +116,31 @@ describe("Entity.resolveSubsetQuery", () => {
116
116
  expect(caseEntity.getSubsetAutoInternalFields("A")).toEqual(["owner.id"]);
117
117
  });
118
118
  });
119
+
120
+ describe("Entity.fieldExprsToPropNodes", () => {
121
+ afterEach(() => {
122
+ vi.restoreAllMocks();
123
+ });
124
+
125
+ it("관계의 id만 고르면 FK 칸이 관계의 제목·설명을 이어받는다", () => {
126
+ const chatRoom = new Entity(chatRoomJson);
127
+ const caseEntity = new Entity({
128
+ ...caseJson,
129
+ props: caseJson.props.map((prop) =>
130
+ prop.name === "owner" ? { ...prop, description: "케이스를 가진 채팅방" } : prop,
131
+ ),
132
+ });
133
+ vi.spyOn(EntityManager, "get").mockImplementation((id: string) =>
134
+ id === "ChatRoom" ? chatRoom : caseEntity,
135
+ );
136
+
137
+ const [node] = caseEntity.fieldExprsToPropNodes(["owner.id"]);
138
+
139
+ expect(node?.prop).toMatchObject({
140
+ name: "owner_id",
141
+ type: "integer",
142
+ title: "소유 채팅방",
143
+ description: "케이스를 가진 채팅방",
144
+ });
145
+ });
146
+ });
@@ -42,7 +42,8 @@ const EnumValuesSchema = z.record(z.string(), z.string());
42
42
  const CodegenSafePropSchema = z.looseObject({
43
43
  name: identifier("prop 이름"),
44
44
  type: z.string(),
45
- desc: z.string().optional(),
45
+ title: z.string().optional(),
46
+ description: z.string().optional(),
46
47
  id: patterned(TYPE_REFERENCE_PATTERN, "prop id").optional(),
47
48
  with: identifier("relation 대상 entity id").optional(),
48
49
  relationType: identifier("relationType").optional(),
@@ -773,6 +773,7 @@ export class Entity {
773
773
  (groupedFieldExprs[0] === "id" || groupedFieldExprs[0] === "id?")
774
774
  ) {
775
775
  // id 하나만 있는지 체크해서, 하나만 있으면 상위 prop으로 id를 리턴
776
+ // 타입은 대상 엔티티의 id를 따르되, 이름·제목·설명은 이 칸이 가리키는 관계의 것을 씁니다.
776
777
  const idProp = relEntity.propsDict.id;
777
778
  return {
778
779
  nodeType: "plain" as const,
@@ -780,6 +781,8 @@ export class Entity {
780
781
  ...idProp,
781
782
  name: `${key}_id`,
782
783
  nullable: prop.nullable,
784
+ title: prop.title,
785
+ description: prop.description,
783
786
  },
784
787
  };
785
788
  }
@@ -341,8 +341,7 @@ export const SQLDateTimeString = z
341
341
  message: "잘못된 SQLDate 타입",
342
342
  })
343
343
  .min(10)
344
- .max(19)
345
- .describe("SQLDateTimeString");
344
+ .max(19);
346
345
  export type SQLDateTimeString = z.infer<typeof SQLDateTimeString>;
347
346
 
348
347
  /*
@@ -289,8 +289,7 @@ export const SQLDateTimeString = z
289
289
  message: "잘못된 SQLDate 타입",
290
290
  })
291
291
  .min(10)
292
- .max(19)
293
- .describe("SQLDateTimeString");
292
+ .max(19);
294
293
  export type SQLDateTimeString = z.infer<typeof SQLDateTimeString>;
295
294
 
296
295
  /**
@@ -25,8 +25,8 @@ export function getLabel(entityId: string, enumId: string): string {
25
25
  const enumProp = EntityManager.get(entityId).props.find(
26
26
  (prop) => `${entityId}${inflection.camelize(prop.name)}` === enumId,
27
27
  );
28
- if (enumProp?.desc) {
29
- return enumProp.desc;
28
+ if (enumProp?.title) {
29
+ return enumProp.title;
30
30
  }
31
31
  return enumId;
32
32
  }
@@ -44,7 +44,7 @@ export function getEnumInfoFromColName(entityId: string, colName: string): EnumC
44
44
  id: prop.id,
45
45
  targetEntityId: entityId,
46
46
  targetEntityNames: EntityManager.getNamesFromId(entityId),
47
- title: prop.desc ?? prop.id,
47
+ title: prop.title ?? prop.id,
48
48
  };
49
49
  } else {
50
50
  const idCandidate = inflection.camelize(