@ztimson/momentum 0.19.0 → 0.21.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 +2 -1
- package/dist/actions.d.ts +13 -13
- package/dist/actions.d.ts.map +1 -1
- package/dist/auth.d.ts +2 -21
- package/dist/auth.d.ts.map +1 -1
- package/dist/email.d.ts +1 -1
- package/dist/email.d.ts.map +1 -1
- package/dist/groups.d.ts +9 -1
- package/dist/groups.d.ts.map +1 -1
- package/dist/momentum.cjs +2 -2
- package/dist/momentum.cjs.map +1 -1
- package/dist/momentum.mjs +319 -326
- package/dist/momentum.mjs.map +1 -1
- package/dist/pdf.d.ts +5 -5
- package/dist/pdf.d.ts.map +1 -1
- package/dist/users.d.ts +13 -1
- package/dist/users.d.ts.map +1 -1
- package/package.json +7 -2
package/dist/momentum.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var at = Object.defineProperty;
|
|
2
|
+
var ut = (i, e, t) => e in i ? at(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var u = (i, e, t) => ut(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var ct = Object.defineProperty, ht = (i, e, t) => e in i ? ct(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, h = (i, e, t) => (ht(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
5
5
|
function lt(i, e = !1) {
|
|
6
6
|
if (i == null)
|
|
@@ -11,13 +11,13 @@ function lt(i, e = !1) {
|
|
|
11
11
|
}
|
|
12
12
|
function X(i, e) {
|
|
13
13
|
const t = typeof i, r = typeof e;
|
|
14
|
-
return t != "object" || i == null || r != "object" || e == null ? t == "function" && r == "function" ? i.toString() == e.toString() : i === e : Object.keys(i).length != Object.keys(e).length ? !1 : Object.keys(i).every((
|
|
14
|
+
return t != "object" || i == null || r != "object" || e == null ? t == "function" && r == "function" ? i.toString() == e.toString() : i === e : Object.keys(i).length != Object.keys(e).length ? !1 : Object.keys(i).every((s) => X(i[s], e[s]));
|
|
15
15
|
}
|
|
16
16
|
function Z(i, e) {
|
|
17
17
|
const t = document.createElement("a");
|
|
18
18
|
t.href = i, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
19
19
|
}
|
|
20
|
-
class
|
|
20
|
+
class d {
|
|
21
21
|
constructor() {
|
|
22
22
|
h(this, "listeners", {});
|
|
23
23
|
}
|
|
@@ -26,17 +26,17 @@ class p {
|
|
|
26
26
|
}
|
|
27
27
|
static off(e, t) {
|
|
28
28
|
const r = e.toString();
|
|
29
|
-
this.listeners[r] = (this.listeners[r] || []).filter((
|
|
29
|
+
this.listeners[r] = (this.listeners[r] || []).filter((s) => s === t);
|
|
30
30
|
}
|
|
31
31
|
static on(e, t) {
|
|
32
32
|
var r;
|
|
33
|
-
const
|
|
34
|
-
return this.listeners[
|
|
33
|
+
const s = e.toString();
|
|
34
|
+
return this.listeners[s] || (this.listeners[s] = []), (r = this.listeners[s]) == null || r.push(t), () => this.off(e, t);
|
|
35
35
|
}
|
|
36
36
|
static once(e, t) {
|
|
37
37
|
return new Promise((r) => {
|
|
38
|
-
const
|
|
39
|
-
r(
|
|
38
|
+
const s = this.on(e, (...n) => {
|
|
39
|
+
r(n.length == 1 ? n[0] : n), t && t(...n), s();
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -52,13 +52,13 @@ class p {
|
|
|
52
52
|
}
|
|
53
53
|
once(e, t) {
|
|
54
54
|
return new Promise((r) => {
|
|
55
|
-
const
|
|
56
|
-
r(
|
|
55
|
+
const s = this.on(e, (...n) => {
|
|
56
|
+
r(n.length == 1 ? n[0] : n), t && t(...n), s();
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
h(
|
|
61
|
+
h(d, "listeners", {});
|
|
62
62
|
class L extends Error {
|
|
63
63
|
constructor(e, t) {
|
|
64
64
|
super(e), h(this, "_code"), t != null && (this._code = t);
|
|
@@ -85,7 +85,7 @@ class L extends Error {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
h(L, "code", 500);
|
|
88
|
-
class
|
|
88
|
+
class pt extends L {
|
|
89
89
|
constructor(e = "Bad Request") {
|
|
90
90
|
super(e);
|
|
91
91
|
}
|
|
@@ -93,8 +93,8 @@ class dt extends L {
|
|
|
93
93
|
return e.constructor.code == this.code;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
h(
|
|
97
|
-
class
|
|
96
|
+
h(pt, "code", 400);
|
|
97
|
+
class dt extends L {
|
|
98
98
|
constructor(e = "Unauthorized") {
|
|
99
99
|
super(e);
|
|
100
100
|
}
|
|
@@ -102,7 +102,7 @@ class pt extends L {
|
|
|
102
102
|
return e.constructor.code == this.code;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
h(
|
|
105
|
+
h(dt, "code", 401);
|
|
106
106
|
class ft extends L {
|
|
107
107
|
constructor(e = "Forbidden") {
|
|
108
108
|
super(e);
|
|
@@ -121,7 +121,7 @@ class mt extends L {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
h(mt, "code", 404);
|
|
124
|
-
class
|
|
124
|
+
class yt extends L {
|
|
125
125
|
constructor(e = "Internal Server Error") {
|
|
126
126
|
super(e);
|
|
127
127
|
}
|
|
@@ -129,7 +129,7 @@ class Et extends L {
|
|
|
129
129
|
return e.constructor.code == this.code;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
h(
|
|
132
|
+
h(yt, "code", 500);
|
|
133
133
|
const O = {
|
|
134
134
|
CLEAR: "\x1B[0m",
|
|
135
135
|
BRIGHT: "\x1B[1m",
|
|
@@ -138,7 +138,7 @@ const O = {
|
|
|
138
138
|
BLINK: "\x1B[5m",
|
|
139
139
|
REVERSE: "\x1B[7m",
|
|
140
140
|
HIDDEN: "\x1B[8m"
|
|
141
|
-
},
|
|
141
|
+
}, A = {
|
|
142
142
|
BLACK: "\x1B[30m",
|
|
143
143
|
RED: "\x1B[31m",
|
|
144
144
|
GREEN: "\x1B[32m",
|
|
@@ -157,16 +157,16 @@ const O = {
|
|
|
157
157
|
WHITE: "\x1B[97m"
|
|
158
158
|
};
|
|
159
159
|
var S = /* @__PURE__ */ ((i) => (i[i.ERROR = 0] = "ERROR", i[i.WARN = 1] = "WARN", i[i.INFO = 2] = "INFO", i[i.LOG = 3] = "LOG", i[i.DEBUG = 4] = "DEBUG", i))(S || {});
|
|
160
|
-
const
|
|
160
|
+
const Et = class m extends d {
|
|
161
161
|
constructor(e) {
|
|
162
162
|
super(), this.namespace = e;
|
|
163
163
|
}
|
|
164
|
-
pad(e, t, r,
|
|
165
|
-
const
|
|
164
|
+
pad(e, t, r, s = !1) {
|
|
165
|
+
const n = e.toString(), o = t - n.length;
|
|
166
166
|
if (o <= 0)
|
|
167
|
-
return
|
|
168
|
-
const
|
|
169
|
-
return
|
|
167
|
+
return n;
|
|
168
|
+
const a = Array(~~(o / r.length)).fill(r).join("");
|
|
169
|
+
return s ? n + a : a + n;
|
|
170
170
|
}
|
|
171
171
|
format(...e) {
|
|
172
172
|
const t = /* @__PURE__ */ new Date();
|
|
@@ -176,7 +176,7 @@ const yt = class m extends p {
|
|
|
176
176
|
if (m.LOG_LEVEL < 4)
|
|
177
177
|
return;
|
|
178
178
|
const t = this.format(...e);
|
|
179
|
-
m.emit(4, t), console.debug(
|
|
179
|
+
m.emit(4, t), console.debug(A.LIGHT_GREY + t + O.CLEAR);
|
|
180
180
|
}
|
|
181
181
|
log(...e) {
|
|
182
182
|
if (m.LOG_LEVEL < 3)
|
|
@@ -188,28 +188,28 @@ const yt = class m extends p {
|
|
|
188
188
|
if (m.LOG_LEVEL < 2)
|
|
189
189
|
return;
|
|
190
190
|
const t = this.format(...e);
|
|
191
|
-
m.emit(2, t), console.info(
|
|
191
|
+
m.emit(2, t), console.info(A.BLUE + t + O.CLEAR);
|
|
192
192
|
}
|
|
193
193
|
warn(...e) {
|
|
194
194
|
if (m.LOG_LEVEL < 1)
|
|
195
195
|
return;
|
|
196
196
|
const t = this.format(...e);
|
|
197
|
-
m.emit(1, t), console.warn(
|
|
197
|
+
m.emit(1, t), console.warn(A.YELLOW + t + O.CLEAR);
|
|
198
198
|
}
|
|
199
199
|
error(...e) {
|
|
200
200
|
if (m.LOG_LEVEL < 0)
|
|
201
201
|
return;
|
|
202
202
|
const t = this.format(...e);
|
|
203
|
-
m.emit(0, t), console.error(
|
|
203
|
+
m.emit(0, t), console.error(A.RED + t + O.CLEAR);
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
|
-
h(
|
|
207
|
-
class
|
|
206
|
+
h(Et, "LOG_LEVEL", 4);
|
|
207
|
+
class gt extends Promise {
|
|
208
208
|
constructor(e) {
|
|
209
209
|
super((t, r) => e(
|
|
210
|
-
(
|
|
211
|
-
(
|
|
212
|
-
(
|
|
210
|
+
(s) => t(s),
|
|
211
|
+
(s) => r(s),
|
|
212
|
+
(s) => this.progress = s
|
|
213
213
|
)), h(this, "listeners", []), h(this, "_progress", 0);
|
|
214
214
|
}
|
|
215
215
|
get progress() {
|
|
@@ -222,7 +222,7 @@ class bt extends Promise {
|
|
|
222
222
|
return this.listeners.push(e), this;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
const
|
|
225
|
+
const j = class v {
|
|
226
226
|
constructor(e = {}) {
|
|
227
227
|
h(this, "interceptors", {}), h(this, "headers", {}), this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => v.addInterceptor(t));
|
|
228
228
|
}
|
|
@@ -242,113 +242,111 @@ const B = class v {
|
|
|
242
242
|
var t, r;
|
|
243
243
|
if (!this.opts.url && !e.url)
|
|
244
244
|
throw new Error("URL needs to be set");
|
|
245
|
-
|
|
245
|
+
let s = ((t = e.url) != null && t.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
246
|
+
if (e.fragment && (s.includes("#") ? s.replace(/#.*(\?|\n)/g, (o, a) => `#${e.fragment}${a}`) : s += "#" + e.fragment), e.query) {
|
|
247
|
+
const o = Array.isArray(e.query) ? e.query : Object.keys(e.query).map((a) => ({ key: a, value: e.query[a] }));
|
|
248
|
+
s += (s.includes("?") ? "&" : "?") + o.map((a) => `${a.key}=${a.value}`).join("&");
|
|
249
|
+
}
|
|
250
|
+
const n = lt({
|
|
246
251
|
"Content-Type": e.body && !(e.body instanceof FormData) ? "application/json" : void 0,
|
|
247
252
|
...v.headers,
|
|
248
253
|
...this.headers,
|
|
249
254
|
...e.headers
|
|
250
255
|
});
|
|
251
|
-
return fetch(
|
|
252
|
-
headers:
|
|
256
|
+
return fetch(s, {
|
|
257
|
+
headers: n,
|
|
253
258
|
method: e.method || (e.body ? "POST" : "GET"),
|
|
254
|
-
body: (r =
|
|
259
|
+
body: (r = n["Content-Type"]) != null && r.startsWith("application/json") && e.body ? JSON.stringify(e.body) : e.body
|
|
255
260
|
}).then(async (o) => {
|
|
256
261
|
for (let l of [...Object.values(v.interceptors), ...Object.values(this.interceptors)])
|
|
257
|
-
await new Promise((
|
|
258
|
-
const
|
|
259
|
-
var l,
|
|
260
|
-
return !e.skipConverting && (l = o.headers.get("Content-Type")) != null && l.startsWith("application/json") ? await o.json() : !e.skipConverting && (
|
|
262
|
+
await new Promise((E) => l(o, () => E()));
|
|
263
|
+
const a = await (async () => {
|
|
264
|
+
var l, E;
|
|
265
|
+
return !e.skipConverting && (l = o.headers.get("Content-Type")) != null && l.startsWith("application/json") ? await o.json() : !e.skipConverting && (E = o.headers.get("Content-Type")) != null && E.startsWith("text/plain") ? await o.text() : o;
|
|
261
266
|
})();
|
|
262
267
|
if (o.ok)
|
|
263
|
-
return
|
|
264
|
-
const c = o.statusText || (typeof
|
|
265
|
-
throw c ? new Error(c) :
|
|
268
|
+
return a;
|
|
269
|
+
const c = o.statusText || (typeof a == "string" ? a : null);
|
|
270
|
+
throw c ? new Error(c) : a;
|
|
266
271
|
});
|
|
267
272
|
}
|
|
268
273
|
};
|
|
269
|
-
h(
|
|
270
|
-
let
|
|
271
|
-
class f extends
|
|
274
|
+
h(j, "interceptors", {}), h(j, "headers", {});
|
|
275
|
+
let bt = j;
|
|
276
|
+
class f extends bt {
|
|
272
277
|
constructor(t = location.origin, r = {}) {
|
|
273
278
|
r.url = t;
|
|
274
279
|
super(r);
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
280
|
+
u(this, "emitter", new d());
|
|
281
|
+
u(this, "_token", null);
|
|
282
|
+
u(this, "emit", this.emitter.emit.bind(this.emitter));
|
|
283
|
+
u(this, "off", this.emitter.off.bind(this.emitter));
|
|
284
|
+
u(this, "on", this.emitter.on.bind(this.emitter));
|
|
285
|
+
u(this, "once", this.emitter.once.bind(this.emitter));
|
|
281
286
|
this.url = t, this.opts = r;
|
|
282
287
|
}
|
|
283
288
|
get token() {
|
|
284
289
|
return this._token;
|
|
285
290
|
}
|
|
286
291
|
set token(t) {
|
|
287
|
-
t != this._token && (this._token = t, this.headers.Authorization = `Bearer ${t}
|
|
292
|
+
t != this._token && (this._token = t, this.headers.Authorization = t ? `Bearer ${t}` : void 0, this.emit("TOKEN", t));
|
|
288
293
|
}
|
|
289
294
|
request(t) {
|
|
290
|
-
const r = super.request(t).then((
|
|
291
|
-
throw this.emit("REJECTED",
|
|
295
|
+
const r = super.request(t).then((s) => (this.emit("RESPONSE", s, t), s)).catch((s) => {
|
|
296
|
+
throw this.emit("REJECTED", s, t), s;
|
|
292
297
|
});
|
|
293
298
|
return this.emit("REQUEST", r, t), r;
|
|
294
299
|
}
|
|
295
300
|
}
|
|
296
|
-
var
|
|
297
|
-
return
|
|
301
|
+
var k = function(i, e) {
|
|
302
|
+
return k = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, r) {
|
|
298
303
|
t.__proto__ = r;
|
|
299
304
|
} || function(t, r) {
|
|
300
|
-
for (var
|
|
301
|
-
|
|
302
|
-
}, j(i, e);
|
|
305
|
+
for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (t[s] = r[s]);
|
|
306
|
+
}, k(i, e);
|
|
303
307
|
};
|
|
304
308
|
function $(i, e) {
|
|
305
309
|
if (typeof e != "function" && e !== null)
|
|
306
310
|
throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
|
|
307
|
-
|
|
311
|
+
k(i, e);
|
|
308
312
|
function t() {
|
|
309
313
|
this.constructor = i;
|
|
310
314
|
}
|
|
311
315
|
i.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
312
316
|
}
|
|
313
|
-
function
|
|
317
|
+
function B(i) {
|
|
314
318
|
var e = typeof Symbol == "function" && Symbol.iterator, t = e && i[e], r = 0;
|
|
315
|
-
if (t)
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
};
|
|
319
|
+
if (t) return t.call(i);
|
|
320
|
+
if (i && typeof i.length == "number") return {
|
|
321
|
+
next: function() {
|
|
322
|
+
return i && r >= i.length && (i = void 0), { value: i && i[r++], done: !i };
|
|
323
|
+
}
|
|
324
|
+
};
|
|
323
325
|
throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
324
326
|
}
|
|
325
327
|
function G(i, e) {
|
|
326
328
|
var t = typeof Symbol == "function" && i[Symbol.iterator];
|
|
327
|
-
if (!t)
|
|
328
|
-
|
|
329
|
-
var r = t.call(i), n, s = [], o;
|
|
329
|
+
if (!t) return i;
|
|
330
|
+
var r = t.call(i), s, n = [], o;
|
|
330
331
|
try {
|
|
331
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
o = { error: u };
|
|
332
|
+
for (; (e === void 0 || e-- > 0) && !(s = r.next()).done; ) n.push(s.value);
|
|
333
|
+
} catch (a) {
|
|
334
|
+
o = { error: a };
|
|
335
335
|
} finally {
|
|
336
336
|
try {
|
|
337
|
-
|
|
337
|
+
s && !s.done && (t = r.return) && t.call(r);
|
|
338
338
|
} finally {
|
|
339
|
-
if (o)
|
|
340
|
-
throw o.error;
|
|
339
|
+
if (o) throw o.error;
|
|
341
340
|
}
|
|
342
341
|
}
|
|
343
|
-
return
|
|
342
|
+
return n;
|
|
344
343
|
}
|
|
345
344
|
function N(i, e, t) {
|
|
346
|
-
if (t || arguments.length === 2)
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return i.concat(s || Array.prototype.slice.call(e));
|
|
345
|
+
if (t || arguments.length === 2) for (var r = 0, s = e.length, n; r < s; r++)
|
|
346
|
+
(n || !(r in e)) && (n || (n = Array.prototype.slice.call(e, 0, r)), n[r] = e[r]);
|
|
347
|
+
return i.concat(n || Array.prototype.slice.call(e));
|
|
350
348
|
}
|
|
351
|
-
function
|
|
349
|
+
function g(i) {
|
|
352
350
|
return typeof i == "function";
|
|
353
351
|
}
|
|
354
352
|
function tt(i) {
|
|
@@ -360,8 +358,8 @@ function tt(i) {
|
|
|
360
358
|
var U = tt(function(i) {
|
|
361
359
|
return function(t) {
|
|
362
360
|
i(this), this.message = t ? t.length + ` errors occurred during unsubscription:
|
|
363
|
-
` + t.map(function(r,
|
|
364
|
-
return
|
|
361
|
+
` + t.map(function(r, s) {
|
|
362
|
+
return s + 1 + ") " + r.toString();
|
|
365
363
|
}).join(`
|
|
366
364
|
`) : "", this.name = "UnsubscriptionError", this.errors = t;
|
|
367
365
|
};
|
|
@@ -377,61 +375,59 @@ var P = function() {
|
|
|
377
375
|
this.initialTeardown = e, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
378
376
|
}
|
|
379
377
|
return i.prototype.unsubscribe = function() {
|
|
380
|
-
var e, t, r,
|
|
378
|
+
var e, t, r, s, n;
|
|
381
379
|
if (!this.closed) {
|
|
382
380
|
this.closed = !0;
|
|
383
381
|
var o = this._parentage;
|
|
384
382
|
if (o)
|
|
385
383
|
if (this._parentage = null, Array.isArray(o))
|
|
386
384
|
try {
|
|
387
|
-
for (var
|
|
385
|
+
for (var a = B(o), c = a.next(); !c.done; c = a.next()) {
|
|
388
386
|
var l = c.value;
|
|
389
387
|
l.remove(this);
|
|
390
388
|
}
|
|
391
|
-
} catch (
|
|
392
|
-
e = { error:
|
|
389
|
+
} catch (p) {
|
|
390
|
+
e = { error: p };
|
|
393
391
|
} finally {
|
|
394
392
|
try {
|
|
395
|
-
c && !c.done && (t =
|
|
393
|
+
c && !c.done && (t = a.return) && t.call(a);
|
|
396
394
|
} finally {
|
|
397
|
-
if (e)
|
|
398
|
-
throw e.error;
|
|
395
|
+
if (e) throw e.error;
|
|
399
396
|
}
|
|
400
397
|
}
|
|
401
398
|
else
|
|
402
399
|
o.remove(this);
|
|
403
|
-
var
|
|
404
|
-
if (
|
|
400
|
+
var E = this.initialTeardown;
|
|
401
|
+
if (g(E))
|
|
405
402
|
try {
|
|
406
|
-
|
|
407
|
-
} catch (
|
|
408
|
-
|
|
403
|
+
E();
|
|
404
|
+
} catch (p) {
|
|
405
|
+
n = p instanceof U ? p.errors : [p];
|
|
409
406
|
}
|
|
410
407
|
var T = this._finalizers;
|
|
411
408
|
if (T) {
|
|
412
409
|
this._finalizers = null;
|
|
413
410
|
try {
|
|
414
|
-
for (var
|
|
415
|
-
var _ =
|
|
411
|
+
for (var b = B(T), y = b.next(); !y.done; y = b.next()) {
|
|
412
|
+
var _ = y.value;
|
|
416
413
|
try {
|
|
417
414
|
V(_);
|
|
418
|
-
} catch (
|
|
419
|
-
|
|
415
|
+
} catch (p) {
|
|
416
|
+
n = n ?? [], p instanceof U ? n = N(N([], G(n)), G(p.errors)) : n.push(p);
|
|
420
417
|
}
|
|
421
418
|
}
|
|
422
|
-
} catch (
|
|
423
|
-
r = { error:
|
|
419
|
+
} catch (p) {
|
|
420
|
+
r = { error: p };
|
|
424
421
|
} finally {
|
|
425
422
|
try {
|
|
426
|
-
|
|
423
|
+
y && !y.done && (s = b.return) && s.call(b);
|
|
427
424
|
} finally {
|
|
428
|
-
if (r)
|
|
429
|
-
throw r.error;
|
|
425
|
+
if (r) throw r.error;
|
|
430
426
|
}
|
|
431
427
|
}
|
|
432
428
|
}
|
|
433
|
-
if (
|
|
434
|
-
throw new U(
|
|
429
|
+
if (n)
|
|
430
|
+
throw new U(n);
|
|
435
431
|
}
|
|
436
432
|
}, i.prototype.add = function(e) {
|
|
437
433
|
var t;
|
|
@@ -464,10 +460,10 @@ var P = function() {
|
|
|
464
460
|
}(), i;
|
|
465
461
|
}(), et = P.EMPTY;
|
|
466
462
|
function rt(i) {
|
|
467
|
-
return i instanceof P || i && "closed" in i &&
|
|
463
|
+
return i instanceof P || i && "closed" in i && g(i.remove) && g(i.add) && g(i.unsubscribe);
|
|
468
464
|
}
|
|
469
465
|
function V(i) {
|
|
470
|
-
|
|
466
|
+
g(i) ? i() : i.unsubscribe();
|
|
471
467
|
}
|
|
472
468
|
var it = {
|
|
473
469
|
onUnhandledError: null,
|
|
@@ -475,20 +471,20 @@ var it = {
|
|
|
475
471
|
Promise: void 0,
|
|
476
472
|
useDeprecatedSynchronousErrorHandling: !1,
|
|
477
473
|
useDeprecatedNextContext: !1
|
|
478
|
-
},
|
|
474
|
+
}, st = {
|
|
479
475
|
setTimeout: function(i, e) {
|
|
480
476
|
for (var t = [], r = 2; r < arguments.length; r++)
|
|
481
477
|
t[r - 2] = arguments[r];
|
|
482
478
|
return setTimeout.apply(void 0, N([i, e], G(t)));
|
|
483
479
|
},
|
|
484
480
|
clearTimeout: function(i) {
|
|
485
|
-
var e =
|
|
481
|
+
var e = st.delegate;
|
|
486
482
|
return ((e == null ? void 0 : e.clearTimeout) || clearTimeout)(i);
|
|
487
483
|
},
|
|
488
484
|
delegate: void 0
|
|
489
485
|
};
|
|
490
486
|
function vt(i) {
|
|
491
|
-
|
|
487
|
+
st.setTimeout(function() {
|
|
492
488
|
throw i;
|
|
493
489
|
});
|
|
494
490
|
}
|
|
@@ -497,14 +493,14 @@ function K() {
|
|
|
497
493
|
function x(i) {
|
|
498
494
|
i();
|
|
499
495
|
}
|
|
500
|
-
var
|
|
496
|
+
var nt = function(i) {
|
|
501
497
|
$(e, i);
|
|
502
498
|
function e(t) {
|
|
503
499
|
var r = i.call(this) || this;
|
|
504
500
|
return r.isStopped = !1, t ? (r.destination = t, rt(t) && t.add(r)) : r.destination = Tt, r;
|
|
505
501
|
}
|
|
506
|
-
return e.create = function(t, r,
|
|
507
|
-
return new W(t, r,
|
|
502
|
+
return e.create = function(t, r, s) {
|
|
503
|
+
return new W(t, r, s);
|
|
508
504
|
}, e.prototype.next = function(t) {
|
|
509
505
|
this.isStopped || this._next(t);
|
|
510
506
|
}, e.prototype.error = function(t) {
|
|
@@ -542,7 +538,7 @@ var St = function() {
|
|
|
542
538
|
try {
|
|
543
539
|
t.next(e);
|
|
544
540
|
} catch (r) {
|
|
545
|
-
|
|
541
|
+
R(r);
|
|
546
542
|
}
|
|
547
543
|
}, i.prototype.error = function(e) {
|
|
548
544
|
var t = this.partialObserver;
|
|
@@ -550,44 +546,44 @@ var St = function() {
|
|
|
550
546
|
try {
|
|
551
547
|
t.error(e);
|
|
552
548
|
} catch (r) {
|
|
553
|
-
|
|
549
|
+
R(r);
|
|
554
550
|
}
|
|
555
551
|
else
|
|
556
|
-
|
|
552
|
+
R(e);
|
|
557
553
|
}, i.prototype.complete = function() {
|
|
558
554
|
var e = this.partialObserver;
|
|
559
555
|
if (e.complete)
|
|
560
556
|
try {
|
|
561
557
|
e.complete();
|
|
562
558
|
} catch (t) {
|
|
563
|
-
|
|
559
|
+
R(t);
|
|
564
560
|
}
|
|
565
561
|
}, i;
|
|
566
562
|
}(), W = function(i) {
|
|
567
563
|
$(e, i);
|
|
568
|
-
function e(t, r,
|
|
569
|
-
var
|
|
570
|
-
if (
|
|
564
|
+
function e(t, r, s) {
|
|
565
|
+
var n = i.call(this) || this, o;
|
|
566
|
+
if (g(t) || !t)
|
|
571
567
|
o = {
|
|
572
568
|
next: t ?? void 0,
|
|
573
569
|
error: r ?? void 0,
|
|
574
|
-
complete:
|
|
570
|
+
complete: s ?? void 0
|
|
575
571
|
};
|
|
576
572
|
else {
|
|
577
|
-
var
|
|
578
|
-
|
|
579
|
-
return
|
|
573
|
+
var a;
|
|
574
|
+
n && it.useDeprecatedNextContext ? (a = Object.create(t), a.unsubscribe = function() {
|
|
575
|
+
return n.unsubscribe();
|
|
580
576
|
}, o = {
|
|
581
|
-
next: t.next && C(t.next,
|
|
582
|
-
error: t.error && C(t.error,
|
|
583
|
-
complete: t.complete && C(t.complete,
|
|
577
|
+
next: t.next && C(t.next, a),
|
|
578
|
+
error: t.error && C(t.error, a),
|
|
579
|
+
complete: t.complete && C(t.complete, a)
|
|
584
580
|
}) : o = t;
|
|
585
581
|
}
|
|
586
|
-
return
|
|
582
|
+
return n.destination = new St(o), n;
|
|
587
583
|
}
|
|
588
584
|
return e;
|
|
589
|
-
}(
|
|
590
|
-
function
|
|
585
|
+
}(nt);
|
|
586
|
+
function R(i) {
|
|
591
587
|
vt(i);
|
|
592
588
|
}
|
|
593
589
|
function Lt(i) {
|
|
@@ -606,8 +602,8 @@ function $t(i) {
|
|
|
606
602
|
}
|
|
607
603
|
function _t(i) {
|
|
608
604
|
return i.length === 0 ? $t : i.length === 1 ? i[0] : function(t) {
|
|
609
|
-
return i.reduce(function(r,
|
|
610
|
-
return
|
|
605
|
+
return i.reduce(function(r, s) {
|
|
606
|
+
return s(r);
|
|
611
607
|
}, t);
|
|
612
608
|
};
|
|
613
609
|
}
|
|
@@ -619,11 +615,11 @@ var z = function() {
|
|
|
619
615
|
var t = new i();
|
|
620
616
|
return t.source = this, t.operator = e, t;
|
|
621
617
|
}, i.prototype.subscribe = function(e, t, r) {
|
|
622
|
-
var
|
|
618
|
+
var s = this, n = Rt(e) ? e : new W(e, t, r);
|
|
623
619
|
return x(function() {
|
|
624
|
-
var o =
|
|
625
|
-
|
|
626
|
-
}),
|
|
620
|
+
var o = s, a = o.operator, c = o.source;
|
|
621
|
+
n.add(a ? a.call(n, c) : c ? s._subscribe(n) : s._trySubscribe(n));
|
|
622
|
+
}), n;
|
|
627
623
|
}, i.prototype._trySubscribe = function(e) {
|
|
628
624
|
try {
|
|
629
625
|
return this._subscribe(e);
|
|
@@ -632,17 +628,17 @@ var z = function() {
|
|
|
632
628
|
}
|
|
633
629
|
}, i.prototype.forEach = function(e, t) {
|
|
634
630
|
var r = this;
|
|
635
|
-
return t = J(t), new t(function(
|
|
631
|
+
return t = J(t), new t(function(s, n) {
|
|
636
632
|
var o = new W({
|
|
637
|
-
next: function(
|
|
633
|
+
next: function(a) {
|
|
638
634
|
try {
|
|
639
|
-
e(
|
|
635
|
+
e(a);
|
|
640
636
|
} catch (c) {
|
|
641
|
-
|
|
637
|
+
n(c), o.unsubscribe();
|
|
642
638
|
}
|
|
643
639
|
},
|
|
644
|
-
error:
|
|
645
|
-
complete:
|
|
640
|
+
error: n,
|
|
641
|
+
complete: s
|
|
646
642
|
});
|
|
647
643
|
r.subscribe(o);
|
|
648
644
|
});
|
|
@@ -657,14 +653,14 @@ var z = function() {
|
|
|
657
653
|
return _t(e)(this);
|
|
658
654
|
}, i.prototype.toPromise = function(e) {
|
|
659
655
|
var t = this;
|
|
660
|
-
return e = J(e), new e(function(r,
|
|
661
|
-
var
|
|
656
|
+
return e = J(e), new e(function(r, s) {
|
|
657
|
+
var n;
|
|
662
658
|
t.subscribe(function(o) {
|
|
663
|
-
return
|
|
659
|
+
return n = o;
|
|
664
660
|
}, function(o) {
|
|
665
|
-
return
|
|
661
|
+
return s(o);
|
|
666
662
|
}, function() {
|
|
667
|
-
return r(
|
|
663
|
+
return r(n);
|
|
668
664
|
});
|
|
669
665
|
});
|
|
670
666
|
}, i.create = function(e) {
|
|
@@ -675,11 +671,11 @@ function J(i) {
|
|
|
675
671
|
var e;
|
|
676
672
|
return (e = i ?? it.Promise) !== null && e !== void 0 ? e : Promise;
|
|
677
673
|
}
|
|
678
|
-
function Rt(i) {
|
|
679
|
-
return i && b(i.next) && b(i.error) && b(i.complete);
|
|
680
|
-
}
|
|
681
674
|
function At(i) {
|
|
682
|
-
return i && i
|
|
675
|
+
return i && g(i.next) && g(i.error) && g(i.complete);
|
|
676
|
+
}
|
|
677
|
+
function Rt(i) {
|
|
678
|
+
return i && i instanceof nt || At(i) && rt(i);
|
|
683
679
|
}
|
|
684
680
|
var xt = tt(function(i) {
|
|
685
681
|
return function() {
|
|
@@ -700,22 +696,21 @@ var xt = tt(function(i) {
|
|
|
700
696
|
}, e.prototype.next = function(t) {
|
|
701
697
|
var r = this;
|
|
702
698
|
x(function() {
|
|
703
|
-
var
|
|
699
|
+
var s, n;
|
|
704
700
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
705
701
|
r.currentObservers || (r.currentObservers = Array.from(r.observers));
|
|
706
702
|
try {
|
|
707
|
-
for (var o =
|
|
708
|
-
var c =
|
|
703
|
+
for (var o = B(r.currentObservers), a = o.next(); !a.done; a = o.next()) {
|
|
704
|
+
var c = a.value;
|
|
709
705
|
c.next(t);
|
|
710
706
|
}
|
|
711
707
|
} catch (l) {
|
|
712
|
-
|
|
708
|
+
s = { error: l };
|
|
713
709
|
} finally {
|
|
714
710
|
try {
|
|
715
|
-
|
|
711
|
+
a && !a.done && (n = o.return) && n.call(o);
|
|
716
712
|
} finally {
|
|
717
|
-
if (
|
|
718
|
-
throw n.error;
|
|
713
|
+
if (s) throw s.error;
|
|
719
714
|
}
|
|
720
715
|
}
|
|
721
716
|
}
|
|
@@ -725,8 +720,8 @@ var xt = tt(function(i) {
|
|
|
725
720
|
x(function() {
|
|
726
721
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
727
722
|
r.hasError = r.isStopped = !0, r.thrownError = t;
|
|
728
|
-
for (var
|
|
729
|
-
|
|
723
|
+
for (var s = r.observers; s.length; )
|
|
724
|
+
s.shift().error(t);
|
|
730
725
|
}
|
|
731
726
|
});
|
|
732
727
|
}, e.prototype.complete = function() {
|
|
@@ -752,13 +747,13 @@ var xt = tt(function(i) {
|
|
|
752
747
|
}, e.prototype._subscribe = function(t) {
|
|
753
748
|
return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
|
|
754
749
|
}, e.prototype._innerSubscribe = function(t) {
|
|
755
|
-
var r = this,
|
|
756
|
-
return
|
|
757
|
-
r.currentObservers = null, H(
|
|
750
|
+
var r = this, s = this, n = s.hasError, o = s.isStopped, a = s.observers;
|
|
751
|
+
return n || o ? et : (this.currentObservers = null, a.push(t), new P(function() {
|
|
752
|
+
r.currentObservers = null, H(a, t);
|
|
758
753
|
}));
|
|
759
754
|
}, e.prototype._checkFinalizedStatuses = function(t) {
|
|
760
|
-
var r = this,
|
|
761
|
-
|
|
755
|
+
var r = this, s = r.hasError, n = r.thrownError, o = r.isStopped;
|
|
756
|
+
s ? t.error(n) : o && t.complete();
|
|
762
757
|
}, e.prototype.asObservable = function() {
|
|
763
758
|
var t = new z();
|
|
764
759
|
return t.source = this, t;
|
|
@@ -768,23 +763,23 @@ var xt = tt(function(i) {
|
|
|
768
763
|
}(z), Q = function(i) {
|
|
769
764
|
$(e, i);
|
|
770
765
|
function e(t, r) {
|
|
771
|
-
var
|
|
772
|
-
return
|
|
766
|
+
var s = i.call(this) || this;
|
|
767
|
+
return s.destination = t, s.source = r, s;
|
|
773
768
|
}
|
|
774
769
|
return e.prototype.next = function(t) {
|
|
775
|
-
var r,
|
|
776
|
-
(
|
|
770
|
+
var r, s;
|
|
771
|
+
(s = (r = this.destination) === null || r === void 0 ? void 0 : r.next) === null || s === void 0 || s.call(r, t);
|
|
777
772
|
}, e.prototype.error = function(t) {
|
|
778
|
-
var r,
|
|
779
|
-
(
|
|
773
|
+
var r, s;
|
|
774
|
+
(s = (r = this.destination) === null || r === void 0 ? void 0 : r.error) === null || s === void 0 || s.call(r, t);
|
|
780
775
|
}, e.prototype.complete = function() {
|
|
781
776
|
var t, r;
|
|
782
777
|
(r = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || r === void 0 || r.call(t);
|
|
783
778
|
}, e.prototype._subscribe = function(t) {
|
|
784
|
-
var r,
|
|
785
|
-
return (
|
|
779
|
+
var r, s;
|
|
780
|
+
return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t)) !== null && s !== void 0 ? s : et;
|
|
786
781
|
}, e;
|
|
787
|
-
}(ot),
|
|
782
|
+
}(ot), I = function(i) {
|
|
788
783
|
$(e, i);
|
|
789
784
|
function e(t) {
|
|
790
785
|
var r = i.call(this) || this;
|
|
@@ -800,19 +795,19 @@ var xt = tt(function(i) {
|
|
|
800
795
|
var r = i.prototype._subscribe.call(this, t);
|
|
801
796
|
return !r.closed && t.next(this._value), r;
|
|
802
797
|
}, e.prototype.getValue = function() {
|
|
803
|
-
var t = this, r = t.hasError,
|
|
798
|
+
var t = this, r = t.hasError, s = t.thrownError, n = t._value;
|
|
804
799
|
if (r)
|
|
805
|
-
throw
|
|
806
|
-
return this._throwIfClosed(),
|
|
800
|
+
throw s;
|
|
801
|
+
return this._throwIfClosed(), n;
|
|
807
802
|
}, e.prototype.next = function(t) {
|
|
808
803
|
i.prototype.next.call(this, this._value = t);
|
|
809
804
|
}, e;
|
|
810
|
-
}(ot),
|
|
811
|
-
class Pt extends
|
|
805
|
+
}(ot), qt = /* @__PURE__ */ ((i) => (i[i.CRON = 0] = "CRON", i[i.EVENT = 1] = "EVENT", i[i.DELETE = 2] = "DELETE", i[i.GET = 3] = "GET", i[i.PATCH = 4] = "PATCH", i[i.POST = 5] = "POST", i[i.PUT = 6] = "PUT", i))(qt || {});
|
|
806
|
+
class Pt extends d {
|
|
812
807
|
constructor(t) {
|
|
813
808
|
super();
|
|
814
|
-
|
|
815
|
-
|
|
809
|
+
u(this, "api");
|
|
810
|
+
u(this, "$cache", new I([]));
|
|
816
811
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
817
812
|
}
|
|
818
813
|
get cache() {
|
|
@@ -830,37 +825,40 @@ class Pt extends p {
|
|
|
830
825
|
return this.api.request({ url: "/api/actions" }).then((t) => (this.cache = t, this.emit("LIST", t), t));
|
|
831
826
|
}
|
|
832
827
|
read(t, r = !1) {
|
|
833
|
-
const
|
|
834
|
-
return !r &&
|
|
828
|
+
const s = this.cache.find((n) => n._id == t);
|
|
829
|
+
return !r && s ? Promise.resolve(s) : this.api.request({ url: `/api/actions/${t}` }).then((n) => (n && (this.cache = this.cache.filter((o) => o._id != t).concat([n])), this.emit("READ", n), n));
|
|
835
830
|
}
|
|
836
831
|
run(t, r = {}) {
|
|
837
832
|
return this.api.request({ url: ("/api/actions/run/" + t).replaceAll("//", "/"), ...r });
|
|
838
833
|
}
|
|
839
834
|
runById(t, r = {}) {
|
|
840
|
-
const
|
|
841
|
-
return this.api.request({ url: "/api/actions/run-by-id/" +
|
|
835
|
+
const s = typeof t == "string" ? t : t._id;
|
|
836
|
+
return this.api.request({ url: "/api/actions/run-by-id/" + s, method: "POST", ...r });
|
|
842
837
|
}
|
|
843
838
|
update(t) {
|
|
844
839
|
return this.api.request({
|
|
845
840
|
url: `/api/actions${t._id ? `/${t._id}` : ""}`,
|
|
846
841
|
method: "POST",
|
|
847
842
|
body: t
|
|
848
|
-
}).then((r) => (r && (this.cache = this.cache.filter((
|
|
843
|
+
}).then((r) => (r && (this.cache = this.cache.filter((s) => s._id != r._id).concat([r])), this.emit("UPDATE", r), r));
|
|
849
844
|
}
|
|
850
845
|
}
|
|
851
|
-
class
|
|
846
|
+
class It extends d {
|
|
852
847
|
constructor(t, r) {
|
|
853
|
-
var
|
|
848
|
+
var s;
|
|
854
849
|
super();
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
if (this.opts = r, this.api = typeof t == "string" ? new f(t) : t, (
|
|
850
|
+
u(this, "api");
|
|
851
|
+
u(this, "storageKey");
|
|
852
|
+
u(this, "$user", new I(void 0));
|
|
853
|
+
if (this.opts = r, this.api = typeof t == "string" ? new f(t) : t, (s = this.opts) != null && s.loginUi || (this.opts = { ...this.opts, loginUi: this.api.url + "/ui/login" }), this.storageKey = `momentum:${new URL(this.api.url).host}`, this.api.addInterceptor((n, o) => {
|
|
854
|
+
n.status == 401 && !n.url.includes(`${this.api.url}/api/auth/login`) && this.emit("SESSION_EXPIRED"), o();
|
|
855
|
+
}), this.api.on("TOKEN", (n) => {
|
|
859
856
|
var o;
|
|
860
|
-
(o = this.opts) != null && o.persist && (
|
|
857
|
+
(o = this.opts) != null && o.persist && (n ? localStorage.setItem(this.storageKey, n) : localStorage.removeItem(this.storageKey)), n ? this.whoAmI(n, !0).catch(() => {
|
|
858
|
+
}) : this.user = null;
|
|
861
859
|
}), r != null && r.persist) {
|
|
862
|
-
const
|
|
863
|
-
|
|
860
|
+
const n = localStorage.getItem(this.storageKey);
|
|
861
|
+
n ? this.api.token = n : this.user = null;
|
|
864
862
|
} else
|
|
865
863
|
this.user = null;
|
|
866
864
|
}
|
|
@@ -881,22 +879,20 @@ class qt extends p {
|
|
|
881
879
|
url: "/api/auth/login",
|
|
882
880
|
headers: { Authorization: void 0 },
|
|
883
881
|
body: {
|
|
884
|
-
username: t,
|
|
885
|
-
password: r
|
|
882
|
+
username: t.trim(),
|
|
883
|
+
password: r.trim()
|
|
886
884
|
}
|
|
887
|
-
}).then(async (
|
|
885
|
+
}).then(async (s) => (this.api.token = s.token, await this.once("USER")));
|
|
888
886
|
}
|
|
889
887
|
loginRedirect(t = location.origin) {
|
|
890
|
-
return new Promise((r,
|
|
888
|
+
return new Promise((r, s) => {
|
|
891
889
|
var o;
|
|
892
|
-
const
|
|
893
|
-
if (!s)
|
|
894
|
-
|
|
895
|
-
s.addEventListener("message", (u) => {
|
|
890
|
+
const n = window.open(encodeURI(`${(o = this.opts) == null ? void 0 : o.loginUi}?redirect=postmessage&host=${t}`), "_blank");
|
|
891
|
+
if (!n) return s("Unable to open login");
|
|
892
|
+
n.addEventListener("message", (a) => {
|
|
896
893
|
var c;
|
|
897
|
-
if (!((c =
|
|
898
|
-
|
|
899
|
-
this.api.token = u.data.token, r(u.data.token), s.close();
|
|
894
|
+
if (!((c = a == null ? void 0 : a.data) != null && c.token)) return s("Unknown response from login");
|
|
895
|
+
this.api.token = a.data.token, r(a.data.token), n.close();
|
|
900
896
|
});
|
|
901
897
|
});
|
|
902
898
|
}
|
|
@@ -919,17 +915,17 @@ class qt extends p {
|
|
|
919
915
|
}
|
|
920
916
|
async whoAmI(t, r = !1) {
|
|
921
917
|
t || (t = this.api.token);
|
|
922
|
-
const
|
|
918
|
+
const s = await this.api.request({
|
|
923
919
|
url: "/api/auth/whoami",
|
|
924
920
|
headers: t ? { Authorization: `Bearer ${t}` } : void 0
|
|
925
921
|
});
|
|
926
|
-
return r && (this.api.token = t, this.user = (
|
|
922
|
+
return r && (this.api.token = t, this.user = (s == null ? void 0 : s.user) || null, s && this.emit("LOGIN", s.user)), s;
|
|
927
923
|
}
|
|
928
924
|
}
|
|
929
|
-
class
|
|
925
|
+
class Dt extends d {
|
|
930
926
|
constructor(t) {
|
|
931
927
|
super();
|
|
932
|
-
|
|
928
|
+
u(this, "api");
|
|
933
929
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
934
930
|
}
|
|
935
931
|
delete(t, r) {
|
|
@@ -939,41 +935,41 @@ class It extends p {
|
|
|
939
935
|
}).then(() => this.emit("DELETE", t, r));
|
|
940
936
|
}
|
|
941
937
|
get(t, r) {
|
|
942
|
-
return this.api.request({ url: `/api/data/${t}${r ? `/${r}` : ""}` }).then((
|
|
938
|
+
return this.api.request({ url: `/api/data/${t}${r ? `/${r}` : ""}` }).then((s) => (this.emit("GET", t, s), s));
|
|
943
939
|
}
|
|
944
|
-
raw(t, r,
|
|
940
|
+
raw(t, r, s, n) {
|
|
945
941
|
return this.api.request({
|
|
946
942
|
url: `/api/data/${t}`,
|
|
947
943
|
body: {
|
|
948
944
|
operand: r,
|
|
949
|
-
query:
|
|
950
|
-
options:
|
|
945
|
+
query: s,
|
|
946
|
+
options: n
|
|
951
947
|
}
|
|
952
948
|
}).then((o) => (this.emit("RAW", t, o), o));
|
|
953
949
|
}
|
|
954
|
-
set(t, r,
|
|
950
|
+
set(t, r, s = !1) {
|
|
955
951
|
return this.api.request({
|
|
956
952
|
url: `/api/data/${t}/${r._id || ""}`,
|
|
957
|
-
method:
|
|
953
|
+
method: s ? "PATCH" : "POST",
|
|
958
954
|
body: r
|
|
959
|
-
}).then((
|
|
955
|
+
}).then((n) => (this.emit("SET", t, r), n));
|
|
960
956
|
}
|
|
961
957
|
}
|
|
962
|
-
class Ut extends
|
|
958
|
+
class Ut extends d {
|
|
963
959
|
constructor(t) {
|
|
964
960
|
super();
|
|
965
|
-
|
|
961
|
+
u(this, "api");
|
|
966
962
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
967
963
|
}
|
|
968
964
|
send(t) {
|
|
969
965
|
let r = "/api/email";
|
|
970
|
-
return typeof t.body == "object" && (r += `/${t.body.template}`), this.api.request({ url: r, body: t }).then((
|
|
966
|
+
return typeof t.body == "object" && (r += `/${t.body.template}`), this.api.request({ url: r, body: t }).then((s) => (this.emit("SENT", t), s));
|
|
971
967
|
}
|
|
972
968
|
}
|
|
973
|
-
class Ct extends
|
|
969
|
+
class Ct extends d {
|
|
974
970
|
constructor(t) {
|
|
975
971
|
super();
|
|
976
|
-
|
|
972
|
+
u(this, "api");
|
|
977
973
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
978
974
|
}
|
|
979
975
|
create(t) {
|
|
@@ -1003,9 +999,9 @@ class Ct extends p {
|
|
|
1003
999
|
}).then(() => this.emit("DELETE", t));
|
|
1004
1000
|
}
|
|
1005
1001
|
}
|
|
1006
|
-
class
|
|
1002
|
+
class jt {
|
|
1007
1003
|
constructor(e, t) {
|
|
1008
|
-
|
|
1004
|
+
u(this, "api");
|
|
1009
1005
|
this.api = typeof e == "string" ? new f(e) : e, t != null && t != "NONE" && (window.addEventListener("error", (r) => this.error(r.error.stack)), window.addEventListener("unhandledrejection", async (r) => this.error(r.reason.stack)));
|
|
1010
1006
|
}
|
|
1011
1007
|
buildLog(e, t) {
|
|
@@ -1028,11 +1024,11 @@ class Bt {
|
|
|
1028
1024
|
return this.api.request({ url: "/api/logs/server", method: "DELETE" });
|
|
1029
1025
|
}
|
|
1030
1026
|
clientLogs(e, t) {
|
|
1031
|
-
const r = [e ? `length=${e}` : void 0, t ? `page=${t}` : void 0].filter((
|
|
1027
|
+
const r = [e ? `length=${e}` : void 0, t ? `page=${t}` : void 0].filter((s) => !!s).join("&");
|
|
1032
1028
|
return this.api.request({ url: `/api/logs/client${r ? `?${r}` : ""}` });
|
|
1033
1029
|
}
|
|
1034
1030
|
serverLogs(e, t) {
|
|
1035
|
-
const r = [e ? `length=${e}` : void 0, t ? `page=${t}` : void 0].filter((
|
|
1031
|
+
const r = [e ? `length=${e}` : void 0, t ? `page=${t}` : void 0].filter((s) => !!s).join("&");
|
|
1036
1032
|
return this.api.request({ url: `/api/logs/server${r ? `?${r}` : ""}` });
|
|
1037
1033
|
}
|
|
1038
1034
|
debug(...e) {
|
|
@@ -1056,36 +1052,37 @@ class Bt {
|
|
|
1056
1052
|
});
|
|
1057
1053
|
}
|
|
1058
1054
|
}
|
|
1059
|
-
class
|
|
1055
|
+
class kt extends d {
|
|
1060
1056
|
constructor(t) {
|
|
1061
1057
|
super();
|
|
1062
|
-
|
|
1058
|
+
u(this, "api");
|
|
1063
1059
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
1064
1060
|
}
|
|
1065
1061
|
async handleResponse(t, r) {
|
|
1066
|
-
const
|
|
1062
|
+
const s = await t.blob();
|
|
1067
1063
|
if (r) {
|
|
1068
|
-
const
|
|
1069
|
-
Z(
|
|
1064
|
+
const n = URL.createObjectURL(s);
|
|
1065
|
+
Z(n, r.endsWith(".pdf") ? r : r + ".pdf"), URL.revokeObjectURL(n);
|
|
1070
1066
|
}
|
|
1071
|
-
return this.emit("CREATE",
|
|
1067
|
+
return this.emit("CREATE", s), s;
|
|
1072
1068
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1069
|
+
generate(t, r = {}) {
|
|
1070
|
+
const s = t == null ? void 0 : t.template;
|
|
1071
|
+
return this.api.request({
|
|
1072
|
+
url: `/api/pdf${s ? `/${s}` : ""}`,
|
|
1073
|
+
body: s ? t == null ? void 0 : t.data : { html: t }
|
|
1074
|
+
}).then((n) => this.handleResponse(n, r.download ? r.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1075
1075
|
}
|
|
1076
1076
|
fromUrl(t, r = {}) {
|
|
1077
|
-
return this.api.request({ url: `/api/pdf?url=${t}` }).then((
|
|
1078
|
-
}
|
|
1079
|
-
fromTemplate(t, r, n = {}) {
|
|
1080
|
-
return this.api.request({ url: `/api/pdf/${t}`, body: { data: r } }).then((s) => this.handleResponse(s, n.download ? n.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1077
|
+
return this.api.request({ url: `/api/pdf?url=${t}` }).then((s) => this.handleResponse(s, r.download ? r.fileName || (/* @__PURE__ */ new Date()).toISOString() : void 0));
|
|
1081
1078
|
}
|
|
1082
1079
|
}
|
|
1083
|
-
const
|
|
1080
|
+
const q = class q {
|
|
1084
1081
|
constructor(e) {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1082
|
+
u(this, "api");
|
|
1083
|
+
u(this, "url");
|
|
1084
|
+
u(this, "connection");
|
|
1085
|
+
u(this, "open", !1);
|
|
1089
1086
|
this.api = typeof e == "string" ? new f(e) : e, this.url = this.api.url.replace("http", "ws"), this.api.on("TOKEN", () => this.connect()), this.api.token || this.connect();
|
|
1090
1087
|
}
|
|
1091
1088
|
close() {
|
|
@@ -1096,7 +1093,7 @@ const D = class D {
|
|
|
1096
1093
|
((r = this.connection) == null ? void 0 : r.readyState) < 2 && this.connection.close(), this.connection = new WebSocket(this.url + (this.api.token ? `?token=${this.api.token}` : ""));
|
|
1097
1094
|
const t = setTimeout(() => {
|
|
1098
1095
|
this.open || (this.connection.close(), console.error("Momentum connection timeout"), e > 0 && this.connect(e - 1));
|
|
1099
|
-
},
|
|
1096
|
+
}, q.timeout);
|
|
1100
1097
|
this.connection.onclose = () => this.open = !1, this.connection.onmessage = this.handle, this.connection.onopen = () => {
|
|
1101
1098
|
this.open = !0, clearTimeout(t), console.debug("Connected to Momentum");
|
|
1102
1099
|
};
|
|
@@ -1112,12 +1109,12 @@ const D = class D {
|
|
|
1112
1109
|
}));
|
|
1113
1110
|
}
|
|
1114
1111
|
};
|
|
1115
|
-
|
|
1116
|
-
let F =
|
|
1117
|
-
class
|
|
1112
|
+
u(q, "timeout", 1e4);
|
|
1113
|
+
let F = q;
|
|
1114
|
+
class Bt extends d {
|
|
1118
1115
|
constructor(t) {
|
|
1119
1116
|
super();
|
|
1120
|
-
|
|
1117
|
+
u(this, "api");
|
|
1121
1118
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
1122
1119
|
}
|
|
1123
1120
|
delete(t) {
|
|
@@ -1128,57 +1125,55 @@ class kt extends p {
|
|
|
1128
1125
|
}
|
|
1129
1126
|
list(t) {
|
|
1130
1127
|
const r = (t.startsWith("/api/storage/") ? t : "/api/storage/" + t).replaceAll("//", "/");
|
|
1131
|
-
return this.api.request({ url: r + "?list" }).then((
|
|
1128
|
+
return this.api.request({ url: r + "?list" }).then((s) => (this.emit("LIST", t, s), s));
|
|
1132
1129
|
}
|
|
1133
1130
|
open(t, r = "_blank") {
|
|
1134
|
-
const
|
|
1135
|
-
return r ? (this.emit("OPEN", t), window.open(
|
|
1131
|
+
const s = (t.startsWith("/api/storage/") ? t : "/api/storage/" + t).replaceAll(/\/{2,}/g, "/"), n = `${this.api.url}${s}${this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
1132
|
+
return r ? (this.emit("OPEN", t), window.open(n, r)) : n;
|
|
1136
1133
|
}
|
|
1137
1134
|
mkdir(t) {
|
|
1138
1135
|
const r = (t.startsWith("/api/storage/") ? t : "/api/storage/" + t).replaceAll(/\/{2,}/g, "/");
|
|
1139
1136
|
return this.api.request({ url: r + "?directory", method: "POST" });
|
|
1140
1137
|
}
|
|
1141
1138
|
download(t, r = {}) {
|
|
1142
|
-
return new
|
|
1143
|
-
const
|
|
1144
|
-
this.api.request({ ...r, url:
|
|
1145
|
-
var
|
|
1146
|
-
if (!c.ok)
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
const E = (d = c.body) == null ? void 0 : d.getReader(), _ = (M) => {
|
|
1139
|
+
return new gt((s, n, o) => {
|
|
1140
|
+
const a = ("/api/storage/" + t).replaceAll("//", "/");
|
|
1141
|
+
this.api.request({ ...r, url: a, skipConverting: !0 }).then((c) => {
|
|
1142
|
+
var p;
|
|
1143
|
+
if (!c.ok) return n(c.statusText);
|
|
1144
|
+
const l = c.headers.get("Content-Length"), E = l ? parseInt(l, 10) : 0;
|
|
1145
|
+
let T = [], b = 0;
|
|
1146
|
+
const y = (p = c.body) == null ? void 0 : p.getReader(), _ = (M) => {
|
|
1151
1147
|
if (M.done) {
|
|
1152
1148
|
o(1);
|
|
1153
|
-
const w = new Blob(T),
|
|
1154
|
-
Z(Y,
|
|
1149
|
+
const w = new Blob(T), D = r.downloadAs || new URL(c.url).pathname.split("/").pop(), Y = URL.createObjectURL(w);
|
|
1150
|
+
Z(Y, D.includes(".") ? D : D + ".zip"), URL.revokeObjectURL(Y), this.emit("DOWNLOAD", t, w), s(w);
|
|
1155
1151
|
} else {
|
|
1156
1152
|
const w = M.value;
|
|
1157
|
-
T.push(w),
|
|
1153
|
+
T.push(w), b += w.length, o(b / E), y.read().then(_);
|
|
1158
1154
|
}
|
|
1159
1155
|
};
|
|
1160
|
-
|
|
1156
|
+
y == null || y.read().then(_);
|
|
1161
1157
|
});
|
|
1162
1158
|
});
|
|
1163
1159
|
}
|
|
1164
1160
|
async upload(t, r = "") {
|
|
1165
|
-
if (t || (t = await new Promise((
|
|
1161
|
+
if (t || (t = await new Promise((a) => {
|
|
1166
1162
|
const c = document.createElement("input");
|
|
1167
1163
|
c.type = "file", c.accept = (r == null ? void 0 : r.accept) || "*", c.style.display = "none", c.multiple = !!(r != null && r.multiple), c.onblur = c.onchange = async () => {
|
|
1168
|
-
|
|
1164
|
+
a(Array.from(c.files)), c.remove();
|
|
1169
1165
|
}, document.body.appendChild(c), c.click();
|
|
1170
|
-
})), !t || Array.isArray(t) && !t.length)
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
return (Array.isArray(t) ? t : [t]).forEach((u) => s.append("file", u)), this.api.request({ url: o, body: s }).then((u) => (this.emit("UPLOAD", u), u));
|
|
1166
|
+
})), !t || Array.isArray(t) && !t.length) return [];
|
|
1167
|
+
const n = new FormData(), o = ("/api/storage/" + (typeof r == "string" ? r : r == null ? void 0 : r.path)).replaceAll("//", "/");
|
|
1168
|
+
return (Array.isArray(t) ? t : [t]).forEach((a) => n.append("file", a)), this.api.request({ url: o, body: n }).then((a) => (this.emit("UPLOAD", a), a));
|
|
1174
1169
|
}
|
|
1175
1170
|
}
|
|
1176
|
-
class Gt extends
|
|
1171
|
+
class Gt extends d {
|
|
1177
1172
|
constructor(t) {
|
|
1178
1173
|
super();
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1174
|
+
u(this, "api");
|
|
1175
|
+
u(this, "listed", !1);
|
|
1176
|
+
u(this, "$cache", new I([]));
|
|
1182
1177
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
1183
1178
|
}
|
|
1184
1179
|
get cache() {
|
|
@@ -1200,25 +1195,24 @@ class Gt extends p {
|
|
|
1200
1195
|
}
|
|
1201
1196
|
read(t, r = !1) {
|
|
1202
1197
|
if (!r) {
|
|
1203
|
-
const
|
|
1204
|
-
if (
|
|
1205
|
-
return Promise.resolve(n);
|
|
1198
|
+
const s = this.cache.find((n) => n.username == t);
|
|
1199
|
+
if (s) return Promise.resolve(s);
|
|
1206
1200
|
}
|
|
1207
|
-
return this.api.request({ url: `/api/users/${t}` }).then((
|
|
1201
|
+
return this.api.request({ url: `/api/users/${t}` }).then((s) => (s && (this.cache = { ...this.cache, [s.username]: s }), this.emit("READ", s), s));
|
|
1208
1202
|
}
|
|
1209
1203
|
update(t) {
|
|
1210
1204
|
return this.api.request({
|
|
1211
1205
|
url: `/api/users/${t.username}`,
|
|
1212
1206
|
method: "PATCH",
|
|
1213
1207
|
body: t
|
|
1214
|
-
}).then((r) => (r && (this.cache = this.cache.filter((
|
|
1208
|
+
}).then((r) => (r && (this.cache = this.cache.filter((s) => s.username != t.username).concat([r])), this.emit("UPDATE", r), r));
|
|
1215
1209
|
}
|
|
1216
1210
|
}
|
|
1217
|
-
class Nt extends
|
|
1211
|
+
class Nt extends d {
|
|
1218
1212
|
constructor(t) {
|
|
1219
1213
|
super();
|
|
1220
|
-
|
|
1221
|
-
|
|
1214
|
+
u(this, "api");
|
|
1215
|
+
u(this, "$cache", new I({}));
|
|
1222
1216
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
1223
1217
|
}
|
|
1224
1218
|
get cache() {
|
|
@@ -1228,7 +1222,7 @@ class Nt extends p {
|
|
|
1228
1222
|
this.$cache.next(t);
|
|
1229
1223
|
}
|
|
1230
1224
|
list(t = !1) {
|
|
1231
|
-
return this.api.request({ url: "/api/settings" + (t ? "?detailed" : "") }).then((r) => (this.cache = t ? Object.values(r).reduce((
|
|
1225
|
+
return this.api.request({ url: "/api/settings" + (t ? "?detailed" : "") }).then((r) => (this.cache = t ? Object.values(r).reduce((s, n) => ({ ...s, [n.key]: n.value }), {}) : r, this.emit("LIST", r), r));
|
|
1232
1226
|
}
|
|
1233
1227
|
delete(t) {
|
|
1234
1228
|
return this.api.request({ url: `/api/settings/${t}`, method: "DELETE" }).then(() => {
|
|
@@ -1236,16 +1230,16 @@ class Nt extends p {
|
|
|
1236
1230
|
});
|
|
1237
1231
|
}
|
|
1238
1232
|
read(t, r = !1) {
|
|
1239
|
-
return !r && this.cache[t] ? Promise.resolve(this.cache[t]) : this.api.request({ url: `/api/settings/${t}` }).then((
|
|
1233
|
+
return !r && this.cache[t] ? Promise.resolve(this.cache[t]) : this.api.request({ url: `/api/settings/${t}` }).then((s) => (s && (this.cache = { ...this.cache, [s.key]: s }), this.emit("READ", s), s));
|
|
1240
1234
|
}
|
|
1241
1235
|
update(t) {
|
|
1242
1236
|
return this.api.request({ url: `/api/settings/${t.key}`, body: t }).then((r) => (r && (this.cache = { ...this.cache, [r.key]: r.value }), this.emit("UPDATE", r), r));
|
|
1243
1237
|
}
|
|
1244
1238
|
}
|
|
1245
|
-
class Ht extends
|
|
1239
|
+
class Ht extends d {
|
|
1246
1240
|
constructor(t) {
|
|
1247
1241
|
super();
|
|
1248
|
-
|
|
1242
|
+
u(this, "api");
|
|
1249
1243
|
this.api = typeof t == "string" ? new f(t) : t;
|
|
1250
1244
|
}
|
|
1251
1245
|
delete(t) {
|
|
@@ -1255,60 +1249,59 @@ class Ht extends p {
|
|
|
1255
1249
|
}
|
|
1256
1250
|
list(t) {
|
|
1257
1251
|
const r = ("/api/static/" + t).replaceAll("//", "/");
|
|
1258
|
-
return this.api.request({ url: r }).then((
|
|
1252
|
+
return this.api.request({ url: r }).then((s) => (this.emit("LIST", t, s), s));
|
|
1259
1253
|
}
|
|
1260
1254
|
upload(t, r = "/") {
|
|
1261
|
-
const
|
|
1262
|
-
return (Array.isArray(t) ? t : [t]).forEach((
|
|
1255
|
+
const s = new FormData();
|
|
1256
|
+
return (Array.isArray(t) ? t : [t]).forEach((n) => s.append("file", n)), this.api.request({ url: "/api/static" + r, body: s }).then((n) => (this.emit("UPLOAD", n), n));
|
|
1263
1257
|
}
|
|
1264
1258
|
}
|
|
1265
|
-
class Ft extends
|
|
1259
|
+
class Ft extends d {
|
|
1266
1260
|
constructor(t, r) {
|
|
1267
1261
|
super();
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
this.api = new f(t, r == null ? void 0 : r.api), this.actions = new Pt(this.api), this.auth = new
|
|
1262
|
+
u(this, "api");
|
|
1263
|
+
u(this, "actions");
|
|
1264
|
+
u(this, "auth");
|
|
1265
|
+
u(this, "data");
|
|
1266
|
+
u(this, "email");
|
|
1267
|
+
u(this, "groups");
|
|
1268
|
+
u(this, "logger");
|
|
1269
|
+
u(this, "pdf");
|
|
1270
|
+
u(this, "settings");
|
|
1271
|
+
u(this, "socket");
|
|
1272
|
+
u(this, "static");
|
|
1273
|
+
u(this, "storage");
|
|
1274
|
+
u(this, "users");
|
|
1275
|
+
this.api = new f(t, r == null ? void 0 : r.api), this.actions = new Pt(this.api), this.auth = new It(this.api, {
|
|
1282
1276
|
persist: (r == null ? void 0 : r.persist) ?? !0,
|
|
1283
1277
|
loginUi: r == null ? void 0 : r.loginUi
|
|
1284
|
-
}), this.data = new
|
|
1278
|
+
}), this.data = new Dt(this.api), this.email = new Ut(this.api), this.groups = new Ct(this.api), this.logger = new jt(this.api, r == null ? void 0 : r.logLevel), this.pdf = new kt(this.api), this.settings = new Nt(this.api), this.static = new Ht(this.api), this.storage = new Bt(this.api), this.users = new Gt(this.api), r != null && r.socket && (this.socket = new F(this.api)), this.api.on("*", (s, ...n) => this.emit(`API::${s}`, ...n)), this.actions.on("*", (s, ...n) => this.emit(`ACTIONS::${s}`, ...n)), this.auth.on("*", (s, ...n) => this.emit(`AUTH::${s}`, ...n)), this.data.on("*", (s, ...n) => this.emit(`DATA::${s}`, ...n)), this.email.on("*", (s, ...n) => this.emit(`EMAIL::${s}`, ...n)), this.groups.on("*", (s, ...n) => this.emit(`GROUPS::${s}`, ...n)), this.pdf.on("*", (s, ...n) => this.emit(`PDF::${s}`, ...n)), this.settings.on("*", (s, ...n) => this.emit(`SETTINGS::${s}`, ...n)), this.static.on("*", (s, ...n) => this.emit(`STATIC::${s}`, ...n)), this.storage.on("*", (s, ...n) => this.emit(`STORAGE::${s}`, ...n)), this.users.on("*", (s, ...n) => this.emit(`USERS::${s}`, ...n)), this.users.on("*", (s, ...n) => {
|
|
1285
1279
|
var o;
|
|
1286
|
-
if (Array.isArray(
|
|
1287
|
-
const
|
|
1280
|
+
if (Array.isArray(n[0])) {
|
|
1281
|
+
const a = n[0].find((c) => {
|
|
1288
1282
|
var l;
|
|
1289
1283
|
return c._id == ((l = this.auth.user) == null ? void 0 : l._id);
|
|
1290
1284
|
});
|
|
1291
|
-
|
|
1292
|
-
} else
|
|
1293
|
-
s[0]._id == ((o = this.auth.user) == null ? void 0 : o._id) && (this.auth.user = s[0]);
|
|
1285
|
+
a && (this.auth.user = a);
|
|
1286
|
+
} else n[0]._id == ((o = this.auth.user) == null ? void 0 : o._id) && (this.auth.user = n[0]);
|
|
1294
1287
|
});
|
|
1295
1288
|
}
|
|
1296
1289
|
}
|
|
1297
1290
|
export {
|
|
1298
|
-
|
|
1291
|
+
qt as ActionType,
|
|
1299
1292
|
Pt as Actions,
|
|
1300
1293
|
f as Api,
|
|
1301
|
-
|
|
1302
|
-
|
|
1294
|
+
It as Auth,
|
|
1295
|
+
Dt as Data,
|
|
1303
1296
|
Ut as Email,
|
|
1304
1297
|
Ct as Groups,
|
|
1305
|
-
|
|
1298
|
+
jt as Logger,
|
|
1306
1299
|
Ft as Momentum,
|
|
1307
|
-
|
|
1300
|
+
kt as Pdf,
|
|
1308
1301
|
Nt as Settings,
|
|
1309
1302
|
F as Socket,
|
|
1310
1303
|
Ht as Static,
|
|
1311
|
-
|
|
1304
|
+
Bt as Storage,
|
|
1312
1305
|
Gt as Users
|
|
1313
1306
|
};
|
|
1314
1307
|
//# sourceMappingURL=momentum.mjs.map
|