@financial-times/cp-content-pipeline-schema 2.5.3 → 2.6.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 (66) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +187 -41
  3. package/lib/datasources/base.d.ts +1 -0
  4. package/lib/datasources/capi.js +1 -0
  5. package/lib/datasources/capi.js.map +1 -1
  6. package/lib/datasources/instrumented.d.ts +1 -0
  7. package/lib/datasources/instrumented.js +1 -9
  8. package/lib/datasources/instrumented.js.map +1 -1
  9. package/lib/datasources/origami-image.js +1 -0
  10. package/lib/datasources/origami-image.js.map +1 -1
  11. package/lib/datasources/twitter.js +1 -0
  12. package/lib/datasources/twitter.js.map +1 -1
  13. package/lib/datasources/url-management.d.ts +1 -0
  14. package/lib/datasources/url-management.js +2 -0
  15. package/lib/datasources/url-management.js.map +1 -1
  16. package/lib/fixtures/capiObject.js +1 -1
  17. package/lib/fixtures/capiObject.js.map +1 -1
  18. package/lib/generated/index.d.ts +572 -2
  19. package/lib/model/CapiResponse.d.ts +1 -0
  20. package/lib/model/CapiResponse.js +4 -2
  21. package/lib/model/CapiResponse.js.map +1 -1
  22. package/lib/model/CapiResponse.test.js +7 -0
  23. package/lib/model/CapiResponse.test.js.map +1 -1
  24. package/lib/resolvers/content-tree/Workarounds.d.ts +8 -1
  25. package/lib/resolvers/content-tree/nodePredicates.d.ts +1 -1
  26. package/lib/resolvers/content-tree/tagMappings.js +14 -5
  27. package/lib/resolvers/content-tree/tagMappings.js.map +1 -1
  28. package/lib/resolvers/content.d.ts +8 -0
  29. package/lib/resolvers/content.js +1 -0
  30. package/lib/resolvers/content.js.map +1 -1
  31. package/lib/resolvers/index.d.ts +8 -0
  32. package/package.json +1 -1
  33. package/queries/article.graphql +1 -0
  34. package/src/datasources/base.ts +1 -0
  35. package/src/datasources/capi.ts +1 -0
  36. package/src/datasources/instrumented.ts +1 -11
  37. package/src/datasources/origami-image.ts +3 -0
  38. package/src/datasources/twitter.ts +2 -0
  39. package/src/datasources/url-management.ts +2 -0
  40. package/src/fixtures/capiObject.ts +1 -1
  41. package/src/generated/index.ts +572 -2
  42. package/src/model/CapiResponse.test.ts +9 -0
  43. package/src/model/CapiResponse.ts +4 -3
  44. package/src/resolvers/content-tree/Workarounds.ts +10 -0
  45. package/src/resolvers/content-tree/tagMappings.ts +15 -5
  46. package/src/resolvers/content.ts +1 -0
  47. package/tsconfig.tsbuildinfo +1 -1
  48. package/typedefs/clip.graphql +28 -0
  49. package/typedefs/concept.graphql +21 -2
  50. package/typedefs/content.graphql +465 -36
  51. package/typedefs/core.graphql +6 -0
  52. package/typedefs/image.graphql +210 -15
  53. package/typedefs/picture.graphql +54 -1
  54. package/typedefs/references/clipSet.graphql +34 -1
  55. package/typedefs/references/flourish.graphql +8 -0
  56. package/typedefs/references/imageSet.graphql +6 -0
  57. package/typedefs/references/layoutImage.graphql +3 -0
  58. package/typedefs/references/rawImage.graphql +3 -0
  59. package/typedefs/references/recommended.graphql +3 -0
  60. package/typedefs/references/reference.graphql +1 -0
  61. package/typedefs/references/scrollyImage.graphql +3 -0
  62. package/typedefs/references/tweet.graphql +3 -0
  63. package/typedefs/references/video.graphql +5 -0
  64. package/typedefs/richText.graphql +7 -4
  65. package/typedefs/teaser.graphql +42 -1
  66. package/typedefs/topper.graphql +219 -7
@@ -75,6 +75,15 @@ describe('CAPI response', () => {
75
75
  })
76
76
  })
77
77
 
78
+ describe('Publish timestamp', () => {
79
+ test('generates a timestamp from the published date', () => {
80
+ const article = cloneDeep(baseCapiObject)
81
+ const capiResponse = new CapiResponse(article, context)
82
+
83
+ expect(capiResponse.publishedTimestamp()).toEqual(1712052009935)
84
+ })
85
+ })
86
+
78
87
  describe('liveBlogPosts', () => {
79
88
  test('returns a resolved array of the articles contained sorted by most recently published', async () => {
80
89
  const liveBlogPackage = cloneDeep({
@@ -364,6 +364,9 @@ export class CapiResponse {
364
364
  publishedDate() {
365
365
  return this.capiData.publishedDate
366
366
  }
367
+ publishedTimestamp() {
368
+ return new Date(this.capiData.publishedDate).getTime()
369
+ }
367
370
  firstPublishedDate() {
368
371
  return this.capiData.firstPublishedDate || this.capiData.publishedDate
369
372
  }
@@ -673,9 +676,7 @@ export class CapiResponse {
673
676
  this.context.addSurrogateKeys(contains.map((article) => article.id()))
674
677
 
675
678
  const liveBlogPosts = contains.sort(
676
- (a, b) =>
677
- new Date(b.publishedDate()).getTime() -
678
- new Date(a.publishedDate()).getTime()
679
+ (a, b) => b.publishedTimestamp() - a.publishedTimestamp()
679
680
  )
680
681
 
681
682
  return liveBlogPosts
@@ -15,6 +15,11 @@ export interface AuthorLink extends ContentTree.Parent {
15
15
  children: ContentTree.Text[]
16
16
  }
17
17
 
18
+ export interface Cite extends ContentTree.Node {
19
+ type: 'cite'
20
+ children: ContentTree.Phrasing[]
21
+ }
22
+
18
23
  /*
19
24
  Raw Image nodes only exist because of old Wordpress articles,
20
25
  and so will not be added to content-tree.
@@ -39,6 +44,10 @@ export interface RawImage extends ContentTree.Node {
39
44
  width?: number
40
45
  }
41
46
 
47
+ export interface ContentTreePullquote extends ContentTree.Pullquote {
48
+ children: ContentTree.ImageSet[]
49
+ }
50
+
42
51
  /*
43
52
  Whilst we are converting the bodyXML to the content-tree, we still do not have a way of
44
53
  knowing if the article should display a mainImage or not.
@@ -190,3 +199,4 @@ export type AnyNode =
190
199
  | MainImageRaw
191
200
  | RawImage
192
201
  | AuthorLink
202
+ | Cite
@@ -119,6 +119,10 @@ const commonTagMappings: TagMappings = {
119
119
  type: 'emphasis',
120
120
  children: childrenOfTypes(phrasingTypes, traverse(), 'emphasis', context),
121
121
  }),
122
+ 'blockquote > cite': ($el, traverse, context) => ({
123
+ type: 'cite',
124
+ children: childrenOfTypes(phrasingTypes, traverse(), 'cite', context),
125
+ }),
122
126
  blockquote: ($el, traverse, context) => ({
123
127
  type: 'blockquote',
124
128
  children: childrenOfTypes(phrasingTypes, traverse(), 'blockquote', context),
@@ -160,11 +164,17 @@ const commonTagMappings: TagMappings = {
160
164
  level: 'label',
161
165
  children: everyChildIsType('text', traverse(), 'heading', context),
162
166
  }),
163
- 'pull-quote': ($el) => ({
164
- type: 'pullquote',
165
- text: $el.find('pull-quote-text').text(),
166
- source: $el.find('pull-quote-source').text(),
167
- }),
167
+ 'pull-quote': ($el, traverse, context) => {
168
+ const children = traverse()
169
+ const image = findChildOftype('image-set', children, 'pullquote', context)
170
+
171
+ return {
172
+ type: 'pullquote',
173
+ text: $el.find('pull-quote-text').text(),
174
+ source: $el.find('pull-quote-source').text(),
175
+ children: image ? [image] : [],
176
+ }
177
+ },
168
178
  'body > ft-content[type="http://www.ft.com/ontology/content/Video"]': (
169
179
  $el
170
180
  ) => ({
@@ -34,6 +34,7 @@ const contentResolvers: ContentResolvers = {
34
34
  mainImage: (parent) => parent.mainImage(),
35
35
  originatingParty: (parent) => parent.originatingParty(),
36
36
  publishedDate: (parent) => parent.publishedDate(),
37
+ publishedTimestamp: (parent) => parent.publishedTimestamp(),
37
38
  standfirst: (parent) => parent.standfirst(),
38
39
  teaser: (parent) => parent.teaser(),
39
40
  title: (parent) => parent.title(),