@nu-art/permissions-frontend 0.400.5
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/PermissionKey_FE.d.ts +25 -0
- package/PermissionKey_FE.js +23 -0
- package/_entity/permission-access-level/ModuleFE_PermissionAccessLevel.d.ts +11 -0
- package/_entity/permission-access-level/ModuleFE_PermissionAccessLevel.js +12 -0
- package/_entity/permission-access-level/index.d.ts +2 -0
- package/_entity/permission-access-level/index.js +2 -0
- package/_entity/permission-access-level/module-pack.d.ts +1 -0
- package/_entity/permission-access-level/module-pack.js +2 -0
- package/_entity/permission-access-level/shared.d.ts +1 -0
- package/_entity/permission-access-level/shared.js +1 -0
- package/_entity/permission-access-level/ui-components.d.ts +37 -0
- package/_entity/permission-access-level/ui-components.js +21 -0
- package/_entity/permission-api/ModuleFE_PermissionAPI.d.ts +11 -0
- package/_entity/permission-api/ModuleFE_PermissionAPI.js +12 -0
- package/_entity/permission-api/index.d.ts +2 -0
- package/_entity/permission-api/index.js +2 -0
- package/_entity/permission-api/module-pack.d.ts +1 -0
- package/_entity/permission-api/module-pack.js +2 -0
- package/_entity/permission-api/shared.d.ts +1 -0
- package/_entity/permission-api/shared.js +1 -0
- package/_entity/permission-api/ui-components.d.ts +37 -0
- package/_entity/permission-api/ui-components.js +21 -0
- package/_entity/permission-domain/ModuleFE_PermissionDomain.d.ts +9 -0
- package/_entity/permission-domain/ModuleFE_PermissionDomain.js +10 -0
- package/_entity/permission-domain/index.d.ts +2 -0
- package/_entity/permission-domain/index.js +2 -0
- package/_entity/permission-domain/module-pack.d.ts +1 -0
- package/_entity/permission-domain/module-pack.js +2 -0
- package/_entity/permission-domain/shared.d.ts +1 -0
- package/_entity/permission-domain/shared.js +1 -0
- package/_entity/permission-domain/ui-components.d.ts +37 -0
- package/_entity/permission-domain/ui-components.js +21 -0
- package/_entity/permission-group/ModuleFE_PermissionGroup.d.ts +11 -0
- package/_entity/permission-group/ModuleFE_PermissionGroup.js +12 -0
- package/_entity/permission-group/index.d.ts +2 -0
- package/_entity/permission-group/index.js +2 -0
- package/_entity/permission-group/module-pack.d.ts +1 -0
- package/_entity/permission-group/module-pack.js +2 -0
- package/_entity/permission-group/shared.d.ts +1 -0
- package/_entity/permission-group/shared.js +1 -0
- package/_entity/permission-group/ui-components.d.ts +37 -0
- package/_entity/permission-group/ui-components.js +21 -0
- package/_entity/permission-project/ModuleFE_PermissionProject.d.ts +11 -0
- package/_entity/permission-project/ModuleFE_PermissionProject.js +12 -0
- package/_entity/permission-project/index.d.ts +2 -0
- package/_entity/permission-project/index.js +2 -0
- package/_entity/permission-project/module-pack.d.ts +1 -0
- package/_entity/permission-project/module-pack.js +2 -0
- package/_entity/permission-project/shared.d.ts +1 -0
- package/_entity/permission-project/shared.js +1 -0
- package/_entity/permission-project/ui-components.d.ts +37 -0
- package/_entity/permission-project/ui-components.js +21 -0
- package/_entity/permission-user/ModuleFE_PermissionUser.d.ts +11 -0
- package/_entity/permission-user/ModuleFE_PermissionUser.js +14 -0
- package/_entity/permission-user/index.d.ts +2 -0
- package/_entity/permission-user/index.js +2 -0
- package/_entity/permission-user/module-pack.d.ts +1 -0
- package/_entity/permission-user/module-pack.js +2 -0
- package/_entity/permission-user/shared.d.ts +1 -0
- package/_entity/permission-user/shared.js +1 -0
- package/_entity/permission-user/ui-components.d.ts +37 -0
- package/_entity/permission-user/ui-components.js +36 -0
- package/_entity.d.ts +12 -0
- package/_entity.js +18 -0
- package/consts.d.ts +4 -0
- package/consts.js +3 -0
- package/core/module-pack.d.ts +2 -0
- package/core/module-pack.js +29 -0
- package/core/permission-keys.d.ts +4 -0
- package/core/permission-keys.js +5 -0
- package/index.d.ts +5 -0
- package/index.js +23 -0
- package/modules/ModuleFE_PermissionsAssert.d.ts +32 -0
- package/modules/ModuleFE_PermissionsAssert.js +80 -0
- package/package.json +84 -0
- package/shared.d.ts +1 -0
- package/shared.js +19 -0
- package/ui/ATS_ComponentPermissionKeys/ATS_ComponentPermissionKeys.d.ts +11 -0
- package/ui/ATS_ComponentPermissionKeys/ATS_ComponentPermissionKeys.js +22 -0
- package/ui/ATS_ComponentPermissionKeys/permission-keys-editor.scss +153 -0
- package/ui/ATS_ComponentPermissionKeys/subEditors/Component_AccessLevelsEditor.d.ts +16 -0
- package/ui/ATS_ComponentPermissionKeys/subEditors/Component_AccessLevelsEditor.js +38 -0
- package/ui/ATS_ComponentPermissionKeys/subEditors/permission-keys-editor.d.ts +16 -0
- package/ui/ATS_ComponentPermissionKeys/subEditors/permission-keys-editor.js +33 -0
- package/ui/ATS_Permissions/ATS_Permissions.d.ts +8 -0
- package/ui/ATS_Permissions/ATS_Permissions.js +63 -0
- package/ui/ATS_Permissions/ATS_Permissions.scss +172 -0
- package/ui/Component_SwitchView.d.ts +23 -0
- package/ui/Component_SwitchView.js +32 -0
- package/ui/Component_SwitchViewV2.d.ts +21 -0
- package/ui/Component_SwitchViewV2.js +25 -0
- package/ui/PermissionsComponent.d.ts +21 -0
- package/ui/PermissionsComponent.js +42 -0
- package/ui/PermissionsEditableComponent.d.ts +18 -0
- package/ui/PermissionsEditableComponent.js +21 -0
- package/ui/Renderer_RoleNames.d.ts +1 -0
- package/ui/Renderer_RoleNames.js +7 -0
- package/ui/index.d.ts +8 -0
- package/ui/index.js +8 -0
- package/ui/permission-editors/components.d.ts +6 -0
- package/ui/permission-editors/components.js +9 -0
- package/ui/permission-editors/editor-base.d.ts +18 -0
- package/ui/permission-editors/editor-base.js +17 -0
- package/ui/permission-editors/editor-base.scss +298 -0
- package/ui/permission-editors/permission-api-edior/permission-api-editor.d.ts +16 -0
- package/ui/permission-editors/permission-api-edior/permission-api-editor.js +63 -0
- package/ui/permission-editors/permission-api-edior/permission-api-editor.scss +7 -0
- package/ui/permission-editors/permission-domains-editor.d.ts +9 -0
- package/ui/permission-editors/permission-domains-editor.js +139 -0
- package/ui/permission-editors/permission-groups-editor.d.ts +9 -0
- package/ui/permission-editors/permission-groups-editor.js +80 -0
- package/ui/permission-editors/permission-project-editor/permission-project-editor.scss +10 -0
- package/ui/permission-editors/permission-project-editor/permission-projects-editor.d.ts +10 -0
- package/ui/permission-editors/permission-project-editor/permission-projects-editor.js +52 -0
- package/ui/permission-editors/permission-users-editor.d.ts +9 -0
- package/ui/permission-editors/permission-users-editor.js +48 -0
- package/ui/ui-props.d.ts +16 -0
- package/ui/ui-props.js +62 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleFE_BaseApi } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
import { ApiDefCaller } from '@nu-art/thunderstorm-shared';
|
|
3
|
+
import { DispatcherDef, ThunderDispatcherV3 } from '@nu-art/thunderstorm-frontend/core/db-api-gen/types';
|
|
4
|
+
import { ApiStruct_PermissionUser, DBProto_PermissionUser } from '@nu-art/permissions-shared';
|
|
5
|
+
export type DispatcherType_PermissionUser = DispatcherDef<DBProto_PermissionUser, `__onPermissionUserUpdated`>;
|
|
6
|
+
export declare const dispatch_onPermissionUserChanged: ThunderDispatcherV3<DispatcherType_PermissionUser>;
|
|
7
|
+
export declare class ModuleFE_PermissionUser_Class extends ModuleFE_BaseApi<DBProto_PermissionUser> implements ApiDefCaller<ApiStruct_PermissionUser> {
|
|
8
|
+
_v1: ApiDefCaller<ApiStruct_PermissionUser>['_v1'];
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
export declare const ModuleFE_PermissionUser: ModuleFE_PermissionUser_Class;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { apiWithBody, ModuleFE_BaseApi } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
import { ThunderDispatcherV3 } from '@nu-art/thunderstorm-frontend/core/db-api-gen/types';
|
|
3
|
+
import { ApiDef_PermissionUser, DBDef_PermissionUser } from '@nu-art/permissions-shared';
|
|
4
|
+
export const dispatch_onPermissionUserChanged = new ThunderDispatcherV3('__onPermissionUserUpdated');
|
|
5
|
+
export class ModuleFE_PermissionUser_Class extends ModuleFE_BaseApi {
|
|
6
|
+
_v1;
|
|
7
|
+
constructor() {
|
|
8
|
+
super(DBDef_PermissionUser, dispatch_onPermissionUserChanged);
|
|
9
|
+
this._v1 = {
|
|
10
|
+
assignPermissions: apiWithBody(ApiDef_PermissionUser._v1.assignPermissions),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const ModuleFE_PermissionUser = new ModuleFE_PermissionUser_Class();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ModulePackFE_PermissionUser: import("./ModuleFE_PermissionUser.js").ModuleFE_PermissionUser_Class[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@nu-art/permissions-shared';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@nu-art/permissions-shared';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const DropDown_PermissionUser: {
|
|
2
|
+
editable: (props: import("@nu-art/thunderstorm-frontend/components/types").ComponentProps_Error & {
|
|
3
|
+
dropdownRef?: import("react").RefObject<any>;
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: import("react").CSSProperties;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
mapper?: ((item: import("@nu-art/permissions-shared").DB_PermissionUser) => (string | undefined)[]) | undefined;
|
|
8
|
+
noOptionsRenderer?: import("react").ReactNode | ((filter?: string) => import("react").ReactNode);
|
|
9
|
+
renderer?: ((item: import("@nu-art/permissions-shared").DB_PermissionUser) => import("react").ReactElement) | undefined;
|
|
10
|
+
ifNoneShowAll?: boolean;
|
|
11
|
+
caret?: {
|
|
12
|
+
open: import("react").ReactNode;
|
|
13
|
+
close: import("react").ReactNode;
|
|
14
|
+
};
|
|
15
|
+
onNoMatchingSelectionForString?: ((filterText: string, matchingItems: import("@nu-art/permissions-shared").DB_PermissionUser[], e: import("react").KeyboardEvent) => any) | undefined;
|
|
16
|
+
limitItems?: number;
|
|
17
|
+
hidePlaceholderOnOpen?: boolean;
|
|
18
|
+
itemResolver?: (() => import("@nu-art/permissions-shared").DB_PermissionUser[]) | undefined;
|
|
19
|
+
innerRef?: import("react").RefObject<any>;
|
|
20
|
+
tabIndex?: number;
|
|
21
|
+
unselectLabel?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
queryFilter?: ((item: import("@nu-art/permissions-shared").DB_PermissionUser) => boolean) | undefined;
|
|
24
|
+
sortBy?: ("groups" | "_id" | "__metadata1" | "__hardDelete" | "__created" | "__updated" | "_v" | "_originDocId" | "_auditorId" | "__groupIds" | ((item: import("@nu-art/permissions-shared").DB_PermissionUser) => string | number))[] | undefined;
|
|
25
|
+
} & {
|
|
26
|
+
inputValue?: string;
|
|
27
|
+
boundingParentSelector?: string;
|
|
28
|
+
renderSearch?: ((dropDown: import("@nu-art/thunderstorm-frontend/index").TS_DropDown<import("@nu-art/permissions-shared").DB_PermissionUser>) => import("react").ReactNode) | undefined;
|
|
29
|
+
limitItems?: number;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
} & import("@nu-art/thunderstorm-frontend/index").UIProps_EditableItem<any, any, string> & {
|
|
32
|
+
onSelected?: ((selected: import("@nu-art/permissions-shared").DB_PermissionUser | undefined, superOnSelected: (selected?: import("@nu-art/permissions-shared").DB_PermissionUser | undefined) => Promise<void>) => void) | undefined;
|
|
33
|
+
canUnselect?: boolean;
|
|
34
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
selectable: (props: import("@nu-art/thunderstorm-frontend/index").AppLevelProps_TS_GenericDropDownV3<import("@nu-art/permissions-shared").DB_PermissionUser>) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
};
|
|
37
|
+
export declare const MultiSelect_PermissionUser: <EnclosingItem_, Prop extends import("@nu-art/ts-common").SubsetKeys<keyof EnclosingItem_, EnclosingItem_, string[] | undefined>>(props: import("@nu-art/thunderstorm-frontend/index").DynamicProps_TS_MultiSelect_V2<EnclosingItem_, Prop> & Partial<import("@nu-art/thunderstorm-frontend/index").StaticProps_TS_MultiSelect_V2<string>>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GenericDropDownV3, TS_MultiSelect_V2 } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { ModuleFE_PermissionUser } from './ModuleFE_PermissionUser.js';
|
|
4
|
+
import { DBItemDropDownMultiSelector } from '@nu-art/thunderstorm-frontend/components/_TS_MultiSelect/DBItemDropDownMultiSelector';
|
|
5
|
+
import { ModuleFE_Account } from '@nu-art/user-account-frontend/index';
|
|
6
|
+
import { MUSTNeverHappenException } from '@nu-art/ts-common';
|
|
7
|
+
import { TS_Icons } from '@nu-art/ts-styles';
|
|
8
|
+
const Props_DropDown = {
|
|
9
|
+
module: ModuleFE_PermissionUser,
|
|
10
|
+
modules: [ModuleFE_PermissionUser],
|
|
11
|
+
mapper: item => {
|
|
12
|
+
const account = ModuleFE_Account.cache.unique(item._id);
|
|
13
|
+
if (!account)
|
|
14
|
+
throw new MUSTNeverHappenException(`Could not find account connected to permission-user with id ${item._id}`);
|
|
15
|
+
return [account.email];
|
|
16
|
+
},
|
|
17
|
+
placeholder: 'Choose a PermissionUser',
|
|
18
|
+
renderer: item => {
|
|
19
|
+
const account = ModuleFE_Account.cache.unique(item._id);
|
|
20
|
+
if (!account)
|
|
21
|
+
throw new MUSTNeverHappenException(`Could not find account connected to permission-user with id ${item._id}`);
|
|
22
|
+
return _jsxs("div", { className: "ll_h_c", children: [" ", account.email, " "] });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export const DropDown_PermissionUser = GenericDropDownV3.prepare(Props_DropDown);
|
|
26
|
+
const Props_MultiSelect = DBItemDropDownMultiSelector.propsV3({
|
|
27
|
+
module: ModuleFE_PermissionUser,
|
|
28
|
+
itemRenderer: (item, onDelete) => {
|
|
29
|
+
const account = ModuleFE_Account.cache.unique(item?._id);
|
|
30
|
+
if (item?._id && !account)
|
|
31
|
+
throw new MUSTNeverHappenException(`Could not find account connected to permission-user with id ${item?._id}`);
|
|
32
|
+
return !account ? _jsx(_Fragment, { children: "Not Found" }) : _jsxs(_Fragment, { children: [_jsx(TS_Icons.x.component, { onClick: onDelete, className: 'ts-icon__small' }), account.email] });
|
|
33
|
+
},
|
|
34
|
+
uiSelector: DropDown_PermissionUser.selectable,
|
|
35
|
+
});
|
|
36
|
+
export const MultiSelect_PermissionUser = TS_MultiSelect_V2.prepare(Props_MultiSelect);
|
package/_entity.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './_entity/permission-access-level/index.js';
|
|
2
|
+
export * from './_entity/permission-access-level/index.js';
|
|
3
|
+
export * from './_entity/permission-api/index.js';
|
|
4
|
+
export * from './_entity/permission-api/index.js';
|
|
5
|
+
export * from './_entity/permission-project/index.js';
|
|
6
|
+
export * from './_entity/permission-project/index.js';
|
|
7
|
+
export * from './_entity/permission-domain/index.js';
|
|
8
|
+
export * from './_entity/permission-domain/index.js';
|
|
9
|
+
export * from './_entity/permission-group/index.js';
|
|
10
|
+
export * from './_entity/permission-group/index.js';
|
|
11
|
+
export * from './_entity/permission-user/index.js';
|
|
12
|
+
export * from './_entity/permission-user/index.js';
|
package/_entity.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//Access Level
|
|
2
|
+
export * from './_entity/permission-access-level/index.js';
|
|
3
|
+
export * from './_entity/permission-access-level/index.js';
|
|
4
|
+
//API
|
|
5
|
+
export * from './_entity/permission-api/index.js';
|
|
6
|
+
export * from './_entity/permission-api/index.js';
|
|
7
|
+
//Project
|
|
8
|
+
export * from './_entity/permission-project/index.js';
|
|
9
|
+
export * from './_entity/permission-project/index.js';
|
|
10
|
+
//Domain
|
|
11
|
+
export * from './_entity/permission-domain/index.js';
|
|
12
|
+
export * from './_entity/permission-domain/index.js';
|
|
13
|
+
//Group
|
|
14
|
+
export * from './_entity/permission-group/index.js';
|
|
15
|
+
export * from './_entity/permission-group/index.js';
|
|
16
|
+
//User
|
|
17
|
+
export * from './_entity/permission-user/index.js';
|
|
18
|
+
export * from './_entity/permission-user/index.js';
|
package/consts.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SessionData_Permissions, SessionData_StrictMode } from '@nu-art/permissions-shared';
|
|
2
|
+
import { SessionKey_FE } from '@nu-art/user-account-frontend';
|
|
3
|
+
export declare const SessionKey_Permissions_FE: SessionKey_FE<SessionData_Permissions>;
|
|
4
|
+
export declare const SessionKey_StrictMode_FE: SessionKey_FE<SessionData_StrictMode>;
|
package/consts.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Permissions management system, define access level for each of
|
|
3
|
+
* your server apis, and restrict users by giving them access levels
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { ModuleFE_PermissionsAssert } from '../modules/ModuleFE_PermissionsAssert.js';
|
|
20
|
+
import { ModulePackFE_PermissionAccessLevel, ModulePackFE_PermissionAPI, ModulePackFE_PermissionDomain, ModulePackFE_PermissionGroup, ModulePackFE_PermissionProject, ModulePackFE_PermissionUser } from '../_entity.js';
|
|
21
|
+
export const ModulePackFE_Permissions = [
|
|
22
|
+
ModuleFE_PermissionsAssert,
|
|
23
|
+
...ModulePackFE_PermissionAccessLevel,
|
|
24
|
+
...ModulePackFE_PermissionAPI,
|
|
25
|
+
...ModulePackFE_PermissionProject,
|
|
26
|
+
...ModulePackFE_PermissionDomain,
|
|
27
|
+
...ModulePackFE_PermissionGroup,
|
|
28
|
+
...ModulePackFE_PermissionUser,
|
|
29
|
+
];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PermissionKey_FE } from '../PermissionKey_FE.js';
|
|
2
|
+
export declare const PermissionKeyFE_DeveloperViewer: PermissionKey_FE<"permission-key--developer-viewer">;
|
|
3
|
+
export declare const PermissionKeyFE_DeveloperEditor: PermissionKey_FE<"permission-key--developer-editor">;
|
|
4
|
+
export declare const PermissionKeyFE_DeveloperAdmin: PermissionKey_FE<"permission-key--developer-admin">;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PermissionKey_FE } from '../PermissionKey_FE.js';
|
|
2
|
+
import { PermissionKey_DeveloperAdmin, PermissionKey_DeveloperViewer, PermissionKey_DeveloperWriter } from '@nu-art/permissions-shared';
|
|
3
|
+
export const PermissionKeyFE_DeveloperViewer = new PermissionKey_FE(PermissionKey_DeveloperViewer);
|
|
4
|
+
export const PermissionKeyFE_DeveloperEditor = new PermissionKey_FE(PermissionKey_DeveloperWriter);
|
|
5
|
+
export const PermissionKeyFE_DeveloperAdmin = new PermissionKey_FE(PermissionKey_DeveloperAdmin);
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Permissions management system, define access level for each of
|
|
3
|
+
* your server apis, and restrict users by giving them access levels
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
export * from './PermissionKey_FE.js';
|
|
20
|
+
export * from './core/module-pack.js';
|
|
21
|
+
export * from './ui/index.js';
|
|
22
|
+
export * from './consts.js';
|
|
23
|
+
export * from './_entity.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Module, TypedMap } from '@nu-art/ts-common';
|
|
2
|
+
import { PermissionKey_FE } from '../PermissionKey_FE.js';
|
|
3
|
+
export type PermissionsModuleFEConfig = {
|
|
4
|
+
projectId: string;
|
|
5
|
+
};
|
|
6
|
+
export interface OnPermissionsChanged {
|
|
7
|
+
__onPermissionsChanged: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface OnPermissionsFailed {
|
|
10
|
+
__onPermissionsFailed: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare enum AccessLevel {
|
|
13
|
+
Undefined = 0,
|
|
14
|
+
NoAccessLevelsDefined = 1,
|
|
15
|
+
NoAccess = 2,
|
|
16
|
+
HasAccess = 3
|
|
17
|
+
}
|
|
18
|
+
export declare class ModuleFE_PermissionsAssert_Class extends Module<PermissionsModuleFEConfig> {
|
|
19
|
+
permissionKeys: TypedMap<PermissionKey_FE<any>>;
|
|
20
|
+
readonly v1: {
|
|
21
|
+
toggleStrictMode: (params: import("@nu-art/thunderstorm-shared").QueryParams) => import("@nu-art/thunderstorm-shared").BaseHttpRequest<import("@nu-art/thunderstorm-shared").QueryApi<void>>;
|
|
22
|
+
createProject: (params: import("@nu-art/thunderstorm-shared").QueryParams) => import("@nu-art/thunderstorm-shared").BaseHttpRequest<import("@nu-art/thunderstorm-shared").QueryApi<void>>;
|
|
23
|
+
};
|
|
24
|
+
constructor();
|
|
25
|
+
protected init(): void;
|
|
26
|
+
getAccessLevelByKeyString(key: string): AccessLevel;
|
|
27
|
+
getAccessLevel(key: PermissionKey_FE): AccessLevel;
|
|
28
|
+
getPermissionKey(key: string): PermissionKey_FE;
|
|
29
|
+
registerPermissionKey(key: PermissionKey_FE): void;
|
|
30
|
+
getAllPermissionKeys(): TypedMap<PermissionKey_FE<any>>;
|
|
31
|
+
}
|
|
32
|
+
export declare const ModuleFE_PermissionsAssert: ModuleFE_PermissionsAssert_Class;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Permissions management system, define access level for each of
|
|
3
|
+
* your server apis, and restrict users by giving them access levels
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { _keys, BadImplementationException, exists, Module } from '@nu-art/ts-common';
|
|
20
|
+
import { apiWithQuery, ModuleFE_Utils, } from '@nu-art/thunderstorm-frontend/index';
|
|
21
|
+
import { SessionKey_Permissions_FE, SessionKey_StrictMode_FE } from '../consts.js';
|
|
22
|
+
import { RendererKey_AccountMenu_SubHeader } from '@nu-art/user-account-frontend/consts';
|
|
23
|
+
import { Renderer_RoleNames } from '../ui/Renderer_RoleNames.js';
|
|
24
|
+
import { ApiDef_Permissions } from '@nu-art/permissions-shared';
|
|
25
|
+
// const dispatch_onPermissionsChanged = new ThunderDispatcher<OnPermissionsChanged, '__onPermissionsChanged'>('__onPermissionsChanged');
|
|
26
|
+
// const dispatch_onPermissionsFailed = new ThunderDispatcher<OnPermissionsFailed, '__onPermissionsFailed'>('__onPermissionsFailed');
|
|
27
|
+
export var AccessLevel;
|
|
28
|
+
(function (AccessLevel) {
|
|
29
|
+
AccessLevel[AccessLevel["Undefined"] = 0] = "Undefined";
|
|
30
|
+
AccessLevel[AccessLevel["NoAccessLevelsDefined"] = 1] = "NoAccessLevelsDefined";
|
|
31
|
+
AccessLevel[AccessLevel["NoAccess"] = 2] = "NoAccess";
|
|
32
|
+
AccessLevel[AccessLevel["HasAccess"] = 3] = "HasAccess";
|
|
33
|
+
})(AccessLevel || (AccessLevel = {}));
|
|
34
|
+
export class ModuleFE_PermissionsAssert_Class extends Module {
|
|
35
|
+
permissionKeys = {};
|
|
36
|
+
v1;
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
this.v1 = {
|
|
40
|
+
toggleStrictMode: apiWithQuery(ApiDef_Permissions.v1.toggleStrictMode),
|
|
41
|
+
createProject: apiWithQuery(ApiDef_Permissions.v1.createProject),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
init() {
|
|
45
|
+
super.init();
|
|
46
|
+
ModuleFE_Utils.registerRenderer(RendererKey_AccountMenu_SubHeader, Renderer_RoleNames);
|
|
47
|
+
}
|
|
48
|
+
getAccessLevelByKeyString(key) {
|
|
49
|
+
return this.getAccessLevel(this.getPermissionKey(key));
|
|
50
|
+
}
|
|
51
|
+
getAccessLevel(key) {
|
|
52
|
+
const keyData = key.get();
|
|
53
|
+
if (!exists(keyData))
|
|
54
|
+
return SessionKey_StrictMode_FE.get() ? AccessLevel.Undefined : AccessLevel.HasAccess;
|
|
55
|
+
if (keyData.accessLevelIds.length === 0)
|
|
56
|
+
return AccessLevel.NoAccessLevelsDefined;
|
|
57
|
+
const userAccessLevels = SessionKey_Permissions_FE.get().domainToValueMap;
|
|
58
|
+
try {
|
|
59
|
+
const canAccess = _keys(keyData._accessLevels).reduce((hasAccess, domainId) => {
|
|
60
|
+
return hasAccess && userAccessLevels[domainId] >= keyData._accessLevels[domainId];
|
|
61
|
+
}, true);
|
|
62
|
+
return canAccess ? AccessLevel.HasAccess : AccessLevel.NoAccess;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
return AccessLevel.NoAccess;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
getPermissionKey(key) {
|
|
69
|
+
return this.permissionKeys[key];
|
|
70
|
+
}
|
|
71
|
+
registerPermissionKey(key) {
|
|
72
|
+
if (this.permissionKeys[key.key])
|
|
73
|
+
throw new BadImplementationException(`Registered PermissionKey '${key}' more than once!`);
|
|
74
|
+
this.permissionKeys[key.key] = key;
|
|
75
|
+
}
|
|
76
|
+
getAllPermissionKeys() {
|
|
77
|
+
return this.permissionKeys;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export const ModuleFE_PermissionsAssert = new ModuleFE_PermissionsAssert_Class();
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nu-art/permissions-frontend",
|
|
3
|
+
"version": "0.400.5",
|
|
4
|
+
"description": "Permissions Frontend",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"TacB0sS",
|
|
7
|
+
"create account",
|
|
8
|
+
"express",
|
|
9
|
+
"infra",
|
|
10
|
+
"login",
|
|
11
|
+
"nu-art",
|
|
12
|
+
"permissions",
|
|
13
|
+
"saml",
|
|
14
|
+
"thunderstorm",
|
|
15
|
+
"typescript",
|
|
16
|
+
"user-account"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://github.com/nu-art-js/permissions",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/nu-art-js/permissions/issues"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+ssh://git@github.com:nu-art-js/permissions.git"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"directory": "dist",
|
|
28
|
+
"linkDirectory": true
|
|
29
|
+
},
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"author": "TacB0sS",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc",
|
|
34
|
+
"run-tests": "firebase emulators:exec \"npm run test\"",
|
|
35
|
+
"test": "ts-mocha -w -p src/test/tsconfig.json --timeout 0 --inspect=8107 --watch-files '**/*.ts' src/test/__all-tests.ts"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@nu-art/permissions-shared": "0.400.5",
|
|
39
|
+
"@nu-art/firebase-frontend": "0.400.5",
|
|
40
|
+
"@nu-art/firebase-shared": "0.400.5",
|
|
41
|
+
"@nu-art/thunderstorm-frontend": "0.400.5",
|
|
42
|
+
"@nu-art/thunderstorm-shared": "0.400.5",
|
|
43
|
+
"@nu-art/ts-common": "0.400.5",
|
|
44
|
+
"@nu-art/ts-styles": "0.400.5",
|
|
45
|
+
"@nu-art/user-account-frontend": "0.400.5",
|
|
46
|
+
"@nu-art/user-account-shared": "0.400.5",
|
|
47
|
+
"express": "^4.18.2",
|
|
48
|
+
"firebase": "^11.9.0",
|
|
49
|
+
"firebase-admin": "13.4.0",
|
|
50
|
+
"firebase-functions": "6.3.2",
|
|
51
|
+
"moment": "^2.29.4",
|
|
52
|
+
"react": "^18.0.0",
|
|
53
|
+
"react-dom": "^18.0.0",
|
|
54
|
+
"react-router-dom": "^6.9.0",
|
|
55
|
+
"request": "^2.88.0",
|
|
56
|
+
"saml2-js": "^4.0.1"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/react": "^18.0.0",
|
|
60
|
+
"@types/express": "^4.17.17",
|
|
61
|
+
"@types/react-dom": "^18.0.0",
|
|
62
|
+
"@types/react-router": "^5.1.20",
|
|
63
|
+
"@types/react-router-dom": "^5.3.3",
|
|
64
|
+
"@types/chai": "^4.3.4",
|
|
65
|
+
"@types/mocha": "^10.0.1",
|
|
66
|
+
"@types/history": "^4.7.2",
|
|
67
|
+
"@types/request": "^2.48.1",
|
|
68
|
+
"@types/saml2-js": "^1.6.8"
|
|
69
|
+
},
|
|
70
|
+
"unitConfig": {
|
|
71
|
+
"type": "typescript-lib"
|
|
72
|
+
},
|
|
73
|
+
"type": "module",
|
|
74
|
+
"exports": {
|
|
75
|
+
".": {
|
|
76
|
+
"types": "./index.d.ts",
|
|
77
|
+
"import": "./index.js"
|
|
78
|
+
},
|
|
79
|
+
"./*": {
|
|
80
|
+
"types": "./*.d.ts",
|
|
81
|
+
"import": "./*.js"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
package/shared.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@nu-art/permissions-shared';
|
package/shared.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Permissions management system, define access level for each of
|
|
3
|
+
* your server apis, and restrict users by giving them access levels
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
export * from '@nu-art/permissions-shared';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppToolsScreen, ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
type State = {
|
|
3
|
+
selectedProjectId?: string;
|
|
4
|
+
};
|
|
5
|
+
type Props = {};
|
|
6
|
+
export declare class ATS_ComponentPermissionKeys extends ComponentSync<Props, State> {
|
|
7
|
+
static screen: AppToolsScreen;
|
|
8
|
+
protected deriveStateFromProps(nextProps: Props, state: State): State;
|
|
9
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ComponentSync, LL_V_L } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { PermissionKeysEditor } from './subEditors/permission-keys-editor.js';
|
|
4
|
+
import { ModuleFE_PermissionAccessLevel } from '../../_entity.js';
|
|
5
|
+
export class ATS_ComponentPermissionKeys extends ComponentSync {
|
|
6
|
+
static screen = {
|
|
7
|
+
key: 'component-permission-keys',
|
|
8
|
+
name: 'Component Permission Keys',
|
|
9
|
+
renderer: this,
|
|
10
|
+
group: 'Permissions',
|
|
11
|
+
modulesToAwait: [ModuleFE_PermissionAccessLevel],
|
|
12
|
+
};
|
|
13
|
+
//######################### Life Cycle #########################
|
|
14
|
+
deriveStateFromProps(nextProps, state) {
|
|
15
|
+
state ??= (this.state ? { ...this.state } : {});
|
|
16
|
+
return state;
|
|
17
|
+
}
|
|
18
|
+
//######################### Render #########################
|
|
19
|
+
render() {
|
|
20
|
+
return _jsx(LL_V_L, { className: '', children: _jsx(PermissionKeysEditor, {}) });
|
|
21
|
+
}
|
|
22
|
+
}
|