@ontrails/adapter-kit 1.0.0-beta.19 → 1.0.0-beta.22
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/package.json +1 -1
- package/src/check.ts +96 -3
- package/src/index.ts +4 -0
package/package.json
CHANGED
package/src/check.ts
CHANGED
|
@@ -46,6 +46,7 @@ export interface AdapterCheckDiagnostic {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export interface AdapterCheckSubject {
|
|
49
|
+
readonly adapterType?: string | undefined;
|
|
49
50
|
readonly conformanceTestPaths: readonly string[];
|
|
50
51
|
readonly key: string;
|
|
51
52
|
readonly ownerPackage: string;
|
|
@@ -58,8 +59,36 @@ export interface AdapterCheckSubject {
|
|
|
58
59
|
readonly testingImport?: string | undefined;
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
export type AdapterFactKind = 'available' | 'configured' | 'observed' | 'used';
|
|
63
|
+
|
|
64
|
+
export type AdapterFactProvenanceSource =
|
|
65
|
+
| 'adapter-package-manifest'
|
|
66
|
+
| 'conformance-test'
|
|
67
|
+
| 'owner-package-manifest'
|
|
68
|
+
| 'runtime-observation';
|
|
69
|
+
|
|
70
|
+
export interface AdapterFactProvenance {
|
|
71
|
+
readonly packageJsonPath?: string | undefined;
|
|
72
|
+
readonly paths?: readonly string[] | undefined;
|
|
73
|
+
readonly source: AdapterFactProvenanceSource;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface AdapterFact {
|
|
77
|
+
readonly adapterType?: string | undefined;
|
|
78
|
+
readonly key: string;
|
|
79
|
+
readonly kind: AdapterFactKind;
|
|
80
|
+
readonly ownerPackage?: string | undefined;
|
|
81
|
+
readonly packageName?: string | undefined;
|
|
82
|
+
readonly placement?: AdapterTargetPlacement | undefined;
|
|
83
|
+
readonly placements?: readonly AdapterTargetPlacement[] | undefined;
|
|
84
|
+
readonly provenance: AdapterFactProvenance;
|
|
85
|
+
readonly target: string;
|
|
86
|
+
readonly targetKey?: string | undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
61
89
|
export interface AdapterCheckReport {
|
|
62
90
|
readonly diagnostics: readonly AdapterCheckDiagnostic[];
|
|
91
|
+
readonly facts: readonly AdapterFact[];
|
|
63
92
|
readonly subjects: readonly AdapterCheckSubject[];
|
|
64
93
|
readonly targets: readonly AdapterTargetCatalogEntry[];
|
|
65
94
|
}
|
|
@@ -323,6 +352,64 @@ const targetEntriesByTarget = (
|
|
|
323
352
|
): ReadonlyMap<string, AdapterTargetCatalogEntry> =>
|
|
324
353
|
new Map(targets.map((target) => [target.target, target]));
|
|
325
354
|
|
|
355
|
+
const adapterFacts = (
|
|
356
|
+
targets: readonly AdapterTargetCatalogEntry[],
|
|
357
|
+
subjects: readonly AdapterCheckSubject[]
|
|
358
|
+
): readonly AdapterFact[] => {
|
|
359
|
+
const facts: AdapterFact[] = [];
|
|
360
|
+
|
|
361
|
+
for (const target of targets) {
|
|
362
|
+
facts.push({
|
|
363
|
+
key: `${target.key}:available`,
|
|
364
|
+
kind: 'available',
|
|
365
|
+
ownerPackage: target.ownerPackage,
|
|
366
|
+
placements: target.placements,
|
|
367
|
+
provenance: {
|
|
368
|
+
packageJsonPath: target.packageJsonPath,
|
|
369
|
+
source: 'owner-package-manifest',
|
|
370
|
+
},
|
|
371
|
+
target: target.target,
|
|
372
|
+
targetKey: target.key,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
for (const subject of subjects) {
|
|
377
|
+
facts.push({
|
|
378
|
+
key: `${subject.key}:${subject.target}:configured`,
|
|
379
|
+
kind: 'configured',
|
|
380
|
+
ownerPackage: subject.ownerPackage,
|
|
381
|
+
packageName: subject.packageName,
|
|
382
|
+
placement: subject.placement,
|
|
383
|
+
provenance: {
|
|
384
|
+
packageJsonPath: subject.packageJsonPath,
|
|
385
|
+
source: 'adapter-package-manifest',
|
|
386
|
+
},
|
|
387
|
+
target: subject.target,
|
|
388
|
+
targetKey: subject.targetKey,
|
|
389
|
+
...(subject.adapterType ? { adapterType: subject.adapterType } : {}),
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
if (subject.conformanceTestPaths.length > 0) {
|
|
393
|
+
facts.push({
|
|
394
|
+
key: `${subject.key}:${subject.target}:used`,
|
|
395
|
+
kind: 'used',
|
|
396
|
+
ownerPackage: subject.ownerPackage,
|
|
397
|
+
packageName: subject.packageName,
|
|
398
|
+
placement: subject.placement,
|
|
399
|
+
provenance: {
|
|
400
|
+
paths: subject.conformanceTestPaths,
|
|
401
|
+
source: 'conformance-test',
|
|
402
|
+
},
|
|
403
|
+
target: subject.target,
|
|
404
|
+
targetKey: subject.targetKey,
|
|
405
|
+
...(subject.adapterType ? { adapterType: subject.adapterType } : {}),
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return facts;
|
|
411
|
+
};
|
|
412
|
+
|
|
326
413
|
const collectSourceFiles = (dir: string): readonly string[] => {
|
|
327
414
|
if (!existsSync(dir)) {
|
|
328
415
|
return [];
|
|
@@ -2033,6 +2120,9 @@ const checkAdapterPackage = (
|
|
|
2033
2120
|
placement,
|
|
2034
2121
|
target: targetEntry.target,
|
|
2035
2122
|
targetKey: targetEntry.key,
|
|
2123
|
+
...(conformance?.adapterType
|
|
2124
|
+
? { adapterType: conformance.adapterType }
|
|
2125
|
+
: {}),
|
|
2036
2126
|
...(testingImport ? { testingImport } : {}),
|
|
2037
2127
|
},
|
|
2038
2128
|
};
|
|
@@ -2054,11 +2144,14 @@ export const checkAdapters = (rootDir: string): AdapterCheckReport => {
|
|
|
2054
2144
|
}
|
|
2055
2145
|
}
|
|
2056
2146
|
|
|
2147
|
+
const sortedSubjects = subjects.toSorted((left, right) =>
|
|
2148
|
+
left.key.localeCompare(right.key)
|
|
2149
|
+
);
|
|
2150
|
+
|
|
2057
2151
|
return {
|
|
2058
2152
|
diagnostics,
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
),
|
|
2153
|
+
facts: adapterFacts(catalog.targets, sortedSubjects),
|
|
2154
|
+
subjects: sortedSubjects,
|
|
2062
2155
|
targets: catalog.targets,
|
|
2063
2156
|
};
|
|
2064
2157
|
};
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,10 @@ export type {
|
|
|
3
3
|
AdapterCheckDiagnostic,
|
|
4
4
|
AdapterCheckDiagnosticCode,
|
|
5
5
|
AdapterCheckDiagnosticSeverity,
|
|
6
|
+
AdapterFact,
|
|
7
|
+
AdapterFactKind,
|
|
8
|
+
AdapterFactProvenance,
|
|
9
|
+
AdapterFactProvenanceSource,
|
|
6
10
|
AdapterCheckReport,
|
|
7
11
|
AdapterCheckSubject,
|
|
8
12
|
} from './check.js';
|