@getmikk/core 1.2.0 → 1.3.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.
Files changed (44) hide show
  1. package/README.md +431 -0
  2. package/package.json +6 -2
  3. package/src/contract/contract-generator.ts +85 -85
  4. package/src/contract/contract-reader.ts +28 -28
  5. package/src/contract/contract-writer.ts +114 -114
  6. package/src/contract/index.ts +12 -12
  7. package/src/contract/lock-compiler.ts +221 -221
  8. package/src/contract/lock-reader.ts +34 -34
  9. package/src/contract/schema.ts +147 -147
  10. package/src/graph/cluster-detector.ts +312 -312
  11. package/src/graph/graph-builder.ts +211 -211
  12. package/src/graph/impact-analyzer.ts +55 -55
  13. package/src/graph/index.ts +4 -4
  14. package/src/graph/types.ts +59 -59
  15. package/src/hash/file-hasher.ts +30 -30
  16. package/src/hash/hash-store.ts +119 -119
  17. package/src/hash/index.ts +3 -3
  18. package/src/hash/tree-hasher.ts +20 -20
  19. package/src/index.ts +12 -12
  20. package/src/parser/base-parser.ts +16 -16
  21. package/src/parser/boundary-checker.ts +211 -211
  22. package/src/parser/index.ts +46 -46
  23. package/src/parser/types.ts +90 -90
  24. package/src/parser/typescript/ts-extractor.ts +543 -543
  25. package/src/parser/typescript/ts-parser.ts +41 -41
  26. package/src/parser/typescript/ts-resolver.ts +86 -86
  27. package/src/utils/errors.ts +42 -42
  28. package/src/utils/fs.ts +75 -75
  29. package/src/utils/fuzzy-match.ts +186 -186
  30. package/src/utils/logger.ts +36 -36
  31. package/src/utils/minimatch.ts +19 -19
  32. package/tests/contract.test.ts +134 -134
  33. package/tests/fixtures/simple-api/package.json +5 -5
  34. package/tests/fixtures/simple-api/src/auth/middleware.ts +9 -9
  35. package/tests/fixtures/simple-api/src/auth/verify.ts +6 -6
  36. package/tests/fixtures/simple-api/src/index.ts +9 -9
  37. package/tests/fixtures/simple-api/src/utils/jwt.ts +3 -3
  38. package/tests/fixtures/simple-api/tsconfig.json +8 -8
  39. package/tests/fuzzy-match.test.ts +142 -142
  40. package/tests/graph.test.ts +169 -169
  41. package/tests/hash.test.ts +49 -49
  42. package/tests/helpers.ts +83 -83
  43. package/tests/parser.test.ts +218 -218
  44. package/tsconfig.json +15 -15
@@ -1,90 +1,90 @@
1
- /**
2
- * Parser types — data shapes that flow through the entire Mikk system.
3
- * Parser produces them, graph consumes them, contract stores them.
4
- */
5
-
6
- /** A single parameter in a function signature */
7
- export interface ParsedParam {
8
- name: string
9
- type: string
10
- optional: boolean
11
- defaultValue?: string
12
- }
13
-
14
- export interface ParsedFunction {
15
- id: string // "fn:auth/verify.ts:verifyToken"
16
- name: string // "verifyToken"
17
- file: string // "src/auth/verify.ts"
18
- startLine: number // 14
19
- endLine: number // 28
20
- params: ParsedParam[] // [{name: "token", type: "string"}]
21
- returnType: string // "boolean"
22
- isExported: boolean // true
23
- isAsync: boolean // false
24
- isGenerator?: boolean // true for function* / async function*
25
- typeParameters?: string[] // ["T", "U"] for generic functions
26
- calls: string[] // ["jwtDecode", "findUser"]
27
- hash: string // SHA-256 of the function body
28
- purpose: string // Extracted from JSDoc or comments
29
- edgeCasesHandled: string[] // Found conditions like 'if (!x) return'
30
- errorHandling: { line: number, type: 'try-catch' | 'throw', detail: string }[]
31
- detailedLines: { startLine: number, endLine: number, blockType: string }[]
32
- }
33
-
34
- /** A single import statement */
35
- export interface ParsedImport {
36
- source: string // "../../utils/jwt"
37
- resolvedPath: string // "src/utils/jwt.ts" (absolute within project)
38
- names: string[] // ["jwtDecode", "jwtSign"]
39
- isDefault: boolean // false
40
- isDynamic: boolean // false
41
- }
42
-
43
- /** A single exported symbol */
44
- export interface ParsedExport {
45
- name: string // "verifyToken"
46
- type: 'function' | 'class' | 'const' | 'type' | 'default' | 'interface'
47
- file: string
48
- }
49
-
50
- /** A parsed class */
51
- export interface ParsedClass {
52
- id: string
53
- name: string
54
- file: string
55
- startLine: number
56
- endLine: number
57
- methods: ParsedFunction[]
58
- isExported: boolean
59
- decorators?: string[] // ["Injectable", "Controller"]
60
- typeParameters?: string[] // ["T"] for generic classes
61
- purpose?: string
62
- edgeCasesHandled?: string[]
63
- errorHandling?: { line: number, type: 'try-catch' | 'throw', detail: string }[]
64
- }
65
-
66
- /** A generic declaration like interface, type, or constant with metadata */
67
- export interface ParsedGeneric {
68
- id: string
69
- name: string
70
- type: string // "interface" | "type" | "const"
71
- file: string
72
- startLine: number
73
- endLine: number
74
- isExported: boolean
75
- typeParameters?: string[] // ["T", "K"] for generic interfaces/types
76
- purpose?: string
77
- }
78
-
79
- /** Everything extracted from a single file */
80
- export interface ParsedFile {
81
- path: string // "src/auth/verify.ts"
82
- language: 'typescript' | 'python'
83
- functions: ParsedFunction[]
84
- classes: ParsedClass[]
85
- generics: ParsedGeneric[]
86
- imports: ParsedImport[]
87
- exports: ParsedExport[]
88
- hash: string // SHA-256 of the entire file content
89
- parsedAt: number // Date.now()
90
- }
1
+ /**
2
+ * Parser types — data shapes that flow through the entire Mikk system.
3
+ * Parser produces them, graph consumes them, contract stores them.
4
+ */
5
+
6
+ /** A single parameter in a function signature */
7
+ export interface ParsedParam {
8
+ name: string
9
+ type: string
10
+ optional: boolean
11
+ defaultValue?: string
12
+ }
13
+
14
+ export interface ParsedFunction {
15
+ id: string // "fn:auth/verify.ts:verifyToken"
16
+ name: string // "verifyToken"
17
+ file: string // "src/auth/verify.ts"
18
+ startLine: number // 14
19
+ endLine: number // 28
20
+ params: ParsedParam[] // [{name: "token", type: "string"}]
21
+ returnType: string // "boolean"
22
+ isExported: boolean // true
23
+ isAsync: boolean // false
24
+ isGenerator?: boolean // true for function* / async function*
25
+ typeParameters?: string[] // ["T", "U"] for generic functions
26
+ calls: string[] // ["jwtDecode", "findUser"]
27
+ hash: string // SHA-256 of the function body
28
+ purpose: string // Extracted from JSDoc or comments
29
+ edgeCasesHandled: string[] // Found conditions like 'if (!x) return'
30
+ errorHandling: { line: number, type: 'try-catch' | 'throw', detail: string }[]
31
+ detailedLines: { startLine: number, endLine: number, blockType: string }[]
32
+ }
33
+
34
+ /** A single import statement */
35
+ export interface ParsedImport {
36
+ source: string // "../../utils/jwt"
37
+ resolvedPath: string // "src/utils/jwt.ts" (absolute within project)
38
+ names: string[] // ["jwtDecode", "jwtSign"]
39
+ isDefault: boolean // false
40
+ isDynamic: boolean // false
41
+ }
42
+
43
+ /** A single exported symbol */
44
+ export interface ParsedExport {
45
+ name: string // "verifyToken"
46
+ type: 'function' | 'class' | 'const' | 'type' | 'default' | 'interface'
47
+ file: string
48
+ }
49
+
50
+ /** A parsed class */
51
+ export interface ParsedClass {
52
+ id: string
53
+ name: string
54
+ file: string
55
+ startLine: number
56
+ endLine: number
57
+ methods: ParsedFunction[]
58
+ isExported: boolean
59
+ decorators?: string[] // ["Injectable", "Controller"]
60
+ typeParameters?: string[] // ["T"] for generic classes
61
+ purpose?: string
62
+ edgeCasesHandled?: string[]
63
+ errorHandling?: { line: number, type: 'try-catch' | 'throw', detail: string }[]
64
+ }
65
+
66
+ /** A generic declaration like interface, type, or constant with metadata */
67
+ export interface ParsedGeneric {
68
+ id: string
69
+ name: string
70
+ type: string // "interface" | "type" | "const"
71
+ file: string
72
+ startLine: number
73
+ endLine: number
74
+ isExported: boolean
75
+ typeParameters?: string[] // ["T", "K"] for generic interfaces/types
76
+ purpose?: string
77
+ }
78
+
79
+ /** Everything extracted from a single file */
80
+ export interface ParsedFile {
81
+ path: string // "src/auth/verify.ts"
82
+ language: 'typescript' | 'python'
83
+ functions: ParsedFunction[]
84
+ classes: ParsedClass[]
85
+ generics: ParsedGeneric[]
86
+ imports: ParsedImport[]
87
+ exports: ParsedExport[]
88
+ hash: string // SHA-256 of the entire file content
89
+ parsedAt: number // Date.now()
90
+ }