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,220 +1,220 @@
1
1
  ---
2
2
  name: sonamu-fixture-cli
3
- description: Sonamu Fixture CLI 사용 가이드. fixture gen/fetch/explore 명령어로 테스트 데이터 생성 및 관리. Use when creating or managing fixture data.
3
+ description: Sonamu Fixture CLI usage guide. Create and manage test data with the fixture gen/fetch/explore commands. Use when creating or managing fixture data.
4
4
  ---
5
5
 
6
- # Fixture CLI 사용 가이드
6
+ # Fixture CLI Usage Guide
7
7
 
8
- Sonamu 테스트용 fixture 데이터를 생성하고 관리하기 위한 CLI 명령어를 제공합니다.
8
+ Sonamu provides CLI commands for generating and managing fixture data for testing.
9
9
 
10
- **참고**: Fixture 생성 팁은 아래 "실전 " 섹션 참조
10
+ **Note**: See the "Practical Tips" section below for fixture generation tips.
11
11
 
12
12
  ---
13
13
 
14
- ## 3-Tier DB 구조 이해 (필수)
14
+ ## Understanding the 3-Tier DB Structure (Required)
15
15
 
16
- Sonamu 3단계 데이터베이스 구조를 사용합니다. **이 구조를 이해하지 못하면 fixture 명령어 사용 혼란이 발생합니다.**
16
+ Sonamu uses a three-tier database structure. **Without understanding this structure, using fixture commands will be confusing.**
17
17
 
18
18
  ```
19
- production/development master (실제 DB)
19
+ production/development master (live DB)
20
20
  ↓ (fixture fetch)
21
21
  project_fixture (fixture DB)
22
22
  ↓ (fixture sync)
23
23
  project_test (test DB)
24
24
  ```
25
25
 
26
- ### DB별 역할
26
+ ### Role of Each DB
27
27
 
28
- | DB | 용도 | 데이터 출처 |
29
- |----|------|-----------|
30
- | `project` | 운영/개발 실제 DB | 실제 사용자 데이터 |
31
- | `project_fixture` | 테스트용 참조 데이터 저장소 | fetch 가져오거나 gen으로 생성 |
32
- | `project_test` | 테스트 실행 환경 | fixture에서 sync |
28
+ | DB | Purpose | Data origin |
29
+ |----|---------|-------------|
30
+ | `project` | Production/development live DB | Real user data |
31
+ | `project_fixture` | Reference data store for testing | Imported via fetch or generated via gen |
32
+ | `project_test` | Test execution environment | Synced from fixture |
33
33
 
34
- ### 명령어별 DB 사용
34
+ ### Which DB Each Command Uses
35
35
 
36
- | 명령어 | sourceDb | targetDb | 설명 |
37
- |--------|----------|----------|------|
38
- | `fixture gen` | fixture DB | fixture DB | fixture DB 내부에서 참조 관계 해결 생성 |
39
- | `fixture fetch` | production master | fixture DB | 실제 DB → fixture DB import |
40
- | `fixture sync` | fixture DB | test DB | fixture DB → test DB 동기화 (기존) |
36
+ | Command | sourceDb | targetDb | Description |
37
+ |---------|----------|----------|-------------|
38
+ | `fixture gen` | fixture DB | fixture DB | Resolves and generates relations within the fixture DB |
39
+ | `fixture fetch` | production master | fixture DB | Imports from live DB → fixture DB |
40
+ | `fixture sync` | fixture DB | test DB | Synchronizes fixture DB → test DB (existing behavior) |
41
41
 
42
- **CRITICAL**: sourceDb targetDb 잘못 설정하면 FK 참조 오류가 발생합니다.
42
+ **CRITICAL**: Incorrect sourceDb or targetDb settings will cause FK reference errors.
43
43
 
44
44
  ---
45
45
 
46
- ## CLI 명령어
46
+ ## CLI Commands
47
47
 
48
- ### 1. fixture gen - 새로운 fixture 생성
48
+ ### 1. fixture gen - Generate new fixtures
49
49
 
50
- faker 기반으로 새로운 테스트 데이터를 생성합니다.
50
+ Generates new test data based on faker.
51
51
 
52
- **CRITICAL: `--use-llm` 옵션은 실제 프로젝트에서 항상 사용해야 한다.** `--use-llm` 없이 생성하면 cone.note 기반 도메인 맥락이 반영되지 않아 faker 기본값만 사용되므로, 의미 없는 데이터가 생성될 있다. LLM `contract/**/*.contract.md`를 참조해 맥락에 맞는 데이터를 생성하려면 이 옵션이 필수이다.
52
+ **CRITICAL: The `--use-llm` option must always be used in real projects.** Without `--use-llm`, domain context from cone.note is not applied and only faker defaults are used, potentially producing meaningless data. This option is required for the LLM to reference `contract/**/*.contract.md` and generate contextually appropriate data.
53
53
 
54
- **CRITICAL: fixture gen 실행하기 전에 `cone.note`가 주요 prop에 존재하는지 확인한다.** cone.note 없으면 LLM 맥락을 파악할 없어 의미 있는 데이터 생성이 불가능하다. cone.note 부족하면 `pnpm sonamu cone generate --use-llm`으로 cone을 재생성한다.
54
+ **CRITICAL: Before running fixture gen, verify that `cone.note` exists for key props.** Without cone.note, the LLM cannot understand context and cannot generate meaningful data. If cone.note is insufficient, regenerate it with `pnpm sonamu cone generate --use-llm`.
55
55
 
56
- #### 기본 사용법
56
+ #### Basic Usage
57
57
 
58
58
  ```bash
59
- # 대화형 모드 (권장)
59
+ # Interactive mode (recommended)
60
60
  pnpm sonamu fixture gen
61
61
 
62
- # Entity 지정
62
+ # Specify Entity
63
63
  pnpm sonamu fixture gen --include User --count 10
64
64
 
65
- # 여러 Entity 지정
65
+ # Multiple Entities
66
66
  pnpm sonamu fixture gen --include User,Post,Comment --count 5
67
67
 
68
- # 전체 Entity
68
+ # All Entities
69
69
  pnpm sonamu fixture gen --all --count 3
70
70
 
71
- # 전체에서 일부 제외
71
+ # All minus exclusions
72
72
  pnpm sonamu fixture gen --all --exclude Admin,Log --count 3
73
73
  ```
74
74
 
75
- #### 저장 옵션
75
+ #### Save Options
76
76
 
77
77
  ```bash
78
- # DB 저장 (기본값)
78
+ # Save to DB (default)
79
79
  pnpm sonamu fixture gen --include User --count 10 --save-to db
80
80
 
81
- # 파일로 저장 (테이블명.json)
81
+ # Save to file (tablename.json)
82
82
  pnpm sonamu fixture gen --include User --count 10 --save-to file
83
83
  # → test/fixtures/users.json
84
84
 
85
- # 파일명 지정
85
+ # Specify filename
86
86
  pnpm sonamu fixture gen --include User --count 10 --save-to file:my-users.json
87
87
  # → test/fixtures/my-users.json
88
88
 
89
- # 출력만 (저장 )
89
+ # Output only (do not save)
90
90
  pnpm sonamu fixture gen --include User --count 10 --save-to none
91
91
  ```
92
92
 
93
- #### 옵션
93
+ #### Options
94
94
 
95
- - `--include <entities>`: 생성할 Entity 목록 (쉼표 구분)
96
- - `--all`: 모든 Entity
97
- - `--exclude <entities>`: --all 함께 사용, 제외할 Entity
98
- - `--count <number>`: Entity별 생성 개수 (기본값: 5)
99
- - `--save-to <target>`: 저장 방식 - `db` | `file` | `file:name.json` | `none`
100
- - `--use-llm`: cone.note 기반 LLM 생성 활성화 (ANTHROPIC_API_KEY 필요)
101
- - `--no-cache`: LLM 캐시 비활성화 (기본값: 캐시 ON)
102
- - `--llm-model <model>`: LLM 모델 지정 (기본값: `claude-sonnet-4-5`)
95
+ - `--include <entities>`: List of Entities to generate (comma-separated)
96
+ - `--all`: All Entities
97
+ - `--exclude <entities>`: Used with --all; Entities to exclude
98
+ - `--count <number>`: Number to generate per Entity (default: 5)
99
+ - `--save-to <target>`: Save mode - `db` | `file` | `file:name.json` | `none`
100
+ - `--use-llm`: Enable LLM-based generation from cone.note (requires ANTHROPIC_API_KEY)
101
+ - `--no-cache`: Disable LLM cache (default: cache ON)
102
+ - `--llm-model <model>`: Specify LLM model (default: `claude-sonnet-4-5`)
103
103
 
104
104
  ---
105
105
 
106
- ### 2. fixture fetch - 실제 DB에서 import
106
+ ### 2. fixture fetch - Import from live DB
107
107
 
108
- 실제 운영/개발 DB에서 데이터를 가져와 fixture DB에 저장합니다.
108
+ Fetches data from the production/development DB and saves it to the fixture DB.
109
109
 
110
- #### 기본 사용법
110
+ #### Basic Usage
111
111
 
112
112
  ```bash
113
- # 대화형 모드
113
+ # Interactive mode
114
114
  pnpm sonamu fixture fetch
115
115
 
116
- # 최근 데이터 가져오기
116
+ # Fetch recent data
117
117
  pnpm sonamu fixture fetch --include User --strategy recent --limit 10
118
118
 
119
- # 여러 Entity
119
+ # Multiple Entities
120
120
  pnpm sonamu fixture fetch --include User,Post --strategy sample --limit 5
121
121
 
122
- # 전체 Entity
122
+ # All Entities
123
123
  pnpm sonamu fixture fetch --all --strategy recent --limit 3
124
124
  ```
125
125
 
126
- #### 전략 (Strategy)
126
+ #### Strategies
127
127
 
128
- | 전략 | 설명 | 예시 |
129
- |------|------|------|
130
- | `recent` | 최근 데이터 (created_at 기준) | `--strategy recent --limit 10` |
131
- | `sample` | 균등 샘플링 | `--strategy sample --limit 10` |
132
- | `random` | 랜덤 샘플링 | `--strategy random --limit 10` |
128
+ | Strategy | Description | Example |
129
+ |----------|-------------|---------|
130
+ | `recent` | Most recent data (by created_at) | `--strategy recent --limit 10` |
131
+ | `sample` | Uniform sampling | `--strategy sample --limit 10` |
132
+ | `random` | Random sampling | `--strategy random --limit 10` |
133
133
 
134
- **CRITICAL**: fetch 관련 데이터를 **재귀적으로 가져옵니다** (maxDepth: 2)
135
- - User fetch하면 → User department, institution도 함께 import
136
- - Post fetch하면 → Post author(User)도 함께 import
134
+ **CRITICAL**: fetch retrieves related data **recursively** (maxDepth: 2)
135
+ - Fetching User → also imports User's department and institution
136
+ - Fetching Post → also imports Post's author (User)
137
137
 
138
- #### 옵션
138
+ #### Options
139
139
 
140
- - `--include <entities>`: import할 Entity 목록
141
- - `--all`: 모든 Entity
142
- - `--exclude <entities>`: --all 함께 사용, 제외할 Entity
143
- - `--strategy <strategy>`: 조회 전략 - `recent` | `sample` | `random` (기본값: recent)
144
- - `--limit <number>`: Entity별 조회 개수 (기본값: 10)
140
+ - `--include <entities>`: List of Entities to import
141
+ - `--all`: All Entities
142
+ - `--exclude <entities>`: Used with --all; Entities to exclude
143
+ - `--strategy <strategy>`: Fetch strategy - `recent` | `sample` | `random` (default: recent)
144
+ - `--limit <number>`: Number of records per Entity (default: 10)
145
145
 
146
146
  ---
147
147
 
148
- ### 3. fixture explore - 데이터 조회 (저장 안 함)
148
+ ### 3. fixture explore - Query data (without saving)
149
149
 
150
- 실제 DB 데이터를 조회하여 콘솔에 출력합니다. **저장하지 않고 조회만** 합니다.
150
+ Queries data from the live DB and prints it to the console. **Query only — nothing is saved.**
151
151
 
152
- #### 기본 사용법
152
+ #### Basic Usage
153
153
 
154
154
  ```bash
155
- # 대화형 모드
155
+ # Interactive mode
156
156
  pnpm sonamu fixture explore
157
157
 
158
- # 최근 User 조회
158
+ # Query recent Users
159
159
  pnpm sonamu fixture explore --include User --strategy recent --limit 10
160
160
 
161
- # 샘플링
161
+ # Sampling
162
162
  pnpm sonamu fixture explore --include Department --strategy sample --limit 5
163
163
  ```
164
164
 
165
- #### 언제 사용하나?
165
+ #### When to use
166
166
 
167
- - 실제 DB에 어떤 데이터가 있는지 빠르게 확인
168
- - fixture fetch 전에 미리 확인
169
- - 데이터 분포 파악
167
+ - Quickly check what data exists in the live DB
168
+ - Preview before running fixture fetch
169
+ - Understand data distribution
170
170
 
171
171
  ---
172
172
 
173
- ## 실전 사용 시나리오
173
+ ## Practical Scenarios
174
174
 
175
- ### 시나리오 1: DB에서 시작
175
+ ### Scenario 1: Starting from an empty DB
176
176
 
177
177
  ```bash
178
- # 1. 기본 fixture 생성
178
+ # 1. Generate base fixtures
179
179
  pnpm sonamu fixture gen --all --exclude Admin,Log --count 5
180
180
 
181
- # 2. fixture → test DB 동기화
181
+ # 2. Sync fixture → test DB
182
182
  pnpm sonamu fixture sync
183
183
 
184
- # 3. 테스트 실행
184
+ # 3. Run tests
185
185
  pnpm test
186
186
  ```
187
187
 
188
- ### 시나리오 2: 실제 데이터 기반 테스트
188
+ ### Scenario 2: Testing with real data
189
189
 
190
190
  ```bash
191
- # 1. 실제 DB에서 최근 데이터 가져오기
191
+ # 1. Fetch recent data from live DB
192
192
  pnpm sonamu fixture fetch --include User,Department --strategy recent --limit 20
193
193
 
194
- # 2. 부족한 데이터 추가 생성
194
+ # 2. Generate additional data
195
195
  pnpm sonamu fixture gen --include Post,Comment --count 50
196
196
 
197
- # 3. fixture → test DB 동기화
197
+ # 3. Sync fixture → test DB
198
198
  pnpm sonamu fixture sync
199
199
 
200
- # 4. 테스트 실행
200
+ # 4. Run tests
201
201
  pnpm test
202
202
  ```
203
203
 
204
- ### 시나리오 3: 특정 시나리오 테스트 준비
204
+ ### Scenario 3: Preparing for a specific scenario test
205
205
 
206
206
  ```bash
207
- # 1. 특정 Entity만 생성
207
+ # 1. Generate specific Entities only
208
208
  pnpm sonamu fixture gen --include User --count 3
209
209
 
210
- # 2. 대화형으로 추가 생성
210
+ # 2. Generate additional interactively
211
211
  pnpm sonamu fixture gen
212
- # ? Fixture를 생성할 Entity를 선택하세요: Post, Comment 선택
213
- # ? Entity별 생성 개수: 10
212
+ # ? Select entities to generate fixtures for: choose Post, Comment
213
+ # ? Count per entity: 10
214
214
 
215
- # 3. 파일로 저장 (버전 관리)
215
+ # 3. Save to file (for version control)
216
216
  pnpm sonamu fixture gen --include User --count 10 --save-to file
217
- # → test/fixtures/users.json 생성
217
+ # → creates test/fixtures/users.json
218
218
 
219
219
  # 4. fixture sync
220
220
  pnpm sonamu fixture sync
@@ -222,17 +222,17 @@ pnpm sonamu fixture sync
222
222
 
223
223
  ---
224
224
 
225
- ## 실전
225
+ ## Practical Tips
226
226
 
227
- ### 1. 한국어 데이터 자동 생성
227
+ ### 1. Automatic Korean data generation
228
228
 
229
- FixtureGenerator 특정 필드명에 대해 한국어 데이터를 자동으로 생성합니다:
229
+ FixtureGenerator automatically generates Korean data for specific field names:
230
230
 
231
- **자동 한국어 생성 필드**:
232
- - `name`, `username`: 한국 사람 이름 (`fakerKO.person.fullName()`)
233
- - Entity `Department`이고 prop `name`: 한국 부서명
231
+ **Fields with automatic Korean generation**:
232
+ - `name`, `username`: Korean full name (`fakerKO.person.fullName()`)
233
+ - Entity is `Department` and prop is `name`: Korean department name
234
234
 
235
- **예시 결과**:
235
+ **Example output**:
236
236
  ```typescript
237
237
  // User
238
238
  { name: "김민준", username: "이서연" }
@@ -241,44 +241,44 @@ FixtureGenerator는 특정 필드명에 대해 한국어 데이터를 자동으
241
241
  { name: "개발팀 1팀", name: "글로벌 마케팅팀" }
242
242
  ```
243
243
 
244
- **커스터마이징**:
244
+ **Customization**:
245
245
  ```typescript
246
- // fixture-generator.ts에서 수정
246
+ // Edit in fixture-generator.ts
247
247
  if (entity?.id === "Department" && prop.name === "name") {
248
248
  const departments = ["개발팀", "기획팀", "마케팅팀", "영업팀"];
249
249
  // ...
250
250
  }
251
251
  ```
252
252
 
253
- ### 2. Unique Constraint 처리
253
+ ### 2. Handling Unique Constraints
254
254
 
255
- unique constraint가 있는 필드는 중복 방지 전략이 필요합니다.
255
+ Fields with unique constraints require a deduplication strategy.
256
256
 
257
- **문제 상황**:
257
+ **Problem**:
258
258
  ```sql
259
- -- departments 테이블
259
+ -- departments table
260
260
  UNIQUE (company_id, name)
261
261
  ```
262
262
 
263
- **해결: 자동 변형**
263
+ **Solution: Automatic variation**
264
264
  ```typescript
265
- // 같은 company_id에 "개발팀" 여러 생성되지 않도록
266
- // 70% 확률로 prefix/suffix 자동 추가
265
+ // Prevents "개발팀" from being generated multiple times under the same company_id
266
+ // Automatically adds prefix/suffix with 70% probability
267
267
 
268
- // 결과:
268
+ // Result:
269
269
  "개발팀" // 30%
270
270
  "개발팀 1팀" // 20%
271
271
  "개발팀 본부" // 20%
272
272
  "글로벌 개발팀" // 30%
273
273
  ```
274
274
 
275
- **구현 위치**: `fixture-generator.ts`의 `generateDefaultValue()`
275
+ **Implementation location**: `generateDefaultValue()` in `fixture-generator.ts`
276
276
 
277
- ### 3. BelongsToOne FK 설정
277
+ ### 3. BelongsToOne FK Setup
278
278
 
279
- BelongsToOne 관계는 `{name}_id` 컬럼을 자동 생성하므로, 코드에서도 `_id` 접미사를 사용해야 합니다.
279
+ BelongsToOne relations auto-generate a `{name}_id` column, so code must use the `_id` suffix.
280
280
 
281
- **Entity 정의**:
281
+ **Entity definition**:
282
282
  ```json
283
283
  {
284
284
  "type": "relation",
@@ -288,45 +288,45 @@ BelongsToOne 관계는 `{name}_id` 컬럼을 자동 생성하므로, 코드에
288
288
  }
289
289
  ```
290
290
 
291
- **FixtureGenerator 내부**:
291
+ **Inside FixtureGenerator**:
292
292
  ```typescript
293
293
  // ✓ CORRECT
294
294
  fixture[`${prop.name}_id`] = relationValue; // company_id
295
295
 
296
296
  // ✗ WRONG
297
- fixture[prop.name] = relationValue; // company (FK NULL로 저장됨!)
297
+ fixture[prop.name] = relationValue; // company (FK saved as NULL!)
298
298
  ```
299
299
 
300
- **실수하기 쉬운 이유**:
301
- - Entity JSON에서는 `name: "company"`로 정의
302
- - DB 컬럼은 `company_id`로 자동 생성
303
- - 코드에서는 `company_id` 사용해야 함
300
+ **Easy to get wrong because**:
301
+ - Entity JSON defines `name: "company"`
302
+ - DB column is auto-created as `company_id`
303
+ - Code must use `company_id`
304
304
 
305
- ### 4. 순서 문제 해결
305
+ ### 4. Resolving Ordering Issues
306
306
 
307
- fixture gen **자동으로 의존성 순서를 정렬**합니다 (FixtureManager RelationGraph 사용).
307
+ fixture gen **automatically sorts by dependency order** (uses FixtureManager's RelationGraph).
308
308
 
309
- **예시**:
309
+ **Example**:
310
310
  ```bash
311
- # Department Company 참조하지만 순서 걱정 불필요
311
+ # Department references Company, but no need to worry about order
312
312
  pnpm sonamu fixture gen --include Department,Company --count 5
313
313
 
314
- # 내부적으로:
315
- # 1. Company 먼저 생성 (FK 없음)
316
- # 2. Department 생성 (company_id 참조)
314
+ # Internally:
315
+ # 1. Company generated first (no FK)
316
+ # 2. Department generated next (references company_id)
317
317
  ```
318
318
 
319
- **주의**: 순환 참조는 경고 발생
319
+ **Note**: Circular references will produce a warning.
320
320
 
321
- **내부 구현 (RelationGraph):**
321
+ **Internal implementation (RelationGraph):**
322
322
 
323
- `FixtureManager`는 `RelationGraph` 클래스(`_relation-graph.ts`) 사용하여 의존성 그래프를 구축하고 위상 정렬(topological sort)하여 삽입 순서를 결정합니다. BelongsToOne OneToOne(hasJoinColumn) 관계를 분석하여 부모 엔티티가 항상 자식보다 먼저 삽입되도록 보장합니다.
323
+ `FixtureManager` uses the `RelationGraph` class (`_relation-graph.ts`) to build a dependency graph and topologically sort it to determine insertion order. It analyzes BelongsToOne and OneToOne (hasJoinColumn) relations to guarantee that parent entities are always inserted before children.
324
324
 
325
- ### 5. DB 시퀀스 리셋
325
+ ### 5. DB Sequence Reset
326
326
 
327
- fixture 생성 ID 시퀀스가 맞지 않을 있습니다.
327
+ After generating fixtures, ID sequences may be out of sync.
328
328
 
329
- **확인**:
329
+ **Check**:
330
330
  ```bash
331
331
  PGPASSWORD=1234 psql -h 0.0.0.0 -U postgres -d project_fixture -c "
332
332
  SELECT sequencename, last_value
@@ -336,16 +336,16 @@ ORDER BY sequencename;
336
336
  "
337
337
  ```
338
338
 
339
- **리셋**:
339
+ **Reset**:
340
340
  ```sql
341
- -- 테이블마다
341
+ -- Per table
342
342
  SELECT setval('departments_id_seq', (SELECT MAX(id) FROM departments), true);
343
343
  SELECT setval('companies_id_seq', (SELECT MAX(id) FROM companies), true);
344
344
  ```
345
345
 
346
- **자동화**:
346
+ **Automated**:
347
347
  ```bash
348
- # 모든 시퀀스 리셋 스크립트
348
+ # Reset all sequences script
349
349
  PGPASSWORD=1234 psql -h 0.0.0.0 -U postgres -d project_fixture -c "
350
350
  SELECT 'SELECT setval(''' || sequencename || ''', (SELECT COALESCE(MAX(id), 1) FROM ' ||
351
351
  replace(sequencename, '_id_seq', '') || '), true);'
@@ -354,34 +354,34 @@ WHERE schemaname = 'public' AND sequencename LIKE '%_id_seq';
354
354
  " | grep SELECT | PGPASSWORD=1234 psql -h 0.0.0.0 -U postgres -d project_fixture
355
355
  ```
356
356
 
357
- ### 6. 파일 저장 활용
357
+ ### 6. Using File Storage
358
358
 
359
- 파일로 저장하면 **버전 관리**가 가능합니다.
359
+ Saving to file enables **version control**.
360
360
 
361
361
  ```bash
362
- # 1. 파일로 저장
362
+ # 1. Save to file
363
363
  pnpm sonamu fixture gen --include User --count 10 --save-to file
364
364
  # → test/fixtures/users.json
365
365
 
366
- # 2. git에 커밋
366
+ # 2. Commit to git
367
367
  git add test/fixtures/users.json
368
368
  git commit -m "Add user fixtures for testing"
369
369
 
370
- # 3. 다른 개발자도 동일한 데이터로 테스트 가능
370
+ # 3. Other developers can test with the same data
371
371
  ```
372
372
 
373
- **언제 사용?**
374
- - CI/CD 환경에서 일관된 테스트 데이터 필요
375
- - 특정 시나리오 재현
376
- - 팀원 테스트 데이터 공유
373
+ **When to use**:
374
+ - Consistent test data needed in CI/CD environments
375
+ - Reproducing specific scenarios
376
+ - Sharing test data across team members
377
377
 
378
378
  ---
379
379
 
380
- ## 고급: cone 메타데이터 (선택사항)
380
+ ## Advanced: cone Metadata (Optional)
381
381
 
382
- Entity JSON에 `cone` 메타데이터를 추가하면 fixture 생성을 더욱 세밀하게 제어할 있습니다.
382
+ Adding `cone` metadata to Entity JSON gives you finer control over fixture generation.
383
383
 
384
- ### dataSource - 참조 전략 지정
384
+ ### dataSource - Specify a reference strategy
385
385
 
386
386
  ```json
387
387
  {
@@ -403,15 +403,15 @@ Entity JSON에 `cone` 메타데이터를 추가하면 fixture 생성을 더욱
403
403
  }
404
404
  ```
405
405
 
406
- **지원 전략**:
407
- - `sample`: 균등 샘플링
408
- - `recent`: 최근 데이터 (created_at 기준)
409
- - `random`: 랜덤 샘플링
410
- - `ids`: 특정 ID 지정
411
- - `query`: 사용자 정의 쿼리
412
- - `file`: 파일에서 로드
406
+ **Supported strategies**:
407
+ - `sample`: Uniform sampling
408
+ - `recent`: Most recent data (by created_at)
409
+ - `random`: Random sampling
410
+ - `ids`: Specific IDs
411
+ - `query`: Custom query
412
+ - `file`: Load from file
413
413
 
414
- ### fixtureGenerator - 커스텀 생성 로직
414
+ ### fixtureGenerator - Custom generation logic
415
415
 
416
416
  ```json
417
417
  {
@@ -423,9 +423,9 @@ Entity JSON에 `cone` 메타데이터를 추가하면 fixture 생성을 더욱
423
423
  }
424
424
  ```
425
425
 
426
- **보안 주의**: eval 사용으로 인한 보안 위험 (신뢰할 있는 표현식만 사용)
426
+ **Security note**: Security risk due to eval usage (only use trusted expressions)
427
427
 
428
- ### fixtureDefault - 기본값 지정
428
+ ### fixtureDefault - Specify a default value
429
429
 
430
430
  ```json
431
431
  {
@@ -437,152 +437,152 @@ Entity JSON에 `cone` 메타데이터를 추가하면 fixture 생성을 더욱
437
437
  }
438
438
  ```
439
439
 
440
- ### note - 설명 LLM 연동 트리거
440
+ ### note - Description and LLM trigger
441
441
 
442
442
  ```json
443
443
  {
444
444
  "name": "phone",
445
445
  "type": "string",
446
446
  "cone": {
447
- "note": "010-XXXX-XXXX 형식의 한국 전화번호"
447
+ "note": "Korean phone number in 010-XXXX-XXXX format"
448
448
  }
449
449
  }
450
450
  ```
451
451
 
452
- **동작 방식**:
453
- - `--use-llm` 없을 때: 개발자/LLM 참고용 설명 역할만 (cone-generator 읽어 메타데이터 생성 시 활용)
454
- - `--use-llm` 있을 때: fixture gen Claude API 호출하여 note 내용 기반의 실제 생성
452
+ **How it works**:
453
+ - Without `--use-llm`: serves only as a reference description for developers/LLMs (used by cone-generator when generating metadata)
454
+ - With `--use-llm`: fixture gen calls the Claude API and generates actual values based on the note content
455
455
 
456
- **용도**:
457
- - 단순 faker.js로 표현하기 어려운 맥락있는 텍스트 (자기소개, 설명문 )
458
- - 개발자에게 필드의 의미와 생성 패턴 설명
459
- - 길이 제한 없음 (짧은 패턴 또는 설명 모두 가능)
456
+ **Use cases**:
457
+ - Contextual text that is hard to express with simple faker.js (self-introductions, descriptions, etc.)
458
+ - Explaining the field's meaning and generation pattern to developers
459
+ - No length limit (short patterns or long descriptions are both fine)
460
460
 
461
461
  ---
462
462
 
463
- ### LLM 기반 데이터 생성
463
+ ### LLM-based Data Generation
464
464
 
465
- `--use-llm` 플래그를 사용하면 `cone.note`가 Claude API 호출 트리거로 작동합니다.
465
+ When the `--use-llm` flag is used, `cone.note` acts as the trigger for Claude API calls.
466
466
 
467
- #### 우선순위 체인
467
+ #### Priority chain
468
468
 
469
469
  ```
470
- 1. override (generate() 호출 시 전달)
471
- 2. cone.note + LLM ← --use-llm 플래그 활성화 (API key 있을 때 최우선)
472
- 3. fixtureGenerator (faker.js 표현식) ← LLM 실패 fallback
473
- 4. fixtureDefault (고정 기본값)
474
- 5. 타입별 기본값 (자동 생성)
470
+ 1. override value (passed at generate() call time)
471
+ 2. cone.note + LLM ← activated with --use-llm flag (highest priority when API key is present)
472
+ 3. fixtureGenerator (faker.js expression) ← fallback when LLM fails
473
+ 4. fixtureDefault (fixed default value)
474
+ 5. type-based default (auto-generated)
475
475
  ```
476
476
 
477
- #### CLI 사용법
477
+ #### CLI usage
478
478
 
479
479
  ```bash
480
- # LLM 활성화
480
+ # Enable LLM
481
481
  pnpm sonamu fixture gen --include User --count 10 --use-llm
482
482
 
483
- # 캐시 비활성화
483
+ # Disable cache
484
484
  pnpm sonamu fixture gen --include User --count 10 --use-llm --no-cache
485
485
  ```
486
486
 
487
- #### API 설정
487
+ #### API Key Setup
488
488
 
489
489
  ```bash
490
- # 방법 1: 환경변수
490
+ # Option 1: environment variable
491
491
  export ANTHROPIC_API_KEY=sk-ant-...
492
492
 
493
- # 방법 2: sonamu.config.ts
493
+ # Option 2: sonamu.config.ts
494
494
  export default defineConfig({
495
495
  secret: { anthropic_api_key: "sk-ant-..." }
496
496
  });
497
497
  ```
498
498
 
499
- #### 캐싱 동작
499
+ #### Caching behavior
500
500
 
501
- - `useLLM=true` 하나의 row에서 LLM 대상 필드 전체를 **단일 LLM 호출**로 생성 (필드별 개별 호출 아님)
502
- - 단일 호출 덕분에 `name`, `name_en`, `name_cn`, `email` 등 연관 필드 간 일관성이 자동으로 보장됨
503
- - 생성된 결과는 `rowKey:fieldName` 키로 인메모리 캐시에 저장되어, 같은 row 다음 필드 처리 시 즉시 반환
504
- - 캐시는 같은 FixtureGenerator 인스턴스 내에서만 유효
505
- - `--no-cache`로 캐시 비활성화 가능 (단, row 단위 생성 방식 자체는 유지됨)
501
+ - When `useLLM=true`, all LLM-targeted fields in a single row are generated in **a single LLM call** (not per-field individual calls)
502
+ - This single call guarantees automatic consistency across correlated fields such as `name`, `name_en`, `name_cn`, `email`
503
+ - Generated results are stored in an in-memory cache keyed by `rowKey:fieldName`, and returned immediately for subsequent fields in the same row
504
+ - Cache is valid only within the same FixtureGenerator instance
505
+ - Cache can be disabled with `--no-cache` (the row-level generation approach itself is preserved)
506
506
 
507
- #### Fallback 동작
507
+ #### Fallback behavior
508
508
 
509
- - API 없음 → fixtureDefault 또는 타입 기본값으로 fallback (에러 없음)
510
- - LLM 호출 실패동일하게 fallback (콘솔 경고만 출력)
509
+ - No API keyfalls back to fixtureDefault or type default (no error)
510
+ - LLM call failssame fallback (console warning only)
511
511
 
512
- #### note vs fixtureGenerator 선택 기준
512
+ #### When to choose note vs fixtureGenerator
513
513
 
514
- | 상황 | 추천 |
515
- |------|------|
516
- | 이메일, 이름, 숫자 단순한 | `fixtureGenerator` (faker.js) |
517
- | 자기소개, 설명문 맥락있는 텍스트 | `cone.note` + `--use-llm` (LLM) |
518
- | 특정 목록에서 선택 | `fixtureGenerator` (arrayElement) |
514
+ | Situation | Recommended |
515
+ |-----------|-------------|
516
+ | Simple values such as email, name, number | `fixtureGenerator` (faker.js) |
517
+ | Contextual text such as self-introductions or descriptions | `cone.note` + `--use-llm` (LLM) |
518
+ | Selecting from a specific list of values | `fixtureGenerator` (arrayElement) |
519
519
 
520
520
  ---
521
521
 
522
- ## FixtureGenerator 옵션 (FixtureGeneratorOptions)
522
+ ## FixtureGenerator Options (FixtureGeneratorOptions)
523
523
 
524
- **소스코드:** `modules/sonamu/src/testing/fixture-generator.ts`
524
+ **Source:** `modules/sonamu/src/testing/fixture-generator.ts`
525
525
 
526
- | 옵션 | 타입 | 기본값 | 설명 |
527
- |------|------|--------|------|
528
- | `locale` | `"ko"` \| `"en"` \| `"ja"` | `"ko"` | 생성 데이터 로케일 |
529
- | `useLLM` | boolean | `false` | LLM 기반 데이터 생성 (`--use-llm`) |
530
- | `enableLLMCache` | boolean | `true` | LLM 결과 캐싱 (`--no-cache`로 비활성화) |
531
- | `llmModel` | string | `"claude-sonnet-4-5"` | 사용할 LLM 모델 |
526
+ | Option | Type | Default | Description |
527
+ |--------|------|---------|-------------|
528
+ | `locale` | `"ko"` \| `"en"` \| `"ja"` | `"ko"` | Locale for generated data |
529
+ | `useLLM` | boolean | `false` | LLM-based data generation (`--use-llm`) |
530
+ | `enableLLMCache` | boolean | `true` | Cache LLM results (disable with `--no-cache`) |
531
+ | `llmModel` | string | `"claude-sonnet-4-5"` | LLM model to use |
532
532
 
533
533
  ---
534
534
 
535
- ## 문제 해결
535
+ ## Troubleshooting
536
536
 
537
- ### 문제 1: "Cannot generate non-nullable relation without dataSource"
537
+ ### Problem 1: "Cannot generate non-nullable relation without dataSource"
538
538
 
539
- **원인**: BelongsToOne relation nullable 아닌데 참조할 데이터가 없음
539
+ **Cause**: BelongsToOne relation is non-nullable but there is no data to reference
540
540
 
541
- **해결**:
541
+ **Solution**:
542
542
  ```bash
543
- # 참조 Entity 먼저 생성
543
+ # Generate the referenced Entity first
544
544
  pnpm sonamu fixture gen --include Company --count 5
545
545
 
546
- # 다음 Department 생성
546
+ # Then generate Department
547
547
  pnpm sonamu fixture gen --include Department --count 10
548
548
  ```
549
549
 
550
- 또는:
550
+ Or:
551
551
  ```bash
552
- # 함께 생성 (자동 순서 정렬)
552
+ # Generate together (auto-sorted by dependency order)
553
553
  pnpm sonamu fixture gen --include Company,Department --count 5
554
554
  ```
555
555
 
556
- ### 문제 2: "duplicate key value violates unique constraint"
556
+ ### Problem 2: "duplicate key value violates unique constraint"
557
557
 
558
- **원인**: unique constraint가 있는 필드에 중복 생성
558
+ **Cause**: Duplicate values generated for a field with a unique constraint
559
559
 
560
- **해결**:
561
- 1. `fixture-generator.ts`에서 해당 Entity의 필드별 생성 로직 수정
562
- 2. prefix/suffix 추가 또는 UUID 사용
563
- 3. count 줄이기
560
+ **Solution**:
561
+ 1. Modify the per-field generation logic for that Entity in `fixture-generator.ts`
562
+ 2. Add prefix/suffix or use UUID
563
+ 3. Reduce count
564
564
 
565
- ### 문제 3: FK 참조 오류 "violates foreign key constraint"
565
+ ### Problem 3: FK reference error "violates foreign key constraint"
566
566
 
567
- **원인**: sourceDbtargetDb 설정 문제
567
+ **Cause**: Incorrect sourceDb/targetDb configuration
568
568
 
569
- **확인**:
569
+ **Check**:
570
570
  ```typescript
571
- // fixture.ts 확인
571
+ // Verify in fixture.ts
572
572
  const fixtureDb = createKnexInstance(Sonamu.dbConfig.fixture);
573
573
  const generator = new FixtureGenerator(fixtureDb, fixtureDb, "fixture", EntityManager);
574
574
  ```
575
575
 
576
- **올바른 설정**:
576
+ **Correct configuration**:
577
577
  - `fixture gen`: sourceDb = fixtureDb, targetDb = fixtureDb
578
578
  - `fixture fetch`: sourceDb = production, targetDb = fixtureDb
579
579
 
580
580
  ---
581
581
 
582
- ## 참고 자료
582
+ ## References
583
583
 
584
- - **3-Tier DB 구조**: `database.md` "3-Tier DB 구조" 섹션
585
- - **Fixture 생성 팁**: `testing.md` "Fixture 데이터 생성 " 섹션
586
- - **BelongsToOne FK**: `entity-relations.md` "코드에서 FK 사용하기" 섹션
587
- - **실제 구현**: `modules/sonamu/src/bin/fixture.ts`
588
- - **생성 로직**: `modules/sonamu/src/testing/fixture-generator.ts`
584
+ - **3-Tier DB Structure**: "3-Tier DB Structure" section in `database.md`
585
+ - **Fixture generation tips**: "Fixture Data Generation Tips" section in `testing.md`
586
+ - **BelongsToOne FK**: "Using FK in Code" section in `entity-relations.md`
587
+ - **Implementation**: `modules/sonamu/src/bin/fixture.ts`
588
+ - **Generation logic**: `modules/sonamu/src/testing/fixture-generator.ts`