@feedmepos/mf-hrm-portal 2.3.2-dev.5 → 2.3.2-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/{ApprovalCodeList-NYJNwdDZ.js → ApprovalCodeList-Bw0E-hZl.js} +7 -7
  2. package/dist/{AuditLogList-Ghn4aBnn.js → AuditLogList-CA-_t77n.js} +5 -5
  3. package/dist/{ConditionBuilderForm.vue_vue_type_script_setup_true_lang-BxZ9t3MZ.js → ConditionBuilderForm.vue_vue_type_script_setup_true_lang-LtjNCAFN.js} +10 -10
  4. package/dist/{EmployeeList-jc8LTznV.js → EmployeeList-D_bX0EhQ.js} +8 -8
  5. package/dist/{FormSection.vue_vue_type_script_setup_true_lang-DLgm6oCz.js → FormSection.vue_vue_type_script_setup_true_lang-CyZxQa-b.js} +1 -1
  6. package/dist/{GrantUserList-BtPTpypR.js → GrantUserList-Cg7ITk_M.js} +8 -8
  7. package/dist/{Main-BizCV-_x.js → Main-BaB4vgI5.js} +11 -11
  8. package/dist/{Main-McMZU_cR.js → Main-Bl-Ocx1G.js} +5 -5
  9. package/dist/{Main-BF8hlYeV.js → Main-D5wi42fp.js} +10 -10
  10. package/dist/{MyPosProfile-BjeCnBvL.js → MyPosProfile-CUG_201f.js} +1 -1
  11. package/dist/{PermissionSetList-NWLoqFHC.js → PermissionSetList-kgG9H3DX.js} +66 -66
  12. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-y1YcZpGA.js +4207 -0
  13. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-nwpdr7T7.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-fQyCtDXM.js} +19 -19
  14. package/dist/{RoleForm.vue_vue_type_script_setup_true_lang-eT-dPsOX.js → RoleForm.vue_vue_type_script_setup_true_lang-3Q8udk43.js} +30 -30
  15. package/dist/{RoleList-CIfN10zu.js → RoleList-Cmz97HHP.js} +96 -105
  16. package/dist/{ScheduleAddPositionModal.vue_vue_type_script_setup_true_lang-CMTXC_UR.js → ScheduleAddPositionModal.vue_vue_type_script_setup_true_lang-CggEy3OI.js} +1 -1
  17. package/dist/{ScheduleGeneralPage-8vS1DUrk.js → ScheduleGeneralPage-B39k3SQH.js} +2 -2
  18. package/dist/{ScheduleModal.vue_vue_type_script_setup_true_lang-Br4AcF1g.js → ScheduleModal.vue_vue_type_script_setup_true_lang-C5j3D4eF.js} +4 -4
  19. package/dist/{SchedulePage-DqbE1PoV.js → SchedulePage-AVmRkFi1.js} +9 -9
  20. package/dist/{SchedulePositionPage-DUnkT0Tp.js → SchedulePositionPage-3rE-O8CG.js} +3 -3
  21. package/dist/{SelectFilter-voMj4_j1.js → SelectFilter-R7ry_GEg.js} +2 -3
  22. package/dist/{TeamMemberList-DoEOWNDC.js → TeamMemberList-CvDnIILn.js} +184 -184
  23. package/dist/TimesheetList-DYoglTi8.js +401 -0
  24. package/dist/TimesheetList.vue_vue_type_style_index_0_scoped_d0c6fd51_lang-DBpzyQ17.js +63 -0
  25. package/dist/{app-CDCO87ji.js → app-DKUCzcrc.js} +5444 -4624
  26. package/dist/app.js +1 -1
  27. package/dist/{approval-code-CLE9s5dL.js → approval-code-nsETgIry.js} +1 -1
  28. package/dist/{dayjs.min-BW6-XAUB.js → dayjs.min-CtULWW1N.js} +1 -1
  29. package/dist/{employee-BaCU-FLC.js → employee-DlsSqR3i.js} +5 -5
  30. package/dist/{grant-user-DMtilLJx.js → grant-user-Dpa_Rl6j.js} +1 -1
  31. package/dist/{iteration-CPLGGFBb.js → iteration-DpHBtiyr.js} +1 -1
  32. package/dist/{lodash-snXoiw60.js → lodash-YaHCUo_F.js} +1 -1
  33. package/dist/member-grant-CEokFI3_.js +54 -0
  34. package/dist/restaurant-CDFKqEFm.js +52 -0
  35. package/dist/role-DyBVVlEA.js +97 -0
  36. package/dist/rule-xErZqYmH.js +842 -0
  37. package/dist/src/api/timesheet/index.d.ts +1 -1
  38. package/dist/src/helpers/permission-set.d.ts +1 -102
  39. package/dist/src/helpers/rule.d.ts +2 -2
  40. package/dist/src/stores/restaurant.d.ts +61 -1
  41. package/dist/src/stores/timesheet.d.ts +6 -6
  42. package/dist/src/views/audit-log/locales/index.d.ts +12 -0
  43. package/dist/style.css +1 -1
  44. package/dist/tsconfig.app.tsbuildinfo +1 -1
  45. package/dist/{useAppStore-pKAGQL6q.js → useAppStore-BqsvPsPB.js} +1 -1
  46. package/dist/{useLoading-D67DIqfk.js → useLoading-BS1bnZg1.js} +1 -1
  47. package/dist/{useReportPermissions-CfgnE0NY.js → useReportPermissions-DJEhkyGc.js} +5 -5
  48. package/package.json +3 -3
  49. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-UPcpeVD5.js +0 -4243
  50. package/dist/TimesheetList-BBv2SV96.js +0 -402
  51. package/dist/TimesheetList.vue_vue_type_style_index_0_scoped_63294af2_lang-h-bWBmpI.js +0 -58
  52. package/dist/member-grant-CJyOr-q0.js +0 -55
  53. package/dist/restaurant-BMlLIUqe.js +0 -51
  54. package/dist/role-DqcBOWHL.js +0 -93
  55. package/dist/rule-B5YNhGJ4.js +0 -788
@@ -1,788 +0,0 @@
1
- import { s as W, c as q, e as y } from "./iteration-CPLGGFBb.js";
2
- import { g, b as v, y as O, n as z, m as _, z as F, v as x, C as S, O as ee, D as B } from "./app-CDCO87ji.js";
3
- import { s as se } from "./utils-BZkjJbju.js";
4
- import { defineStore as V, storeToRefs as K } from "pinia";
5
- import { ref as h, computed as J } from "vue";
6
- import { useCoreStore as X } from "@feedmepos/mf-common";
7
- import { u as te } from "./restaurant-BMlLIUqe.js";
8
- const E = "/permission-sets", N = {
9
- async read() {
10
- return g(await v().get(E));
11
- },
12
- async create(e) {
13
- return g(await v().post(E, e));
14
- },
15
- async update(e, s) {
16
- return g(await v().put(`${E}/${e}`, s));
17
- },
18
- async delete(e) {
19
- return g(await v().delete(`${E}/${e}`));
20
- }
21
- }, ne = V("permissionSet", () => {
22
- const { currentBusiness: e } = X(), s = h([]), r = h(!1), n = h(null);
23
- async function i() {
24
- var l;
25
- const c = ((l = e.value) == null ? void 0 : l._id) ?? null;
26
- if (n.value !== c)
27
- try {
28
- r.value = !0;
29
- const d = await N.read();
30
- s.value = u(d), n.value = c;
31
- } finally {
32
- r.value = !1;
33
- }
34
- }
35
- async function t(c) {
36
- const l = await N.create(c);
37
- s.value = u([...s.value, l]);
38
- }
39
- async function a(c, l) {
40
- const d = await N.update(c, l);
41
- s.value = u(s.value.map((m) => m.id === c ? d : m));
42
- }
43
- async function o(c) {
44
- await N.delete(c), s.value = u(s.value.filter((l) => l.id !== c));
45
- }
46
- function u(c) {
47
- return c.sort((l, d) => l.name.localeCompare(d.name));
48
- }
49
- return {
50
- permissionSets: s,
51
- isLoading: r,
52
- readPermissionSets: i,
53
- createPermissionSet: t,
54
- updatePermissionSet: a,
55
- deletePermissionSet: o
56
- };
57
- }), re = () => {
58
- const e = ne();
59
- return {
60
- ...e,
61
- ...K(e)
62
- };
63
- };
64
- function D(e) {
65
- if (e) {
66
- if (typeof e == "string") {
67
- if (e === "{}") return;
68
- try {
69
- return JSON.parse(e);
70
- } catch {
71
- return;
72
- }
73
- }
74
- if (typeof e == "object")
75
- return Object.keys(e).length > 0 ? e : void 0;
76
- }
77
- }
78
- function j(e) {
79
- return e ? Object.values(e).every(
80
- (s) => s !== null && typeof s == "object" && !Array.isArray(s) && Object.keys(s).length === 1 && Array.isArray(s.$in)
81
- ) : !0;
82
- }
83
- function Q(e) {
84
- const s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = (i, t, a) => {
85
- var o, u;
86
- const c = D(t.conditions);
87
- let l = `${t.subject}::${JSON.stringify([...t.actions].sort())}`;
88
- j(c) || (l += `::${JSON.stringify(c)}`);
89
- const d = i.get(l);
90
- if (!d) {
91
- i.set(l, { ...t, setNames: [a.name], setId: a._id });
92
- return;
93
- }
94
- d.setNames.push(a.name);
95
- const m = D(d.conditions);
96
- if (!m || !c) {
97
- d.conditions = void 0;
98
- return;
99
- }
100
- for (const f in c)
101
- (o = m[f]) != null && o.$in && (u = c[f]) != null && u.$in ? m[f].$in = Array.from(
102
- /* @__PURE__ */ new Set([...m[f].$in, ...c[f].$in])
103
- ) : m[f] || (m[f] = c[f]);
104
- d.conditions = JSON.stringify(m);
105
- };
106
- for (const i of e)
107
- for (const t of i.permissions)
108
- n(t.inverted ? r : s, t, i);
109
- return [...Array.from(s.values()), ...Array.from(r.values())];
110
- }
111
- function T(e, s) {
112
- return `${e}::${[...s].sort().join(",")}`;
113
- }
114
- function G(e, s) {
115
- const r = [...e], n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
116
- for (const o of e) {
117
- const u = O(o.subject);
118
- n.add(T(u, o.actions)), o.inverted && o.actions.includes("manage") && i.add(`set_${u}`), !o.inverted && o.actions.includes("manage") && t.add(u);
119
- }
120
- const a = [...e];
121
- for (; a.length > 0; ) {
122
- const o = a.shift(), u = `set_${O(o.subject)}`, c = s[u];
123
- if (!c || i.has(u) || !o.actions.includes("manage") || o.inverted) continue;
124
- i.add(u);
125
- const l = ie(o);
126
- o.source && !o.source.trace && (o.source = { ...o.source, trace: l });
127
- const d = [...l, `${c.name} (system)`];
128
- for (const m of c.permissions ?? []) {
129
- const f = O(m.subject), p = T(f, m.actions);
130
- n.has(p) || t.has(f) || (n.add(p), r.push({
131
- ...m,
132
- // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
133
- fields: m.fields ?? void 0,
134
- source: {
135
- type: "systemPermissionSet",
136
- permissionSetId: c.key,
137
- permissionSetName: c.name,
138
- trace: d
139
- }
140
- }));
141
- }
142
- for (const m of c.permissionSets ?? []) {
143
- const f = O(m), p = T(f, ["manage"]), b = {
144
- subject: f,
145
- actions: ["manage"],
146
- source: {
147
- type: "systemPermissionSet",
148
- permissionSetId: c.key,
149
- permissionSetName: c.name,
150
- trace: d
151
- }
152
- };
153
- n.has(p) || (n.add(p), r.push(b)), a.push(b);
154
- }
155
- }
156
- return [...r.filter((o) => !o.inverted), ...r.filter((o) => o.inverted)];
157
- }
158
- function ie(e) {
159
- if (!e.source) return [];
160
- const { type: s, trace: r, permissionSetName: n } = e.source;
161
- if (r && r.length > 0) return r;
162
- switch (s) {
163
- case "permissionSet":
164
- return n ? [n] : [];
165
- case "custom":
166
- return ["custom"];
167
- default:
168
- return [];
169
- }
170
- }
171
- function H(e, s, r = /* @__PURE__ */ new Set()) {
172
- var i;
173
- const n = [];
174
- for (const t of e) {
175
- if (r.has(t)) continue;
176
- r.add(t);
177
- const a = s.find((o) => o.id === t);
178
- a && (n.push(a), (i = a.permissionSetIds) != null && i.length && n.push(...H(a.permissionSetIds, s, r)));
179
- }
180
- return n;
181
- }
182
- function Ae(e) {
183
- const s = Q(e).map(
184
- ({ setNames: i, setId: t, ...a }) => a
185
- ), r = s.filter((i) => !i.inverted), n = s.filter((i) => i.inverted);
186
- return L(r, n);
187
- }
188
- function Oe(e, s, r) {
189
- const n = /* @__PURE__ */ new Map();
190
- return e.forEach(
191
- ({ name: i, permissions: t }) => t.forEach(({ conditions: a, actions: o }) => {
192
- var c, l;
193
- const u = JSON.parse(a || "{}");
194
- (c = u[s]) != null && c.$in ? (l = u[s]) == null || l.$in.forEach(
195
- (d) => (n.get(d) ?? n.set(d, /* @__PURE__ */ new Set()).get(d)).add(i)
196
- ) : o[0] === "manage" && r.forEach((d) => {
197
- (n.get(d) ?? n.set(d, /* @__PURE__ */ new Set()).get(d)).add(i);
198
- });
199
- })
200
- ), [...n].map(([i, t]) => ({
201
- id: i,
202
- setNames: [...t]
203
- }));
204
- }
205
- function _e(e, s) {
206
- const r = (o, u) => {
207
- const c = { ...o }, l = JSON.parse(c.conditions || "{}");
208
- if (u)
209
- if (u.length > 0) {
210
- const d = Object.keys(l)[0];
211
- l[d].$in = u;
212
- } else
213
- delete c.conditions;
214
- return {
215
- ...c,
216
- inverted: !0,
217
- ...c.conditions && { conditions: JSON.stringify(l) }
218
- };
219
- }, n = new Map(e.map((o) => [o.subject, o])), i = new Map(s.map((o) => [o.subject, o])), t = [], a = /* @__PURE__ */ new Set([...n.keys(), ...i.keys()]);
220
- for (const o of a) {
221
- const u = n.get(o), c = i.get(o);
222
- if (u && c) {
223
- if (u.conditions && c.conditions) {
224
- const l = JSON.parse(u.conditions), d = JSON.parse(c.conditions);
225
- if (!j(l) || !j(d)) {
226
- JSON.stringify(l) !== JSON.stringify(d) && t.push(c);
227
- continue;
228
- }
229
- const m = Object.keys(l)[0], f = l[m].$in.filter(
230
- (b) => !d[m].$in.includes(b)
231
- );
232
- f.length > 0 && t.push(r(u, f)), d[m].$in.filter(
233
- (b) => !l[m].$in.includes(b)
234
- ).length > 0 && t.push(c);
235
- } else if (!u.conditions && c.conditions)
236
- t.push(c);
237
- else if (u.conditions && !c.conditions)
238
- j(JSON.parse(u.conditions)) || t.push(c);
239
- else if (!u.conditions && !c.conditions) {
240
- const l = new Set(u.actions), d = new Set(c.actions), m = c.actions.some((p) => !l.has(p)), f = u.actions.filter((p) => !d.has(p));
241
- if (m) {
242
- const p = c.actions.filter((b) => !l.has(b));
243
- t.push({
244
- ...c,
245
- actions: p
246
- });
247
- }
248
- f.length > 0 && t.push({
249
- ...u,
250
- actions: f,
251
- inverted: !0
252
- });
253
- }
254
- continue;
255
- }
256
- if (u) {
257
- t.push(
258
- r(
259
- u,
260
- // If base has conditions, set diffIds to empty array, disallow all access to collection
261
- // otherwise, invert directly
262
- u.conditions && []
263
- )
264
- );
265
- continue;
266
- }
267
- c && t.push(c);
268
- }
269
- return t;
270
- }
271
- function Ee(e) {
272
- const s = G(
273
- e,
274
- z
275
- ), r = new Set(
276
- s.filter((i) => {
277
- var t;
278
- return ((t = i.source) == null ? void 0 : t.type) === "systemPermissionSet" && !i.inverted;
279
- }).map((i) => i.subject)
280
- ), n = new Set(
281
- s.filter(
282
- (i) => {
283
- var t;
284
- return ((t = i.source) == null ? void 0 : t.type) === "systemPermissionSet" && !i.inverted && i.actions.includes("manage");
285
- }
286
- ).map((i) => i.subject)
287
- );
288
- return e.filter((i) => i.inverted ? !(r.has(i.subject) && !n.has(i.subject)) : !r.has(i.subject));
289
- }
290
- const oe = "business::report::";
291
- function Ne(e, s) {
292
- const r = [], n = e.filter((i) => {
293
- const t = i.subject;
294
- return !t.startsWith(oe) || s.has(t) ? !0 : (r.push(t), !1);
295
- });
296
- return r.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", r), n;
297
- }
298
- const ae = "business::report::reports::", ce = _.Subject.Business.report_reports_allDefaultReports, ue = _.Subject.Business.report_reports_allCustomReports;
299
- function le(e, s) {
300
- return e.conditions ? !!s.conditions && e.conditions === s.conditions : !s.conditions;
301
- }
302
- function Ue(e, s) {
303
- const r = e.find(
304
- (a) => !a.inverted && a.subject === ce
305
- ), n = e.find(
306
- (a) => !a.inverted && a.subject === ue
307
- );
308
- if (!r && !n) return e;
309
- const i = r ? new Set(r.actions) : null, t = n ? new Set(n.actions) : null;
310
- return e.reduce((a, o) => {
311
- if (o.inverted)
312
- return a.push(o), a;
313
- const u = o.subject;
314
- if (!u.startsWith(ae))
315
- return a.push(o), a;
316
- const c = s.has(u), l = c ? i : t, d = c ? r : n;
317
- if (!l || !d || !le(d, o))
318
- return a.push(o), a;
319
- if (l.has("manage")) return a;
320
- const m = o.actions;
321
- if (m.includes("manage"))
322
- return a.push(o), a;
323
- const f = new Set(m);
324
- for (const p of l)
325
- f.delete(p);
326
- return f.size === 0 || a.push({ ...o, actions: Array.from(f) }), a;
327
- }, []);
328
- }
329
- function L(e, s) {
330
- var n, i;
331
- const r = new Map(e.map((t) => [t.subject, t]));
332
- for (const t of s) {
333
- if (t.inverted) {
334
- const o = r.get(t.subject);
335
- if (t.conditions) {
336
- if (o != null && o.conditions) {
337
- const u = JSON.parse(o.conditions), c = JSON.parse(t.conditions);
338
- if (!j(u) || !j(c)) {
339
- r.delete(t.subject);
340
- continue;
341
- }
342
- const l = Object.keys(c)[0], d = ((n = c[l]) == null ? void 0 : n.$in) ?? [], f = (((i = u[l]) == null ? void 0 : i.$in) ?? []).filter((p) => !d.includes(p));
343
- f.length > 0 ? r.set(t.subject, {
344
- ...o,
345
- conditions: JSON.stringify({ [l]: { $in: f } })
346
- }) : r.delete(t.subject);
347
- } else
348
- r.delete(t.subject);
349
- continue;
350
- }
351
- if (o) {
352
- const u = new Set(t.actions), c = o.actions.filter((l) => !u.has(l));
353
- c.length > 0 ? r.set(t.subject, { ...o, actions: c }) : r.delete(t.subject);
354
- continue;
355
- }
356
- continue;
357
- }
358
- if (t.conditions) {
359
- r.set(t.subject, t);
360
- continue;
361
- }
362
- const a = r.get(t.subject);
363
- if (a != null && a.conditions && !j(JSON.parse(a.conditions))) {
364
- r.set(t.subject, t);
365
- continue;
366
- }
367
- if (a) {
368
- const o = [
369
- .../* @__PURE__ */ new Set([
370
- ...a.actions,
371
- ...t.actions
372
- ])
373
- ];
374
- r.set(t.subject, { ...a, actions: o });
375
- } else
376
- r.set(t.subject, t);
377
- }
378
- return Array.from(r.values());
379
- }
380
- function de(e, s) {
381
- const r = L(e, s), n = new Set(e.map((t) => t.subject)), i = s.filter(
382
- (t) => t.inverted && !n.has(t.subject)
383
- );
384
- return [...r, ...i];
385
- }
386
- const P = "/permission-assignments", I = {
387
- async readAll() {
388
- return g(await v().get(P));
389
- },
390
- async readByUserId(e) {
391
- return g(await v().get(`${P}/user/${e}`));
392
- },
393
- async readById(e) {
394
- return g(await v().get(`${P}/${e}`));
395
- },
396
- async create(e) {
397
- return g(await v().post(P, e));
398
- },
399
- async update(e, s) {
400
- return g(await v().put(`${P}/${e}`, s));
401
- },
402
- async delete(e) {
403
- return g(await v().delete(`${P}/${e}`));
404
- },
405
- async addReportManagePermission(e, s) {
406
- return g(
407
- await v().post("/my-permissions/report-manage", { permissionKey: e, label: s })
408
- );
409
- }
410
- }, me = V("permissionAssignment", () => {
411
- const e = h([]);
412
- async function s() {
413
- const o = await I.readAll();
414
- e.value = o;
415
- }
416
- async function r(o) {
417
- return await I.readByUserId(o);
418
- }
419
- async function n(o) {
420
- const u = await I.create(o);
421
- e.value = [...e.value, u];
422
- }
423
- async function i(o, u) {
424
- const c = await I.update(o, u);
425
- e.value = e.value.map((l) => l.id === o ? c : l);
426
- }
427
- async function t(o) {
428
- await I.delete(o), e.value = e.value.filter((u) => u.id !== o);
429
- }
430
- function a(o) {
431
- return e.value.find((u) => u.userId === o);
432
- }
433
- return {
434
- permissionAssignments: e,
435
- readPermissionAssignments: s,
436
- readPermissionAssignmentByUserId: r,
437
- createPermissionAssignment: n,
438
- updatePermissionAssignment: i,
439
- deletePermissionAssignment: t,
440
- getPermissionAssignmentByUserId: a
441
- };
442
- }), fe = () => {
443
- const e = me();
444
- return {
445
- ...e,
446
- ...K(e)
447
- };
448
- }, pe = {
449
- async fetchReportPermissions(e, s) {
450
- const r = s ? { lang: s } : {};
451
- return g(
452
- await F().get(`/report-query/hrm/${e}/reports`, { params: r })
453
- );
454
- },
455
- async fetchReportPermissionsForPortal(e, s) {
456
- const r = s ? { isSupportPos: !1, lang: s } : { isSupportPos: !1 };
457
- return g(
458
- await F().get(`/report-query/hrm/${e}/reports`, { params: r })
459
- );
460
- }
461
- }, U = h([]), C = h(!1), R = h(!1), $ = h(null), k = h(null), M = h(!1);
462
- function ge() {
463
- const e = X();
464
- async function s() {
465
- var t;
466
- const n = (t = e.currentBusiness.value) == null ? void 0 : t.id;
467
- if (!n) return;
468
- const i = localStorage.getItem("locale");
469
- if ($.value !== n && (U.value = [], C.value = !1, R.value = !1, $.value = n, M.value = !1), !(C.value && k.value === i)) {
470
- if (R.value) {
471
- M.value = !0;
472
- return;
473
- }
474
- R.value = !0;
475
- try {
476
- const a = await pe.fetchReportPermissionsForPortal(n, i);
477
- if ($.value !== n) return;
478
- U.value = a, C.value = !0, k.value = i;
479
- } catch (a) {
480
- if ($.value !== n) return;
481
- console.warn("Failed to fetch custom report permissions:", a), U.value = [];
482
- } finally {
483
- $.value === n && (R.value = !1, M.value && (M.value = !1, await s()));
484
- }
485
- }
486
- }
487
- const r = J(() => U.value.map(
488
- (n) => n.isDefault ? {
489
- label: n.name,
490
- subject: `business::report::reports::${n.permissionKey}`,
491
- actions: [S.manage, S.read, S.create],
492
- category: x.reports
493
- } : {
494
- label: n.name,
495
- subject: `business::report::reports::${n.permissionKey}`,
496
- actions: [
497
- S.manage,
498
- S.read,
499
- S.create,
500
- S.update,
501
- S.delete
502
- ],
503
- category: x.customReports
504
- }
505
- ));
506
- return {
507
- fetchCustomReportPermissions: s,
508
- customReportPermissions: r,
509
- isLoading: J(() => R.value),
510
- isLoaded: J(() => C.value)
511
- };
512
- }
513
- function A(e) {
514
- const s = re(), r = fe(), n = te().restaurants, { customReportPermissions: i } = ge(), t = r.getPermissionAssignmentByUserId(e.id), a = H(
515
- (t == null ? void 0 : t.permissionSetIds) ?? e.permissionSetIds ?? [],
516
- s.permissionSets.value
517
- ), o = Q(a).map(
518
- ({ setNames: p, ...b }) => b
519
- ), u = t == null ? void 0 : t.customPermissions, c = u ?? e.permissions.map((p) => ({
520
- ...p,
521
- subject: O(p.subject)
522
- })), l = L(o, c), d = G(
523
- de(o, c),
524
- z
525
- ).filter((p) => !p.inverted), m = Y(d), f = m ?? n.value.map((p) => p._id);
526
- return {
527
- doc: e,
528
- id: e.id,
529
- // An invite's name is the admin's, or its sign-in key when it has none.
530
- name: e.status === "invited" ? e.name || "-" : e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
531
- phoneNumber: e.phoneNumber,
532
- email: e.email,
533
- restaurants: W(
534
- f.map((p) => {
535
- var b;
536
- return ((b = n.value.find((Z) => Z._id === p)) == null ? void 0 : b.profile.name) ?? "";
537
- })
538
- ),
539
- managableRestaurantIds: m,
540
- permissionLabels: Se(d, i.value),
541
- permissions: l,
542
- status: e.status ?? "active",
543
- loginMethod: e.loginMethod ?? "feedme"
544
- };
545
- }
546
- const ve = Object.freeze(
547
- Object.values(ee)
548
- ), Ce = {
549
- async readTeamMembers() {
550
- return g(
551
- await v().get("/portal-users")
552
- ).map(A);
553
- },
554
- async readTeamMembersPage(e) {
555
- var r, n, i, t, a;
556
- const s = g(
557
- await v().get("/portal-users/paged", {
558
- params: {
559
- limit: e.limit,
560
- offset: e.offset,
561
- search: e.search,
562
- restaurantIds: (r = e.restaurantIds) != null && r.length ? e.restaurantIds : void 0,
563
- permissionSubjects: (n = e.permissionSubjects) != null && n.length ? e.permissionSubjects : void 0,
564
- permissionSetIds: (i = e.permissionSetIds) != null && i.length ? e.permissionSetIds : void 0,
565
- statuses: (t = e.statuses) != null && t.length ? e.statuses : void 0,
566
- loginMethods: (a = e.loginMethods) != null && a.length ? e.loginMethods : void 0
567
- }
568
- })
569
- );
570
- return {
571
- items: s.items.map(A),
572
- total: s.total
573
- };
574
- },
575
- async readTeamMember(e) {
576
- return A(
577
- g(await v().get(`/portal-users/${e}`))
578
- );
579
- },
580
- async createTeamMember(e) {
581
- return A(
582
- g(await v().post("/portal-users", e))
583
- );
584
- },
585
- async updateTeamMember(e, s) {
586
- return A(
587
- g(await v().put(`/portal-users/${e}`, s))
588
- );
589
- },
590
- async deleteTeamMember(e) {
591
- return g(await v().delete(`/portal-users/${e}`));
592
- },
593
- async readTeamMemberPosUserIds() {
594
- return g(await v().get("/portal-users")).map((s) => s.posUserId);
595
- },
596
- async generateMasterUserPasscode(e) {
597
- return `${g(
598
- await v().post("/portal-users/generate-passcode", {
599
- restaurantIds: e.restaurantIds,
600
- excludePosUserId: e.excludePosUserId
601
- })
602
- )}`;
603
- }
604
- };
605
- function Me(e, s, r) {
606
- if (e.some((a) => a.subject === "all")) return "All";
607
- const n = (r ?? B).filter(
608
- (a) => a.subject === s
609
- ), i = new Set(n.map((a) => w(a).value)), t = e.filter((a) => a.subject === s).filter((a) => i.has(w(a).value));
610
- return t.length === n.length ? "All" : t.length === 0 ? "-" : `${t.length} permission allow`;
611
- }
612
- function w(e) {
613
- const s = q(e), r = s.subject;
614
- return {
615
- ...s,
616
- get conditions() {
617
- if (typeof s.conditions != "string") return s.conditions;
618
- try {
619
- return JSON.parse(s.conditions);
620
- } catch {
621
- return;
622
- }
623
- },
624
- get isDiscountOperation() {
625
- var n;
626
- return r === y.F_RULE_SUBJECT.enum.order && ((n = this.conditions) == null ? void 0 : n.operation) === y.F_RULE_ORDER_OPERATION.enum.discount;
627
- },
628
- get isOrderOperation() {
629
- return r === y.F_RULE_SUBJECT.enum.order;
630
- },
631
- get isReportPermission() {
632
- return r === y.F_RULE_SUBJECT.enum.report;
633
- },
634
- /**
635
- * Order and report rules are only meaningful together with the condition
636
- * that names them. A rule missing it cannot be rendered or matched against
637
- * the available permission list, so callers must preserve it verbatim —
638
- * see `splitRoleFormPermissions`, which routes it to `passthrough`, not
639
- * `dropped`. Dropping it would silently revoke a grant the portal cannot
640
- * display (HRM-0027).
641
- */
642
- get isResolvable() {
643
- return this.discriminator !== void 0;
644
- },
645
- /**
646
- * The condition value that identifies this rule, if the subject needs one.
647
- * An empty condition counts as missing: `{ name: '' }` is a known corrupted
648
- * shape that used to resolve to the first hardcoded report permission on
649
- * save (HRM-0027), so it must not look resolvable here either.
650
- */
651
- get discriminator() {
652
- var n, i;
653
- return this.isOrderOperation ? ((n = this.conditions) == null ? void 0 : n.operation) || void 0 : this.isReportPermission ? ((i = this.conditions) == null ? void 0 : i.name) || void 0 : r.toString();
654
- },
655
- get formatted() {
656
- const n = this.discriminator;
657
- return n === void 0 ? r.toString() : n.endsWith("_") ? n.slice(0, n.length - 1) : n;
658
- },
659
- get label() {
660
- return s.label || se(this.formatted);
661
- },
662
- get value() {
663
- const n = this.discriminator;
664
- return this.isOrderOperation || this.isReportPermission ? n === void 0 ? r.toString() : `${r}:${n}` : r.toString();
665
- }
666
- };
667
- }
668
- function Je(e) {
669
- var n, i;
670
- const s = e.map((t) => w(t)).find((t) => t.isDiscountOperation);
671
- if (!s) return 100;
672
- const r = Number((i = (n = s.conditions) == null ? void 0 : n.adjustment) == null ? void 0 : i.$lte);
673
- return Number.isFinite(r) ? parseInt((r * 100).toFixed(0)) : 0;
674
- }
675
- function Y(e) {
676
- const s = e.find(
677
- (r) => r.subject === _.Subject.Restaurant.restaurant
678
- );
679
- return s ? s.conditions ? JSON.parse(s.conditions).restaurantId.$in : null : [];
680
- }
681
- function Te(e, s) {
682
- return s.isOwner ? { restaurantIds: null, roleIds: null } : { restaurantIds: Y(e), roleIds: be(e) };
683
- }
684
- function Be(e) {
685
- return (e == null ? void 0 : e.some((s) => s.subject === "all")) ?? !1;
686
- }
687
- function be(e) {
688
- const s = e.find((r) => r.subject === _.Subject.Business.role);
689
- return s ? s.conditions ? JSON.parse(s.conditions).roleId.$in : null : [];
690
- }
691
- function Le(e) {
692
- const s = w(e);
693
- if (!s.isReportPermission) return;
694
- const { name: r, ...n } = s.conditions ?? {};
695
- return Object.keys(n).length > 0 ? n : void 0;
696
- }
697
- function Fe(e, s, r) {
698
- return e.flatMap((n) => {
699
- const i = he(n);
700
- if (!i) return [];
701
- const t = i.isReportPermission ? r == null ? void 0 : r.get(n) : void 0;
702
- return [
703
- {
704
- subject: i.subject,
705
- actions: i.actions,
706
- conditions: {
707
- ...i.conditions,
708
- ...t ?? {},
709
- adjustment: i.isDiscountOperation ? { $lte: parseFloat((s / 100).toFixed(2)) } : void 0
710
- }
711
- }
712
- ];
713
- });
714
- }
715
- function he(e) {
716
- const s = e.indexOf(":"), r = s === -1 ? e : e.slice(0, s), n = s === -1 ? void 0 : e.slice(s + 1);
717
- if (s !== -1 && !n) return;
718
- let i;
719
- return n ? (i = B.find((t) => {
720
- if (t.subject !== r) return !1;
721
- const a = typeof t.conditions == "string" ? JSON.parse(t.conditions) : t.conditions;
722
- return [a == null ? void 0 : a.operation, a == null ? void 0 : a.name].includes(n);
723
- }), !i && r === y.F_RULE_SUBJECT.enum.report && (i = {
724
- label: "",
725
- subject: y.F_RULE_SUBJECT.enum.report,
726
- actions: ["read"],
727
- conditions: { name: n },
728
- inverted: !1,
729
- reason: ""
730
- })) : i = B.find((t) => t.subject === r), i ? w(i) : void 0;
731
- }
732
- function xe(e, s) {
733
- const r = { values: [], passthrough: [], dropped: [] };
734
- for (const n of e) {
735
- const i = n == null ? void 0 : n.actions;
736
- if (typeof (n == null ? void 0 : n.subject) != "string" || n.subject.trim().length === 0 || !Array.isArray(i) || i.length === 0 || i.some((u) => typeof u != "string" || u.trim().length === 0)) {
737
- r.dropped.push(n);
738
- continue;
739
- }
740
- const t = w(n).value, a = `${y.F_RULE_SUBJECT.enum.report}:`, o = t.startsWith(a) ? t.slice(a.length) : "";
741
- s.has(t) || o && o !== "undefined" ? r.values.push(t) : r.passthrough.push(n);
742
- }
743
- return r;
744
- }
745
- function Se(e, s = []) {
746
- return W(
747
- e.reduce((r, n) => {
748
- const i = ve.find(
749
- (t) => t.subject === n.subject && n.actions.includes("manage")
750
- ) || s.find((t) => t.subject === n.subject);
751
- if (i) {
752
- const t = i.subject === _.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
753
- r.push(t);
754
- }
755
- return r;
756
- }, [])
757
- );
758
- }
759
- export {
760
- G as N,
761
- Q as P,
762
- oe as R,
763
- ge as a,
764
- Te as b,
765
- H as c,
766
- fe as d,
767
- Fe as e,
768
- Me as f,
769
- de as g,
770
- Be as h,
771
- Je as i,
772
- Le as j,
773
- pe as k,
774
- Ne as l,
775
- Ae as m,
776
- Ue as n,
777
- Ee as o,
778
- ve as p,
779
- _e as q,
780
- w as r,
781
- xe as s,
782
- Ce as t,
783
- re as u,
784
- Se as v,
785
- Oe as w,
786
- Y as x,
787
- be as y
788
- };