diff --git a/apps/docs/components/icons.tsx b/apps/docs/components/icons.tsx index c31380d81c..53c643f4ba 100644 --- a/apps/docs/components/icons.tsx +++ b/apps/docs/components/icons.tsx @@ -4407,6 +4407,161 @@ export function DatadogIcon(props: SVGProps) { ) } +export function MicrosoftDataverseIcon(props: SVGProps) { + const id = useId() + const clip0 = `dataverse_clip0_${id}` + const clip1 = `dataverse_clip1_${id}` + const clip2 = `dataverse_clip2_${id}` + const paint0 = `dataverse_paint0_${id}` + const paint1 = `dataverse_paint1_${id}` + const paint2 = `dataverse_paint2_${id}` + const paint3 = `dataverse_paint3_${id}` + const paint4 = `dataverse_paint4_${id}` + const paint5 = `dataverse_paint5_${id}` + const paint6 = `dataverse_paint6_${id}` + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) +} + export function KalshiIcon(props: SVGProps) { return ( @@ -5547,3 +5702,18 @@ export function VercelIcon(props: SVGProps) { ) } + +export function CloudflareIcon(props: SVGProps) { + return ( + + + + + ) +} diff --git a/apps/docs/components/ui/icon-mapping.ts b/apps/docs/components/ui/icon-mapping.ts index 171d8461be..492dae71b4 100644 --- a/apps/docs/components/ui/icon-mapping.ts +++ b/apps/docs/components/ui/icon-mapping.ts @@ -19,6 +19,7 @@ import { CirclebackIcon, ClayIcon, ClerkIcon, + CloudflareIcon, ConfluenceIcon, CursorIcon, DatadogIcon, @@ -71,6 +72,7 @@ import { MailgunIcon, MailServerIcon, Mem0Icon, + MicrosoftDataverseIcon, MicrosoftExcelIcon, MicrosoftOneDriveIcon, MicrosoftPlannerIcon, @@ -156,6 +158,7 @@ export const blockTypeToIconMap: Record = { circleback: CirclebackIcon, clay: ClayIcon, clerk: ClerkIcon, + cloudflare: CloudflareIcon, confluence_v2: ConfluenceIcon, cursor_v2: CursorIcon, datadog: DatadogIcon, @@ -209,6 +212,7 @@ export const blockTypeToIconMap: Record = { mailgun: MailgunIcon, mem0: Mem0Icon, memory: BrainIcon, + microsoft_dataverse: MicrosoftDataverseIcon, microsoft_excel_v2: MicrosoftExcelIcon, microsoft_planner: MicrosoftPlannerIcon, microsoft_teams: MicrosoftTeamsIcon, diff --git a/apps/docs/content/docs/en/tools/cloudflare.mdx b/apps/docs/content/docs/en/tools/cloudflare.mdx new file mode 100644 index 0000000000..67c629e071 --- /dev/null +++ b/apps/docs/content/docs/en/tools/cloudflare.mdx @@ -0,0 +1,569 @@ +--- +title: Cloudflare +description: Manage DNS, domains, certificates, and cache +--- + +import { BlockInfoCard } from "@/components/ui/block-info-card" + + + +{/* MANUAL-CONTENT-START:intro */} +[Cloudflare](https://cloudflare.com/) is a global cloud platform that provides content delivery, domain management, cybersecurity, and performance services for websites and applications. + +In Sim, the Cloudflare integration empowers your agents to automate the management of DNS records, SSL/TLS certificates, domains (zones), cache, zone settings, and more through easy-to-use API tools. Agents can securely list and edit domains, update DNS records, monitor analytics, and manage security and performance—all as part of your automated workflows. + +With Cloudflare, you can: + +- **Manage DNS and Domains**: List all your domains (zones), view zone details, and fully control DNS records from your automated agent workflows. +- **Handle SSL/TLS Certificates and Settings**: Issue, renew, or list certificates and adjust security and performance settings for your sites. +- **Purge Cache and Analyze Traffic**: Instantly purge edge cache and review real-time DNS analytics directly within your Sim agent processes. +- **Automate Security and Operations**: Use agents to programmatically manage zones, update settings, and streamline repetitive Cloudflare tasks. + +This integration enables streamlined, secure management of your site's infrastructure from within Sim. Your agents can integrate Cloudflare operations directly into processes—keeping DNS records up-to-date, responding to security events, improving site performance, and automating large-scale site and account administration. +{/* MANUAL-CONTENT-END */} + + +## Usage Instructions + +Integrate Cloudflare into the workflow. Manage zones (domains), DNS records, SSL/TLS certificates, zone settings, DNS analytics, and cache purging via the Cloudflare API. + + + +## Tools + +### `cloudflare_list_zones` + +Lists all zones (domains) in the Cloudflare account. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `name` | string | No | Filter zones by domain name \(e.g., "example.com"\) | +| `status` | string | No | Filter by zone status: "initializing", "pending", "active", or "moved" | +| `page` | number | No | Page number for pagination \(default: 1\) | +| `per_page` | number | No | Number of zones per page \(default: 20, max: 50\) | +| `accountId` | string | No | Filter zones by account ID | +| `order` | string | No | Sort field \(name, status, account.id, account.name\) | +| `direction` | string | No | Sort direction \(asc, desc\) | +| `match` | string | No | Match logic for filters \(any, all\). Default: all | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `zones` | array | List of zones/domains | +| ↳ `id` | string | Zone ID | +| ↳ `name` | string | Domain name | +| ↳ `status` | string | Zone status \(initializing, pending, active, moved\) | +| ↳ `paused` | boolean | Whether the zone is paused | +| ↳ `type` | string | Zone type \(full, partial, or secondary\) | +| ↳ `name_servers` | array | Assigned Cloudflare name servers | +| ↳ `original_name_servers` | array | Original name servers before moving to Cloudflare | +| ↳ `created_on` | string | ISO 8601 date when the zone was created | +| ↳ `modified_on` | string | ISO 8601 date when the zone was last modified | +| ↳ `activated_on` | string | ISO 8601 date when the zone was activated | +| ↳ `development_mode` | number | Seconds remaining in development mode \(0 = off\) | +| ↳ `plan` | object | Zone plan information | +| ↳ `id` | string | Plan identifier | +| ↳ `name` | string | Plan name | +| ↳ `price` | number | Plan price | +| ↳ `is_subscribed` | boolean | Whether the zone is subscribed to the plan | +| ↳ `frequency` | string | Plan billing frequency | +| ↳ `currency` | string | Plan currency | +| ↳ `legacy_id` | string | Legacy plan identifier | +| ↳ `account` | object | Account the zone belongs to | +| ↳ `id` | string | Account identifier | +| ↳ `name` | string | Account name | +| ↳ `owner` | object | Zone owner information | +| ↳ `id` | string | Owner identifier | +| ↳ `name` | string | Owner name | +| ↳ `type` | string | Owner type | +| ↳ `meta` | object | Zone metadata | +| ↳ `cdn_only` | boolean | Whether the zone is CDN only | +| ↳ `custom_certificate_quota` | number | Custom certificate quota | +| ↳ `dns_only` | boolean | Whether the zone is DNS only | +| ↳ `foundation_dns` | boolean | Whether foundation DNS is enabled | +| ↳ `page_rule_quota` | number | Page rule quota | +| ↳ `phishing_detected` | boolean | Whether phishing was detected | +| ↳ `step` | number | Current setup step | +| ↳ `vanity_name_servers` | array | Custom vanity name servers | +| ↳ `permissions` | array | User permissions for the zone | +| `total_count` | number | Total number of zones matching the query | + +### `cloudflare_get_zone` + +Gets details for a specific zone (domain) by its ID. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to retrieve details for | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Zone ID | +| `name` | string | Domain name | +| `status` | string | Zone status \(initializing, pending, active, moved\) | +| `paused` | boolean | Whether the zone is paused | +| `type` | string | Zone type \(full, partial, or secondary\) | +| `name_servers` | array | Assigned Cloudflare name servers | +| `original_name_servers` | array | Original name servers before moving to Cloudflare | +| `created_on` | string | ISO 8601 date when the zone was created | +| `modified_on` | string | ISO 8601 date when the zone was last modified | +| `activated_on` | string | ISO 8601 date when the zone was activated | +| `development_mode` | number | Seconds remaining in development mode \(0 = off\) | +| `plan` | object | Zone plan information | +| ↳ `id` | string | Plan identifier | +| ↳ `name` | string | Plan name | +| ↳ `price` | number | Plan price | +| ↳ `is_subscribed` | boolean | Whether the zone is subscribed to the plan | +| ↳ `frequency` | string | Plan billing frequency | +| ↳ `currency` | string | Plan currency | +| ↳ `legacy_id` | string | Legacy plan identifier | +| `account` | object | Account the zone belongs to | +| ↳ `id` | string | Account identifier | +| ↳ `name` | string | Account name | +| `owner` | object | Zone owner information | +| ↳ `id` | string | Owner identifier | +| ↳ `name` | string | Owner name | +| ↳ `type` | string | Owner type | +| `meta` | object | Zone metadata | +| ↳ `cdn_only` | boolean | Whether the zone is CDN only | +| ↳ `custom_certificate_quota` | number | Custom certificate quota | +| ↳ `dns_only` | boolean | Whether the zone is DNS only | +| ↳ `foundation_dns` | boolean | Whether foundation DNS is enabled | +| ↳ `page_rule_quota` | number | Page rule quota | +| ↳ `phishing_detected` | boolean | Whether phishing was detected | +| ↳ `step` | number | Current setup step | +| `vanity_name_servers` | array | Custom vanity name servers | +| `permissions` | array | User permissions for the zone | + +### `cloudflare_create_zone` + +Adds a new zone (domain) to the Cloudflare account. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `name` | string | Yes | The domain name to add \(e.g., "example.com"\) | +| `accountId` | string | Yes | The Cloudflare account ID | +| `type` | string | No | Zone type: "full" \(Cloudflare manages DNS\), "partial" \(CNAME setup\), or "secondary" \(secondary DNS\) | +| `jump_start` | boolean | No | Automatically attempt to fetch existing DNS records when creating the zone | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Created zone ID | +| `name` | string | Domain name | +| `status` | string | Zone status \(initializing, pending, active, moved\) | +| `paused` | boolean | Whether the zone is paused | +| `type` | string | Zone type \(full, partial, or secondary\) | +| `name_servers` | array | Assigned Cloudflare name servers | +| `original_name_servers` | array | Original name servers before moving to Cloudflare | +| `created_on` | string | ISO 8601 date when the zone was created | +| `modified_on` | string | ISO 8601 date when the zone was last modified | +| `activated_on` | string | ISO 8601 date when the zone was activated | +| `development_mode` | number | Seconds remaining in development mode \(0 = off\) | +| `plan` | object | Zone plan information | +| ↳ `id` | string | Plan identifier | +| ↳ `name` | string | Plan name | +| ↳ `price` | number | Plan price | +| ↳ `is_subscribed` | boolean | Whether the zone is subscribed to the plan | +| ↳ `frequency` | string | Plan billing frequency | +| ↳ `currency` | string | Plan currency | +| ↳ `legacy_id` | string | Legacy plan identifier | +| `account` | object | Account the zone belongs to | +| ↳ `id` | string | Account identifier | +| ↳ `name` | string | Account name | +| `owner` | object | Zone owner information | +| ↳ `id` | string | Owner identifier | +| ↳ `name` | string | Owner name | +| ↳ `type` | string | Owner type | +| `meta` | object | Zone metadata | +| ↳ `cdn_only` | boolean | Whether the zone is CDN only | +| ↳ `custom_certificate_quota` | number | Custom certificate quota | +| ↳ `dns_only` | boolean | Whether the zone is DNS only | +| ↳ `foundation_dns` | boolean | Whether foundation DNS is enabled | +| ↳ `page_rule_quota` | number | Page rule quota | +| ↳ `phishing_detected` | boolean | Whether phishing was detected | +| ↳ `step` | number | Current setup step | +| `vanity_name_servers` | array | Custom vanity name servers | +| `permissions` | array | User permissions for the zone | + +### `cloudflare_delete_zone` + +Deletes a zone (domain) from the Cloudflare account. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to delete | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Deleted zone ID | + +### `cloudflare_list_dns_records` + +Lists DNS records for a specific zone. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to list DNS records for | +| `type` | string | No | Filter by record type \(e.g., "A", "AAAA", "CNAME", "MX", "TXT"\) | +| `name` | string | No | Filter by record name \(exact match\) | +| `content` | string | No | Filter by record content \(exact match\) | +| `page` | number | No | Page number for pagination \(default: 1\) | +| `per_page` | number | No | Number of records per page \(default: 100, max: 5000000\) | +| `direction` | string | No | Sort direction \(asc or desc\) | +| `match` | string | No | Match logic for filters: any or all \(default: all\) | +| `order` | string | No | Sort field \(type, name, content, ttl, proxied\) | +| `proxied` | boolean | No | Filter by proxy status | +| `search` | string | No | Free-text search across record name, content, and value | +| `tag` | string | No | Filter by tags \(comma-separated\) | +| `tag_match` | string | No | Tag filter match logic: any or all | +| `commentFilter` | string | No | Filter records by comment content \(substring match\) | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `records` | array | List of DNS records | +| ↳ `id` | string | Unique identifier for the DNS record | +| ↳ `zone_id` | string | The ID of the zone the record belongs to | +| ↳ `zone_name` | string | The name of the zone | +| ↳ `type` | string | Record type \(A, AAAA, CNAME, MX, TXT, etc.\) | +| ↳ `name` | string | Record name \(e.g., example.com\) | +| ↳ `content` | string | Record content \(e.g., IP address\) | +| ↳ `proxiable` | boolean | Whether the record can be proxied | +| ↳ `proxied` | boolean | Whether Cloudflare proxy is enabled | +| ↳ `ttl` | number | TTL in seconds \(1 = automatic\) | +| ↳ `locked` | boolean | Whether the record is locked | +| ↳ `priority` | number | MX/SRV record priority | +| ↳ `comment` | string | Comment associated with the record | +| ↳ `tags` | array | Tags associated with the record | +| ↳ `comment_modified_on` | string | ISO 8601 timestamp when the comment was last modified | +| ↳ `tags_modified_on` | string | ISO 8601 timestamp when tags were last modified | +| ↳ `meta` | object | Record metadata | +| ↳ `source` | string | Source of the DNS record | +| ↳ `created_on` | string | ISO 8601 timestamp when the record was created | +| ↳ `modified_on` | string | ISO 8601 timestamp when the record was last modified | +| `total_count` | number | Total number of DNS records matching the query | + +### `cloudflare_create_dns_record` + +Creates a new DNS record for a zone. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to create the DNS record in | +| `type` | string | Yes | DNS record type \(e.g., "A", "AAAA", "CNAME", "MX", "TXT", "NS", "SRV"\) | +| `name` | string | Yes | DNS record name \(e.g., "example.com" or "subdomain.example.com"\) | +| `content` | string | Yes | DNS record content \(e.g., IP address for A records, target for CNAME\) | +| `ttl` | number | No | Time to live in seconds \(1 = automatic, default: 1\) | +| `proxied` | boolean | No | Whether to enable Cloudflare proxy \(default: false\) | +| `priority` | number | No | Priority for MX and SRV records | +| `comment` | string | No | Comment for the DNS record | +| `tags` | string | No | Comma-separated tags for the DNS record | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Unique identifier for the created DNS record | +| `zone_id` | string | The ID of the zone the record belongs to | +| `zone_name` | string | The name of the zone | +| `type` | string | DNS record type \(A, AAAA, CNAME, MX, TXT, etc.\) | +| `name` | string | DNS record hostname | +| `content` | string | DNS record value \(e.g., IP address, target hostname\) | +| `proxiable` | boolean | Whether the record can be proxied through Cloudflare | +| `proxied` | boolean | Whether Cloudflare proxy is enabled | +| `ttl` | number | Time to live in seconds \(1 = automatic\) | +| `locked` | boolean | Whether the record is locked | +| `priority` | number | Priority for MX and SRV records | +| `comment` | string | Comment associated with the record | +| `tags` | array | Tags associated with the record | +| `comment_modified_on` | string | ISO 8601 timestamp when the comment was last modified | +| `tags_modified_on` | string | ISO 8601 timestamp when tags were last modified | +| `meta` | object | Record metadata | +| ↳ `source` | string | Source of the DNS record | +| `created_on` | string | ISO 8601 timestamp when the record was created | +| `modified_on` | string | ISO 8601 timestamp when the record was last modified | + +### `cloudflare_update_dns_record` + +Updates an existing DNS record for a zone. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID containing the DNS record | +| `recordId` | string | Yes | The DNS record ID to update | +| `type` | string | No | DNS record type \(e.g., "A", "AAAA", "CNAME", "MX", "TXT"\) | +| `name` | string | No | DNS record name | +| `content` | string | No | DNS record content \(e.g., IP address\) | +| `ttl` | number | No | Time to live in seconds \(1 = automatic\) | +| `proxied` | boolean | No | Whether to enable Cloudflare proxy | +| `priority` | number | No | Priority for MX and SRV records | +| `comment` | string | No | Comment for the DNS record | +| `tags` | string | No | Comma-separated tags for the DNS record | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Unique identifier for the updated DNS record | +| `zone_id` | string | The ID of the zone the record belongs to | +| `zone_name` | string | The name of the zone | +| `type` | string | DNS record type \(A, AAAA, CNAME, MX, TXT, etc.\) | +| `name` | string | DNS record hostname | +| `content` | string | DNS record value \(e.g., IP address, target hostname\) | +| `proxiable` | boolean | Whether the record can be proxied through Cloudflare | +| `proxied` | boolean | Whether Cloudflare proxy is enabled | +| `ttl` | number | Time to live in seconds \(1 = automatic\) | +| `locked` | boolean | Whether the record is locked | +| `priority` | number | Priority for MX and SRV records | +| `comment` | string | Comment associated with the record | +| `tags` | array | Tags associated with the record | +| `comment_modified_on` | string | ISO 8601 timestamp when the comment was last modified | +| `tags_modified_on` | string | ISO 8601 timestamp when tags were last modified | +| `meta` | object | Record metadata | +| ↳ `source` | string | Source of the DNS record | +| `created_on` | string | ISO 8601 timestamp when the record was created | +| `modified_on` | string | ISO 8601 timestamp when the record was last modified | + +### `cloudflare_delete_dns_record` + +Deletes a DNS record from a zone. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID containing the DNS record | +| `recordId` | string | Yes | The DNS record ID to delete | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Deleted record ID | + +### `cloudflare_list_certificates` + +Lists SSL/TLS certificate packs for a zone. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to list certificates for | +| `status` | string | No | Filter certificate packs by status \(e.g., "all", "active", "pending"\) | +| `page` | number | No | Page number of paginated results \(default: 1\) | +| `per_page` | number | No | Number of certificate packs per page \(default: 20, min: 5, max: 50\) | +| `deploy` | string | No | Filter by deployment environment: "staging" or "production" | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `certificates` | array | List of SSL/TLS certificate packs | +| ↳ `id` | string | Certificate pack ID | +| ↳ `type` | string | Certificate type \(e.g., "universal", "advanced"\) | +| ↳ `hosts` | array | Hostnames covered by this certificate pack | +| ↳ `primary_certificate` | string | ID of the primary certificate in the pack | +| ↳ `status` | string | Certificate pack status \(e.g., "active", "pending"\) | +| ↳ `certificates` | array | Individual certificates within the pack | +| ↳ `id` | string | Certificate ID | +| ↳ `hosts` | array | Hostnames covered by this certificate | +| ↳ `issuer` | string | Certificate issuer | +| ↳ `signature` | string | Signature algorithm \(e.g., "ECDSAWithSHA256"\) | +| ↳ `status` | string | Certificate status | +| ↳ `bundle_method` | string | Bundle method \(e.g., "ubiquitous"\) | +| ↳ `zone_id` | string | Zone ID the certificate belongs to | +| ↳ `uploaded_on` | string | Upload date \(ISO 8601\) | +| ↳ `modified_on` | string | Last modified date \(ISO 8601\) | +| ↳ `expires_on` | string | Expiration date \(ISO 8601\) | +| ↳ `priority` | number | Certificate priority order | +| ↳ `geo_restrictions` | object | Geographic restrictions for the certificate | +| ↳ `label` | string | Geographic restriction label | +| ↳ `cloudflare_branding` | boolean | Whether Cloudflare branding is enabled on the certificate | +| ↳ `validation_method` | string | Validation method \(e.g., "txt", "http", "cname"\) | +| ↳ `validity_days` | number | Validity period in days | +| ↳ `certificate_authority` | string | Certificate authority \(e.g., "lets_encrypt", "google"\) | +| ↳ `validation_errors` | array | Validation issues for the certificate pack | +| ↳ `message` | string | Validation error message | +| ↳ `validation_records` | array | Validation records for the certificate pack | +| ↳ `cname` | string | CNAME record name | +| ↳ `cname_target` | string | CNAME record target | +| ↳ `emails` | array | Email addresses for validation | +| ↳ `http_body` | string | HTTP validation body content | +| ↳ `http_url` | string | HTTP validation URL | +| ↳ `status` | string | Validation record status | +| ↳ `txt_name` | string | TXT record name | +| ↳ `txt_value` | string | TXT record value | +| ↳ `dcv_delegation_records` | array | Domain control validation delegation records | +| ↳ `cname` | string | CNAME record name | +| ↳ `cname_target` | string | CNAME record target | +| ↳ `emails` | array | Email addresses for validation | +| ↳ `http_body` | string | HTTP validation body content | +| ↳ `http_url` | string | HTTP validation URL | +| ↳ `status` | string | Delegation record status | +| ↳ `txt_name` | string | TXT record name | +| ↳ `txt_value` | string | TXT record value | +| `total_count` | number | Total number of certificate packs | + +### `cloudflare_get_zone_settings` + +Gets all settings for a zone including SSL mode, minification, caching level, and security settings. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to get settings for | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `settings` | array | List of zone settings | +| ↳ `id` | string | Setting identifier \(e.g., ssl, minify, cache_level, security_level, always_use_https\) | +| ↳ `value` | string | Setting value as a string. Simple values returned as-is \(e.g., "full", "on"\). Complex values are JSON-stringified \(e.g., \ | +| ↳ `editable` | boolean | Whether the setting can be modified for the current zone plan | +| ↳ `modified_on` | string | ISO 8601 timestamp when the setting was last modified | +| ↳ `time_remaining` | number | Seconds remaining until the setting can be modified again \(only present for rate-limited settings\) | + +### `cloudflare_update_zone_setting` + +Updates a specific zone setting such as SSL mode, security level, cache level, minification, or other configuration. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to update settings for | +| `settingId` | string | Yes | Setting to update \(e.g., "ssl", "security_level", "cache_level", "minify", "always_use_https", "browser_cache_ttl", "http3", "min_tls_version", "ciphers"\) | +| `value` | string | Yes | New value for the setting as a string or JSON string for complex values \(e.g., "full" for SSL, "medium" for security_level, "aggressive" for cache_level, \'\{"css":"on","html":"on","js":"on"\}\' for minify, \'\["ECDHE-RSA-AES128-GCM-SHA256"\]\' for ciphers\) | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Setting identifier \(e.g., ssl, minify, cache_level\) | +| `value` | string | Updated setting value as a string. Simple values returned as-is \(e.g., "full", "on"\). Complex values are JSON-stringified. | +| `editable` | boolean | Whether the setting can be modified for the current zone plan | +| `modified_on` | string | ISO 8601 timestamp when the setting was last modified | +| `time_remaining` | number | Seconds remaining until the setting can be modified again \(only present for rate-limited settings\) | + +### `cloudflare_dns_analytics` + +Gets DNS analytics report for a zone including query counts and trends. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to get DNS analytics for | +| `since` | string | No | Start date for analytics \(ISO 8601, e.g., "2024-01-01T00:00:00Z"\) or relative \(e.g., "-6h"\) | +| `until` | string | No | End date for analytics \(ISO 8601, e.g., "2024-01-31T23:59:59Z"\) or relative \(e.g., "now"\) | +| `metrics` | string | Yes | Comma-separated metrics to retrieve \(e.g., "queryCount,uncachedCount,staleCount,responseTimeAvg,responseTimeMedian,responseTime90th,responseTime99th"\) | +| `dimensions` | string | No | Comma-separated dimensions to group by \(e.g., "queryName,queryType,responseCode,responseCached,coloName,origin,dayOfWeek,tcp,ipVersion,querySizeBucket,responseSizeBucket"\) | +| `filters` | string | No | Filters to apply to the data \(e.g., "queryType==A"\) | +| `sort` | string | No | Sort order for the result set. Fields must be included in metrics or dimensions \(e.g., "+queryCount" or "-responseTimeAvg"\) | +| `limit` | number | No | Maximum number of results to return | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `totals` | object | Aggregate DNS analytics totals for the entire queried period | +| ↳ `queryCount` | number | Total number of DNS queries | +| ↳ `uncachedCount` | number | Number of uncached DNS queries | +| ↳ `staleCount` | number | Number of stale DNS queries | +| ↳ `responseTimeAvg` | number | Average response time in milliseconds | +| ↳ `responseTimeMedian` | number | Median response time in milliseconds | +| ↳ `responseTime90th` | number | 90th percentile response time in milliseconds | +| ↳ `responseTime99th` | number | 99th percentile response time in milliseconds | +| `min` | object | Minimum values across the analytics period | +| ↳ `queryCount` | number | Minimum number of DNS queries | +| ↳ `uncachedCount` | number | Minimum number of uncached DNS queries | +| ↳ `staleCount` | number | Minimum number of stale DNS queries | +| ↳ `responseTimeAvg` | number | Minimum average response time in milliseconds | +| ↳ `responseTimeMedian` | number | Minimum median response time in milliseconds | +| ↳ `responseTime90th` | number | Minimum 90th percentile response time in milliseconds | +| ↳ `responseTime99th` | number | Minimum 99th percentile response time in milliseconds | +| `max` | object | Maximum values across the analytics period | +| ↳ `queryCount` | number | Maximum number of DNS queries | +| ↳ `uncachedCount` | number | Maximum number of uncached DNS queries | +| ↳ `staleCount` | number | Maximum number of stale DNS queries | +| ↳ `responseTimeAvg` | number | Maximum average response time in milliseconds | +| ↳ `responseTimeMedian` | number | Maximum median response time in milliseconds | +| ↳ `responseTime90th` | number | Maximum 90th percentile response time in milliseconds | +| ↳ `responseTime99th` | number | Maximum 99th percentile response time in milliseconds | +| `data` | array | Raw analytics data rows returned by the Cloudflare DNS analytics report | +| ↳ `dimensions` | array | Dimension values for this data row, parallel to the requested dimensions list | +| ↳ `metrics` | array | Metric values for this data row, parallel to the requested metrics list | +| `data_lag` | number | Processing lag in seconds before analytics data becomes available | +| `rows` | number | Total number of rows in the result set | +| `query` | object | Echo of the query parameters sent to the API | +| ↳ `since` | string | Start date of the analytics query | +| ↳ `until` | string | End date of the analytics query | +| ↳ `metrics` | array | Metrics requested in the query | +| ↳ `dimensions` | array | Dimensions requested in the query | +| ↳ `filters` | string | Filters applied to the query | +| ↳ `sort` | array | Sort order applied to the query | +| ↳ `limit` | number | Maximum number of results requested | + +### `cloudflare_purge_cache` + +Purges cached content for a zone. Can purge everything or specific files/tags/hosts/prefixes. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `zoneId` | string | Yes | The zone ID to purge cache for | +| `purge_everything` | boolean | No | Set to true to purge all cached content. Mutually exclusive with files, tags, hosts, and prefixes | +| `files` | string | No | Comma-separated list of URLs to purge from cache | +| `tags` | string | No | Comma-separated list of cache tags to purge \(Enterprise only\) | +| `hosts` | string | No | Comma-separated list of hostnames to purge \(Enterprise only\) | +| `prefixes` | string | No | Comma-separated list of URL prefixes to purge \(Enterprise only\) | +| `apiKey` | string | Yes | Cloudflare API Token | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `id` | string | Purge request identifier returned by Cloudflare | + + diff --git a/apps/docs/content/docs/en/tools/meta.json b/apps/docs/content/docs/en/tools/meta.json index e19b01b3d5..21c2a2cf1b 100644 --- a/apps/docs/content/docs/en/tools/meta.json +++ b/apps/docs/content/docs/en/tools/meta.json @@ -15,6 +15,7 @@ "circleback", "clay", "clerk", + "cloudflare", "confluence", "cursor", "datadog", @@ -68,6 +69,7 @@ "mailgun", "mem0", "memory", + "microsoft_dataverse", "microsoft_excel", "microsoft_planner", "microsoft_teams", diff --git a/apps/docs/content/docs/en/tools/microsoft_dataverse.mdx b/apps/docs/content/docs/en/tools/microsoft_dataverse.mdx new file mode 100644 index 0000000000..e548c0ea0e --- /dev/null +++ b/apps/docs/content/docs/en/tools/microsoft_dataverse.mdx @@ -0,0 +1,426 @@ +--- +title: Microsoft Dataverse +description: Manage records in Microsoft Dataverse tables +--- + +import { BlockInfoCard } from "@/components/ui/block-info-card" + + + +{/* MANUAL-CONTENT-START:intro */} +[Microsoft Dataverse](https://learn.microsoft.com/en-us/power-apps/maker/data-platform/data-platform-intro) is a powerful cloud data platform for securely storing, managing, and interacting with structured business data. The Microsoft Dataverse integration enables you to programmatically create, read, update, delete, and link records in Dataverse tables as part of your workflow and automation needs. + +With Microsoft Dataverse integration, you can: + +- **List and query records:** Access lists of records or query with advanced filters to find the data you need from any Dataverse table. +- **Create and update records:** Add new records or update existing ones in any table for use across Power Platform, Dynamics 365, and custom apps. +- **Delete and manage records:** Remove records as part of data lifecycle management directly from your automation flows. +- **Associate and disassociate records:** Link related items together or remove associations using entity relationships and navigation properties—essential for reflecting complex business processes. +- **Work with any Dataverse environment:** Connect to your organization’s environments, including production, sandbox, or Dynamics 365 tenants, for maximum flexibility. +- **Integrate with Power Platform and Dynamics 365:** Automate tasks ranging from sales and marketing data updates to custom app workflows—all powered by Dataverse's security and governance. + +The Dataverse integration empowers solution builders and business users to automate business processes, maintain accurate and up-to-date information, create system integrations, trigger actions, and drive insights—all with robust security and governance. + +Connect Microsoft Dataverse to your automations to unlock sophisticated data management, orchestration, and business logic across your apps, teams, and cloud services. +{/* MANUAL-CONTENT-END */} + + +## Usage Instructions + +Integrate Microsoft Dataverse into your workflow. Create, read, update, delete, upsert, associate, query, search, and execute actions and functions against Dataverse tables using the Web API. Supports bulk operations, FetchXML, file uploads, and relevance search. Works with Dynamics 365, Power Platform, and custom Dataverse environments. + + + +## Tools + +### `microsoft_dataverse_associate` + +Associate two records in Microsoft Dataverse via a navigation property. Creates a relationship between a source record and a target record. Supports both collection-valued (POST) and single-valued (PUT) navigation properties. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Source entity set name \(e.g., accounts\) | +| `recordId` | string | Yes | Source record GUID | +| `navigationProperty` | string | Yes | Navigation property name \(e.g., contact_customer_accounts for collection-valued, or parentcustomerid_account for single-valued\) | +| `targetEntitySetName` | string | Yes | Target entity set name \(e.g., contacts\) | +| `targetRecordId` | string | Yes | Target record GUID to associate | +| `navigationType` | string | No | Type of navigation property: "collection" \(default, uses POST\) or "single" \(uses PUT for lookup fields\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the association was created successfully | +| `entitySetName` | string | Source entity set name used in the association | +| `recordId` | string | Source record GUID that was associated | +| `navigationProperty` | string | Navigation property used for the association | +| `targetEntitySetName` | string | Target entity set name used in the association | +| `targetRecordId` | string | Target record GUID that was associated | + +### `microsoft_dataverse_create_multiple` + +Create multiple records of the same table type in a single request. Each record in the Targets array must include an @odata.type annotation. Recommended batch size: 100-1000 records for standard tables. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `entityLogicalName` | string | Yes | Table logical name for @odata.type annotation \(e.g., account, contact\). Used to set Microsoft.Dynamics.CRM.\{entityLogicalName\} on each record. | +| `records` | object | Yes | Array of record objects to create. Each record should contain column logical names as keys. The @odata.type annotation is added automatically. | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `ids` | array | Array of GUIDs for the created records | +| `count` | number | Number of records created | +| `success` | boolean | Whether all records were created successfully | + +### `microsoft_dataverse_create_record` + +Create a new record in a Microsoft Dataverse table. Requires the entity set name (plural table name) and record data as a JSON object. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `data` | object | Yes | Record data as a JSON object with column names as keys | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `recordId` | string | The ID of the created record | +| `record` | object | Dataverse record object. Contains dynamic columns based on the queried table, plus OData metadata fields. | +| `success` | boolean | Whether the record was created successfully | + +### `microsoft_dataverse_delete_record` + +Delete a record from a Microsoft Dataverse table by its ID. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `recordId` | string | Yes | The unique identifier \(GUID\) of the record to delete | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `recordId` | string | The ID of the deleted record | +| `success` | boolean | Operation success status | + +### `microsoft_dataverse_disassociate` + +Remove an association between two records in Microsoft Dataverse. For collection-valued navigation properties, provide the target record ID. For single-valued navigation properties, only the navigation property name is needed. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Source entity set name \(e.g., accounts\) | +| `recordId` | string | Yes | Source record GUID | +| `navigationProperty` | string | Yes | Navigation property name \(e.g., contact_customer_accounts for collection-valued, or parentcustomerid_account for single-valued\) | +| `targetRecordId` | string | No | Target record GUID \(required for collection-valued navigation properties, omit for single-valued\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the disassociation was completed successfully | +| `entitySetName` | string | Source entity set name used in the disassociation | +| `recordId` | string | Source record GUID that was disassociated | +| `navigationProperty` | string | Navigation property used for the disassociation | +| `targetRecordId` | string | Target record GUID that was disassociated | + +### `microsoft_dataverse_download_file` + +Download a file from a file or image column on a Dataverse record. Returns the file content as a base64-encoded string along with file metadata from response headers. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `recordId` | string | Yes | Record GUID to download the file from | +| `fileColumn` | string | Yes | File or image column logical name \(e.g., entityimage, cr_document\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `fileContent` | string | Base64-encoded file content | +| `fileName` | string | Name of the downloaded file | +| `fileSize` | number | File size in bytes | +| `mimeType` | string | MIME type of the file | +| `success` | boolean | Whether the file was downloaded successfully | + +### `microsoft_dataverse_execute_action` + +Execute a bound or unbound Dataverse action. Actions perform operations with side effects (e.g., Merge, GrantAccess, SendEmail, QualifyLead). For bound actions, provide the entity set name and record ID. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `actionName` | string | Yes | Action name \(e.g., Merge, GrantAccess, SendEmail\). Do not include the Microsoft.Dynamics.CRM. namespace prefix for unbound actions. | +| `entitySetName` | string | No | Entity set name for bound actions \(e.g., accounts\). Leave empty for unbound actions. | +| `recordId` | string | No | Record GUID for bound actions. Leave empty for unbound or collection-bound actions. | +| `parameters` | object | No | Action parameters as a JSON object. For entity references, include @odata.type annotation \(e.g., \{"Target": \{"@odata.type": "Microsoft.Dynamics.CRM.account", "accountid": "..."\}\}\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `result` | object | Action response data. Structure varies by action. Null for actions that return 204 No Content. | +| `success` | boolean | Whether the action executed successfully | + +### `microsoft_dataverse_execute_function` + +Execute a bound or unbound Dataverse function. Functions are read-only operations (e.g., RetrievePrincipalAccess, RetrieveTotalRecordCount, InitializeFrom). For bound functions, provide the entity set name and record ID. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `functionName` | string | Yes | Function name \(e.g., RetrievePrincipalAccess, RetrieveTotalRecordCount\). Do not include the Microsoft.Dynamics.CRM. namespace prefix for unbound functions. | +| `entitySetName` | string | No | Entity set name for bound functions \(e.g., systemusers\). Leave empty for unbound functions. | +| `recordId` | string | No | Record GUID for bound functions. Leave empty for unbound functions. | +| `parameters` | string | No | Function parameters as a comma-separated list of name=value pairs for the URL \(e.g., "LocalizedStandardName=\'Pacific Standard Time\ | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `result` | object | Function response data. Structure varies by function. | +| `success` | boolean | Whether the function executed successfully | + +### `microsoft_dataverse_fetchxml_query` + +Execute a FetchXML query against a Microsoft Dataverse table. FetchXML supports aggregation, grouping, linked-entity joins, and complex filtering beyond OData capabilities. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `fetchXml` | string | Yes | FetchXML query string. Must include <fetch> root element and <entity> child element matching the table logical name. | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `records` | array | Array of Dataverse records. Each record has dynamic columns based on the table schema. | +| `count` | number | Number of records returned in the current page | +| `fetchXmlPagingCookie` | string | Paging cookie for retrieving the next page of results | +| `moreRecords` | boolean | Whether more records are available beyond the current page | +| `success` | boolean | Operation success status | + +### `microsoft_dataverse_get_record` + +Retrieve a single record from a Microsoft Dataverse table by its ID. Supports $select and $expand OData query options. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `recordId` | string | Yes | The unique identifier \(GUID\) of the record to retrieve | +| `select` | string | No | Comma-separated list of columns to return \(OData $select\) | +| `expand` | string | No | Navigation properties to expand \(OData $expand\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `record` | object | Dataverse record object. Contains dynamic columns based on the queried table, plus OData metadata fields. | +| `recordId` | string | The record primary key ID \(auto-detected from response\) | +| `success` | boolean | Whether the record was retrieved successfully | + +### `microsoft_dataverse_list_records` + +Query and list records from a Microsoft Dataverse table. Supports OData query options for filtering, selecting columns, ordering, and pagination. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `select` | string | No | Comma-separated list of columns to return \(OData $select\) | +| `filter` | string | No | OData $filter expression \(e.g., statecode eq 0\) | +| `orderBy` | string | No | OData $orderby expression \(e.g., name asc, createdon desc\) | +| `top` | number | No | Maximum number of records to return \(OData $top\) | +| `expand` | string | No | Navigation properties to expand \(OData $expand\) | +| `count` | string | No | Set to "true" to include total record count in response \(OData $count\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `records` | array | Array of Dataverse records. Each record has dynamic columns based on the table schema. | +| `count` | number | Number of records returned in the current page | +| `totalCount` | number | Total number of matching records server-side \(requires $count=true\) | +| `nextLink` | string | URL for the next page of results | +| `success` | boolean | Operation success status | + +### `microsoft_dataverse_search` + +Perform a full-text relevance search across Microsoft Dataverse tables. Requires Dataverse Search to be enabled on the environment. Supports simple and Lucene query syntax. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `searchTerm` | string | Yes | Search text \(1-100 chars\). Supports simple syntax: + \(AND\), \| \(OR\), - \(NOT\), * \(wildcard\), "exact phrase" | +| `entities` | string | No | JSON array of search entity configs. Each object: \{"Name":"account","SelectColumns":\["name"\],"SearchColumns":\["name"\],"Filter":"statecode eq 0"\} | +| `filter` | string | No | Global OData filter applied across all entities \(e.g., "createdon gt 2024-01-01"\) | +| `facets` | string | No | JSON array of facet specifications \(e.g., \["entityname,count:100","ownerid,count:100"\]\) | +| `top` | number | No | Maximum number of results \(default: 50, max: 100\) | +| `skip` | number | No | Number of results to skip for pagination | +| `orderBy` | string | No | JSON array of sort expressions \(e.g., \["createdon desc"\]\) | +| `searchMode` | string | No | Search mode: "any" \(default, match any term\) or "all" \(match all terms\) | +| `searchType` | string | No | Query type: "simple" \(default\) or "lucene" \(enables regex, fuzzy, proximity, boosting\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `results` | array | Array of search result objects | +| ↳ `Id` | string | Record GUID | +| ↳ `EntityName` | string | Table logical name \(e.g., account, contact\) | +| ↳ `ObjectTypeCode` | number | Entity type code | +| ↳ `Attributes` | object | Record attributes matching the search. Keys are column logical names. | +| ↳ `Highlights` | object | Highlighted search matches. Keys are column names, values are arrays of strings with \{crmhit\}/\{/crmhit\} markers. | +| ↳ `Score` | number | Relevance score for this result | +| `totalCount` | number | Total number of matching records across all tables | +| `count` | number | Number of results returned in this page | +| `facets` | object | Facet results when facets were requested. Keys are facet names, values are arrays of facet value objects with count and value properties. | +| `success` | boolean | Operation success status | + +### `microsoft_dataverse_update_multiple` + +Update multiple records of the same table type in a single request. Each record must include its primary key. Only include columns that need to be changed. Recommended batch size: 100-1000 records. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `entityLogicalName` | string | Yes | Table logical name for @odata.type annotation \(e.g., account, contact\). Used to set Microsoft.Dynamics.CRM.\{entityLogicalName\} on each record. | +| `records` | object | Yes | Array of record objects to update. Each record must include its primary key \(e.g., accountid\) and only the columns being changed. The @odata.type annotation is added automatically. | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether all records were updated successfully | + +### `microsoft_dataverse_update_record` + +Update an existing record in a Microsoft Dataverse table. Only send the columns you want to change. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `recordId` | string | Yes | The unique identifier \(GUID\) of the record to update | +| `data` | object | Yes | Record data to update as a JSON object with column names as keys | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `recordId` | string | The ID of the updated record | +| `success` | boolean | Operation success status | + +### `microsoft_dataverse_upload_file` + +Upload a file to a file or image column on a Dataverse record. Supports single-request upload for files up to 128 MB. The file content must be provided as a base64-encoded string. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `recordId` | string | Yes | Record GUID to upload the file to | +| `fileColumn` | string | Yes | File or image column logical name \(e.g., entityimage, cr_document\) | +| `fileName` | string | Yes | Name of the file being uploaded \(e.g., document.pdf\) | +| `file` | file | No | File to upload \(UserFile object\) | +| `fileContent` | string | No | Base64-encoded file content \(legacy\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `recordId` | string | Record GUID the file was uploaded to | +| `fileColumn` | string | File column the file was uploaded to | +| `fileName` | string | Name of the uploaded file | +| `success` | boolean | Whether the file was uploaded successfully | + +### `microsoft_dataverse_upsert_record` + +Create or update a record in a Microsoft Dataverse table. If a record with the given ID exists, it is updated; otherwise, a new record is created. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | +| `entitySetName` | string | Yes | Entity set name \(plural table name, e.g., accounts, contacts\) | +| `recordId` | string | Yes | The unique identifier \(GUID\) of the record to upsert | +| `data` | object | Yes | Record data as a JSON object with column names as keys | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `recordId` | string | The ID of the upserted record | +| `created` | boolean | True if the record was created, false if updated | +| `record` | object | Dataverse record object. Contains dynamic columns based on the queried table, plus OData metadata fields. | +| `success` | boolean | Operation success status | + +### `microsoft_dataverse_whoami` + +Retrieve the current authenticated user information from Microsoft Dataverse. Useful for testing connectivity and getting the user ID, business unit ID, and organization ID. + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `environmentUrl` | string | Yes | Dataverse environment URL \(e.g., https://myorg.crm.dynamics.com\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `userId` | string | The authenticated user ID | +| `businessUnitId` | string | The business unit ID | +| `organizationId` | string | The organization ID | +| `success` | boolean | Operation success status | + + diff --git a/apps/sim/app/api/tools/microsoft-dataverse/upload-file/route.ts b/apps/sim/app/api/tools/microsoft-dataverse/upload-file/route.ts new file mode 100644 index 0000000000..003daa064a --- /dev/null +++ b/apps/sim/app/api/tools/microsoft-dataverse/upload-file/route.ts @@ -0,0 +1,145 @@ +import { createLogger } from '@sim/logger' +import { type NextRequest, NextResponse } from 'next/server' +import { z } from 'zod' +import { checkInternalAuth } from '@/lib/auth/hybrid' +import { generateRequestId } from '@/lib/core/utils/request' +import { RawFileInputSchema } from '@/lib/uploads/utils/file-schemas' +import { processSingleFileToUserFile } from '@/lib/uploads/utils/file-utils' +import { downloadFileFromStorage } from '@/lib/uploads/utils/file-utils.server' + +export const dynamic = 'force-dynamic' + +const logger = createLogger('DataverseUploadFileAPI') + +const DataverseUploadFileSchema = z.object({ + accessToken: z.string().min(1, 'Access token is required'), + environmentUrl: z.string().min(1, 'Environment URL is required'), + entitySetName: z.string().min(1, 'Entity set name is required'), + recordId: z.string().min(1, 'Record ID is required'), + fileColumn: z.string().min(1, 'File column is required'), + fileName: z.string().min(1, 'File name is required'), + file: RawFileInputSchema.optional().nullable(), + fileContent: z.string().optional().nullable(), +}) + +export async function POST(request: NextRequest) { + const requestId = generateRequestId() + + try { + const authResult = await checkInternalAuth(request, { requireWorkflowId: false }) + + if (!authResult.success) { + logger.warn(`[${requestId}] Unauthorized Dataverse upload attempt: ${authResult.error}`) + return NextResponse.json( + { success: false, error: authResult.error || 'Authentication required' }, + { status: 401 } + ) + } + + logger.info( + `[${requestId}] Authenticated Dataverse upload request via ${authResult.authType}`, + { + userId: authResult.userId, + } + ) + + const body = await request.json() + const validatedData = DataverseUploadFileSchema.parse(body) + + logger.info(`[${requestId}] Uploading file to Dataverse`, { + entitySetName: validatedData.entitySetName, + recordId: validatedData.recordId, + fileColumn: validatedData.fileColumn, + fileName: validatedData.fileName, + hasFile: !!validatedData.file, + hasFileContent: !!validatedData.fileContent, + }) + + let fileBuffer: Buffer + + if (validatedData.file) { + const rawFile = validatedData.file + logger.info(`[${requestId}] Processing UserFile upload: ${rawFile.name}`) + + let userFile + try { + userFile = processSingleFileToUserFile(rawFile, requestId, logger) + } catch (error) { + return NextResponse.json( + { + success: false, + error: error instanceof Error ? error.message : 'Failed to process file', + }, + { status: 400 } + ) + } + + fileBuffer = await downloadFileFromStorage(userFile, requestId, logger) + } else if (validatedData.fileContent) { + fileBuffer = Buffer.from(validatedData.fileContent, 'base64') + } else { + return NextResponse.json( + { success: false, error: 'Either file or fileContent must be provided' }, + { status: 400 } + ) + } + + const baseUrl = validatedData.environmentUrl.replace(/\/$/, '') + const uploadUrl = `${baseUrl}/api/data/v9.2/${validatedData.entitySetName}(${validatedData.recordId})/${validatedData.fileColumn}` + + const response = await fetch(uploadUrl, { + method: 'PATCH', + headers: { + Authorization: `Bearer ${validatedData.accessToken}`, + 'Content-Type': 'application/octet-stream', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + 'x-ms-file-name': validatedData.fileName, + }, + body: new Uint8Array(fileBuffer), + }) + + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error(`[${requestId}] Dataverse upload file failed`, { + errorData, + status: response.status, + }) + return NextResponse.json({ success: false, error: errorMessage }, { status: response.status }) + } + + logger.info(`[${requestId}] File uploaded to Dataverse successfully`, { + entitySetName: validatedData.entitySetName, + recordId: validatedData.recordId, + fileColumn: validatedData.fileColumn, + }) + + return NextResponse.json({ + success: true, + output: { + recordId: validatedData.recordId, + fileColumn: validatedData.fileColumn, + fileName: validatedData.fileName, + success: true, + }, + }) + } catch (error) { + if (error instanceof z.ZodError) { + logger.warn(`[${requestId}] Invalid request data`, { errors: error.errors }) + return NextResponse.json( + { success: false, error: 'Invalid request data', details: error.errors }, + { status: 400 } + ) + } + + logger.error(`[${requestId}] Error uploading file to Dataverse:`, error) + + return NextResponse.json( + { success: false, error: error instanceof Error ? error.message : 'Internal server error' }, + { status: 500 } + ) + } +} diff --git a/apps/sim/blocks/blocks/cloudflare.ts b/apps/sim/blocks/blocks/cloudflare.ts new file mode 100644 index 0000000000..d1a264d718 --- /dev/null +++ b/apps/sim/blocks/blocks/cloudflare.ts @@ -0,0 +1,1098 @@ +import { CloudflareIcon } from '@/components/icons' +import { AuthMode, type BlockConfig } from '@/blocks/types' +import type { CloudflareResponse } from '@/tools/cloudflare/types' + +export const CloudflareBlock: BlockConfig = { + type: 'cloudflare', + name: 'Cloudflare', + description: 'Manage DNS, domains, certificates, and cache', + authMode: AuthMode.ApiKey, + longDescription: + 'Integrate Cloudflare into the workflow. Manage zones (domains), DNS records, SSL/TLS certificates, zone settings, DNS analytics, and cache purging via the Cloudflare API.', + docsLink: 'https://docs.sim.ai/tools/cloudflare', + category: 'tools', + bgColor: '#F5F6FA', + icon: CloudflareIcon, + subBlocks: [ + { + id: 'operation', + title: 'Operation', + type: 'dropdown', + options: [ + { label: 'List Zones', id: 'list_zones' }, + { label: 'Get Zone Details', id: 'get_zone' }, + { label: 'Create Zone', id: 'create_zone' }, + { label: 'Delete Zone', id: 'delete_zone' }, + { label: 'List DNS Records', id: 'list_dns_records' }, + { label: 'Create DNS Record', id: 'create_dns_record' }, + { label: 'Update DNS Record', id: 'update_dns_record' }, + { label: 'Delete DNS Record', id: 'delete_dns_record' }, + { label: 'List Certificates', id: 'list_certificates' }, + { label: 'Get Zone Settings', id: 'get_zone_settings' }, + { label: 'Update Zone Setting', id: 'update_zone_setting' }, + { label: 'DNS Analytics', id: 'dns_analytics' }, + { label: 'Purge Cache', id: 'purge_cache' }, + ], + value: () => 'list_zones', + }, + + // List Zones inputs + { + id: 'name', + title: 'Domain Name', + type: 'short-input', + placeholder: 'Filter by domain (e.g., example.com)', + condition: { field: 'operation', value: 'list_zones' }, + mode: 'advanced', + }, + { + id: 'status', + title: 'Status Filter', + type: 'dropdown', + options: [ + { label: 'All', id: '' }, + { label: 'Active', id: 'active' }, + { label: 'Pending', id: 'pending' }, + { label: 'Initializing', id: 'initializing' }, + { label: 'Moved', id: 'moved' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_zones' }, + mode: 'advanced', + }, + { + id: 'page', + title: 'Page', + type: 'short-input', + placeholder: 'Page number (default: 1)', + condition: { field: 'operation', value: 'list_zones' }, + mode: 'advanced', + }, + { + id: 'per_page', + title: 'Per Page', + type: 'short-input', + placeholder: 'Results per page (default: 20, max: 50)', + condition: { field: 'operation', value: 'list_zones' }, + mode: 'advanced', + }, + { + id: 'accountId', + title: 'Account ID', + type: 'short-input', + placeholder: 'Filter by account ID', + condition: { field: 'operation', value: 'list_zones' }, + mode: 'advanced', + }, + { + id: 'order', + title: 'Sort Field', + type: 'dropdown', + options: [ + { label: 'Default', id: '' }, + { label: 'Name', id: 'name' }, + { label: 'Status', id: 'status' }, + { label: 'Account ID', id: 'account.id' }, + { label: 'Account Name', id: 'account.name' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_zones' }, + mode: 'advanced', + }, + { + id: 'direction', + title: 'Sort Direction', + type: 'dropdown', + options: [ + { label: 'Default', id: '' }, + { label: 'Ascending', id: 'asc' }, + { label: 'Descending', id: 'desc' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_zones' }, + mode: 'advanced', + }, + { + id: 'match', + title: 'Match Logic', + type: 'dropdown', + options: [ + { label: 'All (default)', id: '' }, + { label: 'Any', id: 'any' }, + { label: 'All', id: 'all' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_zones' }, + mode: 'advanced', + }, + + // Create Zone inputs + { + id: 'name', + title: 'Domain Name', + type: 'short-input', + required: true, + placeholder: 'e.g., example.com', + condition: { field: 'operation', value: 'create_zone' }, + }, + { + id: 'accountId', + title: 'Account ID', + type: 'short-input', + required: true, + placeholder: 'Enter Cloudflare account ID', + condition: { field: 'operation', value: 'create_zone' }, + }, + { + id: 'zoneType', + title: 'Zone Type', + type: 'dropdown', + options: [ + { label: 'Full (Cloudflare DNS)', id: 'full' }, + { label: 'Partial (CNAME Setup)', id: 'partial' }, + ], + value: () => 'full', + condition: { field: 'operation', value: 'create_zone' }, + mode: 'advanced', + }, + { + id: 'jump_start', + title: 'Auto-Import DNS', + type: 'dropdown', + options: [ + { label: 'No', id: 'false' }, + { label: 'Yes', id: 'true' }, + ], + value: () => 'false', + condition: { field: 'operation', value: 'create_zone' }, + mode: 'advanced', + }, + + // Get Zone inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'get_zone' }, + }, + + // Delete Zone inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID to delete', + condition: { field: 'operation', value: 'delete_zone' }, + }, + + // List DNS Records inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'list_dns_records' }, + }, + { + id: 'type', + title: 'Record Type', + type: 'dropdown', + options: [ + { label: 'All', id: '' }, + { label: 'A', id: 'A' }, + { label: 'AAAA', id: 'AAAA' }, + { label: 'CNAME', id: 'CNAME' }, + { label: 'MX', id: 'MX' }, + { label: 'TXT', id: 'TXT' }, + { label: 'NS', id: 'NS' }, + { label: 'SRV', id: 'SRV' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'name', + title: 'Name Filter', + type: 'short-input', + placeholder: 'Filter by record name (exact match)', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'content', + title: 'Content Filter', + type: 'short-input', + placeholder: 'Filter by record content (exact match)', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'direction', + title: 'Sort Direction', + type: 'dropdown', + options: [ + { label: 'Default', id: '' }, + { label: 'Ascending', id: 'asc' }, + { label: 'Descending', id: 'desc' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'match', + title: 'Match Logic', + type: 'dropdown', + options: [ + { label: 'All (default)', id: '' }, + { label: 'Any', id: 'any' }, + { label: 'All', id: 'all' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'order', + title: 'Sort Field', + type: 'dropdown', + options: [ + { label: 'Default', id: '' }, + { label: 'Type', id: 'type' }, + { label: 'Name', id: 'name' }, + { label: 'Content', id: 'content' }, + { label: 'TTL', id: 'ttl' }, + { label: 'Proxied', id: 'proxied' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'proxied', + title: 'Proxied Filter', + type: 'dropdown', + options: [ + { label: 'All', id: '' }, + { label: 'Proxied Only', id: 'true' }, + { label: 'DNS Only', id: 'false' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'search', + title: 'Search', + type: 'short-input', + placeholder: 'Free-text search across record properties', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'tag', + title: 'Tag Filter', + type: 'short-input', + placeholder: 'Comma-separated tags to filter by', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'tag_match', + title: 'Tag Match Logic', + type: 'dropdown', + options: [ + { label: 'Default', id: '' }, + { label: 'Any', id: 'any' }, + { label: 'All', id: 'all' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'commentFilter', + title: 'Comment Filter', + type: 'short-input', + placeholder: 'Filter by comment content (substring match)', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'page', + title: 'Page', + type: 'short-input', + placeholder: 'Page number (default: 1)', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + { + id: 'per_page', + title: 'Per Page', + type: 'short-input', + placeholder: 'Results per page (default: 100, max: 5000000)', + condition: { field: 'operation', value: 'list_dns_records' }, + mode: 'advanced', + }, + + // Create DNS Record inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'create_dns_record' }, + }, + { + id: 'type', + title: 'Record Type', + type: 'dropdown', + options: [ + { label: 'A', id: 'A' }, + { label: 'AAAA', id: 'AAAA' }, + { label: 'CNAME', id: 'CNAME' }, + { label: 'MX', id: 'MX' }, + { label: 'TXT', id: 'TXT' }, + { label: 'NS', id: 'NS' }, + { label: 'SRV', id: 'SRV' }, + ], + value: () => 'A', + condition: { field: 'operation', value: 'create_dns_record' }, + }, + { + id: 'name', + title: 'Record Name', + type: 'short-input', + required: true, + placeholder: 'e.g., example.com or sub.example.com', + condition: { field: 'operation', value: 'create_dns_record' }, + }, + { + id: 'content', + title: 'Record Content', + type: 'short-input', + required: true, + placeholder: 'e.g., 192.0.2.1 or target.example.com', + condition: { field: 'operation', value: 'create_dns_record' }, + }, + { + id: 'ttl', + title: 'TTL (seconds)', + type: 'short-input', + placeholder: '1 (automatic)', + condition: { field: 'operation', value: 'create_dns_record' }, + mode: 'advanced', + }, + { + id: 'proxied', + title: 'Proxied', + type: 'dropdown', + options: [ + { label: 'No', id: 'false' }, + { label: 'Yes', id: 'true' }, + ], + value: () => 'false', + condition: { field: 'operation', value: 'create_dns_record' }, + mode: 'advanced', + }, + { + id: 'priority', + title: 'Priority', + type: 'short-input', + placeholder: 'MX/SRV priority (e.g., 10)', + condition: { field: 'operation', value: 'create_dns_record' }, + mode: 'advanced', + }, + { + id: 'comment', + title: 'Comment', + type: 'short-input', + placeholder: 'Optional comment', + condition: { field: 'operation', value: 'create_dns_record' }, + mode: 'advanced', + }, + { + id: 'tags', + title: 'Tags', + type: 'short-input', + placeholder: 'Comma-separated tags (e.g., production,web)', + condition: { field: 'operation', value: 'create_dns_record' }, + mode: 'advanced', + }, + + // Update DNS Record inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'update_dns_record' }, + }, + { + id: 'recordId', + title: 'Record ID', + type: 'short-input', + required: true, + placeholder: 'Enter DNS record ID', + condition: { field: 'operation', value: 'update_dns_record' }, + }, + { + id: 'type', + title: 'Record Type', + type: 'dropdown', + options: [ + { label: 'No Change', id: '' }, + { label: 'A', id: 'A' }, + { label: 'AAAA', id: 'AAAA' }, + { label: 'CNAME', id: 'CNAME' }, + { label: 'MX', id: 'MX' }, + { label: 'TXT', id: 'TXT' }, + { label: 'NS', id: 'NS' }, + { label: 'SRV', id: 'SRV' }, + ], + value: () => '', + condition: { field: 'operation', value: 'update_dns_record' }, + mode: 'advanced', + }, + { + id: 'name', + title: 'Record Name', + type: 'short-input', + placeholder: 'e.g., example.com or sub.example.com', + condition: { field: 'operation', value: 'update_dns_record' }, + mode: 'advanced', + }, + { + id: 'content', + title: 'New Content', + type: 'short-input', + placeholder: 'e.g., 192.0.2.1', + condition: { field: 'operation', value: 'update_dns_record' }, + mode: 'advanced', + }, + { + id: 'ttl', + title: 'TTL (seconds)', + type: 'short-input', + placeholder: '1 (automatic)', + condition: { field: 'operation', value: 'update_dns_record' }, + mode: 'advanced', + }, + { + id: 'proxied', + title: 'Proxied', + type: 'dropdown', + options: [ + { label: 'No Change', id: '' }, + { label: 'No', id: 'false' }, + { label: 'Yes', id: 'true' }, + ], + value: () => '', + condition: { field: 'operation', value: 'update_dns_record' }, + mode: 'advanced', + }, + { + id: 'priority', + title: 'Priority', + type: 'short-input', + placeholder: 'MX/SRV priority (e.g., 10)', + condition: { field: 'operation', value: 'update_dns_record' }, + mode: 'advanced', + }, + { + id: 'comment', + title: 'Comment', + type: 'short-input', + placeholder: 'Optional comment', + condition: { field: 'operation', value: 'update_dns_record' }, + mode: 'advanced', + }, + { + id: 'tags', + title: 'Tags', + type: 'short-input', + placeholder: 'Comma-separated tags (e.g., production,web)', + condition: { field: 'operation', value: 'update_dns_record' }, + mode: 'advanced', + }, + + // Delete DNS Record inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'delete_dns_record' }, + }, + { + id: 'recordId', + title: 'Record ID', + type: 'short-input', + required: true, + placeholder: 'Enter DNS record ID to delete', + condition: { field: 'operation', value: 'delete_dns_record' }, + }, + + // List Certificates inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'list_certificates' }, + }, + { + id: 'status', + title: 'Status Filter', + type: 'dropdown', + options: [ + { label: 'All', id: 'all' }, + { label: 'Active', id: 'active' }, + { label: 'Pending', id: 'pending' }, + ], + value: () => 'all', + condition: { field: 'operation', value: 'list_certificates' }, + mode: 'advanced', + }, + { + id: 'page', + title: 'Page', + type: 'short-input', + placeholder: 'Page number (default: 1)', + condition: { field: 'operation', value: 'list_certificates' }, + mode: 'advanced', + }, + { + id: 'per_page', + title: 'Per Page', + type: 'short-input', + placeholder: 'Results per page (default: 20, min: 5, max: 50)', + condition: { field: 'operation', value: 'list_certificates' }, + mode: 'advanced', + }, + { + id: 'deploy', + title: 'Environment', + type: 'dropdown', + options: [ + { label: 'All', id: '' }, + { label: 'Production', id: 'production' }, + { label: 'Staging', id: 'staging' }, + ], + value: () => '', + condition: { field: 'operation', value: 'list_certificates' }, + mode: 'advanced', + }, + + // Get Zone Settings inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'get_zone_settings' }, + }, + + // Update Zone Setting inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'update_zone_setting' }, + }, + { + id: 'settingId', + title: 'Setting', + type: 'dropdown', + options: [ + { label: 'SSL Mode', id: 'ssl' }, + { label: 'Always Use HTTPS', id: 'always_use_https' }, + { label: 'Security Level', id: 'security_level' }, + { label: 'Cache Level', id: 'cache_level' }, + { label: 'Browser Cache TTL', id: 'browser_cache_ttl' }, + { label: 'Minification', id: 'minify' }, + { label: 'Auto Minify', id: 'auto_minify' }, + { label: 'Rocket Loader', id: 'rocket_loader' }, + { label: 'Email Obfuscation', id: 'email_obfuscation' }, + { label: 'Hotlink Protection', id: 'hotlink_protection' }, + { label: 'IP Geolocation', id: 'ip_geolocation' }, + { label: 'HTTP/2', id: 'http2' }, + { label: 'HTTP/3', id: 'http3' }, + { label: 'WebSockets', id: 'websockets' }, + { label: 'TLS 1.3', id: 'tls_1_3' }, + { label: 'Minimum TLS Version', id: 'min_tls_version' }, + ], + value: () => 'ssl', + condition: { field: 'operation', value: 'update_zone_setting' }, + }, + { + id: 'value', + title: 'Value', + type: 'short-input', + required: true, + placeholder: 'e.g., full, strict, on, off, medium', + condition: { field: 'operation', value: 'update_zone_setting' }, + wandConfig: { + enabled: true, + prompt: `Generate the correct value for a Cloudflare zone setting based on the user's description. + +Common settings and their valid values: +- ssl: "off", "flexible", "full", "strict" +- always_use_https: "on", "off" +- security_level: "off", "essentially_off", "low", "medium", "high", "under_attack" +- cache_level: "aggressive", "basic", "simplified" +- browser_cache_ttl: number in seconds (e.g., 14400 for 4 hours, 86400 for 1 day) +- minify: JSON object {"css":"on","html":"off","js":"on"} +- rocket_loader: "on", "off" +- email_obfuscation: "on", "off" +- hotlink_protection: "on", "off" +- ip_geolocation: "on", "off" +- http2: "on", "off" +- http3: "on", "off" +- websockets: "on", "off" +- tls_1_3: "on", "off", "zrt" +- min_tls_version: "1.0", "1.1", "1.2", "1.3" + +For simple string/boolean settings, return the plain value (e.g., "full", "on"). +For complex settings like minify, return the JSON string (e.g., {"css":"on","html":"on","js":"on"}). +For numeric settings like browser_cache_ttl, return the number (e.g., 14400). + +Return ONLY the value - no explanations, no extra text.`, + placeholder: + 'Describe the setting value (e.g., "enable strict SSL", "minify CSS and JS")...', + }, + }, + + // DNS Analytics inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'dns_analytics' }, + }, + { + id: 'since', + title: 'Start Date', + type: 'short-input', + placeholder: 'ISO 8601 or relative (e.g., 2024-01-01T00:00:00Z or -6h)', + condition: { field: 'operation', value: 'dns_analytics' }, + wandConfig: { + enabled: true, + prompt: `Generate a timestamp or relative time expression for the Cloudflare DNS Analytics API based on the user's description. +Cloudflare accepts either ISO 8601 timestamps (e.g., 2024-01-01T00:00:00Z) or relative expressions (e.g., -6h, -7d, -30d). +Examples: +- "last 6 hours" -> -6h +- "last 24 hours" -> -24h +- "last 7 days" -> -7d +- "last 30 days" -> -30d +- "since January 1st 2024" -> 2024-01-01T00:00:00Z +- "beginning of this month" -> First day of current month at 00:00:00Z +- "1 hour ago" -> -1h + +Return ONLY the timestamp or relative expression - no explanations, no quotes, no extra text.`, + placeholder: 'Describe the start time (e.g., "last 7 days", "since January 1st")...', + generationType: 'timestamp', + }, + }, + { + id: 'until', + title: 'End Date', + type: 'short-input', + placeholder: 'ISO 8601 or relative (e.g., 2024-01-31T23:59:59Z or now)', + condition: { field: 'operation', value: 'dns_analytics' }, + wandConfig: { + enabled: true, + prompt: `Generate a timestamp or relative time expression for the Cloudflare DNS Analytics API based on the user's description. +Cloudflare accepts either ISO 8601 timestamps (e.g., 2024-01-31T23:59:59Z) or relative expressions (e.g., now). +Examples: +- "now" -> now +- "today" -> Today's date at 23:59:59Z +- "end of yesterday" -> Yesterday's date at 23:59:59Z +- "end of last month" -> Last day of previous month at 23:59:59Z + +Return ONLY the timestamp or relative expression - no explanations, no quotes, no extra text.`, + placeholder: 'Describe the end time (e.g., "now", "end of yesterday")...', + generationType: 'timestamp', + }, + }, + { + id: 'metrics', + title: 'Metrics', + type: 'short-input', + placeholder: 'Comma-separated (e.g., queryCount,uncachedCount,responseTimeAvg)', + required: { field: 'operation', value: 'dns_analytics' }, + condition: { field: 'operation', value: 'dns_analytics' }, + wandConfig: { + enabled: true, + prompt: `Generate a comma-separated list of Cloudflare DNS Analytics metrics based on the user's description. + +Available metrics: +- queryCount: Total number of DNS queries +- uncachedCount: Number of DNS queries not served from cache +- staleCount: Number of stale DNS responses served +- responseTimeAvg: Average response time in milliseconds +- responseTimeMedian: Median response time in milliseconds +- responseTime90th: 90th percentile response time +- responseTime99th: 99th percentile response time + +Examples: +- "query counts" -> queryCount +- "all query metrics" -> queryCount,uncachedCount,staleCount +- "response times" -> responseTimeAvg,responseTimeMedian,responseTime90th,responseTime99th +- "everything" -> queryCount,uncachedCount,staleCount,responseTimeAvg,responseTimeMedian,responseTime90th,responseTime99th + +Return ONLY the comma-separated metric names - no explanations, no quotes, no extra text.`, + placeholder: 'Describe what to measure (e.g., "query counts and response times")...', + }, + }, + { + id: 'dimensions', + title: 'Dimensions', + type: 'short-input', + placeholder: 'Comma-separated (e.g., queryName,queryType,responseCode)', + condition: { field: 'operation', value: 'dns_analytics' }, + mode: 'advanced', + wandConfig: { + enabled: true, + prompt: `Generate a comma-separated list of Cloudflare DNS Analytics dimensions based on the user's description. + +Available dimensions: +- queryName: DNS record name being queried +- queryType: DNS query type (A, AAAA, CNAME, MX, etc.) +- responseCode: DNS response code (NOERROR, NXDOMAIN, SERVFAIL, etc.) +- responseCached: Whether the response was cached +- coloName: Cloudflare data center handling the query +- origin: Origin server +- dayOfWeek: Day of the week +- tcp: Whether the query used TCP +- ipVersion: IP version (4 or 6) + +Examples: +- "by record type" -> queryType +- "by record name and type" -> queryName,queryType +- "by data center" -> coloName +- "by response code and cache status" -> responseCode,responseCached + +Return ONLY the comma-separated dimension names - no explanations, no quotes, no extra text.`, + placeholder: 'Describe how to group results (e.g., "by record type and name")...', + }, + }, + { + id: 'filters', + title: 'Filters', + type: 'short-input', + placeholder: 'e.g., queryType==A', + condition: { field: 'operation', value: 'dns_analytics' }, + mode: 'advanced', + wandConfig: { + enabled: true, + prompt: `Generate a Cloudflare DNS Analytics filter expression based on the user's description. + +Filter syntax: field==value or field!=value +Multiple filters can be combined with semicolons: field1==value1;field2==value2 + +Available filter fields: +- queryType: DNS record type (A, AAAA, CNAME, MX, TXT, NS, SRV, etc.) +- queryName: DNS record name +- responseCode: DNS response code (NOERROR, NXDOMAIN, SERVFAIL, REFUSED) +- responseCached: Whether cached (0 or 1) +- coloName: Data center name +- origin: Origin server + +Examples: +- "only A records" -> queryType==A +- "only CNAME records" -> queryType==CNAME +- "failed queries" -> responseCode==SERVFAIL +- "non-existent domains" -> responseCode==NXDOMAIN +- "A records that weren't cached" -> queryType==A;responseCached==0 +- "queries for example.com" -> queryName==example.com + +Return ONLY the filter expression - no explanations, no quotes, no extra text.`, + placeholder: 'Describe what to filter (e.g., "only A records", "failed queries")...', + }, + }, + { + id: 'sort', + title: 'Sort', + type: 'short-input', + placeholder: 'e.g., +queryCount or -responseTimeAvg', + condition: { field: 'operation', value: 'dns_analytics' }, + mode: 'advanced', + }, + { + id: 'limit', + title: 'Limit', + type: 'short-input', + placeholder: 'Max results (e.g., 100)', + condition: { field: 'operation', value: 'dns_analytics' }, + mode: 'advanced', + }, + + // Purge Cache inputs + { + id: 'zoneId', + title: 'Zone ID', + type: 'short-input', + required: true, + placeholder: 'Enter zone ID', + condition: { field: 'operation', value: 'purge_cache' }, + }, + { + id: 'purge_everything', + title: 'Purge Everything', + type: 'dropdown', + options: [ + { label: 'Yes - Purge All', id: 'true' }, + { label: 'No - Purge Specific', id: 'false' }, + ], + value: () => 'true', + condition: { field: 'operation', value: 'purge_cache' }, + }, + { + id: 'files', + title: 'Files to Purge', + type: 'long-input', + placeholder: + 'Comma-separated URLs (e.g., https://example.com/style.css, https://example.com/app.js)', + condition: { field: 'operation', value: 'purge_cache' }, + wandConfig: { + enabled: true, + prompt: `Generate a comma-separated list of URLs to purge from Cloudflare's cache based on the user's description. + +Each URL should be a full URL including the protocol (https://). +Examples: +- "the homepage and about page of example.com" -> https://example.com/, https://example.com/about +- "all CSS and JS files" -> https://example.com/style.css, https://example.com/app.js +- "the API endpoint" -> https://example.com/api/v1/data + +Return ONLY the comma-separated URLs - no explanations, no extra text.`, + placeholder: 'Describe what to purge (e.g., "homepage and CSS files")...', + }, + }, + { + id: 'tags', + title: 'Cache Tags', + type: 'short-input', + placeholder: 'Comma-separated cache tags (Enterprise only)', + condition: { field: 'operation', value: 'purge_cache' }, + mode: 'advanced', + }, + { + id: 'hosts', + title: 'Hostnames', + type: 'short-input', + placeholder: 'Comma-separated hostnames (Enterprise only)', + condition: { field: 'operation', value: 'purge_cache' }, + mode: 'advanced', + }, + { + id: 'prefixes', + title: 'URL Prefixes', + type: 'short-input', + placeholder: 'Comma-separated URL prefixes (Enterprise only)', + condition: { field: 'operation', value: 'purge_cache' }, + mode: 'advanced', + }, + + // API Key (common) + { + id: 'apiKey', + title: 'API Token', + type: 'short-input', + required: true, + placeholder: 'Enter your Cloudflare API token', + password: true, + }, + ], + tools: { + access: [ + 'cloudflare_list_zones', + 'cloudflare_get_zone', + 'cloudflare_create_zone', + 'cloudflare_delete_zone', + 'cloudflare_list_dns_records', + 'cloudflare_create_dns_record', + 'cloudflare_update_dns_record', + 'cloudflare_delete_dns_record', + 'cloudflare_list_certificates', + 'cloudflare_get_zone_settings', + 'cloudflare_update_zone_setting', + 'cloudflare_dns_analytics', + 'cloudflare_purge_cache', + ], + config: { + tool: (params) => `cloudflare_${params.operation}`, + params: (params) => { + const result = { ...params } + + if (result.ttl) result.ttl = Number(result.ttl) + if (result.priority) result.priority = Number(result.priority) + if (result.limit) result.limit = Number(result.limit) + if (result.page) result.page = Number(result.page) + if (result.per_page) result.per_page = Number(result.per_page) + + if (result.proxied === 'true') result.proxied = true + else if (result.proxied === 'false') result.proxied = false + else if (result.proxied === '') result.proxied = undefined + + if (result.purge_everything === 'true') result.purge_everything = true + else if (result.purge_everything === 'false') result.purge_everything = false + + if (result.jump_start === 'true') result.jump_start = true + else if (result.jump_start === 'false') result.jump_start = false + + if (result.type === '' && result.operation !== 'create_dns_record') { + result.type = undefined + } + if (result.status === '') result.status = undefined + if (result.order === '') result.order = undefined + if (result.direction === '') result.direction = undefined + if (result.match === '') result.match = undefined + if (result.tag_match === '') result.tag_match = undefined + if (result.deploy === '') result.deploy = undefined + + if (result.operation === 'update_dns_record') { + if (result.content === '') result.content = undefined + if (result.name === '') result.name = undefined + if (result.comment === '') result.comment = undefined + } + + if (result.operation === 'create_zone' && result.zoneType) { + result.type = result.zoneType + } + + return result + }, + }, + }, + inputs: { + operation: { type: 'string', description: 'Operation to perform' }, + apiKey: { type: 'string', description: 'Cloudflare API token' }, + zoneId: { type: 'string', description: 'Zone ID' }, + accountId: { type: 'string', description: 'Cloudflare account ID' }, + zoneType: { type: 'string', description: 'Zone type (full or partial)' }, + jump_start: { + type: 'boolean', + description: 'Automatically import DNS records when creating a zone', + }, + order: { type: 'string', description: 'Sort field for listing zones' }, + direction: { type: 'string', description: 'Sort direction (asc, desc)' }, + match: { type: 'string', description: 'Match logic for filters (any, all)' }, + recordId: { type: 'string', description: 'DNS record ID' }, + name: { type: 'string', description: 'Domain or record name' }, + type: { type: 'string', description: 'DNS record type' }, + content: { type: 'string', description: 'DNS record content' }, + ttl: { type: 'number', description: 'Time to live in seconds' }, + proxied: { type: 'boolean', description: 'Whether Cloudflare proxy is enabled' }, + priority: { type: 'number', description: 'Record priority (MX/SRV)' }, + comment: { type: 'string', description: 'Record comment' }, + search: { type: 'string', description: 'Free-text search across record properties' }, + tag: { type: 'string', description: 'Comma-separated tags to filter by' }, + tag_match: { type: 'string', description: 'Tag filter match logic (any, all)' }, + commentFilter: { type: 'string', description: 'Filter records by comment content' }, + settingId: { type: 'string', description: 'Zone setting ID' }, + value: { type: 'string', description: 'Setting value' }, + since: { type: 'string', description: 'Start date for analytics' }, + until: { type: 'string', description: 'End date for analytics' }, + metrics: { type: 'string', description: 'Comma-separated metrics to retrieve' }, + dimensions: { type: 'string', description: 'Comma-separated dimensions to group by' }, + filters: { type: 'string', description: 'Filters to apply (e.g., queryType==A)' }, + sort: { type: 'string', description: 'Sort order for results' }, + limit: { type: 'number', description: 'Maximum number of results' }, + status: { type: 'string', description: 'Status filter for zones or certificates' }, + page: { type: 'number', description: 'Page number for pagination' }, + per_page: { type: 'number', description: 'Number of results per page' }, + deploy: { + type: 'string', + description: 'Filter certificates by deployment environment (staging, production)', + }, + purge_everything: { type: 'boolean', description: 'Purge all cached content' }, + files: { type: 'string', description: 'Comma-separated URLs to purge' }, + tags: { type: 'string', description: 'Comma-separated cache tags to purge (Enterprise only)' }, + hosts: { type: 'string', description: 'Comma-separated hostnames to purge (Enterprise only)' }, + prefixes: { + type: 'string', + description: 'Comma-separated URL prefixes to purge (Enterprise only)', + }, + }, + outputs: { + zones: { type: 'json', description: 'List of zones/domains' }, + records: { type: 'json', description: 'List of DNS records' }, + certificates: { type: 'json', description: 'List of SSL/TLS certificate packs' }, + settings: { type: 'json', description: 'List of zone settings' }, + totals: { type: 'json', description: 'Aggregate DNS analytics totals' }, + min: { type: 'json', description: 'Minimum values across the DNS analytics period' }, + max: { type: 'json', description: 'Maximum values across the DNS analytics period' }, + query: { type: 'json', description: 'Echo of the DNS analytics query parameters sent' }, + validation_errors: { type: 'json', description: 'Validation issues for certificate packs' }, + data: { type: 'json', description: 'Raw analytics data rows from the DNS analytics report' }, + data_lag: { + type: 'number', + description: 'Processing lag in seconds before analytics data becomes available', + }, + rows: { type: 'number', description: 'Total number of rows in the DNS analytics result set' }, + id: { type: 'string', description: 'Resource ID' }, + zone_id: { type: 'string', description: 'Zone ID the record belongs to' }, + zone_name: { type: 'string', description: 'Zone domain name' }, + name: { type: 'string', description: 'Resource name' }, + status: { type: 'string', description: 'Resource status' }, + paused: { type: 'boolean', description: 'Whether the zone is paused' }, + type: { type: 'string', description: 'Zone or record type' }, + name_servers: { type: 'json', description: 'Assigned Cloudflare name servers' }, + original_name_servers: { type: 'json', description: 'Original registrar name servers' }, + plan: { + type: 'json', + description: + 'Zone plan information (id, name, price, currency, frequency, is_subscribed, legacy_id)', + }, + account: { type: 'json', description: 'Account the zone belongs to (id, name)' }, + owner: { type: 'json', description: 'Zone owner information (id, name, type)' }, + activated_on: { type: 'string', description: 'ISO 8601 date when the zone was activated' }, + development_mode: { + type: 'number', + description: 'Seconds remaining in development mode (0 = off)', + }, + meta: { + type: 'json', + description: 'Resource metadata (zone: cdn_only, dns_only, etc.; DNS record: source)', + }, + vanity_name_servers: { type: 'json', description: 'Custom vanity name servers' }, + permissions: { type: 'json', description: 'User permissions for the zone' }, + content: { type: 'string', description: 'DNS record value (e.g., IP address)' }, + proxiable: { type: 'boolean', description: 'Whether the record can be proxied' }, + proxied: { type: 'boolean', description: 'Whether Cloudflare proxy is enabled' }, + ttl: { type: 'number', description: 'TTL in seconds (1 = automatic)' }, + locked: { type: 'boolean', description: 'Whether the record is locked' }, + priority: { type: 'number', description: 'Priority for MX and SRV records' }, + comment: { type: 'string', description: 'Record comment' }, + tags: { type: 'json', description: 'Tags associated with the record or cache tags to purge' }, + comment_modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the comment was last modified', + }, + tags_modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when tags were last modified', + }, + created_on: { type: 'string', description: 'Creation date (ISO 8601)' }, + modified_on: { type: 'string', description: 'Last modified date (ISO 8601)' }, + value: { type: 'string', description: 'Setting value (complex values are JSON-stringified)' }, + editable: { type: 'boolean', description: 'Whether the setting can be modified' }, + time_remaining: { type: 'number', description: 'Seconds until setting can be modified again' }, + total_count: { type: 'number', description: 'Total count of results' }, + }, +} diff --git a/apps/sim/blocks/blocks/microsoft_dataverse.ts b/apps/sim/blocks/blocks/microsoft_dataverse.ts new file mode 100644 index 0000000000..7bb17f12c0 --- /dev/null +++ b/apps/sim/blocks/blocks/microsoft_dataverse.ts @@ -0,0 +1,597 @@ +import { MicrosoftDataverseIcon } from '@/components/icons' +import type { BlockConfig } from '@/blocks/types' +import { AuthMode } from '@/blocks/types' +import { normalizeFileInput } from '@/blocks/utils' +import type { DataverseResponse } from '@/tools/microsoft_dataverse/types' + +export const MicrosoftDataverseBlock: BlockConfig = { + type: 'microsoft_dataverse', + name: 'Microsoft Dataverse', + description: 'Manage records in Microsoft Dataverse tables', + authMode: AuthMode.OAuth, + longDescription: + 'Integrate Microsoft Dataverse into your workflow. Create, read, update, delete, upsert, associate, query, search, and execute actions and functions against Dataverse tables using the Web API. Supports bulk operations, FetchXML, file uploads, and relevance search. Works with Dynamics 365, Power Platform, and custom Dataverse environments.', + docsLink: 'https://docs.sim.ai/tools/microsoft_dataverse', + category: 'tools', + bgColor: '#E0E0E0', + icon: MicrosoftDataverseIcon, + subBlocks: [ + { + id: 'operation', + title: 'Operation', + type: 'dropdown', + options: [ + { label: 'List Records', id: 'list_records' }, + { label: 'Get Record', id: 'get_record' }, + { label: 'Create Record', id: 'create_record' }, + { label: 'Update Record', id: 'update_record' }, + { label: 'Upsert Record', id: 'upsert_record' }, + { label: 'Delete Record', id: 'delete_record' }, + { label: 'Create Multiple', id: 'create_multiple' }, + { label: 'Update Multiple', id: 'update_multiple' }, + { label: 'FetchXML Query', id: 'fetchxml_query' }, + { label: 'Search', id: 'search' }, + { label: 'Execute Action', id: 'execute_action' }, + { label: 'Execute Function', id: 'execute_function' }, + { label: 'Upload File', id: 'upload_file' }, + { label: 'Download File', id: 'download_file' }, + { label: 'Associate Records', id: 'associate' }, + { label: 'Disassociate Records', id: 'disassociate' }, + { label: 'WhoAmI', id: 'whoami' }, + ], + value: () => 'list_records', + }, + { + id: 'credential', + title: 'Microsoft Account', + type: 'oauth-input', + serviceId: 'microsoft-dataverse', + requiredScopes: [ + 'openid', + 'profile', + 'email', + 'https://dynamics.microsoft.com/user_impersonation', + 'offline_access', + ], + placeholder: 'Select Microsoft account', + required: true, + }, + { + id: 'environmentUrl', + title: 'Environment URL', + type: 'short-input', + placeholder: 'https://myorg.crm.dynamics.com', + required: true, + }, + { + id: 'entitySetName', + title: 'Entity Set Name', + type: 'short-input', + placeholder: 'Plural table name (e.g., accounts, contacts)', + condition: { + field: 'operation', + value: ['whoami', 'search'], + not: true, + }, + required: { + field: 'operation', + value: ['whoami', 'search', 'execute_action', 'execute_function'], + not: true, + }, + }, + { + id: 'recordId', + title: 'Record ID', + type: 'short-input', + placeholder: 'Record GUID (e.g., 00000000-0000-0000-0000-000000000000)', + condition: { + field: 'operation', + value: [ + 'get_record', + 'update_record', + 'upsert_record', + 'delete_record', + 'associate', + 'disassociate', + 'upload_file', + 'download_file', + 'execute_action', + 'execute_function', + ], + }, + required: { + field: 'operation', + value: [ + 'get_record', + 'update_record', + 'upsert_record', + 'delete_record', + 'associate', + 'disassociate', + 'upload_file', + 'download_file', + ], + }, + }, + { + id: 'data', + title: 'Record Data', + type: 'long-input', + placeholder: + 'JSON object with column values (e.g., {"name": "Contoso", "telephone1": "555-0100"})', + condition: { field: 'operation', value: ['create_record', 'update_record', 'upsert_record'] }, + required: { field: 'operation', value: ['create_record', 'update_record', 'upsert_record'] }, + wandConfig: { + enabled: true, + prompt: `Generate a Dataverse record JSON object based on the user's description. +The JSON should contain column logical names as keys and appropriate values. +Common Dataverse column naming conventions: +- Text: "name", "description", "emailaddress1", "telephone1" +- Lookup: "_primarycontactid_value" (read-only), use "primarycontactid@odata.bind": "/contacts(guid)" for setting +- Choice/OptionSet: integer values (e.g., "statecode": 0, "statuscode": 1) +- Date: ISO 8601 format (e.g., "createdon": "2024-01-15T00:00:00Z") +- Currency: decimal numbers (e.g., "revenue": 1000000.00) + +Return ONLY valid JSON - no explanations, no markdown code blocks.`, + placeholder: 'Describe the record data you want to create or update...', + generationType: 'json-object', + }, + }, + // FetchXML Query + { + id: 'fetchXml', + title: 'FetchXML', + type: 'long-input', + placeholder: + '', + condition: { field: 'operation', value: 'fetchxml_query' }, + required: { field: 'operation', value: 'fetchxml_query' }, + wandConfig: { + enabled: true, + prompt: `Generate a FetchXML query for the Microsoft Dataverse Web API based on the user's description. +FetchXML structure: +- Root: +- Entity: (singular table name, e.g., "account") +- Attributes: or +- Filter: +- Order: +- Link-entity: +- Aggregation: + +Operators: eq, ne, gt, ge, lt, le, like, not-like, in, not-in, null, not-null, between, not-between, contains, not-contain + +Return ONLY valid FetchXML - no explanations, no markdown code blocks.`, + placeholder: 'Describe the query you want to run...', + generationType: 'json-object', + }, + }, + // Search + { + id: 'searchTerm', + title: 'Search Term', + type: 'short-input', + placeholder: 'Search text (e.g., Contoso)', + condition: { field: 'operation', value: 'search' }, + required: { field: 'operation', value: 'search' }, + }, + { + id: 'searchEntities', + title: 'Search Entities', + type: 'long-input', + placeholder: + 'JSON array of entity configs (e.g., [{"Name":"account","SelectColumns":["name"],"SearchColumns":["name"]}])', + condition: { field: 'operation', value: 'search' }, + mode: 'advanced', + }, + { + id: 'searchMode', + title: 'Search Mode', + type: 'dropdown', + options: [ + { label: 'Any (match any term)', id: 'any' }, + { label: 'All (match all terms)', id: 'all' }, + ], + value: () => 'any', + condition: { field: 'operation', value: 'search' }, + mode: 'advanced', + }, + { + id: 'searchType', + title: 'Query Type', + type: 'dropdown', + options: [ + { label: 'Simple (default)', id: 'simple' }, + { label: 'Lucene (regex, fuzzy, proximity)', id: 'lucene' }, + ], + value: () => 'simple', + condition: { field: 'operation', value: 'search' }, + mode: 'advanced', + }, + // Execute Action + { + id: 'actionName', + title: 'Action Name', + type: 'short-input', + placeholder: 'e.g., Merge, GrantAccess, SendEmail', + condition: { field: 'operation', value: 'execute_action' }, + required: { field: 'operation', value: 'execute_action' }, + }, + // Execute Function + { + id: 'functionName', + title: 'Function Name', + type: 'short-input', + placeholder: 'e.g., RetrievePrincipalAccess, RetrieveTotalRecordCount', + condition: { field: 'operation', value: 'execute_function' }, + required: { field: 'operation', value: 'execute_function' }, + }, + { + id: 'functionParameters', + title: 'Function Parameters', + type: 'short-input', + placeholder: "e.g., LocalizedStandardName='Pacific Standard Time',LocaleId=1033", + condition: { field: 'operation', value: 'execute_function' }, + mode: 'advanced', + }, + // Action/Function parameters (shared JSON body for actions) + { + id: 'parameters', + title: 'Action Parameters', + type: 'long-input', + placeholder: + 'JSON object with action parameters (e.g., {"Target": {"@odata.type": "Microsoft.Dynamics.CRM.account", "accountid": "..."}})', + condition: { field: 'operation', value: 'execute_action' }, + wandConfig: { + enabled: true, + prompt: `Generate a JSON object containing parameters for a Microsoft Dataverse action based on the user's description. +For entity references, include @odata.type annotations: +- {"Target": {"@odata.type": "Microsoft.Dynamics.CRM.account", "accountid": "guid"}} +- {"EntityMoniker": {"@odata.type": "Microsoft.Dynamics.CRM.contact", "contactid": "guid"}} +For simple values, just use the parameter name and value. + +Return ONLY valid JSON - no explanations, no markdown code blocks.`, + placeholder: 'Describe the action parameters...', + generationType: 'json-object', + }, + }, + // Bulk operations + { + id: 'entityLogicalName', + title: 'Table Logical Name', + type: 'short-input', + placeholder: 'Singular table name (e.g., account, contact)', + condition: { field: 'operation', value: ['create_multiple', 'update_multiple'] }, + required: { field: 'operation', value: ['create_multiple', 'update_multiple'] }, + }, + { + id: 'records', + title: 'Records', + type: 'long-input', + placeholder: 'JSON array of records (e.g., [{"name": "Contoso"}, {"name": "Fabrikam"}])', + condition: { field: 'operation', value: ['create_multiple', 'update_multiple'] }, + required: { field: 'operation', value: ['create_multiple', 'update_multiple'] }, + wandConfig: { + enabled: true, + prompt: `Generate a JSON array of Dataverse records based on the user's description. +Each record should be an object with column logical names as keys. +For UpdateMultiple, each record must include its primary key (e.g., accountid). +Common column naming conventions: +- Text: "name", "description", "emailaddress1", "telephone1" +- Choice/OptionSet: integer values (e.g., "statecode": 0) +- Date: ISO 8601 format (e.g., "2024-01-15T00:00:00Z") + +Return ONLY a valid JSON array - no explanations, no markdown code blocks.`, + placeholder: 'Describe the records you want to create or update...', + generationType: 'json-object', + }, + }, + // File operations + { + id: 'fileColumn', + title: 'File Column', + type: 'short-input', + placeholder: 'File column logical name (e.g., entityimage, cr_document)', + condition: { field: 'operation', value: ['upload_file', 'download_file'] }, + required: { field: 'operation', value: ['upload_file', 'download_file'] }, + }, + { + id: 'fileName', + title: 'File Name', + type: 'short-input', + placeholder: 'e.g., document.pdf', + condition: { field: 'operation', value: 'upload_file' }, + required: { field: 'operation', value: 'upload_file' }, + }, + { + id: 'uploadFile', + title: 'File', + type: 'file-upload', + canonicalParamId: 'file', + placeholder: 'Upload a file', + condition: { field: 'operation', value: 'upload_file' }, + mode: 'basic', + multiple: false, + required: { field: 'operation', value: 'upload_file' }, + }, + { + id: 'fileReference', + title: 'File', + type: 'short-input', + canonicalParamId: 'file', + placeholder: 'Reference a file from previous blocks (e.g., {{block_1.output.file}})', + condition: { field: 'operation', value: 'upload_file' }, + mode: 'advanced', + required: { field: 'operation', value: 'upload_file' }, + }, + // OData query options (list_records) + { + id: 'select', + title: 'Select Columns', + type: 'short-input', + placeholder: 'Comma-separated columns (e.g., name,telephone1,emailaddress1)', + condition: { field: 'operation', value: ['list_records', 'get_record'] }, + mode: 'advanced', + wandConfig: { + enabled: true, + prompt: `Generate a comma-separated list of Dataverse column logical names based on the user's description. +Use lowercase logical names without spaces. +Common columns by table: +- Accounts: name, accountnumber, telephone1, emailaddress1, address1_city, revenue, industrycode +- Contacts: firstname, lastname, fullname, emailaddress1, telephone1, jobtitle, birthdate +- General: statecode, statuscode, createdon, modifiedon, ownerid, createdby + +Return ONLY the comma-separated column names - no explanations.`, + placeholder: 'Describe which columns you want to retrieve...', + generationType: 'odata-expression', + }, + }, + { + id: 'filter', + title: 'Filter', + type: 'short-input', + placeholder: "OData filter (e.g., statecode eq 0 and contains(name,'Contoso'))", + condition: { field: 'operation', value: ['list_records', 'search'] }, + wandConfig: { + enabled: true, + prompt: `Generate an OData $filter expression for the Dataverse Web API based on the user's description. +OData filter syntax: +- Comparison: eq, ne, gt, ge, lt, le (e.g., "revenue gt 1000000") +- Logical: and, or, not (e.g., "statecode eq 0 and revenue gt 1000000") +- String functions: contains(name,'value'), startswith(name,'value'), endswith(name,'value') +- Date functions: year(createdon) eq 2024, month(createdon) eq 1 +- Null check: fieldname eq null, fieldname ne null +- Status: statecode eq 0 (active), statecode eq 1 (inactive) + +Return ONLY the filter expression - no $filter= prefix, no explanations.`, + placeholder: 'Describe which records you want to filter for...', + generationType: 'odata-expression', + }, + }, + { + id: 'orderBy', + title: 'Order By', + type: 'short-input', + placeholder: 'e.g., name asc, createdon desc', + condition: { field: 'operation', value: ['list_records', 'search'] }, + mode: 'advanced', + wandConfig: { + enabled: true, + prompt: `Generate an OData $orderby expression for sorting Dataverse records based on the user's description. +Format: column_name asc|desc, separated by commas for multi-column sort. +Examples: +- "name asc" - Sort by name alphabetically +- "createdon desc" - Sort by creation date, newest first +- "name asc, createdon desc" - Sort by name, then by date + +Return ONLY the orderby expression - no $orderby= prefix, no explanations.`, + placeholder: 'Describe how you want to sort the results...', + generationType: 'odata-expression', + }, + }, + { + id: 'top', + title: 'Max Results', + type: 'short-input', + placeholder: 'Maximum number of records (default: 5000)', + condition: { field: 'operation', value: ['list_records', 'search'] }, + mode: 'advanced', + }, + { + id: 'expand', + title: 'Expand', + type: 'short-input', + placeholder: 'Navigation properties to expand (e.g., primarycontactid)', + condition: { field: 'operation', value: ['list_records', 'get_record'] }, + mode: 'advanced', + wandConfig: { + enabled: true, + prompt: `Generate an OData $expand expression for the Dataverse Web API based on the user's description. +$expand retrieves related records through navigation properties. +Examples: +- "primarycontactid" - Expand the primary contact lookup +- "contact_customer_accounts" - Expand related contacts for an account +- "primarycontactid($select=fullname,emailaddress1)" - Expand with selected columns +- "contact_customer_accounts($select=fullname;$top=5;$orderby=fullname asc)" - Expand with query options + +Return ONLY the expand expression - no $expand= prefix, no explanations.`, + placeholder: 'Describe which related records you want to include...', + generationType: 'odata-expression', + }, + }, + // Associate/Disassociate + { + id: 'navigationProperty', + title: 'Navigation Property', + type: 'short-input', + placeholder: 'e.g., contact_customer_accounts', + condition: { field: 'operation', value: ['associate', 'disassociate'] }, + required: { field: 'operation', value: ['associate', 'disassociate'] }, + }, + { + id: 'navigationType', + title: 'Navigation Type', + type: 'dropdown', + options: [ + { label: 'Collection-valued (default)', id: 'collection' }, + { label: 'Single-valued (lookup)', id: 'single' }, + ], + value: () => 'collection', + condition: { field: 'operation', value: 'associate' }, + mode: 'advanced', + }, + { + id: 'targetEntitySetName', + title: 'Target Entity Set', + type: 'short-input', + placeholder: 'Target table name (e.g., contacts)', + condition: { field: 'operation', value: 'associate' }, + required: { field: 'operation', value: 'associate' }, + }, + { + id: 'targetRecordId', + title: 'Target Record ID', + type: 'short-input', + placeholder: 'Target record GUID', + condition: { field: 'operation', value: ['associate', 'disassociate'] }, + required: { field: 'operation', value: 'associate' }, + }, + ], + tools: { + access: [ + 'microsoft_dataverse_associate', + 'microsoft_dataverse_create_multiple', + 'microsoft_dataverse_create_record', + 'microsoft_dataverse_delete_record', + 'microsoft_dataverse_disassociate', + 'microsoft_dataverse_download_file', + 'microsoft_dataverse_execute_action', + 'microsoft_dataverse_execute_function', + 'microsoft_dataverse_fetchxml_query', + 'microsoft_dataverse_get_record', + 'microsoft_dataverse_list_records', + 'microsoft_dataverse_search', + 'microsoft_dataverse_update_multiple', + 'microsoft_dataverse_update_record', + 'microsoft_dataverse_upload_file', + 'microsoft_dataverse_upsert_record', + 'microsoft_dataverse_whoami', + ], + config: { + tool: (params) => `microsoft_dataverse_${params.operation}`, + params: (params) => { + const { credential, operation, file, ...rest } = params + + const cleanParams: Record = { + credential, + } + + // Normalize file input from basic (uploadFile) or advanced (fileReference) mode + const normalizedFile = normalizeFileInput(file, { single: true }) + if (normalizedFile) { + cleanParams.file = normalizedFile + } + + // Map block subBlock IDs to tool param names where they differ + if (operation === 'search' && rest.searchEntities) { + cleanParams.entities = rest.searchEntities + rest.searchEntities = undefined + } + if (operation === 'execute_function' && rest.functionParameters) { + cleanParams.parameters = rest.functionParameters + rest.functionParameters = undefined + // Prevent stale action parameters from overwriting mapped function parameters + rest.parameters = undefined + } + // Always clean up mapped subBlock IDs so they don't leak through the loop below + rest.searchEntities = undefined + rest.functionParameters = undefined + + Object.entries(rest).forEach(([key, value]) => { + if (value !== undefined && value !== null && value !== '') { + cleanParams[key] = value + } + }) + + return cleanParams + }, + }, + }, + inputs: { + operation: { type: 'string', description: 'Operation to perform' }, + credential: { type: 'string', description: 'Microsoft Dataverse OAuth credential' }, + environmentUrl: { type: 'string', description: 'Dataverse environment URL' }, + entitySetName: { type: 'string', description: 'Entity set name (plural table name)' }, + recordId: { type: 'string', description: 'Record GUID' }, + data: { type: 'json', description: 'Record data as JSON object' }, + select: { type: 'string', description: 'Columns to return (comma-separated)' }, + filter: { type: 'string', description: 'OData $filter expression' }, + orderBy: { type: 'string', description: 'OData $orderby expression' }, + top: { type: 'string', description: 'Maximum number of records' }, + expand: { type: 'string', description: 'Navigation properties to expand' }, + navigationProperty: { + type: 'string', + description: 'Navigation property name for associations', + }, + navigationType: { + type: 'string', + description: + 'Navigation property type: "collection" (default) or "single" (for lookup fields)', + }, + targetEntitySetName: { type: 'string', description: 'Target entity set for association' }, + targetRecordId: { type: 'string', description: 'Target record GUID for association' }, + fetchXml: { type: 'string', description: 'FetchXML query string' }, + searchTerm: { type: 'string', description: 'Search text for relevance search' }, + searchEntities: { type: 'string', description: 'JSON array of search entity configurations' }, + searchMode: { type: 'string', description: 'Search mode: "any" or "all"' }, + searchType: { type: 'string', description: 'Query type: "simple" or "lucene"' }, + actionName: { type: 'string', description: 'Dataverse action name to execute' }, + functionName: { type: 'string', description: 'Dataverse function name to execute' }, + functionParameters: { + type: 'string', + description: 'Function parameters as URL-encoded string', + }, + parameters: { type: 'json', description: 'Action parameters as JSON object' }, + entityLogicalName: { type: 'string', description: 'Table logical name for @odata.type' }, + records: { type: 'json', description: 'Array of record objects for bulk operations' }, + fileColumn: { type: 'string', description: 'File or image column logical name' }, + fileName: { type: 'string', description: 'Name of the file to upload' }, + file: { type: 'json', description: 'File to upload (canonical param)' }, + }, + outputs: { + records: { type: 'json', description: 'Array of records (list/fetchxml/search)' }, + record: { type: 'json', description: 'Single record data' }, + recordId: { type: 'string', description: 'Record ID' }, + count: { type: 'number', description: 'Number of records returned in the current page' }, + totalCount: { + type: 'number', + description: 'Total matching records server-side', + }, + nextLink: { type: 'string', description: 'URL for next page of results' }, + created: { type: 'boolean', description: 'Whether a new record was created (upsert)' }, + userId: { type: 'string', description: 'Authenticated user ID (WhoAmI)' }, + businessUnitId: { type: 'string', description: 'Business unit ID (WhoAmI)' }, + organizationId: { type: 'string', description: 'Organization ID (WhoAmI)' }, + entitySetName: { + type: 'string', + description: 'Source entity set name (associate/disassociate)', + }, + navigationProperty: { + type: 'string', + description: 'Navigation property used (associate/disassociate)', + }, + targetEntitySetName: { type: 'string', description: 'Target entity set name (associate)' }, + targetRecordId: { type: 'string', description: 'Target record GUID (associate/disassociate)' }, + success: { type: 'boolean', description: 'Operation success status' }, + result: { type: 'json', description: 'Action/function result data' }, + ids: { type: 'json', description: 'Array of created record IDs (create multiple)' }, + fetchXmlPagingCookie: { type: 'string', description: 'Paging cookie for FetchXML pagination' }, + moreRecords: { type: 'boolean', description: 'Whether more records are available (FetchXML)' }, + results: { type: 'json', description: 'Search results array' }, + facets: { type: 'json', description: 'Facet results for search (when facets requested)' }, + fileContent: { type: 'string', description: 'Base64-encoded downloaded file content' }, + fileName: { type: 'string', description: 'Downloaded file name' }, + fileSize: { type: 'number', description: 'File size in bytes' }, + mimeType: { type: 'string', description: 'File MIME type' }, + fileColumn: { type: 'string', description: 'File column name' }, + }, +} diff --git a/apps/sim/blocks/blocks/vercel.ts b/apps/sim/blocks/blocks/vercel.ts index 138b2c23a6..c49e37d017 100644 --- a/apps/sim/blocks/blocks/vercel.ts +++ b/apps/sim/blocks/blocks/vercel.ts @@ -99,6 +99,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Filter by project ID or name (optional)', condition: { field: 'operation', value: 'list_deployments' }, + mode: 'advanced', }, { id: 'target', @@ -110,6 +111,7 @@ export const VercelBlock: BlockConfig = { { label: 'Staging', id: 'staging' }, ], condition: { field: 'operation', value: 'list_deployments' }, + mode: 'advanced', }, { id: 'state', @@ -124,6 +126,7 @@ export const VercelBlock: BlockConfig = { { label: 'Canceled', id: 'CANCELED' }, ], condition: { field: 'operation', value: 'list_deployments' }, + mode: 'advanced', }, { id: 'deploymentId', @@ -166,6 +169,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Project ID (optional, overrides name)', condition: { field: 'operation', value: 'create_deployment' }, + mode: 'advanced', }, { id: 'redeployId', @@ -173,6 +177,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Existing deployment ID to redeploy (optional)', condition: { field: 'operation', value: 'create_deployment' }, + mode: 'advanced', }, { id: 'deployTarget', @@ -184,6 +189,7 @@ export const VercelBlock: BlockConfig = { { label: 'Staging', id: 'staging' }, ], condition: { field: 'operation', value: 'create_deployment' }, + mode: 'advanced', }, // === Project fields === @@ -193,6 +199,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Search projects by name (optional)', condition: { field: 'operation', value: 'list_projects' }, + mode: 'advanced', }, { id: 'projectId', @@ -259,6 +266,7 @@ export const VercelBlock: BlockConfig = { { label: 'Other', id: 'other' }, ], condition: { field: 'operation', value: ['create_project', 'update_project'] }, + mode: 'advanced', }, { id: 'buildCommand', @@ -266,6 +274,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Custom build command (optional)', condition: { field: 'operation', value: ['create_project', 'update_project'] }, + mode: 'advanced', }, { id: 'outputDirectory', @@ -273,6 +282,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Output directory (optional)', condition: { field: 'operation', value: ['create_project', 'update_project'] }, + mode: 'advanced', }, { id: 'installCommand', @@ -280,6 +290,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Install command (optional)', condition: { field: 'operation', value: ['create_project', 'update_project'] }, + mode: 'advanced', }, // === Project Domain fields === @@ -362,6 +373,7 @@ export const VercelBlock: BlockConfig = { { label: 'Sensitive', id: 'sensitive' }, ], condition: { field: 'operation', value: ['create_env_var', 'update_env_var'] }, + mode: 'advanced', }, // === DNS fields === @@ -489,6 +501,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Comma-separated project IDs (optional)', condition: { field: 'operation', value: 'create_webhook' }, + mode: 'advanced', }, { id: 'webhookId', @@ -553,6 +566,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'Page path being checked (optional)', condition: { field: 'operation', value: ['create_check', 'update_check'] }, + mode: 'advanced', }, { id: 'checkDetailsUrl', @@ -560,6 +574,7 @@ export const VercelBlock: BlockConfig = { type: 'short-input', placeholder: 'URL for more details (optional)', condition: { field: 'operation', value: ['create_check', 'update_check'] }, + mode: 'advanced', }, { id: 'checkStatus', @@ -607,6 +622,7 @@ export const VercelBlock: BlockConfig = { { label: 'Billing', id: 'BILLING' }, ], condition: { field: 'operation', value: 'list_team_members' }, + mode: 'advanced', }, // === Shared optional Team ID (for scoping requests) === @@ -629,6 +645,7 @@ export const VercelBlock: BlockConfig = { ], not: true, }, + mode: 'advanced', }, ], tools: { diff --git a/apps/sim/blocks/blocks/youtube.ts b/apps/sim/blocks/blocks/youtube.ts index b869954453..73c4c79a8c 100644 --- a/apps/sim/blocks/blocks/youtube.ts +++ b/apps/sim/blocks/blocks/youtube.ts @@ -50,6 +50,7 @@ export const YouTubeBlock: BlockConfig = { step: 1, integer: true, condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'pageToken', @@ -57,6 +58,7 @@ export const YouTubeBlock: BlockConfig = { type: 'short-input', placeholder: 'Token for pagination (from nextPageToken)', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'channelId', @@ -64,6 +66,7 @@ export const YouTubeBlock: BlockConfig = { type: 'short-input', placeholder: 'Filter results to a specific channel', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'eventType', @@ -77,6 +80,7 @@ export const YouTubeBlock: BlockConfig = { ], value: () => '', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'publishedAfter', @@ -84,6 +88,7 @@ export const YouTubeBlock: BlockConfig = { type: 'short-input', placeholder: '2024-01-01T00:00:00Z', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', wandConfig: { enabled: true, prompt: `Generate an ISO 8601 timestamp based on the user's description. @@ -106,6 +111,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: '2024-12-31T23:59:59Z', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', wandConfig: { enabled: true, prompt: `Generate an ISO 8601 timestamp based on the user's description. @@ -134,6 +140,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, ], value: () => 'any', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'order', @@ -148,6 +155,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, ], value: () => 'relevance', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'videoCategoryId', @@ -155,6 +163,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'Use Get Video Categories to find IDs', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'videoDefinition', @@ -167,6 +176,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, ], value: () => 'any', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'videoCaption', @@ -179,6 +189,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, ], value: () => 'any', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'regionCode', @@ -189,6 +200,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, field: 'operation', value: ['youtube_search', 'youtube_trending', 'youtube_video_categories'], }, + mode: 'advanced', }, { id: 'relevanceLanguage', @@ -196,6 +208,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'en, es, fr', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, { id: 'safeSearch', @@ -208,6 +221,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, ], value: () => 'moderate', condition: { field: 'operation', value: 'youtube_search' }, + mode: 'advanced', }, // Get Trending Videos operation inputs { @@ -226,6 +240,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'Use Get Video Categories to find IDs', condition: { field: 'operation', value: 'youtube_trending' }, + mode: 'advanced', }, { id: 'pageToken', @@ -233,6 +248,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'Token for pagination (from nextPageToken)', condition: { field: 'operation', value: 'youtube_trending' }, + mode: 'advanced', }, // Get Video Details operation inputs { @@ -250,6 +266,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'en, es, fr (for category names)', condition: { field: 'operation', value: 'youtube_video_categories' }, + mode: 'advanced', }, // Get Channel Info operation inputs { @@ -298,6 +315,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, ], value: () => 'date', condition: { field: 'operation', value: 'youtube_channel_videos' }, + mode: 'advanced', }, { id: 'pageToken', @@ -305,6 +323,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'Token for pagination (from nextPageToken)', condition: { field: 'operation', value: 'youtube_channel_videos' }, + mode: 'advanced', }, // Get Channel Playlists operation inputs { @@ -331,6 +350,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'Token for pagination (from nextPageToken)', condition: { field: 'operation', value: 'youtube_channel_playlists' }, + mode: 'advanced', }, // Get Playlist Items operation inputs { @@ -357,6 +377,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'Token for pagination (from nextPageToken)', condition: { field: 'operation', value: 'youtube_playlist_items' }, + mode: 'advanced', }, // Get Video Comments operation inputs { @@ -387,6 +408,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, ], value: () => 'relevance', condition: { field: 'operation', value: 'youtube_comments' }, + mode: 'advanced', }, { id: 'pageToken', @@ -394,6 +416,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`, type: 'short-input', placeholder: 'Token for pagination (from nextPageToken)', condition: { field: 'operation', value: 'youtube_comments' }, + mode: 'advanced', }, // API Key (common to all operations) { diff --git a/apps/sim/blocks/registry.ts b/apps/sim/blocks/registry.ts index bb3193fd1f..ee118b08b7 100644 --- a/apps/sim/blocks/registry.ts +++ b/apps/sim/blocks/registry.ts @@ -16,6 +16,7 @@ import { ChatTriggerBlock } from '@/blocks/blocks/chat_trigger' import { CirclebackBlock } from '@/blocks/blocks/circleback' import { ClayBlock } from '@/blocks/blocks/clay' import { ClerkBlock } from '@/blocks/blocks/clerk' +import { CloudflareBlock } from '@/blocks/blocks/cloudflare' import { ConditionBlock } from '@/blocks/blocks/condition' import { ConfluenceBlock, ConfluenceV2Block } from '@/blocks/blocks/confluence' import { CursorBlock, CursorV2Block } from '@/blocks/blocks/cursor' @@ -78,6 +79,7 @@ import { ManualTriggerBlock } from '@/blocks/blocks/manual_trigger' import { McpBlock } from '@/blocks/blocks/mcp' import { Mem0Block } from '@/blocks/blocks/mem0' import { MemoryBlock } from '@/blocks/blocks/memory' +import { MicrosoftDataverseBlock } from '@/blocks/blocks/microsoft_dataverse' import { MicrosoftExcelBlock, MicrosoftExcelV2Block } from '@/blocks/blocks/microsoft_excel' import { MicrosoftPlannerBlock } from '@/blocks/blocks/microsoft_planner' import { MicrosoftTeamsBlock } from '@/blocks/blocks/microsoft_teams' @@ -183,6 +185,7 @@ export const registry: Record = { calendly: CalendlyBlock, chat_trigger: ChatTriggerBlock, circleback: CirclebackBlock, + cloudflare: CloudflareBlock, clay: ClayBlock, clerk: ClerkBlock, condition: ConditionBlock, @@ -259,6 +262,7 @@ export const registry: Record = { mcp: McpBlock, mem0: Mem0Block, memory: MemoryBlock, + microsoft_dataverse: MicrosoftDataverseBlock, microsoft_excel: MicrosoftExcelBlock, microsoft_excel_v2: MicrosoftExcelV2Block, microsoft_planner: MicrosoftPlannerBlock, diff --git a/apps/sim/blocks/types.ts b/apps/sim/blocks/types.ts index 30158d7347..96c1b6263c 100644 --- a/apps/sim/blocks/types.ts +++ b/apps/sim/blocks/types.ts @@ -41,6 +41,7 @@ export type GenerationType = | 'timestamp' | 'timezone' | 'cron-expression' + | 'odata-expression' export type SubBlockType = | 'short-input' // Single line input diff --git a/apps/sim/components/icons.tsx b/apps/sim/components/icons.tsx index c31380d81c..53c643f4ba 100644 --- a/apps/sim/components/icons.tsx +++ b/apps/sim/components/icons.tsx @@ -4407,6 +4407,161 @@ export function DatadogIcon(props: SVGProps) { ) } +export function MicrosoftDataverseIcon(props: SVGProps) { + const id = useId() + const clip0 = `dataverse_clip0_${id}` + const clip1 = `dataverse_clip1_${id}` + const clip2 = `dataverse_clip2_${id}` + const paint0 = `dataverse_paint0_${id}` + const paint1 = `dataverse_paint1_${id}` + const paint2 = `dataverse_paint2_${id}` + const paint3 = `dataverse_paint3_${id}` + const paint4 = `dataverse_paint4_${id}` + const paint5 = `dataverse_paint5_${id}` + const paint6 = `dataverse_paint6_${id}` + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) +} + export function KalshiIcon(props: SVGProps) { return ( @@ -5547,3 +5702,18 @@ export function VercelIcon(props: SVGProps) { ) } + +export function CloudflareIcon(props: SVGProps) { + return ( + + + + + ) +} diff --git a/apps/sim/lib/auth/auth.ts b/apps/sim/lib/auth/auth.ts index 4bfc800386..93555f7516 100644 --- a/apps/sim/lib/auth/auth.ts +++ b/apps/sim/lib/auth/auth.ts @@ -395,6 +395,7 @@ export const auth = betterAuth({ 'google-groups', 'vertex-ai', 'github-repo', + 'microsoft-dataverse', 'microsoft-teams', 'microsoft-excel', 'microsoft-planner', @@ -1153,6 +1154,54 @@ export const auth = betterAuth({ } }, }, + { + providerId: 'microsoft-dataverse', + clientId: env.MICROSOFT_CLIENT_ID as string, + clientSecret: env.MICROSOFT_CLIENT_SECRET as string, + authorizationUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize', + tokenUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/token', + userInfoUrl: 'https://graph.microsoft.com/v1.0/me', + scopes: [ + 'openid', + 'profile', + 'email', + 'https://dynamics.microsoft.com/user_impersonation', + 'offline_access', + ], + responseType: 'code', + accessType: 'offline', + authentication: 'basic', + pkce: true, + redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/microsoft-dataverse`, + getUserInfo: async (tokens) => { + // Dataverse access tokens target dynamics.microsoft.com, not graph.microsoft.com, + // so we cannot call the Graph API /me endpoint. Instead, we decode the ID token JWT + // which is always returned when the openid scope is requested. + const idToken = (tokens as Record).idToken as string | undefined + if (!idToken) { + logger.error( + 'Microsoft Dataverse OAuth: no ID token received. Ensure openid scope is requested.' + ) + throw new Error('Microsoft Dataverse OAuth requires an ID token (openid scope)') + } + + const parts = idToken.split('.') + if (parts.length !== 3) { + throw new Error('Microsoft Dataverse OAuth: malformed ID token') + } + + const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf-8')) + const now = new Date() + return { + id: `${payload.oid || payload.sub}-${crypto.randomUUID()}`, + name: payload.name || 'Microsoft User', + email: payload.preferred_username || payload.email || payload.upn, + emailVerified: true, + createdAt: now, + updatedAt: now, + } + }, + }, { providerId: 'microsoft-planner', clientId: env.MICROSOFT_CLIENT_ID as string, diff --git a/apps/sim/lib/oauth/microsoft.ts b/apps/sim/lib/oauth/microsoft.ts index f512ee1e63..cb6c68382a 100644 --- a/apps/sim/lib/oauth/microsoft.ts +++ b/apps/sim/lib/oauth/microsoft.ts @@ -2,6 +2,7 @@ export const MICROSOFT_REFRESH_TOKEN_LIFETIME_DAYS = 90 export const PROACTIVE_REFRESH_THRESHOLD_DAYS = 7 export const MICROSOFT_PROVIDERS = new Set([ + 'microsoft-dataverse', 'microsoft-excel', 'microsoft-planner', 'microsoft-teams', diff --git a/apps/sim/lib/oauth/oauth.ts b/apps/sim/lib/oauth/oauth.ts index 7bb11ca357..11d91f6495 100644 --- a/apps/sim/lib/oauth/oauth.ts +++ b/apps/sim/lib/oauth/oauth.ts @@ -18,6 +18,7 @@ import { JiraIcon, LinearIcon, LinkedInIcon, + MicrosoftDataverseIcon, MicrosoftExcelIcon, MicrosoftIcon, MicrosoftOneDriveIcon, @@ -154,6 +155,20 @@ export const OAUTH_PROVIDERS: Record = { name: 'Microsoft', icon: MicrosoftIcon, services: { + 'microsoft-dataverse': { + name: 'Microsoft Dataverse', + description: 'Connect to Microsoft Dataverse and manage records.', + providerId: 'microsoft-dataverse', + icon: MicrosoftDataverseIcon, + baseProviderIcon: MicrosoftIcon, + scopes: [ + 'openid', + 'profile', + 'email', + 'https://dynamics.microsoft.com/user_impersonation', + 'offline_access', + ], + }, 'microsoft-excel': { name: 'Microsoft Excel', description: 'Connect to Microsoft Excel and manage spreadsheets.', diff --git a/apps/sim/lib/oauth/types.ts b/apps/sim/lib/oauth/types.ts index 961c7a0b1c..22e1dfbcc7 100644 --- a/apps/sim/lib/oauth/types.ts +++ b/apps/sim/lib/oauth/types.ts @@ -20,6 +20,7 @@ export type OAuthProvider = | 'jira' | 'dropbox' | 'microsoft' + | 'microsoft-dataverse' | 'microsoft-excel' | 'microsoft-planner' | 'microsoft-teams' @@ -61,6 +62,7 @@ export type OAuthService = | 'notion' | 'jira' | 'dropbox' + | 'microsoft-dataverse' | 'microsoft-excel' | 'microsoft-teams' | 'microsoft-planner' diff --git a/apps/sim/tools/cloudflare/create_dns_record.ts b/apps/sim/tools/cloudflare/create_dns_record.ts new file mode 100644 index 0000000000..a962ce7277 --- /dev/null +++ b/apps/sim/tools/cloudflare/create_dns_record.ts @@ -0,0 +1,211 @@ +import type { + CloudflareCreateDnsRecordParams, + CloudflareCreateDnsRecordResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const createDnsRecordTool: ToolConfig< + CloudflareCreateDnsRecordParams, + CloudflareCreateDnsRecordResponse +> = { + id: 'cloudflare_create_dns_record', + name: 'Cloudflare Create DNS Record', + description: 'Creates a new DNS record for a zone.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to create the DNS record in', + }, + type: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'DNS record type (e.g., "A", "AAAA", "CNAME", "MX", "TXT", "NS", "SRV")', + }, + name: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'DNS record name (e.g., "example.com" or "subdomain.example.com")', + }, + content: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'DNS record content (e.g., IP address for A records, target for CNAME)', + }, + ttl: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Time to live in seconds (1 = automatic, default: 1)', + }, + proxied: { + type: 'boolean', + required: false, + visibility: 'user-or-llm', + description: 'Whether to enable Cloudflare proxy (default: false)', + }, + priority: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Priority for MX and SRV records', + }, + comment: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comment for the DNS record', + }, + tags: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated tags for the DNS record', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => `https://api.cloudflare.com/client/v4/zones/${params.zoneId}/dns_records`, + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + body: (params) => { + const body: Record = { + type: params.type, + name: params.name, + content: params.content, + } + if (params.ttl !== undefined) body.ttl = Number(params.ttl) + if (params.proxied !== undefined) body.proxied = params.proxied + if (params.priority !== undefined) body.priority = Number(params.priority) + if (params.comment) body.comment = params.comment + if (params.tags) { + const tagList = String(params.tags) + .split(',') + .map((t) => t.trim()) + .filter(Boolean) + if (tagList.length > 0) body.tags = tagList + } + return body + }, + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { + id: '', + zone_id: '', + zone_name: '', + type: '', + name: '', + content: '', + proxiable: false, + proxied: false, + ttl: 0, + locked: false, + priority: undefined, + comment: null, + tags: [], + comment_modified_on: null, + tags_modified_on: null, + meta: null, + created_on: '', + modified_on: '', + }, + error: data.errors?.[0]?.message ?? 'Failed to create DNS record', + } + } + + const record = data.result + return { + success: true, + output: { + id: record?.id ?? '', + zone_id: record?.zone_id ?? '', + zone_name: record?.zone_name ?? '', + type: record?.type ?? '', + name: record?.name ?? '', + content: record?.content ?? '', + proxiable: record?.proxiable ?? false, + proxied: record?.proxied ?? false, + ttl: record?.ttl ?? 0, + locked: record?.locked ?? false, + priority: record?.priority ?? null, + comment: record?.comment ?? null, + tags: record?.tags ?? [], + comment_modified_on: record?.comment_modified_on ?? null, + tags_modified_on: record?.tags_modified_on ?? null, + meta: record?.meta ?? null, + created_on: record?.created_on ?? '', + modified_on: record?.modified_on ?? '', + }, + } + }, + + outputs: { + id: { type: 'string', description: 'Unique identifier for the created DNS record' }, + zone_id: { type: 'string', description: 'The ID of the zone the record belongs to' }, + zone_name: { type: 'string', description: 'The name of the zone' }, + type: { type: 'string', description: 'DNS record type (A, AAAA, CNAME, MX, TXT, etc.)' }, + name: { type: 'string', description: 'DNS record hostname' }, + content: { + type: 'string', + description: 'DNS record value (e.g., IP address, target hostname)', + }, + proxiable: { + type: 'boolean', + description: 'Whether the record can be proxied through Cloudflare', + }, + proxied: { type: 'boolean', description: 'Whether Cloudflare proxy is enabled' }, + ttl: { type: 'number', description: 'Time to live in seconds (1 = automatic)' }, + locked: { type: 'boolean', description: 'Whether the record is locked' }, + priority: { type: 'number', description: 'Priority for MX and SRV records', optional: true }, + comment: { type: 'string', description: 'Comment associated with the record', optional: true }, + tags: { + type: 'array', + description: 'Tags associated with the record', + items: { type: 'string', description: 'Tag value' }, + }, + comment_modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the comment was last modified', + optional: true, + }, + tags_modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when tags were last modified', + optional: true, + }, + meta: { + type: 'object', + description: 'Record metadata', + optional: true, + properties: { + source: { type: 'string', description: 'Source of the DNS record' }, + }, + }, + created_on: { type: 'string', description: 'ISO 8601 timestamp when the record was created' }, + modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the record was last modified', + }, + }, +} diff --git a/apps/sim/tools/cloudflare/create_zone.ts b/apps/sim/tools/cloudflare/create_zone.ts new file mode 100644 index 0000000000..81209328bd --- /dev/null +++ b/apps/sim/tools/cloudflare/create_zone.ts @@ -0,0 +1,253 @@ +import type { + CloudflareCreateZoneParams, + CloudflareCreateZoneResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const createZoneTool: ToolConfig = + { + id: 'cloudflare_create_zone', + name: 'Cloudflare Create Zone', + description: 'Adds a new zone (domain) to the Cloudflare account.', + version: '1.0.0', + + params: { + name: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The domain name to add (e.g., "example.com")', + }, + accountId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The Cloudflare account ID', + }, + type: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Zone type: "full" (Cloudflare manages DNS), "partial" (CNAME setup), or "secondary" (secondary DNS)', + }, + jump_start: { + type: 'boolean', + required: false, + visibility: 'user-or-llm', + description: 'Automatically attempt to fetch existing DNS records when creating the zone', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: 'https://api.cloudflare.com/client/v4/zones', + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + body: (params) => { + const body: Record = { + name: params.name, + account: { id: params.accountId }, + } + if (params.type) body.type = params.type + if (params.jump_start !== undefined) body.jump_start = params.jump_start + return body + }, + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { + id: '', + name: '', + status: '', + paused: false, + type: '', + name_servers: [], + original_name_servers: [], + created_on: '', + modified_on: '', + activated_on: '', + development_mode: 0, + plan: { + id: '', + name: '', + price: 0, + is_subscribed: false, + frequency: '', + currency: '', + legacy_id: '', + }, + account: { id: '', name: '' }, + owner: { id: '', name: '', type: '' }, + meta: { + cdn_only: false, + custom_certificate_quota: 0, + dns_only: false, + foundation_dns: false, + page_rule_quota: 0, + phishing_detected: false, + step: 0, + }, + vanity_name_servers: [], + permissions: [], + }, + error: data.errors?.[0]?.message ?? 'Failed to create zone', + } + } + + const zone = data.result + return { + success: true, + output: { + id: zone?.id ?? '', + name: zone?.name ?? '', + status: zone?.status ?? '', + paused: zone?.paused ?? false, + type: zone?.type ?? '', + name_servers: zone?.name_servers ?? [], + original_name_servers: zone?.original_name_servers ?? [], + created_on: zone?.created_on ?? '', + modified_on: zone?.modified_on ?? '', + activated_on: zone?.activated_on ?? '', + development_mode: zone?.development_mode ?? 0, + plan: { + id: zone?.plan?.id ?? '', + name: zone?.plan?.name ?? '', + price: zone?.plan?.price ?? 0, + is_subscribed: zone?.plan?.is_subscribed ?? false, + frequency: zone?.plan?.frequency ?? '', + currency: zone?.plan?.currency ?? '', + legacy_id: zone?.plan?.legacy_id ?? '', + }, + account: { + id: zone?.account?.id ?? '', + name: zone?.account?.name ?? '', + }, + owner: { + id: zone?.owner?.id ?? '', + name: zone?.owner?.name ?? '', + type: zone?.owner?.type ?? '', + }, + meta: { + cdn_only: zone?.meta?.cdn_only ?? false, + custom_certificate_quota: zone?.meta?.custom_certificate_quota ?? 0, + dns_only: zone?.meta?.dns_only ?? false, + foundation_dns: zone?.meta?.foundation_dns ?? false, + page_rule_quota: zone?.meta?.page_rule_quota ?? 0, + phishing_detected: zone?.meta?.phishing_detected ?? false, + step: zone?.meta?.step ?? 0, + }, + vanity_name_servers: zone?.vanity_name_servers ?? [], + permissions: zone?.permissions ?? [], + }, + } + }, + + outputs: { + id: { type: 'string', description: 'Created zone ID' }, + name: { type: 'string', description: 'Domain name' }, + status: { + type: 'string', + description: 'Zone status (initializing, pending, active, moved)', + }, + paused: { type: 'boolean', description: 'Whether the zone is paused' }, + type: { type: 'string', description: 'Zone type (full, partial, or secondary)' }, + name_servers: { + type: 'array', + description: 'Assigned Cloudflare name servers', + items: { type: 'string', description: 'Name server hostname' }, + }, + original_name_servers: { + type: 'array', + description: 'Original name servers before moving to Cloudflare', + items: { type: 'string', description: 'Name server hostname' }, + optional: true, + }, + created_on: { type: 'string', description: 'ISO 8601 date when the zone was created' }, + modified_on: { + type: 'string', + description: 'ISO 8601 date when the zone was last modified', + }, + activated_on: { + type: 'string', + description: 'ISO 8601 date when the zone was activated', + optional: true, + }, + development_mode: { + type: 'number', + description: 'Seconds remaining in development mode (0 = off)', + }, + plan: { + type: 'object', + description: 'Zone plan information', + properties: { + id: { type: 'string', description: 'Plan identifier' }, + name: { type: 'string', description: 'Plan name' }, + price: { type: 'number', description: 'Plan price' }, + is_subscribed: { + type: 'boolean', + description: 'Whether the zone is subscribed to the plan', + }, + frequency: { type: 'string', description: 'Plan billing frequency' }, + currency: { type: 'string', description: 'Plan currency' }, + legacy_id: { type: 'string', description: 'Legacy plan identifier' }, + }, + }, + account: { + type: 'object', + description: 'Account the zone belongs to', + properties: { + id: { type: 'string', description: 'Account identifier' }, + name: { type: 'string', description: 'Account name' }, + }, + }, + owner: { + type: 'object', + description: 'Zone owner information', + properties: { + id: { type: 'string', description: 'Owner identifier' }, + name: { type: 'string', description: 'Owner name' }, + type: { type: 'string', description: 'Owner type' }, + }, + }, + meta: { + type: 'object', + description: 'Zone metadata', + properties: { + cdn_only: { type: 'boolean', description: 'Whether the zone is CDN only' }, + custom_certificate_quota: { type: 'number', description: 'Custom certificate quota' }, + dns_only: { type: 'boolean', description: 'Whether the zone is DNS only' }, + foundation_dns: { type: 'boolean', description: 'Whether foundation DNS is enabled' }, + page_rule_quota: { type: 'number', description: 'Page rule quota' }, + phishing_detected: { type: 'boolean', description: 'Whether phishing was detected' }, + step: { type: 'number', description: 'Current setup step' }, + }, + optional: true, + }, + vanity_name_servers: { + type: 'array', + description: 'Custom vanity name servers', + items: { type: 'string', description: 'Vanity name server hostname' }, + optional: true, + }, + permissions: { + type: 'array', + description: 'User permissions for the zone', + items: { type: 'string', description: 'Permission string' }, + optional: true, + }, + }, + } diff --git a/apps/sim/tools/cloudflare/delete_dns_record.ts b/apps/sim/tools/cloudflare/delete_dns_record.ts new file mode 100644 index 0000000000..4e6bced66f --- /dev/null +++ b/apps/sim/tools/cloudflare/delete_dns_record.ts @@ -0,0 +1,69 @@ +import type { + CloudflareDeleteDnsRecordParams, + CloudflareDeleteDnsRecordResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const deleteDnsRecordTool: ToolConfig< + CloudflareDeleteDnsRecordParams, + CloudflareDeleteDnsRecordResponse +> = { + id: 'cloudflare_delete_dns_record', + name: 'Cloudflare Delete DNS Record', + description: 'Deletes a DNS record from a zone.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID containing the DNS record', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The DNS record ID to delete', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => + `https://api.cloudflare.com/client/v4/zones/${params.zoneId}/dns_records/${params.recordId}`, + method: 'DELETE', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { id: '' }, + error: data.errors?.[0]?.message ?? 'Failed to delete DNS record', + } + } + + return { + success: true, + output: { + id: data.result?.id ?? '', + }, + } + }, + + outputs: { + id: { type: 'string', description: 'Deleted record ID' }, + }, +} diff --git a/apps/sim/tools/cloudflare/delete_zone.ts b/apps/sim/tools/cloudflare/delete_zone.ts new file mode 100644 index 0000000000..7cf1522996 --- /dev/null +++ b/apps/sim/tools/cloudflare/delete_zone.ts @@ -0,0 +1,60 @@ +import type { + CloudflareDeleteZoneParams, + CloudflareDeleteZoneResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const deleteZoneTool: ToolConfig = + { + id: 'cloudflare_delete_zone', + name: 'Cloudflare Delete Zone', + description: 'Deletes a zone (domain) from the Cloudflare account.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to delete', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => `https://api.cloudflare.com/client/v4/zones/${params.zoneId}`, + method: 'DELETE', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { id: '' }, + error: data.errors?.[0]?.message ?? 'Failed to delete zone', + } + } + + return { + success: true, + output: { + id: data.result?.id ?? '', + }, + } + }, + + outputs: { + id: { type: 'string', description: 'Deleted zone ID' }, + }, + } diff --git a/apps/sim/tools/cloudflare/dns_analytics.ts b/apps/sim/tools/cloudflare/dns_analytics.ts new file mode 100644 index 0000000000..93525b6562 --- /dev/null +++ b/apps/sim/tools/cloudflare/dns_analytics.ts @@ -0,0 +1,346 @@ +import type { + CloudflareDnsAnalyticsParams, + CloudflareDnsAnalyticsResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const dnsAnalyticsTool: ToolConfig< + CloudflareDnsAnalyticsParams, + CloudflareDnsAnalyticsResponse +> = { + id: 'cloudflare_dns_analytics', + name: 'Cloudflare DNS Analytics', + description: 'Gets DNS analytics report for a zone including query counts and trends.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to get DNS analytics for', + }, + since: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Start date for analytics (ISO 8601, e.g., "2024-01-01T00:00:00Z") or relative (e.g., "-6h")', + }, + until: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'End date for analytics (ISO 8601, e.g., "2024-01-31T23:59:59Z") or relative (e.g., "now")', + }, + metrics: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Comma-separated metrics to retrieve (e.g., "queryCount,uncachedCount,staleCount,responseTimeAvg,responseTimeMedian,responseTime90th,responseTime99th")', + }, + dimensions: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Comma-separated dimensions to group by (e.g., "queryName,queryType,responseCode,responseCached,coloName,origin,dayOfWeek,tcp,ipVersion,querySizeBucket,responseSizeBucket")', + }, + filters: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filters to apply to the data (e.g., "queryType==A")', + }, + sort: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Sort order for the result set. Fields must be included in metrics or dimensions (e.g., "+queryCount" or "-responseTimeAvg")', + }, + limit: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Maximum number of results to return', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => { + const url = new URL( + `https://api.cloudflare.com/client/v4/zones/${params.zoneId}/dns_analytics/report` + ) + if (params.since) url.searchParams.append('since', params.since) + if (params.until) url.searchParams.append('until', params.until) + if (params.metrics) url.searchParams.append('metrics', params.metrics) + if (params.dimensions) url.searchParams.append('dimensions', params.dimensions) + if (params.filters) url.searchParams.append('filters', params.filters) + if (params.sort) url.searchParams.append('sort', params.sort) + if (params.limit) url.searchParams.append('limit', String(params.limit)) + return url.toString() + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { + totals: { + queryCount: 0, + uncachedCount: 0, + staleCount: 0, + responseTimeAvg: 0, + responseTimeMedian: 0, + responseTime90th: 0, + responseTime99th: 0, + }, + min: { + queryCount: 0, + uncachedCount: 0, + staleCount: 0, + responseTimeAvg: 0, + responseTimeMedian: 0, + responseTime90th: 0, + responseTime99th: 0, + }, + max: { + queryCount: 0, + uncachedCount: 0, + staleCount: 0, + responseTimeAvg: 0, + responseTimeMedian: 0, + responseTime90th: 0, + responseTime99th: 0, + }, + data: [], + data_lag: 0, + rows: 0, + query: { + since: '', + until: '', + metrics: [], + dimensions: [], + filters: '', + sort: [], + limit: 0, + }, + }, + error: data.errors?.[0]?.message ?? 'Failed to get DNS analytics', + } + } + + const result = data.result + return { + success: true, + output: { + totals: { + queryCount: result?.totals?.queryCount ?? 0, + uncachedCount: result?.totals?.uncachedCount ?? 0, + staleCount: result?.totals?.staleCount ?? 0, + responseTimeAvg: result?.totals?.responseTimeAvg ?? 0, + responseTimeMedian: result?.totals?.responseTimeMedian ?? 0, + responseTime90th: result?.totals?.responseTime90th ?? 0, + responseTime99th: result?.totals?.responseTime99th ?? 0, + }, + min: { + queryCount: result?.min?.queryCount ?? 0, + uncachedCount: result?.min?.uncachedCount ?? 0, + staleCount: result?.min?.staleCount ?? 0, + responseTimeAvg: result?.min?.responseTimeAvg ?? 0, + responseTimeMedian: result?.min?.responseTimeMedian ?? 0, + responseTime90th: result?.min?.responseTime90th ?? 0, + responseTime99th: result?.min?.responseTime99th ?? 0, + }, + max: { + queryCount: result?.max?.queryCount ?? 0, + uncachedCount: result?.max?.uncachedCount ?? 0, + staleCount: result?.max?.staleCount ?? 0, + responseTimeAvg: result?.max?.responseTimeAvg ?? 0, + responseTimeMedian: result?.max?.responseTimeMedian ?? 0, + responseTime90th: result?.max?.responseTime90th ?? 0, + responseTime99th: result?.max?.responseTime99th ?? 0, + }, + data: + result?.data?.map((entry: any) => ({ + dimensions: entry.dimensions ?? [], + metrics: entry.metrics ?? [], + })) ?? [], + data_lag: result?.data_lag ?? 0, + rows: result?.rows ?? 0, + query: { + since: result?.query?.since ?? '', + until: result?.query?.until ?? '', + metrics: result?.query?.metrics ?? [], + dimensions: result?.query?.dimensions ?? [], + filters: result?.query?.filters ?? '', + sort: result?.query?.sort ?? [], + limit: result?.query?.limit ?? 0, + }, + }, + } + }, + + outputs: { + totals: { + type: 'object', + description: 'Aggregate DNS analytics totals for the entire queried period', + properties: { + queryCount: { type: 'number', description: 'Total number of DNS queries' }, + uncachedCount: { type: 'number', description: 'Number of uncached DNS queries' }, + staleCount: { type: 'number', description: 'Number of stale DNS queries' }, + responseTimeAvg: { + type: 'number', + description: 'Average response time in milliseconds', + optional: true, + }, + responseTimeMedian: { + type: 'number', + description: 'Median response time in milliseconds', + optional: true, + }, + responseTime90th: { + type: 'number', + description: '90th percentile response time in milliseconds', + optional: true, + }, + responseTime99th: { + type: 'number', + description: '99th percentile response time in milliseconds', + optional: true, + }, + }, + }, + min: { + type: 'object', + description: 'Minimum values across the analytics period', + optional: true, + properties: { + queryCount: { type: 'number', description: 'Minimum number of DNS queries' }, + uncachedCount: { type: 'number', description: 'Minimum number of uncached DNS queries' }, + staleCount: { type: 'number', description: 'Minimum number of stale DNS queries' }, + responseTimeAvg: { + type: 'number', + description: 'Minimum average response time in milliseconds', + optional: true, + }, + responseTimeMedian: { + type: 'number', + description: 'Minimum median response time in milliseconds', + optional: true, + }, + responseTime90th: { + type: 'number', + description: 'Minimum 90th percentile response time in milliseconds', + optional: true, + }, + responseTime99th: { + type: 'number', + description: 'Minimum 99th percentile response time in milliseconds', + optional: true, + }, + }, + }, + max: { + type: 'object', + description: 'Maximum values across the analytics period', + optional: true, + properties: { + queryCount: { type: 'number', description: 'Maximum number of DNS queries' }, + uncachedCount: { type: 'number', description: 'Maximum number of uncached DNS queries' }, + staleCount: { type: 'number', description: 'Maximum number of stale DNS queries' }, + responseTimeAvg: { + type: 'number', + description: 'Maximum average response time in milliseconds', + optional: true, + }, + responseTimeMedian: { + type: 'number', + description: 'Maximum median response time in milliseconds', + optional: true, + }, + responseTime90th: { + type: 'number', + description: 'Maximum 90th percentile response time in milliseconds', + optional: true, + }, + responseTime99th: { + type: 'number', + description: 'Maximum 99th percentile response time in milliseconds', + optional: true, + }, + }, + }, + data: { + type: 'array', + description: 'Raw analytics data rows returned by the Cloudflare DNS analytics report', + items: { + type: 'object', + properties: { + dimensions: { + type: 'array', + description: + 'Dimension values for this data row, parallel to the requested dimensions list', + items: { type: 'string', description: 'Dimension value' }, + }, + metrics: { + type: 'array', + description: 'Metric values for this data row, parallel to the requested metrics list', + items: { type: 'number', description: 'Metric value' }, + }, + }, + }, + }, + data_lag: { + type: 'number', + description: 'Processing lag in seconds before analytics data becomes available', + }, + rows: { + type: 'number', + description: 'Total number of rows in the result set', + }, + query: { + type: 'object', + description: 'Echo of the query parameters sent to the API', + optional: true, + properties: { + since: { type: 'string', description: 'Start date of the analytics query' }, + until: { type: 'string', description: 'End date of the analytics query' }, + metrics: { + type: 'array', + description: 'Metrics requested in the query', + items: { type: 'string', description: 'Metric name' }, + }, + dimensions: { + type: 'array', + description: 'Dimensions requested in the query', + items: { type: 'string', description: 'Dimension name' }, + }, + filters: { type: 'string', description: 'Filters applied to the query' }, + sort: { + type: 'array', + description: 'Sort order applied to the query', + items: { type: 'string', description: 'Sort field with direction prefix' }, + }, + limit: { type: 'number', description: 'Maximum number of results requested' }, + }, + }, + }, +} diff --git a/apps/sim/tools/cloudflare/get_zone.ts b/apps/sim/tools/cloudflare/get_zone.ts new file mode 100644 index 0000000000..2e926a0f6f --- /dev/null +++ b/apps/sim/tools/cloudflare/get_zone.ts @@ -0,0 +1,218 @@ +import type { CloudflareGetZoneParams, CloudflareGetZoneResponse } from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const getZoneTool: ToolConfig = { + id: 'cloudflare_get_zone', + name: 'Cloudflare Get Zone', + description: 'Gets details for a specific zone (domain) by its ID.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to retrieve details for', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => `https://api.cloudflare.com/client/v4/zones/${params.zoneId}`, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { + id: '', + name: '', + status: '', + paused: false, + type: '', + name_servers: [], + original_name_servers: [], + created_on: '', + modified_on: '', + activated_on: '', + development_mode: 0, + plan: { + id: '', + name: '', + price: 0, + is_subscribed: false, + frequency: '', + currency: '', + legacy_id: '', + }, + account: { id: '', name: '' }, + owner: { id: '', name: '', type: '' }, + meta: { + cdn_only: false, + custom_certificate_quota: 0, + dns_only: false, + foundation_dns: false, + page_rule_quota: 0, + phishing_detected: false, + step: 0, + }, + vanity_name_servers: [], + permissions: [], + }, + error: data.errors?.[0]?.message ?? 'Failed to get zone', + } + } + + const zone = data.result + return { + success: true, + output: { + id: zone?.id ?? '', + name: zone?.name ?? '', + status: zone?.status ?? '', + paused: zone?.paused ?? false, + type: zone?.type ?? '', + name_servers: zone?.name_servers ?? [], + original_name_servers: zone?.original_name_servers ?? [], + created_on: zone?.created_on ?? '', + modified_on: zone?.modified_on ?? '', + activated_on: zone?.activated_on ?? '', + development_mode: zone?.development_mode ?? 0, + plan: { + id: zone?.plan?.id ?? '', + name: zone?.plan?.name ?? '', + price: zone?.plan?.price ?? 0, + is_subscribed: zone?.plan?.is_subscribed ?? false, + frequency: zone?.plan?.frequency ?? '', + currency: zone?.plan?.currency ?? '', + legacy_id: zone?.plan?.legacy_id ?? '', + }, + account: { + id: zone?.account?.id ?? '', + name: zone?.account?.name ?? '', + }, + owner: { + id: zone?.owner?.id ?? '', + name: zone?.owner?.name ?? '', + type: zone?.owner?.type ?? '', + }, + meta: { + cdn_only: zone?.meta?.cdn_only ?? false, + custom_certificate_quota: zone?.meta?.custom_certificate_quota ?? 0, + dns_only: zone?.meta?.dns_only ?? false, + foundation_dns: zone?.meta?.foundation_dns ?? false, + page_rule_quota: zone?.meta?.page_rule_quota ?? 0, + phishing_detected: zone?.meta?.phishing_detected ?? false, + step: zone?.meta?.step ?? 0, + }, + vanity_name_servers: zone?.vanity_name_servers ?? [], + permissions: zone?.permissions ?? [], + }, + } + }, + + outputs: { + id: { type: 'string', description: 'Zone ID' }, + name: { type: 'string', description: 'Domain name' }, + status: { + type: 'string', + description: 'Zone status (initializing, pending, active, moved)', + }, + paused: { type: 'boolean', description: 'Whether the zone is paused' }, + type: { type: 'string', description: 'Zone type (full, partial, or secondary)' }, + name_servers: { + type: 'array', + description: 'Assigned Cloudflare name servers', + items: { type: 'string', description: 'Name server hostname' }, + }, + original_name_servers: { + type: 'array', + description: 'Original name servers before moving to Cloudflare', + items: { type: 'string', description: 'Name server hostname' }, + optional: true, + }, + created_on: { type: 'string', description: 'ISO 8601 date when the zone was created' }, + modified_on: { type: 'string', description: 'ISO 8601 date when the zone was last modified' }, + activated_on: { + type: 'string', + description: 'ISO 8601 date when the zone was activated', + optional: true, + }, + development_mode: { + type: 'number', + description: 'Seconds remaining in development mode (0 = off)', + }, + plan: { + type: 'object', + description: 'Zone plan information', + properties: { + id: { type: 'string', description: 'Plan identifier' }, + name: { type: 'string', description: 'Plan name' }, + price: { type: 'number', description: 'Plan price' }, + is_subscribed: { + type: 'boolean', + description: 'Whether the zone is subscribed to the plan', + }, + frequency: { type: 'string', description: 'Plan billing frequency' }, + currency: { type: 'string', description: 'Plan currency' }, + legacy_id: { type: 'string', description: 'Legacy plan identifier' }, + }, + }, + account: { + type: 'object', + description: 'Account the zone belongs to', + properties: { + id: { type: 'string', description: 'Account identifier' }, + name: { type: 'string', description: 'Account name' }, + }, + }, + owner: { + type: 'object', + description: 'Zone owner information', + properties: { + id: { type: 'string', description: 'Owner identifier' }, + name: { type: 'string', description: 'Owner name' }, + type: { type: 'string', description: 'Owner type' }, + }, + }, + meta: { + type: 'object', + description: 'Zone metadata', + properties: { + cdn_only: { type: 'boolean', description: 'Whether the zone is CDN only' }, + custom_certificate_quota: { type: 'number', description: 'Custom certificate quota' }, + dns_only: { type: 'boolean', description: 'Whether the zone is DNS only' }, + foundation_dns: { type: 'boolean', description: 'Whether foundation DNS is enabled' }, + page_rule_quota: { type: 'number', description: 'Page rule quota' }, + phishing_detected: { type: 'boolean', description: 'Whether phishing was detected' }, + step: { type: 'number', description: 'Current setup step' }, + }, + optional: true, + }, + vanity_name_servers: { + type: 'array', + description: 'Custom vanity name servers', + items: { type: 'string', description: 'Vanity name server hostname' }, + optional: true, + }, + permissions: { + type: 'array', + description: 'User permissions for the zone', + items: { type: 'string', description: 'Permission string' }, + optional: true, + }, + }, +} diff --git a/apps/sim/tools/cloudflare/get_zone_settings.ts b/apps/sim/tools/cloudflare/get_zone_settings.ts new file mode 100644 index 0000000000..2bfcd3d3f1 --- /dev/null +++ b/apps/sim/tools/cloudflare/get_zone_settings.ts @@ -0,0 +1,107 @@ +import type { + CloudflareGetZoneSettingsParams, + CloudflareGetZoneSettingsResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const getZoneSettingsTool: ToolConfig< + CloudflareGetZoneSettingsParams, + CloudflareGetZoneSettingsResponse +> = { + id: 'cloudflare_get_zone_settings', + name: 'Cloudflare Get Zone Settings', + description: + 'Gets all settings for a zone including SSL mode, minification, caching level, and security settings.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to get settings for', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => `https://api.cloudflare.com/client/v4/zones/${params.zoneId}/settings`, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { settings: [] }, + error: data.errors?.[0]?.message ?? 'Failed to get zone settings', + } + } + + return { + success: true, + output: { + settings: + data.result?.map((setting: Record) => ({ + id: (setting.id as string) ?? '', + value: + typeof setting.value === 'object' && setting.value !== null + ? JSON.stringify(setting.value) + : String(setting.value ?? ''), + editable: (setting.editable as boolean) ?? false, + modified_on: (setting.modified_on as string) ?? '', + ...(setting.time_remaining != null + ? { time_remaining: setting.time_remaining as number } + : {}), + })) ?? [], + }, + } + }, + + outputs: { + settings: { + type: 'array', + description: 'List of zone settings', + items: { + type: 'object', + properties: { + id: { + type: 'string', + description: + 'Setting identifier (e.g., ssl, minify, cache_level, security_level, always_use_https)', + }, + value: { + type: 'string', + description: + 'Setting value as a string. Simple values returned as-is (e.g., "full", "on"). Complex values are JSON-stringified (e.g., \'{"css":"on","html":"on","js":"on"}\').', + }, + editable: { + type: 'boolean', + description: 'Whether the setting can be modified for the current zone plan', + }, + modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the setting was last modified', + }, + time_remaining: { + type: 'number', + description: + 'Seconds remaining until the setting can be modified again (only present for rate-limited settings)', + optional: true, + }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/cloudflare/index.ts b/apps/sim/tools/cloudflare/index.ts new file mode 100644 index 0000000000..e3f21d34c9 --- /dev/null +++ b/apps/sim/tools/cloudflare/index.ts @@ -0,0 +1,27 @@ +import { createDnsRecordTool } from '@/tools/cloudflare/create_dns_record' +import { createZoneTool } from '@/tools/cloudflare/create_zone' +import { deleteDnsRecordTool } from '@/tools/cloudflare/delete_dns_record' +import { deleteZoneTool } from '@/tools/cloudflare/delete_zone' +import { dnsAnalyticsTool } from '@/tools/cloudflare/dns_analytics' +import { getZoneTool } from '@/tools/cloudflare/get_zone' +import { getZoneSettingsTool } from '@/tools/cloudflare/get_zone_settings' +import { listCertificatesTool } from '@/tools/cloudflare/list_certificates' +import { listDnsRecordsTool } from '@/tools/cloudflare/list_dns_records' +import { listZonesTool } from '@/tools/cloudflare/list_zones' +import { purgeCacheTool } from '@/tools/cloudflare/purge_cache' +import { updateDnsRecordTool } from '@/tools/cloudflare/update_dns_record' +import { updateZoneSettingTool } from '@/tools/cloudflare/update_zone_setting' + +export const cloudflareCreateDnsRecordTool = createDnsRecordTool +export const cloudflareCreateZoneTool = createZoneTool +export const cloudflareDeleteDnsRecordTool = deleteDnsRecordTool +export const cloudflareDeleteZoneTool = deleteZoneTool +export const cloudflareDnsAnalyticsTool = dnsAnalyticsTool +export const cloudflareGetZoneTool = getZoneTool +export const cloudflareGetZoneSettingsTool = getZoneSettingsTool +export const cloudflareListCertificatesTool = listCertificatesTool +export const cloudflareListDnsRecordsTool = listDnsRecordsTool +export const cloudflareListZonesTool = listZonesTool +export const cloudflarePurgeCacheTool = purgeCacheTool +export const cloudflareUpdateDnsRecordTool = updateDnsRecordTool +export const cloudflareUpdateZoneSettingTool = updateZoneSettingTool diff --git a/apps/sim/tools/cloudflare/list_certificates.ts b/apps/sim/tools/cloudflare/list_certificates.ts new file mode 100644 index 0000000000..41a44803d5 --- /dev/null +++ b/apps/sim/tools/cloudflare/list_certificates.ts @@ -0,0 +1,302 @@ +import type { + CloudflareListCertificatesParams, + CloudflareListCertificatesResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const listCertificatesTool: ToolConfig< + CloudflareListCertificatesParams, + CloudflareListCertificatesResponse +> = { + id: 'cloudflare_list_certificates', + name: 'Cloudflare List Certificates', + description: 'Lists SSL/TLS certificate packs for a zone.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to list certificates for', + }, + status: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter certificate packs by status (e.g., "all", "active", "pending")', + }, + page: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Page number of paginated results (default: 1)', + }, + per_page: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of certificate packs per page (default: 20, min: 5, max: 50)', + }, + deploy: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter by deployment environment: "staging" or "production"', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => { + const url = new URL( + `https://api.cloudflare.com/client/v4/zones/${params.zoneId}/ssl/certificate_packs` + ) + if (params.status) url.searchParams.append('status', params.status) + if (params.page) url.searchParams.append('page', String(params.page)) + if (params.per_page) url.searchParams.append('per_page', String(params.per_page)) + if (params.deploy) url.searchParams.append('deploy', params.deploy) + return url.toString() + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { certificates: [], total_count: 0 }, + error: data.errors?.[0]?.message ?? 'Failed to list certificates', + } + } + + return { + success: true, + output: { + certificates: + data.result?.map((cert: any) => ({ + id: cert.id ?? '', + type: cert.type ?? '', + hosts: cert.hosts ?? [], + primary_certificate: cert.primary_certificate ?? '', + status: cert.status ?? '', + certificates: + cert.certificates?.map((c: any) => ({ + id: c.id ?? '', + hosts: c.hosts ?? [], + issuer: c.issuer ?? '', + signature: c.signature ?? '', + status: c.status ?? '', + bundle_method: c.bundle_method ?? '', + zone_id: c.zone_id ?? '', + uploaded_on: c.uploaded_on ?? '', + modified_on: c.modified_on ?? '', + expires_on: c.expires_on ?? '', + priority: c.priority ?? 0, + geo_restrictions: c.geo_restrictions ?? undefined, + })) ?? [], + cloudflare_branding: cert.cloudflare_branding ?? false, + validation_method: cert.validation_method ?? '', + validity_days: cert.validity_days ?? 0, + certificate_authority: cert.certificate_authority ?? '', + validation_errors: + cert.validation_errors?.map((e: any) => ({ + message: e.message ?? '', + })) ?? [], + validation_records: + cert.validation_records?.map((r: any) => ({ + cname: r.cname ?? '', + cname_target: r.cname_target ?? '', + emails: r.emails ?? [], + http_body: r.http_body ?? '', + http_url: r.http_url ?? '', + status: r.status ?? '', + txt_name: r.txt_name ?? '', + txt_value: r.txt_value ?? '', + })) ?? [], + dcv_delegation_records: + cert.dcv_delegation_records?.map((r: any) => ({ + cname: r.cname ?? '', + cname_target: r.cname_target ?? '', + emails: r.emails ?? [], + http_body: r.http_body ?? '', + http_url: r.http_url ?? '', + status: r.status ?? '', + txt_name: r.txt_name ?? '', + txt_value: r.txt_value ?? '', + })) ?? [], + })) ?? [], + total_count: data.result_info?.total_count ?? data.result?.length ?? 0, + }, + } + }, + + outputs: { + certificates: { + type: 'array', + description: 'List of SSL/TLS certificate packs', + items: { + type: 'object', + properties: { + id: { type: 'string', description: 'Certificate pack ID' }, + type: { type: 'string', description: 'Certificate type (e.g., "universal", "advanced")' }, + hosts: { + type: 'array', + description: 'Hostnames covered by this certificate pack', + items: { + type: 'string', + description: 'Hostname', + }, + }, + primary_certificate: { + type: 'string', + description: 'ID of the primary certificate in the pack', + optional: true, + }, + status: { + type: 'string', + description: 'Certificate pack status (e.g., "active", "pending")', + }, + certificates: { + type: 'array', + description: 'Individual certificates within the pack', + items: { + type: 'object', + properties: { + id: { type: 'string', description: 'Certificate ID' }, + hosts: { + type: 'array', + description: 'Hostnames covered by this certificate', + items: { type: 'string', description: 'Hostname' }, + }, + issuer: { type: 'string', description: 'Certificate issuer' }, + signature: { + type: 'string', + description: 'Signature algorithm (e.g., "ECDSAWithSHA256")', + }, + status: { type: 'string', description: 'Certificate status' }, + bundle_method: { + type: 'string', + description: 'Bundle method (e.g., "ubiquitous")', + }, + zone_id: { type: 'string', description: 'Zone ID the certificate belongs to' }, + uploaded_on: { type: 'string', description: 'Upload date (ISO 8601)' }, + modified_on: { type: 'string', description: 'Last modified date (ISO 8601)' }, + expires_on: { type: 'string', description: 'Expiration date (ISO 8601)' }, + priority: { + type: 'number', + description: 'Certificate priority order', + optional: true, + }, + geo_restrictions: { + type: 'object', + description: 'Geographic restrictions for the certificate', + optional: true, + properties: { + label: { + type: 'string', + description: 'Geographic restriction label', + }, + }, + }, + }, + }, + }, + cloudflare_branding: { + type: 'boolean', + description: 'Whether Cloudflare branding is enabled on the certificate', + optional: true, + }, + validation_method: { + type: 'string', + description: 'Validation method (e.g., "txt", "http", "cname")', + optional: true, + }, + validity_days: { + type: 'number', + description: 'Validity period in days', + optional: true, + }, + certificate_authority: { + type: 'string', + description: 'Certificate authority (e.g., "lets_encrypt", "google")', + optional: true, + }, + validation_errors: { + type: 'array', + description: 'Validation issues for the certificate pack', + optional: true, + items: { + type: 'object', + properties: { + message: { + type: 'string', + description: 'Validation error message', + }, + }, + }, + }, + validation_records: { + type: 'array', + description: 'Validation records for the certificate pack', + optional: true, + items: { + type: 'object', + properties: { + cname: { type: 'string', description: 'CNAME record name' }, + cname_target: { type: 'string', description: 'CNAME record target' }, + emails: { + type: 'array', + description: 'Email addresses for validation', + items: { type: 'string', description: 'Email address' }, + }, + http_body: { type: 'string', description: 'HTTP validation body content' }, + http_url: { type: 'string', description: 'HTTP validation URL' }, + status: { type: 'string', description: 'Validation record status' }, + txt_name: { type: 'string', description: 'TXT record name' }, + txt_value: { type: 'string', description: 'TXT record value' }, + }, + }, + }, + dcv_delegation_records: { + type: 'array', + description: 'Domain control validation delegation records', + optional: true, + items: { + type: 'object', + properties: { + cname: { type: 'string', description: 'CNAME record name' }, + cname_target: { type: 'string', description: 'CNAME record target' }, + emails: { + type: 'array', + description: 'Email addresses for validation', + items: { type: 'string', description: 'Email address' }, + }, + http_body: { type: 'string', description: 'HTTP validation body content' }, + http_url: { type: 'string', description: 'HTTP validation URL' }, + status: { type: 'string', description: 'Delegation record status' }, + txt_name: { type: 'string', description: 'TXT record name' }, + txt_value: { type: 'string', description: 'TXT record value' }, + }, + }, + }, + }, + }, + }, + total_count: { + type: 'number', + description: 'Total number of certificate packs', + }, + }, +} diff --git a/apps/sim/tools/cloudflare/list_dns_records.ts b/apps/sim/tools/cloudflare/list_dns_records.ts new file mode 100644 index 0000000000..3c33ba83e1 --- /dev/null +++ b/apps/sim/tools/cloudflare/list_dns_records.ts @@ -0,0 +1,236 @@ +import type { + CloudflareListDnsRecordsParams, + CloudflareListDnsRecordsResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const listDnsRecordsTool: ToolConfig< + CloudflareListDnsRecordsParams, + CloudflareListDnsRecordsResponse +> = { + id: 'cloudflare_list_dns_records', + name: 'Cloudflare List DNS Records', + description: 'Lists DNS records for a specific zone.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to list DNS records for', + }, + type: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter by record type (e.g., "A", "AAAA", "CNAME", "MX", "TXT")', + }, + name: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter by record name (exact match)', + }, + content: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter by record content (exact match)', + }, + page: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Page number for pagination (default: 1)', + }, + per_page: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of records per page (default: 100, max: 5000000)', + }, + direction: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Sort direction (asc or desc)', + }, + match: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Match logic for filters: any or all (default: all)', + }, + order: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Sort field (type, name, content, ttl, proxied)', + }, + proxied: { + type: 'boolean', + required: false, + visibility: 'user-or-llm', + description: 'Filter by proxy status', + }, + search: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Free-text search across record name, content, and value', + }, + tag: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter by tags (comma-separated)', + }, + tag_match: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Tag filter match logic: any or all', + }, + commentFilter: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter records by comment content (substring match)', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => { + const url = new URL(`https://api.cloudflare.com/client/v4/zones/${params.zoneId}/dns_records`) + if (params.type) url.searchParams.append('type', params.type) + if (params.name) url.searchParams.append('name', params.name) + if (params.content) url.searchParams.append('content', params.content) + if (params.page) url.searchParams.append('page', String(params.page)) + if (params.per_page) url.searchParams.append('per_page', String(params.per_page)) + if (params.direction) url.searchParams.append('direction', params.direction) + if (params.match) url.searchParams.append('match', params.match) + if (params.order) url.searchParams.append('order', params.order) + if (params.proxied !== undefined) url.searchParams.append('proxied', String(params.proxied)) + if (params.search) url.searchParams.append('search', params.search) + if (params.tag) url.searchParams.append('tag', params.tag) + if (params.tag_match) url.searchParams.append('tag_match', params.tag_match) + if (params.commentFilter) url.searchParams.append('comment.contains', params.commentFilter) + return url.toString() + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { records: [], total_count: 0 }, + error: data.errors?.[0]?.message ?? 'Failed to list DNS records', + } + } + + return { + success: true, + output: { + records: + data.result?.map((record: any) => ({ + id: record.id ?? '', + zone_id: record.zone_id ?? '', + zone_name: record.zone_name ?? '', + type: record.type ?? '', + name: record.name ?? '', + content: record.content ?? '', + proxiable: record.proxiable ?? false, + proxied: record.proxied ?? false, + ttl: record.ttl ?? 0, + locked: record.locked ?? false, + priority: record.priority ?? null, + comment: record.comment ?? null, + tags: record.tags ?? [], + comment_modified_on: record.comment_modified_on ?? null, + tags_modified_on: record.tags_modified_on ?? null, + meta: record.meta ?? null, + created_on: record.created_on ?? '', + modified_on: record.modified_on ?? '', + })) ?? [], + total_count: data.result_info?.total_count ?? data.result?.length ?? 0, + }, + } + }, + + outputs: { + records: { + type: 'array', + description: 'List of DNS records', + items: { + type: 'object', + properties: { + id: { type: 'string', description: 'Unique identifier for the DNS record' }, + zone_id: { type: 'string', description: 'The ID of the zone the record belongs to' }, + zone_name: { type: 'string', description: 'The name of the zone' }, + type: { type: 'string', description: 'Record type (A, AAAA, CNAME, MX, TXT, etc.)' }, + name: { type: 'string', description: 'Record name (e.g., example.com)' }, + content: { type: 'string', description: 'Record content (e.g., IP address)' }, + proxiable: { type: 'boolean', description: 'Whether the record can be proxied' }, + proxied: { type: 'boolean', description: 'Whether Cloudflare proxy is enabled' }, + ttl: { type: 'number', description: 'TTL in seconds (1 = automatic)' }, + locked: { type: 'boolean', description: 'Whether the record is locked' }, + priority: { type: 'number', description: 'MX/SRV record priority', optional: true }, + comment: { + type: 'string', + description: 'Comment associated with the record', + optional: true, + }, + tags: { + type: 'array', + description: 'Tags associated with the record', + items: { type: 'string', description: 'Tag value' }, + }, + comment_modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the comment was last modified', + optional: true, + }, + tags_modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when tags were last modified', + optional: true, + }, + meta: { + type: 'object', + description: 'Record metadata', + optional: true, + properties: { + source: { type: 'string', description: 'Source of the DNS record' }, + }, + }, + created_on: { + type: 'string', + description: 'ISO 8601 timestamp when the record was created', + }, + modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the record was last modified', + }, + }, + }, + }, + total_count: { + type: 'number', + description: 'Total number of DNS records matching the query', + }, + }, +} diff --git a/apps/sim/tools/cloudflare/list_zones.ts b/apps/sim/tools/cloudflare/list_zones.ts new file mode 100644 index 0000000000..ee165c6940 --- /dev/null +++ b/apps/sim/tools/cloudflare/list_zones.ts @@ -0,0 +1,259 @@ +import type { + CloudflareListZonesParams, + CloudflareListZonesResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const listZonesTool: ToolConfig = { + id: 'cloudflare_list_zones', + name: 'Cloudflare List Zones', + description: 'Lists all zones (domains) in the Cloudflare account.', + version: '1.0.0', + + params: { + name: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter zones by domain name (e.g., "example.com")', + }, + status: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter by zone status: "initializing", "pending", "active", or "moved"', + }, + page: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Page number for pagination (default: 1)', + }, + per_page: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of zones per page (default: 20, max: 50)', + }, + accountId: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Filter zones by account ID', + }, + order: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Sort field (name, status, account.id, account.name)', + }, + direction: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Sort direction (asc, desc)', + }, + match: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Match logic for filters (any, all). Default: all', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => { + const url = new URL('https://api.cloudflare.com/client/v4/zones') + if (params.name) url.searchParams.append('name', params.name) + if (params.status) url.searchParams.append('status', params.status) + if (params.page) url.searchParams.append('page', String(params.page)) + if (params.per_page) url.searchParams.append('per_page', String(params.per_page)) + if (params.accountId) url.searchParams.append('account.id', params.accountId) + if (params.order) url.searchParams.append('order', params.order) + if (params.direction) url.searchParams.append('direction', params.direction) + if (params.match) url.searchParams.append('match', params.match) + return url.toString() + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { zones: [], total_count: 0 }, + error: data.errors?.[0]?.message ?? 'Failed to list zones', + } + } + + return { + success: true, + output: { + zones: + data.result?.map((zone: any) => ({ + id: zone.id ?? '', + name: zone.name ?? '', + status: zone.status ?? '', + paused: zone.paused ?? false, + type: zone.type ?? '', + name_servers: zone.name_servers ?? [], + original_name_servers: zone.original_name_servers ?? [], + created_on: zone.created_on ?? '', + modified_on: zone.modified_on ?? '', + activated_on: zone.activated_on ?? '', + development_mode: zone.development_mode ?? 0, + plan: { + id: zone.plan?.id ?? '', + name: zone.plan?.name ?? '', + price: zone.plan?.price ?? 0, + is_subscribed: zone.plan?.is_subscribed ?? false, + frequency: zone.plan?.frequency ?? '', + currency: zone.plan?.currency ?? '', + legacy_id: zone.plan?.legacy_id ?? '', + }, + account: { + id: zone.account?.id ?? '', + name: zone.account?.name ?? '', + }, + owner: { + id: zone.owner?.id ?? '', + name: zone.owner?.name ?? '', + type: zone.owner?.type ?? '', + }, + meta: { + cdn_only: zone.meta?.cdn_only ?? false, + custom_certificate_quota: zone.meta?.custom_certificate_quota ?? 0, + dns_only: zone.meta?.dns_only ?? false, + foundation_dns: zone.meta?.foundation_dns ?? false, + page_rule_quota: zone.meta?.page_rule_quota ?? 0, + phishing_detected: zone.meta?.phishing_detected ?? false, + step: zone.meta?.step ?? 0, + }, + vanity_name_servers: zone.vanity_name_servers ?? [], + permissions: zone.permissions ?? [], + })) ?? [], + total_count: data.result_info?.total_count ?? data.result?.length ?? 0, + }, + } + }, + + outputs: { + zones: { + type: 'array', + description: 'List of zones/domains', + items: { + type: 'object', + properties: { + id: { type: 'string', description: 'Zone ID' }, + name: { type: 'string', description: 'Domain name' }, + status: { + type: 'string', + description: 'Zone status (initializing, pending, active, moved)', + }, + paused: { type: 'boolean', description: 'Whether the zone is paused' }, + type: { type: 'string', description: 'Zone type (full, partial, or secondary)' }, + name_servers: { + type: 'array', + description: 'Assigned Cloudflare name servers', + items: { type: 'string', description: 'Name server hostname' }, + }, + original_name_servers: { + type: 'array', + description: 'Original name servers before moving to Cloudflare', + items: { type: 'string', description: 'Name server hostname' }, + optional: true, + }, + created_on: { type: 'string', description: 'ISO 8601 date when the zone was created' }, + modified_on: { + type: 'string', + description: 'ISO 8601 date when the zone was last modified', + }, + activated_on: { + type: 'string', + description: 'ISO 8601 date when the zone was activated', + optional: true, + }, + development_mode: { + type: 'number', + description: 'Seconds remaining in development mode (0 = off)', + }, + plan: { + type: 'object', + description: 'Zone plan information', + properties: { + id: { type: 'string', description: 'Plan identifier' }, + name: { type: 'string', description: 'Plan name' }, + price: { type: 'number', description: 'Plan price' }, + is_subscribed: { + type: 'boolean', + description: 'Whether the zone is subscribed to the plan', + }, + frequency: { type: 'string', description: 'Plan billing frequency' }, + currency: { type: 'string', description: 'Plan currency' }, + legacy_id: { type: 'string', description: 'Legacy plan identifier' }, + }, + }, + account: { + type: 'object', + description: 'Account the zone belongs to', + properties: { + id: { type: 'string', description: 'Account identifier' }, + name: { type: 'string', description: 'Account name' }, + }, + }, + owner: { + type: 'object', + description: 'Zone owner information', + properties: { + id: { type: 'string', description: 'Owner identifier' }, + name: { type: 'string', description: 'Owner name' }, + type: { type: 'string', description: 'Owner type' }, + }, + }, + meta: { + type: 'object', + description: 'Zone metadata', + properties: { + cdn_only: { type: 'boolean', description: 'Whether the zone is CDN only' }, + custom_certificate_quota: { type: 'number', description: 'Custom certificate quota' }, + dns_only: { type: 'boolean', description: 'Whether the zone is DNS only' }, + foundation_dns: { type: 'boolean', description: 'Whether foundation DNS is enabled' }, + page_rule_quota: { type: 'number', description: 'Page rule quota' }, + phishing_detected: { type: 'boolean', description: 'Whether phishing was detected' }, + step: { type: 'number', description: 'Current setup step' }, + }, + optional: true, + }, + vanity_name_servers: { + type: 'array', + description: 'Custom vanity name servers', + items: { type: 'string', description: 'Vanity name server hostname' }, + optional: true, + }, + permissions: { + type: 'array', + description: 'User permissions for the zone', + items: { type: 'string', description: 'Permission string' }, + optional: true, + }, + }, + }, + }, + total_count: { + type: 'number', + description: 'Total number of zones matching the query', + }, + }, +} diff --git a/apps/sim/tools/cloudflare/purge_cache.ts b/apps/sim/tools/cloudflare/purge_cache.ts new file mode 100644 index 0000000000..0eee61ce25 --- /dev/null +++ b/apps/sim/tools/cloudflare/purge_cache.ts @@ -0,0 +1,135 @@ +import type { + CloudflarePurgeCacheParams, + CloudflarePurgeCacheResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const purgeCacheTool: ToolConfig = + { + id: 'cloudflare_purge_cache', + name: 'Cloudflare Purge Cache', + description: + 'Purges cached content for a zone. Can purge everything or specific files/tags/hosts/prefixes.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to purge cache for', + }, + purge_everything: { + type: 'boolean', + required: false, + visibility: 'user-or-llm', + description: + 'Set to true to purge all cached content. Mutually exclusive with files, tags, hosts, and prefixes', + }, + files: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated list of URLs to purge from cache', + }, + tags: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated list of cache tags to purge (Enterprise only)', + }, + hosts: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated list of hostnames to purge (Enterprise only)', + }, + prefixes: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated list of URL prefixes to purge (Enterprise only)', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => `https://api.cloudflare.com/client/v4/zones/${params.zoneId}/purge_cache`, + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + body: (params) => { + if (params.purge_everything) { + return { purge_everything: true } + } + + const body: Record = {} + if (params.files) { + const fileList = String(params.files) + .split(',') + .map((f) => f.trim()) + .filter(Boolean) + if (fileList.length > 0) body.files = fileList + } + if (params.tags) { + const tagList = String(params.tags) + .split(',') + .map((t) => t.trim()) + .filter(Boolean) + if (tagList.length > 0) body.tags = tagList + } + if (params.hosts) { + const hostList = String(params.hosts) + .split(',') + .map((h) => h.trim()) + .filter(Boolean) + if (hostList.length > 0) body.hosts = hostList + } + if (params.prefixes) { + const prefixList = String(params.prefixes) + .split(',') + .map((p) => p.trim()) + .filter(Boolean) + if (prefixList.length > 0) body.prefixes = prefixList + } + + if (Object.keys(body).length === 0) { + throw new Error( + 'No purge targets specified. Provide at least one of: files, tags, hosts, or prefixes, or set purge_everything to true.' + ) + } + + return body + }, + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { id: '' }, + error: data.errors?.[0]?.message ?? 'Failed to purge cache', + } + } + + return { + success: true, + output: { + id: data.result?.id ?? '', + }, + } + }, + + outputs: { + id: { type: 'string', description: 'Purge request identifier returned by Cloudflare' }, + }, + } diff --git a/apps/sim/tools/cloudflare/types.ts b/apps/sim/tools/cloudflare/types.ts new file mode 100644 index 0000000000..f69ef7f913 --- /dev/null +++ b/apps/sim/tools/cloudflare/types.ts @@ -0,0 +1,455 @@ +import type { ToolResponse } from '@/tools/types' + +export interface CloudflareBaseParams { + apiKey: string +} + +export interface CloudflareListZonesParams extends CloudflareBaseParams { + name?: string + status?: string + page?: number + per_page?: number + accountId?: string + order?: string + direction?: string + match?: string +} + +export interface CloudflareZonePlan { + id: string + name: string + price: number + is_subscribed: boolean + frequency: string + currency: string + legacy_id: string +} + +export interface CloudflareZoneMeta { + cdn_only: boolean + custom_certificate_quota: number + dns_only: boolean + foundation_dns: boolean + page_rule_quota: number + phishing_detected: boolean + step: number +} + +export interface CloudflareZone { + id: string + name: string + status: string + paused: boolean + type: string + name_servers: string[] + original_name_servers?: string[] + created_on: string + modified_on: string + activated_on?: string + development_mode?: number + plan?: CloudflareZonePlan + account?: { + id: string + name: string + } + owner?: { + id: string + name: string + type: string + } + meta?: CloudflareZoneMeta + vanity_name_servers?: string[] + permissions?: string[] +} + +export interface CloudflareListZonesResponse extends ToolResponse { + output: { + zones: CloudflareZone[] + total_count: number + } +} + +export interface CloudflareGetZoneParams extends CloudflareBaseParams { + zoneId: string +} + +export interface CloudflareGetZoneResponse extends ToolResponse { + output: { + id: string + name: string + status: string + paused: boolean + type: string + name_servers: string[] + original_name_servers: string[] + created_on: string + modified_on: string + activated_on: string + development_mode: number + plan: CloudflareZonePlan + account: { + id: string + name: string + } + owner: { + id: string + name: string + type: string + } + meta: CloudflareZoneMeta + vanity_name_servers: string[] + permissions: string[] + } +} + +export interface CloudflareCreateZoneParams extends CloudflareBaseParams { + name: string + accountId: string + type?: string + jump_start?: boolean +} + +export interface CloudflareCreateZoneResponse extends ToolResponse { + output: { + id: string + name: string + status: string + paused: boolean + type: string + name_servers: string[] + original_name_servers: string[] + created_on: string + modified_on: string + activated_on: string + development_mode: number + plan: CloudflareZonePlan + account: { + id: string + name: string + } + owner: { + id: string + name: string + type: string + } + meta: CloudflareZoneMeta + vanity_name_servers: string[] + permissions: string[] + } +} + +export interface CloudflareDeleteZoneParams extends CloudflareBaseParams { + zoneId: string +} + +export interface CloudflareDeleteZoneResponse extends ToolResponse { + output: { + id: string + } +} + +export interface CloudflareListDnsRecordsParams extends CloudflareBaseParams { + zoneId: string + type?: string + name?: string + content?: string + page?: number + per_page?: number + direction?: string + match?: string + order?: string + proxied?: boolean + search?: string + tag?: string + tag_match?: string + commentFilter?: string +} + +export interface CloudflareDnsRecordMeta { + source: string +} + +export interface CloudflareDnsRecord { + id: string + zone_id: string + zone_name: string + type: string + name: string + content: string + proxiable: boolean + proxied: boolean + ttl: number + locked: boolean + priority?: number + comment?: string | null + tags: string[] + comment_modified_on?: string | null + tags_modified_on?: string | null + meta?: CloudflareDnsRecordMeta | null + created_on: string + modified_on: string +} + +export interface CloudflareListDnsRecordsResponse extends ToolResponse { + output: { + records: CloudflareDnsRecord[] + total_count: number + } +} + +export interface CloudflareCreateDnsRecordParams extends CloudflareBaseParams { + zoneId: string + type: string + name: string + content: string + ttl?: number + proxied?: boolean + priority?: number + comment?: string + tags?: string +} + +export interface CloudflareCreateDnsRecordResponse extends ToolResponse { + output: { + id: string + zone_id: string + zone_name: string + type: string + name: string + content: string + proxiable: boolean + proxied: boolean + ttl: number + locked: boolean + priority?: number + comment?: string | null + tags: string[] + comment_modified_on?: string | null + tags_modified_on?: string | null + meta?: CloudflareDnsRecordMeta | null + created_on: string + modified_on: string + } +} + +export interface CloudflareUpdateDnsRecordParams extends CloudflareBaseParams { + zoneId: string + recordId: string + type?: string + name?: string + content?: string + ttl?: number + proxied?: boolean + priority?: number + comment?: string + tags?: string +} + +export interface CloudflareUpdateDnsRecordResponse extends ToolResponse { + output: { + id: string + zone_id: string + zone_name: string + type: string + name: string + content: string + proxiable: boolean + proxied: boolean + ttl: number + locked: boolean + priority?: number + comment?: string | null + tags: string[] + comment_modified_on?: string | null + tags_modified_on?: string | null + meta?: CloudflareDnsRecordMeta | null + created_on: string + modified_on: string + } +} + +export interface CloudflareDeleteDnsRecordParams extends CloudflareBaseParams { + zoneId: string + recordId: string +} + +export interface CloudflareDeleteDnsRecordResponse extends ToolResponse { + output: { + id: string + } +} + +export interface CloudflareListCertificatesParams extends CloudflareBaseParams { + zoneId: string + status?: string + page?: number + per_page?: number + deploy?: string +} + +export interface CloudflareCertificateGeoRestrictions { + label: string +} + +export interface CloudflareCertificate { + id: string + hosts: string[] + issuer: string + signature: string + status: string + bundle_method: string + zone_id: string + uploaded_on: string + modified_on: string + expires_on: string + priority?: number + geo_restrictions?: CloudflareCertificateGeoRestrictions +} + +export interface CloudflareCertificateValidationError { + message: string +} + +export interface CloudflareDcvDelegationRecord { + cname: string + cname_target: string + emails: string[] + http_body: string + http_url: string + status: string + txt_name: string + txt_value: string +} + +export interface CloudflareCertificatePack { + id: string + type: string + hosts: string[] + primary_certificate: string + status: string + certificates: CloudflareCertificate[] + cloudflare_branding?: boolean + validation_method?: string + validity_days?: number + certificate_authority?: string + validation_errors?: CloudflareCertificateValidationError[] + validation_records?: CloudflareDcvDelegationRecord[] + dcv_delegation_records?: CloudflareDcvDelegationRecord[] +} + +export interface CloudflareListCertificatesResponse extends ToolResponse { + output: { + certificates: CloudflareCertificatePack[] + total_count: number + } +} + +export interface CloudflarePurgeCacheParams extends CloudflareBaseParams { + zoneId: string + purge_everything?: boolean + files?: string + tags?: string + hosts?: string + prefixes?: string +} + +export interface CloudflarePurgeCacheResponse extends ToolResponse { + output: { + id: string + } +} + +export interface CloudflareDnsAnalyticsParams extends CloudflareBaseParams { + zoneId: string + since?: string + until?: string + metrics: string + dimensions?: string + filters?: string + sort?: string + limit?: number +} + +export interface CloudflareDnsAnalyticsTotals { + queryCount: number + uncachedCount: number + staleCount: number + responseTimeAvg?: number + responseTimeMedian?: number + responseTime90th?: number + responseTime99th?: number +} + +export interface CloudflareDnsAnalyticsQuery { + since: string + until: string + metrics: string[] + dimensions: string[] + filters: string + sort: string[] + limit: number +} + +export interface CloudflareDnsAnalyticsResponse extends ToolResponse { + output: { + totals: CloudflareDnsAnalyticsTotals + min: CloudflareDnsAnalyticsTotals + max: CloudflareDnsAnalyticsTotals + data: Array<{ + dimensions: string[] + metrics: number[] + }> + data_lag: number + rows: number + query: CloudflareDnsAnalyticsQuery + } +} + +export interface CloudflareGetZoneSettingsParams extends CloudflareBaseParams { + zoneId: string +} + +export interface CloudflareZoneSetting { + id: string + value: string + editable: boolean + modified_on: string + time_remaining?: number +} + +export interface CloudflareGetZoneSettingsResponse extends ToolResponse { + output: { + settings: CloudflareZoneSetting[] + } +} + +export interface CloudflareUpdateZoneSettingParams extends CloudflareBaseParams { + zoneId: string + settingId: string + value: string +} + +export interface CloudflareUpdateZoneSettingResponse extends ToolResponse { + output: { + id: string + value: string + editable: boolean + modified_on: string + time_remaining?: number + } +} + +export type CloudflareResponse = + | CloudflareListZonesResponse + | CloudflareGetZoneResponse + | CloudflareCreateZoneResponse + | CloudflareDeleteZoneResponse + | CloudflareListDnsRecordsResponse + | CloudflareCreateDnsRecordResponse + | CloudflareUpdateDnsRecordResponse + | CloudflareDeleteDnsRecordResponse + | CloudflareListCertificatesResponse + | CloudflarePurgeCacheResponse + | CloudflareDnsAnalyticsResponse + | CloudflareGetZoneSettingsResponse + | CloudflareUpdateZoneSettingResponse diff --git a/apps/sim/tools/cloudflare/update_dns_record.ts b/apps/sim/tools/cloudflare/update_dns_record.ts new file mode 100644 index 0000000000..7b51dbbfc1 --- /dev/null +++ b/apps/sim/tools/cloudflare/update_dns_record.ts @@ -0,0 +1,217 @@ +import type { + CloudflareUpdateDnsRecordParams, + CloudflareUpdateDnsRecordResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const updateDnsRecordTool: ToolConfig< + CloudflareUpdateDnsRecordParams, + CloudflareUpdateDnsRecordResponse +> = { + id: 'cloudflare_update_dns_record', + name: 'Cloudflare Update DNS Record', + description: 'Updates an existing DNS record for a zone.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID containing the DNS record', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The DNS record ID to update', + }, + type: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'DNS record type (e.g., "A", "AAAA", "CNAME", "MX", "TXT")', + }, + name: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'DNS record name', + }, + content: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'DNS record content (e.g., IP address)', + }, + ttl: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Time to live in seconds (1 = automatic)', + }, + proxied: { + type: 'boolean', + required: false, + visibility: 'user-or-llm', + description: 'Whether to enable Cloudflare proxy', + }, + priority: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Priority for MX and SRV records', + }, + comment: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comment for the DNS record', + }, + tags: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated tags for the DNS record', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => + `https://api.cloudflare.com/client/v4/zones/${params.zoneId}/dns_records/${params.recordId}`, + method: 'PATCH', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + body: (params) => { + const body: Record = {} + if (params.type !== undefined) body.type = params.type + if (params.name !== undefined) body.name = params.name + if (params.content !== undefined) body.content = params.content + if (params.ttl !== undefined) body.ttl = Number(params.ttl) + if (params.proxied !== undefined) body.proxied = params.proxied + if (params.priority !== undefined) body.priority = Number(params.priority) + if (params.comment !== undefined) body.comment = params.comment + if (params.tags) { + const tagList = String(params.tags) + .split(',') + .map((t) => t.trim()) + .filter(Boolean) + if (tagList.length > 0) body.tags = tagList + } + return body + }, + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { + id: '', + zone_id: '', + zone_name: '', + type: '', + name: '', + content: '', + proxiable: false, + proxied: false, + ttl: 0, + locked: false, + priority: undefined, + comment: null, + tags: [], + comment_modified_on: null, + tags_modified_on: null, + meta: null, + created_on: '', + modified_on: '', + }, + error: data.errors?.[0]?.message ?? 'Failed to update DNS record', + } + } + + const record = data.result + return { + success: true, + output: { + id: record?.id ?? '', + zone_id: record?.zone_id ?? '', + zone_name: record?.zone_name ?? '', + type: record?.type ?? '', + name: record?.name ?? '', + content: record?.content ?? '', + proxiable: record?.proxiable ?? false, + proxied: record?.proxied ?? false, + ttl: record?.ttl ?? 0, + locked: record?.locked ?? false, + priority: record?.priority ?? null, + comment: record?.comment ?? null, + tags: record?.tags ?? [], + comment_modified_on: record?.comment_modified_on ?? null, + tags_modified_on: record?.tags_modified_on ?? null, + meta: record?.meta ?? null, + created_on: record?.created_on ?? '', + modified_on: record?.modified_on ?? '', + }, + } + }, + + outputs: { + id: { type: 'string', description: 'Unique identifier for the updated DNS record' }, + zone_id: { type: 'string', description: 'The ID of the zone the record belongs to' }, + zone_name: { type: 'string', description: 'The name of the zone' }, + type: { type: 'string', description: 'DNS record type (A, AAAA, CNAME, MX, TXT, etc.)' }, + name: { type: 'string', description: 'DNS record hostname' }, + content: { + type: 'string', + description: 'DNS record value (e.g., IP address, target hostname)', + }, + proxiable: { + type: 'boolean', + description: 'Whether the record can be proxied through Cloudflare', + }, + proxied: { type: 'boolean', description: 'Whether Cloudflare proxy is enabled' }, + ttl: { type: 'number', description: 'Time to live in seconds (1 = automatic)' }, + locked: { type: 'boolean', description: 'Whether the record is locked' }, + priority: { type: 'number', description: 'Priority for MX and SRV records', optional: true }, + comment: { type: 'string', description: 'Comment associated with the record', optional: true }, + tags: { + type: 'array', + description: 'Tags associated with the record', + items: { type: 'string', description: 'Tag value' }, + }, + comment_modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the comment was last modified', + optional: true, + }, + tags_modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when tags were last modified', + optional: true, + }, + meta: { + type: 'object', + description: 'Record metadata', + optional: true, + properties: { + source: { type: 'string', description: 'Source of the DNS record' }, + }, + }, + created_on: { type: 'string', description: 'ISO 8601 timestamp when the record was created' }, + modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the record was last modified', + }, + }, +} diff --git a/apps/sim/tools/cloudflare/update_zone_setting.ts b/apps/sim/tools/cloudflare/update_zone_setting.ts new file mode 100644 index 0000000000..1efdb88881 --- /dev/null +++ b/apps/sim/tools/cloudflare/update_zone_setting.ts @@ -0,0 +1,117 @@ +import type { + CloudflareUpdateZoneSettingParams, + CloudflareUpdateZoneSettingResponse, +} from '@/tools/cloudflare/types' +import type { ToolConfig } from '@/tools/types' + +export const updateZoneSettingTool: ToolConfig< + CloudflareUpdateZoneSettingParams, + CloudflareUpdateZoneSettingResponse +> = { + id: 'cloudflare_update_zone_setting', + name: 'Cloudflare Update Zone Setting', + description: + 'Updates a specific zone setting such as SSL mode, security level, cache level, minification, or other configuration.', + version: '1.0.0', + + params: { + zoneId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The zone ID to update settings for', + }, + settingId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Setting to update (e.g., "ssl", "security_level", "cache_level", "minify", "always_use_https", "browser_cache_ttl", "http3", "min_tls_version", "ciphers")', + }, + value: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'New value for the setting as a string or JSON string for complex values (e.g., "full" for SSL, "medium" for security_level, "aggressive" for cache_level, \'{"css":"on","html":"on","js":"on"}\' for minify, \'["ECDHE-RSA-AES128-GCM-SHA256"]\' for ciphers)', + }, + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Cloudflare API Token', + }, + }, + + request: { + url: (params) => + `https://api.cloudflare.com/client/v4/zones/${params.zoneId}/settings/${params.settingId}`, + method: 'PATCH', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + 'Content-Type': 'application/json', + }), + body: (params) => { + try { + return { value: JSON.parse(params.value) } + } catch { + return { value: params.value } + } + }, + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + return { + success: false, + output: { id: '', value: '', editable: false, modified_on: '' }, + error: data.errors?.[0]?.message ?? 'Failed to update zone setting', + } + } + + const setting = data.result + return { + success: true, + output: { + id: setting?.id ?? '', + value: + typeof setting?.value === 'object' && setting?.value !== null + ? JSON.stringify(setting.value) + : String(setting?.value ?? ''), + editable: setting?.editable ?? false, + modified_on: setting?.modified_on ?? '', + ...(setting?.time_remaining != null + ? { time_remaining: setting.time_remaining as number } + : {}), + }, + } + }, + + outputs: { + id: { + type: 'string', + description: 'Setting identifier (e.g., ssl, minify, cache_level)', + }, + value: { + type: 'string', + description: + 'Updated setting value as a string. Simple values returned as-is (e.g., "full", "on"). Complex values are JSON-stringified.', + }, + editable: { + type: 'boolean', + description: 'Whether the setting can be modified for the current zone plan', + }, + modified_on: { + type: 'string', + description: 'ISO 8601 timestamp when the setting was last modified', + }, + time_remaining: { + type: 'number', + description: + 'Seconds remaining until the setting can be modified again (only present for rate-limited settings)', + optional: true, + }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/associate.ts b/apps/sim/tools/microsoft_dataverse/associate.ts new file mode 100644 index 0000000000..3256803dce --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/associate.ts @@ -0,0 +1,137 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseAssociateParams, + DataverseAssociateResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseAssociate') + +export const dataverseAssociateTool: ToolConfig< + DataverseAssociateParams, + DataverseAssociateResponse +> = { + id: 'microsoft_dataverse_associate', + name: 'Associate Microsoft Dataverse Records', + description: + 'Associate two records in Microsoft Dataverse via a navigation property. Creates a relationship between a source record and a target record. Supports both collection-valued (POST) and single-valued (PUT) navigation properties.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Source entity set name (e.g., accounts)', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Source record GUID', + }, + navigationProperty: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Navigation property name (e.g., contact_customer_accounts for collection-valued, or parentcustomerid_account for single-valued)', + }, + targetEntitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Target entity set name (e.g., contacts)', + }, + targetRecordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Target record GUID to associate', + }, + navigationType: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Type of navigation property: "collection" (default, uses POST) or "single" (uses PUT for lookup fields)', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})/${params.navigationProperty}/$ref` + }, + method: (params) => (params.navigationType === 'single' ? 'PUT' : 'POST'), + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + body: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return { + '@odata.id': `${baseUrl}/api/data/v9.2/${params.targetEntitySetName}(${params.targetRecordId})`, + } + }, + }, + + transformResponse: async (response: Response, params?: DataverseAssociateParams) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse associate failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + return { + success: true, + output: { + success: true, + entitySetName: params?.entitySetName ?? '', + recordId: params?.recordId ?? '', + navigationProperty: params?.navigationProperty ?? '', + targetEntitySetName: params?.targetEntitySetName ?? '', + targetRecordId: params?.targetRecordId ?? '', + }, + } + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the association was created successfully' }, + entitySetName: { + type: 'string', + description: 'Source entity set name used in the association', + }, + recordId: { type: 'string', description: 'Source record GUID that was associated' }, + navigationProperty: { + type: 'string', + description: 'Navigation property used for the association', + }, + targetEntitySetName: { + type: 'string', + description: 'Target entity set name used in the association', + }, + targetRecordId: { type: 'string', description: 'Target record GUID that was associated' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/create_multiple.ts b/apps/sim/tools/microsoft_dataverse/create_multiple.ts new file mode 100644 index 0000000000..5125e849bb --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/create_multiple.ts @@ -0,0 +1,126 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseCreateMultipleParams, + DataverseCreateMultipleResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseCreateMultiple') + +export const dataverseCreateMultipleTool: ToolConfig< + DataverseCreateMultipleParams, + DataverseCreateMultipleResponse +> = { + id: 'microsoft_dataverse_create_multiple', + name: 'Create Multiple Microsoft Dataverse Records', + description: + 'Create multiple records of the same table type in a single request. Each record in the Targets array must include an @odata.type annotation. Recommended batch size: 100-1000 records for standard tables.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + entityLogicalName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Table logical name for @odata.type annotation (e.g., account, contact). Used to set Microsoft.Dynamics.CRM.{entityLogicalName} on each record.', + }, + records: { + type: 'object', + required: true, + visibility: 'user-or-llm', + description: + 'Array of record objects to create. Each record should contain column logical names as keys. The @odata.type annotation is added automatically.', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/${params.entitySetName}/Microsoft.Dynamics.CRM.CreateMultiple` + }, + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + body: (params) => { + let records = params.records + if (typeof records === 'string') { + try { + records = JSON.parse(records) + } catch { + throw new Error('Invalid JSON format for records array') + } + } + if (!Array.isArray(records)) { + throw new Error('Records must be an array of objects') + } + const targets = records.map((record: Record) => ({ + ...record, + '@odata.type': `Microsoft.Dynamics.CRM.${params.entityLogicalName}`, + })) + return { Targets: targets } + }, + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse create multiple failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = await response.json().catch(() => null) + const ids = data?.Ids ?? [] + + return { + success: true, + output: { + ids, + count: ids.length, + success: true, + }, + } + }, + + outputs: { + ids: { + type: 'array', + description: 'Array of GUIDs for the created records', + items: { + type: 'string', + description: 'GUID of a created record', + }, + }, + count: { type: 'number', description: 'Number of records created' }, + success: { type: 'boolean', description: 'Whether all records were created successfully' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/create_record.ts b/apps/sim/tools/microsoft_dataverse/create_record.ts new file mode 100644 index 0000000000..dffcd9941f --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/create_record.ts @@ -0,0 +1,121 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseCreateRecordParams, + DataverseCreateRecordResponse, +} from '@/tools/microsoft_dataverse/types' +import { DATAVERSE_RECORD_OUTPUT } from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseCreateRecord') + +export const dataverseCreateRecordTool: ToolConfig< + DataverseCreateRecordParams, + DataverseCreateRecordResponse +> = { + id: 'microsoft_dataverse_create_record', + name: 'Create Microsoft Dataverse Record', + description: + 'Create a new record in a Microsoft Dataverse table. Requires the entity set name (plural table name) and record data as a JSON object.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + data: { + type: 'object', + required: true, + visibility: 'user-or-llm', + description: 'Record data as a JSON object with column names as keys', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/${params.entitySetName}` + }, + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + Prefer: 'return=representation', + }), + body: (params) => { + let data = params.data + if (typeof data === 'string') { + try { + data = JSON.parse(data) + } catch { + throw new Error('Invalid JSON format for record data') + } + } + return data + }, + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse create record failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = await response.json().catch(() => null) + + let recordId = '' + if (data) { + const idKey = Object.keys(data).find((k) => k.endsWith('id') && !k.startsWith('@')) + recordId = idKey ? String(data[idKey]) : '' + } + + if (!recordId) { + const entityIdHeader = response.headers.get('OData-EntityId') + if (entityIdHeader) { + const match = entityIdHeader.match(/\(([^)]+)\)/) + if (match) { + recordId = match[1] + } + } + } + + return { + success: true, + output: { + recordId, + record: data ?? {}, + success: true, + }, + } + }, + + outputs: { + recordId: { type: 'string', description: 'The ID of the created record', optional: true }, + record: { ...DATAVERSE_RECORD_OUTPUT, optional: true }, + success: { type: 'boolean', description: 'Whether the record was created successfully' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/delete_record.ts b/apps/sim/tools/microsoft_dataverse/delete_record.ts new file mode 100644 index 0000000000..adb8a06b7d --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/delete_record.ts @@ -0,0 +1,86 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseDeleteRecordParams, + DataverseDeleteRecordResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseDeleteRecord') + +export const dataverseDeleteRecordTool: ToolConfig< + DataverseDeleteRecordParams, + DataverseDeleteRecordResponse +> = { + id: 'microsoft_dataverse_delete_record', + name: 'Delete Microsoft Dataverse Record', + description: 'Delete a record from a Microsoft Dataverse table by its ID.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The unique identifier (GUID) of the record to delete', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})` + }, + method: 'DELETE', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + }, + + transformResponse: async (response: Response, params?: DataverseDeleteRecordParams) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse delete record failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + return { + success: true, + output: { + recordId: params?.recordId ?? '', + success: true, + }, + } + }, + + outputs: { + recordId: { type: 'string', description: 'The ID of the deleted record' }, + success: { type: 'boolean', description: 'Operation success status' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/disassociate.ts b/apps/sim/tools/microsoft_dataverse/disassociate.ts new file mode 100644 index 0000000000..2aa5798e65 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/disassociate.ts @@ -0,0 +1,123 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseDisassociateParams, + DataverseDisassociateResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseDisassociate') + +export const dataverseDisassociateTool: ToolConfig< + DataverseDisassociateParams, + DataverseDisassociateResponse +> = { + id: 'microsoft_dataverse_disassociate', + name: 'Disassociate Microsoft Dataverse Records', + description: + 'Remove an association between two records in Microsoft Dataverse. For collection-valued navigation properties, provide the target record ID. For single-valued navigation properties, only the navigation property name is needed.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Source entity set name (e.g., accounts)', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Source record GUID', + }, + navigationProperty: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Navigation property name (e.g., contact_customer_accounts for collection-valued, or parentcustomerid_account for single-valued)', + }, + targetRecordId: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Target record GUID (required for collection-valued navigation properties, omit for single-valued)', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + if (params.targetRecordId) { + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})/${params.navigationProperty}(${params.targetRecordId})/$ref` + } + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})/${params.navigationProperty}/$ref` + }, + method: 'DELETE', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + }, + + transformResponse: async (response: Response, params?: DataverseDisassociateParams) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse disassociate failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + return { + success: true, + output: { + success: true, + entitySetName: params?.entitySetName ?? '', + recordId: params?.recordId ?? '', + navigationProperty: params?.navigationProperty ?? '', + ...(params?.targetRecordId ? { targetRecordId: params.targetRecordId } : {}), + }, + } + }, + + outputs: { + success: { + type: 'boolean', + description: 'Whether the disassociation was completed successfully', + }, + entitySetName: { + type: 'string', + description: 'Source entity set name used in the disassociation', + }, + recordId: { type: 'string', description: 'Source record GUID that was disassociated' }, + navigationProperty: { + type: 'string', + description: 'Navigation property used for the disassociation', + }, + targetRecordId: { + type: 'string', + description: 'Target record GUID that was disassociated', + optional: true, + }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/download_file.ts b/apps/sim/tools/microsoft_dataverse/download_file.ts new file mode 100644 index 0000000000..6d66994c2c --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/download_file.ts @@ -0,0 +1,105 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseDownloadFileParams, + DataverseDownloadFileResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseDownloadFile') + +export const dataverseDownloadFileTool: ToolConfig< + DataverseDownloadFileParams, + DataverseDownloadFileResponse +> = { + id: 'microsoft_dataverse_download_file', + name: 'Download File from Microsoft Dataverse', + description: + 'Download a file from a file or image column on a Dataverse record. Returns the file content as a base64-encoded string along with file metadata from response headers.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Record GUID to download the file from', + }, + fileColumn: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'File or image column logical name (e.g., entityimage, cr_document)', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})/${params.fileColumn}/$value` + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + }), + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse download file failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const fileName = response.headers.get('x-ms-file-name') ?? '' + const fileSize = response.headers.get('x-ms-file-size') ?? '' + const mimeType = response.headers.get('mimetype') ?? response.headers.get('content-type') ?? '' + + const buffer = await response.arrayBuffer() + const base64Content = Buffer.from(buffer).toString('base64') + + return { + success: true, + output: { + fileContent: base64Content, + fileName, + fileSize: fileSize ? Number.parseInt(fileSize, 10) : buffer.byteLength, + mimeType, + success: true, + }, + } + }, + + outputs: { + fileContent: { type: 'string', description: 'Base64-encoded file content' }, + fileName: { type: 'string', description: 'Name of the downloaded file', optional: true }, + fileSize: { type: 'number', description: 'File size in bytes' }, + mimeType: { type: 'string', description: 'MIME type of the file', optional: true }, + success: { type: 'boolean', description: 'Whether the file was downloaded successfully' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/execute_action.ts b/apps/sim/tools/microsoft_dataverse/execute_action.ts new file mode 100644 index 0000000000..aacaa11f8d --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/execute_action.ts @@ -0,0 +1,129 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseExecuteActionParams, + DataverseExecuteActionResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseExecuteAction') + +export const dataverseExecuteActionTool: ToolConfig< + DataverseExecuteActionParams, + DataverseExecuteActionResponse +> = { + id: 'microsoft_dataverse_execute_action', + name: 'Execute Microsoft Dataverse Action', + description: + 'Execute a bound or unbound Dataverse action. Actions perform operations with side effects (e.g., Merge, GrantAccess, SendEmail, QualifyLead). For bound actions, provide the entity set name and record ID.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + actionName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Action name (e.g., Merge, GrantAccess, SendEmail). Do not include the Microsoft.Dynamics.CRM. namespace prefix for unbound actions.', + }, + entitySetName: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Entity set name for bound actions (e.g., accounts). Leave empty for unbound actions.', + }, + recordId: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Record GUID for bound actions. Leave empty for unbound or collection-bound actions.', + }, + parameters: { + type: 'object', + required: false, + visibility: 'user-or-llm', + description: + 'Action parameters as a JSON object. For entity references, include @odata.type annotation (e.g., {"Target": {"@odata.type": "Microsoft.Dynamics.CRM.account", "accountid": "..."}})', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + if (params.entitySetName) { + if (params.recordId) { + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})/Microsoft.Dynamics.CRM.${params.actionName}` + } + return `${baseUrl}/api/data/v9.2/${params.entitySetName}/Microsoft.Dynamics.CRM.${params.actionName}` + } + return `${baseUrl}/api/data/v9.2/${params.actionName}` + }, + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + body: (params) => { + if (!params.parameters) return {} + let data = params.parameters + if (typeof data === 'string') { + try { + data = JSON.parse(data) + } catch { + throw new Error('Invalid JSON format for action parameters') + } + } + return data + }, + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse execute action failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = response.status === 204 ? null : await response.json().catch(() => null) + + return { + success: true, + output: { + result: data, + success: true, + }, + } + }, + + outputs: { + result: { + type: 'object', + description: + 'Action response data. Structure varies by action. Null for actions that return 204 No Content.', + optional: true, + }, + success: { type: 'boolean', description: 'Whether the action executed successfully' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/execute_function.ts b/apps/sim/tools/microsoft_dataverse/execute_function.ts new file mode 100644 index 0000000000..dcd44f791b --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/execute_function.ts @@ -0,0 +1,115 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseExecuteFunctionParams, + DataverseExecuteFunctionResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseExecuteFunction') + +export const dataverseExecuteFunctionTool: ToolConfig< + DataverseExecuteFunctionParams, + DataverseExecuteFunctionResponse +> = { + id: 'microsoft_dataverse_execute_function', + name: 'Execute Microsoft Dataverse Function', + description: + 'Execute a bound or unbound Dataverse function. Functions are read-only operations (e.g., RetrievePrincipalAccess, RetrieveTotalRecordCount, InitializeFrom). For bound functions, provide the entity set name and record ID.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + functionName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Function name (e.g., RetrievePrincipalAccess, RetrieveTotalRecordCount). Do not include the Microsoft.Dynamics.CRM. namespace prefix for unbound functions.', + }, + entitySetName: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Entity set name for bound functions (e.g., systemusers). Leave empty for unbound functions.', + }, + recordId: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Record GUID for bound functions. Leave empty for unbound functions.', + }, + parameters: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Function parameters as a comma-separated list of name=value pairs for the URL (e.g., "LocalizedStandardName=\'Pacific Standard Time\',LocaleId=1033"). Use @p1,@p2 aliases for complex values.', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + const paramStr = params.parameters ? `(${params.parameters})` : '()' + if (params.entitySetName) { + if (params.recordId) { + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})/Microsoft.Dynamics.CRM.${params.functionName}${paramStr}` + } + return `${baseUrl}/api/data/v9.2/${params.entitySetName}/Microsoft.Dynamics.CRM.${params.functionName}${paramStr}` + } + return `${baseUrl}/api/data/v9.2/${params.functionName}${paramStr}` + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse execute function failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = await response.json().catch(() => null) + + return { + success: true, + output: { + result: data, + success: true, + }, + } + }, + + outputs: { + result: { + type: 'object', + description: 'Function response data. Structure varies by function.', + optional: true, + }, + success: { type: 'boolean', description: 'Whether the function executed successfully' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/fetchxml_query.ts b/apps/sim/tools/microsoft_dataverse/fetchxml_query.ts new file mode 100644 index 0000000000..96af993277 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/fetchxml_query.ts @@ -0,0 +1,109 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseFetchXmlQueryParams, + DataverseFetchXmlQueryResponse, +} from '@/tools/microsoft_dataverse/types' +import { DATAVERSE_RECORDS_ARRAY_OUTPUT } from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseFetchXmlQuery') + +export const dataverseFetchXmlQueryTool: ToolConfig< + DataverseFetchXmlQueryParams, + DataverseFetchXmlQueryResponse +> = { + id: 'microsoft_dataverse_fetchxml_query', + name: 'FetchXML Query Microsoft Dataverse', + description: + 'Execute a FetchXML query against a Microsoft Dataverse table. FetchXML supports aggregation, grouping, linked-entity joins, and complex filtering beyond OData capabilities.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + fetchXml: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'FetchXML query string. Must include root element and child element matching the table logical name.', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + const encodedFetchXml = encodeURIComponent(params.fetchXml) + return `${baseUrl}/api/data/v9.2/${params.entitySetName}?fetchXml=${encodedFetchXml}` + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + Prefer: 'odata.include-annotations="*"', + }), + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse FetchXML query failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = await response.json() + const records = data.value ?? [] + const fetchXmlPagingCookie = data['@Microsoft.Dynamics.CRM.fetchxmlpagingcookie'] ?? null + const moreRecords = data['@Microsoft.Dynamics.CRM.morerecords'] ?? false + + return { + success: true, + output: { + records, + count: records.length, + fetchXmlPagingCookie, + moreRecords, + success: true, + }, + } + }, + + outputs: { + records: DATAVERSE_RECORDS_ARRAY_OUTPUT, + count: { type: 'number', description: 'Number of records returned in the current page' }, + fetchXmlPagingCookie: { + type: 'string', + description: 'Paging cookie for retrieving the next page of results', + optional: true, + }, + moreRecords: { + type: 'boolean', + description: 'Whether more records are available beyond the current page', + }, + success: { type: 'boolean', description: 'Operation success status' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/get_record.ts b/apps/sim/tools/microsoft_dataverse/get_record.ts new file mode 100644 index 0000000000..2f81394983 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/get_record.ts @@ -0,0 +1,115 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseGetRecordParams, + DataverseGetRecordResponse, +} from '@/tools/microsoft_dataverse/types' +import { DATAVERSE_RECORD_OUTPUT } from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseGetRecord') + +export const dataverseGetRecordTool: ToolConfig< + DataverseGetRecordParams, + DataverseGetRecordResponse +> = { + id: 'microsoft_dataverse_get_record', + name: 'Get Microsoft Dataverse Record', + description: + 'Retrieve a single record from a Microsoft Dataverse table by its ID. Supports $select and $expand OData query options.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The unique identifier (GUID) of the record to retrieve', + }, + select: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated list of columns to return (OData $select)', + }, + expand: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Navigation properties to expand (OData $expand)', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + const queryParts: string[] = [] + if (params.select) queryParts.push(`$select=${params.select}`) + if (params.expand) queryParts.push(`$expand=${params.expand}`) + const query = queryParts.length > 0 ? `?${queryParts.join('&')}` : '' + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})${query}` + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + Prefer: 'odata.include-annotations="*"', + }), + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse get record failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = await response.json() + const idKey = Object.keys(data).find((k) => k.endsWith('id') && !k.startsWith('@')) + const recordId = idKey ? String(data[idKey]) : '' + + return { + success: true, + output: { + record: data, + recordId, + success: true, + }, + } + }, + + outputs: { + record: DATAVERSE_RECORD_OUTPUT, + recordId: { + type: 'string', + description: 'The record primary key ID (auto-detected from response)', + optional: true, + }, + success: { type: 'boolean', description: 'Whether the record was retrieved successfully' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/index.ts b/apps/sim/tools/microsoft_dataverse/index.ts new file mode 100644 index 0000000000..df7b0e5880 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/index.ts @@ -0,0 +1,17 @@ +export { dataverseAssociateTool } from './associate' +export { dataverseCreateMultipleTool } from './create_multiple' +export { dataverseCreateRecordTool } from './create_record' +export { dataverseDeleteRecordTool } from './delete_record' +export { dataverseDisassociateTool } from './disassociate' +export { dataverseDownloadFileTool } from './download_file' +export { dataverseExecuteActionTool } from './execute_action' +export { dataverseExecuteFunctionTool } from './execute_function' +export { dataverseFetchXmlQueryTool } from './fetchxml_query' +export { dataverseGetRecordTool } from './get_record' +export { dataverseListRecordsTool } from './list_records' +export { dataverseSearchTool } from './search' +export { dataverseUpdateMultipleTool } from './update_multiple' +export { dataverseUpdateRecordTool } from './update_record' +export { dataverseUploadFileTool } from './upload_file' +export { dataverseUpsertRecordTool } from './upsert_record' +export { dataverseWhoAmITool } from './whoami' diff --git a/apps/sim/tools/microsoft_dataverse/list_records.ts b/apps/sim/tools/microsoft_dataverse/list_records.ts new file mode 100644 index 0000000000..0fba025db2 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/list_records.ts @@ -0,0 +1,146 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseListRecordsParams, + DataverseListRecordsResponse, +} from '@/tools/microsoft_dataverse/types' +import { DATAVERSE_RECORDS_ARRAY_OUTPUT } from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseListRecords') + +export const dataverseListRecordsTool: ToolConfig< + DataverseListRecordsParams, + DataverseListRecordsResponse +> = { + id: 'microsoft_dataverse_list_records', + name: 'List Microsoft Dataverse Records', + description: + 'Query and list records from a Microsoft Dataverse table. Supports OData query options for filtering, selecting columns, ordering, and pagination.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + select: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Comma-separated list of columns to return (OData $select)', + }, + filter: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'OData $filter expression (e.g., statecode eq 0)', + }, + orderBy: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'OData $orderby expression (e.g., name asc, createdon desc)', + }, + top: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Maximum number of records to return (OData $top)', + }, + expand: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Navigation properties to expand (OData $expand)', + }, + count: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Set to "true" to include total record count in response (OData $count)', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + const queryParts: string[] = [] + if (params.select) queryParts.push(`$select=${params.select}`) + if (params.filter) queryParts.push(`$filter=${params.filter}`) + if (params.orderBy) queryParts.push(`$orderby=${params.orderBy}`) + if (params.top) queryParts.push(`$top=${params.top}`) + if (params.expand) queryParts.push(`$expand=${params.expand}`) + if (params.count) queryParts.push(`$count=${params.count}`) + const query = queryParts.length > 0 ? `?${queryParts.join('&')}` : '' + return `${baseUrl}/api/data/v9.2/${params.entitySetName}${query}` + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + Prefer: 'odata.include-annotations="*",odata.maxpagesize=100', + }), + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse list records failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = await response.json() + const records = data.value ?? [] + const nextLink = data['@odata.nextLink'] ?? null + const totalCount = data['@odata.count'] ?? null + + return { + success: true, + output: { + records, + count: records.length, + totalCount, + nextLink, + success: true, + }, + } + }, + + outputs: { + records: DATAVERSE_RECORDS_ARRAY_OUTPUT, + count: { type: 'number', description: 'Number of records returned in the current page' }, + totalCount: { + type: 'number', + description: 'Total number of matching records server-side (requires $count=true)', + optional: true, + }, + nextLink: { + type: 'string', + description: 'URL for the next page of results', + optional: true, + }, + success: { type: 'boolean', description: 'Operation success status' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/search.ts b/apps/sim/tools/microsoft_dataverse/search.ts new file mode 100644 index 0000000000..20ecb76baa --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/search.ts @@ -0,0 +1,206 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseSearchParams, + DataverseSearchResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseSearch') + +export const dataverseSearchTool: ToolConfig = { + id: 'microsoft_dataverse_search', + name: 'Search Microsoft Dataverse', + description: + 'Perform a full-text relevance search across Microsoft Dataverse tables. Requires Dataverse Search to be enabled on the environment. Supports simple and Lucene query syntax.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + searchTerm: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Search text (1-100 chars). Supports simple syntax: + (AND), | (OR), - (NOT), * (wildcard), "exact phrase"', + }, + entities: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'JSON array of search entity configs. Each object: {"Name":"account","SelectColumns":["name"],"SearchColumns":["name"],"Filter":"statecode eq 0"}', + }, + filter: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Global OData filter applied across all entities (e.g., "createdon gt 2024-01-01")', + }, + facets: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'JSON array of facet specifications (e.g., ["entityname,count:100","ownerid,count:100"])', + }, + top: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Maximum number of results (default: 50, max: 100)', + }, + skip: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of results to skip for pagination', + }, + orderBy: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'JSON array of sort expressions (e.g., ["createdon desc"])', + }, + searchMode: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Search mode: "any" (default, match any term) or "all" (match all terms)', + }, + searchType: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: + 'Query type: "simple" (default) or "lucene" (enables regex, fuzzy, proximity, boosting)', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/searchquery` + }, + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + body: (params) => { + const body: Record = { + search: params.searchTerm, + count: true, + } + if (params.entities) body.entities = params.entities + if (params.filter) body.filter = params.filter + if (params.facets) body.facets = params.facets + if (params.top) body.top = params.top + if (params.skip) body.skip = params.skip + if (params.orderBy) body.orderby = params.orderBy + + const options: Record = {} + if (params.searchMode) options.searchmode = params.searchMode + if (params.searchType) options.querytype = params.searchType + if (Object.keys(options).length > 0) { + body.options = JSON.stringify(options).replace(/"/g, "'") + } + + return body + }, + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse search failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = await response.json() + let parsedResponse = data.response + if (typeof parsedResponse === 'string') { + try { + parsedResponse = JSON.parse(parsedResponse) + } catch { + parsedResponse = {} + } + } + + const results = parsedResponse?.Value ?? [] + const totalCount = parsedResponse?.Count ?? 0 + const facets = parsedResponse?.Facets ?? null + + return { + success: true, + output: { + results, + totalCount, + count: results.length, + facets, + success: true, + }, + } + }, + + outputs: { + results: { + type: 'array', + description: 'Array of search result objects', + items: { + type: 'object', + properties: { + Id: { type: 'string', description: 'Record GUID' }, + EntityName: { + type: 'string', + description: 'Table logical name (e.g., account, contact)', + }, + ObjectTypeCode: { type: 'number', description: 'Entity type code' }, + Attributes: { + type: 'object', + description: 'Record attributes matching the search. Keys are column logical names.', + }, + Highlights: { + type: 'object', + description: + 'Highlighted search matches. Keys are column names, values are arrays of strings with {crmhit}/{/crmhit} markers.', + optional: true, + }, + Score: { type: 'number', description: 'Relevance score for this result' }, + }, + }, + }, + totalCount: { + type: 'number', + description: 'Total number of matching records across all tables', + }, + count: { type: 'number', description: 'Number of results returned in this page' }, + facets: { + type: 'object', + description: + 'Facet results when facets were requested. Keys are facet names, values are arrays of facet value objects with count and value properties.', + optional: true, + }, + success: { type: 'boolean', description: 'Operation success status' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/types.ts b/apps/sim/tools/microsoft_dataverse/types.ts new file mode 100644 index 0000000000..f7e1e7bcad --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/types.ts @@ -0,0 +1,367 @@ +import type { OutputProperty, ToolResponse } from '@/tools/types' + +/** + * Microsoft Dataverse Web API types. + * @see https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/overview + */ + +/** + * Dataverse record output definition. + * Dataverse records are dynamic (user-defined tables), so columns vary by table. + * Every record includes OData metadata fields such as `@odata.etag`. + * @see https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/retrieve-entity-using-web-api + */ +export const DATAVERSE_RECORD_OUTPUT: OutputProperty = { + type: 'object', + description: + 'Dataverse record object. Contains dynamic columns based on the queried table, plus OData metadata fields.', + properties: { + '@odata.context': { + type: 'string', + description: 'OData context URL describing the entity type and properties returned', + optional: true, + }, + '@odata.etag': { + type: 'string', + description: 'OData entity tag for concurrency control (e.g., W/"12345")', + optional: true, + }, + }, +} + +/** + * Array of Dataverse records output definition for list endpoints. + * Each item mirrors `DATAVERSE_RECORD_OUTPUT`. + * @see https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/query-data-web-api + */ +export const DATAVERSE_RECORDS_ARRAY_OUTPUT: OutputProperty = { + type: 'array', + description: + 'Array of Dataverse records. Each record has dynamic columns based on the table schema.', + items: { + type: 'object', + description: 'A single Dataverse record with dynamic columns based on the table schema', + properties: { + '@odata.etag': { + type: 'string', + description: 'OData entity tag for concurrency control (e.g., W/"12345")', + optional: true, + }, + }, + }, +} + +export interface DataverseCreateRecordParams { + accessToken: string + environmentUrl: string + entitySetName: string + data: Record +} + +export interface DataverseGetRecordParams { + accessToken: string + environmentUrl: string + entitySetName: string + recordId: string + select?: string + expand?: string +} + +export interface DataverseUpdateRecordParams { + accessToken: string + environmentUrl: string + entitySetName: string + recordId: string + data: Record +} + +export interface DataverseDeleteRecordParams { + accessToken: string + environmentUrl: string + entitySetName: string + recordId: string +} + +export interface DataverseListRecordsParams { + accessToken: string + environmentUrl: string + entitySetName: string + select?: string + filter?: string + orderBy?: string + top?: number + expand?: string + count?: string +} + +export interface DataverseCreateRecordResponse extends ToolResponse { + output: { + recordId: string + record: Record + success: boolean + } +} + +export interface DataverseGetRecordResponse extends ToolResponse { + output: { + record: Record + recordId: string + success: boolean + } +} + +export interface DataverseUpdateRecordResponse extends ToolResponse { + output: { + recordId: string + success: boolean + } +} + +export interface DataverseDeleteRecordResponse extends ToolResponse { + output: { + recordId: string + success: boolean + } +} + +export interface DataverseListRecordsResponse extends ToolResponse { + output: { + records: Record[] + count: number + totalCount: number | null + nextLink: string | null + success: boolean + } +} + +export interface DataverseUpsertRecordParams { + accessToken: string + environmentUrl: string + entitySetName: string + recordId: string + data: Record +} + +export interface DataverseUpsertRecordResponse extends ToolResponse { + output: { + recordId: string + created: boolean + record: Record | null + success: boolean + } +} + +export interface DataverseWhoAmIParams { + accessToken: string + environmentUrl: string +} + +export interface DataverseWhoAmIResponse extends ToolResponse { + output: { + userId: string + businessUnitId: string + organizationId: string + success: boolean + } +} + +export interface DataverseAssociateParams { + accessToken: string + environmentUrl: string + entitySetName: string + recordId: string + navigationProperty: string + targetEntitySetName: string + targetRecordId: string + navigationType?: 'collection' | 'single' +} + +export interface DataverseAssociateResponse extends ToolResponse { + output: { + success: boolean + entitySetName: string + recordId: string + navigationProperty: string + targetEntitySetName: string + targetRecordId: string + } +} + +export interface DataverseDisassociateParams { + accessToken: string + environmentUrl: string + entitySetName: string + recordId: string + navigationProperty: string + targetRecordId?: string +} + +export interface DataverseDisassociateResponse extends ToolResponse { + output: { + success: boolean + entitySetName: string + recordId: string + navigationProperty: string + targetRecordId?: string + } +} + +export interface DataverseFetchXmlQueryParams { + accessToken: string + environmentUrl: string + entitySetName: string + fetchXml: string +} + +export interface DataverseFetchXmlQueryResponse extends ToolResponse { + output: { + records: Record[] + count: number + fetchXmlPagingCookie: string | null + moreRecords: boolean + success: boolean + } +} + +export interface DataverseExecuteActionParams { + accessToken: string + environmentUrl: string + actionName: string + entitySetName?: string + recordId?: string + parameters?: Record +} + +export interface DataverseExecuteActionResponse extends ToolResponse { + output: { + result: Record | null + success: boolean + } +} + +export interface DataverseExecuteFunctionParams { + accessToken: string + environmentUrl: string + functionName: string + entitySetName?: string + recordId?: string + parameters?: string +} + +export interface DataverseExecuteFunctionResponse extends ToolResponse { + output: { + result: Record | null + success: boolean + } +} + +export interface DataverseCreateMultipleParams { + accessToken: string + environmentUrl: string + entitySetName: string + entityLogicalName: string + records: Record[] +} + +export interface DataverseCreateMultipleResponse extends ToolResponse { + output: { + ids: string[] + count: number + success: boolean + } +} + +export interface DataverseUpdateMultipleParams { + accessToken: string + environmentUrl: string + entitySetName: string + entityLogicalName: string + records: Record[] +} + +export interface DataverseUpdateMultipleResponse extends ToolResponse { + output: { + success: boolean + } +} + +export interface DataverseUploadFileParams { + accessToken: string + environmentUrl: string + entitySetName: string + recordId: string + fileColumn: string + fileName: string + file?: unknown + fileContent?: string +} + +export interface DataverseUploadFileResponse extends ToolResponse { + output: { + recordId: string + fileColumn: string + fileName: string + success: boolean + } +} + +export interface DataverseDownloadFileParams { + accessToken: string + environmentUrl: string + entitySetName: string + recordId: string + fileColumn: string +} + +export interface DataverseDownloadFileResponse extends ToolResponse { + output: { + fileContent: string + fileName: string + fileSize: number + mimeType: string + success: boolean + } +} + +export interface DataverseSearchParams { + accessToken: string + environmentUrl: string + searchTerm: string + entities?: string + filter?: string + facets?: string + top?: number + skip?: number + orderBy?: string + searchMode?: string + searchType?: string +} + +export interface DataverseSearchResponse extends ToolResponse { + output: { + results: Record[] + totalCount: number + count: number + facets: Record | null + success: boolean + } +} + +export type DataverseResponse = + | DataverseCreateRecordResponse + | DataverseGetRecordResponse + | DataverseUpdateRecordResponse + | DataverseDeleteRecordResponse + | DataverseListRecordsResponse + | DataverseUpsertRecordResponse + | DataverseWhoAmIResponse + | DataverseAssociateResponse + | DataverseDisassociateResponse + | DataverseFetchXmlQueryResponse + | DataverseExecuteActionResponse + | DataverseExecuteFunctionResponse + | DataverseCreateMultipleResponse + | DataverseUpdateMultipleResponse + | DataverseUploadFileResponse + | DataverseDownloadFileResponse + | DataverseSearchResponse diff --git a/apps/sim/tools/microsoft_dataverse/update_multiple.ts b/apps/sim/tools/microsoft_dataverse/update_multiple.ts new file mode 100644 index 0000000000..fd93c7d112 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/update_multiple.ts @@ -0,0 +1,112 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseUpdateMultipleParams, + DataverseUpdateMultipleResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseUpdateMultiple') + +export const dataverseUpdateMultipleTool: ToolConfig< + DataverseUpdateMultipleParams, + DataverseUpdateMultipleResponse +> = { + id: 'microsoft_dataverse_update_multiple', + name: 'Update Multiple Microsoft Dataverse Records', + description: + 'Update multiple records of the same table type in a single request. Each record must include its primary key. Only include columns that need to be changed. Recommended batch size: 100-1000 records.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + entityLogicalName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Table logical name for @odata.type annotation (e.g., account, contact). Used to set Microsoft.Dynamics.CRM.{entityLogicalName} on each record.', + }, + records: { + type: 'object', + required: true, + visibility: 'user-or-llm', + description: + 'Array of record objects to update. Each record must include its primary key (e.g., accountid) and only the columns being changed. The @odata.type annotation is added automatically.', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/${params.entitySetName}/Microsoft.Dynamics.CRM.UpdateMultiple` + }, + method: 'POST', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + body: (params) => { + let records = params.records + if (typeof records === 'string') { + try { + records = JSON.parse(records) + } catch { + throw new Error('Invalid JSON format for records array') + } + } + if (!Array.isArray(records)) { + throw new Error('Records must be an array of objects') + } + const targets = records.map((record: Record) => ({ + ...record, + '@odata.type': `Microsoft.Dynamics.CRM.${params.entityLogicalName}`, + })) + return { Targets: targets } + }, + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse update multiple failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + return { + success: true, + output: { + success: true, + }, + } + }, + + outputs: { + success: { type: 'boolean', description: 'Whether all records were updated successfully' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/update_record.ts b/apps/sim/tools/microsoft_dataverse/update_record.ts new file mode 100644 index 0000000000..a5af3820b2 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/update_record.ts @@ -0,0 +1,106 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseUpdateRecordParams, + DataverseUpdateRecordResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseUpdateRecord') + +export const dataverseUpdateRecordTool: ToolConfig< + DataverseUpdateRecordParams, + DataverseUpdateRecordResponse +> = { + id: 'microsoft_dataverse_update_record', + name: 'Update Microsoft Dataverse Record', + description: + 'Update an existing record in a Microsoft Dataverse table. Only send the columns you want to change.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The unique identifier (GUID) of the record to update', + }, + data: { + type: 'object', + required: true, + visibility: 'user-or-llm', + description: 'Record data to update as a JSON object with column names as keys', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})` + }, + method: 'PATCH', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + 'If-Match': '*', + }), + body: (params) => { + let data = params.data + if (typeof data === 'string') { + try { + data = JSON.parse(data) + } catch { + throw new Error('Invalid JSON format for record data') + } + } + return data + }, + }, + + transformResponse: async (response: Response, params?: DataverseUpdateRecordParams) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse update record failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + return { + success: true, + output: { + recordId: params?.recordId ?? '', + success: true, + }, + } + }, + + outputs: { + recordId: { type: 'string', description: 'The ID of the updated record' }, + success: { type: 'boolean', description: 'Operation success status' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/upload_file.ts b/apps/sim/tools/microsoft_dataverse/upload_file.ts new file mode 100644 index 0000000000..a8025fe091 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/upload_file.ts @@ -0,0 +1,107 @@ +import type { + DataverseUploadFileParams, + DataverseUploadFileResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +export const dataverseUploadFileTool: ToolConfig< + DataverseUploadFileParams, + DataverseUploadFileResponse +> = { + id: 'microsoft_dataverse_upload_file', + name: 'Upload File to Microsoft Dataverse', + description: + 'Upload a file to a file or image column on a Dataverse record. Supports single-request upload for files up to 128 MB. The file content must be provided as a base64-encoded string.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Record GUID to upload the file to', + }, + fileColumn: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'File or image column logical name (e.g., entityimage, cr_document)', + }, + fileName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Name of the file being uploaded (e.g., document.pdf)', + }, + file: { + type: 'file', + required: false, + visibility: 'user-only', + description: 'File to upload (UserFile object)', + }, + fileContent: { + type: 'string', + required: false, + visibility: 'hidden', + description: 'Base64-encoded file content (legacy)', + }, + }, + + request: { + url: '/api/tools/microsoft-dataverse/upload-file', + method: 'POST', + headers: () => ({ + 'Content-Type': 'application/json', + }), + body: (params) => ({ + accessToken: params.accessToken, + environmentUrl: params.environmentUrl, + entitySetName: params.entitySetName, + recordId: params.recordId, + fileColumn: params.fileColumn, + fileName: params.fileName, + file: params.file, + fileContent: params.fileContent, + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + if (!data.success) { + throw new Error(data.error || 'Dataverse upload file failed') + } + + return { + success: true, + output: data.output, + } + }, + + outputs: { + recordId: { type: 'string', description: 'Record GUID the file was uploaded to' }, + fileColumn: { type: 'string', description: 'File column the file was uploaded to' }, + fileName: { type: 'string', description: 'Name of the uploaded file' }, + success: { type: 'boolean', description: 'Whether the file was uploaded successfully' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/upsert_record.ts b/apps/sim/tools/microsoft_dataverse/upsert_record.ts new file mode 100644 index 0000000000..3fa16d2b2c --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/upsert_record.ts @@ -0,0 +1,114 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseUpsertRecordParams, + DataverseUpsertRecordResponse, +} from '@/tools/microsoft_dataverse/types' +import { DATAVERSE_RECORD_OUTPUT } from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseUpsertRecord') + +export const dataverseUpsertRecordTool: ToolConfig< + DataverseUpsertRecordParams, + DataverseUpsertRecordResponse +> = { + id: 'microsoft_dataverse_upsert_record', + name: 'Upsert Microsoft Dataverse Record', + description: + 'Create or update a record in a Microsoft Dataverse table. If a record with the given ID exists, it is updated; otherwise, a new record is created.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + entitySetName: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'Entity set name (plural table name, e.g., accounts, contacts)', + }, + recordId: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The unique identifier (GUID) of the record to upsert', + }, + data: { + type: 'object', + required: true, + visibility: 'user-or-llm', + description: 'Record data as a JSON object with column names as keys', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/${params.entitySetName}(${params.recordId})` + }, + method: 'PATCH', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + Prefer: 'return=representation', + }), + body: (params) => { + let data = params.data + if (typeof data === 'string') { + try { + data = JSON.parse(data) + } catch { + throw new Error('Invalid JSON format for record data') + } + } + return data + }, + }, + + transformResponse: async (response: Response, params?: DataverseUpsertRecordParams) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse upsert record failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const created = response.status === 201 + const data = await response.json().catch(() => null) + + return { + success: true, + output: { + recordId: params?.recordId ?? '', + created, + record: data, + success: true, + }, + } + }, + + outputs: { + recordId: { type: 'string', description: 'The ID of the upserted record' }, + created: { type: 'boolean', description: 'True if the record was created, false if updated' }, + record: { ...DATAVERSE_RECORD_OUTPUT, optional: true }, + success: { type: 'boolean', description: 'Operation success status' }, + }, +} diff --git a/apps/sim/tools/microsoft_dataverse/whoami.ts b/apps/sim/tools/microsoft_dataverse/whoami.ts new file mode 100644 index 0000000000..7d70e5ee12 --- /dev/null +++ b/apps/sim/tools/microsoft_dataverse/whoami.ts @@ -0,0 +1,78 @@ +import { createLogger } from '@sim/logger' +import type { + DataverseWhoAmIParams, + DataverseWhoAmIResponse, +} from '@/tools/microsoft_dataverse/types' +import type { ToolConfig } from '@/tools/types' + +const logger = createLogger('DataverseWhoAmI') + +export const dataverseWhoAmITool: ToolConfig = { + id: 'microsoft_dataverse_whoami', + name: 'Microsoft Dataverse WhoAmI', + description: + 'Retrieve the current authenticated user information from Microsoft Dataverse. Useful for testing connectivity and getting the user ID, business unit ID, and organization ID.', + version: '1.0.0', + + oauth: { required: true, provider: 'microsoft-dataverse' }, + errorExtractor: 'nested-error-object', + + params: { + accessToken: { + type: 'string', + required: true, + visibility: 'hidden', + description: 'OAuth access token for Microsoft Dataverse API', + }, + environmentUrl: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'Dataverse environment URL (e.g., https://myorg.crm.dynamics.com)', + }, + }, + + request: { + url: (params) => { + const baseUrl = params.environmentUrl.replace(/\/$/, '') + return `${baseUrl}/api/data/v9.2/WhoAmI()` + }, + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.accessToken}`, + 'OData-MaxVersion': '4.0', + 'OData-Version': '4.0', + Accept: 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + if (!response.ok) { + const errorData = await response.json().catch(() => ({})) + const errorMessage = + errorData?.error?.message ?? + `Dataverse API error: ${response.status} ${response.statusText}` + logger.error('Dataverse WhoAmI failed', { errorData, status: response.status }) + throw new Error(errorMessage) + } + + const data = await response.json() + + return { + success: true, + output: { + userId: data.UserId ?? '', + businessUnitId: data.BusinessUnitId ?? '', + organizationId: data.OrganizationId ?? '', + success: true, + }, + } + }, + + outputs: { + userId: { type: 'string', description: 'The authenticated user ID' }, + businessUnitId: { type: 'string', description: 'The business unit ID' }, + organizationId: { type: 'string', description: 'The organization ID' }, + success: { type: 'boolean', description: 'Operation success status' }, + }, +} diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index f931313a15..b308f6eb65 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -110,6 +110,21 @@ import { clerkRevokeSessionTool, clerkUpdateUserTool, } from '@/tools/clerk' +import { + cloudflareCreateDnsRecordTool, + cloudflareCreateZoneTool, + cloudflareDeleteDnsRecordTool, + cloudflareDeleteZoneTool, + cloudflareDnsAnalyticsTool, + cloudflareGetZoneSettingsTool, + cloudflareGetZoneTool, + cloudflareListCertificatesTool, + cloudflareListDnsRecordsTool, + cloudflareListZonesTool, + cloudflarePurgeCacheTool, + cloudflareUpdateDnsRecordTool, + cloudflareUpdateZoneSettingTool, +} from '@/tools/cloudflare' import { confluenceAddLabelTool, confluenceCreateBlogPostTool, @@ -1074,6 +1089,25 @@ import { } from '@/tools/mailgun' import { mem0AddMemoriesTool, mem0GetMemoriesTool, mem0SearchMemoriesTool } from '@/tools/mem0' import { memoryAddTool, memoryDeleteTool, memoryGetAllTool, memoryGetTool } from '@/tools/memory' +import { + dataverseAssociateTool, + dataverseCreateMultipleTool, + dataverseCreateRecordTool, + dataverseDeleteRecordTool, + dataverseDisassociateTool, + dataverseDownloadFileTool, + dataverseExecuteActionTool, + dataverseExecuteFunctionTool, + dataverseFetchXmlQueryTool, + dataverseGetRecordTool, + dataverseListRecordsTool, + dataverseSearchTool, + dataverseUpdateMultipleTool, + dataverseUpdateRecordTool, + dataverseUploadFileTool, + dataverseUpsertRecordTool, + dataverseWhoAmITool, +} from '@/tools/microsoft_dataverse' import { microsoftExcelReadTool, microsoftExcelReadV2Tool, @@ -2934,6 +2968,19 @@ export const tools: Record = { clerk_list_sessions: clerkListSessionsTool, clerk_get_session: clerkGetSessionTool, clerk_revoke_session: clerkRevokeSessionTool, + cloudflare_list_zones: cloudflareListZonesTool, + cloudflare_get_zone: cloudflareGetZoneTool, + cloudflare_create_zone: cloudflareCreateZoneTool, + cloudflare_delete_zone: cloudflareDeleteZoneTool, + cloudflare_list_dns_records: cloudflareListDnsRecordsTool, + cloudflare_create_dns_record: cloudflareCreateDnsRecordTool, + cloudflare_update_dns_record: cloudflareUpdateDnsRecordTool, + cloudflare_delete_dns_record: cloudflareDeleteDnsRecordTool, + cloudflare_list_certificates: cloudflareListCertificatesTool, + cloudflare_get_zone_settings: cloudflareGetZoneSettingsTool, + cloudflare_update_zone_setting: cloudflareUpdateZoneSettingTool, + cloudflare_dns_analytics: cloudflareDnsAnalyticsTool, + cloudflare_purge_cache: cloudflarePurgeCacheTool, discord_send_message: discordSendMessageTool, discord_get_messages: discordGetMessagesTool, discord_get_server: discordGetServerTool, @@ -3114,6 +3161,23 @@ export const tools: Record = { onedrive_download: onedriveDownloadTool, onedrive_list: onedriveListTool, onedrive_upload: onedriveUploadTool, + microsoft_dataverse_associate: dataverseAssociateTool, + microsoft_dataverse_create_multiple: dataverseCreateMultipleTool, + microsoft_dataverse_create_record: dataverseCreateRecordTool, + microsoft_dataverse_delete_record: dataverseDeleteRecordTool, + microsoft_dataverse_disassociate: dataverseDisassociateTool, + microsoft_dataverse_download_file: dataverseDownloadFileTool, + microsoft_dataverse_execute_action: dataverseExecuteActionTool, + microsoft_dataverse_execute_function: dataverseExecuteFunctionTool, + microsoft_dataverse_fetchxml_query: dataverseFetchXmlQueryTool, + microsoft_dataverse_get_record: dataverseGetRecordTool, + microsoft_dataverse_list_records: dataverseListRecordsTool, + microsoft_dataverse_search: dataverseSearchTool, + microsoft_dataverse_update_multiple: dataverseUpdateMultipleTool, + microsoft_dataverse_update_record: dataverseUpdateRecordTool, + microsoft_dataverse_upload_file: dataverseUploadFileTool, + microsoft_dataverse_upsert_record: dataverseUpsertRecordTool, + microsoft_dataverse_whoami: dataverseWhoAmITool, microsoft_excel_read: microsoftExcelReadTool, microsoft_excel_write: microsoftExcelWriteTool, microsoft_excel_table_add: microsoftExcelTableAddTool,