@bentonow/bento-node-sdk 0.2.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE → LICENSE.md} +1 -1
- package/README.md +496 -1077
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1273 -5
- package/dist/sdk/batch/enums.d.ts +8 -8
- package/dist/sdk/batch/errors.d.ts +18 -18
- package/dist/sdk/batch/events.d.ts +71 -71
- package/dist/sdk/batch/index.d.ts +55 -55
- package/dist/sdk/batch/types.d.ts +37 -37
- package/dist/sdk/broadcasts/index.d.ts +25 -0
- package/dist/sdk/broadcasts/types.d.ts +28 -0
- package/dist/sdk/client/errors.d.ts +9 -6
- package/dist/sdk/client/index.d.ts +74 -64
- package/dist/sdk/client/types.d.ts +3 -3
- package/dist/sdk/commands/enums.d.ts +12 -12
- package/dist/sdk/commands/index.d.ts +79 -79
- package/dist/sdk/commands/types.d.ts +32 -32
- package/dist/sdk/email-templates/index.d.ts +21 -0
- package/dist/sdk/email-templates/types.d.ts +23 -0
- package/dist/sdk/enums.d.ts +12 -9
- package/dist/sdk/errors.d.ts +2 -2
- package/dist/sdk/experimental/index.d.ts +75 -57
- package/dist/sdk/experimental/types.d.ts +71 -41
- package/dist/sdk/fields/index.d.ts +29 -29
- package/dist/sdk/fields/types.d.ts +17 -17
- package/dist/sdk/forms/index.d.ts +14 -14
- package/dist/sdk/forms/types.d.ts +28 -28
- package/dist/sdk/index.d.ts +11 -8
- package/dist/sdk/interfaces.d.ts +13 -13
- package/dist/sdk/sequences/index.d.ts +13 -0
- package/dist/sdk/sequences/types.d.ts +18 -0
- package/dist/sdk/stats/index.d.ts +24 -0
- package/dist/sdk/stats/types.d.ts +26 -0
- package/dist/sdk/subscribers/index.d.ts +20 -20
- package/dist/sdk/subscribers/types.d.ts +25 -25
- package/dist/sdk/tags/index.d.ts +20 -20
- package/dist/sdk/tags/types.d.ts +17 -17
- package/dist/sdk/types.d.ts +41 -41
- package/dist/sdk/workflows/index.d.ts +13 -0
- package/dist/sdk/workflows/types.d.ts +18 -0
- package/dist/versions/v1/index.d.ts +164 -132
- package/dist/versions/v1/types.d.ts +31 -31
- package/package.json +30 -43
- package/src/sdk/batch/events.ts +1 -1
- package/src/sdk/batch/index.ts +13 -25
- package/src/sdk/broadcasts/index.ts +43 -0
- package/src/sdk/broadcasts/types.ts +34 -0
- package/src/sdk/client/errors.ts +7 -0
- package/src/sdk/client/index.ts +108 -25
- package/src/sdk/commands/index.ts +54 -89
- package/src/sdk/email-templates/index.ts +39 -0
- package/src/sdk/email-templates/types.ts +27 -0
- package/src/sdk/enums.ts +3 -0
- package/src/sdk/experimental/index.ts +44 -26
- package/src/sdk/experimental/types.ts +35 -0
- package/src/sdk/fields/index.ts +1 -3
- package/src/sdk/forms/index.ts +4 -9
- package/src/sdk/forms/types.ts +1 -7
- package/src/sdk/index.ts +3 -0
- package/src/sdk/sequences/index.ts +21 -0
- package/src/sdk/sequences/types.ts +21 -0
- package/src/sdk/stats/index.ts +37 -0
- package/src/sdk/stats/types.ts +28 -0
- package/src/sdk/subscribers/index.ts +5 -15
- package/src/sdk/tags/index.ts +1 -3
- package/src/sdk/types.ts +1 -1
- package/src/sdk/workflows/index.ts +21 -0
- package/src/sdk/workflows/types.ts +21 -0
- package/src/versions/v1/index.ts +59 -10
- package/dist/bento-node-sdk.cjs.development.js +0 -2943
- package/dist/bento-node-sdk.cjs.development.js.map +0 -1
- package/dist/bento-node-sdk.cjs.production.min.js +0 -2
- package/dist/bento-node-sdk.cjs.production.min.js.map +0 -1
- package/dist/bento-node-sdk.esm.js +0 -2935
- package/dist/bento-node-sdk.esm.js.map +0 -1
|
@@ -1,2943 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var fetch = _interopDefault(require('isomorphic-fetch'));
|
|
8
|
-
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
-
try {
|
|
11
|
-
var info = gen[key](arg);
|
|
12
|
-
var value = info.value;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
reject(error);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (info.done) {
|
|
19
|
-
resolve(value);
|
|
20
|
-
} else {
|
|
21
|
-
Promise.resolve(value).then(_next, _throw);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function _asyncToGenerator(fn) {
|
|
26
|
-
return function () {
|
|
27
|
-
var self = this,
|
|
28
|
-
args = arguments;
|
|
29
|
-
return new Promise(function (resolve, reject) {
|
|
30
|
-
var gen = fn.apply(self, args);
|
|
31
|
-
|
|
32
|
-
function _next(value) {
|
|
33
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function _throw(err) {
|
|
37
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
_next(undefined);
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function _extends() {
|
|
46
|
-
_extends = Object.assign || function (target) {
|
|
47
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
-
var source = arguments[i];
|
|
49
|
-
|
|
50
|
-
for (var key in source) {
|
|
51
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
52
|
-
target[key] = source[key];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return target;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return _extends.apply(this, arguments);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _inheritsLoose(subClass, superClass) {
|
|
64
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
65
|
-
subClass.prototype.constructor = subClass;
|
|
66
|
-
|
|
67
|
-
_setPrototypeOf(subClass, superClass);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _getPrototypeOf(o) {
|
|
71
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
72
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
73
|
-
};
|
|
74
|
-
return _getPrototypeOf(o);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function _setPrototypeOf(o, p) {
|
|
78
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
79
|
-
o.__proto__ = p;
|
|
80
|
-
return o;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return _setPrototypeOf(o, p);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function _isNativeReflectConstruct() {
|
|
87
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
88
|
-
if (Reflect.construct.sham) return false;
|
|
89
|
-
if (typeof Proxy === "function") return true;
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
93
|
-
return true;
|
|
94
|
-
} catch (e) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function _construct(Parent, args, Class) {
|
|
100
|
-
if (_isNativeReflectConstruct()) {
|
|
101
|
-
_construct = Reflect.construct;
|
|
102
|
-
} else {
|
|
103
|
-
_construct = function _construct(Parent, args, Class) {
|
|
104
|
-
var a = [null];
|
|
105
|
-
a.push.apply(a, args);
|
|
106
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
107
|
-
var instance = new Constructor();
|
|
108
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
109
|
-
return instance;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return _construct.apply(null, arguments);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function _isNativeFunction(fn) {
|
|
117
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function _wrapNativeSuper(Class) {
|
|
121
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
122
|
-
|
|
123
|
-
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
124
|
-
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
125
|
-
|
|
126
|
-
if (typeof Class !== "function") {
|
|
127
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (typeof _cache !== "undefined") {
|
|
131
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
132
|
-
|
|
133
|
-
_cache.set(Class, Wrapper);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function Wrapper() {
|
|
137
|
-
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
141
|
-
constructor: {
|
|
142
|
-
value: Wrapper,
|
|
143
|
-
enumerable: false,
|
|
144
|
-
writable: true,
|
|
145
|
-
configurable: true
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
return _setPrototypeOf(Wrapper, Class);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return _wrapNativeSuper(Class);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function createCommonjsModule(fn, module) {
|
|
155
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
var runtime_1 = createCommonjsModule(function (module) {
|
|
159
|
-
/**
|
|
160
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
161
|
-
*
|
|
162
|
-
* This source code is licensed under the MIT license found in the
|
|
163
|
-
* LICENSE file in the root directory of this source tree.
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
var runtime = (function (exports) {
|
|
167
|
-
|
|
168
|
-
var Op = Object.prototype;
|
|
169
|
-
var hasOwn = Op.hasOwnProperty;
|
|
170
|
-
var undefined$1; // More compressible than void 0.
|
|
171
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
172
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
173
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
174
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
175
|
-
|
|
176
|
-
function define(obj, key, value) {
|
|
177
|
-
Object.defineProperty(obj, key, {
|
|
178
|
-
value: value,
|
|
179
|
-
enumerable: true,
|
|
180
|
-
configurable: true,
|
|
181
|
-
writable: true
|
|
182
|
-
});
|
|
183
|
-
return obj[key];
|
|
184
|
-
}
|
|
185
|
-
try {
|
|
186
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
187
|
-
define({}, "");
|
|
188
|
-
} catch (err) {
|
|
189
|
-
define = function(obj, key, value) {
|
|
190
|
-
return obj[key] = value;
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
195
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
196
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
197
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
198
|
-
var context = new Context(tryLocsList || []);
|
|
199
|
-
|
|
200
|
-
// The ._invoke method unifies the implementations of the .next,
|
|
201
|
-
// .throw, and .return methods.
|
|
202
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
203
|
-
|
|
204
|
-
return generator;
|
|
205
|
-
}
|
|
206
|
-
exports.wrap = wrap;
|
|
207
|
-
|
|
208
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
209
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
210
|
-
// have been (and was previously) designed to take a closure to be
|
|
211
|
-
// invoked without arguments, but in all the cases we care about we
|
|
212
|
-
// already have an existing method we want to call, so there's no need
|
|
213
|
-
// to create a new function object. We can even get away with assuming
|
|
214
|
-
// the method takes exactly one argument, since that happens to be true
|
|
215
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
216
|
-
// only additional allocation required is the completion record, which
|
|
217
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
218
|
-
function tryCatch(fn, obj, arg) {
|
|
219
|
-
try {
|
|
220
|
-
return { type: "normal", arg: fn.call(obj, arg) };
|
|
221
|
-
} catch (err) {
|
|
222
|
-
return { type: "throw", arg: err };
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
227
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
228
|
-
var GenStateExecuting = "executing";
|
|
229
|
-
var GenStateCompleted = "completed";
|
|
230
|
-
|
|
231
|
-
// Returning this object from the innerFn has the same effect as
|
|
232
|
-
// breaking out of the dispatch switch statement.
|
|
233
|
-
var ContinueSentinel = {};
|
|
234
|
-
|
|
235
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
236
|
-
// .constructor.prototype properties for functions that return Generator
|
|
237
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
238
|
-
// minifier not to mangle the names of these two functions.
|
|
239
|
-
function Generator() {}
|
|
240
|
-
function GeneratorFunction() {}
|
|
241
|
-
function GeneratorFunctionPrototype() {}
|
|
242
|
-
|
|
243
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
244
|
-
// don't natively support it.
|
|
245
|
-
var IteratorPrototype = {};
|
|
246
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
247
|
-
return this;
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
var getProto = Object.getPrototypeOf;
|
|
251
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
252
|
-
if (NativeIteratorPrototype &&
|
|
253
|
-
NativeIteratorPrototype !== Op &&
|
|
254
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
255
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
256
|
-
// of the polyfill.
|
|
257
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
var Gp = GeneratorFunctionPrototype.prototype =
|
|
261
|
-
Generator.prototype = Object.create(IteratorPrototype);
|
|
262
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
263
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
264
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
265
|
-
GeneratorFunction.displayName = define(
|
|
266
|
-
GeneratorFunctionPrototype,
|
|
267
|
-
toStringTagSymbol,
|
|
268
|
-
"GeneratorFunction"
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
272
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
273
|
-
function defineIteratorMethods(prototype) {
|
|
274
|
-
["next", "throw", "return"].forEach(function(method) {
|
|
275
|
-
define(prototype, method, function(arg) {
|
|
276
|
-
return this._invoke(method, arg);
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
exports.isGeneratorFunction = function(genFun) {
|
|
282
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
283
|
-
return ctor
|
|
284
|
-
? ctor === GeneratorFunction ||
|
|
285
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
286
|
-
// do is to check its .name property.
|
|
287
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
288
|
-
: false;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
exports.mark = function(genFun) {
|
|
292
|
-
if (Object.setPrototypeOf) {
|
|
293
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
294
|
-
} else {
|
|
295
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
296
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
297
|
-
}
|
|
298
|
-
genFun.prototype = Object.create(Gp);
|
|
299
|
-
return genFun;
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
// Within the body of any async function, `await x` is transformed to
|
|
303
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
304
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
305
|
-
// meant to be awaited.
|
|
306
|
-
exports.awrap = function(arg) {
|
|
307
|
-
return { __await: arg };
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
311
|
-
function invoke(method, arg, resolve, reject) {
|
|
312
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
313
|
-
if (record.type === "throw") {
|
|
314
|
-
reject(record.arg);
|
|
315
|
-
} else {
|
|
316
|
-
var result = record.arg;
|
|
317
|
-
var value = result.value;
|
|
318
|
-
if (value &&
|
|
319
|
-
typeof value === "object" &&
|
|
320
|
-
hasOwn.call(value, "__await")) {
|
|
321
|
-
return PromiseImpl.resolve(value.__await).then(function(value) {
|
|
322
|
-
invoke("next", value, resolve, reject);
|
|
323
|
-
}, function(err) {
|
|
324
|
-
invoke("throw", err, resolve, reject);
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
|
329
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
330
|
-
// the .value of the Promise<{value,done}> result for the
|
|
331
|
-
// current iteration.
|
|
332
|
-
result.value = unwrapped;
|
|
333
|
-
resolve(result);
|
|
334
|
-
}, function(error) {
|
|
335
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
336
|
-
// into the async generator function so it can be handled there.
|
|
337
|
-
return invoke("throw", error, resolve, reject);
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
var previousPromise;
|
|
343
|
-
|
|
344
|
-
function enqueue(method, arg) {
|
|
345
|
-
function callInvokeWithMethodAndArg() {
|
|
346
|
-
return new PromiseImpl(function(resolve, reject) {
|
|
347
|
-
invoke(method, arg, resolve, reject);
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return previousPromise =
|
|
352
|
-
// If enqueue has been called before, then we want to wait until
|
|
353
|
-
// all previous Promises have been resolved before calling invoke,
|
|
354
|
-
// so that results are always delivered in the correct order. If
|
|
355
|
-
// enqueue has not been called before, then it is important to
|
|
356
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
357
|
-
// so that the async generator function has the opportunity to do
|
|
358
|
-
// any necessary setup in a predictable way. This predictability
|
|
359
|
-
// is why the Promise constructor synchronously invokes its
|
|
360
|
-
// executor callback, and why async functions synchronously
|
|
361
|
-
// execute code before the first await. Since we implement simple
|
|
362
|
-
// async functions in terms of async generators, it is especially
|
|
363
|
-
// important to get this right, even though it requires care.
|
|
364
|
-
previousPromise ? previousPromise.then(
|
|
365
|
-
callInvokeWithMethodAndArg,
|
|
366
|
-
// Avoid propagating failures to Promises returned by later
|
|
367
|
-
// invocations of the iterator.
|
|
368
|
-
callInvokeWithMethodAndArg
|
|
369
|
-
) : callInvokeWithMethodAndArg();
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// Define the unified helper method that is used to implement .next,
|
|
373
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
374
|
-
this._invoke = enqueue;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
378
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
379
|
-
return this;
|
|
380
|
-
});
|
|
381
|
-
exports.AsyncIterator = AsyncIterator;
|
|
382
|
-
|
|
383
|
-
// Note that simple async functions are implemented on top of
|
|
384
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
385
|
-
// the final result produced by the iterator.
|
|
386
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
387
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
388
|
-
|
|
389
|
-
var iter = new AsyncIterator(
|
|
390
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
391
|
-
PromiseImpl
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
return exports.isGeneratorFunction(outerFn)
|
|
395
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
396
|
-
: iter.next().then(function(result) {
|
|
397
|
-
return result.done ? result.value : iter.next();
|
|
398
|
-
});
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
402
|
-
var state = GenStateSuspendedStart;
|
|
403
|
-
|
|
404
|
-
return function invoke(method, arg) {
|
|
405
|
-
if (state === GenStateExecuting) {
|
|
406
|
-
throw new Error("Generator is already running");
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (state === GenStateCompleted) {
|
|
410
|
-
if (method === "throw") {
|
|
411
|
-
throw arg;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
415
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
416
|
-
return doneResult();
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
context.method = method;
|
|
420
|
-
context.arg = arg;
|
|
421
|
-
|
|
422
|
-
while (true) {
|
|
423
|
-
var delegate = context.delegate;
|
|
424
|
-
if (delegate) {
|
|
425
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
426
|
-
if (delegateResult) {
|
|
427
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
428
|
-
return delegateResult;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (context.method === "next") {
|
|
433
|
-
// Setting context._sent for legacy support of Babel's
|
|
434
|
-
// function.sent implementation.
|
|
435
|
-
context.sent = context._sent = context.arg;
|
|
436
|
-
|
|
437
|
-
} else if (context.method === "throw") {
|
|
438
|
-
if (state === GenStateSuspendedStart) {
|
|
439
|
-
state = GenStateCompleted;
|
|
440
|
-
throw context.arg;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
context.dispatchException(context.arg);
|
|
444
|
-
|
|
445
|
-
} else if (context.method === "return") {
|
|
446
|
-
context.abrupt("return", context.arg);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
state = GenStateExecuting;
|
|
450
|
-
|
|
451
|
-
var record = tryCatch(innerFn, self, context);
|
|
452
|
-
if (record.type === "normal") {
|
|
453
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
454
|
-
// GenStateExecuting and loop back for another invocation.
|
|
455
|
-
state = context.done
|
|
456
|
-
? GenStateCompleted
|
|
457
|
-
: GenStateSuspendedYield;
|
|
458
|
-
|
|
459
|
-
if (record.arg === ContinueSentinel) {
|
|
460
|
-
continue;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return {
|
|
464
|
-
value: record.arg,
|
|
465
|
-
done: context.done
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
} else if (record.type === "throw") {
|
|
469
|
-
state = GenStateCompleted;
|
|
470
|
-
// Dispatch the exception by looping back around to the
|
|
471
|
-
// context.dispatchException(context.arg) call above.
|
|
472
|
-
context.method = "throw";
|
|
473
|
-
context.arg = record.arg;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
480
|
-
// result, either by returning a { value, done } result from the
|
|
481
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
482
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
483
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
484
|
-
var method = delegate.iterator[context.method];
|
|
485
|
-
if (method === undefined$1) {
|
|
486
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
487
|
-
// method always terminates the yield* loop.
|
|
488
|
-
context.delegate = null;
|
|
489
|
-
|
|
490
|
-
if (context.method === "throw") {
|
|
491
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
492
|
-
if (delegate.iterator["return"]) {
|
|
493
|
-
// If the delegate iterator has a return method, give it a
|
|
494
|
-
// chance to clean up.
|
|
495
|
-
context.method = "return";
|
|
496
|
-
context.arg = undefined$1;
|
|
497
|
-
maybeInvokeDelegate(delegate, context);
|
|
498
|
-
|
|
499
|
-
if (context.method === "throw") {
|
|
500
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
501
|
-
// "return" to "throw", let that override the TypeError below.
|
|
502
|
-
return ContinueSentinel;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
context.method = "throw";
|
|
507
|
-
context.arg = new TypeError(
|
|
508
|
-
"The iterator does not provide a 'throw' method");
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
return ContinueSentinel;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
515
|
-
|
|
516
|
-
if (record.type === "throw") {
|
|
517
|
-
context.method = "throw";
|
|
518
|
-
context.arg = record.arg;
|
|
519
|
-
context.delegate = null;
|
|
520
|
-
return ContinueSentinel;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
var info = record.arg;
|
|
524
|
-
|
|
525
|
-
if (! info) {
|
|
526
|
-
context.method = "throw";
|
|
527
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
528
|
-
context.delegate = null;
|
|
529
|
-
return ContinueSentinel;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (info.done) {
|
|
533
|
-
// Assign the result of the finished delegate to the temporary
|
|
534
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
535
|
-
context[delegate.resultName] = info.value;
|
|
536
|
-
|
|
537
|
-
// Resume execution at the desired location (see delegateYield).
|
|
538
|
-
context.next = delegate.nextLoc;
|
|
539
|
-
|
|
540
|
-
// If context.method was "throw" but the delegate handled the
|
|
541
|
-
// exception, let the outer generator proceed normally. If
|
|
542
|
-
// context.method was "next", forget context.arg since it has been
|
|
543
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
544
|
-
// "return", allow the original .return call to continue in the
|
|
545
|
-
// outer generator.
|
|
546
|
-
if (context.method !== "return") {
|
|
547
|
-
context.method = "next";
|
|
548
|
-
context.arg = undefined$1;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
} else {
|
|
552
|
-
// Re-yield the result returned by the delegate method.
|
|
553
|
-
return info;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
557
|
-
// the outer generator.
|
|
558
|
-
context.delegate = null;
|
|
559
|
-
return ContinueSentinel;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
563
|
-
// unified ._invoke helper method.
|
|
564
|
-
defineIteratorMethods(Gp);
|
|
565
|
-
|
|
566
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
567
|
-
|
|
568
|
-
// A Generator should always return itself as the iterator object when the
|
|
569
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
570
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
571
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
572
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
573
|
-
define(Gp, iteratorSymbol, function() {
|
|
574
|
-
return this;
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
define(Gp, "toString", function() {
|
|
578
|
-
return "[object Generator]";
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
function pushTryEntry(locs) {
|
|
582
|
-
var entry = { tryLoc: locs[0] };
|
|
583
|
-
|
|
584
|
-
if (1 in locs) {
|
|
585
|
-
entry.catchLoc = locs[1];
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
if (2 in locs) {
|
|
589
|
-
entry.finallyLoc = locs[2];
|
|
590
|
-
entry.afterLoc = locs[3];
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
this.tryEntries.push(entry);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
function resetTryEntry(entry) {
|
|
597
|
-
var record = entry.completion || {};
|
|
598
|
-
record.type = "normal";
|
|
599
|
-
delete record.arg;
|
|
600
|
-
entry.completion = record;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function Context(tryLocsList) {
|
|
604
|
-
// The root entry object (effectively a try statement without a catch
|
|
605
|
-
// or a finally block) gives us a place to store values thrown from
|
|
606
|
-
// locations where there is no enclosing try statement.
|
|
607
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
608
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
609
|
-
this.reset(true);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
exports.keys = function(object) {
|
|
613
|
-
var keys = [];
|
|
614
|
-
for (var key in object) {
|
|
615
|
-
keys.push(key);
|
|
616
|
-
}
|
|
617
|
-
keys.reverse();
|
|
618
|
-
|
|
619
|
-
// Rather than returning an object with a next method, we keep
|
|
620
|
-
// things simple and return the next function itself.
|
|
621
|
-
return function next() {
|
|
622
|
-
while (keys.length) {
|
|
623
|
-
var key = keys.pop();
|
|
624
|
-
if (key in object) {
|
|
625
|
-
next.value = key;
|
|
626
|
-
next.done = false;
|
|
627
|
-
return next;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// To avoid creating an additional object, we just hang the .value
|
|
632
|
-
// and .done properties off the next function object itself. This
|
|
633
|
-
// also ensures that the minifier will not anonymize the function.
|
|
634
|
-
next.done = true;
|
|
635
|
-
return next;
|
|
636
|
-
};
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
function values(iterable) {
|
|
640
|
-
if (iterable) {
|
|
641
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
642
|
-
if (iteratorMethod) {
|
|
643
|
-
return iteratorMethod.call(iterable);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
if (typeof iterable.next === "function") {
|
|
647
|
-
return iterable;
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
if (!isNaN(iterable.length)) {
|
|
651
|
-
var i = -1, next = function next() {
|
|
652
|
-
while (++i < iterable.length) {
|
|
653
|
-
if (hasOwn.call(iterable, i)) {
|
|
654
|
-
next.value = iterable[i];
|
|
655
|
-
next.done = false;
|
|
656
|
-
return next;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
next.value = undefined$1;
|
|
661
|
-
next.done = true;
|
|
662
|
-
|
|
663
|
-
return next;
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
return next.next = next;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
// Return an iterator with no values.
|
|
671
|
-
return { next: doneResult };
|
|
672
|
-
}
|
|
673
|
-
exports.values = values;
|
|
674
|
-
|
|
675
|
-
function doneResult() {
|
|
676
|
-
return { value: undefined$1, done: true };
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
Context.prototype = {
|
|
680
|
-
constructor: Context,
|
|
681
|
-
|
|
682
|
-
reset: function(skipTempReset) {
|
|
683
|
-
this.prev = 0;
|
|
684
|
-
this.next = 0;
|
|
685
|
-
// Resetting context._sent for legacy support of Babel's
|
|
686
|
-
// function.sent implementation.
|
|
687
|
-
this.sent = this._sent = undefined$1;
|
|
688
|
-
this.done = false;
|
|
689
|
-
this.delegate = null;
|
|
690
|
-
|
|
691
|
-
this.method = "next";
|
|
692
|
-
this.arg = undefined$1;
|
|
693
|
-
|
|
694
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
695
|
-
|
|
696
|
-
if (!skipTempReset) {
|
|
697
|
-
for (var name in this) {
|
|
698
|
-
// Not sure about the optimal order of these conditions:
|
|
699
|
-
if (name.charAt(0) === "t" &&
|
|
700
|
-
hasOwn.call(this, name) &&
|
|
701
|
-
!isNaN(+name.slice(1))) {
|
|
702
|
-
this[name] = undefined$1;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
},
|
|
707
|
-
|
|
708
|
-
stop: function() {
|
|
709
|
-
this.done = true;
|
|
710
|
-
|
|
711
|
-
var rootEntry = this.tryEntries[0];
|
|
712
|
-
var rootRecord = rootEntry.completion;
|
|
713
|
-
if (rootRecord.type === "throw") {
|
|
714
|
-
throw rootRecord.arg;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
return this.rval;
|
|
718
|
-
},
|
|
719
|
-
|
|
720
|
-
dispatchException: function(exception) {
|
|
721
|
-
if (this.done) {
|
|
722
|
-
throw exception;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
var context = this;
|
|
726
|
-
function handle(loc, caught) {
|
|
727
|
-
record.type = "throw";
|
|
728
|
-
record.arg = exception;
|
|
729
|
-
context.next = loc;
|
|
730
|
-
|
|
731
|
-
if (caught) {
|
|
732
|
-
// If the dispatched exception was caught by a catch block,
|
|
733
|
-
// then let that catch block handle the exception normally.
|
|
734
|
-
context.method = "next";
|
|
735
|
-
context.arg = undefined$1;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
return !! caught;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
742
|
-
var entry = this.tryEntries[i];
|
|
743
|
-
var record = entry.completion;
|
|
744
|
-
|
|
745
|
-
if (entry.tryLoc === "root") {
|
|
746
|
-
// Exception thrown outside of any try block that could handle
|
|
747
|
-
// it, so set the completion value of the entire function to
|
|
748
|
-
// throw the exception.
|
|
749
|
-
return handle("end");
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
if (entry.tryLoc <= this.prev) {
|
|
753
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
754
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
755
|
-
|
|
756
|
-
if (hasCatch && hasFinally) {
|
|
757
|
-
if (this.prev < entry.catchLoc) {
|
|
758
|
-
return handle(entry.catchLoc, true);
|
|
759
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
760
|
-
return handle(entry.finallyLoc);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
} else if (hasCatch) {
|
|
764
|
-
if (this.prev < entry.catchLoc) {
|
|
765
|
-
return handle(entry.catchLoc, true);
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
} else if (hasFinally) {
|
|
769
|
-
if (this.prev < entry.finallyLoc) {
|
|
770
|
-
return handle(entry.finallyLoc);
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
} else {
|
|
774
|
-
throw new Error("try statement without catch or finally");
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
},
|
|
779
|
-
|
|
780
|
-
abrupt: function(type, arg) {
|
|
781
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
782
|
-
var entry = this.tryEntries[i];
|
|
783
|
-
if (entry.tryLoc <= this.prev &&
|
|
784
|
-
hasOwn.call(entry, "finallyLoc") &&
|
|
785
|
-
this.prev < entry.finallyLoc) {
|
|
786
|
-
var finallyEntry = entry;
|
|
787
|
-
break;
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
if (finallyEntry &&
|
|
792
|
-
(type === "break" ||
|
|
793
|
-
type === "continue") &&
|
|
794
|
-
finallyEntry.tryLoc <= arg &&
|
|
795
|
-
arg <= finallyEntry.finallyLoc) {
|
|
796
|
-
// Ignore the finally entry if control is not jumping to a
|
|
797
|
-
// location outside the try/catch block.
|
|
798
|
-
finallyEntry = null;
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
802
|
-
record.type = type;
|
|
803
|
-
record.arg = arg;
|
|
804
|
-
|
|
805
|
-
if (finallyEntry) {
|
|
806
|
-
this.method = "next";
|
|
807
|
-
this.next = finallyEntry.finallyLoc;
|
|
808
|
-
return ContinueSentinel;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
return this.complete(record);
|
|
812
|
-
},
|
|
813
|
-
|
|
814
|
-
complete: function(record, afterLoc) {
|
|
815
|
-
if (record.type === "throw") {
|
|
816
|
-
throw record.arg;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
if (record.type === "break" ||
|
|
820
|
-
record.type === "continue") {
|
|
821
|
-
this.next = record.arg;
|
|
822
|
-
} else if (record.type === "return") {
|
|
823
|
-
this.rval = this.arg = record.arg;
|
|
824
|
-
this.method = "return";
|
|
825
|
-
this.next = "end";
|
|
826
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
827
|
-
this.next = afterLoc;
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
return ContinueSentinel;
|
|
831
|
-
},
|
|
832
|
-
|
|
833
|
-
finish: function(finallyLoc) {
|
|
834
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
835
|
-
var entry = this.tryEntries[i];
|
|
836
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
837
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
838
|
-
resetTryEntry(entry);
|
|
839
|
-
return ContinueSentinel;
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
},
|
|
843
|
-
|
|
844
|
-
"catch": function(tryLoc) {
|
|
845
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
846
|
-
var entry = this.tryEntries[i];
|
|
847
|
-
if (entry.tryLoc === tryLoc) {
|
|
848
|
-
var record = entry.completion;
|
|
849
|
-
if (record.type === "throw") {
|
|
850
|
-
var thrown = record.arg;
|
|
851
|
-
resetTryEntry(entry);
|
|
852
|
-
}
|
|
853
|
-
return thrown;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// The context.catch method must only be called with a location
|
|
858
|
-
// argument that corresponds to a known catch block.
|
|
859
|
-
throw new Error("illegal catch attempt");
|
|
860
|
-
},
|
|
861
|
-
|
|
862
|
-
delegateYield: function(iterable, resultName, nextLoc) {
|
|
863
|
-
this.delegate = {
|
|
864
|
-
iterator: values(iterable),
|
|
865
|
-
resultName: resultName,
|
|
866
|
-
nextLoc: nextLoc
|
|
867
|
-
};
|
|
868
|
-
|
|
869
|
-
if (this.method === "next") {
|
|
870
|
-
// Deliberately forget the last sent value so that we don't
|
|
871
|
-
// accidentally pass it on to the delegate.
|
|
872
|
-
this.arg = undefined$1;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
return ContinueSentinel;
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
|
|
879
|
-
// Regardless of whether this script is executing as a CommonJS module
|
|
880
|
-
// or not, return the runtime object so that we can declare the variable
|
|
881
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
882
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
883
|
-
return exports;
|
|
884
|
-
|
|
885
|
-
}(
|
|
886
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
887
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
888
|
-
// object. Either way, the resulting object will be used to initialize
|
|
889
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
890
|
-
module.exports
|
|
891
|
-
));
|
|
892
|
-
|
|
893
|
-
try {
|
|
894
|
-
regeneratorRuntime = runtime;
|
|
895
|
-
} catch (accidentalStrictMode) {
|
|
896
|
-
// This module should not be running in strict mode, so the above
|
|
897
|
-
// assignment should always work unless something is misconfigured. Just
|
|
898
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
899
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
900
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
901
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
902
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
903
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
904
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
905
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
906
|
-
if (typeof globalThis === "object") {
|
|
907
|
-
globalThis.regeneratorRuntime = runtime;
|
|
908
|
-
} else {
|
|
909
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
var TooFewSubscribersError = /*#__PURE__*/function (_Error) {
|
|
915
|
-
_inheritsLoose(TooFewSubscribersError, _Error);
|
|
916
|
-
|
|
917
|
-
function TooFewSubscribersError(message) {
|
|
918
|
-
var _this;
|
|
919
|
-
|
|
920
|
-
if (message === void 0) {
|
|
921
|
-
message = 'Too few subscribers';
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
_this = _Error.call(this, message) || this;
|
|
925
|
-
_this.name = 'TooFewSubscribersError';
|
|
926
|
-
return _this;
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
return TooFewSubscribersError;
|
|
930
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
931
|
-
var TooManySubscribersError = /*#__PURE__*/function (_Error2) {
|
|
932
|
-
_inheritsLoose(TooManySubscribersError, _Error2);
|
|
933
|
-
|
|
934
|
-
function TooManySubscribersError(message) {
|
|
935
|
-
var _this2;
|
|
936
|
-
|
|
937
|
-
if (message === void 0) {
|
|
938
|
-
message = 'Too many subscribers';
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
_this2 = _Error2.call(this, message) || this;
|
|
942
|
-
_this2.name = 'TooManySubscribersError';
|
|
943
|
-
return _this2;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
return TooManySubscribersError;
|
|
947
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
948
|
-
var TooFewEventsError = /*#__PURE__*/function (_Error3) {
|
|
949
|
-
_inheritsLoose(TooFewEventsError, _Error3);
|
|
950
|
-
|
|
951
|
-
function TooFewEventsError(message) {
|
|
952
|
-
var _this3;
|
|
953
|
-
|
|
954
|
-
if (message === void 0) {
|
|
955
|
-
message = 'Too few events';
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
_this3 = _Error3.call(this, message) || this;
|
|
959
|
-
_this3.name = 'TooFewEventsError';
|
|
960
|
-
return _this3;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
return TooFewEventsError;
|
|
964
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
965
|
-
var TooManyEventsError = /*#__PURE__*/function (_Error4) {
|
|
966
|
-
_inheritsLoose(TooManyEventsError, _Error4);
|
|
967
|
-
|
|
968
|
-
function TooManyEventsError(message) {
|
|
969
|
-
var _this4;
|
|
970
|
-
|
|
971
|
-
if (message === void 0) {
|
|
972
|
-
message = 'Too many events';
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
_this4 = _Error4.call(this, message) || this;
|
|
976
|
-
_this4.name = 'TooManyEventsError';
|
|
977
|
-
return _this4;
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
return TooManyEventsError;
|
|
981
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
982
|
-
var TooFewEmailsError = /*#__PURE__*/function (_Error5) {
|
|
983
|
-
_inheritsLoose(TooFewEmailsError, _Error5);
|
|
984
|
-
|
|
985
|
-
function TooFewEmailsError(message) {
|
|
986
|
-
var _this5;
|
|
987
|
-
|
|
988
|
-
if (message === void 0) {
|
|
989
|
-
message = 'Too few emails';
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
_this5 = _Error5.call(this, message) || this;
|
|
993
|
-
_this5.name = 'TooFewEmailsError';
|
|
994
|
-
return _this5;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
return TooFewEmailsError;
|
|
998
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
999
|
-
var TooManyEmailsError = /*#__PURE__*/function (_Error6) {
|
|
1000
|
-
_inheritsLoose(TooManyEmailsError, _Error6);
|
|
1001
|
-
|
|
1002
|
-
function TooManyEmailsError(message) {
|
|
1003
|
-
var _this6;
|
|
1004
|
-
|
|
1005
|
-
if (message === void 0) {
|
|
1006
|
-
message = 'Too many emails';
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
_this6 = _Error6.call(this, message) || this;
|
|
1010
|
-
_this6.name = 'TooManyEmailsError';
|
|
1011
|
-
return _this6;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
return TooManyEmailsError;
|
|
1015
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1016
|
-
|
|
1017
|
-
var BentoBatch = /*#__PURE__*/function () {
|
|
1018
|
-
function BentoBatch(_client) {
|
|
1019
|
-
this._client = void 0;
|
|
1020
|
-
this._maxEmailBatchSize = 100;
|
|
1021
|
-
this._maxBatchSize = 1000;
|
|
1022
|
-
this._url = '/batch';
|
|
1023
|
-
this._client = _client;
|
|
1024
|
-
}
|
|
1025
|
-
/**
|
|
1026
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please batch import
|
|
1027
|
-
* events with the type set to `BentoEvents.SUBSCRIBE`, or `$subscribe`. Note that the batch event import
|
|
1028
|
-
* cannot attach custom fields and will ignore everything except the email.
|
|
1029
|
-
*
|
|
1030
|
-
* Creates a batch job to import subscribers into the system. You can pass in
|
|
1031
|
-
* between 1 and 1,000 subscribers to import. Each subscriber must have an email,
|
|
1032
|
-
* and may optionally have any additional fields. The additional fields are added
|
|
1033
|
-
* as custom fields on the subscriber.
|
|
1034
|
-
*
|
|
1035
|
-
* This method is processed by the Bento import queues and it may take between 1 and
|
|
1036
|
-
* 5 minutes for the results to appear in your dashboard.
|
|
1037
|
-
*
|
|
1038
|
-
* Returns the number of subscribers that were imported.
|
|
1039
|
-
*
|
|
1040
|
-
* @param parameters
|
|
1041
|
-
* @returns Promise\<number\>
|
|
1042
|
-
*/
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
var _proto = BentoBatch.prototype;
|
|
1046
|
-
|
|
1047
|
-
_proto.importSubscribers =
|
|
1048
|
-
/*#__PURE__*/
|
|
1049
|
-
function () {
|
|
1050
|
-
var _importSubscribers = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(parameters) {
|
|
1051
|
-
var result;
|
|
1052
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1053
|
-
while (1) {
|
|
1054
|
-
switch (_context.prev = _context.next) {
|
|
1055
|
-
case 0:
|
|
1056
|
-
if (!(parameters.subscribers.length === 0)) {
|
|
1057
|
-
_context.next = 2;
|
|
1058
|
-
break;
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
throw new TooFewSubscribersError("You must send between 1 and 1,000 subscribers.");
|
|
1062
|
-
|
|
1063
|
-
case 2:
|
|
1064
|
-
if (!(parameters.subscribers.length > this._maxBatchSize)) {
|
|
1065
|
-
_context.next = 4;
|
|
1066
|
-
break;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
throw new TooManySubscribersError("You must send between 1 and 1,000 subscribers.");
|
|
1070
|
-
|
|
1071
|
-
case 4:
|
|
1072
|
-
_context.next = 6;
|
|
1073
|
-
return this._client.post(this._url + "/subscribers", {
|
|
1074
|
-
subscribers: parameters.subscribers
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
case 6:
|
|
1078
|
-
result = _context.sent;
|
|
1079
|
-
return _context.abrupt("return", result.results);
|
|
1080
|
-
|
|
1081
|
-
case 8:
|
|
1082
|
-
case "end":
|
|
1083
|
-
return _context.stop();
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
}, _callee, this);
|
|
1087
|
-
}));
|
|
1088
|
-
|
|
1089
|
-
function importSubscribers(_x) {
|
|
1090
|
-
return _importSubscribers.apply(this, arguments);
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
return importSubscribers;
|
|
1094
|
-
}()
|
|
1095
|
-
/**
|
|
1096
|
-
* Creates a batch job to import events into the system. You can pass in
|
|
1097
|
-
* between 1 and 1,000 events to import. Each event must have an email and
|
|
1098
|
-
* a type. In addition to this, you my pass in additional data in the
|
|
1099
|
-
* `details` property.
|
|
1100
|
-
*
|
|
1101
|
-
* Returns the number of events that were imported.
|
|
1102
|
-
*
|
|
1103
|
-
* @param parameters
|
|
1104
|
-
* @returns Promise\<number\>
|
|
1105
|
-
*/
|
|
1106
|
-
;
|
|
1107
|
-
|
|
1108
|
-
_proto.importEvents =
|
|
1109
|
-
/*#__PURE__*/
|
|
1110
|
-
function () {
|
|
1111
|
-
var _importEvents = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(parameters) {
|
|
1112
|
-
var result;
|
|
1113
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1114
|
-
while (1) {
|
|
1115
|
-
switch (_context2.prev = _context2.next) {
|
|
1116
|
-
case 0:
|
|
1117
|
-
if (!(parameters.events.length === 0)) {
|
|
1118
|
-
_context2.next = 2;
|
|
1119
|
-
break;
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
throw new TooFewEventsError("You must send between 1 and 1,000 events.");
|
|
1123
|
-
|
|
1124
|
-
case 2:
|
|
1125
|
-
if (!(parameters.events.length > this._maxBatchSize)) {
|
|
1126
|
-
_context2.next = 4;
|
|
1127
|
-
break;
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
throw new TooManyEventsError("You must send between 1 and 1,000 events.");
|
|
1131
|
-
|
|
1132
|
-
case 4:
|
|
1133
|
-
_context2.next = 6;
|
|
1134
|
-
return this._client.post(this._url + "/events", {
|
|
1135
|
-
events: parameters.events
|
|
1136
|
-
});
|
|
1137
|
-
|
|
1138
|
-
case 6:
|
|
1139
|
-
result = _context2.sent;
|
|
1140
|
-
return _context2.abrupt("return", result.results);
|
|
1141
|
-
|
|
1142
|
-
case 8:
|
|
1143
|
-
case "end":
|
|
1144
|
-
return _context2.stop();
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
}, _callee2, this);
|
|
1148
|
-
}));
|
|
1149
|
-
|
|
1150
|
-
function importEvents(_x2) {
|
|
1151
|
-
return _importEvents.apply(this, arguments);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
return importEvents;
|
|
1155
|
-
}()
|
|
1156
|
-
/**
|
|
1157
|
-
* Creates a batch job to send transactional emails from Bento's infrastructure. You can pass in
|
|
1158
|
-
* between 1 and 100 emails to send.
|
|
1159
|
-
*
|
|
1160
|
-
* Each email must have a `to` address, a `from` address, a `subject`, an `html_body`
|
|
1161
|
-
* and `transactional: true`.
|
|
1162
|
-
* In addition you can add a `personalizations` object to provide
|
|
1163
|
-
* liquid tsags that will be injected into the email.
|
|
1164
|
-
*
|
|
1165
|
-
* Returns the number of events that were imported.
|
|
1166
|
-
*
|
|
1167
|
-
* @param parameters
|
|
1168
|
-
* @returns Promise\<number\>
|
|
1169
|
-
*/
|
|
1170
|
-
;
|
|
1171
|
-
|
|
1172
|
-
_proto.sendTransactionalEmails =
|
|
1173
|
-
/*#__PURE__*/
|
|
1174
|
-
function () {
|
|
1175
|
-
var _sendTransactionalEmails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(parameters) {
|
|
1176
|
-
var result;
|
|
1177
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1178
|
-
while (1) {
|
|
1179
|
-
switch (_context3.prev = _context3.next) {
|
|
1180
|
-
case 0:
|
|
1181
|
-
if (!(parameters.emails.length === 0)) {
|
|
1182
|
-
_context3.next = 2;
|
|
1183
|
-
break;
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
throw new TooFewEmailsError("You must send between 1 and 100 emails.");
|
|
1187
|
-
|
|
1188
|
-
case 2:
|
|
1189
|
-
if (!(parameters.emails.length > this._maxEmailBatchSize)) {
|
|
1190
|
-
_context3.next = 4;
|
|
1191
|
-
break;
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
throw new TooManyEmailsError("You must send between 1 and 100 emails.");
|
|
1195
|
-
|
|
1196
|
-
case 4:
|
|
1197
|
-
_context3.next = 6;
|
|
1198
|
-
return this._client.post(this._url + "/emails", {
|
|
1199
|
-
emails: parameters.emails
|
|
1200
|
-
});
|
|
1201
|
-
|
|
1202
|
-
case 6:
|
|
1203
|
-
result = _context3.sent;
|
|
1204
|
-
return _context3.abrupt("return", result.results);
|
|
1205
|
-
|
|
1206
|
-
case 8:
|
|
1207
|
-
case "end":
|
|
1208
|
-
return _context3.stop();
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
}, _callee3, this);
|
|
1212
|
-
}));
|
|
1213
|
-
|
|
1214
|
-
function sendTransactionalEmails(_x3) {
|
|
1215
|
-
return _sendTransactionalEmails.apply(this, arguments);
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
return sendTransactionalEmails;
|
|
1219
|
-
}();
|
|
1220
|
-
|
|
1221
|
-
return BentoBatch;
|
|
1222
|
-
}();
|
|
1223
|
-
|
|
1224
|
-
var NotAuthorizedError = /*#__PURE__*/function (_Error) {
|
|
1225
|
-
_inheritsLoose(NotAuthorizedError, _Error);
|
|
1226
|
-
|
|
1227
|
-
function NotAuthorizedError(message) {
|
|
1228
|
-
var _this;
|
|
1229
|
-
|
|
1230
|
-
if (message === void 0) {
|
|
1231
|
-
message = 'Not authorized';
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
_this = _Error.call(this, message) || this;
|
|
1235
|
-
_this.name = 'NotAuthorizedError';
|
|
1236
|
-
return _this;
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
return NotAuthorizedError;
|
|
1240
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1241
|
-
var RateLimitedError = /*#__PURE__*/function (_Error2) {
|
|
1242
|
-
_inheritsLoose(RateLimitedError, _Error2);
|
|
1243
|
-
|
|
1244
|
-
function RateLimitedError(message) {
|
|
1245
|
-
var _this2;
|
|
1246
|
-
|
|
1247
|
-
if (message === void 0) {
|
|
1248
|
-
message = 'You are being rate limited';
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
_this2 = _Error2.call(this, message) || this;
|
|
1252
|
-
_this2.name = 'RateLimitedError';
|
|
1253
|
-
return _this2;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
return RateLimitedError;
|
|
1257
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1258
|
-
|
|
1259
|
-
var BentoClient = /*#__PURE__*/function () {
|
|
1260
|
-
function BentoClient(options) {
|
|
1261
|
-
var _options$clientOption;
|
|
1262
|
-
|
|
1263
|
-
this._headers = {};
|
|
1264
|
-
this._baseUrl = 'https://app.bentonow.com/api/v1';
|
|
1265
|
-
this._siteUuid = '';
|
|
1266
|
-
this._logErrors = false;
|
|
1267
|
-
this._baseUrl = ((_options$clientOption = options.clientOptions) == null ? void 0 : _options$clientOption.baseUrl) || this._baseUrl;
|
|
1268
|
-
this._siteUuid = options.siteUuid;
|
|
1269
|
-
this._headers = this._extractHeaders(options.authentication);
|
|
1270
|
-
this._logErrors = options.logErrors || false;
|
|
1271
|
-
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Wraps a GET request to the Bento API and automatically adds the required
|
|
1274
|
-
* headers.
|
|
1275
|
-
*
|
|
1276
|
-
* @param endpoint string
|
|
1277
|
-
* @param payload object
|
|
1278
|
-
* @returns Promise\<T\>
|
|
1279
|
-
* */
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
var _proto = BentoClient.prototype;
|
|
1283
|
-
|
|
1284
|
-
_proto.get = function get(endpoint, payload) {
|
|
1285
|
-
var _this = this;
|
|
1286
|
-
|
|
1287
|
-
if (payload === void 0) {
|
|
1288
|
-
payload = {};
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
return new Promise(function (resolve, reject) {
|
|
1292
|
-
var queryParameters = _this._getQueryParameters(payload);
|
|
1293
|
-
|
|
1294
|
-
fetch("" + _this._baseUrl + endpoint + "?" + queryParameters, {
|
|
1295
|
-
method: 'GET',
|
|
1296
|
-
headers: _this._headers
|
|
1297
|
-
}).then( /*#__PURE__*/function () {
|
|
1298
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(result) {
|
|
1299
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1300
|
-
while (1) {
|
|
1301
|
-
switch (_context.prev = _context.next) {
|
|
1302
|
-
case 0:
|
|
1303
|
-
if (!_this._isSuccessfulStatus(result.status)) {
|
|
1304
|
-
_context.next = 2;
|
|
1305
|
-
break;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
return _context.abrupt("return", result.json());
|
|
1309
|
-
|
|
1310
|
-
case 2:
|
|
1311
|
-
_context.next = 4;
|
|
1312
|
-
return _this._getErrorForResponse(result);
|
|
1313
|
-
|
|
1314
|
-
case 4:
|
|
1315
|
-
throw _context.sent;
|
|
1316
|
-
|
|
1317
|
-
case 5:
|
|
1318
|
-
case "end":
|
|
1319
|
-
return _context.stop();
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
}, _callee);
|
|
1323
|
-
}));
|
|
1324
|
-
|
|
1325
|
-
return function (_x) {
|
|
1326
|
-
return _ref.apply(this, arguments);
|
|
1327
|
-
};
|
|
1328
|
-
}()).then(function (data) {
|
|
1329
|
-
return resolve(data);
|
|
1330
|
-
})["catch"](function (error) {
|
|
1331
|
-
return reject(error);
|
|
1332
|
-
});
|
|
1333
|
-
});
|
|
1334
|
-
}
|
|
1335
|
-
/**
|
|
1336
|
-
* Wraps a POST request to the Bento API and automatically adds the required
|
|
1337
|
-
* headers.
|
|
1338
|
-
*
|
|
1339
|
-
* @param endpoint string
|
|
1340
|
-
* @param payload object
|
|
1341
|
-
* @returns Promise\<T\>
|
|
1342
|
-
* */
|
|
1343
|
-
;
|
|
1344
|
-
|
|
1345
|
-
_proto.post = function post(endpoint, payload) {
|
|
1346
|
-
var _this2 = this;
|
|
1347
|
-
|
|
1348
|
-
if (payload === void 0) {
|
|
1349
|
-
payload = {};
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
return new Promise(function (resolve, reject) {
|
|
1353
|
-
var body = _this2._getBody(payload);
|
|
1354
|
-
|
|
1355
|
-
fetch("" + _this2._baseUrl + endpoint, {
|
|
1356
|
-
method: 'POST',
|
|
1357
|
-
headers: _extends({}, _this2._headers, {
|
|
1358
|
-
'Content-Type': 'application/json'
|
|
1359
|
-
}),
|
|
1360
|
-
body: body
|
|
1361
|
-
}).then( /*#__PURE__*/function () {
|
|
1362
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(result) {
|
|
1363
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1364
|
-
while (1) {
|
|
1365
|
-
switch (_context2.prev = _context2.next) {
|
|
1366
|
-
case 0:
|
|
1367
|
-
if (!_this2._isSuccessfulStatus(result.status)) {
|
|
1368
|
-
_context2.next = 2;
|
|
1369
|
-
break;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
return _context2.abrupt("return", result.json());
|
|
1373
|
-
|
|
1374
|
-
case 2:
|
|
1375
|
-
_context2.next = 4;
|
|
1376
|
-
return _this2._getErrorForResponse(result);
|
|
1377
|
-
|
|
1378
|
-
case 4:
|
|
1379
|
-
throw _context2.sent;
|
|
1380
|
-
|
|
1381
|
-
case 5:
|
|
1382
|
-
case "end":
|
|
1383
|
-
return _context2.stop();
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}, _callee2);
|
|
1387
|
-
}));
|
|
1388
|
-
|
|
1389
|
-
return function (_x2) {
|
|
1390
|
-
return _ref2.apply(this, arguments);
|
|
1391
|
-
};
|
|
1392
|
-
}()).then(function (data) {
|
|
1393
|
-
return resolve(data);
|
|
1394
|
-
})["catch"](function (error) {
|
|
1395
|
-
return reject(error);
|
|
1396
|
-
});
|
|
1397
|
-
});
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
* Extracts the `publishableKey` and `secretKey` from the `authentication` options and
|
|
1401
|
-
* adds the `Authorization` header.
|
|
1402
|
-
*
|
|
1403
|
-
* @param authentication AuthenticationOptions
|
|
1404
|
-
* @returns HeadersInit
|
|
1405
|
-
*/
|
|
1406
|
-
;
|
|
1407
|
-
|
|
1408
|
-
_proto._extractHeaders = function _extractHeaders(authentication) {
|
|
1409
|
-
var authenticationKey = Buffer.from(authentication.publishableKey + ":" + authentication.secretKey).toString('base64');
|
|
1410
|
-
return {
|
|
1411
|
-
Authorization: "Basic " + authenticationKey
|
|
1412
|
-
};
|
|
1413
|
-
}
|
|
1414
|
-
/**
|
|
1415
|
-
* Takes the existing payload and adds the `site_uuid` to it, then returns
|
|
1416
|
-
* it out as a JSON string so that it can be sent alongside the request.
|
|
1417
|
-
*
|
|
1418
|
-
* @param payload object
|
|
1419
|
-
* @returns string
|
|
1420
|
-
*/
|
|
1421
|
-
;
|
|
1422
|
-
|
|
1423
|
-
_proto._getBody = function _getBody(payload) {
|
|
1424
|
-
return JSON.stringify(_extends({}, payload, {
|
|
1425
|
-
site_uuid: this._siteUuid
|
|
1426
|
-
}));
|
|
1427
|
-
}
|
|
1428
|
-
/**
|
|
1429
|
-
* Takes the existing payload and adds the `site_uuid` to it, converts the
|
|
1430
|
-
* object to a query string so that it can be sent alongside a GET request.
|
|
1431
|
-
*
|
|
1432
|
-
* @param payload object
|
|
1433
|
-
* @returns string
|
|
1434
|
-
*/
|
|
1435
|
-
;
|
|
1436
|
-
|
|
1437
|
-
_proto._getQueryParameters = function _getQueryParameters(payload) {
|
|
1438
|
-
var body = _extends({}, payload, {
|
|
1439
|
-
site_uuid: this._siteUuid
|
|
1440
|
-
});
|
|
1441
|
-
|
|
1442
|
-
var queryParameters = new URLSearchParams();
|
|
1443
|
-
|
|
1444
|
-
for (var _i = 0, _Object$entries = Object.entries(body); _i < _Object$entries.length; _i++) {
|
|
1445
|
-
var _Object$entries$_i = _Object$entries[_i],
|
|
1446
|
-
key = _Object$entries$_i[0],
|
|
1447
|
-
value = _Object$entries$_i[1];
|
|
1448
|
-
queryParameters.append(key, value);
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
return queryParameters.toString();
|
|
1452
|
-
}
|
|
1453
|
-
/**
|
|
1454
|
-
* Filters down the status codes to those that are considered a 'success'.
|
|
1455
|
-
*
|
|
1456
|
-
* @param statusCode number
|
|
1457
|
-
* @returns boolean
|
|
1458
|
-
*/
|
|
1459
|
-
;
|
|
1460
|
-
|
|
1461
|
-
_proto._isSuccessfulStatus = function _isSuccessfulStatus(statusCode) {
|
|
1462
|
-
var validStatusCodes = [200, 201];
|
|
1463
|
-
return validStatusCodes.includes(statusCode);
|
|
1464
|
-
}
|
|
1465
|
-
/**
|
|
1466
|
-
* Returns an appropriate error to be thrown given the received response.
|
|
1467
|
-
*
|
|
1468
|
-
* @param response Response
|
|
1469
|
-
* @returns Error
|
|
1470
|
-
*/
|
|
1471
|
-
;
|
|
1472
|
-
|
|
1473
|
-
_proto._getErrorForResponse =
|
|
1474
|
-
/*#__PURE__*/
|
|
1475
|
-
function () {
|
|
1476
|
-
var _getErrorForResponse2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(response) {
|
|
1477
|
-
var contentType, responseMessage;
|
|
1478
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1479
|
-
while (1) {
|
|
1480
|
-
switch (_context3.prev = _context3.next) {
|
|
1481
|
-
case 0:
|
|
1482
|
-
if (this._logErrors) {
|
|
1483
|
-
console.error(response);
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
if (!(response.status === 401)) {
|
|
1487
|
-
_context3.next = 3;
|
|
1488
|
-
break;
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
return _context3.abrupt("return", new NotAuthorizedError());
|
|
1492
|
-
|
|
1493
|
-
case 3:
|
|
1494
|
-
if (!(response.status === 429)) {
|
|
1495
|
-
_context3.next = 5;
|
|
1496
|
-
break;
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
return _context3.abrupt("return", new RateLimitedError());
|
|
1500
|
-
|
|
1501
|
-
case 5:
|
|
1502
|
-
contentType = response.headers.get('Content-Type');
|
|
1503
|
-
responseMessage = '';
|
|
1504
|
-
_context3.t0 = contentType == null ? void 0 : contentType.toLocaleLowerCase();
|
|
1505
|
-
_context3.next = _context3.t0 === 'text/plain' ? 10 : _context3.t0 === 'application/json' ? 14 : 20;
|
|
1506
|
-
break;
|
|
1507
|
-
|
|
1508
|
-
case 10:
|
|
1509
|
-
_context3.next = 12;
|
|
1510
|
-
return response.text();
|
|
1511
|
-
|
|
1512
|
-
case 12:
|
|
1513
|
-
responseMessage = _context3.sent;
|
|
1514
|
-
return _context3.abrupt("break", 22);
|
|
1515
|
-
|
|
1516
|
-
case 14:
|
|
1517
|
-
_context3.t1 = JSON;
|
|
1518
|
-
_context3.next = 17;
|
|
1519
|
-
return response.json();
|
|
1520
|
-
|
|
1521
|
-
case 17:
|
|
1522
|
-
_context3.t2 = _context3.sent;
|
|
1523
|
-
responseMessage = _context3.t1.stringify.call(_context3.t1, _context3.t2);
|
|
1524
|
-
return _context3.abrupt("break", 22);
|
|
1525
|
-
|
|
1526
|
-
case 20:
|
|
1527
|
-
responseMessage = 'Unknown response from the Bento API.';
|
|
1528
|
-
return _context3.abrupt("break", 22);
|
|
1529
|
-
|
|
1530
|
-
case 22:
|
|
1531
|
-
return _context3.abrupt("return", new Error("[" + response.status + "] - " + responseMessage));
|
|
1532
|
-
|
|
1533
|
-
case 23:
|
|
1534
|
-
case "end":
|
|
1535
|
-
return _context3.stop();
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
}, _callee3, this);
|
|
1539
|
-
}));
|
|
1540
|
-
|
|
1541
|
-
function _getErrorForResponse(_x3) {
|
|
1542
|
-
return _getErrorForResponse2.apply(this, arguments);
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
return _getErrorForResponse;
|
|
1546
|
-
}();
|
|
1547
|
-
|
|
1548
|
-
return BentoClient;
|
|
1549
|
-
}();
|
|
1550
|
-
|
|
1551
|
-
/**
|
|
1552
|
-
* Command Enums
|
|
1553
|
-
*/
|
|
1554
|
-
var CommandTypes;
|
|
1555
|
-
|
|
1556
|
-
(function (CommandTypes) {
|
|
1557
|
-
CommandTypes["ADD_FIELD"] = "add_field";
|
|
1558
|
-
CommandTypes["ADD_TAG"] = "add_tag";
|
|
1559
|
-
CommandTypes["CHANGE_EMAIL"] = "change_email";
|
|
1560
|
-
CommandTypes["REMOVE_FIELD"] = "remove_field";
|
|
1561
|
-
CommandTypes["REMOVE_TAG"] = "remove_tag";
|
|
1562
|
-
CommandTypes["SUBSCRIBE"] = "subscribe";
|
|
1563
|
-
CommandTypes["UNSUBSCRIBE"] = "unsubscribe";
|
|
1564
|
-
})(CommandTypes || (CommandTypes = {}));
|
|
1565
|
-
|
|
1566
|
-
var BentoCommands = /*#__PURE__*/function () {
|
|
1567
|
-
function BentoCommands(_client) {
|
|
1568
|
-
this._client = void 0;
|
|
1569
|
-
this._url = '/fetch/commands';
|
|
1570
|
-
this._client = _client;
|
|
1571
|
-
}
|
|
1572
|
-
/**
|
|
1573
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please use the
|
|
1574
|
-
* core module's `tagSubscriber` method.
|
|
1575
|
-
*
|
|
1576
|
-
* Adds a tag to the subscriber with the matching email.
|
|
1577
|
-
*
|
|
1578
|
-
* Note that both the tag and the subscriber will be created if either is missing
|
|
1579
|
-
* from system.
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
* @param parameters \{ email: string, tagName: string \}
|
|
1583
|
-
* @returns Promise\<Subscriber | null\>
|
|
1584
|
-
*/
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
var _proto = BentoCommands.prototype;
|
|
1588
|
-
|
|
1589
|
-
_proto.addTag =
|
|
1590
|
-
/*#__PURE__*/
|
|
1591
|
-
function () {
|
|
1592
|
-
var _addTag = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(parameters) {
|
|
1593
|
-
var result;
|
|
1594
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1595
|
-
while (1) {
|
|
1596
|
-
switch (_context.prev = _context.next) {
|
|
1597
|
-
case 0:
|
|
1598
|
-
_context.next = 2;
|
|
1599
|
-
return this._client.post(this._url, {
|
|
1600
|
-
command: {
|
|
1601
|
-
command: CommandTypes.ADD_TAG,
|
|
1602
|
-
email: parameters.email,
|
|
1603
|
-
query: parameters.tagName
|
|
1604
|
-
}
|
|
1605
|
-
});
|
|
1606
|
-
|
|
1607
|
-
case 2:
|
|
1608
|
-
result = _context.sent;
|
|
1609
|
-
|
|
1610
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1611
|
-
_context.next = 5;
|
|
1612
|
-
break;
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
return _context.abrupt("return", null);
|
|
1616
|
-
|
|
1617
|
-
case 5:
|
|
1618
|
-
return _context.abrupt("return", result.data);
|
|
1619
|
-
|
|
1620
|
-
case 6:
|
|
1621
|
-
case "end":
|
|
1622
|
-
return _context.stop();
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
}, _callee, this);
|
|
1626
|
-
}));
|
|
1627
|
-
|
|
1628
|
-
function addTag(_x) {
|
|
1629
|
-
return _addTag.apply(this, arguments);
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
return addTag;
|
|
1633
|
-
}()
|
|
1634
|
-
/**
|
|
1635
|
-
* Removes the specified tag from the subscriber with the matching email.
|
|
1636
|
-
*
|
|
1637
|
-
* @param parameters \{ email: string, tagName: string \}
|
|
1638
|
-
* @returns Promise\<Subscriber | null\>
|
|
1639
|
-
*/
|
|
1640
|
-
;
|
|
1641
|
-
|
|
1642
|
-
_proto.removeTag =
|
|
1643
|
-
/*#__PURE__*/
|
|
1644
|
-
function () {
|
|
1645
|
-
var _removeTag = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(parameters) {
|
|
1646
|
-
var result;
|
|
1647
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1648
|
-
while (1) {
|
|
1649
|
-
switch (_context2.prev = _context2.next) {
|
|
1650
|
-
case 0:
|
|
1651
|
-
_context2.next = 2;
|
|
1652
|
-
return this._client.post(this._url, {
|
|
1653
|
-
command: {
|
|
1654
|
-
command: CommandTypes.REMOVE_TAG,
|
|
1655
|
-
email: parameters.email,
|
|
1656
|
-
query: parameters.tagName
|
|
1657
|
-
}
|
|
1658
|
-
});
|
|
1659
|
-
|
|
1660
|
-
case 2:
|
|
1661
|
-
result = _context2.sent;
|
|
1662
|
-
|
|
1663
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1664
|
-
_context2.next = 5;
|
|
1665
|
-
break;
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
return _context2.abrupt("return", null);
|
|
1669
|
-
|
|
1670
|
-
case 5:
|
|
1671
|
-
return _context2.abrupt("return", result.data);
|
|
1672
|
-
|
|
1673
|
-
case 6:
|
|
1674
|
-
case "end":
|
|
1675
|
-
return _context2.stop();
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
}, _callee2, this);
|
|
1679
|
-
}));
|
|
1680
|
-
|
|
1681
|
-
function removeTag(_x2) {
|
|
1682
|
-
return _removeTag.apply(this, arguments);
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
return removeTag;
|
|
1686
|
-
}()
|
|
1687
|
-
/**
|
|
1688
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please use the
|
|
1689
|
-
* core module's `updateFields` method.
|
|
1690
|
-
*
|
|
1691
|
-
* Adds a field to the subscriber with the matching email.
|
|
1692
|
-
*
|
|
1693
|
-
* Note that both the field and the subscriber will be created if either is missing
|
|
1694
|
-
* from system.
|
|
1695
|
-
*
|
|
1696
|
-
* @param parameters \{ email: string, field: \{ key: string; value: string; \} \}
|
|
1697
|
-
* @returns Promise\<Subscriber | null\>
|
|
1698
|
-
*/
|
|
1699
|
-
;
|
|
1700
|
-
|
|
1701
|
-
_proto.addField =
|
|
1702
|
-
/*#__PURE__*/
|
|
1703
|
-
function () {
|
|
1704
|
-
var _addField = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(parameters) {
|
|
1705
|
-
var result;
|
|
1706
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1707
|
-
while (1) {
|
|
1708
|
-
switch (_context3.prev = _context3.next) {
|
|
1709
|
-
case 0:
|
|
1710
|
-
_context3.next = 2;
|
|
1711
|
-
return this._client.post(this._url, {
|
|
1712
|
-
command: {
|
|
1713
|
-
command: CommandTypes.ADD_FIELD,
|
|
1714
|
-
email: parameters.email,
|
|
1715
|
-
query: parameters.field
|
|
1716
|
-
}
|
|
1717
|
-
});
|
|
1718
|
-
|
|
1719
|
-
case 2:
|
|
1720
|
-
result = _context3.sent;
|
|
1721
|
-
|
|
1722
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1723
|
-
_context3.next = 5;
|
|
1724
|
-
break;
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
return _context3.abrupt("return", null);
|
|
1728
|
-
|
|
1729
|
-
case 5:
|
|
1730
|
-
return _context3.abrupt("return", result.data);
|
|
1731
|
-
|
|
1732
|
-
case 6:
|
|
1733
|
-
case "end":
|
|
1734
|
-
return _context3.stop();
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
}, _callee3, this);
|
|
1738
|
-
}));
|
|
1739
|
-
|
|
1740
|
-
function addField(_x3) {
|
|
1741
|
-
return _addField.apply(this, arguments);
|
|
1742
|
-
}
|
|
1743
|
-
|
|
1744
|
-
return addField;
|
|
1745
|
-
}()
|
|
1746
|
-
/**
|
|
1747
|
-
* Removes a field to the subscriber with the matching email.
|
|
1748
|
-
*
|
|
1749
|
-
* @param parameters \{ email: string, fieldName: string \}
|
|
1750
|
-
* @returns Promise\<Subscriber | null\>
|
|
1751
|
-
*/
|
|
1752
|
-
;
|
|
1753
|
-
|
|
1754
|
-
_proto.removeField =
|
|
1755
|
-
/*#__PURE__*/
|
|
1756
|
-
function () {
|
|
1757
|
-
var _removeField = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(parameters) {
|
|
1758
|
-
var result;
|
|
1759
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1760
|
-
while (1) {
|
|
1761
|
-
switch (_context4.prev = _context4.next) {
|
|
1762
|
-
case 0:
|
|
1763
|
-
_context4.next = 2;
|
|
1764
|
-
return this._client.post(this._url, {
|
|
1765
|
-
command: {
|
|
1766
|
-
command: CommandTypes.REMOVE_FIELD,
|
|
1767
|
-
email: parameters.email,
|
|
1768
|
-
query: parameters.fieldName
|
|
1769
|
-
}
|
|
1770
|
-
});
|
|
1771
|
-
|
|
1772
|
-
case 2:
|
|
1773
|
-
result = _context4.sent;
|
|
1774
|
-
|
|
1775
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1776
|
-
_context4.next = 5;
|
|
1777
|
-
break;
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
return _context4.abrupt("return", null);
|
|
1781
|
-
|
|
1782
|
-
case 5:
|
|
1783
|
-
return _context4.abrupt("return", result.data);
|
|
1784
|
-
|
|
1785
|
-
case 6:
|
|
1786
|
-
case "end":
|
|
1787
|
-
return _context4.stop();
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
}, _callee4, this);
|
|
1791
|
-
}));
|
|
1792
|
-
|
|
1793
|
-
function removeField(_x4) {
|
|
1794
|
-
return _removeField.apply(this, arguments);
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
|
-
return removeField;
|
|
1798
|
-
}()
|
|
1799
|
-
/**
|
|
1800
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please use the
|
|
1801
|
-
* core module's `addSubscriber` method.
|
|
1802
|
-
*
|
|
1803
|
-
* Subscribes the supplied email to Bento. If the email does not exist, it is created.
|
|
1804
|
-
* If the subscriber had previously unsubscribed, they will be re-subscribed.
|
|
1805
|
-
*
|
|
1806
|
-
* @param parameters \{ email: string \}
|
|
1807
|
-
* @returns Promise\<Subscriber | null\>
|
|
1808
|
-
*/
|
|
1809
|
-
;
|
|
1810
|
-
|
|
1811
|
-
_proto.subscribe =
|
|
1812
|
-
/*#__PURE__*/
|
|
1813
|
-
function () {
|
|
1814
|
-
var _subscribe = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(parameters) {
|
|
1815
|
-
var result;
|
|
1816
|
-
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1817
|
-
while (1) {
|
|
1818
|
-
switch (_context5.prev = _context5.next) {
|
|
1819
|
-
case 0:
|
|
1820
|
-
_context5.next = 2;
|
|
1821
|
-
return this._client.post(this._url, {
|
|
1822
|
-
command: {
|
|
1823
|
-
command: CommandTypes.SUBSCRIBE,
|
|
1824
|
-
email: parameters.email
|
|
1825
|
-
}
|
|
1826
|
-
});
|
|
1827
|
-
|
|
1828
|
-
case 2:
|
|
1829
|
-
result = _context5.sent;
|
|
1830
|
-
|
|
1831
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1832
|
-
_context5.next = 5;
|
|
1833
|
-
break;
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
return _context5.abrupt("return", null);
|
|
1837
|
-
|
|
1838
|
-
case 5:
|
|
1839
|
-
return _context5.abrupt("return", result.data);
|
|
1840
|
-
|
|
1841
|
-
case 6:
|
|
1842
|
-
case "end":
|
|
1843
|
-
return _context5.stop();
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
}, _callee5, this);
|
|
1847
|
-
}));
|
|
1848
|
-
|
|
1849
|
-
function subscribe(_x5) {
|
|
1850
|
-
return _subscribe.apply(this, arguments);
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
return subscribe;
|
|
1854
|
-
}()
|
|
1855
|
-
/**
|
|
1856
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please use the
|
|
1857
|
-
* core module's `removeSubscriber` method.
|
|
1858
|
-
*
|
|
1859
|
-
* Unsubscribes the supplied email to Bento. If the email does not exist, it is created and
|
|
1860
|
-
* immediately unsubscribed. If they had already unsubscribed, the `unsubscribed_at` property
|
|
1861
|
-
* is updated.
|
|
1862
|
-
*
|
|
1863
|
-
* @param parameters \{ email: string \}
|
|
1864
|
-
* @returns Promise\<Subscriber | null\>
|
|
1865
|
-
*/
|
|
1866
|
-
;
|
|
1867
|
-
|
|
1868
|
-
_proto.unsubscribe =
|
|
1869
|
-
/*#__PURE__*/
|
|
1870
|
-
function () {
|
|
1871
|
-
var _unsubscribe = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(parameters) {
|
|
1872
|
-
var result;
|
|
1873
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1874
|
-
while (1) {
|
|
1875
|
-
switch (_context6.prev = _context6.next) {
|
|
1876
|
-
case 0:
|
|
1877
|
-
_context6.next = 2;
|
|
1878
|
-
return this._client.post(this._url, {
|
|
1879
|
-
command: {
|
|
1880
|
-
command: CommandTypes.UNSUBSCRIBE,
|
|
1881
|
-
email: parameters.email
|
|
1882
|
-
}
|
|
1883
|
-
});
|
|
1884
|
-
|
|
1885
|
-
case 2:
|
|
1886
|
-
result = _context6.sent;
|
|
1887
|
-
|
|
1888
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1889
|
-
_context6.next = 5;
|
|
1890
|
-
break;
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
return _context6.abrupt("return", null);
|
|
1894
|
-
|
|
1895
|
-
case 5:
|
|
1896
|
-
return _context6.abrupt("return", result.data);
|
|
1897
|
-
|
|
1898
|
-
case 6:
|
|
1899
|
-
case "end":
|
|
1900
|
-
return _context6.stop();
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
}, _callee6, this);
|
|
1904
|
-
}));
|
|
1905
|
-
|
|
1906
|
-
function unsubscribe(_x6) {
|
|
1907
|
-
return _unsubscribe.apply(this, arguments);
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
return unsubscribe;
|
|
1911
|
-
}()
|
|
1912
|
-
/**
|
|
1913
|
-
* Updates the email of a user in Bento.
|
|
1914
|
-
*
|
|
1915
|
-
* @param parameters \{ oldEmail: string, newEmail: string \}
|
|
1916
|
-
* @returns Promise\<Subscriber | null\>
|
|
1917
|
-
*/
|
|
1918
|
-
;
|
|
1919
|
-
|
|
1920
|
-
_proto.changeEmail =
|
|
1921
|
-
/*#__PURE__*/
|
|
1922
|
-
function () {
|
|
1923
|
-
var _changeEmail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(parameters) {
|
|
1924
|
-
var result;
|
|
1925
|
-
return runtime_1.wrap(function _callee7$(_context7) {
|
|
1926
|
-
while (1) {
|
|
1927
|
-
switch (_context7.prev = _context7.next) {
|
|
1928
|
-
case 0:
|
|
1929
|
-
_context7.next = 2;
|
|
1930
|
-
return this._client.post(this._url, {
|
|
1931
|
-
command: {
|
|
1932
|
-
command: CommandTypes.CHANGE_EMAIL,
|
|
1933
|
-
email: parameters.oldEmail,
|
|
1934
|
-
query: parameters.newEmail
|
|
1935
|
-
}
|
|
1936
|
-
});
|
|
1937
|
-
|
|
1938
|
-
case 2:
|
|
1939
|
-
result = _context7.sent;
|
|
1940
|
-
|
|
1941
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1942
|
-
_context7.next = 5;
|
|
1943
|
-
break;
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
return _context7.abrupt("return", null);
|
|
1947
|
-
|
|
1948
|
-
case 5:
|
|
1949
|
-
return _context7.abrupt("return", result.data);
|
|
1950
|
-
|
|
1951
|
-
case 6:
|
|
1952
|
-
case "end":
|
|
1953
|
-
return _context7.stop();
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
}, _callee7, this);
|
|
1957
|
-
}));
|
|
1958
|
-
|
|
1959
|
-
function changeEmail(_x7) {
|
|
1960
|
-
return _changeEmail.apply(this, arguments);
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
return changeEmail;
|
|
1964
|
-
}();
|
|
1965
|
-
|
|
1966
|
-
return BentoCommands;
|
|
1967
|
-
}();
|
|
1968
|
-
|
|
1969
|
-
var BentoExperimental = /*#__PURE__*/function () {
|
|
1970
|
-
function BentoExperimental(_client) {
|
|
1971
|
-
this._client = void 0;
|
|
1972
|
-
this._url = '/experimental';
|
|
1973
|
-
this._client = _client;
|
|
1974
|
-
}
|
|
1975
|
-
/**
|
|
1976
|
-
* **EXPERIMENTAL** -
|
|
1977
|
-
* This functionality is experimental and may change or stop working at any time.
|
|
1978
|
-
*
|
|
1979
|
-
* Attempts to validate the email. You can provide additional information to further
|
|
1980
|
-
* refine the validation.
|
|
1981
|
-
*
|
|
1982
|
-
* If a name is provided, it compares it against the US Census Data, and so the results
|
|
1983
|
-
* may be biased.
|
|
1984
|
-
*
|
|
1985
|
-
* @param parameters
|
|
1986
|
-
* @returns Promise\<boolean\>
|
|
1987
|
-
*/
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
var _proto = BentoExperimental.prototype;
|
|
1991
|
-
|
|
1992
|
-
_proto.validateEmail =
|
|
1993
|
-
/*#__PURE__*/
|
|
1994
|
-
function () {
|
|
1995
|
-
var _validateEmail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(parameters) {
|
|
1996
|
-
var result;
|
|
1997
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1998
|
-
while (1) {
|
|
1999
|
-
switch (_context.prev = _context.next) {
|
|
2000
|
-
case 0:
|
|
2001
|
-
_context.next = 2;
|
|
2002
|
-
return this._client.post(this._url + "/validation", {
|
|
2003
|
-
email: parameters.email,
|
|
2004
|
-
ip: parameters.ip,
|
|
2005
|
-
name: parameters.name,
|
|
2006
|
-
user_agent: parameters.userAgent
|
|
2007
|
-
});
|
|
2008
|
-
|
|
2009
|
-
case 2:
|
|
2010
|
-
result = _context.sent;
|
|
2011
|
-
return _context.abrupt("return", result.valid);
|
|
2012
|
-
|
|
2013
|
-
case 4:
|
|
2014
|
-
case "end":
|
|
2015
|
-
return _context.stop();
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
}, _callee, this);
|
|
2019
|
-
}));
|
|
2020
|
-
|
|
2021
|
-
function validateEmail(_x) {
|
|
2022
|
-
return _validateEmail.apply(this, arguments);
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
return validateEmail;
|
|
2026
|
-
}()
|
|
2027
|
-
/**
|
|
2028
|
-
* **EXPERIMENTAL** -
|
|
2029
|
-
* This functionality is experimental and may change or stop working at any time.
|
|
2030
|
-
*
|
|
2031
|
-
* Attempts to guess the gender of the person given a provided name. It compares
|
|
2032
|
-
* the name against the US Census Data, and so the results may be biased.
|
|
2033
|
-
*
|
|
2034
|
-
* It is possible for the gender to be unknown if the system cannot confidently
|
|
2035
|
-
* conclude what gender it may be.
|
|
2036
|
-
*
|
|
2037
|
-
* @param parameters
|
|
2038
|
-
* @returns Promise\<GuessGenderResponse\>
|
|
2039
|
-
*/
|
|
2040
|
-
;
|
|
2041
|
-
|
|
2042
|
-
_proto.guessGender =
|
|
2043
|
-
/*#__PURE__*/
|
|
2044
|
-
function () {
|
|
2045
|
-
var _guessGender = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(parameters) {
|
|
2046
|
-
var result;
|
|
2047
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2048
|
-
while (1) {
|
|
2049
|
-
switch (_context2.prev = _context2.next) {
|
|
2050
|
-
case 0:
|
|
2051
|
-
_context2.next = 2;
|
|
2052
|
-
return this._client.post(this._url + "/gender", parameters);
|
|
2053
|
-
|
|
2054
|
-
case 2:
|
|
2055
|
-
result = _context2.sent;
|
|
2056
|
-
return _context2.abrupt("return", result);
|
|
2057
|
-
|
|
2058
|
-
case 4:
|
|
2059
|
-
case "end":
|
|
2060
|
-
return _context2.stop();
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
}, _callee2, this);
|
|
2064
|
-
}));
|
|
2065
|
-
|
|
2066
|
-
function guessGender(_x2) {
|
|
2067
|
-
return _guessGender.apply(this, arguments);
|
|
2068
|
-
}
|
|
2069
|
-
|
|
2070
|
-
return guessGender;
|
|
2071
|
-
}()
|
|
2072
|
-
/**
|
|
2073
|
-
* **EXPERIMENTAL** -
|
|
2074
|
-
* This functionality is experimental and may change or stop working at any time.
|
|
2075
|
-
*
|
|
2076
|
-
* Attempts to provide location data given a provided IP address.
|
|
2077
|
-
*
|
|
2078
|
-
* @param parameters
|
|
2079
|
-
* @returns Promise\<GeolocateResponse\>
|
|
2080
|
-
*/
|
|
2081
|
-
;
|
|
2082
|
-
|
|
2083
|
-
_proto.geolocate =
|
|
2084
|
-
/*#__PURE__*/
|
|
2085
|
-
function () {
|
|
2086
|
-
var _geolocate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(parameters) {
|
|
2087
|
-
var result;
|
|
2088
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2089
|
-
while (1) {
|
|
2090
|
-
switch (_context3.prev = _context3.next) {
|
|
2091
|
-
case 0:
|
|
2092
|
-
_context3.next = 2;
|
|
2093
|
-
return this._client.get(this._url + "/geolocation", parameters);
|
|
2094
|
-
|
|
2095
|
-
case 2:
|
|
2096
|
-
result = _context3.sent;
|
|
2097
|
-
|
|
2098
|
-
if (!(Object.keys(result).length === 0)) {
|
|
2099
|
-
_context3.next = 5;
|
|
2100
|
-
break;
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
return _context3.abrupt("return", null);
|
|
2104
|
-
|
|
2105
|
-
case 5:
|
|
2106
|
-
return _context3.abrupt("return", result);
|
|
2107
|
-
|
|
2108
|
-
case 6:
|
|
2109
|
-
case "end":
|
|
2110
|
-
return _context3.stop();
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
}, _callee3, this);
|
|
2114
|
-
}));
|
|
2115
|
-
|
|
2116
|
-
function geolocate(_x3) {
|
|
2117
|
-
return _geolocate.apply(this, arguments);
|
|
2118
|
-
}
|
|
2119
|
-
|
|
2120
|
-
return geolocate;
|
|
2121
|
-
}()
|
|
2122
|
-
/**
|
|
2123
|
-
* **EXPERIMENTAL** -
|
|
2124
|
-
* This functionality is experimental and may change or stop working at any time.
|
|
2125
|
-
*
|
|
2126
|
-
* Looks up the provided URL or IP Address against various blacklists to see if the site has been
|
|
2127
|
-
* blacklisted anywhere.
|
|
2128
|
-
*
|
|
2129
|
-
* @param parameters
|
|
2130
|
-
* @returns Promise\<BlacklistResponse\>
|
|
2131
|
-
*/
|
|
2132
|
-
;
|
|
2133
|
-
|
|
2134
|
-
_proto.checkBlacklist =
|
|
2135
|
-
/*#__PURE__*/
|
|
2136
|
-
function () {
|
|
2137
|
-
var _checkBlacklist = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(parameters) {
|
|
2138
|
-
var result;
|
|
2139
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2140
|
-
while (1) {
|
|
2141
|
-
switch (_context4.prev = _context4.next) {
|
|
2142
|
-
case 0:
|
|
2143
|
-
_context4.next = 2;
|
|
2144
|
-
return this._client.get(this._url + "/blacklist.json", parameters);
|
|
2145
|
-
|
|
2146
|
-
case 2:
|
|
2147
|
-
result = _context4.sent;
|
|
2148
|
-
return _context4.abrupt("return", result);
|
|
2149
|
-
|
|
2150
|
-
case 4:
|
|
2151
|
-
case "end":
|
|
2152
|
-
return _context4.stop();
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
}, _callee4, this);
|
|
2156
|
-
}));
|
|
2157
|
-
|
|
2158
|
-
function checkBlacklist(_x4) {
|
|
2159
|
-
return _checkBlacklist.apply(this, arguments);
|
|
2160
|
-
}
|
|
2161
|
-
|
|
2162
|
-
return checkBlacklist;
|
|
2163
|
-
}();
|
|
2164
|
-
|
|
2165
|
-
return BentoExperimental;
|
|
2166
|
-
}();
|
|
2167
|
-
|
|
2168
|
-
var BentoFields = /*#__PURE__*/function () {
|
|
2169
|
-
function BentoFields(_client) {
|
|
2170
|
-
this._client = void 0;
|
|
2171
|
-
this._url = '/fetch/fields';
|
|
2172
|
-
this._client = _client;
|
|
2173
|
-
}
|
|
2174
|
-
/**
|
|
2175
|
-
* Returns all of the fields for the site.
|
|
2176
|
-
*
|
|
2177
|
-
* @returns Promise<Field[]>
|
|
2178
|
-
*/
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
var _proto = BentoFields.prototype;
|
|
2182
|
-
|
|
2183
|
-
_proto.getFields =
|
|
2184
|
-
/*#__PURE__*/
|
|
2185
|
-
function () {
|
|
2186
|
-
var _getFields = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2187
|
-
var result;
|
|
2188
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2189
|
-
while (1) {
|
|
2190
|
-
switch (_context.prev = _context.next) {
|
|
2191
|
-
case 0:
|
|
2192
|
-
_context.next = 2;
|
|
2193
|
-
return this._client.get(this._url);
|
|
2194
|
-
|
|
2195
|
-
case 2:
|
|
2196
|
-
result = _context.sent;
|
|
2197
|
-
|
|
2198
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
2199
|
-
_context.next = 5;
|
|
2200
|
-
break;
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
return _context.abrupt("return", null);
|
|
2204
|
-
|
|
2205
|
-
case 5:
|
|
2206
|
-
return _context.abrupt("return", result.data);
|
|
2207
|
-
|
|
2208
|
-
case 6:
|
|
2209
|
-
case "end":
|
|
2210
|
-
return _context.stop();
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
}, _callee, this);
|
|
2214
|
-
}));
|
|
2215
|
-
|
|
2216
|
-
function getFields() {
|
|
2217
|
-
return _getFields.apply(this, arguments);
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
|
-
return getFields;
|
|
2221
|
-
}()
|
|
2222
|
-
/**
|
|
2223
|
-
* Creates a field inside of Bento. The name of the field is automatically generated
|
|
2224
|
-
* from the key that is passed in upon creation. For example
|
|
2225
|
-
* - Key: `thisIsAKey`
|
|
2226
|
-
* Name: `This Is A Key`
|
|
2227
|
-
* - Key: `this is a key`
|
|
2228
|
-
* Name: `This Is A Key`
|
|
2229
|
-
* - Key: `this-is-a-key`
|
|
2230
|
-
* Name: `This Is A Key`
|
|
2231
|
-
* - Key: `this_is_a_key`
|
|
2232
|
-
* Name: `This Is A Key`
|
|
2233
|
-
*
|
|
2234
|
-
* @param parameters \{ key: string \}
|
|
2235
|
-
* @returns Promise<Field[]>
|
|
2236
|
-
*/
|
|
2237
|
-
;
|
|
2238
|
-
|
|
2239
|
-
_proto.createField =
|
|
2240
|
-
/*#__PURE__*/
|
|
2241
|
-
function () {
|
|
2242
|
-
var _createField = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(parameters) {
|
|
2243
|
-
var result;
|
|
2244
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2245
|
-
while (1) {
|
|
2246
|
-
switch (_context2.prev = _context2.next) {
|
|
2247
|
-
case 0:
|
|
2248
|
-
_context2.next = 2;
|
|
2249
|
-
return this._client.post(this._url, {
|
|
2250
|
-
field: parameters
|
|
2251
|
-
});
|
|
2252
|
-
|
|
2253
|
-
case 2:
|
|
2254
|
-
result = _context2.sent;
|
|
2255
|
-
|
|
2256
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
2257
|
-
_context2.next = 5;
|
|
2258
|
-
break;
|
|
2259
|
-
}
|
|
2260
|
-
|
|
2261
|
-
return _context2.abrupt("return", null);
|
|
2262
|
-
|
|
2263
|
-
case 5:
|
|
2264
|
-
return _context2.abrupt("return", result.data);
|
|
2265
|
-
|
|
2266
|
-
case 6:
|
|
2267
|
-
case "end":
|
|
2268
|
-
return _context2.stop();
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
}, _callee2, this);
|
|
2272
|
-
}));
|
|
2273
|
-
|
|
2274
|
-
function createField(_x) {
|
|
2275
|
-
return _createField.apply(this, arguments);
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
return createField;
|
|
2279
|
-
}();
|
|
2280
|
-
|
|
2281
|
-
return BentoFields;
|
|
2282
|
-
}();
|
|
2283
|
-
|
|
2284
|
-
var BentoForms = /*#__PURE__*/function () {
|
|
2285
|
-
function BentoForms(_client) {
|
|
2286
|
-
this._client = void 0;
|
|
2287
|
-
this._url = '/fetch/responses';
|
|
2288
|
-
this._client = _client;
|
|
2289
|
-
}
|
|
2290
|
-
/**
|
|
2291
|
-
* Returns all of the responses for the form with the specified identifier.
|
|
2292
|
-
*
|
|
2293
|
-
* @param formIdentifier string
|
|
2294
|
-
* @returns Promise\<FormResponse[] | null\>
|
|
2295
|
-
*/
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
var _proto = BentoForms.prototype;
|
|
2299
|
-
|
|
2300
|
-
_proto.getResponses =
|
|
2301
|
-
/*#__PURE__*/
|
|
2302
|
-
function () {
|
|
2303
|
-
var _getResponses = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(formIdentifier) {
|
|
2304
|
-
var result;
|
|
2305
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2306
|
-
while (1) {
|
|
2307
|
-
switch (_context.prev = _context.next) {
|
|
2308
|
-
case 0:
|
|
2309
|
-
_context.next = 2;
|
|
2310
|
-
return this._client.get(this._url, {
|
|
2311
|
-
id: formIdentifier
|
|
2312
|
-
});
|
|
2313
|
-
|
|
2314
|
-
case 2:
|
|
2315
|
-
result = _context.sent;
|
|
2316
|
-
|
|
2317
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
2318
|
-
_context.next = 5;
|
|
2319
|
-
break;
|
|
2320
|
-
}
|
|
2321
|
-
|
|
2322
|
-
return _context.abrupt("return", null);
|
|
2323
|
-
|
|
2324
|
-
case 5:
|
|
2325
|
-
return _context.abrupt("return", result.data);
|
|
2326
|
-
|
|
2327
|
-
case 6:
|
|
2328
|
-
case "end":
|
|
2329
|
-
return _context.stop();
|
|
2330
|
-
}
|
|
2331
|
-
}
|
|
2332
|
-
}, _callee, this);
|
|
2333
|
-
}));
|
|
2334
|
-
|
|
2335
|
-
function getResponses(_x) {
|
|
2336
|
-
return _getResponses.apply(this, arguments);
|
|
2337
|
-
}
|
|
2338
|
-
|
|
2339
|
-
return getResponses;
|
|
2340
|
-
}();
|
|
2341
|
-
|
|
2342
|
-
return BentoForms;
|
|
2343
|
-
}();
|
|
2344
|
-
|
|
2345
|
-
var BentoSubscribers = /*#__PURE__*/function () {
|
|
2346
|
-
function BentoSubscribers(_client) {
|
|
2347
|
-
this._client = void 0;
|
|
2348
|
-
this._url = '/fetch/subscribers';
|
|
2349
|
-
this._client = _client;
|
|
2350
|
-
}
|
|
2351
|
-
/**
|
|
2352
|
-
* Returns the subscriber with the specified email or UUID.
|
|
2353
|
-
*
|
|
2354
|
-
* @returns Promise\<Subscriber\<S\> | null\>
|
|
2355
|
-
*/
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
var _proto = BentoSubscribers.prototype;
|
|
2359
|
-
|
|
2360
|
-
_proto.getSubscribers =
|
|
2361
|
-
/*#__PURE__*/
|
|
2362
|
-
function () {
|
|
2363
|
-
var _getSubscribers = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(parameters) {
|
|
2364
|
-
var result;
|
|
2365
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2366
|
-
while (1) {
|
|
2367
|
-
switch (_context.prev = _context.next) {
|
|
2368
|
-
case 0:
|
|
2369
|
-
_context.next = 2;
|
|
2370
|
-
return this._client.get(this._url, parameters);
|
|
2371
|
-
|
|
2372
|
-
case 2:
|
|
2373
|
-
result = _context.sent;
|
|
2374
|
-
|
|
2375
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
2376
|
-
_context.next = 5;
|
|
2377
|
-
break;
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
return _context.abrupt("return", null);
|
|
2381
|
-
|
|
2382
|
-
case 5:
|
|
2383
|
-
return _context.abrupt("return", result.data);
|
|
2384
|
-
|
|
2385
|
-
case 6:
|
|
2386
|
-
case "end":
|
|
2387
|
-
return _context.stop();
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
}, _callee, this);
|
|
2391
|
-
}));
|
|
2392
|
-
|
|
2393
|
-
function getSubscribers(_x) {
|
|
2394
|
-
return _getSubscribers.apply(this, arguments);
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
|
-
return getSubscribers;
|
|
2398
|
-
}()
|
|
2399
|
-
/**
|
|
2400
|
-
* Creates a subscriber inside of Bento.
|
|
2401
|
-
*
|
|
2402
|
-
* @param parameters CreateSubscriberParameters
|
|
2403
|
-
* @returns Promise\<Subscriber\<S\> | null\>
|
|
2404
|
-
*/
|
|
2405
|
-
;
|
|
2406
|
-
|
|
2407
|
-
_proto.createSubscriber =
|
|
2408
|
-
/*#__PURE__*/
|
|
2409
|
-
function () {
|
|
2410
|
-
var _createSubscriber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(parameters) {
|
|
2411
|
-
var result;
|
|
2412
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2413
|
-
while (1) {
|
|
2414
|
-
switch (_context2.prev = _context2.next) {
|
|
2415
|
-
case 0:
|
|
2416
|
-
_context2.next = 2;
|
|
2417
|
-
return this._client.post(this._url, {
|
|
2418
|
-
subscriber: parameters
|
|
2419
|
-
});
|
|
2420
|
-
|
|
2421
|
-
case 2:
|
|
2422
|
-
result = _context2.sent;
|
|
2423
|
-
|
|
2424
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
2425
|
-
_context2.next = 5;
|
|
2426
|
-
break;
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
return _context2.abrupt("return", null);
|
|
2430
|
-
|
|
2431
|
-
case 5:
|
|
2432
|
-
return _context2.abrupt("return", result.data);
|
|
2433
|
-
|
|
2434
|
-
case 6:
|
|
2435
|
-
case "end":
|
|
2436
|
-
return _context2.stop();
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
}, _callee2, this);
|
|
2440
|
-
}));
|
|
2441
|
-
|
|
2442
|
-
function createSubscriber(_x2) {
|
|
2443
|
-
return _createSubscriber.apply(this, arguments);
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
|
-
return createSubscriber;
|
|
2447
|
-
}();
|
|
2448
|
-
|
|
2449
|
-
return BentoSubscribers;
|
|
2450
|
-
}();
|
|
2451
|
-
|
|
2452
|
-
var BentoTags = /*#__PURE__*/function () {
|
|
2453
|
-
function BentoTags(_client) {
|
|
2454
|
-
this._client = void 0;
|
|
2455
|
-
this._url = '/fetch/tags';
|
|
2456
|
-
this._client = _client;
|
|
2457
|
-
}
|
|
2458
|
-
/**
|
|
2459
|
-
* Returns all of the fields for the site.
|
|
2460
|
-
*
|
|
2461
|
-
* @returns Promise\<Tag[] | null\>
|
|
2462
|
-
*/
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
var _proto = BentoTags.prototype;
|
|
2466
|
-
|
|
2467
|
-
_proto.getTags =
|
|
2468
|
-
/*#__PURE__*/
|
|
2469
|
-
function () {
|
|
2470
|
-
var _getTags = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2471
|
-
var result;
|
|
2472
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2473
|
-
while (1) {
|
|
2474
|
-
switch (_context.prev = _context.next) {
|
|
2475
|
-
case 0:
|
|
2476
|
-
_context.next = 2;
|
|
2477
|
-
return this._client.get(this._url);
|
|
2478
|
-
|
|
2479
|
-
case 2:
|
|
2480
|
-
result = _context.sent;
|
|
2481
|
-
|
|
2482
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
2483
|
-
_context.next = 5;
|
|
2484
|
-
break;
|
|
2485
|
-
}
|
|
2486
|
-
|
|
2487
|
-
return _context.abrupt("return", null);
|
|
2488
|
-
|
|
2489
|
-
case 5:
|
|
2490
|
-
return _context.abrupt("return", result.data);
|
|
2491
|
-
|
|
2492
|
-
case 6:
|
|
2493
|
-
case "end":
|
|
2494
|
-
return _context.stop();
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
}, _callee, this);
|
|
2498
|
-
}));
|
|
2499
|
-
|
|
2500
|
-
function getTags() {
|
|
2501
|
-
return _getTags.apply(this, arguments);
|
|
2502
|
-
}
|
|
2503
|
-
|
|
2504
|
-
return getTags;
|
|
2505
|
-
}()
|
|
2506
|
-
/**
|
|
2507
|
-
* Creates a tag inside of Bento.
|
|
2508
|
-
*
|
|
2509
|
-
* @param parameters CreateTagParameters
|
|
2510
|
-
* @returns Promise\<Tag[] | null\>
|
|
2511
|
-
*/
|
|
2512
|
-
;
|
|
2513
|
-
|
|
2514
|
-
_proto.createTag =
|
|
2515
|
-
/*#__PURE__*/
|
|
2516
|
-
function () {
|
|
2517
|
-
var _createTag = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(parameters) {
|
|
2518
|
-
var result;
|
|
2519
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2520
|
-
while (1) {
|
|
2521
|
-
switch (_context2.prev = _context2.next) {
|
|
2522
|
-
case 0:
|
|
2523
|
-
_context2.next = 2;
|
|
2524
|
-
return this._client.post(this._url, {
|
|
2525
|
-
tag: parameters
|
|
2526
|
-
});
|
|
2527
|
-
|
|
2528
|
-
case 2:
|
|
2529
|
-
result = _context2.sent;
|
|
2530
|
-
|
|
2531
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
2532
|
-
_context2.next = 5;
|
|
2533
|
-
break;
|
|
2534
|
-
}
|
|
2535
|
-
|
|
2536
|
-
return _context2.abrupt("return", null);
|
|
2537
|
-
|
|
2538
|
-
case 5:
|
|
2539
|
-
return _context2.abrupt("return", result.data);
|
|
2540
|
-
|
|
2541
|
-
case 6:
|
|
2542
|
-
case "end":
|
|
2543
|
-
return _context2.stop();
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
}, _callee2, this);
|
|
2547
|
-
}));
|
|
2548
|
-
|
|
2549
|
-
function createTag(_x) {
|
|
2550
|
-
return _createTag.apply(this, arguments);
|
|
2551
|
-
}
|
|
2552
|
-
|
|
2553
|
-
return createTag;
|
|
2554
|
-
}();
|
|
2555
|
-
|
|
2556
|
-
return BentoTags;
|
|
2557
|
-
}();
|
|
2558
|
-
|
|
2559
|
-
var BentoEvents;
|
|
2560
|
-
|
|
2561
|
-
(function (BentoEvents) {
|
|
2562
|
-
BentoEvents["PURCHASE"] = "$purchase";
|
|
2563
|
-
BentoEvents["SUBSCRIBE"] = "$subscribe";
|
|
2564
|
-
BentoEvents["TAG"] = "$tag";
|
|
2565
|
-
BentoEvents["REMOVE_TAG"] = "$remove_tag";
|
|
2566
|
-
BentoEvents["UNSUBSCRIBE"] = "$unsubscribe";
|
|
2567
|
-
BentoEvents["UPDATE_FIELDS"] = "$update_fields";
|
|
2568
|
-
})(BentoEvents || (BentoEvents = {}));
|
|
2569
|
-
|
|
2570
|
-
var BentoAPIV1 = /*#__PURE__*/function () {
|
|
2571
|
-
function BentoAPIV1(options) {
|
|
2572
|
-
this._client = void 0;
|
|
2573
|
-
this.Batch = void 0;
|
|
2574
|
-
this.Commands = void 0;
|
|
2575
|
-
this.Experimental = void 0;
|
|
2576
|
-
this.Fields = void 0;
|
|
2577
|
-
this.Forms = void 0;
|
|
2578
|
-
this.Subscribers = void 0;
|
|
2579
|
-
this.Tags = void 0;
|
|
2580
|
-
this._client = new BentoClient(options);
|
|
2581
|
-
this.Batch = new BentoBatch(this._client);
|
|
2582
|
-
this.Commands = new BentoCommands(this._client);
|
|
2583
|
-
this.Experimental = new BentoExperimental(this._client);
|
|
2584
|
-
this.Fields = new BentoFields(this._client);
|
|
2585
|
-
this.Forms = new BentoForms(this._client);
|
|
2586
|
-
this.Subscribers = new BentoSubscribers(this._client);
|
|
2587
|
-
this.Tags = new BentoTags(this._client);
|
|
2588
|
-
}
|
|
2589
|
-
/**
|
|
2590
|
-
* **This TRIGGERS automations!** - If you do not wish to trigger automations, please use the
|
|
2591
|
-
* `Commands.addTag` method.
|
|
2592
|
-
*
|
|
2593
|
-
* Tags a subscriber with the specified email and tag. If either the tag or the user
|
|
2594
|
-
* do not exist, they will be created in the system. If the user already has the tag,
|
|
2595
|
-
* another tag event will be sent, triggering any automations that take place upon a
|
|
2596
|
-
* tag being added to a subscriber. Please be aware of the potential consequences.
|
|
2597
|
-
*
|
|
2598
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
2599
|
-
* to appear in the system.
|
|
2600
|
-
*
|
|
2601
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
2602
|
-
*
|
|
2603
|
-
* @param parameters TagSubscriberParameters
|
|
2604
|
-
* @returns Promise\<boolean\>
|
|
2605
|
-
*/
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
var _proto = BentoAPIV1.prototype;
|
|
2609
|
-
|
|
2610
|
-
_proto.tagSubscriber =
|
|
2611
|
-
/*#__PURE__*/
|
|
2612
|
-
function () {
|
|
2613
|
-
var _tagSubscriber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(parameters) {
|
|
2614
|
-
var result;
|
|
2615
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2616
|
-
while (1) {
|
|
2617
|
-
switch (_context.prev = _context.next) {
|
|
2618
|
-
case 0:
|
|
2619
|
-
_context.next = 2;
|
|
2620
|
-
return this.Batch.importEvents({
|
|
2621
|
-
events: [{
|
|
2622
|
-
date: parameters.date,
|
|
2623
|
-
details: {
|
|
2624
|
-
tag: parameters.tagName
|
|
2625
|
-
},
|
|
2626
|
-
email: parameters.email,
|
|
2627
|
-
type: BentoEvents.TAG
|
|
2628
|
-
}]
|
|
2629
|
-
});
|
|
2630
|
-
|
|
2631
|
-
case 2:
|
|
2632
|
-
result = _context.sent;
|
|
2633
|
-
return _context.abrupt("return", result === 1);
|
|
2634
|
-
|
|
2635
|
-
case 4:
|
|
2636
|
-
case "end":
|
|
2637
|
-
return _context.stop();
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
}, _callee, this);
|
|
2641
|
-
}));
|
|
2642
|
-
|
|
2643
|
-
function tagSubscriber(_x) {
|
|
2644
|
-
return _tagSubscriber.apply(this, arguments);
|
|
2645
|
-
}
|
|
2646
|
-
|
|
2647
|
-
return tagSubscriber;
|
|
2648
|
-
}()
|
|
2649
|
-
/**
|
|
2650
|
-
* **This TRIGGERS automations!** - If you do not wish to trigger automations, please use the
|
|
2651
|
-
* `Commands.subscribe` method.
|
|
2652
|
-
*
|
|
2653
|
-
* Creates a subscriber in the system. If the subscriber already exists, another subscribe event
|
|
2654
|
-
* will be sent, triggering any automations that take place upon subscription. Please be aware
|
|
2655
|
-
* of the potential consequences.
|
|
2656
|
-
*
|
|
2657
|
-
* You may optionally pass any fields that you wish to be set on the subscriber during creation
|
|
2658
|
-
* as well as a `Date` which will backdate the event. If no date is supplied, then the event will
|
|
2659
|
-
* default to the current time.
|
|
2660
|
-
*
|
|
2661
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
2662
|
-
* to appear in the system.
|
|
2663
|
-
*
|
|
2664
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
2665
|
-
*
|
|
2666
|
-
* @param parameters AddSubscriberParameters
|
|
2667
|
-
* @returns Promise\<boolean\>
|
|
2668
|
-
*/
|
|
2669
|
-
;
|
|
2670
|
-
|
|
2671
|
-
_proto.addSubscriber =
|
|
2672
|
-
/*#__PURE__*/
|
|
2673
|
-
function () {
|
|
2674
|
-
var _addSubscriber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(parameters) {
|
|
2675
|
-
var result;
|
|
2676
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2677
|
-
while (1) {
|
|
2678
|
-
switch (_context2.prev = _context2.next) {
|
|
2679
|
-
case 0:
|
|
2680
|
-
_context2.next = 2;
|
|
2681
|
-
return this.Batch.importEvents({
|
|
2682
|
-
events: [{
|
|
2683
|
-
date: parameters.date,
|
|
2684
|
-
email: parameters.email,
|
|
2685
|
-
type: BentoEvents.SUBSCRIBE,
|
|
2686
|
-
fields: parameters.fields || {}
|
|
2687
|
-
}]
|
|
2688
|
-
});
|
|
2689
|
-
|
|
2690
|
-
case 2:
|
|
2691
|
-
result = _context2.sent;
|
|
2692
|
-
return _context2.abrupt("return", result === 1);
|
|
2693
|
-
|
|
2694
|
-
case 4:
|
|
2695
|
-
case "end":
|
|
2696
|
-
return _context2.stop();
|
|
2697
|
-
}
|
|
2698
|
-
}
|
|
2699
|
-
}, _callee2, this);
|
|
2700
|
-
}));
|
|
2701
|
-
|
|
2702
|
-
function addSubscriber(_x2) {
|
|
2703
|
-
return _addSubscriber.apply(this, arguments);
|
|
2704
|
-
}
|
|
2705
|
-
|
|
2706
|
-
return addSubscriber;
|
|
2707
|
-
}()
|
|
2708
|
-
/**
|
|
2709
|
-
* **This TRIGGERS automations!** - If you do not wish to trigger automations, please use the
|
|
2710
|
-
* `Commands.unsubscribe` method.
|
|
2711
|
-
*
|
|
2712
|
-
* Unsubscribes an email in the system. If the email is already unsubscribed, another unsubscribe event
|
|
2713
|
-
* will be sent, triggering any automations that take place upon an unsubscribe happening. Please be aware
|
|
2714
|
-
* of the potential consequences.
|
|
2715
|
-
*
|
|
2716
|
-
* You may optionally pass a `Date` which will backdate the event. If no date is supplied, then the event
|
|
2717
|
-
* will default to the current time.
|
|
2718
|
-
*
|
|
2719
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
2720
|
-
* to appear in the system.
|
|
2721
|
-
*
|
|
2722
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
2723
|
-
*
|
|
2724
|
-
* @param parameters RemoveSubscriberParameters
|
|
2725
|
-
* @returns Promise\<boolean\>
|
|
2726
|
-
*/
|
|
2727
|
-
;
|
|
2728
|
-
|
|
2729
|
-
_proto.removeSubscriber =
|
|
2730
|
-
/*#__PURE__*/
|
|
2731
|
-
function () {
|
|
2732
|
-
var _removeSubscriber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(parameters) {
|
|
2733
|
-
var result;
|
|
2734
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2735
|
-
while (1) {
|
|
2736
|
-
switch (_context3.prev = _context3.next) {
|
|
2737
|
-
case 0:
|
|
2738
|
-
_context3.next = 2;
|
|
2739
|
-
return this.Batch.importEvents({
|
|
2740
|
-
events: [{
|
|
2741
|
-
date: parameters.date,
|
|
2742
|
-
email: parameters.email,
|
|
2743
|
-
type: BentoEvents.UNSUBSCRIBE
|
|
2744
|
-
}]
|
|
2745
|
-
});
|
|
2746
|
-
|
|
2747
|
-
case 2:
|
|
2748
|
-
result = _context3.sent;
|
|
2749
|
-
return _context3.abrupt("return", result === 1);
|
|
2750
|
-
|
|
2751
|
-
case 4:
|
|
2752
|
-
case "end":
|
|
2753
|
-
return _context3.stop();
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
}, _callee3, this);
|
|
2757
|
-
}));
|
|
2758
|
-
|
|
2759
|
-
function removeSubscriber(_x3) {
|
|
2760
|
-
return _removeSubscriber.apply(this, arguments);
|
|
2761
|
-
}
|
|
2762
|
-
|
|
2763
|
-
return removeSubscriber;
|
|
2764
|
-
}()
|
|
2765
|
-
/**
|
|
2766
|
-
* **This TRIGGERS automations!** - If you do not wish to trigger automations, please use the
|
|
2767
|
-
* `Commands.addField` method.
|
|
2768
|
-
*
|
|
2769
|
-
* Sets the passed-in custom fields on the subscriber, creating the subscriber if it does not exist.
|
|
2770
|
-
* If the fields are already set on the subscriber, the event will be sent, triggering any automations
|
|
2771
|
-
* that take place upon fields being updated. Please be aware of the potential consequences.
|
|
2772
|
-
*
|
|
2773
|
-
* You may optionally pass a `Date` which will backdate the event. If no date is supplied, then the event
|
|
2774
|
-
* will default to the current time.
|
|
2775
|
-
*
|
|
2776
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
2777
|
-
* to appear in the system.
|
|
2778
|
-
*
|
|
2779
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
2780
|
-
*
|
|
2781
|
-
* @param parameters UpdateFieldsParameters\<S\>
|
|
2782
|
-
* @returns Promise\<boolean\>
|
|
2783
|
-
*/
|
|
2784
|
-
;
|
|
2785
|
-
|
|
2786
|
-
_proto.updateFields =
|
|
2787
|
-
/*#__PURE__*/
|
|
2788
|
-
function () {
|
|
2789
|
-
var _updateFields = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(parameters) {
|
|
2790
|
-
var result;
|
|
2791
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2792
|
-
while (1) {
|
|
2793
|
-
switch (_context4.prev = _context4.next) {
|
|
2794
|
-
case 0:
|
|
2795
|
-
_context4.next = 2;
|
|
2796
|
-
return this.Batch.importEvents({
|
|
2797
|
-
events: [{
|
|
2798
|
-
date: parameters.date,
|
|
2799
|
-
email: parameters.email,
|
|
2800
|
-
type: BentoEvents.UPDATE_FIELDS,
|
|
2801
|
-
fields: parameters.fields
|
|
2802
|
-
}]
|
|
2803
|
-
});
|
|
2804
|
-
|
|
2805
|
-
case 2:
|
|
2806
|
-
result = _context4.sent;
|
|
2807
|
-
return _context4.abrupt("return", result === 1);
|
|
2808
|
-
|
|
2809
|
-
case 4:
|
|
2810
|
-
case "end":
|
|
2811
|
-
return _context4.stop();
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
|
-
}, _callee4, this);
|
|
2815
|
-
}));
|
|
2816
|
-
|
|
2817
|
-
function updateFields(_x4) {
|
|
2818
|
-
return _updateFields.apply(this, arguments);
|
|
2819
|
-
}
|
|
2820
|
-
|
|
2821
|
-
return updateFields;
|
|
2822
|
-
}()
|
|
2823
|
-
/**
|
|
2824
|
-
* **This TRIGGERS automations!** - There is no way to achieve this same behavior without triggering
|
|
2825
|
-
* automations.
|
|
2826
|
-
*
|
|
2827
|
-
* Tracks a purchase in Bento, used to calculate LTV for your subscribers. The values that are received
|
|
2828
|
-
* should be numbers, in cents. For example, `$1.00` should be `100`.
|
|
2829
|
-
*
|
|
2830
|
-
* You may optionally pass a `Date` which will backdate the event. If no date is supplied, then the event
|
|
2831
|
-
* will default to the current time.
|
|
2832
|
-
*
|
|
2833
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
2834
|
-
* to appear in the system.
|
|
2835
|
-
*
|
|
2836
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
2837
|
-
*
|
|
2838
|
-
* @param parameters TrackPurchaseParameters
|
|
2839
|
-
* @returns Promise\<boolean\>
|
|
2840
|
-
*/
|
|
2841
|
-
;
|
|
2842
|
-
|
|
2843
|
-
_proto.trackPurchase =
|
|
2844
|
-
/*#__PURE__*/
|
|
2845
|
-
function () {
|
|
2846
|
-
var _trackPurchase = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(parameters) {
|
|
2847
|
-
var result;
|
|
2848
|
-
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2849
|
-
while (1) {
|
|
2850
|
-
switch (_context5.prev = _context5.next) {
|
|
2851
|
-
case 0:
|
|
2852
|
-
_context5.next = 2;
|
|
2853
|
-
return this.Batch.importEvents({
|
|
2854
|
-
events: [{
|
|
2855
|
-
date: parameters.date,
|
|
2856
|
-
email: parameters.email,
|
|
2857
|
-
type: BentoEvents.PURCHASE,
|
|
2858
|
-
details: parameters.purchaseDetails
|
|
2859
|
-
}]
|
|
2860
|
-
});
|
|
2861
|
-
|
|
2862
|
-
case 2:
|
|
2863
|
-
result = _context5.sent;
|
|
2864
|
-
return _context5.abrupt("return", result === 1);
|
|
2865
|
-
|
|
2866
|
-
case 4:
|
|
2867
|
-
case "end":
|
|
2868
|
-
return _context5.stop();
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
}, _callee5, this);
|
|
2872
|
-
}));
|
|
2873
|
-
|
|
2874
|
-
function trackPurchase(_x5) {
|
|
2875
|
-
return _trackPurchase.apply(this, arguments);
|
|
2876
|
-
}
|
|
2877
|
-
|
|
2878
|
-
return trackPurchase;
|
|
2879
|
-
}()
|
|
2880
|
-
/**
|
|
2881
|
-
* **This TRIGGERS automations!** - There is no way to achieve this same behavior without triggering
|
|
2882
|
-
* automations.
|
|
2883
|
-
*
|
|
2884
|
-
* Tracks a custom event in Bento.
|
|
2885
|
-
*
|
|
2886
|
-
* You may optionally pass a `Date` which will backdate the event. If no date is supplied, then the event
|
|
2887
|
-
* will default to the current time.
|
|
2888
|
-
*
|
|
2889
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
2890
|
-
* to appear in the system.
|
|
2891
|
-
*
|
|
2892
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
2893
|
-
*
|
|
2894
|
-
* @param parameters TrackParameters<S, E>
|
|
2895
|
-
* @returns Promise\<boolean\>
|
|
2896
|
-
*/
|
|
2897
|
-
;
|
|
2898
|
-
|
|
2899
|
-
_proto.track =
|
|
2900
|
-
/*#__PURE__*/
|
|
2901
|
-
function () {
|
|
2902
|
-
var _track = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(parameters) {
|
|
2903
|
-
var result;
|
|
2904
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2905
|
-
while (1) {
|
|
2906
|
-
switch (_context6.prev = _context6.next) {
|
|
2907
|
-
case 0:
|
|
2908
|
-
_context6.next = 2;
|
|
2909
|
-
return this.Batch.importEvents({
|
|
2910
|
-
events: [parameters]
|
|
2911
|
-
});
|
|
2912
|
-
|
|
2913
|
-
case 2:
|
|
2914
|
-
result = _context6.sent;
|
|
2915
|
-
return _context6.abrupt("return", result === 1);
|
|
2916
|
-
|
|
2917
|
-
case 4:
|
|
2918
|
-
case "end":
|
|
2919
|
-
return _context6.stop();
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
}, _callee6, this);
|
|
2923
|
-
}));
|
|
2924
|
-
|
|
2925
|
-
function track(_x6) {
|
|
2926
|
-
return _track.apply(this, arguments);
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
|
-
return track;
|
|
2930
|
-
}();
|
|
2931
|
-
|
|
2932
|
-
return BentoAPIV1;
|
|
2933
|
-
}();
|
|
2934
|
-
|
|
2935
|
-
var Analytics = function Analytics(options) {
|
|
2936
|
-
this.V1 = void 0;
|
|
2937
|
-
this.V1 = new BentoAPIV1(options);
|
|
2938
|
-
};
|
|
2939
|
-
|
|
2940
|
-
exports.Analytics = Analytics;
|
|
2941
|
-
exports.NotAuthorizedError = NotAuthorizedError;
|
|
2942
|
-
exports.RateLimitedError = RateLimitedError;
|
|
2943
|
-
//# sourceMappingURL=bento-node-sdk.cjs.development.js.map
|