Skip to content

Commit

Permalink
Add tasks on Session resource
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraBeatris committed Feb 14, 2025
1 parent 8daa94a commit 465496a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
4 changes: 4 additions & 0 deletions packages/clerk-js/src/core/resources/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
SessionJSONSnapshot,
SessionResource,
SessionStatus,
SessionTasks,
SessionVerificationJSON,
SessionVerificationResource,
SessionVerifyAttemptFirstFactorParams,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ export * from './customMenuItems';
export * from './samlConnection';
export * from './waitlist';
export * from './snapshots';
export * from './tasks';
25 changes: 2 additions & 23 deletions packages/types/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand 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;
Expand Down
3 changes: 3 additions & 0 deletions packages/types/src/tasks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface SessionTasks {
orgs: Record<string, unknown>;
}

0 comments on commit 465496a

Please sign in to comment.