Skip to content

Commit

Permalink
Feature/implement get permissions v3 (#162)
Browse files Browse the repository at this point in the history
* Implement V3.GET_PERMISSIONS

* Implement V3.GET_PERMISSIONS

Revert change in changelog
  • Loading branch information
kistll committed Aug 29, 2023
1 parent 0f0f82d commit 876c86c
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.18.0] - 2023-08-29

### Added

- Implement V3.GET_PERMISSIONS

## [1.17.1] - 2023-05-08

### Fixed
Expand Down
40 changes: 38 additions & 2 deletions docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,49 @@ Request restricted token for using by an extension

<!-- tabs:start -->

#### **Version 3**

```
SHELL_EVENTS.Version3.GET_PERMISSIONS
```

Request permissions for specified object from the Shell. The version 3 uses a different permission calculation than the versions 1 and 2: If the user has the permission NONE for a CRUD operation, _false_ is provided for this CRUD operation. If the user has any other permission (ALL, OWN, ORG_LEVEL or any further permission) for a CRUD operation, _true_ is provided for this CRUD operation. Because of this, there is no need for the property _owners_.

- Request payload

type: PermissionRequestV3

```typescript
{
objectName: string; // permission object type
}
```

- Response payload

type: PermissionResponseV3

```typescript
{
objectName: string;
permission: {
CREATE: boolean;
READ: boolean;
UPDATE: boolean;
DELETE: boolean;
UI_PERMISSIONS: number[];
};
}

```

#### **Version 2**

```
SHELL_EVENTS.Version2.GET_PERMISSIONS
```

Request permissions for specified object from the shell
Request permissions for specified object from the Shell

- Request payload

Expand Down Expand Up @@ -144,7 +180,7 @@ Request permissions for specified object from the shell
SHELL_EVENTS.Version1.GET_PERMISSIONS
```

Request permissions for specified object from the shell
Request permissions for specified object from the Shell

- Request payload

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fsm-shell",
"version": "1.17.1",
"version": "1.18.0",
"description": "client library for FSM shell",
"main": "release/fsm-shell-client.js",
"module": "release/fsm-shell-client.es.js",
Expand Down
4 changes: 4 additions & 0 deletions src/ShellEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type EventType =
| 'V1.REQUIRE_PERMISSIONS'
| 'V1.GET_PERMISSIONS'
| 'V2.GET_PERMISSIONS'
| 'V3.GET_PERMISSIONS'
| 'V1.GET_SETTINGS'
| 'V1.GET_STORAGE_ITEM'
| 'V2.GET_STORAGE_ITEM'
Expand Down Expand Up @@ -65,6 +66,9 @@ export const SHELL_EVENTS = {
OPEN: 'V2.MODAL.OPEN',
},
},
Version3: {
GET_PERMISSIONS: 'V3.GET_PERMISSIONS',
},
ERROR: 'ERROR',
};

Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
Permission,
PermissionRequest,
PermissionResponse,
PermissionRequestV3,
PermissionResponseV3,
UiPermissions,
SettingsResponse,
SetViewStateRequest,
Expand Down Expand Up @@ -54,6 +56,8 @@ export {
Permission,
PermissionRequest,
PermissionResponse,
PermissionRequestV3,
PermissionResponseV3,
UiPermissions,
SettingsResponse,
SetViewStateRequest,
Expand Down
2 changes: 2 additions & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export { PermissionRequest } from './permissions/permission-request.model';
export { PermissionResponse } from './permissions/permission-response.model';
export { PermissionRequestV3 } from './permissions/permission-request.v3.model';
export { PermissionResponseV3 } from './permissions/permission-response.v3.model';
export { Permission } from './permissions/permission.model';
export { UiPermissions } from './permissions/ui-permissions.model';

Expand Down
3 changes: 3 additions & 0 deletions src/models/permissions/permission-request.v3.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface PermissionRequestV3 {
objectName: string;
}
6 changes: 6 additions & 0 deletions src/models/permissions/permission-response.v3.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Permission } from './permission.model';

export interface PermissionResponseV3 {
objectName: string;
permission: Permission;
}
3 changes: 0 additions & 3 deletions src/models/permissions/permission.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

import { UiPermissions } from './ui-permissions.model';

export interface Permission {
CREATE: boolean;
READ: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const getPermissionsRequest_v3_schema = {
type: 'object',
properties: {
objectName: {
type: 'string',
},
},
required: ['objectName'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { getPermissionsResponse_v1_schema } from './get-permissions-response.v1.schema';

export const getPermissionsResponse_v3_schema = {
type: 'object',
properties: {
objectName: {
type: 'string',
},
permission: getPermissionsResponse_v1_schema,
},
required: ['objectName', 'permission'],
};
13 changes: 13 additions & 0 deletions src/validation/schemas/validation-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import { modalCloseRequest_v1_schema } from './modal/modal-close-request.v1.sche

import { getPermissionsRequest_v1_schema } from './permissions/get-permissions-request.v1.schema';
import { getPermissionsRequest_v2_schema } from './permissions/get-permissions-request.v2.schema';
import { getPermissionsRequest_v3_schema } from './permissions/get-permissions-request.v3.schema';
import { getPermissionsResponse_v1_schema } from './permissions/get-permissions-response.v1.schema';
import { getPermissionsResponse_v2_schema } from './permissions/get-permissions-response.v2.schema';
import { getPermissionsResponse_v3_schema } from './permissions/get-permissions-response.v3.schema';

import { getSettingsRequest_v1_schema } from './settings/get-settings-request.v1.schema';
import { getSettingsResponse_v1_schema } from './settings/get-settings-response.v1.schema';
Expand Down Expand Up @@ -161,6 +163,17 @@ export const getEventValidationConfiguration =
},
},

[SHELL_EVENTS.Version3.GET_PERMISSIONS]: {
request: {
schema: getPermissionsRequest_v3_schema,
validationFunction: null,
},
response: {
schema: getPermissionsResponse_v3_schema,
validationFunction: null,
},
},

[SHELL_EVENTS.Version1.GET_SETTINGS]: {
request: {
schema: getSettingsRequest_v1_schema,
Expand Down

0 comments on commit 876c86c

Please sign in to comment.