@builtwithjavascript/permissions
Advanced tools
| var p = Object.defineProperty; | ||
| var d = (t, s, e) => s in t ? p(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e; | ||
| var c = (t, s, e) => d(t, typeof s != "symbol" ? s + "" : s, e); | ||
| const a = Object.freeze({ | ||
| const a = { | ||
| View: 1, | ||
@@ -9,3 +9,3 @@ Add: 2, | ||
| Delete: 8 | ||
| }), y = class { | ||
| }, y = class { | ||
| static hasPermission(t, s) { | ||
@@ -60,3 +60,2 @@ return t === (s & t); | ||
| byExclusion(s) { | ||
| this.types; | ||
| const e = Object.getOwnPropertyNames(this.types).filter( | ||
@@ -63,0 +62,0 @@ (i) => s.indexOf(i) === -1 |
@@ -1,1 +0,1 @@ | ||
| (function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.permissions={}))})(this,function(t){"use strict";var y=Object.defineProperty;var m=(t,e,r)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const e=Object.freeze({View:1,Add:2,Update:4,Delete:8}),r=class{static hasPermission(d,s){return d===(s&d)}static extendTypes(d){const s={},i=Object.keys(e),n=e[i[0]];let o=Object.keys(e).length;return n===0&&(o-=1),d.forEach(c=>[s[c]=Math.pow(2,o++)]),Object.freeze({...e,...s})}};class u{constructor(s){p(this,"types");this.types=s}fromKeys(s){this.types;let i=0;return s.forEach(n=>{const o=this.types[n];i=i|o}),i}byExclusion(s){this.types;const i=Object.getOwnPropertyNames(this.types).filter(n=>s.indexOf(n)===-1);return this.fromKeys(i)}fromRange(s,i){this.types;const n=Object.getOwnPropertyNames(this.types);let o=0;return n.forEach(a=>{const c=this.types[a];c>=s&&c<=i&&(o=o|c)}),o}}class f{constructor(){p(this,"dataMap",new Map)}addPermissionsInfo(s){this.dataMap.set(s.id,s.permissions)}hasPermissions(s){const{id:i,domain:n,permissionType:o}=s;if(this.dataMap.has(i)){const a=this.dataMap.get(i);if(a&&a[n]){const c=a[n];return r.hasPermission(o,c)}}return!1}}t.PermissionType=e,t.Permissions=r,t.PermissionsBuilder=u,t.Security=f,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}); | ||
| (function(t,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(t=typeof globalThis<"u"?globalThis:t||self,s(t.permissions={}))})(this,function(t){"use strict";var y=Object.defineProperty;var m=(t,s,r)=>s in t?y(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var p=(t,s,r)=>m(t,typeof s!="symbol"?s+"":s,r);const s={View:1,Add:2,Update:4,Delete:8},r=class{static hasPermission(d,e){return d===(e&d)}static extendTypes(d){const e={},i=Object.keys(s),n=s[i[0]];let o=Object.keys(s).length;return n===0&&(o-=1),d.forEach(c=>[e[c]=Math.pow(2,o++)]),Object.freeze({...s,...e})}};class u{constructor(e){p(this,"types");this.types=e}fromKeys(e){this.types;let i=0;return e.forEach(n=>{const o=this.types[n];i=i|o}),i}byExclusion(e){const i=Object.getOwnPropertyNames(this.types).filter(n=>e.indexOf(n)===-1);return this.fromKeys(i)}fromRange(e,i){this.types;const n=Object.getOwnPropertyNames(this.types);let o=0;return n.forEach(a=>{const c=this.types[a];c>=e&&c<=i&&(o=o|c)}),o}}class f{constructor(){p(this,"dataMap",new Map)}addPermissionsInfo(e){this.dataMap.set(e.id,e.permissions)}hasPermissions(e){const{id:i,domain:n,permissionType:o}=e;if(this.dataMap.has(i)){const a=this.dataMap.get(i);if(a&&a[n]){const c=a[n];return r.hasPermission(o,c)}}return!1}}t.PermissionType=s,t.Permissions=r,t.PermissionsBuilder=u,t.Security=f,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}); |
@@ -13,7 +13,7 @@ /** | ||
| */ | ||
| export interface IPermissionType { | ||
| readonly View: number; | ||
| readonly Add: number; | ||
| readonly Update: number; | ||
| readonly Delete: number; | ||
| export interface IPermissionType extends Record<string, number> { | ||
| View: number; | ||
| Add: number; | ||
| Update: number; | ||
| Delete: number; | ||
| } | ||
@@ -20,0 +20,0 @@ /** |
+1
-1
| { | ||
| "name": "@builtwithjavascript/permissions", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "author": "Damiano Fusco", |
17054
-0.36%301
-0.33%