@bentonow/bento-node-sdk 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -572
- package/dist/sdk/workflows/types.d.ts +1 -0
- package/package.json +3 -4
- package/src/sdk/client/index.ts +0 -1
- package/src/sdk/workflows/types.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,570 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
7
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
8
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
9
|
-
for (let key of __getOwnPropNames(mod))
|
|
10
|
-
if (!__hasOwnProp.call(to, key))
|
|
11
|
-
__defProp(to, key, {
|
|
12
|
-
get: () => mod[key],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
18
|
-
|
|
19
|
-
// node_modules/cross-fetch/dist/browser-ponyfill.js
|
|
20
|
-
var require_browser_ponyfill = __commonJS((exports, module) => {
|
|
21
|
-
var __global__ = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || typeof global !== "undefined" && global;
|
|
22
|
-
var __globalThis__ = function() {
|
|
23
|
-
function F() {
|
|
24
|
-
this.fetch = false;
|
|
25
|
-
this.DOMException = __global__.DOMException;
|
|
26
|
-
}
|
|
27
|
-
F.prototype = __global__;
|
|
28
|
-
return new F;
|
|
29
|
-
}();
|
|
30
|
-
(function(globalThis2) {
|
|
31
|
-
var irrelevant = function(exports2) {
|
|
32
|
-
var g = typeof globalThis2 !== "undefined" && globalThis2 || typeof self !== "undefined" && self || typeof global !== "undefined" && global || {};
|
|
33
|
-
var support = {
|
|
34
|
-
searchParams: "URLSearchParams" in g,
|
|
35
|
-
iterable: "Symbol" in g && "iterator" in Symbol,
|
|
36
|
-
blob: "FileReader" in g && "Blob" in g && function() {
|
|
37
|
-
try {
|
|
38
|
-
new Blob;
|
|
39
|
-
return true;
|
|
40
|
-
} catch (e) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}(),
|
|
44
|
-
formData: "FormData" in g,
|
|
45
|
-
arrayBuffer: "ArrayBuffer" in g
|
|
46
|
-
};
|
|
47
|
-
function isDataView(obj) {
|
|
48
|
-
return obj && DataView.prototype.isPrototypeOf(obj);
|
|
49
|
-
}
|
|
50
|
-
if (support.arrayBuffer) {
|
|
51
|
-
var viewClasses = [
|
|
52
|
-
"[object Int8Array]",
|
|
53
|
-
"[object Uint8Array]",
|
|
54
|
-
"[object Uint8ClampedArray]",
|
|
55
|
-
"[object Int16Array]",
|
|
56
|
-
"[object Uint16Array]",
|
|
57
|
-
"[object Int32Array]",
|
|
58
|
-
"[object Uint32Array]",
|
|
59
|
-
"[object Float32Array]",
|
|
60
|
-
"[object Float64Array]"
|
|
61
|
-
];
|
|
62
|
-
var isArrayBufferView = ArrayBuffer.isView || function(obj) {
|
|
63
|
-
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function normalizeName(name) {
|
|
67
|
-
if (typeof name !== "string") {
|
|
68
|
-
name = String(name);
|
|
69
|
-
}
|
|
70
|
-
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
|
|
71
|
-
throw new TypeError('Invalid character in header field name: "' + name + '"');
|
|
72
|
-
}
|
|
73
|
-
return name.toLowerCase();
|
|
74
|
-
}
|
|
75
|
-
function normalizeValue(value) {
|
|
76
|
-
if (typeof value !== "string") {
|
|
77
|
-
value = String(value);
|
|
78
|
-
}
|
|
79
|
-
return value;
|
|
80
|
-
}
|
|
81
|
-
function iteratorFor(items) {
|
|
82
|
-
var iterator = {
|
|
83
|
-
next: function() {
|
|
84
|
-
var value = items.shift();
|
|
85
|
-
return { done: value === undefined, value };
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
if (support.iterable) {
|
|
89
|
-
iterator[Symbol.iterator] = function() {
|
|
90
|
-
return iterator;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
return iterator;
|
|
94
|
-
}
|
|
95
|
-
function Headers(headers) {
|
|
96
|
-
this.map = {};
|
|
97
|
-
if (headers instanceof Headers) {
|
|
98
|
-
headers.forEach(function(value, name) {
|
|
99
|
-
this.append(name, value);
|
|
100
|
-
}, this);
|
|
101
|
-
} else if (Array.isArray(headers)) {
|
|
102
|
-
headers.forEach(function(header) {
|
|
103
|
-
if (header.length != 2) {
|
|
104
|
-
throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
|
|
105
|
-
}
|
|
106
|
-
this.append(header[0], header[1]);
|
|
107
|
-
}, this);
|
|
108
|
-
} else if (headers) {
|
|
109
|
-
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
110
|
-
this.append(name, headers[name]);
|
|
111
|
-
}, this);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
Headers.prototype.append = function(name, value) {
|
|
115
|
-
name = normalizeName(name);
|
|
116
|
-
value = normalizeValue(value);
|
|
117
|
-
var oldValue = this.map[name];
|
|
118
|
-
this.map[name] = oldValue ? oldValue + ", " + value : value;
|
|
119
|
-
};
|
|
120
|
-
Headers.prototype["delete"] = function(name) {
|
|
121
|
-
delete this.map[normalizeName(name)];
|
|
122
|
-
};
|
|
123
|
-
Headers.prototype.get = function(name) {
|
|
124
|
-
name = normalizeName(name);
|
|
125
|
-
return this.has(name) ? this.map[name] : null;
|
|
126
|
-
};
|
|
127
|
-
Headers.prototype.has = function(name) {
|
|
128
|
-
return this.map.hasOwnProperty(normalizeName(name));
|
|
129
|
-
};
|
|
130
|
-
Headers.prototype.set = function(name, value) {
|
|
131
|
-
this.map[normalizeName(name)] = normalizeValue(value);
|
|
132
|
-
};
|
|
133
|
-
Headers.prototype.forEach = function(callback, thisArg) {
|
|
134
|
-
for (var name in this.map) {
|
|
135
|
-
if (this.map.hasOwnProperty(name)) {
|
|
136
|
-
callback.call(thisArg, this.map[name], name, this);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
Headers.prototype.keys = function() {
|
|
141
|
-
var items = [];
|
|
142
|
-
this.forEach(function(value, name) {
|
|
143
|
-
items.push(name);
|
|
144
|
-
});
|
|
145
|
-
return iteratorFor(items);
|
|
146
|
-
};
|
|
147
|
-
Headers.prototype.values = function() {
|
|
148
|
-
var items = [];
|
|
149
|
-
this.forEach(function(value) {
|
|
150
|
-
items.push(value);
|
|
151
|
-
});
|
|
152
|
-
return iteratorFor(items);
|
|
153
|
-
};
|
|
154
|
-
Headers.prototype.entries = function() {
|
|
155
|
-
var items = [];
|
|
156
|
-
this.forEach(function(value, name) {
|
|
157
|
-
items.push([name, value]);
|
|
158
|
-
});
|
|
159
|
-
return iteratorFor(items);
|
|
160
|
-
};
|
|
161
|
-
if (support.iterable) {
|
|
162
|
-
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
|
|
163
|
-
}
|
|
164
|
-
function consumed(body) {
|
|
165
|
-
if (body._noBody)
|
|
166
|
-
return;
|
|
167
|
-
if (body.bodyUsed) {
|
|
168
|
-
return Promise.reject(new TypeError("Already read"));
|
|
169
|
-
}
|
|
170
|
-
body.bodyUsed = true;
|
|
171
|
-
}
|
|
172
|
-
function fileReaderReady(reader) {
|
|
173
|
-
return new Promise(function(resolve, reject) {
|
|
174
|
-
reader.onload = function() {
|
|
175
|
-
resolve(reader.result);
|
|
176
|
-
};
|
|
177
|
-
reader.onerror = function() {
|
|
178
|
-
reject(reader.error);
|
|
179
|
-
};
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
function readBlobAsArrayBuffer(blob) {
|
|
183
|
-
var reader = new FileReader;
|
|
184
|
-
var promise = fileReaderReady(reader);
|
|
185
|
-
reader.readAsArrayBuffer(blob);
|
|
186
|
-
return promise;
|
|
187
|
-
}
|
|
188
|
-
function readBlobAsText(blob) {
|
|
189
|
-
var reader = new FileReader;
|
|
190
|
-
var promise = fileReaderReady(reader);
|
|
191
|
-
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
|
|
192
|
-
var encoding = match ? match[1] : "utf-8";
|
|
193
|
-
reader.readAsText(blob, encoding);
|
|
194
|
-
return promise;
|
|
195
|
-
}
|
|
196
|
-
function readArrayBufferAsText(buf) {
|
|
197
|
-
var view = new Uint8Array(buf);
|
|
198
|
-
var chars = new Array(view.length);
|
|
199
|
-
for (var i = 0;i < view.length; i++) {
|
|
200
|
-
chars[i] = String.fromCharCode(view[i]);
|
|
201
|
-
}
|
|
202
|
-
return chars.join("");
|
|
203
|
-
}
|
|
204
|
-
function bufferClone(buf) {
|
|
205
|
-
if (buf.slice) {
|
|
206
|
-
return buf.slice(0);
|
|
207
|
-
} else {
|
|
208
|
-
var view = new Uint8Array(buf.byteLength);
|
|
209
|
-
view.set(new Uint8Array(buf));
|
|
210
|
-
return view.buffer;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function Body() {
|
|
214
|
-
this.bodyUsed = false;
|
|
215
|
-
this._initBody = function(body) {
|
|
216
|
-
this.bodyUsed = this.bodyUsed;
|
|
217
|
-
this._bodyInit = body;
|
|
218
|
-
if (!body) {
|
|
219
|
-
this._noBody = true;
|
|
220
|
-
this._bodyText = "";
|
|
221
|
-
} else if (typeof body === "string") {
|
|
222
|
-
this._bodyText = body;
|
|
223
|
-
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
224
|
-
this._bodyBlob = body;
|
|
225
|
-
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
226
|
-
this._bodyFormData = body;
|
|
227
|
-
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
228
|
-
this._bodyText = body.toString();
|
|
229
|
-
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
230
|
-
this._bodyArrayBuffer = bufferClone(body.buffer);
|
|
231
|
-
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
|
232
|
-
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
233
|
-
this._bodyArrayBuffer = bufferClone(body);
|
|
234
|
-
} else {
|
|
235
|
-
this._bodyText = body = Object.prototype.toString.call(body);
|
|
236
|
-
}
|
|
237
|
-
if (!this.headers.get("content-type")) {
|
|
238
|
-
if (typeof body === "string") {
|
|
239
|
-
this.headers.set("content-type", "text/plain;charset=UTF-8");
|
|
240
|
-
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
241
|
-
this.headers.set("content-type", this._bodyBlob.type);
|
|
242
|
-
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
243
|
-
this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
if (support.blob) {
|
|
248
|
-
this.blob = function() {
|
|
249
|
-
var rejected = consumed(this);
|
|
250
|
-
if (rejected) {
|
|
251
|
-
return rejected;
|
|
252
|
-
}
|
|
253
|
-
if (this._bodyBlob) {
|
|
254
|
-
return Promise.resolve(this._bodyBlob);
|
|
255
|
-
} else if (this._bodyArrayBuffer) {
|
|
256
|
-
return Promise.resolve(new Blob([this._bodyArrayBuffer]));
|
|
257
|
-
} else if (this._bodyFormData) {
|
|
258
|
-
throw new Error("could not read FormData body as blob");
|
|
259
|
-
} else {
|
|
260
|
-
return Promise.resolve(new Blob([this._bodyText]));
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
this.arrayBuffer = function() {
|
|
265
|
-
if (this._bodyArrayBuffer) {
|
|
266
|
-
var isConsumed = consumed(this);
|
|
267
|
-
if (isConsumed) {
|
|
268
|
-
return isConsumed;
|
|
269
|
-
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
|
270
|
-
return Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset, this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength));
|
|
271
|
-
} else {
|
|
272
|
-
return Promise.resolve(this._bodyArrayBuffer);
|
|
273
|
-
}
|
|
274
|
-
} else if (support.blob) {
|
|
275
|
-
return this.blob().then(readBlobAsArrayBuffer);
|
|
276
|
-
} else {
|
|
277
|
-
throw new Error("could not read as ArrayBuffer");
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
this.text = function() {
|
|
281
|
-
var rejected = consumed(this);
|
|
282
|
-
if (rejected) {
|
|
283
|
-
return rejected;
|
|
284
|
-
}
|
|
285
|
-
if (this._bodyBlob) {
|
|
286
|
-
return readBlobAsText(this._bodyBlob);
|
|
287
|
-
} else if (this._bodyArrayBuffer) {
|
|
288
|
-
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
|
|
289
|
-
} else if (this._bodyFormData) {
|
|
290
|
-
throw new Error("could not read FormData body as text");
|
|
291
|
-
} else {
|
|
292
|
-
return Promise.resolve(this._bodyText);
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
if (support.formData) {
|
|
296
|
-
this.formData = function() {
|
|
297
|
-
return this.text().then(decode);
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
this.json = function() {
|
|
301
|
-
return this.text().then(JSON.parse);
|
|
302
|
-
};
|
|
303
|
-
return this;
|
|
304
|
-
}
|
|
305
|
-
var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
|
|
306
|
-
function normalizeMethod(method) {
|
|
307
|
-
var upcased = method.toUpperCase();
|
|
308
|
-
return methods.indexOf(upcased) > -1 ? upcased : method;
|
|
309
|
-
}
|
|
310
|
-
function Request(input, options) {
|
|
311
|
-
if (!(this instanceof Request)) {
|
|
312
|
-
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
313
|
-
}
|
|
314
|
-
options = options || {};
|
|
315
|
-
var body = options.body;
|
|
316
|
-
if (input instanceof Request) {
|
|
317
|
-
if (input.bodyUsed) {
|
|
318
|
-
throw new TypeError("Already read");
|
|
319
|
-
}
|
|
320
|
-
this.url = input.url;
|
|
321
|
-
this.credentials = input.credentials;
|
|
322
|
-
if (!options.headers) {
|
|
323
|
-
this.headers = new Headers(input.headers);
|
|
324
|
-
}
|
|
325
|
-
this.method = input.method;
|
|
326
|
-
this.mode = input.mode;
|
|
327
|
-
this.signal = input.signal;
|
|
328
|
-
if (!body && input._bodyInit != null) {
|
|
329
|
-
body = input._bodyInit;
|
|
330
|
-
input.bodyUsed = true;
|
|
331
|
-
}
|
|
332
|
-
} else {
|
|
333
|
-
this.url = String(input);
|
|
334
|
-
}
|
|
335
|
-
this.credentials = options.credentials || this.credentials || "same-origin";
|
|
336
|
-
if (options.headers || !this.headers) {
|
|
337
|
-
this.headers = new Headers(options.headers);
|
|
338
|
-
}
|
|
339
|
-
this.method = normalizeMethod(options.method || this.method || "GET");
|
|
340
|
-
this.mode = options.mode || this.mode || null;
|
|
341
|
-
this.signal = options.signal || this.signal || function() {
|
|
342
|
-
if ("AbortController" in g) {
|
|
343
|
-
var ctrl = new AbortController;
|
|
344
|
-
return ctrl.signal;
|
|
345
|
-
}
|
|
346
|
-
}();
|
|
347
|
-
this.referrer = null;
|
|
348
|
-
if ((this.method === "GET" || this.method === "HEAD") && body) {
|
|
349
|
-
throw new TypeError("Body not allowed for GET or HEAD requests");
|
|
350
|
-
}
|
|
351
|
-
this._initBody(body);
|
|
352
|
-
if (this.method === "GET" || this.method === "HEAD") {
|
|
353
|
-
if (options.cache === "no-store" || options.cache === "no-cache") {
|
|
354
|
-
var reParamSearch = /([?&])_=[^&]*/;
|
|
355
|
-
if (reParamSearch.test(this.url)) {
|
|
356
|
-
this.url = this.url.replace(reParamSearch, "$1_=" + new Date().getTime());
|
|
357
|
-
} else {
|
|
358
|
-
var reQueryString = /\?/;
|
|
359
|
-
this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + new Date().getTime();
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
Request.prototype.clone = function() {
|
|
365
|
-
return new Request(this, { body: this._bodyInit });
|
|
366
|
-
};
|
|
367
|
-
function decode(body) {
|
|
368
|
-
var form = new FormData;
|
|
369
|
-
body.trim().split("&").forEach(function(bytes) {
|
|
370
|
-
if (bytes) {
|
|
371
|
-
var split = bytes.split("=");
|
|
372
|
-
var name = split.shift().replace(/\+/g, " ");
|
|
373
|
-
var value = split.join("=").replace(/\+/g, " ");
|
|
374
|
-
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
return form;
|
|
378
|
-
}
|
|
379
|
-
function parseHeaders(rawHeaders) {
|
|
380
|
-
var headers = new Headers;
|
|
381
|
-
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
|
|
382
|
-
preProcessedHeaders.split("\r").map(function(header) {
|
|
383
|
-
return header.indexOf(`
|
|
384
|
-
`) === 0 ? header.substr(1, header.length) : header;
|
|
385
|
-
}).forEach(function(line) {
|
|
386
|
-
var parts = line.split(":");
|
|
387
|
-
var key = parts.shift().trim();
|
|
388
|
-
if (key) {
|
|
389
|
-
var value = parts.join(":").trim();
|
|
390
|
-
try {
|
|
391
|
-
headers.append(key, value);
|
|
392
|
-
} catch (error) {
|
|
393
|
-
console.warn("Response " + error.message);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
return headers;
|
|
398
|
-
}
|
|
399
|
-
Body.call(Request.prototype);
|
|
400
|
-
function Response(bodyInit, options) {
|
|
401
|
-
if (!(this instanceof Response)) {
|
|
402
|
-
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
403
|
-
}
|
|
404
|
-
if (!options) {
|
|
405
|
-
options = {};
|
|
406
|
-
}
|
|
407
|
-
this.type = "default";
|
|
408
|
-
this.status = options.status === undefined ? 200 : options.status;
|
|
409
|
-
if (this.status < 200 || this.status > 599) {
|
|
410
|
-
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
|
|
411
|
-
}
|
|
412
|
-
this.ok = this.status >= 200 && this.status < 300;
|
|
413
|
-
this.statusText = options.statusText === undefined ? "" : "" + options.statusText;
|
|
414
|
-
this.headers = new Headers(options.headers);
|
|
415
|
-
this.url = options.url || "";
|
|
416
|
-
this._initBody(bodyInit);
|
|
417
|
-
}
|
|
418
|
-
Body.call(Response.prototype);
|
|
419
|
-
Response.prototype.clone = function() {
|
|
420
|
-
return new Response(this._bodyInit, {
|
|
421
|
-
status: this.status,
|
|
422
|
-
statusText: this.statusText,
|
|
423
|
-
headers: new Headers(this.headers),
|
|
424
|
-
url: this.url
|
|
425
|
-
});
|
|
426
|
-
};
|
|
427
|
-
Response.error = function() {
|
|
428
|
-
var response = new Response(null, { status: 200, statusText: "" });
|
|
429
|
-
response.ok = false;
|
|
430
|
-
response.status = 0;
|
|
431
|
-
response.type = "error";
|
|
432
|
-
return response;
|
|
433
|
-
};
|
|
434
|
-
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
435
|
-
Response.redirect = function(url, status) {
|
|
436
|
-
if (redirectStatuses.indexOf(status) === -1) {
|
|
437
|
-
throw new RangeError("Invalid status code");
|
|
438
|
-
}
|
|
439
|
-
return new Response(null, { status, headers: { location: url } });
|
|
440
|
-
};
|
|
441
|
-
exports2.DOMException = g.DOMException;
|
|
442
|
-
try {
|
|
443
|
-
new exports2.DOMException;
|
|
444
|
-
} catch (err) {
|
|
445
|
-
exports2.DOMException = function(message, name) {
|
|
446
|
-
this.message = message;
|
|
447
|
-
this.name = name;
|
|
448
|
-
var error = Error(message);
|
|
449
|
-
this.stack = error.stack;
|
|
450
|
-
};
|
|
451
|
-
exports2.DOMException.prototype = Object.create(Error.prototype);
|
|
452
|
-
exports2.DOMException.prototype.constructor = exports2.DOMException;
|
|
453
|
-
}
|
|
454
|
-
function fetch(input, init) {
|
|
455
|
-
return new Promise(function(resolve, reject) {
|
|
456
|
-
var request = new Request(input, init);
|
|
457
|
-
if (request.signal && request.signal.aborted) {
|
|
458
|
-
return reject(new exports2.DOMException("Aborted", "AbortError"));
|
|
459
|
-
}
|
|
460
|
-
var xhr = new XMLHttpRequest;
|
|
461
|
-
function abortXhr() {
|
|
462
|
-
xhr.abort();
|
|
463
|
-
}
|
|
464
|
-
xhr.onload = function() {
|
|
465
|
-
var options = {
|
|
466
|
-
statusText: xhr.statusText,
|
|
467
|
-
headers: parseHeaders(xhr.getAllResponseHeaders() || "")
|
|
468
|
-
};
|
|
469
|
-
if (request.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
470
|
-
options.status = 200;
|
|
471
|
-
} else {
|
|
472
|
-
options.status = xhr.status;
|
|
473
|
-
}
|
|
474
|
-
options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
|
|
475
|
-
var body = "response" in xhr ? xhr.response : xhr.responseText;
|
|
476
|
-
setTimeout(function() {
|
|
477
|
-
resolve(new Response(body, options));
|
|
478
|
-
}, 0);
|
|
479
|
-
};
|
|
480
|
-
xhr.onerror = function() {
|
|
481
|
-
setTimeout(function() {
|
|
482
|
-
reject(new TypeError("Network request failed"));
|
|
483
|
-
}, 0);
|
|
484
|
-
};
|
|
485
|
-
xhr.ontimeout = function() {
|
|
486
|
-
setTimeout(function() {
|
|
487
|
-
reject(new TypeError("Network request timed out"));
|
|
488
|
-
}, 0);
|
|
489
|
-
};
|
|
490
|
-
xhr.onabort = function() {
|
|
491
|
-
setTimeout(function() {
|
|
492
|
-
reject(new exports2.DOMException("Aborted", "AbortError"));
|
|
493
|
-
}, 0);
|
|
494
|
-
};
|
|
495
|
-
function fixUrl(url) {
|
|
496
|
-
try {
|
|
497
|
-
return url === "" && g.location.href ? g.location.href : url;
|
|
498
|
-
} catch (e) {
|
|
499
|
-
return url;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
xhr.open(request.method, fixUrl(request.url), true);
|
|
503
|
-
if (request.credentials === "include") {
|
|
504
|
-
xhr.withCredentials = true;
|
|
505
|
-
} else if (request.credentials === "omit") {
|
|
506
|
-
xhr.withCredentials = false;
|
|
507
|
-
}
|
|
508
|
-
if ("responseType" in xhr) {
|
|
509
|
-
if (support.blob) {
|
|
510
|
-
xhr.responseType = "blob";
|
|
511
|
-
} else if (support.arrayBuffer) {
|
|
512
|
-
xhr.responseType = "arraybuffer";
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
if (init && typeof init.headers === "object" && !(init.headers instanceof Headers || g.Headers && init.headers instanceof g.Headers)) {
|
|
516
|
-
var names = [];
|
|
517
|
-
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
|
518
|
-
names.push(normalizeName(name));
|
|
519
|
-
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
|
520
|
-
});
|
|
521
|
-
request.headers.forEach(function(value, name) {
|
|
522
|
-
if (names.indexOf(name) === -1) {
|
|
523
|
-
xhr.setRequestHeader(name, value);
|
|
524
|
-
}
|
|
525
|
-
});
|
|
526
|
-
} else {
|
|
527
|
-
request.headers.forEach(function(value, name) {
|
|
528
|
-
xhr.setRequestHeader(name, value);
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
if (request.signal) {
|
|
532
|
-
request.signal.addEventListener("abort", abortXhr);
|
|
533
|
-
xhr.onreadystatechange = function() {
|
|
534
|
-
if (xhr.readyState === 4) {
|
|
535
|
-
request.signal.removeEventListener("abort", abortXhr);
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
fetch.polyfill = true;
|
|
543
|
-
if (!g.fetch) {
|
|
544
|
-
g.fetch = fetch;
|
|
545
|
-
g.Headers = Headers;
|
|
546
|
-
g.Request = Request;
|
|
547
|
-
g.Response = Response;
|
|
548
|
-
}
|
|
549
|
-
exports2.Headers = Headers;
|
|
550
|
-
exports2.Request = Request;
|
|
551
|
-
exports2.Response = Response;
|
|
552
|
-
exports2.fetch = fetch;
|
|
553
|
-
return exports2;
|
|
554
|
-
}({});
|
|
555
|
-
})(__globalThis__);
|
|
556
|
-
__globalThis__.fetch.ponyfill = true;
|
|
557
|
-
delete __globalThis__.fetch.polyfill;
|
|
558
|
-
var ctx = __global__.fetch ? __global__ : __globalThis__;
|
|
559
|
-
exports = ctx.fetch;
|
|
560
|
-
exports.default = ctx.fetch;
|
|
561
|
-
exports.fetch = ctx.fetch;
|
|
562
|
-
exports.Headers = ctx.Headers;
|
|
563
|
-
exports.Request = ctx.Request;
|
|
564
|
-
exports.Response = ctx.Response;
|
|
565
|
-
module.exports = exports;
|
|
566
|
-
});
|
|
567
|
-
|
|
568
1
|
// src/sdk/batch/errors.ts
|
|
569
2
|
class TooFewSubscribersError extends Error {
|
|
570
3
|
constructor(message = "Too few subscribers") {
|
|
@@ -654,9 +87,6 @@ class BentoBatch {
|
|
|
654
87
|
return result.results;
|
|
655
88
|
}
|
|
656
89
|
}
|
|
657
|
-
// src/sdk/client/index.ts
|
|
658
|
-
var import_cross_fetch = __toESM(require_browser_ponyfill(), 1);
|
|
659
|
-
|
|
660
90
|
// src/sdk/client/errors.ts
|
|
661
91
|
class NotAuthorizedError extends Error {
|
|
662
92
|
constructor(message = "Not authorized") {
|
|
@@ -759,12 +189,12 @@ class BentoClient {
|
|
|
759
189
|
}
|
|
760
190
|
async _fetchWithTimeout(url, options, timeout) {
|
|
761
191
|
if (timeout === null) {
|
|
762
|
-
return
|
|
192
|
+
return fetch(url, options);
|
|
763
193
|
}
|
|
764
194
|
const controller = new AbortController;
|
|
765
195
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
766
196
|
try {
|
|
767
|
-
const response = await
|
|
197
|
+
const response = await fetch(url, {
|
|
768
198
|
...options,
|
|
769
199
|
signal: controller.signal
|
|
770
200
|
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bentonow/bento-node-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "🍱 Bento Node.JS SDK and tracking library",
|
|
5
5
|
"author": "Backpack Internet",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"main": "dist/index.js",
|
|
8
9
|
"module": "dist/index.js",
|
|
9
10
|
"types": "dist/index.d.ts",
|
|
@@ -46,9 +47,7 @@
|
|
|
46
47
|
"ts-jest": "^29.4.6",
|
|
47
48
|
"typescript": "^5.7.3"
|
|
48
49
|
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"cross-fetch": "^4.1.0"
|
|
51
|
-
},
|
|
50
|
+
"dependencies": {},
|
|
52
51
|
"size-limit": [
|
|
53
52
|
{
|
|
54
53
|
"path": "dist/index.js",
|
package/src/sdk/client/index.ts
CHANGED