Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / SimulatorClientOptions

Interface: SimulatorClientOptions ​

Defined in: packages/ts-sdk/src/client.ts:46

Constructor options for the simulator client.

baseUrl points at the HTTP origin for the simulator server. The SDK derives /api/*, /health, and the matching /ws socket origin from this value.

Example:

ts
import type { SimulatorClientOptions } from '@my-swu/simulator-client'

const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }

console.log(simulatorClientOptions)

Example ​

ts
import { createSimulatorClient } from '@my-swu/simulator-client'

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
})

console.log(await simulatorClient.system.health())

See ​

Properties ​

baseUrl ​

Example:

ts
import type { SimulatorClientOptions } from '@my-swu/simulator-client'

const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }

const { baseUrl: simulatorBaseUrl } = simulatorClientOptions

console.log(simulatorBaseUrl)

baseUrl: string

Defined in: packages/ts-sdk/src/client.ts:51

Base URL of the simulator HTTP API, for example http://127.0.0.1:4000. The trailing slash is optional.


fetch? ​

Example:

ts
import type { SimulatorClientOptions } from '@my-swu/simulator-client'

const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }

const { fetch } = simulatorClientOptions

console.log(fetch)

optional fetch?: {(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

Defined in: packages/ts-sdk/src/client.ts:55

Optional fetch implementation. Defaults to the global fetch when available.

Call Signature ​

(input, init?): Promise<Response>

MDN Reference

Parameters ​
input ​

URL | RequestInfo

init? ​

RequestInit

Returns ​

Promise<Response>

Call Signature ​

(input, init?): Promise<Response>

MDN Reference

Parameters ​
input ​

string | URL | Request

init? ​

RequestInit

Returns ​

Promise<Response>


timeoutMs? ​

Example:

ts
import type { SimulatorClientOptions } from '@my-swu/simulator-client'

const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }

const { timeoutMs } = simulatorClientOptions

console.log(timeoutMs)

optional timeoutMs?: number

Defined in: packages/ts-sdk/src/client.ts:63

Optional default timeout, in milliseconds, for every HTTP resource call.

A per-call timeoutMs overrides this value, and passing 0 for one call opts that call out. Leave it unset to keep requests unbounded, which is how the client behaved before timeouts existed.


validate? ​

Example:

ts
import type { SimulatorClientOptions } from '@my-swu/simulator-client'

const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }

const { validate } = simulatorClientOptions

console.log(validate)

optional validate?: SchemaValidator

Defined in: packages/ts-sdk/src/client.ts:87

Optional runtime validator for every payload crossing the network boundary.

Off by default: HTTP responses, HTTP request bodies and socket frames are trusted as-is. Pass createSchemaValidator() to check all of them against the generated schemas, which is what the SDK did unconditionally before this option existed.

The default exists for bundle size: naming createSchemaValidator is what makes the generated schema map and Ajv reachable from this module, and they are about 90% of the SDK's minified weight. A custom implementation of SchemaValidator is accepted too.

Example ​

ts
import { createSchemaValidator, createSimulatorClient } from '@my-swu/simulator-client'

const simulatorClient = createSimulatorClient({
  baseUrl: 'http://127.0.0.1:4000',
  validate: createSchemaValidator(),
})

webSocketFactory? ​

Example:

ts
import type { SimulatorClientOptions } from '@my-swu/simulator-client'

const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }

const { webSocketFactory } = simulatorClientOptions

console.log(webSocketFactory)

optional webSocketFactory?: WebSocketFactory

Defined in: packages/ts-sdk/src/client.ts:91

Optional WebSocket factory. Defaults to the global WebSocket when available.

Released under the MIT License.