@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:
import type { SimulatorClientOptions } from '@my-swu/simulator-client'
const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }
console.log(simulatorClientOptions)Example
import { createSimulatorClient } from '@my-swu/simulator-client'
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
})
console.log(await simulatorClient.system.health())See
- https://simulator-sdk.my-swu.com/guide/getting-started
- https://simulator-sdk.my-swu.com/guide/runtime-adapters
Properties
baseUrl
Example:
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:
import type { SimulatorClientOptions } from '@my-swu/simulator-client'
const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }
const { fetch } = simulatorClientOptions
console.log(fetch)
optionalfetch?: {(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>
Parameters
input
URL | RequestInfo
init?
RequestInit
Returns
Promise<Response>
Call Signature
(
input,init?):Promise<Response>
Parameters
input
string | URL | Request
init?
RequestInit
Returns
Promise<Response>
timeoutMs?
Example:
import type { SimulatorClientOptions } from '@my-swu/simulator-client'
const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }
const { timeoutMs } = simulatorClientOptions
console.log(timeoutMs)
optionaltimeoutMs?: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:
import type { SimulatorClientOptions } from '@my-swu/simulator-client'
const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }
const { validate } = simulatorClientOptions
console.log(validate)
optionalvalidate?: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
import { createSchemaValidator, createSimulatorClient } from '@my-swu/simulator-client'
const simulatorClient = createSimulatorClient({
baseUrl: 'http://127.0.0.1:4000',
validate: createSchemaValidator(),
})webSocketFactory?
Example:
import type { SimulatorClientOptions } from '@my-swu/simulator-client'
const simulatorClientOptions: SimulatorClientOptions = { baseUrl: 'http://127.0.0.1:4000' }
const { webSocketFactory } = simulatorClientOptions
console.log(webSocketFactory)
optionalwebSocketFactory?:WebSocketFactory
Defined in: packages/ts-sdk/src/client.ts:91
Optional WebSocket factory. Defaults to the global WebSocket when available.
