@feedmepos/mf-hrm-portal 2.0.25 → 2.1.0-dev

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 (55) hide show
  1. package/dist/AuditLogList-C1bGND8z.js +1037 -0
  2. package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-tiuei7CA.js +383 -0
  3. package/dist/{EmployeeList-aRGYYmxf.js → EmployeeList-DqQF9xEx.js} +78 -78
  4. package/dist/{FormItem.vue_vue_type_script_setup_true_lang-DPT2FoIc.js → FormItem.vue_vue_type_script_setup_true_lang-D3MOFOUI.js} +1 -1
  5. package/dist/{Main-C6YMg19H.js → Main-BgOhmojO.js} +6 -6
  6. package/dist/{Main-CyqPnLTe.js → Main-D2Wf__wM.js} +1138 -1142
  7. package/dist/Main-DcKVuIjB.js +90 -0
  8. package/dist/PermissionSetList-CQpTa0eY.js +384 -0
  9. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CCKVpAwv.js +4030 -0
  10. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-DWeS7VXx.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-D-14ca2J.js} +1 -1
  11. package/dist/RoleList-tSC8RJHe.js +674 -0
  12. package/dist/SelectFilter-DUj7GBtT.js +251 -0
  13. package/dist/TeamMemberList-Bz-kDJ0e.js +1163 -0
  14. package/dist/{TimesheetList-DzeE73Ns.js → TimesheetList-BFVhmcRt.js} +10 -10
  15. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_91afda4e_lang-CTQs7MIl.js → TimesheetList.vue_vue_type_style_index_0_scoped_d7ed31d7_lang-CtHuL5tW.js} +2 -2
  16. package/dist/{app-Df4eEEIU.js → app-DRnSocX8.js} +5052 -2394
  17. package/dist/app.js +1 -1
  18. package/dist/{dayjs.min-DmGoh5hw.js → dayjs.min-B8xOAypU.js} +1 -1
  19. package/dist/{employee-zWTRoOkw.js → employee-UrXqUaik.js} +3 -3
  20. package/dist/{iteration-DTV3udF0.js → iteration-LEYoQKiI.js} +3 -3
  21. package/dist/{lodash-LInzVEDS.js → lodash-Bq6_eZZ0.js} +1 -1
  22. package/dist/rule-CJC6Cq6S.js +1047 -0
  23. package/dist/src/api/audit-log/index.d.ts +0 -17
  24. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  25. package/dist/src/components/form/SelectFilter.vue.d.ts +0 -3
  26. package/dist/src/composables/useBasePermission.d.ts +1 -0
  27. package/dist/src/composables/useConditionDraft.d.ts +40 -0
  28. package/dist/src/composables/useCoverConditionOverride.d.ts +61 -0
  29. package/dist/src/helpers/business-timezone.d.ts +22 -0
  30. package/dist/src/helpers/permission-set.d.ts +4 -2
  31. package/dist/src/helpers/rule.d.ts +2 -1
  32. package/dist/src/stores/team.d.ts +1 -4
  33. package/dist/src/views/audit-log/locales/index.d.ts +16 -24
  34. package/dist/src/views/hr/locales/index.d.ts +0 -4
  35. package/dist/src/views/team/components/BasePermission.vue.d.ts +13 -0
  36. package/dist/src/views/team/condition-builders/ConditionFormHost.vue.d.ts +22 -0
  37. package/dist/src/views/team/condition-builders/ConditionFormRenderer.vue.d.ts +23 -0
  38. package/dist/src/views/team/condition-builders/component-map.d.ts +4 -0
  39. package/dist/src/views/team/condition-builders/condition-form-dedupe.d.ts +23 -0
  40. package/dist/src/views/team/locales/index.d.ts +68 -4
  41. package/dist/style.css +1 -1
  42. package/dist/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/{useAppStore-BlQSL2ZO.js → useAppStore-BGsfYWAR.js} +1 -1
  44. package/dist/{useLoading-NkUvAr71.js → useLoading-BUM5R2qV.js} +1 -1
  45. package/dist/{useReportPermissions-R-eg1L2r.js → useReportPermissions-nlQ_BBL2.js} +3 -3
  46. package/package.json +2 -2
  47. package/dist/AuditLogList-BWwgm5wH.js +0 -1145
  48. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +0 -58
  49. package/dist/Main-DQg87aB2.js +0 -94
  50. package/dist/PermissionSetList-BfKgFFUh.js +0 -356
  51. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CNEAlTnY.js +0 -3457
  52. package/dist/RoleList-CtcVwAPE.js +0 -566
  53. package/dist/SelectFilter-ATOm0hdn.js +0 -269
  54. package/dist/TeamMemberList-DU1jYeql.js +0 -1130
  55. package/dist/rule-O-E9JWJz.js +0 -995
@@ -1,995 +0,0 @@
1
- import { g as b, b as v, q as L, u as H, s as k, d as Y, e as h } from "./iteration-DTV3udF0.js";
2
- import { e as R, P as x, b as F, l as j, k as Z, d as J } from "./app-Df4eEEIU.js";
3
- import { s as q } from "./utils-BZkjJbju.js";
4
- import { defineStore as W, storeToRefs as V } from "pinia";
5
- import { ref as S, computed as C } from "vue";
6
- import { useCoreStore as z } from "@feedmepos/mf-common";
7
- const B = [
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 v().get(A));
344
- },
345
- async create(e) {
346
- return b(await v().post(A, e));
347
- },
348
- async update(e, s) {
349
- return b(await v().put(`${A}/${e}`, s));
350
- },
351
- async delete(e) {
352
- return b(await v().delete(`${A}/${e}`));
353
- }
354
- }, ee = W("permissionSet", () => {
355
- const { currentBusiness: e } = z(), s = S([]), t = S(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
- s.value = r(u), t.value = a;
362
- }
363
- async function i(a) {
364
- const u = await O.create(a);
365
- s.value = r([...s.value, u]);
366
- }
367
- async function n(a, u) {
368
- const l = await O.update(a, u);
369
- s.value = r(s.value.map((d) => d.id === a ? l : d));
370
- }
371
- async function c(a) {
372
- await O.delete(a), s.value = r(s.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: s,
379
- readPermissionSets: o,
380
- createPermissionSet: i,
381
- updatePermissionSet: n,
382
- deletePermissionSet: c
383
- };
384
- }), se = () => {
385
- const e = ee();
386
- return {
387
- ...e,
388
- ...V(e)
389
- };
390
- };
391
- function K(e) {
392
- const s = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = (i, n, c) => {
393
- var r, a;
394
- const u = `${n.subject}::${JSON.stringify([...n.actions].sort())}`, l = i.get(u);
395
- if (!l) {
396
- i.set(u, { ...n, setNames: [c.name], setId: c._id });
397
- return;
398
- }
399
- if (l.setNames.push(c.name), l.conditions && n.conditions) {
400
- const d = typeof l.conditions == "string" ? JSON.parse(l.conditions) : l.conditions, p = typeof n.conditions == "string" ? JSON.parse(n.conditions) : n.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 n of i.permissions)
408
- o(n.inverted ? t : s, n, i);
409
- return [...Array.from(s.values()), ...Array.from(t.values())];
410
- }
411
- function U(e, s) {
412
- return `${e}::${[...s].sort().join(",")}`;
413
- }
414
- function X(e, s) {
415
- const t = [...e], o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
416
- for (const r of e) {
417
- const a = R(r.subject);
418
- o.add(U(a, r.actions)), r.inverted && r.actions.includes("manage") && i.add(`set_${a}`), !r.inverted && r.actions.includes("manage") && n.add(a);
419
- }
420
- const c = [...e];
421
- for (; c.length > 0; ) {
422
- const r = c.shift(), a = `set_${R(r.subject)}`, u = s[a];
423
- if (!u || i.has(a) || !r.actions.includes("manage") || r.inverted) continue;
424
- i.add(a);
425
- const l = ne(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 = R(p.subject), f = U(m, p.actions);
430
- o.has(f) || n.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 = R(p), f = U(m, ["manage"]), g = {
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(g)), c.push(g);
454
- }
455
- }
456
- return [...t.filter((r) => !r.inverted), ...t.filter((r) => r.inverted)];
457
- }
458
- function ne(e) {
459
- if (!e.source) return [];
460
- const { type: s, trace: t, permissionSetName: o } = e.source;
461
- if (t && t.length > 0) return t;
462
- switch (s) {
463
- case "permissionSet":
464
- return o ? [o] : [];
465
- case "custom":
466
- return ["custom"];
467
- default:
468
- return [];
469
- }
470
- }
471
- function Q(e, s, t = /* @__PURE__ */ new Set()) {
472
- var i;
473
- const o = [];
474
- for (const n of e) {
475
- if (t.has(n)) continue;
476
- t.add(n);
477
- const c = s.find((r) => r.id === n);
478
- c && (o.push(c), (i = c.permissionSetIds) != null && i.length && o.push(...Q(c.permissionSetIds, s, t)));
479
- }
480
- return o;
481
- }
482
- function Pe(e) {
483
- const s = K(e).map(
484
- ({ setNames: i, setId: n, ...c }) => c
485
- ), t = s.filter((i) => !i.inverted), o = s.filter((i) => i.inverted);
486
- return M(t, o);
487
- }
488
- function we(e, s, t) {
489
- const o = /* @__PURE__ */ new Map();
490
- return e.forEach(
491
- ({ name: i, permissions: n }) => n.forEach(({ conditions: c, actions: r }) => {
492
- var u, l;
493
- const a = JSON.parse(c || "{}");
494
- (u = a[s]) != null && u.$in ? (l = a[s]) == 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, n]) => ({
501
- id: i,
502
- setNames: [...n]
503
- }));
504
- }
505
- function $e(e, s) {
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(s.map((r) => [r.subject, r])), n = [], 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
- (g) => !d[p].$in.includes(g)
526
- );
527
- m.length > 0 && n.push(t(a, m)), d[p].$in.filter(
528
- (g) => !l[p].$in.includes(g)
529
- ).length > 0 && n.push(u);
530
- } else if (!a.conditions && u.conditions)
531
- n.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((g) => !l.has(g));
536
- n.push({
537
- ...u,
538
- actions: f
539
- });
540
- }
541
- m.length > 0 && n.push({
542
- ...a,
543
- actions: m,
544
- inverted: !0
545
- });
546
- }
547
- continue;
548
- }
549
- if (a) {
550
- n.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 && n.push(u);
561
- }
562
- return n;
563
- }
564
- function Ie(e) {
565
- const s = X(
566
- e,
567
- x
568
- ), t = new Set(
569
- s.filter((i) => {
570
- var n;
571
- return ((n = i.source) == null ? void 0 : n.type) === "systemPermissionSet" && !i.inverted;
572
- }).map((i) => i.subject)
573
- ), o = new Set(
574
- s.filter(
575
- (i) => {
576
- var n;
577
- return ((n = i.source) == null ? void 0 : n.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 te = "business::report::";
584
- function Re(e, s) {
585
- const t = [], o = e.filter((i) => {
586
- const n = i.subject;
587
- return !n.startsWith(te) || s.has(n) ? !0 : (t.push(n), !1);
588
- });
589
- return t.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", t), o;
590
- }
591
- const oe = "business::report::reports::", ie = "business::report::allDefaultReports", re = "business::report::allCustomReports";
592
- function Ae(e, s) {
593
- const t = e.find(
594
- (c) => !c.inverted && c.subject === ie
595
- ), o = e.find(
596
- (c) => !c.inverted && c.subject === re
597
- );
598
- if (!t && !o) return e;
599
- const i = t ? new Set(t.actions) : null, n = 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(oe))
605
- return c.push(r), c;
606
- const l = s.has(a) ? i : n;
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, s) {
618
- var o, i;
619
- const t = new Map(e.map((n) => [n.subject, n]));
620
- for (const n of s) {
621
- if (n.inverted) {
622
- const r = t.get(n.subject);
623
- if (n.conditions) {
624
- if (r != null && r.conditions) {
625
- const a = JSON.parse(r.conditions), u = JSON.parse(n.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(n.subject, {
627
- ...r,
628
- conditions: JSON.stringify({ [l]: { $in: m } })
629
- }) : t.delete(n.subject);
630
- } else
631
- t.delete(n.subject);
632
- continue;
633
- }
634
- if (r) {
635
- const a = new Set(n.actions), u = r.actions.filter((l) => !a.has(l));
636
- u.length > 0 ? t.set(n.subject, { ...r, actions: u }) : t.delete(n.subject);
637
- continue;
638
- }
639
- continue;
640
- }
641
- if (n.conditions) {
642
- t.set(n.subject, n);
643
- continue;
644
- }
645
- const c = t.get(n.subject);
646
- if (c) {
647
- const r = [
648
- .../* @__PURE__ */ new Set([
649
- ...c.actions,
650
- ...n.actions
651
- ])
652
- ];
653
- t.set(n.subject, { ...c, actions: r });
654
- } else
655
- t.set(n.subject, n);
656
- }
657
- return Array.from(t.values());
658
- }
659
- function ae(e, s) {
660
- const t = M(e, s), o = new Set(e.map((n) => n.subject)), i = s.filter(
661
- (n) => n.inverted && !o.has(n.subject)
662
- );
663
- return [...t, ...i];
664
- }
665
- const y = "/permission-assignments", P = {
666
- async readAll() {
667
- return b(await v().get(y));
668
- },
669
- async readByUserId(e) {
670
- return b(await v().get(`${y}/user/${e}`));
671
- },
672
- async readById(e) {
673
- return b(await v().get(`${y}/${e}`));
674
- },
675
- async create(e) {
676
- return b(await v().post(y, e));
677
- },
678
- async update(e, s) {
679
- return b(await v().put(`${y}/${e}`, s));
680
- },
681
- async delete(e) {
682
- return b(await v().delete(`${y}/${e}`));
683
- },
684
- async addReportManagePermission(e, s) {
685
- return b(
686
- await v().post("/my-permissions/report-manage", { permissionKey: e, label: s })
687
- );
688
- }
689
- }, ce = W("permissionAssignment", () => {
690
- const e = S([]);
691
- async function s() {
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 n(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: s,
715
- readPermissionAssignmentByUserId: t,
716
- createPermissionAssignment: o,
717
- updatePermissionAssignment: i,
718
- deletePermissionAssignment: n,
719
- getPermissionAssignmentByUserId: c
720
- };
721
- }), ue = () => {
722
- const e = ce();
723
- return {
724
- ...e,
725
- ...V(e)
726
- };
727
- }, le = {
728
- async fetchReportPermissions(e, s) {
729
- const t = s ? { lang: s } : {};
730
- return b(
731
- await L().get(`/report-query/hrm/${e}/reports`, { params: t })
732
- );
733
- },
734
- async fetchReportPermissionsForPortal(e, s) {
735
- const t = s ? { isSupportPos: !1, lang: s } : { isSupportPos: !1 };
736
- return b(
737
- await L().get(`/report-query/hrm/${e}/reports`, { params: t })
738
- );
739
- }
740
- }, _ = S([]), E = S(!1), w = S(!1), $ = S(null), D = S(null), N = S(!1);
741
- function de() {
742
- const e = z();
743
- async function s() {
744
- var n;
745
- const o = (n = e.currentBusiness.value) == null ? void 0 : n.id;
746
- if (!o) return;
747
- const i = localStorage.getItem("locale");
748
- if ($.value !== o && (_.value = [], E.value = !1, w.value = !1, $.value = o, N.value = !1), !(E.value && D.value === i)) {
749
- if (w.value) {
750
- N.value = !0;
751
- return;
752
- }
753
- w.value = !0;
754
- try {
755
- const c = await le.fetchReportPermissionsForPortal(o, i);
756
- if ($.value !== o) return;
757
- _.value = c, E.value = !0, D.value = i;
758
- } catch (c) {
759
- if ($.value !== o) return;
760
- console.warn("Failed to fetch custom report permissions:", c), _.value = [];
761
- } finally {
762
- $.value === o && (w.value = !1, N.value && (N.value = !1, await s()));
763
- }
764
- }
765
- }
766
- const t = C(() => _.value.map(
767
- (o) => o.isDefault ? {
768
- label: o.name,
769
- subject: `business::report::reports::${o.permissionKey}`,
770
- actions: [j.manage, j.read, j.create],
771
- category: F.reports
772
- } : {
773
- label: o.name,
774
- subject: `business::report::reports::${o.permissionKey}`,
775
- actions: [
776
- j.manage,
777
- j.read,
778
- j.create,
779
- j.update,
780
- j.delete
781
- ],
782
- category: F.customReports
783
- }
784
- ));
785
- return {
786
- fetchCustomReportPermissions: s,
787
- customReportPermissions: t,
788
- isLoading: C(() => w.value),
789
- isLoaded: C(() => E.value)
790
- };
791
- }
792
- function I(e) {
793
- const s = se(), t = ue(), o = H().restaurants, { customReportPermissions: i } = de(), n = t.getPermissionAssignmentByUserId(e.id), c = Q(
794
- (n == null ? void 0 : n.permissionSetIds) ?? [],
795
- s.permissionSets.value
796
- ), r = K(c).map(
797
- ({ setNames: f, ...g }) => g
798
- ), a = n == null ? void 0 : n.customPermissions, u = a ?? e.permissions.map((f) => ({
799
- ...f,
800
- subject: R(f.subject)
801
- })), l = M(r, u), d = X(
802
- ae(r, u),
803
- x
804
- ).filter((f) => !f.inverted), p = fe(d), m = p ?? o.value.map((f) => f._id);
805
- return {
806
- doc: e,
807
- id: e.id,
808
- name: e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
809
- phoneNumber: e.phoneNumber,
810
- email: e.email,
811
- restaurants: k(
812
- m.map((f) => {
813
- var g;
814
- return ((g = o.value.find((G) => G._id === f)) == null ? void 0 : g.profile.name) ?? "";
815
- })
816
- ),
817
- managableRestaurantIds: p,
818
- permissionLabels: be(d, i.value),
819
- permissions: l
820
- };
821
- }
822
- const me = Object.freeze(
823
- Object.values(Z)
824
- ), Oe = {
825
- async readTeamMembers() {
826
- return b(
827
- await v().get("/portal-users")
828
- ).map(I);
829
- },
830
- async readTeamMembersPage(e) {
831
- var t, o, i;
832
- const s = b(
833
- await v().get("/portal-users/paged", {
834
- params: {
835
- limit: e.limit,
836
- offset: e.offset,
837
- search: e.search,
838
- restaurantIds: (t = e.restaurantIds) != null && t.length ? e.restaurantIds : void 0,
839
- permissionSubjects: (o = e.permissionSubjects) != null && o.length ? e.permissionSubjects : void 0,
840
- permissionSetIds: (i = e.permissionSetIds) != null && i.length ? e.permissionSetIds : void 0
841
- }
842
- })
843
- );
844
- return {
845
- items: s.items.map(I),
846
- total: s.total
847
- };
848
- },
849
- async readTeamMember(e) {
850
- return I(
851
- b(await v().get(`/portal-users/${e}`))
852
- );
853
- },
854
- async createTeamMember(e) {
855
- return I(
856
- b(await v().post("/portal-users", e))
857
- );
858
- },
859
- async updateTeamMember(e, s) {
860
- return I(
861
- b(await v().put(`/portal-users/${e}`, s))
862
- );
863
- },
864
- async deleteTeamMember(e) {
865
- return b(await v().delete(`/portal-users/${e}`));
866
- },
867
- async readTeamMemberPosUserIds() {
868
- return b(await v().get("/portal-users")).map((s) => s.posUserId);
869
- }
870
- };
871
- function _e(e, s, t) {
872
- if (e.some((c) => c.subject === "all")) return "All";
873
- const o = (t ?? B).filter(
874
- (c) => c.subject === s
875
- ), i = new Set(o.map((c) => T(c).value)), n = e.filter((c) => c.subject === s).filter((c) => i.has(T(c).value));
876
- return n.length === o.length ? "All" : n.length === 0 ? "-" : `${n.length} permission allow`;
877
- }
878
- function T(e) {
879
- const s = Y(e), t = s.subject;
880
- return {
881
- ...s,
882
- get conditions() {
883
- return typeof s.conditions == "string" ? JSON.parse(s.conditions) : s.conditions;
884
- },
885
- get isDiscountOperation() {
886
- var o;
887
- return t === h.F_RULE_SUBJECT.enum.order && ((o = this.conditions) == null ? void 0 : o.operation) === h.F_RULE_ORDER_OPERATION.enum.discount;
888
- },
889
- get isOrderOperation() {
890
- return t === h.F_RULE_SUBJECT.enum.order;
891
- },
892
- get isReportPermission() {
893
- return t === h.F_RULE_SUBJECT.enum.report;
894
- },
895
- get formatted() {
896
- const o = (i) => i.endsWith("_") ? i.slice(0, i.length - 1) : i;
897
- return this.isOrderOperation ? o(this.conditions.operation) : this.isReportPermission ? o(this.conditions.name) : t.toString();
898
- },
899
- get label() {
900
- return s.label || q(this.formatted);
901
- },
902
- get value() {
903
- return this.isOrderOperation ? `${t}:${this.conditions.operation}` : this.isReportPermission ? `${t}:${this.conditions.name}` : t.toString();
904
- }
905
- };
906
- }
907
- function Ee(e) {
908
- const s = e.map((t) => T(t)).find((t) => t.isDiscountOperation);
909
- return s ? parseInt((s.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
910
- }
911
- function fe(e) {
912
- const s = e.find(
913
- (t) => t.subject === J.Subject.Restaurant.restaurant
914
- );
915
- return s ? s.conditions ? JSON.parse(s.conditions).restaurantId.$in : null : [];
916
- }
917
- function Ne(e) {
918
- return (e == null ? void 0 : e.some((s) => s.subject === "all")) ?? !1;
919
- }
920
- function Te(e) {
921
- const s = e.find((t) => t.subject === J.Subject.Business.role);
922
- return s ? s.conditions ? JSON.parse(s.conditions).roleId.$in : null : [];
923
- }
924
- function Ce(e, s) {
925
- return e.map((t) => {
926
- const o = pe(t);
927
- return {
928
- subject: o.subject,
929
- actions: o.actions,
930
- conditions: {
931
- ...o.conditions,
932
- adjustment: o.isDiscountOperation ? { $lte: parseFloat((s / 100).toFixed(2)) } : void 0
933
- }
934
- };
935
- });
936
- }
937
- function pe(e) {
938
- const [s, t] = e.split(":");
939
- let o;
940
- return t ? (o = B.find(
941
- (i) => i.subject === s && [
942
- (typeof i.conditions == "object" ? i.conditions : JSON.parse(i.conditions)).operation,
943
- i.conditions.name
944
- ].includes(t)
945
- ), !o && s === h.F_RULE_SUBJECT.enum.report && (o = {
946
- label: "",
947
- subject: h.F_RULE_SUBJECT.enum.report,
948
- actions: ["read"],
949
- conditions: { name: t },
950
- inverted: !1,
951
- reason: ""
952
- })) : o = B.find((i) => i.subject === s), T(o || { subject: h.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
953
- }
954
- function be(e, s = []) {
955
- return k(
956
- e.reduce((t, o) => {
957
- const i = me.find(
958
- (n) => n.subject === o.subject && o.actions.includes("manage")
959
- ) || s.find((n) => n.subject === o.subject);
960
- if (i) {
961
- const n = i.subject === J.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
962
- t.push(n);
963
- }
964
- return t;
965
- }, [])
966
- );
967
- }
968
- export {
969
- X as $,
970
- le as R,
971
- _e as a,
972
- ae as b,
973
- Q as c,
974
- de as d,
975
- B as e,
976
- Ce as f,
977
- Ee as g,
978
- Ne as h,
979
- te as i,
980
- Te as j,
981
- fe as k,
982
- Re as l,
983
- Pe as m,
984
- Ae as n,
985
- $e as o,
986
- me as p,
987
- ue as q,
988
- T as r,
989
- Ie as s,
990
- Oe as t,
991
- se as u,
992
- be as v,
993
- K as w,
994
- we as x
995
- };