@prezly/sdk 18.2.2 → 19.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.
Files changed (119) hide show
  1. package/dist/api/DeferredJobsApiClient.cjs +0 -1
  2. package/dist/api/DeferredJobsApiClient.js +0 -1
  3. package/dist/api/constants.cjs +2 -3
  4. package/dist/api/constants.js +1 -1
  5. package/dist/api/types.d.ts +1 -1
  6. package/dist/endpoints/Accounts/index.cjs +2 -0
  7. package/dist/endpoints/Billing/index.cjs +2 -0
  8. package/dist/endpoints/Billing/types.cjs +3 -5
  9. package/dist/endpoints/CampaignRecipients/Client.d.ts +3 -3
  10. package/dist/endpoints/CampaignRecipients/index.cjs +2 -0
  11. package/dist/endpoints/Campaigns/index.cjs +2 -0
  12. package/dist/endpoints/Contacts/Client.d.ts +2 -2
  13. package/dist/endpoints/Contacts/index.cjs +2 -0
  14. package/dist/endpoints/Contacts/types.d.ts +3 -3
  15. package/dist/endpoints/ContactsExports/index.cjs +2 -0
  16. package/dist/endpoints/Coverage/Client.d.ts +1 -1
  17. package/dist/endpoints/Coverage/index.cjs +2 -0
  18. package/dist/endpoints/Coverage/types.d.ts +1 -1
  19. package/dist/endpoints/Jobs/index.cjs +2 -0
  20. package/dist/endpoints/Licenses/index.cjs +1 -0
  21. package/dist/endpoints/NewsroomCategories/Client.d.ts +1 -1
  22. package/dist/endpoints/NewsroomCategories/index.cjs +2 -0
  23. package/dist/endpoints/NewsroomContacts/Client.d.ts +2 -2
  24. package/dist/endpoints/NewsroomContacts/index.cjs +2 -0
  25. package/dist/endpoints/NewsroomContacts/types.d.ts +1 -1
  26. package/dist/endpoints/NewsroomDomains/Client.d.ts +1 -1
  27. package/dist/endpoints/NewsroomDomains/index.cjs +2 -0
  28. package/dist/endpoints/NewsroomGalleries/Client.d.ts +2 -2
  29. package/dist/endpoints/NewsroomGalleries/index.cjs +2 -0
  30. package/dist/endpoints/NewsroomHub/Client.d.ts +1 -1
  31. package/dist/endpoints/NewsroomHub/index.cjs +2 -0
  32. package/dist/endpoints/NewsroomHub/types.d.ts +1 -1
  33. package/dist/endpoints/NewsroomLanguages/Client.d.ts +1 -1
  34. package/dist/endpoints/NewsroomLanguages/index.cjs +2 -0
  35. package/dist/endpoints/NewsroomPrivacyRequests/index.cjs +2 -0
  36. package/dist/endpoints/NewsroomSubscriptions/Client.d.ts +1 -1
  37. package/dist/endpoints/NewsroomSubscriptions/index.cjs +2 -0
  38. package/dist/endpoints/NewsroomThemes/Client.d.ts +2 -2
  39. package/dist/endpoints/NewsroomThemes/index.cjs +1 -0
  40. package/dist/endpoints/NewsroomWebhooks/Client.d.ts +1 -1
  41. package/dist/endpoints/NewsroomWebhooks/index.cjs +2 -0
  42. package/dist/endpoints/Newsrooms/Client.d.ts +1 -1
  43. package/dist/endpoints/Newsrooms/index.cjs +2 -0
  44. package/dist/endpoints/NotificationSubscriptions/index.cjs +2 -0
  45. package/dist/endpoints/PricingTables/index.cjs +2 -0
  46. package/dist/endpoints/PricingTables/types.cjs +5 -9
  47. package/dist/endpoints/SenderAddresses/index.cjs +2 -0
  48. package/dist/endpoints/Snippets/Client.d.ts +1 -1
  49. package/dist/endpoints/Snippets/index.cjs +2 -0
  50. package/dist/endpoints/Stories/Client.cjs +69 -20
  51. package/dist/endpoints/Stories/Client.d.ts +20 -9
  52. package/dist/endpoints/Stories/Client.js +68 -23
  53. package/dist/endpoints/Stories/index.cjs +3 -0
  54. package/dist/endpoints/Stories/scopes.cjs +2 -3
  55. package/dist/endpoints/Stories/types.cjs +14 -4
  56. package/dist/endpoints/Stories/types.d.ts +28 -9
  57. package/dist/endpoints/Stories/types.js +13 -3
  58. package/dist/endpoints/Subscriptions/Client.d.ts +1 -1
  59. package/dist/endpoints/Subscriptions/index.cjs +2 -0
  60. package/dist/endpoints/Subscriptions/types.cjs +1 -2
  61. package/dist/endpoints/index.cjs +3 -3
  62. package/dist/http/constants.cjs +3 -6
  63. package/dist/http/index.cjs +8 -8
  64. package/dist/http/lib.cjs +0 -16
  65. package/dist/http/lib.js +0 -14
  66. package/dist/http/types.cjs +2 -4
  67. package/dist/index.cjs +7 -4
  68. package/dist/routing.cjs +2 -3
  69. package/dist/types/BillingCycle.cjs +1 -2
  70. package/dist/types/Campaign.cjs +1 -2
  71. package/dist/types/Category.cjs +1 -2
  72. package/dist/types/Category.d.ts +3 -3
  73. package/dist/types/Contact.cjs +1 -2
  74. package/dist/types/ContactDuplicateSuggestion.cjs +2 -2
  75. package/dist/types/ContactDuplicateSuggestion.d.ts +1 -1
  76. package/dist/types/ContactsExport.cjs +1 -2
  77. package/dist/types/ContactsExport.d.ts +1 -1
  78. package/dist/types/ContactsScope.cjs +1 -2
  79. package/dist/types/ContactsScope.d.ts +1 -1
  80. package/dist/types/CoverageEntry.cjs +1 -2
  81. package/dist/types/Culture.cjs +7 -2
  82. package/dist/types/Culture.d.ts +1 -1
  83. package/dist/types/Culture.js +6 -0
  84. package/dist/types/Currency.cjs +1 -2
  85. package/dist/types/DnsConfigurationInstruction.d.ts +1 -1
  86. package/dist/types/EmailRecipient.cjs +1 -2
  87. package/dist/types/JobState.cjs +1 -2
  88. package/dist/types/JobState.d.ts +1 -1
  89. package/dist/types/License.cjs +1 -2
  90. package/dist/types/Newsroom.cjs +4 -2
  91. package/dist/types/Newsroom.d.ts +2 -2
  92. package/dist/types/Newsroom.js +3 -0
  93. package/dist/types/NewsroomDomain.cjs +1 -2
  94. package/dist/types/NewsroomGallery.cjs +1 -2
  95. package/dist/types/NewsroomTheme.cjs +3 -5
  96. package/dist/types/NewsroomTheme.d.ts +1 -1
  97. package/dist/types/NewsroomTheme.js +1 -1
  98. package/dist/types/NewsroomWebhook.cjs +1 -2
  99. package/dist/types/NotificationSubscription.cjs +1 -2
  100. package/dist/types/Permissions.cjs +1 -2
  101. package/dist/types/Permissions.d.ts +1 -1
  102. package/dist/types/Plan.cjs +3 -4
  103. package/dist/types/PrivacyRequest.cjs +1 -2
  104. package/dist/types/SenderAddress.cjs +1 -2
  105. package/dist/types/SenderDomain.cjs +1 -2
  106. package/dist/types/SortOrder.cjs +1 -2
  107. package/dist/types/Story.cjs +17 -6
  108. package/dist/types/Story.d.ts +2 -2
  109. package/dist/types/Story.js +16 -4
  110. package/dist/types/User.cjs +1 -2
  111. package/dist/types/UserAccount.d.ts +1 -1
  112. package/dist/types/common/Notification.cjs +1 -2
  113. package/dist/types/common/OEmbedInfo.cjs +1 -2
  114. package/dist/types/common/Pagination.cjs +2 -2
  115. package/dist/types/common/Query.cjs +1 -2
  116. package/dist/types/common/Query.d.ts +1 -1
  117. package/dist/types/common/index.cjs +6 -0
  118. package/dist/types/index.cjs +36 -0
  119. package/package.json +10 -13
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _Client = require("./Client.cjs");
7
7
  Object.keys(_Client).forEach(function (key) {
8
8
  if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Client[key]) return;
9
10
  Object.defineProperty(exports, key, {
10
11
  enumerable: true,
11
12
  get: function () {
@@ -16,6 +17,7 @@ Object.keys(_Client).forEach(function (key) {
16
17
  var _types = require("./types.cjs");
17
18
  Object.keys(_types).forEach(function (key) {
18
19
  if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _types[key]) return;
19
21
  Object.defineProperty(exports, key, {
20
22
  enumerable: true,
21
23
  get: function () {
@@ -1,7 +1,7 @@
1
1
  import type { DeferredJobsApiClient } from '../../api';
2
2
  import type { Snippet } from '../../types';
3
3
  import type { CreateRequest, UpdateRequest } from './types';
4
- declare type SnippetId = Snippet['uuid'] | Snippet['id'];
4
+ type SnippetId = Snippet['uuid'] | Snippet['id'];
5
5
  export declare class Client {
6
6
  private readonly apiClient;
7
7
  constructor(apiClient: DeferredJobsApiClient);
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _Client = require("./Client.cjs");
7
7
  Object.keys(_Client).forEach(function (key) {
8
8
  if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Client[key]) return;
9
10
  Object.defineProperty(exports, key, {
10
11
  enumerable: true,
11
12
  get: function () {
@@ -16,6 +17,7 @@ Object.keys(_Client).forEach(function (key) {
16
17
  var _types = require("./types.cjs");
17
18
  Object.keys(_types).forEach(function (key) {
18
19
  if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _types[key]) return;
19
21
  Object.defineProperty(exports, key, {
20
22
  enumerable: true,
21
23
  get: function () {
@@ -8,6 +8,15 @@ var _index = require("../../http/index.cjs");
8
8
  var _routing = require("../../routing.cjs");
9
9
  var _index2 = require("../../types/index.cjs");
10
10
  var _types = require("./types.cjs");
11
+ /**
12
+ * `uuid` is the preferred way of targeting a Story. Numeric `id` is considered deprecated.
13
+ */
14
+
15
+ /**
16
+ * Utility type to forbid arbitrary ad-hoc extensions of generic parameters.
17
+ * @see https://stackoverflow.com/a/69666350
18
+ */
19
+
11
20
  class Client {
12
21
  constructor(apiClient) {
13
22
  this.apiClient = apiClient;
@@ -59,6 +68,20 @@ class Client {
59
68
  * Get story by UUID.
60
69
  */
61
70
 
71
+ /**
72
+ * Get multiple stories by UUIDs.
73
+ */
74
+
75
+ /**
76
+ * Get story by deprecated numeric ID, or UUID.
77
+ * @deprecated Please use UUID instead.
78
+ */
79
+
80
+ /**
81
+ * Get multiple stories by numeric IDs.
82
+ * @deprecated Please use UUID instead.
83
+ */
84
+
62
85
  /**
63
86
  * Implementation
64
87
  */
@@ -112,22 +135,46 @@ class Client {
112
135
  });
113
136
  return story;
114
137
  }
115
- async create(payload, options) {
138
+ async getBySlug(slug, options) {
139
+ if (slug.includes('/') || slug.includes('\\')) {
140
+ throw new Error('Story slugs cannot contain slashes.');
141
+ }
116
142
  const {
117
143
  include,
144
+ query,
118
145
  formats
119
146
  } = options ?? {};
120
147
  const {
121
148
  story
122
- } = await this.apiClient.post(_routing.routing.storiesUrl, {
149
+ } = await this.apiClient.post(`${_routing.routing.storiesUrl}/by-slug/${slug}`, {
123
150
  headers: acceptedFormatsHeader(formats),
124
- payload,
125
151
  query: {
126
152
  include
153
+ },
154
+ payload: {
155
+ query
127
156
  }
128
157
  });
129
158
  return story;
130
159
  }
160
+ async create(payload, options) {
161
+ const {
162
+ include,
163
+ formats,
164
+ force = false
165
+ } = options ?? {};
166
+ const {
167
+ story
168
+ } = await this.apiClient.post(_routing.routing.storiesUrl, {
169
+ headers: acceptedFormatsHeader(formats),
170
+ query: {
171
+ include,
172
+ force: force || undefined // only pass it if it's true
173
+ },
174
+ payload
175
+ });
176
+ return story;
177
+ }
131
178
  async duplicate(id, options) {
132
179
  const {
133
180
  include,
@@ -169,8 +216,8 @@ class Client {
169
216
  async move(id, payload, options) {
170
217
  const {
171
218
  include,
172
- force,
173
- formats
219
+ formats,
220
+ force = false
174
221
  } = options ?? {};
175
222
  const url = `${_routing.routing.storiesUrl}/${id}/move`;
176
223
  try {
@@ -179,8 +226,8 @@ class Client {
179
226
  } = await this.apiClient.post(url, {
180
227
  headers: acceptedFormatsHeader(formats),
181
228
  query: {
182
- include: include,
183
- force
229
+ include,
230
+ force: force || undefined // only pass it if it's true
184
231
  },
185
232
  payload
186
233
  });
@@ -199,16 +246,18 @@ class Client {
199
246
  const url = `${_routing.routing.storiesUrl}/${id}`;
200
247
  const {
201
248
  include,
202
- formats
249
+ formats,
250
+ force = false
203
251
  } = options ?? {};
204
252
  const {
205
253
  story
206
254
  } = await this.apiClient.patch(url, {
207
255
  headers: acceptedFormatsHeader(formats),
208
- payload,
209
256
  query: {
210
- include: include
211
- }
257
+ include,
258
+ force: force || undefined // only pass it if it's true
259
+ },
260
+ payload
212
261
  });
213
262
  return story;
214
263
  }
@@ -228,7 +277,7 @@ class Client {
228
277
  headers: acceptedFormatsHeader(formats),
229
278
  payload,
230
279
  query: {
231
- include: include
280
+ include
232
281
  }
233
282
  });
234
283
  return story;
@@ -249,7 +298,7 @@ class Client {
249
298
  headers: acceptedFormatsHeader(formats),
250
299
  payload,
251
300
  query: {
252
- include: include
301
+ include
253
302
  }
254
303
  });
255
304
  return story;
@@ -266,7 +315,7 @@ class Client {
266
315
  headers: acceptedFormatsHeader(formats),
267
316
  payload,
268
317
  query: {
269
- include: include
318
+ include
270
319
  }
271
320
  });
272
321
  return story;
@@ -283,7 +332,7 @@ class Client {
283
332
  headers: acceptedFormatsHeader(formats),
284
333
  payload,
285
334
  query: {
286
- include: include
335
+ include
287
336
  }
288
337
  });
289
338
  return story;
@@ -300,7 +349,7 @@ class Client {
300
349
  headers: acceptedFormatsHeader(formats),
301
350
  payload,
302
351
  query: {
303
- include: include
352
+ include
304
353
  }
305
354
  });
306
355
  return story;
@@ -317,7 +366,7 @@ class Client {
317
366
  headers: acceptedFormatsHeader(formats),
318
367
  payload,
319
368
  query: {
320
- include: include
369
+ include
321
370
  }
322
371
  });
323
372
  return story;
@@ -326,8 +375,8 @@ class Client {
326
375
  const url = `${_routing.routing.storiesUrl}/${id}/pin`;
327
376
  const {
328
377
  include,
329
- force,
330
- formats
378
+ formats,
379
+ force = false
331
380
  } = options ?? {};
332
381
  const {
333
382
  story
@@ -335,7 +384,7 @@ class Client {
335
384
  headers: acceptedFormatsHeader(formats),
336
385
  query: {
337
386
  include: include,
338
- force: force || undefined
387
+ force: force || undefined // only pass it if it's true
339
388
  }
340
389
  });
341
390
  return story;
@@ -1,17 +1,17 @@
1
1
  import type { DeferredJobsApiClient } from '../../api';
2
- import type { ExtendedStory, Story } from '../../types';
2
+ import type { ExtendedStory, Query, Story } from '../../types';
3
3
  import type { AutosaveRequest, ChangeNewsroomSuccessResponse, ChangeNewsroomUnsafeResponse, CreateRequest, IncludeOptions, ListOptions, ListResponse, MoveRequest, PreviewResponse, PreviewOptions, PublishRequest, RevertRequest, ScheduleRequest, SearchOptions, TranslateRequest, UnpublishRequest, UnscheduleRequest, UpdateRequest } from './types';
4
4
  /**
5
5
  * `uuid` is the preferred way of targeting a Story. Numeric `id` is considered deprecated.
6
6
  */
7
- declare type StoryId = Story['uuid'] | Story['id'];
8
- declare type Formats = Story.FormatVersion[];
7
+ type StoryId = Story['uuid'] | Story['id'];
8
+ type Formats = Story.FormatVersion[];
9
9
  /**
10
10
  * Utility type to forbid arbitrary ad-hoc extensions of generic parameters.
11
11
  * @see https://stackoverflow.com/a/69666350
12
12
  */
13
- declare type Exactly<Concrete, Abstract> = Concrete & Record<Exclude<keyof Concrete, keyof Abstract>, never>;
14
- declare type InferExtraFields<T> = T extends Required<IncludeOptions<infer I>> ? Pick<Story.ExtraFields, I> : unknown;
13
+ type Exactly<Concrete, Abstract> = Concrete & Record<Exclude<keyof Concrete, keyof Abstract>, never>;
14
+ type InferExtraFields<T> = T extends Required<IncludeOptions<infer I>> ? Pick<Story.ExtraFields, I> : unknown;
15
15
  export declare class Client {
16
16
  private readonly apiClient;
17
17
  constructor(apiClient: DeferredJobsApiClient);
@@ -51,10 +51,19 @@ export declare class Client {
51
51
  }>(ids: Story['id'][], options?: Exactly<Options, IncludeOptions & {
52
52
  formats?: Formats;
53
53
  }>): Promise<(ExtendedStory & InferExtraFields<Options>)[]>;
54
+ getBySlug<Options extends IncludeOptions & {
55
+ formats?: Formats;
56
+ query?: Query;
57
+ }>(slug: Story['slug'], options?: Exactly<Options, IncludeOptions & {
58
+ formats?: Formats;
59
+ query?: Query;
60
+ }>): Promise<ExtendedStory & InferExtraFields<Options>>;
54
61
  create<Options extends IncludeOptions & {
55
62
  formats?: Formats;
63
+ force?: boolean;
56
64
  }>(payload: CreateRequest, options?: Exactly<Options, IncludeOptions & {
57
65
  formats?: Formats;
66
+ force?: boolean;
58
67
  }>): Promise<ExtendedStory & InferExtraFields<Options>>;
59
68
  duplicate<Options extends IncludeOptions & {
60
69
  formats?: Formats;
@@ -67,16 +76,18 @@ export declare class Client {
67
76
  formats?: Formats;
68
77
  }>): Promise<ExtendedStory & InferExtraFields<Options>>;
69
78
  move<Options extends IncludeOptions & {
70
- force?: true;
71
79
  formats?: Formats;
80
+ force?: boolean;
72
81
  }>(id: StoryId, payload: MoveRequest, options?: Exactly<Options, IncludeOptions & {
73
- force?: true;
74
82
  formats?: Formats;
83
+ force?: boolean;
75
84
  }>): Promise<ChangeNewsroomSuccessResponse<ExtendedStory & InferExtraFields<Options>> | ChangeNewsroomUnsafeResponse>;
76
85
  update<Options extends IncludeOptions & {
77
86
  formats?: Formats;
87
+ force?: boolean;
78
88
  }>(id: StoryId, payload: UpdateRequest, options?: Exactly<Options, IncludeOptions & {
79
89
  formats?: Formats;
90
+ force?: boolean;
80
91
  }>): Promise<ExtendedStory & InferExtraFields<Options>>;
81
92
  /**
82
93
  * This operation is only allowed for V3 stories
@@ -115,11 +126,11 @@ export declare class Client {
115
126
  formats?: Formats;
116
127
  }>): Promise<ExtendedStory & InferExtraFields<Options>>;
117
128
  pin<Options extends IncludeOptions & {
118
- force?: boolean;
119
129
  formats?: Formats;
120
- }>(id: StoryId, options?: Exactly<Options, IncludeOptions & {
121
130
  force?: boolean;
131
+ }>(id: StoryId, options?: Exactly<Options, IncludeOptions & {
122
132
  formats?: Formats;
133
+ force?: boolean;
123
134
  }>): Promise<ExtendedStory & InferExtraFields<Options>>;
124
135
  unpin<Options extends IncludeOptions & {
125
136
  formats?: Formats;
@@ -1,9 +1,14 @@
1
1
  import { ApiError, HttpCodes } from "../../http/index.js";
2
2
  import { routing } from "../../routing.js";
3
3
  import { SortOrder } from "../../types/index.js";
4
- import { EXTENDED_STORY_INCLUDED_EXTRA_FIELDS } from "./types.js"; /**
5
- * `uuid` is the preferred way of targeting a Story. Numeric `id` is considered deprecated.
6
- */
4
+ import { EXTENDED_STORY_INCLUDED_EXTRA_FIELDS } from "./types.js";
5
+ /**
6
+ * `uuid` is the preferred way of targeting a Story. Numeric `id` is considered deprecated.
7
+ */
8
+ /**
9
+ * Utility type to forbid arbitrary ad-hoc extensions of generic parameters.
10
+ * @see https://stackoverflow.com/a/69666350
11
+ */
7
12
  export class Client {
8
13
  constructor(apiClient) {
9
14
  this.apiClient = apiClient;
@@ -55,6 +60,20 @@ export class Client {
55
60
  * Get story by UUID.
56
61
  */
57
62
 
63
+ /**
64
+ * Get multiple stories by UUIDs.
65
+ */
66
+
67
+ /**
68
+ * Get story by deprecated numeric ID, or UUID.
69
+ * @deprecated Please use UUID instead.
70
+ */
71
+
72
+ /**
73
+ * Get multiple stories by numeric IDs.
74
+ * @deprecated Please use UUID instead.
75
+ */
76
+
58
77
  /**
59
78
  * Implementation
60
79
  */
@@ -108,22 +127,46 @@ export class Client {
108
127
  });
109
128
  return story;
110
129
  }
111
- async create(payload, options) {
130
+ async getBySlug(slug, options) {
131
+ if (slug.includes('/') || slug.includes('\\')) {
132
+ throw new Error('Story slugs cannot contain slashes.');
133
+ }
112
134
  const {
113
135
  include,
136
+ query,
114
137
  formats
115
138
  } = options ?? {};
116
139
  const {
117
140
  story
118
- } = await this.apiClient.post(routing.storiesUrl, {
141
+ } = await this.apiClient.post(`${routing.storiesUrl}/by-slug/${slug}`, {
119
142
  headers: acceptedFormatsHeader(formats),
120
- payload,
121
143
  query: {
122
144
  include
145
+ },
146
+ payload: {
147
+ query
123
148
  }
124
149
  });
125
150
  return story;
126
151
  }
152
+ async create(payload, options) {
153
+ const {
154
+ include,
155
+ formats,
156
+ force = false
157
+ } = options ?? {};
158
+ const {
159
+ story
160
+ } = await this.apiClient.post(routing.storiesUrl, {
161
+ headers: acceptedFormatsHeader(formats),
162
+ query: {
163
+ include,
164
+ force: force || undefined // only pass it if it's true
165
+ },
166
+ payload
167
+ });
168
+ return story;
169
+ }
127
170
  async duplicate(id, options) {
128
171
  const {
129
172
  include,
@@ -165,8 +208,8 @@ export class Client {
165
208
  async move(id, payload, options) {
166
209
  const {
167
210
  include,
168
- force,
169
- formats
211
+ formats,
212
+ force = false
170
213
  } = options ?? {};
171
214
  const url = `${routing.storiesUrl}/${id}/move`;
172
215
  try {
@@ -175,8 +218,8 @@ export class Client {
175
218
  } = await this.apiClient.post(url, {
176
219
  headers: acceptedFormatsHeader(formats),
177
220
  query: {
178
- include: include,
179
- force
221
+ include,
222
+ force: force || undefined // only pass it if it's true
180
223
  },
181
224
  payload
182
225
  });
@@ -195,16 +238,18 @@ export class Client {
195
238
  const url = `${routing.storiesUrl}/${id}`;
196
239
  const {
197
240
  include,
198
- formats
241
+ formats,
242
+ force = false
199
243
  } = options ?? {};
200
244
  const {
201
245
  story
202
246
  } = await this.apiClient.patch(url, {
203
247
  headers: acceptedFormatsHeader(formats),
204
- payload,
205
248
  query: {
206
- include: include
207
- }
249
+ include,
250
+ force: force || undefined // only pass it if it's true
251
+ },
252
+ payload
208
253
  });
209
254
  return story;
210
255
  }
@@ -224,7 +269,7 @@ export class Client {
224
269
  headers: acceptedFormatsHeader(formats),
225
270
  payload,
226
271
  query: {
227
- include: include
272
+ include
228
273
  }
229
274
  });
230
275
  return story;
@@ -245,7 +290,7 @@ export class Client {
245
290
  headers: acceptedFormatsHeader(formats),
246
291
  payload,
247
292
  query: {
248
- include: include
293
+ include
249
294
  }
250
295
  });
251
296
  return story;
@@ -262,7 +307,7 @@ export class Client {
262
307
  headers: acceptedFormatsHeader(formats),
263
308
  payload,
264
309
  query: {
265
- include: include
310
+ include
266
311
  }
267
312
  });
268
313
  return story;
@@ -279,7 +324,7 @@ export class Client {
279
324
  headers: acceptedFormatsHeader(formats),
280
325
  payload,
281
326
  query: {
282
- include: include
327
+ include
283
328
  }
284
329
  });
285
330
  return story;
@@ -296,7 +341,7 @@ export class Client {
296
341
  headers: acceptedFormatsHeader(formats),
297
342
  payload,
298
343
  query: {
299
- include: include
344
+ include
300
345
  }
301
346
  });
302
347
  return story;
@@ -313,7 +358,7 @@ export class Client {
313
358
  headers: acceptedFormatsHeader(formats),
314
359
  payload,
315
360
  query: {
316
- include: include
361
+ include
317
362
  }
318
363
  });
319
364
  return story;
@@ -322,8 +367,8 @@ export class Client {
322
367
  const url = `${routing.storiesUrl}/${id}/pin`;
323
368
  const {
324
369
  include,
325
- force,
326
- formats
370
+ formats,
371
+ force = false
327
372
  } = options ?? {};
328
373
  const {
329
374
  story
@@ -331,7 +376,7 @@ export class Client {
331
376
  headers: acceptedFormatsHeader(formats),
332
377
  query: {
333
378
  include: include,
334
- force: force || undefined
379
+ force: force || undefined // only pass it if it's true
335
380
  }
336
381
  });
337
382
  return story;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _Client = require("./Client.cjs");
7
7
  Object.keys(_Client).forEach(function (key) {
8
8
  if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Client[key]) return;
9
10
  Object.defineProperty(exports, key, {
10
11
  enumerable: true,
11
12
  get: function () {
@@ -16,6 +17,7 @@ Object.keys(_Client).forEach(function (key) {
16
17
  var _types = require("./types.cjs");
17
18
  Object.keys(_types).forEach(function (key) {
18
19
  if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _types[key]) return;
19
21
  Object.defineProperty(exports, key, {
20
22
  enumerable: true,
21
23
  get: function () {
@@ -26,6 +28,7 @@ Object.keys(_types).forEach(function (key) {
26
28
  var _scopes = require("./scopes.cjs");
27
29
  Object.keys(_scopes).forEach(function (key) {
28
30
  if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _scopes[key]) return;
29
32
  Object.defineProperty(exports, key, {
30
33
  enumerable: true,
31
34
  get: function () {
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Scope = void 0;
7
7
  var _index = require("../../types/index.cjs");
8
- const Scope = {
8
+ const Scope = exports.Scope = {
9
9
  EXCLUDE_ARCHIVED_NEWSROOMS: {
10
10
  'newsroom.status': {
11
11
  $nin: [_index.Newsroom.Status.ARCHIVED]
12
12
  }
13
13
  }
14
- };
15
- exports.Scope = Scope;
14
+ };
@@ -5,6 +5,18 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.EXTENDED_STORY_INCLUDED_EXTRA_FIELDS = exports.ALL_EXTRA_FIELDS = void 0;
7
7
  var _index = require("../../types/index.cjs");
8
+ /**
9
+ * Uploadcare image JSON string.
10
+ */
11
+ /**
12
+ * Raw HTML string.
13
+ */
14
+ /**
15
+ * String-serialized JSON object.
16
+ */
17
+ /**
18
+ * String containing Prezly Content Format JSON structure.
19
+ */
8
20
  var Alignment = _index.Campaign.StoryAlignment;
9
21
  var Appearance = _index.Campaign.StoryAppearance;
10
22
  const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE = {
@@ -40,7 +52,5 @@ const ALL_EXTRA_FIELDS_SHAPE = {
40
52
  'pitches.count': true
41
53
  }; // satisfies Record<keyof Story.OnDemandFields, boolean>; // TODO: Use Typescript `satisfies` operator, when it's out of beta
42
54
 
43
- const ALL_EXTRA_FIELDS = Object.keys(ALL_EXTRA_FIELDS_SHAPE);
44
- exports.ALL_EXTRA_FIELDS = ALL_EXTRA_FIELDS;
45
- const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS = Object.keys(EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE);
46
- exports.EXTENDED_STORY_INCLUDED_EXTRA_FIELDS = EXTENDED_STORY_INCLUDED_EXTRA_FIELDS;
55
+ const ALL_EXTRA_FIELDS = exports.ALL_EXTRA_FIELDS = Object.keys(ALL_EXTRA_FIELDS_SHAPE);
56
+ const EXTENDED_STORY_INCLUDED_EXTRA_FIELDS = exports.EXTENDED_STORY_INCLUDED_EXTRA_FIELDS = Object.keys(EXTENDED_STORY_INCLUDED_EXTRA_FIELDS_SHAPE);
@@ -3,20 +3,20 @@ import { Campaign } from '../../types';
3
3
  /**
4
4
  * Uploadcare image JSON string.
5
5
  */
6
- declare type UploadedImage = string;
7
- declare type Iso8601DateTime = string;
6
+ type UploadedImage = string;
7
+ type Iso8601DateTime = string;
8
8
  /**
9
9
  * Raw HTML string.
10
10
  */
11
- declare type Html = string;
11
+ type Html = string;
12
12
  /**
13
13
  * String-serialized JSON object.
14
14
  */
15
- declare type Json = string;
15
+ type Json = string;
16
16
  /**
17
17
  * String containing Prezly Content Format JSON structure.
18
18
  */
19
- declare type PrezlyContentFormat = string;
19
+ type PrezlyContentFormat = string;
20
20
  interface BaseWarning {
21
21
  text: string;
22
22
  scope: string;
@@ -48,7 +48,7 @@ interface StoryEmbeddedContactsWillBeRemovedWarning extends BaseWarning {
48
48
  field: 'room_contacts';
49
49
  value: NewsroomContactRef[];
50
50
  }
51
- export declare type ChangeNewsroomWarning = ChangingNewsroomUnsafeOperationWarning | DestinationNewsroomMissingCategoriesWarning | DestinationNewsroomMissingCulturesWarning | StoryEmbeddedContactsWillBeRemovedWarning | StoryTranslationsWillMoveWarning;
51
+ export type ChangeNewsroomWarning = ChangingNewsroomUnsafeOperationWarning | DestinationNewsroomMissingCategoriesWarning | DestinationNewsroomMissingCulturesWarning | StoryEmbeddedContactsWillBeRemovedWarning | StoryTranslationsWillMoveWarning;
52
52
  export interface IncludeOptions<Include extends keyof Story.ExtraFields = keyof Story.ExtraFields> {
53
53
  include?: Include[];
54
54
  }
@@ -70,6 +70,15 @@ export interface ListResponse<S extends Story = Story> {
70
70
  sort: string;
71
71
  }
72
72
  interface GenericCreateRequest {
73
+ /**
74
+ * Set a custom slug for a Story.
75
+ *
76
+ * - If there is another story with exactly the same slug value, the Create request will throw [HTTP 409 Conflict].
77
+ *
78
+ * - Conflicts can be force-resolved by passing `?force` GET parameter.
79
+ * This will update other conflicting stories slugs to something else (i.e. adding random suffix).
80
+ */
81
+ slug?: Story['slug'];
73
82
  newsroom?: Newsroom['id'] | Newsroom['uuid'];
74
83
  published_at?: Iso8601DateTime;
75
84
  visibility?: Story.Visibility;
@@ -82,6 +91,16 @@ interface GenericCreateRequest {
82
91
  is_shared_to_prpro?: boolean;
83
92
  }
84
93
  interface GenericUpdateRequest {
94
+ /**
95
+ * Set a custom slug for a Story.
96
+ * Updating it to `null` will revert back to automatically generated slugs.
97
+ *
98
+ * - If there is another story with exactly the same slug value, the Update request will throw [HTTP 409 Conflict].
99
+ *
100
+ * - Conflicts can be force-resolved by passing `?force` GET parameter.
101
+ * This will update other conflicting stories slugs to something else (i.e. adding random suffix).
102
+ */
103
+ slug?: Story['slug'] | null;
85
104
  published_at?: Iso8601DateTime;
86
105
  visibility?: Story.Visibility;
87
106
  culture?: CultureRef['code'];
@@ -201,8 +220,8 @@ export interface PreviewOptions {
201
220
  }
202
221
  export import Alignment = Campaign.StoryAlignment;
203
222
  export import Appearance = Campaign.StoryAppearance;
204
- export declare type CreateRequest = HtmlStoryCreateRequest | SlateV3StoryCreateRequest | SlateV4StoryCreateRequest | SlateV5StoryCreateRequest;
205
- export declare type UpdateRequest = HtmlStoryUpdateRequest | SlateV3StoryUpdateRequest | SlateV4StoryUpdateRequest | SlateV5StoryUpdateRequest;
223
+ export type CreateRequest = HtmlStoryCreateRequest | SlateV3StoryCreateRequest | SlateV4StoryCreateRequest | SlateV5StoryCreateRequest;
224
+ export type UpdateRequest = HtmlStoryUpdateRequest | SlateV3StoryUpdateRequest | SlateV4StoryUpdateRequest | SlateV5StoryUpdateRequest;
206
225
  export interface AutosaveRequest {
207
226
  autosaved_content: PrezlyContentFormat;
208
227
  content_version?: number;
@@ -221,7 +240,7 @@ export interface ScheduleRequest {
221
240
  publish_at: Iso8601DateTime;
222
241
  visibility?: Story.Visibility.PUBLIC | Story.Visibility.EMBARGO;
223
242
  }
224
- export declare type UnscheduleRequest = UnpublishRequest;
243
+ export type UnscheduleRequest = UnpublishRequest;
225
244
  export interface TranslateRequest {
226
245
  culture?: CultureRef['code'];
227
246
  }