idosell 0.4.13 → 0.4.17

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.
@@ -0,0 +1,343 @@
1
+ import type { SearchProductsResponse } from "$dist/responses";
2
+
3
+ export const STOCK_PRODUCT: SearchProductsResponse['results'][number] = {
4
+ "productId": 541321313,
5
+ "productStocksData": {
6
+ "productSizesDeliveries": [
7
+ {
8
+ "productSizeQuantity": 3,
9
+ "sizeId": "5",
10
+ "sizePanelName": "L"
11
+ },
12
+ {
13
+ "productSizeQuantity": 3,
14
+ "sizeId": "6",
15
+ "sizePanelName": "X"
16
+ }
17
+ ],
18
+ "productStocksQuantities": [
19
+ {
20
+ "stockId": 1,
21
+ "productSizesData": [
22
+ {
23
+ "sizeId": "3",
24
+ "sizePanelName": "S",
25
+ "productSizeCodeExternal": "PX-ZERO-S",
26
+ "productSizeQuantity": 1,
27
+ // @ts-expect-error never needed
28
+ "productSizeReservations": {
29
+ "productSizeReservationOrder": 0
30
+ }
31
+ },
32
+ {
33
+ "sizeId": "4",
34
+ "sizePanelName": "M",
35
+ "productSizeCodeExternal": "PX-ZERO-M",
36
+ "productSizeQuantity": 0,
37
+ // @ts-expect-error never needed
38
+ "productSizeReservations": {
39
+ "productSizeReservationOrder": 0
40
+ }
41
+ },
42
+ {
43
+ "sizeId": "5",
44
+ "sizePanelName": "L",
45
+ "productSizeCodeExternal": "PX-ZERO-L",
46
+ "productSizeQuantity": 0,
47
+ // @ts-expect-error never needed
48
+ "productSizeReservations": {
49
+ "productSizeReservationOrder": 0
50
+ }
51
+ },
52
+ {
53
+ "sizeId": "6",
54
+ "sizePanelName": "XL",
55
+ "productSizeCodeExternal": "PX-ZERO-X",
56
+ "productSizeQuantity": 0,
57
+ // @ts-expect-error never needed
58
+ "productSizeReservations": {
59
+ "productSizeReservationOrder": 0
60
+ }
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ "stockId": 3,
66
+ "productSizesData": [
67
+ {
68
+ "sizeId": "3",
69
+ "sizePanelName": "S",
70
+ "productSizeCodeExternal": "PX-ZERO-S",
71
+ "productSizeQuantity": 9,
72
+ // @ts-expect-error never needed
73
+ "productSizeReservations": {
74
+ "productSizeReservationOrder": 2
75
+ }
76
+ },
77
+ {
78
+ "sizeId": "4",
79
+ "sizePanelName": "M",
80
+ "productSizeCodeExternal": "PX-ZERO-M",
81
+ "productSizeQuantity": 10,
82
+ // @ts-expect-error never needed
83
+ "productSizeReservations": {
84
+ "productSizeReservationOrder": 0
85
+ }
86
+ },
87
+ {
88
+ "sizeId": "5",
89
+ "sizePanelName": "L",
90
+ "productSizeCodeExternal": "PX-ZERO-L",
91
+ "productSizeQuantity": 0,
92
+ // @ts-expect-error never needed
93
+ "productSizeReservations": {
94
+ "productSizeReservationOrder": 0
95
+ }
96
+ },
97
+ {
98
+ "sizeId": "6",
99
+ "sizePanelName": "XL",
100
+ "productSizeCodeExternal": "PX-ZERO-X",
101
+ "productSizeQuantity": 0,
102
+ // @ts-expect-error never needed
103
+ "productSizeReservations": {
104
+ "productSizeReservationOrder": 0
105
+ }
106
+ }
107
+ ]
108
+ }
109
+ ],
110
+ "productSizesDispositions": {
111
+ "productSizesDispositionsInSales": [
112
+ {
113
+ "sizeId": "3",
114
+ "sizePanelName": "S",
115
+ "productSizeCodeExternal": "PX-ZERO-S",
116
+ "productSizeQuantityOutsideStock": 0,
117
+ "productSizeQuantityOwnStock": 8,
118
+ "productSizeQuantityAllStocks": 8
119
+ },
120
+ {
121
+ "sizeId": "4",
122
+ "sizePanelName": "M",
123
+ "productSizeCodeExternal": "PX-ZERO-M",
124
+ "productSizeQuantityOutsideStock": 0,
125
+ "productSizeQuantityOwnStock": 10,
126
+ "productSizeQuantityAllStocks": 10
127
+ },
128
+ {
129
+ "sizeId": "5",
130
+ "sizePanelName": "L",
131
+ "productSizeCodeExternal": "PX-ZERO-L",
132
+ "productSizeQuantityOutsideStock": 5,
133
+ "productSizeQuantityOwnStock": 0,
134
+ "productSizeQuantityAllStocks": 5
135
+ },
136
+ {
137
+ "sizeId": "6",
138
+ "sizePanelName": "XL",
139
+ "productSizeCodeExternal": "PX-ZERO-X",
140
+ "productSizeQuantityOutsideStock": 0,
141
+ "productSizeQuantityOwnStock": 0,
142
+ "productSizeQuantityAllStocks": 0
143
+ }
144
+ ],
145
+ "productSizesDispositionsInAuctions": [
146
+ {
147
+ "sizeId": "3",
148
+ "sizePanelName": "S",
149
+ "productSizeCodeExternal": "PX-ZERO-S",
150
+ "productSizeQuantity": 1
151
+ },
152
+ {
153
+ "sizeId": "4",
154
+ "sizePanelName": "M",
155
+ "productSizeCodeExternal": "PX-ZERO-M",
156
+ "productSizeQuantity": 0
157
+ },
158
+ {
159
+ "sizeId": "5",
160
+ "sizePanelName": "L",
161
+ "productSizeCodeExternal": "PX-ZERO-L",
162
+ "productSizeQuantity": 0
163
+ },
164
+ {
165
+ "sizeId": "6",
166
+ "sizePanelName": "XL",
167
+ "productSizeCodeExternal": "PX-ZERO-X",
168
+ "productSizeQuantity": 0
169
+ }
170
+ ]
171
+ },
172
+ "productOrdersUnfinishedQuantities": [
173
+ {
174
+ "stockId": 1,
175
+ "productSizesData": [
176
+ {
177
+ "sizeId": "3",
178
+ "sizePanelName": "S",
179
+ "productSizeCodeExternal": "PX-ZERO-S",
180
+ "productSizeQuantity": 2
181
+ }
182
+ ]
183
+ }
184
+ ],
185
+ "productSizesStocksLocations": [
186
+ {
187
+ "stockId": 1,
188
+ "productSizesLocation": [
189
+ {
190
+ "stockLocationCode": "F",
191
+ "stockAdditionalLocations": [
192
+ {
193
+ "stockAdditionalLocationId": 46,
194
+ "stockAdditionalLocationTextId": "M1\\A015",
195
+ "stockAdditionalLocationCode": "P"
196
+ },
197
+ {
198
+ "stockAdditionalLocationId": 1,
199
+ "stockAdditionalLocationTextId": "M1\\A113",
200
+ "stockAdditionalLocationCode": "A"
201
+ }
202
+ ],
203
+ "sizeId": "3",
204
+ "stockLocationId": 16,
205
+ "stockLocationTextId": "M1\\A014"
206
+ },
207
+ {
208
+ "stockLocationCode": "F",
209
+ "sizeId": "4",
210
+ "stockLocationId": 16,
211
+ "stockLocationTextId": "M1\\A014"
212
+ },
213
+ {
214
+ "stockLocationCode": "B",
215
+ "sizeId": "5",
216
+ "stockLocationId": 4,
217
+ "stockLocationTextId": "M1\\B013"
218
+ },
219
+ {
220
+ "stockLocationCode": "B",
221
+ "sizeId": "6",
222
+ "stockLocationId": 4,
223
+ "stockLocationTextId": "M1\\B013"
224
+ }
225
+ ]
226
+ },
227
+ {
228
+ "stockId": 2,
229
+ "productSizesLocation": [
230
+ {
231
+ "stockLocationCode": "B",
232
+ "sizeId": "3",
233
+ "stockLocationId": 5,
234
+ "stockLocationTextId": "M2\\G013"
235
+ },
236
+ {
237
+ "stockLocationCode": "Q",
238
+ "sizeId": "4",
239
+ "stockLocationId": 50,
240
+ "stockLocationTextId": "M2\\G015"
241
+ },
242
+ {
243
+ "stockLocationCode": "L",
244
+ "sizeId": "5",
245
+ "stockLocationId": 35,
246
+ "stockLocationTextId": "M2\\G114"
247
+ },
248
+ {
249
+ "stockLocationCode": "G",
250
+ "sizeId": "6",
251
+ "stockLocationId": 20,
252
+ "stockLocationTextId": "M2\\G214"
253
+ }
254
+ ]
255
+ },
256
+ {
257
+ "stockId": 3,
258
+ "productSizesLocation": [
259
+ {
260
+ "stockLocationCode": "F",
261
+ "sizeId": "3",
262
+ "stockLocationId": 18,
263
+ "stockLocationTextId": "M3\\K014"
264
+ },
265
+ {
266
+ "stockLocationCode": "B",
267
+ "sizeId": "4",
268
+ "stockLocationId": 6,
269
+ "stockLocationTextId": "M3\\L013"
270
+ },
271
+ {
272
+ "stockLocationCode": "B",
273
+ "sizeId": "5",
274
+ "stockLocationId": 6,
275
+ "stockLocationTextId": "M3\\L013"
276
+ },
277
+ {
278
+ "stockLocationCode": "F",
279
+ "sizeId": "6",
280
+ "stockLocationId": 18,
281
+ "stockLocationTextId": "M3\\K014"
282
+ }
283
+ ]
284
+ }
285
+ ]
286
+ },
287
+ "productSizesAttributes": [
288
+ {
289
+ "productSizeWeightWithoutPackaging": 0,
290
+ "sizeId": "3",
291
+ "sizePanelName": "S",
292
+ "productSizeCodeExternal": "PX-ZERO-S",
293
+ "productSizeCodeProducer": "1234567890128",
294
+ "productInPersistent": "y",
295
+ "productSizeWeight": 0
296
+ },
297
+ {
298
+ "productSizeWeightWithoutPackaging": 0,
299
+ "sizeId": "4",
300
+ "sizePanelName": "M",
301
+ "productSizeCodeExternal": "PX-ZERO-M",
302
+ "productSizeCodeProducer": "1234567890135",
303
+ "productInPersistent": "y",
304
+ "productSizeWeight": 0
305
+ },
306
+ {
307
+ "productSizeWeightWithoutPackaging": 0,
308
+ "sizeId": "5",
309
+ "sizePanelName": "L",
310
+ "productSizeCodeExternal": "PX-ZERO-L",
311
+ "productSizeCodeProducer": "1234567890142",
312
+ "productInPersistent": "y",
313
+ "productSizeWeight": 0
314
+ },
315
+ {
316
+ "productSizeWeightWithoutPackaging": 0,
317
+ "sizeId": "6",
318
+ "sizePanelName": "XL",
319
+ "productSizeCodeExternal": "PX-ZERO-X",
320
+ "productSizeCodeProducer": "1234567890159",
321
+ "productInPersistent": "y",
322
+ "productSizeWeight": 0
323
+ }
324
+ ],
325
+ "productSizes": [
326
+ {
327
+ "sizeId": "3",
328
+ "sizePanelName": "S"
329
+ },
330
+ {
331
+ "sizeId": "4",
332
+ "sizePanelName": "M"
333
+ },
334
+ {
335
+ "sizeId": "5",
336
+ "sizePanelName": "L"
337
+ },
338
+ {
339
+ "sizeId": "6",
340
+ "sizePanelName": "XL"
341
+ }
342
+ ]
343
+ }
@@ -0,0 +1,24 @@
1
+ import distUtils from '$dist/utils.ts';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from "./util.data";
4
+ import ENUMS from '$dist/enums';
5
+
6
+ const CODES = ENUMS.PRODUCT_SIZE_CODES;
7
+
8
+ test('Utils mapProductCodes on sizePanelName', () => {
9
+ expect(CODES.NAME).toEqual('sizePanelName');
10
+ const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.NAME)
11
+ expect(codes).toEqual({"3": "S","4": "M","5": "L","6": "XL"});
12
+ })
13
+
14
+ test('Utils mapProductCodes on productSizeCodeProducer', () => {
15
+ expect(CODES.CODE_PRODUCER).toEqual('productSizeCodeProducer');
16
+ const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_PRODUCER)
17
+ expect(codes).toEqual({"3": "1234567890128","4": "1234567890135","5": "1234567890142","6": "1234567890159"});
18
+ })
19
+
20
+ test('Utils mapProductCodes on productSizeCodeExternal', () => {
21
+ expect(CODES.CODE_EXTERNAL).toEqual('productSizeCodeExternal');
22
+ const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_EXTERNAL)
23
+ expect(codes).toEqual({"3": "PX-ZERO-S","4": "PX-ZERO-M","5": "PX-ZERO-L","6": "PX-ZERO-X"});
24
+ })
@@ -0,0 +1,29 @@
1
+ import distUtils from '$dist/utils.ts';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from "./util.data";
4
+ import { ENUMS } from '$dist';
5
+
6
+ const LOCATION = ENUMS.PRODUCT_SIZE_LOCATIONS;
7
+
8
+ test('Utils mapProductLocations on stockLocationCode', () => {
9
+ expect(LOCATION.CODE).toEqual('stockLocationCode');
10
+ const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.CODE)
11
+ expect(locations).toEqual({"3":["F","P","A"],"4":["F"],"5":["B"],"6":["B"]});
12
+ })
13
+
14
+ test('Utils mapProductLocations on stockLocationTextId', () => {
15
+ expect(LOCATION.NAME).toEqual('stockLocationTextId');
16
+ const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.NAME)
17
+ expect(locations).toEqual({"3":["M1\\A014","M1\\A015","M1\\A113"],"4":["M1\\A014"],"5":["M1\\B013"],"6":["M1\\B013"]});
18
+ })
19
+
20
+ test('Utils mapProductLocations on stockLocationId', () => {
21
+ expect(LOCATION.ID).toEqual('stockLocationId');
22
+ const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.ID)
23
+ expect(locations).toEqual({"3":["16","46","1"],"4":["16"],"5":["4"],"6":["4"]});
24
+ })
25
+
26
+ test('Utils mapProductLocations full', () => {
27
+ const locations = distUtils.mapProductLocations(STOCK_PRODUCT)
28
+ expect(locations).toEqual({"3":["M1\\A014","M1\\A015","M1\\A113","M2\\G013","M3\\K014"],"4":["M1\\A014","M2\\G015","M3\\L013"],"5":["M1\\B013","M2\\G114","M3\\L013"],"6":["M1\\B013","M2\\G214","M3\\K014"]});
29
+ })
@@ -0,0 +1,48 @@
1
+ import distUtils from '$dist/utils.ts';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from "./util.data";
4
+ import ENUMS from '$dist/enums';
5
+
6
+ const COUNTABLE = ENUMS.PRODUCT_SIZE_COUNTABLE;
7
+
8
+ test('Utils mapSizeQuantites on productSizeQuantity', () => {
9
+ expect(COUNTABLE.QUANTITY).toEqual('productSizeQuantity');
10
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY)
11
+ expect(quantities).toEqual({"3":10,"4":10,"5":0,"6":0});
12
+ })
13
+
14
+ test('Utils mapSizeQuantites on productSizeQuantityOwnStock', () => {
15
+ expect(COUNTABLE.QUANTITY_OWN).toEqual('productSizeQuantityOwnStock');
16
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_OWN)
17
+ expect(quantities).toEqual({"3":8,"4":10,"5":0,"6":0});
18
+ })
19
+
20
+ test('Utils mapSizeQuantites on productSizeQuantityOutsideStock', () => {
21
+ expect(COUNTABLE.QUANTITY_OUTSIDE).toEqual('productSizeQuantityOutsideStock');
22
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_OUTSIDE)
23
+ expect(quantities).toEqual({"3":0,"4":0,"5":5,"6":0});
24
+ })
25
+
26
+ test('Utils mapSizeQuantites on productSizeQuantityAllStocks', () => {
27
+ expect(COUNTABLE.QUANTITY_ALL).toEqual('productSizeQuantityAllStocks');
28
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_ALL)
29
+ expect(quantities).toEqual({"3":8,"4":10,"5":5,"6":0});
30
+ })
31
+
32
+ test('Utils mapSizeQuantites on productOrdersUnfinishedQuantities', () => {
33
+ expect(COUNTABLE.QUANTITY_ORDERS_UNFINISHED).toEqual('productOrdersUnfinishedQuantities');
34
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_ORDERS_UNFINISHED)
35
+ expect(quantities).toEqual({"3":2});
36
+ })
37
+
38
+ test('Utils mapSizeQuantites on productSizesDeliveries', () => {
39
+ expect(COUNTABLE.DELIVERIES).toEqual('productSizesDeliveries');
40
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.DELIVERIES)
41
+ expect(quantities).toEqual({"5":3,"6":3});
42
+ })
43
+
44
+ test('Utils mapSizeQuantites on productSizesDispositionsInAuctions', () => {
45
+ expect(COUNTABLE.AUCTIONS).toEqual('productSizesDispositionsInAuctions');
46
+ const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.AUCTIONS)
47
+ expect(quantities).toEqual({"3":1,"4":0,"5":0,"6":0});
48
+ })
@@ -0,0 +1,48 @@
1
+ import distUtils from '$dist/utils.ts';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from "./util.data";
4
+ import ENUMS from '$dist/enums';
5
+
6
+ const COUNTABLE = ENUMS.PRODUCT_SIZE_COUNTABLE;
7
+
8
+ test('Utils sumProductQuantities on productSizeQuantity', () => {
9
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY).toEqual('productSizeQuantity');
10
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY)
11
+ expect(sum).toEqual(20);
12
+ })
13
+
14
+ test('Utils sumProductQuantities on productSizeQuantityOwnStock', () => {
15
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_OWN).toEqual('productSizeQuantityOwnStock');
16
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_OWN)
17
+ expect(sum).toEqual(18);
18
+ })
19
+
20
+ test('Utils sumProductQuantities on productSizeQuantityOutsideStock', () => {
21
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_OUTSIDE).toEqual('productSizeQuantityOutsideStock');
22
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_OUTSIDE)
23
+ expect(sum).toEqual(5);
24
+ })
25
+
26
+ test('Utils sumProductQuantities on productSizeQuantityAllStocks', () => {
27
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_ALL).toEqual('productSizeQuantityAllStocks');
28
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_ALL)
29
+ expect(sum).toEqual(23);
30
+ })
31
+
32
+ test('Utils sumProductQuantities on productOrdersUnfinishedQuantities', () => {
33
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_ORDERS_UNFINISHED).toEqual('productOrdersUnfinishedQuantities');
34
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_ORDERS_UNFINISHED)
35
+ expect(sum).toEqual(2);
36
+ })
37
+
38
+ test('Utils sumProductQuantities on productSizesDeliveries', () => {
39
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.DELIVERIES).toEqual('productSizesDeliveries');
40
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.DELIVERIES)
41
+ expect(sum).toEqual(6);
42
+ })
43
+
44
+ test('Utils sumProductQuantities on productSizesDispositionsInAuctions', () => {
45
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.AUCTIONS).toEqual('productSizesDispositionsInAuctions');
46
+ const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.AUCTIONS)
47
+ expect(sum).toEqual(1);
48
+ })