@luvio/environments 0.63.3 → 0.64.0
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StoreResolveResultState, HttpStatusCode, Store, buildStaleWhileRevalidateImplementation as buildStaleWhileRevalidateImplementation$1 } from '@luvio/engine';
|
|
1
|
+
import { StoreResolveResultState, HttpStatusCode, Store, coerceAdapterRequestContext, buildStaleWhileRevalidateImplementation as buildStaleWhileRevalidateImplementation$1 } from '@luvio/engine';
|
|
2
2
|
|
|
3
3
|
function isDeprecatedDurableStoreEntry(durableRecord) {
|
|
4
4
|
if (durableRecord.expiration !== undefined) {
|
|
@@ -21,8 +21,8 @@ function appendTTLStrategy(storeLookup, ttlStrategy) {
|
|
|
21
21
|
return (sel, refresh) => storeLookup(sel, refresh, ttlStrategy);
|
|
22
22
|
}
|
|
23
23
|
function buildNetworkSnapshot(args) {
|
|
24
|
-
const { buildNetworkSnapshot, buildSnapshotContext } = args;
|
|
25
|
-
return buildNetworkSnapshot(buildSnapshotContext).then((snapshot) => snapshot.state === 'Pending' ? args.resolvePendingSnapshot(snapshot) : snapshot);
|
|
24
|
+
const { buildNetworkSnapshot, buildSnapshotContext, coercedAdapterRequestContext } = args;
|
|
25
|
+
return buildNetworkSnapshot(buildSnapshotContext, coercedAdapterRequestContext).then((snapshot) => snapshot.state === 'Pending' ? args.resolvePendingSnapshot(snapshot) : snapshot);
|
|
26
26
|
}
|
|
27
27
|
function buildTTLStrategy(staleDurationMilliseconds = 0) {
|
|
28
28
|
return (timestamp, metadata, valueIsError) => {
|
|
@@ -46,7 +46,7 @@ function buildTTLStrategy(staleDurationMilliseconds = 0) {
|
|
|
46
46
|
function buildCacheAndNetworkImplementation(funcs, staleDurationSeconds) {
|
|
47
47
|
return function (args) {
|
|
48
48
|
funcs.validateNotDisposed();
|
|
49
|
-
const { buildInMemorySnapshot, buildNetworkSnapshot: buildNetworkSnapshot$1, buildSnapshotContext, storeLookup } = args;
|
|
49
|
+
const { buildInMemorySnapshot, buildNetworkSnapshot: buildNetworkSnapshot$1, buildSnapshotContext, storeLookup, coercedAdapterRequestContext, } = args;
|
|
50
50
|
const staleDurationMilliseconds = staleDurationSeconds === undefined ? undefined : staleDurationSeconds * 1000;
|
|
51
51
|
const cachePolicyStoreLookup = appendTTLStrategy(storeLookup, buildTTLStrategy(staleDurationMilliseconds));
|
|
52
52
|
const snapshot = buildInMemorySnapshot(buildSnapshotContext, cachePolicyStoreLookup);
|
|
@@ -54,14 +54,14 @@ function buildCacheAndNetworkImplementation(funcs, staleDurationSeconds) {
|
|
|
54
54
|
// data found in L1 cache
|
|
55
55
|
if (snapshot.state === 'Fulfilled' || snapshot.state === 'Error') {
|
|
56
56
|
// kick off network request, do not await it
|
|
57
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
57
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
58
58
|
// return the cached snapshot to caller
|
|
59
59
|
return snapshot;
|
|
60
60
|
}
|
|
61
61
|
// network request outstanding
|
|
62
62
|
if (snapshot.state === 'Pending') {
|
|
63
63
|
// kick off another network request, do not await it
|
|
64
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
64
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
65
65
|
return args.resolvePendingSnapshot(snapshot);
|
|
66
66
|
}
|
|
67
67
|
// stale data found in L1 cache
|
|
@@ -81,13 +81,13 @@ function buildCacheAndNetworkImplementation(funcs, staleDurationSeconds) {
|
|
|
81
81
|
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
82
82
|
revivedSnapshot.state === 'Error') {
|
|
83
83
|
// kick off network request, do not await it
|
|
84
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
84
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
85
85
|
// return the L2 cached snapshot to caller
|
|
86
86
|
return revivedSnapshot;
|
|
87
87
|
}
|
|
88
88
|
if (revivedSnapshot.state === 'Pending') {
|
|
89
89
|
// kick off network request, do not await it
|
|
90
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
90
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
91
91
|
return args.resolvePendingSnapshot(revivedSnapshot);
|
|
92
92
|
}
|
|
93
93
|
// stale data found in L2 cache
|
|
@@ -995,7 +995,8 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
995
995
|
}
|
|
996
996
|
const applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
|
|
997
997
|
validateNotDisposed();
|
|
998
|
-
const
|
|
998
|
+
const { cachePolicy } = adapterRequestContext;
|
|
999
|
+
const cachePolicyImpl = resolveCachePolicy(cachePolicy);
|
|
999
1000
|
const resolvePendingSnapshot = (snapshot) => environment.resolvePendingSnapshot(snapshot);
|
|
1000
1001
|
const storeLookup = (sel, refresh, ttlStrategy) => environment.storeLookup(sel, environment.createSnapshot, refresh, ttlStrategy);
|
|
1001
1002
|
const applyCachePolicy = () => {
|
|
@@ -1005,6 +1006,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
1005
1006
|
buildSnapshotContext,
|
|
1006
1007
|
resolvePendingSnapshot,
|
|
1007
1008
|
storeLookup,
|
|
1009
|
+
coercedAdapterRequestContext: coerceAdapterRequestContext(adapterRequestContext),
|
|
1008
1010
|
});
|
|
1009
1011
|
};
|
|
1010
1012
|
return isRevivingTTLOverrides !== undefined
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
return (sel, refresh) => storeLookup(sel, refresh, ttlStrategy);
|
|
26
26
|
}
|
|
27
27
|
function buildNetworkSnapshot(args) {
|
|
28
|
-
const { buildNetworkSnapshot, buildSnapshotContext } = args;
|
|
29
|
-
return buildNetworkSnapshot(buildSnapshotContext).then((snapshot) => snapshot.state === 'Pending' ? args.resolvePendingSnapshot(snapshot) : snapshot);
|
|
28
|
+
const { buildNetworkSnapshot, buildSnapshotContext, coercedAdapterRequestContext } = args;
|
|
29
|
+
return buildNetworkSnapshot(buildSnapshotContext, coercedAdapterRequestContext).then((snapshot) => snapshot.state === 'Pending' ? args.resolvePendingSnapshot(snapshot) : snapshot);
|
|
30
30
|
}
|
|
31
31
|
function buildTTLStrategy(staleDurationMilliseconds = 0) {
|
|
32
32
|
return (timestamp, metadata, valueIsError) => {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
function buildCacheAndNetworkImplementation(funcs, staleDurationSeconds) {
|
|
51
51
|
return function (args) {
|
|
52
52
|
funcs.validateNotDisposed();
|
|
53
|
-
const { buildInMemorySnapshot, buildNetworkSnapshot: buildNetworkSnapshot$1, buildSnapshotContext, storeLookup } = args;
|
|
53
|
+
const { buildInMemorySnapshot, buildNetworkSnapshot: buildNetworkSnapshot$1, buildSnapshotContext, storeLookup, coercedAdapterRequestContext, } = args;
|
|
54
54
|
const staleDurationMilliseconds = staleDurationSeconds === undefined ? undefined : staleDurationSeconds * 1000;
|
|
55
55
|
const cachePolicyStoreLookup = appendTTLStrategy(storeLookup, buildTTLStrategy(staleDurationMilliseconds));
|
|
56
56
|
const snapshot = buildInMemorySnapshot(buildSnapshotContext, cachePolicyStoreLookup);
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
// data found in L1 cache
|
|
59
59
|
if (snapshot.state === 'Fulfilled' || snapshot.state === 'Error') {
|
|
60
60
|
// kick off network request, do not await it
|
|
61
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
61
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
62
62
|
// return the cached snapshot to caller
|
|
63
63
|
return snapshot;
|
|
64
64
|
}
|
|
65
65
|
// network request outstanding
|
|
66
66
|
if (snapshot.state === 'Pending') {
|
|
67
67
|
// kick off another network request, do not await it
|
|
68
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
68
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
69
69
|
return args.resolvePendingSnapshot(snapshot);
|
|
70
70
|
}
|
|
71
71
|
// stale data found in L1 cache
|
|
@@ -85,13 +85,13 @@
|
|
|
85
85
|
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
86
86
|
revivedSnapshot.state === 'Error') {
|
|
87
87
|
// kick off network request, do not await it
|
|
88
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
88
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
89
89
|
// return the L2 cached snapshot to caller
|
|
90
90
|
return revivedSnapshot;
|
|
91
91
|
}
|
|
92
92
|
if (revivedSnapshot.state === 'Pending') {
|
|
93
93
|
// kick off network request, do not await it
|
|
94
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
94
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
95
95
|
return args.resolvePendingSnapshot(revivedSnapshot);
|
|
96
96
|
}
|
|
97
97
|
// stale data found in L2 cache
|
|
@@ -999,7 +999,8 @@
|
|
|
999
999
|
}
|
|
1000
1000
|
const applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
|
|
1001
1001
|
validateNotDisposed();
|
|
1002
|
-
const
|
|
1002
|
+
const { cachePolicy } = adapterRequestContext;
|
|
1003
|
+
const cachePolicyImpl = resolveCachePolicy(cachePolicy);
|
|
1003
1004
|
const resolvePendingSnapshot = (snapshot) => environment.resolvePendingSnapshot(snapshot);
|
|
1004
1005
|
const storeLookup = (sel, refresh, ttlStrategy) => environment.storeLookup(sel, environment.createSnapshot, refresh, ttlStrategy);
|
|
1005
1006
|
const applyCachePolicy = () => {
|
|
@@ -1009,6 +1010,7 @@
|
|
|
1009
1010
|
buildSnapshotContext,
|
|
1010
1011
|
resolvePendingSnapshot,
|
|
1011
1012
|
storeLookup,
|
|
1013
|
+
coercedAdapterRequestContext: engine.coerceAdapterRequestContext(adapterRequestContext),
|
|
1012
1014
|
});
|
|
1013
1015
|
};
|
|
1014
1016
|
return isRevivingTTLOverrides !== undefined
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
function buildNetworkSnapshot(args) {
|
|
66
|
-
var buildNetworkSnapshot = args.buildNetworkSnapshot, buildSnapshotContext = args.buildSnapshotContext;
|
|
67
|
-
return buildNetworkSnapshot(buildSnapshotContext).then(function (snapshot) {
|
|
66
|
+
var buildNetworkSnapshot = args.buildNetworkSnapshot, buildSnapshotContext = args.buildSnapshotContext, coercedAdapterRequestContext = args.coercedAdapterRequestContext;
|
|
67
|
+
return buildNetworkSnapshot(buildSnapshotContext, coercedAdapterRequestContext).then(function (snapshot) {
|
|
68
68
|
return snapshot.state === 'Pending' ? args.resolvePendingSnapshot(snapshot) : snapshot;
|
|
69
69
|
});
|
|
70
70
|
}
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
function buildCacheAndNetworkImplementation(funcs, staleDurationSeconds) {
|
|
92
92
|
return function (args) {
|
|
93
93
|
funcs.validateNotDisposed();
|
|
94
|
-
var buildInMemorySnapshot = args.buildInMemorySnapshot, buildNetworkSnapshot$1 = args.buildNetworkSnapshot, buildSnapshotContext = args.buildSnapshotContext, storeLookup = args.storeLookup;
|
|
94
|
+
var buildInMemorySnapshot = args.buildInMemorySnapshot, buildNetworkSnapshot$1 = args.buildNetworkSnapshot, buildSnapshotContext = args.buildSnapshotContext, storeLookup = args.storeLookup, coercedAdapterRequestContext = args.coercedAdapterRequestContext;
|
|
95
95
|
var staleDurationMilliseconds = staleDurationSeconds === undefined ? undefined : staleDurationSeconds * 1000;
|
|
96
96
|
var cachePolicyStoreLookup = appendTTLStrategy(storeLookup, buildTTLStrategy(staleDurationMilliseconds));
|
|
97
97
|
var snapshot = buildInMemorySnapshot(buildSnapshotContext, cachePolicyStoreLookup);
|
|
@@ -99,14 +99,14 @@
|
|
|
99
99
|
// data found in L1 cache
|
|
100
100
|
if (snapshot.state === 'Fulfilled' || snapshot.state === 'Error') {
|
|
101
101
|
// kick off network request, do not await it
|
|
102
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
102
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
103
103
|
// return the cached snapshot to caller
|
|
104
104
|
return snapshot;
|
|
105
105
|
}
|
|
106
106
|
// network request outstanding
|
|
107
107
|
if (snapshot.state === 'Pending') {
|
|
108
108
|
// kick off another network request, do not await it
|
|
109
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
109
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
110
110
|
return args.resolvePendingSnapshot(snapshot);
|
|
111
111
|
}
|
|
112
112
|
// stale data found in L1 cache
|
|
@@ -126,13 +126,13 @@
|
|
|
126
126
|
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
127
127
|
revivedSnapshot.state === 'Error') {
|
|
128
128
|
// kick off network request, do not await it
|
|
129
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
129
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
130
130
|
// return the L2 cached snapshot to caller
|
|
131
131
|
return revivedSnapshot;
|
|
132
132
|
}
|
|
133
133
|
if (revivedSnapshot.state === 'Pending') {
|
|
134
134
|
// kick off network request, do not await it
|
|
135
|
-
buildNetworkSnapshot$1(buildSnapshotContext);
|
|
135
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
136
136
|
return args.resolvePendingSnapshot(revivedSnapshot);
|
|
137
137
|
}
|
|
138
138
|
// stale data found in L2 cache
|
|
@@ -1044,7 +1044,8 @@
|
|
|
1044
1044
|
}
|
|
1045
1045
|
var applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
|
|
1046
1046
|
validateNotDisposed();
|
|
1047
|
-
var
|
|
1047
|
+
var cachePolicy = adapterRequestContext.cachePolicy;
|
|
1048
|
+
var cachePolicyImpl = resolveCachePolicy(cachePolicy);
|
|
1048
1049
|
var resolvePendingSnapshot = function (snapshot) {
|
|
1049
1050
|
return environment.resolvePendingSnapshot(snapshot);
|
|
1050
1051
|
};
|
|
@@ -1056,6 +1057,7 @@
|
|
|
1056
1057
|
buildSnapshotContext: buildSnapshotContext,
|
|
1057
1058
|
resolvePendingSnapshot: resolvePendingSnapshot,
|
|
1058
1059
|
storeLookup: storeLookup,
|
|
1060
|
+
coercedAdapterRequestContext: engine.coerceAdapterRequestContext(adapterRequestContext),
|
|
1059
1061
|
});
|
|
1060
1062
|
};
|
|
1061
1063
|
return isRevivingTTLOverrides !== undefined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/environments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"description": "Luvio Environments",
|
|
5
5
|
"main": "dist/umd/es2018/environments.js",
|
|
6
6
|
"module": "dist/es/es2018/environments.js",
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
"dist/"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@luvio/engine": "0.
|
|
20
|
+
"@luvio/engine": "0.64.0"
|
|
21
21
|
}
|
|
22
22
|
}
|