feat(data-plane): add provider contracts and ontology delivery
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { loadDataProductDefinitions } from "../src/definitions.mjs";
|
||||
|
||||
const bundled = await loadDataProductDefinitions();
|
||||
assert.deepEqual(bundled.map((definition) => definition.id), ["fleet.positions.current.v1"]);
|
||||
assert.deepEqual(bundled[0].semanticTypes, ["map.moving_object"]);
|
||||
assert.equal(bundled[0].ontologyRevision, "ontology.map.moving_object.v1");
|
||||
assert.equal(bundled[0].history.mode, "sampled");
|
||||
assert.equal(bundled[0].history.intervalMs, 60_000);
|
||||
assert.equal(bundled[0].history.retentionDays, 90);
|
||||
assert.equal(bundled[0].fields.includes("geometry"), true);
|
||||
assert.equal(bundled[0].fields.includes("providerUnitId"), false);
|
||||
assert.equal(bundled[0].fields.includes("provider_unit_id"), false);
|
||||
|
||||
const directory = await mkdtemp(join(tmpdir(), "nodedc-edp-definitions-"));
|
||||
try {
|
||||
await writeFile(join(directory, "wrong-name.json"), JSON.stringify({
|
||||
...bundled[0],
|
||||
id: "another.product.v1",
|
||||
}));
|
||||
await assert.rejects(loadDataProductDefinitions(directory), /data_product_definition_filename_mismatch/);
|
||||
await mkdir(join(directory, "ignored.json"));
|
||||
await assert.rejects(loadDataProductDefinitions(directory), /data_product_definition_file_invalid/);
|
||||
} finally {
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
console.log("external-data-plane definitions: ok");
|
||||
Reference in New Issue
Block a user