bt-core-app 1.4.580 → 1.4.581

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.
@@ -10251,102 +10251,129 @@ function BV() {
10251
10251
  function lk(e) {
10252
10252
  const t = "isInDemoMode", n = localStorage.getItem(t), a = H((e == null ? void 0 : e.startInDemo) == !0 || n == "true"), l = (e == null ? void 0 : e.apis) ?? [];
10253
10253
  function r() {
10254
- var v;
10255
- ((v = e == null ? void 0 : e.auth) == null ? void 0 : v.isLoggedIn.value) == !0 && (e == null || e.auth.logout()), (e == null ? void 0 : e.getAuthToken) != null && e.auth != null && e.auth.setAuth(Yw(e.getAuthToken())), a.value = !0, localStorage.setItem(t, "true"), window.location.href = location.href;
10254
+ var m;
10255
+ ((m = e == null ? void 0 : e.auth) == null ? void 0 : m.isLoggedIn.value) == !0 && (e == null || e.auth.logout()), (e == null ? void 0 : e.getAuthToken) != null && e.auth != null && e.auth.setAuth(Yw(e.getAuthToken())), a.value = !0, localStorage.setItem(t, "true"), window.location.href = location.href;
10256
10256
  }
10257
- function i(v) {
10257
+ function i(m) {
10258
10258
  a.value = !1;
10259
- const m = z0();
10260
- m && m._s.forEach((g) => {
10261
- g.$reset();
10262
- }), localStorage.setItem(t, "false"), (e == null ? void 0 : e.auth) != null && (e == null || e.auth.logout()), window.location.href = v == !0 ? location.origin : location.href;
10259
+ const g = z0();
10260
+ g && g._s.forEach((y) => {
10261
+ y.$reset();
10262
+ }), localStorage.setItem(t, "false"), (e == null ? void 0 : e.auth) != null && (e == null || e.auth.logout()), window.location.href = m == !0 ? location.origin : location.href;
10263
10263
  }
10264
- function o(v) {
10265
- let m;
10266
- if (v.finalUrl != null) {
10267
- const g = new URL(v.finalUrl, "https://demo");
10268
- console.log(`searching for path ${g.pathname} or ${g.pathname + g.search}`), m = l.find((y) => y.path == g.pathname || y.path == g.pathname + g.search);
10264
+ function o(m) {
10265
+ let g;
10266
+ if (m.finalUrl != null) {
10267
+ const y = new URL(m.finalUrl, "https://demo");
10268
+ console.log(`searching for path ${y.pathname} or ${y.pathname + y.search}`), g = l.find((d) => d.path == y.pathname || d.path == y.pathname + y.search);
10269
10269
  }
10270
- return m == null && (m = l.find((g) => Array.isArray(g.nav) ? g.nav.some((y) => y == v.nav) : g.nav == v.nav)), m == null && console.log(`No api group found for ${v.nav} and path: ${v.additionalUrl}`), m;
10270
+ return g == null && (g = l.find((y) => Array.isArray(y.nav) ? y.nav.some((d) => d == m.nav) : y.nav == m.nav)), g == null && console.log(`No api group found for ${m.nav} and path: ${m.additionalUrl}`), g;
10271
10271
  }
10272
- function s(v) {
10273
- var y;
10272
+ function s(m) {
10273
+ var d;
10274
10274
  if (l == null)
10275
10275
  return Promise.resolve("no demo data available for this api");
10276
- const m = v.id ?? ((y = v.data) == null ? void 0 : y.id), g = o(v);
10277
- if (m != null && (g == null ? void 0 : g.data) != null) {
10278
- const d = g.data.findIndex((x) => x.id == m);
10279
- d >= 0 && (g.deleteAction != null ? g.deleteAction(g.data, d) : g.data.splice(d, 1));
10276
+ const g = m.id ?? ((d = m.data) == null ? void 0 : d.id), y = o(m);
10277
+ if (g != null && (y == null ? void 0 : y.data) != null) {
10278
+ const x = y.data.findIndex((C) => C.id == g);
10279
+ x >= 0 && (y.deleteAction != null ? y.deleteAction(y.data, x) : y.data.splice(x, 1));
10280
10280
  }
10281
- return new Promise(function(d) {
10281
+ return new Promise(function(x) {
10282
10282
  setTimeout(function() {
10283
- d({
10283
+ x({
10284
10284
  data: void 0
10285
10285
  });
10286
10286
  }, 200);
10287
10287
  });
10288
10288
  }
10289
- function c(v) {
10290
- var d, x;
10289
+ function c(m, g, y) {
10290
+ var d = y;
10291
+ if (d != null && (d = d.replaceAll("/", "").replaceAll(" ", "").toLowerCase()), d != null) {
10292
+ if (d = d.split("?")[0], g == "Get") {
10293
+ if (d != null && m.getActions != null && m.getActions[d] != null)
10294
+ return m.getActions[d];
10295
+ } else if (g == "Patch") {
10296
+ if (d != null && m.patchActions != null && m.patchActions[d] != null)
10297
+ return m.patchActions[d];
10298
+ } else if (g == "Post" && d != null && m.postActions != null && m.postActions[d] != null)
10299
+ return m.postActions[d];
10300
+ }
10301
+ }
10302
+ function u(m) {
10303
+ var C, p;
10291
10304
  if (l == null)
10292
10305
  throw new Error("no demo data available for this api");
10293
- const m = v.id ?? ((d = v.data) == null ? void 0 : d.id), g = o(v);
10294
- let y;
10295
- return g != null && (g.data ?? (g.data = []), g.getAction != null ? y = g.getAction(g.data, m) : m != null ? y = (x = g.data) == null ? void 0 : x.find((C) => C.id == m) : g.path != null && (y = g.data)), y == null ? Promise.resolve(void 0) : new Promise((C) => {
10306
+ const g = m.id ?? ((C = m.data) == null ? void 0 : C.id), y = o(m);
10307
+ let d;
10308
+ if (y != null) {
10309
+ y.data ?? (y.data = []);
10310
+ var x = c(y, "Get", m.additionalUrl);
10311
+ x != null ? d = x(y.data, m, g) : y.getAction != null ? d = y.getAction(y.data, g) : g != null ? d = (p = y.data) == null ? void 0 : p.find((S) => S.id == g) : y.path != null && (d = y.data);
10312
+ }
10313
+ return d == null ? Promise.resolve(void 0) : new Promise((S) => {
10296
10314
  setTimeout(() => {
10297
- C({
10298
- data: y
10315
+ S({
10316
+ data: d
10299
10317
  });
10300
10318
  });
10301
10319
  });
10302
10320
  }
10303
- function u(v) {
10321
+ function f(m) {
10304
10322
  if (l == null)
10305
10323
  throw new Error("no demo data available for this api");
10306
- const m = o(v);
10307
- let g;
10308
- return m != null && (m.data ?? (m.data = []), m.getAllAction != null ? g = m.getAllAction(m.data, v.params) : g = m.data), g == null ? Promise.resolve(void 0) : new Promise((y) => {
10324
+ const g = o(m);
10325
+ let y;
10326
+ return g != null && (g.data ?? (g.data = []), g.getAllAction != null ? y = g.getAllAction(g.data, m.params) : y = g.data), y == null ? Promise.resolve(void 0) : new Promise((d) => {
10309
10327
  setTimeout(() => {
10310
- y({
10311
- data: g,
10328
+ d({
10329
+ data: y,
10312
10330
  filters: [],
10313
- count: (g == null ? void 0 : g.length) ?? 0
10331
+ count: (y == null ? void 0 : y.length) ?? 0
10314
10332
  });
10315
10333
  });
10316
10334
  });
10317
10335
  }
10318
- function f(v) {
10319
- var y, d;
10336
+ function h(m) {
10337
+ var x, C;
10320
10338
  if (l == null)
10321
10339
  throw new Error("no demo data available for this api");
10322
- const m = o(v);
10323
- let g;
10324
- return m != null && (m.data ?? (m.data = []), m.postAction != null ? g = m.postAction(m.data, v.data) : v.data != null && (v.data.id == null && (v.data.id = ((((y = m.data) == null ? void 0 : y.length) ?? 0) + 1).toString()), g = v.data, (d = m.data) == null || d.push(g))), g == null ? Promise.resolve(void 0) : new Promise((x) => {
10340
+ const g = o(m);
10341
+ let y;
10342
+ if (g != null) {
10343
+ g.data ?? (g.data = []);
10344
+ var d = c(g, "Post", m.additionalUrl);
10345
+ d != null ? y = d(g.data, m) : g.postAction != null ? y = g.postAction(g.data, m.data) : m.data != null && (m.data.id == null && (m.data.id = ((((x = g.data) == null ? void 0 : x.length) ?? 0) + 1).toString()), y = m.data, (C = g.data) == null || C.push(y));
10346
+ }
10347
+ return y == null ? Promise.resolve(void 0) : new Promise((p) => {
10325
10348
  setTimeout(() => {
10326
- x({
10327
- data: g
10349
+ p({
10350
+ data: y
10328
10351
  });
10329
10352
  });
10330
10353
  });
10331
10354
  }
10332
- function h(v) {
10333
- var y, d;
10355
+ function v(m) {
10356
+ var x, C;
10334
10357
  if (l == null)
10335
10358
  throw new Error("no demo data available for this api");
10336
- const m = o(v);
10337
- let g;
10338
- if (m != null) {
10339
- if (m.data ?? (m.data = []), m.patchAction != null)
10340
- g = m.patchAction(m.data, v.data);
10341
- else if (v.data.id != null) {
10342
- const x = (y = m.data) == null ? void 0 : y.findIndex((C) => C.id == v.data.id);
10343
- x != null && x > -1 && ((d = m.data) == null || d.splice(x, 1, v.data)), g = v.data;
10344
- }
10345
- }
10346
- return g == null ? Promise.resolve(void 0) : new Promise((x) => {
10359
+ const g = o(m);
10360
+ let y;
10361
+ if (g != null) {
10362
+ g.data ?? (g.data = []);
10363
+ var d = c(g, "Patch", m.additionalUrl);
10364
+ if (d != null)
10365
+ y = d(g.data, m);
10366
+ else if (g.patchAction != null)
10367
+ y = g.patchAction(g.data, m.data);
10368
+ else if (m.data.id != null) {
10369
+ const p = (x = g.data) == null ? void 0 : x.findIndex((S) => S.id == m.data.id);
10370
+ p != null && p > -1 && ((C = g.data) == null || C.splice(p, 1, m.data)), y = m.data;
10371
+ }
10372
+ }
10373
+ return y == null ? Promise.resolve(void 0) : new Promise((p) => {
10347
10374
  setTimeout(() => {
10348
- x({
10349
- data: g
10375
+ p({
10376
+ data: y
10350
10377
  });
10351
10378
  });
10352
10379
  });
@@ -10357,10 +10384,10 @@ function lk(e) {
10357
10384
  startDemo: r,
10358
10385
  data: l,
10359
10386
  deleteItem: s,
10360
- get: c,
10361
- getAll: u,
10362
- post: f,
10363
- patch: h
10387
+ get: u,
10388
+ getAll: f,
10389
+ post: h,
10390
+ patch: v
10364
10391
  }, hc;
10365
10392
  }
10366
10393
  let bn;
package/dist/index.d.ts CHANGED
@@ -552,6 +552,9 @@ export declare interface DemoApiGroup {
552
552
  getAction?: <T>(list: T[], id?: string) => T | any;
553
553
  patchAction?: <T>(list: T[], item: any) => T | any;
554
554
  postAction?: <T>(list: T[], item: any) => T | any;
555
+ getActions?: Record<string, <T>(list: T[], pathOptions?: PathOptions, id?: string) => any>;
556
+ postActions?: Record<string, <T>(list: T[], pathOptions?: PathOptions, id?: string) => any>;
557
+ patchActions?: Record<string, <T>(list: T[], pathOptions?: PathOptions, id?: string) => any>;
555
558
  }
556
559
 
557
560
  export declare const demoKey: unique symbol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-core-app",
3
- "version": "1.4.580",
3
+ "version": "1.4.581",
4
4
  "description": "Core app tools for some basic features like navigation, authentication, server apis, and cosmetics",
5
5
  "homepage": "https://github.com/BlitzItTech/bt-core",
6
6
  "bugs": {