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.
- package/dist/api/__tests__/config.test.js +189 -0
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +7 -2
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +14 -10
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -1
- package/dist/auth/knex-adapter.d.ts +23 -0
- package/dist/auth/knex-adapter.d.ts.map +1 -0
- package/dist/auth/knex-adapter.js +163 -0
- package/dist/auth/plugins/wrappers/admin.d.ts +2 -2
- package/dist/bin/__tests__/ts-loader-register.test.js +45 -0
- package/dist/bin/cli.js +47 -9
- package/dist/bin/ts-loader-register.js +3 -29
- package/dist/bin/ts-loader-registration.d.ts +2 -0
- package/dist/bin/ts-loader-registration.d.ts.map +1 -0
- package/dist/bin/ts-loader-registration.js +42 -0
- package/dist/cone/cone-generator.js +3 -3
- package/dist/database/puri-subset.test-d.js +9 -1
- package/dist/database/puri-subset.types.d.ts +1 -1
- package/dist/database/puri-subset.types.d.ts.map +1 -1
- package/dist/database/puri-subset.types.js +1 -1
- package/dist/testing/fixture-generator.js +5 -5
- package/dist/ui/ai-client.js +2 -2
- package/dist/ui/api.d.ts.map +1 -1
- package/dist/ui/api.js +14 -14
- package/dist/ui/cdd-service.d.ts +15 -18
- package/dist/ui/cdd-service.d.ts.map +1 -1
- package/dist/ui/cdd-service.js +246 -222
- package/dist/ui/cdd-types.d.ts +41 -68
- package/dist/ui/cdd-types.d.ts.map +1 -1
- package/dist/ui/cdd-types.js +2 -2
- package/dist/ui-web/assets/index-CKo0Z2Iu.css +1 -0
- package/dist/ui-web/assets/{index-CxiydzeC.js → index-DK-2aacv.js} +83 -83
- package/dist/ui-web/index.html +2 -2
- package/package.json +6 -2
- package/src/api/__tests__/config.test.ts +225 -0
- package/src/api/config.ts +10 -4
- package/src/api/sonamu.ts +16 -13
- package/src/auth/index.ts +1 -0
- package/src/auth/knex-adapter.ts +208 -0
- package/src/bin/__tests__/ts-loader-register.test.ts +62 -0
- package/src/bin/cli.ts +52 -9
- package/src/bin/ts-loader-register.ts +2 -32
- package/src/bin/ts-loader-registration.ts +55 -0
- package/src/cone/cone-generator.ts +2 -2
- package/src/database/puri-subset.test-d.ts +102 -0
- package/src/database/puri-subset.types.ts +1 -1
- package/src/skills/commands/sonamu-skills.md +20 -0
- package/src/skills/sonamu/SKILL.md +179 -137
- package/src/skills/sonamu/ai-agents.md +69 -69
- package/src/skills/sonamu/api.md +147 -147
- package/src/skills/sonamu/auth-migration.md +220 -220
- package/src/skills/sonamu/auth-plugins.md +83 -83
- package/src/skills/sonamu/auth.md +106 -106
- package/src/skills/sonamu/cdd.md +65 -200
- package/src/skills/sonamu/cone.md +138 -138
- package/src/skills/sonamu/config.md +191 -191
- package/src/skills/sonamu/create-sonamu.md +66 -66
- package/src/skills/sonamu/database.md +158 -158
- package/src/skills/sonamu/entity-basic.md +292 -293
- package/src/skills/sonamu/entity-relations.md +246 -246
- package/src/skills/sonamu/entity-validation-checklist.md +124 -124
- package/src/skills/sonamu/fixture-cli.md +231 -231
- package/src/skills/sonamu/framework-change.md +37 -37
- package/src/skills/sonamu/frontend.md +223 -223
- package/src/skills/sonamu/i18n.md +82 -82
- package/src/skills/sonamu/migration.md +77 -77
- package/src/skills/sonamu/model.md +222 -222
- package/src/skills/sonamu/naite.md +86 -86
- package/src/skills/sonamu/project-init.md +228 -228
- package/src/skills/sonamu/puri.md +122 -122
- package/src/skills/sonamu/scaffolding.md +154 -154
- package/src/skills/sonamu/skill-contribution.md +124 -124
- package/src/skills/sonamu/subset.md +46 -46
- package/src/skills/sonamu/tasks.md +82 -82
- package/src/skills/sonamu/testing-devrunner.md +147 -147
- package/src/skills/sonamu/testing.md +673 -673
- package/src/skills/sonamu/upsert.md +79 -79
- package/src/skills/sonamu/vector.md +67 -67
- package/src/testing/fixture-generator.ts +4 -4
- package/src/ui/ai-client.ts +1 -1
- package/src/ui/api.ts +18 -17
- package/src/ui/cdd-service.ts +264 -254
- package/src/ui/cdd-types.ts +40 -75
- package/dist/ui-web/assets/index-BrQKU3j9.css +0 -1
- package/src/skills/sonamu/workflow.md +0 -317
|
@@ -1,92 +1,92 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sonamu-skill-contribution
|
|
3
|
-
description:
|
|
3
|
+
description: Workflow for reflecting troubleshooting resolutions into skills. Covers existing skill matching, duplication check, format standards, and user approval gate. Use when a troubleshooting session concludes and the resolution should be captured as reusable knowledge.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Troubleshooting → Skill Contribution Workflow
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The process for capturing knowledge from a resolved troubleshooting session into skills.
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Triggers
|
|
13
13
|
|
|
14
|
-
|
|
|
15
|
-
|
|
16
|
-
|
|
|
17
|
-
|
|
|
14
|
+
| Trigger | Owner | Example |
|
|
15
|
+
|---------|-------|---------|
|
|
16
|
+
| **Explicit request** | User | "Document this in skills", "Record this fix" |
|
|
17
|
+
| **Agent suggestion** | Agent | When a detection pattern below is met, propose: "Should I add this to skills?" |
|
|
18
18
|
|
|
19
|
-
###
|
|
19
|
+
### Agent detection patterns
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Suggest contribution when the following flow is observed in the conversation:
|
|
22
22
|
|
|
23
|
-
1.
|
|
24
|
-
2.
|
|
25
|
-
3.
|
|
23
|
+
1. **Error/failure → investigation → fix → success** pattern completes
|
|
24
|
+
2. The resolution reveals **internal framework behavior** or **undocumented constraints**
|
|
25
|
+
3. The same problem is **likely to occur in other projects or for other users**
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
27
|
+
Do not suggest when:
|
|
28
|
+
- Simple typos or missing imports
|
|
29
|
+
- Project-specific business logic bugs
|
|
30
|
+
- One-off environment issues (e.g., port conflict on a specific machine)
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## Steps
|
|
35
35
|
|
|
36
36
|
```
|
|
37
|
-
[1]
|
|
38
|
-
[2]
|
|
39
|
-
[3]
|
|
40
|
-
[4]
|
|
41
|
-
[5]
|
|
42
|
-
[6]
|
|
37
|
+
[1] Extract — summarize problem / cause / solution / source
|
|
38
|
+
[2] Match — compare against existing skills
|
|
39
|
+
[3] Decide — determine where to put it
|
|
40
|
+
[4] Draft — write the content
|
|
41
|
+
[5] Approve — get user confirmation
|
|
42
|
+
[6] Apply — update or create the file
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
---
|
|
46
46
|
|
|
47
|
-
## [1]
|
|
47
|
+
## [1] Extract
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Summarize from the conversation using the following structure:
|
|
50
50
|
|
|
51
51
|
```yaml
|
|
52
|
-
symptom: "
|
|
53
|
-
cause: "
|
|
54
|
-
solution: "
|
|
55
|
-
source_paths: #
|
|
52
|
+
symptom: "one-line description (error message or observed behavior)"
|
|
53
|
+
cause: "explanation of root cause"
|
|
54
|
+
solution: "resolution steps (include specific commands/code)"
|
|
55
|
+
source_paths: # related source file paths
|
|
56
56
|
- "src/testing/dev-vitest-manager.ts"
|
|
57
|
-
tags: #
|
|
57
|
+
tags: # keywords for matching
|
|
58
58
|
- "testing"
|
|
59
59
|
- "devrunner"
|
|
60
|
-
scope: "sonamu" # "sonamu" (
|
|
60
|
+
scope: "sonamu" # "sonamu" (framework-level) or "local" (project-specific)
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
###
|
|
63
|
+
### Scope decision criteria
|
|
64
64
|
|
|
65
|
-
|
|
|
66
|
-
|
|
67
|
-
| Sonamu
|
|
68
|
-
| Sonamu CLI, config, migration
|
|
69
|
-
|
|
|
70
|
-
|
|
|
65
|
+
| Condition | scope |
|
|
66
|
+
|-----------|-------|
|
|
67
|
+
| Relates to Sonamu framework behavior or constraints | `sonamu` |
|
|
68
|
+
| Relates to Sonamu CLI, config, migration, or shared tooling | `sonamu` |
|
|
69
|
+
| Relates to a specific project's business logic or configuration | `local` |
|
|
70
|
+
| Unclear | Ask the user |
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
-
## [2]
|
|
74
|
+
## [2] Match — Compare Against Existing Skills
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
**Always read existing skills first and check for duplication.** Creating a new file is a last resort.
|
|
77
77
|
|
|
78
|
-
###
|
|
78
|
+
### Match priority
|
|
79
79
|
|
|
80
|
-
|
|
|
81
|
-
|
|
82
|
-
| 1 |
|
|
83
|
-
| 2 |
|
|
84
|
-
| 3 | **SKILL.md
|
|
80
|
+
| Priority | Method | Description |
|
|
81
|
+
|----------|--------|-------------|
|
|
82
|
+
| 1 | **Source paths** | Check whether `source_paths` overlap with source references in existing skills |
|
|
83
|
+
| 2 | **Tags/keywords** | Compare against each skill's YAML `description` and tags |
|
|
84
|
+
| 3 | **SKILL.md task table** | Cross-reference which task row maps to the problem domain |
|
|
85
85
|
|
|
86
|
-
###
|
|
86
|
+
### Source path → skill mapping (key paths)
|
|
87
87
|
|
|
88
|
-
|
|
|
89
|
-
|
|
88
|
+
| Source path pattern | Corresponding skill |
|
|
89
|
+
|---------------------|---------------------|
|
|
90
90
|
| `src/testing/*` | testing.md, testing-devrunner.md, naite.md, fixture-cli.md |
|
|
91
91
|
| `src/database/puri*` | puri.md |
|
|
92
92
|
| `src/database/migrator*` | migration.md |
|
|
@@ -99,144 +99,144 @@ scope: "sonamu" # "sonamu" (공식) 또는 "local" (프로젝트 고유)
|
|
|
99
99
|
| `src/api/*` | api.md |
|
|
100
100
|
| `src/template/*` | framework-change.md |
|
|
101
101
|
| `src/model/*` | model.md |
|
|
102
|
-
| `src/ssr/*` | (
|
|
103
|
-
| `sonamu.config.ts`
|
|
102
|
+
| `src/ssr/*` | (no skill — candidate for new file) |
|
|
103
|
+
| `sonamu.config.ts` related | config.md |
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
If the path is not in this table, fall through to tag/keyword matching.
|
|
106
106
|
|
|
107
|
-
###
|
|
107
|
+
### Matching steps
|
|
108
108
|
|
|
109
|
-
1.
|
|
110
|
-
2.
|
|
111
|
-
3.
|
|
109
|
+
1. Read the Skills list table in `SKILL.md`
|
|
110
|
+
2. Read candidate skill files (1–3 files)
|
|
111
|
+
3. Check whether **identical or similar content already exists** in those skills
|
|
112
112
|
|
|
113
113
|
---
|
|
114
114
|
|
|
115
|
-
## [3]
|
|
115
|
+
## [3] Decide
|
|
116
116
|
|
|
117
|
-
|
|
|
118
|
-
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
117
|
+
| Match result | Decision | Description |
|
|
118
|
+
|--------------|----------|-------------|
|
|
119
|
+
| **Same content exists** in an existing skill | **SKIP** | Report: "Already documented in {skill}.md" |
|
|
120
|
+
| Match found + skill has **troubleshooting section** | **APPEND** | Add item to existing section |
|
|
121
|
+
| Match found + skill has **no troubleshooting section** | **ADD_SECTION** | Add a new troubleshooting section at the end |
|
|
122
|
+
| No match + scope=`sonamu` | **NEW_FILE** | Create a new skill file (rare) |
|
|
123
|
+
| No match + scope=`local` | **LOCAL** | Create in `.claude/skills/local/` |
|
|
124
124
|
|
|
125
|
-
**CRITICAL: APPEND
|
|
125
|
+
**CRITICAL: APPEND and ADD_SECTION should account for the vast majority of cases.** NEW_FILE is only for when the content genuinely does not fit anywhere in the existing skills.
|
|
126
126
|
|
|
127
127
|
---
|
|
128
128
|
|
|
129
|
-
## [4]
|
|
129
|
+
## [4] Draft — Format Standards
|
|
130
130
|
|
|
131
|
-
###
|
|
131
|
+
### Troubleshooting section format
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
Use the pattern from `testing-devrunner.md` as the standard:
|
|
134
134
|
|
|
135
135
|
```markdown
|
|
136
|
-
##
|
|
136
|
+
## Troubleshooting
|
|
137
137
|
|
|
138
|
-
### "
|
|
139
|
-
→
|
|
140
|
-
→
|
|
138
|
+
### "Error message or one-line symptom"
|
|
139
|
+
→ Explanation of root cause
|
|
140
|
+
→ Fix: specific resolution (commands / code / config)
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
List multiple items as separate `###` entries.
|
|
144
144
|
|
|
145
|
-
###
|
|
145
|
+
### Example — APPEND
|
|
146
146
|
|
|
147
|
-
cone.md
|
|
147
|
+
Adding to cone.md:
|
|
148
148
|
|
|
149
149
|
```markdown
|
|
150
|
-
### "pnpm sonamu cone gen --all
|
|
151
|
-
→ .env
|
|
152
|
-
→
|
|
150
|
+
### "pnpm sonamu cone gen --all fails with 'ANTHROPIC_API_KEY is not set'"
|
|
151
|
+
→ Key is missing from .env or was set only in root .env rather than packages/api/.env
|
|
152
|
+
→ Fix: add `ANTHROPIC_API_KEY=sk-ant-...` to `packages/api/.env`
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
###
|
|
155
|
+
### Example — ADD_SECTION
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
Adding a new section at the end of puri.md:
|
|
158
158
|
|
|
159
159
|
```markdown
|
|
160
160
|
---
|
|
161
161
|
|
|
162
|
-
##
|
|
162
|
+
## Troubleshooting
|
|
163
163
|
|
|
164
|
-
### "
|
|
165
|
-
→ Puri
|
|
166
|
-
→
|
|
164
|
+
### "nullable field type inferred as non-null after leftJoin"
|
|
165
|
+
→ Puri type inference does not account for join direction. leftJoin results may be null at runtime but are not reflected as optional in the types.
|
|
166
|
+
→ Fix: explicitly mark the field as optional in the subset, or add a null check at the call site
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
###
|
|
169
|
+
### Example — LOCAL
|
|
170
170
|
|
|
171
171
|
`.claude/skills/local/kopri-deployment.md`:
|
|
172
172
|
|
|
173
173
|
```markdown
|
|
174
174
|
---
|
|
175
175
|
name: kopri-deployment
|
|
176
|
-
description:
|
|
176
|
+
description: Deployment notes for the KOPRI project. Use when deploying KOPRI project.
|
|
177
177
|
---
|
|
178
178
|
|
|
179
|
-
# KOPRI
|
|
179
|
+
# KOPRI Deployment Troubleshooting
|
|
180
180
|
|
|
181
|
-
##
|
|
181
|
+
## Troubleshooting
|
|
182
182
|
|
|
183
|
-
### "
|
|
184
|
-
→ Alpine
|
|
185
|
-
→
|
|
183
|
+
### "sharp package installation fails during Docker build"
|
|
184
|
+
→ Alpine image is missing native dependencies for sharp
|
|
185
|
+
→ Fix: add `RUN apk add --no-cache vips-dev` to Dockerfile
|
|
186
186
|
```
|
|
187
187
|
|
|
188
188
|
---
|
|
189
189
|
|
|
190
|
-
## [5]
|
|
190
|
+
## [5] Approve — User Confirmation Gate
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
Show the user:
|
|
193
193
|
|
|
194
|
-
1.
|
|
195
|
-
2.
|
|
196
|
-
3.
|
|
194
|
+
1. **Decision**: where to put it + one-line reason
|
|
195
|
+
2. **Content preview**: the markdown to be added or modified
|
|
196
|
+
3. **Approval request**
|
|
197
197
|
|
|
198
198
|
```
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
Decision: APPEND — adding troubleshooting entry to cone.md
|
|
200
|
+
Reason: source_paths match src/cone/; troubleshooting section already exists in cone.md
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
### "cone gen
|
|
202
|
+
Content to add:
|
|
203
|
+
### "cone gen fails with 'No entity found'"
|
|
204
204
|
→ ...
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
Shall I apply this?
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
**Do not apply without approval.**
|
|
210
210
|
|
|
211
211
|
---
|
|
212
212
|
|
|
213
|
-
## [6]
|
|
213
|
+
## [6] Apply
|
|
214
214
|
|
|
215
|
-
|
|
|
216
|
-
|
|
217
|
-
| SKIP |
|
|
218
|
-
| APPEND |
|
|
219
|
-
| ADD_SECTION |
|
|
220
|
-
| NEW_FILE |
|
|
221
|
-
| LOCAL | `.claude/skills/local/{name}.md`
|
|
215
|
+
| Decision | Action |
|
|
216
|
+
|----------|--------|
|
|
217
|
+
| SKIP | None |
|
|
218
|
+
| APPEND | Add `###` entry to the troubleshooting section in the skill |
|
|
219
|
+
| ADD_SECTION | Add `## Troubleshooting` section + entry at the end of the skill (just before `## References` if it exists, otherwise at the very end) |
|
|
220
|
+
| NEW_FILE | Create new .md file + **register in both tables in SKILL.md** |
|
|
221
|
+
| LOCAL | Create `.claude/skills/local/{name}.md` |
|
|
222
222
|
|
|
223
|
-
### ADD_SECTION
|
|
223
|
+
### ADD_SECTION insertion position
|
|
224
224
|
|
|
225
|
-
- `##
|
|
226
|
-
-
|
|
225
|
+
- If a `## References` section exists, insert **immediately before it**
|
|
226
|
+
- Otherwise, insert at the **very end** of the file
|
|
227
227
|
|
|
228
|
-
### NEW_FILE
|
|
228
|
+
### NEW_FILE required actions
|
|
229
229
|
|
|
230
|
-
1. `skills/sonamu/`
|
|
231
|
-
2. YAML frontmatter (name, description)
|
|
232
|
-
3.
|
|
233
|
-
4.
|
|
234
|
-
5.
|
|
230
|
+
1. Create file in `skills/sonamu/`
|
|
231
|
+
2. Include YAML frontmatter (name, description)
|
|
232
|
+
3. Add a row to the "Skills List" table in `SKILL.md`
|
|
233
|
+
4. Add a row to the "Task-to-Skill" table in `SKILL.md`
|
|
234
|
+
5. If a related PHASE exists in `.claude/workflow/project_init.md`, add the new skill to its reference skills
|
|
235
235
|
|
|
236
236
|
---
|
|
237
237
|
|
|
238
|
-
##
|
|
238
|
+
## References
|
|
239
239
|
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
240
|
+
- **Skill list and structure**: `SKILL.md`
|
|
241
|
+
- **Agent rules**: `AGENTS.md`
|
|
242
|
+
- **Project-local skills**: `.claude/skills/local/`
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sonamu-subset
|
|
3
|
-
description:
|
|
3
|
+
description: Define API response field scope with Sonamu Subsets. Include relation fields using dot notation. Use when defining which fields to return in API responses.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Subset
|
|
6
|
+
# Subset Definition
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
- `sonamu/examples/miomock/api/src/application/project/project.entity.json` -
|
|
10
|
-
- `sonamu/examples/miomock/api/src/application/employee/employee.entity.json` -
|
|
8
|
+
**Working code references:**
|
|
9
|
+
- `sonamu/examples/miomock/api/src/application/project/project.entity.json` - complex Subset example
|
|
10
|
+
- `sonamu/examples/miomock/api/src/application/employee/employee.entity.json` - basic Subset example
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Basic Structure
|
|
13
13
|
|
|
14
14
|
```json
|
|
15
15
|
{
|
|
@@ -21,20 +21,20 @@ description: Sonamu Subset으로 API 응답 필드 범위 정의. dot notation
|
|
|
21
21
|
}
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
##
|
|
24
|
+
## Naming Conventions
|
|
25
25
|
|
|
26
|
-
**WARNING:
|
|
26
|
+
**WARNING: Only use A, P, and SS as Subset names. Do not use arbitrary names like S, D, or L.**
|
|
27
27
|
|
|
28
|
-
| Subset |
|
|
29
|
-
|
|
30
|
-
| `A` | All -
|
|
31
|
-
| `P` | Partial/Profile -
|
|
32
|
-
| `SS` | Super Simple/Summary -
|
|
33
|
-
| `P2`, `P3` |
|
|
28
|
+
| Subset | Purpose |
|
|
29
|
+
|--------|---------|
|
|
30
|
+
| `A` | All - all fields (detail view, admin). **Required** |
|
|
31
|
+
| `P` | Partial/Profile - partial fields including relations (for list views) |
|
|
32
|
+
| `SS` | Super Simple/Summary - minimal fields, just ID + name (for dropdowns, selects) |
|
|
33
|
+
| `P2`, `P3` | Additional profiles (only for special cases) |
|
|
34
34
|
|
|
35
|
-
### IMPORTANT: Subset A
|
|
35
|
+
### IMPORTANT: Subset A Must Include All Fields
|
|
36
36
|
|
|
37
|
-
**Subset A
|
|
37
|
+
**Subset A must include all regular fields and major relation fields of the Entity.**
|
|
38
38
|
|
|
39
39
|
**DO:**
|
|
40
40
|
```json
|
|
@@ -56,38 +56,38 @@ description: Sonamu Subset으로 API 응답 필드 범위 정의. dot notation
|
|
|
56
56
|
```json
|
|
57
57
|
{
|
|
58
58
|
"subsets": {
|
|
59
|
-
"A": ["id", "title"] // created_at, status, author
|
|
59
|
+
"A": ["id", "title"] // created_at, status, author omitted - incorrect
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
- BelongsToOne
|
|
67
|
-
- HasMany
|
|
64
|
+
**Rules:**
|
|
65
|
+
- Include all regular fields (id, created_at, business fields, etc.)
|
|
66
|
+
- For BelongsToOne relations, include at least `.id` and a display field (`.name`, `.title`, etc.)
|
|
67
|
+
- HasMany relations are optional (include only when needed)
|
|
68
68
|
|
|
69
|
-
###
|
|
69
|
+
### When Only a Single Subset Is Needed
|
|
70
70
|
|
|
71
71
|
```json
|
|
72
|
-
// DO - Correct: A
|
|
72
|
+
// DO - Correct: create only A
|
|
73
73
|
{ "subsets": { "A": ["id", "name", "created_at"] } }
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
### DO NOT - Incorrect Subset Names
|
|
77
77
|
|
|
78
78
|
```json
|
|
79
|
-
// Incorrect: S, D, L
|
|
79
|
+
// Incorrect: do not use S, D, L, etc.
|
|
80
80
|
{
|
|
81
81
|
"subsets": {
|
|
82
82
|
"A": [...],
|
|
83
|
-
"S": [...], // NEVER - SS
|
|
84
|
-
"D": [...], // NEVER -
|
|
85
|
-
"L": [...] // NEVER - P
|
|
83
|
+
"S": [...], // NEVER - use SS instead
|
|
84
|
+
"D": [...], // NEVER - do not use
|
|
85
|
+
"L": [...] // NEVER - use P instead
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
## Relation
|
|
90
|
+
## Relation Fields (Dot Notation)
|
|
91
91
|
|
|
92
92
|
```json
|
|
93
93
|
{
|
|
@@ -102,18 +102,18 @@ description: Sonamu Subset으로 API 응답 필드 범위 정의. dot notation
|
|
|
102
102
|
}
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
- BelongsToOne/OneToOne:
|
|
106
|
-
- HasMany/ManyToMany:
|
|
105
|
+
- BelongsToOne/OneToOne: automatic LEFT JOIN
|
|
106
|
+
- HasMany/ManyToMany: automatically optimized with DataLoader
|
|
107
107
|
|
|
108
|
-
## ID
|
|
108
|
+
## ID-Only Reference Optimization
|
|
109
109
|
|
|
110
110
|
```json
|
|
111
111
|
{ "SS": ["id", "title", "user.id"] }
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
- `user.id
|
|
114
|
+
- Referencing only `user.id` reads the `user_id` column directly without a JOIN
|
|
115
115
|
|
|
116
|
-
## Internal
|
|
116
|
+
## Internal Fields
|
|
117
117
|
|
|
118
118
|
```json
|
|
119
119
|
{
|
|
@@ -123,9 +123,9 @@ description: Sonamu Subset으로 API 응답 필드 범위 정의. dot notation
|
|
|
123
123
|
}
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
-
|
|
126
|
+
- Included in the query but excluded from the API response type
|
|
127
127
|
|
|
128
|
-
##
|
|
128
|
+
## Usage in Models
|
|
129
129
|
|
|
130
130
|
```typescript
|
|
131
131
|
// findById
|
|
@@ -145,22 +145,22 @@ const result = await UserModel.executeSubsetQuery({
|
|
|
145
145
|
});
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
##
|
|
148
|
+
## Notes
|
|
149
149
|
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
-
- **FK
|
|
150
|
+
- The base Subset `A` is required
|
|
151
|
+
- Nesting depth of 3 or fewer levels is recommended
|
|
152
|
+
- Exclude unnecessary relations from list-purpose Subsets
|
|
153
|
+
- **Use relation notation for FK columns**: FK columns for BelongsToOne relations (e.g. `user_id`) must be accessed in Subsets using the `user.id` form. This is because Sonamu recognizes the relation notation and automatically optimizes by reading the FK column directly when only `.id` is referenced.
|
|
154
154
|
|
|
155
155
|
```json
|
|
156
|
-
// DO NOT - Incorrect: FK
|
|
156
|
+
// DO NOT - Incorrect: using FK column directly
|
|
157
157
|
{ "A": ["id", "user_id", "title"] }
|
|
158
158
|
|
|
159
|
-
// DO - Correct: relation.field
|
|
159
|
+
// DO - Correct: use relation.field format (auto-optimized)
|
|
160
160
|
{ "A": ["id", "user.id", "title"] }
|
|
161
|
-
// → Sonamu
|
|
161
|
+
// → Sonamu reads the user_id column directly (no JOIN)
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
- `sonamu/examples/miomock/api/src/application/project/project.entity.json` - Subset
|
|
166
|
-
- `sonamu/examples/miomock/api/src/application/employee/employee.entity.json` - BelongsToOne
|
|
164
|
+
**Working code references:**
|
|
165
|
+
- `sonamu/examples/miomock/api/src/application/project/project.entity.json` - Subset definition examples
|
|
166
|
+
- `sonamu/examples/miomock/api/src/application/employee/employee.entity.json` - BelongsToOne relation examples
|