@newskit-render/core 4.23.29 → 4.24.0-alpha.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.
@@ -1,88 +0,0 @@
1
- /* eslint-disable import/no-anonymous-default-export */
2
- import { GET_UNIVERSAL_ARTICLE } from '../../queries/getUniversalArticle'
3
-
4
- export default [
5
- {
6
- request: {
7
- query: GET_UNIVERSAL_ARTICLE,
8
- variables: {
9
- publisher: 'DEMO',
10
- id: 'demo-1',
11
- },
12
- },
13
- result: {
14
- data: {
15
- universalArticle: {
16
- id: 'demo-6',
17
- url: 'https://mock-site-url/some-location',
18
- label: 'Mock label',
19
- slug: 'some-location',
20
- publisher: 'DEMO',
21
- headline:
22
- 'Mock Article: Lorem ipsum dolor sit amet consectetur adipiscing elit Lorem ipsum dolor sit amet consectetur adipiscing elit',
23
- kicker: 'Latest',
24
- authors: null,
25
- flags: [],
26
- topics: [
27
- {
28
- name: 'Some topic one',
29
- slug: 'some-topic-one',
30
- link: null,
31
- },
32
- {
33
- name: 'Some topic one',
34
- slug: 'some-topic-one',
35
- link: null,
36
- },
37
- ],
38
- template: null,
39
- bylines: [
40
- {
41
- type: 'author',
42
- slug: 'mock-author',
43
- name: 'Mock Author',
44
- },
45
- {
46
- value: 'Chief Mock Author',
47
- type: 'inline',
48
- },
49
- ],
50
- publishedDateTime: '2019-02-14T00:00:00.000Z',
51
- updatedDateTime: '2019-02-14T00:37:17.000Z',
52
- summary: {
53
- children: [
54
- {
55
- text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget lorem vel nunc feugiat malesuada ut ac nisi. Morbi odio ipsum, dignissim nec turpis vel, laoreet condimentum tortor. Duis laoreet tincidunt ullamcorper.',
56
- },
57
- {
58
- text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget lorem vel nunc feugiat malesuada ut ac nisi. Morbi odio ipsum, dignissim nec turpis vel, laoreet condimentum tortor. Duis laoreet tincidunt ullamcorper.',
59
- },
60
- {
61
- url: 'http://this-is-a-url/',
62
- text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget lorem vel nunc feugiat malesuada ut ac nisi. Morbi odio ipsum, dignissim nec turpis vel, laoreet condimentum tortor. Duis laoreet tincidunt ullamcorper.',
63
- },
64
- {
65
- text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget lorem vel nunc feugiat malesuada ut ac nisi. Morbi odio ipsum, dignissim nec turpis vel, laoreet condimentum tortor. Duis laoreet tincidunt ullamcorper.',
66
- },
67
- ],
68
- },
69
- media: {
70
- crops: null,
71
-
72
- accountId: 'brightcove-acc-id-mock',
73
- videoId: 'video-id-mock',
74
- posterImage: {
75
- crops: [
76
- {
77
- url: 'https://localhost:3000/video-thumbnail-artwork-mock.jpg',
78
- alt: null,
79
- aspectRatio: null,
80
- },
81
- ],
82
- },
83
- },
84
- },
85
- },
86
- },
87
- },
88
- ]
@@ -1,104 +0,0 @@
1
- import React from 'react'
2
- import { replaceConsoleAndSetTransactionName } from '../../../helpers/logger'
3
- import {
4
- createApolloClient,
5
- ClientTypes,
6
- getAcsCookie,
7
- Config,
8
- } from '@newskit-render/api'
9
- import { UserData } from '@newskit-render/my-account'
10
- import { ArticleRecommendationsProvider } from '@newskit-render/standalone-components'
11
- import { getHost } from '@newskit-render/shared-components'
12
- import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' /* cra-effected */
13
- import { GET_UNIVERSAL_ARTICLE } from '../../../queries'
14
- import ArticlePage, { UniversalArticle } from '../../../components/article'
15
- import { fetchUser } from '../../../helpers/getUser'
16
- import { getAccountQueryUrl } from '../../../constants'
17
- import { addCacheHeaders } from '../../../helpers/addCacheHeaders'
18
- import {
19
- twitterUsername as configTwitterUsername,
20
- gscId as configGscId,
21
- newskitApiEnvUrl,
22
- newskitApiXApiKey,
23
- optimizelysdkKey /* cra-effected */,
24
- } from '../../../config'
25
-
26
- export type ArticleSlug = {
27
- universalArticle: UniversalArticle
28
- articleURL: string
29
- twitterUsername: string
30
- siteHost: string
31
- gscId?: string
32
- user?: UserData
33
- articleId: string
34
- config: Config
35
- }
36
-
37
- const ArticleSlugPage: React.FC<ArticleSlug> = ({
38
- universalArticle,
39
- articleURL,
40
- twitterUsername,
41
- siteHost,
42
- gscId,
43
- user,
44
- articleId,
45
- config,
46
- }) => (
47
- <ArticleRecommendationsProvider articleId={articleId} config={config}>
48
- <ArticlePage
49
- articleURL={articleURL}
50
- {...universalArticle}
51
- siteHost={siteHost}
52
- gscId={gscId}
53
- twitterUsername={twitterUsername}
54
- user={user}
55
- />
56
- </ArticleRecommendationsProvider>
57
- )
58
-
59
- export async function getServerSideProps(context) {
60
- const apolloClient = await createApolloClient(ClientTypes.nkapi)
61
- const acsCookie = context.req.headers.cookie
62
- ? getAcsCookie(ClientTypes.main, context.req.headers.cookie)
63
- : ''
64
- const siteHost = getHost(context.req)
65
- const {
66
- params: { articleId, section, articleSlug },
67
- } = context
68
-
69
- replaceConsoleAndSetTransactionName(
70
- `Article: /${section}/${articleId}/${articleSlug}`
71
- )
72
-
73
- const [{ data }, user] = await Promise.all([
74
- apolloClient.query({
75
- query: GET_UNIVERSAL_ARTICLE,
76
- variables: { publisher: 'DEMO', id: articleId },
77
- }),
78
- await fetchUser(acsCookie, getAccountQueryUrl(siteHost)),
79
- ])
80
- /* start cra-effected */
81
- const featureFlags = await initAndGetFeatureFlag(optimizelysdkKey)
82
- /* end cra-effected */
83
-
84
- addCacheHeaders(context.res)
85
- return {
86
- props: {
87
- universalArticle: data.universalArticle,
88
- articleURL: `${siteHost}/${section}/${articleId}/${articleSlug}`,
89
- twitterUsername: configTwitterUsername || '',
90
- siteHost,
91
- gscId: configGscId || '',
92
- showAds: true,
93
- user,
94
- articleId,
95
- config: {
96
- newskitApiEnvUrl,
97
- newskitApiXApiKey,
98
- },
99
- featureFlags /* cra-effected */,
100
- },
101
- }
102
- }
103
-
104
- export default ArticleSlugPage
@@ -1,159 +0,0 @@
1
- import React from 'react'
2
- import {
3
- Block,
4
- IndeterminateProgressIndicator,
5
- Headline,
6
- Button,
7
- Banner,
8
- toNewsKitIcon,
9
- } from 'newskit'
10
- import {
11
- SessionProvider,
12
- PageWithAuth,
13
- getSession,
14
- signIn,
15
- signOut,
16
- CookieView,
17
- } from '@newskit-render/auth'
18
- import {
19
- createApolloClient,
20
- ClientTypes,
21
- getAcsCookie,
22
- } from '@newskit-render/api'
23
- import { ArticleRecommendationsProvider } from '@newskit-render/standalone-components'
24
- import { getHost } from '@newskit-render/shared-components'
25
- import { Info as FilledInfo } from '@emotion-icons/material/Info'
26
- import { GET_UNIVERSAL_ARTICLE } from '../../../../../queries'
27
- import ArticlePage from '../../../../../components/article'
28
- import { fetchUser } from '../../../../../helpers/getUser'
29
- import { getAccountQueryUrl } from '../../../../../constants'
30
- import { addCacheHeaders } from '../../../../../helpers/addCacheHeaders'
31
- import {
32
- twitterUsername as configTwitterUsername,
33
- gscId as configGscId,
34
- newskitApiEnvUrl,
35
- newskitApiXApiKey,
36
- } from '../../../../../config'
37
-
38
- const IconFilledInfo = toNewsKitIcon(FilledInfo)
39
-
40
- const PreviewArticle = ({
41
- universalArticle,
42
- section,
43
- articleURL,
44
- twitterUsername,
45
- siteHost,
46
- gscId,
47
- user,
48
- articleId,
49
- config,
50
- ...props
51
- }) => {
52
- let userId
53
- if (typeof window !== 'undefined') {
54
- userId = window?.utag?.data['cp.utag_main_v_id']
55
- }
56
- const accessDeniedPage = (
57
- <Banner
58
- overrides={{ stylePreset: 'bannerNotice' }}
59
- icon={<IconFilledInfo overrides={{ size: 'iconSize020' }} />}
60
- title="Access Denied"
61
- actions={[
62
- () => (
63
- <Button
64
- size="medium"
65
- onClick={() => signIn('okta')}
66
- overrides={{ stylePreset: 'buttonSolidInverse' }}
67
- >
68
- Sign in
69
- </Button>
70
- ),
71
- ]}
72
- >
73
- You must sign in to see preview articles
74
- </Banner>
75
- )
76
-
77
- const showOnLoading = (
78
- <Block>
79
- <Headline>...Loading</Headline>
80
- <IndeterminateProgressIndicator overrides={{}} />
81
- </Block>
82
- )
83
-
84
- return (
85
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
- <SessionProvider pageProps={props as unknown as any}>
87
- <PageWithAuth onDenied={accessDeniedPage} isLoading={showOnLoading}>
88
- <>
89
- <CookieView>
90
- <Button size="medium" onClick={() => signOut()}>
91
- sign out
92
- </Button>
93
- </CookieView>
94
- <ArticleRecommendationsProvider articleId={articleId} config={config}>
95
- <ArticlePage
96
- section={section}
97
- articleURL={articleURL}
98
- {...universalArticle}
99
- siteHost={siteHost}
100
- gscId={gscId}
101
- twitterUsername={twitterUsername}
102
- user={user}
103
- />
104
- </ArticleRecommendationsProvider>
105
- </>
106
- </PageWithAuth>
107
- </SessionProvider>
108
- )
109
- }
110
-
111
- export async function getServerSideProps(context) {
112
- const apolloClient = await createApolloClient(ClientTypes.nkapi)
113
- const session = await getSession(context)
114
- const acsCookie = context.req.headers.cookie
115
- ? getAcsCookie(ClientTypes.main, context.req.headers.cookie)
116
- : ''
117
- const siteHost = getHost(context.req)
118
- if (!session) {
119
- return {
120
- props: {},
121
- }
122
- }
123
- const {
124
- params: { articleId, versionId },
125
- } = context
126
-
127
- const [{ data }, user] = await Promise.all([
128
- apolloClient.query({
129
- query: GET_UNIVERSAL_ARTICLE,
130
- variables: {
131
- publisher: 'DEMO',
132
- id: articleId,
133
- version: versionId,
134
- },
135
- }),
136
- await fetchUser(acsCookie, getAccountQueryUrl(siteHost)),
137
- ])
138
-
139
- addCacheHeaders(context.res)
140
- return {
141
- props: {
142
- universalArticle: data.universalArticle,
143
- session,
144
- articleURL: `${siteHost}/preview/${articleId}/version/${versionId}`,
145
- twitterUsername: configTwitterUsername || '',
146
- siteHost,
147
- gscId: configGscId || '',
148
- showAds: true,
149
- user,
150
- articleId,
151
- config: {
152
- newskitApiEnvUrl,
153
- newskitApiXApiKey,
154
- },
155
- },
156
- }
157
- }
158
-
159
- export default PreviewArticle
@@ -1,68 +0,0 @@
1
- import { gql } from '@apollo/client'
2
-
3
- export const GET_UNIVERSAL_ARTICLE = gql`
4
- query getUniversalArticle($publisher: Publisher!, $id: ID!, $version: ID) {
5
- universalArticle(publisher: $publisher, id: $id, version: $version) {
6
- id
7
- url
8
- label
9
- slug
10
- publisher
11
- headline
12
- kicker
13
- flags
14
- topics {
15
- name
16
- slug
17
- link
18
- }
19
- template
20
- bylines {
21
- ... on TextByline {
22
- value
23
- type
24
- }
25
- ... on AuthorByline {
26
- type
27
- slug
28
- name
29
- }
30
- }
31
- publishedDateTime
32
- updatedDateTime
33
- summary {
34
- children {
35
- ... on ArticleText {
36
- text
37
- }
38
- ... on ArticleHyperlink {
39
- url
40
- text
41
- }
42
- }
43
- }
44
- media {
45
- ... on Image {
46
- crops {
47
- url
48
- alt
49
- aspectRatio
50
- }
51
- }
52
- ... on Video {
53
- accountId
54
- videoId
55
- posterImage {
56
- ... on Image {
57
- crops {
58
- url
59
- alt
60
- aspectRatio
61
- }
62
- }
63
- }
64
- }
65
- }
66
- }
67
- }
68
- `