mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-20 09:14:22 +01:00
add api to get session
This commit is contained in:
@@ -219,6 +219,34 @@ export namespace Server {
|
|||||||
return c.json(sessions)
|
return c.json(sessions)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.get(
|
||||||
|
"/session/:sessionID",
|
||||||
|
describeRoute({
|
||||||
|
description: "Get session",
|
||||||
|
operationId: "session.get",
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "Get session",
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: resolver(Session.Info),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
zValidator(
|
||||||
|
"param",
|
||||||
|
z.object({
|
||||||
|
id: z.string(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
async (c) => {
|
||||||
|
const sessionID = c.req.valid("param").id
|
||||||
|
const session = await Session.get(sessionID)
|
||||||
|
return c.json(session)
|
||||||
|
},
|
||||||
|
)
|
||||||
.post(
|
.post(
|
||||||
"/session",
|
"/session",
|
||||||
describeRoute({
|
describeRoute({
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import type {
|
|||||||
SessionCreateData,
|
SessionCreateData,
|
||||||
SessionCreateResponses,
|
SessionCreateResponses,
|
||||||
SessionCreateErrors,
|
SessionCreateErrors,
|
||||||
|
SessionGetData,
|
||||||
|
SessionGetResponses,
|
||||||
SessionDeleteData,
|
SessionDeleteData,
|
||||||
SessionDeleteResponses,
|
SessionDeleteResponses,
|
||||||
SessionInitData,
|
SessionInitData,
|
||||||
@@ -202,6 +204,16 @@ class Session extends _HeyApiClient {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get session
|
||||||
|
*/
|
||||||
|
public get<ThrowOnError extends boolean = false>(options: Options<SessionGetData, ThrowOnError>) {
|
||||||
|
return (options.client ?? this._client).get<SessionGetResponses, unknown, ThrowOnError>({
|
||||||
|
url: "/session/{sessionID}",
|
||||||
|
...options,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a session and all its data
|
* Delete a session and all its data
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -537,6 +537,7 @@ export type Config = {
|
|||||||
theme?: string
|
theme?: string
|
||||||
keybinds?: KeybindsConfig
|
keybinds?: KeybindsConfig
|
||||||
plugin?: Array<string>
|
plugin?: Array<string>
|
||||||
|
snapshot?: boolean
|
||||||
/**
|
/**
|
||||||
* Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing
|
* Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing
|
||||||
*/
|
*/
|
||||||
@@ -1102,6 +1103,24 @@ export type SessionCreateResponses = {
|
|||||||
|
|
||||||
export type SessionCreateResponse = SessionCreateResponses[keyof SessionCreateResponses]
|
export type SessionCreateResponse = SessionCreateResponses[keyof SessionCreateResponses]
|
||||||
|
|
||||||
|
export type SessionGetData = {
|
||||||
|
body?: never
|
||||||
|
path: {
|
||||||
|
sessionID: string
|
||||||
|
}
|
||||||
|
query?: never
|
||||||
|
url: "/session/{sessionID}"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SessionGetResponses = {
|
||||||
|
/**
|
||||||
|
* Get session
|
||||||
|
*/
|
||||||
|
200: Session
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SessionGetResponse = SessionGetResponses[keyof SessionGetResponses]
|
||||||
|
|
||||||
export type SessionDeleteData = {
|
export type SessionDeleteData = {
|
||||||
body?: never
|
body?: never
|
||||||
path: {
|
path: {
|
||||||
|
|||||||
Reference in New Issue
Block a user