MessageSessionStoreShape
Defined in: packages/core/src/session/schema.ts:220
The service shape of a message session store.
Properties
Section titled “Properties”consistency
Section titled “consistency”
readonlyconsistency:Consistency
Defined in: packages/core/src/session/schema.ts:225
strong stores provide compare-and-set; eventual stores (KV) do not and
must not be used for concurrent writers.
Methods
Section titled “Methods”acquire()
Section titled “acquire()”acquire(
id,owner,ttlMs):Effect<boolean,SessionStoreError|SessionNotFound|SessionClosed|SessionExpired>
Defined in: packages/core/src/session/schema.ts:274
Acquires a short lease for one writer. Returns false when another owner
holds an unexpired lease. Expired leases are taken over.
Parameters
Section titled “Parameters”string
string
number
Returns
Section titled “Returns”Effect<boolean, SessionStoreError | SessionNotFound | SessionClosed | SessionExpired>
attachMessage()
Section titled “attachMessage()”attachMessage(
id,message):Effect<{build:string;component:string;createdAt:number;ephemeral:boolean;expiresAt?:number;id:string;lastInteractionId?:string;message?: {channelId?:string;guildId?:string;id:string; };props:unknown;state?: {[key:string]:unknown; };status:"closed"|"pending"|"active";updatedAt:number;version:number; },MutationError>
Defined in: packages/core/src/session/schema.ts:249
Attaches the platform message without changing the interaction version.
Parameters
Section titled “Parameters”string
message
Section titled “message”channelId?
Section titled “channelId?”string = ...
guildId?
Section titled “guildId?”string = ...
string = Schema.String
Returns
Section titled “Returns”Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>
close()
Section titled “close()”close(
id):Effect<void,SessionStoreError|SessionNotFound>
Defined in: packages/core/src/session/schema.ts:256
Marks a session closed. Closing a closed session is a no-op.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Effect<void, SessionStoreError | SessionNotFound>
create()
Section titled “create()”create(
session):Effect<void,SessionStoreError|SessionAlreadyExists>
Defined in: packages/core/src/session/schema.ts:226
Parameters
Section titled “Parameters”session
Section titled “session”string = Schema.String
Application build fingerprint. Empty means “do not check”.
component
Section titled “component”string = Schema.String
Registered component key, resolved by the platform integration.
createdAt
Section titled “createdAt”number = Schema.Finite
ephemeral
Section titled “ephemeral”boolean = Schema.Boolean
expiresAt?
Section titled “expiresAt?”number = ...
string = Schema.String
lastInteractionId?
Section titled “lastInteractionId?”string = ...
message?
Section titled “message?”{ channelId?: string; guildId?: string; id: string; } = ...
message.channelId?
Section titled “message.channelId?”string = ...
message.guildId?
Section titled “message.guildId?”string = ...
message.id
Section titled “message.id”string = Schema.String
unknown = Schema.Unknown
state?
Section titled “state?”{[key: string]: unknown; } = ...
status
Section titled “status”"closed" | "pending" | "active" = ...
updatedAt
Section titled “updatedAt”number = Schema.Finite
version
Section titled “version”number = Schema.Int
The state version the message on the platform shows. Bumped per interaction.
Returns
Section titled “Returns”Effect<void, SessionStoreError | SessionAlreadyExists>
findByMessage()
Section titled “findByMessage()”findByMessage(
messageId):Effect<Option<string>,SessionStoreError>
Defined in: packages/core/src/session/schema.ts:254
The session that owns a platform message, if one is known.
Parameters
Section titled “Parameters”messageId
Section titled “messageId”string
Returns
Section titled “Returns”Effect<Option<string>, SessionStoreError>
get(
id):Effect<Option<{build:string;component:string;createdAt:number;ephemeral:boolean;expiresAt?:number;id:string;lastInteractionId?:string;message?: {channelId?:string;guildId?:string;id:string; };props:unknown;state?: {[key:string]:unknown; };status:"closed"|"pending"|"active";updatedAt:number;version:number; }>,SessionStoreError>
Defined in: packages/core/src/session/schema.ts:227
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Effect<Option<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }>, SessionStoreError>
listActive()
Section titled “listActive()”listActive(
options?):Effect<SessionPage,SessionStoreError>
Defined in: packages/core/src/session/schema.ts:269
One bounded page of sessions a restart could resume eagerly, ordered by id. Pass the returned cursor back until it is absent.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Effect<SessionPage, SessionStoreError>
release()
Section titled “release()”release(
id,owner):Effect<void,SessionStoreError>
Defined in: packages/core/src/session/schema.ts:286
Releases a lease only if owner still holds it.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Effect<void, SessionStoreError>
renew()
Section titled “renew()”renew(
id,owner,ttlMs):Effect<boolean,SessionStoreError|SessionNotFound|SessionClosed|SessionExpired>
Defined in: packages/core/src/session/schema.ts:280
Extends an unexpired lease held by owner; false means it was lost.
Parameters
Section titled “Parameters”string
string
number
Returns
Section titled “Returns”Effect<boolean, SessionStoreError | SessionNotFound | SessionClosed | SessionExpired>
setState()
Section titled “setState()”setState(
id,expectedVersion,state):Effect<{build:string;component:string;createdAt:number;ephemeral:boolean;expiresAt?:number;id:string;lastInteractionId?:string;message?: {channelId?:string;guildId?:string;id:string; };props:unknown;state?: {[key:string]:unknown; };status:"closed"|"pending"|"active";updatedAt:number;version:number; },MutationError>
Defined in: packages/core/src/session/schema.ts:243
Stores the first state and marks the session active without bumping the version.
Parameters
Section titled “Parameters”string
expectedVersion
Section titled “expectedVersion”number
State
Returns
Section titled “Returns”Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>
sweep()
Section titled “sweep()”sweep(
now,options?):Effect<SessionSweepPage,SessionStoreError>
Defined in: packages/core/src/session/schema.ts:261
Removes one bounded page of closed and expired sessions, ordered by id. Pass the returned cursor back until it is absent.
Parameters
Section titled “Parameters”number
options?
Section titled “options?”Returns
Section titled “Returns”Effect<SessionSweepPage, SessionStoreError>
update()
Section titled “update()”update(
id,expectedVersion,update,leaseOwner?):Effect<{build:string;component:string;createdAt:number;ephemeral:boolean;expiresAt?:number;id:string;lastInteractionId?:string;message?: {channelId?:string;guildId?:string;id:string; };props:unknown;state?: {[key:string]:unknown; };status:"closed"|"pending"|"active";updatedAt:number;version:number; },MutationError>
Defined in: packages/core/src/session/schema.ts:232
Compares expectedVersion, applies update, bumps the version and
returns the stored record. The callback must not mutate the record.
Parameters
Section titled “Parameters”string
expectedVersion
Section titled “expectedVersion”number
update
Section titled “update”(session) => object
leaseOwner?
Section titled “leaseOwner?”string
When set, the version check and the lease check commit together.
A missing or foreign lease fails with SessionLeaseLost and does not write.
Returns
Section titled “Returns”Effect<{ build: string; component: string; createdAt: number; ephemeral: boolean; expiresAt?: number; id: string; lastInteractionId?: string; message?: { channelId?: string; guildId?: string; id: string; }; props: unknown; state?: {[key: string]: unknown; }; status: "closed" | "pending" | "active"; updatedAt: number; version: number; }, MutationError>