@prezly/sdk 25.8.0 → 26.1.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/api/DeferredJobsApiClient.cjs +2 -1
- package/dist/api/DeferredJobsApiClient.js +2 -1
- package/dist/api/constants.cjs +1 -1
- package/dist/api/constants.js +1 -1
- package/dist/endpoints/CoverageIntegrations/types.cjs +1 -2
- package/dist/endpoints/CoverageIntegrations/types.js +1 -2
- package/dist/endpoints/Newsrooms/Client.cjs +97 -32
- package/dist/endpoints/Newsrooms/Client.d.ts +18 -13
- package/dist/endpoints/Newsrooms/Client.js +96 -32
- package/dist/endpoints/Newsrooms/types.d.ts +8 -4
- package/dist/endpoints/Stories/types.cjs +4 -5
- package/dist/endpoints/Stories/types.d.ts +1 -1
- package/dist/endpoints/Stories/types.js +4 -5
- package/dist/endpoints/index.cjs +1 -2
- package/dist/http/createRequest.cjs +1 -1
- package/dist/http/createRequest.js +1 -1
- package/dist/http/lib.cjs +1 -1
- package/dist/types/Category.cjs +1 -1
- package/dist/types/Category.js +1 -1
- package/dist/types/Newsroom.cjs +8 -0
- package/dist/types/Newsroom.d.ts +24 -14
- package/dist/types/Newsroom.js +8 -0
- package/dist/types/NewsroomTheme.cjs +4 -2
- package/dist/types/NewsroomTheme.js +4 -2
- package/dist/types/Story.d.ts +4 -0
- package/package.json +11 -15
|
@@ -34,7 +34,8 @@ function handleDeferredJob(api, request) {
|
|
|
34
34
|
}
|
|
35
35
|
update(state.progress, state.value);
|
|
36
36
|
await sleep(JOB_STATUS_POLLING_INTERVAL);
|
|
37
|
-
|
|
37
|
+
// biome-ignore lint/correctness/noConstantCondition: <This infinite loop is expected and safe. There are two return statements breaking it when needed>
|
|
38
|
+
} while (true);
|
|
38
39
|
}
|
|
39
40
|
resolve(response.payload);
|
|
40
41
|
} catch (error) {
|
|
@@ -28,7 +28,8 @@ function handleDeferredJob(api, request) {
|
|
|
28
28
|
}
|
|
29
29
|
update(state.progress, state.value);
|
|
30
30
|
await sleep(JOB_STATUS_POLLING_INTERVAL);
|
|
31
|
-
|
|
31
|
+
// biome-ignore lint/correctness/noConstantCondition: <This infinite loop is expected and safe. There are two return statements breaking it when needed>
|
|
32
|
+
} while (true);
|
|
32
33
|
}
|
|
33
34
|
resolve(response.payload);
|
|
34
35
|
} catch (error) {
|
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 = "26.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
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import { CoverageEntry } from "../../types/index.js";
|
|
2
|
-
var Provider = CoverageEntry.Provider;
|
|
1
|
+
import { CoverageEntry } from "../../types/index.js";
|
|
@@ -6,30 +6,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createClient = createClient;
|
|
7
7
|
var _routing = require("../../routing.cjs");
|
|
8
8
|
var _index = require("../../types/index.cjs");
|
|
9
|
+
/**
|
|
10
|
+
* Utility type to forbid arbitrary ad-hoc extensions of generic parameters.
|
|
11
|
+
* @see https://stackoverflow.com/a/69666350
|
|
12
|
+
*/
|
|
13
|
+
|
|
9
14
|
function createClient(api) {
|
|
10
|
-
async function list({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
async function list(options) {
|
|
16
|
+
const {
|
|
17
|
+
search,
|
|
18
|
+
limit,
|
|
19
|
+
offset,
|
|
20
|
+
sortOrder,
|
|
21
|
+
include
|
|
22
|
+
} = options ?? {};
|
|
16
23
|
return api.get(_routing.routing.newsroomsUrl, {
|
|
17
24
|
query: {
|
|
18
25
|
limit,
|
|
19
26
|
offset,
|
|
20
27
|
search,
|
|
21
|
-
sort: _index.SortOrder.stringify(sortOrder)
|
|
28
|
+
sort: _index.SortOrder.stringify(sortOrder),
|
|
29
|
+
include: include?.join(',')
|
|
22
30
|
}
|
|
23
31
|
});
|
|
24
32
|
}
|
|
25
|
-
async function search(options
|
|
33
|
+
async function search(options) {
|
|
26
34
|
const {
|
|
27
35
|
query,
|
|
36
|
+
search,
|
|
28
37
|
limit,
|
|
29
38
|
offset,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} = options;
|
|
39
|
+
sortOrder,
|
|
40
|
+
include
|
|
41
|
+
} = options ?? {};
|
|
42
|
+
|
|
33
43
|
// TODO: Introduce dedicated Search POST API
|
|
34
44
|
return api.get(_routing.routing.newsroomsUrl, {
|
|
35
45
|
query: {
|
|
@@ -37,65 +47,120 @@ function createClient(api) {
|
|
|
37
47
|
limit,
|
|
38
48
|
offset,
|
|
39
49
|
search,
|
|
40
|
-
sort: _index.SortOrder.stringify(sortOrder)
|
|
50
|
+
sort: _index.SortOrder.stringify(sortOrder),
|
|
51
|
+
include: include?.join(',')
|
|
41
52
|
}
|
|
42
53
|
});
|
|
43
54
|
}
|
|
44
|
-
async function get(id) {
|
|
55
|
+
async function get(id, options) {
|
|
56
|
+
const {
|
|
57
|
+
include
|
|
58
|
+
} = options ?? {};
|
|
45
59
|
const {
|
|
46
60
|
newsroom
|
|
47
|
-
} = await api.get(`${_routing.routing.newsroomsUrl}/${id}
|
|
61
|
+
} = await api.get(`${_routing.routing.newsroomsUrl}/${id}`, {
|
|
62
|
+
query: {
|
|
63
|
+
include: include?.join(',')
|
|
64
|
+
}
|
|
65
|
+
});
|
|
48
66
|
return newsroom;
|
|
49
67
|
}
|
|
50
|
-
async function create(payload) {
|
|
68
|
+
async function create(payload, options) {
|
|
69
|
+
const {
|
|
70
|
+
include
|
|
71
|
+
} = options ?? {};
|
|
51
72
|
const {
|
|
52
73
|
newsroom
|
|
53
74
|
} = await api.post(_routing.routing.newsroomsUrl, {
|
|
54
|
-
payload
|
|
75
|
+
payload,
|
|
76
|
+
query: {
|
|
77
|
+
include: include?.join(',')
|
|
78
|
+
}
|
|
55
79
|
});
|
|
56
80
|
return newsroom;
|
|
57
81
|
}
|
|
58
|
-
async function update(id, payload) {
|
|
82
|
+
async function update(id, payload, options) {
|
|
83
|
+
const {
|
|
84
|
+
include
|
|
85
|
+
} = options ?? {};
|
|
59
86
|
const {
|
|
60
87
|
newsroom
|
|
61
88
|
} = await api.patch(`${_routing.routing.newsroomsUrl}/${id}`, {
|
|
62
|
-
payload
|
|
89
|
+
payload,
|
|
90
|
+
query: {
|
|
91
|
+
include: include?.join(',')
|
|
92
|
+
}
|
|
63
93
|
});
|
|
64
94
|
return newsroom;
|
|
65
95
|
}
|
|
66
|
-
async function archive(id) {
|
|
96
|
+
async function archive(id, options) {
|
|
97
|
+
const {
|
|
98
|
+
include
|
|
99
|
+
} = options ?? {};
|
|
67
100
|
const {
|
|
68
101
|
newsroom
|
|
69
|
-
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/archive
|
|
102
|
+
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/archive`, {
|
|
103
|
+
query: {
|
|
104
|
+
include: include?.join(',')
|
|
105
|
+
}
|
|
106
|
+
});
|
|
70
107
|
return newsroom;
|
|
71
108
|
}
|
|
72
|
-
async function unarchive(id) {
|
|
109
|
+
async function unarchive(id, options) {
|
|
110
|
+
const {
|
|
111
|
+
include
|
|
112
|
+
} = options ?? {};
|
|
73
113
|
const {
|
|
74
114
|
newsroom
|
|
75
|
-
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/unarchive
|
|
115
|
+
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/unarchive`, {
|
|
116
|
+
query: {
|
|
117
|
+
include: include?.join(',')
|
|
118
|
+
}
|
|
119
|
+
});
|
|
76
120
|
return newsroom;
|
|
77
121
|
}
|
|
78
|
-
async function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
122
|
+
async function takeOffline(id, options) {
|
|
123
|
+
const {
|
|
124
|
+
include
|
|
125
|
+
} = options ?? {};
|
|
82
126
|
const {
|
|
83
127
|
newsroom
|
|
84
|
-
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/offline
|
|
128
|
+
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/offline`, {
|
|
129
|
+
query: {
|
|
130
|
+
include: include?.join(',')
|
|
131
|
+
}
|
|
132
|
+
});
|
|
85
133
|
return newsroom;
|
|
86
134
|
}
|
|
87
|
-
async function takeOnline(id) {
|
|
135
|
+
async function takeOnline(id, options) {
|
|
136
|
+
const {
|
|
137
|
+
include
|
|
138
|
+
} = options ?? {};
|
|
88
139
|
const {
|
|
89
140
|
newsroom
|
|
90
|
-
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/online
|
|
141
|
+
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/online`, {
|
|
142
|
+
query: {
|
|
143
|
+
include: include?.join(',')
|
|
144
|
+
}
|
|
145
|
+
});
|
|
91
146
|
return newsroom;
|
|
92
147
|
}
|
|
93
|
-
async function convertToHub(id) {
|
|
148
|
+
async function convertToHub(id, options) {
|
|
149
|
+
const {
|
|
150
|
+
include
|
|
151
|
+
} = options ?? {};
|
|
94
152
|
const {
|
|
95
153
|
newsroom
|
|
96
|
-
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/convert
|
|
154
|
+
} = await api.post(`${_routing.routing.newsroomsUrl}/${id}/convert`, {
|
|
155
|
+
query: {
|
|
156
|
+
include: include?.join(',')
|
|
157
|
+
}
|
|
158
|
+
});
|
|
97
159
|
return newsroom;
|
|
98
160
|
}
|
|
161
|
+
async function deleteNewsroom(id) {
|
|
162
|
+
return api.delete(`${_routing.routing.newsroomsUrl}/${id}`);
|
|
163
|
+
}
|
|
99
164
|
return {
|
|
100
165
|
list,
|
|
101
166
|
search,
|
|
@@ -104,7 +169,7 @@ function createClient(api) {
|
|
|
104
169
|
update,
|
|
105
170
|
archive,
|
|
106
171
|
unarchive,
|
|
107
|
-
delete:
|
|
172
|
+
delete: deleteNewsroom,
|
|
108
173
|
takeOnline,
|
|
109
174
|
takeOffline,
|
|
110
175
|
convertToHub
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import type { DeferredJobsApiClient } from '../../api';
|
|
2
2
|
import type { Newsroom } from '../../types';
|
|
3
|
-
import type { CreateRequest, ListOptions, ListResponse, SearchOptions, UpdateRequest } from './types';
|
|
4
|
-
|
|
3
|
+
import type { CreateRequest, IncludeOptions, ListOptions, ListResponse, SearchOptions, UpdateRequest } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Utility type to forbid arbitrary ad-hoc extensions of generic parameters.
|
|
6
|
+
* @see https://stackoverflow.com/a/69666350
|
|
7
|
+
*/
|
|
8
|
+
type Exactly<Concrete, Abstract> = Concrete & Record<Exclude<keyof Concrete, keyof Abstract>, never>;
|
|
9
|
+
type InferExtraFields<T> = T extends Required<IncludeOptions<infer I>> ? Pick<Newsroom.ExtraFields, I> : unknown;
|
|
5
10
|
export type Client = ReturnType<typeof createClient>;
|
|
6
11
|
export declare function createClient(api: DeferredJobsApiClient): {
|
|
7
|
-
list: (
|
|
8
|
-
search: (options?: SearchOptions) => Promise<ListResponse
|
|
9
|
-
get: (id:
|
|
10
|
-
create: (payload: CreateRequest) => Promise<Newsroom
|
|
11
|
-
update: (id:
|
|
12
|
-
archive: (id:
|
|
13
|
-
unarchive: (id:
|
|
14
|
-
delete: (id:
|
|
15
|
-
takeOnline: (id:
|
|
16
|
-
takeOffline: (id:
|
|
17
|
-
convertToHub: (id:
|
|
12
|
+
list: <Options extends ListOptions<keyof Newsroom.ExtraFields>>(options?: Exactly<Options, ListOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<ListResponse<Newsroom & InferExtraFields<Options>>>;
|
|
13
|
+
search: <Options_1 extends SearchOptions<keyof Newsroom.ExtraFields>>(options?: Exactly<Options_1, SearchOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<ListResponse<Newsroom & InferExtraFields<Options_1>>>;
|
|
14
|
+
get: <Options_2 extends IncludeOptions<keyof Newsroom.ExtraFields>>(id: Newsroom['uuid'] | Newsroom['id'], options?: Exactly<Options_2, IncludeOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<Newsroom & InferExtraFields<Options_2>>;
|
|
15
|
+
create: <Options_3 extends IncludeOptions<keyof Newsroom.ExtraFields>>(payload: CreateRequest, options?: Exactly<Options_3, IncludeOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<Newsroom & InferExtraFields<Options_3>>;
|
|
16
|
+
update: <Options_4 extends IncludeOptions<keyof Newsroom.ExtraFields>>(id: Newsroom['uuid'] | Newsroom['id'], payload: UpdateRequest, options?: Exactly<Options_4, IncludeOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<Newsroom & InferExtraFields<Options_4>>;
|
|
17
|
+
archive: <Options_5 extends IncludeOptions<keyof Newsroom.ExtraFields>>(id: Newsroom['uuid'] | Newsroom['id'], options?: Exactly<Options_5, IncludeOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<Newsroom & InferExtraFields<Options_5>>;
|
|
18
|
+
unarchive: <Options_6 extends IncludeOptions<keyof Newsroom.ExtraFields>>(id: Newsroom['uuid'] | Newsroom['id'], options?: Exactly<Options_6, IncludeOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<Newsroom & InferExtraFields<Options_6>>;
|
|
19
|
+
delete: (id: Newsroom['uuid'] | Newsroom['id']) => Promise<void>;
|
|
20
|
+
takeOnline: <Options_7 extends IncludeOptions<keyof Newsroom.ExtraFields>>(id: Newsroom['uuid'] | Newsroom['id'], options?: Exactly<Options_7, IncludeOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<Newsroom & InferExtraFields<Options_7>>;
|
|
21
|
+
takeOffline: <Options_8 extends IncludeOptions<keyof Newsroom.ExtraFields>>(id: Newsroom['uuid'] | Newsroom['id'], options?: Exactly<Options_8, IncludeOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<Newsroom & InferExtraFields<Options_8>>;
|
|
22
|
+
convertToHub: <Options_9 extends IncludeOptions<keyof Newsroom.ExtraFields>>(id: Newsroom['uuid'] | Newsroom['id'], options?: Exactly<Options_9, IncludeOptions<keyof Newsroom.ExtraFields>> | undefined) => Promise<Newsroom & InferExtraFields<Options_9>>;
|
|
18
23
|
};
|
|
19
24
|
export {};
|
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
import { routing } from "../../routing.js";
|
|
2
2
|
import { Query, SortOrder } from "../../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Utility type to forbid arbitrary ad-hoc extensions of generic parameters.
|
|
5
|
+
* @see https://stackoverflow.com/a/69666350
|
|
6
|
+
*/
|
|
3
7
|
export function createClient(api) {
|
|
4
|
-
async function list({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
async function list(options) {
|
|
9
|
+
const {
|
|
10
|
+
search,
|
|
11
|
+
limit,
|
|
12
|
+
offset,
|
|
13
|
+
sortOrder,
|
|
14
|
+
include
|
|
15
|
+
} = options ?? {};
|
|
10
16
|
return api.get(routing.newsroomsUrl, {
|
|
11
17
|
query: {
|
|
12
18
|
limit,
|
|
13
19
|
offset,
|
|
14
20
|
search,
|
|
15
|
-
sort: SortOrder.stringify(sortOrder)
|
|
21
|
+
sort: SortOrder.stringify(sortOrder),
|
|
22
|
+
include: include?.join(',')
|
|
16
23
|
}
|
|
17
24
|
});
|
|
18
25
|
}
|
|
19
|
-
async function search(options
|
|
26
|
+
async function search(options) {
|
|
20
27
|
const {
|
|
21
28
|
query,
|
|
29
|
+
search,
|
|
22
30
|
limit,
|
|
23
31
|
offset,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} = options;
|
|
32
|
+
sortOrder,
|
|
33
|
+
include
|
|
34
|
+
} = options ?? {};
|
|
35
|
+
|
|
27
36
|
// TODO: Introduce dedicated Search POST API
|
|
28
37
|
return api.get(routing.newsroomsUrl, {
|
|
29
38
|
query: {
|
|
@@ -31,65 +40,120 @@ export function createClient(api) {
|
|
|
31
40
|
limit,
|
|
32
41
|
offset,
|
|
33
42
|
search,
|
|
34
|
-
sort: SortOrder.stringify(sortOrder)
|
|
43
|
+
sort: SortOrder.stringify(sortOrder),
|
|
44
|
+
include: include?.join(',')
|
|
35
45
|
}
|
|
36
46
|
});
|
|
37
47
|
}
|
|
38
|
-
async function get(id) {
|
|
48
|
+
async function get(id, options) {
|
|
49
|
+
const {
|
|
50
|
+
include
|
|
51
|
+
} = options ?? {};
|
|
39
52
|
const {
|
|
40
53
|
newsroom
|
|
41
|
-
} = await api.get(`${routing.newsroomsUrl}/${id}
|
|
54
|
+
} = await api.get(`${routing.newsroomsUrl}/${id}`, {
|
|
55
|
+
query: {
|
|
56
|
+
include: include?.join(',')
|
|
57
|
+
}
|
|
58
|
+
});
|
|
42
59
|
return newsroom;
|
|
43
60
|
}
|
|
44
|
-
async function create(payload) {
|
|
61
|
+
async function create(payload, options) {
|
|
62
|
+
const {
|
|
63
|
+
include
|
|
64
|
+
} = options ?? {};
|
|
45
65
|
const {
|
|
46
66
|
newsroom
|
|
47
67
|
} = await api.post(routing.newsroomsUrl, {
|
|
48
|
-
payload
|
|
68
|
+
payload,
|
|
69
|
+
query: {
|
|
70
|
+
include: include?.join(',')
|
|
71
|
+
}
|
|
49
72
|
});
|
|
50
73
|
return newsroom;
|
|
51
74
|
}
|
|
52
|
-
async function update(id, payload) {
|
|
75
|
+
async function update(id, payload, options) {
|
|
76
|
+
const {
|
|
77
|
+
include
|
|
78
|
+
} = options ?? {};
|
|
53
79
|
const {
|
|
54
80
|
newsroom
|
|
55
81
|
} = await api.patch(`${routing.newsroomsUrl}/${id}`, {
|
|
56
|
-
payload
|
|
82
|
+
payload,
|
|
83
|
+
query: {
|
|
84
|
+
include: include?.join(',')
|
|
85
|
+
}
|
|
57
86
|
});
|
|
58
87
|
return newsroom;
|
|
59
88
|
}
|
|
60
|
-
async function archive(id) {
|
|
89
|
+
async function archive(id, options) {
|
|
90
|
+
const {
|
|
91
|
+
include
|
|
92
|
+
} = options ?? {};
|
|
61
93
|
const {
|
|
62
94
|
newsroom
|
|
63
|
-
} = await api.post(`${routing.newsroomsUrl}/${id}/archive
|
|
95
|
+
} = await api.post(`${routing.newsroomsUrl}/${id}/archive`, {
|
|
96
|
+
query: {
|
|
97
|
+
include: include?.join(',')
|
|
98
|
+
}
|
|
99
|
+
});
|
|
64
100
|
return newsroom;
|
|
65
101
|
}
|
|
66
|
-
async function unarchive(id) {
|
|
102
|
+
async function unarchive(id, options) {
|
|
103
|
+
const {
|
|
104
|
+
include
|
|
105
|
+
} = options ?? {};
|
|
67
106
|
const {
|
|
68
107
|
newsroom
|
|
69
|
-
} = await api.post(`${routing.newsroomsUrl}/${id}/unarchive
|
|
108
|
+
} = await api.post(`${routing.newsroomsUrl}/${id}/unarchive`, {
|
|
109
|
+
query: {
|
|
110
|
+
include: include?.join(',')
|
|
111
|
+
}
|
|
112
|
+
});
|
|
70
113
|
return newsroom;
|
|
71
114
|
}
|
|
72
|
-
async function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
115
|
+
async function takeOffline(id, options) {
|
|
116
|
+
const {
|
|
117
|
+
include
|
|
118
|
+
} = options ?? {};
|
|
76
119
|
const {
|
|
77
120
|
newsroom
|
|
78
|
-
} = await api.post(`${routing.newsroomsUrl}/${id}/offline
|
|
121
|
+
} = await api.post(`${routing.newsroomsUrl}/${id}/offline`, {
|
|
122
|
+
query: {
|
|
123
|
+
include: include?.join(',')
|
|
124
|
+
}
|
|
125
|
+
});
|
|
79
126
|
return newsroom;
|
|
80
127
|
}
|
|
81
|
-
async function takeOnline(id) {
|
|
128
|
+
async function takeOnline(id, options) {
|
|
129
|
+
const {
|
|
130
|
+
include
|
|
131
|
+
} = options ?? {};
|
|
82
132
|
const {
|
|
83
133
|
newsroom
|
|
84
|
-
} = await api.post(`${routing.newsroomsUrl}/${id}/online
|
|
134
|
+
} = await api.post(`${routing.newsroomsUrl}/${id}/online`, {
|
|
135
|
+
query: {
|
|
136
|
+
include: include?.join(',')
|
|
137
|
+
}
|
|
138
|
+
});
|
|
85
139
|
return newsroom;
|
|
86
140
|
}
|
|
87
|
-
async function convertToHub(id) {
|
|
141
|
+
async function convertToHub(id, options) {
|
|
142
|
+
const {
|
|
143
|
+
include
|
|
144
|
+
} = options ?? {};
|
|
88
145
|
const {
|
|
89
146
|
newsroom
|
|
90
|
-
} = await api.post(`${routing.newsroomsUrl}/${id}/convert
|
|
147
|
+
} = await api.post(`${routing.newsroomsUrl}/${id}/convert`, {
|
|
148
|
+
query: {
|
|
149
|
+
include: include?.join(',')
|
|
150
|
+
}
|
|
151
|
+
});
|
|
91
152
|
return newsroom;
|
|
92
153
|
}
|
|
154
|
+
async function deleteNewsroom(id) {
|
|
155
|
+
return api.delete(`${routing.newsroomsUrl}/${id}`);
|
|
156
|
+
}
|
|
93
157
|
return {
|
|
94
158
|
list,
|
|
95
159
|
search,
|
|
@@ -98,7 +162,7 @@ export function createClient(api) {
|
|
|
98
162
|
update,
|
|
99
163
|
archive,
|
|
100
164
|
unarchive,
|
|
101
|
-
delete:
|
|
165
|
+
delete: deleteNewsroom,
|
|
102
166
|
takeOnline,
|
|
103
167
|
takeOffline,
|
|
104
168
|
convertToHub
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { UploadedImage } from '@prezly/uploads';
|
|
2
2
|
import type { CultureRef, Newsroom, Pagination, Query, SortOrder } from '../../types';
|
|
3
|
-
export interface
|
|
3
|
+
export interface IncludeOptions<Include extends keyof Newsroom.ExtraFields = keyof Newsroom.ExtraFields> {
|
|
4
|
+
include?: Include[];
|
|
5
|
+
}
|
|
6
|
+
export interface ListOptions<Include extends keyof Newsroom.ExtraFields = keyof Newsroom.ExtraFields> {
|
|
7
|
+
include?: Include[];
|
|
4
8
|
limit?: number;
|
|
5
9
|
offset?: number;
|
|
6
10
|
/**
|
|
@@ -9,14 +13,14 @@ export interface ListOptions {
|
|
|
9
13
|
search?: string;
|
|
10
14
|
sortOrder?: SortOrder | string;
|
|
11
15
|
}
|
|
12
|
-
export interface SearchOptions extends ListOptions {
|
|
16
|
+
export interface SearchOptions<Include extends keyof Newsroom.ExtraFields = keyof Newsroom.ExtraFields> extends ListOptions<Include> {
|
|
13
17
|
/**
|
|
14
18
|
* Filter query using Prezly JSON Query Language
|
|
15
19
|
*/
|
|
16
20
|
query?: Query;
|
|
17
21
|
}
|
|
18
|
-
export interface ListResponse {
|
|
19
|
-
newsrooms:
|
|
22
|
+
export interface ListResponse<T extends Newsroom = Newsroom> {
|
|
23
|
+
newsrooms: T[];
|
|
20
24
|
pagination: Pagination;
|
|
21
25
|
sort: string;
|
|
22
26
|
}
|
|
@@ -34,8 +34,7 @@ const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE = {
|
|
|
34
34
|
content: true,
|
|
35
35
|
attached_gallery_content: true,
|
|
36
36
|
referenced_entities: true
|
|
37
|
-
};
|
|
38
|
-
|
|
37
|
+
};
|
|
39
38
|
const ALL_EXTRA_FIELDS_SHAPE = {
|
|
40
39
|
thumbnail_image: true,
|
|
41
40
|
header_image: true,
|
|
@@ -54,8 +53,8 @@ const ALL_EXTRA_FIELDS_SHAPE = {
|
|
|
54
53
|
attached_contacts_content: true,
|
|
55
54
|
referenced_entities: true,
|
|
56
55
|
'campaigns.count': true,
|
|
57
|
-
'pitches.count': true
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
'pitches.count': true,
|
|
57
|
+
'coverage.count': true
|
|
58
|
+
};
|
|
60
59
|
const ALL_EXTRA_FIELDS = exports.ALL_EXTRA_FIELDS = Object.keys(ALL_EXTRA_FIELDS_SHAPE);
|
|
61
60
|
const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS = exports.EXTENDED_STORY_INCLUDED_EXTRA_FIELDS = Object.keys(EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE);
|
|
@@ -254,6 +254,6 @@ export interface ChangeNewsroomUnsafeResponse {
|
|
|
254
254
|
message: string;
|
|
255
255
|
warnings: ChangeNewsroomWarning[];
|
|
256
256
|
}
|
|
257
|
-
export declare const ALL_EXTRA_FIELDS: (
|
|
257
|
+
export declare const ALL_EXTRA_FIELDS: ("content" | "preview_image" | "thumbnail_image" | "header_image" | "social_image" | "social_text" | "tag_names" | "attached_gallery_content" | "referenced_entities" | "autosaved_content" | "content_version" | "last_modifying_user" | "attached_videos_content" | "attached_bookmarks_content" | "attached_attachments_content" | "attached_contacts_content" | "campaigns.count" | "pitches.count" | "coverage.count")[];
|
|
258
258
|
export declare const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS: ("content" | "preview_image" | "thumbnail_image" | "header_image" | "social_image" | "social_text" | "tag_names" | "attached_gallery_content" | "referenced_entities")[];
|
|
259
259
|
export {};
|
|
@@ -24,8 +24,7 @@ const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE = {
|
|
|
24
24
|
content: true,
|
|
25
25
|
attached_gallery_content: true,
|
|
26
26
|
referenced_entities: true
|
|
27
|
-
};
|
|
28
|
-
|
|
27
|
+
};
|
|
29
28
|
const ALL_EXTRA_FIELDS_SHAPE = {
|
|
30
29
|
thumbnail_image: true,
|
|
31
30
|
header_image: true,
|
|
@@ -44,8 +43,8 @@ const ALL_EXTRA_FIELDS_SHAPE = {
|
|
|
44
43
|
attached_contacts_content: true,
|
|
45
44
|
referenced_entities: true,
|
|
46
45
|
'campaigns.count': true,
|
|
47
|
-
'pitches.count': true
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
'pitches.count': true,
|
|
47
|
+
'coverage.count': true
|
|
48
|
+
};
|
|
50
49
|
export const ALL_EXTRA_FIELDS = Object.keys(ALL_EXTRA_FIELDS_SHAPE);
|
|
51
50
|
export const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS = Object.keys(EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE);
|
package/dist/endpoints/index.cjs
CHANGED
|
@@ -64,5 +64,4 @@ var _Templates = _interopRequireWildcard(require("./Templates/index.cjs"));
|
|
|
64
64
|
exports.Templates = _Templates;
|
|
65
65
|
var _NotificationSubscriptions = _interopRequireWildcard(require("./NotificationSubscriptions/index.cjs"));
|
|
66
66
|
exports.NotificationSubscriptions = _NotificationSubscriptions;
|
|
67
|
-
function
|
|
68
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
67
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -72,7 +72,7 @@ async function createRequest(fetchImpl, url, options, onError) {
|
|
|
72
72
|
let responsePayload;
|
|
73
73
|
try {
|
|
74
74
|
responsePayload = await response.json();
|
|
75
|
-
} catch
|
|
75
|
+
} catch {
|
|
76
76
|
responsePayload = createFakeErrorPayload(response);
|
|
77
77
|
}
|
|
78
78
|
const error = new _ApiError.ApiError({
|
|
@@ -65,7 +65,7 @@ export async function createRequest(fetchImpl, url, options, onError) {
|
|
|
65
65
|
let responsePayload;
|
|
66
66
|
try {
|
|
67
67
|
responsePayload = await response.json();
|
|
68
|
-
} catch
|
|
68
|
+
} catch {
|
|
69
69
|
responsePayload = createFakeErrorPayload(response);
|
|
70
70
|
}
|
|
71
71
|
const error = new ApiError({
|
package/dist/http/lib.cjs
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createUrlWithQuery = createUrlWithQuery;
|
|
7
7
|
exports.isDeferredJobResponse = isDeferredJobResponse;
|
|
8
8
|
var _queryString = _interopRequireDefault(require("query-string"));
|
|
9
|
-
function _interopRequireDefault(
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
function parseUrlParams(query) {
|
|
11
11
|
return _queryString.default.parse(query, {
|
|
12
12
|
arrayFormat: 'bracket'
|
package/dist/types/Category.cjs
CHANGED
|
@@ -37,7 +37,7 @@ let Category = exports.Category = void 0;
|
|
|
37
37
|
_Category.translations = translations;
|
|
38
38
|
})(Category || (exports.Category = Category = {}));
|
|
39
39
|
function isNonEmpty(translation) {
|
|
40
|
-
return Boolean(translation
|
|
40
|
+
return Boolean(translation?.name && translation.slug);
|
|
41
41
|
}
|
|
42
42
|
function localeCode(locale) {
|
|
43
43
|
return typeof locale === 'string' ? locale : locale.code;
|
package/dist/types/Category.js
CHANGED
|
@@ -31,7 +31,7 @@ export let Category;
|
|
|
31
31
|
_Category.translations = translations;
|
|
32
32
|
})(Category || (Category = {}));
|
|
33
33
|
function isNonEmpty(translation) {
|
|
34
|
-
return Boolean(translation
|
|
34
|
+
return Boolean(translation?.name && translation.slug);
|
|
35
35
|
}
|
|
36
36
|
function localeCode(locale) {
|
|
37
37
|
return typeof locale === 'string' ? locale : locale.code;
|
package/dist/types/Newsroom.cjs
CHANGED
|
@@ -8,7 +8,9 @@ let Newsroom = exports.Newsroom = void 0;
|
|
|
8
8
|
(function (_Newsroom) {
|
|
9
9
|
let Status = /*#__PURE__*/function (Status) {
|
|
10
10
|
Status["ACTIVE"] = "active";
|
|
11
|
+
// i.e. "Live"
|
|
11
12
|
Status["INACTIVE"] = "inactive";
|
|
13
|
+
// i.e. "Not live"
|
|
12
14
|
Status["ARCHIVED"] = "archived";
|
|
13
15
|
return Status;
|
|
14
16
|
}({});
|
|
@@ -20,8 +22,14 @@ let Newsroom = exports.Newsroom = void 0;
|
|
|
20
22
|
}({});
|
|
21
23
|
_Newsroom.EmailBrandingMode = EmailBrandingMode;
|
|
22
24
|
let TrackingPolicy = /*#__PURE__*/function (TrackingPolicy) {
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Please use `NORMAL` instead.
|
|
27
|
+
*/
|
|
23
28
|
TrackingPolicy["DEFAULT"] = "default";
|
|
24
29
|
TrackingPolicy["DISABLED"] = "disabled";
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Please use `STRICT` instead.
|
|
32
|
+
*/
|
|
25
33
|
TrackingPolicy["CONSENT_TO_IDENTIFY"] = "consent-to-identify";
|
|
26
34
|
TrackingPolicy["STRICT"] = "strict";
|
|
27
35
|
TrackingPolicy["NORMAL"] = "normal";
|
package/dist/types/Newsroom.d.ts
CHANGED
|
@@ -94,20 +94,6 @@ export interface Newsroom extends NewsroomRef {
|
|
|
94
94
|
*/
|
|
95
95
|
custom_privacy_policy_link: string | null;
|
|
96
96
|
custom_data_request_link: string | null;
|
|
97
|
-
policies: {
|
|
98
|
-
privacy_policy: {
|
|
99
|
-
link: string;
|
|
100
|
-
} | {
|
|
101
|
-
content: string;
|
|
102
|
-
origin: 'default' | 'custom';
|
|
103
|
-
};
|
|
104
|
-
cookie_policy: {
|
|
105
|
-
link: string;
|
|
106
|
-
} | {
|
|
107
|
-
content: string;
|
|
108
|
-
origin: 'default' | 'custom';
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
97
|
tracking_policy: Newsroom.TrackingPolicy;
|
|
112
98
|
onetrust_cookie_consent: {
|
|
113
99
|
is_enabled: boolean;
|
|
@@ -183,4 +169,28 @@ export declare namespace Newsroom {
|
|
|
183
169
|
function isInactive(newsroom: Pick<Newsroom, 'status'>): boolean;
|
|
184
170
|
function isArchived(newsroom: Newsroom['status']): boolean;
|
|
185
171
|
function isArchived(newsroom: Pick<Newsroom, 'status'>): boolean;
|
|
172
|
+
interface ExtraFields {
|
|
173
|
+
policies: {
|
|
174
|
+
privacy_policy: {
|
|
175
|
+
link: string;
|
|
176
|
+
} | {
|
|
177
|
+
content: string;
|
|
178
|
+
origin: 'default' | 'custom';
|
|
179
|
+
};
|
|
180
|
+
cookie_policy: {
|
|
181
|
+
link: string;
|
|
182
|
+
} | {
|
|
183
|
+
content: string;
|
|
184
|
+
origin: 'default' | 'custom';
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
draft_stories_number: number;
|
|
188
|
+
published_stories_number: number;
|
|
189
|
+
draft_campaigns_number: number;
|
|
190
|
+
scheduled_campaigns_number: number;
|
|
191
|
+
sent_campaigns_number: number;
|
|
192
|
+
draft_pitches_number: number;
|
|
193
|
+
sent_pitches_number: number;
|
|
194
|
+
online_coverage_number: number;
|
|
195
|
+
}
|
|
186
196
|
}
|
package/dist/types/Newsroom.js
CHANGED
|
@@ -2,7 +2,9 @@ export let Newsroom;
|
|
|
2
2
|
(function (_Newsroom) {
|
|
3
3
|
let Status = /*#__PURE__*/function (Status) {
|
|
4
4
|
Status["ACTIVE"] = "active";
|
|
5
|
+
// i.e. "Live"
|
|
5
6
|
Status["INACTIVE"] = "inactive";
|
|
7
|
+
// i.e. "Not live"
|
|
6
8
|
Status["ARCHIVED"] = "archived";
|
|
7
9
|
return Status;
|
|
8
10
|
}({});
|
|
@@ -14,8 +16,14 @@ export let Newsroom;
|
|
|
14
16
|
}({});
|
|
15
17
|
_Newsroom.EmailBrandingMode = EmailBrandingMode;
|
|
16
18
|
let TrackingPolicy = /*#__PURE__*/function (TrackingPolicy) {
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Please use `NORMAL` instead.
|
|
21
|
+
*/
|
|
17
22
|
TrackingPolicy["DEFAULT"] = "default";
|
|
18
23
|
TrackingPolicy["DISABLED"] = "disabled";
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Please use `STRICT` instead.
|
|
26
|
+
*/
|
|
19
27
|
TrackingPolicy["CONSENT_TO_IDENTIFY"] = "consent-to-identify";
|
|
20
28
|
TrackingPolicy["STRICT"] = "strict";
|
|
21
29
|
TrackingPolicy["NORMAL"] = "normal";
|
|
@@ -27,10 +27,12 @@ let NewsroomTheme = exports.NewsroomTheme = void 0;
|
|
|
27
27
|
Feature["TITLE_FORMATTING"] = "title_formatting";
|
|
28
28
|
Feature["CTA_BUTTONS"] = "cta_buttons";
|
|
29
29
|
Feature["VIDEO_LAYOUT"] = "video_layout";
|
|
30
|
+
// DEV-7588
|
|
30
31
|
Feature["EMBED_LAYOUT"] = "embed_layout";
|
|
31
|
-
|
|
32
|
+
// DEV-11475
|
|
33
|
+
Feature["STRICT_TRACKING_POLICY"] = "strict_tracking_policy"; // DEV-19123
|
|
32
34
|
return Feature;
|
|
33
|
-
}({});
|
|
35
|
+
}({});
|
|
34
36
|
_NewsroomTheme.Feature = Feature;
|
|
35
37
|
function isFeatureSupported(theme, feature) {
|
|
36
38
|
return theme.features.includes(feature);
|
|
@@ -21,10 +21,12 @@ export let NewsroomTheme;
|
|
|
21
21
|
Feature["TITLE_FORMATTING"] = "title_formatting";
|
|
22
22
|
Feature["CTA_BUTTONS"] = "cta_buttons";
|
|
23
23
|
Feature["VIDEO_LAYOUT"] = "video_layout";
|
|
24
|
+
// DEV-7588
|
|
24
25
|
Feature["EMBED_LAYOUT"] = "embed_layout";
|
|
25
|
-
|
|
26
|
+
// DEV-11475
|
|
27
|
+
Feature["STRICT_TRACKING_POLICY"] = "strict_tracking_policy"; // DEV-19123
|
|
26
28
|
return Feature;
|
|
27
|
-
}({});
|
|
29
|
+
}({});
|
|
28
30
|
_NewsroomTheme.Feature = Feature;
|
|
29
31
|
function isFeatureSupported(theme, feature) {
|
|
30
32
|
return theme.features.includes(feature);
|
package/dist/types/Story.d.ts
CHANGED
|
@@ -262,6 +262,10 @@ export declare namespace Story {
|
|
|
262
262
|
* Number of pitches linked to this story.
|
|
263
263
|
*/
|
|
264
264
|
'pitches.count': number;
|
|
265
|
+
/**
|
|
266
|
+
* Number of coverage entries linked to this story.
|
|
267
|
+
*/
|
|
268
|
+
'coverage.count': number;
|
|
265
269
|
}
|
|
266
270
|
function isActiveNewsroom(story: Pick<Story, 'newsroom'>): boolean;
|
|
267
271
|
function isInactiveNewsroom(story: Pick<Story, 'newsroom'>): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.1.0",
|
|
4
4
|
"description": "Prezly API SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -31,22 +31,18 @@
|
|
|
31
31
|
"query-string": "^6.14.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@babel/cli": "^7.
|
|
35
|
-
"@babel/core": "^7.
|
|
34
|
+
"@babel/cli": "^7.28.6",
|
|
35
|
+
"@babel/core": "^7.28.6",
|
|
36
36
|
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
|
37
|
-
"@babel/preset-env": "^7.
|
|
38
|
-
"@babel/preset-typescript": "^7.
|
|
37
|
+
"@babel/preset-env": "^7.28.6",
|
|
38
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
39
|
+
"@biomejs/biome": "^2.2.4",
|
|
40
|
+
"@prezly/biome-config": "^1.0.1",
|
|
39
41
|
"@types/node": "^20.10.4",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
|
41
|
-
"@typescript-eslint/parser": "^6.13.2",
|
|
42
42
|
"babel-plugin-add-import-extension": "^1.6.0",
|
|
43
43
|
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
44
44
|
"cross-env": "^7.0.3",
|
|
45
|
-
"eslint": "^8.56.0",
|
|
46
|
-
"eslint-config-prettier": "^8.10.0",
|
|
47
|
-
"eslint-plugin-import": "^2.29.1",
|
|
48
45
|
"np": "^9.2.0",
|
|
49
|
-
"prettier": "^2.8.8",
|
|
50
46
|
"rimraf": "^3.0.0",
|
|
51
47
|
"typescript": "^5.3.3",
|
|
52
48
|
"vitest": "^1.2.2",
|
|
@@ -61,13 +57,13 @@
|
|
|
61
57
|
"build:cjs": "babel ./src --ignore='**/*.test.ts' --config-file=./babel.config.cjs.json --extensions=.ts,.cts --source-root=./src --out-dir=./dist --out-file-extension .cjs",
|
|
62
58
|
"watch": "tsc --watch --preserveWatchOutput --project .",
|
|
63
59
|
"start": "npm run build --incremental --watch",
|
|
64
|
-
"lint": "
|
|
65
|
-
"lint:fix": "
|
|
60
|
+
"lint": "biome ci",
|
|
61
|
+
"lint:fix": "biome lint --write",
|
|
66
62
|
"test": "npm run test:build && npm run test:unit",
|
|
67
63
|
"test:unit": "vitest run",
|
|
68
64
|
"test:build": "node dist/index.js && tsc --noEmit dist/index.d.ts",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
65
|
+
"format:check": "biome format",
|
|
66
|
+
"format": "biome format --write",
|
|
71
67
|
"prerelease": "npm run build",
|
|
72
68
|
"release": "np"
|
|
73
69
|
},
|