@feedmepos/mf-hrm-portal 2.2.2-dev.4 → 2.2.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.
- package/dist/{ApprovalCodeList-Dn8R6jgC.js → ApprovalCodeList-BnG3T_Lk.js} +5 -5
- package/dist/{AuditLogList-BdWELtlp.js → AuditLogList-CpK9-YkB.js} +759 -705
- package/dist/{ConditionBuilderForm.vue_vue_type_script_setup_true_lang-DbUdX_Qk.js → ConditionBuilderForm.vue_vue_type_script_setup_true_lang-CzKzq19d.js} +2 -2
- package/dist/{EmployeeList-Br4a6imR.js → EmployeeList-CUsRanu7.js} +6 -6
- package/dist/{GrantUserList-YpLuH3il.js → GrantUserList-BJoj3ZcO.js} +6 -6
- package/dist/{Main-eBobrTdz.js → Main-5QLhf80L.js} +8 -8
- package/dist/{Main-DPoPfzcK.js → Main-BEUu3Hba.js} +5 -5
- package/dist/{Main-DWv0oSH4.js → Main-FPpK9B70.js} +11 -11
- package/dist/{PermissionSetList-ttA1JLVy.js → PermissionSetList-DZGZ0Pm_.js} +7 -7
- package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-DQa3GK8B.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BHEW1_dv.js} +945 -945
- package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-XHuHin8t.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-Z-DH7ouY.js} +1 -1
- package/dist/{RoleList-B790AV-j.js → RoleList-D5yToard.js} +43 -43
- package/dist/{TeamMemberList-B-vgWJw4.js → TeamMemberList-C4-AHxO4.js} +9 -9
- package/dist/{TimesheetList-C05Wl5Gw.js → TimesheetList-DMo8KXoU.js} +7 -7
- package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-CDxi-Gdu.js → TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-2KHu-f8U.js} +3 -3
- package/dist/{app-DzZ_hyHn.js → app-DlSD8S9A.js} +2625 -2217
- package/dist/app.js +1 -1
- package/dist/{approval-code-jIjkeVEb.js → approval-code-BRClD2HN.js} +1 -1
- package/dist/{dayjs.min-B-hCRyX9.js → dayjs.min-DcI2auGP.js} +1 -1
- package/dist/{employee-C2s088Kk.js → employee-C_cvCoHM.js} +4 -4
- package/dist/{grant-user-SNiDV22U.js → grant-user-Dhi3ilC_.js} +1 -1
- package/dist/{iteration-C2OwvCva.js → iteration-DSzPQ0fZ.js} +1 -1
- package/dist/{lodash-BQEjwNx9.js → lodash-Ce0IJ8Y3.js} +1 -1
- package/dist/{restaurant-BTpBmfBV.js → restaurant-DiYb0pCm.js} +2 -2
- package/dist/{role-Z9s80hOy.js → role-DkTkfUgR.js} +2 -2
- package/dist/rule-B-REsmVM.js +771 -0
- package/dist/src/views/audit-log/export-lines.d.ts +8 -0
- package/dist/src/views/audit-log/locales/index.d.ts +68 -12
- package/dist/style.css +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{useAppStore-DCwd8GWN.js → useAppStore-BGhlB1_1.js} +1 -1
- package/dist/{useLoading-CXzTpIVv.js → useLoading-CvgqVDbF.js} +1 -1
- package/dist/{useReportPermissions-VnFzkyAH.js → useReportPermissions-VCzAQXKz.js} +5 -5
- package/package.json +2 -2
- package/dist/rule-DpoKkvLa.js +0 -1121
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
import { s as W, c as Z, e as y } from "./iteration-DSzPQ0fZ.js";
|
|
2
|
+
import { h as O, d as V, e as _, b as F, n as h, O as q, D as L } from "./app-DlSD8S9A.js";
|
|
3
|
+
import { s as ee } from "./utils-BZkjJbju.js";
|
|
4
|
+
import { g, b, q as D, u as te } from "./restaurant-DiYb0pCm.js";
|
|
5
|
+
import { defineStore as z, storeToRefs as K } from "pinia";
|
|
6
|
+
import { ref as S, computed as T } from "vue";
|
|
7
|
+
import { useCoreStore as X } from "@feedmepos/mf-common";
|
|
8
|
+
const E = "/permission-sets", N = {
|
|
9
|
+
async read() {
|
|
10
|
+
return g(await b().get(E));
|
|
11
|
+
},
|
|
12
|
+
async create(e) {
|
|
13
|
+
return g(await b().post(E, e));
|
|
14
|
+
},
|
|
15
|
+
async update(e, t) {
|
|
16
|
+
return g(await b().put(`${E}/${e}`, t));
|
|
17
|
+
},
|
|
18
|
+
async delete(e) {
|
|
19
|
+
return g(await b().delete(`${E}/${e}`));
|
|
20
|
+
}
|
|
21
|
+
}, se = z("permissionSet", () => {
|
|
22
|
+
const { currentBusiness: e } = X(), t = S([]), r = S(!1), n = S(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
|
+
t.value = u(d), n.value = c;
|
|
31
|
+
} finally {
|
|
32
|
+
r.value = !1;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function s(c) {
|
|
36
|
+
const l = await N.create(c);
|
|
37
|
+
t.value = u([...t.value, l]);
|
|
38
|
+
}
|
|
39
|
+
async function a(c, l) {
|
|
40
|
+
const d = await N.update(c, l);
|
|
41
|
+
t.value = u(t.value.map((m) => m.id === c ? d : m));
|
|
42
|
+
}
|
|
43
|
+
async function o(c) {
|
|
44
|
+
await N.delete(c), t.value = u(t.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: t,
|
|
51
|
+
isLoading: r,
|
|
52
|
+
readPermissionSets: i,
|
|
53
|
+
createPermissionSet: s,
|
|
54
|
+
updatePermissionSet: a,
|
|
55
|
+
deletePermissionSet: o
|
|
56
|
+
};
|
|
57
|
+
}), ne = () => {
|
|
58
|
+
const e = se();
|
|
59
|
+
return {
|
|
60
|
+
...e,
|
|
61
|
+
...K(e)
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
function k(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
|
+
(t) => t !== null && typeof t == "object" && !Array.isArray(t) && Object.keys(t).length === 1 && Array.isArray(t.$in)
|
|
81
|
+
) : !0;
|
|
82
|
+
}
|
|
83
|
+
function Q(e) {
|
|
84
|
+
const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = (i, s, a) => {
|
|
85
|
+
var o, u;
|
|
86
|
+
const c = k(s.conditions);
|
|
87
|
+
let l = `${s.subject}::${JSON.stringify([...s.actions].sort())}`;
|
|
88
|
+
j(c) || (l += `::${JSON.stringify(c)}`);
|
|
89
|
+
const d = i.get(l);
|
|
90
|
+
if (!d) {
|
|
91
|
+
i.set(l, { ...s, setNames: [a.name], setId: a._id });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
d.setNames.push(a.name);
|
|
95
|
+
const m = k(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 s of i.permissions)
|
|
108
|
+
n(s.inverted ? r : t, s, i);
|
|
109
|
+
return [...Array.from(t.values()), ...Array.from(r.values())];
|
|
110
|
+
}
|
|
111
|
+
function B(e, t) {
|
|
112
|
+
return `${e}::${[...t].sort().join(",")}`;
|
|
113
|
+
}
|
|
114
|
+
function G(e, t) {
|
|
115
|
+
const r = [...e], n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const o of e) {
|
|
117
|
+
const u = O(o.subject);
|
|
118
|
+
n.add(B(u, o.actions)), o.inverted && o.actions.includes("manage") && i.add(`set_${u}`), !o.inverted && o.actions.includes("manage") && s.add(u);
|
|
119
|
+
}
|
|
120
|
+
const a = [...e];
|
|
121
|
+
for (; a.length > 0; ) {
|
|
122
|
+
const o = a.shift(), u = `set_${O(o.subject)}`, c = t[u];
|
|
123
|
+
if (!c || i.has(u) || !o.actions.includes("manage") || o.inverted) continue;
|
|
124
|
+
i.add(u);
|
|
125
|
+
const l = re(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 = B(f, m.actions);
|
|
130
|
+
n.has(p) || s.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 = B(f, ["manage"]), v = {
|
|
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(v)), a.push(v);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return [...r.filter((o) => !o.inverted), ...r.filter((o) => o.inverted)];
|
|
157
|
+
}
|
|
158
|
+
function re(e) {
|
|
159
|
+
if (!e.source) return [];
|
|
160
|
+
const { type: t, trace: r, permissionSetName: n } = e.source;
|
|
161
|
+
if (r && r.length > 0) return r;
|
|
162
|
+
switch (t) {
|
|
163
|
+
case "permissionSet":
|
|
164
|
+
return n ? [n] : [];
|
|
165
|
+
case "custom":
|
|
166
|
+
return ["custom"];
|
|
167
|
+
default:
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function H(e, t, r = /* @__PURE__ */ new Set()) {
|
|
172
|
+
var i;
|
|
173
|
+
const n = [];
|
|
174
|
+
for (const s of e) {
|
|
175
|
+
if (r.has(s)) continue;
|
|
176
|
+
r.add(s);
|
|
177
|
+
const a = t.find((o) => o.id === s);
|
|
178
|
+
a && (n.push(a), (i = a.permissionSetIds) != null && i.length && n.push(...H(a.permissionSetIds, t, r)));
|
|
179
|
+
}
|
|
180
|
+
return n;
|
|
181
|
+
}
|
|
182
|
+
function Ie(e) {
|
|
183
|
+
const t = Q(e).map(
|
|
184
|
+
({ setNames: i, setId: s, ...a }) => a
|
|
185
|
+
), r = t.filter((i) => !i.inverted), n = t.filter((i) => i.inverted);
|
|
186
|
+
return M(r, n);
|
|
187
|
+
}
|
|
188
|
+
function Ae(e, t, r) {
|
|
189
|
+
const n = /* @__PURE__ */ new Map();
|
|
190
|
+
return e.forEach(
|
|
191
|
+
({ name: i, permissions: s }) => s.forEach(({ conditions: a, actions: o }) => {
|
|
192
|
+
var c, l;
|
|
193
|
+
const u = JSON.parse(a || "{}");
|
|
194
|
+
(c = u[t]) != null && c.$in ? (l = u[t]) == 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, s]) => ({
|
|
201
|
+
id: i,
|
|
202
|
+
setNames: [...s]
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
function Oe(e, t) {
|
|
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(t.map((o) => [o.subject, o])), s = [], 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) && s.push(c);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const m = Object.keys(l)[0], f = l[m].$in.filter(
|
|
230
|
+
(v) => !d[m].$in.includes(v)
|
|
231
|
+
);
|
|
232
|
+
f.length > 0 && s.push(r(u, f)), d[m].$in.filter(
|
|
233
|
+
(v) => !l[m].$in.includes(v)
|
|
234
|
+
).length > 0 && s.push(c);
|
|
235
|
+
} else if (!u.conditions && c.conditions)
|
|
236
|
+
s.push(c);
|
|
237
|
+
else if (u.conditions && !c.conditions)
|
|
238
|
+
j(JSON.parse(u.conditions)) || s.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((v) => !l.has(v));
|
|
243
|
+
s.push({
|
|
244
|
+
...c,
|
|
245
|
+
actions: p
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
f.length > 0 && s.push({
|
|
249
|
+
...u,
|
|
250
|
+
actions: f,
|
|
251
|
+
inverted: !0
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (u) {
|
|
257
|
+
s.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 && s.push(c);
|
|
268
|
+
}
|
|
269
|
+
return s;
|
|
270
|
+
}
|
|
271
|
+
function _e(e) {
|
|
272
|
+
const t = G(
|
|
273
|
+
e,
|
|
274
|
+
V
|
|
275
|
+
), r = new Set(
|
|
276
|
+
t.filter((i) => {
|
|
277
|
+
var s;
|
|
278
|
+
return ((s = i.source) == null ? void 0 : s.type) === "systemPermissionSet" && !i.inverted;
|
|
279
|
+
}).map((i) => i.subject)
|
|
280
|
+
), n = new Set(
|
|
281
|
+
t.filter(
|
|
282
|
+
(i) => {
|
|
283
|
+
var s;
|
|
284
|
+
return ((s = i.source) == null ? void 0 : s.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 ie = "business::report::";
|
|
291
|
+
function Ee(e, t) {
|
|
292
|
+
const r = [], n = e.filter((i) => {
|
|
293
|
+
const s = i.subject;
|
|
294
|
+
return !s.startsWith(ie) || t.has(s) ? !0 : (r.push(s), !1);
|
|
295
|
+
});
|
|
296
|
+
return r.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", r), n;
|
|
297
|
+
}
|
|
298
|
+
const oe = "business::report::reports::", ae = _.Subject.Business.report_reports_allDefaultReports, ce = _.Subject.Business.report_reports_allCustomReports;
|
|
299
|
+
function ue(e, t) {
|
|
300
|
+
return e.conditions ? !!t.conditions && e.conditions === t.conditions : !t.conditions;
|
|
301
|
+
}
|
|
302
|
+
function Ne(e, t) {
|
|
303
|
+
const r = e.find(
|
|
304
|
+
(a) => !a.inverted && a.subject === ae
|
|
305
|
+
), n = e.find(
|
|
306
|
+
(a) => !a.inverted && a.subject === ce
|
|
307
|
+
);
|
|
308
|
+
if (!r && !n) return e;
|
|
309
|
+
const i = r ? new Set(r.actions) : null, s = 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(oe))
|
|
315
|
+
return a.push(o), a;
|
|
316
|
+
const c = t.has(u), l = c ? i : s, d = c ? r : n;
|
|
317
|
+
if (!l || !d || !ue(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 M(e, t) {
|
|
330
|
+
var n, i;
|
|
331
|
+
const r = new Map(e.map((s) => [s.subject, s]));
|
|
332
|
+
for (const s of t) {
|
|
333
|
+
if (s.inverted) {
|
|
334
|
+
const o = r.get(s.subject);
|
|
335
|
+
if (s.conditions) {
|
|
336
|
+
if (o != null && o.conditions) {
|
|
337
|
+
const u = JSON.parse(o.conditions), c = JSON.parse(s.conditions);
|
|
338
|
+
if (!j(u) || !j(c)) {
|
|
339
|
+
r.delete(s.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(s.subject, {
|
|
344
|
+
...o,
|
|
345
|
+
conditions: JSON.stringify({ [l]: { $in: f } })
|
|
346
|
+
}) : r.delete(s.subject);
|
|
347
|
+
} else
|
|
348
|
+
r.delete(s.subject);
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
if (o) {
|
|
352
|
+
const u = new Set(s.actions), c = o.actions.filter((l) => !u.has(l));
|
|
353
|
+
c.length > 0 ? r.set(s.subject, { ...o, actions: c }) : r.delete(s.subject);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (s.conditions) {
|
|
359
|
+
r.set(s.subject, s);
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
const a = r.get(s.subject);
|
|
363
|
+
if (a != null && a.conditions && !j(JSON.parse(a.conditions))) {
|
|
364
|
+
r.set(s.subject, s);
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (a) {
|
|
368
|
+
const o = [
|
|
369
|
+
.../* @__PURE__ */ new Set([
|
|
370
|
+
...a.actions,
|
|
371
|
+
...s.actions
|
|
372
|
+
])
|
|
373
|
+
];
|
|
374
|
+
r.set(s.subject, { ...a, actions: o });
|
|
375
|
+
} else
|
|
376
|
+
r.set(s.subject, s);
|
|
377
|
+
}
|
|
378
|
+
return Array.from(r.values());
|
|
379
|
+
}
|
|
380
|
+
function le(e, t) {
|
|
381
|
+
const r = M(e, t), n = new Set(e.map((s) => s.subject)), i = t.filter(
|
|
382
|
+
(s) => s.inverted && !n.has(s.subject)
|
|
383
|
+
);
|
|
384
|
+
return [...r, ...i];
|
|
385
|
+
}
|
|
386
|
+
const P = "/permission-assignments", R = {
|
|
387
|
+
async readAll() {
|
|
388
|
+
return g(await b().get(P));
|
|
389
|
+
},
|
|
390
|
+
async readByUserId(e) {
|
|
391
|
+
return g(await b().get(`${P}/user/${e}`));
|
|
392
|
+
},
|
|
393
|
+
async readById(e) {
|
|
394
|
+
return g(await b().get(`${P}/${e}`));
|
|
395
|
+
},
|
|
396
|
+
async create(e) {
|
|
397
|
+
return g(await b().post(P, e));
|
|
398
|
+
},
|
|
399
|
+
async update(e, t) {
|
|
400
|
+
return g(await b().put(`${P}/${e}`, t));
|
|
401
|
+
},
|
|
402
|
+
async delete(e) {
|
|
403
|
+
return g(await b().delete(`${P}/${e}`));
|
|
404
|
+
},
|
|
405
|
+
async addReportManagePermission(e, t) {
|
|
406
|
+
return g(
|
|
407
|
+
await b().post("/my-permissions/report-manage", { permissionKey: e, label: t })
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
}, de = z("permissionAssignment", () => {
|
|
411
|
+
const e = S([]);
|
|
412
|
+
async function t() {
|
|
413
|
+
const o = await R.readAll();
|
|
414
|
+
e.value = o;
|
|
415
|
+
}
|
|
416
|
+
async function r(o) {
|
|
417
|
+
return await R.readByUserId(o);
|
|
418
|
+
}
|
|
419
|
+
async function n(o) {
|
|
420
|
+
const u = await R.create(o);
|
|
421
|
+
e.value = [...e.value, u];
|
|
422
|
+
}
|
|
423
|
+
async function i(o, u) {
|
|
424
|
+
const c = await R.update(o, u);
|
|
425
|
+
e.value = e.value.map((l) => l.id === o ? c : l);
|
|
426
|
+
}
|
|
427
|
+
async function s(o) {
|
|
428
|
+
await R.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: t,
|
|
436
|
+
readPermissionAssignmentByUserId: r,
|
|
437
|
+
createPermissionAssignment: n,
|
|
438
|
+
updatePermissionAssignment: i,
|
|
439
|
+
deletePermissionAssignment: s,
|
|
440
|
+
getPermissionAssignmentByUserId: a
|
|
441
|
+
};
|
|
442
|
+
}), me = () => {
|
|
443
|
+
const e = de();
|
|
444
|
+
return {
|
|
445
|
+
...e,
|
|
446
|
+
...K(e)
|
|
447
|
+
};
|
|
448
|
+
}, fe = {
|
|
449
|
+
async fetchReportPermissions(e, t) {
|
|
450
|
+
const r = t ? { lang: t } : {};
|
|
451
|
+
return g(
|
|
452
|
+
await D().get(`/report-query/hrm/${e}/reports`, { params: r })
|
|
453
|
+
);
|
|
454
|
+
},
|
|
455
|
+
async fetchReportPermissionsForPortal(e, t) {
|
|
456
|
+
const r = t ? { isSupportPos: !1, lang: t } : { isSupportPos: !1 };
|
|
457
|
+
return g(
|
|
458
|
+
await D().get(`/report-query/hrm/${e}/reports`, { params: r })
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
}, C = S([]), J = S(!1), $ = S(!1), I = S(null), x = S(null), U = S(!1);
|
|
462
|
+
function pe() {
|
|
463
|
+
const e = X();
|
|
464
|
+
async function t() {
|
|
465
|
+
var s;
|
|
466
|
+
const n = (s = e.currentBusiness.value) == null ? void 0 : s.id;
|
|
467
|
+
if (!n) return;
|
|
468
|
+
const i = localStorage.getItem("locale");
|
|
469
|
+
if (I.value !== n && (C.value = [], J.value = !1, $.value = !1, I.value = n, U.value = !1), !(J.value && x.value === i)) {
|
|
470
|
+
if ($.value) {
|
|
471
|
+
U.value = !0;
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
$.value = !0;
|
|
475
|
+
try {
|
|
476
|
+
const a = await fe.fetchReportPermissionsForPortal(n, i);
|
|
477
|
+
if (I.value !== n) return;
|
|
478
|
+
C.value = a, J.value = !0, x.value = i;
|
|
479
|
+
} catch (a) {
|
|
480
|
+
if (I.value !== n) return;
|
|
481
|
+
console.warn("Failed to fetch custom report permissions:", a), C.value = [];
|
|
482
|
+
} finally {
|
|
483
|
+
I.value === n && ($.value = !1, U.value && (U.value = !1, await t()));
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
const r = T(() => C.value.map(
|
|
488
|
+
(n) => n.isDefault ? {
|
|
489
|
+
label: n.name,
|
|
490
|
+
subject: `business::report::reports::${n.permissionKey}`,
|
|
491
|
+
actions: [h.manage, h.read, h.create],
|
|
492
|
+
category: F.reports
|
|
493
|
+
} : {
|
|
494
|
+
label: n.name,
|
|
495
|
+
subject: `business::report::reports::${n.permissionKey}`,
|
|
496
|
+
actions: [
|
|
497
|
+
h.manage,
|
|
498
|
+
h.read,
|
|
499
|
+
h.create,
|
|
500
|
+
h.update,
|
|
501
|
+
h.delete
|
|
502
|
+
],
|
|
503
|
+
category: F.customReports
|
|
504
|
+
}
|
|
505
|
+
));
|
|
506
|
+
return {
|
|
507
|
+
fetchCustomReportPermissions: t,
|
|
508
|
+
customReportPermissions: r,
|
|
509
|
+
isLoading: T(() => $.value),
|
|
510
|
+
isLoaded: T(() => J.value)
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function A(e) {
|
|
514
|
+
const t = ne(), r = me(), n = te().restaurants, { customReportPermissions: i } = pe(), s = r.getPermissionAssignmentByUserId(e.id), a = H(
|
|
515
|
+
(s == null ? void 0 : s.permissionSetIds) ?? [],
|
|
516
|
+
t.permissionSets.value
|
|
517
|
+
), o = Q(a).map(
|
|
518
|
+
({ setNames: p, ...v }) => v
|
|
519
|
+
), u = s == null ? void 0 : s.customPermissions, c = u ?? e.permissions.map((p) => ({
|
|
520
|
+
...p,
|
|
521
|
+
subject: O(p.subject)
|
|
522
|
+
})), l = M(o, c), d = G(
|
|
523
|
+
le(o, c),
|
|
524
|
+
V
|
|
525
|
+
).filter((p) => !p.inverted), m = be(d), f = m ?? n.value.map((p) => p._id);
|
|
526
|
+
return {
|
|
527
|
+
doc: e,
|
|
528
|
+
id: e.id,
|
|
529
|
+
name: e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
|
|
530
|
+
phoneNumber: e.phoneNumber,
|
|
531
|
+
email: e.email,
|
|
532
|
+
restaurants: W(
|
|
533
|
+
f.map((p) => {
|
|
534
|
+
var v;
|
|
535
|
+
return ((v = n.value.find((Y) => Y._id === p)) == null ? void 0 : v.profile.name) ?? "";
|
|
536
|
+
})
|
|
537
|
+
),
|
|
538
|
+
managableRestaurantIds: m,
|
|
539
|
+
permissionLabels: Se(d, i.value),
|
|
540
|
+
permissions: l
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
const ge = Object.freeze(
|
|
544
|
+
Object.values(q)
|
|
545
|
+
), Ce = {
|
|
546
|
+
async readTeamMembers() {
|
|
547
|
+
return g(
|
|
548
|
+
await b().get("/portal-users")
|
|
549
|
+
).map(A);
|
|
550
|
+
},
|
|
551
|
+
async readTeamMembersPage(e) {
|
|
552
|
+
var r, n, i;
|
|
553
|
+
const t = g(
|
|
554
|
+
await b().get("/portal-users/paged", {
|
|
555
|
+
params: {
|
|
556
|
+
limit: e.limit,
|
|
557
|
+
offset: e.offset,
|
|
558
|
+
search: e.search,
|
|
559
|
+
restaurantIds: (r = e.restaurantIds) != null && r.length ? e.restaurantIds : void 0,
|
|
560
|
+
permissionSubjects: (n = e.permissionSubjects) != null && n.length ? e.permissionSubjects : void 0,
|
|
561
|
+
permissionSetIds: (i = e.permissionSetIds) != null && i.length ? e.permissionSetIds : void 0
|
|
562
|
+
}
|
|
563
|
+
})
|
|
564
|
+
);
|
|
565
|
+
return {
|
|
566
|
+
items: t.items.map(A),
|
|
567
|
+
total: t.total
|
|
568
|
+
};
|
|
569
|
+
},
|
|
570
|
+
async readTeamMember(e) {
|
|
571
|
+
return A(
|
|
572
|
+
g(await b().get(`/portal-users/${e}`))
|
|
573
|
+
);
|
|
574
|
+
},
|
|
575
|
+
async createTeamMember(e) {
|
|
576
|
+
return A(
|
|
577
|
+
g(await b().post("/portal-users", e))
|
|
578
|
+
);
|
|
579
|
+
},
|
|
580
|
+
async updateTeamMember(e, t) {
|
|
581
|
+
return A(
|
|
582
|
+
g(await b().put(`/portal-users/${e}`, t))
|
|
583
|
+
);
|
|
584
|
+
},
|
|
585
|
+
async deleteTeamMember(e) {
|
|
586
|
+
return g(await b().delete(`/portal-users/${e}`));
|
|
587
|
+
},
|
|
588
|
+
async readTeamMemberPosUserIds() {
|
|
589
|
+
return g(await b().get("/portal-users")).map((t) => t.posUserId);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
function Je(e, t, r) {
|
|
593
|
+
if (e.some((a) => a.subject === "all")) return "All";
|
|
594
|
+
const n = (r ?? L).filter(
|
|
595
|
+
(a) => a.subject === t
|
|
596
|
+
), i = new Set(n.map((a) => w(a).value)), s = e.filter((a) => a.subject === t).filter((a) => i.has(w(a).value));
|
|
597
|
+
return s.length === n.length ? "All" : s.length === 0 ? "-" : `${s.length} permission allow`;
|
|
598
|
+
}
|
|
599
|
+
function w(e) {
|
|
600
|
+
const t = Z(e), r = t.subject;
|
|
601
|
+
return {
|
|
602
|
+
...t,
|
|
603
|
+
get conditions() {
|
|
604
|
+
if (typeof t.conditions != "string") return t.conditions;
|
|
605
|
+
try {
|
|
606
|
+
return JSON.parse(t.conditions);
|
|
607
|
+
} catch {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
get isDiscountOperation() {
|
|
612
|
+
var n;
|
|
613
|
+
return r === y.F_RULE_SUBJECT.enum.order && ((n = this.conditions) == null ? void 0 : n.operation) === y.F_RULE_ORDER_OPERATION.enum.discount;
|
|
614
|
+
},
|
|
615
|
+
get isOrderOperation() {
|
|
616
|
+
return r === y.F_RULE_SUBJECT.enum.order;
|
|
617
|
+
},
|
|
618
|
+
get isReportPermission() {
|
|
619
|
+
return r === y.F_RULE_SUBJECT.enum.report;
|
|
620
|
+
},
|
|
621
|
+
/**
|
|
622
|
+
* Order and report rules are only meaningful together with the condition
|
|
623
|
+
* that names them. A rule missing it cannot be rendered or matched against
|
|
624
|
+
* the available permission list, so callers must preserve it verbatim —
|
|
625
|
+
* see `splitRoleFormPermissions`, which routes it to `passthrough`, not
|
|
626
|
+
* `dropped`. Dropping it would silently revoke a grant the portal cannot
|
|
627
|
+
* display (HRM-0027).
|
|
628
|
+
*/
|
|
629
|
+
get isResolvable() {
|
|
630
|
+
return this.discriminator !== void 0;
|
|
631
|
+
},
|
|
632
|
+
/**
|
|
633
|
+
* The condition value that identifies this rule, if the subject needs one.
|
|
634
|
+
* An empty condition counts as missing: `{ name: '' }` is a known corrupted
|
|
635
|
+
* shape that used to resolve to the first hardcoded report permission on
|
|
636
|
+
* save (HRM-0027), so it must not look resolvable here either.
|
|
637
|
+
*/
|
|
638
|
+
get discriminator() {
|
|
639
|
+
var n, i;
|
|
640
|
+
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();
|
|
641
|
+
},
|
|
642
|
+
get formatted() {
|
|
643
|
+
const n = this.discriminator;
|
|
644
|
+
return n === void 0 ? r.toString() : n.endsWith("_") ? n.slice(0, n.length - 1) : n;
|
|
645
|
+
},
|
|
646
|
+
get label() {
|
|
647
|
+
return t.label || ee(this.formatted);
|
|
648
|
+
},
|
|
649
|
+
get value() {
|
|
650
|
+
const n = this.discriminator;
|
|
651
|
+
return this.isOrderOperation || this.isReportPermission ? n === void 0 ? r.toString() : `${r}:${n}` : r.toString();
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function Ue(e) {
|
|
656
|
+
var n, i;
|
|
657
|
+
const t = e.map((s) => w(s)).find((s) => s.isDiscountOperation);
|
|
658
|
+
if (!t) return 100;
|
|
659
|
+
const r = Number((i = (n = t.conditions) == null ? void 0 : n.adjustment) == null ? void 0 : i.$lte);
|
|
660
|
+
return Number.isFinite(r) ? parseInt((r * 100).toFixed(0)) : 0;
|
|
661
|
+
}
|
|
662
|
+
function be(e) {
|
|
663
|
+
const t = e.find(
|
|
664
|
+
(r) => r.subject === _.Subject.Restaurant.restaurant
|
|
665
|
+
);
|
|
666
|
+
return t ? t.conditions ? JSON.parse(t.conditions).restaurantId.$in : null : [];
|
|
667
|
+
}
|
|
668
|
+
function Te(e) {
|
|
669
|
+
return (e == null ? void 0 : e.some((t) => t.subject === "all")) ?? !1;
|
|
670
|
+
}
|
|
671
|
+
function Be(e) {
|
|
672
|
+
const t = e.find((r) => r.subject === _.Subject.Business.role);
|
|
673
|
+
return t ? t.conditions ? JSON.parse(t.conditions).roleId.$in : null : [];
|
|
674
|
+
}
|
|
675
|
+
function Le(e) {
|
|
676
|
+
const t = w(e);
|
|
677
|
+
if (!t.isReportPermission) return;
|
|
678
|
+
const { name: r, ...n } = t.conditions ?? {};
|
|
679
|
+
return Object.keys(n).length > 0 ? n : void 0;
|
|
680
|
+
}
|
|
681
|
+
function Me(e, t, r) {
|
|
682
|
+
return e.flatMap((n) => {
|
|
683
|
+
const i = ve(n);
|
|
684
|
+
if (!i) return [];
|
|
685
|
+
const s = i.isReportPermission ? r == null ? void 0 : r.get(n) : void 0;
|
|
686
|
+
return [
|
|
687
|
+
{
|
|
688
|
+
subject: i.subject,
|
|
689
|
+
actions: i.actions,
|
|
690
|
+
conditions: {
|
|
691
|
+
...i.conditions,
|
|
692
|
+
...s ?? {},
|
|
693
|
+
adjustment: i.isDiscountOperation ? { $lte: parseFloat((t / 100).toFixed(2)) } : void 0
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
];
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
function ve(e) {
|
|
700
|
+
const t = e.indexOf(":"), r = t === -1 ? e : e.slice(0, t), n = t === -1 ? void 0 : e.slice(t + 1);
|
|
701
|
+
if (t !== -1 && !n) return;
|
|
702
|
+
let i;
|
|
703
|
+
return n ? (i = L.find((s) => {
|
|
704
|
+
if (s.subject !== r) return !1;
|
|
705
|
+
const a = typeof s.conditions == "string" ? JSON.parse(s.conditions) : s.conditions;
|
|
706
|
+
return [a == null ? void 0 : a.operation, a == null ? void 0 : a.name].includes(n);
|
|
707
|
+
}), !i && r === y.F_RULE_SUBJECT.enum.report && (i = {
|
|
708
|
+
label: "",
|
|
709
|
+
subject: y.F_RULE_SUBJECT.enum.report,
|
|
710
|
+
actions: ["read"],
|
|
711
|
+
conditions: { name: n },
|
|
712
|
+
inverted: !1,
|
|
713
|
+
reason: ""
|
|
714
|
+
})) : i = L.find((s) => s.subject === r), i ? w(i) : void 0;
|
|
715
|
+
}
|
|
716
|
+
function Fe(e, t) {
|
|
717
|
+
const r = { values: [], passthrough: [], dropped: [] };
|
|
718
|
+
for (const n of e) {
|
|
719
|
+
const i = n == null ? void 0 : n.actions;
|
|
720
|
+
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)) {
|
|
721
|
+
r.dropped.push(n);
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
const s = w(n).value, a = `${y.F_RULE_SUBJECT.enum.report}:`, o = s.startsWith(a) ? s.slice(a.length) : "";
|
|
725
|
+
t.has(s) || o && o !== "undefined" ? r.values.push(s) : r.passthrough.push(n);
|
|
726
|
+
}
|
|
727
|
+
return r;
|
|
728
|
+
}
|
|
729
|
+
function Se(e, t = []) {
|
|
730
|
+
return W(
|
|
731
|
+
e.reduce((r, n) => {
|
|
732
|
+
const i = ge.find(
|
|
733
|
+
(s) => s.subject === n.subject && n.actions.includes("manage")
|
|
734
|
+
) || t.find((s) => s.subject === n.subject);
|
|
735
|
+
if (i) {
|
|
736
|
+
const s = i.subject === _.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
|
|
737
|
+
r.push(s);
|
|
738
|
+
}
|
|
739
|
+
return r;
|
|
740
|
+
}, [])
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
export {
|
|
744
|
+
G as N,
|
|
745
|
+
Q as P,
|
|
746
|
+
fe as R,
|
|
747
|
+
Je as a,
|
|
748
|
+
le as b,
|
|
749
|
+
H as c,
|
|
750
|
+
pe as d,
|
|
751
|
+
Le as e,
|
|
752
|
+
Me as f,
|
|
753
|
+
Ue as g,
|
|
754
|
+
Te as h,
|
|
755
|
+
ie as i,
|
|
756
|
+
Be as j,
|
|
757
|
+
be as k,
|
|
758
|
+
_e as l,
|
|
759
|
+
Ie as m,
|
|
760
|
+
Oe as n,
|
|
761
|
+
Ee as o,
|
|
762
|
+
ge as p,
|
|
763
|
+
Ne as q,
|
|
764
|
+
w as r,
|
|
765
|
+
Fe as s,
|
|
766
|
+
Ce as t,
|
|
767
|
+
ne as u,
|
|
768
|
+
me as v,
|
|
769
|
+
Se as w,
|
|
770
|
+
Ae as x
|
|
771
|
+
};
|