Skip to content

Commit

Permalink
refactor: update to new API schema
Browse files Browse the repository at this point in the history
  • Loading branch information
sorccu committed Jan 24, 2025
1 parent 2636a1d commit 49263e5
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions packages/cli/src/constructs/tcp-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { IPFamily } from './api-check'
import { Session } from './project'
import { Assertion as CoreAssertion, NumericAssertionBuilder, GeneralAssertionBuilder } from './internal/assertion'

type TcpAssertionSource = 'TEXT_BODY' | 'RESPONSE_TIME'
type TcpAssertionSource = 'RESPONSE_DATA' | 'RESPONSE_TIME'

export type TcpAssertion = CoreAssertion<TcpAssertionSource>

export class TcpAssertionBuilder {
static textBody (property?: string) {
return new GeneralAssertionBuilder<TcpAssertionSource>('TEXT_BODY', property)
static responseData (property?: string) {
return new GeneralAssertionBuilder<TcpAssertionSource>('RESPONSE_DATA', property)
}

static responseTime () {
Expand Down Expand Up @@ -40,9 +40,9 @@ export interface TcpRequest {
*/
ipFamily?: IPFamily
/**
* The payload to send to the target host.
* The data to send to the target host.
*/
body?: string
data?: string
}

export interface TcpCheckProps extends CheckProps {
Expand Down Expand Up @@ -94,17 +94,10 @@ export class TcpCheck extends Check {
}

synthesize () {
// Do some tricks to map user-friendly 'hostname' to API-friendly 'url'.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { hostname: _hostname, ...request } = {
...this.request,
url: this.request.hostname,
}

return {
...super.synthesize(),
checkType: 'TCP',
request,
request: this.request,
degradedResponseTime: this.degradedResponseTime,
maxResponseTime: this.maxResponseTime,
}
Expand Down

0 comments on commit 49263e5

Please sign in to comment.