feat(data-plane): add bounded Gelios telemetry contract
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
DATA_PRODUCT_PATCH_SCHEMA_VERSION,
|
||||
DATA_PRODUCT_SNAPSHOT_SCHEMA_VERSION,
|
||||
isBoundedGeoJsonGeometry,
|
||||
isBoundedTelemetryReadings,
|
||||
} from "@nodedc/external-provider-contract/data-plane";
|
||||
|
||||
const IDENTIFIER = /^[a-z][a-z0-9._:-]{2,127}$/;
|
||||
@@ -854,6 +855,7 @@ function assertFieldContractValue(value, contract) {
|
||||
|
||||
function fieldContractValueMatchesType(value, type) {
|
||||
if (type === "string_array") return Array.isArray(value) && value.every((item) => typeof item === "string");
|
||||
if (type === "telemetry_readings") return isBoundedTelemetryReadings(value);
|
||||
if (type === "point") return isBoundedGeoJsonGeometry(value, new Set(["Point"]));
|
||||
if (type === "geometry") return isBoundedGeoJsonGeometry(value);
|
||||
return typeof value === type && (type !== "number" || Number.isFinite(value));
|
||||
|
||||
Reference in New Issue
Block a user