@ikas/storefront 0.0.95 → 0.0.97
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
|
@@ -8,6 +8,7 @@ import Link from 'next/link';
|
|
|
8
8
|
import Head from 'next/head';
|
|
9
9
|
import fs from 'fs';
|
|
10
10
|
import dynamic from 'next/dynamic';
|
|
11
|
+
import Error$1 from 'next/error';
|
|
11
12
|
|
|
12
13
|
/*! *****************************************************************************
|
|
13
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -15929,7 +15930,7 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
15929
15930
|
variantId: i.variant.id,
|
|
15930
15931
|
productId: i.variant.productId,
|
|
15931
15932
|
}); });
|
|
15932
|
-
return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines, [])];
|
|
15933
|
+
return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines, IkasStorefrontConfig.stockLocationIds || [])];
|
|
15933
15934
|
case 1:
|
|
15934
15935
|
result = _b.sent();
|
|
15935
15936
|
if (!result) {
|
|
@@ -28318,6 +28319,26 @@ var IkasStorefront = /** @class */ (function () {
|
|
|
28318
28319
|
return IkasStorefront;
|
|
28319
28320
|
}());
|
|
28320
28321
|
|
|
28322
|
+
var IkasSalesChannel = /** @class */ (function () {
|
|
28323
|
+
function IkasSalesChannel(data) {
|
|
28324
|
+
var _a;
|
|
28325
|
+
this.id = data.id || "";
|
|
28326
|
+
this.name = data.name || "";
|
|
28327
|
+
this.priceListId = data.priceListId || "";
|
|
28328
|
+
this.stockLocations =
|
|
28329
|
+
((_a = data.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return new IkasSalesChannelStockLocation(sl); })) ||
|
|
28330
|
+
[];
|
|
28331
|
+
}
|
|
28332
|
+
return IkasSalesChannel;
|
|
28333
|
+
}());
|
|
28334
|
+
var IkasSalesChannelStockLocation = /** @class */ (function () {
|
|
28335
|
+
function IkasSalesChannelStockLocation(data) {
|
|
28336
|
+
this.id = data.id || "";
|
|
28337
|
+
this.order = data.order || 0;
|
|
28338
|
+
}
|
|
28339
|
+
return IkasSalesChannelStockLocation;
|
|
28340
|
+
}());
|
|
28341
|
+
|
|
28321
28342
|
var SettingsHelper = /** @class */ (function () {
|
|
28322
28343
|
function SettingsHelper() {
|
|
28323
28344
|
}
|
|
@@ -28326,6 +28347,7 @@ var SettingsHelper = /** @class */ (function () {
|
|
|
28326
28347
|
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
28327
28348
|
var settings = serverRuntimeConfig.SETTINGS;
|
|
28328
28349
|
var storefront = new IkasStorefront(settings.storefront);
|
|
28350
|
+
var salesChannel = new IkasSalesChannel(settings.salesChannel);
|
|
28329
28351
|
var localizationMap = settings.localizationMap;
|
|
28330
28352
|
var themeJSONPath = localizationMap[locale];
|
|
28331
28353
|
var routing = storefront.routings.find(function (r) { return r.id === locale || r.path === locale; });
|
|
@@ -28342,40 +28364,42 @@ var SettingsHelper = /** @class */ (function () {
|
|
|
28342
28364
|
resolve({
|
|
28343
28365
|
storefront: storefront,
|
|
28344
28366
|
theme: new IkasTheme(result),
|
|
28367
|
+
salesChannel: salesChannel,
|
|
28345
28368
|
routing: routing,
|
|
28346
28369
|
});
|
|
28347
28370
|
});
|
|
28348
28371
|
});
|
|
28349
28372
|
};
|
|
28350
28373
|
SettingsHelper.getPageData = function (context, isServer, pageType) {
|
|
28374
|
+
var _a;
|
|
28351
28375
|
return __awaiter(this, void 0, void 0, function () {
|
|
28352
|
-
var locale, settings, storefront, theme, routing, provider;
|
|
28353
|
-
return __generator(this, function (
|
|
28354
|
-
switch (
|
|
28376
|
+
var locale, settings, storefront, theme, salesChannel, routing, provider;
|
|
28377
|
+
return __generator(this, function (_b) {
|
|
28378
|
+
switch (_b.label) {
|
|
28355
28379
|
case 0:
|
|
28356
28380
|
locale = context.locale || context.defaultLocale || "en";
|
|
28357
28381
|
return [4 /*yield*/, SettingsHelper.getSettings(locale)];
|
|
28358
28382
|
case 1:
|
|
28359
|
-
settings =
|
|
28383
|
+
settings = _b.sent();
|
|
28360
28384
|
if (!settings ||
|
|
28361
28385
|
!settings.storefront.mainStorefrontThemeId ||
|
|
28362
|
-
!settings.storefront.salesChannelId
|
|
28363
|
-
!settings.routing.priceListId) {
|
|
28386
|
+
!settings.storefront.salesChannelId) {
|
|
28364
28387
|
return [2 /*return*/, {
|
|
28365
28388
|
props: {},
|
|
28366
28389
|
notFound: true,
|
|
28367
28390
|
}];
|
|
28368
28391
|
}
|
|
28369
|
-
storefront = settings.storefront, theme = settings.theme, routing = settings.routing;
|
|
28392
|
+
storefront = settings.storefront, theme = settings.theme, salesChannel = settings.salesChannel, routing = settings.routing;
|
|
28370
28393
|
IkasStorefrontConfig.storefrontId = storefront.id;
|
|
28371
28394
|
IkasStorefrontConfig.storefrontRoutingId = routing.id;
|
|
28372
28395
|
IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
|
|
28373
28396
|
IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
|
|
28374
|
-
IkasStorefrontConfig.priceListId = routing.priceListId;
|
|
28397
|
+
IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
|
|
28398
|
+
IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
|
|
28375
28399
|
provider = new IkasPageDataProvider(theme, context.params, pageType);
|
|
28376
28400
|
return [4 /*yield*/, provider.getPageData()];
|
|
28377
28401
|
case 2:
|
|
28378
|
-
|
|
28402
|
+
_b.sent();
|
|
28379
28403
|
if (!provider.page) {
|
|
28380
28404
|
return [2 /*return*/, {
|
|
28381
28405
|
props: {},
|
|
@@ -28386,7 +28410,9 @@ var SettingsHelper = /** @class */ (function () {
|
|
|
28386
28410
|
return [2 /*return*/, provider.nextPageData];
|
|
28387
28411
|
else
|
|
28388
28412
|
return [2 /*return*/, {
|
|
28389
|
-
props: __assign(__assign({}, provider.nextPageData.props), { pageSpecificDataStr:
|
|
28413
|
+
props: __assign(__assign({}, provider.nextPageData.props), { pageSpecificDataStr: provider.pageSpecificData
|
|
28414
|
+
? JSON.stringify(provider.pageSpecificData || {})
|
|
28415
|
+
: "" }),
|
|
28390
28416
|
revalidate: 60,
|
|
28391
28417
|
}];
|
|
28392
28418
|
}
|
|
@@ -28586,7 +28612,7 @@ var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, voi
|
|
|
28586
28612
|
!customPagePaths.some(function (p) { return p.params.slug === customPage.slug; })) {
|
|
28587
28613
|
customPagePaths.push({
|
|
28588
28614
|
params: { slug: customPage.slug },
|
|
28589
|
-
locale: routing.
|
|
28615
|
+
locale: routing.path || routing.id,
|
|
28590
28616
|
});
|
|
28591
28617
|
}
|
|
28592
28618
|
});
|
|
@@ -28942,15 +28968,27 @@ var search = /*#__PURE__*/Object.freeze({
|
|
|
28942
28968
|
|
|
28943
28969
|
var Page$f = function (_a) {
|
|
28944
28970
|
var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
|
|
28971
|
+
if (!propValuesStr || !page)
|
|
28972
|
+
return createElement(Error$1, { statusCode: 404 });
|
|
28945
28973
|
var router = useRouter();
|
|
28946
28974
|
var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
|
|
28947
28975
|
return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
|
|
28948
28976
|
};
|
|
28949
28977
|
var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
28978
|
+
var props;
|
|
28950
28979
|
return __generator(this, function (_a) {
|
|
28951
28980
|
switch (_a.label) {
|
|
28952
28981
|
case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.NOT_FOUND)];
|
|
28953
|
-
case 1:
|
|
28982
|
+
case 1:
|
|
28983
|
+
props = _a.sent();
|
|
28984
|
+
//@ts-ignore
|
|
28985
|
+
if (props.notFound)
|
|
28986
|
+
return [2 /*return*/, {
|
|
28987
|
+
props: {},
|
|
28988
|
+
revalidate: 60,
|
|
28989
|
+
}];
|
|
28990
|
+
else
|
|
28991
|
+
return [2 /*return*/, props];
|
|
28954
28992
|
}
|
|
28955
28993
|
});
|
|
28956
28994
|
}); };
|
package/build/index.js
CHANGED
|
@@ -12,6 +12,7 @@ var Link = require('next/link');
|
|
|
12
12
|
var Head = require('next/head');
|
|
13
13
|
var fs = require('fs');
|
|
14
14
|
var dynamic = require('next/dynamic');
|
|
15
|
+
var Error$1 = require('next/error');
|
|
15
16
|
|
|
16
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
18
|
|
|
@@ -22,6 +23,7 @@ var Link__default = /*#__PURE__*/_interopDefaultLegacy(Link);
|
|
|
22
23
|
var Head__default = /*#__PURE__*/_interopDefaultLegacy(Head);
|
|
23
24
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
24
25
|
var dynamic__default = /*#__PURE__*/_interopDefaultLegacy(dynamic);
|
|
26
|
+
var Error__default = /*#__PURE__*/_interopDefaultLegacy(Error$1);
|
|
25
27
|
|
|
26
28
|
/*! *****************************************************************************
|
|
27
29
|
Copyright (c) Microsoft Corporation.
|
|
@@ -15934,7 +15936,7 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
15934
15936
|
variantId: i.variant.id,
|
|
15935
15937
|
productId: i.variant.productId,
|
|
15936
15938
|
}); });
|
|
15937
|
-
return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines, [])];
|
|
15939
|
+
return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines, IkasStorefrontConfig.stockLocationIds || [])];
|
|
15938
15940
|
case 1:
|
|
15939
15941
|
result = _b.sent();
|
|
15940
15942
|
if (!result) {
|
|
@@ -28297,6 +28299,26 @@ var IkasStorefront = /** @class */ (function () {
|
|
|
28297
28299
|
return IkasStorefront;
|
|
28298
28300
|
}());
|
|
28299
28301
|
|
|
28302
|
+
var IkasSalesChannel = /** @class */ (function () {
|
|
28303
|
+
function IkasSalesChannel(data) {
|
|
28304
|
+
var _a;
|
|
28305
|
+
this.id = data.id || "";
|
|
28306
|
+
this.name = data.name || "";
|
|
28307
|
+
this.priceListId = data.priceListId || "";
|
|
28308
|
+
this.stockLocations =
|
|
28309
|
+
((_a = data.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return new IkasSalesChannelStockLocation(sl); })) ||
|
|
28310
|
+
[];
|
|
28311
|
+
}
|
|
28312
|
+
return IkasSalesChannel;
|
|
28313
|
+
}());
|
|
28314
|
+
var IkasSalesChannelStockLocation = /** @class */ (function () {
|
|
28315
|
+
function IkasSalesChannelStockLocation(data) {
|
|
28316
|
+
this.id = data.id || "";
|
|
28317
|
+
this.order = data.order || 0;
|
|
28318
|
+
}
|
|
28319
|
+
return IkasSalesChannelStockLocation;
|
|
28320
|
+
}());
|
|
28321
|
+
|
|
28300
28322
|
var SettingsHelper = /** @class */ (function () {
|
|
28301
28323
|
function SettingsHelper() {
|
|
28302
28324
|
}
|
|
@@ -28305,6 +28327,7 @@ var SettingsHelper = /** @class */ (function () {
|
|
|
28305
28327
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
28306
28328
|
var settings = serverRuntimeConfig.SETTINGS;
|
|
28307
28329
|
var storefront = new IkasStorefront(settings.storefront);
|
|
28330
|
+
var salesChannel = new IkasSalesChannel(settings.salesChannel);
|
|
28308
28331
|
var localizationMap = settings.localizationMap;
|
|
28309
28332
|
var themeJSONPath = localizationMap[locale];
|
|
28310
28333
|
var routing = storefront.routings.find(function (r) { return r.id === locale || r.path === locale; });
|
|
@@ -28321,40 +28344,42 @@ var SettingsHelper = /** @class */ (function () {
|
|
|
28321
28344
|
resolve({
|
|
28322
28345
|
storefront: storefront,
|
|
28323
28346
|
theme: new IkasTheme(result),
|
|
28347
|
+
salesChannel: salesChannel,
|
|
28324
28348
|
routing: routing,
|
|
28325
28349
|
});
|
|
28326
28350
|
});
|
|
28327
28351
|
});
|
|
28328
28352
|
};
|
|
28329
28353
|
SettingsHelper.getPageData = function (context, isServer, pageType) {
|
|
28354
|
+
var _a;
|
|
28330
28355
|
return __awaiter(this, void 0, void 0, function () {
|
|
28331
|
-
var locale, settings, storefront, theme, routing, provider;
|
|
28332
|
-
return __generator(this, function (
|
|
28333
|
-
switch (
|
|
28356
|
+
var locale, settings, storefront, theme, salesChannel, routing, provider;
|
|
28357
|
+
return __generator(this, function (_b) {
|
|
28358
|
+
switch (_b.label) {
|
|
28334
28359
|
case 0:
|
|
28335
28360
|
locale = context.locale || context.defaultLocale || "en";
|
|
28336
28361
|
return [4 /*yield*/, SettingsHelper.getSettings(locale)];
|
|
28337
28362
|
case 1:
|
|
28338
|
-
settings =
|
|
28363
|
+
settings = _b.sent();
|
|
28339
28364
|
if (!settings ||
|
|
28340
28365
|
!settings.storefront.mainStorefrontThemeId ||
|
|
28341
|
-
!settings.storefront.salesChannelId
|
|
28342
|
-
!settings.routing.priceListId) {
|
|
28366
|
+
!settings.storefront.salesChannelId) {
|
|
28343
28367
|
return [2 /*return*/, {
|
|
28344
28368
|
props: {},
|
|
28345
28369
|
notFound: true,
|
|
28346
28370
|
}];
|
|
28347
28371
|
}
|
|
28348
|
-
storefront = settings.storefront, theme = settings.theme, routing = settings.routing;
|
|
28372
|
+
storefront = settings.storefront, theme = settings.theme, salesChannel = settings.salesChannel, routing = settings.routing;
|
|
28349
28373
|
IkasStorefrontConfig.storefrontId = storefront.id;
|
|
28350
28374
|
IkasStorefrontConfig.storefrontRoutingId = routing.id;
|
|
28351
28375
|
IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
|
|
28352
28376
|
IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
|
|
28353
|
-
IkasStorefrontConfig.priceListId = routing.priceListId;
|
|
28377
|
+
IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
|
|
28378
|
+
IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
|
|
28354
28379
|
provider = new IkasPageDataProvider(theme, context.params, pageType);
|
|
28355
28380
|
return [4 /*yield*/, provider.getPageData()];
|
|
28356
28381
|
case 2:
|
|
28357
|
-
|
|
28382
|
+
_b.sent();
|
|
28358
28383
|
if (!provider.page) {
|
|
28359
28384
|
return [2 /*return*/, {
|
|
28360
28385
|
props: {},
|
|
@@ -28365,7 +28390,9 @@ var SettingsHelper = /** @class */ (function () {
|
|
|
28365
28390
|
return [2 /*return*/, provider.nextPageData];
|
|
28366
28391
|
else
|
|
28367
28392
|
return [2 /*return*/, {
|
|
28368
|
-
props: __assign(__assign({}, provider.nextPageData.props), { pageSpecificDataStr:
|
|
28393
|
+
props: __assign(__assign({}, provider.nextPageData.props), { pageSpecificDataStr: provider.pageSpecificData
|
|
28394
|
+
? JSON.stringify(provider.pageSpecificData || {})
|
|
28395
|
+
: "" }),
|
|
28369
28396
|
revalidate: 60,
|
|
28370
28397
|
}];
|
|
28371
28398
|
}
|
|
@@ -28565,7 +28592,7 @@ var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, voi
|
|
|
28565
28592
|
!customPagePaths.some(function (p) { return p.params.slug === customPage.slug; })) {
|
|
28566
28593
|
customPagePaths.push({
|
|
28567
28594
|
params: { slug: customPage.slug },
|
|
28568
|
-
locale: routing.
|
|
28595
|
+
locale: routing.path || routing.id,
|
|
28569
28596
|
});
|
|
28570
28597
|
}
|
|
28571
28598
|
});
|
|
@@ -28921,15 +28948,27 @@ var search = /*#__PURE__*/Object.freeze({
|
|
|
28921
28948
|
|
|
28922
28949
|
var Page$f = function (_a) {
|
|
28923
28950
|
var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
|
|
28951
|
+
if (!propValuesStr || !page)
|
|
28952
|
+
return React.createElement(Error__default['default'], { statusCode: 404 });
|
|
28924
28953
|
var router$1 = router.useRouter();
|
|
28925
28954
|
var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
|
|
28926
28955
|
return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
|
|
28927
28956
|
};
|
|
28928
28957
|
var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
|
|
28958
|
+
var props;
|
|
28929
28959
|
return __generator(this, function (_a) {
|
|
28930
28960
|
switch (_a.label) {
|
|
28931
28961
|
case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.NOT_FOUND)];
|
|
28932
|
-
case 1:
|
|
28962
|
+
case 1:
|
|
28963
|
+
props = _a.sent();
|
|
28964
|
+
//@ts-ignore
|
|
28965
|
+
if (props.notFound)
|
|
28966
|
+
return [2 /*return*/, {
|
|
28967
|
+
props: {},
|
|
28968
|
+
revalidate: 60,
|
|
28969
|
+
}];
|
|
28970
|
+
else
|
|
28971
|
+
return [2 /*return*/, props];
|
|
28933
28972
|
}
|
|
28934
28973
|
});
|
|
28935
28974
|
}); };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class IkasSalesChannel {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
priceListId: string | null;
|
|
5
|
+
stockLocations: IkasSalesChannelStockLocation[] | null;
|
|
6
|
+
constructor(data: Partial<IkasSalesChannel>);
|
|
7
|
+
}
|
|
8
|
+
export declare class IkasSalesChannelStockLocation {
|
|
9
|
+
id: string;
|
|
10
|
+
order: number;
|
|
11
|
+
constructor(data: Partial<IkasSalesChannelStockLocation>);
|
|
12
|
+
}
|
|
@@ -9,5 +9,6 @@ export declare class IkasStorefrontConfig {
|
|
|
9
9
|
static storefrontThemeId?: string;
|
|
10
10
|
static salesChannelId?: string;
|
|
11
11
|
static priceListId?: string;
|
|
12
|
+
static stockLocationIds?: string[];
|
|
12
13
|
static init(store: IkasBaseStore, components: any, config: Record<string, any>, apiUrlOverride?: string): void;
|
|
13
14
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { GetServerSidePropsContext, GetStaticPropsContext } from "next";
|
|
3
|
+
import { ParsedUrlQuery } from "querystring";
|
|
2
4
|
import { IkasTheme, IkasThemePageType } from "../models/index";
|
|
3
5
|
import { IkasStorefront } from "../models/data/storefront/index";
|
|
6
|
+
import { IkasSalesChannel } from "../models/data/sales-channel/index";
|
|
4
7
|
import { IkasStorefrontRouting } from "../models/data/storefront/routing/index";
|
|
5
|
-
import { GetServerSidePropsContext, GetStaticPropsContext } from "next";
|
|
6
|
-
import { ParsedUrlQuery } from "querystring";
|
|
7
8
|
export declare class SettingsHelper {
|
|
8
9
|
static getSettings(locale: string): Promise<SettingsData | null>;
|
|
9
10
|
static getPageData(context: GetStaticPropsContext<ParsedUrlQuery> | GetServerSidePropsContext<ParsedUrlQuery>, isServer: boolean, pageType?: IkasThemePageType): Promise<{
|
|
@@ -76,5 +77,6 @@ export declare class SettingsHelper {
|
|
|
76
77
|
export declare type SettingsData = {
|
|
77
78
|
storefront: IkasStorefront;
|
|
78
79
|
theme: IkasTheme;
|
|
80
|
+
salesChannel: IkasSalesChannel;
|
|
79
81
|
routing: IkasStorefrontRouting;
|
|
80
82
|
};
|