@agendize/vue-acl
Advanced tools
Comparing version 1.6.1 to 1.7.0
@@ -0,0 +0,0 @@ import { createAcl, useAcl } from "./vueAcl"; |
import type { Ability } from "../types/acl"; | ||
import { RightsEntity } from "@agendize/js-calendar-api"; | ||
export declare type AbilityObjectType = 'appointment' | 'staffAppointment' | 'company' | 'staff' | 'service' | 'client' | 'report' | 'queue' | 'form' | 'workflow' | 'planning' | 'workingPlanning' | 'conference'; | ||
export type AbilityObjectType = 'appointment' | 'staffAppointment' | 'company' | 'staff' | 'service' | 'client' | 'report' | 'queue' | 'form' | 'workflow' | 'planning' | 'workingPlanning' | 'conference'; | ||
export declare class AbilityResolver { | ||
@@ -5,0 +5,0 @@ static rightToAbilities(right: RightsEntity): Ability[]; |
@@ -56,28 +56,28 @@ import { reactive as M } from "vue"; | ||
r.options = e; | ||
function i(p, c, d, f) { | ||
switch (p) { | ||
function i(d, o, f, p) { | ||
switch (d) { | ||
case "can": | ||
u(c, d); | ||
u(o, f); | ||
break; | ||
case "role": | ||
A(c, d); | ||
A(o, f); | ||
break; | ||
} | ||
} | ||
function s(p, c, d, f, n, o) { | ||
p ? d ? c.style.display = "none" : c.style.display = "" : d ? c.style.display = "" : f ? c.disabled = !0 : n ? c.readOnly = !0 : c.style.display = "none"; | ||
function s(d, o, f, p, n, c) { | ||
d ? f ? o.style.display = "none" : o.style.display = "" : f ? o.style.display = "" : p ? o.disabled = !0 : n ? o.readOnly = !0 : o.style.display = "none"; | ||
} | ||
const u = (p, c, d) => { | ||
const f = c.arg, n = c.value, o = c.modifiers, a = !!o.any, l = !!o.not, h = !!o.readonly, g = !!(o.disable || o.disabled), y = !!(o.hide || o.hidden), L = F({ ability: f, args: n, any: a }); | ||
s(L, p, l, g, h, y); | ||
}, A = (p, c, d) => { | ||
const f = c.arg, n = c.modifiers, o = !!n.any, a = !!n.not, l = !!n.readonly, h = !!(n.disable || n.disabled), g = !!(n.hide || n.hidden), y = U({ roles: [f], any: o }); | ||
s(y, p, a, h, l, g); | ||
}, m = (p, c) => { | ||
p.directive(`${c}`, { | ||
mounted(d, f, n) { | ||
i(c, d, f); | ||
const u = (d, o, f) => { | ||
const p = o.arg, n = o.value, c = o.modifiers, a = !!c.any, l = !!c.not, h = !!c.readonly, g = !!(c.disable || c.disabled), y = !!(c.hide || c.hidden), L = F({ ability: p, args: n, any: a }); | ||
s(L, d, l, g, h, y); | ||
}, A = (d, o, f) => { | ||
const p = o.arg, n = o.modifiers, c = !!n.any, a = !!n.not, l = !!n.readonly, h = !!(n.disable || n.disabled), g = !!(n.hide || n.hidden), y = U({ roles: [p], any: c }); | ||
s(y, d, a, h, l, g); | ||
}, m = (d, o) => { | ||
d.directive(`${o}`, { | ||
mounted(f, p, n) { | ||
i(o, f, p); | ||
}, | ||
updated(d, f, n) { | ||
i(c, d, f); | ||
updated(f, p, n) { | ||
i(o, f, p); | ||
} | ||
@@ -87,33 +87,33 @@ }); | ||
if (t && (m(t, "can"), m(t, "role")), e.router) { | ||
let p = function(n, o) { | ||
let d = function(n, c) { | ||
let a; | ||
if (n.meta.can) { | ||
const l = n.meta.can; | ||
typeof l == "function" ? a = l(n, o, C) : a = C(l); | ||
typeof l == "function" ? a = l(n, c, C) : a = C(l); | ||
} else if (n.meta.canNot) { | ||
const l = n.meta.canNot; | ||
typeof l == "function" ? (Q(l), a = l(n, o, v)) : a = v(l); | ||
typeof l == "function" ? (Q(l), a = l(n, c, v)) : a = v(l); | ||
} else if (n.meta.canAny) { | ||
const l = n.meta.canAny; | ||
typeof l == "function" ? a = l(n, o, b) : a = b(l); | ||
typeof l == "function" ? a = l(n, c, b) : a = b(l); | ||
} else if (n.meta.canNone) { | ||
const l = n.meta.canNone; | ||
typeof l == "function" ? a = !l(n, o, b) : a = !b(l); | ||
typeof l == "function" ? a = !l(n, c, b) : a = !b(l); | ||
} | ||
return a; | ||
}, c = function(n) { | ||
let o; | ||
}, o = function(n) { | ||
let c; | ||
if (n.meta.role) { | ||
const a = n.meta.role; | ||
o = R(a); | ||
c = R(a); | ||
} else if (n.meta.roleNot) { | ||
const a = n.meta.roleNot; | ||
o = I(a); | ||
c = I(a); | ||
} else if (n.meta.roleAny) { | ||
const a = n.meta.roleAny; | ||
o = O(a); | ||
c = O(a); | ||
} | ||
return o; | ||
return c; | ||
}; | ||
const d = (n, o, a, l) => { | ||
const f = (n, c, a, l) => { | ||
if (l) | ||
@@ -123,5 +123,5 @@ a(); | ||
let h = e.onDeniedRoute; | ||
n.meta && n.meta.onDeniedRoute && (h = n.meta.onDeniedRoute), a(typeof h == "object" ? h : h === "$from" ? o : { path: `${h}`, replace: !0 }); | ||
n.meta && n.meta.onDeniedRoute && (h = n.meta.onDeniedRoute), a(typeof h == "object" ? h : h === "$from" ? c : { path: `${h}`, replace: !0 }); | ||
} | ||
}, f = (n, o, a) => { | ||
}, p = (n, c, a) => { | ||
if (!n.meta) { | ||
@@ -131,12 +131,12 @@ a(); | ||
} | ||
let l = p(n, o); | ||
let l = d(n, c); | ||
if (l === !1) { | ||
d(n, o, a, l); | ||
f(n, c, a, l); | ||
return; | ||
} | ||
l = c(n), l === void 0 ? a() : d(n, o, a, l); | ||
l = o(n), l === void 0 ? a() : f(n, c, a, l); | ||
}; | ||
r.options.router.beforeEach((n, o, a) => { | ||
r.options.router.beforeEach((n, c, a) => { | ||
W().then(() => { | ||
f(n, o, a); | ||
p(n, c, a); | ||
}); | ||
@@ -161,4 +161,4 @@ }); | ||
function D(t) { | ||
var i, s; | ||
return ((s = (i = t.rightIds) == null ? void 0 : i.map((u) => E(u))) != null ? s : []).filter((u) => !!u); | ||
var i; | ||
return (((i = t.rightIds) == null ? void 0 : i.map((s) => E(s))) ?? []).filter((s) => !!s); | ||
} | ||
@@ -222,4 +222,4 @@ function E(t) { | ||
return r.organisationEmail = e.organisation, r.userId = i, r.rolesType = D(e), (s = r.options.logger) == null || s.info("User roles", r.rolesType), r.abilities = [], r.companiesAbilities = /* @__PURE__ */ new Map(), e && e.rightIds && e.rightIds.length > 0 && (await r.options.api.getRights(e.organisation, e.rightIds)).forEach((m) => { | ||
var p, c; | ||
m.object && m.object.type ? m.object.type === "company" && ((p = r.companiesAbilities) == null || p.set(m.object.id, P.rightToAbilities(m))) : (c = r.abilities) == null || c.push(...P.rightToAbilities(m)); | ||
var d, o; | ||
m.object && m.object.type ? m.object.type === "company" && ((d = r.companiesAbilities) == null || d.set(m.object.id, P.rightToAbilities(m))) : (o = r.abilities) == null || o.push(...P.rightToAbilities(m)); | ||
}), B(), (u = r.options.logger) == null || u.info("User abilities", r.abilities, r.companiesAbilities), T = !0, Promise.resolve(); | ||
@@ -289,3 +289,3 @@ }, t.initStaffIds = (e) => { | ||
}, k = (t, e, i) => { | ||
var u, A, m, p, c, d; | ||
var u, A, m, d, o; | ||
const s = (u = r.abilities) == null ? void 0 : u.includes(t); | ||
@@ -297,8 +297,8 @@ if (s) | ||
if (z(t) === "company") { | ||
const n = (A = r.companiesAbilities) == null ? void 0 : A.get(e); | ||
if (n) | ||
return (t === "updateStaffAppointment" || t === "acceptStaffAppointment" || t === "readStaffAppointment" || t === "deleteStaffAppointment" || t === "statusChangeStaffAppointment") && n.includes(t) && i && typeof i == "string" ? (p = (m = r.staffIds) == null ? void 0 : m.includes(i)) != null ? p : !1 : n.includes(t); | ||
const p = (A = r.companiesAbilities) == null ? void 0 : A.get(e); | ||
if (p) | ||
return (t === "updateStaffAppointment" || t === "acceptStaffAppointment" || t === "readStaffAppointment" || t === "deleteStaffAppointment" || t === "statusChangeStaffAppointment") && p.includes(t) && i && typeof i == "string" ? ((m = r.staffIds) == null ? void 0 : m.includes(i)) ?? !1 : p.includes(t); | ||
} | ||
} else if (e.type === "company") { | ||
const f = (c = r.companiesAbilities) == null ? void 0 : c.get(e.id); | ||
const f = (d = r.companiesAbilities) == null ? void 0 : d.get(e.id); | ||
if (f) | ||
@@ -309,4 +309,4 @@ return f.includes(t); | ||
let f = !1; | ||
return (d = r.companiesAbilities) == null || d.forEach((n, o) => { | ||
n.includes(t) && (f = !0); | ||
return (o = r.companiesAbilities) == null || o.forEach((p, n) => { | ||
p.includes(t) && (f = !0); | ||
}), f; | ||
@@ -313,0 +313,0 @@ } |
@@ -0,0 +0,0 @@ import { Acl, PluginOption } from "./types/acl"; |
{ | ||
"name": "@agendize/vue-acl", | ||
"private": false, | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "Vue agendize's ACL management", | ||
@@ -46,11 +46,11 @@ "keywords": [ | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^3.2.0", | ||
"typescript": "4.7.4", | ||
"vite": "^3.1.8", | ||
"vite-plugin-dts": "^1.6.1", | ||
"vue": "3.3.13", | ||
"vue-router": "^4.2.5", | ||
"vue-tsc": "^0.29.8", | ||
"vitest": "^0.33.0", | ||
"@vitest/coverage-c8": "^0.33.0" | ||
"@vitejs/plugin-vue": "^5.0.4", | ||
"typescript": "^5.4.2", | ||
"vite": "^5.1.5", | ||
"vite-plugin-dts": "^3.7.3", | ||
"vue": "^3.4.21", | ||
"vue-router": "^4.3.0", | ||
"vue-tsc": "^2.0.6", | ||
"vitest": "^1.3.1", | ||
"@vitest/coverage-v8": "^1.3.1" | ||
}, | ||
@@ -57,0 +57,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17153
8
374