@feedmepos/mf-hrm-portal 2.0.8-dev.3 → 2.0.8-dev.5
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/{AuditLogList-DU9bvapH.js → AuditLogList-ChmO_lsf.js} +29 -29
- package/dist/{EmployeeList-C0Kt6J2s.js → EmployeeList-B43c3tSt.js} +5 -5
- package/dist/{Main-wneSr3Yj.js → Main--wV8uMFW.js} +4 -4
- package/dist/{Main-CGoSOSHf.js → Main-DKJWXUF1.js} +9 -9
- package/dist/{Main-YgAJrDXR.js → Main-eEQq0uiP.js} +6 -6
- package/dist/{PermissionSetList-BG5FcHDo.js → PermissionSetList-CA7dsUY5.js} +5 -5
- package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Dfey316Z.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-DLZyVi00.js} +921 -916
- package/dist/{RoleList-D6aapDtQ.js → RoleList-Nm7T5wl8.js} +7 -7
- package/dist/{TeamMemberList-BQ3xq4Q2.js → TeamMemberList-BOcKTiHH.js} +8 -8
- package/dist/{TimesheetList-DqEtBC_2.js → TimesheetList-CoaX44py.js} +7 -7
- package/dist/{app-efNRBiJB.js → app-CgPpZ0md.js} +1147 -1044
- package/dist/app.js +2 -2
- package/dist/{dayjs.min-O2mY8Dsx.js → dayjs.min-DLZqYqC8.js} +1 -1
- package/dist/{employee-Cr5TX4u1.js → employee-DQIeO3Ta.js} +4 -4
- package/dist/{index-CMFJQ1p8.js → index-CxEFSIGE.js} +1 -1
- package/dist/{index-DPcm9B8U.js → index-D5bUBGCO.js} +255 -248
- package/dist/{iteration-BzPWNf3I.js → iteration-Ceh9Zaed.js} +1 -1
- package/dist/{lodash-rnloBy2O.js → lodash-MQv9R8bY.js} +1 -1
- package/dist/src/helpers/permission-set.d.ts +8 -1
- package/dist/{team-CJ3xjFT7.js → team-DTdEqDL-.js} +1 -1
- package/dist/{timesheet-BABSsqqp.js → timesheet-Co0CE_kB.js} +3 -3
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{useAppStore-DxEeYbWz.js → useAppStore-CNGyVfbo.js} +1 -1
- package/dist/{useLoading-zLCQaKfz.js → useLoading-GdaFiYX1.js} +1 -1
- package/dist/{useReportPermissions-BB-vWjkE.js → useReportPermissions-Cm6b6zJE.js} +3 -3
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as b, b as g, d as X, e as j, s as L, q as M } from "./iteration-
|
|
2
|
-
import {
|
|
1
|
+
import { g as b, b as g, d as X, e as j, s as L, q as M } from "./iteration-Ceh9Zaed.js";
|
|
2
|
+
import { f as J, b as R, U as F, d as D, a as S, H } from "./app-CgPpZ0md.js";
|
|
3
3
|
import { defineStore as x, storeToRefs as k } from "pinia";
|
|
4
4
|
import { ref as h, computed as N } from "vue";
|
|
5
5
|
import { useCoreStore as q } from "@feedmepos/mf-common";
|
|
@@ -344,193 +344,193 @@ const T = [
|
|
|
344
344
|
async create(e) {
|
|
345
345
|
return b(await g().post(A, e));
|
|
346
346
|
},
|
|
347
|
-
async update(e,
|
|
348
|
-
return b(await g().put(`${A}/${e}`,
|
|
347
|
+
async update(e, t) {
|
|
348
|
+
return b(await g().put(`${A}/${e}`, t));
|
|
349
349
|
},
|
|
350
350
|
async delete(e) {
|
|
351
351
|
return b(await g().delete(`${A}/${e}`));
|
|
352
352
|
}
|
|
353
|
-
},
|
|
353
|
+
}, Q = x("permissionSet", () => {
|
|
354
354
|
const e = h([]);
|
|
355
|
-
async function
|
|
356
|
-
const
|
|
357
|
-
e.value =
|
|
355
|
+
async function t() {
|
|
356
|
+
const a = await I.read();
|
|
357
|
+
e.value = n(a);
|
|
358
358
|
}
|
|
359
|
-
async function
|
|
360
|
-
const i = await I.create(
|
|
361
|
-
e.value =
|
|
359
|
+
async function s(a) {
|
|
360
|
+
const i = await I.create(a);
|
|
361
|
+
e.value = n([...e.value, i]);
|
|
362
362
|
}
|
|
363
|
-
async function
|
|
364
|
-
const c = await I.update(
|
|
365
|
-
e.value =
|
|
363
|
+
async function o(a, i) {
|
|
364
|
+
const c = await I.update(a, i);
|
|
365
|
+
e.value = n(e.value.map((u) => u.id === a ? c : u));
|
|
366
366
|
}
|
|
367
|
-
async function a
|
|
368
|
-
await I.delete(
|
|
367
|
+
async function r(a) {
|
|
368
|
+
await I.delete(a), e.value = n(e.value.filter((i) => i.id !== a));
|
|
369
369
|
}
|
|
370
|
-
function
|
|
371
|
-
return
|
|
370
|
+
function n(a) {
|
|
371
|
+
return a.sort((i, c) => i.name.localeCompare(c.name));
|
|
372
372
|
}
|
|
373
373
|
return {
|
|
374
374
|
permissionSets: e,
|
|
375
|
-
readPermissionSets:
|
|
376
|
-
createPermissionSet:
|
|
377
|
-
updatePermissionSet:
|
|
378
|
-
deletePermissionSet:
|
|
375
|
+
readPermissionSets: t,
|
|
376
|
+
createPermissionSet: s,
|
|
377
|
+
updatePermissionSet: o,
|
|
378
|
+
deletePermissionSet: r
|
|
379
379
|
};
|
|
380
|
-
}),
|
|
381
|
-
const e =
|
|
380
|
+
}), Z = () => {
|
|
381
|
+
const e = Q();
|
|
382
382
|
return {
|
|
383
383
|
...e,
|
|
384
384
|
...k(e)
|
|
385
385
|
};
|
|
386
386
|
};
|
|
387
387
|
function Se(e) {
|
|
388
|
-
let
|
|
389
|
-
return
|
|
388
|
+
let t = e.substring(e.indexOf("_") + 1);
|
|
389
|
+
return t.includes("_") && (t = t.substring(0, t.lastIndexOf("_"))), Number.isNaN(Date.parse(t)) ? null : new Date(t).toISOString();
|
|
390
390
|
}
|
|
391
391
|
function je(e) {
|
|
392
|
-
const
|
|
393
|
-
return `${
|
|
392
|
+
const t = Math.floor(e / 60), s = e % 60;
|
|
393
|
+
return `${t}h ${s.toString().padStart(2, "0")}m`;
|
|
394
394
|
}
|
|
395
|
-
function
|
|
396
|
-
const
|
|
397
|
-
return
|
|
395
|
+
function G(e) {
|
|
396
|
+
const t = e.replace(/([A-Z])/g, " $1");
|
|
397
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
398
398
|
}
|
|
399
|
-
function ye(e,
|
|
400
|
-
if (e.some((
|
|
401
|
-
const
|
|
402
|
-
(
|
|
403
|
-
),
|
|
404
|
-
return
|
|
399
|
+
function ye(e, t, s) {
|
|
400
|
+
if (e.some((a) => a.subject === "all")) return "All";
|
|
401
|
+
const o = (s ?? T).filter(
|
|
402
|
+
(a) => a.subject === t
|
|
403
|
+
), r = new Set(o.map((a) => E(a).value)), n = e.filter((a) => a.subject === t).filter((a) => r.has(E(a).value));
|
|
404
|
+
return n.length === o.length ? "All" : n.length === 0 ? "-" : `${n.length} permission allow`;
|
|
405
405
|
}
|
|
406
406
|
function E(e) {
|
|
407
|
-
const
|
|
407
|
+
const t = X(e), s = t.subject;
|
|
408
408
|
return {
|
|
409
|
-
...
|
|
409
|
+
...t,
|
|
410
410
|
get conditions() {
|
|
411
|
-
return typeof
|
|
411
|
+
return typeof t.conditions == "string" ? JSON.parse(t.conditions) : t.conditions;
|
|
412
412
|
},
|
|
413
413
|
get isDiscountOperation() {
|
|
414
|
-
var
|
|
415
|
-
return
|
|
414
|
+
var o;
|
|
415
|
+
return s === j.F_RULE_SUBJECT.enum.order && ((o = this.conditions) == null ? void 0 : o.operation) === j.F_RULE_ORDER_OPERATION.enum.discount;
|
|
416
416
|
},
|
|
417
417
|
get isOrderOperation() {
|
|
418
|
-
return
|
|
418
|
+
return s === j.F_RULE_SUBJECT.enum.order;
|
|
419
419
|
},
|
|
420
420
|
get isReportPermission() {
|
|
421
|
-
return
|
|
421
|
+
return s === j.F_RULE_SUBJECT.enum.report;
|
|
422
422
|
},
|
|
423
423
|
get formatted() {
|
|
424
|
-
const
|
|
425
|
-
return this.isOrderOperation ?
|
|
424
|
+
const o = (r) => r.endsWith("_") ? r.slice(0, r.length - 1) : r;
|
|
425
|
+
return this.isOrderOperation ? o(this.conditions.operation) : this.isReportPermission ? o(this.conditions.name) : s.toString();
|
|
426
426
|
},
|
|
427
427
|
get label() {
|
|
428
|
-
return
|
|
428
|
+
return t.label || G(this.formatted);
|
|
429
429
|
},
|
|
430
430
|
get value() {
|
|
431
|
-
return this.isOrderOperation ? `${
|
|
431
|
+
return this.isOrderOperation ? `${s}:${this.conditions.operation}` : this.isReportPermission ? `${s}:${this.conditions.name}` : s.toString();
|
|
432
432
|
}
|
|
433
433
|
};
|
|
434
434
|
}
|
|
435
435
|
function he(e) {
|
|
436
|
-
const
|
|
437
|
-
return
|
|
436
|
+
const t = e.map((s) => E(s)).find((s) => s.isDiscountOperation);
|
|
437
|
+
return t ? parseInt((t.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
|
|
438
438
|
}
|
|
439
439
|
function Y(e) {
|
|
440
|
-
const
|
|
441
|
-
(
|
|
440
|
+
const t = e.find(
|
|
441
|
+
(s) => s.subject === J.Subject.Restaurant.restaurant
|
|
442
442
|
);
|
|
443
|
-
return
|
|
443
|
+
return t ? t.conditions ? JSON.parse(t.conditions).restaurantId.$in : null : [];
|
|
444
444
|
}
|
|
445
445
|
function Pe(e) {
|
|
446
|
-
return (e == null ? void 0 : e.some((
|
|
446
|
+
return (e == null ? void 0 : e.some((t) => t.subject === "all")) ?? !1;
|
|
447
447
|
}
|
|
448
448
|
function we(e) {
|
|
449
|
-
const
|
|
450
|
-
return
|
|
449
|
+
const t = e.find((s) => s.subject === J.Subject.Business.role);
|
|
450
|
+
return t ? t.conditions ? JSON.parse(t.conditions).roleId.$in : null : [];
|
|
451
451
|
}
|
|
452
|
-
function $e(e,
|
|
453
|
-
return e.map((
|
|
454
|
-
const
|
|
452
|
+
function $e(e, t) {
|
|
453
|
+
return e.map((s) => {
|
|
454
|
+
const o = ee(s);
|
|
455
455
|
return {
|
|
456
|
-
subject:
|
|
457
|
-
actions:
|
|
456
|
+
subject: o.subject,
|
|
457
|
+
actions: o.actions,
|
|
458
458
|
conditions: {
|
|
459
|
-
...
|
|
460
|
-
adjustment:
|
|
459
|
+
...o.conditions,
|
|
460
|
+
adjustment: o.isDiscountOperation ? { $lte: parseFloat((t / 100).toFixed(2)) } : void 0
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
});
|
|
464
464
|
}
|
|
465
465
|
function ee(e) {
|
|
466
|
-
const [
|
|
467
|
-
let
|
|
468
|
-
return
|
|
469
|
-
(
|
|
470
|
-
(typeof
|
|
471
|
-
|
|
472
|
-
].includes(
|
|
473
|
-
), !
|
|
466
|
+
const [t, s] = e.split(":");
|
|
467
|
+
let o;
|
|
468
|
+
return s ? (o = T.find(
|
|
469
|
+
(r) => r.subject === t && [
|
|
470
|
+
(typeof r.conditions == "object" ? r.conditions : JSON.parse(r.conditions)).operation,
|
|
471
|
+
r.conditions.name
|
|
472
|
+
].includes(s)
|
|
473
|
+
), !o && t === j.F_RULE_SUBJECT.enum.report && (o = {
|
|
474
474
|
label: "",
|
|
475
475
|
subject: j.F_RULE_SUBJECT.enum.report,
|
|
476
476
|
actions: ["read"],
|
|
477
|
-
conditions: { name:
|
|
477
|
+
conditions: { name: s },
|
|
478
478
|
inverted: !1,
|
|
479
479
|
reason: ""
|
|
480
|
-
})) :
|
|
480
|
+
})) : o = T.find((r) => r.subject === t), E(o || { subject: j.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
|
|
481
481
|
}
|
|
482
|
-
function ne(e,
|
|
482
|
+
function ne(e, t = []) {
|
|
483
483
|
return L(
|
|
484
|
-
e.reduce((
|
|
485
|
-
const
|
|
486
|
-
if (
|
|
487
|
-
const
|
|
488
|
-
|
|
484
|
+
e.reduce((s, o) => {
|
|
485
|
+
const r = me.find((n) => n.subject === o.subject) || t.find((n) => n.subject === o.subject);
|
|
486
|
+
if (r) {
|
|
487
|
+
const n = r.subject === J.Subject.Business.inventory_stock ? "Warehouse Management" : r.label;
|
|
488
|
+
s.push(n);
|
|
489
489
|
}
|
|
490
|
-
return
|
|
490
|
+
return s;
|
|
491
491
|
}, [])
|
|
492
492
|
);
|
|
493
493
|
}
|
|
494
494
|
function W(e) {
|
|
495
|
-
const
|
|
495
|
+
const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = (r, n, a) => {
|
|
496
496
|
var i, c;
|
|
497
|
-
const u = `${
|
|
497
|
+
const u = `${n.subject}::${JSON.stringify([...n.actions].sort())}`, l = r.get(u);
|
|
498
498
|
if (!l) {
|
|
499
|
-
|
|
499
|
+
r.set(u, { ...n, setNames: [a.name], setId: a._id });
|
|
500
500
|
return;
|
|
501
501
|
}
|
|
502
|
-
if (l.setNames.push(
|
|
503
|
-
const d = typeof l.conditions == "string" ? JSON.parse(l.conditions) : l.conditions, p = typeof
|
|
502
|
+
if (l.setNames.push(a.name), l.conditions && n.conditions) {
|
|
503
|
+
const d = typeof l.conditions == "string" ? JSON.parse(l.conditions) : l.conditions, p = typeof n.conditions == "string" ? JSON.parse(n.conditions) : n.conditions;
|
|
504
504
|
for (const m in p)
|
|
505
505
|
(i = d[m]) != null && i.$in && (c = p[m]) != null && c.$in ? d[m].$in = Array.from(/* @__PURE__ */ new Set([...d[m].$in, ...p[m].$in])) : d[m] || (d[m] = p[m]);
|
|
506
506
|
l.conditions = JSON.stringify(d);
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
|
-
for (const
|
|
510
|
-
for (const
|
|
511
|
-
|
|
512
|
-
return [...Array.from(
|
|
509
|
+
for (const r of e)
|
|
510
|
+
for (const n of r.permissions)
|
|
511
|
+
o(n.inverted ? s : t, n, r);
|
|
512
|
+
return [...Array.from(t.values()), ...Array.from(s.values())];
|
|
513
513
|
}
|
|
514
|
-
function
|
|
515
|
-
return `${e}::${[...
|
|
514
|
+
function U(e, t) {
|
|
515
|
+
return `${e}::${[...t].sort().join(",")}`;
|
|
516
516
|
}
|
|
517
|
-
function z(e,
|
|
518
|
-
const
|
|
517
|
+
function z(e, t) {
|
|
518
|
+
const s = [...e], o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
519
519
|
for (const i of e) {
|
|
520
520
|
const c = R(i.subject);
|
|
521
|
-
|
|
521
|
+
o.add(U(c, i.actions)), i.inverted && i.actions.includes("manage") && r.add(`set_${c}`), !i.inverted && i.actions.includes("manage") && n.add(c);
|
|
522
522
|
}
|
|
523
|
-
const
|
|
524
|
-
for (;
|
|
525
|
-
const i =
|
|
526
|
-
if (!u ||
|
|
527
|
-
|
|
523
|
+
const a = [...e];
|
|
524
|
+
for (; a.length > 0; ) {
|
|
525
|
+
const i = a.shift(), c = `set_${R(i.subject)}`, u = t[c];
|
|
526
|
+
if (!u || r.has(c) || !i.actions.includes("manage") || i.inverted) continue;
|
|
527
|
+
r.add(c);
|
|
528
528
|
const l = te(i);
|
|
529
529
|
i.source && !i.source.trace && (i.source = { ...i.source, trace: l });
|
|
530
530
|
const d = [...l, `${u.name} (system)`];
|
|
531
531
|
for (const p of u.permissions ?? []) {
|
|
532
|
-
const m = R(p.subject), f =
|
|
533
|
-
|
|
532
|
+
const m = R(p.subject), f = U(m, p.actions);
|
|
533
|
+
o.has(f) || n.has(m) || (o.add(f), s.push({
|
|
534
534
|
...p,
|
|
535
535
|
// FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
|
|
536
536
|
fields: p.fields ?? void 0,
|
|
@@ -543,7 +543,7 @@ function z(e, n) {
|
|
|
543
543
|
}));
|
|
544
544
|
}
|
|
545
545
|
for (const p of u.permissionSets ?? []) {
|
|
546
|
-
const m = R(p), f =
|
|
546
|
+
const m = R(p), f = U(m, ["manage"]), v = {
|
|
547
547
|
subject: m,
|
|
548
548
|
actions: ["manage"],
|
|
549
549
|
source: {
|
|
@@ -553,60 +553,60 @@ function z(e, n) {
|
|
|
553
553
|
trace: d
|
|
554
554
|
}
|
|
555
555
|
};
|
|
556
|
-
|
|
556
|
+
o.has(f) || (o.add(f), s.push(v)), a.push(v);
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
-
return [...
|
|
559
|
+
return [...s.filter((i) => !i.inverted), ...s.filter((i) => i.inverted)];
|
|
560
560
|
}
|
|
561
561
|
function te(e) {
|
|
562
562
|
if (!e.source) return [];
|
|
563
|
-
const { type:
|
|
564
|
-
if (
|
|
565
|
-
switch (
|
|
563
|
+
const { type: t, trace: s, permissionSetName: o } = e.source;
|
|
564
|
+
if (s && s.length > 0) return s;
|
|
565
|
+
switch (t) {
|
|
566
566
|
case "permissionSet":
|
|
567
|
-
return
|
|
567
|
+
return o ? [o] : [];
|
|
568
568
|
case "custom":
|
|
569
569
|
return ["custom"];
|
|
570
570
|
default:
|
|
571
571
|
return [];
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
function V(e,
|
|
575
|
-
var
|
|
576
|
-
const
|
|
577
|
-
for (const
|
|
578
|
-
if (
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
|
|
574
|
+
function V(e, t, s = /* @__PURE__ */ new Set()) {
|
|
575
|
+
var r;
|
|
576
|
+
const o = [];
|
|
577
|
+
for (const n of e) {
|
|
578
|
+
if (s.has(n)) continue;
|
|
579
|
+
s.add(n);
|
|
580
|
+
const a = t.find((i) => i.id === n);
|
|
581
|
+
a && (o.push(a), (r = a.permissionSetIds) != null && r.length && o.push(...V(a.permissionSetIds, t, s)));
|
|
582
582
|
}
|
|
583
|
-
return
|
|
583
|
+
return o;
|
|
584
584
|
}
|
|
585
585
|
function Re(e) {
|
|
586
|
-
const
|
|
587
|
-
({ setNames:
|
|
588
|
-
),
|
|
589
|
-
return B(
|
|
586
|
+
const t = W(e).map(
|
|
587
|
+
({ setNames: r, setId: n, ...a }) => a
|
|
588
|
+
), s = t.filter((r) => !r.inverted), o = t.filter((r) => r.inverted);
|
|
589
|
+
return B(s, o);
|
|
590
590
|
}
|
|
591
|
-
function Ae(e,
|
|
592
|
-
const
|
|
591
|
+
function Ae(e, t, s) {
|
|
592
|
+
const o = /* @__PURE__ */ new Map();
|
|
593
593
|
return e.forEach(
|
|
594
|
-
({ name:
|
|
594
|
+
({ name: r, permissions: n }) => n.forEach(({ conditions: a, actions: i }) => {
|
|
595
595
|
var u, l;
|
|
596
|
-
const c = JSON.parse(
|
|
597
|
-
(u = c[
|
|
598
|
-
(d) => (
|
|
599
|
-
) : i[0] === "manage" &&
|
|
600
|
-
(
|
|
596
|
+
const c = JSON.parse(a || "{}");
|
|
597
|
+
(u = c[t]) != null && u.$in ? (l = c[t]) == null || l.$in.forEach(
|
|
598
|
+
(d) => (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(r)
|
|
599
|
+
) : i[0] === "manage" && s.forEach((d) => {
|
|
600
|
+
(o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(r);
|
|
601
601
|
});
|
|
602
602
|
})
|
|
603
|
-
), [...
|
|
604
|
-
id:
|
|
605
|
-
setNames: [...
|
|
603
|
+
), [...o].map(([r, n]) => ({
|
|
604
|
+
id: r,
|
|
605
|
+
setNames: [...n]
|
|
606
606
|
}));
|
|
607
607
|
}
|
|
608
|
-
function Ie(e,
|
|
609
|
-
const
|
|
608
|
+
function Ie(e, t) {
|
|
609
|
+
const s = (i, c) => {
|
|
610
610
|
const u = { ...i }, l = JSON.parse(u.conditions || "{}");
|
|
611
611
|
if (c)
|
|
612
612
|
if (c.length > 0) {
|
|
@@ -619,29 +619,29 @@ function Ie(e, n) {
|
|
|
619
619
|
inverted: !0,
|
|
620
620
|
...u.conditions && { conditions: JSON.stringify(l) }
|
|
621
621
|
};
|
|
622
|
-
},
|
|
623
|
-
for (const i of
|
|
624
|
-
const c =
|
|
622
|
+
}, o = new Map(e.map((i) => [i.subject, i])), r = new Map(t.map((i) => [i.subject, i])), n = [], a = /* @__PURE__ */ new Set([...o.keys(), ...r.keys()]);
|
|
623
|
+
for (const i of a) {
|
|
624
|
+
const c = o.get(i), u = r.get(i);
|
|
625
625
|
if (c && u) {
|
|
626
626
|
if (c.conditions && u.conditions) {
|
|
627
627
|
const l = JSON.parse(c.conditions), d = JSON.parse(u.conditions), p = Object.keys(l)[0], m = l[p].$in.filter(
|
|
628
628
|
(v) => !d[p].$in.includes(v)
|
|
629
629
|
);
|
|
630
|
-
m.length > 0 &&
|
|
630
|
+
m.length > 0 && n.push(s(c, m)), d[p].$in.filter(
|
|
631
631
|
(v) => !l[p].$in.includes(v)
|
|
632
|
-
).length > 0 &&
|
|
632
|
+
).length > 0 && n.push(u);
|
|
633
633
|
} else if (!c.conditions && u.conditions)
|
|
634
|
-
|
|
634
|
+
n.push(u);
|
|
635
635
|
else if (!c.conditions && !u.conditions) {
|
|
636
636
|
const l = new Set(c.actions), d = new Set(u.actions), p = u.actions.some((f) => !l.has(f)), m = c.actions.filter((f) => !d.has(f));
|
|
637
637
|
if (p) {
|
|
638
638
|
const f = u.actions.filter((v) => !l.has(v));
|
|
639
|
-
|
|
639
|
+
n.push({
|
|
640
640
|
...u,
|
|
641
641
|
actions: f
|
|
642
642
|
});
|
|
643
643
|
}
|
|
644
|
-
m.length > 0 &&
|
|
644
|
+
m.length > 0 && n.push({
|
|
645
645
|
...c,
|
|
646
646
|
actions: m,
|
|
647
647
|
inverted: !0
|
|
@@ -650,8 +650,8 @@ function Ie(e, n) {
|
|
|
650
650
|
continue;
|
|
651
651
|
}
|
|
652
652
|
if (c) {
|
|
653
|
-
|
|
654
|
-
|
|
653
|
+
n.push(
|
|
654
|
+
s(
|
|
655
655
|
c,
|
|
656
656
|
// If base has conditions, set diffIds to empty array, disallow all access to collection
|
|
657
657
|
// otherwise, invert directly
|
|
@@ -660,103 +660,110 @@ function Ie(e, n) {
|
|
|
660
660
|
);
|
|
661
661
|
continue;
|
|
662
662
|
}
|
|
663
|
-
u &&
|
|
663
|
+
u && n.push(u);
|
|
664
664
|
}
|
|
665
|
-
return
|
|
665
|
+
return n;
|
|
666
666
|
}
|
|
667
667
|
function Oe(e) {
|
|
668
|
-
const
|
|
668
|
+
const t = z(
|
|
669
669
|
e,
|
|
670
670
|
F
|
|
671
|
+
), s = new Set(
|
|
672
|
+
t.filter((r) => {
|
|
673
|
+
var n;
|
|
674
|
+
return ((n = r.source) == null ? void 0 : n.type) === "systemPermissionSet" && !r.inverted;
|
|
675
|
+
}).map((r) => r.subject)
|
|
671
676
|
), o = new Set(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
677
|
+
t.filter(
|
|
678
|
+
(r) => {
|
|
679
|
+
var n;
|
|
680
|
+
return ((n = r.source) == null ? void 0 : n.type) === "systemPermissionSet" && !r.inverted && r.actions.includes("manage");
|
|
681
|
+
}
|
|
682
|
+
).map((r) => r.subject)
|
|
676
683
|
);
|
|
677
|
-
return e.filter((
|
|
684
|
+
return e.filter((r) => r.inverted ? !(s.has(r.subject) && !o.has(r.subject)) : !s.has(r.subject));
|
|
678
685
|
}
|
|
679
686
|
const se = "business::report::";
|
|
680
|
-
function _e(e,
|
|
681
|
-
const
|
|
682
|
-
const
|
|
683
|
-
return !
|
|
687
|
+
function _e(e, t) {
|
|
688
|
+
const s = [], o = e.filter((r) => {
|
|
689
|
+
const n = r.subject;
|
|
690
|
+
return !n.startsWith(se) || t.has(n) ? !0 : (s.push(n), !1);
|
|
684
691
|
});
|
|
685
|
-
return
|
|
692
|
+
return s.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", s), o;
|
|
686
693
|
}
|
|
687
694
|
const oe = "business::report::reports::", ie = "business::report::allDefaultReports", re = "business::report::allCustomReports";
|
|
688
|
-
function Ee(e,
|
|
689
|
-
const
|
|
690
|
-
(
|
|
691
|
-
),
|
|
692
|
-
(
|
|
695
|
+
function Ee(e, t) {
|
|
696
|
+
const s = e.find(
|
|
697
|
+
(a) => !a.inverted && a.subject === ie
|
|
698
|
+
), o = e.find(
|
|
699
|
+
(a) => !a.inverted && a.subject === re
|
|
693
700
|
);
|
|
694
|
-
if (!
|
|
695
|
-
const
|
|
696
|
-
return e.reduce((
|
|
701
|
+
if (!s && !o) return e;
|
|
702
|
+
const r = s ? new Set(s.actions) : null, n = o ? new Set(o.actions) : null;
|
|
703
|
+
return e.reduce((a, i) => {
|
|
697
704
|
if (i.inverted)
|
|
698
|
-
return
|
|
705
|
+
return a.push(i), a;
|
|
699
706
|
const c = i.subject;
|
|
700
707
|
if (!c.startsWith(oe))
|
|
701
|
-
return
|
|
702
|
-
const l =
|
|
708
|
+
return a.push(i), a;
|
|
709
|
+
const l = t.has(c) ? r : n;
|
|
703
710
|
if (!l)
|
|
704
|
-
return
|
|
705
|
-
if (l.has("manage")) return
|
|
711
|
+
return a.push(i), a;
|
|
712
|
+
if (l.has("manage")) return a;
|
|
706
713
|
const d = new Set(i.actions), p = d.has("manage");
|
|
707
714
|
let m = !1;
|
|
708
715
|
for (const f of l)
|
|
709
716
|
f !== "manage" && d.delete(f) && (m = !0);
|
|
710
|
-
return p && m && d.delete("manage"), d.size === 0 ||
|
|
717
|
+
return p && m && d.delete("manage"), d.size === 0 || a.push({ ...i, actions: Array.from(d) }), a;
|
|
711
718
|
}, []);
|
|
712
719
|
}
|
|
713
|
-
function B(e,
|
|
714
|
-
var
|
|
715
|
-
const
|
|
716
|
-
for (const
|
|
717
|
-
if (
|
|
718
|
-
const i =
|
|
719
|
-
if (
|
|
720
|
+
function B(e, t) {
|
|
721
|
+
var o, r;
|
|
722
|
+
const s = new Map(e.map((n) => [n.subject, n]));
|
|
723
|
+
for (const n of t) {
|
|
724
|
+
if (n.inverted) {
|
|
725
|
+
const i = s.get(n.subject);
|
|
726
|
+
if (n.conditions) {
|
|
720
727
|
if (i != null && i.conditions) {
|
|
721
|
-
const c = JSON.parse(i.conditions), u = JSON.parse(
|
|
722
|
-
m.length > 0 ?
|
|
728
|
+
const c = JSON.parse(i.conditions), u = JSON.parse(n.conditions), l = Object.keys(u)[0], d = ((o = u[l]) == null ? void 0 : o.$in) ?? [], m = (((r = c[l]) == null ? void 0 : r.$in) ?? []).filter((f) => !d.includes(f));
|
|
729
|
+
m.length > 0 ? s.set(n.subject, {
|
|
723
730
|
...i,
|
|
724
731
|
conditions: JSON.stringify({ [l]: { $in: m } })
|
|
725
|
-
}) :
|
|
732
|
+
}) : s.delete(n.subject);
|
|
726
733
|
} else
|
|
727
|
-
|
|
734
|
+
s.delete(n.subject);
|
|
728
735
|
continue;
|
|
729
736
|
}
|
|
730
737
|
if (i) {
|
|
731
|
-
const c = new Set(
|
|
732
|
-
u.length > 0 ?
|
|
738
|
+
const c = new Set(n.actions), u = i.actions.filter((l) => !c.has(l));
|
|
739
|
+
u.length > 0 ? s.set(n.subject, { ...i, actions: u }) : s.delete(n.subject);
|
|
733
740
|
continue;
|
|
734
741
|
}
|
|
735
742
|
continue;
|
|
736
743
|
}
|
|
737
|
-
if (
|
|
738
|
-
|
|
744
|
+
if (n.conditions) {
|
|
745
|
+
s.set(n.subject, n);
|
|
739
746
|
continue;
|
|
740
747
|
}
|
|
741
|
-
const
|
|
742
|
-
if (
|
|
748
|
+
const a = s.get(n.subject);
|
|
749
|
+
if (a) {
|
|
743
750
|
const i = [
|
|
744
751
|
.../* @__PURE__ */ new Set([
|
|
745
|
-
...
|
|
746
|
-
...
|
|
752
|
+
...a.actions,
|
|
753
|
+
...n.actions
|
|
747
754
|
])
|
|
748
755
|
];
|
|
749
|
-
|
|
756
|
+
s.set(n.subject, { ...a, actions: i });
|
|
750
757
|
} else
|
|
751
|
-
|
|
758
|
+
s.set(n.subject, n);
|
|
752
759
|
}
|
|
753
|
-
return Array.from(
|
|
760
|
+
return Array.from(s.values());
|
|
754
761
|
}
|
|
755
|
-
function ae(e,
|
|
756
|
-
const
|
|
757
|
-
(
|
|
762
|
+
function ae(e, t) {
|
|
763
|
+
const s = B(e, t), o = new Set(e.map((n) => n.subject)), r = t.filter(
|
|
764
|
+
(n) => n.inverted && !o.has(n.subject)
|
|
758
765
|
);
|
|
759
|
-
return [...
|
|
766
|
+
return [...s, ...r];
|
|
760
767
|
}
|
|
761
768
|
const y = "/permission-assignments", P = {
|
|
762
769
|
async readAll() {
|
|
@@ -771,48 +778,48 @@ const y = "/permission-assignments", P = {
|
|
|
771
778
|
async create(e) {
|
|
772
779
|
return b(await g().post(y, e));
|
|
773
780
|
},
|
|
774
|
-
async update(e,
|
|
775
|
-
return b(await g().put(`${y}/${e}`,
|
|
781
|
+
async update(e, t) {
|
|
782
|
+
return b(await g().put(`${y}/${e}`, t));
|
|
776
783
|
},
|
|
777
784
|
async delete(e) {
|
|
778
785
|
return b(await g().delete(`${y}/${e}`));
|
|
779
786
|
},
|
|
780
|
-
async addReportManagePermission(e,
|
|
787
|
+
async addReportManagePermission(e, t) {
|
|
781
788
|
return b(
|
|
782
|
-
await g().post("/my-permissions/report-manage", { permissionKey: e, label:
|
|
789
|
+
await g().post("/my-permissions/report-manage", { permissionKey: e, label: t })
|
|
783
790
|
);
|
|
784
791
|
}
|
|
785
792
|
}, ce = x("permissionAssignment", () => {
|
|
786
793
|
const e = h([]);
|
|
787
|
-
async function
|
|
794
|
+
async function t() {
|
|
788
795
|
const i = await P.readAll();
|
|
789
796
|
e.value = i;
|
|
790
797
|
}
|
|
791
|
-
async function
|
|
798
|
+
async function s(i) {
|
|
792
799
|
return await P.readByUserId(i);
|
|
793
800
|
}
|
|
794
|
-
async function
|
|
801
|
+
async function o(i) {
|
|
795
802
|
const c = await P.create(i);
|
|
796
803
|
e.value = [...e.value, c];
|
|
797
804
|
}
|
|
798
|
-
async function
|
|
805
|
+
async function r(i, c) {
|
|
799
806
|
const u = await P.update(i, c);
|
|
800
807
|
e.value = e.value.map((l) => l.id === i ? u : l);
|
|
801
808
|
}
|
|
802
|
-
async function
|
|
809
|
+
async function n(i) {
|
|
803
810
|
await P.delete(i), e.value = e.value.filter((c) => c.id !== i);
|
|
804
811
|
}
|
|
805
|
-
function
|
|
812
|
+
function a(i) {
|
|
806
813
|
return e.value.find((c) => c.userId === i);
|
|
807
814
|
}
|
|
808
815
|
return {
|
|
809
816
|
permissionAssignments: e,
|
|
810
|
-
readPermissionAssignments:
|
|
811
|
-
readPermissionAssignmentByUserId:
|
|
812
|
-
createPermissionAssignment:
|
|
813
|
-
updatePermissionAssignment:
|
|
814
|
-
deletePermissionAssignment:
|
|
815
|
-
getPermissionAssignmentByUserId:
|
|
817
|
+
readPermissionAssignments: t,
|
|
818
|
+
readPermissionAssignmentByUserId: s,
|
|
819
|
+
createPermissionAssignment: o,
|
|
820
|
+
updatePermissionAssignment: r,
|
|
821
|
+
deletePermissionAssignment: n,
|
|
822
|
+
getPermissionAssignmentByUserId: a
|
|
816
823
|
};
|
|
817
824
|
}), ue = () => {
|
|
818
825
|
const e = ce();
|
|
@@ -836,32 +843,32 @@ const y = "/permission-assignments", P = {
|
|
|
836
843
|
}, O = h([]), _ = h(!1), w = h(!1), $ = h(null);
|
|
837
844
|
function de() {
|
|
838
845
|
const e = q();
|
|
839
|
-
async function
|
|
840
|
-
var
|
|
841
|
-
const
|
|
842
|
-
if (
|
|
846
|
+
async function t() {
|
|
847
|
+
var r;
|
|
848
|
+
const o = (r = e.currentBusiness.value) == null ? void 0 : r.id;
|
|
849
|
+
if (o && ($.value !== o && (O.value = [], _.value = !1, w.value = !1, $.value = o), !(_.value || w.value))) {
|
|
843
850
|
w.value = !0;
|
|
844
851
|
try {
|
|
845
|
-
const
|
|
846
|
-
if ($.value !==
|
|
847
|
-
O.value =
|
|
848
|
-
} catch (
|
|
849
|
-
if ($.value !==
|
|
850
|
-
console.warn("Failed to fetch custom report permissions:",
|
|
852
|
+
const n = await le.fetchReportPermissionsForPortal(o);
|
|
853
|
+
if ($.value !== o) return;
|
|
854
|
+
O.value = n, _.value = !0;
|
|
855
|
+
} catch (n) {
|
|
856
|
+
if ($.value !== o) return;
|
|
857
|
+
console.warn("Failed to fetch custom report permissions:", n), O.value = [];
|
|
851
858
|
} finally {
|
|
852
|
-
$.value ===
|
|
859
|
+
$.value === o && (w.value = !1);
|
|
853
860
|
}
|
|
854
861
|
}
|
|
855
862
|
}
|
|
856
|
-
const
|
|
857
|
-
(
|
|
858
|
-
label:
|
|
859
|
-
subject: `business::report::reports::${
|
|
863
|
+
const s = N(() => O.value.map(
|
|
864
|
+
(o) => o.isDefault ? {
|
|
865
|
+
label: o.name,
|
|
866
|
+
subject: `business::report::reports::${o.permissionKey}`,
|
|
860
867
|
actions: [S.manage, S.read, S.create],
|
|
861
868
|
category: D.reports
|
|
862
869
|
} : {
|
|
863
|
-
label:
|
|
864
|
-
subject: `business::report::reports::${
|
|
870
|
+
label: o.name,
|
|
871
|
+
subject: `business::report::reports::${o.permissionKey}`,
|
|
865
872
|
actions: [
|
|
866
873
|
S.manage,
|
|
867
874
|
S.read,
|
|
@@ -873,25 +880,25 @@ function de() {
|
|
|
873
880
|
}
|
|
874
881
|
));
|
|
875
882
|
return {
|
|
876
|
-
fetchCustomReportPermissions:
|
|
877
|
-
customReportPermissions:
|
|
883
|
+
fetchCustomReportPermissions: t,
|
|
884
|
+
customReportPermissions: s,
|
|
878
885
|
isLoading: N(() => w.value),
|
|
879
886
|
isLoaded: N(() => _.value)
|
|
880
887
|
};
|
|
881
888
|
}
|
|
882
|
-
function
|
|
883
|
-
const
|
|
884
|
-
(
|
|
885
|
-
|
|
889
|
+
function C(e) {
|
|
890
|
+
const t = q(), s = Z(), o = ue(), r = t.restaurants, { customReportPermissions: n } = de(), a = o.getPermissionAssignmentByUserId(e.id), i = V(
|
|
891
|
+
(a == null ? void 0 : a.permissionSetIds) ?? [],
|
|
892
|
+
s.permissionSets.value
|
|
886
893
|
), c = W(i).map(
|
|
887
894
|
({ setNames: f, ...v }) => v
|
|
888
|
-
), u =
|
|
895
|
+
), u = a == null ? void 0 : a.customPermissions, l = u ?? e.permissions.map((f) => ({
|
|
889
896
|
...f,
|
|
890
897
|
subject: R(f.subject)
|
|
891
898
|
})), d = B(c, l), p = z(
|
|
892
899
|
ae(c, l),
|
|
893
900
|
F
|
|
894
|
-
).filter((f) => !f.inverted), m = Y(p) ||
|
|
901
|
+
).filter((f) => !f.inverted), m = Y(p) || r.value.map((f) => f._id);
|
|
895
902
|
return {
|
|
896
903
|
doc: e,
|
|
897
904
|
id: e.id,
|
|
@@ -902,38 +909,38 @@ function U(e) {
|
|
|
902
909
|
m.map(
|
|
903
910
|
(f) => {
|
|
904
911
|
var v;
|
|
905
|
-
return ((v =
|
|
912
|
+
return ((v = r.value.find((K) => K._id === f)) == null ? void 0 : v.profile.name) ?? "";
|
|
906
913
|
}
|
|
907
914
|
)
|
|
908
915
|
),
|
|
909
916
|
managableRestaurantIds: m,
|
|
910
|
-
permissionLabels: ne(p,
|
|
917
|
+
permissionLabels: ne(p, n.value),
|
|
911
918
|
permissions: d
|
|
912
919
|
};
|
|
913
920
|
}
|
|
914
921
|
const me = Object.freeze(
|
|
915
|
-
Object.values(
|
|
922
|
+
Object.values(H)
|
|
916
923
|
), Ne = {
|
|
917
924
|
async readTeamMembers() {
|
|
918
925
|
return b(
|
|
919
926
|
await g().get("/portal-users")
|
|
920
|
-
).map(
|
|
927
|
+
).map(C);
|
|
921
928
|
},
|
|
922
929
|
async createTeamMember(e) {
|
|
923
|
-
return
|
|
930
|
+
return C(
|
|
924
931
|
b(await g().post("/portal-users", e))
|
|
925
932
|
);
|
|
926
933
|
},
|
|
927
|
-
async updateTeamMember(e,
|
|
928
|
-
return
|
|
929
|
-
b(await g().put(`/portal-users/${e}`,
|
|
934
|
+
async updateTeamMember(e, t) {
|
|
935
|
+
return C(
|
|
936
|
+
b(await g().put(`/portal-users/${e}`, t))
|
|
930
937
|
);
|
|
931
938
|
},
|
|
932
939
|
async deleteTeamMember(e) {
|
|
933
940
|
return b(await g().delete(`/portal-users/${e}`));
|
|
934
941
|
},
|
|
935
942
|
async readTeamMemberPosUserIds() {
|
|
936
|
-
return b(await g().get("/portal-users")).map((
|
|
943
|
+
return b(await g().get("/portal-users")).map((t) => t.posUserId);
|
|
937
944
|
}
|
|
938
945
|
};
|
|
939
946
|
export {
|
|
@@ -959,7 +966,7 @@ export {
|
|
|
959
966
|
E as r,
|
|
960
967
|
Oe as s,
|
|
961
968
|
Ne as t,
|
|
962
|
-
|
|
969
|
+
Z as u,
|
|
963
970
|
ue as v,
|
|
964
971
|
ne as w,
|
|
965
972
|
W as x,
|