web-push-notifications 3.44.7 → 3.44.8
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/core/Pushwoosh.d.ts +199 -0
- package/core/Pushwoosh.types.d.ts +213 -0
- package/core/Safari.types.d.ts +17 -0
- package/core/constants.d.ts +41 -0
- package/core/events.types.d.ts +55 -0
- package/core/functions.d.ts +5 -0
- package/core/legacyEventsMap.d.ts +5 -0
- package/core/logger.d.ts +14 -0
- package/core/modules/EventBus/EventBus.d.ts +10 -0
- package/core/storage.d.ts +27 -0
- package/helpers/logger.d.ts +11 -0
- package/helpers/pwlogger/Logger.constants.d.ts +21 -0
- package/helpers/pwlogger/Logger.d.ts +37 -0
- package/helpers/pwlogger/Logger.types.d.ts +44 -0
- package/helpers/pwlogger/handlers/handler-console/handler-console.d.ts +2 -0
- package/{src/helpers/unescape.ts → helpers/unescape.d.ts} +1 -18
- package/models/InboxMessages.d.ts +82 -0
- package/models/InboxMessages.types.d.ts +83 -0
- package/models/NotificationPayload.d.ts +39 -0
- package/models/NotificationPayload.types.d.ts +63 -0
- package/modules/Api/Api.d.ts +45 -0
- package/modules/Api/Api.types.d.ts +7 -0
- package/modules/ApiClient/ApiClient.d.ts +29 -0
- package/modules/ApiClient/ApiClient.types.d.ts +188 -0
- package/modules/Data/Data.d.ts +76 -0
- package/modules/DateModule.d.ts +27 -0
- package/modules/InboxMessagesPublic.d.ts +64 -0
- package/modules/PlatformChecker/PlatformChecker.d.ts +45 -0
- package/modules/PlatformChecker/PlatformChecker.types.d.ts +5 -0
- package/modules/storage/Storage.d.ts +63 -0
- package/{src/modules/storage/Storage.types.ts → modules/storage/Storage.types.d.ts} +7 -25
- package/modules/storage/Store.d.ts +22 -0
- package/modules/storage/migrations/26-11-2018.d.ts +2 -0
- package/modules/storage/migrations/MigrationExecutor.d.ts +9 -0
- package/modules/storage/migrations/Migrations.d.ts +15 -0
- package/modules/storage/migrations/constants.d.ts +6 -0
- package/modules/storage/migrations/helpers.d.ts +7 -0
- package/modules/storage/migrations/initial.d.ts +2 -0
- package/modules/storage/version.d.ts +2 -0
- package/npm.js +2 -0
- package/npm.js.map +1 -0
- package/package.json +1 -1
- package/service-worker.d.ts +1 -0
- package/service-worker.js +2 -0
- package/service-worker.js.map +1 -0
- package/services/PushService/PushService.types.d.ts +64 -0
- package/services/PushService/drivers/PushServiceDefault/PushServiceDefault.d.ts +29 -0
- package/{src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.ts → services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.d.ts} +1 -1
- package/services/PushService/drivers/PushServiceSafari/PushServiceSafari.d.ts +21 -0
- package/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.d.ts +4 -0
- package/widget-inbox.js +2 -0
- package/widget-inbox.js.map +1 -0
- package/widget-subscribe-popup.js +2 -0
- package/widget-subscribe-popup.js.map +1 -0
- package/widget-subscription-button.js +2 -0
- package/widget-subscription-button.js.map +1 -0
- package/widget-subscription-prompt.d.ts +2 -0
- package/widget-subscription-prompt.js +2 -0
- package/widget-subscription-prompt.js.map +1 -0
- package/widgets/Inbox/InboxWidget.d.ts +49 -0
- package/widgets/Inbox/constants.d.ts +7 -0
- package/widgets/Inbox/helpers.d.ts +4 -0
- package/widgets/Inbox/inbox_widget.types.d.ts +34 -0
- package/widgets/Inbox/widgetTemplates.d.ts +4 -0
- package/widgets/SubscribePopup/SubscribePopup.d.ts +20 -0
- package/widgets/SubscribePopup/constants.d.ts +6 -0
- package/widgets/SubscribePopup/helpers.d.ts +1 -0
- package/widgets/SubscribePopup/popupTemplates.d.ts +9 -0
- package/widgets/SubscribePopup/types/subscribe-popup.d.ts +43 -0
- package/widgets/SubscriptionButton/bell.d.ts +2 -0
- package/widgets/SubscriptionButton/constants.d.ts +7 -0
- package/widgets/SubscriptionButton/index.d.ts +90 -0
- package/widgets/SubscriptionButton/positioning.d.ts +11 -0
- package/widgets/SubscriptionButton/subscribe_widget.types.d.ts +35 -0
- package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.d.ts +1 -0
- package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.d.ts +14 -0
- package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.d.ts +3 -0
- package/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.d.ts +19 -0
- package/widgets/SubscriptionPrompt/constants.d.ts +21 -0
- package/widgets/SubscriptionPrompt/helpers.d.ts +5 -0
- package/worker/global.d.ts +16 -0
- package/worker/notification.d.ts +9 -0
- package/worker/worker.types.d.ts +4 -0
- package/.editorconfig +0 -11
- package/.gitlab-ci.yml +0 -193
- package/babel.config.js +0 -7
- package/ci/cdn/Dockerfile +0 -12
- package/ci/dev/Dockerfile +0 -30
- package/ci/dev/rootfs/entrypoint.sh +0 -18
- package/ci/dev/rootfs/entrypoint.sh.d/nginx.sh +0 -6
- package/ci/dev/rootfs/entrypoint.sh.d/supervisor.sh +0 -5
- package/ci/dev/rootfs/etc/nginx/_real_ip.conf +0 -2
- package/ci/dev/rootfs/etc/nginx/conf.d/default.conf +0 -20
- package/ci/dev/rootfs/etc/supervisor.d/nginx.ini +0 -11
- package/ci/github/Dockerfile +0 -59
- package/ci/github/release-zip.js +0 -61
- package/ci/npm/Dockerfile +0 -22
- package/config/config.js +0 -24
- package/config/configBuilder.js +0 -126
- package/config/helpers.js +0 -9
- package/config/index.js +0 -1
- package/develop/README.md +0 -42
- package/develop/favicon.png +0 -0
- package/develop/index.html +0 -511
- package/eslint.config.mjs +0 -114
- package/public/index.d.ts +0 -337
- package/scripts/zip.js +0 -26
- package/src/core/Pushwoosh.ts +0 -768
- package/src/core/Pushwoosh.types.ts +0 -254
- package/src/core/Safari.types.ts +0 -26
- package/src/core/constants.ts +0 -58
- package/src/core/events.types.ts +0 -46
- package/src/core/functions.ts +0 -33
- package/src/core/legacyEventsMap.ts +0 -64
- package/src/core/logger.ts +0 -64
- package/src/core/modules/EventBus/EventBus.ts +0 -66
- package/src/core/storage.ts +0 -254
- package/src/helpers/logger.ts +0 -81
- package/src/helpers/pwlogger/Logger.constants.ts +0 -31
- package/src/helpers/pwlogger/Logger.ts +0 -218
- package/src/helpers/pwlogger/Logger.types.ts +0 -66
- package/src/helpers/pwlogger/handlers/handler-console/handler-console.ts +0 -40
- package/src/models/InboxMessages.ts +0 -202
- package/src/models/InboxMessages.types.ts +0 -111
- package/src/models/NotificationPayload.ts +0 -216
- package/src/models/NotificationPayload.types.ts +0 -65
- package/src/modules/Api/Api.ts +0 -386
- package/src/modules/Api/Api.types.ts +0 -7
- package/src/modules/ApiClient/ApiClient.ts +0 -153
- package/src/modules/ApiClient/ApiClient.types.ts +0 -222
- package/src/modules/Data/Data.ts +0 -345
- package/src/modules/DateModule.ts +0 -53
- package/src/modules/InboxMessagesPublic.ts +0 -222
- package/src/modules/PlatformChecker/PlatformChecker.ts +0 -170
- package/src/modules/PlatformChecker/PlatformChecker.types.ts +0 -5
- package/src/modules/storage/Storage.ts +0 -164
- package/src/modules/storage/Store.ts +0 -104
- package/src/modules/storage/migrations/26-11-2018.ts +0 -25
- package/src/modules/storage/migrations/MigrationExecutor.ts +0 -31
- package/src/modules/storage/migrations/Migrations.ts +0 -41
- package/src/modules/storage/migrations/constants.ts +0 -8
- package/src/modules/storage/migrations/helpers.ts +0 -16
- package/src/modules/storage/migrations/initial.ts +0 -47
- package/src/modules/storage/version.ts +0 -2
- package/src/pushwoosh-web-notifications.ts +0 -47
- package/src/pushwoosh-widget-inbox.ts +0 -8
- package/src/pushwoosh-widget-subscribe-popup.ts +0 -9
- package/src/pushwoosh-widget-subscription-button.ts +0 -8
- package/src/pushwoosh-widget-subscription-prompt.ts +0 -6
- package/src/service-worker.ts +0 -455
- package/src/services/PushService/PushService.types.ts +0 -74
- package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.ts +0 -235
- package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.ts +0 -125
- package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.ts +0 -4
- package/src/widget-subscription-prompt.ts +0 -33
- package/src/widgets/Inbox/InboxWidget.ts +0 -564
- package/src/widgets/Inbox/constants.ts +0 -49
- package/src/widgets/Inbox/css/inboxWidgetStyle.css +0 -274
- package/src/widgets/Inbox/helpers.ts +0 -63
- package/src/widgets/Inbox/inbox.d.ts +0 -9
- package/src/widgets/Inbox/inbox_widget.types.ts +0 -41
- package/src/widgets/Inbox/widgetTemplates.ts +0 -55
- package/src/widgets/SubscribePopup/SubscribePopup.ts +0 -241
- package/src/widgets/SubscribePopup/constants.ts +0 -66
- package/src/widgets/SubscribePopup/helpers.ts +0 -11
- package/src/widgets/SubscribePopup/popupTemplates.ts +0 -24
- package/src/widgets/SubscribePopup/styles/popup.css +0 -226
- package/src/widgets/SubscribePopup/types/subscribe-popup.ts +0 -68
- package/src/widgets/SubscriptionButton/assets/css/main.css +0 -205
- package/src/widgets/SubscriptionButton/bell.ts +0 -67
- package/src/widgets/SubscriptionButton/constants.ts +0 -28
- package/src/widgets/SubscriptionButton/index.ts +0 -377
- package/src/widgets/SubscriptionButton/positioning.ts +0 -165
- package/src/widgets/SubscriptionButton/subscribe_widget.types.ts +0 -53
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts +0 -1
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.ts +0 -110
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts +0 -102
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.ts +0 -23
- package/src/widgets/SubscriptionPrompt/constants.ts +0 -22
- package/src/widgets/SubscriptionPrompt/helpers.ts +0 -42
- package/src/widgets/widgets.d.ts +0 -4
- package/src/worker/global.ts +0 -36
- package/src/worker/notification.ts +0 -34
- package/src/worker/worker.types.ts +0 -4
- package/test/__helpers__/apiHelpers.ts +0 -22
- package/test/__helpers__/keyValueHelpers.ts +0 -15
- package/test/__helpers__/platformHelpers.ts +0 -54
- package/test/__helpers__/sinonHelpers.ts +0 -7
- package/test/__helpers__/storageHelpers.ts +0 -56
- package/test/__mocks__/apiRequests.ts +0 -26
- package/test/__mocks__/idbMock.ts +0 -12
- package/test/__mocks__/idbObjectStoreMock.ts +0 -38
- package/test/__mocks__/inboxMessages.ts +0 -292
- package/test/__mocks__/models/inboxModel.ts +0 -71
- package/test/__mocks__/modules/apiClientModule.ts +0 -18
- package/test/__mocks__/modules/dateModule.ts +0 -34
- package/test/__mocks__/modules/inboxParamsModule.ts +0 -21
- package/test/__mocks__/modules/paramsBuilder.ts +0 -12
- package/test/__mocks__/modules/paramsModule.ts +0 -35
- package/test/__mocks__/modules/payloadBuilderModule.ts +0 -15
- package/test/__mocks__/modules/storageModule.ts +0 -58
- package/test/__mocks__/navigator.ts +0 -38
- package/test/__mocks__/notification.ts +0 -84
- package/test/__mocks__/pushwoosh.ts +0 -12
- package/test/__mocks__/userAgents +0 -8
- package/test/functions.test.ts +0 -22
- package/test/ignore-html.js +0 -6
- package/test/mocha.opts +0 -6
- package/test/modules/DateModule/unit.test.ts +0 -80
- package/test/modules/storage/Storage/unit.test.ts +0 -180
- package/test/modules/storage/Store/unit.test.ts +0 -192
- package/testRegister.js +0 -24
- package/tsconfig.json +0 -31
- package/webpack.config.js +0 -163
- /package/{src/core/modules/EventBus/index.ts → core/modules/EventBus/index.d.ts} +0 -0
- /package/{src/helpers/pwlogger/index.ts → helpers/pwlogger/index.d.ts} +0 -0
- /package/{src/modules/PlatformChecker/index.ts → modules/PlatformChecker/index.d.ts} +0 -0
- /package/{src/npm.ts → npm.d.ts} +0 -0
- /package/{src/services/PushService/PushService.ts → services/PushService/PushService.d.ts} +0 -0
- /package/{src/widget-inbox.ts → widget-inbox.d.ts} +0 -0
- /package/{src/widget-subscribe-popup.ts → widget-subscribe-popup.d.ts} +0 -0
- /package/{src/widget-subscription-button.ts → widget-subscription-button.d.ts} +0 -0
- /package/{src/widgets/Inbox/index.ts → widgets/Inbox/index.d.ts} +0 -0
- /package/{src/widgets/SubscribePopup/index.ts → widgets/SubscribePopup/index.d.ts} +0 -0
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { type IInboxMessage } from '../../models/InboxMessages.types';
|
|
2
|
-
|
|
3
|
-
type TMethodCheckDevice = 'checkDevice';
|
|
4
|
-
type TMethodGetConfig = 'getConfig';
|
|
5
|
-
type TMethodApplicationOpen = 'applicationOpen';
|
|
6
|
-
type TMethodRegisterDevice = 'registerDevice';
|
|
7
|
-
type TMethodUnregisterDevice = 'unregisterDevice';
|
|
8
|
-
type TMethodDeleteDevice = 'deleteDevice';
|
|
9
|
-
type TMethodMessageDeliveryEvent = 'messageDeliveryEvent';
|
|
10
|
-
type TMethodPushStat = 'pushStat';
|
|
11
|
-
type TMethodSetTags = 'setTags';
|
|
12
|
-
type TMethodGetTags = 'getTags';
|
|
13
|
-
type TMethodRegisterUser = 'registerUser';
|
|
14
|
-
type TMethodRegisterEmail = 'registerEmail';
|
|
15
|
-
type TMethodRegisterEmailUser = 'registerEmailUser';
|
|
16
|
-
type TMethodSetEmailTags = 'setEmailTags';
|
|
17
|
-
type TMethodPostEvent = 'postEvent';
|
|
18
|
-
type TMethodGetInboxMessages = 'getInboxMessages';
|
|
19
|
-
type TMethodInboxStatus = 'inboxStatus';
|
|
20
|
-
type TMethodPageVisit = 'pageVisit';
|
|
21
|
-
type TMethodSetPurchase = 'setPurchase';
|
|
22
|
-
|
|
23
|
-
export interface IRequest {
|
|
24
|
-
application: string; // Pushwoosh application code.
|
|
25
|
-
hwid: string; // Unique string to identify the device.
|
|
26
|
-
userId: string; // The user ID to associate with event.
|
|
27
|
-
device_type: number; // 10 - safari, 11 - chrome, 12 - firefox.
|
|
28
|
-
device_model: string; // browser version.
|
|
29
|
-
timezone: number; // Timezone offset in seconds for the device.
|
|
30
|
-
language: string; // Language locale of the device. Must be a lowercase two-letter code according to ISO-639-1 standard.
|
|
31
|
-
v: string; // Web SDK version.
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface IRequestEmail extends Omit<IRequest, 'hwid' | 'device_type'> {
|
|
35
|
-
email: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface IRequestGetConfig extends IRequest {
|
|
39
|
-
features: string[]; // array of features names.
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface IRequestRegisterDevice extends IRequest {
|
|
43
|
-
push_token: string; // Push token for the device.
|
|
44
|
-
public_key?: string;
|
|
45
|
-
auth_token?: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface IRequestRegisterUser extends IRequest {
|
|
49
|
-
ts_offset: number; // Timezone offset in seconds for the device. (aka timezone).
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface IRequestRegisterEmail extends IRequestEmail {
|
|
53
|
-
tags?: { [key: string]: any }; // email tags
|
|
54
|
-
ts_offset: number; // Timezone offset in seconds for the device. (aka timezone).
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface IRequestRegisterEmailUser extends IRequestEmail {
|
|
58
|
-
ts_offset: number; // Timezone offset in seconds for the device. (aka timezone).
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface IRequestSetEmailTags extends IRequestEmail {
|
|
62
|
-
tags: { [key: string]: any }; // email tags
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface IRequestPostEvent extends IRequest {
|
|
66
|
-
event: string; // Event name.
|
|
67
|
-
attributes?: { [key: string]: any };
|
|
68
|
-
timestampUTC?: number; // Timestamp in UTC.
|
|
69
|
-
timestampCurrent?: number; // Timestamp in local time.
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface IRequestMessageDeliveryEvent extends IRequest {
|
|
73
|
-
hash: string; // message hash,
|
|
74
|
-
metaData: { [key: string]: any }; // meta data
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
interface IRequestPushStat extends IRequest {
|
|
78
|
-
hash: string; // message hash
|
|
79
|
-
metaData: { [key: string]: any }; // meta data
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
interface IRequestSetTags extends IRequest {
|
|
83
|
-
tags: {
|
|
84
|
-
[key: string]: any;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
interface IRequestGetInboxMessages extends IRequest {
|
|
89
|
-
userId: string; // use hwid or other custom string if no userId
|
|
90
|
-
last_code: string; // For pagination purpose. "next" parameter from response. For first request send empty string
|
|
91
|
-
count?: number; // optional, default messages count on page
|
|
92
|
-
last_request_time: number; // for update new messages counter. UTC
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
interface IRequestInboxStatus extends IRequest {
|
|
96
|
-
userId: string; // use hwid or other custom string if no userId
|
|
97
|
-
inbox_code: string; // order. Ugly logic for fast development.
|
|
98
|
-
time: number; // timestamp utc
|
|
99
|
-
status: number;
|
|
100
|
-
hash?: string; // ??
|
|
101
|
-
device_type: number; // platform type from Pushwoosh system
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
interface IRequestPageVisit extends IRequest {
|
|
105
|
-
title: string;
|
|
106
|
-
url_path: string;
|
|
107
|
-
url: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
interface IRequestSetPurchase extends IRequest {
|
|
111
|
-
transactionDate: string;
|
|
112
|
-
quantity: number;
|
|
113
|
-
currency: string;
|
|
114
|
-
productIdentifier: string;
|
|
115
|
-
price: number;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
type IResponse = void;
|
|
119
|
-
|
|
120
|
-
interface IResponseCheckDevice {
|
|
121
|
-
exist: boolean; // exist device token
|
|
122
|
-
push_token_exist: boolean; // exist push token
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
interface IResponseGetConfig {
|
|
126
|
-
features: {
|
|
127
|
-
page_visit?: {
|
|
128
|
-
entrypoint: string;
|
|
129
|
-
enabled: boolean;
|
|
130
|
-
};
|
|
131
|
-
vapid_key?: string;
|
|
132
|
-
web_in_apps?: {
|
|
133
|
-
enabled: boolean;
|
|
134
|
-
};
|
|
135
|
-
events?: string[];
|
|
136
|
-
subscription_prompt?: {
|
|
137
|
-
useCase: 'not-set' | 'default' | 'not-used';
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
interface IResponseGetTags {
|
|
143
|
-
result: {
|
|
144
|
-
[key: string]: any;
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
interface IResponsePostEvent {
|
|
149
|
-
code?: string;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
interface IResponseGetInboxMessages {
|
|
153
|
-
messages: Array<IInboxMessage>;
|
|
154
|
-
next: string; // pagination code
|
|
155
|
-
deleted: Array<string>; // array of notifications codes deleted from cp
|
|
156
|
-
new_inbox: number; // inbox messages created since last request time
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export type TMethod =
|
|
160
|
-
| TMethodCheckDevice
|
|
161
|
-
| TMethodGetConfig
|
|
162
|
-
| TMethodApplicationOpen
|
|
163
|
-
| TMethodRegisterDevice
|
|
164
|
-
| TMethodUnregisterDevice
|
|
165
|
-
| TMethodDeleteDevice
|
|
166
|
-
| TMethodMessageDeliveryEvent
|
|
167
|
-
| TMethodPushStat
|
|
168
|
-
| TMethodSetTags
|
|
169
|
-
| TMethodGetTags
|
|
170
|
-
| TMethodRegisterUser
|
|
171
|
-
| TMethodRegisterEmail
|
|
172
|
-
| TMethodRegisterEmailUser
|
|
173
|
-
| TMethodSetEmailTags
|
|
174
|
-
| TMethodPostEvent
|
|
175
|
-
| TMethodGetInboxMessages
|
|
176
|
-
| TMethodInboxStatus
|
|
177
|
-
| TMethodPageVisit
|
|
178
|
-
| TMethodSetPurchase;
|
|
179
|
-
|
|
180
|
-
export interface IMapRequest {
|
|
181
|
-
checkDevice: IRequest;
|
|
182
|
-
getConfig: IRequestGetConfig;
|
|
183
|
-
applicationOpen: IRequest;
|
|
184
|
-
registerDevice: IRequestRegisterDevice;
|
|
185
|
-
unregisterDevice: IRequest;
|
|
186
|
-
deleteDevice: IRequest;
|
|
187
|
-
messageDeliveryEvent: IRequestMessageDeliveryEvent;
|
|
188
|
-
pushStat: IRequestPushStat;
|
|
189
|
-
setTags: IRequestSetTags;
|
|
190
|
-
getTags: IRequest;
|
|
191
|
-
registerUser: IRequestRegisterUser;
|
|
192
|
-
registerEmail: IRequestRegisterEmail;
|
|
193
|
-
registerEmailUser: IRequestRegisterEmailUser;
|
|
194
|
-
setEmailTags: IRequestSetEmailTags;
|
|
195
|
-
postEvent: IRequestPostEvent;
|
|
196
|
-
getInboxMessages: IRequestGetInboxMessages;
|
|
197
|
-
inboxStatus: IRequestInboxStatus;
|
|
198
|
-
pageVisit: IRequestPageVisit;
|
|
199
|
-
setPurchase: IRequestSetPurchase;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface IMapResponse {
|
|
203
|
-
checkDevice: IResponseCheckDevice;
|
|
204
|
-
getConfig: IResponseGetConfig;
|
|
205
|
-
applicationOpen: IRequest;
|
|
206
|
-
registerDevice: IResponse;
|
|
207
|
-
unregisterDevice: IResponse;
|
|
208
|
-
deleteDevice: IResponse;
|
|
209
|
-
messageDeliveryEvent: IResponse;
|
|
210
|
-
pushStat: IResponse;
|
|
211
|
-
setTags: IResponse;
|
|
212
|
-
getTags: IResponseGetTags;
|
|
213
|
-
registerUser: IResponse;
|
|
214
|
-
registerEmail: IResponse;
|
|
215
|
-
registerEmailUser: IResponse;
|
|
216
|
-
setEmailTags: IResponse;
|
|
217
|
-
postEvent: IResponsePostEvent;
|
|
218
|
-
getInboxMessages: IResponseGetInboxMessages;
|
|
219
|
-
inboxStatus: IResponse;
|
|
220
|
-
pageVisit: IResponse;
|
|
221
|
-
setPurchase: IResponse;
|
|
222
|
-
}
|
package/src/modules/Data/Data.ts
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import * as CONSTANTS from '../../core/constants';
|
|
2
|
-
import { keyValue } from '../../core/storage';
|
|
3
|
-
|
|
4
|
-
export class Data {
|
|
5
|
-
private readonly store: typeof keyValue;
|
|
6
|
-
|
|
7
|
-
constructor(store: typeof keyValue = keyValue) {
|
|
8
|
-
this.store = store;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
public async clearAll(): Promise<void> {
|
|
12
|
-
await this.store.set('params.applicationCode', undefined);
|
|
13
|
-
await this.store.set('params.hwid', undefined);
|
|
14
|
-
await this.store.set('params.deviceType', undefined);
|
|
15
|
-
await this.store.set('params.deviceModel', undefined);
|
|
16
|
-
await this.store.set('params.language', undefined);
|
|
17
|
-
await this.store.set('params.apiEntrypoint', undefined);
|
|
18
|
-
await this.store.set('params.tokens', undefined);
|
|
19
|
-
await this.store.set('params.applicationServerKey', undefined);
|
|
20
|
-
await this.store.set('params.senderId', undefined);
|
|
21
|
-
await this.store.set('params.webSitePushId', undefined);
|
|
22
|
-
await this.store.set('params.defaultNotificationImage', undefined);
|
|
23
|
-
await this.store.set('params.defaultNotificationTitle', undefined);
|
|
24
|
-
await this.store.set('params.userId', undefined);
|
|
25
|
-
await this.store.set('params.email', undefined);
|
|
26
|
-
await this.store.set('params.userIdWasChanged', undefined);
|
|
27
|
-
|
|
28
|
-
await this.store.set('params.isLastPermissionStatus', undefined);
|
|
29
|
-
await this.store.set('params.isManualUnsubscribed', undefined);
|
|
30
|
-
await this.store.set('params.isCommunicationDisabled', undefined);
|
|
31
|
-
await this.store.set('params.isDropAllData', undefined);
|
|
32
|
-
|
|
33
|
-
await this.store.set('params.sdkVersion', undefined);
|
|
34
|
-
await this.store.set('params.serviceWorkerVersion', undefined);
|
|
35
|
-
await this.store.set('params.serviceWorkerUrl', undefined);
|
|
36
|
-
await this.store.set('params.serviceWorkerScope', undefined);
|
|
37
|
-
|
|
38
|
-
await this.store.set('params.lastOpenMessage', undefined);
|
|
39
|
-
await this.store.set('params.lastOpenApplicationTime', undefined);
|
|
40
|
-
|
|
41
|
-
await this.store.set('params.features', undefined);
|
|
42
|
-
|
|
43
|
-
await this.store.set('params.init', undefined);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public async setApplicationCode(application: string): Promise<void> {
|
|
47
|
-
await this.store.set('params.applicationCode', application);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public async getApplicationCode(): Promise<string> {
|
|
51
|
-
return await this.store.get('params.applicationCode');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public async setApiToken(token: string): Promise<string> {
|
|
55
|
-
return await this.store.set('params.apiToken', token);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public async getApiToken(): Promise<string> {
|
|
59
|
-
return await this.store.get('params.apiToken');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public async setHwid(hwid: string): Promise<void> {
|
|
63
|
-
await this.store.set('params.hwid', hwid);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public async getHwid(): Promise<string> {
|
|
67
|
-
return await this.store.get('params.hwid');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public async setDeviceType(type: number): Promise<void> {
|
|
71
|
-
await this.store.set('params.deviceType', type);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public async getDeviceType(): Promise<number> {
|
|
75
|
-
return await this.store.get('params.deviceType');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public async setDeviceModel(model: string): Promise<void> {
|
|
79
|
-
await this.store.set('params.deviceModel', model);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public async getDeviceModel(): Promise<string> {
|
|
83
|
-
return await this.store.get('params.deviceModel');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public async setLanguage(language: string): Promise<void> {
|
|
87
|
-
await this.store.set('params.language', language);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public async getLanguage(): Promise<string> {
|
|
91
|
-
return await this.store.get('params.language', 'en');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public async setApiEntrypoint(url: string): Promise<void> {
|
|
95
|
-
await this.store.set('params.apiEntrypoint', url);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public async getApiEntrypoint(): Promise<string> {
|
|
99
|
-
return await this.store.get('params.apiEntrypoint', CONSTANTS.DEFAULT_API_URL);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public async setTokens(tokens: any): Promise<void> {
|
|
103
|
-
await this.store.set('params.tokens', tokens);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public getTokens(): Promise<any> {
|
|
107
|
-
return this.store.get('params.tokens');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public async setApplicationServerKey(key: string): Promise<void> {
|
|
111
|
-
await this.store.set('params.applicationServerKey', key);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public async getApplicationServerKey(): Promise<string | undefined> {
|
|
115
|
-
return await this.store.get('params.applicationServerKey');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public async setIsVapidChanged(status: boolean): Promise<void> {
|
|
119
|
-
await this.store.set('params.isVapidChanged', status);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public async getIsVapidChanged(): Promise<boolean> {
|
|
123
|
-
return await this.store.get('params.isVapidChanged', false);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public async setWebSitePushId(senderId: string): Promise<void> {
|
|
127
|
-
await this.store.set('params.webSitePushId', senderId);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public async getWebSitePushId(): Promise<string> {
|
|
131
|
-
return await this.store.get('params.webSitePushId');
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
public async setDefaultNotificationImage(url?: string): Promise<void> {
|
|
135
|
-
await this.store.set('params.defaultNotificationImage', url);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public async getDefaultNotificationImage(): Promise<string> {
|
|
139
|
-
return await this.store.get('params.defaultNotificationImage', CONSTANTS.DEFAULT_NOTIFICATION_IMAGE);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
public async setDefaultNotificationTitle(text?: string): Promise<void> {
|
|
143
|
-
await this.store.set('params.defaultNotificationTitle', text);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public async getDefaultNotificationTitle(): Promise<string> {
|
|
147
|
-
return await this.store.get('params.defaultNotificationTitle', CONSTANTS.DEFAULT_NOTIFICATION_TITLE);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public async setUserId(userId?: string | number): Promise<void> {
|
|
151
|
-
if (!userId) {
|
|
152
|
-
await this.store.set('params.userId', undefined);
|
|
153
|
-
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
await this.store.set('params.userId', userId.toString());
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public async getUserId(): Promise<string | undefined> {
|
|
161
|
-
return await this.store.get('params.userId');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
public async setStatusUserIdWasChanged(status: boolean): Promise<void> {
|
|
165
|
-
await this.store.set('params.userIdWasChanged', status);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public async getStatusUserIdWasChanged(): Promise<boolean> {
|
|
169
|
-
return await this.store.get('params.userIdWasChanged', false);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public async setEmail(email?: string): Promise<void> {
|
|
173
|
-
if (!email) {
|
|
174
|
-
await this.store.set('params.email', undefined);
|
|
175
|
-
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
await this.store.set('params.email', email.toString());
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
public async getEmail(): Promise<string | undefined> {
|
|
183
|
-
return await this.store.get('params.email');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
public async setStatusEmailWasChanged(status: boolean): Promise<void> {
|
|
187
|
-
await this.store.set('params.emailWasChanged', status);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public async getStatusEmailWasChanged(): Promise<boolean> {
|
|
191
|
-
return await this.store.get('params.emailWasChanged', false);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
public async setLastPermissionStatus(status: NotificationPermission): Promise<void> {
|
|
195
|
-
await this.store.set('params.isLastPermissionStatus', status);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public async getLastPermissionStatus(): Promise<NotificationPermission | undefined> {
|
|
199
|
-
return await this.store.get('params.isLastPermissionStatus');
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
public async setStatusManualUnsubscribed(status: boolean): Promise<void> {
|
|
203
|
-
await this.store.set('params.isManualUnsubscribed', status);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
public getStatusManualUnsubscribed(): Promise<boolean> {
|
|
207
|
-
return this.store.get('params.isManualUnsubscribed', false);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
public async setStatusCommunicationDisabled(status: boolean): Promise<void> {
|
|
211
|
-
await this.store.set('params.isCommunicationDisabled', status);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
public getStatusCommunicationDisabled(): Promise<boolean> {
|
|
215
|
-
return this.store.get('params.isCommunicationDisabled', false);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
public async setStatusDropAllData(status: boolean): Promise<void> {
|
|
219
|
-
await this.store.set('params.isDropAllData', status);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
public getStatusDropAllData(): Promise<boolean> {
|
|
223
|
-
return this.store.get('params.isDropAllData', false);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
public async setSdkVersion(version: string): Promise<void> {
|
|
227
|
-
await this.store.set('params.sdkVersion', version);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
public async getSdkVersion(): Promise<string> {
|
|
231
|
-
return await this.store.get('params.sdkVersion');
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
public async setServiceWorkerVersion(version: string): Promise<void> {
|
|
235
|
-
await this.store.set('params.serviceWorkerVersion', version);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
public getServiceWorkerVersion(): Promise<string> {
|
|
239
|
-
return this.store.get('params.serviceWorkerVersion');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
public async setServiceWorkerUrl(url?: string | null): Promise<void> {
|
|
243
|
-
if (!url) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
await this.store.set('params.serviceWorkerUrl', url);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
public async getServiceWorkerUrl(): Promise<string> {
|
|
251
|
-
return await this.store.get('params.serviceWorkerUrl', CONSTANTS.DEFAULT_SERVICE_WORKER_URL);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
public async setServiceWorkerScope(scope?: string): Promise<void> {
|
|
255
|
-
if (!scope) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
await this.store.set('params.serviceWorkerScope', scope);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
public async getServiceWorkerScope(): Promise<string> {
|
|
263
|
-
return await this.store.get('params.serviceWorkerScope');
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
public async setLastOpenMessage(message: any): Promise<void> {
|
|
267
|
-
await this.store.set('params.lastOpenMessage', message);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
public getLastOpenMessage(): Promise<any> {
|
|
271
|
-
return this.store.get('params.lastOpenMessage');
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
public async setLastOpenApplicationTime(time: number): Promise<void> {
|
|
275
|
-
await this.store.set('params.lastOpenApplicationTime', time);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
public async getLastOpenApplicationTime(): Promise<number> {
|
|
279
|
-
return await this.store.get('params.lastOpenApplicationTime');
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
public async setFeatures(features: any): Promise<void> {
|
|
283
|
-
await this.store.set('params.features', features);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
public async getFeatures(): Promise<any> {
|
|
287
|
-
return await this.store.get('params.features');
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
public async setInitParams(params: any): Promise<any> {
|
|
291
|
-
await this.store.set('params.init', params);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
public async getInitParams(): Promise<any> {
|
|
295
|
-
return await this.store.get('params.init');
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
public async setInboxLastRequestCode(lastCode: string): Promise<void> {
|
|
299
|
-
await this.store.set('params.inbox.lastRequestCode', lastCode);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
public async getInboxLastRequestCode(): Promise<string> {
|
|
303
|
-
return await this.store.get('params.inbox.lastRequestCode', '');
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
public async setInboxLastRequestTime(lastRequestTime: number): Promise<void> {
|
|
307
|
-
await this.store.set('params.inbox.lastRequestTime', lastRequestTime);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
public async getInboxLastRequestTime(): Promise<number> {
|
|
311
|
-
return this.store.get('params.inbox.lastRequestTime', 0);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
public async setInboxNewMessagesCount(count: number): Promise<void> {
|
|
315
|
-
await this.store.set('params.inbox.newMessagesCount', count);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
public async getInboxNewMessagesCount(): Promise<number> {
|
|
319
|
-
return this.store.get('params.inbox.newMessagesCount', 0);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
public async setDelayedEvent(event: any): Promise<void> {
|
|
323
|
-
await this.store.set('params.delayedEvent', event);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
public getDelayedEvent(): Promise<any> {
|
|
327
|
-
return this.store.get('params.delayedEvent');
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
public async setPromptDisplayCount(count: number): Promise<void> {
|
|
331
|
-
await this.store.set('params.promptDisplayCount', count);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
public async getPromptDisplayCount(): Promise<number> {
|
|
335
|
-
return this.store.get('params.promptDisplayCount', 0);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
public async setPromptLastSeenTime(time: number): Promise<void> {
|
|
339
|
-
await this.store.set('params.promptLastSeenTime', time);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
public async getPromptLastSeenTime(): Promise<number> {
|
|
343
|
-
return this.store.get('params.promptLastSeenTime', 0);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export default class DateModule {
|
|
2
|
-
private _date: Date;
|
|
3
|
-
|
|
4
|
-
constructor(date: Date = new Date()) {
|
|
5
|
-
this._date = date;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
set date(date: Date) {
|
|
9
|
-
this._date = date;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get date() {
|
|
13
|
-
return this._date;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Timestamp in UTC without milliseconds
|
|
18
|
-
*/
|
|
19
|
-
getUtcTimestamp() {
|
|
20
|
-
return Math.floor((this.date.getTime() + this.date.getTimezoneOffset() * 60 * 1000) / 1000);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Current date timestamp without milliseconds
|
|
25
|
-
*/
|
|
26
|
-
getTimestamp() {
|
|
27
|
-
return Math.round(this.date.getTime() / 1000);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Set date to local timezone
|
|
32
|
-
*/
|
|
33
|
-
setLocal() {
|
|
34
|
-
const newDateTimestamp = this._date.getTime() - this.date.getTimezoneOffset() * 60 * 1000;
|
|
35
|
-
this._date = new Date(newDateTimestamp);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Add days to current date
|
|
40
|
-
* @param days
|
|
41
|
-
*/
|
|
42
|
-
addDays(days: number) {
|
|
43
|
-
const newDateTimestamp = this._date.getTime() + days * 24 * 60 * 60 * 1000;
|
|
44
|
-
this._date = new Date(newDateTimestamp);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get inbox fake order
|
|
49
|
-
*/
|
|
50
|
-
getInboxFakeOrder(): string {
|
|
51
|
-
return (this._date.getTime() * 100 + 25 * 60 * 60 * 1000 * 100).toString();
|
|
52
|
-
}
|
|
53
|
-
}
|