@snabcentr/client-core 3.22.0 → 3.23.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.
@@ -1748,6 +1748,7 @@ class ScProduct extends ScCatalogItem {
1748
1748
  else {
1749
1749
  this.image = data.images?.find((img) => img.isDefault)?.image ?? data.properties?.image;
1750
1750
  this.supplierSku = data.supplierSku;
1751
+ this.brand = data.brand;
1751
1752
  this.cost = data.cost;
1752
1753
  this.costRub = data.costRub;
1753
1754
  this.costDate = data.costDate;
@@ -7948,7 +7949,6 @@ class SchemaOrgFactory {
7948
7949
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
7949
7950
  const image = this.mediaImageTransformerPipe.transform(product?.getImagePreview?.() ?? product.image, true);
7950
7951
  const description = product.properties?.description;
7951
- const priceValidUntil = this.normalizePriceValidUntil(product.discount?.expiredAt);
7952
7952
  return {
7953
7953
  '@context': 'https://schema.org',
7954
7954
  '@type': 'Product',
@@ -7956,21 +7956,16 @@ class SchemaOrgFactory {
7956
7956
  name: product.name,
7957
7957
  ...(image && { image }),
7958
7958
  ...(description && { description: this.stripHtml(description) }),
7959
- mpn: product.code,
7960
- url: productUrl,
7961
- offers: {
7962
- '@type': 'Offer',
7963
- priceCurrency: 'RUB',
7964
- ...(priceValidUntil && { priceValidUntil }),
7965
- price: product.costRub,
7966
- availability: this.getAvailability(product),
7967
- itemCondition: 'https://schema.org/NewCondition',
7968
- seller: {
7969
- '@type': 'Organization',
7970
- name: this.companyInfo.name,
7959
+ sku: product.code,
7960
+ ...(product.supplierSku && { mpn: product.supplierSku }),
7961
+ ...(product.brand && {
7962
+ brand: {
7963
+ '@type': 'Brand',
7964
+ name: product.brand,
7971
7965
  },
7972
- url: productUrl,
7973
- },
7966
+ }),
7967
+ url: productUrl,
7968
+ offers: this.createOffer(product, productUrl),
7974
7969
  };
7975
7970
  }
7976
7971
  /**
@@ -8054,6 +8049,7 @@ class SchemaOrgFactory {
8054
8049
  // eslint-disable-next-line sonarjs/function-return-type
8055
8050
  generateForOrganization() {
8056
8051
  const postalAddress = this.createPostalAddress(this.companyInfo.address);
8052
+ const merchantReturnPolicy = this.createMerchantReturnPolicy();
8057
8053
  return {
8058
8054
  '@context': 'https://schema.org',
8059
8055
  '@type': 'OnlineStore',
@@ -8083,6 +8079,13 @@ class SchemaOrgFactory {
8083
8079
  address: warehouseAddress,
8084
8080
  })),
8085
8081
  }),
8082
+ ...(merchantReturnPolicy && {
8083
+ // Тип возмещения Google принимает только в политике организации, в предложениях его нет.
8084
+ hasMerchantReturnPolicy: {
8085
+ ...merchantReturnPolicy,
8086
+ refundType: 'https://schema.org/FullRefund',
8087
+ },
8088
+ }),
8086
8089
  };
8087
8090
  }
8088
8091
  /**
@@ -8218,6 +8221,22 @@ class SchemaOrgFactory {
8218
8221
  }
8219
8222
  return contactPoints;
8220
8223
  }
8224
+ /**
8225
+ * Формирует MerchantReturnPolicy по условиям возврата из данных о компании.
8226
+ */
8227
+ createMerchantReturnPolicy() {
8228
+ if (!this.companyInfo.returnPolicy) {
8229
+ return undefined;
8230
+ }
8231
+ return {
8232
+ '@type': 'MerchantReturnPolicy',
8233
+ applicableCountry: 'RU',
8234
+ returnPolicyCategory: 'https://schema.org/MerchantReturnFiniteReturnWindow',
8235
+ merchantReturnDays: this.companyInfo.returnPolicy.returnDays,
8236
+ returnMethod: 'https://schema.org/ReturnInStore',
8237
+ returnFees: 'https://schema.org/FreeReturn',
8238
+ };
8239
+ }
8221
8240
  /**
8222
8241
  * Удаляет HTML-разметку из текста.
8223
8242
  *
@@ -8311,6 +8330,30 @@ class SchemaOrgFactory {
8311
8330
  const path = categoryPath.replace(':id', id);
8312
8331
  return `${this.urls.siteUrl}${path}`;
8313
8332
  }
8333
+ /**
8334
+ * Создаёт Offer о продаже товара.
8335
+ *
8336
+ * @param product Данные о продукте.
8337
+ * @param productUrl Полный URL страницы товара.
8338
+ */
8339
+ createOffer(product, productUrl) {
8340
+ const priceValidUntil = this.normalizePriceValidUntil(product.discount?.expiredAt);
8341
+ const merchantReturnPolicy = this.createMerchantReturnPolicy();
8342
+ return {
8343
+ '@type': 'Offer',
8344
+ priceCurrency: 'RUB',
8345
+ ...(priceValidUntil && { priceValidUntil }),
8346
+ price: product.costRub,
8347
+ availability: this.getAvailability(product),
8348
+ itemCondition: 'https://schema.org/NewCondition',
8349
+ seller: {
8350
+ '@type': 'Organization',
8351
+ name: this.companyInfo.name,
8352
+ },
8353
+ url: productUrl,
8354
+ ...(merchantReturnPolicy && { hasMerchantReturnPolicy: merchantReturnPolicy }),
8355
+ };
8356
+ }
8314
8357
  /**
8315
8358
  * Создаёт элемент списка ItemList с кратким Product для страницы категории.
8316
8359
  *
@@ -8323,7 +8366,6 @@ class SchemaOrgFactory {
8323
8366
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
8324
8367
  const image = this.mediaImageTransformerPipe.transform(product?.getImagePreview?.() ?? product.image, true);
8325
8368
  const description = product.seo?.description ?? product.properties?.description;
8326
- const priceValidUntil = this.normalizePriceValidUntil(product.discount?.expiredAt);
8327
8369
  return {
8328
8370
  '@type': 'ListItem',
8329
8371
  position,
@@ -8333,19 +8375,7 @@ class SchemaOrgFactory {
8333
8375
  url: productUrl,
8334
8376
  ...(image && { image }),
8335
8377
  ...(description && { description: this.stripHtml(description) }),
8336
- offers: {
8337
- '@type': 'Offer',
8338
- priceCurrency: 'RUB',
8339
- ...(priceValidUntil && { priceValidUntil }),
8340
- price: product.costRub,
8341
- availability: this.getAvailability(product),
8342
- itemCondition: 'https://schema.org/NewCondition',
8343
- seller: {
8344
- '@type': 'Organization',
8345
- name: this.companyInfo.name,
8346
- },
8347
- url: productUrl,
8348
- },
8378
+ offers: this.createOffer(product, productUrl),
8349
8379
  },
8350
8380
  };
8351
8381
  }