@prezly/sdk 22.10.0 → 23.0.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/dist/Client.cjs +4 -5
- package/dist/Client.d.ts +1 -1
- package/dist/Client.js +5 -6
- package/dist/api/ApiClient.cjs +10 -15
- package/dist/api/ApiClient.d.ts +6 -7
- package/dist/api/ApiClient.js +10 -15
- package/dist/api/DeferredJobsApiClient.cjs +26 -27
- package/dist/api/DeferredJobsApiClient.d.ts +7 -7
- package/dist/api/DeferredJobsApiClient.js +26 -27
- package/dist/api/constants.cjs +1 -1
- package/dist/api/constants.js +1 -1
- package/dist/endpoints/Campaigns/Client.cjs +1 -1
- package/dist/endpoints/Campaigns/Client.js +1 -1
- package/dist/endpoints/Contacts/Client.cjs +2 -2
- package/dist/endpoints/Contacts/Client.js +2 -2
- package/dist/endpoints/Coverage/Client.cjs +1 -1
- package/dist/endpoints/Coverage/Client.js +1 -1
- package/dist/endpoints/Stories/Client.cjs +4 -2
- package/dist/endpoints/Stories/Client.js +4 -2
- package/dist/http/HttpClient.cjs +12 -5
- package/dist/http/HttpClient.d.ts +1 -0
- package/dist/http/HttpClient.js +12 -5
- package/package.json +1 -1
package/dist/Client.cjs
CHANGED
|
@@ -14,12 +14,11 @@ function createClient({
|
|
|
14
14
|
headers = {},
|
|
15
15
|
fetch
|
|
16
16
|
}) {
|
|
17
|
-
const
|
|
18
|
-
fetch
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const api = (0, _index.createDeferredJobsApiClient)((0, _index.createApiClient)((0, _index3.createHttpClient)({
|
|
18
|
+
fetch,
|
|
19
|
+
baseUrl
|
|
20
|
+
}), {
|
|
21
21
|
accessToken,
|
|
22
|
-
baseUrl,
|
|
23
22
|
headers
|
|
24
23
|
}));
|
|
25
24
|
return {
|
package/dist/Client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeferredJobsApiClient } from './api';
|
|
2
2
|
import { type Fetch } from './api';
|
|
3
|
-
import { Accounts, Billing,
|
|
3
|
+
import { Accounts, Billing, CampaignRecipients, Campaigns, Contacts, ContactsExports, ContactTagGroups, ContactTags, Coverage, CoverageIntegrations, Jobs, Licenses, NewsroomCategories, NewsroomContacts, NewsroomDomains, NewsroomGalleries, NewsroomHub, NewsroomLanguages, NewsroomPrivacyRequests, Newsrooms, NewsroomSubscriptions, NewsroomThemes, NewsroomWebhooks, NotificationSubscriptions, PricingTables, SenderAddresses, Snippets, Stories, Subscriptions } from './endpoints';
|
|
4
4
|
import type { HeadersMap } from './http';
|
|
5
5
|
export interface ClientOptions {
|
|
6
6
|
accessToken: string;
|
package/dist/Client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createApiClient, createDeferredJobsApiClient } from "./api/index.js";
|
|
2
|
-
import { Accounts, Billing,
|
|
2
|
+
import { Accounts, Billing, CampaignRecipients, Campaigns, Contacts, ContactsExports, ContactTagGroups, ContactTags, Coverage, CoverageIntegrations, Jobs, Licenses, NewsroomCategories, NewsroomContacts, NewsroomDomains, NewsroomGalleries, NewsroomHub, NewsroomLanguages, NewsroomPrivacyRequests, Newsrooms, NewsroomSubscriptions, NewsroomThemes, NewsroomWebhooks, NotificationSubscriptions, PricingTables, SenderAddresses, Snippets, Stories, Subscriptions } from "./endpoints/index.js";
|
|
3
3
|
import { createHttpClient } from "./http/index.js";
|
|
4
4
|
const DEFAULT_BASE_URL = 'https://api.prezly.com';
|
|
5
5
|
export function createClient({
|
|
@@ -8,12 +8,11 @@ export function createClient({
|
|
|
8
8
|
headers = {},
|
|
9
9
|
fetch
|
|
10
10
|
}) {
|
|
11
|
-
const
|
|
12
|
-
fetch
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const api = createDeferredJobsApiClient(createApiClient(createHttpClient({
|
|
12
|
+
fetch,
|
|
13
|
+
baseUrl
|
|
14
|
+
}), {
|
|
15
15
|
accessToken,
|
|
16
|
-
baseUrl,
|
|
17
16
|
headers
|
|
18
17
|
}));
|
|
19
18
|
return {
|
package/dist/api/ApiClient.cjs
CHANGED
|
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createApiClient = createApiClient;
|
|
7
|
-
var _utils = require("../utils.cjs");
|
|
8
7
|
var _constants = require("./constants.cjs");
|
|
9
8
|
function createApiClient(http, {
|
|
10
9
|
accessToken,
|
|
11
|
-
baseUrl,
|
|
12
10
|
headers
|
|
13
11
|
}) {
|
|
14
12
|
const defaultHeaders = {
|
|
@@ -16,14 +14,11 @@ function createApiClient(http, {
|
|
|
16
14
|
'User-Agent': _constants.DEFAULT_USER_AGENT,
|
|
17
15
|
...headers
|
|
18
16
|
};
|
|
19
|
-
function
|
|
20
|
-
return `${(0, _utils.stripSlashes)(baseUrl)}/${(0, _utils.stripSlashes)(endpointUri)}`;
|
|
21
|
-
}
|
|
22
|
-
function get(endpointUri, {
|
|
17
|
+
function get(url, {
|
|
23
18
|
headers,
|
|
24
19
|
query
|
|
25
20
|
} = {}) {
|
|
26
|
-
return http.get(
|
|
21
|
+
return http.get(url, {
|
|
27
22
|
headers: {
|
|
28
23
|
...defaultHeaders,
|
|
29
24
|
...headers
|
|
@@ -31,12 +26,12 @@ function createApiClient(http, {
|
|
|
31
26
|
query
|
|
32
27
|
});
|
|
33
28
|
}
|
|
34
|
-
function post(
|
|
29
|
+
function post(url, {
|
|
35
30
|
headers,
|
|
36
31
|
payload,
|
|
37
32
|
query
|
|
38
33
|
} = {}) {
|
|
39
|
-
return http.post(
|
|
34
|
+
return http.post(url, {
|
|
40
35
|
headers: {
|
|
41
36
|
...defaultHeaders,
|
|
42
37
|
...headers
|
|
@@ -45,12 +40,12 @@ function createApiClient(http, {
|
|
|
45
40
|
query
|
|
46
41
|
});
|
|
47
42
|
}
|
|
48
|
-
function put(
|
|
43
|
+
function put(url, {
|
|
49
44
|
headers,
|
|
50
45
|
payload,
|
|
51
46
|
query
|
|
52
47
|
} = {}) {
|
|
53
|
-
return http.put(
|
|
48
|
+
return http.put(url, {
|
|
54
49
|
headers: {
|
|
55
50
|
...defaultHeaders,
|
|
56
51
|
...headers
|
|
@@ -59,12 +54,12 @@ function createApiClient(http, {
|
|
|
59
54
|
query
|
|
60
55
|
});
|
|
61
56
|
}
|
|
62
|
-
function patch(
|
|
57
|
+
function patch(url, {
|
|
63
58
|
headers,
|
|
64
59
|
payload,
|
|
65
60
|
query
|
|
66
61
|
} = {}) {
|
|
67
|
-
return http.patch(
|
|
62
|
+
return http.patch(url, {
|
|
68
63
|
headers: {
|
|
69
64
|
...defaultHeaders,
|
|
70
65
|
...headers
|
|
@@ -73,12 +68,12 @@ function createApiClient(http, {
|
|
|
73
68
|
query
|
|
74
69
|
});
|
|
75
70
|
}
|
|
76
|
-
function doDelete(
|
|
71
|
+
function doDelete(url, {
|
|
77
72
|
headers,
|
|
78
73
|
payload,
|
|
79
74
|
query
|
|
80
75
|
} = {}) {
|
|
81
|
-
return http.delete(
|
|
76
|
+
return http.delete(url, {
|
|
82
77
|
headers: {
|
|
83
78
|
...defaultHeaders,
|
|
84
79
|
...headers
|
package/dist/api/ApiClient.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { ApiResponse, HeadersMap, HttpClient, Params, ParamsWithPayload } from '../http';
|
|
2
2
|
export interface Options {
|
|
3
3
|
accessToken: string;
|
|
4
|
-
baseUrl: string;
|
|
5
4
|
headers: HeadersMap;
|
|
6
5
|
}
|
|
7
6
|
export type ApiClient = ReturnType<typeof createApiClient>;
|
|
8
|
-
export declare function createApiClient(http: HttpClient, { accessToken,
|
|
9
|
-
get: <V = any>(
|
|
10
|
-
post: <V_1 = any>(
|
|
11
|
-
put: <V_2 = any>(
|
|
12
|
-
patch: <V_3 = any>(
|
|
13
|
-
delete: <V_4 = any>(
|
|
7
|
+
export declare function createApiClient(http: HttpClient, { accessToken, headers }: Options): {
|
|
8
|
+
get: <V = any>(url: string, { headers, query }?: Params) => Promise<ApiResponse<V>>;
|
|
9
|
+
post: <V_1 = any>(url: string, { headers, payload, query }?: ParamsWithPayload) => Promise<ApiResponse<V_1>>;
|
|
10
|
+
put: <V_2 = any>(url: string, { headers, payload, query }?: ParamsWithPayload) => Promise<ApiResponse<V_2>>;
|
|
11
|
+
patch: <V_3 = any>(url: string, { headers, payload, query }?: ParamsWithPayload) => Promise<ApiResponse<V_3>>;
|
|
12
|
+
delete: <V_4 = any>(url: string, { headers, payload, query }?: ParamsWithPayload) => Promise<ApiResponse<V_4>>;
|
|
14
13
|
};
|
package/dist/api/ApiClient.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { stripSlashes } from "../utils.js";
|
|
2
1
|
import { DEFAULT_USER_AGENT } from "./constants.js";
|
|
3
2
|
export function createApiClient(http, {
|
|
4
3
|
accessToken,
|
|
5
|
-
baseUrl,
|
|
6
4
|
headers
|
|
7
5
|
}) {
|
|
8
6
|
const defaultHeaders = {
|
|
@@ -10,14 +8,11 @@ export function createApiClient(http, {
|
|
|
10
8
|
'User-Agent': DEFAULT_USER_AGENT,
|
|
11
9
|
...headers
|
|
12
10
|
};
|
|
13
|
-
function
|
|
14
|
-
return `${stripSlashes(baseUrl)}/${stripSlashes(endpointUri)}`;
|
|
15
|
-
}
|
|
16
|
-
function get(endpointUri, {
|
|
11
|
+
function get(url, {
|
|
17
12
|
headers,
|
|
18
13
|
query
|
|
19
14
|
} = {}) {
|
|
20
|
-
return http.get(
|
|
15
|
+
return http.get(url, {
|
|
21
16
|
headers: {
|
|
22
17
|
...defaultHeaders,
|
|
23
18
|
...headers
|
|
@@ -25,12 +20,12 @@ export function createApiClient(http, {
|
|
|
25
20
|
query
|
|
26
21
|
});
|
|
27
22
|
}
|
|
28
|
-
function post(
|
|
23
|
+
function post(url, {
|
|
29
24
|
headers,
|
|
30
25
|
payload,
|
|
31
26
|
query
|
|
32
27
|
} = {}) {
|
|
33
|
-
return http.post(
|
|
28
|
+
return http.post(url, {
|
|
34
29
|
headers: {
|
|
35
30
|
...defaultHeaders,
|
|
36
31
|
...headers
|
|
@@ -39,12 +34,12 @@ export function createApiClient(http, {
|
|
|
39
34
|
query
|
|
40
35
|
});
|
|
41
36
|
}
|
|
42
|
-
function put(
|
|
37
|
+
function put(url, {
|
|
43
38
|
headers,
|
|
44
39
|
payload,
|
|
45
40
|
query
|
|
46
41
|
} = {}) {
|
|
47
|
-
return http.put(
|
|
42
|
+
return http.put(url, {
|
|
48
43
|
headers: {
|
|
49
44
|
...defaultHeaders,
|
|
50
45
|
...headers
|
|
@@ -53,12 +48,12 @@ export function createApiClient(http, {
|
|
|
53
48
|
query
|
|
54
49
|
});
|
|
55
50
|
}
|
|
56
|
-
function patch(
|
|
51
|
+
function patch(url, {
|
|
57
52
|
headers,
|
|
58
53
|
payload,
|
|
59
54
|
query
|
|
60
55
|
} = {}) {
|
|
61
|
-
return http.patch(
|
|
56
|
+
return http.patch(url, {
|
|
62
57
|
headers: {
|
|
63
58
|
...defaultHeaders,
|
|
64
59
|
...headers
|
|
@@ -67,12 +62,12 @@ export function createApiClient(http, {
|
|
|
67
62
|
query
|
|
68
63
|
});
|
|
69
64
|
}
|
|
70
|
-
function doDelete(
|
|
65
|
+
function doDelete(url, {
|
|
71
66
|
headers,
|
|
72
67
|
payload,
|
|
73
68
|
query
|
|
74
69
|
} = {}) {
|
|
75
|
-
return http.delete(
|
|
70
|
+
return http.delete(url, {
|
|
76
71
|
headers: {
|
|
77
72
|
...defaultHeaders,
|
|
78
73
|
...headers
|
|
@@ -13,81 +13,80 @@ const JOB_STATUS_POLLING_INTERVAL = 2000; // ms
|
|
|
13
13
|
async function sleep(milliseconds) {
|
|
14
14
|
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function handleDeferredJob(api, request) {
|
|
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;
|
|
20
21
|
do {
|
|
21
|
-
const response = await
|
|
22
|
+
const response = await api.get(`${_routing.routing.jobsUrl}/${id}`, {
|
|
22
23
|
fetch
|
|
23
24
|
});
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (job.status === _index2.JobStatus.RESOLVED) {
|
|
28
|
-
resolve(job.value);
|
|
25
|
+
const state = response.payload.job.state;
|
|
26
|
+
if (state.status === _index2.JobStatus.RESOLVED) {
|
|
27
|
+
resolve(state.value);
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
|
-
if (
|
|
32
|
-
reject(
|
|
30
|
+
if (state.status === _index2.JobStatus.REJECTED) {
|
|
31
|
+
reject(state.value);
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
|
-
|
|
34
|
+
update(state.progress, state.value);
|
|
36
35
|
await sleep(JOB_STATUS_POLLING_INTERVAL);
|
|
37
36
|
} while (true); // eslint-disable-line no-constant-condition
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
}
|
|
38
|
+
resolve(response.payload);
|
|
39
|
+
});
|
|
41
40
|
}
|
|
42
|
-
function createDeferredJobsApiClient(
|
|
43
|
-
function get(
|
|
41
|
+
function createDeferredJobsApiClient(api) {
|
|
42
|
+
function get(url, {
|
|
44
43
|
headers,
|
|
45
44
|
query
|
|
46
45
|
} = {}) {
|
|
47
|
-
return handleDeferredJob(
|
|
46
|
+
return handleDeferredJob(api, api.get(url, {
|
|
48
47
|
headers,
|
|
49
48
|
query
|
|
50
49
|
}));
|
|
51
50
|
}
|
|
52
|
-
function post(
|
|
51
|
+
function post(url, {
|
|
53
52
|
headers,
|
|
54
53
|
payload,
|
|
55
54
|
query
|
|
56
55
|
} = {}) {
|
|
57
|
-
return handleDeferredJob(
|
|
56
|
+
return handleDeferredJob(api, api.post(url, {
|
|
58
57
|
headers,
|
|
59
58
|
payload,
|
|
60
59
|
query
|
|
61
60
|
}));
|
|
62
61
|
}
|
|
63
|
-
function put(
|
|
62
|
+
function put(url, {
|
|
64
63
|
headers,
|
|
65
64
|
payload,
|
|
66
65
|
query
|
|
67
66
|
} = {}) {
|
|
68
|
-
return handleDeferredJob(
|
|
67
|
+
return handleDeferredJob(api, api.put(url, {
|
|
69
68
|
headers,
|
|
70
69
|
payload,
|
|
71
70
|
query
|
|
72
71
|
}));
|
|
73
72
|
}
|
|
74
|
-
function patch(
|
|
73
|
+
function patch(url, {
|
|
75
74
|
headers,
|
|
76
75
|
payload,
|
|
77
76
|
query
|
|
78
77
|
} = {}) {
|
|
79
|
-
return handleDeferredJob(
|
|
78
|
+
return handleDeferredJob(api, api.patch(url, {
|
|
80
79
|
headers,
|
|
81
80
|
payload,
|
|
82
81
|
query
|
|
83
82
|
}));
|
|
84
83
|
}
|
|
85
|
-
function doDelete(
|
|
84
|
+
function doDelete(url, {
|
|
86
85
|
headers,
|
|
87
86
|
payload,
|
|
88
87
|
query
|
|
89
88
|
} = {}) {
|
|
90
|
-
return handleDeferredJob(
|
|
89
|
+
return handleDeferredJob(api, api.delete(url, {
|
|
91
90
|
headers,
|
|
92
91
|
payload,
|
|
93
92
|
query
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ProgressPromise } from '@prezly/progress-promise';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Params, ParamsWithPayload } from '../http';
|
|
3
3
|
import type { ApiClient } from './ApiClient';
|
|
4
4
|
export type DeferredJobsApiClient = ReturnType<typeof createDeferredJobsApiClient>;
|
|
5
|
-
export declare function createDeferredJobsApiClient(
|
|
6
|
-
get: <V = any, P = any>(
|
|
7
|
-
post: <V_1 = any, P_1 = any>(
|
|
8
|
-
put: <V_2 = any, P_2 = any>(
|
|
9
|
-
patch: <V_3 = any, P_3 = any>(
|
|
10
|
-
delete: <V_4 = any, P_4 = any>(
|
|
5
|
+
export declare function createDeferredJobsApiClient(api: ApiClient): {
|
|
6
|
+
get: <V = any, P = any>(url: string, { headers, query }?: Params) => ProgressPromise<V, P>;
|
|
7
|
+
post: <V_1 = any, P_1 = any>(url: string, { headers, payload, query }?: ParamsWithPayload) => ProgressPromise<V_1, P_1>;
|
|
8
|
+
put: <V_2 = any, P_2 = any>(url: string, { headers, payload, query }?: ParamsWithPayload) => ProgressPromise<V_2, P_2>;
|
|
9
|
+
patch: <V_3 = any, P_3 = any>(url: string, { headers, payload, query }?: ParamsWithPayload) => ProgressPromise<V_3, P_3>;
|
|
10
|
+
delete: <V_4 = any, P_4 = any>(url: string, { headers, payload, query }?: ParamsWithPayload) => ProgressPromise<V_4, P_4>;
|
|
11
11
|
};
|
|
@@ -7,81 +7,80 @@ const JOB_STATUS_POLLING_INTERVAL = 2000; // ms
|
|
|
7
7
|
async function sleep(milliseconds) {
|
|
8
8
|
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
function handleDeferredJob(api, request) {
|
|
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;
|
|
14
15
|
do {
|
|
15
|
-
const response = await
|
|
16
|
+
const response = await api.get(`${routing.jobsUrl}/${id}`, {
|
|
16
17
|
fetch
|
|
17
18
|
});
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (job.status === JobStatus.RESOLVED) {
|
|
22
|
-
resolve(job.value);
|
|
19
|
+
const state = response.payload.job.state;
|
|
20
|
+
if (state.status === JobStatus.RESOLVED) {
|
|
21
|
+
resolve(state.value);
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
|
-
if (
|
|
26
|
-
reject(
|
|
24
|
+
if (state.status === JobStatus.REJECTED) {
|
|
25
|
+
reject(state.value);
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
|
-
|
|
28
|
+
update(state.progress, state.value);
|
|
30
29
|
await sleep(JOB_STATUS_POLLING_INTERVAL);
|
|
31
30
|
} while (true); // eslint-disable-line no-constant-condition
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
}
|
|
32
|
+
resolve(response.payload);
|
|
33
|
+
});
|
|
35
34
|
}
|
|
36
|
-
export function createDeferredJobsApiClient(
|
|
37
|
-
function get(
|
|
35
|
+
export function createDeferredJobsApiClient(api) {
|
|
36
|
+
function get(url, {
|
|
38
37
|
headers,
|
|
39
38
|
query
|
|
40
39
|
} = {}) {
|
|
41
|
-
return handleDeferredJob(
|
|
40
|
+
return handleDeferredJob(api, api.get(url, {
|
|
42
41
|
headers,
|
|
43
42
|
query
|
|
44
43
|
}));
|
|
45
44
|
}
|
|
46
|
-
function post(
|
|
45
|
+
function post(url, {
|
|
47
46
|
headers,
|
|
48
47
|
payload,
|
|
49
48
|
query
|
|
50
49
|
} = {}) {
|
|
51
|
-
return handleDeferredJob(
|
|
50
|
+
return handleDeferredJob(api, api.post(url, {
|
|
52
51
|
headers,
|
|
53
52
|
payload,
|
|
54
53
|
query
|
|
55
54
|
}));
|
|
56
55
|
}
|
|
57
|
-
function put(
|
|
56
|
+
function put(url, {
|
|
58
57
|
headers,
|
|
59
58
|
payload,
|
|
60
59
|
query
|
|
61
60
|
} = {}) {
|
|
62
|
-
return handleDeferredJob(
|
|
61
|
+
return handleDeferredJob(api, api.put(url, {
|
|
63
62
|
headers,
|
|
64
63
|
payload,
|
|
65
64
|
query
|
|
66
65
|
}));
|
|
67
66
|
}
|
|
68
|
-
function patch(
|
|
67
|
+
function patch(url, {
|
|
69
68
|
headers,
|
|
70
69
|
payload,
|
|
71
70
|
query
|
|
72
71
|
} = {}) {
|
|
73
|
-
return handleDeferredJob(
|
|
72
|
+
return handleDeferredJob(api, api.patch(url, {
|
|
74
73
|
headers,
|
|
75
74
|
payload,
|
|
76
75
|
query
|
|
77
76
|
}));
|
|
78
77
|
}
|
|
79
|
-
function doDelete(
|
|
78
|
+
function doDelete(url, {
|
|
80
79
|
headers,
|
|
81
80
|
payload,
|
|
82
81
|
query
|
|
83
82
|
} = {}) {
|
|
84
|
-
return handleDeferredJob(
|
|
83
|
+
return handleDeferredJob(api, api.delete(url, {
|
|
85
84
|
headers,
|
|
86
85
|
payload,
|
|
87
86
|
query
|
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 = "22.
|
|
7
|
+
const VERSION = "22.10.1";
|
|
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
|
@@ -75,7 +75,7 @@ function createClient(api) {
|
|
|
75
75
|
} = await api.post(`${_routing.routing.campaignsUrl}/${id}/unschedule`);
|
|
76
76
|
return campaign;
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
function create(payload) {
|
|
79
79
|
return api.post(_routing.routing.campaignsUrl, {
|
|
80
80
|
payload
|
|
81
81
|
});
|
|
@@ -123,7 +123,7 @@ function createClient(api) {
|
|
|
123
123
|
});
|
|
124
124
|
return contact;
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
function bulkTag(selector, tags) {
|
|
127
127
|
const {
|
|
128
128
|
scope,
|
|
129
129
|
query
|
|
@@ -136,7 +136,7 @@ function createClient(api) {
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
function bulkUntag(selector, tags) {
|
|
140
140
|
const {
|
|
141
141
|
query,
|
|
142
142
|
scope
|
|
@@ -117,7 +117,7 @@ export function createClient(api) {
|
|
|
117
117
|
});
|
|
118
118
|
return contact;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
function bulkTag(selector, tags) {
|
|
121
121
|
const {
|
|
122
122
|
scope,
|
|
123
123
|
query
|
|
@@ -130,7 +130,7 @@ export function createClient(api) {
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
function bulkUntag(selector, tags) {
|
|
134
134
|
const {
|
|
135
135
|
query,
|
|
136
136
|
scope
|
|
@@ -190,7 +190,8 @@ function createClient(api) {
|
|
|
190
190
|
}
|
|
191
191
|
async function translate(id, payload = {}, options) {
|
|
192
192
|
const {
|
|
193
|
-
culture
|
|
193
|
+
culture,
|
|
194
|
+
auto = false
|
|
194
195
|
} = payload ?? {};
|
|
195
196
|
const {
|
|
196
197
|
include,
|
|
@@ -205,7 +206,8 @@ function createClient(api) {
|
|
|
205
206
|
include
|
|
206
207
|
},
|
|
207
208
|
payload: {
|
|
208
|
-
culture
|
|
209
|
+
culture,
|
|
210
|
+
auto
|
|
209
211
|
}
|
|
210
212
|
});
|
|
211
213
|
return story;
|
|
@@ -182,7 +182,8 @@ export function createClient(api) {
|
|
|
182
182
|
}
|
|
183
183
|
async function translate(id, payload = {}, options) {
|
|
184
184
|
const {
|
|
185
|
-
culture
|
|
185
|
+
culture,
|
|
186
|
+
auto = false
|
|
186
187
|
} = payload ?? {};
|
|
187
188
|
const {
|
|
188
189
|
include,
|
|
@@ -197,7 +198,8 @@ export function createClient(api) {
|
|
|
197
198
|
include
|
|
198
199
|
},
|
|
199
200
|
payload: {
|
|
200
|
-
culture
|
|
201
|
+
culture,
|
|
202
|
+
auto
|
|
201
203
|
}
|
|
202
204
|
});
|
|
203
205
|
return story;
|
package/dist/http/HttpClient.cjs
CHANGED
|
@@ -7,13 +7,20 @@ exports.createHttpClient = createHttpClient;
|
|
|
7
7
|
var _createRequest = require("./createRequest.cjs");
|
|
8
8
|
var _types = require("./types.cjs");
|
|
9
9
|
function createHttpClient(options = {}) {
|
|
10
|
+
const baseUrl = options.baseUrl ?? null;
|
|
10
11
|
const fetchImpl = options.fetch ?? fetch;
|
|
12
|
+
function resolveUrl(url) {
|
|
13
|
+
if (baseUrl) {
|
|
14
|
+
return new URL(url, baseUrl).toString();
|
|
15
|
+
}
|
|
16
|
+
return url;
|
|
17
|
+
}
|
|
11
18
|
return {
|
|
12
19
|
get(url, {
|
|
13
20
|
headers,
|
|
14
21
|
query
|
|
15
22
|
} = {}) {
|
|
16
|
-
return (0, _createRequest.createRequest)(fetchImpl, url, {
|
|
23
|
+
return (0, _createRequest.createRequest)(fetchImpl, resolveUrl(url), {
|
|
17
24
|
headers,
|
|
18
25
|
method: _types.Method.GET,
|
|
19
26
|
query
|
|
@@ -24,7 +31,7 @@ function createHttpClient(options = {}) {
|
|
|
24
31
|
payload,
|
|
25
32
|
query
|
|
26
33
|
} = {}) {
|
|
27
|
-
return (0, _createRequest.createRequest)(fetchImpl, url, {
|
|
34
|
+
return (0, _createRequest.createRequest)(fetchImpl, resolveUrl(url), {
|
|
28
35
|
headers,
|
|
29
36
|
method: _types.Method.POST,
|
|
30
37
|
payload,
|
|
@@ -36,7 +43,7 @@ function createHttpClient(options = {}) {
|
|
|
36
43
|
payload,
|
|
37
44
|
query
|
|
38
45
|
} = {}) {
|
|
39
|
-
return (0, _createRequest.createRequest)(fetchImpl, url, {
|
|
46
|
+
return (0, _createRequest.createRequest)(fetchImpl, resolveUrl(url), {
|
|
40
47
|
headers,
|
|
41
48
|
method: _types.Method.PUT,
|
|
42
49
|
payload,
|
|
@@ -48,7 +55,7 @@ function createHttpClient(options = {}) {
|
|
|
48
55
|
payload,
|
|
49
56
|
query
|
|
50
57
|
} = {}) {
|
|
51
|
-
return (0, _createRequest.createRequest)(fetchImpl, url, {
|
|
58
|
+
return (0, _createRequest.createRequest)(fetchImpl, resolveUrl(url), {
|
|
52
59
|
headers,
|
|
53
60
|
method: _types.Method.PATCH,
|
|
54
61
|
payload,
|
|
@@ -60,7 +67,7 @@ function createHttpClient(options = {}) {
|
|
|
60
67
|
payload,
|
|
61
68
|
query
|
|
62
69
|
} = {}) {
|
|
63
|
-
return (0, _createRequest.createRequest)(fetchImpl, url, {
|
|
70
|
+
return (0, _createRequest.createRequest)(fetchImpl, resolveUrl(url), {
|
|
64
71
|
headers,
|
|
65
72
|
method: _types.Method.DELETE,
|
|
66
73
|
payload,
|
package/dist/http/HttpClient.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { createRequest } from "./createRequest.js";
|
|
2
2
|
import { Method } from "./types.js";
|
|
3
3
|
export function createHttpClient(options = {}) {
|
|
4
|
+
const baseUrl = options.baseUrl ?? null;
|
|
4
5
|
const fetchImpl = options.fetch ?? fetch;
|
|
6
|
+
function resolveUrl(url) {
|
|
7
|
+
if (baseUrl) {
|
|
8
|
+
return new URL(url, baseUrl).toString();
|
|
9
|
+
}
|
|
10
|
+
return url;
|
|
11
|
+
}
|
|
5
12
|
return {
|
|
6
13
|
get(url, {
|
|
7
14
|
headers,
|
|
8
15
|
query
|
|
9
16
|
} = {}) {
|
|
10
|
-
return createRequest(fetchImpl, url, {
|
|
17
|
+
return createRequest(fetchImpl, resolveUrl(url), {
|
|
11
18
|
headers,
|
|
12
19
|
method: Method.GET,
|
|
13
20
|
query
|
|
@@ -18,7 +25,7 @@ export function createHttpClient(options = {}) {
|
|
|
18
25
|
payload,
|
|
19
26
|
query
|
|
20
27
|
} = {}) {
|
|
21
|
-
return createRequest(fetchImpl, url, {
|
|
28
|
+
return createRequest(fetchImpl, resolveUrl(url), {
|
|
22
29
|
headers,
|
|
23
30
|
method: Method.POST,
|
|
24
31
|
payload,
|
|
@@ -30,7 +37,7 @@ export function createHttpClient(options = {}) {
|
|
|
30
37
|
payload,
|
|
31
38
|
query
|
|
32
39
|
} = {}) {
|
|
33
|
-
return createRequest(fetchImpl, url, {
|
|
40
|
+
return createRequest(fetchImpl, resolveUrl(url), {
|
|
34
41
|
headers,
|
|
35
42
|
method: Method.PUT,
|
|
36
43
|
payload,
|
|
@@ -42,7 +49,7 @@ export function createHttpClient(options = {}) {
|
|
|
42
49
|
payload,
|
|
43
50
|
query
|
|
44
51
|
} = {}) {
|
|
45
|
-
return createRequest(fetchImpl, url, {
|
|
52
|
+
return createRequest(fetchImpl, resolveUrl(url), {
|
|
46
53
|
headers,
|
|
47
54
|
method: Method.PATCH,
|
|
48
55
|
payload,
|
|
@@ -54,7 +61,7 @@ export function createHttpClient(options = {}) {
|
|
|
54
61
|
payload,
|
|
55
62
|
query
|
|
56
63
|
} = {}) {
|
|
57
|
-
return createRequest(fetchImpl, url, {
|
|
64
|
+
return createRequest(fetchImpl, resolveUrl(url), {
|
|
58
65
|
headers,
|
|
59
66
|
method: Method.DELETE,
|
|
60
67
|
payload,
|