Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/docs/content/docs/integrations/ketch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ Retrieve consent status for a data subject. Returns the current consent preferen
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `purposes` | object | Map of purpose codes to consent status and legal basis |
| ↳ `allowed` | string | Consent status for the purpose: "granted" or "denied" |
| ↳ `allowed` | string | Consent status for the purpose: "true" or "false" |
| ↳ `legalBasisCode` | string | Legal basis code \(e.g., "consent_optin", "consent_optout", "disclosure", "other"\) |
| `vendors` | object | Map of vendor consent statuses |
| `vendors` | array | TCF vendor IDs returned with the consent record |

</ReferenceDetails>

Expand All @@ -64,15 +64,15 @@ Update consent preferences for a data subject. Sets the consent status for speci
| `environmentCode` | string | Yes | Environment code defined in Ketch \(e.g., "production"\) |
| `jurisdictionCode` | string | No | Jurisdiction code \(e.g., "gdpr", "ccpa"\) |
| `identities` | json | Yes | Identity map \(e.g., \{"email": "user@example.com"\}\) |
| `purposes` | json | Yes | Map of purpose codes to consent settings \(e.g., \{"analytics": \{"allowed": "granted", "legalBasisCode": "consent_optin"\}\}\) |
| `purposes` | json | Yes | Map of purpose codes to consent settings. "allowed" is "true" or "false" \("granted"/"denied" are accepted and converted\) \(e.g., \{"analytics": \{"allowed": "true", "legalBasisCode": "consent_optin"\}\}\) |
| `collectedAt` | number | No | UNIX timestamp when consent was collected \(defaults to current time\) |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `purposes` | object | Updated consent status map of purpose codes to consent settings |
| ↳ `allowed` | string | Consent status for the purpose: "granted" or "denied" |
| ↳ `allowed` | string | Consent status for the purpose: "true" or "false" |
| ↳ `legalBasisCode` | string | Legal basis code \(e.g., "consent_optin", "consent_optout", "disclosure", "other"\) |

</ReferenceDetails>
Expand Down Expand Up @@ -142,7 +142,7 @@ Submit a data subject rights request (e.g., access, delete, correct, restrict pr
| `jurisdictionCode` | string | Yes | Jurisdiction code \(e.g., "gdpr", "ccpa"\) |
| `rightCode` | string | Yes | Privacy right code to invoke \(e.g., "access", "delete", "correct", "restrict_processing"\) |
| `identities` | json | Yes | Identity map \(e.g., \{"email": "user@example.com"\}\) |
| `userData` | json | No | Optional data subject information \(e.g., \{"email": "user@example.com", "firstName": "John", "lastName": "Doe"\}\) |
| `userData` | json | Yes | Data subject information sent as the request "user"; Ketch requires it for rights requests \(e.g., \{"email": "user@example.com", "firstName": "John", "lastName": "Doe"\}\) |

#### Output

Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/integrations/onepassword.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ List all vaults accessible by the Connect token or Service Account
| ↳ `attributeVersion` | number | Vault attribute version |
| ↳ `contentVersion` | number | Vault content version |
| ↳ `items` | number | Number of items in the vault |
| ↳ `type` | string | Vault type \(USER_CREATED, PERSONAL, or EVERYONE\) |
| ↳ `type` | string | Vault type \(USER_CREATED, PERSONAL, EVERYONE, or TRANSFER\) |
| ↳ `createdAt` | string | Creation timestamp |
| ↳ `updatedAt` | string | Last update timestamp |

Expand Down Expand Up @@ -78,7 +78,7 @@ Get details of a specific vault by ID
| `attributeVersion` | number | Vault attribute version |
| `contentVersion` | number | Vault content version |
| `items` | number | Number of items in the vault |
| `type` | string | Vault type \(USER_CREATED, PERSONAL, or EVERYONE\) |
| `type` | string | Vault type \(USER_CREATED, PERSONAL, EVERYONE, or TRANSFER\) |
| `createdAt` | string | Creation timestamp |
| `updatedAt` | string | Last update timestamp |

Expand Down
64 changes: 64 additions & 0 deletions apps/sim/blocks/blocks/clerk.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { describe, expect, it } from 'vitest'
import { ClerkBlock } from '@/blocks/blocks/clerk'
import { clerkListUsersTool } from '@/tools/clerk/list_users'
import type { ClerkListUsersParams } from '@/tools/clerk/types'

/**
* A tool call merges the stored row with the model's args (keyed by tool param names) and spreads
Expand All @@ -10,6 +12,31 @@ const toolCall = (args: Record<string, unknown>, operation: string) => ({
...ClerkBlock.tools.config?.params?.(args, { operation }),
})

/**
* The canvas executor spreads the mapper result over the block's serialized inputs and passes no
* context. Serialized inputs keep non-empty advanced values saved under another operation.
*/
const canvasCall = (inputs: Record<string, unknown>) => ({
...inputs,
...ClerkBlock.tools.config?.params?.(inputs),
})

const stringParam = (value: unknown) => (typeof value === 'string' ? value : undefined)

const listUsersUrl = (params: Record<string, unknown>) => {
const url = clerkListUsersTool.request.url
if (typeof url !== 'function') throw new Error('expected a URL builder')
const toolParams: ClerkListUsersParams = {
secretKey: 'sk',
emailAddress: stringParam(params.emailAddress),
phoneNumber: stringParam(params.phoneNumber),
externalId: stringParam(params.externalId),
username: stringParam(params.username),
userId: stringParam(params.userId),
}
return new URL(url(toolParams)).searchParams
}

describe('ClerkBlock tool calls', () => {
it('parses metadata the model sends as a JSON string', () => {
const params = toolCall(
Expand All @@ -19,4 +46,41 @@ describe('ClerkBlock tool calls', () => {
expect(params.publicMetadata).toEqual({ plan: 'pro' })
expect(params.emailAddress).toEqual(['a@example.com'])
})

it('keeps the filters the model sends to List Users', () => {
const query = listUsersUrl(
toolCall({ secretKey: 'sk', username: 'alice', externalId: 'ext_1' }, 'clerk_list_users')
)
expect(query.getAll('username')).toEqual(['alice'])
expect(query.getAll('external_id')).toEqual(['ext_1'])
})
})

describe('ClerkBlock canvas List Users', () => {
const staleCreateUserInputs = {
secretKey: 'sk',
username: 'stale-bob',
externalId: 'stale-ext',
phoneNumber: '+15550000000',
}

it('does not filter by values saved under Create or Update User', () => {
const query = listUsersUrl(
canvasCall({ ...staleCreateUserInputs, operation: 'clerk_list_users' })
)
expect(query.has('username')).toBe(false)
expect(query.has('external_id')).toBe(false)
expect(query.has('phone_number')).toBe(false)
})

it('filters by the List Users filter fields over stale same-named values', () => {
const query = listUsersUrl(
canvasCall({
...staleCreateUserInputs,
operation: 'clerk_list_users',
usernameFilter: 'alice',
})
)
expect(query.getAll('username')).toEqual(['alice'])
})
})
19 changes: 11 additions & 8 deletions apps/sim/blocks/blocks/clerk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ClerkIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { mapperOperation, withSavedCredential } from '@/blocks/utils'
import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils'
import { getTrigger } from '@/triggers'

/**
Expand Down Expand Up @@ -849,13 +849,6 @@ export const ClerkBlock: BlockConfig = {

// Map UI fields to API params based on operation
switch (operation) {
case 'clerk_list_users':
if (emailAddressFilter) cleanParams.emailAddress = emailAddressFilter
if (usernameFilter) cleanParams.username = usernameFilter
if (phoneNumberFilter) cleanParams.phoneNumber = phoneNumberFilter
if (externalIdFilter) cleanParams.externalId = externalIdFilter
if (userIdFilter) cleanParams.userId = userIdFilter
break
case 'clerk_create_user':
case 'clerk_update_user':
case 'clerk_create_organization_invitation':
Expand Down Expand Up @@ -919,6 +912,16 @@ export const ClerkBlock: BlockConfig = {
}
})

// List Users filters have dedicated subBlocks. The same-named raw keys can hold Create/Update
// User values, so on the canvas they are cleared rather than forwarded as filters.
if (operation === 'clerk_list_users') {
cleanParams.emailAddress = emailAddressFilter || toolCallArg(context, rest.emailAddress)
cleanParams.username = usernameFilter || toolCallArg(context, rest.username)
cleanParams.phoneNumber = phoneNumberFilter || toolCallArg(context, rest.phoneNumber)
cleanParams.externalId = externalIdFilter || toolCallArg(context, rest.externalId)
cleanParams.userId = userIdFilter || toolCallArg(context, rest.userId)
}

return cleanParams
},
},
Expand Down
19 changes: 19 additions & 0 deletions apps/sim/blocks/blocks/crowdstrike.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@ describe('CrowdStrike block params', () => {
expect(merged.includeHidden).toBe(true)
})

it('sends no status change when the status dropdown keeps the value the editor seeds', () => {
const updateStatus = CrowdStrikeBlock.subBlocks.find(
(subBlock) => subBlock.id === 'updateStatus'
)
const options = typeof updateStatus?.options === 'function' ? [] : (updateStatus?.options ?? [])
const seeded = updateStatus?.value?.({}) ?? options[0]?.id

const merged = merge({
...credentials,
operation: 'crowdstrike_update_alerts',
compositeIds: '["cid:aid:alert"]',
appendComment: 'Reviewed',
updateStatus: seeded,
})

expect(merged.appendComment).toBe('Reviewed')
expect(merged.updateStatus).toBeUndefined()
})

it('still sends false when the analyst turns the hidden-alert switch off', () => {
const merged = merge({
...credentials,
Expand Down
7 changes: 7 additions & 0 deletions apps/sim/blocks/blocks/crowdstrike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,22 @@ export const CrowdStrikeBlock: BlockConfig = {
},
},
{
/**
* Leads with "No change" because the editor seeds an empty dropdown with
* its first option: an update that only comments, tags, or assigns must
* not also send `update_status`.
*/
id: 'updateStatus',
title: 'Status',
type: 'dropdown',
options: [
{ label: 'No change', id: '' },
{ label: 'New', id: 'new' },
{ label: 'In Progress', id: 'in_progress' },
{ label: 'Reopened', id: 'reopened' },
{ label: 'Closed', id: 'closed' },
],
value: () => '',
condition: { field: 'operation', value: 'crowdstrike_update_alerts' },
},
{
Expand Down
5 changes: 5 additions & 0 deletions apps/sim/blocks/blocks/infisical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ export const InfisicalBlock: BlockConfig = {
description:
'Secret object from get/create/update/delete operations (id, secretKey, secretValue, secretComment, secretPath, version, type, environment, isRotatedSecret, rotationId, tags, secretMetadata, actor, createdAt, updatedAt)',
},
approval: {
type: 'json',
description:
'Pending change request (id, policyId, slug, status, hasMerged, folderId, createdAt, updatedAt) returned by create/update/delete instead of the secret when the environment has a secret approval policy',
},
},
}

Expand Down
67 changes: 67 additions & 0 deletions apps/sim/blocks/blocks/ketch.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { describe, expect, it } from 'vitest'
import { KetchBlock } from '@/blocks/blocks/ketch'
import { invokeRightTool } from '@/tools/ketch/invoke_right'
import { setConsentTool } from '@/tools/ketch/set_consent'

const buildParams = KetchBlock.tools.config?.params
if (!buildParams) throw new Error('KetchBlock has no params mapper')
Expand All @@ -22,4 +24,69 @@ describe('KetchBlock', () => {
analytics: { allowed: 'granted' },
})
})

/**
* Ketch records any `allowed` other than the string "true" as denied, so a granted
* consent written as "granted" (the value this integration used to document) must be sent as "true".
*/
it('sends a granted consent as allowed "true"', () => {
const buildBody = setConsentTool.request.body
if (!buildBody) throw new Error('set consent has no body builder')
const body = buildBody({
organizationCode: 'org',
propertyCode: 'web',
environmentCode: 'production',
identities: { email: 'a@example.com' },
purposes: {
analytics: { allowed: 'granted', legalBasisCode: 'consent_optin' },
marketing: { allowed: 'denied', legalBasisCode: 'consent_optin' },
},
collectedAt: 1,
})
if (!body || typeof body === 'string' || body instanceof FormData) {
throw new Error('Expected a JSON body')
}

expect(body.purposes).toEqual({
analytics: { allowed: 'true', legalBasisCode: 'consent_optin' },
marketing: { allowed: 'false', legalBasisCode: 'consent_optin' },
})
})

it('sends an unrecognized allowed value unchanged', () => {
const buildBody = setConsentTool.request.body
if (!buildBody) throw new Error('set consent has no body builder')

const body = buildBody({
organizationCode: 'org',
propertyCode: 'web',
environmentCode: 'production',
identities: { email: 'a@example.com' },
purposes: { analytics: { allowed: 'yes' }, marketing: { allowed: '' } },
})
if (!body || typeof body === 'string' || body instanceof FormData) {
throw new Error('Expected a JSON body')
}

expect(body.purposes).toEqual({ analytics: { allowed: 'yes' }, marketing: { allowed: '' } })
})

it('surfaces the message of a Ketch error envelope', async () => {
const transform = invokeRightTool.transformResponse
if (!transform) throw new Error('invoke right has no response transform')
const response = new Response(
JSON.stringify({
error: {
code: 'invalid',
message: 'user is required for unauthenticated right invocations',
status: 400,
},
}),
{ status: 400 }
)

const result = await transform(response)

expect(result.output.message).toBe('user is required for unauthenticated right invocations')
})
})
6 changes: 3 additions & 3 deletions apps/sim/blocks/blocks/ketch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const KetchBlock: BlockConfig = {
title: 'Purposes',
type: 'code',
placeholder:
'{"analytics": {"allowed": "granted", "legalBasisCode": "consent_optin"}, "marketing": {"allowed": "denied"}}',
'{"analytics": {"allowed": "true", "legalBasisCode": "consent_optin"}, "marketing": {"allowed": "false", "legalBasisCode": "consent_optin"}}',
language: 'json',
condition: { field: 'operation', value: 'set_consent' },
required: { field: 'operation', value: 'set_consent' },
Expand Down Expand Up @@ -160,7 +160,7 @@ export const KetchBlock: BlockConfig = {
placeholder: '{"email": "user@example.com", "firstName": "John", "lastName": "Doe"}',
language: 'json',
condition: { field: 'operation', value: 'invoke_right' },
mode: 'advanced',
required: { field: 'operation', value: 'invoke_right' },
},
{
id: 'collectedAt',
Expand Down Expand Up @@ -256,7 +256,7 @@ export const KetchBlock: BlockConfig = {
},
outputs: {
purposes: { type: 'json', description: 'Consent status per purpose (allowed, legalBasisCode)' },
vendors: { type: 'json', description: 'Vendor consent statuses' },
vendors: { type: 'json', description: 'TCF vendor IDs returned with the consent record' },
topics: {
type: 'json',
description: 'Subscription topic statuses per contact method',
Expand Down
31 changes: 30 additions & 1 deletion apps/sim/lib/internal/onepassword/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ vi.mock('dns/promises', () => ({
}))
vi.mock('@/lib/core/security/input-validation.server', () => inputValidationMock)

import { connectRequest } from '@/lib/internal/onepassword/client'
import type { VaultOverview } from '@1password/sdk'
import { connectRequest, normalizeSdkVault } from '@/lib/internal/onepassword/client'

const { mockSecureFetchWithPinnedIP: mockSecureFetch, mockValidateUrlWithDNS } =
inputValidationMockFns
Expand Down Expand Up @@ -53,3 +54,31 @@ describe('connectRequest', () => {
})
})
})

describe('normalizeSdkVault', () => {
it('maps the service-account vault overview instead of placeholder values', () => {
const vault = {
id: 'vault-1',
title: 'Engineering',
description: 'Shared engineering secrets',
vaultType: 'transfer',
activeItemCount: 12,
contentVersion: 7,
attributeVersion: 3,
createdAt: new Date('2026-01-01T00:00:00Z'),
updatedAt: new Date('2026-02-01T00:00:00Z'),
} as unknown as VaultOverview

expect(normalizeSdkVault(vault)).toEqual({
id: 'vault-1',
name: 'Engineering',
description: 'Shared engineering secrets',
attributeVersion: 3,
contentVersion: 7,
items: 12,
type: 'TRANSFER',
createdAt: '2026-01-01T00:00:00.000Z',
updatedAt: '2026-02-01T00:00:00.000Z',
})
})
})
Loading
Loading