Options
All
  • Public
  • Public/Protected
  • All
Menu

Ditto JS SDK v1.1.8

Index

Type aliases

A representation of the events that can occur in relation to an attachment fetch.

There are three different attachment fetch events: Completed, Progress, or Deleted.

There will be at most one Completed or Deleted event per attachment fetch. There can be many Progress events delivered for each attachment fetch.

Updates relating to an attachment fetch are delivered by registering an AttachmentFetcher through a call to fetchAttachment() on a Collection instance.

AttachmentFetchEventCompleted: { attachment: Attachment; type: "Completed" }

An attachment fetch event used when the attachment's download has completed.

Type declaration

AttachmentFetchEventDeleted: { type: "Deleted" }

An attachment fetch event used when the attachment is deleted.

Type declaration

  • type: "Deleted"
AttachmentFetchEventProgress: { downloadedBytes: number | BigInt; totalBytes: number | BigInt; type: "Progress" }

An attachment fetch event used when the attachment's download progressed but is not yet complete.

Type declaration

  • downloadedBytes: number | BigInt
  • totalBytes: number | BigInt
  • type: "Progress"
AttachmentFetchEventType: "Completed" | "Progress" | "Deleted"

The types of attachment fetch events that can be delivered to an attachment fetcher's callback.

AuthenticationStatus: { isAuthenticated: boolean; userID: string | null }

Provides info about the authentication status.

Type declaration

  • isAuthenticated: boolean

    Returns true if authenticated, otherwise returns false.

  • userID: string | null

    If authenticated, returns the userID if one was provided by the authentication service. Otherwise returns null.

ConditionSource: "BLE" | "TCP" | "AWDL" | "MDNS"

The source for a transport condition.

CustomLogCallback: (logLevel: LogLevel, message: string) => void

Type declaration

DocumentIDValue: any

Represents a unique identifier for a Document.

DocumentLike: Document | DocumentValue | any

This is used whenever you can access the document content properties directly via the document.

DocumentValue: Record<string, any>

A document value is a JavaScript object containing values for keys that can be serialized via CBOR.

The various identity configurations that you can use when initializing a Ditto instance.

InitOptions: { webAssemblyModule?: WebAssemblyModule }

Available options for init().

Type declaration

  • Optional webAssemblyModule?: WebAssemblyModule

    You can explicitly pass the WebAssembly module or its location via the webAssemblyModule option. By default, Ditto tries to load the WebAssembly module from the same path where this JavaScript is served.

InsertOptions: { id?: any; isDefault?: boolean; writeStrategy?: WriteStrategy }

Type declaration

  • Optional id?: any
  • Optional isDefault?: boolean
  • Optional writeStrategy?: WriteStrategy

Represents events delivered by a LiveQuery, which can be initial (fired immediately upon registration) or an update (all subsequent events).

LogLevel: "Error" | "Warning" | "Info" | "Debug" | "Verbose"

The log levels supported by Ditto.

MutableDocumentLike: MutableDocument | DocumentValue | any

This is used whenever you can access and update the document content properties directly via the document.

PresenceConnectionType: "WiFi" | "WebSocket" | "AWDL" | "BLE"

Types of connections that can be established between two peers.

QueryArguments: {}

Represents a dictionary of values to be incorporated into a query keyed by the placeholder used within that query. See method find() of Collection for more info.

Type declaration

  • [key: string]: any
QueryObservationHandler: (documents: DocumentLike[], event: LiveQueryEvent, signalNext?: () => void) => void | Promise<void>

Type declaration

    • The closure that is called whenever the documents covered by a live query change.

      Parameters

      Returns void | Promise<void>

RemotePeer: { approximateDistanceInMeters?: number; connections: PresenceConnectionType[]; deviceName: string; networkID: string; rssi?: number }

A peer object with information about an observed peer.

Type declaration

  • Optional approximateDistanceInMeters?: number
  • connections: PresenceConnectionType[]
  • deviceName: string
  • networkID: string
  • Optional rssi?: number
SingleObservationHandler: (document: DocumentLike | null, event: SingleDocumentLiveQueryEvent, signalNext?: () => void) => void | Promise<void>

Type declaration

SortDirection: "ascending" | "descending"

Describes the direction when sorting a query.

SubscriptionContextInfo: { collectionName: string; ditto: Ditto; query: string; queryArgsCBOR: Uint8Array | null }

Type declaration

  • collectionName: string
  • ditto: Ditto
  • query: string
  • queryArgsCBOR: Uint8Array | null
TransportCondition: "Unknown" | "OK" | "GenericFailure" | "AppInBackground" | "MDNSFailure" | "TCPListenFailure" | "NoBLECentralPermission" | "NoBLEPeripheralPermission" | "CannotEstablishConnection" | "BLEDisabled" | "NoBLEHardware" | "WiFiDisabled" | "TemporarilyUnavailable"

Types of connections that can be established between two peers.

UpdateResultType: "set" | "replacedWithCounter" | "incremented" | "inserted" | "removed" | "pushed" | "popped"

The types of an UpdateResult.

UpsertOptions: { writeStrategy?: WriteStrategy }

Type declaration

WebAssemblyModule: RequestInfo | URL | Response | BufferSource | WebAssembly.Module | string | null

Various options to pass the web assembly module to Ditto.

WriteStrategy: "merge" | "overwrite" | "insertIfAbsent" | "insertDefaultIfAbsent"

Defines the various strategies available when inserting a document into a collection.

  • merge: the existing document will be merged with the document being inserted, if there is a pre-existing document.

  • overwrite: an existing document will be overwritten. This can be thought of as first removing the existing document completely and then inserting the new document in its place, if there is a pre-existing document.

  • insertIfAbsent: insert the document only if there is not already a document with the same ID in the store. If there is already a document in the store with the same ID then this will be a no-op.

  • insertDefaultIfAbsent: insert the document, with its contents treated as default data, only if there is not already a document with the same ID in the store. If there is already a document in the store with the same ID then this will be a no-op. Use this strategy if you want to insert default data for a given document ID, which you want to treat as common initial data amongst all peers and that you expect to be mutated or overwritten in due course.

Variables

IdentityTypesRequiringOfflineLicenseToken: string[]

The list of identity types that require activation through an offlineLicenseToken

attachmentBridge: Bridge<Attachment, "AttachmentHandle_t">

Functions

  • Initializes the whole Ditto module. Needs to be called and complete before any of the Ditto API is used.

    Parameters

    Returns Promise<void>