@getmikk/core 1.2.0 → 1.3.1
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.md +431 -0
- package/package.json +6 -2
- package/src/contract/contract-generator.ts +85 -85
- package/src/contract/contract-reader.ts +28 -28
- package/src/contract/contract-writer.ts +114 -114
- package/src/contract/index.ts +12 -12
- package/src/contract/lock-compiler.ts +221 -221
- package/src/contract/lock-reader.ts +34 -34
- package/src/contract/schema.ts +147 -147
- package/src/graph/cluster-detector.ts +312 -312
- package/src/graph/graph-builder.ts +211 -211
- package/src/graph/impact-analyzer.ts +55 -55
- package/src/graph/index.ts +4 -4
- package/src/graph/types.ts +59 -59
- package/src/hash/file-hasher.ts +30 -30
- package/src/hash/hash-store.ts +119 -119
- package/src/hash/index.ts +3 -3
- package/src/hash/tree-hasher.ts +20 -20
- package/src/index.ts +12 -12
- package/src/parser/base-parser.ts +16 -16
- package/src/parser/boundary-checker.ts +211 -211
- package/src/parser/index.ts +46 -46
- package/src/parser/types.ts +90 -90
- package/src/parser/typescript/ts-extractor.ts +543 -543
- package/src/parser/typescript/ts-parser.ts +41 -41
- package/src/parser/typescript/ts-resolver.ts +86 -86
- package/src/utils/errors.ts +42 -42
- package/src/utils/fs.ts +75 -75
- package/src/utils/fuzzy-match.ts +186 -186
- package/src/utils/logger.ts +36 -36
- package/src/utils/minimatch.ts +19 -19
- package/tests/contract.test.ts +134 -134
- package/tests/fixtures/simple-api/package.json +5 -5
- package/tests/fixtures/simple-api/src/auth/middleware.ts +9 -9
- package/tests/fixtures/simple-api/src/auth/verify.ts +6 -6
- package/tests/fixtures/simple-api/src/index.ts +9 -9
- package/tests/fixtures/simple-api/src/utils/jwt.ts +3 -3
- package/tests/fixtures/simple-api/tsconfig.json +8 -8
- package/tests/fuzzy-match.test.ts +142 -142
- package/tests/graph.test.ts +169 -169
- package/tests/hash.test.ts +49 -49
- package/tests/helpers.ts +83 -83
- package/tests/parser.test.ts +218 -218
- package/tsconfig.json +15 -15
package/src/contract/schema.ts
CHANGED
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
|
|
3
|
-
// ─── mikk.json schema ──────────────────────────────────────
|
|
4
|
-
|
|
5
|
-
export const MikkModuleSchema = z.object({
|
|
6
|
-
id: z.string(),
|
|
7
|
-
name: z.string(),
|
|
8
|
-
description: z.string(),
|
|
9
|
-
intent: z.string().optional(),
|
|
10
|
-
owners: z.array(z.string()).optional(),
|
|
11
|
-
paths: z.array(z.string()),
|
|
12
|
-
entryFunctions: z.array(z.string()).optional(),
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export const MikkDecisionSchema = z.object({
|
|
16
|
-
id: z.string(),
|
|
17
|
-
title: z.string(),
|
|
18
|
-
reason: z.string(),
|
|
19
|
-
date: z.string(),
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
export const MikkOverwriteSchema = z.object({
|
|
23
|
-
mode: z.enum(['never', 'ask', 'explicit']).default('never'),
|
|
24
|
-
requireConfirmation: z.boolean().default(true),
|
|
25
|
-
lastOverwrittenBy: z.string().optional(),
|
|
26
|
-
lastOverwrittenAt: z.string().optional(),
|
|
27
|
-
}).default({ mode: 'never', requireConfirmation: true })
|
|
28
|
-
|
|
29
|
-
export const MikkContractSchema = z.object({
|
|
30
|
-
version: z.string(),
|
|
31
|
-
project: z.object({
|
|
32
|
-
name: z.string(),
|
|
33
|
-
description: z.string(),
|
|
34
|
-
language: z.string(),
|
|
35
|
-
framework: z.string().optional(),
|
|
36
|
-
entryPoints: z.array(z.string()),
|
|
37
|
-
}),
|
|
38
|
-
declared: z.object({
|
|
39
|
-
modules: z.array(MikkModuleSchema),
|
|
40
|
-
constraints: z.array(z.string()).default([]),
|
|
41
|
-
decisions: z.array(MikkDecisionSchema).default([]),
|
|
42
|
-
}),
|
|
43
|
-
overwrite: MikkOverwriteSchema,
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
export type MikkContract = z.infer<typeof MikkContractSchema>
|
|
47
|
-
export type MikkModule = z.infer<typeof MikkModuleSchema>
|
|
48
|
-
export type MikkDecision = z.infer<typeof MikkDecisionSchema>
|
|
49
|
-
|
|
50
|
-
// ─── mikk.lock.json schema ─────────────────────────────────
|
|
51
|
-
|
|
52
|
-
export const MikkLockFunctionSchema = z.object({
|
|
53
|
-
id: z.string(),
|
|
54
|
-
name: z.string(),
|
|
55
|
-
file: z.string(),
|
|
56
|
-
startLine: z.number(),
|
|
57
|
-
endLine: z.number(),
|
|
58
|
-
hash: z.string(),
|
|
59
|
-
calls: z.array(z.string()),
|
|
60
|
-
calledBy: z.array(z.string()),
|
|
61
|
-
moduleId: z.string(),
|
|
62
|
-
purpose: z.string().optional(),
|
|
63
|
-
edgeCasesHandled: z.array(z.string()).optional(),
|
|
64
|
-
errorHandling: z.array(z.object({
|
|
65
|
-
line: z.number(),
|
|
66
|
-
type: z.enum(['try-catch', 'throw']),
|
|
67
|
-
detail: z.string(),
|
|
68
|
-
})).optional(),
|
|
69
|
-
detailedLines: z.array(z.object({
|
|
70
|
-
startLine: z.number(),
|
|
71
|
-
endLine: z.number(),
|
|
72
|
-
blockType: z.string(),
|
|
73
|
-
})).optional()
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
export const MikkLockModuleSchema = z.object({
|
|
77
|
-
id: z.string(),
|
|
78
|
-
files: z.array(z.string()),
|
|
79
|
-
hash: z.string(),
|
|
80
|
-
fragmentPath: z.string(),
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
export const MikkLockFileSchema = z.object({
|
|
84
|
-
path: z.string(),
|
|
85
|
-
hash: z.string(),
|
|
86
|
-
moduleId: z.string(),
|
|
87
|
-
lastModified: z.string(),
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
export const MikkLockClassSchema = z.object({
|
|
91
|
-
id: z.string(),
|
|
92
|
-
name: z.string(),
|
|
93
|
-
file: z.string(),
|
|
94
|
-
startLine: z.number(),
|
|
95
|
-
endLine: z.number(),
|
|
96
|
-
moduleId: z.string(),
|
|
97
|
-
isExported: z.boolean(),
|
|
98
|
-
purpose: z.string().optional(),
|
|
99
|
-
edgeCasesHandled: z.array(z.string()).optional(),
|
|
100
|
-
errorHandling: z.array(z.object({
|
|
101
|
-
line: z.number(),
|
|
102
|
-
type: z.enum(['try-catch', 'throw']),
|
|
103
|
-
detail: z.string(),
|
|
104
|
-
})).optional(),
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
export const MikkLockGenericSchema = z.object({
|
|
108
|
-
id: z.string(),
|
|
109
|
-
name: z.string(),
|
|
110
|
-
type: z.string(),
|
|
111
|
-
file: z.string(),
|
|
112
|
-
startLine: z.number(),
|
|
113
|
-
endLine: z.number(),
|
|
114
|
-
moduleId: z.string(),
|
|
115
|
-
isExported: z.boolean(),
|
|
116
|
-
purpose: z.string().optional(),
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
export const MikkLockSchema = z.object({
|
|
120
|
-
version: z.string(),
|
|
121
|
-
generatedAt: z.string(),
|
|
122
|
-
generatorVersion: z.string(),
|
|
123
|
-
projectRoot: z.string(),
|
|
124
|
-
syncState: z.object({
|
|
125
|
-
status: z.enum(['clean', 'syncing', 'drifted', 'conflict']),
|
|
126
|
-
lastSyncAt: z.string(),
|
|
127
|
-
lockHash: z.string(),
|
|
128
|
-
contractHash: z.string(),
|
|
129
|
-
}),
|
|
130
|
-
modules: z.record(MikkLockModuleSchema),
|
|
131
|
-
functions: z.record(MikkLockFunctionSchema),
|
|
132
|
-
classes: z.record(MikkLockClassSchema).optional(),
|
|
133
|
-
generics: z.record(MikkLockGenericSchema).optional(),
|
|
134
|
-
files: z.record(MikkLockFileSchema),
|
|
135
|
-
graph: z.object({
|
|
136
|
-
nodes: z.number(),
|
|
137
|
-
edges: z.number(),
|
|
138
|
-
rootHash: z.string(),
|
|
139
|
-
}),
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
export type MikkLock = z.infer<typeof MikkLockSchema>
|
|
143
|
-
export type MikkLockFunction = z.infer<typeof MikkLockFunctionSchema>
|
|
144
|
-
export type MikkLockModule = z.infer<typeof MikkLockModuleSchema>
|
|
145
|
-
export type MikkLockFile = z.infer<typeof MikkLockFileSchema>
|
|
146
|
-
export type MikkLockClass = z.infer<typeof MikkLockClassSchema>
|
|
147
|
-
export type MikkLockGeneric = z.infer<typeof MikkLockGenericSchema>
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
// ─── mikk.json schema ──────────────────────────────────────
|
|
4
|
+
|
|
5
|
+
export const MikkModuleSchema = z.object({
|
|
6
|
+
id: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
description: z.string(),
|
|
9
|
+
intent: z.string().optional(),
|
|
10
|
+
owners: z.array(z.string()).optional(),
|
|
11
|
+
paths: z.array(z.string()),
|
|
12
|
+
entryFunctions: z.array(z.string()).optional(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const MikkDecisionSchema = z.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
title: z.string(),
|
|
18
|
+
reason: z.string(),
|
|
19
|
+
date: z.string(),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const MikkOverwriteSchema = z.object({
|
|
23
|
+
mode: z.enum(['never', 'ask', 'explicit']).default('never'),
|
|
24
|
+
requireConfirmation: z.boolean().default(true),
|
|
25
|
+
lastOverwrittenBy: z.string().optional(),
|
|
26
|
+
lastOverwrittenAt: z.string().optional(),
|
|
27
|
+
}).default({ mode: 'never', requireConfirmation: true })
|
|
28
|
+
|
|
29
|
+
export const MikkContractSchema = z.object({
|
|
30
|
+
version: z.string(),
|
|
31
|
+
project: z.object({
|
|
32
|
+
name: z.string(),
|
|
33
|
+
description: z.string(),
|
|
34
|
+
language: z.string(),
|
|
35
|
+
framework: z.string().optional(),
|
|
36
|
+
entryPoints: z.array(z.string()),
|
|
37
|
+
}),
|
|
38
|
+
declared: z.object({
|
|
39
|
+
modules: z.array(MikkModuleSchema),
|
|
40
|
+
constraints: z.array(z.string()).default([]),
|
|
41
|
+
decisions: z.array(MikkDecisionSchema).default([]),
|
|
42
|
+
}),
|
|
43
|
+
overwrite: MikkOverwriteSchema,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
export type MikkContract = z.infer<typeof MikkContractSchema>
|
|
47
|
+
export type MikkModule = z.infer<typeof MikkModuleSchema>
|
|
48
|
+
export type MikkDecision = z.infer<typeof MikkDecisionSchema>
|
|
49
|
+
|
|
50
|
+
// ─── mikk.lock.json schema ─────────────────────────────────
|
|
51
|
+
|
|
52
|
+
export const MikkLockFunctionSchema = z.object({
|
|
53
|
+
id: z.string(),
|
|
54
|
+
name: z.string(),
|
|
55
|
+
file: z.string(),
|
|
56
|
+
startLine: z.number(),
|
|
57
|
+
endLine: z.number(),
|
|
58
|
+
hash: z.string(),
|
|
59
|
+
calls: z.array(z.string()),
|
|
60
|
+
calledBy: z.array(z.string()),
|
|
61
|
+
moduleId: z.string(),
|
|
62
|
+
purpose: z.string().optional(),
|
|
63
|
+
edgeCasesHandled: z.array(z.string()).optional(),
|
|
64
|
+
errorHandling: z.array(z.object({
|
|
65
|
+
line: z.number(),
|
|
66
|
+
type: z.enum(['try-catch', 'throw']),
|
|
67
|
+
detail: z.string(),
|
|
68
|
+
})).optional(),
|
|
69
|
+
detailedLines: z.array(z.object({
|
|
70
|
+
startLine: z.number(),
|
|
71
|
+
endLine: z.number(),
|
|
72
|
+
blockType: z.string(),
|
|
73
|
+
})).optional()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export const MikkLockModuleSchema = z.object({
|
|
77
|
+
id: z.string(),
|
|
78
|
+
files: z.array(z.string()),
|
|
79
|
+
hash: z.string(),
|
|
80
|
+
fragmentPath: z.string(),
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
export const MikkLockFileSchema = z.object({
|
|
84
|
+
path: z.string(),
|
|
85
|
+
hash: z.string(),
|
|
86
|
+
moduleId: z.string(),
|
|
87
|
+
lastModified: z.string(),
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
export const MikkLockClassSchema = z.object({
|
|
91
|
+
id: z.string(),
|
|
92
|
+
name: z.string(),
|
|
93
|
+
file: z.string(),
|
|
94
|
+
startLine: z.number(),
|
|
95
|
+
endLine: z.number(),
|
|
96
|
+
moduleId: z.string(),
|
|
97
|
+
isExported: z.boolean(),
|
|
98
|
+
purpose: z.string().optional(),
|
|
99
|
+
edgeCasesHandled: z.array(z.string()).optional(),
|
|
100
|
+
errorHandling: z.array(z.object({
|
|
101
|
+
line: z.number(),
|
|
102
|
+
type: z.enum(['try-catch', 'throw']),
|
|
103
|
+
detail: z.string(),
|
|
104
|
+
})).optional(),
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
export const MikkLockGenericSchema = z.object({
|
|
108
|
+
id: z.string(),
|
|
109
|
+
name: z.string(),
|
|
110
|
+
type: z.string(),
|
|
111
|
+
file: z.string(),
|
|
112
|
+
startLine: z.number(),
|
|
113
|
+
endLine: z.number(),
|
|
114
|
+
moduleId: z.string(),
|
|
115
|
+
isExported: z.boolean(),
|
|
116
|
+
purpose: z.string().optional(),
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
export const MikkLockSchema = z.object({
|
|
120
|
+
version: z.string(),
|
|
121
|
+
generatedAt: z.string(),
|
|
122
|
+
generatorVersion: z.string(),
|
|
123
|
+
projectRoot: z.string(),
|
|
124
|
+
syncState: z.object({
|
|
125
|
+
status: z.enum(['clean', 'syncing', 'drifted', 'conflict']),
|
|
126
|
+
lastSyncAt: z.string(),
|
|
127
|
+
lockHash: z.string(),
|
|
128
|
+
contractHash: z.string(),
|
|
129
|
+
}),
|
|
130
|
+
modules: z.record(MikkLockModuleSchema),
|
|
131
|
+
functions: z.record(MikkLockFunctionSchema),
|
|
132
|
+
classes: z.record(MikkLockClassSchema).optional(),
|
|
133
|
+
generics: z.record(MikkLockGenericSchema).optional(),
|
|
134
|
+
files: z.record(MikkLockFileSchema),
|
|
135
|
+
graph: z.object({
|
|
136
|
+
nodes: z.number(),
|
|
137
|
+
edges: z.number(),
|
|
138
|
+
rootHash: z.string(),
|
|
139
|
+
}),
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
export type MikkLock = z.infer<typeof MikkLockSchema>
|
|
143
|
+
export type MikkLockFunction = z.infer<typeof MikkLockFunctionSchema>
|
|
144
|
+
export type MikkLockModule = z.infer<typeof MikkLockModuleSchema>
|
|
145
|
+
export type MikkLockFile = z.infer<typeof MikkLockFileSchema>
|
|
146
|
+
export type MikkLockClass = z.infer<typeof MikkLockClassSchema>
|
|
147
|
+
export type MikkLockGeneric = z.infer<typeof MikkLockGenericSchema>
|