diff --git a/apps/sim/blocks/blocks/tailscale.ts b/apps/sim/blocks/blocks/tailscale.ts index de385e83b08..851441f5ce5 100644 --- a/apps/sim/blocks/blocks/tailscale.ts +++ b/apps/sim/blocks/blocks/tailscale.ts @@ -775,7 +775,7 @@ export const TailscaleBlock: BlockConfig = { if ( params.operation === 'create_auth_key' && params.expirySeconds != null && - params.expirySeconds !== '' + !(typeof params.expirySeconds === 'string' && params.expirySeconds.trim() === '') ) { const expirySeconds = Number(params.expirySeconds) if (!Number.isFinite(expirySeconds)) throw new Error('Expiry must be a finite number') diff --git a/apps/sim/lib/workflows/editing/builders.test.ts b/apps/sim/lib/workflows/editing/builders.test.ts index 2d222e8f870..67315497dd5 100644 --- a/apps/sim/lib/workflows/editing/builders.test.ts +++ b/apps/sim/lib/workflows/editing/builders.test.ts @@ -20,7 +20,7 @@ import { TailscaleBlock } from '@/blocks/blocks/tailscale' import { getAllBlocks, getBlock } from '@/blocks/registry' import { prepareBlockState } from '@/stores/workflows/prepare-block-state' import type { BlockState } from '@/stores/workflows/workflow/types' -import { tailscaleAuthorizeDeviceTool } from '@/tools/tailscale' +import { tailscaleAuthorizeDeviceTool, tailscaleCreateAuthKeyTool } from '@/tools/tailscale' const mockIsIntegrationDeploymentAvailable = integrationsAvailabilityMockFns.mockIsIntegrationDeploymentAvailableForVisibility @@ -214,6 +214,20 @@ describe('createBlockFromParams', () => { ).toMatchObject({ authorized: false }) }) + it.each(['', ' ', null, undefined])( + 'omits cleared auth-key expiry %j so the provider default applies', + (expirySeconds) => { + const transform = TailscaleBlock.tools?.config?.params + if (!transform) throw new Error('Tailscale has no parameter transform') + const body = tailscaleCreateAuthKeyTool.request.body?.({ + apiKey: 'test-token', + tailnet: '-', + ...transform({ operation: 'create_auth_key', expirySeconds }), + }) + expect(JSON.stringify(body)).not.toContain('"expirySeconds"') + } + ) + it('exposes the output ports of the seeded Agent default', () => { const block = createBlockFromParams( 'agent-research-default', diff --git a/apps/sim/tools/tailscale/get_dns_configuration.ts b/apps/sim/tools/tailscale/get_dns_configuration.ts index eed556004d1..966ed557a50 100644 --- a/apps/sim/tools/tailscale/get_dns_configuration.ts +++ b/apps/sim/tools/tailscale/get_dns_configuration.ts @@ -1,9 +1,10 @@ +import { DNS_CONFIGURATION_OUTPUT } from '@/tools/tailscale/outputs' import type { TailscaleBaseParams, TailscaleDnsConfiguration, TailscaleGetDnsConfigurationResponse, } from '@/tools/tailscale/types' -import { assertTailscaleResponse } from '@/tools/tailscale/utils' +import { assertTailscaleResponse, mapTailscaleDnsConfiguration } from '@/tools/tailscale/utils' import type { ToolConfig } from '@/tools/types' import { safeUrlPathSegment } from '@/tools/url-path' @@ -42,72 +43,9 @@ export const tailscaleGetDnsConfigurationTool: ToolConfig< return { success: true, output: { - dnsConfiguration: { - nameservers: data.nameservers ?? [], - splitDNS: data.splitDNS ?? null, - searchPaths: data.searchPaths ?? [], - preferences: data.preferences ?? null, - }, + dnsConfiguration: mapTailscaleDnsConfiguration(data), }, } }, - outputs: { - dnsConfiguration: { - type: 'json', - description: 'Dns configuration', - properties: { - nameservers: { - type: 'array', - description: 'Global DNS resolvers to use', - items: { - type: 'json', - properties: { - address: { - type: 'string', - description: 'IPv4 or IPv6 address of the DNS resolver', - optional: true, - }, - useWithExitNode: { - type: 'boolean', - description: - 'If true, this resolver should still be used when a device is configured to use a Tailscale exit node', - optional: true, - }, - }, - }, - }, - splitDNS: { - type: 'json', - description: - 'Map of DNS name suffixes (domains) to lists of resolvers for Split DNS and advanced routing overlays', - nullable: true, - }, - searchPaths: { - type: 'array', - description: 'Search domain paths to apply', - items: { - type: 'string', - }, - }, - preferences: { - type: 'json', - description: 'Preferences', - properties: { - overrideLocalDNS: { - type: 'boolean', - description: - 'If true, resolvers in `nameservers` override the local OS DNS configuration; if false, local resolvers are used', - optional: true, - }, - magicDNS: { - type: 'boolean', - description: 'Whether MagicDNS is enabled for this tailnet', - optional: true, - }, - }, - nullable: true, - }, - }, - }, - }, + outputs: DNS_CONFIGURATION_OUTPUT, } diff --git a/apps/sim/tools/tailscale/get_tailnet_settings.ts b/apps/sim/tools/tailscale/get_tailnet_settings.ts index 27cf1c4a1e2..bb8730fe7ad 100644 --- a/apps/sim/tools/tailscale/get_tailnet_settings.ts +++ b/apps/sim/tools/tailscale/get_tailnet_settings.ts @@ -1,9 +1,10 @@ +import { TAILNET_SETTINGS_OUTPUT } from '@/tools/tailscale/outputs' import type { TailscaleBaseParams, TailscaleGetTailnetSettingsResponse, TailscaleTailnetSettings, } from '@/tools/tailscale/types' -import { assertTailscaleResponse } from '@/tools/tailscale/utils' +import { assertTailscaleResponse, mapTailscaleTailnetSettings } from '@/tools/tailscale/utils' import type { ToolConfig } from '@/tools/types' import { safeUrlPathSegment } from '@/tools/url-path' @@ -42,109 +43,9 @@ export const tailscaleGetTailnetSettingsTool: ToolConfig< return { success: true, output: { - settings: { - aclsExternallyManagedOn: data.aclsExternallyManagedOn ?? null, - aclsExternalLink: data.aclsExternalLink ?? null, - adminConsoleSessionTimeoutMinutes: data.adminConsoleSessionTimeoutMinutes ?? null, - devicesApprovalOn: data.devicesApprovalOn ?? null, - devicesAutoUpdatesOn: data.devicesAutoUpdatesOn ?? null, - devicesKeyDurationDays: data.devicesKeyDurationDays ?? null, - usersApprovalOn: data.usersApprovalOn ?? null, - usersRoleAllowedToJoinExternalTailnets: - data.usersRoleAllowedToJoinExternalTailnets ?? null, - networkFlowLoggingOn: data.networkFlowLoggingOn ?? null, - regionalRoutingOn: data.regionalRoutingOn ?? null, - routeSelection: data.routeSelection ?? null, - postureIdentityCollectionOn: data.postureIdentityCollectionOn ?? null, - httpsEnabled: data.httpsEnabled ?? null, - }, + settings: mapTailscaleTailnetSettings(data), }, } }, - outputs: { - settings: { - type: 'json', - description: 'Settings for a tailnet', - properties: { - aclsExternallyManagedOn: { - type: 'boolean', - description: - 'Prevents users from editing policies in the admin console to avoid conflicts with external management workflows like GitOps or Terraform', - nullable: true, - }, - aclsExternalLink: { - type: 'string', - description: - 'Link to the external tailnet policy definition or management solution for this tailnet', - nullable: true, - }, - adminConsoleSessionTimeoutMinutes: { - type: 'number', - description: - 'The [admin console session timeout](/docs/account/admin-console-session-timeout) for members of this tailnet', - nullable: true, - }, - devicesApprovalOn: { - type: 'boolean', - description: - 'Whether [device approval](/docs/features/access-control/device-management/device-approval) is enabled for the tailnet', - nullable: true, - }, - devicesAutoUpdatesOn: { - type: 'boolean', - description: - 'Whether [auto updates](/docs/features/client/update#auto-updates) are enabled for devices that belong to this tailnet', - nullable: true, - }, - devicesKeyDurationDays: { - type: 'number', - description: - 'The [key expiry](/docs/features/access-control/key-expiry) duration for devices on this tailnet', - nullable: true, - }, - usersApprovalOn: { - type: 'boolean', - description: - 'Whether [user approval](/docs/features/access-control/user-approval) is enabled for this tailnet', - nullable: true, - }, - usersRoleAllowedToJoinExternalTailnets: { - type: 'string', - description: - 'Which user roles are allowed to [join external tailnets](/docs/features/sharing/how-to/invite-any-user)', - nullable: true, - }, - networkFlowLoggingOn: { - type: 'boolean', - description: - 'Whether [network flow logs](/docs/features/logging/network-flow-logs) are enabled for the tailnet', - nullable: true, - }, - regionalRoutingOn: { - type: 'boolean', - description: - 'Whether [regional routing](/docs/features/route-selection#regional-routing) is enabled for the tailnet', - nullable: true, - }, - routeSelection: { - type: 'string', - description: - 'The [route selection](/docs/features/route-selection) algorithm used by the tailnet: * `active-passive-failover` - Active-passive failover (formerly known as "Failover") * `regional-routing` - Regional routing * `regional-routing-failover` - Regional routing with in-region failover * `magicroute` - MagicRoute A PATCH request must not specify both the `regionalRoutingOn` and `routeSelection` fields', - nullable: true, - }, - postureIdentityCollectionOn: { - type: 'boolean', - description: - 'Whether [identity collection](/docs/features/access-control/device-management/how-to/manage-identity) is enabled for [device posture](/docs/features/device-posture) integrations for the tailnet', - nullable: true, - }, - httpsEnabled: { - type: 'boolean', - description: - 'Whether provisioning of [HTTPS certificates](/docs/how-to/set-up-https-certificates) is enabled for this tailnet', - nullable: true, - }, - }, - }, - }, + outputs: TAILNET_SETTINGS_OUTPUT, } diff --git a/apps/sim/tools/tailscale/outputs.ts b/apps/sim/tools/tailscale/outputs.ts index 1919066966f..92a2a9b8b11 100644 --- a/apps/sim/tools/tailscale/outputs.ts +++ b/apps/sim/tools/tailscale/outputs.ts @@ -460,3 +460,150 @@ export const USER_OUTPUT_PROPERTIES = { nullable: true, }, } as const satisfies Record + +export const DNS_CONFIGURATION_OUTPUT = { + dnsConfiguration: { + type: 'json', + description: 'Dns configuration', + properties: { + nameservers: { + type: 'array', + description: 'Global DNS resolvers to use', + items: { + type: 'json', + properties: { + address: { + type: 'string', + description: 'IPv4 or IPv6 address of the DNS resolver', + optional: true, + }, + useWithExitNode: { + type: 'boolean', + description: + 'If true, this resolver should still be used when a device is configured to use a Tailscale exit node', + optional: true, + }, + }, + }, + }, + splitDNS: { + type: 'json', + description: + 'Map of DNS name suffixes (domains) to lists of resolvers for Split DNS and advanced routing overlays', + nullable: true, + }, + searchPaths: { + type: 'array', + description: 'Search domain paths to apply', + items: { + type: 'string', + }, + }, + preferences: { + type: 'json', + description: 'Preferences', + properties: { + overrideLocalDNS: { + type: 'boolean', + description: + 'If true, resolvers in `nameservers` override the local OS DNS configuration; if false, local resolvers are used', + optional: true, + }, + magicDNS: { + type: 'boolean', + description: 'Whether MagicDNS is enabled for this tailnet', + optional: true, + }, + }, + nullable: true, + }, + }, + }, +} as const satisfies Record + +export const TAILNET_SETTINGS_OUTPUT = { + settings: { + type: 'json', + description: 'Settings for a tailnet', + properties: { + aclsExternallyManagedOn: { + type: 'boolean', + description: + 'Prevents users from editing policies in the admin console to avoid conflicts with external management workflows like GitOps or Terraform', + nullable: true, + }, + aclsExternalLink: { + type: 'string', + description: + 'Link to the external tailnet policy definition or management solution for this tailnet', + nullable: true, + }, + adminConsoleSessionTimeoutMinutes: { + type: 'number', + description: + 'The [admin console session timeout](/docs/account/admin-console-session-timeout) for members of this tailnet', + nullable: true, + }, + devicesApprovalOn: { + type: 'boolean', + description: + 'Whether [device approval](/docs/features/access-control/device-management/device-approval) is enabled for the tailnet', + nullable: true, + }, + devicesAutoUpdatesOn: { + type: 'boolean', + description: + 'Whether [auto updates](/docs/features/client/update#auto-updates) are enabled for devices that belong to this tailnet', + nullable: true, + }, + devicesKeyDurationDays: { + type: 'number', + description: + 'The [key expiry](/docs/features/access-control/key-expiry) duration for devices on this tailnet', + nullable: true, + }, + usersApprovalOn: { + type: 'boolean', + description: + 'Whether [user approval](/docs/features/access-control/user-approval) is enabled for this tailnet', + nullable: true, + }, + usersRoleAllowedToJoinExternalTailnets: { + type: 'string', + description: + 'Which user roles are allowed to [join external tailnets](/docs/features/sharing/how-to/invite-any-user)', + nullable: true, + }, + networkFlowLoggingOn: { + type: 'boolean', + description: + 'Whether [network flow logs](/docs/features/logging/network-flow-logs) are enabled for the tailnet', + nullable: true, + }, + regionalRoutingOn: { + type: 'boolean', + description: + 'Whether [regional routing](/docs/features/route-selection#regional-routing) is enabled for the tailnet', + nullable: true, + }, + routeSelection: { + type: 'string', + description: + 'The [route selection](/docs/features/route-selection) algorithm used by the tailnet: * `active-passive-failover` - Active-passive failover (formerly known as "Failover") * `regional-routing` - Regional routing * `regional-routing-failover` - Regional routing with in-region failover * `magicroute` - MagicRoute A PATCH request must not specify both the `regionalRoutingOn` and `routeSelection` fields', + nullable: true, + }, + postureIdentityCollectionOn: { + type: 'boolean', + description: + 'Whether [identity collection](/docs/features/access-control/device-management/how-to/manage-identity) is enabled for [device posture](/docs/features/device-posture) integrations for the tailnet', + nullable: true, + }, + httpsEnabled: { + type: 'boolean', + description: + 'Whether provisioning of [HTTPS certificates](/docs/how-to/set-up-https-certificates) is enabled for this tailnet', + nullable: true, + }, + }, + }, +} as const satisfies Record diff --git a/apps/sim/tools/tailscale/set_dns_configuration.ts b/apps/sim/tools/tailscale/set_dns_configuration.ts index e1fc26a7e5d..4488ec4d46f 100644 --- a/apps/sim/tools/tailscale/set_dns_configuration.ts +++ b/apps/sim/tools/tailscale/set_dns_configuration.ts @@ -1,10 +1,11 @@ import { isRecordLike } from '@sim/utils/object' +import { DNS_CONFIGURATION_OUTPUT } from '@/tools/tailscale/outputs' import type { TailscaleDnsConfiguration, TailscaleSetDnsConfigurationParams, TailscaleSetDnsConfigurationResponse, } from '@/tools/tailscale/types' -import { assertTailscaleResponse } from '@/tools/tailscale/utils' +import { assertTailscaleResponse, mapTailscaleDnsConfiguration } from '@/tools/tailscale/utils' import type { ToolConfig } from '@/tools/types' import { safeUrlPathSegment } from '@/tools/url-path' @@ -58,72 +59,9 @@ export const tailscaleSetDnsConfigurationTool: ToolConfig< return { success: true, output: { - dnsConfiguration: { - nameservers: data.nameservers ?? [], - splitDNS: data.splitDNS ?? null, - searchPaths: data.searchPaths ?? [], - preferences: data.preferences ?? null, - }, + dnsConfiguration: mapTailscaleDnsConfiguration(data), }, } }, - outputs: { - dnsConfiguration: { - type: 'json', - description: 'Dns configuration', - properties: { - nameservers: { - type: 'array', - description: 'Global DNS resolvers to use', - items: { - type: 'json', - properties: { - address: { - type: 'string', - description: 'IPv4 or IPv6 address of the DNS resolver', - optional: true, - }, - useWithExitNode: { - type: 'boolean', - description: - 'If true, this resolver should still be used when a device is configured to use a Tailscale exit node', - optional: true, - }, - }, - }, - }, - splitDNS: { - type: 'json', - description: - 'Map of DNS name suffixes (domains) to lists of resolvers for Split DNS and advanced routing overlays', - nullable: true, - }, - searchPaths: { - type: 'array', - description: 'Search domain paths to apply', - items: { - type: 'string', - }, - }, - preferences: { - type: 'json', - description: 'Preferences', - properties: { - overrideLocalDNS: { - type: 'boolean', - description: - 'If true, resolvers in `nameservers` override the local OS DNS configuration; if false, local resolvers are used', - optional: true, - }, - magicDNS: { - type: 'boolean', - description: 'Whether MagicDNS is enabled for this tailnet', - optional: true, - }, - }, - nullable: true, - }, - }, - }, - }, + outputs: DNS_CONFIGURATION_OUTPUT, } diff --git a/apps/sim/tools/tailscale/types.ts b/apps/sim/tools/tailscale/types.ts index b7c9e276f17..7731af46059 100644 --- a/apps/sim/tools/tailscale/types.ts +++ b/apps/sim/tools/tailscale/types.ts @@ -406,25 +406,7 @@ export interface TailscaleGetTailnetSettingsResponse extends ToolResponse { export interface TailscaleUpdateTailnetSettingsParams extends TailscaleBaseParams { settings: string } -export interface TailscaleUpdateTailnetSettingsResponse extends ToolResponse { - output: { - settings: { - aclsExternallyManagedOn: boolean | null - aclsExternalLink: string | null - adminConsoleSessionTimeoutMinutes: number | null - devicesApprovalOn: boolean | null - devicesAutoUpdatesOn: boolean | null - devicesKeyDurationDays: number | null - usersApprovalOn: boolean | null - usersRoleAllowedToJoinExternalTailnets: string | null - networkFlowLoggingOn: boolean | null - regionalRoutingOn: boolean | null - routeSelection: string | null - postureIdentityCollectionOn: boolean | null - httpsEnabled: boolean | null - } - } -} +export type TailscaleUpdateTailnetSettingsResponse = TailscaleGetTailnetSettingsResponse export interface TailscaleDnsConfiguration { nameservers?: { address?: string; useWithExitNode?: boolean }[] splitDNS?: Record @@ -444,13 +426,4 @@ export interface TailscaleGetDnsConfigurationResponse extends ToolResponse { export interface TailscaleSetDnsConfigurationParams extends TailscaleBaseParams { dnsConfiguration: string } -export interface TailscaleSetDnsConfigurationResponse extends ToolResponse { - output: { - dnsConfiguration: { - nameservers: { address?: string; useWithExitNode?: boolean }[] - splitDNS: Record | null - searchPaths: string[] - preferences: { overrideLocalDNS?: boolean; magicDNS?: boolean } | null - } - } -} +export type TailscaleSetDnsConfigurationResponse = TailscaleGetDnsConfigurationResponse diff --git a/apps/sim/tools/tailscale/update_tailnet_settings.ts b/apps/sim/tools/tailscale/update_tailnet_settings.ts index a8d970f2cc5..a17881c54c7 100644 --- a/apps/sim/tools/tailscale/update_tailnet_settings.ts +++ b/apps/sim/tools/tailscale/update_tailnet_settings.ts @@ -1,10 +1,11 @@ import { isRecordLike } from '@sim/utils/object' +import { TAILNET_SETTINGS_OUTPUT } from '@/tools/tailscale/outputs' import type { TailscaleTailnetSettings, TailscaleUpdateTailnetSettingsParams, TailscaleUpdateTailnetSettingsResponse, } from '@/tools/tailscale/types' -import { assertTailscaleResponse } from '@/tools/tailscale/utils' +import { assertTailscaleResponse, mapTailscaleTailnetSettings } from '@/tools/tailscale/utils' import type { ToolConfig } from '@/tools/types' import { safeUrlPathSegment } from '@/tools/url-path' @@ -59,109 +60,9 @@ export const tailscaleUpdateTailnetSettingsTool: ToolConfig< return { success: true, output: { - settings: { - aclsExternallyManagedOn: data.aclsExternallyManagedOn ?? null, - aclsExternalLink: data.aclsExternalLink ?? null, - adminConsoleSessionTimeoutMinutes: data.adminConsoleSessionTimeoutMinutes ?? null, - devicesApprovalOn: data.devicesApprovalOn ?? null, - devicesAutoUpdatesOn: data.devicesAutoUpdatesOn ?? null, - devicesKeyDurationDays: data.devicesKeyDurationDays ?? null, - usersApprovalOn: data.usersApprovalOn ?? null, - usersRoleAllowedToJoinExternalTailnets: - data.usersRoleAllowedToJoinExternalTailnets ?? null, - networkFlowLoggingOn: data.networkFlowLoggingOn ?? null, - regionalRoutingOn: data.regionalRoutingOn ?? null, - routeSelection: data.routeSelection ?? null, - postureIdentityCollectionOn: data.postureIdentityCollectionOn ?? null, - httpsEnabled: data.httpsEnabled ?? null, - }, + settings: mapTailscaleTailnetSettings(data), }, } }, - outputs: { - settings: { - type: 'json', - description: 'Settings for a tailnet', - properties: { - aclsExternallyManagedOn: { - type: 'boolean', - description: - 'Prevents users from editing policies in the admin console to avoid conflicts with external management workflows like GitOps or Terraform', - nullable: true, - }, - aclsExternalLink: { - type: 'string', - description: - 'Link to the external tailnet policy definition or management solution for this tailnet', - nullable: true, - }, - adminConsoleSessionTimeoutMinutes: { - type: 'number', - description: - 'The [admin console session timeout](/docs/account/admin-console-session-timeout) for members of this tailnet', - nullable: true, - }, - devicesApprovalOn: { - type: 'boolean', - description: - 'Whether [device approval](/docs/features/access-control/device-management/device-approval) is enabled for the tailnet', - nullable: true, - }, - devicesAutoUpdatesOn: { - type: 'boolean', - description: - 'Whether [auto updates](/docs/features/client/update#auto-updates) are enabled for devices that belong to this tailnet', - nullable: true, - }, - devicesKeyDurationDays: { - type: 'number', - description: - 'The [key expiry](/docs/features/access-control/key-expiry) duration for devices on this tailnet', - nullable: true, - }, - usersApprovalOn: { - type: 'boolean', - description: - 'Whether [user approval](/docs/features/access-control/user-approval) is enabled for this tailnet', - nullable: true, - }, - usersRoleAllowedToJoinExternalTailnets: { - type: 'string', - description: - 'Which user roles are allowed to [join external tailnets](/docs/features/sharing/how-to/invite-any-user)', - nullable: true, - }, - networkFlowLoggingOn: { - type: 'boolean', - description: - 'Whether [network flow logs](/docs/features/logging/network-flow-logs) are enabled for the tailnet', - nullable: true, - }, - regionalRoutingOn: { - type: 'boolean', - description: - 'Whether [regional routing](/docs/features/route-selection#regional-routing) is enabled for the tailnet', - nullable: true, - }, - routeSelection: { - type: 'string', - description: - 'The [route selection](/docs/features/route-selection) algorithm used by the tailnet: * `active-passive-failover` - Active-passive failover (formerly known as "Failover") * `regional-routing` - Regional routing * `regional-routing-failover` - Regional routing with in-region failover * `magicroute` - MagicRoute A PATCH request must not specify both the `regionalRoutingOn` and `routeSelection` fields', - nullable: true, - }, - postureIdentityCollectionOn: { - type: 'boolean', - description: - 'Whether [identity collection](/docs/features/access-control/device-management/how-to/manage-identity) is enabled for [device posture](/docs/features/device-posture) integrations for the tailnet', - nullable: true, - }, - httpsEnabled: { - type: 'boolean', - description: - 'Whether provisioning of [HTTPS certificates](/docs/how-to/set-up-https-certificates) is enabled for this tailnet', - nullable: true, - }, - }, - }, - }, + outputs: TAILNET_SETTINGS_OUTPUT, } diff --git a/apps/sim/tools/tailscale/utils.ts b/apps/sim/tools/tailscale/utils.ts index b7562f65c54..8b737b5c378 100644 --- a/apps/sim/tools/tailscale/utils.ts +++ b/apps/sim/tools/tailscale/utils.ts @@ -3,8 +3,12 @@ import { toRecord } from '@sim/utils/object' import type { TailscaleDevice, TailscaleDeviceOutput, + TailscaleDnsConfiguration, + TailscaleGetDnsConfigurationResponse, + TailscaleGetTailnetSettingsResponse, TailscaleKey, TailscaleKeyOutput, + TailscaleTailnetSettings, TailscaleUser, TailscaleUserOutput, } from '@/tools/tailscale/types' @@ -116,3 +120,34 @@ export function mapTailscaleKey(data: TailscaleKey): TailscaleKeyOutput { customClaimRules: data.customClaimRules ?? null, } } + +export function mapTailscaleDnsConfiguration( + data: TailscaleDnsConfiguration +): TailscaleGetDnsConfigurationResponse['output']['dnsConfiguration'] { + return { + nameservers: data.nameservers ?? [], + splitDNS: data.splitDNS ?? null, + searchPaths: data.searchPaths ?? [], + preferences: data.preferences ?? null, + } +} + +export function mapTailscaleTailnetSettings( + data: TailscaleTailnetSettings +): TailscaleGetTailnetSettingsResponse['output']['settings'] { + return { + aclsExternallyManagedOn: data.aclsExternallyManagedOn ?? null, + aclsExternalLink: data.aclsExternalLink ?? null, + adminConsoleSessionTimeoutMinutes: data.adminConsoleSessionTimeoutMinutes ?? null, + devicesApprovalOn: data.devicesApprovalOn ?? null, + devicesAutoUpdatesOn: data.devicesAutoUpdatesOn ?? null, + devicesKeyDurationDays: data.devicesKeyDurationDays ?? null, + usersApprovalOn: data.usersApprovalOn ?? null, + usersRoleAllowedToJoinExternalTailnets: data.usersRoleAllowedToJoinExternalTailnets ?? null, + networkFlowLoggingOn: data.networkFlowLoggingOn ?? null, + regionalRoutingOn: data.regionalRoutingOn ?? null, + routeSelection: data.routeSelection ?? null, + postureIdentityCollectionOn: data.postureIdentityCollectionOn ?? null, + httpsEnabled: data.httpsEnabled ?? null, + } +}