@hamak/smart-data-dico 1.10.0 → 1.11.0

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.
@@ -156400,6 +156400,7 @@ init_EntitySchema();
156400
156400
  init_logger();
156401
156401
  init_StorageBackendToken();
156402
156402
  init_types();
156403
+ var DOMAIN_KINDS = /* @__PURE__ */ new Set(["enum", "codelist", "reference"]);
156403
156404
  var DICT_WS2 = wsId("dictionaries");
156404
156405
  var CONFIG_PATH = pathOf("dico.config.json");
156405
156406
  var STANDARD_TYPES = new Set(Object.values(AttributeType));
@@ -156454,6 +156455,7 @@ function validateDerivedTypes(types) {
156454
156455
  if (!t.basedOn || typeof t.basedOn !== "string") {
156455
156456
  errors.push(`Derived type '${t.name}' must declare a \`basedOn\``);
156456
156457
  }
156458
+ if (t.domain) errors.push(...validateDomain(t.name, t.domain));
156457
156459
  }
156458
156460
  for (const t of types) {
156459
156461
  if (!t?.name || !t?.basedOn) continue;
@@ -156476,6 +156478,42 @@ function validateDerivedTypes(types) {
156476
156478
  return errors;
156477
156479
  }
156478
156480
  __name(validateDerivedTypes, "validateDerivedTypes");
156481
+ function validateDomain(typeName, domain2) {
156482
+ const errors = [];
156483
+ if (!DOMAIN_KINDS.has(domain2.kind)) {
156484
+ errors.push(`Derived type '${typeName}' has invalid domain kind '${domain2.kind}'`);
156485
+ return errors;
156486
+ }
156487
+ const hasValues = Array.isArray(domain2.values) && domain2.values.length > 0;
156488
+ const hasSource = typeof domain2.source === "string" && domain2.source.trim().length > 0;
156489
+ if (domain2.kind === "enum") {
156490
+ if (!hasValues) errors.push(`Enum domain '${typeName}' must list at least one value`);
156491
+ if (hasSource) errors.push(`Enum domain '${typeName}' must not declare a \`source\``);
156492
+ } else if (domain2.kind === "codelist") {
156493
+ if (!hasSource) errors.push(`Codelist domain '${typeName}' must declare a \`source\` name`);
156494
+ } else if (domain2.kind === "reference") {
156495
+ if (!hasSource) errors.push(`Reference domain '${typeName}' must declare a \`source\` name`);
156496
+ if (hasValues) errors.push(`Reference domain '${typeName}' must not carry inline \`values\` (they come from the source)`);
156497
+ }
156498
+ return errors;
156499
+ }
156500
+ __name(validateDomain, "validateDomain");
156501
+ function resolveDomain(typeName, derivedTypes) {
156502
+ if (STANDARD_TYPES.has(typeName)) return null;
156503
+ const byName = new Map(derivedTypes.map((t) => [t.name, t]));
156504
+ const visited = /* @__PURE__ */ new Set();
156505
+ let cursor = typeName;
156506
+ while (!STANDARD_TYPES.has(cursor)) {
156507
+ if (visited.has(cursor)) return null;
156508
+ visited.add(cursor);
156509
+ const dt = byName.get(cursor);
156510
+ if (!dt) return null;
156511
+ if (dt.domain) return dt.domain;
156512
+ cursor = dt.basedOn;
156513
+ }
156514
+ return null;
156515
+ }
156516
+ __name(resolveDomain, "resolveDomain");
156479
156517
  function resolveAttributeType(typeName, derivedTypes) {
156480
156518
  if (STANDARD_TYPES.has(typeName)) {
156481
156519
  return { baseType: typeName, validation: {} };
@@ -160361,8 +160399,21 @@ var ExportService = class {
160361
160399
  description: dt.description || void 0
160362
160400
  };
160363
160401
  this.applyValidationToSchema(schema, resolved.validation);
160402
+ this.applyDomainToSchema(schema, resolveDomain(dt.name, all));
160364
160403
  return schema;
160365
160404
  }
160405
+ /**
160406
+ * Project a {@link ValueDomain} into JSON Schema. enum/codelist values become
160407
+ * a standard `enum`; the kind and (for codelist/reference) the source are kept
160408
+ * as `x-domain` / `x-source` extension keywords so consumers can distinguish
160409
+ * a static code list from a live referential source.
160410
+ */
160411
+ applyDomainToSchema(schema, domain2) {
160412
+ if (!domain2) return;
160413
+ schema["x-domain"] = domain2.kind;
160414
+ if (domain2.source) schema["x-source"] = domain2.source;
160415
+ if (Array.isArray(domain2.values) && domain2.values.length > 0) schema.enum = domain2.values;
160416
+ }
160366
160417
  attributeToJsonSchema(attr, derivedTypes = []) {
160367
160418
  if (!Object.values(AttributeType).includes(attr.type)) {
160368
160419
  const resolved = resolveAttributeType(attr.type, derivedTypes);
@@ -10037,6 +10037,7 @@ var FLOW_STEP_KINDS = /* @__PURE__ */ new Set([
10037
10037
  ]);
10038
10038
 
10039
10039
  // backend/src/services/dicoConfigService.ts
10040
+ var DOMAIN_KINDS = /* @__PURE__ */ new Set(["enum", "codelist", "reference"]);
10040
10041
  var DICT_WS = wsId("dictionaries");
10041
10042
  var CONFIG_PATH = pathOf("dico.config.json");
10042
10043
  var STANDARD_TYPES = new Set(Object.values(AttributeType));
@@ -10059,6 +10060,7 @@ function validateDerivedTypes(types) {
10059
10060
  if (!t.basedOn || typeof t.basedOn !== "string") {
10060
10061
  errors.push(`Derived type '${t.name}' must declare a \`basedOn\``);
10061
10062
  }
10063
+ if (t.domain) errors.push(...validateDomain(t.name, t.domain));
10062
10064
  }
10063
10065
  for (const t of types) {
10064
10066
  if (!t?.name || !t?.basedOn) continue;
@@ -10081,6 +10083,26 @@ function validateDerivedTypes(types) {
10081
10083
  return errors;
10082
10084
  }
10083
10085
  __name(validateDerivedTypes, "validateDerivedTypes");
10086
+ function validateDomain(typeName, domain) {
10087
+ const errors = [];
10088
+ if (!DOMAIN_KINDS.has(domain.kind)) {
10089
+ errors.push(`Derived type '${typeName}' has invalid domain kind '${domain.kind}'`);
10090
+ return errors;
10091
+ }
10092
+ const hasValues = Array.isArray(domain.values) && domain.values.length > 0;
10093
+ const hasSource = typeof domain.source === "string" && domain.source.trim().length > 0;
10094
+ if (domain.kind === "enum") {
10095
+ if (!hasValues) errors.push(`Enum domain '${typeName}' must list at least one value`);
10096
+ if (hasSource) errors.push(`Enum domain '${typeName}' must not declare a \`source\``);
10097
+ } else if (domain.kind === "codelist") {
10098
+ if (!hasSource) errors.push(`Codelist domain '${typeName}' must declare a \`source\` name`);
10099
+ } else if (domain.kind === "reference") {
10100
+ if (!hasSource) errors.push(`Reference domain '${typeName}' must declare a \`source\` name`);
10101
+ if (hasValues) errors.push(`Reference domain '${typeName}' must not carry inline \`values\` (they come from the source)`);
10102
+ }
10103
+ return errors;
10104
+ }
10105
+ __name(validateDomain, "validateDomain");
10084
10106
 
10085
10107
  // backend/src/models/ormVocabulary.ts
10086
10108
  var ORM_VOCABULARY = {