-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathdelete_post.ts
More file actions
76 lines (70 loc) · 1.76 KB
/
Copy pathdelete_post.ts
File metadata and controls
76 lines (70 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import {
BUFFER_API_URL,
type BufferDeletePostParams,
type BufferDeletePostResponse,
bufferHeaders,
parseBufferGraphQLResponse,
} from '@/tools/buffer/types'
import type { ToolConfig } from '@/tools/types'
const DELETE_POST_MUTATION = `
mutation DeletePost($input: DeletePostInput!) {
deletePost(input: $input) {
__typename
... on DeletePostSuccess {
id
}
... on VoidMutationError {
message
}
}
}
`
export const bufferDeletePostTool: ToolConfig<BufferDeletePostParams, BufferDeletePostResponse> = {
id: 'buffer_delete_post',
name: 'Buffer Delete Post',
description: 'Delete a Buffer post by ID',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Buffer API key',
},
postId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'ID of the post to delete',
},
},
request: {
url: BUFFER_API_URL,
method: 'POST',
headers: (params) => bufferHeaders(params.apiKey),
body: (params) => ({
query: DELETE_POST_MUTATION,
variables: {
input: { id: params.postId },
},
}),
},
transformResponse: async (response: Response) => {
const data = await parseBufferGraphQLResponse(response)
const result = data.deletePost
if (result?.__typename !== 'DeletePostSuccess') {
throw new Error(result?.message || 'Failed to delete post')
}
return {
success: true,
output: {
deleted: true,
id: result.id,
},
}
},
outputs: {
deleted: { type: 'boolean', description: 'Whether the post was deleted' },
id: { type: 'string', description: 'ID of the deleted post' },
},
}