idosell 0.4.23 → 0.4.25
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 +2 -0
- package/changelog.md +10 -0
- package/dist/app.d.ts +2 -1
- package/dist/gates.js +51 -15
- package/dist/gateways.d.ts +279 -16
- package/dist/helpers.js +18 -0
- package/dist/index.js +18 -1
- package/dist/methods/deletePromotions.js +6 -0
- package/dist/methods/deletePromotionsArchive.js +6 -0
- package/dist/methods/deletePromotionsElements.js +13 -0
- package/dist/methods/getPromotions.js +6 -0
- package/dist/methods/getPromotionsArchive.js +6 -0
- package/dist/methods/getPromotionsSettings.js +5 -0
- package/dist/methods/postPromotions.js +7 -0
- package/dist/methods/postPromotionsElements.js +13 -0
- package/dist/methods/postPromotionsEnd.js +7 -0
- package/dist/methods/postPromotionsStart.js +7 -0
- package/dist/methods/putPromotions.js +8 -0
- package/dist/methods/putPromotionsSettings.js +6 -0
- package/dist/methods/searchPromotionsArchive.js +14 -0
- package/dist/methods/searchPromotionsElements.js +15 -0
- package/dist/methods/searchPromotionsHistory.js +13 -0
- package/dist/methods/searchPromotionsListView.js +21 -0
- package/dist/params.js +15 -1
- package/dist/reqparams.d.ts +2 -2
- package/dist/request.js +33 -10
- package/dist/responses.d.ts +483 -0
- package/package.json +1 -1
- package/tests/deleteProductsToFacebookCatalog.test.js +7 -0
- package/tests/deleteProductsToPromotion.test.js +7 -0
- package/tests/deletePromotions.test.js +7 -0
- package/tests/deletePromotionsArchive.test.js +7 -0
- package/tests/deletePromotionsElements.test.js +7 -0
- package/tests/getProductsToFacebookCatalog.test.js +8 -0
- package/tests/getPromotions.test.js +7 -0
- package/tests/getPromotionsArchive.test.js +7 -0
- package/tests/postProductsToFacebookCatalog.test.js +7 -0
- package/tests/postProductsToPromotion.test.js +7 -0
- package/tests/postPromotionsElements.test.js +7 -0
- package/tests/postPromotionsEnd.test.js +7 -0
- package/tests/postPromotionsStart.test.js +7 -0
- package/tests/putPromotions.test.js +7 -0
- package/tests/putPromotionsSettings.test.js +7 -0
- package/tests/searchPromotionsArchive.test.js +12 -0
- package/tests/searchPromotionsElements.test.js +12 -0
- package/tests/searchPromotionsHistory.test.js +7 -0
- package/tests/searchPromotionsListView.test.js +7 -0
- package/tests/deleteProductsProductsToFacebookCatalog.test.js +0 -7
- package/tests/deleteProductsProductsToPromotion.test.js +0 -7
- /package/dist/methods/{deleteProductsProductsToFacebookCatalog.js → deleteProductsToFacebookCatalog.js} +0 -0
- /package/dist/methods/{deleteProductsProductsToPromotion.js → deleteProductsToPromotion.js} +0 -0
- /package/dist/methods/{getProductsProductsToFacebookCatalog.js → getProductsToFacebookCatalog.js} +0 -0
- /package/dist/methods/{postProductsProductsToFacebookCatalog.js → postProductsToFacebookCatalog.js} +0 -0
- /package/dist/methods/{postProductsProductsToPromotion.js → postProductsToPromotion.js} +0 -0
- /package/dist/methods/{postSubscriptionsItemsList.js → searchSubscriptionsItems.js} +0 -0
- /package/dist/methods/{postSubscriptionsListViewList.js → searchSubscriptionsListView.js} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
export default (object) => {
|
|
3
|
+
object.gate = { method: 'post', node: '/promotions/elements/remove' };
|
|
4
|
+
object.rootparams = "request";
|
|
5
|
+
object.appendable = {
|
|
6
|
+
except: [],
|
|
7
|
+
arrayNode: "elements",
|
|
8
|
+
index: 0
|
|
9
|
+
};
|
|
10
|
+
object.req = ["promotionId", "type", "id"];
|
|
11
|
+
object.arrays = ["elements"];
|
|
12
|
+
return new Proxy(object, paramsProxy);
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
export default (object) => {
|
|
3
|
+
object.gate = { method: 'post', node: '/promotions/promotions/add' };
|
|
4
|
+
object.rootparams = "request";
|
|
5
|
+
object.arrays = ["activeInShops", "types"];
|
|
6
|
+
return new Proxy(object, paramsProxy);
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
export default (object) => {
|
|
3
|
+
object.gate = { method: 'post', node: '/promotions/elements/add' };
|
|
4
|
+
object.rootparams = "request";
|
|
5
|
+
object.appendable = {
|
|
6
|
+
except: [],
|
|
7
|
+
arrayNode: "elements",
|
|
8
|
+
index: 0
|
|
9
|
+
};
|
|
10
|
+
object.req = ["promotionId", "id", "type"];
|
|
11
|
+
object.arrays = ["elements"];
|
|
12
|
+
return new Proxy(object, paramsProxy);
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
export default (object) => {
|
|
3
|
+
object.gate = { method: 'put', node: '/promotions/promotions/edit' };
|
|
4
|
+
object.rootparams = "request";
|
|
5
|
+
object.req = ["promotionId"];
|
|
6
|
+
object.arrays = ["activeInShops", "types"];
|
|
7
|
+
return new Proxy(object, paramsProxy);
|
|
8
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
import { orderByProperty, paginationObject, nest } from "../helpers.js";
|
|
3
|
+
export default (object) => {
|
|
4
|
+
object.gate = { method: 'post', node: '/promotions/promotionsArchive/list' };
|
|
5
|
+
object.rootparams = "request";
|
|
6
|
+
object.custom = {
|
|
7
|
+
orderByProperty,
|
|
8
|
+
page: paginationObject,
|
|
9
|
+
shops: nest("shops", "filter", {}, true),
|
|
10
|
+
archivedDate: nest("archivedDate", "filter", {}, false)
|
|
11
|
+
};
|
|
12
|
+
object.paginationObject = true;
|
|
13
|
+
return new Proxy(object, paramsProxy);
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
import { orderByProperty, paginationObject, nest } from "../helpers.js";
|
|
3
|
+
export default (object) => {
|
|
4
|
+
object.gate = { method: 'post', node: '/promotions/elements/list' };
|
|
5
|
+
object.rootparams = "request";
|
|
6
|
+
object.custom = {
|
|
7
|
+
orderByProperty,
|
|
8
|
+
page: paginationObject,
|
|
9
|
+
ids: nest("ids", "filter", {}, true),
|
|
10
|
+
types: nest("types", "filter", {}, true),
|
|
11
|
+
promotionIds: nest("promotionIds", "filter", {}, true)
|
|
12
|
+
};
|
|
13
|
+
object.paginationObject = true;
|
|
14
|
+
return new Proxy(object, paramsProxy);
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
import { paginationObject, nest } from "../helpers.js";
|
|
3
|
+
export default (object) => {
|
|
4
|
+
object.gate = { method: 'post', node: '/promotions/history/get' };
|
|
5
|
+
object.rootparams = "request";
|
|
6
|
+
object.custom = {
|
|
7
|
+
page: paginationObject,
|
|
8
|
+
promotionId: nest("promotionId", "filter", {}, false)
|
|
9
|
+
};
|
|
10
|
+
object.paginationObject = true;
|
|
11
|
+
object.req = ["filter"];
|
|
12
|
+
return new Proxy(object, paramsProxy);
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { paramsProxy } from "../params.js";
|
|
2
|
+
import { orderByProperty, paginationObject, nest } from "../helpers.js";
|
|
3
|
+
export default (object) => {
|
|
4
|
+
object.gate = { method: 'post', node: '/promotions/promotions/listView/list' };
|
|
5
|
+
object.rootparams = "request";
|
|
6
|
+
object.custom = {
|
|
7
|
+
orderByProperty,
|
|
8
|
+
page: paginationObject,
|
|
9
|
+
ids: nest("ids", "filter", {}, true),
|
|
10
|
+
name: nest("name", "filter", {}, false),
|
|
11
|
+
changeVisibility: nest("changeVisibility", "filter", {}, false),
|
|
12
|
+
activeInShops: nest("activeInShops", "filter", {}, true),
|
|
13
|
+
types: nest("types", "filter", {}, true),
|
|
14
|
+
priceTypes: nest("priceTypes", "filter", {}, true),
|
|
15
|
+
statuses: nest("statuses", "filter", {}, true),
|
|
16
|
+
dateRange: nest("dateRange", "filter", {}, false),
|
|
17
|
+
productsNotInPromotion: nest("productsNotInPromotion", "filter", {}, true)
|
|
18
|
+
};
|
|
19
|
+
object.paginationObject = true;
|
|
20
|
+
return new Proxy(object, paramsProxy);
|
|
21
|
+
};
|
package/dist/params.js
CHANGED
|
@@ -13,6 +13,19 @@ const requests = {
|
|
|
13
13
|
return receiver;
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
+
function deepAssignSecondLevel(target, source) {
|
|
17
|
+
for (const key of Object.keys(source)) {
|
|
18
|
+
if (key in target &&
|
|
19
|
+
typeof target[key] === 'object' && target[key] !== null &&
|
|
20
|
+
typeof source[key] === 'object' && source[key] !== null) {
|
|
21
|
+
Object.assign(target[key], source[key]);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
target[key] = source[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
16
29
|
export const paramsProxy = {
|
|
17
30
|
get: (object, property, receiver) => {
|
|
18
31
|
if (property === 'then') {
|
|
@@ -48,7 +61,8 @@ export const paramsProxy = {
|
|
|
48
61
|
values = [values[0] ?? 0, values[1] ?? 100, Boolean(object.snakeCase)];
|
|
49
62
|
}
|
|
50
63
|
const param = object.custom[property](...values);
|
|
51
|
-
|
|
64
|
+
if (param)
|
|
65
|
+
deepAssignSecondLevel(object.params, param);
|
|
52
66
|
}
|
|
53
67
|
else if (object.arrays && object.arrays.includes(property)) {
|
|
54
68
|
if (Array.isArray(values[0]))
|
package/dist/reqparams.d.ts
CHANGED
|
@@ -6312,7 +6312,7 @@ export type PostPackagesParams = {
|
|
|
6312
6312
|
}[];
|
|
6313
6313
|
};
|
|
6314
6314
|
|
|
6315
|
-
export type
|
|
6315
|
+
export type PostProductsToFacebookCatalogParams = {
|
|
6316
6316
|
/** @description You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
|
|
6317
6317
|
facebookCatalogId?: number;
|
|
6318
6318
|
/** @description Shop Id */
|
|
@@ -6321,7 +6321,7 @@ export type PostProductsProductsToFacebookCatalogParams = {
|
|
|
6321
6321
|
products?: number[];
|
|
6322
6322
|
};
|
|
6323
6323
|
|
|
6324
|
-
export type
|
|
6324
|
+
export type PostProductsToPromotionParams = {
|
|
6325
6325
|
/** @description Special offer ID */
|
|
6326
6326
|
promotionId?: number;
|
|
6327
6327
|
/** @description Products list. */
|
package/dist/request.js
CHANGED
|
@@ -16,9 +16,20 @@ const catchIdosellError = (err) => {
|
|
|
16
16
|
if (!err.response.headers['x-error'] && err.response.headers['content-type'].indexOf('json') < 0)
|
|
17
17
|
throw new Error('500: Invalid response from Api gateway');
|
|
18
18
|
let message = err.response.headers['x-error'];
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (err.response?.data?.errors) {
|
|
20
|
+
let errorObj = err.response?.data?.errors;
|
|
21
|
+
if (Array.isArray(errorObj))
|
|
22
|
+
errorObj = errorObj[0];
|
|
23
|
+
if (errorObj.message)
|
|
24
|
+
message = errorObj.message;
|
|
25
|
+
}
|
|
26
|
+
if (message) {
|
|
27
|
+
for (const [search, replace] of DECODE_TABLE) {
|
|
28
|
+
message = message.replaceAll(search, replace);
|
|
29
|
+
}
|
|
21
30
|
}
|
|
31
|
+
else
|
|
32
|
+
message = 'Unknown error';
|
|
22
33
|
if (err.response.status === 403) {
|
|
23
34
|
const match = message.match(/Scope: ([a-z]+), level: ([rw]{1,2})/);
|
|
24
35
|
if (match) {
|
|
@@ -41,17 +52,27 @@ const checkNext = (request, response, logPage) => {
|
|
|
41
52
|
};
|
|
42
53
|
throw new IdosellFaultStringError(response.errors.faultString, faultStructure);
|
|
43
54
|
}
|
|
55
|
+
function handlePagination(currentPage, totalPages, request, paramsUpdate) {
|
|
56
|
+
request.next = currentPage + 1 < totalPages;
|
|
57
|
+
if (paramsUpdate)
|
|
58
|
+
Object.assign(request.params, paramsUpdate);
|
|
59
|
+
if (typeof logPage === 'function') {
|
|
60
|
+
logPage('Page: ' + currentPage + ' / ' + totalPages);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
44
63
|
if (response.resultsNumberPage) {
|
|
45
|
-
|
|
46
|
-
request.params.resultsPage = request.params.resultsPage ? request.params.resultsPage + 1 : 1;
|
|
47
|
-
if (logPage)
|
|
48
|
-
logPage('Page: ' + response.resultsPage + ' / ' + response.resultsNumberPage);
|
|
64
|
+
handlePagination(response.resultsPage, response.resultsNumberPage, request, { resultsPage: response.resultsPage + 1 });
|
|
49
65
|
}
|
|
50
66
|
else if (response.results_number_page) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
handlePagination(response.results_page, response.results_number_page, request, { results_page: response.results_page + 1 });
|
|
68
|
+
}
|
|
69
|
+
else if (response.pagination) {
|
|
70
|
+
request.params.pagination.page = response.pagination.resultsPage + 1;
|
|
71
|
+
handlePagination(response.pagination.resultsPage, response.pagination.resultsNumberPage, request);
|
|
72
|
+
}
|
|
73
|
+
else if (response.data?.pagination) {
|
|
74
|
+
request.params.pagination.page = response.data.pagination.resultsPage + 1;
|
|
75
|
+
handlePagination(response.data.pagination.resultsPage, response.data.pagination.resultsNumberPage, request);
|
|
55
76
|
}
|
|
56
77
|
return response;
|
|
57
78
|
};
|
|
@@ -190,6 +211,8 @@ export const countResults = async (request, options) => {
|
|
|
190
211
|
return 0;
|
|
191
212
|
if (request.snakeCase)
|
|
192
213
|
return parseInt(response.results_number_all);
|
|
214
|
+
else if (request.paginationObject)
|
|
215
|
+
return response.pagination.resultsNumberAll;
|
|
193
216
|
else
|
|
194
217
|
return response.resultsNumberAll;
|
|
195
218
|
};
|