@ztimson/momentum 0.33.0 → 0.35.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/dist/api.d.ts CHANGED
@@ -6,17 +6,17 @@ export type ApiEvents = TypedEvents & {
6
6
  TOKEN: (token: string | null) => any;
7
7
  };
8
8
  export type Health = {
9
- status: 'ok' | 'degraded' | 'failing';
10
- database: boolean;
11
- email: boolean;
12
- openAi: boolean;
13
- payments: boolean;
14
- phone: boolean;
15
- server: boolean;
16
- sockets: boolean;
9
+ status: 'offline' | 'ok' | 'degraded' | 'error';
10
+ actions: HealthStatus;
11
+ ai: HealthStatus;
12
+ database: HealthStatus;
13
+ email: HealthStatus;
14
+ payments: HealthStatus;
15
+ phone: HealthStatus;
17
16
  version: string;
18
17
  commit: string;
19
18
  };
19
+ export type HealthStatus = 'disabled' | 'ok' | 'warn' | 'error';
20
20
  export declare class Api extends Http {
21
21
  readonly url: string;
22
22
  readonly opts: HttpDefaults;
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,IAAI,EAAE,YAAY,EAClB,kBAAkB,EAClB,eAAe,EAEf,KAAK,WAAW,EAChB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG;IACrC,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,kBAAkB,KAAK,GAAG,CAAC;IACrE,QAAQ,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,kBAAkB,KAAK,GAAG,CAAC;IAC9D,QAAQ,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,KAAK,GAAG,CAAC;IAChE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,GAAG,CAAA;CACp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
15
  (t && r === void 0 || !t && r == null) && delete n[e];
16
16
  }), n;
17
17
  }
18
- function B(n, t) {
18
+ function b(n, t) {
19
19
  const e = typeof n, r = typeof t;
20
- return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? false : Object.keys(n).every((s) => B(n[s], t[s]));
20
+ return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? false : Object.keys(n).every((s) => b(n[s], t[s]));
21
21
  }
22
- function q(n) {
22
+ function U(n) {
23
23
  try {
24
24
  return JSON.parse(n);
25
25
  } catch {
@@ -63,13 +63,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
63
63
  return this.from(super.finally(e));
64
64
  }
65
65
  }
66
- function ut(n, t) {
66
+ function at(n, t) {
67
67
  const e = document.createElement("a");
68
68
  e.href = n, e.download = t, document.body.appendChild(e), e.click(), document.body.removeChild(e);
69
69
  }
70
70
  function Tt(n, t) {
71
71
  const e = URL.createObjectURL(n);
72
- ut(e, t), URL.revokeObjectURL(e);
72
+ at(e, t), URL.revokeObjectURL(e);
73
73
  }
74
74
  function It(n = {}) {
75
75
  return new Promise((t) => {
@@ -82,10 +82,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
82
82
  function $t(n) {
83
83
  return new m((t, e, r) => {
84
84
  const o = new XMLHttpRequest(), s = new FormData();
85
- n.files.forEach((c) => s.append("file", c)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (c) => c.lengthComputable ? r(c.loaded / c.total) : null), o.addEventListener("loadend", () => t(q(o.responseText))), o.addEventListener("error", () => e(q(o.responseText))), o.addEventListener("timeout", () => e({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([c, y]) => o.setRequestHeader(c, y)), o.send(s);
85
+ n.files.forEach((c) => s.append("file", c)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (c) => c.lengthComputable ? r(c.loaded / c.total) : null), o.addEventListener("loadend", () => t(U(o.responseText))), o.addEventListener("error", () => e(U(o.responseText))), o.addEventListener("timeout", () => e({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([c, y]) => o.setRequestHeader(c, y)), o.send(s);
86
86
  });
87
87
  }
88
- class v {
88
+ class F {
89
89
  constructor() {
90
90
  i(this, "listeners", {});
91
91
  }
@@ -126,7 +126,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
126
126
  });
127
127
  }
128
128
  }
129
- i(v, "listeners", {});
129
+ i(F, "listeners", {});
130
130
  class p extends Error {
131
131
  constructor(e, r) {
132
132
  super(e);
@@ -155,7 +155,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
155
155
  }
156
156
  }
157
157
  i(p, "code", 500);
158
- class F extends p {
158
+ class v extends p {
159
159
  constructor(t = "Bad Request") {
160
160
  super(t);
161
161
  }
@@ -163,8 +163,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
163
163
  return t.constructor.code == this.code;
164
164
  }
165
165
  }
166
- i(F, "code", 400);
167
- class H extends p {
166
+ i(v, "code", 400);
167
+ class Y extends p {
168
168
  constructor(t = "Unauthorized") {
169
169
  super(t);
170
170
  }
@@ -172,8 +172,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
172
172
  return t.constructor.code == this.code;
173
173
  }
174
174
  }
175
- i(H, "code", 401);
176
- class Y extends p {
175
+ i(Y, "code", 401);
176
+ class H extends p {
177
177
  constructor(t = "Payment Required") {
178
178
  super(t);
179
179
  }
@@ -181,7 +181,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
181
181
  return t.constructor.code == this.code;
182
182
  }
183
183
  }
184
- i(Y, "code", 402);
184
+ i(H, "code", 402);
185
185
  class W extends p {
186
186
  constructor(t = "Forbidden") {
187
187
  super(t);
@@ -191,7 +191,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
191
191
  }
192
192
  }
193
193
  i(W, "code", 403);
194
- class J extends p {
194
+ class z extends p {
195
195
  constructor(t = "Not Found") {
196
196
  super(t);
197
197
  }
@@ -199,8 +199,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
199
199
  return t.constructor.code == this.code;
200
200
  }
201
201
  }
202
- i(J, "code", 404);
203
- class z extends p {
202
+ i(z, "code", 404);
203
+ class J extends p {
204
204
  constructor(t = "Method Not Allowed") {
205
205
  super(t);
206
206
  }
@@ -208,7 +208,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
208
208
  return t.constructor.code == this.code;
209
209
  }
210
210
  }
211
- i(z, "code", 405);
211
+ i(J, "code", 405);
212
212
  class K extends p {
213
213
  constructor(t = "Not Acceptable") {
214
214
  super(t);
@@ -218,7 +218,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
218
218
  }
219
219
  }
220
220
  i(K, "code", 406);
221
- class V extends p {
221
+ class Z extends p {
222
222
  constructor(t = "Internal Server Error") {
223
223
  super(t);
224
224
  }
@@ -226,8 +226,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
226
226
  return t.constructor.code == this.code;
227
227
  }
228
228
  }
229
- i(V, "code", 500);
230
- class Z extends p {
229
+ i(Z, "code", 500);
230
+ class V extends p {
231
231
  constructor(t = "Not Implemented") {
232
232
  super(t);
233
233
  }
@@ -235,7 +235,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
235
235
  return t.constructor.code == this.code;
236
236
  }
237
237
  }
238
- i(Z, "code", 501);
238
+ i(V, "code", 501);
239
239
  class X extends p {
240
240
  constructor(t = "Bad Gateway") {
241
241
  super(t);
@@ -302,36 +302,36 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
302
302
  headers: r,
303
303
  method: t.method || (t.body ? "POST" : "GET"),
304
304
  body: t.body
305
- }).then(async (u) => {
306
- var j, G;
307
- for (let a of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
308
- await new Promise((O) => a(u, () => O()));
309
- const R = u.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
305
+ }).then(async (a) => {
306
+ var M, j;
307
+ for (let u of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
308
+ await new Promise((O) => u(a, () => O()));
309
+ const R = a.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
310
310
  let k = 0;
311
- const T = (j = u.body) == null ? void 0 : j.getReader(), tt = new ReadableStream({
312
- start(a) {
311
+ const T = (M = a.body) == null ? void 0 : M.getReader(), tt = new ReadableStream({
312
+ start(u) {
313
313
  function O() {
314
314
  T == null || T.read().then((x) => {
315
315
  if (x.done)
316
- return a.close();
317
- k += x.value.byteLength, y(k / N), a.enqueue(x.value), O();
318
- }).catch((x) => a.error(x));
316
+ return u.close();
317
+ k += x.value.byteLength, y(k / N), u.enqueue(x.value), O();
318
+ }).catch((x) => u.error(x));
319
319
  }
320
320
  O();
321
321
  }
322
322
  });
323
- if (u.data = new Response(tt), t.decode == null || t.decode) {
324
- const a = (G = u.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
325
- a != null && a.includes("form") ? u.data = await u.data.formData() : a != null && a.includes("json") ? u.data = await u.data.json() : a != null && a.includes("text") ? u.data = await u.data.text() : a != null && a.includes("application") && (u.data = await u.data.blob());
323
+ if (a.data = new Response(tt), t.decode == null || t.decode) {
324
+ const u = (j = a.headers.get("Content-Type")) == null ? void 0 : j.toLowerCase();
325
+ u != null && u.includes("form") ? a.data = await a.data.formData() : u != null && u.includes("json") ? a.data = await a.data.json() : u != null && u.includes("text") ? a.data = await a.data.text() : u != null && u.includes("application") && (a.data = await a.data.blob());
326
326
  }
327
- u.ok ? s(u) : c(u);
327
+ a.ok ? s(a) : c(a);
328
328
  });
329
329
  });
330
330
  }
331
331
  };
332
332
  i(w, "interceptors", {}), i(w, "headers", {});
333
- let M = w;
334
- const A = {
333
+ let q = w;
334
+ const B = {
335
335
  CLEAR: "\x1B[0m",
336
336
  BRIGHT: "\x1B[1m",
337
337
  DIM: "\x1B[2m",
@@ -357,8 +357,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
357
357
  LIGHT_CYAN: "\x1B[96m",
358
358
  WHITE: "\x1B[97m"
359
359
  };
360
- var at = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(at || {});
361
- const g = class g2 extends v {
360
+ var ut = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(ut || {});
361
+ const g = class g2 extends F {
362
362
  constructor(t) {
363
363
  super(), this.namespace = t;
364
364
  }
@@ -377,39 +377,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
377
377
  if (g2.LOG_LEVEL < 4)
378
378
  return;
379
379
  const e = this.format(...t);
380
- g2.emit(4, e), console.debug(L.LIGHT_GREY + e + A.CLEAR);
380
+ g2.emit(4, e), console.debug(L.LIGHT_GREY + e + B.CLEAR);
381
381
  }
382
382
  log(...t) {
383
383
  if (g2.LOG_LEVEL < 3)
384
384
  return;
385
385
  const e = this.format(...t);
386
- g2.emit(3, e), console.log(A.CLEAR + e);
386
+ g2.emit(3, e), console.log(B.CLEAR + e);
387
387
  }
388
388
  info(...t) {
389
389
  if (g2.LOG_LEVEL < 2)
390
390
  return;
391
391
  const e = this.format(...t);
392
- g2.emit(2, e), console.info(L.BLUE + e + A.CLEAR);
392
+ g2.emit(2, e), console.info(L.BLUE + e + B.CLEAR);
393
393
  }
394
394
  warn(...t) {
395
395
  if (g2.LOG_LEVEL < 1)
396
396
  return;
397
397
  const e = this.format(...t);
398
- g2.emit(1, e), console.warn(L.YELLOW + e + A.CLEAR);
398
+ g2.emit(1, e), console.warn(L.YELLOW + e + B.CLEAR);
399
399
  }
400
400
  error(...t) {
401
401
  if (g2.LOG_LEVEL < 0)
402
402
  return;
403
403
  const e = this.format(...t);
404
- g2.emit(0, e), console.error(L.RED + e + A.CLEAR);
404
+ g2.emit(0, e), console.error(L.RED + e + B.CLEAR);
405
405
  }
406
406
  };
407
407
  i(g, "LOG_LEVEL", 4);
408
- class Api extends M {
408
+ class Api extends q {
409
409
  constructor(url = location.origin, opts = {}) {
410
410
  opts.url = url;
411
411
  super(opts);
412
- __publicField(this, "emitter", new v());
412
+ __publicField(this, "emitter", new F());
413
413
  __publicField(this, "_token", null);
414
414
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
415
415
  __publicField(this, "off", this.emitter.off.bind(this.emitter));
@@ -443,22 +443,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
443
443
  return req;
444
444
  }
445
445
  }
446
- var extendStatics = function(d, b) {
447
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
448
- d2.__proto__ = b2;
449
- } || function(d2, b2) {
450
- for (var p2 in b2) if (Object.prototype.hasOwnProperty.call(b2, p2)) d2[p2] = b2[p2];
446
+ var extendStatics = function(d, b2) {
447
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b3) {
448
+ d2.__proto__ = b3;
449
+ } || function(d2, b3) {
450
+ for (var p2 in b3) if (Object.prototype.hasOwnProperty.call(b3, p2)) d2[p2] = b3[p2];
451
451
  };
452
- return extendStatics(d, b);
452
+ return extendStatics(d, b2);
453
453
  };
454
- function __extends(d, b) {
455
- if (typeof b !== "function" && b !== null)
456
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
457
- extendStatics(d, b);
454
+ function __extends(d, b2) {
455
+ if (typeof b2 !== "function" && b2 !== null)
456
+ throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
457
+ extendStatics(d, b2);
458
458
  function __() {
459
459
  this.constructor = d;
460
460
  }
461
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
461
+ d.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
462
462
  }
463
463
  function __values(o) {
464
464
  var s = typeof Symbol === "function" && Symbol.iterator, m2 = s && o[s], i2 = 0;
@@ -1159,7 +1159,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1159
1159
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
1160
1160
  return ActionType2;
1161
1161
  })(ActionType || {});
1162
- class Actions extends v {
1162
+ class Actions extends F {
1163
1163
  constructor(api) {
1164
1164
  super();
1165
1165
  __publicField(this, "api");
@@ -1213,7 +1213,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1213
1213
  });
1214
1214
  }
1215
1215
  }
1216
- class Ai extends v {
1216
+ class Ai extends F {
1217
1217
  constructor(api) {
1218
1218
  super();
1219
1219
  __publicField(this, "api");
@@ -1229,7 +1229,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1229
1229
  });
1230
1230
  }
1231
1231
  }
1232
- class Analytics extends v {
1232
+ class Analytics extends F {
1233
1233
  constructor(api) {
1234
1234
  super();
1235
1235
  __publicField(this, "api");
@@ -1260,7 +1260,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1260
1260
  }) });
1261
1261
  }
1262
1262
  }
1263
- class Auth extends v {
1263
+ class Auth extends F {
1264
1264
  constructor(api, opts) {
1265
1265
  var _a;
1266
1266
  super();
@@ -1305,7 +1305,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1305
1305
  return this.$user.value;
1306
1306
  }
1307
1307
  set user(user) {
1308
- if (!B(this.user, user)) {
1308
+ if (!b(this.user, user)) {
1309
1309
  const u = user ? user : null;
1310
1310
  this.$user.next(u);
1311
1311
  this.emit("USER", u);
@@ -1391,7 +1391,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1391
1391
  });
1392
1392
  }
1393
1393
  }
1394
- class Data extends v {
1394
+ class Data extends F {
1395
1395
  constructor(api) {
1396
1396
  super();
1397
1397
  __publicField(this, "api");
@@ -1436,7 +1436,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1436
1436
  });
1437
1437
  }
1438
1438
  }
1439
- class Email extends v {
1439
+ class Email extends F {
1440
1440
  constructor(api) {
1441
1441
  super();
1442
1442
  __publicField(this, "api");
@@ -1451,7 +1451,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1451
1451
  });
1452
1452
  }
1453
1453
  }
1454
- class Groups extends v {
1454
+ class Groups extends F {
1455
1455
  constructor(api) {
1456
1456
  super();
1457
1457
  __publicField(this, "api");
@@ -1533,32 +1533,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1533
1533
  return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
1534
1534
  }
1535
1535
  debug(...logs) {
1536
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.DEBUG, logs) }).then(() => {
1536
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.DEBUG, logs) }).then(() => {
1537
1537
  }).catch(() => {
1538
1538
  });
1539
1539
  }
1540
1540
  log(...logs) {
1541
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.LOG, logs) }).then(() => {
1541
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.LOG, logs) }).then(() => {
1542
1542
  }).catch(() => {
1543
1543
  });
1544
1544
  }
1545
1545
  info(...logs) {
1546
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.INFO, logs) }).then(() => {
1546
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.INFO, logs) }).then(() => {
1547
1547
  }).catch(() => {
1548
1548
  });
1549
1549
  }
1550
1550
  warn(...logs) {
1551
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.WARN, logs) }).then(() => {
1551
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.WARN, logs) }).then(() => {
1552
1552
  }).catch(() => {
1553
1553
  });
1554
1554
  }
1555
1555
  error(...logs) {
1556
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.ERROR, logs) }).then(() => {
1556
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.ERROR, logs) }).then(() => {
1557
1557
  }).catch(() => {
1558
1558
  });
1559
1559
  }
1560
1560
  }
1561
- class Payments extends v {
1561
+ class Payments extends F {
1562
1562
  constructor(api, secret) {
1563
1563
  super();
1564
1564
  __publicField(this, "api");
@@ -1599,7 +1599,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1599
1599
  return history;
1600
1600
  }
1601
1601
  }
1602
- class Pdf extends v {
1602
+ class Pdf extends F {
1603
1603
  constructor(api) {
1604
1604
  super();
1605
1605
  __publicField(this, "api");
@@ -1609,7 +1609,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1609
1609
  const blob = await resp.blob();
1610
1610
  if (fileName) {
1611
1611
  const url = URL.createObjectURL(blob);
1612
- ut(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1612
+ at(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1613
1613
  URL.revokeObjectURL(url);
1614
1614
  }
1615
1615
  this.emit("CREATE", blob);
@@ -1672,12 +1672,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1672
1672
  };
1673
1673
  __publicField(_Socket, "timeout", 1e4);
1674
1674
  let Socket = _Socket;
1675
- class Storage extends v {
1675
+ class Storage extends F {
1676
1676
  constructor(api) {
1677
1677
  super();
1678
1678
  __publicField(this, "api");
1679
1679
  this.api = typeof api == "string" ? new Api(api) : api;
1680
1680
  }
1681
+ copy(path) {
1682
+ return this.api.request({ url: `/api/storage${path.startsWith("/") ? "" : "/"}${path}`, method: "PUT" });
1683
+ }
1681
1684
  delete(path) {
1682
1685
  const url = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll("//", "/");
1683
1686
  return this.api.request({ url, method: "DELETE" }).then(() => {
@@ -1702,6 +1705,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1702
1705
  const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1703
1706
  return this.api.request({ url: p2 + "?directory", method: "POST" });
1704
1707
  }
1708
+ move(from, to) {
1709
+ return this.api.request({ url: `/api/storage${from.startsWith("/") ? "" : "/"}${from}`, method: "PATCH", body: { move: to } });
1710
+ }
1705
1711
  download(path, opts = {}) {
1706
1712
  const p2 = ("/api/storage/" + path).replaceAll("//", "/");
1707
1713
  return this.api.request({ ...opts, url: p2, decode: false }).then(async (response) => {
@@ -1716,7 +1722,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1716
1722
  return new m(async (res, rej, prog) => {
1717
1723
  if (!files) files = await It();
1718
1724
  if (!files || Array.isArray(files) && !files.length) return [];
1719
- const url = this.api.url + ("/api/storage/" + (typeof opts == "string" ? opts : opts == null ? void 0 : opts.path)).replaceAll("//", "/");
1725
+ const url = this.api.url + ("/api/storage/" + ((typeof opts == "string" ? opts : opts == null ? void 0 : opts.path) || "")).replaceAll("//", "/");
1720
1726
  return $t({
1721
1727
  url,
1722
1728
  files: Array.isArray(files) ? files : [files],
@@ -1736,9 +1742,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1736
1742
  }
1737
1743
  async inject(reload = false) {
1738
1744
  if (!Object.keys(this.settings.cache).length || reload) await this.settings.list();
1739
- if (!document.querySelector('meta[name="apple-mobile-web-app-capable"]')) {
1745
+ if (!document.querySelector('meta[name="mobile-web-app-capable"]')) {
1740
1746
  const meta = document.createElement("meta");
1741
- meta.name = "apple-mobile-web-app-capable";
1747
+ meta.name = "mobile-web-app-capable";
1742
1748
  meta.content = "yes";
1743
1749
  document.head.append(meta);
1744
1750
  }
@@ -1934,7 +1940,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1934
1940
  }, 1e3);
1935
1941
  }
1936
1942
  }
1937
- class Users extends v {
1943
+ class Users extends F {
1938
1944
  constructor(api) {
1939
1945
  super();
1940
1946
  __publicField(this, "api");
@@ -2009,7 +2015,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2009
2015
  });
2010
2016
  }
2011
2017
  }
2012
- class Settings extends v {
2018
+ class Settings extends F {
2013
2019
  constructor(api) {
2014
2020
  super();
2015
2021
  __publicField(this, "api");
@@ -2051,7 +2057,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2051
2057
  });
2052
2058
  }
2053
2059
  }
2054
- class Static extends v {
2060
+ class Static extends F {
2055
2061
  constructor(api) {
2056
2062
  super();
2057
2063
  __publicField(this, "api");
@@ -2084,7 +2090,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2084
2090
  });
2085
2091
  }
2086
2092
  }
2087
- class Momentum extends v {
2093
+ class Momentum extends F {
2088
2094
  constructor(url, opts) {
2089
2095
  super();
2090
2096
  __publicField(this, "api");
package/dist/index.mjs CHANGED
@@ -11,11 +11,11 @@ function rt(n, t = false) {
11
11
  (t && r === void 0 || !t && r == null) && delete n[e];
12
12
  }), n;
13
13
  }
14
- function B(n, t) {
14
+ function b(n, t) {
15
15
  const e = typeof n, r = typeof t;
16
- return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? false : Object.keys(n).every((s) => B(n[s], t[s]));
16
+ return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? false : Object.keys(n).every((s) => b(n[s], t[s]));
17
17
  }
18
- function q(n) {
18
+ function U(n) {
19
19
  try {
20
20
  return JSON.parse(n);
21
21
  } catch {
@@ -59,13 +59,13 @@ class m extends Promise {
59
59
  return this.from(super.finally(e));
60
60
  }
61
61
  }
62
- function ut(n, t) {
62
+ function at(n, t) {
63
63
  const e = document.createElement("a");
64
64
  e.href = n, e.download = t, document.body.appendChild(e), e.click(), document.body.removeChild(e);
65
65
  }
66
66
  function Tt(n, t) {
67
67
  const e = URL.createObjectURL(n);
68
- ut(e, t), URL.revokeObjectURL(e);
68
+ at(e, t), URL.revokeObjectURL(e);
69
69
  }
70
70
  function It(n = {}) {
71
71
  return new Promise((t) => {
@@ -78,10 +78,10 @@ function It(n = {}) {
78
78
  function $t(n) {
79
79
  return new m((t, e, r) => {
80
80
  const o = new XMLHttpRequest(), s = new FormData();
81
- n.files.forEach((c) => s.append("file", c)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (c) => c.lengthComputable ? r(c.loaded / c.total) : null), o.addEventListener("loadend", () => t(q(o.responseText))), o.addEventListener("error", () => e(q(o.responseText))), o.addEventListener("timeout", () => e({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([c, y]) => o.setRequestHeader(c, y)), o.send(s);
81
+ n.files.forEach((c) => s.append("file", c)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (c) => c.lengthComputable ? r(c.loaded / c.total) : null), o.addEventListener("loadend", () => t(U(o.responseText))), o.addEventListener("error", () => e(U(o.responseText))), o.addEventListener("timeout", () => e({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([c, y]) => o.setRequestHeader(c, y)), o.send(s);
82
82
  });
83
83
  }
84
- class v {
84
+ class F {
85
85
  constructor() {
86
86
  i(this, "listeners", {});
87
87
  }
@@ -122,7 +122,7 @@ class v {
122
122
  });
123
123
  }
124
124
  }
125
- i(v, "listeners", {});
125
+ i(F, "listeners", {});
126
126
  class p extends Error {
127
127
  constructor(e, r) {
128
128
  super(e);
@@ -151,7 +151,7 @@ class p extends Error {
151
151
  }
152
152
  }
153
153
  i(p, "code", 500);
154
- class F extends p {
154
+ class v extends p {
155
155
  constructor(t = "Bad Request") {
156
156
  super(t);
157
157
  }
@@ -159,8 +159,8 @@ class F extends p {
159
159
  return t.constructor.code == this.code;
160
160
  }
161
161
  }
162
- i(F, "code", 400);
163
- class H extends p {
162
+ i(v, "code", 400);
163
+ class Y extends p {
164
164
  constructor(t = "Unauthorized") {
165
165
  super(t);
166
166
  }
@@ -168,8 +168,8 @@ class H extends p {
168
168
  return t.constructor.code == this.code;
169
169
  }
170
170
  }
171
- i(H, "code", 401);
172
- class Y extends p {
171
+ i(Y, "code", 401);
172
+ class H extends p {
173
173
  constructor(t = "Payment Required") {
174
174
  super(t);
175
175
  }
@@ -177,7 +177,7 @@ class Y extends p {
177
177
  return t.constructor.code == this.code;
178
178
  }
179
179
  }
180
- i(Y, "code", 402);
180
+ i(H, "code", 402);
181
181
  class W extends p {
182
182
  constructor(t = "Forbidden") {
183
183
  super(t);
@@ -187,7 +187,7 @@ class W extends p {
187
187
  }
188
188
  }
189
189
  i(W, "code", 403);
190
- class J extends p {
190
+ class z extends p {
191
191
  constructor(t = "Not Found") {
192
192
  super(t);
193
193
  }
@@ -195,8 +195,8 @@ class J extends p {
195
195
  return t.constructor.code == this.code;
196
196
  }
197
197
  }
198
- i(J, "code", 404);
199
- class z extends p {
198
+ i(z, "code", 404);
199
+ class J extends p {
200
200
  constructor(t = "Method Not Allowed") {
201
201
  super(t);
202
202
  }
@@ -204,7 +204,7 @@ class z extends p {
204
204
  return t.constructor.code == this.code;
205
205
  }
206
206
  }
207
- i(z, "code", 405);
207
+ i(J, "code", 405);
208
208
  class K extends p {
209
209
  constructor(t = "Not Acceptable") {
210
210
  super(t);
@@ -214,7 +214,7 @@ class K extends p {
214
214
  }
215
215
  }
216
216
  i(K, "code", 406);
217
- class V extends p {
217
+ class Z extends p {
218
218
  constructor(t = "Internal Server Error") {
219
219
  super(t);
220
220
  }
@@ -222,8 +222,8 @@ class V extends p {
222
222
  return t.constructor.code == this.code;
223
223
  }
224
224
  }
225
- i(V, "code", 500);
226
- class Z extends p {
225
+ i(Z, "code", 500);
226
+ class V extends p {
227
227
  constructor(t = "Not Implemented") {
228
228
  super(t);
229
229
  }
@@ -231,7 +231,7 @@ class Z extends p {
231
231
  return t.constructor.code == this.code;
232
232
  }
233
233
  }
234
- i(Z, "code", 501);
234
+ i(V, "code", 501);
235
235
  class X extends p {
236
236
  constructor(t = "Bad Gateway") {
237
237
  super(t);
@@ -298,36 +298,36 @@ const w = class w2 {
298
298
  headers: r,
299
299
  method: t.method || (t.body ? "POST" : "GET"),
300
300
  body: t.body
301
- }).then(async (u) => {
302
- var j, G;
303
- for (let a of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
304
- await new Promise((O) => a(u, () => O()));
305
- const R = u.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
301
+ }).then(async (a) => {
302
+ var M, j;
303
+ for (let u of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
304
+ await new Promise((O) => u(a, () => O()));
305
+ const R = a.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
306
306
  let k = 0;
307
- const T = (j = u.body) == null ? void 0 : j.getReader(), tt = new ReadableStream({
308
- start(a) {
307
+ const T = (M = a.body) == null ? void 0 : M.getReader(), tt = new ReadableStream({
308
+ start(u) {
309
309
  function O() {
310
310
  T == null || T.read().then((x) => {
311
311
  if (x.done)
312
- return a.close();
313
- k += x.value.byteLength, y(k / N), a.enqueue(x.value), O();
314
- }).catch((x) => a.error(x));
312
+ return u.close();
313
+ k += x.value.byteLength, y(k / N), u.enqueue(x.value), O();
314
+ }).catch((x) => u.error(x));
315
315
  }
316
316
  O();
317
317
  }
318
318
  });
319
- if (u.data = new Response(tt), t.decode == null || t.decode) {
320
- const a = (G = u.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
321
- a != null && a.includes("form") ? u.data = await u.data.formData() : a != null && a.includes("json") ? u.data = await u.data.json() : a != null && a.includes("text") ? u.data = await u.data.text() : a != null && a.includes("application") && (u.data = await u.data.blob());
319
+ if (a.data = new Response(tt), t.decode == null || t.decode) {
320
+ const u = (j = a.headers.get("Content-Type")) == null ? void 0 : j.toLowerCase();
321
+ u != null && u.includes("form") ? a.data = await a.data.formData() : u != null && u.includes("json") ? a.data = await a.data.json() : u != null && u.includes("text") ? a.data = await a.data.text() : u != null && u.includes("application") && (a.data = await a.data.blob());
322
322
  }
323
- u.ok ? s(u) : c(u);
323
+ a.ok ? s(a) : c(a);
324
324
  });
325
325
  });
326
326
  }
327
327
  };
328
328
  i(w, "interceptors", {}), i(w, "headers", {});
329
- let M = w;
330
- const A = {
329
+ let q = w;
330
+ const B = {
331
331
  CLEAR: "\x1B[0m",
332
332
  BRIGHT: "\x1B[1m",
333
333
  DIM: "\x1B[2m",
@@ -353,8 +353,8 @@ const A = {
353
353
  LIGHT_CYAN: "\x1B[96m",
354
354
  WHITE: "\x1B[97m"
355
355
  };
356
- var at = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(at || {});
357
- const g = class g2 extends v {
356
+ var ut = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(ut || {});
357
+ const g = class g2 extends F {
358
358
  constructor(t) {
359
359
  super(), this.namespace = t;
360
360
  }
@@ -373,39 +373,39 @@ const g = class g2 extends v {
373
373
  if (g2.LOG_LEVEL < 4)
374
374
  return;
375
375
  const e = this.format(...t);
376
- g2.emit(4, e), console.debug(L.LIGHT_GREY + e + A.CLEAR);
376
+ g2.emit(4, e), console.debug(L.LIGHT_GREY + e + B.CLEAR);
377
377
  }
378
378
  log(...t) {
379
379
  if (g2.LOG_LEVEL < 3)
380
380
  return;
381
381
  const e = this.format(...t);
382
- g2.emit(3, e), console.log(A.CLEAR + e);
382
+ g2.emit(3, e), console.log(B.CLEAR + e);
383
383
  }
384
384
  info(...t) {
385
385
  if (g2.LOG_LEVEL < 2)
386
386
  return;
387
387
  const e = this.format(...t);
388
- g2.emit(2, e), console.info(L.BLUE + e + A.CLEAR);
388
+ g2.emit(2, e), console.info(L.BLUE + e + B.CLEAR);
389
389
  }
390
390
  warn(...t) {
391
391
  if (g2.LOG_LEVEL < 1)
392
392
  return;
393
393
  const e = this.format(...t);
394
- g2.emit(1, e), console.warn(L.YELLOW + e + A.CLEAR);
394
+ g2.emit(1, e), console.warn(L.YELLOW + e + B.CLEAR);
395
395
  }
396
396
  error(...t) {
397
397
  if (g2.LOG_LEVEL < 0)
398
398
  return;
399
399
  const e = this.format(...t);
400
- g2.emit(0, e), console.error(L.RED + e + A.CLEAR);
400
+ g2.emit(0, e), console.error(L.RED + e + B.CLEAR);
401
401
  }
402
402
  };
403
403
  i(g, "LOG_LEVEL", 4);
404
- class Api extends M {
404
+ class Api extends q {
405
405
  constructor(url = location.origin, opts = {}) {
406
406
  opts.url = url;
407
407
  super(opts);
408
- __publicField(this, "emitter", new v());
408
+ __publicField(this, "emitter", new F());
409
409
  __publicField(this, "_token", null);
410
410
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
411
411
  __publicField(this, "off", this.emitter.off.bind(this.emitter));
@@ -439,22 +439,22 @@ class Api extends M {
439
439
  return req;
440
440
  }
441
441
  }
442
- var extendStatics = function(d, b) {
443
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
444
- d2.__proto__ = b2;
445
- } || function(d2, b2) {
446
- for (var p2 in b2) if (Object.prototype.hasOwnProperty.call(b2, p2)) d2[p2] = b2[p2];
442
+ var extendStatics = function(d, b2) {
443
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b3) {
444
+ d2.__proto__ = b3;
445
+ } || function(d2, b3) {
446
+ for (var p2 in b3) if (Object.prototype.hasOwnProperty.call(b3, p2)) d2[p2] = b3[p2];
447
447
  };
448
- return extendStatics(d, b);
448
+ return extendStatics(d, b2);
449
449
  };
450
- function __extends(d, b) {
451
- if (typeof b !== "function" && b !== null)
452
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
453
- extendStatics(d, b);
450
+ function __extends(d, b2) {
451
+ if (typeof b2 !== "function" && b2 !== null)
452
+ throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
453
+ extendStatics(d, b2);
454
454
  function __() {
455
455
  this.constructor = d;
456
456
  }
457
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
457
+ d.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
458
458
  }
459
459
  function __values(o) {
460
460
  var s = typeof Symbol === "function" && Symbol.iterator, m2 = s && o[s], i2 = 0;
@@ -1155,7 +1155,7 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
1155
1155
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
1156
1156
  return ActionType2;
1157
1157
  })(ActionType || {});
1158
- class Actions extends v {
1158
+ class Actions extends F {
1159
1159
  constructor(api) {
1160
1160
  super();
1161
1161
  __publicField(this, "api");
@@ -1209,7 +1209,7 @@ class Actions extends v {
1209
1209
  });
1210
1210
  }
1211
1211
  }
1212
- class Ai extends v {
1212
+ class Ai extends F {
1213
1213
  constructor(api) {
1214
1214
  super();
1215
1215
  __publicField(this, "api");
@@ -1225,7 +1225,7 @@ class Ai extends v {
1225
1225
  });
1226
1226
  }
1227
1227
  }
1228
- class Analytics extends v {
1228
+ class Analytics extends F {
1229
1229
  constructor(api) {
1230
1230
  super();
1231
1231
  __publicField(this, "api");
@@ -1256,7 +1256,7 @@ class Totp {
1256
1256
  }) });
1257
1257
  }
1258
1258
  }
1259
- class Auth extends v {
1259
+ class Auth extends F {
1260
1260
  constructor(api, opts) {
1261
1261
  var _a;
1262
1262
  super();
@@ -1301,7 +1301,7 @@ class Auth extends v {
1301
1301
  return this.$user.value;
1302
1302
  }
1303
1303
  set user(user) {
1304
- if (!B(this.user, user)) {
1304
+ if (!b(this.user, user)) {
1305
1305
  const u = user ? user : null;
1306
1306
  this.$user.next(u);
1307
1307
  this.emit("USER", u);
@@ -1387,7 +1387,7 @@ class Auth extends v {
1387
1387
  });
1388
1388
  }
1389
1389
  }
1390
- class Data extends v {
1390
+ class Data extends F {
1391
1391
  constructor(api) {
1392
1392
  super();
1393
1393
  __publicField(this, "api");
@@ -1432,7 +1432,7 @@ class Data extends v {
1432
1432
  });
1433
1433
  }
1434
1434
  }
1435
- class Email extends v {
1435
+ class Email extends F {
1436
1436
  constructor(api) {
1437
1437
  super();
1438
1438
  __publicField(this, "api");
@@ -1447,7 +1447,7 @@ class Email extends v {
1447
1447
  });
1448
1448
  }
1449
1449
  }
1450
- class Groups extends v {
1450
+ class Groups extends F {
1451
1451
  constructor(api) {
1452
1452
  super();
1453
1453
  __publicField(this, "api");
@@ -1529,32 +1529,32 @@ class Logger {
1529
1529
  return this.api.request({ url: `/api/logs/server${query ? `?${query}` : ""}` }).then((resp) => resp);
1530
1530
  }
1531
1531
  debug(...logs) {
1532
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.DEBUG, logs) }).then(() => {
1532
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.DEBUG, logs) }).then(() => {
1533
1533
  }).catch(() => {
1534
1534
  });
1535
1535
  }
1536
1536
  log(...logs) {
1537
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.LOG, logs) }).then(() => {
1537
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.LOG, logs) }).then(() => {
1538
1538
  }).catch(() => {
1539
1539
  });
1540
1540
  }
1541
1541
  info(...logs) {
1542
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.INFO, logs) }).then(() => {
1542
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.INFO, logs) }).then(() => {
1543
1543
  }).catch(() => {
1544
1544
  });
1545
1545
  }
1546
1546
  warn(...logs) {
1547
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.WARN, logs) }).then(() => {
1547
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.WARN, logs) }).then(() => {
1548
1548
  }).catch(() => {
1549
1549
  });
1550
1550
  }
1551
1551
  error(...logs) {
1552
- return this.api.request({ url: `/api/logs/client`, body: this.buildLog(at.ERROR, logs) }).then(() => {
1552
+ return this.api.request({ url: `/api/logs/client`, body: this.buildLog(ut.ERROR, logs) }).then(() => {
1553
1553
  }).catch(() => {
1554
1554
  });
1555
1555
  }
1556
1556
  }
1557
- class Payments extends v {
1557
+ class Payments extends F {
1558
1558
  constructor(api, secret) {
1559
1559
  super();
1560
1560
  __publicField(this, "api");
@@ -1595,7 +1595,7 @@ class Payments extends v {
1595
1595
  return history;
1596
1596
  }
1597
1597
  }
1598
- class Pdf extends v {
1598
+ class Pdf extends F {
1599
1599
  constructor(api) {
1600
1600
  super();
1601
1601
  __publicField(this, "api");
@@ -1605,7 +1605,7 @@ class Pdf extends v {
1605
1605
  const blob = await resp.blob();
1606
1606
  if (fileName) {
1607
1607
  const url = URL.createObjectURL(blob);
1608
- ut(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1608
+ at(url, fileName.endsWith(".pdf") ? fileName : fileName + ".pdf");
1609
1609
  URL.revokeObjectURL(url);
1610
1610
  }
1611
1611
  this.emit("CREATE", blob);
@@ -1668,12 +1668,15 @@ const _Socket = class _Socket {
1668
1668
  };
1669
1669
  __publicField(_Socket, "timeout", 1e4);
1670
1670
  let Socket = _Socket;
1671
- class Storage extends v {
1671
+ class Storage extends F {
1672
1672
  constructor(api) {
1673
1673
  super();
1674
1674
  __publicField(this, "api");
1675
1675
  this.api = typeof api == "string" ? new Api(api) : api;
1676
1676
  }
1677
+ copy(path) {
1678
+ return this.api.request({ url: `/api/storage${path.startsWith("/") ? "" : "/"}${path}`, method: "PUT" });
1679
+ }
1677
1680
  delete(path) {
1678
1681
  const url = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll("//", "/");
1679
1682
  return this.api.request({ url, method: "DELETE" }).then(() => {
@@ -1698,6 +1701,9 @@ class Storage extends v {
1698
1701
  const p2 = (path.startsWith("/api/storage/") ? path : "/api/storage/" + path).replaceAll(/\/{2,}/g, "/");
1699
1702
  return this.api.request({ url: p2 + "?directory", method: "POST" });
1700
1703
  }
1704
+ move(from, to) {
1705
+ return this.api.request({ url: `/api/storage${from.startsWith("/") ? "" : "/"}${from}`, method: "PATCH", body: { move: to } });
1706
+ }
1701
1707
  download(path, opts = {}) {
1702
1708
  const p2 = ("/api/storage/" + path).replaceAll("//", "/");
1703
1709
  return this.api.request({ ...opts, url: p2, decode: false }).then(async (response) => {
@@ -1712,7 +1718,7 @@ class Storage extends v {
1712
1718
  return new m(async (res, rej, prog) => {
1713
1719
  if (!files) files = await It();
1714
1720
  if (!files || Array.isArray(files) && !files.length) return [];
1715
- const url = this.api.url + ("/api/storage/" + (typeof opts == "string" ? opts : opts == null ? void 0 : opts.path)).replaceAll("//", "/");
1721
+ const url = this.api.url + ("/api/storage/" + ((typeof opts == "string" ? opts : opts == null ? void 0 : opts.path) || "")).replaceAll("//", "/");
1716
1722
  return $t({
1717
1723
  url,
1718
1724
  files: Array.isArray(files) ? files : [files],
@@ -1732,9 +1738,9 @@ class UI {
1732
1738
  }
1733
1739
  async inject(reload = false) {
1734
1740
  if (!Object.keys(this.settings.cache).length || reload) await this.settings.list();
1735
- if (!document.querySelector('meta[name="apple-mobile-web-app-capable"]')) {
1741
+ if (!document.querySelector('meta[name="mobile-web-app-capable"]')) {
1736
1742
  const meta = document.createElement("meta");
1737
- meta.name = "apple-mobile-web-app-capable";
1743
+ meta.name = "mobile-web-app-capable";
1738
1744
  meta.content = "yes";
1739
1745
  document.head.append(meta);
1740
1746
  }
@@ -1930,7 +1936,7 @@ class UI {
1930
1936
  }, 1e3);
1931
1937
  }
1932
1938
  }
1933
- class Users extends v {
1939
+ class Users extends F {
1934
1940
  constructor(api) {
1935
1941
  super();
1936
1942
  __publicField(this, "api");
@@ -2005,7 +2011,7 @@ class Users extends v {
2005
2011
  });
2006
2012
  }
2007
2013
  }
2008
- class Settings extends v {
2014
+ class Settings extends F {
2009
2015
  constructor(api) {
2010
2016
  super();
2011
2017
  __publicField(this, "api");
@@ -2047,7 +2053,7 @@ class Settings extends v {
2047
2053
  });
2048
2054
  }
2049
2055
  }
2050
- class Static extends v {
2056
+ class Static extends F {
2051
2057
  constructor(api) {
2052
2058
  super();
2053
2059
  __publicField(this, "api");
@@ -2080,7 +2086,7 @@ class Static extends v {
2080
2086
  });
2081
2087
  }
2082
2088
  }
2083
- class Momentum extends v {
2089
+ class Momentum extends F {
2084
2090
  constructor(url, opts) {
2085
2091
  super();
2086
2092
  __publicField(this, "api");
package/dist/storage.d.ts CHANGED
@@ -13,6 +13,7 @@ export type FileMeta = Meta & {
13
13
  name: string;
14
14
  mime: string;
15
15
  size: number;
16
+ missing?: boolean;
16
17
  };
17
18
  export type StorageEvents = TypedEvents & {
18
19
  LIST: (path: string, response: DirMeta | FileMeta) => any;
@@ -24,11 +25,13 @@ export type StorageEvents = TypedEvents & {
24
25
  export declare class Storage extends TypedEmitter<StorageEvents> {
25
26
  readonly api: Api;
26
27
  constructor(api: Api | string);
28
+ copy(path: string): Promise<DirMeta | FileMeta>;
27
29
  delete(path: string): Promise<void>;
28
30
  list(path: string): Promise<DirMeta | FileMeta>;
29
31
  open(path: string, target: false): string;
30
32
  open(path: string, target?: '_blank' | '_self'): Window | null;
31
33
  mkdir(path: string): Promise<DirMeta>;
34
+ move(from: string, to: string): Promise<DirMeta | FileMeta>;
32
35
  download(path: string, opts?: HttpRequestOptions & {
33
36
  'downlo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AAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAS9D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKrC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;IAI3D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAkB,GAAG;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAM,GAAG,eAAe,CAAC,IAAI,CAAC;IAWtG,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,GAAE,MAAM,GAAG;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;CAkB3I"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/momentum",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
4
4
  "description": "Client library for momentum",
5
5
  "keywords": ["Momentum"],
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
@@ -24,7 +24,7 @@
24
24
  "postbuild": "node -e \"const fs=require('fs');fs.cpSync('dist/index.mjs','../server/public/momentum.mjs');fs.cpSync('dist/index.cjs','../server/public/momentum.js')\""
25
25
  },
26
26
  "dependencies": {
27
- "@ztimson/utils": "0.15.4",
27
+ "@ztimson/utils": "0.15.6",
28
28
  "rxjs": "^7.8.1"
29
29
  },
30
30
  "devDependencies": {