@salesforce/lds-adapters-platform-formula 1.271.0 → 1.273.0

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.
@@ -4,7 +4,7 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2 } from '@luvio/engine';
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$3, typeCheckConfig as typeCheckConfig$3 } from '@luvio/engine';
8
8
 
9
9
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
10
  const { keys: ObjectKeys, create: ObjectCreate } = Object;
@@ -71,9 +71,9 @@ function createLink(ref) {
71
71
  };
72
72
  }
73
73
 
74
- const TTL$1 = 100;
75
- const VERSION$1 = "c06ad095a0c68e00a7cf4b94f01f937b";
76
- function validate$1(obj, path = 'FormulaExplanationRepresentation') {
74
+ const TTL$2 = 100;
75
+ const VERSION$2 = "c06ad095a0c68e00a7cf4b94f01f937b";
76
+ function validate$2(obj, path = 'FormulaExplanationRepresentation') {
77
77
  const v_error = (() => {
78
78
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
79
79
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -91,23 +91,23 @@ function validate$1(obj, path = 'FormulaExplanationRepresentation') {
91
91
  })();
92
92
  return v_error === undefined ? null : v_error;
93
93
  }
94
- const RepresentationType$1 = 'FormulaExplanationRepresentation';
95
- function keyBuilder$1(luvio, config) {
96
- return keyPrefix + '::' + RepresentationType$1 + ':' + config.generationId;
94
+ const RepresentationType$2 = 'FormulaExplanationRepresentation';
95
+ function keyBuilder$2(luvio, config) {
96
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.generationId;
97
97
  }
98
- function keyBuilderFromType$1(luvio, object) {
98
+ function keyBuilderFromType$2(luvio, object) {
99
99
  const keyParams = {
100
100
  generationId: object.generationId
101
101
  };
102
- return keyBuilder$1(luvio, keyParams);
102
+ return keyBuilder$2(luvio, keyParams);
103
103
  }
104
- function normalize$1(input, existing, path, luvio, store, timestamp) {
104
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
105
105
  return input;
106
106
  }
107
- const select$3 = function FormulaExplanationRepresentationSelect() {
107
+ const select$5 = function FormulaExplanationRepresentationSelect() {
108
108
  return {
109
109
  kind: 'Fragment',
110
- version: VERSION$1,
110
+ version: VERSION$2,
111
111
  private: [],
112
112
  selections: [
113
113
  {
@@ -121,7 +121,7 @@ const select$3 = function FormulaExplanationRepresentationSelect() {
121
121
  ]
122
122
  };
123
123
  };
124
- function equals$1(existing, incoming) {
124
+ function equals$2(existing, incoming) {
125
125
  const existing_explanation = existing.explanation;
126
126
  const incoming_explanation = incoming.explanation;
127
127
  if (!(existing_explanation === incoming_explanation)) {
@@ -134,7 +134,185 @@ function equals$1(existing, incoming) {
134
134
  }
135
135
  return true;
136
136
  }
137
- const ingest$1 = function FormulaExplanationRepresentationIngest(input, path, luvio, store, timestamp) {
137
+ const ingest$2 = function FormulaExplanationRepresentationIngest(input, path, luvio, store, timestamp) {
138
+ if (process.env.NODE_ENV !== 'production') {
139
+ const validateError = validate$2(input);
140
+ if (validateError !== null) {
141
+ throw validateError;
142
+ }
143
+ }
144
+ const key = keyBuilderFromType$2(luvio, input);
145
+ const ttlToUse = TTL$2;
146
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "Formula", VERSION$2, RepresentationType$2, equals$2);
147
+ return createLink(key);
148
+ };
149
+ function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
150
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
151
+ const rootKey = keyBuilderFromType$2(luvio, input);
152
+ rootKeySet.set(rootKey, {
153
+ namespace: keyPrefix,
154
+ representationName: RepresentationType$2,
155
+ mergeable: false
156
+ });
157
+ }
158
+
159
+ function select$4(luvio, params) {
160
+ return select$5();
161
+ }
162
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
163
+ getTypeCacheKeys$2(storeKeyMap, luvio, response);
164
+ }
165
+ function ingestSuccess$2(luvio, resourceParams, response) {
166
+ const { body } = response;
167
+ const key = keyBuilderFromType$2(luvio, body);
168
+ luvio.storeIngest(key, ingest$2, body);
169
+ const snapshot = luvio.storeLookup({
170
+ recordId: key,
171
+ node: select$4(),
172
+ variables: {},
173
+ });
174
+ if (process.env.NODE_ENV !== 'production') {
175
+ if (snapshot.state !== 'Fulfilled') {
176
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
177
+ }
178
+ }
179
+ deepFreeze(snapshot.data);
180
+ return snapshot;
181
+ }
182
+ function createResourceRequest$2(config) {
183
+ const headers = {};
184
+ return {
185
+ baseUri: '/services/data/v61.0',
186
+ basePath: '/connect/formula/einstein/explain',
187
+ method: 'post',
188
+ body: config.body,
189
+ urlParams: {},
190
+ queryParams: {},
191
+ headers,
192
+ priority: 'normal',
193
+ };
194
+ }
195
+
196
+ const adapterName$2 = 'getExplanation';
197
+ const getExplanation_ConfigPropertyMetadata = [
198
+ generateParamConfigMetadata('entityName', true, 2 /* Body */, 0 /* String */),
199
+ generateParamConfigMetadata('formula', true, 2 /* Body */, 0 /* String */),
200
+ generateParamConfigMetadata('formulaType', true, 2 /* Body */, 0 /* String */),
201
+ generateParamConfigMetadata('returnType', true, 2 /* Body */, 0 /* String */),
202
+ ];
203
+ const getExplanation_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, getExplanation_ConfigPropertyMetadata);
204
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(getExplanation_ConfigPropertyMetadata);
205
+ function typeCheckConfig$2(untrustedConfig) {
206
+ const config = {};
207
+ typeCheckConfig$3(untrustedConfig, config, getExplanation_ConfigPropertyMetadata);
208
+ return config;
209
+ }
210
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
211
+ if (!untrustedIsObject(untrustedConfig)) {
212
+ return null;
213
+ }
214
+ if (process.env.NODE_ENV !== 'production') {
215
+ validateConfig(untrustedConfig, configPropertyNames);
216
+ }
217
+ const config = typeCheckConfig$2(untrustedConfig);
218
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
219
+ return null;
220
+ }
221
+ return config;
222
+ }
223
+ function buildNetworkSnapshot$2(luvio, config, options) {
224
+ const resourceParams = createResourceParams$2(config);
225
+ const request = createResourceRequest$2(resourceParams);
226
+ return luvio.dispatchResourceRequest(request, options)
227
+ .then((response) => {
228
+ return luvio.handleSuccessResponse(() => {
229
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
230
+ return luvio.storeBroadcast().then(() => snapshot);
231
+ }, () => {
232
+ const cache = new StoreKeyMap();
233
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
234
+ return cache;
235
+ });
236
+ }, (response) => {
237
+ deepFreeze(response);
238
+ throw response;
239
+ });
240
+ }
241
+ const getExplanationAdapterFactory = (luvio) => {
242
+ return function getExplanation(untrustedConfig) {
243
+ const config = validateAdapterConfig$2(untrustedConfig, getExplanation_ConfigPropertyNames);
244
+ // Invalid or incomplete config
245
+ if (config === null) {
246
+ throw new Error('Invalid config for "getExplanation"');
247
+ }
248
+ return buildNetworkSnapshot$2(luvio, config);
249
+ };
250
+ };
251
+
252
+ const TTL$1 = 100;
253
+ const VERSION$1 = "fb4a459f302e4d90aa792f35b0525f8f";
254
+ function validate$1(obj, path = 'FixFormulaRepresentation') {
255
+ const v_error = (() => {
256
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
257
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
258
+ }
259
+ const obj_generationId = obj.generationId;
260
+ const path_generationId = path + '.generationId';
261
+ if (typeof obj_generationId !== 'string') {
262
+ return new TypeError('Expected "string" but received "' + typeof obj_generationId + '" (at "' + path_generationId + '")');
263
+ }
264
+ const obj_response = obj.response;
265
+ const path_response = path + '.response';
266
+ if (typeof obj_response !== 'string') {
267
+ return new TypeError('Expected "string" but received "' + typeof obj_response + '" (at "' + path_response + '")');
268
+ }
269
+ })();
270
+ return v_error === undefined ? null : v_error;
271
+ }
272
+ const RepresentationType$1 = 'FixFormulaRepresentation';
273
+ function keyBuilder$1(luvio, config) {
274
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.generationId;
275
+ }
276
+ function keyBuilderFromType$1(luvio, object) {
277
+ const keyParams = {
278
+ generationId: object.generationId
279
+ };
280
+ return keyBuilder$1(luvio, keyParams);
281
+ }
282
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
283
+ return input;
284
+ }
285
+ const select$3 = function FixFormulaRepresentationSelect() {
286
+ return {
287
+ kind: 'Fragment',
288
+ version: VERSION$1,
289
+ private: [],
290
+ selections: [
291
+ {
292
+ name: 'generationId',
293
+ kind: 'Scalar'
294
+ },
295
+ {
296
+ name: 'response',
297
+ kind: 'Scalar'
298
+ }
299
+ ]
300
+ };
301
+ };
302
+ function equals$1(existing, incoming) {
303
+ const existing_generationId = existing.generationId;
304
+ const incoming_generationId = incoming.generationId;
305
+ if (!(existing_generationId === incoming_generationId)) {
306
+ return false;
307
+ }
308
+ const existing_response = existing.response;
309
+ const incoming_response = incoming.response;
310
+ if (!(existing_response === incoming_response)) {
311
+ return false;
312
+ }
313
+ return true;
314
+ }
315
+ const ingest$1 = function FixFormulaRepresentationIngest(input, path, luvio, store, timestamp) {
138
316
  if (process.env.NODE_ENV !== 'production') {
139
317
  const validateError = validate$1(input);
140
318
  if (validateError !== null) {
@@ -183,7 +361,7 @@ function createResourceRequest$1(config) {
183
361
  const headers = {};
184
362
  return {
185
363
  baseUri: '/services/data/v61.0',
186
- basePath: '/connect/formula/einstein/explain',
364
+ basePath: '/connect/formula/einstein/fix',
187
365
  method: 'post',
188
366
  body: config.body,
189
367
  urlParams: {},
@@ -193,18 +371,19 @@ function createResourceRequest$1(config) {
193
371
  };
194
372
  }
195
373
 
196
- const adapterName$1 = 'getExplanation';
197
- const getExplanation_ConfigPropertyMetadata = [
374
+ const adapterName$1 = 'fixFormula';
375
+ const fixFormula_ConfigPropertyMetadata = [
198
376
  generateParamConfigMetadata('entityName', true, 2 /* Body */, 0 /* String */),
377
+ generateParamConfigMetadata('fieldName', false, 2 /* Body */, 0 /* String */),
199
378
  generateParamConfigMetadata('formula', true, 2 /* Body */, 0 /* String */),
200
379
  generateParamConfigMetadata('formulaType', true, 2 /* Body */, 0 /* String */),
201
380
  generateParamConfigMetadata('returnType', true, 2 /* Body */, 0 /* String */),
202
381
  ];
203
- const getExplanation_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getExplanation_ConfigPropertyMetadata);
204
- const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getExplanation_ConfigPropertyMetadata);
382
+ const fixFormula_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, fixFormula_ConfigPropertyMetadata);
383
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(fixFormula_ConfigPropertyMetadata);
205
384
  function typeCheckConfig$1(untrustedConfig) {
206
385
  const config = {};
207
- typeCheckConfig$2(untrustedConfig, config, getExplanation_ConfigPropertyMetadata);
386
+ typeCheckConfig$3(untrustedConfig, config, fixFormula_ConfigPropertyMetadata);
208
387
  return config;
209
388
  }
210
389
  function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
@@ -238,12 +417,12 @@ function buildNetworkSnapshot$1(luvio, config, options) {
238
417
  throw response;
239
418
  });
240
419
  }
241
- const getExplanationAdapterFactory = (luvio) => {
242
- return function getExplanation(untrustedConfig) {
243
- const config = validateAdapterConfig$1(untrustedConfig, getExplanation_ConfigPropertyNames);
420
+ const fixFormulaAdapterFactory = (luvio) => {
421
+ return function fixFormula(untrustedConfig) {
422
+ const config = validateAdapterConfig$1(untrustedConfig, fixFormula_ConfigPropertyNames);
244
423
  // Invalid or incomplete config
245
424
  if (config === null) {
246
- throw new Error('Invalid config for "getExplanation"');
425
+ throw new Error('Invalid config for "fixFormula"');
247
426
  }
248
427
  return buildNetworkSnapshot$1(luvio, config);
249
428
  };
@@ -412,10 +591,10 @@ const validateFormula_ConfigPropertyMetadata = [
412
591
  generateParamConfigMetadata('returnType', true, 2 /* Body */, 0 /* String */),
413
592
  ];
414
593
  const validateFormula_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, validateFormula_ConfigPropertyMetadata);
415
- const createResourceParams = /*#__PURE__*/ createResourceParams$2(validateFormula_ConfigPropertyMetadata);
594
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(validateFormula_ConfigPropertyMetadata);
416
595
  function typeCheckConfig(untrustedConfig) {
417
596
  const config = {};
418
- typeCheckConfig$2(untrustedConfig, config, validateFormula_ConfigPropertyMetadata);
597
+ typeCheckConfig$3(untrustedConfig, config, validateFormula_ConfigPropertyMetadata);
419
598
  return config;
420
599
  }
421
600
  function validateAdapterConfig(untrustedConfig, configPropertyNames) {
@@ -460,4 +639,4 @@ const validateFormulaAdapterFactory = (luvio) => {
460
639
  };
461
640
  };
462
641
 
463
- export { getExplanationAdapterFactory, validateFormulaAdapterFactory };
642
+ export { fixFormulaAdapterFactory, getExplanationAdapterFactory, validateFormulaAdapterFactory };
@@ -0,0 +1,19 @@
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_postConnectFormulaEinsteinFix_ResourceRequestConfig } from '../resources/postConnectFormulaEinsteinFix';
4
+ import { FixFormulaRepresentation as types_FixFormulaRepresentation_FixFormulaRepresentation } from '../types/FixFormulaRepresentation';
5
+ export declare const adapterName = "fixFormula";
6
+ export declare const fixFormula_ConfigPropertyMetadata: $64$luvio_engine_AdapterConfigMetadata[];
7
+ export declare const fixFormula_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
8
+ export interface FixFormulaConfig {
9
+ entityName: string;
10
+ fieldName?: string;
11
+ formula: string;
12
+ formulaType: string;
13
+ returnType: string;
14
+ }
15
+ export declare const createResourceParams: (config: FixFormulaConfig) => resources_postConnectFormulaEinsteinFix_ResourceRequestConfig;
16
+ export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<FixFormulaConfig>): adapter$45$utils_Untrusted<FixFormulaConfig>;
17
+ export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): FixFormulaConfig | null;
18
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: FixFormulaConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_FixFormulaRepresentation_FixFormulaRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_FixFormulaRepresentation_FixFormulaRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_FixFormulaRepresentation_FixFormulaRepresentation, any>>;
19
+ export declare const fixFormulaAdapterFactory: $64$luvio_engine_AdapterFactory<FixFormulaConfig, types_FixFormulaRepresentation_FixFormulaRepresentation>;
@@ -1,2 +1,3 @@
1
1
  export { getExplanationAdapterFactory } from '../adapters/getExplanation';
2
+ export { fixFormulaAdapterFactory } from '../adapters/fixFormula';
2
3
  export { validateFormulaAdapterFactory } from '../adapters/validateFormula';
@@ -1,3 +1,4 @@
1
+ declare let fixFormula: any;
1
2
  declare let getExplanation: any;
2
3
  declare let validateFormula: any;
3
- export { getExplanation, validateFormula };
4
+ export { fixFormula, getExplanation, validateFormula };
@@ -0,0 +1,16 @@
1
+ import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, FetchResponse as $64$luvio_engine_FetchResponse, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
2
+ import { FixFormulaRepresentation as types_FixFormulaRepresentation_FixFormulaRepresentation } from '../types/FixFormulaRepresentation';
3
+ export interface ResourceRequestConfig {
4
+ body: {
5
+ entityName: string;
6
+ fieldName?: string;
7
+ formula: string;
8
+ formulaType: string;
9
+ returnType: string;
10
+ };
11
+ }
12
+ export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
13
+ export declare function getResponseCacheKeys(storeKeyMap: any, luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_FixFormulaRepresentation_FixFormulaRepresentation): void;
14
+ export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_FixFormulaRepresentation_FixFormulaRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_FixFormulaRepresentation_FixFormulaRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_FixFormulaRepresentation_FixFormulaRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_FixFormulaRepresentation_FixFormulaRepresentation, any>;
15
+ export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
16
+ export default createResourceRequest;
@@ -0,0 +1,40 @@
1
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
2
+ export declare const VERSION = "a777b210643fdd906951635d627027a6";
3
+ export declare function validate(obj: any, path?: string): TypeError | null;
4
+ export declare const RepresentationType: string;
5
+ export declare function normalize(input: FixFormulaInputRepresentation, existing: FixFormulaInputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): FixFormulaInputRepresentationNormalized;
6
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
7
+ export declare function equals(existing: FixFormulaInputRepresentationNormalized, incoming: FixFormulaInputRepresentationNormalized): boolean;
8
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
9
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: FixFormulaInputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
10
+ /**
11
+ * The input representation for fixing a formula
12
+ *
13
+ * Keys:
14
+ * (none)
15
+ */
16
+ export interface FixFormulaInputRepresentationNormalized {
17
+ /** Entity Name from the formula builder */
18
+ entityName: string;
19
+ /** Field name if the formula is already saved */
20
+ fieldName?: string;
21
+ /** Formula which needs to be fixed */
22
+ formula: string;
23
+ /** Formula Type */
24
+ formulaType: string;
25
+ /** Return type of the formula */
26
+ returnType: string;
27
+ }
28
+ /**
29
+ * The input representation for fixing a formula
30
+ *
31
+ * Keys:
32
+ * (none)
33
+ */
34
+ export interface FixFormulaInputRepresentation {
35
+ entityName: string;
36
+ fieldName?: string;
37
+ formula: string;
38
+ formulaType: string;
39
+ returnType: string;
40
+ }
@@ -0,0 +1,41 @@
1
+ import { KeyMetadata as $64$luvio_engine_KeyMetadata, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, Luvio as $64$luvio_engine_Luvio, IngestPath as $64$luvio_engine_IngestPath, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
2
+ export declare const TTL = 100;
3
+ export declare const VERSION = "fb4a459f302e4d90aa792f35b0525f8f";
4
+ export declare function validate(obj: any, path?: string): TypeError | null;
5
+ export declare const RepresentationType: string;
6
+ export interface KeyParams extends $64$luvio_engine_KeyMetadata {
7
+ generationId: string;
8
+ }
9
+ export type FixFormulaRepresentationNormalizedKeyMetadata = KeyParams & $64$luvio_engine_NormalizedKeyMetadata;
10
+ export type PartialFixFormulaRepresentationNormalizedKeyMetadata = Partial<KeyParams> & $64$luvio_engine_NormalizedKeyMetadata;
11
+ export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: KeyParams): string;
12
+ export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: KeyParams): FixFormulaRepresentationNormalizedKeyMetadata;
13
+ export declare function keyBuilderFromType(luvio: $64$luvio_engine_Luvio, object: FixFormulaRepresentation): string;
14
+ export declare function keyBuilderFromType_StructuredKey(luvio: $64$luvio_engine_Luvio, object: FixFormulaRepresentation): $64$luvio_engine_NormalizedKeyMetadata;
15
+ export declare function normalize(input: FixFormulaRepresentation, existing: FixFormulaRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): FixFormulaRepresentationNormalized;
16
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
17
+ export declare function equals(existing: FixFormulaRepresentationNormalized, incoming: FixFormulaRepresentationNormalized): boolean;
18
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
19
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: FixFormulaRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
20
+ /**
21
+ * Fix Formula
22
+ *
23
+ * Keys:
24
+ * generationId (string): generationId
25
+ */
26
+ export interface FixFormulaRepresentationNormalized {
27
+ /** Einstein generationId. If formula is valid, this should be null/empty */
28
+ generationId: string;
29
+ /** Fixed formula if the formula is invalid. If formula is valid, returns error response */
30
+ response: string;
31
+ }
32
+ /**
33
+ * Fix Formula
34
+ *
35
+ * Keys:
36
+ * generationId (string): generationId
37
+ */
38
+ export interface FixFormulaRepresentation {
39
+ generationId: string;
40
+ response: string;
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-platform-formula",
3
- "version": "1.271.0",
3
+ "version": "1.273.0",
4
4
  "description": "APIs related to core Salesforce Formulas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "dist/es/es2018/platform-formula.js",
@@ -40,11 +40,11 @@
40
40
  "test:unit": "jest"
41
41
  },
42
42
  "dependencies": {
43
- "@salesforce/lds-bindings": "^1.271.0"
43
+ "@salesforce/lds-bindings": "^1.273.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@salesforce/lds-compiler-plugins": "^1.271.0",
47
- "@salesforce/lds-karma": "^1.271.0"
46
+ "@salesforce/lds-compiler-plugins": "^1.273.0",
47
+ "@salesforce/lds-karma": "^1.273.0"
48
48
  },
49
49
  "nx": {
50
50
  "targets": {
package/sfdc/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  */
14
14
  /* proxy-compat-disable */
15
15
  import { withDefaultLuvio } from 'force/ldsEngine';
16
- import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2 } from 'force/luvioEngine';
16
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$3, typeCheckConfig as typeCheckConfig$3 } from 'force/luvioEngine';
17
17
 
18
18
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
19
19
  const { keys: ObjectKeys, create: ObjectCreate } = Object;
@@ -80,6 +80,185 @@ function createLink(ref) {
80
80
  };
81
81
  }
82
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/v61.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
+
83
262
  const TTL$1 = 100;
84
263
  const VERSION$1 = "c06ad095a0c68e00a7cf4b94f01f937b";
85
264
  function validate$1(obj, path = 'FormulaExplanationRepresentation') {
@@ -210,10 +389,10 @@ const getExplanation_ConfigPropertyMetadata = [
210
389
  generateParamConfigMetadata('returnType', true, 2 /* Body */, 0 /* String */),
211
390
  ];
212
391
  const getExplanation_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getExplanation_ConfigPropertyMetadata);
213
- const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getExplanation_ConfigPropertyMetadata);
392
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(getExplanation_ConfigPropertyMetadata);
214
393
  function typeCheckConfig$1(untrustedConfig) {
215
394
  const config = {};
216
- typeCheckConfig$2(untrustedConfig, config, getExplanation_ConfigPropertyMetadata);
395
+ typeCheckConfig$3(untrustedConfig, config, getExplanation_ConfigPropertyMetadata);
217
396
  return config;
218
397
  }
219
398
  function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
@@ -421,10 +600,10 @@ const validateFormula_ConfigPropertyMetadata = [
421
600
  generateParamConfigMetadata('returnType', true, 2 /* Body */, 0 /* String */),
422
601
  ];
423
602
  const validateFormula_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, validateFormula_ConfigPropertyMetadata);
424
- const createResourceParams = /*#__PURE__*/ createResourceParams$2(validateFormula_ConfigPropertyMetadata);
603
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(validateFormula_ConfigPropertyMetadata);
425
604
  function typeCheckConfig(untrustedConfig) {
426
605
  const config = {};
427
- typeCheckConfig$2(untrustedConfig, config, validateFormula_ConfigPropertyMetadata);
606
+ typeCheckConfig$3(untrustedConfig, config, validateFormula_ConfigPropertyMetadata);
428
607
  return config;
429
608
  }
430
609
  function validateAdapterConfig(untrustedConfig, configPropertyNames) {
@@ -469,6 +648,7 @@ const validateFormulaAdapterFactory = (luvio) => {
469
648
  };
470
649
  };
471
650
 
651
+ let fixFormula;
472
652
  let getExplanation;
473
653
  let validateFormula;
474
654
  // Notify Update Available
@@ -479,6 +659,7 @@ function bindExportsTo(luvio) {
479
659
  return (config) => adapter(config).then((snapshot) => snapshot.data);
480
660
  }
481
661
  return {
662
+ fixFormula: unwrapSnapshotData(fixFormulaAdapterFactory),
482
663
  getExplanation: unwrapSnapshotData(getExplanationAdapterFactory),
483
664
  validateFormula: unwrapSnapshotData(validateFormulaAdapterFactory),
484
665
  // Imperative GET Adapters
@@ -486,8 +667,8 @@ function bindExportsTo(luvio) {
486
667
  };
487
668
  }
488
669
  withDefaultLuvio((luvio) => {
489
- ({ getExplanation, validateFormula } = bindExportsTo(luvio));
670
+ ({ fixFormula, getExplanation, validateFormula } = bindExportsTo(luvio));
490
671
  });
491
672
 
492
- export { getExplanation, validateFormula };
493
- // version: 1.271.0-c2f810db8
673
+ export { fixFormula, getExplanation, validateFormula };
674
+ // version: 1.273.0-daa4f720d
package/src/raml/api.raml CHANGED
@@ -54,6 +54,50 @@ types:
54
54
  - Percent
55
55
  - Text
56
56
  - Time
57
+ FixFormulaInputRepresentation:
58
+ description: The input representation for fixing a formula
59
+ type: object
60
+ properties:
61
+ entityName:
62
+ description: Entity Name from the formula builder
63
+ type: string
64
+ fieldName:
65
+ description: Field name if the formula is already saved
66
+ type: string
67
+ required: false
68
+ formula:
69
+ description: Formula which needs to be fixed
70
+ type: string
71
+ formulaType:
72
+ description: Formula Type
73
+ type: string
74
+ enum:
75
+ - CustomField
76
+ - DefaultValue
77
+ - Validation
78
+ returnType:
79
+ description: Return type of the formula
80
+ type: string
81
+ enum:
82
+ - Boolean
83
+ - Currency
84
+ - Date
85
+ - DateTime
86
+ - Number
87
+ - Percent
88
+ - Text
89
+ - Time
90
+ FixFormulaRepresentation:
91
+ description: Fix Formula
92
+ type: object
93
+ properties:
94
+ generationId:
95
+ description: Einstein generationId. If formula is valid, this should be null/empty
96
+ type: string
97
+ response:
98
+ description: Fixed formula if the formula is invalid. If formula is valid,
99
+ returns error response
100
+ type: string
57
101
  FormulaExplanationRepresentation:
58
102
  description: Formula Explanation
59
103
  type: object
@@ -110,20 +154,35 @@ types:
110
154
  type: string | nil
111
155
  required: false
112
156
  /connect/formula:
113
- /einstein/explain:
114
- post:
115
- displayName: postFormulaExplanation
116
- description: Gets explanation for a salesforce formula
117
- responses:
118
- '200':
119
- description: Success
120
- body:
121
- application/json:
122
- type: FormulaExplanationRepresentation
123
- body:
124
- application/json:
125
- type: ExplainPromptInputRepresentation
126
- (oas-body-name): formulaExplainInput
157
+ /einstein:
158
+ /explain:
159
+ post:
160
+ displayName: postFormulaExplanation
161
+ description: Gets explanation for a salesforce formula
162
+ responses:
163
+ '200':
164
+ description: Success
165
+ body:
166
+ application/json:
167
+ type: FormulaExplanationRepresentation
168
+ body:
169
+ application/json:
170
+ type: ExplainPromptInputRepresentation
171
+ (oas-body-name): formulaExplainInput
172
+ /fix:
173
+ post:
174
+ displayName: postFormulaFix
175
+ description: Fixes a Salesforce formula
176
+ responses:
177
+ '200':
178
+ description: Success
179
+ body:
180
+ application/json:
181
+ type: FixFormulaRepresentation
182
+ body:
183
+ application/json:
184
+ type: FixFormulaInputRepresentation
185
+ (oas-body-name): formulaFixInput
127
186
  /validate:
128
187
  post:
129
188
  displayName: postFormulaValidation
@@ -16,12 +16,21 @@ types:
16
16
  (luvio.ttl): 100
17
17
  (luvio.key):
18
18
  isFormulaValid: isFormulaValid
19
+ FixFormulaRepresentation:
20
+ (luvio.ttl): 100
21
+ (luvio.key):
22
+ generationId: generationId
19
23
 
20
24
  /connect/formula:
21
- /einstein/explain:
22
- post:
23
- (luvio.adapter):
24
- name: getExplanation
25
+ /einstein:
26
+ /explain:
27
+ post:
28
+ (luvio.adapter):
29
+ name: getExplanation
30
+ /fix:
31
+ post:
32
+ (luvio.adapter):
33
+ name: fixFormula
25
34
  /validate:
26
35
  post:
27
36
  (luvio.adapter):