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

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