@salesforce/lds-adapters-platform-formula 1.245.0 → 1.247.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, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$1, StoreKeyMap, createResourceParams as createResourceParams$1 } from '@luvio/engine';
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$1, typeCheckConfig as typeCheckConfig$1 } from '@luvio/engine';
8
8
 
9
9
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
10
  const { keys: ObjectKeys, create: ObjectCreate } = Object;
@@ -41,13 +41,6 @@ function untrustedIsObject(untrusted) {
41
41
  function areRequiredParametersPresent(config, configPropertyNames) {
42
42
  return configPropertyNames.parameters.required.every(req => req in config);
43
43
  }
44
- const snapshotRefreshOptions = {
45
- overrides: {
46
- headers: {
47
- 'Cache-Control': 'no-cache',
48
- },
49
- }
50
- };
51
44
  function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
52
45
  return {
53
46
  name,
@@ -79,7 +72,7 @@ function createLink(ref) {
79
72
  }
80
73
 
81
74
  const TTL = 100;
82
- const VERSION = "6cbd1c5cb74b9f1dee47794fd77fc37b";
75
+ const VERSION = "c06ad095a0c68e00a7cf4b94f01f937b";
83
76
  function validate(obj, path = 'FormulaExplanationRepresentation') {
84
77
  const v_error = (() => {
85
78
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
@@ -99,6 +92,15 @@ function validate(obj, path = 'FormulaExplanationRepresentation') {
99
92
  return v_error === undefined ? null : v_error;
100
93
  }
101
94
  const RepresentationType = 'FormulaExplanationRepresentation';
95
+ function keyBuilder(luvio, config) {
96
+ return keyPrefix + '::' + RepresentationType + ':' + config.generationId;
97
+ }
98
+ function keyBuilderFromType(luvio, object) {
99
+ const keyParams = {
100
+ generationId: object.generationId
101
+ };
102
+ return keyBuilder(luvio, keyParams);
103
+ }
102
104
  function normalize(input, existing, path, luvio, store, timestamp) {
103
105
  return input;
104
106
  }
@@ -139,14 +141,14 @@ const ingest = function FormulaExplanationRepresentationIngest(input, path, luvi
139
141
  throw validateError;
140
142
  }
141
143
  }
142
- const key = path.fullPath;
144
+ const key = keyBuilderFromType(luvio, input);
143
145
  const ttlToUse = TTL;
144
146
  ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "Formula", VERSION, RepresentationType, equals);
145
147
  return createLink(key);
146
148
  };
147
149
  function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
148
150
  // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
149
- const rootKey = fullPathFactory();
151
+ const rootKey = keyBuilderFromType(luvio, input);
150
152
  rootKeySet.set(rootKey, {
151
153
  namespace: keyPrefix,
152
154
  representationName: RepresentationType,
@@ -157,21 +159,18 @@ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
157
159
  function select(luvio, params) {
158
160
  return select$1();
159
161
  }
160
- function keyBuilder$1(luvio, params) {
161
- return keyPrefix + '::FormulaExplanationRepresentation:(' + 'entityName:' + params.body.entityName + '::' + 'formula:' + params.body.formula + '::' + 'formulaType:' + params.body.formulaType + '::' + 'returnType:' + params.body.returnType + ')';
162
- }
163
162
  function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
164
- getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
163
+ getTypeCacheKeys(storeKeyMap, luvio, response);
165
164
  }
166
- function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
165
+ function ingestSuccess(luvio, resourceParams, response) {
167
166
  const { body } = response;
168
- const key = keyBuilder$1(luvio, resourceParams);
167
+ const key = keyBuilderFromType(luvio, body);
169
168
  luvio.storeIngest(key, ingest, body);
170
169
  const snapshot = luvio.storeLookup({
171
170
  recordId: key,
172
171
  node: select(),
173
172
  variables: {},
174
- }, snapshotRefresh);
173
+ });
175
174
  if (process.env.NODE_ENV !== 'production') {
176
175
  if (snapshot.state !== 'Fulfilled') {
177
176
  throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
@@ -180,18 +179,6 @@ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
180
179
  deepFreeze(snapshot.data);
181
180
  return snapshot;
182
181
  }
183
- function ingestError(luvio, params, error, snapshotRefresh) {
184
- const key = keyBuilder$1(luvio, params);
185
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
186
- const storeMetadataParams = {
187
- ttl: TTL,
188
- namespace: keyPrefix,
189
- version: VERSION,
190
- representationName: RepresentationType
191
- };
192
- luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
193
- return errorSnapshot;
194
- }
195
182
  function createResourceRequest(config) {
196
183
  const headers = {};
197
184
  return {
@@ -215,10 +202,6 @@ const getExplanation_ConfigPropertyMetadata = [
215
202
  ];
216
203
  const getExplanation_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getExplanation_ConfigPropertyMetadata);
217
204
  const createResourceParams = /*#__PURE__*/ createResourceParams$1(getExplanation_ConfigPropertyMetadata);
218
- function keyBuilder(luvio, config) {
219
- const resourceParams = createResourceParams(config);
220
- return keyBuilder$1(luvio, resourceParams);
221
- }
222
205
  function typeCheckConfig(untrustedConfig) {
223
206
  const config = {};
224
207
  typeCheckConfig$1(untrustedConfig, config, getExplanation_ConfigPropertyMetadata);
@@ -237,62 +220,33 @@ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
237
220
  }
238
221
  return config;
239
222
  }
240
- function adapterFragment(luvio, config) {
241
- createResourceParams(config);
242
- return select();
243
- }
244
- function onFetchResponseSuccess(luvio, config, resourceParams, response) {
245
- const snapshot = ingestSuccess(luvio, resourceParams, response, {
246
- config,
247
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
248
- });
249
- return luvio.storeBroadcast().then(() => snapshot);
250
- }
251
- function onFetchResponseError(luvio, config, resourceParams, response) {
252
- const snapshot = ingestError(luvio, resourceParams, response, {
253
- config,
254
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
255
- });
256
- return luvio.storeBroadcast().then(() => snapshot);
257
- }
258
223
  function buildNetworkSnapshot(luvio, config, options) {
259
224
  const resourceParams = createResourceParams(config);
260
225
  const request = createResourceRequest(resourceParams);
261
226
  return luvio.dispatchResourceRequest(request, options)
262
227
  .then((response) => {
263
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
228
+ return luvio.handleSuccessResponse(() => {
229
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
230
+ return luvio.storeBroadcast().then(() => snapshot);
231
+ }, () => {
264
232
  const cache = new StoreKeyMap();
265
233
  getResponseCacheKeys(cache, luvio, resourceParams, response.body);
266
234
  return cache;
267
235
  });
268
236
  }, (response) => {
269
- return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
237
+ deepFreeze(response);
238
+ throw response;
270
239
  });
271
240
  }
272
- function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
273
- return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, 'get', false);
274
- }
275
- function buildCachedSnapshotCachePolicy(context, storeLookup) {
276
- const { luvio, config } = context;
277
- const selector = {
278
- recordId: keyBuilder(luvio, config),
279
- node: adapterFragment(luvio, config),
280
- variables: {},
241
+ const getExplanationAdapterFactory = (luvio) => {
242
+ return function getExplanation(untrustedConfig) {
243
+ const config = validateAdapterConfig(untrustedConfig, getExplanation_ConfigPropertyNames);
244
+ // Invalid or incomplete config
245
+ if (config === null) {
246
+ throw new Error('Invalid config for "getExplanation"');
247
+ }
248
+ return buildNetworkSnapshot(luvio, config);
281
249
  };
282
- const cacheSnapshot = storeLookup(selector, {
283
- config,
284
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
285
- });
286
- return cacheSnapshot;
287
- }
288
- const getExplanationAdapterFactory = (luvio) => function Formula__getExplanation(untrustedConfig, requestContext) {
289
- const config = validateAdapterConfig(untrustedConfig, getExplanation_ConfigPropertyNames);
290
- // Invalid or incomplete config
291
- if (config === null) {
292
- return null;
293
- }
294
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
295
- buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
296
250
  };
297
251
 
298
252
  export { getExplanationAdapterFactory };
@@ -1,4 +1,4 @@
1
- import { AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata, Luvio as $64$luvio_engine_Luvio, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, Fragment as $64$luvio_engine_Fragment, Snapshot as $64$luvio_engine_Snapshot, FetchResponse as $64$luvio_engine_FetchResponse, ErrorResponse as $64$luvio_engine_ErrorResponse, DispatchResourceRequestContext as $64$luvio_engine_DispatchResourceRequestContext, CoercedAdapterRequestContext as $64$luvio_engine_CoercedAdapterRequestContext, StoreLookup as $64$luvio_engine_StoreLookup, AdapterFactory as $64$luvio_engine_AdapterFactory } from '@luvio/engine';
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
2
  import { Untrusted as adapter$45$utils_Untrusted, AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig } from './adapter-utils';
3
3
  import { ResourceRequestConfig as resources_postConnectFormulaEinsteinExplain_ResourceRequestConfig } from '../resources/postConnectFormulaEinsteinExplain';
4
4
  import { FormulaExplanationRepresentation as types_FormulaExplanationRepresentation_FormulaExplanationRepresentation } from '../types/FormulaExplanationRepresentation';
@@ -12,19 +12,7 @@ export interface GetExplanationConfig {
12
12
  returnType: string;
13
13
  }
14
14
  export declare const createResourceParams: (config: GetExplanationConfig) => resources_postConnectFormulaEinsteinExplain_ResourceRequestConfig;
15
- export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: GetExplanationConfig): string;
16
- export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: GetExplanationConfig): $64$luvio_engine_NormalizedKeyMetadata;
17
15
  export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<GetExplanationConfig>): adapter$45$utils_Untrusted<GetExplanationConfig>;
18
16
  export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): GetExplanationConfig | null;
19
- export declare function adapterFragment(luvio: $64$luvio_engine_Luvio, config: GetExplanationConfig): $64$luvio_engine_Fragment;
20
- export declare function buildCachedSnapshot(luvio: $64$luvio_engine_Luvio, config: GetExplanationConfig): $64$luvio_engine_Snapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, any>;
21
- export declare function onFetchResponseSuccess(luvio: $64$luvio_engine_Luvio, config: GetExplanationConfig, resourceParams: resources_postConnectFormulaEinsteinExplain_ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation>): Promise<import("@luvio/engine").FulfilledSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, any>>;
22
- export declare function onFetchResponseError(luvio: $64$luvio_engine_Luvio, config: GetExplanationConfig, resourceParams: resources_postConnectFormulaEinsteinExplain_ResourceRequestConfig, response: $64$luvio_engine_ErrorResponse): Promise<import("@luvio/engine").ErrorSnapshot>;
23
- export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: GetExplanationConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<$64$luvio_engine_Snapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, any>>;
24
- export type BuildSnapshotContext = {
25
- luvio: $64$luvio_engine_Luvio;
26
- config: GetExplanationConfig;
27
- };
28
- export declare function buildNetworkSnapshotCachePolicy(context: BuildSnapshotContext, coercedAdapterRequestContext: $64$luvio_engine_CoercedAdapterRequestContext): Promise<$64$luvio_engine_Snapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, any>>;
29
- export declare function buildCachedSnapshotCachePolicy(context: BuildSnapshotContext, storeLookup: $64$luvio_engine_StoreLookup<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation>): $64$luvio_engine_Snapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, any>;
17
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: GetExplanationConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, any>>;
30
18
  export declare const getExplanationAdapterFactory: $64$luvio_engine_AdapterFactory<GetExplanationConfig, types_FormulaExplanationRepresentation_FormulaExplanationRepresentation>;
@@ -1,3 +1,2 @@
1
1
  declare let getExplanation: any;
2
- declare let getExplanation_imperative: any;
3
- export { getExplanation, getExplanation_imperative };
2
+ export { getExplanation, };
@@ -1,4 +1,4 @@
1
- import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, FetchResponse as $64$luvio_engine_FetchResponse, SnapshotRefresh as $64$luvio_engine_SnapshotRefresh, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ErrorResponse as $64$luvio_engine_ErrorResponse, ErrorSnapshot as $64$luvio_engine_ErrorSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
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
2
  import { FormulaExplanationRepresentation as types_FormulaExplanationRepresentation_FormulaExplanationRepresentation } from '../types/FormulaExplanationRepresentation';
3
3
  export interface ResourceRequestConfig {
4
4
  body: {
@@ -9,10 +9,7 @@ export interface ResourceRequestConfig {
9
9
  };
10
10
  }
11
11
  export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
12
- export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): string;
13
- export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_NormalizedKeyMetadata;
14
12
  export declare function getResponseCacheKeys(storeKeyMap: any, luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_FormulaExplanationRepresentation_FormulaExplanationRepresentation): void;
15
- export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation>, snapshotRefresh?: $64$luvio_engine_SnapshotRefresh<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, any>;
16
- export declare function ingestError(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig, error: $64$luvio_engine_ErrorResponse, snapshotRefresh?: $64$luvio_engine_SnapshotRefresh<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation>): $64$luvio_engine_ErrorSnapshot;
13
+ export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_FormulaExplanationRepresentation_FormulaExplanationRepresentation, any>;
17
14
  export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
18
15
  export default createResourceRequest;
@@ -1,8 +1,17 @@
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';
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
2
  export declare const TTL = 100;
3
- export declare const VERSION = "6cbd1c5cb74b9f1dee47794fd77fc37b";
3
+ export declare const VERSION = "c06ad095a0c68e00a7cf4b94f01f937b";
4
4
  export declare function validate(obj: any, path?: string): TypeError | null;
5
5
  export declare const RepresentationType: string;
6
+ export interface KeyParams extends $64$luvio_engine_KeyMetadata {
7
+ generationId: string;
8
+ }
9
+ export type FormulaExplanationRepresentationNormalizedKeyMetadata = KeyParams & $64$luvio_engine_NormalizedKeyMetadata;
10
+ export type PartialFormulaExplanationRepresentationNormalizedKeyMetadata = 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): FormulaExplanationRepresentationNormalizedKeyMetadata;
13
+ export declare function keyBuilderFromType(luvio: $64$luvio_engine_Luvio, object: FormulaExplanationRepresentation): string;
14
+ export declare function keyBuilderFromType_StructuredKey(luvio: $64$luvio_engine_Luvio, object: FormulaExplanationRepresentation): $64$luvio_engine_NormalizedKeyMetadata;
6
15
  export declare function normalize(input: FormulaExplanationRepresentation, existing: FormulaExplanationRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): FormulaExplanationRepresentationNormalized;
7
16
  export declare const select: () => $64$luvio_engine_FragmentSelection;
8
17
  export declare function equals(existing: FormulaExplanationRepresentationNormalized, incoming: FormulaExplanationRepresentationNormalized): boolean;
@@ -12,7 +21,7 @@ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableSto
12
21
  * Formula Explanation
13
22
  *
14
23
  * Keys:
15
- * (none)
24
+ * generationId (string): generationId
16
25
  */
17
26
  export interface FormulaExplanationRepresentationNormalized {
18
27
  /** Explanation of a formula */
@@ -24,7 +33,7 @@ export interface FormulaExplanationRepresentationNormalized {
24
33
  * Formula Explanation
25
34
  *
26
35
  * Keys:
27
- * (none)
36
+ * generationId (string): generationId
28
37
  */
29
38
  export interface FormulaExplanationRepresentation {
30
39
  explanation: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-platform-formula",
3
- "version": "1.245.0",
3
+ "version": "1.247.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",
@@ -31,7 +31,7 @@
31
31
  "karan.jain@salesforce.com"
32
32
  ],
33
33
  "scripts": {
34
- "build": "yarn build:raml && yarn build:services",
34
+ "build": "yarn build:services",
35
35
  "build:raml": "luvio generate src/raml/luvio.raml src/generated -p '../lds-compiler-plugins'",
36
36
  "build:services": "rollup --bundleConfigAsCjs --config rollup.config.js",
37
37
  "clean": "rm -rf dist sfdc src/generated",
@@ -50,9 +50,13 @@
50
50
  "targets": {
51
51
  "build": {
52
52
  "outputs": [
53
- "packages/lds-adapters-platform-formula/dist",
54
- "packages/lds-adapters-platform-formula/sfdc",
55
- "packages/lds-adapters-platform-formula/src/generated"
53
+ "{projectRoot}/dist",
54
+ "{projectRoot}/sfdc"
55
+ ]
56
+ },
57
+ "build:raml": {
58
+ "outputs": [
59
+ "{projectRoot}/src/generated"
56
60
  ]
57
61
  }
58
62
  }
package/sfdc/index.js CHANGED
@@ -12,9 +12,8 @@
12
12
  * *******************************************************************************************
13
13
  */
14
14
  /* proxy-compat-disable */
15
- import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
16
15
  import { withDefaultLuvio } from 'force/ldsEngine';
17
- import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$1, StoreKeyMap, createResourceParams as createResourceParams$1 } from 'force/luvioEngine';
16
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$1, typeCheckConfig as typeCheckConfig$1 } from 'force/luvioEngine';
18
17
 
19
18
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
19
  const { keys: ObjectKeys, create: ObjectCreate } = Object;
@@ -51,13 +50,6 @@ function untrustedIsObject(untrusted) {
51
50
  function areRequiredParametersPresent(config, configPropertyNames) {
52
51
  return configPropertyNames.parameters.required.every(req => req in config);
53
52
  }
54
- const snapshotRefreshOptions = {
55
- overrides: {
56
- headers: {
57
- 'Cache-Control': 'no-cache',
58
- },
59
- }
60
- };
61
53
  function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
62
54
  return {
63
55
  name,
@@ -89,7 +81,7 @@ function createLink(ref) {
89
81
  }
90
82
 
91
83
  const TTL = 100;
92
- const VERSION = "6cbd1c5cb74b9f1dee47794fd77fc37b";
84
+ const VERSION = "c06ad095a0c68e00a7cf4b94f01f937b";
93
85
  function validate(obj, path = 'FormulaExplanationRepresentation') {
94
86
  const v_error = (() => {
95
87
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
@@ -109,6 +101,15 @@ function validate(obj, path = 'FormulaExplanationRepresentation') {
109
101
  return v_error === undefined ? null : v_error;
110
102
  }
111
103
  const RepresentationType = 'FormulaExplanationRepresentation';
104
+ function keyBuilder(luvio, config) {
105
+ return keyPrefix + '::' + RepresentationType + ':' + config.generationId;
106
+ }
107
+ function keyBuilderFromType(luvio, object) {
108
+ const keyParams = {
109
+ generationId: object.generationId
110
+ };
111
+ return keyBuilder(luvio, keyParams);
112
+ }
112
113
  function normalize(input, existing, path, luvio, store, timestamp) {
113
114
  return input;
114
115
  }
@@ -149,14 +150,14 @@ const ingest = function FormulaExplanationRepresentationIngest(input, path, luvi
149
150
  throw validateError;
150
151
  }
151
152
  }
152
- const key = path.fullPath;
153
+ const key = keyBuilderFromType(luvio, input);
153
154
  const ttlToUse = TTL;
154
155
  ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "Formula", VERSION, RepresentationType, equals);
155
156
  return createLink(key);
156
157
  };
157
158
  function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
158
159
  // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
159
- const rootKey = fullPathFactory();
160
+ const rootKey = keyBuilderFromType(luvio, input);
160
161
  rootKeySet.set(rootKey, {
161
162
  namespace: keyPrefix,
162
163
  representationName: RepresentationType,
@@ -167,21 +168,18 @@ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
167
168
  function select(luvio, params) {
168
169
  return select$1();
169
170
  }
170
- function keyBuilder$1(luvio, params) {
171
- return keyPrefix + '::FormulaExplanationRepresentation:(' + 'entityName:' + params.body.entityName + '::' + 'formula:' + params.body.formula + '::' + 'formulaType:' + params.body.formulaType + '::' + 'returnType:' + params.body.returnType + ')';
172
- }
173
171
  function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
174
- getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
172
+ getTypeCacheKeys(storeKeyMap, luvio, response);
175
173
  }
176
- function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
174
+ function ingestSuccess(luvio, resourceParams, response) {
177
175
  const { body } = response;
178
- const key = keyBuilder$1(luvio, resourceParams);
176
+ const key = keyBuilderFromType(luvio, body);
179
177
  luvio.storeIngest(key, ingest, body);
180
178
  const snapshot = luvio.storeLookup({
181
179
  recordId: key,
182
180
  node: select(),
183
181
  variables: {},
184
- }, snapshotRefresh);
182
+ });
185
183
  if (process.env.NODE_ENV !== 'production') {
186
184
  if (snapshot.state !== 'Fulfilled') {
187
185
  throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
@@ -190,18 +188,6 @@ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
190
188
  deepFreeze(snapshot.data);
191
189
  return snapshot;
192
190
  }
193
- function ingestError(luvio, params, error, snapshotRefresh) {
194
- const key = keyBuilder$1(luvio, params);
195
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
196
- const storeMetadataParams = {
197
- ttl: TTL,
198
- namespace: keyPrefix,
199
- version: VERSION,
200
- representationName: RepresentationType
201
- };
202
- luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
203
- return errorSnapshot;
204
- }
205
191
  function createResourceRequest(config) {
206
192
  const headers = {};
207
193
  return {
@@ -225,10 +211,6 @@ const getExplanation_ConfigPropertyMetadata = [
225
211
  ];
226
212
  const getExplanation_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getExplanation_ConfigPropertyMetadata);
227
213
  const createResourceParams = /*#__PURE__*/ createResourceParams$1(getExplanation_ConfigPropertyMetadata);
228
- function keyBuilder(luvio, config) {
229
- const resourceParams = createResourceParams(config);
230
- return keyBuilder$1(luvio, resourceParams);
231
- }
232
214
  function typeCheckConfig(untrustedConfig) {
233
215
  const config = {};
234
216
  typeCheckConfig$1(untrustedConfig, config, getExplanation_ConfigPropertyMetadata);
@@ -247,84 +229,51 @@ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
247
229
  }
248
230
  return config;
249
231
  }
250
- function adapterFragment(luvio, config) {
251
- createResourceParams(config);
252
- return select();
253
- }
254
- function onFetchResponseSuccess(luvio, config, resourceParams, response) {
255
- const snapshot = ingestSuccess(luvio, resourceParams, response, {
256
- config,
257
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
258
- });
259
- return luvio.storeBroadcast().then(() => snapshot);
260
- }
261
- function onFetchResponseError(luvio, config, resourceParams, response) {
262
- const snapshot = ingestError(luvio, resourceParams, response, {
263
- config,
264
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
265
- });
266
- return luvio.storeBroadcast().then(() => snapshot);
267
- }
268
232
  function buildNetworkSnapshot(luvio, config, options) {
269
233
  const resourceParams = createResourceParams(config);
270
234
  const request = createResourceRequest(resourceParams);
271
235
  return luvio.dispatchResourceRequest(request, options)
272
236
  .then((response) => {
273
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
237
+ return luvio.handleSuccessResponse(() => {
238
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
239
+ return luvio.storeBroadcast().then(() => snapshot);
240
+ }, () => {
274
241
  const cache = new StoreKeyMap();
275
242
  getResponseCacheKeys(cache, luvio, resourceParams, response.body);
276
243
  return cache;
277
244
  });
278
245
  }, (response) => {
279
- return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
246
+ deepFreeze(response);
247
+ throw response;
280
248
  });
281
249
  }
282
- function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
283
- return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, 'get', false);
284
- }
285
- function buildCachedSnapshotCachePolicy(context, storeLookup) {
286
- const { luvio, config } = context;
287
- const selector = {
288
- recordId: keyBuilder(luvio, config),
289
- node: adapterFragment(luvio, config),
290
- variables: {},
250
+ const getExplanationAdapterFactory = (luvio) => {
251
+ return function getExplanation(untrustedConfig) {
252
+ const config = validateAdapterConfig(untrustedConfig, getExplanation_ConfigPropertyNames);
253
+ // Invalid or incomplete config
254
+ if (config === null) {
255
+ throw new Error('Invalid config for "getExplanation"');
256
+ }
257
+ return buildNetworkSnapshot(luvio, config);
291
258
  };
292
- const cacheSnapshot = storeLookup(selector, {
293
- config,
294
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
295
- });
296
- return cacheSnapshot;
297
- }
298
- const getExplanationAdapterFactory = (luvio) => function Formula__getExplanation(untrustedConfig, requestContext) {
299
- const config = validateAdapterConfig(untrustedConfig, getExplanation_ConfigPropertyNames);
300
- // Invalid or incomplete config
301
- if (config === null) {
302
- return null;
303
- }
304
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
305
- buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
306
259
  };
307
260
 
308
261
  let getExplanation;
309
- // Imperative GET Adapters
310
- let getExplanation_imperative;
311
- // Adapter Metadata
312
- const getExplanationMetadata = { apiFamily: 'Formula', name: 'getExplanation', ttl: 100 };
313
262
  function bindExportsTo(luvio) {
314
- // LDS Adapters
315
- const getExplanation_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getExplanation', getExplanationAdapterFactory), getExplanationMetadata);
263
+ function unwrapSnapshotData(factory) {
264
+ const adapter = factory(luvio);
265
+ return (config) => adapter(config).then(snapshot => snapshot.data);
266
+ }
316
267
  return {
317
- getExplanation: createWireAdapterConstructor(luvio, getExplanation_ldsAdapter, getExplanationMetadata),
268
+ getExplanation: unwrapSnapshotData(getExplanationAdapterFactory),
318
269
  // Imperative GET Adapters
319
- getExplanation_imperative: createImperativeAdapter(luvio, getExplanation_ldsAdapter, getExplanationMetadata)
320
270
  };
321
271
  }
322
272
  withDefaultLuvio((luvio) => {
323
273
  ({
324
274
  getExplanation,
325
- getExplanation_imperative
326
275
  } = bindExportsTo(luvio));
327
276
  });
328
277
 
329
- export { getExplanation, getExplanation_imperative };
330
- // version: 1.245.0-df5596041
278
+ export { getExplanation };
279
+ // version: 1.247.0-418b3895b
@@ -10,9 +10,10 @@ uses:
10
10
  types:
11
11
  FormulaExplanationRepresentation:
12
12
  (luvio.ttl): 100
13
+ (luvio.key):
14
+ generationId: generationId
13
15
 
14
16
  /connect/formula/einstein/explain:
15
17
  post:
16
18
  (luvio.adapter):
17
19
  name: getExplanation
18
- (luvio.method): get