Skip to content

Commit

Permalink
fix(clerk-js,clerk-react): Using missing MembershipRole type (#2403)
Browse files Browse the repository at this point in the history
* fix(clerk-js,clerk-react): Using missing MembershipRole type

* fix(clerk-js,clerk-react): Using missing MembershipRole type
  • Loading branch information
panteliselef authored Dec 19, 2023
1 parent 394cecc commit e425d17
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .changeset/fresh-crews-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
9 changes: 6 additions & 3 deletions packages/clerk-js/src/core/test/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type {
EmailAddressJSON,
ExternalAccountJSON,
MembershipRole,
OAuthProvider,
OrganizationCustomRoleKey,
OrganizationJSON,
OrganizationMembershipJSON,
OrganizationPermission,
OrganizationPermissionKey,
PhoneNumberJSON,
SessionJSON,
SignInJSON,
Expand All @@ -16,7 +16,10 @@ import type {
export const mockJwt =
'eyJhbGciOiJSUzI1NiIsImtpZCI6Imluc18yR0lvUWhiVXB5MGhYN0IyY1ZrdVRNaW5Yb0QiLCJ0eXAiOiJKV1QifQ.eyJhenAiOiJodHRwczovL2FjY291bnRzLmluc3BpcmVkLnB1bWEtNzQubGNsLmRldiIsImV4cCI6MTY2NjY0ODMxMCwiaWF0IjoxNjY2NjQ4MjUwLCJpc3MiOiJodHRwczovL2NsZXJrLmluc3BpcmVkLnB1bWEtNzQubGNsLmRldiIsIm5iZiI6MTY2NjY0ODI0MCwic2lkIjoic2Vzc18yR2JEQjRlbk5kQ2E1dlMxenBDM1h6Zzl0SzkiLCJzdWIiOiJ1c2VyXzJHSXBYT0VwVnlKdzUxcmtabjlLbW5jNlN4ciJ9.n1Usc-DLDftqA0Xb-_2w8IGs4yjCmwc5RngwbSRvwevuZOIuRoeHmE2sgCdEvjfJEa7ewL6EVGVcM557TWPW--g_J1XQPwBy8tXfz7-S73CEuyRFiR97L2AHRdvRtvGtwR-o6l8aHaFxtlmfWbQXfg4kFJz2UGe9afmh3U9-f_4JOZ5fa3mI98UMy1-bo20vjXeWQ9aGrqaxHQxjnzzC-1Kpi5LdPvhQ16H0dPB8MHRTSM5TAuLKTpPV7wqixmbtcc2-0k6b9FKYZNqRVTaIyV-lifZloBvdzlfOF8nW1VVH_fx-iW5Q3hovHFcJIULHEC1kcAYTubbxzpgeVQepGg';

export type OrgParams = Partial<OrganizationJSON> & { role?: MembershipRole; permissions?: OrganizationPermission[] };
export type OrgParams = Partial<OrganizationJSON> & {
role?: OrganizationCustomRoleKey;
permissions?: OrganizationPermissionKey[];
};

type WithUserParams = Omit<
Partial<UserJSON>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {
MembershipRole,
OrganizationCustomRoleKey,
OrganizationDomainResource,
OrganizationDomainVerification,
OrganizationEnrollmentMode,
Expand All @@ -15,7 +15,7 @@ import { jest } from '@jest/globals';
type FakeMemberParams = {
id: string;
orgId: string;
role?: MembershipRole;
role?: OrganizationCustomRoleKey;
identifier?: string;
firstName?: string;
lastName?: string;
Expand Down Expand Up @@ -78,7 +78,7 @@ export const createFakeDomain = (params: FakeDomainParams): OrganizationDomainRe

type FakeInvitationParams = {
id: string;
role?: MembershipRole;
role?: OrganizationCustomRoleKey;
status?: OrganizationInvitationStatus;
emailAddress: string;
organizationId: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {
MembershipRole,
OrganizationCustomRoleKey,
OrganizationInvitationStatus,
OrganizationMembershipResource,
OrganizationSuggestionResource,
Expand All @@ -15,7 +15,7 @@ type FakeOrganizationInvitationParams = {
id: string;
createdAt?: Date;
emailAddress: string;
role?: MembershipRole;
role?: OrganizationCustomRoleKey;
status?: OrganizationInvitationStatus;
publicOrganizationData?: { hasImage?: boolean; id?: string; imageUrl?: string; name?: string; slug?: string };
};
Expand Down Expand Up @@ -48,7 +48,7 @@ export const createFakeUserOrganizationInvitation = (
type FakeUserOrganizationMembershipParams = {
id: string;
createdAt?: Date;
role?: MembershipRole;
role?: OrganizationCustomRoleKey;
organization: FakeOrganizationParams;
};

Expand All @@ -59,6 +59,7 @@ export const createFakeUserOrganizationMembership = (
organization: createFakeOrganization(params.organization),
pathRoot: '',
role: params.role || 'basic_member',
permissions: [],
id: params.id,
createdAt: params?.createdAt || new Date(),
updatedAt: new Date(),
Expand All @@ -74,7 +75,7 @@ type FakeOrganizationSuggestionParams = {
id: string;
createdAt?: Date;
emailAddress: string;
role?: MembershipRole;
role?: OrganizationCustomRoleKey;
status?: OrganizationSuggestionStatus;
publicOrganizationData?: { hasImage?: boolean; id?: string; imageUrl?: string; name?: string; slug?: string };
};
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/contexts/AuthContext.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createContextAndHook } from '@clerk/shared/react';
import type { ActJWTClaim, MembershipRole, OrganizationCustomPermissionKey } from '@clerk/types';
import type { ActJWTClaim, OrganizationCustomPermissionKey, OrganizationCustomRoleKey } from '@clerk/types';

export const [AuthContext, useAuthContext] = createContextAndHook<{
userId: string | null | undefined;
sessionId: string | null | undefined;
actor: ActJWTClaim | null | undefined;
orgId: string | null | undefined;
orgRole: MembershipRole | null | undefined;
orgRole: OrganizationCustomRoleKey | null | undefined;
orgSlug: string | null | undefined;
orgPermissions: OrganizationCustomPermissionKey[] | null | undefined;
}>('AuthContext');
4 changes: 2 additions & 2 deletions packages/react/src/utils/deriveState.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type {
ActiveSessionResource,
InitialState,
MembershipRole,
OrganizationCustomPermissionKey,
OrganizationCustomRoleKey,
OrganizationResource,
Resources,
UserResource,
Expand All @@ -22,7 +22,7 @@ const deriveFromSsrInitialState = (initialState: InitialState) => {
const session = initialState.session as ActiveSessionResource;
const organization = initialState.organization as OrganizationResource;
const orgId = initialState.orgId;
const orgRole = initialState.orgRole as MembershipRole;
const orgRole = initialState.orgRole as OrganizationCustomRoleKey;
const orgPermissions = initialState.orgPermissions as OrganizationCustomPermissionKey[];
const orgSlug = initialState.orgSlug;
const actor = initialState.actor;
Expand Down

0 comments on commit e425d17

Please sign in to comment.