@newskit-render/core 0.0.0-d55b7d88

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 (456) hide show
  1. package/.ci/trigger-circleci-workflow.sh +37 -0
  2. package/.eslintignore +23 -0
  3. package/.eslintrc +74 -0
  4. package/.prettierignore +19 -0
  5. package/.prettierrc +7 -0
  6. package/CHANGELOG.md +7638 -0
  7. package/Dockerfile +14 -0
  8. package/Dockerfile.withNewRelic +15 -0
  9. package/README.md +274 -0
  10. package/__tests__/pages/__snapshots__/brightcove.test.tsx.snap +20 -0
  11. package/__tests__/pages/__snapshots__/home.test.tsx.snap +1195 -0
  12. package/__tests__/pages/brightcove.test.tsx +34 -0
  13. package/__tests__/pages/empty.test.tsx +10 -0
  14. package/__tests__/pages/home.test.tsx +16 -0
  15. package/app-context/InstrumentationContextProvider.tsx +36 -0
  16. package/assets/fontFamily.ts +416 -0
  17. package/assets/fonts/Graphik-Black-App.ttf +0 -0
  18. package/assets/fonts/Graphik-BlackItalic-App.ttf +0 -0
  19. package/assets/fonts/Graphik-Bold-App.ttf +0 -0
  20. package/assets/fonts/Graphik-BoldItalic-App.ttf +0 -0
  21. package/assets/fonts/Graphik-Extralight-App.ttf +0 -0
  22. package/assets/fonts/Graphik-ExtralightItalic-App.ttf +0 -0
  23. package/assets/fonts/Graphik-Light-App.ttf +0 -0
  24. package/assets/fonts/Graphik-LightItalic-App.ttf +0 -0
  25. package/assets/fonts/Graphik-Medium-App.ttf +0 -0
  26. package/assets/fonts/Graphik-Medium-Web.woff2 +0 -0
  27. package/assets/fonts/Graphik-MediumItalic-App.ttf +0 -0
  28. package/assets/fonts/Graphik-Regular-App.ttf +0 -0
  29. package/assets/fonts/Graphik-Regular-Web.woff2 +0 -0
  30. package/assets/fonts/Graphik-RegularItalic-App.ttf +0 -0
  31. package/assets/fonts/Graphik-Semibold-App.ttf +0 -0
  32. package/assets/fonts/Graphik-Semibold-Web.woff2 +0 -0
  33. package/assets/fonts/Graphik-SemiboldItalic-App.ttf +0 -0
  34. package/assets/fonts/Graphik-Super-App.ttf +0 -0
  35. package/assets/fonts/Graphik-SuperItalic-App.ttf +0 -0
  36. package/assets/fonts/Graphik-Thin-App.ttf +0 -0
  37. package/assets/fonts/Graphik-ThinItalic-App.ttf +0 -0
  38. package/assets/fonts/Montserrat-Black.ttf +0 -0
  39. package/assets/fonts/Montserrat-BlackItalic.ttf +0 -0
  40. package/assets/fonts/Montserrat-Bold.ttf +0 -0
  41. package/assets/fonts/Montserrat-BoldItalic.ttf +0 -0
  42. package/assets/fonts/Montserrat-ExtraBold.ttf +0 -0
  43. package/assets/fonts/Montserrat-ExtraBoldItalic.ttf +0 -0
  44. package/assets/fonts/Montserrat-ExtraLight.ttf +0 -0
  45. package/assets/fonts/Montserrat-ExtraLightItalic.ttf +0 -0
  46. package/assets/fonts/Montserrat-Italic.ttf +0 -0
  47. package/assets/fonts/Montserrat-Light.ttf +0 -0
  48. package/assets/fonts/Montserrat-LightItalic.ttf +0 -0
  49. package/assets/fonts/Montserrat-Medium.ttf +0 -0
  50. package/assets/fonts/Montserrat-MediumItalic.ttf +0 -0
  51. package/assets/fonts/Montserrat-Regular.ttf +0 -0
  52. package/assets/fonts/Montserrat-SemiBold.ttf +0 -0
  53. package/assets/fonts/Montserrat-SemiBoldItalic.ttf +0 -0
  54. package/assets/fonts/Montserrat-Thin.ttf +0 -0
  55. package/assets/fonts/Montserrat-ThinItalic.ttf +0 -0
  56. package/assets/fonts/PublicoHeadline-Black-App.ttf +0 -0
  57. package/assets/fonts/PublicoHeadline-BlackItalic-App.ttf +0 -0
  58. package/assets/fonts/PublicoHeadline-Bold-App.ttf +0 -0
  59. package/assets/fonts/PublicoHeadline-Bold-Web.woff2 +0 -0
  60. package/assets/fonts/PublicoHeadline-BoldItalic-App.ttf +0 -0
  61. package/assets/fonts/PublicoHeadline-Extrabold-App.ttf +0 -0
  62. package/assets/fonts/PublicoHeadline-ExtraboldItalic-App.ttf +0 -0
  63. package/assets/fonts/PublicoHeadline-Italic-App.ttf +0 -0
  64. package/assets/fonts/PublicoHeadline-Light-App.ttf +0 -0
  65. package/assets/fonts/PublicoHeadline-LightItalic-App.ttf +0 -0
  66. package/assets/fonts/PublicoHeadline-Medium-App.ttf +0 -0
  67. package/assets/fonts/PublicoHeadline-MediumItalic-App.ttf +0 -0
  68. package/assets/fonts/PublicoHeadline-Roman-App.ttf +0 -0
  69. package/assets/fonts/PublicoHeadline-Roman-Web.woff2 +0 -0
  70. package/assets/fonts/PublicoText-Bold-App.ttf +0 -0
  71. package/assets/fonts/PublicoText-BoldItalic-App.ttf +0 -0
  72. package/assets/fonts/PublicoText-Italic-App.ttf +0 -0
  73. package/assets/fonts/PublicoText-Italic-Web.woff2 +0 -0
  74. package/assets/fonts/PublicoText-Roman-App.ttf +0 -0
  75. package/assets/fonts/PublicoText-Roman-Web.woff2 +0 -0
  76. package/assets/fonts/PublicoText-Semibold-App.ttf +0 -0
  77. package/assets/fonts/PublicoText-SemiboldItalic-App.ttf +0 -0
  78. package/assets/fonts/Roboto-Bold.ttf +0 -0
  79. package/assets/fonts/Roboto-Light.ttf +0 -0
  80. package/assets/fonts/Roboto-Medium.ttf +0 -0
  81. package/assets/fonts/Roboto-Regular.ttf +0 -0
  82. package/assets/fonts/TheSun-Bold.ttf +0 -0
  83. package/assets/fonts/TheSun-BoldItalic.ttf +0 -0
  84. package/assets/fonts/TheSun-HeavyCondensed.ttf +0 -0
  85. package/assets/fonts/TheSun-HeavyNarrow.ttf +0 -0
  86. package/assets/fonts/TheSun-Italic.ttf +0 -0
  87. package/assets/fonts/TheSun-Medium.ttf +0 -0
  88. package/assets/fonts/TheSun-MediumItalic.ttf +0 -0
  89. package/assets/fonts/TheSun-Regular.ttf +0 -0
  90. package/assets/fonts/TimesDigital-Bold.ttf +0 -0
  91. package/assets/fonts/TimesDigital-BoldItalic.ttf +0 -0
  92. package/assets/fonts/TimesDigital-BoldSC.ttf +0 -0
  93. package/assets/fonts/TimesDigital-Italic.ttf +0 -0
  94. package/assets/fonts/TimesDigital-Regular.ttf +0 -0
  95. package/assets/fonts/TimesDigital-RegularSC.ttf +0 -0
  96. package/assets/fonts/TimesDigitalW04-Bold.ttf +0 -0
  97. package/assets/fonts/TimesDigitalW04-BoldItalic.ttf +0 -0
  98. package/assets/fonts/TimesDigitalW04-BoldSC.ttf +0 -0
  99. package/assets/fonts/TimesDigitalW04-Italic.ttf +0 -0
  100. package/assets/fonts/TimesDigitalW04-Regular.ttf +0 -0
  101. package/assets/fonts/TimesDigitalW04-RegularSC.ttf +0 -0
  102. package/assets/fonts/TimesModern-Regular.otf +0 -0
  103. package/assets/fonts/attribuitions.mdx +35 -0
  104. package/assets/fonts/bitter-medium.woff +0 -0
  105. package/assets/fonts/bitter-medium.woff2 +0 -0
  106. package/assets/fonts/bitter-mediumitalic.woff +0 -0
  107. package/assets/fonts/bitter-mediumitalic.woff2 +0 -0
  108. package/assets/fonts/bitter-regular.woff +0 -0
  109. package/assets/fonts/bitter-regular.woff2 +0 -0
  110. package/assets/fonts/bitter-semibold.woff +0 -0
  111. package/assets/fonts/bitter-semibold.woff2 +0 -0
  112. package/assets/fonts/dmmono-medium.woff +0 -0
  113. package/assets/fonts/dmmono-medium.woff2 +0 -0
  114. package/assets/fonts/dmsans-bold-webfont.woff +0 -0
  115. package/assets/fonts/dmsans-bold-webfont.woff2 +0 -0
  116. package/assets/fonts/dmsans-bolditalic-webfont.woff +0 -0
  117. package/assets/fonts/dmsans-bolditalic-webfont.woff2 +0 -0
  118. package/assets/fonts/dmsans-italic-webfont.woff +0 -0
  119. package/assets/fonts/dmsans-italic-webfont.woff2 +0 -0
  120. package/assets/fonts/dmsans-medium-webfont.woff +0 -0
  121. package/assets/fonts/dmsans-medium-webfont.woff2 +0 -0
  122. package/assets/fonts/dmsans-mediumitalic-webfont.woff +0 -0
  123. package/assets/fonts/dmsans-mediumitalic-webfont.woff2 +0 -0
  124. package/assets/fonts/dmsans-regular-webfont.woff +0 -0
  125. package/assets/fonts/dmsans-regular-webfont.woff2 +0 -0
  126. package/assets/fonts/notosans-bold-webfont.woff +0 -0
  127. package/assets/fonts/notosans-bold-webfont.woff2 +0 -0
  128. package/assets/fonts/notosans-italic-webfont.woff +0 -0
  129. package/assets/fonts/notosans-italic-webfont.woff2 +0 -0
  130. package/assets/fonts/notosans-medium-webfont.woff +0 -0
  131. package/assets/fonts/notosans-medium-webfont.woff2 +0 -0
  132. package/assets/fonts/notosans-regular-webfont.woff +0 -0
  133. package/assets/fonts/notosans-regular-webfont.woff2 +0 -0
  134. package/assets/fonts/poppins-bold-webfont.woff +0 -0
  135. package/assets/fonts/poppins-bold-webfont.woff2 +0 -0
  136. package/assets/fonts/poppins-bolditalic-webfont.woff +0 -0
  137. package/assets/fonts/poppins-bolditalic-webfont.woff2 +0 -0
  138. package/assets/fonts/poppins-extrabold-webfont.woff +0 -0
  139. package/assets/fonts/poppins-extrabold-webfont.woff2 +0 -0
  140. package/assets/fonts/poppins-extrabolditalic-webfont.woff +0 -0
  141. package/assets/fonts/poppins-extrabolditalic-webfont.woff2 +0 -0
  142. package/assets/fonts/poppins-italic-webfont.woff +0 -0
  143. package/assets/fonts/poppins-italic-webfont.woff2 +0 -0
  144. package/assets/fonts/poppins-light-webfont.woff +0 -0
  145. package/assets/fonts/poppins-light-webfont.woff2 +0 -0
  146. package/assets/fonts/poppins-lightitalic-webfont.woff +0 -0
  147. package/assets/fonts/poppins-lightitalic-webfont.woff2 +0 -0
  148. package/assets/fonts/poppins-medium-webfont.woff +0 -0
  149. package/assets/fonts/poppins-medium-webfont.woff2 +0 -0
  150. package/assets/fonts/poppins-mediumitalic-webfont.woff +0 -0
  151. package/assets/fonts/poppins-mediumitalic-webfont.woff2 +0 -0
  152. package/assets/fonts/poppins-regular-webfont.woff +0 -0
  153. package/assets/fonts/poppins-regular-webfont.woff2 +0 -0
  154. package/assets/fonts/poppins-semibold-webfont.woff +0 -0
  155. package/assets/fonts/poppins-semibold-webfont.woff2 +0 -0
  156. package/assets/fonts/poppins-semibolditalic-webfont.woff +0 -0
  157. package/assets/fonts/poppins-semibolditalic-webfont.woff2 +0 -0
  158. package/assets/fonts/source-serif-pro-600.woff +0 -0
  159. package/assets/fonts/source-serif-pro-600.woff2 +0 -0
  160. package/assets/fonts/source-serif-pro-600italic.woff +0 -0
  161. package/assets/fonts/source-serif-pro-600italic.woff2 +0 -0
  162. package/assets/fonts/source-serif-pro-700.woff +0 -0
  163. package/assets/fonts/source-serif-pro-700.woff2 +0 -0
  164. package/assets/fonts/source-serif-pro-700italic.woff +0 -0
  165. package/assets/fonts/source-serif-pro-700italic.woff2 +0 -0
  166. package/assets/fonts/source-serif-pro-italic.woff +0 -0
  167. package/assets/fonts/source-serif-pro-italic.woff2 +0 -0
  168. package/assets/fonts/source-serif-pro-regular.woff +0 -0
  169. package/assets/fonts/source-serif-pro-regular.woff2 +0 -0
  170. package/components/AccountDropdown/AccountDropdown.tsx +65 -0
  171. package/components/AccountDropdown/__tests__/AcountDropdown.test.tsx +83 -0
  172. package/components/AccountDropdown/accounts.ts +47 -0
  173. package/components/AccountDropdown/index.tsx +2 -0
  174. package/components/AccountDropdown/utils.ts +21 -0
  175. package/components/ErrorPage/ErrorPage.tsx +135 -0
  176. package/components/ad/index.tsx +35 -0
  177. package/components/article/Highlights.tsx +77 -0
  178. package/components/article/MetaBox.tsx +50 -0
  179. package/components/article/RelatedArticles.tsx +53 -0
  180. package/components/article/RelatedTopics.tsx +59 -0
  181. package/components/article/ShareBarComponent.tsx +53 -0
  182. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +1568 -0
  183. package/components/article/__tests__/index.test.tsx +171 -0
  184. package/components/article/__tests__/mocks.ts +105 -0
  185. package/components/article/index.tsx +320 -0
  186. package/components/common/BackToHomepage.tsx +37 -0
  187. package/components/common/NavLink.tsx +26 -0
  188. package/components/common/NewskitLogo.tsx +52 -0
  189. package/components/common/NewskitLogoShort.tsx +48 -0
  190. package/components/common/SectionTitleBar.tsx +57 -0
  191. package/components/common/ShareButton.tsx +18 -0
  192. package/components/common/ViewMoreButton.tsx +20 -0
  193. package/components/common/iconNavLink/IconNavLink.tsx +70 -0
  194. package/components/common/iconNavLink/__tests__/IconNavLink.test.tsx +35 -0
  195. package/components/common/iconNavLink/index.ts +3 -0
  196. package/components/common/iconNavLink/types.ts +24 -0
  197. package/components/common/icons/IconAccount.tsx +13 -0
  198. package/components/common/icons/IconFilledTwitter.tsx +14 -0
  199. package/components/common/icons/StyledIconFilledChevronRight.tsx +12 -0
  200. package/components/footer/__snapshots__/index.test.tsx.snap +192 -0
  201. package/components/footer/index.test.tsx +13 -0
  202. package/components/footer/index.tsx +151 -0
  203. package/components/header/banner-messages.ts +39 -0
  204. package/components/header/index.tsx +52 -0
  205. package/components/header/navigation-links.ts +20 -0
  206. package/components/layout/Gutter.tsx +11 -0
  207. package/components/layout/LayoutTemplate.tsx +26 -0
  208. package/components/layout/MainGrid.tsx +66 -0
  209. package/components/layout/index.tsx +3 -0
  210. package/components/layout/layoutTypes.ts +13 -0
  211. package/components/section/ArticleSlice.tsx +35 -0
  212. package/components/section/CollectionBlock.tsx +54 -0
  213. package/components/section/SectionContext.tsx +9 -0
  214. package/components/section/__tests__/ArticleSlice.test.tsx +128 -0
  215. package/components/section/__tests__/CollectionBlock.test.tsx +83 -0
  216. package/components/section/__tests__/pageBlock.test.tsx +24 -0
  217. package/components/section/__tests__/sectionUtils.test.ts +94 -0
  218. package/components/section/index.tsx +39 -0
  219. package/components/section/layouts/Block.tsx +79 -0
  220. package/components/section/layouts/FallBack.tsx +24 -0
  221. package/components/section/layouts/Lead.tsx +43 -0
  222. package/components/section/layouts/Rows.tsx +82 -0
  223. package/components/section/layouts/SectionTitle.tsx +57 -0
  224. package/components/section/layouts/__tests__/Lead.test.tsx +37 -0
  225. package/components/section/layouts/__tests__/Rows.test.tsx +40 -0
  226. package/components/section/layouts/__tests__/SectionTitle.test.tsx +37 -0
  227. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +180 -0
  228. package/components/section/layouts/__tests__/__snapshots__/SectionTitle.test.tsx.snap +354 -0
  229. package/components/section/layouts/gridUtils.ts +21 -0
  230. package/components/section/layouts/index.tsx +4 -0
  231. package/components/section/layouts/types.ts +13 -0
  232. package/components/section/pageBlock.tsx +23 -0
  233. package/components/section/sectionUtils.ts +61 -0
  234. package/components/teaser/index.test.tsx +50 -0
  235. package/components/teaser/index.tsx +64 -0
  236. package/components/teaser/teaserVariants.ts +33 -0
  237. package/components/teaser/variant-types.ts +49 -0
  238. package/components/teaser/variants/featureVariant.ts +42 -0
  239. package/components/teaser/variants/horizontal.ts +14 -0
  240. package/components/teaser/variants/titleTeaserVariant.ts +32 -0
  241. package/components/teaser/variants/titleVertical.ts +24 -0
  242. package/components/utils/index.test.ts +12 -0
  243. package/components/utils/index.ts +6 -0
  244. package/config/__tests__/index.test.ts +54 -0
  245. package/config/environment.ts +80 -0
  246. package/config/index.ts +2 -0
  247. package/config/multiTenancy.ts +11 -0
  248. package/constants/index.ts +2 -0
  249. package/context/app-context/AppContext.test.tsx +56 -0
  250. package/context/app-context/holidayStopListContextOverrides.ts +18 -0
  251. package/context/app-context/index.tsx +34 -0
  252. package/context/app-context/paymentMethodContext.tsx +70 -0
  253. package/context/index.tsx +2 -0
  254. package/context/multi-tenancy/MultiTenancy.test.tsx +48 -0
  255. package/context/multi-tenancy/index.tsx +32 -0
  256. package/css/index.ts +15 -0
  257. package/cypress/axe/terminal-log.js +19 -0
  258. package/cypress/config/visual.config.ts +11 -0
  259. package/cypress/config/visual.skip.config.ts +10 -0
  260. package/cypress/e2e/account/accessibility.cy.js +88 -0
  261. package/cypress/e2e/account/banners.cy.js +169 -0
  262. package/cypress/e2e/account/cancellation.cy.js +219 -0
  263. package/cypress/e2e/account/holiday-stops.cy.js +109 -0
  264. package/cypress/e2e/account/main-api.cy.js +102 -0
  265. package/cypress/e2e/account/newsletters-and-alerts.cy.js +149 -0
  266. package/cypress/e2e/account/newsletters-page.cy.js +69 -0
  267. package/cypress/e2e/account/payment-page.cy.js +98 -0
  268. package/cypress/e2e/account/personal-details.cy.js +1161 -0
  269. package/cypress/e2e/account/subscription-and-billing.cy.js +434 -0
  270. package/cypress/e2e/checkout/account-creation.cy.js +8 -0
  271. package/cypress/e2e/checkout/payment-details.cy.js +19 -0
  272. package/cypress/e2e/core/home-page.cy.js +6 -0
  273. package/cypress/e2e/help-hub/accessibility.cy.js +35 -0
  274. package/cypress/e2e/help-hub/article-page.cy.js +115 -0
  275. package/cypress/e2e/help-hub/landing-page.cy.js +94 -0
  276. package/cypress/e2e/help-hub/result-page.cy.js +117 -0
  277. package/cypress/fixtures/empty.html +10 -0
  278. package/cypress/fixtures/example.json +5 -0
  279. package/cypress/fixtures/holiday-stops.json +40 -0
  280. package/cypress/fixtures/paymentFailure.js +24 -0
  281. package/cypress/fixtures/testDates.js +26 -0
  282. package/cypress/support/commands.js +125 -0
  283. package/cypress/support/consentValues.js +5839 -0
  284. package/cypress/support/e2e.js +22 -0
  285. package/cypress/support/users.js +58 -0
  286. package/cypress/visual/account/print-visual-regression.cy.js +9 -0
  287. package/cypress/visual/account/visual-regression.cy.js +40 -0
  288. package/cypress/visual/empty/empty.cy.js +5 -0
  289. package/cypress.config.ts +38 -0
  290. package/helpers/__tests__/getUser.test.ts +45 -0
  291. package/helpers/__tests__/logger.test.ts +62 -0
  292. package/helpers/__tests__/useThemeDropdownObject.test.ts +49 -0
  293. package/helpers/a11y.ts +7 -0
  294. package/helpers/addCacheHeaders.ts +8 -0
  295. package/helpers/getUser.ts +37 -0
  296. package/helpers/getYear.ts +1 -0
  297. package/helpers/global-types.ts +186 -0
  298. package/helpers/logger/getWinstonLogger.ts +19 -0
  299. package/helpers/logger/index.ts +20 -0
  300. package/helpers/logger/replaceConsoleWithLogger.ts +14 -0
  301. package/helpers/mocks/articleMock.ts +50 -0
  302. package/helpers/mocks/getPageMock.ts +369 -0
  303. package/helpers/mocks/getRadioPostMock.ts +71 -0
  304. package/helpers/mocks/getRadioPostsMock.ts +26 -0
  305. package/helpers/mocks/getRecommendationsMock.ts +20 -0
  306. package/helpers/mocks/index.ts +7 -0
  307. package/helpers/multiTenancy.ts +19 -0
  308. package/helpers/setupTests.ts +5 -0
  309. package/helpers/test-utils.tsx +33 -0
  310. package/helpers/useThemeDropdownObject.tsx +73 -0
  311. package/infrastructure/.circleci/config.yml +1187 -0
  312. package/infrastructure/INFRASTRUCTURE.md +142 -0
  313. package/infrastructure/build_and_deploy.png +0 -0
  314. package/infrastructure/helm/Chart.yaml +21 -0
  315. package/infrastructure/helm/templates/_helpers.tpl +87 -0
  316. package/infrastructure/helm/templates/deployment.yaml +45 -0
  317. package/infrastructure/helm/templates/horizontalpodautoscaler.yaml +21 -0
  318. package/infrastructure/helm/templates/ingress.yaml +31 -0
  319. package/infrastructure/helm/templates/networkpolicy.yaml +26 -0
  320. package/infrastructure/helm/templates/secret.yaml +12 -0
  321. package/infrastructure/helm/templates/service.yaml +15 -0
  322. package/infrastructure/helm/values-dev.yaml +39 -0
  323. package/infrastructure/helm/values-local.yaml +30 -0
  324. package/infrastructure/helm/values-pr.yaml +40 -0
  325. package/infrastructure/helm/values-prod.yaml +39 -0
  326. package/infrastructure/helm/values-staging.yaml +39 -0
  327. package/infrastructure/helm/values.yaml +44 -0
  328. package/infrastructure/pull_request.png +0 -0
  329. package/infrastructure/release-documentation-cli.config.json +18 -0
  330. package/infrastructure/remove_pr.png +0 -0
  331. package/infrastructure/terraform-ecr/dev.tfvars +3 -0
  332. package/infrastructure/terraform-ecr/ecr.tf +69 -0
  333. package/infrastructure/terraform-ecr/main.tf +3 -0
  334. package/infrastructure/terraform-ecr/variables.tf +19 -0
  335. package/infrastructure/terraform-ecr/versions.tf +12 -0
  336. package/infrastructure/terraform-newrelic/alerts.tf +290 -0
  337. package/infrastructure/terraform-newrelic/dashboards.tf +347 -0
  338. package/infrastructure/terraform-newrelic/dev.tfvars +3 -0
  339. package/infrastructure/terraform-newrelic/lighthouse-script-dev.js +53 -0
  340. package/infrastructure/terraform-newrelic/lighthouse-script-prod.js +54 -0
  341. package/infrastructure/terraform-newrelic/lighthouse-script-stage.js +54 -0
  342. package/infrastructure/terraform-newrelic/main.tf +11 -0
  343. package/infrastructure/terraform-newrelic/monitors.tf +11 -0
  344. package/infrastructure/terraform-newrelic/prod.tfvars +3 -0
  345. package/infrastructure/terraform-newrelic/staging.tfvars +3 -0
  346. package/infrastructure/terraform-newrelic/variables.tf +33 -0
  347. package/infrastructure/terraform-newrelic/versions.tf +18 -0
  348. package/jest.config.js +40 -0
  349. package/jest.config.pact.js +18 -0
  350. package/newrelic.js +86 -0
  351. package/next-env.d.ts +5 -0
  352. package/next.config.js +95 -0
  353. package/package.json +127 -0
  354. package/pages/_app.tsx +117 -0
  355. package/pages/_document.tsx +112 -0
  356. package/pages/_error.tsx +68 -0
  357. package/pages/account/add/[field].tsx +34 -0
  358. package/pages/account/cancellation/index.tsx +22 -0
  359. package/pages/account/delete/confirm/index.tsx +16 -0
  360. package/pages/account/delete/error/index.tsx +16 -0
  361. package/pages/account/delete/index.tsx +16 -0
  362. package/pages/account/delete/success/index.tsx +16 -0
  363. package/pages/account/dream-team/index.tsx +19 -0
  364. package/pages/account/edit/[field].tsx +45 -0
  365. package/pages/account/family/index.tsx +19 -0
  366. package/pages/account/holiday-stop/index.tsx +19 -0
  367. package/pages/account/holiday-stop/previous-holiday-stops.tsx +19 -0
  368. package/pages/account/holiday-stop/upcoming-holiday-stops.tsx +19 -0
  369. package/pages/account/index.tsx +33 -0
  370. package/pages/account/newsletters/index.tsx +19 -0
  371. package/pages/account/newsletters-and-alerts/index.tsx +24 -0
  372. package/pages/account/payment/[paymentMethod].tsx +37 -0
  373. package/pages/account/payment/index.tsx +23 -0
  374. package/pages/account/payment-methods/index.tsx +21 -0
  375. package/pages/account/subscription-and-billing/index.tsx +29 -0
  376. package/pages/api/account/get-session/index.ts +33 -0
  377. package/pages/api/account/invoice/index.ts +35 -0
  378. package/pages/api/account/mutate/index.ts +8 -0
  379. package/pages/api/account/query/index.ts +7 -0
  380. package/pages/api/auth/[...nextauth].ts +11 -0
  381. package/pages/api/competitions-sitemap.ts +19 -0
  382. package/pages/api/feed.ts +23 -0
  383. package/pages/api/health-check.ts +7 -0
  384. package/pages/api/news-sitemap.ts +18 -0
  385. package/pages/api/pages-sitemap.ts +27 -0
  386. package/pages/api/robots.ts +19 -0
  387. package/pages/api/sitemap.ts +24 -0
  388. package/pages/checkout/account-creation/index.tsx +13 -0
  389. package/pages/checkout/payment-details/index.tsx +10 -0
  390. package/pages/empty.tsx +6 -0
  391. package/pages/help-hub/article/[title]/index.tsx +25 -0
  392. package/pages/help-hub/error.tsx +23 -0
  393. package/pages/help-hub/index.tsx +51 -0
  394. package/pages/help-hub/results.tsx +25 -0
  395. package/pages/index.tsx +19 -0
  396. package/pages/player/brightcove.tsx +19 -0
  397. package/pages/rss/create/index.tsx +18 -0
  398. package/pages/rss/feed/[feedId]/index.tsx +21 -0
  399. package/pages/rss/index.tsx +18 -0
  400. package/public/ads.min.js +8175 -0
  401. package/public/assets/display-base-header.svg +25 -0
  402. package/public/assets/display-personalDetails-header-sun.svg +55 -0
  403. package/public/assets/display-personalDetails-header-times.svg +90 -0
  404. package/public/assets/display-personalDetails-header-vr.svg +46 -0
  405. package/public/assets/dream-team.svg +10 -0
  406. package/public/assets/navigationPrimary-brandMark-sun.svg +9 -0
  407. package/public/assets/navigationPrimary-brandMark-times.svg +18 -0
  408. package/public/assets/navigationPrimary-brandMark-vr.svg +10 -0
  409. package/public/assets/newsletters/bestoftimes-101.png +0 -0
  410. package/public/assets/newsletters/books-115.png +0 -0
  411. package/public/assets/newsletters/environment-140.png +0 -0
  412. package/public/assets/newsletters/fashion-108.png +0 -0
  413. package/public/assets/newsletters/food-106.png +0 -0
  414. package/public/assets/newsletters/football-111.png +0 -0
  415. package/public/assets/newsletters/ireland-152.png +0 -0
  416. package/public/assets/newsletters/law-121.png +0 -0
  417. package/public/assets/newsletters/money-107.png +0 -0
  418. package/public/assets/newsletters/moneymentor-150.png +0 -0
  419. package/public/assets/newsletters/placeholder.png +0 -0
  420. package/public/assets/newsletters/politics-119.png +0 -0
  421. package/public/assets/newsletters/property-113.png +0 -0
  422. package/public/assets/newsletters/puzzles-125.png +0 -0
  423. package/public/assets/newsletters/scotland-134.png +0 -0
  424. package/public/assets/newsletters/theatre-127.png +0 -0
  425. package/public/assets/newsletters/travel-149.png +0 -0
  426. package/public/assets/newsletters/tv-133.png +0 -0
  427. package/public/assets/newsletters/us-153.png +0 -0
  428. package/public/assets/no-subscription.svg +15 -0
  429. package/public/assets/pending-activation.svg +16 -0
  430. package/public/assets/personal-details-header.svg +91 -0
  431. package/public/assets/plchldr150x100.png +0 -0
  432. package/public/assets/previous-subscription.svg +15 -0
  433. package/public/assets/primary-navigation-logo-white.svg +6 -0
  434. package/public/assets/primary-navigation-logo.svg +6 -0
  435. package/public/assets/tls-logo-white.svg +3 -0
  436. package/public/favicon.ico +0 -0
  437. package/public/icon.png +0 -0
  438. package/public/prebid.min.js +1 -0
  439. package/queries/getPage.ts +100 -0
  440. package/queries/getRadioPost.ts +61 -0
  441. package/queries/getRadioPosts.ts +16 -0
  442. package/queries/getUserSubscription.ts +9 -0
  443. package/queries/index.ts +3 -0
  444. package/scripts/k8s-local.sh +137 -0
  445. package/scripts/nr-exports.sh +7 -0
  446. package/temp/_app.tsx +15 -0
  447. package/temp/_document.tsx +61 -0
  448. package/temp/app-context-test.tsx +51 -0
  449. package/temp/app-context.tsx +25 -0
  450. package/temp/config-index.ts +1 -0
  451. package/temp/context-index.tsx +1 -0
  452. package/temp/header.tsx +45 -0
  453. package/temp/next.config.js +56 -0
  454. package/tsconfig.json +51 -0
  455. package/tsconfig.test.json +6 -0
  456. package/validation/index.tsx +24 -0
package/newrelic.js ADDED
@@ -0,0 +1,86 @@
1
+ 'use strict'
2
+ /**
3
+ * New Relic agent configuration.
4
+ *
5
+ * See lib/config/default.js in the agent distribution for a more complete
6
+ * description of configuration variables and their potential values.
7
+ */
8
+ exports.config = {
9
+ /**
10
+ * Array of application names.
11
+ */
12
+ app_name: [process.env.NEW_RELIC_APP_NAME],
13
+ /**
14
+ * Your New Relic license key.
15
+ */
16
+ license_key: process.env.NEW_RELIC_LICENSE_KEY,
17
+ /**
18
+ * This setting controls distributed tracing.
19
+ * Distributed tracing lets you see the path that a request takes through your
20
+ * distributed system. Enabling distributed tracing changes the behavior of some
21
+ * New Relic features, so carefully consult the transition guide before you enable
22
+ * this feature: https://docs.newrelic.com/docs/transition-guide-distributed-tracing
23
+ * Default is false.
24
+ */
25
+ distributed_tracing: {
26
+ /**
27
+ * Enables/disables distributed tracing.
28
+ *
29
+ * @env NEW_RELIC_DISTRIBUTED_TRACING_ENABLED
30
+ */
31
+ enabled: true,
32
+ },
33
+ application_logging: {
34
+ forwarding: {
35
+ enabled: true,
36
+ },
37
+ },
38
+ logging: {
39
+ /**
40
+ * Level at which to log. 'trace' is most useful to New Relic when diagnosing
41
+ * issues with the agent, 'info' and higher will impose the least overhead on
42
+ * production applications.
43
+ */
44
+ level: 'info',
45
+ filepath: '',
46
+ },
47
+ /**
48
+ * When true, all request headers except for those listed in attributes.exclude
49
+ * will be captured for all traces, unless otherwise specified in a destination's
50
+ * attributes include/exclude lists.
51
+ */
52
+ allow_all_headers: true,
53
+ attributes: {
54
+ /**
55
+ * Prefix of attributes to exclude from all destinations. Allows * as wildcard
56
+ * at end.
57
+ *
58
+ * NOTE: If excluding headers, they must be in camelCase form to be filtered.
59
+ *
60
+ * @env NEW_RELIC_ATTRIBUTES_EXCLUDE
61
+ */
62
+ exclude: [
63
+ 'request.headers.cookie',
64
+ 'request.headers.authorization',
65
+ 'request.headers.proxyAuthorization',
66
+ 'request.headers.setCookie*',
67
+ 'request.headers.x*',
68
+ 'response.headers.cookie',
69
+ 'response.headers.authorization',
70
+ 'response.headers.proxyAuthorization',
71
+ 'response.headers.setCookie*',
72
+ 'response.headers.x*',
73
+ ],
74
+ },
75
+ rules: {
76
+ name: [
77
+ { pattern: '/api/account/mutate', name: 'Account mutation call' },
78
+ { pattern: '/api/account/query', name: 'Account query call' },
79
+ { pattern: '/api/auth/.*', name: 'Auth call' },
80
+ { pattern: '/api/health-check', name: 'Health Check' },
81
+ { pattern: '/api/news-sitemap', name: 'News Sitemap' },
82
+ { pattern: '/api/sitemap', name: 'Sitemap' },
83
+ { pattern: '/api/.*', name: 'API call' },
84
+ ],
85
+ },
86
+ }
package/next-env.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/basic-features/typescript for more information.
package/next.config.js ADDED
@@ -0,0 +1,95 @@
1
+ /* eslint-disable no-param-reassign */
2
+ const { PHASE_PRODUCTION_SERVER } = require('next/constants')
3
+
4
+ module.exports = (phase) => {
5
+ const images = {
6
+ remotePatterns: [
7
+ {
8
+ protocol: 'https',
9
+ hostname: 'www.thesun.co.uk',
10
+ pathname: '/wp-content/**',
11
+ },
12
+ {
13
+ protocol: 'https',
14
+ hostname: 'www.plchldr.co',
15
+ pathname: '/**',
16
+ },
17
+ {
18
+ protocol: 'https',
19
+ hostname: 'plchldr.co',
20
+ pathname: '/**',
21
+ },
22
+ ],
23
+ }
24
+
25
+ if (phase === PHASE_PRODUCTION_SERVER) {
26
+ return {
27
+ images,
28
+ }
29
+ }
30
+
31
+ const path = require('path')
32
+ const withTM = require('next-transpile-modules')([
33
+ '@newskit-render/auth',
34
+ '@newskit-render/my-account',
35
+ '@newskit-render/validation',
36
+ ])
37
+ const withBundleAnalyzer = require('@next/bundle-analyzer')({
38
+ enabled: process.env.ANALYZE === 'true',
39
+ })
40
+
41
+ return withBundleAnalyzer(
42
+ withTM({
43
+ webpack: (config, options) => {
44
+ if (options.isServer) {
45
+ config.externals = ['react', ...config.externals]
46
+ }
47
+
48
+ config.resolve.alias.newskit = path.resolve(
49
+ __dirname,
50
+ '.',
51
+ 'node_modules',
52
+ 'newskit'
53
+ )
54
+ config.resolve.alias.react = path.resolve(
55
+ __dirname,
56
+ '.',
57
+ 'node_modules',
58
+ 'react'
59
+ )
60
+
61
+ return config
62
+ },
63
+ images,
64
+ output: 'standalone',
65
+ async rewrites() {
66
+ return [
67
+ {
68
+ source: '/sitemap.xml',
69
+ destination: '/api/sitemap',
70
+ },
71
+ {
72
+ source: '/pages-sitemap.xml',
73
+ destination: '/api/pages-sitemap',
74
+ },
75
+ {
76
+ source: '/competitions-sitemap.xml',
77
+ destination: '/api/competitions-sitemap',
78
+ },
79
+ {
80
+ source: '/news-sitemap.xml',
81
+ destination: '/api/news-sitemap',
82
+ },
83
+ {
84
+ source: '/feed',
85
+ destination: '/api/feed',
86
+ },
87
+ {
88
+ source: '/robots.txt',
89
+ destination: '/api/robots',
90
+ },
91
+ ]
92
+ },
93
+ })
94
+ )
95
+ }
package/package.json ADDED
@@ -0,0 +1,127 @@
1
+ {
2
+ "name": "@newskit-render/core",
3
+ "version": "0.0.0-d55b7d88",
4
+ "description": "Newskit Render - Core package",
5
+ "author": "",
6
+ "license": "UNLICENSED",
7
+ "keywords": [],
8
+ "engines": {
9
+ "node": ">=16.13.0"
10
+ },
11
+ "scripts": {
12
+ "build": "next build",
13
+ "start": "NODE_OPTIONS=--max_old_space_size=8192 next dev",
14
+ "dev:nr": "NODE_OPTIONS='-r @newrelic/next' next dev",
15
+ "start:prod": "next build && next start",
16
+ "start:prod:nr": "next build && NODE_OPTIONS='-r @newrelic/next' next start",
17
+ "clean": "rm -rf node_modules & rm -f package-lock.json & rm -f yarn.lock & rm -rf .next",
18
+ "test:unit": "jest --coverage --verbose --silent --i",
19
+ "test:unit:ci": "JEST_JUNIT_OUTPUT_NAME=core.xml node --max_old_space_size=4096 --expose-gc ./node_modules/.bin/jest --ci --coverage --reporters=default --reporters=jest-junit --runInBand --logHeapUsage",
20
+ "test:watch": "jest --watch",
21
+ "cy:run": "cypress run -b chrome --headless",
22
+ "cy:vis": "percy exec -- cypress run --config-file cypress/config/visual.config.ts -b chrome --headless",
23
+ "cy:vis:skip": "PERCY_PARTIAL_BUILD=1 percy exec -- cypress run --config-file cypress/config/visual.skip.config.ts",
24
+ "cy:open": "cypress open -b chrome",
25
+ "cy:open:vis": "cypress open --config-file cypress/config/visual.config.ts -b chrome",
26
+ "test:e2e": "yarn cy:run",
27
+ "test:e2e:ci": "cypress run --env -b chrome --headless",
28
+ "start:test:server": "next build && next start",
29
+ "wait:server": "wait-on http://localhost:3000",
30
+ "wait:external": "wait-on",
31
+ "lint": "eslint --ext .js,.jsx,.ts,.tsx . --color && prettier --check './**/*.{js,jsx,ts,tsx,json}'",
32
+ "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --color --fix && prettier --write './**/*.{js,jsx,ts,tsx,json}'",
33
+ "precommit:lint": "eslint",
34
+ "precommit": "lint-staged",
35
+ "analyze": "ANALYZE=true next build"
36
+ },
37
+ "dependencies": {
38
+ "@apollo/client": "3.7.4",
39
+ "@emotion-icons/material": "3.14.0",
40
+ "@emotion-icons/material-outlined": "3.14.0",
41
+ "@emotion/react": "11.9.3",
42
+ "@emotion/styled": "11.9.3",
43
+ "@newrelic/next": "0.5.2",
44
+ "@newrelic/winston-enricher": "4.0.1",
45
+ "@newskit-render/api": "^1.12.1",
46
+ "@newskit-render/auth": "^1.8.0",
47
+ "@newskit-render/checkout": "^3.9.34-alpha.0",
48
+ "@newskit-render/feature-flags": "^1.8.1-alpha.1",
49
+ "@newskit-render/feed": "^1.8.9",
50
+ "@newskit-render/my-account": "^7.54.0-alpha.1",
51
+ "@newskit-render/shared-components": "^4.28.0-alpha.0",
52
+ "@newskit-render/standalone-components": "^3.20.27-alpha.0",
53
+ "@newskit-render/validation": "^1.17.0",
54
+ "cross-fetch": "3.1.5",
55
+ "graphql": "16.6.0",
56
+ "lodash.get": "4.4.2",
57
+ "newrelic": "10.6.1",
58
+ "newskit": "7.7.0",
59
+ "next": "13.4.4",
60
+ "react": "18.2.0",
61
+ "react-dom": "18.2.0",
62
+ "react-helmet": "6.1.0",
63
+ "sharp": "0.32.4",
64
+ "swr": "1.3.0",
65
+ "winston": "3.10.0"
66
+ },
67
+ "devDependencies": {
68
+ "@apollo/react-testing": "4.0.0",
69
+ "@emotion/jest": "11.10.5",
70
+ "@next/bundle-analyzer": "12.0.8",
71
+ "@next/env": "13.1.3",
72
+ "@next/eslint-plugin-next": "13.0.6",
73
+ "@percy/cli": "1.16.0",
74
+ "@percy/cypress": "3.1.2",
75
+ "@testing-library/jest-dom": "6.1.3",
76
+ "@testing-library/react": "14.0.0",
77
+ "@testing-library/user-event": "14.4.3",
78
+ "@types/newrelic": "9.14.0",
79
+ "@types/react": "18.0.26",
80
+ "@types/react-dom": "18.0.10",
81
+ "@types/react-helmet": "6.1.0",
82
+ "@typescript-eslint/eslint-plugin": "5.51.0",
83
+ "@typescript-eslint/parser": "5.51.0",
84
+ "axe-core": "4.3.4",
85
+ "babel-jest": "26.3.0",
86
+ "cypress": "13.8.1",
87
+ "cypress-axe": "1.5.0",
88
+ "eslint": "8.34.0",
89
+ "eslint-config-airbnb": "19.0.4",
90
+ "eslint-config-airbnb-typescript": "17.0.0",
91
+ "eslint-config-next": "13.1.2",
92
+ "eslint-config-prettier": "8.6.0",
93
+ "eslint-import-resolver-typescript": "3.5.2",
94
+ "eslint-plugin-cypress": "3.0.1",
95
+ "eslint-plugin-flowtype": "8.0.3",
96
+ "eslint-plugin-no-only-tests": "3.1.0",
97
+ "eslint-plugin-prettier": "4.2.1",
98
+ "jest": "29.7.0",
99
+ "jest-environment-jsdom": "29.7.0",
100
+ "jest-junit": "15.0.0",
101
+ "jest-watch-typeahead": "2.2.1",
102
+ "lint-staged": "13.1.0",
103
+ "next-transpile-modules": "10.0.0",
104
+ "prettier": "2.8.3",
105
+ "prettier-eslint": "15.0.1",
106
+ "prettier-eslint-cli": "7.1.0",
107
+ "typescript": "4.9.4",
108
+ "wait-on": "7.0.1"
109
+ },
110
+ "precommit": [
111
+ "precommit"
112
+ ],
113
+ "lint-staged": {
114
+ "**/*.(ts|tsx)": [
115
+ "yarn run precommit:lint"
116
+ ]
117
+ },
118
+ "publishConfig": {
119
+ "access": "public"
120
+ },
121
+ "resolutions": {
122
+ "@types/react": "18.0.26",
123
+ "@types/react-dom": "18.0.10",
124
+ "@types/pino-std-serializers": "2.4.1",
125
+ "@types/pino-pretty": "4.7.5"
126
+ }
127
+ }
package/pages/_app.tsx ADDED
@@ -0,0 +1,117 @@
1
+ import React from 'react'
2
+ import { AppContext as AppContextType, AppProps } from 'next/app'
3
+ import Head from 'next/head'
4
+ import { ThemeProvider, Global, styled } from 'newskit'
5
+ import { Publisher } from '@newskit-render/api'
6
+ import { getFontFamilyFromNextFont } from '@newskit-render/shared-components'
7
+ import { AppContextProvider, AppContext } from '../context/app-context'
8
+ import { InstrumentationContextProvider } from '../app-context/InstrumentationContextProvider'
9
+ import { getTenant } from '../helpers/multiTenancy'
10
+ import { GlobalStyling } from '../css'
11
+ import MultiTenancyProvider from '../context/multi-tenancy'
12
+ import {
13
+ bitter,
14
+ poppins,
15
+ dmSans,
16
+ theSun,
17
+ roboto,
18
+ timesModern,
19
+ timesDigital,
20
+ montserrat,
21
+ publicoHeadline,
22
+ publicoText,
23
+ graphik,
24
+ } from '../assets/fontFamily'
25
+
26
+ const PageContainer = styled.div`
27
+ position: relative;
28
+ min-height: 100vh;
29
+ `
30
+
31
+ interface MyAppProps extends AppProps {
32
+ tenant: Publisher
33
+ }
34
+
35
+ function MyApp({ Component, pageProps, tenant }: MyAppProps) {
36
+ return (
37
+ <MultiTenancyProvider tenant={tenant}>
38
+ <AppContextProvider>
39
+ <>
40
+ <style jsx global>{`
41
+ :root {
42
+ --bitter: ${bitter.style.fontFamily};
43
+ --poppins: ${poppins.style.fontFamily};
44
+ --dm-sans: ${dmSans.style.fontFamily};
45
+ --the-sun: ${theSun.style.fontFamily};
46
+ --roboto: ${roboto.style.fontFamily};
47
+ --times-modern: ${timesModern.style.fontFamily};
48
+ --times-digital: ${timesDigital.style.fontFamily};
49
+ --montserrat: ${montserrat.style.fontFamily};
50
+ --publico-headline: ${publicoHeadline.style.fontFamily};
51
+ --publico-text: ${publicoText.style.fontFamily};
52
+ --graphik: ${graphik.style.fontFamily};
53
+ }
54
+ `}</style>
55
+ <Head>
56
+ <meta name="robots" content="max-image-preview:standard" />
57
+ <meta name="robots" content="max-video-preview:0" />
58
+ <meta google-site-verification="google-site-verification=9IZcsqYKeNo_Wlkwq6WBqgpqZuiwPGJw90Ug_LAENt4" />
59
+ <meta
60
+ key="viewport"
61
+ name="viewport"
62
+ content="width=device-width, initial-scale=1, maximum-scale=1"
63
+ />
64
+ </Head>
65
+ <InstrumentationContextProvider>
66
+ <AppContext.Consumer>
67
+ {({ theme, themeDropdownObject }) => (
68
+ <ThemeProvider theme={theme}>
69
+ <Global styles={GlobalStyling} />
70
+ <PageContainer>
71
+ <Component
72
+ {...pageProps}
73
+ {...{
74
+ themeDropdownObject,
75
+ customTheme: theme,
76
+ context: {
77
+ fontFamilies: getFontFamilyFromNextFont([
78
+ bitter,
79
+ poppins,
80
+ dmSans,
81
+ theSun,
82
+ roboto,
83
+ timesModern,
84
+ timesDigital,
85
+ montserrat,
86
+ publicoHeadline,
87
+ publicoText,
88
+ graphik,
89
+ ]),
90
+ },
91
+ }}
92
+ />
93
+ </PageContainer>
94
+ </ThemeProvider>
95
+ )}
96
+ </AppContext.Consumer>
97
+ </InstrumentationContextProvider>
98
+ </>
99
+ </AppContextProvider>
100
+ </MultiTenancyProvider>
101
+ )
102
+ }
103
+
104
+ MyApp.getInitialProps = async ({ Component, ctx }: AppContextType) => {
105
+ let pageProps = {}
106
+ const tenant = getTenant(ctx.req?.headers?.host)
107
+ if (Component.getInitialProps) {
108
+ pageProps = await Component.getInitialProps(ctx)
109
+ }
110
+
111
+ return {
112
+ pageProps,
113
+ tenant,
114
+ }
115
+ }
116
+
117
+ export default MyApp
@@ -0,0 +1,112 @@
1
+ /* eslint-disable react/no-danger */
2
+ import React from 'react'
3
+ import Script from 'next/script'
4
+ import Document, {
5
+ Html,
6
+ Head,
7
+ Main,
8
+ NextScript,
9
+ DocumentContext,
10
+ } from 'next/document'
11
+ import { ExperimentationWeb, Consent, Tealium } from 'newskit'
12
+ import Helmet from 'react-helmet'
13
+ import newrelic from 'newrelic'
14
+ import {
15
+ experimentationWeb,
16
+ sourcepointAccountId,
17
+ sourcepointPropertyHref,
18
+ sourcepointPropertyId,
19
+ tealiumAccountId,
20
+ tealiumProfileId,
21
+ tealiumEnv,
22
+ } from '../config'
23
+
24
+ export default class MyDocument extends Document {
25
+ static async getInitialProps(ctx: DocumentContext) {
26
+ const { html, head } = await ctx.renderPage()
27
+
28
+ const browserTimingHeader = newrelic.getBrowserTimingHeader({
29
+ hasToRemoveScriptWrapper: true,
30
+ })
31
+
32
+ return {
33
+ html,
34
+ head,
35
+ browserTimingHeader,
36
+ }
37
+ }
38
+
39
+ render() {
40
+ const helmet = Helmet.rewind()
41
+ const showAds =
42
+ this.props.__NEXT_DATA__.props.pageProps &&
43
+ this.props.__NEXT_DATA__.props.pageProps.showAds
44
+ ? this.props.__NEXT_DATA__.props.pageProps.showAds
45
+ : false
46
+
47
+ const { featureFlags } = this.props.__NEXT_DATA__.props.pageProps
48
+ return (
49
+ <Html lang="en">
50
+ <Head>
51
+ <>
52
+ <script
53
+ type="text/javascript"
54
+ dangerouslySetInnerHTML={{
55
+ // @ts-ignore
56
+ __html: this.props.browserTimingHeader,
57
+ }}
58
+ />
59
+ {experimentationWeb &&
60
+ featureFlags &&
61
+ featureFlags.experimentation_web_flag && (
62
+ <ExperimentationWeb
63
+ optimizelyWebConfig={{
64
+ scriptCdn: experimentationWeb,
65
+ }}
66
+ reactHelmet={Helmet}
67
+ />
68
+ )}
69
+ {helmet.script.toComponent()}
70
+ {sourcepointAccountId && (
71
+ <Consent
72
+ sourcePointConfigUnified={{
73
+ accountId: Number(sourcepointAccountId),
74
+ propertyHref: sourcepointPropertyHref,
75
+ propertyId: Number(sourcepointPropertyId),
76
+ gdpr: {},
77
+ }}
78
+ reactHelmet={Helmet}
79
+ />
80
+ )}
81
+ <meta name="robots" content="noindex" />
82
+ {showAds && (
83
+ <>
84
+ <Script
85
+ type="text/javascript"
86
+ src="https://ads.newskit.co.uk/prebid.newskit.min.js"
87
+ strategy="lazyOnload"
88
+ />
89
+ <Script
90
+ type="text/javascript"
91
+ src="https://ads.newskit.co.uk/ads.newskit.min.js"
92
+ strategy="lazyOnload"
93
+ />
94
+ </>
95
+ )}
96
+ </>
97
+ </Head>
98
+ <body>
99
+ {tealiumAccountId && (
100
+ <Tealium
101
+ accountId={tealiumAccountId}
102
+ profileId={tealiumProfileId as string}
103
+ env={tealiumEnv as string}
104
+ />
105
+ )}
106
+ <Main />
107
+ <NextScript />
108
+ </body>
109
+ </Html>
110
+ )
111
+ }
112
+ }
@@ -0,0 +1,68 @@
1
+ import React from 'react'
2
+ import { NotFound, GenericError } from '@newskit-render/my-account'
3
+ import Error from 'next/error'
4
+ import ErrorPage from '../components/ErrorPage/ErrorPage'
5
+ import ErrorPageHelpHub from '../pages/help-hub/error'
6
+
7
+ function CustomError({ statusCode, asPath }) {
8
+ const isMyAccountApplication = asPath.startsWith('/account')
9
+ const isHelpHubApplication = asPath.startsWith('/help-hub')
10
+
11
+ if (isMyAccountApplication) {
12
+ if (statusCode === 404) {
13
+ return <NotFound />
14
+ }
15
+ return <GenericError />
16
+ }
17
+ if (isHelpHubApplication) {
18
+ if (statusCode === 500 || statusCode === 502) {
19
+ return (
20
+ <ErrorPageHelpHub
21
+ credentials={{
22
+ appId: '',
23
+ apiKey: '',
24
+ indexName: '',
25
+ }}
26
+ />
27
+ )
28
+ }
29
+ return (
30
+ <ErrorPage
31
+ title="Server-side error occurred"
32
+ errorMassage="We could not fetch the data from the server"
33
+ />
34
+ )
35
+ }
36
+ if (statusCode === 404) {
37
+ return (
38
+ <ErrorPage
39
+ title="Page not found"
40
+ errorMassage={`
41
+ We can't seem to find what you're looking for. If you typed a URL
42
+ into your browser, it might be worth checking and trying again.`}
43
+ />
44
+ )
45
+ }
46
+
47
+ if (statusCode === 500 || statusCode === 502) {
48
+ return (
49
+ <ErrorPage
50
+ title="Server-side error occurred"
51
+ errorMassage="We could not fetch the data from the server"
52
+ />
53
+ )
54
+ }
55
+
56
+ return <Error statusCode={statusCode} />
57
+ }
58
+
59
+ CustomError.getInitialProps = ({ res, err, asPath }) => {
60
+ const statusCode = res ? res.statusCode : err ? err.statusCode : 404
61
+
62
+ // Logging the error for being captured by New Relic
63
+ console.error(`An ${statusCode} error has occurred`, err)
64
+
65
+ return { statusCode, asPath }
66
+ }
67
+
68
+ export default CustomError
@@ -0,0 +1,34 @@
1
+ import React from 'react'
2
+ import { replaceConsoleAndSetTransactionName } from '../../../helpers/logger'
3
+ import { AddField, addComponentMap } from '@newskit-render/my-account'
4
+ import validation from '../../../validation'
5
+ import { DynamicPage } from '@newskit-render/my-account'
6
+
7
+ const AccountAddField = (props) => (
8
+ <DynamicPage
9
+ objectMap={addComponentMap}
10
+ pageName={props.data.type}
11
+ Component={AddField}
12
+ componentProps={props}
13
+ validation={validation}
14
+ />
15
+ )
16
+
17
+ export default AccountAddField
18
+ export const getServerSideProps = async (context) => {
19
+ const {
20
+ params: { field },
21
+ } = context
22
+ const doesAddpageExist = Object.keys(addComponentMap).includes(field)
23
+ replaceConsoleAndSetTransactionName(`Account: add ${field}`)
24
+
25
+ if (!doesAddpageExist) {
26
+ context.res.statusCode = 404
27
+ // Logging the error for being captured by New Relic
28
+ console.error(`An error ${context.res.statusCode} occurred on server`)
29
+ }
30
+
31
+ return {
32
+ props: { data: { type: field } },
33
+ }
34
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react'
2
+ import { Cancellation, getProviderProps } from '@newskit-render/my-account'
3
+ import { replaceConsoleAndSetTransactionName } from '../../../helpers/logger'
4
+ import { getFlagsAll } from '@newskit-render/feature-flags' /* cra-effected */
5
+ import validation from '../../../validation'
6
+
7
+ const AccountCancellation = (props) => (
8
+ <Cancellation {...props} validation={validation} />
9
+ )
10
+
11
+ export default AccountCancellation
12
+
13
+ export const getServerSideProps = async (context) => {
14
+ replaceConsoleAndSetTransactionName('Account: Cancellation')
15
+ /* start cra-effected */
16
+ const featureFlags = await getFlagsAll()
17
+ /* end cra-effected */
18
+ return getProviderProps(
19
+ { ...context, provider: 'Cancellation' },
20
+ { featureFlags } /* cra-effected */
21
+ )
22
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react'
2
+ import {
3
+ ConfirmAccountDeletion,
4
+ getProviderProps,
5
+ } from '@newskit-render/my-account'
6
+ import { replaceConsoleAndSetTransactionName } from '../../../../helpers/logger'
7
+
8
+ const ConfirmDeletion = (props) => <ConfirmAccountDeletion {...props} />
9
+
10
+ export default ConfirmDeletion
11
+
12
+ export const getServerSideProps = async (context) => {
13
+ replaceConsoleAndSetTransactionName('Account: Deletion - Confirmation')
14
+
15
+ return getProviderProps({ ...context })
16
+ }