sonamu 0.7.53 → 0.8.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 (271) hide show
  1. package/dist/api/config.d.ts +9 -1
  2. package/dist/api/config.d.ts.map +1 -1
  3. package/dist/api/config.js +1 -1
  4. package/dist/api/sonamu.d.ts +21 -1
  5. package/dist/api/sonamu.d.ts.map +1 -1
  6. package/dist/api/sonamu.js +159 -65
  7. package/dist/auth/plugins/entity-definitions/anonymous.d.ts +10 -0
  8. package/dist/auth/plugins/entity-definitions/anonymous.d.ts.map +1 -0
  9. package/dist/auth/plugins/entity-definitions/anonymous.js +23 -0
  10. package/dist/auth/plugins/entity-definitions/api-key.d.ts +9 -0
  11. package/dist/auth/plugins/entity-definitions/api-key.d.ts.map +1 -0
  12. package/dist/auth/plugins/entity-definitions/api-key.js +199 -0
  13. package/dist/auth/plugins/entity-definitions/index.d.ts +6 -0
  14. package/dist/auth/plugins/entity-definitions/index.d.ts.map +1 -1
  15. package/dist/auth/plugins/entity-definitions/index.js +20 -2
  16. package/dist/auth/plugins/entity-definitions/jwt.d.ts +9 -0
  17. package/dist/auth/plugins/entity-definitions/jwt.d.ts.map +1 -0
  18. package/dist/auth/plugins/entity-definitions/jwt.js +67 -0
  19. package/dist/auth/plugins/entity-definitions/organization.d.ts +9 -0
  20. package/dist/auth/plugins/entity-definitions/organization.d.ts.map +1 -0
  21. package/dist/auth/plugins/entity-definitions/organization.js +424 -0
  22. package/dist/auth/plugins/entity-definitions/passkey.d.ts +10 -0
  23. package/dist/auth/plugins/entity-definitions/passkey.d.ts.map +1 -0
  24. package/dist/auth/plugins/entity-definitions/passkey.js +129 -0
  25. package/dist/auth/plugins/entity-definitions/sso.d.ts +10 -0
  26. package/dist/auth/plugins/entity-definitions/sso.d.ts.map +1 -0
  27. package/dist/auth/plugins/entity-definitions/sso.js +110 -0
  28. package/dist/auth/plugins/entity-definitions/types.d.ts +1 -1
  29. package/dist/auth/plugins/entity-definitions/types.d.ts.map +1 -1
  30. package/dist/auth/plugins/entity-definitions/types.js +1 -1
  31. package/dist/auth/plugins/wrappers/admin.d.ts.map +1 -1
  32. package/dist/auth/plugins/wrappers/admin.js +2 -4
  33. package/dist/auth/plugins/wrappers/anonymous.d.ts +18 -0
  34. package/dist/auth/plugins/wrappers/anonymous.d.ts.map +1 -0
  35. package/dist/auth/plugins/wrappers/anonymous.js +26 -0
  36. package/dist/auth/plugins/wrappers/api-key.d.ts +18 -0
  37. package/dist/auth/plugins/wrappers/api-key.d.ts.map +1 -0
  38. package/dist/auth/plugins/wrappers/api-key.js +38 -0
  39. package/dist/auth/plugins/wrappers/index.d.ts +6 -0
  40. package/dist/auth/plugins/wrappers/index.d.ts.map +1 -1
  41. package/dist/auth/plugins/wrappers/index.js +7 -1
  42. package/dist/auth/plugins/wrappers/jwt.d.ts +18 -0
  43. package/dist/auth/plugins/wrappers/jwt.d.ts.map +1 -0
  44. package/dist/auth/plugins/wrappers/jwt.js +30 -0
  45. package/dist/auth/plugins/wrappers/organization.d.ts +18 -0
  46. package/dist/auth/plugins/wrappers/organization.d.ts.map +1 -0
  47. package/dist/auth/plugins/wrappers/organization.js +67 -0
  48. package/dist/auth/plugins/wrappers/passkey.d.ts +18 -0
  49. package/dist/auth/plugins/wrappers/passkey.d.ts.map +1 -0
  50. package/dist/auth/plugins/wrappers/passkey.js +32 -0
  51. package/dist/auth/plugins/wrappers/phone-number.d.ts.map +1 -1
  52. package/dist/auth/plugins/wrappers/phone-number.js +2 -4
  53. package/dist/auth/plugins/wrappers/sso.d.ts +853 -0
  54. package/dist/auth/plugins/wrappers/sso.d.ts.map +1 -0
  55. package/dist/auth/plugins/wrappers/sso.js +36 -0
  56. package/dist/auth/plugins/wrappers/two-factor.d.ts.map +1 -1
  57. package/dist/auth/plugins/wrappers/two-factor.js +2 -4
  58. package/dist/auth/plugins/wrappers/username.d.ts.map +1 -1
  59. package/dist/auth/plugins/wrappers/username.js +2 -4
  60. package/dist/bin/build-config.d.ts +2 -2
  61. package/dist/bin/build-config.js +6 -7
  62. package/dist/bin/cli.js +417 -32
  63. package/dist/bin/fixture.d.ts +27 -0
  64. package/dist/bin/fixture.d.ts.map +1 -0
  65. package/dist/bin/fixture.js +245 -0
  66. package/dist/cache/decorator.d.ts +4 -3
  67. package/dist/cache/decorator.d.ts.map +1 -1
  68. package/dist/cache/decorator.js +5 -4
  69. package/dist/cone/cone-generator.d.ts +33 -0
  70. package/dist/cone/cone-generator.d.ts.map +1 -0
  71. package/dist/cone/cone-generator.js +286 -0
  72. package/dist/database/_batch_update.d.ts.map +1 -1
  73. package/dist/database/_batch_update.js +16 -2
  74. package/dist/database/puri-subset.test-d.js +1 -1
  75. package/dist/database/puri-subset.types.d.ts +1 -1
  76. package/dist/database/puri-subset.types.d.ts.map +1 -1
  77. package/dist/database/puri-subset.types.js +1 -1
  78. package/dist/database/puri.d.ts +4 -0
  79. package/dist/database/puri.d.ts.map +1 -1
  80. package/dist/database/puri.js +20 -2
  81. package/dist/database/upsert-builder.d.ts.map +1 -1
  82. package/dist/database/upsert-builder.js +19 -3
  83. package/dist/dict/en.d.ts +15 -0
  84. package/dist/dict/en.d.ts.map +1 -1
  85. package/dist/dict/en.js +2 -1
  86. package/dist/dict/ko.d.ts +15 -0
  87. package/dist/dict/ko.d.ts.map +1 -1
  88. package/dist/dict/ko.js +2 -1
  89. package/dist/dict/rc-keys.d.ts +28 -0
  90. package/dist/dict/rc-keys.d.ts.map +1 -1
  91. package/dist/dict/rc-keys.js +31 -1
  92. package/dist/dict/sd.d.ts.map +1 -1
  93. package/dist/dict/sd.js +20 -4
  94. package/dist/entity/entity-manager.d.ts +298 -2
  95. package/dist/entity/entity-manager.d.ts.map +1 -1
  96. package/dist/entity/entity-manager.js +4 -1
  97. package/dist/entity/entity-template-cone.d.ts +14 -0
  98. package/dist/entity/entity-template-cone.d.ts.map +1 -0
  99. package/dist/entity/entity-template-cone.js +222 -0
  100. package/dist/entity/entity.d.ts +47 -2
  101. package/dist/entity/entity.d.ts.map +1 -1
  102. package/dist/entity/entity.js +161 -14
  103. package/dist/ssr/renderer.js +3 -3
  104. package/dist/syncer/api-parser.js +12 -1
  105. package/dist/syncer/checksum.d.ts +0 -14
  106. package/dist/syncer/checksum.d.ts.map +1 -1
  107. package/dist/syncer/checksum.js +1 -23
  108. package/dist/syncer/syncer-actions.d.ts.map +1 -1
  109. package/dist/syncer/syncer-actions.js +8 -2
  110. package/dist/syncer/syncer.d.ts +1 -1
  111. package/dist/syncer/syncer.d.ts.map +1 -1
  112. package/dist/syncer/syncer.js +17 -10
  113. package/dist/tasks/workflow-manager.d.ts +13 -1
  114. package/dist/tasks/workflow-manager.d.ts.map +1 -1
  115. package/dist/tasks/workflow-manager.js +18 -1
  116. package/dist/template/entity-converter.js +4 -4
  117. package/dist/template/helpers.d.ts +10 -0
  118. package/dist/template/helpers.d.ts.map +1 -1
  119. package/dist/template/helpers.js +48 -1
  120. package/dist/template/implementations/entry-server.template.d.ts +1 -1
  121. package/dist/template/implementations/entry-server.template.js +7 -2
  122. package/dist/template/implementations/generated.template.d.ts.map +1 -1
  123. package/dist/template/implementations/generated.template.js +5 -1
  124. package/dist/template/implementations/generated_http.template.d.ts +1 -0
  125. package/dist/template/implementations/generated_http.template.d.ts.map +1 -1
  126. package/dist/template/implementations/generated_http.template.js +6 -2
  127. package/dist/template/implementations/generated_sso.template.d.ts.map +1 -1
  128. package/dist/template/implementations/generated_sso.template.js +29 -8
  129. package/dist/template/implementations/queries.template.d.ts.map +1 -1
  130. package/dist/template/implementations/queries.template.js +9 -1
  131. package/dist/template/implementations/sd.template.d.ts +1 -1
  132. package/dist/template/implementations/sd.template.d.ts.map +1 -1
  133. package/dist/template/implementations/sd.template.js +28 -4
  134. package/dist/template/implementations/services.template.d.ts.map +1 -1
  135. package/dist/template/implementations/services.template.js +12 -12
  136. package/dist/template/implementations/view_form.template.d.ts +11 -7
  137. package/dist/template/implementations/view_form.template.d.ts.map +1 -1
  138. package/dist/template/implementations/view_form.template.js +97 -87
  139. package/dist/template/implementations/view_list.template.d.ts +3 -3
  140. package/dist/template/implementations/view_list.template.d.ts.map +1 -1
  141. package/dist/template/implementations/view_list.template.js +115 -109
  142. package/dist/template/implementations/view_search_input.template.d.ts.map +1 -1
  143. package/dist/template/implementations/view_search_input.template.js +18 -14
  144. package/dist/template/zod-converter.d.ts.map +1 -1
  145. package/dist/template/zod-converter.js +95 -7
  146. package/dist/testing/_relation-graph.js +1 -1
  147. package/dist/testing/data-explorer.d.ts +61 -0
  148. package/dist/testing/data-explorer.d.ts.map +1 -0
  149. package/dist/testing/data-explorer.js +274 -0
  150. package/dist/testing/faker-mappings.d.ts +20 -0
  151. package/dist/testing/faker-mappings.d.ts.map +1 -0
  152. package/dist/testing/faker-mappings.js +421 -0
  153. package/dist/testing/fixture-generator.d.ts +161 -0
  154. package/dist/testing/fixture-generator.d.ts.map +1 -0
  155. package/dist/testing/fixture-generator.js +954 -0
  156. package/dist/testing/fixture-manager.d.ts +6 -1
  157. package/dist/testing/fixture-manager.d.ts.map +1 -1
  158. package/dist/testing/fixture-manager.js +72 -4
  159. package/dist/testing/index.d.ts +3 -0
  160. package/dist/testing/index.d.ts.map +1 -1
  161. package/dist/testing/index.js +4 -1
  162. package/dist/types/types.d.ts +1520 -26
  163. package/dist/types/types.d.ts.map +1 -1
  164. package/dist/types/types.js +136 -22
  165. package/dist/ui/ai-client.d.ts.map +1 -1
  166. package/dist/ui/ai-client.js +9 -4
  167. package/dist/ui/api.d.ts.map +1 -1
  168. package/dist/ui/api.js +303 -24
  169. package/dist/ui-web/assets/index-CsUr-_pV.js +254 -0
  170. package/dist/ui-web/assets/index-T42zzs1K.css +1 -0
  171. package/dist/ui-web/index.html +2 -2
  172. package/dist/utils/fs-utils.d.ts +2 -1
  173. package/dist/utils/fs-utils.d.ts.map +1 -1
  174. package/dist/utils/fs-utils.js +14 -3
  175. package/package.json +19 -11
  176. package/src/api/config.ts +12 -1
  177. package/src/api/sonamu.ts +179 -65
  178. package/src/auth/plugins/entity-definitions/anonymous.ts +17 -0
  179. package/src/auth/plugins/entity-definitions/api-key.ts +93 -0
  180. package/src/auth/plugins/entity-definitions/index.ts +18 -0
  181. package/src/auth/plugins/entity-definitions/jwt.ts +35 -0
  182. package/src/auth/plugins/entity-definitions/organization.ts +215 -0
  183. package/src/auth/plugins/entity-definitions/passkey.ts +64 -0
  184. package/src/auth/plugins/entity-definitions/sso.ts +62 -0
  185. package/src/auth/plugins/entity-definitions/types.ts +11 -1
  186. package/src/auth/plugins/wrappers/admin.ts +1 -3
  187. package/src/auth/plugins/wrappers/anonymous.ts +30 -0
  188. package/src/auth/plugins/wrappers/api-key.ts +42 -0
  189. package/src/auth/plugins/wrappers/index.ts +6 -0
  190. package/src/auth/plugins/wrappers/jwt.ts +34 -0
  191. package/src/auth/plugins/wrappers/organization.ts +73 -0
  192. package/src/auth/plugins/wrappers/passkey.ts +36 -0
  193. package/src/auth/plugins/wrappers/phone-number.ts +1 -3
  194. package/src/auth/plugins/wrappers/sso.ts +40 -0
  195. package/src/auth/plugins/wrappers/two-factor.ts +1 -3
  196. package/src/auth/plugins/wrappers/username.ts +1 -3
  197. package/src/bin/build-config.ts +6 -6
  198. package/src/bin/cli.ts +452 -31
  199. package/src/bin/fixture.ts +302 -0
  200. package/src/cache/decorator.ts +4 -3
  201. package/src/cone/cone-generator.ts +363 -0
  202. package/src/database/_batch_update.ts +11 -0
  203. package/src/database/puri-subset.test-d.ts +13 -13
  204. package/src/database/puri-subset.types.ts +1 -1
  205. package/src/database/puri.ts +43 -1
  206. package/src/database/upsert-builder.ts +16 -2
  207. package/src/dict/en.ts +1 -0
  208. package/src/dict/ko.ts +1 -0
  209. package/src/dict/rc-keys.ts +32 -0
  210. package/src/dict/sd.ts +23 -3
  211. package/src/entity/entity-manager.ts +4 -0
  212. package/src/entity/entity-template-cone.ts +298 -0
  213. package/src/entity/entity.ts +189 -13
  214. package/src/shared/app.shared.ts.txt +5 -0
  215. package/src/shared/web.shared.ts.txt +9 -5
  216. package/src/skills/project/README.md +21 -0
  217. package/src/skills/project/architecture.md +373 -0
  218. package/src/skills/project/business-logic.md +270 -0
  219. package/src/skills/project/requirements.md +160 -0
  220. package/src/skills/sonamu/SKILL.md +168 -3
  221. package/src/skills/sonamu/api.md +102 -0
  222. package/src/skills/sonamu/database.md +220 -1
  223. package/src/skills/sonamu/entity-relations.md +89 -1
  224. package/src/skills/sonamu/fixture-cli.md +501 -0
  225. package/src/skills/sonamu/frontend.md +214 -0
  226. package/src/skills/sonamu/i18n.md +95 -0
  227. package/src/skills/sonamu/model.md +153 -0
  228. package/src/skills/sonamu/project-init.md +178 -8
  229. package/src/skills/sonamu/scaffolding.md +112 -0
  230. package/src/skills/sonamu/subset.md +9 -3
  231. package/src/skills/sonamu/testing.md +287 -2
  232. package/src/skills/sonamu/workflow.md +70 -5
  233. package/src/ssr/renderer.ts +2 -2
  234. package/src/syncer/api-parser.ts +12 -0
  235. package/src/syncer/checksum.ts +0 -38
  236. package/src/syncer/syncer-actions.ts +7 -1
  237. package/src/syncer/syncer.ts +16 -5
  238. package/src/tasks/workflow-manager.ts +29 -8
  239. package/src/template/entity-converter.ts +3 -3
  240. package/src/template/helpers.ts +49 -0
  241. package/src/template/implementations/entry-server.template.ts +1 -1
  242. package/src/template/implementations/generated.template.ts +4 -0
  243. package/src/template/implementations/generated_http.template.ts +1 -0
  244. package/src/template/implementations/generated_sso.template.ts +40 -11
  245. package/src/template/implementations/queries.template.ts +8 -0
  246. package/src/template/implementations/sd.template.ts +22 -3
  247. package/src/template/implementations/services.template.ts +11 -10
  248. package/src/template/implementations/view_form.template.ts +111 -101
  249. package/src/template/implementations/view_list.template.ts +120 -119
  250. package/src/template/implementations/view_search_input.template.ts +17 -13
  251. package/src/template/zod-converter.ts +103 -6
  252. package/src/testing/_relation-graph.ts +1 -1
  253. package/src/testing/data-explorer.ts +427 -0
  254. package/src/testing/faker-mappings.ts +434 -0
  255. package/src/testing/fixture-generator.ts +1166 -0
  256. package/src/testing/fixture-manager.ts +91 -6
  257. package/src/testing/index.ts +3 -0
  258. package/src/types/types.ts +222 -26
  259. package/src/ui/ai-client.ts +9 -1
  260. package/src/ui/api.ts +429 -23
  261. package/src/utils/fs-utils.ts +14 -1
  262. package/dist/template/implementations/view_enums_select.template.d.ts +0 -17
  263. package/dist/template/implementations/view_enums_select.template.d.ts.map +0 -1
  264. package/dist/template/implementations/view_enums_select.template.js +0 -62
  265. package/dist/template/implementations/view_id_async_select.template.d.ts +0 -17
  266. package/dist/template/implementations/view_id_async_select.template.d.ts.map +0 -1
  267. package/dist/template/implementations/view_id_async_select.template.js +0 -125
  268. package/dist/ui-web/assets/index-Bd_2AkLb.css +0 -1
  269. package/dist/ui-web/assets/index-BpSbhQWo.js +0 -225
  270. package/src/template/implementations/view_enums_select.template.ts +0 -65
  271. package/src/template/implementations/view_id_async_select.template.ts +0 -139
@@ -0,0 +1,215 @@
1
+ import type { BetterAuthEntityDef } from "./types";
2
+
3
+ /**
4
+ * better-auth Organization 플러그인 엔티티 정의
5
+ * https://www.better-auth.com/docs/plugins/organization
6
+ *
7
+ * 조직, 멤버, 초대, 팀 관리를 지원합니다.
8
+ */
9
+ export const organizationEntityDef: BetterAuthEntityDef = {
10
+ id: "organization",
11
+ name: "Organization",
12
+ // 엔티티 순서: 의존관계에 따라 정렬 (Organization → Team → Member → Invitation → TeamMember)
13
+ entities: [
14
+ {
15
+ id: "Organization",
16
+ table: "organizations",
17
+ title: "조직",
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: "생성일시" },
25
+ ],
26
+ indexes: [{ type: "unique", name: "organizations_slug_unique", columns: [{ name: "slug" }] }],
27
+ subsets: {
28
+ A: ["id", "name", "slug", "logo", "metadata", "created_at"],
29
+ },
30
+ enums: {
31
+ OrganizationOrderBy: { "id-desc": "ID최신순", "created_at-desc": "생성일최신순" },
32
+ OrganizationSearchField: { id: "ID", name: "조직명", slug: "슬러그" },
33
+ },
34
+ },
35
+ {
36
+ id: "Team",
37
+ table: "teams",
38
+ title: "팀",
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: "수정일시" },
44
+ {
45
+ type: "relation",
46
+ name: "organization",
47
+ with: "Organization",
48
+ relationType: "BelongsToOne",
49
+ onDelete: "CASCADE",
50
+ desc: "조직",
51
+ },
52
+ ],
53
+ indexes: [
54
+ {
55
+ type: "index",
56
+ name: "teams_organization_id_idx",
57
+ columns: [{ name: "organization_id" }],
58
+ },
59
+ ],
60
+ subsets: {
61
+ A: ["id", "name", "created_at", "updated_at", "organization.id"],
62
+ },
63
+ enums: {
64
+ TeamOrderBy: { "id-desc": "ID최신순", "created_at-desc": "생성일최신순" },
65
+ TeamSearchField: { id: "ID", name: "팀명" },
66
+ },
67
+ },
68
+ {
69
+ id: "Member",
70
+ table: "members",
71
+ title: "멤버",
72
+ props: [
73
+ { name: "id", type: "string", desc: "ID" },
74
+ { name: "role", type: "string", desc: "역할" },
75
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
76
+ {
77
+ type: "relation",
78
+ name: "user",
79
+ with: "User",
80
+ relationType: "BelongsToOne",
81
+ onDelete: "CASCADE",
82
+ desc: "사용자",
83
+ },
84
+ {
85
+ type: "relation",
86
+ name: "organization",
87
+ with: "Organization",
88
+ relationType: "BelongsToOne",
89
+ onDelete: "CASCADE",
90
+ desc: "조직",
91
+ },
92
+ ],
93
+ indexes: [
94
+ { type: "index", name: "members_user_id_idx", columns: [{ name: "user_id" }] },
95
+ {
96
+ type: "index",
97
+ name: "members_organization_id_idx",
98
+ columns: [{ name: "organization_id" }],
99
+ },
100
+ ],
101
+ subsets: {
102
+ A: ["id", "role", "created_at", "user.id", "organization.id"],
103
+ },
104
+ enums: {
105
+ MemberOrderBy: { "id-desc": "ID최신순", "created_at-desc": "생성일최신순" },
106
+ MemberSearchField: { id: "ID", role: "역할" },
107
+ },
108
+ },
109
+ {
110
+ id: "Invitation",
111
+ table: "invitations",
112
+ title: "초대",
113
+ props: [
114
+ { name: "id", type: "string", desc: "ID" },
115
+ { name: "email", type: "string", desc: "이메일" },
116
+ { name: "role", type: "string", desc: "역할" },
117
+ { name: "status", type: "string", desc: "상태" },
118
+ { name: "expires_at", type: "date", desc: "만료일시" },
119
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
120
+ {
121
+ type: "relation",
122
+ name: "inviter",
123
+ with: "User",
124
+ relationType: "BelongsToOne",
125
+ onDelete: "CASCADE",
126
+ desc: "초대자",
127
+ },
128
+ {
129
+ type: "relation",
130
+ name: "organization",
131
+ with: "Organization",
132
+ relationType: "BelongsToOne",
133
+ onDelete: "CASCADE",
134
+ desc: "조직",
135
+ },
136
+ {
137
+ type: "relation",
138
+ name: "team",
139
+ with: "Team",
140
+ relationType: "BelongsToOne",
141
+ onDelete: "SET NULL",
142
+ nullable: true,
143
+ desc: "팀",
144
+ },
145
+ ],
146
+ indexes: [
147
+ { type: "index", name: "invitations_email_idx", columns: [{ name: "email" }] },
148
+ {
149
+ type: "index",
150
+ name: "invitations_organization_id_idx",
151
+ columns: [{ name: "organization_id" }],
152
+ },
153
+ ],
154
+ subsets: {
155
+ A: [
156
+ "id",
157
+ "email",
158
+ "role",
159
+ "status",
160
+ "expires_at",
161
+ "created_at",
162
+ "inviter.id",
163
+ "organization.id",
164
+ "team.id",
165
+ ],
166
+ },
167
+ enums: {
168
+ InvitationOrderBy: { "id-desc": "ID최신순", "created_at-desc": "생성일최신순" },
169
+ InvitationSearchField: { id: "ID", email: "이메일" },
170
+ },
171
+ },
172
+ {
173
+ id: "TeamMember",
174
+ table: "team_members",
175
+ title: "팀멤버",
176
+ props: [
177
+ { name: "id", type: "string", desc: "ID" },
178
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
179
+ {
180
+ type: "relation",
181
+ name: "team",
182
+ with: "Team",
183
+ relationType: "BelongsToOne",
184
+ onDelete: "CASCADE",
185
+ desc: "팀",
186
+ },
187
+ {
188
+ type: "relation",
189
+ name: "user",
190
+ with: "User",
191
+ relationType: "BelongsToOne",
192
+ onDelete: "CASCADE",
193
+ desc: "사용자",
194
+ },
195
+ ],
196
+ indexes: [
197
+ { type: "index", name: "team_members_team_id_idx", columns: [{ name: "team_id" }] },
198
+ { type: "index", name: "team_members_user_id_idx", columns: [{ name: "user_id" }] },
199
+ ],
200
+ subsets: {
201
+ A: ["id", "created_at", "team.id", "user.id"],
202
+ },
203
+ enums: {
204
+ TeamMemberOrderBy: { "id-desc": "ID최신순", "created_at-desc": "생성일최신순" },
205
+ TeamMemberSearchField: { id: "ID" },
206
+ },
207
+ },
208
+ ],
209
+ additionalProps: {
210
+ Session: [
211
+ { name: "active_organization_id", type: "string", nullable: true, desc: "활성 조직 ID" },
212
+ { name: "active_team_id", type: "string", nullable: true, desc: "활성 팀 ID" },
213
+ ],
214
+ },
215
+ };
@@ -0,0 +1,64 @@
1
+ import type { BetterAuthEntityDef } from "./types";
2
+
3
+ /**
4
+ * better-auth Passkey 플러그인 엔티티 정의
5
+ * https://www.better-auth.com/docs/plugins/passkey
6
+ *
7
+ * WebAuthn/FIDO2 기반 패스키 인증을 지원합니다.
8
+ * Passkey 테이블을 생성하여 사용자의 패스키 정보를 저장합니다.
9
+ */
10
+ export const passkeyEntityDef: BetterAuthEntityDef = {
11
+ id: "passkey",
12
+ name: "Passkey",
13
+ entities: [
14
+ {
15
+ id: "Passkey",
16
+ table: "passkeys",
17
+ title: "패스키",
18
+ props: [
19
+ { name: "id", type: "string", desc: "ID" },
20
+ { name: "name", type: "string", nullable: true, desc: "패스키 이름" },
21
+ { name: "public_key", type: "string", desc: "공개키" },
22
+ { name: "credential_id", type: "string", desc: "자격 증명 ID" },
23
+ { name: "counter", type: "integer", desc: "카운터" },
24
+ { name: "device_type", type: "string", desc: "장치 유형" },
25
+ { name: "backed_up", type: "boolean", desc: "백업 여부" },
26
+ { name: "transports", type: "string", nullable: true, desc: "전송 방식" },
27
+ { name: "aaguid", type: "string", nullable: true, desc: "AAGUID" },
28
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
29
+ {
30
+ type: "relation",
31
+ name: "user",
32
+ with: "User",
33
+ relationType: "BelongsToOne",
34
+ onDelete: "CASCADE",
35
+ desc: "사용자",
36
+ },
37
+ ],
38
+ indexes: [
39
+ { type: "index", name: "passkeys_user_id_idx", columns: [{ name: "user_id" }] },
40
+ { type: "index", name: "passkeys_credential_id_idx", columns: [{ name: "credential_id" }] },
41
+ ],
42
+ subsets: {
43
+ A: [
44
+ "id",
45
+ "name",
46
+ "public_key",
47
+ "credential_id",
48
+ "counter",
49
+ "device_type",
50
+ "backed_up",
51
+ "transports",
52
+ "aaguid",
53
+ "created_at",
54
+ "user.id",
55
+ ],
56
+ },
57
+ enums: {
58
+ PasskeyOrderBy: { "id-desc": "ID최신순", "created_at-desc": "생성일최신순" },
59
+ PasskeySearchField: { id: "ID", name: "이름" },
60
+ },
61
+ },
62
+ ],
63
+ additionalProps: {},
64
+ };
@@ -0,0 +1,62 @@
1
+ import type { BetterAuthEntityDef } from "./types";
2
+
3
+ /**
4
+ * better-auth SSO 플러그인 엔티티 정의
5
+ * https://www.better-auth.com/docs/plugins/sso
6
+ *
7
+ * 외부 IdP(OIDC, SAML)를 통한 SSO 로그인을 지원합니다.
8
+ * SsoProvider 테이블을 생성하여 SSO 제공자 설정을 저장합니다.
9
+ */
10
+ export const ssoEntityDef: BetterAuthEntityDef = {
11
+ id: "sso",
12
+ name: "SSO",
13
+ entities: [
14
+ {
15
+ id: "SsoProvider",
16
+ table: "sso_providers",
17
+ title: "SSO 제공자",
18
+ props: [
19
+ { name: "id", type: "string", desc: "ID" },
20
+ { name: "created_at", type: "date", dbDefault: "CURRENT_TIMESTAMP", desc: "생성일시" },
21
+ { name: "issuer", type: "string", desc: "발급자 URL" },
22
+ { name: "oidc_config", type: "string", nullable: true, desc: "OIDC 설정 (JSON)" },
23
+ { name: "saml_config", type: "string", nullable: true, desc: "SAML 설정 (JSON)" },
24
+ { name: "provider_id", type: "string", desc: "제공자 ID" },
25
+ { name: "domain", type: "string", nullable: true, desc: "도메인" },
26
+ {
27
+ type: "relation",
28
+ name: "user",
29
+ with: "User",
30
+ relationType: "BelongsToOne",
31
+ onDelete: "CASCADE",
32
+ desc: "생성자",
33
+ },
34
+ ],
35
+ indexes: [
36
+ {
37
+ type: "unique",
38
+ name: "sso_providers_provider_id_unique",
39
+ columns: [{ name: "provider_id" }],
40
+ },
41
+ { type: "index", name: "sso_providers_user_id_idx", columns: [{ name: "user_id" }] },
42
+ ],
43
+ subsets: {
44
+ A: [
45
+ "id",
46
+ "issuer",
47
+ "oidc_config",
48
+ "saml_config",
49
+ "provider_id",
50
+ "domain",
51
+ "created_at",
52
+ "user.id",
53
+ ],
54
+ },
55
+ enums: {
56
+ SsoProviderOrderBy: { "id-desc": "ID최신순" },
57
+ SsoProviderSearchField: { id: "ID", provider_id: "제공자ID" },
58
+ },
59
+ },
60
+ ],
61
+ additionalProps: {},
62
+ };
@@ -4,7 +4,17 @@ import type { EntityIndex, EntityJson, EntityProp } from "../../../types/types";
4
4
  * better-auth 플러그인 ID
5
5
  * 지원하는 플러그인 목록을 정의합니다.
6
6
  */
7
- export type BetterAuthPluginId = "phone-number" | "2fa" | "username" | "admin";
7
+ export type BetterAuthPluginId =
8
+ | "phone-number"
9
+ | "2fa"
10
+ | "username"
11
+ | "admin"
12
+ | "sso"
13
+ | "passkey"
14
+ | "organization"
15
+ | "api-key"
16
+ | "jwt"
17
+ | "anonymous";
8
18
 
9
19
  /**
10
20
  * better-auth 엔티티 정의
@@ -33,8 +33,6 @@ export const ADMIN_SCHEMA: AdminOptions["schema"] = {
33
33
  * Sonamu의 스키마 매핑을 자동으로 병합합니다.
34
34
  */
35
35
  export const admin = (options: AdminOptions = {}) => {
36
- if (options.schema) {
37
- options.schema = merge(ADMIN_SCHEMA, options.schema);
38
- }
36
+ options.schema = merge(ADMIN_SCHEMA, options.schema ?? {});
39
37
  return _admin(options);
40
38
  };
@@ -0,0 +1,30 @@
1
+ import { anonymous as _anonymous, type AnonymousOptions } from "better-auth/plugins";
2
+ import { merge } from "../../../utils/utils";
3
+
4
+ export type { AnonymousOptions } from "better-auth/plugins";
5
+
6
+ /**
7
+ * Anonymous 플러그인 스키마
8
+ *
9
+ * better-auth anonymous 플러그인 호출 시 전달합니다:
10
+ * ```typescript
11
+ * anonymous({ schema: ANONYMOUS_SCHEMA })
12
+ * ```
13
+ */
14
+ export const ANONYMOUS_SCHEMA: AnonymousOptions["schema"] = {
15
+ user: {
16
+ fields: {
17
+ isAnonymous: "is_anonymous",
18
+ },
19
+ },
20
+ };
21
+
22
+ /**
23
+ * anonymous 플러그인 래퍼
24
+ *
25
+ * Sonamu의 스키마 매핑을 자동으로 병합합니다.
26
+ */
27
+ export const anonymous = (options: AnonymousOptions = {}): ReturnType<typeof _anonymous> => {
28
+ options.schema = merge(ANONYMOUS_SCHEMA, options.schema ?? {});
29
+ return _anonymous(options);
30
+ };
@@ -0,0 +1,42 @@
1
+ import { apiKey as _apiKey, type ApiKeyOptions } from "better-auth/plugins";
2
+ import { merge } from "../../../utils/utils";
3
+
4
+ export type { ApiKeyOptions } from "better-auth/plugins";
5
+
6
+ /**
7
+ * API Key 플러그인 스키마
8
+ *
9
+ * better-auth apiKey 플러그인 호출 시 전달합니다:
10
+ * ```typescript
11
+ * apiKey({ schema: API_KEY_SCHEMA })
12
+ * ```
13
+ */
14
+ export const API_KEY_SCHEMA: ApiKeyOptions["schema"] = {
15
+ apikey: {
16
+ modelName: "api_keys",
17
+ fields: {
18
+ userId: "user_id",
19
+ lastRequest: "last_request",
20
+ requestCount: "request_count",
21
+ rateLimitEnabled: "rate_limit_enabled",
22
+ rateLimitTimeWindow: "rate_limit_time_window",
23
+ rateLimitMax: "rate_limit_max",
24
+ refillInterval: "refill_interval",
25
+ refillAmount: "refill_amount",
26
+ lastRefillAt: "last_refill_at",
27
+ expiresAt: "expires_at",
28
+ createdAt: "created_at",
29
+ updatedAt: "updated_at",
30
+ },
31
+ },
32
+ };
33
+
34
+ /**
35
+ * apiKey 플러그인 래퍼
36
+ *
37
+ * Sonamu의 스키마 매핑을 자동으로 병합합니다.
38
+ */
39
+ export const apiKey = (options: ApiKeyOptions = {}): ReturnType<typeof _apiKey> => {
40
+ options.schema = merge(API_KEY_SCHEMA, options.schema ?? {});
41
+ return _apiKey(options);
42
+ };
@@ -1,4 +1,10 @@
1
1
  export { ADMIN_SCHEMA, type AdminOptions, admin } from "./admin";
2
+ export { ANONYMOUS_SCHEMA, type AnonymousOptions, anonymous } from "./anonymous";
3
+ export { API_KEY_SCHEMA, type ApiKeyOptions, apiKey } from "./api-key";
4
+ export { JWT_SCHEMA, type JwtOptions, jwt } from "./jwt";
5
+ export { ORGANIZATION_SCHEMA, type OrganizationOptions, organization } from "./organization";
6
+ export { PASSKEY_SCHEMA, type PasskeyOptions, passkey } from "./passkey";
2
7
  export { PHONE_NUMBER_SCHEMA, type PhoneNumberOptions, phoneNumber } from "./phone-number";
8
+ export { SSO_SCHEMA, type SSOOptions, sso } from "./sso";
3
9
  export { TWO_FACTOR_SCHEMA, type TwoFactorOptions, twoFactor } from "./two-factor";
4
10
  export { USERNAME_SCHEMA, type UsernameOptions, username } from "./username";
@@ -0,0 +1,34 @@
1
+ import { jwt as _jwt, type JwtOptions } from "better-auth/plugins";
2
+ import { merge } from "../../../utils/utils";
3
+
4
+ export type { JwtOptions } from "better-auth/plugins";
5
+
6
+ /**
7
+ * JWT 플러그인 스키마
8
+ *
9
+ * better-auth jwt 플러그인 호출 시 전달합니다:
10
+ * ```typescript
11
+ * jwt({ schema: JWT_SCHEMA })
12
+ * ```
13
+ */
14
+ export const JWT_SCHEMA: JwtOptions["schema"] = {
15
+ jwks: {
16
+ modelName: "jwks",
17
+ fields: {
18
+ publicKey: "public_key",
19
+ privateKey: "private_key",
20
+ createdAt: "created_at",
21
+ expiresAt: "expires_at",
22
+ },
23
+ },
24
+ };
25
+
26
+ /**
27
+ * jwt 플러그인 래퍼
28
+ *
29
+ * Sonamu의 스키마 매핑을 자동으로 병합합니다.
30
+ */
31
+ export const jwt = (options: JwtOptions = {}): ReturnType<typeof _jwt> => {
32
+ options.schema = merge(JWT_SCHEMA, options.schema ?? {});
33
+ return _jwt(options);
34
+ };
@@ -0,0 +1,73 @@
1
+ import { organization as _organization, type OrganizationOptions } from "better-auth/plugins";
2
+ import { merge } from "../../../utils/utils";
3
+
4
+ export type { OrganizationOptions } from "better-auth/plugins";
5
+
6
+ /**
7
+ * Organization 플러그인 스키마
8
+ *
9
+ * better-auth organization 플러그인 호출 시 전달합니다:
10
+ * ```typescript
11
+ * organization({ schema: ORGANIZATION_SCHEMA })
12
+ * ```
13
+ */
14
+ export const ORGANIZATION_SCHEMA: OrganizationOptions["schema"] = {
15
+ organization: {
16
+ modelName: "organizations",
17
+ fields: {
18
+ createdAt: "created_at",
19
+ },
20
+ },
21
+ member: {
22
+ modelName: "members",
23
+ fields: {
24
+ userId: "user_id",
25
+ organizationId: "organization_id",
26
+ createdAt: "created_at",
27
+ },
28
+ },
29
+ invitation: {
30
+ modelName: "invitations",
31
+ fields: {
32
+ inviterId: "inviter_id",
33
+ organizationId: "organization_id",
34
+ teamId: "team_id",
35
+ expiresAt: "expires_at",
36
+ createdAt: "created_at",
37
+ },
38
+ },
39
+ team: {
40
+ modelName: "teams",
41
+ fields: {
42
+ organizationId: "organization_id",
43
+ createdAt: "created_at",
44
+ updatedAt: "updated_at",
45
+ },
46
+ },
47
+ teamMember: {
48
+ modelName: "team_members",
49
+ fields: {
50
+ teamId: "team_id",
51
+ userId: "user_id",
52
+ createdAt: "created_at",
53
+ },
54
+ },
55
+ session: {
56
+ fields: {
57
+ activeOrganizationId: "active_organization_id",
58
+ activeTeamId: "active_team_id",
59
+ },
60
+ },
61
+ };
62
+
63
+ /**
64
+ * organization 플러그인 래퍼
65
+ *
66
+ * Sonamu의 스키마 매핑을 자동으로 병합합니다.
67
+ */
68
+ export const organization = (
69
+ options: OrganizationOptions = {},
70
+ ): ReturnType<typeof _organization> => {
71
+ options.schema = merge(ORGANIZATION_SCHEMA, options.schema ?? {});
72
+ return _organization(options);
73
+ };
@@ -0,0 +1,36 @@
1
+ import { passkey as _passkey, type PasskeyOptions } from "@better-auth/passkey";
2
+ import { merge } from "../../../utils/utils";
3
+
4
+ export type { PasskeyOptions } from "@better-auth/passkey";
5
+
6
+ /**
7
+ * Passkey 플러그인 스키마
8
+ *
9
+ * better-auth passkey 플러그인 호출 시 전달합니다:
10
+ * ```typescript
11
+ * passkey({ schema: PASSKEY_SCHEMA })
12
+ * ```
13
+ */
14
+ export const PASSKEY_SCHEMA: PasskeyOptions["schema"] = {
15
+ passkey: {
16
+ modelName: "passkeys",
17
+ fields: {
18
+ publicKey: "public_key",
19
+ userId: "user_id",
20
+ credentialID: "credential_id",
21
+ deviceType: "device_type",
22
+ backedUp: "backed_up",
23
+ createdAt: "created_at",
24
+ },
25
+ },
26
+ };
27
+
28
+ /**
29
+ * passkey 플러그인 래퍼
30
+ *
31
+ * Sonamu의 스키마 매핑을 자동으로 병합합니다.
32
+ */
33
+ export const passkey = (options: PasskeyOptions = {}): ReturnType<typeof _passkey> => {
34
+ options.schema = merge(PASSKEY_SCHEMA, options.schema ?? {});
35
+ return _passkey(options);
36
+ };
@@ -26,8 +26,6 @@ export const PHONE_NUMBER_SCHEMA: PhoneNumberOptions["schema"] = {
26
26
  * Sonamu의 스키마 매핑을 자동으로 병합합니다.
27
27
  */
28
28
  export const phoneNumber = (options: PhoneNumberOptions) => {
29
- if (options.schema) {
30
- options.schema = merge(PHONE_NUMBER_SCHEMA, options.schema);
31
- }
29
+ options.schema = merge(PHONE_NUMBER_SCHEMA, options.schema ?? {});
32
30
  return _phoneNumber(options);
33
31
  };
@@ -0,0 +1,40 @@
1
+ import { sso as _sso, type SSOOptions } from "@better-auth/sso";
2
+
3
+ export type { SSOOptions } from "@better-auth/sso";
4
+
5
+ /**
6
+ * SSO 플러그인 스키마
7
+ *
8
+ * better-auth sso 플러그인 호출 시 전달합니다:
9
+ * ```typescript
10
+ * sso({ schema: SSO_SCHEMA })
11
+ * ```
12
+ */
13
+ export const SSO_SCHEMA: SSOOptions = {
14
+ modelName: "sso_providers",
15
+ fields: {
16
+ oidcConfig: "oidc_config",
17
+ samlConfig: "saml_config",
18
+ userId: "user_id",
19
+ providerId: "provider_id",
20
+ organizationId: "organization_id",
21
+ },
22
+ };
23
+
24
+ /**
25
+ * sso 플러그인 래퍼
26
+ *
27
+ * Sonamu의 스키마 매핑을 자동으로 병합합니다.
28
+ */
29
+ export const sso = (options: SSOOptions = {}) => {
30
+ options.modelName = "sso_providers";
31
+ options.fields = {
32
+ oidcConfig: "oidc_config",
33
+ samlConfig: "saml_config",
34
+ userId: "user_id",
35
+ providerId: "provider_id",
36
+ organizationId: "organization_id",
37
+ ...options.fields,
38
+ };
39
+ return _sso(options);
40
+ };
@@ -32,8 +32,6 @@ export const TWO_FACTOR_SCHEMA: TwoFactorOptions["schema"] = {
32
32
  * Sonamu의 스키마 매핑을 자동으로 병합합니다.
33
33
  */
34
34
  export const twoFactor = (options: TwoFactorOptions = {}) => {
35
- if (options.schema) {
36
- options.schema = merge(TWO_FACTOR_SCHEMA, options.schema);
37
- }
35
+ options.schema = merge(TWO_FACTOR_SCHEMA, options.schema ?? {});
38
36
  return _twoFactor(options);
39
37
  };
@@ -26,8 +26,6 @@ export const USERNAME_SCHEMA: UsernameOptions["schema"] = {
26
26
  * Sonamu의 스키마 매핑을 자동으로 병합합니다.
27
27
  */
28
28
  export const username = (options: UsernameOptions = {}) => {
29
- if (options.schema) {
30
- options.schema = merge(USERNAME_SCHEMA, options.schema);
31
- }
29
+ options.schema = merge(USERNAME_SCHEMA, options.schema ?? {});
32
30
  return _username(options);
33
31
  };