@htilabs/platform-common-models 0.40.0 → 0.42.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 +149 -0
- package/dist/index.cjs +677 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +658 -0
- package/dist/index.js.map +1 -1
- package/dist/share-rules/index.cjs +822 -0
- package/dist/share-rules/index.cjs.map +1 -0
- package/dist/share-rules/index.d.cts +804 -0
- package/dist/share-rules/index.d.ts +804 -0
- package/dist/share-rules/index.js +736 -0
- package/dist/share-rules/index.js.map +1 -0
- package/dist/sharing-ceiling/index.cjs +679 -2
- package/dist/sharing-ceiling/index.cjs.map +1 -1
- package/dist/sharing-ceiling/index.d.cts +461 -1
- package/dist/sharing-ceiling/index.d.ts +461 -1
- package/dist/sharing-ceiling/index.js +659 -1
- package/dist/sharing-ceiling/index.js.map +1 -1
- package/package.json +6 -1
- package/src/shareRules/__tests__/caseShareLane.test.ts +259 -0
- package/src/shareRules/__tests__/magicLinkAddresses.test.ts +107 -0
- package/src/shareRules/__tests__/platformApps.test.ts +133 -0
- package/src/shareRules/__tests__/releaseTerms.test.ts +358 -0
- package/src/shareRules/__tests__/senderRoiPosture.test.ts +284 -0
- package/src/shareRules/__tests__/sharingMethods.test.ts +105 -0
- package/src/shareRules/caseShareLane.ts +289 -0
- package/src/shareRules/index.ts +31 -0
- package/src/shareRules/magicLinkAddresses.ts +185 -0
- package/src/shareRules/platformApps.ts +168 -0
- package/src/shareRules/releaseTerms.ts +359 -0
- package/src/shareRules/reportPurposes.ts +50 -0
- package/src/shareRules/senderRoiPosture.ts +296 -0
- package/src/shareRules/sharingMethods.ts +204 -0
- package/src/sharingCeiling/__tests__/resolveShare.test.ts +1305 -0
- package/src/sharingCeiling/__tests__/threadLift.test.ts +353 -0
- package/src/sharingCeiling/coverage.ts +63 -0
- package/src/sharingCeiling/defaults.ts +106 -0
- package/src/sharingCeiling/index.ts +13 -1
- package/src/sharingCeiling/resolve.ts +1278 -0
package/dist/index.cjs
CHANGED
|
@@ -270,6 +270,7 @@ __export(src_exports, {
|
|
|
270
270
|
GoalWithdrawalReasonKeys: () => GoalWithdrawalReasonKeys,
|
|
271
271
|
HEALTHCARE_ORG_TYPE_KEYS: () => HEALTHCARE_ORG_TYPE_KEYS,
|
|
272
272
|
HTI_SHARE_PLATFORM_PURPOSE_ENABLED: () => HTI_SHARE_PLATFORM_PURPOSE_ENABLED,
|
|
273
|
+
HTI_SHARE_PLATFORM_REQUIRED_BY_PURPOSE: () => HTI_SHARE_PLATFORM_REQUIRED_BY_PURPOSE,
|
|
273
274
|
HTI_SHARE_PLATFORM_STARTER: () => HTI_SHARE_PLATFORM_STARTER,
|
|
274
275
|
HTI_SHARE_PLATFORM_STARTER_SOURCE: () => HTI_SHARE_PLATFORM_STARTER_SOURCE,
|
|
275
276
|
HairColorKeys: () => HairColorKeys,
|
|
@@ -470,6 +471,10 @@ __export(src_exports, {
|
|
|
470
471
|
SERVICE_STATE_STAMP_CROSSWALK: () => SERVICE_STATE_STAMP_CROSSWALK,
|
|
471
472
|
SESSION_STATES: () => SESSION_STATES,
|
|
472
473
|
SESSION_STATE_LABELS: () => SESSION_STATE_LABELS,
|
|
474
|
+
SHARE_LEVEL_LABEL: () => SHARE_LEVEL_LABEL,
|
|
475
|
+
SHARE_PLATFORM_STATE_LABEL: () => SHARE_PLATFORM_STATE_LABEL,
|
|
476
|
+
SHARE_POSTURE_RANK: () => SHARE_POSTURE_RANK,
|
|
477
|
+
SHARE_REPORTING_PURPOSES: () => SHARE_REPORTING_PURPOSES,
|
|
473
478
|
SHARE_VIEW: () => SHARE_VIEW,
|
|
474
479
|
SHARE_VIEW_LABELS: () => SHARE_VIEW_LABELS,
|
|
475
480
|
SHARE_VIEW_VALUES: () => SHARE_VIEW_VALUES,
|
|
@@ -541,6 +546,7 @@ __export(src_exports, {
|
|
|
541
546
|
WHY_NOT_REPORTING_AXES: () => WHY_NOT_REPORTING_AXES,
|
|
542
547
|
WhyNotKeys: () => WhyNotKeys,
|
|
543
548
|
accommodationTypeSot: () => accommodationType_v1_0_0_default,
|
|
549
|
+
accountSharePurposePolicy: () => accountSharePurposePolicy,
|
|
544
550
|
actionStepCompletionStatusSot: () => actionStepCompletionStatus_v1_0_0_default,
|
|
545
551
|
actionStepTypeSot: () => actionStepType_v1_0_0_default,
|
|
546
552
|
activityTypeSot: () => activityType_v1_0_0_default,
|
|
@@ -561,6 +567,7 @@ __export(src_exports, {
|
|
|
561
567
|
applyRunValidatorsIfUnset: () => applyRunValidatorsIfUnset,
|
|
562
568
|
assertionDomainSot: () => assertionDomain_v1_1_0_default,
|
|
563
569
|
assertionStatusSot: () => assertionStatus_v2_0_0_default,
|
|
570
|
+
attachmentIndexFromPolicies: () => attachmentIndexFromPolicies,
|
|
564
571
|
basisQuickPicksSot: () => basisQuickPicks_v1_0_0_default,
|
|
565
572
|
buildCvcEntrySchema: () => buildCvcEntrySchema,
|
|
566
573
|
buildCvcRegistrySchema: () => buildCvcRegistrySchema,
|
|
@@ -618,6 +625,7 @@ __export(src_exports, {
|
|
|
618
625
|
daIncidentSeveritySot: () => daIncidentSeverity_v1_0_0_default,
|
|
619
626
|
demographicsSchema: () => demographicsSchema,
|
|
620
627
|
deriveAgeBinFromAge: () => deriveAgeBinFromAge,
|
|
628
|
+
derivePlatformDefault: () => derivePlatformDefault,
|
|
621
629
|
determinationHelperCategoriesSot: () => determinationHelperCategories_v1_0_0_default,
|
|
622
630
|
determinationLevelSot: () => determinationLevel_v1_0_0_default,
|
|
623
631
|
disabilitySubtypeSot: () => disabilitySubtype_v1_0_0_default,
|
|
@@ -683,6 +691,7 @@ __export(src_exports, {
|
|
|
683
691
|
incidentParticipationRolesSot: () => incidentParticipationRoles_v1_1_0_default,
|
|
684
692
|
incomeBenefitsSourcesSot: () => incomeBenefitsSources_v1_1_0_default,
|
|
685
693
|
inferenceTypeSot: () => inferenceType_v1_0_0_default,
|
|
694
|
+
intersectSharingCeilingLists: () => intersectSharingCeilingLists,
|
|
686
695
|
investigativeRequestTypeSot: () => investigativeRequestType_v1_0_0_default,
|
|
687
696
|
isAgencyTypeKey: () => isAgencyTypeKey,
|
|
688
697
|
isCanonEvaluableFunction: () => isCanonEvaluableFunction,
|
|
@@ -699,6 +708,7 @@ __export(src_exports, {
|
|
|
699
708
|
isLiveOrganizationProgram: () => isLiveOrganizationProgram,
|
|
700
709
|
isNeverPickableServiceMechanism: () => isNeverPickableServiceMechanism,
|
|
701
710
|
isOrgTypeKey: () => isOrgTypeKey,
|
|
711
|
+
isPermittedByCeiling: () => isPermittedByCeiling,
|
|
702
712
|
isProgramReviewStatus: () => isProgramReviewStatus,
|
|
703
713
|
isProtectedRelationship: () => isProtectedRelationship,
|
|
704
714
|
isReportAuthorityOrgType: () => isReportAuthorityOrgType,
|
|
@@ -717,10 +727,12 @@ __export(src_exports, {
|
|
|
717
727
|
layoutSchema: () => layoutSchema,
|
|
718
728
|
leReportStatusSot: () => leReportStatus_v1_0_0_default,
|
|
719
729
|
legalActionTypeSot: () => legalActionType_v1_0_0_default,
|
|
730
|
+
liveCategories: () => liveCategories,
|
|
720
731
|
livingSituationSot: () => livingSituation_v1_0_0_default,
|
|
721
732
|
locationTypeSot: () => locationType_v1_0_0_default,
|
|
722
733
|
maritalStatusLegalSot: () => maritalStatusLegal_v1_0_0_default,
|
|
723
734
|
maskSelectionToCeiling: () => maskSelectionToCeiling,
|
|
735
|
+
matchTeamRow: () => matchTeamRow,
|
|
724
736
|
mentalHealthStatusSot: () => mentalHealthStatus_v1_0_0_default,
|
|
725
737
|
messageReportReasonSot: () => messageReportReason_v1_0_0_default,
|
|
726
738
|
midStayEventTypeSot: () => midStayEventType_v1_0_0_default,
|
|
@@ -757,6 +769,7 @@ __export(src_exports, {
|
|
|
757
769
|
petExitReasonSot: () => petExitReason_v1_0_0_default,
|
|
758
770
|
petRelationshipBasisSot: () => petRelationshipBasis_v1_0_0_default,
|
|
759
771
|
phoneSchema: () => phoneSchema,
|
|
772
|
+
platformDefaultFor: () => platformDefaultFor,
|
|
760
773
|
platformFunctionModel: () => platformFunctionModel_exports,
|
|
761
774
|
platformFunctionSchemaDefinition: () => platformFunctionSchemaDefinition,
|
|
762
775
|
platformFunctionSchemaOptions: () => platformFunctionSchemaOptions,
|
|
@@ -797,6 +810,7 @@ __export(src_exports, {
|
|
|
797
810
|
resolveOrgTypeKeyFromLegacyNumeric: () => resolveOrgTypeKeyFromLegacyNumeric,
|
|
798
811
|
resolveReferralEntityKeyFromLegacyNumeric: () => resolveReferralEntityKeyFromLegacyNumeric,
|
|
799
812
|
resolveRegistryWithInheritance: () => resolveRegistryWithInheritance,
|
|
813
|
+
resolveShare: () => resolveShare,
|
|
800
814
|
returnedToAbuserStatusSot: () => returnedToAbuserStatus_v1_0_0_default,
|
|
801
815
|
riskCategorySot: () => riskCategory_v1_0_0_default,
|
|
802
816
|
riskIdentificationMilestoneSot: () => riskIdentificationMilestone_v1_0_0_default,
|
|
@@ -810,6 +824,8 @@ __export(src_exports, {
|
|
|
810
824
|
rowsOutsideCeiling: () => rowsOutsideCeiling,
|
|
811
825
|
rowsOverCeiling: () => rowsOverCeiling,
|
|
812
826
|
rsvpResponseSot: () => rsvpResponse_v1_0_0_default,
|
|
827
|
+
scopeListCovers: () => scopeListCovers,
|
|
828
|
+
scopeListStrictlyCovers: () => scopeListStrictlyCovers,
|
|
813
829
|
scopeMigrationsFromSot: () => scopeMigrationsFromSot,
|
|
814
830
|
scopeRowWithinCeiling: () => scopeRowWithinCeiling,
|
|
815
831
|
scopeRowsFromSot: () => scopeRowsFromSot,
|
|
@@ -842,8 +858,10 @@ __export(src_exports, {
|
|
|
842
858
|
severityFollowUpSot: () => severityFollowUp_v1_0_0_default,
|
|
843
859
|
sexProviderSubroleSot: () => sexProviderSubrole_v1_0_0_default,
|
|
844
860
|
shareCadenceSot: () => shareCadence_v1_0_0_default,
|
|
861
|
+
shareDefaultScopeFor: () => shareDefaultScopeFor,
|
|
845
862
|
sharePurposeSot: () => sharePurpose_v1_0_0_default,
|
|
846
863
|
shareResponseReasonSot: () => shareResponseReason_v1_0_0_default,
|
|
864
|
+
shareRowCeiling: () => shareRowCeiling,
|
|
847
865
|
sharingCeilingCellList: () => sharingCeilingCellList,
|
|
848
866
|
sharingCeilingRowKey: () => sharingCeilingRowKey,
|
|
849
867
|
sharingScopeEditsFromCells: () => sharingScopeEditsFromCells,
|
|
@@ -864,6 +882,7 @@ __export(src_exports, {
|
|
|
864
882
|
suggestionSourceSot: () => suggestionSource_v1_0_0_default,
|
|
865
883
|
supportStrengthSot: () => supportStrength_v1_0_0_default,
|
|
866
884
|
supportTopicSot: () => supportTopic_v1_0_0_default,
|
|
885
|
+
systemCategoryOf: () => systemCategoryOf,
|
|
867
886
|
teamDirectorySchemaDefinition: () => teamDirectorySchemaDefinition,
|
|
868
887
|
threadStatusSot: () => threadStatus_v1_0_0_default,
|
|
869
888
|
threadTypeSot: () => threadType_v1_0_0_default,
|
|
@@ -16602,6 +16621,645 @@ function maskSelectionToCeiling(scope, selection, allowed) {
|
|
|
16602
16621
|
for (const code of outside) sel = subtractRow(scope, sel, code);
|
|
16603
16622
|
return withSystemInfo(sel.filter((c) => facts.isLive(c)));
|
|
16604
16623
|
}
|
|
16624
|
+
function isPermittedByCeiling(scope, ceiling, code) {
|
|
16625
|
+
if (ceiling === null || ceiling.allowed === null) return true;
|
|
16626
|
+
if (scope.ancestorsOf(code).includes("system")) {
|
|
16627
|
+
return true;
|
|
16628
|
+
}
|
|
16629
|
+
if (scope.row(code) === void 0) return false;
|
|
16630
|
+
return scopeRowWithinCeiling(scope, ceiling.allowed, code);
|
|
16631
|
+
}
|
|
16632
|
+
function intersectSharingCeilingLists(scope, a, b) {
|
|
16633
|
+
const left = [...a];
|
|
16634
|
+
const right = [...b];
|
|
16635
|
+
const within = (list, code) => scopeRowWithinCeiling(scope, list, code);
|
|
16636
|
+
return [
|
|
16637
|
+
.../* @__PURE__ */ new Set([
|
|
16638
|
+
...left.filter((code) => within(right, code)),
|
|
16639
|
+
...right.filter((code) => within(left, code))
|
|
16640
|
+
])
|
|
16641
|
+
];
|
|
16642
|
+
}
|
|
16643
|
+
|
|
16644
|
+
// src/sharingCeiling/defaults.ts
|
|
16645
|
+
function shareDefaultScopeFor(edits, purpose, opts = {}) {
|
|
16646
|
+
const off = isSharingPurposeDisabled(purpose, opts.purposeOverrides ?? null);
|
|
16647
|
+
if (off || edits === null || edits === void 0) {
|
|
16648
|
+
return { off, accountDefault: [] };
|
|
16649
|
+
}
|
|
16650
|
+
const starter = opts.starter ?? HTI_SHARE_PLATFORM_STARTER;
|
|
16651
|
+
const authored = edits[SHARING_CEILING_DEFAULT_ROW_KEY]?.[purpose];
|
|
16652
|
+
if (Array.isArray(authored)) {
|
|
16653
|
+
return {
|
|
16654
|
+
off,
|
|
16655
|
+
accountDefault: authored.filter(
|
|
16656
|
+
(v) => typeof v === "string"
|
|
16657
|
+
)
|
|
16658
|
+
};
|
|
16659
|
+
}
|
|
16660
|
+
const platform = starter.scopeByPurpose[purpose];
|
|
16661
|
+
return {
|
|
16662
|
+
off,
|
|
16663
|
+
accountDefault: Array.isArray(platform) ? platform.filter((v) => typeof v === "string") : []
|
|
16664
|
+
};
|
|
16665
|
+
}
|
|
16666
|
+
var accountSharePurposePolicy = shareDefaultScopeFor;
|
|
16667
|
+
|
|
16668
|
+
// src/sharingCeiling/resolve.ts
|
|
16669
|
+
var SHARE_REPORTING_PURPOSES = /* @__PURE__ */ new Set([
|
|
16670
|
+
"mandatory_reporting",
|
|
16671
|
+
"authority_reporting"
|
|
16672
|
+
]);
|
|
16673
|
+
var SHARE_POSTURE_RANK = Object.freeze({
|
|
16674
|
+
open: 0,
|
|
16675
|
+
approval: 1,
|
|
16676
|
+
blocked: 2
|
|
16677
|
+
});
|
|
16678
|
+
var SHARE_PLATFORM_STATE_LABEL = Object.freeze({
|
|
16679
|
+
always: "Required",
|
|
16680
|
+
default_on: "Default On",
|
|
16681
|
+
default_off: "Default Off",
|
|
16682
|
+
never: "Blocked"
|
|
16683
|
+
});
|
|
16684
|
+
var SHARE_LEVEL_LABEL = Object.freeze({
|
|
16685
|
+
team_row: "attached on the team-to-team row",
|
|
16686
|
+
relationship: "attached to this relationship",
|
|
16687
|
+
agency_default: "your account's default for this purpose",
|
|
16688
|
+
account_internal: "your account's default for sharing between its own teams",
|
|
16689
|
+
team: "your account's rule for this team",
|
|
16690
|
+
platform_starter: "Platform default",
|
|
16691
|
+
inside_starter: "the platform's default for sharing inside your account"
|
|
16692
|
+
});
|
|
16693
|
+
var own3 = (record, key) => record !== null && typeof record === "object" && Object.prototype.hasOwnProperty.call(record, key) ? record[key] : void 0;
|
|
16694
|
+
var isStringList2 = (v) => Array.isArray(v) && v.every((c) => typeof c === "string");
|
|
16695
|
+
var versionOf = (v) => {
|
|
16696
|
+
const n = typeof v === "number" ? v : parseInt(String(v), 10);
|
|
16697
|
+
return Number.isFinite(n) && n > 0 ? Math.trunc(n) : 1;
|
|
16698
|
+
};
|
|
16699
|
+
var docList = (v) => v === null || v === void 0 ? null : isStringList2(v) ? [...v] : [];
|
|
16700
|
+
function scopeListCovers(scope, list, categoryCode, rowCode) {
|
|
16701
|
+
if (!Array.isArray(list)) return true;
|
|
16702
|
+
const set = new Set(list);
|
|
16703
|
+
if (scope.ancestorsOf(categoryCode).some((c) => set.has(c))) return true;
|
|
16704
|
+
if (rowCode !== void 0)
|
|
16705
|
+
return scope.ancestorsOf(rowCode).some((c) => set.has(c));
|
|
16706
|
+
return list.some(
|
|
16707
|
+
(id) => scope.ancestorsOf(id).slice(1).includes(categoryCode)
|
|
16708
|
+
);
|
|
16709
|
+
}
|
|
16710
|
+
function scopeListStrictlyCovers(scope, list, categoryCode) {
|
|
16711
|
+
if (!Array.isArray(list)) return true;
|
|
16712
|
+
const set = new Set(list);
|
|
16713
|
+
return scope.ancestorsOf(categoryCode).some((c) => set.has(c));
|
|
16714
|
+
}
|
|
16715
|
+
var isLiveDoc = (p) => p !== null && typeof p === "object" && typeof p.id === "string" && p.id !== "" && typeof p.purpose === "string" && p.active !== false;
|
|
16716
|
+
function attachmentIndexFromPolicies(policies) {
|
|
16717
|
+
const nullMap = () => /* @__PURE__ */ Object.create(null);
|
|
16718
|
+
const agencyDefaults = nullMap();
|
|
16719
|
+
const internalDefaults = nullMap();
|
|
16720
|
+
const relationships = nullMap();
|
|
16721
|
+
const teamRows = nullMap();
|
|
16722
|
+
const teams = nullMap();
|
|
16723
|
+
const put = (map, key, purpose, id) => {
|
|
16724
|
+
const row = Object.prototype.hasOwnProperty.call(map, key) ? map[key] : map[key] = nullMap();
|
|
16725
|
+
row[purpose] = id;
|
|
16726
|
+
};
|
|
16727
|
+
for (const p of Array.isArray(policies) ? policies : []) {
|
|
16728
|
+
if (!isLiveDoc(p)) continue;
|
|
16729
|
+
for (const a of Array.isArray(p.assignments) ? p.assignments : []) {
|
|
16730
|
+
if (a === null || typeof a !== "object") continue;
|
|
16731
|
+
switch (a.scope) {
|
|
16732
|
+
case "account":
|
|
16733
|
+
agencyDefaults[p.purpose] = p.id;
|
|
16734
|
+
break;
|
|
16735
|
+
case "account_internal":
|
|
16736
|
+
internalDefaults[p.purpose] = p.id;
|
|
16737
|
+
break;
|
|
16738
|
+
case "account_partner":
|
|
16739
|
+
if (typeof a.partnerId === "string" && a.partnerId !== "")
|
|
16740
|
+
put(relationships, a.partnerId, p.purpose, p.id);
|
|
16741
|
+
break;
|
|
16742
|
+
case "team":
|
|
16743
|
+
if (typeof a.teamId === "string" && a.teamId !== "")
|
|
16744
|
+
put(teams, a.teamId, p.purpose, p.id);
|
|
16745
|
+
break;
|
|
16746
|
+
case "team_pair":
|
|
16747
|
+
if (typeof a.teamRowId === "string" && a.teamRowId !== "")
|
|
16748
|
+
put(teamRows, a.teamRowId, p.purpose, p.id);
|
|
16749
|
+
break;
|
|
16750
|
+
default:
|
|
16751
|
+
break;
|
|
16752
|
+
}
|
|
16753
|
+
}
|
|
16754
|
+
}
|
|
16755
|
+
return { agencyDefaults, internalDefaults, relationships, teamRows, teams };
|
|
16756
|
+
}
|
|
16757
|
+
function matchTeamRow(rows, teamId, recipient, options = {}) {
|
|
16758
|
+
if (typeof teamId !== "string" || teamId === "" || !Array.isArray(rows))
|
|
16759
|
+
return null;
|
|
16760
|
+
const drop = new Set(options.shareBackOnlyRowIds ?? []);
|
|
16761
|
+
const live = rows.filter(
|
|
16762
|
+
(r) => r !== null && typeof r === "object" && typeof r.id === "string" && !drop.has(r.id)
|
|
16763
|
+
);
|
|
16764
|
+
if (recipient.kind === "sibling_team") {
|
|
16765
|
+
return live.find(
|
|
16766
|
+
(r) => r.myTeamId === teamId && r.their?.id === recipient.teamId
|
|
16767
|
+
)?.id ?? null;
|
|
16768
|
+
}
|
|
16769
|
+
if (recipient.kind === "external") return null;
|
|
16770
|
+
if (options.scopeMode === "team_scoped")
|
|
16771
|
+
return live.find((r) => r.myTeamId === teamId)?.id ?? null;
|
|
16772
|
+
return live.find(
|
|
16773
|
+
(r) => r.myTeamId === teamId && (!r.their || r.their.type !== "team" || r.their.id === recipient.id)
|
|
16774
|
+
)?.id ?? null;
|
|
16775
|
+
}
|
|
16776
|
+
function derivePlatformDefault(scope, purpose, seedList, options = {}) {
|
|
16777
|
+
const seed = isStringList2(seedList) ? [...seedList] : [];
|
|
16778
|
+
const req = new Set(options.required ?? []);
|
|
16779
|
+
const states = {};
|
|
16780
|
+
const required = [];
|
|
16781
|
+
const blocked = [];
|
|
16782
|
+
const systemCode = systemCategoryOf(scope);
|
|
16783
|
+
for (const g of liveCategories(scope)) {
|
|
16784
|
+
let state;
|
|
16785
|
+
if (g === systemCode) state = "always";
|
|
16786
|
+
else if (req.has(g)) state = "always";
|
|
16787
|
+
else if (scope.row(g)?.shareableDefault === false) state = "never";
|
|
16788
|
+
else state = scopeListCovers(scope, seed, g) ? "default_on" : "default_off";
|
|
16789
|
+
const bound = own3(options.bounds, g);
|
|
16790
|
+
if (g !== systemCode && (bound === "always" || bound === "default_on" || bound === "default_off" || bound === "never"))
|
|
16791
|
+
state = bound;
|
|
16792
|
+
states[g] = state;
|
|
16793
|
+
if (state === "always" && g !== systemCode) required.push(g);
|
|
16794
|
+
if (state === "never") blocked.push(g);
|
|
16795
|
+
}
|
|
16796
|
+
const categoryOf = (code) => scope.ancestorsOf(code).find((c) => scope.row(c)?.rowType === "category");
|
|
16797
|
+
const raw = [];
|
|
16798
|
+
const push = (c) => {
|
|
16799
|
+
if (!raw.includes(c)) raw.push(c);
|
|
16800
|
+
};
|
|
16801
|
+
for (const code of seed) {
|
|
16802
|
+
const g = categoryOf(code);
|
|
16803
|
+
if (g === void 0) {
|
|
16804
|
+
for (const [cat, st2] of Object.entries(states)) {
|
|
16805
|
+
if ((st2 === "always" || st2 === "default_on") && scope.ancestorsOf(cat).includes(code))
|
|
16806
|
+
push(cat);
|
|
16807
|
+
}
|
|
16808
|
+
continue;
|
|
16809
|
+
}
|
|
16810
|
+
const st = states[g];
|
|
16811
|
+
if (st === "never" || st === "default_off") continue;
|
|
16812
|
+
push(code);
|
|
16813
|
+
}
|
|
16814
|
+
for (const [g, st] of Object.entries(states)) {
|
|
16815
|
+
if ((st === "always" || st === "default_on") && !scopeListCovers(scope, raw, g))
|
|
16816
|
+
push(g);
|
|
16817
|
+
}
|
|
16818
|
+
if (systemCode !== void 0) push(systemCode);
|
|
16819
|
+
return {
|
|
16820
|
+
purpose,
|
|
16821
|
+
version: versionOf(options.version),
|
|
16822
|
+
raw,
|
|
16823
|
+
states,
|
|
16824
|
+
required,
|
|
16825
|
+
blocked,
|
|
16826
|
+
edited: options.edited === true
|
|
16827
|
+
};
|
|
16828
|
+
}
|
|
16829
|
+
var treeCache = /* @__PURE__ */ new WeakMap();
|
|
16830
|
+
function treeIndex(scope) {
|
|
16831
|
+
const hit = treeCache.get(scope);
|
|
16832
|
+
if (hit) return hit;
|
|
16833
|
+
const live = (code) => scope.row(code) !== void 0 && scope.ancestorsOf(code).every((c) => scope.row(c)?.status !== "retired");
|
|
16834
|
+
const categories = scope.rows.filter((r) => r.rowType === "category" && live(r.scopeCode)).map((r) => r.scopeCode);
|
|
16835
|
+
const systemInfoPath = scope.row("system_info") !== void 0 ? scope.ancestorsOf("system_info") : [];
|
|
16836
|
+
const system = systemInfoPath.find((c) => categories.includes(c)) ?? categories.find((g) => g === "system");
|
|
16837
|
+
const descendants = /* @__PURE__ */ new Map();
|
|
16838
|
+
const leaves = /* @__PURE__ */ new Map();
|
|
16839
|
+
for (const g of categories) {
|
|
16840
|
+
const all = [];
|
|
16841
|
+
const walk = (code) => {
|
|
16842
|
+
for (const c of scope.childrenOf(code)) {
|
|
16843
|
+
if (!live(c)) continue;
|
|
16844
|
+
all.push(c);
|
|
16845
|
+
walk(c);
|
|
16846
|
+
}
|
|
16847
|
+
};
|
|
16848
|
+
walk(g);
|
|
16849
|
+
descendants.set(g, all);
|
|
16850
|
+
leaves.set(
|
|
16851
|
+
g,
|
|
16852
|
+
all.filter((c) => !scope.childrenOf(c).some(live))
|
|
16853
|
+
);
|
|
16854
|
+
}
|
|
16855
|
+
const out = { categories, system, leaves, descendants };
|
|
16856
|
+
treeCache.set(scope, out);
|
|
16857
|
+
return out;
|
|
16858
|
+
}
|
|
16859
|
+
function liveCategories(scope) {
|
|
16860
|
+
return [...treeIndex(scope).categories];
|
|
16861
|
+
}
|
|
16862
|
+
function systemCategoryOf(scope) {
|
|
16863
|
+
return treeIndex(scope).system;
|
|
16864
|
+
}
|
|
16865
|
+
function legacyCeilingList(v) {
|
|
16866
|
+
if (v === null || v === void 0) return null;
|
|
16867
|
+
if (isStringList2(v)) return [...v];
|
|
16868
|
+
if (typeof v === "object" && "rung" in v) {
|
|
16869
|
+
const r = v.rung;
|
|
16870
|
+
if (r === "partner_rule" || r === "seeded_partner_rule" || r === "account_default") {
|
|
16871
|
+
return isStringList2(v.allowed) ? [...v.allowed] : [];
|
|
16872
|
+
}
|
|
16873
|
+
return null;
|
|
16874
|
+
}
|
|
16875
|
+
return null;
|
|
16876
|
+
}
|
|
16877
|
+
var HTI_SHARE_PLATFORM_REQUIRED_BY_PURPOSE = Object.freeze({
|
|
16878
|
+
mandatory_reporting: Object.freeze(["identifying"]),
|
|
16879
|
+
authority_reporting: Object.freeze(["identifying"])
|
|
16880
|
+
});
|
|
16881
|
+
function platformDefaultFor(scope, purpose, options = {}) {
|
|
16882
|
+
const starter = options.starter ?? HTI_SHARE_PLATFORM_STARTER;
|
|
16883
|
+
const seed = own3(starter.scopeByPurpose, purpose);
|
|
16884
|
+
if (!isStringList2(seed)) return null;
|
|
16885
|
+
return derivePlatformDefault(scope, purpose, seed, {
|
|
16886
|
+
required: own3(HTI_SHARE_PLATFORM_REQUIRED_BY_PURPOSE, purpose) ?? [],
|
|
16887
|
+
bounds: options.bounds ?? null,
|
|
16888
|
+
version: options.version ?? 1,
|
|
16889
|
+
edited: options.edited === true
|
|
16890
|
+
});
|
|
16891
|
+
}
|
|
16892
|
+
function shareRowCeiling(resolution, scope) {
|
|
16893
|
+
if (!resolution.allowed) return [];
|
|
16894
|
+
const out = [];
|
|
16895
|
+
for (const g of resolution.allowedCategories) {
|
|
16896
|
+
const e = own3(resolution.scope, g);
|
|
16897
|
+
if (e === void 0) continue;
|
|
16898
|
+
const withheld = /* @__PURE__ */ new Set([
|
|
16899
|
+
...e.excludedItems,
|
|
16900
|
+
...e.teamExcludedItems,
|
|
16901
|
+
...e.floorItems
|
|
16902
|
+
]);
|
|
16903
|
+
if (withheld.size === 0) {
|
|
16904
|
+
out.push(g);
|
|
16905
|
+
continue;
|
|
16906
|
+
}
|
|
16907
|
+
const live = (c) => scope.row(c) !== void 0 && scope.ancestorsOf(c).every((a) => scope.row(a)?.status !== "retired");
|
|
16908
|
+
const anyWithheldBeneath = (c) => scope.childrenOf(c).some((k) => live(k) && (withheld.has(k) || anyWithheldBeneath(k)));
|
|
16909
|
+
const visit = (c) => {
|
|
16910
|
+
if (withheld.has(c) || !live(c)) return;
|
|
16911
|
+
if (!anyWithheldBeneath(c)) {
|
|
16912
|
+
out.push(c);
|
|
16913
|
+
return;
|
|
16914
|
+
}
|
|
16915
|
+
for (const k of scope.childrenOf(c)) visit(k);
|
|
16916
|
+
};
|
|
16917
|
+
for (const k of scope.childrenOf(g)) visit(k);
|
|
16918
|
+
}
|
|
16919
|
+
return out;
|
|
16920
|
+
}
|
|
16921
|
+
function named(h) {
|
|
16922
|
+
const p = h.policy;
|
|
16923
|
+
return {
|
|
16924
|
+
id: p.id,
|
|
16925
|
+
familyId: typeof p.familyId === "string" && p.familyId !== "" ? p.familyId : p.id,
|
|
16926
|
+
name: typeof p.name === "string" ? p.name : p.id,
|
|
16927
|
+
version: h.version,
|
|
16928
|
+
level: h.level,
|
|
16929
|
+
levelLabel: SHARE_LEVEL_LABEL[h.level],
|
|
16930
|
+
posture: p.posture === "open" || p.posture === "approval" || p.posture === "blocked" ? p.posture : null,
|
|
16931
|
+
infoScope: docList(p.infoScope),
|
|
16932
|
+
infoScopeItems: copyItems(p.infoScopeItems),
|
|
16933
|
+
edited: p.edited === true,
|
|
16934
|
+
origin: typeof p.origin?.kind === "string" ? p.origin.kind : null,
|
|
16935
|
+
rulePath: h.rulePath
|
|
16936
|
+
};
|
|
16937
|
+
}
|
|
16938
|
+
var uniq = (list) => [...new Set(list)];
|
|
16939
|
+
var copyItems = (v) => {
|
|
16940
|
+
if (v === null || typeof v !== "object") return null;
|
|
16941
|
+
const out = {};
|
|
16942
|
+
for (const [k, rows] of Object.entries(v)) {
|
|
16943
|
+
if (isStringList2(rows)) out[k] = [...rows];
|
|
16944
|
+
}
|
|
16945
|
+
return out;
|
|
16946
|
+
};
|
|
16947
|
+
function resolveShare(input) {
|
|
16948
|
+
const { scope, purpose, recipient } = input;
|
|
16949
|
+
if (typeof purpose !== "string" || purpose === "")
|
|
16950
|
+
throw new TypeError("resolveShare: purpose must be a share purpose code");
|
|
16951
|
+
const teamId = typeof input.sender?.teamId === "string" && input.sender.teamId !== "" ? input.sender.teamId : null;
|
|
16952
|
+
const inside = recipient.kind === "sibling_team";
|
|
16953
|
+
const recipientKey = recipient.kind === "partner" ? recipient.id : recipient.kind === "external" ? "__external__" : null;
|
|
16954
|
+
if (recipient.kind === "partner" && (typeof recipient.id !== "string" || recipient.id === "")) {
|
|
16955
|
+
throw new TypeError("resolveShare: a partner recipient needs an id");
|
|
16956
|
+
}
|
|
16957
|
+
const report = SHARE_REPORTING_PURPOSES.has(purpose);
|
|
16958
|
+
const pd = input.platformDefault ?? null;
|
|
16959
|
+
const purposeLabel = typeof input.purposeLabel === "string" && input.purposeLabel !== "" ? input.purposeLabel : purpose;
|
|
16960
|
+
const pdRaw = pd === null ? [] : isStringList2(pd.raw) ? [...pd.raw] : [];
|
|
16961
|
+
const pdRequired = pd === null ? [] : isStringList2(pd.required) ? [...pd.required] : [];
|
|
16962
|
+
const pdBlocked = pd === null ? [] : isStringList2(pd.blocked) ? [...pd.blocked] : [];
|
|
16963
|
+
const policies = (Array.isArray(input.policies) ? input.policies : []).filter(
|
|
16964
|
+
isLiveDoc
|
|
16965
|
+
);
|
|
16966
|
+
const byId = /* @__PURE__ */ new Map();
|
|
16967
|
+
for (const p of policies) byId.set(p.id, p);
|
|
16968
|
+
const att = attachmentIndexFromPolicies(policies);
|
|
16969
|
+
const tree = treeIndex(scope);
|
|
16970
|
+
const systemCode = tree.system;
|
|
16971
|
+
const hit = (id, level2) => {
|
|
16972
|
+
const p = id === void 0 ? void 0 : byId.get(id);
|
|
16973
|
+
if (p === void 0 || p.purpose !== purpose) return null;
|
|
16974
|
+
if (p.trigger?.answers === "received") return null;
|
|
16975
|
+
const v = versionOf(p.version);
|
|
16976
|
+
const name = typeof p.name === "string" ? p.name : p.id;
|
|
16977
|
+
return {
|
|
16978
|
+
policy: p,
|
|
16979
|
+
level: level2,
|
|
16980
|
+
version: v,
|
|
16981
|
+
rulePath: `sharingPurposePolicies[${p.id}] v${v} (policy \u201C${name}\u201D \u2014 ${SHARE_LEVEL_LABEL[level2]})`
|
|
16982
|
+
};
|
|
16983
|
+
};
|
|
16984
|
+
const cell = (map, key) => own3(own3(map, key), purpose);
|
|
16985
|
+
let gov = null;
|
|
16986
|
+
const purposeKnown = pd !== null;
|
|
16987
|
+
const teamRowId = purposeKnown && teamId !== null && recipient.kind !== "external" && typeof input.teamRowId === "string" && input.teamRowId !== "" ? input.teamRowId : null;
|
|
16988
|
+
if (teamRowId !== null) gov = hit(cell(att.teamRows, teamRowId), "team_row");
|
|
16989
|
+
if (gov === null && inside && purposeKnown) {
|
|
16990
|
+
gov = hit(own3(att.internalDefaults, purpose), "account_internal");
|
|
16991
|
+
if (gov === null && pd !== null) {
|
|
16992
|
+
const starter = {
|
|
16993
|
+
id: `pol-inside-starter-${purpose}`,
|
|
16994
|
+
name: `${purposeLabel} \u2014 Inside your account (platform default)`,
|
|
16995
|
+
purpose,
|
|
16996
|
+
infoScope: null,
|
|
16997
|
+
posture: "open",
|
|
16998
|
+
version: 1,
|
|
16999
|
+
origin: { kind: "starter" }
|
|
17000
|
+
};
|
|
17001
|
+
gov = {
|
|
17002
|
+
policy: starter,
|
|
17003
|
+
level: "inside_starter",
|
|
17004
|
+
version: 1,
|
|
17005
|
+
rulePath: `${starter.id} v1 (${SHARE_LEVEL_LABEL.inside_starter} \u2014 the full record, open)`
|
|
17006
|
+
};
|
|
17007
|
+
}
|
|
17008
|
+
}
|
|
17009
|
+
if (gov === null && !inside && purposeKnown && recipientKey !== null) {
|
|
17010
|
+
gov = hit(cell(att.relationships, recipientKey), "relationship");
|
|
17011
|
+
if (gov === null)
|
|
17012
|
+
gov = hit(own3(att.agencyDefaults, purpose), "agency_default");
|
|
17013
|
+
if (gov === null && pd !== null) {
|
|
17014
|
+
const starter = {
|
|
17015
|
+
id: `pol-starter-${purpose}`,
|
|
17016
|
+
name: `${purposeLabel} \u2014 Platform default`,
|
|
17017
|
+
purpose,
|
|
17018
|
+
infoScope: pdRaw.filter((c) => c !== systemCode),
|
|
17019
|
+
posture: "open",
|
|
17020
|
+
version: pd.version,
|
|
17021
|
+
origin: { kind: "platform_starter" },
|
|
17022
|
+
edited: false
|
|
17023
|
+
};
|
|
17024
|
+
gov = {
|
|
17025
|
+
policy: starter,
|
|
17026
|
+
level: "platform_starter",
|
|
17027
|
+
version: pd.version,
|
|
17028
|
+
rulePath: `${starter.id} v${pd.version} (${SHARE_LEVEL_LABEL.platform_starter})`
|
|
17029
|
+
};
|
|
17030
|
+
}
|
|
17031
|
+
}
|
|
17032
|
+
let tc = null;
|
|
17033
|
+
if (teamId !== null && gov !== null) {
|
|
17034
|
+
const t = hit(cell(att.teams, teamId), "team");
|
|
17035
|
+
if (t !== null && t.policy.id !== gov.policy.id) tc = t;
|
|
17036
|
+
}
|
|
17037
|
+
const govNamed = gov === null ? null : named(gov);
|
|
17038
|
+
const tcNamed = tc === null ? null : named(tc);
|
|
17039
|
+
const rulePath = gov === null ? `no Platform default for purpose \u201C${purpose}\u201D \u2014 nothing governs (fails closed)` : tc === null ? gov.rulePath : `${gov.rulePath} \u2229 ${tc.rulePath} (the sending team's own policy is a ceiling \u2014 only what both allow)`;
|
|
17040
|
+
let posture = input.relationshipPosture === "approval" || input.relationshipPosture === "blocked" ? input.relationshipPosture : "open";
|
|
17041
|
+
let postureSource = "relationship";
|
|
17042
|
+
let posturePol = null;
|
|
17043
|
+
if (govNamed?.posture && SHARE_POSTURE_RANK[govNamed.posture] > SHARE_POSTURE_RANK[posture]) {
|
|
17044
|
+
posture = govNamed.posture;
|
|
17045
|
+
postureSource = "policy";
|
|
17046
|
+
posturePol = govNamed;
|
|
17047
|
+
}
|
|
17048
|
+
if (tcNamed?.posture && SHARE_POSTURE_RANK[tcNamed.posture] > SHARE_POSTURE_RANK[posture]) {
|
|
17049
|
+
posture = tcNamed.posture;
|
|
17050
|
+
postureSource = "team_ceiling";
|
|
17051
|
+
posturePol = tcNamed;
|
|
17052
|
+
}
|
|
17053
|
+
let excluded = null;
|
|
17054
|
+
let reportCarveOut = null;
|
|
17055
|
+
if (gov === null) {
|
|
17056
|
+
excluded = {
|
|
17057
|
+
reason: `No Platform default for purpose \u201C${purpose}\u201D \u2014 nothing may leave under it`,
|
|
17058
|
+
rulePath
|
|
17059
|
+
};
|
|
17060
|
+
} else if (input.purposeOff === true) {
|
|
17061
|
+
excluded = {
|
|
17062
|
+
reason: "Share purpose disabled by your account's sharing policy",
|
|
17063
|
+
rulePath: `purposeOverrides[${purpose}] = false`
|
|
17064
|
+
};
|
|
17065
|
+
} else if (posture === "blocked") {
|
|
17066
|
+
const pol = posturePol;
|
|
17067
|
+
const path = pol === null ? "relationship posture = blocked" : `sharingPurposePolicies[${pol.id}].posture=blocked (policy \u201C${pol.name}\u201D \u2014 ${pol.levelLabel})`;
|
|
17068
|
+
if (report) {
|
|
17069
|
+
reportCarveOut = {
|
|
17070
|
+
note: pol === null ? "Blocked for ordinary sharing \u2014 reachable for reports (nothing at the partner layer extinguishes the duty)" : `The \u201C${pol.name}\u201D policy blocks ordinary sharing \u2014 reachable for reports`,
|
|
17071
|
+
rulePath: path
|
|
17072
|
+
};
|
|
17073
|
+
} else {
|
|
17074
|
+
excluded = {
|
|
17075
|
+
reason: pol === null ? "Blocked for this purpose by the relationship" : `Blocked for this purpose by your account's \u201C${pol.name}\u201D policy`,
|
|
17076
|
+
rulePath: path
|
|
17077
|
+
};
|
|
17078
|
+
}
|
|
17079
|
+
}
|
|
17080
|
+
const excludedAll = excluded !== null;
|
|
17081
|
+
const level = gov?.level ?? null;
|
|
17082
|
+
const govList = govNamed?.infoScope ?? null;
|
|
17083
|
+
const polScopeBinds = gov !== null && Array.isArray(govList) && (level === "team_row" || level === "relationship" || level === "account_internal" || level === "inside_starter" || level === "agency_default" && gov.policy.edited === true);
|
|
17084
|
+
const legacy = legacyCeilingList(input.legacyCeiling);
|
|
17085
|
+
const ceilingIsStarter = legacy === null;
|
|
17086
|
+
let groupCeiling = legacy ?? pdRaw;
|
|
17087
|
+
let ceilingPath = legacy !== null ? "sharingScopeEdits (the account's partner / default rule \u2014 the legacy cell chain)" : pd === null ? "no Platform default" : `pol-starter-${purpose} v${pd.version} (Platform default \u2014 the starting scope for this purpose)`;
|
|
17088
|
+
if (ceilingIsStarter && polScopeBinds) {
|
|
17089
|
+
groupCeiling = null;
|
|
17090
|
+
ceilingPath = "";
|
|
17091
|
+
}
|
|
17092
|
+
if (inside) {
|
|
17093
|
+
groupCeiling = null;
|
|
17094
|
+
ceilingPath = "";
|
|
17095
|
+
}
|
|
17096
|
+
const tcScope = tcNamed?.infoScope ?? null;
|
|
17097
|
+
const tcItems = tc?.policy.infoScopeItems ?? null;
|
|
17098
|
+
const govItems = gov?.policy.infoScopeItems ?? null;
|
|
17099
|
+
const required = (g) => g === systemCode || !inside && pd !== null && pdRequired.includes(g);
|
|
17100
|
+
const blockedSet = new Set(pdBlocked);
|
|
17101
|
+
const asSet2 = (v) => new Set(isStringList2(v) ? v : []);
|
|
17102
|
+
const categoriesOff = asSet2(input.accountScope?.categoriesOff);
|
|
17103
|
+
const rowsOff = asSet2(input.accountScope?.rowsOff);
|
|
17104
|
+
const categoriesOn = asSet2(input.accountScope?.categoriesOn);
|
|
17105
|
+
const rowsOn = asSet2(input.accountScope?.rowsOn);
|
|
17106
|
+
const underFloor = (code) => scope.ancestorsOf(code).some((c) => scope.row(c)?.platformFloor === true);
|
|
17107
|
+
const categoryOffByDefault = (g) => !categoriesOn.has(g) && scope.row(g)?.shareableDefault === false;
|
|
17108
|
+
const heightenedOff = (code, g) => {
|
|
17109
|
+
const chain = scope.ancestorsOf(code);
|
|
17110
|
+
if (chain.some((c) => rowsOff.has(c))) return true;
|
|
17111
|
+
const below = chain.slice(0, Math.max(chain.indexOf(g), 0));
|
|
17112
|
+
return below.some(
|
|
17113
|
+
(c) => !rowsOn.has(c) && scope.row(c)?.shareableDefault === false
|
|
17114
|
+
);
|
|
17115
|
+
};
|
|
17116
|
+
const out = {};
|
|
17117
|
+
const allowedCategories = [];
|
|
17118
|
+
const govName = govNamed?.name ?? "";
|
|
17119
|
+
for (const g of tree.categories) {
|
|
17120
|
+
const items = tree.descendants.get(g) ?? [];
|
|
17121
|
+
const leaves = tree.leaves.get(g) ?? [];
|
|
17122
|
+
const platformRequired = !inside && pd !== null && pdRequired.includes(g) ? {
|
|
17123
|
+
rulePath: `pol-starter-${purpose} v${pd.version} \xB7 ${g} = Required (Platform default \u2014 set by the Platform Admin)`
|
|
17124
|
+
} : null;
|
|
17125
|
+
const req = required(g);
|
|
17126
|
+
let allowed = true;
|
|
17127
|
+
let reason = excluded !== null ? excluded.reason : "Allowed";
|
|
17128
|
+
let path = excluded !== null ? excluded.rulePath : rulePath;
|
|
17129
|
+
const floorItems = items.filter(underFloor);
|
|
17130
|
+
const excludedItems = [];
|
|
17131
|
+
let excludedReason = null;
|
|
17132
|
+
const teamExcludedItems = [];
|
|
17133
|
+
let teamExcludedReason = null;
|
|
17134
|
+
const addExcluded = (rows, why) => {
|
|
17135
|
+
for (const r of rows)
|
|
17136
|
+
if (!floorItems.includes(r) && !excludedItems.includes(r))
|
|
17137
|
+
excludedItems.push(r);
|
|
17138
|
+
if (rows.length > 0 && excludedReason === null) excludedReason = why;
|
|
17139
|
+
};
|
|
17140
|
+
if (gov === null) {
|
|
17141
|
+
allowed = false;
|
|
17142
|
+
} else if ((!req || platformRequired !== null) && excludedAll) {
|
|
17143
|
+
allowed = false;
|
|
17144
|
+
} else if (excludedAll) {
|
|
17145
|
+
reason = "Allowed";
|
|
17146
|
+
path = rulePath;
|
|
17147
|
+
}
|
|
17148
|
+
if (allowed && !req && (categoriesOff.has(g) || categoryOffByDefault(g))) {
|
|
17149
|
+
allowed = false;
|
|
17150
|
+
reason = "Excluded by your account's Information Scope policy";
|
|
17151
|
+
path = categoriesOff.has(g) ? `policies.scopeCatalog[${g}].shareable = false` : `policies.scopeCatalog[${g}] not turned on \u2014 codebook core-information_scope shareableDefault = false (CVC-236 heightened protection: off until the account turns it on)`;
|
|
17152
|
+
}
|
|
17153
|
+
if (allowed && !req && !inside && blockedSet.has(g)) {
|
|
17154
|
+
allowed = false;
|
|
17155
|
+
reason = "Blocked for this purpose by the Platform default \u2014 no account can share it under this purpose";
|
|
17156
|
+
path = `pol-starter-${purpose} v${pd?.version ?? 1} \xB7 ${g} = Blocked (Platform default \u2014 CVC-236 heightened protection | set by the Platform Admin)`;
|
|
17157
|
+
}
|
|
17158
|
+
addExcluded(
|
|
17159
|
+
g === systemCode ? [] : items.filter((r) => !underFloor(r) && heightenedOff(r, g)),
|
|
17160
|
+
"Heightened protection (CVC-236) \u2014 off in your account's Information Scope until the account turns it on"
|
|
17161
|
+
);
|
|
17162
|
+
if (allowed && !req && groupCeiling !== null && !scopeListCovers(scope, groupCeiling, g)) {
|
|
17163
|
+
allowed = false;
|
|
17164
|
+
reason = "Outside the payload for this purpose";
|
|
17165
|
+
path = ceilingPath;
|
|
17166
|
+
}
|
|
17167
|
+
if (allowed && !req && groupCeiling !== null && !scopeListStrictlyCovers(scope, groupCeiling, g)) {
|
|
17168
|
+
addExcluded(
|
|
17169
|
+
items.filter((r) => !scopeListCovers(scope, groupCeiling, g, r)),
|
|
17170
|
+
"Outside the payload for this purpose"
|
|
17171
|
+
);
|
|
17172
|
+
}
|
|
17173
|
+
if (allowed && !req && polScopeBinds && !scopeListCovers(scope, govList, g)) {
|
|
17174
|
+
allowed = false;
|
|
17175
|
+
reason = `Outside what the \u201C${govName}\u201D policy allows for this purpose`;
|
|
17176
|
+
path = `sharingPurposePolicies[${gov?.policy.id}].infoScope (policy \u201C${govName}\u201D \u2014 ${govNamed?.levelLabel})`;
|
|
17177
|
+
}
|
|
17178
|
+
if (allowed && !req && polScopeBinds && !scopeListStrictlyCovers(scope, govList, g)) {
|
|
17179
|
+
addExcluded(
|
|
17180
|
+
items.filter((r) => !scopeListCovers(scope, govList, g, r)),
|
|
17181
|
+
`Outside what the \u201C${govName}\u201D policy allows for this purpose`
|
|
17182
|
+
);
|
|
17183
|
+
}
|
|
17184
|
+
const govRows = polScopeBinds ? own3(govItems, g) : void 0;
|
|
17185
|
+
if (allowed && !req && isStringList2(govRows)) {
|
|
17186
|
+
const keep = new Set(govRows);
|
|
17187
|
+
addExcluded(
|
|
17188
|
+
items.filter(
|
|
17189
|
+
(r) => !keep.has(r) && !scope.ancestorsOf(r).some((a) => a !== g && keep.has(a))
|
|
17190
|
+
),
|
|
17191
|
+
`Outside what the \u201C${govName}\u201D policy allows for this purpose`
|
|
17192
|
+
);
|
|
17193
|
+
}
|
|
17194
|
+
if (allowed && !req && tcScope !== null && !scopeListCovers(scope, tcScope, g)) {
|
|
17195
|
+
allowed = false;
|
|
17196
|
+
reason = `Outside what your team's \u201C${tcNamed?.name}\u201D policy allows`;
|
|
17197
|
+
path = `sharingPurposePolicies[${tc?.policy.id}].infoScope (policy \u201C${tcNamed?.name}\u201D \u2014 ${SHARE_LEVEL_LABEL.team}; a ceiling over \u201C${govName}\u201D)`;
|
|
17198
|
+
}
|
|
17199
|
+
if (allowed && !req && tc !== null) {
|
|
17200
|
+
const why = `Outside what your team's \u201C${tcNamed?.name}\u201D policy allows`;
|
|
17201
|
+
const outRows = /* @__PURE__ */ new Set();
|
|
17202
|
+
if (tcScope !== null && !scopeListStrictlyCovers(scope, tcScope, g)) {
|
|
17203
|
+
for (const r of items)
|
|
17204
|
+
if (!scopeListCovers(scope, tcScope, g, r)) outRows.add(r);
|
|
17205
|
+
}
|
|
17206
|
+
const tcRows = own3(tcItems, g);
|
|
17207
|
+
if (isStringList2(tcRows)) {
|
|
17208
|
+
const keep = new Set(tcRows);
|
|
17209
|
+
for (const r of items)
|
|
17210
|
+
if (!keep.has(r) && !scope.ancestorsOf(r).some((a) => a !== g && keep.has(a)))
|
|
17211
|
+
outRows.add(r);
|
|
17212
|
+
}
|
|
17213
|
+
for (const r of outRows)
|
|
17214
|
+
if (!floorItems.includes(r) && !excludedItems.includes(r))
|
|
17215
|
+
teamExcludedItems.push(r);
|
|
17216
|
+
if (teamExcludedItems.length > 0) teamExcludedReason = why;
|
|
17217
|
+
}
|
|
17218
|
+
if (allowed && (!req || platformRequired !== null) && leaves.length > 0) {
|
|
17219
|
+
const gone = new Set(
|
|
17220
|
+
[...floorItems, ...excludedItems, ...teamExcludedItems].filter(
|
|
17221
|
+
(r) => leaves.includes(r)
|
|
17222
|
+
)
|
|
17223
|
+
);
|
|
17224
|
+
if (gone.size >= leaves.length) {
|
|
17225
|
+
allowed = false;
|
|
17226
|
+
if (leaves.every((r) => floorItems.includes(r))) {
|
|
17227
|
+
reason = "Never shared \u2014 under the platform safety floor";
|
|
17228
|
+
path = "HTI_PLATFORM_SAFETY_FLOOR";
|
|
17229
|
+
} else if (leaves.some((r) => excludedItems.includes(r))) {
|
|
17230
|
+
reason = excludedReason ?? reason;
|
|
17231
|
+
} else {
|
|
17232
|
+
reason = teamExcludedReason ?? reason;
|
|
17233
|
+
}
|
|
17234
|
+
}
|
|
17235
|
+
}
|
|
17236
|
+
out[g] = {
|
|
17237
|
+
allowed,
|
|
17238
|
+
reason,
|
|
17239
|
+
rulePath: path,
|
|
17240
|
+
platformRequired,
|
|
17241
|
+
floorItems: uniq(floorItems),
|
|
17242
|
+
excludedItems: uniq(excludedItems),
|
|
17243
|
+
excludedReason,
|
|
17244
|
+
teamExcludedItems: uniq(teamExcludedItems),
|
|
17245
|
+
teamExcludedReason
|
|
17246
|
+
};
|
|
17247
|
+
if (allowed) allowedCategories.push(g);
|
|
17248
|
+
}
|
|
17249
|
+
return {
|
|
17250
|
+
allowed: !excludedAll,
|
|
17251
|
+
posture,
|
|
17252
|
+
postureSource,
|
|
17253
|
+
excluded,
|
|
17254
|
+
reportCarveOut,
|
|
17255
|
+
governing: govNamed,
|
|
17256
|
+
teamCeiling: tcNamed,
|
|
17257
|
+
inside,
|
|
17258
|
+
scope: out,
|
|
17259
|
+
allowedCategories,
|
|
17260
|
+
rulePath
|
|
17261
|
+
};
|
|
17262
|
+
}
|
|
16605
17263
|
|
|
16606
17264
|
// src/validation/cvc.ts
|
|
16607
17265
|
var import_zod = require("zod");
|
|
@@ -69498,6 +70156,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69498
70156
|
GoalWithdrawalReasonKeys,
|
|
69499
70157
|
HEALTHCARE_ORG_TYPE_KEYS,
|
|
69500
70158
|
HTI_SHARE_PLATFORM_PURPOSE_ENABLED,
|
|
70159
|
+
HTI_SHARE_PLATFORM_REQUIRED_BY_PURPOSE,
|
|
69501
70160
|
HTI_SHARE_PLATFORM_STARTER,
|
|
69502
70161
|
HTI_SHARE_PLATFORM_STARTER_SOURCE,
|
|
69503
70162
|
HairColorKeys,
|
|
@@ -69698,6 +70357,10 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69698
70357
|
SERVICE_STATE_STAMP_CROSSWALK,
|
|
69699
70358
|
SESSION_STATES,
|
|
69700
70359
|
SESSION_STATE_LABELS,
|
|
70360
|
+
SHARE_LEVEL_LABEL,
|
|
70361
|
+
SHARE_PLATFORM_STATE_LABEL,
|
|
70362
|
+
SHARE_POSTURE_RANK,
|
|
70363
|
+
SHARE_REPORTING_PURPOSES,
|
|
69701
70364
|
SHARE_VIEW,
|
|
69702
70365
|
SHARE_VIEW_LABELS,
|
|
69703
70366
|
SHARE_VIEW_VALUES,
|
|
@@ -69769,6 +70432,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69769
70432
|
WHY_NOT_REPORTING_AXES,
|
|
69770
70433
|
WhyNotKeys,
|
|
69771
70434
|
accommodationTypeSot,
|
|
70435
|
+
accountSharePurposePolicy,
|
|
69772
70436
|
actionStepCompletionStatusSot,
|
|
69773
70437
|
actionStepTypeSot,
|
|
69774
70438
|
activityTypeSot,
|
|
@@ -69789,6 +70453,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69789
70453
|
applyRunValidatorsIfUnset,
|
|
69790
70454
|
assertionDomainSot,
|
|
69791
70455
|
assertionStatusSot,
|
|
70456
|
+
attachmentIndexFromPolicies,
|
|
69792
70457
|
basisQuickPicksSot,
|
|
69793
70458
|
buildCvcEntrySchema,
|
|
69794
70459
|
buildCvcRegistrySchema,
|
|
@@ -69846,6 +70511,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69846
70511
|
daIncidentSeveritySot,
|
|
69847
70512
|
demographicsSchema,
|
|
69848
70513
|
deriveAgeBinFromAge,
|
|
70514
|
+
derivePlatformDefault,
|
|
69849
70515
|
determinationHelperCategoriesSot,
|
|
69850
70516
|
determinationLevelSot,
|
|
69851
70517
|
disabilitySubtypeSot,
|
|
@@ -69911,6 +70577,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69911
70577
|
incidentParticipationRolesSot,
|
|
69912
70578
|
incomeBenefitsSourcesSot,
|
|
69913
70579
|
inferenceTypeSot,
|
|
70580
|
+
intersectSharingCeilingLists,
|
|
69914
70581
|
investigativeRequestTypeSot,
|
|
69915
70582
|
isAgencyTypeKey,
|
|
69916
70583
|
isCanonEvaluableFunction,
|
|
@@ -69927,6 +70594,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69927
70594
|
isLiveOrganizationProgram,
|
|
69928
70595
|
isNeverPickableServiceMechanism,
|
|
69929
70596
|
isOrgTypeKey,
|
|
70597
|
+
isPermittedByCeiling,
|
|
69930
70598
|
isProgramReviewStatus,
|
|
69931
70599
|
isProtectedRelationship,
|
|
69932
70600
|
isReportAuthorityOrgType,
|
|
@@ -69945,10 +70613,12 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69945
70613
|
layoutSchema,
|
|
69946
70614
|
leReportStatusSot,
|
|
69947
70615
|
legalActionTypeSot,
|
|
70616
|
+
liveCategories,
|
|
69948
70617
|
livingSituationSot,
|
|
69949
70618
|
locationTypeSot,
|
|
69950
70619
|
maritalStatusLegalSot,
|
|
69951
70620
|
maskSelectionToCeiling,
|
|
70621
|
+
matchTeamRow,
|
|
69952
70622
|
mentalHealthStatusSot,
|
|
69953
70623
|
messageReportReasonSot,
|
|
69954
70624
|
midStayEventTypeSot,
|
|
@@ -69985,6 +70655,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
69985
70655
|
petExitReasonSot,
|
|
69986
70656
|
petRelationshipBasisSot,
|
|
69987
70657
|
phoneSchema,
|
|
70658
|
+
platformDefaultFor,
|
|
69988
70659
|
platformFunctionModel,
|
|
69989
70660
|
platformFunctionSchemaDefinition,
|
|
69990
70661
|
platformFunctionSchemaOptions,
|
|
@@ -70025,6 +70696,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
70025
70696
|
resolveOrgTypeKeyFromLegacyNumeric,
|
|
70026
70697
|
resolveReferralEntityKeyFromLegacyNumeric,
|
|
70027
70698
|
resolveRegistryWithInheritance,
|
|
70699
|
+
resolveShare,
|
|
70028
70700
|
returnedToAbuserStatusSot,
|
|
70029
70701
|
riskCategorySot,
|
|
70030
70702
|
riskIdentificationMilestoneSot,
|
|
@@ -70038,6 +70710,8 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
70038
70710
|
rowsOutsideCeiling,
|
|
70039
70711
|
rowsOverCeiling,
|
|
70040
70712
|
rsvpResponseSot,
|
|
70713
|
+
scopeListCovers,
|
|
70714
|
+
scopeListStrictlyCovers,
|
|
70041
70715
|
scopeMigrationsFromSot,
|
|
70042
70716
|
scopeRowWithinCeiling,
|
|
70043
70717
|
scopeRowsFromSot,
|
|
@@ -70070,8 +70744,10 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
70070
70744
|
severityFollowUpSot,
|
|
70071
70745
|
sexProviderSubroleSot,
|
|
70072
70746
|
shareCadenceSot,
|
|
70747
|
+
shareDefaultScopeFor,
|
|
70073
70748
|
sharePurposeSot,
|
|
70074
70749
|
shareResponseReasonSot,
|
|
70750
|
+
shareRowCeiling,
|
|
70075
70751
|
sharingCeilingCellList,
|
|
70076
70752
|
sharingCeilingRowKey,
|
|
70077
70753
|
sharingScopeEditsFromCells,
|
|
@@ -70092,6 +70768,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
70092
70768
|
suggestionSourceSot,
|
|
70093
70769
|
supportStrengthSot,
|
|
70094
70770
|
supportTopicSot,
|
|
70771
|
+
systemCategoryOf,
|
|
70095
70772
|
teamDirectorySchemaDefinition,
|
|
70096
70773
|
threadStatusSot,
|
|
70097
70774
|
threadTypeSot,
|