import { z } from 'zod/v4';
import { CoderCreateWorkspaceRequestSchema, CoderUpdateWorkspaceRequestSchema, CoderWorkspaceDependencyValidationResponseSchema, CoderWorkspaceDetailSchema, CoderWorkspaceListResponseSchema, } from "./types.js";
const WorkspaceGetResponseSchema = z
    .object({
    workspace: CoderWorkspaceDetailSchema.describe('Workspace payload returned by coder hub'),
})
    .passthrough()
    .describe('Wrapped workspace response from coder hub');
const WorkspaceCreateResponseSchema = z
    .object({
    workspace: CoderWorkspaceDetailSchema.describe('Created workspace payload returned by coder hub'),
})
    .passthrough()
    .describe('Wrapped workspace create response from coder hub');
const WorkspaceUpdateResponseSchema = z
    .object({
    workspace: CoderWorkspaceDetailSchema.describe('Updated workspace payload returned by coder hub'),
})
    .passthrough()
    .describe('Wrapped workspace update response from coder hub');
const WorkspaceSnapshotRefreshResponseSchema = z
    .object({
    workspace: CoderWorkspaceDetailSchema.describe('Workspace payload returned after refreshing its snapshot'),
})
    .passthrough()
    .describe('Wrapped workspace snapshot refresh response from coder hub');
const WorkspaceDependencyValidationWrappedResponseSchema = z
    .object({
    success: z.boolean().describe('Validation request success indicator'),
    data: CoderWorkspaceDependencyValidationResponseSchema.describe('Dependency validation result'),
})
    .passthrough()
    .describe('Wrapped workspace dependency validation response from coder hub');
const OkResponseSchema = z
    .object({
    ok: z.boolean().describe('Operation success indicator'),
})
    .passthrough()
    .describe('Generic ok response from coder hub');
export async function coderListWorkspaces(client) {
    return client.get('/hub/workspaces', CoderWorkspaceListResponseSchema);
}
export async function coderGetWorkspace(client, params) {
    const path = `/hub/workspaces/${encodeURIComponent(params.workspaceId)}`;
    const resp = await client.get(path, WorkspaceGetResponseSchema);
    return resp.workspace;
}
export async function coderCreateWorkspace(client, params) {
    const resp = await client.post('/hub/workspaces', params.body, WorkspaceCreateResponseSchema, CoderCreateWorkspaceRequestSchema);
    return resp.workspace;
}
export async function coderUpdateWorkspace(client, params) {
    const path = `/hub/workspaces/${encodeURIComponent(params.workspaceId)}`;
    const resp = await client.patch(path, params.body, WorkspaceUpdateResponseSchema, CoderUpdateWorkspaceRequestSchema);
    return resp.workspace;
}
export async function coderRefreshWorkspaceSnapshot(client, params) {
    const path = `/hub/workspaces/${encodeURIComponent(params.workspaceId)}/snapshot/refresh`;
    const resp = await client.post(path, undefined, WorkspaceSnapshotRefreshResponseSchema);
    return resp.workspace;
}
export async function coderValidateWorkspaceDependencies(client, params) {
    const resp = await client.post('/hub/workspaces/dependencies/validate', { dependencies: params.dependencies }, WorkspaceDependencyValidationWrappedResponseSchema);
    return resp.data;
}
export async function coderDeleteWorkspace(client, params) {
    const path = `/hub/workspaces/${encodeURIComponent(params.workspaceId)}`;
    await client.delete(path, OkResponseSchema);
}
//# sourceMappingURL=workspaces.js.map