Skip to content

Commit 8d231ce

Browse files
waleedlatif1claude
andcommitted
refactor(selectors): remove unnecessary selected_ prefix from canonicalParamIds
The selected_ prefix was added to avoid a perceived clash between canonicalParamId and subBlock id values, but this clash does not actually cause any issues — pre-existing blocks on main (Google Sheets, Webflow, SharePoint) already use matching values successfully. Remove the prefix from all 14 blocks, revert use-selector-setup.ts to the simple CONTEXT_FIELD_SET pattern, and simplify tools.config.params functions that were only remapping the prefix back. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 20b621d commit 8d231ce

File tree

15 files changed

+179
-229
lines changed

15 files changed

+179
-229
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-selector-setup.ts

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ export function useSelectorSetup(
5050

5151
if (canonicalParamId === 'oauthCredential') {
5252
context.credentialId = strValue
53-
} else {
54-
const contextField = CANONICAL_TO_CONTEXT[canonicalParamId]
55-
if (contextField) {
56-
context[contextField] = strValue
57-
}
53+
} else if (canonicalParamId in CONTEXT_FIELD_SET) {
54+
;(context as Record<string, unknown>)[canonicalParamId] = strValue
5855
}
5956
}
6057

@@ -70,29 +67,18 @@ export function useSelectorSetup(
7067
}
7168
}
7269

73-
/**
74-
* Maps canonical param IDs to SelectorContext field names.
75-
*
76-
* Most canonical param IDs match their SelectorContext field directly (e.g. `siteId` → `siteId`).
77-
* Aliased entries handle cases where `canonicalParamId` was prefixed with `selected_` to avoid
78-
* clashing with a subBlock `id` of the same name.
79-
*/
80-
const CANONICAL_TO_CONTEXT: Record<string, keyof SelectorContext> = {
81-
credentialId: 'credentialId',
82-
domain: 'domain',
83-
teamId: 'teamId',
84-
projectId: 'projectId',
85-
knowledgeBaseId: 'knowledgeBaseId',
86-
planId: 'planId',
87-
siteId: 'siteId',
88-
collectionId: 'collectionId',
89-
spreadsheetId: 'spreadsheetId',
90-
fileId: 'fileId',
91-
baseId: 'baseId',
92-
datasetId: 'datasetId',
93-
serviceDeskId: 'serviceDeskId',
94-
selected_baseId: 'baseId',
95-
selected_datasetId: 'datasetId',
96-
selected_serviceDeskId: 'serviceDeskId',
97-
selected_planId: 'planId',
70+
const CONTEXT_FIELD_SET: Record<string, true> = {
71+
credentialId: true,
72+
domain: true,
73+
teamId: true,
74+
projectId: true,
75+
knowledgeBaseId: true,
76+
planId: true,
77+
siteId: true,
78+
collectionId: true,
79+
spreadsheetId: true,
80+
fileId: true,
81+
baseId: true,
82+
datasetId: true,
83+
serviceDeskId: true,
9884
}

apps/sim/blocks/blocks/airtable.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const AirtableBlock: BlockConfig<AirtableResponse> = {
6161
id: 'baseSelector',
6262
title: 'Base',
6363
type: 'project-selector',
64-
canonicalParamId: 'selected_baseId',
64+
canonicalParamId: 'baseId',
6565
serviceId: 'airtable',
6666
selectorKey: 'airtable.bases',
6767
selectorAllowSearch: false,
@@ -75,7 +75,7 @@ export const AirtableBlock: BlockConfig<AirtableResponse> = {
7575
id: 'baseId',
7676
title: 'Base ID',
7777
type: 'short-input',
78-
canonicalParamId: 'selected_baseId',
78+
canonicalParamId: 'baseId',
7979
placeholder: 'Enter your base ID (e.g., appXXXXXXXXXXXXXX)',
8080
mode: 'advanced',
8181
condition: { field: 'operation', value: 'listBases', not: true },
@@ -85,7 +85,7 @@ export const AirtableBlock: BlockConfig<AirtableResponse> = {
8585
id: 'tableSelector',
8686
title: 'Table',
8787
type: 'file-selector',
88-
canonicalParamId: 'selected_tableId',
88+
canonicalParamId: 'tableId',
8989
serviceId: 'airtable',
9090
selectorKey: 'airtable.tables',
9191
selectorAllowSearch: false,
@@ -99,7 +99,7 @@ export const AirtableBlock: BlockConfig<AirtableResponse> = {
9999
id: 'tableId',
100100
title: 'Table ID',
101101
type: 'short-input',
102-
canonicalParamId: 'selected_tableId',
102+
canonicalParamId: 'tableId',
103103
placeholder: 'Enter table ID (e.g., tblXXXXXXXXXXXXXX)',
104104
mode: 'advanced',
105105
condition: { field: 'operation', value: ['listBases', 'listTables'], not: true },
@@ -274,8 +274,7 @@ Return ONLY the valid JSON object - no explanations, no markdown.`,
274274
}
275275
},
276276
params: (params) => {
277-
const { oauthCredential, records, fields, selected_baseId, selected_tableId, ...rest } =
278-
params
277+
const { oauthCredential, records, fields, ...rest } = params
279278
let parsedRecords: any | undefined
280279
let parsedFields: any | undefined
281280

@@ -294,8 +293,6 @@ Return ONLY the valid JSON object - no explanations, no markdown.`,
294293
// Construct parameters based on operation
295294
const baseParams = {
296295
credential: oauthCredential,
297-
baseId: selected_baseId,
298-
tableId: selected_tableId,
299296
...rest,
300297
}
301298

@@ -314,8 +311,8 @@ Return ONLY the valid JSON object - no explanations, no markdown.`,
314311
inputs: {
315312
operation: { type: 'string', description: 'Operation to perform' },
316313
oauthCredential: { type: 'string', description: 'Airtable access token' },
317-
selected_baseId: { type: 'string', description: 'Airtable base identifier' },
318-
selected_tableId: { type: 'string', description: 'Airtable table identifier' },
314+
baseId: { type: 'string', description: 'Airtable base identifier' },
315+
tableId: { type: 'string', description: 'Airtable table identifier' },
319316
// Conditional inputs
320317
recordId: { type: 'string', description: 'Record identifier' }, // Required for get/update
321318
maxRecords: { type: 'number', description: 'Maximum records to return' }, // Optional for list

apps/sim/blocks/blocks/asana.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const AsanaBlock: BlockConfig<AsanaResponse> = {
5252
id: 'workspaceSelector',
5353
title: 'Workspace',
5454
type: 'project-selector',
55-
canonicalParamId: 'selected_workspace',
55+
canonicalParamId: 'workspace',
5656
serviceId: 'asana',
5757
selectorKey: 'asana.workspaces',
5858
selectorAllowSearch: false,
@@ -69,7 +69,7 @@ export const AsanaBlock: BlockConfig<AsanaResponse> = {
6969
id: 'workspace',
7070
title: 'Workspace GID',
7171
type: 'short-input',
72-
canonicalParamId: 'selected_workspace',
72+
canonicalParamId: 'workspace',
7373
required: true,
7474
placeholder: 'Enter Asana workspace GID',
7575
mode: 'advanced',
@@ -104,7 +104,7 @@ export const AsanaBlock: BlockConfig<AsanaResponse> = {
104104
id: 'getTasksWorkspaceSelector',
105105
title: 'Workspace',
106106
type: 'project-selector',
107-
canonicalParamId: 'selected_getTasks_workspace',
107+
canonicalParamId: 'getTasks_workspace',
108108
serviceId: 'asana',
109109
selectorKey: 'asana.workspaces',
110110
selectorAllowSearch: false,
@@ -120,7 +120,7 @@ export const AsanaBlock: BlockConfig<AsanaResponse> = {
120120
id: 'getTasks_workspace',
121121
title: 'Workspace GID',
122122
type: 'short-input',
123-
canonicalParamId: 'selected_getTasks_workspace',
123+
canonicalParamId: 'getTasks_workspace',
124124
placeholder: 'Enter workspace GID',
125125
mode: 'advanced',
126126
condition: {
@@ -280,14 +280,14 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
280280
return {
281281
...baseParams,
282282
taskGid: params.taskGid,
283-
workspace: params.selected_getTasks_workspace,
283+
workspace: params.getTasks_workspace,
284284
project: params.getTasks_project,
285285
limit: params.getTasks_limit ? Number(params.getTasks_limit) : undefined,
286286
}
287287
case 'create_task':
288288
return {
289289
...baseParams,
290-
workspace: params.selected_workspace,
290+
workspace: params.workspace,
291291
name: params.name,
292292
notes: params.notes,
293293
assignee: params.assignee,
@@ -306,12 +306,12 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
306306
case 'get_projects':
307307
return {
308308
...baseParams,
309-
workspace: params.selected_workspace,
309+
workspace: params.workspace,
310310
}
311311
case 'search_tasks':
312312
return {
313313
...baseParams,
314-
workspace: params.selected_workspace,
314+
workspace: params.workspace,
315315
text: params.searchText,
316316
assignee: params.assignee,
317317
projects: projectsArray,
@@ -332,9 +332,9 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
332332
inputs: {
333333
operation: { type: 'string', description: 'Operation to perform' },
334334
oauthCredential: { type: 'string', description: 'Asana OAuth credential' },
335-
selected_workspace: { type: 'string', description: 'Workspace GID' },
335+
workspace: { type: 'string', description: 'Workspace GID' },
336336
taskGid: { type: 'string', description: 'Task GID' },
337-
selected_getTasks_workspace: { type: 'string', description: 'Workspace GID for getting tasks' },
337+
getTasks_workspace: { type: 'string', description: 'Workspace GID for getting tasks' },
338338
getTasks_project: { type: 'string', description: 'Project GID filter for getting tasks' },
339339
getTasks_limit: { type: 'string', description: 'Limit for getting tasks' },
340340
name: { type: 'string', description: 'Task name' },

apps/sim/blocks/blocks/attio.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const AttioBlock: BlockConfig<AttioResponse> = {
9090
id: 'objectTypeSelector',
9191
title: 'Object Type',
9292
type: 'project-selector',
93-
canonicalParamId: 'selected_objectType',
93+
canonicalParamId: 'objectType',
9494
serviceId: 'attio',
9595
selectorKey: 'attio.objects',
9696
selectorAllowSearch: false,
@@ -124,7 +124,7 @@ export const AttioBlock: BlockConfig<AttioResponse> = {
124124
id: 'objectType',
125125
title: 'Object Type',
126126
type: 'short-input',
127-
canonicalParamId: 'selected_objectType',
127+
canonicalParamId: 'objectType',
128128
placeholder: 'e.g. people, companies',
129129
mode: 'advanced',
130130
condition: {
@@ -564,7 +564,7 @@ Return ONLY the JSON array. No explanations, no markdown, no extra text.
564564
id: 'listSelector',
565565
title: 'List',
566566
type: 'project-selector',
567-
canonicalParamId: 'selected_listIdOrSlug',
567+
canonicalParamId: 'listIdOrSlug',
568568
serviceId: 'attio',
569569
selectorKey: 'attio.lists',
570570
selectorAllowSearch: false,
@@ -600,7 +600,7 @@ Return ONLY the JSON array. No explanations, no markdown, no extra text.
600600
id: 'listIdOrSlug',
601601
title: 'List ID or Slug',
602602
type: 'short-input',
603-
canonicalParamId: 'selected_listIdOrSlug',
603+
canonicalParamId: 'listIdOrSlug',
604604
placeholder: 'Enter the list ID or slug',
605605
mode: 'advanced',
606606
condition: {
@@ -1116,7 +1116,7 @@ workspace-member.created
11161116
}
11171117

11181118
// Record params
1119-
if (params.selected_objectType) cleanParams.objectType = params.selected_objectType
1119+
if (params.objectType) cleanParams.objectType = params.objectType
11201120
if (params.recordId) cleanParams.recordId = params.recordId
11211121
if (params.matchingAttribute) cleanParams.matchingAttribute = params.matchingAttribute
11221122
if (params.values) cleanParams.values = params.values
@@ -1157,7 +1157,7 @@ workspace-member.created
11571157
if (params.objectPluralNoun) cleanParams.pluralNoun = params.objectPluralNoun
11581158

11591159
// List params
1160-
if (params.selected_listIdOrSlug) cleanParams.list = params.selected_listIdOrSlug
1160+
if (params.listIdOrSlug) cleanParams.list = params.listIdOrSlug
11611161
if (params.listName) cleanParams.name = params.listName
11621162
if (params.listParentObject) cleanParams.parentObject = params.listParentObject
11631163
if (params.listApiSlug) cleanParams.apiSlug = params.listApiSlug
@@ -1209,7 +1209,7 @@ workspace-member.created
12091209
inputs: {
12101210
operation: { type: 'string', description: 'The operation to perform' },
12111211
oauthCredential: { type: 'string', description: 'Attio OAuth credential' },
1212-
selected_objectType: { type: 'string', description: 'Object type slug' },
1212+
objectType: { type: 'string', description: 'Object type slug' },
12131213
recordId: { type: 'string', description: 'Record ID' },
12141214
matchingAttribute: { type: 'string', description: 'Matching attribute for upsert' },
12151215
values: { type: 'json', description: 'Record attribute values' },
@@ -1235,7 +1235,7 @@ workspace-member.created
12351235
objectApiSlug: { type: 'string', description: 'Object API slug' },
12361236
objectSingularNoun: { type: 'string', description: 'Object singular name' },
12371237
objectPluralNoun: { type: 'string', description: 'Object plural name' },
1238-
selected_listIdOrSlug: { type: 'string', description: 'List ID or slug' },
1238+
listIdOrSlug: { type: 'string', description: 'List ID or slug' },
12391239
listName: { type: 'string', description: 'List name' },
12401240
listParentObject: { type: 'string', description: 'List parent object' },
12411241
listApiSlug: { type: 'string', description: 'List API slug' },

0 commit comments

Comments
 (0)