feat(provider-contract): add classified unit contact aspect
This commit is contained in:
@@ -14,26 +14,26 @@ import {
|
||||
validateL2ExecutionPlan,
|
||||
} from "../src/index.mjs";
|
||||
import {
|
||||
geliosProviderPackageV9,
|
||||
geliosTelemetryFieldRegistryV2,
|
||||
} from "../providers/gelios/v9/index.mjs";
|
||||
geliosProviderPackageV10,
|
||||
geliosTelemetryFieldRegistryV3,
|
||||
} from "../providers/gelios/v10/index.mjs";
|
||||
|
||||
const positionsConnection = instantiateL2Connection(geliosProviderPackageV9, {
|
||||
const positionsConnection = instantiateL2Connection(geliosProviderPackageV10, {
|
||||
tenantId: "tenant-compiler-fixture",
|
||||
connectionId: "gelios-compiler-fixture",
|
||||
collectionProfileId: "gelios.positions.current.realtime.v7",
|
||||
providerCredentialRef: "ndc-credref:provider-compiler-fixture-0001",
|
||||
});
|
||||
const positionsPlan = compileL2ExecutionPlan(
|
||||
geliosProviderPackageV9,
|
||||
geliosProviderPackageV10,
|
||||
positionsConnection,
|
||||
{ telemetryFieldRegistry: geliosTelemetryFieldRegistryV2 },
|
||||
{ telemetryFieldRegistry: geliosTelemetryFieldRegistryV3 },
|
||||
);
|
||||
|
||||
assert.equal(positionsPlan.schemaVersion, L2_EXECUTION_PLAN_SCHEMA_VERSION);
|
||||
assert.equal(L2_EXECUTION_PLAN_COMPILER_VERSION, "1.2.0");
|
||||
assert.deepEqual(L2_EXECUTION_PLAN_SUPPORTED_COMPILER_VERSIONS, ["1.1.0", "1.2.0"]);
|
||||
assert.equal(positionsPlan.compilerVersion, "1.2.0");
|
||||
assert.equal(L2_EXECUTION_PLAN_COMPILER_VERSION, "1.3.0");
|
||||
assert.deepEqual(L2_EXECUTION_PLAN_SUPPORTED_COMPILER_VERSIONS, ["1.1.0", "1.2.0", "1.3.0"]);
|
||||
assert.equal(positionsPlan.compilerVersion, "1.3.0");
|
||||
assert.deepEqual(validateL2ExecutionPlan(positionsPlan), { ok: true, errors: [] });
|
||||
assert.match(positionsPlan.executionPlanDigest, /^sha256:[a-f0-9]{64}$/);
|
||||
assert.match(positionsPlan.artifacts.packageDigest, /^sha256:[a-f0-9]{64}$/);
|
||||
@@ -123,9 +123,9 @@ assert.equal(Object.isFrozen(positionsPlan.steps), true);
|
||||
assert.equal(Object.isFrozen(positionsPlan.graphBlueprint), true);
|
||||
|
||||
const clonedPlan = compileL2ExecutionPlan(
|
||||
structuredClone(geliosProviderPackageV9),
|
||||
structuredClone(geliosProviderPackageV10),
|
||||
structuredClone(positionsConnection),
|
||||
{ telemetryFieldRegistry: structuredClone(geliosTelemetryFieldRegistryV2) },
|
||||
{ telemetryFieldRegistry: structuredClone(geliosTelemetryFieldRegistryV3) },
|
||||
);
|
||||
assert.equal(clonedPlan.executionPlanDigest, positionsPlan.executionPlanDigest);
|
||||
|
||||
@@ -151,34 +151,34 @@ assert.equal(
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
() => compileL2ExecutionPlan(geliosProviderPackageV9, positionsConnection),
|
||||
() => compileL2ExecutionPlan(geliosProviderPackageV10, positionsConnection),
|
||||
/telemetry_registry_required/,
|
||||
);
|
||||
|
||||
const profileConnection = instantiateL2Connection(geliosProviderPackageV9, {
|
||||
const profileConnection = instantiateL2Connection(geliosProviderPackageV10, {
|
||||
tenantId: "tenant-compiler-fixture",
|
||||
connectionId: "gelios-profile-compiler-fixture",
|
||||
collectionProfileId: "gelios.units.profile.cold.v1",
|
||||
providerCredentialRef: "ndc-credref:provider-compiler-fixture-0001",
|
||||
});
|
||||
const profilePlan = compileL2ExecutionPlan(geliosProviderPackageV9, profileConnection);
|
||||
const profilePlan = compileL2ExecutionPlan(geliosProviderPackageV10, profileConnection);
|
||||
assert.deepEqual(validateL2ExecutionPlan(profilePlan), { ok: true, errors: [] });
|
||||
assert.equal(profilePlan.artifacts.telemetryRegistryDigest, undefined);
|
||||
assert.notEqual(profilePlan.executionPlanDigest, positionsPlan.executionPlanDigest);
|
||||
assert.deepEqual(profilePlan.graphBlueprint.runtime.mappingRuntime.derivationKinds, []);
|
||||
|
||||
for (const collectionProfile of geliosProviderPackageV9.collectionProfiles) {
|
||||
const connection = instantiateL2Connection(geliosProviderPackageV9, {
|
||||
for (const collectionProfile of geliosProviderPackageV10.collectionProfiles) {
|
||||
const connection = instantiateL2Connection(geliosProviderPackageV10, {
|
||||
tenantId: "tenant-all-profiles-fixture",
|
||||
connectionId: `connection-${collectionProfile.id.replaceAll(".", "-")}`,
|
||||
collectionProfileId: collectionProfile.id,
|
||||
providerCredentialRef: "ndc-credref:provider-all-profiles-fixture",
|
||||
});
|
||||
const plan = compileL2ExecutionPlan(
|
||||
geliosProviderPackageV9,
|
||||
geliosProviderPackageV10,
|
||||
connection,
|
||||
collectionProfile.dataProductId === "fleet.positions.current.v5"
|
||||
? { telemetryFieldRegistry: geliosTelemetryFieldRegistryV2 }
|
||||
? { telemetryFieldRegistry: geliosTelemetryFieldRegistryV3 }
|
||||
: {},
|
||||
);
|
||||
assert.deepEqual(validateL2ExecutionPlan(plan), { ok: true, errors: [] });
|
||||
@@ -188,16 +188,16 @@ for (const collectionProfile of geliosProviderPackageV9.collectionProfiles) {
|
||||
assert.equal(plan.graphBlueprint.edges.length, plan.steps.length + expectedEntrypoints - 2);
|
||||
}
|
||||
|
||||
const secondConnection = instantiateL2Connection(geliosProviderPackageV9, {
|
||||
const secondConnection = instantiateL2Connection(geliosProviderPackageV10, {
|
||||
tenantId: "tenant-compiler-fixture",
|
||||
connectionId: "gelios-compiler-fixture-two",
|
||||
collectionProfileId: "gelios.positions.current.realtime.v7",
|
||||
providerCredentialRef: "ndc-credref:provider-compiler-fixture-0002",
|
||||
});
|
||||
const secondPlan = compileL2ExecutionPlan(
|
||||
geliosProviderPackageV9,
|
||||
geliosProviderPackageV10,
|
||||
secondConnection,
|
||||
{ telemetryFieldRegistry: geliosTelemetryFieldRegistryV2 },
|
||||
{ telemetryFieldRegistry: geliosTelemetryFieldRegistryV3 },
|
||||
);
|
||||
assert.notEqual(secondPlan.executionPlanDigest, positionsPlan.executionPlanDigest);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import { geliosProviderPackageV6 } from "../providers/gelios/v6/index.mjs";
|
||||
import { geliosProviderPackageV7 } from "../providers/gelios/v7/index.mjs";
|
||||
import { geliosProviderPackageV8 } from "../providers/gelios/v8/index.mjs";
|
||||
import { geliosProviderPackageV9 } from "../providers/gelios/v9/index.mjs";
|
||||
import { geliosProviderPackageV10 } from "../providers/gelios/v10/index.mjs";
|
||||
import { normalizeDataProductDefinition } from "../../../services/external-data-plane/src/data-product-policy.mjs";
|
||||
|
||||
const expectedFields = [
|
||||
@@ -49,8 +50,11 @@ assert.deepEqual(validateProviderPackage(geliosProviderPackageV6), { ok: true, e
|
||||
assert.deepEqual(validateProviderPackage(geliosProviderPackageV7), { ok: true, errors: [] });
|
||||
assert.deepEqual(validateProviderPackage(geliosProviderPackageV8), { ok: true, errors: [] });
|
||||
assert.deepEqual(validateProviderPackage(geliosProviderPackageV9), { ok: true, errors: [] });
|
||||
assert.deepEqual(validateProviderPackage(geliosProviderPackageV10), { ok: true, errors: [] });
|
||||
assert.equal(geliosProviderPackageV9.id, "gelios.provider.v9");
|
||||
assert.equal(geliosProviderPackageV9.version, "9.0.0");
|
||||
assert.equal(geliosProviderPackageV10.id, "gelios.provider.v10");
|
||||
assert.equal(geliosProviderPackageV10.version, "10.0.0");
|
||||
assert.equal(geliosProviderPackageV8.id, "gelios.provider.v8");
|
||||
|
||||
const profileProduct = geliosProviderPackageV8.dataProducts.find((product) => product.id === "fleet.units.profile.current.v1");
|
||||
@@ -70,6 +74,38 @@ assert.equal(profileMapping.fact.attributes.hardware_type_name.paths[0], "hwType
|
||||
assert.equal(profileMapping.fact.attributes.trip_detection_type.paths[0], "tripParams.tripDetectionType.name");
|
||||
assert.equal(profileMapping.fact.attributes.use_odometer.coerce, "boolean");
|
||||
|
||||
const contactsProduct = geliosProviderPackageV10.dataProducts.find(
|
||||
(product) => product.id === "fleet.units.contacts.current.v1",
|
||||
);
|
||||
const registeredContactsProduct = JSON.parse(await readFile(new URL(
|
||||
"../../../services/external-data-plane/definitions/fleet.units.contacts.current.v1.json",
|
||||
import.meta.url,
|
||||
), "utf8"));
|
||||
assert.deepEqual(contactsProduct, registeredContactsProduct);
|
||||
const contactsMapping = geliosProviderPackageV10.mappingContracts.find(
|
||||
(mapping) => mapping.id === "gelios.units.to.fleet.units.contacts.current.v1",
|
||||
);
|
||||
assert.deepEqual(contactsMapping.fact.attributes.device_imei, {
|
||||
strategy: "first_non_empty",
|
||||
paths: ["imei"],
|
||||
coerce: "string",
|
||||
omitIfMissing: true,
|
||||
guardPath: "imeiIsVisible",
|
||||
guardEquals: true,
|
||||
});
|
||||
assert.equal(contactsMapping.fact.attributes.device_phone_primary.guardPath, "phoneIsVisible");
|
||||
assert.equal(contactsMapping.fact.attributes.device_phone_secondary.guardPath, "phone2IsVisible");
|
||||
assert.equal(contactsMapping.fact.attributes.provider_creator_login.paths[0], "creator.login");
|
||||
|
||||
const incompleteGuard = structuredClone(geliosProviderPackageV10);
|
||||
delete incompleteGuard.mappingContracts.at(-1).fact.attributes.device_imei.guardEquals;
|
||||
assert.equal(
|
||||
validateProviderPackage(incompleteGuard).errors.some(
|
||||
(error) => error.endsWith("guard_requires_path_and_equals"),
|
||||
),
|
||||
true,
|
||||
);
|
||||
|
||||
const telemetryProduct = geliosProviderPackageV7.dataProducts.find((product) => product.id === "fleet.positions.current.v5");
|
||||
const registeredTelemetryProduct = JSON.parse(await readFile(new URL(
|
||||
"../../../services/external-data-plane/definitions/fleet.positions.current.v5.json",
|
||||
|
||||
Reference in New Issue
Block a user