web-push-notifications 3.44.7 → 3.44.9

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 (224) hide show
  1. package/core/Pushwoosh.d.ts +199 -0
  2. package/core/Pushwoosh.types.d.ts +213 -0
  3. package/core/Safari.types.d.ts +17 -0
  4. package/core/constants.d.ts +41 -0
  5. package/core/events.types.d.ts +55 -0
  6. package/core/functions.d.ts +5 -0
  7. package/core/legacyEventsMap.d.ts +5 -0
  8. package/core/logger.d.ts +14 -0
  9. package/core/modules/EventBus/EventBus.d.ts +10 -0
  10. package/core/storage.d.ts +27 -0
  11. package/helpers/logger.d.ts +11 -0
  12. package/helpers/pwlogger/Logger.constants.d.ts +21 -0
  13. package/helpers/pwlogger/Logger.d.ts +37 -0
  14. package/helpers/pwlogger/Logger.types.d.ts +44 -0
  15. package/helpers/pwlogger/handlers/handler-console/handler-console.d.ts +2 -0
  16. package/{src/helpers/unescape.ts → helpers/unescape.d.ts} +1 -18
  17. package/models/InboxMessages.d.ts +82 -0
  18. package/models/InboxMessages.types.d.ts +83 -0
  19. package/models/NotificationPayload.d.ts +39 -0
  20. package/models/NotificationPayload.types.d.ts +63 -0
  21. package/modules/Api/Api.d.ts +45 -0
  22. package/modules/Api/Api.types.d.ts +7 -0
  23. package/modules/ApiClient/ApiClient.d.ts +29 -0
  24. package/modules/ApiClient/ApiClient.types.d.ts +188 -0
  25. package/modules/Data/Data.d.ts +76 -0
  26. package/modules/DateModule.d.ts +27 -0
  27. package/modules/InboxMessagesPublic.d.ts +64 -0
  28. package/modules/PlatformChecker/PlatformChecker.d.ts +45 -0
  29. package/modules/PlatformChecker/PlatformChecker.types.d.ts +5 -0
  30. package/modules/storage/Storage.d.ts +63 -0
  31. package/{src/modules/storage/Storage.types.ts → modules/storage/Storage.types.d.ts} +7 -25
  32. package/modules/storage/Store.d.ts +22 -0
  33. package/modules/storage/migrations/26-11-2018.d.ts +2 -0
  34. package/modules/storage/migrations/MigrationExecutor.d.ts +9 -0
  35. package/modules/storage/migrations/Migrations.d.ts +15 -0
  36. package/modules/storage/migrations/constants.d.ts +6 -0
  37. package/modules/storage/migrations/helpers.d.ts +7 -0
  38. package/modules/storage/migrations/initial.d.ts +2 -0
  39. package/modules/storage/version.d.ts +2 -0
  40. package/npm.js +2 -0
  41. package/npm.js.map +1 -0
  42. package/package.json +1 -1
  43. package/service-worker.d.ts +1 -0
  44. package/service-worker.js +2 -0
  45. package/service-worker.js.map +1 -0
  46. package/services/PushService/PushService.types.d.ts +64 -0
  47. package/services/PushService/drivers/PushServiceDefault/PushServiceDefault.d.ts +29 -0
  48. package/{src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.ts → services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.d.ts} +1 -1
  49. package/services/PushService/drivers/PushServiceSafari/PushServiceSafari.d.ts +21 -0
  50. package/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.d.ts +4 -0
  51. package/widget-inbox.js +2 -0
  52. package/widget-inbox.js.map +1 -0
  53. package/widget-subscribe-popup.js +2 -0
  54. package/widget-subscribe-popup.js.map +1 -0
  55. package/widget-subscription-button.js +2 -0
  56. package/widget-subscription-button.js.map +1 -0
  57. package/widget-subscription-prompt.d.ts +2 -0
  58. package/widget-subscription-prompt.js +2 -0
  59. package/widget-subscription-prompt.js.map +1 -0
  60. package/widgets/Inbox/InboxWidget.d.ts +49 -0
  61. package/widgets/Inbox/constants.d.ts +7 -0
  62. package/widgets/Inbox/helpers.d.ts +4 -0
  63. package/widgets/Inbox/inbox_widget.types.d.ts +34 -0
  64. package/widgets/Inbox/widgetTemplates.d.ts +4 -0
  65. package/widgets/SubscribePopup/SubscribePopup.d.ts +20 -0
  66. package/widgets/SubscribePopup/constants.d.ts +6 -0
  67. package/widgets/SubscribePopup/helpers.d.ts +1 -0
  68. package/widgets/SubscribePopup/popupTemplates.d.ts +9 -0
  69. package/widgets/SubscribePopup/types/subscribe-popup.d.ts +43 -0
  70. package/widgets/SubscriptionButton/bell.d.ts +2 -0
  71. package/widgets/SubscriptionButton/constants.d.ts +7 -0
  72. package/widgets/SubscriptionButton/index.d.ts +90 -0
  73. package/widgets/SubscriptionButton/positioning.d.ts +11 -0
  74. package/widgets/SubscriptionButton/subscribe_widget.types.d.ts +35 -0
  75. package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.d.ts +1 -0
  76. package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.d.ts +14 -0
  77. package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.d.ts +3 -0
  78. package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.d.ts +19 -0
  79. package/widgets/SubscriptionPrompt/constants.d.ts +21 -0
  80. package/widgets/SubscriptionPrompt/helpers.d.ts +5 -0
  81. package/worker/global.d.ts +16 -0
  82. package/worker/notification.d.ts +9 -0
  83. package/worker/worker.types.d.ts +4 -0
  84. package/.editorconfig +0 -11
  85. package/.gitlab-ci.yml +0 -193
  86. package/babel.config.js +0 -7
  87. package/ci/cdn/Dockerfile +0 -12
  88. package/ci/dev/Dockerfile +0 -30
  89. package/ci/dev/rootfs/entrypoint.sh +0 -18
  90. package/ci/dev/rootfs/entrypoint.sh.d/nginx.sh +0 -6
  91. package/ci/dev/rootfs/entrypoint.sh.d/supervisor.sh +0 -5
  92. package/ci/dev/rootfs/etc/nginx/_real_ip.conf +0 -2
  93. package/ci/dev/rootfs/etc/nginx/conf.d/default.conf +0 -20
  94. package/ci/dev/rootfs/etc/supervisor.d/nginx.ini +0 -11
  95. package/ci/github/Dockerfile +0 -59
  96. package/ci/github/release-zip.js +0 -61
  97. package/ci/npm/Dockerfile +0 -22
  98. package/config/config.js +0 -24
  99. package/config/configBuilder.js +0 -126
  100. package/config/helpers.js +0 -9
  101. package/config/index.js +0 -1
  102. package/develop/README.md +0 -42
  103. package/develop/favicon.png +0 -0
  104. package/develop/index.html +0 -511
  105. package/eslint.config.mjs +0 -114
  106. package/public/index.d.ts +0 -337
  107. package/scripts/zip.js +0 -26
  108. package/src/core/Pushwoosh.ts +0 -768
  109. package/src/core/Pushwoosh.types.ts +0 -254
  110. package/src/core/Safari.types.ts +0 -26
  111. package/src/core/constants.ts +0 -58
  112. package/src/core/events.types.ts +0 -46
  113. package/src/core/functions.ts +0 -33
  114. package/src/core/legacyEventsMap.ts +0 -64
  115. package/src/core/logger.ts +0 -64
  116. package/src/core/modules/EventBus/EventBus.ts +0 -66
  117. package/src/core/storage.ts +0 -254
  118. package/src/helpers/logger.ts +0 -81
  119. package/src/helpers/pwlogger/Logger.constants.ts +0 -31
  120. package/src/helpers/pwlogger/Logger.ts +0 -218
  121. package/src/helpers/pwlogger/Logger.types.ts +0 -66
  122. package/src/helpers/pwlogger/handlers/handler-console/handler-console.ts +0 -40
  123. package/src/models/InboxMessages.ts +0 -202
  124. package/src/models/InboxMessages.types.ts +0 -111
  125. package/src/models/NotificationPayload.ts +0 -216
  126. package/src/models/NotificationPayload.types.ts +0 -65
  127. package/src/modules/Api/Api.ts +0 -386
  128. package/src/modules/Api/Api.types.ts +0 -7
  129. package/src/modules/ApiClient/ApiClient.ts +0 -153
  130. package/src/modules/ApiClient/ApiClient.types.ts +0 -222
  131. package/src/modules/Data/Data.ts +0 -345
  132. package/src/modules/DateModule.ts +0 -53
  133. package/src/modules/InboxMessagesPublic.ts +0 -222
  134. package/src/modules/PlatformChecker/PlatformChecker.ts +0 -170
  135. package/src/modules/PlatformChecker/PlatformChecker.types.ts +0 -5
  136. package/src/modules/storage/Storage.ts +0 -164
  137. package/src/modules/storage/Store.ts +0 -104
  138. package/src/modules/storage/migrations/26-11-2018.ts +0 -25
  139. package/src/modules/storage/migrations/MigrationExecutor.ts +0 -31
  140. package/src/modules/storage/migrations/Migrations.ts +0 -41
  141. package/src/modules/storage/migrations/constants.ts +0 -8
  142. package/src/modules/storage/migrations/helpers.ts +0 -16
  143. package/src/modules/storage/migrations/initial.ts +0 -47
  144. package/src/modules/storage/version.ts +0 -2
  145. package/src/pushwoosh-web-notifications.ts +0 -47
  146. package/src/pushwoosh-widget-inbox.ts +0 -8
  147. package/src/pushwoosh-widget-subscribe-popup.ts +0 -9
  148. package/src/pushwoosh-widget-subscription-button.ts +0 -8
  149. package/src/pushwoosh-widget-subscription-prompt.ts +0 -6
  150. package/src/service-worker.ts +0 -455
  151. package/src/services/PushService/PushService.types.ts +0 -74
  152. package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.ts +0 -235
  153. package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.ts +0 -125
  154. package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.ts +0 -4
  155. package/src/widget-subscription-prompt.ts +0 -33
  156. package/src/widgets/Inbox/InboxWidget.ts +0 -564
  157. package/src/widgets/Inbox/constants.ts +0 -49
  158. package/src/widgets/Inbox/css/inboxWidgetStyle.css +0 -274
  159. package/src/widgets/Inbox/helpers.ts +0 -63
  160. package/src/widgets/Inbox/inbox.d.ts +0 -9
  161. package/src/widgets/Inbox/inbox_widget.types.ts +0 -41
  162. package/src/widgets/Inbox/widgetTemplates.ts +0 -55
  163. package/src/widgets/SubscribePopup/SubscribePopup.ts +0 -241
  164. package/src/widgets/SubscribePopup/constants.ts +0 -66
  165. package/src/widgets/SubscribePopup/helpers.ts +0 -11
  166. package/src/widgets/SubscribePopup/popupTemplates.ts +0 -24
  167. package/src/widgets/SubscribePopup/styles/popup.css +0 -226
  168. package/src/widgets/SubscribePopup/types/subscribe-popup.ts +0 -68
  169. package/src/widgets/SubscriptionButton/assets/css/main.css +0 -205
  170. package/src/widgets/SubscriptionButton/bell.ts +0 -67
  171. package/src/widgets/SubscriptionButton/constants.ts +0 -28
  172. package/src/widgets/SubscriptionButton/index.ts +0 -377
  173. package/src/widgets/SubscriptionButton/positioning.ts +0 -165
  174. package/src/widgets/SubscriptionButton/subscribe_widget.types.ts +0 -53
  175. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts +0 -1
  176. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.ts +0 -110
  177. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts +0 -102
  178. package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.ts +0 -23
  179. package/src/widgets/SubscriptionPrompt/constants.ts +0 -22
  180. package/src/widgets/SubscriptionPrompt/helpers.ts +0 -42
  181. package/src/widgets/widgets.d.ts +0 -4
  182. package/src/worker/global.ts +0 -36
  183. package/src/worker/notification.ts +0 -34
  184. package/src/worker/worker.types.ts +0 -4
  185. package/test/__helpers__/apiHelpers.ts +0 -22
  186. package/test/__helpers__/keyValueHelpers.ts +0 -15
  187. package/test/__helpers__/platformHelpers.ts +0 -54
  188. package/test/__helpers__/sinonHelpers.ts +0 -7
  189. package/test/__helpers__/storageHelpers.ts +0 -56
  190. package/test/__mocks__/apiRequests.ts +0 -26
  191. package/test/__mocks__/idbMock.ts +0 -12
  192. package/test/__mocks__/idbObjectStoreMock.ts +0 -38
  193. package/test/__mocks__/inboxMessages.ts +0 -292
  194. package/test/__mocks__/models/inboxModel.ts +0 -71
  195. package/test/__mocks__/modules/apiClientModule.ts +0 -18
  196. package/test/__mocks__/modules/dateModule.ts +0 -34
  197. package/test/__mocks__/modules/inboxParamsModule.ts +0 -21
  198. package/test/__mocks__/modules/paramsBuilder.ts +0 -12
  199. package/test/__mocks__/modules/paramsModule.ts +0 -35
  200. package/test/__mocks__/modules/payloadBuilderModule.ts +0 -15
  201. package/test/__mocks__/modules/storageModule.ts +0 -58
  202. package/test/__mocks__/navigator.ts +0 -38
  203. package/test/__mocks__/notification.ts +0 -84
  204. package/test/__mocks__/pushwoosh.ts +0 -12
  205. package/test/__mocks__/userAgents +0 -8
  206. package/test/functions.test.ts +0 -22
  207. package/test/ignore-html.js +0 -6
  208. package/test/mocha.opts +0 -6
  209. package/test/modules/DateModule/unit.test.ts +0 -80
  210. package/test/modules/storage/Storage/unit.test.ts +0 -180
  211. package/test/modules/storage/Store/unit.test.ts +0 -192
  212. package/testRegister.js +0 -24
  213. package/tsconfig.json +0 -31
  214. package/webpack.config.js +0 -163
  215. /package/{src/core/modules/EventBus/index.ts → core/modules/EventBus/index.d.ts} +0 -0
  216. /package/{src/helpers/pwlogger/index.ts → helpers/pwlogger/index.d.ts} +0 -0
  217. /package/{src/modules/PlatformChecker/index.ts → modules/PlatformChecker/index.d.ts} +0 -0
  218. /package/{src/npm.ts → npm.d.ts} +0 -0
  219. /package/{src/services/PushService/PushService.ts → services/PushService/PushService.d.ts} +0 -0
  220. /package/{src/widget-inbox.ts → widget-inbox.d.ts} +0 -0
  221. /package/{src/widget-subscribe-popup.ts → widget-subscribe-popup.d.ts} +0 -0
  222. /package/{src/widget-subscription-button.ts → widget-subscription-button.d.ts} +0 -0
  223. /package/{src/widgets/Inbox/index.ts → widgets/Inbox/index.d.ts} +0 -0
  224. /package/{src/widgets/SubscribePopup/index.ts → widgets/SubscribePopup/index.d.ts} +0 -0
@@ -0,0 +1,44 @@
1
+ export type TLoggerLevelSilent = 'silent';
2
+ export type TLoggerLevelFatal = 'fatal';
3
+ export type TLoggerLevelError = 'error';
4
+ export type TLoggerLevelWarn = 'warn';
5
+ export type TLoggerLevelInfo = 'info';
6
+ export type TLoggerLevelDebug = 'debug';
7
+ export type TLoggerFromSDK = 'sdk';
8
+ export type TLoggerFromCP = 'cp';
9
+ export type TLoggerApplicationType = TLoggerFromSDK | TLoggerFromCP;
10
+ export type TLoggerOutputLevels = TLoggerLevelFatal | TLoggerLevelError | TLoggerLevelWarn | TLoggerLevelInfo | TLoggerLevelDebug;
11
+ export type TLoggerLevels = TLoggerLevelSilent | TLoggerOutputLevels;
12
+ export interface ILoggerLogOptions {
13
+ handler?: TLoggerHandler;
14
+ [key: string]: any;
15
+ }
16
+ export interface ILoggerLogParams {
17
+ type: TLoggerOutputLevels;
18
+ text: string;
19
+ code?: string | number;
20
+ options?: ILoggerLogOptions;
21
+ }
22
+ export type TLoggerHandler = (message: ILoggerMessage) => void | Promise<void>;
23
+ export interface ILoggerSubscriber {
24
+ handler: TLoggerHandler;
25
+ level: TLoggerOutputLevels;
26
+ }
27
+ export interface ILoggerMessage {
28
+ type: TLoggerOutputLevels;
29
+ text: string;
30
+ applicationType: TLoggerApplicationType;
31
+ code?: string | number;
32
+ applicationCode?: string;
33
+ domain?: string;
34
+ deviceInfo?: {
35
+ [key: string]: any;
36
+ };
37
+ [key: string]: any;
38
+ }
39
+ export interface ILoggerConfig {
40
+ level?: TLoggerLevels;
41
+ applicationType?: TLoggerApplicationType;
42
+ subscribers?: ILoggerSubscriber[];
43
+ }
44
+ export type TReject = (reason: Error) => void;
@@ -0,0 +1,2 @@
1
+ import { type ILoggerMessage } from './../../Logger';
2
+ export declare function handlerConsole(message: ILoggerMessage): void;
@@ -1,16 +1,3 @@
1
- /** Used to map HTML entities to characters. */
2
- const htmlUnescapes: { [key: string]: string } = {
3
- '&amp;': '&',
4
- '&lt;': '<',
5
- '&gt;': '>',
6
- '&quot;': '"',
7
- '&#39;': '\'',
8
- };
9
-
10
- /** Used to match HTML entities and HTML characters. */
11
- const reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
12
- const reHasEscapedHtml = RegExp(reEscapedHtml.source);
13
-
14
1
  /**
15
2
  * The inverse of `escape`this method converts the HTML entities
16
3
  * `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;` in `string` to
@@ -29,8 +16,4 @@ const reHasEscapedHtml = RegExp(reEscapedHtml.source);
29
16
  * unescape('fred, barney, &amp; pebbles')
30
17
  * // => 'fred, barney, & pebbles'
31
18
  */
32
- export function unescape(string: string) {
33
- return (string && reHasEscapedHtml.test(string))
34
- ? string.replace(reEscapedHtml, (entity) => htmlUnescapes[entity])
35
- : string;
36
- }
19
+ export declare function unescape(string: string): string;
@@ -0,0 +1,82 @@
1
+ import { type IInboxMessage } from './InboxMessages.types';
2
+ import { type EventBus } from '../core/modules/EventBus';
3
+ import { type Api } from '../modules/Api/Api';
4
+ import { type Data } from '../modules/Data/Data';
5
+ import DateModule from '../modules/DateModule';
6
+ import Storage from '../modules/storage/Storage';
7
+ import { type TInboxMessagesStoreName } from '../modules/storage/Storage.types';
8
+ export default class InboxMessages {
9
+ eventBus: EventBus;
10
+ data: Data;
11
+ api: Api;
12
+ storage: Storage;
13
+ storeName: TInboxMessagesStoreName;
14
+ dateModule: DateModule;
15
+ constructor(eventBus: EventBus, data: Data, api: Api, storage?: Storage, dateModule?: DateModule);
16
+ /**
17
+ * Get inbox messages by api
18
+ */
19
+ private getInboxMessages;
20
+ /**
21
+ * Store parameters for next getInboxMessages request
22
+ * @param next
23
+ * @param newMessagesCount
24
+ */
25
+ private storeGetInboxMessagesRequestParams;
26
+ /**
27
+ * Put loaded messages. Add delete status to loaded messages if this status set locally.
28
+ * @param messages
29
+ */
30
+ private putServerMessages;
31
+ /**
32
+ * Create or update inbox message
33
+ */
34
+ putMessage(message: IInboxMessage): Promise<string>;
35
+ /**
36
+ * Create or update messages pack
37
+ * @param messages
38
+ */
39
+ putBulkMessages(messages: Array<IInboxMessage>): Promise<Array<string>>;
40
+ /**
41
+ * Delete messages by codes
42
+ * @param codes
43
+ */
44
+ deleteMessages(codes: Array<string>): Promise<Array<void>>;
45
+ /**
46
+ * Delete expired by removal time messages
47
+ */
48
+ deleteExpiredMessages(): Promise<Array<void>>;
49
+ /**
50
+ * Get message by code
51
+ * @param code - inbox_id
52
+ */
53
+ getMessage(code: string): Promise<IInboxMessage>;
54
+ /**
55
+ * Get all read messages
56
+ */
57
+ getReadOpenMessages(): Promise<Array<IInboxMessage>>;
58
+ /**
59
+ * Get all unread messages
60
+ */
61
+ getDeliveredMessages(): Promise<Array<IInboxMessage>>;
62
+ /**
63
+ * All messages count
64
+ */
65
+ messagesCount(): Promise<number>;
66
+ /**
67
+ * Get count of messages with status "Delivered"
68
+ */
69
+ getDeliveredMessagesCount(): Promise<number>;
70
+ /**
71
+ * Get count of messages with status "Read"
72
+ */
73
+ getReadMessagesCount(): Promise<number>;
74
+ /**
75
+ * Get count of messages with status "Delivered" and "Read"
76
+ */
77
+ getDeliveredReadMessagesCount(): Promise<number>;
78
+ /**
79
+ * Load messages and sync with locally
80
+ */
81
+ updateMessages(): Promise<void>;
82
+ }
@@ -0,0 +1,83 @@
1
+ export type TInboxActionLink = 1;
2
+ export type TInboxActionRichMedia = 2;
3
+ export type TInboxActionType = TInboxActionLink | TInboxActionRichMedia;
4
+ export type TInboxMessageStatusDelivered = 1;
5
+ export type TInboxMessageStatusRead = 2;
6
+ export type TInboxMessageStatusOpen = 3;
7
+ export type TInboxMessageStatusDeleted = 4;
8
+ export type TInboxMessageStatus = TInboxMessageStatusDelivered | TInboxMessageStatusRead | TInboxMessageStatusOpen | TInboxMessageStatusDeleted;
9
+ export type TReadInboxMessagesStatusRange = [TInboxMessageStatusRead, TInboxMessageStatusOpen];
10
+ export interface IInboxMessageActionParams {
11
+ l?: string | null;
12
+ rm?: string;
13
+ h?: string;
14
+ r?: string;
15
+ }
16
+ export interface IInboxMessage {
17
+ inbox_id: string;
18
+ order: string;
19
+ rt: string;
20
+ send_date: string;
21
+ title: string;
22
+ image: string;
23
+ text: string;
24
+ action_type: TInboxActionType;
25
+ action_params: string;
26
+ status: TInboxMessageStatus;
27
+ }
28
+ export interface IGetInboxMessagesRequest {
29
+ application: string;
30
+ userId: string;
31
+ hwid: string;
32
+ last_code: string;
33
+ count?: number;
34
+ last_request_time: number;
35
+ }
36
+ export interface IGetInboxMessagesResponse {
37
+ messages: Array<IInboxMessage>;
38
+ next: string;
39
+ deleted: Array<string>;
40
+ new_inbox: number;
41
+ }
42
+ export interface IInboxStatusRequest {
43
+ userId: string;
44
+ hwid: string;
45
+ application: string;
46
+ inbox_code: string;
47
+ time: number;
48
+ status: TInboxMessageStatus;
49
+ hash?: string;
50
+ device_type: number;
51
+ }
52
+ export type TGetInboxMessagesMethod = 'getInboxMessages';
53
+ export type TInboxStatusMethod = 'inboxStatus';
54
+ export type TInboxMessagesIDBKeyPath = 'inbox_id';
55
+ export type TInboxMessagesIDBStatusIndex = 'status';
56
+ export type TInboxMessagesIDBRemovalTimeIndex = 'rt';
57
+ export type TInboxMessageTypePlain = 0;
58
+ export type TInboxMessageTypeRichmedia = 1;
59
+ export type TInboxMessageTypeURL = 2;
60
+ export type TInboxMessageTypeDeeplink = 3;
61
+ export type TInboxMessageType = TInboxMessageTypePlain | TInboxMessageTypeRichmedia | TInboxMessageTypeURL | TInboxMessageTypeDeeplink;
62
+ export type TInboxDefaultLink = '/';
63
+ export interface IInboxMessagePublic {
64
+ code: string;
65
+ title: string;
66
+ message: string;
67
+ imageUrl: string;
68
+ sendDate: string;
69
+ type: TInboxMessageType;
70
+ link: string | TInboxDefaultLink;
71
+ isRead: boolean;
72
+ isActionPerformed: boolean;
73
+ }
74
+ export interface IInboxMessages {
75
+ messagesWithNoActionPerformedCount(): Promise<number>;
76
+ unreadMessagesCount(): Promise<number>;
77
+ messagesCount(): Promise<number>;
78
+ loadMessages(): Promise<Array<IInboxMessagePublic>>;
79
+ readMessagesWithCodes(codes: Array<string>): Promise<void>;
80
+ performActionForMessageWithCode(code: string): Promise<void>;
81
+ deleteMessagesWithCodes(codes: Array<string>): Promise<void>;
82
+ publicMessageBuilder(message: IInboxMessage): Promise<IInboxMessagePublic>;
83
+ }
@@ -0,0 +1,39 @@
1
+ import { type IInboxMessage } from './InboxMessages.types';
2
+ import { type IChromeNotificationPayload, type INotificationButton, type INotificationOptionsPayload, type INotificationPayload, type INotificationPayloadInboxParams, type IShowNotificationOptions } from './NotificationPayload.types';
3
+ import { Data } from '../modules/Data/Data';
4
+ import DateModule from '../modules/DateModule';
5
+ /**
6
+ * Build notification payload for different usage (show notification, use in sdk, inbox messages)
7
+ */
8
+ export default class NotificationPayload {
9
+ payload: INotificationPayload;
10
+ data: Data;
11
+ code: string;
12
+ dateModule: DateModule;
13
+ constructor(payload: INotificationPayload | IChromeNotificationPayload, data?: Data, dateModule?: DateModule);
14
+ getIcon(): Promise<string>;
15
+ getTitle(): Promise<string>;
16
+ get silent(): boolean;
17
+ get body(): string;
18
+ get messageHash(): string;
19
+ get metaData(): {
20
+ [key: string]: any;
21
+ };
22
+ get image(): string;
23
+ get buttons(): Array<INotificationButton>;
24
+ get customData(): {
25
+ [key: string]: any;
26
+ };
27
+ get campaignCode(): string;
28
+ get link(): string;
29
+ get inboxId(): string;
30
+ get inboxParams(): INotificationPayloadInboxParams;
31
+ get inboxRemovalTime(): string;
32
+ getInboxImage(): Promise<string>;
33
+ get rootParams(): {
34
+ [key: string]: any;
35
+ };
36
+ getNotificationOptionsPayload(): Promise<INotificationOptionsPayload>;
37
+ getShowNotificationOptions(): Promise<IShowNotificationOptions>;
38
+ getInboxMessage(): Promise<IInboxMessage>;
39
+ }
@@ -0,0 +1,63 @@
1
+ export interface INotificationPayloadInboxParams {
2
+ image?: string;
3
+ rt?: string;
4
+ }
5
+ export interface INotificationPayload {
6
+ body: string;
7
+ p?: string;
8
+ silent?: string;
9
+ header?: string;
10
+ i?: string;
11
+ u?: string;
12
+ md?: string;
13
+ l?: string;
14
+ pwcid?: string;
15
+ image?: string;
16
+ buttons?: string;
17
+ pw_inbox?: string;
18
+ inbox_params?: string;
19
+ [key: string]: any;
20
+ }
21
+ export interface IChromeNotificationPayload {
22
+ data: INotificationPayload;
23
+ from: string;
24
+ }
25
+ export interface INotificationButton {
26
+ title: string;
27
+ action?: string;
28
+ url?: string;
29
+ }
30
+ export interface INotificationOptionsPayload {
31
+ body: string;
32
+ title: string;
33
+ icon: string;
34
+ image: string;
35
+ buttons: Array<INotificationButton>;
36
+ customData: {
37
+ [key: string]: any;
38
+ };
39
+ metaData: {
40
+ [key: string]: any;
41
+ };
42
+ campaignCode: string;
43
+ openUrl: string;
44
+ [key: string]: any;
45
+ }
46
+ export interface IShowNotificationOptionsData {
47
+ code: string;
48
+ buttons: Array<INotificationButton>;
49
+ image: string;
50
+ campaignCode: string;
51
+ inboxId: string;
52
+ }
53
+ export interface IShowNotificationOptions {
54
+ body: string;
55
+ icon: string;
56
+ tag: string;
57
+ data: IShowNotificationOptionsData;
58
+ actions: Array<INotificationButton>;
59
+ image: string;
60
+ badge?: string;
61
+ silent?: boolean;
62
+ [key: string]: any;
63
+ }
@@ -0,0 +1,45 @@
1
+ import { type SetPurchaseAttributes } from './Api.types';
2
+ import { type EventBus } from '../../core/modules/EventBus';
3
+ import { ApiClient } from '../ApiClient/ApiClient';
4
+ import { type IMapRequest, type IMapResponse } from '../ApiClient/ApiClient.types';
5
+ import { Data } from '../Data/Data';
6
+ export declare class Api {
7
+ private readonly data;
8
+ private readonly apiClient;
9
+ private readonly eventBus;
10
+ constructor(eventBus: EventBus, data?: Data, apiClient?: ApiClient);
11
+ checkDevice(): Promise<IMapResponse['checkDevice']>;
12
+ checkDeviceSubscribeForPushNotifications(useCache?: boolean): Promise<boolean>;
13
+ getConfig(features: string[]): Promise<IMapResponse['getConfig']>;
14
+ applicationOpen(): Promise<IMapResponse['applicationOpen']>;
15
+ registerDevice(): Promise<IMapResponse['registerDevice']>;
16
+ unregisterDevice(): Promise<IMapResponse['unregisterDevice']>;
17
+ deleteDevice(): Promise<IMapResponse['deleteDevice']>;
18
+ messageDeliveryEvent(hash: string, isTrackingLogOnFailure?: boolean, metaData?: {
19
+ [key: string]: any;
20
+ }): Promise<IMapResponse['messageDeliveryEvent']>;
21
+ pushStat(hash: string, isTrackingLogOnFailure?: boolean, metaData?: {
22
+ [key: string]: any;
23
+ }): Promise<IMapResponse['pushStat']>;
24
+ setTags(tags: {
25
+ [key: string]: any;
26
+ }): Promise<IMapResponse['setTags']>;
27
+ getTags(): Promise<IMapResponse['getTags']>;
28
+ registerUser(userId: string | number): Promise<IMapResponse['registerUser']>;
29
+ registerEmail(email: string, params?: IMapRequest['registerEmail']): Promise<IMapResponse['registerEmail']>;
30
+ postEvent(event: string, attributes: {
31
+ [key: string]: any;
32
+ }): Promise<IMapResponse['postEvent']>;
33
+ getInboxMessages(count?: number): Promise<IMapResponse['getInboxMessages']>;
34
+ inboxStatus(order: string, status: number): Promise<IMapResponse['inboxStatus']>;
35
+ triggerEvent(): Promise<void>;
36
+ pageVisit(config: {
37
+ title: string;
38
+ url_path: string;
39
+ url: string;
40
+ }): Promise<IMapResponse['pageVisit']>;
41
+ setPurchase(attributes: SetPurchaseAttributes): Promise<IMapResponse['setPurchase']>;
42
+ getParams(): Promise<any>;
43
+ get params(): void;
44
+ private getRequestParams;
45
+ }
@@ -0,0 +1,7 @@
1
+ export interface SetPurchaseAttributes {
2
+ transactionDate: string;
3
+ quantity: number;
4
+ currency: string;
5
+ productIdentifier: string;
6
+ price: number;
7
+ }
@@ -0,0 +1,29 @@
1
+ import { type IMapRequest, type IMapResponse } from './ApiClient.types';
2
+ import { Logger } from '../../core/logger';
3
+ import { Data } from '../Data/Data';
4
+ export declare class ApiClient {
5
+ private readonly data;
6
+ private readonly logger;
7
+ constructor(data?: Data, logger?: typeof Logger);
8
+ checkDevice(options: IMapRequest['checkDevice']): Promise<IMapResponse['checkDevice']>;
9
+ getConfig(options: IMapRequest['getConfig']): Promise<IMapResponse['getConfig']>;
10
+ applicationOpen(options: IMapRequest['applicationOpen']): Promise<IMapResponse['applicationOpen']>;
11
+ registerDevice(options: IMapRequest['registerDevice']): Promise<IMapResponse['registerDevice']>;
12
+ unregisterDevice(options: IMapRequest['unregisterDevice']): Promise<IMapResponse['unregisterDevice']>;
13
+ deleteDevice(options: IMapRequest['deleteDevice']): Promise<IMapResponse['deleteDevice']>;
14
+ messageDeliveryEvent(options: IMapRequest['messageDeliveryEvent']): Promise<IMapResponse['messageDeliveryEvent']>;
15
+ pushStat(options: IMapRequest['pushStat']): Promise<IMapResponse['pushStat']>;
16
+ setTags(options: IMapRequest['setTags']): Promise<IMapResponse['setTags']>;
17
+ getTags(options: IMapRequest['getTags']): Promise<IMapResponse['getTags']>;
18
+ registerUser(options: IMapRequest['registerUser']): Promise<IMapResponse['registerUser']>;
19
+ registerEmail(options: IMapRequest['registerEmail']): Promise<IMapResponse['registerEmail']>;
20
+ registerEmailUser(options: IMapRequest['registerEmailUser']): Promise<IMapResponse['registerEmailUser']>;
21
+ setEmailTags(options: IMapRequest['setEmailTags']): Promise<IMapResponse['setEmailTags']>;
22
+ postEvent(options: IMapRequest['postEvent']): Promise<IMapResponse['postEvent']>;
23
+ getInboxMessages(options: IMapRequest['getInboxMessages']): Promise<IMapResponse['getInboxMessages']>;
24
+ inboxStatus(options: IMapRequest['inboxStatus']): Promise<IMapResponse['inboxStatus']>;
25
+ pageVisit(options: IMapRequest['pageVisit'], url: string): Promise<IMapResponse['pageVisit']>;
26
+ setPurchase(options: IMapRequest['setPurchase']): Promise<IMapResponse['setPurchase']>;
27
+ private createRequest;
28
+ private checkResponse;
29
+ }
@@ -0,0 +1,188 @@
1
+ import { type IInboxMessage } from '../../models/InboxMessages.types';
2
+ type TMethodCheckDevice = 'checkDevice';
3
+ type TMethodGetConfig = 'getConfig';
4
+ type TMethodApplicationOpen = 'applicationOpen';
5
+ type TMethodRegisterDevice = 'registerDevice';
6
+ type TMethodUnregisterDevice = 'unregisterDevice';
7
+ type TMethodDeleteDevice = 'deleteDevice';
8
+ type TMethodMessageDeliveryEvent = 'messageDeliveryEvent';
9
+ type TMethodPushStat = 'pushStat';
10
+ type TMethodSetTags = 'setTags';
11
+ type TMethodGetTags = 'getTags';
12
+ type TMethodRegisterUser = 'registerUser';
13
+ type TMethodRegisterEmail = 'registerEmail';
14
+ type TMethodRegisterEmailUser = 'registerEmailUser';
15
+ type TMethodSetEmailTags = 'setEmailTags';
16
+ type TMethodPostEvent = 'postEvent';
17
+ type TMethodGetInboxMessages = 'getInboxMessages';
18
+ type TMethodInboxStatus = 'inboxStatus';
19
+ type TMethodPageVisit = 'pageVisit';
20
+ type TMethodSetPurchase = 'setPurchase';
21
+ export interface IRequest {
22
+ application: string;
23
+ hwid: string;
24
+ userId: string;
25
+ device_type: number;
26
+ device_model: string;
27
+ timezone: number;
28
+ language: string;
29
+ v: string;
30
+ }
31
+ export interface IRequestEmail extends Omit<IRequest, 'hwid' | 'device_type'> {
32
+ email: string;
33
+ }
34
+ interface IRequestGetConfig extends IRequest {
35
+ features: string[];
36
+ }
37
+ interface IRequestRegisterDevice extends IRequest {
38
+ push_token: string;
39
+ public_key?: string;
40
+ auth_token?: string;
41
+ }
42
+ interface IRequestRegisterUser extends IRequest {
43
+ ts_offset: number;
44
+ }
45
+ interface IRequestRegisterEmail extends IRequestEmail {
46
+ tags?: {
47
+ [key: string]: any;
48
+ };
49
+ ts_offset: number;
50
+ }
51
+ interface IRequestRegisterEmailUser extends IRequestEmail {
52
+ ts_offset: number;
53
+ }
54
+ interface IRequestSetEmailTags extends IRequestEmail {
55
+ tags: {
56
+ [key: string]: any;
57
+ };
58
+ }
59
+ interface IRequestPostEvent extends IRequest {
60
+ event: string;
61
+ attributes?: {
62
+ [key: string]: any;
63
+ };
64
+ timestampUTC?: number;
65
+ timestampCurrent?: number;
66
+ }
67
+ interface IRequestMessageDeliveryEvent extends IRequest {
68
+ hash: string;
69
+ metaData: {
70
+ [key: string]: any;
71
+ };
72
+ }
73
+ interface IRequestPushStat extends IRequest {
74
+ hash: string;
75
+ metaData: {
76
+ [key: string]: any;
77
+ };
78
+ }
79
+ interface IRequestSetTags extends IRequest {
80
+ tags: {
81
+ [key: string]: any;
82
+ };
83
+ }
84
+ interface IRequestGetInboxMessages extends IRequest {
85
+ userId: string;
86
+ last_code: string;
87
+ count?: number;
88
+ last_request_time: number;
89
+ }
90
+ interface IRequestInboxStatus extends IRequest {
91
+ userId: string;
92
+ inbox_code: string;
93
+ time: number;
94
+ status: number;
95
+ hash?: string;
96
+ device_type: number;
97
+ }
98
+ interface IRequestPageVisit extends IRequest {
99
+ title: string;
100
+ url_path: string;
101
+ url: string;
102
+ }
103
+ interface IRequestSetPurchase extends IRequest {
104
+ transactionDate: string;
105
+ quantity: number;
106
+ currency: string;
107
+ productIdentifier: string;
108
+ price: number;
109
+ }
110
+ type IResponse = void;
111
+ interface IResponseCheckDevice {
112
+ exist: boolean;
113
+ push_token_exist: boolean;
114
+ }
115
+ interface IResponseGetConfig {
116
+ features: {
117
+ page_visit?: {
118
+ entrypoint: string;
119
+ enabled: boolean;
120
+ };
121
+ vapid_key?: string;
122
+ web_in_apps?: {
123
+ enabled: boolean;
124
+ };
125
+ events?: string[];
126
+ subscription_prompt?: {
127
+ useCase: 'not-set' | 'default' | 'not-used';
128
+ };
129
+ };
130
+ }
131
+ interface IResponseGetTags {
132
+ result: {
133
+ [key: string]: any;
134
+ };
135
+ }
136
+ interface IResponsePostEvent {
137
+ code?: string;
138
+ }
139
+ interface IResponseGetInboxMessages {
140
+ messages: Array<IInboxMessage>;
141
+ next: string;
142
+ deleted: Array<string>;
143
+ new_inbox: number;
144
+ }
145
+ export type TMethod = TMethodCheckDevice | TMethodGetConfig | TMethodApplicationOpen | TMethodRegisterDevice | TMethodUnregisterDevice | TMethodDeleteDevice | TMethodMessageDeliveryEvent | TMethodPushStat | TMethodSetTags | TMethodGetTags | TMethodRegisterUser | TMethodRegisterEmail | TMethodRegisterEmailUser | TMethodSetEmailTags | TMethodPostEvent | TMethodGetInboxMessages | TMethodInboxStatus | TMethodPageVisit | TMethodSetPurchase;
146
+ export interface IMapRequest {
147
+ checkDevice: IRequest;
148
+ getConfig: IRequestGetConfig;
149
+ applicationOpen: IRequest;
150
+ registerDevice: IRequestRegisterDevice;
151
+ unregisterDevice: IRequest;
152
+ deleteDevice: IRequest;
153
+ messageDeliveryEvent: IRequestMessageDeliveryEvent;
154
+ pushStat: IRequestPushStat;
155
+ setTags: IRequestSetTags;
156
+ getTags: IRequest;
157
+ registerUser: IRequestRegisterUser;
158
+ registerEmail: IRequestRegisterEmail;
159
+ registerEmailUser: IRequestRegisterEmailUser;
160
+ setEmailTags: IRequestSetEmailTags;
161
+ postEvent: IRequestPostEvent;
162
+ getInboxMessages: IRequestGetInboxMessages;
163
+ inboxStatus: IRequestInboxStatus;
164
+ pageVisit: IRequestPageVisit;
165
+ setPurchase: IRequestSetPurchase;
166
+ }
167
+ export interface IMapResponse {
168
+ checkDevice: IResponseCheckDevice;
169
+ getConfig: IResponseGetConfig;
170
+ applicationOpen: IRequest;
171
+ registerDevice: IResponse;
172
+ unregisterDevice: IResponse;
173
+ deleteDevice: IResponse;
174
+ messageDeliveryEvent: IResponse;
175
+ pushStat: IResponse;
176
+ setTags: IResponse;
177
+ getTags: IResponseGetTags;
178
+ registerUser: IResponse;
179
+ registerEmail: IResponse;
180
+ registerEmailUser: IResponse;
181
+ setEmailTags: IResponse;
182
+ postEvent: IResponsePostEvent;
183
+ getInboxMessages: IResponseGetInboxMessages;
184
+ inboxStatus: IResponse;
185
+ pageVisit: IResponse;
186
+ setPurchase: IResponse;
187
+ }
188
+ export {};