@ikas/storefront 0.0.98 → 0.0.100

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.
package/build/index.es.js CHANGED
@@ -28275,7 +28275,9 @@ var IkasStorefrontThemeLocalization = /** @class */ (function () {
28275
28275
  this.locale = data.locale || "";
28276
28276
  this.storefrontId = data.storefrontId || "";
28277
28277
  this.storefrontThemeId = data.storefrontThemeId || "";
28278
- this.themeJson = data.themeJson || "";
28278
+ this.themeJson = data.themeJson
28279
+ ? new IkasTheme(data.themeJson)
28280
+ : new IkasTheme();
28279
28281
  this.privacyPolicy = data.privacyPolicy || null;
28280
28282
  this.returnPolicy = data.returnPolicy || null;
28281
28283
  this.termsOfService = data.termsOfService || null;
@@ -28362,7 +28364,7 @@ var SettingsHelper = /** @class */ (function () {
28362
28364
  SettingsHelper.getSettings = function (locale) {
28363
28365
  var _this = this;
28364
28366
  return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
28365
- var settings, storefront, salesChannel, localizationMap, themeJSONPath, routing;
28367
+ var settings, storefront, salesChannel, localizationMap, themeLocalizationPath, routing;
28366
28368
  return __generator(this, function (_a) {
28367
28369
  switch (_a.label) {
28368
28370
  case 0: return [4 /*yield*/, SettingsHelper.readSettingsFile()];
@@ -28373,24 +28375,24 @@ var SettingsHelper = /** @class */ (function () {
28373
28375
  storefront = new IkasStorefront(settings.storefront);
28374
28376
  salesChannel = new IkasSalesChannel(settings.salesChannel);
28375
28377
  localizationMap = settings.localizationMap;
28376
- themeJSONPath = localizationMap[locale];
28378
+ themeLocalizationPath = localizationMap[locale];
28377
28379
  routing = storefront.routings.find(function (r) { return r.id === locale || r.path === locale; });
28378
- if (!themeJSONPath || !routing) {
28379
- console.error("THEMEJSONPATH OR ROUTING MISSING!!!");
28380
+ if (!themeLocalizationPath || !routing) {
28381
+ console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!");
28380
28382
  return [2 /*return*/, resolve(null)];
28381
28383
  }
28382
- fs.readFile(themeJSONPath, {
28384
+ fs.readFile(themeLocalizationPath, {
28383
28385
  flag: "a+",
28384
28386
  }, function (err, file) {
28385
28387
  if (err) {
28386
- console.error("THEMEJSON FILE RED ERROR!!!");
28388
+ console.error("THEME LOCALZIATION FILE READ ERROR!!!");
28387
28389
  console.error(err);
28388
28390
  return resolve(null);
28389
28391
  }
28390
28392
  var result = file.length ? JSON.parse(file.toString()) : {};
28391
28393
  resolve({
28392
28394
  storefront: storefront,
28393
- theme: new IkasTheme(result),
28395
+ themeLocalization: new IkasStorefrontThemeLocalization(result),
28394
28396
  salesChannel: salesChannel,
28395
28397
  routing: routing,
28396
28398
  });
@@ -28403,7 +28405,7 @@ var SettingsHelper = /** @class */ (function () {
28403
28405
  SettingsHelper.getPageData = function (context, isServer, pageType) {
28404
28406
  var _a;
28405
28407
  return __awaiter(this, void 0, void 0, function () {
28406
- var locale, settings, storefront, theme, salesChannel, routing, provider;
28408
+ var locale, settings, storefront, themeLocalization, salesChannel, routing, provider;
28407
28409
  return __generator(this, function (_b) {
28408
28410
  switch (_b.label) {
28409
28411
  case 0:
@@ -28419,14 +28421,14 @@ var SettingsHelper = /** @class */ (function () {
28419
28421
  notFound: true,
28420
28422
  }];
28421
28423
  }
28422
- storefront = settings.storefront, theme = settings.theme, salesChannel = settings.salesChannel, routing = settings.routing;
28424
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, salesChannel = settings.salesChannel, routing = settings.routing;
28423
28425
  IkasStorefrontConfig.storefrontId = storefront.id;
28424
28426
  IkasStorefrontConfig.storefrontRoutingId = routing.id;
28425
28427
  IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28426
28428
  IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28427
28429
  IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
28428
28430
  IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
28429
- provider = new IkasPageDataProvider(theme, context.params, pageType);
28431
+ provider = new IkasPageDataProvider(themeLocalization.themeJson, context.params, pageType);
28430
28432
  return [4 /*yield*/, provider.getPageData()];
28431
28433
  case 2:
28432
28434
  _b.sent();
@@ -28633,10 +28635,10 @@ var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, voi
28633
28635
  allSettings = (_a.sent());
28634
28636
  customPagePaths = [];
28635
28637
  allSettings.forEach(function (_a) {
28636
- var theme = _a.theme, routing = _a.routing;
28637
- if (!theme)
28638
+ var themeLocalization = _a.themeLocalization, routing = _a.routing;
28639
+ if (!themeLocalization)
28638
28640
  return;
28639
- var customPages = theme.pages.filter(function (p) { return p.type === IkasThemePageType.CUSTOM; });
28641
+ var customPages = themeLocalization.themeJson.pages.filter(function (p) { return p.type === IkasThemePageType.CUSTOM; });
28640
28642
  customPages.forEach(function (customPage) {
28641
28643
  if (customPage.slug &&
28642
28644
  !customPagePaths.some(function (p) { return p.params.slug === customPage.slug; })) {
@@ -28681,7 +28683,7 @@ var CheckoutPage = function (_a) {
28681
28683
  };
28682
28684
  var _id_ = observer(CheckoutPage);
28683
28685
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28684
- var id, locale, settings, storefront, routing, redirect, checkout, region;
28686
+ var id, locale, settings, storefront, themeLocalization, routing, redirect, checkout;
28685
28687
  return __generator(this, function (_a) {
28686
28688
  switch (_a.label) {
28687
28689
  case 0:
@@ -28693,19 +28695,17 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
28693
28695
  // TODO maybe remove this and convert this page to static
28694
28696
  if (!settings ||
28695
28697
  !settings.storefront.mainStorefrontThemeId ||
28696
- !settings.storefront.salesChannelId ||
28697
- !settings.routing.priceListId) {
28698
+ !settings.storefront.salesChannelId) {
28698
28699
  return [2 /*return*/, {
28699
28700
  props: {},
28700
28701
  notFound: true,
28701
28702
  }];
28702
28703
  }
28703
- storefront = settings.storefront, routing = settings.routing;
28704
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, routing = settings.routing;
28704
28705
  IkasStorefrontConfig.storefrontId = storefront.id;
28705
28706
  IkasStorefrontConfig.storefrontRoutingId = routing.id;
28706
28707
  IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28707
28708
  IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28708
- IkasStorefrontConfig.priceListId = routing.priceListId;
28709
28709
  redirect = function () {
28710
28710
  context.res.writeHead(302, { Location: "/" });
28711
28711
  context.res.end();
@@ -28718,13 +28718,12 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
28718
28718
  case 2:
28719
28719
  checkout = _a.sent();
28720
28720
  if (checkout) {
28721
- region = settings.storefront.regions.find(function (r) { return r.id === storefront.mainStorefrontThemeId; });
28722
28721
  return [2 /*return*/, {
28723
28722
  props: {
28724
28723
  checkoutStr: JSON.stringify(checkout),
28725
- returnPolicy: (region === null || region === void 0 ? void 0 : region.returnPolicy) || "",
28726
- privacyPolicy: (region === null || region === void 0 ? void 0 : region.privacyPolicy) || "",
28727
- termsOfService: (region === null || region === void 0 ? void 0 : region.termsOfService) || "",
28724
+ returnPolicy: themeLocalization.returnPolicy || "",
28725
+ privacyPolicy: themeLocalization.privacyPolicy || "",
28726
+ termsOfService: themeLocalization.termsOfService || "",
28728
28727
  queryParams: context.query,
28729
28728
  },
28730
28729
  }];
package/build/index.js CHANGED
@@ -28255,7 +28255,9 @@ var IkasStorefrontThemeLocalization = /** @class */ (function () {
28255
28255
  this.locale = data.locale || "";
28256
28256
  this.storefrontId = data.storefrontId || "";
28257
28257
  this.storefrontThemeId = data.storefrontThemeId || "";
28258
- this.themeJson = data.themeJson || "";
28258
+ this.themeJson = data.themeJson
28259
+ ? new IkasTheme(data.themeJson)
28260
+ : new IkasTheme();
28259
28261
  this.privacyPolicy = data.privacyPolicy || null;
28260
28262
  this.returnPolicy = data.returnPolicy || null;
28261
28263
  this.termsOfService = data.termsOfService || null;
@@ -28342,7 +28344,7 @@ var SettingsHelper = /** @class */ (function () {
28342
28344
  SettingsHelper.getSettings = function (locale) {
28343
28345
  var _this = this;
28344
28346
  return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
28345
- var settings, storefront, salesChannel, localizationMap, themeJSONPath, routing;
28347
+ var settings, storefront, salesChannel, localizationMap, themeLocalizationPath, routing;
28346
28348
  return __generator(this, function (_a) {
28347
28349
  switch (_a.label) {
28348
28350
  case 0: return [4 /*yield*/, SettingsHelper.readSettingsFile()];
@@ -28353,24 +28355,24 @@ var SettingsHelper = /** @class */ (function () {
28353
28355
  storefront = new IkasStorefront(settings.storefront);
28354
28356
  salesChannel = new IkasSalesChannel(settings.salesChannel);
28355
28357
  localizationMap = settings.localizationMap;
28356
- themeJSONPath = localizationMap[locale];
28358
+ themeLocalizationPath = localizationMap[locale];
28357
28359
  routing = storefront.routings.find(function (r) { return r.id === locale || r.path === locale; });
28358
- if (!themeJSONPath || !routing) {
28359
- console.error("THEMEJSONPATH OR ROUTING MISSING!!!");
28360
+ if (!themeLocalizationPath || !routing) {
28361
+ console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!");
28360
28362
  return [2 /*return*/, resolve(null)];
28361
28363
  }
28362
- fs__default['default'].readFile(themeJSONPath, {
28364
+ fs__default['default'].readFile(themeLocalizationPath, {
28363
28365
  flag: "a+",
28364
28366
  }, function (err, file) {
28365
28367
  if (err) {
28366
- console.error("THEMEJSON FILE RED ERROR!!!");
28368
+ console.error("THEME LOCALZIATION FILE READ ERROR!!!");
28367
28369
  console.error(err);
28368
28370
  return resolve(null);
28369
28371
  }
28370
28372
  var result = file.length ? JSON.parse(file.toString()) : {};
28371
28373
  resolve({
28372
28374
  storefront: storefront,
28373
- theme: new IkasTheme(result),
28375
+ themeLocalization: new IkasStorefrontThemeLocalization(result),
28374
28376
  salesChannel: salesChannel,
28375
28377
  routing: routing,
28376
28378
  });
@@ -28383,7 +28385,7 @@ var SettingsHelper = /** @class */ (function () {
28383
28385
  SettingsHelper.getPageData = function (context, isServer, pageType) {
28384
28386
  var _a;
28385
28387
  return __awaiter(this, void 0, void 0, function () {
28386
- var locale, settings, storefront, theme, salesChannel, routing, provider;
28388
+ var locale, settings, storefront, themeLocalization, salesChannel, routing, provider;
28387
28389
  return __generator(this, function (_b) {
28388
28390
  switch (_b.label) {
28389
28391
  case 0:
@@ -28399,14 +28401,14 @@ var SettingsHelper = /** @class */ (function () {
28399
28401
  notFound: true,
28400
28402
  }];
28401
28403
  }
28402
- storefront = settings.storefront, theme = settings.theme, salesChannel = settings.salesChannel, routing = settings.routing;
28404
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, salesChannel = settings.salesChannel, routing = settings.routing;
28403
28405
  IkasStorefrontConfig.storefrontId = storefront.id;
28404
28406
  IkasStorefrontConfig.storefrontRoutingId = routing.id;
28405
28407
  IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28406
28408
  IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28407
28409
  IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
28408
28410
  IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
28409
- provider = new IkasPageDataProvider(theme, context.params, pageType);
28411
+ provider = new IkasPageDataProvider(themeLocalization.themeJson, context.params, pageType);
28410
28412
  return [4 /*yield*/, provider.getPageData()];
28411
28413
  case 2:
28412
28414
  _b.sent();
@@ -28613,10 +28615,10 @@ var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, voi
28613
28615
  allSettings = (_a.sent());
28614
28616
  customPagePaths = [];
28615
28617
  allSettings.forEach(function (_a) {
28616
- var theme = _a.theme, routing = _a.routing;
28617
- if (!theme)
28618
+ var themeLocalization = _a.themeLocalization, routing = _a.routing;
28619
+ if (!themeLocalization)
28618
28620
  return;
28619
- var customPages = theme.pages.filter(function (p) { return p.type === exports.IkasThemePageType.CUSTOM; });
28621
+ var customPages = themeLocalization.themeJson.pages.filter(function (p) { return p.type === exports.IkasThemePageType.CUSTOM; });
28620
28622
  customPages.forEach(function (customPage) {
28621
28623
  if (customPage.slug &&
28622
28624
  !customPagePaths.some(function (p) { return p.params.slug === customPage.slug; })) {
@@ -28661,7 +28663,7 @@ var CheckoutPage = function (_a) {
28661
28663
  };
28662
28664
  var _id_ = mobxReactLite.observer(CheckoutPage);
28663
28665
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28664
- var id, locale, settings, storefront, routing, redirect, checkout, region;
28666
+ var id, locale, settings, storefront, themeLocalization, routing, redirect, checkout;
28665
28667
  return __generator(this, function (_a) {
28666
28668
  switch (_a.label) {
28667
28669
  case 0:
@@ -28673,19 +28675,17 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
28673
28675
  // TODO maybe remove this and convert this page to static
28674
28676
  if (!settings ||
28675
28677
  !settings.storefront.mainStorefrontThemeId ||
28676
- !settings.storefront.salesChannelId ||
28677
- !settings.routing.priceListId) {
28678
+ !settings.storefront.salesChannelId) {
28678
28679
  return [2 /*return*/, {
28679
28680
  props: {},
28680
28681
  notFound: true,
28681
28682
  }];
28682
28683
  }
28683
- storefront = settings.storefront, routing = settings.routing;
28684
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, routing = settings.routing;
28684
28685
  IkasStorefrontConfig.storefrontId = storefront.id;
28685
28686
  IkasStorefrontConfig.storefrontRoutingId = routing.id;
28686
28687
  IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28687
28688
  IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28688
- IkasStorefrontConfig.priceListId = routing.priceListId;
28689
28689
  redirect = function () {
28690
28690
  context.res.writeHead(302, { Location: "/" });
28691
28691
  context.res.end();
@@ -28698,13 +28698,12 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
28698
28698
  case 2:
28699
28699
  checkout = _a.sent();
28700
28700
  if (checkout) {
28701
- region = settings.storefront.regions.find(function (r) { return r.id === storefront.mainStorefrontThemeId; });
28702
28701
  return [2 /*return*/, {
28703
28702
  props: {
28704
28703
  checkoutStr: JSON.stringify(checkout),
28705
- returnPolicy: (region === null || region === void 0 ? void 0 : region.returnPolicy) || "",
28706
- privacyPolicy: (region === null || region === void 0 ? void 0 : region.privacyPolicy) || "",
28707
- termsOfService: (region === null || region === void 0 ? void 0 : region.termsOfService) || "",
28704
+ returnPolicy: themeLocalization.returnPolicy || "",
28705
+ privacyPolicy: themeLocalization.privacyPolicy || "",
28706
+ termsOfService: themeLocalization.termsOfService || "",
28708
28707
  queryParams: context.query,
28709
28708
  },
28710
28709
  }];
@@ -1,9 +1,10 @@
1
+ import { IkasTheme } from "../../../theme/index";
1
2
  export declare class IkasStorefrontThemeLocalization {
2
3
  id: string;
3
4
  locale: string;
4
5
  storefrontId: string;
5
6
  storefrontThemeId: string;
6
- themeJson: string;
7
+ themeJson: IkasTheme;
7
8
  privacyPolicy: string | null;
8
9
  returnPolicy: string | null;
9
10
  termsOfService: string | null;
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import { GetServerSidePropsContext, GetStaticPropsContext } from "next";
3
3
  import { ParsedUrlQuery } from "querystring";
4
- import { IkasTheme, IkasThemePageType } from "../models/index";
4
+ import { IkasThemePageType } from "../models/index";
5
5
  import { IkasStorefront } from "../models/data/storefront/index";
6
6
  import { IkasSalesChannel } from "../models/data/sales-channel/index";
7
7
  import { IkasStorefrontRouting } from "../models/data/storefront/routing/index";
8
+ import { IkasStorefrontThemeLocalization } from "../models/data/storefront/theme-localization/index";
8
9
  export declare class SettingsHelper {
9
10
  static readSettingsFile(): Promise<any>;
10
11
  static getSettings(locale: string): Promise<SettingsData | null>;
@@ -77,7 +78,7 @@ export declare class SettingsHelper {
77
78
  }
78
79
  export declare type SettingsData = {
79
80
  storefront: IkasStorefront;
80
- theme: IkasTheme;
81
+ themeLocalization: IkasStorefrontThemeLocalization;
81
82
  salesChannel: IkasSalesChannel;
82
83
  routing: IkasStorefrontRouting;
83
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.98",
3
+ "version": "0.0.100",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",