@mandujs/core 0.12.1 → 0.13.0
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/README.ko.md +304 -304
- package/README.md +653 -653
- package/package.json +8 -8
- package/src/brain/architecture/analyzer.ts +28 -26
- package/src/brain/doctor/analyzer.ts +1 -1
- package/src/bundler/build.ts +91 -91
- package/src/bundler/css.ts +302 -302
- package/src/bundler/dev.ts +0 -1
- package/src/change/history.ts +3 -3
- package/src/change/snapshot.ts +10 -9
- package/src/change/transaction.ts +2 -2
- package/src/client/Link.tsx +227 -227
- package/src/client/globals.ts +44 -44
- package/src/client/hooks.ts +267 -267
- package/src/client/index.ts +5 -5
- package/src/client/island.ts +8 -8
- package/src/client/router.ts +435 -435
- package/src/client/runtime.ts +23 -23
- package/src/client/serialize.ts +404 -404
- package/src/client/window-state.ts +101 -101
- package/src/config/mandu.ts +94 -96
- package/src/config/validate.ts +213 -215
- package/src/config/watcher.ts +311 -311
- package/src/constants.ts +40 -40
- package/src/content/content-layer.ts +314 -314
- package/src/content/content.test.ts +433 -433
- package/src/content/data-store.ts +245 -245
- package/src/content/digest.ts +133 -133
- package/src/content/index.ts +164 -164
- package/src/content/loader-context.ts +172 -172
- package/src/content/loaders/api.ts +216 -216
- package/src/content/loaders/file.ts +169 -169
- package/src/content/loaders/glob.ts +252 -252
- package/src/content/loaders/index.ts +34 -34
- package/src/content/loaders/types.ts +137 -137
- package/src/content/meta-store.ts +209 -209
- package/src/content/types.ts +282 -282
- package/src/content/watcher.ts +135 -135
- package/src/contract/client-safe.test.ts +42 -42
- package/src/contract/client-safe.ts +114 -114
- package/src/contract/client.ts +16 -16
- package/src/contract/define.ts +459 -459
- package/src/contract/handler.ts +10 -10
- package/src/contract/normalize.test.ts +276 -276
- package/src/contract/normalize.ts +404 -404
- package/src/contract/registry.test.ts +206 -206
- package/src/contract/registry.ts +568 -568
- package/src/contract/schema.ts +48 -48
- package/src/contract/types.ts +58 -58
- package/src/contract/validator.ts +32 -32
- package/src/devtools/ai/context-builder.ts +375 -375
- package/src/devtools/ai/index.ts +25 -25
- package/src/devtools/ai/mcp-connector.ts +465 -465
- package/src/devtools/client/catchers/error-catcher.ts +327 -327
- package/src/devtools/client/catchers/index.ts +18 -18
- package/src/devtools/client/catchers/network-proxy.ts +363 -363
- package/src/devtools/client/components/index.ts +39 -39
- package/src/devtools/client/components/kitchen-root.tsx +362 -362
- package/src/devtools/client/components/mandu-character.tsx +241 -241
- package/src/devtools/client/components/overlay.tsx +368 -368
- package/src/devtools/client/components/panel/errors-panel.tsx +259 -259
- package/src/devtools/client/components/panel/guard-panel.tsx +244 -244
- package/src/devtools/client/components/panel/index.ts +32 -32
- package/src/devtools/client/components/panel/islands-panel.tsx +304 -304
- package/src/devtools/client/components/panel/network-panel.tsx +292 -292
- package/src/devtools/client/components/panel/panel-container.tsx +259 -259
- package/src/devtools/client/filters/context-filters.ts +282 -282
- package/src/devtools/client/filters/index.ts +16 -16
- package/src/devtools/client/index.ts +63 -63
- package/src/devtools/client/persistence.ts +335 -335
- package/src/devtools/client/state-manager.ts +478 -478
- package/src/devtools/design-tokens.ts +263 -263
- package/src/devtools/hook/create-hook.ts +207 -207
- package/src/devtools/hook/index.ts +13 -13
- package/src/devtools/index.ts +439 -439
- package/src/devtools/init.ts +266 -266
- package/src/devtools/protocol.ts +237 -237
- package/src/devtools/server/index.ts +17 -17
- package/src/devtools/server/source-context.ts +444 -444
- package/src/devtools/types.ts +319 -319
- package/src/devtools/worker/index.ts +25 -25
- package/src/devtools/worker/redaction-worker.ts +222 -222
- package/src/devtools/worker/worker-manager.ts +409 -409
- package/src/error/classifier.ts +2 -2
- package/src/error/domains.ts +265 -265
- package/src/error/formatter.ts +32 -32
- package/src/error/result.ts +46 -46
- package/src/error/stack-analyzer.ts +5 -0
- package/src/error/types.ts +6 -6
- package/src/errors/extractor.ts +409 -409
- package/src/errors/index.ts +19 -19
- package/src/filling/auth.ts +308 -308
- package/src/filling/context.ts +569 -569
- package/src/filling/deps.ts +238 -238
- package/src/generator/contract-glue.ts +2 -1
- package/src/generator/generate.ts +12 -10
- package/src/generator/index.ts +3 -3
- package/src/generator/templates.ts +80 -79
- package/src/guard/analyzer.ts +360 -360
- package/src/guard/ast-analyzer.ts +806 -806
- package/src/guard/auto-correct.ts +1 -1
- package/src/guard/check.ts +128 -128
- package/src/guard/contract-guard.ts +9 -9
- package/src/guard/file-type.test.ts +24 -24
- package/src/guard/healing.ts +2 -0
- package/src/guard/index.ts +2 -0
- package/src/guard/negotiation.ts +430 -4
- package/src/guard/presets/atomic.ts +70 -70
- package/src/guard/presets/clean.ts +77 -77
- package/src/guard/presets/cqrs.test.ts +175 -0
- package/src/guard/presets/cqrs.ts +107 -0
- package/src/guard/presets/fsd.ts +79 -79
- package/src/guard/presets/hexagonal.ts +68 -68
- package/src/guard/presets/index.ts +291 -288
- package/src/guard/reporter.ts +445 -445
- package/src/guard/rules.ts +12 -12
- package/src/guard/statistics.ts +578 -578
- package/src/guard/suggestions.ts +358 -352
- package/src/guard/types.ts +348 -347
- package/src/guard/validator.ts +834 -834
- package/src/guard/watcher.ts +404 -404
- package/src/index.ts +1 -0
- package/src/intent/index.ts +310 -310
- package/src/island/index.ts +304 -304
- package/src/logging/index.ts +22 -22
- package/src/logging/transports.ts +365 -365
- package/src/paths.test.ts +47 -0
- package/src/paths.ts +47 -0
- package/src/plugins/index.ts +38 -38
- package/src/plugins/registry.ts +377 -377
- package/src/plugins/types.ts +363 -363
- package/src/report/build.ts +1 -1
- package/src/report/index.ts +1 -1
- package/src/router/fs-patterns.ts +387 -387
- package/src/router/fs-routes.ts +344 -401
- package/src/router/fs-scanner.ts +497 -497
- package/src/router/fs-types.ts +270 -278
- package/src/router/index.ts +81 -81
- package/src/runtime/boundary.tsx +232 -232
- package/src/runtime/compose.ts +222 -222
- package/src/runtime/lifecycle.ts +381 -381
- package/src/runtime/logger.test.ts +345 -345
- package/src/runtime/logger.ts +677 -677
- package/src/runtime/router.test.ts +476 -476
- package/src/runtime/router.ts +105 -105
- package/src/runtime/security.ts +155 -155
- package/src/runtime/server.ts +24 -24
- package/src/runtime/session-key.ts +328 -328
- package/src/runtime/ssr.ts +367 -367
- package/src/runtime/streaming-ssr.ts +1245 -1245
- package/src/runtime/trace.ts +144 -144
- package/src/seo/index.ts +214 -214
- package/src/seo/integration/ssr.ts +307 -307
- package/src/seo/render/basic.ts +427 -427
- package/src/seo/render/index.ts +143 -143
- package/src/seo/render/jsonld.ts +539 -539
- package/src/seo/render/opengraph.ts +191 -191
- package/src/seo/render/robots.ts +116 -116
- package/src/seo/render/sitemap.ts +137 -137
- package/src/seo/render/twitter.ts +126 -126
- package/src/seo/resolve/index.ts +353 -353
- package/src/seo/resolve/opengraph.ts +143 -143
- package/src/seo/resolve/robots.ts +73 -73
- package/src/seo/resolve/title.ts +94 -94
- package/src/seo/resolve/twitter.ts +73 -73
- package/src/seo/resolve/url.ts +97 -97
- package/src/seo/routes/index.ts +290 -290
- package/src/seo/types.ts +575 -575
- package/src/slot/validator.ts +39 -39
- package/src/spec/index.ts +3 -3
- package/src/spec/load.ts +76 -76
- package/src/spec/lock.ts +56 -56
- package/src/utils/bun.ts +8 -8
- package/src/utils/lru-cache.ts +75 -75
- package/src/utils/safe-io.ts +188 -188
- package/src/utils/string-safe.ts +298 -298
- package/src/watcher/rules.ts +5 -5
package/src/guard/types.ts
CHANGED
|
@@ -1,347 +1,348 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mandu Guard Types
|
|
3
|
-
*
|
|
4
|
-
* 실시간 아키텍처 감시 시스템 타입 정의
|
|
5
|
-
*
|
|
6
|
-
* @module guard/types
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { TIMEOUTS } from "../constants";
|
|
10
|
-
|
|
11
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
12
|
-
// Configuration Types
|
|
13
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 프리셋 이름
|
|
17
|
-
*/
|
|
18
|
-
export type GuardPreset =
|
|
19
|
-
| "fsd" // Feature-Sliced Design
|
|
20
|
-
| "clean" // Clean Architecture
|
|
21
|
-
| "hexagonal" // Hexagonal Architecture
|
|
22
|
-
| "atomic" // Atomic Design
|
|
23
|
-
| "
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
| "
|
|
193
|
-
| "
|
|
194
|
-
| "
|
|
195
|
-
| "
|
|
196
|
-
| "
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
"**/*.test.
|
|
324
|
-
"**/*.
|
|
325
|
-
"**/*.spec.
|
|
326
|
-
"**/*.
|
|
327
|
-
"
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Mandu Guard Types
|
|
3
|
+
*
|
|
4
|
+
* 실시간 아키텍처 감시 시스템 타입 정의
|
|
5
|
+
*
|
|
6
|
+
* @module guard/types
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { TIMEOUTS } from "../constants";
|
|
10
|
+
|
|
11
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
12
|
+
// Configuration Types
|
|
13
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 프리셋 이름
|
|
17
|
+
*/
|
|
18
|
+
export type GuardPreset =
|
|
19
|
+
| "fsd" // Feature-Sliced Design
|
|
20
|
+
| "clean" // Clean Architecture
|
|
21
|
+
| "hexagonal" // Hexagonal Architecture
|
|
22
|
+
| "atomic" // Atomic Design
|
|
23
|
+
| "cqrs" // CQRS (Command Query Responsibility Segregation)
|
|
24
|
+
| "mandu"; // Mandu 권장 (FSD + Clean 조합)
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 심각도 레벨
|
|
28
|
+
*/
|
|
29
|
+
export type Severity = "error" | "warn" | "info";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 심각도 설정
|
|
33
|
+
*/
|
|
34
|
+
export interface SeverityConfig {
|
|
35
|
+
/** 레이어 위반 */
|
|
36
|
+
layerViolation?: Severity;
|
|
37
|
+
/** 순환 의존 */
|
|
38
|
+
circularDependency?: Severity;
|
|
39
|
+
/** 깊은 중첩 */
|
|
40
|
+
deepNesting?: Severity;
|
|
41
|
+
/** 같은 레이어 내 슬라이스 간 의존 */
|
|
42
|
+
crossSliceDependency?: Severity;
|
|
43
|
+
/** 파일 타입 위반 (.js/.jsx 금지 등) */
|
|
44
|
+
fileType?: Severity;
|
|
45
|
+
/** shared 하위 세그먼트 위반 */
|
|
46
|
+
invalidSharedSegment?: Severity;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* FS Routes Guard 설정
|
|
51
|
+
*/
|
|
52
|
+
export interface FSRoutesGuardConfig {
|
|
53
|
+
/** page.tsx에서 다른 page import 금지 */
|
|
54
|
+
noPageToPage?: boolean;
|
|
55
|
+
/** page.tsx가 import 가능한 레이어 */
|
|
56
|
+
pageCanImport?: string[];
|
|
57
|
+
/** layout.tsx가 import 가능한 레이어 */
|
|
58
|
+
layoutCanImport?: string[];
|
|
59
|
+
/** route.ts가 import 가능한 레이어 */
|
|
60
|
+
routeCanImport?: string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Guard 설정
|
|
65
|
+
*/
|
|
66
|
+
export interface GuardConfig {
|
|
67
|
+
/** 프리셋 이름 */
|
|
68
|
+
preset?: GuardPreset;
|
|
69
|
+
|
|
70
|
+
/** 실시간 감시 여부 (기본값: true) */
|
|
71
|
+
realtime?: boolean;
|
|
72
|
+
|
|
73
|
+
/** 감시 대상 디렉토리 (기본값: "src") */
|
|
74
|
+
srcDir?: string;
|
|
75
|
+
|
|
76
|
+
/** 제외 패턴 (glob) */
|
|
77
|
+
exclude?: string[];
|
|
78
|
+
|
|
79
|
+
/** 무시할 import 패턴 */
|
|
80
|
+
ignoreImports?: string[];
|
|
81
|
+
|
|
82
|
+
/** 커스텀 레이어 정의 */
|
|
83
|
+
layers?: LayerDefinition[];
|
|
84
|
+
|
|
85
|
+
/** 프리셋 오버라이드 */
|
|
86
|
+
override?: {
|
|
87
|
+
layers?: Record<string, Partial<LayerDefinition>>;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** 심각도 설정 */
|
|
91
|
+
severity?: SeverityConfig;
|
|
92
|
+
|
|
93
|
+
/** FS Routes 통합 */
|
|
94
|
+
fsRoutes?: FSRoutesGuardConfig;
|
|
95
|
+
|
|
96
|
+
/** 실시간 출력 형식 */
|
|
97
|
+
realtimeOutput?: "console" | "agent" | "json";
|
|
98
|
+
|
|
99
|
+
/** 캐시 사용 여부 (기본값: true) */
|
|
100
|
+
cache?: boolean;
|
|
101
|
+
|
|
102
|
+
/** 증분 분석 (기본값: true) */
|
|
103
|
+
incremental?: boolean;
|
|
104
|
+
|
|
105
|
+
/** 디바운스 시간 (ms, 기본값: 100) */
|
|
106
|
+
debounceMs?: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
110
|
+
// Layer Types
|
|
111
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 레이어 정의
|
|
115
|
+
*/
|
|
116
|
+
export interface LayerDefinition {
|
|
117
|
+
/** 레이어 이름 */
|
|
118
|
+
name: string;
|
|
119
|
+
|
|
120
|
+
/** 파일 패턴 (glob) */
|
|
121
|
+
pattern: string;
|
|
122
|
+
|
|
123
|
+
/** import 가능한 레이어 목록 */
|
|
124
|
+
canImport: string[];
|
|
125
|
+
|
|
126
|
+
/** 레이어 설명 */
|
|
127
|
+
description?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 해석된 레이어 규칙
|
|
132
|
+
*/
|
|
133
|
+
export interface LayerRule {
|
|
134
|
+
/** 소스 레이어 */
|
|
135
|
+
from: string;
|
|
136
|
+
/** 타겟 레이어 */
|
|
137
|
+
to: string;
|
|
138
|
+
/** 허용 여부 */
|
|
139
|
+
allowed: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
143
|
+
// Analysis Types
|
|
144
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Import 정보
|
|
148
|
+
*/
|
|
149
|
+
export interface ImportInfo {
|
|
150
|
+
/** import 문 전체 */
|
|
151
|
+
statement: string;
|
|
152
|
+
/** import 경로 */
|
|
153
|
+
path: string;
|
|
154
|
+
/** 라인 번호 */
|
|
155
|
+
line: number;
|
|
156
|
+
/** 컬럼 번호 */
|
|
157
|
+
column: number;
|
|
158
|
+
/** import 유형 */
|
|
159
|
+
type: "static" | "dynamic" | "require";
|
|
160
|
+
/** named imports */
|
|
161
|
+
namedImports?: string[];
|
|
162
|
+
/** default import */
|
|
163
|
+
defaultImport?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 파일 분석 결과
|
|
168
|
+
*/
|
|
169
|
+
export interface FileAnalysis {
|
|
170
|
+
/** 파일 경로 */
|
|
171
|
+
filePath: string;
|
|
172
|
+
/** 분석 기준 루트 디렉토리 */
|
|
173
|
+
rootDir?: string;
|
|
174
|
+
/** 파일이 속한 레이어 */
|
|
175
|
+
layer: string | null;
|
|
176
|
+
/** 슬라이스 이름 (FSD의 경우) */
|
|
177
|
+
slice?: string;
|
|
178
|
+
/** import 목록 */
|
|
179
|
+
imports: ImportInfo[];
|
|
180
|
+
/** 분석 시간 */
|
|
181
|
+
analyzedAt: number;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
185
|
+
// Violation Types
|
|
186
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 위반 유형
|
|
190
|
+
*/
|
|
191
|
+
export type ViolationType =
|
|
192
|
+
| "layer-violation" // 레이어 의존 위반
|
|
193
|
+
| "circular-dependency" // 순환 의존
|
|
194
|
+
| "cross-slice" // 같은 레이어 내 슬라이스 간 의존
|
|
195
|
+
| "deep-nesting" // 깊은 중첩 import
|
|
196
|
+
| "file-type" // 파일 타입 위반
|
|
197
|
+
| "invalid-shared-segment"; // shared 세그먼트 위반
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 아키텍처 위반
|
|
201
|
+
*/
|
|
202
|
+
export interface Violation {
|
|
203
|
+
/** 위반 유형 */
|
|
204
|
+
type: ViolationType;
|
|
205
|
+
|
|
206
|
+
/** 위반 파일 경로 */
|
|
207
|
+
filePath: string;
|
|
208
|
+
|
|
209
|
+
/** 라인 번호 */
|
|
210
|
+
line: number;
|
|
211
|
+
|
|
212
|
+
/** 컬럼 번호 */
|
|
213
|
+
column: number;
|
|
214
|
+
|
|
215
|
+
/** 위반 import 문 */
|
|
216
|
+
importStatement: string;
|
|
217
|
+
|
|
218
|
+
/** import 경로 */
|
|
219
|
+
importPath: string;
|
|
220
|
+
|
|
221
|
+
/** 소스 레이어 */
|
|
222
|
+
fromLayer: string;
|
|
223
|
+
|
|
224
|
+
/** 타겟 레이어 */
|
|
225
|
+
toLayer: string;
|
|
226
|
+
|
|
227
|
+
/** 규칙 이름 */
|
|
228
|
+
ruleName: string;
|
|
229
|
+
|
|
230
|
+
/** 규칙 설명 */
|
|
231
|
+
ruleDescription: string;
|
|
232
|
+
|
|
233
|
+
/** 심각도 */
|
|
234
|
+
severity: Severity;
|
|
235
|
+
|
|
236
|
+
/** 허용된 레이어 목록 */
|
|
237
|
+
allowedLayers: string[];
|
|
238
|
+
|
|
239
|
+
/** 해결 제안 */
|
|
240
|
+
suggestions: string[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 위반 리포트
|
|
245
|
+
*/
|
|
246
|
+
export interface ViolationReport {
|
|
247
|
+
/** 총 위반 수 */
|
|
248
|
+
totalViolations: number;
|
|
249
|
+
|
|
250
|
+
/** 심각도별 카운트 */
|
|
251
|
+
bySeverity: Record<Severity, number>;
|
|
252
|
+
|
|
253
|
+
/** 타입별 카운트 */
|
|
254
|
+
byType: Record<ViolationType, number>;
|
|
255
|
+
|
|
256
|
+
/** 위반 목록 */
|
|
257
|
+
violations: Violation[];
|
|
258
|
+
|
|
259
|
+
/** 분석된 파일 수 */
|
|
260
|
+
filesAnalyzed: number;
|
|
261
|
+
|
|
262
|
+
/** 분석 시간 (ms) */
|
|
263
|
+
analysisTime: number;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
267
|
+
// Watcher Types
|
|
268
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Guard Watcher 이벤트
|
|
272
|
+
*/
|
|
273
|
+
export type WatcherEvent = "add" | "change" | "unlink";
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Guard Watcher 콜백
|
|
277
|
+
*/
|
|
278
|
+
export type WatcherCallback = (event: WatcherEvent, filePath: string) => void;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Guard Watcher 인터페이스
|
|
282
|
+
*/
|
|
283
|
+
export interface GuardWatcher {
|
|
284
|
+
/** 감시 시작 */
|
|
285
|
+
start(): void;
|
|
286
|
+
/** 감시 중지 */
|
|
287
|
+
close(): void;
|
|
288
|
+
/** 전체 검사 */
|
|
289
|
+
scanAll(): Promise<ViolationReport>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
293
|
+
// Preset Types
|
|
294
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* 프리셋 정의
|
|
298
|
+
*/
|
|
299
|
+
export interface PresetDefinition {
|
|
300
|
+
/** 프리셋 이름 */
|
|
301
|
+
name: GuardPreset;
|
|
302
|
+
/** 설명 */
|
|
303
|
+
description: string;
|
|
304
|
+
/** 레이어 정의 */
|
|
305
|
+
layers: LayerDefinition[];
|
|
306
|
+
/** 레이어 계층 구조 (상위 → 하위) */
|
|
307
|
+
hierarchy: string[];
|
|
308
|
+
/** 기본 심각도 설정 */
|
|
309
|
+
defaultSeverity?: SeverityConfig;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
313
|
+
// Constants
|
|
314
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* 기본 Guard 설정
|
|
318
|
+
*/
|
|
319
|
+
export const DEFAULT_GUARD_CONFIG: Required<Omit<GuardConfig, "preset" | "layers" | "override" | "fsRoutes">> = {
|
|
320
|
+
realtime: true,
|
|
321
|
+
srcDir: "src",
|
|
322
|
+
exclude: [
|
|
323
|
+
"**/*.test.ts",
|
|
324
|
+
"**/*.test.tsx",
|
|
325
|
+
"**/*.spec.ts",
|
|
326
|
+
"**/*.spec.tsx",
|
|
327
|
+
"**/*.stories.tsx",
|
|
328
|
+
"**/node_modules/**",
|
|
329
|
+
],
|
|
330
|
+
ignoreImports: [],
|
|
331
|
+
severity: {
|
|
332
|
+
layerViolation: "error",
|
|
333
|
+
circularDependency: "warn",
|
|
334
|
+
deepNesting: "info",
|
|
335
|
+
crossSliceDependency: "warn",
|
|
336
|
+
fileType: "error",
|
|
337
|
+
invalidSharedSegment: "error",
|
|
338
|
+
},
|
|
339
|
+
realtimeOutput: "console",
|
|
340
|
+
cache: true,
|
|
341
|
+
incremental: true,
|
|
342
|
+
debounceMs: TIMEOUTS.WATCHER_DEBOUNCE,
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 감시 대상 파일 확장자
|
|
347
|
+
*/
|
|
348
|
+
export const WATCH_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|