@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htilabs/platform-common-models",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "Shared constants, types, and models for HTI Labs applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -101,6 +101,11 @@
|
|
|
101
101
|
"types": "./dist/age/index.d.ts",
|
|
102
102
|
"import": "./dist/age/index.js",
|
|
103
103
|
"require": "./dist/age/index.cjs"
|
|
104
|
+
},
|
|
105
|
+
"./share-rules": {
|
|
106
|
+
"types": "./dist/share-rules/index.d.ts",
|
|
107
|
+
"import": "./dist/share-rules/index.js",
|
|
108
|
+
"require": "./dist/share-rules/index.cjs"
|
|
104
109
|
}
|
|
105
110
|
},
|
|
106
111
|
"files": [
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ported from Thread `@thread/shared` `src/__tests__/caseShareLane.test.ts` @ thread develop
|
|
3
|
+
* f021be2, adapted only for import paths (unchanged otherwise).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* th-fbb8e — the ONE CaseShare landing rule (canon: the receiving team's
|
|
7
|
+
* first app; no team, or a team with no app, lands in PAVE — canon's fallback,
|
|
8
|
+
* Nate's N1 ruling; a LEADS-first team lands in Thread — the deviation).
|
|
9
|
+
*/
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
import {
|
|
12
|
+
CASE_SHARE_LANE_FAILURE,
|
|
13
|
+
agencyIdKey,
|
|
14
|
+
caseShareLandingLane,
|
|
15
|
+
caseShareLaneMismatch,
|
|
16
|
+
caseShareLaneUnverified,
|
|
17
|
+
caseShareLandingNeedsAgencyApps,
|
|
18
|
+
caseShareStaleTeamFailure,
|
|
19
|
+
pickDefaultShareTeam,
|
|
20
|
+
recipientUsesApp,
|
|
21
|
+
} from "../index.js";
|
|
22
|
+
|
|
23
|
+
/** The hosted platform-prod teams of Test Agency (602195579f782800111557d1). */
|
|
24
|
+
const PROGRAM_SERVICES = {
|
|
25
|
+
id: "69f137cb73a45dcd11bca1f0",
|
|
26
|
+
name: "Program Services",
|
|
27
|
+
apps: ["THREAD", "PAVE"],
|
|
28
|
+
};
|
|
29
|
+
const CRISIS_INTAKE = {
|
|
30
|
+
id: "69f137cb73a45dcd11bca1ec",
|
|
31
|
+
name: "Crisis Intake",
|
|
32
|
+
apps: ["PAVE", "THREAD"],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe("the shared helpers", () => {
|
|
36
|
+
it("recipientUsesApp: trimmed, case-insensitive, a bare string is one app", () => {
|
|
37
|
+
expect(recipientUsesApp(["PAVE", " thread "], "THREAD")).toBe(true);
|
|
38
|
+
expect(recipientUsesApp("Thread", "THREAD")).toBe(true);
|
|
39
|
+
expect(recipientUsesApp(["PAVE"], "THREAD")).toBe(false);
|
|
40
|
+
expect(recipientUsesApp([null, 7, ""], "THREAD")).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("agencyIdKey lower-cases a 24-hex id only", () => {
|
|
44
|
+
expect(agencyIdKey("602195579F782800111557D1")).toBe(
|
|
45
|
+
"602195579f782800111557d1",
|
|
46
|
+
);
|
|
47
|
+
expect(agencyIdKey("agency_HTI")).toBe("agency_HTI");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("caseShareLandingLane — the receiving team's first app", () => {
|
|
52
|
+
it("the hosted shapes: Program Services ['THREAD','PAVE'] → Thread; Crisis Intake ['PAVE','THREAD'] → PAVE", () => {
|
|
53
|
+
expect(
|
|
54
|
+
caseShareLandingLane({ name: "Test Agency", team: PROGRAM_SERVICES }),
|
|
55
|
+
).toEqual({ ok: true, lane: "thread", team: PROGRAM_SERVICES });
|
|
56
|
+
expect(
|
|
57
|
+
caseShareLandingLane({ name: "Test Agency", team: CRISIS_INTAKE }),
|
|
58
|
+
).toEqual({ ok: true, lane: "pave", team: CRISIS_INTAKE });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Nate's ruling (2026-10-16, N1 — 70 of 90 PAVE-only agencies on
|
|
62
|
+
// platform-prod have NO teams): follow canon's fallback — monolith L340192
|
|
63
|
+
// `_landApp = team.apps_used[0] || "pave"`, clamp L340201 @ c2900116.
|
|
64
|
+
it("no team lands in PAVE — canon's fallback (a PAVE-only or a dual-app agency alike)", () => {
|
|
65
|
+
for (const agencyApps of [["PAVE"], ["PAVE", "THREAD"], undefined]) {
|
|
66
|
+
expect(
|
|
67
|
+
caseShareLandingLane({ name: "Test Agency", agencyApps, team: null }),
|
|
68
|
+
).toEqual({ ok: true, lane: "pave", team: null });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("a team with no app, or a first app Thread cannot land in, lands in PAVE — canon's clamp", () => {
|
|
73
|
+
for (const apps of [
|
|
74
|
+
[],
|
|
75
|
+
undefined,
|
|
76
|
+
null,
|
|
77
|
+
["TRAIL"],
|
|
78
|
+
["pave"],
|
|
79
|
+
["ECHO", "THREAD"],
|
|
80
|
+
]) {
|
|
81
|
+
const team = { id: "t1", name: "Intake", apps };
|
|
82
|
+
expect(caseShareLandingLane({ name: "Test Agency", team })).toEqual({
|
|
83
|
+
ok: true,
|
|
84
|
+
lane: "pave",
|
|
85
|
+
team,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("the only refusals: a stale named team and an unreadable directory", () => {
|
|
91
|
+
expect(
|
|
92
|
+
caseShareLandingLane({ name: "Test Agency", team: "stale" }),
|
|
93
|
+
).toEqual({ ok: false, ...caseShareStaleTeamFailure("Test Agency") });
|
|
94
|
+
expect(caseShareStaleTeamFailure("Test Agency")).toEqual({
|
|
95
|
+
code: CASE_SHARE_LANE_FAILURE.TEAM_UNAVAILABLE,
|
|
96
|
+
message:
|
|
97
|
+
"The team you chose at Test Agency is no longer available — choose the team again.",
|
|
98
|
+
});
|
|
99
|
+
// No name: lower-case mid-sentence.
|
|
100
|
+
expect(caseShareStaleTeamFailure(undefined).message).toBe(
|
|
101
|
+
"The team you chose at the recipient is no longer available — choose the team again.",
|
|
102
|
+
);
|
|
103
|
+
expect(
|
|
104
|
+
caseShareLandingLane({ name: "Test Agency", team: "unverified" }),
|
|
105
|
+
).toMatchObject({ ok: false, code: CASE_SHARE_LANE_FAILURE.UNVERIFIED });
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Ruling (Nate, 2026-10-16): Thread cannot deliver into LEADS, so a team
|
|
110
|
+
// whose first app is LEADS lands as a THREAD CaseShare — as on develop before
|
|
111
|
+
// th-fbb8e (CATALOG #18, edge case 28). Mandated and legal-override reports to
|
|
112
|
+
// LEADS-only agencies keep working.
|
|
113
|
+
describe("LEADS → a THREAD CaseShare (recorded deviation)", () => {
|
|
114
|
+
it("a LEADS-first team lands in Thread", () => {
|
|
115
|
+
const tips = { id: "t1", name: "Tips", apps: ["LEADS", "PAVE"] };
|
|
116
|
+
expect(caseShareLandingLane({ name: "Police", team: tips })).toEqual({
|
|
117
|
+
ok: true,
|
|
118
|
+
lane: "thread",
|
|
119
|
+
team: tips,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("a LEADS-only agency with no team, or a team declaring no app, lands in Thread", () => {
|
|
124
|
+
expect(
|
|
125
|
+
caseShareLandingLane({
|
|
126
|
+
name: "Police",
|
|
127
|
+
agencyApps: ["LEADS"],
|
|
128
|
+
team: null,
|
|
129
|
+
}),
|
|
130
|
+
).toEqual({ ok: true, lane: "thread", team: null });
|
|
131
|
+
expect(
|
|
132
|
+
caseShareLandingLane({
|
|
133
|
+
name: "Police",
|
|
134
|
+
agencyApps: [" leads "],
|
|
135
|
+
team: { id: "t1", name: "Tips", apps: [] },
|
|
136
|
+
}),
|
|
137
|
+
).toMatchObject({ ok: true, lane: "thread" });
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("an agency on Thread or PAVE too lands in PAVE (canon's fallback, no deviation)", () => {
|
|
141
|
+
expect(
|
|
142
|
+
caseShareLandingLane({
|
|
143
|
+
name: "Police",
|
|
144
|
+
agencyApps: ["LEADS", "THREAD"],
|
|
145
|
+
team: null,
|
|
146
|
+
}),
|
|
147
|
+
).toEqual({ ok: true, lane: "pave", team: null });
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// N2: the LEADS-only reading decides only with no team or a team with no
|
|
151
|
+
// app — then unreadable agency apps are UNVERIFIED (retryable), never a
|
|
152
|
+
// permanent wrong lane.
|
|
153
|
+
it("unreadable agency apps are unverified only where they decide", () => {
|
|
154
|
+
expect(
|
|
155
|
+
caseShareLandingLane({
|
|
156
|
+
name: "Police",
|
|
157
|
+
agencyAppsUnread: true,
|
|
158
|
+
team: null,
|
|
159
|
+
}),
|
|
160
|
+
).toMatchObject({ ok: false, code: CASE_SHARE_LANE_FAILURE.UNVERIFIED });
|
|
161
|
+
expect(
|
|
162
|
+
caseShareLandingLane({
|
|
163
|
+
name: "Police",
|
|
164
|
+
agencyAppsUnread: true,
|
|
165
|
+
team: { id: "t1", name: "Tips", apps: [] },
|
|
166
|
+
}),
|
|
167
|
+
).toMatchObject({ ok: false, code: CASE_SHARE_LANE_FAILURE.UNVERIFIED });
|
|
168
|
+
expect(
|
|
169
|
+
caseShareLandingLane({
|
|
170
|
+
name: "Police",
|
|
171
|
+
agencyAppsUnread: true,
|
|
172
|
+
team: PROGRAM_SERVICES,
|
|
173
|
+
}),
|
|
174
|
+
).toMatchObject({ ok: true, lane: "thread" });
|
|
175
|
+
expect(caseShareLandingNeedsAgencyApps(null)).toBe(true);
|
|
176
|
+
expect(caseShareLandingNeedsAgencyApps(PROGRAM_SERVICES)).toBe(false);
|
|
177
|
+
expect(caseShareLandingNeedsAgencyApps("stale")).toBe(false);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe("pickDefaultShareTeam — canon's single-organization ladder", () => {
|
|
182
|
+
const a = { id: "b2", name: "B", apps: ["PAVE"] };
|
|
183
|
+
const b = { id: "a1", name: "A", apps: ["THREAD"] };
|
|
184
|
+
|
|
185
|
+
it("configured → declared → single → first by id", () => {
|
|
186
|
+
expect(pickDefaultShareTeam([a, b], "b2")?.via).toBe("configured");
|
|
187
|
+
// A 24-hex configured id matches its upper-case form.
|
|
188
|
+
expect(
|
|
189
|
+
pickDefaultShareTeam(
|
|
190
|
+
[{ ...a, id: "69f137cb73a45dcd11bca1ec" }, b],
|
|
191
|
+
"69F137CB73A45DCD11BCA1EC",
|
|
192
|
+
)?.via,
|
|
193
|
+
).toBe("configured");
|
|
194
|
+
expect(
|
|
195
|
+
pickDefaultShareTeam([a, { ...b, defaultTeam: true }], null)?.team.id,
|
|
196
|
+
).toBe("a1");
|
|
197
|
+
expect(pickDefaultShareTeam([a], null)?.via).toBe("auto_single");
|
|
198
|
+
expect(pickDefaultShareTeam([a, b], null)?.team.id).toBe("a1");
|
|
199
|
+
expect(pickDefaultShareTeam([], null)).toBeNull();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("two declared defaults are ambiguous and skipped", () => {
|
|
203
|
+
expect(
|
|
204
|
+
pickDefaultShareTeam(
|
|
205
|
+
[
|
|
206
|
+
{ ...a, defaultTeam: true },
|
|
207
|
+
{ ...b, defaultTeam: true },
|
|
208
|
+
],
|
|
209
|
+
null,
|
|
210
|
+
)?.via,
|
|
211
|
+
).toBe("first_team");
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("an in-app predicate (the intake resolver's PAVE) prefers that app's teams", () => {
|
|
215
|
+
const pave = (t: { apps: readonly unknown[] }) => t.apps[0] === "PAVE";
|
|
216
|
+
expect(pickDefaultShareTeam([a, b], null, pave)).toMatchObject({
|
|
217
|
+
team: { id: "b2" },
|
|
218
|
+
via: "auto_single_in_app",
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe("the mismatch and unverified refusals", () => {
|
|
224
|
+
it("name the team and the app it lands in", () => {
|
|
225
|
+
expect(
|
|
226
|
+
caseShareLaneMismatch(
|
|
227
|
+
{ name: "Test Agency", team: CRISIS_INTAKE },
|
|
228
|
+
"pave",
|
|
229
|
+
"thread",
|
|
230
|
+
),
|
|
231
|
+
).toEqual({
|
|
232
|
+
code: CASE_SHARE_LANE_FAILURE.MISMATCH,
|
|
233
|
+
message:
|
|
234
|
+
'The team "Crisis Intake" at Test Agency receives CaseShares in PAVE, so this share was not sent as it was composed — compose it again.',
|
|
235
|
+
});
|
|
236
|
+
expect(
|
|
237
|
+
caseShareLaneMismatch(
|
|
238
|
+
{ name: "Test Agency", team: PROGRAM_SERVICES },
|
|
239
|
+
"thread",
|
|
240
|
+
"thread",
|
|
241
|
+
),
|
|
242
|
+
).toBeNull();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("an unreadable configuration is retryable and promises no reload", () => {
|
|
246
|
+
const refusal = caseShareLaneUnverified("Test Agency");
|
|
247
|
+
expect(refusal.code).toBe(CASE_SHARE_LANE_FAILURE.UNVERIFIED);
|
|
248
|
+
expect(refusal.message).not.toMatch(/reload/i);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("a mismatch with no team (a LEADS-only agency) names the agency", () => {
|
|
252
|
+
expect(
|
|
253
|
+
caseShareLaneMismatch({ name: "Police", team: null }, "thread", "pave"),
|
|
254
|
+
).toMatchObject({
|
|
255
|
+
message:
|
|
256
|
+
"Police receives CaseShares in Thread, so this share was not sent as it was composed — compose it again.",
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ported from Thread `@thread/shared` `src/__tests__/magicLinkPartner.test.ts` @ thread develop
|
|
3
|
+
* f021be2, adapted only for import paths. NOT ported: the two
|
|
4
|
+
* `queuedSharePocSchema` blocks — they test Thread's zod wire schema, not
|
|
5
|
+
* these rules, and stay in Thread.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* th-9aynm / th-333y1 — the Magic Link partner rules, declared once in
|
|
9
|
+
* @thread/shared: `derivesOffPlatformRecipient` (the ONE "reached by a secure
|
|
10
|
+
* link" rule the API directory and the web read) and `magicLinkAddresses`
|
|
11
|
+
* (the ONE order / de-dup rule for a link's addresses).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, expect, it } from "vitest";
|
|
15
|
+
import {
|
|
16
|
+
derivesOffPlatformRecipient,
|
|
17
|
+
magicLinkAddressOverflow,
|
|
18
|
+
magicLinkAddresses,
|
|
19
|
+
MAGIC_LINK_MAX_ADDRESSES,
|
|
20
|
+
magicLinkToText,
|
|
21
|
+
magicLinkConfidentialOverflow,
|
|
22
|
+
magicLinkConfidentialOnly,
|
|
23
|
+
magicLinkPocHasVisibleAddress,
|
|
24
|
+
} from "../index.js";
|
|
25
|
+
|
|
26
|
+
describe("derivesOffPlatformRecipient (th-9aynm)", () => {
|
|
27
|
+
it("a row with no casework app, or no apps at all, is a Magic Link partner", () => {
|
|
28
|
+
expect(derivesOffPlatformRecipient({ apps: [] })).toBe(true);
|
|
29
|
+
expect(derivesOffPlatformRecipient({})).toBe(true);
|
|
30
|
+
expect(derivesOffPlatformRecipient({ apps: null })).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
it("a row on an app, and the caller's own agency, never are", () => {
|
|
33
|
+
expect(derivesOffPlatformRecipient({ apps: ["THREAD"] })).toBe(false);
|
|
34
|
+
expect(derivesOffPlatformRecipient({ isSelf: true, apps: [] })).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// th-333y1 — the ONE ordering / de-dup rule every surface applies to a magic
|
|
39
|
+
// link's addresses (composer, create door, drain).
|
|
40
|
+
describe("magicLinkAddresses (th-333y1)", () => {
|
|
41
|
+
it("keeps list order, trims, drops blanks, de-duplicates case-insensitively (first spelling wins)", () => {
|
|
42
|
+
expect(
|
|
43
|
+
magicLinkAddresses(
|
|
44
|
+
[" Typed@Partner.org ", "", null, undefined],
|
|
45
|
+
["intake@partner.org", "typed@partner.org", " "],
|
|
46
|
+
),
|
|
47
|
+
).toEqual(["Typed@Partner.org", "intake@partner.org"]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("caps the list at MAGIC_LINK_MAX_ADDRESSES and counts what it left out", () => {
|
|
51
|
+
const many = Array.from({ length: 40 }, (_, i) => `a${i}@x.org`);
|
|
52
|
+
expect(magicLinkAddresses(many)).toHaveLength(MAGIC_LINK_MAX_ADDRESSES);
|
|
53
|
+
expect(magicLinkAddressOverflow(many, ["A0@x.org"])).toBe(15);
|
|
54
|
+
expect(magicLinkAddressOverflow(["a@x.org"])).toBe(0);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// pl-iza — the canon sentence, a verbatim port of the prototype's
|
|
59
|
+
// `HTI_MAGIC_LINK_TO_TEXT` (HTI-LEADS-PAVE-Thread-prototype.html @ 184893b6
|
|
60
|
+
// L164656-L164663): visible addresses, then a COUNT of confidential holders.
|
|
61
|
+
describe("magicLinkToText (pl-iza, canon HTI_MAGIC_LINK_TO_TEXT)", () => {
|
|
62
|
+
it("prints the canon wording", () => {
|
|
63
|
+
expect(magicLinkToText(["a@x.org"], 1)).toBe(
|
|
64
|
+
"a@x.org + 1 confidential recipient",
|
|
65
|
+
);
|
|
66
|
+
expect(magicLinkToText(["a@x.org", "b@y.org"], 1)).toBe(
|
|
67
|
+
"a@x.org, b@y.org + 1 confidential recipient",
|
|
68
|
+
);
|
|
69
|
+
expect(magicLinkToText([], 1)).toBe("1 confidential recipient");
|
|
70
|
+
expect(magicLinkToText([], 3)).toBe("3 confidential recipients");
|
|
71
|
+
expect(magicLinkToText(["a@x.org"], 0)).toBe("a@x.org");
|
|
72
|
+
expect(magicLinkToText(null, undefined)).toBe("");
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe("magicLinkConfidentialOverflow (pl-iza)", () => {
|
|
77
|
+
it("counts the holders past the cap once the visible addresses are counted", () => {
|
|
78
|
+
expect(magicLinkConfidentialOverflow(24, 3)).toBe(2);
|
|
79
|
+
expect(magicLinkConfidentialOverflow(25, 1)).toBe(1);
|
|
80
|
+
expect(magicLinkConfidentialOverflow(10, 3)).toBe(0);
|
|
81
|
+
expect(magicLinkConfidentialOverflow(0, undefined)).toBe(0);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe("magicLinkConfidentialOnly / magicLinkPocHasVisibleAddress (pl-iza)", () => {
|
|
86
|
+
it("is confidential-only exactly when the count is the sole address", () => {
|
|
87
|
+
expect(magicLinkConfidentialOnly({ confidentialCount: 1 })).toBe(true);
|
|
88
|
+
expect(
|
|
89
|
+
magicLinkConfidentialOnly({ email: " ", confidentialCount: 1 }),
|
|
90
|
+
).toBe(true);
|
|
91
|
+
expect(
|
|
92
|
+
magicLinkConfidentialOnly({ email: "a@x.org", confidentialCount: 1 }),
|
|
93
|
+
).toBe(false);
|
|
94
|
+
expect(
|
|
95
|
+
magicLinkConfidentialOnly({
|
|
96
|
+
addedEmails: ["a@x.org"],
|
|
97
|
+
confidentialCount: 1,
|
|
98
|
+
}),
|
|
99
|
+
).toBe(false);
|
|
100
|
+
expect(magicLinkConfidentialOnly({ confidentialCount: 0 })).toBe(false);
|
|
101
|
+
expect(magicLinkConfidentialOnly(undefined)).toBe(false);
|
|
102
|
+
expect(magicLinkPocHasVisibleAddress({ contactEmails: ["c@x.org"] })).toBe(
|
|
103
|
+
true,
|
|
104
|
+
);
|
|
105
|
+
expect(magicLinkPocHasVisibleAddress({})).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ported from Thread `@thread/shared` `src/__tests__/shareEdge.test.ts` (the
|
|
3
|
+
* `recipientPlatformFromApps` block; `networkReachFor` stays in Thread) and
|
|
4
|
+
* `teamLanding.test.ts` (whole) @ thread develop f021be2, adapted only for
|
|
5
|
+
* import paths.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* th-a2dfb — the ONE on/off-platform derivation (`recipientPlatformFromApps`)
|
|
9
|
+
* decides on-platform by the daily casework apps only, exactly as the
|
|
10
|
+
* platform's `networkReachFor` (platform-prototype src/agencyhub.jsx
|
|
11
|
+
* L8708-8711 @ 0fa04c1):
|
|
12
|
+
*
|
|
13
|
+
* const daily = (appsUsed || []).filter(a =>
|
|
14
|
+
* ["thread", "pave", "leads"].includes(String(a).toLowerCase()));
|
|
15
|
+
* return daily.length ? "in_network" : "magic_link";
|
|
16
|
+
*
|
|
17
|
+
* The picker's reach chip and the share's routing lane both read it, so an
|
|
18
|
+
* org on TRAIL alone is a Magic Link row AND rides the magic link. The basis
|
|
19
|
+
* the edge stores keeps every app as read (audit), casework or not. PAVE
|
|
20
|
+
* parity (pave-2.0 `packages/domain/src/networkReach.ts`): tokens match
|
|
21
|
+
* trimmed, and a bare-string `apps` value is a one-item list.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { describe, expect, it } from "vitest";
|
|
25
|
+
import {
|
|
26
|
+
recipientPlatformFromApps,
|
|
27
|
+
teamLandingApp,
|
|
28
|
+
teamLandsInPave,
|
|
29
|
+
teamLandsInThread,
|
|
30
|
+
} from "../index.js";
|
|
31
|
+
|
|
32
|
+
describe("recipientPlatformFromApps — on-platform by casework apps, basis as read (th-a2dfb)", () => {
|
|
33
|
+
it.each([
|
|
34
|
+
[["THREAD"], ["THREAD"]],
|
|
35
|
+
[["PAVE"], ["PAVE"]],
|
|
36
|
+
[["LEADS"], ["LEADS"]],
|
|
37
|
+
[
|
|
38
|
+
["thread", "Pave"],
|
|
39
|
+
["thread", "Pave"],
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
["TRAIL", "PAVE"],
|
|
43
|
+
["TRAIL", "PAVE"],
|
|
44
|
+
],
|
|
45
|
+
[["PAVE", 7], ["PAVE"]],
|
|
46
|
+
[[null, "LEADS"], ["LEADS"]],
|
|
47
|
+
// tokens match trimmed; the basis keeps them as written
|
|
48
|
+
[["PAVE "], ["PAVE "]],
|
|
49
|
+
[[" thread"], [" thread"]],
|
|
50
|
+
[["\tPAVE\r\n"], ["\tPAVE\r\n"]],
|
|
51
|
+
// a bare-string value is a one-item list
|
|
52
|
+
["PAVE", ["PAVE"]],
|
|
53
|
+
[" leads ", [" leads "]],
|
|
54
|
+
] as const)("%j is on-platform", (apps, basis) => {
|
|
55
|
+
expect(recipientPlatformFromApps(apps)).toEqual({
|
|
56
|
+
recipientOnPlatform: true,
|
|
57
|
+
recipientOnPlatformBasis: basis,
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it.each([
|
|
62
|
+
[["TRAIL"], ["TRAIL"]],
|
|
63
|
+
[["ECHO"], ["ECHO"]],
|
|
64
|
+
[["PLATFORM"], ["PLATFORM"]],
|
|
65
|
+
[
|
|
66
|
+
["TRAIL", "ECHO", "PLATFORM"],
|
|
67
|
+
["TRAIL", "ECHO", "PLATFORM"],
|
|
68
|
+
],
|
|
69
|
+
[[null, "TRAIL"], ["TRAIL"]],
|
|
70
|
+
[["threads"], ["threads"]],
|
|
71
|
+
["TRAIL", ["TRAIL"]],
|
|
72
|
+
// ASCII whitespace only is trimmed (the listing query's PCRE \s): a
|
|
73
|
+
// non-breaking-space-padded token is not a casework app.
|
|
74
|
+
[["PAVE\u00a0"], ["PAVE\u00a0"]],
|
|
75
|
+
[["\u00a0THREAD"], ["\u00a0THREAD"]],
|
|
76
|
+
[[""], []],
|
|
77
|
+
[[], []],
|
|
78
|
+
["", []],
|
|
79
|
+
[7, []],
|
|
80
|
+
[null, []],
|
|
81
|
+
[undefined, []],
|
|
82
|
+
] as const)(
|
|
83
|
+
"%j is off-platform, the basis keeping the apps as read",
|
|
84
|
+
(apps, basis) => {
|
|
85
|
+
expect(recipientPlatformFromApps(apps)).toEqual({
|
|
86
|
+
recipientOnPlatform: false,
|
|
87
|
+
recipientOnPlatformBasis: basis,
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
it("counts exactly the three daily casework apps", () => {
|
|
93
|
+
for (const app of ["THREAD", "PAVE", "LEADS", "thread", "Pave", "leads"]) {
|
|
94
|
+
expect(recipientPlatformFromApps([app]).recipientOnPlatform).toBe(true);
|
|
95
|
+
}
|
|
96
|
+
for (const app of ["TRAIL", "ECHO", "PLATFORM", "LEAD", "PAVE2"]) {
|
|
97
|
+
expect(recipientPlatformFromApps([app]).recipientOnPlatform).toBe(false);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// ─── Thread teamLanding.test.ts ─────────────────────────────────────────────
|
|
103
|
+
// The team landing predicate (th-ng838.4 fix round MINOR-1): ONE reading of
|
|
104
|
+
// "where does a share to this team land" — canon `_landApp = apps_used[0]`
|
|
105
|
+
// (monolith L321353 @ prototype 94ee0702).
|
|
106
|
+
|
|
107
|
+
describe("teamLandingApp — the first declared app", () => {
|
|
108
|
+
it("is apps[0]", () => {
|
|
109
|
+
expect(teamLandingApp(["PAVE", "THREAD"])).toBe("PAVE");
|
|
110
|
+
expect(teamLandingApp(["THREAD", "PAVE"])).toBe("THREAD");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("is undefined when nothing usable is declared", () => {
|
|
114
|
+
expect(teamLandingApp(undefined)).toBeUndefined();
|
|
115
|
+
expect(teamLandingApp(null)).toBeUndefined();
|
|
116
|
+
expect(teamLandingApp([])).toBeUndefined();
|
|
117
|
+
expect(teamLandingApp([7])).toBeUndefined();
|
|
118
|
+
expect(teamLandingApp([""])).toBeUndefined();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe("teamLandsInPave / teamLandsInThread", () => {
|
|
123
|
+
it("a team listing PAVE second does NOT land in PAVE", () => {
|
|
124
|
+
expect(teamLandsInPave(["THREAD", "PAVE"])).toBe(false);
|
|
125
|
+
expect(teamLandsInThread(["THREAD", "PAVE"])).toBe(true);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("matches the uppercase PLATFORM_TOOL codes only", () => {
|
|
129
|
+
expect(teamLandsInPave(["PAVE"])).toBe(true);
|
|
130
|
+
expect(teamLandsInPave(["pave"])).toBe(false);
|
|
131
|
+
expect(teamLandsInThread(["thread"])).toBe(false);
|
|
132
|
+
});
|
|
133
|
+
});
|