@salesforce/lds-adapters-platform-data-provider 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/platform-data-provider.js +534 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/adapters/getFieldMetadata.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/adapters/getSchema.d.ts +28 -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 +5 -0
- package/dist/es/es2018/types/src/generated/resources/getConnectDataProvidersFieldMetadataByDataProviderFullyQualifiedNameAndFieldName.d.ts +16 -0
- package/dist/es/es2018/types/src/generated/resources/postConnectDataProvidersSchemaByDataProviderFullyQualifiedName.d.ts +18 -0
- package/dist/es/es2018/types/src/generated/types/DataProviderFieldMetadataRepresentation.d.ts +33 -0
- package/dist/es/es2018/types/src/generated/types/DataProviderSchemaRepresentation.d.ts +33 -0
- package/dist/es/es2018/types/src/generated/types/SchemaInputRepresentation.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
- package/dist/es/es2018/types/src/raml-artifacts/resources/getConnectDataProvidersFieldMetadataByDataProviderFullyQualifiedNameAndFieldName/keyBuilder.d.ts +3 -0
- package/dist/es/es2018/types/src/raml-artifacts/resources/postConnectDataProvidersSchemaByDataProviderFullyQualifiedName/keyBuilder.d.ts +4 -0
- package/package.json +79 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +576 -0
- package/src/raml/api.raml +95 -0
- package/src/raml/luvio.raml +26 -0
package/sfdc/index.js
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
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, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$2, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } 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 = 'DataProviders';
|
|
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$1 = 3600000;
|
|
94
|
+
const VERSION$1 = "8bb941e44209c32ce3ad80bda08962bc";
|
|
95
|
+
function validate$1(obj, path = 'DataProviderFieldMetadataRepresentation') {
|
|
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_metadata = obj.metadata;
|
|
101
|
+
const path_metadata = path + '.metadata';
|
|
102
|
+
if (!ArrayIsArray(obj_metadata)) {
|
|
103
|
+
return new TypeError('Expected "array" but received "' + typeof obj_metadata + '" (at "' + path_metadata + '")');
|
|
104
|
+
}
|
|
105
|
+
for (let i = 0; i < obj_metadata.length; i++) {
|
|
106
|
+
const obj_metadata_item = obj_metadata[i];
|
|
107
|
+
const path_metadata_item = path_metadata + '[' + i + ']';
|
|
108
|
+
if (typeof obj_metadata_item !== 'object' || ArrayIsArray(obj_metadata_item) || obj_metadata_item === null) {
|
|
109
|
+
return new TypeError('Expected "object" but received "' + typeof obj_metadata_item + '" (at "' + path_metadata_item + '")');
|
|
110
|
+
}
|
|
111
|
+
const obj_metadata_item_keys = ObjectKeys(obj_metadata_item);
|
|
112
|
+
for (let i = 0; i < obj_metadata_item_keys.length; i++) {
|
|
113
|
+
const key = obj_metadata_item_keys[i];
|
|
114
|
+
const obj_metadata_item_prop = obj_metadata_item[key];
|
|
115
|
+
const path_metadata_item_prop = path_metadata_item + '["' + key + '"]';
|
|
116
|
+
if (obj_metadata_item_prop === undefined) {
|
|
117
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_metadata_item_prop + '" (at "' + path_metadata_item_prop + '")');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
})();
|
|
122
|
+
return v_error === undefined ? null : v_error;
|
|
123
|
+
}
|
|
124
|
+
const RepresentationType$1 = 'DataProviderFieldMetadataRepresentation';
|
|
125
|
+
function normalize$1(input, existing, path, luvio, store, timestamp) {
|
|
126
|
+
return input;
|
|
127
|
+
}
|
|
128
|
+
const select$3 = function DataProviderFieldMetadataRepresentationSelect() {
|
|
129
|
+
return {
|
|
130
|
+
kind: 'Fragment',
|
|
131
|
+
version: VERSION$1,
|
|
132
|
+
private: [],
|
|
133
|
+
opaque: true
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
function equals$1(existing, incoming) {
|
|
137
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
const ingest$1 = function DataProviderFieldMetadataRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
143
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
144
|
+
const validateError = validate$1(input);
|
|
145
|
+
if (validateError !== null) {
|
|
146
|
+
throw validateError;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const key = path.fullPath;
|
|
150
|
+
const ttlToUse = TTL$1;
|
|
151
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "DataProviders", VERSION$1, RepresentationType$1, equals$1);
|
|
152
|
+
return createLink(key);
|
|
153
|
+
};
|
|
154
|
+
function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
|
|
155
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
156
|
+
const rootKey = fullPathFactory();
|
|
157
|
+
rootKeySet.set(rootKey, {
|
|
158
|
+
namespace: keyPrefix,
|
|
159
|
+
representationName: RepresentationType$1,
|
|
160
|
+
mergeable: false
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function keyBuilder$3(luvio, params) {
|
|
165
|
+
return (keyPrefix +
|
|
166
|
+
'::' +
|
|
167
|
+
'dataProviderFQN:' +
|
|
168
|
+
params.urlParams.dataProviderFullyQualifiedName +
|
|
169
|
+
',' +
|
|
170
|
+
'fieldName:' +
|
|
171
|
+
params.urlParams.fieldName);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function select$2(luvio, params) {
|
|
175
|
+
return select$3();
|
|
176
|
+
}
|
|
177
|
+
function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
|
|
178
|
+
getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$3(luvio, resourceParams));
|
|
179
|
+
}
|
|
180
|
+
function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
|
|
181
|
+
const { body } = response;
|
|
182
|
+
const key = keyBuilder$3(luvio, resourceParams);
|
|
183
|
+
luvio.storeIngest(key, ingest$1, body);
|
|
184
|
+
const snapshot = luvio.storeLookup({
|
|
185
|
+
recordId: key,
|
|
186
|
+
node: select$2(),
|
|
187
|
+
variables: {},
|
|
188
|
+
}, snapshotRefresh);
|
|
189
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
190
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
191
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
deepFreeze(snapshot.data);
|
|
195
|
+
return snapshot;
|
|
196
|
+
}
|
|
197
|
+
function ingestError$1(luvio, params, error, snapshotRefresh) {
|
|
198
|
+
const key = keyBuilder$3(luvio, params);
|
|
199
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
200
|
+
const storeMetadataParams = {
|
|
201
|
+
ttl: TTL$1,
|
|
202
|
+
namespace: keyPrefix,
|
|
203
|
+
version: VERSION$1,
|
|
204
|
+
representationName: RepresentationType$1
|
|
205
|
+
};
|
|
206
|
+
luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
|
|
207
|
+
return errorSnapshot;
|
|
208
|
+
}
|
|
209
|
+
function createResourceRequest$1(config) {
|
|
210
|
+
const headers = {};
|
|
211
|
+
return {
|
|
212
|
+
baseUri: '/services/data/v66.0',
|
|
213
|
+
basePath: '/connect/data-providers/' + config.urlParams.dataProviderFullyQualifiedName + '/fieldMetadata/' + config.urlParams.fieldName + '',
|
|
214
|
+
method: 'get',
|
|
215
|
+
body: null,
|
|
216
|
+
urlParams: config.urlParams,
|
|
217
|
+
queryParams: {},
|
|
218
|
+
headers,
|
|
219
|
+
priority: 'normal',
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const adapterName$1 = 'getFieldMetadata';
|
|
224
|
+
const getFieldMetadata_ConfigPropertyMetadata = [
|
|
225
|
+
generateParamConfigMetadata('dataProviderFullyQualifiedName', true, 0 /* UrlParameter */, 0 /* String */),
|
|
226
|
+
generateParamConfigMetadata('fieldName', true, 0 /* UrlParameter */, 0 /* String */),
|
|
227
|
+
];
|
|
228
|
+
const getFieldMetadata_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getFieldMetadata_ConfigPropertyMetadata);
|
|
229
|
+
const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getFieldMetadata_ConfigPropertyMetadata);
|
|
230
|
+
function keyBuilder$2(luvio, config) {
|
|
231
|
+
const resourceParams = createResourceParams$1(config);
|
|
232
|
+
return keyBuilder$3(luvio, resourceParams);
|
|
233
|
+
}
|
|
234
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
235
|
+
const config = {};
|
|
236
|
+
typeCheckConfig$2(untrustedConfig, config, getFieldMetadata_ConfigPropertyMetadata);
|
|
237
|
+
return config;
|
|
238
|
+
}
|
|
239
|
+
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
240
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
244
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
245
|
+
}
|
|
246
|
+
const config = typeCheckConfig$1(untrustedConfig);
|
|
247
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
return config;
|
|
251
|
+
}
|
|
252
|
+
function adapterFragment$1(luvio, config) {
|
|
253
|
+
createResourceParams$1(config);
|
|
254
|
+
return select$2();
|
|
255
|
+
}
|
|
256
|
+
function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
|
|
257
|
+
const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
|
|
258
|
+
config,
|
|
259
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
260
|
+
});
|
|
261
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
262
|
+
}
|
|
263
|
+
function onFetchResponseError$1(luvio, config, resourceParams, response) {
|
|
264
|
+
const snapshot = ingestError$1(luvio, resourceParams, response, {
|
|
265
|
+
config,
|
|
266
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
267
|
+
});
|
|
268
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
269
|
+
}
|
|
270
|
+
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
271
|
+
const resourceParams = createResourceParams$1(config);
|
|
272
|
+
const request = createResourceRequest$1(resourceParams);
|
|
273
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
274
|
+
.then((response) => {
|
|
275
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => {
|
|
276
|
+
const cache = new StoreKeyMap();
|
|
277
|
+
getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
|
|
278
|
+
return cache;
|
|
279
|
+
});
|
|
280
|
+
}, (response) => {
|
|
281
|
+
return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
|
|
285
|
+
return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
|
|
286
|
+
}
|
|
287
|
+
function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
|
|
288
|
+
const { luvio, config } = context;
|
|
289
|
+
const selector = {
|
|
290
|
+
recordId: keyBuilder$2(luvio, config),
|
|
291
|
+
node: adapterFragment$1(luvio, config),
|
|
292
|
+
variables: {},
|
|
293
|
+
};
|
|
294
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
295
|
+
config,
|
|
296
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
297
|
+
});
|
|
298
|
+
return cacheSnapshot;
|
|
299
|
+
}
|
|
300
|
+
const getFieldMetadataAdapterFactory = (luvio) => function DataProviders__getFieldMetadata(untrustedConfig, requestContext) {
|
|
301
|
+
const config = validateAdapterConfig$1(untrustedConfig, getFieldMetadata_ConfigPropertyNames);
|
|
302
|
+
// Invalid or incomplete config
|
|
303
|
+
if (config === null) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
307
|
+
buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const TTL = 3600000;
|
|
311
|
+
const VERSION = "fa63b622a17d190f6bafa7967153c8be";
|
|
312
|
+
function validate(obj, path = 'DataProviderSchemaRepresentation') {
|
|
313
|
+
const v_error = (() => {
|
|
314
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
315
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
316
|
+
}
|
|
317
|
+
const obj_schema = obj.schema;
|
|
318
|
+
const path_schema = path + '.schema';
|
|
319
|
+
if (typeof obj_schema !== 'object' || ArrayIsArray(obj_schema) || obj_schema === null) {
|
|
320
|
+
return new TypeError('Expected "object" but received "' + typeof obj_schema + '" (at "' + path_schema + '")');
|
|
321
|
+
}
|
|
322
|
+
const obj_schema_keys = ObjectKeys(obj_schema);
|
|
323
|
+
for (let i = 0; i < obj_schema_keys.length; i++) {
|
|
324
|
+
const key = obj_schema_keys[i];
|
|
325
|
+
const obj_schema_prop = obj_schema[key];
|
|
326
|
+
const path_schema_prop = path_schema + '["' + key + '"]';
|
|
327
|
+
if (obj_schema_prop === undefined) {
|
|
328
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_schema_prop + '" (at "' + path_schema_prop + '")');
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
})();
|
|
332
|
+
return v_error === undefined ? null : v_error;
|
|
333
|
+
}
|
|
334
|
+
const RepresentationType = 'DataProviderSchemaRepresentation';
|
|
335
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
336
|
+
return input;
|
|
337
|
+
}
|
|
338
|
+
const select$1 = function DataProviderSchemaRepresentationSelect() {
|
|
339
|
+
return {
|
|
340
|
+
kind: 'Fragment',
|
|
341
|
+
version: VERSION,
|
|
342
|
+
private: [],
|
|
343
|
+
opaque: true
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
function equals(existing, incoming) {
|
|
347
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
const ingest = function DataProviderSchemaRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
353
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
354
|
+
const validateError = validate(input);
|
|
355
|
+
if (validateError !== null) {
|
|
356
|
+
throw validateError;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const key = path.fullPath;
|
|
360
|
+
const ttlToUse = TTL;
|
|
361
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "DataProviders", VERSION, RepresentationType, equals);
|
|
362
|
+
return createLink(key);
|
|
363
|
+
};
|
|
364
|
+
function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
|
|
365
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
366
|
+
const rootKey = fullPathFactory();
|
|
367
|
+
rootKeySet.set(rootKey, {
|
|
368
|
+
namespace: keyPrefix,
|
|
369
|
+
representationName: RepresentationType,
|
|
370
|
+
mergeable: false
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function keyBuilder$1(luvio, params) {
|
|
375
|
+
const schema = params.body.schema;
|
|
376
|
+
if (schema) {
|
|
377
|
+
return (keyPrefix +
|
|
378
|
+
'::' +
|
|
379
|
+
'dataProviderFQN:' +
|
|
380
|
+
params.urlParams.dataProviderFullyQualifiedName +
|
|
381
|
+
',' +
|
|
382
|
+
serializeDataProviderProperties(schema.schema));
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
return (keyPrefix + '::' + 'dataProviderFQN:' + params.urlParams.dataProviderFullyQualifiedName);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function serializeDataProviderProperties(schema) {
|
|
389
|
+
let propertiesKey = '';
|
|
390
|
+
if (!schema) {
|
|
391
|
+
return propertiesKey;
|
|
392
|
+
}
|
|
393
|
+
const properties = schema;
|
|
394
|
+
const sortedKeys = Object.keys(properties).sort();
|
|
395
|
+
for (const key of sortedKeys) {
|
|
396
|
+
if (typeof properties[key] === 'object') {
|
|
397
|
+
propertiesKey += key + ':' + serializeDataProviderProperties(properties[key]) + ',';
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
propertiesKey += key + ':' + properties[key] + ',';
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return 'properties:(' + propertiesKey + ')';
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function select(luvio, params) {
|
|
407
|
+
return select$1();
|
|
408
|
+
}
|
|
409
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
410
|
+
getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
|
|
411
|
+
}
|
|
412
|
+
function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
|
|
413
|
+
const { body } = response;
|
|
414
|
+
const key = keyBuilder$1(luvio, resourceParams);
|
|
415
|
+
luvio.storeIngest(key, ingest, body);
|
|
416
|
+
const snapshot = luvio.storeLookup({
|
|
417
|
+
recordId: key,
|
|
418
|
+
node: select(),
|
|
419
|
+
variables: {},
|
|
420
|
+
}, snapshotRefresh);
|
|
421
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
422
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
423
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
deepFreeze(snapshot.data);
|
|
427
|
+
return snapshot;
|
|
428
|
+
}
|
|
429
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
430
|
+
const key = keyBuilder$1(luvio, params);
|
|
431
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
432
|
+
const storeMetadataParams = {
|
|
433
|
+
ttl: TTL,
|
|
434
|
+
namespace: keyPrefix,
|
|
435
|
+
version: VERSION,
|
|
436
|
+
representationName: RepresentationType
|
|
437
|
+
};
|
|
438
|
+
luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
|
|
439
|
+
return errorSnapshot;
|
|
440
|
+
}
|
|
441
|
+
function createResourceRequest(config) {
|
|
442
|
+
const headers = {};
|
|
443
|
+
return {
|
|
444
|
+
baseUri: '/services/data/v66.0',
|
|
445
|
+
basePath: '/connect/data-providers/' + config.urlParams.dataProviderFullyQualifiedName + '/schema',
|
|
446
|
+
method: 'post',
|
|
447
|
+
body: config.body,
|
|
448
|
+
urlParams: config.urlParams,
|
|
449
|
+
queryParams: {},
|
|
450
|
+
headers,
|
|
451
|
+
priority: 'normal',
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const adapterName = 'getSchema';
|
|
456
|
+
const getSchema_ConfigPropertyMetadata = [
|
|
457
|
+
generateParamConfigMetadata('dataProviderFullyQualifiedName', true, 0 /* UrlParameter */, 0 /* String */),
|
|
458
|
+
generateParamConfigMetadata('schema', true, 2 /* Body */, 4 /* Unsupported */),
|
|
459
|
+
];
|
|
460
|
+
const getSchema_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getSchema_ConfigPropertyMetadata);
|
|
461
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$2(getSchema_ConfigPropertyMetadata);
|
|
462
|
+
function keyBuilder(luvio, config) {
|
|
463
|
+
const resourceParams = createResourceParams(config);
|
|
464
|
+
return keyBuilder$1(luvio, resourceParams);
|
|
465
|
+
}
|
|
466
|
+
function typeCheckConfig(untrustedConfig) {
|
|
467
|
+
const config = {};
|
|
468
|
+
typeCheckConfig$2(untrustedConfig, config, getSchema_ConfigPropertyMetadata);
|
|
469
|
+
const untrustedConfig_schema = untrustedConfig.schema;
|
|
470
|
+
config.schema = untrustedConfig_schema;
|
|
471
|
+
return config;
|
|
472
|
+
}
|
|
473
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
474
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
477
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
478
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
479
|
+
}
|
|
480
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
481
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
return config;
|
|
485
|
+
}
|
|
486
|
+
function adapterFragment(luvio, config) {
|
|
487
|
+
createResourceParams(config);
|
|
488
|
+
return select();
|
|
489
|
+
}
|
|
490
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
491
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response, {
|
|
492
|
+
config,
|
|
493
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
494
|
+
});
|
|
495
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
496
|
+
}
|
|
497
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
498
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
499
|
+
config,
|
|
500
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
501
|
+
});
|
|
502
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
503
|
+
}
|
|
504
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
505
|
+
const resourceParams = createResourceParams(config);
|
|
506
|
+
const request = createResourceRequest(resourceParams);
|
|
507
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
508
|
+
.then((response) => {
|
|
509
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
|
|
510
|
+
const cache = new StoreKeyMap();
|
|
511
|
+
getResponseCacheKeys(cache, luvio, resourceParams, response.body);
|
|
512
|
+
return cache;
|
|
513
|
+
});
|
|
514
|
+
}, (response) => {
|
|
515
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
519
|
+
return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot, 'get', false);
|
|
520
|
+
}
|
|
521
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
522
|
+
const { luvio, config } = context;
|
|
523
|
+
const selector = {
|
|
524
|
+
recordId: keyBuilder(luvio, config),
|
|
525
|
+
node: adapterFragment(luvio, config),
|
|
526
|
+
variables: {},
|
|
527
|
+
};
|
|
528
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
529
|
+
config,
|
|
530
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
531
|
+
});
|
|
532
|
+
return cacheSnapshot;
|
|
533
|
+
}
|
|
534
|
+
const getSchemaAdapterFactory = (luvio) => function DataProviders__getSchema(untrustedConfig, requestContext) {
|
|
535
|
+
const config = validateAdapterConfig(untrustedConfig, getSchema_ConfigPropertyNames);
|
|
536
|
+
// Invalid or incomplete config
|
|
537
|
+
if (config === null) {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
541
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
let getFieldMetadata;
|
|
545
|
+
let getSchema;
|
|
546
|
+
// Imperative GET Adapters
|
|
547
|
+
let getFieldMetadata_imperative;
|
|
548
|
+
let getSchema_imperative;
|
|
549
|
+
// Adapter Metadata
|
|
550
|
+
const getFieldMetadataMetadata = {
|
|
551
|
+
apiFamily: 'DataProviders',
|
|
552
|
+
name: 'getFieldMetadata',
|
|
553
|
+
ttl: 3600000,
|
|
554
|
+
};
|
|
555
|
+
const getSchemaMetadata = { apiFamily: 'DataProviders', name: 'getSchema', ttl: 3600000 };
|
|
556
|
+
// Notify Update Available
|
|
557
|
+
function bindExportsTo(luvio) {
|
|
558
|
+
// LDS Adapters
|
|
559
|
+
const getFieldMetadata_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getFieldMetadata', getFieldMetadataAdapterFactory), getFieldMetadataMetadata);
|
|
560
|
+
const getSchema_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getSchema', getSchemaAdapterFactory), getSchemaMetadata);
|
|
561
|
+
return {
|
|
562
|
+
getFieldMetadata: createWireAdapterConstructor(luvio, getFieldMetadata_ldsAdapter, getFieldMetadataMetadata),
|
|
563
|
+
getSchema: createWireAdapterConstructor(luvio, getSchema_ldsAdapter, getSchemaMetadata),
|
|
564
|
+
// Imperative GET Adapters
|
|
565
|
+
getFieldMetadata_imperative: createImperativeAdapter(luvio, getFieldMetadata_ldsAdapter, getFieldMetadataMetadata),
|
|
566
|
+
getSchema_imperative: createImperativeAdapter(luvio, getSchema_ldsAdapter, getSchemaMetadata),
|
|
567
|
+
// Notify Update Availables
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
withDefaultLuvio((luvio) => {
|
|
571
|
+
({ getFieldMetadata, getSchema, getFieldMetadata_imperative, getSchema_imperative } =
|
|
572
|
+
bindExportsTo(luvio));
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
export { getFieldMetadata, getFieldMetadata_imperative, getSchema, getSchema_imperative };
|
|
576
|
+
// version: 0.1.0-dev1-c978a7b010
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#%RAML 1.0
|
|
2
|
+
securedBy:
|
|
3
|
+
- OAuth2
|
|
4
|
+
title: Salesforce Connect API
|
|
5
|
+
version: '64.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
|
+
DataProviderSchemaRepresentation:
|
|
29
|
+
description: Data Provider Schema
|
|
30
|
+
type: object
|
|
31
|
+
properties:
|
|
32
|
+
schema:
|
|
33
|
+
description: The expanded type of data provider schema.
|
|
34
|
+
type: object
|
|
35
|
+
properties:
|
|
36
|
+
//:
|
|
37
|
+
type: any # TODO W-12579297 Hand Rolled
|
|
38
|
+
SchemaInputRepresentation:
|
|
39
|
+
description: The input representation for a data provider schema
|
|
40
|
+
type: object
|
|
41
|
+
properties:
|
|
42
|
+
schema:
|
|
43
|
+
description: Input schema map used to fetch data provider schema
|
|
44
|
+
type: any # TODO W-12579297 Hand Rolled
|
|
45
|
+
DataProviderFieldMetadataRepresentation:
|
|
46
|
+
description: Data Provider Field Metadata
|
|
47
|
+
type: object
|
|
48
|
+
properties:
|
|
49
|
+
metadata:
|
|
50
|
+
description: The data returned for the provided data provider instance
|
|
51
|
+
type: array
|
|
52
|
+
items:
|
|
53
|
+
type: object
|
|
54
|
+
properties:
|
|
55
|
+
//:
|
|
56
|
+
type: any # TODO W-12579297 Hand Rolled
|
|
57
|
+
/connect/data-providers/{dataProviderFullyQualifiedName}/schema:
|
|
58
|
+
post:
|
|
59
|
+
displayName: postDataProviderSchema
|
|
60
|
+
description: Gets output schema for a data provider FQN
|
|
61
|
+
responses:
|
|
62
|
+
'200':
|
|
63
|
+
description: Success
|
|
64
|
+
body:
|
|
65
|
+
application/json:
|
|
66
|
+
type: DataProviderSchemaRepresentation
|
|
67
|
+
body:
|
|
68
|
+
application/json:
|
|
69
|
+
type: SchemaInputRepresentation
|
|
70
|
+
(oas-body-name): schema
|
|
71
|
+
uriParameters:
|
|
72
|
+
dataProviderFullyQualifiedName:
|
|
73
|
+
description: Data Provider Fully Qualified Name
|
|
74
|
+
type: string
|
|
75
|
+
required: true
|
|
76
|
+
|
|
77
|
+
/connect/data-providers/{dataProviderFullyQualifiedName}/fieldMetadata/{fieldName}:
|
|
78
|
+
get:
|
|
79
|
+
displayName: getDataProviderFieldMetadata
|
|
80
|
+
description: Get the data provider list
|
|
81
|
+
responses:
|
|
82
|
+
'200':
|
|
83
|
+
description: Success
|
|
84
|
+
body:
|
|
85
|
+
application/json:
|
|
86
|
+
type: DataProviderFieldMetadataRepresentation
|
|
87
|
+
uriParameters:
|
|
88
|
+
dataProviderFullyQualifiedName:
|
|
89
|
+
description: Data Provider Fully Qualified Name
|
|
90
|
+
type: string
|
|
91
|
+
required: true
|
|
92
|
+
fieldName:
|
|
93
|
+
description: Field Name
|
|
94
|
+
type: string
|
|
95
|
+
required: true
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#%RAML 1.0 Overlay
|
|
2
|
+
extends: ./api.raml
|
|
3
|
+
|
|
4
|
+
uses:
|
|
5
|
+
luvio: luvio://annotations.raml
|
|
6
|
+
|
|
7
|
+
(luvio.keyPrefix): 'DataProviders'
|
|
8
|
+
|
|
9
|
+
types:
|
|
10
|
+
DataProviderSchemaRepresentation:
|
|
11
|
+
(luvio.ttl): 3600000
|
|
12
|
+
(luvio.opaque): true
|
|
13
|
+
DataProviderFieldMetadataRepresentation:
|
|
14
|
+
(luvio.ttl): 3600000
|
|
15
|
+
(luvio.opaque): true
|
|
16
|
+
|
|
17
|
+
/connect/data-providers/{dataProviderFullyQualifiedName}/schema:
|
|
18
|
+
post:
|
|
19
|
+
(luvio.adapter):
|
|
20
|
+
name: getSchema
|
|
21
|
+
(luvio.method): get
|
|
22
|
+
|
|
23
|
+
/connect/data-providers/{dataProviderFullyQualifiedName}/fieldMetadata/{fieldName}:
|
|
24
|
+
get:
|
|
25
|
+
(luvio.adapter):
|
|
26
|
+
name: getFieldMetadata
|