@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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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) {
|
package/dist/api/constants.cjs
CHANGED
|
@@ -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 = "
|
|
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})`;
|
package/dist/api/constants.js
CHANGED