@luvio/lwc-luvio 0.138.1 → 0.138.2

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.
Files changed (40) hide show
  1. package/dist/es/es2018/lwcluvio.js +521 -521
  2. package/dist/es/es2018/{LWCGraphQLLuvioWireAdapter.d.ts → types/LWCGraphQLLuvioWireAdapter.d.ts} +56 -56
  3. package/dist/{umd/es2018 → es/es2018/types}/LWCInfiniteScrollingLuvioWireAdapter.d.ts +26 -26
  4. package/dist/{umd/es2018 → es/es2018/types}/LWCLuvioBindings.d.ts +4 -4
  5. package/dist/{umd/es5 → es/es2018/types}/LWCLuvioWireAdapter.d.ts +64 -64
  6. package/dist/es/es2018/{main.d.ts → types/main.d.ts} +8 -8
  7. package/dist/es/es2018/{utils → types/utils}/SnapshotState.d.ts +12 -12
  8. package/dist/es/es2018/{utils → types/utils}/constants.d.ts +5 -5
  9. package/dist/es/es2018/{utils → types/utils}/dataToTupleWeakMap.d.ts +2 -2
  10. package/dist/es/es2018/{utils → types/utils}/isPromise.d.ts +1 -1
  11. package/dist/es/es2018/{utils → types/utils}/language.d.ts +14 -14
  12. package/dist/{umd/es2018 → es/es2018/types}/utils/sanitize.d.ts +9 -9
  13. package/dist/{umd/es5 → es/es2018/types}/utils/throwAnnotatedError.d.ts +7 -7
  14. package/dist/umd/es2018/lwcluvio.js +521 -521
  15. package/dist/umd/{es5 → es2018/types}/LWCGraphQLLuvioWireAdapter.d.ts +56 -56
  16. package/dist/{es/es2018 → umd/es2018/types}/LWCInfiniteScrollingLuvioWireAdapter.d.ts +26 -26
  17. package/dist/umd/{es5 → es2018/types}/LWCLuvioBindings.d.ts +4 -4
  18. package/dist/umd/es2018/{LWCLuvioWireAdapter.d.ts → types/LWCLuvioWireAdapter.d.ts} +64 -64
  19. package/dist/umd/es2018/{main.d.ts → types/main.d.ts} +8 -8
  20. package/dist/umd/{es5 → es2018/types}/utils/SnapshotState.d.ts +12 -12
  21. package/dist/umd/es2018/{utils → types/utils}/constants.d.ts +5 -5
  22. package/dist/umd/es2018/{utils → types/utils}/dataToTupleWeakMap.d.ts +2 -2
  23. package/dist/umd/es2018/{utils → types/utils}/isPromise.d.ts +1 -1
  24. package/dist/umd/es2018/{utils → types/utils}/language.d.ts +14 -14
  25. package/dist/{es/es2018 → umd/es2018/types}/utils/sanitize.d.ts +9 -9
  26. package/dist/{es/es2018 → umd/es2018/types}/utils/throwAnnotatedError.d.ts +7 -7
  27. package/dist/umd/es5/lwcluvio.js +541 -541
  28. package/dist/umd/{es2018 → es5/types}/LWCGraphQLLuvioWireAdapter.d.ts +56 -56
  29. package/dist/umd/es5/{LWCInfiniteScrollingLuvioWireAdapter.d.ts → types/LWCInfiniteScrollingLuvioWireAdapter.d.ts} +26 -26
  30. package/dist/{es/es2018 → umd/es5/types}/LWCLuvioBindings.d.ts +4 -4
  31. package/dist/{es/es2018 → umd/es5/types}/LWCLuvioWireAdapter.d.ts +64 -64
  32. package/dist/umd/es5/{main.d.ts → types/main.d.ts} +8 -8
  33. package/dist/umd/{es2018 → es5/types}/utils/SnapshotState.d.ts +12 -12
  34. package/dist/umd/es5/{utils → types/utils}/constants.d.ts +5 -5
  35. package/dist/umd/es5/{utils → types/utils}/dataToTupleWeakMap.d.ts +2 -2
  36. package/dist/umd/es5/{utils → types/utils}/isPromise.d.ts +1 -1
  37. package/dist/umd/es5/{utils → types/utils}/language.d.ts +14 -14
  38. package/dist/umd/es5/{utils → types/utils}/sanitize.d.ts +9 -9
  39. package/dist/umd/{es2018 → es5/types}/utils/throwAnnotatedError.d.ts +7 -7
  40. package/package.json +7 -7
@@ -4,360 +4,360 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.lwcLuvio = {}, global.LWC));
5
5
  })(this, (function (exports, lwc) { 'use strict';
6
6
 
7
- // instrumentation keys to be imported by ldsInstrumentation
8
- var REFRESH_ADAPTER_EVENT = 'refresh-adapter-event';
9
- var ADAPTER_UNFULFILLED_ERROR = 'adapter-unfulfilled-error';
10
- var USERLAND_PROVISION_ERROR_MESSAGE = "LWC component's @wire target property or method threw an error during value provisioning. Original error:";
11
- var ADAPTER_SNAPSHOT_REJECTED_MESSAGE = 'Luvio wire adapter Promise<Snapshot> rejected. Original error:';
7
+ // instrumentation keys to be imported by ldsInstrumentation
8
+ var REFRESH_ADAPTER_EVENT = 'refresh-adapter-event';
9
+ var ADAPTER_UNFULFILLED_ERROR = 'adapter-unfulfilled-error';
10
+ var USERLAND_PROVISION_ERROR_MESSAGE = "LWC component's @wire target property or method threw an error during value provisioning. Original error:";
11
+ var ADAPTER_SNAPSHOT_REJECTED_MESSAGE = 'Luvio wire adapter Promise<Snapshot> rejected. Original error:';
12
12
  var USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE = 'Use `gql` parser to parse your "query" string';
13
13
 
14
- // map of emitted object -> [ adapter name, snapshot ]; snapshot is only undefined for the
15
- // initially-emitted { data: undefined, error: undefined } value
14
+ // map of emitted object -> [ adapter name, snapshot ]; snapshot is only undefined for the
15
+ // initially-emitted { data: undefined, error: undefined } value
16
16
  var dataToTupleWeakMap = new WeakMap();
17
17
 
18
- var SnapshotState;
19
- (function (SnapshotState) {
20
- SnapshotState["Fulfilled"] = "Fulfilled";
21
- SnapshotState["Unfulfilled"] = "Unfulfilled";
22
- SnapshotState["Error"] = "Error";
23
- SnapshotState["Pending"] = "Pending";
24
- SnapshotState["Stale"] = "Stale";
25
- })(SnapshotState || (SnapshotState = {}));
26
- function isErrorSnapshot(snapshot) {
27
- return snapshot.state === SnapshotState.Error;
28
- }
29
- function isFulfilledSnapshot(snapshot) {
30
- return snapshot.state === SnapshotState.Fulfilled;
31
- }
32
- function isStaleSnapshot(snapshot) {
33
- return snapshot.state === SnapshotState.Stale;
34
- }
35
- function isUnfulfilledSnapshot(snapshot) {
36
- return snapshot.state === SnapshotState.Unfulfilled;
37
- }
38
- /**
39
- * Transform a Snapshot into a payload suitable for passing to a DataCallback.
40
- *
41
- * @param snapshot Snapshot
42
- */
43
- function snapshotToPayload$1(snapshot) {
44
- if (snapshot === undefined) {
45
- return {
46
- data: undefined,
47
- error: undefined,
48
- };
49
- }
50
- if (isErrorSnapshot(snapshot)) {
51
- return {
52
- data: undefined,
53
- error: snapshot.error,
54
- };
55
- }
56
- // fulfilled or stale
57
- return {
58
- data: snapshot.data,
59
- error: undefined,
60
- };
18
+ var SnapshotState;
19
+ (function (SnapshotState) {
20
+ SnapshotState["Fulfilled"] = "Fulfilled";
21
+ SnapshotState["Unfulfilled"] = "Unfulfilled";
22
+ SnapshotState["Error"] = "Error";
23
+ SnapshotState["Pending"] = "Pending";
24
+ SnapshotState["Stale"] = "Stale";
25
+ })(SnapshotState || (SnapshotState = {}));
26
+ function isErrorSnapshot(snapshot) {
27
+ return snapshot.state === SnapshotState.Error;
28
+ }
29
+ function isFulfilledSnapshot(snapshot) {
30
+ return snapshot.state === SnapshotState.Fulfilled;
31
+ }
32
+ function isStaleSnapshot(snapshot) {
33
+ return snapshot.state === SnapshotState.Stale;
34
+ }
35
+ function isUnfulfilledSnapshot(snapshot) {
36
+ return snapshot.state === SnapshotState.Unfulfilled;
37
+ }
38
+ /**
39
+ * Transform a Snapshot into a payload suitable for passing to a DataCallback.
40
+ *
41
+ * @param snapshot Snapshot
42
+ */
43
+ function snapshotToPayload$1(snapshot) {
44
+ if (snapshot === undefined) {
45
+ return {
46
+ data: undefined,
47
+ error: undefined,
48
+ };
49
+ }
50
+ if (isErrorSnapshot(snapshot)) {
51
+ return {
52
+ data: undefined,
53
+ error: snapshot.error,
54
+ };
55
+ }
56
+ // fulfilled or stale
57
+ return {
58
+ data: snapshot.data,
59
+ error: undefined,
60
+ };
61
61
  }
62
62
 
63
- function bindWireRefresh(luvio) {
64
- return function refresh(data) {
65
- return refreshData(data, dataToTupleWeakMap, luvio);
66
- };
67
- }
68
- function refreshData(data, dataToTuple, luvio) {
69
- var tuple = dataToTuple.get(lwc.unwrap(data));
70
- if (tuple === undefined) {
71
- if (process.env.NODE_ENV !== 'production') {
72
- throw new Error('Refresh failed because resolved configuration is not available.');
73
- }
74
- return;
75
- }
76
- var adapterName = tuple[0], snapshot = tuple[1];
77
- luvio.instrument(function () {
78
- var _a;
79
- return _a = {},
80
- _a[REFRESH_ADAPTER_EVENT] = true,
81
- _a.adapterName = adapterName,
82
- _a;
83
- });
84
- // snapshot is undefined when a caller refreshes the initial
85
- // { data: undefined, error: undefined } object that we emitted
86
- if (snapshot === undefined) {
87
- return Promise.resolve(undefined);
88
- }
89
- return luvio.refreshSnapshot(snapshot).then(function (refreshed) {
90
- if (isErrorSnapshot(refreshed)) {
91
- throw refreshed.error;
92
- }
93
- if (process.env.NODE_ENV !== 'production') {
94
- if (isUnfulfilledSnapshot(refreshed)) {
95
- throw new Error('Refresh resulted in unfulfilled snapshot');
96
- }
97
- }
98
- return undefined;
99
- });
63
+ function bindWireRefresh(luvio) {
64
+ return function refresh(data) {
65
+ return refreshData(data, dataToTupleWeakMap, luvio);
66
+ };
67
+ }
68
+ function refreshData(data, dataToTuple, luvio) {
69
+ var tuple = dataToTuple.get(lwc.unwrap(data));
70
+ if (tuple === undefined) {
71
+ if (process.env.NODE_ENV !== 'production') {
72
+ throw new Error('Refresh failed because resolved configuration is not available.');
73
+ }
74
+ return;
75
+ }
76
+ var adapterName = tuple[0], snapshot = tuple[1];
77
+ luvio.instrument(function () {
78
+ var _a;
79
+ return _a = {},
80
+ _a[REFRESH_ADAPTER_EVENT] = true,
81
+ _a.adapterName = adapterName,
82
+ _a;
83
+ });
84
+ // snapshot is undefined when a caller refreshes the initial
85
+ // { data: undefined, error: undefined } object that we emitted
86
+ if (snapshot === undefined) {
87
+ return Promise.resolve(undefined);
88
+ }
89
+ return luvio.refreshSnapshot(snapshot).then(function (refreshed) {
90
+ if (isErrorSnapshot(refreshed)) {
91
+ throw refreshed.error;
92
+ }
93
+ if (process.env.NODE_ENV !== 'production') {
94
+ if (isUnfulfilledSnapshot(refreshed)) {
95
+ throw new Error('Refresh resulted in unfulfilled snapshot');
96
+ }
97
+ }
98
+ return undefined;
99
+ });
100
100
  }
101
101
 
102
- var keys = Object.keys;
103
- var isArray = Array.isArray;
102
+ var keys = Object.keys;
103
+ var isArray = Array.isArray;
104
104
  var stringify = JSON.stringify;
105
105
 
106
- function isPromise(value) {
107
- // check for Thenable due to test frameworks using custom Promise impls
108
- return value.then !== undefined;
106
+ function isPromise(value) {
107
+ // check for Thenable due to test frameworks using custom Promise impls
108
+ return value.then !== undefined;
109
109
  }
110
110
 
111
- /**
112
- * (Re)throws an error after adding a prefix to the message.
113
- *
114
- * @param error Error
115
- * @param messagePrefix prefix to add to error's message
116
- */
117
- function throwAnnotatedError(error, messagePrefix) {
118
- if (error instanceof Error) {
119
- error.message = "".concat(messagePrefix, "\n[").concat(error.message, "]");
120
- throw error;
121
- }
122
- throw new Error("".concat(messagePrefix, "\n[").concat(stringify(error), "]"));
111
+ /**
112
+ * (Re)throws an error after adding a prefix to the message.
113
+ *
114
+ * @param error Error
115
+ * @param messagePrefix prefix to add to error's message
116
+ */
117
+ function throwAnnotatedError(error, messagePrefix) {
118
+ if (error instanceof Error) {
119
+ error.message = "".concat(messagePrefix, "\n[").concat(error.message, "]");
120
+ throw error;
121
+ }
122
+ throw new Error("".concat(messagePrefix, "\n[").concat(stringify(error), "]"));
123
123
  }
124
124
 
125
- var Sanitizer = /** @class */ (function () {
126
- function Sanitizer(obj) {
127
- this.obj = obj;
128
- this.copy = {};
129
- this.currentPath = {
130
- key: '',
131
- value: obj,
132
- parent: null,
133
- data: this.copy,
134
- };
135
- }
136
- Sanitizer.prototype.sanitize = function () {
137
- var sanitizer = this;
138
- stringify(this.obj, function (key, value) {
139
- if (key === '') {
140
- return value;
141
- }
142
- var parent = this;
143
- if (parent !== sanitizer.currentPath.value) {
144
- sanitizer.exit(parent);
145
- }
146
- if (typeof value === 'object' && value !== null) {
147
- sanitizer.enter(key, value);
148
- return value;
149
- }
150
- sanitizer.currentPath.data[key] = value;
151
- return value;
152
- });
153
- return this.copy;
154
- };
155
- Sanitizer.prototype.enter = function (key, value) {
156
- var parentPath = this.currentPath;
157
- var data = (parentPath.data[key] = isArray(value) ? [] : {});
158
- this.currentPath = {
159
- key: key,
160
- value: value,
161
- parent: parentPath,
162
- data: data,
163
- };
164
- };
165
- Sanitizer.prototype.exit = function (parent) {
166
- while (this.currentPath.value !== parent) {
167
- this.currentPath = this.currentPath.parent || this.currentPath;
168
- }
169
- };
170
- return Sanitizer;
171
- }());
172
- /**
173
- * Returns a sanitized version of an object by recursively unwrapping the Proxies.
174
- *
175
- * In order to keep luvio performance optimal on IE11, we need to make sure that luvio code gets
176
- * transformed by the es5-proxy-compat. At the same time we need to ensure that no ProxyCompat leaks
177
- * into the luvio engine code nor into the adapters. All the data coming from LWC-land need to be
178
- * sanitized first.
179
- */
180
- function sanitize(obj) {
181
- return new Sanitizer(obj).sanitize();
125
+ var Sanitizer = /** @class */ (function () {
126
+ function Sanitizer(obj) {
127
+ this.obj = obj;
128
+ this.copy = {};
129
+ this.currentPath = {
130
+ key: '',
131
+ value: obj,
132
+ parent: null,
133
+ data: this.copy,
134
+ };
135
+ }
136
+ Sanitizer.prototype.sanitize = function () {
137
+ var sanitizer = this;
138
+ stringify(this.obj, function (key, value) {
139
+ if (key === '') {
140
+ return value;
141
+ }
142
+ var parent = this;
143
+ if (parent !== sanitizer.currentPath.value) {
144
+ sanitizer.exit(parent);
145
+ }
146
+ if (typeof value === 'object' && value !== null) {
147
+ sanitizer.enter(key, value);
148
+ return value;
149
+ }
150
+ sanitizer.currentPath.data[key] = value;
151
+ return value;
152
+ });
153
+ return this.copy;
154
+ };
155
+ Sanitizer.prototype.enter = function (key, value) {
156
+ var parentPath = this.currentPath;
157
+ var data = (parentPath.data[key] = isArray(value) ? [] : {});
158
+ this.currentPath = {
159
+ key: key,
160
+ value: value,
161
+ parent: parentPath,
162
+ data: data,
163
+ };
164
+ };
165
+ Sanitizer.prototype.exit = function (parent) {
166
+ while (this.currentPath.value !== parent) {
167
+ this.currentPath = this.currentPath.parent || this.currentPath;
168
+ }
169
+ };
170
+ return Sanitizer;
171
+ }());
172
+ /**
173
+ * Returns a sanitized version of an object by recursively unwrapping the Proxies.
174
+ *
175
+ * In order to keep luvio performance optimal on IE11, we need to make sure that luvio code gets
176
+ * transformed by the es5-proxy-compat. At the same time we need to ensure that no ProxyCompat leaks
177
+ * into the luvio engine code nor into the adapters. All the data coming from LWC-land need to be
178
+ * sanitized first.
179
+ */
180
+ function sanitize(obj) {
181
+ return new Sanitizer(obj).sanitize();
182
182
  }
183
183
 
184
- var LWCLuvioWireAdapter = /** @class */ (function () {
185
- /**
186
- * Constructs a new wire adapter instance for the given adapter.
187
- *
188
- * @param callback callback to be invoked with new values
189
- */
190
- function LWCLuvioWireAdapter(adapter, name, luvio, callback) {
191
- // a component can be connected-disconnected-reconnected multiple times during its
192
- // life but we only want to keep subscriptions active while it is connected; the
193
- // connect/disconnect methods below keep this value updated to reflect the current
194
- // state
195
- this.connected = false;
196
- this.adapter = adapter;
197
- this.name = name;
198
- this.luvio = luvio;
199
- this.callback = callback;
200
- // initialize the wired property with a properly shaped object so cmps can use <template if:true={wiredProperty.data}>
201
- this.emit();
202
- }
203
- // WireAdapter interface methods
204
- /**
205
- * Called when the component associated with the wire adapter is connected.
206
- */
207
- LWCLuvioWireAdapter.prototype.connect = function () {
208
- this.connected = true;
209
- this.callAdapter();
210
- };
211
- /**
212
- * Called when the component associated with the wire adapter is disconnected.
213
- */
214
- LWCLuvioWireAdapter.prototype.disconnect = function () {
215
- this.unsubscribe();
216
- this.connected = false;
217
- };
218
- /**
219
- * Called when new or updated config is supplied to the wire adapter.
220
- *
221
- * @param config new config parameters for the wire adapter
222
- * @param _context not used
223
- */
224
- LWCLuvioWireAdapter.prototype.update = function (config, _context) {
225
- this.unsubscribe();
226
- this.config = sanitize(config);
227
- this.callAdapter();
228
- };
229
- // private and protected utility methods
230
- /**
231
- * Calls the adapter if config has been set and the component is connected.
232
- */
233
- LWCLuvioWireAdapter.prototype.callAdapter = function () {
234
- if (!this.connected || this.config === undefined) {
235
- return;
236
- }
237
- var snapshotOrPromise = this.adapter(this.config);
238
- this.processAdapterResponse(snapshotOrPromise);
239
- };
240
- LWCLuvioWireAdapter.prototype.processAdapterResponse = function (snapshotOrPromise) {
241
- var _this = this;
242
- // insufficient config, wait for new config from component
243
- if (snapshotOrPromise === null) {
244
- return;
245
- }
246
- var configForSnapshot = this.config;
247
- var emitAndSubscribe = function (snapshot) {
248
- // adapters leveraging adapter context could asynchronously
249
- // return null (due to invalid config)
250
- if (snapshot === null) {
251
- return;
252
- }
253
- // We should never broadcast an unfulfilled snapshot to a component
254
- if (isUnfulfilledSnapshot(snapshot)) {
255
- if (process.env.NODE_ENV !== 'production') {
256
- throw new Error("Unfulfilled snapshot emitted to component from subscription, missingPaths: ".concat(keys(snapshot.missingPaths)));
257
- }
258
- // Instrument as a failed request
259
- _this.luvio.instrument(function () {
260
- var _a;
261
- return _a = {},
262
- _a[ADAPTER_UNFULFILLED_ERROR] = true,
263
- _a.adapterName = _this.adapter.name,
264
- _a.missingPaths = snapshot.missingPaths,
265
- _a.missingLinks = snapshot.missingLinks,
266
- _a;
267
- });
268
- return;
269
- }
270
- // if config has changed before the snapshot arrives then ignore snapshot
271
- if (_this.config !== configForSnapshot) {
272
- return;
273
- }
274
- // emit unless snapshot is pending
275
- if (isFulfilledSnapshot(snapshot) ||
276
- isErrorSnapshot(snapshot) ||
277
- isStaleSnapshot(snapshot)) {
278
- _this.emit(snapshot);
279
- }
280
- // subscribe to the new snapshot
281
- _this.subscribe(snapshot);
282
- };
283
- // Data resolved sync
284
- if (!isPromise(snapshotOrPromise)) {
285
- emitAndSubscribe(snapshotOrPromise);
286
- }
287
- else {
288
- // We want to let errors from this promise propagate to the app container,
289
- // which is why we do not have a reject handler here.
290
- // If an error is thrown here, it means that there was an error somewhere
291
- // inside an adapter which means that there was a mistake by the implementor.
292
- // Errors that come from the network should never hit this block because
293
- // they are treated like regular snapshots, not true error paths.
294
- snapshotOrPromise.then(emitAndSubscribe, function (error) {
295
- return throwAnnotatedError(error, ADAPTER_SNAPSHOT_REJECTED_MESSAGE);
296
- });
297
- }
298
- };
299
- /**
300
- * Emits new values to the callback.
301
- *
302
- * @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
303
- */
304
- LWCLuvioWireAdapter.prototype.emit = function (snapshot) {
305
- var payload = snapshotToPayload$1(snapshot);
306
- dataToTupleWeakMap.set(payload, [this.name, snapshot]);
307
- try {
308
- this.callback(payload);
309
- }
310
- catch (error) {
311
- if (error instanceof Error) {
312
- throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
313
- }
314
- }
315
- };
316
- /**
317
- * Subscribes this wire adapter to future changes to the specified snapshot. Any changes
318
- * to the snapshot will be automatically emitted to the component.
319
- *
320
- * @param snapshot Snapshot
321
- * @param subscriptionCallback callback
322
- */
323
- LWCLuvioWireAdapter.prototype.subscribe = function (snapshot) {
324
- // always clean up any old subscription that we might have
325
- this.unsubscribe();
326
- // but only subscribe if component is currently connected
327
- if (this.connected) {
328
- this.unsubscriber = this.luvio.storeSubscribe(snapshot, this.emit.bind(this));
329
- }
330
- };
331
- /**
332
- * Deletes this wire adapter's snapshot subscription (if any).
333
- */
334
- LWCLuvioWireAdapter.prototype.unsubscribe = function () {
335
- // clean up subscription
336
- if (this.unsubscriber !== undefined) {
337
- this.unsubscriber();
338
- this.unsubscriber = undefined;
339
- }
340
- };
341
- return LWCLuvioWireAdapter;
342
- }());
343
- /**
344
- * Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
345
- *
346
- * @param adapter Adapter
347
- * @param name name to assign to the generated constructor
348
- * @param luvio Luvio
349
- */
350
- function createWireAdapterConstructor(adapter, name, luvio) {
351
- var constructor = function (callback) {
352
- var delegate = new LWCLuvioWireAdapter(adapter, name, luvio, callback);
353
- this.connect = function () { return delegate.connect(); };
354
- this.disconnect = function () { return delegate.disconnect(); };
355
- this.update = function (config, context) {
356
- return delegate.update(config, context);
357
- };
358
- };
359
- Object.defineProperty(constructor, 'name', { value: name });
360
- return constructor;
184
+ var LWCLuvioWireAdapter = /** @class */ (function () {
185
+ /**
186
+ * Constructs a new wire adapter instance for the given adapter.
187
+ *
188
+ * @param callback callback to be invoked with new values
189
+ */
190
+ function LWCLuvioWireAdapter(adapter, name, luvio, callback) {
191
+ // a component can be connected-disconnected-reconnected multiple times during its
192
+ // life but we only want to keep subscriptions active while it is connected; the
193
+ // connect/disconnect methods below keep this value updated to reflect the current
194
+ // state
195
+ this.connected = false;
196
+ this.adapter = adapter;
197
+ this.name = name;
198
+ this.luvio = luvio;
199
+ this.callback = callback;
200
+ // initialize the wired property with a properly shaped object so cmps can use <template if:true={wiredProperty.data}>
201
+ this.emit();
202
+ }
203
+ // WireAdapter interface methods
204
+ /**
205
+ * Called when the component associated with the wire adapter is connected.
206
+ */
207
+ LWCLuvioWireAdapter.prototype.connect = function () {
208
+ this.connected = true;
209
+ this.callAdapter();
210
+ };
211
+ /**
212
+ * Called when the component associated with the wire adapter is disconnected.
213
+ */
214
+ LWCLuvioWireAdapter.prototype.disconnect = function () {
215
+ this.unsubscribe();
216
+ this.connected = false;
217
+ };
218
+ /**
219
+ * Called when new or updated config is supplied to the wire adapter.
220
+ *
221
+ * @param config new config parameters for the wire adapter
222
+ * @param _context not used
223
+ */
224
+ LWCLuvioWireAdapter.prototype.update = function (config, _context) {
225
+ this.unsubscribe();
226
+ this.config = sanitize(config);
227
+ this.callAdapter();
228
+ };
229
+ // private and protected utility methods
230
+ /**
231
+ * Calls the adapter if config has been set and the component is connected.
232
+ */
233
+ LWCLuvioWireAdapter.prototype.callAdapter = function () {
234
+ if (!this.connected || this.config === undefined) {
235
+ return;
236
+ }
237
+ var snapshotOrPromise = this.adapter(this.config);
238
+ this.processAdapterResponse(snapshotOrPromise);
239
+ };
240
+ LWCLuvioWireAdapter.prototype.processAdapterResponse = function (snapshotOrPromise) {
241
+ var _this = this;
242
+ // insufficient config, wait for new config from component
243
+ if (snapshotOrPromise === null) {
244
+ return;
245
+ }
246
+ var configForSnapshot = this.config;
247
+ var emitAndSubscribe = function (snapshot) {
248
+ // adapters leveraging adapter context could asynchronously
249
+ // return null (due to invalid config)
250
+ if (snapshot === null) {
251
+ return;
252
+ }
253
+ // We should never broadcast an unfulfilled snapshot to a component
254
+ if (isUnfulfilledSnapshot(snapshot)) {
255
+ if (process.env.NODE_ENV !== 'production') {
256
+ throw new Error("Unfulfilled snapshot emitted to component from subscription, missingPaths: ".concat(keys(snapshot.missingPaths)));
257
+ }
258
+ // Instrument as a failed request
259
+ _this.luvio.instrument(function () {
260
+ var _a;
261
+ return _a = {},
262
+ _a[ADAPTER_UNFULFILLED_ERROR] = true,
263
+ _a.adapterName = _this.adapter.name,
264
+ _a.missingPaths = snapshot.missingPaths,
265
+ _a.missingLinks = snapshot.missingLinks,
266
+ _a;
267
+ });
268
+ return;
269
+ }
270
+ // if config has changed before the snapshot arrives then ignore snapshot
271
+ if (_this.config !== configForSnapshot) {
272
+ return;
273
+ }
274
+ // emit unless snapshot is pending
275
+ if (isFulfilledSnapshot(snapshot) ||
276
+ isErrorSnapshot(snapshot) ||
277
+ isStaleSnapshot(snapshot)) {
278
+ _this.emit(snapshot);
279
+ }
280
+ // subscribe to the new snapshot
281
+ _this.subscribe(snapshot);
282
+ };
283
+ // Data resolved sync
284
+ if (!isPromise(snapshotOrPromise)) {
285
+ emitAndSubscribe(snapshotOrPromise);
286
+ }
287
+ else {
288
+ // We want to let errors from this promise propagate to the app container,
289
+ // which is why we do not have a reject handler here.
290
+ // If an error is thrown here, it means that there was an error somewhere
291
+ // inside an adapter which means that there was a mistake by the implementor.
292
+ // Errors that come from the network should never hit this block because
293
+ // they are treated like regular snapshots, not true error paths.
294
+ snapshotOrPromise.then(emitAndSubscribe, function (error) {
295
+ return throwAnnotatedError(error, ADAPTER_SNAPSHOT_REJECTED_MESSAGE);
296
+ });
297
+ }
298
+ };
299
+ /**
300
+ * Emits new values to the callback.
301
+ *
302
+ * @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
303
+ */
304
+ LWCLuvioWireAdapter.prototype.emit = function (snapshot) {
305
+ var payload = snapshotToPayload$1(snapshot);
306
+ dataToTupleWeakMap.set(payload, [this.name, snapshot]);
307
+ try {
308
+ this.callback(payload);
309
+ }
310
+ catch (error) {
311
+ if (error instanceof Error) {
312
+ throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
313
+ }
314
+ }
315
+ };
316
+ /**
317
+ * Subscribes this wire adapter to future changes to the specified snapshot. Any changes
318
+ * to the snapshot will be automatically emitted to the component.
319
+ *
320
+ * @param snapshot Snapshot
321
+ * @param subscriptionCallback callback
322
+ */
323
+ LWCLuvioWireAdapter.prototype.subscribe = function (snapshot) {
324
+ // always clean up any old subscription that we might have
325
+ this.unsubscribe();
326
+ // but only subscribe if component is currently connected
327
+ if (this.connected) {
328
+ this.unsubscriber = this.luvio.storeSubscribe(snapshot, this.emit.bind(this));
329
+ }
330
+ };
331
+ /**
332
+ * Deletes this wire adapter's snapshot subscription (if any).
333
+ */
334
+ LWCLuvioWireAdapter.prototype.unsubscribe = function () {
335
+ // clean up subscription
336
+ if (this.unsubscriber !== undefined) {
337
+ this.unsubscriber();
338
+ this.unsubscriber = undefined;
339
+ }
340
+ };
341
+ return LWCLuvioWireAdapter;
342
+ }());
343
+ /**
344
+ * Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
345
+ *
346
+ * @param adapter Adapter
347
+ * @param name name to assign to the generated constructor
348
+ * @param luvio Luvio
349
+ */
350
+ function createWireAdapterConstructor(adapter, name, luvio) {
351
+ var constructor = function (callback) {
352
+ var delegate = new LWCLuvioWireAdapter(adapter, name, luvio, callback);
353
+ this.connect = function () { return delegate.connect(); };
354
+ this.disconnect = function () { return delegate.disconnect(); };
355
+ this.update = function (config, context) {
356
+ return delegate.update(config, context);
357
+ };
358
+ };
359
+ Object.defineProperty(constructor, 'name', { value: name });
360
+ return constructor;
361
361
  }
362
362
 
363
363
  /******************************************************************************
@@ -402,211 +402,211 @@
402
402
  return __assign.apply(this, arguments);
403
403
  };
404
404
 
405
- var LWCInfinteScrollingLuvioWireAdapter = /** @class */ (function (_super) {
406
- __extends(LWCInfinteScrollingLuvioWireAdapter, _super);
407
- function LWCInfinteScrollingLuvioWireAdapter() {
408
- return _super !== null && _super.apply(this, arguments) || this;
409
- }
410
- /**
411
- * Called when the component associated with the wire adapter is connected.
412
- */
413
- LWCInfinteScrollingLuvioWireAdapter.prototype.connect = function () {
414
- this.connectTimestamp = Date.now();
415
- _super.prototype.connect.call(this);
416
- };
417
- /**
418
- * Called when the component associated with the wire adapter is disconnected.
419
- */
420
- LWCInfinteScrollingLuvioWireAdapter.prototype.disconnect = function () {
421
- this.connectTimestamp = undefined;
422
- _super.prototype.disconnect.call(this);
423
- };
424
- /**
425
- * Called when new or updated config is supplied to the wire adapter.
426
- *
427
- * @param config new config parameters for the wire adapter
428
- * @param context context for the wire adapter
429
- */
430
- LWCInfinteScrollingLuvioWireAdapter.prototype.update = function (config, context) {
431
- if (this.connectTimestamp) {
432
- var mergedContext = Object.assign({
433
- cachePolicy: {
434
- type: 'valid-at',
435
- timestamp: this.connectTimestamp,
436
- },
437
- }, context);
438
- _super.prototype.unsubscribe.call(this);
439
- this.config = sanitize(config);
440
- this.callAdapterWithContext(mergedContext);
441
- }
442
- else {
443
- _super.prototype.update.call(this, config, context);
444
- }
445
- };
446
- /**
447
- * Calls the adapter if config has been set and the component is connected.
448
- */
449
- LWCInfinteScrollingLuvioWireAdapter.prototype.callAdapterWithContext = function (context) {
450
- if (!this.connected || this.config === undefined) {
451
- return;
452
- }
453
- var snapshotOrPromise = this.adapter(this.config, context);
454
- _super.prototype.processAdapterResponse.call(this, snapshotOrPromise);
455
- };
456
- return LWCInfinteScrollingLuvioWireAdapter;
457
- }(LWCLuvioWireAdapter));
458
- function createInfiniteScrollingWireAdapterConstructor(adapter, name, luvio) {
459
- var constructor = function (callback) {
460
- var delegate = new LWCInfinteScrollingLuvioWireAdapter(adapter, name, luvio, callback);
461
- this.connect = function () { return delegate.connect(); };
462
- this.disconnect = function () { return delegate.disconnect(); };
463
- this.update = function (config, context) {
464
- return delegate.update(config, context);
465
- };
466
- };
467
- Object.defineProperty(constructor, 'name', { value: name });
468
- return constructor;
405
+ var LWCInfinteScrollingLuvioWireAdapter = /** @class */ (function (_super) {
406
+ __extends(LWCInfinteScrollingLuvioWireAdapter, _super);
407
+ function LWCInfinteScrollingLuvioWireAdapter() {
408
+ return _super !== null && _super.apply(this, arguments) || this;
409
+ }
410
+ /**
411
+ * Called when the component associated with the wire adapter is connected.
412
+ */
413
+ LWCInfinteScrollingLuvioWireAdapter.prototype.connect = function () {
414
+ this.connectTimestamp = Date.now();
415
+ _super.prototype.connect.call(this);
416
+ };
417
+ /**
418
+ * Called when the component associated with the wire adapter is disconnected.
419
+ */
420
+ LWCInfinteScrollingLuvioWireAdapter.prototype.disconnect = function () {
421
+ this.connectTimestamp = undefined;
422
+ _super.prototype.disconnect.call(this);
423
+ };
424
+ /**
425
+ * Called when new or updated config is supplied to the wire adapter.
426
+ *
427
+ * @param config new config parameters for the wire adapter
428
+ * @param context context for the wire adapter
429
+ */
430
+ LWCInfinteScrollingLuvioWireAdapter.prototype.update = function (config, context) {
431
+ if (this.connectTimestamp) {
432
+ var mergedContext = Object.assign({
433
+ cachePolicy: {
434
+ type: 'valid-at',
435
+ timestamp: this.connectTimestamp,
436
+ },
437
+ }, context);
438
+ _super.prototype.unsubscribe.call(this);
439
+ this.config = sanitize(config);
440
+ this.callAdapterWithContext(mergedContext);
441
+ }
442
+ else {
443
+ _super.prototype.update.call(this, config, context);
444
+ }
445
+ };
446
+ /**
447
+ * Calls the adapter if config has been set and the component is connected.
448
+ */
449
+ LWCInfinteScrollingLuvioWireAdapter.prototype.callAdapterWithContext = function (context) {
450
+ if (!this.connected || this.config === undefined) {
451
+ return;
452
+ }
453
+ var snapshotOrPromise = this.adapter(this.config, context);
454
+ _super.prototype.processAdapterResponse.call(this, snapshotOrPromise);
455
+ };
456
+ return LWCInfinteScrollingLuvioWireAdapter;
457
+ }(LWCLuvioWireAdapter));
458
+ function createInfiniteScrollingWireAdapterConstructor(adapter, name, luvio) {
459
+ var constructor = function (callback) {
460
+ var delegate = new LWCInfinteScrollingLuvioWireAdapter(adapter, name, luvio, callback);
461
+ this.connect = function () { return delegate.connect(); };
462
+ this.disconnect = function () { return delegate.disconnect(); };
463
+ this.update = function (config, context) {
464
+ return delegate.update(config, context);
465
+ };
466
+ };
467
+ Object.defineProperty(constructor, 'name', { value: name });
468
+ return constructor;
469
469
  }
470
470
 
471
- function snapshotToPayload(snapshot) {
472
- var payload = {
473
- data: undefined,
474
- errors: undefined,
475
- };
476
- if (snapshot === undefined) {
477
- return payload;
478
- }
479
- payload.data = extractSnapshotData(snapshot);
480
- // TODO handle batch error scenarios.
481
- if ('error' in snapshot && snapshot.error !== undefined) {
482
- if (Array.isArray(snapshot.error)) {
483
- payload.errors = snapshot.error;
484
- }
485
- else {
486
- payload.errors = [snapshot.error];
487
- }
488
- }
489
- return payload;
490
- }
491
- var LWCGraphQLLuvioWireAdapter = /** @class */ (function (_super) {
492
- __extends(LWCGraphQLLuvioWireAdapter, _super);
493
- function LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback) {
494
- var _this = _super.call(this, adapter, name, luvio, callback) || this;
495
- _this.astResolver = astResolver;
496
- return _this;
497
- }
498
- LWCGraphQLLuvioWireAdapter.prototype.update = function (config, _context) {
499
- this.unsubscribe();
500
- if (config.batchQuery) {
501
- this.config = {
502
- batchQuery: config.batchQuery.map(function (individualConfig) {
503
- return safeSanitizeGraphQLConfigObject(individualConfig);
504
- }),
505
- };
506
- }
507
- else {
508
- this.config = safeSanitizeGraphQLConfigObject(config);
509
- }
510
- this.callAdapter();
511
- };
512
- /**
513
- * Emits new values to the callback.
514
- *
515
- * @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
516
- */
517
- LWCGraphQLLuvioWireAdapter.prototype.emit = function (snapshot) {
518
- var payload = snapshotToPayload(snapshot);
519
- dataToTupleWeakMap.set(payload, [this.name, snapshot]);
520
- try {
521
- this.callback(payload);
522
- }
523
- catch (error) {
524
- if (error instanceof Error) {
525
- throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
526
- }
527
- }
528
- };
529
- /**
530
- * Coerce config before calling the adapter, preserve current behavior otherwise
531
- */
532
- LWCGraphQLLuvioWireAdapter.prototype.callAdapter = function () {
533
- var _this = this;
534
- if (!this.connected || this.config === undefined) {
535
- return;
536
- }
537
- var config = this.config;
538
- if ('batchQuery' in config) {
539
- var batchConfig = {
540
- batchQuery: config.batchQuery.map(function (individualConfig) {
541
- return _this.resolveQueryAst(individualConfig);
542
- }),
543
- };
544
- // If any of the configurations are invalid, we bail out of calling the adapter.
545
- if (batchConfig.batchQuery.some(function (val) { return val === undefined; })) {
546
- return;
547
- }
548
- var snapshotOrPromise = this.adapter(batchConfig);
549
- this.processAdapterResponse(snapshotOrPromise);
550
- }
551
- else if ('query' in config) {
552
- var singleConfig = this.resolveQueryAst(config);
553
- if (singleConfig !== undefined) {
554
- var snapshotOrPromise = this.adapter(singleConfig);
555
- this.processAdapterResponse(snapshotOrPromise);
556
- }
557
- }
558
- };
559
- LWCGraphQLLuvioWireAdapter.prototype.resolveQueryAst = function (config) {
560
- if (config.query === null) {
561
- return;
562
- }
563
- var ast = this.astResolver(config.query);
564
- if (ast === undefined && config.query !== undefined) {
565
- // this should only happen if the user didn't parse the query
566
- if (process.env.NODE_ENV !== 'production') {
567
- throw new Error(USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE);
568
- }
569
- return;
570
- }
571
- var resolvedAdapterConfig = __assign(__assign({}, config), { query: ast });
572
- return resolvedAdapterConfig;
573
- };
574
- return LWCGraphQLLuvioWireAdapter;
575
- }(LWCLuvioWireAdapter));
576
- function extractSnapshotData(snapshot) {
577
- if ('data' in snapshot && snapshot.data !== undefined) {
578
- var isSingleGraphQLData = 'data' in snapshot.data && snapshot.data.data !== undefined;
579
- var isBatchGraphQLData = 'results' in snapshot.data && snapshot.data.results !== undefined;
580
- if (isSingleGraphQLData)
581
- return snapshot.data.data;
582
- if (isBatchGraphQLData)
583
- return snapshot.data;
584
- }
585
- }
586
- /**
587
- * Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
588
- *
589
- * @param adapter Adapter
590
- * @param name name to assign to the generated constructor
591
- * @param luvio Luvio
592
- */
593
- function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
594
- var constructor = function (callback) {
595
- var delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
596
- this.connect = function () { return delegate.connect(); };
597
- this.disconnect = function () { return delegate.disconnect(); };
598
- this.update = function (config, context) {
599
- return delegate.update(config, context);
600
- };
601
- };
602
- Object.defineProperty(constructor, 'name', { value: name });
603
- return constructor;
604
- }
605
- function safeSanitizeGraphQLConfigObject(config) {
606
- // graphql query AST is passed by reference
607
- // sanitizing it makes a copy and we lose that reference
608
- // so we avoid sanitizing it
609
- return __assign(__assign({}, sanitize(config)), { query: config.query });
471
+ function snapshotToPayload(snapshot) {
472
+ var payload = {
473
+ data: undefined,
474
+ errors: undefined,
475
+ };
476
+ if (snapshot === undefined) {
477
+ return payload;
478
+ }
479
+ payload.data = extractSnapshotData(snapshot);
480
+ // TODO handle batch error scenarios.
481
+ if ('error' in snapshot && snapshot.error !== undefined) {
482
+ if (Array.isArray(snapshot.error)) {
483
+ payload.errors = snapshot.error;
484
+ }
485
+ else {
486
+ payload.errors = [snapshot.error];
487
+ }
488
+ }
489
+ return payload;
490
+ }
491
+ var LWCGraphQLLuvioWireAdapter = /** @class */ (function (_super) {
492
+ __extends(LWCGraphQLLuvioWireAdapter, _super);
493
+ function LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback) {
494
+ var _this = _super.call(this, adapter, name, luvio, callback) || this;
495
+ _this.astResolver = astResolver;
496
+ return _this;
497
+ }
498
+ LWCGraphQLLuvioWireAdapter.prototype.update = function (config, _context) {
499
+ this.unsubscribe();
500
+ if (config.batchQuery) {
501
+ this.config = {
502
+ batchQuery: config.batchQuery.map(function (individualConfig) {
503
+ return safeSanitizeGraphQLConfigObject(individualConfig);
504
+ }),
505
+ };
506
+ }
507
+ else {
508
+ this.config = safeSanitizeGraphQLConfigObject(config);
509
+ }
510
+ this.callAdapter();
511
+ };
512
+ /**
513
+ * Emits new values to the callback.
514
+ *
515
+ * @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
516
+ */
517
+ LWCGraphQLLuvioWireAdapter.prototype.emit = function (snapshot) {
518
+ var payload = snapshotToPayload(snapshot);
519
+ dataToTupleWeakMap.set(payload, [this.name, snapshot]);
520
+ try {
521
+ this.callback(payload);
522
+ }
523
+ catch (error) {
524
+ if (error instanceof Error) {
525
+ throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
526
+ }
527
+ }
528
+ };
529
+ /**
530
+ * Coerce config before calling the adapter, preserve current behavior otherwise
531
+ */
532
+ LWCGraphQLLuvioWireAdapter.prototype.callAdapter = function () {
533
+ var _this = this;
534
+ if (!this.connected || this.config === undefined) {
535
+ return;
536
+ }
537
+ var config = this.config;
538
+ if ('batchQuery' in config) {
539
+ var batchConfig = {
540
+ batchQuery: config.batchQuery.map(function (individualConfig) {
541
+ return _this.resolveQueryAst(individualConfig);
542
+ }),
543
+ };
544
+ // If any of the configurations are invalid, we bail out of calling the adapter.
545
+ if (batchConfig.batchQuery.some(function (val) { return val === undefined; })) {
546
+ return;
547
+ }
548
+ var snapshotOrPromise = this.adapter(batchConfig);
549
+ this.processAdapterResponse(snapshotOrPromise);
550
+ }
551
+ else if ('query' in config) {
552
+ var singleConfig = this.resolveQueryAst(config);
553
+ if (singleConfig !== undefined) {
554
+ var snapshotOrPromise = this.adapter(singleConfig);
555
+ this.processAdapterResponse(snapshotOrPromise);
556
+ }
557
+ }
558
+ };
559
+ LWCGraphQLLuvioWireAdapter.prototype.resolveQueryAst = function (config) {
560
+ if (config.query === null) {
561
+ return;
562
+ }
563
+ var ast = this.astResolver(config.query);
564
+ if (ast === undefined && config.query !== undefined) {
565
+ // this should only happen if the user didn't parse the query
566
+ if (process.env.NODE_ENV !== 'production') {
567
+ throw new Error(USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE);
568
+ }
569
+ return;
570
+ }
571
+ var resolvedAdapterConfig = __assign(__assign({}, config), { query: ast });
572
+ return resolvedAdapterConfig;
573
+ };
574
+ return LWCGraphQLLuvioWireAdapter;
575
+ }(LWCLuvioWireAdapter));
576
+ function extractSnapshotData(snapshot) {
577
+ if ('data' in snapshot && snapshot.data !== undefined) {
578
+ var isSingleGraphQLData = 'data' in snapshot.data && snapshot.data.data !== undefined;
579
+ var isBatchGraphQLData = 'results' in snapshot.data && snapshot.data.results !== undefined;
580
+ if (isSingleGraphQLData)
581
+ return snapshot.data.data;
582
+ if (isBatchGraphQLData)
583
+ return snapshot.data;
584
+ }
585
+ }
586
+ /**
587
+ * Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
588
+ *
589
+ * @param adapter Adapter
590
+ * @param name name to assign to the generated constructor
591
+ * @param luvio Luvio
592
+ */
593
+ function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
594
+ var constructor = function (callback) {
595
+ var delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
596
+ this.connect = function () { return delegate.connect(); };
597
+ this.disconnect = function () { return delegate.disconnect(); };
598
+ this.update = function (config, context) {
599
+ return delegate.update(config, context);
600
+ };
601
+ };
602
+ Object.defineProperty(constructor, 'name', { value: name });
603
+ return constructor;
604
+ }
605
+ function safeSanitizeGraphQLConfigObject(config) {
606
+ // graphql query AST is passed by reference
607
+ // sanitizing it makes a copy and we lose that reference
608
+ // so we avoid sanitizing it
609
+ return __assign(__assign({}, sanitize(config)), { query: config.query });
610
610
  }
611
611
 
612
612
  exports.ADAPTER_UNFULFILLED_ERROR = ADAPTER_UNFULFILLED_ERROR;