@htilabs/platform-common-models 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/dist/{index-Dr6GBCoY.d.ts → index-ClTjjJ_S.d.ts} +1 -1
- package/dist/{index-BTqHP4DM.d.cts → index-Pt82NxQg.d.cts} +1 -1
- package/dist/index.cjs +457 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +437 -2
- package/dist/index.js.map +1 -1
- package/dist/information-scope/index.d.cts +3 -350
- package/dist/information-scope/index.d.ts +3 -350
- package/dist/informationScopeResolver-BzYu97DE.d.cts +351 -0
- package/dist/informationScopeResolver-BzYu97DE.d.ts +351 -0
- 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.d.cts +2 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/sharing-ceiling/index.cjs +497 -0
- package/dist/sharing-ceiling/index.cjs.map +1 -0
- package/dist/sharing-ceiling/index.d.cts +318 -0
- package/dist/sharing-ceiling/index.d.ts +318 -0
- package/dist/sharing-ceiling/index.js +451 -0
- package/dist/sharing-ceiling/index.js.map +1 -0
- package/package.json +7 -1
- package/src/__sot__/README.md +1 -0
- package/src/__sot__/sharingStarter.pin.json +229 -0
- package/src/__tests__/sharing-starter-canon.test.ts +178 -0
- package/src/generated/sharingPlatformStarter.ts +165 -0
- package/src/index.ts +5 -0
- package/src/sharingCeiling/__tests__/sharingCeiling.test.ts +678 -0
- package/src/sharingCeiling/chain.ts +269 -0
- package/src/sharingCeiling/coverage.ts +346 -0
- package/src/sharingCeiling/index.ts +14 -0
- package/src/sharingCeiling/starter.ts +89 -0
- package/dist/{cvcEntry-BqAGctqK.d.cts → cvcEntry-Asg7mxjB.d.cts} +8 -8
- package/dist/{cvcEntry-BqAGctqK.d.ts → cvcEntry-Asg7mxjB.d.ts} +8 -8
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
// src/generated/sharingPlatformStarter.ts
|
|
2
|
+
var SHARING_PLATFORM_STARTER_SOURCE = {
|
|
3
|
+
"monolith": {
|
|
4
|
+
"repo": "htilabstech/prototype",
|
|
5
|
+
"file": "HTI-LEADS-PAVE-Thread-prototype.html",
|
|
6
|
+
"sha": "d85f05b7",
|
|
7
|
+
"lines": [
|
|
8
|
+
326475,
|
|
9
|
+
326543
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"mirror": {
|
|
13
|
+
"repo": "htilabstech/platform-prototype",
|
|
14
|
+
"file": "src/data.js",
|
|
15
|
+
"sha": "a6f1f3a5",
|
|
16
|
+
"starterLines": [
|
|
17
|
+
38170,
|
|
18
|
+
38190
|
|
19
|
+
],
|
|
20
|
+
"purposeLines": [
|
|
21
|
+
32450,
|
|
22
|
+
32531
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"fieldPlacements": {
|
|
26
|
+
"repo": "htilabstech/prototype",
|
|
27
|
+
"file": "docs/share-roi/information_scope_v4.fields.csv",
|
|
28
|
+
"sha": "d85f05b7"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var SHARING_PLATFORM_STARTER_DATA = {
|
|
32
|
+
scopeVersion: 4,
|
|
33
|
+
scopeByPurpose: {
|
|
34
|
+
"referral": ["identifying", "contact", "services", "system", "summary_needs_assessment"],
|
|
35
|
+
"case_collaboration": ["identifying", "risk", "contact", "services", "notes", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "summary_needs_assessment"],
|
|
36
|
+
"deconfliction": ["identifying", "system"],
|
|
37
|
+
"mandatory_reporting": ["identifying", "risk", "contact", "services", "notes", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "summary_needs_assessment", "offenders.identifying", "offenders.risk", "relationships_household", "family"],
|
|
38
|
+
"discretionary_share": ["identifying", "system"],
|
|
39
|
+
"authority_reporting": ["identifying", "risk", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "offenders.identifying", "offenders.risk", "relationships_household", "family"],
|
|
40
|
+
"automatic_account_share": ["identifying", "system"],
|
|
41
|
+
"records_request": ["identifying", "system"]
|
|
42
|
+
},
|
|
43
|
+
counterpartyOverrides: {
|
|
44
|
+
"palomar": {
|
|
45
|
+
"case_collaboration": ["identifying", "risk", "contact", "services", "notes", "health_accommodation", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "summary_mental_health_screen", "summary_behavioral_health_intake", "summary_trauma_and_coping_screen", "summary_needs_assessment"]
|
|
46
|
+
},
|
|
47
|
+
"okcpd": {
|
|
48
|
+
"mandatory_reporting": ["identifying", "risk", "contact", "services", "notes", "system", "summary_initial_screen", "summary_lap", "summary_danger_assessment", "summary_stalking_assessment", "summary_injury_and_strangulation", "summary_ae_intake", "summary_tra", "summary_needs_assessment", "offenders.identifying", "offenders.risk", "relationships_household", "family"],
|
|
49
|
+
"referral": ["identifying", "contact", "services", "system", "summary_needs_assessment"]
|
|
50
|
+
},
|
|
51
|
+
"legal_aid_ok": {
|
|
52
|
+
"referral": ["identifying", "contact", "services", "notes", "system", "summary_needs_assessment"]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
purposeEnabled: {
|
|
56
|
+
"referral": true,
|
|
57
|
+
"case_collaboration": true,
|
|
58
|
+
"deconfliction": true,
|
|
59
|
+
"mandatory_reporting": true,
|
|
60
|
+
"discretionary_share": true,
|
|
61
|
+
"authority_reporting": true,
|
|
62
|
+
"automatic_account_share": true,
|
|
63
|
+
"records_request": false
|
|
64
|
+
},
|
|
65
|
+
fieldHomeRows: [
|
|
66
|
+
"accommodation_needs",
|
|
67
|
+
"ad_content",
|
|
68
|
+
"additional_ids",
|
|
69
|
+
"addresses",
|
|
70
|
+
"case_attachments",
|
|
71
|
+
"case_determinations",
|
|
72
|
+
"case_lifecycle",
|
|
73
|
+
"case_notes",
|
|
74
|
+
"commercial_activity",
|
|
75
|
+
"contact_info",
|
|
76
|
+
"demographics",
|
|
77
|
+
"derived_risk_signals",
|
|
78
|
+
"dob",
|
|
79
|
+
"encounter_location",
|
|
80
|
+
"family.health_accommodation",
|
|
81
|
+
"family.identifying",
|
|
82
|
+
"family.risk",
|
|
83
|
+
"full_ae_intake",
|
|
84
|
+
"full_behavioral_health_intake",
|
|
85
|
+
"full_danger_assessment",
|
|
86
|
+
"full_findings",
|
|
87
|
+
"full_hope_scale",
|
|
88
|
+
"full_ida",
|
|
89
|
+
"full_initial_screen",
|
|
90
|
+
"full_injury_and_strangulation",
|
|
91
|
+
"full_lap",
|
|
92
|
+
"full_mental_health_screen",
|
|
93
|
+
"full_needs_assessment",
|
|
94
|
+
"full_stalking_assessment",
|
|
95
|
+
"full_tra",
|
|
96
|
+
"full_trauma_and_coping_screen",
|
|
97
|
+
"health_status",
|
|
98
|
+
"identifying",
|
|
99
|
+
"immigration_applications",
|
|
100
|
+
"immigration_status",
|
|
101
|
+
"instruments",
|
|
102
|
+
"names",
|
|
103
|
+
"network_membership",
|
|
104
|
+
"object_identity_attributes",
|
|
105
|
+
"offenders.risk",
|
|
106
|
+
"others.risk",
|
|
107
|
+
"persona_links",
|
|
108
|
+
"phone_identifiers",
|
|
109
|
+
"plans_goals",
|
|
110
|
+
"priorities_safety",
|
|
111
|
+
"relationships_household",
|
|
112
|
+
"screen_indicators",
|
|
113
|
+
"service_history",
|
|
114
|
+
"session_summary",
|
|
115
|
+
"summary_ae_intake",
|
|
116
|
+
"summary_behavioral_health_intake",
|
|
117
|
+
"summary_danger_assessment",
|
|
118
|
+
"summary_findings",
|
|
119
|
+
"summary_hope_scale",
|
|
120
|
+
"summary_ida",
|
|
121
|
+
"summary_initial_screen",
|
|
122
|
+
"summary_injury_and_strangulation",
|
|
123
|
+
"summary_lap",
|
|
124
|
+
"summary_mental_health_screen",
|
|
125
|
+
"summary_needs_assessment",
|
|
126
|
+
"summary_stalking_assessment",
|
|
127
|
+
"summary_tra",
|
|
128
|
+
"summary_trauma_and_coping_screen",
|
|
129
|
+
"system",
|
|
130
|
+
"system_involvement",
|
|
131
|
+
"victimization"
|
|
132
|
+
]
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/sharingCeiling/starter.ts
|
|
136
|
+
var SHARING_CEILING_SCOPE_VERSION = 4;
|
|
137
|
+
function freezeLists(lists) {
|
|
138
|
+
const out = {};
|
|
139
|
+
for (const [purpose, codes] of Object.entries(lists)) out[purpose] = Object.freeze([...codes]);
|
|
140
|
+
return Object.freeze(out);
|
|
141
|
+
}
|
|
142
|
+
var HTI_SHARE_PLATFORM_STARTER = Object.freeze({
|
|
143
|
+
scopeVersion: SHARING_CEILING_SCOPE_VERSION,
|
|
144
|
+
scopeByPurpose: freezeLists(SHARING_PLATFORM_STARTER_DATA.scopeByPurpose),
|
|
145
|
+
counterpartyOverrides: Object.freeze(
|
|
146
|
+
Object.fromEntries(
|
|
147
|
+
Object.entries(SHARING_PLATFORM_STARTER_DATA.counterpartyOverrides).map(([cp, lists]) => [
|
|
148
|
+
cp,
|
|
149
|
+
freezeLists(lists)
|
|
150
|
+
])
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
});
|
|
154
|
+
var HTI_SHARE_PLATFORM_PURPOSE_ENABLED = Object.freeze({
|
|
155
|
+
...SHARING_PLATFORM_STARTER_DATA.purposeEnabled
|
|
156
|
+
});
|
|
157
|
+
var INFORMATION_SCOPE_FIELD_HOME_ROWS = new Set(
|
|
158
|
+
SHARING_PLATFORM_STARTER_DATA.fieldHomeRows
|
|
159
|
+
);
|
|
160
|
+
var HTI_SHARE_PLATFORM_STARTER_SOURCE = SHARING_PLATFORM_STARTER_SOURCE;
|
|
161
|
+
|
|
162
|
+
// src/sharingCeiling/chain.ts
|
|
163
|
+
var SHARING_CEILING_DEFAULT_ROW_KEY = "__default__";
|
|
164
|
+
var SHARING_CEILING_EXTERNAL_ROW_KEY = "__external__";
|
|
165
|
+
var own = (record, key) => record !== null && typeof record === "object" && Object.prototype.hasOwnProperty.call(record, key) ? record[key] : void 0;
|
|
166
|
+
var isStringList = (v) => Array.isArray(v) && v.every((c) => typeof c === "string");
|
|
167
|
+
function sharingCeilingCellList(cell) {
|
|
168
|
+
if (cell.scopeVersion === SHARING_CEILING_SCOPE_VERSION && isStringList(cell.informationScope)) {
|
|
169
|
+
return [...cell.informationScope];
|
|
170
|
+
}
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
var sameSet = (a, b) => {
|
|
174
|
+
const sa = new Set(a);
|
|
175
|
+
const sb = new Set(b);
|
|
176
|
+
return sa.size === sb.size && [...sa].every((c) => sb.has(c));
|
|
177
|
+
};
|
|
178
|
+
function sharingScopeEditsFromCells(cells) {
|
|
179
|
+
const byRow = /* @__PURE__ */ new Map();
|
|
180
|
+
if (cells === null || cells === void 0 || typeof cells[Symbol.iterator] !== "function") {
|
|
181
|
+
return {};
|
|
182
|
+
}
|
|
183
|
+
for (const cell of cells) {
|
|
184
|
+
if (cell === null || typeof cell !== "object") continue;
|
|
185
|
+
const { rowKey, purpose } = cell;
|
|
186
|
+
if (typeof rowKey !== "string" || rowKey === "" || typeof purpose !== "string" || purpose === "") continue;
|
|
187
|
+
const list = sharingCeilingCellList(cell);
|
|
188
|
+
const row = byRow.get(rowKey) ?? /* @__PURE__ */ new Map();
|
|
189
|
+
const prior = row.get(purpose);
|
|
190
|
+
row.set(purpose, prior === void 0 || sameSet(prior, list) ? list : []);
|
|
191
|
+
byRow.set(rowKey, row);
|
|
192
|
+
}
|
|
193
|
+
return Object.fromEntries([...byRow].map(([k, row]) => [k, Object.fromEntries(row)]));
|
|
194
|
+
}
|
|
195
|
+
function rungList(value) {
|
|
196
|
+
if (value === void 0 || value === null) return void 0;
|
|
197
|
+
return isStringList(value) ? [...value] : [];
|
|
198
|
+
}
|
|
199
|
+
function isSharingPurposeDisabled(purpose, purposeOverrides, purposeEnabled) {
|
|
200
|
+
const override = own(purposeOverrides, purpose);
|
|
201
|
+
if (override === false) return true;
|
|
202
|
+
const callerRow = own(purposeEnabled, purpose);
|
|
203
|
+
const enabled = typeof callerRow === "boolean" ? callerRow : own(HTI_SHARE_PLATFORM_PURPOSE_ENABLED, purpose);
|
|
204
|
+
return enabled === false && override !== true;
|
|
205
|
+
}
|
|
206
|
+
function sharingCeilingRowKey(recipient) {
|
|
207
|
+
if (recipient.external === true) return SHARING_CEILING_EXTERNAL_ROW_KEY;
|
|
208
|
+
const id = recipient.id;
|
|
209
|
+
if (typeof id !== "string" || id === "") {
|
|
210
|
+
throw new TypeError("sharing ceiling: an on-platform recipient needs a partner id");
|
|
211
|
+
}
|
|
212
|
+
if (id === SHARING_CEILING_DEFAULT_ROW_KEY || id === SHARING_CEILING_EXTERNAL_ROW_KEY) {
|
|
213
|
+
throw new RangeError(`sharing ceiling: "${id}" is a reserved row key, not a partner id`);
|
|
214
|
+
}
|
|
215
|
+
return id;
|
|
216
|
+
}
|
|
217
|
+
function effectiveCeiling(rowKey, purpose, inputs) {
|
|
218
|
+
if (typeof rowKey !== "string" || rowKey === "") {
|
|
219
|
+
throw new TypeError("sharing ceiling: rowKey must be a partner id or __external__");
|
|
220
|
+
}
|
|
221
|
+
if (rowKey === SHARING_CEILING_DEFAULT_ROW_KEY) {
|
|
222
|
+
throw new RangeError("sharing ceiling: __default__ is the account default, not a recipient row key");
|
|
223
|
+
}
|
|
224
|
+
if (typeof purpose !== "string" || purpose === "") {
|
|
225
|
+
throw new TypeError("sharing ceiling: purpose must be a share purpose code");
|
|
226
|
+
}
|
|
227
|
+
const starter = inputs.starter ?? HTI_SHARE_PLATFORM_STARTER;
|
|
228
|
+
if (isSharingPurposeDisabled(purpose, inputs.purposeOverrides, inputs.purposeEnabled)) {
|
|
229
|
+
return { allowed: [], rung: "purpose_disabled", disabled: true };
|
|
230
|
+
}
|
|
231
|
+
const edits = inputs.edits;
|
|
232
|
+
const rungs = [
|
|
233
|
+
["partner_rule", own(own(edits, rowKey), purpose)],
|
|
234
|
+
["seeded_partner_rule", own(own(starter.counterpartyOverrides, rowKey), purpose)],
|
|
235
|
+
["account_default", own(own(edits, SHARING_CEILING_DEFAULT_ROW_KEY), purpose)],
|
|
236
|
+
["platform_default", own(starter.scopeByPurpose, purpose)]
|
|
237
|
+
];
|
|
238
|
+
for (const [rung, value] of rungs) {
|
|
239
|
+
const allowed = rungList(value);
|
|
240
|
+
if (allowed !== void 0) return { allowed, rung, disabled: false };
|
|
241
|
+
}
|
|
242
|
+
return { allowed: [], rung: "none", disabled: false };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// src/services/informationScopeResolver.ts
|
|
246
|
+
var INFORMATION_SCOPE_READABLE_VERSIONS = Object.freeze([3, 4]);
|
|
247
|
+
var INFORMATION_SCOPE_SYSTEM_INFO = "system_info";
|
|
248
|
+
var SELECTION_PRECEDENCE = [
|
|
249
|
+
"category",
|
|
250
|
+
"identity",
|
|
251
|
+
"row",
|
|
252
|
+
"retired before v4"
|
|
253
|
+
];
|
|
254
|
+
var RESTRICTION_PRECEDENCE = [
|
|
255
|
+
"subtract",
|
|
256
|
+
...SELECTION_PRECEDENCE
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
// src/sharingCeiling/coverage.ts
|
|
260
|
+
var factsCache = /* @__PURE__ */ new WeakMap();
|
|
261
|
+
function memoize(fn) {
|
|
262
|
+
const memo = /* @__PURE__ */ new Map();
|
|
263
|
+
return (code) => {
|
|
264
|
+
if (memo.has(code)) return memo.get(code);
|
|
265
|
+
const out = fn(code);
|
|
266
|
+
memo.set(code, out);
|
|
267
|
+
return out;
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function treeFacts(scope) {
|
|
271
|
+
const hit = factsCache.get(scope);
|
|
272
|
+
if (hit) return hit;
|
|
273
|
+
const systemPath = scope.ancestorsOf(INFORMATION_SCOPE_SYSTEM_INFO);
|
|
274
|
+
const systemRoot = systemPath.length > 0 ? systemPath[systemPath.length - 1] : void 0;
|
|
275
|
+
const isLive = memoize(
|
|
276
|
+
(code) => scope.row(code) !== void 0 && scope.ancestorsOf(code).every((c) => scope.row(c)?.status !== "retired")
|
|
277
|
+
);
|
|
278
|
+
const isSystem = memoize(
|
|
279
|
+
(code) => systemRoot !== void 0 && scope.ancestorsOf(code).includes(systemRoot)
|
|
280
|
+
);
|
|
281
|
+
const underFloor = memoize(
|
|
282
|
+
(code) => scope.ancestorsOf(code).some((c) => scope.row(c)?.platformFloor === true)
|
|
283
|
+
);
|
|
284
|
+
const isCoverageRow = memoize((code) => isLive(code) && !isSystem(code) && !underFloor(code));
|
|
285
|
+
const coverageChildren = memoize(
|
|
286
|
+
(code) => Object.freeze(scope.childrenOf(code).filter(isCoverageRow))
|
|
287
|
+
);
|
|
288
|
+
const hasOwnContent = memoize((code) => {
|
|
289
|
+
const row = scope.row(code);
|
|
290
|
+
if (row === void 0) return false;
|
|
291
|
+
const homed = INFORMATION_SCOPE_FIELD_HOME_ROWS.has(code) || row.kindRow !== void 0 && INFORMATION_SCOPE_FIELD_HOME_ROWS.has(row.kindRow);
|
|
292
|
+
if (!homed) return false;
|
|
293
|
+
return !scope.childrenOf(code).some((c) => scope.row(c)?.rowType === "category_rest" && isLive(c));
|
|
294
|
+
});
|
|
295
|
+
const facts = {
|
|
296
|
+
isLive,
|
|
297
|
+
isSystem,
|
|
298
|
+
underFloor,
|
|
299
|
+
isCoverageRow,
|
|
300
|
+
coverageChildren,
|
|
301
|
+
hasOwnContent
|
|
302
|
+
};
|
|
303
|
+
factsCache.set(scope, facts);
|
|
304
|
+
return facts;
|
|
305
|
+
}
|
|
306
|
+
function asCeilingSet(allowed) {
|
|
307
|
+
if (allowed === null) return null;
|
|
308
|
+
if (allowed instanceof Set) return allowed;
|
|
309
|
+
if (Array.isArray(allowed)) {
|
|
310
|
+
return new Set(allowed.filter((c) => typeof c === "string"));
|
|
311
|
+
}
|
|
312
|
+
return /* @__PURE__ */ new Set();
|
|
313
|
+
}
|
|
314
|
+
function isCeilingCoverageRow(scope, code) {
|
|
315
|
+
return treeFacts(scope).isCoverageRow(code);
|
|
316
|
+
}
|
|
317
|
+
function hasOwnScopeContent(scope, code) {
|
|
318
|
+
return treeFacts(scope).hasOwnContent(code);
|
|
319
|
+
}
|
|
320
|
+
function ceilingCoverage(scope, allowed) {
|
|
321
|
+
const facts = treeFacts(scope);
|
|
322
|
+
const set = asCeilingSet(allowed);
|
|
323
|
+
const memo = /* @__PURE__ */ new Map();
|
|
324
|
+
const within = (code) => {
|
|
325
|
+
const hit = memo.get(code);
|
|
326
|
+
if (hit !== void 0) return hit;
|
|
327
|
+
let out;
|
|
328
|
+
if (!facts.isLive(code)) out = false;
|
|
329
|
+
else if (set === null) out = true;
|
|
330
|
+
else if (scope.ancestorsOf(code).some((c) => set.has(c))) out = true;
|
|
331
|
+
else if (facts.hasOwnContent(code)) out = false;
|
|
332
|
+
else {
|
|
333
|
+
const kids = facts.coverageChildren(code);
|
|
334
|
+
out = kids.length > 0 && kids.every(within);
|
|
335
|
+
}
|
|
336
|
+
memo.set(code, out);
|
|
337
|
+
return out;
|
|
338
|
+
};
|
|
339
|
+
return within;
|
|
340
|
+
}
|
|
341
|
+
function scopeRowWithinCeiling(scope, allowed, code) {
|
|
342
|
+
return ceilingCoverage(scope, allowed)(code);
|
|
343
|
+
}
|
|
344
|
+
function rowsOverCeiling(scope, declared, allowed) {
|
|
345
|
+
const facts = treeFacts(scope);
|
|
346
|
+
const within = ceilingCoverage(scope, allowed);
|
|
347
|
+
const out = [];
|
|
348
|
+
for (const code of new Set(Array.isArray(declared) ? declared : [])) {
|
|
349
|
+
if (code === INFORMATION_SCOPE_SYSTEM_INFO) continue;
|
|
350
|
+
if (!facts.isLive(code)) {
|
|
351
|
+
out.push(code);
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
if (facts.isSystem(code) || facts.underFloor(code)) continue;
|
|
355
|
+
if (!within(code)) out.push(code);
|
|
356
|
+
}
|
|
357
|
+
return out;
|
|
358
|
+
}
|
|
359
|
+
function walkCeiling(scope, allowed) {
|
|
360
|
+
const facts = treeFacts(scope);
|
|
361
|
+
if (asCeilingSet(allowed) === null) return { outside: [], expanded: [] };
|
|
362
|
+
const within = ceilingCoverage(scope, allowed);
|
|
363
|
+
const holdsMemo = /* @__PURE__ */ new Map();
|
|
364
|
+
const holdsWithin = (code) => {
|
|
365
|
+
const hit = holdsMemo.get(code);
|
|
366
|
+
if (hit !== void 0) return hit;
|
|
367
|
+
const out = scope.childrenOf(code).some((c) => facts.isCoverageRow(c) && within(c) || holdsWithin(c));
|
|
368
|
+
holdsMemo.set(code, out);
|
|
369
|
+
return out;
|
|
370
|
+
};
|
|
371
|
+
const outside = [];
|
|
372
|
+
const expanded = [];
|
|
373
|
+
const visit = (code) => {
|
|
374
|
+
if (!facts.isLive(code) || within(code)) return;
|
|
375
|
+
if (!holdsWithin(code)) {
|
|
376
|
+
outside.push(code);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
if (facts.hasOwnContent(code)) expanded.push(code);
|
|
380
|
+
for (const child of scope.childrenOf(code)) visit(child);
|
|
381
|
+
};
|
|
382
|
+
for (const r of scope.rows) {
|
|
383
|
+
if (r.parentScopeCode !== null && r.parentScopeCode !== "") continue;
|
|
384
|
+
if (facts.isSystem(r.scopeCode)) continue;
|
|
385
|
+
visit(r.scopeCode);
|
|
386
|
+
}
|
|
387
|
+
return { outside, expanded };
|
|
388
|
+
}
|
|
389
|
+
function rowsOutsideCeiling(scope, allowed) {
|
|
390
|
+
return walkCeiling(scope, allowed).outside;
|
|
391
|
+
}
|
|
392
|
+
function rowsExpandedByCeiling(scope, allowed) {
|
|
393
|
+
return walkCeiling(scope, allowed).expanded;
|
|
394
|
+
}
|
|
395
|
+
function withSystemInfo(codes) {
|
|
396
|
+
return [.../* @__PURE__ */ new Set([INFORMATION_SCOPE_SYSTEM_INFO, ...codes])];
|
|
397
|
+
}
|
|
398
|
+
function subtractRow(scope, selection, code) {
|
|
399
|
+
const path = scope.ancestorsOf(code);
|
|
400
|
+
let sel = selection.filter((c) => !scope.ancestorsOf(c).includes(code));
|
|
401
|
+
for (; ; ) {
|
|
402
|
+
const coverAt = path.findIndex((c, i) => i > 0 && sel.includes(c));
|
|
403
|
+
if (coverAt === -1) break;
|
|
404
|
+
sel = sel.filter((c) => c !== path[coverAt]);
|
|
405
|
+
for (let i = coverAt; i >= 1; i -= 1) {
|
|
406
|
+
const parent = path[i];
|
|
407
|
+
const onPath = path[i - 1];
|
|
408
|
+
for (const child of scope.childrenOf(parent)) {
|
|
409
|
+
if (child !== onPath && !sel.includes(child)) sel.push(child);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return sel;
|
|
414
|
+
}
|
|
415
|
+
function maskSelectionToCeiling(scope, selection, allowed) {
|
|
416
|
+
const facts = treeFacts(scope);
|
|
417
|
+
const { outside, expanded } = walkCeiling(scope, allowed);
|
|
418
|
+
let sel = (Array.isArray(selection) ? selection : []).filter(
|
|
419
|
+
(c) => typeof c === "string" && facts.isLive(c)
|
|
420
|
+
);
|
|
421
|
+
for (const code of expanded) {
|
|
422
|
+
if (!scope.ancestorsOf(code).some((c) => sel.includes(c))) continue;
|
|
423
|
+
sel = subtractRow(scope, sel, code);
|
|
424
|
+
for (const child of scope.childrenOf(code)) if (!sel.includes(child)) sel.push(child);
|
|
425
|
+
}
|
|
426
|
+
for (const code of outside) sel = subtractRow(scope, sel, code);
|
|
427
|
+
return withSystemInfo(sel.filter((c) => facts.isLive(c)));
|
|
428
|
+
}
|
|
429
|
+
export {
|
|
430
|
+
HTI_SHARE_PLATFORM_PURPOSE_ENABLED,
|
|
431
|
+
HTI_SHARE_PLATFORM_STARTER,
|
|
432
|
+
HTI_SHARE_PLATFORM_STARTER_SOURCE,
|
|
433
|
+
INFORMATION_SCOPE_FIELD_HOME_ROWS,
|
|
434
|
+
SHARING_CEILING_DEFAULT_ROW_KEY,
|
|
435
|
+
SHARING_CEILING_EXTERNAL_ROW_KEY,
|
|
436
|
+
SHARING_CEILING_SCOPE_VERSION,
|
|
437
|
+
ceilingCoverage,
|
|
438
|
+
effectiveCeiling,
|
|
439
|
+
hasOwnScopeContent,
|
|
440
|
+
isCeilingCoverageRow,
|
|
441
|
+
isSharingPurposeDisabled,
|
|
442
|
+
maskSelectionToCeiling,
|
|
443
|
+
rowsExpandedByCeiling,
|
|
444
|
+
rowsOutsideCeiling,
|
|
445
|
+
rowsOverCeiling,
|
|
446
|
+
scopeRowWithinCeiling,
|
|
447
|
+
sharingCeilingCellList,
|
|
448
|
+
sharingCeilingRowKey,
|
|
449
|
+
sharingScopeEditsFromCells
|
|
450
|
+
};
|
|
451
|
+
//# sourceMappingURL=index.js.map
|