@prezly/theme-kit-nextjs 1.18.2 → 1.18.4-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 (35) hide show
  1. package/build/adapter-nextjs/page-props/category.d.ts +2 -2
  2. package/build/adapter-nextjs/page-props/home.d.ts +2 -2
  3. package/build/adapter-nextjs/page-props/lib/types.d.ts +1 -1
  4. package/build/adapter-nextjs/page-props/sitemap/types.d.ts +1 -1
  5. package/build/components-nextjs/PageSeo/PageSeo.d.ts +1 -1
  6. package/build/components-nextjs/PageSeo/lib/types.d.ts +1 -1
  7. package/build/components-nextjs/StorySeo/StorySeo.d.ts +1 -1
  8. package/build/components-nextjs/StorySeo/StorySeo.js +1 -1
  9. package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
  10. package/build/data-fetching/api/PrezlyApi.d.ts +5 -6
  11. package/build/data-fetching/api/PrezlyApi.js +7 -8
  12. package/build/data-fetching/api/PrezlyApi.js.map +1 -1
  13. package/build/infinite-loading/useInfiniteStoriesLoading.d.ts +2 -2
  14. package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
  15. package/build/intl/languages.d.ts +1 -1
  16. package/build/newsroom-context/hooks/useGetTranslationUrl.js +15 -14
  17. package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
  18. package/build/tsconfig.tsbuildinfo +1 -1
  19. package/build/types.d.ts +2 -2
  20. package/build/utils/getPrivacyPortalUrl.d.ts +1 -1
  21. package/build/utils/getUploadcareGroupUrl.js +1 -1
  22. package/build/utils/getUploadcareGroupUrl.js.map +1 -1
  23. package/build/utils/isEmbargoStory.d.ts +1 -1
  24. package/package.json +19 -19
  25. package/src/__mocks__/languages.ts +10 -11
  26. package/src/__mocks__/story.ts +36 -28
  27. package/src/adapter-nextjs/page-props/category.ts +2 -2
  28. package/src/adapter-nextjs/page-props/home.ts +2 -2
  29. package/src/components-nextjs/StorySeo/StorySeo.tsx +2 -2
  30. package/src/data-fetching/api/PrezlyApi.ts +12 -10
  31. package/src/infinite-loading/useInfiniteStoriesLoading.ts +3 -3
  32. package/src/intl/locale.test.ts +1 -0
  33. package/src/newsroom-context/hooks/useGetTranslationUrl.ts +10 -9
  34. package/src/types.ts +2 -2
  35. package/src/utils/getUploadcareGroupUrl.ts +1 -1
package/build/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CultureRef, ExtraStoryFields, Story } from '@prezly/sdk';
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 declare type AlgoliaStory = Pick<Story, 'uuid' | 'slug' | 'title' | 'subtitle'> & Pick<ExtraStoryFields, 'thumbnail_image'> & {
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;
@@ -1,6 +1,6 @@
1
1
  import type { Newsroom } from '@prezly/sdk';
2
2
  import type { LocaleObject } from '../intl';
3
- declare type PrivacyPortalUrlOptions = {
3
+ type PrivacyPortalUrlOptions = {
4
4
  email?: string;
5
5
  action?: 'data-request' | 'subscribe' | 'unsubscribe';
6
6
  };
@@ -11,7 +11,7 @@ const constants_1 = require("./constants");
11
11
  */
12
12
  function getUploadcareGroupUrl(uuid, title) {
13
13
  // UploadCare doesn't like slashes in filenames even in encoded form.
14
- return `${constants_1.ASSETS_URL}/${uuid}/archive/zip/${encodeURIComponent(title.replace('/', '_'))}.zip`;
14
+ return `${constants_1.ASSETS_URL}/${uuid}/archive/zip/${encodeURIComponent(title.replace(/\//g, '_'))}.zip`;
15
15
  }
16
16
  exports.getUploadcareGroupUrl = getUploadcareGroupUrl;
17
17
  //# sourceMappingURL=getUploadcareGroupUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getUploadcareGroupUrl.js","sourceRoot":"","sources":["../../src/utils/getUploadcareGroupUrl.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC7D,qEAAqE;IACrE,OAAO,GAAG,sBAAU,IAAI,IAAI,gBAAgB,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;AAClG,CAAC;AAHD,sDAGC"}
1
+ {"version":3,"file":"getUploadcareGroupUrl.js","sourceRoot":"","sources":["../../src/utils/getUploadcareGroupUrl.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC7D,qEAAqE;IACrE,OAAO,GAAG,sBAAU,IAAI,IAAI,gBAAgB,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;AACpG,CAAC;AAHD,sDAGC"}
@@ -1,5 +1,5 @@
1
1
  import type { Story } from '@prezly/sdk';
2
- export declare type EmbargoStory = Omit<Story, 'is_embargo' | 'published_at'> & {
2
+ export type EmbargoStory = Omit<Story, 'is_embargo' | 'published_at'> & {
3
3
  is_embargo: true;
4
4
  published_at: string;
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/theme-kit-nextjs",
3
- "version": "1.18.2",
3
+ "version": "1.18.4-0",
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",
@@ -9,12 +9,12 @@
9
9
  "src"
10
10
  ],
11
11
  "engines": {
12
- "node": ">= 14.x",
13
- "npm": ">= 7.x"
12
+ "node": ">= 16.x",
13
+ "npm": ">= 8.x"
14
14
  },
15
15
  "devEngines": {
16
- "node": ">= 14.x",
17
- "npm": ">= 7.x"
16
+ "node": ">= 16.x",
17
+ "npm": ">= 8.x"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  "clean": "rimraf build/ node_modules/",
32
32
  "build": "tsc --project .",
33
33
  "watch": "tsc --watch --preserveWatchOutput --project .",
34
- "test": "jest",
34
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
35
35
  "typecheck": "tsc --noEmit --incremental --project .",
36
36
  "lint": "eslint src",
37
37
  "lint:fix": "npm run lint -- --fix",
@@ -43,32 +43,32 @@
43
43
  "release:preview": "npm run prerelease && np --any-branch --no-release-draft --tag=preview"
44
44
  },
45
45
  "peerDependencies": {
46
- "next": "^12.x",
46
+ "next": "^12.x || ^13.x",
47
47
  "react": "^17.x || ^18.x",
48
48
  "react-dom": "^17.x || ^18.x"
49
49
  },
50
50
  "dependencies": {
51
- "@prezly/sdk": "^7.11.0-0",
51
+ "@prezly/sdk": "^11.8.1-cjs",
52
52
  "@prezly/uploadcare": "^2.3.4",
53
- "@react-hookz/web": "^14.2.2",
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.0",
59
- "@sentry/nextjs": "7.16.0",
60
- "@types/jest": "28.1.8",
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.22",
64
- "@types/react-dom": "18.0.7",
65
- "eslint": "8.26.0",
66
- "jest": "28.1.3",
63
+ "@types/react": "18.0.26",
64
+ "@types/react-dom": "18.0.9",
65
+ "eslint": "8.29.0",
66
+ "jest": "29.3.1",
67
67
  "np": "7.6.2",
68
- "prettier": "2.7.1",
68
+ "prettier": "2.8.0",
69
69
  "rimraf": "3.0.2",
70
- "ts-jest": "28.0.8",
71
- "typescript": "4.8.4"
70
+ "ts-jest": "29.0.3",
71
+ "typescript": "4.9.3"
72
72
  },
73
73
  "publishConfig": {
74
74
  "access": "public"
@@ -1,5 +1,4 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
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,
@@ -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: StoryLifecycleStatus.PUBLISHED,
33
- publication_status: StoryPublicationStatus.PUBLISHED,
34
- visibility: StoryVisibility.PUBLIC,
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: 'unknown',
58
- sign_in_flow: 'password',
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: NewsroomStatus.ACTIVE,
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: StoryLifecycleStatus.PUBLISHED,
152
- publication_status: StoryPublicationStatus.PUBLISHED,
153
- visibility: StoryVisibility.PUBLIC,
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: 'unknown',
168
- sign_in_flow: 'password',
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: NewsroomStatus.ACTIVE,
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: StoryLifecycleStatus.PUBLISHED,
251
- publication_status: StoryPublicationStatus.PUBLISHED,
252
- visibility: StoryVisibility.PUBLIC,
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: 'stories',
267
- sign_in_flow: 'google',
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: NewsroomStatus.ACTIVE,
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 { ExtraStoryFields, Story } from '@prezly/sdk';
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 ExtraStoryFields)[];
27
+ extraStoryFields?: (keyof Story.ExtraFields)[];
28
28
  pageSize?: number;
29
29
  }
30
30
 
@@ -1,4 +1,4 @@
1
- import type { ExtraStoryFields, Story } from '@prezly/sdk';
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 ExtraStoryFields)[];
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 { StoryVisibility } from '@prezly/sdk';
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 === StoryVisibility.PUBLIC;
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 ExtraStoryFields)[];
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: PrezlySDK;
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 = new PrezlySDK({
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
- return await this.sdk.stories.get(uuid);
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: typeof PrezlySDK.prototype.stories.search = (options) =>
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.list(this.newsroomUuid, {
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
- return await this.sdk.newsroomGalleries.get(this.newsroomUuid, uuid);
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, ExtraStoryFields, Story } from '@prezly/sdk';
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 ExtraStoryFields)[],
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 ExtraStoryFields)[],
50
+ include?: (keyof Story.ExtraFields)[],
51
51
  ) {
52
52
  const currentLocale = useCurrentLocale();
53
53
 
@@ -1,3 +1,4 @@
1
+ import { jest } from '@jest/globals';
1
2
  import {
2
3
  DEFAULT_LOCALE,
3
4
  DUMMY_DEFAULT_LOCALE,
@@ -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 StoryVisibility {
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): StoryVisibility[] {
20
+ function getAllowedTranslationVisibilityValues(story: ExtendedStory): Visibility[] {
20
21
  const { visibility } = story;
21
22
 
22
23
  switch (visibility) {
23
- case StoryVisibility.EMBARGO:
24
- return [StoryVisibility.EMBARGO, StoryVisibility.PUBLIC];
25
- case StoryVisibility.PRIVATE:
26
- return [StoryVisibility.PRIVATE, StoryVisibility.PUBLIC];
27
- case StoryVisibility.CONFIDENTIAL:
28
- return [StoryVisibility.CONFIDENTIAL, StoryVisibility.PRIVATE, StoryVisibility.PUBLIC];
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 [StoryVisibility.PUBLIC];
31
+ return [Visibility.PUBLIC];
31
32
  }
32
33
  }
33
34
 
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CultureRef, ExtraStoryFields, Story } from '@prezly/sdk';
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<ExtraStoryFields, 'thumbnail_image'> & {
33
+ Pick<Story.ExtraFields, 'thumbnail_image'> & {
34
34
  content_text: string;
35
35
  updated_at: number;
36
36
  published_at: number;
@@ -9,5 +9,5 @@ import { ASSETS_URL } from './constants';
9
9
  */
10
10
  export function getUploadcareGroupUrl(uuid: string, title: string) {
11
11
  // UploadCare doesn't like slashes in filenames even in encoded form.
12
- return `${ASSETS_URL}/${uuid}/archive/zip/${encodeURIComponent(title.replace('/', '_'))}.zip`;
12
+ return `${ASSETS_URL}/${uuid}/archive/zip/${encodeURIComponent(title.replace(/\//g, '_'))}.zip`;
13
13
  }