-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathdelete.ts
More file actions
106 lines (99 loc) · 2.97 KB
/
Copy pathdelete.ts
File metadata and controls
106 lines (99 loc) · 2.97 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import type { DynamoDBDeleteParams, DynamoDBDeleteResponse } from '@/tools/dynamodb/types'
import type { ToolConfig } from '@/tools/types'
export const deleteTool: ToolConfig<DynamoDBDeleteParams, DynamoDBDeleteResponse> = {
id: 'dynamodb_delete',
name: 'DynamoDB Delete',
description: 'Delete an item from a DynamoDB table',
version: '1.0.0',
params: {
region: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'AWS region (e.g., us-east-1)',
},
accessKeyId: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'AWS access key ID',
},
secretAccessKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'AWS secret access key',
},
tableName: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'DynamoDB table name (e.g., "Users", "Orders")',
},
key: {
type: 'json',
required: true,
visibility: 'user-or-llm',
description:
'Primary key of the item to delete (e.g., {"pk": "USER#123"} or {"pk": "ORDER#456", "sk": "ITEM#789"})',
},
conditionExpression: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Condition that must be met for the delete to succeed (e.g., "attribute_exists(pk)")',
},
expressionAttributeNames: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description:
'Attribute name mappings for reserved words used in conditionExpression (e.g., {"#status": "status"})',
},
expressionAttributeValues: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description:
'Expression attribute values used in conditionExpression (e.g., {":status": "active"})',
},
},
request: {
url: '/api/tools/dynamodb/delete',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
region: params.region,
accessKeyId: params.accessKeyId,
secretAccessKey: params.secretAccessKey,
tableName: params.tableName,
key: params.key,
...(params.conditionExpression && { conditionExpression: params.conditionExpression }),
...(params.expressionAttributeNames && {
expressionAttributeNames: params.expressionAttributeNames,
}),
...(params.expressionAttributeValues && {
expressionAttributeValues: params.expressionAttributeValues,
}),
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'DynamoDB delete failed')
}
return {
success: true,
output: {
message: data.message || 'Item deleted successfully',
},
error: undefined,
}
},
outputs: {
message: { type: 'string', description: 'Operation status message' },
},
}