sonamu 0.8.24 → 0.8.26

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 (88) hide show
  1. package/dist/api/__tests__/config.test.js +189 -0
  2. package/dist/api/config.d.ts.map +1 -1
  3. package/dist/api/config.js +7 -2
  4. package/dist/api/sonamu.d.ts.map +1 -1
  5. package/dist/api/sonamu.js +14 -10
  6. package/dist/auth/index.d.ts +1 -0
  7. package/dist/auth/index.d.ts.map +1 -1
  8. package/dist/auth/index.js +2 -1
  9. package/dist/auth/knex-adapter.d.ts +23 -0
  10. package/dist/auth/knex-adapter.d.ts.map +1 -0
  11. package/dist/auth/knex-adapter.js +163 -0
  12. package/dist/auth/plugins/wrappers/admin.d.ts +2 -2
  13. package/dist/bin/__tests__/ts-loader-register.test.js +45 -0
  14. package/dist/bin/cli.js +47 -9
  15. package/dist/bin/ts-loader-register.js +3 -29
  16. package/dist/bin/ts-loader-registration.d.ts +2 -0
  17. package/dist/bin/ts-loader-registration.d.ts.map +1 -0
  18. package/dist/bin/ts-loader-registration.js +42 -0
  19. package/dist/cone/cone-generator.js +3 -3
  20. package/dist/database/puri-subset.test-d.js +9 -1
  21. package/dist/database/puri-subset.types.d.ts +1 -1
  22. package/dist/database/puri-subset.types.d.ts.map +1 -1
  23. package/dist/database/puri-subset.types.js +1 -1
  24. package/dist/testing/fixture-generator.js +5 -5
  25. package/dist/ui/ai-client.js +2 -2
  26. package/dist/ui/api.d.ts.map +1 -1
  27. package/dist/ui/api.js +14 -14
  28. package/dist/ui/cdd-service.d.ts +15 -18
  29. package/dist/ui/cdd-service.d.ts.map +1 -1
  30. package/dist/ui/cdd-service.js +246 -222
  31. package/dist/ui/cdd-types.d.ts +41 -68
  32. package/dist/ui/cdd-types.d.ts.map +1 -1
  33. package/dist/ui/cdd-types.js +2 -2
  34. package/dist/ui-web/assets/index-CKo0Z2Iu.css +1 -0
  35. package/dist/ui-web/assets/{index-CxiydzeC.js → index-DK-2aacv.js} +83 -83
  36. package/dist/ui-web/index.html +2 -2
  37. package/package.json +6 -2
  38. package/src/api/__tests__/config.test.ts +225 -0
  39. package/src/api/config.ts +10 -4
  40. package/src/api/sonamu.ts +16 -13
  41. package/src/auth/index.ts +1 -0
  42. package/src/auth/knex-adapter.ts +208 -0
  43. package/src/bin/__tests__/ts-loader-register.test.ts +62 -0
  44. package/src/bin/cli.ts +52 -9
  45. package/src/bin/ts-loader-register.ts +2 -32
  46. package/src/bin/ts-loader-registration.ts +55 -0
  47. package/src/cone/cone-generator.ts +2 -2
  48. package/src/database/puri-subset.test-d.ts +102 -0
  49. package/src/database/puri-subset.types.ts +1 -1
  50. package/src/skills/commands/sonamu-skills.md +20 -0
  51. package/src/skills/sonamu/SKILL.md +179 -137
  52. package/src/skills/sonamu/ai-agents.md +69 -69
  53. package/src/skills/sonamu/api.md +147 -147
  54. package/src/skills/sonamu/auth-migration.md +220 -220
  55. package/src/skills/sonamu/auth-plugins.md +83 -83
  56. package/src/skills/sonamu/auth.md +106 -106
  57. package/src/skills/sonamu/cdd.md +65 -200
  58. package/src/skills/sonamu/cone.md +138 -138
  59. package/src/skills/sonamu/config.md +191 -191
  60. package/src/skills/sonamu/create-sonamu.md +66 -66
  61. package/src/skills/sonamu/database.md +158 -158
  62. package/src/skills/sonamu/entity-basic.md +292 -293
  63. package/src/skills/sonamu/entity-relations.md +246 -246
  64. package/src/skills/sonamu/entity-validation-checklist.md +124 -124
  65. package/src/skills/sonamu/fixture-cli.md +231 -231
  66. package/src/skills/sonamu/framework-change.md +37 -37
  67. package/src/skills/sonamu/frontend.md +223 -223
  68. package/src/skills/sonamu/i18n.md +82 -82
  69. package/src/skills/sonamu/migration.md +77 -77
  70. package/src/skills/sonamu/model.md +222 -222
  71. package/src/skills/sonamu/naite.md +86 -86
  72. package/src/skills/sonamu/project-init.md +228 -228
  73. package/src/skills/sonamu/puri.md +122 -122
  74. package/src/skills/sonamu/scaffolding.md +154 -154
  75. package/src/skills/sonamu/skill-contribution.md +124 -124
  76. package/src/skills/sonamu/subset.md +46 -46
  77. package/src/skills/sonamu/tasks.md +82 -82
  78. package/src/skills/sonamu/testing-devrunner.md +147 -147
  79. package/src/skills/sonamu/testing.md +673 -673
  80. package/src/skills/sonamu/upsert.md +79 -79
  81. package/src/skills/sonamu/vector.md +67 -67
  82. package/src/testing/fixture-generator.ts +4 -4
  83. package/src/ui/ai-client.ts +1 -1
  84. package/src/ui/api.ts +18 -17
  85. package/src/ui/cdd-service.ts +264 -254
  86. package/src/ui/cdd-types.ts +40 -75
  87. package/dist/ui-web/assets/index-BrQKU3j9.css +0 -1
  88. package/src/skills/sonamu/workflow.md +0 -317
@@ -1,64 +1,64 @@
1
1
  ---
2
2
  name: sonamu-auth-plugins
3
- description: better-auth 플러그인 래퍼 엔티티 자동 생성. Sonamu snake_case 스키마 매핑 포함. Use when adding auth plugins like admin, organization, 2fa, passkey, phone-number, jwt, api-key, sso, username, anonymous.
3
+ description: better-auth plugin wrappers and automatic entity generation. Includes Sonamu snake_case schema mapping. Use when adding auth plugins like admin, organization, 2fa, passkey, phone-number, jwt, api-key, sso, username, anonymous.
4
4
  ---
5
5
 
6
- # better-auth 플러그인 가이드
6
+ # better-auth Plugin Guide
7
7
 
8
- Sonamu better-auth 플러그인을 snake_case 스키마 매핑과 함께 래핑하여 제공합니다.
9
- `auth generate --plugins` 명령어로 플러그인 엔티티를 자동 생성할 수 있습니다.
8
+ Sonamu wraps better-auth plugins with snake_case schema mapping.
9
+ Use the `auth generate --plugins` command to auto-generate plugin entities.
10
10
 
11
- **소스코드:**
12
- - 래퍼: `modules/sonamu/src/auth/plugins/wrappers/`
13
- - 엔티티 정의: `modules/sonamu/src/auth/plugins/entity-definitions/`
14
- - 생성기: `modules/sonamu/src/auth/auth-generator.ts`
11
+ **Source code:**
12
+ - Wrappers: `modules/sonamu/src/auth/plugins/wrappers/`
13
+ - Entity definitions: `modules/sonamu/src/auth/plugins/entity-definitions/`
14
+ - Generator: `modules/sonamu/src/auth/auth-generator.ts`
15
15
 
16
16
  ---
17
17
 
18
- ## 지원 플러그인
19
-
20
- | 플러그인 ID | 래퍼 함수 | 패키지 | 용도 |
21
- |------------|----------|--------|------|
22
- | `admin` | `admin()` | `better-auth/plugins` | 관리자 기능, 사용자 밴/언밴, 세션 impersonation |
23
- | `organization` | `organization()` | `better-auth/plugins` | 조직, 팀, 멤버, 초대 관리 |
24
- | `2fa` | `twoFactor()` | `better-auth/plugins` | TOTP 기반 2단계 인증 |
25
- | `username` | `username()` | `better-auth/plugins` | 사용자명 기반 인증 |
26
- | `phone-number` | `phoneNumber()` | `better-auth/plugins` | 전화번호 인증 |
27
- | `api-key` | `apiKey()` | `better-auth/plugins` | API 발급/관리, Rate Limit |
28
- | `jwt` | `jwt()` | `better-auth/plugins` | JWT 토큰 + JWKS 관리 |
29
- | `passkey` | `passkey()` | `@better-auth/passkey` | WebAuthn/Passkey 인증 |
30
- | `sso` | `sso()` | `@better-auth/sso` | OIDC/SAML SSO 연동 |
31
- | `anonymous` | `anonymous()` | `better-auth/plugins` | 익명 사용자 지원 |
18
+ ## Supported Plugins
19
+
20
+ | Plugin ID | Wrapper function | Package | Purpose |
21
+ |-----------|-----------------|---------|---------|
22
+ | `admin` | `admin()` | `better-auth/plugins` | Admin features, user ban/unban, session impersonation |
23
+ | `organization` | `organization()` | `better-auth/plugins` | Organization, team, member, and invitation management |
24
+ | `2fa` | `twoFactor()` | `better-auth/plugins` | TOTP-based two-factor authentication |
25
+ | `username` | `username()` | `better-auth/plugins` | Username-based authentication |
26
+ | `phone-number` | `phoneNumber()` | `better-auth/plugins` | Phone number authentication |
27
+ | `api-key` | `apiKey()` | `better-auth/plugins` | API key issuance/management, rate limiting |
28
+ | `jwt` | `jwt()` | `better-auth/plugins` | JWT tokens + JWKS key management |
29
+ | `passkey` | `passkey()` | `@better-auth/passkey` | WebAuthn/Passkey authentication |
30
+ | `sso` | `sso()` | `@better-auth/sso` | OIDC/SAML SSO integration |
31
+ | `anonymous` | `anonymous()` | `better-auth/plugins` | Anonymous user support |
32
32
 
33
33
  ---
34
34
 
35
- ## CLI 사용법
35
+ ## CLI Usage
36
36
 
37
37
  ```bash
38
- # 기본 엔티티만 (User, Session, Account, Verification)
38
+ # Base entities only (User, Session, Account, Verification)
39
39
  pnpm sonamu auth generate
40
40
 
41
- # 플러그인 포함
41
+ # With plugins
42
42
  pnpm sonamu auth generate --plugins admin,organization
43
43
 
44
- # 여러 플러그인
44
+ # Multiple plugins
45
45
  pnpm sonamu auth generate --plugins admin,2fa,phone-number,username
46
46
  ```
47
47
 
48
- ### 동작 방식
48
+ ### How It Works
49
49
 
50
- 1. **기본 엔티티** 생성/업데이트 (User, Session, Account, Verification)
51
- 2. **플러그인별** 처리:
52
- - `entities`: 테이블 생성 (예: Organization → organizations, members, invitations, teams, team_members)
53
- - `additionalProps`: 기존 엔티티에 필드 추가 (예: admin → User에 ban_reason, ban_expires 추가)
54
- - `additionalIndexes`: 기존 엔티티에 인덱스 추가
55
- 3. 이미 존재하는 엔티티는 **누락된 필드만 추가**, 기존 필드 보존
50
+ 1. **Base entities** are created/updated (User, Session, Account, Verification)
51
+ 2. **Per-plugin** processing:
52
+ - `entities`: creates new tables (e.g. Organization → organizations, members, invitations, teams, team_members)
53
+ - `additionalProps`: adds fields to existing entities (e.g. admin → adds ban_reason, ban_expires to User)
54
+ - `additionalIndexes`: adds indexes to existing entities
55
+ 3. Entities that already exist have **only missing fields added**; existing fields are preserved
56
56
 
57
57
  ---
58
58
 
59
- ## 래퍼 사용법 (sonamu.config.ts)
59
+ ## Wrapper Usage (sonamu.config.ts)
60
60
 
61
- Sonamu 래퍼를 사용하면 snake_case 스키마 매핑이 자동 적용됩니다.
61
+ Using Sonamu wrappers automatically applies snake_case schema mapping.
62
62
 
63
63
  ```typescript
64
64
  // sonamu.config.ts
@@ -79,45 +79,45 @@ export default defineConfig({
79
79
  });
80
80
  ```
81
81
 
82
- **CRITICAL: `better-auth/plugins`에서 직접 import하지 마세요.** Sonamu 래퍼를 거쳐야 snake_case 매핑이 적용됩니다.
82
+ **CRITICAL: Do not import directly from `better-auth/plugins`.** You must go through the Sonamu wrapper for snake_case mapping to apply.
83
83
 
84
84
  ```typescript
85
- // WRONG - snake_case 매핑
85
+ // WRONG - snake_case mapping not applied
86
86
  import { admin } from "better-auth/plugins";
87
87
 
88
- // CORRECT - Sonamu 래퍼
88
+ // CORRECT - Sonamu wrapper
89
89
  import { admin } from "sonamu/auth/plugins";
90
90
  ```
91
91
 
92
92
  ---
93
93
 
94
- ## 플러그인별 상세
94
+ ## Per-Plugin Details
95
95
 
96
96
  ### admin
97
97
 
98
- **추가 엔티티:** 없음
99
- **User에 추가되는 필드:** `role`, `banned`, `ban_reason`, `ban_expires`
100
- **Session에 추가되는 필드:** `impersonated_by`
98
+ **Additional entities:** None
99
+ **Fields added to User:** `role`, `banned`, `ban_reason`, `ban_expires`
100
+ **Fields added to Session:** `impersonated_by`
101
101
 
102
102
  ```typescript
103
103
  import { admin } from "sonamu/auth/plugins";
104
104
 
105
- // 기본 사용
105
+ // Basic usage
106
106
  admin()
107
107
 
108
- // 옵션 커스터마이즈 (스키마 매핑은 자동 병합)
108
+ // Customize options (schema mapping is automatically merged)
109
109
  admin({ defaultRole: "user" })
110
110
  ```
111
111
 
112
- 스키마 매핑:
112
+ Schema mapping:
113
113
  - `banReason` → `ban_reason`
114
114
  - `banExpires` → `ban_expires`
115
115
  - `impersonatedBy` → `impersonated_by`
116
116
 
117
117
  ### organization
118
118
 
119
- **추가 엔티티:** Organization, Member, Invitation, Team, TeamMember
120
- **Session에 추가되는 필드:** `active_organization_id`, `active_team_id`
119
+ **Additional entities:** Organization, Member, Invitation, Team, TeamMember
120
+ **Fields added to Session:** `active_organization_id`, `active_team_id`
121
121
 
122
122
  ```typescript
123
123
  import { organization } from "sonamu/auth/plugins";
@@ -125,8 +125,8 @@ import { organization } from "sonamu/auth/plugins";
125
125
  organization()
126
126
  ```
127
127
 
128
- 스키마 매핑:
129
- - 모든 테이블: `createdAt` → `created_at`
128
+ Schema mapping:
129
+ - All tables: `createdAt` → `created_at`
130
130
  - Member: `userId` → `user_id`, `organizationId` → `organization_id`
131
131
  - Invitation: `inviterId` → `inviter_id`, `organizationId` → `organization_id`, `teamId` → `team_id`, `expiresAt` → `expires_at`
132
132
  - Team: `organizationId` → `organization_id`, `updatedAt` → `updated_at`
@@ -135,8 +135,8 @@ organization()
135
135
 
136
136
  ### 2fa (twoFactor)
137
137
 
138
- **추가 엔티티:** TwoFactor
139
- **User에 추가되는 필드:** `two_factor_enabled`
138
+ **Additional entities:** TwoFactor
139
+ **Fields added to User:** `two_factor_enabled`
140
140
 
141
141
  ```typescript
142
142
  import { twoFactor } from "sonamu/auth/plugins";
@@ -144,13 +144,13 @@ import { twoFactor } from "sonamu/auth/plugins";
144
144
  twoFactor()
145
145
  ```
146
146
 
147
- 스키마 매핑:
147
+ Schema mapping:
148
148
  - User: `twoFactorEnabled` → `two_factor_enabled`
149
149
  - TwoFactor: `userId` → `user_id`, `backupCodes` → `backup_codes`
150
150
 
151
151
  ### username
152
152
 
153
- **User에 추가되는 필드:** `display_username`
153
+ **Fields added to User:** `display_username`
154
154
 
155
155
  ```typescript
156
156
  import { username } from "sonamu/auth/plugins";
@@ -158,26 +158,26 @@ import { username } from "sonamu/auth/plugins";
158
158
  username()
159
159
  ```
160
160
 
161
- 스키마 매핑:
161
+ Schema mapping:
162
162
  - `displayUsername` → `display_username`
163
163
 
164
164
  ### phone-number
165
165
 
166
- **User에 추가되는 필드:** `phone_number`, `phone_number_verified`
166
+ **Fields added to User:** `phone_number`, `phone_number_verified`
167
167
 
168
168
  ```typescript
169
169
  import { phoneNumber } from "sonamu/auth/plugins";
170
170
 
171
- phoneNumber({ sendOTP: async ({ phoneNumber, otp }) => { /* SMS 발송 */ } })
171
+ phoneNumber({ sendOTP: async ({ phoneNumber, otp }) => { /* send SMS */ } })
172
172
  ```
173
173
 
174
- 스키마 매핑:
174
+ Schema mapping:
175
175
  - `phoneNumber` → `phone_number`
176
176
  - `phoneNumberVerified` → `phone_number_verified`
177
177
 
178
178
  ### api-key
179
179
 
180
- **추가 엔티티:** ApiKey (테이블: `api_keys`)
180
+ **Additional entities:** ApiKey (table: `api_keys`)
181
181
 
182
182
  ```typescript
183
183
  import { apiKey } from "sonamu/auth/plugins";
@@ -185,7 +185,7 @@ import { apiKey } from "sonamu/auth/plugins";
185
185
  apiKey()
186
186
  ```
187
187
 
188
- 스키마 매핑:
188
+ Schema mapping:
189
189
  - `userId` → `user_id`, `lastRequest` → `last_request`, `requestCount` → `request_count`
190
190
  - `rateLimitEnabled` → `rate_limit_enabled`, `rateLimitTimeWindow` → `rate_limit_time_window`
191
191
  - `rateLimitMax` → `rate_limit_max`, `refillInterval` → `refill_interval`
@@ -194,7 +194,7 @@ apiKey()
194
194
 
195
195
  ### jwt
196
196
 
197
- **추가 엔티티:** Jwks (테이블: `jwks`)
197
+ **Additional entities:** Jwks (table: `jwks`)
198
198
 
199
199
  ```typescript
200
200
  import { jwt } from "sonamu/auth/plugins";
@@ -202,14 +202,14 @@ import { jwt } from "sonamu/auth/plugins";
202
202
  jwt()
203
203
  ```
204
204
 
205
- 스키마 매핑:
205
+ Schema mapping:
206
206
  - `publicKey` → `public_key`, `privateKey` → `private_key`
207
207
  - `createdAt` → `created_at`, `expiresAt` → `expires_at`
208
208
 
209
209
  ### passkey
210
210
 
211
- **추가 엔티티:** Passkey (테이블: `passkeys`)
212
- **패키지:** `@better-auth/passkey` (별도 설치 필요)
211
+ **Additional entities:** Passkey (table: `passkeys`)
212
+ **Package:** `@better-auth/passkey` (must be installed separately)
213
213
 
214
214
  ```bash
215
215
  pnpm add @better-auth/passkey
@@ -221,13 +221,13 @@ import { passkey } from "sonamu/auth/plugins";
221
221
  passkey({ rpID: "localhost", rpName: "My App" })
222
222
  ```
223
223
 
224
- 스키마 매핑:
224
+ Schema mapping:
225
225
  - `publicKey` → `public_key`, `userId` → `user_id`, `credentialID` → `credential_id`
226
226
  - `deviceType` → `device_type`, `backedUp` → `backed_up`, `createdAt` → `created_at`
227
227
 
228
228
  ### sso
229
229
 
230
- **패키지:** `@better-auth/sso` (별도 설치 필요)
230
+ **Package:** `@better-auth/sso` (must be installed separately)
231
231
 
232
232
  ```bash
233
233
  pnpm add @better-auth/sso
@@ -239,14 +239,14 @@ import { sso } from "sonamu/auth/plugins";
239
239
  sso()
240
240
  ```
241
241
 
242
- 테이블: `sso_providers`
243
- 스키마 매핑:
242
+ Table: `sso_providers`
243
+ Schema mapping:
244
244
  - `oidcConfig` → `oidc_config`, `samlConfig` → `saml_config`
245
245
  - `userId` → `user_id`, `providerId` → `provider_id`, `organizationId` → `organization_id`
246
246
 
247
247
  ### anonymous
248
248
 
249
- **User에 추가되는 필드:** `is_anonymous`
249
+ **Fields added to User:** `is_anonymous`
250
250
 
251
251
  ```typescript
252
252
  import { anonymous } from "sonamu/auth/plugins";
@@ -254,14 +254,14 @@ import { anonymous } from "sonamu/auth/plugins";
254
254
  anonymous()
255
255
  ```
256
256
 
257
- 스키마 매핑:
257
+ Schema mapping:
258
258
  - `isAnonymous` → `is_anonymous`
259
259
 
260
260
  ---
261
261
 
262
- ## 커스텀 스키마 옵션
262
+ ## Custom Schema Options
263
263
 
264
- 래퍼 함수에 추가 옵션을 전달하면 Sonamu 기본 매핑과 자동 병합됩니다:
264
+ Passing additional options to a wrapper function automatically merges them with Sonamu's default mapping:
265
265
 
266
266
  ```typescript
267
267
  admin({
@@ -269,29 +269,29 @@ admin({
269
269
  schema: {
270
270
  user: {
271
271
  fields: {
272
- customField: "custom_field", // 추가 매핑
272
+ customField: "custom_field", // additional mapping
273
273
  },
274
274
  },
275
275
  },
276
276
  })
277
277
  ```
278
278
 
279
- 내부적으로 `merge(ADMIN_SCHEMA, options.schema)`가 실행되어 Sonamu 매핑이 보존됩니다.
279
+ Internally, `merge(ADMIN_SCHEMA, options.schema)` is executed to preserve the Sonamu mapping.
280
280
 
281
281
  ---
282
282
 
283
- ## 플러그인 추가 작업 순서
283
+ ## Steps After Adding a Plugin
284
284
 
285
- 1. `pnpm sonamu auth generate --plugins <플러그인 목록>`
286
- 2. Sonamu UI에서 생성된 엔티티 확인
287
- 3. `pnpm sonamu migrate run`으로 마이그레이션 실행
288
- 4. `sonamu.config.ts`에 래퍼 함수 추가
289
- 5. 필요시 `guardHandler`에 플러그인별 권한 로직 추가
285
+ 1. `pnpm sonamu auth generate --plugins <plugin list>`
286
+ 2. Confirm generated entities in Sonamu UI
287
+ 3. Run migration with `pnpm sonamu migrate run`
288
+ 4. Add wrapper functions to `sonamu.config.ts`
289
+ 5. If needed, add plugin-specific permission logic to `guardHandler`
290
290
 
291
291
  ---
292
292
 
293
- ## 참고
293
+ ## References
294
294
 
295
- - **기본 인증 설정:** `auth.md`
296
- - **PK 타입 변경 (better-auth → string PK):** `auth-migration.md`
297
- - **소스코드:** `modules/sonamu/src/auth/plugins/`
295
+ - **Basic auth configuration:** `auth.md`
296
+ - **Changing PK type (better-auth → string PK):** `auth-migration.md`
297
+ - **Source code:** `modules/sonamu/src/auth/plugins/`