@goodbones/core 0.1.0-beta.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.
Files changed (147) hide show
  1. package/LICENSE +21 -0
  2. package/build/dts/core/baseline.d.ts +16 -0
  3. package/build/dts/core/baseline.d.ts.map +1 -0
  4. package/build/dts/core/coverage.d.ts +47 -0
  5. package/build/dts/core/coverage.d.ts.map +1 -0
  6. package/build/dts/core/exports.d.ts +38 -0
  7. package/build/dts/core/exports.d.ts.map +1 -0
  8. package/build/dts/core/graph.d.ts +40 -0
  9. package/build/dts/core/graph.d.ts.map +1 -0
  10. package/build/dts/core/imports.d.ts +29 -0
  11. package/build/dts/core/imports.d.ts.map +1 -0
  12. package/build/dts/core/members.d.ts +26 -0
  13. package/build/dts/core/members.d.ts.map +1 -0
  14. package/build/dts/core/patterns.d.ts +17 -0
  15. package/build/dts/core/patterns.d.ts.map +1 -0
  16. package/build/dts/core/structure.d.ts +48 -0
  17. package/build/dts/core/structure.d.ts.map +1 -0
  18. package/build/dts/core/surface.d.ts +39 -0
  19. package/build/dts/core/surface.d.ts.map +1 -0
  20. package/build/dts/domain/architecture-config.d.ts +322 -0
  21. package/build/dts/domain/architecture-config.d.ts.map +1 -0
  22. package/build/dts/domain/architecture-error.d.ts +35 -0
  23. package/build/dts/domain/architecture-error.d.ts.map +1 -0
  24. package/build/dts/domain/facts.d.ts +26 -0
  25. package/build/dts/domain/facts.d.ts.map +1 -0
  26. package/build/dts/domain/violation.d.ts +11 -0
  27. package/build/dts/domain/violation.d.ts.map +1 -0
  28. package/build/dts/index.d.ts +23 -0
  29. package/build/dts/index.d.ts.map +1 -0
  30. package/build/dts/infrastructure/fact-extractor-fake.d.ts +4 -0
  31. package/build/dts/infrastructure/fact-extractor-fake.d.ts.map +1 -0
  32. package/build/dts/infrastructure/file-system-fake.d.ts +3 -0
  33. package/build/dts/infrastructure/file-system-fake.d.ts.map +1 -0
  34. package/build/dts/infrastructure/file-system-live.d.ts +3 -0
  35. package/build/dts/infrastructure/file-system-live.d.ts.map +1 -0
  36. package/build/dts/infrastructure/manifest-file.d.ts +3 -0
  37. package/build/dts/infrastructure/manifest-file.d.ts.map +1 -0
  38. package/build/dts/infrastructure/module-resolver-fake.d.ts +3 -0
  39. package/build/dts/infrastructure/module-resolver-fake.d.ts.map +1 -0
  40. package/build/dts/infrastructure/walk.d.ts +4 -0
  41. package/build/dts/infrastructure/walk.d.ts.map +1 -0
  42. package/build/dts/load/policy.d.ts +42 -0
  43. package/build/dts/load/policy.d.ts.map +1 -0
  44. package/build/dts/manifest/compile.d.ts +26 -0
  45. package/build/dts/manifest/compile.d.ts.map +1 -0
  46. package/build/dts/manifest/glob.d.ts +14 -0
  47. package/build/dts/manifest/glob.d.ts.map +1 -0
  48. package/build/dts/manifest/manifest.d.ts +208 -0
  49. package/build/dts/manifest/manifest.d.ts.map +1 -0
  50. package/build/dts/ports/fact-extractor.d.ts +5 -0
  51. package/build/dts/ports/fact-extractor.d.ts.map +1 -0
  52. package/build/dts/ports/file-system.d.ts +5 -0
  53. package/build/dts/ports/file-system.d.ts.map +1 -0
  54. package/build/dts/ports/language.d.ts +14 -0
  55. package/build/dts/ports/language.d.ts.map +1 -0
  56. package/build/dts/ports/module-resolver.d.ts +12 -0
  57. package/build/dts/ports/module-resolver.d.ts.map +1 -0
  58. package/build/dts/testing.d.ts +4 -0
  59. package/build/dts/testing.d.ts.map +1 -0
  60. package/build/esm/core/baseline.js +30 -0
  61. package/build/esm/core/baseline.js.map +1 -0
  62. package/build/esm/core/coverage.js +75 -0
  63. package/build/esm/core/coverage.js.map +1 -0
  64. package/build/esm/core/exports.js +102 -0
  65. package/build/esm/core/exports.js.map +1 -0
  66. package/build/esm/core/graph.js +259 -0
  67. package/build/esm/core/graph.js.map +1 -0
  68. package/build/esm/core/imports.js +103 -0
  69. package/build/esm/core/imports.js.map +1 -0
  70. package/build/esm/core/members.js +106 -0
  71. package/build/esm/core/members.js.map +1 -0
  72. package/build/esm/core/patterns.js +75 -0
  73. package/build/esm/core/patterns.js.map +1 -0
  74. package/build/esm/core/structure.js +257 -0
  75. package/build/esm/core/structure.js.map +1 -0
  76. package/build/esm/core/surface.js +137 -0
  77. package/build/esm/core/surface.js.map +1 -0
  78. package/build/esm/domain/architecture-config.js +312 -0
  79. package/build/esm/domain/architecture-config.js.map +1 -0
  80. package/build/esm/domain/architecture-error.js +41 -0
  81. package/build/esm/domain/architecture-error.js.map +1 -0
  82. package/build/esm/domain/facts.js +2 -0
  83. package/build/esm/domain/facts.js.map +1 -0
  84. package/build/esm/domain/violation.js +8 -0
  85. package/build/esm/domain/violation.js.map +1 -0
  86. package/build/esm/index.js +22 -0
  87. package/build/esm/index.js.map +1 -0
  88. package/build/esm/infrastructure/fact-extractor-fake.js +24 -0
  89. package/build/esm/infrastructure/fact-extractor-fake.js.map +1 -0
  90. package/build/esm/infrastructure/file-system-fake.js +10 -0
  91. package/build/esm/infrastructure/file-system-fake.js.map +1 -0
  92. package/build/esm/infrastructure/file-system-live.js +27 -0
  93. package/build/esm/infrastructure/file-system-live.js.map +1 -0
  94. package/build/esm/infrastructure/manifest-file.js +15 -0
  95. package/build/esm/infrastructure/manifest-file.js.map +1 -0
  96. package/build/esm/infrastructure/module-resolver-fake.js +33 -0
  97. package/build/esm/infrastructure/module-resolver-fake.js.map +1 -0
  98. package/build/esm/infrastructure/walk.js +45 -0
  99. package/build/esm/infrastructure/walk.js.map +1 -0
  100. package/build/esm/load/policy.js +207 -0
  101. package/build/esm/load/policy.js.map +1 -0
  102. package/build/esm/manifest/compile.js +706 -0
  103. package/build/esm/manifest/compile.js.map +1 -0
  104. package/build/esm/manifest/glob.js +77 -0
  105. package/build/esm/manifest/glob.js.map +1 -0
  106. package/build/esm/manifest/manifest.js +303 -0
  107. package/build/esm/manifest/manifest.js.map +1 -0
  108. package/build/esm/ports/fact-extractor.js +2 -0
  109. package/build/esm/ports/fact-extractor.js.map +1 -0
  110. package/build/esm/ports/file-system.js +2 -0
  111. package/build/esm/ports/file-system.js.map +1 -0
  112. package/build/esm/ports/language.js +2 -0
  113. package/build/esm/ports/language.js.map +1 -0
  114. package/build/esm/ports/module-resolver.js +2 -0
  115. package/build/esm/ports/module-resolver.js.map +1 -0
  116. package/build/esm/testing.js +7 -0
  117. package/build/esm/testing.js.map +1 -0
  118. package/package.json +61 -0
  119. package/src/core/baseline.ts +62 -0
  120. package/src/core/coverage.ts +154 -0
  121. package/src/core/exports.ts +171 -0
  122. package/src/core/graph.ts +331 -0
  123. package/src/core/imports.ts +160 -0
  124. package/src/core/members.ts +161 -0
  125. package/src/core/patterns.ts +116 -0
  126. package/src/core/structure.ts +349 -0
  127. package/src/core/surface.ts +181 -0
  128. package/src/domain/architecture-config.ts +370 -0
  129. package/src/domain/architecture-error.ts +59 -0
  130. package/src/domain/facts.ts +47 -0
  131. package/src/domain/violation.ts +24 -0
  132. package/src/index.ts +136 -0
  133. package/src/infrastructure/fact-extractor-fake.ts +28 -0
  134. package/src/infrastructure/file-system-fake.ts +14 -0
  135. package/src/infrastructure/file-system-live.ts +27 -0
  136. package/src/infrastructure/manifest-file.ts +17 -0
  137. package/src/infrastructure/module-resolver-fake.ts +39 -0
  138. package/src/infrastructure/walk.ts +54 -0
  139. package/src/load/policy.ts +344 -0
  140. package/src/manifest/compile.ts +1011 -0
  141. package/src/manifest/glob.ts +108 -0
  142. package/src/manifest/manifest.ts +408 -0
  143. package/src/ports/fact-extractor.ts +12 -0
  144. package/src/ports/file-system.ts +8 -0
  145. package/src/ports/language.ts +39 -0
  146. package/src/ports/module-resolver.ts +28 -0
  147. package/src/testing.ts +6 -0
@@ -0,0 +1,208 @@
1
+ import * as Result from "effect/Result";
2
+ import * as Schema from "effect/Schema";
3
+ import { ConfigInvalid } from "../domain/architecture-error.js";
4
+ declare const Imports: Schema.Struct<{
5
+ readonly message: Schema.optionalKey<Schema.String>;
6
+ readonly allow: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
7
+ readonly external: Schema.optionalKey<Schema.$Array<Schema.String>>;
8
+ readonly deny: Schema.optionalKey<Schema.$Array<Schema.Struct<{
9
+ readonly match: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
10
+ readonly matchNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
11
+ readonly except: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
12
+ readonly message: Schema.String;
13
+ }>>>;
14
+ readonly reset: Schema.optionalKey<Schema.Boolean>;
15
+ readonly unrestricted: Schema.optionalKey<Schema.Boolean>;
16
+ }>;
17
+ declare const ImportedBy: Schema.Struct<{
18
+ readonly message: Schema.String;
19
+ readonly allow: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
20
+ readonly matchNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
21
+ }>;
22
+ declare const Naming: Schema.Union<readonly [Schema.Literals<readonly ["kebab-case", "camelCase", "PascalCase", "snake_case"]>, Schema.Struct<{
23
+ readonly regex: Schema.String;
24
+ readonly message: Schema.optionalKey<Schema.String>;
25
+ }>, Schema.Struct<{
26
+ readonly like: Schema.String;
27
+ readonly message: Schema.optionalKey<Schema.String>;
28
+ }>]>;
29
+ declare const Members: Schema.Struct<{
30
+ readonly message: Schema.String;
31
+ readonly subject: Schema.Literals<readonly ["members", "calls"]>;
32
+ readonly in: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
33
+ readonly declares: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["function", "class", "variable", "type", "interface", "enum", "expression", "other"]>>>;
34
+ readonly match: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
35
+ readonly matchNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
36
+ readonly allow: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
37
+ readonly probe: Schema.optionalKey<Schema.Struct<{
38
+ readonly source: Schema.String;
39
+ readonly name: Schema.String;
40
+ }>>;
41
+ }>;
42
+ declare const Surface: Schema.Struct<{
43
+ readonly message: Schema.String;
44
+ readonly kinds: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["named", "default", "namespace"]>>>;
45
+ readonly declares: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["function", "class", "variable", "type", "interface", "enum", "expression", "other"]>>>;
46
+ readonly reexport: Schema.optionalKey<Schema.Boolean>;
47
+ readonly match: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
48
+ readonly matchNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
49
+ readonly forbid: Schema.optionalKey<Schema.Boolean>;
50
+ readonly allow: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
51
+ readonly convention: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["kebab-case", "camelCase", "PascalCase", "snake_case"]>, Schema.Struct<{
52
+ readonly regex: Schema.String;
53
+ }>]>>;
54
+ readonly count: Schema.optionalKey<Schema.Struct<{
55
+ readonly min: Schema.optionalKey<Schema.Finite>;
56
+ readonly max: Schema.optionalKey<Schema.Finite>;
57
+ }>>;
58
+ readonly except: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
59
+ readonly probe: Schema.optionalKey<Schema.Struct<{
60
+ readonly source: Schema.String;
61
+ }>>;
62
+ }>;
63
+ declare const ExportRestriction: Schema.Struct<{
64
+ readonly name: Schema.String;
65
+ readonly message: Schema.String;
66
+ readonly module: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
67
+ readonly symbols: Schema.optionalKey<Schema.$Array<Schema.String>>;
68
+ readonly kinds: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["named", "default", "namespace"]>>>;
69
+ readonly except: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
70
+ readonly fix: Schema.optionalKey<Schema.Literal<"subpath-namespace-import">>;
71
+ readonly probe: Schema.optionalKey<Schema.Struct<{
72
+ readonly source: Schema.String;
73
+ readonly symbol: Schema.String;
74
+ }>>;
75
+ }>;
76
+ export type ManifestNode = {
77
+ readonly message?: string;
78
+ readonly partial?: boolean;
79
+ readonly layout?: "open";
80
+ readonly name?: typeof Naming.Type;
81
+ readonly imports?: typeof Imports.Type;
82
+ readonly importedBy?: typeof ImportedBy.Type;
83
+ readonly members?: ReadonlyArray<typeof Members.Type>;
84
+ readonly surface?: ReadonlyArray<typeof Surface.Type>;
85
+ readonly requires?: ReadonlyArray<string>;
86
+ readonly requiresNot?: ReadonlyArray<string>;
87
+ readonly children?: Readonly<Record<string, ManifestNode>>;
88
+ };
89
+ declare const Graph: Schema.Struct<{
90
+ readonly cycles: Schema.optionalKey<Schema.$Array<Schema.Struct<{
91
+ readonly name: Schema.String;
92
+ readonly message: Schema.String;
93
+ readonly within: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
94
+ readonly withinNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
95
+ }>>>;
96
+ readonly orphans: Schema.optionalKey<Schema.$Array<Schema.Struct<{
97
+ readonly name: Schema.String;
98
+ readonly message: Schema.String;
99
+ readonly within: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
100
+ readonly withinNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
101
+ readonly entry: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
102
+ }>>>;
103
+ readonly reach: Schema.optionalKey<Schema.$Array<Schema.Struct<{
104
+ readonly name: Schema.String;
105
+ readonly message: Schema.String;
106
+ readonly from: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
107
+ readonly fromNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
108
+ readonly to: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
109
+ readonly toNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
110
+ readonly via: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
111
+ }>>>;
112
+ }>;
113
+ declare const Limits: Schema.Struct<{
114
+ readonly unrestricted: Schema.optionalKey<Schema.Finite>;
115
+ readonly partial: Schema.optionalKey<Schema.Finite>;
116
+ readonly coverage: Schema.optionalKey<Schema.Struct<{
117
+ readonly imports: Schema.optionalKey<Schema.Finite>;
118
+ readonly structure: Schema.optionalKey<Schema.Finite>;
119
+ readonly members: Schema.optionalKey<Schema.Finite>;
120
+ readonly surface: Schema.optionalKey<Schema.Finite>;
121
+ readonly graph: Schema.optionalKey<Schema.Finite>;
122
+ }>>;
123
+ }>;
124
+ export declare const Manifest: Schema.Struct<{
125
+ readonly resolve: Schema.Struct<{
126
+ readonly scopes: Schema.$Array<Schema.Struct<{
127
+ readonly files: Schema.String;
128
+ readonly language: Schema.String;
129
+ readonly options: Schema.optionalKey<Schema.Unknown>;
130
+ }>>;
131
+ readonly unresolved: Schema.optionalKey<Schema.Literals<readonly ["error", "off"]>>;
132
+ readonly ignoreUnresolved: Schema.optionalKey<Schema.$Array<Schema.String>>;
133
+ }>;
134
+ readonly baseline: Schema.optionalKey<Schema.String>;
135
+ readonly deny: Schema.optionalKey<Schema.$Array<Schema.Struct<{
136
+ readonly match: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
137
+ readonly matchNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
138
+ readonly except: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
139
+ readonly message: Schema.String;
140
+ }>>>;
141
+ readonly exports: Schema.optionalKey<Schema.$Array<Schema.Struct<{
142
+ readonly name: Schema.String;
143
+ readonly message: Schema.String;
144
+ readonly module: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
145
+ readonly symbols: Schema.optionalKey<Schema.$Array<Schema.String>>;
146
+ readonly kinds: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["named", "default", "namespace"]>>>;
147
+ readonly except: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
148
+ readonly fix: Schema.optionalKey<Schema.Literal<"subpath-namespace-import">>;
149
+ readonly probe: Schema.optionalKey<Schema.Struct<{
150
+ readonly source: Schema.String;
151
+ readonly symbol: Schema.String;
152
+ }>>;
153
+ }>>>;
154
+ readonly graph: Schema.optionalKey<Schema.Struct<{
155
+ readonly cycles: Schema.optionalKey<Schema.$Array<Schema.Struct<{
156
+ readonly name: Schema.String;
157
+ readonly message: Schema.String;
158
+ readonly within: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
159
+ readonly withinNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
160
+ }>>>;
161
+ readonly orphans: Schema.optionalKey<Schema.$Array<Schema.Struct<{
162
+ readonly name: Schema.String;
163
+ readonly message: Schema.String;
164
+ readonly within: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
165
+ readonly withinNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
166
+ readonly entry: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
167
+ }>>>;
168
+ readonly reach: Schema.optionalKey<Schema.$Array<Schema.Struct<{
169
+ readonly name: Schema.String;
170
+ readonly message: Schema.String;
171
+ readonly from: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
172
+ readonly fromNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
173
+ readonly to: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>;
174
+ readonly toNot: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
175
+ readonly via: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
176
+ }>>>;
177
+ }>>;
178
+ readonly limits: Schema.optionalKey<Schema.Struct<{
179
+ readonly unrestricted: Schema.optionalKey<Schema.Finite>;
180
+ readonly partial: Schema.optionalKey<Schema.Finite>;
181
+ readonly coverage: Schema.optionalKey<Schema.Struct<{
182
+ readonly imports: Schema.optionalKey<Schema.Finite>;
183
+ readonly structure: Schema.optionalKey<Schema.Finite>;
184
+ readonly members: Schema.optionalKey<Schema.Finite>;
185
+ readonly surface: Schema.optionalKey<Schema.Finite>;
186
+ readonly graph: Schema.optionalKey<Schema.Finite>;
187
+ }>>;
188
+ }>>;
189
+ readonly aliases: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
190
+ readonly tree: Schema.$Record<Schema.String, Schema.Codec<ManifestNode, ManifestNode, never, never>>;
191
+ }>;
192
+ export type Manifest = typeof Manifest.Type;
193
+ export type ImportsSpec = typeof Imports.Type;
194
+ export type ImportedBySpec = typeof ImportedBy.Type;
195
+ export type MembersSpec = typeof Members.Type;
196
+ export type SurfaceSpec = typeof Surface.Type;
197
+ export type GraphSpec = typeof Graph.Type;
198
+ export type LimitsSpec = typeof Limits.Type;
199
+ export type NamingSpec = typeof Naming.Type;
200
+ export type ExportRestriction = typeof ExportRestriction.Type;
201
+ export declare const globsOf: (globs: string | ReadonlyArray<string>) => ReadonlyArray<string>;
202
+ export type DecodedManifest = {
203
+ readonly manifest: Manifest;
204
+ readonly notices: ReadonlyArray<string>;
205
+ };
206
+ export declare const decodeManifest: (configPath: string, input: unknown) => Result.Result<DecodedManifest, ConfigInvalid>;
207
+ export {};
208
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/manifest/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MA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ourceFacts;
4
+ };
5
+ //# sourceMappingURL=fact-extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fact-extractor.d.ts","sourceRoot":"","sources":["../../../src/ports/fact-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAStD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,WAAW,CAAC;CAC/D,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type FileSystem = {
2
+ readonly exists: (repoRelativePath: string) => boolean;
3
+ readonly readText: (repoRelativePath: string) => string | null;
4
+ };
5
+ //# sourceMappingURL=file-system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-system.d.ts","sourceRoot":"","sources":["../../../src/ports/file-system.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,OAAO,CAAC;IAEvD,QAAQ,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CAChE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type * as Result from "effect/Result";
2
+ import type { ExportFix, ResolveScope } from "../domain/architecture-config.js";
3
+ import type { ScopeInvalid } from "../domain/architecture-error.js";
4
+ import type { FactExtractor } from "./fact-extractor.js";
5
+ import type { ModuleResolver } from "./module-resolver.js";
6
+ export type Language = {
7
+ readonly id: string;
8
+ readonly extensions: ReadonlyArray<string>;
9
+ readonly ignoredFiles: ReadonlyArray<RegExp>;
10
+ readonly extractor: FactExtractor;
11
+ readonly fixes: ReadonlyArray<ExportFix>;
12
+ readonly makeResolver: (repoRoot: string, scope: ResolveScope) => Result.Result<ModuleResolver, ScopeInvalid>;
13
+ };
14
+ //# sourceMappingURL=language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../../src/ports/language.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAU3D,MAAM,MAAM,QAAQ,GAAG;IAErB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAG3C,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAG7C,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAIlC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAKzC,QAAQ,CAAC,YAAY,EAAE,CACrB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,YAAY,KAChB,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;CAClD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type * as Result from "effect/Result";
2
+ import type { ImportUnresolved } from "../domain/architecture-error.js";
3
+ export type DependencyKind = "local" | "external" | "builtin";
4
+ export type ResolvedTarget = {
5
+ readonly path: string;
6
+ readonly kind: DependencyKind;
7
+ readonly package?: string;
8
+ };
9
+ export type ModuleResolver = {
10
+ readonly resolve: (fromFile: string, specifier: string) => Result.Result<ResolvedTarget, ImportUnresolved>;
11
+ };
12
+ //# sourceMappingURL=module-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-resolver.d.ts","sourceRoot":"","sources":["../../../src/ports/module-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG;IAM3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAGtB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAI9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE,CAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;CACtD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { makeFactExtractorFake } from "./infrastructure/fact-extractor-fake.js";
2
+ export { makeFileSystemFake } from "./infrastructure/file-system-fake.js";
3
+ export { makeModuleResolverFake } from "./infrastructure/module-resolver-fake.js";
4
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/testing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { fingerprintOf } from "../domain/violation.js";
2
+ export const EMPTY_BASELINE = { version: 1, entries: [] };
3
+ export const baselineOf = (violations) => ({
4
+ version: 1,
5
+ entries: [...new Set([...violations].map(fingerprintOf))].sort(),
6
+ });
7
+ export const decodeBaseline = (raw) => {
8
+ if (typeof raw !== "object" || raw === null)
9
+ return EMPTY_BASELINE;
10
+ const entries = raw.entries;
11
+ if (!Array.isArray(entries))
12
+ return EMPTY_BASELINE;
13
+ return { version: 1, entries: entries.filter((one) => typeof one === "string") };
14
+ };
15
+ export const serializeBaseline = (baseline) => `${JSON.stringify(baseline, null, 2)}\n`;
16
+ export const makeBaselineFilter = (baseline) => {
17
+ const entries = new Set(baseline.entries);
18
+ return { isBaselined: (violation) => entries.has(fingerprintOf(violation)) };
19
+ };
20
+ // The ratchet's teeth: entries the code no longer produces. A baseline that is
21
+ // allowed to keep them stops being a record of debt and becomes a place to hide.
22
+ export const staleEntriesOf = (baseline, violations) => {
23
+ const current = new Set([...violations].map(fingerprintOf));
24
+ return baseline.entries.filter((entry) => !current.has(entry));
25
+ };
26
+ export const unbaselined = (baseline, violations) => {
27
+ const { isBaselined } = makeBaselineFilter(baseline);
28
+ return [...violations].filter((violation) => !isBaselined(violation));
29
+ };
30
+ //# sourceMappingURL=baseline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline.js","sourceRoot":"","sources":["../../../src/core/baseline.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAkBvD,MAAM,CAAC,MAAM,cAAc,GAAa,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAEpE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAA+B,EAAY,EAAE,CAAC,CAAC;IACxE,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;CACjE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAY,EAAY,EAAE;IACvD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,cAAc,CAAC;IACnE,MAAM,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;IACrD,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACxE,CAAC,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { OPEN_LAYOUT } from "../domain/architecture-config.js";
2
+ import { firstFromMatch } from "./patterns.js";
3
+ // An allowlist names no `to`: it fires when the target matches none of its
4
+ // `toNot`. A prohibition names one. Only the former bounds a file.
5
+ const isAllowlist = (rule) => rule.to.length === 0 && rule.toNot.length > 0;
6
+ const dirnameOf = (file) => {
7
+ const at = file.lastIndexOf("/");
8
+ return at === -1 ? "" : file.slice(0, at);
9
+ };
10
+ const selects = (rule, file) => firstFromMatch(rule, file) !== null;
11
+ export const coverageOf = (policy, files) => {
12
+ const allowlists = policy.importRules.filter(isAllowlist);
13
+ let imports = 0;
14
+ let enumerated = 0;
15
+ let open = 0;
16
+ let members = 0;
17
+ let surface = 0;
18
+ let graph = 0;
19
+ for (const file of files) {
20
+ if (allowlists.some((rule) => selects(rule, file)))
21
+ imports += 1;
22
+ const folder = dirnameOf(file);
23
+ const governing = policy.structure.folders.filter((rule) => rule.folder.some((pattern) => pattern.test(folder)));
24
+ if (governing.length > 0) {
25
+ if (governing.every((rule) => rule.files.some((pattern) => pattern.source === OPEN_LAYOUT))) {
26
+ open += 1;
27
+ }
28
+ else {
29
+ enumerated += 1;
30
+ }
31
+ }
32
+ if (policy.memberRules.some((rule) => selects(rule, file)))
33
+ members += 1;
34
+ if (policy.surfaceRules.some((rule) => selects(rule, file)))
35
+ surface += 1;
36
+ const scoped = [...policy.graph.cycles, ...policy.graph.orphans].some((rule) => rule.within.some((pattern) => pattern.test(file)) &&
37
+ !rule.withinNot.some((pattern) => pattern.test(file)));
38
+ if (scoped)
39
+ graph += 1;
40
+ }
41
+ const total = files.length;
42
+ return {
43
+ files: total,
44
+ imports: { covered: imports, total },
45
+ structure: { enumerated, open, total },
46
+ members: { covered: members, total },
47
+ surface: { covered: surface, total },
48
+ graph: { covered: graph, total },
49
+ };
50
+ };
51
+ export const fractionOf = (covered, total) => total === 0 ? 1 : covered / total;
52
+ export const fractionsOf = (coverage) => ({
53
+ imports: fractionOf(coverage.imports.covered, coverage.imports.total),
54
+ structure: fractionOf(coverage.structure.enumerated, coverage.structure.total),
55
+ members: fractionOf(coverage.members.covered, coverage.members.total),
56
+ surface: fractionOf(coverage.surface.covered, coverage.surface.total),
57
+ graph: fractionOf(coverage.graph.covered, coverage.graph.total),
58
+ });
59
+ export const coverageShortfalls = (coverage, floors) => {
60
+ const actual = fractionsOf(coverage);
61
+ const families = [
62
+ "imports",
63
+ "structure",
64
+ "members",
65
+ "surface",
66
+ "graph",
67
+ ];
68
+ return families.flatMap((family) => {
69
+ const floor = floors[family];
70
+ if (floor === undefined || actual[family] >= floor)
71
+ return [];
72
+ return [{ family, actual: actual[family], floor }];
73
+ });
74
+ };
75
+ //# sourceMappingURL=coverage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../../src/core/coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAI/D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA0C/C,2EAA2E;AAC3E,mEAAmE;AACnE,MAAM,WAAW,GAAG,CAAC,IAAwB,EAAW,EAAE,CACxD,IAAI,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAEhD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE;IACzC,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC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AAE,OAAO,EAAE,CAAC;QAC9D,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,102 @@
1
+ import * as Result from "effect/Result";
2
+ import { compilePatterns, firstFromMatch, sourcesOf, targetAllowed, validateTargetPatterns, } from "./patterns.js";
3
+ const DEFAULT_KINDS = ["named"];
4
+ export const compileExportRule = (rule) => {
5
+ const from = compilePatterns(rule.name, "from", rule.from);
6
+ if (Result.isFailure(from))
7
+ return Result.fail(from.failure);
8
+ const fromNot = compilePatterns(rule.name, "fromNot", rule.fromNot);
9
+ if (Result.isFailure(fromNot))
10
+ return Result.fail(fromNot.failure);
11
+ const targets = validateTargetPatterns(rule.name, [
12
+ ["to", rule.to],
13
+ ["toNot", rule.toNot],
14
+ ]);
15
+ if (Result.isFailure(targets))
16
+ return Result.fail(targets.failure);
17
+ return Result.succeed({
18
+ name: rule.name,
19
+ message: rule.message,
20
+ probe: rule.probe,
21
+ from: from.success,
22
+ fromNot: fromNot.success,
23
+ to: sourcesOf(rule.to),
24
+ toNot: sourcesOf(rule.toNot),
25
+ symbols: rule.symbols === undefined ? null : new Set(rule.symbols),
26
+ kinds: rule.kinds ?? DEFAULT_KINDS,
27
+ fix: rule.fix ?? null,
28
+ });
29
+ };
30
+ export const compileExportRules = (rules) => {
31
+ const compiled = [];
32
+ for (const rule of rules) {
33
+ const one = compileExportRule(rule);
34
+ if (Result.isFailure(one))
35
+ return Result.fail(one.failure);
36
+ compiled.push(one.success);
37
+ }
38
+ return Result.succeed(compiled);
39
+ };
40
+ export const exportRulesSelecting = (rules, importer) => {
41
+ const selected = [];
42
+ for (const rule of rules) {
43
+ const captures = firstFromMatch(rule, importer);
44
+ if (captures !== null)
45
+ selected.push([rule, captures]);
46
+ }
47
+ return selected;
48
+ };
49
+ const covers = (rule, binding) => rule.kinds.includes(binding.kind) && (rule.symbols === null || rule.symbols.has(binding.symbol));
50
+ export const evaluateSelectedBindings = (selected, resolver, edge) => {
51
+ if (selected.length === 0 || edge.bindings.length === 0)
52
+ return Result.succeed([]);
53
+ const resolved = resolver.resolve(edge.importer, edge.specifier);
54
+ if (Result.isFailure(resolved))
55
+ return Result.fail(resolved.failure);
56
+ const target = resolved.success;
57
+ const violations = [];
58
+ for (const [rule, captures] of selected) {
59
+ if (!targetAllowed(rule, captures, target.path))
60
+ continue;
61
+ const offending = edge.bindings.filter((binding) => covers(rule, binding));
62
+ if (offending.length === 0)
63
+ continue;
64
+ // A rule carrying a fix reports once for the whole declaration, because the
65
+ // fix rewrites the declaration as a unit; one without reports per symbol, so
66
+ // the diagnostic sits on the name that is actually restricted.
67
+ const groups = rule.fix === null ? offending.map((binding) => [binding]) : [offending];
68
+ for (const bindings of groups) {
69
+ violations.push({
70
+ rule,
71
+ bindings,
72
+ violation: {
73
+ kind: "export",
74
+ ruleName: rule.name,
75
+ message: rule.message,
76
+ file: edge.importer,
77
+ subject: `${target.path}#${bindings.map((binding) => binding.symbol).join(",")}`,
78
+ },
79
+ });
80
+ }
81
+ }
82
+ return Result.succeed(violations);
83
+ };
84
+ export const evaluateBindingEdge = (rules, resolver, edge) => evaluateSelectedBindings(exportRulesSelecting(rules, edge.importer), resolver, edge);
85
+ // A probe with a `source` is checked through the parser: every edge in the
86
+ // snippet is taken to resolve to `probe.to`, and a binding named `probe.symbol`
87
+ // must come out of the extractor covered by the rule. A probe without one is
88
+ // checked against the rule's patterns alone.
89
+ export const exportRulesFailingTheirProbe = (rules, extractor) => rules.filter((rule) => {
90
+ const captures = firstFromMatch(rule, rule.probe.from);
91
+ if (captures === null)
92
+ return true;
93
+ if (!targetAllowed(rule, captures, rule.probe.to))
94
+ return true;
95
+ if (rule.probe.source === undefined) {
96
+ return !covers(rule, { symbol: rule.probe.symbol, kind: rule.probe.kind ?? "named" });
97
+ }
98
+ const facts = extractor.factsOf(rule.probe.from, rule.probe.source);
99
+ const bindings = [...facts.bindings.values()].flat();
100
+ return !bindings.some((binding) => binding.symbol === rule.probe.symbol && covers(rule, binding));
101
+ });
102
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../src/core/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAQxC,OAAO,EACL,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAIvB,MAAM,aAAa,GAA+B,CAAC,OAAO,CAAC,CAAC;AAe5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAgB,EACmC,EAAE;IACrD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACpE,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnE,MAAM,OAAO,GAAG,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE;QAChD,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACf,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;KACtB,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnE,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,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