@prezly/theme-kit-nextjs 1.18.3 → 1.18.4-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/adapter-nextjs/page-props/category.d.ts +2 -2
- package/build/adapter-nextjs/page-props/home.d.ts +2 -2
- package/build/components-nextjs/StorySeo/StorySeo.js +1 -1
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
- package/build/data-fetching/api/PrezlyApi.d.ts +4 -5
- package/build/data-fetching/api/PrezlyApi.js +7 -8
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/infinite-loading/useInfiniteStoriesLoading.d.ts +2 -2
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
- package/build/intl/languages.d.ts +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +15 -14
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types.d.ts +2 -2
- package/package.json +8 -8
- package/src/__mocks__/languages.ts +10 -11
- package/src/__mocks__/story.ts +36 -28
- package/src/adapter-nextjs/page-props/category.ts +2 -2
- package/src/adapter-nextjs/page-props/home.ts +2 -2
- package/src/components-nextjs/StorySeo/StorySeo.tsx +2 -2
- package/src/data-fetching/api/PrezlyApi.ts +12 -10
- package/src/infinite-loading/useInfiniteStoriesLoading.ts +3 -3
- package/src/intl/locale.test.ts +1 -0
- package/src/newsroom-context/hooks/useGetTranslationUrl.ts +10 -9
- package/src/types.ts +2 -2
package/build/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CultureRef,
|
|
1
|
+
import type { CultureRef, Story } from '@prezly/sdk';
|
|
2
2
|
import type { NewsroomContextProps } from './newsroom-context';
|
|
3
3
|
export interface ServerSidePageProps {
|
|
4
4
|
/**
|
|
@@ -24,7 +24,7 @@ export interface AlgoliaCategoryRef {
|
|
|
24
24
|
/**
|
|
25
25
|
* Stories in Algolia index are stored in a simplified format, with only minimal subset of fields.
|
|
26
26
|
*/
|
|
27
|
-
export type AlgoliaStory = Pick<Story, 'uuid' | 'slug' | 'title' | 'subtitle'> & Pick<
|
|
27
|
+
export type AlgoliaStory = Pick<Story, 'uuid' | 'slug' | 'title' | 'subtitle'> & Pick<Story.ExtraFields, 'thumbnail_image'> & {
|
|
28
28
|
content_text: string;
|
|
29
29
|
updated_at: number;
|
|
30
30
|
published_at: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-nextjs",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.4-1",
|
|
4
4
|
"description": "Data layer and utility library for developing Prezly themes with NextJS",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -48,24 +48,24 @@
|
|
|
48
48
|
"react-dom": "^17.x || ^18.x"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@prezly/sdk": "^
|
|
51
|
+
"@prezly/sdk": "^11.8.1-0",
|
|
52
52
|
"@prezly/uploadcare": "^2.3.4",
|
|
53
53
|
"@react-hookz/web": "^16.0.0",
|
|
54
54
|
"next-seo": "^5.4.0",
|
|
55
55
|
"parse-data-url": "^4.0.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@prezly/eslint-config": "4.2
|
|
59
|
-
"@sentry/nextjs": "7.
|
|
60
|
-
"@types/jest": "29.2.
|
|
58
|
+
"@prezly/eslint-config": "4.3.2",
|
|
59
|
+
"@sentry/nextjs": "7.23.0",
|
|
60
|
+
"@types/jest": "29.2.4",
|
|
61
61
|
"@types/node": "17.0.14",
|
|
62
62
|
"@types/parse-data-url": "3.0.0",
|
|
63
|
-
"@types/react": "18.0.
|
|
63
|
+
"@types/react": "18.0.26",
|
|
64
64
|
"@types/react-dom": "18.0.9",
|
|
65
|
-
"eslint": "8.
|
|
65
|
+
"eslint": "8.29.0",
|
|
66
66
|
"jest": "29.3.1",
|
|
67
67
|
"np": "7.6.2",
|
|
68
|
-
"prettier": "2.
|
|
68
|
+
"prettier": "2.8.0",
|
|
69
69
|
"rimraf": "3.0.2",
|
|
70
70
|
"ts-jest": "29.0.3",
|
|
71
71
|
"typescript": "4.9.3"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { type NewsroomLanguageSettings, TextDirection } from '@prezly/sdk';
|
|
1
|
+
import { type NewsroomLanguageSettings, Culture } from '@prezly/sdk';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Pulled from The Good Newsroom (with some additions)
|
|
@@ -12,7 +11,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
12
11
|
locale: 'nl_BE',
|
|
13
12
|
name: 'Dutch (Belgium)',
|
|
14
13
|
native_name: 'Nederlands (België)',
|
|
15
|
-
direction: TextDirection.LTR,
|
|
14
|
+
direction: Culture.TextDirection.LTR,
|
|
16
15
|
language_code: 'nl',
|
|
17
16
|
},
|
|
18
17
|
is_default: false,
|
|
@@ -57,7 +56,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
57
56
|
locale: 'nl_NL',
|
|
58
57
|
name: 'Dutch (Netherlands)',
|
|
59
58
|
native_name: 'Nederlands (Nederland)',
|
|
60
|
-
direction: TextDirection.LTR,
|
|
59
|
+
direction: Culture.TextDirection.LTR,
|
|
61
60
|
language_code: 'nl',
|
|
62
61
|
},
|
|
63
62
|
is_default: false,
|
|
@@ -98,7 +97,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
98
97
|
locale: 'en',
|
|
99
98
|
name: 'English (Global)',
|
|
100
99
|
native_name: 'English (Global)',
|
|
101
|
-
direction: TextDirection.LTR,
|
|
100
|
+
direction: Culture.TextDirection.LTR,
|
|
102
101
|
language_code: 'en',
|
|
103
102
|
},
|
|
104
103
|
is_default: true,
|
|
@@ -145,7 +144,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
145
144
|
locale: 'en_US',
|
|
146
145
|
name: 'English (US)',
|
|
147
146
|
native_name: 'English (US)',
|
|
148
|
-
direction: TextDirection.LTR,
|
|
147
|
+
direction: Culture.TextDirection.LTR,
|
|
149
148
|
language_code: 'en',
|
|
150
149
|
},
|
|
151
150
|
is_default: false,
|
|
@@ -192,7 +191,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
192
191
|
locale: 'en_GB',
|
|
193
192
|
name: 'English (UK)',
|
|
194
193
|
native_name: 'English (UK)',
|
|
195
|
-
direction: TextDirection.LTR,
|
|
194
|
+
direction: Culture.TextDirection.LTR,
|
|
196
195
|
language_code: 'en',
|
|
197
196
|
},
|
|
198
197
|
is_default: false,
|
|
@@ -239,7 +238,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
239
238
|
locale: 'fr',
|
|
240
239
|
name: 'French (Global)',
|
|
241
240
|
native_name: 'Français (Mondial)',
|
|
242
|
-
direction: TextDirection.LTR,
|
|
241
|
+
direction: Culture.TextDirection.LTR,
|
|
243
242
|
language_code: 'fr',
|
|
244
243
|
},
|
|
245
244
|
is_default: false,
|
|
@@ -286,7 +285,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
286
285
|
locale: 'fr_BE',
|
|
287
286
|
name: 'French (Belgium)',
|
|
288
287
|
native_name: 'Français (België)',
|
|
289
|
-
direction: TextDirection.LTR,
|
|
288
|
+
direction: Culture.TextDirection.LTR,
|
|
290
289
|
language_code: 'fr',
|
|
291
290
|
},
|
|
292
291
|
is_default: false,
|
|
@@ -333,7 +332,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
333
332
|
locale: 'es_ES',
|
|
334
333
|
name: 'Spanish (Spain)',
|
|
335
334
|
native_name: 'Español (España)',
|
|
336
|
-
direction: TextDirection.LTR,
|
|
335
|
+
direction: Culture.TextDirection.LTR,
|
|
337
336
|
language_code: 'es',
|
|
338
337
|
},
|
|
339
338
|
is_default: false,
|
|
@@ -377,7 +376,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
377
376
|
locale: 'es_419',
|
|
378
377
|
name: 'Spanish (Latin America)',
|
|
379
378
|
native_name: 'Español (Latinoamérica)',
|
|
380
|
-
direction: TextDirection.LTR,
|
|
379
|
+
direction: Culture.TextDirection.LTR,
|
|
381
380
|
language_code: 'es',
|
|
382
381
|
},
|
|
383
382
|
is_default: false,
|
package/src/__mocks__/story.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import type { ExtendedStory } from '@prezly/sdk';
|
|
2
|
-
import {
|
|
3
|
-
NewsroomStatus,
|
|
4
|
-
StoryLifecycleStatus,
|
|
5
|
-
StoryPublicationStatus,
|
|
6
|
-
StoryVisibility,
|
|
7
|
-
TextDirection,
|
|
8
|
-
} from '@prezly/sdk';
|
|
2
|
+
import { Newsroom, Story, Culture, User } from '@prezly/sdk';
|
|
9
3
|
|
|
10
4
|
export const STORY: ExtendedStory = {
|
|
11
5
|
id: 380023,
|
|
6
|
+
attached_gallery_content: null,
|
|
7
|
+
is_pinned: false,
|
|
8
|
+
is_shared_to_prpro: false,
|
|
9
|
+
pinned_by: null,
|
|
10
|
+
seo_settings: {
|
|
11
|
+
canonical_url: null,
|
|
12
|
+
default_meta_description: null,
|
|
13
|
+
default_meta_title: null,
|
|
14
|
+
meta_description: null,
|
|
15
|
+
meta_title: null,
|
|
16
|
+
},
|
|
12
17
|
uuid: '65018f5b-b313-453f-b23b-9e739c6a8591',
|
|
13
18
|
thumbnail_url:
|
|
14
19
|
'https://avatars-cdn.prezly.com/story/6337/380023/c3a3d56ee09ce808dbb1bc2f06d16b68bdaeefbf731d8a080b7e4d5e68fb3e94?t=1640077510&v=1',
|
|
@@ -23,15 +28,15 @@ export const STORY: ExtendedStory = {
|
|
|
23
28
|
locale: 'en',
|
|
24
29
|
name: 'English (Global)',
|
|
25
30
|
native_name: 'English (Global)',
|
|
26
|
-
direction: TextDirection.LTR,
|
|
31
|
+
direction: Culture.TextDirection.LTR,
|
|
27
32
|
language_code: 'en',
|
|
28
33
|
},
|
|
29
34
|
slug: 'take-a-breath',
|
|
30
35
|
format_version: 3,
|
|
31
36
|
language: 'EN',
|
|
32
|
-
lifecycle_status:
|
|
33
|
-
publication_status:
|
|
34
|
-
visibility:
|
|
37
|
+
lifecycle_status: Story.LifecycleStatus.PUBLISHED,
|
|
38
|
+
publication_status: Story.PublicationStatus.PUBLISHED,
|
|
39
|
+
visibility: Story.Visibility.PUBLIC,
|
|
35
40
|
is_archived: false,
|
|
36
41
|
is_finalized: true,
|
|
37
42
|
is_published: true,
|
|
@@ -54,11 +59,12 @@ export const STORY: ExtendedStory = {
|
|
|
54
59
|
last_name: 'Anthonis',
|
|
55
60
|
avatar_url:
|
|
56
61
|
'https://avatars-cdn.prezly.com/user/7680/6260be53465a846a511c44edd8f594f38235d782f3fa515ab968ad2f947a236c?v=1&c=cc6e751bdb46638cd948d0d812149ce391e45b7cd2b5d80a94de575ba0ce65d0',
|
|
57
|
-
use_case_answer:
|
|
58
|
-
sign_in_flow:
|
|
62
|
+
use_case_answer: User.UseCaseAnswer.UNKNOWN,
|
|
63
|
+
sign_in_flow: User.SignInFlow.PASSWORD,
|
|
59
64
|
created_at: '2019-02-06T09:54:34+00:00',
|
|
60
65
|
is_terms_of_service_accepted: false,
|
|
61
66
|
last_seen_at: '2021-12-03T09:15:39+00:00',
|
|
67
|
+
locked_until: null,
|
|
62
68
|
},
|
|
63
69
|
newsroom: {
|
|
64
70
|
uuid: '578e78e9-9a5b-44ad-bda2-5214895ee036',
|
|
@@ -69,7 +75,7 @@ export const STORY: ExtendedStory = {
|
|
|
69
75
|
thumbnail_url:
|
|
70
76
|
'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
|
|
71
77
|
timezone: 'europe/london',
|
|
72
|
-
status:
|
|
78
|
+
status: Newsroom.Status.ACTIVE,
|
|
73
79
|
is_active: true,
|
|
74
80
|
is_archived: false,
|
|
75
81
|
is_online: true,
|
|
@@ -145,12 +151,12 @@ export const STORY: ExtendedStory = {
|
|
|
145
151
|
locale: 'nl_BE',
|
|
146
152
|
name: 'Dutch (Belgium)',
|
|
147
153
|
native_name: 'Nederlands (België)',
|
|
148
|
-
direction: TextDirection.LTR,
|
|
154
|
+
direction: Culture.TextDirection.LTR,
|
|
149
155
|
language_code: 'nl',
|
|
150
156
|
},
|
|
151
|
-
lifecycle_status:
|
|
152
|
-
publication_status:
|
|
153
|
-
visibility:
|
|
157
|
+
lifecycle_status: Story.LifecycleStatus.PUBLISHED,
|
|
158
|
+
publication_status: Story.PublicationStatus.PUBLISHED,
|
|
159
|
+
visibility: Story.Visibility.PUBLIC,
|
|
154
160
|
created_at: '2020-05-05T10:07:11+00:00',
|
|
155
161
|
updated_at: '2021-12-21T09:05:05+00:00',
|
|
156
162
|
published_at: '2020-05-05T10:21:00+00:00',
|
|
@@ -164,11 +170,12 @@ export const STORY: ExtendedStory = {
|
|
|
164
170
|
last_name: 'Anthonis',
|
|
165
171
|
avatar_url:
|
|
166
172
|
'https://avatars-cdn.prezly.com/user/7680/6260be53465a846a511c44edd8f594f38235d782f3fa515ab968ad2f947a236c?v=1&c=cc6e751bdb46638cd948d0d812149ce391e45b7cd2b5d80a94de575ba0ce65d0',
|
|
167
|
-
use_case_answer:
|
|
168
|
-
sign_in_flow:
|
|
173
|
+
use_case_answer: User.UseCaseAnswer.UNKNOWN,
|
|
174
|
+
sign_in_flow: User.SignInFlow.PASSWORD,
|
|
169
175
|
created_at: '2019-02-06T09:54:34+00:00',
|
|
170
176
|
is_terms_of_service_accepted: false,
|
|
171
177
|
last_seen_at: '2021-12-03T09:15:39+00:00',
|
|
178
|
+
locked_until: null,
|
|
172
179
|
},
|
|
173
180
|
newsroom: {
|
|
174
181
|
uuid: '578e78e9-9a5b-44ad-bda2-5214895ee036',
|
|
@@ -179,7 +186,7 @@ export const STORY: ExtendedStory = {
|
|
|
179
186
|
thumbnail_url:
|
|
180
187
|
'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
|
|
181
188
|
timezone: 'europe/london',
|
|
182
|
-
status:
|
|
189
|
+
status: Newsroom.Status.ACTIVE,
|
|
183
190
|
is_active: true,
|
|
184
191
|
is_archived: false,
|
|
185
192
|
is_online: true,
|
|
@@ -244,12 +251,12 @@ export const STORY: ExtendedStory = {
|
|
|
244
251
|
locale: 'nl_NL',
|
|
245
252
|
name: 'Dutch (Netherlands)',
|
|
246
253
|
native_name: 'Nederlands (Nederland)',
|
|
247
|
-
direction: TextDirection.LTR,
|
|
254
|
+
direction: Culture.TextDirection.LTR,
|
|
248
255
|
language_code: 'nl',
|
|
249
256
|
},
|
|
250
|
-
lifecycle_status:
|
|
251
|
-
publication_status:
|
|
252
|
-
visibility:
|
|
257
|
+
lifecycle_status: Story.LifecycleStatus.PUBLISHED,
|
|
258
|
+
publication_status: Story.PublicationStatus.PUBLISHED,
|
|
259
|
+
visibility: Story.Visibility.PUBLIC,
|
|
253
260
|
created_at: '2022-06-28T07:29:03+00:00',
|
|
254
261
|
updated_at: '2022-06-28T07:29:09+00:00',
|
|
255
262
|
published_at: '2022-06-28T07:29:09+00:00',
|
|
@@ -263,11 +270,12 @@ export const STORY: ExtendedStory = {
|
|
|
263
270
|
last_name: 'Semyonov',
|
|
264
271
|
avatar_url:
|
|
265
272
|
'https://avatars-cdn.prezly.com/user/10324/85fc2201624703503c24a3a97cc7e1776015e9f6ffe2ad96016650add0b9ab5f?v=1&c=add8f27908ec1f74f1a7c0530a74d88027eea08d05cac4300713d1c07fed0e1b',
|
|
266
|
-
use_case_answer:
|
|
267
|
-
sign_in_flow:
|
|
273
|
+
use_case_answer: User.UseCaseAnswer.UNKNOWN,
|
|
274
|
+
sign_in_flow: User.SignInFlow.PASSWORD,
|
|
268
275
|
created_at: '2021-02-25T13:30:04+00:00',
|
|
269
276
|
is_terms_of_service_accepted: true,
|
|
270
277
|
last_seen_at: '2022-06-28T09:06:32+00:00',
|
|
278
|
+
locked_until: null,
|
|
271
279
|
},
|
|
272
280
|
newsroom: {
|
|
273
281
|
uuid: '578e78e9-9a5b-44ad-bda2-5214895ee036',
|
|
@@ -278,7 +286,7 @@ export const STORY: ExtendedStory = {
|
|
|
278
286
|
thumbnail_url:
|
|
279
287
|
'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
|
|
280
288
|
timezone: 'europe/london',
|
|
281
|
-
status:
|
|
289
|
+
status: Newsroom.Status.ACTIVE,
|
|
282
290
|
is_active: true,
|
|
283
291
|
is_archived: false,
|
|
284
292
|
is_online: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Story } from '@prezly/sdk';
|
|
2
2
|
import type {
|
|
3
3
|
GetServerSidePropsContext,
|
|
4
4
|
GetServerSidePropsResult,
|
|
@@ -24,7 +24,7 @@ export interface CategoryPageProps<StoryType extends Story = Story> {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
interface Options {
|
|
27
|
-
extraStoryFields?: (keyof
|
|
27
|
+
extraStoryFields?: (keyof Story.ExtraFields)[];
|
|
28
28
|
pageSize?: number;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Story } from '@prezly/sdk';
|
|
2
2
|
import type {
|
|
3
3
|
GetServerSidePropsContext,
|
|
4
4
|
GetServerSidePropsResult,
|
|
@@ -21,7 +21,7 @@ export interface HomePageProps<StoryType extends Story = Story> {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
interface Options {
|
|
24
|
-
extraStoryFields?: (keyof
|
|
24
|
+
extraStoryFields?: (keyof Story.ExtraFields)[];
|
|
25
25
|
pageSize?: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtendedStory } from '@prezly/sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { Story } from '@prezly/sdk';
|
|
3
3
|
import { ArticleJsonLd, NextSeo } from 'next-seo';
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
@@ -16,7 +16,7 @@ export function StorySeo({ story, noindex }: Props) {
|
|
|
16
16
|
|
|
17
17
|
const authorName = author?.display_name || author?.email || 'Unknown';
|
|
18
18
|
const description = subtitle || summary;
|
|
19
|
-
const indexable = newsroom.is_indexable && story.visibility ===
|
|
19
|
+
const indexable = newsroom.is_indexable && story.visibility === Story.Visibility.PUBLIC;
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { createPrezlyClient } from '@prezly/sdk';
|
|
1
2
|
import type {
|
|
2
3
|
Category,
|
|
3
|
-
ExtraStoryFields,
|
|
4
4
|
Newsroom,
|
|
5
5
|
NewsroomLanguageSettings,
|
|
6
|
+
PrezlyClient,
|
|
7
|
+
Stories,
|
|
6
8
|
Story,
|
|
7
9
|
} from '@prezly/sdk';
|
|
8
|
-
import PrezlySDK from '@prezly/sdk';
|
|
9
10
|
import type { IncomingMessage } from 'http';
|
|
10
11
|
|
|
11
12
|
import {
|
|
@@ -41,7 +42,7 @@ interface GetStoriesOptions {
|
|
|
41
42
|
page?: number;
|
|
42
43
|
pageSize?: number;
|
|
43
44
|
order?: SortOrder;
|
|
44
|
-
include?: (keyof
|
|
45
|
+
include?: (keyof Story.ExtraFields)[];
|
|
45
46
|
localeCode?: string;
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -51,7 +52,7 @@ interface GetGalleriesOptions {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
export class PrezlyApi {
|
|
54
|
-
private readonly sdk:
|
|
55
|
+
private readonly sdk: PrezlyClient;
|
|
55
56
|
|
|
56
57
|
private readonly newsroomUuid: Newsroom['uuid'];
|
|
57
58
|
|
|
@@ -59,7 +60,7 @@ export class PrezlyApi {
|
|
|
59
60
|
|
|
60
61
|
constructor(accessToken: string, newsroomUuid: Newsroom['uuid'], themeUuid?: string) {
|
|
61
62
|
const baseUrl = process.env.API_BASE_URL_OVERRIDE ?? undefined;
|
|
62
|
-
this.sdk =
|
|
63
|
+
this.sdk = createPrezlyClient({
|
|
63
64
|
accessToken,
|
|
64
65
|
baseUrl,
|
|
65
66
|
// This returns stories created by legacy version of the editor in a format that can be displayed by the Prezly Content Renderer.
|
|
@@ -75,7 +76,8 @@ export class PrezlyApi {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
try {
|
|
78
|
-
|
|
79
|
+
const story = await this.sdk.stories.get(uuid);
|
|
80
|
+
return story;
|
|
79
81
|
} catch (error) {
|
|
80
82
|
if (
|
|
81
83
|
isSdkError(error) &&
|
|
@@ -211,11 +213,10 @@ export class PrezlyApi {
|
|
|
211
213
|
);
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
searchStories:
|
|
215
|
-
this.sdk.stories.search(options);
|
|
216
|
+
searchStories: Stories.Client['search'] = (options) => this.sdk.stories.search(options);
|
|
216
217
|
|
|
217
218
|
async getGalleries({ page, pageSize }: GetGalleriesOptions) {
|
|
218
|
-
return this.sdk.newsroomGalleries.
|
|
219
|
+
return this.sdk.newsroomGalleries.search(this.newsroomUuid, {
|
|
219
220
|
limit: pageSize,
|
|
220
221
|
offset:
|
|
221
222
|
typeof page === 'undefined' || typeof pageSize === 'undefined'
|
|
@@ -234,7 +235,8 @@ export class PrezlyApi {
|
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
try {
|
|
237
|
-
|
|
238
|
+
const gallery = await this.sdk.newsroomGalleries.get(this.newsroomUuid, uuid);
|
|
239
|
+
return gallery;
|
|
238
240
|
} catch (error) {
|
|
239
241
|
if (isSdkError(error) && error.status === 404) {
|
|
240
242
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Category,
|
|
1
|
+
import type { Category, Story } from '@prezly/sdk';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
import type { LocaleObject } from '../intl';
|
|
@@ -12,7 +12,7 @@ async function fetchStories<T extends Story = Story>(
|
|
|
12
12
|
pageSize: number,
|
|
13
13
|
category?: Category,
|
|
14
14
|
locale?: LocaleObject,
|
|
15
|
-
include?: (keyof
|
|
15
|
+
include?: (keyof Story.ExtraFields)[],
|
|
16
16
|
): Promise<{ stories: T[] }> {
|
|
17
17
|
const result = await fetch('/api/fetch-stories', {
|
|
18
18
|
method: 'POST',
|
|
@@ -47,7 +47,7 @@ export function useInfiniteStoriesLoading<T extends Story = Story>(
|
|
|
47
47
|
initialStories: T[],
|
|
48
48
|
pagination: PaginationProps,
|
|
49
49
|
category?: Category,
|
|
50
|
-
include?: (keyof
|
|
50
|
+
include?: (keyof Story.ExtraFields)[],
|
|
51
51
|
) {
|
|
52
52
|
const currentLocale = useCurrentLocale();
|
|
53
53
|
|
package/src/intl/locale.test.ts
CHANGED
|
@@ -9,25 +9,26 @@ import { useCurrentCategory } from './useCurrentCategory';
|
|
|
9
9
|
import { useCurrentStory } from './useCurrentStory';
|
|
10
10
|
|
|
11
11
|
// Pulled from SDK types to not leak the `@prezly/sdk` dependency into the client bundle
|
|
12
|
-
enum
|
|
12
|
+
// It looks like a hack, but the name of enum must be the same as in SDK
|
|
13
|
+
enum Visibility {
|
|
13
14
|
PUBLIC = 'public',
|
|
14
15
|
EMBARGO = 'embargo',
|
|
15
16
|
PRIVATE = 'private',
|
|
16
17
|
CONFIDENTIAL = 'confidential',
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
function getAllowedTranslationVisibilityValues(story: ExtendedStory):
|
|
20
|
+
function getAllowedTranslationVisibilityValues(story: ExtendedStory): Visibility[] {
|
|
20
21
|
const { visibility } = story;
|
|
21
22
|
|
|
22
23
|
switch (visibility) {
|
|
23
|
-
case
|
|
24
|
-
return [
|
|
25
|
-
case
|
|
26
|
-
return [
|
|
27
|
-
case
|
|
28
|
-
return [
|
|
24
|
+
case Visibility.EMBARGO:
|
|
25
|
+
return [Visibility.EMBARGO, Visibility.PUBLIC];
|
|
26
|
+
case Visibility.PRIVATE:
|
|
27
|
+
return [Visibility.PRIVATE, Visibility.PUBLIC];
|
|
28
|
+
case Visibility.CONFIDENTIAL:
|
|
29
|
+
return [Visibility.CONFIDENTIAL, Visibility.PRIVATE, Visibility.PUBLIC];
|
|
29
30
|
default:
|
|
30
|
-
return [
|
|
31
|
+
return [Visibility.PUBLIC];
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CultureRef,
|
|
1
|
+
import type { CultureRef, Story } from '@prezly/sdk';
|
|
2
2
|
|
|
3
3
|
import type { NewsroomContextProps } from './newsroom-context';
|
|
4
4
|
|
|
@@ -30,7 +30,7 @@ export interface AlgoliaCategoryRef {
|
|
|
30
30
|
* Stories in Algolia index are stored in a simplified format, with only minimal subset of fields.
|
|
31
31
|
*/
|
|
32
32
|
export type AlgoliaStory = Pick<Story, 'uuid' | 'slug' | 'title' | 'subtitle'> &
|
|
33
|
-
Pick<
|
|
33
|
+
Pick<Story.ExtraFields, 'thumbnail_image'> & {
|
|
34
34
|
content_text: string;
|
|
35
35
|
updated_at: number;
|
|
36
36
|
published_at: number;
|