@delicity/client-cart 1.0.0 → 1.1.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/classes/Cart.d.ts +29 -0
- package/classes/Cart.d.ts.map +1 -0
- package/classes/Cart.js +93 -0
- package/classes/Cart.js.map +1 -0
- package/index.d.ts +1 -34
- package/index.d.ts.map +1 -1
- package/index.js +15 -45
- package/index.js.map +1 -1
- package/package.json +8 -6
- package/service/CartService.d.ts +8 -8
- package/service/CartService.d.ts.map +1 -1
- package/service/CartService.js +74 -86
- package/service/CartService.js.map +1 -1
- package/service/CartItemService.d.ts +0 -13
- package/service/CartItemService.d.ts.map +0 -1
- package/service/CartItemService.js +0 -180
- package/service/CartItemService.js.map +0 -1
- package/types/CartType.d.ts +0 -16
- package/types/CartType.d.ts.map +0 -1
- package/types/CartType.js +0 -3
- package/types/CartType.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ICart, ICartItem, ICartModifierGroup, IClientConfig, Menu, MenuItem, Merchant, OrderModesEnum } from "@delicity/client-types";
|
|
2
|
+
export interface CartClass {
|
|
3
|
+
addToCart(item: MenuItem, modifierGroup: ICartModifierGroup[], quantity: number): Cart;
|
|
4
|
+
updateCart(cartItem: ICartItem, modifierGroup: ICartModifierGroup[], quantity: number): Cart;
|
|
5
|
+
removeFromCart(cartItem: ICartItem): Cart;
|
|
6
|
+
getCart(): ICart;
|
|
7
|
+
getItems(): ICartItem[];
|
|
8
|
+
getTotalItems(): number;
|
|
9
|
+
getTotalItemPrice(): number;
|
|
10
|
+
}
|
|
11
|
+
export declare class Cart implements CartClass {
|
|
12
|
+
private cart;
|
|
13
|
+
private merchant;
|
|
14
|
+
private menu;
|
|
15
|
+
private when;
|
|
16
|
+
private config;
|
|
17
|
+
constructor(config: IClientConfig, merchant: Merchant, menu: Menu, OrderMode: OrderModesEnum, when: string | null);
|
|
18
|
+
setWhen(when: string | null): void;
|
|
19
|
+
setNow(): void;
|
|
20
|
+
addToCart(item: MenuItem, modifierGroups: ICartModifierGroup[], quantity: number): Cart;
|
|
21
|
+
removeFromCart(cartItem: ICartItem): Cart;
|
|
22
|
+
updateCart(cartItem: ICartItem, modifierGroup: ICartModifierGroup[], quantity: number): Cart;
|
|
23
|
+
getCart(): ICart;
|
|
24
|
+
getItems(): ICartItem[];
|
|
25
|
+
getTotalItems(): number;
|
|
26
|
+
getTotalItemPrice(): number;
|
|
27
|
+
validateCart(): Promise<any>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Cart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cart.d.ts","sourceRoot":"","sources":["../../src/classes/Cart.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,SAAS,EACT,kBAAkB,EAClB,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,cAAc,EACjB,MAAM,wBAAwB,CAAC;AAUhC,MAAM,WAAW,SAAS;IACtB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAC,MAAM,GAAG,IAAI,CAAA;IACpF,UAAU,CAAC,QAAQ,EAAC,SAAS,EAAE,aAAa,EAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAC,MAAM,GAAG,IAAI,CAAA;IACzF,cAAc,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAA;IACzC,OAAO,IAAI,KAAK,CAAA;IAChB,QAAQ,IAAI,SAAS,EAAE,CAAA;IACvB,aAAa,IAAI,MAAM,CAAA;IACvB,iBAAiB,IAAI,MAAM,CAAA;CAC9B;AAED,qBAAa,IAAK,YAAW,SAAS;IAClC,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAC,IAAI;IAc/G,OAAO,CAAC,IAAI,EAAC,MAAM,GAAC,IAAI;IAIxB,MAAM;IAIN,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IA+BtF,cAAc,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI;IAOzC,UAAU,CAAC,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK3F,OAAO,IAAI,KAAK;IAGhB,QAAQ,IAAI,SAAS,EAAE;IAGvB,aAAa,IAAI,MAAM;IAGvB,iBAAiB,IAAI,MAAM;IAIrB,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC;CAGrC"}
|
package/classes/Cart.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Cart = void 0;
|
|
13
|
+
const uuid_1 = require("uuid");
|
|
14
|
+
const CartService_1 = require("@/service/CartService");
|
|
15
|
+
class Cart {
|
|
16
|
+
constructor(config, merchant, menu, OrderMode, when) {
|
|
17
|
+
this.merchant = merchant;
|
|
18
|
+
this.menu = menu;
|
|
19
|
+
this.when = when;
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.cart = {
|
|
22
|
+
items: [],
|
|
23
|
+
totalItems: 0,
|
|
24
|
+
totalItemPrice: 0,
|
|
25
|
+
when: null,
|
|
26
|
+
type: OrderMode,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
setWhen(when) {
|
|
30
|
+
// @todo check if when is ok ?
|
|
31
|
+
this.when = when;
|
|
32
|
+
}
|
|
33
|
+
setNow() {
|
|
34
|
+
this.when = null;
|
|
35
|
+
}
|
|
36
|
+
addToCart(item, modifierGroups, quantity) {
|
|
37
|
+
// Check if item have mandatory modifiers
|
|
38
|
+
if (!(0, CartService_1.mandatoryModifierCheck)(item, modifierGroups, this.menu)) {
|
|
39
|
+
throw new Error('mandatory_field_missing');
|
|
40
|
+
}
|
|
41
|
+
// Check if item is available
|
|
42
|
+
if (!(0, CartService_1.isItemAvailable)(item, this.menu)) {
|
|
43
|
+
throw new Error('item_not_available');
|
|
44
|
+
}
|
|
45
|
+
const index = (0, CartService_1.isItemAlreadyInCart)(item, modifierGroups, this.cart);
|
|
46
|
+
if (index !== -1) {
|
|
47
|
+
this.cart.items[index].quantity += quantity;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const cartItem = {
|
|
51
|
+
uuid: (0, uuid_1.v4)(),
|
|
52
|
+
item,
|
|
53
|
+
modifierGroups,
|
|
54
|
+
quantity,
|
|
55
|
+
unitPrice: (0, CartService_1.getProductPrice)(item, this.cart.type),
|
|
56
|
+
totalPrice: (0, CartService_1.getProductPrice)(item, this.cart.type) * quantity
|
|
57
|
+
};
|
|
58
|
+
this.cart.items.push(cartItem);
|
|
59
|
+
}
|
|
60
|
+
this.cart.totalItems = (0, CartService_1.getProductCount)(this.cart);
|
|
61
|
+
this.cart.totalItemPrice = (0, CartService_1.getProductPriceSum)(this.cart);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
removeFromCart(cartItem) {
|
|
65
|
+
this.cart.items = this.cart.items.filter((item) => item.uuid !== cartItem.uuid);
|
|
66
|
+
this.cart.totalItems = (0, CartService_1.getProductCount)(this.cart);
|
|
67
|
+
this.cart.totalItemPrice = (0, CartService_1.getProductPriceSum)(this.cart);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
updateCart(cartItem, modifierGroup, quantity) {
|
|
71
|
+
this.removeFromCart(cartItem);
|
|
72
|
+
return this.addToCart(cartItem.item, modifierGroup, quantity);
|
|
73
|
+
}
|
|
74
|
+
getCart() {
|
|
75
|
+
return this.cart;
|
|
76
|
+
}
|
|
77
|
+
getItems() {
|
|
78
|
+
return this.cart.items;
|
|
79
|
+
}
|
|
80
|
+
getTotalItems() {
|
|
81
|
+
return this.cart.totalItems;
|
|
82
|
+
}
|
|
83
|
+
getTotalItemPrice() {
|
|
84
|
+
return this.cart.totalItemPrice;
|
|
85
|
+
}
|
|
86
|
+
validateCart() {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
return (0, CartService_1.validateCart)(this.config, this.cart, this.merchant.id);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.Cart = Cart;
|
|
93
|
+
//# sourceMappingURL=Cart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cart.js","sourceRoot":"","sources":["../../src/classes/Cart.ts"],"names":[],"mappings":";;;;;;;;;;;;AAUA,+BAAoC;AACpC,uDAM+B;AAY/B,MAAa,IAAI;IAOb,YAAY,MAAqB,EAAE,QAAkB,EAAE,IAAU,EAAE,SAAyB,EAAE,IAAiB;QAC3G,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG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AC;IACpC,CAAC;IAEK,YAAY;;YACd,OAAO,IAAA,0BAAY,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;KAAA;CACJ;AAxFD,oBAwFC"}
|
package/index.d.ts
CHANGED
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { IMenu } from "@delicity/client-types/Merchant/Menu";
|
|
3
|
-
import { IClientConfig, OrderModesEnum } from "@delicity/client-types/Global";
|
|
4
|
-
import { ICartReturn } from "@/types/CartType";
|
|
5
|
-
export interface ICartInterface {
|
|
6
|
-
getConfig(): IClientConfig;
|
|
7
|
-
setMerchantMenu(merchantMenu: IMenu): Promise<ICartReturn>;
|
|
8
|
-
setOrderTime(when: number | null): Promise<ICartReturn>;
|
|
9
|
-
setOrderType(type: OrderModesEnum): Promise<ICartReturn>;
|
|
10
|
-
setDeliveryAddress(addressUuid: string): Promise<ICartReturn>;
|
|
11
|
-
addCartItem(item: ICartItem): Promise<ICartReturn>;
|
|
12
|
-
removeCartItem(uuid: string): Promise<ICartReturn>;
|
|
13
|
-
updateCartItem(uuid: string, item: ICartItem): Promise<ICartReturn>;
|
|
14
|
-
publishCart(): Promise<any>;
|
|
15
|
-
}
|
|
16
|
-
export declare class Cart implements ICartInterface {
|
|
17
|
-
protected config: IClientConfig;
|
|
18
|
-
merchantUid: string | number;
|
|
19
|
-
merchantMenu: IMenu;
|
|
20
|
-
items: ICartItem[];
|
|
21
|
-
when: number | null;
|
|
22
|
-
addressUuid: string | null;
|
|
23
|
-
type: OrderModesEnum | null;
|
|
24
|
-
constructor(config: IClientConfig, merchantUid: string | number, merchantMenu: IMenu);
|
|
25
|
-
getConfig(): IClientConfig;
|
|
26
|
-
setMerchantMenu(merchantMenu: IMenu): Promise<ICartReturn>;
|
|
27
|
-
setOrderTime(when: number | null): Promise<ICartReturn>;
|
|
28
|
-
setOrderType(type: OrderModesEnum): Promise<ICartReturn>;
|
|
29
|
-
setDeliveryAddress(addressUuid: string): Promise<ICartReturn>;
|
|
30
|
-
addCartItem(item: ICartItem): Promise<ICartReturn>;
|
|
31
|
-
removeCartItem(uuid: string): Promise<ICartReturn>;
|
|
32
|
-
updateCartItem(uuid: string, item: ICartItem): Promise<ICartReturn>;
|
|
33
|
-
publishCart(): Promise<any>;
|
|
34
|
-
}
|
|
1
|
+
export * from './classes/Cart';
|
|
35
2
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
|
package/index.js
CHANGED
|
@@ -1,48 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const CartService_1 = require("@/service/CartService");
|
|
5
|
-
class Cart {
|
|
6
|
-
constructor(config, merchantUid, merchantMenu) {
|
|
7
|
-
this.items = [];
|
|
8
|
-
this.when = null;
|
|
9
|
-
this.addressUuid = null;
|
|
10
|
-
this.type = null;
|
|
11
|
-
this.config = config;
|
|
12
|
-
this.merchantUid = merchantUid;
|
|
13
|
-
this.merchantMenu = merchantMenu;
|
|
14
|
-
}
|
|
15
|
-
getConfig() {
|
|
16
|
-
return this.config;
|
|
17
|
-
}
|
|
18
|
-
setMerchantMenu(merchantMenu) {
|
|
19
|
-
this.merchantMenu = merchantMenu;
|
|
20
|
-
return (0, CartService_1.updateCart)(this);
|
|
21
|
-
}
|
|
22
|
-
setOrderTime(when) {
|
|
23
|
-
this.when = when;
|
|
24
|
-
return (0, CartService_1.updateCart)(this);
|
|
25
|
-
}
|
|
26
|
-
setOrderType(type) {
|
|
27
|
-
this.type = type;
|
|
28
|
-
return (0, CartService_1.updateCart)(this);
|
|
29
|
-
}
|
|
30
|
-
setDeliveryAddress(addressUuid) {
|
|
31
|
-
this.addressUuid = addressUuid;
|
|
32
|
-
return (0, CartService_1.updateCart)(this);
|
|
33
|
-
}
|
|
34
|
-
addCartItem(item) {
|
|
35
|
-
return (0, CartService_1.addToCart)(this, item);
|
|
36
|
-
}
|
|
37
|
-
removeCartItem(uuid) {
|
|
38
|
-
return (0, CartService_1.removeCartItem)(this, uuid);
|
|
39
|
-
}
|
|
40
|
-
updateCartItem(uuid, item) {
|
|
41
|
-
return (0, CartService_1.updateCartItem)(this, uuid, item);
|
|
42
|
-
}
|
|
43
|
-
publishCart() {
|
|
44
|
-
return (0, CartService_1.publishCart)(this);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.Cart = Cart;
|
|
17
|
+
__exportStar(require("./classes/Cart"), exports);
|
|
48
18
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delicity/client-cart",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Cart Client Package",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"build": "npx tsc",
|
|
9
|
-
"pub": "npx tsc && cp package.json dist/package.json && cd dist/"
|
|
9
|
+
"pub": "npx tsc && cp package.json dist/package.json && cd dist/ && npm publish && cd ../ && rm -rf dist/"
|
|
10
10
|
},
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@jest/globals": "^29.3.1",
|
|
15
|
+
"@types/uuid": "^9.0.4",
|
|
15
16
|
"jest": "^29.3.1",
|
|
16
17
|
"ts-jest": "^29.0.5",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
18
|
+
"ts-node": "^10.9.1",
|
|
19
|
+
"typescript": "^4.9.4"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
22
|
+
"@delicity/client-types": "^2.0.2",
|
|
23
|
+
"axios": "^1.5.1",
|
|
24
|
+
"uuid": "^9.0.1"
|
|
23
25
|
}
|
|
24
26
|
}
|
package/service/CartService.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
1
|
+
import { ICart, ICartModifierGroup, IClientConfig, Menu, MenuItem, OrderModesEnum } from "@delicity/client-types";
|
|
2
|
+
export declare function getProductPriceSum(cart: ICart): number;
|
|
3
|
+
export declare function getProductCount(cart: ICart): number;
|
|
4
|
+
export declare function mandatoryModifierCheck(item: MenuItem, cartModifier: ICartModifierGroup[], menu: Menu): boolean;
|
|
5
|
+
export declare function isItemAvailable(item: MenuItem, menu: Menu): boolean;
|
|
6
|
+
export declare function getProductPrice(item: MenuItem, mode: OrderModesEnum): number;
|
|
7
|
+
export declare function isItemAlreadyInCart(item: MenuItem, modifierGroups: ICartModifierGroup[], cart: ICart): number;
|
|
8
|
+
export declare function validateCart(config: IClientConfig, cart: ICart, merchantId: number): Promise<unknown>;
|
|
9
9
|
//# sourceMappingURL=CartService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartService.d.ts","sourceRoot":"","sources":["../../src/service/CartService.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CartService.d.ts","sourceRoot":"","sources":["../../src/service/CartService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAGhH,wBAAgB,kBAAkB,CAAC,IAAI,EAAC,KAAK,GAAG,MAAM,CAErD;AACD,wBAAgB,eAAe,CAAC,IAAI,EAAC,KAAK,GAAG,MAAM,CAElD;AAGD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAgB9G;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,WAEzD;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAC,QAAQ,EAAE,IAAI,EAAC,cAAc,GAAG,MAAM,CAiB1E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAC,QAAQ,EAAE,cAAc,EAAC,kBAAkB,EAAE,EAAE,IAAI,EAAC,KAAK,GAAG,MAAM,CAmB1G;AAGD,wBAAgB,YAAY,CAAC,MAAM,EAAC,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAUjF"}
|
package/service/CartService.js
CHANGED
|
@@ -1,98 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const axios_1 = __importDefault(require("axios"));
|
|
19
|
-
function addToCart(cart, item) {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
(0, CartItemService_1.checkItemHierarchy)([item], cart.merchantMenu)
|
|
22
|
-
.then(() => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
cart.items.push(item);
|
|
24
|
-
resolve(yield updateCart(cart));
|
|
25
|
-
}))
|
|
26
|
-
.catch((e) => {
|
|
27
|
-
reject(e);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
3
|
+
exports.validateCart = exports.isItemAlreadyInCart = exports.getProductPrice = exports.isItemAvailable = exports.mandatoryModifierCheck = exports.getProductCount = exports.getProductPriceSum = void 0;
|
|
4
|
+
function getProductPriceSum(cart) {
|
|
5
|
+
return cart.items.reduce((acc, item) => acc + item.totalPrice, 0);
|
|
30
6
|
}
|
|
31
|
-
exports.
|
|
32
|
-
function
|
|
33
|
-
cart.items.
|
|
34
|
-
return updateCart(cart);
|
|
7
|
+
exports.getProductPriceSum = getProductPriceSum;
|
|
8
|
+
function getProductCount(cart) {
|
|
9
|
+
return cart.items.reduce((acc, item) => acc + item.quantity, 0);
|
|
35
10
|
}
|
|
36
|
-
exports.
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
11
|
+
exports.getProductCount = getProductCount;
|
|
12
|
+
function mandatoryModifierCheck(item, cartModifier, menu) {
|
|
13
|
+
if (!item.children)
|
|
14
|
+
return true;
|
|
15
|
+
// get all mandatory modifiers in this item.
|
|
16
|
+
const modifierGroups = menu.modifierGroups.filter((m) => { var _a; return ((_a = item.children) === null || _a === void 0 ? void 0 : _a.includes(m.uid)) && m.min > 0 && m.min; });
|
|
17
|
+
for (let modifier of modifierGroups) {
|
|
18
|
+
const m = cartModifier.find((m) => m.item.uid === modifier.uid);
|
|
19
|
+
if (!m)
|
|
20
|
+
return false;
|
|
21
|
+
if (modifier.min === null)
|
|
22
|
+
continue;
|
|
23
|
+
const selectedOption = m.modifiers.reduce((acc, m) => acc + m.quantity, 0);
|
|
24
|
+
if (selectedOption < modifier.min)
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
40
28
|
}
|
|
41
|
-
exports.
|
|
42
|
-
function
|
|
43
|
-
return
|
|
44
|
-
const cartErrors = [];
|
|
45
|
-
const itemsErrors = [];
|
|
46
|
-
if (cart.type === null) {
|
|
47
|
-
cartErrors.push(CartErrors_1.CartErrorEnum.TYPE_NOT_SET);
|
|
48
|
-
}
|
|
49
|
-
if (!cart.addressUuid) {
|
|
50
|
-
cartErrors.push(CartErrors_1.CartErrorEnum.ADDRESS_NOT_SET);
|
|
51
|
-
}
|
|
52
|
-
// Check items availabilities
|
|
53
|
-
yield (0, CartItemService_1.isItemInCartAvailable)(cart)
|
|
54
|
-
.catch((e) => {
|
|
55
|
-
itemsErrors.push(...e.errors);
|
|
56
|
-
});
|
|
57
|
-
const accumulator = (0, CartItemService_1.productTotalAccumulator)(cart);
|
|
58
|
-
const data = {
|
|
59
|
-
items: cart.items,
|
|
60
|
-
addressUuid: cart.addressUuid,
|
|
61
|
-
when: cart.when,
|
|
62
|
-
currency: "eur",
|
|
63
|
-
merchantUid: cart.merchantUid,
|
|
64
|
-
productPrice: accumulator.productPrice,
|
|
65
|
-
type: cart.type,
|
|
66
|
-
errors: {
|
|
67
|
-
menu: itemsErrors,
|
|
68
|
-
cart: cartErrors
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
resolve(data);
|
|
72
|
-
}));
|
|
29
|
+
exports.mandatoryModifierCheck = mandatoryModifierCheck;
|
|
30
|
+
function isItemAvailable(item, menu) {
|
|
31
|
+
return item.unavailable !== true;
|
|
73
32
|
}
|
|
74
|
-
exports.
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
33
|
+
exports.isItemAvailable = isItemAvailable;
|
|
34
|
+
function getProductPrice(item, mode) {
|
|
35
|
+
if (!item.price) {
|
|
36
|
+
throw new Error('price_not_set');
|
|
37
|
+
}
|
|
38
|
+
if (typeof item.price === 'number') {
|
|
39
|
+
return item.price;
|
|
40
|
+
}
|
|
41
|
+
if (mode === 'delivery') {
|
|
42
|
+
return item.price.delivery;
|
|
43
|
+
}
|
|
44
|
+
else if (mode === 'pickup') {
|
|
45
|
+
return item.price.pickup;
|
|
46
|
+
}
|
|
47
|
+
else if (mode === 'on_site_counter') {
|
|
48
|
+
return item.price.onsite;
|
|
49
|
+
}
|
|
50
|
+
return item.price.delivery;
|
|
51
|
+
}
|
|
52
|
+
exports.getProductPrice = getProductPrice;
|
|
53
|
+
function isItemAlreadyInCart(item, modifierGroups, cart) {
|
|
54
|
+
// Check if item is already in cart
|
|
55
|
+
const sameCartProducts = cart.items
|
|
56
|
+
.filter((i) => i.item.uid === item.uid)
|
|
57
|
+
.filter((c) => {
|
|
58
|
+
if (c.modifierGroups.length !== modifierGroups.length)
|
|
59
|
+
return false;
|
|
60
|
+
const newItemModifierGroupsKey = modifierGroups.flatMap((m) => {
|
|
61
|
+
return m.modifiers.map((o) => { return { id: o.item.id, quantity: o.quantity }; });
|
|
62
|
+
}).sort((a, b) => a.id - b.id).map((m) => m.id + ':' + m.quantity).join('|');
|
|
63
|
+
const CartItemModifierGroupsKey = c.modifierGroups.flatMap((m) => {
|
|
64
|
+
return m.modifiers.map((o) => { return { id: o.item.id, quantity: o.quantity }; });
|
|
65
|
+
}).sort((a, b) => a.id - b.id).map((m) => m.id + ':' + m.quantity).join('|');
|
|
66
|
+
return newItemModifierGroupsKey === CartItemModifierGroupsKey;
|
|
67
|
+
});
|
|
68
|
+
// If not existing in cart, return -1
|
|
69
|
+
if (sameCartProducts.length === 0)
|
|
70
|
+
return -1;
|
|
71
|
+
return cart.items.findIndex((c) => c.uuid === sameCartProducts[0].uuid);
|
|
72
|
+
}
|
|
73
|
+
exports.isItemAlreadyInCart = isItemAlreadyInCart;
|
|
74
|
+
function validateCart(config, cart, merchantId) {
|
|
75
|
+
return new Promise(((resolve, reject) => {
|
|
76
|
+
config.axiosClient.post(config.apiUrl + '/v1/client/cart/create', { merchantId, cart })
|
|
89
77
|
.then((response) => {
|
|
90
78
|
resolve(response.data);
|
|
91
79
|
})
|
|
92
|
-
.catch((
|
|
93
|
-
reject(
|
|
80
|
+
.catch((error) => {
|
|
81
|
+
reject(error);
|
|
94
82
|
});
|
|
95
|
-
});
|
|
83
|
+
}));
|
|
96
84
|
}
|
|
97
|
-
exports.
|
|
85
|
+
exports.validateCart = validateCart;
|
|
98
86
|
//# sourceMappingURL=CartService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartService.js","sourceRoot":"","sources":["../../src/service/CartService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CartService.js","sourceRoot":"","sources":["../../src/service/CartService.ts"],"names":[],"mappings":";;;AAGA,SAAgB,kBAAkB,CAAC,IAAU;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AACtE,CAAC;AAFD,gDAEC;AACD,SAAgB,eAAe,CAAC,IAAU;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,0CAEC;AAGD,SAAgB,sBAAsB,CAAC,IAAc,EAAE,YAAkC,EAAE,IAAU;IACjG,IAAG,CAAC,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE/B,4CAA4C;IAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAK,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAI,CAAC,CAAC,GAAG,GAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAA,EAAA,CAAC,CAAC;IAEjH,KAAI,IAAI,QAAQ,IAAI,cAAc,EAAC;QAC/B,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC;QACpE,IAAG,CAAC,CAAC;YA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AAE,GAAG,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7E,OAAO,wBAAwB,KAAK,yBAAyB,CAAC;IAClE,CAAC,CAAC,CAAA;IAEN,qCAAqC;IACrC,IAAG,gBAAgB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IAE5C,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;AAnBD,kDAmBC;AAGD,SAAgB,YAAY,CAAC,MAAoB,EAAE,IAAW,EAAE,UAAkB;IAC9E,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAC,wBAAwB,EAAE,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC;aAC9E,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACf,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,CAAC,CAAA;IACV,CAAC,CAAC,CAAC,CAAC;AACR,CAAC;AAVD,oCAUC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Cart } from "@/index";
|
|
2
|
-
import { ICartItem } from "@delicity/client-types/Cart/CartRequest";
|
|
3
|
-
import { IMenu } from "@delicity/client-types/Merchant/Menu";
|
|
4
|
-
interface IProductTotalAccumulator {
|
|
5
|
-
productPrice: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function productTotalAccumulator(cart: Cart): IProductTotalAccumulator;
|
|
8
|
-
export declare function isItemAvailable(item: ICartItem, cart: Cart): Promise<boolean>;
|
|
9
|
-
export declare function isItemInCartAvailable(cart: Cart): Promise<boolean>;
|
|
10
|
-
export declare function checkItemHierarchy(items: ICartItem[], menu: IMenu): Promise<any>;
|
|
11
|
-
export declare function checkItem(item: ICartItem, menu: IMenu, parentItem?: ICartItem | null): Promise<boolean>;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=CartItemService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CartItemService.d.ts","sourceRoot":"","sources":["../../src/service/CartItemService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,SAAS,CAAC;AAI7B,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAC;AAClE,OAAO,EAAC,KAAK,EAAgB,MAAM,sCAAsC,CAAC;AAE1E,UAAU,wBAAwB;IAC9B,YAAY,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,wBAAwB,CAQ5E;AAwCD,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CA0B7E;AAGD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBlE;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAqBhF;AAID,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAC,SAAS,GAAC,IAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CA2DxG"}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.checkItem = exports.checkItemHierarchy = exports.isItemInCartAvailable = exports.isItemAvailable = exports.productTotalAccumulator = void 0;
|
|
13
|
-
const CartErrors_1 = require("@delicity/client-types/Cart/CartErrors");
|
|
14
|
-
const Global_1 = require("@delicity/client-types/Global");
|
|
15
|
-
const Menu_1 = require("@delicity/client-types/Merchant/Menu");
|
|
16
|
-
function productTotalAccumulator(cart) {
|
|
17
|
-
let totalPriceProduct = 0;
|
|
18
|
-
cart.items.forEach((item) => {
|
|
19
|
-
var _a;
|
|
20
|
-
totalPriceProduct += getPrice(cart.merchantMenu, item, (_a = cart.type) !== null && _a !== void 0 ? _a : Global_1.OrderModesEnum.DELIVERY);
|
|
21
|
-
});
|
|
22
|
-
return {
|
|
23
|
-
productPrice: totalPriceProduct
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.productTotalAccumulator = productTotalAccumulator;
|
|
27
|
-
function getPrice(menu, item, type) {
|
|
28
|
-
var _a;
|
|
29
|
-
let price = 0;
|
|
30
|
-
let itemPrices;
|
|
31
|
-
itemPrices = (_a = getMenuItem(item, menu)) === null || _a === void 0 ? void 0 : _a.prices;
|
|
32
|
-
if (itemPrices && type && itemPrices[type] !== undefined) {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
price += itemPrices[type];
|
|
35
|
-
}
|
|
36
|
-
if (item.subItems.length > 0) {
|
|
37
|
-
item.subItems.forEach((subItem) => {
|
|
38
|
-
price += getPrice(menu, subItem, type);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return price;
|
|
42
|
-
}
|
|
43
|
-
function getMenuItem(item, menu) {
|
|
44
|
-
if (item.type === Menu_1.TMenuItemEnum.PRODUCT) {
|
|
45
|
-
return menu.products.find((m) => m.uuid === item.uuid);
|
|
46
|
-
}
|
|
47
|
-
else if (item.type === Menu_1.TMenuItemEnum.MODIFIER) {
|
|
48
|
-
return menu.modifiers.find((m) => m.uuid === item.uuid);
|
|
49
|
-
}
|
|
50
|
-
else if (item.type === Menu_1.TMenuItemEnum.BUNDLE) {
|
|
51
|
-
return menu.bundles.find((m) => m.uuid === item.uuid);
|
|
52
|
-
}
|
|
53
|
-
else if (item.type === Menu_1.TMenuItemEnum.MODIFIER_GROUP) {
|
|
54
|
-
return menu.modifierGroups.find((m) => m.uuid === item.uuid);
|
|
55
|
-
}
|
|
56
|
-
else if (item.type === Menu_1.TMenuItemEnum.CATEGORY) {
|
|
57
|
-
return menu.categories.find((m) => m.uuid === item.uuid);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function isItemAvailable(item, cart) {
|
|
61
|
-
return new Promise((resolve, reject) => {
|
|
62
|
-
var _a;
|
|
63
|
-
const menuItem = getMenuItem(item, cart.merchantMenu);
|
|
64
|
-
const errors = [];
|
|
65
|
-
const itemErrors = [];
|
|
66
|
-
if (!menuItem) {
|
|
67
|
-
itemErrors.push(CartErrors_1.CartErrorEnum.ITEM_NOT_FOUND);
|
|
68
|
-
}
|
|
69
|
-
// Check available when order is set ?
|
|
70
|
-
if (menuItem && menuItem.unavailableUntil && menuItem.unavailableUntil > ((_a = cart.when) !== null && _a !== void 0 ? _a : Math.round((new Date()).getTime() / 1000))) {
|
|
71
|
-
itemErrors.push(CartErrors_1.CartErrorEnum.ITEM_NOT_AVAILABLE_AT_THIS_TIME);
|
|
72
|
-
}
|
|
73
|
-
// Check if product are available at this type
|
|
74
|
-
if (menuItem && cart.type && !menuItem.allowedModes.includes(cart.type)) {
|
|
75
|
-
itemErrors.push(CartErrors_1.CartErrorEnum.ITEM_NOT_AVAILABLE_ON_THIS_TYPE);
|
|
76
|
-
}
|
|
77
|
-
if (itemErrors.length > 0) {
|
|
78
|
-
errors.push({ errors: itemErrors, uuid: item.uuid, type: item.type });
|
|
79
|
-
reject(errors);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
resolve(true);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
exports.isItemAvailable = isItemAvailable;
|
|
87
|
-
function isItemInCartAvailable(cart) {
|
|
88
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
const itemsErrors = [];
|
|
90
|
-
const checkProductPromises = [];
|
|
91
|
-
cart.items.forEach((item) => {
|
|
92
|
-
checkProductPromises.push(isItemAvailable(item, cart));
|
|
93
|
-
});
|
|
94
|
-
yield Promise.allSettled(checkProductPromises)
|
|
95
|
-
.then((results) => {
|
|
96
|
-
if (results.length > 0 && results[0].status === 'rejected') {
|
|
97
|
-
itemsErrors.push(...results[0].reason);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
if (itemsErrors.length > 0) {
|
|
101
|
-
return reject({ errors: itemsErrors });
|
|
102
|
-
}
|
|
103
|
-
resolve(true);
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
exports.isItemInCartAvailable = isItemInCartAvailable;
|
|
107
|
-
function checkItemHierarchy(items, menu) {
|
|
108
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
const errorsBag = [];
|
|
110
|
-
const promises = [];
|
|
111
|
-
items.forEach((item) => {
|
|
112
|
-
promises.push(checkItem(item, menu));
|
|
113
|
-
});
|
|
114
|
-
yield Promise.allSettled(promises)
|
|
115
|
-
.then((results) => {
|
|
116
|
-
if (results.length > 0 && results[0].status === 'rejected') {
|
|
117
|
-
errorsBag.push(...results[0].reason);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
if (errorsBag.length > 0) {
|
|
121
|
-
return reject(errorsBag);
|
|
122
|
-
}
|
|
123
|
-
resolve(true);
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
exports.checkItemHierarchy = checkItemHierarchy;
|
|
127
|
-
function checkItem(item, menu, parentItem = null) {
|
|
128
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
const errors = [];
|
|
130
|
-
if (!getMenuItem(item, menu)) {
|
|
131
|
-
errors.push(CartErrors_1.CartErrorEnum.ITEM_NOT_FOUND);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
if (parentItem) {
|
|
135
|
-
const parentMenu = getMenuItem(parentItem, menu);
|
|
136
|
-
if (item.type === Menu_1.TMenuItemEnum.BUNDLE) {
|
|
137
|
-
if (parentMenu && !parentMenu.subItemsUUIDs.includes(item.uuid)) {
|
|
138
|
-
errors.push(CartErrors_1.CartErrorEnum.ITEM_NOT_ALLOWED);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else if (item.type === Menu_1.TMenuItemEnum.MODIFIER) {
|
|
142
|
-
// check if CartProduct -> CartValue === menuProduct -> menuModifierGroup -> menuModifier
|
|
143
|
-
if (!menu.modifierGroups.some((modifierGroup) => {
|
|
144
|
-
return modifierGroup.subItemsUUIDs.includes(item.uuid)
|
|
145
|
-
&& menu.products.some(p => {
|
|
146
|
-
return p.subItemsUUIDs.includes(modifierGroup.uuid) && p.uuid === parentItem.uuid;
|
|
147
|
-
});
|
|
148
|
-
})) {
|
|
149
|
-
errors.push(CartErrors_1.CartErrorEnum.ITEM_NOT_ALLOWED);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
const childErrors = [];
|
|
155
|
-
const promises = [];
|
|
156
|
-
if (item.subItems.length > 0) {
|
|
157
|
-
item.subItems.forEach((subItem) => {
|
|
158
|
-
promises.push(checkItem(subItem, menu, item));
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
yield Promise.allSettled(promises)
|
|
162
|
-
.then((results) => {
|
|
163
|
-
if (results.length > 0 && results[0].status === 'rejected') {
|
|
164
|
-
childErrors.push(...results[0].reason);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
if (errors.length > 0 || childErrors.length > 0) {
|
|
168
|
-
if (errors.length > 0) {
|
|
169
|
-
const itemErrors = { errors, uuid: item.uuid, type: item.type };
|
|
170
|
-
reject([itemErrors, ...childErrors]);
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
reject(childErrors);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
resolve(true);
|
|
177
|
-
}));
|
|
178
|
-
}
|
|
179
|
-
exports.checkItem = checkItem;
|
|
180
|
-
//# sourceMappingURL=CartItemService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CartItemService.js","sourceRoot":"","sources":["../../src/service/CartItemService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,uEAAqE;AACrE,0DAA6D;AAE7D,+DAA0E;AAM1E,SAAgB,uBAAuB,CAAC,IAAU;IAC9C,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;QACxB,iBAAiB,IAAI,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,MAAA,IAAI,CAAC,IAAI,mCAAI,uBAAc,CAAC,QAAQ,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;IACH,OAAO;QACH,YAAY,EAAC,iBAAiB;KACjC,CAAC;AACN,CAAC;AARD,0DAQC;AAED,SAAS,QAAQ,CAAC,IAAW,EAAE,IAAe,EAAE,IAAyB;;IACrE,IAAI,KAAK,GAAQ,CAAC,CAAC;IACnB,IAAI,UAAU,CAAC;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AM,KAAK,UAAU,EAAC;gBACtD,WAAW,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;aAC1C;QACL,CAAC,CAAC,CAAC;QAEP,IAAG,MAAM,CAAC,MAAM,GAAC,CAAC,IAAI,WAAW,CAAC,MAAM,GAAC,CAAC,EAAC;YACvC,IAAG,MAAM,CAAC,MAAM,GAAC,CAAC,EAAC;gBACf,MAAM,UAAU,GAAkB,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAC,CAAC;gBAC7E,MAAM,CAAC,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;aACxC;iBACG;gBACA,MAAM,CAAC,WAAW,CAAC,CAAC;aACvB;SACJ;QACD,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,CAAA,CAAC,CAAC;AACP,CAAC;AA3DD,8BA2DC"}
|
package/types/CartType.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ICartRequest } from "@delicity/client-types/Cart/CartRequest";
|
|
2
|
-
import { TMenuItemEnum } from "@delicity/client-types/Merchant/Menu";
|
|
3
|
-
import { CartErrorEnum } from "@delicity/client-types/Cart/CartErrors";
|
|
4
|
-
export interface ICartMenuError {
|
|
5
|
-
type: TMenuItemEnum;
|
|
6
|
-
uuid: string;
|
|
7
|
-
errors: CartErrorEnum[];
|
|
8
|
-
}
|
|
9
|
-
export interface ICartReturn extends ICartRequest {
|
|
10
|
-
productPrice: number;
|
|
11
|
-
errors: {
|
|
12
|
-
menu: ICartMenuError[];
|
|
13
|
-
cart: CartErrorEnum[];
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=CartType.d.ts.map
|
package/types/CartType.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CartType.d.ts","sourceRoot":"","sources":["../../src/types/CartType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,yCAAyC,CAAC;AACrE,OAAO,EAAC,aAAa,EAAC,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAC,aAAa,EAAC,MAAM,wCAAwC,CAAC;AAGrE,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,EAAE,CAAA;CAC1B;AACD,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE;QACJ,IAAI,EAAE,cAAc,EAAE,CAAC;QACvB,IAAI,EAAE,aAAa,EAAE,CAAA;KACxB,CAAA;CACJ"}
|
package/types/CartType.js
DELETED
package/types/CartType.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CartType.js","sourceRoot":"","sources":["../../src/types/CartType.ts"],"names":[],"mappings":""}
|