@htilabs/platform-common-models 0.54.0 → 0.55.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 +48 -0
- package/dist/authz/index.cjs.map +1 -1
- package/dist/authz/index.d.cts +10 -8
- package/dist/authz/index.d.ts +10 -8
- package/dist/authz/index.js.map +1 -1
- package/dist/{index-XWSYon40.d.cts → index-Bj-s0nZy.d.cts} +1 -1
- package/dist/{index-Bh1zO_Vu.d.ts → index-DvAypMJV.d.ts} +1 -1
- package/dist/index.cjs +152 -2
- 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 +145 -2
- package/dist/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/sharing-ceiling/index.cjs +152 -2
- package/dist/sharing-ceiling/index.cjs.map +1 -1
- package/dist/sharing-ceiling/index.d.cts +214 -2
- package/dist/sharing-ceiling/index.d.ts +214 -2
- package/dist/sharing-ceiling/index.js +145 -2
- package/dist/sharing-ceiling/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/core-function-default-bounds.test.ts +2 -2
- package/src/authz/functionDoor.ts +4 -4
- package/src/authz/resolveEffectiveFunctions.ts +6 -4
- package/src/sharingCeiling/__tests__/fireShareEvent.test.ts +437 -0
- package/src/sharingCeiling/fireShareEvent.ts +352 -0
- package/src/sharingCeiling/index.ts +4 -0
- package/src/sharingCeiling/resolve.ts +31 -5
- package/dist/{cvcEntry-D787utvP.d.cts → cvcEntry-BLeRivoF.d.cts} +8 -8
- package/dist/{cvcEntry-D787utvP.d.ts → cvcEntry-BLeRivoF.d.ts} +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-
|
|
1
|
+
import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-BLeRivoF.cjs';
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
import { HydratedDocument, Connection, Model } from 'mongoose';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-
|
|
1
|
+
import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-BLeRivoF.js';
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
import { HydratedDocument, Connection, Model } from 'mongoose';
|
|
4
4
|
|
package/dist/index.cjs
CHANGED
|
@@ -479,10 +479,12 @@ __export(src_exports, {
|
|
|
479
479
|
SERVICE_STATE_STAMP_CROSSWALK: () => SERVICE_STATE_STAMP_CROSSWALK,
|
|
480
480
|
SESSION_STATES: () => SESSION_STATES,
|
|
481
481
|
SESSION_STATE_LABELS: () => SESSION_STATE_LABELS,
|
|
482
|
+
SHARE_EVENT: () => SHARE_EVENT,
|
|
482
483
|
SHARE_LEVEL_LABEL: () => SHARE_LEVEL_LABEL,
|
|
483
484
|
SHARE_PLATFORM_STATE_LABEL: () => SHARE_PLATFORM_STATE_LABEL,
|
|
484
485
|
SHARE_POSTURE_RANK: () => SHARE_POSTURE_RANK,
|
|
485
486
|
SHARE_REPORTING_PURPOSES: () => SHARE_REPORTING_PURPOSES,
|
|
487
|
+
SHARE_TRIGGER_EVENTS: () => SHARE_TRIGGER_EVENTS,
|
|
486
488
|
SHARE_VIEW: () => SHARE_VIEW,
|
|
487
489
|
SHARE_VIEW_LABELS: () => SHARE_VIEW_LABELS,
|
|
488
490
|
SHARE_VIEW_VALUES: () => SHARE_VIEW_VALUES,
|
|
@@ -662,6 +664,8 @@ __export(src_exports, {
|
|
|
662
664
|
facilitatorEntityTypeSot: () => facilitatorEntityType_v1_0_0_default,
|
|
663
665
|
facilitatorLabelUsedInSourceSot: () => facilitatorLabelUsedInSource_v1_0_0_default,
|
|
664
666
|
facilitatorSubroleSot: () => facilitatorSubrole_v1_0_0_default,
|
|
667
|
+
fireShareEvent: () => fireShareEvent,
|
|
668
|
+
firedShareKey: () => firedShareKey,
|
|
665
669
|
formModel: () => formModel_exports,
|
|
666
670
|
formSchemaDefinition: () => formSchemaDefinition,
|
|
667
671
|
formSchemaOptions: () => formSchemaOptions,
|
|
@@ -799,6 +803,7 @@ __export(src_exports, {
|
|
|
799
803
|
poPetitionBasisSot: () => poPetitionBasis_v1_0_0_default,
|
|
800
804
|
poStatusSot: () => poStatus_v1_0_0_default,
|
|
801
805
|
poViolationStatusSot: () => poViolationStatus_v1_0_0_default,
|
|
806
|
+
policyIsShareListener: () => policyIsShareListener,
|
|
802
807
|
preferredContactMethodSot: () => preferredContactMethod_v1_0_0_default,
|
|
803
808
|
primaryLanguageSot: () => primaryLanguage_v1_0_0_default,
|
|
804
809
|
programEnrollmentChangeTypeSot: () => programEnrollmentChangeType_v1_0_0_default,
|
|
@@ -884,9 +889,11 @@ __export(src_exports, {
|
|
|
884
889
|
sexProviderSubroleSot: () => sexProviderSubrole_v1_0_0_default,
|
|
885
890
|
shareCadenceSot: () => shareCadence_v1_0_0_default,
|
|
886
891
|
shareDefaultScopeFor: () => shareDefaultScopeFor,
|
|
892
|
+
shareListenersFor: () => shareListenersFor,
|
|
887
893
|
sharePurposeSot: () => sharePurpose_v1_0_0_default,
|
|
888
894
|
shareResponseReasonSot: () => shareResponseReason_v1_0_0_default,
|
|
889
895
|
shareRowCeiling: () => shareRowCeiling,
|
|
896
|
+
shareTriggerLabel: () => shareTriggerLabel,
|
|
890
897
|
sharingCeilingCellList: () => sharingCeilingCellList,
|
|
891
898
|
sharingCeilingRowKey: () => sharingCeilingRowKey,
|
|
892
899
|
sharingScopeEditsFromCells: () => sharingScopeEditsFromCells,
|
|
@@ -25962,7 +25969,9 @@ function resolveShare(input) {
|
|
|
25962
25969
|
const teamExcludedItems = [];
|
|
25963
25970
|
let teamExcludedReason = null;
|
|
25964
25971
|
const outside = (covered) => items.filter(
|
|
25965
|
-
(r) => !covered(r) && !items.some(
|
|
25972
|
+
(r) => !covered(r) && !items.some(
|
|
25973
|
+
(d) => d !== r && covered(d) && scope.ancestorsOf(d).includes(r)
|
|
25974
|
+
)
|
|
25966
25975
|
);
|
|
25967
25976
|
const addExcluded = (rows, why) => {
|
|
25968
25977
|
for (const r of rows)
|
|
@@ -26032,7 +26041,8 @@ function resolveShare(input) {
|
|
|
26032
26041
|
const why = `Outside what your team's \u201C${tcNamed?.name}\u201D policy allows`;
|
|
26033
26042
|
const outRows = /* @__PURE__ */ new Set();
|
|
26034
26043
|
if (tcScope !== null && !scopeListStrictlyCovers(scope, tcScope, g)) {
|
|
26035
|
-
for (const r of outside((x) => scopeListCovers(scope, tcScope, g, x)))
|
|
26044
|
+
for (const r of outside((x) => scopeListCovers(scope, tcScope, g, x)))
|
|
26045
|
+
outRows.add(r);
|
|
26036
26046
|
}
|
|
26037
26047
|
const tcRows = own3(tcItems, g);
|
|
26038
26048
|
if (isStringList2(tcRows)) {
|
|
@@ -26091,6 +26101,139 @@ function resolveShare(input) {
|
|
|
26091
26101
|
};
|
|
26092
26102
|
}
|
|
26093
26103
|
|
|
26104
|
+
// src/sharingCeiling/fireShareEvent.ts
|
|
26105
|
+
var SHARE_TRIGGER_EVENTS = Object.freeze([
|
|
26106
|
+
{ code: "sessionSubmitted", label: "Session submitted", group: "case" },
|
|
26107
|
+
{ code: "caseOpened", label: "Case opened", group: "case" },
|
|
26108
|
+
{ code: "caseStatusChanged", label: "Case status changed", group: "case" },
|
|
26109
|
+
{ code: "caseCloseRuled", label: "Case closed", group: "case" },
|
|
26110
|
+
{
|
|
26111
|
+
code: "determinationIssued",
|
|
26112
|
+
label: "Determination issued",
|
|
26113
|
+
group: "case"
|
|
26114
|
+
},
|
|
26115
|
+
{ code: "serviceLogged", label: "Service logged", group: "case" },
|
|
26116
|
+
{ code: "noteAdded", label: "Note added", group: "case" },
|
|
26117
|
+
{ code: "shareClaimed", label: "Share you sent claimed", group: "share" },
|
|
26118
|
+
{
|
|
26119
|
+
code: "referralClaimed",
|
|
26120
|
+
label: "Referral you sent claimed",
|
|
26121
|
+
group: "share"
|
|
26122
|
+
},
|
|
26123
|
+
{
|
|
26124
|
+
code: "shareAcknowledged",
|
|
26125
|
+
label: "Share you sent acknowledged",
|
|
26126
|
+
group: "share"
|
|
26127
|
+
}
|
|
26128
|
+
]);
|
|
26129
|
+
var SHARE_EVENT = Object.freeze({
|
|
26130
|
+
SESSION_SUBMITTED: "sessionSubmitted",
|
|
26131
|
+
CASE_CLOSED: "caseCloseRuled"
|
|
26132
|
+
});
|
|
26133
|
+
function shareTriggerLabel(code) {
|
|
26134
|
+
return SHARE_TRIGGER_EVENTS.find((t) => t.code === code)?.label ?? code;
|
|
26135
|
+
}
|
|
26136
|
+
var str2 = (v) => typeof v === "string" && v !== "";
|
|
26137
|
+
function policyIsShareListener(p) {
|
|
26138
|
+
if (p === null || p === void 0 || typeof p !== "object") return false;
|
|
26139
|
+
if (p.active === false) return false;
|
|
26140
|
+
if (p.cadences?.ongoing !== true) return false;
|
|
26141
|
+
const on = p.trigger?.on;
|
|
26142
|
+
if (!Array.isArray(on) || !on.some(str2)) return false;
|
|
26143
|
+
return p.trigger?.answers !== "received";
|
|
26144
|
+
}
|
|
26145
|
+
function linkTarget(a) {
|
|
26146
|
+
const withTeam = a.with !== null && typeof a.with === "object" && a.with.type === "team" && str2(a.with.id) ? a.with.id : null;
|
|
26147
|
+
if (str2(a.partnerId)) {
|
|
26148
|
+
return {
|
|
26149
|
+
recipient: { kind: "partner", id: a.partnerId },
|
|
26150
|
+
partnerTeamId: withTeam
|
|
26151
|
+
};
|
|
26152
|
+
}
|
|
26153
|
+
if (withTeam !== null) {
|
|
26154
|
+
return {
|
|
26155
|
+
recipient: { kind: "sibling_team", teamId: withTeam },
|
|
26156
|
+
partnerTeamId: null
|
|
26157
|
+
};
|
|
26158
|
+
}
|
|
26159
|
+
return null;
|
|
26160
|
+
}
|
|
26161
|
+
var targetKey = (l) => l.recipient.kind === "partner" ? ["partner", l.recipient.id, l.partnerTeamId] : ["team", l.recipient.teamId, null];
|
|
26162
|
+
function rowAgrees(rows, a, target) {
|
|
26163
|
+
const row = rows.find(
|
|
26164
|
+
(r) => r !== null && typeof r === "object" && r.id === a.teamRowId
|
|
26165
|
+
);
|
|
26166
|
+
if (row === void 0 || row.myTeamId !== a.teamId) return false;
|
|
26167
|
+
const theirTeam = row.their?.type === "team" && str2(row.their.id) ? row.their.id : null;
|
|
26168
|
+
return target.recipient.kind === "sibling_team" ? theirTeam === target.recipient.teamId : theirTeam === target.partnerTeamId;
|
|
26169
|
+
}
|
|
26170
|
+
function shareListenersFor(policies, teamId, options = {}) {
|
|
26171
|
+
if (!Array.isArray(policies) || !str2(teamId)) return [];
|
|
26172
|
+
const cells = attachmentIndexFromPolicies(policies).teamRows;
|
|
26173
|
+
const rows = Array.isArray(options.teamRows) ? options.teamRows : null;
|
|
26174
|
+
const out = [];
|
|
26175
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26176
|
+
for (const p of policies) {
|
|
26177
|
+
if (!policyIsShareListener(p) || !str2(p.id) || !str2(p.purpose)) continue;
|
|
26178
|
+
const events = (p.trigger?.on ?? []).filter(str2);
|
|
26179
|
+
if (str2(options.event) && !events.includes(options.event)) continue;
|
|
26180
|
+
for (const a of Array.isArray(p.assignments) ? p.assignments : []) {
|
|
26181
|
+
if (a === null || typeof a !== "object" || a.scope !== "team_pair")
|
|
26182
|
+
continue;
|
|
26183
|
+
if (!str2(a.teamRowId) || a.teamId !== teamId) continue;
|
|
26184
|
+
if (cells[a.teamRowId]?.[p.purpose] !== p.id) continue;
|
|
26185
|
+
const target = linkTarget(a);
|
|
26186
|
+
if (target === null) continue;
|
|
26187
|
+
if (rows !== null && !rowAgrees(rows, a, target)) continue;
|
|
26188
|
+
if (target.recipient.kind === "sibling_team" && target.recipient.teamId === teamId)
|
|
26189
|
+
continue;
|
|
26190
|
+
const dedupe = JSON.stringify([p.id, ...targetKey(target)]);
|
|
26191
|
+
if (seen.has(dedupe)) continue;
|
|
26192
|
+
seen.add(dedupe);
|
|
26193
|
+
out.push({
|
|
26194
|
+
policy: {
|
|
26195
|
+
id: p.id,
|
|
26196
|
+
familyId: str2(p.familyId) ? p.familyId : p.id,
|
|
26197
|
+
name: str2(p.name) ? p.name : p.id,
|
|
26198
|
+
version: parseInt(String(p.version), 10) || 1
|
|
26199
|
+
},
|
|
26200
|
+
purpose: p.purpose,
|
|
26201
|
+
fromTeamId: teamId,
|
|
26202
|
+
teamRowId: a.teamRowId,
|
|
26203
|
+
...target,
|
|
26204
|
+
events
|
|
26205
|
+
});
|
|
26206
|
+
}
|
|
26207
|
+
}
|
|
26208
|
+
return out;
|
|
26209
|
+
}
|
|
26210
|
+
function firedShareKey(event, ref, listener) {
|
|
26211
|
+
return JSON.stringify([
|
|
26212
|
+
event,
|
|
26213
|
+
ref,
|
|
26214
|
+
listener.policy.id,
|
|
26215
|
+
listener.fromTeamId,
|
|
26216
|
+
...targetKey(listener)
|
|
26217
|
+
]);
|
|
26218
|
+
}
|
|
26219
|
+
function fireShareEvent(policies, event, options = {}) {
|
|
26220
|
+
if (event === null || event === void 0 || !str2(event.event)) return [];
|
|
26221
|
+
const session = str2(event.sessionId) ? event.sessionId : null;
|
|
26222
|
+
const kase = str2(event.caseId) ? event.caseId : null;
|
|
26223
|
+
const ref = str2(event.ref) ? event.ref : event.event === SHARE_EVENT.SESSION_SUBMITTED ? session ?? kase : kase ?? session;
|
|
26224
|
+
const done = new Set(options.alreadyFired ?? []);
|
|
26225
|
+
const fired = [];
|
|
26226
|
+
for (const l of shareListenersFor(policies, event.teamId, {
|
|
26227
|
+
event: event.event,
|
|
26228
|
+
teamRows: options.teamRows ?? null
|
|
26229
|
+
})) {
|
|
26230
|
+
const key = firedShareKey(event.event, ref, l);
|
|
26231
|
+
if (done.has(key)) continue;
|
|
26232
|
+
fired.push({ ...l, event: event.event, ref, key });
|
|
26233
|
+
}
|
|
26234
|
+
return fired;
|
|
26235
|
+
}
|
|
26236
|
+
|
|
26094
26237
|
// src/validation/cvc.ts
|
|
26095
26238
|
var import_zod = require("zod");
|
|
26096
26239
|
var CvcCodeSchema = import_zod.z.string().regex(/^\d{3}(-\d{3}){6}$/);
|
|
@@ -73788,10 +73931,12 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
73788
73931
|
SERVICE_STATE_STAMP_CROSSWALK,
|
|
73789
73932
|
SESSION_STATES,
|
|
73790
73933
|
SESSION_STATE_LABELS,
|
|
73934
|
+
SHARE_EVENT,
|
|
73791
73935
|
SHARE_LEVEL_LABEL,
|
|
73792
73936
|
SHARE_PLATFORM_STATE_LABEL,
|
|
73793
73937
|
SHARE_POSTURE_RANK,
|
|
73794
73938
|
SHARE_REPORTING_PURPOSES,
|
|
73939
|
+
SHARE_TRIGGER_EVENTS,
|
|
73795
73940
|
SHARE_VIEW,
|
|
73796
73941
|
SHARE_VIEW_LABELS,
|
|
73797
73942
|
SHARE_VIEW_VALUES,
|
|
@@ -73971,6 +74116,8 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
73971
74116
|
facilitatorEntityTypeSot,
|
|
73972
74117
|
facilitatorLabelUsedInSourceSot,
|
|
73973
74118
|
facilitatorSubroleSot,
|
|
74119
|
+
fireShareEvent,
|
|
74120
|
+
firedShareKey,
|
|
73974
74121
|
formModel,
|
|
73975
74122
|
formSchemaDefinition,
|
|
73976
74123
|
formSchemaOptions,
|
|
@@ -74108,6 +74255,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
74108
74255
|
poPetitionBasisSot,
|
|
74109
74256
|
poStatusSot,
|
|
74110
74257
|
poViolationStatusSot,
|
|
74258
|
+
policyIsShareListener,
|
|
74111
74259
|
preferredContactMethodSot,
|
|
74112
74260
|
primaryLanguageSot,
|
|
74113
74261
|
programEnrollmentChangeTypeSot,
|
|
@@ -74193,9 +74341,11 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
74193
74341
|
sexProviderSubroleSot,
|
|
74194
74342
|
shareCadenceSot,
|
|
74195
74343
|
shareDefaultScopeFor,
|
|
74344
|
+
shareListenersFor,
|
|
74196
74345
|
sharePurposeSot,
|
|
74197
74346
|
shareResponseReasonSot,
|
|
74198
74347
|
shareRowCeiling,
|
|
74348
|
+
shareTriggerLabel,
|
|
74199
74349
|
sharingCeilingCellList,
|
|
74200
74350
|
sharingCeilingRowKey,
|
|
74201
74351
|
sharingScopeEditsFromCells,
|