feat(map): render classified unit identity aspects

This commit is contained in:
Codex
2026-07-24 11:43:20 +03:00
parent 49f0c449c1
commit c859ae4db0
11 changed files with 320 additions and 7 deletions
+12 -1
View File
@@ -175,7 +175,7 @@ function validateConsumerContract(value) {
|| fieldProjection.some((item) => !/^[A-Za-z][A-Za-z0-9_.-]{0,127}$/.test(item))
|| !fieldTypes
|| JSON.stringify(Object.keys(fieldTypes)) !== JSON.stringify(fieldProjection)
|| Object.values(fieldTypes).some((type) => !["string", "number", "boolean"].includes(type))
|| Object.values(fieldTypes).some((type) => !["string", "number", "boolean", "string_array"].includes(type))
|| geometryTypes.length > supportedGeometryTypes.size
|| new Set(geometryTypes).size !== geometryTypes.length
|| geometryTypes.some((type) => !supportedGeometryTypes.has(type))
@@ -230,6 +230,17 @@ function assertFactContract(fact, policy) {
if (!contract.semanticTypes.includes(fact.semanticType)) {
throw consumerError("data_product_consumer_fact_contract_invalid", 502);
}
const attributes = fact?.attributes && typeof fact.attributes === "object" && !Array.isArray(fact.attributes)
? fact.attributes
: {};
for (const [field, type] of Object.entries(contract.fieldTypes)) {
if (attributes[field] === undefined) continue;
const value = attributes[field];
const valid = type === "string_array"
? Array.isArray(value) && value.every((item) => typeof item === "string")
: typeof value === type && (type !== "number" || Number.isFinite(value));
if (!valid) throw consumerError("data_product_consumer_fact_contract_invalid", 502);
}
const hasGeometry = fact.geometry !== undefined && fact.geometry !== null;
if (contract.geometryTypes.length === 0) {
if (hasGeometry) throw consumerError("data_product_consumer_fact_contract_invalid", 502);