Skip to content

Commit 494cb8a

Browse files
committed
refactor: simplify and clean up the sweep changes
1 parent ab98fd2 commit 494cb8a

6 files changed

Lines changed: 114 additions & 119 deletions

File tree

‎apps/sim/blocks/blocks/cloudflare.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4523,7 +4523,7 @@ export const CloudflareBlock: BlockConfig = {
45234523
tool: (params) => `cloudflare_${params.operation}`,
45244524
params: (params, context) => {
45254525
const result = { ...params }
4526-
const operation = mapperOperation(params, context) ?? ''
4526+
const operation = mapperOperation(params, context)
45274527
const toolCall = isToolCall(context)
45284528
for (const [toolParam, aliasId] of Object.entries(SUBBLOCK_ALIASES[operation] ?? {})) {
45294529
const aliasValue = result[aliasId]

‎apps/sim/blocks/blocks/cloudtrail.ts‎

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -428,47 +428,46 @@ Return ONLY the SQL query — no explanations, no markdown code blocks.`,
428428
}
429429
},
430430
params: (params, context) => {
431-
const rest = params
432431
const operation = mapperOperation(params, context)
433432

434-
const awsRegion = rest.awsRegion
435-
const awsAccessKeyId = rest.awsAccessKeyId
436-
const awsSecretAccessKey = rest.awsSecretAccessKey
433+
const awsRegion = params.awsRegion
434+
const awsAccessKeyId = params.awsAccessKeyId
435+
const awsSecretAccessKey = params.awsSecretAccessKey
437436
const credentials = { awsRegion, awsAccessKeyId, awsSecretAccessKey }
438437

439438
switch (operation) {
440439
case 'lookup_events': {
441-
const maxResults = parseBoundedInt(rest.lookupMaxResults)
442-
if (Boolean(rest.attributeKey) !== Boolean(rest.attributeValue)) {
440+
const maxResults = parseBoundedInt(params.lookupMaxResults)
441+
if (Boolean(params.attributeKey) !== Boolean(params.attributeValue)) {
443442
throw new Error('Provide both a filter attribute and a filter value, or neither')
444443
}
445444
return {
446445
...credentials,
447-
...(rest.attributeKey && {
448-
attributeKey: rest.attributeKey,
449-
attributeValue: rest.attributeValue,
446+
...(params.attributeKey && {
447+
attributeKey: params.attributeKey,
448+
attributeValue: params.attributeValue,
450449
}),
451-
...(rest.startTime && { startTime: rest.startTime }),
452-
...(rest.endTime && { endTime: rest.endTime }),
453-
...(rest.eventCategory === 'insight' && { eventCategory: 'insight' }),
450+
...(params.startTime && { startTime: params.startTime }),
451+
...(params.endTime && { endTime: params.endTime }),
452+
...(params.eventCategory === 'insight' && { eventCategory: 'insight' }),
454453
...(maxResults !== undefined && { maxResults }),
455-
...(rest.nextToken && { nextToken: rest.nextToken }),
454+
...(params.nextToken && { nextToken: params.nextToken }),
456455
}
457456
}
458457

459458
case 'describe_trails':
460459
return {
461460
...credentials,
462-
...(rest.trailNameList && { trailNameList: rest.trailNameList }),
463-
...(rest.includeShadowTrails !== undefined &&
464-
rest.includeShadowTrails !== '' && {
465-
includeShadowTrails: String(rest.includeShadowTrails) !== 'false',
461+
...(params.trailNameList && { trailNameList: params.trailNameList }),
462+
...(params.includeShadowTrails !== undefined &&
463+
params.includeShadowTrails !== '' && {
464+
includeShadowTrails: String(params.includeShadowTrails) !== 'false',
466465
}),
467466
}
468467

469468
case 'get_trail':
470469
case 'get_trail_status': {
471-
const name = rest.trailName || toolCallArg(context, rest.name)
470+
const name = params.trailName || toolCallArg(context, params.name)
472471
if (!name) {
473472
throw new Error('Trail name or ARN is required')
474473
}
@@ -478,107 +477,107 @@ Return ONLY the SQL query — no explanations, no markdown code blocks.`,
478477
case 'list_trails':
479478
return {
480479
...credentials,
481-
...(rest.nextToken && { nextToken: rest.nextToken }),
480+
...(params.nextToken && { nextToken: params.nextToken }),
482481
}
483482

484483
case 'get_event_selectors':
485-
if (!rest.trailName) {
484+
if (!params.trailName) {
486485
throw new Error('Trail name or ARN is required')
487486
}
488-
return { ...credentials, trailName: rest.trailName }
487+
return { ...credentials, trailName: params.trailName }
489488

490489
case 'get_insight_selectors':
491-
if (Boolean(rest.trailName) === Boolean(rest.eventDataStore)) {
490+
if (Boolean(params.trailName) === Boolean(params.eventDataStore)) {
492491
throw new Error(
493492
'Specify exactly one of trail name or event data store for Insights selectors'
494493
)
495494
}
496495
return {
497496
...credentials,
498-
...(rest.trailName && { trailName: rest.trailName }),
499-
...(rest.eventDataStore && { eventDataStore: rest.eventDataStore }),
497+
...(params.trailName && { trailName: params.trailName }),
498+
...(params.eventDataStore && { eventDataStore: params.eventDataStore }),
500499
}
501500

502501
case 'start_query':
503-
if (Boolean(rest.queryStatement) === Boolean(rest.queryAlias)) {
502+
if (Boolean(params.queryStatement) === Boolean(params.queryAlias)) {
504503
throw new Error('Specify exactly one of Lake SQL query or query template alias')
505504
}
506505
return {
507506
...credentials,
508-
...(rest.queryStatement && { queryStatement: rest.queryStatement }),
509-
...(rest.queryAlias && { queryAlias: rest.queryAlias }),
510-
...(rest.queryParameters && { queryParameters: rest.queryParameters }),
511-
...(rest.deliveryS3Uri && { deliveryS3Uri: rest.deliveryS3Uri }),
512-
...(rest.eventDataStoreOwnerAccountId && {
513-
eventDataStoreOwnerAccountId: rest.eventDataStoreOwnerAccountId,
507+
...(params.queryStatement && { queryStatement: params.queryStatement }),
508+
...(params.queryAlias && { queryAlias: params.queryAlias }),
509+
...(params.queryParameters && { queryParameters: params.queryParameters }),
510+
...(params.deliveryS3Uri && { deliveryS3Uri: params.deliveryS3Uri }),
511+
...(params.eventDataStoreOwnerAccountId && {
512+
eventDataStoreOwnerAccountId: params.eventDataStoreOwnerAccountId,
514513
}),
515514
}
516515

517516
case 'describe_query':
518-
if (Boolean(rest.queryId) === Boolean(rest.queryAlias)) {
517+
if (Boolean(params.queryId) === Boolean(params.queryAlias)) {
519518
throw new Error('Specify exactly one of query ID or query template alias')
520519
}
521520
return {
522521
...credentials,
523-
...(rest.queryId && { queryId: rest.queryId }),
524-
...(rest.queryAlias && { queryAlias: rest.queryAlias }),
525-
...(rest.refreshId && { refreshId: rest.refreshId }),
526-
...(rest.eventDataStoreOwnerAccountId && {
527-
eventDataStoreOwnerAccountId: rest.eventDataStoreOwnerAccountId,
522+
...(params.queryId && { queryId: params.queryId }),
523+
...(params.queryAlias && { queryAlias: params.queryAlias }),
524+
...(params.refreshId && { refreshId: params.refreshId }),
525+
...(params.eventDataStoreOwnerAccountId && {
526+
eventDataStoreOwnerAccountId: params.eventDataStoreOwnerAccountId,
528527
}),
529528
}
530529

531530
case 'get_query_results': {
532-
if (!rest.queryId) {
531+
if (!params.queryId) {
533532
throw new Error('Query ID is required')
534533
}
535-
const maxQueryResults = parseBoundedInt(rest.maxQueryResults)
534+
const maxQueryResults = parseBoundedInt(params.maxQueryResults)
536535
return {
537536
...credentials,
538-
queryId: rest.queryId,
537+
queryId: params.queryId,
539538
...(maxQueryResults !== undefined && { maxQueryResults }),
540-
...(rest.nextToken && { nextToken: rest.nextToken }),
541-
...(rest.eventDataStoreOwnerAccountId && {
542-
eventDataStoreOwnerAccountId: rest.eventDataStoreOwnerAccountId,
539+
...(params.nextToken && { nextToken: params.nextToken }),
540+
...(params.eventDataStoreOwnerAccountId && {
541+
eventDataStoreOwnerAccountId: params.eventDataStoreOwnerAccountId,
543542
}),
544543
}
545544
}
546545

547546
case 'cancel_query':
548-
if (!rest.queryId) {
547+
if (!params.queryId) {
549548
throw new Error('Query ID is required')
550549
}
551550
return {
552551
...credentials,
553-
queryId: rest.queryId,
554-
...(rest.eventDataStoreOwnerAccountId && {
555-
eventDataStoreOwnerAccountId: rest.eventDataStoreOwnerAccountId,
552+
queryId: params.queryId,
553+
...(params.eventDataStoreOwnerAccountId && {
554+
eventDataStoreOwnerAccountId: params.eventDataStoreOwnerAccountId,
556555
}),
557556
}
558557

559558
case 'list_event_data_stores': {
560-
const maxResults = parseBoundedInt(rest.eventDataStoreMaxResults)
559+
const maxResults = parseBoundedInt(params.eventDataStoreMaxResults)
561560
return {
562561
...credentials,
563562
...(maxResults !== undefined && { maxResults }),
564-
...(rest.nextToken && { nextToken: rest.nextToken }),
563+
...(params.nextToken && { nextToken: params.nextToken }),
565564
}
566565
}
567566

568567
case 'get_event_data_store':
569-
if (!rest.eventDataStore) {
568+
if (!params.eventDataStore) {
570569
throw new Error('Event data store ARN or ID is required')
571570
}
572-
return { ...credentials, eventDataStore: rest.eventDataStore }
571+
return { ...credentials, eventDataStore: params.eventDataStore }
573572

574573
case 'list_tags':
575-
if (!rest.resourceIdList) {
574+
if (!params.resourceIdList) {
576575
throw new Error('At least one resource ARN is required')
577576
}
578577
return {
579578
...credentials,
580-
resourceIdList: rest.resourceIdList,
581-
...(rest.nextToken && { nextToken: rest.nextToken }),
579+
resourceIdList: params.resourceIdList,
580+
...(params.nextToken && { nextToken: params.nextToken }),
582581
}
583582

584583
default:

‎apps/sim/blocks/blocks/daytona.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ export const DaytonaBlock: BlockConfig = {
463463

464464
const baseParams: Record<string, unknown> = { apiKey }
465465

466-
if (operation && SANDBOX_SCOPED_OPERATIONS.includes(operation)) {
466+
if (SANDBOX_SCOPED_OPERATIONS.includes(operation)) {
467467
baseParams.sandboxId = rest.sandboxId
468468
}
469469

‎apps/sim/blocks/blocks/fivetran.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ export const FivetranBlock: BlockConfig = {
10611061
},
10621062
params: (params, context) => {
10631063
const result: Record<string, unknown> = {}
1064-
const operation = mapperOperation(params, context) ?? ''
1064+
const operation = mapperOperation(params, context)
10651065
const isConnectionSettings = (CONNECTION_SETTINGS_OPS as readonly string[]).includes(
10661066
operation
10671067
)

0 commit comments

Comments
 (0)