Package-level declarations

Types

Link copied to clipboard

The server's row changes a test reports to an in-memory client, in place of a Realtime channel:

Link copied to clipboard

The local data of in-memory clients, kept from one client to the next, for a test of what an app does after a restart: the cache, the mutation queue with the rejected and conflicted lists, and the Storage file cache. Hand the same store to each client's inMemory:

Functions

Link copied to clipboard
fun appliedOutcome(result: PostgrestResult): MutationOutcome.Applied

The outcome of a write the server applied, as a test double of the app's own returns it.

Link copied to clipboard
fun appliedUploadOutcome(response: FileUploadResponse): UploadOutcome.Applied

The outcome of an upload Storage stored, as a test double of the app's own returns it.

Link copied to clipboard
fun cachedFile(path: String, fetchedAt: Instant, sizeBytes: Long): CachedFile

A Storage object held in the file cache, as the offline bucket reports one.

Link copied to clipboard
fun cachedResult(data: String, supabase: SupabaseClient, fetchedAt: Instant, hasPendingMutations: Boolean = false): PostgrestResult

The result of a one-shot read the cache answered, as a fake of the app's own repository returns it: PostgrestResult.isFromCache reads true, PostgrestResult.fetchedAt the time given, to the millisecond, and PostgrestResult.hasPendingMutations the flag given. The library stamps a read's result in headers PostgREST never sends, and this one carries the same stamp; a result built with PostgrestResult(data, Headers.Empty, supabase.postgrest) carries none, and reads as a result supabase-kt returned itself.

fun cachedResult(data: String, supabase: SupabaseClient, fetchedAt: Instant, pendingRowKeys: Set<JsonObject>): PostgrestResult

The result of a one-shot read the cache answered that names the rows a queued write changed: cachedResult, with PostgrestResult.pendingRowKeys reading pendingRowKeys and PostgrestResult.hasPendingMutations reading true exactly when it is not empty.

Link copied to clipboard
fun cacheMissException(message: String = "No valid cached data found for this query"): CacheMissException

The failure of a read that may use only the cache and found nothing there.

Link copied to clipboard
fun conflictedMutation(id: Long, table: String, operation: MutationOperation, createdAt: Instant, rowKeys: List<JsonObject> = emptyList(), body: JsonElement? = null, base: JsonObject = JsonObject(emptyMap()), server: JsonObject? = null, serverVersion: String? = null, changedOnServer: Set<String> = emptySet(), conflictingColumns: Set<String> = emptySet(), message: String, conflictedAt: Instant): ConflictedMutation

A write parked on the conflicted list, as Offline.conflictedMutations lists one.

Link copied to clipboard
fun downloadProgress(bytesReceived: Long, totalBytes: Long?): DownloadProgress

The progress of a download into the file cache, as ensureCachedFile with a progress callback reports it.

Link copied to clipboard
fun Offline.Config.inMemory(clock: Clock = Clock.System)

Keeps the plugin's local data in memory, for tests: the cache, the mutation queue and the Storage file cache live in the client, and nothing is written to disk. Every other setting applies as it does in an app, so a test builds its client exactly as production does:

fun Offline.Config.inMemory(clock: Clock = Clock.System, realtime: FakeRealtime)

inMemory, with the server's row changes reported by realtime in place of a Realtime channel, so a test of an app that names tables in realtime { } needs no install(Realtime):

fun Offline.Config.inMemory(clock: Clock = Clock.System, store: InMemoryStore)

inMemory, over store: the client starts with what an earlier client over store left there (the queued writes, which it replays, the rejected and conflicted lists, the cached queries and files) and leaves its own there when it closes. A test closes one client and builds the next to see what the app does after it is killed and relaunched:

fun Offline.Config.inMemory(clock: Clock = Clock.System, realtime: FakeRealtime, store: InMemoryStore)

inMemory over store, as the overload that takes a store alone, with the server's row changes reported by realtime in place of a Realtime channel, as the overload that takes a FakeRealtime alone.

Link copied to clipboard

The reason of a sync call a failure on the device stopped, such as the local database failing.

Link copied to clipboard
fun mutationConflict(mutationId: Long, table: String, operation: MutationOperation, rowKey: JsonObject, base: JsonObject = JsonObject(emptyMap()), local: JsonObject? = null, server: JsonObject? = null, changedOnServer: Set<String> = emptySet(), conflictingColumns: Set<String> = emptySet()): MutationConflict

A conflict a replay found, as a ConflictResolver is shown one, for a test of the app's own resolver.

Link copied to clipboard
fun mutationNotQueueableException(cause: Throwable, message: String = "The write could not be queued, and could not be sent"): MutationNotQueueableException

The failure of a write the mutation queue could not hold, sent at once and refused for want of a connection.

Link copied to clipboard
fun networkDisabledException(message: String = "The library's network access is turned off"): NetworkDisabledException

The failure of a request asked for while the app had turned the library's network access off.

Link copied to clipboard

The failure of a call on a closed client, with the library's own message and no cause, as a test double of the app's own throws it after its client is closed.

Link copied to clipboard
fun pendingMutation(id: Long, table: String, operation: MutationOperation, createdAt: Instant, rowKeys: List<JsonObject> = emptyList(), body: JsonElement? = null): PendingMutation

A write waiting in the mutation queue, as Offline.pendingMutations lists one.

fun pendingMutation(id: Long, table: String, operation: MutationOperation, createdAt: Instant, rowKeys: List<JsonObject> = emptyList(), body: JsonElement? = null, baseVersion: String?): PendingMutation

A write waiting in the mutation queue with the version it replays against, as Offline.pendingMutations lists a write to a table with a version column.

Link copied to clipboard
fun pendingUpload(id: Long, bucketId: String, path: String, createdAt: Instant, sizeBytes: Long, contentType: String? = null, upsert: Boolean = false): PendingUpload

An upload waiting in the mutation queue, as OfflineStorage.pendingUploads lists one.

Link copied to clipboard
fun querySnapshot(result: PostgrestResult?, isFromCache: Boolean, fetchedAt: Instant?, hasPendingMutations: Boolean = false, refresh: RefreshState = RefreshState.Idle): QuerySnapshot

One emission of a reactive read, as selectAsFlow hands one out.

fun querySnapshot(result: PostgrestResult?, isFromCache: Boolean, fetchedAt: Instant?, pendingRowKeys: Set<JsonObject>, refresh: RefreshState = RefreshState.Idle): QuerySnapshot

One emission of a reactive read that names the rows a queued write changed, as selectAsFlow hands one out: QuerySnapshot.pendingRowKeys reads pendingRowKeys, and QuerySnapshot.hasPendingMutations reads true exactly when it is not empty, as the library's own snapshot does when each row changed carries its key. For a write that changed a row without a key to name, build the snapshot with the other querySnapshot and hasPendingMutations = true.

Link copied to clipboard

The outcome of a write that waits in the mutation queue.

Link copied to clipboard

The outcome of an upload that waits in the mutation queue.

Link copied to clipboard
fun rejectedMutation(id: Long, table: String, operation: MutationOperation, createdAt: Instant, rowKeys: List<JsonObject> = emptyList(), body: JsonElement? = null, serverError: ServerError? = null, message: String, rejectedAt: Instant, isRetryable: Boolean = true): RejectedMutation

A queued write the server refused for good, as Offline.rejectedMutations lists one.

Link copied to clipboard
fun rejectedUpload(id: Long, bucketId: String, path: String, createdAt: Instant, sizeBytes: Long, contentType: String? = null, upsert: Boolean = false, serverError: ServerError? = null, message: String, rejectedAt: Instant, isRetryable: Boolean = true): RejectedUpload

A queued upload Storage refused for good, as OfflineStorage.rejectedUploads lists one.

fun rejectedUpload(id: Long, bucketId: String, path: String, createdAt: Instant, sizeBytes: Long, contentType: String? = null, upsert: Boolean = false, serverError: ServerError? = null, message: String, rejectedAt: Instant, isRetryable: Boolean = true, localPath: String?): RejectedUpload

A queued upload Storage refused for good, with its bytes on the device at localPath, as OfflineStorage.rejectedUploads lists one whose file is still whole.

Link copied to clipboard
fun serverError(status: Int, code: String? = null, message: String, details: String? = null, hint: String? = null): ServerError

What the server answered when it refused a write.

Link copied to clipboard

The reason of a sync call the server stopped with a failure that may pass, such as a 503.

Link copied to clipboard

The state of a Realtime channel whose join was refused or that ended, which the client joins again.

Link copied to clipboard

The state of a refresh that keeps failing.

Link copied to clipboard
fun syncFailedException(message: String = "The sync pass stopped with writes still queued", httpStatus: Int? = null, code: String? = null, isConnectivityFailure: Boolean = false): SyncFailedException

Why a sync pass stopped with writes still queued, as SyncStatus.lastSyncError reports it.

Link copied to clipboard
fun syncReport(syncedCount: Int, rejected: List<RejectedMutation> = emptyList(), remainingCount: Int = 0, alreadyOnServerCount: Int = 0, heldBehindOtherTablesCount: Int = 0): SyncReport

What a call of Offline.syncPendingMutations did. Its SyncReport.stopReason is the one the library gives such a report: SyncStopReason.HeldBehindOtherTables when heldBehindOtherTablesCount is more than zero, else SyncStopReason.Completed.

fun syncReport(syncedCount: Int, rejected: List<RejectedMutation> = emptyList(), remainingCount: Int = 0, alreadyOnServerCount: Int = 0, heldBehindOtherTablesCount: Int = 0, conflictsResolvedCount: Int = 0, conflictsKeptServerCount: Int = 0, conflicted: List<ConflictedMutation> = emptyList()): SyncReport

What a call of Offline.syncPendingMutations did, with the conflicts its replay met; a test sets the conflict fields it reads, and the others keep the values of a pass that met none. Its SyncReport.stopReason is the one the library gives such a report: SyncStopReason.HeldBehindOtherTables when heldBehindOtherTablesCount is more than zero, else SyncStopReason.Completed.

fun syncReport(syncedCount: Int = 0, rejected: List<RejectedMutation> = emptyList(), remainingCount: Int = 0, alreadyOnServerCount: Int = 0, heldBehindOtherTablesCount: Int = 0, conflictsResolvedCount: Int = 0, conflictsKeptServerCount: Int = 0, conflicted: List<ConflictedMutation> = emptyList(), stopReason: SyncStopReason): SyncReport

What a call of Offline.syncPendingMutations did, and why it returned when it did; every field but stopReason, which selects this overload, defaults to the value of a call that sent nothing. Build a failure's reason with serverFailureStop or localFailureStop; the others are objects, such as SyncStopReason.NetworkUnavailable.

fun syncReport(syncedCount: Int = 0, rejected: List<RejectedMutation> = emptyList(), remainingCount: Int = 0, alreadyOnServerCount: Int = 0, heldBehindOtherTablesCount: Int = 0, conflictsResolvedCount: Int = 0, conflictsKeptServerCount: Int = 0, conflicted: List<ConflictedMutation> = emptyList(), stopReason: SyncStopReason = SyncStopReason.Completed, rejectedUploads: List<RejectedUpload>): SyncReport

What a call of Offline.syncPendingMutations did, with the queued uploads Storage refused; every field but rejectedUploads, which selects this overload, defaults to the value of a call that sent nothing and ran to the end.

Link copied to clipboard
fun syncStatus(network: NetworkStatus = NetworkStatus.UNKNOWN, pendingMutationCount: Int = 0, rejectedMutationCount: Int = 0, isSyncing: Boolean = false, lastSyncedAt: Instant? = null, lastSyncError: SyncFailedException? = null): SyncStatus

Where the library stands with the queue and the network, as Offline.syncStatus holds it; every field defaults to the state of a client that has done nothing yet and has counted its queue: nothing waiting, SyncStatus.isQueueCounted true. For the value a client starts with, before its first count, give isQueueCounted = false, which selects the third overload.

fun syncStatus(network: NetworkStatus = NetworkStatus.UNKNOWN, pendingMutationCount: Int = 0, rejectedMutationCount: Int = 0, isSyncing: Boolean = false, lastSyncedAt: Instant? = null, lastSyncError: SyncFailedException? = null, conflictedMutationCount: Int): SyncStatus

Where the library stands with the queue and the network, the conflicted list included; every field but conflictedMutationCount, which selects this overload, defaults to the state of a client that has done nothing yet and has counted its queue.

fun syncStatus(network: NetworkStatus = NetworkStatus.UNKNOWN, pendingMutationCount: Int = 0, rejectedMutationCount: Int = 0, isSyncing: Boolean = false, lastSyncedAt: Instant? = null, lastSyncError: SyncFailedException? = null, conflictedMutationCount: Int = 0, isQueueCounted: Boolean): SyncStatus

Where the library stands with the queue and the network, saying whether the queue has been counted; every field but isQueueCounted, which selects this overload, defaults to the state of a client that has done nothing yet. syncStatus(isQueueCounted = false) is the value a client starts with, before its first count.