@feedmepos/mf-hrm-portal 2.0.25-dev.2 → 2.1.0-dev
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/AuditLogList-C1bGND8z.js +1037 -0
- package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-tiuei7CA.js +383 -0
- package/dist/{EmployeeList-Cpv6Pc4J.js → EmployeeList-DqQF9xEx.js} +78 -78
- package/dist/{FormItem.vue_vue_type_script_setup_true_lang-DPT2FoIc.js → FormItem.vue_vue_type_script_setup_true_lang-D3MOFOUI.js} +1 -1
- package/dist/{Main-3IwCguRi.js → Main-BgOhmojO.js} +6 -6
- package/dist/{Main-DrquIYbM.js → Main-D2Wf__wM.js} +1138 -1142
- package/dist/Main-DcKVuIjB.js +90 -0
- package/dist/PermissionSetList-CQpTa0eY.js +384 -0
- package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CCKVpAwv.js +4030 -0
- package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-sueNu2MD.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-D-14ca2J.js} +1 -1
- package/dist/RoleList-tSC8RJHe.js +674 -0
- package/dist/SelectFilter-DUj7GBtT.js +251 -0
- package/dist/TeamMemberList-Bz-kDJ0e.js +1163 -0
- package/dist/{TimesheetList-CMqKNZOd.js → TimesheetList-BFVhmcRt.js} +10 -10
- package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_91afda4e_lang-ekr2tKEO.js → TimesheetList.vue_vue_type_style_index_0_scoped_d7ed31d7_lang-CtHuL5tW.js} +2 -2
- package/dist/{app-D5h3x9dh.js → app-DRnSocX8.js} +5052 -2394
- package/dist/app.js +1 -1
- package/dist/{dayjs.min-BLtrWiQ_.js → dayjs.min-B8xOAypU.js} +1 -1
- package/dist/{employee-CpW9HMLY.js → employee-UrXqUaik.js} +3 -3
- package/dist/{iteration-D1WDQ_Kv.js → iteration-LEYoQKiI.js} +1 -1
- package/dist/{lodash-BI_MmDQa.js → lodash-Bq6_eZZ0.js} +1 -1
- package/dist/rule-CJC6Cq6S.js +1047 -0
- package/dist/src/api/audit-log/index.d.ts +0 -17
- package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
- package/dist/src/components/form/SelectFilter.vue.d.ts +0 -3
- package/dist/src/composables/useBasePermission.d.ts +1 -0
- package/dist/src/composables/useConditionDraft.d.ts +40 -0
- package/dist/src/composables/useCoverConditionOverride.d.ts +61 -0
- package/dist/src/helpers/business-timezone.d.ts +22 -0
- package/dist/src/helpers/permission-set.d.ts +4 -2
- package/dist/src/helpers/rule.d.ts +2 -1
- package/dist/src/stores/team.d.ts +1 -4
- package/dist/src/views/audit-log/locales/index.d.ts +16 -24
- package/dist/src/views/hr/locales/index.d.ts +0 -4
- package/dist/src/views/team/components/BasePermission.vue.d.ts +13 -0
- package/dist/src/views/team/condition-builders/ConditionFormHost.vue.d.ts +22 -0
- package/dist/src/views/team/condition-builders/ConditionFormRenderer.vue.d.ts +23 -0
- package/dist/src/views/team/condition-builders/component-map.d.ts +4 -0
- package/dist/src/views/team/condition-builders/condition-form-dedupe.d.ts +23 -0
- package/dist/src/views/team/locales/index.d.ts +68 -4
- package/dist/style.css +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{useAppStore-hU1uAhE-.js → useAppStore-BGsfYWAR.js} +1 -1
- package/dist/{useLoading-D0XTdxji.js → useLoading-BUM5R2qV.js} +1 -1
- package/dist/{useReportPermissions-Drb4irzE.js → useReportPermissions-nlQ_BBL2.js} +3 -3
- package/package.json +2 -2
- package/dist/AuditLogList-UHJxYRdr.js +0 -1145
- package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +0 -58
- package/dist/Main-Da2SFU8t.js +0 -94
- package/dist/PermissionSetList-upvouEfb.js +0 -356
- package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CAjf-JPW.js +0 -3457
- package/dist/RoleList-CgSg0ydf.js +0 -566
- package/dist/SelectFilter-ATOm0hdn.js +0 -269
- package/dist/TeamMemberList-jEODaxFX.js +0 -1130
- package/dist/rule-DG8tt7hf.js +0 -995
|
@@ -0,0 +1,1047 @@
|
|
|
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-LEYoQKiI.js";
|
|
2
|
+
import { h as A, P as V, d as _, v as k, n as j, b as ee } from "./app-DRnSocX8.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 M = [
|
|
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(null);
|
|
356
|
+
async function o() {
|
|
357
|
+
var l;
|
|
358
|
+
const c = ((l = e.value) == null ? void 0 : l._id) ?? null;
|
|
359
|
+
if (t.value === c) return;
|
|
360
|
+
const a = await N.read();
|
|
361
|
+
n.value = r(a), t.value = c;
|
|
362
|
+
}
|
|
363
|
+
async function i(c) {
|
|
364
|
+
const a = await N.create(c);
|
|
365
|
+
n.value = r([...n.value, a]);
|
|
366
|
+
}
|
|
367
|
+
async function s(c, a) {
|
|
368
|
+
const l = await N.update(c, a);
|
|
369
|
+
n.value = r(n.value.map((d) => d.id === c ? l : d));
|
|
370
|
+
}
|
|
371
|
+
async function u(c) {
|
|
372
|
+
await N.delete(c), n.value = r(n.value.filter((a) => a.id !== c));
|
|
373
|
+
}
|
|
374
|
+
function r(c) {
|
|
375
|
+
return c.sort((a, l) => a.name.localeCompare(l.name));
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
permissionSets: n,
|
|
379
|
+
readPermissionSets: o,
|
|
380
|
+
createPermissionSet: i,
|
|
381
|
+
updatePermissionSet: s,
|
|
382
|
+
deletePermissionSet: u
|
|
383
|
+
};
|
|
384
|
+
}), te = () => {
|
|
385
|
+
const e = se();
|
|
386
|
+
return {
|
|
387
|
+
...e,
|
|
388
|
+
...K(e)
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
function D(e) {
|
|
392
|
+
if (e) {
|
|
393
|
+
if (typeof e == "string") {
|
|
394
|
+
if (e === "{}") return;
|
|
395
|
+
try {
|
|
396
|
+
return JSON.parse(e);
|
|
397
|
+
} catch {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (typeof e == "object")
|
|
402
|
+
return Object.keys(e).length > 0 ? e : void 0;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function h(e) {
|
|
406
|
+
return e ? Object.values(e).every(
|
|
407
|
+
(n) => n !== null && typeof n == "object" && !Array.isArray(n) && Object.keys(n).length === 1 && Array.isArray(n.$in)
|
|
408
|
+
) : !0;
|
|
409
|
+
}
|
|
410
|
+
function Q(e) {
|
|
411
|
+
const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = (i, s, u) => {
|
|
412
|
+
var r, c;
|
|
413
|
+
const a = D(s.conditions);
|
|
414
|
+
let l = `${s.subject}::${JSON.stringify([...s.actions].sort())}`;
|
|
415
|
+
h(a) || (l += `::${JSON.stringify(a)}`);
|
|
416
|
+
const d = i.get(l);
|
|
417
|
+
if (!d) {
|
|
418
|
+
i.set(l, { ...s, setNames: [u.name], setId: u._id });
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
d.setNames.push(u.name);
|
|
422
|
+
const m = D(d.conditions);
|
|
423
|
+
if (m && a) {
|
|
424
|
+
for (const f in a)
|
|
425
|
+
(r = m[f]) != null && r.$in && (c = a[f]) != null && c.$in ? m[f].$in = Array.from(
|
|
426
|
+
/* @__PURE__ */ new Set([...m[f].$in, ...a[f].$in])
|
|
427
|
+
) : m[f] || (m[f] = a[f]);
|
|
428
|
+
d.conditions = JSON.stringify(m);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
for (const i of e)
|
|
432
|
+
for (const s of i.permissions)
|
|
433
|
+
o(s.inverted ? t : n, s, i);
|
|
434
|
+
return [...Array.from(n.values()), ...Array.from(t.values())];
|
|
435
|
+
}
|
|
436
|
+
function B(e, n) {
|
|
437
|
+
return `${e}::${[...n].sort().join(",")}`;
|
|
438
|
+
}
|
|
439
|
+
function G(e, n) {
|
|
440
|
+
const t = [...e], o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
|
|
441
|
+
for (const r of e) {
|
|
442
|
+
const c = A(r.subject);
|
|
443
|
+
o.add(B(c, r.actions)), r.inverted && r.actions.includes("manage") && i.add(`set_${c}`), !r.inverted && r.actions.includes("manage") && s.add(c);
|
|
444
|
+
}
|
|
445
|
+
const u = [...e];
|
|
446
|
+
for (; u.length > 0; ) {
|
|
447
|
+
const r = u.shift(), c = `set_${A(r.subject)}`, a = n[c];
|
|
448
|
+
if (!a || i.has(c) || !r.actions.includes("manage") || r.inverted) continue;
|
|
449
|
+
i.add(c);
|
|
450
|
+
const l = oe(r);
|
|
451
|
+
r.source && !r.source.trace && (r.source = { ...r.source, trace: l });
|
|
452
|
+
const d = [...l, `${a.name} (system)`];
|
|
453
|
+
for (const m of a.permissions ?? []) {
|
|
454
|
+
const f = A(m.subject), p = B(f, m.actions);
|
|
455
|
+
o.has(p) || s.has(f) || (o.add(p), t.push({
|
|
456
|
+
...m,
|
|
457
|
+
// FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
|
|
458
|
+
fields: m.fields ?? void 0,
|
|
459
|
+
source: {
|
|
460
|
+
type: "systemPermissionSet",
|
|
461
|
+
permissionSetId: a.key,
|
|
462
|
+
permissionSetName: a.name,
|
|
463
|
+
trace: d
|
|
464
|
+
}
|
|
465
|
+
}));
|
|
466
|
+
}
|
|
467
|
+
for (const m of a.permissionSets ?? []) {
|
|
468
|
+
const f = A(m), p = B(f, ["manage"]), g = {
|
|
469
|
+
subject: f,
|
|
470
|
+
actions: ["manage"],
|
|
471
|
+
source: {
|
|
472
|
+
type: "systemPermissionSet",
|
|
473
|
+
permissionSetId: a.key,
|
|
474
|
+
permissionSetName: a.name,
|
|
475
|
+
trace: d
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
o.has(p) || (o.add(p), t.push(g)), u.push(g);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return [...t.filter((r) => !r.inverted), ...t.filter((r) => r.inverted)];
|
|
482
|
+
}
|
|
483
|
+
function oe(e) {
|
|
484
|
+
if (!e.source) return [];
|
|
485
|
+
const { type: n, trace: t, permissionSetName: o } = e.source;
|
|
486
|
+
if (t && t.length > 0) return t;
|
|
487
|
+
switch (n) {
|
|
488
|
+
case "permissionSet":
|
|
489
|
+
return o ? [o] : [];
|
|
490
|
+
case "custom":
|
|
491
|
+
return ["custom"];
|
|
492
|
+
default:
|
|
493
|
+
return [];
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
function H(e, n, t = /* @__PURE__ */ new Set()) {
|
|
497
|
+
var i;
|
|
498
|
+
const o = [];
|
|
499
|
+
for (const s of e) {
|
|
500
|
+
if (t.has(s)) continue;
|
|
501
|
+
t.add(s);
|
|
502
|
+
const u = n.find((r) => r.id === s);
|
|
503
|
+
u && (o.push(u), (i = u.permissionSetIds) != null && i.length && o.push(...H(u.permissionSetIds, n, t)));
|
|
504
|
+
}
|
|
505
|
+
return o;
|
|
506
|
+
}
|
|
507
|
+
function $e(e) {
|
|
508
|
+
const n = Q(e).map(
|
|
509
|
+
({ setNames: i, setId: s, ...u }) => u
|
|
510
|
+
), t = n.filter((i) => !i.inverted), o = n.filter((i) => i.inverted);
|
|
511
|
+
return L(t, o);
|
|
512
|
+
}
|
|
513
|
+
function Ie(e, n, t) {
|
|
514
|
+
const o = /* @__PURE__ */ new Map();
|
|
515
|
+
return e.forEach(
|
|
516
|
+
({ name: i, permissions: s }) => s.forEach(({ conditions: u, actions: r }) => {
|
|
517
|
+
var a, l;
|
|
518
|
+
const c = JSON.parse(u || "{}");
|
|
519
|
+
(a = c[n]) != null && a.$in ? (l = c[n]) == null || l.$in.forEach(
|
|
520
|
+
(d) => (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i)
|
|
521
|
+
) : r[0] === "manage" && t.forEach((d) => {
|
|
522
|
+
(o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i);
|
|
523
|
+
});
|
|
524
|
+
})
|
|
525
|
+
), [...o].map(([i, s]) => ({
|
|
526
|
+
id: i,
|
|
527
|
+
setNames: [...s]
|
|
528
|
+
}));
|
|
529
|
+
}
|
|
530
|
+
function Ae(e, n) {
|
|
531
|
+
const t = (r, c) => {
|
|
532
|
+
const a = { ...r }, l = JSON.parse(a.conditions || "{}");
|
|
533
|
+
if (c)
|
|
534
|
+
if (c.length > 0) {
|
|
535
|
+
const d = Object.keys(l)[0];
|
|
536
|
+
l[d].$in = c;
|
|
537
|
+
} else
|
|
538
|
+
delete a.conditions;
|
|
539
|
+
return {
|
|
540
|
+
...a,
|
|
541
|
+
inverted: !0,
|
|
542
|
+
...a.conditions && { conditions: JSON.stringify(l) }
|
|
543
|
+
};
|
|
544
|
+
}, o = new Map(e.map((r) => [r.subject, r])), i = new Map(n.map((r) => [r.subject, r])), s = [], u = /* @__PURE__ */ new Set([...o.keys(), ...i.keys()]);
|
|
545
|
+
for (const r of u) {
|
|
546
|
+
const c = o.get(r), a = i.get(r);
|
|
547
|
+
if (c && a) {
|
|
548
|
+
if (c.conditions && a.conditions) {
|
|
549
|
+
const l = JSON.parse(c.conditions), d = JSON.parse(a.conditions);
|
|
550
|
+
if (!h(l) || !h(d)) {
|
|
551
|
+
JSON.stringify(l) !== JSON.stringify(d) && s.push(a);
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
const m = Object.keys(l)[0], f = l[m].$in.filter(
|
|
555
|
+
(g) => !d[m].$in.includes(g)
|
|
556
|
+
);
|
|
557
|
+
f.length > 0 && s.push(t(c, f)), d[m].$in.filter(
|
|
558
|
+
(g) => !l[m].$in.includes(g)
|
|
559
|
+
).length > 0 && s.push(a);
|
|
560
|
+
} else if (!c.conditions && a.conditions)
|
|
561
|
+
s.push(a);
|
|
562
|
+
else if (c.conditions && !a.conditions)
|
|
563
|
+
h(JSON.parse(c.conditions)) || s.push(a);
|
|
564
|
+
else if (!c.conditions && !a.conditions) {
|
|
565
|
+
const l = new Set(c.actions), d = new Set(a.actions), m = a.actions.some((p) => !l.has(p)), f = c.actions.filter((p) => !d.has(p));
|
|
566
|
+
if (m) {
|
|
567
|
+
const p = a.actions.filter((g) => !l.has(g));
|
|
568
|
+
s.push({
|
|
569
|
+
...a,
|
|
570
|
+
actions: p
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
f.length > 0 && s.push({
|
|
574
|
+
...c,
|
|
575
|
+
actions: f,
|
|
576
|
+
inverted: !0
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
if (c) {
|
|
582
|
+
s.push(
|
|
583
|
+
t(
|
|
584
|
+
c,
|
|
585
|
+
// If base has conditions, set diffIds to empty array, disallow all access to collection
|
|
586
|
+
// otherwise, invert directly
|
|
587
|
+
c.conditions && []
|
|
588
|
+
)
|
|
589
|
+
);
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
a && s.push(a);
|
|
593
|
+
}
|
|
594
|
+
return s;
|
|
595
|
+
}
|
|
596
|
+
function Oe(e) {
|
|
597
|
+
const n = G(
|
|
598
|
+
e,
|
|
599
|
+
V
|
|
600
|
+
), t = new Set(
|
|
601
|
+
n.filter((i) => {
|
|
602
|
+
var s;
|
|
603
|
+
return ((s = i.source) == null ? void 0 : s.type) === "systemPermissionSet" && !i.inverted;
|
|
604
|
+
}).map((i) => i.subject)
|
|
605
|
+
), o = new Set(
|
|
606
|
+
n.filter(
|
|
607
|
+
(i) => {
|
|
608
|
+
var s;
|
|
609
|
+
return ((s = i.source) == null ? void 0 : s.type) === "systemPermissionSet" && !i.inverted && i.actions.includes("manage");
|
|
610
|
+
}
|
|
611
|
+
).map((i) => i.subject)
|
|
612
|
+
);
|
|
613
|
+
return e.filter((i) => i.inverted ? !(t.has(i.subject) && !o.has(i.subject)) : !t.has(i.subject));
|
|
614
|
+
}
|
|
615
|
+
const ie = "business::report::";
|
|
616
|
+
function _e(e, n) {
|
|
617
|
+
const t = [], o = e.filter((i) => {
|
|
618
|
+
const s = i.subject;
|
|
619
|
+
return !s.startsWith(ie) || n.has(s) ? !0 : (t.push(s), !1);
|
|
620
|
+
});
|
|
621
|
+
return t.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", t), o;
|
|
622
|
+
}
|
|
623
|
+
const re = "business::report::reports::", ae = _.Subject.Business.report_reports_allDefaultReports, ce = _.Subject.Business.report_reports_allCustomReports;
|
|
624
|
+
function ue(e, n) {
|
|
625
|
+
return e.conditions ? !!n.conditions && e.conditions === n.conditions : !n.conditions;
|
|
626
|
+
}
|
|
627
|
+
function Ee(e, n) {
|
|
628
|
+
const t = e.find(
|
|
629
|
+
(u) => !u.inverted && u.subject === ae
|
|
630
|
+
), o = e.find(
|
|
631
|
+
(u) => !u.inverted && u.subject === ce
|
|
632
|
+
);
|
|
633
|
+
if (!t && !o) return e;
|
|
634
|
+
const i = t ? new Set(t.actions) : null, s = o ? new Set(o.actions) : null;
|
|
635
|
+
return e.reduce((u, r) => {
|
|
636
|
+
if (r.inverted)
|
|
637
|
+
return u.push(r), u;
|
|
638
|
+
const c = r.subject;
|
|
639
|
+
if (!c.startsWith(re))
|
|
640
|
+
return u.push(r), u;
|
|
641
|
+
const a = n.has(c), l = a ? i : s, d = a ? t : o;
|
|
642
|
+
if (!l || !d || !ue(d, r))
|
|
643
|
+
return u.push(r), u;
|
|
644
|
+
if (l.has("manage")) return u;
|
|
645
|
+
const m = new Set(r.actions), f = m.has("manage");
|
|
646
|
+
let p = !1;
|
|
647
|
+
for (const g of l)
|
|
648
|
+
g !== "manage" && m.delete(g) && (p = !0);
|
|
649
|
+
return f && p && m.delete("manage"), m.size === 0 || u.push({ ...r, actions: Array.from(m) }), u;
|
|
650
|
+
}, []);
|
|
651
|
+
}
|
|
652
|
+
function L(e, n) {
|
|
653
|
+
var o, i;
|
|
654
|
+
const t = new Map(e.map((s) => [s.subject, s]));
|
|
655
|
+
for (const s of n) {
|
|
656
|
+
if (s.inverted) {
|
|
657
|
+
const r = t.get(s.subject);
|
|
658
|
+
if (s.conditions) {
|
|
659
|
+
if (r != null && r.conditions) {
|
|
660
|
+
const c = JSON.parse(r.conditions), a = JSON.parse(s.conditions);
|
|
661
|
+
if (!h(c) || !h(a)) {
|
|
662
|
+
t.delete(s.subject);
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
const l = Object.keys(a)[0], d = ((o = a[l]) == null ? void 0 : o.$in) ?? [], f = (((i = c[l]) == null ? void 0 : i.$in) ?? []).filter((p) => !d.includes(p));
|
|
666
|
+
f.length > 0 ? t.set(s.subject, {
|
|
667
|
+
...r,
|
|
668
|
+
conditions: JSON.stringify({ [l]: { $in: f } })
|
|
669
|
+
}) : t.delete(s.subject);
|
|
670
|
+
} else
|
|
671
|
+
t.delete(s.subject);
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
if (r) {
|
|
675
|
+
const c = new Set(s.actions), a = r.actions.filter((l) => !c.has(l));
|
|
676
|
+
a.length > 0 ? t.set(s.subject, { ...r, actions: a }) : t.delete(s.subject);
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
if (s.conditions) {
|
|
682
|
+
t.set(s.subject, s);
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
const u = t.get(s.subject);
|
|
686
|
+
if (u != null && u.conditions && !h(JSON.parse(u.conditions))) {
|
|
687
|
+
t.set(s.subject, s);
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (u) {
|
|
691
|
+
const r = [
|
|
692
|
+
.../* @__PURE__ */ new Set([
|
|
693
|
+
...u.actions,
|
|
694
|
+
...s.actions
|
|
695
|
+
])
|
|
696
|
+
];
|
|
697
|
+
t.set(s.subject, { ...u, actions: r });
|
|
698
|
+
} else
|
|
699
|
+
t.set(s.subject, s);
|
|
700
|
+
}
|
|
701
|
+
return Array.from(t.values());
|
|
702
|
+
}
|
|
703
|
+
function le(e, n) {
|
|
704
|
+
const t = L(e, n), o = new Set(e.map((s) => s.subject)), i = n.filter(
|
|
705
|
+
(s) => s.inverted && !o.has(s.subject)
|
|
706
|
+
);
|
|
707
|
+
return [...t, ...i];
|
|
708
|
+
}
|
|
709
|
+
const P = "/permission-assignments", w = {
|
|
710
|
+
async readAll() {
|
|
711
|
+
return b(await v().get(P));
|
|
712
|
+
},
|
|
713
|
+
async readByUserId(e) {
|
|
714
|
+
return b(await v().get(`${P}/user/${e}`));
|
|
715
|
+
},
|
|
716
|
+
async readById(e) {
|
|
717
|
+
return b(await v().get(`${P}/${e}`));
|
|
718
|
+
},
|
|
719
|
+
async create(e) {
|
|
720
|
+
return b(await v().post(P, e));
|
|
721
|
+
},
|
|
722
|
+
async update(e, n) {
|
|
723
|
+
return b(await v().put(`${P}/${e}`, n));
|
|
724
|
+
},
|
|
725
|
+
async delete(e) {
|
|
726
|
+
return b(await v().delete(`${P}/${e}`));
|
|
727
|
+
},
|
|
728
|
+
async addReportManagePermission(e, n) {
|
|
729
|
+
return b(
|
|
730
|
+
await v().post("/my-permissions/report-manage", { permissionKey: e, label: n })
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
}, de = z("permissionAssignment", () => {
|
|
734
|
+
const e = S([]);
|
|
735
|
+
async function n() {
|
|
736
|
+
const r = await w.readAll();
|
|
737
|
+
e.value = r;
|
|
738
|
+
}
|
|
739
|
+
async function t(r) {
|
|
740
|
+
return await w.readByUserId(r);
|
|
741
|
+
}
|
|
742
|
+
async function o(r) {
|
|
743
|
+
const c = await w.create(r);
|
|
744
|
+
e.value = [...e.value, c];
|
|
745
|
+
}
|
|
746
|
+
async function i(r, c) {
|
|
747
|
+
const a = await w.update(r, c);
|
|
748
|
+
e.value = e.value.map((l) => l.id === r ? a : l);
|
|
749
|
+
}
|
|
750
|
+
async function s(r) {
|
|
751
|
+
await w.delete(r), e.value = e.value.filter((c) => c.id !== r);
|
|
752
|
+
}
|
|
753
|
+
function u(r) {
|
|
754
|
+
return e.value.find((c) => c.userId === r);
|
|
755
|
+
}
|
|
756
|
+
return {
|
|
757
|
+
permissionAssignments: e,
|
|
758
|
+
readPermissionAssignments: n,
|
|
759
|
+
readPermissionAssignmentByUserId: t,
|
|
760
|
+
createPermissionAssignment: o,
|
|
761
|
+
updatePermissionAssignment: i,
|
|
762
|
+
deletePermissionAssignment: s,
|
|
763
|
+
getPermissionAssignmentByUserId: u
|
|
764
|
+
};
|
|
765
|
+
}), me = () => {
|
|
766
|
+
const e = de();
|
|
767
|
+
return {
|
|
768
|
+
...e,
|
|
769
|
+
...K(e)
|
|
770
|
+
};
|
|
771
|
+
}, fe = {
|
|
772
|
+
async fetchReportPermissions(e, n) {
|
|
773
|
+
const t = n ? { lang: n } : {};
|
|
774
|
+
return b(
|
|
775
|
+
await F().get(`/report-query/hrm/${e}/reports`, { params: t })
|
|
776
|
+
);
|
|
777
|
+
},
|
|
778
|
+
async fetchReportPermissionsForPortal(e, n) {
|
|
779
|
+
const t = n ? { isSupportPos: !1, lang: n } : { isSupportPos: !1 };
|
|
780
|
+
return b(
|
|
781
|
+
await F().get(`/report-query/hrm/${e}/reports`, { params: t })
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
}, T = S([]), C = S(!1), R = S(!1), $ = S(null), x = S(null), J = S(!1);
|
|
785
|
+
function pe() {
|
|
786
|
+
const e = X();
|
|
787
|
+
async function n() {
|
|
788
|
+
var s;
|
|
789
|
+
const o = (s = e.currentBusiness.value) == null ? void 0 : s.id;
|
|
790
|
+
if (!o) return;
|
|
791
|
+
const i = localStorage.getItem("locale");
|
|
792
|
+
if ($.value !== o && (T.value = [], C.value = !1, R.value = !1, $.value = o, J.value = !1), !(C.value && x.value === i)) {
|
|
793
|
+
if (R.value) {
|
|
794
|
+
J.value = !0;
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
R.value = !0;
|
|
798
|
+
try {
|
|
799
|
+
const u = await fe.fetchReportPermissionsForPortal(o, i);
|
|
800
|
+
if ($.value !== o) return;
|
|
801
|
+
T.value = u, C.value = !0, x.value = i;
|
|
802
|
+
} catch (u) {
|
|
803
|
+
if ($.value !== o) return;
|
|
804
|
+
console.warn("Failed to fetch custom report permissions:", u), T.value = [];
|
|
805
|
+
} finally {
|
|
806
|
+
$.value === o && (R.value = !1, J.value && (J.value = !1, await n()));
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
const t = U(() => T.value.map(
|
|
811
|
+
(o) => o.isDefault ? {
|
|
812
|
+
label: o.name,
|
|
813
|
+
subject: `business::report::reports::${o.permissionKey}`,
|
|
814
|
+
actions: [j.manage, j.read, j.create],
|
|
815
|
+
category: k.reports
|
|
816
|
+
} : {
|
|
817
|
+
label: o.name,
|
|
818
|
+
subject: `business::report::reports::${o.permissionKey}`,
|
|
819
|
+
actions: [
|
|
820
|
+
j.manage,
|
|
821
|
+
j.read,
|
|
822
|
+
j.create,
|
|
823
|
+
j.update,
|
|
824
|
+
j.delete
|
|
825
|
+
],
|
|
826
|
+
category: k.customReports
|
|
827
|
+
}
|
|
828
|
+
));
|
|
829
|
+
return {
|
|
830
|
+
fetchCustomReportPermissions: n,
|
|
831
|
+
customReportPermissions: t,
|
|
832
|
+
isLoading: U(() => R.value),
|
|
833
|
+
isLoaded: U(() => C.value)
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
function I(e) {
|
|
837
|
+
const n = te(), t = me(), o = Z().restaurants, { customReportPermissions: i } = pe(), s = t.getPermissionAssignmentByUserId(e.id), u = H(
|
|
838
|
+
(s == null ? void 0 : s.permissionSetIds) ?? [],
|
|
839
|
+
n.permissionSets.value
|
|
840
|
+
), r = Q(u).map(
|
|
841
|
+
({ setNames: p, ...g }) => g
|
|
842
|
+
), c = s == null ? void 0 : s.customPermissions, a = c ?? e.permissions.map((p) => ({
|
|
843
|
+
...p,
|
|
844
|
+
subject: A(p.subject)
|
|
845
|
+
})), l = L(r, a), d = G(
|
|
846
|
+
le(r, a),
|
|
847
|
+
V
|
|
848
|
+
).filter((p) => !p.inverted), m = ve(d), f = m ?? o.value.map((p) => p._id);
|
|
849
|
+
return {
|
|
850
|
+
doc: e,
|
|
851
|
+
id: e.id,
|
|
852
|
+
name: e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
|
|
853
|
+
phoneNumber: e.phoneNumber,
|
|
854
|
+
email: e.email,
|
|
855
|
+
restaurants: W(
|
|
856
|
+
f.map((p) => {
|
|
857
|
+
var g;
|
|
858
|
+
return ((g = o.value.find((Y) => Y._id === p)) == null ? void 0 : g.profile.name) ?? "";
|
|
859
|
+
})
|
|
860
|
+
),
|
|
861
|
+
managableRestaurantIds: m,
|
|
862
|
+
permissionLabels: Se(d, i.value),
|
|
863
|
+
permissions: l
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
const be = Object.freeze(
|
|
867
|
+
Object.values(ee)
|
|
868
|
+
), Ne = {
|
|
869
|
+
async readTeamMembers() {
|
|
870
|
+
return b(
|
|
871
|
+
await v().get("/portal-users")
|
|
872
|
+
).map(I);
|
|
873
|
+
},
|
|
874
|
+
async readTeamMembersPage(e) {
|
|
875
|
+
var t, o, i;
|
|
876
|
+
const n = b(
|
|
877
|
+
await v().get("/portal-users/paged", {
|
|
878
|
+
params: {
|
|
879
|
+
limit: e.limit,
|
|
880
|
+
offset: e.offset,
|
|
881
|
+
search: e.search,
|
|
882
|
+
restaurantIds: (t = e.restaurantIds) != null && t.length ? e.restaurantIds : void 0,
|
|
883
|
+
permissionSubjects: (o = e.permissionSubjects) != null && o.length ? e.permissionSubjects : void 0,
|
|
884
|
+
permissionSetIds: (i = e.permissionSetIds) != null && i.length ? e.permissionSetIds : void 0
|
|
885
|
+
}
|
|
886
|
+
})
|
|
887
|
+
);
|
|
888
|
+
return {
|
|
889
|
+
items: n.items.map(I),
|
|
890
|
+
total: n.total
|
|
891
|
+
};
|
|
892
|
+
},
|
|
893
|
+
async readTeamMember(e) {
|
|
894
|
+
return I(
|
|
895
|
+
b(await v().get(`/portal-users/${e}`))
|
|
896
|
+
);
|
|
897
|
+
},
|
|
898
|
+
async createTeamMember(e) {
|
|
899
|
+
return I(
|
|
900
|
+
b(await v().post("/portal-users", e))
|
|
901
|
+
);
|
|
902
|
+
},
|
|
903
|
+
async updateTeamMember(e, n) {
|
|
904
|
+
return I(
|
|
905
|
+
b(await v().put(`/portal-users/${e}`, n))
|
|
906
|
+
);
|
|
907
|
+
},
|
|
908
|
+
async deleteTeamMember(e) {
|
|
909
|
+
return b(await v().delete(`/portal-users/${e}`));
|
|
910
|
+
},
|
|
911
|
+
async readTeamMemberPosUserIds() {
|
|
912
|
+
return b(await v().get("/portal-users")).map((n) => n.posUserId);
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
function Te(e, n, t) {
|
|
916
|
+
if (e.some((u) => u.subject === "all")) return "All";
|
|
917
|
+
const o = (t ?? M).filter(
|
|
918
|
+
(u) => u.subject === n
|
|
919
|
+
), i = new Set(o.map((u) => O(u).value)), s = e.filter((u) => u.subject === n).filter((u) => i.has(O(u).value));
|
|
920
|
+
return s.length === o.length ? "All" : s.length === 0 ? "-" : `${s.length} permission allow`;
|
|
921
|
+
}
|
|
922
|
+
function O(e) {
|
|
923
|
+
const n = q(e), t = n.subject;
|
|
924
|
+
return {
|
|
925
|
+
...n,
|
|
926
|
+
get conditions() {
|
|
927
|
+
return typeof n.conditions == "string" ? JSON.parse(n.conditions) : n.conditions;
|
|
928
|
+
},
|
|
929
|
+
get isDiscountOperation() {
|
|
930
|
+
var o;
|
|
931
|
+
return t === y.F_RULE_SUBJECT.enum.order && ((o = this.conditions) == null ? void 0 : o.operation) === y.F_RULE_ORDER_OPERATION.enum.discount;
|
|
932
|
+
},
|
|
933
|
+
get isOrderOperation() {
|
|
934
|
+
return t === y.F_RULE_SUBJECT.enum.order;
|
|
935
|
+
},
|
|
936
|
+
get isReportPermission() {
|
|
937
|
+
return t === y.F_RULE_SUBJECT.enum.report;
|
|
938
|
+
},
|
|
939
|
+
get formatted() {
|
|
940
|
+
const o = (i) => i.endsWith("_") ? i.slice(0, i.length - 1) : i;
|
|
941
|
+
return this.isOrderOperation ? o(this.conditions.operation) : this.isReportPermission ? o(this.conditions.name) : t.toString();
|
|
942
|
+
},
|
|
943
|
+
get label() {
|
|
944
|
+
return n.label || ne(this.formatted);
|
|
945
|
+
},
|
|
946
|
+
get value() {
|
|
947
|
+
return this.isOrderOperation ? `${t}:${this.conditions.operation}` : this.isReportPermission ? `${t}:${this.conditions.name}` : t.toString();
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
function Ce(e) {
|
|
952
|
+
const n = e.map((t) => O(t)).find((t) => t.isDiscountOperation);
|
|
953
|
+
return n ? parseInt((n.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
|
|
954
|
+
}
|
|
955
|
+
function ve(e) {
|
|
956
|
+
const n = e.find(
|
|
957
|
+
(t) => t.subject === _.Subject.Restaurant.restaurant
|
|
958
|
+
);
|
|
959
|
+
return n ? n.conditions ? JSON.parse(n.conditions).restaurantId.$in : null : [];
|
|
960
|
+
}
|
|
961
|
+
function Je(e) {
|
|
962
|
+
return (e == null ? void 0 : e.some((n) => n.subject === "all")) ?? !1;
|
|
963
|
+
}
|
|
964
|
+
function Ue(e) {
|
|
965
|
+
const n = e.find((t) => t.subject === _.Subject.Business.role);
|
|
966
|
+
return n ? n.conditions ? JSON.parse(n.conditions).roleId.$in : null : [];
|
|
967
|
+
}
|
|
968
|
+
function Be(e) {
|
|
969
|
+
const n = O(e);
|
|
970
|
+
if (!n.isReportPermission) return;
|
|
971
|
+
const { name: t, ...o } = n.conditions ?? {};
|
|
972
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
973
|
+
}
|
|
974
|
+
function Me(e, n, t) {
|
|
975
|
+
return e.map((o) => {
|
|
976
|
+
const i = ge(o), s = i.isReportPermission ? t == null ? void 0 : t.get(o) : void 0;
|
|
977
|
+
return {
|
|
978
|
+
subject: i.subject,
|
|
979
|
+
actions: i.actions,
|
|
980
|
+
conditions: {
|
|
981
|
+
...i.conditions,
|
|
982
|
+
...s ?? {},
|
|
983
|
+
adjustment: i.isDiscountOperation ? { $lte: parseFloat((n / 100).toFixed(2)) } : void 0
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
function ge(e) {
|
|
989
|
+
const [n, t] = e.split(":");
|
|
990
|
+
let o;
|
|
991
|
+
return t ? (o = M.find(
|
|
992
|
+
(i) => i.subject === n && [
|
|
993
|
+
(typeof i.conditions == "object" ? i.conditions : JSON.parse(i.conditions)).operation,
|
|
994
|
+
i.conditions.name
|
|
995
|
+
].includes(t)
|
|
996
|
+
), !o && n === y.F_RULE_SUBJECT.enum.report && (o = {
|
|
997
|
+
label: "",
|
|
998
|
+
subject: y.F_RULE_SUBJECT.enum.report,
|
|
999
|
+
actions: ["read"],
|
|
1000
|
+
conditions: { name: t },
|
|
1001
|
+
inverted: !1,
|
|
1002
|
+
reason: ""
|
|
1003
|
+
})) : o = M.find((i) => i.subject === n), O(o || { subject: y.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
|
|
1004
|
+
}
|
|
1005
|
+
function Se(e, n = []) {
|
|
1006
|
+
return W(
|
|
1007
|
+
e.reduce((t, o) => {
|
|
1008
|
+
const i = be.find(
|
|
1009
|
+
(s) => s.subject === o.subject && o.actions.includes("manage")
|
|
1010
|
+
) || n.find((s) => s.subject === o.subject);
|
|
1011
|
+
if (i) {
|
|
1012
|
+
const s = i.subject === _.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
|
|
1013
|
+
t.push(s);
|
|
1014
|
+
}
|
|
1015
|
+
return t;
|
|
1016
|
+
}, [])
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
export {
|
|
1020
|
+
G as N,
|
|
1021
|
+
Q as P,
|
|
1022
|
+
fe as R,
|
|
1023
|
+
Be as a,
|
|
1024
|
+
Te as b,
|
|
1025
|
+
H as c,
|
|
1026
|
+
le as d,
|
|
1027
|
+
M as e,
|
|
1028
|
+
Me as f,
|
|
1029
|
+
Ce as g,
|
|
1030
|
+
Je as h,
|
|
1031
|
+
pe as i,
|
|
1032
|
+
ie as j,
|
|
1033
|
+
Ue as k,
|
|
1034
|
+
ve as l,
|
|
1035
|
+
$e as m,
|
|
1036
|
+
_e as n,
|
|
1037
|
+
Ee as o,
|
|
1038
|
+
be as p,
|
|
1039
|
+
Ae as q,
|
|
1040
|
+
O as r,
|
|
1041
|
+
Oe as s,
|
|
1042
|
+
Ne as t,
|
|
1043
|
+
te as u,
|
|
1044
|
+
me as v,
|
|
1045
|
+
Se as w,
|
|
1046
|
+
Ie as x
|
|
1047
|
+
};
|