@dereekb/firebase 11.0.21 → 11.1.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.
Files changed (28) hide show
  1. package/index.cjs.js +1881 -93
  2. package/index.esm.js +2042 -37
  3. package/package.json +3 -2
  4. package/src/lib/client/error/error.d.ts +8 -0
  5. package/src/lib/client/error/index.d.ts +1 -0
  6. package/src/lib/client/firestore/error.d.ts +1 -0
  7. package/src/lib/client/firestore/index.d.ts +1 -0
  8. package/src/lib/client/index.d.ts +1 -0
  9. package/src/lib/common/firestore/accessor/document.utility.d.ts +4 -0
  10. package/src/lib/common/firestore/collection/collection.d.ts +6 -1
  11. package/src/lib/model/index.d.ts +1 -0
  12. package/src/lib/model/notification/index.d.ts +14 -0
  13. package/src/lib/model/notification/notification.action.d.ts +24 -0
  14. package/src/lib/model/notification/notification.api.d.ts +389 -0
  15. package/src/lib/model/notification/notification.api.error.d.ts +7 -0
  16. package/src/lib/model/notification/notification.api.util.d.ts +31 -0
  17. package/src/lib/model/notification/notification.config.d.ts +207 -0
  18. package/src/lib/model/notification/notification.create.d.ts +139 -0
  19. package/src/lib/model/notification/notification.d.ts +403 -0
  20. package/src/lib/model/notification/notification.details.d.ts +98 -0
  21. package/src/lib/model/notification/notification.id.d.ts +49 -0
  22. package/src/lib/model/notification/notification.item.d.ts +70 -0
  23. package/src/lib/model/notification/notification.message.d.ts +152 -0
  24. package/src/lib/model/notification/notification.query.d.ts +43 -0
  25. package/src/lib/model/notification/notification.send.d.ts +22 -0
  26. package/src/lib/model/notification/notification.util.d.ts +51 -0
  27. package/test/CHANGELOG.md +4 -0
  28. package/test/package.json +1 -1
@@ -0,0 +1,152 @@
1
+ import { type Maybe, type WebsiteUrl } from '@dereekb/util';
2
+ import { type NotificationRecipient, type NotificationRecipientWithConfig } from './notification.config';
3
+ import { type Notification, type NotificationBox } from './notification';
4
+ import { type NotificationItem, type NotificationItemMetadata } from './notification.item';
5
+ import { type DocumentDataWithIdAndKey } from '../../common';
6
+ /**
7
+ * Contextual information when
8
+ */
9
+ export interface NotificationMessageInputContext {
10
+ /**
11
+ * Recipient of the notification.
12
+ */
13
+ readonly recipient: NotificationRecipient;
14
+ }
15
+ /**
16
+ * Arbitrary template name/key that is used to configure which template to use by the sending service.
17
+ */
18
+ export type NotificationSendMessageTemplateName = string;
19
+ /**
20
+ * Generic notification message content.
21
+ */
22
+ export interface NotificationMessageContent {
23
+ /**
24
+ * Explicit send template name to use, if applicable.
25
+ *
26
+ * The sending service determines how this template is used.
27
+ */
28
+ readonly sendTemplateName?: Maybe<NotificationSendMessageTemplateName>;
29
+ /**
30
+ * The title/subject of the message for the recipient
31
+ */
32
+ readonly title: string;
33
+ /**
34
+ * The message for the recipient
35
+ */
36
+ readonly openingMessage?: Maybe<string>;
37
+ /**
38
+ * Bolded/Highlighted information
39
+ */
40
+ readonly boldHighlight?: Maybe<string>;
41
+ /**
42
+ * Second paragraph. Comes after the main message and bold content.
43
+ */
44
+ readonly closingMessage?: Maybe<string>;
45
+ /**
46
+ * The associated action.
47
+ */
48
+ readonly action?: Maybe<string>;
49
+ /**
50
+ * Url the action goes to.
51
+ */
52
+ readonly actionUrl?: Maybe<WebsiteUrl>;
53
+ }
54
+ export interface NotificationMessageEmailContent extends NotificationMessageContent {
55
+ /**
56
+ * Email subject. If not defined, defaults to the title.
57
+ */
58
+ readonly subject?: string;
59
+ /**
60
+ * Email action prompt. If not defined, defaults to the title.
61
+ */
62
+ readonly prompt?: string;
63
+ }
64
+ export interface NotificationMessageNotificationSummaryContent {
65
+ }
66
+ export declare enum NotificationMessageFlag {
67
+ /**
68
+ * No flag
69
+ */
70
+ NONE = 0,
71
+ /**
72
+ * Special flag to indicate there is no content. Should not be sent.
73
+ */
74
+ NO_CONTENT = 1,
75
+ /**
76
+ * Special flag to not send the notification.
77
+ */
78
+ DO_NOT_SEND = 2
79
+ }
80
+ /**
81
+ * A NotificationMessage is the final result of the expanded notification.
82
+ */
83
+ export interface NotificationMessage<D extends NotificationItemMetadata = {}> {
84
+ /**
85
+ * Optional flag
86
+ */
87
+ readonly flag?: NotificationMessageFlag;
88
+ /**
89
+ * Associated item used to generate the content.
90
+ *
91
+ * Is required for sending NotificationSummary messages.
92
+ */
93
+ readonly item?: NotificationItem<D>;
94
+ /**
95
+ * The input context used to generate the message.
96
+ */
97
+ readonly inputContext: NotificationMessageInputContext;
98
+ /**
99
+ * The output content.
100
+ */
101
+ readonly content: NotificationMessageContent;
102
+ /**
103
+ * Content specific for an email.
104
+ */
105
+ readonly emailContent?: NotificationMessageEmailContent;
106
+ /**
107
+ * Content specific for a text.
108
+ */
109
+ readonly textContent?: NotificationMessageContent;
110
+ /**
111
+ * Content specific for notification summaries.
112
+ */
113
+ readonly notificationSummaryContent?: NotificationMessageNotificationSummaryContent;
114
+ }
115
+ export interface NotificationMessageFunctionFactoryConfig<D extends NotificationItemMetadata = {}> {
116
+ /**
117
+ * Notification item.
118
+ */
119
+ readonly item: NotificationItem<D>;
120
+ /**
121
+ * NotificationBox details for this message.
122
+ */
123
+ readonly notificationBox: Pick<NotificationBox, 'm'>;
124
+ /**
125
+ * Full Notification for this message.
126
+ */
127
+ readonly notification: DocumentDataWithIdAndKey<Notification>;
128
+ }
129
+ /**
130
+ * Creates a NotificationMessageFunction from the input config.
131
+ */
132
+ export type NotificationMessageFunctionFactory<D extends NotificationItemMetadata = {}> = (config: NotificationMessageFunctionFactoryConfig<D>) => Promise<NotificationMessageFunction>;
133
+ export interface NotificationMessageFunctionExtras {
134
+ /**
135
+ * Any global/additional recipient(s) that should be added to all Notifications associated with this NotificationMessageFunctionExtras.
136
+ */
137
+ readonly globalRecipients?: Maybe<NotificationRecipientWithConfig[]>;
138
+ }
139
+ export type NotificationMessageFunctionWithoutExtras = (inputContext: NotificationMessageInputContext) => Promise<NotificationMessage>;
140
+ /**
141
+ * Converts a NotificationMessageContext to a NotificationMessage.
142
+ */
143
+ export type NotificationMessageFunction = NotificationMessageFunctionWithoutExtras & NotificationMessageFunctionExtras;
144
+ /**
145
+ * Creates a NotificationMessageFunction from the input.
146
+ *
147
+ * @param fn
148
+ * @param extras
149
+ * @returns
150
+ */
151
+ export declare function notificationMessageFunction(fn: NotificationMessageFunctionWithoutExtras, extras?: NotificationMessageFunctionExtras): NotificationMessageFunction;
152
+ export declare function noContentNotificationMessageFunctionFactory<D extends NotificationItemMetadata = any>(): NotificationMessageFunctionFactory<D>;
@@ -0,0 +1,43 @@
1
+ import { type FirestoreQueryConstraint } from '../../common/firestore';
2
+ /**
3
+ * Query for notificationUsers that are flagged for initialization.
4
+ *
5
+ * @param now
6
+ * @returns
7
+ */
8
+ export declare function notificationUsersFlaggedForNeedsSyncQuery(): FirestoreQueryConstraint[];
9
+ /**
10
+ * Query for notificationSummaries that are flagged for initialization.
11
+ *
12
+ * @param now
13
+ * @returns
14
+ */
15
+ export declare function notificationSummariesFlaggedForNeedsInitializationQuery(): FirestoreQueryConstraint[];
16
+ /**
17
+ * Query for notificationBoxes that are flagged for initialization.
18
+ *
19
+ * @param now
20
+ * @returns
21
+ */
22
+ export declare function notificationBoxesFlaggedForNeedsInitializationQuery(): FirestoreQueryConstraint[];
23
+ /**
24
+ * Query for notificationBoxes that are flagged as invalid.
25
+ *
26
+ * @param now
27
+ * @returns
28
+ */
29
+ export declare function notificationBoxesFlaggedInvalidQuery(): FirestoreQueryConstraint[];
30
+ /**
31
+ * Query for notifications that are not done and the send at time is in the past.
32
+ *
33
+ * @param now
34
+ * @returns
35
+ */
36
+ export declare function notificationsPastSendAtTimeQuery(now?: Date): FirestoreQueryConstraint[];
37
+ /**
38
+ * Query for notifications that are marked ready for cleanup/deletion.
39
+ *
40
+ * @param now
41
+ * @returns
42
+ */
43
+ export declare function notificationsReadyForCleanupQuery(): FirestoreQueryConstraint[];
@@ -0,0 +1,22 @@
1
+ import { type Maybe, type EmailAddress, type E164PhoneNumber } from '@dereekb/util';
2
+ import { type NotificationSummaryId } from './notification.id';
3
+ export interface NotificationSendMessagesResult<K> {
4
+ /**
5
+ * Set of all successful recipients.
6
+ */
7
+ readonly success: K[];
8
+ /**
9
+ * Set of all failed recipients.
10
+ *
11
+ * A failed recipient is a valid recipient that failed due to a temporary error and should be retried again it the future.
12
+ */
13
+ readonly failed: K[];
14
+ /**
15
+ * Set of all ignored recipients, if applicable..
16
+ */
17
+ readonly ignored: K[];
18
+ }
19
+ export declare function mergeNotificationSendMessagesResult<K>(a: Maybe<NotificationSendMessagesResult<K>>, b: Maybe<NotificationSendMessagesResult<K>>): NotificationSendMessagesResult<K>;
20
+ export type NotificationSendEmailMessagesResult = NotificationSendMessagesResult<EmailAddress>;
21
+ export type NotificationSendTextMessagesResult = NotificationSendMessagesResult<E164PhoneNumber>;
22
+ export type NotificationSendNotificationSummaryMessagesResult = NotificationSendMessagesResult<NotificationSummaryId>;
@@ -0,0 +1,51 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type Notification, NotificationRecipientSendFlag, type NotificationSendFlags, NotificationSendState } from './notification';
3
+ import { type NotificationUserNotificationBoxRecipientConfig, type NotificationBoxRecipient, type NotificationUserDefaultNotificationBoxRecipientConfig } from './notification.config';
4
+ import { type AppNotificationTemplateTypeInfoRecordService } from './notification.details';
5
+ import { type FirebaseAuthUserId, type FirestoreModelKey } from '../../common';
6
+ export interface EffectiveNotificationBoxRecipientConfigInput {
7
+ readonly uid: FirebaseAuthUserId;
8
+ readonly m?: FirestoreModelKey;
9
+ readonly appNotificationTemplateTypeInfoRecordService: AppNotificationTemplateTypeInfoRecordService;
10
+ readonly gc: NotificationUserDefaultNotificationBoxRecipientConfig;
11
+ readonly boxConfig: NotificationUserNotificationBoxRecipientConfig;
12
+ readonly recipient?: Maybe<NotificationBoxRecipient>;
13
+ }
14
+ export declare function effectiveNotificationBoxRecipientConfig(input: EffectiveNotificationBoxRecipientConfigInput): NotificationBoxRecipient;
15
+ /**
16
+ * Returns true if the notification's send types are all marked as sent.
17
+ *
18
+ * @param input
19
+ * @returns
20
+ */
21
+ export declare function notificationSendFlagsImplyIsComplete(input: NotificationSendFlags): boolean;
22
+ /**
23
+ * Returns true if the state implies completion of sending (not necessarily success, but that attempts to send are done)
24
+ *
25
+ * @param input
26
+ * @returns
27
+ */
28
+ export declare function isCompleteNotificationSendState(input: NotificationSendState): boolean;
29
+ export interface AllowedNotificationRecipients {
30
+ readonly canSendToGlobalRecipients: boolean;
31
+ readonly canSendToBoxRecipients: boolean;
32
+ readonly canSendToExplicitRecipients: boolean;
33
+ }
34
+ /**
35
+ * Returns a AllowedNotificationRecipients from the input NotificationRecipientSendFlag.
36
+ *
37
+ * @param flag
38
+ * @returns
39
+ */
40
+ export declare function allowedNotificationRecipients(flag?: Maybe<NotificationRecipientSendFlag>): AllowedNotificationRecipients;
41
+ /**
42
+ * Whether or not the Notification should be saved to the NotificationWeek.
43
+ *
44
+ * A Notification should only be saved when the notification can be sent to box recipients.
45
+ *
46
+ * @param notification
47
+ * @returns
48
+ */
49
+ export declare function shouldSaveNotificationToNotificationWeek(notification: Notification): boolean;
50
+ export declare function mergeNotificationUserNotificationBoxRecipientConfigs(a: NotificationUserNotificationBoxRecipientConfig, b: Partial<NotificationUserNotificationBoxRecipientConfig>): NotificationUserNotificationBoxRecipientConfig;
51
+ export declare function mergeNotificationBoxRecipients<T extends NotificationBoxRecipient>(a: T, b: Partial<T>): T;
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
+ # [11.1.0](https://github.com/dereekb/dbx-components/compare/v11.0.21-dev...v11.1.0) (2025-02-28)
6
+
7
+
8
+
5
9
  ## [11.0.21](https://github.com/dereekb/dbx-components/compare/v11.0.20-dev...v11.0.21) (2025-01-28)
6
10
 
7
11
 
package/test/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase/test",
3
- "version": "11.0.21",
3
+ "version": "11.1.0",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {
6
6
  "@dereekb/util": "*",