Skip to content

Commit fca2e6c

Browse files
committed
fix(square): correct canonical file param usage and revert query split
- Read the catalog image file from the canonical `params.file` (the basic/advanced inputs are collapsed before the params function runs) instead of the raw uploadFile/fileRef ids, which no longer exist at that point — fixes the Canonical Param Validation test and a latent upload bug - Revert the per-operation query split: canonicalParamId is only valid for basic/advanced pairs under one condition. Use a single query field with a schema-neutral placeholder and a wand prompt that covers each search operation
1 parent 81d5107 commit fca2e6c

1 file changed

Lines changed: 12 additions & 43 deletions

File tree

apps/sim/blocks/blocks/square.ts

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -309,54 +309,24 @@ export const SquareBlock: BlockConfig<SquareResponse> = {
309309
mode: 'advanced',
310310
},
311311

312-
// Search query — one field per search operation so the placeholder and wand
313-
// prompt match each endpoint's distinct query schema. All map to the same
314-
// canonical `query` param.
312+
// Search query — shared across the three search operations. The placeholder
313+
// stays schema-neutral (each endpoint expects a different query shape) and
314+
// the examples for each are spelled out in the wand prompt.
315315
{
316-
id: 'queryCustomers',
316+
id: 'query',
317317
title: 'Query (JSON)',
318318
type: 'code',
319319
language: 'json',
320-
canonicalParamId: 'query',
321-
placeholder: '{"filter": {"email_address": {"exact": "customer@example.com"}}}',
322-
condition: { field: 'operation', value: 'search_customers' },
323-
mode: 'advanced',
324-
wandConfig: {
325-
enabled: true,
326-
prompt:
327-
'Generate a Square SearchCustomers query JSON object with a filter and optional sort. Return ONLY the JSON object.',
328-
generationType: 'json-object',
329-
},
330-
},
331-
{
332-
id: 'queryOrders',
333-
title: 'Query (JSON)',
334-
type: 'code',
335-
language: 'json',
336-
canonicalParamId: 'query',
337-
placeholder: '{"filter": {"state_filter": {"states": ["OPEN"]}}}',
338-
condition: { field: 'operation', value: 'search_orders' },
339-
mode: 'advanced',
340-
wandConfig: {
341-
enabled: true,
342-
prompt:
343-
'Generate a Square SearchOrders query JSON object with a filter (e.g. state_filter, date_time_filter) and optional sort. Return ONLY the JSON object.',
344-
generationType: 'json-object',
320+
placeholder: 'Square search query JSON for the selected operation',
321+
condition: {
322+
field: 'operation',
323+
value: ['search_customers', 'search_orders', 'search_catalog_objects'],
345324
},
346-
},
347-
{
348-
id: 'queryCatalog',
349-
title: 'Query (JSON)',
350-
type: 'code',
351-
language: 'json',
352-
canonicalParamId: 'query',
353-
placeholder: '{"text_query": {"keywords": ["coffee"]}}',
354-
condition: { field: 'operation', value: 'search_catalog_objects' },
355325
mode: 'advanced',
356326
wandConfig: {
357327
enabled: true,
358328
prompt:
359-
'Generate a Square SearchCatalogObjects query JSON object (e.g. text_query, prefix_query, exact_query). Return ONLY the JSON object.',
329+
'Generate a Square search query JSON object for the selected operation. For Search Customers use a filter like {"filter":{"email_address":{"exact":"a@b.com"}}}; for Search Orders use {"filter":{"state_filter":{"states":["OPEN"]}}}; for Search Catalog Objects use {"text_query":{"keywords":["coffee"]}}. Return ONLY the JSON object.',
360330
generationType: 'json-object',
361331
},
362332
},
@@ -707,8 +677,6 @@ export const SquareBlock: BlockConfig<SquareResponse> = {
707677
params: (params) => {
708678
const {
709679
operation,
710-
uploadFile,
711-
fileRef,
712680
address,
713681
query,
714682
order,
@@ -728,8 +696,9 @@ export const SquareBlock: BlockConfig<SquareResponse> = {
728696
...rest
729697
} = params
730698

731-
// Normalize the catalog image file from basic (uploadFile) or advanced (fileRef)
732-
const normalizedFile = normalizeFileInput(uploadFile || fileRef, { single: true })
699+
// The basic/advanced image inputs are collapsed into the canonical `file`
700+
// param before this runs, so normalize from params.file.
701+
const normalizedFile = normalizeFileInput(params.file, { single: true })
733702

734703
// Parse a JSON-typed input, naming the field in any error so the user
735704
// knows exactly which input to fix.

0 commit comments

Comments
 (0)