@hamak/smart-data-dico 1.10.1 → 1.12.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.
package/README.md CHANGED
@@ -292,6 +292,44 @@ cd frontend && npm run dev # port 3000
292
292
 
293
293
  In dev, the backend serves the bundled sample project at `samples/eshop/` (three packages: `order-service`, `product-service`, `user-service`). Override with `DATA_DIR=/path/to/your/project npm run dev` to point at your own data.
294
294
 
295
+ ### Option C — Restricted networks (no npm registry for this package, or no git)
296
+
297
+ When the npm registry copy of the package is unavailable, install it from git or
298
+ from a prebuilt release tarball. These do **not** require the package to be on a
299
+ registry; the lower options additionally avoid needing the `git` binary.
300
+
301
+ **C1 — Prebuilt tarball over `curl` (no git, no build, fully offline-capable).**
302
+ Each release attaches a **self-contained** tarball (esbuild-bundled backend, no
303
+ runtime `node_modules`; Node ≥ 18). Download and install it directly:
304
+
305
+ ```bash
306
+ curl -fL -o smart-data-dico.tgz \
307
+ https://github.com/amah/smart-data-dico/releases/download/v1.11.0/hamak-smart-data-dico-1.11.0.tgz
308
+ npm install -g ./smart-data-dico.tgz
309
+ smart-data-dico --data-dir /path/to/your/project
310
+ ```
311
+
312
+ For a fully air-gapped machine, download the `.tgz` on a connected host, copy it
313
+ across, and run the `npm install -g ./…tgz` step there — it needs no network.
314
+
315
+ **C2 — Build from git with the helper script.** Clones a pinned ref, installs
316
+ deps (root/frontend/backend), builds both bundles, packs a tarball, and installs
317
+ the CLI globally:
318
+
319
+ ```bash
320
+ scripts/install-from-git.sh # build v1.11.0, install globally
321
+ scripts/install-from-git.sh --pack-only # just produce the tarball (prints its path)
322
+ ```
323
+
324
+ Add `--archive` (auto-enabled when `git` is absent) to fetch the source via
325
+ `curl`/`wget` instead of cloning. Useful env/flags: `SDD_REF` (tag/branch/commit),
326
+ `SDD_REPO_URL` (internal mirror or SSH), `-d` (work dir). Run `scripts/install-from-git.sh --help`
327
+ for the full list.
328
+
329
+ > Note: C2 still pulls build **dependencies** from whichever npm registry / proxy
330
+ > `npm` is configured to use. If even that is blocked, use **C1** — build the
331
+ > tarball once on a connected machine (`--pack-only`) and install the artifact offline.
332
+
295
333
  ### Option C — Docker
296
334
 
297
335
  ```bash
@@ -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 = {