@htilabs/platform-common-models 0.19.0 → 0.20.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/dist/cvcs/index.cjs +4769 -643
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +5036 -606
- package/dist/cvcs/index.d.ts +5036 -606
- package/dist/cvcs/index.js +4769 -643
- package/dist/cvcs/index.js.map +1 -1
- package/dist/enums/index.cjs +74 -1
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.cts +77 -4
- package/dist/enums/index.d.ts +77 -4
- package/dist/enums/index.js +74 -1
- package/dist/enums/index.js.map +1 -1
- package/dist/index.cjs +5199 -588
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5189 -588
- package/dist/index.js.map +1 -1
- package/dist/information-scope/index.cjs +440 -0
- package/dist/information-scope/index.cjs.map +1 -0
- package/dist/information-scope/index.d.cts +313 -0
- package/dist/information-scope/index.d.ts +313 -0
- package/dist/information-scope/index.js +404 -0
- package/dist/information-scope/index.js.map +1 -0
- package/dist/services/index.cjs +414 -2
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +403 -1
- package/dist/services/index.js.map +1 -1
- package/package.json +32 -26
- package/src/__tests__/__snapshots__/cvc-sot.snap +3 -3
- package/src/__tests__/core-information-scope-invariant.test.ts +709 -456
- package/src/__tests__/cvc-sot-snapshot.test.ts +16 -17
- package/src/__tests__/cvc-structural.test.ts +2 -2
- package/src/__tests__/location-type-routing-invariant.test.ts +25 -8
- package/src/cvcs/coreInformationScope.v2.0.0.json +5396 -0
- package/src/cvcs/index.ts +2 -2
- package/src/cvcs/roiScope.v1.3.0.json +360 -0
- package/src/generated/cvc-enums.ts +77 -4
- package/src/services/__tests__/fixtures/infoscope-v4/information_scope_v4.migrations.csv +106 -0
- package/src/services/__tests__/fixtures/infoscope-v4/information_scope_v4.rows.csv +117 -0
- package/src/services/__tests__/fixtures/infoscope-v4/loadInfoscopeV4Fixtures.ts +116 -0
- package/src/services/__tests__/informationScopeResolver.test.ts +964 -0
- package/src/services/index.ts +10 -3
- package/src/services/informationScope.ts +10 -0
- package/src/services/informationScopeResolver.ts +672 -0
- package/src/services/informationScopeSot.ts +161 -0
- package/src/cvcs/coreInformationScope.v1.1.0.json +0 -1290
- package/src/cvcs/roiScope.v1.2.0.json +0 -340
package/dist/services/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Connection, Types } from 'mongoose';
|
|
2
|
+
export { CoreInformationScopeSot, CoreInformationScopeSotEntry, CoreInformationScopeSotMigrationLine, CreateInformationScopeResolverInput, INFORMATION_SCOPE_READABLE_VERSIONS, INFORMATION_SCOPE_SYSTEM_INFO, INFORMATION_SCOPE_VERSION, InformationScopeResolver, ScopeApp, ScopeApps, ScopeCodeReading, ScopeKindBranch, ScopeMigration, ScopeMigrationRule, ScopePersonKind, ScopeReading, ScopeReadingRule, ScopeRow, ScopeRowStatus, ScopeRowType, ScopeShareOptions, ScopeShareReason, ScopeShareVerdict, ScopeSpecialDataType, ScopeSubjectKind, StoredScopeList, createInformationScopeResolver, isScopeInstrumentRow, isScopeRestRow, isSelectableScopeRow, kindForPerson, scopeMigrationsFromSot, scopeRowsFromSot } from '../information-scope/index.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @htilabs/platform-common-models — CvcRegistryService
|
package/dist/services/index.js
CHANGED
|
@@ -1405,11 +1405,413 @@ var CvcRegistryService = class {
|
|
|
1405
1405
|
return [...this.resolvedCache.keys()];
|
|
1406
1406
|
}
|
|
1407
1407
|
};
|
|
1408
|
+
|
|
1409
|
+
// src/services/informationScopeResolver.ts
|
|
1410
|
+
var INFORMATION_SCOPE_VERSION = 4;
|
|
1411
|
+
var INFORMATION_SCOPE_READABLE_VERSIONS = Object.freeze([3, 4]);
|
|
1412
|
+
var INFORMATION_SCOPE_SYSTEM_INFO = "system_info";
|
|
1413
|
+
var isSelectableScopeRow = (row) => row !== void 0 && row.selectable && row.status !== "retired";
|
|
1414
|
+
var isScopeRestRow = (row) => row !== void 0 && row.rowType === "category_rest";
|
|
1415
|
+
var isScopeInstrumentRow = (row) => row !== void 0 && row.rowType === "instrument row";
|
|
1416
|
+
function kindForPerson(person) {
|
|
1417
|
+
if (person.causedHarm) return "offenders";
|
|
1418
|
+
if (person.efmAsserted) return "family";
|
|
1419
|
+
return "others";
|
|
1420
|
+
}
|
|
1421
|
+
var PERSON_KINDS = /* @__PURE__ */ new Set(["offenders", "family", "others"]);
|
|
1422
|
+
var SPECIAL_DATA_TYPES = /* @__PURE__ */ new Set([
|
|
1423
|
+
"none",
|
|
1424
|
+
"survivor_confidential",
|
|
1425
|
+
"criminal_intelligence",
|
|
1426
|
+
"evidence"
|
|
1427
|
+
]);
|
|
1428
|
+
var MIGRATION_RULES = /* @__PURE__ */ new Set([
|
|
1429
|
+
"identity",
|
|
1430
|
+
"row",
|
|
1431
|
+
"category",
|
|
1432
|
+
"subtract",
|
|
1433
|
+
"retired before v4"
|
|
1434
|
+
]);
|
|
1435
|
+
var RETIRED_RULES = /* @__PURE__ */ new Set([
|
|
1436
|
+
"row",
|
|
1437
|
+
"subtract",
|
|
1438
|
+
"retired before v4"
|
|
1439
|
+
]);
|
|
1440
|
+
var SELECTION_PRECEDENCE = [
|
|
1441
|
+
"category",
|
|
1442
|
+
"identity",
|
|
1443
|
+
"row",
|
|
1444
|
+
"retired before v4"
|
|
1445
|
+
];
|
|
1446
|
+
var RESTRICTION_PRECEDENCE = [
|
|
1447
|
+
"subtract",
|
|
1448
|
+
...SELECTION_PRECEDENCE
|
|
1449
|
+
];
|
|
1450
|
+
var asList = (list) => Array.isArray(list) ? list : [];
|
|
1451
|
+
function createInformationScopeResolver(input) {
|
|
1452
|
+
const rows = Object.freeze([...input.rows]);
|
|
1453
|
+
const byCode = /* @__PURE__ */ new Map();
|
|
1454
|
+
const order = /* @__PURE__ */ new Map();
|
|
1455
|
+
for (const r of rows) {
|
|
1456
|
+
if (byCode.has(r.scopeCode)) {
|
|
1457
|
+
throw new Error(`information scope: duplicate code "${r.scopeCode}"`);
|
|
1458
|
+
}
|
|
1459
|
+
byCode.set(r.scopeCode, r);
|
|
1460
|
+
order.set(r.scopeCode, order.size);
|
|
1461
|
+
}
|
|
1462
|
+
const isLive = (code) => {
|
|
1463
|
+
const r = byCode.get(code);
|
|
1464
|
+
return r !== void 0 && r.status !== "retired";
|
|
1465
|
+
};
|
|
1466
|
+
const children = /* @__PURE__ */ new Map();
|
|
1467
|
+
for (const r of rows) {
|
|
1468
|
+
if (r.status !== "retired" && !SPECIAL_DATA_TYPES.has(r.specialDataType)) {
|
|
1469
|
+
throw new Error(
|
|
1470
|
+
`information scope: "${r.scopeCode}" has specialDataType ${JSON.stringify(r.specialDataType)}`
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1473
|
+
if (r.parentScopeCode === null || r.parentScopeCode === "") continue;
|
|
1474
|
+
if (!byCode.has(r.parentScopeCode)) {
|
|
1475
|
+
throw new Error(
|
|
1476
|
+
`information scope: "${r.scopeCode}" names unknown parent "${r.parentScopeCode}"`
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
if (r.status === "retired") continue;
|
|
1480
|
+
const list = children.get(r.parentScopeCode) ?? [];
|
|
1481
|
+
list.push(r.scopeCode);
|
|
1482
|
+
children.set(r.parentScopeCode, list);
|
|
1483
|
+
}
|
|
1484
|
+
const ancestorCache = /* @__PURE__ */ new Map();
|
|
1485
|
+
const ancestors = (code) => {
|
|
1486
|
+
const hit = ancestorCache.get(code);
|
|
1487
|
+
if (hit) return hit;
|
|
1488
|
+
const out = [];
|
|
1489
|
+
let cur = code;
|
|
1490
|
+
while (cur !== null && cur !== "") {
|
|
1491
|
+
const r = byCode.get(cur);
|
|
1492
|
+
if (!r) break;
|
|
1493
|
+
if (out.includes(cur)) throw new Error(`information scope: cycle at "${cur}"`);
|
|
1494
|
+
out.push(cur);
|
|
1495
|
+
cur = r.parentScopeCode;
|
|
1496
|
+
}
|
|
1497
|
+
ancestorCache.set(code, out);
|
|
1498
|
+
return out;
|
|
1499
|
+
};
|
|
1500
|
+
for (const r of rows) ancestors(r.scopeCode);
|
|
1501
|
+
if (!isLive(INFORMATION_SCOPE_SYSTEM_INFO)) {
|
|
1502
|
+
throw new Error(`information scope: the tree has no "${INFORMATION_SCOPE_SYSTEM_INFO}" row`);
|
|
1503
|
+
}
|
|
1504
|
+
const alwaysCovered = new Set(ancestors(INFORMATION_SCOPE_SYSTEM_INFO));
|
|
1505
|
+
const kids = (code) => children.get(code) ?? [];
|
|
1506
|
+
const descendantsOf = (code) => {
|
|
1507
|
+
const out = [];
|
|
1508
|
+
const stack = [...kids(code)];
|
|
1509
|
+
while (stack.length > 0) {
|
|
1510
|
+
const c = stack.pop();
|
|
1511
|
+
out.push(c);
|
|
1512
|
+
stack.push(...kids(c));
|
|
1513
|
+
}
|
|
1514
|
+
return out;
|
|
1515
|
+
};
|
|
1516
|
+
const restRowOf = (code) => kids(code).find((c) => isScopeRestRow(byCode.get(c)));
|
|
1517
|
+
const kindRoot = /* @__PURE__ */ new Map();
|
|
1518
|
+
const perKindRow = /* @__PURE__ */ new Map();
|
|
1519
|
+
for (const r of rows) {
|
|
1520
|
+
if (r.status === "retired" || r.kindBranch === null || !PERSON_KINDS.has(r.kindBranch)) continue;
|
|
1521
|
+
if (r.rowType === "person_type") {
|
|
1522
|
+
kindRoot.set(r.kindBranch, r.scopeCode);
|
|
1523
|
+
continue;
|
|
1524
|
+
}
|
|
1525
|
+
if (r.kindRow === void 0 || !isLive(r.kindRow)) {
|
|
1526
|
+
throw new Error(
|
|
1527
|
+
`information scope: per-kind row "${r.scopeCode}" has no live kindRow (${String(r.kindRow)})`
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1530
|
+
perKindRow.set(`${r.kindBranch}\0${r.kindRow}`, r.scopeCode);
|
|
1531
|
+
}
|
|
1532
|
+
const migrations = /* @__PURE__ */ new Map();
|
|
1533
|
+
for (const m of input.migrations ?? []) {
|
|
1534
|
+
if (!MIGRATION_RULES.has(m.rule)) {
|
|
1535
|
+
throw new Error(`information scope: unknown migration rule "${m.rule}" on "${m.from}"`);
|
|
1536
|
+
}
|
|
1537
|
+
for (const to of m.to) {
|
|
1538
|
+
if (!isLive(to)) {
|
|
1539
|
+
throw new Error(
|
|
1540
|
+
`information scope: migration "${m.from}" (${m.rule}) reads as "${to}", not a live row`
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
const perCode = migrations.get(m.from) ?? /* @__PURE__ */ new Map();
|
|
1545
|
+
const prior = perCode.get(m.rule);
|
|
1546
|
+
if (prior && prior.to.join(" ") !== m.to.join(" ")) {
|
|
1547
|
+
throw new Error(`information scope: two "${m.rule}" readings for "${m.from}"`);
|
|
1548
|
+
}
|
|
1549
|
+
perCode.set(m.rule, {
|
|
1550
|
+
from: m.from,
|
|
1551
|
+
rule: m.rule,
|
|
1552
|
+
to: Object.freeze([...m.to]),
|
|
1553
|
+
widens: m.widens === true || prior?.widens === true
|
|
1554
|
+
});
|
|
1555
|
+
migrations.set(m.from, perCode);
|
|
1556
|
+
}
|
|
1557
|
+
const normalize = (codes, withSystemInfo = true) => {
|
|
1558
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1559
|
+
const known = [];
|
|
1560
|
+
const unknown = [];
|
|
1561
|
+
const all = withSystemInfo ? [INFORMATION_SCOPE_SYSTEM_INFO, ...codes] : [...codes];
|
|
1562
|
+
for (const c of all) {
|
|
1563
|
+
if (seen.has(c)) continue;
|
|
1564
|
+
seen.add(c);
|
|
1565
|
+
(byCode.has(c) ? known : unknown).push(c);
|
|
1566
|
+
}
|
|
1567
|
+
known.sort((a, b) => order.get(a) - order.get(b));
|
|
1568
|
+
return [...known, ...unknown];
|
|
1569
|
+
};
|
|
1570
|
+
const requirePickable = (code, op) => {
|
|
1571
|
+
if (!byCode.has(code)) throw new RangeError(`information scope ${op}: unknown code "${code}"`);
|
|
1572
|
+
if (!isSelectableScopeRow(byCode.get(code))) {
|
|
1573
|
+
throw new RangeError(`information scope ${op}: "${code}" is not selectable`);
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
const isCovered = (selection, code) => {
|
|
1577
|
+
if (!isLive(code)) return false;
|
|
1578
|
+
if (alwaysCovered.has(code)) return true;
|
|
1579
|
+
const sel = new Set(asList(selection));
|
|
1580
|
+
if (ancestors(code).some((a) => sel.has(a))) return true;
|
|
1581
|
+
const rest = restRowOf(code);
|
|
1582
|
+
return rest !== void 0 && sel.has(rest);
|
|
1583
|
+
};
|
|
1584
|
+
const shareVerdict = (selection, code, options = {}) => {
|
|
1585
|
+
if (!isLive(code)) return { included: false, reason: "unknown_code" };
|
|
1586
|
+
if (!isCovered(selection, code)) return { included: false, reason: "not_covered" };
|
|
1587
|
+
const chain = ancestors(code).map((c) => byCode.get(c));
|
|
1588
|
+
if (chain.some((r) => r.platformFloor)) return { included: false, reason: "platform_floor" };
|
|
1589
|
+
const enabled = new Set(options.enabledOffByDefault ?? []);
|
|
1590
|
+
const notEnabled = chain.filter((r) => !r.shareableDefault && !enabled.has(r.scopeCode)).map((r) => r.scopeCode);
|
|
1591
|
+
if (notEnabled.length > 0) return { included: false, reason: "off_by_default", notEnabled };
|
|
1592
|
+
return { included: true, reason: "included" };
|
|
1593
|
+
};
|
|
1594
|
+
const expandSelectAll = (code) => {
|
|
1595
|
+
if (!byCode.has(code)) throw new RangeError(`information scope expand: unknown code "${code}"`);
|
|
1596
|
+
return [...kids(code)];
|
|
1597
|
+
};
|
|
1598
|
+
const selectAll = (selection, code) => {
|
|
1599
|
+
requirePickable(code, "selectAll");
|
|
1600
|
+
const drop = new Set(descendantsOf(code));
|
|
1601
|
+
return normalize([...selection.filter((c) => !drop.has(c)), code]);
|
|
1602
|
+
};
|
|
1603
|
+
const deselectChild = (selection, childCode) => {
|
|
1604
|
+
requirePickable(childCode, "deselectChild");
|
|
1605
|
+
if (alwaysCovered.has(childCode)) {
|
|
1606
|
+
throw new RangeError(`information scope deselectChild: "${childCode}" is always included`);
|
|
1607
|
+
}
|
|
1608
|
+
const sel = new Set(selection);
|
|
1609
|
+
const path = ancestors(childCode);
|
|
1610
|
+
let top = 0;
|
|
1611
|
+
for (let i = 1; i < path.length; i += 1) if (sel.has(path[i])) top = i;
|
|
1612
|
+
for (let i = 1; i <= top; i += 1) {
|
|
1613
|
+
sel.delete(path[i]);
|
|
1614
|
+
for (const c of kids(path[i])) if (c !== path[i - 1]) sel.add(c);
|
|
1615
|
+
}
|
|
1616
|
+
sel.delete(childCode);
|
|
1617
|
+
for (const d of descendantsOf(childCode)) sel.delete(d);
|
|
1618
|
+
return normalize(sel);
|
|
1619
|
+
};
|
|
1620
|
+
const readOne = (from, scopeVersion, precedence) => {
|
|
1621
|
+
if (scopeVersion === INFORMATION_SCOPE_VERSION && isLive(from)) {
|
|
1622
|
+
return { from, rule: "identity", reads: [from], widens: false };
|
|
1623
|
+
}
|
|
1624
|
+
const lines = migrations.get(from);
|
|
1625
|
+
if (lines) {
|
|
1626
|
+
for (const rule of precedence) {
|
|
1627
|
+
if (scopeVersion === INFORMATION_SCOPE_VERSION && (rule === "identity" || rule === "category")) {
|
|
1628
|
+
continue;
|
|
1629
|
+
}
|
|
1630
|
+
const line = lines.get(rule);
|
|
1631
|
+
if (line) return { from, rule, reads: [...line.to], widens: line.widens === true };
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
return { from, rule: "unknown", reads: [], widens: false };
|
|
1635
|
+
};
|
|
1636
|
+
const read = (list, scopeVersion, precedence, isRestriction) => {
|
|
1637
|
+
const stored = [...asList(list)];
|
|
1638
|
+
const supported = typeof scopeVersion === "number" && INFORMATION_SCOPE_READABLE_VERSIONS.includes(scopeVersion);
|
|
1639
|
+
const codes = [];
|
|
1640
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1641
|
+
for (const from of stored) {
|
|
1642
|
+
if (seen.has(from)) continue;
|
|
1643
|
+
seen.add(from);
|
|
1644
|
+
codes.push(
|
|
1645
|
+
supported ? readOne(from, scopeVersion, precedence) : { from, rule: "unknown", reads: [], widens: false }
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
return {
|
|
1649
|
+
storedVersion: typeof scopeVersion === "number" ? scopeVersion : null,
|
|
1650
|
+
stored,
|
|
1651
|
+
version: INFORMATION_SCOPE_VERSION,
|
|
1652
|
+
unsupportedVersion: !supported,
|
|
1653
|
+
informationScope: normalize(
|
|
1654
|
+
codes.flatMap((c) => c.reads),
|
|
1655
|
+
!isRestriction
|
|
1656
|
+
),
|
|
1657
|
+
codes,
|
|
1658
|
+
retired: codes.filter((c) => RETIRED_RULES.has(c.rule)).map((c) => c.from),
|
|
1659
|
+
unknown: codes.filter((c) => c.rule === "unknown").map((c) => c.from),
|
|
1660
|
+
widened: codes.filter((c) => c.widens).map((c) => c.from)
|
|
1661
|
+
};
|
|
1662
|
+
};
|
|
1663
|
+
const rowForSubject = (homeRow, kind) => {
|
|
1664
|
+
const home = byCode.get(homeRow);
|
|
1665
|
+
if (!home) throw new RangeError(`information scope rowForSubject: unknown home "${homeRow}"`);
|
|
1666
|
+
if (kind === "client") return homeRow;
|
|
1667
|
+
const chain = ancestors(homeRow);
|
|
1668
|
+
if (byCode.get(chain[chain.length - 1])?.rowType !== "branch") return homeRow;
|
|
1669
|
+
if (home.specialDataType === "criminal_intelligence") return homeRow;
|
|
1670
|
+
const root = kindRoot.get(kind);
|
|
1671
|
+
if (!root) throw new RangeError(`information scope rowForSubject: the tree has no "${kind}" kind`);
|
|
1672
|
+
if (chain.includes(root)) return homeRow;
|
|
1673
|
+
for (const anc of chain) {
|
|
1674
|
+
const perKind = perKindRow.get(`${kind}\0${anc}`);
|
|
1675
|
+
if (perKind !== void 0) return perKind;
|
|
1676
|
+
}
|
|
1677
|
+
return root;
|
|
1678
|
+
};
|
|
1679
|
+
const expandBranchPickToGrain = (selection, ceiling) => {
|
|
1680
|
+
const ceil = asList(ceiling);
|
|
1681
|
+
const ceilSet = new Set(ceil);
|
|
1682
|
+
const isWithin = (c) => ancestors(c).some((a) => ceilSet.has(a));
|
|
1683
|
+
const isAbove = (c) => ceil.some((k) => k !== c && ancestors(k).includes(c));
|
|
1684
|
+
const out = [];
|
|
1685
|
+
const stack = [...asList(selection)];
|
|
1686
|
+
while (stack.length > 0) {
|
|
1687
|
+
const c = stack.pop();
|
|
1688
|
+
if (isLive(c) && !isWithin(c) && isAbove(c)) stack.push(...kids(c));
|
|
1689
|
+
else out.push(c);
|
|
1690
|
+
}
|
|
1691
|
+
return normalize(out);
|
|
1692
|
+
};
|
|
1693
|
+
const clampToCeiling = (selection, ceiling) => {
|
|
1694
|
+
const ceil = new Set(asList(ceiling));
|
|
1695
|
+
return normalize(
|
|
1696
|
+
expandBranchPickToGrain(selection, ceiling).filter(
|
|
1697
|
+
(c) => isLive(c) && ancestors(c).some((a) => ceil.has(a))
|
|
1698
|
+
)
|
|
1699
|
+
);
|
|
1700
|
+
};
|
|
1701
|
+
return {
|
|
1702
|
+
version: INFORMATION_SCOPE_VERSION,
|
|
1703
|
+
rows,
|
|
1704
|
+
row: (code) => byCode.get(code),
|
|
1705
|
+
childrenOf: (code) => [...kids(code)],
|
|
1706
|
+
ancestorsOf: (code) => [...ancestors(code)],
|
|
1707
|
+
isCovered,
|
|
1708
|
+
isIncludedOnShare: (selection, code, options) => shareVerdict(selection, code, options).included,
|
|
1709
|
+
shareVerdict,
|
|
1710
|
+
// Rule 7: the lowest internal viewing level that sees the row. Level 2
|
|
1711
|
+
// (autocomplete) sees the level-1 stub (§ 5). Sharing ignores this.
|
|
1712
|
+
isVisibleAtLevel: (level, code) => typeof level === "number" && isLive(code) && level >= byCode.get(code).levelFloor,
|
|
1713
|
+
expandSelectAll,
|
|
1714
|
+
selectAll,
|
|
1715
|
+
deselectChild,
|
|
1716
|
+
readSelection: (list, scopeVersion) => read(list, scopeVersion, SELECTION_PRECEDENCE, false),
|
|
1717
|
+
readRestriction: (list, scopeVersion) => read(list, scopeVersion, RESTRICTION_PRECEDENCE, true),
|
|
1718
|
+
rowForSubject,
|
|
1719
|
+
expandBranchPickToGrain,
|
|
1720
|
+
clampToCeiling
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
// src/services/informationScopeSot.ts
|
|
1725
|
+
var ROW_TYPES = /* @__PURE__ */ new Set([
|
|
1726
|
+
"branch",
|
|
1727
|
+
"category",
|
|
1728
|
+
"subcategory",
|
|
1729
|
+
"sub-category",
|
|
1730
|
+
"person_type",
|
|
1731
|
+
"category_rest",
|
|
1732
|
+
"instrument row"
|
|
1733
|
+
]);
|
|
1734
|
+
var KIND_BRANCHES = /* @__PURE__ */ new Set([
|
|
1735
|
+
"client",
|
|
1736
|
+
"offenders",
|
|
1737
|
+
"family",
|
|
1738
|
+
"others",
|
|
1739
|
+
"leads"
|
|
1740
|
+
]);
|
|
1741
|
+
var LIVE = /* @__PURE__ */ new Set(["as_today", "new"]);
|
|
1742
|
+
var MISSINGNESS_ROOT = "missingness_root";
|
|
1743
|
+
function keyReader(sot) {
|
|
1744
|
+
const byKey = new Map(sot.entries.map((e) => [e.key, e.canonicalCode ?? e.key]));
|
|
1745
|
+
return (key) => byKey.get(key) ?? key.replace(/__/g, ".");
|
|
1746
|
+
}
|
|
1747
|
+
function fail(key, field, value) {
|
|
1748
|
+
throw new TypeError(
|
|
1749
|
+
`information scope SOT: live entry "${key}" has ${field} ${JSON.stringify(value)}`
|
|
1750
|
+
);
|
|
1751
|
+
}
|
|
1752
|
+
function scopeRowsFromSot(sot) {
|
|
1753
|
+
const code = keyReader(sot);
|
|
1754
|
+
const missingness = new Set(
|
|
1755
|
+
sot.entries.filter((e) => e.key === MISSINGNESS_ROOT || e.parentKey === MISSINGNESS_ROOT).map((e) => e.key)
|
|
1756
|
+
);
|
|
1757
|
+
const rows = [];
|
|
1758
|
+
for (const e of sot.entries) {
|
|
1759
|
+
if (missingness.has(e.key)) continue;
|
|
1760
|
+
if (e.status === "retired") continue;
|
|
1761
|
+
if (e.status === void 0 || !LIVE.has(e.status)) fail(e.key, "status", e.status);
|
|
1762
|
+
if (e.rowType === void 0 || !ROW_TYPES.has(e.rowType)) fail(e.key, "rowType", e.rowType);
|
|
1763
|
+
const kindBranch = e.kindBranch ?? null;
|
|
1764
|
+
if (kindBranch !== null && !KIND_BRANCHES.has(kindBranch)) fail(e.key, "kindBranch", kindBranch);
|
|
1765
|
+
if (e.apps === void 0) fail(e.key, "apps", e.apps);
|
|
1766
|
+
for (const b of ["selectable", "shareableDefault", "platformFloor"]) {
|
|
1767
|
+
if (typeof e[b] !== "boolean") fail(e.key, b, e[b]);
|
|
1768
|
+
}
|
|
1769
|
+
if (e.levelFloor !== 1 && e.levelFloor !== 3) fail(e.key, "levelFloor", e.levelFloor);
|
|
1770
|
+
if (e.specialDataType === void 0) fail(e.key, "specialDataType", e.specialDataType);
|
|
1771
|
+
const row = {
|
|
1772
|
+
scopeCode: code(e.key),
|
|
1773
|
+
parentScopeCode: e.parentKey ? code(e.parentKey) : null,
|
|
1774
|
+
rowType: e.rowType,
|
|
1775
|
+
kindBranch,
|
|
1776
|
+
apps: { pave: e.apps.pave, thread: e.apps.thread, leads: e.apps.leads },
|
|
1777
|
+
selectable: e.selectable,
|
|
1778
|
+
shareableDefault: e.shareableDefault,
|
|
1779
|
+
platformFloor: e.platformFloor,
|
|
1780
|
+
levelFloor: e.levelFloor,
|
|
1781
|
+
specialDataType: e.specialDataType,
|
|
1782
|
+
status: e.status,
|
|
1783
|
+
replacesV3: [...e.replacesV3 ?? []]
|
|
1784
|
+
};
|
|
1785
|
+
if (e.kindRow !== void 0) row.kindRow = code(e.kindRow);
|
|
1786
|
+
rows.push(row);
|
|
1787
|
+
}
|
|
1788
|
+
return rows;
|
|
1789
|
+
}
|
|
1790
|
+
function scopeMigrationsFromSot(sot) {
|
|
1791
|
+
const code = keyReader(sot);
|
|
1792
|
+
return (sot.migrations?.table ?? []).map((l) => ({
|
|
1793
|
+
from: code(l.from),
|
|
1794
|
+
to: l.to.map(code),
|
|
1795
|
+
rule: l.rule,
|
|
1796
|
+
...l.note === void 0 ? {} : { note: l.note },
|
|
1797
|
+
...l.widens === void 0 ? {} : { widens: l.widens }
|
|
1798
|
+
}));
|
|
1799
|
+
}
|
|
1408
1800
|
export {
|
|
1409
1801
|
CvcRegistryService,
|
|
1802
|
+
INFORMATION_SCOPE_READABLE_VERSIONS,
|
|
1803
|
+
INFORMATION_SCOPE_SYSTEM_INFO,
|
|
1804
|
+
INFORMATION_SCOPE_VERSION,
|
|
1410
1805
|
applyEntryOverrides,
|
|
1411
1806
|
cascadeExclusions,
|
|
1807
|
+
createInformationScopeResolver,
|
|
1412
1808
|
cvcVersionsToRecord,
|
|
1413
|
-
|
|
1809
|
+
isScopeInstrumentRow,
|
|
1810
|
+
isScopeRestRow,
|
|
1811
|
+
isSelectableScopeRow,
|
|
1812
|
+
kindForPerson,
|
|
1813
|
+
resolveRegistryWithInheritance,
|
|
1814
|
+
scopeMigrationsFromSot,
|
|
1815
|
+
scopeRowsFromSot
|
|
1414
1816
|
};
|
|
1415
1817
|
//# sourceMappingURL=index.js.map
|