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,130 +1,130 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sonamu-naite
|
|
3
|
-
description: Naite
|
|
3
|
+
description: Naite tracing system. Record values in source code with Naite.t(), verify in tests with Naite.get(). Supports chaining filters (fromFile, fromFunction, where), wildcard patterns, and DevRunner trace output. Use when tracing/debugging Model internals, verifying queries, or inspecting UpsertBuilder behavior.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Naite (
|
|
6
|
+
# Naite (Tracing System)
|
|
7
7
|
|
|
8
|
-
Naite
|
|
8
|
+
Naite is a tracing system for recording values in source code and verifying them in tests.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
**Source code:** `modules/sonamu/src/naite/naite.ts`
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
1.
|
|
14
|
-
2.
|
|
12
|
+
**How it works:**
|
|
13
|
+
1. **Source code**: Record values with `Naite.t("key", value)`
|
|
14
|
+
2. **Test code**: Retrieve recorded values with `Naite.get("key")`
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Recording in Source Code (Naite.t)
|
|
19
19
|
|
|
20
20
|
```typescript
|
|
21
|
-
// Model
|
|
21
|
+
// In Model or library code
|
|
22
22
|
import { Naite } from "sonamu";
|
|
23
23
|
|
|
24
|
-
//
|
|
24
|
+
// Record a query
|
|
25
25
|
Naite.t("esq-query", qb.toQuery());
|
|
26
26
|
|
|
27
|
-
// UpsertBuilder
|
|
27
|
+
// Inside UpsertBuilder
|
|
28
28
|
Naite.t("puri:ub-register", { tableName, uuid, isUuidReused, row });
|
|
29
29
|
Naite.t("puri:ub-upserted", { tableName, mode, rowCount, returnedIds });
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## Verifying in Tests (Naite.get)
|
|
35
35
|
|
|
36
36
|
```typescript
|
|
37
|
-
//
|
|
37
|
+
// In test code
|
|
38
38
|
import { Naite } from "sonamu";
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// Verify a recorded query
|
|
41
41
|
expect(Naite.get("esq-query").first()).not.contain("limit");
|
|
42
42
|
|
|
43
|
-
// UpsertBuilder
|
|
43
|
+
// Verify UpsertBuilder behavior
|
|
44
44
|
const trace = Naite.get("puri:ub-upserted").first();
|
|
45
45
|
expect(trace).toMatchObject({ tableName: "users", rowCount: 3 });
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
50
|
-
##
|
|
51
|
-
|
|
52
|
-
|
|
|
53
|
-
|
|
54
|
-
| `esq-query` |
|
|
55
|
-
| `puri:executed-query` |
|
|
56
|
-
| `puri:ub-register` | UpsertBuilder register
|
|
57
|
-
| `puri:ub-upserted` | UpsertBuilder upsert
|
|
58
|
-
| `puri:ub-ref-resolved` | UBRef →
|
|
59
|
-
| `puri:ub-batch-updated` | updateBatch
|
|
60
|
-
| `puri:ub-clean-orphans` | cleanOrphans
|
|
61
|
-
| `puri:ub-inherit` | inherit
|
|
62
|
-
| `mock:fs/promises:virtualFileSystem` |
|
|
63
|
-
| `fs/promises:writeFile` | writeFile
|
|
64
|
-
| `fs/promises:rm` | rm
|
|
50
|
+
## Built-in Naite Keys (Sonamu)
|
|
51
|
+
|
|
52
|
+
| Key | Description | Data |
|
|
53
|
+
|-----|-------------|------|
|
|
54
|
+
| `esq-query` | Executed SQL query | Query string |
|
|
55
|
+
| `puri:executed-query` | Query executed by Puri | Query string |
|
|
56
|
+
| `puri:ub-register` | UpsertBuilder register call | `{ tableName, uuid, isUuidReused, row }` |
|
|
57
|
+
| `puri:ub-upserted` | UpsertBuilder upsert complete | `{ tableName, mode, rowCount, returnedIds }` |
|
|
58
|
+
| `puri:ub-ref-resolved` | UBRef → actual ID substitution | `{ tableName, field, from, to }` |
|
|
59
|
+
| `puri:ub-batch-updated` | updateBatch complete | `{ tableName, rowCount, whereColumns }` |
|
|
60
|
+
| `puri:ub-clean-orphans` | cleanOrphans executed | `{ tableName, cleanOrphans, deletedCount }` |
|
|
61
|
+
| `puri:ub-inherit` | inherit option applied | `{ tableName, inheritColumns, excludedFromUpdate }` |
|
|
62
|
+
| `mock:fs/promises:virtualFileSystem` | Virtual file system path | File path string |
|
|
63
|
+
| `fs/promises:writeFile` | writeFile call | `{ path, data }` |
|
|
64
|
+
| `fs/promises:rm` | rm call | `{ path, options }` |
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
68
|
-
##
|
|
68
|
+
## Recording with Custom Keys
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
|
-
//
|
|
71
|
+
// Record with a custom key in source code
|
|
72
72
|
Naite.t("user:created", { userId: 1, email: "test@test.com" });
|
|
73
73
|
|
|
74
|
-
//
|
|
74
|
+
// Virtual file system for mocking
|
|
75
75
|
Naite.t("mock:fs/promises:virtualFileSystem", "/path/to/virtual/file.ts");
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
---
|
|
79
79
|
|
|
80
|
-
## Naite.get()
|
|
80
|
+
## Naite.get() Retrieval Methods
|
|
81
81
|
|
|
82
82
|
```typescript
|
|
83
|
-
//
|
|
84
|
-
Naite.get("key").first() //
|
|
85
|
-
Naite.get("key").last() //
|
|
86
|
-
Naite.get("key").at(2) //
|
|
87
|
-
Naite.get("key").result() //
|
|
88
|
-
Naite.get("key").getTraces() //
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
Naite.get("puri:*").result() // puri:
|
|
92
|
-
Naite.get("syncer:*:user").result() // syncer:XXX:user
|
|
83
|
+
// Basic retrieval
|
|
84
|
+
Naite.get("key").first() // first entry
|
|
85
|
+
Naite.get("key").last() // last entry
|
|
86
|
+
Naite.get("key").at(2) // nth entry
|
|
87
|
+
Naite.get("key").result() // all entries as an array
|
|
88
|
+
Naite.get("key").getTraces() // raw trace array (includes call stack)
|
|
89
|
+
|
|
90
|
+
// Wildcard patterns
|
|
91
|
+
Naite.get("puri:*").result() // all with puri: prefix
|
|
92
|
+
Naite.get("syncer:*:user").result() // syncer:XXX:user pattern
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
---
|
|
96
96
|
|
|
97
|
-
##
|
|
97
|
+
## Chaining Filters
|
|
98
98
|
|
|
99
99
|
```typescript
|
|
100
|
-
//
|
|
100
|
+
// Filter by file name
|
|
101
101
|
Naite.get("esq-query")
|
|
102
|
-
.fromFile("user.model.ts") //
|
|
102
|
+
.fromFile("user.model.ts") // only entries recorded from this file
|
|
103
103
|
.result();
|
|
104
104
|
|
|
105
|
-
//
|
|
105
|
+
// Filter by function name
|
|
106
106
|
Naite.get("puri:executed-query")
|
|
107
|
-
.fromFunction("findById") //
|
|
107
|
+
.fromFunction("findById") // only entries called from this function
|
|
108
108
|
.result();
|
|
109
109
|
|
|
110
|
-
// fromFunction
|
|
110
|
+
// fromFunction options
|
|
111
111
|
Naite.get("key")
|
|
112
|
-
.fromFunction("save", { from: "direct" }) //
|
|
113
|
-
.fromFunction("save", { from: "indirect" }) //
|
|
114
|
-
.fromFunction("save", { from: "both" }) //
|
|
112
|
+
.fromFunction("save", { from: "direct" }) // direct calls only (stack[0])
|
|
113
|
+
.fromFunction("save", { from: "indirect" }) // indirect calls only (stack[1+])
|
|
114
|
+
.fromFunction("save", { from: "both" }) // both (default)
|
|
115
115
|
|
|
116
|
-
//
|
|
116
|
+
// Filter by data path (radash get path)
|
|
117
117
|
Naite.get("puri:ub-register")
|
|
118
|
-
.where("data.tableName", "=", "users") // tableName
|
|
118
|
+
.where("data.tableName", "=", "users") // only where tableName is "users"
|
|
119
119
|
.where("data.rowCount", ">", 5) // rowCount > 5
|
|
120
120
|
.result();
|
|
121
121
|
|
|
122
|
-
// where
|
|
122
|
+
// where operators: ">", "<", ">=", "<=", "=", "!=", "includes"
|
|
123
123
|
Naite.get("key")
|
|
124
|
-
.where("data.query", "includes", "WHERE") //
|
|
124
|
+
.where("data.query", "includes", "WHERE") // check if string includes substring
|
|
125
125
|
.result();
|
|
126
126
|
|
|
127
|
-
//
|
|
127
|
+
// Combining filters
|
|
128
128
|
Naite.get("puri:executed-query")
|
|
129
129
|
.fromFunction("findMany")
|
|
130
130
|
.where("data", "includes", "users")
|
|
@@ -133,27 +133,27 @@ Naite.get("puri:executed-query")
|
|
|
133
133
|
|
|
134
134
|
---
|
|
135
135
|
|
|
136
|
-
## Naite.del() -
|
|
136
|
+
## Naite.del() - Delete Values
|
|
137
137
|
|
|
138
138
|
```typescript
|
|
139
139
|
Naite.t("mock:fs/promises:virtualFileSystem", "/virtual/path");
|
|
140
|
-
// ...
|
|
140
|
+
// ... test ...
|
|
141
141
|
Naite.del("mock:fs/promises:virtualFileSystem");
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
---
|
|
145
145
|
|
|
146
|
-
##
|
|
146
|
+
## Test Examples
|
|
147
147
|
|
|
148
148
|
```typescript
|
|
149
|
-
test("
|
|
149
|
+
test("query should not have a limit", async () => {
|
|
150
150
|
await UserModel.findMany("A", { num: 0, page: 1 });
|
|
151
151
|
|
|
152
152
|
expect(Naite.get("esq-query").first()).not.contain("limit");
|
|
153
153
|
expect(Naite.get("esq-query").first()).not.contain("offset");
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
test("UpsertBuilder register
|
|
156
|
+
test("trace UpsertBuilder register", async () => {
|
|
157
157
|
const ub = new UpsertBuilder();
|
|
158
158
|
const ref = ub.register("users", { email: "test@test.com", username: "test" });
|
|
159
159
|
|
|
@@ -165,8 +165,8 @@ test("UpsertBuilder register 추적", async () => {
|
|
|
165
165
|
});
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
test("upsert
|
|
169
|
-
// ... upsert
|
|
168
|
+
test("trace upsert completion", async () => {
|
|
169
|
+
// ... run upsert ...
|
|
170
170
|
|
|
171
171
|
const trace = Naite.get("puri:ub-upserted").first();
|
|
172
172
|
expect(trace).toMatchObject({
|
|
@@ -179,23 +179,23 @@ test("upsert 완료 추적", async () => {
|
|
|
179
179
|
|
|
180
180
|
---
|
|
181
181
|
|
|
182
|
-
##
|
|
182
|
+
## Viewing Traces in DevRunner
|
|
183
183
|
|
|
184
|
-
`sonamu test --traces`
|
|
184
|
+
Use the `sonamu test --traces` flag to view Naite traces directly in the CLI:
|
|
185
185
|
|
|
186
186
|
```bash
|
|
187
187
|
sonamu test user.model --traces
|
|
188
188
|
sonamu test user.model -t
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
Example output:
|
|
192
192
|
```
|
|
193
193
|
Tests: 5 passed, 0 failed, 5 total
|
|
194
194
|
Duration: 791ms
|
|
195
195
|
|
|
196
196
|
Traces:
|
|
197
197
|
|
|
198
|
-
UserModel > BaseModel
|
|
198
|
+
UserModel > BaseModel basic functionality > Model.findMany() with num = 0
|
|
199
199
|
user.model.test.ts
|
|
200
200
|
|
|
201
201
|
[esq-query] user.model.ts:113
|
|
@@ -205,13 +205,13 @@ Traces:
|
|
|
205
205
|
select COUNT(*)::integer as "total" from "users" limit 1
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
Trace data is fetched from `testCase.meta().traces` (collected in `afterEach` of `bootstrap.ts`) and serialized as the `SerializedTrace` type (exported from `naite.ts`).
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
See `testing-devrunner.md` for DevRunner details.
|
|
211
211
|
|
|
212
212
|
---
|
|
213
213
|
|
|
214
|
-
##
|
|
214
|
+
## Internal Structure
|
|
215
215
|
|
|
216
216
|
### NaiteStore
|
|
217
217
|
|
|
@@ -221,18 +221,18 @@ type NaiteStore = Map<string, NaiteTrace[]>;
|
|
|
221
221
|
interface NaiteTrace {
|
|
222
222
|
key: string;
|
|
223
223
|
data: any;
|
|
224
|
-
stack: StackFrame[]; //
|
|
224
|
+
stack: StackFrame[]; // call stack information
|
|
225
225
|
at: Date;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
interface StackFrame {
|
|
229
229
|
functionName: string | null;
|
|
230
|
-
filePath: string; //
|
|
231
|
-
lineNumber: number; //
|
|
230
|
+
filePath: string; // path relative to TS file
|
|
231
|
+
lineNumber: number; // line number in TS file
|
|
232
232
|
}
|
|
233
233
|
```
|
|
234
234
|
|
|
235
|
-
### SerializedTrace (API
|
|
235
|
+
### SerializedTrace (for API responses / DevRunner)
|
|
236
236
|
|
|
237
237
|
```typescript
|
|
238
238
|
type SerializedTrace = {
|
|
@@ -246,19 +246,19 @@ type SerializedTrace = {
|
|
|
246
246
|
|
|
247
247
|
---
|
|
248
248
|
|
|
249
|
-
##
|
|
249
|
+
## Debugging Uses
|
|
250
250
|
|
|
251
|
-
Naite
|
|
251
|
+
Naite can also be used for source code behavior analysis beyond tests:
|
|
252
252
|
|
|
253
|
-
-
|
|
254
|
-
- **UpsertBuilder
|
|
255
|
-
-
|
|
256
|
-
-
|
|
253
|
+
- **Query tracing**: Use `esq-query` and `puri:executed-query` to see the actual SQL being executed
|
|
254
|
+
- **UpsertBuilder analysis**: Trace the full flow (register → upsert → ref-resolved → batch-updated) with `puri:ub-*` keys
|
|
255
|
+
- **File I/O tracing**: Use `fs/promises:*` keys to see file operations performed by the syncer and others
|
|
256
|
+
- **Isolate a specific function**: Use `.fromFunction("findById")` chaining to filter traces to only those originating from a specific method
|
|
257
257
|
|
|
258
258
|
---
|
|
259
259
|
|
|
260
|
-
##
|
|
260
|
+
## References
|
|
261
261
|
|
|
262
|
-
-
|
|
263
|
-
- **DevRunner
|
|
264
|
-
- **expectQuery
|
|
262
|
+
- **Testing guide**: `testing.md`
|
|
263
|
+
- **DevRunner details**: `testing-devrunner.md`
|
|
264
|
+
- **expectQuery helper** (Naite-based): see "Test Helpers: expectQuery" section in `testing.md`
|