remove manual validations

This commit is contained in:
Vikhyath Mondreti
2026-02-04 22:42:01 -08:00
parent 5fde0bd941
commit 5f719b3746
9 changed files with 93 additions and 230 deletions

View File

@@ -88,6 +88,19 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
placeholder: 'Select Confluence page',
dependsOn: ['credential', 'domain'],
mode: 'basic',
required: {
field: 'operation',
value: [
'read',
'update',
'delete',
'create_comment',
'list_comments',
'list_attachments',
'list_labels',
'upload_attachment',
],
},
},
{
id: 'manualPageId',
@@ -96,14 +109,26 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
canonicalParamId: 'pageId',
placeholder: 'Enter Confluence page ID',
mode: 'advanced',
required: {
field: 'operation',
value: [
'read',
'update',
'delete',
'create_comment',
'list_comments',
'list_attachments',
'list_labels',
'upload_attachment',
],
},
},
{
id: 'spaceId',
title: 'Space ID',
type: 'short-input',
placeholder: 'Enter Confluence space ID',
required: true,
condition: { field: 'operation', value: ['create', 'get_space'] },
required: { field: 'operation', value: ['create', 'get_space'] },
},
{
id: 'title',
@@ -267,27 +292,6 @@ export const ConfluenceBlock: BlockConfig<ConfluenceResponse> = {
const effectivePageId = pageId ? String(pageId).trim() : ''
const requiresPageId = [
'read',
'update',
'delete',
'create_comment',
'list_comments',
'list_attachments',
'list_labels',
'upload_attachment',
]
const requiresSpaceId = ['create', 'get_space']
if (requiresPageId.includes(operation) && !effectivePageId) {
throw new Error('Page ID is required. Please select a page or enter a page ID manually.')
}
if (requiresSpaceId.includes(operation) && !rest.spaceId) {
throw new Error('Space ID is required for this operation.')
}
if (operation === 'upload_attachment') {
return {
credential,
@@ -435,6 +439,19 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
placeholder: 'Select Confluence page',
dependsOn: ['credential', 'domain'],
mode: 'basic',
required: {
field: 'operation',
value: [
'read',
'update',
'delete',
'create_comment',
'list_comments',
'list_attachments',
'list_labels',
'upload_attachment',
],
},
},
{
id: 'manualPageId',
@@ -443,14 +460,26 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
canonicalParamId: 'pageId',
placeholder: 'Enter Confluence page ID',
mode: 'advanced',
required: {
field: 'operation',
value: [
'read',
'update',
'delete',
'create_comment',
'list_comments',
'list_attachments',
'list_labels',
'upload_attachment',
],
},
},
{
id: 'spaceId',
title: 'Space ID',
type: 'short-input',
placeholder: 'Enter Confluence space ID',
required: true,
condition: { field: 'operation', value: ['create', 'get_space'] },
required: { field: 'operation', value: ['create', 'get_space'] },
},
{
id: 'title',
@@ -513,6 +542,7 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
placeholder: 'Select file to upload',
condition: { field: 'operation', value: 'upload_attachment' },
mode: 'basic',
required: { field: 'operation', value: 'upload_attachment' },
},
{
id: 'attachmentFileReference',
@@ -522,6 +552,7 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
placeholder: 'Reference file from previous blocks',
condition: { field: 'operation', value: 'upload_attachment' },
mode: 'advanced',
required: { field: 'operation', value: 'upload_attachment' },
},
{
id: 'attachmentFileName',
@@ -624,27 +655,6 @@ export const ConfluenceV2Block: BlockConfig<ConfluenceResponse> = {
const effectivePageId = pageId ? String(pageId).trim() : ''
const requiresPageId = [
'read',
'update',
'delete',
'create_comment',
'list_comments',
'list_attachments',
'list_labels',
'upload_attachment',
]
const requiresSpaceId = ['create', 'get_space']
if (requiresPageId.includes(operation) && !effectivePageId) {
throw new Error('Page ID is required. Please select a page or enter a page ID manually.')
}
if (requiresSpaceId.includes(operation) && !rest.spaceId) {
throw new Error('Space ID is required for this operation.')
}
if (operation === 'upload_attachment') {
const normalizedFile = normalizeFileInput(attachmentFile, { single: true })
if (!normalizedFile) {

View File

@@ -256,7 +256,6 @@ Example for "Add a required multiple choice question about favorite color":
switch (operation) {
case 'get_responses':
if (!effectiveFormId) throw new Error('Form ID is required.')
return {
...baseParams,
formId: effectiveFormId,
@@ -265,10 +264,8 @@ Example for "Add a required multiple choice question about favorite color":
}
case 'get_form':
case 'list_watches':
if (!effectiveFormId) throw new Error('Form ID is required.')
return { ...baseParams, formId: effectiveFormId }
case 'create_form':
if (!title) throw new Error('Form title is required.')
return {
...baseParams,
title: String(title).trim(),
@@ -276,8 +273,6 @@ Example for "Add a required multiple choice question about favorite color":
unpublished: unpublished ?? false,
}
case 'batch_update':
if (!effectiveFormId) throw new Error('Form ID is required.')
if (!requests) throw new Error('Update requests are required.')
return {
...baseParams,
formId: effectiveFormId,
@@ -285,7 +280,6 @@ Example for "Add a required multiple choice question about favorite color":
includeFormInResponse: includeFormInResponse ?? false,
}
case 'set_publish_settings':
if (!effectiveFormId) throw new Error('Form ID is required.')
return {
...baseParams,
formId: effectiveFormId,
@@ -293,9 +287,6 @@ Example for "Add a required multiple choice question about favorite color":
isAcceptingResponses: isAcceptingResponses,
}
case 'create_watch':
if (!effectiveFormId) throw new Error('Form ID is required.')
if (!eventType) throw new Error('Event type is required.')
if (!topicName) throw new Error('Pub/Sub topic is required.')
return {
...baseParams,
formId: effectiveFormId,
@@ -305,8 +296,6 @@ Example for "Add a required multiple choice question about favorite color":
}
case 'delete_watch':
case 'renew_watch':
if (!effectiveFormId) throw new Error('Form ID is required.')
if (!watchId) throw new Error('Watch ID is required.')
return {
...baseParams,
formId: effectiveFormId,

View File

@@ -858,9 +858,6 @@ Return ONLY the comment text - no explanations.`,
}
}
case 'add_attachment': {
if (!effectiveIssueKey) {
throw new Error('Issue Key is required to add attachments.')
}
const normalizedFiles = normalizeFileInput(params.files)
if (!normalizedFiles || normalizedFiles.length === 0) {
throw new Error('At least one attachment file is required.')
@@ -878,9 +875,6 @@ Return ONLY the comment text - no explanations.`,
}
}
case 'add_worklog': {
if (!effectiveIssueKey) {
throw new Error('Issue Key is required to add a worklog.')
}
return {
...baseParams,
issueKey: effectiveIssueKey,
@@ -892,9 +886,6 @@ Return ONLY the comment text - no explanations.`,
}
}
case 'get_worklogs': {
if (!effectiveIssueKey) {
throw new Error('Issue Key is required to get worklogs.')
}
return {
...baseParams,
issueKey: effectiveIssueKey,

View File

@@ -84,6 +84,10 @@ export const MicrosoftPlannerBlock: BlockConfig<MicrosoftPlannerResponse> = {
field: 'operation',
value: ['create_task', 'read_task', 'read_plan', 'list_buckets', 'create_bucket'],
},
required: {
field: 'operation',
value: ['read_plan', 'list_buckets', 'create_bucket', 'create_task'],
},
dependsOn: ['credential'],
},
@@ -122,6 +126,7 @@ export const MicrosoftPlannerBlock: BlockConfig<MicrosoftPlannerResponse> = {
field: 'operation',
value: ['update_task', 'delete_task', 'get_task_details', 'update_task_details'],
},
required: true,
dependsOn: ['credential'],
},
@@ -132,6 +137,7 @@ export const MicrosoftPlannerBlock: BlockConfig<MicrosoftPlannerResponse> = {
type: 'short-input',
placeholder: 'Enter the bucket ID',
condition: { field: 'operation', value: ['read_bucket', 'update_bucket', 'delete_bucket'] },
required: true,
dependsOn: ['credential'],
},
@@ -162,6 +168,7 @@ export const MicrosoftPlannerBlock: BlockConfig<MicrosoftPlannerResponse> = {
type: 'short-input',
placeholder: 'Enter the task title',
condition: { field: 'operation', value: ['create_task', 'update_task'] },
required: { field: 'operation', value: 'create_task' },
},
// Name for bucket operations
@@ -171,6 +178,7 @@ export const MicrosoftPlannerBlock: BlockConfig<MicrosoftPlannerResponse> = {
type: 'short-input',
placeholder: 'Enter the bucket name',
condition: { field: 'operation', value: ['create_bucket', 'update_bucket'] },
required: { field: 'operation', value: 'create_bucket' },
},
// Description for task details
@@ -382,31 +390,22 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
// Read Plan
if (operation === 'read_plan') {
if (!planId?.trim()) {
throw new Error('Plan ID is required to read a plan.')
}
return {
...baseParams,
planId: planId.trim(),
planId: planId?.trim(),
}
}
// List Buckets
if (operation === 'list_buckets') {
if (!planId?.trim()) {
throw new Error('Plan ID is required to list buckets.')
}
return {
...baseParams,
planId: planId.trim(),
planId: planId?.trim(),
}
}
// Read Bucket
if (operation === 'read_bucket') {
if (!effectiveBucketId) {
throw new Error('Bucket ID is required to read a bucket.')
}
return {
...baseParams,
bucketId: effectiveBucketId,
@@ -415,31 +414,19 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
// Create Bucket
if (operation === 'create_bucket') {
if (!planId?.trim()) {
throw new Error('Plan ID is required to create a bucket.')
}
if (!name?.trim()) {
throw new Error('Bucket name is required to create a bucket.')
}
return {
...baseParams,
planId: planId.trim(),
name: name.trim(),
planId: planId?.trim(),
name: name?.trim(),
}
}
// Update Bucket
if (operation === 'update_bucket') {
if (!effectiveBucketId) {
throw new Error('Bucket ID is required to update a bucket.')
}
if (!etag?.trim()) {
throw new Error('ETag is required to update a bucket.')
}
const updateBucketParams: MicrosoftPlannerBlockParams = {
...baseParams,
bucketId: effectiveBucketId,
etag: etag.trim(),
etag: etag?.trim(),
}
if (name?.trim()) {
updateBucketParams.name = name.trim()
@@ -449,16 +436,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
// Delete Bucket
if (operation === 'delete_bucket') {
if (!effectiveBucketId) {
throw new Error('Bucket ID is required to delete a bucket.')
}
if (!etag?.trim()) {
throw new Error('ETag is required to delete a bucket.')
}
return {
...baseParams,
bucketId: effectiveBucketId,
etag: etag.trim(),
etag: etag?.trim(),
}
}
@@ -477,17 +458,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
// Create Task
if (operation === 'create_task') {
if (!planId?.trim()) {
throw new Error('Plan ID is required to create a task.')
}
if (!title?.trim()) {
throw new Error('Task title is required to create a task.')
}
const createParams: MicrosoftPlannerBlockParams = {
...baseParams,
planId: planId.trim(),
title: title.trim(),
planId: planId?.trim(),
title: title?.trim(),
}
if (description?.trim()) {
@@ -508,17 +482,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
// Update Task
if (operation === 'update_task') {
if (!effectiveUpdateTaskId) {
throw new Error('Task ID is required to update a task.')
}
if (!etag?.trim()) {
throw new Error('ETag is required to update a task.')
}
const updateParams: MicrosoftPlannerBlockParams = {
...baseParams,
taskId: effectiveUpdateTaskId,
etag: etag.trim(),
etag: etag?.trim(),
}
if (title?.trim()) {
@@ -548,24 +515,15 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
// Delete Task
if (operation === 'delete_task') {
if (!effectiveUpdateTaskId) {
throw new Error('Task ID is required to delete a task.')
}
if (!etag?.trim()) {
throw new Error('ETag is required to delete a task.')
}
return {
...baseParams,
taskId: effectiveUpdateTaskId,
etag: etag.trim(),
etag: etag?.trim(),
}
}
// Get Task Details
if (operation === 'get_task_details') {
if (!effectiveUpdateTaskId) {
throw new Error('Task ID is required to get task details.')
}
return {
...baseParams,
taskId: effectiveUpdateTaskId,
@@ -574,17 +532,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
// Update Task Details
if (operation === 'update_task_details') {
if (!effectiveUpdateTaskId) {
throw new Error('Task ID is required to update task details.')
}
if (!etag?.trim()) {
throw new Error('ETag is required to update task details.')
}
const updateDetailsParams: MicrosoftPlannerBlockParams = {
...baseParams,
taskId: effectiveUpdateTaskId,
etag: etag.trim(),
etag: etag?.trim(),
}
if (description?.trim()) {

View File

@@ -92,6 +92,7 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
'list_channel_members',
],
},
required: true,
},
{
id: 'manualTeamId',
@@ -112,6 +113,7 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
'list_channel_members',
],
},
required: true,
},
{
id: 'chatSelector',
@@ -127,6 +129,7 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
field: 'operation',
value: ['read_chat', 'write_chat', 'update_chat_message', 'delete_chat_message'],
},
required: true,
},
{
id: 'manualChatId',
@@ -139,6 +142,7 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
field: 'operation',
value: ['read_chat', 'write_chat', 'update_chat_message', 'delete_chat_message'],
},
required: true,
},
{
id: 'channelSelector',
@@ -161,6 +165,7 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
'list_channel_members',
],
},
required: true,
},
{
id: 'manualChannelId',
@@ -180,6 +185,7 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
'list_channel_members',
],
},
required: true,
},
{
id: 'messageId',
@@ -365,9 +371,6 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
operation === 'update_chat_message' ||
operation === 'delete_chat_message'
) {
if (!effectiveChatId) {
throw new Error('Chat ID is required. Please select a chat or enter a chat ID.')
}
return { ...baseParams, chatId: effectiveChatId }
}
@@ -379,31 +382,16 @@ export const MicrosoftTeamsBlock: BlockConfig<MicrosoftTeamsResponse> = {
operation === 'delete_channel_message' ||
operation === 'reply_to_message'
) {
if (!effectiveTeamId) {
throw new Error('Team ID is required for channel operations.')
}
if (!effectiveChannelId) {
throw new Error('Channel ID is required for channel operations.')
}
return { ...baseParams, teamId: effectiveTeamId, channelId: effectiveChannelId }
}
// Team member operations
if (operation === 'list_team_members') {
if (!effectiveTeamId) {
throw new Error('Team ID is required for team member operations.')
}
return { ...baseParams, teamId: effectiveTeamId }
}
// Channel member operations
if (operation === 'list_channel_members') {
if (!effectiveTeamId) {
throw new Error('Team ID is required for channel member operations.')
}
if (!effectiveChannelId) {
throw new Error('Channel ID is required for channel member operations.')
}
return { ...baseParams, teamId: effectiveTeamId, channelId: effectiveChannelId }
}

View File

@@ -25,6 +25,7 @@ export const PulseBlock: BlockConfig<PulseParserOutput> = {
placeholder: 'Upload a document',
mode: 'basic',
maxSize: 50,
required: true,
},
{
id: 'filePath',
@@ -33,6 +34,7 @@ export const PulseBlock: BlockConfig<PulseParserOutput> = {
canonicalParamId: 'document',
placeholder: 'Document URL',
mode: 'advanced',
required: true,
},
{
id: 'pages',
@@ -66,19 +68,12 @@ export const PulseBlock: BlockConfig<PulseParserOutput> = {
config: {
tool: () => 'pulse_parser',
params: (params) => {
if (!params || !params.apiKey || params.apiKey.trim() === '') {
throw new Error('Pulse API key is required')
}
const parameters: Record<string, unknown> = {
apiKey: params.apiKey.trim(),
}
// document is the canonical param from fileUpload (basic) or filePath (advanced)
const documentInput = params.document
if (!documentInput) {
throw new Error('Document is required')
}
if (typeof documentInput === 'object') {
parameters.file = documentInput
} else if (typeof documentInput === 'string') {
@@ -148,6 +143,7 @@ const pulseV2SubBlocks = (PulseBlock.subBlocks || []).flatMap((subBlock) => {
canonicalParamId: 'document',
placeholder: 'File reference',
mode: 'advanced' as const,
required: true,
},
]
}
@@ -171,10 +167,6 @@ export const PulseV2Block: BlockConfig<PulseParserOutput> = {
fallbackToolId: 'pulse_parser_v2',
}),
params: (params) => {
if (!params || !params.apiKey || params.apiKey.trim() === '') {
throw new Error('Pulse API key is required')
}
const parameters: Record<string, unknown> = {
apiKey: params.apiKey.trim(),
}

View File

@@ -24,6 +24,7 @@ export const ReductoBlock: BlockConfig<ReductoParserOutput> = {
placeholder: 'Upload a PDF document',
mode: 'basic',
maxSize: 50,
required: true,
},
{
id: 'filePath',
@@ -32,6 +33,7 @@ export const ReductoBlock: BlockConfig<ReductoParserOutput> = {
canonicalParamId: 'document',
placeholder: 'Document URL',
mode: 'advanced',
required: true,
},
{
id: 'pages',
@@ -62,19 +64,12 @@ export const ReductoBlock: BlockConfig<ReductoParserOutput> = {
config: {
tool: () => 'reducto_parser',
params: (params) => {
if (!params || !params.apiKey || params.apiKey.trim() === '') {
throw new Error('Reducto API key is required')
}
const parameters: Record<string, unknown> = {
apiKey: params.apiKey.trim(),
}
// document is the canonical param from fileUpload (basic) or filePath (advanced)
const documentInput = params.document
if (!documentInput) {
throw new Error('PDF document is required')
}
if (typeof documentInput === 'object') {
parameters.file = documentInput
@@ -153,6 +148,7 @@ const reductoV2SubBlocks = (ReductoBlock.subBlocks || []).flatMap((subBlock) =>
canonicalParamId: 'document',
placeholder: 'File reference',
mode: 'advanced' as const,
required: true,
},
]
}
@@ -175,10 +171,6 @@ export const ReductoV2Block: BlockConfig<ReductoParserOutput> = {
fallbackToolId: 'reducto_parser_v2',
}),
params: (params) => {
if (!params || !params.apiKey || params.apiKey.trim() === '') {
throw new Error('Reducto API key is required')
}
const parameters: Record<string, unknown> = {
apiKey: params.apiKey.trim(),
}

View File

@@ -92,6 +92,7 @@ export const SlackBlock: BlockConfig<SlackResponse> = {
field: 'authMethod',
value: 'oauth',
},
required: true,
},
{
id: 'botToken',
@@ -104,6 +105,7 @@ export const SlackBlock: BlockConfig<SlackResponse> = {
field: 'authMethod',
value: 'bot_token',
},
required: true,
},
{
id: 'channel',
@@ -124,6 +126,7 @@ export const SlackBlock: BlockConfig<SlackResponse> = {
not: true,
},
},
required: true,
},
{
id: 'manualChannel',
@@ -142,6 +145,7 @@ export const SlackBlock: BlockConfig<SlackResponse> = {
not: true,
},
},
required: true,
},
{
id: 'dmUserId',
@@ -156,6 +160,7 @@ export const SlackBlock: BlockConfig<SlackResponse> = {
field: 'destinationType',
value: 'dm',
},
required: true,
},
{
id: 'manualDmUserId',
@@ -168,6 +173,7 @@ export const SlackBlock: BlockConfig<SlackResponse> = {
field: 'destinationType',
value: 'dm',
},
required: true,
},
{
id: 'text',
@@ -576,17 +582,8 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
const effectiveChannel = channel ? String(channel).trim() : ''
const effectiveUserId = dmUserId ? String(dmUserId).trim() : ''
const noChannelOperations = ['list_channels', 'list_users', 'get_user']
const dmSupportedOperations = ['send', 'read']
if (isDM && dmSupportedOperations.includes(operation)) {
if (!effectiveUserId) {
throw new Error('User is required for DM operations.')
}
} else if (!effectiveChannel && !noChannelOperations.includes(operation)) {
throw new Error('Channel is required.')
}
const baseParams: Record<string, any> = {}
if (isDM && dmSupportedOperations.includes(operation)) {
@@ -597,23 +594,14 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
// Handle authentication based on method
if (authMethod === 'bot_token') {
if (!botToken) {
throw new Error('Bot token is required when using bot token authentication')
}
baseParams.accessToken = botToken
} else {
// Default to OAuth
if (!credential) {
throw new Error('Slack account credential is required when using Sim Bot')
}
baseParams.credential = credential
}
switch (operation) {
case 'send': {
if (!text || text.trim() === '') {
throw new Error('Message text is required for send operation')
}
baseParams.text = text
if (threadTs) {
baseParams.thread_ts = threadTs
@@ -627,9 +615,6 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
}
case 'canvas':
if (!title || !content) {
throw new Error('Title and content are required for canvas operation')
}
baseParams.title = title
baseParams.content = content
break
@@ -647,16 +632,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
}
case 'get_message':
if (!getMessageTimestamp) {
throw new Error('Message timestamp is required for get message operation')
}
baseParams.timestamp = getMessageTimestamp
break
case 'get_thread': {
if (!getThreadTimestamp) {
throw new Error('Thread timestamp is required for get thread operation')
}
baseParams.threadTs = getThreadTimestamp
if (threadLimit) {
const parsedLimit = Number.parseInt(threadLimit, 10)
@@ -686,18 +665,12 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
}
case 'get_user':
if (!userId) {
throw new Error('User ID is required for get user operation')
}
baseParams.userId = userId
break
case 'download': {
const fileId = (rest as any).fileId
const downloadFileName = (rest as any).downloadFileName
if (!fileId) {
throw new Error('File ID is required for download operation')
}
baseParams.fileId = fileId
if (downloadFileName) {
baseParams.fileName = downloadFileName
@@ -706,24 +679,15 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
}
case 'update':
if (!updateTimestamp || !updateText) {
throw new Error('Timestamp and text are required for update operation')
}
baseParams.timestamp = updateTimestamp
baseParams.text = updateText
break
case 'delete':
if (!deleteTimestamp) {
throw new Error('Timestamp is required for delete operation')
}
baseParams.timestamp = deleteTimestamp
break
case 'react':
if (!reactionTimestamp || !emojiName) {
throw new Error('Timestamp and emoji name are required for reaction operation')
}
baseParams.timestamp = reactionTimestamp
baseParams.name = emojiName
break

View File

@@ -177,14 +177,6 @@ export const WebflowBlock: BlockConfig<WebflowResponse> = {
const effectiveCollectionId = collectionId ? String(collectionId).trim() : ''
const effectiveItemId = itemId ? String(itemId).trim() : ''
if (!effectiveSiteId) {
throw new Error('Site ID is required')
}
if (!effectiveCollectionId) {
throw new Error('Collection ID is required')
}
const baseParams = {
credential,
siteId: effectiveSiteId,
@@ -195,9 +187,6 @@ export const WebflowBlock: BlockConfig<WebflowResponse> = {
switch (params.operation) {
case 'create':
case 'update':
if (params.operation === 'update' && !effectiveItemId) {
throw new Error('Item ID is required for update operation')
}
return {
...baseParams,
itemId: effectiveItemId || undefined,
@@ -205,9 +194,6 @@ export const WebflowBlock: BlockConfig<WebflowResponse> = {
}
case 'get':
case 'delete':
if (!effectiveItemId) {
throw new Error(`Item ID is required for ${params.operation} operation`)
}
return { ...baseParams, itemId: effectiveItemId }
default:
return baseParams