@c4a/extract-contract 0.7.9 → 0.7.10-alpha.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/index.js +21 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -21825,6 +21825,26 @@ function refTarget(importer, raw) {
|
|
|
21825
21825
|
const targetPath = posix.normalize(posix.join(posix.dirname(importer), rawPath));
|
|
21826
21826
|
return portablePath(targetPath) ? { targetPath, pointer, external: true } : null;
|
|
21827
21827
|
}
|
|
21828
|
+
function openApiSourceDependencies(path, source) {
|
|
21829
|
+
if (!/\.(?:json|ya?ml)$/iu.test(path))
|
|
21830
|
+
return [];
|
|
21831
|
+
if (!portablePath(path))
|
|
21832
|
+
throw new TypeError(`contract source path is not portable: ${path}`);
|
|
21833
|
+
const parsed = parseYaml(path, source);
|
|
21834
|
+
if (parsed.parseError)
|
|
21835
|
+
throw new TypeError(`${path}: ${parsed.parseError}`);
|
|
21836
|
+
const dependencies = new Set;
|
|
21837
|
+
for (const ref of collectRefs(parsed)) {
|
|
21838
|
+
if (ref.underBaseId && !ref.raw.startsWith("#"))
|
|
21839
|
+
throw new TypeError(`${path}: reference under $id requires an explicit registered URI mapping: ${ref.raw}`);
|
|
21840
|
+
const target = refTarget(path, ref.raw);
|
|
21841
|
+
if (!target)
|
|
21842
|
+
throw new TypeError(`${path}: reference leaves registered source scope: ${ref.raw}`);
|
|
21843
|
+
if (target.external)
|
|
21844
|
+
dependencies.add(target.targetPath);
|
|
21845
|
+
}
|
|
21846
|
+
return [...dependencies];
|
|
21847
|
+
}
|
|
21828
21848
|
function cycleMembers(graph) {
|
|
21829
21849
|
const cycles = new Set;
|
|
21830
21850
|
const visiting = new Set;
|
|
@@ -27146,6 +27166,7 @@ function contractSourcesToEvidenceAdapterMaterialization(files, invocation) {
|
|
|
27146
27166
|
var CONTRACT_EVIDENCE_ADAPTER_EXPORT = "contractSourcesToEvidenceAdapterMaterialization";
|
|
27147
27167
|
export {
|
|
27148
27168
|
parseContractSources,
|
|
27169
|
+
openApiSourceDependencies,
|
|
27149
27170
|
contractSourcesToEvidenceAdapterResult,
|
|
27150
27171
|
contractSourcesToEvidenceAdapterMaterialization,
|
|
27151
27172
|
CONTRACT_EVIDENCE_ADAPTER_EXPORT
|