Skip to content

Commit 019d731

Browse files
Adam GoughAdam Gough
authored andcommitted
added metadata
1 parent b7a1e37 commit 019d731

2 files changed

Lines changed: 37 additions & 8 deletions

File tree

apps/sim/blocks/blocks/clay.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ Plain Text: Best for populating a table in free-form style.
5555
data: { type: 'json', description: 'Data to populate' },
5656
},
5757
outputs: {
58-
data: { type: 'json', description: 'Response data' },
58+
data: { type: 'json', description: 'Response data from Clay webhook' },
59+
metadata: {
60+
type: 'json',
61+
description: 'Webhook metadata including status, headers, timestamp, and content type',
62+
},
5963
},
6064
}

apps/sim/tools/clay/populate.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,52 @@ export const clayPopulateTool: ToolConfig<ClayPopulateParams, ClayPopulateRespon
5151

5252
transformResponse: async (response: Response) => {
5353
const contentType = response.headers.get('content-type')
54-
let data
54+
const timestamp = new Date().toISOString()
5555

56+
// Extract response headers
57+
const headers: Record<string, string> = {}
58+
response.headers.forEach((value, key) => {
59+
headers[key] = value
60+
})
61+
62+
// Parse response body
63+
let responseData
5664
if (contentType?.includes('application/json')) {
57-
data = await response.json()
65+
responseData = await response.json()
5866
} else {
59-
data = await response.text()
67+
responseData = await response.text()
6068
}
6169

6270
return {
6371
success: true,
6472
output: {
65-
data: contentType?.includes('application/json') ? data : { message: data },
73+
data: contentType?.includes('application/json') ? responseData : { message: responseData },
74+
metadata: {
75+
status: response.status,
76+
statusText: response.statusText,
77+
headers: headers,
78+
timestamp: timestamp,
79+
contentType: contentType || 'unknown',
80+
},
6681
},
6782
}
6883
},
6984

7085
outputs: {
71-
success: { type: 'boolean', description: 'Operation success status' },
72-
output: {
86+
data: {
7387
type: 'json',
74-
description: 'Clay populate operation results including response data from Clay webhook',
88+
description: 'Response data from Clay webhook',
89+
},
90+
metadata: {
91+
type: 'object',
92+
description: 'Webhook response metadata',
93+
properties: {
94+
status: { type: 'number', description: 'HTTP status code' },
95+
statusText: { type: 'string', description: 'HTTP status text' },
96+
headers: { type: 'object', description: 'Response headers from Clay' },
97+
timestamp: { type: 'string', description: 'ISO timestamp when webhook was received' },
98+
contentType: { type: 'string', description: 'Content type of the response' },
99+
},
75100
},
76101
},
77102
}

0 commit comments

Comments
 (0)