From 0867c739def5d6aa324da52c338dbbb070db04fd Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Tue, 1 Aug 2023 20:31:50 +0300 Subject: [PATCH 1/4] feat(backend): Add has_image field in user / organization --- packages/backend/src/api/resources/JSON.ts | 3 +++ packages/backend/src/api/resources/Organization.ts | 2 ++ packages/backend/src/api/resources/OrganizationMembership.ts | 2 ++ packages/backend/src/api/resources/User.ts | 2 ++ 4 files changed, 9 insertions(+) diff --git a/packages/backend/src/api/resources/JSON.ts b/packages/backend/src/api/resources/JSON.ts index 2bb65e7302..4c5be9fffc 100644 --- a/packages/backend/src/api/resources/JSON.ts +++ b/packages/backend/src/api/resources/JSON.ts @@ -138,6 +138,7 @@ export interface OrganizationJSON extends ClerkResourceJSON { */ logo_url: string | null; image_url: string; + has_image: boolean; public_metadata: OrganizationPublicMetadata | null; private_metadata?: OrganizationPrivateMetadata; created_by: string; @@ -178,6 +179,7 @@ export interface OrganizationMembershipPublicUserDataJSON { */ profile_image_url: string; image_url: string; + has_image: boolean; user_id: string; } @@ -264,6 +266,7 @@ export interface UserJSON extends ClerkResourceJSON { */ profile_image_url: string; image_url: string; + has_image: boolean; primary_email_address_id: string; primary_phone_number_id: string | null; primary_web3_wallet_id: string | null; diff --git a/packages/backend/src/api/resources/Organization.ts b/packages/backend/src/api/resources/Organization.ts index 995977df15..7d5172f9ce 100644 --- a/packages/backend/src/api/resources/Organization.ts +++ b/packages/backend/src/api/resources/Organization.ts @@ -10,6 +10,7 @@ export class Organization { */ readonly logoUrl: string | null, readonly imageUrl: string, + readonly hasImage: boolean, readonly createdBy: string, readonly createdAt: number, readonly updatedAt: number, @@ -26,6 +27,7 @@ export class Organization { data.slug, data.logo_url, data.image_url, + data.has_image, data.created_by, data.created_at, data.updated_at, diff --git a/packages/backend/src/api/resources/OrganizationMembership.ts b/packages/backend/src/api/resources/OrganizationMembership.ts index 5c5e8b75ca..a318bb4a9c 100644 --- a/packages/backend/src/api/resources/OrganizationMembership.ts +++ b/packages/backend/src/api/resources/OrganizationMembership.ts @@ -38,6 +38,7 @@ export class OrganizationMembershipPublicUserData { */ readonly profileImageUrl: string, readonly imageUrl: string, + readonly hasImage: boolean, readonly userId: string, ) {} @@ -48,6 +49,7 @@ export class OrganizationMembershipPublicUserData { data.last_name, data.profile_image_url, data.image_url, + data.has_image, data.user_id, ); } diff --git a/packages/backend/src/api/resources/User.ts b/packages/backend/src/api/resources/User.ts index ce9be7b51d..a3c5b4ea7b 100644 --- a/packages/backend/src/api/resources/User.ts +++ b/packages/backend/src/api/resources/User.ts @@ -19,6 +19,7 @@ export class User { */ readonly profileImageUrl: string, readonly imageUrl: string, + readonly hasImage: boolean, readonly gender: string, readonly birthday: string, readonly primaryEmailAddressId: string | null, @@ -50,6 +51,7 @@ export class User { data.updated_at, data.profile_image_url, data.image_url, + data.has_image, data.gender, data.birthday, data.primary_email_address_id, From 5d8a38015fc47ca00e65753ce075f7728e429a29 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Tue, 1 Aug 2023 20:32:20 +0300 Subject: [PATCH 2/4] feat(clerk-js): Add has_image field in user / organization --- packages/clerk-js/src/core/resources/Organization.test.ts | 1 + packages/clerk-js/src/core/resources/Organization.ts | 2 ++ .../clerk-js/src/core/resources/OrganizationMembership.test.ts | 2 ++ packages/clerk-js/src/core/resources/OrganizationMembership.ts | 1 + packages/clerk-js/src/core/resources/User.ts | 2 ++ .../src/core/resources/__snapshots__/Organization.test.ts.snap | 1 + .../resources/__snapshots__/OrganizationMembership.test.ts.snap | 2 ++ 7 files changed, 11 insertions(+) diff --git a/packages/clerk-js/src/core/resources/Organization.test.ts b/packages/clerk-js/src/core/resources/Organization.test.ts index 48274dc6c0..14a2f6f33c 100644 --- a/packages/clerk-js/src/core/resources/Organization.test.ts +++ b/packages/clerk-js/src/core/resources/Organization.test.ts @@ -16,6 +16,7 @@ describe('Organization', () => { pending_invitations_count: 10, admin_delete_enabled: true, max_allowed_memberships: 3, + has_image: true, }); expect(organization).toMatchSnapshot(); diff --git a/packages/clerk-js/src/core/resources/Organization.ts b/packages/clerk-js/src/core/resources/Organization.ts index 924b8d8715..430e32a356 100644 --- a/packages/clerk-js/src/core/resources/Organization.ts +++ b/packages/clerk-js/src/core/resources/Organization.ts @@ -29,6 +29,7 @@ export class Organization extends BaseResource implements OrganizationResource { */ logoUrl!: string; imageUrl!: string; + hasImage!: boolean; publicMetadata: OrganizationPublicMetadata = {}; adminDeleteEnabled!: boolean; createdAt!: Date; @@ -181,6 +182,7 @@ export class Organization extends BaseResource implements OrganizationResource { this.slug = data.slug; this.logoUrl = data.logo_url; this.imageUrl = data.image_url; + this.hasImage = data.has_image; this.publicMetadata = data.public_metadata; this.membersCount = data.members_count; this.pendingInvitationsCount = data.pending_invitations_count; diff --git a/packages/clerk-js/src/core/resources/OrganizationMembership.test.ts b/packages/clerk-js/src/core/resources/OrganizationMembership.test.ts index dfa7bc0bcd..cbc0b2e418 100644 --- a/packages/clerk-js/src/core/resources/OrganizationMembership.test.ts +++ b/packages/clerk-js/src/core/resources/OrganizationMembership.test.ts @@ -22,6 +22,7 @@ describe('OrganizationMembership', () => { pending_invitations_count: 10, admin_delete_enabled: true, max_allowed_memberships: 3, + has_image: true, }, public_metadata: { foo: 'bar', @@ -34,6 +35,7 @@ describe('OrganizationMembership', () => { image_url: 'https://clerk.com', identifier: 'test@identifier.gr', id: 'test_user_id', + has_image: true, }, }); diff --git a/packages/clerk-js/src/core/resources/OrganizationMembership.ts b/packages/clerk-js/src/core/resources/OrganizationMembership.ts index 7cad6a72b5..fe3092cc4f 100644 --- a/packages/clerk-js/src/core/resources/OrganizationMembership.ts +++ b/packages/clerk-js/src/core/resources/OrganizationMembership.ts @@ -68,6 +68,7 @@ export class OrganizationMembership extends BaseResource implements Organization lastName: data.public_user_data.last_name, profileImageUrl: data.public_user_data.profile_image_url, imageUrl: data.public_user_data.image_url, + hasImage: data.public_user_data.has_image, identifier: data.public_user_data.identifier, userId: data.public_user_data.user_id, }; diff --git a/packages/clerk-js/src/core/resources/User.ts b/packages/clerk-js/src/core/resources/User.ts index 9371976c05..d825d35e17 100644 --- a/packages/clerk-js/src/core/resources/User.ts +++ b/packages/clerk-js/src/core/resources/User.ts @@ -79,6 +79,7 @@ export class User extends BaseResource implements UserResource { */ profileImageUrl = ''; imageUrl = ''; + hasImage = false; twoFactorEnabled = false; totpEnabled = false; backupCodeEnabled = false; @@ -296,6 +297,7 @@ export class User extends BaseResource implements UserResource { this.profileImageUrl = data.profile_image_url; this.imageUrl = data.image_url; + this.hasImage = data.has_image; this.username = data.username; this.passwordEnabled = data.password_enabled; this.emailAddresses = (data.email_addresses || []).map( diff --git a/packages/clerk-js/src/core/resources/__snapshots__/Organization.test.ts.snap b/packages/clerk-js/src/core/resources/__snapshots__/Organization.test.ts.snap index 797db11537..1c50c75187 100644 --- a/packages/clerk-js/src/core/resources/__snapshots__/Organization.test.ts.snap +++ b/packages/clerk-js/src/core/resources/__snapshots__/Organization.test.ts.snap @@ -8,6 +8,7 @@ Organization { "destroy": [Function], "getMemberships": [Function], "getPendingInvitations": [Function], + "hasImage": true, "id": "test_id", "imageUrl": "https://clerk.com", "inviteMember": [Function], diff --git a/packages/clerk-js/src/core/resources/__snapshots__/OrganizationMembership.test.ts.snap b/packages/clerk-js/src/core/resources/__snapshots__/OrganizationMembership.test.ts.snap index d94f244d67..fabc1c46c0 100644 --- a/packages/clerk-js/src/core/resources/__snapshots__/OrganizationMembership.test.ts.snap +++ b/packages/clerk-js/src/core/resources/__snapshots__/OrganizationMembership.test.ts.snap @@ -12,6 +12,7 @@ OrganizationMembership { "destroy": [Function], "getMemberships": [Function], "getPendingInvitations": [Function], + "hasImage": true, "id": "test_org_id", "imageUrl": "https://clerk.com", "inviteMember": [Function], @@ -38,6 +39,7 @@ OrganizationMembership { }, "publicUserData": { "firstName": "test_first_name", + "hasImage": true, "identifier": "test@identifier.gr", "imageUrl": "https://clerk.com", "lastName": "test_last_name", From 33c53be3267e7ed855d18eeda7e4911b5829196a Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Tue, 1 Aug 2023 20:34:39 +0300 Subject: [PATCH 3/4] feat(types): Add has_image field in user / organization / session --- packages/types/src/json.ts | 4 ++++ packages/types/src/organization.ts | 1 + packages/types/src/session.ts | 1 + packages/types/src/user.ts | 1 + 4 files changed, 7 insertions(+) diff --git a/packages/types/src/json.ts b/packages/types/src/json.ts index e7e73da829..5719e51101 100644 --- a/packages/types/src/json.ts +++ b/packages/types/src/json.ts @@ -188,6 +188,7 @@ export interface UserJSON extends ClerkResourceJSON { */ profile_image_url: string; image_url: string; + has_image: boolean; username: string; email_addresses: EmailAddressJSON[]; phone_numbers: PhoneNumberJSON[]; @@ -228,6 +229,7 @@ export interface PublicUserDataJSON extends ClerkResourceJSON { */ profile_image_url: string; image_url: string; + has_image: boolean; identifier: string; user_id?: string; } @@ -306,6 +308,7 @@ export interface OrganizationJSON extends ClerkResourceJSON { */ logo_url: string; image_url: string; + has_image: boolean; name: string; slug: string; public_metadata: OrganizationPublicMetadata; @@ -360,6 +363,7 @@ export interface UserDataJSON { */ profile_image_url?: string; image_url: string; + has_image: boolean; } export interface TOTPJSON extends ClerkResourceJSON { diff --git a/packages/types/src/organization.ts b/packages/types/src/organization.ts index 2ee32d9e4c..ba26334836 100644 --- a/packages/types/src/organization.ts +++ b/packages/types/src/organization.ts @@ -32,6 +32,7 @@ export interface OrganizationResource extends ClerkResource { */ logoUrl: string | null; imageUrl: string; + hasImage: boolean; membersCount: number; pendingInvitationsCount: number; publicMetadata: OrganizationPublicMetadata; diff --git a/packages/types/src/session.ts b/packages/types/src/session.ts index f14e0193f1..416acb2ed5 100644 --- a/packages/types/src/session.ts +++ b/packages/types/src/session.ts @@ -61,6 +61,7 @@ export interface PublicUserData { */ profileImageUrl: string; imageUrl: string; + hasImage: boolean; identifier: string; userId?: string; } diff --git a/packages/types/src/user.ts b/packages/types/src/user.ts index b4fc7e3838..242531a77c 100644 --- a/packages/types/src/user.ts +++ b/packages/types/src/user.ts @@ -64,6 +64,7 @@ export interface UserResource extends ClerkResource { */ profileImageUrl: string; imageUrl: string; + hasImage: boolean; emailAddresses: EmailAddressResource[]; phoneNumbers: PhoneNumberResource[]; web3Wallets: Web3WalletResource[]; From 3cd4147918baea70e3dfdd0e524e0c24ca7985b0 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Tue, 1 Aug 2023 20:51:56 +0300 Subject: [PATCH 4/4] chore(repo): Add changeset for hasImage property --- .changeset/quiet-shirts-notice.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/quiet-shirts-notice.md diff --git a/.changeset/quiet-shirts-notice.md b/.changeset/quiet-shirts-notice.md new file mode 100644 index 0000000000..ff2848ea67 --- /dev/null +++ b/.changeset/quiet-shirts-notice.md @@ -0,0 +1,7 @@ +--- +'@clerk/clerk-js': minor +'@clerk/backend': minor +'@clerk/types': minor +--- + +Introduce `hasImage` in User / Organization / Session resources