-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(clerk-js,types): Warn about publicUserData.profileImageUrl deprec…
…ation warning (#1812) To support the nested property deprecation we introduced a class to handle loading the PublicUserData and added a deprecation warning on that class profileImageUrl property. This changed was introduced based on the example of how the OrganizationMembership loads the Organization data.
- Loading branch information
Showing
7 changed files
with
49 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@clerk/clerk-js': patch | ||
'@clerk/types': patch | ||
--- | ||
|
||
Warn about `publicUserData.profileImageUrl` nested property deprecation in `OrganizationMembership` & `OrganizationMembershipRequest` resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/clerk-js/src/core/resources/OrganizationPublicUserData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { deprecatedProperty } from '@clerk/shared'; | ||
import type { PublicUserData } from '@clerk/types'; | ||
import type { PublicUserDataJSON } from '@clerk/types'; | ||
|
||
export class OrganizationPublicUserData implements PublicUserData { | ||
firstName!: string | null; | ||
lastName!: string | null; | ||
/** | ||
* @deprecated Use `imageUrl` instead. | ||
*/ | ||
profileImageUrl!: string; | ||
imageUrl!: string; | ||
hasImage!: boolean; | ||
identifier!: string; | ||
userId?: string; | ||
|
||
constructor(data: PublicUserDataJSON) { | ||
this.fromJSON(data); | ||
} | ||
|
||
protected fromJSON(data: PublicUserDataJSON | null): this { | ||
if (data) { | ||
this.firstName = data.first_name; | ||
this.lastName = data.last_name; | ||
this.profileImageUrl = data.profile_image_url; | ||
this.imageUrl = data.image_url; | ||
this.hasImage = data.has_image; | ||
this.identifier = data.identifier; | ||
this.userId = data.user_id; | ||
} | ||
|
||
return this; | ||
} | ||
} | ||
|
||
deprecatedProperty(OrganizationPublicUserData, 'profileImageUrl', 'Use `imageUrl` instead.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters