@dereekb/firebase 12.3.12 → 12.3.13
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/index.cjs.js +228 -94
- package/index.esm.js +223 -95
- package/package.json +1 -1
- package/src/lib/model/notification/notification.api.d.ts +9 -0
- package/src/lib/model/notification/notification.api.error.d.ts +1 -0
- package/src/lib/model/notification/notification.config.d.ts +8 -2
- package/src/lib/model/notification/notification.d.ts +13 -1
- package/src/lib/model/notification/notification.id.d.ts +13 -1
- package/src/lib/model/notification/notification.message.d.ts +2 -2
- package/src/lib/model/notification/notification.query.d.ts +9 -0
- package/src/lib/model/notification/notification.util.d.ts +29 -2
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +1 -1
package/package.json
CHANGED
|
@@ -211,6 +211,15 @@ export declare class UpdateNotificationBoxRecipientParams extends UpdateNotifica
|
|
|
211
211
|
* Whether or not to remove the user if they exist. Defaults to false.
|
|
212
212
|
*/
|
|
213
213
|
remove?: Maybe<boolean>;
|
|
214
|
+
/**
|
|
215
|
+
* If true, the target recipient will have this NotificationBox added to their exclusion list.
|
|
216
|
+
* If false, the target recipient will have this NotificationBox removed from their exclusion list.
|
|
217
|
+
*
|
|
218
|
+
* If set, the other functions are ignored.
|
|
219
|
+
*
|
|
220
|
+
* If targeting the user by the index, the NotificationBox must exist, and the user must have a uid, otherwise an error will be thrown.
|
|
221
|
+
*/
|
|
222
|
+
setExclusion?: Maybe<boolean>;
|
|
214
223
|
}
|
|
215
224
|
export declare class NotificationRecipientParams {
|
|
216
225
|
/**
|
|
@@ -3,6 +3,7 @@ export declare const NOTIFICATION_MODEL_ALREADY_INITIALIZED_ERROR_CODE = "NOTIFI
|
|
|
3
3
|
export declare const NOTIFICATION_BOX_DOES_NOT_EXIST_ERROR_CODE = "NOTIFICATION_BOX_DOES_NOT_EXIST";
|
|
4
4
|
export declare const NOTIFICATION_BOX_EXISTS_FOR_MODEL_ERROR_CODE = "NOTIFICATION_BOX_EXISTS_FOR_MODEL";
|
|
5
5
|
export declare const NOTIFICATION_BOX_RECIPIENT_DOES_NOT_EXIST_ERROR_CODE = "NOTIFICATION_BOX_RECIPIENT_DOES_NOT_EXIST";
|
|
6
|
+
export declare const NOTIFICATION_BOX_EXCLUSION_TARGET_INVALID_ERROR_CODE = "NOTIFICATION_BOX_EXCLUSION_TARGET_INVALID";
|
|
6
7
|
export declare const NOTIFICATION_USER_INVALID_UID_FOR_CREATE_ERROR_CODE = "NOTIFICATION_USER_INVALID_UID_FOR_CREATE";
|
|
7
8
|
export declare const NOTIFICATION_USER_BLOCKED_FROM_BEING_ADD_TO_RECIPIENTS_ERROR_CODE = "NOTIFICATION_USER_BLOCKED_FROM_BEING_ADD_TO_RECIPIENTS";
|
|
8
9
|
export declare const NOTIFICATION_USER_LOCKED_CONFIG_FROM_BEING_UPDATED_ERROR_CODE = "NOTIFICATION_USER_LOCKED_CONFIG_FROM_BEING_UPDATED";
|
|
@@ -29,7 +29,7 @@ export interface NotificationBoxRecipientTemplateConfig {
|
|
|
29
29
|
sn?: Maybe<boolean>;
|
|
30
30
|
}
|
|
31
31
|
export declare function mergeNotificationBoxRecipientTemplateConfigs(a?: Maybe<NotificationBoxRecipientTemplateConfig>, b?: Maybe<NotificationBoxRecipientTemplateConfig>): NotificationBoxRecipientTemplateConfig;
|
|
32
|
-
export declare function effectiveNotificationBoxRecipientTemplateConfig(
|
|
32
|
+
export declare function effectiveNotificationBoxRecipientTemplateConfig(a: NotificationBoxRecipientTemplateConfig): NotificationBoxRecipientTemplateConfig;
|
|
33
33
|
/**
|
|
34
34
|
* Recipient configuration for a notification
|
|
35
35
|
*/
|
|
@@ -83,6 +83,12 @@ export declare enum NotificationBoxRecipientFlag {
|
|
|
83
83
|
* If uid is set, then most other NotificationRecipient fields are ignored as those are pulled from auth.
|
|
84
84
|
*/
|
|
85
85
|
export interface NotificationBoxRecipient extends NotificationRecipient, IndexRef {
|
|
86
|
+
/**
|
|
87
|
+
* Whether or not this recipient has been marked as excluded.
|
|
88
|
+
*
|
|
89
|
+
* This can only be updated by removing the exclusion from the.
|
|
90
|
+
*/
|
|
91
|
+
x?: Maybe<SavedToFirestoreIfTrue>;
|
|
86
92
|
/**
|
|
87
93
|
* Enabled config types
|
|
88
94
|
*/
|
|
@@ -104,7 +110,7 @@ export declare function newNotificationBoxRecipientForUid(uid: FirebaseAuthUserI
|
|
|
104
110
|
/**
|
|
105
111
|
* Default NotificationUserNotificationBoxRecipientConfig.
|
|
106
112
|
*/
|
|
107
|
-
export interface NotificationUserDefaultNotificationBoxRecipientConfig extends Omit<NotificationBoxRecipient, 'i' | 'n' | 's' | 'uid'> {
|
|
113
|
+
export interface NotificationUserDefaultNotificationBoxRecipientConfig extends Omit<NotificationBoxRecipient, 'i' | 'n' | 's' | 'uid' | 'x'> {
|
|
108
114
|
/**
|
|
109
115
|
* Locked state.
|
|
110
116
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type E164PhoneNumber, type EmailAddress, type Maybe, type NeedsSyncBoolean } from '@dereekb/util';
|
|
2
2
|
import { type GrantedReadRole, type GrantedUpdateRole } from '@dereekb/model';
|
|
3
|
-
import { type NotificationBoxId } from './notification.id';
|
|
3
|
+
import { NotificationBoxSendExclusionList, type NotificationBoxId } from './notification.id';
|
|
4
4
|
import { type NotificationBoxRecipient, type NotificationRecipientWithConfig, type NotificationUserNotificationBoxRecipientConfig, type NotificationUserDefaultNotificationBoxRecipientConfig } from './notification.config';
|
|
5
5
|
import { type YearWeekCode } from '@dereekb/date';
|
|
6
6
|
import { type UserRelatedById, type UserRelated } from '../user';
|
|
@@ -48,6 +48,18 @@ export interface NotificationUser extends UserRelated, UserRelatedById {
|
|
|
48
48
|
* List of notification boxes this user is associated with. Cannot be changed directly.
|
|
49
49
|
*/
|
|
50
50
|
b: NotificationBoxId[];
|
|
51
|
+
/**
|
|
52
|
+
* Notification box id exclusion list. This value is treated used to generated send opt-outs.
|
|
53
|
+
*
|
|
54
|
+
* This list is used to exclude a user from recieving notifications from the NotificationBoxes in this list.
|
|
55
|
+
*
|
|
56
|
+
* Values in this list are usually populated from functions from the model controlling the NotificationBox.
|
|
57
|
+
*
|
|
58
|
+
* The user must be associated with atleast one NotificationBoxId that matches items in this list, otherwise non-matching items are removed.
|
|
59
|
+
*
|
|
60
|
+
* The exclusions are sync'd to the corresponding bc values, which are then sync'd to the NotificationBoxes.
|
|
61
|
+
*/
|
|
62
|
+
x: NotificationBoxSendExclusionList;
|
|
51
63
|
/**
|
|
52
64
|
* Global config override.
|
|
53
65
|
*
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { type FactoryWithRequiredInput } from '@dereekb/util';
|
|
2
|
-
import { type FirestoreModelId, type FirestoreModelKey, type FlatFirestoreModelKey, twoWayFlatFirestoreModelKey, inferKeyFromTwoWayFlatFirestoreModelKey, type FirebaseAuthUserId, type RootFirestoreModelIdentity, FirestoreModelIdInput } from '../../common';
|
|
2
|
+
import { type FirestoreModelId, type FirestoreModelKey, type FlatFirestoreModelKey, twoWayFlatFirestoreModelKey, inferKeyFromTwoWayFlatFirestoreModelKey, type FirebaseAuthUserId, type RootFirestoreModelIdentity, FirestoreModelIdInput, FirestoreCollectionName } from '../../common';
|
|
3
3
|
/**
|
|
4
4
|
* The NotificationBox's id is the two way flat firestore model key of the object that it represents.
|
|
5
5
|
*/
|
|
6
6
|
export type NotificationBoxId = FlatFirestoreModelKey;
|
|
7
7
|
export type NotificationBoxKey = FirestoreModelKey;
|
|
8
|
+
/**
|
|
9
|
+
* A notification box id (or firestore collection name) that is used to exclude a user from receiving notifications from that box or any notification boxes that start with the same prefix.
|
|
10
|
+
*
|
|
11
|
+
* This is used in cases where a user might be removed from access temporarily and should not recieve any notifications from that box or any child boxes.
|
|
12
|
+
*
|
|
13
|
+
* For example, if a box with id ab_123 is excluded, then any notifications to child boxes that start with ab_123 (e.g. ab_123_cd_456) will also be excluded.
|
|
14
|
+
*/
|
|
15
|
+
export type NotificationBoxSendExclusion = FirestoreCollectionName | NotificationBoxId;
|
|
16
|
+
/**
|
|
17
|
+
* List of notification box exclusions.
|
|
18
|
+
*/
|
|
19
|
+
export type NotificationBoxSendExclusionList = NotificationBoxSendExclusion[];
|
|
8
20
|
/**
|
|
9
21
|
* Creates a NotificationBoxId from the input FirestoreModelKey.
|
|
10
22
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Maybe, type WebsiteUrl } from '@dereekb/util';
|
|
1
|
+
import { PromiseOrValue, type Maybe, type WebsiteUrl } from '@dereekb/util';
|
|
2
2
|
import { type NotificationRecipient, type NotificationRecipientWithConfig } from './notification.config';
|
|
3
3
|
import { NotificationSendFlags, type Notification, type NotificationBox } from './notification';
|
|
4
4
|
import { type NotificationItem, type NotificationItemMetadata } from './notification.item';
|
|
@@ -138,7 +138,7 @@ export interface NotificationMessageFunctionExtrasCallbackDetails {
|
|
|
138
138
|
readonly sendTextsResult?: Maybe<NotificationSendTextMessagesResult>;
|
|
139
139
|
readonly sendNotificationSummaryResult?: Maybe<NotificationSendNotificationSummaryMessagesResult>;
|
|
140
140
|
}
|
|
141
|
-
export type NotificationMessageFunctionExtrasCallbackFunction = (callbackDetails: NotificationMessageFunctionExtrasCallbackDetails) =>
|
|
141
|
+
export type NotificationMessageFunctionExtrasCallbackFunction = (callbackDetails: NotificationMessageFunctionExtrasCallbackDetails) => PromiseOrValue<unknown>;
|
|
142
142
|
export interface NotificationMessageFunctionExtras {
|
|
143
143
|
/**
|
|
144
144
|
* Any global/additional recipient(s) that should be added to all Notifications associated with this NotificationMessageFunctionExtras.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type FirestoreQueryConstraint } from '../../common/firestore';
|
|
2
|
+
import { NotificationBoxSendExclusion } from './notification.id';
|
|
3
|
+
import { type ArrayOrValue } from '@dereekb/util';
|
|
2
4
|
/**
|
|
3
5
|
* Query for notificationUsers that are flagged for initialization.
|
|
4
6
|
*
|
|
@@ -6,6 +8,13 @@ import { type FirestoreQueryConstraint } from '../../common/firestore';
|
|
|
6
8
|
* @returns
|
|
7
9
|
*/
|
|
8
10
|
export declare function notificationUsersFlaggedForNeedsSyncQuery(): FirestoreQueryConstraint[];
|
|
11
|
+
/**
|
|
12
|
+
* Query for notificationUsers that have excluded any of the input notification box ids.
|
|
13
|
+
*
|
|
14
|
+
* @param now
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function notificationUserHasExclusionQuery(exclusionId: ArrayOrValue<NotificationBoxSendExclusion>): FirestoreQueryConstraint[];
|
|
9
18
|
/**
|
|
10
19
|
* Query for notificationSummaries that are flagged for initialization.
|
|
11
20
|
*
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type Maybe } from '@dereekb/util';
|
|
2
|
-
import { type Notification, type NotificationBox, type NotificationBoxDocument, NotificationRecipientSendFlag, type NotificationSendFlags, NotificationSendState } from './notification';
|
|
1
|
+
import { ArrayOrValue, type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type Notification, type NotificationBox, type NotificationBoxDocument, NotificationRecipientSendFlag, type NotificationSendFlags, NotificationSendState, NotificationUser } from './notification';
|
|
3
3
|
import { type NotificationUserNotificationBoxRecipientConfig, type NotificationBoxRecipient, type NotificationUserDefaultNotificationBoxRecipientConfig } from './notification.config';
|
|
4
4
|
import { type AppNotificationTemplateTypeInfoRecordService } from './notification.details';
|
|
5
5
|
import { type FirebaseAuthUserId, type FirestoreDocumentAccessor, type FirestoreModelKey } from '../../common';
|
|
6
|
+
import { NotificationBoxId, NotificationId, NotificationBoxSendExclusionList, NotificationBoxSendExclusion } from './notification.id';
|
|
6
7
|
export interface EffectiveNotificationBoxRecipientConfigInput {
|
|
7
8
|
readonly uid: FirebaseAuthUserId;
|
|
8
9
|
readonly m?: FirestoreModelKey;
|
|
@@ -12,6 +13,32 @@ export interface EffectiveNotificationBoxRecipientConfigInput {
|
|
|
12
13
|
readonly recipient?: Maybe<NotificationBoxRecipient>;
|
|
13
14
|
}
|
|
14
15
|
export declare function effectiveNotificationBoxRecipientConfig(input: EffectiveNotificationBoxRecipientConfigInput): NotificationBoxRecipient;
|
|
16
|
+
export interface UpdateNotificationUserNotificationSendExclusionsInput {
|
|
17
|
+
readonly notificationUser: Pick<NotificationUser, 'b' | 'x' | 'bc'>;
|
|
18
|
+
readonly addExclusions?: ArrayOrValue<NotificationBoxSendExclusion>;
|
|
19
|
+
readonly removeExclusions?: ArrayOrValue<NotificationBoxSendExclusion>;
|
|
20
|
+
}
|
|
21
|
+
export interface UpdateNotificationUserNotificationSendExclusionsResult {
|
|
22
|
+
readonly nextExclusions: NotificationBoxSendExclusionList;
|
|
23
|
+
readonly update: Pick<NotificationUser, 'x' | 'ns' | 'bc'>;
|
|
24
|
+
}
|
|
25
|
+
export declare function updateNotificationUserNotificationSendExclusions(input: UpdateNotificationUserNotificationSendExclusionsInput): UpdateNotificationUserNotificationSendExclusionsResult;
|
|
26
|
+
export interface ApplyExclusionsToNotificationUserNotificationBoxRecipientConfigsParams {
|
|
27
|
+
readonly x?: NotificationBoxSendExclusionList;
|
|
28
|
+
readonly bc?: Maybe<NotificationUserNotificationBoxRecipientConfig[]>;
|
|
29
|
+
readonly notificationUser?: Pick<NotificationUser, 'bc' | 'x'>;
|
|
30
|
+
readonly recalculateNs?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type ApplyExclusionsToNotificationUserNotificationBoxRecipientConfigsResult = Pick<NotificationUser, 'bc' | 'ns'>;
|
|
33
|
+
export declare function applyExclusionsToNotificationUserNotificationBoxRecipientConfigs(params: ApplyExclusionsToNotificationUserNotificationBoxRecipientConfigsParams): ApplyExclusionsToNotificationUserNotificationBoxRecipientConfigsResult;
|
|
34
|
+
export declare function calculateNsForNotificationUserNotificationBoxRecipientConfigs(configs: NotificationUserNotificationBoxRecipientConfig[]): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Function that returns true if the notification is not excluded from being sent.
|
|
37
|
+
*/
|
|
38
|
+
export type NotificationSendExclusionCanSendFunction = ((notification: NotificationId | NotificationBoxId) => boolean) & {
|
|
39
|
+
readonly _exclusions: NotificationBoxSendExclusionList;
|
|
40
|
+
};
|
|
41
|
+
export declare const notificationSendExclusionCanSendFunction: (exclusions: NotificationBoxSendExclusionList) => NotificationSendExclusionCanSendFunction;
|
|
15
42
|
/**
|
|
16
43
|
* Returns true if the notification's send types are all marked as sent.
|
|
17
44
|
*
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [12.3.13](https://github.com/dereekb/dbx-components/compare/v12.3.12-dev...v12.3.13) (2025-08-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [12.3.12](https://github.com/dereekb/dbx-components/compare/v12.3.11-dev...v12.3.12) (2025-08-20)
|
|
6
10
|
|
|
7
11
|
|