@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/LICENSE.txt +82 -0
- package/dist/es/es2018/cdp-query.js +485 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/adapters/cdpQuery.d.ts +20 -0
- package/dist/es/es2018/types/src/generated/adapters/universalIdLookupBySourceId.d.ts +31 -0
- package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +2 -0
- package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +4 -0
- package/dist/es/es2018/types/src/generated/resources/getSsotUniversalIdLookupByDataSourceIdAndDataSourceObjectIdAndEntityNameAndSourceRecordId.d.ts +21 -0
- package/dist/es/es2018/types/src/generated/resources/postSsotQuery.d.ts +19 -0
- package/dist/es/es2018/types/src/generated/types/CdpQueryDataOutputRepresentation.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/types/CdpQueryInputRepresentation.d.ts +31 -0
- package/dist/es/es2018/types/src/generated/types/CdpQueryOutputRepresentation.d.ts +60 -0
- package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
- package/package.json +66 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +525 -0
- package/src/raml/api.raml +133 -0
- package/src/raml/luvio.raml +28 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2022, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from '@luvio/engine';
|
|
8
|
+
|
|
9
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
+
const { keys: ObjectKeys$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
|
+
function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
|
|
52
|
+
return {
|
|
53
|
+
name,
|
|
54
|
+
required,
|
|
55
|
+
resourceType,
|
|
56
|
+
typeCheckShape,
|
|
57
|
+
isArrayShape,
|
|
58
|
+
coerceFn,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function buildAdapterValidationConfig(displayName, paramsMeta) {
|
|
62
|
+
const required = paramsMeta.filter(p => p.required).map(p => p.name);
|
|
63
|
+
const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
|
|
64
|
+
return {
|
|
65
|
+
displayName,
|
|
66
|
+
parameters: {
|
|
67
|
+
required,
|
|
68
|
+
optional,
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const keyPrefix = 'cdp-query';
|
|
73
|
+
|
|
74
|
+
const { keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
75
|
+
const { isArray: ArrayIsArray } = Array;
|
|
76
|
+
const { stringify: JSONStringify } = JSON;
|
|
77
|
+
function createLink(ref) {
|
|
78
|
+
return {
|
|
79
|
+
__ref: serializeStructuredKey(ref),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const VERSION$1 = "7df04f81d9b64d7cdebf01b86018ba25";
|
|
84
|
+
function validate$1(obj, path = 'CdpQueryDataOutputRepresentation') {
|
|
85
|
+
const v_error = (() => {
|
|
86
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
87
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
88
|
+
}
|
|
89
|
+
const obj_data = obj.data;
|
|
90
|
+
const path_data = path + '.data';
|
|
91
|
+
if (!ArrayIsArray(obj_data)) {
|
|
92
|
+
return new TypeError('Expected "array" but received "' + typeof obj_data + '" (at "' + path_data + '")');
|
|
93
|
+
}
|
|
94
|
+
for (let i = 0; i < obj_data.length; i++) {
|
|
95
|
+
const obj_data_item = obj_data[i];
|
|
96
|
+
const path_data_item = path_data + '[' + i + ']';
|
|
97
|
+
if (obj_data_item === undefined) {
|
|
98
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_data_item + '" (at "' + path_data_item + '")');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
})();
|
|
102
|
+
return v_error === undefined ? null : v_error;
|
|
103
|
+
}
|
|
104
|
+
const RepresentationType$1 = 'CdpQueryDataOutputRepresentation';
|
|
105
|
+
function normalize$1(input, existing, path, luvio, store, timestamp) {
|
|
106
|
+
return input;
|
|
107
|
+
}
|
|
108
|
+
const select$3 = function CdpQueryDataOutputRepresentationSelect() {
|
|
109
|
+
return {
|
|
110
|
+
kind: 'Fragment',
|
|
111
|
+
version: VERSION$1,
|
|
112
|
+
private: [],
|
|
113
|
+
opaque: true
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
function equals$1(existing, incoming) {
|
|
117
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
const ingest$1 = function CdpQueryDataOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
123
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
124
|
+
const validateError = validate$1(input);
|
|
125
|
+
if (validateError !== null) {
|
|
126
|
+
throw validateError;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const key = path.fullPath;
|
|
130
|
+
const ttlToUse = path.ttl !== undefined ? path.ttl : 360000;
|
|
131
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "cdp-query", VERSION$1, RepresentationType$1, equals$1);
|
|
132
|
+
return createLink(key);
|
|
133
|
+
};
|
|
134
|
+
function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
|
|
135
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
136
|
+
const rootKey = fullPathFactory();
|
|
137
|
+
rootKeySet.set(rootKey, {
|
|
138
|
+
namespace: keyPrefix,
|
|
139
|
+
representationName: RepresentationType$1,
|
|
140
|
+
mergeable: false
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function select$2(luvio, params) {
|
|
145
|
+
return select$3();
|
|
146
|
+
}
|
|
147
|
+
function keyBuilder$2(luvio, params) {
|
|
148
|
+
return keyPrefix + '::CdpQueryDataOutputRepresentation:(' + 'dataspace:' + params.queryParams.dataspace + ',' + 'dataSourceId:' + params.urlParams.dataSourceId + ',' + 'dataSourceObjectId:' + params.urlParams.dataSourceObjectId + ',' + 'entityName:' + params.urlParams.entityName + ',' + 'sourceRecordId:' + params.urlParams.sourceRecordId + ')';
|
|
149
|
+
}
|
|
150
|
+
function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
|
|
151
|
+
getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
|
|
152
|
+
}
|
|
153
|
+
function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
|
|
154
|
+
const { body } = response;
|
|
155
|
+
const key = keyBuilder$2(luvio, resourceParams);
|
|
156
|
+
luvio.storeIngest(key, ingest$1, body);
|
|
157
|
+
const snapshot = luvio.storeLookup({
|
|
158
|
+
recordId: key,
|
|
159
|
+
node: select$2(),
|
|
160
|
+
variables: {},
|
|
161
|
+
}, snapshotRefresh);
|
|
162
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
163
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
164
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
deepFreeze(snapshot.data);
|
|
168
|
+
return snapshot;
|
|
169
|
+
}
|
|
170
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
171
|
+
const key = keyBuilder$2(luvio, params);
|
|
172
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
173
|
+
luvio.storeIngestError(key, errorSnapshot);
|
|
174
|
+
return errorSnapshot;
|
|
175
|
+
}
|
|
176
|
+
function createResourceRequest$1(config) {
|
|
177
|
+
const headers = {};
|
|
178
|
+
return {
|
|
179
|
+
baseUri: '/services/data/v66.0',
|
|
180
|
+
basePath: '/ssot/universalIdLookup/' + config.urlParams.entityName + '/' + config.urlParams.dataSourceId + '/' + config.urlParams.dataSourceObjectId + '/' + config.urlParams.sourceRecordId + '',
|
|
181
|
+
method: 'get',
|
|
182
|
+
body: null,
|
|
183
|
+
urlParams: config.urlParams,
|
|
184
|
+
queryParams: config.queryParams,
|
|
185
|
+
headers,
|
|
186
|
+
priority: 'normal',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const adapterName$1 = 'universalIdLookupBySourceId';
|
|
191
|
+
const universalIdLookupBySourceId_ConfigPropertyMetadata = [
|
|
192
|
+
generateParamConfigMetadata('dataSourceId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
193
|
+
generateParamConfigMetadata('dataSourceObjectId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
194
|
+
generateParamConfigMetadata('entityName', true, 0 /* UrlParameter */, 0 /* String */),
|
|
195
|
+
generateParamConfigMetadata('sourceRecordId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
196
|
+
generateParamConfigMetadata('dataspace', false, 1 /* QueryParameter */, 0 /* String */),
|
|
197
|
+
];
|
|
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);
|
|
203
|
+
}
|
|
204
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
205
|
+
const config = {};
|
|
206
|
+
typeCheckConfig$2(untrustedConfig, config, universalIdLookupBySourceId_ConfigPropertyMetadata);
|
|
207
|
+
return config;
|
|
208
|
+
}
|
|
209
|
+
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
210
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
214
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
215
|
+
}
|
|
216
|
+
const config = typeCheckConfig$1(untrustedConfig);
|
|
217
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
return config;
|
|
221
|
+
}
|
|
222
|
+
function adapterFragment(luvio, config) {
|
|
223
|
+
createResourceParams$1(config);
|
|
224
|
+
return select$2();
|
|
225
|
+
}
|
|
226
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
227
|
+
const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
|
|
228
|
+
config,
|
|
229
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
230
|
+
});
|
|
231
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
232
|
+
}
|
|
233
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
234
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
235
|
+
config,
|
|
236
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
237
|
+
});
|
|
238
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
239
|
+
}
|
|
240
|
+
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
241
|
+
const resourceParams = createResourceParams$1(config);
|
|
242
|
+
const request = createResourceRequest$1(resourceParams);
|
|
243
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
244
|
+
.then((response) => {
|
|
245
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
|
|
246
|
+
const cache = new StoreKeyMap();
|
|
247
|
+
getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
|
|
248
|
+
return cache;
|
|
249
|
+
});
|
|
250
|
+
}, (response) => {
|
|
251
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
255
|
+
return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
|
|
256
|
+
}
|
|
257
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
258
|
+
const { luvio, config } = context;
|
|
259
|
+
const selector = {
|
|
260
|
+
recordId: keyBuilder$1(luvio, config),
|
|
261
|
+
node: adapterFragment(luvio, config),
|
|
262
|
+
variables: {},
|
|
263
|
+
};
|
|
264
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
265
|
+
config,
|
|
266
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
267
|
+
});
|
|
268
|
+
return cacheSnapshot;
|
|
269
|
+
}
|
|
270
|
+
const universalIdLookupBySourceIdAdapterFactory = (luvio) => function cdpQuery__universalIdLookupBySourceId(untrustedConfig, requestContext) {
|
|
271
|
+
const config = validateAdapterConfig$1(untrustedConfig, universalIdLookupBySourceId_ConfigPropertyNames);
|
|
272
|
+
// Invalid or incomplete config
|
|
273
|
+
if (config === null) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
277
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
278
|
+
};
|
|
279
|
+
|
|
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/v66.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,62 @@
|
|
|
1
|
+
import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot, AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata } from '@luvio/engine';
|
|
2
|
+
export declare const ObjectPrototypeHasOwnProperty: (v: PropertyKey) => boolean;
|
|
3
|
+
declare const ObjectKeys: {
|
|
4
|
+
(o: object): string[];
|
|
5
|
+
(o: {}): string[];
|
|
6
|
+
}, ObjectCreate: {
|
|
7
|
+
(o: object | null): any;
|
|
8
|
+
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
9
|
+
};
|
|
10
|
+
export { ObjectCreate, ObjectKeys };
|
|
11
|
+
export declare const ArrayIsArray: (arg: any) => arg is any[];
|
|
12
|
+
export declare const ArrayPrototypePush: (...items: any[]) => number;
|
|
13
|
+
export interface AdapterValidationConfig {
|
|
14
|
+
displayName: string;
|
|
15
|
+
parameters: {
|
|
16
|
+
required: string[];
|
|
17
|
+
optional: string[];
|
|
18
|
+
unsupported?: string[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Validates an adapter config is well-formed.
|
|
23
|
+
* @param config The config to validate.
|
|
24
|
+
* @param adapter The adapter validation configuration.
|
|
25
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
26
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateConfig<T>(config: Untrusted<T>, adapter: AdapterValidationConfig, oneOf?: string[]): void;
|
|
29
|
+
export declare function untrustedIsObject<Base>(untrusted: unknown): untrusted is Untrusted<Base>;
|
|
30
|
+
export type UncoercedConfiguration<Base, Options extends {
|
|
31
|
+
[key in keyof Base]?: any;
|
|
32
|
+
}> = {
|
|
33
|
+
[Key in keyof Base]?: Base[Key] | Options[Key];
|
|
34
|
+
};
|
|
35
|
+
export type Untrusted<Base> = Partial<Base>;
|
|
36
|
+
export declare function areRequiredParametersPresent<T>(config: any, configPropertyNames: AdapterValidationConfig): config is T;
|
|
37
|
+
export declare function refreshable<C, D, R>(adapter: $64$luvio_engine_Adapter<C, D>, resolve: (config: unknown) => Promise<$64$luvio_engine_Snapshot<R>>): $64$luvio_engine_Adapter<C, D>;
|
|
38
|
+
export declare const SNAPSHOT_STATE_FULFILLED = "Fulfilled";
|
|
39
|
+
export declare const SNAPSHOT_STATE_UNFULFILLED = "Unfulfilled";
|
|
40
|
+
export declare const snapshotRefreshOptions: {
|
|
41
|
+
overrides: {
|
|
42
|
+
headers: {
|
|
43
|
+
'Cache-Control': string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
|
|
49
|
+
* This is needed because insertion order for JSON.stringify(object) affects output:
|
|
50
|
+
* JSON.stringify({a: 1, b: 2})
|
|
51
|
+
* "{"a":1,"b":2}"
|
|
52
|
+
* JSON.stringify({b: 2, a: 1})
|
|
53
|
+
* "{"b":2,"a":1}"
|
|
54
|
+
* @param data Data to be JSON-stringified.
|
|
55
|
+
* @returns JSON.stringified value with consistent ordering of keys.
|
|
56
|
+
*/
|
|
57
|
+
export declare function stableJSONStringify(node: any): string | undefined;
|
|
58
|
+
export declare function getFetchResponseStatusText(status: number): string;
|
|
59
|
+
export declare function isUnfulfilledSnapshot<T, U>(snapshot: $64$luvio_engine_Snapshot<T, U>): snapshot is $64$luvio_engine_UnfulfilledSnapshot<T, U>;
|
|
60
|
+
export declare function generateParamConfigMetadata(name: string, required: boolean, resourceType: $64$luvio_engine_AdapterConfigMetadata['resourceType'], typeCheckShape: $64$luvio_engine_AdapterConfigMetadata['typeCheckShape'], isArrayShape?: boolean, coerceFn?: (v: unknown) => unknown): $64$luvio_engine_AdapterConfigMetadata;
|
|
61
|
+
export declare function buildAdapterValidationConfig(displayName: string, paramsMeta: $64$luvio_engine_AdapterConfigMetadata[]): AdapterValidationConfig;
|
|
62
|
+
export declare const keyPrefix = "cdp-query";
|
|
@@ -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>;
|