zudello-integration-sdk 1.0.58 → 1.0.59
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/package.json
CHANGED
|
@@ -18,7 +18,7 @@ class UniversalModule {
|
|
|
18
18
|
* @param {boolean} appendLimit Append limit & offset to URL.
|
|
19
19
|
* @returns {object} Universal Request Response.
|
|
20
20
|
*/
|
|
21
|
-
async request({ url, method, qs = {}, body = {}}) {
|
|
21
|
+
async request({ url, method, qs = {}, body = {}, appendLimit = false }) {
|
|
22
22
|
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
23
23
|
|
|
24
24
|
if (!validateIsEmpty.valid) {
|
|
@@ -53,64 +53,66 @@ class UniversalModule {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* Universal List By URL
|
|
57
|
-
* @param {string} url URL of
|
|
58
|
-
* @param {string}
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {
|
|
56
|
+
* Universal List By URL.
|
|
57
|
+
* @param {string} url URL of the request.
|
|
58
|
+
* @param {string} after Cursor for pagination.
|
|
59
|
+
* @param {number} limit Limit of listed data.
|
|
60
|
+
* @param {string} query Query of listed data.
|
|
61
|
+
* @param {object} variables Additional variables for the query.
|
|
61
62
|
* @returns {object} Universal List Response.
|
|
62
63
|
*/
|
|
63
|
-
async list({ url,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return await this.request({ url, method, qs, body });
|
|
64
|
+
async list({ url, after = "", limit = 100, query = "", variables = {} }) {
|
|
65
|
+
return await this.request({
|
|
66
|
+
url,
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: {
|
|
69
|
+
query,
|
|
70
|
+
variables: {
|
|
71
|
+
after,
|
|
72
|
+
first: limit,
|
|
73
|
+
...variables,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
});
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
/**
|
|
82
|
-
* Universal Auto Pagination Listing
|
|
83
|
-
* @param {string} url URL of
|
|
84
|
-
* @param {string}
|
|
85
|
-
* @param {
|
|
86
|
-
* @param {
|
|
87
|
-
* @
|
|
80
|
+
* Universal Auto Pagination Listing.
|
|
81
|
+
* @param {string} url URL of the request.
|
|
82
|
+
* @param {string} after Cursor for pagination.
|
|
83
|
+
* @param {number} limit Limit of listed data.
|
|
84
|
+
* @param {string} query Query of listed data.
|
|
85
|
+
* @param {object} variables Additional variables for the query.
|
|
86
|
+
* @param {string} pageInfoPath Path to pageInfo in the response (e.g., "data.users.pageInfo").
|
|
87
|
+
* @returns {AsyncGenerator} Auto Pagination responses.
|
|
88
88
|
*/
|
|
89
|
-
async *autoPaginationList({
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
let response = await this.list({ url, method, qs, body });
|
|
99
|
-
let currentPageCount = response?.data?.length;
|
|
100
|
-
|
|
89
|
+
async *autoPaginationList({
|
|
90
|
+
url,
|
|
91
|
+
after = "",
|
|
92
|
+
limit = 100,
|
|
93
|
+
query = "",
|
|
94
|
+
variables = {},
|
|
95
|
+
pageInfoPath = "",
|
|
96
|
+
}) {
|
|
97
|
+
let response = await this.list({ url, after, limit, query, variables });
|
|
101
98
|
yield response;
|
|
102
99
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
response = await this.list({ url, method, qs, body });
|
|
108
|
-
currentPageCount = response?.data?.length;
|
|
100
|
+
let pageInfo = _.get(response, pageInfoPath);
|
|
101
|
+
if (pageInfo && pageInfo.hasNextPage) {
|
|
102
|
+
while (pageInfo.hasNextPage) {
|
|
103
|
+
after = pageInfo.endCursor;
|
|
109
104
|
|
|
105
|
+
response = await this.list({ url, after, limit, query, variables });
|
|
110
106
|
yield response;
|
|
107
|
+
|
|
108
|
+
pageInfo = _.get(response, pageInfoPath);
|
|
109
|
+
|
|
110
|
+
if (!pageInfo) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
module.exports = UniversalModule;
|
|
118
|
+
module.exports = UniversalModule;
|