@feedmepos/mf-hrm-portal 2.1.1-dev.4 → 2.1.1-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/ApprovalCodeList-CXJyMKEg.js +757 -0
  2. package/dist/AuditLogList-CXUkbDyT.js +1145 -0
  3. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +58 -0
  4. package/dist/EmployeeList-BSfUFTcN.js +899 -0
  5. package/dist/{GrantUserList-DoyxknJZ.js → GrantUserList-DKP4MBQM.js} +137 -140
  6. package/dist/{Main-BGONIxo8.js → Main-CblWfQk_.js} +3 -3
  7. package/dist/{Main-B5BKGpLg.js → Main-CyCfz4ka.js} +1029 -1033
  8. package/dist/{Main-DQj4xtkB.js → Main-Cz1pfe2k.js} +7 -7
  9. package/dist/PermissionSetList-BwyblSeE.js +357 -0
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BJ-PZ2Nv.js +3458 -0
  11. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DVVSBIx2.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-BJp9hEfv.js} +0 -1
  12. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js +38 -0
  13. package/dist/RoleList-CXYgCmHp.js +567 -0
  14. package/dist/TeamMemberList-CnLbqaPS.js +1131 -0
  15. package/dist/{TimesheetList-DwIcsOM-.js → TimesheetList-s_bP5OGA.js} +112 -118
  16. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-B9qlQ6KG.js → TimesheetList.vue_vue_type_style_index_0_scoped_91afda4e_lang-BCLv-2Re.js} +2 -2
  17. package/dist/{app-BZwE2coe.js → app-BP0oihBR.js} +2359 -5361
  18. package/dist/app.js +1 -1
  19. package/dist/{dayjs.min-BXBPls4m.js → dayjs.min-BTSZLci9.js} +1 -1
  20. package/dist/{employee-CJTbs1f7.js → employee-BPv1j6T4.js} +3 -3
  21. package/dist/{iteration-BCbIbdHR.js → iteration-BNA1cEos.js} +1 -1
  22. package/dist/{lodash-CUIS1iIz.js → lodash-DKG9IyB-.js} +1 -1
  23. package/dist/{role-CzXchcSS.js → role-BS3LFO8u.js} +1 -1
  24. package/dist/rule-DaSLVZWm.js +996 -0
  25. package/dist/src/api/audit-log/index.d.ts +0 -6
  26. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  27. package/dist/src/components/button/ResponsiveFabButton.vue.d.ts +1 -7
  28. package/dist/src/components/table/TableEmptyState.vue.d.ts +15 -7
  29. package/dist/src/composables/useBasePermission.d.ts +1 -2
  30. package/dist/src/helpers/permission-set.d.ts +4 -8
  31. package/dist/src/helpers/rule.d.ts +1 -2
  32. package/dist/src/stores/approval-code.d.ts +6 -6
  33. package/dist/src/stores/permission-set.d.ts +3 -12
  34. package/dist/src/types/approval-code.d.ts +51 -26
  35. package/dist/src/types/audit-log.d.ts +1 -1
  36. package/dist/src/views/approval-code/ApprovalCodeList.vue.d.ts +1 -1
  37. package/dist/src/views/approval-code/locales/index.d.ts +4 -12
  38. package/dist/src/views/audit-log/locales/index.d.ts +0 -296
  39. package/dist/src/views/hr/employee/EmployeeList.vue.d.ts +0 -1
  40. package/dist/src/views/team/components/BasePermission.vue.d.ts +0 -13
  41. package/dist/src/views/team/locales/index.d.ts +0 -80
  42. package/dist/style.css +1 -1
  43. package/dist/tsconfig.app.tsbuildinfo +1 -1
  44. package/dist/useDebounce-CWb5QR9G.js +28 -0
  45. package/dist/{useReportPermissions-Q-xLwz5N.js → useReportPermissions-J3-DjopO.js} +3 -3
  46. package/package.json +2 -2
  47. package/dist/ApprovalCodeList-B0PLZwav.js +0 -758
  48. package/dist/AuditLogList-CRXwPImZ.js +0 -1611
  49. package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-zJwkM_Xb.js +0 -387
  50. package/dist/EmployeeList-DN2pnXcS.js +0 -884
  51. package/dist/PermissionSetList-4uIU9FvN.js +0 -393
  52. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-D0luaKDb.js +0 -4122
  53. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-QrqYEy8i.js +0 -42
  54. package/dist/RoleList-Bj5Y5jd_.js +0 -685
  55. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js +0 -16
  56. package/dist/TableEmptyState.vue_vue_type_script_setup_true_lang-IfAZmWr0.js +0 -37
  57. package/dist/TeamMemberList-Byjlca2Y.js +0 -1216
  58. package/dist/rule-BO6xj2Xa.js +0 -1058
  59. package/dist/src/composables/useConditionDraft.d.ts +0 -40
  60. package/dist/src/composables/useCoverConditionOverride.d.ts +0 -61
  61. package/dist/src/helpers/business-timezone.d.ts +0 -22
  62. package/dist/src/helpers/filter.d.ts +0 -15
  63. package/dist/src/helpers/permission-reconcile.d.ts +0 -15
  64. package/dist/src/helpers/permission-reconcile.test.d.ts +0 -1
  65. package/dist/src/views/audit-log/event-line.d.ts +0 -13
  66. package/dist/src/views/audit-log/snapshot-diff.d.ts +0 -11
  67. package/dist/src/views/team/condition-builders/ConditionFormHost.vue.d.ts +0 -22
  68. package/dist/src/views/team/condition-builders/ConditionFormRenderer.vue.d.ts +0 -23
  69. package/dist/src/views/team/condition-builders/component-map.d.ts +0 -4
  70. package/dist/src/views/team/condition-builders/condition-form-dedupe.d.ts +0 -23
  71. package/dist/useDebounce-B8ZPVS5C.js +0 -15
@@ -1,1058 +0,0 @@
1
- import { s as W, c as Z, e as y } from "./iteration-BCbIbdHR.js";
2
- import { h as A, P as V, d as _, v as F, n as j, b as q } from "./app-BZwE2coe.js";
3
- import { s as ee } from "./utils-BZkjJbju.js";
4
- import { g as b, b as v, q as k, u as ne } from "./restaurant-YOVMuuFY.js";
5
- import { defineStore as z, storeToRefs as K } from "pinia";
6
- import { ref as S, computed as U } from "vue";
7
- import { useCoreStore as X } from "@feedmepos/mf-common";
8
- const L = [
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
- ], E = "/permission-sets", N = {
343
- async read() {
344
- return b(await v().get(E));
345
- },
346
- async create(e) {
347
- return b(await v().post(E, e));
348
- },
349
- async update(e, n) {
350
- return b(await v().put(`${E}/${e}`, n));
351
- },
352
- async delete(e) {
353
- return b(await v().delete(`${E}/${e}`));
354
- }
355
- }, se = z("permissionSet", () => {
356
- const { currentBusiness: e } = X(), n = S([]), t = S(!1), o = S(null);
357
- async function i() {
358
- var l;
359
- const a = ((l = e.value) == null ? void 0 : l._id) ?? null;
360
- if (o.value !== a)
361
- try {
362
- t.value = !0;
363
- const d = await N.read();
364
- n.value = u(d), o.value = a;
365
- } finally {
366
- t.value = !1;
367
- }
368
- }
369
- async function s(a) {
370
- const l = await N.create(a);
371
- n.value = u([...n.value, l]);
372
- }
373
- async function c(a, l) {
374
- const d = await N.update(a, l);
375
- n.value = u(n.value.map((m) => m.id === a ? d : m));
376
- }
377
- async function r(a) {
378
- await N.delete(a), n.value = u(n.value.filter((l) => l.id !== a));
379
- }
380
- function u(a) {
381
- return a.sort((l, d) => l.name.localeCompare(d.name));
382
- }
383
- return {
384
- permissionSets: n,
385
- isLoading: t,
386
- readPermissionSets: i,
387
- createPermissionSet: s,
388
- updatePermissionSet: c,
389
- deletePermissionSet: r
390
- };
391
- }), te = () => {
392
- const e = se();
393
- return {
394
- ...e,
395
- ...K(e)
396
- };
397
- };
398
- function D(e) {
399
- if (e) {
400
- if (typeof e == "string") {
401
- if (e === "{}") return;
402
- try {
403
- return JSON.parse(e);
404
- } catch {
405
- return;
406
- }
407
- }
408
- if (typeof e == "object")
409
- return Object.keys(e).length > 0 ? e : void 0;
410
- }
411
- }
412
- function h(e) {
413
- return e ? Object.values(e).every(
414
- (n) => n !== null && typeof n == "object" && !Array.isArray(n) && Object.keys(n).length === 1 && Array.isArray(n.$in)
415
- ) : !0;
416
- }
417
- function Q(e) {
418
- const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = (i, s, c) => {
419
- var r, u;
420
- const a = D(s.conditions);
421
- let l = `${s.subject}::${JSON.stringify([...s.actions].sort())}`;
422
- h(a) || (l += `::${JSON.stringify(a)}`);
423
- const d = i.get(l);
424
- if (!d) {
425
- i.set(l, { ...s, setNames: [c.name], setId: c._id });
426
- return;
427
- }
428
- d.setNames.push(c.name);
429
- const m = D(d.conditions);
430
- if (!m || !a) {
431
- d.conditions = void 0;
432
- return;
433
- }
434
- for (const f in a)
435
- (r = m[f]) != null && r.$in && (u = a[f]) != null && u.$in ? m[f].$in = Array.from(
436
- /* @__PURE__ */ new Set([...m[f].$in, ...a[f].$in])
437
- ) : m[f] || (m[f] = a[f]);
438
- d.conditions = JSON.stringify(m);
439
- };
440
- for (const i of e)
441
- for (const s of i.permissions)
442
- o(s.inverted ? t : n, s, i);
443
- return [...Array.from(n.values()), ...Array.from(t.values())];
444
- }
445
- function B(e, n) {
446
- return `${e}::${[...n].sort().join(",")}`;
447
- }
448
- function G(e, n) {
449
- const t = [...e], o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
450
- for (const r of e) {
451
- const u = A(r.subject);
452
- o.add(B(u, r.actions)), r.inverted && r.actions.includes("manage") && i.add(`set_${u}`), !r.inverted && r.actions.includes("manage") && s.add(u);
453
- }
454
- const c = [...e];
455
- for (; c.length > 0; ) {
456
- const r = c.shift(), u = `set_${A(r.subject)}`, a = n[u];
457
- if (!a || i.has(u) || !r.actions.includes("manage") || r.inverted) continue;
458
- i.add(u);
459
- const l = oe(r);
460
- r.source && !r.source.trace && (r.source = { ...r.source, trace: l });
461
- const d = [...l, `${a.name} (system)`];
462
- for (const m of a.permissions ?? []) {
463
- const f = A(m.subject), p = B(f, m.actions);
464
- o.has(p) || s.has(f) || (o.add(p), t.push({
465
- ...m,
466
- // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
467
- fields: m.fields ?? void 0,
468
- source: {
469
- type: "systemPermissionSet",
470
- permissionSetId: a.key,
471
- permissionSetName: a.name,
472
- trace: d
473
- }
474
- }));
475
- }
476
- for (const m of a.permissionSets ?? []) {
477
- const f = A(m), p = B(f, ["manage"]), g = {
478
- subject: f,
479
- actions: ["manage"],
480
- source: {
481
- type: "systemPermissionSet",
482
- permissionSetId: a.key,
483
- permissionSetName: a.name,
484
- trace: d
485
- }
486
- };
487
- o.has(p) || (o.add(p), t.push(g)), c.push(g);
488
- }
489
- }
490
- return [...t.filter((r) => !r.inverted), ...t.filter((r) => r.inverted)];
491
- }
492
- function oe(e) {
493
- if (!e.source) return [];
494
- const { type: n, trace: t, permissionSetName: o } = e.source;
495
- if (t && t.length > 0) return t;
496
- switch (n) {
497
- case "permissionSet":
498
- return o ? [o] : [];
499
- case "custom":
500
- return ["custom"];
501
- default:
502
- return [];
503
- }
504
- }
505
- function H(e, n, t = /* @__PURE__ */ new Set()) {
506
- var i;
507
- const o = [];
508
- for (const s of e) {
509
- if (t.has(s)) continue;
510
- t.add(s);
511
- const c = n.find((r) => r.id === s);
512
- c && (o.push(c), (i = c.permissionSetIds) != null && i.length && o.push(...H(c.permissionSetIds, n, t)));
513
- }
514
- return o;
515
- }
516
- function Ie(e) {
517
- const n = Q(e).map(
518
- ({ setNames: i, setId: s, ...c }) => c
519
- ), t = n.filter((i) => !i.inverted), o = n.filter((i) => i.inverted);
520
- return M(t, o);
521
- }
522
- function Ae(e, n, t) {
523
- const o = /* @__PURE__ */ new Map();
524
- return e.forEach(
525
- ({ name: i, permissions: s }) => s.forEach(({ conditions: c, actions: r }) => {
526
- var a, l;
527
- const u = JSON.parse(c || "{}");
528
- (a = u[n]) != null && a.$in ? (l = u[n]) == null || l.$in.forEach(
529
- (d) => (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i)
530
- ) : r[0] === "manage" && t.forEach((d) => {
531
- (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i);
532
- });
533
- })
534
- ), [...o].map(([i, s]) => ({
535
- id: i,
536
- setNames: [...s]
537
- }));
538
- }
539
- function Oe(e, n) {
540
- const t = (r, u) => {
541
- const a = { ...r }, l = JSON.parse(a.conditions || "{}");
542
- if (u)
543
- if (u.length > 0) {
544
- const d = Object.keys(l)[0];
545
- l[d].$in = u;
546
- } else
547
- delete a.conditions;
548
- return {
549
- ...a,
550
- inverted: !0,
551
- ...a.conditions && { conditions: JSON.stringify(l) }
552
- };
553
- }, 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()]);
554
- for (const r of c) {
555
- const u = o.get(r), a = i.get(r);
556
- if (u && a) {
557
- if (u.conditions && a.conditions) {
558
- const l = JSON.parse(u.conditions), d = JSON.parse(a.conditions);
559
- if (!h(l) || !h(d)) {
560
- JSON.stringify(l) !== JSON.stringify(d) && s.push(a);
561
- continue;
562
- }
563
- const m = Object.keys(l)[0], f = l[m].$in.filter(
564
- (g) => !d[m].$in.includes(g)
565
- );
566
- f.length > 0 && s.push(t(u, f)), d[m].$in.filter(
567
- (g) => !l[m].$in.includes(g)
568
- ).length > 0 && s.push(a);
569
- } else if (!u.conditions && a.conditions)
570
- s.push(a);
571
- else if (u.conditions && !a.conditions)
572
- h(JSON.parse(u.conditions)) || s.push(a);
573
- else if (!u.conditions && !a.conditions) {
574
- const l = new Set(u.actions), d = new Set(a.actions), m = a.actions.some((p) => !l.has(p)), f = u.actions.filter((p) => !d.has(p));
575
- if (m) {
576
- const p = a.actions.filter((g) => !l.has(g));
577
- s.push({
578
- ...a,
579
- actions: p
580
- });
581
- }
582
- f.length > 0 && s.push({
583
- ...u,
584
- actions: f,
585
- inverted: !0
586
- });
587
- }
588
- continue;
589
- }
590
- if (u) {
591
- s.push(
592
- t(
593
- u,
594
- // If base has conditions, set diffIds to empty array, disallow all access to collection
595
- // otherwise, invert directly
596
- u.conditions && []
597
- )
598
- );
599
- continue;
600
- }
601
- a && s.push(a);
602
- }
603
- return s;
604
- }
605
- function _e(e) {
606
- const n = G(
607
- e,
608
- V
609
- ), t = new Set(
610
- n.filter((i) => {
611
- var s;
612
- return ((s = i.source) == null ? void 0 : s.type) === "systemPermissionSet" && !i.inverted;
613
- }).map((i) => i.subject)
614
- ), o = new Set(
615
- n.filter(
616
- (i) => {
617
- var s;
618
- return ((s = i.source) == null ? void 0 : s.type) === "systemPermissionSet" && !i.inverted && i.actions.includes("manage");
619
- }
620
- ).map((i) => i.subject)
621
- );
622
- return e.filter((i) => i.inverted ? !(t.has(i.subject) && !o.has(i.subject)) : !t.has(i.subject));
623
- }
624
- const ie = "business::report::";
625
- function Ee(e, n) {
626
- const t = [], o = e.filter((i) => {
627
- const s = i.subject;
628
- return !s.startsWith(ie) || n.has(s) ? !0 : (t.push(s), !1);
629
- });
630
- return t.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", t), o;
631
- }
632
- const re = "business::report::reports::", ae = _.Subject.Business.report_reports_allDefaultReports, ce = _.Subject.Business.report_reports_allCustomReports;
633
- function ue(e, n) {
634
- return e.conditions ? !!n.conditions && e.conditions === n.conditions : !n.conditions;
635
- }
636
- function Ne(e, n) {
637
- const t = e.find(
638
- (c) => !c.inverted && c.subject === ae
639
- ), o = e.find(
640
- (c) => !c.inverted && c.subject === ce
641
- );
642
- if (!t && !o) return e;
643
- const i = t ? new Set(t.actions) : null, s = o ? new Set(o.actions) : null;
644
- return e.reduce((c, r) => {
645
- if (r.inverted)
646
- return c.push(r), c;
647
- const u = r.subject;
648
- if (!u.startsWith(re))
649
- return c.push(r), c;
650
- const a = n.has(u), l = a ? i : s, d = a ? t : o;
651
- if (!l || !d || !ue(d, r))
652
- return c.push(r), c;
653
- if (l.has("manage")) return c;
654
- const m = r.actions;
655
- if (m.includes("manage"))
656
- return c.push(r), c;
657
- const f = new Set(m);
658
- for (const p of l)
659
- f.delete(p);
660
- return f.size === 0 || c.push({ ...r, actions: Array.from(f) }), c;
661
- }, []);
662
- }
663
- function M(e, n) {
664
- var o, i;
665
- const t = new Map(e.map((s) => [s.subject, s]));
666
- for (const s of n) {
667
- if (s.inverted) {
668
- const r = t.get(s.subject);
669
- if (s.conditions) {
670
- if (r != null && r.conditions) {
671
- const u = JSON.parse(r.conditions), a = JSON.parse(s.conditions);
672
- if (!h(u) || !h(a)) {
673
- t.delete(s.subject);
674
- continue;
675
- }
676
- const l = Object.keys(a)[0], d = ((o = a[l]) == null ? void 0 : o.$in) ?? [], f = (((i = u[l]) == null ? void 0 : i.$in) ?? []).filter((p) => !d.includes(p));
677
- f.length > 0 ? t.set(s.subject, {
678
- ...r,
679
- conditions: JSON.stringify({ [l]: { $in: f } })
680
- }) : t.delete(s.subject);
681
- } else
682
- t.delete(s.subject);
683
- continue;
684
- }
685
- if (r) {
686
- const u = new Set(s.actions), a = r.actions.filter((l) => !u.has(l));
687
- a.length > 0 ? t.set(s.subject, { ...r, actions: a }) : t.delete(s.subject);
688
- continue;
689
- }
690
- continue;
691
- }
692
- if (s.conditions) {
693
- t.set(s.subject, s);
694
- continue;
695
- }
696
- const c = t.get(s.subject);
697
- if (c != null && c.conditions && !h(JSON.parse(c.conditions))) {
698
- t.set(s.subject, s);
699
- continue;
700
- }
701
- if (c) {
702
- const r = [
703
- .../* @__PURE__ */ new Set([
704
- ...c.actions,
705
- ...s.actions
706
- ])
707
- ];
708
- t.set(s.subject, { ...c, actions: r });
709
- } else
710
- t.set(s.subject, s);
711
- }
712
- return Array.from(t.values());
713
- }
714
- function le(e, n) {
715
- const t = M(e, n), o = new Set(e.map((s) => s.subject)), i = n.filter(
716
- (s) => s.inverted && !o.has(s.subject)
717
- );
718
- return [...t, ...i];
719
- }
720
- const P = "/permission-assignments", w = {
721
- async readAll() {
722
- return b(await v().get(P));
723
- },
724
- async readByUserId(e) {
725
- return b(await v().get(`${P}/user/${e}`));
726
- },
727
- async readById(e) {
728
- return b(await v().get(`${P}/${e}`));
729
- },
730
- async create(e) {
731
- return b(await v().post(P, e));
732
- },
733
- async update(e, n) {
734
- return b(await v().put(`${P}/${e}`, n));
735
- },
736
- async delete(e) {
737
- return b(await v().delete(`${P}/${e}`));
738
- },
739
- async addReportManagePermission(e, n) {
740
- return b(
741
- await v().post("/my-permissions/report-manage", { permissionKey: e, label: n })
742
- );
743
- }
744
- }, de = z("permissionAssignment", () => {
745
- const e = S([]);
746
- async function n() {
747
- const r = await w.readAll();
748
- e.value = r;
749
- }
750
- async function t(r) {
751
- return await w.readByUserId(r);
752
- }
753
- async function o(r) {
754
- const u = await w.create(r);
755
- e.value = [...e.value, u];
756
- }
757
- async function i(r, u) {
758
- const a = await w.update(r, u);
759
- e.value = e.value.map((l) => l.id === r ? a : l);
760
- }
761
- async function s(r) {
762
- await w.delete(r), e.value = e.value.filter((u) => u.id !== r);
763
- }
764
- function c(r) {
765
- return e.value.find((u) => u.userId === r);
766
- }
767
- return {
768
- permissionAssignments: e,
769
- readPermissionAssignments: n,
770
- readPermissionAssignmentByUserId: t,
771
- createPermissionAssignment: o,
772
- updatePermissionAssignment: i,
773
- deletePermissionAssignment: s,
774
- getPermissionAssignmentByUserId: c
775
- };
776
- }), me = () => {
777
- const e = de();
778
- return {
779
- ...e,
780
- ...K(e)
781
- };
782
- }, fe = {
783
- async fetchReportPermissions(e, n) {
784
- const t = n ? { lang: n } : {};
785
- return b(
786
- await k().get(`/report-query/hrm/${e}/reports`, { params: t })
787
- );
788
- },
789
- async fetchReportPermissionsForPortal(e, n) {
790
- const t = n ? { isSupportPos: !1, lang: n } : { isSupportPos: !1 };
791
- return b(
792
- await k().get(`/report-query/hrm/${e}/reports`, { params: t })
793
- );
794
- }
795
- }, T = S([]), C = S(!1), R = S(!1), $ = S(null), x = S(null), J = S(!1);
796
- function pe() {
797
- const e = X();
798
- async function n() {
799
- var s;
800
- const o = (s = e.currentBusiness.value) == null ? void 0 : s.id;
801
- if (!o) return;
802
- const i = localStorage.getItem("locale");
803
- if ($.value !== o && (T.value = [], C.value = !1, R.value = !1, $.value = o, J.value = !1), !(C.value && x.value === i)) {
804
- if (R.value) {
805
- J.value = !0;
806
- return;
807
- }
808
- R.value = !0;
809
- try {
810
- const c = await fe.fetchReportPermissionsForPortal(o, i);
811
- if ($.value !== o) return;
812
- T.value = c, C.value = !0, x.value = i;
813
- } catch (c) {
814
- if ($.value !== o) return;
815
- console.warn("Failed to fetch custom report permissions:", c), T.value = [];
816
- } finally {
817
- $.value === o && (R.value = !1, J.value && (J.value = !1, await n()));
818
- }
819
- }
820
- }
821
- const t = U(() => T.value.map(
822
- (o) => o.isDefault ? {
823
- label: o.name,
824
- subject: `business::report::reports::${o.permissionKey}`,
825
- actions: [j.manage, j.read, j.create],
826
- category: F.reports
827
- } : {
828
- label: o.name,
829
- subject: `business::report::reports::${o.permissionKey}`,
830
- actions: [
831
- j.manage,
832
- j.read,
833
- j.create,
834
- j.update,
835
- j.delete
836
- ],
837
- category: F.customReports
838
- }
839
- ));
840
- return {
841
- fetchCustomReportPermissions: n,
842
- customReportPermissions: t,
843
- isLoading: U(() => R.value),
844
- isLoaded: U(() => C.value)
845
- };
846
- }
847
- function I(e) {
848
- const n = te(), t = me(), o = ne().restaurants, { customReportPermissions: i } = pe(), s = t.getPermissionAssignmentByUserId(e.id), c = H(
849
- (s == null ? void 0 : s.permissionSetIds) ?? [],
850
- n.permissionSets.value
851
- ), r = Q(c).map(
852
- ({ setNames: p, ...g }) => g
853
- ), u = s == null ? void 0 : s.customPermissions, a = u ?? e.permissions.map((p) => ({
854
- ...p,
855
- subject: A(p.subject)
856
- })), l = M(r, a), d = G(
857
- le(r, a),
858
- V
859
- ).filter((p) => !p.inverted), m = ve(d), f = m ?? o.value.map((p) => p._id);
860
- return {
861
- doc: e,
862
- id: e.id,
863
- name: e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
864
- phoneNumber: e.phoneNumber,
865
- email: e.email,
866
- restaurants: W(
867
- f.map((p) => {
868
- var g;
869
- return ((g = o.value.find((Y) => Y._id === p)) == null ? void 0 : g.profile.name) ?? "";
870
- })
871
- ),
872
- managableRestaurantIds: m,
873
- permissionLabels: Se(d, i.value),
874
- permissions: l
875
- };
876
- }
877
- const be = Object.freeze(
878
- Object.values(q)
879
- ), Te = {
880
- async readTeamMembers() {
881
- return b(
882
- await v().get("/portal-users")
883
- ).map(I);
884
- },
885
- async readTeamMembersPage(e) {
886
- var t, o, i;
887
- const n = b(
888
- await v().get("/portal-users/paged", {
889
- params: {
890
- limit: e.limit,
891
- offset: e.offset,
892
- search: e.search,
893
- restaurantIds: (t = e.restaurantIds) != null && t.length ? e.restaurantIds : void 0,
894
- permissionSubjects: (o = e.permissionSubjects) != null && o.length ? e.permissionSubjects : void 0,
895
- permissionSetIds: (i = e.permissionSetIds) != null && i.length ? e.permissionSetIds : void 0
896
- }
897
- })
898
- );
899
- return {
900
- items: n.items.map(I),
901
- total: n.total
902
- };
903
- },
904
- async readTeamMember(e) {
905
- return I(
906
- b(await v().get(`/portal-users/${e}`))
907
- );
908
- },
909
- async createTeamMember(e) {
910
- return I(
911
- b(await v().post("/portal-users", e))
912
- );
913
- },
914
- async updateTeamMember(e, n) {
915
- return I(
916
- b(await v().put(`/portal-users/${e}`, n))
917
- );
918
- },
919
- async deleteTeamMember(e) {
920
- return b(await v().delete(`/portal-users/${e}`));
921
- },
922
- async readTeamMemberPosUserIds() {
923
- return b(await v().get("/portal-users")).map((n) => n.posUserId);
924
- }
925
- };
926
- function Ce(e, n, t) {
927
- if (e.some((c) => c.subject === "all")) return "All";
928
- const o = (t ?? L).filter(
929
- (c) => c.subject === n
930
- ), i = new Set(o.map((c) => O(c).value)), s = e.filter((c) => c.subject === n).filter((c) => i.has(O(c).value));
931
- return s.length === o.length ? "All" : s.length === 0 ? "-" : `${s.length} permission allow`;
932
- }
933
- function O(e) {
934
- const n = Z(e), t = n.subject;
935
- return {
936
- ...n,
937
- get conditions() {
938
- return typeof n.conditions == "string" ? JSON.parse(n.conditions) : n.conditions;
939
- },
940
- get isDiscountOperation() {
941
- var o;
942
- return t === y.F_RULE_SUBJECT.enum.order && ((o = this.conditions) == null ? void 0 : o.operation) === y.F_RULE_ORDER_OPERATION.enum.discount;
943
- },
944
- get isOrderOperation() {
945
- return t === y.F_RULE_SUBJECT.enum.order;
946
- },
947
- get isReportPermission() {
948
- return t === y.F_RULE_SUBJECT.enum.report;
949
- },
950
- get formatted() {
951
- const o = (i) => i.endsWith("_") ? i.slice(0, i.length - 1) : i;
952
- return this.isOrderOperation ? o(this.conditions.operation) : this.isReportPermission ? o(this.conditions.name) : t.toString();
953
- },
954
- get label() {
955
- return n.label || ee(this.formatted);
956
- },
957
- get value() {
958
- return this.isOrderOperation ? `${t}:${this.conditions.operation}` : this.isReportPermission ? `${t}:${this.conditions.name}` : t.toString();
959
- }
960
- };
961
- }
962
- function Je(e) {
963
- const n = e.map((t) => O(t)).find((t) => t.isDiscountOperation);
964
- return n ? parseInt((n.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
965
- }
966
- function ve(e) {
967
- const n = e.find(
968
- (t) => t.subject === _.Subject.Restaurant.restaurant
969
- );
970
- return n ? n.conditions ? JSON.parse(n.conditions).restaurantId.$in : null : [];
971
- }
972
- function Ue(e) {
973
- return (e == null ? void 0 : e.some((n) => n.subject === "all")) ?? !1;
974
- }
975
- function Be(e) {
976
- const n = e.find((t) => t.subject === _.Subject.Business.role);
977
- return n ? n.conditions ? JSON.parse(n.conditions).roleId.$in : null : [];
978
- }
979
- function Le(e) {
980
- const n = O(e);
981
- if (!n.isReportPermission) return;
982
- const { name: t, ...o } = n.conditions ?? {};
983
- return Object.keys(o).length > 0 ? o : void 0;
984
- }
985
- function Me(e, n, t) {
986
- return e.map((o) => {
987
- const i = ge(o), s = i.isReportPermission ? t == null ? void 0 : t.get(o) : void 0;
988
- return {
989
- subject: i.subject,
990
- actions: i.actions,
991
- conditions: {
992
- ...i.conditions,
993
- ...s ?? {},
994
- adjustment: i.isDiscountOperation ? { $lte: parseFloat((n / 100).toFixed(2)) } : void 0
995
- }
996
- };
997
- });
998
- }
999
- function ge(e) {
1000
- const [n, t] = e.split(":");
1001
- let o;
1002
- return t ? (o = L.find(
1003
- (i) => i.subject === n && [
1004
- (typeof i.conditions == "object" ? i.conditions : JSON.parse(i.conditions)).operation,
1005
- i.conditions.name
1006
- ].includes(t)
1007
- ), !o && n === y.F_RULE_SUBJECT.enum.report && (o = {
1008
- label: "",
1009
- subject: y.F_RULE_SUBJECT.enum.report,
1010
- actions: ["read"],
1011
- conditions: { name: t },
1012
- inverted: !1,
1013
- reason: ""
1014
- })) : o = L.find((i) => i.subject === n), O(o || { subject: y.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
1015
- }
1016
- function Se(e, n = []) {
1017
- return W(
1018
- e.reduce((t, o) => {
1019
- const i = be.find(
1020
- (s) => s.subject === o.subject && o.actions.includes("manage")
1021
- ) || n.find((s) => s.subject === o.subject);
1022
- if (i) {
1023
- const s = i.subject === _.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
1024
- t.push(s);
1025
- }
1026
- return t;
1027
- }, [])
1028
- );
1029
- }
1030
- export {
1031
- G as N,
1032
- Q as P,
1033
- fe as R,
1034
- Le as a,
1035
- Ce as b,
1036
- H as c,
1037
- le as d,
1038
- L as e,
1039
- Me as f,
1040
- Je as g,
1041
- Ue as h,
1042
- pe as i,
1043
- ie as j,
1044
- Be as k,
1045
- ve as l,
1046
- Ie as m,
1047
- Oe as n,
1048
- Ee as o,
1049
- be as p,
1050
- Ne as q,
1051
- O as r,
1052
- _e as s,
1053
- Te as t,
1054
- te as u,
1055
- me as v,
1056
- Se as w,
1057
- Ae as x
1058
- };