@htilabs/platform-common-models 0.54.0 → 0.56.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 +90 -0
- package/dist/authz/index.cjs +353 -2
- package/dist/authz/index.cjs.map +1 -1
- package/dist/authz/index.d.cts +330 -9
- package/dist/authz/index.d.ts +330 -9
- package/dist/authz/index.js +339 -1
- 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 +503 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +483 -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__/authz-resolve.test.ts +5 -0
- package/src/__tests__/authz-viewing-policy.test.ts +685 -0
- package/src/__tests__/authz-viewing-scope.test.ts +1037 -0
- package/src/__tests__/core-function-default-bounds.test.ts +2 -2
- package/src/authz/functionDoor.ts +4 -4
- package/src/authz/index.ts +2 -0
- package/src/authz/resolveEffectiveFunctions.ts +6 -4
- package/src/authz/viewingPolicy.ts +525 -0
- package/src/authz/viewingScope.ts +359 -0
- 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
package/dist/index.js
CHANGED
|
@@ -24103,6 +24103,331 @@ function functionDoor(input) {
|
|
|
24103
24103
|
};
|
|
24104
24104
|
}
|
|
24105
24105
|
|
|
24106
|
+
// src/authz/viewingPolicy.ts
|
|
24107
|
+
var VIEWING_POLICY_SPECIES = "viewing";
|
|
24108
|
+
var VIEWING_POLICY_VOCABULARIES = Object.freeze({
|
|
24109
|
+
3: Object.freeze({ scopeVersion: 3, oneHomeCarry: true, identifyingAlias: true }),
|
|
24110
|
+
4: Object.freeze({ scopeVersion: 3, oneHomeCarry: false, identifyingAlias: true }),
|
|
24111
|
+
5: Object.freeze({ scopeVersion: 4, oneHomeCarry: false, identifyingAlias: false })
|
|
24112
|
+
});
|
|
24113
|
+
function viewingPolicyVocabulary(scopeVocab) {
|
|
24114
|
+
return scopeVocab === 3 || scopeVocab === 4 || scopeVocab === 5 ? VIEWING_POLICY_VOCABULARIES[scopeVocab] : null;
|
|
24115
|
+
}
|
|
24116
|
+
function unavailableViewingPolicy(reason, policyId) {
|
|
24117
|
+
return {
|
|
24118
|
+
source: "unavailable",
|
|
24119
|
+
level: 0,
|
|
24120
|
+
visibleGroups: [],
|
|
24121
|
+
scopeVocab: null,
|
|
24122
|
+
policy: null,
|
|
24123
|
+
reason,
|
|
24124
|
+
policyId: policyId ?? null,
|
|
24125
|
+
rulePath: `viewing policy unavailable: ${reason}` + (policyId ? ` (${policyId})` : "") + " \u2014 no view of other teams' cases"
|
|
24126
|
+
};
|
|
24127
|
+
}
|
|
24128
|
+
var HEX_OBJECT_ID = /^[0-9a-fA-F]{24}$/;
|
|
24129
|
+
function objectIdHex(v) {
|
|
24130
|
+
if (typeof v === "object" && v !== null && "toHexString" in v) {
|
|
24131
|
+
const toHex = v.toHexString;
|
|
24132
|
+
if (typeof toHex === "function") {
|
|
24133
|
+
const hex = toHex.call(v);
|
|
24134
|
+
if (typeof hex === "string") return hex.toLowerCase();
|
|
24135
|
+
}
|
|
24136
|
+
}
|
|
24137
|
+
return null;
|
|
24138
|
+
}
|
|
24139
|
+
function idText(v) {
|
|
24140
|
+
if (typeof v === "string") return v === "" ? null : v;
|
|
24141
|
+
return objectIdHex(v);
|
|
24142
|
+
}
|
|
24143
|
+
function normalizedId(id) {
|
|
24144
|
+
return HEX_OBJECT_ID.test(id) ? id.toLowerCase() : id;
|
|
24145
|
+
}
|
|
24146
|
+
function policyIdOf(d) {
|
|
24147
|
+
return idText(d.entity_id) ?? idText(d.id) ?? idText(d._id) ?? "(no id)";
|
|
24148
|
+
}
|
|
24149
|
+
function placementOf(d) {
|
|
24150
|
+
if (!Array.isArray(d.assignments) || d.assignments.length !== 1) {
|
|
24151
|
+
return { kind: "unreadable" };
|
|
24152
|
+
}
|
|
24153
|
+
const [a] = d.assignments;
|
|
24154
|
+
if (typeof a !== "object" || a === null) return { kind: "unreadable" };
|
|
24155
|
+
const { scope, teamId } = a;
|
|
24156
|
+
if (scope === "account") return { kind: "account" };
|
|
24157
|
+
const team = idText(teamId);
|
|
24158
|
+
if (scope === "team" && team !== null) {
|
|
24159
|
+
return { kind: "team", teamId: normalizedId(team) };
|
|
24160
|
+
}
|
|
24161
|
+
return { kind: "unreadable" };
|
|
24162
|
+
}
|
|
24163
|
+
function positiveIntOrNull(v) {
|
|
24164
|
+
if (v === void 0 || v === null) return null;
|
|
24165
|
+
return typeof v === "number" && Number.isInteger(v) && v >= 1 ? v : void 0;
|
|
24166
|
+
}
|
|
24167
|
+
function governingRowOf(rows) {
|
|
24168
|
+
const [only] = rows;
|
|
24169
|
+
if (rows.length === 1 && only !== void 0) return { row: only };
|
|
24170
|
+
const family = idText(rows[0]?.familyId);
|
|
24171
|
+
const versions = rows.map((r) => positiveIntOrNull(r.version));
|
|
24172
|
+
const ordered = family !== null && rows.every((r) => idText(r.familyId) === family) && versions.every((v) => typeof v === "number") && new Set(versions).size === versions.length;
|
|
24173
|
+
if (!ordered) {
|
|
24174
|
+
return unavailableViewingPolicy("ambiguous_rows", policyIdOf(rows[0] ?? {}));
|
|
24175
|
+
}
|
|
24176
|
+
let best = rows[0];
|
|
24177
|
+
for (const r of rows) {
|
|
24178
|
+
if (r.version > best.version) best = r;
|
|
24179
|
+
}
|
|
24180
|
+
return { row: best };
|
|
24181
|
+
}
|
|
24182
|
+
function whitelistProblem(visibleGroups, vocab, scope) {
|
|
24183
|
+
const reading = scope.readSelection(visibleGroups, vocab.scopeVersion, {
|
|
24184
|
+
subject: "policy"
|
|
24185
|
+
});
|
|
24186
|
+
if (reading.unsupportedVersion) return "unsupported_scope_vocab";
|
|
24187
|
+
if (reading.unknown.length > 0 || reading.retired.length > 0) {
|
|
24188
|
+
return "unknown_visible_group";
|
|
24189
|
+
}
|
|
24190
|
+
return null;
|
|
24191
|
+
}
|
|
24192
|
+
function withoutRestRows(visibleGroups, scope) {
|
|
24193
|
+
return visibleGroups.filter((code) => scope.row(code)?.rowType !== "category_rest");
|
|
24194
|
+
}
|
|
24195
|
+
function ruleText(source, ref) {
|
|
24196
|
+
const v = ref.version === null ? "" : ` v${ref.version}`;
|
|
24197
|
+
return source === "team" ? `${ref.id}${v} (the team's own row \u2014 it governs this team in place of the account-wide rule)` : `${ref.id}${v} (the account-wide viewing rule \u2014 no row for this team)`;
|
|
24198
|
+
}
|
|
24199
|
+
function readRow(d, source, accountId, scope) {
|
|
24200
|
+
const policyId = policyIdOf(d);
|
|
24201
|
+
const level = d.level;
|
|
24202
|
+
if (level !== 0 && level !== 1 && level !== 2 && level !== 3) {
|
|
24203
|
+
return unavailableViewingPolicy("malformed_level", policyId);
|
|
24204
|
+
}
|
|
24205
|
+
let visibleGroups = [];
|
|
24206
|
+
if (d.visibleGroups !== void 0 && d.visibleGroups !== null) {
|
|
24207
|
+
if (!Array.isArray(d.visibleGroups) || !d.visibleGroups.every((g) => typeof g === "string")) {
|
|
24208
|
+
return unavailableViewingPolicy("malformed_visible_groups", policyId);
|
|
24209
|
+
}
|
|
24210
|
+
visibleGroups = [...d.visibleGroups];
|
|
24211
|
+
}
|
|
24212
|
+
const scopeVocab = positiveIntOrNull(d.scopeVocab);
|
|
24213
|
+
if (scopeVocab === void 0) {
|
|
24214
|
+
return unavailableViewingPolicy("malformed_scope_vocab", policyId);
|
|
24215
|
+
}
|
|
24216
|
+
const vocab = viewingPolicyVocabulary(scopeVocab);
|
|
24217
|
+
if (scopeVocab === null || vocab === null) {
|
|
24218
|
+
return unavailableViewingPolicy("unsupported_scope_vocab", policyId);
|
|
24219
|
+
}
|
|
24220
|
+
const problem = whitelistProblem(visibleGroups, vocab, scope);
|
|
24221
|
+
if (problem !== null) return unavailableViewingPolicy(problem, policyId);
|
|
24222
|
+
const policy = {
|
|
24223
|
+
id: policyId,
|
|
24224
|
+
familyId: idText(d.familyId),
|
|
24225
|
+
version: positiveIntOrNull(d.version) ?? null
|
|
24226
|
+
};
|
|
24227
|
+
return {
|
|
24228
|
+
source,
|
|
24229
|
+
level,
|
|
24230
|
+
visibleGroups: withoutRestRows(visibleGroups, scope),
|
|
24231
|
+
scopeVocab,
|
|
24232
|
+
policy,
|
|
24233
|
+
accountId,
|
|
24234
|
+
rulePath: ruleText(source, policy)
|
|
24235
|
+
};
|
|
24236
|
+
}
|
|
24237
|
+
function resolveViewingPolicy(docs, query, scope) {
|
|
24238
|
+
const accountRaw = typeof query.accountId === "string" ? query.accountId.trim() : "";
|
|
24239
|
+
if (accountRaw === "") return unavailableViewingPolicy("account_unresolved");
|
|
24240
|
+
if (!Array.isArray(docs)) return unavailableViewingPolicy("read_error");
|
|
24241
|
+
const accountId = normalizedId(accountRaw);
|
|
24242
|
+
const teamRaw = typeof query.teamId === "string" ? query.teamId.trim() : "";
|
|
24243
|
+
const actingTeamId = teamRaw !== "" ? normalizedId(teamRaw) : null;
|
|
24244
|
+
const rows = [];
|
|
24245
|
+
for (const raw of docs) {
|
|
24246
|
+
if (typeof raw !== "object" || raw === null) {
|
|
24247
|
+
return unavailableViewingPolicy("read_error");
|
|
24248
|
+
}
|
|
24249
|
+
const d = raw;
|
|
24250
|
+
if (d.species !== VIEWING_POLICY_SPECIES) continue;
|
|
24251
|
+
const owner = idText(d.account_id);
|
|
24252
|
+
if (owner === null || normalizedId(owner) !== accountId) continue;
|
|
24253
|
+
rows.push(d);
|
|
24254
|
+
}
|
|
24255
|
+
const teamRows = [];
|
|
24256
|
+
const accountRows = [];
|
|
24257
|
+
for (const d of rows) {
|
|
24258
|
+
if (d.active === false) continue;
|
|
24259
|
+
const placement = placementOf(d);
|
|
24260
|
+
if (placement.kind === "unreadable") {
|
|
24261
|
+
return unavailableViewingPolicy("unreadable_assignment", policyIdOf(d));
|
|
24262
|
+
}
|
|
24263
|
+
const governsHere = placement.kind === "account" || actingTeamId !== null && placement.teamId === actingTeamId;
|
|
24264
|
+
if (!governsHere) continue;
|
|
24265
|
+
if (d.active !== true) {
|
|
24266
|
+
return unavailableViewingPolicy("malformed_active", policyIdOf(d));
|
|
24267
|
+
}
|
|
24268
|
+
if (placement.kind === "account") accountRows.push(d);
|
|
24269
|
+
else teamRows.push(d);
|
|
24270
|
+
}
|
|
24271
|
+
const [source, candidates] = teamRows.length > 0 ? ["team", teamRows] : ["account", accountRows];
|
|
24272
|
+
if (candidates.length === 0) {
|
|
24273
|
+
const retiredRowsOnly = rows.length > 0 && rows.every((d) => d.active === false);
|
|
24274
|
+
return {
|
|
24275
|
+
source: "none",
|
|
24276
|
+
level: null,
|
|
24277
|
+
visibleGroups: null,
|
|
24278
|
+
scopeVocab: null,
|
|
24279
|
+
policy: null,
|
|
24280
|
+
accountId,
|
|
24281
|
+
retiredRowsOnly,
|
|
24282
|
+
rulePath: retiredRowsOnly ? "no viewing policy on file (every viewing row is retired) \u2014 the role level alone decides" : "no viewing policy on file \u2014 the role level alone decides"
|
|
24283
|
+
};
|
|
24284
|
+
}
|
|
24285
|
+
const governing = governingRowOf(candidates);
|
|
24286
|
+
if (!("row" in governing)) return governing;
|
|
24287
|
+
return readRow(governing.row, source, accountId, scope);
|
|
24288
|
+
}
|
|
24289
|
+
function teamViewingLevelFromPolicy(policy) {
|
|
24290
|
+
switch (policy.source) {
|
|
24291
|
+
case "team":
|
|
24292
|
+
case "account":
|
|
24293
|
+
return policy.level;
|
|
24294
|
+
case "none":
|
|
24295
|
+
return null;
|
|
24296
|
+
default:
|
|
24297
|
+
return 0;
|
|
24298
|
+
}
|
|
24299
|
+
}
|
|
24300
|
+
|
|
24301
|
+
// src/authz/viewingScope.ts
|
|
24302
|
+
var CURRENT_VIEWING_POLICY_VOCAB = 5;
|
|
24303
|
+
var RELATIONSHIPS_HOUSEHOLD = "relationships_household";
|
|
24304
|
+
var RELATIONSHIP_DYNAMICS2 = "relationship_dynamics";
|
|
24305
|
+
function viewingWhitelistFromPolicy(policy) {
|
|
24306
|
+
switch (policy.source) {
|
|
24307
|
+
case "none":
|
|
24308
|
+
return null;
|
|
24309
|
+
case "team":
|
|
24310
|
+
case "account":
|
|
24311
|
+
return { informationScope: [...policy.visibleGroups], scopeVocab: policy.scopeVocab };
|
|
24312
|
+
default:
|
|
24313
|
+
return { informationScope: [], scopeVocab: null };
|
|
24314
|
+
}
|
|
24315
|
+
}
|
|
24316
|
+
function caseViewingAccess(ctx, scope) {
|
|
24317
|
+
if (ctx.canSeeCase !== true) {
|
|
24318
|
+
return { mode: "none", reason: "cannot_see_case" };
|
|
24319
|
+
}
|
|
24320
|
+
if (ctx.ownedByViewer === true) return { mode: "full", reason: "owned" };
|
|
24321
|
+
if (ctx.level === 1 || ctx.level === 2) {
|
|
24322
|
+
return { mode: "stub", level: ctx.level };
|
|
24323
|
+
}
|
|
24324
|
+
if (ctx.level !== 3) return { mode: "none", reason: "level_0" };
|
|
24325
|
+
if (ctx.whitelist === null) {
|
|
24326
|
+
return { mode: "full", reason: "no_viewing_policy" };
|
|
24327
|
+
}
|
|
24328
|
+
const stored = ctx.whitelist ?? {
|
|
24329
|
+
informationScope: [],
|
|
24330
|
+
scopeVocab: CURRENT_VIEWING_POLICY_VOCAB
|
|
24331
|
+
};
|
|
24332
|
+
const stamp = typeof stored.scopeVocab === "number" ? stored.scopeVocab : null;
|
|
24333
|
+
const vocab = viewingPolicyVocabulary(stamp);
|
|
24334
|
+
const reading = scope.readSelection(
|
|
24335
|
+
stored.informationScope,
|
|
24336
|
+
vocab !== null ? vocab.scopeVersion : stamp,
|
|
24337
|
+
{ subject: "policy" }
|
|
24338
|
+
);
|
|
24339
|
+
const identifyingAlias = vocab !== null && vocab.identifyingAlias && reading.informationScope.includes("identifying");
|
|
24340
|
+
return {
|
|
24341
|
+
mode: "whitelist",
|
|
24342
|
+
reading,
|
|
24343
|
+
visibleScope: identifyingAlias ? [...reading.informationScope, RELATIONSHIPS_HOUSEHOLD] : reading.informationScope,
|
|
24344
|
+
oneHomeCarry: vocab !== null && vocab.oneHomeCarry,
|
|
24345
|
+
relationshipDynamicsCarry: identifyingAlias
|
|
24346
|
+
};
|
|
24347
|
+
}
|
|
24348
|
+
function caseSurfacesOn(access, surface) {
|
|
24349
|
+
switch (access.mode) {
|
|
24350
|
+
case "none":
|
|
24351
|
+
return false;
|
|
24352
|
+
case "full":
|
|
24353
|
+
case "whitelist":
|
|
24354
|
+
return true;
|
|
24355
|
+
case "stub":
|
|
24356
|
+
if (surface === "search") return true;
|
|
24357
|
+
if (surface === "autocomplete") return access.level === 2;
|
|
24358
|
+
return false;
|
|
24359
|
+
}
|
|
24360
|
+
}
|
|
24361
|
+
function caseSurfacesAsStub(access) {
|
|
24362
|
+
return access.mode === "stub";
|
|
24363
|
+
}
|
|
24364
|
+
var ONE_HOME_CARRY = [
|
|
24365
|
+
{ homeRow: "summary_ida", domains: /* @__PURE__ */ new Set(["ida_determination"]), unlockedBy: "risk" },
|
|
24366
|
+
{
|
|
24367
|
+
homeRow: "summary_needs_assessment",
|
|
24368
|
+
domains: /* @__PURE__ */ new Set(["needs_assessment", "recommended_followup"]),
|
|
24369
|
+
unlockedBy: "services"
|
|
24370
|
+
}
|
|
24371
|
+
];
|
|
24372
|
+
function isClientStubRow(scope, code) {
|
|
24373
|
+
const row = scope.row(code);
|
|
24374
|
+
return row !== void 0 && row.levelFloor === 1 && row.rowType !== "branch" && (row.kindBranch === "client" || row.kindBranch === null);
|
|
24375
|
+
}
|
|
24376
|
+
function recordViewing(access, record, viewerUserId, scope) {
|
|
24377
|
+
if (access.mode === "none" && access.reason === "cannot_see_case") {
|
|
24378
|
+
return { visible: false, reason: "cannot_see_case" };
|
|
24379
|
+
}
|
|
24380
|
+
const author = record.authorUserId;
|
|
24381
|
+
if (typeof author === "string" && author.trim().length > 0 && author === viewerUserId) {
|
|
24382
|
+
return { visible: true, reason: "author" };
|
|
24383
|
+
}
|
|
24384
|
+
switch (access.mode) {
|
|
24385
|
+
case "none":
|
|
24386
|
+
return { visible: false, reason: access.reason };
|
|
24387
|
+
case "full":
|
|
24388
|
+
return { visible: true, reason: "full" };
|
|
24389
|
+
case "stub":
|
|
24390
|
+
return { visible: false, reason: "not_opened" };
|
|
24391
|
+
case "whitelist":
|
|
24392
|
+
return whitelistDecision(access, record, scope);
|
|
24393
|
+
}
|
|
24394
|
+
}
|
|
24395
|
+
function whitelistDecision(access, record, scope) {
|
|
24396
|
+
const home = scope.row(record.homeRow);
|
|
24397
|
+
if (home === void 0 || home.kindRow !== void 0) {
|
|
24398
|
+
return { visible: false, reason: "unknown_row" };
|
|
24399
|
+
}
|
|
24400
|
+
if ((record.subjectKind === "client" || home.kindBranch !== "client") && isClientStubRow(scope, record.homeRow)) {
|
|
24401
|
+
return { visible: true, reason: "stub_row" };
|
|
24402
|
+
}
|
|
24403
|
+
const list2 = access.visibleScope;
|
|
24404
|
+
if (scope.isCovered(list2, record.homeRow)) {
|
|
24405
|
+
return { visible: true, reason: "covered" };
|
|
24406
|
+
}
|
|
24407
|
+
if (access.relationshipDynamicsCarry && record.domain === RELATIONSHIP_DYNAMICS2) {
|
|
24408
|
+
return { visible: true, reason: "identifying_alias_carry" };
|
|
24409
|
+
}
|
|
24410
|
+
if (access.oneHomeCarry && !scope.isCovered(list2, "instruments") && typeof record.domain === "string") {
|
|
24411
|
+
for (const carry of ONE_HOME_CARRY) {
|
|
24412
|
+
if (record.homeRow === carry.homeRow && carry.domains.has(record.domain) && scope.isCovered(list2, carry.unlockedBy)) {
|
|
24413
|
+
return { visible: true, reason: "one_home_carry" };
|
|
24414
|
+
}
|
|
24415
|
+
}
|
|
24416
|
+
}
|
|
24417
|
+
return { visible: false, reason: "not_covered" };
|
|
24418
|
+
}
|
|
24419
|
+
function viewingRowVisible(access, homeRow, scope) {
|
|
24420
|
+
return recordViewing(access, { homeRow, subjectKind: "client" }, null, scope).visible;
|
|
24421
|
+
}
|
|
24422
|
+
function viewingComponentOpen(access, homeRow, scope) {
|
|
24423
|
+
if (access.mode === "full") return true;
|
|
24424
|
+
if (access.mode !== "whitelist") return false;
|
|
24425
|
+
const row = scope.row(homeRow);
|
|
24426
|
+
if (row === void 0 || row.kindRow !== void 0) return false;
|
|
24427
|
+
if (row.status === "retired") return false;
|
|
24428
|
+
return scope.isCovered(access.visibleScope, homeRow);
|
|
24429
|
+
}
|
|
24430
|
+
|
|
24106
24431
|
// src/generated/sharingPlatformStarter.ts
|
|
24107
24432
|
var SHARING_PLATFORM_STARTER_SOURCE = {
|
|
24108
24433
|
"monolith": {
|
|
@@ -25028,7 +25353,9 @@ function resolveShare(input) {
|
|
|
25028
25353
|
const teamExcludedItems = [];
|
|
25029
25354
|
let teamExcludedReason = null;
|
|
25030
25355
|
const outside = (covered) => items.filter(
|
|
25031
|
-
(r) => !covered(r) && !items.some(
|
|
25356
|
+
(r) => !covered(r) && !items.some(
|
|
25357
|
+
(d) => d !== r && covered(d) && scope.ancestorsOf(d).includes(r)
|
|
25358
|
+
)
|
|
25032
25359
|
);
|
|
25033
25360
|
const addExcluded = (rows, why) => {
|
|
25034
25361
|
for (const r of rows)
|
|
@@ -25098,7 +25425,8 @@ function resolveShare(input) {
|
|
|
25098
25425
|
const why = `Outside what your team's \u201C${tcNamed?.name}\u201D policy allows`;
|
|
25099
25426
|
const outRows = /* @__PURE__ */ new Set();
|
|
25100
25427
|
if (tcScope !== null && !scopeListStrictlyCovers(scope, tcScope, g)) {
|
|
25101
|
-
for (const r of outside((x) => scopeListCovers(scope, tcScope, g, x)))
|
|
25428
|
+
for (const r of outside((x) => scopeListCovers(scope, tcScope, g, x)))
|
|
25429
|
+
outRows.add(r);
|
|
25102
25430
|
}
|
|
25103
25431
|
const tcRows = own3(tcItems, g);
|
|
25104
25432
|
if (isStringList2(tcRows)) {
|
|
@@ -25157,6 +25485,139 @@ function resolveShare(input) {
|
|
|
25157
25485
|
};
|
|
25158
25486
|
}
|
|
25159
25487
|
|
|
25488
|
+
// src/sharingCeiling/fireShareEvent.ts
|
|
25489
|
+
var SHARE_TRIGGER_EVENTS = Object.freeze([
|
|
25490
|
+
{ code: "sessionSubmitted", label: "Session submitted", group: "case" },
|
|
25491
|
+
{ code: "caseOpened", label: "Case opened", group: "case" },
|
|
25492
|
+
{ code: "caseStatusChanged", label: "Case status changed", group: "case" },
|
|
25493
|
+
{ code: "caseCloseRuled", label: "Case closed", group: "case" },
|
|
25494
|
+
{
|
|
25495
|
+
code: "determinationIssued",
|
|
25496
|
+
label: "Determination issued",
|
|
25497
|
+
group: "case"
|
|
25498
|
+
},
|
|
25499
|
+
{ code: "serviceLogged", label: "Service logged", group: "case" },
|
|
25500
|
+
{ code: "noteAdded", label: "Note added", group: "case" },
|
|
25501
|
+
{ code: "shareClaimed", label: "Share you sent claimed", group: "share" },
|
|
25502
|
+
{
|
|
25503
|
+
code: "referralClaimed",
|
|
25504
|
+
label: "Referral you sent claimed",
|
|
25505
|
+
group: "share"
|
|
25506
|
+
},
|
|
25507
|
+
{
|
|
25508
|
+
code: "shareAcknowledged",
|
|
25509
|
+
label: "Share you sent acknowledged",
|
|
25510
|
+
group: "share"
|
|
25511
|
+
}
|
|
25512
|
+
]);
|
|
25513
|
+
var SHARE_EVENT = Object.freeze({
|
|
25514
|
+
SESSION_SUBMITTED: "sessionSubmitted",
|
|
25515
|
+
CASE_CLOSED: "caseCloseRuled"
|
|
25516
|
+
});
|
|
25517
|
+
function shareTriggerLabel(code) {
|
|
25518
|
+
return SHARE_TRIGGER_EVENTS.find((t) => t.code === code)?.label ?? code;
|
|
25519
|
+
}
|
|
25520
|
+
var str2 = (v) => typeof v === "string" && v !== "";
|
|
25521
|
+
function policyIsShareListener(p) {
|
|
25522
|
+
if (p === null || p === void 0 || typeof p !== "object") return false;
|
|
25523
|
+
if (p.active === false) return false;
|
|
25524
|
+
if (p.cadences?.ongoing !== true) return false;
|
|
25525
|
+
const on = p.trigger?.on;
|
|
25526
|
+
if (!Array.isArray(on) || !on.some(str2)) return false;
|
|
25527
|
+
return p.trigger?.answers !== "received";
|
|
25528
|
+
}
|
|
25529
|
+
function linkTarget(a) {
|
|
25530
|
+
const withTeam = a.with !== null && typeof a.with === "object" && a.with.type === "team" && str2(a.with.id) ? a.with.id : null;
|
|
25531
|
+
if (str2(a.partnerId)) {
|
|
25532
|
+
return {
|
|
25533
|
+
recipient: { kind: "partner", id: a.partnerId },
|
|
25534
|
+
partnerTeamId: withTeam
|
|
25535
|
+
};
|
|
25536
|
+
}
|
|
25537
|
+
if (withTeam !== null) {
|
|
25538
|
+
return {
|
|
25539
|
+
recipient: { kind: "sibling_team", teamId: withTeam },
|
|
25540
|
+
partnerTeamId: null
|
|
25541
|
+
};
|
|
25542
|
+
}
|
|
25543
|
+
return null;
|
|
25544
|
+
}
|
|
25545
|
+
var targetKey = (l) => l.recipient.kind === "partner" ? ["partner", l.recipient.id, l.partnerTeamId] : ["team", l.recipient.teamId, null];
|
|
25546
|
+
function rowAgrees(rows, a, target) {
|
|
25547
|
+
const row = rows.find(
|
|
25548
|
+
(r) => r !== null && typeof r === "object" && r.id === a.teamRowId
|
|
25549
|
+
);
|
|
25550
|
+
if (row === void 0 || row.myTeamId !== a.teamId) return false;
|
|
25551
|
+
const theirTeam = row.their?.type === "team" && str2(row.their.id) ? row.their.id : null;
|
|
25552
|
+
return target.recipient.kind === "sibling_team" ? theirTeam === target.recipient.teamId : theirTeam === target.partnerTeamId;
|
|
25553
|
+
}
|
|
25554
|
+
function shareListenersFor(policies, teamId, options = {}) {
|
|
25555
|
+
if (!Array.isArray(policies) || !str2(teamId)) return [];
|
|
25556
|
+
const cells = attachmentIndexFromPolicies(policies).teamRows;
|
|
25557
|
+
const rows = Array.isArray(options.teamRows) ? options.teamRows : null;
|
|
25558
|
+
const out = [];
|
|
25559
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25560
|
+
for (const p of policies) {
|
|
25561
|
+
if (!policyIsShareListener(p) || !str2(p.id) || !str2(p.purpose)) continue;
|
|
25562
|
+
const events = (p.trigger?.on ?? []).filter(str2);
|
|
25563
|
+
if (str2(options.event) && !events.includes(options.event)) continue;
|
|
25564
|
+
for (const a of Array.isArray(p.assignments) ? p.assignments : []) {
|
|
25565
|
+
if (a === null || typeof a !== "object" || a.scope !== "team_pair")
|
|
25566
|
+
continue;
|
|
25567
|
+
if (!str2(a.teamRowId) || a.teamId !== teamId) continue;
|
|
25568
|
+
if (cells[a.teamRowId]?.[p.purpose] !== p.id) continue;
|
|
25569
|
+
const target = linkTarget(a);
|
|
25570
|
+
if (target === null) continue;
|
|
25571
|
+
if (rows !== null && !rowAgrees(rows, a, target)) continue;
|
|
25572
|
+
if (target.recipient.kind === "sibling_team" && target.recipient.teamId === teamId)
|
|
25573
|
+
continue;
|
|
25574
|
+
const dedupe = JSON.stringify([p.id, ...targetKey(target)]);
|
|
25575
|
+
if (seen.has(dedupe)) continue;
|
|
25576
|
+
seen.add(dedupe);
|
|
25577
|
+
out.push({
|
|
25578
|
+
policy: {
|
|
25579
|
+
id: p.id,
|
|
25580
|
+
familyId: str2(p.familyId) ? p.familyId : p.id,
|
|
25581
|
+
name: str2(p.name) ? p.name : p.id,
|
|
25582
|
+
version: parseInt(String(p.version), 10) || 1
|
|
25583
|
+
},
|
|
25584
|
+
purpose: p.purpose,
|
|
25585
|
+
fromTeamId: teamId,
|
|
25586
|
+
teamRowId: a.teamRowId,
|
|
25587
|
+
...target,
|
|
25588
|
+
events
|
|
25589
|
+
});
|
|
25590
|
+
}
|
|
25591
|
+
}
|
|
25592
|
+
return out;
|
|
25593
|
+
}
|
|
25594
|
+
function firedShareKey(event, ref, listener) {
|
|
25595
|
+
return JSON.stringify([
|
|
25596
|
+
event,
|
|
25597
|
+
ref,
|
|
25598
|
+
listener.policy.id,
|
|
25599
|
+
listener.fromTeamId,
|
|
25600
|
+
...targetKey(listener)
|
|
25601
|
+
]);
|
|
25602
|
+
}
|
|
25603
|
+
function fireShareEvent(policies, event, options = {}) {
|
|
25604
|
+
if (event === null || event === void 0 || !str2(event.event)) return [];
|
|
25605
|
+
const session = str2(event.sessionId) ? event.sessionId : null;
|
|
25606
|
+
const kase = str2(event.caseId) ? event.caseId : null;
|
|
25607
|
+
const ref = str2(event.ref) ? event.ref : event.event === SHARE_EVENT.SESSION_SUBMITTED ? session ?? kase : kase ?? session;
|
|
25608
|
+
const done = new Set(options.alreadyFired ?? []);
|
|
25609
|
+
const fired = [];
|
|
25610
|
+
for (const l of shareListenersFor(policies, event.teamId, {
|
|
25611
|
+
event: event.event,
|
|
25612
|
+
teamRows: options.teamRows ?? null
|
|
25613
|
+
})) {
|
|
25614
|
+
const key = firedShareKey(event.event, ref, l);
|
|
25615
|
+
if (done.has(key)) continue;
|
|
25616
|
+
fired.push({ ...l, event: event.event, ref, key });
|
|
25617
|
+
}
|
|
25618
|
+
return fired;
|
|
25619
|
+
}
|
|
25620
|
+
|
|
25160
25621
|
// src/validation/cvc.ts
|
|
25161
25622
|
import { z } from "zod";
|
|
25162
25623
|
var CvcCodeSchema = z.string().regex(/^\d{3}(-\d{3}){6}$/);
|
|
@@ -72853,10 +73314,12 @@ export {
|
|
|
72853
73314
|
SERVICE_STATE_STAMP_CROSSWALK,
|
|
72854
73315
|
SESSION_STATES,
|
|
72855
73316
|
SESSION_STATE_LABELS,
|
|
73317
|
+
SHARE_EVENT,
|
|
72856
73318
|
SHARE_LEVEL_LABEL,
|
|
72857
73319
|
SHARE_PLATFORM_STATE_LABEL,
|
|
72858
73320
|
SHARE_POSTURE_RANK,
|
|
72859
73321
|
SHARE_REPORTING_PURPOSES,
|
|
73322
|
+
SHARE_TRIGGER_EVENTS,
|
|
72860
73323
|
SHARE_VIEW,
|
|
72861
73324
|
SHARE_VIEW_LABELS,
|
|
72862
73325
|
SHARE_VIEW_VALUES,
|
|
@@ -72918,6 +73381,8 @@ export {
|
|
|
72918
73381
|
VALID_RECORD_STATES,
|
|
72919
73382
|
VICTIM_SERVING_ORG_TYPE_KEYS,
|
|
72920
73383
|
VIEWING_LEVEL_FUNCTIONS,
|
|
73384
|
+
VIEWING_POLICY_SPECIES,
|
|
73385
|
+
VIEWING_POLICY_VOCABULARIES,
|
|
72921
73386
|
VSP_TWO_STEP_ISSUE,
|
|
72922
73387
|
VehicleBodyTypeKeys,
|
|
72923
73388
|
VehicleColorKeys,
|
|
@@ -72974,6 +73439,9 @@ export {
|
|
|
72974
73439
|
carCorrectionReason_v2_1_0_default as carCorrectionReasonSot,
|
|
72975
73440
|
cascadeExclusions,
|
|
72976
73441
|
caseShareState_v1_2_0_default as caseShareStateSot,
|
|
73442
|
+
caseSurfacesAsStub,
|
|
73443
|
+
caseSurfacesOn,
|
|
73444
|
+
caseViewingAccess,
|
|
72977
73445
|
ceilingCoverage,
|
|
72978
73446
|
checkInActivity_v1_0_0_default as checkInActivitySot,
|
|
72979
73447
|
checkInPhase_v1_1_0_default as checkInPhaseSot,
|
|
@@ -73036,6 +73504,8 @@ export {
|
|
|
73036
73504
|
facilitatorEntityType_v1_0_0_default as facilitatorEntityTypeSot,
|
|
73037
73505
|
facilitatorLabelUsedInSource_v1_0_0_default as facilitatorLabelUsedInSourceSot,
|
|
73038
73506
|
facilitatorSubrole_v1_0_0_default as facilitatorSubroleSot,
|
|
73507
|
+
fireShareEvent,
|
|
73508
|
+
firedShareKey,
|
|
73039
73509
|
formModel_exports as formModel,
|
|
73040
73510
|
formSchemaDefinition,
|
|
73041
73511
|
formSchemaOptions,
|
|
@@ -73173,6 +73643,7 @@ export {
|
|
|
73173
73643
|
poPetitionBasis_v1_0_0_default as poPetitionBasisSot,
|
|
73174
73644
|
poStatus_v1_0_0_default as poStatusSot,
|
|
73175
73645
|
poViolationStatus_v1_0_0_default as poViolationStatusSot,
|
|
73646
|
+
policyIsShareListener,
|
|
73176
73647
|
preferredContactMethod_v1_0_0_default as preferredContactMethodSot,
|
|
73177
73648
|
primaryLanguage_v1_0_0_default as primaryLanguageSot,
|
|
73178
73649
|
programEnrollmentChangeType_v1_0_0_default as programEnrollmentChangeTypeSot,
|
|
@@ -73189,6 +73660,7 @@ export {
|
|
|
73189
73660
|
radiusBucket_v1_0_0_default as radiusBucketSot,
|
|
73190
73661
|
recencyBand_v1_0_0_default as recencyBandSot,
|
|
73191
73662
|
recordRemovalReason_v1_0_0_default as recordRemovalReasonSot,
|
|
73663
|
+
recordViewing,
|
|
73192
73664
|
referenceLinkType_v1_0_0_default as referenceLinkTypeSot,
|
|
73193
73665
|
referralEntityCategory_v1_2_0_default as referralEntityCategorySot,
|
|
73194
73666
|
referralOrigin_v1_0_0_default as referralOriginSot,
|
|
@@ -73207,6 +73679,7 @@ export {
|
|
|
73207
73679
|
resolveReferralEntityKeyFromLegacyNumeric,
|
|
73208
73680
|
resolveRegistryWithInheritance,
|
|
73209
73681
|
resolveShare,
|
|
73682
|
+
resolveViewingPolicy,
|
|
73210
73683
|
returnedToAbuserStatus_v1_0_0_default as returnedToAbuserStatusSot,
|
|
73211
73684
|
riskCategory_v1_0_0_default as riskCategorySot,
|
|
73212
73685
|
riskIdentificationMilestone_v1_0_0_default as riskIdentificationMilestoneSot,
|
|
@@ -73258,9 +73731,11 @@ export {
|
|
|
73258
73731
|
sexProviderSubrole_v1_0_0_default as sexProviderSubroleSot,
|
|
73259
73732
|
shareCadence_v1_0_0_default as shareCadenceSot,
|
|
73260
73733
|
shareDefaultScopeFor,
|
|
73734
|
+
shareListenersFor,
|
|
73261
73735
|
sharePurpose_v1_0_0_default as sharePurposeSot,
|
|
73262
73736
|
shareResponseReason_v1_0_0_default as shareResponseReasonSot,
|
|
73263
73737
|
shareRowCeiling,
|
|
73738
|
+
shareTriggerLabel,
|
|
73264
73739
|
sharingCeilingCellList,
|
|
73265
73740
|
sharingCeilingRowKey,
|
|
73266
73741
|
sharingScopeEditsFromCells,
|
|
@@ -73283,11 +73758,13 @@ export {
|
|
|
73283
73758
|
supportTopic_v1_0_0_default as supportTopicSot,
|
|
73284
73759
|
systemCategoryOf,
|
|
73285
73760
|
teamDirectorySchemaDefinition,
|
|
73761
|
+
teamViewingLevelFromPolicy,
|
|
73286
73762
|
threadStatus_v1_0_0_default as threadStatusSot,
|
|
73287
73763
|
threadType_v1_0_0_default as threadTypeSot,
|
|
73288
73764
|
timeScope_v1_0_0_default as timeScopeSot,
|
|
73289
73765
|
traffickingRelevantRole_v1_0_0_default as traffickingRelevantRoleSot,
|
|
73290
73766
|
tribes_v1_0_0_default as tribesSot,
|
|
73767
|
+
unavailableViewingPolicy,
|
|
73291
73768
|
userRoles_v2_0_0_default as userRolesSot,
|
|
73292
73769
|
vehicleBodyType_v1_0_0_default as vehicleBodyTypeSot,
|
|
73293
73770
|
vehicleColor_v1_0_0_default as vehicleColorSot,
|
|
@@ -73296,7 +73773,11 @@ export {
|
|
|
73296
73773
|
veteranStatus_v1_0_0_default as veteranStatusSot,
|
|
73297
73774
|
victimAbuseTypes_v1_1_0_default as victimAbuseTypesSot,
|
|
73298
73775
|
victimStatusFamily_v1_0_0_default as victimStatusFamilySot,
|
|
73776
|
+
viewingComponentOpen,
|
|
73299
73777
|
viewingLevelFromFunctions,
|
|
73778
|
+
viewingPolicyVocabulary,
|
|
73779
|
+
viewingRowVisible,
|
|
73780
|
+
viewingWhitelistFromPolicy,
|
|
73300
73781
|
visaType_v1_0_0_default as visaTypeSot,
|
|
73301
73782
|
visibilityRuleSchema,
|
|
73302
73783
|
vspTwoStepHolds,
|