@dereekb/firebase 11.1.1 → 11.1.3

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 CHANGED
@@ -9073,6 +9073,12 @@ const notificationConverter = snapshotConverterFunctions({
9073
9073
  r: firestoreObjectArray({
9074
9074
  objectField: firestoreNotificationRecipientWithConfig
9075
9075
  }),
9076
+ ois: optionalFirestoreBoolean({
9077
+ dontStoreIf: false
9078
+ }),
9079
+ ots: optionalFirestoreBoolean({
9080
+ dontStoreIf: true
9081
+ }),
9076
9082
  sat: firestoreDate(),
9077
9083
  a: firestoreNumber({
9078
9084
  default: 0
@@ -9713,8 +9719,13 @@ function createNotificationTemplate(input) {
9713
9719
  const notificationModel = readFirestoreModelKey(inputNotification);
9714
9720
  const targetModel = inputTargetModel ? readFirestoreModelKey(inputTargetModel) : undefined;
9715
9721
  let d = data != null ? data : inputD;
9716
- if (d && util.objectHasNoKeys(d)) {
9717
- d = undefined;
9722
+ if (d != null) {
9723
+ const filteredData = util.filterUndefinedValues(d, true); // filter both null and undefined values
9724
+ if (util.objectHasNoKeys(filteredData)) {
9725
+ d = undefined;
9726
+ } else {
9727
+ d = filteredData;
9728
+ }
9718
9729
  }
9719
9730
  const template = {
9720
9731
  notificationModel,
@@ -9826,7 +9837,7 @@ function createNotificationDocumentPair(input) {
9826
9837
  }
9827
9838
 
9828
9839
  /**
9829
- * Creates a NotificationTemplateTypeInfoRecord from the input details array.
9840
+ * Creates a NotificationTemplateTypeInfoRecord from the input info array.
9830
9841
  *
9831
9842
  * @param infoArray
9832
9843
  * @returns
@@ -9851,19 +9862,19 @@ function appNotificationTemplateTypeInfoRecordService(appNotificationTemplateTyp
9851
9862
  const targetModelTypeInfoMapBuilder = util.multiValueMapBuilder();
9852
9863
  const allKnownTemplateTypes = [];
9853
9864
  const allKnownTemplateTypeInfo = [];
9854
- Object.entries(appNotificationTemplateTypeInfoRecord).forEach(([_, details]) => {
9865
+ Object.entries(appNotificationTemplateTypeInfoRecord).forEach(([_, info]) => {
9855
9866
  const {
9856
9867
  notificationModelIdentity,
9857
9868
  targetModelIdentity,
9858
9869
  alternativeModelIdentities
9859
- } = details;
9870
+ } = info;
9860
9871
  function addInfoForIdentity(modelIdentity, targetIdentity) {
9861
9872
  var _targetIdentity$colle;
9862
9873
  const {
9863
9874
  collectionType
9864
9875
  } = modelIdentity;
9865
- notificationModelTypeInfoMapBuilder.add(collectionType, details);
9866
- targetModelTypeInfoMapBuilder.add((_targetIdentity$colle = targetIdentity == null ? void 0 : targetIdentity.collectionType) != null ? _targetIdentity$colle : collectionType, details);
9876
+ notificationModelTypeInfoMapBuilder.add(collectionType, info);
9877
+ targetModelTypeInfoMapBuilder.add((_targetIdentity$colle = targetIdentity == null ? void 0 : targetIdentity.collectionType) != null ? _targetIdentity$colle : collectionType, info);
9867
9878
  allNotificationModelIdentityValuesSet.add(modelIdentity);
9868
9879
  }
9869
9880
  addInfoForIdentity(notificationModelIdentity, targetModelIdentity);
@@ -9873,8 +9884,8 @@ function appNotificationTemplateTypeInfoRecordService(appNotificationTemplateTyp
9873
9884
  addInfoForIdentity(x.altNotificationModelIdentity, (_x$altTargetModelIden = x.altTargetModelIdentity) != null ? _x$altTargetModelIden : targetModelIdentity);
9874
9885
  });
9875
9886
  }
9876
- allKnownTemplateTypeInfo.push(details);
9877
- allKnownTemplateTypes.push(details.type);
9887
+ allKnownTemplateTypeInfo.push(info);
9888
+ allKnownTemplateTypes.push(info.type);
9878
9889
  });
9879
9890
  const allNotificationModelIdentityValues = Array.from(allNotificationModelIdentityValuesSet);
9880
9891
  const notificationModelTemplateInfoMap = notificationModelTypeInfoMapBuilder.map();
package/index.esm.js CHANGED
@@ -9902,6 +9902,12 @@ const notificationConverter = snapshotConverterFunctions({
9902
9902
  r: firestoreObjectArray({
9903
9903
  objectField: firestoreNotificationRecipientWithConfig
9904
9904
  }),
9905
+ ois: optionalFirestoreBoolean({
9906
+ dontStoreIf: false
9907
+ }),
9908
+ ots: optionalFirestoreBoolean({
9909
+ dontStoreIf: true
9910
+ }),
9905
9911
  sat: firestoreDate(),
9906
9912
  a: firestoreNumber({
9907
9913
  default: 0
@@ -10717,8 +10723,14 @@ function createNotificationTemplate(input) {
10717
10723
  const notificationModel = readFirestoreModelKey(inputNotification);
10718
10724
  const targetModel = inputTargetModel ? readFirestoreModelKey(inputTargetModel) : undefined;
10719
10725
  let d = data != null ? data : inputD;
10720
- if (d && objectHasNoKeys(d)) {
10721
- d = undefined;
10726
+ if (d != null) {
10727
+ const filteredData = filterUndefinedValues(d, true); // filter both null and undefined values
10728
+
10729
+ if (objectHasNoKeys(filteredData)) {
10730
+ d = undefined;
10731
+ } else {
10732
+ d = filteredData;
10733
+ }
10722
10734
  }
10723
10735
  const template = {
10724
10736
  notificationModel,
@@ -10890,7 +10902,7 @@ async function createNotificationDocumentIfSending(input) {
10890
10902
  */
10891
10903
 
10892
10904
  /**
10893
- * Creates a NotificationTemplateTypeInfoRecord from the input details array.
10905
+ * Creates a NotificationTemplateTypeInfoRecord from the input info array.
10894
10906
  *
10895
10907
  * @param infoArray
10896
10908
  * @returns
@@ -10966,19 +10978,19 @@ function appNotificationTemplateTypeInfoRecordService(appNotificationTemplateTyp
10966
10978
  const targetModelTypeInfoMapBuilder = multiValueMapBuilder();
10967
10979
  const allKnownTemplateTypes = [];
10968
10980
  const allKnownTemplateTypeInfo = [];
10969
- Object.entries(appNotificationTemplateTypeInfoRecord).forEach(([_, details]) => {
10981
+ Object.entries(appNotificationTemplateTypeInfoRecord).forEach(([_, info]) => {
10970
10982
  const {
10971
10983
  notificationModelIdentity,
10972
10984
  targetModelIdentity,
10973
10985
  alternativeModelIdentities
10974
- } = details;
10986
+ } = info;
10975
10987
  function addInfoForIdentity(modelIdentity, targetIdentity) {
10976
10988
  var _targetIdentity$colle;
10977
10989
  const {
10978
10990
  collectionType
10979
10991
  } = modelIdentity;
10980
- notificationModelTypeInfoMapBuilder.add(collectionType, details);
10981
- targetModelTypeInfoMapBuilder.add((_targetIdentity$colle = targetIdentity == null ? void 0 : targetIdentity.collectionType) != null ? _targetIdentity$colle : collectionType, details);
10992
+ notificationModelTypeInfoMapBuilder.add(collectionType, info);
10993
+ targetModelTypeInfoMapBuilder.add((_targetIdentity$colle = targetIdentity == null ? void 0 : targetIdentity.collectionType) != null ? _targetIdentity$colle : collectionType, info);
10982
10994
  allNotificationModelIdentityValuesSet.add(modelIdentity);
10983
10995
  }
10984
10996
  addInfoForIdentity(notificationModelIdentity, targetModelIdentity);
@@ -10988,8 +11000,8 @@ function appNotificationTemplateTypeInfoRecordService(appNotificationTemplateTyp
10988
11000
  addInfoForIdentity(x.altNotificationModelIdentity, (_x$altTargetModelIden = x.altTargetModelIdentity) != null ? _x$altTargetModelIden : targetModelIdentity);
10989
11001
  });
10990
11002
  }
10991
- allKnownTemplateTypeInfo.push(details);
10992
- allKnownTemplateTypes.push(details.type);
11003
+ allKnownTemplateTypeInfo.push(info);
11004
+ allKnownTemplateTypes.push(info.type);
10993
11005
  });
10994
11006
  const allNotificationModelIdentityValues = Array.from(allNotificationModelIdentityValuesSet);
10995
11007
  const notificationModelTemplateInfoMap = notificationModelTypeInfoMapBuilder.map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase",
3
- "version": "11.1.1",
3
+ "version": "11.1.3",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -4,7 +4,7 @@ import { 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';
7
- import { AbstractFirestoreDocument, AbstractFirestoreDocumentWithParent, type CollectionGroup, type CollectionReference, type FirestoreCollection, type FirestoreCollectionGroup, type FirestoreCollectionWithParent, type FirestoreContext, type FirestoreModelKey, type SavedToFirestoreIfTrue } from '../../common';
7
+ import { AbstractFirestoreDocument, AbstractFirestoreDocumentWithParent, type CollectionGroup, type CollectionReference, type FirestoreCollection, type FirestoreCollectionGroup, type FirestoreCollectionWithParent, type FirestoreContext, type FirestoreModelKey, type SavedToFirestoreIfTrue, type SavedToFirestoreIfFalse } from '../../common';
8
8
  import { type NotificationItem } from './notification.item';
9
9
  export declare abstract class NotificationFirestoreCollections {
10
10
  abstract readonly notificationUserCollection: NotificationUserFirestoreCollection;
@@ -340,8 +340,28 @@ export interface Notification extends NotificationSendFlags, NotificationSendChe
340
340
  n: NotificationItem;
341
341
  /**
342
342
  * Additional embedded recipients.
343
+ *
344
+ * Any values for the NotificationBoxRecipientTemplateConfig-related parameters will be used when considering explicit opt-in/op-out.
345
+ * (I.E. setting "st" to true for a user with no other config for the notification template type will mark them as opt-in for texts, and
346
+ * can only be overridden by the user's own config)
343
347
  */
344
348
  r: NotificationRecipientWithConfig[];
349
+ /**
350
+ * Explicit opt-in send only.
351
+ *
352
+ * If true, will only send to users that have explicitly opted in to recieving notifications via specific methods.
353
+ *
354
+ * This setting takes priority over the system's configured default for this notification's template type.
355
+ */
356
+ ois?: Maybe<SavedToFirestoreIfTrue>;
357
+ /**
358
+ * Explicit opt-in text/sms send only.
359
+ *
360
+ * If false, will send text/sms to all users regardless if they have not explicitly opted in to text/sms. Will still take their opt-out into account.
361
+ *
362
+ * This setting takes priority over the system's configured default for this notification's template type.
363
+ */
364
+ ots?: Maybe<SavedToFirestoreIfFalse>;
345
365
  /**
346
366
  * Minimum time at which this notification should be sent.
347
367
  *
@@ -67,13 +67,21 @@ export interface NotificationTemplateTypeInfo extends NotificationTemplateTypeIn
67
67
  * Description of the notification's content.
68
68
  */
69
69
  readonly description: string;
70
+ /**
71
+ * If true, this notification will only be sent to recipients that explicitly enable recieving via respective NotificationBoxRecipientTemplateConfig for this type.
72
+ */
73
+ readonly onlySendToExplicitlyEnabledRecipients?: boolean;
74
+ /**
75
+ * If false, this notification will send sms/texts to all recipients, even if they have not explicitly opted in to recieving sms/texts.
76
+ */
77
+ readonly onlyTextExplicitlyEnabledRecipients?: boolean;
70
78
  }
71
79
  /**
72
80
  * Record of NotificationTemplateTypeInfo keyed by type.
73
81
  */
74
82
  export type NotificationTemplateTypeInfoRecord = Record<NotificationTemplateType, NotificationTemplateTypeInfo>;
75
83
  /**
76
- * Creates a NotificationTemplateTypeInfoRecord from the input details array.
84
+ * Creates a NotificationTemplateTypeInfoRecord from the input info array.
77
85
  *
78
86
  * @param infoArray
79
87
  * @returns
package/test/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [11.1.3](https://github.com/dereekb/dbx-components/compare/v11.1.2-dev...v11.1.3) (2025-03-07)
6
+
7
+
8
+
9
+ ## [11.1.2](https://github.com/dereekb/dbx-components/compare/v11.1.1-dev...v11.1.2) (2025-03-04)
10
+
11
+
12
+
5
13
  ## [11.1.1](https://github.com/dereekb/dbx-components/compare/v11.1.0-dev...v11.1.1) (2025-03-03)
6
14
 
7
15
 
package/test/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase/test",
3
- "version": "11.1.1",
3
+ "version": "11.1.3",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {
6
6
  "@dereekb/util": "*",