miolo-cli 3.0.0-beta.155 → 3.0.0-beta.159
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/package.json +11 -16
- package/src/catcher/index.mjs +19 -21
- package/src/fetcher/fetcher.mjs +66 -68
- package/src/fetcher/index.mjs +2 -3
- package/src/fetcher/utils.mjs +7 -8
- package/src/index.mjs +13 -16
- package/src/socket/index.mjs +2 -2
- package/dist/miolo-cli.mjs +0 -469
- package/dist/miolo-cli.mjs.map +0 -1
- package/dist/miolo-cli.umd.js +0 -699
- package/dist/miolo-cli.umd.js.map +0 -1
package/dist/miolo-cli.umd.js
DELETED
|
@@ -1,699 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* miolo-cli v3.0.0-beta.155
|
|
3
|
-
*
|
|
4
|
-
* https://www.afialapis.com/os/miolo
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Donato Lorenzo <donato@afialapis.com>
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the MIT license found in the
|
|
9
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
10
|
-
*
|
|
11
|
-
* @license MIT
|
|
12
|
-
*/
|
|
13
|
-
/* eslint-disable */
|
|
14
|
-
(function (global, factory) {
|
|
15
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('qs')) :
|
|
16
|
-
typeof define === 'function' && define.amd ? define(['exports', 'qs'], factory) :
|
|
17
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.mioloCli = {}, global.qs));
|
|
18
|
-
})(this, (function (exports, qs) { 'use strict';
|
|
19
|
-
|
|
20
|
-
function init_catcher(catcher_url, fetcher) {
|
|
21
|
-
if (typeof window == "undefined") {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (window.miolo_listeners === true) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// window.onerror = function(msg, file, line, col, error) {
|
|
29
|
-
// try {
|
|
30
|
-
// const params= {
|
|
31
|
-
// 'error': {
|
|
32
|
-
// msg, file, line, col, error
|
|
33
|
-
// },
|
|
34
|
-
// 'path' : window.location.pathname,
|
|
35
|
-
// 'agent': 'UserAgent' + navigator.userAgent
|
|
36
|
-
// }
|
|
37
|
-
//
|
|
38
|
-
// fetcher.post(catcher_url, params)
|
|
39
|
-
// } catch(e) {
|
|
40
|
-
// console.error(e)
|
|
41
|
-
// }
|
|
42
|
-
// }
|
|
43
|
-
|
|
44
|
-
window.addEventListener("error", function (event) {
|
|
45
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
var params = {
|
|
49
|
-
'error': {
|
|
50
|
-
msg: (event == null ? void 0 : event.message) || 'Client error',
|
|
51
|
-
file: event == null ? void 0 : event.filename,
|
|
52
|
-
line: event == null ? void 0 : event.lineno,
|
|
53
|
-
col: event == null ? void 0 : event.colno,
|
|
54
|
-
error: event == null ? void 0 : event.error
|
|
55
|
-
},
|
|
56
|
-
'path': window.location.pathname,
|
|
57
|
-
'agent': 'UserAgent' + navigator.userAgent
|
|
58
|
-
};
|
|
59
|
-
fetcher.post(catcher_url, params);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
console.error(e);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
window.addEventListener("unhandledrejection", function (event) {
|
|
65
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
var params = {
|
|
69
|
-
'warning': {
|
|
70
|
-
msg: (event == null ? void 0 : event.reason) || 'Client Unhandled rejection',
|
|
71
|
-
file: undefined,
|
|
72
|
-
line: undefined,
|
|
73
|
-
col: undefined,
|
|
74
|
-
error: event == null ? void 0 : event.reason
|
|
75
|
-
},
|
|
76
|
-
'path': window.location.pathname,
|
|
77
|
-
'agent': 'UserAgent' + navigator.userAgent
|
|
78
|
-
};
|
|
79
|
-
fetcher.post(catcher_url, params);
|
|
80
|
-
} catch (e) {
|
|
81
|
-
console.error(e);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
window.miolo_listeners = true;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
88
|
-
try {
|
|
89
|
-
var i = n[a](c),
|
|
90
|
-
u = i.value;
|
|
91
|
-
} catch (n) {
|
|
92
|
-
return void e(n);
|
|
93
|
-
}
|
|
94
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
95
|
-
}
|
|
96
|
-
function _asyncToGenerator(n) {
|
|
97
|
-
return function () {
|
|
98
|
-
var t = this,
|
|
99
|
-
e = arguments;
|
|
100
|
-
return new Promise(function (r, o) {
|
|
101
|
-
var a = n.apply(t, e);
|
|
102
|
-
function _next(n) {
|
|
103
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
104
|
-
}
|
|
105
|
-
function _throw(n) {
|
|
106
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
107
|
-
}
|
|
108
|
-
_next(void 0);
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function _extends() {
|
|
113
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
114
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
115
|
-
var t = arguments[e];
|
|
116
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
117
|
-
}
|
|
118
|
-
return n;
|
|
119
|
-
}, _extends.apply(null, arguments);
|
|
120
|
-
}
|
|
121
|
-
function _regenerator() {
|
|
122
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
123
|
-
var e,
|
|
124
|
-
t,
|
|
125
|
-
r = "function" == typeof Symbol ? Symbol : {},
|
|
126
|
-
n = r.iterator || "@@iterator",
|
|
127
|
-
o = r.toStringTag || "@@toStringTag";
|
|
128
|
-
function i(r, n, o, i) {
|
|
129
|
-
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
130
|
-
u = Object.create(c.prototype);
|
|
131
|
-
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
132
|
-
var i,
|
|
133
|
-
c,
|
|
134
|
-
u,
|
|
135
|
-
f = 0,
|
|
136
|
-
p = o || [],
|
|
137
|
-
y = false,
|
|
138
|
-
G = {
|
|
139
|
-
p: 0,
|
|
140
|
-
n: 0,
|
|
141
|
-
v: e,
|
|
142
|
-
a: d,
|
|
143
|
-
f: d.bind(e, 4),
|
|
144
|
-
d: function (t, r) {
|
|
145
|
-
return i = t, c = 0, u = e, G.n = r, a;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
function d(r, n) {
|
|
149
|
-
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
150
|
-
var o,
|
|
151
|
-
i = p[t],
|
|
152
|
-
d = G.p,
|
|
153
|
-
l = i[2];
|
|
154
|
-
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
155
|
-
}
|
|
156
|
-
if (o || r > 1) return a;
|
|
157
|
-
throw y = true, n;
|
|
158
|
-
}
|
|
159
|
-
return function (o, p, l) {
|
|
160
|
-
if (f > 1) throw TypeError("Generator is already running");
|
|
161
|
-
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
162
|
-
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
163
|
-
try {
|
|
164
|
-
if (f = 2, i) {
|
|
165
|
-
if (c || (o = "next"), t = i[o]) {
|
|
166
|
-
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
167
|
-
if (!t.done) return t;
|
|
168
|
-
u = t.value, c < 2 && (c = 0);
|
|
169
|
-
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
170
|
-
i = e;
|
|
171
|
-
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
172
|
-
} catch (t) {
|
|
173
|
-
i = e, c = 1, u = t;
|
|
174
|
-
} finally {
|
|
175
|
-
f = 1;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
value: t,
|
|
180
|
-
done: y
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
}(r, o, i), true), u;
|
|
184
|
-
}
|
|
185
|
-
var a = {};
|
|
186
|
-
function Generator() {}
|
|
187
|
-
function GeneratorFunction() {}
|
|
188
|
-
function GeneratorFunctionPrototype() {}
|
|
189
|
-
t = Object.getPrototypeOf;
|
|
190
|
-
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
191
|
-
return this;
|
|
192
|
-
}), t),
|
|
193
|
-
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
194
|
-
function f(e) {
|
|
195
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
196
|
-
}
|
|
197
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
198
|
-
return this;
|
|
199
|
-
}), _regeneratorDefine(u, "toString", function () {
|
|
200
|
-
return "[object Generator]";
|
|
201
|
-
}), (_regenerator = function () {
|
|
202
|
-
return {
|
|
203
|
-
w: i,
|
|
204
|
-
m: f
|
|
205
|
-
};
|
|
206
|
-
})();
|
|
207
|
-
}
|
|
208
|
-
function _regeneratorDefine(e, r, n, t) {
|
|
209
|
-
var i = Object.defineProperty;
|
|
210
|
-
try {
|
|
211
|
-
i({}, "", {});
|
|
212
|
-
} catch (e) {
|
|
213
|
-
i = 0;
|
|
214
|
-
}
|
|
215
|
-
_regeneratorDefine = function (e, r, n, t) {
|
|
216
|
-
function o(r, n) {
|
|
217
|
-
_regeneratorDefine(e, r, function (e) {
|
|
218
|
-
return this._invoke(r, n, e);
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
r ? i ? i(e, r, {
|
|
222
|
-
value: n,
|
|
223
|
-
enumerable: !t,
|
|
224
|
-
configurable: !t,
|
|
225
|
-
writable: !t
|
|
226
|
-
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
227
|
-
}, _regeneratorDefine(e, r, n, t);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Transform an JSON object to a query string
|
|
232
|
-
*/
|
|
233
|
-
// const _parse_value= (value) => {
|
|
234
|
-
// try {
|
|
235
|
-
// return value.replace(/\+/g, '%2B')
|
|
236
|
-
// } catch(e) {
|
|
237
|
-
// return value
|
|
238
|
-
// }
|
|
239
|
-
// }
|
|
240
|
-
//
|
|
241
|
-
// export function json_to_query_string(obj) {
|
|
242
|
-
// if (obj && (Object.keys(obj).length>0)) {
|
|
243
|
-
// const uparams = new URLSearchParams()
|
|
244
|
-
// for (const key in obj) {
|
|
245
|
-
// if (Object.hasOwn(obj, key)) {
|
|
246
|
-
// const value = obj[key];
|
|
247
|
-
// if (Array.isArray(value)) {
|
|
248
|
-
// value.forEach(item => uparams.append(key, _parse_value(item)))
|
|
249
|
-
// } else if (value !== undefined && value !== null) {
|
|
250
|
-
// uparams.append(key, _parse_value(value))
|
|
251
|
-
// }
|
|
252
|
-
// }
|
|
253
|
-
// }
|
|
254
|
-
// return `?${uparams.toString()}`
|
|
255
|
-
// }
|
|
256
|
-
// return ''
|
|
257
|
-
// }
|
|
258
|
-
|
|
259
|
-
function json_to_query_string(obj) {
|
|
260
|
-
if (!obj || Object.keys(obj).length === 0) return '';
|
|
261
|
-
return "?" + qs.stringify(obj, {
|
|
262
|
-
arrayFormat: 'repeat'
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
function trim_left(str, what) {
|
|
266
|
-
return str.replace(new RegExp("^" + (what) + "+"), '');
|
|
267
|
-
}
|
|
268
|
-
function omit_nil(obj) {
|
|
269
|
-
if (typeof obj !== 'object') return obj;
|
|
270
|
-
return Object.keys(obj).reduce(function (acc, v) {
|
|
271
|
-
if (obj[v] !== undefined) acc[v] = omit_nil(obj[v]);
|
|
272
|
-
return acc;
|
|
273
|
-
}, {});
|
|
274
|
-
}
|
|
275
|
-
function null_to_undefined(value) {
|
|
276
|
-
if (Array.isArray(value)) {
|
|
277
|
-
return value.map(null_to_undefined);
|
|
278
|
-
} else if (value && typeof value === 'object') {
|
|
279
|
-
var data = {};
|
|
280
|
-
for (var _i = 0, _Object$entries = Object.entries(value); _i < _Object$entries.length; _i++) {
|
|
281
|
-
var _Object$entries$_i = _Object$entries[_i],
|
|
282
|
-
key = _Object$entries$_i[0],
|
|
283
|
-
val = _Object$entries$_i[1];
|
|
284
|
-
data[key] = val === null ? undefined : null_to_undefined(val);
|
|
285
|
-
}
|
|
286
|
-
return data;
|
|
287
|
-
}
|
|
288
|
-
return value;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
var Fetcher = /*#__PURE__*/function () {
|
|
292
|
-
/**
|
|
293
|
-
* @param {*} config {hostname, port, force_hostname, silent_fail: false}
|
|
294
|
-
*/
|
|
295
|
-
function Fetcher(config) {
|
|
296
|
-
this.config = config;
|
|
297
|
-
this.http_auth = undefined;
|
|
298
|
-
}
|
|
299
|
-
var _proto = Fetcher.prototype;
|
|
300
|
-
_proto.set_http_auth = function set_http_auth(auth) {
|
|
301
|
-
if (auth) {
|
|
302
|
-
var username = auth.username,
|
|
303
|
-
password = auth.password;
|
|
304
|
-
this.http_auth = {
|
|
305
|
-
username: username,
|
|
306
|
-
password: password
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
_proto.get_headers = function get_headers() {
|
|
311
|
-
var headers = {};
|
|
312
|
-
if (this.http_auth) {
|
|
313
|
-
var _this$http_auth = this.http_auth,
|
|
314
|
-
username = _this$http_auth.username,
|
|
315
|
-
password = _this$http_auth.password;
|
|
316
|
-
username = username || '';
|
|
317
|
-
password = password || '';
|
|
318
|
-
var sauth;
|
|
319
|
-
try {
|
|
320
|
-
sauth = 'Basic ' + Buffer.from(username + ":" + password).toString('base64');
|
|
321
|
-
} catch (_) {
|
|
322
|
-
sauth = 'Basic ' + btoa(username + ":" + password);
|
|
323
|
-
}
|
|
324
|
-
headers['Authorization'] = sauth;
|
|
325
|
-
}
|
|
326
|
-
return headers;
|
|
327
|
-
};
|
|
328
|
-
_proto._prepare_url = function _prepare_url(url) {
|
|
329
|
-
var endpoint = '/' + trim_left(url, '/');
|
|
330
|
-
var _ref = this.config || {},
|
|
331
|
-
hostname = _ref.hostname,
|
|
332
|
-
port = _ref.port,
|
|
333
|
-
force_hostname = _ref.force_hostname;
|
|
334
|
-
if (hostname && force_hostname) {
|
|
335
|
-
return "http://" + hostname + ":" + port + endpoint;
|
|
336
|
-
}
|
|
337
|
-
return endpoint;
|
|
338
|
-
};
|
|
339
|
-
_proto._fetch = /*#__PURE__*/function () {
|
|
340
|
-
var _fetch2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(method, url, params, http_auth) {
|
|
341
|
-
var request, wurl, response, isBrowser, isTest, resp, data;
|
|
342
|
-
return _regenerator().w(function (_context) {
|
|
343
|
-
while (1) switch (_context.n) {
|
|
344
|
-
case 0:
|
|
345
|
-
if (http_auth === void 0) {
|
|
346
|
-
http_auth = undefined;
|
|
347
|
-
}
|
|
348
|
-
this.set_http_auth(http_auth);
|
|
349
|
-
request = {
|
|
350
|
-
method: method,
|
|
351
|
-
mode: 'cors',
|
|
352
|
-
credentials: 'include',
|
|
353
|
-
headers: _extends({
|
|
354
|
-
'content-type': 'application/json'
|
|
355
|
-
}, this.get_headers() || {})
|
|
356
|
-
};
|
|
357
|
-
wurl = this._prepare_url(url);
|
|
358
|
-
if (method === 'POST') {
|
|
359
|
-
request.body = JSON.stringify(params || {}, function (k, v) {
|
|
360
|
-
return v === undefined ? null : v;
|
|
361
|
-
});
|
|
362
|
-
} else if (method === 'GET') {
|
|
363
|
-
if (params) {
|
|
364
|
-
wurl += json_to_query_string(params);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
_context.n = 1;
|
|
368
|
-
return fetch(wurl, request);
|
|
369
|
-
case 1:
|
|
370
|
-
response = _context.v;
|
|
371
|
-
if (!response.redirected) {
|
|
372
|
-
_context.n = 3;
|
|
373
|
-
break;
|
|
374
|
-
}
|
|
375
|
-
isBrowser = typeof window == 'object';
|
|
376
|
-
if (!isBrowser) {
|
|
377
|
-
_context.n = 3;
|
|
378
|
-
break;
|
|
379
|
-
}
|
|
380
|
-
// JSDOM does not support navigation, so lets skip it for tests
|
|
381
|
-
isTest = typeof navigator !== "undefined" && navigator.userAgent.includes("Node.js");
|
|
382
|
-
if (isTest) {
|
|
383
|
-
_context.n = 2;
|
|
384
|
-
break;
|
|
385
|
-
}
|
|
386
|
-
window.location.replace(response.url);
|
|
387
|
-
return _context.a(2, Promise.resolve(response));
|
|
388
|
-
case 2:
|
|
389
|
-
console.error("Response for " + wurl + " is a redirect to " + response.url + ". But you are in a test environment, where redirects cannot be done. Unexpected results are coming...");
|
|
390
|
-
case 3:
|
|
391
|
-
if (!(response.headers.get('content-type').indexOf('json') >= 0)) {
|
|
392
|
-
_context.n = 5;
|
|
393
|
-
break;
|
|
394
|
-
}
|
|
395
|
-
_context.n = 4;
|
|
396
|
-
return response.json();
|
|
397
|
-
case 4:
|
|
398
|
-
resp = _context.v;
|
|
399
|
-
resp = null_to_undefined(resp);
|
|
400
|
-
return _context.a(2, _extends({}, resp, {
|
|
401
|
-
status: response.status,
|
|
402
|
-
response: response
|
|
403
|
-
}));
|
|
404
|
-
case 5:
|
|
405
|
-
_context.n = 6;
|
|
406
|
-
return response.text();
|
|
407
|
-
case 6:
|
|
408
|
-
data = _context.v;
|
|
409
|
-
return _context.a(2, {
|
|
410
|
-
ok: true,
|
|
411
|
-
data: data,
|
|
412
|
-
status: response.status,
|
|
413
|
-
response: response
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}, _callee, this);
|
|
417
|
-
}));
|
|
418
|
-
function _fetch(_x, _x2, _x3, _x4) {
|
|
419
|
-
return _fetch2.apply(this, arguments);
|
|
420
|
-
}
|
|
421
|
-
return _fetch;
|
|
422
|
-
}();
|
|
423
|
-
_proto.get = /*#__PURE__*/function () {
|
|
424
|
-
var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(url, params, http_auth) {
|
|
425
|
-
var resp, _this$config, _t;
|
|
426
|
-
return _regenerator().w(function (_context2) {
|
|
427
|
-
while (1) switch (_context2.p = _context2.n) {
|
|
428
|
-
case 0:
|
|
429
|
-
if (http_auth === void 0) {
|
|
430
|
-
http_auth = undefined;
|
|
431
|
-
}
|
|
432
|
-
_context2.p = 1;
|
|
433
|
-
_context2.n = 2;
|
|
434
|
-
return this._fetch('GET', url, omit_nil(params), http_auth);
|
|
435
|
-
case 2:
|
|
436
|
-
resp = _context2.v;
|
|
437
|
-
return _context2.a(2, resp);
|
|
438
|
-
case 3:
|
|
439
|
-
_context2.p = 3;
|
|
440
|
-
_t = _context2.v;
|
|
441
|
-
if (((_this$config = this.config) == null ? void 0 : _this$config.silent_fail) !== true) {
|
|
442
|
-
console.error("Error on GET " + url);
|
|
443
|
-
console.error(_t);
|
|
444
|
-
}
|
|
445
|
-
return _context2.a(2, {
|
|
446
|
-
ok: false,
|
|
447
|
-
error: _t,
|
|
448
|
-
status: -1
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
}, _callee2, this, [[1, 3]]);
|
|
452
|
-
}));
|
|
453
|
-
function get(_x5, _x6, _x7) {
|
|
454
|
-
return _get.apply(this, arguments);
|
|
455
|
-
}
|
|
456
|
-
return get;
|
|
457
|
-
}();
|
|
458
|
-
_proto.post = /*#__PURE__*/function () {
|
|
459
|
-
var _post = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(url, data, http_auth) {
|
|
460
|
-
var resp, _this$config2, _t2;
|
|
461
|
-
return _regenerator().w(function (_context3) {
|
|
462
|
-
while (1) switch (_context3.p = _context3.n) {
|
|
463
|
-
case 0:
|
|
464
|
-
if (http_auth === void 0) {
|
|
465
|
-
http_auth = undefined;
|
|
466
|
-
}
|
|
467
|
-
_context3.p = 1;
|
|
468
|
-
_context3.n = 2;
|
|
469
|
-
return this._fetch('POST', url, data, http_auth);
|
|
470
|
-
case 2:
|
|
471
|
-
resp = _context3.v;
|
|
472
|
-
return _context3.a(2, resp);
|
|
473
|
-
case 3:
|
|
474
|
-
_context3.p = 3;
|
|
475
|
-
_t2 = _context3.v;
|
|
476
|
-
if (((_this$config2 = this.config) == null ? void 0 : _this$config2.silent_fail) !== true) {
|
|
477
|
-
console.error("Error on POST " + url);
|
|
478
|
-
console.error(_t2);
|
|
479
|
-
}
|
|
480
|
-
return _context3.a(2, {
|
|
481
|
-
ok: false,
|
|
482
|
-
error: _t2,
|
|
483
|
-
status: -1
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
}, _callee3, this, [[1, 3]]);
|
|
487
|
-
}));
|
|
488
|
-
function post(_x8, _x9, _x0) {
|
|
489
|
-
return _post.apply(this, arguments);
|
|
490
|
-
}
|
|
491
|
-
return post;
|
|
492
|
-
}();
|
|
493
|
-
_proto.read = /*#__PURE__*/function () {
|
|
494
|
-
var _read = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(url, params, http_auth) {
|
|
495
|
-
return _regenerator().w(function (_context4) {
|
|
496
|
-
while (1) switch (_context4.n) {
|
|
497
|
-
case 0:
|
|
498
|
-
if (http_auth === void 0) {
|
|
499
|
-
http_auth = undefined;
|
|
500
|
-
}
|
|
501
|
-
_context4.n = 1;
|
|
502
|
-
return this.get(url + "/read", params, http_auth);
|
|
503
|
-
case 1:
|
|
504
|
-
return _context4.a(2, _context4.v);
|
|
505
|
-
}
|
|
506
|
-
}, _callee4, this);
|
|
507
|
-
}));
|
|
508
|
-
function read(_x1, _x10, _x11) {
|
|
509
|
-
return _read.apply(this, arguments);
|
|
510
|
-
}
|
|
511
|
-
return read;
|
|
512
|
-
}();
|
|
513
|
-
_proto.key_list = /*#__PURE__*/function () {
|
|
514
|
-
var _key_list = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url, params, http_auth) {
|
|
515
|
-
return _regenerator().w(function (_context5) {
|
|
516
|
-
while (1) switch (_context5.n) {
|
|
517
|
-
case 0:
|
|
518
|
-
if (http_auth === void 0) {
|
|
519
|
-
http_auth = undefined;
|
|
520
|
-
}
|
|
521
|
-
_context5.n = 1;
|
|
522
|
-
return this.get(url + "/key_list", params, http_auth);
|
|
523
|
-
case 1:
|
|
524
|
-
return _context5.a(2, _context5.v);
|
|
525
|
-
}
|
|
526
|
-
}, _callee5, this);
|
|
527
|
-
}));
|
|
528
|
-
function key_list(_x12, _x13, _x14) {
|
|
529
|
-
return _key_list.apply(this, arguments);
|
|
530
|
-
}
|
|
531
|
-
return key_list;
|
|
532
|
-
}();
|
|
533
|
-
_proto.name_list = /*#__PURE__*/function () {
|
|
534
|
-
var _name_list = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(url, params, http_auth) {
|
|
535
|
-
var resp;
|
|
536
|
-
return _regenerator().w(function (_context6) {
|
|
537
|
-
while (1) switch (_context6.n) {
|
|
538
|
-
case 0:
|
|
539
|
-
if (http_auth === void 0) {
|
|
540
|
-
http_auth = undefined;
|
|
541
|
-
}
|
|
542
|
-
_context6.n = 1;
|
|
543
|
-
return this.key_list(url, params, http_auth);
|
|
544
|
-
case 1:
|
|
545
|
-
resp = _context6.v;
|
|
546
|
-
if (resp != null && resp.data) {
|
|
547
|
-
resp.data = Object.values(resp.data);
|
|
548
|
-
}
|
|
549
|
-
return _context6.a(2, resp);
|
|
550
|
-
}
|
|
551
|
-
}, _callee6, this);
|
|
552
|
-
}));
|
|
553
|
-
function name_list(_x15, _x16, _x17) {
|
|
554
|
-
return _name_list.apply(this, arguments);
|
|
555
|
-
}
|
|
556
|
-
return name_list;
|
|
557
|
-
}();
|
|
558
|
-
_proto.find = /*#__PURE__*/function () {
|
|
559
|
-
var _find = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(url, id, http_auth) {
|
|
560
|
-
return _regenerator().w(function (_context7) {
|
|
561
|
-
while (1) switch (_context7.n) {
|
|
562
|
-
case 0:
|
|
563
|
-
if (http_auth === void 0) {
|
|
564
|
-
http_auth = undefined;
|
|
565
|
-
}
|
|
566
|
-
_context7.n = 1;
|
|
567
|
-
return this.get(url + "/find", {
|
|
568
|
-
id: id
|
|
569
|
-
}, http_auth);
|
|
570
|
-
case 1:
|
|
571
|
-
return _context7.a(2, _context7.v);
|
|
572
|
-
}
|
|
573
|
-
}, _callee7, this);
|
|
574
|
-
}));
|
|
575
|
-
function find(_x18, _x19, _x20) {
|
|
576
|
-
return _find.apply(this, arguments);
|
|
577
|
-
}
|
|
578
|
-
return find;
|
|
579
|
-
}();
|
|
580
|
-
_proto.distinct = /*#__PURE__*/function () {
|
|
581
|
-
var _distinct = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(url, field, params, http_auth) {
|
|
582
|
-
var nparams;
|
|
583
|
-
return _regenerator().w(function (_context8) {
|
|
584
|
-
while (1) switch (_context8.n) {
|
|
585
|
-
case 0:
|
|
586
|
-
if (http_auth === void 0) {
|
|
587
|
-
http_auth = undefined;
|
|
588
|
-
}
|
|
589
|
-
nparams = _extends({}, params, {
|
|
590
|
-
distinct_field: field
|
|
591
|
-
});
|
|
592
|
-
_context8.n = 1;
|
|
593
|
-
return this.get(url + "/distinct", nparams, http_auth);
|
|
594
|
-
case 1:
|
|
595
|
-
return _context8.a(2, _context8.v);
|
|
596
|
-
}
|
|
597
|
-
}, _callee8, this);
|
|
598
|
-
}));
|
|
599
|
-
function distinct(_x21, _x22, _x23, _x24) {
|
|
600
|
-
return _distinct.apply(this, arguments);
|
|
601
|
-
}
|
|
602
|
-
return distinct;
|
|
603
|
-
}();
|
|
604
|
-
_proto.upsave = /*#__PURE__*/function () {
|
|
605
|
-
var _upsave = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(url, data, http_auth) {
|
|
606
|
-
var resp;
|
|
607
|
-
return _regenerator().w(function (_context9) {
|
|
608
|
-
while (1) switch (_context9.n) {
|
|
609
|
-
case 0:
|
|
610
|
-
if (http_auth === void 0) {
|
|
611
|
-
http_auth = undefined;
|
|
612
|
-
}
|
|
613
|
-
if (!(data.id == undefined)) {
|
|
614
|
-
_context9.n = 2;
|
|
615
|
-
break;
|
|
616
|
-
}
|
|
617
|
-
delete data.id;
|
|
618
|
-
_context9.n = 1;
|
|
619
|
-
return this.post(url + "/save", data, http_auth);
|
|
620
|
-
case 1:
|
|
621
|
-
resp = _context9.v;
|
|
622
|
-
_context9.n = 4;
|
|
623
|
-
break;
|
|
624
|
-
case 2:
|
|
625
|
-
_context9.n = 3;
|
|
626
|
-
return this.post(url + "/update", data, http_auth);
|
|
627
|
-
case 3:
|
|
628
|
-
resp = _context9.v;
|
|
629
|
-
case 4:
|
|
630
|
-
return _context9.a(2, resp);
|
|
631
|
-
}
|
|
632
|
-
}, _callee9, this);
|
|
633
|
-
}));
|
|
634
|
-
function upsave(_x25, _x26, _x27) {
|
|
635
|
-
return _upsave.apply(this, arguments);
|
|
636
|
-
}
|
|
637
|
-
return upsave;
|
|
638
|
-
}();
|
|
639
|
-
_proto.remove = /*#__PURE__*/function () {
|
|
640
|
-
var _remove = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(url, id, http_auth) {
|
|
641
|
-
var data;
|
|
642
|
-
return _regenerator().w(function (_context0) {
|
|
643
|
-
while (1) switch (_context0.n) {
|
|
644
|
-
case 0:
|
|
645
|
-
if (http_auth === void 0) {
|
|
646
|
-
http_auth = undefined;
|
|
647
|
-
}
|
|
648
|
-
data = {
|
|
649
|
-
id: id
|
|
650
|
-
};
|
|
651
|
-
_context0.n = 1;
|
|
652
|
-
return this.post(url + "/delete", data, http_auth);
|
|
653
|
-
case 1:
|
|
654
|
-
return _context0.a(2, _context0.v);
|
|
655
|
-
}
|
|
656
|
-
}, _callee0, this);
|
|
657
|
-
}));
|
|
658
|
-
function remove(_x28, _x29, _x30) {
|
|
659
|
-
return _remove.apply(this, arguments);
|
|
660
|
-
}
|
|
661
|
-
return remove;
|
|
662
|
-
}();
|
|
663
|
-
return Fetcher;
|
|
664
|
-
}();
|
|
665
|
-
Fetcher.keyList = Fetcher.key_list;
|
|
666
|
-
Fetcher.nameList = Fetcher.name_list;
|
|
667
|
-
|
|
668
|
-
function init_fetcher(config) {
|
|
669
|
-
var fetcher = new Fetcher(config);
|
|
670
|
-
return fetcher;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// import {init_socket} from './socket/index.mjs'
|
|
674
|
-
|
|
675
|
-
function miolo_client(context) {
|
|
676
|
-
var config = context.config;
|
|
677
|
-
var fetcher = init_fetcher(config);
|
|
678
|
-
if (config != null && config.catcher_url) {
|
|
679
|
-
init_catcher(config == null ? void 0 : config.catcher_url, fetcher);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
// let socket
|
|
683
|
-
// if (config?.socket?.enabled===true) {
|
|
684
|
-
// const domain = config?.socket?.domain
|
|
685
|
-
// const options = config?.socket?.options
|
|
686
|
-
// socket = init_socket(domain, options)
|
|
687
|
-
// }
|
|
688
|
-
|
|
689
|
-
var miolo_obj = {
|
|
690
|
-
fetcher: fetcher
|
|
691
|
-
//socket
|
|
692
|
-
};
|
|
693
|
-
return miolo_obj;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
exports.miolo_client = miolo_client;
|
|
697
|
-
|
|
698
|
-
}));
|
|
699
|
-
//# sourceMappingURL=miolo-cli.umd.js.map
|