@prezly/sdk 23.0.0 → 23.0.1

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.
@@ -15,27 +15,31 @@ async function sleep(milliseconds) {
15
15
  }
16
16
  function handleDeferredJob(api, request) {
17
17
  return new _progressPromise.ProgressPromise(async (resolve, reject, update) => {
18
- const response = await request;
19
- if (response.status === _index.HttpCodes.ACCEPTED && (0, _index.isDeferredJobResponse)(response.payload)) {
20
- const id = response.payload.progress.id;
21
- do {
22
- const response = await api.get(`${_routing.routing.jobsUrl}/${id}`, {
23
- fetch
24
- });
25
- const state = response.payload.job.state;
26
- if (state.status === _index2.JobStatus.RESOLVED) {
27
- resolve(state.value);
28
- return;
29
- }
30
- if (state.status === _index2.JobStatus.REJECTED) {
31
- reject(state.value);
32
- return;
33
- }
34
- update(state.progress, state.value);
35
- await sleep(JOB_STATUS_POLLING_INTERVAL);
36
- } while (true); // eslint-disable-line no-constant-condition
18
+ try {
19
+ const response = await request;
20
+ if (response.status === _index.HttpCodes.ACCEPTED && (0, _index.isDeferredJobResponse)(response.payload)) {
21
+ const id = response.payload.progress.id;
22
+ do {
23
+ const response = await api.get(`${_routing.routing.jobsUrl}/${id}`, {
24
+ fetch
25
+ });
26
+ const state = response.payload.job.state;
27
+ if (state.status === _index2.JobStatus.RESOLVED) {
28
+ resolve(state.value);
29
+ return;
30
+ }
31
+ if (state.status === _index2.JobStatus.REJECTED) {
32
+ reject(state.value);
33
+ return;
34
+ }
35
+ update(state.progress, state.value);
36
+ await sleep(JOB_STATUS_POLLING_INTERVAL);
37
+ } while (true); // eslint-disable-line no-constant-condition
38
+ }
39
+ resolve(response.payload);
40
+ } catch (error) {
41
+ reject(error);
37
42
  }
38
- resolve(response.payload);
39
43
  });
40
44
  }
41
45
  function createDeferredJobsApiClient(api) {
@@ -9,27 +9,31 @@ async function sleep(milliseconds) {
9
9
  }
10
10
  function handleDeferredJob(api, request) {
11
11
  return new ProgressPromise(async (resolve, reject, update) => {
12
- const response = await request;
13
- if (response.status === HttpCodes.ACCEPTED && isDeferredJobResponse(response.payload)) {
14
- const id = response.payload.progress.id;
15
- do {
16
- const response = await api.get(`${routing.jobsUrl}/${id}`, {
17
- fetch
18
- });
19
- const state = response.payload.job.state;
20
- if (state.status === JobStatus.RESOLVED) {
21
- resolve(state.value);
22
- return;
23
- }
24
- if (state.status === JobStatus.REJECTED) {
25
- reject(state.value);
26
- return;
27
- }
28
- update(state.progress, state.value);
29
- await sleep(JOB_STATUS_POLLING_INTERVAL);
30
- } while (true); // eslint-disable-line no-constant-condition
12
+ try {
13
+ const response = await request;
14
+ if (response.status === HttpCodes.ACCEPTED && isDeferredJobResponse(response.payload)) {
15
+ const id = response.payload.progress.id;
16
+ do {
17
+ const response = await api.get(`${routing.jobsUrl}/${id}`, {
18
+ fetch
19
+ });
20
+ const state = response.payload.job.state;
21
+ if (state.status === JobStatus.RESOLVED) {
22
+ resolve(state.value);
23
+ return;
24
+ }
25
+ if (state.status === JobStatus.REJECTED) {
26
+ reject(state.value);
27
+ return;
28
+ }
29
+ update(state.progress, state.value);
30
+ await sleep(JOB_STATUS_POLLING_INTERVAL);
31
+ } while (true); // eslint-disable-line no-constant-condition
32
+ }
33
+ resolve(response.payload);
34
+ } catch (error) {
35
+ reject(error);
31
36
  }
32
- resolve(response.payload);
33
37
  });
34
38
  }
35
39
  export function createDeferredJobsApiClient(api) {
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DEFAULT_USER_AGENT = void 0;
7
- const VERSION = "22.10.1";
7
+ const VERSION = "23.0.0";
8
8
  const URL = 'https://github.com/prezly/javascript-sdk';
9
9
  const DEFAULT_USER_AGENT = exports.DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
@@ -1,3 +1,3 @@
1
- const VERSION = "22.10.1";
1
+ const VERSION = "23.0.0";
2
2
  const URL = 'https://github.com/prezly/javascript-sdk';
3
3
  export const DEFAULT_USER_AGENT = `prezly-javascript-sdk/${VERSION} (+${URL})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/sdk",
3
- "version": "23.0.0",
3
+ "version": "23.0.1",
4
4
  "description": "Prezly API SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",