@htilabs/platform-common-models 0.30.0 → 0.32.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 +107 -1
- package/dist/{index-Pt82NxQg.d.cts → index-BTqHP4DM.d.cts} +1 -1
- package/dist/{index-ClTjjJ_S.d.ts → index-Dr6GBCoY.d.ts} +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/points-of-contact/index.cjs +135 -16
- package/dist/points-of-contact/index.cjs.map +1 -1
- package/dist/points-of-contact/index.d.cts +128 -5
- package/dist/points-of-contact/index.d.ts +128 -5
- package/dist/points-of-contact/index.js +134 -16
- package/dist/points-of-contact/index.js.map +1 -1
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/package.json +1 -1
- package/src/pointsOfContact/__tests__/pointsOfContact.test.ts +447 -0
- package/src/pointsOfContact/__tests__/reader.mongo.test.ts +211 -0
- package/src/pointsOfContact/index.ts +3 -1
- package/src/pointsOfContact/readRules.ts +8 -1
- package/src/pointsOfContact/reader.ts +353 -37
- package/src/pointsOfContact/vocabulary.ts +4 -1
- package/dist/{cvcEntry-Asg7mxjB.d.cts → cvcEntry-BqAGctqK.d.cts} +8 -8
- package/dist/{cvcEntry-Asg7mxjB.d.ts → cvcEntry-BqAGctqK.d.ts} +8 -8
|
@@ -96,7 +96,10 @@ declare const CONTACT_PURPOSES: readonly ContactPurpose[];
|
|
|
96
96
|
/**
|
|
97
97
|
* The magic-link purpose. A magic link goes to EVERY contact on the partner
|
|
98
98
|
* carrying it (Crysta 2026-08-23, restated 2026-10-14), and a contact carrying
|
|
99
|
-
* it must have an email (Crysta 2026-10-14, the Admin Hub editor rule).
|
|
99
|
+
* it must have an email (Crysta 2026-10-14, the Admin Hub editor rule). CVC-338
|
|
100
|
+
* (prototype `data/cvcs/core_contact_purpose.yaml` @ 184893b6 L95): "A
|
|
101
|
+
* confidential holder still receives it; the sender never sees the address."
|
|
102
|
+
* (pl-iza: `resolveMagicLinkRecipients`, `ConfidentialReferralRecipients`.)
|
|
100
103
|
*/
|
|
101
104
|
declare const REFERRALS_MAGIC_LINK_PURPOSE: ContactPurposeCode;
|
|
102
105
|
declare function isContactPurposeCode(code: unknown): code is ContactPurposeCode;
|
|
@@ -1090,7 +1093,14 @@ declare function pocIdentityKey(c: Pick<PointOfContactDoc, "user_id" | "person_i
|
|
|
1090
1093
|
* `Org + Personnel Registry/DIRECTORY_CSV_EDITING_GUIDE.md` @ 6c2db859
|
|
1091
1094
|
* § 0.9 L958; hti-features `PointOfContact.v1.json` `is_confidential`:
|
|
1092
1095
|
* "Never publish this contact"), so it is left out entirely rather
|
|
1093
|
-
* than masked
|
|
1096
|
+
* than masked. The network view is unchanged by pl-iza (0.32.0):
|
|
1097
|
+
* confidential rows are absent from every view another organization
|
|
1098
|
+
* sees (this view, `getContact`, `listContactsForSubject`, the
|
|
1099
|
+
* referral `recipients`; only the subject's owner and the steward see
|
|
1100
|
+
* them). A confidential Referrals (magic link) holder still receives
|
|
1101
|
+
* the magic link, but only through the send-only
|
|
1102
|
+
* `resolveMagicLinkRecipients` (`./reader.ts`), which never projects
|
|
1103
|
+
* the row and exposes a count;
|
|
1094
1104
|
* - the seat / person links, `notes`, review stamps, actor ids and the
|
|
1095
1105
|
* identity key are not projected.
|
|
1096
1106
|
* - **Owner view** ({@link toOwnerView}): the subject's own editor (Admin
|
|
@@ -1203,6 +1213,19 @@ declare function byContactReadingOrder(a: Pick<PointOfContactDoc, "subject_type"
|
|
|
1203
1213
|
* ObjectId filter for `users._id`; the reader passes a {@link SeatResolver}
|
|
1204
1214
|
* that reads its own `users`. The partner rollup REQUIRES one, so a reader
|
|
1205
1215
|
* cannot silently drop seat-linked referral contacts.
|
|
1216
|
+
*
|
|
1217
|
+
* ## Confidential Referrals (magic link) holders (pl-iza, 0.32.0)
|
|
1218
|
+
*
|
|
1219
|
+
* A confidential holder still receives the magic link; the sender never sees
|
|
1220
|
+
* the address (CVC-338, prototype `data/cvcs/core_contact_purpose.yaml` @
|
|
1221
|
+
* 184893b6 L95; HANDOFF.md @ 184893b6 L569, L575 "POC-PROFILE-ALIGNMENTS"
|
|
1222
|
+
* D(ii)). Confidential rows are absent from every view another organization
|
|
1223
|
+
* sees (only the owner and steward reads carry them). The referral rollup
|
|
1224
|
+
* reads them in a SEPARATE query and hands out only a count
|
|
1225
|
+
* (`confidentialCount`) or, to a send, a {@link ConfidentialReferralRecipients}
|
|
1226
|
+
* whose `deliver` alone touches the addresses (the implementation is not
|
|
1227
|
+
* exported). A confidential row never reaches `unreachable`, and a corrupt
|
|
1228
|
+
* row that may be confidential is counted, never thrown.
|
|
1206
1229
|
*/
|
|
1207
1230
|
|
|
1208
1231
|
/** The slice of a driver `Collection` the reads use. */
|
|
@@ -1280,8 +1303,20 @@ interface ReferralContactsOptions {
|
|
|
1280
1303
|
interface ReferralContactsResult {
|
|
1281
1304
|
/** One per distinct email, in reading order (the agency's own contacts first). */
|
|
1282
1305
|
recipients: ReferralRecipient[];
|
|
1283
|
-
/**
|
|
1306
|
+
/**
|
|
1307
|
+
* Ids of tagged, VISIBLE contacts with no email to send to (a seat whose
|
|
1308
|
+
* `users` row has none). Never a confidential holder's id.
|
|
1309
|
+
*/
|
|
1284
1310
|
unreachable: string[];
|
|
1311
|
+
/**
|
|
1312
|
+
* The number of distinct confidential Referrals (magic link) holder
|
|
1313
|
+
* addresses (pl-iza): active, confirmed, `is_confidential`, tagged, on the
|
|
1314
|
+
* same rollup. Deduped among the confidential holders ONLY, never against
|
|
1315
|
+
* any visible, pending, typed or added address, so no other row or input
|
|
1316
|
+
* moves it. A sender sees this number, never a name, an id or an address
|
|
1317
|
+
* ("+ 1 confidential recipient").
|
|
1318
|
+
*/
|
|
1319
|
+
confidentialCount: number;
|
|
1285
1320
|
}
|
|
1286
1321
|
/**
|
|
1287
1322
|
* The partner's Referrals (magic link) contacts: every active, confirmed,
|
|
@@ -1296,9 +1331,97 @@ interface ReferralContactsResult {
|
|
|
1296
1331
|
* own pending in-app adds on the partner, so a contact they just added can be
|
|
1297
1332
|
* picked before HTI Labs confirms it (pending, marked, after the confirmed
|
|
1298
1333
|
* recipients; an email a confirmed recipient already has is not repeated).
|
|
1299
|
-
* Confidential rows stay
|
|
1334
|
+
* Confidential rows stay out of `recipients` and `unreachable`; they are
|
|
1335
|
+
* counted (`confidentialCount`, pl-iza) and reached only through
|
|
1336
|
+
* {@link resolveMagicLinkRecipients}. The partner has a
|
|
1337
|
+
* magic-link holder when `recipients.length + confidentialCount > 0`.
|
|
1300
1338
|
*/
|
|
1301
1339
|
declare function listReferralContactsForPartner(db: PocDbLike, partner: PocPartnerSelector, opts: ReferralContactsOptions): Promise<ReferralContactsResult>;
|
|
1340
|
+
/** What a send needs: the visible recipients, plus the confidential holders behind a count. */
|
|
1341
|
+
interface MagicLinkSendList {
|
|
1342
|
+
/** As {@link ReferralContactsResult.recipients}. */
|
|
1343
|
+
recipients: ReferralRecipient[];
|
|
1344
|
+
/** As {@link ReferralContactsResult.unreachable}: visible contacts only. */
|
|
1345
|
+
unreachable: string[];
|
|
1346
|
+
/** The confidential holders: a count, and a `deliver` that alone touches their addresses. */
|
|
1347
|
+
confidential: ConfidentialReferralRecipients;
|
|
1348
|
+
/**
|
|
1349
|
+
* SERVER-SIDE diagnostic, never returned to a sender: the confidential
|
|
1350
|
+
* holder rows that cannot be sent to (no email, a seat with none or not
|
|
1351
|
+
* found), plus skipped rows that do not match the contract and may be
|
|
1352
|
+
* confidential (their error would name their id). A count, never an id.
|
|
1353
|
+
*/
|
|
1354
|
+
confidentialUnreachableCount: number;
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* SEND-ONLY (pl-iza). The same read as {@link listReferralContactsForPartner},
|
|
1358
|
+
* with the confidential holders as a {@link ConfidentialReferralRecipients}
|
|
1359
|
+
* instead of a bare count. Call it at send time, server-side, and hand
|
|
1360
|
+
* `confidential.deliver` the mailer; never return the result to a browser
|
|
1361
|
+
* beyond `confidential.count` (its `toJSON` is `{ count }`). This is the only
|
|
1362
|
+
* way to obtain a `ConfidentialReferralRecipients` (the implementation is
|
|
1363
|
+
* not exported).
|
|
1364
|
+
*
|
|
1365
|
+
* Canon: CVC-338 `REFERRALS_MAGIC_LINK` (prototype
|
|
1366
|
+
* `data/cvcs/core_contact_purpose.yaml` @ 184893b6 L95): "A confidential
|
|
1367
|
+
* holder still receives it; the sender never sees the address."
|
|
1368
|
+
*/
|
|
1369
|
+
declare function resolveMagicLinkRecipients(db: PocDbLike, partner: PocPartnerSelector, opts: ReferralContactsOptions): Promise<MagicLinkSendList>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Sends one magic link to one address. It must THROW (or reject) on failure;
|
|
1372
|
+
* returning normally counts as delivered. It must not log, persist or return
|
|
1373
|
+
* `address`.
|
|
1374
|
+
*/
|
|
1375
|
+
type ConfidentialSendOne = (address: string) => void | Promise<void>;
|
|
1376
|
+
interface ConfidentialDeliverOptions {
|
|
1377
|
+
/** At most this many sends (a non-negative integer); the rest are `overflow`. Unlimited when omitted. */
|
|
1378
|
+
capacity?: number;
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* A confidential delivery's outcome: numbers and an error class name, never an
|
|
1382
|
+
* address. SERVER-SIDE, for audit only: a sender may see `count`, or one
|
|
1383
|
+
* all-or-nothing status derived from it, never `delivered`, `failed`,
|
|
1384
|
+
* `overflow` or `firstErrorName`.
|
|
1385
|
+
*/
|
|
1386
|
+
interface ConfidentialDeliveryResult {
|
|
1387
|
+
/** The holder count (`delivered + failed + overflow`). */
|
|
1388
|
+
count: number;
|
|
1389
|
+
delivered: number;
|
|
1390
|
+
failed: number;
|
|
1391
|
+
/** Holders beyond `capacity`, not sent: `max(0, count - capacity)`. */
|
|
1392
|
+
overflow: number;
|
|
1393
|
+
/** The first failed send's `err.name` (never its message, which can echo the address), or null. */
|
|
1394
|
+
firstErrorName: string | null;
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* A partner's confidential Referrals (magic link) holders (pl-iza). It carries
|
|
1398
|
+
* their addresses privately and exposes only `count`: `toJSON()` is
|
|
1399
|
+
* `{ count }`, `util.inspect` draws `ConfidentialReferralRecipients(n)`, and
|
|
1400
|
+
* no public member returns an address. Only {@link deliver} touches them,
|
|
1401
|
+
* handing each to the caller's `sendOne`.
|
|
1402
|
+
*
|
|
1403
|
+
* An interface, exported as a type only. The implementation is not
|
|
1404
|
+
* exported: obtain values only via {@link resolveMagicLinkRecipients}.
|
|
1405
|
+
*/
|
|
1406
|
+
interface ConfidentialReferralRecipients {
|
|
1407
|
+
readonly count: number;
|
|
1408
|
+
/**
|
|
1409
|
+
* Sends to the first `capacity` holders (all when omitted), one at a time.
|
|
1410
|
+
* The outcome depends only on the holders, `capacity` and each send's
|
|
1411
|
+
* result, never on any address the caller handled: an address the sender
|
|
1412
|
+
* also typed is sent again, so nothing observable moves when one matches.
|
|
1413
|
+
* Never rejects for a failed send: each error is caught and only its `name`
|
|
1414
|
+
* is kept (a provider's message can echo the address). The result is
|
|
1415
|
+
* server-side only (see {@link ConfidentialDeliveryResult}).
|
|
1416
|
+
*/
|
|
1417
|
+
deliver(sendOne: ConfidentialSendOne, opts?: ConfidentialDeliverOptions): Promise<ConfidentialDeliveryResult>;
|
|
1418
|
+
/** `{ count }`: what a response, a record or an event may carry. */
|
|
1419
|
+
toJSON(): {
|
|
1420
|
+
count: number;
|
|
1421
|
+
};
|
|
1422
|
+
/** `ConfidentialReferralRecipients(n)`. */
|
|
1423
|
+
toString(): string;
|
|
1424
|
+
}
|
|
1302
1425
|
/** One contact as other organizations see it, or null (absent or not network-visible). */
|
|
1303
1426
|
declare function getContact(db: PocDbLike, id: string, opts?: {
|
|
1304
1427
|
resolveSeats?: SeatResolver;
|
|
@@ -1581,4 +1704,4 @@ interface MintPartnerContactArgs {
|
|
|
1581
1704
|
*/
|
|
1582
1705
|
declare function mintPartnerContact(db: PocWriteDbLike, args: MintPartnerContactArgs, driver: PocWriterDriver): Promise<PartnerContactResult>;
|
|
1583
1706
|
|
|
1584
|
-
export { CONTACT_PURPOSES, CONTACT_PURPOSE_CODES, type ContactPurpose, type ContactPurposeCode, type MintPartnerContactArgs, PARTNER_CONTACT_FAILURE_REASONS, POC_ADDED_IN_APPS, POC_IDENTITY_INDEX_FILTER, POC_ID_PATTERN, POC_IN_APP_PENDING_CAP_PER_ACTOR, POC_IN_APP_PENDING_CAP_PER_PARTNER, POC_IN_APP_PENDING_INDEX, POC_IN_APP_PENDING_INDEX_FILTER, POC_IN_APP_PENDING_INDEX_KEY, POC_MAX_CONTACT_ENTRIES, POC_ORIGINS, POC_PARTNER_ADD_APPS, POC_PENDING_QUEUE_INDEX, POC_PRIMARY_INDEX_FILTER, POC_STATUSES, POC_SUBJECT_TYPES, POC_SUBJECT_TYPE_LABELS, POC_URGENT_METHODS, POC_URGENT_METHOD_KEYS, POINTS_OF_CONTACT_COLLECTION, POINT_OF_CONTACT_INDEXES, type PartnerContactFailure, type PartnerContactFailureReason, type PartnerContactReceipt, type PartnerContactResult, type PartnerContactSelector, type PartnerContactSelectorInput, PartnerContactSelectorSchema, type PocAddedInApp, type PocCollectionLike, type PocContactEntry, type PocCreateIndexOptions, type PocDbLike, type PocDetails, type PocDetailsInput, PocDetailsSchema, PocEmailListSchema, PocEmailSchema, type PocInApp, type PocInAppActor, type PocInAppInput, PocInAppSchema, type PocIndexInfoLike, PocLinkIdSchema, type PocObjectIdClass, type PocOrigin, type PocOwner, PocOwnerSchema, type PocPartnerAddApp, type PocPartnerSelector, type PocPatch, type PocPatchInput, PocPatchSchema, PocPhoneListSchema, type PocRuleInput, type PocRuleViolation, type PocSeed, type PocSeedInput, PocSeedSchema, type PocStatus, type PocSubjectRef, type PocSubjectType, type PocUrgentMethod, type PocWriteCollectionLike, type PocWriteCursorLike, type PocWriteDbLike, type PocWriterDriver, type PointOfContactDoc, PointOfContactDocSchema, type PointOfContactNetworkView, type PointOfContactOwnerView, PointOfContactShapeError, type PointOfContactStewardView, REFERRALS_MAGIC_LINK_PURPOSE, type ReferralContactsOptions, type ReferralContactsResult, type ReferralRecipient, type SeatReach, type SeatResolver, StoredContactEntrySchema, StoredEmailListSchema, StoredPhoneListSchema, byContactReadingOrder, checkPocIndexes, contactPurposeLabel, definedPatch, ensurePocIndexes, formatPocPhone, getContact, isContactPurposeCode, isNetworkVisible, isPocUrgentMethodCode, listContactsForSubject, listOwnerContactsForSubject, listPendingContacts, listReferralContactsForPartner, mintPartnerContact, normalizePointOfContact, pocDuplicateKeyFailure, pocIdentityKey, pocInitialStatus, pocPhoneDigits, pocRowsWithIdentity, pocRuleViolations, pocSubjectTypeLabel, pocUrgentMethodCode, preferredContactEntry, preferredEmail, preferredPhone, toNetworkView, toOwnerView, toStewardView };
|
|
1707
|
+
export { CONTACT_PURPOSES, CONTACT_PURPOSE_CODES, type ConfidentialDeliverOptions, type ConfidentialDeliveryResult, type ConfidentialReferralRecipients, type ConfidentialSendOne, type ContactPurpose, type ContactPurposeCode, type MagicLinkSendList, type MintPartnerContactArgs, PARTNER_CONTACT_FAILURE_REASONS, POC_ADDED_IN_APPS, POC_IDENTITY_INDEX_FILTER, POC_ID_PATTERN, POC_IN_APP_PENDING_CAP_PER_ACTOR, POC_IN_APP_PENDING_CAP_PER_PARTNER, POC_IN_APP_PENDING_INDEX, POC_IN_APP_PENDING_INDEX_FILTER, POC_IN_APP_PENDING_INDEX_KEY, POC_MAX_CONTACT_ENTRIES, POC_ORIGINS, POC_PARTNER_ADD_APPS, POC_PENDING_QUEUE_INDEX, POC_PRIMARY_INDEX_FILTER, POC_STATUSES, POC_SUBJECT_TYPES, POC_SUBJECT_TYPE_LABELS, POC_URGENT_METHODS, POC_URGENT_METHOD_KEYS, POINTS_OF_CONTACT_COLLECTION, POINT_OF_CONTACT_INDEXES, type PartnerContactFailure, type PartnerContactFailureReason, type PartnerContactReceipt, type PartnerContactResult, type PartnerContactSelector, type PartnerContactSelectorInput, PartnerContactSelectorSchema, type PocAddedInApp, type PocCollectionLike, type PocContactEntry, type PocCreateIndexOptions, type PocDbLike, type PocDetails, type PocDetailsInput, PocDetailsSchema, PocEmailListSchema, PocEmailSchema, type PocInApp, type PocInAppActor, type PocInAppInput, PocInAppSchema, type PocIndexInfoLike, PocLinkIdSchema, type PocObjectIdClass, type PocOrigin, type PocOwner, PocOwnerSchema, type PocPartnerAddApp, type PocPartnerSelector, type PocPatch, type PocPatchInput, PocPatchSchema, PocPhoneListSchema, type PocRuleInput, type PocRuleViolation, type PocSeed, type PocSeedInput, PocSeedSchema, type PocStatus, type PocSubjectRef, type PocSubjectType, type PocUrgentMethod, type PocWriteCollectionLike, type PocWriteCursorLike, type PocWriteDbLike, type PocWriterDriver, type PointOfContactDoc, PointOfContactDocSchema, type PointOfContactNetworkView, type PointOfContactOwnerView, PointOfContactShapeError, type PointOfContactStewardView, REFERRALS_MAGIC_LINK_PURPOSE, type ReferralContactsOptions, type ReferralContactsResult, type ReferralRecipient, type SeatReach, type SeatResolver, StoredContactEntrySchema, StoredEmailListSchema, StoredPhoneListSchema, byContactReadingOrder, checkPocIndexes, contactPurposeLabel, definedPatch, ensurePocIndexes, formatPocPhone, getContact, isContactPurposeCode, isNetworkVisible, isPocUrgentMethodCode, listContactsForSubject, listOwnerContactsForSubject, listPendingContacts, listReferralContactsForPartner, mintPartnerContact, normalizePointOfContact, pocDuplicateKeyFailure, pocIdentityKey, pocInitialStatus, pocPhoneDigits, pocRowsWithIdentity, pocRuleViolations, pocSubjectTypeLabel, pocUrgentMethodCode, preferredContactEntry, preferredEmail, preferredPhone, resolveMagicLinkRecipients, toNetworkView, toOwnerView, toStewardView };
|
|
@@ -96,7 +96,10 @@ declare const CONTACT_PURPOSES: readonly ContactPurpose[];
|
|
|
96
96
|
/**
|
|
97
97
|
* The magic-link purpose. A magic link goes to EVERY contact on the partner
|
|
98
98
|
* carrying it (Crysta 2026-08-23, restated 2026-10-14), and a contact carrying
|
|
99
|
-
* it must have an email (Crysta 2026-10-14, the Admin Hub editor rule).
|
|
99
|
+
* it must have an email (Crysta 2026-10-14, the Admin Hub editor rule). CVC-338
|
|
100
|
+
* (prototype `data/cvcs/core_contact_purpose.yaml` @ 184893b6 L95): "A
|
|
101
|
+
* confidential holder still receives it; the sender never sees the address."
|
|
102
|
+
* (pl-iza: `resolveMagicLinkRecipients`, `ConfidentialReferralRecipients`.)
|
|
100
103
|
*/
|
|
101
104
|
declare const REFERRALS_MAGIC_LINK_PURPOSE: ContactPurposeCode;
|
|
102
105
|
declare function isContactPurposeCode(code: unknown): code is ContactPurposeCode;
|
|
@@ -1090,7 +1093,14 @@ declare function pocIdentityKey(c: Pick<PointOfContactDoc, "user_id" | "person_i
|
|
|
1090
1093
|
* `Org + Personnel Registry/DIRECTORY_CSV_EDITING_GUIDE.md` @ 6c2db859
|
|
1091
1094
|
* § 0.9 L958; hti-features `PointOfContact.v1.json` `is_confidential`:
|
|
1092
1095
|
* "Never publish this contact"), so it is left out entirely rather
|
|
1093
|
-
* than masked
|
|
1096
|
+
* than masked. The network view is unchanged by pl-iza (0.32.0):
|
|
1097
|
+
* confidential rows are absent from every view another organization
|
|
1098
|
+
* sees (this view, `getContact`, `listContactsForSubject`, the
|
|
1099
|
+
* referral `recipients`; only the subject's owner and the steward see
|
|
1100
|
+
* them). A confidential Referrals (magic link) holder still receives
|
|
1101
|
+
* the magic link, but only through the send-only
|
|
1102
|
+
* `resolveMagicLinkRecipients` (`./reader.ts`), which never projects
|
|
1103
|
+
* the row and exposes a count;
|
|
1094
1104
|
* - the seat / person links, `notes`, review stamps, actor ids and the
|
|
1095
1105
|
* identity key are not projected.
|
|
1096
1106
|
* - **Owner view** ({@link toOwnerView}): the subject's own editor (Admin
|
|
@@ -1203,6 +1213,19 @@ declare function byContactReadingOrder(a: Pick<PointOfContactDoc, "subject_type"
|
|
|
1203
1213
|
* ObjectId filter for `users._id`; the reader passes a {@link SeatResolver}
|
|
1204
1214
|
* that reads its own `users`. The partner rollup REQUIRES one, so a reader
|
|
1205
1215
|
* cannot silently drop seat-linked referral contacts.
|
|
1216
|
+
*
|
|
1217
|
+
* ## Confidential Referrals (magic link) holders (pl-iza, 0.32.0)
|
|
1218
|
+
*
|
|
1219
|
+
* A confidential holder still receives the magic link; the sender never sees
|
|
1220
|
+
* the address (CVC-338, prototype `data/cvcs/core_contact_purpose.yaml` @
|
|
1221
|
+
* 184893b6 L95; HANDOFF.md @ 184893b6 L569, L575 "POC-PROFILE-ALIGNMENTS"
|
|
1222
|
+
* D(ii)). Confidential rows are absent from every view another organization
|
|
1223
|
+
* sees (only the owner and steward reads carry them). The referral rollup
|
|
1224
|
+
* reads them in a SEPARATE query and hands out only a count
|
|
1225
|
+
* (`confidentialCount`) or, to a send, a {@link ConfidentialReferralRecipients}
|
|
1226
|
+
* whose `deliver` alone touches the addresses (the implementation is not
|
|
1227
|
+
* exported). A confidential row never reaches `unreachable`, and a corrupt
|
|
1228
|
+
* row that may be confidential is counted, never thrown.
|
|
1206
1229
|
*/
|
|
1207
1230
|
|
|
1208
1231
|
/** The slice of a driver `Collection` the reads use. */
|
|
@@ -1280,8 +1303,20 @@ interface ReferralContactsOptions {
|
|
|
1280
1303
|
interface ReferralContactsResult {
|
|
1281
1304
|
/** One per distinct email, in reading order (the agency's own contacts first). */
|
|
1282
1305
|
recipients: ReferralRecipient[];
|
|
1283
|
-
/**
|
|
1306
|
+
/**
|
|
1307
|
+
* Ids of tagged, VISIBLE contacts with no email to send to (a seat whose
|
|
1308
|
+
* `users` row has none). Never a confidential holder's id.
|
|
1309
|
+
*/
|
|
1284
1310
|
unreachable: string[];
|
|
1311
|
+
/**
|
|
1312
|
+
* The number of distinct confidential Referrals (magic link) holder
|
|
1313
|
+
* addresses (pl-iza): active, confirmed, `is_confidential`, tagged, on the
|
|
1314
|
+
* same rollup. Deduped among the confidential holders ONLY, never against
|
|
1315
|
+
* any visible, pending, typed or added address, so no other row or input
|
|
1316
|
+
* moves it. A sender sees this number, never a name, an id or an address
|
|
1317
|
+
* ("+ 1 confidential recipient").
|
|
1318
|
+
*/
|
|
1319
|
+
confidentialCount: number;
|
|
1285
1320
|
}
|
|
1286
1321
|
/**
|
|
1287
1322
|
* The partner's Referrals (magic link) contacts: every active, confirmed,
|
|
@@ -1296,9 +1331,97 @@ interface ReferralContactsResult {
|
|
|
1296
1331
|
* own pending in-app adds on the partner, so a contact they just added can be
|
|
1297
1332
|
* picked before HTI Labs confirms it (pending, marked, after the confirmed
|
|
1298
1333
|
* recipients; an email a confirmed recipient already has is not repeated).
|
|
1299
|
-
* Confidential rows stay
|
|
1334
|
+
* Confidential rows stay out of `recipients` and `unreachable`; they are
|
|
1335
|
+
* counted (`confidentialCount`, pl-iza) and reached only through
|
|
1336
|
+
* {@link resolveMagicLinkRecipients}. The partner has a
|
|
1337
|
+
* magic-link holder when `recipients.length + confidentialCount > 0`.
|
|
1300
1338
|
*/
|
|
1301
1339
|
declare function listReferralContactsForPartner(db: PocDbLike, partner: PocPartnerSelector, opts: ReferralContactsOptions): Promise<ReferralContactsResult>;
|
|
1340
|
+
/** What a send needs: the visible recipients, plus the confidential holders behind a count. */
|
|
1341
|
+
interface MagicLinkSendList {
|
|
1342
|
+
/** As {@link ReferralContactsResult.recipients}. */
|
|
1343
|
+
recipients: ReferralRecipient[];
|
|
1344
|
+
/** As {@link ReferralContactsResult.unreachable}: visible contacts only. */
|
|
1345
|
+
unreachable: string[];
|
|
1346
|
+
/** The confidential holders: a count, and a `deliver` that alone touches their addresses. */
|
|
1347
|
+
confidential: ConfidentialReferralRecipients;
|
|
1348
|
+
/**
|
|
1349
|
+
* SERVER-SIDE diagnostic, never returned to a sender: the confidential
|
|
1350
|
+
* holder rows that cannot be sent to (no email, a seat with none or not
|
|
1351
|
+
* found), plus skipped rows that do not match the contract and may be
|
|
1352
|
+
* confidential (their error would name their id). A count, never an id.
|
|
1353
|
+
*/
|
|
1354
|
+
confidentialUnreachableCount: number;
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* SEND-ONLY (pl-iza). The same read as {@link listReferralContactsForPartner},
|
|
1358
|
+
* with the confidential holders as a {@link ConfidentialReferralRecipients}
|
|
1359
|
+
* instead of a bare count. Call it at send time, server-side, and hand
|
|
1360
|
+
* `confidential.deliver` the mailer; never return the result to a browser
|
|
1361
|
+
* beyond `confidential.count` (its `toJSON` is `{ count }`). This is the only
|
|
1362
|
+
* way to obtain a `ConfidentialReferralRecipients` (the implementation is
|
|
1363
|
+
* not exported).
|
|
1364
|
+
*
|
|
1365
|
+
* Canon: CVC-338 `REFERRALS_MAGIC_LINK` (prototype
|
|
1366
|
+
* `data/cvcs/core_contact_purpose.yaml` @ 184893b6 L95): "A confidential
|
|
1367
|
+
* holder still receives it; the sender never sees the address."
|
|
1368
|
+
*/
|
|
1369
|
+
declare function resolveMagicLinkRecipients(db: PocDbLike, partner: PocPartnerSelector, opts: ReferralContactsOptions): Promise<MagicLinkSendList>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Sends one magic link to one address. It must THROW (or reject) on failure;
|
|
1372
|
+
* returning normally counts as delivered. It must not log, persist or return
|
|
1373
|
+
* `address`.
|
|
1374
|
+
*/
|
|
1375
|
+
type ConfidentialSendOne = (address: string) => void | Promise<void>;
|
|
1376
|
+
interface ConfidentialDeliverOptions {
|
|
1377
|
+
/** At most this many sends (a non-negative integer); the rest are `overflow`. Unlimited when omitted. */
|
|
1378
|
+
capacity?: number;
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* A confidential delivery's outcome: numbers and an error class name, never an
|
|
1382
|
+
* address. SERVER-SIDE, for audit only: a sender may see `count`, or one
|
|
1383
|
+
* all-or-nothing status derived from it, never `delivered`, `failed`,
|
|
1384
|
+
* `overflow` or `firstErrorName`.
|
|
1385
|
+
*/
|
|
1386
|
+
interface ConfidentialDeliveryResult {
|
|
1387
|
+
/** The holder count (`delivered + failed + overflow`). */
|
|
1388
|
+
count: number;
|
|
1389
|
+
delivered: number;
|
|
1390
|
+
failed: number;
|
|
1391
|
+
/** Holders beyond `capacity`, not sent: `max(0, count - capacity)`. */
|
|
1392
|
+
overflow: number;
|
|
1393
|
+
/** The first failed send's `err.name` (never its message, which can echo the address), or null. */
|
|
1394
|
+
firstErrorName: string | null;
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* A partner's confidential Referrals (magic link) holders (pl-iza). It carries
|
|
1398
|
+
* their addresses privately and exposes only `count`: `toJSON()` is
|
|
1399
|
+
* `{ count }`, `util.inspect` draws `ConfidentialReferralRecipients(n)`, and
|
|
1400
|
+
* no public member returns an address. Only {@link deliver} touches them,
|
|
1401
|
+
* handing each to the caller's `sendOne`.
|
|
1402
|
+
*
|
|
1403
|
+
* An interface, exported as a type only. The implementation is not
|
|
1404
|
+
* exported: obtain values only via {@link resolveMagicLinkRecipients}.
|
|
1405
|
+
*/
|
|
1406
|
+
interface ConfidentialReferralRecipients {
|
|
1407
|
+
readonly count: number;
|
|
1408
|
+
/**
|
|
1409
|
+
* Sends to the first `capacity` holders (all when omitted), one at a time.
|
|
1410
|
+
* The outcome depends only on the holders, `capacity` and each send's
|
|
1411
|
+
* result, never on any address the caller handled: an address the sender
|
|
1412
|
+
* also typed is sent again, so nothing observable moves when one matches.
|
|
1413
|
+
* Never rejects for a failed send: each error is caught and only its `name`
|
|
1414
|
+
* is kept (a provider's message can echo the address). The result is
|
|
1415
|
+
* server-side only (see {@link ConfidentialDeliveryResult}).
|
|
1416
|
+
*/
|
|
1417
|
+
deliver(sendOne: ConfidentialSendOne, opts?: ConfidentialDeliverOptions): Promise<ConfidentialDeliveryResult>;
|
|
1418
|
+
/** `{ count }`: what a response, a record or an event may carry. */
|
|
1419
|
+
toJSON(): {
|
|
1420
|
+
count: number;
|
|
1421
|
+
};
|
|
1422
|
+
/** `ConfidentialReferralRecipients(n)`. */
|
|
1423
|
+
toString(): string;
|
|
1424
|
+
}
|
|
1302
1425
|
/** One contact as other organizations see it, or null (absent or not network-visible). */
|
|
1303
1426
|
declare function getContact(db: PocDbLike, id: string, opts?: {
|
|
1304
1427
|
resolveSeats?: SeatResolver;
|
|
@@ -1581,4 +1704,4 @@ interface MintPartnerContactArgs {
|
|
|
1581
1704
|
*/
|
|
1582
1705
|
declare function mintPartnerContact(db: PocWriteDbLike, args: MintPartnerContactArgs, driver: PocWriterDriver): Promise<PartnerContactResult>;
|
|
1583
1706
|
|
|
1584
|
-
export { CONTACT_PURPOSES, CONTACT_PURPOSE_CODES, type ContactPurpose, type ContactPurposeCode, type MintPartnerContactArgs, PARTNER_CONTACT_FAILURE_REASONS, POC_ADDED_IN_APPS, POC_IDENTITY_INDEX_FILTER, POC_ID_PATTERN, POC_IN_APP_PENDING_CAP_PER_ACTOR, POC_IN_APP_PENDING_CAP_PER_PARTNER, POC_IN_APP_PENDING_INDEX, POC_IN_APP_PENDING_INDEX_FILTER, POC_IN_APP_PENDING_INDEX_KEY, POC_MAX_CONTACT_ENTRIES, POC_ORIGINS, POC_PARTNER_ADD_APPS, POC_PENDING_QUEUE_INDEX, POC_PRIMARY_INDEX_FILTER, POC_STATUSES, POC_SUBJECT_TYPES, POC_SUBJECT_TYPE_LABELS, POC_URGENT_METHODS, POC_URGENT_METHOD_KEYS, POINTS_OF_CONTACT_COLLECTION, POINT_OF_CONTACT_INDEXES, type PartnerContactFailure, type PartnerContactFailureReason, type PartnerContactReceipt, type PartnerContactResult, type PartnerContactSelector, type PartnerContactSelectorInput, PartnerContactSelectorSchema, type PocAddedInApp, type PocCollectionLike, type PocContactEntry, type PocCreateIndexOptions, type PocDbLike, type PocDetails, type PocDetailsInput, PocDetailsSchema, PocEmailListSchema, PocEmailSchema, type PocInApp, type PocInAppActor, type PocInAppInput, PocInAppSchema, type PocIndexInfoLike, PocLinkIdSchema, type PocObjectIdClass, type PocOrigin, type PocOwner, PocOwnerSchema, type PocPartnerAddApp, type PocPartnerSelector, type PocPatch, type PocPatchInput, PocPatchSchema, PocPhoneListSchema, type PocRuleInput, type PocRuleViolation, type PocSeed, type PocSeedInput, PocSeedSchema, type PocStatus, type PocSubjectRef, type PocSubjectType, type PocUrgentMethod, type PocWriteCollectionLike, type PocWriteCursorLike, type PocWriteDbLike, type PocWriterDriver, type PointOfContactDoc, PointOfContactDocSchema, type PointOfContactNetworkView, type PointOfContactOwnerView, PointOfContactShapeError, type PointOfContactStewardView, REFERRALS_MAGIC_LINK_PURPOSE, type ReferralContactsOptions, type ReferralContactsResult, type ReferralRecipient, type SeatReach, type SeatResolver, StoredContactEntrySchema, StoredEmailListSchema, StoredPhoneListSchema, byContactReadingOrder, checkPocIndexes, contactPurposeLabel, definedPatch, ensurePocIndexes, formatPocPhone, getContact, isContactPurposeCode, isNetworkVisible, isPocUrgentMethodCode, listContactsForSubject, listOwnerContactsForSubject, listPendingContacts, listReferralContactsForPartner, mintPartnerContact, normalizePointOfContact, pocDuplicateKeyFailure, pocIdentityKey, pocInitialStatus, pocPhoneDigits, pocRowsWithIdentity, pocRuleViolations, pocSubjectTypeLabel, pocUrgentMethodCode, preferredContactEntry, preferredEmail, preferredPhone, toNetworkView, toOwnerView, toStewardView };
|
|
1707
|
+
export { CONTACT_PURPOSES, CONTACT_PURPOSE_CODES, type ConfidentialDeliverOptions, type ConfidentialDeliveryResult, type ConfidentialReferralRecipients, type ConfidentialSendOne, type ContactPurpose, type ContactPurposeCode, type MagicLinkSendList, type MintPartnerContactArgs, PARTNER_CONTACT_FAILURE_REASONS, POC_ADDED_IN_APPS, POC_IDENTITY_INDEX_FILTER, POC_ID_PATTERN, POC_IN_APP_PENDING_CAP_PER_ACTOR, POC_IN_APP_PENDING_CAP_PER_PARTNER, POC_IN_APP_PENDING_INDEX, POC_IN_APP_PENDING_INDEX_FILTER, POC_IN_APP_PENDING_INDEX_KEY, POC_MAX_CONTACT_ENTRIES, POC_ORIGINS, POC_PARTNER_ADD_APPS, POC_PENDING_QUEUE_INDEX, POC_PRIMARY_INDEX_FILTER, POC_STATUSES, POC_SUBJECT_TYPES, POC_SUBJECT_TYPE_LABELS, POC_URGENT_METHODS, POC_URGENT_METHOD_KEYS, POINTS_OF_CONTACT_COLLECTION, POINT_OF_CONTACT_INDEXES, type PartnerContactFailure, type PartnerContactFailureReason, type PartnerContactReceipt, type PartnerContactResult, type PartnerContactSelector, type PartnerContactSelectorInput, PartnerContactSelectorSchema, type PocAddedInApp, type PocCollectionLike, type PocContactEntry, type PocCreateIndexOptions, type PocDbLike, type PocDetails, type PocDetailsInput, PocDetailsSchema, PocEmailListSchema, PocEmailSchema, type PocInApp, type PocInAppActor, type PocInAppInput, PocInAppSchema, type PocIndexInfoLike, PocLinkIdSchema, type PocObjectIdClass, type PocOrigin, type PocOwner, PocOwnerSchema, type PocPartnerAddApp, type PocPartnerSelector, type PocPatch, type PocPatchInput, PocPatchSchema, PocPhoneListSchema, type PocRuleInput, type PocRuleViolation, type PocSeed, type PocSeedInput, PocSeedSchema, type PocStatus, type PocSubjectRef, type PocSubjectType, type PocUrgentMethod, type PocWriteCollectionLike, type PocWriteCursorLike, type PocWriteDbLike, type PocWriterDriver, type PointOfContactDoc, PointOfContactDocSchema, type PointOfContactNetworkView, type PointOfContactOwnerView, PointOfContactShapeError, type PointOfContactStewardView, REFERRALS_MAGIC_LINK_PURPOSE, type ReferralContactsOptions, type ReferralContactsResult, type ReferralRecipient, type SeatReach, type SeatResolver, StoredContactEntrySchema, StoredEmailListSchema, StoredPhoneListSchema, byContactReadingOrder, checkPocIndexes, contactPurposeLabel, definedPatch, ensurePocIndexes, formatPocPhone, getContact, isContactPurposeCode, isNetworkVisible, isPocUrgentMethodCode, listContactsForSubject, listOwnerContactsForSubject, listPendingContacts, listReferralContactsForPartner, mintPartnerContact, normalizePointOfContact, pocDuplicateKeyFailure, pocIdentityKey, pocInitialStatus, pocPhoneDigits, pocRowsWithIdentity, pocRuleViolations, pocSubjectTypeLabel, pocUrgentMethodCode, preferredContactEntry, preferredEmail, preferredPhone, resolveMagicLinkRecipients, toNetworkView, toOwnerView, toStewardView };
|
|
@@ -500,7 +500,7 @@ async function listContactsForSubject(db, subject, opts = {}) {
|
|
|
500
500
|
const docs = await findDocs(db, { ...subjectFilter(subject), ...NETWORK_VISIBLE });
|
|
501
501
|
return networkViews(docs, await seatsFor(docs, opts.resolveSeats));
|
|
502
502
|
}
|
|
503
|
-
|
|
503
|
+
function partnerKeys(partner) {
|
|
504
504
|
const keys = [];
|
|
505
505
|
if (partner.agency_id !== void 0 && partner.agency_id !== null) {
|
|
506
506
|
keys.push({ agency_id: requireId("agency_id", partner.agency_id) });
|
|
@@ -509,17 +509,53 @@ async function listReferralContactsForPartner(db, partner, opts) {
|
|
|
509
509
|
keys.push({ org_id: requireId("org_id", partner.org_id) });
|
|
510
510
|
}
|
|
511
511
|
if (keys.length === 0) throw new TypeError("points-of-contact: select a partner by agency_id, org_id or both");
|
|
512
|
+
return keys;
|
|
513
|
+
}
|
|
514
|
+
var mayBeConfidential = (raw) => raw.is_confidential !== false && raw.is_confidential !== void 0;
|
|
515
|
+
async function findHolderDocs(db, filter, confidentialLeg) {
|
|
516
|
+
const raw = await db.collection(POINTS_OF_CONTACT_COLLECTION).find(filter).toArray();
|
|
517
|
+
const docs = [];
|
|
518
|
+
let skipped = 0;
|
|
519
|
+
for (const r of raw) {
|
|
520
|
+
const row = rowOf(r);
|
|
521
|
+
try {
|
|
522
|
+
docs.push(normalizePointOfContact(row));
|
|
523
|
+
} catch (err) {
|
|
524
|
+
if (!confidentialLeg && !mayBeConfidential(row)) throw err;
|
|
525
|
+
skipped++;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return { docs: docs.sort(byContactReadingOrder), skipped };
|
|
529
|
+
}
|
|
530
|
+
async function readReferralHolders(db, partner, opts) {
|
|
531
|
+
const keys = partnerKeys(partner);
|
|
512
532
|
const pendingFor = opts.includeOwnPendingFor === void 0 ? null : requireId("includeOwnPendingFor", opts.includeOwnPendingFor);
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
purposes: REFERRALS_MAGIC_LINK_PURPOSE,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const
|
|
533
|
+
const visible = await findHolderDocs(
|
|
534
|
+
db,
|
|
535
|
+
{ $or: keys, purposes: REFERRALS_MAGIC_LINK_PURPOSE, ...NETWORK_VISIBLE },
|
|
536
|
+
false
|
|
537
|
+
);
|
|
538
|
+
const pending = pendingFor === null ? { docs: [], skipped: 0 } : await findHolderDocs(
|
|
539
|
+
db,
|
|
540
|
+
{
|
|
541
|
+
$or: keys,
|
|
542
|
+
purposes: REFERRALS_MAGIC_LINK_PURPOSE,
|
|
543
|
+
...OWN_PENDING_IN_APP,
|
|
544
|
+
createdBy: pendingFor
|
|
545
|
+
},
|
|
546
|
+
false
|
|
547
|
+
);
|
|
548
|
+
const confidential = await findHolderDocs(
|
|
549
|
+
db,
|
|
550
|
+
{ $or: keys, purposes: REFERRALS_MAGIC_LINK_PURPOSE, ...CONFIDENTIAL_CONFIRMED },
|
|
551
|
+
true
|
|
552
|
+
);
|
|
553
|
+
const docs = visible.docs;
|
|
554
|
+
const seats = await seatsFor([...docs, ...confidential.docs], opts.resolveSeats);
|
|
519
555
|
const recipients = [];
|
|
520
556
|
const unreachable = [];
|
|
521
557
|
const seen = /* @__PURE__ */ new Set();
|
|
522
|
-
for (const v of
|
|
558
|
+
for (const v of networkViews(docs, seats)) {
|
|
523
559
|
if (!v.purposes.includes(REFERRALS_MAGIC_LINK_PURPOSE)) continue;
|
|
524
560
|
const email = v.email;
|
|
525
561
|
if (!email) {
|
|
@@ -531,13 +567,7 @@ async function listReferralContactsForPartner(db, partner, opts) {
|
|
|
531
567
|
recipients.push({ ...v, email });
|
|
532
568
|
}
|
|
533
569
|
if (pendingFor !== null) {
|
|
534
|
-
const
|
|
535
|
-
$or: keys,
|
|
536
|
-
purposes: REFERRALS_MAGIC_LINK_PURPOSE,
|
|
537
|
-
...OWN_PENDING_IN_APP,
|
|
538
|
-
createdBy: pendingFor
|
|
539
|
-
});
|
|
540
|
-
for (const d of pending) {
|
|
570
|
+
for (const d of pending.docs) {
|
|
541
571
|
if (!isOwnPendingInApp(d, pendingFor)) continue;
|
|
542
572
|
const v = toNetworkView({ ...d, status: "confirmed" });
|
|
543
573
|
const email = v?.email;
|
|
@@ -546,8 +576,93 @@ async function listReferralContactsForPartner(db, partner, opts) {
|
|
|
546
576
|
recipients.push({ ...v, email, pending: true });
|
|
547
577
|
}
|
|
548
578
|
}
|
|
549
|
-
|
|
579
|
+
const confidentialAddresses = [];
|
|
580
|
+
const confidentialSeen = /* @__PURE__ */ new Set();
|
|
581
|
+
let confidentialUnreachableCount = visible.skipped + pending.skipped + confidential.skipped;
|
|
582
|
+
for (const d of confidential.docs) {
|
|
583
|
+
if (!isConfidentialHolder(d)) continue;
|
|
584
|
+
const email = toStewardView(d, seatOf(d, seats)).email;
|
|
585
|
+
if (!email) {
|
|
586
|
+
confidentialUnreachableCount++;
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
if (confidentialSeen.has(email)) continue;
|
|
590
|
+
confidentialSeen.add(email);
|
|
591
|
+
confidentialAddresses.push(email);
|
|
592
|
+
}
|
|
593
|
+
return { recipients, unreachable, confidentialAddresses, confidentialUnreachableCount };
|
|
594
|
+
}
|
|
595
|
+
async function listReferralContactsForPartner(db, partner, opts) {
|
|
596
|
+
const holders = await readReferralHolders(db, partner, opts);
|
|
597
|
+
return {
|
|
598
|
+
recipients: holders.recipients,
|
|
599
|
+
unreachable: holders.unreachable,
|
|
600
|
+
confidentialCount: holders.confidentialAddresses.length
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
async function resolveMagicLinkRecipients(db, partner, opts) {
|
|
604
|
+
const holders = await readReferralHolders(db, partner, opts);
|
|
605
|
+
return {
|
|
606
|
+
recipients: holders.recipients,
|
|
607
|
+
unreachable: holders.unreachable,
|
|
608
|
+
confidential: new ConfidentialHolders(holders.confidentialAddresses),
|
|
609
|
+
confidentialUnreachableCount: holders.confidentialUnreachableCount
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
var SAFE_ERROR_NAME = /^[A-Za-z_$][\w$.-]{0,63}$/;
|
|
613
|
+
function errorName(err) {
|
|
614
|
+
try {
|
|
615
|
+
if (err === null || typeof err !== "object" && typeof err !== "function") return "Error";
|
|
616
|
+
const name = err.name;
|
|
617
|
+
return typeof name === "string" && SAFE_ERROR_NAME.test(name) ? name : "Error";
|
|
618
|
+
} catch {
|
|
619
|
+
return "Error";
|
|
620
|
+
}
|
|
550
621
|
}
|
|
622
|
+
var ConfidentialHolders = class {
|
|
623
|
+
count;
|
|
624
|
+
#addresses;
|
|
625
|
+
constructor(addresses) {
|
|
626
|
+
this.#addresses = Object.freeze([...addresses]);
|
|
627
|
+
this.count = this.#addresses.length;
|
|
628
|
+
Object.freeze(this);
|
|
629
|
+
}
|
|
630
|
+
/** See {@link ConfidentialReferralRecipients.deliver}. */
|
|
631
|
+
async deliver(sendOne, opts = {}) {
|
|
632
|
+
const { capacity } = opts;
|
|
633
|
+
if (capacity !== void 0 && !(Number.isInteger(capacity) && capacity >= 0)) {
|
|
634
|
+
throw new TypeError("points-of-contact: capacity must be a non-negative integer");
|
|
635
|
+
}
|
|
636
|
+
const toSend = capacity === void 0 ? this.#addresses : this.#addresses.slice(0, capacity);
|
|
637
|
+
const out = {
|
|
638
|
+
count: this.count,
|
|
639
|
+
delivered: 0,
|
|
640
|
+
failed: 0,
|
|
641
|
+
overflow: this.count - toSend.length,
|
|
642
|
+
firstErrorName: null
|
|
643
|
+
};
|
|
644
|
+
for (const address of toSend) {
|
|
645
|
+
try {
|
|
646
|
+
await sendOne(address);
|
|
647
|
+
out.delivered++;
|
|
648
|
+
} catch (err) {
|
|
649
|
+
out.failed++;
|
|
650
|
+
out.firstErrorName ??= errorName(err);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return out;
|
|
654
|
+
}
|
|
655
|
+
/** `{ count }`: what a response, a record or an event may carry. */
|
|
656
|
+
toJSON() {
|
|
657
|
+
return { count: this.count };
|
|
658
|
+
}
|
|
659
|
+
toString() {
|
|
660
|
+
return `ConfidentialReferralRecipients(${this.count})`;
|
|
661
|
+
}
|
|
662
|
+
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
|
|
663
|
+
return this.toString();
|
|
664
|
+
}
|
|
665
|
+
};
|
|
551
666
|
var OWN_PENDING_IN_APP = {
|
|
552
667
|
active: true,
|
|
553
668
|
status: "pending",
|
|
@@ -555,6 +670,8 @@ var OWN_PENDING_IN_APP = {
|
|
|
555
670
|
is_confidential: { $ne: true }
|
|
556
671
|
};
|
|
557
672
|
var isOwnPendingInApp = (d, sub) => d.active && d.status === "pending" && d.origin === "in_app" && !d.is_confidential && !d.user_id && d.createdBy === sub && d.purposes.includes(REFERRALS_MAGIC_LINK_PURPOSE);
|
|
673
|
+
var CONFIDENTIAL_CONFIRMED = { active: true, status: "confirmed", is_confidential: true };
|
|
674
|
+
var isConfidentialHolder = (d) => d.active && d.status === "confirmed" && d.is_confidential && d.purposes.includes(REFERRALS_MAGIC_LINK_PURPOSE);
|
|
558
675
|
async function getContact(db, id, opts = {}) {
|
|
559
676
|
const raw = await db.collection(POINTS_OF_CONTACT_COLLECTION).findOne({ id: requireId("id", id) });
|
|
560
677
|
if (!raw) return null;
|
|
@@ -1238,6 +1355,7 @@ export {
|
|
|
1238
1355
|
preferredContactEntry,
|
|
1239
1356
|
preferredEmail,
|
|
1240
1357
|
preferredPhone,
|
|
1358
|
+
resolveMagicLinkRecipients,
|
|
1241
1359
|
toNetworkView,
|
|
1242
1360
|
toOwnerView,
|
|
1243
1361
|
toStewardView
|