miolo-cli 3.0.0-beta.3

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.
@@ -0,0 +1,749 @@
1
+ /**
2
+ * miolo-cli v3.0.0-beta.2
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) :
16
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
17
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.mioloCli = {}));
18
+ })(this, (function (exports) { '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
+ if (r) i ? i(e, r, {
217
+ value: n,
218
+ enumerable: !t,
219
+ configurable: !t,
220
+ writable: !t
221
+ }) : e[r] = n;else {
222
+ function o(r, n) {
223
+ _regeneratorDefine(e, r, function (e) {
224
+ return this._invoke(r, n, e);
225
+ });
226
+ }
227
+ o("next", 0), o("throw", 1), o("return", 2);
228
+ }
229
+ }, _regeneratorDefine(e, r, n, t);
230
+ }
231
+
232
+ /**
233
+ * Transform an JSON object to a query string
234
+ */
235
+ var _parse_value = function _parse_value(value) {
236
+ try {
237
+ return value.replace(/\+/g, '%2B');
238
+ } catch (e) {
239
+ return value;
240
+ }
241
+ };
242
+ function json_to_query_string(obj) {
243
+ if (obj && Object.keys(obj).length > 0) {
244
+ var uparams = new URLSearchParams();
245
+ var _loop = function _loop(key) {
246
+ if (Object.hasOwn(obj, key)) {
247
+ var value = obj[key];
248
+ if (Array.isArray(value)) {
249
+ value.forEach(function (item) {
250
+ return uparams.append(key, _parse_value(item));
251
+ });
252
+ } else if (value !== undefined && value !== null) {
253
+ uparams.append(key, _parse_value(value));
254
+ }
255
+ }
256
+ };
257
+ for (var key in obj) {
258
+ _loop(key);
259
+ }
260
+ return "?" + uparams.toString();
261
+ }
262
+ return '';
263
+ }
264
+ function trim_left(str, what) {
265
+ return str.replace(new RegExp("^" + (what) + "+"), '');
266
+ }
267
+ function omit_nil(obj) {
268
+ if (typeof obj !== 'object') return obj;
269
+ return Object.keys(obj).reduce(function (acc, v) {
270
+ if (obj[v] !== undefined) acc[v] = obj[v];
271
+ return acc;
272
+ }, {});
273
+ }
274
+ function parse_login_cookie(response) {
275
+ if (typeof window !== 'object') {
276
+ return undefined;
277
+ }
278
+ try {
279
+ var raw = response.headers.raw()['set-cookie'];
280
+ return raw.map(function (entry) {
281
+ var parts = entry.split(';');
282
+ var cookiePart = parts[0];
283
+ return cookiePart;
284
+ }).join(';');
285
+ } catch (e) {
286
+ console.log('[miolo-cli] Could not get the set-cookie after login');
287
+ return undefined;
288
+ }
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.auth = undefined;
298
+ this.cookie = undefined;
299
+ }
300
+ var _proto = Fetcher.prototype;
301
+ _proto.set_auth = function set_auth(auth) {
302
+ if (auth) {
303
+ var username = auth.username,
304
+ password = auth.password;
305
+ this.auth = {
306
+ username: username,
307
+ password: password
308
+ };
309
+ }
310
+ };
311
+ _proto.get_headers = function get_headers() {
312
+ var headers = {};
313
+ if (this.auth) {
314
+ var _this$auth = this.auth,
315
+ username = _this$auth.username,
316
+ password = _this$auth.password;
317
+ username = username || '';
318
+ password = password || '';
319
+ var sauth;
320
+ try {
321
+ sauth = 'Basic ' + Buffer.from(username + ":" + password).toString('base64');
322
+ } catch (_) {
323
+ sauth = 'Basic ' + btoa(username + ":" + password);
324
+ }
325
+ headers['Authorization'] = sauth;
326
+ }
327
+ if (this.cookie) {
328
+ headers['Cookie'] = this.cookie;
329
+ }
330
+ return headers;
331
+ };
332
+ _proto._prepare_url = function _prepare_url(url) {
333
+ var endpoint = '/' + trim_left(url, '/');
334
+ var _ref = this.config || {},
335
+ hostname = _ref.hostname,
336
+ port = _ref.port,
337
+ force_hostname = _ref.force_hostname;
338
+ if (hostname && force_hostname) {
339
+ return "http://" + hostname + ":" + port + endpoint;
340
+ }
341
+ return endpoint;
342
+ };
343
+ _proto._fetch = /*#__PURE__*/function () {
344
+ var _fetch2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(method, url, params, auth) {
345
+ var request, wurl, response, isBrowser, isTest, _data, data;
346
+ return _regenerator().w(function (_context) {
347
+ while (1) switch (_context.n) {
348
+ case 0:
349
+ if (auth === void 0) {
350
+ auth = undefined;
351
+ }
352
+ this.set_auth(auth);
353
+ request = {
354
+ method: method,
355
+ mode: 'cors',
356
+ credentials: 'include',
357
+ headers: _extends({
358
+ 'content-type': 'application/json'
359
+ }, this.get_headers() || {})
360
+ };
361
+ wurl = this._prepare_url(url);
362
+ if (method === 'POST') {
363
+ request.body = JSON.stringify(params || {}, function (k, v) {
364
+ return v === undefined ? null : v;
365
+ });
366
+ } else if (method === 'GET') {
367
+ if (params) {
368
+ wurl += json_to_query_string(params);
369
+ }
370
+ }
371
+ _context.n = 1;
372
+ return fetch(wurl, request);
373
+ case 1:
374
+ response = _context.v;
375
+ if (!response.redirected) {
376
+ _context.n = 3;
377
+ break;
378
+ }
379
+ isBrowser = typeof window == 'object';
380
+ if (!isBrowser) {
381
+ _context.n = 3;
382
+ break;
383
+ }
384
+ // JSDOM does not support navigation, so lets skip it for tests
385
+ isTest = typeof navigator !== "undefined" && navigator.userAgent.includes("Node.js");
386
+ if (isTest) {
387
+ _context.n = 2;
388
+ break;
389
+ }
390
+ window.location.replace(response.url);
391
+ return _context.a(2, Promise.resolve(response));
392
+ case 2:
393
+ 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...");
394
+ case 3:
395
+ if (!(response.headers.get('content-type').indexOf('json') >= 0)) {
396
+ _context.n = 5;
397
+ break;
398
+ }
399
+ _context.n = 4;
400
+ return response.json();
401
+ case 4:
402
+ _data = _context.v;
403
+ return _context.a(2, {
404
+ data: _data,
405
+ status: response.status,
406
+ response: response
407
+ });
408
+ case 5:
409
+ _context.n = 6;
410
+ return response.text();
411
+ case 6:
412
+ data = _context.v;
413
+ return _context.a(2, {
414
+ data: data,
415
+ status: response.status,
416
+ response: response
417
+ });
418
+ }
419
+ }, _callee, this);
420
+ }));
421
+ function _fetch(_x, _x2, _x3, _x4) {
422
+ return _fetch2.apply(this, arguments);
423
+ }
424
+ return _fetch;
425
+ }();
426
+ _proto.get = /*#__PURE__*/function () {
427
+ var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(url, params, auth) {
428
+ var resp, _this$config, _t;
429
+ return _regenerator().w(function (_context2) {
430
+ while (1) switch (_context2.p = _context2.n) {
431
+ case 0:
432
+ if (auth === void 0) {
433
+ auth = undefined;
434
+ }
435
+ _context2.p = 1;
436
+ _context2.n = 2;
437
+ return this._fetch('GET', url, omit_nil(params), auth);
438
+ case 2:
439
+ resp = _context2.v;
440
+ return _context2.a(2, resp);
441
+ case 3:
442
+ _context2.p = 3;
443
+ _t = _context2.v;
444
+ if (((_this$config = this.config) == null ? void 0 : _this$config.silent_fail) !== true) {
445
+ console.error("Error on GET " + url);
446
+ console.error(_t);
447
+ }
448
+ return _context2.a(2, {
449
+ data: _t,
450
+ status: -1
451
+ });
452
+ }
453
+ }, _callee2, this, [[1, 3]]);
454
+ }));
455
+ function get(_x5, _x6, _x7) {
456
+ return _get.apply(this, arguments);
457
+ }
458
+ return get;
459
+ }();
460
+ _proto.post = /*#__PURE__*/function () {
461
+ var _post = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(url, data, auth) {
462
+ var resp, _this$config2, _t2;
463
+ return _regenerator().w(function (_context3) {
464
+ while (1) switch (_context3.p = _context3.n) {
465
+ case 0:
466
+ if (auth === void 0) {
467
+ auth = undefined;
468
+ }
469
+ _context3.p = 1;
470
+ _context3.n = 2;
471
+ return this._fetch('POST', url, data, auth);
472
+ case 2:
473
+ resp = _context3.v;
474
+ return _context3.a(2, resp);
475
+ case 3:
476
+ _context3.p = 3;
477
+ _t2 = _context3.v;
478
+ if (((_this$config2 = this.config) == null ? void 0 : _this$config2.silent_fail) !== true) {
479
+ console.error("Error on POST " + url);
480
+ console.error(_t2);
481
+ }
482
+ return _context3.a(2, {
483
+ data: _t2,
484
+ status: -1
485
+ });
486
+ }
487
+ }, _callee3, this, [[1, 3]]);
488
+ }));
489
+ function post(_x8, _x9, _x0) {
490
+ return _post.apply(this, arguments);
491
+ }
492
+ return post;
493
+ }();
494
+ _proto.login = /*#__PURE__*/function () {
495
+ var _login = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(url, _ref2) {
496
+ var username, password, res;
497
+ return _regenerator().w(function (_context4) {
498
+ while (1) switch (_context4.n) {
499
+ case 0:
500
+ username = _ref2.username, password = _ref2.password;
501
+ _context4.n = 1;
502
+ return this._fetch('POST', url || '/login', {
503
+ username: username,
504
+ password: password
505
+ });
506
+ case 1:
507
+ res = _context4.v;
508
+ this.cookie = parse_login_cookie(res.response);
509
+ return _context4.a(2, res);
510
+ }
511
+ }, _callee4, this);
512
+ }));
513
+ function login(_x1, _x10) {
514
+ return _login.apply(this, arguments);
515
+ }
516
+ return login;
517
+ }();
518
+ _proto.logout = /*#__PURE__*/function () {
519
+ var _logout = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(url) {
520
+ var res;
521
+ return _regenerator().w(function (_context5) {
522
+ while (1) switch (_context5.n) {
523
+ case 0:
524
+ this.cookie = undefined;
525
+ _context5.n = 1;
526
+ return this._fetch('POST', url || '/logout', {});
527
+ case 1:
528
+ res = _context5.v;
529
+ return _context5.a(2, res);
530
+ }
531
+ }, _callee5, this);
532
+ }));
533
+ function logout(_x11) {
534
+ return _logout.apply(this, arguments);
535
+ }
536
+ return logout;
537
+ }();
538
+ _proto.read = /*#__PURE__*/function () {
539
+ var _read = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(url, params, auth) {
540
+ var result;
541
+ return _regenerator().w(function (_context6) {
542
+ while (1) switch (_context6.n) {
543
+ case 0:
544
+ if (auth === void 0) {
545
+ auth = undefined;
546
+ }
547
+ _context6.n = 1;
548
+ return this.get(url + "/read", params, auth);
549
+ case 1:
550
+ result = _context6.v;
551
+ return _context6.a(2, result.data);
552
+ }
553
+ }, _callee6, this);
554
+ }));
555
+ function read(_x12, _x13, _x14) {
556
+ return _read.apply(this, arguments);
557
+ }
558
+ return read;
559
+ }();
560
+ _proto.key_list = /*#__PURE__*/function () {
561
+ var _key_list = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(url, params, auth) {
562
+ var result;
563
+ return _regenerator().w(function (_context7) {
564
+ while (1) switch (_context7.n) {
565
+ case 0:
566
+ if (auth === void 0) {
567
+ auth = undefined;
568
+ }
569
+ _context7.n = 1;
570
+ return this.get(url + "/key_list", params, auth);
571
+ case 1:
572
+ result = _context7.v;
573
+ return _context7.a(2, result.data);
574
+ }
575
+ }, _callee7, this);
576
+ }));
577
+ function key_list(_x15, _x16, _x17) {
578
+ return _key_list.apply(this, arguments);
579
+ }
580
+ return key_list;
581
+ }();
582
+ _proto.name_list = /*#__PURE__*/function () {
583
+ var _name_list = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(url, params, auth) {
584
+ var result;
585
+ return _regenerator().w(function (_context8) {
586
+ while (1) switch (_context8.n) {
587
+ case 0:
588
+ if (auth === void 0) {
589
+ auth = undefined;
590
+ }
591
+ _context8.n = 1;
592
+ return this.key_list(url, params, auth);
593
+ case 1:
594
+ result = _context8.v;
595
+ return _context8.a(2, Object.values(result));
596
+ }
597
+ }, _callee8, this);
598
+ }));
599
+ function name_list(_x18, _x19, _x20) {
600
+ return _name_list.apply(this, arguments);
601
+ }
602
+ return name_list;
603
+ }();
604
+ _proto.find = /*#__PURE__*/function () {
605
+ var _find = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(url, id, auth) {
606
+ var result;
607
+ return _regenerator().w(function (_context9) {
608
+ while (1) switch (_context9.n) {
609
+ case 0:
610
+ if (auth === void 0) {
611
+ auth = undefined;
612
+ }
613
+ _context9.n = 1;
614
+ return this.get(url + "/find", {
615
+ id: id
616
+ }, auth);
617
+ case 1:
618
+ result = _context9.v;
619
+ return _context9.a(2, result.data);
620
+ }
621
+ }, _callee9, this);
622
+ }));
623
+ function find(_x21, _x22, _x23) {
624
+ return _find.apply(this, arguments);
625
+ }
626
+ return find;
627
+ }();
628
+ _proto.distinct = /*#__PURE__*/function () {
629
+ var _distinct = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(url, field, params, auth) {
630
+ var nparams, result;
631
+ return _regenerator().w(function (_context0) {
632
+ while (1) switch (_context0.n) {
633
+ case 0:
634
+ if (auth === void 0) {
635
+ auth = undefined;
636
+ }
637
+ nparams = _extends({}, params, {
638
+ distinct_field: field
639
+ });
640
+ _context0.n = 1;
641
+ return this.get(url + "/distinct", nparams, auth);
642
+ case 1:
643
+ result = _context0.v;
644
+ return _context0.a(2, result.data);
645
+ }
646
+ }, _callee0, this);
647
+ }));
648
+ function distinct(_x24, _x25, _x26, _x27) {
649
+ return _distinct.apply(this, arguments);
650
+ }
651
+ return distinct;
652
+ }();
653
+ _proto.upsave = /*#__PURE__*/function () {
654
+ var _upsave = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(url, data, auth) {
655
+ var result;
656
+ return _regenerator().w(function (_context1) {
657
+ while (1) switch (_context1.n) {
658
+ case 0:
659
+ if (auth === void 0) {
660
+ auth = undefined;
661
+ }
662
+ if (!(data.id == undefined)) {
663
+ _context1.n = 2;
664
+ break;
665
+ }
666
+ delete data.id;
667
+ _context1.n = 1;
668
+ return this.post(url + "/save", data, auth);
669
+ case 1:
670
+ result = _context1.v;
671
+ _context1.n = 4;
672
+ break;
673
+ case 2:
674
+ _context1.n = 3;
675
+ return this.post(url + "/update", data, auth);
676
+ case 3:
677
+ result = _context1.v;
678
+ case 4:
679
+ return _context1.a(2, result.data);
680
+ }
681
+ }, _callee1, this);
682
+ }));
683
+ function upsave(_x28, _x29, _x30) {
684
+ return _upsave.apply(this, arguments);
685
+ }
686
+ return upsave;
687
+ }();
688
+ _proto.remove = /*#__PURE__*/function () {
689
+ var _remove = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(url, id, auth) {
690
+ var data, result;
691
+ return _regenerator().w(function (_context10) {
692
+ while (1) switch (_context10.n) {
693
+ case 0:
694
+ if (auth === void 0) {
695
+ auth = undefined;
696
+ }
697
+ data = {
698
+ id: id
699
+ };
700
+ _context10.n = 1;
701
+ return this.post(url + "/delete", data, auth);
702
+ case 1:
703
+ result = _context10.v;
704
+ return _context10.a(2, result.data);
705
+ }
706
+ }, _callee10, this);
707
+ }));
708
+ function remove(_x31, _x32, _x33) {
709
+ return _remove.apply(this, arguments);
710
+ }
711
+ return remove;
712
+ }();
713
+ return Fetcher;
714
+ }();
715
+ Fetcher.keyList = Fetcher.key_list;
716
+ Fetcher.nameList = Fetcher.name_list;
717
+
718
+ function init_fetcher(config) {
719
+ var fetcher = new Fetcher(config);
720
+ return fetcher;
721
+ }
722
+
723
+ // import {init_socket} from './socket/index.mjs'
724
+
725
+ function miolo_client(context) {
726
+ var config = context.config;
727
+ var fetcher = init_fetcher(config);
728
+ if (config != null && config.catcher_url) {
729
+ init_catcher(config == null ? void 0 : config.catcher_url, fetcher);
730
+ }
731
+
732
+ // let socket
733
+ // if (config?.socket?.enabled===true) {
734
+ // const domain = config?.socket?.domain
735
+ // const options = config?.socket?.options
736
+ // socket = init_socket(domain, options)
737
+ // }
738
+
739
+ var miolo_obj = {
740
+ fetcher: fetcher
741
+ //socket
742
+ };
743
+ return miolo_obj;
744
+ }
745
+
746
+ exports.miolo_client = miolo_client;
747
+
748
+ }));
749
+ //# sourceMappingURL=miolo-cli.umd.js.map