From 03ec223b61feca9b7acb6f48c3fcfaf3155b3de4 Mon Sep 17 00:00:00 2001 From: Sokratis Vidros Date: Tue, 12 Apr 2022 01:05:51 +0300 Subject: [PATCH 1/2] fix(clerk-js): Expose user.externalId field ExternalId is used during imports. An example usage is if they had an auth0_id, and need to use that to reference the user, instead of the clerk_id, then they put it there. --- packages/clerk-js/src/core/resources/User.ts | 2 ++ packages/types/src/json.ts | 1 + packages/types/src/user.ts | 1 + 3 files changed, 4 insertions(+) diff --git a/packages/clerk-js/src/core/resources/User.ts b/packages/clerk-js/src/core/resources/User.ts index 9cc9f9e78ef..139bf8c66a3 100644 --- a/packages/clerk-js/src/core/resources/User.ts +++ b/packages/clerk-js/src/core/resources/User.ts @@ -32,6 +32,7 @@ export class User extends BaseResource implements UserResource { pathRoot = '/me'; id = ''; + externalId: string | null = null; username: string | null = null; emailAddresses: EmailAddressResource[] = []; phoneNumbers: PhoneNumberResource[] = []; @@ -170,6 +171,7 @@ export class User extends BaseResource implements UserResource { protected fromJSON(data: UserJSON): this { this.id = data.id; + this.externalId = data.external_id; this.firstName = data.first_name; this.lastName = data.last_name; if (this.firstName && this.lastName) { diff --git a/packages/types/src/json.ts b/packages/types/src/json.ts index 3d6ec7a30f5..8982529f2ce 100644 --- a/packages/types/src/json.ts +++ b/packages/types/src/json.ts @@ -153,6 +153,7 @@ export interface ExternalAccountJSON extends ClerkResourceJSON { export interface UserJSON extends ClerkResourceJSON { object: 'user'; id: string; + external_id: string; primary_email_address_id: string; primary_phone_number_id: string; primary_web3_wallet_id: string; diff --git a/packages/types/src/user.ts b/packages/types/src/user.ts index 6fc00bdde60..a933eddc3d2 100644 --- a/packages/types/src/user.ts +++ b/packages/types/src/user.ts @@ -31,6 +31,7 @@ declare global { export interface UserResource extends ClerkResource { id: string; + externalId: string | null; primaryEmailAddressId: string | null; primaryEmailAddress: EmailAddressResource | null; primaryPhoneNumberId: string | null; From a37e06b22e42242945f49c73049610629706d3d5 Mon Sep 17 00:00:00 2001 From: Sokratis Vidros Date: Tue, 12 Apr 2022 01:06:41 +0300 Subject: [PATCH 2/2] fix(backend-core): Expose user.externalId field ExternalId is used during imports. An example usage is if they had an auth0_id, and need to use that to reference the user, instead of the clerk_id, then they put it there. --- packages/backend-core/src/api/resources/Props.ts | 4 +--- packages/backend-core/src/api/resources/User.ts | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/backend-core/src/api/resources/Props.ts b/packages/backend-core/src/api/resources/Props.ts index 082cc1580ac..a8e26932a5a 100644 --- a/packages/backend-core/src/api/resources/Props.ts +++ b/packages/backend-core/src/api/resources/Props.ts @@ -134,6 +134,7 @@ export interface SMSMessageProps extends ClerkProps { } export interface UserProps extends ClerkProps { + externalId: Nullable; username: Nullable; firstName: Nullable; lastName: Nullable; @@ -144,9 +145,6 @@ export interface UserProps extends ClerkProps { primaryPhoneNumberId: Nullable; passwordEnabled: boolean; twoFactorEnabled: boolean; - // emailAddresses: EmailAddressProps[]; - // phoneNumbers: PhoneNumberProps[]; - // externalAccounts: GoogleAccountProps[]; publicMetadata: Record; privateMetadata: Record; unsafeMetadata: Record; diff --git a/packages/backend-core/src/api/resources/User.ts b/packages/backend-core/src/api/resources/User.ts index c9bfaf3a834..c92951d93ad 100644 --- a/packages/backend-core/src/api/resources/User.ts +++ b/packages/backend-core/src/api/resources/User.ts @@ -24,6 +24,7 @@ export interface User extends UserPayload {} export class User { static attributes = [ 'id', + 'externalId', 'username', 'firstName', 'lastName',