@icanbwell/bwell-sdk-ts 1.36.2 → 1.36.4

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 (112) hide show
  1. package/README.md +2 -2
  2. package/dist/__version__.d.ts +1 -1
  3. package/dist/__version__.js +1 -1
  4. package/dist/api/api-provider-factory.d.ts +1 -1
  5. package/dist/api/api-provider-factory.js +1 -2
  6. package/dist/api/base/activity/activity-manager.d.ts +35 -0
  7. package/dist/api/base/activity/activity-manager.js +1 -0
  8. package/dist/api/base/activity/get-tasks-request.d.ts +49 -0
  9. package/dist/api/base/activity/get-tasks-request.js +35 -0
  10. package/dist/api/base/activity/index.d.ts +4 -0
  11. package/dist/api/base/activity/index.js +2 -0
  12. package/dist/api/base/activity/types.d.ts +3 -0
  13. package/dist/api/base/activity/types.js +5 -0
  14. package/dist/api/base/activity/update-task-status-request.d.ts +18 -0
  15. package/dist/api/base/activity/update-task-status-request.js +15 -0
  16. package/dist/api/base/api-provider.d.ts +14 -8
  17. package/dist/api/base/connection/connection-manager.d.ts +2 -0
  18. package/dist/api/base/device/device-manager.d.ts +22 -0
  19. package/dist/api/base/device/device-manager.js +5 -0
  20. package/dist/api/base/device/device-request.d.ts +62 -0
  21. package/dist/api/base/device/device-request.js +71 -0
  22. package/dist/api/base/device/index.d.ts +2 -0
  23. package/dist/api/base/device/index.js +2 -0
  24. package/dist/api/base/event/event-manager.d.ts +16 -0
  25. package/dist/api/base/event/event-manager.js +1 -0
  26. package/dist/api/base/event/event-request.d.ts +35 -0
  27. package/dist/api/base/event/event-request.js +64 -0
  28. package/dist/api/base/event/index.d.ts +2 -0
  29. package/dist/api/base/event/index.js +1 -0
  30. package/dist/api/base/health-data/health-manager.d.ts +227 -4
  31. package/dist/api/base/health-data/index.d.ts +1 -1
  32. package/dist/api/base/index.d.ts +4 -0
  33. package/dist/api/base/index.js +4 -4
  34. package/dist/api/base/search/index.d.ts +4 -0
  35. package/dist/api/base/search/index.js +3 -0
  36. package/dist/api/base/search/request-connection-request.d.ts +24 -0
  37. package/dist/api/base/search/request-connection-request.js +3 -0
  38. package/dist/api/base/search/search-health-resources-request.d.ts +87 -0
  39. package/dist/api/base/search/search-health-resources-request.js +20 -0
  40. package/dist/api/base/search/search-manager.d.ts +58 -0
  41. package/dist/api/base/search/search-manager.js +1 -0
  42. package/dist/api/base/search/search-request.d.ts +84 -0
  43. package/dist/api/base/search/search-request.js +78 -0
  44. package/dist/api/base/user/create-data-export-direct-download-url-request.d.ts +14 -0
  45. package/dist/api/base/user/create-data-export-direct-download-url-request.js +21 -0
  46. package/dist/api/base/user/index.d.ts +2 -1
  47. package/dist/api/base/user/index.js +1 -4
  48. package/dist/api/base/user/user-manager.d.ts +7 -1
  49. package/dist/api/graphql-api/activity/activity-request-factories.d.ts +13 -0
  50. package/dist/api/graphql-api/activity/activity-request-factories.js +66 -0
  51. package/dist/api/graphql-api/activity/graphql-activity-manager.d.ts +14 -0
  52. package/dist/api/graphql-api/activity/graphql-activity-manager.js +72 -0
  53. package/dist/api/graphql-api/activity/index.d.ts +1 -0
  54. package/dist/api/graphql-api/activity/index.js +1 -0
  55. package/dist/api/graphql-api/connection/graphql-connection-manager.d.ts +3 -1
  56. package/dist/api/graphql-api/connection/graphql-connection-manager.js +21 -23
  57. package/dist/api/graphql-api/connection/graphql-get-member-connections-bwell-response-factory.d.ts +18 -0
  58. package/dist/api/graphql-api/connection/graphql-get-member-connections-bwell-response-factory.js +40 -0
  59. package/dist/api/graphql-api/connection/index.d.ts +1 -0
  60. package/dist/api/graphql-api/connection/index.js +1 -1
  61. package/dist/api/graphql-api/device/device-request-factory.d.ts +9 -0
  62. package/dist/api/graphql-api/device/device-request-factory.js +15 -0
  63. package/dist/api/graphql-api/device/graphql-device-manager.d.ts +13 -0
  64. package/dist/api/graphql-api/device/graphql-device-manager.js +73 -0
  65. package/dist/api/graphql-api/device/index.d.ts +1 -0
  66. package/dist/api/graphql-api/device/index.js +1 -0
  67. package/dist/api/graphql-api/event/event-request-factory.d.ts +6 -0
  68. package/dist/api/graphql-api/event/event-request-factory.js +11 -0
  69. package/dist/api/graphql-api/event/graphql-event-manager.d.ts +15 -0
  70. package/dist/api/graphql-api/event/graphql-event-manager.js +65 -0
  71. package/dist/api/graphql-api/event/index.d.ts +1 -0
  72. package/dist/api/graphql-api/event/index.js +1 -0
  73. package/dist/api/graphql-api/graphql-api-provider.d.ts +13 -4
  74. package/dist/api/graphql-api/graphql-api-provider.js +9 -10
  75. package/dist/api/graphql-api/graphql-sdk/graphql-sdk.js +1 -1
  76. package/dist/api/graphql-api/healthdata/graphql-get-medication-dispense-bwell-response-factory.d.ts +10 -0
  77. package/dist/api/graphql-api/healthdata/graphql-get-medication-dispense-bwell-response-factory.js +35 -0
  78. package/dist/api/graphql-api/healthdata/graphql-get-medication-request-bwell-response-factory.d.ts +10 -0
  79. package/dist/api/graphql-api/healthdata/graphql-get-medication-request-bwell-response-factory.js +35 -0
  80. package/dist/api/graphql-api/healthdata/graphql-health-manager.d.ts +27 -3
  81. package/dist/api/graphql-api/healthdata/graphql-health-manager.js +328 -26
  82. package/dist/api/graphql-api/search/connection-search-request-factory.d.ts +7 -0
  83. package/dist/api/graphql-api/search/connection-search-request-factory.js +21 -0
  84. package/dist/api/graphql-api/search/graphql-search-manager.d.ts +17 -0
  85. package/dist/api/graphql-api/search/graphql-search-manager.js +133 -0
  86. package/dist/api/graphql-api/search/index.d.ts +1 -0
  87. package/dist/api/graphql-api/search/index.js +1 -0
  88. package/dist/api/graphql-api/search/provider-search-request-factory.d.ts +7 -0
  89. package/dist/api/graphql-api/search/provider-search-request-factory.js +21 -0
  90. package/dist/api/graphql-api/search/request-connection-request-factory.d.ts +6 -0
  91. package/dist/api/graphql-api/search/request-connection-request-factory.js +12 -0
  92. package/dist/api/graphql-api/search/search-health-resources-request-factory.d.ts +14 -0
  93. package/dist/api/graphql-api/search/search-health-resources-request-factory.js +28 -0
  94. package/dist/api/graphql-api/search/search-request-factory.d.ts +6 -0
  95. package/dist/api/graphql-api/search/search-request-factory.js +44 -0
  96. package/dist/api/graphql-api/user/create-data-export-direct-download-url-request-factory.d.ts +6 -0
  97. package/dist/api/graphql-api/user/create-data-export-direct-download-url-request-factory.js +9 -0
  98. package/dist/api/graphql-api/user/get-consent-request-factory.d.ts +6 -0
  99. package/dist/api/graphql-api/user/get-consent-request-factory.js +8 -0
  100. package/dist/api/graphql-api/user/graphql-user-manager.d.ts +6 -3
  101. package/dist/api/graphql-api/user/graphql-user-manager.js +46 -68
  102. package/dist/bwell-sdk/bwell-sdk.d.ts +13 -2
  103. package/dist/bwell-sdk/bwell-sdk.js +27 -27
  104. package/dist/config/sdk-config.js +3 -3
  105. package/dist/graphql/operations/index.d.ts +285 -14
  106. package/dist/graphql/operations/index.js +2423 -225
  107. package/dist/graphql/operations/types.d.ts +15240 -2305
  108. package/dist/graphql/schema.d.ts +4800 -68156
  109. package/dist/graphql/schema.js +63 -7
  110. package/package.json +2 -4
  111. package/dist/api/graphql-api/healthdata/health-data-request-factory.d.ts +0 -12
  112. package/dist/api/graphql-api/healthdata/health-data-request-factory.js +0 -12
package/README.md CHANGED
@@ -9,8 +9,8 @@ providers or connections. Please see the documentation for details.
9
9
 
10
10
  ## SDKv2 / SDKv1 Update
11
11
 
12
- The `main` branch will soon be updated to be for SDKv2 only. Any v1 updates are
13
- to be made to `typescript-sdk-v1` branch once that happens.
12
+ The `main` has been updated to be for TS SDKv2 only. Any v1 updates should be
13
+ made to `typescript-sdk-v1` branch.
14
14
 
15
15
  ## Installation
16
16
 
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * This file is automatically generated. Please do not edit this file directly.
3
3
  */
4
- export declare const VERSION = "1.36.2";
4
+ export declare const VERSION = "1.36.4";
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * This file is automatically generated. Please do not edit this file directly.
3
3
  */
4
- export const VERSION = "1.36.2";
4
+ export const VERSION = "1.36.4";
@@ -3,5 +3,5 @@ import { LoggerProvider } from "../logger/index.js";
3
3
  import { TokenManager } from "../tokens/index.js";
4
4
  import { ApiProvider } from "./base/api-provider.js";
5
5
  export declare class ApiProviderFactory {
6
- createApiProvider(config: SdkConfig, loggerProvider: LoggerProvider, tokenManager?: TokenManager): ApiProvider;
6
+ createApiProvider(config: SdkConfig, tokenManager: TokenManager, loggerProvider: LoggerProvider): ApiProvider;
7
7
  }
@@ -1,8 +1,7 @@
1
1
  import { graphQLSDKFactory } from "./graphql-api/graphql-sdk/index.js";
2
2
  import { GraphQLApiProvider } from "./graphql-api/index.js";
3
3
  export class ApiProviderFactory {
4
- createApiProvider(config, loggerProvider, tokenManager) {
5
- // TODO: PHR-1137 - Handle optional params better
4
+ createApiProvider(config, tokenManager, loggerProvider) {
6
5
  const { sdk, client } = graphQLSDKFactory(config.graphQL.apiUrl, tokenManager, config.bwellConfig.language);
7
6
  return new GraphQLApiProvider(sdk, loggerProvider, client);
8
7
  }
@@ -0,0 +1,35 @@
1
+ import { ValidationError } from "../../../errors/index.js";
2
+ import { GetTasksQueryResults, TaskUpdateStatusMutationResults } from "../../../graphql/operations/types.js";
3
+ import type { BWellQueryResult, BWellTransactionResult } from "../../../results/index.js";
4
+ import { BaseManagerError } from "../errors.js";
5
+ import { GetTasksRequest } from "./get-tasks-request.js";
6
+ import { UpdateTaskStatusRequest } from "./update-task-status-request.js";
7
+ export type GetTasksResults = GetTasksQueryResults["getTasks"];
8
+ export type UpdateTaskStatusResults = TaskUpdateStatusMutationResults["taskUpdateStatus"];
9
+ /**
10
+ * The ActivityManager interface provides methods for managing FHIR tasks.
11
+ * See also https://www.hl7.org/fhir/task.html
12
+ */
13
+ export interface ActivityManager {
14
+ /**
15
+ * Tasks represent insights, recommendations, and/or requests for the user. They
16
+ * can be personalized and have a status to track progress. Tasks can also be linked
17
+ * to other FHIR resources and/or external content.
18
+ *
19
+ * @param {GetTasksRequest} request - The query search criteria
20
+ * @returns {Promise<BWellQueryResult<GetTasksResults, BaseManagerError>>} Collection of FHIR Task resources
21
+ */
22
+ getTasks(request: GetTasksRequest): Promise<BWellQueryResult<GetTasksResults, BaseManagerError | ValidationError>>;
23
+ /**
24
+ * Updates the status of a specified Task. The status of the task identified
25
+ * by request.taskId will be updated to the new status provided.
26
+ *
27
+ * The new status must be one of the potential TaskStatus values
28
+ *
29
+ * @param {UpdateTaskStatusRequest} request - Object containing the id and desired status for the task
30
+ * @returns {Promise<BWellTransactionResult<UpdateTaskStatusResults, BaseManagerError>>} - Object containing the updated FHIR task resource
31
+ *
32
+ * @see https://build.fhir.org/valueset-task-status.html
33
+ */
34
+ updateTaskStatus(request: UpdateTaskStatusRequest): Promise<BWellTransactionResult<UpdateTaskStatusResults, BaseManagerError | ValidationError>>;
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ import { ErrorsCollector, PagedRequest, PagedRequestInput, PagedRequestValidator } from "../../../requests/index.js";
2
+ import { TaskStatus } from "./types.js";
3
+ export type GetTaskRequestInput = PagedRequestInput & {
4
+ /**
5
+ * The id[s] of a tasks to search for
6
+ */
7
+ id?: string | string[];
8
+ /**
9
+ * The activityId[s] of tasks to filter by
10
+ */
11
+ activityId?: string | string[];
12
+ /**
13
+ * The activityType[s] of tasks to filter by
14
+ */
15
+ activityType?: string | string[];
16
+ /**
17
+ * The activityTopic[s] of tasks to filter by
18
+ */
19
+ activityTopic?: string | string[];
20
+ /**
21
+ * The status[es] of tasks to fitler by
22
+ */
23
+ status?: TaskStatus | TaskStatus[];
24
+ /**
25
+ * subject[s] of tasks to filter by
26
+ */
27
+ subject?: string | string[];
28
+ /**
29
+ * If present and true, retrieve referenced content from CMS. All content found
30
+ * will be added to the associated Task field “extension”
31
+ */
32
+ enrichContent?: boolean;
33
+ /**
34
+ * If present and true, results will be ordered to place better Tasks for user
35
+ * consumption at the front of the list. Otherwise, Tasks will be unordered.
36
+ */
37
+ smartSort?: boolean;
38
+ /**
39
+ * The preferred language for returned content, e.g. "en" for English, "es" for Spanish
40
+ */
41
+ contentLanguage?: string;
42
+ };
43
+ export declare class GetTasksRequestValidator extends PagedRequestValidator<GetTaskRequestInput> {
44
+ #private;
45
+ validate(data: GetTaskRequestInput, errors: ErrorsCollector): void;
46
+ }
47
+ export declare class GetTasksRequest extends PagedRequest<GetTaskRequestInput> {
48
+ protected validator: PagedRequestValidator<GetTaskRequestInput>;
49
+ }
@@ -0,0 +1,35 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _GetTasksRequestValidator_instances, _GetTasksRequestValidator_validateTaskStatus;
7
+ import { PagedRequest, PagedRequestValidator, } from "../../../requests/index.js";
8
+ import { isUndefined } from "../../../utils/index.js";
9
+ import { isValidTaskStatus } from "./types.js";
10
+ export class GetTasksRequestValidator extends PagedRequestValidator {
11
+ constructor() {
12
+ super(...arguments);
13
+ _GetTasksRequestValidator_instances.add(this);
14
+ }
15
+ validate(data, errors) {
16
+ super.validate(data, errors);
17
+ if (!isUndefined(data.status)) {
18
+ const statuses = Array.isArray(data.status) ? data.status : [data.status];
19
+ for (const status of statuses) {
20
+ __classPrivateFieldGet(this, _GetTasksRequestValidator_instances, "m", _GetTasksRequestValidator_validateTaskStatus).call(this, status, errors);
21
+ }
22
+ }
23
+ }
24
+ }
25
+ _GetTasksRequestValidator_instances = new WeakSet(), _GetTasksRequestValidator_validateTaskStatus = function _GetTasksRequestValidator_validateTaskStatus(status, errors) {
26
+ if (!isValidTaskStatus(status)) {
27
+ errors.add(`Invalid task status: "${status}"`);
28
+ }
29
+ };
30
+ export class GetTasksRequest extends PagedRequest {
31
+ constructor() {
32
+ super(...arguments);
33
+ this.validator = new GetTasksRequestValidator();
34
+ }
35
+ }
@@ -0,0 +1,4 @@
1
+ export { GetTasksResults, UpdateTaskStatusResults, ActivityManager, } from "./activity-manager.js";
2
+ export { GetTasksRequest, GetTaskRequestInput } from "./get-tasks-request.js";
3
+ export { UpdateTaskStatusRequest, UpdateTaskStatusRequestInput, } from "./update-task-status-request.js";
4
+ export { TaskStatus } from "./types.js";
@@ -0,0 +1,2 @@
1
+ export { GetTasksRequest } from "./get-tasks-request.js";
2
+ export { UpdateTaskStatusRequest, } from "./update-task-status-request.js";
@@ -0,0 +1,3 @@
1
+ import { TaskStatus as GraphQLTaskStatus } from "../../../graphql/schema.js";
2
+ export type TaskStatus = `${GraphQLTaskStatus}`;
3
+ export declare function isValidTaskStatus(status: string): status is GraphQLTaskStatus;
@@ -0,0 +1,5 @@
1
+ import { TaskStatus as GraphQLTaskStatus } from "../../../graphql/schema.js";
2
+ const taskStatusCache = new Set(Object.values(GraphQLTaskStatus));
3
+ export function isValidTaskStatus(status) {
4
+ return taskStatusCache.has(status);
5
+ }
@@ -0,0 +1,18 @@
1
+ import { TaskStatus as GraphQLTaskStatus } from "../../../graphql/schema.js";
2
+ import { ErrorsCollector, ValidationRequest, Validator } from "../../../requests/index.js";
3
+ import { TaskStatus } from "./types.js";
4
+ export type UpdateTaskStatusRequestInput = {
5
+ taskId: string;
6
+ newStatus: TaskStatus;
7
+ };
8
+ type UpdateTaskStatusRequestData = {
9
+ taskId: string;
10
+ newStatus: GraphQLTaskStatus;
11
+ };
12
+ export declare class UpdateTaskStatusRequestValidator implements Validator<UpdateTaskStatusRequestInput> {
13
+ validate(data: UpdateTaskStatusRequestInput, errors: ErrorsCollector): void;
14
+ }
15
+ export declare class UpdateTaskStatusRequest extends ValidationRequest<UpdateTaskStatusRequestInput, UpdateTaskStatusRequestData> {
16
+ protected validator: Validator<UpdateTaskStatusRequestInput>;
17
+ }
18
+ export {};
@@ -0,0 +1,15 @@
1
+ import { ValidationRequest, } from "../../../requests/index.js";
2
+ import { isValidTaskStatus } from "./types.js";
3
+ export class UpdateTaskStatusRequestValidator {
4
+ validate(data, errors) {
5
+ if (!isValidTaskStatus(data.newStatus)) {
6
+ errors.add(`Invalid task status: "${data.newStatus}"`);
7
+ }
8
+ }
9
+ }
10
+ export class UpdateTaskStatusRequest extends ValidationRequest {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.validator = new UpdateTaskStatusRequestValidator();
14
+ }
15
+ }
@@ -1,16 +1,22 @@
1
1
  import type { LanguageManager } from "../../language/language-manager.js";
2
- import { ConnectionManager } from "./connection/index.js";
3
- import { HealthManager } from "./health-data/index.js";
4
- import { HealthSpaceManager } from "./health-space/index.js";
5
- import { IdentityManager } from "./identity/identity-manager.js";
6
- import { QuestionnaireManager } from "./questionnaire/index.js";
7
- import { UserManager } from "./user/index.js";
2
+ import type { ActivityManager } from "./activity/activity-manager.js";
3
+ import type { ConnectionManager } from "./connection/connection-manager.js";
4
+ import type { DeviceManager } from "./device/device-manager.js";
5
+ import type { EventManager } from "./event/event-manager.js";
6
+ import type { HealthManager } from "./health-data/health-manager.js";
7
+ import type { HealthSpaceManager } from "./health-space/health-space-manager.js";
8
+ import type { QuestionnaireManager } from "./questionnaire/questionnaire-manager.js";
9
+ import type { SearchManager } from "./search/search-manager.js";
10
+ import type { UserManager } from "./user/user-manager.js";
8
11
  export interface ApiProvider {
9
12
  readonly health: HealthManager;
10
13
  readonly healthSpace: HealthSpaceManager;
11
14
  readonly user: UserManager;
15
+ readonly device: DeviceManager;
12
16
  readonly connection: ConnectionManager;
13
- readonly questionnaire: QuestionnaireManager;
17
+ readonly activity: ActivityManager;
18
+ readonly event: EventManager;
19
+ readonly search: SearchManager;
14
20
  readonly language: LanguageManager;
15
- readonly identity: IdentityManager;
21
+ readonly questionnaire: QuestionnaireManager;
16
22
  }
@@ -1,5 +1,6 @@
1
1
  import { CreateConnectionMutationResults, DeleteConnectionMutationResults, DisconnectConnectionMutationResults, GetDataSourceQueryResults, GetOauthUrlQueryResults } from "../../../graphql/operations/types.js";
2
2
  import type { BWellQueryResult, BWellTransactionResult } from "../../../results/index.js";
3
+ import { MemberConnectionResults } from "../../graphql-api/connection/index.js";
3
4
  import type { BaseManagerError } from "../errors.js";
4
5
  import { ConnectionRequest, DataSourceRequest } from "./connection-request.js";
5
6
  export declare const MEMBER_CONNECTION_SUBSCRIPTION_STATUS_EXTENSION_ID = "data-connection-status";
@@ -28,6 +29,7 @@ export interface ConnectionManager {
28
29
  *
29
30
  * @returns {Promise<BWellQueryResult<MemberConnectionResults>>} A promise resolving to an object representing the list of MemberConnections resources retrieved, along with potential validation or GraphQL errors.
30
31
  */
32
+ getMemberConnections(): Promise<BWellQueryResult<MemberConnectionResults, BaseManagerError>>;
31
33
  /**
32
34
  * Retrieves a DataSource by id.
33
35
  *
@@ -0,0 +1,22 @@
1
+ import type { UpdateDeviceRegistrationMutationResults } from "../../../graphql/operations/types.js";
2
+ import type { BWellTransactionResult } from "../../../results/index.js";
3
+ import type { BaseManagerError } from "../errors.js";
4
+ import { DeregisterDeviceRequest, RegisterDeviceRequest } from "./device-request.js";
5
+ export type DeviceRegistrationResults = UpdateDeviceRegistrationMutationResults["updateDeviceRegistration"];
6
+ /**
7
+ * Base manager for device registration; used to subscribe and unsubscribe devices for push notifications.
8
+ */
9
+ export declare abstract class DeviceManager {
10
+ /**
11
+ * Registers a device to receive notifications.
12
+ * @param request The request to register the device.
13
+ * @returns A promise resolving to an object representing the transaction result with the registration results or an error.
14
+ */
15
+ abstract registerDevice(request: RegisterDeviceRequest): Promise<BWellTransactionResult<DeviceRegistrationResults, BaseManagerError>>;
16
+ /**
17
+ * Deregisters a device so that it will no longer receive notifications.
18
+ * @param request The request to deregister the device.
19
+ * @returns A promise resolving to an object representing the transaction result with the deregistration results or an error.
20
+ */
21
+ abstract deregisterDevice(request: DeregisterDeviceRequest): Promise<BWellTransactionResult<DeviceRegistrationResults, BaseManagerError>>;
22
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Base manager for device registration; used to subscribe and unsubscribe devices for push notifications.
3
+ */
4
+ export class DeviceManager {
5
+ }
@@ -0,0 +1,62 @@
1
+ import { ErrorsCollector, ValidationRequest, Validator } from "../../../requests/index.js";
2
+ /**
3
+ * Error message for when deviceToken is missing
4
+ */
5
+ export declare const INVALID_DEVICE_TOKEN_ERROR = "deviceToken is required";
6
+ /**
7
+ * Error message for when platformName is not a valid DevicePlatform value
8
+ */
9
+ export declare const INVALID_PLATFORM_NAME_ERROR = "platformName must be a valid DevicePlatform value";
10
+ /**
11
+ * Error message for when applicationName is missing
12
+ */
13
+ export declare const INVALID_APPLICATION_NAME_ERROR = "applicationName is required";
14
+ /**
15
+ * Enum for the device platform; currently only supports IOS and ANDROID
16
+ */
17
+ declare enum DevicePlatformEnum {
18
+ IOS = "IOS",
19
+ ANDROID = "ANDROID"
20
+ }
21
+ /**
22
+ * Type for the device platform; currently only supports IOS and ANDROID
23
+ */
24
+ export type DevicePlatform = `${DevicePlatformEnum}`;
25
+ /**
26
+ * Base input for device request; used directly by DeregisterDeviceRequest
27
+ */
28
+ export type DeviceRequestInput = {
29
+ deviceToken: string;
30
+ };
31
+ /**
32
+ * Input for the register device request
33
+ */
34
+ export type RegisterDeviceRequestInput = DeviceRequestInput & {
35
+ platformName: DevicePlatform;
36
+ applicationName: string;
37
+ };
38
+ /**
39
+ * Base validator for device requests - only deviceToken is required in both request types
40
+ */
41
+ export declare class DeviceRequestValidator<T extends DeviceRequestInput> implements Validator<T> {
42
+ validate(data: T, errors: ErrorsCollector): void;
43
+ }
44
+ /**
45
+ * Validator for RegisterDeviceRequest - checks that platform, applicationName and deviceToken are valid
46
+ */
47
+ export declare class RegisterDeviceRequestValidator<T extends RegisterDeviceRequestInput> extends DeviceRequestValidator<T> {
48
+ validate(data: T, errors: ErrorsCollector): void;
49
+ }
50
+ /**
51
+ * Request for registering a device
52
+ */
53
+ export declare class RegisterDeviceRequest extends ValidationRequest<RegisterDeviceRequestInput> {
54
+ protected validator: RegisterDeviceRequestValidator<RegisterDeviceRequestInput>;
55
+ }
56
+ /**
57
+ * Request for deregistering a device
58
+ */
59
+ export declare class DeregisterDeviceRequest extends ValidationRequest<DeviceRequestInput> {
60
+ protected validator: DeviceRequestValidator<DeviceRequestInput>;
61
+ }
62
+ export {};
@@ -0,0 +1,71 @@
1
+ import { ValidationRequest, } from "../../../requests/index.js";
2
+ import { isBlank } from "../../../utils/index.js";
3
+ /**
4
+ * Error message for when deviceToken is missing
5
+ */
6
+ export const INVALID_DEVICE_TOKEN_ERROR = "deviceToken is required";
7
+ /**
8
+ * Error message for when platformName is not a valid DevicePlatform value
9
+ */
10
+ export const INVALID_PLATFORM_NAME_ERROR = "platformName must be a valid DevicePlatform value";
11
+ /**
12
+ * Error message for when applicationName is missing
13
+ */
14
+ export const INVALID_APPLICATION_NAME_ERROR = "applicationName is required";
15
+ /**
16
+ * Enum for the device platform; currently only supports IOS and ANDROID
17
+ */
18
+ var DevicePlatformEnum;
19
+ (function (DevicePlatformEnum) {
20
+ DevicePlatformEnum["IOS"] = "IOS";
21
+ DevicePlatformEnum["ANDROID"] = "ANDROID";
22
+ })(DevicePlatformEnum || (DevicePlatformEnum = {}));
23
+ const devicePlatformValueCache = new Set(Object.values(DevicePlatformEnum));
24
+ function isValidDevicePlatform(value) {
25
+ return devicePlatformValueCache.has(value);
26
+ }
27
+ function isNotValidDevicePlatform(value) {
28
+ return !isValidDevicePlatform(value);
29
+ }
30
+ /**
31
+ * Base validator for device requests - only deviceToken is required in both request types
32
+ */
33
+ export class DeviceRequestValidator {
34
+ validate(data, errors) {
35
+ if (isBlank(data.deviceToken)) {
36
+ errors.add(INVALID_DEVICE_TOKEN_ERROR);
37
+ }
38
+ }
39
+ }
40
+ /**
41
+ * Validator for RegisterDeviceRequest - checks that platform, applicationName and deviceToken are valid
42
+ */
43
+ export class RegisterDeviceRequestValidator extends DeviceRequestValidator {
44
+ validate(data, errors) {
45
+ super.validate(data, errors);
46
+ if (isNotValidDevicePlatform(data.platformName.toUpperCase())) {
47
+ errors.add(INVALID_PLATFORM_NAME_ERROR);
48
+ }
49
+ if (isBlank(data.applicationName)) {
50
+ errors.add(INVALID_APPLICATION_NAME_ERROR);
51
+ }
52
+ }
53
+ }
54
+ /**
55
+ * Request for registering a device
56
+ */
57
+ export class RegisterDeviceRequest extends ValidationRequest {
58
+ constructor() {
59
+ super(...arguments);
60
+ this.validator = new RegisterDeviceRequestValidator();
61
+ }
62
+ }
63
+ /**
64
+ * Request for deregistering a device
65
+ */
66
+ export class DeregisterDeviceRequest extends ValidationRequest {
67
+ constructor() {
68
+ super(...arguments);
69
+ this.validator = new DeviceRequestValidator();
70
+ }
71
+ }
@@ -0,0 +1,2 @@
1
+ export { DeviceRegistrationResults, DeviceManager } from "./device-manager.js";
2
+ export { DevicePlatform, DeviceRequestInput, RegisterDeviceRequestInput, DeregisterDeviceRequest, RegisterDeviceRequest, } from "./device-request.js";
@@ -0,0 +1,2 @@
1
+ export { DeviceManager } from "./device-manager.js";
2
+ export { DeregisterDeviceRequest, RegisterDeviceRequest, } from "./device-request.js";
@@ -0,0 +1,16 @@
1
+ import { PublishEventMutationResults } from "../../../graphql/operations/types.js";
2
+ import type { BWellTransactionResult } from "../../../results/index.js";
3
+ import { BaseManagerError } from "../errors.js";
4
+ import { HandleNotificationRequest } from "./event-request.js";
5
+ export type HandleNotificationResults = PublishEventMutationResults["publishEvent"];
6
+ /**
7
+ * The EventManager interface provides a method for marking a notification as read.
8
+ */
9
+ export interface EventManager {
10
+ /**
11
+ * Handles a notification event. This is used to track when a user opens a push notification.
12
+ * @param request The request to handle the notification. This takes a string parameter representing the serialized notification.
13
+ * @returns A promise that resolves to a transaction result with the results of the operation.
14
+ */
15
+ handleNotification(request: HandleNotificationRequest): Promise<BWellTransactionResult<HandleNotificationResults, BaseManagerError>>;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import { ErrorsCollector, ValidationRequest, Validator } from "../../../requests/index.js";
2
+ export type EventRequestInput = {
3
+ serializedNotification: string;
4
+ };
5
+ export type IterableNotification = {
6
+ notification_id: string;
7
+ itbl: {
8
+ messageId: string;
9
+ };
10
+ };
11
+ export declare const SERIALIZED_NOTIFICATION_ERROR = "string parameter serializedNotification must be provided";
12
+ export declare const NOTIFICATION_ID_ERROR = "serialized notification must have a non-empty notification_id field of type string";
13
+ export declare const ITBL_ERROR = "serialized notification must have an itbl object containing a non-empty messageId field of type string";
14
+ export declare const NOT_AN_OBJECT_ERROR = "parsed notification must be a non-null object.";
15
+ export declare const INVALID_JSON_ERROR = "serialized notification is not valid JSON.";
16
+ /**
17
+ * Validator for event requests.
18
+ */
19
+ export declare class EventRequestValidator implements Validator<EventRequestInput> {
20
+ /**
21
+ * Validates the serializedNotification property.
22
+ * @param data The data to validate.
23
+ * @param errors The collector for errors.
24
+ */
25
+ validate(data: EventRequestInput, errors: ErrorsCollector): void;
26
+ }
27
+ /**
28
+ * Base request object for handling notifications.
29
+ * This request is used to track when a user opens a push notification.
30
+ * The request takes a string parameter representing the serialized notification.
31
+ * @extends ValidationRequest
32
+ */
33
+ export declare class HandleNotificationRequest extends ValidationRequest<EventRequestInput, EventRequestInput> {
34
+ protected validator: EventRequestValidator;
35
+ }
@@ -0,0 +1,64 @@
1
+ import { ValidationRequest, } from "../../../requests/index.js";
2
+ import { isBlank, isNullOrUndefined, isUndefined, } from "../../../utils/index.js";
3
+ export const SERIALIZED_NOTIFICATION_ERROR = "string parameter serializedNotification must be provided";
4
+ export const NOTIFICATION_ID_ERROR = "serialized notification must have a non-empty notification_id field of type string";
5
+ export const ITBL_ERROR = "serialized notification must have an itbl object containing a non-empty messageId field of type string";
6
+ export const NOT_AN_OBJECT_ERROR = "parsed notification must be a non-null object.";
7
+ export const INVALID_JSON_ERROR = "serialized notification is not valid JSON.";
8
+ /**
9
+ * Validator for event requests.
10
+ */
11
+ export class EventRequestValidator {
12
+ /**
13
+ * Validates the serializedNotification property.
14
+ * @param data The data to validate.
15
+ * @param errors The collector for errors.
16
+ */
17
+ validate(data, errors) {
18
+ if (isUndefined(data.serializedNotification) ||
19
+ typeof data.serializedNotification !== "string" ||
20
+ isBlank(data.serializedNotification)) {
21
+ errors.add(SERIALIZED_NOTIFICATION_ERROR);
22
+ return;
23
+ }
24
+ let notification = null;
25
+ try {
26
+ notification = JSON.parse(data.serializedNotification);
27
+ }
28
+ catch (_a) {
29
+ errors.add(INVALID_JSON_ERROR);
30
+ return;
31
+ }
32
+ if (typeof notification !== "object" || notification === null) {
33
+ errors.add(NOT_AN_OBJECT_ERROR);
34
+ return;
35
+ }
36
+ const { itbl, notification_id } = notification;
37
+ if (isUndefined(notification_id) ||
38
+ typeof notification_id !== "string" ||
39
+ isBlank(notification_id)) {
40
+ errors.add(NOTIFICATION_ID_ERROR);
41
+ }
42
+ if (typeof itbl !== "object" || isNullOrUndefined(itbl)) {
43
+ errors.add(ITBL_ERROR);
44
+ return;
45
+ }
46
+ if (isUndefined(itbl.messageId) ||
47
+ typeof itbl.messageId !== "string" ||
48
+ isBlank(itbl.messageId)) {
49
+ errors.add(ITBL_ERROR);
50
+ }
51
+ }
52
+ }
53
+ /**
54
+ * Base request object for handling notifications.
55
+ * This request is used to track when a user opens a push notification.
56
+ * The request takes a string parameter representing the serialized notification.
57
+ * @extends ValidationRequest
58
+ */
59
+ export class HandleNotificationRequest extends ValidationRequest {
60
+ constructor() {
61
+ super(...arguments);
62
+ this.validator = new EventRequestValidator();
63
+ }
64
+ }
@@ -0,0 +1,2 @@
1
+ export { HandleNotificationResults, EventManager } from "./event-manager.js";
2
+ export { EventRequestInput, HandleNotificationRequest, } from "./event-request.js";
@@ -0,0 +1 @@
1
+ export { HandleNotificationRequest, } from "./event-request.js";