sonamu 0.10.7 → 0.10.9

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 (79) hide show
  1. package/dist/api/decorators.d.ts.map +1 -1
  2. package/dist/api/decorators.js +5 -12
  3. package/dist/bin/cli.js +10 -253
  4. package/dist/database/base-model.d.ts +1 -0
  5. package/dist/database/base-model.d.ts.map +1 -1
  6. package/dist/database/base-model.js +14 -8
  7. package/dist/database/db.d.ts +2 -1
  8. package/dist/database/db.d.ts.map +1 -1
  9. package/dist/database/db.js +13 -3
  10. package/dist/database/puri-wrapper.d.ts.map +1 -1
  11. package/dist/database/puri-wrapper.js +4 -11
  12. package/dist/database/transaction-context.d.ts +8 -3
  13. package/dist/database/transaction-context.d.ts.map +1 -1
  14. package/dist/database/transaction-context.js +12 -7
  15. package/dist/migration/code-generation.js +2 -2
  16. package/dist/naite/naite-reporter.d.ts +8 -3
  17. package/dist/naite/naite-reporter.d.ts.map +1 -1
  18. package/dist/naite/naite-reporter.js +9 -4
  19. package/dist/ui-web/assets/{index-D0MHYbxl.js → index-CJf8uJYf.js} +47 -41
  20. package/dist/ui-web/assets/index-GMMIVGja.css +1 -0
  21. package/dist/ui-web/index.html +2 -2
  22. package/package.json +3 -3
  23. package/src/api/decorators.ts +11 -22
  24. package/src/bin/cli.ts +12 -375
  25. package/src/database/__tests__/transaction-scope.test.ts +227 -0
  26. package/src/database/base-model.ts +31 -6
  27. package/src/database/db.ts +17 -2
  28. package/src/database/puri-wrapper.ts +5 -22
  29. package/src/database/transaction-context.ts +14 -6
  30. package/src/migration/code-generation.ts +1 -1
  31. package/src/naite/naite-reporter.ts +8 -3
  32. package/dist/ui-web/assets/index-Dx_JX4aQ.css +0 -1
  33. package/src/skills/AGENTS.md +0 -108
  34. package/src/skills/sonamu/SKILL.md +0 -75
  35. package/src/skills/sonamu-ai-agents/SKILL.md +0 -205
  36. package/src/skills/sonamu-api/SKILL.md +0 -480
  37. package/src/skills/sonamu-auth/SKILL.md +0 -327
  38. package/src/skills/sonamu-auth/references/plugins.md +0 -310
  39. package/src/skills/sonamu-auth/references/user-id-migration-followups.md +0 -192
  40. package/src/skills/sonamu-auth/references/user-id-migration.md +0 -455
  41. package/src/skills/sonamu-config/SKILL.md +0 -203
  42. package/src/skills/sonamu-config/references/database.md +0 -452
  43. package/src/skills/sonamu-config/references/environments.md +0 -178
  44. package/src/skills/sonamu-config/references/server-options.md +0 -400
  45. package/src/skills/sonamu-entity/SKILL.md +0 -180
  46. package/src/skills/sonamu-entity/references/creation-workflow.md +0 -581
  47. package/src/skills/sonamu-entity/references/design-guides.md +0 -243
  48. package/src/skills/sonamu-entity/references/field-types.md +0 -170
  49. package/src/skills/sonamu-entity/references/relations-detail.md +0 -245
  50. package/src/skills/sonamu-entity/references/relations.md +0 -463
  51. package/src/skills/sonamu-entity/references/subset.md +0 -156
  52. package/src/skills/sonamu-fixture/SKILL.md +0 -180
  53. package/src/skills/sonamu-fixture/references/cli-usage.md +0 -439
  54. package/src/skills/sonamu-fixture/references/cone.md +0 -298
  55. package/src/skills/sonamu-frontend/SKILL.md +0 -142
  56. package/src/skills/sonamu-frontend/references/components.md +0 -323
  57. package/src/skills/sonamu-frontend/references/examples.md +0 -64
  58. package/src/skills/sonamu-frontend/references/hooks.md +0 -273
  59. package/src/skills/sonamu-frontend/references/runtime.md +0 -165
  60. package/src/skills/sonamu-frontend/references/scaffolding.md +0 -439
  61. package/src/skills/sonamu-i18n/SKILL.md +0 -287
  62. package/src/skills/sonamu-migration/SKILL.md +0 -316
  63. package/src/skills/sonamu-naite/SKILL.md +0 -266
  64. package/src/skills/sonamu-query/SKILL.md +0 -48
  65. package/src/skills/sonamu-query/references/model-patterns.md +0 -390
  66. package/src/skills/sonamu-query/references/model.md +0 -366
  67. package/src/skills/sonamu-query/references/puri.md +0 -413
  68. package/src/skills/sonamu-query/references/search.md +0 -238
  69. package/src/skills/sonamu-query/references/upsert.md +0 -324
  70. package/src/skills/sonamu-tasks/SKILL.md +0 -236
  71. package/src/skills/sonamu-testing/SKILL.md +0 -251
  72. package/src/skills/sonamu-testing/references/devrunner.md +0 -405
  73. package/src/skills/sonamu-testing/references/helpers.md +0 -185
  74. package/src/skills/sonamu-testing/references/patterns.md +0 -263
  75. package/src/skills/sonamu-testing/references/pitfalls.md +0 -588
  76. package/src/skills/sonamu-testing/references/quick-start.md +0 -285
  77. package/src/skills/sonamu-testing/references/type-safety.md +0 -172
  78. package/src/skills/sonamu-testing/references/writing-plan.md +0 -375
  79. package/src/skills/sonamu-vector/SKILL.md +0 -222
@@ -1,180 +0,0 @@
1
- ---
2
- name: sonamu-entity
3
- description: Defines and modifies Sonamu entities: fields, relationships, subsets, and the sync pipeline. Use when creating or editing an entity.json, adding a field or enum, wiring BelongsToOne/HasMany/ManyToMany/parentId, defining a subset, or resolving a schema validation or sync error. Covers stub entity, sonamu sync, dbDefault, OrderBy enums, FieldExpr, and nullable handling in types.ts.
4
- ---
5
-
6
- # Sonamu Entity
7
-
8
- **Working code references:**
9
-
10
- - `sonamu/examples/miomock/api/src/application/user/user.entity.json` — basic entity
11
- - `sonamu/examples/miomock/api/src/application/project/project.entity.json` — complex entity
12
- - `sonamu/examples/miomock/api/src/application/employee/employee.entity.json` — BelongsToOne
13
-
14
- ## Reference Map
15
-
16
- | Need | Read |
17
- | --- | --- |
18
- | Step-by-step creation, validation before/after sync, migration and scaffolding checks | `references/creation-workflow.md` |
19
- | Field types, dbDefault, OrderBy enum rules, integer vs number, ENUM defaults | `references/field-types.md` |
20
- | Choosing a relationship type, BelongsToOne/HasMany/OneToOne/ManyToMany/self-reference, parentId | `references/relations.md` |
21
- | FK reference rules (FieldExpr), relationships inside subsets, ManyToMany type definitions | `references/relations-detail.md` |
22
- | Response field scope, naming conventions, ID-only optimization | `references/subset.md` |
23
- | Domain-specific design patterns and worked examples | `references/design-guides.md` |
24
-
25
- Migration execution and schema-change errors live in the `sonamu-migration` skill.
26
- cone metadata and fixture generation live in `sonamu-fixture`.
27
-
28
- ---
29
-
30
- ## Prerequisite: CRITICAL
31
-
32
- **Always run `pnpm dev` in `packages/api` before creating or editing an entity.**
33
-
34
- ```bash
35
- cd packages/api
36
- pnpm dev # keep running for all entity work
37
- ```
38
-
39
- In dev mode the syncer detects `entity.json` changes and auto-generates `types.ts`. This is
40
- required for **all** entity creation, not just auth entities.
41
-
42
- ---
43
-
44
- ## When a User Requests a New System
45
-
46
- When the user requests a system to be built, proceed in the following order:
47
-
48
- **1. Analyze requirements** (identify missing entities)
49
-
50
- - "Do you need a User entity?"
51
- - "Are there any other entities needed?"
52
-
53
- **2. Confirm relationships between entities** (one question at a time)
54
-
55
- - "Is A to B a 1:N or N:M relationship?"
56
- - "Should chapters be managed as children of courses?"
57
-
58
- **3. Decide whether to use parentId**
59
-
60
- - "Can it exist without a parent?"
61
- - "Should it be created and deleted together with the parent?"
62
-
63
- **4. Final confirmation with the user**
64
-
65
- - Finalize entity list
66
- - Provide a relationship diagram or clear description
67
-
68
- ### Entity Design Done Checklist
69
-
70
- - [ ] All required entities identified
71
- - [ ] Relationships between entities defined
72
- - [ ] parentId usage decided
73
- - [ ] User confirmation complete
74
-
75
- **When done:** proceed to "Entity Creation Workflow"
76
-
77
- ---
78
-
79
-
80
- ## Checklist for New Entity Creation
81
-
82
- 1. **id**: PascalCase (e.g., `User`, `BlogPost`)
83
- 2. **table**: snake_case plural (e.g., `users`, `blog_posts`) — can be omitted
84
- 3. **title**: display name
85
- 4. **Recommended props**: `id`, `created_at` (not enforced by schema but best practice)
86
- 5. **Recommended enums**: `{EntityId}OrderBy`, `{EntityId}SearchField` (not enforced but best practice)
87
-
88
- ## IMPORTANT: Analyze Requirements Before Creating Entity
89
-
90
- **STOP! Ask questions one at a time before creating any entity.**
91
-
92
- ### Identify missing entities
93
-
94
- Do not only create entities explicitly mentioned by the user. **Ask one at a time:**
95
-
96
- - "Do you need a User entity?" → wait for response
97
- - "Does the User have multiple roles?" → wait for response
98
- - "Are there any other entities needed?" → wait for response
99
-
100
- **Note on User entity**: `id` is an auto-increment sequence (PK) and is not a login ID. When using better-auth, a separate `login_id` is not needed (managed by the auth table).
101
-
102
- **Commonly missed entities**: Content (Comment, Like, Tag, Category), Commerce (Review, Cart, Payment), Reservation (Reservation, Schedule), Education (Enrollment, Progress)
103
-
104
- ### When multiple entities are requested — confirm relationships
105
-
106
- When 2+ entities are requested, **ask about relationships one at a time before writing any code**:
107
-
108
- - Which relationship type: BelongsToOne, HasMany, ManyToMany, or parentId
109
- - Whether it is a parent-child dependency (delete together) or independent
110
-
111
- ### Always confirm before designing
112
-
113
- **1. Polymorphic Association** (`entity_type + entity_id` pattern):
114
-
115
- - If there is a string PK entity (e.g., better-auth User) → use `string` type for `entity_id` uniformly
116
- - Otherwise → `integer` is fine
117
-
118
- **2. Domain term ↔ entity English ID mapping**: finalize with the user before writing any code (e.g., "위탁연구과제" → `ResearchContract`). Changing this later requires a full rename.
119
-
120
- ## Parent-Child Relationships (parentId)
121
-
122
- ### What is parentId?
123
-
124
- A top-level option used when a child entity is managed as a dependent of a parent entity.
125
-
126
- - With parentId: the child has no independent CRUD — it is created, updated, and deleted through the parent
127
- - Without parentId: an independent entity with its own CRUD
128
-
129
- ### When to use parentId
130
-
131
- | Situation | parentId | Example |
132
- | ---------------------------------------- | -------- | ---------------------------------- |
133
- | Cannot exist without a parent | Yes | OrderItem → Order |
134
- | Created and deleted together with parent | Yes | Chapter → Course, Lesson → Chapter |
135
- | Can be independently CRUD'd | No | Comment → Post |
136
- | Can belong to multiple parents | No | Tag → Post (ManyToMany) |
137
-
138
- ### parentId usage example
139
-
140
- ```json
141
- {
142
- "id": "OrderItem",
143
- "table": "order_items",
144
- "title": "Order Item",
145
- "parentId": "Order",
146
- "props": [...]
147
- }
148
- ```
149
-
150
- ### Child entities with parentId do not generate types.ts
151
-
152
- Child entities with parentId set (e.g., Chapter, Lesson) do not get their own `types.ts` file. This is expected behavior — child entities are managed through the parent. If you need independent CRUD and types.ts, do not use parentId.
153
-
154
- ### Folder location for parentId child entities
155
-
156
- Child entities with parentId must be placed **in the same folder as the root parent entity**.
157
-
158
- | Structure | Description |
159
- | ---------------------------- | ------------------------------------------------- |
160
- | `course/course.entity.json` | Root entity |
161
- | `course/chapter.entity.json` | parentId: "Course" → same folder |
162
- | `course/lesson.entity.json` | parentId: "Chapter" → same folder (based on root) |
163
- | `course/course.types.ts` | types.ts generated only for root |
164
-
165
- **Note:** Do not create child entities in a separate folder (e.g., `chapter/chapter.entity.json`).
166
-
167
- ### IMPORTANT: When Uncertain - Ask User (Never Guess)
168
-
169
- **Do not guess — ask.** In situations like the following, ask the user directly:
170
-
171
- - "Should chapters be managed as children of courses, or created as an independent entity?"
172
- - "Should order items be saved together with the order, or managed separately?"
173
-
174
- **When in doubt, ask. One question is better than a wrong design.**
175
-
176
- **Helpful questions to ask the user:**
177
-
178
- - "Will this data ever need to be queried or updated independently without a parent?"
179
- - "Should this data be deleted when the parent is deleted?"
180
- - "Does the admin UI need a separate list page for this?"