@salesforce/lds-adapters-cdp-query 1.308.0-dev7 → 1.309.0-dev10

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.
@@ -4,10 +4,10 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$1, StoreKeyMap, createResourceParams as createResourceParams$1 } from '@luvio/engine';
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from '@luvio/engine';
8
8
 
9
9
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
- const { keys: ObjectKeys, create: ObjectCreate } = Object;
10
+ const { keys: ObjectKeys$1, create: ObjectCreate$1 } = Object;
11
11
  const { isArray: ArrayIsArray$1 } = Array;
12
12
  /**
13
13
  * Validates an adapter config is well-formed.
@@ -31,7 +31,7 @@ function validateConfig(config, adapter, oneOf) {
31
31
  throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
32
32
  }
33
33
  const supported = required.concat(optional);
34
- if (ObjectKeys(config).some(key => !supported.includes(key))) {
34
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
35
35
  throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
36
36
  }
37
37
  }
@@ -71,6 +71,7 @@ function buildAdapterValidationConfig(displayName, paramsMeta) {
71
71
  }
72
72
  const keyPrefix = 'cdp-query';
73
73
 
74
+ const { keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
74
75
  const { isArray: ArrayIsArray } = Array;
75
76
  const { stringify: JSONStringify } = JSON;
76
77
  function createLink(ref) {
@@ -79,8 +80,8 @@ function createLink(ref) {
79
80
  };
80
81
  }
81
82
 
82
- const VERSION = "7df04f81d9b64d7cdebf01b86018ba25";
83
- function validate(obj, path = 'CdpQueryDataOutputRepresentation') {
83
+ const VERSION$1 = "7df04f81d9b64d7cdebf01b86018ba25";
84
+ function validate$1(obj, path = 'CdpQueryDataOutputRepresentation') {
84
85
  const v_error = (() => {
85
86
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
86
87
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -100,62 +101,62 @@ function validate(obj, path = 'CdpQueryDataOutputRepresentation') {
100
101
  })();
101
102
  return v_error === undefined ? null : v_error;
102
103
  }
103
- const RepresentationType = 'CdpQueryDataOutputRepresentation';
104
- function normalize(input, existing, path, luvio, store, timestamp) {
104
+ const RepresentationType$1 = 'CdpQueryDataOutputRepresentation';
105
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
105
106
  return input;
106
107
  }
107
- const select$1 = function CdpQueryDataOutputRepresentationSelect() {
108
+ const select$3 = function CdpQueryDataOutputRepresentationSelect() {
108
109
  return {
109
110
  kind: 'Fragment',
110
- version: VERSION,
111
+ version: VERSION$1,
111
112
  private: [],
112
113
  opaque: true
113
114
  };
114
115
  };
115
- function equals(existing, incoming) {
116
+ function equals$1(existing, incoming) {
116
117
  if (JSONStringify(incoming) !== JSONStringify(existing)) {
117
118
  return false;
118
119
  }
119
120
  return true;
120
121
  }
121
- const ingest = function CdpQueryDataOutputRepresentationIngest(input, path, luvio, store, timestamp) {
122
+ const ingest$1 = function CdpQueryDataOutputRepresentationIngest(input, path, luvio, store, timestamp) {
122
123
  if (process.env.NODE_ENV !== 'production') {
123
- const validateError = validate(input);
124
+ const validateError = validate$1(input);
124
125
  if (validateError !== null) {
125
126
  throw validateError;
126
127
  }
127
128
  }
128
129
  const key = path.fullPath;
129
130
  const ttlToUse = path.ttl !== undefined ? path.ttl : 360000;
130
- ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "cdp-query", VERSION, RepresentationType, equals);
131
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "cdp-query", VERSION$1, RepresentationType$1, equals$1);
131
132
  return createLink(key);
132
133
  };
133
- function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
134
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
134
135
  // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
135
136
  const rootKey = fullPathFactory();
136
137
  rootKeySet.set(rootKey, {
137
138
  namespace: keyPrefix,
138
- representationName: RepresentationType,
139
+ representationName: RepresentationType$1,
139
140
  mergeable: false
140
141
  });
141
142
  }
142
143
 
143
- function select(luvio, params) {
144
- return select$1();
144
+ function select$2(luvio, params) {
145
+ return select$3();
145
146
  }
146
- function keyBuilder$1(luvio, params) {
147
+ function keyBuilder$2(luvio, params) {
147
148
  return keyPrefix + '::CdpQueryDataOutputRepresentation:(' + 'dataspace:' + params.queryParams.dataspace + ',' + 'dataSourceId:' + params.urlParams.dataSourceId + ',' + 'dataSourceObjectId:' + params.urlParams.dataSourceObjectId + ',' + 'entityName:' + params.urlParams.entityName + ',' + 'sourceRecordId:' + params.urlParams.sourceRecordId + ')';
148
149
  }
149
- function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
150
- getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
150
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
151
+ getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
151
152
  }
152
- function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
153
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
153
154
  const { body } = response;
154
- const key = keyBuilder$1(luvio, resourceParams);
155
- luvio.storeIngest(key, ingest, body);
155
+ const key = keyBuilder$2(luvio, resourceParams);
156
+ luvio.storeIngest(key, ingest$1, body);
156
157
  const snapshot = luvio.storeLookup({
157
158
  recordId: key,
158
- node: select(),
159
+ node: select$2(),
159
160
  variables: {},
160
161
  }, snapshotRefresh);
161
162
  if (process.env.NODE_ENV !== 'production') {
@@ -167,12 +168,12 @@ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
167
168
  return snapshot;
168
169
  }
169
170
  function ingestError(luvio, params, error, snapshotRefresh) {
170
- const key = keyBuilder$1(luvio, params);
171
+ const key = keyBuilder$2(luvio, params);
171
172
  const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
172
173
  luvio.storeIngestError(key, errorSnapshot);
173
174
  return errorSnapshot;
174
175
  }
175
- function createResourceRequest(config) {
176
+ function createResourceRequest$1(config) {
176
177
  const headers = {};
177
178
  return {
178
179
  baseUri: '/services/data/v62.0',
@@ -186,7 +187,7 @@ function createResourceRequest(config) {
186
187
  };
187
188
  }
188
189
 
189
- const adapterName = 'universalIdLookupBySourceId';
190
+ const adapterName$1 = 'universalIdLookupBySourceId';
190
191
  const universalIdLookupBySourceId_ConfigPropertyMetadata = [
191
192
  generateParamConfigMetadata('dataSourceId', true, 0 /* UrlParameter */, 0 /* String */),
192
193
  generateParamConfigMetadata('dataSourceObjectId', true, 0 /* UrlParameter */, 0 /* String */),
@@ -194,56 +195,56 @@ const universalIdLookupBySourceId_ConfigPropertyMetadata = [
194
195
  generateParamConfigMetadata('sourceRecordId', true, 0 /* UrlParameter */, 0 /* String */),
195
196
  generateParamConfigMetadata('dataspace', false, 1 /* QueryParameter */, 0 /* String */),
196
197
  ];
197
- const universalIdLookupBySourceId_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, universalIdLookupBySourceId_ConfigPropertyMetadata);
198
- const createResourceParams = /*#__PURE__*/ createResourceParams$1(universalIdLookupBySourceId_ConfigPropertyMetadata);
199
- function keyBuilder(luvio, config) {
200
- const resourceParams = createResourceParams(config);
201
- return keyBuilder$1(luvio, resourceParams);
198
+ const universalIdLookupBySourceId_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, universalIdLookupBySourceId_ConfigPropertyMetadata);
199
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(universalIdLookupBySourceId_ConfigPropertyMetadata);
200
+ function keyBuilder$1(luvio, config) {
201
+ const resourceParams = createResourceParams$1(config);
202
+ return keyBuilder$2(luvio, resourceParams);
202
203
  }
203
- function typeCheckConfig(untrustedConfig) {
204
+ function typeCheckConfig$1(untrustedConfig) {
204
205
  const config = {};
205
- typeCheckConfig$1(untrustedConfig, config, universalIdLookupBySourceId_ConfigPropertyMetadata);
206
+ typeCheckConfig$2(untrustedConfig, config, universalIdLookupBySourceId_ConfigPropertyMetadata);
206
207
  return config;
207
208
  }
208
- function validateAdapterConfig(untrustedConfig, configPropertyNames) {
209
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
209
210
  if (!untrustedIsObject(untrustedConfig)) {
210
211
  return null;
211
212
  }
212
213
  if (process.env.NODE_ENV !== 'production') {
213
214
  validateConfig(untrustedConfig, configPropertyNames);
214
215
  }
215
- const config = typeCheckConfig(untrustedConfig);
216
+ const config = typeCheckConfig$1(untrustedConfig);
216
217
  if (!areRequiredParametersPresent(config, configPropertyNames)) {
217
218
  return null;
218
219
  }
219
220
  return config;
220
221
  }
221
222
  function adapterFragment(luvio, config) {
222
- createResourceParams(config);
223
- return select();
223
+ createResourceParams$1(config);
224
+ return select$2();
224
225
  }
225
226
  function onFetchResponseSuccess(luvio, config, resourceParams, response) {
226
- const snapshot = ingestSuccess(luvio, resourceParams, response, {
227
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
227
228
  config,
228
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
229
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
229
230
  });
230
231
  return luvio.storeBroadcast().then(() => snapshot);
231
232
  }
232
233
  function onFetchResponseError(luvio, config, resourceParams, response) {
233
234
  const snapshot = ingestError(luvio, resourceParams, response, {
234
235
  config,
235
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
236
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
236
237
  });
237
238
  return luvio.storeBroadcast().then(() => snapshot);
238
239
  }
239
- function buildNetworkSnapshot(luvio, config, options) {
240
- const resourceParams = createResourceParams(config);
241
- const request = createResourceRequest(resourceParams);
240
+ function buildNetworkSnapshot$1(luvio, config, options) {
241
+ const resourceParams = createResourceParams$1(config);
242
+ const request = createResourceRequest$1(resourceParams);
242
243
  return luvio.dispatchResourceRequest(request, options)
243
244
  .then((response) => {
244
245
  return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
245
246
  const cache = new StoreKeyMap();
246
- getResponseCacheKeys(cache, luvio, resourceParams, response.body);
247
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
247
248
  return cache;
248
249
  });
249
250
  }, (response) => {
@@ -251,23 +252,23 @@ function buildNetworkSnapshot(luvio, config, options) {
251
252
  });
252
253
  }
253
254
  function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
254
- return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, undefined, false);
255
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
255
256
  }
256
257
  function buildCachedSnapshotCachePolicy(context, storeLookup) {
257
258
  const { luvio, config } = context;
258
259
  const selector = {
259
- recordId: keyBuilder(luvio, config),
260
+ recordId: keyBuilder$1(luvio, config),
260
261
  node: adapterFragment(luvio, config),
261
262
  variables: {},
262
263
  };
263
264
  const cacheSnapshot = storeLookup(selector, {
264
265
  config,
265
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
266
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
266
267
  });
267
268
  return cacheSnapshot;
268
269
  }
269
270
  const universalIdLookupBySourceIdAdapterFactory = (luvio) => function cdpQuery__universalIdLookupBySourceId(untrustedConfig, requestContext) {
270
- const config = validateAdapterConfig(untrustedConfig, universalIdLookupBySourceId_ConfigPropertyNames);
271
+ const config = validateAdapterConfig$1(untrustedConfig, universalIdLookupBySourceId_ConfigPropertyNames);
271
272
  // Invalid or incomplete config
272
273
  if (config === null) {
273
274
  return null;
@@ -276,4 +277,209 @@ const universalIdLookupBySourceIdAdapterFactory = (luvio) => function cdpQuery__
276
277
  buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
277
278
  };
278
279
 
279
- export { universalIdLookupBySourceIdAdapterFactory };
280
+ const TTL = 100;
281
+ const VERSION = "318ac9ee34fe90764a782a1b3eac7d16";
282
+ function validate(obj, path = 'CdpQueryOutputRepresentation') {
283
+ const v_error = (() => {
284
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
285
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
286
+ }
287
+ const obj_data = obj.data;
288
+ const path_data = path + '.data';
289
+ if (!ArrayIsArray(obj_data)) {
290
+ return new TypeError('Expected "array" but received "' + typeof obj_data + '" (at "' + path_data + '")');
291
+ }
292
+ for (let i = 0; i < obj_data.length; i++) {
293
+ const obj_data_item = obj_data[i];
294
+ const path_data_item = path_data + '[' + i + ']';
295
+ if (typeof obj_data_item !== 'object' || ArrayIsArray(obj_data_item) || obj_data_item === null) {
296
+ return new TypeError('Expected "object" but received "' + typeof obj_data_item + '" (at "' + path_data_item + '")');
297
+ }
298
+ }
299
+ const obj_done = obj.done;
300
+ const path_done = path + '.done';
301
+ if (typeof obj_done !== 'boolean') {
302
+ return new TypeError('Expected "boolean" but received "' + typeof obj_done + '" (at "' + path_done + '")');
303
+ }
304
+ const obj_endTime = obj.endTime;
305
+ const path_endTime = path + '.endTime';
306
+ if (typeof obj_endTime !== 'string') {
307
+ return new TypeError('Expected "string" but received "' + typeof obj_endTime + '" (at "' + path_endTime + '")');
308
+ }
309
+ const obj_metadata = obj.metadata;
310
+ const path_metadata = path + '.metadata';
311
+ if (typeof obj_metadata !== 'object' || ArrayIsArray(obj_metadata) || obj_metadata === null) {
312
+ return new TypeError('Expected "object" but received "' + typeof obj_metadata + '" (at "' + path_metadata + '")');
313
+ }
314
+ const obj_metadata_keys = ObjectKeys(obj_metadata);
315
+ for (let i = 0; i < obj_metadata_keys.length; i++) {
316
+ const key = obj_metadata_keys[i];
317
+ const obj_metadata_prop = obj_metadata[key];
318
+ const path_metadata_prop = path_metadata + '["' + key + '"]';
319
+ if (typeof obj_metadata_prop !== 'object' || ArrayIsArray(obj_metadata_prop) || obj_metadata_prop === null) {
320
+ return new TypeError('Expected "object" but received "' + typeof obj_metadata_prop + '" (at "' + path_metadata_prop + '")');
321
+ }
322
+ }
323
+ const obj_queryId = obj.queryId;
324
+ const path_queryId = path + '.queryId';
325
+ if (typeof obj_queryId !== 'string') {
326
+ return new TypeError('Expected "string" but received "' + typeof obj_queryId + '" (at "' + path_queryId + '")');
327
+ }
328
+ const obj_rowCount = obj.rowCount;
329
+ const path_rowCount = path + '.rowCount';
330
+ if (typeof obj_rowCount !== 'number' || (typeof obj_rowCount === 'number' && Math.floor(obj_rowCount) !== obj_rowCount)) {
331
+ return new TypeError('Expected "integer" but received "' + typeof obj_rowCount + '" (at "' + path_rowCount + '")');
332
+ }
333
+ const obj_startTime = obj.startTime;
334
+ const path_startTime = path + '.startTime';
335
+ if (typeof obj_startTime !== 'string') {
336
+ return new TypeError('Expected "string" but received "' + typeof obj_startTime + '" (at "' + path_startTime + '")');
337
+ }
338
+ })();
339
+ return v_error === undefined ? null : v_error;
340
+ }
341
+ const RepresentationType = 'CdpQueryOutputRepresentation';
342
+ function keyBuilder(luvio, config) {
343
+ return keyPrefix + '::' + RepresentationType + ':' + config.id;
344
+ }
345
+ function keyBuilderFromType(luvio, object) {
346
+ const keyParams = {
347
+ id: object.queryId
348
+ };
349
+ return keyBuilder(luvio, keyParams);
350
+ }
351
+ function normalize(input, existing, path, luvio, store, timestamp) {
352
+ return input;
353
+ }
354
+ const select$1 = function CdpQueryOutputRepresentationSelect() {
355
+ return {
356
+ kind: 'Fragment',
357
+ version: VERSION,
358
+ private: [],
359
+ opaque: true
360
+ };
361
+ };
362
+ function equals(existing, incoming) {
363
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
364
+ return false;
365
+ }
366
+ return true;
367
+ }
368
+ const ingest = function CdpQueryOutputRepresentationIngest(input, path, luvio, store, timestamp) {
369
+ if (process.env.NODE_ENV !== 'production') {
370
+ const validateError = validate(input);
371
+ if (validateError !== null) {
372
+ throw validateError;
373
+ }
374
+ }
375
+ const key = keyBuilderFromType(luvio, input);
376
+ const ttlToUse = TTL;
377
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "cdp-query", VERSION, RepresentationType, equals);
378
+ return createLink(key);
379
+ };
380
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
381
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
382
+ const rootKey = keyBuilderFromType(luvio, input);
383
+ rootKeySet.set(rootKey, {
384
+ namespace: keyPrefix,
385
+ representationName: RepresentationType,
386
+ mergeable: false
387
+ });
388
+ }
389
+
390
+ function select(luvio, params) {
391
+ return select$1();
392
+ }
393
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
394
+ getTypeCacheKeys(storeKeyMap, luvio, response);
395
+ }
396
+ function ingestSuccess(luvio, resourceParams, response) {
397
+ const { body } = response;
398
+ const key = keyBuilderFromType(luvio, body);
399
+ luvio.storeIngest(key, ingest, body);
400
+ const snapshot = luvio.storeLookup({
401
+ recordId: key,
402
+ node: select(),
403
+ variables: {},
404
+ });
405
+ if (process.env.NODE_ENV !== 'production') {
406
+ if (snapshot.state !== 'Fulfilled') {
407
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
408
+ }
409
+ }
410
+ deepFreeze(snapshot.data);
411
+ return snapshot;
412
+ }
413
+ function createResourceRequest(config) {
414
+ const headers = {};
415
+ return {
416
+ baseUri: '/services/data/v62.0',
417
+ basePath: '/ssot/query',
418
+ method: 'post',
419
+ body: config.body,
420
+ urlParams: {},
421
+ queryParams: config.queryParams,
422
+ headers,
423
+ priority: 'normal',
424
+ };
425
+ }
426
+
427
+ const adapterName = 'cdpQuery';
428
+ const cdpQuery_ConfigPropertyMetadata = [
429
+ generateParamConfigMetadata('batchSize', false, 1 /* QueryParameter */, 3 /* Integer */),
430
+ generateParamConfigMetadata('dataspace', false, 1 /* QueryParameter */, 0 /* String */),
431
+ generateParamConfigMetadata('offset', false, 1 /* QueryParameter */, 3 /* Integer */),
432
+ generateParamConfigMetadata('orderby', false, 1 /* QueryParameter */, 0 /* String */),
433
+ generateParamConfigMetadata('sql', true, 2 /* Body */, 0 /* String */),
434
+ generateParamConfigMetadata('userAgent', true, 2 /* Body */, 0 /* String */),
435
+ ];
436
+ const cdpQuery_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, cdpQuery_ConfigPropertyMetadata);
437
+ const createResourceParams = /*#__PURE__*/ createResourceParams$2(cdpQuery_ConfigPropertyMetadata);
438
+ function typeCheckConfig(untrustedConfig) {
439
+ const config = {};
440
+ typeCheckConfig$2(untrustedConfig, config, cdpQuery_ConfigPropertyMetadata);
441
+ return config;
442
+ }
443
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
444
+ if (!untrustedIsObject(untrustedConfig)) {
445
+ return null;
446
+ }
447
+ if (process.env.NODE_ENV !== 'production') {
448
+ validateConfig(untrustedConfig, configPropertyNames);
449
+ }
450
+ const config = typeCheckConfig(untrustedConfig);
451
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
452
+ return null;
453
+ }
454
+ return config;
455
+ }
456
+ function buildNetworkSnapshot(luvio, config, options) {
457
+ const resourceParams = createResourceParams(config);
458
+ const request = createResourceRequest(resourceParams);
459
+ return luvio.dispatchResourceRequest(request, options)
460
+ .then((response) => {
461
+ return luvio.handleSuccessResponse(() => {
462
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
463
+ return luvio.storeBroadcast().then(() => snapshot);
464
+ }, () => {
465
+ const cache = new StoreKeyMap();
466
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
467
+ return cache;
468
+ });
469
+ }, (response) => {
470
+ deepFreeze(response);
471
+ throw response;
472
+ });
473
+ }
474
+ const cdpQueryAdapterFactory = (luvio) => {
475
+ return function cdpQuery(untrustedConfig) {
476
+ const config = validateAdapterConfig(untrustedConfig, cdpQuery_ConfigPropertyNames);
477
+ // Invalid or incomplete config
478
+ if (config === null) {
479
+ throw new Error('Invalid config for "cdpQuery"');
480
+ }
481
+ return buildNetworkSnapshot(luvio, config);
482
+ };
483
+ };
484
+
485
+ export { cdpQueryAdapterFactory, universalIdLookupBySourceIdAdapterFactory };
@@ -0,0 +1,20 @@
1
+ import { AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata, Luvio as $64$luvio_engine_Luvio, DispatchResourceRequestContext as $64$luvio_engine_DispatchResourceRequestContext, AdapterFactory as $64$luvio_engine_AdapterFactory } from '@luvio/engine';
2
+ import { Untrusted as adapter$45$utils_Untrusted, AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig } from './adapter-utils';
3
+ import { ResourceRequestConfig as resources_postSsotQuery_ResourceRequestConfig } from '../resources/postSsotQuery';
4
+ import { CdpQueryOutputRepresentation as types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation } from '../types/CdpQueryOutputRepresentation';
5
+ export declare const adapterName = "cdpQuery";
6
+ export declare const cdpQuery_ConfigPropertyMetadata: $64$luvio_engine_AdapterConfigMetadata[];
7
+ export declare const cdpQuery_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
8
+ export interface CdpQueryConfig {
9
+ batchSize?: number;
10
+ dataspace?: string;
11
+ offset?: number;
12
+ orderby?: string;
13
+ sql: string;
14
+ userAgent: string;
15
+ }
16
+ export declare const createResourceParams: (config: CdpQueryConfig) => resources_postSsotQuery_ResourceRequestConfig;
17
+ export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<CdpQueryConfig>): adapter$45$utils_Untrusted<CdpQueryConfig>;
18
+ export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): CdpQueryConfig | null;
19
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: CdpQueryConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation, any>>;
20
+ export declare const cdpQueryAdapterFactory: $64$luvio_engine_AdapterFactory<CdpQueryConfig, types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation>;
@@ -1 +1,2 @@
1
1
  export { universalIdLookupBySourceIdAdapterFactory } from '../adapters/universalIdLookupBySourceId';
2
+ export { cdpQueryAdapterFactory } from '../adapters/cdpQuery';
@@ -1,3 +1,4 @@
1
+ declare let cdpQuery: any;
1
2
  declare let universalIdLookupBySourceId: any;
2
3
  declare let universalIdLookupBySourceId_imperative: any;
3
- export { universalIdLookupBySourceId, universalIdLookupBySourceId_imperative };
4
+ export { cdpQuery, universalIdLookupBySourceId, universalIdLookupBySourceId_imperative };
@@ -0,0 +1,19 @@
1
+ import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, FetchResponse as $64$luvio_engine_FetchResponse, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
2
+ import { CdpQueryOutputRepresentation as types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation } from '../types/CdpQueryOutputRepresentation';
3
+ export interface ResourceRequestConfig {
4
+ queryParams: {
5
+ batchSize?: number;
6
+ dataspace?: string;
7
+ offset?: number;
8
+ orderby?: string;
9
+ };
10
+ body: {
11
+ sql: string;
12
+ userAgent: string;
13
+ };
14
+ }
15
+ export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
16
+ export declare function getResponseCacheKeys(storeKeyMap: any, luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation): void;
17
+ export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_CdpQueryOutputRepresentation_CdpQueryOutputRepresentation, any>;
18
+ export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
19
+ export default createResourceRequest;
@@ -0,0 +1,31 @@
1
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
2
+ export declare const VERSION = "97f287735601dbb1a4cee846d93ead08";
3
+ export declare function validate(obj: any, path?: string): TypeError | null;
4
+ export declare const RepresentationType: string;
5
+ export declare function normalize(input: CdpQueryInputRepresentation, existing: CdpQueryInputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): CdpQueryInputRepresentationNormalized;
6
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
7
+ export declare function equals(existing: CdpQueryInputRepresentationNormalized, incoming: CdpQueryInputRepresentationNormalized): boolean;
8
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
9
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: CdpQueryInputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
10
+ /**
11
+ * Input representation for creating CDP query
12
+ *
13
+ * Keys:
14
+ * (none)
15
+ */
16
+ export interface CdpQueryInputRepresentationNormalized {
17
+ /** Sql */
18
+ sql: string;
19
+ /** UserAgent */
20
+ userAgent: string;
21
+ }
22
+ /**
23
+ * Input representation for creating CDP query
24
+ *
25
+ * Keys:
26
+ * (none)
27
+ */
28
+ export interface CdpQueryInputRepresentation {
29
+ sql: string;
30
+ userAgent: string;
31
+ }
@@ -0,0 +1,60 @@
1
+ import { KeyMetadata as $64$luvio_engine_KeyMetadata, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, Luvio as $64$luvio_engine_Luvio, IngestPath as $64$luvio_engine_IngestPath, Store as $64$luvio_engine_Store, BaseFragment as $64$luvio_engine_BaseFragment, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
2
+ export declare const TTL = 100;
3
+ export declare const VERSION = "318ac9ee34fe90764a782a1b3eac7d16";
4
+ export declare function validate(obj: any, path?: string): TypeError | null;
5
+ export declare const RepresentationType: string;
6
+ export interface KeyParams extends $64$luvio_engine_KeyMetadata {
7
+ id: string;
8
+ }
9
+ export type CdpQueryOutputRepresentationNormalizedKeyMetadata = KeyParams & $64$luvio_engine_NormalizedKeyMetadata;
10
+ export type PartialCdpQueryOutputRepresentationNormalizedKeyMetadata = Partial<KeyParams> & $64$luvio_engine_NormalizedKeyMetadata;
11
+ export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: KeyParams): string;
12
+ export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: KeyParams): CdpQueryOutputRepresentationNormalizedKeyMetadata;
13
+ export declare function keyBuilderFromType(luvio: $64$luvio_engine_Luvio, object: CdpQueryOutputRepresentation): string;
14
+ export declare function keyBuilderFromType_StructuredKey(luvio: $64$luvio_engine_Luvio, object: CdpQueryOutputRepresentation): $64$luvio_engine_NormalizedKeyMetadata;
15
+ export declare function normalize(input: CdpQueryOutputRepresentation, existing: CdpQueryOutputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): CdpQueryOutputRepresentationNormalized;
16
+ export declare const select: () => $64$luvio_engine_BaseFragment;
17
+ export declare function equals(existing: CdpQueryOutputRepresentationNormalized, incoming: CdpQueryOutputRepresentationNormalized): boolean;
18
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
19
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: CdpQueryOutputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
20
+ /**
21
+ * Represents Cdp Query output
22
+ *
23
+ * Keys:
24
+ * id (string): queryId
25
+ */
26
+ export interface CdpQueryOutputRepresentationNormalized {
27
+ /** Result data set */
28
+ data: Array<{}>;
29
+ /** Query start time */
30
+ done: boolean;
31
+ /** Query end time */
32
+ endTime: string;
33
+ /** Query start time */
34
+ metadata: {
35
+ [key: string]: {};
36
+ };
37
+ /** Query Id */
38
+ queryId: string;
39
+ /** Query start time */
40
+ rowCount: number;
41
+ /** Query start time */
42
+ startTime: string;
43
+ }
44
+ /**
45
+ * Represents Cdp Query output
46
+ *
47
+ * Keys:
48
+ * id (string): queryId
49
+ */
50
+ export interface CdpQueryOutputRepresentation {
51
+ data: Array<{}>;
52
+ done: boolean;
53
+ endTime: string;
54
+ metadata: {
55
+ [key: string]: {};
56
+ };
57
+ queryId: string;
58
+ rowCount: number;
59
+ startTime: string;
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-cdp-query",
3
- "version": "1.308.0-dev7",
3
+ "version": "1.309.0-dev10",
4
4
  "description": "CDP Query",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "dist/es/es2018/cdp-query.js",
@@ -40,10 +40,10 @@
40
40
  "test:unit": "jest"
41
41
  },
42
42
  "dependencies": {
43
- "@salesforce/lds-bindings": "^1.308.0-dev7"
43
+ "@salesforce/lds-bindings": "^1.309.0-dev10"
44
44
  },
45
45
  "devDependencies": {
46
- "@salesforce/lds-compiler-plugins": "^1.308.0-dev7"
46
+ "@salesforce/lds-compiler-plugins": "^1.309.0-dev10"
47
47
  },
48
48
  "nx": {
49
49
  "targets": {
package/sfdc/index.js CHANGED
@@ -14,10 +14,10 @@
14
14
  /* proxy-compat-disable */
15
15
  import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
16
16
  import { withDefaultLuvio } from 'force/ldsEngine';
17
- import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$1, StoreKeyMap, createResourceParams as createResourceParams$1 } from 'force/luvioEngine';
17
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1 } from 'force/luvioEngine';
18
18
 
19
19
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
- const { keys: ObjectKeys, create: ObjectCreate } = Object;
20
+ const { keys: ObjectKeys$1, create: ObjectCreate$1 } = Object;
21
21
  const { isArray: ArrayIsArray$1 } = Array;
22
22
  /**
23
23
  * Validates an adapter config is well-formed.
@@ -41,7 +41,7 @@ function validateConfig(config, adapter, oneOf) {
41
41
  throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
42
42
  }
43
43
  const supported = required.concat(optional);
44
- if (ObjectKeys(config).some(key => !supported.includes(key))) {
44
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
45
45
  throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
46
46
  }
47
47
  }
@@ -81,6 +81,7 @@ function buildAdapterValidationConfig(displayName, paramsMeta) {
81
81
  }
82
82
  const keyPrefix = 'cdp-query';
83
83
 
84
+ const { keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
84
85
  const { isArray: ArrayIsArray } = Array;
85
86
  const { stringify: JSONStringify } = JSON;
86
87
  function createLink(ref) {
@@ -89,6 +90,211 @@ function createLink(ref) {
89
90
  };
90
91
  }
91
92
 
93
+ const TTL = 100;
94
+ const VERSION$1 = "318ac9ee34fe90764a782a1b3eac7d16";
95
+ function validate$1(obj, path = 'CdpQueryOutputRepresentation') {
96
+ const v_error = (() => {
97
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
98
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
99
+ }
100
+ const obj_data = obj.data;
101
+ const path_data = path + '.data';
102
+ if (!ArrayIsArray(obj_data)) {
103
+ return new TypeError('Expected "array" but received "' + typeof obj_data + '" (at "' + path_data + '")');
104
+ }
105
+ for (let i = 0; i < obj_data.length; i++) {
106
+ const obj_data_item = obj_data[i];
107
+ const path_data_item = path_data + '[' + i + ']';
108
+ if (typeof obj_data_item !== 'object' || ArrayIsArray(obj_data_item) || obj_data_item === null) {
109
+ return new TypeError('Expected "object" but received "' + typeof obj_data_item + '" (at "' + path_data_item + '")');
110
+ }
111
+ }
112
+ const obj_done = obj.done;
113
+ const path_done = path + '.done';
114
+ if (typeof obj_done !== 'boolean') {
115
+ return new TypeError('Expected "boolean" but received "' + typeof obj_done + '" (at "' + path_done + '")');
116
+ }
117
+ const obj_endTime = obj.endTime;
118
+ const path_endTime = path + '.endTime';
119
+ if (typeof obj_endTime !== 'string') {
120
+ return new TypeError('Expected "string" but received "' + typeof obj_endTime + '" (at "' + path_endTime + '")');
121
+ }
122
+ const obj_metadata = obj.metadata;
123
+ const path_metadata = path + '.metadata';
124
+ if (typeof obj_metadata !== 'object' || ArrayIsArray(obj_metadata) || obj_metadata === null) {
125
+ return new TypeError('Expected "object" but received "' + typeof obj_metadata + '" (at "' + path_metadata + '")');
126
+ }
127
+ const obj_metadata_keys = ObjectKeys(obj_metadata);
128
+ for (let i = 0; i < obj_metadata_keys.length; i++) {
129
+ const key = obj_metadata_keys[i];
130
+ const obj_metadata_prop = obj_metadata[key];
131
+ const path_metadata_prop = path_metadata + '["' + key + '"]';
132
+ if (typeof obj_metadata_prop !== 'object' || ArrayIsArray(obj_metadata_prop) || obj_metadata_prop === null) {
133
+ return new TypeError('Expected "object" but received "' + typeof obj_metadata_prop + '" (at "' + path_metadata_prop + '")');
134
+ }
135
+ }
136
+ const obj_queryId = obj.queryId;
137
+ const path_queryId = path + '.queryId';
138
+ if (typeof obj_queryId !== 'string') {
139
+ return new TypeError('Expected "string" but received "' + typeof obj_queryId + '" (at "' + path_queryId + '")');
140
+ }
141
+ const obj_rowCount = obj.rowCount;
142
+ const path_rowCount = path + '.rowCount';
143
+ if (typeof obj_rowCount !== 'number' || (typeof obj_rowCount === 'number' && Math.floor(obj_rowCount) !== obj_rowCount)) {
144
+ return new TypeError('Expected "integer" but received "' + typeof obj_rowCount + '" (at "' + path_rowCount + '")');
145
+ }
146
+ const obj_startTime = obj.startTime;
147
+ const path_startTime = path + '.startTime';
148
+ if (typeof obj_startTime !== 'string') {
149
+ return new TypeError('Expected "string" but received "' + typeof obj_startTime + '" (at "' + path_startTime + '")');
150
+ }
151
+ })();
152
+ return v_error === undefined ? null : v_error;
153
+ }
154
+ const RepresentationType$1 = 'CdpQueryOutputRepresentation';
155
+ function keyBuilder$2(luvio, config) {
156
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.id;
157
+ }
158
+ function keyBuilderFromType(luvio, object) {
159
+ const keyParams = {
160
+ id: object.queryId
161
+ };
162
+ return keyBuilder$2(luvio, keyParams);
163
+ }
164
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
165
+ return input;
166
+ }
167
+ const select$3 = function CdpQueryOutputRepresentationSelect() {
168
+ return {
169
+ kind: 'Fragment',
170
+ version: VERSION$1,
171
+ private: [],
172
+ opaque: true
173
+ };
174
+ };
175
+ function equals$1(existing, incoming) {
176
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
177
+ return false;
178
+ }
179
+ return true;
180
+ }
181
+ const ingest$1 = function CdpQueryOutputRepresentationIngest(input, path, luvio, store, timestamp) {
182
+ if (process.env.NODE_ENV !== 'production') {
183
+ const validateError = validate$1(input);
184
+ if (validateError !== null) {
185
+ throw validateError;
186
+ }
187
+ }
188
+ const key = keyBuilderFromType(luvio, input);
189
+ const ttlToUse = TTL;
190
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "cdp-query", VERSION$1, RepresentationType$1, equals$1);
191
+ return createLink(key);
192
+ };
193
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
194
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
195
+ const rootKey = keyBuilderFromType(luvio, input);
196
+ rootKeySet.set(rootKey, {
197
+ namespace: keyPrefix,
198
+ representationName: RepresentationType$1,
199
+ mergeable: false
200
+ });
201
+ }
202
+
203
+ function select$2(luvio, params) {
204
+ return select$3();
205
+ }
206
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
207
+ getTypeCacheKeys$1(storeKeyMap, luvio, response);
208
+ }
209
+ function ingestSuccess$1(luvio, resourceParams, response) {
210
+ const { body } = response;
211
+ const key = keyBuilderFromType(luvio, body);
212
+ luvio.storeIngest(key, ingest$1, body);
213
+ const snapshot = luvio.storeLookup({
214
+ recordId: key,
215
+ node: select$2(),
216
+ variables: {},
217
+ });
218
+ if (process.env.NODE_ENV !== 'production') {
219
+ if (snapshot.state !== 'Fulfilled') {
220
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
221
+ }
222
+ }
223
+ deepFreeze(snapshot.data);
224
+ return snapshot;
225
+ }
226
+ function createResourceRequest$1(config) {
227
+ const headers = {};
228
+ return {
229
+ baseUri: '/services/data/v62.0',
230
+ basePath: '/ssot/query',
231
+ method: 'post',
232
+ body: config.body,
233
+ urlParams: {},
234
+ queryParams: config.queryParams,
235
+ headers,
236
+ priority: 'normal',
237
+ };
238
+ }
239
+
240
+ const adapterName$1 = 'cdpQuery';
241
+ const cdpQuery_ConfigPropertyMetadata = [
242
+ generateParamConfigMetadata('batchSize', false, 1 /* QueryParameter */, 3 /* Integer */),
243
+ generateParamConfigMetadata('dataspace', false, 1 /* QueryParameter */, 0 /* String */),
244
+ generateParamConfigMetadata('offset', false, 1 /* QueryParameter */, 3 /* Integer */),
245
+ generateParamConfigMetadata('orderby', false, 1 /* QueryParameter */, 0 /* String */),
246
+ generateParamConfigMetadata('sql', true, 2 /* Body */, 0 /* String */),
247
+ generateParamConfigMetadata('userAgent', true, 2 /* Body */, 0 /* String */),
248
+ ];
249
+ const cdpQuery_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, cdpQuery_ConfigPropertyMetadata);
250
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(cdpQuery_ConfigPropertyMetadata);
251
+ function typeCheckConfig$1(untrustedConfig) {
252
+ const config = {};
253
+ typeCheckConfig$2(untrustedConfig, config, cdpQuery_ConfigPropertyMetadata);
254
+ return config;
255
+ }
256
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
257
+ if (!untrustedIsObject(untrustedConfig)) {
258
+ return null;
259
+ }
260
+ if (process.env.NODE_ENV !== 'production') {
261
+ validateConfig(untrustedConfig, configPropertyNames);
262
+ }
263
+ const config = typeCheckConfig$1(untrustedConfig);
264
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
265
+ return null;
266
+ }
267
+ return config;
268
+ }
269
+ function buildNetworkSnapshot$1(luvio, config, options) {
270
+ const resourceParams = createResourceParams$1(config);
271
+ const request = createResourceRequest$1(resourceParams);
272
+ return luvio.dispatchResourceRequest(request, options)
273
+ .then((response) => {
274
+ return luvio.handleSuccessResponse(() => {
275
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response);
276
+ return luvio.storeBroadcast().then(() => snapshot);
277
+ }, () => {
278
+ const cache = new StoreKeyMap();
279
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
280
+ return cache;
281
+ });
282
+ }, (response) => {
283
+ deepFreeze(response);
284
+ throw response;
285
+ });
286
+ }
287
+ const cdpQueryAdapterFactory = (luvio) => {
288
+ return function cdpQuery(untrustedConfig) {
289
+ const config = validateAdapterConfig$1(untrustedConfig, cdpQuery_ConfigPropertyNames);
290
+ // Invalid or incomplete config
291
+ if (config === null) {
292
+ throw new Error('Invalid config for "cdpQuery"');
293
+ }
294
+ return buildNetworkSnapshot$1(luvio, config);
295
+ };
296
+ };
297
+
92
298
  const VERSION = "7df04f81d9b64d7cdebf01b86018ba25";
93
299
  function validate(obj, path = 'CdpQueryDataOutputRepresentation') {
94
300
  const v_error = (() => {
@@ -205,14 +411,14 @@ const universalIdLookupBySourceId_ConfigPropertyMetadata = [
205
411
  generateParamConfigMetadata('dataspace', false, 1 /* QueryParameter */, 0 /* String */),
206
412
  ];
207
413
  const universalIdLookupBySourceId_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, universalIdLookupBySourceId_ConfigPropertyMetadata);
208
- const createResourceParams = /*#__PURE__*/ createResourceParams$1(universalIdLookupBySourceId_ConfigPropertyMetadata);
414
+ const createResourceParams = /*#__PURE__*/ createResourceParams$2(universalIdLookupBySourceId_ConfigPropertyMetadata);
209
415
  function keyBuilder(luvio, config) {
210
416
  const resourceParams = createResourceParams(config);
211
417
  return keyBuilder$1(luvio, resourceParams);
212
418
  }
213
419
  function typeCheckConfig(untrustedConfig) {
214
420
  const config = {};
215
- typeCheckConfig$1(untrustedConfig, config, universalIdLookupBySourceId_ConfigPropertyMetadata);
421
+ typeCheckConfig$2(untrustedConfig, config, universalIdLookupBySourceId_ConfigPropertyMetadata);
216
422
  return config;
217
423
  }
218
424
  function validateAdapterConfig(untrustedConfig, configPropertyNames) {
@@ -286,10 +492,10 @@ const universalIdLookupBySourceIdAdapterFactory = (luvio) => function cdpQuery__
286
492
  buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
287
493
  };
288
494
 
495
+ let cdpQuery;
289
496
  let universalIdLookupBySourceId;
290
497
  // Imperative GET Adapters
291
498
  let universalIdLookupBySourceId_imperative;
292
- // Adapter Metadata
293
499
  const universalIdLookupBySourceIdMetadata = {
294
500
  apiFamily: 'cdpquery',
295
501
  name: 'universalIdLookupBySourceId',
@@ -298,7 +504,12 @@ const universalIdLookupBySourceIdMetadata = {
298
504
  function bindExportsTo(luvio) {
299
505
  // LDS Adapters
300
506
  const universalIdLookupBySourceId_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'universalIdLookupBySourceId', universalIdLookupBySourceIdAdapterFactory), universalIdLookupBySourceIdMetadata);
507
+ function unwrapSnapshotData(factory) {
508
+ const adapter = factory(luvio);
509
+ return (config) => adapter(config).then((snapshot) => snapshot.data);
510
+ }
301
511
  return {
512
+ cdpQuery: unwrapSnapshotData(cdpQueryAdapterFactory),
302
513
  universalIdLookupBySourceId: createWireAdapterConstructor(luvio, universalIdLookupBySourceId_ldsAdapter, universalIdLookupBySourceIdMetadata),
303
514
  // Imperative GET Adapters
304
515
  universalIdLookupBySourceId_imperative: createImperativeAdapter(luvio, universalIdLookupBySourceId_ldsAdapter, universalIdLookupBySourceIdMetadata),
@@ -306,9 +517,9 @@ function bindExportsTo(luvio) {
306
517
  };
307
518
  }
308
519
  withDefaultLuvio((luvio) => {
309
- ({ universalIdLookupBySourceId, universalIdLookupBySourceId_imperative } =
520
+ ({ cdpQuery, universalIdLookupBySourceId, universalIdLookupBySourceId_imperative } =
310
521
  bindExportsTo(luvio));
311
522
  });
312
523
 
313
- export { universalIdLookupBySourceId, universalIdLookupBySourceId_imperative };
314
- // version: 1.308.0-dev7-8ae69a25e5
524
+ export { cdpQuery, universalIdLookupBySourceId, universalIdLookupBySourceId_imperative };
525
+ // version: 1.309.0-dev10-96422fc06f
package/src/raml/api.raml CHANGED
@@ -34,6 +34,46 @@ types:
34
34
  type: array
35
35
  items:
36
36
  type: any # TODO hand rolled. W-15573704
37
+ CdpQueryInputRepresentation:
38
+ description: Input representation for creating CDP query
39
+ type: object
40
+ properties:
41
+ sql:
42
+ description: Sql
43
+ type: string
44
+ userAgent:
45
+ description: UserAgent
46
+ type: string
47
+ CdpQueryOutputRepresentation:
48
+ description: Represents Cdp Query output
49
+ type: object
50
+ properties:
51
+ data:
52
+ description: Result data set
53
+ type: array
54
+ items:
55
+ type: object
56
+ done:
57
+ description: Query start time
58
+ type: boolean
59
+ endTime:
60
+ description: Query end time
61
+ type: string
62
+ metadata:
63
+ description: Query start time
64
+ type: object
65
+ properties:
66
+ //:
67
+ type: object
68
+ queryId:
69
+ description: Query Id
70
+ type: string
71
+ rowCount:
72
+ description: Query start time
73
+ type: integer
74
+ startTime:
75
+ description: Query start time
76
+ type: string
37
77
 
38
78
  /ssot:
39
79
  /universalIdLookup/{entityName}/{dataSourceId}/{dataSourceObjectId}/{sourceRecordId}:
@@ -63,3 +103,31 @@ types:
63
103
  sourceRecordId:
64
104
  type: string
65
105
  required: true
106
+ /query:
107
+ post:
108
+ displayName: postCdpQuery
109
+ description: Queries off-core data
110
+ responses:
111
+ '200':
112
+ description: Success
113
+ body:
114
+ application/json:
115
+ type: CdpQueryOutputRepresentation
116
+ queryParameters:
117
+ batchSize:
118
+ type: integer
119
+ required: false
120
+ dataspace:
121
+ type: string
122
+ required: false
123
+ offset:
124
+ type: integer
125
+ required: false
126
+ orderby:
127
+ type: string
128
+ required: false
129
+ body:
130
+ application/json:
131
+ type: CdpQueryInputRepresentation
132
+ # TODO hand-rolled W-9271732 (removed required: false)
133
+ (oas-body-name): input
@@ -11,8 +11,18 @@ types:
11
11
  CdpQueryDataOutputRepresentation:
12
12
  (luvio.opaque): true
13
13
 
14
+ CdpQueryOutputRepresentation:
15
+ (luvio.opaque): true
16
+ (luvio.key):
17
+ id: queryId
18
+ (luvio.ttl): 100
19
+
14
20
  /ssot:
15
21
  /universalIdLookup/{entityName}/{dataSourceId}/{dataSourceObjectId}/{sourceRecordId}:
16
22
  get:
17
23
  (luvio.adapter):
18
24
  name: universalIdLookupBySourceId
25
+ /query:
26
+ post:
27
+ (luvio.adapter):
28
+ name: cdpQuery