Skip to content

Commit 636a20a

Browse files
committed
chore(types): Add Key prefix to OrganizationCustomPermission
1 parent bda5428 commit 636a20a

File tree

11 files changed

+41
-55
lines changed

11 files changed

+41
-55
lines changed

packages/backend/src/tokens/authObjects.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type {
22
ActClaim,
33
CheckAuthorizationWithCustomPermissions,
44
JwtPayload,
5-
OrganizationCustomPermission,
6-
OrganizationCustomRole,
5+
OrganizationCustomPermissionKey,
6+
OrganizationCustomRoleKey,
77
ServerGetToken,
88
ServerGetTokenOptions,
99
} from '@clerk/types';
@@ -30,9 +30,9 @@ export type SignedInAuthObject = {
3030
userId: string;
3131
user: User | undefined;
3232
orgId: string | undefined;
33-
orgRole: OrganizationCustomRole | undefined;
33+
orgRole: OrganizationCustomRoleKey | undefined;
3434
orgSlug: string | undefined;
35-
orgPermissions: OrganizationCustomPermission[] | undefined;
35+
orgPermissions: OrganizationCustomPermissionKey[] | undefined;
3636
organization: Organization | undefined;
3737
getToken: ServerGetToken;
3838
has: CheckAuthorizationWithCustomPermissions;

packages/clerk-js/src/core/resources/OrganizationMembership.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
MembershipRole,
66
OrganizationMembershipJSON,
77
OrganizationMembershipResource,
8-
OrganizationPermission,
8+
OrganizationPermissionKey,
99
} from '@clerk/types';
1010

1111
import { unixEpochToDate } from '../../utils/date';
@@ -17,10 +17,7 @@ export class OrganizationMembership extends BaseResource implements Organization
1717
publicMetadata: OrganizationMembershipPublicMetadata = {};
1818
publicUserData!: PublicUserData;
1919
organization!: Organization;
20-
/**
21-
* @experimental The property is experimental and subject to change in future releases.
22-
*/
23-
permissions: OrganizationPermission[] = [];
20+
permissions: OrganizationPermissionKey[] = [];
2421
role!: MembershipRole;
2522
createdAt!: Date;
2623
updatedAt!: Date;
@@ -36,7 +33,7 @@ export class OrganizationMembership extends BaseResource implements Organization
3633
method: 'GET',
3734
// `paginated` is used in some legacy endpoints to support clerk paginated responses
3835
// The parameter will be dropped in FAPI v2
39-
search: convertPageToOffset({ ...retrieveMembershipsParams, paginated: true }) as any,
36+
search: convertPageToOffset({ ...retrieveMembershipsParams, paginated: true }),
4037
})
4138
.then(res => {
4239
if (!res?.response) {

packages/nextjs/src/app-router/server/auth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { SignedInAuthObject, SignedOutAuthObject } from '@clerk/backend';
22
import type {
33
CheckAuthorizationWithCustomPermissions,
4-
OrganizationCustomPermission,
5-
OrganizationCustomRole,
4+
OrganizationCustomPermissionKey,
5+
OrganizationCustomRoleKey,
66
} from '@clerk/types';
77
import { notFound } from 'next/navigation';
88

@@ -21,12 +21,12 @@ export const auth = () => {
2121
protect: (
2222
params?:
2323
| {
24-
role: OrganizationCustomRole;
24+
role: OrganizationCustomRoleKey;
2525
permission?: never;
2626
}
2727
| {
2828
role?: never;
29-
permission: OrganizationCustomPermission;
29+
permission: OrganizationCustomPermissionKey;
3030
}
3131
| ((has: CheckAuthorizationWithCustomPermissions) => boolean),
3232
) => AuthObjectWithoutResources<SignedInAuthObject>;

packages/nextjs/src/app-router/server/controlComponents.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {
22
CheckAuthorizationWithCustomPermissions,
3-
OrganizationCustomPermission,
4-
OrganizationCustomRole,
3+
OrganizationCustomPermissionKey,
4+
OrganizationCustomRoleKey,
55
} from '@clerk/types';
66
import React from 'react';
77

@@ -19,17 +19,17 @@ export function SignedOut(props: React.PropsWithChildren) {
1919
return userId ? null : <>{children}</>;
2020
}
2121

22-
type GateServerComponentProps = React.PropsWithChildren<
22+
type ProtectServerComponentProps = React.PropsWithChildren<
2323
(
2424
| {
2525
condition?: never;
26-
role: OrganizationCustomRole;
26+
role: OrganizationCustomRoleKey;
2727
permission?: never;
2828
}
2929
| {
3030
condition?: never;
3131
role?: never;
32-
permission: OrganizationCustomPermission;
32+
permission: OrganizationCustomPermissionKey;
3333
}
3434
| {
3535
condition: (has: CheckAuthorizationWithCustomPermissions) => boolean;
@@ -46,11 +46,8 @@ type GateServerComponentProps = React.PropsWithChildren<
4646
}
4747
>;
4848

49-
/**
50-
* @experimental The component is experimental and subject to change in future releases.
51-
*/
52-
export function Protect(gateProps: GateServerComponentProps) {
53-
const { children, fallback, ...restAuthorizedParams } = gateProps;
49+
export function Protect(props: ProtectServerComponentProps) {
50+
const { children, fallback, ...restAuthorizedParams } = props;
5451
const { has, userId, sessionId } = auth();
5552

5653
/**

packages/nextjs/src/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ export const ClerkProvider = ComponentsModule.ClerkProvider as ServerComponentsS
8989
export const SignedIn = ComponentsModule.SignedIn as ServerComponentsServerModuleTypes['SignedIn'];
9090
export const SignedOut = ComponentsModule.SignedOut as ServerComponentsServerModuleTypes['SignedOut'];
9191

92-
/**
93-
* @experimental
94-
*/
9592
export const Protect = ComponentsModule.Protect as ServerComponentsServerModuleTypes['Protect'];
9693

9794
export const auth = ServerHelperModule.auth as ServerHelpersServerModuleTypes['auth'];

packages/react/src/components/controlComponents.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {
22
CheckAuthorizationWithCustomPermissions,
33
HandleOAuthCallbackParams,
4-
OrganizationCustomPermission,
5-
OrganizationCustomRole,
4+
OrganizationCustomPermissionKey,
5+
OrganizationCustomRoleKey,
66
} from '@clerk/types';
77
import React from 'react';
88

@@ -50,13 +50,13 @@ type ProtectProps = React.PropsWithChildren<
5050
(
5151
| {
5252
condition?: never;
53-
role: OrganizationCustomRole;
53+
role: OrganizationCustomRoleKey;
5454
permission?: never;
5555
}
5656
| {
5757
condition?: never;
5858
role?: never;
59-
permission: OrganizationCustomPermission;
59+
permission: OrganizationCustomPermissionKey;
6060
}
6161
| {
6262
condition: (has: CheckAuthorizationWithCustomPermissions) => boolean;

packages/types/src/json.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { ActJWTClaim } from './jwt';
77
import type { OAuthProvider } from './oauth';
88
import type { OrganizationDomainVerificationStatus, OrganizationEnrollmentMode } from './organizationDomain';
99
import type { OrganizationInvitationStatus } from './organizationInvitation';
10-
import type { MembershipRole, OrganizationPermission } from './organizationMembership';
10+
import type { MembershipRole, OrganizationPermissionKey } from './organizationMembership';
1111
import type { OrganizationSettingsJSON } from './organizationSettings';
1212
import type { OrganizationSuggestionStatus } from './organizationSuggestion';
1313
import type { SamlIdpSlug } from './saml';
@@ -300,10 +300,7 @@ export interface OrganizationMembershipJSON extends ClerkResourceJSON {
300300
object: 'organization_membership';
301301
id: string;
302302
organization: OrganizationJSON;
303-
/**
304-
* @experimental The property is experimental and subject to change in future releases.
305-
*/
306-
permissions: OrganizationPermission[];
303+
permissions: OrganizationPermissionKey[];
307304
public_metadata: OrganizationMembershipPublicMetadata;
308305
public_user_data: PublicUserDataJSON;
309306
role: MembershipRole;

packages/types/src/jwtv2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { MembershipRole, OrganizationCustomPermission } from './organizationMembership';
1+
import type { MembershipRole, OrganizationCustomPermissionKey } from './organizationMembership';
22

33
export interface Jwt {
44
header: JwtHeader;
@@ -99,7 +99,7 @@ export interface JwtPayload extends CustomJwtSessionClaims {
9999
/**
100100
* Active organization role
101101
*/
102-
org_permissions?: OrganizationCustomPermission[];
102+
org_permissions?: OrganizationCustomPermissionKey[];
103103

104104
/**
105105
* Any other JWT Claim Set member.

packages/types/src/organizationMembership.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ declare global {
2626
export interface OrganizationMembershipResource extends ClerkResource {
2727
id: string;
2828
organization: OrganizationResource;
29-
/**
30-
* @experimental The property is experimental and subject to change in future releases.
31-
*/
32-
permissions: OrganizationPermission[];
29+
permissions: OrganizationPermissionKey[];
3330
publicMetadata: OrganizationMembershipPublicMetadata;
3431
publicUserData: PublicUserData;
3532
role: MembershipRole;
@@ -39,8 +36,8 @@ export interface OrganizationMembershipResource extends ClerkResource {
3936
update: (updateParams: UpdateOrganizationMembershipParams) => Promise<OrganizationMembershipResource>;
4037
}
4138

42-
export type OrganizationCustomPermission = string;
43-
export type OrganizationCustomRole = string;
39+
export type OrganizationCustomPermissionKey = string;
40+
export type OrganizationCustomRoleKey = string;
4441

4542
/**
4643
* @deprecated This type is deprecated and will be removed in the next major release.
@@ -50,7 +47,7 @@ export type OrganizationCustomRole = string;
5047
*/
5148
export type MembershipRole = Autocomplete<'admin' | 'basic_member' | 'guest_member'>;
5249

53-
export type OrganizationSystemPermission =
50+
export type OrganizationSystemPermissionKey =
5451
| 'org:sys_domains:manage'
5552
| 'org:sys_domains:delete'
5653
| 'org:sys_profile:manage'
@@ -64,7 +61,7 @@ export type OrganizationSystemPermission =
6461
* OrganizationPermission is a combination of system and custom permissions.
6562
* System permissions are only accessible from FAPI and client-side operations/utils
6663
*/
67-
export type OrganizationPermission = Autocomplete<OrganizationSystemPermission>;
64+
export type OrganizationPermissionKey = Autocomplete<OrganizationSystemPermissionKey>;
6865

6966
export type UpdateOrganizationMembershipParams = {
7067
role: MembershipRole;

packages/types/src/session.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import type { ActJWTClaim } from './jwt';
22
import type {
33
MembershipRole,
4-
OrganizationCustomPermission,
5-
OrganizationCustomRole,
6-
OrganizationPermission,
4+
OrganizationCustomPermissionKey,
5+
OrganizationCustomRoleKey,
6+
OrganizationPermissionKey,
77
} from './organizationMembership';
88
import type { ClerkResource } from './resource';
99
import type { TokenResource } from './token';
1010
import type { UserResource } from './user';
11+
1112
export type CheckAuthorizationFn<Params> = (isAuthorizedParams: Params) => boolean;
1213

1314
export type CheckAuthorizationWithCustomPermissions =
1415
CheckAuthorizationFn<CheckAuthorizationParamsWithCustomPermissions>;
1516

1617
type CheckAuthorizationParamsWithCustomPermissions =
1718
| {
18-
role: OrganizationCustomRole;
19+
role: OrganizationCustomRoleKey;
1920
permission?: never;
2021
}
2122
| {
2223
role?: never;
23-
permission: OrganizationCustomPermission;
24+
permission: OrganizationCustomPermissionKey;
2425
};
2526

2627
export type CheckAuthorization = CheckAuthorizationFn<CheckAuthorizationParams>;
@@ -34,7 +35,7 @@ type CheckAuthorizationParams =
3435
}
3536
| {
3637
role?: never;
37-
permission: OrganizationPermission;
38+
permission: OrganizationPermissionKey;
3839
}
3940
)[];
4041
role?: never;
@@ -48,7 +49,7 @@ type CheckAuthorizationParams =
4849
| {
4950
some?: never;
5051
role?: never;
51-
permission: OrganizationPermission;
52+
permission: OrganizationPermissionKey;
5253
};
5354

5455
export interface SessionResource extends ClerkResource {

packages/types/src/ssr.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ActClaim, JwtPayload } from './jwtv2';
22
import type { OrganizationResource } from './organization';
3-
import type { MembershipRole, OrganizationCustomPermission } from './organizationMembership';
3+
import type { MembershipRole, OrganizationCustomPermissionKey } from './organizationMembership';
44
import type { SessionResource } from './session';
55
import type { UserResource } from './user';
66
import type { Serializable } from './utils';
@@ -18,6 +18,6 @@ export type InitialState = Serializable<{
1818
orgId: string | undefined;
1919
orgRole: MembershipRole | undefined;
2020
orgSlug: string | undefined;
21-
orgPermissions: OrganizationCustomPermission[] | undefined;
21+
orgPermissions: OrganizationCustomPermissionKey[] | undefined;
2222
organization: OrganizationResource | undefined;
2323
}>;

0 commit comments

Comments
 (0)