From 613811f5ce5d20631476d351e276cb09f1d2d4a8 Mon Sep 17 00:00:00 2001 From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:40:52 -0300 Subject: [PATCH] Add `tasks` on `Session` resource --- .../clerk-js/src/core/resources/Session.ts | 4 +++ packages/types/src/index.ts | 1 + packages/types/src/json.ts | 25 ++----------------- packages/types/src/tasks.ts | 4 +++ 4 files changed, 11 insertions(+), 23 deletions(-) create mode 100644 packages/types/src/tasks.ts diff --git a/packages/clerk-js/src/core/resources/Session.ts b/packages/clerk-js/src/core/resources/Session.ts index 2a6c1b6e3aa..b28a899db4e 100644 --- a/packages/clerk-js/src/core/resources/Session.ts +++ b/packages/clerk-js/src/core/resources/Session.ts @@ -12,6 +12,7 @@ import type { SessionJSONSnapshot, SessionResource, SessionStatus, + SessionTasks, SessionVerificationJSON, SessionVerificationResource, SessionVerifyAttemptFirstFactorParams, @@ -42,6 +43,7 @@ export class Session extends BaseResource implements SessionResource { user!: UserResource | null; publicUserData!: PublicUserData; factorVerificationAge: [number, number] | null = null; + tasks!: SessionTasks | null; expireAt!: Date; abandonAt!: Date; createdAt!: Date; @@ -224,6 +226,7 @@ export class Session extends BaseResource implements SessionResource { this.createdAt = unixEpochToDate(data.created_at); this.updatedAt = unixEpochToDate(data.updated_at); this.user = new User(data.user); + this.tasks = data.tasks; if (data.public_user_data) { this.publicUserData = new PublicUserData(data.public_user_data); @@ -245,6 +248,7 @@ export class Session extends BaseResource implements SessionResource { last_active_at: this.lastActiveAt.getTime(), last_active_organization_id: this.lastActiveOrganizationId, actor: this.actor, + tasks: this.tasks, user: this.user?.__internal_toSnapshot() || null, public_user_data: this.publicUserData.__internal_toSnapshot(), last_active_token: this.lastActiveToken?.__internal_toSnapshot() || null, diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index ea41eaa12aa..b122e4cce9d 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -65,3 +65,4 @@ export * from './customMenuItems'; export * from './samlConnection'; export * from './waitlist'; export * from './snapshots'; +export * from './tasks'; diff --git a/packages/types/src/json.ts b/packages/types/src/json.ts index 663a4303d0e..a7acb98ad5c 100644 --- a/packages/types/src/json.ts +++ b/packages/types/src/json.ts @@ -16,6 +16,7 @@ import type { SessionStatus } from './session'; import type { SessionVerificationLevel, SessionVerificationStatus } from './sessionVerification'; import type { SignInFirstFactor, SignInJSON, SignInSecondFactor } from './signIn'; import type { SignUpField, SignUpIdentificationField, SignUpStatus } from './signUp'; +import type { SessionTasks } from './tasks'; import type { BoxShadow, Color, EmUnit, FontWeight, HexColor } from './theme'; import type { UserSettingsJSON } from './userSettings'; import type { CamelToSnake } from './utils'; @@ -76,29 +77,6 @@ export interface ClientJSON extends ClerkResourceJSON { created_at: number; updated_at: number; } -// export type ClientJSON = ClerkResourceJSON & { -// object: 'client'; -// id: string; -// status: any; -// sessions: SessionJSON[]; -// sign_up: SignUpJSON | null; -// sign_in: SignInJSON | null; -// last_active_session_id: string | null; -// cookie_expires_at: number | null; -// created_at: number; -// updated_at: number; -// } | { -// object: 'client'; -// id: null; -// status: null; -// sessions: null -// sign_up: null -// sign_in: null -// last_active_session_id: null -// cookie_expires_at: null -// created_at: null; -// updated_at: null; -// } export interface SignUpJSON extends ClerkResourceJSON { object: 'sign_up'; @@ -140,6 +118,7 @@ export interface SessionJSON extends ClerkResourceJSON { last_active_token: TokenJSON; last_active_organization_id: string | null; actor: ActJWTClaim | null; + tasks: SessionTasks | null; user: UserJSON; public_user_data: PublicUserDataJSON; created_at: number; diff --git a/packages/types/src/tasks.ts b/packages/types/src/tasks.ts new file mode 100644 index 00000000000..105e724b239 --- /dev/null +++ b/packages/types/src/tasks.ts @@ -0,0 +1,4 @@ +export interface SessionTasks { + // todo(laura): Are we going to return something within + orgs: Record; +}