Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the resources / types to include has_Image #1544

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/quiet-shirts-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/clerk-js': minor
'@clerk/backend': minor
'@clerk/types': minor
---

Introduce `hasImage` in User / Organization / Session resources
3 changes: 3 additions & 0 deletions packages/backend/src/api/resources/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -178,6 +179,7 @@ export interface OrganizationMembershipPublicUserDataJSON {
*/
profile_image_url: string;
image_url: string;
has_image: boolean;
user_id: string;
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/api/resources/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/api/resources/OrganizationMembership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class OrganizationMembershipPublicUserData {
*/
readonly profileImageUrl: string,
readonly imageUrl: string,
readonly hasImage: boolean,
readonly userId: string,
) {}

Expand All @@ -48,6 +49,7 @@ export class OrganizationMembershipPublicUserData {
data.last_name,
data.profile_image_url,
data.image_url,
data.has_image,
data.user_id,
);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/api/resources/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/clerk-js/src/core/resources/Organization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Organization', () => {
pending_invitations_count: 10,
admin_delete_enabled: true,
max_allowed_memberships: 3,
has_image: true,
});

expect(organization).toMatchSnapshot();
Expand Down
2 changes: 2 additions & 0 deletions packages/clerk-js/src/core/resources/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class Organization extends BaseResource implements OrganizationResource {
*/
logoUrl!: string;
imageUrl!: string;
hasImage!: boolean;
publicMetadata: OrganizationPublicMetadata = {};
adminDeleteEnabled!: boolean;
createdAt!: Date;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -34,6 +35,7 @@ describe('OrganizationMembership', () => {
image_url: 'https://clerk.com',
identifier: 'test@identifier.gr',
id: 'test_user_id',
has_image: true,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 2 additions & 0 deletions packages/clerk-js/src/core/resources/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class User extends BaseResource implements UserResource {
*/
profileImageUrl = '';
imageUrl = '';
hasImage = false;
twoFactorEnabled = false;
totpEnabled = false;
backupCodeEnabled = false;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Organization {
"destroy": [Function],
"getMemberships": [Function],
"getPendingInvitations": [Function],
"hasImage": true,
"id": "test_id",
"imageUrl": "https://clerk.com",
"inviteMember": [Function],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ OrganizationMembership {
"destroy": [Function],
"getMemberships": [Function],
"getPendingInvitations": [Function],
"hasImage": true,
"id": "test_org_id",
"imageUrl": "https://clerk.com",
"inviteMember": [Function],
Expand All @@ -38,6 +39,7 @@ OrganizationMembership {
},
"publicUserData": {
"firstName": "test_first_name",
"hasImage": true,
"identifier": "test@identifier.gr",
"imageUrl": "https://clerk.com",
"lastName": "test_last_name",
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -228,6 +229,7 @@ export interface PublicUserDataJSON extends ClerkResourceJSON {
*/
profile_image_url: string;
image_url: string;
has_image: boolean;
identifier: string;
user_id?: string;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -360,6 +363,7 @@ export interface UserDataJSON {
*/
profile_image_url?: string;
image_url: string;
has_image: boolean;
}

export interface TOTPJSON extends ClerkResourceJSON {
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface OrganizationResource extends ClerkResource {
*/
logoUrl: string | null;
imageUrl: string;
hasImage: boolean;
membersCount: number;
pendingInvitationsCount: number;
publicMetadata: OrganizationPublicMetadata;
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface PublicUserData {
*/
profileImageUrl: string;
imageUrl: string;
hasImage: boolean;
identifier: string;
userId?: string;
}
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface UserResource extends ClerkResource {
*/
profileImageUrl: string;
imageUrl: string;
hasImage: boolean;
emailAddresses: EmailAddressResource[];
phoneNumbers: PhoneNumberResource[];
web3Wallets: Web3WalletResource[];
Expand Down