Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / SimulatorClient

Interface: SimulatorClient

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

Public typed client used to call simulator HTTP and WebSocket APIs.

The client groups endpoints by workflow: system checks, card metadata, match lifecycle calls, Limited Events, and high-level match sessions.

Example:

ts
import { 
createSimulatorClient
} from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes. const
simulatorClient
=
createSimulatorClient
({
baseUrl
: 'http://127.0.0.1:4000',
}) // System health verifies the client can reach the simulator. const
health
= await
simulatorClient
.
system
.
health
()
console
.
log
(
health
.
status
)

Example

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

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

const health = await simulatorClient.system.health()
const requestedCardMetadata = await simulatorClient.cards.get([46102])
console.log(health.status, requestedCardMetadata[0]?.title)

See

https://simulator-sdk.my-swu.com/guide/client-api

Properties

cards

Example:

ts
import { 
createSimulatorClient
} from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes. const
simulatorClient
=
createSimulatorClient
({
baseUrl
: 'http://127.0.0.1:4000',
}) // Card resources read canonical card metadata. const
cardMetadata
= await
simulatorClient
.
cards
.
get
([
46102, // Leia Organa - Someone Who Loves You 308, // Echo Base ])

readonly cards: CardsResource

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

Card metadata APIs.


limitedEvents

Example:

ts
import { 
createSimulatorClient
} from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes. const
simulatorClient
=
createSimulatorClient
({
baseUrl
: 'http://127.0.0.1:4000',
}) // Limited Events generate draft or sealed pools before match creation. const
draftEventAccess
= await
simulatorClient
.
limitedEvents
.
create
({
kind
: 'draft',
setCode
: 'SOR',
playerCount
: 4,
})

readonly limitedEvents: LimitedEventsResource

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

Limited Event APIs.


matches

Example:

ts
import { 
createSimulatorClient
} from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes. const
simulatorClient
=
createSimulatorClient
({
baseUrl
: 'http://127.0.0.1:4000',
}) // Use card ids; the server validates deck legality. const
premierHostDeck
= {
leader
: 46102, // Leia Organa - Someone Who Loves You
base
: 308, // Echo Base
cards
:
Array
.
from
({
length
: 50 }, () => 45), // Alliance X-Wing
} // Match creation returns the host seat access object. const
hostAccess
= await
simulatorClient
.
matches
.
create
({
hostDeck
:
premierHostDeck
})

readonly matches: MatchesResource

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

Match lifecycle APIs.


session

Example:

ts
import { 
createSimulatorClient
} from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes. const
simulatorClient
=
createSimulatorClient
({
baseUrl
: 'http://127.0.0.1:4000',
}) // Sessions own live socket state for one private seat. const
matchSession
=
simulatorClient
.
session
.
create
({
matchId
: 'match_123',
seatToken
: 'seat_token_123',
})

readonly session: SessionResource

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

High-level live match session APIs.


system

Example:

ts
import { 
createSimulatorClient
} from '@my-swu/simulator-client'
// Point this at the simulator HTTP origin for /health and /api routes. const
simulatorClient
=
createSimulatorClient
({
baseUrl
: 'http://127.0.0.1:4000',
}) // System health verifies the server is reachable. const
health
= await
simulatorClient
.
system
.
health
()

readonly system: SystemResource

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

System APIs.

Released under the MIT License.