@hellotext/hellotext 2.5.6 → 2.5.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/README.md +5 -26
- package/dist/hellotext.js +1 -1
- package/dist/hellotext.js.LICENSE.txt +1 -1
- package/index.d.ts +15 -6
- package/lib/api/acks.cjs +17 -31
- package/lib/api/acks.js +17 -42
- package/lib/api/businesses.cjs +14 -28
- package/lib/api/businesses.js +13 -36
- package/lib/api/events.cjs +26 -40
- package/lib/api/events.js +28 -52
- package/lib/api/forms.cjs +24 -40
- package/lib/api/forms.js +24 -57
- package/lib/api/identifications.cjs +15 -29
- package/lib/api/identifications.js +15 -40
- package/lib/api/index.cjs +26 -46
- package/lib/api/index.js +28 -49
- package/lib/api/push/identities.cjs +43 -0
- package/lib/api/push/identities.js +35 -0
- package/lib/api/response.cjs +30 -52
- package/lib/api/response.js +31 -60
- package/lib/api/submissions.cjs +18 -34
- package/lib/api/submissions.js +18 -48
- package/lib/api/webchat/messages.cjs +44 -64
- package/lib/api/webchat/messages.js +44 -80
- package/lib/api/webchats.cjs +37 -56
- package/lib/api/webchats.js +37 -65
- package/lib/api/whatsapp_widgets.cjs +49 -72
- package/lib/api/whatsapp_widgets.js +48 -91
- package/lib/builders/input_builder.cjs +36 -48
- package/lib/builders/input_builder.js +36 -48
- package/lib/builders/logo_builder.cjs +10 -29
- package/lib/builders/logo_builder.js +20 -28
- package/lib/channels/application_channel.cjs +136 -178
- package/lib/channels/application_channel.js +137 -180
- package/lib/channels/webchat_channel.cjs +125 -170
- package/lib/channels/webchat_channel.js +125 -170
- package/lib/controllers/form_controller.cjs +82 -121
- package/lib/controllers/form_controller.js +82 -130
- package/lib/controllers/message_controller.cjs +211 -282
- package/lib/controllers/message_controller.js +209 -284
- package/lib/controllers/mixins/usePopover.cjs +3 -6
- package/lib/controllers/mixins/usePopover.js +17 -22
- package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
- package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
- package/lib/controllers/webchat/useBehaviour.js +5 -5
- package/lib/controllers/webchat/useOpeningSequence.js +6 -6
- package/lib/controllers/webchat/useTeaser.js +9 -9
- package/lib/controllers/webchat_controller.cjs +916 -1088
- package/lib/controllers/webchat_controller.js +926 -1152
- package/lib/core/configuration/forms.cjs +21 -35
- package/lib/core/configuration/forms.js +20 -35
- package/lib/core/configuration/locale.cjs +36 -71
- package/lib/core/configuration/locale.js +36 -70
- package/lib/core/configuration/push.cjs +16 -0
- package/lib/core/configuration/push.js +10 -0
- package/lib/core/configuration/webchat.cjs +142 -182
- package/lib/core/configuration/webchat.js +145 -189
- package/lib/core/configuration/whatsapp.cjs +76 -102
- package/lib/core/configuration/whatsapp.js +76 -105
- package/lib/core/configuration.cjs +62 -75
- package/lib/core/configuration.js +61 -75
- package/lib/core/event.cjs +36 -59
- package/lib/core/event.js +35 -61
- package/lib/core/sanitize_html.js +4 -4
- package/lib/errors/invalid_event.cjs +5 -26
- package/lib/errors/invalid_event.js +5 -26
- package/lib/errors/not_initialized_error.cjs +5 -26
- package/lib/errors/not_initialized_error.js +5 -26
- package/lib/hellotext.cjs +186 -211
- package/lib/hellotext.js +189 -236
- package/lib/index.js +1 -1
- package/lib/models/business.cjs +115 -152
- package/lib/models/business.js +118 -162
- package/lib/models/cookies.cjs +34 -51
- package/lib/models/cookies.js +34 -51
- package/lib/models/fingerprint.cjs +8 -23
- package/lib/models/fingerprint.js +25 -58
- package/lib/models/form.cjs +106 -142
- package/lib/models/form.js +105 -153
- package/lib/models/form_collection.cjs +63 -101
- package/lib/models/form_collection.js +61 -107
- package/lib/models/index.cjs +7 -0
- package/lib/models/index.js +1 -0
- package/lib/models/page.cjs +106 -129
- package/lib/models/page.js +106 -131
- package/lib/models/push.cjs +345 -0
- package/lib/models/push.js +339 -0
- package/lib/models/query.cjs +21 -41
- package/lib/models/query.js +21 -41
- package/lib/models/session.cjs +33 -65
- package/lib/models/session.js +30 -63
- package/lib/models/user.cjs +29 -51
- package/lib/models/user.js +29 -51
- package/lib/models/utm.cjs +15 -27
- package/lib/models/utm.js +17 -32
- package/lib/models/webchat.cjs +52 -76
- package/lib/models/webchat.js +52 -90
- package/lib/models/whatsapp_widget.cjs +41 -59
- package/lib/models/whatsapp_widget.js +41 -73
- package/lib/vanilla.cjs +4 -7
- package/lib/vanilla.js +2 -1
- package/package.json +2 -10
- package/src/api/index.js +5 -0
- package/src/api/push/identities.js +42 -0
- package/src/core/configuration/push.js +12 -0
- package/src/core/configuration.js +5 -0
- package/src/hellotext.js +15 -1
- package/src/index.bundle.js +0 -1
- package/src/models/business.js +1 -0
- package/src/models/index.js +1 -0
- package/src/models/push.js +397 -0
- package/src/vanilla.js +2 -1
- package/styles/index.css +0 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.4.
|
|
1
|
+
/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */
|
package/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface HellotextConfig {
|
|
|
7
7
|
}
|
|
8
8
|
webchat?: false | HellotextWebchatConfig
|
|
9
9
|
whatsappWidget?: false | HellotextWhatsAppWidgetConfig
|
|
10
|
+
push?: false | HellotextPushConfig
|
|
10
11
|
session?: string
|
|
11
12
|
autoGenerateSession?: boolean
|
|
12
13
|
}
|
|
@@ -67,6 +68,18 @@ export interface HellotextWhatsAppWidgetConfig {
|
|
|
67
68
|
appearance?: HellotextWhatsAppWidgetAppearance
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
export interface HellotextPushConfig {
|
|
72
|
+
serviceWorkerUrl?: string | null
|
|
73
|
+
channelId?: string | null
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface HellotextPush {
|
|
77
|
+
readonly ready: Promise<void>
|
|
78
|
+
readonly subscribed: boolean
|
|
79
|
+
subscribe(): Promise<Response | void>
|
|
80
|
+
unsubscribe(): Promise<Response | null | void>
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
export interface HellotextBusinessCountry {
|
|
71
84
|
code?: string
|
|
72
85
|
prefix?: string
|
|
@@ -81,6 +94,7 @@ export interface HellotextBusinessData {
|
|
|
81
94
|
style_url?: string
|
|
82
95
|
webchat?: HellotextWebchatConfig | null
|
|
83
96
|
whatsapp?: HellotextWhatsAppWidgetConfig | null
|
|
97
|
+
push?: { public_key: string } | null
|
|
84
98
|
whitelist?: string | string[] | null
|
|
85
99
|
subscription?: string | null
|
|
86
100
|
[key: string]: any
|
|
@@ -142,6 +156,7 @@ declare class Hellotext {
|
|
|
142
156
|
static business: HellotextBusiness
|
|
143
157
|
static webchat: any
|
|
144
158
|
static whatsapp: any
|
|
159
|
+
static push: HellotextPush | null
|
|
145
160
|
}
|
|
146
161
|
|
|
147
162
|
export declare class User {
|
|
@@ -160,9 +175,3 @@ export declare class Cookies {
|
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
export default Hellotext
|
|
163
|
-
|
|
164
|
-
// Declare the CSS module
|
|
165
|
-
declare module '@hellotext/hellotext/styles/index.css' {
|
|
166
|
-
const styles: string
|
|
167
|
-
export default styles
|
|
168
|
-
}
|
package/lib/api/acks.cjs
CHANGED
|
@@ -7,37 +7,23 @@ exports.default = void 0;
|
|
|
7
7
|
var _hellotext = _interopRequireDefault(require("../hellotext"));
|
|
8
8
|
var _core = require("../core");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
let AcksAPI = /*#__PURE__*/function () {
|
|
16
|
-
function AcksAPI() {
|
|
17
|
-
_classCallCheck(this, AcksAPI);
|
|
10
|
+
class AcksAPI {
|
|
11
|
+
static get endpoint() {
|
|
12
|
+
return _core.Configuration.endpoint('public/acks');
|
|
18
13
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
method: 'POST',
|
|
34
|
-
headers: _hellotext.default.headers,
|
|
35
|
-
body: JSON.stringify(payload),
|
|
36
|
-
keepalive: true
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}]);
|
|
40
|
-
return AcksAPI;
|
|
41
|
-
}();
|
|
14
|
+
static async send(params = {}) {
|
|
15
|
+
const payload = {
|
|
16
|
+
...params,
|
|
17
|
+
session: _hellotext.default.session,
|
|
18
|
+
at: new Date().toISOString()
|
|
19
|
+
};
|
|
20
|
+
fetch(this.endpoint, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: _hellotext.default.headers,
|
|
23
|
+
body: JSON.stringify(payload),
|
|
24
|
+
keepalive: true
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
42
28
|
var _default = AcksAPI;
|
|
43
29
|
exports.default = _default;
|
package/lib/api/acks.js
CHANGED
|
@@ -1,46 +1,21 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
8
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
1
|
import Hellotext from '../hellotext';
|
|
12
2
|
import { Configuration } from '../core';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
class AcksAPI {
|
|
4
|
+
static get endpoint() {
|
|
5
|
+
return Configuration.endpoint('public/acks');
|
|
16
6
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
fetch(this.endpoint, {
|
|
32
|
-
method: 'POST',
|
|
33
|
-
headers: Hellotext.headers,
|
|
34
|
-
body: JSON.stringify(payload),
|
|
35
|
-
keepalive: true
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
function send() {
|
|
39
|
-
return _send.apply(this, arguments);
|
|
40
|
-
}
|
|
41
|
-
return send;
|
|
42
|
-
}()
|
|
43
|
-
}]);
|
|
44
|
-
return AcksAPI;
|
|
45
|
-
}();
|
|
7
|
+
static async send(params = {}) {
|
|
8
|
+
const payload = {
|
|
9
|
+
...params,
|
|
10
|
+
session: Hellotext.session,
|
|
11
|
+
at: new Date().toISOString()
|
|
12
|
+
};
|
|
13
|
+
fetch(this.endpoint, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: Hellotext.headers,
|
|
16
|
+
body: JSON.stringify(payload),
|
|
17
|
+
keepalive: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
46
21
|
export default AcksAPI;
|
package/lib/api/businesses.cjs
CHANGED
|
@@ -5,33 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _core = require("../core");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
-
let _default = /*#__PURE__*/function () {
|
|
14
|
-
function _default() {
|
|
15
|
-
_classCallCheck(this, _default);
|
|
8
|
+
class _default {
|
|
9
|
+
static get endpoint() {
|
|
10
|
+
return _core.Configuration.endpoint('public/businesses');
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Authorization: `Bearer ${id}`,
|
|
29
|
-
Accept: 'application/json',
|
|
30
|
-
'Content-Type': 'application/json'
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}]);
|
|
35
|
-
return _default;
|
|
36
|
-
}();
|
|
12
|
+
static async get(id) {
|
|
13
|
+
return fetch(`${this.endpoint}/${id}`, {
|
|
14
|
+
method: 'GET',
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${id}`,
|
|
17
|
+
Accept: 'application/json',
|
|
18
|
+
'Content-Type': 'application/json'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
37
23
|
exports.default = _default;
|
package/lib/api/businesses.js
CHANGED
|
@@ -1,39 +1,16 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
7
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
1
|
import { Configuration } from '../core';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
export default class {
|
|
3
|
+
static get endpoint() {
|
|
4
|
+
return Configuration.endpoint('public/businesses');
|
|
12
5
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
value: function () {
|
|
21
|
-
var _get = _asyncToGenerator(function* (id) {
|
|
22
|
-
return fetch("".concat(this.endpoint, "/").concat(id), {
|
|
23
|
-
method: 'GET',
|
|
24
|
-
headers: {
|
|
25
|
-
Authorization: "Bearer ".concat(id),
|
|
26
|
-
Accept: 'application/json',
|
|
27
|
-
'Content-Type': 'application/json'
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
function get(_x) {
|
|
32
|
-
return _get.apply(this, arguments);
|
|
6
|
+
static async get(id) {
|
|
7
|
+
return fetch(`${this.endpoint}/${id}`, {
|
|
8
|
+
method: 'GET',
|
|
9
|
+
headers: {
|
|
10
|
+
Authorization: `Bearer ${id}`,
|
|
11
|
+
Accept: 'application/json',
|
|
12
|
+
'Content-Type': 'application/json'
|
|
33
13
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return _default;
|
|
38
|
-
}();
|
|
39
|
-
export { _default as default };
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
package/lib/api/events.cjs
CHANGED
|
@@ -7,49 +7,35 @@ exports.default = void 0;
|
|
|
7
7
|
var _core = require("../core");
|
|
8
8
|
var _models = require("../models");
|
|
9
9
|
var _response = require("./response");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
let EventsAPI = /*#__PURE__*/function () {
|
|
16
|
-
function EventsAPI() {
|
|
17
|
-
_classCallCheck(this, EventsAPI);
|
|
10
|
+
class EventsAPI {
|
|
11
|
+
static get endpoint() {
|
|
12
|
+
return _core.Configuration.endpoint('track/events');
|
|
18
13
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
static async create({
|
|
15
|
+
headers,
|
|
16
|
+
body,
|
|
17
|
+
keepalive = false
|
|
18
|
+
}) {
|
|
19
|
+
if (_models.Query.inPreviewMode) {
|
|
20
|
+
return new _response.Response(true, {
|
|
21
|
+
received: true
|
|
22
|
+
});
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
value: async function create({
|
|
24
|
+
const fetchOptions = {
|
|
25
|
+
method: 'POST',
|
|
27
26
|
headers,
|
|
28
|
-
body
|
|
29
|
-
|
|
30
|
-
}) {
|
|
31
|
-
if (_models.Query.inPreviewMode) {
|
|
32
|
-
return new _response.Response(true, {
|
|
33
|
-
received: true
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const fetchOptions = {
|
|
37
|
-
method: 'POST',
|
|
38
|
-
headers,
|
|
39
|
-
body: JSON.stringify(body)
|
|
40
|
-
};
|
|
27
|
+
body: JSON.stringify(body)
|
|
28
|
+
};
|
|
41
29
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
const response = await fetch(this.endpoint, fetchOptions);
|
|
50
|
-
return new _response.Response(response.status === 200, await response.json());
|
|
30
|
+
// Do not send `keepalive: false`. The track caller opts in only for payloads
|
|
31
|
+
// that fit the browser keepalive budget; omitting the key for larger events
|
|
32
|
+
// preserves normal fetch behavior for rich carts/orders instead of asking
|
|
33
|
+
// the browser to use an unload-safe transport it may reject.
|
|
34
|
+
if (keepalive) {
|
|
35
|
+
fetchOptions.keepalive = true;
|
|
51
36
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
37
|
+
const response = await fetch(this.endpoint, fetchOptions);
|
|
38
|
+
return new _response.Response(response.status === 200, await response.json());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
55
41
|
exports.default = EventsAPI;
|
package/lib/api/events.js
CHANGED
|
@@ -1,58 +1,34 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
7
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
1
|
import { Configuration } from '../core';
|
|
9
2
|
import { Query } from '../models';
|
|
10
3
|
import { Response } from './response';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
export default class EventsAPI {
|
|
5
|
+
static get endpoint() {
|
|
6
|
+
return Configuration.endpoint('track/events');
|
|
14
7
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
static async create({
|
|
9
|
+
headers,
|
|
10
|
+
body,
|
|
11
|
+
keepalive = false
|
|
12
|
+
}) {
|
|
13
|
+
if (Query.inPreviewMode) {
|
|
14
|
+
return new Response(true, {
|
|
15
|
+
received: true
|
|
16
|
+
});
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
headers,
|
|
26
|
-
body,
|
|
27
|
-
keepalive = false
|
|
28
|
-
} = _ref;
|
|
29
|
-
if (Query.inPreviewMode) {
|
|
30
|
-
return new Response(true, {
|
|
31
|
-
received: true
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
var fetchOptions = {
|
|
35
|
-
method: 'POST',
|
|
36
|
-
headers,
|
|
37
|
-
body: JSON.stringify(body)
|
|
38
|
-
};
|
|
18
|
+
const fetchOptions = {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers,
|
|
21
|
+
body: JSON.stringify(body)
|
|
22
|
+
};
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return _create.apply(this, arguments);
|
|
52
|
-
}
|
|
53
|
-
return create;
|
|
54
|
-
}()
|
|
55
|
-
}]);
|
|
56
|
-
return EventsAPI;
|
|
57
|
-
}();
|
|
58
|
-
export { EventsAPI as default };
|
|
24
|
+
// Do not send `keepalive: false`. The track caller opts in only for payloads
|
|
25
|
+
// that fit the browser keepalive budget; omitting the key for larger events
|
|
26
|
+
// preserves normal fetch behavior for rich carts/orders instead of asking
|
|
27
|
+
// the browser to use an unload-safe transport it may reject.
|
|
28
|
+
if (keepalive) {
|
|
29
|
+
fetchOptions.keepalive = true;
|
|
30
|
+
}
|
|
31
|
+
const response = await fetch(this.endpoint, fetchOptions);
|
|
32
|
+
return new Response(response.status === 200, await response.json());
|
|
33
|
+
}
|
|
34
|
+
}
|
package/lib/api/forms.cjs
CHANGED
|
@@ -8,45 +8,29 @@ var _core = require("../core");
|
|
|
8
8
|
var _hellotext = _interopRequireDefault(require("../hellotext"));
|
|
9
9
|
var _response = require("./response");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
-
let FormsAPI = /*#__PURE__*/function () {
|
|
17
|
-
function FormsAPI() {
|
|
18
|
-
_classCallCheck(this, FormsAPI);
|
|
11
|
+
class FormsAPI {
|
|
12
|
+
static get endpoint() {
|
|
13
|
+
return _core.Configuration.endpoint('public/forms');
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
headers: _hellotext.default.headers,
|
|
42
|
-
body: JSON.stringify({
|
|
43
|
-
session: _hellotext.default.session,
|
|
44
|
-
...data
|
|
45
|
-
})
|
|
46
|
-
});
|
|
47
|
-
return new _response.Response(response.ok, response);
|
|
48
|
-
}
|
|
49
|
-
}]);
|
|
50
|
-
return FormsAPI;
|
|
51
|
-
}();
|
|
15
|
+
static async get(id) {
|
|
16
|
+
const url = new URL(`${this.endpoint}/${id}`);
|
|
17
|
+
url.searchParams.append('session', _hellotext.default.session);
|
|
18
|
+
url.searchParams.append('locale', _core.Locale.toString());
|
|
19
|
+
return fetch(url, {
|
|
20
|
+
method: 'GET',
|
|
21
|
+
headers: _hellotext.default.headers
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
static async submit(id, data) {
|
|
25
|
+
const response = await fetch(`${this.endpoint}/${id}/submissions`, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
headers: _hellotext.default.headers,
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
session: _hellotext.default.session,
|
|
30
|
+
...data
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
return new _response.Response(response.ok, response);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
52
36
|
exports.default = FormsAPI;
|
package/lib/api/forms.js
CHANGED
|
@@ -1,61 +1,28 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
8
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
1
|
import { Configuration, Locale } from '../core';
|
|
12
2
|
import Hellotext from '../hellotext';
|
|
13
3
|
import { Response } from './response';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
export default class FormsAPI {
|
|
5
|
+
static get endpoint() {
|
|
6
|
+
return Configuration.endpoint('public/forms');
|
|
17
7
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}()
|
|
40
|
-
}, {
|
|
41
|
-
key: "submit",
|
|
42
|
-
value: function () {
|
|
43
|
-
var _submit = _asyncToGenerator(function* (id, data) {
|
|
44
|
-
var response = yield fetch("".concat(this.endpoint, "/").concat(id, "/submissions"), {
|
|
45
|
-
method: 'POST',
|
|
46
|
-
headers: Hellotext.headers,
|
|
47
|
-
body: JSON.stringify(_objectSpread({
|
|
48
|
-
session: Hellotext.session
|
|
49
|
-
}, data))
|
|
50
|
-
});
|
|
51
|
-
return new Response(response.ok, response);
|
|
52
|
-
});
|
|
53
|
-
function submit(_x2, _x3) {
|
|
54
|
-
return _submit.apply(this, arguments);
|
|
55
|
-
}
|
|
56
|
-
return submit;
|
|
57
|
-
}()
|
|
58
|
-
}]);
|
|
59
|
-
return FormsAPI;
|
|
60
|
-
}();
|
|
61
|
-
export { FormsAPI as default };
|
|
8
|
+
static async get(id) {
|
|
9
|
+
const url = new URL(`${this.endpoint}/${id}`);
|
|
10
|
+
url.searchParams.append('session', Hellotext.session);
|
|
11
|
+
url.searchParams.append('locale', Locale.toString());
|
|
12
|
+
return fetch(url, {
|
|
13
|
+
method: 'GET',
|
|
14
|
+
headers: Hellotext.headers
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
static async submit(id, data) {
|
|
18
|
+
const response = await fetch(`${this.endpoint}/${id}/submissions`, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers: Hellotext.headers,
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
session: Hellotext.session,
|
|
23
|
+
...data
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
return new Response(response.ok, response);
|
|
27
|
+
}
|
|
28
|
+
}
|