@luvio/environments 0.63.1 → 0.65.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
@@ -182,6 +182,8 @@ function buildNotCachedErrorSnapshot() {
182
182
  error,
183
183
  state: 'Error',
184
184
  data: undefined,
185
+ // TODO[@W-10164067]: copy refresh data from the snapshot returned by buildInMemorySnapshot (if any)
186
+ // refresh: ...
185
187
  };
186
188
  }
187
189
  function buildOnlyIfCachedImplementation(funcs) {
@@ -923,13 +925,17 @@ function makeDurable(environment, { durableStore, instrumentation }) {
923
925
  };
924
926
  const storeSetTTLOverride = function (namespace, representationName, ttl) {
925
927
  validateNotDisposed();
926
- durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl);
927
- environment.storeSetTTLOverride(namespace, representationName, ttl);
928
+ return Promise.all([
929
+ environment.storeSetTTLOverride(namespace, representationName, ttl),
930
+ durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl),
931
+ ]).then();
928
932
  };
929
933
  const storeSetDefaultTTLOverride = function (ttl) {
930
934
  validateNotDisposed();
931
- durableTTLStore.setDefaultDurableTTLOverrides(ttl);
932
- environment.storeSetDefaultTTLOverride(ttl);
935
+ return Promise.all([
936
+ environment.storeSetDefaultTTLOverride(ttl),
937
+ durableTTLStore.setDefaultDurableTTLOverrides(ttl),
938
+ ]).then();
933
939
  };
934
940
  const getDurableTTLOverrides = function () {
935
941
  validateNotDisposed();
@@ -989,7 +995,8 @@ function makeDurable(environment, { durableStore, instrumentation }) {
989
995
  }
990
996
  const applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
991
997
  validateNotDisposed();
992
- const cachePolicyImpl = resolveCachePolicy(adapterRequestContext.cachePolicy);
998
+ const { cachePolicy } = adapterRequestContext;
999
+ const cachePolicyImpl = resolveCachePolicy(cachePolicy);
993
1000
  const resolvePendingSnapshot = (snapshot) => environment.resolvePendingSnapshot(snapshot);
994
1001
  const storeLookup = (sel, refresh, ttlStrategy) => environment.storeLookup(sel, environment.createSnapshot, refresh, ttlStrategy);
995
1002
  const applyCachePolicy = () => {
@@ -999,6 +1006,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
999
1006
  buildSnapshotContext,
1000
1007
  resolvePendingSnapshot,
1001
1008
  storeLookup,
1009
+ coercedAdapterRequestContext: coerceAdapterRequestContext(adapterRequestContext),
1002
1010
  });
1003
1011
  };
1004
1012
  return isRevivingTTLOverrides !== undefined
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildCacheAndNetworkImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds?: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildCacheAndNetworkImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds?: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildCacheThenNetworkImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildCacheThenNetworkImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildNoCacheImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildNoCacheImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
- import { CachePolicyImplementationArgs, ErrorSnapshot, Snapshot } from '@luvio/engine';
1
+ import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildOnlyIfCachedImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildOnlyIfCachedImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildStaleWhileRevalidateImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildStaleWhileRevalidateImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -14,6 +14,6 @@ declare const keys: {
14
14
  <T_1 extends Function>(f: T_1): T_1;
15
15
  <T_2>(o: T_2): Readonly<T_2>;
16
16
  };
17
- declare const hasOwnProperty: (v: string | number | symbol) => boolean;
17
+ declare const hasOwnProperty: (v: PropertyKey) => boolean;
18
18
  declare const isArray: (arg: any) => arg is any[];
19
19
  export { create as ObjectCreate, keys as ObjectKeys, assign as ObjectAssign, freeze as ObjectFreeze, hasOwnProperty as ObjectPrototypeHasOwnProperty, isArray as ArrayIsArray, };
@@ -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
@@ -186,6 +186,8 @@
186
186
  error,
187
187
  state: 'Error',
188
188
  data: undefined,
189
+ // TODO[@W-10164067]: copy refresh data from the snapshot returned by buildInMemorySnapshot (if any)
190
+ // refresh: ...
189
191
  };
190
192
  }
191
193
  function buildOnlyIfCachedImplementation(funcs) {
@@ -927,13 +929,17 @@
927
929
  };
928
930
  const storeSetTTLOverride = function (namespace, representationName, ttl) {
929
931
  validateNotDisposed();
930
- durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl);
931
- environment.storeSetTTLOverride(namespace, representationName, ttl);
932
+ return Promise.all([
933
+ environment.storeSetTTLOverride(namespace, representationName, ttl),
934
+ durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl),
935
+ ]).then();
932
936
  };
933
937
  const storeSetDefaultTTLOverride = function (ttl) {
934
938
  validateNotDisposed();
935
- durableTTLStore.setDefaultDurableTTLOverrides(ttl);
936
- environment.storeSetDefaultTTLOverride(ttl);
939
+ return Promise.all([
940
+ environment.storeSetDefaultTTLOverride(ttl),
941
+ durableTTLStore.setDefaultDurableTTLOverrides(ttl),
942
+ ]).then();
937
943
  };
938
944
  const getDurableTTLOverrides = function () {
939
945
  validateNotDisposed();
@@ -993,7 +999,8 @@
993
999
  }
994
1000
  const applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
995
1001
  validateNotDisposed();
996
- const cachePolicyImpl = resolveCachePolicy(adapterRequestContext.cachePolicy);
1002
+ const { cachePolicy } = adapterRequestContext;
1003
+ const cachePolicyImpl = resolveCachePolicy(cachePolicy);
997
1004
  const resolvePendingSnapshot = (snapshot) => environment.resolvePendingSnapshot(snapshot);
998
1005
  const storeLookup = (sel, refresh, ttlStrategy) => environment.storeLookup(sel, environment.createSnapshot, refresh, ttlStrategy);
999
1006
  const applyCachePolicy = () => {
@@ -1003,6 +1010,7 @@
1003
1010
  buildSnapshotContext,
1004
1011
  resolvePendingSnapshot,
1005
1012
  storeLookup,
1013
+ coercedAdapterRequestContext: engine.coerceAdapterRequestContext(adapterRequestContext),
1006
1014
  });
1007
1015
  };
1008
1016
  return isRevivingTTLOverrides !== undefined
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildCacheAndNetworkImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds?: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildCacheAndNetworkImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds?: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildCacheThenNetworkImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildCacheThenNetworkImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildNoCacheImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildNoCacheImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
- import { CachePolicyImplementationArgs, ErrorSnapshot, Snapshot } from '@luvio/engine';
1
+ import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildOnlyIfCachedImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildOnlyIfCachedImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildStaleWhileRevalidateImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildStaleWhileRevalidateImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -14,6 +14,6 @@ declare const keys: {
14
14
  <T_1 extends Function>(f: T_1): T_1;
15
15
  <T_2>(o: T_2): Readonly<T_2>;
16
16
  };
17
- declare const hasOwnProperty: (v: string | number | symbol) => boolean;
17
+ declare const hasOwnProperty: (v: PropertyKey) => boolean;
18
18
  declare const isArray: (arg: any) => arg is any[];
19
19
  export { create as ObjectCreate, keys as ObjectKeys, assign as ObjectAssign, freeze as ObjectFreeze, hasOwnProperty as ObjectPrototypeHasOwnProperty, isArray as ArrayIsArray, };
@@ -19,18 +19,18 @@
19
19
  var DefaultDurableSegment = 'DEFAULT';
20
20
 
21
21
  /*! *****************************************************************************
22
- Copyright (c) Microsoft Corporation. All rights reserved.
23
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
24
- this file except in compliance with the License. You may obtain a copy of the
25
- License at http://www.apache.org/licenses/LICENSE-2.0
22
+ Copyright (c) Microsoft Corporation.
26
23
 
27
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
28
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
29
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
30
- MERCHANTABLITY OR NON-INFRINGEMENT.
24
+ Permission to use, copy, modify, and/or distribute this software for any
25
+ purpose with or without fee is hereby granted.
31
26
 
32
- See the Apache Version 2.0 License for specific language governing permissions
33
- and limitations under the License.
27
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
28
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
29
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
30
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
31
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
32
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33
+ PERFORMANCE OF THIS SOFTWARE.
34
34
  ***************************************************************************** */
35
35
 
36
36
  var __assign = function() {
@@ -44,12 +44,14 @@
44
44
  return __assign.apply(this, arguments);
45
45
  };
46
46
 
47
- function __spreadArrays() {
48
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
49
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
50
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
51
- r[k] = a[j];
52
- return r;
47
+ function __spreadArray(to, from, pack) {
48
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
49
+ if (ar || !(i in from)) {
50
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
51
+ ar[i] = from[i];
52
+ }
53
+ }
54
+ return to.concat(ar || Array.prototype.slice.call(from));
53
55
  }
54
56
 
55
57
  var keys = Object.keys, create = Object.create, assign = Object.assign, freeze = Object.freeze;
@@ -61,8 +63,8 @@
61
63
  };
62
64
  }
63
65
  function buildNetworkSnapshot(args) {
64
- var buildNetworkSnapshot = args.buildNetworkSnapshot, buildSnapshotContext = args.buildSnapshotContext;
65
- 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) {
66
68
  return snapshot.state === 'Pending' ? args.resolvePendingSnapshot(snapshot) : snapshot;
67
69
  });
68
70
  }
@@ -89,7 +91,7 @@
89
91
  function buildCacheAndNetworkImplementation(funcs, staleDurationSeconds) {
90
92
  return function (args) {
91
93
  funcs.validateNotDisposed();
92
- 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;
93
95
  var staleDurationMilliseconds = staleDurationSeconds === undefined ? undefined : staleDurationSeconds * 1000;
94
96
  var cachePolicyStoreLookup = appendTTLStrategy(storeLookup, buildTTLStrategy(staleDurationMilliseconds));
95
97
  var snapshot = buildInMemorySnapshot(buildSnapshotContext, cachePolicyStoreLookup);
@@ -97,14 +99,14 @@
97
99
  // data found in L1 cache
98
100
  if (snapshot.state === 'Fulfilled' || snapshot.state === 'Error') {
99
101
  // kick off network request, do not await it
100
- buildNetworkSnapshot$1(buildSnapshotContext);
102
+ buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
101
103
  // return the cached snapshot to caller
102
104
  return snapshot;
103
105
  }
104
106
  // network request outstanding
105
107
  if (snapshot.state === 'Pending') {
106
108
  // kick off another network request, do not await it
107
- buildNetworkSnapshot$1(buildSnapshotContext);
109
+ buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
108
110
  return args.resolvePendingSnapshot(snapshot);
109
111
  }
110
112
  // stale data found in L1 cache
@@ -124,13 +126,13 @@
124
126
  if (revivedSnapshot.state === 'Fulfilled' ||
125
127
  revivedSnapshot.state === 'Error') {
126
128
  // kick off network request, do not await it
127
- buildNetworkSnapshot$1(buildSnapshotContext);
129
+ buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
128
130
  // return the L2 cached snapshot to caller
129
131
  return revivedSnapshot;
130
132
  }
131
133
  if (revivedSnapshot.state === 'Pending') {
132
134
  // kick off network request, do not await it
133
- buildNetworkSnapshot$1(buildSnapshotContext);
135
+ buildNetworkSnapshot$1(buildSnapshotContext, coercedAdapterRequestContext);
134
136
  return args.resolvePendingSnapshot(revivedSnapshot);
135
137
  }
136
138
  // stale data found in L2 cache
@@ -225,6 +227,8 @@
225
227
  error: error,
226
228
  state: 'Error',
227
229
  data: undefined,
230
+ // TODO[@W-10164067]: copy refresh data from the snapshot returned by buildInMemorySnapshot (if any)
231
+ // refresh: ...
228
232
  };
229
233
  }
230
234
  function buildOnlyIfCachedImplementation(funcs) {
@@ -366,16 +370,16 @@
366
370
  for (var i = 0, len = selections.length; i < len; i++) {
367
371
  var selection = selections[i];
368
372
  if (selection.kind === 'Object') {
369
- nestedSelections = __spreadArrays(nestedSelections, getSelections(selection.selections));
373
+ nestedSelections = __spreadArray(__spreadArray([], nestedSelections, true), getSelections(selection.selections), true);
370
374
  }
371
375
  else if (selection.kind === 'Link') {
372
- nestedSelections = __spreadArrays(nestedSelections, getSelectionsFromFragment(selection.fragment));
376
+ nestedSelections = __spreadArray(__spreadArray([], nestedSelections, true), getSelectionsFromFragment(selection.fragment), true);
373
377
  }
374
378
  else {
375
379
  nonNestedSelections.push(selection);
376
380
  }
377
381
  }
378
- return __spreadArrays(nestedSelections, nonNestedSelections);
382
+ return __spreadArray(__spreadArray([], nestedSelections, true), nonNestedSelections, true);
379
383
  }
380
384
  function getSelectionsFromFragment(fragment) {
381
385
  var selections = [];
@@ -385,7 +389,7 @@
385
389
  var unionKeys = keys(unionSelections);
386
390
  for (var i = 0, len = unionKeys.length; i < len; i++) {
387
391
  var key = unionKeys[i];
388
- selections = __spreadArrays(selections, unionSelections[key].selections);
392
+ selections = __spreadArray(__spreadArray([], selections, true), unionSelections[key].selections, true);
389
393
  }
390
394
  }
391
395
  // if fragment has selections properties then get them
@@ -566,7 +570,7 @@
566
570
  var TTL_DURABLE_SEGMENT = 'TTL_DURABLE_SEGMENT';
567
571
  var TTL_DEFAULT_KEY = 'TTL_DEFAULT_KEY';
568
572
  function buildDurableTTLOverrideStoreKey(namespace, representationName) {
569
- return namespace + "::" + representationName;
573
+ return "".concat(namespace, "::").concat(representationName);
570
574
  }
571
575
  function isEntryDurableTTLOverride(entry) {
572
576
  if (typeof entry === 'object' && entry !== undefined && entry !== null) {
@@ -649,7 +653,7 @@
649
653
  }
650
654
  if (isArray(source)) {
651
655
  // TS doesn't trust that this new array is an array unless we cast it
652
- return __spreadArrays(source);
656
+ return __spreadArray([], source, true);
653
657
  }
654
658
  return __assign({}, source);
655
659
  }
@@ -947,7 +951,7 @@
947
951
  validateNotDisposed();
948
952
  var contextId = options.contextId, onContextLoaded = options.onContextLoaded;
949
953
  var context = undefined;
950
- var contextAsPromise = reviveOrCreateContext(contextId === undefined ? adapter.name : "" + contextId + ADAPTER_CONTEXT_ID_SUFFIX, durableStore, durableStoreErrorHandler, onContextLoaded);
954
+ var contextAsPromise = reviveOrCreateContext(contextId === undefined ? adapter.name : "".concat(contextId).concat(ADAPTER_CONTEXT_ID_SUFFIX), durableStore, durableStoreErrorHandler, onContextLoaded);
951
955
  return function (config, requestContext) {
952
956
  if (context === undefined) {
953
957
  return contextAsPromise.then(function (revivedContext) {
@@ -968,13 +972,17 @@
968
972
  };
969
973
  var storeSetTTLOverride = function (namespace, representationName, ttl) {
970
974
  validateNotDisposed();
971
- durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl);
972
- environment.storeSetTTLOverride(namespace, representationName, ttl);
975
+ return Promise.all([
976
+ environment.storeSetTTLOverride(namespace, representationName, ttl),
977
+ durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl),
978
+ ]).then();
973
979
  };
974
980
  var storeSetDefaultTTLOverride = function (ttl) {
975
981
  validateNotDisposed();
976
- durableTTLStore.setDefaultDurableTTLOverrides(ttl);
977
- environment.storeSetDefaultTTLOverride(ttl);
982
+ return Promise.all([
983
+ environment.storeSetDefaultTTLOverride(ttl),
984
+ durableTTLStore.setDefaultDurableTTLOverrides(ttl),
985
+ ]).then();
978
986
  };
979
987
  var getDurableTTLOverrides = function () {
980
988
  validateNotDisposed();
@@ -1028,7 +1036,7 @@
1028
1036
  }
1029
1037
  default: {
1030
1038
  if (process.env.NODE_ENV !== 'production') {
1031
- throw new Error("unrecognized cache policy: " + JSON.stringify(cachePolicy));
1039
+ throw new Error("unrecognized cache policy: ".concat(JSON.stringify(cachePolicy)));
1032
1040
  }
1033
1041
  return defaultCachePolicy;
1034
1042
  }
@@ -1036,7 +1044,8 @@
1036
1044
  }
1037
1045
  var applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
1038
1046
  validateNotDisposed();
1039
- var cachePolicyImpl = resolveCachePolicy(adapterRequestContext.cachePolicy);
1047
+ var cachePolicy = adapterRequestContext.cachePolicy;
1048
+ var cachePolicyImpl = resolveCachePolicy(cachePolicy);
1040
1049
  var resolvePendingSnapshot = function (snapshot) {
1041
1050
  return environment.resolvePendingSnapshot(snapshot);
1042
1051
  };
@@ -1048,6 +1057,7 @@
1048
1057
  buildSnapshotContext: buildSnapshotContext,
1049
1058
  resolvePendingSnapshot: resolvePendingSnapshot,
1050
1059
  storeLookup: storeLookup,
1060
+ coercedAdapterRequestContext: engine.coerceAdapterRequestContext(adapterRequestContext),
1051
1061
  });
1052
1062
  };
1053
1063
  return isRevivingTTLOverrides !== undefined
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildCacheAndNetworkImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds?: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildCacheAndNetworkImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds?: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildCacheThenNetworkImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildCacheThenNetworkImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildNoCacheImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildNoCacheImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
- import { CachePolicyImplementationArgs, ErrorSnapshot, Snapshot } from '@luvio/engine';
1
+ import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildOnlyIfCachedImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildOnlyIfCachedImplementation(funcs: DurableCachePolicyFunctions): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -1,3 +1,3 @@
1
1
  import { CachePolicyImplementationArgs, Snapshot } from '@luvio/engine';
2
2
  import { DurableCachePolicyFunctions } from './utils';
3
- export declare function buildStaleWhileRevalidateImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => import("@luvio/engine").ErrorSnapshot | import("@luvio/engine").FulfilledSnapshot<D, unknown> | import("@luvio/engine").UnfulfilledSnapshot<D, unknown> | import("@luvio/engine").StaleSnapshot<D, unknown> | import("@luvio/engine").PendingSnapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
3
+ export declare function buildStaleWhileRevalidateImplementation(funcs: DurableCachePolicyFunctions, staleDurationSeconds: number): <C, D>(args: CachePolicyImplementationArgs<C, D>) => Snapshot<D, unknown> | Promise<Snapshot<D, unknown>>;
@@ -14,6 +14,6 @@ declare const keys: {
14
14
  <T_1 extends Function>(f: T_1): T_1;
15
15
  <T_2>(o: T_2): Readonly<T_2>;
16
16
  };
17
- declare const hasOwnProperty: (v: string | number | symbol) => boolean;
17
+ declare const hasOwnProperty: (v: PropertyKey) => boolean;
18
18
  declare const isArray: (arg: any) => arg is any[];
19
19
  export { create as ObjectCreate, keys as ObjectKeys, assign as ObjectAssign, freeze as ObjectFreeze, hasOwnProperty as ObjectPrototypeHasOwnProperty, isArray as ArrayIsArray, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luvio/environments",
3
- "version": "0.63.1",
3
+ "version": "0.65.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.63.1"
20
+ "@luvio/engine": "0.65.0"
21
21
  }
22
22
  }