Skip to content

Latest commit

 

History

History
617 lines (359 loc) · 16.6 KB

File metadata and controls

617 lines (359 loc) · 16.6 KB

Back to README.md

@openmrs/esm-offline

Table of contents

Interfaces

Type aliases

Variables

Functions

Type aliases

KnownOmrsServiceWorkerEvents

Ƭ KnownOmrsServiceWorkerEvents: NetworkRequestFailedEvent

Defined in

service-worker-events.ts:15


KnownOmrsServiceWorkerMessages

Ƭ KnownOmrsServiceWorkerMessages: OnImportMapChangedMessage | ClearDynamicRoutesMessage | RegisterDynamicRouteMessage

Defined in

service-worker-messaging.ts:43


OmrsOfflineHttpHeaderNames

Ƭ OmrsOfflineHttpHeaderNames: keyof OmrsOfflineHttpHeaders

Defined in

service-worker-http-headers.ts:36


OmrsOfflineHttpHeaders

Ƭ OmrsOfflineHttpHeaders: Object

Defines the keys of the custom headers which can be appended to an HTTP request. HTTP requests with these headers are handled in a special way by the SPA's service worker.

Type declaration

Name Type Description
x-omrs-offline-caching-strategy? "default" | "network-first" Instructs the service worker to use a specific caching strategy for this request. The supported values are: * default: Equal to the absence of this header/an invalid value. The service worker decides the strategy to be used. * network-first: The service worker will make the request and cache its response.
x-omrs-offline-response-body? string If the client is offline and the request cannot be read from the cache (i.e. if there is no way to receive any kind of data for this request), the service worker will return a response with the body in this header.
x-omrs-offline-response-status? `${number}` If the client is offline and the request cannot be read from the cache (i.e. if there is no way to receive any kind of data for this request), the service worker will return a response with the status code defined in this header.

Defined in

service-worker-http-headers.ts:12


ProcessSyncItem

Ƭ ProcessSyncItem<T>: (item: T, options: SyncProcessOptions<T>) => Promise<any>

Type parameters

Name
T

Type declaration

▸ (item, options): Promise<any>

Parameters
Name Type
item T
options SyncProcessOptions<T>
Returns

Promise<any>

Defined in

sync.ts:28

Variables

offlineUuidPrefix

Const offlineUuidPrefix: "OFFLINE+"

Defined in

uuid.ts:3


omrsOfflineCachingStrategyHttpHeaderName

Const omrsOfflineCachingStrategyHttpHeaderName: "x-omrs-offline-caching-strategy"

Defined in

service-worker-http-headers.ts:5


omrsOfflineResponseBodyHttpHeaderName

Const omrsOfflineResponseBodyHttpHeaderName: "x-omrs-offline-response-body"

Defined in

service-worker-http-headers.ts:1


omrsOfflineResponseStatusHttpHeaderName

Const omrsOfflineResponseStatusHttpHeaderName: "x-omrs-offline-response-status"

Defined in

service-worker-http-headers.ts:3

Functions

deleteSynchronizationItem

deleteSynchronizationItem(id): Promise<void>

Parameters

Name Type
id number

Returns

Promise<void>

Defined in

sync.ts:251


dispatchNetworkRequestFailed

dispatchNetworkRequestFailed(data): void

Parameters

Name Type
data NetworkRequestFailedEvent

Returns

void

Defined in

events.ts:5


generateOfflineUuid

generateOfflineUuid(): string

Generates a UUID-like string which is used for uniquely identifying objects while offline.

Returns

string

Defined in

uuid.ts:6


getOfflinePatientDataStore

getOfflinePatientDataStore(): Store<OfflinePatientDataSyncStore>

Returns

Store<OfflinePatientDataSyncStore>

Defined in

offline-patient-data.ts:85


getOfflineSynchronizationStore

getOfflineSynchronizationStore(): Store<OfflineSynchronizationStore>

Returns

Store<OfflineSynchronizationStore>

Defined in

sync.ts:80


getOmrsServiceWorker

getOmrsServiceWorker(): Promise<Workbox | undefined>

If a service worker has been registered, returns a promise that resolves to a {@link Workbox} instance which is used by the application to manage that service worker.

If no service worker has been registered (e.g. when the application is built without offline specific features), returns a promise which immediately resolves to undefined.

Returns

Promise<Workbox | undefined>

A promise which either resolves to undefined or to the app's {@link Workbox} instance.

Defined in

service-worker.ts:42


getSynchronizationItems

getSynchronizationItems<T>(type): Promise<T[]>

Type parameters

Name
T

Parameters

Name Type
type string

Returns

Promise<T[]>

Defined in

sync.ts:246


getSynchronizationItemsFor

getSynchronizationItemsFor<T>(userId, type): Promise<T[]>

Type parameters

Name
T

Parameters

Name Type
userId string
type string

Returns

Promise<T[]>

Defined in

sync.ts:232


isOfflineUuid

isOfflineUuid(uuid): boolean

Checks whether the given string has the format of an offline UUID generated by generateOfflineUuid

Parameters

Name Type
uuid string

Returns

boolean

Defined in

uuid.ts:11


loadPersistedPatientDataSyncState

loadPersistedPatientDataSyncState(): Promise<void>

Returns

Promise<void>

Defined in

offline-patient-data.ts:199


messageOmrsServiceWorker

messageOmrsServiceWorker(message): Promise<MessageServiceWorkerResult<any>>

Sends the specified message to the application's service worker.

Parameters

Name Type Description
message KnownOmrsServiceWorkerMessages The message to be sent.

Returns

Promise<MessageServiceWorkerResult<any>>

A promise which completes when the message has been successfully processed by the Service Worker.

Defined in

service-worker-messaging.ts:9


patchXMLHttpRequest

patchXMLHttpRequest(): void

Returns

void

Defined in

patches.ts:1


queueSynchronizationItem

queueSynchronizationItem<T>(type, content, descriptor?): Promise<number>

Type parameters

Name
T

Parameters

Name Type
type string
content T
descriptor? QueueItemDescriptor

Returns

Promise<number>

Defined in

sync.ts:223


queueSynchronizationItemFor

queueSynchronizationItemFor<T>(userId, type, content, descriptor?): Promise<number>

Type parameters

Name
T

Parameters

Name Type
userId string
type string
content T
descriptor? QueueItemDescriptor

Returns

Promise<number>

Defined in

sync.ts:195


registerOfflinePatientHandler

registerOfflinePatientHandler(identifier, handler): void

Attempts to add the specified patient handler registration to the list of offline patient handlers.

Parameters

Name Type Description
identifier string A key which uniquely identifies the registration.
handler OfflinePatientDataSyncHandler The patient handler registration to be registered.

Returns

void

true if the registration was successfully made; false if another registration with the same identifier has already been registered before.

Defined in

offline-patient-data.ts:96


registerOmrsServiceWorker

registerOmrsServiceWorker(scriptUrl, registerOptions?): Promise<Workbox>

If not yet registered, registers the application's global Service Worker. Throws if registration is not possible.

Parameters

Name Type
scriptUrl string
registerOptions? object

Returns

Promise<Workbox>

A promise which resolves to the registered {@link Workbox} instance which manages the SW.

Defined in

service-worker.ts:12


runSynchronization

runSynchronization(): Promise<void>

Returns

Promise<void>

Defined in

sync.ts:84


setupOfflineSync

setupOfflineSync<T>(type, dependsOn, process): void

Type parameters

Name
T

Parameters

Name Type
type string
dependsOn string[]
process ProcessSyncItem<T>

Returns

void

Defined in

sync.ts:263


subscribeNetworkRequestFailed

subscribeNetworkRequestFailed(cb): () => void

Parameters

Name Type
cb (data: NetworkRequestFailedEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

events.ts:11


syncOfflinePatientData

syncOfflinePatientData(patientUuid): Promise<void>

Notifies all registered offline patient handlers that a new patient must be made available offline.

Parameters

Name Type
patientUuid string

Returns

Promise<void>

A promise which resolves once all registered handlers have finished synchronizing.

Defined in

offline-patient-data.ts:111