@feedmepos/mf-hrm-portal 2.0.17-dev.2 → 2.0.17-dev.4

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