@htilabs/platform-common-models 0.20.0 → 0.21.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 +222 -120
- package/dist/cvcs/index.cjs.map +1 -1
- package/dist/cvcs/index.d.cts +223 -117
- package/dist/cvcs/index.d.ts +223 -117
- package/dist/cvcs/index.js +222 -120
- package/dist/cvcs/index.js.map +1 -1
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.cts +4 -4
- package/dist/enums/index.d.ts +4 -4
- package/dist/enums/index.js.map +1 -1
- package/dist/{index-I-DiX9eQ.d.ts → index-CDoqrfc1.d.ts} +1 -1
- package/dist/{index-CoVr1jIV.d.cts → index-Zu_mOJRn.d.cts} +1 -1
- package/dist/index.cjs +320 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +319 -137
- package/dist/index.js.map +1 -1
- package/dist/information-scope/index.cjs +98 -17
- package/dist/information-scope/index.cjs.map +1 -1
- package/dist/information-scope/index.d.cts +142 -13
- package/dist/information-scope/index.d.ts +142 -13
- package/dist/information-scope/index.js +97 -17
- package/dist/information-scope/index.js.map +1 -1
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/dist/services/index.cjs +98 -17
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +97 -17
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/cvc-sot.snap +2 -2
- package/src/__tests__/core-information-scope-invariant.test.ts +141 -15
- package/src/__tests__/cvc-sot-snapshot.test.ts +4 -3
- package/src/__tests__/cvc-structural.test.ts +2 -2
- package/src/__tests__/location-type-routing-invariant.test.ts +1 -1
- package/src/cvcs/{coreInformationScope.v2.0.0.json → coreInformationScope.v2.1.0.json} +190 -88
- package/src/cvcs/index.ts +2 -2
- package/src/cvcs/{roiScope.v1.3.0.json → roiScope.v1.4.0.json} +26 -26
- package/src/generated/cvc-enums.ts +4 -4
- package/src/services/__tests__/fixtures/infoscope-v4/information_scope_v3_placements.projection.csv +12 -0
- package/src/services/__tests__/fixtures/infoscope-v4/information_scope_v4.migrations.csv +27 -27
- package/src/services/__tests__/fixtures/infoscope-v4/information_scope_v4.rows.csv +1 -1
- package/src/services/__tests__/fixtures/infoscope-v4/loadInfoscopeV4Fixtures.ts +85 -14
- package/src/services/__tests__/informationScopeResolver.test.ts +336 -22
- package/src/services/informationScopeResolver.ts +226 -19
- package/src/services/informationScopeSot.ts +50 -8
- package/dist/{cvcEntry-BCj1OWqL.d.cts → cvcEntry-0BIB9sen.d.cts} +8 -8
- package/dist/{cvcEntry-BCj1OWqL.d.ts → cvcEntry-0BIB9sen.d.ts} +8 -8
|
@@ -1,5 +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.cjs';
|
|
2
|
+
export { CoreInformationScopeSot, CoreInformationScopeSotEntry, CoreInformationScopeSotMigrationLine, CreateInformationScopeResolverInput, INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE, INFORMATION_SCOPE_READABLE_VERSIONS, INFORMATION_SCOPE_SYSTEM_INFO, INFORMATION_SCOPE_VERSION, InformationScopeResolver, ScopeApp, ScopeApps, ScopeCodeReading, ScopeKindBranch, ScopeMigration, ScopeMigrationRule, ScopePersonKind, ScopeReadOptions, ScopeReading, ScopeReadingRule, ScopeReadingSubject, ScopeRetainedReading, ScopeRow, ScopeRowStatus, ScopeRowType, ScopeShareOptions, ScopeShareReason, ScopeShareVerdict, ScopeSpecialDataType, ScopeSubjectKind, StoredScopeList, createInformationScopeResolver, isScopeInstrumentRow, isScopeRestRow, isSelectableScopeRow, kindForPerson, scopeMigrationsFromSot, scopeRowsFromSot } from '../information-scope/index.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @htilabs/platform-common-models — CvcRegistryService
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,5 +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
|
+
export { CoreInformationScopeSot, CoreInformationScopeSotEntry, CoreInformationScopeSotMigrationLine, CreateInformationScopeResolverInput, INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE, INFORMATION_SCOPE_READABLE_VERSIONS, INFORMATION_SCOPE_SYSTEM_INFO, INFORMATION_SCOPE_VERSION, InformationScopeResolver, ScopeApp, ScopeApps, ScopeCodeReading, ScopeKindBranch, ScopeMigration, ScopeMigrationRule, ScopePersonKind, ScopeReadOptions, ScopeReading, ScopeReadingRule, ScopeReadingSubject, ScopeRetainedReading, ScopeRow, ScopeRowStatus, ScopeRowType, ScopeShareOptions, ScopeShareReason, ScopeShareVerdict, ScopeSpecialDataType, ScopeSubjectKind, StoredScopeList, createInformationScopeResolver, isScopeInstrumentRow, isScopeRestRow, isSelectableScopeRow, kindForPerson, scopeMigrationsFromSot, scopeRowsFromSot } from '../information-scope/index.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @htilabs/platform-common-models — CvcRegistryService
|
package/dist/services/index.js
CHANGED
|
@@ -1447,6 +1447,12 @@ var RESTRICTION_PRECEDENCE = [
|
|
|
1447
1447
|
"subtract",
|
|
1448
1448
|
...SELECTION_PRECEDENCE
|
|
1449
1449
|
];
|
|
1450
|
+
var READING_SUBJECTS = /* @__PURE__ */ new Set([
|
|
1451
|
+
"release",
|
|
1452
|
+
"share",
|
|
1453
|
+
"policy"
|
|
1454
|
+
]);
|
|
1455
|
+
var INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE = "Handoff \xA7 3: a policy is migrated with a new version row on the record, dated, so a Member Admin sees a change in history, not a silent rewrite. Write that row before acting on this reading; the stored list itself is never rewritten.";
|
|
1450
1456
|
var asList = (list) => Array.isArray(list) ? list : [];
|
|
1451
1457
|
function createInformationScopeResolver(input) {
|
|
1452
1458
|
const rows = Object.freeze([...input.rows]);
|
|
@@ -1541,16 +1547,34 @@ function createInformationScopeResolver(input) {
|
|
|
1541
1547
|
);
|
|
1542
1548
|
}
|
|
1543
1549
|
}
|
|
1550
|
+
if (m.releaseReading !== void 0 && m.releaseReading !== "retain" && m.releaseReading !== "successor") {
|
|
1551
|
+
throw new Error(`information scope: "${m.from}" has releaseReading "${String(m.releaseReading)}"`);
|
|
1552
|
+
}
|
|
1553
|
+
if (m.policyReading !== void 0 && m.policyReading !== "successor") {
|
|
1554
|
+
throw new Error(`information scope: "${m.from}" has policyReading "${String(m.policyReading)}"`);
|
|
1555
|
+
}
|
|
1556
|
+
if (m.releaseReading === "retain" && (m.to.length !== 1 || !Array.isArray(m.v3Fields) || !Array.isArray(m.v3Domains))) {
|
|
1557
|
+
throw new Error(
|
|
1558
|
+
`information scope: retained line "${m.from}" needs one successor and its v3Fields / v3Domains`
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1544
1561
|
const perCode = migrations.get(m.from) ?? /* @__PURE__ */ new Map();
|
|
1545
1562
|
const prior = perCode.get(m.rule);
|
|
1546
1563
|
if (prior && prior.to.join(" ") !== m.to.join(" ")) {
|
|
1547
1564
|
throw new Error(`information scope: two "${m.rule}" readings for "${m.from}"`);
|
|
1548
1565
|
}
|
|
1566
|
+
const retain = m.releaseReading === "retain" ? m : prior?.releaseReading === "retain" ? prior : null;
|
|
1549
1567
|
perCode.set(m.rule, {
|
|
1550
1568
|
from: m.from,
|
|
1551
1569
|
rule: m.rule,
|
|
1552
1570
|
to: Object.freeze([...m.to]),
|
|
1553
|
-
widens: m.widens === true || prior?.widens === true
|
|
1571
|
+
widens: m.widens === true || prior?.widens === true,
|
|
1572
|
+
...retain === null ? {} : {
|
|
1573
|
+
releaseReading: "retain",
|
|
1574
|
+
v3Fields: Object.freeze([...retain.v3Fields ?? []]),
|
|
1575
|
+
v3Domains: Object.freeze([...retain.v3Domains ?? []]),
|
|
1576
|
+
...retain.v3FieldsNote === void 0 ? {} : { v3FieldsNote: retain.v3FieldsNote }
|
|
1577
|
+
}
|
|
1554
1578
|
});
|
|
1555
1579
|
migrations.set(m.from, perCode);
|
|
1556
1580
|
}
|
|
@@ -1617,9 +1641,9 @@ function createInformationScopeResolver(input) {
|
|
|
1617
1641
|
for (const d of descendantsOf(childCode)) sel.delete(d);
|
|
1618
1642
|
return normalize(sel);
|
|
1619
1643
|
};
|
|
1620
|
-
const readOne = (from, scopeVersion, precedence) => {
|
|
1644
|
+
const readOne = (from, scopeVersion, precedence, keepsGrain) => {
|
|
1621
1645
|
if (scopeVersion === INFORMATION_SCOPE_VERSION && isLive(from)) {
|
|
1622
|
-
return { from, rule: "identity", reads: [from], widens: false };
|
|
1646
|
+
return { from, rule: "identity", reads: [from], widens: false, retained: false };
|
|
1623
1647
|
}
|
|
1624
1648
|
const lines = migrations.get(from);
|
|
1625
1649
|
if (lines) {
|
|
@@ -1628,21 +1652,39 @@ function createInformationScopeResolver(input) {
|
|
|
1628
1652
|
continue;
|
|
1629
1653
|
}
|
|
1630
1654
|
const line = lines.get(rule);
|
|
1631
|
-
if (line)
|
|
1655
|
+
if (!line) continue;
|
|
1656
|
+
if (keepsGrain && line.releaseReading === "retain") {
|
|
1657
|
+
return scopeVersion === 3 ? { from, rule, reads: [], widens: false, retained: true } : { from, rule, reads: [], widens: false, retained: false };
|
|
1658
|
+
}
|
|
1659
|
+
return { from, rule, reads: [...line.to], widens: line.widens === true, retained: false };
|
|
1632
1660
|
}
|
|
1633
1661
|
}
|
|
1634
|
-
return { from, rule: "unknown", reads: [], widens: false };
|
|
1662
|
+
return { from, rule: "unknown", reads: [], widens: false, retained: false };
|
|
1663
|
+
};
|
|
1664
|
+
const retainedOf = (c) => {
|
|
1665
|
+
const line = migrations.get(c.from)?.get(c.rule);
|
|
1666
|
+
return {
|
|
1667
|
+
code: c.from,
|
|
1668
|
+
v3Fields: [...line.v3Fields ?? []],
|
|
1669
|
+
v3Domains: [...line.v3Domains ?? []],
|
|
1670
|
+
successor: line.to[0],
|
|
1671
|
+
...line.v3FieldsNote === void 0 ? {} : { note: line.v3FieldsNote }
|
|
1672
|
+
};
|
|
1635
1673
|
};
|
|
1636
|
-
const read = (list, scopeVersion, precedence,
|
|
1674
|
+
const read = (list, scopeVersion, precedence, subject) => {
|
|
1675
|
+
const isRestriction = subject === null;
|
|
1676
|
+
const keepsGrain = subject === "release" || subject === "share";
|
|
1677
|
+
const isPolicyLike = subject === "policy" || isRestriction;
|
|
1637
1678
|
const stored = [...asList(list)];
|
|
1638
1679
|
const supported = typeof scopeVersion === "number" && INFORMATION_SCOPE_READABLE_VERSIONS.includes(scopeVersion);
|
|
1680
|
+
const versionRowRequired = isPolicyLike && supported && scopeVersion !== INFORMATION_SCOPE_VERSION;
|
|
1639
1681
|
const codes = [];
|
|
1640
1682
|
const seen = /* @__PURE__ */ new Set();
|
|
1641
1683
|
for (const from of stored) {
|
|
1642
1684
|
if (seen.has(from)) continue;
|
|
1643
1685
|
seen.add(from);
|
|
1644
1686
|
codes.push(
|
|
1645
|
-
supported ? readOne(from, scopeVersion, precedence) : { from, rule: "unknown", reads: [], widens: false }
|
|
1687
|
+
supported ? readOne(from, scopeVersion, precedence, keepsGrain) : { from, rule: "unknown", reads: [], widens: false, retained: false }
|
|
1646
1688
|
);
|
|
1647
1689
|
}
|
|
1648
1690
|
return {
|
|
@@ -1657,9 +1699,22 @@ function createInformationScopeResolver(input) {
|
|
|
1657
1699
|
codes,
|
|
1658
1700
|
retired: codes.filter((c) => RETIRED_RULES.has(c.rule)).map((c) => c.from),
|
|
1659
1701
|
unknown: codes.filter((c) => c.rule === "unknown").map((c) => c.from),
|
|
1660
|
-
widened: codes.filter((c) => c.widens).map((c) => c.from)
|
|
1702
|
+
widened: codes.filter((c) => c.widens).map((c) => c.from),
|
|
1703
|
+
subject,
|
|
1704
|
+
retained: codes.filter((c) => c.retained).map(retainedOf),
|
|
1705
|
+
versionRowRequired,
|
|
1706
|
+
note: versionRowRequired ? INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE : null
|
|
1661
1707
|
};
|
|
1662
1708
|
};
|
|
1709
|
+
const readSelection = (list, scopeVersion, options) => {
|
|
1710
|
+
const subject = options?.subject;
|
|
1711
|
+
if (subject === void 0 || !READING_SUBJECTS.has(subject)) {
|
|
1712
|
+
throw new TypeError(
|
|
1713
|
+
`information scope readSelection: options.subject must be "release", "share" or "policy" (got ${JSON.stringify(subject)}) \u2014 there is no default`
|
|
1714
|
+
);
|
|
1715
|
+
}
|
|
1716
|
+
return read(list, scopeVersion, SELECTION_PRECEDENCE, subject);
|
|
1717
|
+
};
|
|
1663
1718
|
const rowForSubject = (homeRow, kind) => {
|
|
1664
1719
|
const home = byCode.get(homeRow);
|
|
1665
1720
|
if (!home) throw new RangeError(`information scope rowForSubject: unknown home "${homeRow}"`);
|
|
@@ -1713,8 +1768,8 @@ function createInformationScopeResolver(input) {
|
|
|
1713
1768
|
expandSelectAll,
|
|
1714
1769
|
selectAll,
|
|
1715
1770
|
deselectChild,
|
|
1716
|
-
readSelection
|
|
1717
|
-
readRestriction: (list, scopeVersion) => read(list, scopeVersion, RESTRICTION_PRECEDENCE,
|
|
1771
|
+
readSelection,
|
|
1772
|
+
readRestriction: (list, scopeVersion) => read(list, scopeVersion, RESTRICTION_PRECEDENCE, null),
|
|
1718
1773
|
rowForSubject,
|
|
1719
1774
|
expandBranchPickToGrain,
|
|
1720
1775
|
clampToCeiling
|
|
@@ -1789,16 +1844,41 @@ function scopeRowsFromSot(sot) {
|
|
|
1789
1844
|
}
|
|
1790
1845
|
function scopeMigrationsFromSot(sot) {
|
|
1791
1846
|
const code = keyReader(sot);
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1847
|
+
const byKey = new Map(sot.entries.map((e) => [e.key, e]));
|
|
1848
|
+
return (sot.migrations?.table ?? []).map((l) => {
|
|
1849
|
+
const m = {
|
|
1850
|
+
from: code(l.from),
|
|
1851
|
+
to: l.to.map(code),
|
|
1852
|
+
rule: l.rule,
|
|
1853
|
+
...l.note === void 0 ? {} : { note: l.note },
|
|
1854
|
+
...l.widens === void 0 ? {} : { widens: l.widens },
|
|
1855
|
+
...l.informational === void 0 ? {} : { informational: l.informational },
|
|
1856
|
+
...l.policyReading === void 0 ? {} : { policyReading: l.policyReading }
|
|
1857
|
+
};
|
|
1858
|
+
if (l.releaseReading === void 0) return m;
|
|
1859
|
+
if (l.releaseReading !== "retain") {
|
|
1860
|
+
return {
|
|
1861
|
+
...m,
|
|
1862
|
+
releaseReading: l.releaseReading,
|
|
1863
|
+
...l.releaseReadingNote === void 0 ? {} : { releaseReadingNote: l.releaseReadingNote }
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
const e = byKey.get(l.from);
|
|
1867
|
+
if (e?.v3Fields === void 0 || e.v3Domains === void 0) {
|
|
1868
|
+
fail(l.from, "v3Fields / v3Domains (its line is releaseReading retain)", e?.v3Fields);
|
|
1869
|
+
}
|
|
1870
|
+
return {
|
|
1871
|
+
...m,
|
|
1872
|
+
releaseReading: l.releaseReading,
|
|
1873
|
+
v3Fields: [...e.v3Fields],
|
|
1874
|
+
v3Domains: [...e.v3Domains],
|
|
1875
|
+
...e.v3FieldsNote === void 0 ? {} : { v3FieldsNote: e.v3FieldsNote }
|
|
1876
|
+
};
|
|
1877
|
+
});
|
|
1799
1878
|
}
|
|
1800
1879
|
export {
|
|
1801
1880
|
CvcRegistryService,
|
|
1881
|
+
INFORMATION_SCOPE_POLICY_VERSION_ROW_NOTE,
|
|
1802
1882
|
INFORMATION_SCOPE_READABLE_VERSIONS,
|
|
1803
1883
|
INFORMATION_SCOPE_SYSTEM_INFO,
|
|
1804
1884
|
INFORMATION_SCOPE_VERSION,
|