@extrahorizon/javascript-sdk 8.7.0-dev-101-9e49b6c → 8.7.0-dev-103-01749fa

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.
@@ -661,6 +661,13 @@ class RefreshTokenUnknownError extends BadRequestError {
661
661
  }
662
662
  class RefreshTokenExpiredError extends BadRequestError {
663
663
  }
664
+ class FirebaseInvalidPlatformDataError extends BadRequestError {
665
+ constructor(apiError) {
666
+ super(apiError);
667
+ this.notificationId = apiError.response.notificationId;
668
+ this.errors = apiError.response.errors;
669
+ }
670
+ }
664
671
  // 401 Unauthorized
665
672
  class UnauthorizedError extends ApiError {
666
673
  }
@@ -746,6 +753,13 @@ class BadGatewayServerError extends ApiError {
746
753
  }
747
754
  class StripeRequestError extends BadGatewayServerError {
748
755
  }
756
+ class FirebaseConnectionError extends BadGatewayServerError {
757
+ constructor(apiError) {
758
+ super(apiError);
759
+ this.notificationId = apiError.response.notificationId;
760
+ this.errors = apiError.response.errors;
761
+ }
762
+ }
749
763
  // 503 Service Unavailable Error
750
764
  class ServiceUnavailableError extends ApiError {
751
765
  }
@@ -5498,7 +5512,7 @@ const logsService = (httpWithAuth) => {
5498
5512
  };
5499
5513
  };
5500
5514
 
5501
- const version = '8.7.0-dev-101-9e49b6c';
5515
+ const version = '8.7.0-dev-103-01749fa';
5502
5516
 
5503
5517
  /**
5504
5518
  * Create ExtraHorizon client.
@@ -5703,6 +5717,8 @@ exports.EmptyBodyError = EmptyBodyError;
5703
5717
  exports.ErrorClassMap = ErrorClassMap;
5704
5718
  exports.FieldFormatError = FieldFormatError;
5705
5719
  exports.FileTooLargeError = FileTooLargeError;
5720
+ exports.FirebaseConnectionError = FirebaseConnectionError;
5721
+ exports.FirebaseInvalidPlatformDataError = FirebaseInvalidPlatformDataError;
5706
5722
  exports.ForbiddenError = ForbiddenError;
5707
5723
  exports.ForgotPasswordRequestLimitError = ForgotPasswordRequestLimitError;
5708
5724
  exports.ForgotPasswordRequestTimeoutError = ForgotPasswordRequestTimeoutError;
package/build/index.mjs CHANGED
@@ -631,6 +631,13 @@ class RefreshTokenUnknownError extends BadRequestError {
631
631
  }
632
632
  class RefreshTokenExpiredError extends BadRequestError {
633
633
  }
634
+ class FirebaseInvalidPlatformDataError extends BadRequestError {
635
+ constructor(apiError) {
636
+ super(apiError);
637
+ this.notificationId = apiError.response.notificationId;
638
+ this.errors = apiError.response.errors;
639
+ }
640
+ }
634
641
  // 401 Unauthorized
635
642
  class UnauthorizedError extends ApiError {
636
643
  }
@@ -716,6 +723,13 @@ class BadGatewayServerError extends ApiError {
716
723
  }
717
724
  class StripeRequestError extends BadGatewayServerError {
718
725
  }
726
+ class FirebaseConnectionError extends BadGatewayServerError {
727
+ constructor(apiError) {
728
+ super(apiError);
729
+ this.notificationId = apiError.response.notificationId;
730
+ this.errors = apiError.response.errors;
731
+ }
732
+ }
719
733
  // 503 Service Unavailable Error
720
734
  class ServiceUnavailableError extends ApiError {
721
735
  }
@@ -5468,7 +5482,7 @@ const logsService = (httpWithAuth) => {
5468
5482
  };
5469
5483
  };
5470
5484
 
5471
- const version = '8.7.0-dev-101-9e49b6c';
5485
+ const version = '8.7.0-dev-103-01749fa';
5472
5486
 
5473
5487
  /**
5474
5488
  * Create ExtraHorizon client.
@@ -5647,4 +5661,4 @@ const parseStoredCredentials = (fileContent) => exhCredentialsDecoder(fileConten
5647
5661
  .filter(line => line.length === 2)
5648
5662
  .reduce((memo, [key, value]) => ({ ...memo, [key]: value }), {}));
5649
5663
 
5650
- export { AccessTokenExpiredError, AccessTokenUnknownError, ActionType, ActivationRequestLimitError, ActivationRequestTimeoutError, ActivationUnknownError, AlreadyActivatedError, ApiError, ApiFunctionRequestMethod, ApiRequestErrorType, AppStoreTransactionAlreadyLinked, ApplicationNotAuthenticatedError, ApplicationType, ApplicationUnknownError, AuthenticationError, AuthorizationCodeExpiredError, AuthorizationUnknownError, BadGatewayServerError, BadRequestError, BodyFormatError, CallbackNotValidError, Comorbidities, DefaultLocalizationMissingError, DisabledForOidcUsersError, DuplicateRequestError, EmailUnknownError, EmailUsedError, EmptyBodyError, ErrorClassMap, FieldFormatError, FieldType, FileTooLargeError, ForbiddenError, ForgotPasswordRequestLimitError, ForgotPasswordRequestTimeoutError, Gender, GlobalPermissionName, IDFormatError, IllegalArgumentError, IllegalStateError, Impediments, IncorrectPinCodeError, InvalidClientError, InvalidCurrencyForProductPrice, InvalidGrantError, InvalidMfaCodeError, InvalidMfaTokenError, InvalidNonceError, InvalidPKCEError, InvalidPresenceTokenError, InvalidReceiptDataError, InvalidRequestError, InvalidTokenError, JSONSchemaType, LocalizationKeyMissingError, LockedDocumentError, LoginAttemptStatus, LoginFreezeError, LoginTimeoutError, MedicationFrequency, MedicationUnit, MfaReattemptDelayError, MfaRequiredError, MissingPKCEVerifierError, MissingRequiredFieldsError, NewMFARequiredError, NewPasswordHashUnknownError, NewPasswordPinCodeUnknownError, NoConfiguredAppStoreProduct, NoConfiguredPlayStoreProduct, NoMatchingPlayStoreLinkedSubscription, NoPermissionError, NotActivatedError, NotEnoughMfaMethodsError, NotFoundError, OAuth2ClientIdError, OAuth2ClientSecretError, OAuth2ErrorClassMap, OAuth2LoginError, OAuth2MissingClientCredentialsError, OauthKeyError, OauthSignatureError, OauthTokenError, ObjectMaxBytesOptionType, ObjectMinBytesOptionType, OidcIdTokenError, OidcInvalidAuthorizationCodeError, OidcProviderResponseError, OrderSchemaStatus, PasswordError, PaymentIntentCreationSchemaPaymentMethodType, PaymentIntentCreationSchemaSetupPaymentMethodReuse, PinCodesNotEnabledError, PlayStoreTransactionAlreadyLinked, ProfileActivity, ProfileAlreadyExistsError, QueuedMailStatus, RefreshTokenExpiredError, RefreshTokenUnknownError, RemoveFieldError, ResourceAlreadyExistsError, ResourceUnknownError, Results, ServerError, ServiceUnavailableError, StatusInUseError, StripePaymentMethodError, StripeRequestError, SubscriptionEntitlementSource, SubscriptionEntitlementStatus, SubscriptionEntitlementStatusCategory, SubscriptionEventSource, SubscriptionEventType, SupportedLanguageCodes, TaskStatus, TemplateFillingError, TokenNotDeleteableError, TokenPermission, TooManyFailedAttemptsError, UnauthorizedClientError, UnauthorizedError, UnauthorizedTokenError, UnknownReceiptTransactionError, UnsupportedGrantError, UnsupportedGrantTypeError, UnsupportedResponseTypeError, UserNotAuthenticatedError, createClient, createOAuth1Client, createOAuth2Client, createProxyClient, findAllGeneric, findAllIterator, getMockSdkOAuth2 as getMockSdk, getMockSdkOAuth1, getMockSdkOAuth2, getMockSdkProxy, parseGlobalPermissions, parseStoredCredentials, recursiveMap, rqlBuilder, rqlParser };
5664
+ export { AccessTokenExpiredError, AccessTokenUnknownError, ActionType, ActivationRequestLimitError, ActivationRequestTimeoutError, ActivationUnknownError, AlreadyActivatedError, ApiError, ApiFunctionRequestMethod, ApiRequestErrorType, AppStoreTransactionAlreadyLinked, ApplicationNotAuthenticatedError, ApplicationType, ApplicationUnknownError, AuthenticationError, AuthorizationCodeExpiredError, AuthorizationUnknownError, BadGatewayServerError, BadRequestError, BodyFormatError, CallbackNotValidError, Comorbidities, DefaultLocalizationMissingError, DisabledForOidcUsersError, DuplicateRequestError, EmailUnknownError, EmailUsedError, EmptyBodyError, ErrorClassMap, FieldFormatError, FieldType, FileTooLargeError, FirebaseConnectionError, FirebaseInvalidPlatformDataError, ForbiddenError, ForgotPasswordRequestLimitError, ForgotPasswordRequestTimeoutError, Gender, GlobalPermissionName, IDFormatError, IllegalArgumentError, IllegalStateError, Impediments, IncorrectPinCodeError, InvalidClientError, InvalidCurrencyForProductPrice, InvalidGrantError, InvalidMfaCodeError, InvalidMfaTokenError, InvalidNonceError, InvalidPKCEError, InvalidPresenceTokenError, InvalidReceiptDataError, InvalidRequestError, InvalidTokenError, JSONSchemaType, LocalizationKeyMissingError, LockedDocumentError, LoginAttemptStatus, LoginFreezeError, LoginTimeoutError, MedicationFrequency, MedicationUnit, MfaReattemptDelayError, MfaRequiredError, MissingPKCEVerifierError, MissingRequiredFieldsError, NewMFARequiredError, NewPasswordHashUnknownError, NewPasswordPinCodeUnknownError, NoConfiguredAppStoreProduct, NoConfiguredPlayStoreProduct, NoMatchingPlayStoreLinkedSubscription, NoPermissionError, NotActivatedError, NotEnoughMfaMethodsError, NotFoundError, OAuth2ClientIdError, OAuth2ClientSecretError, OAuth2ErrorClassMap, OAuth2LoginError, OAuth2MissingClientCredentialsError, OauthKeyError, OauthSignatureError, OauthTokenError, ObjectMaxBytesOptionType, ObjectMinBytesOptionType, OidcIdTokenError, OidcInvalidAuthorizationCodeError, OidcProviderResponseError, OrderSchemaStatus, PasswordError, PaymentIntentCreationSchemaPaymentMethodType, PaymentIntentCreationSchemaSetupPaymentMethodReuse, PinCodesNotEnabledError, PlayStoreTransactionAlreadyLinked, ProfileActivity, ProfileAlreadyExistsError, QueuedMailStatus, RefreshTokenExpiredError, RefreshTokenUnknownError, RemoveFieldError, ResourceAlreadyExistsError, ResourceUnknownError, Results, ServerError, ServiceUnavailableError, StatusInUseError, StripePaymentMethodError, StripeRequestError, SubscriptionEntitlementSource, SubscriptionEntitlementStatus, SubscriptionEntitlementStatusCategory, SubscriptionEventSource, SubscriptionEventType, SupportedLanguageCodes, TaskStatus, TemplateFillingError, TokenNotDeleteableError, TokenPermission, TooManyFailedAttemptsError, UnauthorizedClientError, UnauthorizedError, UnauthorizedTokenError, UnknownReceiptTransactionError, UnsupportedGrantError, UnsupportedGrantTypeError, UnsupportedResponseTypeError, UserNotAuthenticatedError, createClient, createOAuth1Client, createOAuth2Client, createProxyClient, findAllGeneric, findAllIterator, getMockSdkOAuth2 as getMockSdk, getMockSdkOAuth1, getMockSdkOAuth2, getMockSdkProxy, parseGlobalPermissions, parseStoredCredentials, recursiveMap, rqlBuilder, rqlParser };
@@ -1,4 +1,4 @@
1
- import { MfaMethod } from './types';
1
+ import { MfaMethod, NotificationV2Error } from './types';
2
2
  declare type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH';
3
3
  interface RequestConfig {
4
4
  url?: string;
@@ -145,6 +145,11 @@ export declare class RefreshTokenUnknownError extends BadRequestError {
145
145
  }
146
146
  export declare class RefreshTokenExpiredError extends BadRequestError {
147
147
  }
148
+ export declare class FirebaseInvalidPlatformDataError extends BadRequestError {
149
+ notificationId?: string;
150
+ errors?: NotificationV2Error[];
151
+ constructor(apiError: ApiError);
152
+ }
148
153
  export declare class UnauthorizedError extends ApiError {
149
154
  }
150
155
  export declare class ApplicationNotAuthenticatedError extends UnauthorizedError {
@@ -215,6 +220,11 @@ export declare class BadGatewayServerError extends ApiError {
215
220
  }
216
221
  export declare class StripeRequestError extends BadGatewayServerError {
217
222
  }
223
+ export declare class FirebaseConnectionError extends BadGatewayServerError {
224
+ notificationId?: string;
225
+ errors?: NotificationV2Error[];
226
+ constructor(apiError: ApiError);
227
+ }
218
228
  export declare class ServiceUnavailableError extends ApiError {
219
229
  }
220
230
  export declare class OidcIdTokenError extends ServiceUnavailableError {
@@ -1,7 +1,7 @@
1
1
  import { ObjectId, OptionsBase, OptionsWithRql, PagedResultWithPager } from '../types';
2
2
  export * from './users/types';
3
3
  export interface NotificationV2Creation<T extends Record<string, string> = Record<string, string>> {
4
- targetUserId: string;
4
+ targetUserId: ObjectId;
5
5
  title: string;
6
6
  body: string;
7
7
  data?: T;
@@ -21,25 +21,77 @@ export interface NotificationV2Creation<T extends Record<string, string> = Recor
21
21
  export interface NotificationV2<T extends Record<string, string> = Record<string, string>> extends NotificationV2Creation<T> {
22
22
  id: ObjectId;
23
23
  creatorId: ObjectId;
24
+ /**
25
+ * Indicates whether we tried to send the notification.
26
+ * Would be `false` if no devices with FCM tokens were found for the user.
27
+ * See `errors` for any errors that occurred.
28
+ */
24
29
  sent: boolean;
30
+ /**
31
+ * The errors that occurred while sending the notification, if any.
32
+ */
33
+ errors?: NotificationV2Error[];
25
34
  creationTimestamp: Date;
26
35
  updateTimestamp: Date;
27
36
  }
37
+ export interface NotificationV2Error {
38
+ /**
39
+ * The name of the device for which the error occurred.
40
+ * If not set, the error occurred for the FCM token defined on the root of the user settings.
41
+ */
42
+ deviceName?: string;
43
+ exhError: {
44
+ code: string;
45
+ name: string;
46
+ message: string;
47
+ };
48
+ /**
49
+ * The error received from FCM, unchanged, if available.
50
+ * @example
51
+ * {
52
+ * "error": {
53
+ * "code": 403,
54
+ * "message": "SenderId mismatch",
55
+ * "status": "PERMISSION_DENIED",
56
+ * "details": [
57
+ * {
58
+ * "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
59
+ * "errorCode": "SENDER_ID_MISMATCH",
60
+ * }
61
+ * ]
62
+ * }
63
+ * }
64
+ * */
65
+ fcmError?: any;
66
+ }
28
67
  export interface NotificationV2Service {
29
68
  /**
30
69
  * # Create a notification
31
70
  *
71
+ * A user's FCM token and their device's with an FCM token will be targeted for the notification
72
+ *
73
+ * If an unusable FCM token is detected, the request will succeed, however, the FCM token will be removed from the user's settings.
74
+ * Any unusable FCM token errors will be included in the `errors` field of the response.
75
+ *
76
+ * Multiple errors can occur at once when multiple devices are targeted and errors are thrown in this order:
77
+ * - `FirebaseConnectionError`
78
+ * - `FirebaseInvalidPlatformDataError`
79
+ * Both error types will include a `notificationId` and an `errors` field with details about any errors that occurred.
80
+ *
32
81
  * ## Access via permissions
33
82
  * Permission | Scopes | Effect
34
83
  * - | - | -
35
84
  * `CREATE_NOTIFICATIONS` | `global` | Create notifications for any user
36
- * `CREATE_NOTIFICATIONS` | `group` | Create notifications for any patient in group
85
+ * `CREATE_NOTIFICATIONS` | `group` | Create notifications for any patient in a group
37
86
  * none | | Create notifications for yourself
38
87
  *
39
88
  * # Interface
40
89
  * @param requestBody
41
90
  * @param options
42
91
  * @returns NotificationV2<T>
92
+ *
93
+ * @throws {FirebaseInvalidPlatformDataError} if FCM reports invalid values for `android`, `apns`, or `webpush`.
94
+ * @throws {FirebaseConnectionError} if FCM is unreachable or returns an unknown error.
43
95
  */
44
96
  create<T extends Record<string, string>>(requestBody: NotificationV2Creation<T>, options?: OptionsBase): Promise<NotificationV2<T>>;
45
97
  /**
@@ -34,6 +34,7 @@ export interface NotificationV2UserService {
34
34
  */
35
35
  getById(userId: ObjectId, options?: OptionsBase): Promise<NotificationV2User>;
36
36
  /**
37
+ * @deprecated We recommend using `devices` instead, managed by the `addOrUpdateDevice()` and `removeDevice()` methods.
37
38
  * # Update a user its notification settings
38
39
  *
39
40
  * Updates (or creates if non exists) a user its settings for the specified user id.
@@ -1 +1 @@
1
- export declare const version = "8.7.0-dev-101-9e49b6c";
1
+ export declare const version = "8.7.0-dev-103-01749fa";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/javascript-sdk",
3
- "version": "8.7.0-dev-101-9e49b6c",
3
+ "version": "8.7.0-dev-103-01749fa",
4
4
  "description": "This package serves as a JavaScript wrapper around all Extra Horizon cloud services.",
5
5
  "main": "build/index.cjs.js",
6
6
  "types": "build/types/index.d.ts",