@mondaydotcomorg/monday-authorization 3.0.0-feature-bashanye-create-custom-roles-sdk.9c70903 → 3.0.0-feature-bashanye-create-custom-roles-sdk.f14722d

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.
@@ -1,5 +1,5 @@
1
- import { RecursivePartial } from "@mondaydotcomorg/monday-fetch-api";
2
- import { FetcherConfig } from "@mondaydotcomorg/trident-backend-api";
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";
@@ -1,5 +1,5 @@
1
- import { RecursivePartial } from "@mondaydotcomorg/monday-fetch-api";
2
- import { FetcherConfig } from "@mondaydotcomorg/trident-backend-api";
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";
@@ -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
@@ -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;AAE1C,OAAO,EAAE,OAAO,EAAE,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"}
@@ -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 { CustomRole, RolesResponse, RoleUpdate } from './types/roles';
4
- export declare class CustomRoles {
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;
@@ -14,12 +14,12 @@ export declare class CustomRoles {
14
14
  /**
15
15
  * Get all roles for an account
16
16
  * @param accountId - The account ID
17
- * @returns - The roles for the account, both basic and custom roles. Note that role ids are in A style and not B style.
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: CustomRole[]): Promise<RolesResponse>;
20
+ createCustomRole(accountId: number, roles: RoleCreateRequest[]): Promise<RolesResponse>;
21
21
  deleteCustomRole(accountId: number, roleIds: number[]): Promise<RolesResponse>;
22
- updateCustomRole(accountId: number, updateRequests: RoleUpdate[]): Promise<RolesResponse>;
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;CA+B9B"}
@@ -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
- const STYLE = 'A';
8
- class CustomRoles {
7
+ const A_STYLE_NAME = 'A';
8
+ class RolesService {
9
9
  httpClient;
10
10
  fetchOptions;
11
11
  attributionHeaders;
@@ -37,26 +37,17 @@ class CustomRoles {
37
37
  /**
38
38
  * Get all roles for an account
39
39
  * @param accountId - The account ID
40
- * @returns - The roles for the account, both basic and custom roles. Note that role ids are in A style and not B style.
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, {}, { resourceTypes: resourceTypes.join(',') });
43
+ return await this.sendRoleRequest('GET', accountId, { resourceTypes: resourceTypes.join(',') });
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: serializedRoles,
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, additionalQueryParams = {}) {
63
+ async sendRoleRequest(method, accountId, body) {
73
64
  try {
74
65
  return await this.httpClient.fetch({
75
66
  url: {
@@ -77,8 +68,7 @@ class CustomRoles {
77
68
  path: API_PATH.replace('{accountId}', accountId.toString()),
78
69
  },
79
70
  query: {
80
- style: STYLE,
81
- ...additionalQueryParams,
71
+ style: A_STYLE_NAME,
82
72
  },
83
73
  method,
84
74
  headers: {
@@ -97,4 +87,4 @@ class CustomRoles {
97
87
  }
98
88
  }
99
89
 
100
- export { CustomRoles };
90
+ 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 declare enum RoleType {
20
- CUSTOM = "custom_role",
21
- BASIC = "basic_role"
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 RoleUpdate {
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;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;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BAAiB;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
@@ -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,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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 { CustomRole, RolesResponse, RoleUpdate } from './types/roles';
4
- export declare class CustomRoles {
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;
@@ -14,12 +14,12 @@ export declare class CustomRoles {
14
14
  /**
15
15
  * Get all roles for an account
16
16
  * @param accountId - The account ID
17
- * @returns - The roles for the account, both basic and custom roles. Note that role ids are in A style and not B style.
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: CustomRole[]): Promise<RolesResponse>;
20
+ createCustomRole(accountId: number, roles: RoleCreateRequest[]): Promise<RolesResponse>;
21
21
  deleteCustomRole(accountId: number, roleIds: number[]): Promise<RolesResponse>;
22
- updateCustomRole(accountId: number, updateRequests: RoleUpdate[]): Promise<RolesResponse>;
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;CA+B9B"}
@@ -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
- const STYLE = 'A';
10
- class CustomRoles {
9
+ const A_STYLE_NAME = 'A';
10
+ class RolesService {
11
11
  httpClient;
12
12
  fetchOptions;
13
13
  attributionHeaders;
@@ -39,26 +39,17 @@ class CustomRoles {
39
39
  /**
40
40
  * Get all roles for an account
41
41
  * @param accountId - The account ID
42
- * @returns - The roles for the account, both basic and custom roles. Note that role ids are in A style and not B style.
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, {}, { resourceTypes: resourceTypes.join(',') });
45
+ return await this.sendRoleRequest('GET', accountId, { resourceTypes: resourceTypes.join(',') });
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: serializedRoles,
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, additionalQueryParams = {}) {
65
+ async sendRoleRequest(method, accountId, body) {
75
66
  try {
76
67
  return await this.httpClient.fetch({
77
68
  url: {
@@ -79,8 +70,7 @@ class CustomRoles {
79
70
  path: API_PATH.replace('{accountId}', accountId.toString()),
80
71
  },
81
72
  query: {
82
- style: STYLE,
83
- ...additionalQueryParams,
73
+ style: A_STYLE_NAME,
84
74
  },
85
75
  method,
86
76
  headers: {
@@ -99,4 +89,4 @@ class CustomRoles {
99
89
  }
100
90
  }
101
91
 
102
- exports.CustomRoles = CustomRoles;
92
+ exports.RolesService = 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 declare enum RoleType {
20
- CUSTOM = "custom_role",
21
- BASIC = "basic_role"
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 RoleUpdate {
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;IACvB,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,CAAA;CAC1B;AAED,MAAM,WAAW,SAAS;IACtB,EAAE,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,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.9c70903",
3
+ "version": "3.0.0-feature-bashanye-create-custom-roles-sdk.f14722d",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "BSD-3-Clause",
@@ -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,qBAAa,WAAW;IACtB,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,UAAU,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAkBhF,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAM9E,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,G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