@aptos-scp/scp-component-store-selling-features-domain-model 1.29.0 → 1.30.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.
@@ -0,0 +1,4 @@
1
+ export interface IStoreItemSummary {
2
+ uniqueId: string;
3
+ imageUrl: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IStoreItemSummary.js.map
@@ -7,7 +7,7 @@ const scp_component_store_items_1 = require("@aptos-scp/scp-component-store-item
7
7
  const scp_component_store_selling_core_1 = require("@aptos-scp/scp-component-store-selling-core");
8
8
  const scp_types_commerce_transaction_1 = require("@aptos-scp/scp-types-commerce-transaction");
9
9
  const ErrorCodes_1 = require("../../config/ErrorCodes");
10
- const utils_1 = require("../utility/utils");
10
+ const utility_1 = require("../utility");
11
11
  const logger = scp_component_logging_1.LogManager.getLogger("com.aptos.storesellingfeatures.domain.model.StoreItem");
12
12
  var SourceType;
13
13
  (function (SourceType) {
@@ -115,7 +115,7 @@ function getProductAttributeTranslation(attribute, locale = "en") {
115
115
  if (!attribute.translations) {
116
116
  return undefined;
117
117
  }
118
- const localeToUse = utils_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
118
+ const localeToUse = utility_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
119
119
  let translation = localeToUse && attribute.translations[localeToUse];
120
120
  if (!translation) {
121
121
  const defaultLocale = "en";
@@ -128,7 +128,7 @@ function getMerchandiseHierarchyNodeNameTranslation(node, locale = "en") {
128
128
  if (!node.translations) {
129
129
  return { name: node.nodeInLevelId };
130
130
  }
131
- const localeToUse = utils_1.getLocaleCodeForTranslationSet(node.translations, locale);
131
+ const localeToUse = utility_1.getLocaleCodeForTranslationSet(node.translations, locale);
132
132
  let translation = localeToUse && node.translations[localeToUse];
133
133
  if (!translation) {
134
134
  const defaultLocale = "en";
@@ -178,7 +178,7 @@ class ColorAttribute {
178
178
  constructor(attribute, locale) {
179
179
  this.id = attribute.id;
180
180
  this.code = attribute.code;
181
- const localeCodeToUse = attribute.translations && utils_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
181
+ const localeCodeToUse = attribute.translations && utility_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
182
182
  const translations = localeCodeToUse && attribute.translations[localeCodeToUse];
183
183
  if (translations) {
184
184
  this.name = translations.name;
@@ -194,7 +194,7 @@ class StyleAttribute {
194
194
  constructor(attribute, locale) {
195
195
  this.id = attribute.id;
196
196
  this.code = attribute.code;
197
- const localeCodeToUse = attribute.translations && utils_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
197
+ const localeCodeToUse = attribute.translations && utility_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
198
198
  const translations = localeCodeToUse && attribute.translations[localeCodeToUse];
199
199
  if (translations) {
200
200
  this.name = translations.name;
@@ -211,7 +211,7 @@ class SizeAttribute {
211
211
  this.id = attribute.id;
212
212
  this.code = attribute.code;
213
213
  this.subcode = attribute.subcode;
214
- const localeCodeToUse = attribute.translations && utils_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
214
+ const localeCodeToUse = attribute.translations && utility_1.getLocaleCodeForTranslationSet(attribute.translations, locale);
215
215
  const translations = localeCodeToUse && attribute.translations[localeCodeToUse];
216
216
  if (translations) {
217
217
  this.name = translations.name;
@@ -355,30 +355,9 @@ class StoreItem {
355
355
  storeItem.itemType = item.type && findItemType(item.type);
356
356
  //sourceIndicator
357
357
  storeItem.source = sourceIndicator;
358
- // imageUrl
359
- const lineItemImageConfiguration = configurationManager.getFunctionalBehaviorValues().lineItemImage;
360
- const getImageUrl = (imageSource) => {
361
- switch (imageSource) {
362
- case "ImageFromItemData":
363
- let imageUrl = undefined;
364
- if (item.images && item.images.length > 0) {
365
- const primaryImages = item.images.filter((x) => x.primaryImage === true);
366
- imageUrl = (primaryImages.length > 0 ? primaryImages : item.images)[0].imageUrl;
367
- }
368
- return imageUrl;
369
- case "ImageFromUrlPattern":
370
- let urlPattern = lineItemImageConfiguration.urlPattern;
371
- const aSkuKey = item.lookupKeys.find((aKey) => aKey.keyType === scp_component_store_items_1.KeyType.SKU);
372
- if (aSkuKey) {
373
- urlPattern = urlPattern.replace(/{{SKU}}/g, aSkuKey.value);
374
- }
375
- return urlPattern;
376
- default:
377
- return undefined;
378
- }
379
- };
380
- storeItem.imageUrl = getImageUrl(lineItemImageConfiguration.imageSource);
381
- if (lineItemImageConfiguration.imageSource === "ImageFromItemData" &&
358
+ storeItem.imageUrl = utility_1.getImageUrlForItem(configurationManager, item);
359
+ if (configurationManager.getFunctionalBehaviorValues().lineItemImage.imageSource ===
360
+ "ImageFromItemData" &&
382
361
  item.images &&
383
362
  item.images.length > 0) {
384
363
  storeItem.images = item.images;
@@ -698,7 +677,7 @@ class StoreItem {
698
677
  static updateLocalizableTextsFromItemAttributeObject(storeItem, sourceItem, locale) {
699
678
  let useDefaultValues = true;
700
679
  if (!!locale && locale !== sourceItem.language && sourceItem.translations) {
701
- const localeToUse = utils_1.getLocaleCodeForTranslationSet(sourceItem.translations, locale);
680
+ const localeToUse = utility_1.getLocaleCodeForTranslationSet(sourceItem.translations, locale);
702
681
  if (localeToUse) {
703
682
  // ... language-specific values
704
683
  const itemTranslationAttribute = sourceItem.translations[localeToUse];
@@ -107,3 +107,4 @@ export * from "./lottery/";
107
107
  export * from "./ITransactionMetadataPersistanceObject";
108
108
  export * from "./IReceipt";
109
109
  export * from "./storeGoals/";
110
+ export * from "./IStoreItemSummary";
@@ -1,2 +1,3 @@
1
1
  export * from "./utils";
2
2
  export * from "./orderUtils";
3
+ export * from "./itemImageUtils";
@@ -5,4 +5,5 @@ function __export(m) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  __export(require("./utils"));
7
7
  __export(require("./orderUtils"));
8
+ __export(require("./itemImageUtils"));
8
9
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ import { IItem } from "@aptos-scp/scp-component-store-items";
2
+ import { IConfigurationManager } from "@aptos-scp/scp-component-store-selling-core";
3
+ export declare function getImageUrlForItem(configurationManager: IConfigurationManager, item: IItem): string;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const scp_component_store_items_1 = require("@aptos-scp/scp-component-store-items");
4
+ function getImageUrlForItem(configurationManager, item) {
5
+ var _a, _b;
6
+ const lineItemImageConfig = configurationManager.getFunctionalBehaviorValues().lineItemImage;
7
+ switch (lineItemImageConfig.imageSource) {
8
+ case "ImageFromItemData":
9
+ if ((_a = item.images) === null || _a === void 0 ? void 0 : _a.length) {
10
+ const primaryImages = item.images.filter((x) => x.primaryImage);
11
+ return (primaryImages.length > 0 ? primaryImages : item.images)[0].imageUrl;
12
+ }
13
+ return undefined;
14
+ case "ImageFromUrlPattern":
15
+ const urlPattern = lineItemImageConfig.urlPattern;
16
+ const aSkuKey = (_b = item.lookupKeys) === null || _b === void 0 ? void 0 : _b.find((aKey) => aKey.keyType === scp_component_store_items_1.KeyType.SKU);
17
+ if (aSkuKey) {
18
+ return urlPattern.replace(/{{SKU}}/g, aSkuKey.value);
19
+ }
20
+ return urlPattern;
21
+ default:
22
+ return undefined;
23
+ }
24
+ }
25
+ exports.getImageUrlForItem = getImageUrlForItem;
26
+ //# sourceMappingURL=itemImageUtils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-scp/scp-component-store-selling-features-domain-model",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "description": "This component library provides the common components to handle the coordination of processing the business events from the UI.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENSE.md",