@salesforce/lds-adapters-commerce-store-pricing 1.212.1 → 1.213.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- import { serializeStructuredKey, deepFreeze, typeCheckScalars, StoreKeyMap } from '@luvio/engine';
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckScalars, StoreKeyMap } from '@luvio/engine';
8
8
 
9
9
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
10
  const { keys: ObjectKeys, create: ObjectCreate } = Object;
@@ -48,6 +48,24 @@ const snapshotRefreshOptions = {
48
48
  },
49
49
  }
50
50
  };
51
+ function generateParamConfigMetadata(name, required, coerceFn) {
52
+ return {
53
+ name,
54
+ required,
55
+ coerceFn,
56
+ };
57
+ }
58
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
59
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
60
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
61
+ return {
62
+ displayName,
63
+ parameters: {
64
+ required,
65
+ optional,
66
+ }
67
+ };
68
+ }
51
69
  const keyPrefix = 'Commerce';
52
70
 
53
71
  const { isArray: ArrayIsArray } = Array;
@@ -210,26 +228,8 @@ const ingest = function ProductPriceRepresentationIngest(input, path, luvio, sto
210
228
  }
211
229
  }
212
230
  const key = path.fullPath;
213
- const existingRecord = store.readEntry(key);
214
231
  const ttlToUse = path.ttl !== undefined ? path.ttl : 2592000000;
215
- let incomingRecord = normalize(input, store.readEntry(key), {
216
- fullPath: key,
217
- parent: path.parent,
218
- propertyName: path.propertyName,
219
- ttl: ttlToUse
220
- });
221
- if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
222
- luvio.storePublish(key, incomingRecord);
223
- }
224
- if (ttlToUse !== undefined) {
225
- const storeMetadataParams = {
226
- ttl: ttlToUse,
227
- namespace: "Commerce",
228
- version: VERSION,
229
- representationName: RepresentationType,
230
- };
231
- luvio.publishStoreMetadata(key, storeMetadataParams);
232
- }
232
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "Commerce", VERSION, RepresentationType, equals);
233
233
  return createLink(key);
234
234
  };
235
235
  function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
@@ -288,13 +288,13 @@ function createResourceRequest(config) {
288
288
  };
289
289
  }
290
290
 
291
- const getProductPrice_ConfigPropertyNames = {
292
- displayName: 'getProductPrice',
293
- parameters: {
294
- required: ['productId', 'webstoreId'],
295
- optional: ['effectiveAccountId']
296
- }
297
- };
291
+ const adapterName = 'getProductPrice';
292
+ const getProductPrice_ConfigPropertyMetadata = [
293
+ generateParamConfigMetadata('productId', true),
294
+ generateParamConfigMetadata('webstoreId', true),
295
+ generateParamConfigMetadata('effectiveAccountId', false),
296
+ ];
297
+ const getProductPrice_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getProductPrice_ConfigPropertyMetadata);
298
298
  function createResourceParams(config) {
299
299
  const resourceParams = {
300
300
  urlParams: {
@@ -365,21 +365,7 @@ function buildNetworkSnapshot(luvio, config, options) {
365
365
  });
366
366
  }
367
367
  function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
368
- const { luvio, config } = context;
369
- const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
370
- const dispatchOptions = {
371
- resourceRequestContext: {
372
- requestCorrelator,
373
- luvioRequestMethod: undefined,
374
- },
375
- eventObservers
376
- };
377
- if (networkPriority !== 'normal') {
378
- dispatchOptions.overrides = {
379
- priority: networkPriority
380
- };
381
- }
382
- return buildNetworkSnapshot(luvio, config, dispatchOptions);
368
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, undefined, false);
383
369
  }
384
370
  function buildCachedSnapshotCachePolicy(context, storeLookup) {
385
371
  const { luvio, config } = context;
@@ -1,4 +1,4 @@
1
- import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot } from '@luvio/engine';
1
+ import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot, AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata } from '@luvio/engine';
2
2
  export declare const ObjectPrototypeHasOwnProperty: (v: PropertyKey) => boolean;
3
3
  declare const ObjectKeys: {
4
4
  (o: object): string[];
@@ -57,4 +57,6 @@ export declare const snapshotRefreshOptions: {
57
57
  export declare function stableJSONStringify(node: any): string | undefined;
58
58
  export declare function getFetchResponseStatusText(status: number): string;
59
59
  export declare function isUnfulfilledSnapshot<T, U>(snapshot: $64$luvio_engine_Snapshot<T, U>): snapshot is $64$luvio_engine_UnfulfilledSnapshot<T, U>;
60
+ export declare function generateParamConfigMetadata(name: string, required: boolean, coerceFn?: (v: unknown) => unknown): $64$luvio_engine_AdapterConfigMetadata;
61
+ export declare function buildAdapterValidationConfig(displayName: string, paramsMeta: $64$luvio_engine_AdapterConfigMetadata[]): AdapterValidationConfig;
60
62
  export declare const keyPrefix = "Commerce";
@@ -1,8 +1,9 @@
1
- import { AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig, Untrusted as adapter$45$utils_Untrusted } from './adapter-utils';
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';
2
+ import { Untrusted as adapter$45$utils_Untrusted, AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig } from './adapter-utils';
2
3
  import { ResourceRequestConfig as resources_getCommerceWebstoresPricingProductsByProductIdAndWebstoreId_ResourceRequestConfig } from '../resources/getCommerceWebstoresPricingProductsByProductIdAndWebstoreId';
3
- import { 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';
4
4
  import { ProductPriceRepresentation as types_ProductPriceRepresentation_ProductPriceRepresentation } from '../types/ProductPriceRepresentation';
5
5
  export declare const adapterName = "getProductPrice";
6
+ export declare const getProductPrice_ConfigPropertyMetadata: $64$luvio_engine_AdapterConfigMetadata[];
6
7
  export declare const getProductPrice_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
7
8
  export interface GetProductPriceConfig {
8
9
  productId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-commerce-store-pricing",
3
- "version": "1.212.1",
3
+ "version": "1.213.1",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "Wire adapters Commerce Store Pricing",
6
6
  "main": "dist/es/es2018/commerce-store-pricing.js",
package/sfdc/index.js CHANGED
@@ -14,7 +14,7 @@
14
14
  /* proxy-compat-disable */
15
15
  import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
16
16
  import { withDefaultLuvio } from 'force/ldsEngine';
17
- import { serializeStructuredKey, deepFreeze, typeCheckScalars, StoreKeyMap } from 'force/luvioEngine';
17
+ import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckScalars, StoreKeyMap } from 'force/luvioEngine';
18
18
 
19
19
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
20
  const { keys: ObjectKeys, create: ObjectCreate } = Object;
@@ -58,6 +58,24 @@ const snapshotRefreshOptions = {
58
58
  },
59
59
  }
60
60
  };
61
+ function generateParamConfigMetadata(name, required, coerceFn) {
62
+ return {
63
+ name,
64
+ required,
65
+ coerceFn,
66
+ };
67
+ }
68
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
69
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
70
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
71
+ return {
72
+ displayName,
73
+ parameters: {
74
+ required,
75
+ optional,
76
+ }
77
+ };
78
+ }
61
79
  const keyPrefix = 'Commerce';
62
80
 
63
81
  const { isArray: ArrayIsArray } = Array;
@@ -220,26 +238,8 @@ const ingest = function ProductPriceRepresentationIngest(input, path, luvio, sto
220
238
  }
221
239
  }
222
240
  const key = path.fullPath;
223
- const existingRecord = store.readEntry(key);
224
241
  const ttlToUse = path.ttl !== undefined ? path.ttl : 2592000000;
225
- let incomingRecord = normalize(input, store.readEntry(key), {
226
- fullPath: key,
227
- parent: path.parent,
228
- propertyName: path.propertyName,
229
- ttl: ttlToUse
230
- });
231
- if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
232
- luvio.storePublish(key, incomingRecord);
233
- }
234
- if (ttlToUse !== undefined) {
235
- const storeMetadataParams = {
236
- ttl: ttlToUse,
237
- namespace: "Commerce",
238
- version: VERSION,
239
- representationName: RepresentationType,
240
- };
241
- luvio.publishStoreMetadata(key, storeMetadataParams);
242
- }
242
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "Commerce", VERSION, RepresentationType, equals);
243
243
  return createLink(key);
244
244
  };
245
245
  function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
@@ -298,13 +298,13 @@ function createResourceRequest(config) {
298
298
  };
299
299
  }
300
300
 
301
- const getProductPrice_ConfigPropertyNames = {
302
- displayName: 'getProductPrice',
303
- parameters: {
304
- required: ['productId', 'webstoreId'],
305
- optional: ['effectiveAccountId']
306
- }
307
- };
301
+ const adapterName = 'getProductPrice';
302
+ const getProductPrice_ConfigPropertyMetadata = [
303
+ generateParamConfigMetadata('productId', true),
304
+ generateParamConfigMetadata('webstoreId', true),
305
+ generateParamConfigMetadata('effectiveAccountId', false),
306
+ ];
307
+ const getProductPrice_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getProductPrice_ConfigPropertyMetadata);
308
308
  function createResourceParams(config) {
309
309
  const resourceParams = {
310
310
  urlParams: {
@@ -375,21 +375,7 @@ function buildNetworkSnapshot(luvio, config, options) {
375
375
  });
376
376
  }
377
377
  function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
378
- const { luvio, config } = context;
379
- const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
380
- const dispatchOptions = {
381
- resourceRequestContext: {
382
- requestCorrelator,
383
- luvioRequestMethod: undefined,
384
- },
385
- eventObservers
386
- };
387
- if (networkPriority !== 'normal') {
388
- dispatchOptions.overrides = {
389
- priority: networkPriority
390
- };
391
- }
392
- return buildNetworkSnapshot(luvio, config, dispatchOptions);
378
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, undefined, false);
393
379
  }
394
380
  function buildCachedSnapshotCachePolicy(context, storeLookup) {
395
381
  const { luvio, config } = context;
@@ -436,4 +422,4 @@ withDefaultLuvio((luvio) => {
436
422
  });
437
423
 
438
424
  export { getProductPrice, getProductPrice_imperative };
439
- // version: 1.212.1-49679d2a7
425
+ // version: 1.213.1-79de10fe1