- ClearDynamicRoutesMessage
- MessageServiceWorkerResult
- NetworkRequestFailedEvent
- OfflinePatientArgs
- OfflinePatientDataSyncHandler
- OfflinePatientDataSyncState
- OfflinePatientDataSyncStore
- OfflineSynchronizationStore
- OmrsServiceWorkerEvent
- OmrsServiceWorkerMessage
- OnImportMapChangedMessage
- QueueItemDescriptor
- RegisterDynamicRouteMessage
- SyncItem
- SyncProcessOptions
- KnownOmrsServiceWorkerEvents
- KnownOmrsServiceWorkerMessages
- OmrsOfflineHttpHeaderNames
- OmrsOfflineHttpHeaders
- ProcessSyncItem
- offlineUuidPrefix
- omrsOfflineCachingStrategyHttpHeaderName
- omrsOfflineResponseBodyHttpHeaderName
- omrsOfflineResponseStatusHttpHeaderName
- deleteSynchronizationItem
- dispatchNetworkRequestFailed
- generateOfflineUuid
- getOfflinePatientDataStore
- getOfflineSynchronizationStore
- getOmrsServiceWorker
- getSynchronizationItems
- getSynchronizationItemsFor
- isOfflineUuid
- loadPersistedPatientDataSyncState
- messageOmrsServiceWorker
- patchXMLHttpRequest
- queueSynchronizationItem
- queueSynchronizationItemFor
- registerOfflinePatientHandler
- registerOmrsServiceWorker
- runSynchronization
- setupOfflineSync
- subscribeNetworkRequestFailed
- syncOfflinePatientData
Ƭ KnownOmrsServiceWorkerEvents: NetworkRequestFailedEvent
Ƭ KnownOmrsServiceWorkerMessages: OnImportMapChangedMessage
| ClearDynamicRoutesMessage
| RegisterDynamicRouteMessage
service-worker-messaging.ts:43
Ƭ OmrsOfflineHttpHeaderNames: keyof OmrsOfflineHttpHeaders
service-worker-http-headers.ts:36
Ƭ 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.
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. |
service-worker-http-headers.ts:12
Ƭ ProcessSyncItem<T
>: (item
: T
, options
: SyncProcessOptions
<T
>) => Promise
<any
>
Name |
---|
T |
▸ (item
, options
): Promise
<any
>
Name | Type |
---|---|
item |
T |
options |
SyncProcessOptions <T > |
Promise
<any
>
• Const
offlineUuidPrefix: "OFFLINE+"
• Const
omrsOfflineCachingStrategyHttpHeaderName: "x-omrs-offline-caching-strategy"
service-worker-http-headers.ts:5
• Const
omrsOfflineResponseBodyHttpHeaderName: "x-omrs-offline-response-body"
service-worker-http-headers.ts:1
• Const
omrsOfflineResponseStatusHttpHeaderName: "x-omrs-offline-response-status"
service-worker-http-headers.ts:3
▸ deleteSynchronizationItem(id
): Promise
<void
>
Name | Type |
---|---|
id |
number |
Promise
<void
>
▸ dispatchNetworkRequestFailed(data
): void
Name | Type |
---|---|
data |
NetworkRequestFailedEvent |
void
▸ generateOfflineUuid(): string
Generates a UUID-like string which is used for uniquely identifying objects while offline.
string
▸ getOfflinePatientDataStore(): Store
<OfflinePatientDataSyncStore
>
Store
<OfflinePatientDataSyncStore
>
▸ getOfflineSynchronizationStore(): Store
<OfflineSynchronizationStore
>
Store
<OfflineSynchronizationStore
>
▸ 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
.
Promise
<Workbox
| undefined
>
A promise which either resolves to undefined
or to the app's {@link Workbox} instance.
▸ getSynchronizationItems<T
>(type
): Promise
<T
[]>
Name |
---|
T |
Name | Type |
---|---|
type |
string |
Promise
<T
[]>
▸ getSynchronizationItemsFor<T
>(userId
, type
): Promise
<T
[]>
Name |
---|
T |
Name | Type |
---|---|
userId |
string |
type |
string |
Promise
<T
[]>
▸ isOfflineUuid(uuid
): boolean
Checks whether the given string has the format of an offline UUID generated by generateOfflineUuid
Name | Type |
---|---|
uuid |
string |
boolean
▸ loadPersistedPatientDataSyncState(): Promise
<void
>
Promise
<void
>
▸ messageOmrsServiceWorker(message
): Promise
<MessageServiceWorkerResult
<any
>>
Sends the specified message to the application's service worker.
Name | Type | Description |
---|---|---|
message |
KnownOmrsServiceWorkerMessages |
The message to be sent. |
Promise
<MessageServiceWorkerResult
<any
>>
A promise which completes when the message has been successfully processed by the Service Worker.
▸ patchXMLHttpRequest(): void
void
▸ queueSynchronizationItem<T
>(type
, content
, descriptor?
): Promise
<number
>
Name |
---|
T |
Name | Type |
---|---|
type |
string |
content |
T |
descriptor? |
QueueItemDescriptor |
Promise
<number
>
▸ queueSynchronizationItemFor<T
>(userId
, type
, content
, descriptor?
): Promise
<number
>
Name |
---|
T |
Name | Type |
---|---|
userId |
string |
type |
string |
content |
T |
descriptor? |
QueueItemDescriptor |
Promise
<number
>
▸ registerOfflinePatientHandler(identifier
, handler
): void
Attempts to add the specified patient handler registration to the list of offline patient handlers.
Name | Type | Description |
---|---|---|
identifier |
string |
A key which uniquely identifies the registration. |
handler |
OfflinePatientDataSyncHandler |
The patient handler registration to be registered. |
void
true
if the registration was successfully made; false
if another registration with
the same identifier has already been registered before.
▸ registerOmrsServiceWorker(scriptUrl
, registerOptions?
): Promise
<Workbox
>
If not yet registered, registers the application's global Service Worker. Throws if registration is not possible.
Name | Type |
---|---|
scriptUrl |
string |
registerOptions? |
object |
Promise
<Workbox
>
A promise which resolves to the registered {@link Workbox} instance which manages the SW.
▸ runSynchronization(): Promise
<void
>
Promise
<void
>
▸ setupOfflineSync<T
>(type
, dependsOn
, process
): void
Name |
---|
T |
Name | Type |
---|---|
type |
string |
dependsOn |
string [] |
process |
ProcessSyncItem <T > |
void
▸ subscribeNetworkRequestFailed(cb
): () => void
Name | Type |
---|---|
cb |
(data : NetworkRequestFailedEvent ) => void |
fn
▸ (): void
void
▸ syncOfflinePatientData(patientUuid
): Promise
<void
>
Notifies all registered offline patient handlers that a new patient must be made available offline.
Name | Type |
---|---|
patientUuid |
string |
Promise
<void
>
A promise which resolves once all registered handlers have finished synchronizing.