Skip to main content

abstract AbstractRemote

Extended by

Constructors

new AbstractRemote()

new AbstractRemote(
connector,
logger?,
options?): AbstractRemote

Parameters

ParameterType
connectorRemoteConnector
logger?ILogger
options?Partial<AbstractRemoteOptions>

Returns

AbstractRemote

Accessors

fetch

Get Signature

get fetch(): (input, init?) => Promise<Response>(input, init?) => Promise<Response>(input, init?) => Promise<Response>(input, init?) => Promise<Response>(input, init?) => Promise<Response>(input, init?) => Promise<Response>
Returns

Function

a fetch implementation (function) which can be called to perform fetch requests

MDN Reference

Parameters
ParameterType
inputRequestInfo | URL
init?RequestInit
Returns

Promise<Response>

MDN Reference

Parameters
ParameterType
inputRequestInfo
init?RequestInit
Returns

Promise<Response>

MDN Reference

Parameters
ParameterType
inputRequestInfo
init?RequestInit
Returns

Promise<Response>

MDN Reference

Parameters
ParameterType
inputRequestInfo
init?RequestInit
Returns

Promise<Response>

MDN Reference

Parameters
ParameterType
inputRequestInfo
init?RequestInit
Returns

Promise<Response>

MDN Reference

Parameters
ParameterType
inputstring | Request | URL
init?RequestInit
Returns

Promise<Response>

Methods

fetchCredentials()

fetchCredentials(): Promise<null | PowerSyncCredentials>

Get credentials for PowerSync.

This should always fetch a fresh set of credentials - don't use cached values.

Returns

Promise<null | PowerSyncCredentials>


get()

get(path, headers?): Promise<any>

Parameters

ParameterType
pathstring
headers?Record<string, string>

Returns

Promise<any>


getBSON()

abstract getBSON(): Promise<typeof BSON>

Provides a BSON implementation. The import nature of this varies depending on the platform

Returns

Promise<typeof BSON>


getCredentials()

getCredentials(): Promise<null | PowerSyncCredentials>

Get credentials currently cached, or fetch new credentials if none are available.

These credentials may have expired already.

Returns

Promise<null | PowerSyncCredentials>


getUserAgent()

getUserAgent(): string

Returns

string


invalidateCredentials()

invalidateCredentials(): void

Immediately invalidate credentials.

This may be called when the current credentials have expired.

Returns

void


post()

post(
path,
data,
headers?): Promise<any>

Parameters

ParameterType
pathstring
dataany
headers?Record<string, string>

Returns

Promise<any>


postStream()

postStream(options): Promise<DataStream<StreamingSyncLine, any>>

Connects to the sync/stream http endpoint, parsing lines as JSON.

Parameters

ParameterType
optionsSyncStreamOptions

Returns

Promise<DataStream<StreamingSyncLine, any>>


postStreamRaw()

postStreamRaw<T>(options, mapLine): Promise<DataStream<T, any>>

Connects to the sync/stream http endpoint, mapping and emitting each received string line.

Type Parameters

Type Parameter
T

Parameters

ParameterType
optionsSyncStreamOptions
mapLine(line) => T

Returns

Promise<DataStream<T, any>>


prefetchCredentials()

prefetchCredentials(): Promise<null | PowerSyncCredentials>

Fetch a new set of credentials and cache it.

Until this call succeeds, getCredentials will still return the old credentials.

This may be called before the current credentials have expired.

Returns

Promise<null | PowerSyncCredentials>


socketStream()

socketStream(options): Promise<DataStream<StreamingSyncLine, any>>

Connects to the sync/stream websocket endpoint and delivers sync lines by decoding the BSON events sent by the server.

Parameters

ParameterType
optionsSocketSyncStreamOptions

Returns

Promise<DataStream<StreamingSyncLine, any>>


socketStreamRaw()

socketStreamRaw<T>(
options,
map,
bson?): Promise<DataStream<T, any>>

Returns a data stream of sync line data.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
optionsSocketSyncStreamOptions-
map(buffer) => TMaps received payload frames to the typed event value.
bson?typeof BSONA BSON encoder and decoder. When set, the data stream will be requested with a BSON payload (required for compatibility with older sync services).

Returns

Promise<DataStream<T, any>>