@salesforce/lds-adapters-cdp-query 0.1.0-dev1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sfdc/index.js ADDED
@@ -0,0 +1,525 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /*
8
+ * ATTENTION!
9
+ * THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
10
+ * If you would like to contribute to LDS, please follow the steps outlined in the git repo.
11
+ * Any changes made to this file in p4 will be automatically overwritten.
12
+ * *******************************************************************************************
13
+ */
14
+ /* proxy-compat-disable */
15
+ import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
16
+ import { withDefaultLuvio } from 'force/ldsEngine';
17
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1 } from 'force/luvioEngine';
18
+
19
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
+ const { keys: ObjectKeys$1, create: ObjectCreate$1 } = Object;
21
+ const { isArray: ArrayIsArray$1 } = Array;
22
+ /**
23
+ * Validates an adapter config is well-formed.
24
+ * @param config The config to validate.
25
+ * @param adapter The adapter validation configuration.
26
+ * @param oneOf The keys the config must contain at least one of.
27
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
28
+ */
29
+ function validateConfig(config, adapter, oneOf) {
30
+ const { displayName } = adapter;
31
+ const { required, optional, unsupported } = adapter.parameters;
32
+ if (config === undefined ||
33
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
34
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
35
+ }
36
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
37
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
38
+ }
39
+ if (unsupported !== undefined &&
40
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
41
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
42
+ }
43
+ const supported = required.concat(optional);
44
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
45
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
46
+ }
47
+ }
48
+ function untrustedIsObject(untrusted) {
49
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
50
+ }
51
+ function areRequiredParametersPresent(config, configPropertyNames) {
52
+ return configPropertyNames.parameters.required.every(req => req in config);
53
+ }
54
+ const snapshotRefreshOptions = {
55
+ overrides: {
56
+ headers: {
57
+ 'Cache-Control': 'no-cache',
58
+ },
59
+ }
60
+ };
61
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
62
+ return {
63
+ name,
64
+ required,
65
+ resourceType,
66
+ typeCheckShape,
67
+ isArrayShape,
68
+ coerceFn,
69
+ };
70
+ }
71
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
72
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
73
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
74
+ return {
75
+ displayName,
76
+ parameters: {
77
+ required,
78
+ optional,
79
+ }
80
+ };
81
+ }
82
+ const keyPrefix = 'cdp-query';
83
+
84
+ const { keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
85
+ const { isArray: ArrayIsArray } = Array;
86
+ const { stringify: JSONStringify } = JSON;
87
+ function createLink(ref) {
88
+ return {
89
+ __ref: serializeStructuredKey(ref),
90
+ };
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/v66.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
+
298
+ const VERSION = "7df04f81d9b64d7cdebf01b86018ba25";
299
+ function validate(obj, path = 'CdpQueryDataOutputRepresentation') {
300
+ const v_error = (() => {
301
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
302
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
303
+ }
304
+ const obj_data = obj.data;
305
+ const path_data = path + '.data';
306
+ if (!ArrayIsArray(obj_data)) {
307
+ return new TypeError('Expected "array" but received "' + typeof obj_data + '" (at "' + path_data + '")');
308
+ }
309
+ for (let i = 0; i < obj_data.length; i++) {
310
+ const obj_data_item = obj_data[i];
311
+ const path_data_item = path_data + '[' + i + ']';
312
+ if (obj_data_item === undefined) {
313
+ return new TypeError('Expected "defined" but received "' + typeof obj_data_item + '" (at "' + path_data_item + '")');
314
+ }
315
+ }
316
+ })();
317
+ return v_error === undefined ? null : v_error;
318
+ }
319
+ const RepresentationType = 'CdpQueryDataOutputRepresentation';
320
+ function normalize(input, existing, path, luvio, store, timestamp) {
321
+ return input;
322
+ }
323
+ const select$1 = function CdpQueryDataOutputRepresentationSelect() {
324
+ return {
325
+ kind: 'Fragment',
326
+ version: VERSION,
327
+ private: [],
328
+ opaque: true
329
+ };
330
+ };
331
+ function equals(existing, incoming) {
332
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
333
+ return false;
334
+ }
335
+ return true;
336
+ }
337
+ const ingest = function CdpQueryDataOutputRepresentationIngest(input, path, luvio, store, timestamp) {
338
+ if (process.env.NODE_ENV !== 'production') {
339
+ const validateError = validate(input);
340
+ if (validateError !== null) {
341
+ throw validateError;
342
+ }
343
+ }
344
+ const key = path.fullPath;
345
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 360000;
346
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "cdp-query", VERSION, RepresentationType, equals);
347
+ return createLink(key);
348
+ };
349
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
350
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
351
+ const rootKey = fullPathFactory();
352
+ rootKeySet.set(rootKey, {
353
+ namespace: keyPrefix,
354
+ representationName: RepresentationType,
355
+ mergeable: false
356
+ });
357
+ }
358
+
359
+ function select(luvio, params) {
360
+ return select$1();
361
+ }
362
+ function keyBuilder$1(luvio, params) {
363
+ return keyPrefix + '::CdpQueryDataOutputRepresentation:(' + 'dataspace:' + params.queryParams.dataspace + ',' + 'dataSourceId:' + params.urlParams.dataSourceId + ',' + 'dataSourceObjectId:' + params.urlParams.dataSourceObjectId + ',' + 'entityName:' + params.urlParams.entityName + ',' + 'sourceRecordId:' + params.urlParams.sourceRecordId + ')';
364
+ }
365
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
366
+ getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
367
+ }
368
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
369
+ const { body } = response;
370
+ const key = keyBuilder$1(luvio, resourceParams);
371
+ luvio.storeIngest(key, ingest, body);
372
+ const snapshot = luvio.storeLookup({
373
+ recordId: key,
374
+ node: select(),
375
+ variables: {},
376
+ }, snapshotRefresh);
377
+ if (process.env.NODE_ENV !== 'production') {
378
+ if (snapshot.state !== 'Fulfilled') {
379
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
380
+ }
381
+ }
382
+ deepFreeze(snapshot.data);
383
+ return snapshot;
384
+ }
385
+ function ingestError(luvio, params, error, snapshotRefresh) {
386
+ const key = keyBuilder$1(luvio, params);
387
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
388
+ luvio.storeIngestError(key, errorSnapshot);
389
+ return errorSnapshot;
390
+ }
391
+ function createResourceRequest(config) {
392
+ const headers = {};
393
+ return {
394
+ baseUri: '/services/data/v66.0',
395
+ basePath: '/ssot/universalIdLookup/' + config.urlParams.entityName + '/' + config.urlParams.dataSourceId + '/' + config.urlParams.dataSourceObjectId + '/' + config.urlParams.sourceRecordId + '',
396
+ method: 'get',
397
+ body: null,
398
+ urlParams: config.urlParams,
399
+ queryParams: config.queryParams,
400
+ headers,
401
+ priority: 'normal',
402
+ };
403
+ }
404
+
405
+ const adapterName = 'universalIdLookupBySourceId';
406
+ const universalIdLookupBySourceId_ConfigPropertyMetadata = [
407
+ generateParamConfigMetadata('dataSourceId', true, 0 /* UrlParameter */, 0 /* String */),
408
+ generateParamConfigMetadata('dataSourceObjectId', true, 0 /* UrlParameter */, 0 /* String */),
409
+ generateParamConfigMetadata('entityName', true, 0 /* UrlParameter */, 0 /* String */),
410
+ generateParamConfigMetadata('sourceRecordId', true, 0 /* UrlParameter */, 0 /* String */),
411
+ generateParamConfigMetadata('dataspace', false, 1 /* QueryParameter */, 0 /* String */),
412
+ ];
413
+ const universalIdLookupBySourceId_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, universalIdLookupBySourceId_ConfigPropertyMetadata);
414
+ const createResourceParams = /*#__PURE__*/ createResourceParams$2(universalIdLookupBySourceId_ConfigPropertyMetadata);
415
+ function keyBuilder(luvio, config) {
416
+ const resourceParams = createResourceParams(config);
417
+ return keyBuilder$1(luvio, resourceParams);
418
+ }
419
+ function typeCheckConfig(untrustedConfig) {
420
+ const config = {};
421
+ typeCheckConfig$2(untrustedConfig, config, universalIdLookupBySourceId_ConfigPropertyMetadata);
422
+ return config;
423
+ }
424
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
425
+ if (!untrustedIsObject(untrustedConfig)) {
426
+ return null;
427
+ }
428
+ if (process.env.NODE_ENV !== 'production') {
429
+ validateConfig(untrustedConfig, configPropertyNames);
430
+ }
431
+ const config = typeCheckConfig(untrustedConfig);
432
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
433
+ return null;
434
+ }
435
+ return config;
436
+ }
437
+ function adapterFragment(luvio, config) {
438
+ createResourceParams(config);
439
+ return select();
440
+ }
441
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
442
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
443
+ config,
444
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
445
+ });
446
+ return luvio.storeBroadcast().then(() => snapshot);
447
+ }
448
+ function onFetchResponseError(luvio, config, resourceParams, response) {
449
+ const snapshot = ingestError(luvio, resourceParams, response, {
450
+ config,
451
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
452
+ });
453
+ return luvio.storeBroadcast().then(() => snapshot);
454
+ }
455
+ function buildNetworkSnapshot(luvio, config, options) {
456
+ const resourceParams = createResourceParams(config);
457
+ const request = createResourceRequest(resourceParams);
458
+ return luvio.dispatchResourceRequest(request, options)
459
+ .then((response) => {
460
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
461
+ const cache = new StoreKeyMap();
462
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
463
+ return cache;
464
+ });
465
+ }, (response) => {
466
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
467
+ });
468
+ }
469
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
470
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, undefined, false);
471
+ }
472
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
473
+ const { luvio, config } = context;
474
+ const selector = {
475
+ recordId: keyBuilder(luvio, config),
476
+ node: adapterFragment(luvio, config),
477
+ variables: {},
478
+ };
479
+ const cacheSnapshot = storeLookup(selector, {
480
+ config,
481
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
482
+ });
483
+ return cacheSnapshot;
484
+ }
485
+ const universalIdLookupBySourceIdAdapterFactory = (luvio) => function cdpQuery__universalIdLookupBySourceId(untrustedConfig, requestContext) {
486
+ const config = validateAdapterConfig(untrustedConfig, universalIdLookupBySourceId_ConfigPropertyNames);
487
+ // Invalid or incomplete config
488
+ if (config === null) {
489
+ return null;
490
+ }
491
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
492
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
493
+ };
494
+
495
+ let cdpQuery;
496
+ let universalIdLookupBySourceId;
497
+ // Imperative GET Adapters
498
+ let universalIdLookupBySourceId_imperative;
499
+ const universalIdLookupBySourceIdMetadata = {
500
+ apiFamily: 'cdpquery',
501
+ name: 'universalIdLookupBySourceId',
502
+ };
503
+ // Notify Update Available
504
+ function bindExportsTo(luvio) {
505
+ // LDS Adapters
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
+ }
511
+ return {
512
+ cdpQuery: unwrapSnapshotData(cdpQueryAdapterFactory),
513
+ universalIdLookupBySourceId: createWireAdapterConstructor(luvio, universalIdLookupBySourceId_ldsAdapter, universalIdLookupBySourceIdMetadata),
514
+ // Imperative GET Adapters
515
+ universalIdLookupBySourceId_imperative: createImperativeAdapter(luvio, universalIdLookupBySourceId_ldsAdapter, universalIdLookupBySourceIdMetadata),
516
+ // Notify Update Availables
517
+ };
518
+ }
519
+ withDefaultLuvio((luvio) => {
520
+ ({ cdpQuery, universalIdLookupBySourceId, universalIdLookupBySourceId_imperative } =
521
+ bindExportsTo(luvio));
522
+ });
523
+
524
+ export { cdpQuery, universalIdLookupBySourceId, universalIdLookupBySourceId_imperative };
525
+ // version: 0.1.0-dev1-c978a7b010
@@ -0,0 +1,133 @@
1
+ #%RAML 1.0
2
+ securedBy:
3
+ - OAuth2
4
+ title: Salesforce Connect API
5
+ version: '62.0'
6
+ mediaType: application/json
7
+ protocols:
8
+ - https
9
+ baseUri: /services/data/v66.0
10
+ securitySchemes:
11
+ OAuth2:
12
+ type: OAuth 2.0
13
+ settings:
14
+ authorizationUri: https://example.com/oauth/authorize
15
+ accessTokenUri: ''
16
+ authorizationGrants:
17
+ - implicit
18
+ annotationTypes:
19
+ oas-readOnly:
20
+ type: boolean
21
+ allowedTargets: TypeDeclaration
22
+ oas-collectionFormat:
23
+ type: string
24
+ oas-body-name:
25
+ type: string
26
+ allowedTargets: TypeDeclaration
27
+ types:
28
+ CdpQueryDataOutputRepresentation:
29
+ description: Represents Cdp Query Data Output
30
+ type: object
31
+ properties:
32
+ data:
33
+ description: Result data set
34
+ type: array
35
+ items:
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
77
+
78
+ /ssot:
79
+ /universalIdLookup/{entityName}/{dataSourceId}/{dataSourceObjectId}/{sourceRecordId}:
80
+ get:
81
+ displayName: getCdpUniversalIdLookup
82
+ description: Queries Universal Id Lookup
83
+ responses:
84
+ '200':
85
+ description: Success
86
+ body:
87
+ application/json:
88
+ type: CdpQueryDataOutputRepresentation
89
+ queryParameters:
90
+ dataspace:
91
+ type: string
92
+ required: false
93
+ uriParameters:
94
+ dataSourceId:
95
+ type: string
96
+ required: true
97
+ dataSourceObjectId:
98
+ type: string
99
+ required: true
100
+ entityName:
101
+ type: string
102
+ required: true
103
+ sourceRecordId:
104
+ type: string
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
@@ -0,0 +1,28 @@
1
+ #%RAML 1.0 Overlay
2
+ extends: ./api.raml
3
+
4
+ uses:
5
+ luvio: luvio://annotations.raml
6
+
7
+ (luvio.keyPrefix): 'cdp-query'
8
+ (luvio.ttl): 360000
9
+
10
+ types:
11
+ CdpQueryDataOutputRepresentation:
12
+ (luvio.opaque): true
13
+
14
+ CdpQueryOutputRepresentation:
15
+ (luvio.opaque): true
16
+ (luvio.key):
17
+ id: queryId
18
+ (luvio.ttl): 100
19
+
20
+ /ssot:
21
+ /universalIdLookup/{entityName}/{dataSourceId}/{dataSourceObjectId}/{sourceRecordId}:
22
+ get:
23
+ (luvio.adapter):
24
+ name: universalIdLookupBySourceId
25
+ /query:
26
+ post:
27
+ (luvio.adapter):
28
+ name: cdpQuery