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