rerobe-js-orm 2.5.5 → 2.5.8
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/lib/factories/ChatRoom/ChatRoomFactory.d.ts +1 -1
- package/lib/factories/ChatRoom/ChatRoomFromNewUserSignUp.d.ts +1 -1
- package/lib/factories/ChatRoom/ChatRoomFromNewUserSignUp.js +2 -1
- package/lib/factories/Order/OrderFromFormState.js +6 -0
- package/lib/form-states/Product/options.js +1 -1
- package/lib/helpers/OrderHelpers.d.ts +4 -0
- package/lib/helpers/OrderHelpers.js +47 -0
- package/lib/index.d.ts +40 -1
- package/lib/index.js +10 -1
- package/lib/models/ChatRoom.d.ts +12 -0
- package/lib/models/ChatRoom.js +92 -0
- package/lib/models/Order.d.ts +43 -0
- package/lib/models/Order.js +68 -37
- package/lib/types/rerobe-chatroom-types.d.ts +16 -0
- package/lib/types/rerobe-order-types.d.ts +9 -0
- package/package.json +1 -1
|
@@ -4,5 +4,5 @@ export default abstract class ChatRoomFactory extends Base {
|
|
|
4
4
|
abstract createChatRoom(user: {
|
|
5
5
|
uid: string;
|
|
6
6
|
displayName: string;
|
|
7
|
-
}, admins: ChatRoomUserInfo[], welcomeMessage: LastMessageObj, chatRoomType: ChatRoomType): ChatRoom;
|
|
7
|
+
}, admins: ChatRoomUserInfo[], welcomeMessage: LastMessageObj, chatRoomType: ChatRoomType, merchantId: string): ChatRoom;
|
|
8
8
|
}
|
|
@@ -4,5 +4,5 @@ export default class ChatRoomFromNewUserSignUp extends ChatRoomFactory {
|
|
|
4
4
|
createChatRoom(user: {
|
|
5
5
|
uid: string;
|
|
6
6
|
displayName: string;
|
|
7
|
-
}, admins: ChatRoomUserInfo[], welcomeMessageObj: LastMessageObj, chatRoomType: ChatRoomType): ChatRoom;
|
|
7
|
+
}, admins: ChatRoomUserInfo[], welcomeMessageObj: LastMessageObj, chatRoomType: ChatRoomType, merchantId: string): ChatRoom;
|
|
8
8
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ChatRoomFactory_1 = require("./ChatRoomFactory");
|
|
4
4
|
const ChatRoom_1 = require("../../models/ChatRoom");
|
|
5
5
|
class ChatRoomFromNewUserSignUp extends ChatRoomFactory_1.default {
|
|
6
|
-
createChatRoom(user, admins, welcomeMessageObj, chatRoomType) {
|
|
6
|
+
createChatRoom(user, admins, welcomeMessageObj, chatRoomType, merchantId) {
|
|
7
7
|
const chatRoomAttributes = {
|
|
8
8
|
userIdsToBeNotified: [user.uid],
|
|
9
9
|
type: chatRoomType,
|
|
@@ -18,6 +18,7 @@ class ChatRoomFromNewUserSignUp extends ChatRoomFactory_1.default {
|
|
|
18
18
|
online: false,
|
|
19
19
|
typing: false,
|
|
20
20
|
} }),
|
|
21
|
+
merchantId: merchantId || '',
|
|
21
22
|
};
|
|
22
23
|
return new ChatRoom_1.default(Object.assign({}, chatRoomAttributes));
|
|
23
24
|
}
|
|
@@ -89,6 +89,12 @@ class OrderFromFormState extends OrderFactory_1.default {
|
|
|
89
89
|
merchantId: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.merchantId) || '',
|
|
90
90
|
tags: fs.fields.tags.selectedValues || [],
|
|
91
91
|
refunds: ((_t = fs.props) === null || _t === void 0 ? void 0 : _t.refunds) || [],
|
|
92
|
+
subtotalPricePresentment: fs.props.subtotalPricePresentment,
|
|
93
|
+
totalDiscountPresentment: fs.props.totalDiscountPresentment,
|
|
94
|
+
totalPricePresentment: fs.props.totalPricePresentment,
|
|
95
|
+
totalRefundedPresentment: fs.props.totalRefundedPresentment,
|
|
96
|
+
totalShippingPricePresentment: fs.props.totalShippingPricePresentment,
|
|
97
|
+
totalTaxPresentment: fs.props.totalTaxPresentment,
|
|
92
98
|
};
|
|
93
99
|
return new Order_1.default(Object.assign({}, orderAttributes));
|
|
94
100
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.productOptions = exports.productIsOnSaleOptions = exports.discountTypeOptions = exports.
|
|
3
|
+
exports.productOptions = exports.productIsOnSaleOptions = exports.discountTypeOptions = exports.salesChannelOptions = exports.unisexJewelry = exports.mensJewelry = exports.jewelry = exports.unisexAccessories = exports.mensAccessories = exports.accessories = exports.unisexBags = exports.mensBags = exports.bags = exports.unisexShoes = exports.mensShoes = exports.shoes = exports.unisexClothing = exports.mensClothing = exports.clothing = exports.productCategories = exports.clothingMaterials = exports.shoeSizes = exports.jeanSizes = exports.gender = exports.conditions = exports.colors = exports.brands = exports.sizeCommentOptions = exports.clothingSizeOptions = exports.statusOptions = exports.publishTypeOptions = exports.availableForSaleOptions = void 0;
|
|
4
4
|
const ProductStateManager_1 = require("../../models/ProductStateManager");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const availableForSaleOptions = [
|
|
@@ -9,4 +9,8 @@ export default class OrderHelpers {
|
|
|
9
9
|
getOrderInfoWithRefundsAndFulfillments(order: CompleteOrder): OrderWithRefundsAndFulfillmentsInfoObj;
|
|
10
10
|
getUpdatedOrderObjWithRefunds(orderObj: CompleteOrder, refundObj: OrderRefund): CompleteOrder;
|
|
11
11
|
getUpdatedOrderObjWithFulfillment(orderObj: CompleteOrder, fulfillmentObj: FulfillmentAdmin, totalUnfulfilledItems: number): CompleteOrder;
|
|
12
|
+
getSubtotalPrice(lineItems: ReRobeOrderLineItem[] | any[], userAvailableCredit?: number | string): number;
|
|
13
|
+
getCreditDiscount(lineItems: ReRobeOrderLineItem[] | undefined, userAvailableCredit: number | string): number;
|
|
14
|
+
getSaleDiscount(lineItems?: ReRobeOrderLineItem[]): number;
|
|
15
|
+
getDiscountAmount(lineItems?: ReRobeOrderLineItem[], userAvailableCredit?: number | string): number;
|
|
12
16
|
}
|
|
@@ -84,6 +84,9 @@ class OrderHelpers {
|
|
|
84
84
|
},
|
|
85
85
|
shopifyProductId: product.shopifyId || null,
|
|
86
86
|
productId: product.documentId,
|
|
87
|
+
status: product.status || '',
|
|
88
|
+
isOnSale: product.isOnSale || '',
|
|
89
|
+
salePrice: product.salePrice || '',
|
|
87
90
|
};
|
|
88
91
|
}
|
|
89
92
|
toFixedPointPrice(price) {
|
|
@@ -193,5 +196,49 @@ class OrderHelpers {
|
|
|
193
196
|
totalUnfulfilledItems - fulfilledItemsQuantity > 0 ? 'PARTIALLY_FULFILLED' : 'FULFILLED';
|
|
194
197
|
return updatedOrder;
|
|
195
198
|
}
|
|
199
|
+
getSubtotalPrice(lineItems, userAvailableCredit = 0) {
|
|
200
|
+
// Get subtotal without saleDiscount (products on sale) and creditDiscount (userAvailableCredit)
|
|
201
|
+
if (!lineItems || !lineItems.length) {
|
|
202
|
+
return 0;
|
|
203
|
+
}
|
|
204
|
+
const subtotalWithoutSaleDiscount = lineItems.reduce((acc, lineItem) => {
|
|
205
|
+
var _a;
|
|
206
|
+
const isSaleItem = lineItem.isOnSale === 'yes' && (lineItem.status === 'CLEARANCE' || lineItem.status === 'RESERVED');
|
|
207
|
+
const itemPrice = isSaleItem ? lineItem.salePrice : (_a = lineItem.originalTotalPrice) === null || _a === void 0 ? void 0 : _a.amount;
|
|
208
|
+
return acc + Number(itemPrice);
|
|
209
|
+
}, 0);
|
|
210
|
+
let subtotal = subtotalWithoutSaleDiscount;
|
|
211
|
+
if (userAvailableCredit && Number(userAvailableCredit) > 0) {
|
|
212
|
+
subtotal = subtotalWithoutSaleDiscount - Number(userAvailableCredit);
|
|
213
|
+
}
|
|
214
|
+
if (subtotal < 0) {
|
|
215
|
+
subtotal = 0;
|
|
216
|
+
}
|
|
217
|
+
return Number(Number(subtotal).toFixed(2));
|
|
218
|
+
}
|
|
219
|
+
getCreditDiscount(lineItems = [], userAvailableCredit) {
|
|
220
|
+
if (!userAvailableCredit || Number(userAvailableCredit) <= 0) {
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
223
|
+
const subtotal = this.getSubtotalPrice(lineItems);
|
|
224
|
+
return subtotal > userAvailableCredit ? Number(userAvailableCredit) : subtotal;
|
|
225
|
+
}
|
|
226
|
+
getSaleDiscount(lineItems = []) {
|
|
227
|
+
return lineItems.reduce((acc, cur) => {
|
|
228
|
+
var _a;
|
|
229
|
+
const isSaleItem = cur.isOnSale === 'yes' && (cur.status === 'CLEARANCE' || cur.status === 'RESERVED');
|
|
230
|
+
let prodDiscount = 0;
|
|
231
|
+
if (isSaleItem) {
|
|
232
|
+
prodDiscount = Number((Number((_a = cur.originalTotalPrice) === null || _a === void 0 ? void 0 : _a.amount) - Number(cur.salePrice)).toFixed(2));
|
|
233
|
+
}
|
|
234
|
+
return acc + prodDiscount;
|
|
235
|
+
}, 0);
|
|
236
|
+
}
|
|
237
|
+
getDiscountAmount(lineItems = [], userAvailableCredit = 0) {
|
|
238
|
+
const creditDiscount = this.getCreditDiscount(lineItems, userAvailableCredit);
|
|
239
|
+
const saleDiscount = this.getSaleDiscount(lineItems);
|
|
240
|
+
const discount = Number(Number(creditDiscount + saleDiscount).toFixed(2));
|
|
241
|
+
return discount;
|
|
242
|
+
}
|
|
196
243
|
}
|
|
197
244
|
exports.default = OrderHelpers;
|
package/lib/index.d.ts
CHANGED
|
@@ -33,4 +33,43 @@ import WebhookFormState from './form-states/Merchant/WebhookFormState';
|
|
|
33
33
|
import ReRobeProductHelpers from './helpers/ReRobeProductHelpers';
|
|
34
34
|
import AnalyticsHelpers from './helpers/AnalyticsHelpers';
|
|
35
35
|
import OrderHelpers from './helpers/OrderHelpers';
|
|
36
|
-
|
|
36
|
+
declare const CONSTANTS: {
|
|
37
|
+
SHIPPING_TYPES: {
|
|
38
|
+
localPickUp: string;
|
|
39
|
+
localDelivery: string;
|
|
40
|
+
shipping: string;
|
|
41
|
+
};
|
|
42
|
+
PAYMENT_TYPES: {
|
|
43
|
+
creditCard: string;
|
|
44
|
+
klarna: string;
|
|
45
|
+
swish: string;
|
|
46
|
+
};
|
|
47
|
+
ORDER_STATES: {
|
|
48
|
+
draft: string;
|
|
49
|
+
completed: string;
|
|
50
|
+
};
|
|
51
|
+
SALES_CHANNELS: {
|
|
52
|
+
mobileApp: string;
|
|
53
|
+
webApp: string;
|
|
54
|
+
store: string;
|
|
55
|
+
onlineStore: string;
|
|
56
|
+
thirdParty: string;
|
|
57
|
+
ahlens: string;
|
|
58
|
+
};
|
|
59
|
+
FULFILLMENT_TYPES: {
|
|
60
|
+
fulfilled: string;
|
|
61
|
+
partiallyFulfilled: string;
|
|
62
|
+
unfulfilled: string;
|
|
63
|
+
inProgress: string;
|
|
64
|
+
canceled: string;
|
|
65
|
+
restocked: string;
|
|
66
|
+
};
|
|
67
|
+
FINANCIAL_TYPES: {
|
|
68
|
+
paid: string;
|
|
69
|
+
pending: string;
|
|
70
|
+
refunded: string;
|
|
71
|
+
partiallyRefunded: string;
|
|
72
|
+
authorized: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export { ProductFromAlgoliaJSONDoc, ProductFromShopifyWebhookJSONDoc, ProductFromShopifyJSClientJSONDoc, ProductFormStateFactory, ProductCollectionFormStateFactory, ProductCollectionHelpers, SellRequestFormStateFactory, PickUpFormStateFactory, AddressFormStateFactory, UserFormStateFactory, UserFromShopifyWebhookJSONDoc, UserFromAuthTemplateMethod, DraftOrderFromMirakl, DraftOrderFromApp, ChatRoomFromNewUserSignUp, KlarnaSessionFactory, Product, ProductStateManager, Order, OrderFromShopifyWebhook, OrderFromShopifyAdminApi, OrderFromShopifyStorefrontApi, OrderFromApp, OrderFormStateFactory, RefundFormStateFactory, PayoutAccount, PayoutAccountFormState, Merchant, MerchantFormState, MerchantFormStateFactory, ReRobeProductHelpers, User, AnalyticsHelpers, OrderHelpers, WebhookFormState, CONSTANTS, };
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebhookFormState = exports.OrderHelpers = exports.AnalyticsHelpers = exports.User = exports.ReRobeProductHelpers = exports.MerchantFormStateFactory = exports.MerchantFormState = exports.Merchant = exports.PayoutAccountFormState = exports.PayoutAccount = exports.RefundFormStateFactory = exports.OrderFormStateFactory = exports.OrderFromApp = exports.OrderFromShopifyStorefrontApi = exports.OrderFromShopifyAdminApi = exports.OrderFromShopifyWebhook = exports.Order = exports.ProductStateManager = exports.Product = exports.KlarnaSessionFactory = exports.ChatRoomFromNewUserSignUp = exports.DraftOrderFromApp = exports.DraftOrderFromMirakl = exports.UserFromAuthTemplateMethod = exports.UserFromShopifyWebhookJSONDoc = exports.UserFormStateFactory = exports.AddressFormStateFactory = exports.PickUpFormStateFactory = exports.SellRequestFormStateFactory = exports.ProductCollectionHelpers = exports.ProductCollectionFormStateFactory = exports.ProductFormStateFactory = exports.ProductFromShopifyJSClientJSONDoc = exports.ProductFromShopifyWebhookJSONDoc = exports.ProductFromAlgoliaJSONDoc = void 0;
|
|
3
|
+
exports.CONSTANTS = exports.WebhookFormState = exports.OrderHelpers = exports.AnalyticsHelpers = exports.User = exports.ReRobeProductHelpers = exports.MerchantFormStateFactory = exports.MerchantFormState = exports.Merchant = exports.PayoutAccountFormState = exports.PayoutAccount = exports.RefundFormStateFactory = exports.OrderFormStateFactory = exports.OrderFromApp = exports.OrderFromShopifyStorefrontApi = exports.OrderFromShopifyAdminApi = exports.OrderFromShopifyWebhook = exports.Order = exports.ProductStateManager = exports.Product = exports.KlarnaSessionFactory = exports.ChatRoomFromNewUserSignUp = exports.DraftOrderFromApp = exports.DraftOrderFromMirakl = exports.UserFromAuthTemplateMethod = exports.UserFromShopifyWebhookJSONDoc = exports.UserFormStateFactory = exports.AddressFormStateFactory = exports.PickUpFormStateFactory = exports.SellRequestFormStateFactory = exports.ProductCollectionHelpers = exports.ProductCollectionFormStateFactory = exports.ProductFormStateFactory = exports.ProductFromShopifyJSClientJSONDoc = exports.ProductFromShopifyWebhookJSONDoc = exports.ProductFromAlgoliaJSONDoc = void 0;
|
|
4
4
|
const ProductFromShopifyJSClientJSONDoc_1 = require("./factories/Product/ProductFromShopifyJSClientJSONDoc");
|
|
5
5
|
exports.ProductFromShopifyJSClientJSONDoc = ProductFromShopifyJSClientJSONDoc_1.default;
|
|
6
6
|
const ProductFromAlgoliaJSONDoc_1 = require("./factories/Product/ProductFromAlgoliaJSONDoc");
|
|
@@ -71,3 +71,12 @@ const AnalyticsHelpers_1 = require("./helpers/AnalyticsHelpers");
|
|
|
71
71
|
exports.AnalyticsHelpers = AnalyticsHelpers_1.default;
|
|
72
72
|
const OrderHelpers_1 = require("./helpers/OrderHelpers");
|
|
73
73
|
exports.OrderHelpers = OrderHelpers_1.default;
|
|
74
|
+
const CONSTANTS = {
|
|
75
|
+
SHIPPING_TYPES: Order_1.SHIPPING_TYPES,
|
|
76
|
+
PAYMENT_TYPES: Order_1.PAYMENT_TYPES,
|
|
77
|
+
ORDER_STATES: Order_1.ORDER_STATES,
|
|
78
|
+
SALES_CHANNELS: Order_1.SALES_CHANNELS,
|
|
79
|
+
FULFILLMENT_TYPES: Order_1.FULFILLMENT_TYPES,
|
|
80
|
+
FINANCIAL_TYPES: Order_1.FINANCIAL_TYPES,
|
|
81
|
+
};
|
|
82
|
+
exports.CONSTANTS = CONSTANTS;
|
package/lib/models/ChatRoom.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import Base from '../Base';
|
|
2
2
|
export default class ChatRoom extends Base {
|
|
3
|
+
documentId: string;
|
|
3
4
|
userIdsToBeNotified: string[];
|
|
4
5
|
type: ChatRoomType;
|
|
5
6
|
lastMessage: LastMessageObj;
|
|
6
7
|
userIds: string[];
|
|
7
8
|
userInfo: ChatRoomUserInfoObj;
|
|
9
|
+
merchantId: string;
|
|
8
10
|
constructor(props?: any);
|
|
9
11
|
toObj(): ChatRoomAttributes;
|
|
12
|
+
generateSchemaForTypesense(name?: string): {
|
|
13
|
+
default_sorting_field: string;
|
|
14
|
+
fields: {
|
|
15
|
+
facet: boolean;
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}[];
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
toObjForTypesense(): TypesenseChatRoomObj;
|
|
10
22
|
}
|
package/lib/models/ChatRoom.js
CHANGED
|
@@ -4,20 +4,112 @@ const Base_1 = require("../Base");
|
|
|
4
4
|
class ChatRoom extends Base_1.default {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super();
|
|
7
|
+
this.documentId = (props === null || props === void 0 ? void 0 : props.documentId) || this.utilities.makeRandId(28);
|
|
7
8
|
this.userIdsToBeNotified = (props === null || props === void 0 ? void 0 : props.userIdsToBeNotified) || [];
|
|
8
9
|
this.type = (props === null || props === void 0 ? void 0 : props.type) || 'CUSTOMER_SUPPORT';
|
|
9
10
|
this.lastMessage = (props === null || props === void 0 ? void 0 : props.lastMessage) || {};
|
|
10
11
|
this.userIds = (props === null || props === void 0 ? void 0 : props.userIds) || [];
|
|
11
12
|
this.userInfo = (props === null || props === void 0 ? void 0 : props.userInfo) || {};
|
|
13
|
+
this.merchantId = (props === null || props === void 0 ? void 0 : props.merchantId) || '';
|
|
12
14
|
}
|
|
13
15
|
toObj() {
|
|
14
16
|
return {
|
|
17
|
+
documentId: this.documentId,
|
|
15
18
|
userIdsToBeNotified: this.userIdsToBeNotified,
|
|
16
19
|
type: this.type,
|
|
17
20
|
lastMessage: this.lastMessage,
|
|
18
21
|
userIds: this.userIds,
|
|
19
22
|
userInfo: this.userInfo,
|
|
23
|
+
merchantId: this.merchantId,
|
|
20
24
|
};
|
|
21
25
|
}
|
|
26
|
+
generateSchemaForTypesense(name = 'prod_chatRooms_20220704') {
|
|
27
|
+
return {
|
|
28
|
+
default_sorting_field: 'lastMessage.createdAtTimestamp',
|
|
29
|
+
fields: [
|
|
30
|
+
{
|
|
31
|
+
facet: false,
|
|
32
|
+
name: 'documentId',
|
|
33
|
+
type: 'string',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
facet: true,
|
|
37
|
+
name: 'type',
|
|
38
|
+
type: 'string',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
facet: false,
|
|
42
|
+
name: 'userIds',
|
|
43
|
+
type: 'string[]',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
facet: false,
|
|
47
|
+
name: 'userIdsToBeNotified',
|
|
48
|
+
type: 'string[]',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
facet: false,
|
|
52
|
+
name: 'lastMessage.authorId',
|
|
53
|
+
type: 'string',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
facet: true,
|
|
57
|
+
name: 'lastMessage.authorName',
|
|
58
|
+
type: 'string',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
facet: false,
|
|
62
|
+
name: 'lastMessage.content',
|
|
63
|
+
type: 'string',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
facet: true,
|
|
67
|
+
name: 'lastMessage.createdAtTimestamp',
|
|
68
|
+
type: 'int64',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
facet: true,
|
|
72
|
+
name: 'adminMemberNames',
|
|
73
|
+
type: 'string[]',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
facet: true,
|
|
77
|
+
name: 'userNames',
|
|
78
|
+
type: 'string[]',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
facet: true,
|
|
82
|
+
name: 'merchantId',
|
|
83
|
+
type: 'string',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
name,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
toObjForTypesense() {
|
|
90
|
+
const userNames = [];
|
|
91
|
+
const sanitizedAdminMembersNames = Object.keys(this.userInfo).reduce((result, key) => {
|
|
92
|
+
const currentUserInfo = this.userInfo[key];
|
|
93
|
+
userNames.push(this.utilities.sanitizeString(currentUserInfo.displayName));
|
|
94
|
+
if (currentUserInfo.isChatAdmin) {
|
|
95
|
+
result.push(this.utilities.sanitizeString(currentUserInfo.displayName));
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}, []);
|
|
99
|
+
const stagedObj = {
|
|
100
|
+
documentId: this.utilities.sanitizeString(this.documentId),
|
|
101
|
+
type: this.utilities.sanitizeString(this.type),
|
|
102
|
+
userIds: this.utilities.sanitzeStringArr(this.userIds),
|
|
103
|
+
userIdsToBeNotified: this.utilities.sanitzeStringArr(this.userIdsToBeNotified),
|
|
104
|
+
'lastMessage.authorId': this.utilities.sanitizeString(this.lastMessage.authorId),
|
|
105
|
+
'lastMessage.authorName': this.utilities.sanitizeString(this.lastMessage.authorName),
|
|
106
|
+
'lastMessage.content': this.utilities.sanitizeString(this.lastMessage.content),
|
|
107
|
+
'lastMessage.createdAtTimestamp': this.utilities.sanitizeMillisTimeStamp(this.lastMessage.createdAt),
|
|
108
|
+
adminMemberNames: sanitizedAdminMembersNames,
|
|
109
|
+
userNames,
|
|
110
|
+
merchantId: this.utilities.sanitizeString(this.merchantId),
|
|
111
|
+
};
|
|
112
|
+
return stagedObj;
|
|
113
|
+
}
|
|
22
114
|
}
|
|
23
115
|
exports.default = ChatRoom;
|
package/lib/models/Order.d.ts
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import Base from '../Base';
|
|
2
|
+
export declare const SHIPPING_TYPES: {
|
|
3
|
+
localPickUp: string;
|
|
4
|
+
localDelivery: string;
|
|
5
|
+
shipping: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const PAYMENT_TYPES: {
|
|
8
|
+
creditCard: string;
|
|
9
|
+
klarna: string;
|
|
10
|
+
swish: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const ORDER_STATES: {
|
|
13
|
+
draft: string;
|
|
14
|
+
completed: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const SALES_CHANNELS: {
|
|
17
|
+
mobileApp: string;
|
|
18
|
+
webApp: string;
|
|
19
|
+
store: string;
|
|
20
|
+
onlineStore: string;
|
|
21
|
+
thirdParty: string;
|
|
22
|
+
ahlens: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const FULFILLMENT_TYPES: {
|
|
25
|
+
fulfilled: string;
|
|
26
|
+
partiallyFulfilled: string;
|
|
27
|
+
unfulfilled: string;
|
|
28
|
+
inProgress: string;
|
|
29
|
+
canceled: string;
|
|
30
|
+
restocked: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const FINANCIAL_TYPES: {
|
|
33
|
+
paid: string;
|
|
34
|
+
pending: string;
|
|
35
|
+
refunded: string;
|
|
36
|
+
partiallyRefunded: string;
|
|
37
|
+
authorized: string;
|
|
38
|
+
};
|
|
2
39
|
export default class Order extends Base {
|
|
3
40
|
static SHIPPING_TYPES: {
|
|
4
41
|
localPickUp: string;
|
|
@@ -82,6 +119,12 @@ export default class Order extends Base {
|
|
|
82
119
|
customerName: string;
|
|
83
120
|
merchantId: string;
|
|
84
121
|
refunds: OrderRefund[];
|
|
122
|
+
subtotalPricePresentment: Money;
|
|
123
|
+
totalDiscountPresentment: Money;
|
|
124
|
+
totalPricePresentment: Money;
|
|
125
|
+
totalRefundedPresentment: Money;
|
|
126
|
+
totalShippingPricePresentment: Money;
|
|
127
|
+
totalTaxPresentment: Money;
|
|
85
128
|
constructor(props?: any);
|
|
86
129
|
toObj(): ReRobeOrderObj;
|
|
87
130
|
}
|
package/lib/models/Order.js
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FINANCIAL_TYPES = exports.FULFILLMENT_TYPES = exports.SALES_CHANNELS = exports.ORDER_STATES = exports.PAYMENT_TYPES = exports.SHIPPING_TYPES = void 0;
|
|
3
4
|
const Base_1 = require("../Base");
|
|
5
|
+
exports.SHIPPING_TYPES = {
|
|
6
|
+
localPickUp: 'LOCAL_PICK_UP',
|
|
7
|
+
localDelivery: 'LOCAL_DELIVERY',
|
|
8
|
+
shipping: 'SHIPPING',
|
|
9
|
+
};
|
|
10
|
+
exports.PAYMENT_TYPES = {
|
|
11
|
+
creditCard: 'CREDIT_CARD',
|
|
12
|
+
klarna: 'KLARNA',
|
|
13
|
+
swish: 'SWISH',
|
|
14
|
+
};
|
|
15
|
+
exports.ORDER_STATES = {
|
|
16
|
+
draft: 'DRAFT',
|
|
17
|
+
completed: 'COMPLETED',
|
|
18
|
+
};
|
|
19
|
+
exports.SALES_CHANNELS = {
|
|
20
|
+
mobileApp: 'MOBILE_APP',
|
|
21
|
+
webApp: 'DRAFT_ORDER',
|
|
22
|
+
store: 'STORE',
|
|
23
|
+
onlineStore: 'ONLINE_STORE',
|
|
24
|
+
thirdParty: 'THIRD_PARTY',
|
|
25
|
+
ahlens: 'AHLENS',
|
|
26
|
+
};
|
|
27
|
+
exports.FULFILLMENT_TYPES = {
|
|
28
|
+
fulfilled: 'FULFILLED',
|
|
29
|
+
partiallyFulfilled: 'PARTIALLY_FULFILLED',
|
|
30
|
+
unfulfilled: 'UNFULFILLED',
|
|
31
|
+
inProgress: 'IN_PROGRESS',
|
|
32
|
+
canceled: 'CANCELED',
|
|
33
|
+
restocked: 'RESTOCKED',
|
|
34
|
+
};
|
|
35
|
+
exports.FINANCIAL_TYPES = {
|
|
36
|
+
paid: 'PAID',
|
|
37
|
+
pending: 'PENDING',
|
|
38
|
+
refunded: 'REFUNDED',
|
|
39
|
+
partiallyRefunded: 'PARTIALLY_REFUNDED',
|
|
40
|
+
authorized: 'AUTHORIZED',
|
|
41
|
+
};
|
|
4
42
|
class Order extends Base_1.default {
|
|
5
43
|
constructor(props) {
|
|
6
44
|
super();
|
|
@@ -105,6 +143,24 @@ class Order extends Base_1.default {
|
|
|
105
143
|
this.customerName = (props === null || props === void 0 ? void 0 : props.customerName) || '';
|
|
106
144
|
this.merchantId = (props === null || props === void 0 ? void 0 : props.merchantId) || '';
|
|
107
145
|
this.refunds = (props === null || props === void 0 ? void 0 : props.refunds) || [];
|
|
146
|
+
this.subtotalPricePresentment = (props === null || props === void 0 ? void 0 : props.subtotalPricePresentment) || {
|
|
147
|
+
amount: 0,
|
|
148
|
+
};
|
|
149
|
+
this.totalDiscountPresentment = (props === null || props === void 0 ? void 0 : props.totalDiscountPresentment) || {
|
|
150
|
+
amount: 0,
|
|
151
|
+
};
|
|
152
|
+
this.totalPricePresentment = (props === null || props === void 0 ? void 0 : props.totalPricePresentment) || {
|
|
153
|
+
amount: 0,
|
|
154
|
+
};
|
|
155
|
+
this.totalRefundedPresentment = (props === null || props === void 0 ? void 0 : props.totalRefundedPresentment) || {
|
|
156
|
+
amount: 0,
|
|
157
|
+
};
|
|
158
|
+
this.totalShippingPricePresentment = (props === null || props === void 0 ? void 0 : props.totalShippingPricePresentment) || {
|
|
159
|
+
amount: 0,
|
|
160
|
+
};
|
|
161
|
+
this.totalTaxPresentment = (props === null || props === void 0 ? void 0 : props.totalTaxPresentment) || {
|
|
162
|
+
amount: 0,
|
|
163
|
+
};
|
|
108
164
|
}
|
|
109
165
|
toObj() {
|
|
110
166
|
const orderObj = {
|
|
@@ -150,6 +206,12 @@ class Order extends Base_1.default {
|
|
|
150
206
|
customerName: this.customerName,
|
|
151
207
|
merchantId: this.merchantId,
|
|
152
208
|
refunds: this.refunds,
|
|
209
|
+
subtotalPricePresentment: this.subtotalPricePresentment,
|
|
210
|
+
totalDiscountPresentment: this.totalDiscountPresentment,
|
|
211
|
+
totalPricePresentment: this.totalPricePresentment,
|
|
212
|
+
totalRefundedPresentment: this.totalRefundedPresentment,
|
|
213
|
+
totalShippingPricePresentment: this.totalShippingPricePresentment,
|
|
214
|
+
totalTaxPresentment: this.totalTaxPresentment,
|
|
153
215
|
};
|
|
154
216
|
if (this.paymentType) {
|
|
155
217
|
orderObj.paymentType = this.paymentType;
|
|
@@ -164,40 +226,9 @@ class Order extends Base_1.default {
|
|
|
164
226
|
}
|
|
165
227
|
}
|
|
166
228
|
exports.default = Order;
|
|
167
|
-
Order.SHIPPING_TYPES =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
Order.
|
|
173
|
-
creditCard: 'CREDIT_CARD',
|
|
174
|
-
klarna: 'KLARNA',
|
|
175
|
-
swish: 'SWISH',
|
|
176
|
-
};
|
|
177
|
-
Order.ORDER_STATES = {
|
|
178
|
-
draft: 'DRAFT',
|
|
179
|
-
completed: 'COMPLETED',
|
|
180
|
-
};
|
|
181
|
-
Order.SALES_CHANNELS = {
|
|
182
|
-
mobileApp: 'MOBILE_APP',
|
|
183
|
-
webApp: 'DRAFT_ORDER',
|
|
184
|
-
store: 'STORE',
|
|
185
|
-
onlineStore: 'ONLINE_STORE',
|
|
186
|
-
thirdParty: 'THIRD_PARTY',
|
|
187
|
-
ahlens: 'AHLENS',
|
|
188
|
-
};
|
|
189
|
-
Order.FULFILLMENT_TYPES = {
|
|
190
|
-
fulfilled: 'FULFILLED',
|
|
191
|
-
partiallyFulfilled: 'PARTIALLY_FULFILLED',
|
|
192
|
-
unfulfilled: 'UNFULFILLED',
|
|
193
|
-
inProgress: 'IN_PROGRESS',
|
|
194
|
-
canceled: 'CANCELED',
|
|
195
|
-
restocked: 'RESTOCKED',
|
|
196
|
-
};
|
|
197
|
-
Order.FINANCIAL_TYPES = {
|
|
198
|
-
paid: 'PAID',
|
|
199
|
-
pending: 'PENDING',
|
|
200
|
-
refunded: 'REFUNDED',
|
|
201
|
-
partiallyRefunded: 'PARTIALLY_REFUNDED',
|
|
202
|
-
authorized: 'AUTHORIZED',
|
|
203
|
-
};
|
|
229
|
+
Order.SHIPPING_TYPES = exports.SHIPPING_TYPES;
|
|
230
|
+
Order.PAYMENT_TYPES = exports.PAYMENT_TYPES;
|
|
231
|
+
Order.ORDER_STATES = exports.ORDER_STATES;
|
|
232
|
+
Order.SALES_CHANNELS = exports.SALES_CHANNELS;
|
|
233
|
+
Order.FULFILLMENT_TYPES = exports.FULFILLMENT_TYPES;
|
|
234
|
+
Order.FINANCIAL_TYPES = exports.FINANCIAL_TYPES;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
declare type ChatRoomAttributes = {
|
|
2
|
+
documentId: string;
|
|
2
3
|
userIdsToBeNotified: string[];
|
|
3
4
|
type: ChatRoomType;
|
|
4
5
|
lastMessage: LastMessageObj;
|
|
5
6
|
userIds: string[];
|
|
6
7
|
userInfo: ChatRoomUserInfoObj;
|
|
8
|
+
merchantId: string;
|
|
7
9
|
};
|
|
8
10
|
declare type ChatRoomType = 'CUSTOMER_SUPPORT' | 'SELLER_CONCIERGE';
|
|
9
11
|
declare type LastMessageObj = {
|
|
@@ -23,5 +25,19 @@ declare type ChatRoomUserInfo = {
|
|
|
23
25
|
typing: boolean;
|
|
24
26
|
isChatAdmin?: boolean;
|
|
25
27
|
isReRobeStaff?: boolean;
|
|
28
|
+
isSeller?: boolean;
|
|
26
29
|
firstName?: string;
|
|
27
30
|
};
|
|
31
|
+
declare type TypesenseChatRoomObj = {
|
|
32
|
+
documentId: string;
|
|
33
|
+
type: string;
|
|
34
|
+
userIds: string[];
|
|
35
|
+
userIdsToBeNotified: string[];
|
|
36
|
+
'lastMessage.authorId': string;
|
|
37
|
+
'lastMessage.authorName': string;
|
|
38
|
+
'lastMessage.content': string;
|
|
39
|
+
'lastMessage.createdAtTimestamp': number;
|
|
40
|
+
adminMemberNames: string[];
|
|
41
|
+
userNames: string[];
|
|
42
|
+
merchantId: string;
|
|
43
|
+
};
|
|
@@ -63,6 +63,12 @@ declare type ReRobeOrderObj = {
|
|
|
63
63
|
refunds?: OrderRefund[];
|
|
64
64
|
createdAt?: string;
|
|
65
65
|
updatedAt?: string;
|
|
66
|
+
subtotalPricePresentment?: Money;
|
|
67
|
+
totalDiscountPresentment?: Money;
|
|
68
|
+
totalPricePresentment?: Money;
|
|
69
|
+
totalRefundedPresentment?: Money;
|
|
70
|
+
totalShippingPricePresentment?: Money;
|
|
71
|
+
totalTaxPresentment?: Money;
|
|
66
72
|
};
|
|
67
73
|
declare type OrderWithRefundsAndFulfillmentsInfoObj = {
|
|
68
74
|
documentId?: string;
|
|
@@ -213,6 +219,9 @@ interface ReRobeOrderLineItem extends OrderLineItem {
|
|
|
213
219
|
canceledQuantity?: number | string;
|
|
214
220
|
fulfilledQuantity?: number | string;
|
|
215
221
|
unfulfilledQuantity?: number | string;
|
|
222
|
+
status?: ProductSellStatusKeys | string;
|
|
223
|
+
isOnSale?: string;
|
|
224
|
+
salePrice?: string;
|
|
216
225
|
}
|
|
217
226
|
declare type OrderLineItemConnection = {
|
|
218
227
|
edges: OrderLineItemEdge[];
|