@salesforce/lds-adapters-platform-formula 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.
Files changed (23) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/es/es2018/platform-formula.js +642 -0
  3. package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
  4. package/dist/es/es2018/types/src/generated/adapters/fixFormula.d.ts +19 -0
  5. package/dist/es/es2018/types/src/generated/adapters/getExplanation.d.ts +18 -0
  6. package/dist/es/es2018/types/src/generated/adapters/validateFormula.d.ts +19 -0
  7. package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +3 -0
  8. package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +4 -0
  9. package/dist/es/es2018/types/src/generated/resources/postConnectFormulaEinsteinExplain.d.ts +15 -0
  10. package/dist/es/es2018/types/src/generated/resources/postConnectFormulaEinsteinFix.d.ts +16 -0
  11. package/dist/es/es2018/types/src/generated/resources/postConnectFormulaValidate.d.ts +16 -0
  12. package/dist/es/es2018/types/src/generated/types/ExplainPromptInputRepresentation.d.ts +37 -0
  13. package/dist/es/es2018/types/src/generated/types/FixFormulaInputRepresentation.d.ts +40 -0
  14. package/dist/es/es2018/types/src/generated/types/FixFormulaRepresentation.d.ts +41 -0
  15. package/dist/es/es2018/types/src/generated/types/FormulaExplanationRepresentation.d.ts +41 -0
  16. package/dist/es/es2018/types/src/generated/types/FormulaValidationInputRepresentation.d.ts +40 -0
  17. package/dist/es/es2018/types/src/generated/types/FormulaValidationRepresentation.d.ts +41 -0
  18. package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
  19. package/package.json +67 -0
  20. package/sfdc/index.d.ts +1 -0
  21. package/sfdc/index.js +674 -0
  22. package/src/raml/api.raml +199 -0
  23. package/src/raml/luvio.raml +37 -0
package/sfdc/index.js ADDED
@@ -0,0 +1,674 @@
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 { withDefaultLuvio } from 'force/ldsEngine';
16
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$3, typeCheckConfig as typeCheckConfig$3 } from 'force/luvioEngine';
17
+
18
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
19
+ const { keys: ObjectKeys, create: ObjectCreate } = Object;
20
+ const { isArray: ArrayIsArray$1 } = Array;
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
+ function validateConfig(config, adapter, oneOf) {
29
+ const { displayName } = adapter;
30
+ const { required, optional, unsupported } = adapter.parameters;
31
+ if (config === undefined ||
32
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
33
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
34
+ }
35
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
36
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
37
+ }
38
+ if (unsupported !== undefined &&
39
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
40
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
41
+ }
42
+ const supported = required.concat(optional);
43
+ if (ObjectKeys(config).some(key => !supported.includes(key))) {
44
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
45
+ }
46
+ }
47
+ function untrustedIsObject(untrusted) {
48
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
49
+ }
50
+ function areRequiredParametersPresent(config, configPropertyNames) {
51
+ return configPropertyNames.parameters.required.every(req => req in config);
52
+ }
53
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
54
+ return {
55
+ name,
56
+ required,
57
+ resourceType,
58
+ typeCheckShape,
59
+ isArrayShape,
60
+ coerceFn,
61
+ };
62
+ }
63
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
64
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
65
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
66
+ return {
67
+ displayName,
68
+ parameters: {
69
+ required,
70
+ optional,
71
+ }
72
+ };
73
+ }
74
+ const keyPrefix = 'Formula';
75
+
76
+ const { isArray: ArrayIsArray } = Array;
77
+ function createLink(ref) {
78
+ return {
79
+ __ref: serializeStructuredKey(ref),
80
+ };
81
+ }
82
+
83
+ const TTL$2 = 100;
84
+ const VERSION$2 = "fb4a459f302e4d90aa792f35b0525f8f";
85
+ function validate$2(obj, path = 'FixFormulaRepresentation') {
86
+ const v_error = (() => {
87
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
88
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
89
+ }
90
+ const obj_generationId = obj.generationId;
91
+ const path_generationId = path + '.generationId';
92
+ if (typeof obj_generationId !== 'string') {
93
+ return new TypeError('Expected "string" but received "' + typeof obj_generationId + '" (at "' + path_generationId + '")');
94
+ }
95
+ const obj_response = obj.response;
96
+ const path_response = path + '.response';
97
+ if (typeof obj_response !== 'string') {
98
+ return new TypeError('Expected "string" but received "' + typeof obj_response + '" (at "' + path_response + '")');
99
+ }
100
+ })();
101
+ return v_error === undefined ? null : v_error;
102
+ }
103
+ const RepresentationType$2 = 'FixFormulaRepresentation';
104
+ function keyBuilder$2(luvio, config) {
105
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.generationId;
106
+ }
107
+ function keyBuilderFromType$2(luvio, object) {
108
+ const keyParams = {
109
+ generationId: object.generationId
110
+ };
111
+ return keyBuilder$2(luvio, keyParams);
112
+ }
113
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
114
+ return input;
115
+ }
116
+ const select$5 = function FixFormulaRepresentationSelect() {
117
+ return {
118
+ kind: 'Fragment',
119
+ version: VERSION$2,
120
+ private: [],
121
+ selections: [
122
+ {
123
+ name: 'generationId',
124
+ kind: 'Scalar'
125
+ },
126
+ {
127
+ name: 'response',
128
+ kind: 'Scalar'
129
+ }
130
+ ]
131
+ };
132
+ };
133
+ function equals$2(existing, incoming) {
134
+ const existing_generationId = existing.generationId;
135
+ const incoming_generationId = incoming.generationId;
136
+ if (!(existing_generationId === incoming_generationId)) {
137
+ return false;
138
+ }
139
+ const existing_response = existing.response;
140
+ const incoming_response = incoming.response;
141
+ if (!(existing_response === incoming_response)) {
142
+ return false;
143
+ }
144
+ return true;
145
+ }
146
+ const ingest$2 = function FixFormulaRepresentationIngest(input, path, luvio, store, timestamp) {
147
+ if (process.env.NODE_ENV !== 'production') {
148
+ const validateError = validate$2(input);
149
+ if (validateError !== null) {
150
+ throw validateError;
151
+ }
152
+ }
153
+ const key = keyBuilderFromType$2(luvio, input);
154
+ const ttlToUse = TTL$2;
155
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "Formula", VERSION$2, RepresentationType$2, equals$2);
156
+ return createLink(key);
157
+ };
158
+ function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
159
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
160
+ const rootKey = keyBuilderFromType$2(luvio, input);
161
+ rootKeySet.set(rootKey, {
162
+ namespace: keyPrefix,
163
+ representationName: RepresentationType$2,
164
+ mergeable: false
165
+ });
166
+ }
167
+
168
+ function select$4(luvio, params) {
169
+ return select$5();
170
+ }
171
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
172
+ getTypeCacheKeys$2(storeKeyMap, luvio, response);
173
+ }
174
+ function ingestSuccess$2(luvio, resourceParams, response) {
175
+ const { body } = response;
176
+ const key = keyBuilderFromType$2(luvio, body);
177
+ luvio.storeIngest(key, ingest$2, body);
178
+ const snapshot = luvio.storeLookup({
179
+ recordId: key,
180
+ node: select$4(),
181
+ variables: {},
182
+ });
183
+ if (process.env.NODE_ENV !== 'production') {
184
+ if (snapshot.state !== 'Fulfilled') {
185
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
186
+ }
187
+ }
188
+ deepFreeze(snapshot.data);
189
+ return snapshot;
190
+ }
191
+ function createResourceRequest$2(config) {
192
+ const headers = {};
193
+ return {
194
+ baseUri: '/services/data/v66.0',
195
+ basePath: '/connect/formula/einstein/fix',
196
+ method: 'post',
197
+ body: config.body,
198
+ urlParams: {},
199
+ queryParams: {},
200
+ headers,
201
+ priority: 'normal',
202
+ };
203
+ }
204
+
205
+ const adapterName$2 = 'fixFormula';
206
+ const fixFormula_ConfigPropertyMetadata = [
207
+ generateParamConfigMetadata('entityName', true, 2 /* Body */, 0 /* String */),
208
+ generateParamConfigMetadata('fieldName', false, 2 /* Body */, 0 /* String */),
209
+ generateParamConfigMetadata('formula', true, 2 /* Body */, 0 /* String */),
210
+ generateParamConfigMetadata('formulaType', true, 2 /* Body */, 0 /* String */),
211
+ generateParamConfigMetadata('returnType', true, 2 /* Body */, 0 /* String */),
212
+ ];
213
+ const fixFormula_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, fixFormula_ConfigPropertyMetadata);
214
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(fixFormula_ConfigPropertyMetadata);
215
+ function typeCheckConfig$2(untrustedConfig) {
216
+ const config = {};
217
+ typeCheckConfig$3(untrustedConfig, config, fixFormula_ConfigPropertyMetadata);
218
+ return config;
219
+ }
220
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
221
+ if (!untrustedIsObject(untrustedConfig)) {
222
+ return null;
223
+ }
224
+ if (process.env.NODE_ENV !== 'production') {
225
+ validateConfig(untrustedConfig, configPropertyNames);
226
+ }
227
+ const config = typeCheckConfig$2(untrustedConfig);
228
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
229
+ return null;
230
+ }
231
+ return config;
232
+ }
233
+ function buildNetworkSnapshot$2(luvio, config, options) {
234
+ const resourceParams = createResourceParams$2(config);
235
+ const request = createResourceRequest$2(resourceParams);
236
+ return luvio.dispatchResourceRequest(request, options)
237
+ .then((response) => {
238
+ return luvio.handleSuccessResponse(() => {
239
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
240
+ return luvio.storeBroadcast().then(() => snapshot);
241
+ }, () => {
242
+ const cache = new StoreKeyMap();
243
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
244
+ return cache;
245
+ });
246
+ }, (response) => {
247
+ deepFreeze(response);
248
+ throw response;
249
+ });
250
+ }
251
+ const fixFormulaAdapterFactory = (luvio) => {
252
+ return function fixFormula(untrustedConfig) {
253
+ const config = validateAdapterConfig$2(untrustedConfig, fixFormula_ConfigPropertyNames);
254
+ // Invalid or incomplete config
255
+ if (config === null) {
256
+ throw new Error('Invalid config for "fixFormula"');
257
+ }
258
+ return buildNetworkSnapshot$2(luvio, config);
259
+ };
260
+ };
261
+
262
+ const TTL$1 = 100;
263
+ const VERSION$1 = "c06ad095a0c68e00a7cf4b94f01f937b";
264
+ function validate$1(obj, path = 'FormulaExplanationRepresentation') {
265
+ const v_error = (() => {
266
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
267
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
268
+ }
269
+ const obj_explanation = obj.explanation;
270
+ const path_explanation = path + '.explanation';
271
+ if (typeof obj_explanation !== 'string') {
272
+ return new TypeError('Expected "string" but received "' + typeof obj_explanation + '" (at "' + path_explanation + '")');
273
+ }
274
+ const obj_generationId = obj.generationId;
275
+ const path_generationId = path + '.generationId';
276
+ if (typeof obj_generationId !== 'string') {
277
+ return new TypeError('Expected "string" but received "' + typeof obj_generationId + '" (at "' + path_generationId + '")');
278
+ }
279
+ })();
280
+ return v_error === undefined ? null : v_error;
281
+ }
282
+ const RepresentationType$1 = 'FormulaExplanationRepresentation';
283
+ function keyBuilder$1(luvio, config) {
284
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.generationId;
285
+ }
286
+ function keyBuilderFromType$1(luvio, object) {
287
+ const keyParams = {
288
+ generationId: object.generationId
289
+ };
290
+ return keyBuilder$1(luvio, keyParams);
291
+ }
292
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
293
+ return input;
294
+ }
295
+ const select$3 = function FormulaExplanationRepresentationSelect() {
296
+ return {
297
+ kind: 'Fragment',
298
+ version: VERSION$1,
299
+ private: [],
300
+ selections: [
301
+ {
302
+ name: 'explanation',
303
+ kind: 'Scalar'
304
+ },
305
+ {
306
+ name: 'generationId',
307
+ kind: 'Scalar'
308
+ }
309
+ ]
310
+ };
311
+ };
312
+ function equals$1(existing, incoming) {
313
+ const existing_explanation = existing.explanation;
314
+ const incoming_explanation = incoming.explanation;
315
+ if (!(existing_explanation === incoming_explanation)) {
316
+ return false;
317
+ }
318
+ const existing_generationId = existing.generationId;
319
+ const incoming_generationId = incoming.generationId;
320
+ if (!(existing_generationId === incoming_generationId)) {
321
+ return false;
322
+ }
323
+ return true;
324
+ }
325
+ const ingest$1 = function FormulaExplanationRepresentationIngest(input, path, luvio, store, timestamp) {
326
+ if (process.env.NODE_ENV !== 'production') {
327
+ const validateError = validate$1(input);
328
+ if (validateError !== null) {
329
+ throw validateError;
330
+ }
331
+ }
332
+ const key = keyBuilderFromType$1(luvio, input);
333
+ const ttlToUse = TTL$1;
334
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "Formula", VERSION$1, RepresentationType$1, equals$1);
335
+ return createLink(key);
336
+ };
337
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
338
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
339
+ const rootKey = keyBuilderFromType$1(luvio, input);
340
+ rootKeySet.set(rootKey, {
341
+ namespace: keyPrefix,
342
+ representationName: RepresentationType$1,
343
+ mergeable: false
344
+ });
345
+ }
346
+
347
+ function select$2(luvio, params) {
348
+ return select$3();
349
+ }
350
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
351
+ getTypeCacheKeys$1(storeKeyMap, luvio, response);
352
+ }
353
+ function ingestSuccess$1(luvio, resourceParams, response) {
354
+ const { body } = response;
355
+ const key = keyBuilderFromType$1(luvio, body);
356
+ luvio.storeIngest(key, ingest$1, body);
357
+ const snapshot = luvio.storeLookup({
358
+ recordId: key,
359
+ node: select$2(),
360
+ variables: {},
361
+ });
362
+ if (process.env.NODE_ENV !== 'production') {
363
+ if (snapshot.state !== 'Fulfilled') {
364
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
365
+ }
366
+ }
367
+ deepFreeze(snapshot.data);
368
+ return snapshot;
369
+ }
370
+ function createResourceRequest$1(config) {
371
+ const headers = {};
372
+ return {
373
+ baseUri: '/services/data/v66.0',
374
+ basePath: '/connect/formula/einstein/explain',
375
+ method: 'post',
376
+ body: config.body,
377
+ urlParams: {},
378
+ queryParams: {},
379
+ headers,
380
+ priority: 'normal',
381
+ };
382
+ }
383
+
384
+ const adapterName$1 = 'getExplanation';
385
+ const getExplanation_ConfigPropertyMetadata = [
386
+ generateParamConfigMetadata('entityName', true, 2 /* Body */, 0 /* String */),
387
+ generateParamConfigMetadata('formula', true, 2 /* Body */, 0 /* String */),
388
+ generateParamConfigMetadata('formulaType', true, 2 /* Body */, 0 /* String */),
389
+ generateParamConfigMetadata('returnType', true, 2 /* Body */, 0 /* String */),
390
+ ];
391
+ const getExplanation_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getExplanation_ConfigPropertyMetadata);
392
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(getExplanation_ConfigPropertyMetadata);
393
+ function typeCheckConfig$1(untrustedConfig) {
394
+ const config = {};
395
+ typeCheckConfig$3(untrustedConfig, config, getExplanation_ConfigPropertyMetadata);
396
+ return config;
397
+ }
398
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
399
+ if (!untrustedIsObject(untrustedConfig)) {
400
+ return null;
401
+ }
402
+ if (process.env.NODE_ENV !== 'production') {
403
+ validateConfig(untrustedConfig, configPropertyNames);
404
+ }
405
+ const config = typeCheckConfig$1(untrustedConfig);
406
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
407
+ return null;
408
+ }
409
+ return config;
410
+ }
411
+ function buildNetworkSnapshot$1(luvio, config, options) {
412
+ const resourceParams = createResourceParams$1(config);
413
+ const request = createResourceRequest$1(resourceParams);
414
+ return luvio.dispatchResourceRequest(request, options)
415
+ .then((response) => {
416
+ return luvio.handleSuccessResponse(() => {
417
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response);
418
+ return luvio.storeBroadcast().then(() => snapshot);
419
+ }, () => {
420
+ const cache = new StoreKeyMap();
421
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
422
+ return cache;
423
+ });
424
+ }, (response) => {
425
+ deepFreeze(response);
426
+ throw response;
427
+ });
428
+ }
429
+ const getExplanationAdapterFactory = (luvio) => {
430
+ return function getExplanation(untrustedConfig) {
431
+ const config = validateAdapterConfig$1(untrustedConfig, getExplanation_ConfigPropertyNames);
432
+ // Invalid or incomplete config
433
+ if (config === null) {
434
+ throw new Error('Invalid config for "getExplanation"');
435
+ }
436
+ return buildNetworkSnapshot$1(luvio, config);
437
+ };
438
+ };
439
+
440
+ const TTL = 100;
441
+ const VERSION = "6fae0fe9f113df4590f7d92a6005ddeb";
442
+ function validate(obj, path = 'FormulaValidationRepresentation') {
443
+ const v_error = (() => {
444
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
445
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
446
+ }
447
+ const obj_isFormulaValid = obj.isFormulaValid;
448
+ const path_isFormulaValid = path + '.isFormulaValid';
449
+ if (typeof obj_isFormulaValid !== 'boolean') {
450
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isFormulaValid + '" (at "' + path_isFormulaValid + '")');
451
+ }
452
+ if (obj.message !== undefined) {
453
+ const obj_message = obj.message;
454
+ const path_message = path + '.message';
455
+ let obj_message_union0 = null;
456
+ const obj_message_union0_error = (() => {
457
+ if (typeof obj_message !== 'string') {
458
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
459
+ }
460
+ })();
461
+ if (obj_message_union0_error != null) {
462
+ obj_message_union0 = obj_message_union0_error.message;
463
+ }
464
+ let obj_message_union1 = null;
465
+ const obj_message_union1_error = (() => {
466
+ if (obj_message !== null) {
467
+ return new TypeError('Expected "null" but received "' + typeof obj_message + '" (at "' + path_message + '")');
468
+ }
469
+ })();
470
+ if (obj_message_union1_error != null) {
471
+ obj_message_union1 = obj_message_union1_error.message;
472
+ }
473
+ if (obj_message_union0 && obj_message_union1) {
474
+ let message = 'Object doesn\'t match union (at "' + path_message + '")';
475
+ message += '\n' + obj_message_union0.split('\n').map((line) => '\t' + line).join('\n');
476
+ message += '\n' + obj_message_union1.split('\n').map((line) => '\t' + line).join('\n');
477
+ return new TypeError(message);
478
+ }
479
+ }
480
+ })();
481
+ return v_error === undefined ? null : v_error;
482
+ }
483
+ const RepresentationType = 'FormulaValidationRepresentation';
484
+ function keyBuilder(luvio, config) {
485
+ return keyPrefix + '::' + RepresentationType + ':' + config.isFormulaValid;
486
+ }
487
+ function keyBuilderFromType(luvio, object) {
488
+ const keyParams = {
489
+ isFormulaValid: object.isFormulaValid
490
+ };
491
+ return keyBuilder(luvio, keyParams);
492
+ }
493
+ function normalize(input, existing, path, luvio, store, timestamp) {
494
+ return input;
495
+ }
496
+ const select$1 = function FormulaValidationRepresentationSelect() {
497
+ return {
498
+ kind: 'Fragment',
499
+ version: VERSION,
500
+ private: [],
501
+ selections: [
502
+ {
503
+ name: 'isFormulaValid',
504
+ kind: 'Scalar'
505
+ },
506
+ {
507
+ name: 'message',
508
+ kind: 'Scalar',
509
+ required: false
510
+ }
511
+ ]
512
+ };
513
+ };
514
+ function equals(existing, incoming) {
515
+ const existing_isFormulaValid = existing.isFormulaValid;
516
+ const incoming_isFormulaValid = incoming.isFormulaValid;
517
+ if (!(existing_isFormulaValid === incoming_isFormulaValid)) {
518
+ return false;
519
+ }
520
+ const existing_message = existing.message;
521
+ const incoming_message = incoming.message;
522
+ // if at least one of these optionals is defined
523
+ if (existing_message !== undefined || incoming_message !== undefined) {
524
+ // if one of these is not defined we know the other is defined and therefore
525
+ // not equal
526
+ if (existing_message === undefined || incoming_message === undefined) {
527
+ return false;
528
+ }
529
+ if (!(existing_message === incoming_message)) {
530
+ return false;
531
+ }
532
+ }
533
+ return true;
534
+ }
535
+ const ingest = function FormulaValidationRepresentationIngest(input, path, luvio, store, timestamp) {
536
+ if (process.env.NODE_ENV !== 'production') {
537
+ const validateError = validate(input);
538
+ if (validateError !== null) {
539
+ throw validateError;
540
+ }
541
+ }
542
+ const key = keyBuilderFromType(luvio, input);
543
+ const ttlToUse = TTL;
544
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "Formula", VERSION, RepresentationType, equals);
545
+ return createLink(key);
546
+ };
547
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
548
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
549
+ const rootKey = keyBuilderFromType(luvio, input);
550
+ rootKeySet.set(rootKey, {
551
+ namespace: keyPrefix,
552
+ representationName: RepresentationType,
553
+ mergeable: false
554
+ });
555
+ }
556
+
557
+ function select(luvio, params) {
558
+ return select$1();
559
+ }
560
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
561
+ getTypeCacheKeys(storeKeyMap, luvio, response);
562
+ }
563
+ function ingestSuccess(luvio, resourceParams, response) {
564
+ const { body } = response;
565
+ const key = keyBuilderFromType(luvio, body);
566
+ luvio.storeIngest(key, ingest, body);
567
+ const snapshot = luvio.storeLookup({
568
+ recordId: key,
569
+ node: select(),
570
+ variables: {},
571
+ });
572
+ if (process.env.NODE_ENV !== 'production') {
573
+ if (snapshot.state !== 'Fulfilled') {
574
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
575
+ }
576
+ }
577
+ deepFreeze(snapshot.data);
578
+ return snapshot;
579
+ }
580
+ function createResourceRequest(config) {
581
+ const headers = {};
582
+ return {
583
+ baseUri: '/services/data/v66.0',
584
+ basePath: '/connect/formula/validate',
585
+ method: 'post',
586
+ body: config.body,
587
+ urlParams: {},
588
+ queryParams: {},
589
+ headers,
590
+ priority: 'normal',
591
+ };
592
+ }
593
+
594
+ const adapterName = 'validateFormula';
595
+ const validateFormula_ConfigPropertyMetadata = [
596
+ generateParamConfigMetadata('entityName', true, 2 /* Body */, 0 /* String */),
597
+ generateParamConfigMetadata('fieldName', false, 2 /* Body */, 0 /* String */),
598
+ generateParamConfigMetadata('formula', true, 2 /* Body */, 0 /* String */),
599
+ generateParamConfigMetadata('formulaType', true, 2 /* Body */, 0 /* String */),
600
+ generateParamConfigMetadata('returnType', true, 2 /* Body */, 0 /* String */),
601
+ ];
602
+ const validateFormula_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, validateFormula_ConfigPropertyMetadata);
603
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(validateFormula_ConfigPropertyMetadata);
604
+ function typeCheckConfig(untrustedConfig) {
605
+ const config = {};
606
+ typeCheckConfig$3(untrustedConfig, config, validateFormula_ConfigPropertyMetadata);
607
+ return config;
608
+ }
609
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
610
+ if (!untrustedIsObject(untrustedConfig)) {
611
+ return null;
612
+ }
613
+ if (process.env.NODE_ENV !== 'production') {
614
+ validateConfig(untrustedConfig, configPropertyNames);
615
+ }
616
+ const config = typeCheckConfig(untrustedConfig);
617
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
618
+ return null;
619
+ }
620
+ return config;
621
+ }
622
+ function buildNetworkSnapshot(luvio, config, options) {
623
+ const resourceParams = createResourceParams(config);
624
+ const request = createResourceRequest(resourceParams);
625
+ return luvio.dispatchResourceRequest(request, options)
626
+ .then((response) => {
627
+ return luvio.handleSuccessResponse(() => {
628
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
629
+ return luvio.storeBroadcast().then(() => snapshot);
630
+ }, () => {
631
+ const cache = new StoreKeyMap();
632
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
633
+ return cache;
634
+ });
635
+ }, (response) => {
636
+ deepFreeze(response);
637
+ throw response;
638
+ });
639
+ }
640
+ const validateFormulaAdapterFactory = (luvio) => {
641
+ return function validateFormula(untrustedConfig) {
642
+ const config = validateAdapterConfig(untrustedConfig, validateFormula_ConfigPropertyNames);
643
+ // Invalid or incomplete config
644
+ if (config === null) {
645
+ throw new Error('Invalid config for "validateFormula"');
646
+ }
647
+ return buildNetworkSnapshot(luvio, config);
648
+ };
649
+ };
650
+
651
+ let fixFormula;
652
+ let getExplanation;
653
+ let validateFormula;
654
+ // Notify Update Available
655
+ function bindExportsTo(luvio) {
656
+ // LDS Adapters
657
+ function unwrapSnapshotData(factory) {
658
+ const adapter = factory(luvio);
659
+ return (config) => adapter(config).then((snapshot) => snapshot.data);
660
+ }
661
+ return {
662
+ fixFormula: unwrapSnapshotData(fixFormulaAdapterFactory),
663
+ getExplanation: unwrapSnapshotData(getExplanationAdapterFactory),
664
+ validateFormula: unwrapSnapshotData(validateFormulaAdapterFactory),
665
+ // Imperative GET Adapters
666
+ // Notify Update Availables
667
+ };
668
+ }
669
+ withDefaultLuvio((luvio) => {
670
+ ({ fixFormula, getExplanation, validateFormula } = bindExportsTo(luvio));
671
+ });
672
+
673
+ export { fixFormula, getExplanation, validateFormula };
674
+ // version: 0.1.0-dev1-c978a7b010