@pega/dx-component-builder-sdk 8.23.17 → 8.23.18

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/dx-component-builder-sdk",
3
- "version": "8.23.17",
3
+ "version": "8.23.18",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -243,42 +243,36 @@ export const publishComponentToServer = async (data, doFetch = true) => {
243
243
  refresh_token: refreshToken
244
244
  } = JSON.parse(OauthData);
245
245
  let status = 500;
246
- fetch(url, {
246
+ const response = await fetch(url, {
247
247
  method: 'POST',
248
248
  agent: getHttpsAgent(defaultPegaConfig),
249
249
  headers: {
250
250
  Authorization: `${tokenType} ${accessToken}`
251
251
  },
252
252
  body: JSON.stringify(apiBody)
253
- })
254
- .then(response => {
255
- status = response.status;
256
- return response.text();
257
- })
258
- .then(resp => {
259
- const respData = JSON.parse(resp);
260
- if (status === 401) {
261
- throw new Error(
262
- 'Error occurred in authentication. Please regenerate using authenticate'
263
- );
264
- // console.log(accessTokenUri, refreshToken);
265
- /* TODO - Handle refresh_token */
266
- } else if (status == 200) {
267
- console.log(chalk.bold.green(`Success : ${respData.message}`));
268
- }
269
- else if (status === 403) {
270
- // eslint-disable-next-line prefer-promise-reject-errors
271
- Promise.reject(
272
- `${chalk.bold.red(
273
- 'Error forbidden: User does not have privileges to Publish.'
274
- )}`
275
- );
276
- }
277
- else {
278
- throw new Error(`${respData.message}`);
279
- }
280
- })
281
- .catch(e => Promise.reject(`${chalk.bold.red(e)}`));
253
+ });
254
+
255
+ if (!response.ok) {
256
+ if (response.status === 408) {
257
+ throw new Error(
258
+ 'Time out'
259
+ );
260
+ }
261
+ if (response.status === 401) {
262
+ throw new Error(
263
+ 'Error occurred in authentication. Please regenerate using authenticate'
264
+ );
265
+ }
266
+ if (response.status === 403) {
267
+ throw new Error(
268
+ 'Error forbidden: User does not have privileges to Publish.'
269
+ );
270
+ }
271
+
272
+ }
273
+
274
+ const data = await response.json();
275
+
282
276
  } else {
283
277
  throw new Error(`Error occurred in authentication. Please regenerate using authenticate`);
284
278
  }