@primmel/primmel 1.21.19 → 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.
- package/dist/src/check.d.ts.map +1 -1
- package/dist/src/check.js +0 -27
- package/dist/src/check.js.map +1 -1
- package/dist/src/export/retrieval.d.ts +1 -1
- package/dist/src/export/retrieval.d.ts.map +1 -1
- package/dist/src/export/retrieval.js +0 -79
- package/dist/src/export/retrieval.js.map +1 -1
- package/dist/src/model-diff.d.ts.map +1 -1
- package/dist/src/model-diff.js +0 -1
- package/dist/src/model-diff.js.map +1 -1
- package/dist/src/ser-des/config/index.d.ts.map +1 -1
- package/dist/src/ser-des/config/index.js +0 -1
- package/dist/src/ser-des/config/index.js.map +1 -1
- package/dist/src/ser-des/config/subject.d.ts +1 -9
- package/dist/src/ser-des/config/subject.d.ts.map +1 -1
- package/dist/src/ser-des/config/subject.js +1 -181
- package/dist/src/ser-des/config/subject.js.map +1 -1
- package/dist/src/ser-des/package.d.ts.map +1 -1
- package/dist/src/ser-des/package.js +0 -1
- package/dist/src/ser-des/package.js.map +1 -1
- package/dist/src/ser-des/parse.d.ts.map +1 -1
- package/dist/src/ser-des/parse.js +0 -1
- package/dist/src/ser-des/parse.js.map +1 -1
- package/dist/src/ser-des/types.d.ts +1 -2
- package/dist/src/ser-des/types.d.ts.map +1 -1
- package/dist/src/types/Artifact.d.ts +2 -3
- package/dist/src/types/Artifact.d.ts.map +1 -1
- package/dist/src/types/Artifact.js +2 -3
- package/dist/src/types/Artifact.js.map +1 -1
- package/dist/src/types/Standard.d.ts +1 -2
- package/dist/src/types/Standard.d.ts.map +1 -1
- package/dist/src/types/Subject.d.ts +0 -43
- package/dist/src/types/Subject.d.ts.map +1 -1
- package/dist-browser/index.mjs +644 -722
- package/dist-cli/primmel.mjs +19 -343
- package/package.json +1 -1
package/dist-cli/primmel.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// scripts/check.mts
|
|
4
|
-
import { existsSync as
|
|
5
|
-
import { join as
|
|
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)
|
|
@@ -14468,153 +14467,6 @@ var dumpBehavior = function(b) {
|
|
|
14468
14467
|
out += "}\n";
|
|
14469
14468
|
return out;
|
|
14470
14469
|
};
|
|
14471
|
-
var parseConditionSet = function(id, data) {
|
|
14472
|
-
const result = {
|
|
14473
|
-
id,
|
|
14474
|
-
role: "",
|
|
14475
|
-
entries: [],
|
|
14476
|
-
source: null,
|
|
14477
|
-
sources: [],
|
|
14478
|
-
referenceIds: []
|
|
14479
|
-
};
|
|
14480
|
-
const t = tokenizePackage(data);
|
|
14481
|
-
let i = 0;
|
|
14482
|
-
while (i < t.length) {
|
|
14483
|
-
const cmd = t[i++];
|
|
14484
|
-
if (i >= t.length) {
|
|
14485
|
-
break;
|
|
14486
|
-
}
|
|
14487
|
-
if (cmd === "role") {
|
|
14488
|
-
result.role = stripWrapping(t[i++]);
|
|
14489
|
-
} else if (cmd === "subject") {
|
|
14490
|
-
result.subject = stripWrapping(t[i++]);
|
|
14491
|
-
} else if (cmd === "description") {
|
|
14492
|
-
result.description = stripWrapping(t[i++]);
|
|
14493
|
-
} else if (cmd === "entries") {
|
|
14494
|
-
result.entries = parseConditionEntries(unwrapBlock(t[i++]));
|
|
14495
|
-
} else if (cmd === "source") {
|
|
14496
|
-
const src = readSource(unwrapBlock(t[i++]));
|
|
14497
|
-
result.sources.push(src);
|
|
14498
|
-
if (!result.source) {
|
|
14499
|
-
result.source = src;
|
|
14500
|
-
}
|
|
14501
|
-
} else if (cmd === "ref") {
|
|
14502
|
-
const rr = parseRef(t, i, stripWrapping, unwrapBlock);
|
|
14503
|
-
i = rr.next;
|
|
14504
|
-
if (rr.ref.predicate === "derives-from") {
|
|
14505
|
-
const b = refTargetToSourceRef(rr.ref.target);
|
|
14506
|
-
if (b) {
|
|
14507
|
-
result.sources.push(b);
|
|
14508
|
-
if (!result.source) {
|
|
14509
|
-
result.source = b;
|
|
14510
|
-
}
|
|
14511
|
-
} else {
|
|
14512
|
-
(result.refs ??= []).push(rr.ref);
|
|
14513
|
-
}
|
|
14514
|
-
} else if (rr.ref.predicate === "cites") {
|
|
14515
|
-
result.referenceIds.push(rr.ref.target);
|
|
14516
|
-
} else {
|
|
14517
|
-
(result.refs ??= []).push(rr.ref);
|
|
14518
|
-
}
|
|
14519
|
-
} else if (cmd === "corresponds") {
|
|
14520
|
-
const cc = parseCorresponds(t, i, stripWrapping);
|
|
14521
|
-
(result.correspondences ??= []).push(cc.corr);
|
|
14522
|
-
i = cc.next;
|
|
14523
|
-
} else if (cmd === "reference") {
|
|
14524
|
-
result.referenceIds = readReference(t[i++]);
|
|
14525
|
-
} else {
|
|
14526
|
-
i = skipUnknownValue(t, i, cmd);
|
|
14527
|
-
}
|
|
14528
|
-
}
|
|
14529
|
-
return (ctx) => {
|
|
14530
|
-
ctx.conditionSets[id] = result;
|
|
14531
|
-
return ctx;
|
|
14532
|
-
};
|
|
14533
|
-
};
|
|
14534
|
-
function parseConditionEntries(block) {
|
|
14535
|
-
const out = [];
|
|
14536
|
-
const t = tokenize(block);
|
|
14537
|
-
let i = 0;
|
|
14538
|
-
while (i < t.length) {
|
|
14539
|
-
const qk = stripColon(t[i++]);
|
|
14540
|
-
if (!qk) {
|
|
14541
|
-
break;
|
|
14542
|
-
}
|
|
14543
|
-
const entry = {
|
|
14544
|
-
quantityKind: qk,
|
|
14545
|
-
value: "",
|
|
14546
|
-
unit: "",
|
|
14547
|
-
tolerance: ""
|
|
14548
|
-
};
|
|
14549
|
-
if (i < t.length && t[i].startsWith("{")) {
|
|
14550
|
-
const eblock = unwrapBlock(t[i++]);
|
|
14551
|
-
const et = tokenize(eblock);
|
|
14552
|
-
let j = 0;
|
|
14553
|
-
while (j < et.length) {
|
|
14554
|
-
const cmd = et[j++];
|
|
14555
|
-
if (j >= et.length) {
|
|
14556
|
-
break;
|
|
14557
|
-
}
|
|
14558
|
-
if (cmd === "value") {
|
|
14559
|
-
entry.value = stripWrapping(et[j++]);
|
|
14560
|
-
} else if (cmd === "unit") {
|
|
14561
|
-
entry.unit = stripWrapping(et[j++]);
|
|
14562
|
-
} else if (cmd === "tolerance") {
|
|
14563
|
-
entry.tolerance = stripWrapping(et[j++]);
|
|
14564
|
-
} else if (cmd === "note") {
|
|
14565
|
-
entry.note = stripWrapping(et[j++]);
|
|
14566
|
-
} else {
|
|
14567
|
-
unwrapBlock(et[j++]);
|
|
14568
|
-
}
|
|
14569
|
-
}
|
|
14570
|
-
}
|
|
14571
|
-
out.push(entry);
|
|
14572
|
-
}
|
|
14573
|
-
return out;
|
|
14574
|
-
}
|
|
14575
|
-
var dumpConditionSet = function(cs) {
|
|
14576
|
-
let out = "condition_set " + cs.id + " {\n";
|
|
14577
|
-
if (cs.role) {
|
|
14578
|
-
out += " role " + cs.role + "\n";
|
|
14579
|
-
}
|
|
14580
|
-
if (cs.subject) {
|
|
14581
|
-
out += " subject " + cs.subject + "\n";
|
|
14582
|
-
}
|
|
14583
|
-
if (cs.description) {
|
|
14584
|
-
out += ' description "' + escapeString(cs.description) + '"\n';
|
|
14585
|
-
}
|
|
14586
|
-
if (cs.entries.length > 0) {
|
|
14587
|
-
out += " entries {\n";
|
|
14588
|
-
for (const e of cs.entries) {
|
|
14589
|
-
let line = " " + e.quantityKind + " { value " + dumpBareSafe(e.value);
|
|
14590
|
-
if (e.unit) {
|
|
14591
|
-
line += ' unit "' + escapeString(e.unit) + '"';
|
|
14592
|
-
}
|
|
14593
|
-
if (e.tolerance) {
|
|
14594
|
-
line += " tolerance " + dumpBareSafe(e.tolerance);
|
|
14595
|
-
}
|
|
14596
|
-
if (e.note) {
|
|
14597
|
-
line += ' note "' + escapeString(e.note) + '"';
|
|
14598
|
-
}
|
|
14599
|
-
out += line + " }\n";
|
|
14600
|
-
}
|
|
14601
|
-
out += " }\n";
|
|
14602
|
-
}
|
|
14603
|
-
const sources = cs.sources && cs.sources.length > 0 ? cs.sources : cs.source ? [cs.source] : [];
|
|
14604
|
-
for (const s of sources) {
|
|
14605
|
-
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
14606
|
-
}
|
|
14607
|
-
out += dumpIdList("reference", cs.referenceIds, " ");
|
|
14608
|
-
out += dumpRefs(cs.refs, " ", escapeString);
|
|
14609
|
-
out += dumpCorrespondences(
|
|
14610
|
-
cs.correspondences,
|
|
14611
|
-
" ",
|
|
14612
|
-
escapeString,
|
|
14613
|
-
dumpBareSafe
|
|
14614
|
-
);
|
|
14615
|
-
out += "}\n";
|
|
14616
|
-
return out;
|
|
14617
|
-
};
|
|
14618
14470
|
function readStringMap2(block) {
|
|
14619
14471
|
const out = {};
|
|
14620
14472
|
const t = tokenize(block);
|
|
@@ -15347,14 +15199,6 @@ var behaviorConstruct = {
|
|
|
15347
15199
|
parse: parseBehavior,
|
|
15348
15200
|
dump: dumpBehavior
|
|
15349
15201
|
};
|
|
15350
|
-
var conditionSetConstruct = {
|
|
15351
|
-
keyword: "condition_set",
|
|
15352
|
-
field: "conditionSets",
|
|
15353
|
-
takesID: true,
|
|
15354
|
-
parse: parseConditionSet,
|
|
15355
|
-
dump: dumpConditionSet,
|
|
15356
|
-
deprecated: "the severity/condition register is the legacy spelling \u2014 migrate to the typed table construct (typed columns, typed rows; the values that decide testing bind in limits via table:<id>.<column>); the legacy spelling keeps parsing as visible debt"
|
|
15357
|
-
};
|
|
15358
15202
|
var subjectConstruct = {
|
|
15359
15203
|
keyword: "subject",
|
|
15360
15204
|
field: "subjects",
|
|
@@ -20679,7 +20523,6 @@ var CONSTRUCTS = [
|
|
|
20679
20523
|
attributeDefinitionConstruct,
|
|
20680
20524
|
capabilityConstruct,
|
|
20681
20525
|
behaviorConstruct,
|
|
20682
|
-
conditionSetConstruct,
|
|
20683
20526
|
conformanceClassConstruct,
|
|
20684
20527
|
defineConstruct({
|
|
20685
20528
|
keyword: "conformance_test",
|
|
@@ -21330,7 +21173,6 @@ var MERGE_FIELDS = [
|
|
|
21330
21173
|
"attributeDefinitions",
|
|
21331
21174
|
"capabilities",
|
|
21332
21175
|
"behaviors",
|
|
21333
|
-
"conditionSets",
|
|
21334
21176
|
"subjects",
|
|
21335
21177
|
// The documentary identity slots + the qualitative aspect register
|
|
21336
21178
|
// (smart TODO.roadmap/40 batch 3) compose like the subject anatomy
|
|
@@ -22417,7 +22259,6 @@ var TIER_BY_FIELD = {
|
|
|
22417
22259
|
attributeDefinitions: "primary",
|
|
22418
22260
|
capabilities: "primary",
|
|
22419
22261
|
behaviors: "primary",
|
|
22420
|
-
conditionSets: "primary",
|
|
22421
22262
|
instances: "primary",
|
|
22422
22263
|
duals: "primary",
|
|
22423
22264
|
artifactDefinitions: "primary",
|
|
@@ -26107,7 +25948,6 @@ var IDENTITY_PREFIXES = [
|
|
|
26107
25948
|
var DIM_ALIASES = {
|
|
26108
25949
|
humidity_class: "humidity_symbol"
|
|
26109
25950
|
};
|
|
26110
|
-
var NUMERIC_TOKEN = /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;
|
|
26111
25951
|
function isIdentityPath(path) {
|
|
26112
25952
|
return IDENTITY_PREFIXES.some((p) => path.startsWith(p));
|
|
26113
25953
|
}
|
|
@@ -30299,33 +30139,6 @@ function checkPackage(dir, options = {}) {
|
|
|
30299
30139
|
}
|
|
30300
30140
|
}
|
|
30301
30141
|
}
|
|
30302
|
-
for (const cs of standard.conditionSets ?? []) {
|
|
30303
|
-
for (const e of cs.entries ?? []) {
|
|
30304
|
-
if (!e.unit) {
|
|
30305
|
-
if (NUMERIC_TOKEN.test(e.value)) {
|
|
30306
|
-
err(
|
|
30307
|
-
"C32",
|
|
30308
|
-
`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)`
|
|
30309
|
-
);
|
|
30310
|
-
}
|
|
30311
|
-
continue;
|
|
30312
|
-
}
|
|
30313
|
-
const eKind = kindOfUnit(e.unit);
|
|
30314
|
-
if (eKind === void 0) {
|
|
30315
|
-
if (registersExist) {
|
|
30316
|
-
warn(
|
|
30317
|
-
"C33",
|
|
30318
|
-
`condition_set ${cs.id}: entry "${e.quantityKind}" carries unit "${e.unit}", which no quantity_register declares (quantity-coherence)`
|
|
30319
|
-
);
|
|
30320
|
-
}
|
|
30321
|
-
} else if (kindDecl.has(e.quantityKind) && eKind !== e.quantityKind) {
|
|
30322
|
-
err(
|
|
30323
|
-
"C33",
|
|
30324
|
-
`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)`
|
|
30325
|
-
);
|
|
30326
|
-
}
|
|
30327
|
-
}
|
|
30328
|
-
}
|
|
30329
30142
|
const unitables = [
|
|
30330
30143
|
...(standard.symbols ?? []).map((s) => ({
|
|
30331
30144
|
kind: "symbol",
|
|
@@ -32176,7 +31989,6 @@ function checkPackage(dir, options = {}) {
|
|
|
32176
31989
|
collect("attribute_definition", standard.attributeDefinitions ?? []);
|
|
32177
31990
|
collect("capability", standard.capabilities ?? []);
|
|
32178
31991
|
collect("behavior", standard.behaviors ?? []);
|
|
32179
|
-
collect("condition_set", standard.conditionSets ?? []);
|
|
32180
31992
|
collect("requirement", standard.requirements ?? []);
|
|
32181
31993
|
collect("conformance_test", standard.conformanceTests ?? []);
|
|
32182
31994
|
collect("form", standard.forms ?? []);
|
|
@@ -32776,7 +32588,6 @@ function checkSpellingCodes(standard) {
|
|
|
32776
32588
|
"attributeDefinitions",
|
|
32777
32589
|
"capabilities",
|
|
32778
32590
|
"behaviors",
|
|
32779
|
-
"conditionSets",
|
|
32780
32591
|
"subjects",
|
|
32781
32592
|
"referenceMaterials",
|
|
32782
32593
|
"artifactDefinitions",
|
|
@@ -33016,9 +32827,6 @@ function checkDeclaredPredicates(standard) {
|
|
|
33016
32827
|
for (const s of standard.testSequences ?? []) {
|
|
33017
32828
|
visit(`test_sequence ${s.id}`, s.refs);
|
|
33018
32829
|
}
|
|
33019
|
-
for (const c of standard.conditionSets ?? []) {
|
|
33020
|
-
visit(`condition_set ${c.id}`, c.refs);
|
|
33021
|
-
}
|
|
33022
32830
|
for (const i of standard.instruments ?? []) {
|
|
33023
32831
|
visit(`instrument ${i.id}`, i.refs);
|
|
33024
32832
|
}
|
|
@@ -34940,65 +34748,8 @@ function renderJsonLd(prefixes, triples) {
|
|
|
34940
34748
|
|
|
34941
34749
|
// src/export/retrieval.ts
|
|
34942
34750
|
import { createHash } from "node:crypto";
|
|
34943
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
34944
|
-
import { join as
|
|
34945
|
-
|
|
34946
|
-
// src/export/unitsdb.ts
|
|
34947
|
-
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
|
|
34948
|
-
import { join as join6 } from "node:path";
|
|
34949
|
-
function loadUnitsDb(dir) {
|
|
34950
|
-
if (!dir) {
|
|
34951
|
-
return null;
|
|
34952
|
-
}
|
|
34953
|
-
try {
|
|
34954
|
-
const entries = [];
|
|
34955
|
-
const jsonPath = join6(dir, "units.json");
|
|
34956
|
-
if (!existsSync6(jsonPath)) {
|
|
34957
|
-
return null;
|
|
34958
|
-
}
|
|
34959
|
-
const parsed = JSON.parse(readFileSync7(jsonPath, "utf8")).units;
|
|
34960
|
-
if (!Array.isArray(parsed)) {
|
|
34961
|
-
return null;
|
|
34962
|
-
}
|
|
34963
|
-
for (const u of parsed) {
|
|
34964
|
-
const identifiers = u.identifiers ?? [];
|
|
34965
|
-
const unitsml = identifiers.find((i) => i.type === "unitsml")?.id;
|
|
34966
|
-
if (!unitsml) {
|
|
34967
|
-
continue;
|
|
34968
|
-
}
|
|
34969
|
-
const nist = identifiers.find((i) => i.type === "nist")?.id;
|
|
34970
|
-
const scale = u.scale_reference?.id;
|
|
34971
|
-
const symbols = (u.symbols ?? []).map((s) => String(s.ascii ?? s.id)).filter(Boolean);
|
|
34972
|
-
const entry = {
|
|
34973
|
-
unitsml,
|
|
34974
|
-
...nist ? { nist } : {},
|
|
34975
|
-
...scale ? { scale } : {},
|
|
34976
|
-
symbols
|
|
34977
|
-
};
|
|
34978
|
-
entries.push(entry);
|
|
34979
|
-
}
|
|
34980
|
-
const bySymbol = /* @__PURE__ */ new Map();
|
|
34981
|
-
const byUnitsml = /* @__PURE__ */ new Map();
|
|
34982
|
-
const spellings = (s) => [
|
|
34983
|
-
s,
|
|
34984
|
-
s.replace(/\*([a-zA-ZμΩ°]+)\^-1\b/g, "/$1")
|
|
34985
|
-
];
|
|
34986
|
-
for (const e of entries) {
|
|
34987
|
-
byUnitsml.set(e.unitsml, e);
|
|
34988
|
-
for (const s of e.symbols) {
|
|
34989
|
-
for (const sp of spellings(s)) {
|
|
34990
|
-
bySymbol.set(sp, e);
|
|
34991
|
-
}
|
|
34992
|
-
}
|
|
34993
|
-
}
|
|
34994
|
-
return { bySymbol, byUnitsml };
|
|
34995
|
-
} catch {
|
|
34996
|
-
return null;
|
|
34997
|
-
}
|
|
34998
|
-
}
|
|
34999
|
-
function unitsDbEntryFor(db, unit) {
|
|
35000
|
-
return db?.bySymbol.get(unit) ?? null;
|
|
35001
|
-
}
|
|
34751
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync7, statSync as statSync4 } from "node:fs";
|
|
34752
|
+
import { join as join6, relative } from "node:path";
|
|
35002
34753
|
|
|
35003
34754
|
// src/export/yaml-lite.ts
|
|
35004
34755
|
var NUMERIC2 = /^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/;
|
|
@@ -35191,7 +34942,7 @@ function* walkPackage(dir) {
|
|
|
35191
34942
|
if (entry === ".DS_Store") {
|
|
35192
34943
|
continue;
|
|
35193
34944
|
}
|
|
35194
|
-
const p =
|
|
34945
|
+
const p = join6(dir, entry);
|
|
35195
34946
|
if (statSync4(p).isDirectory()) {
|
|
35196
34947
|
yield* walkPackage(p);
|
|
35197
34948
|
} else {
|
|
@@ -35204,7 +34955,7 @@ function packageSourceHash(dir) {
|
|
|
35204
34955
|
for (const file of walkPackage(dir)) {
|
|
35205
34956
|
h.update(relative(dir, file));
|
|
35206
34957
|
h.update("\0");
|
|
35207
|
-
h.update(createHash("sha256").update(
|
|
34958
|
+
h.update(createHash("sha256").update(readFileSync7(file)).digest());
|
|
35208
34959
|
h.update("\n");
|
|
35209
34960
|
}
|
|
35210
34961
|
return h.digest("hex");
|
|
@@ -35496,7 +35247,6 @@ var TEXT_ADDRESS_COLLECTIONS = [
|
|
|
35496
35247
|
"attributeDefinitions",
|
|
35497
35248
|
"capabilities",
|
|
35498
35249
|
"behaviors",
|
|
35499
|
-
"conditionSets",
|
|
35500
35250
|
"subjects",
|
|
35501
35251
|
"referenceMaterials",
|
|
35502
35252
|
"artifactDefinitions",
|
|
@@ -35908,76 +35658,6 @@ function sequenceUnit(s) {
|
|
|
35908
35658
|
collectClauses({ sourceRefs: s.sourceRefs, refs: s.refs })
|
|
35909
35659
|
);
|
|
35910
35660
|
}
|
|
35911
|
-
function conditionSetUnit(cs, registers, db = null) {
|
|
35912
|
-
const unitsBySymbol = /* @__PURE__ */ new Map();
|
|
35913
|
-
for (const reg of registers ?? []) {
|
|
35914
|
-
const siUnitByKind = new Map(reg.kinds.map((k) => [k.id, k.siUnit]));
|
|
35915
|
-
for (const u of reg.units ?? []) {
|
|
35916
|
-
const siUnit = siUnitByKind.get(u.kind);
|
|
35917
|
-
if (siUnit) {
|
|
35918
|
-
unitsBySymbol.set(u.symbol, {
|
|
35919
|
-
kind: u.kind,
|
|
35920
|
-
factorToSI: u.factorToSI,
|
|
35921
|
-
offsetToSI: u.offsetToSI,
|
|
35922
|
-
siUnit
|
|
35923
|
-
});
|
|
35924
|
-
}
|
|
35925
|
-
}
|
|
35926
|
-
}
|
|
35927
|
-
const siOf = (value, unit) => {
|
|
35928
|
-
const def = unitsBySymbol.get(unit);
|
|
35929
|
-
if (!def) {
|
|
35930
|
-
return void 0;
|
|
35931
|
-
}
|
|
35932
|
-
const n = Number(String(value).replace(",", "."));
|
|
35933
|
-
if (!Number.isFinite(n)) {
|
|
35934
|
-
return void 0;
|
|
35935
|
-
}
|
|
35936
|
-
return { value: n * def.factorToSI + def.offsetToSI, unit: def.siUnit };
|
|
35937
|
-
};
|
|
35938
|
-
const payload = {
|
|
35939
|
-
role: cs.role,
|
|
35940
|
-
...cs.subject ? { subject: cs.subject } : {},
|
|
35941
|
-
entries: cs.entries.map((e) => {
|
|
35942
|
-
const si = siOf(e.value, e.unit);
|
|
35943
|
-
const ud = unitsDbEntryFor(db, e.unit);
|
|
35944
|
-
return {
|
|
35945
|
-
quantity_kind: e.quantityKind,
|
|
35946
|
-
value: e.value,
|
|
35947
|
-
unit: e.unit,
|
|
35948
|
-
tolerance: e.tolerance,
|
|
35949
|
-
...si ? { si } : {},
|
|
35950
|
-
...ud ? {
|
|
35951
|
-
unitsdb: {
|
|
35952
|
-
unitsml: ud.unitsml,
|
|
35953
|
-
...ud.scale ? { scale: ud.scale } : {}
|
|
35954
|
-
}
|
|
35955
|
-
} : {},
|
|
35956
|
-
...e.note ? { note: e.note } : {}
|
|
35957
|
-
};
|
|
35958
|
-
})
|
|
35959
|
-
};
|
|
35960
|
-
return assemble(
|
|
35961
|
-
{
|
|
35962
|
-
id: `/condition/${cs.id}`,
|
|
35963
|
-
kind: "condition_set",
|
|
35964
|
-
name: cs.id,
|
|
35965
|
-
statement: [
|
|
35966
|
-
`${cs.role} condition set`,
|
|
35967
|
-
...cs.description ? [cs.description] : [],
|
|
35968
|
-
...cs.entries.map(
|
|
35969
|
-
(e) => `${e.quantityKind.replace(/_/g, " ")}: ${e.value} ${e.unit} \xB1${e.tolerance}`
|
|
35970
|
-
)
|
|
35971
|
-
].join(" \u2014 "),
|
|
35972
|
-
payload
|
|
35973
|
-
},
|
|
35974
|
-
collectClauses({
|
|
35975
|
-
sourceRefs: cs.sources,
|
|
35976
|
-
refs: cs.refs,
|
|
35977
|
-
source: cs.source
|
|
35978
|
-
})
|
|
35979
|
-
);
|
|
35980
|
-
}
|
|
35981
35661
|
function noteUnit(n) {
|
|
35982
35662
|
return assemble(
|
|
35983
35663
|
{
|
|
@@ -36082,7 +35762,6 @@ function packageBlock(standard) {
|
|
|
36082
35762
|
};
|
|
36083
35763
|
}
|
|
36084
35764
|
function exportStandardRetrieval(standard, options = {}) {
|
|
36085
|
-
const unitsDb = loadUnitsDb(process.env.UNITSDB_DIR);
|
|
36086
35765
|
const pkg = packageBlock(standard);
|
|
36087
35766
|
const built = [];
|
|
36088
35767
|
const push = (content, elementId) => {
|
|
@@ -36124,9 +35803,6 @@ function exportStandardRetrieval(standard, options = {}) {
|
|
|
36124
35803
|
for (const s of standard.testSequences ?? []) {
|
|
36125
35804
|
push(sequenceUnit(s), s.id);
|
|
36126
35805
|
}
|
|
36127
|
-
for (const cs of standard.conditionSets ?? []) {
|
|
36128
|
-
push(conditionSetUnit(cs, standard.quantityRegisters, unitsDb), cs.id);
|
|
36129
|
-
}
|
|
36130
35806
|
for (const n of standard.notes ?? []) {
|
|
36131
35807
|
push(noteUnit(n), n.id);
|
|
36132
35808
|
}
|
|
@@ -36407,8 +36083,8 @@ function exportPackageImpact(dir) {
|
|
|
36407
36083
|
}
|
|
36408
36084
|
|
|
36409
36085
|
// src/export/cddal.ts
|
|
36410
|
-
import { readFileSync as
|
|
36411
|
-
import { basename, join as
|
|
36086
|
+
import { readFileSync as readFileSync8, readdirSync as readdirSync6 } from "node:fs";
|
|
36087
|
+
import { basename, join as join7, resolve as resolve5 } from "node:path";
|
|
36412
36088
|
var CDDAL_PROJECTION_VERSION = "primmel-cddal/1";
|
|
36413
36089
|
function escapeCddalString(s) {
|
|
36414
36090
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
@@ -36554,23 +36230,23 @@ function projectCddal(model, packageId, l10n = /* @__PURE__ */ new Map()) {
|
|
|
36554
36230
|
}
|
|
36555
36231
|
function exportPackageCddal(dir) {
|
|
36556
36232
|
const model = loadPackage(dir);
|
|
36557
|
-
const l10nFiles = readdirSync6(dir).filter((e) => /^l10n\.[^/]+\.prl$/.test(e)).map((e) =>
|
|
36558
|
-
const l10n = readL10n(l10nFiles, (p) =>
|
|
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"));
|
|
36559
36235
|
return projectCddal(model, basename(resolve5(dir)), l10n);
|
|
36560
36236
|
}
|
|
36561
36237
|
|
|
36562
36238
|
// src/package-diff.ts
|
|
36563
|
-
import { existsSync as
|
|
36564
|
-
import { join as
|
|
36239
|
+
import { existsSync as existsSync6, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "fs";
|
|
36240
|
+
import { join as join8 } from "path";
|
|
36565
36241
|
function packageMappings(dir, standard) {
|
|
36566
36242
|
const profiles = [...standard.mapProfiles ?? []];
|
|
36567
|
-
if (
|
|
36243
|
+
if (existsSync6(dir)) {
|
|
36568
36244
|
for (const entry of readdirSync7(dir).sort()) {
|
|
36569
36245
|
if (!entry.endsWith(".prm")) {
|
|
36570
36246
|
continue;
|
|
36571
36247
|
}
|
|
36572
36248
|
profiles.push(
|
|
36573
|
-
...prmToMapProfiles(loadPrm(
|
|
36249
|
+
...prmToMapProfiles(loadPrm(readFileSync9(join8(dir, entry), "utf8")))
|
|
36574
36250
|
);
|
|
36575
36251
|
}
|
|
36576
36252
|
}
|
|
@@ -36579,8 +36255,8 @@ function packageMappings(dir, standard) {
|
|
|
36579
36255
|
}
|
|
36580
36256
|
function packageClauseTexts(dir) {
|
|
36581
36257
|
const out = /* @__PURE__ */ new Map();
|
|
36582
|
-
const prdDir =
|
|
36583
|
-
if (!
|
|
36258
|
+
const prdDir = join8(dir, "sources-prd");
|
|
36259
|
+
if (!existsSync6(prdDir)) {
|
|
36584
36260
|
return out;
|
|
36585
36261
|
}
|
|
36586
36262
|
for (const entry of readdirSync7(prdDir).sort()) {
|
|
@@ -36589,7 +36265,7 @@ function packageClauseTexts(dir) {
|
|
|
36589
36265
|
}
|
|
36590
36266
|
let payload;
|
|
36591
36267
|
try {
|
|
36592
|
-
payload = JSON.parse(
|
|
36268
|
+
payload = JSON.parse(readFileSync9(join8(prdDir, entry), "utf8"));
|
|
36593
36269
|
} catch {
|
|
36594
36270
|
continue;
|
|
36595
36271
|
}
|
|
@@ -36650,7 +36326,7 @@ function readablePackageDirProblem(target, needsManifest) {
|
|
|
36650
36326
|
const err = e;
|
|
36651
36327
|
return err.code === "ENOENT" ? "no such directory" : err.message;
|
|
36652
36328
|
}
|
|
36653
|
-
if (needsManifest && !
|
|
36329
|
+
if (needsManifest && !existsSync7(join9(target, "package.primmel"))) {
|
|
36654
36330
|
return "no package.primmel found";
|
|
36655
36331
|
}
|
|
36656
36332
|
return null;
|
|
@@ -36891,7 +36567,7 @@ function fmtCli(argv) {
|
|
|
36891
36567
|
const check = argv.includes("--check");
|
|
36892
36568
|
const rest = argv.filter((a) => a !== "--check");
|
|
36893
36569
|
const dir = rest[rest.length - 1];
|
|
36894
|
-
if (!dir || !
|
|
36570
|
+
if (!dir || !existsSync7(dir)) {
|
|
36895
36571
|
console.error(`cannot read package at ${dir || "(none)"}: no such directory`);
|
|
36896
36572
|
process.exit(2);
|
|
36897
36573
|
}
|
package/package.json
CHANGED