idosell 0.4.18 → 0.4.23

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/README.md CHANGED
@@ -15,7 +15,7 @@ const idosellRequest = idosell('SHOP_URL', 'API_KEY', API_VERSION)
15
15
 
16
16
  **API_KEY** can be obtained in your Idosell panel.
17
17
  **SHOP_URL** is the base URI of your shop.
18
- **API_VERSION** version of the API to call, current default version is **v6**
18
+ **API_VERSION** version of the API to call, current default version is **v7**
19
19
  Here are some examples:
20
20
  ```
21
21
  https://yourdomain.com
package/changelog.md CHANGED
@@ -5,12 +5,25 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.23] - 2025-03-11
9
+ ### Changed
10
+ - Added custom error class
11
+ - Fixed types for ids that can be integer instead of string
12
+ - Changed types of execution options, this allows custom logs
13
+
14
+ ## [0.4.20] - 2025-12-18
15
+ ### Changed
16
+ - Added indexing option for utils functions
17
+ - Fixed typings and tests
18
+ - Added descriptions
19
+
8
20
  ## [0.4.18] - 2025-12-18
21
+ ### Changed
9
22
  - Updated to v7.10
10
23
  - Updated utils
11
24
  - Fixed dates helper default value
12
25
  - Improved typing on empty PHP objects conversion
13
- - Updated axios
26
+ - Updated axios version
14
27
 
15
28
  ## [0.4.13] - 2025-10-15
16
29
  ### Changed
package/dist/app.d.ts CHANGED
@@ -1,7 +1,13 @@
1
+ export interface ExecutableDumpParams {
2
+ url: string;
3
+ method: string;
4
+ params: Record<string,any>;
5
+ }
6
+
1
7
  export interface ExecutableOptions {
2
- log?: boolean,
3
- dump?: boolean,
4
- logPage?: boolean,
8
+ log?: boolean | ((obj: ExecutableDumpParams) => void),
9
+ dump?: boolean | ((obj: ExecutableDumpParams) => void),
10
+ logPage?: boolean | ((text: string) => void),
5
11
  skipCheck?: boolean
6
12
  }
7
13
 
@@ -32,12 +38,13 @@ export type GatewayRequestProxyObject = {
32
38
  arrayNode: string,
33
39
  except: string[]
34
40
  },
35
- custom?: Record<string,Function>,
41
+ custom?: Record<string,(..._: any) => false|Record<string,any>>,
36
42
  snakeCase?: boolean,
37
43
  next?: boolean,
38
44
  rootparams?: string|boolean,
39
45
  arrays?: string[],
40
46
  req?: RequirementType[],
47
+ n?: Record<string,number>,
41
48
  } & RequestProxyObject;
42
49
 
43
50
  export interface Gateway<R = JSObject, P = JSObject> {
@@ -91,4 +98,9 @@ export interface AppendableGateway<T,R = JSObject, P = JSObject> extends Gateway
91
98
  append: () => T
92
99
  }
93
100
 
94
- export {};
101
+ export interface IdosellErrorFaultStructure {
102
+ faultCode: number;
103
+ faultString: string;
104
+ }
105
+
106
+ export {};
package/dist/enums.d.ts CHANGED
@@ -379,15 +379,16 @@ export enum PRODUCT_SIZE_COUNTABLE {
379
379
  QUANTITY_OWN = 'productSizeQuantityOwnStock',
380
380
  QUANTITY_OUTSIDE = 'productSizeQuantityOutsideStock',
381
381
  QUANTITY_ALL = 'productSizeQuantityAllStocks',
382
- QUANTITY_ORDERS_UNFINISHED = 'productOrdersUnfinishedQuantities',
382
+ QUANTITY_UNFINISHED = 'productOrdersUnfinishedQuantities',
383
383
  DELIVERIES = 'productSizesDeliveries',
384
384
  AUCTIONS = 'productSizesDispositionsInAuctions',
385
+ RESERVATIONS = 'productSizeReservationOrder'
385
386
  }
386
387
 
387
388
  export enum PRODUCT_SIZE_CODES {
388
389
  NAME = 'sizePanelName',
389
390
  CODE_PRODUCER = 'productSizeCodeProducer',
390
- CODE_EXTERNAL = 'productSizeCodeExternal',
391
+ CODE_EXTERNAL = 'productSizeCodeExternal'
391
392
  }
392
393
 
393
394
  export enum PRODUCT_SIZE_LOCATIONS {
package/dist/enums.js CHANGED
@@ -380,9 +380,10 @@ var PRODUCT_SIZE_COUNTABLE;
380
380
  PRODUCT_SIZE_COUNTABLE["QUANTITY_OWN"] = "productSizeQuantityOwnStock";
381
381
  PRODUCT_SIZE_COUNTABLE["QUANTITY_OUTSIDE"] = "productSizeQuantityOutsideStock";
382
382
  PRODUCT_SIZE_COUNTABLE["QUANTITY_ALL"] = "productSizeQuantityAllStocks";
383
- PRODUCT_SIZE_COUNTABLE["QUANTITY_ORDERS_UNFINISHED"] = "productOrdersUnfinishedQuantities";
383
+ PRODUCT_SIZE_COUNTABLE["QUANTITY_UNFINISHED"] = "productOrdersUnfinishedQuantities";
384
384
  PRODUCT_SIZE_COUNTABLE["DELIVERIES"] = "productSizesDeliveries";
385
385
  PRODUCT_SIZE_COUNTABLE["AUCTIONS"] = "productSizesDispositionsInAuctions";
386
+ PRODUCT_SIZE_COUNTABLE["RESERVATIONS"] = "productSizeReservationOrder";
386
387
  })(PRODUCT_SIZE_COUNTABLE || (PRODUCT_SIZE_COUNTABLE = {}));
387
388
  var PRODUCT_SIZE_CODES;
388
389
  (function (PRODUCT_SIZE_CODES) {
package/dist/errors.js ADDED
@@ -0,0 +1,16 @@
1
+ export class IdosellFaultStringError extends Error {
2
+ cause;
3
+ constructor(message, cause) {
4
+ super(message);
5
+ this.name = 'IdosellFaultStringError';
6
+ this.cause = cause;
7
+ }
8
+ }
9
+ export function catchEmptyList(defaultValue) {
10
+ return (err) => {
11
+ if (err?.cause?.faultCode === 2) {
12
+ return defaultValue;
13
+ }
14
+ throw err;
15
+ };
16
+ }
@@ -1,10 +1,18 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-object-type */
2
- import type { PagableGateway, AppendableGateway, Gateway, DateLike, JSObject } from "./app.d.ts"
2
+ import type { PagableGateway, AppendableGateway, Gateway, DateLike, JSObject, IdosellErrorFaultStructure } from "./app.d.ts"
3
3
  import type { GetClientsBalanceResponse, BooleanStatusResponse, GetClientsResponse, PostClientsResponse, PutClientsResponse, SearchClientsCrmResponse, GetClientsDeliveryAddressResponse, PostClientsDeliveryAddressResponse, PutClientsDeliveryAddressResponse, VouchersResponse, PutVouchersResponse, SearchClientsGiftcardsResponse, GetClientsGiftcardsTypesResponse, GetClientsMembershipCardsResponse, PutClientsMembershipCardsResponse, SearchClientsNewsletterEmailResponse, SearchClientsNewsletterSmsResponse, GetClientsPayerAddressResponse, PostClientsPayerAddressResponse, PutClientsPayerAddressResponse, GetClientsPricelistsClientsResponse, PutClientsPricelistsClientsResponse, GetClientsPricelistsResponse, PostClientsPricelistsResponse, GetClientsPricelistsProductsResponse, PutClientsPricelistsProductsResponse, GetClientsPricesActiveCardResponse, GetClientsPricesDiscountGroupsResponse, GetClientsPricesDiscountsResponse, PutClientsPricesDiscountsResponse, GetClientsProfitPointsResponse, GetClientsProvinceListResponse, GetClientsTagsResponse, PostClientsTagsResponse, PutClientsTagsResponse, GetConfigVariablesResponse, PutConfigVariablesResponse, GetCouriersAssignedToShippingProfilesResponse, GetCouriersResponse, GetCouriersPickupPointsResponse, PutCouriersPickupPointsResponse, GetCpaCampaignResponse, CmsCampaignResponse, CmsResponse, GetCpaResponse, GetDeliveriesProfilesResponse, GetDeliveriesRegionsResponse, PostDeliveriesRegionsResponse, GetDiscountsGroupsClientsResponse, GetDiscountsGroupsResponse, PostDiscountsGroupsResponse, GetEntriesResponse, PostEntriesResponse, GetEntriesPagesToDisplayResponse, GetEntriesSourcesResponse, GetMenuResponse, PostMenuResponse, PutMenuResponse, PutMenuSortResponse, GetOrdersAnalyticsResponse, GetOrdersAuctionDetailsResponse, PutOrdersCourierResponse, PostOrdersDocumentsCreateResponse, GetOrdersDocumentsResponse, PostOrdersDocumentsResponse, GetOrdersHandlerResponse, GetOrdersHistoryResponse, GetOrdersImagesResponse, PostOrdersImagesResponse, GetOrdersLabelsResponse, SearchOrdersOpinionsResponse, GetOrdersOpinionsRateResponse, SearchOrdersResponse, PostOrdersResponse, PutOrdersResponse, GetOrdersPackagesResponse, PutOrdersPackagesResponse, PutOrdersProductsSerialNumbersResponse, PutOrdersProfitMarginResponse, GetOrdersProfitabilityResponse, GetOrdersStatusesResponse, GetOrdersWarehouseResponse, PostPackagesLabelsResponse, PutPackagesResponse, SearchPackagesResponse, GetPaymentsFormsResponse, GetPaymentsResponse, PostPaymentsResponse, GetPaymentsProfilesResponse, PostPaymentsRepaymentResponse, GetProductsSKUbyBarcodeResponse, PutProductsAttachmentsResponse, GetProductsAuctionsResponse, GetProductsBrandsResponse, PutProductsBrandsResponse, GetProductsCategoriesResponse, PutProductsCategoriesResponse, SearchProductsCategoriesIdosellResponse, GetProductsCodeExistenceResponse, SearchProductsDeliveryTimeResponse, GetProductsDescriptionsResponse, ProductIdentResponse, PutProductsGroupsSettingsResponse, GetProductsIdBySizecodeResponse, PutProductsImagesResponse, GetProductsMarketingPromotionResponse, PostProductsMarketingPromotionResponse, PutProductsMarketingPromotionResponse, GetProductsMarketingZonesResponse, PutProductsMarketingZonesResponse, GetProductsOmnibusPricesResponse, GetProductsOpinionsResponse, PostProductsOpinionsResponse, GetProductsOpinionsRateResponse, PutProductsParametersResponse, SearchProductsParametersResponse, SearchProductsResponse, PostProductsResponse, PutProductsResponse, GetProductsQuestionsResponse, GetProductsReservationsResponse, GetProductsSeriesResponse, PutProductsSeriesResponse, GetProductsSizesResponse, PutProductsSizesResponse, PutProductsStockQuantityResponse, GetProductsStocksResponse, PutProductsStocksResponse, GetProductsStrikethroughPricesResponse, PutProductsSupplierCodeResponse, PutProductsSupplierProductDataResponse, GetResponsibilityEntitiesResponse, PutResponsibilityEntitiesResponse, GetReturnsResponse, PostReturnsResponse, PutReturnsResponse, PutReturnsSerialNumberResponse, GetRmaResponse, PutRmaResponse, GetRmaStatusesResponse, GetShopsCurrenciesResponse, GetShopsLanguagesResponse, GetSizechartsResponse, PutSizechartsResponse, GetSizesResponse, PutSizesResponse, GetSnippetsCampaignResponse, GetSnippetsCookiesResponse, GetSnippetsResponse, GetSystemConfigResponse, GetSystemCurrenciesResponse, PutSystemCurrenciesResponse, GetSystemProcessesAutomationResponse, GetSystemServerLoadResponse, GetSystemServerTimeResponse, GetSystemShopsDataResponse, GetSystemUnitsResponse, PutSystemUnitsResponse, GetSystemUsersResponse, GetVouchersTypesResponse, GetVouchersResponse, GetWarrantiesCountTotalResponse, PutWarrantiesLanguageDataResponse, GetWarrantiesResponse, PutWarrantiesResponse, GetWmsLocationsResponse, GetWmsStocksdocumentsDocumentsResponse, PostWmsStocksdocumentsDocumentsResponse, PutWmsStocksdocumentsDocumentsResponse, GetWmsStocksdocumentsOpenedDocumentsResponse, GetWmsStocksdocumentsProductsResponse, PutWmsStocksdocumentsProductsResponse, GetWmsSuppliersResponse, PutWmsSuppliersResponse } from "./responses.d.ts"
4
4
  import type * as RequestParams from "./reqparams.d.ts";
5
5
  import * as ENUMS from "./enums";
6
6
  import utils from "./utils";
7
7
 
8
+ export class IdosellFaultStringError extends Error {
9
+ cause: IdosellFaultStringError;
10
+ constructor(message: string, cause: IdosellErrorFaultStructure);
11
+ }
12
+
13
+ export function catchEmptyList(): (_err: IdosellFaultStringError) => undefined;
14
+ export function catchEmptyList<T>(_defaultValue: T): (_err: IdosellFaultStringError) => T;
15
+
8
16
  export interface GetClientsBalanceRequest extends PagableGateway<GetClientsBalanceRequest, GetClientsBalanceResponse> {
9
17
  /** Customer Id */
10
18
  clientNumbers: (value: number|string|number[]|string[]) => this;
@@ -67,7 +75,7 @@ export interface GetClientsRequest extends PagableGateway<GetClientsRequest, Get
67
75
  /** Client Registration Date */
68
76
  clientRegistrationDate: (value: JSObject) => this;
69
77
  /** The ID of the shop, that client is assigned to. */
70
- shopId: (value: string) => this;
78
+ shopId: (value: number|string) => this;
71
79
  /** Define range of dates */
72
80
  lastPurchased: (dateFrom: DateLike, dateTo: DateLike) => this;
73
81
  /** Define range of dates */
@@ -163,7 +171,7 @@ export interface PutClientsRequest extends AppendableGateway<PutClientsRequest,
163
171
  /** Country ID in accordance with ISO-3166. */
164
172
  clientCountryId: (clientCountryId: string) => this
165
173
  /** Administrative region code. */
166
- clientProvinceId: (clientProvinceId: string) => this
174
+ clientProvinceId: (clientProvinceId: number|string) => this
167
175
  /** Customer password (min. 8 characters). */
168
176
  clientPassword: (clientPassword: string) => this
169
177
  /** Date of birth. */
@@ -331,9 +339,9 @@ export interface PostClientsDeliveryAddressRequest extends AppendableGateway<Pos
331
339
  /** Recipient street and number. */
332
340
  clientDeliveryAddressStreet: (clientDeliveryAddressStreet: string) => this
333
341
  /** Administrative region code. */
334
- clientDeliveryAddressRegionId: (clientDeliveryAddressRegionId: string) => this
342
+ clientDeliveryAddressRegionId: (clientDeliveryAddressRegionId: number|string) => this
335
343
  /** Administrative region code. */
336
- clientDeliveryAddressProvinceId: (clientDeliveryAddressProvinceId: string) => this
344
+ clientDeliveryAddressProvinceId: (clientDeliveryAddressProvinceId: number|string) => this
337
345
  /** Recipient's postal code. */
338
346
  clientDeliveryAddressZipCode: (clientDeliveryAddressZipCode: string) => this
339
347
  /** Recipient's country. */
@@ -348,7 +356,7 @@ export interface PutClientsDeliveryAddressRequest extends AppendableGateway<PutC
348
356
  /** External system code. */
349
357
  clientCodeExternal: (clientCodeExternal: string) => this
350
358
  /** Delivery address ID. */
351
- clientDeliveryAddressId: (clientDeliveryAddressId: string) => this
359
+ clientDeliveryAddressId: (clientDeliveryAddressId: number|string) => this
352
360
  /** List of stores IDs When mask is determined, this parameter is omitted. */
353
361
  shopsIds: (shopsIds: number|string|number[]|string[]) => this
354
362
  /** Currency ID */
@@ -366,9 +374,9 @@ export interface PutClientsDeliveryAddressRequest extends AppendableGateway<PutC
366
374
  /** Recipient street and number. */
367
375
  clientDeliveryAddressStreet: (clientDeliveryAddressStreet: string) => this
368
376
  /** Administrative region code. */
369
- clientDeliveryAddressRegionId: (clientDeliveryAddressRegionId: string) => this
377
+ clientDeliveryAddressRegionId: (clientDeliveryAddressRegionId: number|string) => this
370
378
  /** Administrative region code. */
371
- clientDeliveryAddressProvinceId: (clientDeliveryAddressProvinceId: string) => this
379
+ clientDeliveryAddressProvinceId: (clientDeliveryAddressProvinceId: number|string) => this
372
380
  /** Recipient's postal code. */
373
381
  clientDeliveryAddressZipCode: (clientDeliveryAddressZipCode: string) => this
374
382
  /** Recipient's country. */
@@ -551,7 +559,7 @@ export interface DeleteClientsPayerAddressRequest extends AppendableGateway<Dele
551
559
 
552
560
  export interface GetClientsPayerAddressRequest extends PagableGateway<GetClientsPayerAddressRequest, GetClientsPayerAddressResponse> {
553
561
  /** Unique client's number. */
554
- clientId: (value: string) => this;
562
+ clientId: (value: number|string) => this;
555
563
  /** Page with results number. Numeration starts from 0 */
556
564
  resultsPage: (value: number|string) => this;
557
565
  /** Number of results on page. Value from 1 to 100 */
@@ -585,9 +593,9 @@ export interface PostClientsPayerAddressRequest extends AppendableGateway<PostCl
585
593
  export interface PutClientsPayerAddressRequest extends AppendableGateway<PutClientsPayerAddressRequest, PutClientsPayerAddressResponse, RequestParams.PutClientsPayerAddressParams> {
586
594
  payers: (value: RequestParams.PutClientsPayerAddressParams["payers"]) => this;
587
595
  /** Unique client's number. */
588
- clientId: (clientId: string) => this
596
+ clientId: (clientId: number|string) => this
589
597
  /** Buyer's address id. */
590
- payerAddressId: (payerAddressId: string) => this
598
+ payerAddressId: (payerAddressId: number|string) => this
591
599
  /** Buyer's first name. */
592
600
  payerAddressFirstName: (payerAddressFirstName: string) => this
593
601
  /** Buyer's last name. */
@@ -869,7 +877,7 @@ export interface GetCouriersRequest extends PagableGateway<GetCouriersRequest, G
869
877
  export interface DeleteCouriersPickupPointsRequest extends AppendableGateway<DeleteCouriersPickupPointsRequest> {
870
878
  pickupPointDeleteRequests: (value: Array<JSObject>) => this;
871
879
  /** Collection point ID. */
872
- pickupPointId: (pickupPointId: string) => this
880
+ pickupPointId: (pickupPointId: number|string) => this
873
881
  /** external system code. */
874
882
  pickupPointExternalId: (pickupPointExternalId: string) => this
875
883
  /** Courier ID. */
@@ -880,7 +888,7 @@ export interface GetCouriersPickupPointsRequest extends PagableGateway<GetCourie
880
888
  /** Courier ID. */
881
889
  courierId: (value: number|string) => this;
882
890
  /** Collection point ID. */
883
- pickupPointId: (value: string) => this;
891
+ pickupPointId: (value: number|string) => this;
884
892
  /** External system code. */
885
893
  pickupPointExternalId: (value: string) => this;
886
894
  /** Page with results number. Numeration starts from 0 */
@@ -912,7 +920,7 @@ export interface PostCouriersPickupPointsRequest extends AppendableGateway<PostC
912
920
  export interface PutCouriersPickupPointsRequest extends AppendableGateway<PutCouriersPickupPointsRequest, PutCouriersPickupPointsResponse, RequestParams.PutCouriersPickupPointsParams> {
913
921
  pickupPoints: (value: RequestParams.PutCouriersPickupPointsParams["pickupPoints"]) => this;
914
922
  /** Collection point ID. */
915
- pickupPointId: (pickupPointId: string) => this
923
+ pickupPointId: (pickupPointId: number|string) => this
916
924
  /** external system code. */
917
925
  pickupPointExternalId: (pickupPointExternalId: string) => this
918
926
  /** Courier ID. */
@@ -1272,7 +1280,7 @@ export interface PutMenuFilterRequest extends AppendableGateway<PutMenuFilterReq
1272
1280
  /** Active filters. */
1273
1281
  menuFiltersActive: (value: Array<JSObject>) => this;
1274
1282
  /** Menu filter ID. */
1275
- menuFilterId: (menuFilterId: string) => this
1283
+ menuFilterId: (menuFilterId: number|string) => this
1276
1284
  /** Filter name on page. */
1277
1285
  menuFilterName: (menuFilterName: string) => this
1278
1286
  /** Display as: "name" - text, "gfx" - graphics, "namegfx" - text and graphics. */
@@ -1321,7 +1329,7 @@ export interface PostMenuRequest extends AppendableGateway<PostMenuRequest, Post
1321
1329
  /** Menu ID. */
1322
1330
  menu_id: (menu_id: number|string) => this
1323
1331
  /** Parent menu element ID. */
1324
- parent_id: (parent_id: string) => this
1332
+ parent_id: (parent_id: number|string) => this
1325
1333
  /** Menu element text identifier. Example: "item1\item2". */
1326
1334
  parent_textid: (parent_textid: string) => this
1327
1335
  /** */
@@ -1337,7 +1345,7 @@ export interface PutMenuRequest extends AppendableGateway<PutMenuRequest, PutMen
1337
1345
  /** Menu ID. */
1338
1346
  menu_id: (menu_id: number|string) => this
1339
1347
  /** Menu element ID. */
1340
- item_id: (item_id: string) => this
1348
+ item_id: (item_id: number|string) => this
1341
1349
  /** Menu element text identifier. Example: "item1\item2\item3". */
1342
1350
  item_textid: (item_textid: string) => this
1343
1351
  /** */
@@ -1389,7 +1397,7 @@ export interface PutOrdersCourierRequest extends Gateway<PutOrdersCourierRespons
1389
1397
  /** Courier ID. */
1390
1398
  courierId: (value: number|string) => this;
1391
1399
  /** Collection point ID. */
1392
- pickupPointId: (value: string) => this;
1400
+ pickupPointId: (value: number|string) => this;
1393
1401
  }
1394
1402
 
1395
1403
  export interface PutOrdersDeliveryAddressRequest extends Gateway {
@@ -1436,7 +1444,7 @@ export interface DeleteOrdersDocumentsRequest extends AppendableGateway<DeleteOr
1436
1444
 
1437
1445
  export interface GetOrdersDocumentsRequest extends Gateway<GetOrdersDocumentsResponse> {
1438
1446
  /** Order serial number. */
1439
- orderSerialNumber: (value: string|string[]) => this;
1447
+ orderSerialNumber: (value: number|string|number[]|string[]) => this;
1440
1448
  /** Document type */
1441
1449
  documentType: (value: 'sales_confirmation'|'vat_invoice'|'corrective_vat_invoice'|'advance_vat_invoice'|'final_advance_vat_invoice'|'pro_forma_invoice'|'advance_pro_forma_invoice'|'final_advance_pro_forma_invoice'|'delivery_note'|'fiscal_receipt'|'fiscal_invoice'|'other') => this;
1442
1450
  /** Elements returned by api */
@@ -1629,7 +1637,7 @@ export interface PostOrdersRequest extends AppendableGateway<PostOrdersRequest,
1629
1637
  /** Courier ID. */
1630
1638
  courierId: (courierId: number|string) => this
1631
1639
  /** Collection point ID. */
1632
- pickupPointId: (pickupPointId: string) => this
1640
+ pickupPointId: (pickupPointId: number|string) => this
1633
1641
  /** Delivery cost. */
1634
1642
  deliveryCost: (deliveryCost: number) => this
1635
1643
  /** Delivery address data. */
@@ -1662,7 +1670,7 @@ export interface PutOrdersRequest extends AppendableGateway<PutOrdersRequest, Pu
1662
1670
  /** Orders. */
1663
1671
  orders: (value: RequestParams.PutOrdersParams["orders"]) => this;
1664
1672
  /** Order ID. */
1665
- orderId: (orderId: string) => this
1673
+ orderId: (orderId: number|string) => this
1666
1674
  /** Order serial number. */
1667
1675
  orderSerialNumber: (orderSerialNumber: number|string) => this
1668
1676
  /** Order status. Allowed values: "finished_ext" - order status: completed in FA application, "finished" - completed, "new" - not handled, "payment_waiting" - awaiting payment, "delivery_waiting" - awaiting delivery, "on_order" - in progress, "packed" - being picked, "packed_fulfillment" - being picked - fulfilment, "packed_ready" - packed, "ready" - ready, "wait_for_dispatch" - awaiting dispatch date, "suspended" - on hold, "joined" - merged, "missing" - missing, "lost" - lost, "false" - false, "canceled" - Customer canceled. */
@@ -1722,7 +1730,7 @@ export interface SearchOrdersRequest extends PagableGateway<SearchOrdersRequest,
1722
1730
  orderType: (value: 'wholesale'|'retail'|'dropshipping'|'deliverer') => this;
1723
1731
  dropshippingOrderStatus: (value: 'all'|'finished'|'canceled'|'notCanceled') => this;
1724
1732
  /** Orders IDs. */
1725
- ordersIds: (value: string|string[]) => this;
1733
+ ordersIds: (value: number|string|number[]|string[]) => this;
1726
1734
  /** Order serial numbers. */
1727
1735
  ordersSerialNumbers: (value: number|string|number[]|string[]) => this;
1728
1736
  /** Customer data. */
@@ -1816,7 +1824,7 @@ export interface PostOrdersPackagesRequest extends AppendableGateway<PostOrdersP
1816
1824
  /** List of parcels assigned to the order Maximum default number: 100 parcels. */
1817
1825
  orderPackages: (value: RequestParams.PostOrdersPackagesParams["orderPackages"]) => this;
1818
1826
  /** Id. */
1819
- eventId: (eventId: string) => this
1827
+ eventId: (eventId: number|string) => this
1820
1828
  /** Type. */
1821
1829
  eventType: (eventType: 'order'|'rma'|'return') => this
1822
1830
  /** Information on consignments. */
@@ -1827,7 +1835,7 @@ export interface PutOrdersPackagesRequest extends AppendableGateway<PutOrdersPac
1827
1835
  /** List of parcels assigned to the order Maximum default number: 100 parcels. */
1828
1836
  orderPackages: (value: RequestParams.PutOrdersPackagesParams["orderPackages"]) => this;
1829
1837
  /** Id. */
1830
- eventId: (eventId: string) => this
1838
+ eventId: (eventId: number|string) => this
1831
1839
  /** Type. */
1832
1840
  eventType: (eventType: 'order'|'rma'|'return') => this
1833
1841
  /** Information on consignments. */
@@ -1838,7 +1846,7 @@ export interface PutOrdersPickupPointRequest extends Gateway<PutOrdersCourierRes
1838
1846
  /** Order serial number. */
1839
1847
  orderSerialNumber: (value: number|string) => this;
1840
1848
  /** Collection point ID. */
1841
- pickupPointId: (value: string) => this;
1849
+ pickupPointId: (value: number|string) => this;
1842
1850
  }
1843
1851
 
1844
1852
  export interface GetOrdersPrinterDocumentsRequest extends Gateway {
@@ -1904,7 +1912,7 @@ export interface SearchOrdersUnfinishedRequest extends PagableGateway<SearchOrde
1904
1912
  /** Dropshipping order status in the supplier's system. Allowed values: "all" - all, "finished" - sent, "canceled" - canceled, "notCanceled" - failed to cancel. */
1905
1913
  dropshippingOrderStatus: (value: 'all'|'finished'|'canceled'|'notCanceled') => this;
1906
1914
  /** Orders IDs. */
1907
- ordersIds: (value: string|string[]) => this;
1915
+ ordersIds: (value: number|string|number[]|string[]) => this;
1908
1916
  /** Order serial numbers. */
1909
1917
  ordersSerialNumbers: (value: number|string|number[]|string[]) => this;
1910
1918
  /** Customer data. */
@@ -2008,7 +2016,7 @@ export interface PostPackagesLabelsRequest extends AppendableGateway<PostPackage
2008
2016
  /** Shipment configuration options available for Inpost Smile courier */
2009
2017
  parcelParametersByPackages: (value: RequestParams.PostPackagesLabelsParams["parcelParametersByPackages"]) => this;
2010
2018
  /** Package ID in system. */
2011
- packageId: (packageId: string) => this
2019
+ packageId: (packageId: number|string) => this
2012
2020
  /** Set order serial number */
2013
2021
  orderSn: (orderSn: number |string) => this;
2014
2022
  /** Set default parcel size */
@@ -2220,7 +2228,7 @@ export interface PutProductsBrandsFilterRequest extends AppendableGateway<PutPro
2220
2228
  /** Active filters. */
2221
2229
  filtersActive: (value: Array<JSObject>) => this;
2222
2230
  /** Menu filter ID. */
2223
- filterId: (filterId: string) => this
2231
+ filterId: (filterId: number|string) => this
2224
2232
  /** Filter name on page. */
2225
2233
  filterName: (filterName: string) => this
2226
2234
  /** Display as: "name" - text, "gfx" - graphics, "namegfx" - text and graphics. */
@@ -2356,7 +2364,7 @@ export interface GetProductsCodeExistenceRequest extends Gateway<GetProductsCode
2356
2364
  identType: (value: 'id'|'index'|'codeExtern'|'codeProducer'|'codeDeliverer') => this;
2357
2365
  /** Products list. */
2358
2366
  products: (value: string|string[]) => this;
2359
- delivererId: (value: string) => this;
2367
+ delivererId: (value: number|string) => this;
2360
2368
  /** Set product identifiers */
2361
2369
  productId: (productId: number|string|number|string|number[]|string[], type?: 'id'|'index'|'codeExtern'|'codeProducer') => this;
2362
2370
  }
@@ -2413,7 +2421,7 @@ export interface SearchProductsDeliveryTimeRequest extends AppendableGateway<Sea
2413
2421
  /** Product Id */
2414
2422
  productId: (productId: number|string) => this
2415
2423
  /** Size identifier */
2416
- sizeId: (sizeId: string) => this
2424
+ sizeId: (sizeId: number|string) => this
2417
2425
  /** Size name */
2418
2426
  sizePanelName: (sizePanelName: string) => this
2419
2427
  /** Product IAI code */
@@ -2492,7 +2500,7 @@ export interface DeleteProductsImagesRequest extends AppendableGateway<DeletePro
2492
2500
  /** Shop Id */
2493
2501
  shopId: (shopId: number|string) => this
2494
2502
  /** */
2495
- productImagesId: (productImagesId: string|string[]) => this
2503
+ productImagesId: (productImagesId: number|string|number[]|string[]) => this
2496
2504
  }
2497
2505
 
2498
2506
  export interface PutProductsImagesRequest extends AppendableGateway<PutProductsImagesRequest, PutProductsImagesResponse, RequestParams.PutProductsImagesParams> {
@@ -2558,12 +2566,12 @@ export interface PostProductsMarketingPromotionRequest extends AppendableGateway
2558
2566
  /** */
2559
2567
  elementType: (elementType: 'product'|'series'|'producer'|'category'|'menu') => this
2560
2568
  /** Identifier of the element affected by the promotion (in the case of a menu in the format: storeId-menuId-itemId) */
2561
- elementId: (elementId: string) => this
2569
+ elementId: (elementId: number|string) => this
2562
2570
  }
2563
2571
 
2564
2572
  export interface PutProductsMarketingPromotionRequest extends AppendableGateway<PutProductsMarketingPromotionRequest, PutProductsMarketingPromotionResponse, RequestParams.PutProductsMarketingPromotionParams> {
2565
2573
  /** Promotion ID */
2566
- promotionId: (value: string) => this;
2574
+ promotionId: (value: number|string) => this;
2567
2575
  /** Promotion name */
2568
2576
  promotionName: (value: string) => this;
2569
2577
  /** List of stores IDs When mask is determined, this parameter is omitted. */
@@ -2593,7 +2601,7 @@ export interface PutProductsMarketingPromotionRequest extends AppendableGateway<
2593
2601
  /** */
2594
2602
  elementType: (elementType: 'product'|'series'|'producer'|'category'|'menu') => this
2595
2603
  /** Identifier of the element affected by the promotion (in the case of a menu in the format: storeId-menuId-itemId) */
2596
- elementId: (elementId: string) => this
2604
+ elementId: (elementId: number|string) => this
2597
2605
  }
2598
2606
 
2599
2607
  export interface GetProductsMarketingZonesRequest extends Gateway<GetProductsMarketingZonesResponse> {
@@ -2750,9 +2758,9 @@ export interface PutProductsParametersRequest extends AppendableGateway<PutProdu
2750
2758
  /** Icons of section, parameter or value to display on the list of products. */
2751
2759
  link_icons: (link_icons: RequestParams.PutProductsParametersParams["items"][number]["link_icons"]) => this
2752
2760
  /** Parameter's additional feature. 1. Status: context_id = "CONTEXT_STATE" Takes values context_value_id: - CONTEXT_STATE_NEW - New, - CONTEXT_STATE_USED - Used, - CONTEXT_STATE_USED_EXCELLENT - Used - excellent condition - CONTEXT_STATE_USED_VERYGOOD - Used - very good condition - CONTEXT_STATE_USED_CORRECT - Used - good condition - CONTEXT_STATE_USED_ACCEPTABLE - Used - acceptable condition - CONTEXT_STATE_REFURBISHED_EXCELLENT - Refurbished - excellent condition - CONTEXT_STATE_REFURBISHED_VERYGOOD - Refurbished - very good condition - CONTEXT_STATE_REFURBISHED_CORRECT - Refurbished - good condition - CONTEXT_STATE_NEW_OTHERS - New other (see details) - CONTEXT_STATE_NEW_WITH_DEFECTS - New with defects - CONTEXT_STATE_NEW_OEM - New - OEM - CONTEXT_STATE_NEW_OPEN_BOX - New - open box - CONTEXT_STATE_REFURBISHED_BY_PRODUCER - Renewed by a manufacturer, - CONTEXT_STATE_REFURBISHED_BY_SELLER - Renewed by a seller, - CONTEXT_STATE_FOR_PARTS_OR_BROKEN - In parts or damaged. 2. Product weight in grams: context_id = "CONTEXT_STD_UNIT_WEIGHT" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 3. A product's value in milliliters: context_id = "CONTEXT_STD_UNIT_VOLUME" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 4. Sex: context_id = "CONTEXT_SEX" Takes values context_value_id: - CONTEXT_SEX_MAN - Man, - CONTEXT_SEX_WOMAN - Woman, - CONTEXT_SEX_UNISEX - Unisex. 5. Age group: context_id = "CONTEXT_AGE_GROUP" Takes values context_value_id: - CONTEXT_AGE_GROUP_ADULT - Adults, - CONTEXT_AGE_GROUP_MINOR - Children. 6. Maximum number of products in an order: context_id = "CONTEXT_MAX_QUANTITY_PER_RETAIL_ORDER" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 7. Maximum number of products in a wholesale order: context_id = "CONTEXT_MAX_QUANTITY_PER_WHOLESALE_ORDER" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 8. Minimal number of products in an order: context_id = "CONTEXT_MIN_QUANTITY_PER_RETAIL_ORDER" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 9. Minimum number of products in a wholesale order: context_id = "CONTEXT_MIN_QUANTITY_PER_WHOLESALE_ORDER" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 10. Maximal number of a single size in an order: context_id = "CONTEXT_MAX_SIZE_QUANTITY_PER_RETAIL_ORDER" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 11. Maximal number of a single size in a wholesale order: context_id = "CONTEXT_MAX_SIZE_QUANTITY_PER_WHOLESALE_ORDER" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 12. Minimal number of a single size in an order: context_id = "CONTEXT_MIN_SIZE_QUANTITY_PER_RETAIL_ORDER" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 13. Minimal number of a single size in a wholesale order: context_id = "CONTEXT_MIN_SIZE_QUANTITY_PER_WHOLESALE_ORDER" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 14. Net weight: context_id = "CONTEXT_WEIGHT_NET" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 15. Color: context_id = "CONTEXT_COLOR" Takes values context_value_id: - Value of additional feature is set automatically basing on the parameter's value. 16. #!TylkoDlaDoroslych!#: context_id = "CONTEXT_ONLY_ADULTS" Takes values context_value_id: - CONTEXT_ONLY_ADULTS_YES - yes, - CONTEXT_ONLY_ADULTS_NO - no. 17. Prescription drug: context_id = "CONTEXT_PRESCRIPTION_MEDICINE" Takes values context_value_id: - CONTEXT_PRESCRIPTION_MEDICINE_YES - yes, - CONTEXT_PRESCRIPTION_MEDICINE_NO - no. 18. Season Rate: context_id = "CONTEXT_SEASON" Takes values context_value_id: - CONTEXT_SEASON_SPRING - Spring, - CONTEXT_SEASON_SUMMER - Summer, - CONTEXT_SEASON_FALL - Autumn, - CONTEXT_SEASON_WINTER - Winter, - CONTEXT_SEASON_SPRING_SUMMER - Spring/Summer, - CONTEXT_SEASON_FALL_WINTER - Autumn/Winter 19. Risk - signal word: context_id = \"CONTEXT_HAZMAT_SIGNAL\" Takes values context_value_id: - CONTEXT_HAZMAT_SIGNAL_DANGER - danger, - CONTEXT_HAZMAT_SIGNAL_WARNING - warnging, - CONTEXT_HAZMAT_SIGNAL_CAUTION - caution, - CONTEXT_HAZMAT_SIGNAL_NOTICE - notice, 20. Risk - warning pictogram context_id = \"CONTEXT_HAZMAT_PICTOGRAM\" Takes values context_value_id: - GHS01, GHS02, GHS03, GHS04, GHS05, GHS06, GHS07, GHS08, GHS09 21. Risk - type of hazard: context_id = \"CONTEXT_HAZMAT_STATEMENT\" Takes values context_value_id: - H200, H201, H202, H203, H204, H205, H220, H221, H222, H223, H224, H225, H226, H228, H240, H241, H242, H250, H251, H252, H260, H261, H270, H271, H272, H280, H281, H290, H300, H301, H302, H304, H310, H311, H312, H314, H315, H317, H318, H319, H330, H331, H332, H334, H335, H336, H340, H341, H350, H351, H360, H361, H362, H370, H371, H372, H373, H400, H410, H411, H412, H413, EUH 001, EUH 014, EUH 018, EUH 019, EUH 044, EUH 029, EUH 031, EUH 032, EUH 066, EUH 070, EUH 071, EUH 201, EUH 201A, EUH 202, EUH 203, EUH 204, EUH 205, EUH 206, EUH 207, EUH 208, EUH 209, EUH 209A, EUH 210, EUH 401 22. Repair score: context_id = \"CONTEXT_REPAIR_SCORE\" Takes values context_value_id: - The value of the additional feature is set automatically based on the parameter's value 23. Safety - information pictogram: context_id = \"CONTEXT_SAFETY_PICTOGRAM\" Takes values context_value_id: - 1 (Not suitable for small children) - 2 (CE mark) 24. Safety - type of warning: context_id = \"CONTEXT_SAFETY_STATEMENT\" Takes values context_value_id: - 1 (Not suitable for children under 3 years) - 2 (Keep out of the reach of children) - 3 (Product contains a button cell or coin battery) - 4 (Use under the direct supervision of adults) - 5 (Required protective gear. Do not use in public traffic) - 6 (Contains toy. Adult supervision recommended) - 7 (To prevent possible injury from entanglement, remove this toy as soon as the child begins to crawl) - 8 (Use only in shallow water under adult supervision) - 9 (Only use under adult supervision) - 10 (This toy does not provide protection) - 11 (Contains fragrances that may cause allergies) - 12 (For household use only). */
2753
- context_id: (context_id: string) => this
2761
+ context_id: (context_id: number|string) => this
2754
2762
  /** value of additional feature - Values described in context_id. */
2755
- context_value_id: (context_value_id: string) => this
2763
+ context_value_id: (context_value_id: number|string) => this
2756
2764
  }
2757
2765
 
2758
2766
  export interface SearchProductsParametersRequest extends PagableGateway<SearchProductsParametersRequest, SearchProductsParametersResponse, RequestParams.SearchProductsParametersParams> {
@@ -2781,7 +2789,7 @@ export interface DeleteProductsRequest extends AppendableGateway<DeleteProductsR
2781
2789
 
2782
2790
  export interface GetProductsRequest extends Gateway<SearchProductsResponse> {
2783
2791
  /** List of the unique, indexed product codes (IAI code / External system code / Producer code). You can transfer a maximum of 100 products IDs in one request. */
2784
- productIds: (value: string|string[]) => this;
2792
+ productIds: (value: number|string|number[]|string[]) => this;
2785
2793
  }
2786
2794
 
2787
2795
  export interface PostProductsRequest extends AppendableGateway<PostProductsRequest, PostProductsResponse, RequestParams.PostProductsParams> {
@@ -3343,7 +3351,7 @@ export interface SearchProductsRequest extends PagableGateway<SearchProductsRequ
3343
3351
  /** Price range for sought products. */
3344
3352
  productSearchPriceRange: (value: RequestParams.SearchProductsParams["productSearchPriceRange"]) => this;
3345
3353
  /** VAT value for sought products */
3346
- productVatRates: (value: Array<Number>) => this;
3354
+ productVatRates: (value: number|number[]) => this;
3347
3355
  /** Is product VAT-free Allowed values "y" - yes, "n" - no. */
3348
3356
  productIsVatFree: (value: string) => this;
3349
3357
  /** Product has defined wholesale price. Available values: "y" - has wholesale price, "n" - does not have wholesale price. */
@@ -3520,7 +3528,7 @@ export interface PutProductsSeriesFilterRequest extends AppendableGateway<PutPro
3520
3528
  /** Active filters. */
3521
3529
  filtersActive: (value: Array<JSObject>) => this;
3522
3530
  /** Menu filter ID. */
3523
- filterId: (filterId: string) => this
3531
+ filterId: (filterId: number|string) => this
3524
3532
  /** Filter name on page. */
3525
3533
  filterName: (filterName: string) => this
3526
3534
  /** Display as: "name" - text, "gfx" - graphics, "namegfx" - text and graphics. */
@@ -3963,7 +3971,7 @@ export interface GetRmaRequest extends PagableGateway<GetRmaRequest, GetRmaRespo
3963
3971
  /** Login of the user handling the complaint */
3964
3972
  operatorLogin: (value: string) => this;
3965
3973
  /** Unique client's number. */
3966
- clientId: (value: string) => this;
3974
+ clientId: (value: number|string) => this;
3967
3975
  /** Complaint creation date in the YYYY-MM-DD format */
3968
3976
  creationDate: (value: JSObject) => this;
3969
3977
  /** Complaint modification date in the YYYY-MM-DD format */
@@ -4044,7 +4052,7 @@ export interface PutSizesRequest extends AppendableGateway<PutSizesRequest, PutS
4044
4052
  /** Size group ID. */
4045
4053
  group_id: (group_id: number|string) => this
4046
4054
  /** Size identifier. */
4047
- id: (id: string) => this
4055
+ id: (id: number|string) => this
4048
4056
  /** Category plural name. */
4049
4057
  name: (name: string) => this
4050
4058
  /** Size description. */
@@ -4546,23 +4554,23 @@ export interface PutVouchersRequest extends AppendableGateway<PutVouchersRequest
4546
4554
  }
4547
4555
 
4548
4556
  export interface GetWarrantiesCountTotalRequest extends Gateway<GetWarrantiesCountTotalResponse> {
4549
- warranty_ids: (value: string|string[]) => this;
4557
+ warranty_ids: (value: number|string|number[]|string[]) => this;
4550
4558
  }
4551
4559
 
4552
4560
  export interface PutWarrantiesLanguageDataRequest extends AppendableGateway<PutWarrantiesLanguageDataRequest, PutWarrantiesLanguageDataResponse, RequestParams.PutWarrantiesLanguageDataParams> {
4553
4561
  lang_data: (value: RequestParams.PutWarrantiesLanguageDataParams["lang_data"]) => this;
4554
4562
  /** Warranty ID (numeric or text based). */
4555
- warranty_id: (warranty_id: string) => this
4563
+ warranty_id: (warranty_id: number|string) => this
4556
4564
  /** */
4557
4565
  lang: (lang: RequestParams.PutWarrantiesLanguageDataParams["lang_data"][number]["lang"]) => this
4558
4566
  }
4559
4567
 
4560
4568
  export interface DeleteWarrantiesRequest extends Gateway {
4561
- warranty_ids: (value: string|string[]) => this;
4569
+ warranty_ids: (value: number|string|number[]|string[]) => this;
4562
4570
  }
4563
4571
 
4564
4572
  export interface GetWarrantiesRequest extends PagableGateway<GetWarrantiesRequest, GetWarrantiesResponse> {
4565
- warranty_ids: (value: string|string[]) => this;
4573
+ warranty_ids: (value: number|string|number[]|string[]) => this;
4566
4574
  /** Number of results on page. */
4567
4575
  results_limit: (value: number|string) => this;
4568
4576
  /** Result page number. */
@@ -4587,7 +4595,7 @@ export interface PostWarrantiesRequest extends AppendableGateway<PostWarrantiesR
4587
4595
  export interface PutWarrantiesRequest extends AppendableGateway<PutWarrantiesRequest, PutWarrantiesResponse, RequestParams.PutWarrantiesParams> {
4588
4596
  warranties: (value: RequestParams.PutWarrantiesParams["warranties"]) => this;
4589
4597
  /** Warranty ID (numeric or text based). */
4590
- id: (id: string) => this
4598
+ id: (id: number|string) => this
4591
4599
  /** Name. */
4592
4600
  name: (name: string) => this
4593
4601
  /** */
@@ -5206,4 +5214,4 @@ export interface Gateways {
5206
5214
 
5207
5215
  declare const defaultExport: (url: string, apiKey: string, version?: number | string) => Gateways;
5208
5216
  export default defaultExport;
5209
- export { ENUMS, RequestParams }
5217
+ export { ENUMS, RequestParams, utils }
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import ENUMS from "./enums.js";
2
2
  import utils from "./utils.js";
3
3
  import { gateProxy } from "./gates.js";
4
+ import { IdosellFaultStringError, catchEmptyList } from "./errors.js";
4
5
  export const DEFAULT_VERSION = 7;
5
6
  const idosell = (url, apiKey, version = DEFAULT_VERSION) => {
6
7
  const auth = { url, apiKey, version, apikey: apiKey ? apiKey.slice(0, 6) + '*'.repeat(20) : "" };
@@ -9,4 +10,4 @@ const idosell = (url, apiKey, version = DEFAULT_VERSION) => {
9
10
  return new Proxy(element, gateProxy);
10
11
  };
11
12
  export default idosell;
12
- export { ENUMS, utils };
13
+ export { ENUMS, utils, IdosellFaultStringError, catchEmptyList };
@@ -6,7 +6,7 @@ export default (object) => {
6
6
  arrayNode: "products",
7
7
  index: 0
8
8
  };
9
- object.req = ["productSizeCodeExternal", "stockId"];
9
+ object.req = [{ "any": ["productSizeCodeExternal", "productIndex", "productSizeCodeProducer"] }, "stockId"];
10
10
  object.arrays = ["products"];
11
11
  return new Proxy(object, paramsProxy);
12
12
  };
package/dist/params.js CHANGED
@@ -32,10 +32,12 @@ export const paramsProxy = {
32
32
  }
33
33
  else if (object.custom && typeof object.custom[property] === 'function') {
34
34
  const param = object.custom[property](...values);
35
- if (param.root)
36
- Object.assign(object.params, param.root);
37
- else
38
- Object.assign(item, param);
35
+ if (param) {
36
+ if (param.root)
37
+ Object.assign(object.params, param.root);
38
+ else
39
+ Object.assign(item, param);
40
+ }
39
41
  }
40
42
  else {
41
43
  item[property] = values[0];
package/dist/request.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import axios from "axios";
2
2
  import { page } from "./helpers.js";
3
- import { inspect } from 'util';
3
+ import { IdosellFaultStringError } from "./errors.js";
4
4
  const DECODE_TABLE = [
5
5
  ['Å\x82', "ł"],
6
6
  ['Ä\x99', 'ę']
7
7
  ];
8
+ const DEFAULT_LOG_FUNCTION = console.log;
8
9
  const catchIdosellError = (err) => {
9
10
  if (!err.response) {
10
11
  if (err.cause)
@@ -29,21 +30,28 @@ const catchIdosellError = (err) => {
29
30
  throw new Error(`${err.response.status}: ${message}`, { cause: err.response.status });
30
31
  };
31
32
  const checkNext = (request, response, logPage) => {
33
+ if (logPage === true)
34
+ logPage = DEFAULT_LOG_FUNCTION;
32
35
  if (!response)
33
36
  return;
34
- if (response?.errors?.faultCode > 0)
35
- throw new Error(response.errors.faultString, { cause: response.errors });
37
+ if (response?.errors?.faultString) {
38
+ const faultStructure = {
39
+ faultCode: response?.errors?.faultCode ?? 999,
40
+ faultString: response.errors.faultString,
41
+ };
42
+ throw new IdosellFaultStringError(response.errors.faultString, faultStructure);
43
+ }
36
44
  if (response.resultsNumberPage) {
37
45
  request.next = response.resultsPage + 1 < response.resultsNumberPage;
38
46
  request.params.resultsPage = request.params.resultsPage ? request.params.resultsPage + 1 : 1;
39
47
  if (logPage)
40
- console.log('Page: ' + response.resultsPage + ' / ' + response.resultsNumberPage);
48
+ logPage('Page: ' + response.resultsPage + ' / ' + response.resultsNumberPage);
41
49
  }
42
50
  else if (response.results_number_page) {
43
51
  request.next = response.results_page + 1 < response.results_number_page;
44
52
  request.params.results_page = request.params.results_page ? request.params.results_page + 1 : 1;
45
53
  if (logPage)
46
- console.log('Page: ' + response.results_page + ' / ' + response.results_page);
54
+ logPage('Page: ' + response.results_page + ' / ' + response.results_page);
47
55
  }
48
56
  return response;
49
57
  };
@@ -141,10 +149,21 @@ export const sendRequest = async (request, options = {}) => {
141
149
  request.next = false;
142
150
  const { method, node } = request.gate;
143
151
  let url = `${request.auth.url}/api/admin/v${request.auth.version}${node}`;
144
- if (options.log || options.dump) {
145
- console.log(inspect({ params: request.params, method, url }, { showHidden: false, depth: null, colors: true }));
146
- if (options.dump)
152
+ if (options.dump || options.log) {
153
+ const dumpData = { params: request.params, method, url };
154
+ if (options.dump) {
155
+ if (options.dump === true)
156
+ DEFAULT_LOG_FUNCTION(dumpData);
157
+ else
158
+ options.dump(dumpData);
147
159
  return {};
160
+ }
161
+ else if (options.log) {
162
+ if (options.log === true)
163
+ DEFAULT_LOG_FUNCTION(dumpData);
164
+ else
165
+ options.log(dumpData);
166
+ }
148
167
  }
149
168
  if (method === 'get' || method === 'delete') {
150
169
  url += '?' + queryfy(request.params);
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PRODUCT_SIZE_COUNTABLE, PRODUCT_SIZE_LOCATIONS, PRODUCT_SIZE_CODES } from "./enums.d";
1
+ import type { PRODUCT_SIZE_COUNTABLE, PRODUCT_SIZE_LOCATIONS, PRODUCT_SIZE_CODES, PRODUCE_SIZE_INDEX } from "./enums.d";
2
2
  import type { SearchProductsResponse } from "./responses.d.ts"
3
3
 
4
4
  export type IdosellProduct = SearchProductsResponse['results'][0];
@@ -7,24 +7,35 @@ export type GetIaICodeFunction = (productId: number|string, sizeId: string) => s
7
7
 
8
8
  export type SumProductQuantitiesFunction = (productStocksData: IdosellProduct['productStocksData'], stockType?: PRODUCT_SIZE_COUNTABLE | `${PRODUCT_SIZE_COUNTABLE}`) => number;
9
9
 
10
- export type MapSizeQuantitesFunction = (product: IdosellProduct, stockType?: `${PRODUCT_SIZE_COUNTABLE}`) => Record<string,number>;
10
+ export type MapSizeQuantitesFunction = (product: IdosellProduct, stockType?: `${PRODUCT_SIZE_COUNTABLE}`, indexBy?: `${PRODUCE_SIZE_INDEX}`) => Record<string,number>;
11
11
 
12
- export type MapProductCodesFunction = (product: IdosellProduct, codeType?: `${PRODUCT_SIZE_CODES}`) => Record<string,string>;
12
+ export type MapProductCodesFunction = (product: IdosellProduct, codeType?: `${PRODUCT_SIZE_CODES}`, indexBy?: `${PRODUCE_SIZE_INDEX}`) => Record<string,string>;
13
13
 
14
- export type MapProductLocationsFunction = (product: IdosellProduct, stockId?: number, codeType?: `${PRODUCT_SIZE_LOCATIONS}`) => Record<string,string[]>;
14
+ export type MapProductAllCodesFunction = (product: IdosellProduct, indexBy?: `${PRODUCE_SIZE_INDEX}`) => Record<string,string[]>;
15
+
16
+ export type MapProductLocationsFunction = (product: IdosellProduct, stockId?: number, codeType?: `${PRODUCT_SIZE_LOCATIONS}`, indexBy?: `${PRODUCE_SIZE_INDEX}`) => Record<string,string[]>;
15
17
 
16
18
  export type GetLangDataFunction = <T extends { langId: string}>(array: T[], langId?: string) => T|undefined;
17
19
 
18
- export type ClearParametersLangDataFunction = (products: SearchProductsResponse['results'], langId: string = 'pol') => SearchProductsResponse['results'];
20
+ export type ClearParametersLangDataFunction = (products: SearchProductsResponse['results'], langId?: string) => SearchProductsResponse['results'];
19
21
 
20
22
  declare namespace utils {
23
+ /** @description The method allows you to build an IAI code from the product ID and size ID. */
21
24
  const getIaiCode: GetIaICodeFunction;
25
+ /** @description The method allows you to sum up the current stock levels: warehouses, available stocks, etc. */
22
26
  const sumProductQuantities: SumProductQuantitiesFunction;
27
+ /** @description The method allows mapping the sum of the current stock levels (in warehouses, at disposal, etc.) divided into sizes */
23
28
  const mapSizeQuantites: MapSizeQuantitesFunction;
29
+ /** @description The method allows mapping the producers's or external system's codes stored in the system to SKUs */
24
30
  const mapProductCodes: MapProductCodesFunction;
31
+ /** @description The method allows mapping all known codes: IAI code, manufacturer code or external code as an array */
32
+ const mapAllProductCodes: MapProductAllCodesFunction;
33
+ /** @description This method allows you to map product locations stored in the system, broken down by size. You can select a specific warehouse or list all of them, both primary and secondary. */
34
+ const mapProductLocations: MapProductLocationsFunction;
35
+ /** @description Get first item (description, series, parameter name or value) with the selected langId */
25
36
  const getLangData: GetLangDataFunction;
37
+ /** @description Modifies product response by removing all parameter names nad values that are not in selected langId */
26
38
  const clearParametersLangData: ClearParametersLangDataFunction;
27
- const mapProductLocations: MapProductLocationsFunction;
28
39
  }
29
40
 
30
41
  export default utils;
package/dist/utils.js CHANGED
@@ -50,7 +50,7 @@ const productSizesPathMap = {
50
50
  'productSizesDispositionsInSales',
51
51
  'array'
52
52
  ],
53
- [ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_ORDERS_UNFINISHED]: [
53
+ [ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_UNFINISHED]: [
54
54
  'productStocksData',
55
55
  'productOrdersUnfinishedQuantities',
56
56
  'array',
@@ -68,6 +68,13 @@ const productSizesPathMap = {
68
68
  'productSizesDispositionsInAuctions',
69
69
  'array'
70
70
  ],
71
+ [ENUMS.PRODUCT_SIZE_COUNTABLE.RESERVATIONS]: [
72
+ 'productStocksData',
73
+ 'productStocksQuantities',
74
+ 'array',
75
+ 'productSizesData',
76
+ 'array'
77
+ ],
71
78
  [ENUMS.PRODUCT_SIZE_CODES.NAME]: [
72
79
  'productSizes',
73
80
  'array'
@@ -126,29 +133,55 @@ const sumProductQuantities = (productStocksData, nodeName = ENUMS.PRODUCT_SIZE_C
126
133
  });
127
134
  return sum;
128
135
  };
129
- const mapSizeQuantites = (product, nodeName = ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_OWN) => {
136
+ const getProductIndexFunction = (type, product) => {
137
+ switch (type) {
138
+ case ENUMS.PRODUCE_SIZE_INDEX.ID: return (obj) => obj.sizeId;
139
+ case ENUMS.PRODUCE_SIZE_INDEX.IAI_CODE: return (obj) => getIaiCode(product.productId, obj.sizeId);
140
+ case ENUMS.PRODUCE_SIZE_INDEX.NAME: {
141
+ return (obj) => {
142
+ if (obj.sizePanelName)
143
+ return obj.sizePanelName;
144
+ if (product.productSizes) {
145
+ const nameItem = product.productSizes.find(size => size.sizeId === obj.sizeId);
146
+ if (nameItem)
147
+ return nameItem.sizePanelName;
148
+ }
149
+ throw new Error("Could not index by name - sizePanelName and productSizes missing");
150
+ };
151
+ }
152
+ default: throw new Error('Invalid indexBy');
153
+ }
154
+ };
155
+ const mapSizeQuantites = (product, nodeName = ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_OWN, indexBy = ENUMS.PRODUCE_SIZE_INDEX.ID) => {
130
156
  const results = getTraversedPathElements(product, nodeName);
157
+ if (nodeName === 'productSizeReservationOrder') {
158
+ results.forEach(node => {
159
+ node.productSizeReservationOrder = node.productSizeReservations.productSizeReservationOrder;
160
+ });
161
+ }
131
162
  const aggregated = {};
132
163
  if (['productOrdersUnfinishedQuantities', 'productSizesDeliveries', 'productSizesDispositionsInAuctions'].includes(nodeName))
133
164
  nodeName = 'productSizeQuantity';
165
+ const getIndex = getProductIndexFunction(indexBy, product);
134
166
  results.forEach(item => {
135
167
  if (item?.sizeId && item[nodeName] !== undefined) {
136
- const sizeId = String(item.sizeId);
168
+ const index = getIndex(item) ?? item.sizeId;
137
169
  const value = Number(item[nodeName]) || 0;
138
- aggregated[sizeId] = (aggregated[sizeId] || 0) + value;
170
+ aggregated[index] = (aggregated[index] || 0) + value;
139
171
  }
140
172
  });
141
173
  return aggregated;
142
174
  };
143
- const mapProductCodes = (product, codeType = ENUMS.PRODUCT_SIZE_CODES.NAME) => {
175
+ const mapProductCodes = (product, codeType = ENUMS.PRODUCT_SIZE_CODES.NAME, indexBy = ENUMS.PRODUCE_SIZE_INDEX.ID) => {
144
176
  const results = getTraversedPathElements(product, codeType);
145
177
  const mapped = {};
178
+ const getIndex = getProductIndexFunction(indexBy, product);
146
179
  results.forEach(item => {
147
180
  if (item?.sizeId && item[codeType] !== undefined) {
148
- const sizeId = String(item.sizeId);
181
+ const index = getIndex(item) ?? item.sizeId;
149
182
  const value = String(item[codeType] || '');
150
- if (!mapped[sizeId] || value) {
151
- mapped[sizeId] = value;
183
+ if (!mapped[index] || value) {
184
+ mapped[index] = value;
152
185
  }
153
186
  }
154
187
  });
@@ -159,7 +192,24 @@ const SUB_TYPE_NODES = {
159
192
  stockLocationId: 'stockAdditionalLocationId',
160
193
  stockLocationCode: 'stockAdditionalLocationCode'
161
194
  };
162
- const mapProductLocations = (product, stockId, locationType = ENUMS.PRODUCT_SIZE_LOCATIONS.NAME) => {
195
+ const mapAllProductCodes = (product, indexBy) => {
196
+ const results = getTraversedPathElements(product, ENUMS.PRODUCT_SIZE_CODES.CODE_PRODUCER);
197
+ const mapped = {};
198
+ const getIndex = getProductIndexFunction(indexBy, product);
199
+ for (const item of results) {
200
+ const index = getIndex(item);
201
+ if (!mapped[index]) {
202
+ mapped[index] = [];
203
+ }
204
+ mapped[index].push(getIaiCode(product.productId, item.sizeId));
205
+ if (item.productSizeCodeProducer?.length)
206
+ mapped[index].push(item.productSizeCodeProducer);
207
+ if (item.productSizeCodeExternal?.length)
208
+ mapped[index].push(item.productSizeCodeExternal);
209
+ }
210
+ return mapped;
211
+ };
212
+ const mapProductLocations = (product, stockId, locationType = ENUMS.PRODUCT_SIZE_LOCATIONS.NAME, indexBy = ENUMS.PRODUCE_SIZE_INDEX.ID) => {
163
213
  let results = getTraversedPathElements(product, locationType);
164
214
  if (stockId) {
165
215
  const prefix = 'M' + stockId;
@@ -167,22 +217,23 @@ const mapProductLocations = (product, stockId, locationType = ENUMS.PRODUCT_SIZE
167
217
  }
168
218
  const mapped = {};
169
219
  const subNode = SUB_TYPE_NODES[locationType];
220
+ const getIndex = getProductIndexFunction(indexBy, product);
170
221
  for (const item of results) {
171
- const { sizeId } = item;
172
- if (!mapped[sizeId]) {
173
- mapped[sizeId] = [];
222
+ const index = getIndex(item);
223
+ if (!mapped[index]) {
224
+ mapped[index] = [];
174
225
  }
175
226
  // main location
176
227
  const mainLocation = item[locationType];
177
228
  if (mainLocation) {
178
- mapped[sizeId].push(mainLocation.toString());
229
+ mapped[index].push(mainLocation.toString());
179
230
  }
180
231
  // additional locations
181
232
  if (item.stockAdditionalLocations?.length) {
182
233
  for (const additional of item.stockAdditionalLocations) {
183
234
  const value = additional[subNode];
184
235
  if (value) {
185
- mapped[sizeId].push(value.toString());
236
+ mapped[index].push(value.toString());
186
237
  }
187
238
  }
188
239
  }
@@ -211,12 +262,30 @@ const clearParametersLangData = (products, langId = 'pol') => {
211
262
  }
212
263
  return products;
213
264
  };
265
+ const removeRmaAttachments = (rmaResponse) => {
266
+ for (const rma of rmaResponse.rmas) {
267
+ for (const product of rma.products)
268
+ product.attachments = [];
269
+ }
270
+ return rmaResponse;
271
+ };
214
272
  export default {
215
- sumProductQuantities,
273
+ /** @description The method allows you to build an IAI code from the product ID and size ID. */
216
274
  getIaiCode,
275
+ /** @description The method allows you to sum up the current stock levels: warehouses, available stocks, etc. */
276
+ sumProductQuantities,
277
+ /** @description The method allows mapping the sum of the current stock levels (in warehouses, at disposal, etc.) divided into sizes */
217
278
  mapSizeQuantites,
279
+ /** @description The method allows mapping the producers's or external system's codes stored in the system to SKUs */
218
280
  mapProductCodes,
281
+ /** @description The method allows mapping all known codes: IAI code, manufacturer code or external code as an array */
282
+ mapAllProductCodes,
283
+ /** @description This method allows you to map product locations stored in the system, broken down by size. You can select a specific warehouse or list all of them, both primary and secondary. */
219
284
  mapProductLocations,
285
+ /** @description Get first item (description, series, parameter name or value) with the selected langId */
220
286
  getLangData,
221
- clearParametersLangData
287
+ /** @description Modifies product response by removing all parameter names nad values that are not in selected langId */
288
+ clearParametersLangData,
289
+ /** @description Removes attachments to RMA that are returned by default, helps to reduce data if serialized or forwarded */
290
+ removeRmaAttachments
222
291
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idosell",
3
- "version": "0.4.18",
3
+ "version": "0.4.23",
4
4
  "description": "Idosell 3 REST connector",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/gateways.d.ts",
@@ -1,4 +1,4 @@
1
- import idosell from "./dist/index.ts"
1
+ import idosell from "./dist/index"
2
2
  import { expect, test } from "vitest"
3
3
 
4
4
  test("getMenu", () => {
@@ -1,4 +1,4 @@
1
- import idosell from "./dist/index.ts"
1
+ import idosell from "./dist/index"
2
2
  import { expect, test } from "vitest"
3
3
 
4
4
  test("getOrdersAuctionDetailsSerialNumbers", () => {
@@ -1,4 +1,4 @@
1
- import idosell from "./dist/index.ts"
1
+ import idosell from "./dist/index"
2
2
  import { expect, test } from "vitest"
3
3
 
4
4
  test("getOrdersExportdocuments", () => {
@@ -1,4 +1,4 @@
1
- import idosell from "./dist/index.ts"
1
+ import idosell from "./dist/index"
2
2
  import { expect, test } from "vitest"
3
3
 
4
4
  test("getPayments", () => {
@@ -1,4 +1,4 @@
1
- import idosell from "./dist/index.ts"
1
+ import idosell from "./dist/index"
2
2
  import { expect, test } from "vitest"
3
3
 
4
4
  test("putRefundsConfirmRefundPaymentId", () => {
@@ -0,0 +1,24 @@
1
+ import { ENUMS, utils } from '../dist/index';
2
+ import { expect, test } from "vitest"
3
+ import { STOCK_PRODUCT } from './utilTestData';
4
+
5
+
6
+ const INDEX = ENUMS.PRODUCE_SIZE_INDEX;
7
+
8
+ test('Utils mapAllProductCodes by ID', () => {
9
+ const codes = utils.mapAllProductCodes(STOCK_PRODUCT, INDEX.ID)
10
+ console.log(JSON.stringify(codes));
11
+ expect(codes).toEqual({"3":["1234-3","1234567890128","PX-ZERO-S"],"4":["1234-4","1234567890135","PX-ZERO-M"],"5":["1234-5","1234567890142","PX-ZERO-L"],"6":["1234-6","1234567890159","PX-ZERO-X"]});
12
+ })
13
+
14
+ test('Utils mapAllProductCodes by IAI code', () => {
15
+ const codes = utils.mapAllProductCodes(STOCK_PRODUCT, INDEX.IAI_CODE)
16
+ console.log(JSON.stringify(codes));
17
+ expect(codes).toEqual({"1234-3":["1234-3","1234567890128","PX-ZERO-S"],"1234-4":["1234-4","1234567890135","PX-ZERO-M"],"1234-5":["1234-5","1234567890142","PX-ZERO-L"],"1234-6":["1234-6","1234567890159","PX-ZERO-X"]});
18
+ })
19
+
20
+ test('Utils mapAllProductCodes by name', () => {
21
+ const codes = utils.mapAllProductCodes(STOCK_PRODUCT, INDEX.NAME)
22
+ console.log(JSON.stringify(codes));
23
+ expect(codes).toEqual({"S":["1234-3","1234567890128","PX-ZERO-S"],"M":["1234-4","1234567890135","PX-ZERO-M"],"L":["1234-5","1234567890142","PX-ZERO-L"],"XL":["1234-6","1234567890159","PX-ZERO-X"]});
24
+ })
@@ -1,24 +1,36 @@
1
- import distUtils from '$dist/utils.ts';
1
+ import { ENUMS, utils } from '../dist/index';
2
2
  import { expect, test } from "vitest"
3
- import { STOCK_PRODUCT } from "./util.data";
4
- import ENUMS from '$dist/enums';
3
+ import { STOCK_PRODUCT } from './utilTestData';
5
4
 
6
5
  const CODES = ENUMS.PRODUCT_SIZE_CODES;
6
+ const INDEX = ENUMS.PRODUCE_SIZE_INDEX;
7
7
 
8
8
  test('Utils mapProductCodes on sizePanelName', () => {
9
9
  expect(CODES.NAME).toEqual('sizePanelName');
10
- const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.NAME)
10
+ const codes = utils.mapProductCodes(STOCK_PRODUCT, CODES.NAME)
11
11
  expect(codes).toEqual({"3": "S","4": "M","5": "L","6": "XL"});
12
12
  })
13
13
 
14
14
  test('Utils mapProductCodes on productSizeCodeProducer', () => {
15
15
  expect(CODES.CODE_PRODUCER).toEqual('productSizeCodeProducer');
16
- const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_PRODUCER)
16
+ const codes = utils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_PRODUCER)
17
17
  expect(codes).toEqual({"3": "1234567890128","4": "1234567890135","5": "1234567890142","6": "1234567890159"});
18
18
  })
19
19
 
20
20
  test('Utils mapProductCodes on productSizeCodeExternal', () => {
21
21
  expect(CODES.CODE_EXTERNAL).toEqual('productSizeCodeExternal');
22
- const codes = distUtils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_EXTERNAL)
22
+ const codes = utils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_EXTERNAL)
23
23
  expect(codes).toEqual({"3": "PX-ZERO-S","4": "PX-ZERO-M","5": "PX-ZERO-L","6": "PX-ZERO-X"});
24
+ })
25
+
26
+ test('Utils mapProductCodes on sizePanelName by IAI code', () => {
27
+ expect(CODES.NAME).toEqual('sizePanelName');
28
+ const codes = utils.mapProductCodes(STOCK_PRODUCT, CODES.NAME, INDEX.IAI_CODE)
29
+ expect(codes).toEqual({"1234-3":"S","1234-4":"M","1234-5":"L","1234-6":"XL"});
30
+ })
31
+
32
+ test('Utils mapProductCodes on productSizeCodeProducer by size name', () => {
33
+ expect(CODES.NAME).toEqual('sizePanelName');
34
+ const codes = utils.mapProductCodes(STOCK_PRODUCT, CODES.CODE_PRODUCER, INDEX.NAME)
35
+ expect(codes).toEqual({"S":"1234567890128","M":"1234567890135","L":"1234567890142","XL":"1234567890159"});
24
36
  })
@@ -1,29 +1,47 @@
1
- import distUtils from '$dist/utils.ts';
1
+ import { ENUMS, utils } from '../dist/index';
2
2
  import { expect, test } from "vitest"
3
- import { STOCK_PRODUCT } from "./util.data";
4
- import { ENUMS } from '$dist';
3
+ import { STOCK_PRODUCT } from './utilTestData';
5
4
 
6
5
  const LOCATION = ENUMS.PRODUCT_SIZE_LOCATIONS;
6
+ const INDEX = ENUMS.PRODUCE_SIZE_INDEX;
7
7
 
8
8
  test('Utils mapProductLocations on stockLocationCode', () => {
9
9
  expect(LOCATION.CODE).toEqual('stockLocationCode');
10
- const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.CODE)
10
+ const locations = utils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.CODE)
11
11
  expect(locations).toEqual({"3":["F","P","A"],"4":["F"],"5":["B"],"6":["B"]});
12
12
  })
13
13
 
14
+ test('Utils mapProductLocations on stockLocationId', () => {
15
+ expect(LOCATION.ID).toEqual('stockLocationId');
16
+ const locations = utils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.ID)
17
+ expect(locations).toEqual({"3":["16","46","1"],"4":["16"],"5":["4"],"6":["4"]});
18
+ })
19
+
14
20
  test('Utils mapProductLocations on stockLocationTextId', () => {
15
21
  expect(LOCATION.NAME).toEqual('stockLocationTextId');
16
- const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.NAME)
22
+ const locations = utils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.NAME)
17
23
  expect(locations).toEqual({"3":["M1\\A014","M1\\A015","M1\\A113"],"4":["M1\\A014"],"5":["M1\\B013"],"6":["M1\\B013"]});
18
24
  })
19
25
 
26
+ test('Utils mapProductLocations on stockLocationTextId by IAI code', () => {
27
+ expect(LOCATION.NAME).toEqual('stockLocationTextId');
28
+ const locations = utils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.NAME, INDEX.IAI_CODE)
29
+ expect(locations).toEqual({"1234-3":["M1\\A014","M1\\A015","M1\\A113"],"1234-4":["M1\\A014"],"1234-5":["M1\\B013"],"1234-6":["M1\\B013"]});
30
+ })
31
+
32
+ test('Utils mapProductLocations on stockLocationTextId by size name', () => {
33
+ expect(LOCATION.NAME).toEqual('stockLocationTextId');
34
+ const locations = utils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.NAME, INDEX.NAME)
35
+ expect(locations).toEqual({"S":["M1\\A014","M1\\A015","M1\\A113"],"M":["M1\\A014"],"L":["M1\\B013"],"XL":["M1\\B013"]});
36
+ })
37
+
20
38
  test('Utils mapProductLocations on stockLocationId', () => {
21
39
  expect(LOCATION.ID).toEqual('stockLocationId');
22
- const locations = distUtils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.ID)
40
+ const locations = utils.mapProductLocations(STOCK_PRODUCT, 1, LOCATION.ID)
23
41
  expect(locations).toEqual({"3":["16","46","1"],"4":["16"],"5":["4"],"6":["4"]});
24
42
  })
25
43
 
26
44
  test('Utils mapProductLocations full', () => {
27
- const locations = distUtils.mapProductLocations(STOCK_PRODUCT)
45
+ const locations = utils.mapProductLocations(STOCK_PRODUCT)
28
46
  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
47
  })
@@ -1,48 +1,60 @@
1
- import distUtils from '$dist/utils.ts';
1
+ import { ENUMS, utils } from '../dist/index';
2
2
  import { expect, test } from "vitest"
3
- import { STOCK_PRODUCT } from "./util.data";
4
- import ENUMS from '$dist/enums';
3
+ import { STOCK_PRODUCT } from './utilTestData';
5
4
 
6
5
  const COUNTABLE = ENUMS.PRODUCT_SIZE_COUNTABLE;
6
+ const INDEX = ENUMS.PRODUCE_SIZE_INDEX;
7
7
 
8
8
  test('Utils mapSizeQuantites on productSizeQuantity', () => {
9
9
  expect(COUNTABLE.QUANTITY).toEqual('productSizeQuantity');
10
- const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY)
10
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY)
11
11
  expect(quantities).toEqual({"3":10,"4":10,"5":0,"6":0});
12
12
  })
13
13
 
14
+ test('Utils mapSizeQuantites on productSizeQuantity by IAI code', () => {
15
+ expect(COUNTABLE.QUANTITY).toEqual('productSizeQuantity');
16
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY, INDEX.IAI_CODE)
17
+ expect(quantities).toEqual({"1234-3":10,"1234-4":10,"1234-5":0,"1234-6":0});
18
+ })
19
+
20
+ test('Utils mapSizeQuantites on productSizeQuantity by size name', () => {
21
+ expect(COUNTABLE.QUANTITY).toEqual('productSizeQuantity');
22
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY, INDEX.NAME)
23
+ expect(quantities).toEqual({"S":10,"M":10,"L":0,"XL":0});
24
+ })
25
+
14
26
  test('Utils mapSizeQuantites on productSizeQuantityOwnStock', () => {
15
27
  expect(COUNTABLE.QUANTITY_OWN).toEqual('productSizeQuantityOwnStock');
16
- const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_OWN)
28
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_OWN)
17
29
  expect(quantities).toEqual({"3":8,"4":10,"5":0,"6":0});
18
30
  })
19
31
 
20
32
  test('Utils mapSizeQuantites on productSizeQuantityOutsideStock', () => {
21
33
  expect(COUNTABLE.QUANTITY_OUTSIDE).toEqual('productSizeQuantityOutsideStock');
22
- const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_OUTSIDE)
34
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_OUTSIDE)
23
35
  expect(quantities).toEqual({"3":0,"4":0,"5":5,"6":0});
24
36
  })
25
37
 
26
38
  test('Utils mapSizeQuantites on productSizeQuantityAllStocks', () => {
27
39
  expect(COUNTABLE.QUANTITY_ALL).toEqual('productSizeQuantityAllStocks');
28
- const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_ALL)
40
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_ALL)
29
41
  expect(quantities).toEqual({"3":8,"4":10,"5":5,"6":0});
30
42
  })
31
43
 
32
44
  test('Utils mapSizeQuantites on productOrdersUnfinishedQuantities', () => {
33
- expect(COUNTABLE.QUANTITY_ORDERS_UNFINISHED).toEqual('productOrdersUnfinishedQuantities');
34
- const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_ORDERS_UNFINISHED)
45
+ expect(COUNTABLE.QUANTITY_UNFINISHED).toEqual('productOrdersUnfinishedQuantities');
46
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.QUANTITY_UNFINISHED)
35
47
  expect(quantities).toEqual({"3":2});
36
48
  })
37
49
 
38
50
  test('Utils mapSizeQuantites on productSizesDeliveries', () => {
39
51
  expect(COUNTABLE.DELIVERIES).toEqual('productSizesDeliveries');
40
- const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.DELIVERIES)
52
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.DELIVERIES)
41
53
  expect(quantities).toEqual({"5":3,"6":3});
42
54
  })
43
55
 
44
56
  test('Utils mapSizeQuantites on productSizesDispositionsInAuctions', () => {
45
57
  expect(COUNTABLE.AUCTIONS).toEqual('productSizesDispositionsInAuctions');
46
- const quantities = distUtils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.AUCTIONS)
58
+ const quantities = utils.mapSizeQuantites(STOCK_PRODUCT, COUNTABLE.AUCTIONS)
47
59
  expect(quantities).toEqual({"3":1,"4":0,"5":0,"6":0});
48
60
  })
@@ -1,48 +1,47 @@
1
- import distUtils from '$dist/utils.ts';
1
+ import { ENUMS, utils } from '../dist/index';
2
2
  import { expect, test } from "vitest"
3
- import { STOCK_PRODUCT } from "./util.data";
4
- import ENUMS from '$dist/enums';
3
+ import { STOCK_PRODUCT } from './utilTestData';
5
4
 
6
5
  const COUNTABLE = ENUMS.PRODUCT_SIZE_COUNTABLE;
7
6
 
8
7
  test('Utils sumProductQuantities on productSizeQuantity', () => {
9
8
  expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY).toEqual('productSizeQuantity');
10
- const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY)
9
+ const sum = utils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY)
11
10
  expect(sum).toEqual(20);
12
11
  })
13
12
 
14
13
  test('Utils sumProductQuantities on productSizeQuantityOwnStock', () => {
15
14
  expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_OWN).toEqual('productSizeQuantityOwnStock');
16
- const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_OWN)
15
+ const sum = utils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_OWN)
17
16
  expect(sum).toEqual(18);
18
17
  })
19
18
 
20
19
  test('Utils sumProductQuantities on productSizeQuantityOutsideStock', () => {
21
20
  expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_OUTSIDE).toEqual('productSizeQuantityOutsideStock');
22
- const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_OUTSIDE)
21
+ const sum = utils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_OUTSIDE)
23
22
  expect(sum).toEqual(5);
24
23
  })
25
24
 
26
25
  test('Utils sumProductQuantities on productSizeQuantityAllStocks', () => {
27
26
  expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_ALL).toEqual('productSizeQuantityAllStocks');
28
- const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_ALL)
27
+ const sum = utils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_ALL)
29
28
  expect(sum).toEqual(23);
30
29
  })
31
30
 
32
31
  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)
32
+ expect(ENUMS.PRODUCT_SIZE_COUNTABLE.QUANTITY_UNFINISHED).toEqual('productOrdersUnfinishedQuantities');
33
+ const sum = utils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.QUANTITY_UNFINISHED)
35
34
  expect(sum).toEqual(2);
36
35
  })
37
36
 
38
37
  test('Utils sumProductQuantities on productSizesDeliveries', () => {
39
38
  expect(ENUMS.PRODUCT_SIZE_COUNTABLE.DELIVERIES).toEqual('productSizesDeliveries');
40
- const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.DELIVERIES)
39
+ const sum = utils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.DELIVERIES)
41
40
  expect(sum).toEqual(6);
42
41
  })
43
42
 
44
43
  test('Utils sumProductQuantities on productSizesDispositionsInAuctions', () => {
45
44
  expect(ENUMS.PRODUCT_SIZE_COUNTABLE.AUCTIONS).toEqual('productSizesDispositionsInAuctions');
46
- const sum = distUtils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.AUCTIONS)
45
+ const sum = utils.sumProductQuantities(STOCK_PRODUCT.productStocksData, COUNTABLE.AUCTIONS)
47
46
  expect(sum).toEqual(1);
48
47
  })
@@ -1,7 +1,8 @@
1
- import type { SearchProductsResponse } from "$dist/responses";
1
+ import type { SearchProductsResponse } from "../dist/responses";
2
2
 
3
3
  export const STOCK_PRODUCT: SearchProductsResponse['results'][number] = {
4
- "productId": 541321313,
4
+ "productId": 1234,
5
+ "productDisplayedCode": 'ZERO',
5
6
  "productStocksData": {
6
7
  "productSizesDeliveries": [
7
8
  {