@newskit-render/core 0.131.1 → 0.138.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/CHANGELOG.md +169 -0
- package/README.md +1 -1
- package/__pacts__/client.ts +10 -6
- package/__tests__/pages/[articleSlug].test.tsx +20 -7
- package/__tests__/pages/__snapshots__/home.test.tsx.snap +599 -690
- package/__tests__/pages/home.test.tsx +22 -10
- package/components/404/404.tsx +9 -5
- package/components/article/__tests__/__snapshots__/index.test.tsx.snap +650 -687
- package/components/common/NavLink.tsx +4 -3
- package/components/footer/__snapshots__/index.test.tsx.snap +15 -23
- package/components/header/index.tsx +4 -3
- package/components/section/__tests__/ArticleSlice.test.tsx +2 -2
- package/components/section/layouts/FallBack.tsx +3 -3
- package/components/section/layouts/SectionRow.tsx +4 -3
- package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +152 -167
- package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +857 -952
- package/helpers/addCacheHeaders.ts +8 -0
- package/infrastructure/.circleci/config.yml +2 -2
- package/jest.config.js +4 -0
- package/jest.config.pact.js +3 -2
- package/package.json +11 -9
- package/pages/[section]/[articleId]/[articleSlug].tsx +11 -4
- package/pages/[section]/index.tsx +11 -4
- package/pages/api/account/zuora/generate-rsa.ts +5 -0
- package/pages/index.tsx +11 -4
- package/pages/preview/[articleId]/version/[versionId]/index.tsx +4 -2
- package/temp/header.tsx +4 -3
- package/tsconfig.json +3 -2
- package/helpers/createApolloClient.tsx +0 -28
|
@@ -643,7 +643,7 @@ orbs:
|
|
|
643
643
|
source $BASH_ENV
|
|
644
644
|
CURRENT_VERSION=$(jq -r .version ./package.json)
|
|
645
645
|
|
|
646
|
-
npm install --no-save release-documentation-cli@
|
|
646
|
+
npm install --no-save release-documentation-cli@5.2.0
|
|
647
647
|
|
|
648
648
|
# If your tags are prefixed (i.e. lerna) check the --tagFilter parameter
|
|
649
649
|
echo "Creating a release request for $CURRENT_VERSION to be deployed to production."
|
|
@@ -668,7 +668,7 @@ orbs:
|
|
|
668
668
|
export CURRENT_VERSION=$(jq -r .version ./package.json)
|
|
669
669
|
echo "export CURRENT_VERSION=$CURRENT_VERSION" >> $BASH_ENV
|
|
670
670
|
|
|
671
|
-
npm install --no-save release-documentation-cli@
|
|
671
|
+
npm install --no-save release-documentation-cli@5.2.0
|
|
672
672
|
|
|
673
673
|
# If your tags are prefixed (i.e. lerna) check the --tagFilter parameter
|
|
674
674
|
$(npm bin)/release promote
|
package/jest.config.js
CHANGED
package/jest.config.pact.js
CHANGED
|
@@ -6,12 +6,13 @@ module.exports = {
|
|
|
6
6
|
],
|
|
7
7
|
globals: {
|
|
8
8
|
'ts-jest': {
|
|
9
|
-
|
|
9
|
+
tsconfig: 'tsconfig.test.json'
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
transform: {
|
|
13
13
|
'^.+\\.(ts|tsx)$': 'ts-jest',
|
|
14
14
|
},
|
|
15
15
|
modulePathIgnorePatterns: [],
|
|
16
|
-
moduleFileExtensions: ['ts', 'tsx', 'js', 'json']
|
|
16
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
|
17
|
+
preset: 'ts-jest/presets/js-with-ts',
|
|
17
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newskit-render/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.138.1",
|
|
4
4
|
"description": "Newskit Render - Core package",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -27,17 +27,19 @@
|
|
|
27
27
|
"lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --color --fix && prettier --write './**/*.{js,jsx,ts,tsx,json}'"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@apollo/client": "^3.
|
|
31
|
-
"@newskit-render/
|
|
32
|
-
"@newskit-render/
|
|
33
|
-
"@newskit-render/
|
|
34
|
-
"@newskit-render/
|
|
35
|
-
"@newskit-render/
|
|
30
|
+
"@apollo/client": "^3.4.16",
|
|
31
|
+
"@newskit-render/api": "^0.3.0",
|
|
32
|
+
"@newskit-render/auth": "^0.21.0",
|
|
33
|
+
"@newskit-render/checkout": "^0.4.0",
|
|
34
|
+
"@newskit-render/my-account": "^0.104.1",
|
|
35
|
+
"@newskit-render/shared-components": "^0.8.0",
|
|
36
|
+
"@newskit-render/sitemap": "^0.24.0",
|
|
37
|
+
"@newskit-render/validation": "^0.24.0",
|
|
36
38
|
"cross-fetch": "^3.1.4",
|
|
37
39
|
"graphql": "^15.6.0",
|
|
38
40
|
"newrelic": "^7.1.0",
|
|
39
|
-
"newskit": "^
|
|
40
|
-
"next": "^
|
|
41
|
+
"newskit": "^4.0.1",
|
|
42
|
+
"next": "^12.0.2",
|
|
41
43
|
"react": "^17.0.1",
|
|
42
44
|
"react-dom": "^17.0.2",
|
|
43
45
|
"react-helmet": "^6.1.0",
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import newrelic from 'newrelic'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createApolloClient,
|
|
5
|
+
sessionParser,
|
|
6
|
+
getMainSession,
|
|
7
|
+
ClientTypes,
|
|
8
|
+
} from '@newskit-render/api'
|
|
4
9
|
import { GET_UNIVERSAL_ARTICLE } from '../../../queries'
|
|
5
10
|
import ArticlePage, { UniversalArticle } from '../../../components/article'
|
|
6
11
|
import { highlights, relatedArticles } from '../../../helpers/mocks/articleMock'
|
|
7
|
-
import createApolloClient from '../../../helpers/createApolloClient'
|
|
8
12
|
import { UserData } from '../../../helpers/global-types'
|
|
9
13
|
import { fetchUser } from '../../../helpers/getUser'
|
|
10
14
|
import { ACCOUNT_QUERY_URL } from '../../../constants'
|
|
15
|
+
import { addCacheHeaders } from '../../../helpers/addCacheHeaders'
|
|
11
16
|
|
|
12
17
|
export type ArticleSlug = {
|
|
13
18
|
universalArticle: UniversalArticle
|
|
@@ -40,8 +45,9 @@ const Article: React.FC<ArticleSlug> = ({
|
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
export async function getServerSideProps(context) {
|
|
43
|
-
const apolloClient = createApolloClient(
|
|
44
|
-
const
|
|
48
|
+
const apolloClient = await createApolloClient(ClientTypes.nkapi)
|
|
49
|
+
const mainSession = getMainSession(context.req.headers.cookie)
|
|
50
|
+
const session = sessionParser(mainSession)
|
|
45
51
|
|
|
46
52
|
const {
|
|
47
53
|
params: { articleId, section, articleSlug },
|
|
@@ -59,6 +65,7 @@ export async function getServerSideProps(context) {
|
|
|
59
65
|
await fetchUser(session, ACCOUNT_QUERY_URL),
|
|
60
66
|
])
|
|
61
67
|
|
|
68
|
+
addCacheHeaders(context.res)
|
|
62
69
|
return {
|
|
63
70
|
props: {
|
|
64
71
|
universalArticle: data.universalArticle,
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import newrelic from 'newrelic'
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
createApolloClient,
|
|
4
|
+
sessionParser,
|
|
5
|
+
getMainSession,
|
|
6
|
+
ClientTypes,
|
|
7
|
+
} from '@newskit-render/api'
|
|
4
8
|
import { GET_PAGE } from '../../queries'
|
|
5
9
|
import SectionPage from '../../components/section'
|
|
6
10
|
import { fetchUser } from '../../helpers/getUser'
|
|
7
11
|
import { ACCOUNT_QUERY_URL } from '../../constants'
|
|
12
|
+
import { addCacheHeaders } from '../../helpers/addCacheHeaders'
|
|
8
13
|
|
|
9
14
|
export async function getServerSideProps(context) {
|
|
10
|
-
const apolloClient = createApolloClient(
|
|
15
|
+
const apolloClient = await createApolloClient(ClientTypes.nkapi)
|
|
11
16
|
|
|
12
17
|
const {
|
|
13
18
|
params: { section },
|
|
14
19
|
} = context
|
|
15
20
|
|
|
16
|
-
const
|
|
21
|
+
const mainSession = getMainSession(context.req.headers.cookie)
|
|
22
|
+
const session = sessionParser(mainSession)
|
|
17
23
|
|
|
18
24
|
newrelic.setTransactionName(`Section: ${section}`)
|
|
19
25
|
const [{ data }, user] = await Promise.all([
|
|
@@ -24,6 +30,7 @@ export async function getServerSideProps(context) {
|
|
|
24
30
|
await fetchUser(session, ACCOUNT_QUERY_URL),
|
|
25
31
|
])
|
|
26
32
|
|
|
33
|
+
addCacheHeaders(context.res)
|
|
27
34
|
return {
|
|
28
35
|
props: {
|
|
29
36
|
page: data.page,
|
package/pages/index.tsx
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import newrelic from 'newrelic'
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
createApolloClient,
|
|
4
|
+
sessionParser,
|
|
5
|
+
getMainSession,
|
|
6
|
+
ClientTypes,
|
|
7
|
+
} from '@newskit-render/api'
|
|
4
8
|
import { GET_PAGE } from '../queries'
|
|
5
9
|
import SectionPage from '../components/section'
|
|
6
10
|
import { fetchUser } from '../helpers/getUser'
|
|
7
11
|
import { ACCOUNT_QUERY_URL } from '../constants'
|
|
12
|
+
import { addCacheHeaders } from '../helpers/addCacheHeaders'
|
|
8
13
|
|
|
9
14
|
export async function getServerSideProps(context) {
|
|
10
15
|
newrelic.setTransactionName('Homepage')
|
|
11
16
|
console.warn('context:')
|
|
12
17
|
console.warn(context.req && context.req.headers)
|
|
13
18
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
19
|
+
const apolloClient = await createApolloClient(ClientTypes.nkapi)
|
|
20
|
+
const mainSession = getMainSession(context.req.headers.cookie)
|
|
21
|
+
const session = sessionParser(mainSession)
|
|
16
22
|
|
|
17
23
|
const [{ data }, user] = await Promise.all([
|
|
18
24
|
apolloClient.query({
|
|
@@ -22,6 +28,7 @@ export async function getServerSideProps(context) {
|
|
|
22
28
|
await fetchUser(session, ACCOUNT_QUERY_URL),
|
|
23
29
|
])
|
|
24
30
|
|
|
31
|
+
addCacheHeaders(context.res)
|
|
25
32
|
const { page } = data
|
|
26
33
|
return {
|
|
27
34
|
props: {
|
|
@@ -14,13 +14,14 @@ import {
|
|
|
14
14
|
signOut,
|
|
15
15
|
CookieView,
|
|
16
16
|
} from '@newskit-render/auth'
|
|
17
|
+
import { createApolloClient, ClientTypes } from '@newskit-render/api'
|
|
17
18
|
import { GET_UNIVERSAL_ARTICLE } from '../../../../../queries'
|
|
18
19
|
import ArticlePage from '../../../../../components/article'
|
|
19
20
|
import {
|
|
20
21
|
highlights,
|
|
21
22
|
relatedArticles,
|
|
22
23
|
} from '../../../../../helpers/mocks/articleMock'
|
|
23
|
-
import
|
|
24
|
+
import { addCacheHeaders } from '../../../../../helpers/addCacheHeaders'
|
|
24
25
|
|
|
25
26
|
const PreviewArticle = ({
|
|
26
27
|
universalArticle,
|
|
@@ -80,7 +81,7 @@ const PreviewArticle = ({
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export async function getServerSideProps(context) {
|
|
83
|
-
const apolloClient = createApolloClient(
|
|
84
|
+
const apolloClient = await createApolloClient(ClientTypes.nkapi)
|
|
84
85
|
const session = await getSession(context)
|
|
85
86
|
if (!session) {
|
|
86
87
|
return {
|
|
@@ -96,6 +97,7 @@ export async function getServerSideProps(context) {
|
|
|
96
97
|
variables: { publisher: 'DEMO', id: articleId, version: versionId },
|
|
97
98
|
})
|
|
98
99
|
|
|
100
|
+
addCacheHeaders(context.res)
|
|
99
101
|
return {
|
|
100
102
|
props: {
|
|
101
103
|
universalArticle: data.universalArticle,
|
package/temp/header.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
Cell,
|
|
4
|
-
LinkStandalone,
|
|
5
4
|
styled,
|
|
6
5
|
getColorCssFromTheme,
|
|
7
6
|
getSizingCssFromTheme,
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
Block,
|
|
13
12
|
IconFilledMenu,
|
|
14
13
|
} from 'newskit'
|
|
14
|
+
import { NextLink } from '@newskit-render/shared-components'
|
|
15
15
|
import { PastDueBannerExternal } from '@newskit-render/my-account'
|
|
16
16
|
import { MainGrid } from '../layout/MainGrid'
|
|
17
17
|
import NewsKitLogoFull from '../common/NewskitLogo'
|
|
@@ -160,7 +160,8 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
|
|
|
160
160
|
stackDistribution="space-between"
|
|
161
161
|
wrap="nowrap"
|
|
162
162
|
>
|
|
163
|
-
<
|
|
163
|
+
<NextLink
|
|
164
|
+
type="standalone"
|
|
164
165
|
overrides={{ stylePreset: 'linkStandaloneInverse' }}
|
|
165
166
|
href="/"
|
|
166
167
|
aria-label="Logo Link"
|
|
@@ -171,7 +172,7 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
|
|
|
171
172
|
<Visible xs sm>
|
|
172
173
|
<NewsKitLogoShort color="white" size="sizing120" />
|
|
173
174
|
</Visible>
|
|
174
|
-
</
|
|
175
|
+
</NextLink>
|
|
175
176
|
<Stack
|
|
176
177
|
flow="horizontal-center"
|
|
177
178
|
stackDistribution="flex-end"
|
package/tsconfig.json
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"useUnknownInCatchVariables": false,
|
|
19
19
|
"exactOptionalPropertyTypes": false,
|
|
20
20
|
"isolatedModules": true,
|
|
21
|
-
"jsx": "preserve"
|
|
21
|
+
"jsx": "preserve",
|
|
22
|
+
"incremental": true
|
|
22
23
|
},
|
|
23
24
|
"paths": {
|
|
24
25
|
"@newskit-render/*": [
|
|
@@ -42,4 +43,4 @@
|
|
|
42
43
|
".circleci",
|
|
43
44
|
"temp"
|
|
44
45
|
]
|
|
45
|
-
}
|
|
46
|
+
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ApolloClient,
|
|
3
|
-
createHttpLink,
|
|
4
|
-
InMemoryCache,
|
|
5
|
-
NormalizedCacheObject,
|
|
6
|
-
} from '@apollo/client'
|
|
7
|
-
import fetch from 'cross-fetch'
|
|
8
|
-
|
|
9
|
-
export default ({
|
|
10
|
-
initialState = {},
|
|
11
|
-
addTypename = true,
|
|
12
|
-
}: {
|
|
13
|
-
initialState?: NormalizedCacheObject
|
|
14
|
-
addTypename?: boolean
|
|
15
|
-
}) =>
|
|
16
|
-
new ApolloClient({
|
|
17
|
-
ssrMode: true,
|
|
18
|
-
link: createHttpLink({
|
|
19
|
-
uri: process.env.NEWSKIT_API_ENV_URL,
|
|
20
|
-
headers: {
|
|
21
|
-
'x-api-key': process.env.NEWSKIT_API_X_API_KEY,
|
|
22
|
-
},
|
|
23
|
-
fetch,
|
|
24
|
-
}),
|
|
25
|
-
name: 'ncu-newskit-render',
|
|
26
|
-
version: '0.1.0',
|
|
27
|
-
cache: new InMemoryCache({ addTypename }).restore(initialState),
|
|
28
|
-
})
|