@thescaffold/jsx-polylog 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -0
- package/common/init/config.d.ts +2 -0
- package/common/init/index.d.ts +2 -0
- package/common/queue/index.d.ts +4 -0
- package/common/utils/functions.d.ts +8 -0
- package/common/utils/values.d.ts +197 -0
- package/events/index.d.ts +4 -0
- package/index.d.ts +13 -0
- package/index.js +8 -0
- package/jsx-polylog.cjs.development.js +823 -0
- package/jsx-polylog.cjs.development.js.map +1 -0
- package/jsx-polylog.cjs.production.min.js +2 -0
- package/jsx-polylog.cjs.production.min.js.map +1 -0
- package/jsx-polylog.esm.js +809 -0
- package/jsx-polylog.esm.js.map +1 -0
- package/package.json +16 -0
- package/platform/base-entity-service.service.d.ts +13 -0
- package/platform/base-service.service.d.ts +9 -0
- package/platform/index.d.ts +2 -0
- package/request/batch.d.ts +1 -0
- package/request/index.d.ts +2 -0
- package/request/methods.d.ts +8 -0
|
@@ -0,0 +1,823 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
4
|
+
try {
|
|
5
|
+
var i = n[a](c),
|
|
6
|
+
u = i.value;
|
|
7
|
+
} catch (n) {
|
|
8
|
+
return void e(n);
|
|
9
|
+
}
|
|
10
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
11
|
+
}
|
|
12
|
+
function _asyncToGenerator(n) {
|
|
13
|
+
return function () {
|
|
14
|
+
var t = this,
|
|
15
|
+
e = arguments;
|
|
16
|
+
return new Promise(function (r, o) {
|
|
17
|
+
var a = n.apply(t, e);
|
|
18
|
+
function _next(n) {
|
|
19
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
20
|
+
}
|
|
21
|
+
function _throw(n) {
|
|
22
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
23
|
+
}
|
|
24
|
+
_next(void 0);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function _extends() {
|
|
29
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
30
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
31
|
+
var t = arguments[e];
|
|
32
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
33
|
+
}
|
|
34
|
+
return n;
|
|
35
|
+
}, _extends.apply(null, arguments);
|
|
36
|
+
}
|
|
37
|
+
function _inheritsLoose(t, o) {
|
|
38
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
39
|
+
}
|
|
40
|
+
function _regeneratorRuntime() {
|
|
41
|
+
_regeneratorRuntime = function () {
|
|
42
|
+
return e;
|
|
43
|
+
};
|
|
44
|
+
var t,
|
|
45
|
+
e = {},
|
|
46
|
+
r = Object.prototype,
|
|
47
|
+
n = r.hasOwnProperty,
|
|
48
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
49
|
+
t[e] = r.value;
|
|
50
|
+
},
|
|
51
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
52
|
+
a = i.iterator || "@@iterator",
|
|
53
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
54
|
+
u = i.toStringTag || "@@toStringTag";
|
|
55
|
+
function define(t, e, r) {
|
|
56
|
+
return Object.defineProperty(t, e, {
|
|
57
|
+
value: r,
|
|
58
|
+
enumerable: !0,
|
|
59
|
+
configurable: !0,
|
|
60
|
+
writable: !0
|
|
61
|
+
}), t[e];
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
define({}, "");
|
|
65
|
+
} catch (t) {
|
|
66
|
+
define = function (t, e, r) {
|
|
67
|
+
return t[e] = r;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function wrap(t, e, r, n) {
|
|
71
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
72
|
+
a = Object.create(i.prototype),
|
|
73
|
+
c = new Context(n || []);
|
|
74
|
+
return o(a, "_invoke", {
|
|
75
|
+
value: makeInvokeMethod(t, r, c)
|
|
76
|
+
}), a;
|
|
77
|
+
}
|
|
78
|
+
function tryCatch(t, e, r) {
|
|
79
|
+
try {
|
|
80
|
+
return {
|
|
81
|
+
type: "normal",
|
|
82
|
+
arg: t.call(e, r)
|
|
83
|
+
};
|
|
84
|
+
} catch (t) {
|
|
85
|
+
return {
|
|
86
|
+
type: "throw",
|
|
87
|
+
arg: t
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
e.wrap = wrap;
|
|
92
|
+
var h = "suspendedStart",
|
|
93
|
+
l = "suspendedYield",
|
|
94
|
+
f = "executing",
|
|
95
|
+
s = "completed",
|
|
96
|
+
y = {};
|
|
97
|
+
function Generator() {}
|
|
98
|
+
function GeneratorFunction() {}
|
|
99
|
+
function GeneratorFunctionPrototype() {}
|
|
100
|
+
var p = {};
|
|
101
|
+
define(p, a, function () {
|
|
102
|
+
return this;
|
|
103
|
+
});
|
|
104
|
+
var d = Object.getPrototypeOf,
|
|
105
|
+
v = d && d(d(values([])));
|
|
106
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
107
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
108
|
+
function defineIteratorMethods(t) {
|
|
109
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
110
|
+
define(t, e, function (t) {
|
|
111
|
+
return this._invoke(e, t);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function AsyncIterator(t, e) {
|
|
116
|
+
function invoke(r, o, i, a) {
|
|
117
|
+
var c = tryCatch(t[r], t, o);
|
|
118
|
+
if ("throw" !== c.type) {
|
|
119
|
+
var u = c.arg,
|
|
120
|
+
h = u.value;
|
|
121
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
122
|
+
invoke("next", t, i, a);
|
|
123
|
+
}, function (t) {
|
|
124
|
+
invoke("throw", t, i, a);
|
|
125
|
+
}) : e.resolve(h).then(function (t) {
|
|
126
|
+
u.value = t, i(u);
|
|
127
|
+
}, function (t) {
|
|
128
|
+
return invoke("throw", t, i, a);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
a(c.arg);
|
|
132
|
+
}
|
|
133
|
+
var r;
|
|
134
|
+
o(this, "_invoke", {
|
|
135
|
+
value: function (t, n) {
|
|
136
|
+
function callInvokeWithMethodAndArg() {
|
|
137
|
+
return new e(function (e, r) {
|
|
138
|
+
invoke(t, n, e, r);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function makeInvokeMethod(e, r, n) {
|
|
146
|
+
var o = h;
|
|
147
|
+
return function (i, a) {
|
|
148
|
+
if (o === f) throw Error("Generator is already running");
|
|
149
|
+
if (o === s) {
|
|
150
|
+
if ("throw" === i) throw a;
|
|
151
|
+
return {
|
|
152
|
+
value: t,
|
|
153
|
+
done: !0
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
for (n.method = i, n.arg = a;;) {
|
|
157
|
+
var c = n.delegate;
|
|
158
|
+
if (c) {
|
|
159
|
+
var u = maybeInvokeDelegate(c, n);
|
|
160
|
+
if (u) {
|
|
161
|
+
if (u === y) continue;
|
|
162
|
+
return u;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
166
|
+
if (o === h) throw o = s, n.arg;
|
|
167
|
+
n.dispatchException(n.arg);
|
|
168
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
169
|
+
o = f;
|
|
170
|
+
var p = tryCatch(e, r, n);
|
|
171
|
+
if ("normal" === p.type) {
|
|
172
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
173
|
+
return {
|
|
174
|
+
value: p.arg,
|
|
175
|
+
done: n.done
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function maybeInvokeDelegate(e, r) {
|
|
183
|
+
var n = r.method,
|
|
184
|
+
o = e.iterator[n];
|
|
185
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
186
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
187
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
188
|
+
var a = i.arg;
|
|
189
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
190
|
+
}
|
|
191
|
+
function pushTryEntry(t) {
|
|
192
|
+
var e = {
|
|
193
|
+
tryLoc: t[0]
|
|
194
|
+
};
|
|
195
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
196
|
+
}
|
|
197
|
+
function resetTryEntry(t) {
|
|
198
|
+
var e = t.completion || {};
|
|
199
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
200
|
+
}
|
|
201
|
+
function Context(t) {
|
|
202
|
+
this.tryEntries = [{
|
|
203
|
+
tryLoc: "root"
|
|
204
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
205
|
+
}
|
|
206
|
+
function values(e) {
|
|
207
|
+
if (e || "" === e) {
|
|
208
|
+
var r = e[a];
|
|
209
|
+
if (r) return r.call(e);
|
|
210
|
+
if ("function" == typeof e.next) return e;
|
|
211
|
+
if (!isNaN(e.length)) {
|
|
212
|
+
var o = -1,
|
|
213
|
+
i = function next() {
|
|
214
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
215
|
+
return next.value = t, next.done = !0, next;
|
|
216
|
+
};
|
|
217
|
+
return i.next = i;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
221
|
+
}
|
|
222
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
223
|
+
value: GeneratorFunctionPrototype,
|
|
224
|
+
configurable: !0
|
|
225
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
226
|
+
value: GeneratorFunction,
|
|
227
|
+
configurable: !0
|
|
228
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
229
|
+
var e = "function" == typeof t && t.constructor;
|
|
230
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
231
|
+
}, e.mark = function (t) {
|
|
232
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
233
|
+
}, e.awrap = function (t) {
|
|
234
|
+
return {
|
|
235
|
+
__await: t
|
|
236
|
+
};
|
|
237
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
238
|
+
return this;
|
|
239
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
240
|
+
void 0 === i && (i = Promise);
|
|
241
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
242
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
243
|
+
return t.done ? t.value : a.next();
|
|
244
|
+
});
|
|
245
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
246
|
+
return this;
|
|
247
|
+
}), define(g, "toString", function () {
|
|
248
|
+
return "[object Generator]";
|
|
249
|
+
}), e.keys = function (t) {
|
|
250
|
+
var e = Object(t),
|
|
251
|
+
r = [];
|
|
252
|
+
for (var n in e) r.push(n);
|
|
253
|
+
return r.reverse(), function next() {
|
|
254
|
+
for (; r.length;) {
|
|
255
|
+
var t = r.pop();
|
|
256
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
257
|
+
}
|
|
258
|
+
return next.done = !0, next;
|
|
259
|
+
};
|
|
260
|
+
}, e.values = values, Context.prototype = {
|
|
261
|
+
constructor: Context,
|
|
262
|
+
reset: function (e) {
|
|
263
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
264
|
+
},
|
|
265
|
+
stop: function () {
|
|
266
|
+
this.done = !0;
|
|
267
|
+
var t = this.tryEntries[0].completion;
|
|
268
|
+
if ("throw" === t.type) throw t.arg;
|
|
269
|
+
return this.rval;
|
|
270
|
+
},
|
|
271
|
+
dispatchException: function (e) {
|
|
272
|
+
if (this.done) throw e;
|
|
273
|
+
var r = this;
|
|
274
|
+
function handle(n, o) {
|
|
275
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
276
|
+
}
|
|
277
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
278
|
+
var i = this.tryEntries[o],
|
|
279
|
+
a = i.completion;
|
|
280
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
281
|
+
if (i.tryLoc <= this.prev) {
|
|
282
|
+
var c = n.call(i, "catchLoc"),
|
|
283
|
+
u = n.call(i, "finallyLoc");
|
|
284
|
+
if (c && u) {
|
|
285
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
286
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
287
|
+
} else if (c) {
|
|
288
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
289
|
+
} else {
|
|
290
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
291
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
abrupt: function (t, e) {
|
|
297
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
298
|
+
var o = this.tryEntries[r];
|
|
299
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
300
|
+
var i = o;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
305
|
+
var a = i ? i.completion : {};
|
|
306
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
307
|
+
},
|
|
308
|
+
complete: function (t, e) {
|
|
309
|
+
if ("throw" === t.type) throw t.arg;
|
|
310
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
311
|
+
},
|
|
312
|
+
finish: function (t) {
|
|
313
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
314
|
+
var r = this.tryEntries[e];
|
|
315
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
catch: function (t) {
|
|
319
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
320
|
+
var r = this.tryEntries[e];
|
|
321
|
+
if (r.tryLoc === t) {
|
|
322
|
+
var n = r.completion;
|
|
323
|
+
if ("throw" === n.type) {
|
|
324
|
+
var o = n.arg;
|
|
325
|
+
resetTryEntry(r);
|
|
326
|
+
}
|
|
327
|
+
return o;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
throw Error("illegal catch attempt");
|
|
331
|
+
},
|
|
332
|
+
delegateYield: function (e, r, n) {
|
|
333
|
+
return this.delegate = {
|
|
334
|
+
iterator: values(e),
|
|
335
|
+
resultName: r,
|
|
336
|
+
nextLoc: n
|
|
337
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
338
|
+
}
|
|
339
|
+
}, e;
|
|
340
|
+
}
|
|
341
|
+
function _setPrototypeOf(t, e) {
|
|
342
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
343
|
+
return t.__proto__ = e, t;
|
|
344
|
+
}, _setPrototypeOf(t, e);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
exports.EventEntityType = void 0;
|
|
348
|
+
(function (EventEntityType) {
|
|
349
|
+
EventEntityType["Source"] = "source";
|
|
350
|
+
EventEntityType["Channel"] = "channel";
|
|
351
|
+
})(exports.EventEntityType || (exports.EventEntityType = {}));
|
|
352
|
+
exports.CategoryType = void 0;
|
|
353
|
+
(function (CategoryType) {
|
|
354
|
+
CategoryType["Form"] = "form";
|
|
355
|
+
CategoryType["File"] = "file";
|
|
356
|
+
CategoryType["Webhook"] = "webhook";
|
|
357
|
+
CategoryType["Job"] = "job";
|
|
358
|
+
CategoryType["Event"] = "event";
|
|
359
|
+
CategoryType["Log"] = "log";
|
|
360
|
+
CategoryType["Motion"] = "motion";
|
|
361
|
+
CategoryType["Message"] = "message";
|
|
362
|
+
CategoryType["Others"] = "others";
|
|
363
|
+
})(exports.CategoryType || (exports.CategoryType = {}));
|
|
364
|
+
exports.LogType = void 0;
|
|
365
|
+
(function (LogType) {
|
|
366
|
+
LogType["INFO"] = "info";
|
|
367
|
+
LogType["WARN"] = "warn";
|
|
368
|
+
LogType["ERROR"] = "error";
|
|
369
|
+
})(exports.LogType || (exports.LogType = {}));
|
|
370
|
+
|
|
371
|
+
var config = {
|
|
372
|
+
server: '',
|
|
373
|
+
credential: '',
|
|
374
|
+
sourceId: '',
|
|
375
|
+
batch: {
|
|
376
|
+
interval: 5 * 1000,
|
|
377
|
+
backoff: 30 * 1000,
|
|
378
|
+
limit: 3
|
|
379
|
+
},
|
|
380
|
+
log: {
|
|
381
|
+
auto: false
|
|
382
|
+
},
|
|
383
|
+
event: {
|
|
384
|
+
auto: true,
|
|
385
|
+
names: []
|
|
386
|
+
},
|
|
387
|
+
logs: [exports.LogType.ERROR],
|
|
388
|
+
debug: false
|
|
389
|
+
};
|
|
390
|
+
var getConfig = function getConfig() {
|
|
391
|
+
return config;
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
var isObject = function isObject(x) {
|
|
395
|
+
return typeof x === 'object' && !Array.isArray(x) && x !== null;
|
|
396
|
+
};
|
|
397
|
+
var _recursiveMerge = function recursiveMerge(target) {
|
|
398
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
399
|
+
sources[_key - 1] = arguments[_key];
|
|
400
|
+
}
|
|
401
|
+
for (var _i = 0, _sources = sources; _i < _sources.length; _i++) {
|
|
402
|
+
var source = _sources[_i];
|
|
403
|
+
for (var key in source) {
|
|
404
|
+
if (isObject(source[key])) {
|
|
405
|
+
if (!target[key]) {
|
|
406
|
+
target[key] = {};
|
|
407
|
+
}
|
|
408
|
+
_recursiveMerge(target[key], source[key]);
|
|
409
|
+
} else {
|
|
410
|
+
target[key] = source[key];
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return target;
|
|
415
|
+
};
|
|
416
|
+
var managedLog = function managedLog(title, message, config) {
|
|
417
|
+
var _config$logs;
|
|
418
|
+
for (var _len2 = arguments.length, types = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
|
|
419
|
+
types[_key2 - 3] = arguments[_key2];
|
|
420
|
+
}
|
|
421
|
+
(_config$logs = config.logs) == null || _config$logs.forEach(function (allowed) {
|
|
422
|
+
if (types.includes(allowed)) {
|
|
423
|
+
if (config.debug === true) {
|
|
424
|
+
console[allowed](title, message);
|
|
425
|
+
} else {
|
|
426
|
+
console[allowed](title);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
var sleep = function sleep(ms) {
|
|
432
|
+
return new Promise(function (resolve) {
|
|
433
|
+
setTimeout(resolve, ms);
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
function isFunction(value) {
|
|
437
|
+
return typeof value === 'function';
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* global in-memory queue store
|
|
442
|
+
* not exported, only used by this module
|
|
443
|
+
*/
|
|
444
|
+
var store = [];
|
|
445
|
+
var push = function push() {
|
|
446
|
+
for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
447
|
+
items[_key] = arguments[_key];
|
|
448
|
+
}
|
|
449
|
+
var config = getConfig();
|
|
450
|
+
items = items.map(function (i) {
|
|
451
|
+
return _extends({
|
|
452
|
+
entityId: config.sourceId,
|
|
453
|
+
entityName: exports.EventEntityType.Source
|
|
454
|
+
}, i);
|
|
455
|
+
});
|
|
456
|
+
store.push.apply(store, items);
|
|
457
|
+
managedLog("QUEUE - " + items.length + " ITEM(S) ADDED", items, getConfig(), exports.LogType.INFO);
|
|
458
|
+
};
|
|
459
|
+
var pop = function pop(length) {
|
|
460
|
+
if (length === void 0) {
|
|
461
|
+
length = 12;
|
|
462
|
+
}
|
|
463
|
+
var items = store.splice(0, length);
|
|
464
|
+
managedLog("QUEUE - " + items.length + " ITEM(S) REMOVED", items, getConfig(), exports.LogType.INFO);
|
|
465
|
+
return items;
|
|
466
|
+
};
|
|
467
|
+
var length = function length() {
|
|
468
|
+
return store.length;
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
var identify = function identify(id, attributes, options) {
|
|
472
|
+
push({
|
|
473
|
+
category: exports.CategoryType.Event,
|
|
474
|
+
type: 'user.identify',
|
|
475
|
+
payload: {
|
|
476
|
+
type: 'identify',
|
|
477
|
+
id: id,
|
|
478
|
+
attributes: attributes,
|
|
479
|
+
options: options
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
var track = function track(id, type, attributes, options) {
|
|
484
|
+
push({
|
|
485
|
+
category: exports.CategoryType.Event,
|
|
486
|
+
type: type,
|
|
487
|
+
payload: {
|
|
488
|
+
type: 'track',
|
|
489
|
+
id: id,
|
|
490
|
+
attributes: attributes,
|
|
491
|
+
options: options
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
};
|
|
495
|
+
var message = function message(type, attributes, options) {
|
|
496
|
+
push({
|
|
497
|
+
category: exports.CategoryType.Event,
|
|
498
|
+
type: type,
|
|
499
|
+
payload: _extends({}, attributes)
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
var axios = /*#__PURE__*/require('axios');
|
|
504
|
+
var raw = axios;
|
|
505
|
+
var request = /*#__PURE__*/function () {
|
|
506
|
+
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(method, url, body, queries, headers) {
|
|
507
|
+
var config, _request, response, _response;
|
|
508
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
509
|
+
while (1) switch (_context.prev = _context.next) {
|
|
510
|
+
case 0:
|
|
511
|
+
config = getConfig();
|
|
512
|
+
_context.prev = 1;
|
|
513
|
+
_request = {
|
|
514
|
+
method: method,
|
|
515
|
+
url: url,
|
|
516
|
+
headers: _extends({
|
|
517
|
+
'content-type': 'application/json',
|
|
518
|
+
authorization: "bearer " + config.credential
|
|
519
|
+
}, headers),
|
|
520
|
+
data: body,
|
|
521
|
+
params: queries
|
|
522
|
+
};
|
|
523
|
+
managedLog('BATCH REQUEST', _request, config, exports.LogType.INFO);
|
|
524
|
+
_context.next = 6;
|
|
525
|
+
return raw.request(_request, {
|
|
526
|
+
validateStatus: function validateStatus(status) {
|
|
527
|
+
return status < 500;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
case 6:
|
|
531
|
+
response = _context.sent;
|
|
532
|
+
managedLog('BATCH RESPONSE', response.data, config, exports.LogType.INFO);
|
|
533
|
+
return _context.abrupt("return", [true, response.status, response.statusText, null, response.data]);
|
|
534
|
+
case 11:
|
|
535
|
+
_context.prev = 11;
|
|
536
|
+
_context.t0 = _context["catch"](1);
|
|
537
|
+
managedLog('BATCH ERROR', _context.t0, config, exports.LogType.ERROR);
|
|
538
|
+
if (!_context.t0.response) {
|
|
539
|
+
_context.next = 19;
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
// The request was made and the server responded with a status code
|
|
543
|
+
// that falls out of the range of 2xx
|
|
544
|
+
_response = _context.t0.response;
|
|
545
|
+
return _context.abrupt("return", [false, _response.status, _response.statusText, null, _response.data]);
|
|
546
|
+
case 19:
|
|
547
|
+
if (!_context.t0.request) {
|
|
548
|
+
_context.next = 23;
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
return _context.abrupt("return", [false, 503, 'Service is Down', 'Unable to get any response from the ', _context.t0]);
|
|
552
|
+
case 23:
|
|
553
|
+
return _context.abrupt("return", [false, 403, 'Service is Down', 'Could not make the request, check and try again.', _context.t0]);
|
|
554
|
+
case 24:
|
|
555
|
+
case "end":
|
|
556
|
+
return _context.stop();
|
|
557
|
+
}
|
|
558
|
+
}, _callee, null, [[1, 11]]);
|
|
559
|
+
}));
|
|
560
|
+
return function request(_x, _x2, _x3, _x4, _x5) {
|
|
561
|
+
return _ref.apply(this, arguments);
|
|
562
|
+
};
|
|
563
|
+
}();
|
|
564
|
+
var requestWithError = /*#__PURE__*/function () {
|
|
565
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(method, url, body, queries, headers) {
|
|
566
|
+
var _yield$request, status, httpStatus, title, message, response, _response$message;
|
|
567
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
568
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
569
|
+
case 0:
|
|
570
|
+
_context2.next = 2;
|
|
571
|
+
return request(method, url, body, queries, headers);
|
|
572
|
+
case 2:
|
|
573
|
+
_yield$request = _context2.sent;
|
|
574
|
+
status = _yield$request[0];
|
|
575
|
+
httpStatus = _yield$request[1];
|
|
576
|
+
title = _yield$request[2];
|
|
577
|
+
message = _yield$request[3];
|
|
578
|
+
response = _yield$request[4];
|
|
579
|
+
if (!(status !== true)) {
|
|
580
|
+
_context2.next = 10;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
throw new Error(httpStatus + ": " + title + " " + ((_response$message = response == null ? void 0 : response.message) != null ? _response$message : message));
|
|
584
|
+
case 10:
|
|
585
|
+
return _context2.abrupt("return", response);
|
|
586
|
+
case 11:
|
|
587
|
+
case "end":
|
|
588
|
+
return _context2.stop();
|
|
589
|
+
}
|
|
590
|
+
}, _callee2);
|
|
591
|
+
}));
|
|
592
|
+
return function requestWithError(_x6, _x7, _x8, _x9, _x10) {
|
|
593
|
+
return _ref2.apply(this, arguments);
|
|
594
|
+
};
|
|
595
|
+
}();
|
|
596
|
+
var post = function post(url, body, queries, headers) {
|
|
597
|
+
return request('POST', url, body, queries, headers);
|
|
598
|
+
};
|
|
599
|
+
var get = function get(url, queries, headers) {
|
|
600
|
+
return request('GET', url, null, queries, headers);
|
|
601
|
+
};
|
|
602
|
+
var patch = function patch(url, body, queries, headers) {
|
|
603
|
+
return request('PATCH', url, body, queries, headers);
|
|
604
|
+
};
|
|
605
|
+
var put = function put(url, body, queries, headers) {
|
|
606
|
+
return request('PUT', url, body, queries, headers);
|
|
607
|
+
};
|
|
608
|
+
var remove = function remove(url, body, queries, headers) {
|
|
609
|
+
return request('DELETE', url, body, queries, headers);
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
var limit = 25;
|
|
613
|
+
var retryTracker = 0;
|
|
614
|
+
var run = /*#__PURE__*/function () {
|
|
615
|
+
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
616
|
+
var config, handler;
|
|
617
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
618
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
619
|
+
case 0:
|
|
620
|
+
config = getConfig();
|
|
621
|
+
handler = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
622
|
+
var items, _yield$post, status, _config$batch, _config$batch3, _config$batch4, _config$batch2;
|
|
623
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
624
|
+
while (1) switch (_context.prev = _context.next) {
|
|
625
|
+
case 0:
|
|
626
|
+
if (!(length() < 1)) {
|
|
627
|
+
_context.next = 3;
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
managedLog('BATCH RUN', 'Nothing to process', getConfig(), exports.LogType.INFO);
|
|
631
|
+
return _context.abrupt("return");
|
|
632
|
+
case 3:
|
|
633
|
+
items = pop(limit);
|
|
634
|
+
_context.prev = 4;
|
|
635
|
+
_context.next = 7;
|
|
636
|
+
return post(config.server + "/apps/emitr/ingest/batch", {
|
|
637
|
+
items: items
|
|
638
|
+
});
|
|
639
|
+
case 7:
|
|
640
|
+
_yield$post = _context.sent;
|
|
641
|
+
status = _yield$post[0];
|
|
642
|
+
if (status) {
|
|
643
|
+
_context.next = 26;
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
push.apply(void 0, items);
|
|
647
|
+
managedLog('BATCH RUN', items.length + " sent back to queue", getConfig(), exports.LogType.INFO, exports.LogType.ERROR);
|
|
648
|
+
++retryTracker;
|
|
649
|
+
if (!(retryTracker > ((_config$batch = config.batch) == null ? void 0 : _config$batch.limit))) {
|
|
650
|
+
_context.next = 22;
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
clearInterval(handler);
|
|
654
|
+
managedLog('BATCH RETRY LIMIT EXHAUSTED', {
|
|
655
|
+
retryTracker: retryTracker,
|
|
656
|
+
giveUpAfter: (_config$batch2 = config.batch) == null ? void 0 : _config$batch2.limit
|
|
657
|
+
}, config, exports.LogType.INFO, exports.LogType.ERROR);
|
|
658
|
+
managedLog('BATCH RUN', "Processed stopped due to retry limit exhausted", getConfig(), exports.LogType.INFO, exports.LogType.ERROR);
|
|
659
|
+
return _context.abrupt("return");
|
|
660
|
+
case 22:
|
|
661
|
+
managedLog('BATCH RUN', "Sleeping for " + ((_config$batch3 = config.batch) == null ? void 0 : _config$batch3.backoff) + "ms", getConfig(), exports.LogType.INFO, exports.LogType.ERROR);
|
|
662
|
+
_context.next = 25;
|
|
663
|
+
return sleep((_config$batch4 = config.batch) == null ? void 0 : _config$batch4.backoff);
|
|
664
|
+
case 25:
|
|
665
|
+
return _context.abrupt("return");
|
|
666
|
+
case 26:
|
|
667
|
+
retryTracker = 0;
|
|
668
|
+
managedLog('BATCH RUN', items.length + " sent to server", getConfig(), exports.LogType.INFO);
|
|
669
|
+
_context.next = 33;
|
|
670
|
+
break;
|
|
671
|
+
case 30:
|
|
672
|
+
_context.prev = 30;
|
|
673
|
+
_context.t0 = _context["catch"](4);
|
|
674
|
+
console.error(_context.t0);
|
|
675
|
+
case 33:
|
|
676
|
+
case "end":
|
|
677
|
+
return _context.stop();
|
|
678
|
+
}
|
|
679
|
+
}, _callee, null, [[4, 30]]);
|
|
680
|
+
})), config.batch.interval);
|
|
681
|
+
case 2:
|
|
682
|
+
case "end":
|
|
683
|
+
return _context2.stop();
|
|
684
|
+
}
|
|
685
|
+
}, _callee2);
|
|
686
|
+
}));
|
|
687
|
+
return function run() {
|
|
688
|
+
return _ref.apply(this, arguments);
|
|
689
|
+
};
|
|
690
|
+
}();
|
|
691
|
+
|
|
692
|
+
var sourceId = '4b0765da-6df0-4eaa-bf16-e0cb48a3c47c';
|
|
693
|
+
var init = function init(c) {
|
|
694
|
+
var cf = isFunction(c) ? c() : c;
|
|
695
|
+
var config = _recursiveMerge(getConfig(), cf);
|
|
696
|
+
if (!config.server || config.server == '') {
|
|
697
|
+
managedLog('INIT CONFIG VALIDATION', config, config, exports.LogType.ERROR);
|
|
698
|
+
throw new Error('Invalid configuration - server not defined');
|
|
699
|
+
}
|
|
700
|
+
if (!config.sourceId || config.sourceId == '') {
|
|
701
|
+
managedLog('INIT CONFIG VALIDATION', config, config, exports.LogType.ERROR);
|
|
702
|
+
throw new Error('Invalid configuration - sourceId not defined');
|
|
703
|
+
}
|
|
704
|
+
managedLog('INIT ACTIVE CONFIG', config, config, exports.LogType.INFO);
|
|
705
|
+
run();
|
|
706
|
+
managedLog('INIT', 'Batch processing started', config, exports.LogType.INFO);
|
|
707
|
+
// register SDK as source
|
|
708
|
+
push({
|
|
709
|
+
category: exports.CategoryType.Event,
|
|
710
|
+
payload: {
|
|
711
|
+
id: sourceId,
|
|
712
|
+
category: exports.CategoryType.Event,
|
|
713
|
+
key: 'sdk',
|
|
714
|
+
typeKey: 'javascript',
|
|
715
|
+
name: 'Polylog SDK Javascript',
|
|
716
|
+
desc: null
|
|
717
|
+
},
|
|
718
|
+
type: 'apps.emitr.source.register'
|
|
719
|
+
});
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
var BaseServiceService = /*#__PURE__*/function () {
|
|
723
|
+
function BaseServiceService() {
|
|
724
|
+
this.name = void 0;
|
|
725
|
+
}
|
|
726
|
+
var _proto = BaseServiceService.prototype;
|
|
727
|
+
_proto.request = /*#__PURE__*/function () {
|
|
728
|
+
var _request = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(method, url, body, queries, headers) {
|
|
729
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
730
|
+
while (1) switch (_context.prev = _context.next) {
|
|
731
|
+
case 0:
|
|
732
|
+
return _context.abrupt("return", requestWithError(method, url, body, queries, headers));
|
|
733
|
+
case 1:
|
|
734
|
+
case "end":
|
|
735
|
+
return _context.stop();
|
|
736
|
+
}
|
|
737
|
+
}, _callee);
|
|
738
|
+
}));
|
|
739
|
+
function request(_x, _x2, _x3, _x4, _x5) {
|
|
740
|
+
return _request.apply(this, arguments);
|
|
741
|
+
}
|
|
742
|
+
return request;
|
|
743
|
+
}();
|
|
744
|
+
_proto.post = function post(path, body, queries, headers) {
|
|
745
|
+
return this.request('POST', this.name + "/" + path, body, queries, headers);
|
|
746
|
+
};
|
|
747
|
+
_proto.put = function put(path, body, queries, headers) {
|
|
748
|
+
return this.request('PUT', this.name + "/" + path, body, queries, headers);
|
|
749
|
+
};
|
|
750
|
+
_proto.get = function get(path, queries, headers) {
|
|
751
|
+
return this.request('GET', this.name + "/" + path, null, queries, headers);
|
|
752
|
+
};
|
|
753
|
+
_proto.patch = function patch(path, body, queries, headers) {
|
|
754
|
+
return this.request('PATCH', this.name + "/" + path, body, queries, headers);
|
|
755
|
+
};
|
|
756
|
+
_proto["delete"] = function _delete(path, queries, headers) {
|
|
757
|
+
return this.request('DELETE', this.name + "/" + path, null, queries, headers);
|
|
758
|
+
};
|
|
759
|
+
return BaseServiceService;
|
|
760
|
+
}();
|
|
761
|
+
|
|
762
|
+
var BaseEntityServiceService = /*#__PURE__*/function (_BaseServiceService) {
|
|
763
|
+
function BaseEntityServiceService() {
|
|
764
|
+
return _BaseServiceService.apply(this, arguments) || this;
|
|
765
|
+
}
|
|
766
|
+
_inheritsLoose(BaseEntityServiceService, _BaseServiceService);
|
|
767
|
+
var _proto = BaseEntityServiceService.prototype;
|
|
768
|
+
_proto.create = function create(body, queries, headers) {
|
|
769
|
+
return this.post("" + this.name, body, queries, headers);
|
|
770
|
+
};
|
|
771
|
+
_proto.upsert = function upsert(body, queries, headers) {
|
|
772
|
+
return this.put("" + this.name, body, queries, headers);
|
|
773
|
+
};
|
|
774
|
+
_proto.getOne = function getOne(id, queries, headers) {
|
|
775
|
+
return this.get(this.name + "/" + id, queries, headers);
|
|
776
|
+
};
|
|
777
|
+
_proto.getMany = function getMany(queries, headers) {
|
|
778
|
+
return this.get("" + this.name, queries, headers);
|
|
779
|
+
};
|
|
780
|
+
_proto.update = function update(id, body, queries, headers) {
|
|
781
|
+
return this.patch(this.name + "/" + id, body, queries, headers);
|
|
782
|
+
};
|
|
783
|
+
_proto.remove = function remove(id, queries, headers) {
|
|
784
|
+
return this["delete"](this.name + "/" + id, queries, headers);
|
|
785
|
+
};
|
|
786
|
+
_proto.getRelative = function getRelative(id, relative, queries, headers) {
|
|
787
|
+
return this.get(this.name + "/" + id + "/" + relative, queries, headers);
|
|
788
|
+
};
|
|
789
|
+
_proto.getMetrics = function getMetrics(queries, headers) {
|
|
790
|
+
if (queries === void 0) {
|
|
791
|
+
queries = {};
|
|
792
|
+
}
|
|
793
|
+
return this.get(this.name + "/metrics", queries, headers);
|
|
794
|
+
};
|
|
795
|
+
_proto.find = function find(queries, type, headers) {
|
|
796
|
+
if (type === void 0) {
|
|
797
|
+
type = 'latest';
|
|
798
|
+
}
|
|
799
|
+
return this.get(this.name + "/find/" + type, queries, headers);
|
|
800
|
+
};
|
|
801
|
+
return BaseEntityServiceService;
|
|
802
|
+
}(BaseServiceService);
|
|
803
|
+
|
|
804
|
+
var events = {
|
|
805
|
+
identify: identify,
|
|
806
|
+
track: track,
|
|
807
|
+
message: message
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
exports.BaseEntityServiceService = BaseEntityServiceService;
|
|
811
|
+
exports.BaseServiceService = BaseServiceService;
|
|
812
|
+
exports.events = events;
|
|
813
|
+
exports.get = get;
|
|
814
|
+
exports.init = init;
|
|
815
|
+
exports.patch = patch;
|
|
816
|
+
exports.post = post;
|
|
817
|
+
exports.put = put;
|
|
818
|
+
exports.raw = raw;
|
|
819
|
+
exports.remove = remove;
|
|
820
|
+
exports.request = request;
|
|
821
|
+
exports.requestWithError = requestWithError;
|
|
822
|
+
exports.run = run;
|
|
823
|
+
//# sourceMappingURL=jsx-polylog.cjs.development.js.map
|