@workos-inc/node 7.4.0 → 7.5.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.
- package/lib/user-management/fixtures/deactivate-organization-membership.json +12 -0
- package/lib/user-management/interfaces/list-organization-memberships-options.interface.d.ts +3 -0
- package/lib/user-management/interfaces/organization-membership.interface.d.ts +3 -2
- package/lib/user-management/serializers/list-organization-memberships-options.serializer.js +12 -8
- package/lib/user-management/user-management.d.ts +2 -0
- package/lib/user-management/user-management.js +12 -0
- package/lib/user-management/user-management.spec.js +40 -5
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "organization_membership",
|
|
3
|
+
"id": "om_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
4
|
+
"user_id": "user_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
5
|
+
"organization_id": "organization_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
6
|
+
"status": "inactive",
|
|
7
|
+
"role": {
|
|
8
|
+
"slug": "member"
|
|
9
|
+
},
|
|
10
|
+
"created_at": "2023-07-18T02:07:19.911Z",
|
|
11
|
+
"updated_at": "2023-07-18T02:07:19.911Z"
|
|
12
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { PaginationOptions } from '../../common/interfaces';
|
|
2
|
+
import { OrganizationMembershipStatus } from './organization-membership.interface';
|
|
2
3
|
export interface ListOrganizationMembershipsOptions extends PaginationOptions {
|
|
3
4
|
organizationId?: string;
|
|
4
5
|
userId?: string;
|
|
6
|
+
statuses?: OrganizationMembershipStatus[];
|
|
5
7
|
}
|
|
6
8
|
export interface SerializedListOrganizationMembershipsOptions extends PaginationOptions {
|
|
7
9
|
organization_id?: string;
|
|
8
10
|
user_id?: string;
|
|
11
|
+
statuses?: string;
|
|
9
12
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { RoleResponse } from './role.interface';
|
|
2
|
+
export type OrganizationMembershipStatus = 'active' | 'inactive' | 'pending';
|
|
2
3
|
export interface OrganizationMembership {
|
|
3
4
|
object: 'organization_membership';
|
|
4
5
|
id: string;
|
|
5
6
|
organizationId: string;
|
|
6
|
-
status:
|
|
7
|
+
status: OrganizationMembershipStatus;
|
|
7
8
|
userId: string;
|
|
8
9
|
createdAt: string;
|
|
9
10
|
updatedAt: string;
|
|
@@ -13,7 +14,7 @@ export interface OrganizationMembershipResponse {
|
|
|
13
14
|
object: 'organization_membership';
|
|
14
15
|
id: string;
|
|
15
16
|
organization_id: string;
|
|
16
|
-
status:
|
|
17
|
+
status: OrganizationMembershipStatus;
|
|
17
18
|
user_id: string;
|
|
18
19
|
created_at: string;
|
|
19
20
|
updated_at: string;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serializeListOrganizationMembershipsOptions = void 0;
|
|
4
|
-
const serializeListOrganizationMembershipsOptions = (options) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const serializeListOrganizationMembershipsOptions = (options) => {
|
|
5
|
+
var _a;
|
|
6
|
+
return ({
|
|
7
|
+
user_id: options.userId,
|
|
8
|
+
organization_id: options.organizationId,
|
|
9
|
+
statuses: (_a = options.statuses) === null || _a === void 0 ? void 0 : _a.join(','),
|
|
10
|
+
limit: options.limit,
|
|
11
|
+
before: options.before,
|
|
12
|
+
after: options.after,
|
|
13
|
+
order: options.order,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
12
16
|
exports.serializeListOrganizationMembershipsOptions = serializeListOrganizationMembershipsOptions;
|
|
@@ -55,6 +55,8 @@ export declare class UserManagement {
|
|
|
55
55
|
createOrganizationMembership(options: CreateOrganizationMembershipOptions): Promise<OrganizationMembership>;
|
|
56
56
|
updateOrganizationMembership(organizationMembershipId: string, options: UpdateOrganizationMembershipOptions): Promise<OrganizationMembership>;
|
|
57
57
|
deleteOrganizationMembership(organizationMembershipId: string): Promise<void>;
|
|
58
|
+
deactivateOrganizationMembership(organizationMembershipId: string): Promise<OrganizationMembership>;
|
|
59
|
+
reactivateOrganizationMembership(organizationMembershipId: string): Promise<OrganizationMembership>;
|
|
58
60
|
getInvitation(invitationId: string): Promise<Invitation>;
|
|
59
61
|
listInvitations(options: ListInvitationsOptions): Promise<AutoPaginatable<Invitation>>;
|
|
60
62
|
sendInvitation(payload: SendInvitationOptions): Promise<Invitation>;
|
|
@@ -202,6 +202,18 @@ class UserManagement {
|
|
|
202
202
|
yield this.workos.delete(`/user_management/organization_memberships/${organizationMembershipId}`);
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
+
deactivateOrganizationMembership(organizationMembershipId) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
const { data } = yield this.workos.put(`/user_management/organization_memberships/${organizationMembershipId}/deactivate`, {});
|
|
208
|
+
return (0, organization_membership_serializer_1.deserializeOrganizationMembership)(data);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
reactivateOrganizationMembership(organizationMembershipId) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
+
const { data } = yield this.workos.put(`/user_management/organization_memberships/${organizationMembershipId}/reactivate`, {});
|
|
214
|
+
return (0, organization_membership_serializer_1.deserializeOrganizationMembership)(data);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
205
217
|
getInvitation(invitationId) {
|
|
206
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
207
219
|
const { data } = yield this.workos.get(`/user_management/invitations/${invitationId}`);
|
|
@@ -15,14 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
|
|
16
16
|
const test_utils_1 = require("../common/utils/test-utils");
|
|
17
17
|
const workos_1 = require("../workos");
|
|
18
|
-
const
|
|
19
|
-
const list_users_json_1 = __importDefault(require("./fixtures/list-users.json"));
|
|
20
|
-
const list_factors_json_1 = __importDefault(require("./fixtures/list-factors.json"));
|
|
21
|
-
const organization_membership_json_1 = __importDefault(require("./fixtures/organization-membership.json"));
|
|
22
|
-
const list_organization_memberships_json_1 = __importDefault(require("./fixtures/list-organization-memberships.json"));
|
|
18
|
+
const deactivate_organization_membership_json_1 = __importDefault(require("./fixtures/deactivate-organization-membership.json"));
|
|
23
19
|
const invitation_json_1 = __importDefault(require("./fixtures/invitation.json"));
|
|
20
|
+
const list_factors_json_1 = __importDefault(require("./fixtures/list-factors.json"));
|
|
24
21
|
const list_invitations_json_1 = __importDefault(require("./fixtures/list-invitations.json"));
|
|
22
|
+
const list_organization_memberships_json_1 = __importDefault(require("./fixtures/list-organization-memberships.json"));
|
|
23
|
+
const list_users_json_1 = __importDefault(require("./fixtures/list-users.json"));
|
|
25
24
|
const magic_auth_json_1 = __importDefault(require("./fixtures/magic_auth.json"));
|
|
25
|
+
const organization_membership_json_1 = __importDefault(require("./fixtures/organization-membership.json"));
|
|
26
|
+
const user_json_1 = __importDefault(require("./fixtures/user.json"));
|
|
26
27
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
27
28
|
const userId = 'user_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
28
29
|
const organizationMembershipId = 'om_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
@@ -583,12 +584,14 @@ describe('UserManagement', () => {
|
|
|
583
584
|
yield workos.userManagement.listOrganizationMemberships({
|
|
584
585
|
userId: 'user_someuser',
|
|
585
586
|
organizationId: 'org_someorg',
|
|
587
|
+
statuses: ['active', 'inactive'],
|
|
586
588
|
after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
587
589
|
limit: 10,
|
|
588
590
|
});
|
|
589
591
|
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
590
592
|
user_id: 'user_someuser',
|
|
591
593
|
organization_id: 'org_someorg',
|
|
594
|
+
statuses: 'active,inactive',
|
|
592
595
|
after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
593
596
|
limit: '10',
|
|
594
597
|
order: 'desc',
|
|
@@ -644,6 +647,38 @@ describe('UserManagement', () => {
|
|
|
644
647
|
expect(resp).toBeUndefined();
|
|
645
648
|
}));
|
|
646
649
|
});
|
|
650
|
+
describe('deactivateOrganizationMembership', () => {
|
|
651
|
+
it('sends a deactivateOrganizationMembership request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
652
|
+
(0, test_utils_1.fetchOnce)(deactivate_organization_membership_json_1.default);
|
|
653
|
+
const organizationMembership = yield workos.userManagement.deactivateOrganizationMembership(organizationMembershipId);
|
|
654
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/organization_memberships/${organizationMembershipId}/deactivate`);
|
|
655
|
+
expect(organizationMembership).toMatchObject({
|
|
656
|
+
object: 'organization_membership',
|
|
657
|
+
organizationId: 'organization_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
658
|
+
userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
659
|
+
status: 'inactive',
|
|
660
|
+
role: {
|
|
661
|
+
slug: 'member',
|
|
662
|
+
},
|
|
663
|
+
});
|
|
664
|
+
}));
|
|
665
|
+
});
|
|
666
|
+
describe('reactivateOrganizationMembership', () => {
|
|
667
|
+
it('sends a reactivateOrganizationMembership request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
668
|
+
(0, test_utils_1.fetchOnce)(organization_membership_json_1.default);
|
|
669
|
+
const organizationMembership = yield workos.userManagement.reactivateOrganizationMembership(organizationMembershipId);
|
|
670
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/organization_memberships/${organizationMembershipId}/reactivate`);
|
|
671
|
+
expect(organizationMembership).toMatchObject({
|
|
672
|
+
object: 'organization_membership',
|
|
673
|
+
organizationId: 'organization_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
674
|
+
userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
675
|
+
status: 'active',
|
|
676
|
+
role: {
|
|
677
|
+
slug: 'member',
|
|
678
|
+
},
|
|
679
|
+
});
|
|
680
|
+
}));
|
|
681
|
+
});
|
|
647
682
|
describe('getInvitation', () => {
|
|
648
683
|
it('sends a Get Invitation request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
649
684
|
(0, test_utils_1.fetchOnce)(invitation_json_1.default);
|
package/lib/workos.js
CHANGED
|
@@ -24,7 +24,7 @@ const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
|
24
24
|
const user_management_1 = require("./user-management/user-management");
|
|
25
25
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
26
26
|
const fetch_client_1 = require("./common/utils/fetch-client");
|
|
27
|
-
const VERSION = '7.
|
|
27
|
+
const VERSION = '7.5.0';
|
|
28
28
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
29
29
|
class WorkOS {
|
|
30
30
|
constructor(key, options = {}) {
|
package/package.json
CHANGED