@lwrjs/everywhere 0.9.0-alpha.5 → 0.9.0-alpha.6
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/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/b1134e720c2be0e52b81360343481cdf/config.js +10 -0
- package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/default-luvio/configuration/ci/-/luvio-/s/63ca089b220deddd8ef9cca972aa829f/config.js +10 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@luvio/engine/v/0_47_5/s/36bfa830117d5ec91c746f01125fb4d5/@luvio_engine.js +1766 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_9_0-alpha_6/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +14 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/default-luvio/module/amd/v/0_9_0-alpha_6/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_default-luvio_module_amd.js +14 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@salesforce/lds-default-luvio/v/0_9_0-alpha_6/s/5ae21f28a13422477cb94ec98bd2a9d5/@salesforce_lds-default-luvio.js +45 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_9_0-alpha_5 → 0_9_0-alpha_6}/s/c538071acf5bde58e816967a14c465c3/lwr_everywhereAmd.js +3 -3
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/{0_9_0-alpha_5 → 0_9_0-alpha_6}/s/6258bcb20cc2d5d6a9f3c5a6f9d0acaf/lwr_init.js +3 -3
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_9_0-alpha_5/s/4fce68570b6491fdd6652420aaffcdfa → 0_9_0-alpha_6/s/0c527183a8d89ff166673c84bee3ca00}/lwr_loader.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_9_0-alpha_5 → 0_9_0-alpha_6}/s/dfbc827104d50ff7d16b59c9d0e06aca/lwr_metrics.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_9_0-alpha_5 → 0_9_0-alpha_6}/s/5a10236d8c52bc9f6dee22875cd7016d/lwr_profiler.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/setupLDS/v/0_9_0-alpha_6/s/cf7cf380b862ab903eea6919430f7464/lwr_setupLDS.js +11 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/setupLDS#network/v/0_9_0-alpha_6/s/d23ea215cb26790477d0de4bc67da67e/lwr_setupLDS_network.js +106 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_9_0-alpha_5 → 0_9_0-alpha_6}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_9_0-alpha_5 → 0_9_0-alpha_6} +1 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.js/v/{0_9_0-alpha_5 → 0_9_0-alpha_6} +5 -5
- package/build/__generated_site_amd_modules__/en-US/index.html +6 -6
- package/build/__generated_site_amd_modules__/en-US/luvio/index.html +26 -0
- package/build/__generated_site_amd_modules__/index.html +6 -6
- package/build/__generated_site_amd_modules__/luvio/index.html +26 -0
- package/build/assets/amd/lwr-everywhere-debug.js +50 -8
- package/build/assets/amd/lwr-everywhere-min.js +1 -1
- package/build/assets/amd/lwr-everywhere.js +50 -8
- package/build/assets/core/lwr-everywhere-debug.js +46 -4
- package/build/assets/core/lwr-everywhere-min.js +1 -1
- package/build/assets/core/lwr-everywhere.js +46 -4
- package/build/assets/esm/lwr-everywhere-debug.js +1 -1
- package/build/assets/esm/lwr-everywhere-min.js +1 -1
- package/build/assets/esm/lwr-everywhere.js +1 -1
- package/build/generate.js +11 -7
- package/package.json +5 -5
- package/src/generate.ts +11 -7
- package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/24d3f480c4f43e717a17fd587b8d1796/config.js +0 -10
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_9_0-alpha_5/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -14
|
@@ -0,0 +1,1766 @@
|
|
|
1
|
+
LWR.define("@luvio/engine/v/0_47_5", ["exports"], function(exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
var DEFAULT_TOKEN = "0";
|
|
4
|
+
var END_TOKEN = "__END__";
|
|
5
|
+
function pagination(pd, save) {
|
|
6
|
+
const pd_ = pd || {[DEFAULT_TOKEN]: 0};
|
|
7
|
+
return {
|
|
8
|
+
defaultToken: () => DEFAULT_TOKEN,
|
|
9
|
+
endOffset: () => pd_[END_TOKEN],
|
|
10
|
+
isPastEnd: (offset) => {
|
|
11
|
+
return END_TOKEN in pd_ && offset >= pd_[END_TOKEN];
|
|
12
|
+
},
|
|
13
|
+
limitToEnd: (offset) => {
|
|
14
|
+
return END_TOKEN in pd_ && offset >= pd_[END_TOKEN] ? pd_[END_TOKEN] : offset;
|
|
15
|
+
},
|
|
16
|
+
offsetFor: (token) => {
|
|
17
|
+
return pd_[token || DEFAULT_TOKEN];
|
|
18
|
+
},
|
|
19
|
+
save: () => {
|
|
20
|
+
if (!save)
|
|
21
|
+
;
|
|
22
|
+
else {
|
|
23
|
+
save(pd_);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
setEnd: (offset) => {
|
|
27
|
+
if (offset === void 0) {
|
|
28
|
+
delete pd_[END_TOKEN];
|
|
29
|
+
} else {
|
|
30
|
+
pd_[END_TOKEN] = offset;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
setToken: (token, offset) => {
|
|
34
|
+
if (offset === void 0) {
|
|
35
|
+
delete pd_[token];
|
|
36
|
+
} else {
|
|
37
|
+
pd_[token] = offset;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
tokenFor: (offset) => {
|
|
41
|
+
const tokens = Object.keys(pd_);
|
|
42
|
+
for (let i = 0; i < tokens.length; ++i) {
|
|
43
|
+
if (pd_[tokens[i]] === offset) {
|
|
44
|
+
return tokens[i];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
tokenForAtMost: (offset) => {
|
|
49
|
+
let result = [DEFAULT_TOKEN, 0];
|
|
50
|
+
const tokens = Object.keys(pd_);
|
|
51
|
+
for (let i = 0; i < tokens.length; ++i) {
|
|
52
|
+
let offsetI = pd_[tokens[i]];
|
|
53
|
+
if (offsetI <= offset && offsetI > result[1]) {
|
|
54
|
+
result = [tokens[i], offsetI];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function isUnionObjectSelection(sel) {
|
|
62
|
+
return sel.union === true && sel.kind === "Object";
|
|
63
|
+
}
|
|
64
|
+
function isReaderFragment(fragment) {
|
|
65
|
+
return fragment.reader === true;
|
|
66
|
+
}
|
|
67
|
+
function isFragmentUnionSelection(sel) {
|
|
68
|
+
return sel.union === true;
|
|
69
|
+
}
|
|
70
|
+
var {create, freeze, keys} = Object;
|
|
71
|
+
var {hasOwnProperty} = Object.prototype;
|
|
72
|
+
var {isArray} = Array;
|
|
73
|
+
var {push, indexOf, slice} = Array.prototype;
|
|
74
|
+
var {stringify} = JSON;
|
|
75
|
+
function deepFreeze(value) {
|
|
76
|
+
if (typeof value !== "object" || value === null) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (isArray(value)) {
|
|
80
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
81
|
+
deepFreeze(value[i]);
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
const keys$1 = keys(value);
|
|
85
|
+
for (let i = 0, len = keys$1.length; i < len; i += 1) {
|
|
86
|
+
deepFreeze(value[keys$1[i]]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
freeze(value);
|
|
90
|
+
}
|
|
91
|
+
var SnapshotState;
|
|
92
|
+
(function(SnapshotState2) {
|
|
93
|
+
SnapshotState2["Fulfilled"] = "Fulfilled";
|
|
94
|
+
SnapshotState2["Unfulfilled"] = "Unfulfilled";
|
|
95
|
+
SnapshotState2["Error"] = "Error";
|
|
96
|
+
SnapshotState2["Pending"] = "Pending";
|
|
97
|
+
SnapshotState2["Stale"] = "Stale";
|
|
98
|
+
})(SnapshotState || (SnapshotState = {}));
|
|
99
|
+
function isErrorSnapshot(snapshot) {
|
|
100
|
+
return snapshot.state === SnapshotState.Error;
|
|
101
|
+
}
|
|
102
|
+
function isFulfilledSnapshot(snapshot) {
|
|
103
|
+
return snapshot.state === SnapshotState.Fulfilled;
|
|
104
|
+
}
|
|
105
|
+
function isUnfulfilledSnapshot(snapshot) {
|
|
106
|
+
return snapshot.state === SnapshotState.Unfulfilled;
|
|
107
|
+
}
|
|
108
|
+
function isPendingSnapshot(snapshot) {
|
|
109
|
+
return snapshot.state === SnapshotState.Pending;
|
|
110
|
+
}
|
|
111
|
+
function createErrorSnapshot(error, refresh) {
|
|
112
|
+
deepFreeze(error);
|
|
113
|
+
const snap = {
|
|
114
|
+
error,
|
|
115
|
+
state: SnapshotState.Error,
|
|
116
|
+
data: void 0,
|
|
117
|
+
refresh
|
|
118
|
+
};
|
|
119
|
+
return snap;
|
|
120
|
+
}
|
|
121
|
+
function formatStorageKey(name, argValues) {
|
|
122
|
+
if (!argValues) {
|
|
123
|
+
return name;
|
|
124
|
+
}
|
|
125
|
+
var values = [];
|
|
126
|
+
for (var _argName in argValues) {
|
|
127
|
+
if (hasOwnProperty.call(argValues, _argName)) {
|
|
128
|
+
var value = argValues[_argName];
|
|
129
|
+
if (value !== null || value !== void 0) {
|
|
130
|
+
values.push(_argName + ":" + stringify(value));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return values.length === 0 ? name : name + "(".concat(values.join(","), ")");
|
|
135
|
+
}
|
|
136
|
+
function getArgumentValues(args, variables) {
|
|
137
|
+
const values = {};
|
|
138
|
+
args.forEach((arg) => {
|
|
139
|
+
if (arg.kind === "Variable") {
|
|
140
|
+
values[arg.name] = variables[arg.variableName];
|
|
141
|
+
} else {
|
|
142
|
+
values[arg.name] = arg.value;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return values;
|
|
146
|
+
}
|
|
147
|
+
function getStorageKey(field, variables) {
|
|
148
|
+
const {args, name} = field;
|
|
149
|
+
if (args && args.length !== 0) {
|
|
150
|
+
return formatStorageKey(name, getArgumentValues(args, variables));
|
|
151
|
+
}
|
|
152
|
+
return name;
|
|
153
|
+
}
|
|
154
|
+
function isDefined(value) {
|
|
155
|
+
return value !== void 0 && value !== null;
|
|
156
|
+
}
|
|
157
|
+
var StoreLinkStateValues;
|
|
158
|
+
(function(StoreLinkStateValues2) {
|
|
159
|
+
StoreLinkStateValues2[StoreLinkStateValues2["NotPresent"] = 0] = "NotPresent";
|
|
160
|
+
StoreLinkStateValues2[StoreLinkStateValues2["RefNotPresent"] = 1] = "RefNotPresent";
|
|
161
|
+
StoreLinkStateValues2[StoreLinkStateValues2["RefPresent"] = 2] = "RefPresent";
|
|
162
|
+
StoreLinkStateValues2[StoreLinkStateValues2["Null"] = 3] = "Null";
|
|
163
|
+
StoreLinkStateValues2[StoreLinkStateValues2["Missing"] = 4] = "Missing";
|
|
164
|
+
StoreLinkStateValues2[StoreLinkStateValues2["Pending"] = 5] = "Pending";
|
|
165
|
+
})(StoreLinkStateValues || (StoreLinkStateValues = {}));
|
|
166
|
+
function getLinkState(link) {
|
|
167
|
+
if (link === void 0) {
|
|
168
|
+
return {
|
|
169
|
+
state: StoreLinkStateValues.NotPresent
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (link === null) {
|
|
173
|
+
return {
|
|
174
|
+
state: StoreLinkStateValues.Null
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const {__ref: key, pending, isMissing} = link;
|
|
178
|
+
if (pending === true) {
|
|
179
|
+
return {
|
|
180
|
+
state: StoreLinkStateValues.Pending
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (isMissing === true) {
|
|
184
|
+
return {
|
|
185
|
+
state: StoreLinkStateValues.Missing
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (key === void 0) {
|
|
189
|
+
return {
|
|
190
|
+
state: StoreLinkStateValues.RefNotPresent
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
state: StoreLinkStateValues.RefPresent,
|
|
195
|
+
key
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
var StoreResolveResultState;
|
|
199
|
+
(function(StoreResolveResultState2) {
|
|
200
|
+
StoreResolveResultState2[StoreResolveResultState2["Found"] = 0] = "Found";
|
|
201
|
+
StoreResolveResultState2[StoreResolveResultState2["Error"] = 1] = "Error";
|
|
202
|
+
StoreResolveResultState2[StoreResolveResultState2["Locked"] = 2] = "Locked";
|
|
203
|
+
StoreResolveResultState2[StoreResolveResultState2["Null"] = 3] = "Null";
|
|
204
|
+
StoreResolveResultState2[StoreResolveResultState2["NotPresent"] = 4] = "NotPresent";
|
|
205
|
+
StoreResolveResultState2[StoreResolveResultState2["Stale"] = 5] = "Stale";
|
|
206
|
+
})(StoreResolveResultState || (StoreResolveResultState = {}));
|
|
207
|
+
function storeLookup(key, timestamp, records, redirects, expirationMap) {
|
|
208
|
+
let canonicalKey = key;
|
|
209
|
+
let value = records[canonicalKey];
|
|
210
|
+
const redirectKeys = [];
|
|
211
|
+
if (value === void 0) {
|
|
212
|
+
while (redirects[canonicalKey] !== void 0) {
|
|
213
|
+
push.call(redirectKeys, canonicalKey);
|
|
214
|
+
canonicalKey = redirects[canonicalKey];
|
|
215
|
+
}
|
|
216
|
+
value = records[canonicalKey];
|
|
217
|
+
if (value === void 0) {
|
|
218
|
+
return {
|
|
219
|
+
state: StoreResolveResultState.NotPresent,
|
|
220
|
+
redirects: redirectKeys,
|
|
221
|
+
resolvedKey: canonicalKey
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const ttl = expirationMap[canonicalKey];
|
|
226
|
+
const valueIsError = value !== null && isStoreRecordError(value);
|
|
227
|
+
const valueIsLocked = value !== null && isStoreRecordLocked(value);
|
|
228
|
+
if (valueIsLocked === true) {
|
|
229
|
+
return {
|
|
230
|
+
state: StoreResolveResultState.Locked,
|
|
231
|
+
redirects: redirectKeys,
|
|
232
|
+
resolvedKey: canonicalKey
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
if (ttl !== void 0) {
|
|
236
|
+
const {fresh, stale} = ttl;
|
|
237
|
+
if (timestamp > fresh) {
|
|
238
|
+
if (timestamp <= stale && valueIsError !== true) {
|
|
239
|
+
return {
|
|
240
|
+
state: StoreResolveResultState.Stale,
|
|
241
|
+
value,
|
|
242
|
+
redirects: redirectKeys,
|
|
243
|
+
resolvedKey: canonicalKey
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
state: StoreResolveResultState.NotPresent,
|
|
248
|
+
redirects: redirectKeys,
|
|
249
|
+
resolvedKey: canonicalKey
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (valueIsError === true) {
|
|
254
|
+
return {
|
|
255
|
+
state: StoreResolveResultState.Error,
|
|
256
|
+
value: value.error,
|
|
257
|
+
redirects: redirectKeys,
|
|
258
|
+
resolvedKey: canonicalKey
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
state: StoreResolveResultState.Found,
|
|
263
|
+
value,
|
|
264
|
+
redirects: redirectKeys,
|
|
265
|
+
resolvedKey: canonicalKey
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
var READER_PATH_ROOT = "ROOT";
|
|
269
|
+
var EMPTY_STRING = "";
|
|
270
|
+
var FragmentReadResultState;
|
|
271
|
+
(function(FragmentReadResultState2) {
|
|
272
|
+
FragmentReadResultState2[FragmentReadResultState2["Missing"] = 0] = "Missing";
|
|
273
|
+
FragmentReadResultState2[FragmentReadResultState2["Success"] = 1] = "Success";
|
|
274
|
+
FragmentReadResultState2[FragmentReadResultState2["Error"] = 2] = "Error";
|
|
275
|
+
FragmentReadResultState2[FragmentReadResultState2["Locked"] = 3] = "Locked";
|
|
276
|
+
})(FragmentReadResultState || (FragmentReadResultState = {}));
|
|
277
|
+
var FRAGMENT_READ_RESULT_MISSING = {
|
|
278
|
+
state: FragmentReadResultState.Missing
|
|
279
|
+
};
|
|
280
|
+
var Reader = class {
|
|
281
|
+
constructor(records, expirationMap, redirects, variables, refresh, baseSnapshot) {
|
|
282
|
+
this.missingPaths = {};
|
|
283
|
+
this.missingLinks = {};
|
|
284
|
+
this.hasPendingData = false;
|
|
285
|
+
this.hasLockedData = false;
|
|
286
|
+
this.getLinkState = getLinkState;
|
|
287
|
+
this.StoreLinkStateValues = StoreLinkStateValues;
|
|
288
|
+
this.StoreResolveResultState = StoreResolveResultState;
|
|
289
|
+
this.variables = variables;
|
|
290
|
+
this.records = records;
|
|
291
|
+
this.seenIds = {};
|
|
292
|
+
this.isMissingData = false;
|
|
293
|
+
this.hasStaleData = false;
|
|
294
|
+
this.refresh = refresh;
|
|
295
|
+
let snapshotChanged = true;
|
|
296
|
+
let baseSnapshotValue = void 0;
|
|
297
|
+
if (baseSnapshot !== void 0 && (baseSnapshot.state === SnapshotState.Fulfilled || baseSnapshot.state === SnapshotState.Stale)) {
|
|
298
|
+
baseSnapshotValue = baseSnapshot.data;
|
|
299
|
+
snapshotChanged = false;
|
|
300
|
+
}
|
|
301
|
+
this.snapshotChanged = snapshotChanged;
|
|
302
|
+
this.currentPath = {
|
|
303
|
+
fullPath: EMPTY_STRING,
|
|
304
|
+
key: READER_PATH_ROOT,
|
|
305
|
+
parent: null,
|
|
306
|
+
baseSnapshotValue
|
|
307
|
+
};
|
|
308
|
+
this.baseSnapshot = baseSnapshot;
|
|
309
|
+
this.expirationMap = expirationMap;
|
|
310
|
+
this.redirects = redirects;
|
|
311
|
+
this.timestamp = Date.now();
|
|
312
|
+
}
|
|
313
|
+
pagination(key) {
|
|
314
|
+
const lookup = this.resolveKey(key);
|
|
315
|
+
return pagination(lookup.value);
|
|
316
|
+
}
|
|
317
|
+
readFragmentUnion(result, selection) {
|
|
318
|
+
const {value: record} = result;
|
|
319
|
+
const {discriminator} = selection;
|
|
320
|
+
const discriminatorValue = record[discriminator];
|
|
321
|
+
return this.readFragment(result, selection.unionSelections[discriminatorValue]);
|
|
322
|
+
}
|
|
323
|
+
read(selector) {
|
|
324
|
+
const {node: selectorNode} = selector;
|
|
325
|
+
const {recordId: key} = selector;
|
|
326
|
+
const result = this.storeLookup(key);
|
|
327
|
+
const fragmentResult = this.readFragment(result, selectorNode);
|
|
328
|
+
switch (fragmentResult.state) {
|
|
329
|
+
case FragmentReadResultState.Missing:
|
|
330
|
+
if (this.isMissingData === false) {
|
|
331
|
+
this.isMissingData = true;
|
|
332
|
+
this.snapshotChanged = true;
|
|
333
|
+
}
|
|
334
|
+
return this.createSnapshot(void 0, selector);
|
|
335
|
+
case FragmentReadResultState.Locked:
|
|
336
|
+
if (this.hasLockedData === false) {
|
|
337
|
+
this.hasLockedData = true;
|
|
338
|
+
this.snapshotChanged = true;
|
|
339
|
+
}
|
|
340
|
+
return this.createSnapshot(void 0, selector);
|
|
341
|
+
case FragmentReadResultState.Error:
|
|
342
|
+
return this.createErrorSnapshot(fragmentResult.value);
|
|
343
|
+
default:
|
|
344
|
+
return this.createSnapshot(fragmentResult.value, selector);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
getSnapshotState() {
|
|
348
|
+
if (this.isMissingData === true) {
|
|
349
|
+
return SnapshotState.Unfulfilled;
|
|
350
|
+
}
|
|
351
|
+
if (this.hasPendingData === true || this.hasLockedData === true) {
|
|
352
|
+
return SnapshotState.Pending;
|
|
353
|
+
}
|
|
354
|
+
if (this.hasStaleData === true) {
|
|
355
|
+
return SnapshotState.Stale;
|
|
356
|
+
}
|
|
357
|
+
return SnapshotState.Fulfilled;
|
|
358
|
+
}
|
|
359
|
+
createErrorSnapshot(data) {
|
|
360
|
+
return {
|
|
361
|
+
data: void 0,
|
|
362
|
+
error: data,
|
|
363
|
+
state: SnapshotState.Error,
|
|
364
|
+
refresh: this.refresh
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
createSnapshot(data, selector) {
|
|
368
|
+
if (this.snapshotChanged === false && selector.recordId === this.baseSnapshot.recordId) {
|
|
369
|
+
return this.baseSnapshot;
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
recordId: selector.recordId,
|
|
373
|
+
select: selector,
|
|
374
|
+
variables: this.variables,
|
|
375
|
+
seenRecords: this.seenIds,
|
|
376
|
+
data,
|
|
377
|
+
state: this.getSnapshotState(),
|
|
378
|
+
missingPaths: this.missingPaths,
|
|
379
|
+
missingLinks: this.missingLinks,
|
|
380
|
+
refresh: this.refresh
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
deepCopy(record, data, key, visitedKeys) {
|
|
384
|
+
const value = record[key];
|
|
385
|
+
this.enterPath(key);
|
|
386
|
+
if (isArray(value)) {
|
|
387
|
+
const items = [];
|
|
388
|
+
this.selectAll(value, items, visitedKeys);
|
|
389
|
+
data[key] = items;
|
|
390
|
+
} else if (typeof value === "object" && value !== null) {
|
|
391
|
+
if (value.__ref !== void 0) {
|
|
392
|
+
const nextRecordId = value.__ref;
|
|
393
|
+
if (isArray(nextRecordId)) {
|
|
394
|
+
const items = [];
|
|
395
|
+
this.selectAll(nextRecordId, items, visitedKeys);
|
|
396
|
+
data[key] = items;
|
|
397
|
+
} else {
|
|
398
|
+
if (hasOwnProperty.call(visitedKeys, nextRecordId) === true) {
|
|
399
|
+
throw new Error(`Invalid eager selection on records with circular references.`);
|
|
400
|
+
}
|
|
401
|
+
const lookupResult = this.resolveKey(nextRecordId);
|
|
402
|
+
switch (lookupResult.state) {
|
|
403
|
+
case StoreResolveResultState.NotPresent:
|
|
404
|
+
data[key] = void 0;
|
|
405
|
+
break;
|
|
406
|
+
case StoreResolveResultState.Found: {
|
|
407
|
+
const nested = {};
|
|
408
|
+
this.selectAll(lookupResult.value, nested, {
|
|
409
|
+
...visitedKeys,
|
|
410
|
+
[nextRecordId]: true
|
|
411
|
+
});
|
|
412
|
+
data[key] = nested;
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
const items = {};
|
|
419
|
+
this.selectAll(value, items, visitedKeys);
|
|
420
|
+
data[key] = items;
|
|
421
|
+
}
|
|
422
|
+
} else {
|
|
423
|
+
this.checkIfChanged(value);
|
|
424
|
+
data[key] = value;
|
|
425
|
+
}
|
|
426
|
+
this.exitPath();
|
|
427
|
+
}
|
|
428
|
+
selectAllArray(record, data, visitedKeys) {
|
|
429
|
+
const {length} = record;
|
|
430
|
+
for (let key = 0; key < length; key += 1) {
|
|
431
|
+
this.deepCopy(record, data, key, visitedKeys);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
selectAllObject(record, data, visitedKeys) {
|
|
435
|
+
const recordKeys = keys(record);
|
|
436
|
+
const {length} = recordKeys;
|
|
437
|
+
for (let i = 0; i < length; i += 1) {
|
|
438
|
+
const key = recordKeys[i];
|
|
439
|
+
this.deepCopy(record, data, key, visitedKeys);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
selectAll(record, data, visitedKeys = {}) {
|
|
443
|
+
const recordIsArray = isArray(record);
|
|
444
|
+
if (recordIsArray === true) {
|
|
445
|
+
this.selectAllArray(record, data, visitedKeys);
|
|
446
|
+
} else {
|
|
447
|
+
this.selectAllObject(record, data, visitedKeys);
|
|
448
|
+
}
|
|
449
|
+
freeze(data);
|
|
450
|
+
}
|
|
451
|
+
markPending() {
|
|
452
|
+
this.hasPendingData = true;
|
|
453
|
+
}
|
|
454
|
+
markStale() {
|
|
455
|
+
this.hasStaleData = true;
|
|
456
|
+
}
|
|
457
|
+
markMissing() {
|
|
458
|
+
this.isMissingData = true;
|
|
459
|
+
this.missingPaths[this.currentPath.fullPath] = true;
|
|
460
|
+
this.checkIfChanged(void 0);
|
|
461
|
+
}
|
|
462
|
+
markLocked() {
|
|
463
|
+
this.hasLockedData = true;
|
|
464
|
+
this.checkIfChanged(void 0);
|
|
465
|
+
}
|
|
466
|
+
markMissingLink(linkKey) {
|
|
467
|
+
this.missingLinks[linkKey] = true;
|
|
468
|
+
this.markMissing();
|
|
469
|
+
}
|
|
470
|
+
unMarkMissing() {
|
|
471
|
+
delete this.missingPaths[this.currentPath.fullPath];
|
|
472
|
+
if (keys(this.missingPaths).length === 0) {
|
|
473
|
+
this.isMissingData = false;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
assignNonScalar(sink, key, value) {
|
|
477
|
+
sink[key] = value;
|
|
478
|
+
freeze(value);
|
|
479
|
+
}
|
|
480
|
+
enterPath(key) {
|
|
481
|
+
const parent = this.currentPath;
|
|
482
|
+
const {key: parentKey, fullPath: parentFullPath, baseSnapshotValue: parentBaseSnapshotValue} = parent;
|
|
483
|
+
let baseSnapshotValue = void 0;
|
|
484
|
+
if (parentBaseSnapshotValue !== void 0 && parentBaseSnapshotValue !== null) {
|
|
485
|
+
baseSnapshotValue = parentBaseSnapshotValue[key];
|
|
486
|
+
}
|
|
487
|
+
this.currentPath = {
|
|
488
|
+
parent,
|
|
489
|
+
key,
|
|
490
|
+
fullPath: parentKey === READER_PATH_ROOT ? key : parentFullPath + "." + key,
|
|
491
|
+
baseSnapshotValue
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
exitPath() {
|
|
495
|
+
this.currentPath = this.currentPath.parent;
|
|
496
|
+
}
|
|
497
|
+
readSingleLink(propertyName, selection, source, sink, assignmentProperty) {
|
|
498
|
+
const {required, nullable, fragment} = selection;
|
|
499
|
+
const link = source[propertyName];
|
|
500
|
+
const property = assignmentProperty === void 0 ? propertyName : assignmentProperty;
|
|
501
|
+
const linkState = getLinkState(link);
|
|
502
|
+
switch (linkState.state) {
|
|
503
|
+
case StoreLinkStateValues.RefNotPresent:
|
|
504
|
+
case StoreLinkStateValues.NotPresent:
|
|
505
|
+
case StoreLinkStateValues.Missing:
|
|
506
|
+
if (isReaderFragment(fragment) && fragment.synthetic === true) {
|
|
507
|
+
return this.assignNonScalar(sink, property, fragment.read(this));
|
|
508
|
+
}
|
|
509
|
+
if (linkState.state === StoreLinkStateValues.Missing && required === false) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
this.markMissing();
|
|
513
|
+
return;
|
|
514
|
+
case StoreLinkStateValues.Null:
|
|
515
|
+
if (nullable === true) {
|
|
516
|
+
this.readScalar(propertyName, source, sink);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
throw new Error(`Invalid Link State. Link on "${this.currentPath.fullPath}" is null but selection is not nullable:
|
|
520
|
+
${stringify(selection, null, 2)}`);
|
|
521
|
+
case StoreLinkStateValues.Pending:
|
|
522
|
+
this.markPending();
|
|
523
|
+
return;
|
|
524
|
+
default:
|
|
525
|
+
this.readStoreLinkWithRef(linkState, fragment, sink, property, required);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
markRedirectsSeen(state) {
|
|
529
|
+
const {redirects} = state;
|
|
530
|
+
const {length: len} = redirects;
|
|
531
|
+
if (len === 0) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
for (let i = 0; i < len; i += 1) {
|
|
535
|
+
this.markSeenId(redirects[i]);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
resolveKey(key, options = {}) {
|
|
539
|
+
const lookup = this.storeLookup(key);
|
|
540
|
+
const {required} = options;
|
|
541
|
+
switch (lookup.state) {
|
|
542
|
+
case StoreResolveResultState.Stale:
|
|
543
|
+
this.markStale();
|
|
544
|
+
break;
|
|
545
|
+
case StoreResolveResultState.NotPresent:
|
|
546
|
+
if (required !== false) {
|
|
547
|
+
this.markMissingLink(key);
|
|
548
|
+
}
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
this.markRedirectsSeen(lookup);
|
|
552
|
+
this.markSeenId(lookup.resolvedKey);
|
|
553
|
+
return lookup;
|
|
554
|
+
}
|
|
555
|
+
readStoreLinkWithRef(linkState, fragment, sink, assignmentProperty, required) {
|
|
556
|
+
const fragmentResult = this.readFragment(this.resolveKey(linkState.key, {required}), fragment);
|
|
557
|
+
switch (fragmentResult.state) {
|
|
558
|
+
case FragmentReadResultState.Error:
|
|
559
|
+
this.markMissing();
|
|
560
|
+
return;
|
|
561
|
+
case FragmentReadResultState.Locked:
|
|
562
|
+
this.markLocked();
|
|
563
|
+
return;
|
|
564
|
+
case FragmentReadResultState.Success:
|
|
565
|
+
this.assignNonScalar(sink, assignmentProperty, fragmentResult.value);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
readObject(key, selection, source, sink) {
|
|
569
|
+
const sourceValue = source[key];
|
|
570
|
+
if (selection.nullable === true && sourceValue === null) {
|
|
571
|
+
this.readScalar(key, source, sink);
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (selection.opaque === true) {
|
|
575
|
+
this.readOpaque(sink, key, sourceValue, selection.required);
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
if (sourceValue === void 0) {
|
|
579
|
+
if (selection.required === false) {
|
|
580
|
+
this.checkIfChanged(sourceValue);
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
return this.markMissing();
|
|
584
|
+
}
|
|
585
|
+
const sinkValue = isArray(sourceValue) ? [] : {};
|
|
586
|
+
if (selection.selections === void 0) {
|
|
587
|
+
this.selectAll(sourceValue, sinkValue);
|
|
588
|
+
} else {
|
|
589
|
+
this.traverseSelections(selection, sourceValue, sinkValue);
|
|
590
|
+
}
|
|
591
|
+
this.assignNonScalar(sink, key, sinkValue);
|
|
592
|
+
}
|
|
593
|
+
checkIfArrayLengthChanged(value) {
|
|
594
|
+
if (this.snapshotChanged === true) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
const {baseSnapshotValue} = this.currentPath;
|
|
598
|
+
if (isDefined(baseSnapshotValue)) {
|
|
599
|
+
this.snapshotChanged = baseSnapshotValue.length !== value.length;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
checkIfObjectKeysLengthChanged(keys$1) {
|
|
603
|
+
if (this.snapshotChanged === true) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const {baseSnapshotValue} = this.currentPath;
|
|
607
|
+
if (isDefined(baseSnapshotValue)) {
|
|
608
|
+
this.snapshotChanged = keys$1.length !== keys(baseSnapshotValue).length;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
checkIfChanged(value) {
|
|
612
|
+
if (this.snapshotChanged === true) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
this.snapshotChanged = this.currentPath.baseSnapshotValue !== value;
|
|
616
|
+
}
|
|
617
|
+
computeCopyBounds(array, selection) {
|
|
618
|
+
if (selection.tokenDataKey !== void 0 && selection.pageSize !== void 0) {
|
|
619
|
+
const pagination2 = this.pagination(selection.tokenDataKey);
|
|
620
|
+
const startingOffset = pagination2.offsetFor(selection.pageToken);
|
|
621
|
+
if (startingOffset === void 0) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const endingOffset = pagination2.limitToEnd(startingOffset + selection.pageSize);
|
|
625
|
+
this.markSeenId(selection.tokenDataKey);
|
|
626
|
+
return [startingOffset, endingOffset];
|
|
627
|
+
} else {
|
|
628
|
+
return [0, array.length];
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
readPluralLink(propertyName, selection, record, data) {
|
|
632
|
+
if (selection.fragment === void 0) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
const array = record[propertyName];
|
|
636
|
+
const [start, end] = this.computeCopyBounds(array, selection) || [-1, -1];
|
|
637
|
+
if (start < 0) {
|
|
638
|
+
return this.markMissing();
|
|
639
|
+
}
|
|
640
|
+
const sink = data[propertyName] = [];
|
|
641
|
+
for (let i = start; i < end; i += 1) {
|
|
642
|
+
this.enterPath(i);
|
|
643
|
+
this.readSingleLink(i, selection, array, sink, i - start);
|
|
644
|
+
this.exitPath();
|
|
645
|
+
}
|
|
646
|
+
this.checkIfArrayLengthChanged(sink);
|
|
647
|
+
freeze(sink);
|
|
648
|
+
}
|
|
649
|
+
readObjectMap(propertyName, selection, record, data) {
|
|
650
|
+
const obj = record[propertyName];
|
|
651
|
+
if (obj === void 0) {
|
|
652
|
+
if (selection.required === false) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
return this.markMissing();
|
|
656
|
+
}
|
|
657
|
+
const sink = data[propertyName] = {};
|
|
658
|
+
const keys$1 = keys(obj);
|
|
659
|
+
this.checkIfObjectKeysLengthChanged(keys$1);
|
|
660
|
+
for (let i = 0, len = keys$1.length; i < len; i += 1) {
|
|
661
|
+
const key = keys$1[i];
|
|
662
|
+
this.enterPath(key);
|
|
663
|
+
this.readObject(key, selection, obj, sink);
|
|
664
|
+
this.exitPath();
|
|
665
|
+
}
|
|
666
|
+
freeze(sink);
|
|
667
|
+
}
|
|
668
|
+
readLinkMap(propertyName, selection, record, data) {
|
|
669
|
+
const map = record[propertyName];
|
|
670
|
+
const keys$1 = keys(map);
|
|
671
|
+
const sink = {};
|
|
672
|
+
this.checkIfObjectKeysLengthChanged(keys$1);
|
|
673
|
+
for (let i = 0, len = keys$1.length; i < len; i += 1) {
|
|
674
|
+
const key = keys$1[i];
|
|
675
|
+
this.enterPath(key);
|
|
676
|
+
this.readSingleLink(key, selection, map, sink);
|
|
677
|
+
this.exitPath();
|
|
678
|
+
}
|
|
679
|
+
this.assignNonScalar(data, propertyName, sink);
|
|
680
|
+
}
|
|
681
|
+
readSuccessResolveState(result, fragment) {
|
|
682
|
+
if (isReaderFragment(fragment)) {
|
|
683
|
+
const value = fragment.read(result.value, this);
|
|
684
|
+
freeze(value);
|
|
685
|
+
return {
|
|
686
|
+
state: FragmentReadResultState.Success,
|
|
687
|
+
value
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
if (fragment.opaque) {
|
|
691
|
+
this.checkIfChanged(result.value);
|
|
692
|
+
return {
|
|
693
|
+
state: FragmentReadResultState.Success,
|
|
694
|
+
value: result.value
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
if (isFragmentUnionSelection(fragment)) {
|
|
698
|
+
return this.readFragmentUnion(result, fragment);
|
|
699
|
+
}
|
|
700
|
+
const sink = {};
|
|
701
|
+
this.traverseSelections(fragment, result.value, sink);
|
|
702
|
+
freeze(sink);
|
|
703
|
+
return {
|
|
704
|
+
state: FragmentReadResultState.Success,
|
|
705
|
+
value: sink
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
readFragment(result, fragment) {
|
|
709
|
+
if (isReaderFragment(fragment) && fragment.synthetic === true) {
|
|
710
|
+
const value = fragment.read(this);
|
|
711
|
+
if (value.state === "Error") {
|
|
712
|
+
return {
|
|
713
|
+
state: FragmentReadResultState.Error,
|
|
714
|
+
value: value.value
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
freeze(value);
|
|
718
|
+
return {
|
|
719
|
+
state: FragmentReadResultState.Success,
|
|
720
|
+
value
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
switch (result.state) {
|
|
724
|
+
case StoreResolveResultState.NotPresent:
|
|
725
|
+
return FRAGMENT_READ_RESULT_MISSING;
|
|
726
|
+
case StoreResolveResultState.Error:
|
|
727
|
+
return {
|
|
728
|
+
state: FragmentReadResultState.Error,
|
|
729
|
+
value: result.value
|
|
730
|
+
};
|
|
731
|
+
case StoreResolveResultState.Locked:
|
|
732
|
+
return {
|
|
733
|
+
state: FragmentReadResultState.Locked
|
|
734
|
+
};
|
|
735
|
+
case StoreResolveResultState.Stale:
|
|
736
|
+
this.markStale();
|
|
737
|
+
return this.readSuccessResolveState(result, fragment);
|
|
738
|
+
case StoreResolveResultState.Found:
|
|
739
|
+
return this.readSuccessResolveState(result, fragment);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
readPluralObject(propertyName, selection, record, data) {
|
|
743
|
+
if (selection.selections === void 0) {
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
const array = record[propertyName];
|
|
747
|
+
const [start, end] = this.computeCopyBounds(array, selection) || [-1, -1];
|
|
748
|
+
if (start < 0) {
|
|
749
|
+
return this.markMissing();
|
|
750
|
+
}
|
|
751
|
+
const sink = data[propertyName] = [];
|
|
752
|
+
for (let i = start; i < end; i += 1) {
|
|
753
|
+
this.enterPath(i);
|
|
754
|
+
const nextRecord = array[i];
|
|
755
|
+
if (nextRecord === void 0) {
|
|
756
|
+
this.markMissing();
|
|
757
|
+
this.exitPath();
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
const obj = {};
|
|
761
|
+
this.traverseSelections(selection, nextRecord, obj);
|
|
762
|
+
push.call(sink, obj);
|
|
763
|
+
freeze(obj);
|
|
764
|
+
this.exitPath();
|
|
765
|
+
}
|
|
766
|
+
this.checkIfArrayLengthChanged(sink);
|
|
767
|
+
freeze(sink);
|
|
768
|
+
}
|
|
769
|
+
readOpaque(sink, propertyName, value, required) {
|
|
770
|
+
this.checkIfChanged(value);
|
|
771
|
+
if (value === void 0 && required === false) {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
sink[propertyName] = value;
|
|
775
|
+
}
|
|
776
|
+
readScalarMap(propertyName, record, data, required) {
|
|
777
|
+
const obj = record[propertyName];
|
|
778
|
+
if (obj === void 0) {
|
|
779
|
+
if (required !== false) {
|
|
780
|
+
this.markMissing();
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
this.checkIfChanged(void 0);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
const sink = data[propertyName] = {};
|
|
787
|
+
const keys$1 = keys(obj);
|
|
788
|
+
this.checkIfObjectKeysLengthChanged(keys$1);
|
|
789
|
+
for (let i = 0, len = keys$1.length; i < len; i += 1) {
|
|
790
|
+
const key = keys$1[i];
|
|
791
|
+
this.enterPath(key);
|
|
792
|
+
this.readScalar(key, obj, sink);
|
|
793
|
+
this.exitPath();
|
|
794
|
+
}
|
|
795
|
+
freeze(sink);
|
|
796
|
+
}
|
|
797
|
+
readScalarPlural(propertyName, record, data) {
|
|
798
|
+
const array = record[propertyName];
|
|
799
|
+
const sink = data[propertyName] = [];
|
|
800
|
+
if (this.snapshotChanged === true) {
|
|
801
|
+
push.apply(sink, array);
|
|
802
|
+
freeze(sink);
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
this.checkIfArrayLengthChanged(array);
|
|
806
|
+
if (this.snapshotChanged === true) {
|
|
807
|
+
push.apply(sink, array);
|
|
808
|
+
freeze(sink);
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
for (let i = 0, len = array.length; i < len; i += 1) {
|
|
812
|
+
this.enterPath(i);
|
|
813
|
+
const value = array[i];
|
|
814
|
+
push.call(sink, value);
|
|
815
|
+
this.checkIfChanged(value);
|
|
816
|
+
this.exitPath();
|
|
817
|
+
if (this.snapshotChanged === true) {
|
|
818
|
+
push.apply(sink, slice.call(array, i + 1));
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
freeze(sink);
|
|
823
|
+
}
|
|
824
|
+
readScalar(propertyName, record, data, required) {
|
|
825
|
+
if (!hasOwnProperty.call(record, propertyName)) {
|
|
826
|
+
if (required !== false) {
|
|
827
|
+
this.markMissing();
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
this.checkIfChanged(void 0);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
this.assignScalar(propertyName, data, record[propertyName]);
|
|
834
|
+
}
|
|
835
|
+
assignScalar(key, sink, value) {
|
|
836
|
+
sink[key] = value;
|
|
837
|
+
this.checkIfChanged(value);
|
|
838
|
+
}
|
|
839
|
+
storeLookup(key) {
|
|
840
|
+
return storeLookup(key, this.timestamp, this.records, this.redirects, this.expirationMap);
|
|
841
|
+
}
|
|
842
|
+
selectUnion(selection, storeEntry, discriminatedObject, sink) {
|
|
843
|
+
const {discriminator} = selection;
|
|
844
|
+
const discriminatorValue = discriminatedObject[discriminator];
|
|
845
|
+
const unionSelection = selection.unionSelections[discriminatorValue];
|
|
846
|
+
const childSelection = {
|
|
847
|
+
selections: unionSelection.selections,
|
|
848
|
+
private: unionSelection.private,
|
|
849
|
+
name: selection.name,
|
|
850
|
+
kind: selection.kind
|
|
851
|
+
};
|
|
852
|
+
this.traverseSelection(childSelection, storeEntry, sink);
|
|
853
|
+
}
|
|
854
|
+
selectObjectUnion(selection, source, sink) {
|
|
855
|
+
const {name: propertyName} = selection;
|
|
856
|
+
const object = source[propertyName];
|
|
857
|
+
if (object === void 0) {
|
|
858
|
+
this.markMissing();
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
if (selection.nullable === true && object === null) {
|
|
862
|
+
this.readScalar(propertyName, source, sink);
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
this.selectUnion(selection, source, object, sink);
|
|
866
|
+
}
|
|
867
|
+
traverseSelection(selection, record, data) {
|
|
868
|
+
const {variables} = this;
|
|
869
|
+
const key = getStorageKey(selection, variables);
|
|
870
|
+
if (isUnionObjectSelection(selection)) {
|
|
871
|
+
this.selectObjectUnion(selection, record, data);
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
if (selection.kind === "Link") {
|
|
875
|
+
if (selection.plural === true) {
|
|
876
|
+
this.readPluralLink(key, selection, record, data);
|
|
877
|
+
} else if (selection.map === true) {
|
|
878
|
+
this.readLinkMap(key, selection, record, data);
|
|
879
|
+
} else {
|
|
880
|
+
this.readSingleLink(key, selection, record, data);
|
|
881
|
+
}
|
|
882
|
+
} else if (selection.kind === "Scalar") {
|
|
883
|
+
if (selection.map === true) {
|
|
884
|
+
this.readScalarMap(key, record, data, selection.required !== false);
|
|
885
|
+
} else if (selection.plural === true) {
|
|
886
|
+
this.readScalarPlural(key, record, data);
|
|
887
|
+
} else {
|
|
888
|
+
this.readScalar(key, record, data, selection.required);
|
|
889
|
+
}
|
|
890
|
+
} else if (selection.kind === "Object") {
|
|
891
|
+
if (selection.map === true) {
|
|
892
|
+
this.readObjectMap(key, selection, record, data);
|
|
893
|
+
} else if (selection.plural === true) {
|
|
894
|
+
this.readPluralObject(key, selection, record, data);
|
|
895
|
+
} else {
|
|
896
|
+
this.readObject(key, selection, record, data);
|
|
897
|
+
}
|
|
898
|
+
} else if (selection.kind === "Custom") {
|
|
899
|
+
selection.reader(key, selection, record, data, variables, this);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
traverseSelections(node, record, data) {
|
|
903
|
+
const {selections} = node;
|
|
904
|
+
if (selections === void 0) {
|
|
905
|
+
this.selectAll(record, data);
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
const {length: len} = selections;
|
|
909
|
+
for (let i = 0; i < len; i += 1) {
|
|
910
|
+
const selection = selections[i];
|
|
911
|
+
this.enterPath(selection.name);
|
|
912
|
+
this.traverseSelection(selection, record, data);
|
|
913
|
+
this.exitPath();
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
isRebuilding() {
|
|
917
|
+
return this.baseSnapshot !== void 0;
|
|
918
|
+
}
|
|
919
|
+
getIsDataMissing() {
|
|
920
|
+
return this.isMissingData;
|
|
921
|
+
}
|
|
922
|
+
getTimeStamp() {
|
|
923
|
+
return this.timestamp;
|
|
924
|
+
}
|
|
925
|
+
markSeenId(key) {
|
|
926
|
+
this.seenIds[key] = true;
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
var resolvedPromise = Promise.resolve();
|
|
930
|
+
function throwNext(error) {
|
|
931
|
+
setTimeout(() => {
|
|
932
|
+
throw error;
|
|
933
|
+
}, 0);
|
|
934
|
+
}
|
|
935
|
+
function resolveImmediate(callback) {
|
|
936
|
+
resolvedPromise.then(callback).catch(throwNext);
|
|
937
|
+
}
|
|
938
|
+
var StoreErrorStatus;
|
|
939
|
+
(function(StoreErrorStatus2) {
|
|
940
|
+
StoreErrorStatus2[StoreErrorStatus2["RESOURCE_NOT_FOUND"] = 404] = "RESOURCE_NOT_FOUND";
|
|
941
|
+
})(StoreErrorStatus || (StoreErrorStatus = {}));
|
|
942
|
+
var StoreRecordType;
|
|
943
|
+
(function(StoreRecordType2) {
|
|
944
|
+
StoreRecordType2["Error"] = "error";
|
|
945
|
+
StoreRecordType2["Locked"] = "locked";
|
|
946
|
+
})(StoreRecordType || (StoreRecordType = {}));
|
|
947
|
+
function isStoreRecordError(storeRecord) {
|
|
948
|
+
return storeRecord.__type === StoreRecordType.Error;
|
|
949
|
+
}
|
|
950
|
+
function isStoreRecordLocked(storeRecord) {
|
|
951
|
+
return storeRecord.__type === StoreRecordType.Locked;
|
|
952
|
+
}
|
|
953
|
+
function hasOverlappingIds(snapshot, visitedIds) {
|
|
954
|
+
const {length: len} = visitedIds;
|
|
955
|
+
const {seenRecords} = snapshot;
|
|
956
|
+
for (let i = 0; i < len; i += 1) {
|
|
957
|
+
const id = visitedIds[i];
|
|
958
|
+
if (seenRecords[id] || id === snapshot.recordId) {
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
return false;
|
|
963
|
+
}
|
|
964
|
+
function isNonPendingSnapshotWithNoOverlappingIds(snapshot, visitedIds) {
|
|
965
|
+
return isPendingSnapshot(snapshot) === false && hasOverlappingIds(snapshot, visitedIds) === false;
|
|
966
|
+
}
|
|
967
|
+
function isPendingSnapshotWithNoOverlappingIds(snapshot, visitedIds, refreshedIds) {
|
|
968
|
+
return isPendingSnapshot(snapshot) === true && hasOverlappingIds(snapshot, refreshedIds) === false && hasOverlappingIds(snapshot, visitedIds) === false;
|
|
969
|
+
}
|
|
970
|
+
function getMatchingIds(prefix, visitedIds) {
|
|
971
|
+
const matchingIds = [];
|
|
972
|
+
for (let i = 0, len = visitedIds.length; i < len; i++) {
|
|
973
|
+
const visitedId = visitedIds[i];
|
|
974
|
+
if (visitedId.indexOf(prefix) === 0) {
|
|
975
|
+
push.call(matchingIds, visitedId);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return matchingIds;
|
|
979
|
+
}
|
|
980
|
+
var OVERRIDE_TTL_KEY_SEPARATOR = "::";
|
|
981
|
+
var OVERRIDE_TTL_DEFAULT_NAMESPACE = "$$Luvio$$";
|
|
982
|
+
var OVERRIDE_TTL_DEFAULT_REPRESENTATION_NAME = "default";
|
|
983
|
+
function getTTLOverrideKey(namespace, representationName) {
|
|
984
|
+
return `${namespace}${OVERRIDE_TTL_KEY_SEPARATOR}${representationName}`;
|
|
985
|
+
}
|
|
986
|
+
var Store = class {
|
|
987
|
+
constructor(options = {}) {
|
|
988
|
+
this.recordExpirations = create(null);
|
|
989
|
+
this.records = create(null);
|
|
990
|
+
this.metadata = create(null);
|
|
991
|
+
this.snapshotSubscriptions = [];
|
|
992
|
+
this.watchSubscriptions = [];
|
|
993
|
+
this.visitedIds = create(null);
|
|
994
|
+
this.refreshedIds = create(null);
|
|
995
|
+
this.insertedIds = create(null);
|
|
996
|
+
this.redirectKeys = create(null);
|
|
997
|
+
this.reverseRedirectKeys = create(null);
|
|
998
|
+
this.retainedIds = create(null);
|
|
999
|
+
this.trimTask = null;
|
|
1000
|
+
this.ttlOverrides = create(null);
|
|
1001
|
+
this.scheduler = options.scheduler || resolveImmediate;
|
|
1002
|
+
}
|
|
1003
|
+
markVisited(canonicalKey) {
|
|
1004
|
+
const {visitedIds, reverseRedirectKeys} = this;
|
|
1005
|
+
visitedIds[canonicalKey] = true;
|
|
1006
|
+
let redirectKey = reverseRedirectKeys[canonicalKey];
|
|
1007
|
+
while (redirectKey !== void 0) {
|
|
1008
|
+
visitedIds[redirectKey] = true;
|
|
1009
|
+
redirectKey = reverseRedirectKeys[redirectKey];
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
markRefreshed(canonicalKey) {
|
|
1013
|
+
const {refreshedIds, reverseRedirectKeys} = this;
|
|
1014
|
+
refreshedIds[canonicalKey] = true;
|
|
1015
|
+
let redirectKey = reverseRedirectKeys[canonicalKey];
|
|
1016
|
+
while (redirectKey !== void 0) {
|
|
1017
|
+
refreshedIds[redirectKey] = true;
|
|
1018
|
+
redirectKey = reverseRedirectKeys[redirectKey];
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
reset() {
|
|
1022
|
+
this.recordExpirations = create(null);
|
|
1023
|
+
this.records = create(null);
|
|
1024
|
+
this.snapshotSubscriptions = [];
|
|
1025
|
+
this.watchSubscriptions = [];
|
|
1026
|
+
this.visitedIds = create(null);
|
|
1027
|
+
this.refreshedIds = create(null);
|
|
1028
|
+
this.insertedIds = create(null);
|
|
1029
|
+
this.redirectKeys = create(null);
|
|
1030
|
+
this.reverseRedirectKeys = create(null);
|
|
1031
|
+
this.retainedIds = create(null);
|
|
1032
|
+
this.ttlOverrides = create(null);
|
|
1033
|
+
this.trimTask = null;
|
|
1034
|
+
this.metadata = create(null);
|
|
1035
|
+
}
|
|
1036
|
+
redirect(key, canonicalKey) {
|
|
1037
|
+
const {redirectKeys, reverseRedirectKeys} = this;
|
|
1038
|
+
if (key === canonicalKey) {
|
|
1039
|
+
throw new Error("cannot redirect a key to itself");
|
|
1040
|
+
}
|
|
1041
|
+
if (reverseRedirectKeys[canonicalKey] !== void 0) {
|
|
1042
|
+
throw new Error("cannot have multiple redirects keys point to the same canonical key");
|
|
1043
|
+
}
|
|
1044
|
+
if (redirectKeys[canonicalKey] !== void 0) {
|
|
1045
|
+
throw new Error("the canonical key must be terminal and cannot already be part of a redirect chain");
|
|
1046
|
+
}
|
|
1047
|
+
redirectKeys[key] = canonicalKey;
|
|
1048
|
+
reverseRedirectKeys[canonicalKey] = key;
|
|
1049
|
+
delete this.records[key];
|
|
1050
|
+
this.visitedIds[key] = true;
|
|
1051
|
+
}
|
|
1052
|
+
publish(recordId, record) {
|
|
1053
|
+
const {records, insertedIds} = this;
|
|
1054
|
+
const canonicalKey = this.getCanonicalRecordId(recordId);
|
|
1055
|
+
if (hasOwnProperty.call(records, canonicalKey) === false) {
|
|
1056
|
+
insertedIds[canonicalKey] = true;
|
|
1057
|
+
}
|
|
1058
|
+
records[canonicalKey] = record;
|
|
1059
|
+
this.markVisited(canonicalKey);
|
|
1060
|
+
}
|
|
1061
|
+
getCanonicalRecordId(recordId) {
|
|
1062
|
+
let canonicalKey = recordId;
|
|
1063
|
+
const {redirectKeys} = this;
|
|
1064
|
+
while (redirectKeys[canonicalKey]) {
|
|
1065
|
+
canonicalKey = redirectKeys[canonicalKey];
|
|
1066
|
+
}
|
|
1067
|
+
return canonicalKey;
|
|
1068
|
+
}
|
|
1069
|
+
setExpiration(recordId, expiration, staleExpiration) {
|
|
1070
|
+
const canonicalKey = this.getCanonicalRecordId(recordId);
|
|
1071
|
+
this.recordExpirations[canonicalKey] = {
|
|
1072
|
+
fresh: expiration,
|
|
1073
|
+
stale: staleExpiration === void 0 ? expiration : staleExpiration
|
|
1074
|
+
};
|
|
1075
|
+
this.markRefreshed(canonicalKey);
|
|
1076
|
+
}
|
|
1077
|
+
updateSubscriptionSnapshot(subscription, newSnapshot) {
|
|
1078
|
+
const {snapshot: oldSnapshot} = subscription;
|
|
1079
|
+
if (oldSnapshot === newSnapshot) {
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
subscription.snapshot = newSnapshot;
|
|
1083
|
+
if (!isErrorSnapshot(newSnapshot)) {
|
|
1084
|
+
this.retainSnapshotIds(newSnapshot);
|
|
1085
|
+
}
|
|
1086
|
+
if (!isErrorSnapshot(oldSnapshot)) {
|
|
1087
|
+
this.releaseSnapshotIds(oldSnapshot);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
emitOrRefreshRebuiltSnapshot(rebuiltSnapshot, subscription, snapshotAvailable) {
|
|
1091
|
+
const {snapshot, callback} = subscription;
|
|
1092
|
+
if (isPendingSnapshot(rebuiltSnapshot)) {
|
|
1093
|
+
if (isPendingSnapshot(snapshot)) {
|
|
1094
|
+
this.updateSubscriptionSnapshot(subscription, rebuiltSnapshot);
|
|
1095
|
+
}
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
this.updateSubscriptionSnapshot(subscription, rebuiltSnapshot);
|
|
1099
|
+
if (snapshotAvailable(rebuiltSnapshot) && rebuiltSnapshot !== snapshot) {
|
|
1100
|
+
callback(rebuiltSnapshot);
|
|
1101
|
+
} else if (isUnfulfilledSnapshot(rebuiltSnapshot)) {
|
|
1102
|
+
const {refresh} = rebuiltSnapshot;
|
|
1103
|
+
if (refresh !== void 0) {
|
|
1104
|
+
refresh.resolve(refresh.config);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
broadcast(rebuildSnapshot, snapshotAvailable) {
|
|
1109
|
+
const {snapshotSubscriptions, watchSubscriptions, visitedIds, refreshedIds, insertedIds, records, redirectKeys} = this;
|
|
1110
|
+
const allVisitedIds = keys(visitedIds);
|
|
1111
|
+
const allRefreshedIds = keys(refreshedIds);
|
|
1112
|
+
if (allVisitedIds.length === 0 && allRefreshedIds.length === 0) {
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
for (let i = 0, len = snapshotSubscriptions.length; i < len; i++) {
|
|
1116
|
+
const subscription = snapshotSubscriptions[i];
|
|
1117
|
+
const {snapshot} = subscription;
|
|
1118
|
+
if (isErrorSnapshot(snapshot) || isNonPendingSnapshotWithNoOverlappingIds(snapshot, allVisitedIds) || isPendingSnapshotWithNoOverlappingIds(snapshot, allVisitedIds, allRefreshedIds)) {
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
const updatedSnapshot = rebuildSnapshot(snapshot, records, {}, redirectKeys, (asyncAvailableSnapshot) => {
|
|
1122
|
+
this.emitOrRefreshRebuiltSnapshot(asyncAvailableSnapshot, subscription, snapshotAvailable);
|
|
1123
|
+
});
|
|
1124
|
+
this.emitOrRefreshRebuiltSnapshot(updatedSnapshot, subscription, snapshotAvailable);
|
|
1125
|
+
}
|
|
1126
|
+
for (let i = 0, len = watchSubscriptions.length; i < len; i++) {
|
|
1127
|
+
const {prefix, callback} = watchSubscriptions[i];
|
|
1128
|
+
const matchingIds = getMatchingIds(prefix, allVisitedIds);
|
|
1129
|
+
if (matchingIds.length > 0) {
|
|
1130
|
+
const watchCallbackEntries = [];
|
|
1131
|
+
for (let i2 = 0, len2 = matchingIds.length; i2 < len2; i2++) {
|
|
1132
|
+
const id = matchingIds[i2];
|
|
1133
|
+
const inserted = insertedIds[id] || false;
|
|
1134
|
+
push.call(watchCallbackEntries, {id, inserted});
|
|
1135
|
+
}
|
|
1136
|
+
callback(watchCallbackEntries);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
this.visitedIds = create(null);
|
|
1140
|
+
this.refreshedIds = create(null);
|
|
1141
|
+
this.insertedIds = create(null);
|
|
1142
|
+
}
|
|
1143
|
+
broadcastNonCachedSnapshot(recordId, errorSnapshot) {
|
|
1144
|
+
const {snapshotSubscriptions} = this;
|
|
1145
|
+
for (let i = 0, len = snapshotSubscriptions.length; i < len; i++) {
|
|
1146
|
+
const subscription = snapshotSubscriptions[i];
|
|
1147
|
+
const {snapshot, callback} = subscription;
|
|
1148
|
+
if (isPendingSnapshot(snapshot) && snapshot.recordId === recordId) {
|
|
1149
|
+
subscription.snapshot = errorSnapshot;
|
|
1150
|
+
callback(errorSnapshot);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
lookup(selector, createSnapshot, refresh) {
|
|
1155
|
+
const {records, recordExpirations, redirectKeys} = this;
|
|
1156
|
+
return createSnapshot(records, recordExpirations, redirectKeys, selector, refresh);
|
|
1157
|
+
}
|
|
1158
|
+
subscribe(snapshot, callback) {
|
|
1159
|
+
const subscription = {snapshot, callback};
|
|
1160
|
+
this.snapshotSubscriptions = [...this.snapshotSubscriptions, subscription];
|
|
1161
|
+
if (!isErrorSnapshot(snapshot)) {
|
|
1162
|
+
this.retainSnapshotIds(snapshot);
|
|
1163
|
+
}
|
|
1164
|
+
return () => {
|
|
1165
|
+
const {snapshotSubscriptions} = this;
|
|
1166
|
+
const index = indexOf.call(snapshotSubscriptions, subscription);
|
|
1167
|
+
if (index > -1) {
|
|
1168
|
+
this.snapshotSubscriptions = [
|
|
1169
|
+
...slice.call(snapshotSubscriptions, 0, index),
|
|
1170
|
+
...slice.call(snapshotSubscriptions, index + 1)
|
|
1171
|
+
];
|
|
1172
|
+
const {snapshot: snapshot2} = subscription;
|
|
1173
|
+
if (!isErrorSnapshot(snapshot2)) {
|
|
1174
|
+
this.releaseSnapshotIds(snapshot2);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
increaseRetentionCount(key) {
|
|
1180
|
+
const count = this.retainedIds[key];
|
|
1181
|
+
this.retainedIds[key] = count === void 0 ? 1 : count + 1;
|
|
1182
|
+
}
|
|
1183
|
+
decreaseRetentionCount(key) {
|
|
1184
|
+
const count = this.retainedIds[key];
|
|
1185
|
+
if (count === 1) {
|
|
1186
|
+
return delete this.retainedIds[key];
|
|
1187
|
+
} else if (count === void 0) {
|
|
1188
|
+
return false;
|
|
1189
|
+
} else {
|
|
1190
|
+
this.retainedIds[key] = count - 1;
|
|
1191
|
+
}
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
release(keys2) {
|
|
1195
|
+
const keysLength = keys2.length;
|
|
1196
|
+
let shouldScheduleTrim = false;
|
|
1197
|
+
for (let i = 0; i < keysLength; i++) {
|
|
1198
|
+
const key = keys2[i];
|
|
1199
|
+
const result = this.decreaseRetentionCount(key);
|
|
1200
|
+
if (shouldScheduleTrim !== true) {
|
|
1201
|
+
shouldScheduleTrim = result;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
if (shouldScheduleTrim === true) {
|
|
1205
|
+
this.scheduleTrim();
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
retain(keys2) {
|
|
1209
|
+
const keysLength = keys2.length;
|
|
1210
|
+
for (let i = 0; i < keysLength; i++) {
|
|
1211
|
+
const key = keys2[i];
|
|
1212
|
+
this.increaseRetentionCount(key);
|
|
1213
|
+
}
|
|
1214
|
+
return () => {
|
|
1215
|
+
this.release(keys2);
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
retainSnapshotIds(snapshot) {
|
|
1219
|
+
const {recordId, seenRecords} = snapshot;
|
|
1220
|
+
const snapshotRetainedIds = seenRecords === void 0 ? [recordId] : [recordId, ...keys(seenRecords)];
|
|
1221
|
+
this.retain(snapshotRetainedIds);
|
|
1222
|
+
}
|
|
1223
|
+
releaseSnapshotIds(snapshot) {
|
|
1224
|
+
const {recordId, seenRecords} = snapshot;
|
|
1225
|
+
const snapshotReleaseIds = seenRecords === void 0 ? [recordId] : [recordId, ...keys(seenRecords)];
|
|
1226
|
+
this.release(snapshotReleaseIds);
|
|
1227
|
+
}
|
|
1228
|
+
scheduleTrim() {
|
|
1229
|
+
if (this.trimTask === null) {
|
|
1230
|
+
this.trimTask = () => {
|
|
1231
|
+
const {records, retainedIds, recordExpirations} = this;
|
|
1232
|
+
const recordKeys = keys(records);
|
|
1233
|
+
const recordKeysLength = recordKeys.length;
|
|
1234
|
+
const now = Date.now();
|
|
1235
|
+
let deallocCount = 0;
|
|
1236
|
+
for (let i = 0; i < recordKeysLength; i++) {
|
|
1237
|
+
const recordKey = recordKeys[i];
|
|
1238
|
+
const recordExpiration = recordExpirations[recordKey];
|
|
1239
|
+
if (retainedIds[recordKey] !== void 0 || recordExpiration === void 0 || recordExpiration !== void 0 && recordExpiration.fresh >= now) {
|
|
1240
|
+
continue;
|
|
1241
|
+
}
|
|
1242
|
+
this.dealloc(recordKey);
|
|
1243
|
+
deallocCount += 1;
|
|
1244
|
+
}
|
|
1245
|
+
this.trimTask = null;
|
|
1246
|
+
return deallocCount;
|
|
1247
|
+
};
|
|
1248
|
+
this.scheduler(this.trimTask);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
watch(prefix, callback) {
|
|
1252
|
+
const subscription = {prefix, callback};
|
|
1253
|
+
this.watchSubscriptions = [...this.watchSubscriptions, subscription];
|
|
1254
|
+
return () => {
|
|
1255
|
+
const {watchSubscriptions} = this;
|
|
1256
|
+
const index = indexOf.call(watchSubscriptions, subscription);
|
|
1257
|
+
this.watchSubscriptions = [
|
|
1258
|
+
...slice.call(watchSubscriptions, 0, index),
|
|
1259
|
+
...slice.call(watchSubscriptions, index + 1)
|
|
1260
|
+
];
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
evict(key) {
|
|
1264
|
+
const canonicalKey = this.getCanonicalRecordId(key);
|
|
1265
|
+
delete this.records[canonicalKey];
|
|
1266
|
+
this.visitedIds[canonicalKey] = true;
|
|
1267
|
+
let redirectKey = this.reverseRedirectKeys[canonicalKey];
|
|
1268
|
+
while (redirectKey !== void 0) {
|
|
1269
|
+
this.visitedIds[redirectKey] = true;
|
|
1270
|
+
redirectKey = this.reverseRedirectKeys[redirectKey];
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
dealloc(key) {
|
|
1274
|
+
const canonicalKey = this.getCanonicalRecordId(key);
|
|
1275
|
+
delete this.records[canonicalKey];
|
|
1276
|
+
}
|
|
1277
|
+
lock(recordId) {
|
|
1278
|
+
const canonicalKey = this.getCanonicalRecordId(recordId);
|
|
1279
|
+
this.records[canonicalKey] = {__type: "locked"};
|
|
1280
|
+
}
|
|
1281
|
+
unlock(recordId) {
|
|
1282
|
+
const canonicalKey = this.getCanonicalRecordId(recordId);
|
|
1283
|
+
const record = this.records[canonicalKey];
|
|
1284
|
+
if (record !== void 0 && isStoreRecordLocked(record)) {
|
|
1285
|
+
this.dealloc(canonicalKey);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
createReader(records, recordExpirations, redirects, variables, refresh, baseSnapshot) {
|
|
1289
|
+
return new Reader(records, recordExpirations, redirects, variables, refresh, baseSnapshot);
|
|
1290
|
+
}
|
|
1291
|
+
publishMetadata(key, storeMetadata) {
|
|
1292
|
+
const {namespace, representationName, ingestionTimestamp} = storeMetadata;
|
|
1293
|
+
const ttlOverrideKey = getTTLOverrideKey(namespace, representationName);
|
|
1294
|
+
const ttlOverride = this.ttlOverrides[ttlOverrideKey];
|
|
1295
|
+
if (ttlOverride !== void 0) {
|
|
1296
|
+
const newExpiration = ingestionTimestamp + ttlOverride;
|
|
1297
|
+
const metaDataOverride = {
|
|
1298
|
+
expirationTimestamp: newExpiration,
|
|
1299
|
+
ingestionTimestamp,
|
|
1300
|
+
namespace,
|
|
1301
|
+
representationName
|
|
1302
|
+
};
|
|
1303
|
+
this.metadata[key] = metaDataOverride;
|
|
1304
|
+
} else {
|
|
1305
|
+
this.metadata[key] = storeMetadata;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
setTTLOverride(namespace, representationName, ttl) {
|
|
1309
|
+
this.ttlOverrides[getTTLOverrideKey(namespace, representationName)] = ttl;
|
|
1310
|
+
}
|
|
1311
|
+
setDefaultTTLOverride(ttl) {
|
|
1312
|
+
this.setTTLOverride(OVERRIDE_TTL_DEFAULT_NAMESPACE, OVERRIDE_TTL_DEFAULT_REPRESENTATION_NAME, ttl);
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
function isNodeLink(node) {
|
|
1316
|
+
return typeof node === "object" && node !== null && hasOwnProperty.call(node, "__ref");
|
|
1317
|
+
}
|
|
1318
|
+
var GraphNodeType;
|
|
1319
|
+
(function(GraphNodeType2) {
|
|
1320
|
+
GraphNodeType2["Link"] = "Link";
|
|
1321
|
+
GraphNodeType2["Node"] = "Node";
|
|
1322
|
+
GraphNodeType2["Error"] = "Error";
|
|
1323
|
+
GraphNodeType2["Locked"] = "Locked";
|
|
1324
|
+
})(GraphNodeType || (GraphNodeType = {}));
|
|
1325
|
+
var GraphNodeError = class {
|
|
1326
|
+
constructor(store, data) {
|
|
1327
|
+
this.type = GraphNodeType.Error;
|
|
1328
|
+
this.store = store;
|
|
1329
|
+
this.data = data;
|
|
1330
|
+
}
|
|
1331
|
+
retrieve() {
|
|
1332
|
+
return this.data;
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
var GraphNodeLocked = class {
|
|
1336
|
+
constructor(store, data) {
|
|
1337
|
+
this.type = GraphNodeType.Locked;
|
|
1338
|
+
this.store = store;
|
|
1339
|
+
this.data = data;
|
|
1340
|
+
}
|
|
1341
|
+
retrieve() {
|
|
1342
|
+
return this.data;
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1345
|
+
function followLink(store, key) {
|
|
1346
|
+
const canonicalKey = store.getCanonicalRecordId(key);
|
|
1347
|
+
return store.records[canonicalKey];
|
|
1348
|
+
}
|
|
1349
|
+
var GraphLink = class {
|
|
1350
|
+
constructor(store, data) {
|
|
1351
|
+
this.type = GraphNodeType.Link;
|
|
1352
|
+
this.store = store;
|
|
1353
|
+
this.data = data;
|
|
1354
|
+
}
|
|
1355
|
+
isPending() {
|
|
1356
|
+
return this.data.pending === true;
|
|
1357
|
+
}
|
|
1358
|
+
isMissing() {
|
|
1359
|
+
return this.data.isMissing === true;
|
|
1360
|
+
}
|
|
1361
|
+
follow() {
|
|
1362
|
+
const {__ref} = this.data;
|
|
1363
|
+
if (__ref === void 0) {
|
|
1364
|
+
return null;
|
|
1365
|
+
}
|
|
1366
|
+
const linked = followLink(this.store, __ref);
|
|
1367
|
+
if (linked === null || linked === void 0) {
|
|
1368
|
+
return null;
|
|
1369
|
+
}
|
|
1370
|
+
if (isStoreRecordError(linked)) {
|
|
1371
|
+
return new GraphNodeError(this.store, linked);
|
|
1372
|
+
}
|
|
1373
|
+
if (isStoreRecordLocked(linked)) {
|
|
1374
|
+
return new GraphNodeLocked(this.store, linked);
|
|
1375
|
+
}
|
|
1376
|
+
return new GraphNode(this.store, linked);
|
|
1377
|
+
}
|
|
1378
|
+
linkData() {
|
|
1379
|
+
return this.data.data;
|
|
1380
|
+
}
|
|
1381
|
+
writeLinkData(data) {
|
|
1382
|
+
this.data.data = data;
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
var GraphNode = class {
|
|
1386
|
+
constructor(store, data) {
|
|
1387
|
+
this.type = GraphNodeType.Node;
|
|
1388
|
+
this.store = store;
|
|
1389
|
+
this.data = data;
|
|
1390
|
+
}
|
|
1391
|
+
object(propertyName) {
|
|
1392
|
+
const value = this.data[propertyName];
|
|
1393
|
+
if (isNodeLink(value)) {
|
|
1394
|
+
throw new Error(`Cannot walk to path ${propertyName}. "${propertyName}" is a link: "${value}"`);
|
|
1395
|
+
}
|
|
1396
|
+
if (typeof value !== "object" || value === null) {
|
|
1397
|
+
throw new Error(`Cannot walk to path ${propertyName}. "${propertyName}" is a scalar: "${value}"`);
|
|
1398
|
+
}
|
|
1399
|
+
return new GraphNode(this.store, value);
|
|
1400
|
+
}
|
|
1401
|
+
link(propertyName) {
|
|
1402
|
+
const value = this.data[propertyName];
|
|
1403
|
+
if (!isNodeLink(value)) {
|
|
1404
|
+
throw new Error(`Cannot walk to link ${propertyName}. "${propertyName}" is not a link: "${value}"`);
|
|
1405
|
+
}
|
|
1406
|
+
return new GraphLink(this.store, value);
|
|
1407
|
+
}
|
|
1408
|
+
scalar(propertyName) {
|
|
1409
|
+
const value = this.data[propertyName];
|
|
1410
|
+
if (typeof value === "object" && value !== null) {
|
|
1411
|
+
throw new Error(`Cannot return value at path ${propertyName}. ${propertyName} is not a scalar.`);
|
|
1412
|
+
}
|
|
1413
|
+
return value;
|
|
1414
|
+
}
|
|
1415
|
+
keys() {
|
|
1416
|
+
return keys(this.data);
|
|
1417
|
+
}
|
|
1418
|
+
isScalar(propertyName) {
|
|
1419
|
+
if (this.data === void 0) {
|
|
1420
|
+
return true;
|
|
1421
|
+
}
|
|
1422
|
+
const value = this.data[propertyName];
|
|
1423
|
+
return typeof value !== "object" || value === null;
|
|
1424
|
+
}
|
|
1425
|
+
write(propertyName, value) {
|
|
1426
|
+
this.data[propertyName] = value;
|
|
1427
|
+
}
|
|
1428
|
+
isUndefined(propertyName) {
|
|
1429
|
+
return this.data[propertyName] === void 0;
|
|
1430
|
+
}
|
|
1431
|
+
retrieve() {
|
|
1432
|
+
return this.data;
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
exports.HttpStatusCode = void 0;
|
|
1436
|
+
(function(HttpStatusCode2) {
|
|
1437
|
+
HttpStatusCode2[HttpStatusCode2["Ok"] = 200] = "Ok";
|
|
1438
|
+
HttpStatusCode2[HttpStatusCode2["Created"] = 201] = "Created";
|
|
1439
|
+
HttpStatusCode2[HttpStatusCode2["NoContent"] = 204] = "NoContent";
|
|
1440
|
+
HttpStatusCode2[HttpStatusCode2["NotModified"] = 304] = "NotModified";
|
|
1441
|
+
HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
|
|
1442
|
+
HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
|
|
1443
|
+
HttpStatusCode2[HttpStatusCode2["ServerError"] = 500] = "ServerError";
|
|
1444
|
+
})(exports.HttpStatusCode || (exports.HttpStatusCode = {}));
|
|
1445
|
+
var Environment = class {
|
|
1446
|
+
constructor(store, networkAdapter) {
|
|
1447
|
+
this.store = store;
|
|
1448
|
+
this.networkAdapter = networkAdapter;
|
|
1449
|
+
this.adapterContextMap = create(null);
|
|
1450
|
+
this.createSnapshot = this.createSnapshot.bind(this);
|
|
1451
|
+
this.rebuildSnapshot = this.rebuildSnapshot.bind(this);
|
|
1452
|
+
}
|
|
1453
|
+
dispatchResourceRequest(request) {
|
|
1454
|
+
return this.networkAdapter(request);
|
|
1455
|
+
}
|
|
1456
|
+
isErrorCacheable(errorSnapshot) {
|
|
1457
|
+
const {error} = errorSnapshot;
|
|
1458
|
+
const {status} = error;
|
|
1459
|
+
return status === exports.HttpStatusCode.NotFound;
|
|
1460
|
+
}
|
|
1461
|
+
resolvePendingSnapshot(snapshot) {
|
|
1462
|
+
return new Promise((resolve) => {
|
|
1463
|
+
let unsubscribe;
|
|
1464
|
+
unsubscribe = this.storeSubscribe(snapshot, (resolvedSnapshot) => {
|
|
1465
|
+
if (unsubscribe !== void 0) {
|
|
1466
|
+
unsubscribe();
|
|
1467
|
+
}
|
|
1468
|
+
resolve(resolvedSnapshot);
|
|
1469
|
+
});
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
resolveSnapshot(snapshot, refresh) {
|
|
1473
|
+
if (snapshot.state === "Pending") {
|
|
1474
|
+
return this.resolvePendingSnapshot(snapshot);
|
|
1475
|
+
}
|
|
1476
|
+
const {resolve, config} = refresh;
|
|
1477
|
+
return resolve(config).then((refreshedSnapshot) => {
|
|
1478
|
+
if (refreshedSnapshot.state === "Pending") {
|
|
1479
|
+
const {records, redirectKeys} = this.store;
|
|
1480
|
+
const rebuilt = this.rebuildSnapshot(refreshedSnapshot, records, {}, redirectKeys, () => {
|
|
1481
|
+
});
|
|
1482
|
+
if (rebuilt.state === "Pending") {
|
|
1483
|
+
return this.resolvePendingSnapshot(refreshedSnapshot);
|
|
1484
|
+
}
|
|
1485
|
+
return rebuilt;
|
|
1486
|
+
}
|
|
1487
|
+
return refreshedSnapshot;
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
storeIngest(key, ingest, response, luvio) {
|
|
1491
|
+
const state = {
|
|
1492
|
+
result: {
|
|
1493
|
+
type: "success"
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
if (ingest !== null) {
|
|
1497
|
+
ingest(response, {
|
|
1498
|
+
fullPath: key,
|
|
1499
|
+
parent: null,
|
|
1500
|
+
propertyName: null,
|
|
1501
|
+
state
|
|
1502
|
+
}, luvio, this.store, Date.now());
|
|
1503
|
+
}
|
|
1504
|
+
return state.result;
|
|
1505
|
+
}
|
|
1506
|
+
storeIngestError(key, errorSnapshot, ttl) {
|
|
1507
|
+
const {error} = errorSnapshot;
|
|
1508
|
+
if (this.isErrorCacheable(errorSnapshot)) {
|
|
1509
|
+
const entry = {
|
|
1510
|
+
__type: StoreRecordType.Error,
|
|
1511
|
+
status: StoreErrorStatus.RESOURCE_NOT_FOUND,
|
|
1512
|
+
error
|
|
1513
|
+
};
|
|
1514
|
+
freeze(entry);
|
|
1515
|
+
this.storePublish(key, entry);
|
|
1516
|
+
if (ttl !== void 0) {
|
|
1517
|
+
this.storeSetExpiration(key, Date.now() + ttl);
|
|
1518
|
+
}
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
this.store.broadcastNonCachedSnapshot(key, errorSnapshot);
|
|
1522
|
+
}
|
|
1523
|
+
storePublish(key, data) {
|
|
1524
|
+
this.store.publish(key, data);
|
|
1525
|
+
}
|
|
1526
|
+
storeRedirect(existingKey, redirectKey) {
|
|
1527
|
+
this.store.redirect(existingKey, redirectKey);
|
|
1528
|
+
}
|
|
1529
|
+
storeGetCanonicalKey(key) {
|
|
1530
|
+
return this.store.getCanonicalRecordId(key);
|
|
1531
|
+
}
|
|
1532
|
+
storeBroadcast(rebuildSnapshot, snapshotAvailable) {
|
|
1533
|
+
this.store.broadcast(rebuildSnapshot, snapshotAvailable);
|
|
1534
|
+
}
|
|
1535
|
+
storeSubscribe(snapshot, callback) {
|
|
1536
|
+
return this.store.subscribe(snapshot, callback);
|
|
1537
|
+
}
|
|
1538
|
+
storeWatch(prefix, callback) {
|
|
1539
|
+
return this.store.watch(prefix, callback);
|
|
1540
|
+
}
|
|
1541
|
+
storeLookup(sel, createSnapshot, refresh) {
|
|
1542
|
+
return this.store.lookup(sel, createSnapshot, refresh);
|
|
1543
|
+
}
|
|
1544
|
+
storeEvict(key) {
|
|
1545
|
+
this.store.evict(key);
|
|
1546
|
+
}
|
|
1547
|
+
storeLock(key) {
|
|
1548
|
+
this.store.lock(key);
|
|
1549
|
+
}
|
|
1550
|
+
storeUnlock(key) {
|
|
1551
|
+
this.store.unlock(key);
|
|
1552
|
+
}
|
|
1553
|
+
storeDealloc(key) {
|
|
1554
|
+
this.store.dealloc(key);
|
|
1555
|
+
}
|
|
1556
|
+
storeReset() {
|
|
1557
|
+
this.store.reset();
|
|
1558
|
+
}
|
|
1559
|
+
storeRetain(keys2) {
|
|
1560
|
+
return this.store.retain(keys2);
|
|
1561
|
+
}
|
|
1562
|
+
snapshotAvailable(snapshot) {
|
|
1563
|
+
return isFulfilledSnapshot(snapshot) || isErrorSnapshot(snapshot);
|
|
1564
|
+
}
|
|
1565
|
+
storeSetExpiration(recordId, expiration, staleExpiration) {
|
|
1566
|
+
this.store.setExpiration(recordId, expiration, staleExpiration);
|
|
1567
|
+
}
|
|
1568
|
+
storeCreateReader(records, recordExpirations, redirects, selector, refresh, baseSnapshot) {
|
|
1569
|
+
return this.store.createReader(records, recordExpirations, redirects, selector.variables, refresh, baseSnapshot);
|
|
1570
|
+
}
|
|
1571
|
+
createSnapshot(records, recordExpirations, redirects, selector, refresh) {
|
|
1572
|
+
return this.store.createReader(records, recordExpirations, redirects, selector.variables, refresh).read(selector);
|
|
1573
|
+
}
|
|
1574
|
+
rebuildSnapshot(snapshot, records, recordExpirations, redirects, _onAsyncRebuild) {
|
|
1575
|
+
return this.store.createReader(records, recordExpirations, redirects, snapshot.variables, snapshot.refresh, snapshot).read(snapshot.select);
|
|
1576
|
+
}
|
|
1577
|
+
getStoreRecords() {
|
|
1578
|
+
return this.store.records;
|
|
1579
|
+
}
|
|
1580
|
+
getStoreVisitedIds() {
|
|
1581
|
+
return this.store.visitedIds;
|
|
1582
|
+
}
|
|
1583
|
+
getStoreRecordExpirations() {
|
|
1584
|
+
return this.store.recordExpirations;
|
|
1585
|
+
}
|
|
1586
|
+
getStoreRedirectKeys() {
|
|
1587
|
+
return this.store.redirectKeys;
|
|
1588
|
+
}
|
|
1589
|
+
getNode(key) {
|
|
1590
|
+
const canonicalKey = this.store.getCanonicalRecordId(key);
|
|
1591
|
+
const value = this.store.records[canonicalKey];
|
|
1592
|
+
if (value === void 0) {
|
|
1593
|
+
return null;
|
|
1594
|
+
}
|
|
1595
|
+
return this.wrapNormalizedGraphNode(value);
|
|
1596
|
+
}
|
|
1597
|
+
wrapNormalizedGraphNode(normalized) {
|
|
1598
|
+
if (normalized === null) {
|
|
1599
|
+
return null;
|
|
1600
|
+
}
|
|
1601
|
+
if (isStoreRecordError(normalized)) {
|
|
1602
|
+
return new GraphNodeError(this.store, normalized);
|
|
1603
|
+
}
|
|
1604
|
+
if (isStoreRecordLocked(normalized)) {
|
|
1605
|
+
return new GraphNodeLocked(this.store, normalized);
|
|
1606
|
+
}
|
|
1607
|
+
return new GraphNode(this.store, normalized);
|
|
1608
|
+
}
|
|
1609
|
+
withContext(adapter, options = {}) {
|
|
1610
|
+
const {contextId, onContextLoaded} = options;
|
|
1611
|
+
if (contextId !== void 0 && this.adapterContextMap[contextId] === void 0) {
|
|
1612
|
+
this.adapterContextMap[contextId] = create(null);
|
|
1613
|
+
}
|
|
1614
|
+
const contextStore = contextId !== void 0 ? this.adapterContextMap[contextId] : create(null);
|
|
1615
|
+
const context = {
|
|
1616
|
+
set(key, value) {
|
|
1617
|
+
contextStore[key] = value;
|
|
1618
|
+
},
|
|
1619
|
+
get(key) {
|
|
1620
|
+
return contextStore[key];
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
if (onContextLoaded === void 0) {
|
|
1624
|
+
return (config) => {
|
|
1625
|
+
return adapter(config, context);
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
let firstRun = true;
|
|
1629
|
+
const hookAsPromise = onContextLoaded(context);
|
|
1630
|
+
return (config) => {
|
|
1631
|
+
if (firstRun) {
|
|
1632
|
+
return hookAsPromise.then(() => {
|
|
1633
|
+
firstRun = false;
|
|
1634
|
+
return adapter(config, context);
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
return adapter(config, context);
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
publishStoreMetadata(key, storeMetadata) {
|
|
1641
|
+
this.store.publishMetadata(key, storeMetadata);
|
|
1642
|
+
}
|
|
1643
|
+
storeSetTTLOverride(namespace, representationName, ttl) {
|
|
1644
|
+
this.store.setTTLOverride(namespace, representationName, ttl);
|
|
1645
|
+
}
|
|
1646
|
+
storeSetDefaultTTLOverride(ttl) {
|
|
1647
|
+
this.store.setDefaultTTLOverride(ttl);
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
var Luvio = class {
|
|
1651
|
+
constructor(environment, options = {}) {
|
|
1652
|
+
this.environment = environment;
|
|
1653
|
+
this.options = options;
|
|
1654
|
+
}
|
|
1655
|
+
pagination(key) {
|
|
1656
|
+
const records = this.environment.getStoreRecords();
|
|
1657
|
+
let data = records[key];
|
|
1658
|
+
data = data && {...data};
|
|
1659
|
+
return pagination(data, (pd) => {
|
|
1660
|
+
this.storePublish(key, pd);
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
storePublish(key, data) {
|
|
1664
|
+
this.environment.storePublish(key, data);
|
|
1665
|
+
}
|
|
1666
|
+
storeRedirect(existingKey, canonicalKey) {
|
|
1667
|
+
this.environment.storeRedirect(existingKey, canonicalKey);
|
|
1668
|
+
}
|
|
1669
|
+
storeRetain(keys2) {
|
|
1670
|
+
return this.environment.storeRetain(keys2);
|
|
1671
|
+
}
|
|
1672
|
+
storeGetCanonicalKey(key) {
|
|
1673
|
+
return this.environment.storeGetCanonicalKey(key);
|
|
1674
|
+
}
|
|
1675
|
+
storeBroadcast() {
|
|
1676
|
+
this.environment.storeBroadcast(this.environment.rebuildSnapshot, this.environment.snapshotAvailable);
|
|
1677
|
+
}
|
|
1678
|
+
storeIngest(key, ingest, response) {
|
|
1679
|
+
return this.environment.storeIngest(key, ingest, response, this);
|
|
1680
|
+
}
|
|
1681
|
+
storeIngestError(key, errorSnapshot, ttl) {
|
|
1682
|
+
return this.environment.storeIngestError(key, errorSnapshot, ttl);
|
|
1683
|
+
}
|
|
1684
|
+
storeSubscribe(snapshot, callback) {
|
|
1685
|
+
return this.environment.storeSubscribe(snapshot, callback);
|
|
1686
|
+
}
|
|
1687
|
+
storeWatch(prefix, callback) {
|
|
1688
|
+
return this.environment.storeWatch(prefix, callback);
|
|
1689
|
+
}
|
|
1690
|
+
storeLookup(sel, refresh) {
|
|
1691
|
+
return this.environment.storeLookup(sel, this.environment.createSnapshot, refresh);
|
|
1692
|
+
}
|
|
1693
|
+
storeEvict(key) {
|
|
1694
|
+
this.environment.storeEvict(key);
|
|
1695
|
+
}
|
|
1696
|
+
storeSetExpiration(recordId, expiration, staleExpiration) {
|
|
1697
|
+
this.environment.storeSetExpiration(recordId, expiration, staleExpiration);
|
|
1698
|
+
}
|
|
1699
|
+
createSnapshot(records, recordExpirations, redirects, selector, refresh) {
|
|
1700
|
+
return this.environment.createSnapshot(records, recordExpirations, redirects, selector, refresh);
|
|
1701
|
+
}
|
|
1702
|
+
errorSnapshot(error, refresh) {
|
|
1703
|
+
return createErrorSnapshot(error, refresh);
|
|
1704
|
+
}
|
|
1705
|
+
dispatchResourceRequest(resourceRequest, overrides) {
|
|
1706
|
+
let mergedResourceRequest = resourceRequest;
|
|
1707
|
+
if (overrides !== void 0) {
|
|
1708
|
+
mergedResourceRequest = {
|
|
1709
|
+
...resourceRequest,
|
|
1710
|
+
headers: {
|
|
1711
|
+
...resourceRequest.headers,
|
|
1712
|
+
...overrides.headers
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
return this.environment.dispatchResourceRequest(mergedResourceRequest);
|
|
1717
|
+
}
|
|
1718
|
+
resolveSnapshot(snapshot, refresh) {
|
|
1719
|
+
return this.environment.resolveSnapshot(snapshot, refresh);
|
|
1720
|
+
}
|
|
1721
|
+
refreshSnapshot(snapshot) {
|
|
1722
|
+
const {refresh} = snapshot;
|
|
1723
|
+
if (refresh !== void 0) {
|
|
1724
|
+
const {config, resolve} = refresh;
|
|
1725
|
+
return resolve(config);
|
|
1726
|
+
}
|
|
1727
|
+
throw new Error("Snapshot is not refreshable");
|
|
1728
|
+
}
|
|
1729
|
+
getNode(key) {
|
|
1730
|
+
return this.environment.getNode(key);
|
|
1731
|
+
}
|
|
1732
|
+
wrapNormalizedGraphNode(normalized) {
|
|
1733
|
+
return this.environment.wrapNormalizedGraphNode(normalized);
|
|
1734
|
+
}
|
|
1735
|
+
instrument(paramsBuilder) {
|
|
1736
|
+
const {instrument} = this.options;
|
|
1737
|
+
if (instrument) {
|
|
1738
|
+
instrument(paramsBuilder());
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
snapshotAvailable(snapshot) {
|
|
1742
|
+
return this.environment.snapshotAvailable(snapshot);
|
|
1743
|
+
}
|
|
1744
|
+
withContext(adapter, options = {}) {
|
|
1745
|
+
return this.environment.withContext(adapter, options);
|
|
1746
|
+
}
|
|
1747
|
+
resolvePendingSnapshot(snapshot) {
|
|
1748
|
+
return this.environment.resolvePendingSnapshot(snapshot);
|
|
1749
|
+
}
|
|
1750
|
+
publishStoreMetadata(key, storeMetadata) {
|
|
1751
|
+
return this.environment.publishStoreMetadata(key, storeMetadata);
|
|
1752
|
+
}
|
|
1753
|
+
storeSetTTLOverride(namespace, representationName, ttl) {
|
|
1754
|
+
this.environment.storeSetTTLOverride(namespace, representationName, ttl);
|
|
1755
|
+
}
|
|
1756
|
+
storeSetDefaultTTLOverride(ttl) {
|
|
1757
|
+
this.environment.storeSetDefaultTTLOverride(ttl);
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
exports.Environment = Environment;
|
|
1761
|
+
exports.GraphNode = GraphNode;
|
|
1762
|
+
exports.Luvio = Luvio;
|
|
1763
|
+
exports.Reader = Reader;
|
|
1764
|
+
exports.Store = Store;
|
|
1765
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
1766
|
+
});
|