Skip to content

Commit 495af31

Browse files
authored
Add externalId support to user (#1228)
Allows adding one during create and update and includes the externalId in the user object. ## Description ## Documentation Does this require changes to the WorkOS Docs? E.g. the [API Reference](https://workos.com/docs/reference) or code snippets need updates. ``` [x] Yes ``` If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required. ^ docs are coming but looking to get this out in a preview release ahead of time.
1 parent a917507 commit 495af31

File tree

7 files changed

+10
-0
lines changed

7 files changed

+10
-0
lines changed

src/actions/actions.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ describe('Actions', () => {
126126
profilePictureUrl: 'https://example.com/jane.jpg',
127127
createdAt: '2024-10-22T17:12:50.746Z',
128128
updatedAt: '2024-10-22T17:12:50.746Z',
129+
externalId: null,
129130
},
130131
ipAddress: '50.141.123.10',
131132
userAgent: 'Mozilla/5.0',

src/user-management/interfaces/create-user-options.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface CreateUserOptions {
88
firstName?: string;
99
lastName?: string;
1010
emailVerified?: boolean;
11+
externalId?: string;
1112
}
1213

1314
export interface SerializedCreateUserOptions {
@@ -18,4 +19,5 @@ export interface SerializedCreateUserOptions {
1819
first_name?: string;
1920
last_name?: string;
2021
email_verified?: boolean;
22+
external_id?: string;
2123
}

src/user-management/interfaces/update-user-options.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface UpdateUserOptions {
88
password?: string;
99
passwordHash?: string;
1010
passwordHashType?: PasswordHashType;
11+
externalId?: string;
1112
}
1213

1314
export interface SerializedUpdateUserOptions {
@@ -17,4 +18,5 @@ export interface SerializedUpdateUserOptions {
1718
password?: string;
1819
password_hash?: string;
1920
password_hash_type?: PasswordHashType;
21+
external_id?: string;
2022
}

src/user-management/interfaces/user.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface User {
99
lastSignInAt: string | null;
1010
createdAt: string;
1111
updatedAt: string;
12+
externalId: string | null;
1213
}
1314

1415
export interface UserResponse {
@@ -22,4 +23,5 @@ export interface UserResponse {
2223
last_sign_in_at: string | null;
2324
created_at: string;
2425
updated_at: string;
26+
external_id?: string;
2527
}

src/user-management/serializers/create-user-options.serializer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export const serializeCreateUserOptions = (
1010
first_name: options.firstName,
1111
last_name: options.lastName,
1212
email_verified: options.emailVerified,
13+
external_id: options.externalId,
1314
});

src/user-management/serializers/update-user-options.serializer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export const serializeUpdateUserOptions = (
99
password: options.password,
1010
password_hash: options.passwordHash,
1111
password_hash_type: options.passwordHashType,
12+
external_id: options.externalId,
1213
});

src/user-management/serializers/user.serializer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export const deserializeUser = (user: UserResponse): User => ({
1111
lastSignInAt: user.last_sign_in_at,
1212
createdAt: user.created_at,
1313
updatedAt: user.updated_at,
14+
externalId: user.external_id ?? null,
1415
});

0 commit comments

Comments
 (0)