@luvio/environments 0.63.2 → 0.66.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
@@ -925,13 +925,17 @@ function makeDurable(environment, { durableStore, instrumentation }) {
925
925
  };
926
926
  const storeSetTTLOverride = function (namespace, representationName, ttl) {
927
927
  validateNotDisposed();
928
- durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl);
929
- environment.storeSetTTLOverride(namespace, representationName, ttl);
928
+ return Promise.all([
929
+ environment.storeSetTTLOverride(namespace, representationName, ttl),
930
+ durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl),
931
+ ]).then();
930
932
  };
931
933
  const storeSetDefaultTTLOverride = function (ttl) {
932
934
  validateNotDisposed();
933
- durableTTLStore.setDefaultDurableTTLOverrides(ttl);
934
- environment.storeSetDefaultTTLOverride(ttl);
935
+ return Promise.all([
936
+ environment.storeSetDefaultTTLOverride(ttl),
937
+ durableTTLStore.setDefaultDurableTTLOverrides(ttl),
938
+ ]).then();
935
939
  };
936
940
  const getDurableTTLOverrides = function () {
937
941
  validateNotDisposed();
@@ -991,7 +995,8 @@ function makeDurable(environment, { durableStore, instrumentation }) {
991
995
  }
992
996
  const applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
993
997
  validateNotDisposed();
994
- const cachePolicyImpl = resolveCachePolicy(adapterRequestContext.cachePolicy);
998
+ const { cachePolicy } = adapterRequestContext;
999
+ const cachePolicyImpl = resolveCachePolicy(cachePolicy);
995
1000
  const resolvePendingSnapshot = (snapshot) => environment.resolvePendingSnapshot(snapshot);
996
1001
  const storeLookup = (sel, refresh, ttlStrategy) => environment.storeLookup(sel, environment.createSnapshot, refresh, ttlStrategy);
997
1002
  const applyCachePolicy = () => {
@@ -1001,6 +1006,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
1001
1006
  buildSnapshotContext,
1002
1007
  resolvePendingSnapshot,
1003
1008
  storeLookup,
1009
+ coercedAdapterRequestContext: coerceAdapterRequestContext(adapterRequestContext),
1004
1010
  });
1005
1011
  };
1006
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
@@ -929,13 +929,17 @@
929
929
  };
930
930
  const storeSetTTLOverride = function (namespace, representationName, ttl) {
931
931
  validateNotDisposed();
932
- durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl);
933
- environment.storeSetTTLOverride(namespace, representationName, ttl);
932
+ return Promise.all([
933
+ environment.storeSetTTLOverride(namespace, representationName, ttl),
934
+ durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl),
935
+ ]).then();
934
936
  };
935
937
  const storeSetDefaultTTLOverride = function (ttl) {
936
938
  validateNotDisposed();
937
- durableTTLStore.setDefaultDurableTTLOverrides(ttl);
938
- environment.storeSetDefaultTTLOverride(ttl);
939
+ return Promise.all([
940
+ environment.storeSetDefaultTTLOverride(ttl),
941
+ durableTTLStore.setDefaultDurableTTLOverrides(ttl),
942
+ ]).then();
939
943
  };
940
944
  const getDurableTTLOverrides = function () {
941
945
  validateNotDisposed();
@@ -995,7 +999,8 @@
995
999
  }
996
1000
  const applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
997
1001
  validateNotDisposed();
998
- const cachePolicyImpl = resolveCachePolicy(adapterRequestContext.cachePolicy);
1002
+ const { cachePolicy } = adapterRequestContext;
1003
+ const cachePolicyImpl = resolveCachePolicy(cachePolicy);
999
1004
  const resolvePendingSnapshot = (snapshot) => environment.resolvePendingSnapshot(snapshot);
1000
1005
  const storeLookup = (sel, refresh, ttlStrategy) => environment.storeLookup(sel, environment.createSnapshot, refresh, ttlStrategy);
1001
1006
  const applyCachePolicy = () => {
@@ -1005,6 +1010,7 @@
1005
1010
  buildSnapshotContext,
1006
1011
  resolvePendingSnapshot,
1007
1012
  storeLookup,
1013
+ coercedAdapterRequestContext: engine.coerceAdapterRequestContext(adapterRequestContext),
1008
1014
  });
1009
1015
  };
1010
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
@@ -972,13 +972,17 @@
972
972
  };
973
973
  var storeSetTTLOverride = function (namespace, representationName, ttl) {
974
974
  validateNotDisposed();
975
- durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl);
976
- environment.storeSetTTLOverride(namespace, representationName, ttl);
975
+ return Promise.all([
976
+ environment.storeSetTTLOverride(namespace, representationName, ttl),
977
+ durableTTLStore.setDurableTTLOverride(namespace, representationName, ttl),
978
+ ]).then();
977
979
  };
978
980
  var storeSetDefaultTTLOverride = function (ttl) {
979
981
  validateNotDisposed();
980
- durableTTLStore.setDefaultDurableTTLOverrides(ttl);
981
- environment.storeSetDefaultTTLOverride(ttl);
982
+ return Promise.all([
983
+ environment.storeSetDefaultTTLOverride(ttl),
984
+ durableTTLStore.setDefaultDurableTTLOverrides(ttl),
985
+ ]).then();
982
986
  };
983
987
  var getDurableTTLOverrides = function () {
984
988
  validateNotDisposed();
@@ -1040,7 +1044,8 @@
1040
1044
  }
1041
1045
  var applyCachePolicy = function (adapterRequestContext, buildSnapshotContext, buildInMemorySnapshot, buildNetworkSnapshot) {
1042
1046
  validateNotDisposed();
1043
- var cachePolicyImpl = resolveCachePolicy(adapterRequestContext.cachePolicy);
1047
+ var cachePolicy = adapterRequestContext.cachePolicy;
1048
+ var cachePolicyImpl = resolveCachePolicy(cachePolicy);
1044
1049
  var resolvePendingSnapshot = function (snapshot) {
1045
1050
  return environment.resolvePendingSnapshot(snapshot);
1046
1051
  };
@@ -1052,6 +1057,7 @@
1052
1057
  buildSnapshotContext: buildSnapshotContext,
1053
1058
  resolvePendingSnapshot: resolvePendingSnapshot,
1054
1059
  storeLookup: storeLookup,
1060
+ coercedAdapterRequestContext: engine.coerceAdapterRequestContext(adapterRequestContext),
1055
1061
  });
1056
1062
  };
1057
1063
  return isRevivingTTLOverrides !== undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luvio/environments",
3
- "version": "0.63.2",
3
+ "version": "0.66.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.2"
20
+ "@luvio/engine": "0.66.0"
21
21
  }
22
22
  }