@primmel/primmel 1.21.18 → 1.21.20

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.
Files changed (52) hide show
  1. package/dist/src/check-rules.d.ts.map +1 -1
  2. package/dist/src/check-rules.js +1 -0
  3. package/dist/src/check-rules.js.map +1 -1
  4. package/dist/src/check.d.ts.map +1 -1
  5. package/dist/src/check.js +73 -27
  6. package/dist/src/check.js.map +1 -1
  7. package/dist/src/export/retrieval.d.ts +1 -1
  8. package/dist/src/export/retrieval.d.ts.map +1 -1
  9. package/dist/src/export/retrieval.js +0 -79
  10. package/dist/src/export/retrieval.js.map +1 -1
  11. package/dist/src/model-diff.d.ts.map +1 -1
  12. package/dist/src/model-diff.js +0 -1
  13. package/dist/src/model-diff.js.map +1 -1
  14. package/dist/src/ser-des/config/index.d.ts.map +1 -1
  15. package/dist/src/ser-des/config/index.js +0 -1
  16. package/dist/src/ser-des/config/index.js.map +1 -1
  17. package/dist/src/ser-des/config/process.d.ts.map +1 -1
  18. package/dist/src/ser-des/config/process.js +4 -0
  19. package/dist/src/ser-des/config/process.js.map +1 -1
  20. package/dist/src/ser-des/config/quantity.d.ts.map +1 -1
  21. package/dist/src/ser-des/config/quantity.js +25 -7
  22. package/dist/src/ser-des/config/quantity.js.map +1 -1
  23. package/dist/src/ser-des/config/series.d.ts.map +1 -1
  24. package/dist/src/ser-des/config/series.js +11 -1
  25. package/dist/src/ser-des/config/series.js.map +1 -1
  26. package/dist/src/ser-des/config/subject.d.ts +1 -8
  27. package/dist/src/ser-des/config/subject.d.ts.map +1 -1
  28. package/dist/src/ser-des/config/subject.js +1 -180
  29. package/dist/src/ser-des/config/subject.js.map +1 -1
  30. package/dist/src/ser-des/package.d.ts.map +1 -1
  31. package/dist/src/ser-des/package.js +0 -1
  32. package/dist/src/ser-des/package.js.map +1 -1
  33. package/dist/src/ser-des/parse.d.ts.map +1 -1
  34. package/dist/src/ser-des/parse.js +0 -1
  35. package/dist/src/ser-des/parse.js.map +1 -1
  36. package/dist/src/ser-des/types.d.ts +1 -2
  37. package/dist/src/ser-des/types.d.ts.map +1 -1
  38. package/dist/src/types/Artifact.d.ts +2 -3
  39. package/dist/src/types/Artifact.d.ts.map +1 -1
  40. package/dist/src/types/Artifact.js +2 -3
  41. package/dist/src/types/Artifact.js.map +1 -1
  42. package/dist/src/types/Quantity.d.ts +11 -0
  43. package/dist/src/types/Quantity.d.ts.map +1 -1
  44. package/dist/src/types/Series.d.ts +7 -0
  45. package/dist/src/types/Series.d.ts.map +1 -1
  46. package/dist/src/types/Standard.d.ts +1 -2
  47. package/dist/src/types/Standard.d.ts.map +1 -1
  48. package/dist/src/types/Subject.d.ts +0 -43
  49. package/dist/src/types/Subject.d.ts.map +1 -1
  50. package/dist-browser/index.mjs +672 -728
  51. package/dist-cli/primmel.mjs +132 -350
  52. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // scripts/check.mts
4
- import { existsSync as existsSync8, readdirSync as readdirSync8, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
5
- import { join as join10 } from "node:path";
4
+ import { existsSync as existsSync7, readdirSync as readdirSync8, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
5
+ import { join as join9 } from "node:path";
6
6
 
7
7
  // src/check.ts
8
8
  import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
@@ -322,7 +322,6 @@ function parseDeclarations(declarations, parsers, options = {}) {
322
322
  attributeDefinitions: {},
323
323
  capabilities: {},
324
324
  behaviors: {},
325
- conditionSets: {},
326
325
  // Primmel v3 subject anatomy (is/has/does — TODO.roadmap/01)
327
326
  subjects: {},
328
327
  // The identity slots + aspect register (smart TODO.roadmap/40 batch 3)
@@ -676,6 +675,10 @@ function parseSeriesDecl(block) {
676
675
  let i = 0;
677
676
  while (i < t.length) {
678
677
  const cmd = t[i++];
678
+ if (cmd === "record") {
679
+ decl.record = stripWrapping(t[i++]);
680
+ continue;
681
+ }
679
682
  if (cmd !== "axis" && cmd !== "cell") {
680
683
  if (i < t.length) {
681
684
  unwrapBlock(t[i - 1]);
@@ -753,7 +756,11 @@ function dumpSeriesDecl(decl) {
753
756
  if (decl.cellUnit) {
754
757
  out += 'unit "' + escapeString(decl.cellUnit) + '" ';
755
758
  }
756
- out += "} }";
759
+ out += "} ";
760
+ if (decl.record !== void 0) {
761
+ out += "record " + decl.record + " ";
762
+ }
763
+ out += "}";
757
764
  return out;
758
765
  }
759
766
 
@@ -2945,15 +2952,30 @@ function readQuantityBlock(content) {
2945
2952
  break;
2946
2953
  }
2947
2954
  if (cmd === "value") {
2948
- out.value = coerceValueToken(t[i++]);
2955
+ const rawTok = t[i++];
2956
+ out.value = coerceValueToken(rawTok);
2957
+ const bare = stripWrapping(rawTok);
2958
+ if (typeof out.value === "number" && String(out.value) !== bare) {
2959
+ out.valueLiteral = bare;
2960
+ }
2949
2961
  } else if (cmd === "unit") {
2950
2962
  out.unit = stripWrapping(t[i++]);
2951
2963
  } else if (cmd === "kind" || cmd === "quantity_kind") {
2952
2964
  out.quantityKind = stripWrapping(t[i++]);
2953
2965
  } else if (cmd === "uncertainty") {
2954
- out.uncertainty = coerceValueToken(t[i++]);
2966
+ const rawTok = t[i++];
2967
+ out.uncertainty = coerceValueToken(rawTok);
2968
+ const bare = stripWrapping(rawTok);
2969
+ if (typeof out.uncertainty === "number" && String(out.uncertainty) !== bare) {
2970
+ out.uncertaintyLiteral = bare;
2971
+ }
2955
2972
  } else if (cmd === "tolerance") {
2956
- out.tolerance = coerceValueToken(t[i++]);
2973
+ const rawTok = t[i++];
2974
+ out.tolerance = coerceValueToken(rawTok);
2975
+ const bare = stripWrapping(rawTok);
2976
+ if (typeof out.tolerance === "number" && String(out.tolerance) !== bare) {
2977
+ out.toleranceLiteral = bare;
2978
+ }
2957
2979
  } else if (cmd === "provenance") {
2958
2980
  out.provenance = readProvenanceBlock(unwrapBlock(t[i++]));
2959
2981
  } else {
@@ -3025,13 +3047,15 @@ function dumpScalarToken(v) {
3025
3047
  }
3026
3048
  function dumpQuantityValue(v) {
3027
3049
  if (!needsQuantityBlock(v)) {
3028
- const val = dumpScalarToken(v.value);
3050
+ const val = v.valueLiteral ?? dumpScalarToken(v.value);
3029
3051
  return v.unit === void 0 ? val : val + " " + dumpBareSafe(v.unit);
3030
3052
  }
3031
3053
  return dumpQuantityBlock(v);
3032
3054
  }
3033
3055
  function dumpQuantityBlock(v) {
3034
- const parts = ["value " + dumpScalarToken(v.value)];
3056
+ const parts = [
3057
+ "value " + (v.valueLiteral ?? dumpScalarToken(v.value))
3058
+ ];
3035
3059
  if (v.unit !== void 0) {
3036
3060
  parts.push('unit "' + escapeString(v.unit) + '"');
3037
3061
  }
@@ -3039,10 +3063,14 @@ function dumpQuantityBlock(v) {
3039
3063
  parts.push("kind " + dumpBareSafe(v.quantityKind));
3040
3064
  }
3041
3065
  if (v.uncertainty !== void 0) {
3042
- parts.push("uncertainty " + dumpScalarToken(v.uncertainty));
3066
+ parts.push(
3067
+ "uncertainty " + (v.uncertaintyLiteral ?? dumpScalarToken(v.uncertainty))
3068
+ );
3043
3069
  }
3044
3070
  if (v.tolerance !== void 0) {
3045
- parts.push("tolerance " + dumpScalarToken(v.tolerance));
3071
+ parts.push(
3072
+ "tolerance " + (v.toleranceLiteral ?? dumpScalarToken(v.tolerance))
3073
+ );
3046
3074
  }
3047
3075
  if (v.provenance !== void 0) {
3048
3076
  parts.push("provenance " + dumpProvenanceBlock(v.provenance));
@@ -3107,6 +3135,9 @@ function parseParamList(block, allowInitial = false) {
3107
3135
  const [rawValue, rawUnit] = parts;
3108
3136
  const value = coerceValueToken(rawValue);
3109
3137
  const initial = rawUnit === void 0 ? { value } : { value, unit: stripWrapping(rawUnit) };
3138
+ if (typeof value === "number" && String(value) !== stripWrapping(rawValue)) {
3139
+ initial.valueLiteral = stripWrapping(rawValue);
3140
+ }
3110
3141
  param.initial = initial;
3111
3142
  }
3112
3143
  }
@@ -14436,153 +14467,6 @@ var dumpBehavior = function(b) {
14436
14467
  out += "}\n";
14437
14468
  return out;
14438
14469
  };
14439
- var parseConditionSet = function(id, data) {
14440
- const result = {
14441
- id,
14442
- role: "",
14443
- entries: [],
14444
- source: null,
14445
- sources: [],
14446
- referenceIds: []
14447
- };
14448
- const t = tokenizePackage(data);
14449
- let i = 0;
14450
- while (i < t.length) {
14451
- const cmd = t[i++];
14452
- if (i >= t.length) {
14453
- break;
14454
- }
14455
- if (cmd === "role") {
14456
- result.role = stripWrapping(t[i++]);
14457
- } else if (cmd === "subject") {
14458
- result.subject = stripWrapping(t[i++]);
14459
- } else if (cmd === "description") {
14460
- result.description = stripWrapping(t[i++]);
14461
- } else if (cmd === "entries") {
14462
- result.entries = parseConditionEntries(unwrapBlock(t[i++]));
14463
- } else if (cmd === "source") {
14464
- const src = readSource(unwrapBlock(t[i++]));
14465
- result.sources.push(src);
14466
- if (!result.source) {
14467
- result.source = src;
14468
- }
14469
- } else if (cmd === "ref") {
14470
- const rr = parseRef(t, i, stripWrapping, unwrapBlock);
14471
- i = rr.next;
14472
- if (rr.ref.predicate === "derives-from") {
14473
- const b = refTargetToSourceRef(rr.ref.target);
14474
- if (b) {
14475
- result.sources.push(b);
14476
- if (!result.source) {
14477
- result.source = b;
14478
- }
14479
- } else {
14480
- (result.refs ??= []).push(rr.ref);
14481
- }
14482
- } else if (rr.ref.predicate === "cites") {
14483
- result.referenceIds.push(rr.ref.target);
14484
- } else {
14485
- (result.refs ??= []).push(rr.ref);
14486
- }
14487
- } else if (cmd === "corresponds") {
14488
- const cc = parseCorresponds(t, i, stripWrapping);
14489
- (result.correspondences ??= []).push(cc.corr);
14490
- i = cc.next;
14491
- } else if (cmd === "reference") {
14492
- result.referenceIds = readReference(t[i++]);
14493
- } else {
14494
- i = skipUnknownValue(t, i, cmd);
14495
- }
14496
- }
14497
- return (ctx) => {
14498
- ctx.conditionSets[id] = result;
14499
- return ctx;
14500
- };
14501
- };
14502
- function parseConditionEntries(block) {
14503
- const out = [];
14504
- const t = tokenize(block);
14505
- let i = 0;
14506
- while (i < t.length) {
14507
- const qk = stripColon(t[i++]);
14508
- if (!qk) {
14509
- break;
14510
- }
14511
- const entry = {
14512
- quantityKind: qk,
14513
- value: "",
14514
- unit: "",
14515
- tolerance: ""
14516
- };
14517
- if (i < t.length && t[i].startsWith("{")) {
14518
- const eblock = unwrapBlock(t[i++]);
14519
- const et = tokenize(eblock);
14520
- let j = 0;
14521
- while (j < et.length) {
14522
- const cmd = et[j++];
14523
- if (j >= et.length) {
14524
- break;
14525
- }
14526
- if (cmd === "value") {
14527
- entry.value = stripWrapping(et[j++]);
14528
- } else if (cmd === "unit") {
14529
- entry.unit = stripWrapping(et[j++]);
14530
- } else if (cmd === "tolerance") {
14531
- entry.tolerance = stripWrapping(et[j++]);
14532
- } else if (cmd === "note") {
14533
- entry.note = stripWrapping(et[j++]);
14534
- } else {
14535
- unwrapBlock(et[j++]);
14536
- }
14537
- }
14538
- }
14539
- out.push(entry);
14540
- }
14541
- return out;
14542
- }
14543
- var dumpConditionSet = function(cs) {
14544
- let out = "condition_set " + cs.id + " {\n";
14545
- if (cs.role) {
14546
- out += " role " + cs.role + "\n";
14547
- }
14548
- if (cs.subject) {
14549
- out += " subject " + cs.subject + "\n";
14550
- }
14551
- if (cs.description) {
14552
- out += ' description "' + escapeString(cs.description) + '"\n';
14553
- }
14554
- if (cs.entries.length > 0) {
14555
- out += " entries {\n";
14556
- for (const e of cs.entries) {
14557
- let line = " " + e.quantityKind + " { value " + dumpBareSafe(e.value);
14558
- if (e.unit) {
14559
- line += ' unit "' + escapeString(e.unit) + '"';
14560
- }
14561
- if (e.tolerance) {
14562
- line += " tolerance " + dumpBareSafe(e.tolerance);
14563
- }
14564
- if (e.note) {
14565
- line += ' note "' + escapeString(e.note) + '"';
14566
- }
14567
- out += line + " }\n";
14568
- }
14569
- out += " }\n";
14570
- }
14571
- const sources = cs.sources && cs.sources.length > 0 ? cs.sources : cs.source ? [cs.source] : [];
14572
- for (const s of sources) {
14573
- out += dumpSourceRefAsRef(s, " ", escapeString);
14574
- }
14575
- out += dumpIdList("reference", cs.referenceIds, " ");
14576
- out += dumpRefs(cs.refs, " ", escapeString);
14577
- out += dumpCorrespondences(
14578
- cs.correspondences,
14579
- " ",
14580
- escapeString,
14581
- dumpBareSafe
14582
- );
14583
- out += "}\n";
14584
- return out;
14585
- };
14586
14470
  function readStringMap2(block) {
14587
14471
  const out = {};
14588
14472
  const t = tokenize(block);
@@ -15315,13 +15199,6 @@ var behaviorConstruct = {
15315
15199
  parse: parseBehavior,
15316
15200
  dump: dumpBehavior
15317
15201
  };
15318
- var conditionSetConstruct = {
15319
- keyword: "condition_set",
15320
- field: "conditionSets",
15321
- takesID: true,
15322
- parse: parseConditionSet,
15323
- dump: dumpConditionSet
15324
- };
15325
15202
  var subjectConstruct = {
15326
15203
  keyword: "subject",
15327
15204
  field: "subjects",
@@ -20646,7 +20523,6 @@ var CONSTRUCTS = [
20646
20523
  attributeDefinitionConstruct,
20647
20524
  capabilityConstruct,
20648
20525
  behaviorConstruct,
20649
- conditionSetConstruct,
20650
20526
  conformanceClassConstruct,
20651
20527
  defineConstruct({
20652
20528
  keyword: "conformance_test",
@@ -21297,7 +21173,6 @@ var MERGE_FIELDS = [
21297
21173
  "attributeDefinitions",
21298
21174
  "capabilities",
21299
21175
  "behaviors",
21300
- "conditionSets",
21301
21176
  "subjects",
21302
21177
  // The documentary identity slots + the qualitative aspect register
21303
21178
  // (smart TODO.roadmap/40 batch 3) compose like the subject anatomy
@@ -22384,7 +22259,6 @@ var TIER_BY_FIELD = {
22384
22259
  attributeDefinitions: "primary",
22385
22260
  capabilities: "primary",
22386
22261
  behaviors: "primary",
22387
- conditionSets: "primary",
22388
22262
  instances: "primary",
22389
22263
  duals: "primary",
22390
22264
  artifactDefinitions: "primary",
@@ -23607,6 +23481,14 @@ var CHECK_RULES = [
23607
23481
  "normal",
23608
23482
  "the run store registry and the record forms of the test agree on the data class \u2014 the output records and the store hold the same shape"
23609
23483
  ),
23484
+ R(
23485
+ "C182",
23486
+ "series-record-fields",
23487
+ "quantities",
23488
+ "error",
23489
+ "normal",
23490
+ "a series variable whose series declares a record form types its row members by that form\u2019s typed fields \u2014 a collection derivation\u2019s lambda members resolve against them, never kind-silent"
23491
+ ),
23610
23492
  R(
23611
23493
  "C173",
23612
23494
  "step-plane-refs-resolve",
@@ -26066,7 +25948,6 @@ var IDENTITY_PREFIXES = [
26066
25948
  var DIM_ALIASES = {
26067
25949
  humidity_class: "humidity_symbol"
26068
25950
  };
26069
- var NUMERIC_TOKEN = /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;
26070
25951
  function isIdentityPath(path) {
26071
25952
  return IDENTITY_PREFIXES.some((p) => path.startsWith(p));
26072
25953
  }
@@ -29745,6 +29626,71 @@ function checkPackage(dir, options = {}) {
29745
29626
  }
29746
29627
  }
29747
29628
  }
29629
+ {
29630
+ const recordFormFields = /* @__PURE__ */ new Map();
29631
+ for (const f of standard.forms ?? []) {
29632
+ recordFormFields.set(f.id, new Set((f.fields ?? []).map((x) => x.name)));
29633
+ }
29634
+ const walkMembers = (n, bound, out) => {
29635
+ if (n.type === "nav") {
29636
+ const inner = new Map(bound);
29637
+ inner.set(n.var, n.source);
29638
+ walkMembers(n.body, inner, out);
29639
+ return;
29640
+ }
29641
+ if (n.type === "name" && n.path.length > 0) {
29642
+ const parts = [...n.path[0].split("."), ...n.path.slice(1)];
29643
+ if (parts.length > 1) {
29644
+ const src = bound.get(parts[0]);
29645
+ if (src !== void 0) {
29646
+ out.push({ source: src, field: parts.slice(1).join(".") });
29647
+ }
29648
+ }
29649
+ return;
29650
+ }
29651
+ const kids = n.type === "call" ? n.args : n.type === "binop" ? [n.left, n.right] : n.type === "unop" ? [n.operand] : n.type === "ifelse" ? [n.cond, n.then, n.else] : [];
29652
+ for (const k of kids) {
29653
+ walkMembers(k, bound, out);
29654
+ }
29655
+ };
29656
+ for (const t of standard.conformanceTests ?? []) {
29657
+ for (const v of t.variables ?? []) {
29658
+ const rec = v.series?.record;
29659
+ if (!rec) {
29660
+ continue;
29661
+ }
29662
+ const fields = recordFormFields.get(rec);
29663
+ if (!fields) {
29664
+ err(
29665
+ "C182",
29666
+ `conformance test ${t.id}: variable "${v.name}" series record "${rec}" names no declared form \u2014 the row members type by the record form's fields (series-record-fields)`
29667
+ );
29668
+ continue;
29669
+ }
29670
+ if (!v.derivation) {
29671
+ continue;
29672
+ }
29673
+ let ast;
29674
+ try {
29675
+ ast = parseExpression(
29676
+ v.derivation.replace(/^ocl\{/, "").replace(/\}$/, "")
29677
+ );
29678
+ } catch {
29679
+ continue;
29680
+ }
29681
+ const members = [];
29682
+ walkMembers(ast, /* @__PURE__ */ new Map(), members);
29683
+ for (const m of members) {
29684
+ if (m.source === v.name && !fields.has(m.field)) {
29685
+ err(
29686
+ "C182",
29687
+ `conformance test ${t.id}: variable "${v.name}" derivation names "m.${m.field}" \u2014 the record form ${rec} declares no such field; the row members are its typed fields (series-record-fields)`
29688
+ );
29689
+ }
29690
+ }
29691
+ }
29692
+ }
29693
+ }
29748
29694
  {
29749
29695
  const KNOWN_CONTENT = new Set(PASSPORT_CONTENT_CLASSES);
29750
29696
  const KNOWN_LEVELS = new Set(PASSPORT_UPI_LEVELS);
@@ -30193,33 +30139,6 @@ function checkPackage(dir, options = {}) {
30193
30139
  }
30194
30140
  }
30195
30141
  }
30196
- for (const cs of standard.conditionSets ?? []) {
30197
- for (const e of cs.entries ?? []) {
30198
- if (!e.unit) {
30199
- if (NUMERIC_TOKEN.test(e.value)) {
30200
- err(
30201
- "C32",
30202
- `condition_set ${cs.id}: entry "${e.quantityKind}" is a bare physical value \u2014 a numeric condition value carries a unit \u2014 INV-1: no bare numbers (inv1-no-bare-quantity)`
30203
- );
30204
- }
30205
- continue;
30206
- }
30207
- const eKind = kindOfUnit(e.unit);
30208
- if (eKind === void 0) {
30209
- if (registersExist) {
30210
- warn(
30211
- "C33",
30212
- `condition_set ${cs.id}: entry "${e.quantityKind}" carries unit "${e.unit}", which no quantity_register declares (quantity-coherence)`
30213
- );
30214
- }
30215
- } else if (kindDecl.has(e.quantityKind) && eKind !== e.quantityKind) {
30216
- err(
30217
- "C33",
30218
- `condition_set ${cs.id}: entry "${e.quantityKind}" carries unit "${e.unit}" (kind ${eKind}) \u2014 the unit does not measure the entry's quantity kind (quantity-coherence)`
30219
- );
30220
- }
30221
- }
30222
- }
30223
30142
  const unitables = [
30224
30143
  ...(standard.symbols ?? []).map((s) => ({
30225
30144
  kind: "symbol",
@@ -32070,7 +31989,6 @@ function checkPackage(dir, options = {}) {
32070
31989
  collect("attribute_definition", standard.attributeDefinitions ?? []);
32071
31990
  collect("capability", standard.capabilities ?? []);
32072
31991
  collect("behavior", standard.behaviors ?? []);
32073
- collect("condition_set", standard.conditionSets ?? []);
32074
31992
  collect("requirement", standard.requirements ?? []);
32075
31993
  collect("conformance_test", standard.conformanceTests ?? []);
32076
31994
  collect("form", standard.forms ?? []);
@@ -32670,7 +32588,6 @@ function checkSpellingCodes(standard) {
32670
32588
  "attributeDefinitions",
32671
32589
  "capabilities",
32672
32590
  "behaviors",
32673
- "conditionSets",
32674
32591
  "subjects",
32675
32592
  "referenceMaterials",
32676
32593
  "artifactDefinitions",
@@ -32910,9 +32827,6 @@ function checkDeclaredPredicates(standard) {
32910
32827
  for (const s of standard.testSequences ?? []) {
32911
32828
  visit(`test_sequence ${s.id}`, s.refs);
32912
32829
  }
32913
- for (const c of standard.conditionSets ?? []) {
32914
- visit(`condition_set ${c.id}`, c.refs);
32915
- }
32916
32830
  for (const i of standard.instruments ?? []) {
32917
32831
  visit(`instrument ${i.id}`, i.refs);
32918
32832
  }
@@ -34834,65 +34748,8 @@ function renderJsonLd(prefixes, triples) {
34834
34748
 
34835
34749
  // src/export/retrieval.ts
34836
34750
  import { createHash } from "node:crypto";
34837
- import { readdirSync as readdirSync5, readFileSync as readFileSync8, statSync as statSync4 } from "node:fs";
34838
- import { join as join7, relative } from "node:path";
34839
-
34840
- // src/export/unitsdb.ts
34841
- import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
34842
- import { join as join6 } from "node:path";
34843
- function loadUnitsDb(dir) {
34844
- if (!dir) {
34845
- return null;
34846
- }
34847
- try {
34848
- const entries = [];
34849
- const jsonPath = join6(dir, "units.json");
34850
- if (!existsSync6(jsonPath)) {
34851
- return null;
34852
- }
34853
- const parsed = JSON.parse(readFileSync7(jsonPath, "utf8")).units;
34854
- if (!Array.isArray(parsed)) {
34855
- return null;
34856
- }
34857
- for (const u of parsed) {
34858
- const identifiers = u.identifiers ?? [];
34859
- const unitsml = identifiers.find((i) => i.type === "unitsml")?.id;
34860
- if (!unitsml) {
34861
- continue;
34862
- }
34863
- const nist = identifiers.find((i) => i.type === "nist")?.id;
34864
- const scale = u.scale_reference?.id;
34865
- const symbols = (u.symbols ?? []).map((s) => String(s.ascii ?? s.id)).filter(Boolean);
34866
- const entry = {
34867
- unitsml,
34868
- ...nist ? { nist } : {},
34869
- ...scale ? { scale } : {},
34870
- symbols
34871
- };
34872
- entries.push(entry);
34873
- }
34874
- const bySymbol = /* @__PURE__ */ new Map();
34875
- const byUnitsml = /* @__PURE__ */ new Map();
34876
- const spellings = (s) => [
34877
- s,
34878
- s.replace(/\*([a-zA-ZμΩ°]+)\^-1\b/g, "/$1")
34879
- ];
34880
- for (const e of entries) {
34881
- byUnitsml.set(e.unitsml, e);
34882
- for (const s of e.symbols) {
34883
- for (const sp of spellings(s)) {
34884
- bySymbol.set(sp, e);
34885
- }
34886
- }
34887
- }
34888
- return { bySymbol, byUnitsml };
34889
- } catch {
34890
- return null;
34891
- }
34892
- }
34893
- function unitsDbEntryFor(db, unit) {
34894
- return db?.bySymbol.get(unit) ?? null;
34895
- }
34751
+ import { readdirSync as readdirSync5, readFileSync as readFileSync7, statSync as statSync4 } from "node:fs";
34752
+ import { join as join6, relative } from "node:path";
34896
34753
 
34897
34754
  // src/export/yaml-lite.ts
34898
34755
  var NUMERIC2 = /^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/;
@@ -35085,7 +34942,7 @@ function* walkPackage(dir) {
35085
34942
  if (entry === ".DS_Store") {
35086
34943
  continue;
35087
34944
  }
35088
- const p = join7(dir, entry);
34945
+ const p = join6(dir, entry);
35089
34946
  if (statSync4(p).isDirectory()) {
35090
34947
  yield* walkPackage(p);
35091
34948
  } else {
@@ -35098,7 +34955,7 @@ function packageSourceHash(dir) {
35098
34955
  for (const file of walkPackage(dir)) {
35099
34956
  h.update(relative(dir, file));
35100
34957
  h.update("\0");
35101
- h.update(createHash("sha256").update(readFileSync8(file)).digest());
34958
+ h.update(createHash("sha256").update(readFileSync7(file)).digest());
35102
34959
  h.update("\n");
35103
34960
  }
35104
34961
  return h.digest("hex");
@@ -35390,7 +35247,6 @@ var TEXT_ADDRESS_COLLECTIONS = [
35390
35247
  "attributeDefinitions",
35391
35248
  "capabilities",
35392
35249
  "behaviors",
35393
- "conditionSets",
35394
35250
  "subjects",
35395
35251
  "referenceMaterials",
35396
35252
  "artifactDefinitions",
@@ -35802,76 +35658,6 @@ function sequenceUnit(s) {
35802
35658
  collectClauses({ sourceRefs: s.sourceRefs, refs: s.refs })
35803
35659
  );
35804
35660
  }
35805
- function conditionSetUnit(cs, registers, db = null) {
35806
- const unitsBySymbol = /* @__PURE__ */ new Map();
35807
- for (const reg of registers ?? []) {
35808
- const siUnitByKind = new Map(reg.kinds.map((k) => [k.id, k.siUnit]));
35809
- for (const u of reg.units ?? []) {
35810
- const siUnit = siUnitByKind.get(u.kind);
35811
- if (siUnit) {
35812
- unitsBySymbol.set(u.symbol, {
35813
- kind: u.kind,
35814
- factorToSI: u.factorToSI,
35815
- offsetToSI: u.offsetToSI,
35816
- siUnit
35817
- });
35818
- }
35819
- }
35820
- }
35821
- const siOf = (value, unit) => {
35822
- const def = unitsBySymbol.get(unit);
35823
- if (!def) {
35824
- return void 0;
35825
- }
35826
- const n = Number(String(value).replace(",", "."));
35827
- if (!Number.isFinite(n)) {
35828
- return void 0;
35829
- }
35830
- return { value: n * def.factorToSI + def.offsetToSI, unit: def.siUnit };
35831
- };
35832
- const payload = {
35833
- role: cs.role,
35834
- ...cs.subject ? { subject: cs.subject } : {},
35835
- entries: cs.entries.map((e) => {
35836
- const si = siOf(e.value, e.unit);
35837
- const ud = unitsDbEntryFor(db, e.unit);
35838
- return {
35839
- quantity_kind: e.quantityKind,
35840
- value: e.value,
35841
- unit: e.unit,
35842
- tolerance: e.tolerance,
35843
- ...si ? { si } : {},
35844
- ...ud ? {
35845
- unitsdb: {
35846
- unitsml: ud.unitsml,
35847
- ...ud.scale ? { scale: ud.scale } : {}
35848
- }
35849
- } : {},
35850
- ...e.note ? { note: e.note } : {}
35851
- };
35852
- })
35853
- };
35854
- return assemble(
35855
- {
35856
- id: `/condition/${cs.id}`,
35857
- kind: "condition_set",
35858
- name: cs.id,
35859
- statement: [
35860
- `${cs.role} condition set`,
35861
- ...cs.description ? [cs.description] : [],
35862
- ...cs.entries.map(
35863
- (e) => `${e.quantityKind.replace(/_/g, " ")}: ${e.value} ${e.unit} \xB1${e.tolerance}`
35864
- )
35865
- ].join(" \u2014 "),
35866
- payload
35867
- },
35868
- collectClauses({
35869
- sourceRefs: cs.sources,
35870
- refs: cs.refs,
35871
- source: cs.source
35872
- })
35873
- );
35874
- }
35875
35661
  function noteUnit(n) {
35876
35662
  return assemble(
35877
35663
  {
@@ -35976,7 +35762,6 @@ function packageBlock(standard) {
35976
35762
  };
35977
35763
  }
35978
35764
  function exportStandardRetrieval(standard, options = {}) {
35979
- const unitsDb = loadUnitsDb(process.env.UNITSDB_DIR);
35980
35765
  const pkg = packageBlock(standard);
35981
35766
  const built = [];
35982
35767
  const push = (content, elementId) => {
@@ -36018,9 +35803,6 @@ function exportStandardRetrieval(standard, options = {}) {
36018
35803
  for (const s of standard.testSequences ?? []) {
36019
35804
  push(sequenceUnit(s), s.id);
36020
35805
  }
36021
- for (const cs of standard.conditionSets ?? []) {
36022
- push(conditionSetUnit(cs, standard.quantityRegisters, unitsDb), cs.id);
36023
- }
36024
35806
  for (const n of standard.notes ?? []) {
36025
35807
  push(noteUnit(n), n.id);
36026
35808
  }
@@ -36301,8 +36083,8 @@ function exportPackageImpact(dir) {
36301
36083
  }
36302
36084
 
36303
36085
  // src/export/cddal.ts
36304
- import { readFileSync as readFileSync9, readdirSync as readdirSync6 } from "node:fs";
36305
- import { basename, join as join8, resolve as resolve5 } from "node:path";
36086
+ import { readFileSync as readFileSync8, readdirSync as readdirSync6 } from "node:fs";
36087
+ import { basename, join as join7, resolve as resolve5 } from "node:path";
36306
36088
  var CDDAL_PROJECTION_VERSION = "primmel-cddal/1";
36307
36089
  function escapeCddalString(s) {
36308
36090
  return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
@@ -36448,23 +36230,23 @@ function projectCddal(model, packageId, l10n = /* @__PURE__ */ new Map()) {
36448
36230
  }
36449
36231
  function exportPackageCddal(dir) {
36450
36232
  const model = loadPackage(dir);
36451
- const l10nFiles = readdirSync6(dir).filter((e) => /^l10n\.[^/]+\.prl$/.test(e)).map((e) => join8(dir, e));
36452
- const l10n = readL10n(l10nFiles, (p) => readFileSync9(p, "utf8"));
36233
+ const l10nFiles = readdirSync6(dir).filter((e) => /^l10n\.[^/]+\.prl$/.test(e)).map((e) => join7(dir, e));
36234
+ const l10n = readL10n(l10nFiles, (p) => readFileSync8(p, "utf8"));
36453
36235
  return projectCddal(model, basename(resolve5(dir)), l10n);
36454
36236
  }
36455
36237
 
36456
36238
  // src/package-diff.ts
36457
- import { existsSync as existsSync7, readdirSync as readdirSync7, readFileSync as readFileSync10 } from "fs";
36458
- import { join as join9 } from "path";
36239
+ import { existsSync as existsSync6, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "fs";
36240
+ import { join as join8 } from "path";
36459
36241
  function packageMappings(dir, standard) {
36460
36242
  const profiles = [...standard.mapProfiles ?? []];
36461
- if (existsSync7(dir)) {
36243
+ if (existsSync6(dir)) {
36462
36244
  for (const entry of readdirSync7(dir).sort()) {
36463
36245
  if (!entry.endsWith(".prm")) {
36464
36246
  continue;
36465
36247
  }
36466
36248
  profiles.push(
36467
- ...prmToMapProfiles(loadPrm(readFileSync10(join9(dir, entry), "utf8")))
36249
+ ...prmToMapProfiles(loadPrm(readFileSync9(join8(dir, entry), "utf8")))
36468
36250
  );
36469
36251
  }
36470
36252
  }
@@ -36473,8 +36255,8 @@ function packageMappings(dir, standard) {
36473
36255
  }
36474
36256
  function packageClauseTexts(dir) {
36475
36257
  const out = /* @__PURE__ */ new Map();
36476
- const prdDir = join9(dir, "sources-prd");
36477
- if (!existsSync7(prdDir)) {
36258
+ const prdDir = join8(dir, "sources-prd");
36259
+ if (!existsSync6(prdDir)) {
36478
36260
  return out;
36479
36261
  }
36480
36262
  for (const entry of readdirSync7(prdDir).sort()) {
@@ -36483,7 +36265,7 @@ function packageClauseTexts(dir) {
36483
36265
  }
36484
36266
  let payload;
36485
36267
  try {
36486
- payload = JSON.parse(readFileSync10(join9(prdDir, entry), "utf8"));
36268
+ payload = JSON.parse(readFileSync9(join8(prdDir, entry), "utf8"));
36487
36269
  } catch {
36488
36270
  continue;
36489
36271
  }
@@ -36544,7 +36326,7 @@ function readablePackageDirProblem(target, needsManifest) {
36544
36326
  const err = e;
36545
36327
  return err.code === "ENOENT" ? "no such directory" : err.message;
36546
36328
  }
36547
- if (needsManifest && !existsSync8(join10(target, "package.primmel"))) {
36329
+ if (needsManifest && !existsSync7(join9(target, "package.primmel"))) {
36548
36330
  return "no package.primmel found";
36549
36331
  }
36550
36332
  return null;
@@ -36785,7 +36567,7 @@ function fmtCli(argv) {
36785
36567
  const check = argv.includes("--check");
36786
36568
  const rest = argv.filter((a) => a !== "--check");
36787
36569
  const dir = rest[rest.length - 1];
36788
- if (!dir || !existsSync8(dir)) {
36570
+ if (!dir || !existsSync7(dir)) {
36789
36571
  console.error(`cannot read package at ${dir || "(none)"}: no such directory`);
36790
36572
  process.exit(2);
36791
36573
  }