@openmrs/esm-offline 3.1.13-pre.656 → 3.1.13-pre.667

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/API.md CHANGED
@@ -26,6 +26,7 @@
26
26
 
27
27
  - [KnownOmrsServiceWorkerEvents](API.md#knownomrsserviceworkerevents)
28
28
  - [KnownOmrsServiceWorkerMessages](API.md#knownomrsserviceworkermessages)
29
+ - [OmrsOfflineCachingStrategy](API.md#omrsofflinecachingstrategy)
29
30
  - [OmrsOfflineHttpHeaderNames](API.md#omrsofflinehttpheadernames)
30
31
  - [OmrsOfflineHttpHeaders](API.md#omrsofflinehttpheaders)
31
32
  - [ProcessSyncItem](API.md#processsyncitem)
@@ -78,7 +79,22 @@ ___
78
79
 
79
80
  #### Defined in
80
81
 
81
- [service-worker-messaging.ts:43](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L43)
82
+ [service-worker-messaging.ts:45](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L45)
83
+
84
+ ___
85
+
86
+ ### OmrsOfflineCachingStrategy
87
+
88
+ Ƭ **OmrsOfflineCachingStrategy**: ``"network-only-or-cache-only"`` \| ``"network-first"``
89
+
90
+ * `cache-or-network`: The default strategy, equal to the absence of this header.
91
+ The SW attempts to resolve the request via the network, but falls back to the cache if required.
92
+ The service worker decides the strategy to be used.
93
+ * `network-first`: See https://developers.google.com/web/tools/workbox/modules/workbox-strategies#network_first_network_falling_back_to_cache.
94
+
95
+ #### Defined in
96
+
97
+ [service-worker-http-headers.ts:16](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-http-headers.ts#L16)
82
98
 
83
99
  ___
84
100
 
@@ -88,7 +104,7 @@ ___
88
104
 
89
105
  #### Defined in
90
106
 
91
- [service-worker-http-headers.ts:36](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-http-headers.ts#L36)
107
+ [service-worker-http-headers.ts:43](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-http-headers.ts#L43)
92
108
 
93
109
  ___
94
110
 
@@ -103,13 +119,13 @@ HTTP requests with these headers are handled in a special way by the SPA's servi
103
119
 
104
120
  | Name | Type | Description |
105
121
  | :------ | :------ | :------ |
106
- | `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. |
122
+ | `x-omrs-offline-caching-strategy?` | [`OmrsOfflineCachingStrategy`](API.md#omrsofflinecachingstrategy) | Instructs the service worker to use a specific caching strategy for this request. |
107
123
  | `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. |
108
124
  | `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. |
109
125
 
110
126
  #### Defined in
111
127
 
112
- [service-worker-http-headers.ts:12](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-http-headers.ts#L12)
128
+ [service-worker-http-headers.ts:24](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-http-headers.ts#L24)
113
129
 
114
130
  ___
115
131
 
@@ -399,7 +415,7 @@ A promise which completes when the message has been successfully processed by th
399
415
 
400
416
  #### Defined in
401
417
 
402
- [service-worker-messaging.ts:9](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L9)
418
+ [service-worker-messaging.ts:10](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L10)
403
419
 
404
420
  ___
405
421
 
@@ -26,4 +26,4 @@
26
26
 
27
27
  #### Defined in
28
28
 
29
- [service-worker-messaging.ts:26](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L26)
29
+ [service-worker-messaging.ts:27](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L27)
@@ -24,7 +24,7 @@
24
24
 
25
25
  #### Defined in
26
26
 
27
- [service-worker-messaging.ts:51](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L51)
27
+ [service-worker-messaging.ts:53](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L53)
28
28
 
29
29
  ___
30
30
 
@@ -34,7 +34,7 @@ ___
34
34
 
35
35
  #### Defined in
36
36
 
37
- [service-worker-messaging.ts:50](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L50)
37
+ [service-worker-messaging.ts:52](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L52)
38
38
 
39
39
  ___
40
40
 
@@ -44,4 +44,4 @@ ___
44
44
 
45
45
  #### Defined in
46
46
 
47
- [service-worker-messaging.ts:49](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L49)
47
+ [service-worker-messaging.ts:51](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L51)
@@ -32,4 +32,4 @@
32
32
 
33
33
  #### Defined in
34
34
 
35
- [service-worker-messaging.ts:26](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L26)
35
+ [service-worker-messaging.ts:27](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L27)
@@ -23,7 +23,7 @@
23
23
 
24
24
  #### Defined in
25
25
 
26
- [service-worker-messaging.ts:31](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L31)
26
+ [service-worker-messaging.ts:32](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L32)
27
27
 
28
28
  ___
29
29
 
@@ -37,4 +37,4 @@ ___
37
37
 
38
38
  #### Defined in
39
39
 
40
- [service-worker-messaging.ts:26](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L26)
40
+ [service-worker-messaging.ts:27](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L27)
@@ -13,6 +13,7 @@
13
13
  ### Properties
14
14
 
15
15
  - [pattern](RegisterDynamicRouteMessage.md#pattern)
16
+ - [strategy](RegisterDynamicRouteMessage.md#strategy)
16
17
  - [type](RegisterDynamicRouteMessage.md#type)
17
18
  - [url](RegisterDynamicRouteMessage.md#url)
18
19
 
@@ -24,7 +25,17 @@
24
25
 
25
26
  #### Defined in
26
27
 
27
- [service-worker-messaging.ts:39](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L39)
28
+ [service-worker-messaging.ts:40](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L40)
29
+
30
+ ___
31
+
32
+ ### strategy
33
+
34
+ • `Optional` **strategy**: [`OmrsOfflineCachingStrategy`](../API.md#omrsofflinecachingstrategy)
35
+
36
+ #### Defined in
37
+
38
+ [service-worker-messaging.ts:42](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L42)
28
39
 
29
40
  ___
30
41
 
@@ -38,7 +49,7 @@ ___
38
49
 
39
50
  #### Defined in
40
51
 
41
- [service-worker-messaging.ts:26](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L26)
52
+ [service-worker-messaging.ts:27](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L27)
42
53
 
43
54
  ___
44
55
 
@@ -48,4 +59,4 @@ ___
48
59
 
49
60
  #### Defined in
50
61
 
51
- [service-worker-messaging.ts:40](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L40)
62
+ [service-worker-messaging.ts:41](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-offline/src/service-worker-messaging.ts#L41)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-offline",
3
- "version": "3.1.13-pre.656",
3
+ "version": "3.1.13-pre.667",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Helper utilities for OpenMRS",
6
6
  "browser": "dist/openmrs-esm-offline.js",
@@ -37,10 +37,10 @@
37
37
  "access": "public"
38
38
  },
39
39
  "devDependencies": {
40
- "@openmrs/esm-api": "^3.1.13-pre.656",
41
- "@openmrs/esm-globals": "^3.1.13-pre.656",
42
- "@openmrs/esm-state": "^3.1.13-pre.656",
43
- "@openmrs/esm-styleguide": "^3.1.13-pre.656",
40
+ "@openmrs/esm-api": "^3.1.13-pre.667",
41
+ "@openmrs/esm-globals": "^3.1.13-pre.667",
42
+ "@openmrs/esm-state": "^3.1.13-pre.667",
43
+ "@openmrs/esm-styleguide": "^3.1.13-pre.667",
44
44
  "@types/uuid": "^8.3.0",
45
45
  "rxjs": "^6.5.3"
46
46
  },
@@ -57,5 +57,5 @@
57
57
  "uuid": "^8.3.2",
58
58
  "workbox-window": "^6.1.5"
59
59
  },
60
- "gitHead": "f3906e0c4e4f5fdc868941b10c8f8570eeecbc0e"
60
+ "gitHead": "edbf3e89aa3a326e713f94ff89b8228b70e8af36"
61
61
  }
@@ -5,6 +5,18 @@ export const omrsOfflineResponseStatusHttpHeaderName =
5
5
  export const omrsOfflineCachingStrategyHttpHeaderName =
6
6
  "x-omrs-offline-caching-strategy";
7
7
 
8
+ /**
9
+ *
10
+ *
11
+ * * `cache-or-network`: The default strategy, equal to the absence of this header.
12
+ * The SW attempts to resolve the request via the network, but falls back to the cache if required.
13
+ * The service worker decides the strategy to be used.
14
+ * * `network-first`: See https://developers.google.com/web/tools/workbox/modules/workbox-strategies#network_first_network_falling_back_to_cache.
15
+ */
16
+ export type OmrsOfflineCachingStrategy =
17
+ | "network-only-or-cache-only"
18
+ | "network-first";
19
+
8
20
  /**
9
21
  * Defines the keys of the custom headers which can be appended to an HTTP request.
10
22
  * HTTP requests with these headers are handled in a special way by the SPA's service worker.
@@ -24,13 +36,8 @@ export type OmrsOfflineHttpHeaders = {
24
36
  [omrsOfflineResponseStatusHttpHeaderName]?: `${number}`;
25
37
  /**
26
38
  * Instructs the service worker to use a specific caching strategy for this request.
27
- * The supported values are:
28
- *
29
- * * `default`: Equal to the absence of this header/an invalid value.
30
- * The service worker decides the strategy to be used.
31
- * * `network-first`: The service worker will make the request and cache its response.
32
39
  */
33
- [omrsOfflineCachingStrategyHttpHeaderName]?: "default" | "network-first";
40
+ [omrsOfflineCachingStrategyHttpHeaderName]?: OmrsOfflineCachingStrategy;
34
41
  };
35
42
 
36
43
  export type OmrsOfflineHttpHeaderNames = keyof OmrsOfflineHttpHeaders;
@@ -1,4 +1,5 @@
1
1
  import type { ImportMap } from "@openmrs/esm-globals";
2
+ import { OmrsOfflineCachingStrategy } from "./service-worker-http-headers";
2
3
  import { getOmrsServiceWorker } from "./service-worker";
3
4
 
4
5
  /**
@@ -38,6 +39,7 @@ export interface RegisterDynamicRouteMessage
38
39
  extends OmrsServiceWorkerMessage<"registerDynamicRoute"> {
39
40
  pattern?: string;
40
41
  url?: string;
42
+ strategy?: OmrsOfflineCachingStrategy;
41
43
  }
42
44
 
43
45
  export type KnownOmrsServiceWorkerMessages =