@dereekb/firebase-server 11.0.21 → 11.1.1
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/CHANGELOG.md +13 -0
- package/mailgun/package.json +1 -1
- package/model/package.json +6 -0
- package/model/src/index.d.ts +1 -0
- package/model/src/index.js +5 -0
- package/model/src/index.js.map +1 -0
- package/model/src/lib/index.d.ts +2 -0
- package/model/src/lib/index.js +6 -0
- package/model/src/lib/index.js.map +1 -0
- package/model/src/lib/mailgun/index.d.ts +1 -0
- package/model/src/lib/mailgun/index.js +5 -0
- package/model/src/lib/mailgun/index.js.map +1 -0
- package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +51 -0
- package/model/src/lib/mailgun/notification.send.service.mailgun.js +67 -0
- package/model/src/lib/mailgun/notification.send.service.mailgun.js.map +1 -0
- package/model/src/lib/notification/index.d.ts +11 -0
- package/model/src/lib/notification/index.js +15 -0
- package/model/src/lib/notification/index.js.map +1 -0
- package/model/src/lib/notification/notification.action.init.server.d.ts +72 -0
- package/model/src/lib/notification/notification.action.init.server.js +228 -0
- package/model/src/lib/notification/notification.action.init.server.js.map +1 -0
- package/model/src/lib/notification/notification.action.server.d.ts +70 -0
- package/model/src/lib/notification/notification.action.server.js +1049 -0
- package/model/src/lib/notification/notification.action.server.js.map +1 -0
- package/model/src/lib/notification/notification.config.d.ts +31 -0
- package/model/src/lib/notification/notification.config.js +13 -0
- package/model/src/lib/notification/notification.config.js.map +1 -0
- package/model/src/lib/notification/notification.config.service.d.ts +49 -0
- package/model/src/lib/notification/notification.config.service.js +59 -0
- package/model/src/lib/notification/notification.config.service.js.map +1 -0
- package/model/src/lib/notification/notification.error.d.ts +9 -0
- package/model/src/lib/notification/notification.error.js +74 -0
- package/model/src/lib/notification/notification.error.js.map +1 -0
- package/model/src/lib/notification/notification.module.d.ts +49 -0
- package/model/src/lib/notification/notification.module.js +69 -0
- package/model/src/lib/notification/notification.module.js.map +1 -0
- package/model/src/lib/notification/notification.send.d.ts +4 -0
- package/model/src/lib/notification/notification.send.js +3 -0
- package/model/src/lib/notification/notification.send.js.map +1 -0
- package/model/src/lib/notification/notification.send.service.d.ts +65 -0
- package/model/src/lib/notification/notification.send.service.js +10 -0
- package/model/src/lib/notification/notification.send.service.js.map +1 -0
- package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +18 -0
- package/model/src/lib/notification/notification.send.service.notificationsummary.js +105 -0
- package/model/src/lib/notification/notification.send.service.notificationsummary.js.map +1 -0
- package/model/src/lib/notification/notification.send.service.text.d.ts +9 -0
- package/model/src/lib/notification/notification.send.service.text.js +30 -0
- package/model/src/lib/notification/notification.send.service.text.js.map +1 -0
- package/model/src/lib/notification/notification.util.d.ts +128 -0
- package/model/src/lib/notification/notification.util.js +465 -0
- package/model/src/lib/notification/notification.util.js.map +1 -0
- package/package.json +7 -1
- package/test/package.json +1 -1
- package/zoho/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.firestoreNotificationSummarySendService = void 0;
|
|
4
|
+
const firebase_1 = require("@dereekb/firebase");
|
|
5
|
+
const util_1 = require("@dereekb/util");
|
|
6
|
+
const notification_util_1 = require("./notification.util");
|
|
7
|
+
function firestoreNotificationSummarySendService(config) {
|
|
8
|
+
const { context, allowCreateNotificationSummaries: inputAllowCreateNotificationSummaries } = config;
|
|
9
|
+
const { firestoreContext, notificationSummaryCollection } = context;
|
|
10
|
+
const allowCreateNotificationSummaries = inputAllowCreateNotificationSummaries ?? true;
|
|
11
|
+
const sendService = {
|
|
12
|
+
async buildSendInstanceForNotificationSummaryMessages(notificationMessages) {
|
|
13
|
+
const messagesGroupedByNotificationSummaryMapBuilder = (0, util_1.multiValueMapBuilder)();
|
|
14
|
+
notificationMessages.forEach((x) => {
|
|
15
|
+
if (x.inputContext.recipient.s != null && x.item != null) {
|
|
16
|
+
// only add to map builder if recipient id is defined
|
|
17
|
+
messagesGroupedByNotificationSummaryMapBuilder.add(x.inputContext.recipient.s, x);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const cutSubject = (0, util_1.cutStringFunction)({ maxLength: firebase_1.NOTIFICATION_SUMMARY_EMBEDDED_NOTIFICATION_ITEM_SUBJECT_MAX_LENGTH });
|
|
21
|
+
const cutMessage = (0, util_1.cutStringFunction)({ maxLength: firebase_1.NOTIFICATION_SUMMARY_EMBEDDED_NOTIFICATION_ITEM_MESSAGE_MAX_LENGTH });
|
|
22
|
+
const messagesGroups = messagesGroupedByNotificationSummaryMapBuilder.entries();
|
|
23
|
+
return async () => {
|
|
24
|
+
const success = [];
|
|
25
|
+
const failed = [];
|
|
26
|
+
const ignored = [];
|
|
27
|
+
await (0, util_1.runAsyncTasksForValues)(messagesGroups, async ([notificationSummaryId, messages]) => {
|
|
28
|
+
await firestoreContext
|
|
29
|
+
.runTransaction(async (transaction) => {
|
|
30
|
+
const notificationSummaryDocument = notificationSummaryCollection.documentAccessorForTransaction(transaction).loadDocumentForId(notificationSummaryId);
|
|
31
|
+
const notificationSummary = await notificationSummaryDocument.snapshotData();
|
|
32
|
+
let updated = false;
|
|
33
|
+
let updateTemplate;
|
|
34
|
+
const existingMessages = notificationSummary?.n ?? [];
|
|
35
|
+
const existingMessageIds = new Set(existingMessages.map((x) => x.id));
|
|
36
|
+
// ignore any repeat messages
|
|
37
|
+
const messagesToSend = messages.filter((x) => !existingMessageIds.has(x.item.id));
|
|
38
|
+
if (messagesToSend.length > 0) {
|
|
39
|
+
// add the new items to existing n, then keep the last 1000
|
|
40
|
+
const sortedN = existingMessages
|
|
41
|
+
.concat(messagesToSend.map((x) => {
|
|
42
|
+
let message = '';
|
|
43
|
+
if (x.content.openingMessage) {
|
|
44
|
+
message = x.content.openingMessage;
|
|
45
|
+
}
|
|
46
|
+
if (x.content.closingMessage) {
|
|
47
|
+
message = (message ? message + '\n\n' : message) + x.content.closingMessage;
|
|
48
|
+
}
|
|
49
|
+
const item = {
|
|
50
|
+
...x.item,
|
|
51
|
+
s: cutSubject(x.content.title),
|
|
52
|
+
g: cutMessage(message)
|
|
53
|
+
};
|
|
54
|
+
return item;
|
|
55
|
+
}))
|
|
56
|
+
.sort(firebase_1.sortNotificationItemsFunction);
|
|
57
|
+
const n = (0, util_1.takeLast)(sortedN, firebase_1.NOTIFICATION_SUMMARY_ITEM_LIMIT);
|
|
58
|
+
updateTemplate = {
|
|
59
|
+
n,
|
|
60
|
+
lat: new Date()
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (updateTemplate != null) {
|
|
64
|
+
if (notificationSummary != null) {
|
|
65
|
+
await notificationSummaryDocument.update(updateTemplate);
|
|
66
|
+
updated = true;
|
|
67
|
+
}
|
|
68
|
+
else if (allowCreateNotificationSummaries) {
|
|
69
|
+
// if it does not exist, and we are allowed to create new summaries, create it and add the new notifications
|
|
70
|
+
const createTemplate = {
|
|
71
|
+
...(0, notification_util_1.makeNewNotificationSummaryTemplate)((0, firebase_1.inferKeyFromTwoWayFlatFirestoreModelKey)(notificationSummaryId)),
|
|
72
|
+
...updateTemplate
|
|
73
|
+
};
|
|
74
|
+
await notificationSummaryDocument.create(createTemplate);
|
|
75
|
+
updated = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return updated;
|
|
79
|
+
})
|
|
80
|
+
.then((updated) => {
|
|
81
|
+
if (updated) {
|
|
82
|
+
success.push(notificationSummaryId);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
ignored.push(notificationSummaryId);
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
.catch((e) => {
|
|
89
|
+
console.error('firestoreNotificationSummarySendService(): failed updating notification summary', e);
|
|
90
|
+
failed.push(notificationSummaryId);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
const sendResult = {
|
|
94
|
+
success,
|
|
95
|
+
failed,
|
|
96
|
+
ignored
|
|
97
|
+
};
|
|
98
|
+
return sendResult;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return sendService;
|
|
103
|
+
}
|
|
104
|
+
exports.firestoreNotificationSummarySendService = firestoreNotificationSummarySendService;
|
|
105
|
+
//# sourceMappingURL=notification.send.service.notificationsummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.send.service.notificationsummary.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/notification/notification.send.service.notificationsummary.ts"],"names":[],"mappings":";;;AAAA,gDAc2B;AAI3B,wCAAsH;AACtH,2DAAyE;AAiBzE,SAAgB,uCAAuC,CAAC,MAAqD;IAC3G,MAAM,EAAE,OAAO,EAAE,gCAAgC,EAAE,qCAAqC,EAAE,GAAG,MAAM,CAAC;IACpG,MAAM,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC;IAEpE,MAAM,gCAAgC,GAAG,qCAAqC,IAAI,IAAI,CAAC;IAEvF,MAAM,WAAW,GAA4C;QAC3D,KAAK,CAAC,+CAA+C,CAAC,oBAA2C;YAC/F,MAAM,8CAA8C,GAAG,IAAA,2BAAoB,GAA8C,CAAC;YAE1H,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACjC,IAAI,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE;oBACxD,qDAAqD;oBACrD,8CAA8C,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBACnF;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,IAAA,wBAAiB,EAAC,EAAE,SAAS,EAAE,6EAAkE,EAAE,CAAC,CAAC;YACxH,MAAM,UAAU,GAAG,IAAA,wBAAiB,EAAC,EAAE,SAAS,EAAE,6EAAkE,EAAE,CAAC,CAA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C;yBACD,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;wBAChB,IAAI,OAAO,EAAE;4BACX,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;yBACrC;6BAAM;4BACL,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;yBACrC;oBACH,CAAC,CAAC;yBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;wBACX,OAAO,CAAC,KAAK,CAAC,iFAAiF,EAAE,CAAC,CAAC,CAAC;wBACpG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;oBACrC,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;gBAEH,MAAM,UAAU,GAAsD;oBACpE,OAAO;oBACP,MAAM;oBACN,OAAO;iBACR,CAAC;gBAEF,OAAO,UAAU,CAAC;YACpB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AAvHD,0FAuHC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type NotificationTextSendService } from './notification.send.service';
|
|
2
|
+
/**
|
|
3
|
+
* NotificationTextSendService that ignores sending all messages.
|
|
4
|
+
*
|
|
5
|
+
* This is useful for cases where your app may eventually want to send text notifications and want the rest of your app configured like it currently does.
|
|
6
|
+
*
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function ignoreSendNotificationTextSendService(): NotificationTextSendService;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ignoreSendNotificationTextSendService = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* NotificationTextSendService that ignores sending all messages.
|
|
6
|
+
*
|
|
7
|
+
* This is useful for cases where your app may eventually want to send text notifications and want the rest of your app configured like it currently does.
|
|
8
|
+
*
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function ignoreSendNotificationTextSendService() {
|
|
12
|
+
const sendService = {
|
|
13
|
+
async buildSendInstanceForTextNotificationMessages(notificationMessages) {
|
|
14
|
+
return async () => {
|
|
15
|
+
const success = [];
|
|
16
|
+
const failed = [];
|
|
17
|
+
const ignored = notificationMessages.map((x) => x.inputContext.recipient.t);
|
|
18
|
+
const sendResult = {
|
|
19
|
+
success,
|
|
20
|
+
failed,
|
|
21
|
+
ignored
|
|
22
|
+
};
|
|
23
|
+
return sendResult;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return sendService;
|
|
28
|
+
}
|
|
29
|
+
exports.ignoreSendNotificationTextSendService = ignoreSendNotificationTextSendService;
|
|
30
|
+
//# sourceMappingURL=notification.send.service.text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.send.service.text.js","sourceRoot":"","sources":["../../../../../../../packages/firebase-server/model/src/lib/notification/notification.send.service.text.ts"],"names":[],"mappings":";;;AAKA;;;;;;GAMG;AACH,SAAgB,qCAAqC;IACnD,MAAM,WAAW,GAAgC;QAC/C,KAAK,CAAC,4CAA4C,CAAC,oBAA2C;YAC5F,OAAO,KAAK,IAAI,EAAE;gBAChB,MAAM,OAAO,GAAsB,EAAE,CAAC;gBACtC,MAAM,MAAM,GAAsB,EAAE,CAAC;gBACrC,MAAM,OAAO,GAAsB,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAoB,CAAC,CAAC;gBAElH,MAAM,UAAU,GAAuC;oBACrD,OAAO;oBACP,MAAM;oBACN,OAAO;iBACR,CAAC;gBAEF,OAAO,UAAU,CAAC;YACpB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AApBD,sFAoBC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { type Notification, type NotificationBox, type NotificationBoxRecipient, type NotificationBoxRecipientTemplateConfig, NotificationRecipientSendFlag, type NotificationRecipientWithConfig, type FirebaseAuthDetails, type FirebaseAuthUserId, type NotificationSummaryId, type NotificationBoxId, type NotificationUser, type NotificationUserNotificationBoxRecipientConfig, type NotificationUserId, type FirestoreDocumentAccessor, type NotificationUserDocument, type NotificationUserDefaultNotificationBoxRecipientConfig, type NotificationSummaryIdForUidFunction, type NotificationSummary } from '@dereekb/firebase';
|
|
2
|
+
import { type FirebaseServerAuthService } from '@dereekb/firebase-server';
|
|
3
|
+
import { type E164PhoneNumber, type EmailAddress, type Maybe, type PhoneNumber, type ModelKey } from '@dereekb/util';
|
|
4
|
+
export declare function makeNewNotificationSummaryTemplate(model: ModelKey): NotificationSummary;
|
|
5
|
+
export interface ExpandNotificationRecipientsInput {
|
|
6
|
+
readonly notification: Notification;
|
|
7
|
+
readonly notificationBox?: Maybe<NotificationBox>;
|
|
8
|
+
readonly authService: FirebaseServerAuthService;
|
|
9
|
+
/**
|
|
10
|
+
* Used for loading NotificationUsers in the system for accessing default configurations for the "other" recipients not in the NotificationBox.
|
|
11
|
+
*/
|
|
12
|
+
readonly notificationUserAccessor: FirestoreDocumentAccessor<NotificationUser, NotificationUserDocument>;
|
|
13
|
+
/**
|
|
14
|
+
* Factory for creating a NotificationSummaryKey given a uid.
|
|
15
|
+
*
|
|
16
|
+
* If not defined, then notification summaries will not be generated for recipients with uids.
|
|
17
|
+
*/
|
|
18
|
+
readonly notificationSummaryIdForUid?: Maybe<NotificationSummaryIdForUidFunction>;
|
|
19
|
+
/**
|
|
20
|
+
* Overrides the recipient flag for the notification.
|
|
21
|
+
*/
|
|
22
|
+
readonly recipientFlagOverride?: Maybe<NotificationRecipientSendFlag>;
|
|
23
|
+
/**
|
|
24
|
+
* Recipients that come from the message, also known as global recipients.
|
|
25
|
+
*/
|
|
26
|
+
readonly globalRecipients?: Maybe<NotificationRecipientWithConfig[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Only text those who have texting/sms notifications explicitly enabled.
|
|
29
|
+
*
|
|
30
|
+
* Defaults to true.
|
|
31
|
+
*/
|
|
32
|
+
readonly onlyTextExplicitlyEnabledRecipients?: Maybe<boolean>;
|
|
33
|
+
}
|
|
34
|
+
export interface ExpandedNotificationRecipientConfig {
|
|
35
|
+
readonly recipient: Omit<NotificationBoxRecipient, 'i'>;
|
|
36
|
+
readonly effectiveTemplateConfig?: Maybe<NotificationBoxRecipientTemplateConfig>;
|
|
37
|
+
}
|
|
38
|
+
export interface ExpandedNotificationRecipientBase {
|
|
39
|
+
readonly name?: Maybe<string>;
|
|
40
|
+
readonly emailAddress?: Maybe<EmailAddress>;
|
|
41
|
+
readonly phoneNumber?: Maybe<E164PhoneNumber>;
|
|
42
|
+
/**
|
|
43
|
+
* The recipient that is registered with the NotificationBox and their configuration from that box.
|
|
44
|
+
*/
|
|
45
|
+
readonly boxRecipient?: ExpandedNotificationRecipientConfig;
|
|
46
|
+
/**
|
|
47
|
+
* A recipient that is not registered with the NotificationBox but was requested by UID and their configuration from their NotificationUser, if applicable.
|
|
48
|
+
*/
|
|
49
|
+
readonly otherUserRecipient?: ExpandedNotificationRecipientConfig;
|
|
50
|
+
/**
|
|
51
|
+
* The recipient that is not registered with the NotificationBox.
|
|
52
|
+
*/
|
|
53
|
+
readonly otherRecipient?: NotificationRecipientWithConfig;
|
|
54
|
+
}
|
|
55
|
+
export interface ExpandedNotificationRecipientEmail extends ExpandedNotificationRecipientBase {
|
|
56
|
+
readonly emailAddress: EmailAddress;
|
|
57
|
+
}
|
|
58
|
+
export interface ExpandedNotificationRecipientPhone extends ExpandedNotificationRecipientBase {
|
|
59
|
+
readonly phoneNumber: E164PhoneNumber;
|
|
60
|
+
}
|
|
61
|
+
export type ExpandedNotificationRecipientText = ExpandedNotificationRecipientPhone;
|
|
62
|
+
export interface ExpandedNotificationNotificationSummaryRecipient extends Pick<ExpandedNotificationRecipientBase, 'name' | 'boxRecipient' | 'otherRecipient'> {
|
|
63
|
+
readonly notificationSummaryId: NotificationSummaryId;
|
|
64
|
+
}
|
|
65
|
+
export interface ExpandNotificationRecipientsInternal {
|
|
66
|
+
readonly userDetailsMap: Map<string, FirebaseAuthDetails | undefined>;
|
|
67
|
+
readonly explicitRecipients: NotificationRecipientWithConfig[];
|
|
68
|
+
readonly globalRecipients: NotificationRecipientWithConfig[];
|
|
69
|
+
readonly allBoxRecipientConfigs: NotificationBoxRecipient[];
|
|
70
|
+
readonly relevantBoxRecipientConfigs: ExpandedNotificationRecipientConfig[];
|
|
71
|
+
readonly recipientUids: Set<FirebaseAuthUserId>;
|
|
72
|
+
readonly otherRecipientConfigs: Map<FirebaseAuthUserId, NotificationRecipientWithConfig>;
|
|
73
|
+
readonly explicitOtherRecipientEmailAddresses: Map<EmailAddress, NotificationRecipientWithConfig>;
|
|
74
|
+
readonly explicitOtherRecipientTextNumbers: Map<PhoneNumber, NotificationRecipientWithConfig>;
|
|
75
|
+
readonly explicitOtherRecipientNotificationSummaryIds: Map<NotificationSummaryId, NotificationRecipientWithConfig>;
|
|
76
|
+
readonly otherNotificationUserUidOptOuts: Set<NotificationUserId>;
|
|
77
|
+
readonly nonNotificationBoxUidRecipientConfigs: Map<FirebaseAuthUserId, NotificationRecipientWithConfig>;
|
|
78
|
+
readonly notificationUserRecipientConfigs: Map<NotificationUserId, NotificationUserDefaultNotificationBoxRecipientConfig>;
|
|
79
|
+
}
|
|
80
|
+
export interface ExpandNotificationRecipientsResult {
|
|
81
|
+
readonly _internal: ExpandNotificationRecipientsInternal;
|
|
82
|
+
readonly emails: ExpandedNotificationRecipientEmail[];
|
|
83
|
+
readonly texts: ExpandedNotificationRecipientText[];
|
|
84
|
+
readonly notificationSummaries: ExpandedNotificationNotificationSummaryRecipient[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* "Expands" the input into recipients for emails, texts, etc.
|
|
88
|
+
*
|
|
89
|
+
* Recipients may come from the NotificationBox, Notification or from the global recipients.
|
|
90
|
+
*
|
|
91
|
+
* Recipients are each configurable and may be defined with as little info as a single contact info, or have multiple contact info pieces associated with them.
|
|
92
|
+
*
|
|
93
|
+
* @param input
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
export declare function expandNotificationRecipients(input: ExpandNotificationRecipientsInput): Promise<ExpandNotificationRecipientsResult>;
|
|
97
|
+
export interface UpdateNotificationUserNotificationBoxRecipientConfigInput {
|
|
98
|
+
readonly notificationBoxId: NotificationBoxId;
|
|
99
|
+
readonly notificationBoxAssociatedModelKey: ModelKey;
|
|
100
|
+
readonly notificationUserId: NotificationUserId;
|
|
101
|
+
/**
|
|
102
|
+
* The existing NotificationUser.
|
|
103
|
+
*/
|
|
104
|
+
readonly notificationUser: Pick<NotificationUser, 'gc' | 'bc'>;
|
|
105
|
+
/**
|
|
106
|
+
* If true, flag as if the recipient is being inserted into the NotificationBox since it does not exist there.
|
|
107
|
+
*/
|
|
108
|
+
readonly insertingRecipientIntoNotificationBox?: Maybe<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* If true, flag as if the recipient is being removed from the NotificationBox.
|
|
111
|
+
*/
|
|
112
|
+
readonly removeRecipientFromNotificationBox?: Maybe<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* The current NotificationBoxRecipient
|
|
115
|
+
*/
|
|
116
|
+
readonly notificationBoxRecipient: Maybe<NotificationBoxRecipient>;
|
|
117
|
+
}
|
|
118
|
+
export interface UpdateNotificationUserNotificationBoxRecipientConfigResult {
|
|
119
|
+
/**
|
|
120
|
+
* New configs array, if changes occured.
|
|
121
|
+
*/
|
|
122
|
+
readonly updatedBc?: Maybe<NotificationUserNotificationBoxRecipientConfig[]>;
|
|
123
|
+
/**
|
|
124
|
+
* The updated NotificationBox recipient
|
|
125
|
+
*/
|
|
126
|
+
readonly updatedNotificationBoxRecipient: Maybe<NotificationBoxRecipient>;
|
|
127
|
+
}
|
|
128
|
+
export declare function updateNotificationUserNotificationBoxRecipientConfig(input: UpdateNotificationUserNotificationBoxRecipientConfigInput): UpdateNotificationUserNotificationBoxRecipientConfigResult;
|