@contentstack/marketplace-sdk 1.2.9 → 1.4.0
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/CHANGELOG.md +9 -1
- package/dist/es-modules/core/concurrency-queue.js +24 -11
- package/dist/es-modules/marketplace/index.js +86 -18
- package/dist/es5/core/concurrency-queue.js +24 -11
- package/dist/es5/marketplace/index.js +86 -18
- package/dist/nativescript/contentstack-marketplace.js +1 -1
- package/dist/node/contentstack-marketplace.js +1 -1
- package/dist/react-native/contentstack-marketplace.js +1 -1
- package/dist/web/contentstack-marketplace.js +1 -1
- package/package.json +1 -1
- package/types/marketplace/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
## [v1.4.0](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.3.0) (2024-08-25)
|
|
4
|
+
- Enhancement: Retry logic to make use of x-ratelimit-remaining header
|
|
5
|
+
|
|
6
|
+
## [v1.3.0](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.3.0) (2024-08-11)
|
|
7
|
+
- Enh: Add search function to query apps by names
|
|
8
|
+
|
|
9
|
+
## [v1.2.9](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.9) (2024-08-04)
|
|
3
10
|
- Fix: Fixed the Linting issues
|
|
4
11
|
- Updated all the dependency to the latest version
|
|
5
12
|
- Added Pre-commit hook to run the snyk and talismand scans
|
|
6
13
|
|
|
7
14
|
## [v1.2.8](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.8) (2024-05-26)
|
|
15
|
+
|
|
8
16
|
- Fix: Added params support to getInstalledApps method for enhanced flexibility
|
|
9
17
|
|
|
10
18
|
## [v1.2.7](https://github.com/contentstack/contentstack-marketplace-sdk/tree/v1.2.7) (2024-05-15)
|
|
@@ -213,18 +213,31 @@ export function ConcurrencyQueue(_ref) {
|
|
|
213
213
|
} else {
|
|
214
214
|
return Promise.reject(responseHandler(error));
|
|
215
215
|
}
|
|
216
|
-
} else
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
} else {
|
|
217
|
+
var rateLimitRemaining = response.headers['x-ratelimit-remaining'];
|
|
218
|
+
if (rateLimitRemaining !== undefined && parseInt(rateLimitRemaining) <= 0) {
|
|
219
|
+
// return Promise.reject(responseHandler(error))
|
|
220
|
+
|
|
221
|
+
_this.running.shift();
|
|
222
|
+
return _delay(wait).then(function () {
|
|
223
|
+
error.config.retryCount = networkError++;
|
|
224
|
+
// deepcode ignore Ssrf: URL is dynamic
|
|
225
|
+
return axios(updateRequestConfig(error, 'Rate Limit Hit', wait));
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
if (response.status === 429 || response.status === 401 && _this.config.refreshToken) {
|
|
229
|
+
retryErrorType = "Error with status: ".concat(response.status);
|
|
230
|
+
networkError++;
|
|
231
|
+
if (networkError > _this.config.retryLimit) {
|
|
232
|
+
return Promise.reject(responseHandler(error));
|
|
233
|
+
}
|
|
234
|
+
_this.running.shift();
|
|
235
|
+
// Cool down the running requests
|
|
236
|
+
_delay(wait, response.status === 401);
|
|
237
|
+
error.config.retryCount = networkError;
|
|
238
|
+
// deepcode ignore Ssrf: URL is dynamic
|
|
239
|
+
return axios(updateRequestConfig(error, retryErrorType, wait));
|
|
221
240
|
}
|
|
222
|
-
_this.running.shift();
|
|
223
|
-
// Cool down the running requests
|
|
224
|
-
_delay(wait, response.status === 401);
|
|
225
|
-
error.config.retryCount = networkError;
|
|
226
|
-
// deepcode ignore Ssrf: URL is dynamic
|
|
227
|
-
return axios(updateRequestConfig(error, retryErrorType, wait));
|
|
228
241
|
}
|
|
229
242
|
if (_this.config.retryCondition && _this.config.retryCondition(error)) {
|
|
230
243
|
retryErrorType = error.response ? "Error with status: ".concat(response.status) : "Error Code:".concat(error.code);
|
|
@@ -112,6 +112,74 @@ export function Marketplace(http, data) {
|
|
|
112
112
|
this.urlPath = '/manifests';
|
|
113
113
|
this.findAllApps = fetchAll(http, AppCollection, this.params);
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* @description Search installed apps
|
|
117
|
+
* @memberof Marketplace
|
|
118
|
+
* @func searchInstalledApps
|
|
119
|
+
* @param {String} search - Search term
|
|
120
|
+
* @param {Object} queryParams - Additional query parameters
|
|
121
|
+
* @returns {Promise<ContentstackCollection<App>>}
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* import * as contentstack from '@contentstack/marketplace'
|
|
125
|
+
* const client = contentstack.client({ authtoken: 'TOKEN'})
|
|
126
|
+
*
|
|
127
|
+
* client.marketplace('organization_uid').searchApps('search_term')
|
|
128
|
+
* .then((collection) => console.log(collection))
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
this.searchApps = /*#__PURE__*/function () {
|
|
132
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(search) {
|
|
133
|
+
var queryParams,
|
|
134
|
+
headers,
|
|
135
|
+
response,
|
|
136
|
+
_args = arguments,
|
|
137
|
+
_t;
|
|
138
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
139
|
+
while (1) switch (_context.prev = _context.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
queryParams = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
142
|
+
_context.prev = 1;
|
|
143
|
+
if (search) {
|
|
144
|
+
_context.next = 2;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
throw new Error("Search parameter is required");
|
|
148
|
+
case 2:
|
|
149
|
+
headers = {
|
|
150
|
+
headers: _objectSpread({}, cloneDeep(_this.params)),
|
|
151
|
+
params: _objectSpread({
|
|
152
|
+
search: search
|
|
153
|
+
}, cloneDeep(queryParams))
|
|
154
|
+
};
|
|
155
|
+
_context.next = 3;
|
|
156
|
+
return http.get(_this.urlPath, headers);
|
|
157
|
+
case 3:
|
|
158
|
+
response = _context.sent;
|
|
159
|
+
if (!response.data) {
|
|
160
|
+
_context.next = 4;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
return _context.abrupt("return", response.data);
|
|
164
|
+
case 4:
|
|
165
|
+
throw error(response);
|
|
166
|
+
case 5:
|
|
167
|
+
_context.next = 7;
|
|
168
|
+
break;
|
|
169
|
+
case 6:
|
|
170
|
+
_context.prev = 6;
|
|
171
|
+
_t = _context["catch"](1);
|
|
172
|
+
throw error(_t);
|
|
173
|
+
case 7:
|
|
174
|
+
case "end":
|
|
175
|
+
return _context.stop();
|
|
176
|
+
}
|
|
177
|
+
}, _callee, null, [[1, 6]]);
|
|
178
|
+
}));
|
|
179
|
+
return function (_x) {
|
|
180
|
+
return _ref.apply(this, arguments);
|
|
181
|
+
};
|
|
182
|
+
}();
|
|
115
183
|
/**
|
|
116
184
|
* @description To get the apps list of authorized apps for the particular organization
|
|
117
185
|
* @memberof Marketplace
|
|
@@ -126,44 +194,44 @@ export function Marketplace(http, data) {
|
|
|
126
194
|
* .then((roles) => console.log(roles))
|
|
127
195
|
*
|
|
128
196
|
*/
|
|
129
|
-
this.findAllAuthorizedApps = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
197
|
+
this.findAllAuthorizedApps = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
130
198
|
var param,
|
|
131
199
|
headers,
|
|
132
200
|
response,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return _regeneratorRuntime.wrap(function (
|
|
136
|
-
while (1) switch (
|
|
201
|
+
_args2 = arguments,
|
|
202
|
+
_t2;
|
|
203
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
204
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
137
205
|
case 0:
|
|
138
|
-
param =
|
|
206
|
+
param = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
139
207
|
headers = {
|
|
140
208
|
headers: _objectSpread({}, cloneDeep(_this.params))
|
|
141
209
|
};
|
|
142
210
|
headers.params = _objectSpread({}, param);
|
|
143
|
-
|
|
144
|
-
|
|
211
|
+
_context2.prev = 1;
|
|
212
|
+
_context2.next = 2;
|
|
145
213
|
return http.get("/authorized-apps", headers);
|
|
146
214
|
case 2:
|
|
147
|
-
response =
|
|
215
|
+
response = _context2.sent;
|
|
148
216
|
if (!response.data) {
|
|
149
|
-
|
|
217
|
+
_context2.next = 3;
|
|
150
218
|
break;
|
|
151
219
|
}
|
|
152
|
-
return
|
|
220
|
+
return _context2.abrupt("return", response.data);
|
|
153
221
|
case 3:
|
|
154
|
-
return
|
|
222
|
+
return _context2.abrupt("return", error(response));
|
|
155
223
|
case 4:
|
|
156
|
-
|
|
224
|
+
_context2.next = 6;
|
|
157
225
|
break;
|
|
158
226
|
case 5:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return
|
|
227
|
+
_context2.prev = 5;
|
|
228
|
+
_t2 = _context2["catch"](1);
|
|
229
|
+
return _context2.abrupt("return", error(_t2));
|
|
162
230
|
case 6:
|
|
163
231
|
case "end":
|
|
164
|
-
return
|
|
232
|
+
return _context2.stop();
|
|
165
233
|
}
|
|
166
|
-
},
|
|
234
|
+
}, _callee2, null, [[1, 5]]);
|
|
167
235
|
}));
|
|
168
236
|
}
|
|
169
237
|
return this;
|
|
@@ -223,18 +223,31 @@ function ConcurrencyQueue(_ref) {
|
|
|
223
223
|
} else {
|
|
224
224
|
return Promise.reject(responseHandler(error));
|
|
225
225
|
}
|
|
226
|
-
} else
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
226
|
+
} else {
|
|
227
|
+
var rateLimitRemaining = response.headers['x-ratelimit-remaining'];
|
|
228
|
+
if (rateLimitRemaining !== undefined && parseInt(rateLimitRemaining) <= 0) {
|
|
229
|
+
// return Promise.reject(responseHandler(error))
|
|
230
|
+
|
|
231
|
+
_this.running.shift();
|
|
232
|
+
return _delay(wait).then(function () {
|
|
233
|
+
error.config.retryCount = networkError++;
|
|
234
|
+
// deepcode ignore Ssrf: URL is dynamic
|
|
235
|
+
return axios(updateRequestConfig(error, 'Rate Limit Hit', wait));
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (response.status === 429 || response.status === 401 && _this.config.refreshToken) {
|
|
239
|
+
retryErrorType = "Error with status: ".concat(response.status);
|
|
240
|
+
networkError++;
|
|
241
|
+
if (networkError > _this.config.retryLimit) {
|
|
242
|
+
return Promise.reject(responseHandler(error));
|
|
243
|
+
}
|
|
244
|
+
_this.running.shift();
|
|
245
|
+
// Cool down the running requests
|
|
246
|
+
_delay(wait, response.status === 401);
|
|
247
|
+
error.config.retryCount = networkError;
|
|
248
|
+
// deepcode ignore Ssrf: URL is dynamic
|
|
249
|
+
return axios(updateRequestConfig(error, retryErrorType, wait));
|
|
231
250
|
}
|
|
232
|
-
_this.running.shift();
|
|
233
|
-
// Cool down the running requests
|
|
234
|
-
_delay(wait, response.status === 401);
|
|
235
|
-
error.config.retryCount = networkError;
|
|
236
|
-
// deepcode ignore Ssrf: URL is dynamic
|
|
237
|
-
return axios(updateRequestConfig(error, retryErrorType, wait));
|
|
238
251
|
}
|
|
239
252
|
if (_this.config.retryCondition && _this.config.retryCondition(error)) {
|
|
240
253
|
retryErrorType = error.response ? "Error with status: ".concat(response.status) : "Error Code:".concat(error.code);
|
|
@@ -125,6 +125,74 @@ function Marketplace(http, data) {
|
|
|
125
125
|
this.urlPath = '/manifests';
|
|
126
126
|
this.findAllApps = (0, _entity.fetchAll)(http, AppCollection, this.params);
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @description Search installed apps
|
|
130
|
+
* @memberof Marketplace
|
|
131
|
+
* @func searchInstalledApps
|
|
132
|
+
* @param {String} search - Search term
|
|
133
|
+
* @param {Object} queryParams - Additional query parameters
|
|
134
|
+
* @returns {Promise<ContentstackCollection<App>>}
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* import * as contentstack from '@contentstack/marketplace'
|
|
138
|
+
* const client = contentstack.client({ authtoken: 'TOKEN'})
|
|
139
|
+
*
|
|
140
|
+
* client.marketplace('organization_uid').searchApps('search_term')
|
|
141
|
+
* .then((collection) => console.log(collection))
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
this.searchApps = /*#__PURE__*/function () {
|
|
145
|
+
var _ref = (0, _asyncToGenerator3["default"])(/*#__PURE__*/_regenerator2["default"].mark(function _callee(search) {
|
|
146
|
+
var queryParams,
|
|
147
|
+
headers,
|
|
148
|
+
response,
|
|
149
|
+
_args = arguments,
|
|
150
|
+
_t;
|
|
151
|
+
return _regenerator2["default"].wrap(function (_context) {
|
|
152
|
+
while (1) switch (_context.prev = _context.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
queryParams = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
155
|
+
_context.prev = 1;
|
|
156
|
+
if (search) {
|
|
157
|
+
_context.next = 2;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
throw new Error("Search parameter is required");
|
|
161
|
+
case 2:
|
|
162
|
+
headers = {
|
|
163
|
+
headers: _objectSpread({}, (0, _cloneDeep2["default"])(_this.params)),
|
|
164
|
+
params: _objectSpread({
|
|
165
|
+
search: search
|
|
166
|
+
}, (0, _cloneDeep2["default"])(queryParams))
|
|
167
|
+
};
|
|
168
|
+
_context.next = 3;
|
|
169
|
+
return http.get(_this.urlPath, headers);
|
|
170
|
+
case 3:
|
|
171
|
+
response = _context.sent;
|
|
172
|
+
if (!response.data) {
|
|
173
|
+
_context.next = 4;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
return _context.abrupt("return", response.data);
|
|
177
|
+
case 4:
|
|
178
|
+
throw (0, _contentstackError2["default"])(response);
|
|
179
|
+
case 5:
|
|
180
|
+
_context.next = 7;
|
|
181
|
+
break;
|
|
182
|
+
case 6:
|
|
183
|
+
_context.prev = 6;
|
|
184
|
+
_t = _context["catch"](1);
|
|
185
|
+
throw (0, _contentstackError2["default"])(_t);
|
|
186
|
+
case 7:
|
|
187
|
+
case "end":
|
|
188
|
+
return _context.stop();
|
|
189
|
+
}
|
|
190
|
+
}, _callee, null, [[1, 6]]);
|
|
191
|
+
}));
|
|
192
|
+
return function (_x) {
|
|
193
|
+
return _ref.apply(this, arguments);
|
|
194
|
+
};
|
|
195
|
+
}();
|
|
128
196
|
/**
|
|
129
197
|
* @description To get the apps list of authorized apps for the particular organization
|
|
130
198
|
* @memberof Marketplace
|
|
@@ -139,44 +207,44 @@ function Marketplace(http, data) {
|
|
|
139
207
|
* .then((roles) => console.log(roles))
|
|
140
208
|
*
|
|
141
209
|
*/
|
|
142
|
-
this.findAllAuthorizedApps = /*#__PURE__*/(0, _asyncToGenerator3["default"])(/*#__PURE__*/_regenerator2["default"].mark(function
|
|
210
|
+
this.findAllAuthorizedApps = /*#__PURE__*/(0, _asyncToGenerator3["default"])(/*#__PURE__*/_regenerator2["default"].mark(function _callee2() {
|
|
143
211
|
var param,
|
|
144
212
|
headers,
|
|
145
213
|
response,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return _regenerator2["default"].wrap(function (
|
|
149
|
-
while (1) switch (
|
|
214
|
+
_args2 = arguments,
|
|
215
|
+
_t2;
|
|
216
|
+
return _regenerator2["default"].wrap(function (_context2) {
|
|
217
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
150
218
|
case 0:
|
|
151
|
-
param =
|
|
219
|
+
param = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
152
220
|
headers = {
|
|
153
221
|
headers: _objectSpread({}, (0, _cloneDeep2["default"])(_this.params))
|
|
154
222
|
};
|
|
155
223
|
headers.params = _objectSpread({}, param);
|
|
156
|
-
|
|
157
|
-
|
|
224
|
+
_context2.prev = 1;
|
|
225
|
+
_context2.next = 2;
|
|
158
226
|
return http.get("/authorized-apps", headers);
|
|
159
227
|
case 2:
|
|
160
|
-
response =
|
|
228
|
+
response = _context2.sent;
|
|
161
229
|
if (!response.data) {
|
|
162
|
-
|
|
230
|
+
_context2.next = 3;
|
|
163
231
|
break;
|
|
164
232
|
}
|
|
165
|
-
return
|
|
233
|
+
return _context2.abrupt("return", response.data);
|
|
166
234
|
case 3:
|
|
167
|
-
return
|
|
235
|
+
return _context2.abrupt("return", (0, _contentstackError2["default"])(response));
|
|
168
236
|
case 4:
|
|
169
|
-
|
|
237
|
+
_context2.next = 6;
|
|
170
238
|
break;
|
|
171
239
|
case 5:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return
|
|
240
|
+
_context2.prev = 5;
|
|
241
|
+
_t2 = _context2["catch"](1);
|
|
242
|
+
return _context2.abrupt("return", (0, _contentstackError2["default"])(_t2));
|
|
175
243
|
case 6:
|
|
176
244
|
case "end":
|
|
177
|
-
return
|
|
245
|
+
return _context2.stop();
|
|
178
246
|
}
|
|
179
|
-
},
|
|
247
|
+
}, _callee2, null, [[1, 5]]);
|
|
180
248
|
}));
|
|
181
249
|
}
|
|
182
250
|
return this;
|