@ikas/storefront 0.2.0-beta.1 → 0.2.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.
package/build/index.js CHANGED
@@ -19882,28 +19882,6 @@ var moment = createCommonjsModule(function (module, exports) {
19882
19882
  })));
19883
19883
  });
19884
19884
 
19885
- var ProductOptionTypeEnum;
19886
- (function (ProductOptionTypeEnum) {
19887
- ProductOptionTypeEnum["CHECKBOX"] = "CHECKBOX";
19888
- ProductOptionTypeEnum["CHOICE"] = "CHOICE";
19889
- ProductOptionTypeEnum["COLOR_PICKER"] = "COLOR_PICKER";
19890
- ProductOptionTypeEnum["DATE_PICKER"] = "DATE_PICKER";
19891
- ProductOptionTypeEnum["FILE"] = "FILE";
19892
- ProductOptionTypeEnum["IMAGE"] = "IMAGE";
19893
- ProductOptionTypeEnum["TEXT"] = "TEXT";
19894
- ProductOptionTypeEnum["TEXT_AREA"] = "TEXT_AREA";
19895
- })(ProductOptionTypeEnum || (ProductOptionTypeEnum = {}));
19896
- var IkasOrderLineOptions = /** @class */ (function () {
19897
- function IkasOrderLineOptions(data) {
19898
- this.name = data.name;
19899
- this.productOptionId = data.productOptionId;
19900
- this.productOptionsSetId = data.productOptionsSetId;
19901
- this.type = data.type;
19902
- this.values = data.values;
19903
- }
19904
- return IkasOrderLineOptions;
19905
- }());
19906
-
19907
19885
  var IkasOrderLineItem = /** @class */ (function () {
19908
19886
  function IkasOrderLineItem(data) {
19909
19887
  this.discount = null;
@@ -19931,9 +19909,6 @@ var IkasOrderLineItem = /** @class */ (function () {
19931
19909
  ? new IkasOrderLineVariant(data.variant)
19932
19910
  : new IkasOrderLineVariant();
19933
19911
  this.status = data.status || OrderLineItemStatusEnum.FULFILLED;
19934
- this.options = data.options
19935
- ? data.options.map(function (oP) { return new IkasOrderLineOptions(oP); })
19936
- : null;
19937
19912
  mobx.makeAutoObservable(this);
19938
19913
  }
19939
19914
  Object.defineProperty(IkasOrderLineItem.prototype, "orderedAtDays", {
@@ -21181,19 +21156,6 @@ var IkasProduct = /** @class */ (function () {
21181
21156
  enumerable: false,
21182
21157
  configurable: true
21183
21158
  });
21184
- Object.defineProperty(IkasProduct.prototype, "canAddToCart", {
21185
- get: function () {
21186
- if (this.productOptionSetId) {
21187
- return (!!this.productOptionSet &&
21188
- this.productOptionSet.options.every(function (o) { return o.hasValidValues; }));
21189
- }
21190
- else {
21191
- return true;
21192
- }
21193
- },
21194
- enumerable: false,
21195
- configurable: true
21196
- });
21197
21159
  return IkasProduct;
21198
21160
  }());
21199
21161
  (function (IkasProductType) {
@@ -24043,8 +24005,8 @@ var IkasTransactionCardTypeEnum;
24043
24005
  IkasProductOptionType["CHOICE"] = "CHOICE";
24044
24006
  IkasProductOptionType["TEXT"] = "TEXT";
24045
24007
  IkasProductOptionType["TEXT_AREA"] = "TEXT_AREA";
24046
- // IMAGE = "IMAGE",
24047
- // FILE = "FILE",
24008
+ IkasProductOptionType["IMAGE"] = "IMAGE";
24009
+ IkasProductOptionType["FILE"] = "FILE";
24048
24010
  IkasProductOptionType["COLOR_PICKER"] = "COLOR_PICKER";
24049
24011
  // DATE_PICKER = "DATE_PICKER",
24050
24012
  IkasProductOptionType["CHECKBOX"] = "CHECKBOX";
@@ -24087,16 +24049,16 @@ var IkasProductOptionSetTranslations = /** @class */ (function () {
24087
24049
  var IkasProductOptionSelectValue = /** @class */ (function () {
24088
24050
  function IkasProductOptionSelectValue(data) {
24089
24051
  if (data === void 0) { data = {}; }
24090
- this.thumbnailImage = null;
24091
- this.id = data.id || "";
24092
24052
  this.order = data.order || 0;
24093
24053
  this.value = data.value || "";
24094
24054
  this.price = data.price || null;
24095
24055
  this.thumbnailImageId = data.thumbnailImageId || null;
24096
24056
  this.colorCode = data.colorCode || null;
24097
- this.thumbnailImage = this.thumbnailImageId
24098
- ? new IkasImage(this.thumbnailImageId)
24099
- : null;
24057
+ this.thumbnailImage =
24058
+ data.thumbnailImage ||
24059
+ (this.thumbnailImageId
24060
+ ? new IkasImage(this.thumbnailImageId)
24061
+ : undefined);
24100
24062
  mobx.makeAutoObservable(this);
24101
24063
  }
24102
24064
  return IkasProductOptionSelectValue;
@@ -24106,14 +24068,8 @@ var IkasProductOptionSelectSettings = /** @class */ (function () {
24106
24068
  if (data === void 0) { data = {}; }
24107
24069
  var _a;
24108
24070
  this.type = data.type || exports.IkasProductOptionSelectType.BOX;
24109
- this.minSelect =
24110
- data.minSelect !== null && data.minSelect !== undefined
24111
- ? data.minSelect
24112
- : null;
24113
- this.maxSelect =
24114
- data.maxSelect !== null && data.maxSelect !== undefined
24115
- ? data.maxSelect
24116
- : null;
24071
+ this.minSelect = data.minSelect || null;
24072
+ this.maxSelect = data.maxSelect || null;
24117
24073
  this.values =
24118
24074
  ((_a = data.values) === null || _a === void 0 ? void 0 : _a.map(function (o) { return new IkasProductOptionSelectValue(o); })) || [];
24119
24075
  mobx.makeAutoObservable(this);
@@ -24131,8 +24087,8 @@ var IkasProductOptionDateSettings = /** @class */ (function () {
24131
24087
  var IkasProductOptionTextSettings = /** @class */ (function () {
24132
24088
  function IkasProductOptionTextSettings(data) {
24133
24089
  if (data === void 0) { data = {}; }
24134
- this.min = data.min !== null && data.min !== undefined ? data.min : null;
24135
- this.max = data.max !== null && data.max !== undefined ? data.max : null;
24090
+ this.min = data.min || null;
24091
+ this.max = data.max || null;
24136
24092
  mobx.makeAutoObservable(this);
24137
24093
  }
24138
24094
  return IkasProductOptionTextSettings;
@@ -24140,51 +24096,14 @@ var IkasProductOptionTextSettings = /** @class */ (function () {
24140
24096
  var IkasProductOptionFileSettings = /** @class */ (function () {
24141
24097
  function IkasProductOptionFileSettings(data) {
24142
24098
  this.allowedExtensions = data.allowedExtensions || null;
24143
- this.minQuantity =
24144
- data.minQuantity !== null && data.minQuantity !== undefined
24145
- ? data.minQuantity
24146
- : null;
24147
- this.maxQuantity =
24148
- data.maxQuantity !== null && data.maxQuantity !== undefined
24149
- ? data.maxQuantity
24150
- : null;
24099
+ this.minQuantity = data.minQuantity || null;
24100
+ this.maxQuantity = data.maxQuantity || null;
24151
24101
  mobx.makeAutoObservable(this);
24152
24102
  }
24153
24103
  return IkasProductOptionFileSettings;
24154
24104
  }());
24155
24105
  var IkasProductOption = /** @class */ (function () {
24156
24106
  function IkasProductOption(data) {
24157
- var _this = this;
24158
- this._values = [];
24159
- this.childOptions = [];
24160
- this.initValues = function () {
24161
- if (!_this.isOptional) {
24162
- _this.values = [];
24163
- if (_this.childOptions) {
24164
- _this.childOptions.forEach(function (co) { return co.initValues(); });
24165
- }
24166
- }
24167
- };
24168
- this.isValidTextOptionValue = function () {
24169
- return (!!_this.textSettings &&
24170
- (_this.textSettings.min !== null
24171
- ? _this.values[0].length >= _this.textSettings.min
24172
- : true) &&
24173
- (_this.textSettings.max !== null
24174
- ? _this.values[0].length <= _this.textSettings.max
24175
- : true));
24176
- };
24177
- this.isValidChoiceOptionValue = function () {
24178
- return (!!_this.selectSettings &&
24179
- (_this.selectSettings.minSelect !== null
24180
- ? _this.values.length >= _this.selectSettings.minSelect
24181
- : true) &&
24182
- (_this.selectSettings.maxSelect !== null
24183
- ? _this.values.length <= _this.selectSettings.maxSelect
24184
- : true));
24185
- };
24186
- this.id = data.id || "";
24187
- this.productOptionSetId = data.productOptionSetId || "";
24188
24107
  this.name = data.name || "";
24189
24108
  this.order = data.order || 0;
24190
24109
  this.type = data.type || exports.IkasProductOptionType.CHOICE;
@@ -24205,134 +24124,19 @@ var IkasProductOption = /** @class */ (function () {
24205
24124
  this.optionalText = data.optionalText || null;
24206
24125
  this.requiredOptionId = data.requiredOptionId || null;
24207
24126
  this.requiredOptionValueIds = data.requiredOptionValueIds || null;
24208
- this.values = data.values || [];
24209
- this.childOptions = data.childOptions || [];
24210
24127
  mobx.makeAutoObservable(this);
24211
24128
  }
24212
- Object.defineProperty(IkasProductOption.prototype, "displayedChildOptions", {
24213
- get: function () {
24214
- var _this = this;
24215
- return this.childOptions.filter(function (co) {
24216
- var _a;
24217
- // Check if all required options are selected
24218
- if ((_a = co.requiredOptionValueIds) === null || _a === void 0 ? void 0 : _a.length) {
24219
- return co.requiredOptionValueIds.every(function (rovId) {
24220
- return _this.values.some(function (v) { return v === rovId; });
24221
- });
24222
- }
24223
- else {
24224
- return !!_this.values.length;
24225
- }
24226
- });
24227
- },
24228
- enumerable: false,
24229
- configurable: true
24230
- });
24231
- Object.defineProperty(IkasProductOption.prototype, "hasValidValues", {
24232
- get: function () {
24233
- if (!this.values.length && !this.isOptional) {
24234
- return false;
24235
- }
24236
- var hasValidValues = false;
24237
- switch (this.type) {
24238
- case exports.IkasProductOptionType.TEXT:
24239
- case exports.IkasProductOptionType.TEXT_AREA:
24240
- hasValidValues = this.isValidTextOptionValue();
24241
- break;
24242
- case exports.IkasProductOptionType.CHECKBOX:
24243
- case exports.IkasProductOptionType.COLOR_PICKER:
24244
- hasValidValues = true;
24245
- break;
24246
- case exports.IkasProductOptionType.CHOICE:
24247
- hasValidValues = this.isValidChoiceOptionValue();
24248
- break;
24249
- }
24250
- return hasValidValues && this.childOptions.every(function (co) { return co.hasValidValues; });
24251
- },
24252
- enumerable: false,
24253
- configurable: true
24254
- });
24255
- Object.defineProperty(IkasProductOption.prototype, "values", {
24256
- get: function () {
24257
- return this._values;
24258
- },
24259
- set: function (values) {
24260
- this._values = values;
24261
- if (!values.length) {
24262
- this.childOptions.forEach(function (co) { return (co.values = []); });
24263
- }
24264
- },
24265
- enumerable: false,
24266
- configurable: true
24267
- });
24268
24129
  return IkasProductOption;
24269
24130
  }());
24270
24131
  var IkasProductOptionSet = /** @class */ (function () {
24271
24132
  function IkasProductOptionSet(data) {
24272
- var _this = this;
24273
24133
  var _a, _b;
24274
- this.initOptionValues = function () { return __awaiter(_this, void 0, void 0, function () {
24275
- return __generator(this, function (_a) {
24276
- this.options.forEach(function (o) { return o.initValues(); });
24277
- return [2 /*return*/];
24278
- });
24279
- }); };
24280
- this.id = data.id || "";
24281
24134
  this.name = data.name || "";
24282
- this.options =
24283
- ((_a = data.options) === null || _a === void 0 ? void 0 : _a.map(function (o) {
24284
- return new IkasProductOption(__assign(__assign({}, o), { productOptionSetId: _this.id }));
24285
- })) || [];
24135
+ this.options = ((_a = data.options) === null || _a === void 0 ? void 0 : _a.map(function (o) { return new IkasProductOption(o); })) || [];
24286
24136
  this.translations = data.translations
24287
24137
  ? (_b = data.translations) === null || _b === void 0 ? void 0 : _b.map(function (o) { return new IkasProductOptionSetTranslations(o); }) : null;
24288
- this.setChildOptions();
24289
- this.setTranslations();
24290
- this.initOptionValues();
24291
24138
  mobx.makeAutoObservable(this);
24292
24139
  }
24293
- Object.defineProperty(IkasProductOptionSet.prototype, "displayedOptions", {
24294
- get: function () {
24295
- return this.options.filter(function (o) { return !o.requiredOptionId; });
24296
- },
24297
- enumerable: false,
24298
- configurable: true
24299
- });
24300
- IkasProductOptionSet.prototype.setTranslations = function () {
24301
- var _this = this;
24302
- var _a;
24303
- var locale = IkasStorefrontConfig.getCurrentLocale();
24304
- if (this.translations &&
24305
- this.translations.some(function (t) { return t.locale === locale; })) {
24306
- var localeTranslations = this.translations.find(function (t) { return t.locale === locale; });
24307
- (_a = localeTranslations === null || localeTranslations === void 0 ? void 0 : localeTranslations.options) === null || _a === void 0 ? void 0 : _a.forEach(function (translatedOption) {
24308
- var _a;
24309
- var option = _this.options.find(function (o) { return o.id === translatedOption.id; });
24310
- if (option) {
24311
- option.name = translatedOption.name || option.name;
24312
- option.optionalText =
24313
- translatedOption.optionalText || option.optionalText;
24314
- if (option.type === exports.IkasProductOptionType.CHOICE) {
24315
- (_a = translatedOption.values) === null || _a === void 0 ? void 0 : _a.forEach(function (translatedValue) {
24316
- var _a;
24317
- var selectValue = (_a = option.selectSettings) === null || _a === void 0 ? void 0 : _a.values.find(function (sv) { return sv.id === translatedValue.id; });
24318
- if (selectValue) {
24319
- selectValue.value = translatedValue.value || selectValue.value;
24320
- }
24321
- });
24322
- }
24323
- }
24324
- });
24325
- }
24326
- };
24327
- IkasProductOptionSet.prototype.setChildOptions = function () {
24328
- var _this = this;
24329
- this.options.forEach(function (option) {
24330
- var childOptions = _this.options.filter(function (o) { return o.requiredOptionId === option.id; });
24331
- if (childOptions.length) {
24332
- option.childOptions = childOptions;
24333
- }
24334
- });
24335
- };
24336
24140
  return IkasProductOptionSet;
24337
24141
  }());
24338
24142
 
@@ -37941,7 +37745,7 @@ var ProductOptionSelectTypeEnum;
37941
37745
  ProductOptionSelectTypeEnum["SELECT"] = "SELECT";
37942
37746
  ProductOptionSelectTypeEnum["SWATCH"] = "SWATCH";
37943
37747
  })(ProductOptionSelectTypeEnum || (ProductOptionSelectTypeEnum = {}));
37944
- var ProductOptionTypeEnum$1;
37748
+ var ProductOptionTypeEnum;
37945
37749
  (function (ProductOptionTypeEnum) {
37946
37750
  ProductOptionTypeEnum["CHECKBOX"] = "CHECKBOX";
37947
37751
  ProductOptionTypeEnum["CHOICE"] = "CHOICE";
@@ -37951,7 +37755,7 @@ var ProductOptionTypeEnum$1;
37951
37755
  ProductOptionTypeEnum["IMAGE"] = "IMAGE";
37952
37756
  ProductOptionTypeEnum["TEXT"] = "TEXT";
37953
37757
  ProductOptionTypeEnum["TEXT_AREA"] = "TEXT_AREA";
37954
- })(ProductOptionTypeEnum$1 || (ProductOptionTypeEnum$1 = {}));
37758
+ })(ProductOptionTypeEnum || (ProductOptionTypeEnum = {}));
37955
37759
  var ProductSearchShowStockOptionEnum;
37956
37760
  (function (ProductSearchShowStockOptionEnum) {
37957
37761
  ProductSearchShowStockOptionEnum["HIDE_OUT_OF_STOCK"] = "HIDE_OUT_OF_STOCK";
@@ -41466,7 +41270,7 @@ var IkasCartAPI = /** @class */ (function () {
41466
41270
  return __generator(this, function (_b) {
41467
41271
  switch (_b.label) {
41468
41272
  case 0:
41469
- MUTATION = src(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n options {\n name\n productOptionsSetId\n productOptionId\n type\n values {\n name\n price\n value\n }\n }\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "], ["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n options {\n name\n productOptionsSetId\n productOptionId\n type\n values {\n name\n price\n value\n }\n }\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "])));
41273
+ MUTATION = src(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "], ["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "])));
41470
41274
  _b.label = 1;
41471
41275
  case 1:
41472
41276
  _b.trys.push([1, 3, , 4]);
@@ -41501,7 +41305,7 @@ var IkasCartAPI = /** @class */ (function () {
41501
41305
  return __generator(this, function (_b) {
41502
41306
  switch (_b.label) {
41503
41307
  case 0:
41504
- QUERY = src(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n query getCart(\n $cartId: String\n $customerId: String\n $storefrontRoutingId: String\n ) {\n getCart(\n id: $cartId\n customerId: $customerId\n storefrontRoutingId: $storefrontRoutingId\n ) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "], ["\n query getCart(\n $cartId: String\n $customerId: String\n $storefrontRoutingId: String\n ) {\n getCart(\n id: $cartId\n customerId: $customerId\n storefrontRoutingId: $storefrontRoutingId\n ) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "])));
41308
+ QUERY = src(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n query getCart(\n $cartId: String\n $customerId: String\n $storefrontRoutingId: String\n ) {\n getCart(\n id: $cartId\n customerId: $customerId\n storefrontRoutingId: $storefrontRoutingId\n ) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "], ["\n query getCart(\n $cartId: String\n $customerId: String\n $storefrontRoutingId: String\n ) {\n getCart(\n id: $cartId\n customerId: $customerId\n storefrontRoutingId: $storefrontRoutingId\n ) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "])));
41505
41309
  _b.label = 1;
41506
41310
  case 1:
41507
41311
  _b.trys.push([1, 3, , 4]);
@@ -43617,9 +43421,7 @@ var IkasProductOptionSetAPI = /** @class */ (function () {
43617
43421
  return [2 /*return*/];
43618
43422
  }
43619
43423
  return [2 /*return*/, {
43620
- data: data.listProductOptionSet.map(function (c) {
43621
- return new IkasProductOptionSet(c);
43622
- }),
43424
+ data: data.listProductOptionSet.map(function (c) { return new IkasProductOptionSet(c); }),
43623
43425
  }];
43624
43426
  case 2:
43625
43427
  err_1 = _b.sent();
@@ -70714,17 +70516,6 @@ var Note = mobxReactLite.observer(function (_a) {
70714
70516
  isSuccessStep ? (React.createElement("div", { className: styles$g.CheckoutNoteDisplay }, vm.checkout.note)) : (React.createElement(FormItem, { style: { width: "100%" }, type: FormItemType.TEXT_AREA, disableResize: true, label: "", value: vm.checkout.note || "", onChange: onCheckoutNoteChange }))))));
70715
70517
  });
70716
70518
 
70717
- var IkasProductCartLineOption = /** @class */ (function () {
70718
- function IkasProductCartLineOption(data) {
70719
- if (data === void 0) { data = {}; }
70720
- this.productOptionId = data.productOptionId || "";
70721
- this.productOptionsSetId = data.productOptionsSetId || "";
70722
- this.values = data.values || [];
70723
- mobx.makeAutoObservable(this);
70724
- }
70725
- return IkasProductCartLineOption;
70726
- }());
70727
-
70728
70519
  var CART_LS_KEY = "cartId";
70729
70520
  var CHECKOUT_LS_KEY = "checkoutId";
70730
70521
  var IkasCartStore = /** @class */ (function () {
@@ -70750,7 +70541,9 @@ var IkasCartStore = /** @class */ (function () {
70750
70541
  cartId = ((_b = this.cart) === null || _b === void 0 ? void 0 : _b.id) || localStorage.getItem(CART_LS_KEY);
70751
70542
  if (!cartId && !customerId)
70752
70543
  return [2 /*return*/];
70753
- return [4 /*yield*/, IkasCartAPI.getCart(cartId || undefined)];
70544
+ return [4 /*yield*/, IkasCartAPI.getCart(cartId || undefined
70545
+ // customerId || undefined // TODO reopen this when we have a way of telling backend that we cleared a cart
70546
+ )];
70754
70547
  case 2:
70755
70548
  cart = _c.sent();
70756
70549
  if (!cart) return [3 /*break*/, 4];
@@ -70814,89 +70607,28 @@ var IkasCartStore = /** @class */ (function () {
70814
70607
  }
70815
70608
  });
70816
70609
  }); };
70817
- this.findExistingItem = function (variant, product) {
70818
- var _a, _b, _c, _d, _e;
70819
- if (!product.productOptionSetId) {
70820
- return (_a = _this.cart) === null || _a === void 0 ? void 0 : _a.items.find(function (item) { return item.variant.id === variant.id; });
70821
- }
70822
- var existingItems = ((_b = _this.cart) === null || _b === void 0 ? void 0 : _b.items.filter(function (item) { return item.variant.id === variant.id; })) || [];
70823
- for (var _i = 0, existingItems_1 = existingItems; _i < existingItems_1.length; _i++) {
70824
- var item = existingItems_1[_i];
70825
- if (item.options) {
70826
- var hasSameOptionValues = true;
70827
- var _loop_1 = function (option) {
70828
- var existingOptionValues = option.values.map(function (v) { return v.value; });
70829
- var productOptionValues = (_e = (_d = (_c = product.productOptionSet) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.find(function (o) { return o.id === option.productOptionId; })) === null || _e === void 0 ? void 0 : _e.values;
70830
- hasSameOptionValues =
70831
- hasSameOptionValues &&
70832
- existingOptionValues.length === (productOptionValues === null || productOptionValues === void 0 ? void 0 : productOptionValues.values.length) &&
70833
- existingOptionValues.every(function (val) { return productOptionValues === null || productOptionValues === void 0 ? void 0 : productOptionValues.includes(val); });
70834
- if (!hasSameOptionValues)
70835
- return "break";
70836
- };
70837
- for (var _f = 0, _g = item.options; _f < _g.length; _f++) {
70838
- var option = _g[_f];
70839
- var state_1 = _loop_1(option);
70840
- if (state_1 === "break")
70841
- break;
70842
- }
70843
- if (hasSameOptionValues)
70844
- return item;
70845
- }
70846
- }
70847
- };
70848
- this.createCartLineOptions = function (item) {
70849
- if (item && item.options) {
70850
- var options = [];
70851
- for (var _i = 0, _a = item.options; _i < _a.length; _i++) {
70852
- var option = _a[_i];
70853
- var data = new IkasProductCartLineOption({});
70854
- data.productOptionId = option.productOptionId;
70855
- data.productOptionsSetId = option.productOptionsSetId;
70856
- data.values = option.values.map(function (val) { return val.value; });
70857
- options.push(data);
70858
- }
70859
- return options;
70860
- }
70861
- else {
70862
- return null;
70863
- }
70864
- };
70865
70610
  this.addItem = function (variant, product, initialQuantity) {
70866
70611
  if (initialQuantity === void 0) { initialQuantity = 1; }
70867
70612
  return __awaiter(_this, void 0, void 0, function () {
70868
- var existingItem, optionValues_1, cartId, input, cart, eventId, item, err_2;
70869
- var _a, _b, _c, _d, _e;
70870
- return __generator(this, function (_f) {
70871
- switch (_f.label) {
70613
+ var existingItem, cartId, input, cart, eventId, item, err_2;
70614
+ var _a, _b, _c;
70615
+ return __generator(this, function (_d) {
70616
+ switch (_d.label) {
70872
70617
  case 0:
70873
- _f.trys.push([0, 5, , 6]);
70874
- if (!product.canAddToCart)
70875
- return [2 /*return*/, false];
70618
+ _d.trys.push([0, 5, , 6]);
70876
70619
  return [4 /*yield*/, this.beforeCartOperationCheck()];
70877
70620
  case 1:
70878
- _f.sent();
70621
+ _d.sent();
70879
70622
  if (this.cart) {
70880
- existingItem = this.findExistingItem(variant, product);
70623
+ existingItem = this.cart.items.find(function (item) { return item.variant.id === variant.id; });
70881
70624
  if (existingItem) {
70882
- (_a = product.productOptionSet) === null || _a === void 0 ? void 0 : _a.initOptionValues();
70883
70625
  return [2 /*return*/, this.changeItemQuantity(existingItem, existingItem.quantity + 1)];
70884
70626
  }
70885
70627
  }
70886
- optionValues_1 = [];
70887
- (_b = product.productOptionSet) === null || _b === void 0 ? void 0 : _b.options.forEach(function (o) {
70888
- if (o.values.length) {
70889
- optionValues_1.push(new IkasProductCartLineOption({
70890
- productOptionId: o.id,
70891
- productOptionsSetId: o.productOptionSetId,
70892
- values: o.values,
70893
- }));
70894
- }
70895
- });
70896
- cartId = ((_c = this.cart) === null || _c === void 0 ? void 0 : _c.id) || localStorage.getItem(CART_LS_KEY);
70628
+ cartId = ((_a = this.cart) === null || _a === void 0 ? void 0 : _a.id) || localStorage.getItem(CART_LS_KEY);
70897
70629
  input = {
70898
70630
  cartId: cartId,
70899
- customerId: ((_d = this.cart) === null || _d === void 0 ? void 0 : _d.customerId) || ((_e = this.baseStore.customerStore.customer) === null || _e === void 0 ? void 0 : _e.id) ||
70631
+ customerId: ((_b = this.cart) === null || _b === void 0 ? void 0 : _b.customerId) || ((_c = this.baseStore.customerStore.customer) === null || _c === void 0 ? void 0 : _c.id) ||
70900
70632
  null,
70901
70633
  item: {
70902
70634
  id: null,
@@ -70906,7 +70638,6 @@ var IkasCartStore = /** @class */ (function () {
70906
70638
  name: product.name,
70907
70639
  },
70908
70640
  },
70909
- options: optionValues_1.length ? optionValues_1 : null,
70910
70641
  priceListId: IkasStorefrontConfig.priceListId || null,
70911
70642
  salesChannelId: IkasStorefrontConfig.salesChannelId,
70912
70643
  storefrontId: IkasStorefrontConfig.storefrontId,
@@ -70915,12 +70646,12 @@ var IkasCartStore = /** @class */ (function () {
70915
70646
  };
70916
70647
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
70917
70648
  case 2:
70918
- cart = _f.sent();
70649
+ cart = _d.sent();
70919
70650
  if (!cart) return [3 /*break*/, 4];
70920
70651
  return [4 /*yield*/, this.setCart(cart)];
70921
70652
  case 3:
70922
- _f.sent();
70923
- _f.label = 4;
70653
+ _d.sent();
70654
+ _d.label = 4;
70924
70655
  case 4:
70925
70656
  if (this.cart) {
70926
70657
  eventId = this.cart.id + "-" + this.cart.updatedAt;
@@ -70929,11 +70660,11 @@ var IkasCartStore = /** @class */ (function () {
70929
70660
  Analytics.addToCart(item, initialQuantity, eventId, this.cart);
70930
70661
  }
70931
70662
  }
70932
- return [2 /*return*/, true];
70663
+ return [3 /*break*/, 6];
70933
70664
  case 5:
70934
- err_2 = _f.sent();
70665
+ err_2 = _d.sent();
70935
70666
  console.log(err_2);
70936
- return [2 /*return*/, false];
70667
+ return [3 /*break*/, 6];
70937
70668
  case 6: return [2 /*return*/];
70938
70669
  }
70939
70670
  });
@@ -70961,7 +70692,6 @@ var IkasCartStore = /** @class */ (function () {
70961
70692
  name: item.variant.name,
70962
70693
  },
70963
70694
  },
70964
- options: this.createCartLineOptions(item),
70965
70695
  priceListId: IkasStorefrontConfig.priceListId || null,
70966
70696
  salesChannelId: IkasStorefrontConfig.salesChannelId,
70967
70697
  storefrontId: IkasStorefrontConfig.storefrontId,
@@ -70988,11 +70718,11 @@ var IkasCartStore = /** @class */ (function () {
70988
70718
  Analytics.addToCart(item, quantity - oldQuantity, eventId, this.cart);
70989
70719
  }
70990
70720
  }
70991
- return [2 /*return*/, true];
70721
+ return [3 /*break*/, 6];
70992
70722
  case 5:
70993
70723
  err_3 = _d.sent();
70994
70724
  console.log(err_3);
70995
- return [2 /*return*/, false];
70725
+ return [3 /*break*/, 6];
70996
70726
  case 6: return [2 /*return*/];
70997
70727
  }
70998
70728
  });
@@ -1,5 +1,4 @@
1
1
  import { IkasOrderLineItem } from "../order/line-item/index";
2
- import { IkasProductCartLineOption } from "../product-cart-item-options/index";
3
2
  export declare class IkasCart {
4
3
  id: string;
5
4
  createdAt: string;
@@ -41,7 +40,6 @@ export declare type IkasSaveItemToCartInput = {
41
40
  salesChannelId: string;
42
41
  storefrontId: string;
43
42
  storefrontRoutingId: string;
44
- options: IkasProductCartLineOption[] | null;
45
43
  storefrontThemeId: string;
46
44
  };
47
45
  export {};
@@ -1,6 +1,5 @@
1
1
  import { IkasOrderLineDiscount } from "./discount/index";
2
2
  import { IkasOrderLineVariant } from "./variant/index";
3
- import { IkasOrderLineOptions } from "./options/index";
4
3
  export declare class IkasOrderLineItem {
5
4
  id: string;
6
5
  createdAt: string;
@@ -12,7 +11,6 @@ export declare class IkasOrderLineItem {
12
11
  discount?: IkasOrderLineDiscount | null;
13
12
  discountPrice?: number | null;
14
13
  finalPrice: number;
15
- options: IkasOrderLineOptions[] | null;
16
14
  originalOrderLineItemId?: string | null;
17
15
  price: number;
18
16
  quantity: number;
@@ -26,7 +26,6 @@ export declare class IkasProduct {
26
26
  get hasStock(): boolean;
27
27
  get mainVariantType(): import("../index").IkasVariantType | undefined;
28
28
  get href(): string;
29
- get canAddToCart(): boolean;
30
29
  }
31
30
  export declare enum IkasProductType {
32
31
  PHYSICAL = "PHYSICAL",
@@ -3,6 +3,8 @@ export declare enum IkasProductOptionType {
3
3
  CHOICE = "CHOICE",
4
4
  TEXT = "TEXT",
5
5
  TEXT_AREA = "TEXT_AREA",
6
+ IMAGE = "IMAGE",
7
+ FILE = "FILE",
6
8
  COLOR_PICKER = "COLOR_PICKER",
7
9
  CHECKBOX = "CHECKBOX"
8
10
  }
@@ -29,13 +31,12 @@ export declare class IkasProductOptionSetTranslations {
29
31
  constructor(data: Partial<IkasProductOptionSetTranslations>);
30
32
  }
31
33
  export declare class IkasProductOptionSelectValue {
32
- id: string;
33
34
  order: number;
34
35
  value: string;
35
36
  price: number | null;
36
37
  thumbnailImageId: string | null;
37
38
  colorCode: string | null;
38
- thumbnailImage: IkasImage | null;
39
+ thumbnailImage?: IkasImage;
39
40
  constructor(data?: Partial<IkasProductOptionSelectValue>);
40
41
  }
41
42
  export declare class IkasProductOptionSelectSettings {
@@ -62,8 +63,6 @@ export declare class IkasProductOptionFileSettings {
62
63
  constructor(data: Partial<IkasProductOptionFileSettings>);
63
64
  }
64
65
  export declare class IkasProductOption {
65
- id: string;
66
- productOptionSetId: string;
67
66
  name: string;
68
67
  order: number;
69
68
  type: IkasProductOptionType;
@@ -76,25 +75,11 @@ export declare class IkasProductOption {
76
75
  optionalText: string | null;
77
76
  requiredOptionId: string | null;
78
77
  requiredOptionValueIds: string[] | null;
79
- private _values;
80
- childOptions: IkasProductOption[];
81
78
  constructor(data: Partial<IkasProductOption>);
82
- get displayedChildOptions(): IkasProductOption[];
83
- get hasValidValues(): boolean;
84
- get values(): string[];
85
- set values(values: string[]);
86
- initValues: () => void;
87
- private isValidTextOptionValue;
88
- private isValidChoiceOptionValue;
89
79
  }
90
80
  export declare class IkasProductOptionSet {
91
- id: string;
92
81
  name: string;
93
82
  options: IkasProductOption[];
94
83
  translations: IkasProductOptionSetTranslations[] | null;
95
84
  constructor(data: Partial<IkasProductOptionSet>);
96
- get displayedOptions(): IkasProductOption[];
97
- private setTranslations;
98
- private setChildOptions;
99
- initOptionValues: () => Promise<void>;
100
85
  }