@mondaydotcomorg/monday-authorization 3.0.0-feature-bashanye-create-custom-roles-sdk.b34d2d3 → 3.0.0-feature-bashanye-create-custom-roles-sdk.094a966
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/dist/constants.d.ts +2 -2
- package/dist/esm/constants.d.ts +2 -2
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/{roles.d.ts → roles-service.d.ts} +5 -5
- package/dist/esm/roles-service.d.ts.map +1 -0
- package/dist/esm/{roles.mjs → roles-service.mjs} +7 -15
- package/dist/esm/types/roles.d.ts +13 -4
- package/dist/esm/types/roles.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/{roles.d.ts → roles-service.d.ts} +5 -5
- package/dist/roles-service.d.ts.map +1 -0
- package/dist/{roles.js → roles-service.js} +7 -15
- package/dist/types/roles.d.ts +13 -4
- package/dist/types/roles.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/esm/roles.d.ts.map +0 -1
- package/dist/roles.d.ts.map +0 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RecursivePartial } from
|
|
2
|
-
import { FetcherConfig } from
|
|
1
|
+
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
2
|
+
import { FetcherConfig } from '@mondaydotcomorg/trident-backend-api';
|
|
3
3
|
export declare const APP_NAME = "authorization";
|
|
4
4
|
export declare const ERROR_MESSAGES: {
|
|
5
5
|
readonly HTTP_CLIENT_NOT_INITIALIZED: "MondayAuthorization: HTTP client is not initialized";
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RecursivePartial } from
|
|
2
|
-
import { FetcherConfig } from
|
|
1
|
+
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
2
|
+
import { FetcherConfig } from '@mondaydotcomorg/trident-backend-api';
|
|
3
3
|
export declare const APP_NAME = "authorization";
|
|
4
4
|
export declare const ERROR_MESSAGES: {
|
|
5
5
|
readonly HTTP_CLIENT_NOT_INITIALIZED: "MondayAuthorization: HTTP client is not initialized";
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export declare function init(options?: InitOptions): Promise<void>;
|
|
|
10
10
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
11
11
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
12
12
|
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
13
|
+
export { RolesService } from './roles-service';
|
|
13
14
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
|
14
15
|
export { Translation, ScopedAction, ScopedActionResponseObject, ScopedActionPermit, } from './types/scoped-actions-contracts';
|
|
16
|
+
export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest, RolesResponse } from './types/roles';
|
|
15
17
|
export { TestKit };
|
|
16
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;CACjD;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBAcnD;AAED,OAAO,EAC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,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -5,6 +5,8 @@ import * as testKit_index from './testKit/index.mjs';
|
|
|
5
5
|
export { testKit_index as TestKit };
|
|
6
6
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware } from './authorization-middleware.mjs';
|
|
7
7
|
export { AuthorizationAttributesService } from './authorization-attributes-service.mjs';
|
|
8
|
+
export { RolesService } from './roles-service.mjs';
|
|
9
|
+
export { RoleType } from './types/roles.mjs';
|
|
8
10
|
|
|
9
11
|
async function init(options = {}) {
|
|
10
12
|
if (options.prometheus) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
|
|
2
2
|
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
|
-
import {
|
|
4
|
-
export declare class
|
|
3
|
+
import { RoleCreateRequest, RolesResponse, RoleUpdateRequest } from './types/roles';
|
|
4
|
+
export declare class RolesService {
|
|
5
5
|
private httpClient;
|
|
6
6
|
private fetchOptions;
|
|
7
7
|
private attributionHeaders;
|
|
@@ -17,9 +17,9 @@ export declare class CustomRoles {
|
|
|
17
17
|
* @returns - The roles for the account, both basic and custom roles. Note that basic role ids are returned in A style and not B style.
|
|
18
18
|
*/
|
|
19
19
|
getRoles(accountId: number, resourceTypes: string[]): Promise<RolesResponse>;
|
|
20
|
-
createCustomRole(accountId: number, roles:
|
|
20
|
+
createCustomRole(accountId: number, roles: RoleCreateRequest[]): Promise<RolesResponse>;
|
|
21
21
|
deleteCustomRole(accountId: number, roleIds: number[]): Promise<RolesResponse>;
|
|
22
|
-
updateCustomRole(accountId: number, updateRequests:
|
|
22
|
+
updateCustomRole(accountId: number, updateRequests: RoleUpdateRequest[]): Promise<RolesResponse>;
|
|
23
23
|
private sendRoleRequest;
|
|
24
24
|
}
|
|
25
|
-
//# sourceMappingURL=roles.d.ts.map
|
|
25
|
+
//# sourceMappingURL=roles-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles-service.d.ts","sourceRoot":"","sources":["../../src/roles-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,aAAa,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAoB,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOlF,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,kBAAkB,CAA4B;IAEtD;;;;OAIG;gBACS,UAAU,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAqBnF;;;;OAIG;IACG,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAI5E,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAUvF,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAM9E,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;YAMxF,eAAe;CAiC9B"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Api } from '@mondaydotcomorg/trident-backend-api';
|
|
2
2
|
import { HttpFetcherError } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
|
-
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
4
3
|
import { getAttributionsFromApi } from './attributions-service.mjs';
|
|
4
|
+
import { ERROR_MESSAGES, DEFAULT_FETCH_OPTIONS, APP_NAME } from './constants.mjs';
|
|
5
5
|
|
|
6
6
|
const API_PATH = '/roles/account/{accountId}';
|
|
7
7
|
const A_STYLE_NAME = 'A';
|
|
8
|
-
class
|
|
8
|
+
class RolesService {
|
|
9
9
|
httpClient;
|
|
10
10
|
fetchOptions;
|
|
11
11
|
attributionHeaders;
|
|
@@ -40,23 +40,14 @@ class CustomRoles {
|
|
|
40
40
|
* @returns - The roles for the account, both basic and custom roles. Note that basic role ids are returned in A style and not B style.
|
|
41
41
|
*/
|
|
42
42
|
async getRoles(accountId, resourceTypes) {
|
|
43
|
-
return await this.sendRoleRequest('GET', accountId, {
|
|
43
|
+
return await this.sendRoleRequest('GET', accountId, {}, { resourceTypes });
|
|
44
44
|
}
|
|
45
45
|
async createCustomRole(accountId, roles) {
|
|
46
46
|
if (roles.length === 0) {
|
|
47
47
|
throw new Error('Roles array cannot be empty');
|
|
48
48
|
}
|
|
49
|
-
const serializedRoles = roles.map(role => ({
|
|
50
|
-
"name": role.name,
|
|
51
|
-
"resourceType": role.resourceType,
|
|
52
|
-
"resourceId": role.resourceId,
|
|
53
|
-
"sourceRole": {
|
|
54
|
-
"id": role.basicRoleId,
|
|
55
|
-
"type": role.basicRoleType,
|
|
56
|
-
}
|
|
57
|
-
}));
|
|
58
49
|
return await this.sendRoleRequest('PUT', accountId, {
|
|
59
|
-
customRoles:
|
|
50
|
+
customRoles: roles,
|
|
60
51
|
});
|
|
61
52
|
}
|
|
62
53
|
async deleteCustomRole(accountId, roleIds) {
|
|
@@ -69,7 +60,7 @@ class CustomRoles {
|
|
|
69
60
|
customRoles: updateRequests,
|
|
70
61
|
});
|
|
71
62
|
}
|
|
72
|
-
async sendRoleRequest(method, accountId, body) {
|
|
63
|
+
async sendRoleRequest(method, accountId, body, additionalQueryParams = {}) {
|
|
73
64
|
try {
|
|
74
65
|
return await this.httpClient.fetch({
|
|
75
66
|
url: {
|
|
@@ -78,6 +69,7 @@ class CustomRoles {
|
|
|
78
69
|
},
|
|
79
70
|
query: {
|
|
80
71
|
style: A_STYLE_NAME,
|
|
72
|
+
...additionalQueryParams,
|
|
81
73
|
},
|
|
82
74
|
method,
|
|
83
75
|
headers: {
|
|
@@ -96,4 +88,4 @@ class CustomRoles {
|
|
|
96
88
|
}
|
|
97
89
|
}
|
|
98
90
|
|
|
99
|
-
export {
|
|
91
|
+
export { RolesService };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export declare enum RoleType {
|
|
2
|
+
CUSTOM = "custom_role",
|
|
3
|
+
BASIC = "basic_role"
|
|
4
|
+
}
|
|
1
5
|
export interface CustomRole {
|
|
2
6
|
id?: number;
|
|
3
7
|
name: string;
|
|
@@ -16,11 +20,16 @@ export interface RolesResponse {
|
|
|
16
20
|
customRoles: CustomRole[];
|
|
17
21
|
basicRoles?: BasicRole[];
|
|
18
22
|
}
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
export interface RoleCreateRequest {
|
|
24
|
+
name: string;
|
|
25
|
+
resourceType: string;
|
|
26
|
+
resourceId: number;
|
|
27
|
+
sourceRole: {
|
|
28
|
+
id: number;
|
|
29
|
+
type: RoleType;
|
|
30
|
+
};
|
|
22
31
|
}
|
|
23
|
-
export interface
|
|
32
|
+
export interface RoleUpdateRequest {
|
|
24
33
|
id: number;
|
|
25
34
|
updatedAttributes: {
|
|
26
35
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../src/types/roles.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;
|
|
1
|
+
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../src/types/roles.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,MAAM,gBAAgB;IACtB,KAAK,eAAe;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,QAAQ,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE;QACV,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,QAAQ,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export declare function init(options?: InitOptions): Promise<void>;
|
|
|
10
10
|
export { authorizationCheckMiddleware, getAuthorizationMiddleware, skipAuthorizationMiddleware, } from './authorization-middleware';
|
|
11
11
|
export { AuthorizationService, AuthorizeResponse } from './authorization-service';
|
|
12
12
|
export { AuthorizationAttributesService } from './authorization-attributes-service';
|
|
13
|
+
export { RolesService } from './roles-service';
|
|
13
14
|
export { AuthorizationObject, Resource, BaseRequest, ResourceGetter, ContextGetter } from './types/general';
|
|
14
15
|
export { Translation, ScopedAction, ScopedActionResponseObject, ScopedActionPermit, } from './types/scoped-actions-contracts';
|
|
16
|
+
export { CustomRole, BasicRole, RoleType, RoleCreateRequest, RoleUpdateRequest, RolesResponse } from './types/roles';
|
|
15
17
|
export { TestKit };
|
|
16
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;CACjD;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBAcnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,sCAAsC,CAAC,EAAE,MAAM,CAAC;CACjD;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,WAAgB,iBAcnD;AAED,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EACL,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@ const authorizationService = require('./authorization-service.js');
|
|
|
5
5
|
const testKit_index = require('./testKit/index.js');
|
|
6
6
|
const authorizationMiddleware = require('./authorization-middleware.js');
|
|
7
7
|
const authorizationAttributesService = require('./authorization-attributes-service.js');
|
|
8
|
+
const rolesService = require('./roles-service.js');
|
|
9
|
+
const types_roles = require('./types/roles.js');
|
|
8
10
|
|
|
9
11
|
async function init(options = {}) {
|
|
10
12
|
if (options.prometheus) {
|
|
@@ -26,4 +28,9 @@ exports.authorizationCheckMiddleware = authorizationMiddleware.authorizationChec
|
|
|
26
28
|
exports.getAuthorizationMiddleware = authorizationMiddleware.getAuthorizationMiddleware;
|
|
27
29
|
exports.skipAuthorizationMiddleware = authorizationMiddleware.skipAuthorizationMiddleware;
|
|
28
30
|
exports.AuthorizationAttributesService = authorizationAttributesService.AuthorizationAttributesService;
|
|
31
|
+
exports.RolesService = rolesService.RolesService;
|
|
32
|
+
Object.defineProperty(exports, 'RoleType', {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: () => types_roles.RoleType
|
|
35
|
+
});
|
|
29
36
|
exports.init = init;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FetcherConfig, HttpClient } from '@mondaydotcomorg/trident-backend-api';
|
|
2
2
|
import { RecursivePartial } from '@mondaydotcomorg/monday-fetch-api';
|
|
3
|
-
import {
|
|
4
|
-
export declare class
|
|
3
|
+
import { RoleCreateRequest, RolesResponse, RoleUpdateRequest } from './types/roles';
|
|
4
|
+
export declare class RolesService {
|
|
5
5
|
private httpClient;
|
|
6
6
|
private fetchOptions;
|
|
7
7
|
private attributionHeaders;
|
|
@@ -17,9 +17,9 @@ export declare class CustomRoles {
|
|
|
17
17
|
* @returns - The roles for the account, both basic and custom roles. Note that basic role ids are returned in A style and not B style.
|
|
18
18
|
*/
|
|
19
19
|
getRoles(accountId: number, resourceTypes: string[]): Promise<RolesResponse>;
|
|
20
|
-
createCustomRole(accountId: number, roles:
|
|
20
|
+
createCustomRole(accountId: number, roles: RoleCreateRequest[]): Promise<RolesResponse>;
|
|
21
21
|
deleteCustomRole(accountId: number, roleIds: number[]): Promise<RolesResponse>;
|
|
22
|
-
updateCustomRole(accountId: number, updateRequests:
|
|
22
|
+
updateCustomRole(accountId: number, updateRequests: RoleUpdateRequest[]): Promise<RolesResponse>;
|
|
23
23
|
private sendRoleRequest;
|
|
24
24
|
}
|
|
25
|
-
//# sourceMappingURL=roles.d.ts.map
|
|
25
|
+
//# sourceMappingURL=roles-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles-service.d.ts","sourceRoot":"","sources":["../src/roles-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,aAAa,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAoB,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOlF,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAkC;IACtD,OAAO,CAAC,kBAAkB,CAA4B;IAEtD;;;;OAIG;gBACS,UAAU,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAqBnF;;;;OAIG;IACG,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAI5E,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAUvF,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAM9E,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;YAMxF,eAAe;CAiC9B"}
|
|
@@ -2,12 +2,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const tridentBackendApi = require('@mondaydotcomorg/trident-backend-api');
|
|
4
4
|
const mondayFetchApi = require('@mondaydotcomorg/monday-fetch-api');
|
|
5
|
-
const constants = require('./constants.js');
|
|
6
5
|
const attributionsService = require('./attributions-service.js');
|
|
6
|
+
const constants = require('./constants.js');
|
|
7
7
|
|
|
8
8
|
const API_PATH = '/roles/account/{accountId}';
|
|
9
9
|
const A_STYLE_NAME = 'A';
|
|
10
|
-
class
|
|
10
|
+
class RolesService {
|
|
11
11
|
httpClient;
|
|
12
12
|
fetchOptions;
|
|
13
13
|
attributionHeaders;
|
|
@@ -42,23 +42,14 @@ class CustomRoles {
|
|
|
42
42
|
* @returns - The roles for the account, both basic and custom roles. Note that basic role ids are returned in A style and not B style.
|
|
43
43
|
*/
|
|
44
44
|
async getRoles(accountId, resourceTypes) {
|
|
45
|
-
return await this.sendRoleRequest('GET', accountId, {
|
|
45
|
+
return await this.sendRoleRequest('GET', accountId, {}, { resourceTypes });
|
|
46
46
|
}
|
|
47
47
|
async createCustomRole(accountId, roles) {
|
|
48
48
|
if (roles.length === 0) {
|
|
49
49
|
throw new Error('Roles array cannot be empty');
|
|
50
50
|
}
|
|
51
|
-
const serializedRoles = roles.map(role => ({
|
|
52
|
-
"name": role.name,
|
|
53
|
-
"resourceType": role.resourceType,
|
|
54
|
-
"resourceId": role.resourceId,
|
|
55
|
-
"sourceRole": {
|
|
56
|
-
"id": role.basicRoleId,
|
|
57
|
-
"type": role.basicRoleType,
|
|
58
|
-
}
|
|
59
|
-
}));
|
|
60
51
|
return await this.sendRoleRequest('PUT', accountId, {
|
|
61
|
-
customRoles:
|
|
52
|
+
customRoles: roles,
|
|
62
53
|
});
|
|
63
54
|
}
|
|
64
55
|
async deleteCustomRole(accountId, roleIds) {
|
|
@@ -71,7 +62,7 @@ class CustomRoles {
|
|
|
71
62
|
customRoles: updateRequests,
|
|
72
63
|
});
|
|
73
64
|
}
|
|
74
|
-
async sendRoleRequest(method, accountId, body) {
|
|
65
|
+
async sendRoleRequest(method, accountId, body, additionalQueryParams = {}) {
|
|
75
66
|
try {
|
|
76
67
|
return await this.httpClient.fetch({
|
|
77
68
|
url: {
|
|
@@ -80,6 +71,7 @@ class CustomRoles {
|
|
|
80
71
|
},
|
|
81
72
|
query: {
|
|
82
73
|
style: A_STYLE_NAME,
|
|
74
|
+
...additionalQueryParams,
|
|
83
75
|
},
|
|
84
76
|
method,
|
|
85
77
|
headers: {
|
|
@@ -98,4 +90,4 @@ class CustomRoles {
|
|
|
98
90
|
}
|
|
99
91
|
}
|
|
100
92
|
|
|
101
|
-
exports.
|
|
93
|
+
exports.RolesService = RolesService;
|
package/dist/types/roles.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export declare enum RoleType {
|
|
2
|
+
CUSTOM = "custom_role",
|
|
3
|
+
BASIC = "basic_role"
|
|
4
|
+
}
|
|
1
5
|
export interface CustomRole {
|
|
2
6
|
id?: number;
|
|
3
7
|
name: string;
|
|
@@ -16,11 +20,16 @@ export interface RolesResponse {
|
|
|
16
20
|
customRoles: CustomRole[];
|
|
17
21
|
basicRoles?: BasicRole[];
|
|
18
22
|
}
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
export interface RoleCreateRequest {
|
|
24
|
+
name: string;
|
|
25
|
+
resourceType: string;
|
|
26
|
+
resourceId: number;
|
|
27
|
+
sourceRole: {
|
|
28
|
+
id: number;
|
|
29
|
+
type: RoleType;
|
|
30
|
+
};
|
|
22
31
|
}
|
|
23
|
-
export interface
|
|
32
|
+
export interface RoleUpdateRequest {
|
|
24
33
|
id: number;
|
|
25
34
|
updatedAttributes: {
|
|
26
35
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../src/types/roles.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;
|
|
1
|
+
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../src/types/roles.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,MAAM,gBAAgB;IACtB,KAAK,eAAe;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,QAAQ,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE;QACV,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,QAAQ,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/monday-authorization",
|
|
3
|
-
"version": "3.0.0-feature-bashanye-create-custom-roles-sdk.
|
|
3
|
+
"version": "3.0.0-feature-bashanye-create-custom-roles-sdk.094a966",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "BSD-3-Clause",
|
package/dist/esm/roles.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../src/roles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,aAAa,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAoB,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAEvF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMpE,qBAA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