Skip to content

client


@tsky/client / client / Client

Client<Q, P>

Defined in: client/src/client.ts:22

Type Parameters

Q = Queries

P = Procedures

Constructors

new Client()

ts
new Client<Q, P>(xrpc, crenditials): Client<Q, P>

Defined in: client/src/client.ts:26

Parameters

xrpc

XRPC

crenditials

CredentialManager

Returns

Client<Q, P>

Properties

crenditials

ts
crenditials: CredentialManager;

Defined in: client/src/client.ts:24


xrpc

ts
xrpc: XRPC;

Defined in: client/src/client.ts:23

Methods

call()

ts
call<K>(nsid, options): Promise<XRPCResponse<OutputOf<P[K]>>>

Defined in: client/src/client.ts:51

Makes a procedure (POST) request

Type Parameters

K extends string | number | symbol

Parameters

nsid

K

Namespace ID of a procedure endpoint

options

RPCOptions<P[K]>

Options to include like input body or parameters

Returns

Promise<XRPCResponse<OutputOf<P[K]>>>

The response of the request


createRecord()

ts
createRecord<K>(
   nsid, 
   record, 
rkey?): Promise<StrongRef>

Defined in: client/src/client.ts:71

Create a record.

Type Parameters

K extends string | number | symbol

Parameters

nsid

K

The collection's NSID.

record

Omit<RPCOptions<P[K]>, "$type" | "createdAt">

The record to create.

rkey?

string

The rkey to use.

Returns

Promise<StrongRef>

The record's AT URI and CID.


deleteRecord()

ts
deleteRecord(uri, options): Promise<void>

Defined in: client/src/client.ts:131

Delete a record.

Parameters

uri

string

The record's AT URI.

options

RPCOptions = {}

Returns

Promise<void>


get()

ts
get<K>(nsid, options): Promise<XRPCResponse<OutputOf<Q[K]>>>

Defined in: client/src/client.ts:37

Makes a query (GET) request

Type Parameters

K extends string | number | symbol

Parameters

nsid

K

Namespace ID of a query endpoint

options

RPCOptions<Q[K]>

Options to include like parameters

Returns

Promise<XRPCResponse<OutputOf<Q[K]>>>

The response of the request


putRecord()

ts
putRecord(
   nsid, 
   record, 
rkey): Promise<StrongRef>

Defined in: client/src/client.ts:103

Put a record in place of an existing record.

Parameters

nsid

string

The collection's NSID.

record

object

The record to put.

rkey

string

The rkey to use.

Returns

Promise<StrongRef>

The record's AT URI and CID.


request()

ts
request(options): Promise<XRPCResponse>

Defined in: client/src/client.ts:60

Makes a request to the XRPC service

Parameters

options

XRPCRequestOptions

Returns

Promise<XRPCResponse>