orion-design 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,6 @@
1
1
  import { Ref } from 'vue';
2
2
  import { CodeData } from '../components/types';
3
3
  export interface ThroneType {
4
- hasAuth: (authId: string) => boolean | null;
5
- getIcon: (iconId: string) => () => unknown;
6
4
  getCode: (codeName: string, context?: Record<string, any>) => Ref<CodeData>;
7
5
  impl: (throne: Partial<ThroneType>) => void;
8
6
  }
@@ -1,20 +1,14 @@
1
- import o from "../error/OrionError.js";
2
- let t = () => {
3
- throw new o("Throne.hasAuth not configured!");
4
- }, n = (e) => {
5
- throw new o("Throne.getIcon not configured!");
6
- }, r = (e) => {
7
- throw new o("Throne.getCode not configured!");
1
+ import t from "../error/OrionError.js";
2
+ let o = (e) => {
3
+ throw new t("Throne.getCode not configured!");
8
4
  };
9
- const u = {
10
- hasAuth: (e) => t(e),
11
- getIcon: (e) => n(e),
12
- getCode: (e, g) => r(e, g),
5
+ const n = {
6
+ getCode: (e, r) => o(e, r),
13
7
  impl: (e) => {
14
- e.hasAuth && (t = e.hasAuth), e.getIcon && (n = e.getIcon), e.getCode && (r = e.getCode);
8
+ e.getCode && (o = e.getCode);
15
9
  }
16
10
  };
17
11
  export {
18
- u as default
12
+ n as default
19
13
  };
20
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/Throne/index.ts"],"sourcesContent":["import OrionError from '../error/OrionError'\r\nimport type { Ref } from 'vue'\r\n\r\nimport type { CodeData } from '../components/types'\r\n\r\nexport interface ThroneType {\r\n hasAuth: (authId: string) => boolean | null\r\n getIcon: (iconId: string) => () => unknown\r\n getCode: (codeName: string, context?: Record<string, any>) => Ref<CodeData>\r\n impl: (throne: Partial<ThroneType>) => void\r\n}\r\n\r\nlet hasAuth: ThroneType['hasAuth'] = () => {\r\n throw new OrionError(`Throne.hasAuth not configured!`)\r\n}\r\n\r\nlet getIcon: ThroneType['getIcon'] = (iconId) => {\r\n throw new OrionError(`Throne.getIcon not configured!`)\r\n}\r\n\r\nlet getCode: ThroneType['getCode'] = (codeName) => {\r\n throw new OrionError(`Throne.getCode not configured!`)\r\n}\r\n\r\nconst Throne: ThroneType = {\r\n hasAuth: (authId) => {\r\n return hasAuth(authId)\r\n },\r\n getIcon: (iconId) => {\r\n return getIcon(iconId)\r\n },\r\n getCode: (codeName, context?: Record<string, any>) => {\r\n return getCode(codeName, context)\r\n },\r\n impl: (throne) => {\r\n if (throne.hasAuth) {\r\n hasAuth = throne.hasAuth\r\n }\r\n\r\n if (throne.getIcon) {\r\n getIcon = throne.getIcon\r\n }\r\n\r\n if (throne.getCode) {\r\n getCode = throne.getCode\r\n }\r\n },\r\n}\r\n\r\nexport default Throne\r\n"],"names":["hasAuth","OrionError","getIcon","iconId","getCode","codeName","Throne","authId","context","throne"],"mappings":";AAYA,IAAIA,IAAiC,MAAM;AACnC,QAAA,IAAIC,EAAW,gCAAgC;AACvD,GAEIC,IAAiC,CAACC,MAAW;AACzC,QAAA,IAAIF,EAAW,gCAAgC;AACvD,GAEIG,IAAiC,CAACC,MAAa;AAC3C,QAAA,IAAIJ,EAAW,gCAAgC;AACvD;AAEA,MAAMK,IAAqB;AAAA,EACzB,SAAS,CAACC,MACDP,EAAQO,CAAM;AAAA,EAEvB,SAAS,CAACJ,MACDD,EAAQC,CAAM;AAAA,EAEvB,SAAS,CAACE,GAAUG,MACXJ,EAAQC,GAAUG,CAAO;AAAA,EAElC,MAAM,CAACC,MAAW;AAChB,IAAIA,EAAO,YACTT,IAAUS,EAAO,UAGfA,EAAO,YACTP,IAAUO,EAAO,UAGfA,EAAO,YACTL,IAAUK,EAAO;AAAA,EAErB;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/Throne/index.ts"],"sourcesContent":["import OrionError from '../error/OrionError'\r\nimport type { Ref } from 'vue'\r\n\r\nimport type { CodeData } from '../components/types'\r\n\r\nexport interface ThroneType {\r\n getCode: (codeName: string, context?: Record<string, any>) => Ref<CodeData>\r\n impl: (throne: Partial<ThroneType>) => void\r\n}\r\n\r\nlet getCode: ThroneType['getCode'] = (codeName) => {\r\n throw new OrionError(`Throne.getCode not configured!`)\r\n}\r\n\r\nconst Throne: ThroneType = {\r\n getCode: (codeName, context?: Record<string, any>) => {\r\n return getCode(codeName, context)\r\n },\r\n impl: (throne) => {\r\n if (throne.getCode) {\r\n getCode = throne.getCode\r\n }\r\n },\r\n}\r\n\r\nexport default Throne\r\n"],"names":["getCode","codeName","OrionError","Throne","context","throne"],"mappings":";AAUA,IAAIA,IAAiC,CAACC,MAAa;AAC3C,QAAA,IAAIC,EAAW,gCAAgC;AACvD;AAEA,MAAMC,IAAqB;AAAA,EACzB,SAAS,CAACF,GAAUG,MACXJ,EAAQC,GAAUG,CAAO;AAAA,EAElC,MAAM,CAACC,MAAW;AAChB,IAAIA,EAAO,YACTL,IAAUK,EAAO;AAAA,EAErB;AACF;"}
@@ -0,0 +1,16 @@
1
+ interface AuthData {
2
+ permissionList: string[] | null;
3
+ roleList: string[] | null;
4
+ }
5
+ export declare const AuthConfig: {
6
+ setAuthData(data: AuthData): void;
7
+ };
8
+ export declare const p: (permission: string | string[], type?: "and" | "or") => boolean;
9
+ export declare const r: (role: string | string[], type?: "and" | "or") => boolean;
10
+ export declare function hasPermission(permission: string): boolean;
11
+ export declare function hasPermissionAnd(permissions: string[]): boolean;
12
+ export declare function hasPermissionOr(permissions: string[]): boolean;
13
+ export declare function hasRole(role: string): boolean;
14
+ export declare function hasRoleAnd(roles: string[]): boolean;
15
+ export declare function hasRoleOr(roles: string[]): boolean;
16
+ export {};
@@ -0,0 +1,49 @@
1
+ import { isString as f, isArray as u } from "lodash-es";
2
+ let e;
3
+ const c = {
4
+ setAuthData(t) {
5
+ e = t;
6
+ }
7
+ }, A = (t, r) => f(t) ? n(t) : u(t) ? r == "and" ? s(t) : l(t) : !1, d = (t, r) => f(t) ? i(t) : u(t) ? r == "and" ? a(t) : o(t) : !1;
8
+ function n(t) {
9
+ return !e || !e.permissionList ? !1 : e.permissionList.indexOf(t) > -1;
10
+ }
11
+ function s(t) {
12
+ for (let r = 0; r < t.length; r++)
13
+ if (!n(t[r]))
14
+ return !1;
15
+ return !0;
16
+ }
17
+ function l(t) {
18
+ for (let r = 0; r < t.length; r++)
19
+ if (n(t[r]))
20
+ return !0;
21
+ return !1;
22
+ }
23
+ function i(t) {
24
+ return !e || !e.roleList ? !1 : e.roleList.indexOf(t) > -1;
25
+ }
26
+ function a(t) {
27
+ for (let r = 0; r < t.length; r++)
28
+ if (!i(t[r]))
29
+ return !1;
30
+ return !0;
31
+ }
32
+ function o(t) {
33
+ for (let r = 0; r < t.length; r++)
34
+ if (n(t[r]))
35
+ return !0;
36
+ return !1;
37
+ }
38
+ export {
39
+ c as AuthConfig,
40
+ n as hasPermission,
41
+ s as hasPermissionAnd,
42
+ l as hasPermissionOr,
43
+ i as hasRole,
44
+ a as hasRoleAnd,
45
+ o as hasRoleOr,
46
+ A as p,
47
+ d as r
48
+ };
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/auth/index.ts"],"sourcesContent":["import { isArray, isString } from 'lodash-es'\r\n\r\ninterface AuthData {\r\n permissionList: string[] | null\r\n roleList: string[] | null\r\n}\r\n\r\nlet AUTH_DATA: AuthData\r\n\r\nexport const AuthConfig = {\r\n setAuthData(data: AuthData) {\r\n AUTH_DATA = data\r\n },\r\n}\r\n\r\nexport const p = (permission: string | string[], type?: 'and' | 'or') => {\r\n if (isString(permission)) {\r\n return hasPermission(permission)\r\n } else if (isArray(permission)) {\r\n if (type == 'and') {\r\n return hasPermissionAnd(permission)\r\n } else {\r\n return hasPermissionOr(permission)\r\n }\r\n }\r\n\r\n return false\r\n}\r\n\r\nexport const r = (role: string | string[], type?: 'and' | 'or') => {\r\n if (isString(role)) {\r\n return hasRole(role)\r\n } else if (isArray(role)) {\r\n if (type == 'and') {\r\n return hasRoleAnd(role)\r\n } else {\r\n return hasRoleOr(role)\r\n }\r\n }\r\n\r\n return false\r\n}\r\n\r\nexport function hasPermission(permission: string) {\r\n if (!AUTH_DATA || !AUTH_DATA.permissionList) {\r\n return false\r\n }\r\n\r\n return AUTH_DATA.permissionList.indexOf(permission) > -1\r\n}\r\n\r\nexport function hasPermissionAnd(permissions: string[]) {\r\n for (let i = 0; i < permissions.length; i++) {\r\n if (!hasPermission(permissions[i])) {\r\n return false\r\n }\r\n }\r\n\r\n return true\r\n}\r\n\r\nexport function hasPermissionOr(permissions: string[]) {\r\n for (let i = 0; i < permissions.length; i++) {\r\n if (hasPermission(permissions[i])) {\r\n return true\r\n }\r\n }\r\n\r\n return false\r\n}\r\n\r\nexport function hasRole(role: string) {\r\n if (!AUTH_DATA || !AUTH_DATA.roleList) {\r\n return false\r\n }\r\n\r\n return AUTH_DATA.roleList.indexOf(role) > -1\r\n}\r\n\r\nexport function hasRoleAnd(roles: string[]) {\r\n for (let i = 0; i < roles.length; i++) {\r\n if (!hasRole(roles[i])) {\r\n return false\r\n }\r\n }\r\n\r\n return true\r\n}\r\n\r\nexport function hasRoleOr(roles: string[]) {\r\n for (let i = 0; i < roles.length; i++) {\r\n if (hasPermission(roles[i])) {\r\n return true\r\n }\r\n }\r\n\r\n return false\r\n}\r\n"],"names":["AUTH_DATA","AuthConfig","data","p","permission","type","isString","hasPermission","isArray","hasPermissionAnd","hasPermissionOr","r","role","hasRole","hasRoleAnd","hasRoleOr","permissions","i","roles"],"mappings":";AAOA,IAAIA;AAEG,MAAMC,IAAa;AAAA,EACxB,YAAYC,GAAgB;AACd,IAAAF,IAAAE;AAAA,EACd;AACF,GAEaC,IAAI,CAACC,GAA+BC,MAC3CC,EAASF,CAAU,IACdG,EAAcH,CAAU,IACtBI,EAAQJ,CAAU,IACvBC,KAAQ,QACHI,EAAiBL,CAAU,IAE3BM,EAAgBN,CAAU,IAI9B,IAGIO,IAAI,CAACC,GAAyBP,MACrCC,EAASM,CAAI,IACRC,EAAQD,CAAI,IACVJ,EAAQI,CAAI,IACjBP,KAAQ,QACHS,EAAWF,CAAI,IAEfG,EAAUH,CAAI,IAIlB;AAGF,SAASL,EAAcH,GAAoB;AAChD,SAAI,CAACJ,KAAa,CAACA,EAAU,iBACpB,KAGFA,EAAU,eAAe,QAAQI,CAAU,IAAI;AACxD;AAEO,SAASK,EAAiBO,GAAuB;AACtD,WAASC,IAAI,GAAGA,IAAID,EAAY,QAAQC;AACtC,QAAI,CAACV,EAAcS,EAAYC,CAAC,CAAC;AACxB,aAAA;AAIJ,SAAA;AACT;AAEO,SAASP,EAAgBM,GAAuB;AACrD,WAASC,IAAI,GAAGA,IAAID,EAAY,QAAQC;AACtC,QAAIV,EAAcS,EAAYC,CAAC,CAAC;AACvB,aAAA;AAIJ,SAAA;AACT;AAEO,SAASJ,EAAQD,GAAc;AACpC,SAAI,CAACZ,KAAa,CAACA,EAAU,WACpB,KAGFA,EAAU,SAAS,QAAQY,CAAI,IAAI;AAC5C;AAEO,SAASE,EAAWI,GAAiB;AAC1C,WAASD,IAAI,GAAGA,IAAIC,EAAM,QAAQD;AAChC,QAAI,CAACJ,EAAQK,EAAMD,CAAC,CAAC;AACZ,aAAA;AAIJ,SAAA;AACT;AAEO,SAASF,EAAUG,GAAiB;AACzC,WAASD,IAAI,GAAGA,IAAIC,EAAM,QAAQD;AAChC,QAAIV,EAAcW,EAAMD,CAAC,CAAC;AACjB,aAAA;AAIJ,SAAA;AACT;"}
@@ -1,2 +1,2 @@
1
- declare const _default: "1.0.5";
1
+ declare const _default: "1.0.6";
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
- const e = "1.0.5";
1
+ const e = "1.0.6";
2
2
  export {
3
3
  e as default
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../src/version/version.ts"],"sourcesContent":["export default '1.0.5';"],"names":["version"],"mappings":"AAAA,MAAAA,IAAe;"}
1
+ {"version":3,"file":"version.js","sources":["../../src/version/version.ts"],"sourcesContent":["export default '1.0.6';"],"names":["version"],"mappings":"AAAA,MAAAA,IAAe;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orion-design",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",