@feedmepos/mf-hrm-portal 2.0.15-dev → 2.0.15-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{AuditLogList-DBIsI4YF.js → AuditLogList-eyzJecZc.js} +4 -4
  2. package/dist/EmployeeList-QibdsTN-.js +736 -0
  3. package/dist/{Main-BAZAQTWi.js → Main-B_QCpWOx.js} +4 -4
  4. package/dist/{Main-D7yzD5SW.js → Main-Bjfm9a6M.js} +5 -5
  5. package/dist/{Main-B3YiMuFq.js → Main-DX1aet8y.js} +1298 -1294
  6. package/dist/{PermissionSetList-DBT9LtfT.js → PermissionSetList-fE9Zfrl6.js} +30 -30
  7. package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BfqnjeTK.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-JpCfRxA9.js} +500 -500
  8. package/dist/RoleList-ByXZemFz.js +528 -0
  9. package/dist/{TeamMemberList-BCv5Vixx.js → TeamMemberList-D-_icv19.js} +327 -324
  10. package/dist/{TimesheetList-DpMBgVtY.js → TimesheetList-DVvz6id4.js} +7 -7
  11. package/dist/{app-pvHHFjbx.js → app-DJG3HGqG.js} +220 -261
  12. package/dist/app.js +2 -2
  13. package/dist/{dayjs.min-BK_bM9xY.js → dayjs.min-CN6o-ax9.js} +1 -1
  14. package/dist/{employee-DhkixwiI.js → employee-CU-G-rAZ.js} +71 -74
  15. package/dist/{index-DK4fVbTF.js → index-ynxje0mm.js} +1 -1
  16. package/dist/{iteration-Bk3cnP07.js → iteration-C6Km_Rno.js} +1 -1
  17. package/dist/{lodash-TrOlqj07.js → lodash-DZvG4gEx.js} +1 -1
  18. package/dist/rule-X41LxaES.js +991 -0
  19. package/dist/src/helpers/rule.d.ts +1 -1
  20. package/dist/src/stores/employee.d.ts +124 -19
  21. package/dist/src/types/employee.d.ts +3 -0
  22. package/dist/src/views/hr/employee/EmployeeList.vue.d.ts +4 -0
  23. package/dist/style.css +1 -1
  24. package/dist/{timesheet-DSQeCVfL.js → timesheet-DUtxTIA4.js} +9 -9
  25. package/dist/tsconfig.app.tsbuildinfo +1 -1
  26. package/dist/useAppStore-CrUYEAtX.js +171 -0
  27. package/dist/useDiscardConfirm-BHni0LNu.js +28 -0
  28. package/dist/{useLoading-fEAOlgoV.js → useLoading-hGUqfW4U.js} +1 -1
  29. package/dist/{useReportPermissions-CkOk_2tl.js → useReportPermissions-BgTdISQy.js} +3 -3
  30. package/dist/utils-BZkjJbju.js +17 -0
  31. package/package.json +1 -1
  32. package/dist/EmployeeList-BOSxLZbY.js +0 -702
  33. package/dist/RoleList-DeE5tN-5.js +0 -519
  34. package/dist/index-Bckj5jnu.js +0 -998
  35. package/dist/useAppStore-DwfwjZpc.js +0 -168
  36. package/dist/useRestaurantMap-e9fQJiLC.js +0 -39
@@ -1,998 +0,0 @@
1
- import { g as b, b as g, d as Q, e as j, s as L, q as M } from "./iteration-Bk3cnP07.js";
2
- import { i as J, u as A, A as F, d as D, y as S, C as Z } from "./app-pvHHFjbx.js";
3
- import { defineStore as x, storeToRefs as k } from "pinia";
4
- import { ref as y, computed as N } from "vue";
5
- import { useCoreStore as W } from "@feedmepos/mf-common";
6
- const U = [
7
- {
8
- label: "",
9
- subject: "order",
10
- actions: ["update"],
11
- conditions: {
12
- operation: "discount",
13
- adjustment: {
14
- $lte: 1
15
- }
16
- },
17
- inverted: !1,
18
- reason: null
19
- },
20
- {
21
- label: "",
22
- subject: "order",
23
- actions: ["update"],
24
- conditions: { operation: "changePrice" },
25
- inverted: !1,
26
- reason: null
27
- },
28
- {
29
- label: "",
30
- subject: "order",
31
- actions: ["update"],
32
- conditions: { operation: "void" },
33
- inverted: !1,
34
- reason: null
35
- },
36
- {
37
- label: "",
38
- subject: "order",
39
- actions: ["update"],
40
- conditions: { operation: "payment" },
41
- inverted: !1,
42
- reason: null
43
- },
44
- {
45
- label: "",
46
- subject: "order",
47
- actions: ["update"],
48
- conditions: { operation: "claimDeposit" },
49
- inverted: !1,
50
- reason: null
51
- },
52
- {
53
- label: "",
54
- subject: "order",
55
- actions: ["update"],
56
- conditions: { operation: "resend" },
57
- inverted: !1,
58
- reason: null
59
- },
60
- {
61
- label: "",
62
- subject: "order",
63
- actions: ["update"],
64
- conditions: { operation: "changePaymentType" },
65
- inverted: !1,
66
- reason: null
67
- },
68
- {
69
- label: "",
70
- subject: "refund",
71
- actions: ["create"],
72
- conditions: null,
73
- inverted: !1,
74
- reason: null
75
- },
76
- {
77
- label: "",
78
- subject: "counter",
79
- actions: ["manage"],
80
- conditions: null,
81
- inverted: !1,
82
- reason: null
83
- },
84
- {
85
- label: "",
86
- subject: "mallIntegration",
87
- actions: ["manage"],
88
- conditions: null,
89
- inverted: !1,
90
- reason: null
91
- },
92
- {
93
- label: "",
94
- subject: "drawer",
95
- actions: ["manage"],
96
- conditions: null,
97
- inverted: !1,
98
- reason: null
99
- },
100
- {
101
- label: "",
102
- subject: "menu",
103
- actions: ["manage"],
104
- conditions: null,
105
- inverted: !1,
106
- reason: null
107
- },
108
- {
109
- label: "",
110
- subject: "inventory",
111
- actions: ["manage"],
112
- conditions: null,
113
- inverted: !1,
114
- reason: null
115
- },
116
- {
117
- label: "",
118
- subject: "deposit",
119
- actions: ["manage"],
120
- conditions: null,
121
- inverted: !1,
122
- reason: null
123
- },
124
- {
125
- label: "",
126
- subject: "delivery",
127
- actions: ["manage"],
128
- conditions: null,
129
- inverted: !1,
130
- reason: null
131
- },
132
- {
133
- label: "",
134
- subject: "counterRecord",
135
- actions: ["manage"],
136
- conditions: null,
137
- inverted: !1,
138
- reason: null
139
- },
140
- {
141
- label: "",
142
- subject: "restaurantSetting",
143
- actions: ["manage"],
144
- conditions: null,
145
- inverted: !1,
146
- reason: null
147
- },
148
- {
149
- label: "",
150
- subject: "display",
151
- actions: ["manage"],
152
- conditions: null,
153
- inverted: !1,
154
- reason: null
155
- },
156
- {
157
- label: "",
158
- subject: "printer",
159
- actions: ["manage"],
160
- conditions: null,
161
- inverted: !1,
162
- reason: null
163
- },
164
- {
165
- label: "",
166
- subject: "table",
167
- actions: ["manage"],
168
- conditions: null,
169
- inverted: !1,
170
- reason: null
171
- },
172
- {
173
- label: "",
174
- subject: "employee",
175
- actions: ["manage"],
176
- conditions: null,
177
- inverted: !1,
178
- reason: null
179
- },
180
- {
181
- label: "",
182
- subject: "system",
183
- actions: ["manage"],
184
- conditions: null,
185
- inverted: !1,
186
- reason: null
187
- },
188
- {
189
- label: "",
190
- subject: "tax",
191
- actions: ["manage"],
192
- conditions: null,
193
- inverted: !1,
194
- reason: null
195
- },
196
- {
197
- label: "",
198
- subject: "paymentType",
199
- actions: ["manage"],
200
- conditions: null,
201
- inverted: !1,
202
- reason: null
203
- },
204
- {
205
- label: "",
206
- subject: "faceId",
207
- actions: ["manage"],
208
- conditions: null,
209
- inverted: !1,
210
- reason: null
211
- },
212
- {
213
- label: "",
214
- subject: "report",
215
- actions: ["read"],
216
- conditions: { name: "closeup" },
217
- inverted: !1,
218
- reason: ""
219
- },
220
- {
221
- label: "",
222
- subject: "report",
223
- actions: ["read"],
224
- conditions: { name: "counter" },
225
- inverted: !1,
226
- reason: ""
227
- },
228
- {
229
- label: "",
230
- subject: "report",
231
- actions: ["read"],
232
- conditions: { name: "hourlySales" },
233
- inverted: !1,
234
- reason: ""
235
- },
236
- {
237
- label: "",
238
- subject: "report",
239
- actions: ["read"],
240
- conditions: { name: "dailySales" },
241
- inverted: !1,
242
- reason: ""
243
- },
244
- {
245
- label: "",
246
- subject: "report",
247
- actions: ["read"],
248
- conditions: { name: "productSales" },
249
- inverted: !1,
250
- reason: ""
251
- },
252
- {
253
- label: "",
254
- subject: "report",
255
- actions: ["read"],
256
- conditions: { name: "sourceProductSales" },
257
- inverted: !1,
258
- reason: ""
259
- },
260
- {
261
- label: "",
262
- subject: "report",
263
- actions: ["read"],
264
- conditions: { name: "userProductSales" },
265
- inverted: !1,
266
- reason: ""
267
- },
268
- {
269
- label: "",
270
- subject: "report",
271
- actions: ["read"],
272
- conditions: { name: "categorySales" },
273
- inverted: !1,
274
- reason: ""
275
- },
276
- {
277
- label: "",
278
- subject: "report",
279
- actions: ["read"],
280
- conditions: { name: "addonSales" },
281
- inverted: !1,
282
- reason: ""
283
- },
284
- {
285
- label: "",
286
- subject: "report",
287
- actions: ["read"],
288
- conditions: { name: "slotSales" },
289
- inverted: !1,
290
- reason: ""
291
- },
292
- {
293
- label: "",
294
- subject: "report",
295
- actions: ["read"],
296
- conditions: { name: "drawer" },
297
- inverted: !1,
298
- reason: ""
299
- },
300
- {
301
- label: "",
302
- subject: "report",
303
- actions: ["read"],
304
- conditions: { name: "discount" },
305
- inverted: !1,
306
- reason: ""
307
- },
308
- {
309
- label: "",
310
- subject: "report",
311
- actions: ["read"],
312
- conditions: { name: "refund" },
313
- inverted: !1,
314
- reason: ""
315
- },
316
- {
317
- label: "",
318
- subject: "report",
319
- actions: ["read"],
320
- conditions: { name: "void" },
321
- inverted: !1,
322
- reason: ""
323
- },
324
- {
325
- label: "",
326
- subject: "report",
327
- actions: ["read"],
328
- conditions: { name: "timesheet" },
329
- inverted: !1,
330
- reason: ""
331
- },
332
- {
333
- label: "",
334
- subject: "report",
335
- actions: ["read"],
336
- conditions: { name: "counterPayment" },
337
- inverted: !1,
338
- reason: ""
339
- }
340
- ], I = "/permission-sets", O = {
341
- async read() {
342
- return b(await g().get(I));
343
- },
344
- async create(e) {
345
- return b(await g().post(I, e));
346
- },
347
- async update(e, t) {
348
- return b(await g().put(`${I}/${e}`, t));
349
- },
350
- async delete(e) {
351
- return b(await g().delete(`${I}/${e}`));
352
- }
353
- }, G = x("permissionSet", () => {
354
- const e = y([]);
355
- async function t() {
356
- const a = await O.read();
357
- e.value = n(a);
358
- }
359
- async function s(a) {
360
- const i = await O.create(a);
361
- e.value = n([...e.value, i]);
362
- }
363
- async function o(a, i) {
364
- const c = await O.update(a, i);
365
- e.value = n(e.value.map((u) => u.id === a ? c : u));
366
- }
367
- async function r(a) {
368
- await O.delete(a), e.value = n(e.value.filter((i) => i.id !== a));
369
- }
370
- function n(a) {
371
- return a.sort((i, c) => i.name.localeCompare(c.name));
372
- }
373
- return {
374
- permissionSets: e,
375
- readPermissionSets: t,
376
- createPermissionSet: s,
377
- updatePermissionSet: o,
378
- deletePermissionSet: r
379
- };
380
- }), H = () => {
381
- const e = G();
382
- return {
383
- ...e,
384
- ...k(e)
385
- };
386
- };
387
- function Se(e) {
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
- }
391
- function je(e) {
392
- const t = Math.floor(e / 60), s = e % 60;
393
- return `${t}h ${s.toString().padStart(2, "0")}m`;
394
- }
395
- function Y(e) {
396
- const t = e.replace(/([A-Z])/g, " $1");
397
- return t.charAt(0).toUpperCase() + t.slice(1);
398
- }
399
- function he(e, t, s) {
400
- if (e.some((a) => a.subject === "all")) return "All";
401
- const o = (s ?? U).filter(
402
- (a) => a.subject === t
403
- ), r = new Set(o.map((a) => C(a).value)), n = e.filter((a) => a.subject === t).filter((a) => r.has(C(a).value));
404
- return n.length === o.length ? "All" : n.length === 0 ? "-" : `${n.length} permission allow`;
405
- }
406
- function C(e) {
407
- const t = Q(e), s = t.subject;
408
- return {
409
- ...t,
410
- get conditions() {
411
- return typeof t.conditions == "string" ? JSON.parse(t.conditions) : t.conditions;
412
- },
413
- get isDiscountOperation() {
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
- },
417
- get isOrderOperation() {
418
- return s === j.F_RULE_SUBJECT.enum.order;
419
- },
420
- get isReportPermission() {
421
- return s === j.F_RULE_SUBJECT.enum.report;
422
- },
423
- get formatted() {
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
- },
427
- get label() {
428
- return t.label || Y(this.formatted);
429
- },
430
- get value() {
431
- return this.isOrderOperation ? `${s}:${this.conditions.operation}` : this.isReportPermission ? `${s}:${this.conditions.name}` : s.toString();
432
- }
433
- };
434
- }
435
- function ye(e) {
436
- const t = e.map((s) => C(s)).find((s) => s.isDiscountOperation);
437
- return t ? parseInt((t.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
438
- }
439
- function q(e) {
440
- const t = e.find(
441
- (s) => s.subject === J.Subject.Restaurant.restaurant
442
- );
443
- return t ? t.conditions ? JSON.parse(t.conditions).restaurantId.$in : null : [];
444
- }
445
- function Pe(e) {
446
- return (e == null ? void 0 : e.some((t) => t.subject === "all")) ?? !1;
447
- }
448
- function we(e) {
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
- }
452
- function $e(e, t) {
453
- return e.map((s) => {
454
- const o = ee(s);
455
- return {
456
- subject: o.subject,
457
- actions: o.actions,
458
- conditions: {
459
- ...o.conditions,
460
- adjustment: o.isDiscountOperation ? { $lte: parseFloat((t / 100).toFixed(2)) } : void 0
461
- }
462
- };
463
- });
464
- }
465
- function ee(e) {
466
- const [t, s] = e.split(":");
467
- let o;
468
- return s ? (o = U.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
- label: "",
475
- subject: j.F_RULE_SUBJECT.enum.report,
476
- actions: ["read"],
477
- conditions: { name: s },
478
- inverted: !1,
479
- reason: ""
480
- })) : o = U.find((r) => r.subject === t), C(o || { subject: j.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
481
- }
482
- function te(e, t = []) {
483
- return L(
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
- }
490
- return s;
491
- }, [])
492
- );
493
- }
494
- function z(e) {
495
- const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = (r, n, a) => {
496
- var i, c;
497
- const u = `${n.subject}::${JSON.stringify([...n.actions].sort())}`, l = r.get(u);
498
- if (!l) {
499
- r.set(u, { ...n, setNames: [a.name], setId: a._id });
500
- return;
501
- }
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
- for (const m in p)
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
- l.conditions = JSON.stringify(d);
507
- }
508
- };
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
- }
514
- function T(e, t) {
515
- return `${e}::${[...t].sort().join(",")}`;
516
- }
517
- function V(e, t) {
518
- const s = [...e], o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
519
- for (const i of e) {
520
- const c = A(i.subject);
521
- o.add(T(c, i.actions)), i.inverted && i.actions.includes("manage") && r.add(`set_${c}`), !i.inverted && i.actions.includes("manage") && n.add(c);
522
- }
523
- const a = [...e];
524
- for (; a.length > 0; ) {
525
- const i = a.shift(), c = `set_${A(i.subject)}`, u = t[c];
526
- if (!u || r.has(c) || !i.actions.includes("manage") || i.inverted) continue;
527
- r.add(c);
528
- const l = ne(i);
529
- i.source && !i.source.trace && (i.source = { ...i.source, trace: l });
530
- const d = [...l, `${u.name} (system)`];
531
- for (const p of u.permissions ?? []) {
532
- const m = A(p.subject), f = T(m, p.actions);
533
- o.has(f) || n.has(m) || (o.add(f), s.push({
534
- ...p,
535
- // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
536
- fields: p.fields ?? void 0,
537
- source: {
538
- type: "systemPermissionSet",
539
- permissionSetId: u.key,
540
- permissionSetName: u.name,
541
- trace: d
542
- }
543
- }));
544
- }
545
- for (const p of u.permissionSets ?? []) {
546
- const m = A(p), f = T(m, ["manage"]), v = {
547
- subject: m,
548
- actions: ["manage"],
549
- source: {
550
- type: "systemPermissionSet",
551
- permissionSetId: u.key,
552
- permissionSetName: u.name,
553
- trace: d
554
- }
555
- };
556
- o.has(f) || (o.add(f), s.push(v)), a.push(v);
557
- }
558
- }
559
- return [...s.filter((i) => !i.inverted), ...s.filter((i) => i.inverted)];
560
- }
561
- function ne(e) {
562
- if (!e.source) return [];
563
- const { type: t, trace: s, permissionSetName: o } = e.source;
564
- if (s && s.length > 0) return s;
565
- switch (t) {
566
- case "permissionSet":
567
- return o ? [o] : [];
568
- case "custom":
569
- return ["custom"];
570
- default:
571
- return [];
572
- }
573
- }
574
- function K(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(...K(a.permissionSetIds, t, s)));
582
- }
583
- return o;
584
- }
585
- function Re(e) {
586
- const t = z(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
- }
591
- function Ae(e, t, s) {
592
- const o = /* @__PURE__ */ new Map();
593
- return e.forEach(
594
- ({ name: r, permissions: n }) => n.forEach(({ conditions: a, actions: i }) => {
595
- var u, l;
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
- });
602
- })
603
- ), [...o].map(([r, n]) => ({
604
- id: r,
605
- setNames: [...n]
606
- }));
607
- }
608
- function Ie(e, t) {
609
- const s = (i, c) => {
610
- const u = { ...i }, l = JSON.parse(u.conditions || "{}");
611
- if (c)
612
- if (c.length > 0) {
613
- const d = Object.keys(l)[0];
614
- l[d].$in = c;
615
- } else
616
- delete u.conditions;
617
- return {
618
- ...u,
619
- inverted: !0,
620
- ...u.conditions && { conditions: JSON.stringify(l) }
621
- };
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
- if (c && u) {
626
- if (c.conditions && u.conditions) {
627
- const l = JSON.parse(c.conditions), d = JSON.parse(u.conditions), p = Object.keys(l)[0], m = l[p].$in.filter(
628
- (v) => !d[p].$in.includes(v)
629
- );
630
- m.length > 0 && n.push(s(c, m)), d[p].$in.filter(
631
- (v) => !l[p].$in.includes(v)
632
- ).length > 0 && n.push(u);
633
- } else if (!c.conditions && u.conditions)
634
- n.push(u);
635
- else if (!c.conditions && !u.conditions) {
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
- if (p) {
638
- const f = u.actions.filter((v) => !l.has(v));
639
- n.push({
640
- ...u,
641
- actions: f
642
- });
643
- }
644
- m.length > 0 && n.push({
645
- ...c,
646
- actions: m,
647
- inverted: !0
648
- });
649
- }
650
- continue;
651
- }
652
- if (c) {
653
- n.push(
654
- s(
655
- c,
656
- // If base has conditions, set diffIds to empty array, disallow all access to collection
657
- // otherwise, invert directly
658
- c.conditions && []
659
- )
660
- );
661
- continue;
662
- }
663
- u && n.push(u);
664
- }
665
- return n;
666
- }
667
- function Oe(e) {
668
- const t = V(
669
- e,
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)
676
- ), o = new Set(
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)
683
- );
684
- return e.filter((r) => r.inverted ? !(s.has(r.subject) && !o.has(r.subject)) : !s.has(r.subject));
685
- }
686
- const se = "business::report::";
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);
691
- });
692
- return s.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", s), o;
693
- }
694
- const oe = "business::report::reports::", ie = "business::report::allDefaultReports", re = "business::report::allCustomReports";
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
700
- );
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) => {
704
- if (i.inverted)
705
- return a.push(i), a;
706
- const c = i.subject;
707
- if (!c.startsWith(oe))
708
- return a.push(i), a;
709
- const l = t.has(c) ? r : n;
710
- if (!l)
711
- return a.push(i), a;
712
- if (l.has("manage")) return a;
713
- const d = new Set(i.actions), p = d.has("manage");
714
- let m = !1;
715
- for (const f of l)
716
- f !== "manage" && d.delete(f) && (m = !0);
717
- return p && m && d.delete("manage"), d.size === 0 || a.push({ ...i, actions: Array.from(d) }), a;
718
- }, []);
719
- }
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) {
727
- if (i != null && i.conditions) {
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, {
730
- ...i,
731
- conditions: JSON.stringify({ [l]: { $in: m } })
732
- }) : s.delete(n.subject);
733
- } else
734
- s.delete(n.subject);
735
- continue;
736
- }
737
- if (i) {
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);
740
- continue;
741
- }
742
- continue;
743
- }
744
- if (n.conditions) {
745
- s.set(n.subject, n);
746
- continue;
747
- }
748
- const a = s.get(n.subject);
749
- if (a) {
750
- const i = [
751
- .../* @__PURE__ */ new Set([
752
- ...a.actions,
753
- ...n.actions
754
- ])
755
- ];
756
- s.set(n.subject, { ...a, actions: i });
757
- } else
758
- s.set(n.subject, n);
759
- }
760
- return Array.from(s.values());
761
- }
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)
765
- );
766
- return [...s, ...r];
767
- }
768
- const h = "/permission-assignments", P = {
769
- async readAll() {
770
- return b(await g().get(h));
771
- },
772
- async readByUserId(e) {
773
- return b(await g().get(`${h}/user/${e}`));
774
- },
775
- async readById(e) {
776
- return b(await g().get(`${h}/${e}`));
777
- },
778
- async create(e) {
779
- return b(await g().post(h, e));
780
- },
781
- async update(e, t) {
782
- return b(await g().put(`${h}/${e}`, t));
783
- },
784
- async delete(e) {
785
- return b(await g().delete(`${h}/${e}`));
786
- },
787
- async addReportManagePermission(e, t) {
788
- return b(
789
- await g().post("/my-permissions/report-manage", { permissionKey: e, label: t })
790
- );
791
- }
792
- }, ce = x("permissionAssignment", () => {
793
- const e = y([]);
794
- async function t() {
795
- const i = await P.readAll();
796
- e.value = i;
797
- }
798
- async function s(i) {
799
- return await P.readByUserId(i);
800
- }
801
- async function o(i) {
802
- const c = await P.create(i);
803
- e.value = [...e.value, c];
804
- }
805
- async function r(i, c) {
806
- const u = await P.update(i, c);
807
- e.value = e.value.map((l) => l.id === i ? u : l);
808
- }
809
- async function n(i) {
810
- await P.delete(i), e.value = e.value.filter((c) => c.id !== i);
811
- }
812
- function a(i) {
813
- return e.value.find((c) => c.userId === i);
814
- }
815
- return {
816
- permissionAssignments: e,
817
- readPermissionAssignments: t,
818
- readPermissionAssignmentByUserId: s,
819
- createPermissionAssignment: o,
820
- updatePermissionAssignment: r,
821
- deletePermissionAssignment: n,
822
- getPermissionAssignmentByUserId: a
823
- };
824
- }), ue = () => {
825
- const e = ce();
826
- return {
827
- ...e,
828
- ...k(e)
829
- };
830
- }, le = {
831
- async fetchReportPermissions(e) {
832
- return b(
833
- await M().get(`/report-query/hrm/${e}/reports`)
834
- );
835
- },
836
- async fetchReportPermissionsForPortal(e) {
837
- return b(
838
- await M().get(
839
- `/report-query/hrm/${e}/reports?isSupportPos=false`
840
- )
841
- );
842
- }
843
- }, _ = y([]), E = y(!1), w = y(!1), $ = y(null);
844
- function de() {
845
- const e = W();
846
- async function t() {
847
- var r;
848
- const o = (r = e.currentBusiness.value) == null ? void 0 : r.id;
849
- if (o && ($.value !== o && (_.value = [], E.value = !1, w.value = !1, $.value = o), !(E.value || w.value))) {
850
- w.value = !0;
851
- try {
852
- const n = await le.fetchReportPermissionsForPortal(o);
853
- if ($.value !== o) return;
854
- _.value = n, E.value = !0;
855
- } catch (n) {
856
- if ($.value !== o) return;
857
- console.warn("Failed to fetch custom report permissions:", n), _.value = [];
858
- } finally {
859
- $.value === o && (w.value = !1);
860
- }
861
- }
862
- }
863
- const s = N(() => _.value.map(
864
- (o) => o.isDefault ? {
865
- label: o.name,
866
- subject: `business::report::reports::${o.permissionKey}`,
867
- actions: [S.manage, S.read, S.create],
868
- category: D.reports
869
- } : {
870
- label: o.name,
871
- subject: `business::report::reports::${o.permissionKey}`,
872
- actions: [
873
- S.manage,
874
- S.read,
875
- S.create,
876
- S.update,
877
- S.delete
878
- ],
879
- category: D.customReports
880
- }
881
- ));
882
- return {
883
- fetchCustomReportPermissions: t,
884
- customReportPermissions: s,
885
- isLoading: N(() => w.value),
886
- isLoaded: N(() => E.value)
887
- };
888
- }
889
- function R(e) {
890
- const t = W(), s = H(), o = ue(), r = t.restaurants, { customReportPermissions: n } = de(), a = o.getPermissionAssignmentByUserId(e.id), i = K(
891
- (a == null ? void 0 : a.permissionSetIds) ?? [],
892
- s.permissionSets.value
893
- ), c = z(i).map(
894
- ({ setNames: f, ...v }) => v
895
- ), u = a == null ? void 0 : a.customPermissions, l = u ?? e.permissions.map((f) => ({
896
- ...f,
897
- subject: A(f.subject)
898
- })), d = B(c, l), p = V(
899
- ae(c, l),
900
- F
901
- ).filter((f) => !f.inverted), m = q(p) || r.value.map((f) => f._id);
902
- return {
903
- doc: e,
904
- id: e.id,
905
- name: e.name || "-",
906
- phoneNumber: e.phoneNumber,
907
- email: e.email,
908
- restaurants: L(
909
- m.map(
910
- (f) => {
911
- var v;
912
- return ((v = r.value.find((X) => X._id === f)) == null ? void 0 : v.profile.name) ?? "";
913
- }
914
- )
915
- ),
916
- managableRestaurantIds: m,
917
- permissionLabels: te(p, n.value),
918
- permissions: d
919
- };
920
- }
921
- const me = Object.freeze(
922
- Object.values(Z)
923
- ), Ce = {
924
- async readTeamMembers() {
925
- return b(
926
- await g().get("/portal-users")
927
- ).map(R);
928
- },
929
- async readTeamMembersPage(e) {
930
- var s, o;
931
- const t = b(
932
- await g().get("/portal-users/paged", {
933
- params: {
934
- limit: e.limit,
935
- offset: e.offset,
936
- search: e.search,
937
- restaurantIds: (s = e.restaurantIds) != null && s.length ? e.restaurantIds : void 0,
938
- permissionSubjects: (o = e.permissionSubjects) != null && o.length ? e.permissionSubjects : void 0
939
- }
940
- })
941
- );
942
- return {
943
- items: t.items.map(R),
944
- total: t.total
945
- };
946
- },
947
- async readTeamMember(e) {
948
- return R(
949
- b(await g().get(`/portal-users/${e}`))
950
- );
951
- },
952
- async createTeamMember(e) {
953
- return R(
954
- b(await g().post("/portal-users", e))
955
- );
956
- },
957
- async updateTeamMember(e, t) {
958
- return R(
959
- b(await g().put(`/portal-users/${e}`, t))
960
- );
961
- },
962
- async deleteTeamMember(e) {
963
- return b(await g().delete(`/portal-users/${e}`));
964
- },
965
- async readTeamMemberPosUserIds() {
966
- return b(await g().get("/portal-users")).map((t) => t.posUserId);
967
- }
968
- };
969
- export {
970
- V as $,
971
- le as R,
972
- he as a,
973
- je as b,
974
- K as c,
975
- ae as d,
976
- U as e,
977
- $e as f,
978
- ye as g,
979
- Pe as h,
980
- Se as i,
981
- de as j,
982
- se as k,
983
- we as l,
984
- Re as m,
985
- _e as n,
986
- Ee as o,
987
- me as p,
988
- Ie as q,
989
- C as r,
990
- Oe as s,
991
- Ce as t,
992
- H as u,
993
- ue as v,
994
- te as w,
995
- z as x,
996
- Ae as y,
997
- q as z
998
- };