@salesforce/lds-adapters-analytics-wave-private 1.124.1 → 1.124.3

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.
@@ -6,356 +6,356 @@
6
6
 
7
7
  import { serializeStructuredKey, StoreKeyMap } from '@luvio/engine';
8
8
 
9
- const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
- const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
11
- const { isArray: ArrayIsArray$1 } = Array;
12
- /**
13
- * Validates an adapter config is well-formed.
14
- * @param config The config to validate.
15
- * @param adapter The adapter validation configuration.
16
- * @param oneOf The keys the config must contain at least one of.
17
- * @throws A TypeError if config doesn't satisfy the adapter's config validation.
18
- */
19
- function validateConfig(config, adapter, oneOf) {
20
- const { displayName } = adapter;
21
- const { required, optional, unsupported } = adapter.parameters;
22
- if (config === undefined ||
23
- required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
24
- throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
25
- }
26
- if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
27
- throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
28
- }
29
- if (unsupported !== undefined &&
30
- unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
31
- throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
32
- }
33
- const supported = required.concat(optional);
34
- if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
35
- throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
36
- }
37
- }
38
- function untrustedIsObject(untrusted) {
39
- return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
40
- }
41
- function areRequiredParametersPresent(config, configPropertyNames) {
42
- return configPropertyNames.parameters.required.every(req => req in config);
43
- }
44
- const snapshotRefreshOptions = {
45
- overrides: {
46
- headers: {
47
- 'Cache-Control': 'no-cache',
48
- },
49
- }
50
- };
9
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
+ const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
11
+ const { isArray: ArrayIsArray$1 } = Array;
12
+ /**
13
+ * Validates an adapter config is well-formed.
14
+ * @param config The config to validate.
15
+ * @param adapter The adapter validation configuration.
16
+ * @param oneOf The keys the config must contain at least one of.
17
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
18
+ */
19
+ function validateConfig(config, adapter, oneOf) {
20
+ const { displayName } = adapter;
21
+ const { required, optional, unsupported } = adapter.parameters;
22
+ if (config === undefined ||
23
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
24
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
25
+ }
26
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
27
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
28
+ }
29
+ if (unsupported !== undefined &&
30
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
31
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
32
+ }
33
+ const supported = required.concat(optional);
34
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
35
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
36
+ }
37
+ }
38
+ function untrustedIsObject(untrusted) {
39
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
40
+ }
41
+ function areRequiredParametersPresent(config, configPropertyNames) {
42
+ return configPropertyNames.parameters.required.every(req => req in config);
43
+ }
44
+ const snapshotRefreshOptions = {
45
+ overrides: {
46
+ headers: {
47
+ 'Cache-Control': 'no-cache',
48
+ },
49
+ }
50
+ };
51
51
  const keyPrefix = 'WAVE';
52
52
 
53
- const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
54
- const { isArray: ArrayIsArray } = Array;
55
- const { stringify: JSONStringify } = JSON;
56
- function deepFreeze$1(value) {
57
- // No need to freeze primitives
58
- if (typeof value !== 'object' || value === null) {
59
- return;
60
- }
61
- if (ArrayIsArray(value)) {
62
- for (let i = 0, len = value.length; i < len; i += 1) {
63
- deepFreeze$1(value[i]);
64
- }
65
- }
66
- else {
67
- const keys = ObjectKeys(value);
68
- for (let i = 0, len = keys.length; i < len; i += 1) {
69
- deepFreeze$1(value[keys[i]]);
70
- }
71
- }
72
- ObjectFreeze(value);
73
- }
74
- function createLink(ref) {
75
- return {
76
- __ref: serializeStructuredKey(ref),
77
- };
53
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
54
+ const { isArray: ArrayIsArray } = Array;
55
+ const { stringify: JSONStringify } = JSON;
56
+ function deepFreeze$1(value) {
57
+ // No need to freeze primitives
58
+ if (typeof value !== 'object' || value === null) {
59
+ return;
60
+ }
61
+ if (ArrayIsArray(value)) {
62
+ for (let i = 0, len = value.length; i < len; i += 1) {
63
+ deepFreeze$1(value[i]);
64
+ }
65
+ }
66
+ else {
67
+ const keys = ObjectKeys(value);
68
+ for (let i = 0, len = keys.length; i < len; i += 1) {
69
+ deepFreeze$1(value[keys[i]]);
70
+ }
71
+ }
72
+ ObjectFreeze(value);
73
+ }
74
+ function createLink(ref) {
75
+ return {
76
+ __ref: serializeStructuredKey(ref),
77
+ };
78
78
  }
79
79
 
80
- const TTL = 5000;
81
- const VERSION = "f4d046d44230e53375ee20bbd2483a1f";
82
- function validate(obj, path = 'SoqlQueryResultRepresentation') {
83
- const v_error = (() => {
84
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
85
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
86
- }
87
- const obj_keys = ObjectKeys(obj);
88
- for (let i = 0; i < obj_keys.length; i++) {
89
- const key = obj_keys[i];
90
- const obj_prop = obj[key];
91
- const path_prop = path + '["' + key + '"]';
92
- if (obj_prop === undefined) {
93
- return new TypeError('Expected "defined" but received "' + typeof obj_prop + '" (at "' + path_prop + '")');
94
- }
95
- }
96
- if (obj.done !== undefined) {
97
- const obj_done = obj.done;
98
- const path_done = path + '.done';
99
- if (typeof obj_done !== 'boolean') {
100
- return new TypeError('Expected "boolean" but received "' + typeof obj_done + '" (at "' + path_done + '")');
101
- }
102
- }
103
- const obj_records = obj.records;
104
- const path_records = path + '.records';
105
- if (!ArrayIsArray(obj_records)) {
106
- return new TypeError('Expected "array" but received "' + typeof obj_records + '" (at "' + path_records + '")');
107
- }
108
- for (let i = 0; i < obj_records.length; i++) {
109
- const obj_records_item = obj_records[i];
110
- const path_records_item = path_records + '[' + i + ']';
111
- if (obj_records_item === undefined) {
112
- return new TypeError('Expected "defined" but received "' + typeof obj_records_item + '" (at "' + path_records_item + '")');
113
- }
114
- }
115
- if (obj.totalSize !== undefined) {
116
- const obj_totalSize = obj.totalSize;
117
- const path_totalSize = path + '.totalSize';
118
- if (typeof obj_totalSize !== 'number') {
119
- return new TypeError('Expected "number" but received "' + typeof obj_totalSize + '" (at "' + path_totalSize + '")');
120
- }
121
- }
122
- })();
123
- return v_error === undefined ? null : v_error;
124
- }
125
- const RepresentationType = 'SoqlQueryResultRepresentation';
126
- function normalize(input, existing, path, luvio, store, timestamp) {
127
- return input;
128
- }
129
- const select$1 = function SoqlQueryResultRepresentationSelect() {
130
- return {
131
- kind: 'Fragment',
132
- version: VERSION,
133
- private: [],
134
- opaque: true
135
- };
136
- };
137
- function equals(existing, incoming) {
138
- if (JSONStringify(incoming) !== JSONStringify(existing)) {
139
- return false;
140
- }
141
- return true;
142
- }
143
- function deepFreeze(input) {
144
- const input_keys = Object.keys(input);
145
- const input_length = input_keys.length;
146
- for (let i = 0; i < input_length; i++) {
147
- const key = input_keys[i];
148
- const input_prop = input[key];
149
- deepFreeze$1(input_prop);
150
- }
151
- const input_records = input.records;
152
- for (let i = 0; i < input_records.length; i++) {
153
- const input_records_item = input_records[i];
154
- deepFreeze$1(input_records_item);
155
- }
156
- ObjectFreeze(input_records);
157
- ObjectFreeze(input);
158
- }
159
- const ingest = function SoqlQueryResultRepresentationIngest(input, path, luvio, store, timestamp) {
160
- if (process.env.NODE_ENV !== 'production') {
161
- const validateError = validate(input);
162
- if (validateError !== null) {
163
- throw validateError;
164
- }
165
- }
166
- const key = path.fullPath;
167
- const existingRecord = store.readEntry(key);
168
- const ttlToUse = TTL;
169
- let incomingRecord = normalize(input, store.readEntry(key), {
170
- fullPath: key,
171
- parent: path.parent,
172
- propertyName: path.propertyName,
173
- ttl: ttlToUse
174
- });
175
- deepFreeze(input);
176
- if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
177
- luvio.storePublish(key, incomingRecord);
178
- }
179
- {
180
- const storeMetadataParams = {
181
- ttl: ttlToUse,
182
- namespace: "WAVE",
183
- version: VERSION,
184
- representationName: RepresentationType,
185
- };
186
- luvio.publishStoreMetadata(key, storeMetadataParams);
187
- }
188
- return createLink(key);
189
- };
190
- function getTypeCacheKeys(luvio, input, fullPathFactory) {
191
- const rootKeySet = new StoreKeyMap();
192
- // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
193
- const rootKey = fullPathFactory();
194
- rootKeySet.set(rootKey, {
195
- namespace: keyPrefix,
196
- representationName: RepresentationType,
197
- mergeable: false
198
- });
199
- return rootKeySet;
80
+ const TTL = 5000;
81
+ const VERSION = "f4d046d44230e53375ee20bbd2483a1f";
82
+ function validate(obj, path = 'SoqlQueryResultRepresentation') {
83
+ const v_error = (() => {
84
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
85
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
86
+ }
87
+ const obj_keys = ObjectKeys(obj);
88
+ for (let i = 0; i < obj_keys.length; i++) {
89
+ const key = obj_keys[i];
90
+ const obj_prop = obj[key];
91
+ const path_prop = path + '["' + key + '"]';
92
+ if (obj_prop === undefined) {
93
+ return new TypeError('Expected "defined" but received "' + typeof obj_prop + '" (at "' + path_prop + '")');
94
+ }
95
+ }
96
+ if (obj.done !== undefined) {
97
+ const obj_done = obj.done;
98
+ const path_done = path + '.done';
99
+ if (typeof obj_done !== 'boolean') {
100
+ return new TypeError('Expected "boolean" but received "' + typeof obj_done + '" (at "' + path_done + '")');
101
+ }
102
+ }
103
+ const obj_records = obj.records;
104
+ const path_records = path + '.records';
105
+ if (!ArrayIsArray(obj_records)) {
106
+ return new TypeError('Expected "array" but received "' + typeof obj_records + '" (at "' + path_records + '")');
107
+ }
108
+ for (let i = 0; i < obj_records.length; i++) {
109
+ const obj_records_item = obj_records[i];
110
+ const path_records_item = path_records + '[' + i + ']';
111
+ if (obj_records_item === undefined) {
112
+ return new TypeError('Expected "defined" but received "' + typeof obj_records_item + '" (at "' + path_records_item + '")');
113
+ }
114
+ }
115
+ if (obj.totalSize !== undefined) {
116
+ const obj_totalSize = obj.totalSize;
117
+ const path_totalSize = path + '.totalSize';
118
+ if (typeof obj_totalSize !== 'number') {
119
+ return new TypeError('Expected "number" but received "' + typeof obj_totalSize + '" (at "' + path_totalSize + '")');
120
+ }
121
+ }
122
+ })();
123
+ return v_error === undefined ? null : v_error;
124
+ }
125
+ const RepresentationType = 'SoqlQueryResultRepresentation';
126
+ function normalize(input, existing, path, luvio, store, timestamp) {
127
+ return input;
128
+ }
129
+ const select$1 = function SoqlQueryResultRepresentationSelect() {
130
+ return {
131
+ kind: 'Fragment',
132
+ version: VERSION,
133
+ private: [],
134
+ opaque: true
135
+ };
136
+ };
137
+ function equals(existing, incoming) {
138
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
139
+ return false;
140
+ }
141
+ return true;
142
+ }
143
+ function deepFreeze(input) {
144
+ const input_keys = Object.keys(input);
145
+ const input_length = input_keys.length;
146
+ for (let i = 0; i < input_length; i++) {
147
+ const key = input_keys[i];
148
+ const input_prop = input[key];
149
+ deepFreeze$1(input_prop);
150
+ }
151
+ const input_records = input.records;
152
+ for (let i = 0; i < input_records.length; i++) {
153
+ const input_records_item = input_records[i];
154
+ deepFreeze$1(input_records_item);
155
+ }
156
+ ObjectFreeze(input_records);
157
+ ObjectFreeze(input);
158
+ }
159
+ const ingest = function SoqlQueryResultRepresentationIngest(input, path, luvio, store, timestamp) {
160
+ if (process.env.NODE_ENV !== 'production') {
161
+ const validateError = validate(input);
162
+ if (validateError !== null) {
163
+ throw validateError;
164
+ }
165
+ }
166
+ const key = path.fullPath;
167
+ const existingRecord = store.readEntry(key);
168
+ const ttlToUse = TTL;
169
+ let incomingRecord = normalize(input, store.readEntry(key), {
170
+ fullPath: key,
171
+ parent: path.parent,
172
+ propertyName: path.propertyName,
173
+ ttl: ttlToUse
174
+ });
175
+ deepFreeze(input);
176
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
177
+ luvio.storePublish(key, incomingRecord);
178
+ }
179
+ {
180
+ const storeMetadataParams = {
181
+ ttl: ttlToUse,
182
+ namespace: "WAVE",
183
+ version: VERSION,
184
+ representationName: RepresentationType,
185
+ };
186
+ luvio.publishStoreMetadata(key, storeMetadataParams);
187
+ }
188
+ return createLink(key);
189
+ };
190
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
191
+ const rootKeySet = new StoreKeyMap();
192
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
193
+ const rootKey = fullPathFactory();
194
+ rootKeySet.set(rootKey, {
195
+ namespace: keyPrefix,
196
+ representationName: RepresentationType,
197
+ mergeable: false
198
+ });
199
+ return rootKeySet;
200
200
  }
201
201
 
202
- function select(luvio, params) {
203
- return select$1();
204
- }
205
- function keyBuilder$1(luvio, params) {
206
- return keyPrefix + '::SoqlQueryResultRepresentation:(' + 'query:' + params.body.query + ')';
207
- }
208
- function getResponseCacheKeys(luvio, resourceParams, response) {
209
- return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
210
- }
211
- function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
212
- const { body } = response;
213
- const key = keyBuilder$1(luvio, resourceParams);
214
- luvio.storeIngest(key, ingest, body);
215
- const snapshot = luvio.storeLookup({
216
- recordId: key,
217
- node: select(),
218
- variables: {},
219
- }, snapshotRefresh);
220
- if (process.env.NODE_ENV !== 'production') {
221
- if (snapshot.state !== 'Fulfilled') {
222
- throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
223
- }
224
- }
225
- return snapshot;
226
- }
227
- function ingestError(luvio, params, error, snapshotRefresh) {
228
- const key = keyBuilder$1(luvio, params);
229
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
230
- const storeMetadataParams = {
231
- ttl: TTL,
232
- namespace: keyPrefix,
233
- version: VERSION,
234
- representationName: RepresentationType
235
- };
236
- luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
237
- return errorSnapshot;
238
- }
239
- function createResourceRequest(config) {
240
- const headers = {};
241
- return {
242
- baseUri: '/services/data/v58.0',
243
- basePath: '/wave/soql',
244
- method: 'post',
245
- body: config.body,
246
- urlParams: {},
247
- queryParams: {},
248
- headers,
249
- priority: 'normal',
250
- };
202
+ function select(luvio, params) {
203
+ return select$1();
204
+ }
205
+ function keyBuilder$1(luvio, params) {
206
+ return keyPrefix + '::SoqlQueryResultRepresentation:(' + 'query:' + params.body.query + ')';
207
+ }
208
+ function getResponseCacheKeys(luvio, resourceParams, response) {
209
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
210
+ }
211
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
212
+ const { body } = response;
213
+ const key = keyBuilder$1(luvio, resourceParams);
214
+ luvio.storeIngest(key, ingest, body);
215
+ const snapshot = luvio.storeLookup({
216
+ recordId: key,
217
+ node: select(),
218
+ variables: {},
219
+ }, snapshotRefresh);
220
+ if (process.env.NODE_ENV !== 'production') {
221
+ if (snapshot.state !== 'Fulfilled') {
222
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
223
+ }
224
+ }
225
+ return snapshot;
226
+ }
227
+ function ingestError(luvio, params, error, snapshotRefresh) {
228
+ const key = keyBuilder$1(luvio, params);
229
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
230
+ const storeMetadataParams = {
231
+ ttl: TTL,
232
+ namespace: keyPrefix,
233
+ version: VERSION,
234
+ representationName: RepresentationType
235
+ };
236
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
237
+ return errorSnapshot;
238
+ }
239
+ function createResourceRequest(config) {
240
+ const headers = {};
241
+ return {
242
+ baseUri: '/services/data/v58.0',
243
+ basePath: '/wave/soql',
244
+ method: 'post',
245
+ body: config.body,
246
+ urlParams: {},
247
+ queryParams: {},
248
+ headers,
249
+ priority: 'normal',
250
+ };
251
251
  }
252
252
 
253
- const executeSoqlQueryPost_ConfigPropertyNames = {
254
- displayName: 'executeSoqlQueryPost',
255
- parameters: {
256
- required: ['query'],
257
- optional: []
258
- }
259
- };
260
- function createResourceParams(config) {
261
- const resourceParams = {
262
- body: {
263
- query: config.query
264
- }
265
- };
266
- return resourceParams;
267
- }
268
- function keyBuilder(luvio, config) {
269
- const resourceParams = createResourceParams(config);
270
- return keyBuilder$1(luvio, resourceParams);
271
- }
272
- function typeCheckConfig(untrustedConfig) {
273
- const config = {};
274
- const untrustedConfig_query = untrustedConfig.query;
275
- if (typeof untrustedConfig_query === 'string') {
276
- config.query = untrustedConfig_query;
277
- }
278
- return config;
279
- }
280
- function validateAdapterConfig(untrustedConfig, configPropertyNames) {
281
- if (!untrustedIsObject(untrustedConfig)) {
282
- return null;
283
- }
284
- if (process.env.NODE_ENV !== 'production') {
285
- validateConfig(untrustedConfig, configPropertyNames);
286
- }
287
- const config = typeCheckConfig(untrustedConfig);
288
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
289
- return null;
290
- }
291
- return config;
292
- }
293
- function adapterFragment(luvio, config) {
294
- createResourceParams(config);
295
- return select();
296
- }
297
- function onFetchResponseSuccess(luvio, config, resourceParams, response) {
298
- const snapshot = ingestSuccess(luvio, resourceParams, response, {
299
- config,
300
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
301
- });
302
- return luvio.storeBroadcast().then(() => snapshot);
303
- }
304
- function onFetchResponseError(luvio, config, resourceParams, response) {
305
- const snapshot = ingestError(luvio, resourceParams, response, {
306
- config,
307
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
308
- });
309
- return luvio.storeBroadcast().then(() => snapshot);
310
- }
311
- function buildNetworkSnapshot(luvio, config, options) {
312
- const resourceParams = createResourceParams(config);
313
- const request = createResourceRequest(resourceParams);
314
- return luvio.dispatchResourceRequest(request, options)
315
- .then((response) => {
316
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
317
- }, (response) => {
318
- return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
319
- });
320
- }
321
- function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
322
- const { luvio, config } = context;
323
- const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
324
- const dispatchOptions = {
325
- resourceRequestContext: {
326
- requestCorrelator,
327
- luvioRequestMethod: 'get',
328
- },
329
- eventObservers
330
- };
331
- if (networkPriority !== 'normal') {
332
- dispatchOptions.overrides = {
333
- priority: networkPriority
334
- };
335
- }
336
- return buildNetworkSnapshot(luvio, config, dispatchOptions);
337
- }
338
- function buildCachedSnapshotCachePolicy(context, storeLookup) {
339
- const { luvio, config } = context;
340
- const selector = {
341
- recordId: keyBuilder(luvio, config),
342
- node: adapterFragment(luvio, config),
343
- variables: {},
344
- };
345
- const cacheSnapshot = storeLookup(selector, {
346
- config,
347
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
348
- });
349
- return cacheSnapshot;
350
- }
351
- const executeSoqlQueryPostAdapterFactory = (luvio) => function WAVE__executeSoqlQueryPost(untrustedConfig, requestContext) {
352
- const config = validateAdapterConfig(untrustedConfig, executeSoqlQueryPost_ConfigPropertyNames);
353
- // Invalid or incomplete config
354
- if (config === null) {
355
- return null;
356
- }
357
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
358
- buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
253
+ const executeSoqlQueryPost_ConfigPropertyNames = {
254
+ displayName: 'executeSoqlQueryPost',
255
+ parameters: {
256
+ required: ['query'],
257
+ optional: []
258
+ }
259
+ };
260
+ function createResourceParams(config) {
261
+ const resourceParams = {
262
+ body: {
263
+ query: config.query
264
+ }
265
+ };
266
+ return resourceParams;
267
+ }
268
+ function keyBuilder(luvio, config) {
269
+ const resourceParams = createResourceParams(config);
270
+ return keyBuilder$1(luvio, resourceParams);
271
+ }
272
+ function typeCheckConfig(untrustedConfig) {
273
+ const config = {};
274
+ const untrustedConfig_query = untrustedConfig.query;
275
+ if (typeof untrustedConfig_query === 'string') {
276
+ config.query = untrustedConfig_query;
277
+ }
278
+ return config;
279
+ }
280
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
281
+ if (!untrustedIsObject(untrustedConfig)) {
282
+ return null;
283
+ }
284
+ if (process.env.NODE_ENV !== 'production') {
285
+ validateConfig(untrustedConfig, configPropertyNames);
286
+ }
287
+ const config = typeCheckConfig(untrustedConfig);
288
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
289
+ return null;
290
+ }
291
+ return config;
292
+ }
293
+ function adapterFragment(luvio, config) {
294
+ createResourceParams(config);
295
+ return select();
296
+ }
297
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
298
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
299
+ config,
300
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
301
+ });
302
+ return luvio.storeBroadcast().then(() => snapshot);
303
+ }
304
+ function onFetchResponseError(luvio, config, resourceParams, response) {
305
+ const snapshot = ingestError(luvio, resourceParams, response, {
306
+ config,
307
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
308
+ });
309
+ return luvio.storeBroadcast().then(() => snapshot);
310
+ }
311
+ function buildNetworkSnapshot(luvio, config, options) {
312
+ const resourceParams = createResourceParams(config);
313
+ const request = createResourceRequest(resourceParams);
314
+ return luvio.dispatchResourceRequest(request, options)
315
+ .then((response) => {
316
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
317
+ }, (response) => {
318
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
319
+ });
320
+ }
321
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
322
+ const { luvio, config } = context;
323
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
324
+ const dispatchOptions = {
325
+ resourceRequestContext: {
326
+ requestCorrelator,
327
+ luvioRequestMethod: 'get',
328
+ },
329
+ eventObservers
330
+ };
331
+ if (networkPriority !== 'normal') {
332
+ dispatchOptions.overrides = {
333
+ priority: networkPriority
334
+ };
335
+ }
336
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
337
+ }
338
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
339
+ const { luvio, config } = context;
340
+ const selector = {
341
+ recordId: keyBuilder(luvio, config),
342
+ node: adapterFragment(luvio, config),
343
+ variables: {},
344
+ };
345
+ const cacheSnapshot = storeLookup(selector, {
346
+ config,
347
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
348
+ });
349
+ return cacheSnapshot;
350
+ }
351
+ const executeSoqlQueryPostAdapterFactory = (luvio) => function WAVE__executeSoqlQueryPost(untrustedConfig, requestContext) {
352
+ const config = validateAdapterConfig(untrustedConfig, executeSoqlQueryPost_ConfigPropertyNames);
353
+ // Invalid or incomplete config
354
+ if (config === null) {
355
+ return null;
356
+ }
357
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
358
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
359
359
  };
360
360
 
361
361
  export { executeSoqlQueryPostAdapterFactory };