Skip to content

Commit 5f719b3

Browse files
committed
remove manual validations
1 parent 5fde0bd commit 5f719b3

File tree

9 files changed

+93
-230
lines changed

9 files changed

+93
-230
lines changed

apps/sim/blocks/blocks/confluence.ts

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
8888
placeholder: 'Select Confluence page',
8989
dependsOn: ['credential', 'domain'],
9090
mode: 'basic',
91+
required: {
92+
field: 'operation',
93+
value: [
94+
'read',
95+
'update',
96+
'delete',
97+
'create_comment',
98+
'list_comments',
99+
'list_attachments',
100+
'list_labels',
101+
'upload_attachment',
102+
],
103+
},
91104
},
92105
{
93106
id: 'manualPageId',
@@ -96,14 +109,26 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
96109
canonicalParamId: 'pageId',
97110
placeholder: 'Enter Confluence page ID',
98111
mode: 'advanced',
112+
required: {
113+
field: 'operation',
114+
value: [
115+
'read',
116+
'update',
117+
'delete',
118+
'create_comment',
119+
'list_comments',
120+
'list_attachments',
121+
'list_labels',
122+
'upload_attachment',
123+
],
124+
},
99125
},
100126
{
101127
id: 'spaceId',
102128
title: 'Space ID',
103129
type: 'short-input',
104130
placeholder: 'Enter Confluence space ID',
105-
required: true,
106-
condition: { field: 'operation', value: ['create', 'get_space'] },
131+
required: { field: 'operation', value: ['create', 'get_space'] },
107132
},
108133
{
109134
id: 'title',
@@ -267,27 +292,6 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
267292

268293
const effectivePageId = pageId ? String(pageId).trim() : ''
269294

270-
const requiresPageId = [
271-
'read',
272-
'update',
273-
'delete',
274-
'create_comment',
275-
'list_comments',
276-
'list_attachments',
277-
'list_labels',
278-
'upload_attachment',
279-
]
280-
281-
const requiresSpaceId = ['create', 'get_space']
282-
283-
if (requiresPageId.includes(operation) && !effectivePageId) {
284-
throw new Error('Page ID is required. Please select a page or enter a page ID manually.')
285-
}
286-
287-
if (requiresSpaceId.includes(operation) && !rest.spaceId) {
288-
throw new Error('Space ID is required for this operation.')
289-
}
290-
291295
if (operation === 'upload_attachment') {
292296
return {
293297
credential,
@@ -435,6 +439,19 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
435439
placeholder: 'Select Confluence page',
436440
dependsOn: ['credential', 'domain'],
437441
mode: 'basic',
442+
required: {
443+
field: 'operation',
444+
value: [
445+
'read',
446+
'update',
447+
'delete',
448+
'create_comment',
449+
'list_comments',
450+
'list_attachments',
451+
'list_labels',
452+
'upload_attachment',
453+
],
454+
},
438455
},
439456
{
440457
id: 'manualPageId',
@@ -443,14 +460,26 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
443460
canonicalParamId: 'pageId',
444461
placeholder: 'Enter Confluence page ID',
445462
mode: 'advanced',
463+
required: {
464+
field: 'operation',
465+
value: [
466+
'read',
467+
'update',
468+
'delete',
469+
'create_comment',
470+
'list_comments',
471+
'list_attachments',
472+
'list_labels',
473+
'upload_attachment',
474+
],
475+
},
446476
},
447477
{
448478
id: 'spaceId',
449479
title: 'Space ID',
450480
type: 'short-input',
451481
placeholder: 'Enter Confluence space ID',
452-
required: true,
453-
condition: { field: 'operation', value: ['create', 'get_space'] },
482+
required: { field: 'operation', value: ['create', 'get_space'] },
454483
},
455484
{
456485
id: 'title',
@@ -513,6 +542,7 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
513542
placeholder: 'Select file to upload',
514543
condition: { field: 'operation', value: 'upload_attachment' },
515544
mode: 'basic',
545+
required: { field: 'operation', value: 'upload_attachment' },
516546
},
517547
{
518548
id: 'attachmentFileReference',
@@ -522,6 +552,7 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
522552
placeholder: 'Reference file from previous blocks',
523553
condition: { field: 'operation', value: 'upload_attachment' },
524554
mode: 'advanced',
555+
required: { field: 'operation', value: 'upload_attachment' },
525556
},
526557
{
527558
id: 'attachmentFileName',
@@ -624,27 +655,6 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
624655

625656
const effectivePageId = pageId ? String(pageId).trim() : ''
626657

627-
const requiresPageId = [
628-
'read',
629-
'update',
630-
'delete',
631-
'create_comment',
632-
'list_comments',
633-
'list_attachments',
634-
'list_labels',
635-
'upload_attachment',
636-
]
637-
638-
const requiresSpaceId = ['create', 'get_space']
639-
640-
if (requiresPageId.includes(operation) && !effectivePageId) {
641-
throw new Error('Page ID is required. Please select a page or enter a page ID manually.')
642-
}
643-
644-
if (requiresSpaceId.includes(operation) && !rest.spaceId) {
645-
throw new Error('Space ID is required for this operation.')
646-
}
647-
648658
if (operation === 'upload_attachment') {
649659
const normalizedFile = normalizeFileInput(attachmentFile, { single: true })
650660
if (!normalizedFile) {

apps/sim/blocks/blocks/google_forms.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ Example for "Add a required multiple choice question about favorite color":
256256

257257
switch (operation) {
258258
case 'get_responses':
259-
if (!effectiveFormId) throw new Error('Form ID is required.')
260259
return {
261260
...baseParams,
262261
formId: effectiveFormId,
@@ -265,37 +264,29 @@ Example for "Add a required multiple choice question about favorite color":
265264
}
266265
case 'get_form':
267266
case 'list_watches':
268-
if (!effectiveFormId) throw new Error('Form ID is required.')
269267
return { ...baseParams, formId: effectiveFormId }
270268
case 'create_form':
271-
if (!title) throw new Error('Form title is required.')
272269
return {
273270
...baseParams,
274271
title: String(title).trim(),
275272
documentTitle: documentTitle ? String(documentTitle).trim() : undefined,
276273
unpublished: unpublished ?? false,
277274
}
278275
case 'batch_update':
279-
if (!effectiveFormId) throw new Error('Form ID is required.')
280-
if (!requests) throw new Error('Update requests are required.')
281276
return {
282277
...baseParams,
283278
formId: effectiveFormId,
284279
requests: typeof requests === 'string' ? JSON.parse(requests) : requests,
285280
includeFormInResponse: includeFormInResponse ?? false,
286281
}
287282
case 'set_publish_settings':
288-
if (!effectiveFormId) throw new Error('Form ID is required.')
289283
return {
290284
...baseParams,
291285
formId: effectiveFormId,
292286
isPublished: isPublished ?? false,
293287
isAcceptingResponses: isAcceptingResponses,
294288
}
295289
case 'create_watch':
296-
if (!effectiveFormId) throw new Error('Form ID is required.')
297-
if (!eventType) throw new Error('Event type is required.')
298-
if (!topicName) throw new Error('Pub/Sub topic is required.')
299290
return {
300291
...baseParams,
301292
formId: effectiveFormId,
@@ -305,8 +296,6 @@ Example for "Add a required multiple choice question about favorite color":
305296
}
306297
case 'delete_watch':
307298
case 'renew_watch':
308-
if (!effectiveFormId) throw new Error('Form ID is required.')
309-
if (!watchId) throw new Error('Watch ID is required.')
310299
return {
311300
...baseParams,
312301
formId: effectiveFormId,

apps/sim/blocks/blocks/jira.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,6 @@ Return ONLY the comment text - no explanations.`,
858858
}
859859
}
860860
case 'add_attachment': {
861-
if (!effectiveIssueKey) {
862-
throw new Error('Issue Key is required to add attachments.')
863-
}
864861
const normalizedFiles = normalizeFileInput(params.files)
865862
if (!normalizedFiles || normalizedFiles.length === 0) {
866863
throw new Error('At least one attachment file is required.')
@@ -878,9 +875,6 @@ Return ONLY the comment text - no explanations.`,
878875
}
879876
}
880877
case 'add_worklog': {
881-
if (!effectiveIssueKey) {
882-
throw new Error('Issue Key is required to add a worklog.')
883-
}
884878
return {
885879
...baseParams,
886880
issueKey: effectiveIssueKey,
@@ -892,9 +886,6 @@ Return ONLY the comment text - no explanations.`,
892886
}
893887
}
894888
case 'get_worklogs': {
895-
if (!effectiveIssueKey) {
896-
throw new Error('Issue Key is required to get worklogs.')
897-
}
898889
return {
899890
...baseParams,
900891
issueKey: effectiveIssueKey,

0 commit comments

Comments
 (0)