Skip to content

Commit cff2bdc

Browse files
committed
fix(cloudflare): preserve inputs and outputs across expanded operations
1 parent b2ecf17 commit cff2bdc

42 files changed

Lines changed: 7523 additions & 7837 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/docs/content/docs/integrations/cloudflare.mdx‎

Lines changed: 7002 additions & 7407 deletions
Large diffs are not rendered by default.

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

Lines changed: 33 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ const SUBBLOCK_ALIASES: Record<string, Record<string, string>> = {
108108
header_bg_color: 'accessApplicationHeaderBgColor',
109109
landing_page_design: 'accessApplicationLandingPageDesign',
110110
skip_app_launcher_login_page: 'accessApplicationSkipAppLauncherLoginPage',
111-
saasApp: 'accessApplicationSaasapp',
112-
targetCriteria: 'accessApplicationTargetcriteria',
113111
},
114112
update_access_application: {
115113
type: 'updateAppType',
@@ -142,8 +140,6 @@ const SUBBLOCK_ALIASES: Record<string, Record<string, string>> = {
142140
header_bg_color: 'accessApplicationHeaderBgColor',
143141
landing_page_design: 'accessApplicationLandingPageDesign',
144142
skip_app_launcher_login_page: 'accessApplicationSkipAppLauncherLoginPage',
145-
saasApp: 'accessApplicationSaasapp',
146-
targetCriteria: 'accessApplicationTargetcriteria',
147143
},
148144
update_access_policy: {
149145
decision: 'updatePolicyDecision',
@@ -236,7 +232,7 @@ const SUBBLOCK_ALIASES: Record<string, Record<string, string>> = {
236232
update_zone: {
237233
paused: 'zonePaused',
238234
plan: 'zonePlan',
239-
type: 'zoneType',
235+
type: 'updateZoneType',
240236
vanity_name_servers: 'zoneVanityNameServers',
241237
},
242238
}
@@ -821,7 +817,22 @@ export const CloudflareBlock: BlockConfig = {
821817
{ label: 'Internal DNS', id: 'internal' },
822818
],
823819
value: () => 'full',
824-
condition: { field: 'operation', value: ['create_zone', 'update_zone'] },
820+
condition: { field: 'operation', value: 'create_zone' },
821+
mode: 'advanced',
822+
},
823+
{
824+
id: 'updateZoneType',
825+
title: 'Zone Type',
826+
type: 'dropdown',
827+
options: [
828+
{ label: 'Unchanged', id: '' },
829+
{ label: 'Full (Cloudflare DNS)', id: 'full' },
830+
{ label: 'Partial (CNAME Setup)', id: 'partial' },
831+
{ label: 'Secondary (Secondary DNS)', id: 'secondary' },
832+
{ label: 'Internal DNS', id: 'internal' },
833+
],
834+
value: () => '',
835+
condition: { field: 'operation', value: 'update_zone' },
825836
mode: 'advanced',
826837
},
827838
{
@@ -3192,42 +3203,6 @@ export const CloudflareBlock: BlockConfig = {
31923203
],
31933204
value: () => '',
31943205
},
3195-
{
3196-
id: 'accessApplicationSaasapp',
3197-
title: 'Saas App',
3198-
type: 'short-input',
3199-
placeholder: 'Enter saas app',
3200-
condition: {
3201-
field: 'operation',
3202-
value: ['create_access_application', 'update_access_application'],
3203-
},
3204-
required: false,
3205-
mode: 'advanced',
3206-
wandConfig: {
3207-
enabled: true,
3208-
prompt:
3209-
'Generate the Cloudflare saas app value. JSON SaaS configuration, required for the saas type and rejected on every other type. SAML, e.g. { "auth_type": "saml", "consumer_service_url": "https://example.com/acs", "sp_entity_id": "https://example.com" }; OIDC, e.g. { "auth_type": "oidc", "client_id": "...", "redirect_uris": [ "https://example.com/callback" ] } Return ONLY the value.',
3210-
placeholder: 'Describe the saas app',
3211-
},
3212-
},
3213-
{
3214-
id: 'accessApplicationTargetcriteria',
3215-
title: 'Target Criteria',
3216-
type: 'short-input',
3217-
placeholder: 'Enter target criteria',
3218-
condition: {
3219-
field: 'operation',
3220-
value: ['create_access_application', 'update_access_application'],
3221-
},
3222-
required: false,
3223-
mode: 'advanced',
3224-
wandConfig: {
3225-
enabled: true,
3226-
prompt:
3227-
'Generate the Cloudflare target criteria value. JSON array of infrastructure target criteria, required for the infrastructure and rdp types and rejected on every other type, e.g. [{"port":22,"protocol":"SSH","target_attributes":{"hostname":["production"]}}] Return ONLY the value.',
3228-
placeholder: 'Describe the target criteria',
3229-
},
3230-
},
32313206
{
32323207
id: 'accessGroupExclude',
32333208
title: 'Exclude',
@@ -4734,6 +4709,10 @@ export const CloudflareBlock: BlockConfig = {
47344709
apiKey: { type: 'string', description: 'Cloudflare API token' },
47354710
zoneId: { type: 'string', description: 'Zone ID' },
47364711
accountId: { type: 'string', description: 'Cloudflare account ID' },
4712+
updateZoneType: {
4713+
type: 'string',
4714+
description: 'New zone type; leave unchanged to update another property',
4715+
},
47374716
zoneType: {
47384717
type: 'string',
47394718
description:
@@ -5088,16 +5067,6 @@ export const CloudflareBlock: BlockConfig = {
50885067
type: 'boolean',
50895068
description: 'Determines when to skip the App Launcher landing page.',
50905069
},
5091-
accessApplicationSaasapp: {
5092-
type: 'string',
5093-
description:
5094-
'JSON SaaS configuration, required for the saas type and rejected on every other type. SAML, e.g. { "auth_type": "saml", "consumer_service_url": "https://example.com/acs", "sp_entity_id": "https://example.com" }; OIDC, e.g. { "auth_type": "oidc", "client_id": "...", "redirect_uris": [ "https://example.com/callback" ] }',
5095-
},
5096-
accessApplicationTargetcriteria: {
5097-
type: 'string',
5098-
description:
5099-
'JSON array of infrastructure target criteria, required for the infrastructure and rdp types and rejected on every other type, e.g. [{"port":22,"protocol":"SSH","target_attributes":{"hostname":["production"]}}]',
5100-
},
51015070
accessGroupExclude: {
51025071
type: 'json',
51035072
description:
@@ -5438,6 +5407,18 @@ export const CloudflareBlock: BlockConfig = {
54385407
},
54395408
},
54405409
outputs: {
5410+
zone_id: {
5411+
type: 'string',
5412+
description: 'Legacy DNS response zone ID when returned by Cloudflare',
5413+
},
5414+
zone_name: {
5415+
type: 'string',
5416+
description: 'Legacy DNS response zone name when returned by Cloudflare',
5417+
},
5418+
locked: {
5419+
type: 'boolean',
5420+
description: 'Legacy DNS response lock flag when returned by Cloudflare',
5421+
},
54415422
zones: { type: 'json', description: 'List of zones/domains' },
54425423
records: { type: 'json', description: 'List of DNS records' },
54435424
certificates: { type: 'json', description: 'List of SSL/TLS certificate packs' },

‎apps/sim/tools/cloudflare/cloudflare.test.ts‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,3 +1073,47 @@ describe('list transforms survive a non-array result', () => {
10731073
expect(out.output[key]).toEqual([])
10741074
})
10751075
})
1076+
1077+
describe('Cloudflare review regressions', () => {
1078+
it.each(['create_access_application', 'update_access_application'])(
1079+
'preserves existing SaaS and target inputs through %s request mapping',
1080+
(operation) => {
1081+
const tool =
1082+
operation === 'create_access_application'
1083+
? cloudflareTools.cloudflareCreateAccessApplicationTool
1084+
: cloudflareTools.cloudflareUpdateAccessApplicationTool
1085+
const saasApp = { auth_type: 'saml', consumer_service_url: 'https://example.com/acs' }
1086+
const targetCriteria = [
1087+
{ port: 22, protocol: 'SSH', target_attributes: { hostname: ['example'] } },
1088+
]
1089+
const mapped = mapFor(operation, {
1090+
saasApp: JSON.stringify(saasApp),
1091+
targetCriteria: JSON.stringify(targetCriteria),
1092+
})
1093+
expect(tool.request.body?.(mapped as never)).toMatchObject({
1094+
saas_app: saasApp,
1095+
target_criteria: targetCriteria,
1096+
})
1097+
}
1098+
)
1099+
1100+
it('keeps a pause-only zone update limited to that setting', () => {
1101+
const mapped = mapFor('update_zone', { zoneId: 'zone', zonePaused: 'true' })
1102+
const body = cloudflareTools.cloudflareUpdateZoneTool.request.body?.(mapped as never)
1103+
expect(body).toEqual({ paused: true })
1104+
})
1105+
1106+
it.each([true, false])('returns the ssl_recommender enabled value %s', async (enabled) => {
1107+
const transform = cloudflareTools.cloudflareUpdateZoneSettingTool.transformResponse
1108+
if (!transform) throw new Error('Expected response transform')
1109+
const result = await transform(
1110+
new Response(
1111+
JSON.stringify({
1112+
success: true,
1113+
result: { id: 'ssl_recommender', enabled },
1114+
})
1115+
)
1116+
)
1117+
expect(result.output.value).toBe(String(enabled))
1118+
})
1119+
})

‎apps/sim/tools/cloudflare/create_rate_limit_rule.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
appendParam,
99
cloudflareErrorMessage,
1010
cloudflareHeaders,
11-
mapCloudflareFields,
11+
mapCloudflareRuleset,
1212
parseCsvParam,
1313
parseJsonObjectParam,
1414
readCloudflareResponse,
@@ -240,7 +240,7 @@ export const createRateLimitRuleTool: ToolConfig<
240240
(isRecordLike(data.result) || (params?.dry_run === true && data.result === null))
241241
return {
242242
success,
243-
output: mapCloudflareFields(data.result, RULESET_OUTPUTS),
243+
output: mapCloudflareRuleset(data.result),
244244
...(!success
245245
? { error: cloudflareErrorMessage(data, 'Failed to create rate limit rule') }
246246
: {}),

‎apps/sim/tools/cloudflare/create_ruleset.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
appendParam,
99
cloudflareErrorMessage,
1010
cloudflareHeaders,
11-
mapCloudflareFields,
11+
mapCloudflareRuleset,
1212
parseJsonArrayParam,
1313
readCloudflareResponse,
1414
} from '@/tools/cloudflare/utils'
@@ -112,7 +112,7 @@ export const createRulesetTool: ToolConfig<
112112
(isRecordLike(data.result) || (params?.dry_run === true && data.result === null))
113113
return {
114114
success,
115-
output: mapCloudflareFields(data.result, RULESET_OUTPUTS),
115+
output: mapCloudflareRuleset(data.result),
116116
...(!success ? { error: cloudflareErrorMessage(data, 'Failed to create ruleset') } : {}),
117117
}
118118
},

‎apps/sim/tools/cloudflare/create_ruleset_rule.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
appendParam,
99
cloudflareErrorMessage,
1010
cloudflareHeaders,
11-
mapCloudflareFields,
11+
mapCloudflareRuleset,
1212
parseJsonObjectParam,
1313
readCloudflareResponse,
1414
} from '@/tools/cloudflare/utils'
@@ -172,7 +172,7 @@ export const createRulesetRuleTool: ToolConfig<
172172
(isRecordLike(data.result) || (params?.dry_run === true && data.result === null))
173173
return {
174174
success,
175-
output: mapCloudflareFields(data.result, RULESET_OUTPUTS),
175+
output: mapCloudflareRuleset(data.result),
176176
...(!success ? { error: cloudflareErrorMessage(data, 'Failed to create ruleset rule') } : {}),
177177
}
178178
},

‎apps/sim/tools/cloudflare/create_zone.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const createZoneTool: ToolConfig<CloudflareCreateZoneParams, CloudflareCr
3636
required: false,
3737
visibility: 'user-or-llm',
3838
description:
39-
'Zone type: "full" (Cloudflare manages DNS), "partial" (CNAME setup), or "secondary" (secondary DNS). or "internal" for an internal DNS zone',
39+
'Zone type: "full" (Cloudflare manages DNS), "partial" (CNAME setup), "secondary" (secondary DNS), or "internal" (internal DNS zone)',
4040
},
4141
apiKey: {
4242
type: 'string',

‎apps/sim/tools/cloudflare/delete_access_group.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ export const deleteAccessGroupTool: ToolConfig<
5252
return {
5353
success,
5454
output: mapCloudflareFields(data.result, {
55-
id: { type: 'string', description: 'UUID.' },
55+
id: { type: 'string', nullable: true, description: 'UUID.' },
5656
} as const),
5757
...(!success ? { error: cloudflareErrorMessage(data, 'Failed to delete access group') } : {}),
5858
}
5959
},
60-
outputs: { id: { type: 'string', description: 'UUID.' } },
60+
outputs: { id: { type: 'string', nullable: true, description: 'UUID.' } },
6161
}

‎apps/sim/tools/cloudflare/delete_ruleset_rule.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
appendParam,
99
cloudflareErrorMessage,
1010
cloudflareHeaders,
11-
mapCloudflareFields,
11+
mapCloudflareRuleset,
1212
readCloudflareResponse,
1313
} from '@/tools/cloudflare/utils'
1414
import type { ToolConfig } from '@/tools/types'
@@ -77,7 +77,7 @@ export const deleteRulesetRuleTool: ToolConfig<
7777
(isRecordLike(data.result) || (params?.dry_run === true && data.result === null))
7878
return {
7979
success,
80-
output: mapCloudflareFields(data.result, RULESET_OUTPUTS),
80+
output: mapCloudflareRuleset(data.result),
8181
...(!success ? { error: cloudflareErrorMessage(data, 'Failed to delete ruleset rule') } : {}),
8282
}
8383
},

‎apps/sim/tools/cloudflare/delete_worker_route.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ export const deleteWorkerRouteTool: ToolConfig<
5252
return {
5353
success,
5454
output: mapCloudflareFields(data.result, {
55-
id: { type: 'string', description: 'Identifier.' },
55+
id: { type: 'string', nullable: true, description: 'Identifier.' },
5656
} as const),
5757
...(!success ? { error: cloudflareErrorMessage(data, 'Failed to delete worker route') } : {}),
5858
}
5959
},
60-
outputs: { id: { type: 'string', description: 'Identifier.' } },
60+
outputs: { id: { type: 'string', nullable: true, description: 'Identifier.' } },
6161
}

0 commit comments

Comments
 (0)