@repometry/core 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/package.json +48 -4
- package/target/main/resources/plugin-v1.schema.json +328 -0
- package/target/main/ts/engine/author-contracts.d.ts +25 -0
- package/target/main/ts/engine/author-contracts.js +51 -0
- package/target/main/ts/engine/execute.d.ts +15 -0
- package/target/main/ts/engine/execute.js +63 -0
- package/target/main/ts/engine/manifest.d.ts +3 -0
- package/target/main/ts/engine/manifest.js +129 -0
- package/target/main/ts/engine/operation-cache.d.ts +14 -0
- package/target/main/ts/engine/operation-cache.js +66 -0
- package/target/main/ts/engine/plan.d.ts +21 -0
- package/target/main/ts/engine/plan.js +123 -0
- package/target/main/ts/engine/plugin-manifest.d.ts +40 -0
- package/target/main/ts/engine/plugin-manifest.js +7 -0
- package/target/main/ts/engine/plugin.d.ts +71 -0
- package/target/main/ts/engine/plugin.js +3 -0
- package/target/main/ts/engine/report-products.d.ts +16 -0
- package/target/main/ts/engine/report-products.js +76 -0
- package/target/main/ts/index.d.ts +13 -0
- package/target/main/ts/index.js +5 -0
- package/target/main/ts/model/changes.d.ts +39 -0
- package/target/main/ts/model/changes.js +6 -0
- package/target/main/ts/model/churn.d.ts +11 -0
- package/target/main/ts/model/churn.js +6 -0
- package/target/main/ts/model/clone-source.d.ts +19 -0
- package/target/main/ts/model/clone-source.js +20 -0
- package/target/main/ts/model/code-structure.d.ts +45 -0
- package/target/main/ts/model/code-structure.js +63 -0
- package/target/main/ts/model/comparison.d.ts +24 -0
- package/target/main/ts/model/comparison.js +2 -0
- package/target/main/ts/model/coverage-input.d.ts +12 -0
- package/target/main/ts/model/coverage-input.js +11 -0
- package/target/main/ts/model/diff-coverage.d.ts +25 -0
- package/target/main/ts/model/diff-coverage.js +10 -0
- package/target/main/ts/model/file-types.d.ts +20 -0
- package/target/main/ts/model/file-types.js +50 -0
- package/target/main/ts/model/finding-ignore.d.ts +8 -0
- package/target/main/ts/model/finding-ignore.js +48 -0
- package/target/main/ts/model/finding.d.ts +34 -0
- package/target/main/ts/model/finding.js +45 -0
- package/target/main/ts/model/ignore-rule.d.ts +22 -0
- package/target/main/ts/model/ignore-rule.js +2 -0
- package/target/main/ts/model/inspection-category.d.ts +8 -0
- package/target/main/ts/model/inspection-category.js +8 -0
- package/target/main/ts/model/language.d.ts +44 -0
- package/target/main/ts/model/language.js +31 -0
- package/target/main/ts/model/line-coverage.d.ts +15 -0
- package/target/main/ts/model/line-coverage.js +43 -0
- package/target/main/ts/model/measurement.d.ts +34 -0
- package/target/main/ts/model/measurement.js +42 -0
- package/target/main/ts/model/metric-descriptor.d.ts +17 -0
- package/target/main/ts/model/metric-descriptor.js +2 -0
- package/target/main/ts/model/plugin-data.d.ts +32 -0
- package/target/main/ts/model/plugin-data.js +16 -0
- package/target/main/ts/model/pull-review.d.ts +70 -0
- package/target/main/ts/model/pull-review.js +4 -0
- package/target/main/ts/model/quality-summary.d.ts +46 -0
- package/target/main/ts/model/quality-summary.js +92 -0
- package/target/main/ts/model/report.d.ts +45 -0
- package/target/main/ts/model/report.js +5 -0
- package/target/main/ts/model/scanner-import.d.ts +39 -0
- package/target/main/ts/model/scanner-import.js +29 -0
- package/target/main/ts/model/snapshot.d.ts +14 -0
- package/target/main/ts/model/snapshot.js +49 -0
- package/target/main/ts/model/source-locator.d.ts +7 -0
- package/target/main/ts/model/source-locator.js +2 -0
- package/target/main/ts/model/source.d.ts +31 -0
- package/target/main/ts/model/source.js +20 -0
- package/target/main/ts/ports/report.d.ts +9 -0
- package/target/main/ts/ports/report.js +2 -0
- package/target/main/ts/ports/source-provider.d.ts +14 -0
- package/target/main/ts/ports/source-provider.js +5 -0
- package/target/main/ts/ports/tool-runner.d.ts +18 -0
- package/target/main/ts/ports/tool-runner.js +2 -0
- package/target/main/ts/profile/exclusions.d.ts +11 -0
- package/target/main/ts/profile/exclusions.js +58 -0
- package/target/main/ts/profile/ignore.d.ts +4 -0
- package/target/main/ts/profile/ignore.js +82 -0
- package/target/main/ts/profile/maintainability.d.ts +31 -0
- package/target/main/ts/profile/maintainability.js +10 -0
- package/target/main/ts/profile/profile.d.ts +4 -0
- package/target/main/ts/profile/profile.js +11 -0
- package/target/main/ts/usecases/diff-coverage-policy.d.ts +6 -0
- package/target/main/ts/usecases/diff-coverage-policy.js +11 -0
- package/target/main/ts/usecases/diff-coverage.d.ts +40 -0
- package/target/main/ts/usecases/diff-coverage.js +16 -0
- package/target/main/ts/usecases/inspect.d.ts +38 -0
- package/target/main/ts/usecases/inspect.js +48 -0
- package/target/main/ts/usecases/review-effect.d.ts +18 -0
- package/target/main/ts/usecases/review-effect.js +37 -0
- package/target/main/ts/usecases/review-match.d.ts +14 -0
- package/target/main/ts/usecases/review-match.js +72 -0
- package/target/main/ts/usecases/review-position.d.ts +14 -0
- package/target/main/ts/usecases/review-position.js +53 -0
- package/target/main/ts/usecases/review-scope.d.ts +21 -0
- package/target/main/ts/usecases/review-scope.js +41 -0
- package/target/main/ts/usecases/review.d.ts +42 -0
- package/target/main/ts/usecases/review.js +112 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Idleware
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repometry/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Repometry plugin API and inspection engine",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/idleware/repometry.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/idleware/repometry#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/idleware/repometry/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"repometry",
|
|
16
|
+
"plugin",
|
|
17
|
+
"metrics"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=24"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./target/main/ts/index.d.ts",
|
|
26
|
+
"default": "./target/main/ts/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./internal/*.js": {
|
|
29
|
+
"types": "./target/main/ts/*.d.ts",
|
|
30
|
+
"default": "./target/main/ts/*.js"
|
|
31
|
+
},
|
|
32
|
+
"./plugin-v1.schema.json": "./target/main/resources/plugin-v1.schema.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"target/main",
|
|
36
|
+
"!target/main/**/*.map"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "node -e \"require('node:fs').rmSync('target/main', { recursive: true, force: true })\" && tsc -p tsconfig.json && node -e \"const fs = require('node:fs'); fs.cpSync('../../LICENSE', 'LICENSE'); fs.cpSync('src/main/resources', 'target/main/resources', { recursive: true })\"",
|
|
43
|
+
"build:test": "npm run build && node -e \"require('node:fs').rmSync('target/verification', { recursive: true, force: true })\" && tsc -p tsconfig.test.json",
|
|
44
|
+
"test": "npm run build:test && node --test 'target/verification/test/ts/*.test.js'",
|
|
45
|
+
"prepack": "npm run build"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"ajv": "8.20.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "urn:repometry:schema:plugin:1",
|
|
4
|
+
"title": "Repometry plugin manifest",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"schema",
|
|
9
|
+
"id",
|
|
10
|
+
"category"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"id": {
|
|
14
|
+
"$ref": "#/$defs/id"
|
|
15
|
+
},
|
|
16
|
+
"version": {
|
|
17
|
+
"$ref": "#/$defs/text"
|
|
18
|
+
},
|
|
19
|
+
"image": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9.:/@_-]*$"
|
|
22
|
+
},
|
|
23
|
+
"command": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"minItems": 1,
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"pattern": "^[^\\u0000]*$"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"scope": {
|
|
32
|
+
"enum": [
|
|
33
|
+
"file",
|
|
34
|
+
"repository"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"fileIndependent": {
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"description": "Each file's results and diagnostics are independent of the other files supplied to a repository parser."
|
|
40
|
+
},
|
|
41
|
+
"include": {
|
|
42
|
+
"$ref": "#/$defs/globs"
|
|
43
|
+
},
|
|
44
|
+
"exclude": {
|
|
45
|
+
"$ref": "#/$defs/globs"
|
|
46
|
+
},
|
|
47
|
+
"limits": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"properties": {
|
|
51
|
+
"timeoutMs": {
|
|
52
|
+
"type": "integer",
|
|
53
|
+
"minimum": 1,
|
|
54
|
+
"maximum": 2147483647
|
|
55
|
+
},
|
|
56
|
+
"maxOutputBytes": {
|
|
57
|
+
"$ref": "#/$defs/positiveInteger"
|
|
58
|
+
},
|
|
59
|
+
"memoryBytes": {
|
|
60
|
+
"$ref": "#/$defs/positiveInteger"
|
|
61
|
+
},
|
|
62
|
+
"pidsLimit": {
|
|
63
|
+
"$ref": "#/$defs/positiveInteger"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"tools": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"minProperties": 1,
|
|
70
|
+
"additionalProperties": {
|
|
71
|
+
"$ref": "#/$defs/text"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"languages": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"minItems": 1,
|
|
77
|
+
"items": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"additionalProperties": false,
|
|
80
|
+
"required": [
|
|
81
|
+
"id",
|
|
82
|
+
"label",
|
|
83
|
+
"include"
|
|
84
|
+
],
|
|
85
|
+
"properties": {
|
|
86
|
+
"id": {
|
|
87
|
+
"$ref": "#/$defs/id"
|
|
88
|
+
},
|
|
89
|
+
"label": {
|
|
90
|
+
"$ref": "#/$defs/text"
|
|
91
|
+
},
|
|
92
|
+
"color": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"pattern": "^#[0-9A-Fa-f]{6}$"
|
|
95
|
+
},
|
|
96
|
+
"syntax": {
|
|
97
|
+
"$ref": "#/$defs/syntax"
|
|
98
|
+
},
|
|
99
|
+
"measures": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"uniqueItems": true,
|
|
102
|
+
"items": {
|
|
103
|
+
"enum": [
|
|
104
|
+
"functions",
|
|
105
|
+
"cyclomaticComplexity",
|
|
106
|
+
"cognitiveComplexity",
|
|
107
|
+
"classes",
|
|
108
|
+
"commentLines",
|
|
109
|
+
"codeLines",
|
|
110
|
+
"duplication",
|
|
111
|
+
"checks"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"include": {
|
|
116
|
+
"$ref": "#/$defs/globs"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"optionsSchema": {
|
|
122
|
+
"anyOf": [
|
|
123
|
+
{
|
|
124
|
+
"type": "object"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"type": "boolean"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
"requires": {
|
|
132
|
+
"type": "object",
|
|
133
|
+
"additionalProperties": false,
|
|
134
|
+
"properties": {
|
|
135
|
+
"node": {
|
|
136
|
+
"$ref": "#/$defs/text"
|
|
137
|
+
},
|
|
138
|
+
"repometry": {
|
|
139
|
+
"$ref": "#/$defs/text"
|
|
140
|
+
},
|
|
141
|
+
"tools": {
|
|
142
|
+
"type": "array",
|
|
143
|
+
"uniqueItems": true,
|
|
144
|
+
"items": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"pattern": "^[^\\s/\\\\\\u0000]+$"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"schema": {
|
|
152
|
+
"const": "urn:repometry:schema:plugin:1"
|
|
153
|
+
},
|
|
154
|
+
"category": {
|
|
155
|
+
"enum": [
|
|
156
|
+
"language",
|
|
157
|
+
"source",
|
|
158
|
+
"maintainability",
|
|
159
|
+
"coverage",
|
|
160
|
+
"security"
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
"checks": {
|
|
164
|
+
"type": "array",
|
|
165
|
+
"items": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"required": [
|
|
168
|
+
"id"
|
|
169
|
+
],
|
|
170
|
+
"additionalProperties": false,
|
|
171
|
+
"properties": {
|
|
172
|
+
"id": {
|
|
173
|
+
"$ref": "#/$defs/text"
|
|
174
|
+
},
|
|
175
|
+
"description": {
|
|
176
|
+
"$ref": "#/$defs/text"
|
|
177
|
+
},
|
|
178
|
+
"measure": {
|
|
179
|
+
"$ref": "#/$defs/text"
|
|
180
|
+
},
|
|
181
|
+
"defaults": {
|
|
182
|
+
"type": "object",
|
|
183
|
+
"additionalProperties": false,
|
|
184
|
+
"properties": {
|
|
185
|
+
"limit": {
|
|
186
|
+
"type": "number",
|
|
187
|
+
"minimum": 0
|
|
188
|
+
},
|
|
189
|
+
"cost": {
|
|
190
|
+
"type": "number",
|
|
191
|
+
"minimum": 0
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"per": {
|
|
196
|
+
"type": "array",
|
|
197
|
+
"minItems": 2,
|
|
198
|
+
"maxItems": 2,
|
|
199
|
+
"items": {
|
|
200
|
+
"$ref": "#/$defs/text"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"$defs": {
|
|
208
|
+
"syntax": {
|
|
209
|
+
"type": "object",
|
|
210
|
+
"additionalProperties": false,
|
|
211
|
+
"properties": {
|
|
212
|
+
"lineComments": {
|
|
213
|
+
"type": "array",
|
|
214
|
+
"items": {
|
|
215
|
+
"$ref": "#/$defs/syntax/$defs/marker"
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
"blockComments": {
|
|
219
|
+
"type": "array",
|
|
220
|
+
"items": {
|
|
221
|
+
"type": "array",
|
|
222
|
+
"minItems": 2,
|
|
223
|
+
"maxItems": 2,
|
|
224
|
+
"items": {
|
|
225
|
+
"$ref": "#/$defs/syntax/$defs/marker"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"strings": {
|
|
230
|
+
"type": "array",
|
|
231
|
+
"items": {
|
|
232
|
+
"type": "object",
|
|
233
|
+
"required": [
|
|
234
|
+
"quote"
|
|
235
|
+
],
|
|
236
|
+
"additionalProperties": false,
|
|
237
|
+
"properties": {
|
|
238
|
+
"quote": {
|
|
239
|
+
"$ref": "#/$defs/syntax/$defs/marker"
|
|
240
|
+
},
|
|
241
|
+
"multiline": {
|
|
242
|
+
"type": "boolean"
|
|
243
|
+
},
|
|
244
|
+
"raw": {
|
|
245
|
+
"type": "boolean"
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"stringPrefixes": {
|
|
251
|
+
"type": "array",
|
|
252
|
+
"items": {
|
|
253
|
+
"$ref": "#/$defs/syntax/$defs/word"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"keywords": {
|
|
257
|
+
"type": "array",
|
|
258
|
+
"maxItems": 512,
|
|
259
|
+
"items": {
|
|
260
|
+
"$ref": "#/$defs/syntax/$defs/word"
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"regexAfter": {
|
|
264
|
+
"type": "array",
|
|
265
|
+
"items": {
|
|
266
|
+
"$ref": "#/$defs/syntax/$defs/word"
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"$defs": {
|
|
271
|
+
"marker": {
|
|
272
|
+
"type": "string",
|
|
273
|
+
"minLength": 1,
|
|
274
|
+
"maxLength": 8,
|
|
275
|
+
"pattern": "^\\S+$"
|
|
276
|
+
},
|
|
277
|
+
"word": {
|
|
278
|
+
"type": "string",
|
|
279
|
+
"pattern": "^[A-Za-z_$][\\w$]*$"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
"id": {
|
|
284
|
+
"type": "string",
|
|
285
|
+
"pattern": "^[a-z][a-z0-9-]*$"
|
|
286
|
+
},
|
|
287
|
+
"text": {
|
|
288
|
+
"type": "string",
|
|
289
|
+
"pattern": "\\S"
|
|
290
|
+
},
|
|
291
|
+
"positiveInteger": {
|
|
292
|
+
"type": "integer",
|
|
293
|
+
"minimum": 1,
|
|
294
|
+
"maximum": 9007199254740991
|
|
295
|
+
},
|
|
296
|
+
"globs": {
|
|
297
|
+
"type": "array",
|
|
298
|
+
"uniqueItems": true,
|
|
299
|
+
"items": {
|
|
300
|
+
"$ref": "#/$defs/text"
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
"allOf": [
|
|
305
|
+
{
|
|
306
|
+
"if": {
|
|
307
|
+
"required": [
|
|
308
|
+
"category"
|
|
309
|
+
],
|
|
310
|
+
"properties": {
|
|
311
|
+
"category": {
|
|
312
|
+
"const": "language"
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
"then": {
|
|
317
|
+
"required": [
|
|
318
|
+
"languages"
|
|
319
|
+
]
|
|
320
|
+
},
|
|
321
|
+
"else": {
|
|
322
|
+
"properties": {
|
|
323
|
+
"languages": false
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DataContract } from './plugin.js';
|
|
2
|
+
import type { CodeStructure as StoredStructure, StructuralObservation as StoredObservation } from '../model/code-structure.js';
|
|
3
|
+
import type { Finding as StoredFinding, FindingResult as StoredFindings } from '../model/finding.js';
|
|
4
|
+
import type { PluginCategory } from '../model/inspection-category.js';
|
|
5
|
+
export type StructuralObservation = Omit<StoredObservation, 'rule'> & {
|
|
6
|
+
readonly check: StoredObservation['rule'];
|
|
7
|
+
};
|
|
8
|
+
export type CodeStructure = Omit<StoredStructure, 'observations'> & {
|
|
9
|
+
readonly observations?: readonly StructuralObservation[];
|
|
10
|
+
};
|
|
11
|
+
export type Finding = Omit<StoredFinding, 'tool' | 'rule' | 'category'> & {
|
|
12
|
+
readonly plugin?: string;
|
|
13
|
+
readonly check: string;
|
|
14
|
+
};
|
|
15
|
+
export type FindingResult = Omit<StoredFindings, 'findings'> & {
|
|
16
|
+
readonly findings: readonly Finding[];
|
|
17
|
+
};
|
|
18
|
+
export declare const codeStructure: DataContract<CodeStructure>;
|
|
19
|
+
export declare const codeStructures: DataContract<readonly CodeStructure[]>;
|
|
20
|
+
export declare const findingResult: DataContract<FindingResult>;
|
|
21
|
+
export declare function writeStructure(value: unknown): unknown;
|
|
22
|
+
export declare function writeFindings(value: unknown, id?: string, dimension?: PluginCategory): unknown;
|
|
23
|
+
export declare function readStructure(value: StoredStructure): CodeStructure;
|
|
24
|
+
export declare function readFindings(value: StoredFindings): FindingResult;
|
|
25
|
+
export declare function findingCategory(dimension: PluginCategory | undefined, chargesEffort: boolean): StoredFinding['category'];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { codeStructure as storedStructure, codeStructures as storedStructures } from '../model/code-structure.js';
|
|
2
|
+
import { findingResult as storedFindings } from '../model/finding.js';
|
|
3
|
+
import { category } from '../model/inspection-category.js';
|
|
4
|
+
import { isRecord } from '../model/plugin-data.js';
|
|
5
|
+
export const codeStructure = { id: storedStructure.id,
|
|
6
|
+
accepts: (value) => storedStructure.accepts(writeStructure(value)) };
|
|
7
|
+
export const codeStructures = { id: storedStructures.id,
|
|
8
|
+
accepts: (value) => Array.isArray(value) && value.every(codeStructure.accepts) };
|
|
9
|
+
export const findingResult = { id: storedFindings.id,
|
|
10
|
+
accepts: (value) => storedFindings.accepts(writeFindings(value)) };
|
|
11
|
+
export function writeStructure(value) {
|
|
12
|
+
if (!isRecord(value) || !Array.isArray(value.observations))
|
|
13
|
+
return value;
|
|
14
|
+
return { ...value, observations: value.observations.map(writeObservation) };
|
|
15
|
+
}
|
|
16
|
+
function writeObservation(value) {
|
|
17
|
+
if (!isRecord(value))
|
|
18
|
+
return value;
|
|
19
|
+
const { check, ...fields } = value;
|
|
20
|
+
return { ...fields, rule: check };
|
|
21
|
+
}
|
|
22
|
+
export function writeFindings(value, id, dimension) {
|
|
23
|
+
if (!isRecord(value) || !Array.isArray(value.findings))
|
|
24
|
+
return value;
|
|
25
|
+
return { ...value, findings: value.findings.map(finding => writeFinding(finding, id, dimension)) };
|
|
26
|
+
}
|
|
27
|
+
function writeFinding(value, id, dimension) {
|
|
28
|
+
if (!isRecord(value))
|
|
29
|
+
return value;
|
|
30
|
+
const { plugin, check, ...fields } = value;
|
|
31
|
+
if (id !== undefined && plugin !== undefined && plugin !== id)
|
|
32
|
+
throw new Error('A finding may only name its reporting plugin ' + id);
|
|
33
|
+
if (dimension !== undefined && dimension !== category.maintainability && dimension !== category.security) {
|
|
34
|
+
throw new Error('Plugins in ' + dimension + ' do not produce findings');
|
|
35
|
+
}
|
|
36
|
+
const group = findingCategory(dimension, fields.effortMinutes !== undefined);
|
|
37
|
+
return { ...fields, tool: plugin ?? id ?? 'plugin', rule: check, category: group };
|
|
38
|
+
}
|
|
39
|
+
export function readStructure(value) {
|
|
40
|
+
const { observations, ...fields } = value;
|
|
41
|
+
return observations === undefined ? fields : { ...fields, observations: observations.map(({ rule, ...entry }) => ({ ...entry, check: rule })) };
|
|
42
|
+
}
|
|
43
|
+
export function readFindings(value) {
|
|
44
|
+
return { ...value, findings: value.findings.map(({ tool, rule, category, ...entry }) => ({ ...entry, plugin: tool, check: rule })) };
|
|
45
|
+
}
|
|
46
|
+
export function findingCategory(dimension, chargesEffort) {
|
|
47
|
+
if (dimension === category.security)
|
|
48
|
+
return 'security';
|
|
49
|
+
return chargesEffort ? 'structure' : 'lint';
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=author-contracts.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OperationCacheOptions } from './operation-cache.js';
|
|
2
|
+
import type { Product } from './plugin.js';
|
|
3
|
+
import type { PlannedOperation } from './plan.js';
|
|
4
|
+
export type Outcome = {
|
|
5
|
+
readonly state: 'completed';
|
|
6
|
+
readonly product: Product;
|
|
7
|
+
readonly diagnostics?: readonly {
|
|
8
|
+
message: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
}[];
|
|
11
|
+
} | {
|
|
12
|
+
readonly state: 'failed' | 'blocked';
|
|
13
|
+
readonly reason: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function execute(plan: readonly PlannedOperation[], external: ReadonlyMap<string, Product>, cache?: OperationCacheOptions): Promise<ReadonlyMap<string, Outcome>>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { operationCacheKey, readCachedOperation, writeCachedOperation } from './operation-cache.js';
|
|
2
|
+
export async function execute(plan, external, cache) {
|
|
3
|
+
const results = new Map();
|
|
4
|
+
for (const task of plan) {
|
|
5
|
+
const inputs = new Map();
|
|
6
|
+
const missing = [];
|
|
7
|
+
for (const [name, binding] of task.inputs) {
|
|
8
|
+
const producer = 'operation' in binding ? results.get(binding.operation) : undefined;
|
|
9
|
+
const product = 'external' in binding ? external.get(binding.external)
|
|
10
|
+
: producer?.state === 'completed' ? producer.product : undefined;
|
|
11
|
+
if (product)
|
|
12
|
+
inputs.set(name, product);
|
|
13
|
+
else
|
|
14
|
+
missing.push(name);
|
|
15
|
+
}
|
|
16
|
+
results.set(task.key, missing.length
|
|
17
|
+
? { state: 'blocked', reason: `Unavailable inputs: ${missing.join(', ')}` }
|
|
18
|
+
: await runTask(task, inputs, cache));
|
|
19
|
+
}
|
|
20
|
+
return results;
|
|
21
|
+
}
|
|
22
|
+
async function runTask(task, inputs, cache) {
|
|
23
|
+
try {
|
|
24
|
+
const { operation, validateOutput } = task;
|
|
25
|
+
for (const [name, contract] of Object.entries(operation.inputs))
|
|
26
|
+
readInput(inputs, name, contract);
|
|
27
|
+
const key = cache && operationCacheKey(task, inputs, cache.configurationDigest);
|
|
28
|
+
const hit = key && cache ? await readCachedOperation(cache.store, key, task) : undefined;
|
|
29
|
+
if (hit)
|
|
30
|
+
return { state: 'completed', product: hit };
|
|
31
|
+
const diagnostics = [];
|
|
32
|
+
const context = {
|
|
33
|
+
read: (port, contract) => {
|
|
34
|
+
if (!Object.hasOwn(operation.inputs, port) || operation.inputs[port]?.id !== contract.id) {
|
|
35
|
+
throw new Error(`Undeclared input contract: ${port} (${contract.id})`);
|
|
36
|
+
}
|
|
37
|
+
return readInput(inputs, port, contract);
|
|
38
|
+
},
|
|
39
|
+
emitDiagnostic: (message, path) => diagnostics.push(path === undefined ? { message } : { message, path }),
|
|
40
|
+
};
|
|
41
|
+
const value = await operation.execute(context);
|
|
42
|
+
const { output } = operation;
|
|
43
|
+
if (!output.accepts(value))
|
|
44
|
+
throw new Error(`Invalid output for ${output.id}`);
|
|
45
|
+
if (validateOutput && !validateOutput(value))
|
|
46
|
+
throw new Error(`Output violates the schema for ${output.id}`);
|
|
47
|
+
const product = { contract: output.id, value };
|
|
48
|
+
if (key && cache && diagnostics.length === 0)
|
|
49
|
+
await writeCachedOperation(cache.store, key, product);
|
|
50
|
+
return { state: 'completed', product, ...(diagnostics.length ? { diagnostics } : {}) };
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return { state: 'failed', reason: error instanceof Error ? error.message : String(error) };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function readInput(inputs, port, contract) {
|
|
57
|
+
const product = inputs.get(port);
|
|
58
|
+
if (!product || product.contract !== contract.id || !contract.accepts(product.value)) {
|
|
59
|
+
throw new Error(`Invalid input: ${port} (${contract.id})`);
|
|
60
|
+
}
|
|
61
|
+
return product.value;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=execute.js.map
|