@workos-inc/node 7.35.1 → 7.36.0

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.
@@ -50,7 +50,7 @@ class Actions {
50
50
  return response;
51
51
  });
52
52
  }
53
- constructAction({ payload, sigHeader, secret, tolerance = 300, }) {
53
+ constructAction({ payload, sigHeader, secret, tolerance = 30000, }) {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
55
  const options = { payload, sigHeader, secret, tolerance };
56
56
  yield this.verifyHeader(options);
@@ -73,7 +73,7 @@ const deserializeEvent = (event) => {
73
73
  case 'role.created':
74
74
  case 'role.deleted':
75
75
  case 'role.updated':
76
- return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, role_serializer_1.deserializeRole)(event.data) });
76
+ return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, role_serializer_1.deserializeRoleEvent)(event.data) });
77
77
  case 'session.created':
78
78
  return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, session_serializer_1.deserializeSession)(event.data) });
79
79
  case 'organization.created':
@@ -0,0 +1,35 @@
1
+ {
2
+ "object": "list",
3
+ "data": [
4
+ {
5
+ "object": "role",
6
+ "id": "role_01EHQMYV6MBK39QC5PZXHY59C5",
7
+ "name": "Admin",
8
+ "slug": "admin",
9
+ "description": null,
10
+ "type": "EnvironmentRole",
11
+ "created_at": "2024-01-01T00:00:00.000Z",
12
+ "updated_at": "2024-01-01T00:00:00.000Z"
13
+ },
14
+ {
15
+ "object": "role",
16
+ "id": "role_01EHQMYV6MBK39QC5PZXHY59C3",
17
+ "name": "Member",
18
+ "slug": "member",
19
+ "description": null,
20
+ "type": "EnvironmentRole",
21
+ "created_at": "2024-01-01T00:00:00.000Z",
22
+ "updated_at": "2024-01-01T00:00:00.000Z"
23
+ },
24
+ {
25
+ "object": "role",
26
+ "id": "role_01EHQMYV6MBK39QC5PZXHY59C3",
27
+ "name": "OrganizationMember",
28
+ "slug": "org-member",
29
+ "description": null,
30
+ "type": "OrganizationRole",
31
+ "created_at": "2024-01-01T00:00:00.000Z",
32
+ "updated_at": "2024-01-01T00:00:00.000Z"
33
+ }
34
+ ]
35
+ }
@@ -0,0 +1,3 @@
1
+ export interface ListOrganizationRolesOptions {
2
+ organizationId: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,8 @@
1
1
  import { AutoPaginatable } from '../common/utils/pagination';
2
2
  import { WorkOS } from '../workos';
3
3
  import { CreateOrganizationOptions, CreateOrganizationRequestOptions, ListOrganizationsOptions, Organization, UpdateOrganizationOptions } from './interfaces';
4
+ import { RoleList } from '../roles/interfaces';
5
+ import { ListOrganizationRolesOptions } from './interfaces/list-organization-roles-options.interface';
4
6
  export declare class Organizations {
5
7
  private readonly workos;
6
8
  constructor(workos: WorkOS);
@@ -9,4 +11,5 @@ export declare class Organizations {
9
11
  deleteOrganization(id: string): Promise<void>;
10
12
  getOrganization(id: string): Promise<Organization>;
11
13
  updateOrganization(options: UpdateOrganizationOptions): Promise<Organization>;
14
+ listOrganizationRoles(options: ListOrganizationRolesOptions): Promise<RoleList>;
12
15
  }
@@ -24,6 +24,7 @@ exports.Organizations = void 0;
24
24
  const pagination_1 = require("../common/utils/pagination");
25
25
  const serializers_1 = require("./serializers");
26
26
  const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
27
+ const role_serializer_1 = require("../roles/serializers/role.serializer");
27
28
  class Organizations {
28
29
  constructor(workos) {
29
30
  this.workos = workos;
@@ -57,5 +58,15 @@ class Organizations {
57
58
  return (0, serializers_1.deserializeOrganization)(data);
58
59
  });
59
60
  }
61
+ listOrganizationRoles(options) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const { organizationId } = options;
64
+ const { data: response } = yield this.workos.get(`/organizations/${organizationId}/roles`);
65
+ return {
66
+ object: 'list',
67
+ data: response.data.map((role) => (0, role_serializer_1.deserializeRole)(role)),
68
+ };
69
+ });
70
+ }
60
71
  }
61
72
  exports.Organizations = Organizations;
@@ -20,6 +20,7 @@ const create_organization_invalid_json_1 = __importDefault(require("./fixtures/c
20
20
  const create_organization_json_1 = __importDefault(require("./fixtures/create-organization.json"));
21
21
  const get_organization_json_1 = __importDefault(require("./fixtures/get-organization.json"));
22
22
  const list_organizations_json_1 = __importDefault(require("./fixtures/list-organizations.json"));
23
+ const list_organization_roles_json_1 = __importDefault(require("./fixtures/list-organization-roles.json"));
23
24
  const update_organization_json_1 = __importDefault(require("./fixtures/update-organization.json"));
24
25
  const set_stripe_customer_id_json_1 = __importDefault(require("./fixtures/set-stripe-customer-id.json"));
25
26
  const set_stripe_customer_id_disabled_json_1 = __importDefault(require("./fixtures/set-stripe-customer-id-disabled.json"));
@@ -275,4 +276,15 @@ describe('Organizations', () => {
275
276
  });
276
277
  });
277
278
  });
279
+ describe('listOrganizationRoles', () => {
280
+ it('returns roles for the organization', () => __awaiter(void 0, void 0, void 0, function* () {
281
+ (0, test_utils_1.fetchOnce)(list_organization_roles_json_1.default);
282
+ const { data, object } = yield workos.organizations.listOrganizationRoles({
283
+ organizationId: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
284
+ });
285
+ expect((0, test_utils_1.fetchURL)()).toContain('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T/roles');
286
+ expect(object).toEqual('list');
287
+ expect(data).toHaveLength(3);
288
+ }));
289
+ });
278
290
  });
@@ -9,3 +9,31 @@ export interface RoleEventResponse {
9
9
  object: 'role';
10
10
  slug: string;
11
11
  }
12
+ export interface ListOrganizationRolesResponse {
13
+ object: 'list';
14
+ data: OrganizationRoleResponse[];
15
+ }
16
+ export interface OrganizationRoleResponse {
17
+ object: 'role';
18
+ id: string;
19
+ name: string;
20
+ slug: string;
21
+ description: string | null;
22
+ type: 'EnvironmentRole' | 'OrganizationRole';
23
+ created_at: string;
24
+ updated_at: string;
25
+ }
26
+ export interface Role {
27
+ object: 'role';
28
+ id: string;
29
+ name: string;
30
+ slug: string;
31
+ description: string | null;
32
+ type: 'EnvironmentRole' | 'OrganizationRole';
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ }
36
+ export interface RoleList {
37
+ object: 'list';
38
+ data: Role[];
39
+ }
@@ -0,0 +1,2 @@
1
+ import { OrganizationRoleResponse, Role } from '../interfaces';
2
+ export declare const deserializeRole: (role: OrganizationRoleResponse) => Role;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeRole = void 0;
4
+ const deserializeRole = (role) => ({
5
+ object: role.object,
6
+ id: role.id,
7
+ name: role.name,
8
+ slug: role.slug,
9
+ description: role.description,
10
+ type: role.type,
11
+ createdAt: role.created_at,
12
+ updatedAt: role.updated_at,
13
+ });
14
+ exports.deserializeRole = deserializeRole;
@@ -1,2 +1,2 @@
1
1
  import { RoleEvent, RoleEventResponse } from '../../roles/interfaces';
2
- export declare const deserializeRole: (role: RoleEventResponse) => RoleEvent;
2
+ export declare const deserializeRoleEvent: (role: RoleEventResponse) => RoleEvent;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeRole = void 0;
4
- const deserializeRole = (role) => ({
3
+ exports.deserializeRoleEvent = void 0;
4
+ const deserializeRoleEvent = (role) => ({
5
5
  object: 'role',
6
6
  slug: role.slug,
7
7
  });
8
- exports.deserializeRole = deserializeRole;
8
+ exports.deserializeRoleEvent = deserializeRoleEvent;
package/lib/workos.js CHANGED
@@ -29,7 +29,7 @@ const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider
29
29
  const fetch_client_1 = require("./common/net/fetch-client");
30
30
  const widgets_1 = require("./widgets/widgets");
31
31
  const actions_1 = require("./actions/actions");
32
- const VERSION = '7.35.1';
32
+ const VERSION = '7.36.0';
33
33
  const DEFAULT_HOSTNAME = 'api.workos.com';
34
34
  const HEADER_AUTHORIZATION = 'Authorization';
35
35
  const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.35.1",
2
+ "version": "7.36.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -72,4 +72,4 @@
72
72
  "default": "./lib/index.js"
73
73
  }
74
74
  }
75
- }
75
+ }