@arizeai/phoenix-client
Version:
A client for the Phoenix API
60 lines • 2.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteSession = deleteSession;
const client_1 = require("../client");
const serverRequirements_1 = require("../constants/serverRequirements");
const serverVersionUtils_1 = require("../utils/serverVersionUtils");
/**
* Delete a single session by ID.
*
* This will permanently remove the session and all associated traces, spans,
* and annotations via cascade delete.
*
* @experimental this function is experimental and may change in the future
*
* @param params - The parameters to delete a session
* @returns Promise that resolves when the session is successfully deleted
* @throws Error if the session is not found or deletion fails
*
* @requires Phoenix server >= 13.13.0
*
* @example
* ```ts
* // Delete by user-provided session ID
* await deleteSession({
* client,
* sessionId: "my-session-id"
* });
*
* // Delete by Phoenix Global ID
* await deleteSession({
* client,
* sessionId: "UHJvamVjdFNlc3Npb246MTIz"
* });
* ```
*/
async function deleteSession({ client: _client, sessionId, }) {
const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)();
await (0, serverVersionUtils_1.ensureServerCapability)({ client, requirement: serverRequirements_1.DELETE_SESSION });
const { error } = await client.DELETE("/v1/sessions/{session_identifier}", {
params: {
path: {
session_identifier: sessionId,
},
},
});
if (error) {
const isNotFound = typeof error === "object" &&
error !== null &&
"status" in error &&
error.status === 404;
if (isNotFound) {
throw new Error(`Session not found: ${sessionId}`);
}
const errorMessage = typeof error === "object" && error !== null
? JSON.stringify(error, null, 2)
: String(error);
throw new Error(`Failed to delete session: ${errorMessage}`);
}
}
//# sourceMappingURL=deleteSession.js.map