@ikas/storefront 0.0.92 → 0.0.94

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.
@@ -16,4 +16,5 @@ export declare class Analytics {
16
16
  static completeRegistration(): void;
17
17
  static viewCart(cart: IkasCart | null | undefined): void;
18
18
  static viewCategory(categoryPath: string): void;
19
+ static contactForm(): void;
19
20
  }
@@ -11,4 +11,5 @@ export declare class FacebookPixel {
11
11
  static completeRegistration(): void;
12
12
  static viewCart(cart: IkasCart): void;
13
13
  static viewCategory(categoryPath: string): void;
14
+ static contactForm(): void;
14
15
  }
package/build/index.es.js CHANGED
@@ -10884,7 +10884,7 @@ var Apollo = /** @class */ (function () {
10884
10884
  this.createApolloClient = function (apiKey) {
10885
10885
  var authLink = setContext(function (_request, _a) {
10886
10886
  var headers = _a.headers;
10887
- var newHeaders = __assign(__assign({}, headers), { "x-api-key": apiKey || IkasStorefrontConfig.config.apiKey, "X-Operation-Name": _request.operationName });
10887
+ var newHeaders = __assign(__assign({}, headers), { "x-api-key": apiKey || IkasStorefrontConfig.config.apiKey });
10888
10888
  if (Apollo.customerToken) {
10889
10889
  newHeaders.Authorization = "Bearer " + Apollo.customerToken;
10890
10890
  }
@@ -10892,8 +10892,13 @@ var Apollo = /** @class */ (function () {
10892
10892
  headers: newHeaders,
10893
10893
  };
10894
10894
  });
10895
+ var customFetch = function (uri, options) {
10896
+ var operationName = JSON.parse(options.body).operationName;
10897
+ return fetch(uri + "?op=" + operationName, options);
10898
+ };
10895
10899
  var httpLink = createHttpLink({
10896
10900
  uri: IkasStorefrontConfig.apiUrlOverride || process.env.NEXT_PUBLIC_GQL_URL,
10901
+ fetch: customFetch,
10897
10902
  });
10898
10903
  _this._client = new ApolloClient({
10899
10904
  link: authLink.concat(httpLink),
@@ -13189,6 +13194,17 @@ var FacebookPixel = /** @class */ (function () {
13189
13194
  console.error(err);
13190
13195
  }
13191
13196
  };
13197
+ FacebookPixel.contactForm = function () {
13198
+ try {
13199
+ !isServer &&
13200
+ window.fbq &&
13201
+ window.fbq("track", "ContactForm", {});
13202
+ return;
13203
+ }
13204
+ catch (err) {
13205
+ console.error(err);
13206
+ }
13207
+ };
13192
13208
  return FacebookPixel;
13193
13209
  }());
13194
13210
  function productToFBPItem(productDetail, quantity) {
@@ -16851,6 +16867,14 @@ var Analytics = /** @class */ (function () {
16851
16867
  console.error(err);
16852
16868
  }
16853
16869
  };
16870
+ Analytics.contactForm = function () {
16871
+ try {
16872
+ FacebookPixel.contactForm();
16873
+ }
16874
+ catch (err) {
16875
+ console.error(err);
16876
+ }
16877
+ };
16854
16878
  return Analytics;
16855
16879
  }());
16856
16880
 
@@ -16936,7 +16960,9 @@ var IkasCustomerStore = /** @class */ (function () {
16936
16960
  this.saveContactForm = function (input) { return __awaiter(_this, void 0, void 0, function () {
16937
16961
  return __generator(this, function (_a) {
16938
16962
  switch (_a.label) {
16939
- case 0: return [4 /*yield*/, IkasContactFormAPI.sendContactFormToMerchant(input)];
16963
+ case 0:
16964
+ Analytics.contactForm();
16965
+ return [4 /*yield*/, IkasContactFormAPI.sendContactFormToMerchant(input)];
16940
16966
  case 1: return [2 /*return*/, _a.sent()];
16941
16967
  }
16942
16968
  });
@@ -17601,6 +17627,15 @@ var IkasProductVariantType = /** @class */ (function () {
17601
17627
  return IkasProductVariantType;
17602
17628
  }());
17603
17629
 
17630
+ var IkasProductTag = /** @class */ (function () {
17631
+ function IkasProductTag(data) {
17632
+ this.id = data.id || "";
17633
+ this.name = data.name || "";
17634
+ makeAutoObservable(this);
17635
+ }
17636
+ return IkasProductTag;
17637
+ }());
17638
+
17604
17639
  var IkasProduct = /** @class */ (function () {
17605
17640
  function IkasProduct(data) {
17606
17641
  if (data === void 0) { data = {}; }
@@ -17616,6 +17651,9 @@ var IkasProduct = /** @class */ (function () {
17616
17651
  this.categories = data.categories
17617
17652
  ? data.categories.map(function (c) { return new IkasCategory(c); })
17618
17653
  : [];
17654
+ this.tags = data.tags
17655
+ ? data.tags.map(function (tag) { return new IkasProductTag(tag); })
17656
+ : [];
17619
17657
  this.variants = data.variants
17620
17658
  ? data.variants.map(function (v) { return new IkasProductVariant(v); })
17621
17659
  : [];
@@ -25502,7 +25540,7 @@ var IkasProductSearchAPI = /** @class */ (function () {
25502
25540
  return IkasProductSearchAPI;
25503
25541
  }());
25504
25542
  function simpleToProduct(simple) {
25505
- var _a, _b, _c, _d, _e;
25543
+ var _a, _b, _c, _d, _e, _f;
25506
25544
  return new IkasProduct({
25507
25545
  id: simple.id,
25508
25546
  attributes: (_a = simple.attributes) === null || _a === void 0 ? void 0 : _a.map(function (a) {
@@ -25536,6 +25574,12 @@ function simpleToProduct(simple) {
25536
25574
  }),
25537
25575
  });
25538
25576
  }),
25577
+ tags: (_f = simple.tags) === null || _f === void 0 ? void 0 : _f.map(function (tag) {
25578
+ return new IkasProductTag({
25579
+ id: tag.id,
25580
+ name: tag.name,
25581
+ });
25582
+ }),
25539
25583
  description: simple.description || undefined,
25540
25584
  metaData: new IkasHTMLMetaData(simple.metaData || undefined),
25541
25585
  name: simple.name,
@@ -27495,11 +27539,9 @@ var IkasPageHead = observer(function (_a) {
27495
27539
  var categorySchema = createCategorySchema(pageSpecificDataStr);
27496
27540
  if (categorySchema)
27497
27541
  schemas.push(categorySchema);
27498
- // TODO
27499
- // const categoryBreadcrumbSchema = createCategoryBreadcrumbSchema(
27500
- // pageSpecificDataStr
27501
- // );
27502
- // if (categoryBreadcrumbSchema) schemas.push(categoryBreadcrumbSchema);
27542
+ var categoryBreadcrumbSchema = createCategoryBreadcrumbSchema(pageSpecificDataStr);
27543
+ if (categoryBreadcrumbSchema)
27544
+ schemas.push(categoryBreadcrumbSchema);
27503
27545
  }
27504
27546
  return (createElement(Head, null,
27505
27547
  createElement("title", null, pageTitle || ""),
@@ -27552,12 +27594,16 @@ function createProductSchema(productDetail) {
27552
27594
  }
27553
27595
  }
27554
27596
  }
27597
+ var productUrl = isBrowser
27598
+ ? "https://" + window.location.hostname + productDetail.href
27599
+ : "";
27555
27600
  return {
27556
27601
  "@context": "https://schema.org/",
27557
27602
  "@type": "Product",
27558
27603
  name: productDetail.product.name,
27559
27604
  description: (_a = productDetail.product.metaData) === null || _a === void 0 ? void 0 : _a.description,
27560
27605
  image: productDetail.selectedVariant.images.map(function (i) { return i.src; }),
27606
+ productId: productDetail.selectedVariant.id,
27561
27607
  sku: productDetail.selectedVariant.sku,
27562
27608
  mpn: productDetail.selectedVariant.barcodeList.length
27563
27609
  ? productDetail.selectedVariant.barcodeList[0]
@@ -27568,7 +27614,7 @@ function createProductSchema(productDetail) {
27568
27614
  },
27569
27615
  offers: {
27570
27616
  "@type": "Offer",
27571
- url: "https://" + window.location.hostname + productDetail.href,
27617
+ url: productUrl,
27572
27618
  priceCurrency: productDetail.selectedVariant.price.currency || "TRY",
27573
27619
  price: productDetail.selectedVariant.price.finalPrice,
27574
27620
  priceValidUntil: "",
@@ -27586,10 +27632,13 @@ function createCategorySchema(pageSpecificDataStr) {
27586
27632
  try {
27587
27633
  var categoryParsed = JSON.parse(pageSpecificDataStr);
27588
27634
  var category = new IkasCategory(categoryParsed);
27635
+ var categoryUrl = typeof window !== undefined
27636
+ ? "https://" + window.location.hostname + category.href
27637
+ : "";
27589
27638
  return {
27590
27639
  "@context": "http://schema.org",
27591
27640
  "@type": "CollectionPage",
27592
- url: "https://" + window.location.hostname + category.href,
27641
+ url: categoryUrl,
27593
27642
  name: (_a = category.metaData) === null || _a === void 0 ? void 0 : _a.pageTitle,
27594
27643
  description: (_b = category.metaData) === null || _b === void 0 ? void 0 : _b.description,
27595
27644
  image: (_c = category.image) === null || _c === void 0 ? void 0 : _c.src,
@@ -27597,26 +27646,25 @@ function createCategorySchema(pageSpecificDataStr) {
27597
27646
  }
27598
27647
  catch (_d) { }
27599
27648
  }
27600
- // TODO - Waiting for CategoryParentTree feature
27601
- // https://app.clubhouse.io/ikas/story/256/schema-org-json-lar%C4%B1n%C4%B1n-t%C3%BCm-kategori-sayfalar%C4%B1na-yerle%C5%9Ftirilmesini-istiyorum
27602
- // function createCategoryBreadcrumbSchema(pageSpecificDataStr: string) {
27603
- // try {
27604
- // const categoryParsed = JSON.parse(pageSpecificDataStr) as IkasCategory;
27605
- // const category = new IkasCategory(categoryParsed);
27606
- // return {
27607
- // "@context": "http://schema.org",
27608
- // "@type": "BreadcrumbList",
27609
- // "itemListElement": [
27610
- // {
27611
- // "@type": "ListItem",
27612
- // "position": 1,
27613
- // "name": "category.name",
27614
- // "item": "https://" + window.location.hostname + "category.href"
27615
- // }
27616
- // ]
27617
- // };
27618
- // } catch {}
27619
- // }
27649
+ function createCategoryBreadcrumbSchema(pageSpecificDataStr) {
27650
+ try {
27651
+ var categoryParsed = JSON.parse(pageSpecificDataStr);
27652
+ var category = new IkasCategory(categoryParsed);
27653
+ return {
27654
+ "@context": "http://schema.org",
27655
+ "@type": "BreadcrumbList",
27656
+ itemListElement: category.path.map(function (categoryPath, index) { return ({
27657
+ "@type": "ListItem",
27658
+ position: index + 1,
27659
+ name: categoryPath.name,
27660
+ item: typeof window !== undefined
27661
+ ? "https://" + window.location.hostname + categoryPath.href
27662
+ : "",
27663
+ }); }),
27664
+ };
27665
+ }
27666
+ catch (_a) { }
27667
+ }
27620
27668
 
27621
27669
  var IkasCheckoutPage = observer(function (_a) {
27622
27670
  var _b, _c, _d;
package/build/index.js CHANGED
@@ -10898,7 +10898,7 @@ var Apollo = /** @class */ (function () {
10898
10898
  this.createApolloClient = function (apiKey) {
10899
10899
  var authLink = setContext(function (_request, _a) {
10900
10900
  var headers = _a.headers;
10901
- var newHeaders = __assign(__assign({}, headers), { "x-api-key": apiKey || IkasStorefrontConfig.config.apiKey, "X-Operation-Name": _request.operationName });
10901
+ var newHeaders = __assign(__assign({}, headers), { "x-api-key": apiKey || IkasStorefrontConfig.config.apiKey });
10902
10902
  if (Apollo.customerToken) {
10903
10903
  newHeaders.Authorization = "Bearer " + Apollo.customerToken;
10904
10904
  }
@@ -10906,8 +10906,13 @@ var Apollo = /** @class */ (function () {
10906
10906
  headers: newHeaders,
10907
10907
  };
10908
10908
  });
10909
+ var customFetch = function (uri, options) {
10910
+ var operationName = JSON.parse(options.body).operationName;
10911
+ return fetch(uri + "?op=" + operationName, options);
10912
+ };
10909
10913
  var httpLink = createHttpLink({
10910
10914
  uri: IkasStorefrontConfig.apiUrlOverride || process.env.NEXT_PUBLIC_GQL_URL,
10915
+ fetch: customFetch,
10911
10916
  });
10912
10917
  _this._client = new ApolloClient({
10913
10918
  link: authLink.concat(httpLink),
@@ -13194,6 +13199,17 @@ var FacebookPixel = /** @class */ (function () {
13194
13199
  console.error(err);
13195
13200
  }
13196
13201
  };
13202
+ FacebookPixel.contactForm = function () {
13203
+ try {
13204
+ !isServer &&
13205
+ window.fbq &&
13206
+ window.fbq("track", "ContactForm", {});
13207
+ return;
13208
+ }
13209
+ catch (err) {
13210
+ console.error(err);
13211
+ }
13212
+ };
13197
13213
  return FacebookPixel;
13198
13214
  }());
13199
13215
  function productToFBPItem(productDetail, quantity) {
@@ -16856,6 +16872,14 @@ var Analytics = /** @class */ (function () {
16856
16872
  console.error(err);
16857
16873
  }
16858
16874
  };
16875
+ Analytics.contactForm = function () {
16876
+ try {
16877
+ FacebookPixel.contactForm();
16878
+ }
16879
+ catch (err) {
16880
+ console.error(err);
16881
+ }
16882
+ };
16859
16883
  return Analytics;
16860
16884
  }());
16861
16885
 
@@ -16941,7 +16965,9 @@ var IkasCustomerStore = /** @class */ (function () {
16941
16965
  this.saveContactForm = function (input) { return __awaiter(_this, void 0, void 0, function () {
16942
16966
  return __generator(this, function (_a) {
16943
16967
  switch (_a.label) {
16944
- case 0: return [4 /*yield*/, IkasContactFormAPI.sendContactFormToMerchant(input)];
16968
+ case 0:
16969
+ Analytics.contactForm();
16970
+ return [4 /*yield*/, IkasContactFormAPI.sendContactFormToMerchant(input)];
16945
16971
  case 1: return [2 /*return*/, _a.sent()];
16946
16972
  }
16947
16973
  });
@@ -17597,6 +17623,15 @@ var IkasProductVariantType = /** @class */ (function () {
17597
17623
  return IkasProductVariantType;
17598
17624
  }());
17599
17625
 
17626
+ var IkasProductTag = /** @class */ (function () {
17627
+ function IkasProductTag(data) {
17628
+ this.id = data.id || "";
17629
+ this.name = data.name || "";
17630
+ mobx.makeAutoObservable(this);
17631
+ }
17632
+ return IkasProductTag;
17633
+ }());
17634
+
17600
17635
  var IkasProduct = /** @class */ (function () {
17601
17636
  function IkasProduct(data) {
17602
17637
  if (data === void 0) { data = {}; }
@@ -17612,6 +17647,9 @@ var IkasProduct = /** @class */ (function () {
17612
17647
  this.categories = data.categories
17613
17648
  ? data.categories.map(function (c) { return new IkasCategory(c); })
17614
17649
  : [];
17650
+ this.tags = data.tags
17651
+ ? data.tags.map(function (tag) { return new IkasProductTag(tag); })
17652
+ : [];
17615
17653
  this.variants = data.variants
17616
17654
  ? data.variants.map(function (v) { return new IkasProductVariant(v); })
17617
17655
  : [];
@@ -25481,7 +25519,7 @@ var IkasProductSearchAPI = /** @class */ (function () {
25481
25519
  return IkasProductSearchAPI;
25482
25520
  }());
25483
25521
  function simpleToProduct(simple) {
25484
- var _a, _b, _c, _d, _e;
25522
+ var _a, _b, _c, _d, _e, _f;
25485
25523
  return new IkasProduct({
25486
25524
  id: simple.id,
25487
25525
  attributes: (_a = simple.attributes) === null || _a === void 0 ? void 0 : _a.map(function (a) {
@@ -25515,6 +25553,12 @@ function simpleToProduct(simple) {
25515
25553
  }),
25516
25554
  });
25517
25555
  }),
25556
+ tags: (_f = simple.tags) === null || _f === void 0 ? void 0 : _f.map(function (tag) {
25557
+ return new IkasProductTag({
25558
+ id: tag.id,
25559
+ name: tag.name,
25560
+ });
25561
+ }),
25518
25562
  description: simple.description || undefined,
25519
25563
  metaData: new IkasHTMLMetaData(simple.metaData || undefined),
25520
25564
  name: simple.name,
@@ -27474,11 +27518,9 @@ var IkasPageHead = mobxReactLite.observer(function (_a) {
27474
27518
  var categorySchema = createCategorySchema(pageSpecificDataStr);
27475
27519
  if (categorySchema)
27476
27520
  schemas.push(categorySchema);
27477
- // TODO
27478
- // const categoryBreadcrumbSchema = createCategoryBreadcrumbSchema(
27479
- // pageSpecificDataStr
27480
- // );
27481
- // if (categoryBreadcrumbSchema) schemas.push(categoryBreadcrumbSchema);
27521
+ var categoryBreadcrumbSchema = createCategoryBreadcrumbSchema(pageSpecificDataStr);
27522
+ if (categoryBreadcrumbSchema)
27523
+ schemas.push(categoryBreadcrumbSchema);
27482
27524
  }
27483
27525
  return (React.createElement(Head__default['default'], null,
27484
27526
  React.createElement("title", null, pageTitle || ""),
@@ -27531,12 +27573,16 @@ function createProductSchema(productDetail) {
27531
27573
  }
27532
27574
  }
27533
27575
  }
27576
+ var productUrl = isBrowser
27577
+ ? "https://" + window.location.hostname + productDetail.href
27578
+ : "";
27534
27579
  return {
27535
27580
  "@context": "https://schema.org/",
27536
27581
  "@type": "Product",
27537
27582
  name: productDetail.product.name,
27538
27583
  description: (_a = productDetail.product.metaData) === null || _a === void 0 ? void 0 : _a.description,
27539
27584
  image: productDetail.selectedVariant.images.map(function (i) { return i.src; }),
27585
+ productId: productDetail.selectedVariant.id,
27540
27586
  sku: productDetail.selectedVariant.sku,
27541
27587
  mpn: productDetail.selectedVariant.barcodeList.length
27542
27588
  ? productDetail.selectedVariant.barcodeList[0]
@@ -27547,7 +27593,7 @@ function createProductSchema(productDetail) {
27547
27593
  },
27548
27594
  offers: {
27549
27595
  "@type": "Offer",
27550
- url: "https://" + window.location.hostname + productDetail.href,
27596
+ url: productUrl,
27551
27597
  priceCurrency: productDetail.selectedVariant.price.currency || "TRY",
27552
27598
  price: productDetail.selectedVariant.price.finalPrice,
27553
27599
  priceValidUntil: "",
@@ -27565,10 +27611,13 @@ function createCategorySchema(pageSpecificDataStr) {
27565
27611
  try {
27566
27612
  var categoryParsed = JSON.parse(pageSpecificDataStr);
27567
27613
  var category = new IkasCategory(categoryParsed);
27614
+ var categoryUrl = typeof window !== undefined
27615
+ ? "https://" + window.location.hostname + category.href
27616
+ : "";
27568
27617
  return {
27569
27618
  "@context": "http://schema.org",
27570
27619
  "@type": "CollectionPage",
27571
- url: "https://" + window.location.hostname + category.href,
27620
+ url: categoryUrl,
27572
27621
  name: (_a = category.metaData) === null || _a === void 0 ? void 0 : _a.pageTitle,
27573
27622
  description: (_b = category.metaData) === null || _b === void 0 ? void 0 : _b.description,
27574
27623
  image: (_c = category.image) === null || _c === void 0 ? void 0 : _c.src,
@@ -27576,26 +27625,25 @@ function createCategorySchema(pageSpecificDataStr) {
27576
27625
  }
27577
27626
  catch (_d) { }
27578
27627
  }
27579
- // TODO - Waiting for CategoryParentTree feature
27580
- // https://app.clubhouse.io/ikas/story/256/schema-org-json-lar%C4%B1n%C4%B1n-t%C3%BCm-kategori-sayfalar%C4%B1na-yerle%C5%9Ftirilmesini-istiyorum
27581
- // function createCategoryBreadcrumbSchema(pageSpecificDataStr: string) {
27582
- // try {
27583
- // const categoryParsed = JSON.parse(pageSpecificDataStr) as IkasCategory;
27584
- // const category = new IkasCategory(categoryParsed);
27585
- // return {
27586
- // "@context": "http://schema.org",
27587
- // "@type": "BreadcrumbList",
27588
- // "itemListElement": [
27589
- // {
27590
- // "@type": "ListItem",
27591
- // "position": 1,
27592
- // "name": "category.name",
27593
- // "item": "https://" + window.location.hostname + "category.href"
27594
- // }
27595
- // ]
27596
- // };
27597
- // } catch {}
27598
- // }
27628
+ function createCategoryBreadcrumbSchema(pageSpecificDataStr) {
27629
+ try {
27630
+ var categoryParsed = JSON.parse(pageSpecificDataStr);
27631
+ var category = new IkasCategory(categoryParsed);
27632
+ return {
27633
+ "@context": "http://schema.org",
27634
+ "@type": "BreadcrumbList",
27635
+ itemListElement: category.path.map(function (categoryPath, index) { return ({
27636
+ "@type": "ListItem",
27637
+ position: index + 1,
27638
+ name: categoryPath.name,
27639
+ item: typeof window !== undefined
27640
+ ? "https://" + window.location.hostname + categoryPath.href
27641
+ : "",
27642
+ }); }),
27643
+ };
27644
+ }
27645
+ catch (_a) { }
27646
+ }
27599
27647
 
27600
27648
  var IkasCheckoutPage = mobxReactLite.observer(function (_a) {
27601
27649
  var _b, _c, _d;
@@ -4,6 +4,7 @@ import { IkasProductAttributeValue } from "./attribute-value/index";
4
4
  import { IkasProductVariantType } from "./variant-type/index";
5
5
  import { IkasBrand } from "../brand/index";
6
6
  import { IkasHTMLMetaData } from "../html-meta-data/index";
7
+ import { IkasProductTag } from "../product-tag/index";
7
8
  export declare class IkasProduct {
8
9
  id: string;
9
10
  name: string;
@@ -13,6 +14,7 @@ export declare class IkasProduct {
13
14
  metaData?: IkasHTMLMetaData;
14
15
  brand: IkasBrand | null;
15
16
  categories: IkasCategory[];
17
+ tags: IkasProductTag[] | null;
16
18
  variants: IkasProductVariant[];
17
19
  attributes: IkasProductAttributeValue[];
18
20
  variantTypes: IkasProductVariantType[];
@@ -0,0 +1,5 @@
1
+ export declare class IkasProductTag {
2
+ id: string;
3
+ name: string;
4
+ constructor(data: Partial<IkasProductTag>);
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.92",
3
+ "version": "0.0.94",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",