@salesforce/lds-adapters-analytics-wave-private 1.100.1

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,393 @@
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, StoreKeyMap } from 'force/luvioEngine';
18
+
19
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
+ const { keys: ObjectKeys$1, freeze: ObjectFreeze$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
+ const keyPrefix = 'WAVE';
62
+
63
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
64
+ const { isArray: ArrayIsArray } = Array;
65
+ const { stringify: JSONStringify } = JSON;
66
+ function deepFreeze$1(value) {
67
+ // No need to freeze primitives
68
+ if (typeof value !== 'object' || value === null) {
69
+ return;
70
+ }
71
+ if (ArrayIsArray(value)) {
72
+ for (let i = 0, len = value.length; i < len; i += 1) {
73
+ deepFreeze$1(value[i]);
74
+ }
75
+ }
76
+ else {
77
+ const keys = ObjectKeys(value);
78
+ for (let i = 0, len = keys.length; i < len; i += 1) {
79
+ deepFreeze$1(value[keys[i]]);
80
+ }
81
+ }
82
+ ObjectFreeze(value);
83
+ }
84
+ function createLink(ref) {
85
+ return {
86
+ __ref: serializeStructuredKey(ref),
87
+ };
88
+ }
89
+
90
+ const TTL = 5000;
91
+ const VERSION = "f4d046d44230e53375ee20bbd2483a1f";
92
+ function validate(obj, path = 'SoqlQueryResultRepresentation') {
93
+ const v_error = (() => {
94
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
95
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
96
+ }
97
+ const obj_keys = ObjectKeys(obj);
98
+ for (let i = 0; i < obj_keys.length; i++) {
99
+ const key = obj_keys[i];
100
+ const obj_prop = obj[key];
101
+ const path_prop = path + '["' + key + '"]';
102
+ if (obj_prop === undefined) {
103
+ return new TypeError('Expected "defined" but received "' + typeof obj_prop + '" (at "' + path_prop + '")');
104
+ }
105
+ }
106
+ if (obj.done !== undefined) {
107
+ const obj_done = obj.done;
108
+ const path_done = path + '.done';
109
+ if (typeof obj_done !== 'boolean') {
110
+ return new TypeError('Expected "boolean" but received "' + typeof obj_done + '" (at "' + path_done + '")');
111
+ }
112
+ }
113
+ const obj_records = obj.records;
114
+ const path_records = path + '.records';
115
+ if (!ArrayIsArray(obj_records)) {
116
+ return new TypeError('Expected "array" but received "' + typeof obj_records + '" (at "' + path_records + '")');
117
+ }
118
+ for (let i = 0; i < obj_records.length; i++) {
119
+ const obj_records_item = obj_records[i];
120
+ const path_records_item = path_records + '[' + i + ']';
121
+ if (obj_records_item === undefined) {
122
+ return new TypeError('Expected "defined" but received "' + typeof obj_records_item + '" (at "' + path_records_item + '")');
123
+ }
124
+ }
125
+ if (obj.totalSize !== undefined) {
126
+ const obj_totalSize = obj.totalSize;
127
+ const path_totalSize = path + '.totalSize';
128
+ if (typeof obj_totalSize !== 'number') {
129
+ return new TypeError('Expected "number" but received "' + typeof obj_totalSize + '" (at "' + path_totalSize + '")');
130
+ }
131
+ }
132
+ })();
133
+ return v_error === undefined ? null : v_error;
134
+ }
135
+ const RepresentationType = 'SoqlQueryResultRepresentation';
136
+ function normalize(input, existing, path, luvio, store, timestamp) {
137
+ return input;
138
+ }
139
+ const select$1 = function SoqlQueryResultRepresentationSelect() {
140
+ return {
141
+ kind: 'Fragment',
142
+ version: VERSION,
143
+ private: [],
144
+ opaque: true
145
+ };
146
+ };
147
+ function equals(existing, incoming) {
148
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
149
+ return false;
150
+ }
151
+ return true;
152
+ }
153
+ function deepFreeze(input) {
154
+ const input_keys = Object.keys(input);
155
+ const input_length = input_keys.length;
156
+ for (let i = 0; i < input_length; i++) {
157
+ const key = input_keys[i];
158
+ const input_prop = input[key];
159
+ deepFreeze$1(input_prop);
160
+ }
161
+ const input_records = input.records;
162
+ for (let i = 0; i < input_records.length; i++) {
163
+ const input_records_item = input_records[i];
164
+ deepFreeze$1(input_records_item);
165
+ }
166
+ ObjectFreeze(input_records);
167
+ ObjectFreeze(input);
168
+ }
169
+ const ingest = function SoqlQueryResultRepresentationIngest(input, path, luvio, store, timestamp) {
170
+ if (process.env.NODE_ENV !== 'production') {
171
+ const validateError = validate(input);
172
+ if (validateError !== null) {
173
+ throw validateError;
174
+ }
175
+ }
176
+ const key = path.fullPath;
177
+ const existingRecord = store.readEntry(key);
178
+ const ttlToUse = TTL;
179
+ let incomingRecord = normalize(input, store.readEntry(key), {
180
+ fullPath: key,
181
+ parent: path.parent,
182
+ propertyName: path.propertyName,
183
+ ttl: ttlToUse
184
+ });
185
+ deepFreeze(input);
186
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
187
+ luvio.storePublish(key, incomingRecord);
188
+ }
189
+ {
190
+ const storeMetadataParams = {
191
+ ttl: ttlToUse,
192
+ namespace: "WAVE",
193
+ version: VERSION,
194
+ representationName: RepresentationType,
195
+ };
196
+ luvio.publishStoreMetadata(key, storeMetadataParams);
197
+ }
198
+ return createLink(key);
199
+ };
200
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
201
+ const rootKeySet = new StoreKeyMap();
202
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
203
+ const rootKey = fullPathFactory();
204
+ rootKeySet.set(rootKey, {
205
+ namespace: keyPrefix,
206
+ representationName: RepresentationType,
207
+ mergeable: false
208
+ });
209
+ return rootKeySet;
210
+ }
211
+
212
+ function select(luvio, params) {
213
+ return select$1();
214
+ }
215
+ function keyBuilder$1(luvio, params) {
216
+ return keyPrefix + '::SoqlQueryResultRepresentation:(' + 'query:' + params.body.query + ')';
217
+ }
218
+ function getResponseCacheKeys(luvio, resourceParams, response) {
219
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
220
+ }
221
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
222
+ const { body } = response;
223
+ const key = keyBuilder$1(luvio, resourceParams);
224
+ luvio.storeIngest(key, ingest, body);
225
+ const snapshot = luvio.storeLookup({
226
+ recordId: key,
227
+ node: select(),
228
+ variables: {},
229
+ }, snapshotRefresh);
230
+ if (process.env.NODE_ENV !== 'production') {
231
+ if (snapshot.state !== 'Fulfilled') {
232
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
233
+ }
234
+ }
235
+ return snapshot;
236
+ }
237
+ function ingestError(luvio, params, error, snapshotRefresh) {
238
+ const key = keyBuilder$1(luvio, params);
239
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
240
+ const storeMetadataParams = {
241
+ ttl: TTL,
242
+ namespace: keyPrefix,
243
+ version: VERSION,
244
+ representationName: RepresentationType
245
+ };
246
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
247
+ return errorSnapshot;
248
+ }
249
+ function createResourceRequest(config) {
250
+ const headers = {};
251
+ return {
252
+ baseUri: '/services/data/v58.0',
253
+ basePath: '/wave/soql',
254
+ method: 'post',
255
+ body: config.body,
256
+ urlParams: {},
257
+ queryParams: {},
258
+ headers,
259
+ priority: 'normal',
260
+ };
261
+ }
262
+
263
+ const executeSoqlQueryPost_ConfigPropertyNames = {
264
+ displayName: 'executeSoqlQueryPost',
265
+ parameters: {
266
+ required: ['query'],
267
+ optional: []
268
+ }
269
+ };
270
+ function createResourceParams(config) {
271
+ const resourceParams = {
272
+ body: {
273
+ query: config.query
274
+ }
275
+ };
276
+ return resourceParams;
277
+ }
278
+ function keyBuilder(luvio, config) {
279
+ const resourceParams = createResourceParams(config);
280
+ return keyBuilder$1(luvio, resourceParams);
281
+ }
282
+ function typeCheckConfig(untrustedConfig) {
283
+ const config = {};
284
+ const untrustedConfig_query = untrustedConfig.query;
285
+ if (typeof untrustedConfig_query === 'string') {
286
+ config.query = untrustedConfig_query;
287
+ }
288
+ return config;
289
+ }
290
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
291
+ if (!untrustedIsObject(untrustedConfig)) {
292
+ return null;
293
+ }
294
+ if (process.env.NODE_ENV !== 'production') {
295
+ validateConfig(untrustedConfig, configPropertyNames);
296
+ }
297
+ const config = typeCheckConfig(untrustedConfig);
298
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
299
+ return null;
300
+ }
301
+ return config;
302
+ }
303
+ function adapterFragment(luvio, config) {
304
+ createResourceParams(config);
305
+ return select();
306
+ }
307
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
308
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
309
+ config,
310
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
311
+ });
312
+ return luvio.storeBroadcast().then(() => snapshot);
313
+ }
314
+ function onFetchResponseError(luvio, config, resourceParams, response) {
315
+ const snapshot = ingestError(luvio, resourceParams, response, {
316
+ config,
317
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
318
+ });
319
+ return luvio.storeBroadcast().then(() => snapshot);
320
+ }
321
+ function buildNetworkSnapshot(luvio, config, options) {
322
+ const resourceParams = createResourceParams(config);
323
+ const request = createResourceRequest(resourceParams);
324
+ return luvio.dispatchResourceRequest(request, options)
325
+ .then((response) => {
326
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
327
+ }, (response) => {
328
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
329
+ });
330
+ }
331
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
332
+ const { luvio, config } = context;
333
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
334
+ const dispatchOptions = {
335
+ resourceRequestContext: {
336
+ requestCorrelator,
337
+ luvioRequestMethod: 'get',
338
+ },
339
+ eventObservers
340
+ };
341
+ if (networkPriority !== 'normal') {
342
+ dispatchOptions.overrides = {
343
+ priority: networkPriority
344
+ };
345
+ }
346
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
347
+ }
348
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
349
+ const { luvio, config } = context;
350
+ const selector = {
351
+ recordId: keyBuilder(luvio, config),
352
+ node: adapterFragment(luvio, config),
353
+ variables: {},
354
+ };
355
+ const cacheSnapshot = storeLookup(selector, {
356
+ config,
357
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
358
+ });
359
+ return cacheSnapshot;
360
+ }
361
+ const executeSoqlQueryPostAdapterFactory = (luvio) => function WAVE__executeSoqlQueryPost(untrustedConfig, requestContext) {
362
+ const config = validateAdapterConfig(untrustedConfig, executeSoqlQueryPost_ConfigPropertyNames);
363
+ // Invalid or incomplete config
364
+ if (config === null) {
365
+ return null;
366
+ }
367
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
368
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
369
+ };
370
+
371
+ let executeSoqlQueryPost;
372
+ // Imperative GET Adapters
373
+ let executeSoqlQueryPost_imperative;
374
+ // Adapter Metadata
375
+ const executeSoqlQueryPostMetadata = { apiFamily: 'WAVE', name: 'executeSoqlQueryPost', ttl: 5000 };
376
+ function bindExportsTo(luvio) {
377
+ // LDS Adapters
378
+ const executeSoqlQueryPost_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'executeSoqlQueryPost', executeSoqlQueryPostAdapterFactory), executeSoqlQueryPostMetadata);
379
+ return {
380
+ executeSoqlQueryPost: createWireAdapterConstructor(luvio, executeSoqlQueryPost_ldsAdapter, executeSoqlQueryPostMetadata),
381
+ // Imperative GET Adapters
382
+ executeSoqlQueryPost_imperative: createImperativeAdapter(luvio, executeSoqlQueryPost_ldsAdapter, executeSoqlQueryPostMetadata)
383
+ };
384
+ }
385
+ withDefaultLuvio((luvio) => {
386
+ ({
387
+ executeSoqlQueryPost,
388
+ executeSoqlQueryPost_imperative
389
+ } = bindExportsTo(luvio));
390
+ });
391
+
392
+ export { executeSoqlQueryPost, executeSoqlQueryPost_imperative };
393
+ // version: 1.100.1-5f548b01c
@@ -0,0 +1,73 @@
1
+ #%RAML 1.0
2
+ # This RAML has been modified and "ELT Foundation - Analytics" is responsible for maintaining it
3
+ securedBy:
4
+ - OAuth2
5
+ title: Salesforce Connect API
6
+ version: '52.0'
7
+ mediaType: application/json
8
+ protocols:
9
+ - https
10
+ baseUri: /services/data/v58.0
11
+ securitySchemes:
12
+ OAuth2:
13
+ type: OAuth 2.0
14
+ settings:
15
+ authorizationUri: https://example.com/oauth/authorize
16
+ accessTokenUri: ''
17
+ authorizationGrants:
18
+ - implicit
19
+ annotationTypes:
20
+ oas-readOnly:
21
+ type: boolean
22
+ allowedTargets: TypeDeclaration
23
+ oas-collectionFormat:
24
+ type: string
25
+ oas-body-name:
26
+ type: string
27
+ allowedTargets: TypeDeclaration
28
+
29
+ types:
30
+ # TODO: Intentionally hand-rolled
31
+ # The java source has a single 'json' string field, but uses a custom serializer which outputs that as
32
+ # the actual json. The json output is not defined in the connect annotations.
33
+ # Similar to SaqlQueryResultsRepresentation in lds-adapters-analytics-wave
34
+ SoqlQueryResultRepresentation:
35
+ description: Represents a string of JSON content that will be serialized as-is.
36
+ type: object
37
+ properties:
38
+ totalSize:
39
+ type: number
40
+ required: false
41
+ done:
42
+ type: boolean
43
+ required: false
44
+ records:
45
+ description: The result records
46
+ type: array
47
+ items:
48
+ type: any
49
+ # depending on the type of query and the underlying data, there might be other properties
50
+ //:
51
+ type: any
52
+ SoqlQueryInputRepresentation:
53
+ description: A query input representation SOQL
54
+ type: object
55
+ properties:
56
+ query:
57
+ description: The query
58
+ type: string
59
+
60
+ /wave:
61
+ /soql:
62
+ post:
63
+ description: Execute a query.
64
+ responses:
65
+ '200':
66
+ description: Success
67
+ body:
68
+ application/json:
69
+ type: SoqlQueryResultRepresentation
70
+ body:
71
+ application/json:
72
+ type: SoqlQueryInputRepresentation
73
+ (oas-body-name): query
@@ -0,0 +1,20 @@
1
+ #%RAML 1.0 Overlay
2
+ extends: ./api.raml
3
+
4
+ uses:
5
+ luvio: luvio://annotations.raml
6
+
7
+ (luvio.keyPrefix): 'WAVE'
8
+ (luvio.ttl): 2592000000
9
+
10
+ types:
11
+ SoqlQueryResultRepresentation:
12
+ (luvio.opaque): true
13
+ (luvio.ttl): 5000
14
+
15
+ /wave:
16
+ /soql:
17
+ post:
18
+ (luvio.adapter):
19
+ name: executeSoqlQueryPost
20
+ (luvio.method): get