@prezly/sdk 25.8.0 → 26.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/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/Billing/types.cjs +6 -6
- package/dist/endpoints/Billing/types.js +6 -6
- package/dist/endpoints/ContactTagGroups/types.cjs +3 -3
- package/dist/endpoints/ContactTagGroups/types.js +3 -3
- 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/PricingTables/types.cjs +12 -12
- package/dist/endpoints/PricingTables/types.js +12 -12
- package/dist/endpoints/Subscriptions/types.cjs +3 -3
- package/dist/endpoints/Subscriptions/types.js +3 -3
- package/dist/http/createRequest.cjs +1 -1
- package/dist/http/createRequest.js +1 -1
- package/dist/http/types.cjs +6 -6
- package/dist/http/types.js +6 -6
- package/dist/types/BillingCycle.cjs +3 -3
- package/dist/types/BillingCycle.js +3 -3
- package/dist/types/Campaign.cjs +18 -18
- package/dist/types/Campaign.js +18 -18
- package/dist/types/Category.cjs +2 -1
- package/dist/types/Category.js +2 -1
- package/dist/types/Contact.cjs +18 -18
- package/dist/types/Contact.js +18 -18
- package/dist/types/ContactDuplicateSuggestion.cjs +3 -3
- package/dist/types/ContactDuplicateSuggestion.js +4 -3
- package/dist/types/ContactTag.cjs +2 -1
- package/dist/types/ContactTag.js +2 -1
- package/dist/types/ContactsExport.cjs +3 -3
- package/dist/types/ContactsExport.js +3 -3
- package/dist/types/ContactsScope.cjs +3 -3
- package/dist/types/ContactsScope.js +3 -3
- package/dist/types/CoverageEntry.cjs +9 -9
- package/dist/types/CoverageEntry.js +9 -9
- package/dist/types/CoverageIntegration.cjs +3 -3
- package/dist/types/CoverageIntegration.js +3 -3
- package/dist/types/CoverageIntegrationRun.cjs +3 -3
- package/dist/types/CoverageIntegrationRun.js +3 -3
- package/dist/types/Culture.cjs +3 -3
- package/dist/types/Culture.js +3 -3
- package/dist/types/Currency.cjs +3 -3
- package/dist/types/Currency.js +3 -3
- package/dist/types/EmailRecipient.cjs +6 -6
- package/dist/types/EmailRecipient.js +6 -6
- package/dist/types/JobState.cjs +3 -3
- package/dist/types/JobState.js +3 -3
- package/dist/types/License.cjs +12 -12
- package/dist/types/License.js +12 -12
- package/dist/types/Newsroom.cjs +12 -12
- package/dist/types/Newsroom.d.ts +24 -14
- package/dist/types/Newsroom.js +12 -12
- package/dist/types/NewsroomDomain.cjs +6 -6
- package/dist/types/NewsroomDomain.js +6 -6
- package/dist/types/NewsroomGallery.cjs +6 -6
- package/dist/types/NewsroomGallery.js +6 -6
- package/dist/types/NewsroomTheme.cjs +8 -7
- package/dist/types/NewsroomTheme.js +8 -7
- package/dist/types/NewsroomWebhook.cjs +3 -3
- package/dist/types/NewsroomWebhook.js +3 -3
- package/dist/types/NotificationSubscription.cjs +3 -3
- package/dist/types/NotificationSubscription.js +3 -3
- package/dist/types/Permissions.cjs +3 -3
- package/dist/types/Permissions.js +3 -3
- package/dist/types/Plan.cjs +10 -10
- package/dist/types/Plan.js +11 -11
- package/dist/types/Price.cjs +6 -6
- package/dist/types/Price.js +6 -6
- package/dist/types/PrivacyRequest.cjs +6 -6
- package/dist/types/PrivacyRequest.js +6 -6
- package/dist/types/SenderAddress.cjs +3 -3
- package/dist/types/SenderAddress.js +3 -3
- package/dist/types/SenderDomain.cjs +3 -3
- package/dist/types/SenderDomain.js +3 -3
- package/dist/types/SortOrder.cjs +3 -3
- package/dist/types/SortOrder.js +3 -3
- package/dist/types/Story.cjs +12 -12
- package/dist/types/Story.js +12 -12
- package/dist/types/User.cjs +6 -6
- package/dist/types/User.js +6 -6
- package/dist/types/common/Notification.cjs +3 -3
- package/dist/types/common/Notification.js +3 -3
- package/dist/types/common/OEmbedInfo.cjs +3 -3
- package/dist/types/common/OEmbedInfo.js +3 -3
- package/dist/types/common/Pagination.cjs +3 -3
- package/dist/types/common/Pagination.js +3 -3
- package/dist/types/common/Query.js +1 -0
- package/package.json +7 -11
|
@@ -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 = "25.
|
|
7
|
+
const VERSION = "25.8.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
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SignupPlan = exports.SignupCurrency = void 0;
|
|
7
|
-
let SignupPlan = exports.SignupPlan =
|
|
7
|
+
let SignupPlan = exports.SignupPlan = void 0;
|
|
8
|
+
(function (SignupPlan) {
|
|
8
9
|
SignupPlan["ESSENTIAL"] = "essential";
|
|
9
10
|
SignupPlan["STANDARD"] = "standard";
|
|
10
11
|
SignupPlan["AGENCY_ESSENTIAL"] = "agency_essential";
|
|
11
12
|
SignupPlan["AGENCY_STANDARD"] = "agency_standard";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
})(SignupPlan || (exports.SignupPlan = SignupPlan = {}));
|
|
14
|
+
let SignupCurrency = exports.SignupCurrency = void 0;
|
|
15
|
+
(function (SignupCurrency) {
|
|
15
16
|
SignupCurrency["EUR"] = "eur";
|
|
16
17
|
SignupCurrency["USD"] = "usd";
|
|
17
|
-
|
|
18
|
-
}({});
|
|
18
|
+
})(SignupCurrency || (exports.SignupCurrency = SignupCurrency = {}));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export let SignupPlan
|
|
1
|
+
export let SignupPlan;
|
|
2
|
+
(function (SignupPlan) {
|
|
2
3
|
SignupPlan["ESSENTIAL"] = "essential";
|
|
3
4
|
SignupPlan["STANDARD"] = "standard";
|
|
4
5
|
SignupPlan["AGENCY_ESSENTIAL"] = "agency_essential";
|
|
5
6
|
SignupPlan["AGENCY_STANDARD"] = "agency_standard";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
})(SignupPlan || (SignupPlan = {}));
|
|
8
|
+
export let SignupCurrency;
|
|
9
|
+
(function (SignupCurrency) {
|
|
9
10
|
SignupCurrency["EUR"] = "eur";
|
|
10
11
|
SignupCurrency["USD"] = "usd";
|
|
11
|
-
|
|
12
|
-
}({});
|
|
12
|
+
})(SignupCurrency || (SignupCurrency = {}));
|
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Color = void 0;
|
|
7
|
-
let Color = exports.Color =
|
|
7
|
+
let Color = exports.Color = void 0;
|
|
8
|
+
(function (Color) {
|
|
8
9
|
Color["RED"] = "red";
|
|
9
10
|
Color["PINK"] = "pink";
|
|
10
11
|
Color["ORANGE"] = "orange";
|
|
@@ -15,5 +16,4 @@ let Color = exports.Color = /*#__PURE__*/function (Color) {
|
|
|
15
16
|
Color["BLUE"] = "blue";
|
|
16
17
|
Color["INDIGO"] = "indigo";
|
|
17
18
|
Color["PURPLE"] = "purple";
|
|
18
|
-
|
|
19
|
-
}({});
|
|
19
|
+
})(Color || (exports.Color = Color = {}));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export let Color
|
|
1
|
+
export let Color;
|
|
2
|
+
(function (Color) {
|
|
2
3
|
Color["RED"] = "red";
|
|
3
4
|
Color["PINK"] = "pink";
|
|
4
5
|
Color["ORANGE"] = "orange";
|
|
@@ -9,5 +10,4 @@ export let Color = /*#__PURE__*/function (Color) {
|
|
|
9
10
|
Color["BLUE"] = "blue";
|
|
10
11
|
Color["INDIGO"] = "indigo";
|
|
11
12
|
Color["PURPLE"] = "purple";
|
|
12
|
-
|
|
13
|
-
}({});
|
|
13
|
+
})(Color || (Color = {}));
|
|
@@ -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
|
}
|
|
@@ -4,12 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TableId = exports.OptionId = exports.LimitId = exports.AddOnId = void 0;
|
|
7
|
-
let TableId = exports.TableId =
|
|
7
|
+
let TableId = exports.TableId = void 0;
|
|
8
|
+
(function (TableId) {
|
|
8
9
|
TableId["STANDARD"] = "standard";
|
|
9
10
|
TableId["AGENCY"] = "agency";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
})(TableId || (exports.TableId = TableId = {}));
|
|
12
|
+
let OptionId = exports.OptionId = void 0;
|
|
13
|
+
(function (OptionId) {
|
|
13
14
|
OptionId["STARTER"] = "starter";
|
|
14
15
|
OptionId["CORE"] = "core";
|
|
15
16
|
OptionId["PREMIUM"] = "premium";
|
|
@@ -18,18 +19,17 @@ let OptionId = exports.OptionId = /*#__PURE__*/function (OptionId) {
|
|
|
18
19
|
OptionId["AGENCY_MEDIUM"] = "agency_medium";
|
|
19
20
|
OptionId["AGENCY_LARGE"] = "agency_large";
|
|
20
21
|
OptionId["AGENCY_HUGE"] = "agency_huge";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
})(OptionId || (exports.OptionId = OptionId = {}));
|
|
23
|
+
let LimitId = exports.LimitId = void 0;
|
|
24
|
+
(function (LimitId) {
|
|
24
25
|
LimitId["STORIES"] = "stories";
|
|
25
26
|
LimitId["USERS"] = "users";
|
|
26
27
|
LimitId["SITES"] = "sites";
|
|
27
28
|
LimitId["CONTACTS"] = "contacts";
|
|
28
29
|
LimitId["EMAIL_SENDS"] = "email_sends";
|
|
29
30
|
LimitId["CUSTOM_SENDER_ADDRESSES"] = "custom_sender_addresses";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
})(LimitId || (exports.LimitId = LimitId = {}));
|
|
32
|
+
let AddOnId = exports.AddOnId = void 0;
|
|
33
|
+
(function (AddOnId) {
|
|
33
34
|
AddOnId["SITE"] = "site";
|
|
34
|
-
|
|
35
|
-
}({});
|
|
35
|
+
})(AddOnId || (exports.AddOnId = AddOnId = {}));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export let TableId
|
|
1
|
+
export let TableId;
|
|
2
|
+
(function (TableId) {
|
|
2
3
|
TableId["STANDARD"] = "standard";
|
|
3
4
|
TableId["AGENCY"] = "agency";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
})(TableId || (TableId = {}));
|
|
6
|
+
export let OptionId;
|
|
7
|
+
(function (OptionId) {
|
|
7
8
|
OptionId["STARTER"] = "starter";
|
|
8
9
|
OptionId["CORE"] = "core";
|
|
9
10
|
OptionId["PREMIUM"] = "premium";
|
|
@@ -12,18 +13,17 @@ export let OptionId = /*#__PURE__*/function (OptionId) {
|
|
|
12
13
|
OptionId["AGENCY_MEDIUM"] = "agency_medium";
|
|
13
14
|
OptionId["AGENCY_LARGE"] = "agency_large";
|
|
14
15
|
OptionId["AGENCY_HUGE"] = "agency_huge";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
})(OptionId || (OptionId = {}));
|
|
17
|
+
export let LimitId;
|
|
18
|
+
(function (LimitId) {
|
|
18
19
|
LimitId["STORIES"] = "stories";
|
|
19
20
|
LimitId["USERS"] = "users";
|
|
20
21
|
LimitId["SITES"] = "sites";
|
|
21
22
|
LimitId["CONTACTS"] = "contacts";
|
|
22
23
|
LimitId["EMAIL_SENDS"] = "email_sends";
|
|
23
24
|
LimitId["CUSTOM_SENDER_ADDRESSES"] = "custom_sender_addresses";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
})(LimitId || (LimitId = {}));
|
|
26
|
+
export let AddOnId;
|
|
27
|
+
(function (AddOnId) {
|
|
27
28
|
AddOnId["SITE"] = "site";
|
|
28
|
-
|
|
29
|
-
}({});
|
|
29
|
+
})(AddOnId || (AddOnId = {}));
|