@luvio/environments 0.68.0 → 0.72.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.
- package/dist/es/es2018/DurableStore.d.ts +0 -1
- package/dist/es/es2018/environments.js +166 -165
- package/dist/es/es2018/makeDurable/cachepolicies/utils.d.ts +3 -2
- package/dist/umd/es2018/DurableStore.d.ts +0 -1
- package/dist/umd/es2018/environments.js +166 -165
- package/dist/umd/es2018/makeDurable/cachepolicies/utils.d.ts +3 -2
- package/dist/umd/es5/DurableStore.d.ts +0 -1
- package/dist/umd/es5/environments.js +166 -164
- package/dist/umd/es5/makeDurable/cachepolicies/utils.d.ts +3 -2
- package/package.json +2 -2
|
@@ -58,9 +58,13 @@
|
|
|
58
58
|
var isArray = Array.isArray;
|
|
59
59
|
|
|
60
60
|
function appendTTLStrategy(storeLookup, ttlStrategy) {
|
|
61
|
-
|
|
61
|
+
var returnStoreLookup = function (sel, refresh) {
|
|
62
62
|
return storeLookup(sel, refresh, ttlStrategy);
|
|
63
63
|
};
|
|
64
|
+
// append ttlStrategy to storeLookup function (in cases where custom adapter
|
|
65
|
+
// wants to perform it's own lookup)
|
|
66
|
+
returnStoreLookup.ttlStrategy = ttlStrategy;
|
|
67
|
+
return returnStoreLookup;
|
|
64
68
|
}
|
|
65
69
|
function buildNetworkSnapshot(args) {
|
|
66
70
|
var buildNetworkSnapshot = args.buildNetworkSnapshot, buildSnapshotContext = args.buildSnapshotContext, coercedAdapterRequestContext = args.coercedAdapterRequestContext;
|
|
@@ -86,102 +90,113 @@
|
|
|
86
90
|
}
|
|
87
91
|
return engine.StoreResolveResultState.Found;
|
|
88
92
|
};
|
|
93
|
+
}
|
|
94
|
+
// TODO - update userland-facing APIs to return `AvailableSnapshot` instead of `Snapshot`
|
|
95
|
+
// and then the signatures here can be updated as well
|
|
96
|
+
function buildAvailableSnapshotFromCachedSnapshotResponse(cachedSnapshot, availableSnapshotFunc) {
|
|
97
|
+
if (isPromise(cachedSnapshot)) {
|
|
98
|
+
return cachedSnapshot.then(availableSnapshotFunc);
|
|
99
|
+
}
|
|
100
|
+
return availableSnapshotFunc(cachedSnapshot);
|
|
101
|
+
}
|
|
102
|
+
function isPromise(value) {
|
|
103
|
+
if (value === undefined) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
// check for Thenable due to test frameworks using custom Promise impls
|
|
107
|
+
return value.then !== undefined;
|
|
89
108
|
}
|
|
90
109
|
|
|
91
110
|
function buildCacheAndNetworkImplementation(funcs, staleDurationSeconds) {
|
|
111
|
+
if (staleDurationSeconds === void 0) { staleDurationSeconds = 0; }
|
|
92
112
|
return function (args) {
|
|
93
113
|
funcs.validateNotDisposed();
|
|
94
|
-
var
|
|
95
|
-
var staleDurationMilliseconds = staleDurationSeconds
|
|
114
|
+
var buildCachedSnapshot = args.buildCachedSnapshot, buildNetworkSnapshot$1 = args.buildNetworkSnapshot, buildSnapshotContext = args.buildSnapshotContext, storeLookup = args.storeLookup, coercedAdapterRequestContext = args.coercedAdapterRequestContext;
|
|
115
|
+
var staleDurationMilliseconds = staleDurationSeconds * 1000;
|
|
96
116
|
var cachePolicyStoreLookup = appendTTLStrategy(storeLookup, buildTTLStrategy(staleDurationMilliseconds));
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return args
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (revivedSnapshot.state === 'Stale') {
|
|
139
|
-
// kick off network request, do not await it
|
|
140
|
-
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
141
|
-
// return the L2 cached snapshot to caller
|
|
142
|
-
return revivedSnapshot;
|
|
143
|
-
}
|
|
144
|
-
// data not found in L2 cache, go to the network
|
|
145
|
-
return buildNetworkSnapshot(args);
|
|
146
|
-
});
|
|
117
|
+
var cachedSnapshot = buildCachedSnapshot(buildSnapshotContext, cachePolicyStoreLookup);
|
|
118
|
+
return buildAvailableSnapshotFromCachedSnapshotResponse(cachedSnapshot, function (snapshot) {
|
|
119
|
+
if (snapshot !== undefined) {
|
|
120
|
+
// data found in L1 cache
|
|
121
|
+
if (snapshot.state === 'Fulfilled' ||
|
|
122
|
+
snapshot.state === 'Error' ||
|
|
123
|
+
snapshot.state === 'Stale') {
|
|
124
|
+
// kick off network request, do not await it
|
|
125
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
126
|
+
// return the cached snapshot to caller
|
|
127
|
+
return snapshot;
|
|
128
|
+
}
|
|
129
|
+
// network request outstanding
|
|
130
|
+
if (snapshot.state === 'Pending') {
|
|
131
|
+
// kick off another network request, do not await it
|
|
132
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
133
|
+
return args.resolvePendingSnapshot(snapshot);
|
|
134
|
+
}
|
|
135
|
+
// if unfulfilled we have enough info to do an L2 lookup
|
|
136
|
+
if (snapshot.state === 'Unfulfilled') {
|
|
137
|
+
return funcs
|
|
138
|
+
.reviveSnapshotWithCachePolicy(snapshot, cachePolicyStoreLookup)
|
|
139
|
+
.then(function (revivedSnapshot) {
|
|
140
|
+
// data found in L2 cache
|
|
141
|
+
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
142
|
+
revivedSnapshot.state === 'Error' ||
|
|
143
|
+
revivedSnapshot.state === 'Stale') {
|
|
144
|
+
// kick off network request, do not await it
|
|
145
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
146
|
+
// return the L2 cached snapshot to caller
|
|
147
|
+
return revivedSnapshot;
|
|
148
|
+
}
|
|
149
|
+
if (revivedSnapshot.state === 'Pending') {
|
|
150
|
+
// kick off network request, do not await it
|
|
151
|
+
buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
|
|
152
|
+
return args.resolvePendingSnapshot(revivedSnapshot);
|
|
153
|
+
}
|
|
154
|
+
// data not found in L2 cache, go to the network
|
|
155
|
+
return buildNetworkSnapshot(args);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
147
158
|
}
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
return buildNetworkSnapshot(args);
|
|
160
|
+
});
|
|
150
161
|
};
|
|
151
162
|
}
|
|
152
163
|
|
|
153
164
|
function buildCacheThenNetworkImplementation(funcs) {
|
|
154
165
|
return function (args) {
|
|
155
166
|
funcs.validateNotDisposed();
|
|
156
|
-
var
|
|
167
|
+
var buildCachedSnapshot = args.buildCachedSnapshot, buildSnapshotContext = args.buildSnapshotContext, storeLookup = args.storeLookup;
|
|
157
168
|
var cachePolicyStoreLookup = appendTTLStrategy(storeLookup, buildTTLStrategy());
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (snapshot.state === 'Pending') {
|
|
165
|
-
return args.resolvePendingSnapshot(snapshot);
|
|
166
|
-
}
|
|
167
|
-
// data not found in L1 cache, try L2 cache
|
|
168
|
-
return funcs
|
|
169
|
-
.reviveSnapshotWithCachePolicy(snapshot, cachePolicyStoreLookup)
|
|
170
|
-
.then(function (revivedSnapshot) {
|
|
171
|
-
// data found in L2 cache
|
|
172
|
-
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
173
|
-
revivedSnapshot.state === 'Error') {
|
|
174
|
-
return revivedSnapshot;
|
|
169
|
+
var cachedSnapshot = buildCachedSnapshot(buildSnapshotContext, cachePolicyStoreLookup);
|
|
170
|
+
return buildAvailableSnapshotFromCachedSnapshotResponse(cachedSnapshot, function (snapshot) {
|
|
171
|
+
if (snapshot !== undefined) {
|
|
172
|
+
// data found in L1 cache
|
|
173
|
+
if (snapshot.state === 'Fulfilled' || snapshot.state === 'Error') {
|
|
174
|
+
return snapshot;
|
|
175
175
|
}
|
|
176
|
-
if (
|
|
177
|
-
return args.resolvePendingSnapshot(
|
|
176
|
+
if (snapshot.state === 'Pending') {
|
|
177
|
+
return args.resolvePendingSnapshot(snapshot);
|
|
178
178
|
}
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
// if unfulfilled we have enough info to do an L2 lookup
|
|
180
|
+
if (snapshot.state === 'Unfulfilled') {
|
|
181
|
+
return funcs
|
|
182
|
+
.reviveSnapshotWithCachePolicy(snapshot, cachePolicyStoreLookup)
|
|
183
|
+
.then(function (revivedSnapshot) {
|
|
184
|
+
// data found in L2 cache
|
|
185
|
+
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
186
|
+
revivedSnapshot.state === 'Error') {
|
|
187
|
+
return revivedSnapshot;
|
|
188
|
+
}
|
|
189
|
+
if (revivedSnapshot.state === 'Pending') {
|
|
190
|
+
return args.resolvePendingSnapshot(revivedSnapshot);
|
|
191
|
+
}
|
|
192
|
+
// data not found in L2 cache, go to the network
|
|
193
|
+
return buildNetworkSnapshot(args);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// L1 lookup could not find enough information to even construct a snapshot, go to the network
|
|
198
|
+
return buildNetworkSnapshot(args);
|
|
199
|
+
});
|
|
185
200
|
};
|
|
186
201
|
}
|
|
187
202
|
|
|
@@ -225,84 +240,90 @@
|
|
|
225
240
|
error: error,
|
|
226
241
|
state: 'Error',
|
|
227
242
|
data: undefined,
|
|
228
|
-
// TODO[@W-10164067]: copy refresh data from the snapshot returned by
|
|
243
|
+
// TODO[@W-10164067]: copy refresh data from the snapshot returned by buildCachedSnapshot (if any)
|
|
229
244
|
// refresh: ...
|
|
230
245
|
};
|
|
231
246
|
}
|
|
232
247
|
function buildOnlyIfCachedImplementation(funcs) {
|
|
233
248
|
return function (args) {
|
|
234
249
|
funcs.validateNotDisposed();
|
|
235
|
-
var
|
|
250
|
+
var buildCachedSnapshot = args.buildCachedSnapshot, buildSnapshotContext = args.buildSnapshotContext, storeLookup = args.storeLookup;
|
|
236
251
|
var cachePolicyStoreLookup = appendTTLStrategy(storeLookup, buildTTLStrategy());
|
|
237
|
-
var
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
// network request outstanding, data is not cached
|
|
244
|
-
if (snapshot.state === 'Pending') {
|
|
245
|
-
return buildNotCachedErrorSnapshot();
|
|
246
|
-
}
|
|
247
|
-
// data not found in L1 cache, try L2 cache
|
|
248
|
-
return funcs
|
|
249
|
-
.reviveSnapshotWithCachePolicy(snapshot, cachePolicyStoreLookup)
|
|
250
|
-
.then(function (revivedSnapshot) {
|
|
251
|
-
// data found in L2 cache
|
|
252
|
-
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
253
|
-
revivedSnapshot.state === 'Error') {
|
|
254
|
-
return revivedSnapshot;
|
|
252
|
+
var cachedSnapshot = buildCachedSnapshot(buildSnapshotContext, cachePolicyStoreLookup);
|
|
253
|
+
return buildAvailableSnapshotFromCachedSnapshotResponse(cachedSnapshot, function (snapshot) {
|
|
254
|
+
if (snapshot !== undefined) {
|
|
255
|
+
// data found in L1 cache
|
|
256
|
+
if (snapshot.state === 'Fulfilled' || snapshot.state === 'Error') {
|
|
257
|
+
return snapshot;
|
|
255
258
|
}
|
|
256
|
-
// data is not cached
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
// network request outstanding, data is not cached
|
|
260
|
+
if (snapshot.state === 'Pending') {
|
|
261
|
+
return buildNotCachedErrorSnapshot();
|
|
262
|
+
}
|
|
263
|
+
// if unfulfilled we have enough info to do an L2 lookup
|
|
264
|
+
if (snapshot.state === 'Unfulfilled') {
|
|
265
|
+
return funcs
|
|
266
|
+
.reviveSnapshotWithCachePolicy(snapshot, cachePolicyStoreLookup)
|
|
267
|
+
.then(function (revivedSnapshot) {
|
|
268
|
+
// data found in L2 cache
|
|
269
|
+
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
270
|
+
revivedSnapshot.state === 'Error') {
|
|
271
|
+
return revivedSnapshot;
|
|
272
|
+
}
|
|
273
|
+
// data is not cached
|
|
274
|
+
return buildNotCachedErrorSnapshot();
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return buildNotCachedErrorSnapshot();
|
|
279
|
+
});
|
|
261
280
|
};
|
|
262
281
|
}
|
|
263
282
|
|
|
264
283
|
function buildStaleWhileRevalidateImplementation(funcs, staleDurationSeconds) {
|
|
265
284
|
return function (args) {
|
|
266
285
|
funcs.validateNotDisposed();
|
|
267
|
-
var
|
|
286
|
+
var buildCachedSnapshot = args.buildCachedSnapshot, buildSnapshotContext = args.buildSnapshotContext, storeLookup = args.storeLookup;
|
|
268
287
|
var cachePolicyStoreLookup = appendTTLStrategy(storeLookup, buildTTLStrategy(staleDurationSeconds * 1000));
|
|
269
|
-
var
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (snapshot.state === 'Pending') {
|
|
276
|
-
return args.resolvePendingSnapshot(snapshot);
|
|
277
|
-
}
|
|
278
|
-
// stale data found in L1 cache
|
|
279
|
-
if (snapshot.state === 'Stale') {
|
|
280
|
-
buildNetworkSnapshot(args);
|
|
281
|
-
return snapshot;
|
|
282
|
-
}
|
|
283
|
-
// data not found in L1 cache, try L2 cache
|
|
284
|
-
return funcs
|
|
285
|
-
.reviveSnapshotWithCachePolicy(snapshot, cachePolicyStoreLookup)
|
|
286
|
-
.then(function (revivedSnapshot) {
|
|
287
|
-
// data found in L2 cache
|
|
288
|
-
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
289
|
-
revivedSnapshot.state === 'Error') {
|
|
290
|
-
return revivedSnapshot;
|
|
288
|
+
var cachedSnapshot = buildCachedSnapshot(buildSnapshotContext, cachePolicyStoreLookup);
|
|
289
|
+
return buildAvailableSnapshotFromCachedSnapshotResponse(cachedSnapshot, function (snapshot) {
|
|
290
|
+
if (snapshot !== undefined) {
|
|
291
|
+
// data found in L1 cache
|
|
292
|
+
if (snapshot.state === 'Fulfilled' || snapshot.state === 'Error') {
|
|
293
|
+
return snapshot;
|
|
291
294
|
}
|
|
292
|
-
if (
|
|
293
|
-
return args.resolvePendingSnapshot(
|
|
295
|
+
if (snapshot.state === 'Pending') {
|
|
296
|
+
return args.resolvePendingSnapshot(snapshot);
|
|
294
297
|
}
|
|
295
|
-
// stale data found in
|
|
296
|
-
if (
|
|
298
|
+
// stale data found in L1 cache
|
|
299
|
+
if (snapshot.state === 'Stale') {
|
|
297
300
|
buildNetworkSnapshot(args);
|
|
298
|
-
return
|
|
301
|
+
return snapshot;
|
|
299
302
|
}
|
|
300
|
-
// data not found in
|
|
301
|
-
return
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
// data not found in L1 cache, try L2 cache
|
|
304
|
+
return funcs
|
|
305
|
+
.reviveSnapshotWithCachePolicy(snapshot, cachePolicyStoreLookup)
|
|
306
|
+
.then(function (revivedSnapshot) {
|
|
307
|
+
// data found in L2 cache
|
|
308
|
+
if (revivedSnapshot.state === 'Fulfilled' ||
|
|
309
|
+
revivedSnapshot.state === 'Error') {
|
|
310
|
+
return revivedSnapshot;
|
|
311
|
+
}
|
|
312
|
+
if (revivedSnapshot.state === 'Pending') {
|
|
313
|
+
return args.resolvePendingSnapshot(revivedSnapshot);
|
|
314
|
+
}
|
|
315
|
+
// stale data found in L2 cache
|
|
316
|
+
if (revivedSnapshot.state === 'Stale') {
|
|
317
|
+
buildNetworkSnapshot(args);
|
|
318
|
+
return revivedSnapshot;
|
|
319
|
+
}
|
|
320
|
+
// data not found in L2 cache, go to the network
|
|
321
|
+
return buildNetworkSnapshot(args);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
// L1 lookup could not find enough information to even construct a snapshot, go to the network
|
|
325
|
+
return buildNetworkSnapshot(args);
|
|
326
|
+
});
|
|
306
327
|
};
|
|
307
328
|
}
|
|
308
329
|
|
|
@@ -313,7 +334,7 @@
|
|
|
313
334
|
// TTLStrategy to use the the valid-at cache policy's timestamp. The flow goes:
|
|
314
335
|
//
|
|
315
336
|
// Environment.applyCachePolicy => validAtImplementation (this function) =>
|
|
316
|
-
// basePolicyImplementation => adapter's
|
|
337
|
+
// basePolicyImplementation => adapter's buildCachedSnapshot =>
|
|
317
338
|
// basePolicyImplementation's storeLookup => validAtStoreLookup (below) =>
|
|
318
339
|
// Environment.applyCachePolicy's storeLookup => Store/Reader code =>
|
|
319
340
|
// valid-at TTLStrategy (below) =>
|
|
@@ -414,9 +435,6 @@
|
|
|
414
435
|
return storeRecord.__type === 'error';
|
|
415
436
|
}
|
|
416
437
|
|
|
417
|
-
function isStoreEntryExpiredAndError(storeRecord, expirationTimestamp, now) {
|
|
418
|
-
return isStoreEntryError(storeRecord) && expirationTimestamp < now;
|
|
419
|
-
}
|
|
420
438
|
/**
|
|
421
439
|
* Takes a set of entries from DurableStore and publishes them via the passed in funcs.
|
|
422
440
|
* This respects expiration and checks for valid DurableStore data shapes. This should
|
|
@@ -439,7 +457,6 @@
|
|
|
439
457
|
// no records to revive
|
|
440
458
|
return { revivedKeys: revivedKeys, hadUnexpectedShape: hadUnexpectedShape };
|
|
441
459
|
}
|
|
442
|
-
var now = Date.now();
|
|
443
460
|
for (var i = 0, len = durableKeys.length; i < len; i += 1) {
|
|
444
461
|
var key = durableKeys[i];
|
|
445
462
|
var durableRecord = durableRecords[key];
|
|
@@ -455,27 +472,12 @@
|
|
|
455
472
|
continue;
|
|
456
473
|
}
|
|
457
474
|
if (metadata !== undefined) {
|
|
458
|
-
var expirationTimestamp = metadata.expirationTimestamp
|
|
475
|
+
var expirationTimestamp = metadata.expirationTimestamp;
|
|
459
476
|
if (expirationTimestamp === undefined) {
|
|
460
477
|
// if unexpected expiration data skip reviving
|
|
461
478
|
hadUnexpectedShape = true;
|
|
462
479
|
continue;
|
|
463
480
|
}
|
|
464
|
-
// if past stale TTL then don't revive
|
|
465
|
-
if (staleTimestamp !== undefined && staleTimestamp < now) {
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
468
|
-
// We don't want to revive a cached value if it's an error and it's
|
|
469
|
-
// expirationTimestamp TTL is expired, otherwise we would never hit the network
|
|
470
|
-
// during resolveSnapshot or rebuildSnapshot because the way the Reader works.
|
|
471
|
-
// If a StoreEntry is an error, the Reader will return UnfulfilledSnapshot
|
|
472
|
-
// if stale TTL is expired. But it will return ErrorSnapshot (instead of
|
|
473
|
-
// StaleSnapshot) if expirationTimestamp TTL is expired (but stale TTL isn't).
|
|
474
|
-
// In our environment the stale TTL is maxed out so Reader will always
|
|
475
|
-
// return ErrorSnapshot.
|
|
476
|
-
if (isStoreEntryExpiredAndError(data, expirationTimestamp, now)) {
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
481
|
publishMetadata(key, metadata);
|
|
480
482
|
}
|
|
481
483
|
if (isStoreEntryError(data)) {
|
|
@@ -873,7 +875,7 @@
|
|
|
873
875
|
if (ingestStagingStore !== null) {
|
|
874
876
|
return ingestStagingStore.lookup(sel, createSnapshot, refresh, ttlStrategy);
|
|
875
877
|
}
|
|
876
|
-
// otherwise this is from
|
|
878
|
+
// otherwise this is from buildCachedSnapshot and we should use the luvio
|
|
877
879
|
// L1 store
|
|
878
880
|
return environment.storeLookup(sel, createSnapshot, refresh, ttlStrategy);
|
|
879
881
|
};
|
|
@@ -1037,7 +1039,7 @@
|
|
|
1037
1039
|
}
|
|
1038
1040
|
}
|
|
1039
1041
|
}
|
|
1040
|
-
var applyCachePolicy = function (adapterRequestContext, buildSnapshotContext,
|
|
1042
|
+
var applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildCachedSnapshot, buildNetworkSnapshot) {
|
|
1041
1043
|
validateNotDisposed();
|
|
1042
1044
|
var cachePolicy = adapterRequestContext.cachePolicy;
|
|
1043
1045
|
var cachePolicyImpl = resolveCachePolicy(cachePolicy);
|
|
@@ -1047,7 +1049,7 @@
|
|
|
1047
1049
|
var storeLookup = function (sel, refresh, ttlStrategy) { return environment.storeLookup(sel, environment.createSnapshot, refresh, ttlStrategy); };
|
|
1048
1050
|
var applyCachePolicy = function () {
|
|
1049
1051
|
return cachePolicyImpl({
|
|
1050
|
-
|
|
1052
|
+
buildCachedSnapshot: buildCachedSnapshot,
|
|
1051
1053
|
buildNetworkSnapshot: buildNetworkSnapshot,
|
|
1052
1054
|
buildSnapshotContext: buildSnapshotContext,
|
|
1053
1055
|
resolvePendingSnapshot: resolvePendingSnapshot,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuildCachedSnapshot, CachePolicyImplementationArgs, Snapshot, StoreLookup, TTLStrategy, UnAvailableSnapshot } from '@luvio/engine';
|
|
2
2
|
export declare type DurableCachePolicyFunctions = {
|
|
3
3
|
validateNotDisposed: () => void;
|
|
4
4
|
reviveSnapshotWithCachePolicy: <D, V>(unavailableSnapshot: UnAvailableSnapshot<D, V>, storeLookup: StoreLookup<D, V>) => Promise<Snapshot<D, V>>;
|
|
5
5
|
};
|
|
6
|
-
export declare function appendTTLStrategy<C, D>(storeLookup: CachePolicyImplementationArgs<C, D>['storeLookup'], ttlStrategy: TTLStrategy): Parameters<
|
|
6
|
+
export declare function appendTTLStrategy<C, D>(storeLookup: CachePolicyImplementationArgs<C, D>['storeLookup'], ttlStrategy: TTLStrategy): Parameters<BuildCachedSnapshot<C, D>>[1];
|
|
7
7
|
export declare function buildNetworkSnapshot<C, D>(args: CachePolicyImplementationArgs<C, D>): Promise<Snapshot<D, unknown>>;
|
|
8
8
|
export declare function buildTTLStrategy(staleDurationMilliseconds?: number): TTLStrategy;
|
|
9
|
+
export declare function buildAvailableSnapshotFromCachedSnapshotResponse<C, D>(cachedSnapshot: ReturnType<BuildCachedSnapshot<C, D>>, availableSnapshotFunc: (snapshot: Snapshot<D> | undefined) => Snapshot<D> | Promise<Snapshot<D>>): Snapshot<D> | Promise<Snapshot<D>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/environments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"description": "Luvio Environments",
|
|
5
5
|
"main": "dist/umd/es2018/environments.js",
|
|
6
6
|
"module": "dist/es/es2018/environments.js",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"dist/"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@luvio/engine": "0.
|
|
29
|
+
"@luvio/engine": "0.72.0"
|
|
30
30
|
}
|
|
31
31
|
}
|