idosell 0.4.27 → 0.4.32

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/dist/helpers.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const getStandardizedDate = (dateValue) => {
2
- if (!dateValue)
2
+ if (typeof dateValue === 'undefined')
3
3
  return new Date();
4
4
  if (typeof dateValue === 'string' && dateValue.length === 10) {
5
5
  dateValue += ' 00:00:00';
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import ENUMS from "./enums.js";
2
2
  import utils from "./utils.js";
3
3
  import { gateProxy } from "./gates.js";
4
4
  import { IdosellFaultStringError, catchEmptyList } from "./errors.js";
5
- export const DEFAULT_VERSION = 7;
5
+ export const DEFAULT_VERSION = 8;
6
6
  function normalizeUrl(input = "") {
7
7
  if (!input.length)
8
8
  return "";
@@ -0,0 +1,5 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'get', node: '/products/attachments/getContent' };
4
+ return new Proxy(object, paramsProxy);
5
+ };
@@ -3,7 +3,7 @@ import { page } from "../helpers.js";
3
3
  export default (object) => {
4
4
  object.gate = { method: 'get', node: '/products/brands' };
5
5
  object.custom = {
6
- page
6
+ page: (pageIndex, limit) => page(pageIndex, limit, true)
7
7
  };
8
8
  object.snakeCase = true;
9
9
  return new Proxy(object, paramsProxy);
@@ -3,7 +3,7 @@ import { page } from "../helpers.js";
3
3
  export default (object) => {
4
4
  object.gate = { method: 'get', node: '/products/categories' };
5
5
  object.custom = {
6
- page
6
+ page: (pageIndex, limit) => page(pageIndex, limit, true)
7
7
  };
8
8
  object.snakeCase = true;
9
9
  return new Proxy(object, paramsProxy);
@@ -1,5 +1,6 @@
1
1
  import { paramsProxy } from "../params.js";
2
2
  export default (object) => {
3
3
  object.gate = { method: 'get', node: '/products/marketing/promotion' };
4
+ object.auth.version = 7;
4
5
  return new Proxy(object, paramsProxy);
5
6
  };
@@ -0,0 +1,10 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { page } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'get', node: '/regulations/history' };
5
+ object.custom = {
6
+ page
7
+ };
8
+ object.req = ["langId"];
9
+ return new Proxy(object, paramsProxy);
10
+ };
@@ -4,7 +4,7 @@ export default (object) => {
4
4
  object.gate = { method: 'get', node: '/returns/returns' };
5
5
  object.custom = {
6
6
  dates: dateRangeType({ "nodeName": "range", "fromName": "date][date_begin", "toName": "date][date_end", "typeName": "date][dates_type", "defaultType": "date_add" }),
7
- page
7
+ page: (pageIndex, limit) => page(pageIndex, limit, true)
8
8
  };
9
9
  object.snakeCase = true;
10
10
  object.req = [{ "any": true }];
@@ -3,7 +3,7 @@ import { page } from "../helpers.js";
3
3
  export default (object) => {
4
4
  object.gate = { method: 'get', node: '/warranties/warranties' };
5
5
  object.custom = {
6
- page
6
+ page: (pageIndex, limit) => page(pageIndex, limit, true)
7
7
  };
8
8
  object.snakeCase = true;
9
9
  return new Proxy(object, paramsProxy);
@@ -3,7 +3,7 @@ import { page } from "../helpers.js";
3
3
  export default (object) => {
4
4
  object.gate = { method: 'get', node: '/wms/stocksdocuments/products' };
5
5
  object.custom = {
6
- page
6
+ page: (pageIndex, limit) => page(pageIndex, limit, true)
7
7
  };
8
8
  object.snakeCase = true;
9
9
  object.req = ["type", "id"];
@@ -1,6 +1,7 @@
1
1
  import { paramsProxy } from "../params.js";
2
2
  export default (object) => {
3
3
  object.gate = { method: 'post', node: '/products/marketing/promotion' };
4
+ object.auth.version = 7;
4
5
  object.appendable = {
5
6
  except: ["promotionName", "shopsIds", "marketingZones", "newPriceSettings", "startDate", "endDate", "changeProductsToVisibleWhileStarting", "removeProductsAfterStockLevelRunsDown", "reduceBasingPrice", "calculationMethod"],
6
7
  arrayNode: "promotionElements",
@@ -1,6 +1,12 @@
1
1
  import { paramsProxy } from "../params.js";
2
2
  export default (object) => {
3
3
  object.gate = { method: 'put', node: '/clients/externalCode' };
4
+ object.appendable = {
5
+ except: [],
6
+ arrayNode: "clients",
7
+ index: 0
8
+ };
4
9
  object.req = [{ "any": ["client_id", "client_login"] }];
10
+ object.arrays = ["clients"];
5
11
  return new Proxy(object, paramsProxy);
6
12
  };
@@ -1,6 +1,7 @@
1
1
  import { paramsProxy } from "../params.js";
2
2
  export default (object) => {
3
3
  object.gate = { method: 'put', node: '/products/marketing/promotion' };
4
+ object.auth.version = 7;
4
5
  object.appendable = {
5
6
  except: ["promotionId", "promotionName", "shopsIds", "marketingZones", "newPriceSettings", "startDate", "endDate", "changeProductsToVisibleWhileStarting", "removeProductsAfterStockLevelRunsDown", "reduceBasingPrice", "calculationMethod", "removeAllPromotionElements"],
6
7
  arrayNode: "promotionElements",
@@ -4,7 +4,7 @@ export default (object) => {
4
4
  object.gate = { method: 'post', node: '/clients/newsletter/email/search' };
5
5
  object.custom = {
6
6
  dates: dateRange({ "nodeName": "date", "fromName": "from", "toName": "to" }),
7
- page
7
+ page: (pageIndex, limit) => page(pageIndex, limit, true)
8
8
  };
9
9
  object.snakeCase = true;
10
10
  object.arrays = ["shops", "return_elements"];
@@ -4,7 +4,7 @@ export default (object) => {
4
4
  object.gate = { method: 'post', node: '/clients/newsletter/sms/search' };
5
5
  object.custom = {
6
6
  dates: dateRange({ "nodeName": "date", "fromName": "from", "toName": "to" }),
7
- page
7
+ page: (pageIndex, limit) => page(pageIndex, limit, true)
8
8
  };
9
9
  object.snakeCase = true;
10
10
  object.arrays = ["shops", "return_elements"];
@@ -325,50 +325,6 @@ export type PostProductsParams = {
325
325
  productPictures?: string[];
326
326
  /** @description List of photos descriptions */
327
327
  productDescriptionPictures?: string[];
328
- /** @description Reduced price */
329
- productPromotion?: {
330
- /** @description Object determines if the promotion should be active.. Allowed values "y" - active promotion, "n" - inactive promotion. */
331
- promoteInEnabled?: string;
332
- /** @description Strikethrough price */
333
- promoteItemNormalPrice?: number;
334
- /** @description Strikethrough wholesale price */
335
- promoteItemWholesaleNormalPrice?: number;
336
- /** @description Switching off date */
337
- promoteItemEndingDate?: string;
338
- };
339
- /** @description Discount for shop. */
340
- productDiscount?: {
341
- /** @description Object determines if the promotion should be active.. Allowed values "y" - active promotion, "n" - inactive promotion. */
342
- promoteInEnabled?: string;
343
- /** @description Strikethrough price */
344
- promoteItemNormalPrice?: number;
345
- /** @description Strikethrough wholesale price */
346
- promoteItemWholesaleNormalPrice?: number;
347
- /** @description Switching off date */
348
- promoteItemEndingDate?: string;
349
- };
350
- /** @description Distinguished product in store. */
351
- productDistinguished?: {
352
- /** @description Object determines if the promotion should be active.. Allowed values "y" - active promotion, "n" - inactive promotion. */
353
- promoteInEnabled?: string;
354
- /** @description Strikethrough price */
355
- promoteItemNormalPrice?: number;
356
- /** @description Strikethrough wholesale price */
357
- promoteItemWholesaleNormalPrice?: number;
358
- /** @description Switching off date */
359
- promoteItemEndingDate?: string;
360
- };
361
- /** @description Special product in store. */
362
- productSpecial?: {
363
- /** @description Object determines if the promotion should be active.. Allowed values "y" - active promotion, "n" - inactive promotion. */
364
- promoteInEnabled?: string;
365
- /** @description Strikethrough price */
366
- promoteItemNormalPrice?: number;
367
- /** @description Strikethrough wholesale price */
368
- promoteItemWholesaleNormalPrice?: number;
369
- /** @description Switching off date */
370
- promoteItemEndingDate?: string;
371
- };
372
328
  /** @description Parameters (distinguished). */
373
329
  productParametersDistinction?: {
374
330
  /** @description Parameter ID */
@@ -1094,66 +1050,6 @@ export type PutProductsParams = {
1094
1050
  /** @description A picture in url or base64 (depends on pictures_input_type). */
1095
1051
  productPictureSource?: string;
1096
1052
  }[];
1097
- /** @description Reduced price */
1098
- productPromotion?: {
1099
- /** @description Is attribute set */
1100
- promoteIsEnabled?: string;
1101
- /** @description Strikethrough price */
1102
- promoteItemNormalPrice?: number;
1103
- /** @description Net strikethrough price. */
1104
- promoteItemNormalPriceNet?: number;
1105
- /** @description Strikethrough wholesale price */
1106
- promoteItemWholesaleNormalPrice?: number;
1107
- /** @description Net wholesale strikethrough price. */
1108
- promoteItemWholesaleNormalPriceNet?: number;
1109
- /** @description Switching off date */
1110
- promoteItemEndingDate?: string;
1111
- };
1112
- /** @description Discount for shop. */
1113
- productDiscount?: {
1114
- /** @description Is attribute set */
1115
- promoteIsEnabled?: string;
1116
- /** @description Strikethrough price */
1117
- promoteItemNormalPrice?: number;
1118
- /** @description Net strikethrough price. */
1119
- promoteItemNormalPriceNet?: number;
1120
- /** @description Strikethrough wholesale price */
1121
- promoteItemWholesaleNormalPrice?: number;
1122
- /** @description Net wholesale strikethrough price. */
1123
- promoteItemWholesaleNormalPriceNet?: number;
1124
- /** @description Switching off date */
1125
- promoteItemEndingDate?: string;
1126
- };
1127
- /** @description Distinguished product in store. */
1128
- productDistinguished?: {
1129
- /** @description Is attribute set */
1130
- promoteIsEnabled?: string;
1131
- /** @description Strikethrough price */
1132
- promoteItemNormalPrice?: number;
1133
- /** @description Net strikethrough price. */
1134
- promoteItemNormalPriceNet?: number;
1135
- /** @description Strikethrough wholesale price */
1136
- promoteItemWholesaleNormalPrice?: number;
1137
- /** @description Switching off date */
1138
- promoteItemEndingDate?: string;
1139
- /** @description Net wholesale strikethrough price. */
1140
- promoteItemWholesaleNormalPriceNet?: number;
1141
- };
1142
- /** @description Special product in store. */
1143
- productSpecial?: {
1144
- /** @description Is attribute set */
1145
- promoteIsEnabled?: string;
1146
- /** @description Strikethrough price */
1147
- promoteItemNormalPrice?: number;
1148
- /** @description Net strikethrough price. */
1149
- promoteItemNormalPriceNet?: number;
1150
- /** @description Strikethrough wholesale price */
1151
- promoteItemWholesaleNormalPrice?: number;
1152
- /** @description Net wholesale strikethrough price. */
1153
- promoteItemWholesaleNormalPriceNet?: number;
1154
- /** @description Switching off date */
1155
- promoteItemEndingDate?: string;
1156
- };
1157
1053
  /** @description Parameters (distinguished). */
1158
1054
  productParametersDistinction?: {
1159
1055
  /** @description Parameter ID */
@@ -6512,12 +6408,15 @@ export type PostDiscountsRebatesCodeParams = {
6512
6408
  };
6513
6409
 
6514
6410
  export type PutClientsExternalCodeParams = {
6515
- /** @example 1 */
6516
- client_id?: number;
6517
- /** @description Customer's login. */
6518
- client_login?: string;
6519
- /** @description External system code. */
6520
- code_extern?: string;
6411
+ /** @description Customer data. */
6412
+ clients: {
6413
+ /** @example 1 */
6414
+ client_id?: number;
6415
+ /** @description Customer's login. */
6416
+ client_login?: string;
6417
+ /** @description External system code. */
6418
+ code_extern?: string;
6419
+ }[];
6521
6420
  };
6522
6421
 
6523
6422
  export type PutClientsGiftcardsParams = {
@@ -7168,7 +7067,7 @@ type PaginationParam = {
7168
7067
  perPage?: number;
7169
7068
  };
7170
7069
 
7171
- type DateRangeParam = {
7070
+ export type DateRangeParam = {
7172
7071
  /** Format: date
7173
7072
  * @description Date "from" (RFC) */
7174
7073
  from?: string | null;
@@ -7317,4 +7216,13 @@ export type PutPromotionsSettingsParams = {
7317
7216
  daysLeftToClose?: number;
7318
7217
  };
7319
7218
 
7219
+ export type GetProductsAttachmentsGetContentParams = {
7220
+ /** @description - product identifier value */
7221
+ productIdentValue: string;
7222
+ /** @description - product identifier type */
7223
+ productIdentType: "codeExtern" | "codeProducer" | "index" | "id";
7224
+ /** @description - product attachment ID */
7225
+ attachmentId: number;
7226
+ };
7227
+
7320
7228
  export { };
package/dist/request.js CHANGED
@@ -52,30 +52,28 @@ const checkNext = (request, response, logPage) => {
52
52
  };
53
53
  throw new IdosellFaultStringError(response.errors.faultString, faultStructure);
54
54
  }
55
- function handlePagination(currentPage, totalPages, request, paramsUpdate) {
56
- request.next = currentPage + 1 < totalPages;
57
- if (paramsUpdate)
58
- Object.assign(request.params, paramsUpdate);
55
+ function handlePagination(currentPage, totalPages, limit, request) {
56
+ const nextPage = currentPage + 1;
57
+ request.next = nextPage < totalPages;
59
58
  if (typeof logPage === 'function') {
60
59
  logPage('Page: ' + currentPage + ' / ' + totalPages);
61
60
  }
61
+ if (request.custom && request.custom.page) {
62
+ const pageObj = request.custom.page(nextPage, limit);
63
+ Object.assign(request.params, pageObj);
64
+ }
62
65
  }
63
66
  if (response.resultsNumberPage) {
64
- handlePagination(response.resultsPage, response.resultsNumberPage, request, { resultsPage: response.resultsPage + 1 });
67
+ handlePagination(response.resultsPage, response.resultsNumberPage, response.resultsLimit, request);
65
68
  }
66
69
  else if (response.results_number_page) {
67
- handlePagination(response.results_page, response.results_number_page, request, { results_page: response.results_page + 1 });
70
+ handlePagination(response.results_page, response.results_number_page, response.results_limit, request);
68
71
  }
69
72
  else if (response.pagination) {
70
- console.log({ rp: request.params, qp: response.pagination });
71
- request.params.pagination.page = response.pagination.resultsPage + 1;
72
- handlePagination(response.pagination.resultsPage, response.pagination.resultsNumberPage, request);
73
+ handlePagination(response.pagination.resultsPage, response.pagination.resultsNumberPage, response.pagination.resultsLimit, request);
73
74
  }
74
75
  else if (response.data?.pagination) {
75
- if (!request.params.pagination)
76
- request.params.pagination = {};
77
- request.params.pagination.page = response.data.pagination.resultsPage + 1;
78
- handlePagination(response.data.pagination.resultsPage, response.data.pagination.resultsNumberPage, request);
76
+ handlePagination(response.data.pagination.resultsPage, response.data.pagination.resultsNumberPage, response.data.pagination.resultsLimit, request);
79
77
  }
80
78
  return response;
81
79
  };
@@ -992,7 +992,7 @@ export type GetConfigVariablesResponse = {
992
992
  /** @description Key of config value. */
993
993
  key: string;
994
994
  /** @description Name of config item. */
995
- readonly name: string;
995
+ name: string;
996
996
  /** @description Value of config item. */
997
997
  value: string;
998
998
  } & {
@@ -1012,7 +1012,7 @@ export type PutConfigVariablesResponse = {
1012
1012
  /** @description Key of config value. */
1013
1013
  key: string;
1014
1014
  /** @description Name of config item. */
1015
- readonly name?: string;
1015
+ name?: string;
1016
1016
  /** @description Value of config item. */
1017
1017
  value: string;
1018
1018
  } & {
@@ -1185,9 +1185,9 @@ export type GetCpaCampaignResponse = {
1185
1185
  /** @description Whether the snippet is active */
1186
1186
  active: "y" | "n";
1187
1187
  /** @description Number of CPA programs associated with the campaign. */
1188
- readonly cpaCount: number | null;
1188
+ cpaCount: number | null;
1189
1189
  /** @description Number of active CPA programs associated with the campaign. */
1190
- readonly activeCpaCount: number | null;
1190
+ activeCpaCount: number | null;
1191
1191
  }[];
1192
1192
  pagination: PagedResponse;
1193
1193
  };
@@ -3492,8 +3492,10 @@ export type PutProductsMarketingZonesResponse = {
3492
3492
 
3493
3493
  export type GetProductsOmnibusPricesResponse = {
3494
3494
  /** @description Products list. */
3495
- products: never[] | Record<string, {
3496
- shops: never[] | Record<string, {
3495
+ products: {
3496
+ /** @description Product ID */
3497
+ productId: number;
3498
+ shops: {
3497
3499
  /** @description Shop Id */
3498
3500
  shop_id: number;
3499
3501
  /** @description Lowest retail price before active promotion (gross). */
@@ -3503,7 +3505,7 @@ export type GetProductsOmnibusPricesResponse = {
3503
3505
  /** @description How to manage the lowest price before promotion. */
3504
3506
  omnibusPriceManagement: "automatic" | "manual";
3505
3507
  /** @description List of sizes */
3506
- sizes: never[] | Record<string, {
3508
+ sizes: {
3507
3509
  /** @description Identifier type. */
3508
3510
  ident: {
3509
3511
  /** */
@@ -3516,9 +3518,12 @@ export type GetProductsOmnibusPricesResponse = {
3516
3518
  /** @description Lowest wholesale price before active promotion (gross). */
3517
3519
  omnibusPriceWholesale: number;
3518
3520
  /** @description How to manage the lowest price before promotion. */
3519
- omnibusPriceManagement: "automatic" | "manual"}>}>;
3521
+ omnibusPriceManagement: "automatic" | "manual";
3522
+ }[];
3523
+ }[];
3520
3524
  /** @description Error information. */
3521
- error?: FaultCodeString}>;
3525
+ error?: FaultCodeString;
3526
+ }[];
3522
3527
  };
3523
3528
 
3524
3529
  export type GetProductsOpinionsRateResponse = {
@@ -6251,18 +6256,18 @@ export type GetSnippetsCampaignResponse = {
6251
6256
  /** @description Whether the snippet is active */
6252
6257
  active: "y" | "n";
6253
6258
  /** @description Whether the snippet campaign is deleted */
6254
- readonly deleted: "y" | "n";
6259
+ deleted: "y" | "n";
6255
6260
  /** @description Snippet order. */
6256
6261
  order: number;
6257
6262
  /** @description Number of code snippets associated with the campaign. */
6258
- readonly snippetCount: number | null;
6263
+ snippetCount: number | null;
6259
6264
  /** @description Number of active code snippets associated with the campaign. */
6260
- readonly activeSnippetCount: number | null;
6265
+ activeSnippetCount: number | null;
6261
6266
  configVariables: {
6262
6267
  /** @description Key of config value. */
6263
6268
  key: string;
6264
6269
  /** @description Name of config item. */
6265
- readonly name: string;
6270
+ name: string;
6266
6271
  /** @description Value of config item. */
6267
6272
  value: string;
6268
6273
  }[];
@@ -6431,9 +6436,9 @@ export type GetSnippetsResponse = {
6431
6436
  } | null;
6432
6437
  };
6433
6438
  /** @description Whether the snippet is marked as deleted. */
6434
- readonly deleted: "y" | "n";
6439
+ deleted: "y" | "n";
6435
6440
  /** @description The number of cookies associated with the snippet. */
6436
- readonly cookiesCount: number;
6441
+ cookiesCount: number;
6437
6442
  }[];
6438
6443
  pagination: PagedResponse;
6439
6444
  };
@@ -9207,10 +9212,10 @@ type PromotionArchiveData = Omit<PromotionData, "archivedDate" | "elementsCount"
9207
9212
 
9208
9213
  export type SearchPromotionsHistoryResponse = PromotionApiResponse<{
9209
9214
  list: {
9210
- readonly id: number;
9211
- readonly date: string;
9212
- readonly login: string;
9213
- readonly description: string;
9215
+ id: number;
9216
+ date: string;
9217
+ login: string;
9218
+ description: string;
9214
9219
  }[];
9215
9220
  pagination: PagedResponse;
9216
9221
  }>;
@@ -9257,4 +9262,30 @@ export type PromotionIdResponse = PromotionApiResponse<number>;
9257
9262
 
9258
9263
  export type PromotionBoolResponse = PromotionApiResponse<boolean | null>;
9259
9264
 
9265
+ export type GetRegulationsHistoryResponse = {
9266
+ results: {
9267
+ /** @description Document's type */
9268
+ type: string;
9269
+ /** @description Language ISO code. */
9270
+ langId: string;
9271
+ /** @description Shop ID. */
9272
+ shopId: number;
9273
+ /** @description Content. */
9274
+ content: string;
9275
+ /** @description Creation time. */
9276
+ creationTime: number;
9277
+ /** @description User. */
9278
+ user: string;
9279
+ /** @description Change type. */
9280
+ changeType: "" | "auto" | "user";
9281
+ /** @description Change source (y - auto, m - markdown editor, n - WYSIWYG/HTML editor). */
9282
+ isDefault: "y" | "m" | "n";
9283
+ /** @description Setting to check if revision was published in shop. */
9284
+ wasPublished: number;
9285
+ /** @description 2-letter ISO country code. */
9286
+ country: string;
9287
+ }[];
9288
+ pagination: PagedResponse;
9289
+ };
9290
+
9260
9291
  export { };
package/dist/utils.d.ts CHANGED
@@ -1,41 +1,34 @@
1
- import type { PRODUCT_SIZE_COUNTABLE, PRODUCT_SIZE_LOCATIONS, PRODUCT_SIZE_CODES, PRODUCE_SIZE_INDEX } from "./enums.d";
2
- import type { SearchProductsResponse } from "./responses.d.ts"
3
-
4
- export type IdosellProduct = SearchProductsResponse['results'][0];
5
-
6
- export type GetIaICodeFunction = (productId: number|string, sizeId: string) => string;
7
-
8
- export type SumProductQuantitiesFunction = (productStocksData: IdosellProduct['productStocksData'], stockType?: PRODUCT_SIZE_COUNTABLE | `${PRODUCT_SIZE_COUNTABLE}`) => number;
9
-
10
- export type MapSizeQuantitesFunction = (product: IdosellProduct, stockType?: `${PRODUCT_SIZE_COUNTABLE}`, indexBy?: `${PRODUCE_SIZE_INDEX}`) => Record<string,number>;
11
-
12
- export type MapProductCodesFunction = (product: IdosellProduct, codeType?: `${PRODUCT_SIZE_CODES}`, indexBy?: `${PRODUCE_SIZE_INDEX}`) => Record<string,string>;
13
-
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[]>;
17
-
18
- export type GetLangDataFunction = <T extends { langId: string}>(array: T[], langId?: string) => T|undefined;
19
-
20
- export type ClearParametersLangDataFunction = (products: SearchProductsResponse['results'], langId?: string) => SearchProductsResponse['results'];
21
-
22
- declare namespace utils {
23
- /** @description The method allows you to build an IAI code from the product ID and size ID. */
24
- const getIaiCode: GetIaICodeFunction;
25
- /** @description The method allows you to sum up the current stock levels: warehouses, available stocks, etc. */
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 */
28
- const mapSizeQuantites: MapSizeQuantitesFunction;
29
- /** @description The method allows mapping the producers's or external system's codes stored in the system to SKUs */
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 */
36
- const getLangData: GetLangDataFunction;
37
- /** @description Modifies product response by removing all parameter names nad values that are not in selected langId */
38
- const clearParametersLangData: ClearParametersLangDataFunction;
39
- }
40
-
41
- export default utils;
1
+ import { ENUMS } from "./enums";
2
+ import type { SearchProductsResponse, GetRmaResponse } from "./responses.d.ts";
3
+ type IdosellProduct = SearchProductsResponse['results'][0];
4
+ type GetIaICodeFunction = (_productId: number | string, _sizeId: string) => string;
5
+ type SumProductQuantitiesFunction = (_productStocksData: IdosellProduct['productStocksData'], _stockType?: ENUMS.PRODUCT_SIZE_COUNTABLE | `${ENUMS.PRODUCT_SIZE_COUNTABLE}`) => number;
6
+ type MapSizeQuantitesFunction = (_product: IdosellProduct, _stockType?: `${ENUMS.PRODUCT_SIZE_COUNTABLE}`, _indexBy?: `${ENUMS.PRODUCE_SIZE_INDEX}`) => Record<string, number>;
7
+ type MapProductCodesFunction = (_product: IdosellProduct, _codeType?: `${ENUMS.PRODUCT_SIZE_CODES}`, _indexBy?: `${ENUMS.PRODUCE_SIZE_INDEX}`) => Record<string, string>;
8
+ type MapProductAllCodesFunction = (_product: IdosellProduct, _indexBy?: `${ENUMS.PRODUCE_SIZE_INDEX}`) => Record<string, string[]>;
9
+ type MapProductLocationsFunction = (_product: IdosellProduct, _stockId?: number, _codeType?: `${ENUMS.PRODUCT_SIZE_LOCATIONS}`, _indexBy?: `${ENUMS.PRODUCE_SIZE_INDEX}`) => Record<string, string[]>;
10
+ type GetLangDataFunction = <T extends {
11
+ langId: string;
12
+ }>(_array: T[], _langId?: string) => T | undefined;
13
+ type ClearParametersLangDataFunction = (_products: SearchProductsResponse['results'], _langId?: string) => SearchProductsResponse['results'];
14
+ declare const _default: {
15
+ /** @description The method allows you to build an IAI code from the product ID and size ID. */
16
+ getIaiCode: GetIaICodeFunction;
17
+ /** @description The method allows you to sum up the current stock levels: warehouses, available stocks, etc. */
18
+ sumProductQuantities: SumProductQuantitiesFunction;
19
+ /** @description The method allows mapping the sum of the current stock levels (in warehouses, at disposal, etc.) divided into sizes */
20
+ mapSizeQuantites: MapSizeQuantitesFunction;
21
+ /** @description The method allows mapping the producers's or external system's codes stored in the system to SKUs */
22
+ mapProductCodes: MapProductCodesFunction;
23
+ /** @description The method allows mapping all known codes: IAI code, manufacturer code or external code as an array */
24
+ mapAllProductCodes: MapProductAllCodesFunction;
25
+ /** @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. */
26
+ mapProductLocations: MapProductLocationsFunction;
27
+ /** @description Get first item (description, series, parameter name or value) with the selected langId */
28
+ getLangData: GetLangDataFunction;
29
+ /** @description Modifies product response by removing all parameter names nad values that are not in selected langId */
30
+ clearParametersLangData: ClearParametersLangDataFunction;
31
+ /** @description Removes attachments to RMA that are returned by default, helps to reduce data if serialized or forwarded */
32
+ removeRmaAttachments: (rmaResponse: GetRmaResponse) => GetRmaResponse;
33
+ };
34
+ export default _default;
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import ENUMS from "./enums.js";
1
+ import { ENUMS } from "./enums.js";
2
2
  const getIaiCode = (productId, sizeId) => {
3
3
  if (sizeId === 'uniw')
4
4
  return productId.toString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idosell",
3
- "version": "0.4.27",
3
+ "version": "0.4.32",
4
4
  "description": "Idosell 3 REST connector",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/gateways.d.ts",
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("getProductsAttachmentsGetContentAttachmentId", () => {
5
+ const params = idosell().getProductsAttachmentsGetContent.productIdentType("id").productIdentValue("294").attachmentId(5).checkParams();
6
+ expect(params).toEqual({"productIdentType":"id","productIdentValue":"294","attachmentId":5});
7
+ })
@@ -1,7 +1,7 @@
1
- import idosell from "./dist/index"
1
+ import idosell from "./dist/index.ts"
2
2
  import { expect, test } from "vitest"
3
3
 
4
4
  test("putClientsExternalCodeCode_extern", () => {
5
- const params = idosell().putClientsExternalCode.client_login("iai_demo").code_extern("abc").checkParams();
6
- expect(params).toEqual({"client_login":"iai_demo","code_extern":"abc"});
5
+ const params = idosell().putClientsExternalCode.client_id(10).code_extern("vip10").checkParams();
6
+ expect(params).toEqual({"clients":[{"client_id":10,"code_extern":"vip10"}]});
7
7
  })
@@ -7,18 +7,15 @@ const INDEX = ENUMS.PRODUCE_SIZE_INDEX;
7
7
 
8
8
  test('Utils mapAllProductCodes by ID', () => {
9
9
  const codes = utils.mapAllProductCodes(STOCK_PRODUCT, INDEX.ID)
10
- console.log(JSON.stringify(codes));
11
10
  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
11
  })
13
12
 
14
13
  test('Utils mapAllProductCodes by IAI code', () => {
15
14
  const codes = utils.mapAllProductCodes(STOCK_PRODUCT, INDEX.IAI_CODE)
16
- console.log(JSON.stringify(codes));
17
15
  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
16
  })
19
17
 
20
18
  test('Utils mapAllProductCodes by name', () => {
21
19
  const codes = utils.mapAllProductCodes(STOCK_PRODUCT, INDEX.NAME)
22
- console.log(JSON.stringify(codes));
23
20
  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
21
  })