@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
|
@@ -8,35 +8,21 @@ var _hellotext = _interopRequireDefault(require("../hellotext"));
|
|
|
8
8
|
var _core = require("../core");
|
|
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 IdentificationsAPI = /*#__PURE__*/function () {
|
|
17
|
-
function IdentificationsAPI() {
|
|
18
|
-
_classCallCheck(this, IdentificationsAPI);
|
|
11
|
+
class IdentificationsAPI {
|
|
12
|
+
static get endpoint() {
|
|
13
|
+
return _core.Configuration.endpoint('public/identifications');
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
session: _hellotext.default.session,
|
|
33
|
-
...data
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
return new _response.Response(response.ok, response);
|
|
37
|
-
}
|
|
38
|
-
}]);
|
|
39
|
-
return IdentificationsAPI;
|
|
40
|
-
}();
|
|
15
|
+
static async create(data = {}) {
|
|
16
|
+
const response = await fetch(this.endpoint, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers: _hellotext.default.headers,
|
|
19
|
+
body: JSON.stringify({
|
|
20
|
+
session: _hellotext.default.session,
|
|
21
|
+
...data
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
return new _response.Response(response.ok, response);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
41
27
|
var _default = IdentificationsAPI;
|
|
42
28
|
exports.default = _default;
|
|
@@ -1,45 +1,20 @@
|
|
|
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
3
|
import { Response } from './response';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
class IdentificationsAPI {
|
|
5
|
+
static get endpoint() {
|
|
6
|
+
return Configuration.endpoint('public/identifications');
|
|
17
7
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
headers: Hellotext.headers,
|
|
31
|
-
body: JSON.stringify(_objectSpread({
|
|
32
|
-
session: Hellotext.session
|
|
33
|
-
}, data))
|
|
34
|
-
});
|
|
35
|
-
return new Response(response.ok, response);
|
|
36
|
-
});
|
|
37
|
-
function create() {
|
|
38
|
-
return _create.apply(this, arguments);
|
|
39
|
-
}
|
|
40
|
-
return create;
|
|
41
|
-
}()
|
|
42
|
-
}]);
|
|
43
|
-
return IdentificationsAPI;
|
|
44
|
-
}();
|
|
8
|
+
static async create(data = {}) {
|
|
9
|
+
const response = await fetch(this.endpoint, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
headers: Hellotext.headers,
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
session: Hellotext.session,
|
|
14
|
+
...data
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
return new Response(response.ok, response);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
45
20
|
export default IdentificationsAPI;
|
package/lib/api/index.cjs
CHANGED
|
@@ -18,13 +18,9 @@ var _identifications = _interopRequireDefault(require("./identifications"));
|
|
|
18
18
|
var _webchats = _interopRequireDefault(require("./webchats"));
|
|
19
19
|
var _whatsapp_widgets = _interopRequireDefault(require("./whatsapp_widgets"));
|
|
20
20
|
var _acks = _interopRequireDefault(require("./acks"));
|
|
21
|
+
var _identities = _interopRequireDefault(require("./push/identities"));
|
|
21
22
|
var _response = require("./response");
|
|
22
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
24
|
-
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); } }
|
|
25
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
26
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
27
|
-
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); }
|
|
28
24
|
// Browsers keep `fetch(..., { keepalive: true })` requests alive during page
|
|
29
25
|
// unload/navigation, which is exactly the failure mode for analytics events
|
|
30
26
|
// fired from checkout redirects, form submissions, tab closes, and pixel
|
|
@@ -45,46 +41,30 @@ function keepaliveFor(body) {
|
|
|
45
41
|
}
|
|
46
42
|
return new Blob([serializedBody]).size < KEEPALIVE_BODY_LIMIT;
|
|
47
43
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
class API {
|
|
45
|
+
static get businesses() {
|
|
46
|
+
return _businesses.default;
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
get: function () {
|
|
75
|
-
return _whatsapp_widgets.default;
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
key: "identifications",
|
|
79
|
-
get: function () {
|
|
80
|
-
return _identifications.default;
|
|
81
|
-
}
|
|
82
|
-
}, {
|
|
83
|
-
key: "acks",
|
|
84
|
-
get: function () {
|
|
85
|
-
return _acks.default;
|
|
86
|
-
}
|
|
87
|
-
}]);
|
|
88
|
-
return API;
|
|
89
|
-
}();
|
|
48
|
+
static get events() {
|
|
49
|
+
return _events.default;
|
|
50
|
+
}
|
|
51
|
+
static get forms() {
|
|
52
|
+
return _forms.default;
|
|
53
|
+
}
|
|
54
|
+
static get webchats() {
|
|
55
|
+
return _webchats.default;
|
|
56
|
+
}
|
|
57
|
+
static get whatsappWidgets() {
|
|
58
|
+
return _whatsapp_widgets.default;
|
|
59
|
+
}
|
|
60
|
+
static get identifications() {
|
|
61
|
+
return _identifications.default;
|
|
62
|
+
}
|
|
63
|
+
static get acks() {
|
|
64
|
+
return _acks.default;
|
|
65
|
+
}
|
|
66
|
+
static get pushIdentities() {
|
|
67
|
+
return _identities.default;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
90
70
|
exports.default = API;
|
package/lib/api/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
-
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); } }
|
|
3
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
5
|
-
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); }
|
|
6
1
|
import BusinessesAPI from './businesses';
|
|
7
2
|
import EventsAPI from './events';
|
|
8
3
|
import FormsAPI from './forms';
|
|
@@ -10,6 +5,7 @@ import IdentificationsAPI from './identifications';
|
|
|
10
5
|
import WebchatsAPI from './webchats';
|
|
11
6
|
import WhatsAppWidgetsAPI from './whatsapp_widgets';
|
|
12
7
|
import AcksAPI from './acks';
|
|
8
|
+
import PushIdentitiesAPI from './push/identities';
|
|
13
9
|
|
|
14
10
|
// Browsers keep `fetch(..., { keepalive: true })` requests alive during page
|
|
15
11
|
// unload/navigation, which is exactly the failure mode for analytics events
|
|
@@ -18,9 +14,9 @@ import AcksAPI from './acks';
|
|
|
18
14
|
// browsers can reject or drop oversized requests instead of making delivery
|
|
19
15
|
// more reliable. Keep the limit below that ceiling so the SDK only opts in when
|
|
20
16
|
// the payload is small enough for the keepalive transport contract.
|
|
21
|
-
|
|
17
|
+
const KEEPALIVE_BODY_LIMIT = 60000;
|
|
22
18
|
function keepaliveFor(body) {
|
|
23
|
-
|
|
19
|
+
const serializedBody = JSON.stringify(body);
|
|
24
20
|
|
|
25
21
|
// Use byte size when the runtime exposes Blob because non-ASCII JSON can be
|
|
26
22
|
// larger on the wire than its JavaScript string length. The string-length
|
|
@@ -31,48 +27,31 @@ function keepaliveFor(body) {
|
|
|
31
27
|
}
|
|
32
28
|
return new Blob([serializedBody]).size < KEEPALIVE_BODY_LIMIT;
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
export default class API {
|
|
31
|
+
static get businesses() {
|
|
32
|
+
return BusinessesAPI;
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get: function get() {
|
|
61
|
-
return WhatsAppWidgetsAPI;
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "identifications",
|
|
65
|
-
get: function get() {
|
|
66
|
-
return IdentificationsAPI;
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "acks",
|
|
70
|
-
get: function get() {
|
|
71
|
-
return AcksAPI;
|
|
72
|
-
}
|
|
73
|
-
}]);
|
|
74
|
-
return API;
|
|
75
|
-
}();
|
|
76
|
-
export { API as default };
|
|
34
|
+
static get events() {
|
|
35
|
+
return EventsAPI;
|
|
36
|
+
}
|
|
37
|
+
static get forms() {
|
|
38
|
+
return FormsAPI;
|
|
39
|
+
}
|
|
40
|
+
static get webchats() {
|
|
41
|
+
return WebchatsAPI;
|
|
42
|
+
}
|
|
43
|
+
static get whatsappWidgets() {
|
|
44
|
+
return WhatsAppWidgetsAPI;
|
|
45
|
+
}
|
|
46
|
+
static get identifications() {
|
|
47
|
+
return IdentificationsAPI;
|
|
48
|
+
}
|
|
49
|
+
static get acks() {
|
|
50
|
+
return AcksAPI;
|
|
51
|
+
}
|
|
52
|
+
static get pushIdentities() {
|
|
53
|
+
return PushIdentitiesAPI;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
77
56
|
export { Response } from './response';
|
|
78
57
|
export { keepaliveFor };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _hellotext = _interopRequireDefault(require("../../hellotext"));
|
|
8
|
+
var _core = require("../../core");
|
|
9
|
+
var _response = require("../response");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
class PushIdentitiesAPI {
|
|
12
|
+
static get endpoint() {
|
|
13
|
+
return _core.Configuration.endpoint('public/push/identities');
|
|
14
|
+
}
|
|
15
|
+
static async create(data = {}) {
|
|
16
|
+
const response = await fetch(this.endpoint, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
keepalive: true,
|
|
19
|
+
headers: _hellotext.default.headers,
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
...data,
|
|
22
|
+
session: _hellotext.default.session,
|
|
23
|
+
origin: window.location.origin
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
return new _response.Response(response.ok, response);
|
|
27
|
+
}
|
|
28
|
+
static async destroy(data = {}) {
|
|
29
|
+
const response = await fetch(this.endpoint, {
|
|
30
|
+
method: 'DELETE',
|
|
31
|
+
keepalive: true,
|
|
32
|
+
headers: _hellotext.default.headers,
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
...data,
|
|
35
|
+
session: _hellotext.default.session,
|
|
36
|
+
origin: window.location.origin
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
return new _response.Response(response.ok, response);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var _default = PushIdentitiesAPI;
|
|
43
|
+
exports.default = _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Hellotext from '../../hellotext';
|
|
2
|
+
import { Configuration } from '../../core';
|
|
3
|
+
import { Response } from '../response';
|
|
4
|
+
class PushIdentitiesAPI {
|
|
5
|
+
static get endpoint() {
|
|
6
|
+
return Configuration.endpoint('public/push/identities');
|
|
7
|
+
}
|
|
8
|
+
static async create(data = {}) {
|
|
9
|
+
const response = await fetch(this.endpoint, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
keepalive: true,
|
|
12
|
+
headers: Hellotext.headers,
|
|
13
|
+
body: JSON.stringify({
|
|
14
|
+
...data,
|
|
15
|
+
session: Hellotext.session,
|
|
16
|
+
origin: window.location.origin
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
return new Response(response.ok, response);
|
|
20
|
+
}
|
|
21
|
+
static async destroy(data = {}) {
|
|
22
|
+
const response = await fetch(this.endpoint, {
|
|
23
|
+
method: 'DELETE',
|
|
24
|
+
keepalive: true,
|
|
25
|
+
headers: Hellotext.headers,
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
...data,
|
|
28
|
+
session: Hellotext.session,
|
|
29
|
+
origin: window.location.origin
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
return new Response(response.ok, response);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default PushIdentitiesAPI;
|
package/lib/api/response.cjs
CHANGED
|
@@ -4,15 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Response = void 0;
|
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
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); } }
|
|
9
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
-
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); }
|
|
12
|
-
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
|
|
13
|
-
var id = 0;
|
|
14
|
-
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
|
|
15
|
-
var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
|
|
16
7
|
/**
|
|
17
8
|
* Response class
|
|
18
9
|
* @class
|
|
@@ -20,57 +11,44 @@ var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
|
|
|
20
11
|
* @property {Boolean} succeeded
|
|
21
12
|
* @property {Object} data
|
|
22
13
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
writable: true,
|
|
28
|
-
value: void 0
|
|
29
|
-
});
|
|
14
|
+
|
|
15
|
+
class Response {
|
|
16
|
+
#success;
|
|
17
|
+
constructor(success, response) {
|
|
30
18
|
this.response = response;
|
|
31
|
-
|
|
19
|
+
this.#success = success;
|
|
32
20
|
}
|
|
33
21
|
|
|
34
22
|
/**
|
|
35
23
|
* Get the response data
|
|
36
24
|
* @returns {*}
|
|
37
25
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return this.response;
|
|
42
|
-
}
|
|
26
|
+
get data() {
|
|
27
|
+
return this.response;
|
|
28
|
+
}
|
|
43
29
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return await this.response.json();
|
|
52
|
-
}
|
|
30
|
+
/**
|
|
31
|
+
* Parse the response as JSON
|
|
32
|
+
* @returns {Promise<*>}
|
|
33
|
+
*/
|
|
34
|
+
async json() {
|
|
35
|
+
return await this.response.json();
|
|
36
|
+
}
|
|
53
37
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return _classPrivateFieldLooseBase(this, _success)[_success] === false;
|
|
62
|
-
}
|
|
38
|
+
/**
|
|
39
|
+
* Has the request failed?
|
|
40
|
+
* @returns {boolean}
|
|
41
|
+
*/
|
|
42
|
+
get failed() {
|
|
43
|
+
return this.#success === false;
|
|
44
|
+
}
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
}]);
|
|
74
|
-
return Response;
|
|
75
|
-
}();
|
|
46
|
+
/**
|
|
47
|
+
* Has the request succeeded?
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
get succeeded() {
|
|
51
|
+
return this.#success === true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
76
54
|
exports.Response = Response;
|
package/lib/api/response.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
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
|
-
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
|
|
9
|
-
var id = 0;
|
|
10
|
-
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
|
|
11
|
-
var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
|
|
12
1
|
/**
|
|
13
2
|
* Response class
|
|
14
3
|
* @class
|
|
@@ -16,62 +5,44 @@ var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
|
|
|
16
5
|
* @property {Boolean} succeeded
|
|
17
6
|
* @property {Object} data
|
|
18
7
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
writable: true,
|
|
24
|
-
value: void 0
|
|
25
|
-
});
|
|
8
|
+
|
|
9
|
+
class Response {
|
|
10
|
+
#success;
|
|
11
|
+
constructor(success, response) {
|
|
26
12
|
this.response = response;
|
|
27
|
-
|
|
13
|
+
this.#success = success;
|
|
28
14
|
}
|
|
29
15
|
|
|
30
16
|
/**
|
|
31
17
|
* Get the response data
|
|
32
18
|
* @returns {*}
|
|
33
19
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
get data() {
|
|
21
|
+
return this.response;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Parse the response as JSON
|
|
26
|
+
* @returns {Promise<*>}
|
|
27
|
+
*/
|
|
28
|
+
async json() {
|
|
29
|
+
return await this.response.json();
|
|
30
|
+
}
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var _json = _asyncToGenerator(function* () {
|
|
48
|
-
return yield this.response.json();
|
|
49
|
-
});
|
|
50
|
-
function json() {
|
|
51
|
-
return _json.apply(this, arguments);
|
|
52
|
-
}
|
|
53
|
-
return json;
|
|
54
|
-
}()
|
|
55
|
-
/**
|
|
56
|
-
* Has the request failed?
|
|
57
|
-
* @returns {boolean}
|
|
58
|
-
*/
|
|
59
|
-
}, {
|
|
60
|
-
key: "failed",
|
|
61
|
-
get: function get() {
|
|
62
|
-
return _classPrivateFieldLooseBase(this, _success)[_success] === false;
|
|
63
|
-
}
|
|
32
|
+
/**
|
|
33
|
+
* Has the request failed?
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
get failed() {
|
|
37
|
+
return this.#success === false;
|
|
38
|
+
}
|
|
64
39
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}]);
|
|
75
|
-
return Response;
|
|
76
|
-
}();
|
|
40
|
+
/**
|
|
41
|
+
* Has the request succeeded?
|
|
42
|
+
* @returns {boolean}
|
|
43
|
+
*/
|
|
44
|
+
get succeeded() {
|
|
45
|
+
return this.#success === true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
77
48
|
export { Response };
|