Skip to content

Commit 93d05c8

Browse files
authored
revert(backend): Introduce OrganizationPermissionAPI and OrganizationRoleAPI (#2252)
* Revert "feat(backend): Introduce OrganizationRoleAPI (#2177)" This reverts commit b3a3dcd * Revert "feat(backend): Introduce OrganizationPermissionAPI (#2178)" This reverts commit 0ce0edc * chore(backend): Add changeset * chore(backend): Keep the previous changesets
1 parent 7d93c4c commit 93d05c8

File tree

14 files changed

+8
-300
lines changed

14 files changed

+8
-300
lines changed

.changeset/cyan-dodos-provide.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-sdk-node': patch
3+
'@clerk/backend': patch
4+
'@clerk/nextjs': patch
5+
---
6+
7+
Drop the introduction of `OrganizationRole` and `OrganizationPermission` resources fro BAPI.
Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +0,0 @@
1-
import type { ClerkPaginationRequest } from '@clerk/types';
2-
3-
import { joinPaths } from '../../util/path';
4-
import type { DeletedObject, Permission } from '../resources';
5-
import { AbstractAPI } from './AbstractApi';
6-
7-
const basePath = '/organizations_permissions';
8-
9-
type GetOrganizationPermissionListParams = ClerkPaginationRequest<{
10-
query?: string;
11-
orderBy?: string;
12-
}>;
13-
14-
type CreateParams = {
15-
name: string;
16-
key: string;
17-
description: string;
18-
};
19-
20-
type GetOrganizationPermissionParams = { permissionId: string };
21-
22-
type UpdateParams = {
23-
name?: string;
24-
key?: string;
25-
description?: string;
26-
};
27-
28-
export class OrganizationPermissionAPI extends AbstractAPI {
29-
public async getOrganizationPermissionList(params?: GetOrganizationPermissionListParams) {
30-
return this.request<Permission[]>({
31-
method: 'GET',
32-
path: basePath,
33-
queryParams: params,
34-
});
35-
}
36-
37-
public async createOrganizationPermission(params: CreateParams) {
38-
return this.request<Permission>({
39-
method: 'POST',
40-
path: basePath,
41-
bodyParams: params,
42-
});
43-
}
44-
45-
public async getOrganizationPermission(params: GetOrganizationPermissionParams) {
46-
this.requireId(params.permissionId);
47-
48-
return this.request<Permission>({
49-
method: 'GET',
50-
path: joinPaths(basePath, params.permissionId),
51-
});
52-
}
53-
54-
public async updateOrganizationPermission(permissionId: string, params: UpdateParams) {
55-
this.requireId(permissionId);
56-
return this.request<Permission>({
57-
method: 'PATCH',
58-
path: joinPaths(basePath, permissionId),
59-
bodyParams: params,
60-
});
61-
}
62-
63-
public async deleteOrganizationPermission(permissionId: string) {
64-
return this.request<DeletedObject>({
65-
method: 'DELETE',
66-
path: joinPaths(basePath, permissionId),
67-
});
68-
}
69-
}
Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +0,0 @@
1-
import type { ClerkPaginationRequest } from '@clerk/types';
2-
3-
import { joinPaths } from '../../util/path';
4-
import type { DeletedObject, Role } from '../resources';
5-
import { AbstractAPI } from './AbstractApi';
6-
7-
const basePath = '/organizations_roles';
8-
9-
type GetRoleListParams = ClerkPaginationRequest<{
10-
query?: string;
11-
order_by?: string;
12-
}>;
13-
14-
type CreateParams = {
15-
/**
16-
* A name of a role in a readable friendly format.
17-
* F.e. `Teacher` or `Administrator`
18-
*/
19-
name: string;
20-
21-
/**
22-
* A unique identifier that represents the role.
23-
* F.e. `org:administrator`
24-
*/
25-
key: string;
26-
27-
/**
28-
* A brief description of what the role represents or its intended use.
29-
*/
30-
description: string;
31-
32-
/**
33-
* An array of permission ids that will be assigned to this role.
34-
*/
35-
permissions: string[];
36-
};
37-
38-
type GetOrganizationRoleParams = { roleId: string };
39-
40-
type UpdateParams = {
41-
/**
42-
* A name of a role in a readable friendly format.
43-
* F.e. `Teacher` or `Administrator`
44-
* Passing undefined has no effect to the existing value.
45-
*/
46-
name?: string;
47-
48-
/**
49-
* A unique identifier that represents the role.
50-
* F.e. `org:administrator`
51-
* Passing undefined has no effect to the existing value.
52-
*/
53-
key?: string;
54-
55-
/**
56-
* A brief description of what the role represents or its intended use.
57-
* Passing undefined has no effect to the existing value.
58-
*/
59-
description?: string;
60-
61-
/**
62-
* An array of permission ids that will be assigned to this role.
63-
* Passing undefined has no effect to the permission that already exist.
64-
* Passing an empty array will override the existing permissions.
65-
*/
66-
permissions?: string[];
67-
};
68-
69-
type RemovePermissionParams = {
70-
permissionId: string;
71-
roleId: string;
72-
};
73-
74-
type AssignPermissionParams = RemovePermissionParams;
75-
76-
export class OrganizationRoleAPI extends AbstractAPI {
77-
public async getOrganizationRoleList(params?: GetRoleListParams) {
78-
return this.request<Role[]>({
79-
method: 'GET',
80-
path: basePath,
81-
queryParams: params,
82-
});
83-
}
84-
85-
public async createOrganizationRole(params: CreateParams) {
86-
return this.request<Role>({
87-
method: 'POST',
88-
path: basePath,
89-
bodyParams: params,
90-
});
91-
}
92-
93-
public async getOrganizationRole(params: GetOrganizationRoleParams) {
94-
this.requireId(params.roleId);
95-
96-
return this.request<Role>({
97-
method: 'GET',
98-
path: joinPaths(basePath, params.roleId),
99-
});
100-
}
101-
102-
public async updateOrganizationRole(roleId: string, params: UpdateParams) {
103-
this.requireId(roleId);
104-
return this.request<Role>({
105-
method: 'PATCH',
106-
path: joinPaths(basePath, roleId),
107-
bodyParams: params,
108-
});
109-
}
110-
111-
public async deleteOrganizationRole(roleId: string) {
112-
this.requireId(roleId);
113-
return this.request<DeletedObject>({
114-
method: 'DELETE',
115-
path: joinPaths(basePath, roleId),
116-
});
117-
}
118-
119-
public async assignPermissionToRole(params: AssignPermissionParams) {
120-
const { roleId, permissionId } = params;
121-
this.requireId(roleId);
122-
this.requireId(permissionId);
123-
return this.request<Role>({
124-
method: 'POST',
125-
path: joinPaths(basePath, roleId, 'permission', permissionId),
126-
});
127-
}
128-
129-
public async removePermissionFromRole(params: RemovePermissionParams) {
130-
const { roleId, permissionId } = params;
131-
this.requireId(roleId);
132-
this.requireId(permissionId);
133-
return this.request<Role>({
134-
method: 'DELETE',
135-
path: joinPaths(basePath, roleId, 'permission', permissionId),
136-
});
137-
}
138-
}

packages/backend/src/api/endpoints/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ export * from './EmailApi';
77
export * from './InterstitialApi';
88
export * from './InvitationApi';
99
export * from './OrganizationApi';
10-
export * from './OrganizationRoleApi';
11-
export * from './OrganizationPermissionApi';
1210
export * from './PhoneNumberApi';
1311
export * from './RedirectUrlApi';
1412
export * from './SessionApi';

packages/backend/src/api/factory.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {
77
InterstitialAPI,
88
InvitationAPI,
99
OrganizationAPI,
10-
OrganizationPermissionAPI,
11-
OrganizationRoleAPI,
1210
PhoneNumberAPI,
1311
RedirectUrlAPI,
1412
SessionAPI,
@@ -23,6 +21,7 @@ export type ApiClient = ReturnType<typeof createBackendApiClient>;
2321

2422
export function createBackendApiClient(options: CreateBackendApiOptions) {
2523
const request = buildRequest(options);
24+
2625
return {
2726
allowlistIdentifiers: new AllowlistIdentifierAPI(request),
2827
clients: new ClientAPI(request),
@@ -31,8 +30,6 @@ export function createBackendApiClient(options: CreateBackendApiOptions) {
3130
interstitial: new InterstitialAPI(request),
3231
invitations: new InvitationAPI(request),
3332
organizations: new OrganizationAPI(request),
34-
organizationRoles: new OrganizationRoleAPI(request),
35-
organizationPermissions: new OrganizationPermissionAPI(request),
3633
phoneNumbers: new PhoneNumberAPI(request),
3734
redirectUrls: new RedirectUrlAPI(request),
3835
sessions: new SessionAPI(request),

packages/backend/src/api/resources/Enums.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ export type OAuthStrategy = `oauth_${OAuthProvider}`;
2020

2121
export type OrganizationInvitationStatus = 'pending' | 'accepted' | 'revoked';
2222

23-
export type PermissionType = 'system' | 'user';
24-
25-
/**
26-
* @deprecated In the next major release this type will change to string
27-
*/
2823
export type OrganizationMembershipRole = 'basic_member' | 'guest_member' | 'admin';
2924

3025
export type SignInStatus = 'needs_identifier' | 'needs_factor_one' | 'needs_factor_two' | 'complete';

packages/backend/src/api/resources/JSON.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type {
22
InvitationStatus,
33
OrganizationInvitationStatus,
44
OrganizationMembershipRole,
5-
PermissionType,
65
SignInStatus,
76
SignUpAttributeRequirements,
87
SignUpStatus,
@@ -21,8 +20,6 @@ export enum ObjectType {
2120
Organization = 'organization',
2221
OrganizationInvitation = 'organization_invitation',
2322
OrganizationMembership = 'organization_membership',
24-
Role = 'role',
25-
Permission = 'permission',
2623
PhoneNumber = 'phone_number',
2724
RedirectUrl = 'redirect_url',
2825
Session = 'session',
@@ -175,27 +172,6 @@ export interface OrganizationMembershipPublicUserDataJSON {
175172
user_id: string;
176173
}
177174

178-
export interface RoleJSON extends ClerkResourceJSON {
179-
object: ObjectType.Role;
180-
name: string;
181-
key: string;
182-
description: string;
183-
permissions: PermissionJSON[];
184-
created_at: number;
185-
updated_at: number;
186-
}
187-
188-
export interface PermissionJSON extends ClerkResourceJSON {
189-
object: ObjectType.Permission;
190-
id: string;
191-
name: string;
192-
key: string;
193-
description: string;
194-
type: PermissionType;
195-
created_at: number;
196-
updated_at: number;
197-
}
198-
199175
export interface PhoneNumberJSON extends ClerkResourceJSON {
200176
object: ObjectType.PhoneNumber;
201177
phone_number: string;

packages/backend/src/api/resources/Permission.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/backend/src/api/resources/Role.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/backend/src/api/resources/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ export * from './Invitation';
2222
export * from './JSON';
2323
export * from './OauthAccessToken';
2424
export * from './Organization';
25-
export * from './Role';
26-
export * from './Permission';
2725
export * from './OrganizationInvitation';
2826
export * from './OrganizationMembership';
2927
export * from './PhoneNumber';

0 commit comments

Comments
 (0)