@ikas/storefront 0.0.97 → 0.0.98

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
@@ -28342,34 +28342,64 @@ var IkasSalesChannelStockLocation = /** @class */ (function () {
28342
28342
  var SettingsHelper = /** @class */ (function () {
28343
28343
  function SettingsHelper() {
28344
28344
  }
28345
- SettingsHelper.getSettings = function (locale) {
28345
+ SettingsHelper.readSettingsFile = function () {
28346
28346
  return new Promise(function (resolve) {
28347
28347
  var serverRuntimeConfig = getConfig().serverRuntimeConfig;
28348
- var settings = serverRuntimeConfig.SETTINGS;
28349
- var storefront = new IkasStorefront(settings.storefront);
28350
- var salesChannel = new IkasSalesChannel(settings.salesChannel);
28351
- var localizationMap = settings.localizationMap;
28352
- var themeJSONPath = localizationMap[locale];
28353
- var routing = storefront.routings.find(function (r) { return r.id === locale || r.path === locale; });
28354
- if (!themeJSONPath || !routing) {
28355
- return resolve(null);
28356
- }
28357
- fs.readFile(themeJSONPath, {
28348
+ var settingsPath = serverRuntimeConfig.SETTINGS;
28349
+ fs.readFile(settingsPath, {
28358
28350
  flag: "a+",
28359
28351
  }, function (err, file) {
28360
28352
  if (err) {
28353
+ console.error("SETTINGS FILE READ ERROR!!!");
28354
+ console.error(err);
28361
28355
  return resolve(null);
28362
28356
  }
28363
28357
  var result = file.length ? JSON.parse(file.toString()) : {};
28364
- resolve({
28365
- storefront: storefront,
28366
- theme: new IkasTheme(result),
28367
- salesChannel: salesChannel,
28368
- routing: routing,
28369
- });
28358
+ resolve(result);
28370
28359
  });
28371
28360
  });
28372
28361
  };
28362
+ SettingsHelper.getSettings = function (locale) {
28363
+ var _this = this;
28364
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
28365
+ var settings, storefront, salesChannel, localizationMap, themeJSONPath, routing;
28366
+ return __generator(this, function (_a) {
28367
+ switch (_a.label) {
28368
+ case 0: return [4 /*yield*/, SettingsHelper.readSettingsFile()];
28369
+ case 1:
28370
+ settings = _a.sent();
28371
+ if (!settings)
28372
+ return [2 /*return*/, resolve(null)];
28373
+ storefront = new IkasStorefront(settings.storefront);
28374
+ salesChannel = new IkasSalesChannel(settings.salesChannel);
28375
+ localizationMap = settings.localizationMap;
28376
+ themeJSONPath = localizationMap[locale];
28377
+ 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
+ return [2 /*return*/, resolve(null)];
28381
+ }
28382
+ fs.readFile(themeJSONPath, {
28383
+ flag: "a+",
28384
+ }, function (err, file) {
28385
+ if (err) {
28386
+ console.error("THEMEJSON FILE RED ERROR!!!");
28387
+ console.error(err);
28388
+ return resolve(null);
28389
+ }
28390
+ var result = file.length ? JSON.parse(file.toString()) : {};
28391
+ resolve({
28392
+ storefront: storefront,
28393
+ theme: new IkasTheme(result),
28394
+ salesChannel: salesChannel,
28395
+ routing: routing,
28396
+ });
28397
+ });
28398
+ return [2 /*return*/];
28399
+ }
28400
+ });
28401
+ }); });
28402
+ };
28373
28403
  SettingsHelper.getPageData = function (context, isServer, pageType) {
28374
28404
  var _a;
28375
28405
  return __awaiter(this, void 0, void 0, function () {
package/build/index.js CHANGED
@@ -28322,34 +28322,64 @@ var IkasSalesChannelStockLocation = /** @class */ (function () {
28322
28322
  var SettingsHelper = /** @class */ (function () {
28323
28323
  function SettingsHelper() {
28324
28324
  }
28325
- SettingsHelper.getSettings = function (locale) {
28325
+ SettingsHelper.readSettingsFile = function () {
28326
28326
  return new Promise(function (resolve) {
28327
28327
  var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
28328
- var settings = serverRuntimeConfig.SETTINGS;
28329
- var storefront = new IkasStorefront(settings.storefront);
28330
- var salesChannel = new IkasSalesChannel(settings.salesChannel);
28331
- var localizationMap = settings.localizationMap;
28332
- var themeJSONPath = localizationMap[locale];
28333
- var routing = storefront.routings.find(function (r) { return r.id === locale || r.path === locale; });
28334
- if (!themeJSONPath || !routing) {
28335
- return resolve(null);
28336
- }
28337
- fs__default['default'].readFile(themeJSONPath, {
28328
+ var settingsPath = serverRuntimeConfig.SETTINGS;
28329
+ fs__default['default'].readFile(settingsPath, {
28338
28330
  flag: "a+",
28339
28331
  }, function (err, file) {
28340
28332
  if (err) {
28333
+ console.error("SETTINGS FILE READ ERROR!!!");
28334
+ console.error(err);
28341
28335
  return resolve(null);
28342
28336
  }
28343
28337
  var result = file.length ? JSON.parse(file.toString()) : {};
28344
- resolve({
28345
- storefront: storefront,
28346
- theme: new IkasTheme(result),
28347
- salesChannel: salesChannel,
28348
- routing: routing,
28349
- });
28338
+ resolve(result);
28350
28339
  });
28351
28340
  });
28352
28341
  };
28342
+ SettingsHelper.getSettings = function (locale) {
28343
+ var _this = this;
28344
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
28345
+ var settings, storefront, salesChannel, localizationMap, themeJSONPath, routing;
28346
+ return __generator(this, function (_a) {
28347
+ switch (_a.label) {
28348
+ case 0: return [4 /*yield*/, SettingsHelper.readSettingsFile()];
28349
+ case 1:
28350
+ settings = _a.sent();
28351
+ if (!settings)
28352
+ return [2 /*return*/, resolve(null)];
28353
+ storefront = new IkasStorefront(settings.storefront);
28354
+ salesChannel = new IkasSalesChannel(settings.salesChannel);
28355
+ localizationMap = settings.localizationMap;
28356
+ themeJSONPath = localizationMap[locale];
28357
+ 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
+ return [2 /*return*/, resolve(null)];
28361
+ }
28362
+ fs__default['default'].readFile(themeJSONPath, {
28363
+ flag: "a+",
28364
+ }, function (err, file) {
28365
+ if (err) {
28366
+ console.error("THEMEJSON FILE RED ERROR!!!");
28367
+ console.error(err);
28368
+ return resolve(null);
28369
+ }
28370
+ var result = file.length ? JSON.parse(file.toString()) : {};
28371
+ resolve({
28372
+ storefront: storefront,
28373
+ theme: new IkasTheme(result),
28374
+ salesChannel: salesChannel,
28375
+ routing: routing,
28376
+ });
28377
+ });
28378
+ return [2 /*return*/];
28379
+ }
28380
+ });
28381
+ }); });
28382
+ };
28353
28383
  SettingsHelper.getPageData = function (context, isServer, pageType) {
28354
28384
  var _a;
28355
28385
  return __awaiter(this, void 0, void 0, function () {
@@ -6,6 +6,7 @@ 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
8
  export declare class SettingsHelper {
9
+ static readSettingsFile(): Promise<any>;
9
10
  static getSettings(locale: string): Promise<SettingsData | null>;
10
11
  static getPageData(context: GetStaticPropsContext<ParsedUrlQuery> | GetServerSidePropsContext<ParsedUrlQuery>, isServer: boolean, pageType?: IkasThemePageType): Promise<{
11
12
  props: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.97",
3
+ "version": "0.0.98",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",