@financial-times/cp-content-pipeline-schema 2.15.1 → 3.0.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.
Files changed (165) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/lib/datasources/capi.d.ts +2 -2
  3. package/lib/datasources/capi.js +4 -2
  4. package/lib/datasources/capi.js.map +1 -1
  5. package/lib/datasources/capi.test.js +2 -2
  6. package/lib/datasources/twitter.d.ts +3 -1
  7. package/lib/datasources/twitter.js +26 -1
  8. package/lib/datasources/twitter.js.map +1 -1
  9. package/lib/fixtures/capiObject.d.ts +2 -2
  10. package/lib/fixtures/capiObject.js +2 -0
  11. package/lib/fixtures/capiObject.js.map +1 -1
  12. package/lib/fixtures/capiPerson.d.ts +1 -1
  13. package/lib/generated/index.d.ts +278 -113
  14. package/lib/helpers/decorateHeadshotUrl.d.ts +1 -2
  15. package/lib/helpers/decorateHeadshotUrl.js +2 -3
  16. package/lib/helpers/decorateHeadshotUrl.js.map +1 -1
  17. package/lib/model/Byline.d.ts +8 -10
  18. package/lib/model/Byline.js +34 -33
  19. package/lib/model/Byline.js.map +1 -1
  20. package/lib/model/Byline.test.js +105 -52
  21. package/lib/model/Byline.test.js.map +1 -1
  22. package/lib/model/CapiResponse.d.ts +11 -15
  23. package/lib/model/CapiResponse.js +37 -40
  24. package/lib/model/CapiResponse.js.map +1 -1
  25. package/lib/model/CapiResponse.test.js +7 -18
  26. package/lib/model/CapiResponse.test.js.map +1 -1
  27. package/lib/model/Clip.d.ts +1 -1
  28. package/lib/model/Concept.d.ts +1 -1
  29. package/lib/model/Concept.js +1 -2
  30. package/lib/model/Concept.js.map +1 -1
  31. package/lib/model/FlourishSource.d.ts +1 -1
  32. package/lib/model/FlourishSource.js.map +1 -1
  33. package/lib/model/Image.d.ts +1 -1
  34. package/lib/model/LeadFlourish.test.js +1 -0
  35. package/lib/model/LeadFlourish.test.js.map +1 -1
  36. package/lib/model/Person.d.ts +6 -12
  37. package/lib/model/Person.js +39 -66
  38. package/lib/model/Person.js.map +1 -1
  39. package/lib/model/Person.test.js +7 -60
  40. package/lib/model/Person.test.js.map +1 -1
  41. package/lib/model/Picture.d.ts +1 -1
  42. package/lib/model/RichText.d.ts +1 -2
  43. package/lib/model/Topper.d.ts +1 -1
  44. package/lib/model/Topper.js +10 -8
  45. package/lib/model/Topper.js.map +1 -1
  46. package/lib/model/Topper.test.js +9 -10
  47. package/lib/model/Topper.test.js.map +1 -1
  48. package/lib/model/schemas/capi/article.d.ts +4 -1
  49. package/lib/model/schemas/capi/article.js +1 -0
  50. package/lib/model/schemas/capi/article.js.map +1 -1
  51. package/lib/model/schemas/capi/audio.d.ts +4 -1
  52. package/lib/model/schemas/capi/audio.js +1 -0
  53. package/lib/model/schemas/capi/audio.js.map +1 -1
  54. package/lib/model/schemas/capi/base-schema.d.ts +11 -120
  55. package/lib/model/schemas/capi/base-schema.js +6 -5
  56. package/lib/model/schemas/capi/base-schema.js.map +1 -1
  57. package/lib/model/schemas/capi/content-package.d.ts +7 -2
  58. package/lib/model/schemas/capi/content-package.js +2 -0
  59. package/lib/model/schemas/capi/content-package.js.map +1 -1
  60. package/lib/model/schemas/capi/index.d.ts +26 -7
  61. package/lib/model/schemas/capi/internal-content.d.ts +24 -0
  62. package/lib/model/schemas/capi/internal-content.js +3 -0
  63. package/lib/model/schemas/capi/internal-content.js.map +1 -0
  64. package/lib/model/schemas/capi/live-blog-package.d.ts +4 -1
  65. package/lib/model/schemas/capi/live-blog-package.js +1 -0
  66. package/lib/model/schemas/capi/live-blog-package.js.map +1 -1
  67. package/lib/model/schemas/capi/placeholder.d.ts +4 -1
  68. package/lib/model/schemas/capi/placeholder.js +1 -0
  69. package/lib/model/schemas/capi/placeholder.js.map +1 -1
  70. package/lib/model/schemas/capi/video.d.ts +7 -2
  71. package/lib/model/schemas/capi/video.js +2 -0
  72. package/lib/model/schemas/capi/video.js.map +1 -1
  73. package/lib/resolvers/concept.d.ts +37 -2
  74. package/lib/resolvers/concept.js +17 -10
  75. package/lib/resolvers/concept.js.map +1 -1
  76. package/lib/resolvers/content-tree/Workarounds.d.ts +19 -11
  77. package/lib/resolvers/content-tree/references/Author.d.ts +4 -0
  78. package/lib/resolvers/content-tree/references/Author.js +14 -0
  79. package/lib/resolvers/content-tree/references/Author.js.map +1 -0
  80. package/lib/resolvers/content-tree/references/ClipSet.d.ts +1 -1
  81. package/lib/resolvers/content-tree/references/ClipSet.js +1 -1
  82. package/lib/resolvers/content-tree/references/ClipSet.js.map +1 -1
  83. package/lib/resolvers/content-tree/references/Flourish.d.ts +1 -1
  84. package/lib/resolvers/content-tree/references/Reference.d.ts +1 -1
  85. package/lib/resolvers/content-tree/references/Tweet.d.ts +1 -1
  86. package/lib/resolvers/content-tree/references/index.d.ts +4 -2
  87. package/lib/resolvers/content-tree/references/index.js +4 -1
  88. package/lib/resolvers/content-tree/references/index.js.map +1 -1
  89. package/lib/resolvers/content-tree/updateTreeWithReferenceIds.d.ts +3 -3
  90. package/lib/resolvers/content-tree/updateTreeWithReferenceIds.js +2 -3
  91. package/lib/resolvers/content-tree/updateTreeWithReferenceIds.js.map +1 -1
  92. package/lib/resolvers/content.d.ts +19 -10
  93. package/lib/resolvers/content.js +4 -2
  94. package/lib/resolvers/content.js.map +1 -1
  95. package/lib/resolvers/image.d.ts +12 -12
  96. package/lib/resolvers/index.d.ts +81 -34
  97. package/lib/resolvers/leadFlourish.d.ts +2 -1
  98. package/lib/resolvers/leadFlourish.js +1 -0
  99. package/lib/resolvers/leadFlourish.js.map +1 -1
  100. package/lib/resolvers/person.d.ts +1 -1
  101. package/lib/resolvers/person.js +1 -1
  102. package/lib/resolvers/person.js.map +1 -1
  103. package/lib/resolvers/picture.d.ts +4 -4
  104. package/lib/resolvers/richText.d.ts +1 -1
  105. package/lib/resolvers/teaser.d.ts +1 -1
  106. package/lib/resolvers/topper.d.ts +3 -3
  107. package/package.json +1 -1
  108. package/queries/article.graphql +35 -13
  109. package/src/datasources/capi.test.ts +3 -3
  110. package/src/datasources/capi.ts +5 -3
  111. package/src/datasources/twitter.ts +5 -1
  112. package/src/fixtures/capiObject.ts +4 -2
  113. package/src/fixtures/capiPerson.ts +1 -1
  114. package/src/generated/index.ts +303 -114
  115. package/src/helpers/decorateHeadshotUrl.ts +2 -2
  116. package/src/model/Byline.test.ts +136 -55
  117. package/src/model/Byline.ts +49 -39
  118. package/src/model/CapiResponse.test.ts +9 -25
  119. package/src/model/CapiResponse.ts +82 -55
  120. package/src/model/Clip.ts +1 -1
  121. package/src/model/Concept.ts +3 -3
  122. package/src/model/FlourishSource.ts +1 -1
  123. package/src/model/Image.test.ts +1 -1
  124. package/src/model/Image.ts +1 -1
  125. package/src/model/LeadFlourish.test.ts +1 -0
  126. package/src/model/Person.test.ts +11 -62
  127. package/src/model/Person.ts +47 -51
  128. package/src/model/Picture.test.ts +1 -1
  129. package/src/model/Picture.ts +1 -1
  130. package/src/model/Topper.test.ts +22 -18
  131. package/src/model/Topper.ts +10 -9
  132. package/src/model/__snapshots__/Byline.test.ts.snap +166 -27
  133. package/src/model/schemas/capi/article.ts +1 -0
  134. package/src/model/schemas/capi/audio.ts +1 -0
  135. package/src/model/schemas/capi/base-schema.ts +4 -3
  136. package/src/model/schemas/capi/content-package.ts +2 -0
  137. package/src/model/schemas/capi/internal-content.ts +45 -0
  138. package/src/model/schemas/capi/live-blog-package.ts +1 -0
  139. package/src/model/schemas/capi/placeholder.ts +1 -0
  140. package/src/model/schemas/capi/video.ts +2 -0
  141. package/src/resolvers/concept.ts +29 -12
  142. package/src/resolvers/content-tree/Workarounds.ts +39 -20
  143. package/src/resolvers/content-tree/references/Author.ts +18 -0
  144. package/src/resolvers/content-tree/references/ClipSet.ts +6 -8
  145. package/src/resolvers/content-tree/references/ImageSet.ts +1 -1
  146. package/src/resolvers/content-tree/references/ScrollyImage.ts +1 -1
  147. package/src/resolvers/content-tree/references/index.ts +6 -1
  148. package/src/resolvers/content-tree/updateTreeWithReferenceIds.ts +6 -8
  149. package/src/resolvers/content.ts +4 -2
  150. package/src/resolvers/leadFlourish.ts +1 -0
  151. package/src/resolvers/person.ts +1 -1
  152. package/src/types/n-display-metadata.d.ts +1 -1
  153. package/tsconfig.tsbuildinfo +1 -1
  154. package/typedefs/clip.graphql +2 -2
  155. package/typedefs/concept.graphql +64 -2
  156. package/typedefs/content.graphql +55 -31
  157. package/typedefs/image.graphql +12 -12
  158. package/typedefs/leadFlourish.graphql +32 -0
  159. package/typedefs/person.graphql +2 -2
  160. package/typedefs/picture.graphql +6 -6
  161. package/typedefs/references/author.graphql +7 -0
  162. package/typedefs/references/clipSet.graphql +14 -2
  163. package/typedefs/teaser.graphql +10 -10
  164. package/src/types/internal-content.d.ts +0 -55
  165. package/typedefs/leadFlouish.graphql +0 -29
@@ -1,3 +1,2 @@
1
- import { CapiPerson } from '../types/internal-content';
2
- export declare const UUID_REGEX: RegExp;
1
+ import { CapiPerson } from '../model/schemas/capi/internal-content';
3
2
  export default function decorateHeadshotUrl(person: CapiPerson): string | null | undefined;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UUID_REGEX = void 0;
4
3
  exports.default = decorateHeadshotUrl;
5
- exports.UUID_REGEX = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-9][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/i;
4
+ const UUID_REGEX = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-9][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/i;
6
5
  const IMAGESET_REGEX = /fthead(?:-v\d)?\:[^?]+/;
7
6
  function decorateHeadshotUrl(person) {
8
7
  const url = person?._imageUrl;
@@ -31,7 +30,7 @@ function isCloudfrontUrl(url) {
31
30
  }
32
31
  }
33
32
  function executeFtcmsMatch(url) {
34
- return exports.UUID_REGEX.exec(url);
33
+ return UUID_REGEX.exec(url);
35
34
  }
36
35
  function executeFtheadMatch(url) {
37
36
  return IMAGESET_REGEX.exec(url);
@@ -1 +1 @@
1
- {"version":3,"file":"decorateHeadshotUrl.js","sourceRoot":"","sources":["../../src/helpers/decorateHeadshotUrl.ts"],"names":[],"mappings":";;;AAOA,sCAoBC;AAzBY,QAAA,UAAU,GACrB,8EAA8E,CAAA;AAEhF,MAAM,cAAc,GAAG,wBAAwB,CAAA;AAE/C,SAAwB,mBAAmB,CAAC,MAAkB;IAC5D,MAAM,GAAG,GAAG,MAAM,EAAE,SAAS,CAAA;IAE7B,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAA;IAErB,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAA;IAEzC,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,SAAS,UAAU,CAAC,GAAG,EAAE,EAAE,CAAA;IACpC,CAAC;IAED,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;IAEjD,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,iBAAiB,CAAC,GAAG,EAAE,CAAA;IAChC,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,GAAW;IAClC,MAAM,uBAAuB,GAAG,+BAA+B,CAAA;IAE/D,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAA;QACzC,OAAO,WAAW,IAAI,WAAW,KAAK,uBAAuB,CAAA;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,OAAO,kBAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC7B,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG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-1,18 +1,16 @@
1
1
  import { ContentTree } from '@financial-times/content-tree';
2
- import { AuthorLink } from '../resolvers/content-tree/Workarounds';
3
- import { QueryContext } from '..';
2
+ import { Concept } from './Concept';
3
+ import { CapiResponse } from './CapiResponse';
4
4
  export declare class Byline {
5
5
  #private;
6
6
  private byline;
7
7
  private vanity;
8
- private authorUrlMapping;
9
- private context;
10
- constructor(byline: string, vanity: boolean, authorUrlMapping: Map<string, string>, context: QueryContext);
8
+ private authors;
9
+ private contentApiData?;
10
+ static normaliseQuotes(str: string): string;
11
+ constructor(byline: string, vanity: boolean, authors: Concept[], contentApiData?: CapiResponse | undefined);
11
12
  buildBylineTree(): Promise<{
12
- tree: {
13
- type: string;
14
- children: (AuthorLink | ContentTree.Text)[];
15
- };
16
- references: never[];
13
+ tree: ContentTree.Parent;
14
+ references: import("../resolvers/content-tree/references").ReferenceWithCAPIData[];
17
15
  }>;
18
16
  }
@@ -4,24 +4,49 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var _Byline_instances, _Byline_splitBylineByName, _Byline_buildUrlTree;
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ var _Byline_instances, _Byline_splitBylineByName;
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.Byline = void 0;
13
+ const updateTreeWithReferenceIds_1 = __importDefault(require("../resolvers/content-tree/updateTreeWithReferenceIds"));
10
14
  class Byline {
11
- constructor(byline, vanity, authorUrlMapping, context) {
15
+ static normaliseQuotes(str) {
16
+ return str.replaceAll("'", '’');
17
+ }
18
+ constructor(byline, vanity, authors, contentApiData) {
12
19
  _Byline_instances.add(this);
13
20
  this.byline = byline;
14
21
  this.vanity = vanity;
15
- this.authorUrlMapping = authorUrlMapping;
16
- this.context = context;
22
+ this.authors = authors;
23
+ this.contentApiData = contentApiData;
17
24
  }
18
25
  async buildBylineTree() {
19
26
  // Normalise apostrophes in byline string
20
- const bylineWithCorrectApostrophes = this.byline.replace("'", '’');
21
- const split = __classPrivateFieldGet(this, _Byline_instances, "m", _Byline_splitBylineByName).call(this, bylineWithCorrectApostrophes, [
22
- ...this.authorUrlMapping.keys(),
23
- ]);
24
- return __classPrivateFieldGet(this, _Byline_instances, "m", _Byline_buildUrlTree).call(this, this.authorUrlMapping, split);
27
+ const normalisedByline = Byline.normaliseQuotes(this.byline);
28
+ const bylineParts = __classPrivateFieldGet(this, _Byline_instances, "m", _Byline_splitBylineByName).call(this, normalisedByline, this.authors.map((author) => Byline.normaliseQuotes(author.prefLabel())));
29
+ const authorNameMapping = Object.fromEntries(this.authors.map((author) => {
30
+ return [Byline.normaliseQuotes(author.prefLabel()), author];
31
+ }));
32
+ const children = bylineParts.map((part) => {
33
+ const author = authorNameMapping[part];
34
+ const text = {
35
+ type: 'text',
36
+ value: part,
37
+ };
38
+ return author
39
+ ? {
40
+ type: 'author',
41
+ id: author.uuid(),
42
+ children: [text],
43
+ }
44
+ : text;
45
+ });
46
+ return (0, updateTreeWithReferenceIds_1.default)({
47
+ type: 'byline',
48
+ children,
49
+ }, this.contentApiData);
25
50
  }
26
51
  }
27
52
  exports.Byline = Byline;
@@ -30,29 +55,5 @@ _Byline_instances = new WeakSet(), _Byline_splitBylineByName = function _Byline_
30
55
  return [byline];
31
56
  const regex = new RegExp(`(${names.join('|')})`, 'ig');
32
57
  return byline.split(regex).filter((string) => string !== '');
33
- }, _Byline_buildUrlTree = async function _Byline_buildUrlTree(urlMapping, parts) {
34
- const children = await Promise.all(parts.map(async (part) => {
35
- const fullUrl = urlMapping.get(part);
36
- const vanityUrl = this.vanity && fullUrl
37
- ? await this.context.dataSources.vanityUrls.get(fullUrl)
38
- : null;
39
- if (fullUrl) {
40
- return {
41
- type: 'author-link',
42
- href: vanityUrl || fullUrl,
43
- children: [{ type: 'text', value: part }],
44
- };
45
- }
46
- else {
47
- return {
48
- type: 'text',
49
- value: part,
50
- };
51
- }
52
- }));
53
- return {
54
- tree: { type: 'root', children },
55
- references: [],
56
- };
57
58
  };
58
59
  //# sourceMappingURL=Byline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Byline.js","sourceRoot":"","sources":["../../src/model/Byline.ts"],"names":[],"mappings":";;;;;;;;;AAIA,MAAa,MAAM;IACjB,YACU,MAAc,EACd,MAAe,EACf,gBAAqC,EACrC,OAAqB;;QAHrB,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAS;QACf,qBAAgB,GAAhB,gBAAgB,CAAqB;QACrC,YAAO,GAAP,OAAO,CAAc;IAC5B,CAAC;IAEJ,KAAK,CAAC,eAAe;QACnB,yCAAyC;QACzC,MAAM,4BAA4B,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAElE,MAAM,KAAK,GAAG,uBAAA,IAAI,oDAAmB,MAAvB,IAAI,EAAoB,4BAA4B,EAAE;YAClE,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE;SAChC,CAAC,CAAA;QACF,OAAO,uBAAA,IAAI,+CAAc,MAAlB,IAAI,EAAe,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;IACzD,CAAC;CAqCF;AArDD,wBAqDC;kGAnCoB,MAAc,EAAE,KAAe;IAChD,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAClC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACtD,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,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kGANoB,MAAc,EAAE,KAAe;IAChD,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAElC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACtD,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,EAAE,CAAC,CAAA;AAC9D,CAAC"}
@@ -5,92 +5,145 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Byline_1 = require("./Byline");
7
7
  const dummyContext_1 = __importDefault(require("../fixtures/dummyContext"));
8
+ const Concept_1 = require("./Concept");
8
9
  const vanity = true;
9
10
  describe('byline transformation', () => {
10
11
  test('adds a link around a single known author', async () => {
11
12
  const bylineText = 'Chris Giles in London';
12
- const authorUrlMapping = new Map([
13
- [
14
- 'Chris Giles',
15
- 'https://www.ft.com/stream/uuid/1d556016-ad16-4fe7-8724-42b3fb15ad28',
16
- ],
17
- ]);
18
- const byline = new Byline_1.Byline(bylineText, vanity, authorUrlMapping, dummyContext_1.default);
13
+ const authors = [
14
+ new Concept_1.Concept({
15
+ id: 'https://api.ft.com/things/1d556016-ad16-4fe7-8724-42b3fb15ad28',
16
+ apiUrl: 'https://api.ft.com/people/1d556016-ad16-4fe7-8724-42b3fb15ad28',
17
+ prefLabel: 'Chris Giles',
18
+ directType: 'http://www.ft.com/ontology/person/Person',
19
+ predicate: 'http://www.ft.com/ontology/annotation/hasAuthor',
20
+ types: [
21
+ 'http://www.ft.com/ontology/core/Thing',
22
+ 'http://www.ft.com/ontology/concept/Concept',
23
+ 'http://www.ft.com/ontology/person/Person',
24
+ ],
25
+ }, dummyContext_1.default),
26
+ ];
27
+ const byline = new Byline_1.Byline(bylineText, vanity, authors);
19
28
  const result = await byline.buildBylineTree();
20
29
  expect(result).toMatchSnapshot();
21
30
  });
22
31
  test('adds links around multiple known authors', async () => {
23
32
  const bylineText = 'Chris Giles and Martin Wolf in London';
24
- const authorUrlMapping = new Map([
25
- [
26
- 'Chris Giles',
27
- 'https://www.ft.com/stream/uuid/1d556016-ad16-4fe7-8724-42b3fb15ad28',
28
- ],
29
- [
30
- 'Martin Wolf',
31
- 'https://www.ft.com/stream/uuid/7c1e1e72-57ae-4461-862a-f8d24dd42e22',
32
- ],
33
- ]);
34
- const byline = new Byline_1.Byline(bylineText, vanity, authorUrlMapping, dummyContext_1.default);
33
+ const authors = [
34
+ new Concept_1.Concept({
35
+ id: 'https://api.ft.com/things/1d556016-ad16-4fe7-8724-42b3fb15ad28',
36
+ apiUrl: 'https://api.ft.com/people/1d556016-ad16-4fe7-8724-42b3fb15ad28',
37
+ prefLabel: 'Chris Giles',
38
+ directType: 'http://www.ft.com/ontology/person/Person',
39
+ predicate: 'http://www.ft.com/ontology/annotation/hasAuthor',
40
+ types: [
41
+ 'http://www.ft.com/ontology/core/Thing',
42
+ 'http://www.ft.com/ontology/concept/Concept',
43
+ 'http://www.ft.com/ontology/person/Person',
44
+ ],
45
+ }, dummyContext_1.default),
46
+ new Concept_1.Concept({
47
+ id: 'https://api.ft.com/things/7c1e1e72-57ae-4461-862a-f8d24dd42e22',
48
+ apiUrl: 'https://api.ft.com/people/7c1e1e72-57ae-4461-862a-f8d24dd42e22',
49
+ prefLabel: 'Martin Wolf',
50
+ directType: 'http://www.ft.com/ontology/person/Person',
51
+ predicate: 'http://www.ft.com/ontology/annotation/hasAuthor',
52
+ types: [
53
+ 'http://www.ft.com/ontology/core/Thing',
54
+ 'http://www.ft.com/ontology/concept/Concept',
55
+ 'http://www.ft.com/ontology/person/Person',
56
+ ],
57
+ }, dummyContext_1.default),
58
+ ];
59
+ const byline = new Byline_1.Byline(bylineText, vanity, authors);
35
60
  const result = await byline.buildBylineTree();
36
61
  expect(result).toMatchSnapshot();
37
62
  });
38
63
  test('ignores unknown authors in byline text', async () => {
39
64
  const bylineText = 'Chris Giles and Nick Ramsbottom in London';
40
- const authorUrlMapping = new Map([
41
- [
42
- 'Chris Giles',
43
- 'https://www.ft.com/stream/uuid/1d556016-ad16-4fe7-8724-42b3fb15ad28',
44
- ],
45
- ]);
46
- const byline = new Byline_1.Byline(bylineText, vanity, authorUrlMapping, dummyContext_1.default);
65
+ const authors = [
66
+ new Concept_1.Concept({
67
+ id: 'https://api.ft.com/things/1d556016-ad16-4fe7-8724-42b3fb15ad28',
68
+ apiUrl: 'https://api.ft.com/people/1d556016-ad16-4fe7-8724-42b3fb15ad28',
69
+ prefLabel: 'Chris Giles',
70
+ directType: 'http://www.ft.com/ontology/person/Person',
71
+ predicate: 'http://www.ft.com/ontology/annotation/hasAuthor',
72
+ types: [
73
+ 'http://www.ft.com/ontology/core/Thing',
74
+ 'http://www.ft.com/ontology/concept/Concept',
75
+ 'http://www.ft.com/ontology/person/Person',
76
+ ],
77
+ }, dummyContext_1.default),
78
+ ];
79
+ const byline = new Byline_1.Byline(bylineText, vanity, authors);
47
80
  const result = await byline.buildBylineTree();
48
81
  expect(result).toMatchSnapshot();
49
82
  });
50
83
  test('ignores extra authors in annotations array', async () => {
51
84
  const bylineText = 'Martin Wolf in London';
52
- const authorUrlMapping = new Map([
53
- [
54
- 'Chris Giles',
55
- 'https://www.ft.com/stream/uuid/1d556016-ad16-4fe7-8724-42b3fb15ad28',
56
- ],
57
- [
58
- 'Martin Wolf',
59
- 'https://www.ft.com/stream/uuid/7c1e1e72-57ae-4461-862a-f8d24dd42e22',
60
- ],
61
- ]);
62
- const byline = new Byline_1.Byline(bylineText, vanity, authorUrlMapping, dummyContext_1.default);
85
+ const authors = [
86
+ new Concept_1.Concept({
87
+ id: 'https://api.ft.com/things/7c1e1e72-57ae-4461-862a-f8d24dd42e22',
88
+ apiUrl: 'https://api.ft.com/people/7c1e1e72-57ae-4461-862a-f8d24dd42e22',
89
+ prefLabel: 'Martin Wolf',
90
+ directType: 'http://www.ft.com/ontology/person/Person',
91
+ predicate: 'http://www.ft.com/ontology/annotation/hasAuthor',
92
+ types: [
93
+ 'http://www.ft.com/ontology/core/Thing',
94
+ 'http://www.ft.com/ontology/concept/Concept',
95
+ 'http://www.ft.com/ontology/person/Person',
96
+ ],
97
+ }, dummyContext_1.default),
98
+ ];
99
+ const byline = new Byline_1.Byline(bylineText, vanity, authors);
63
100
  const result = await byline.buildBylineTree();
64
101
  expect(result).toMatchSnapshot();
65
102
  });
66
103
  test('handles bylines without any matching authors', async () => {
67
104
  const bylineText = 'Chris Giles and Nick Ramsbottom in London';
68
- const authorUrlMapping = new Map([]);
69
- const byline = new Byline_1.Byline(bylineText, vanity, authorUrlMapping, dummyContext_1.default);
105
+ const authors = [];
106
+ const byline = new Byline_1.Byline(bylineText, vanity, authors);
70
107
  const result = await byline.buildBylineTree();
71
108
  expect(result).toMatchSnapshot();
72
109
  });
73
110
  test('converts straight apostrophes in byline', async () => {
74
111
  const bylineText = "Sarah O'Connor in Bali";
75
- const authorUrlMapping = new Map([
76
- [
77
- 'Sarah O’Connor',
78
- 'https://www.ft.com/stream/uuid/1d556016-ad16-4fe7-8724-eeeeeeeeeeee',
79
- ],
80
- ]);
81
- const byline = new Byline_1.Byline(bylineText, vanity, authorUrlMapping, dummyContext_1.default);
112
+ const authors = [
113
+ new Concept_1.Concept({
114
+ id: 'https://api.ft.com/things/1d556016-ad16-4fe7-8724-eeeeeeeeeeee',
115
+ apiUrl: 'https://api.ft.com/people/1d556016-ad16-4fe7-8724-eeeeeeeeeeee',
116
+ prefLabel: 'Sarah O’Connor',
117
+ directType: 'http://www.ft.com/ontology/person/Person',
118
+ predicate: 'http://www.ft.com/ontology/annotation/hasAuthor',
119
+ types: [
120
+ 'http://www.ft.com/ontology/core/Thing',
121
+ 'http://www.ft.com/ontology/concept/Concept',
122
+ 'http://www.ft.com/ontology/person/Person',
123
+ ],
124
+ }, dummyContext_1.default),
125
+ ];
126
+ const byline = new Byline_1.Byline(bylineText, vanity, authors);
82
127
  const result = await byline.buildBylineTree();
83
128
  expect(result).toMatchSnapshot();
84
129
  });
85
130
  test('leaves curly apostrophes in byline', async () => {
86
131
  const bylineText = 'Sarah O’Connor in Bali';
87
- const authorUrlMapping = new Map([
88
- [
89
- 'Sarah O’Connor',
90
- 'https://www.ft.com/stream/uuid/1d556016-ad16-4fe7-8724-eeeeeeeeeeee',
91
- ],
92
- ]);
93
- const byline = new Byline_1.Byline(bylineText, vanity, authorUrlMapping, dummyContext_1.default);
132
+ const authors = [
133
+ new Concept_1.Concept({
134
+ id: 'https://api.ft.com/things/1d556016-ad16-4fe7-8724-eeeeeeeeeeee',
135
+ apiUrl: 'https://api.ft.com/people/1d556016-ad16-4fe7-8724-eeeeeeeeeeee',
136
+ prefLabel: 'Sarah O’Connor',
137
+ directType: 'http://www.ft.com/ontology/person/Person',
138
+ predicate: 'http://www.ft.com/ontology/annotation/hasAuthor',
139
+ types: [
140
+ 'http://www.ft.com/ontology/core/Thing',
141
+ 'http://www.ft.com/ontology/concept/Concept',
142
+ 'http://www.ft.com/ontology/person/Person',
143
+ ],
144
+ }, dummyContext_1.default),
145
+ ];
146
+ const byline = new Byline_1.Byline(bylineText, vanity, authors);
94
147
  const result = await byline.buildBylineTree();
95
148
  expect(result).toMatchSnapshot();
96
149
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Byline.test.js","sourceRoot":"","sources":["../../src/model/Byline.test.ts"],"names":[],"mappings":";;;;;AAAA,qCAAiC;AACjC,4EAA8C;AAC9C,MAAM,MAAM,GAAG,IAAI,CAAA;AAEnB,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,IAAI,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,UAAU,GAAG,uBAAuB,CAAA;QAC1C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;YAC/B;gBACE,aAAa;gBACb,qEAAqE;aACtE;SACF,CAAC,CAA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import type { ImageSet, ContentTypeSchemas, ClipSet } from '../types/internal-content';
1
+ import type { ImageSet, ContentTypeSchemas, ClipSet } from './schemas/capi/internal-content';
2
2
  import type { QueryContext } from '..';
3
3
  import { CAPIImage } from './Image';
4
4
  import { Concept } from './Concept';
5
5
  import { Person } from './Person';
6
6
  import { AccessLevel, ContentType, PackageDesign, CanBeSyndicated } from '../resolvers/scalars';
7
7
  import { LiteralUnionScalarValues } from '../resolvers/literal-union';
8
- import { ContentPackageContainsArgs, ContentUrlArgs, Media, TableOfContents } from '../generated';
8
+ import { ContentAnnotationsArgs, ContentPackageContainsArgs, ContentUrlArgs, Media, TableOfContents } from '../generated';
9
9
  import { RichText } from './RichText';
10
10
  type Design = {
11
11
  theme: LiteralUnionScalarValues<typeof PackageDesign>;
@@ -27,14 +27,10 @@ export declare class CapiResponse {
27
27
  description: string;
28
28
  } | null | undefined;
29
29
  byline({ vanity }: Partial<ContentUrlArgs>): Promise<{
30
- tree: {
31
- type: string;
32
- children: (import("../resolvers/content-tree/Workarounds").AuthorLink | import("@financial-times/content-tree").ContentTree.Text)[];
33
- };
34
- references: never[];
35
- }> | null;
36
- rawByline(): string | null;
37
- annotations(): Concept[];
30
+ tree: import("@financial-times/content-tree").ContentTree.Parent;
31
+ references: import("../resolvers/content-tree/references").ReferenceWithCAPIData[];
32
+ } | null>;
33
+ annotations({ byPredicate }?: ContentAnnotationsArgs): Concept[];
38
34
  types(): string[];
39
35
  url({ relative, vanity }: Partial<ContentUrlArgs>): Promise<string>;
40
36
  absoluteUrl(vanity?: boolean | null): Promise<string>;
@@ -80,12 +76,13 @@ export declare class CapiResponse {
80
76
  textShadow?: boolean | undefined;
81
77
  layoutWidth?: string | undefined;
82
78
  } | null | undefined;
83
- authors(): Person[] | null;
79
+ authors(): Promise<Person[]>;
80
+ primaryAuthor(): Promise<Person | null>;
84
81
  accessLevel(): LiteralUnionScalarValues<typeof AccessLevel>;
85
82
  editorialDesk(): string | null;
86
83
  canBeSyndicated(): LiteralUnionScalarValues<typeof CanBeSyndicated>;
87
84
  instantAlertConcept(): Concept | null;
88
- originatingParty(): string | null;
85
+ originatingParty(): "Reuters" | "FT";
89
86
  summary(): {
90
87
  bodyXML: string;
91
88
  } | null | undefined;
@@ -95,6 +92,7 @@ export declare class CapiResponse {
95
92
  publishedDate(): string;
96
93
  publishedTimestamp(): number;
97
94
  firstPublishedDate(): string;
95
+ modifiedTimestamp(): number;
98
96
  publishReference(): string | null;
99
97
  alternativeTitle(): {
100
98
  promotionalTitle: string;
@@ -106,7 +104,7 @@ export declare class CapiResponse {
106
104
  containedIn(): Promise<CapiResponse | null>;
107
105
  metaLink(): Promise<Concept | CapiResponse | null>;
108
106
  metaAltLink(): Promise<Concept | null>;
109
- metaPrefixText(): Promise<string>;
107
+ metaPrefixText(): Promise<string | null>;
110
108
  teaser(): CapiResponse;
111
109
  isEditorsChoice(): boolean;
112
110
  isExclusive(): boolean;
@@ -118,14 +116,12 @@ export declare class CapiResponse {
118
116
  mainImage(): CAPIImage | null;
119
117
  teaserImage(): CAPIImage | null;
120
118
  rawCapiData(): ContentTypeSchemas;
121
- getAuthorUrlMapping(): Map<string, string>;
122
119
  getBrandConcept(): Concept | undefined;
123
120
  getGenreConcept(): Concept | undefined;
124
121
  getPodcastBrandConcept(): Concept | undefined;
125
122
  getPackageBrandConcept(): Concept | undefined;
126
123
  getDisplayConcept(): Concept | undefined;
127
124
  getPodcastDisplayConcept(): Concept | undefined;
128
- getAuthors(): Concept[];
129
125
  isColumn(): boolean;
130
126
  isOpinion(): boolean;
131
127
  isAlphaville(): boolean;
@@ -7,7 +7,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
7
7
  var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
- var _CapiResponse_instances, _CapiResponse_rawAnnotations, _CapiResponse_teaserMetadata, _CapiResponse_createCAPIImage, _CapiResponse_createStreamLink;
10
+ var _CapiResponse_instances, _CapiResponse_rawAnnotations, _CapiResponse_teaserMetadata, _CapiResponse_createCAPIImage;
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CapiResponse = void 0;
13
13
  const n_concept_ids_1 = __importDefault(require("@financial-times/n-concept-ids"));
@@ -17,7 +17,6 @@ const errors_1 = require("@dotcom-reliability-kit/errors");
17
17
  const lodash_sortby_1 = __importDefault(require("lodash.sortby"));
18
18
  const Image_1 = require("./Image");
19
19
  const Concept_1 = require("./Concept");
20
- const Person_1 = require("./Person");
21
20
  const isError_1 = __importDefault(require("../helpers/isError"));
22
21
  const metadata_1 = require("../helpers/metadata");
23
22
  const capi_1 = require("./schemas/capi");
@@ -116,21 +115,18 @@ class CapiResponse {
116
115
  return this.capiData.leadFlourish;
117
116
  return null;
118
117
  }
119
- byline({ vanity }) {
120
- const bylineText = this.rawByline();
121
- if (!bylineText)
118
+ async byline({ vanity }) {
119
+ if (!this.capiData.byline)
122
120
  return null;
123
- const authorUrlMapping = this.getAuthorUrlMapping();
124
- return new Byline_1.Byline(bylineText, Boolean(vanity), authorUrlMapping, this.context).buildBylineTree();
121
+ const byline = new Byline_1.Byline(this.capiData.byline, Boolean(vanity), this.annotations({ byPredicate: Concept_1.predicates.hasAuthor }), this);
122
+ return byline.buildBylineTree();
125
123
  }
126
- rawByline() {
127
- if ('byline' in this.capiData && this.capiData.byline) {
128
- return this.capiData.byline;
124
+ annotations({ byPredicate } = {}) {
125
+ const concepts = (0, lodash_sortby_1.default)(__classPrivateFieldGet(this, _CapiResponse_instances, "m", _CapiResponse_rawAnnotations).call(this), ['predicate', 'id']).map((concept) => new Concept_1.Concept(concept, this.context));
126
+ if (byPredicate) {
127
+ return concepts.filter((concept) => concept.predicate() === byPredicate);
129
128
  }
130
- return null;
131
- }
132
- annotations() {
133
- return (0, lodash_sortby_1.default)(__classPrivateFieldGet(this, _CapiResponse_instances, "m", _CapiResponse_rawAnnotations).call(this), ['predicate', 'id']).map((concept) => new Concept_1.Concept(concept, this.context));
129
+ return concepts;
134
130
  }
135
131
  types() {
136
132
  return this.capiData.types;
@@ -171,11 +167,18 @@ class CapiResponse {
171
167
  return this.capiData.topper;
172
168
  return null;
173
169
  }
174
- authors() {
175
- const authors = this.getAuthors();
176
- return authors.length === 0
177
- ? null
178
- : authors.map((author) => new Person_1.Person(author, this, this.context));
170
+ async authors() {
171
+ const authors = this.annotations({ byPredicate: Concept_1.predicates.hasAuthor });
172
+ return Promise.all(authors.map((author) => this.context.dataSources.capi.getPerson(author.uuid())));
173
+ }
174
+ async primaryAuthor() {
175
+ const primaryAuthor = this.annotations({
176
+ byPredicate: Concept_1.predicates.hasAuthor,
177
+ })[0];
178
+ if (primaryAuthor) {
179
+ return this.context.dataSources.capi.getPerson(primaryAuthor.uuid());
180
+ }
181
+ return null;
179
182
  }
180
183
  accessLevel() {
181
184
  return this.capiData.accessLevel ?? 'subscribed';
@@ -187,11 +190,10 @@ class CapiResponse {
187
190
  return this.capiData.canBeSyndicated;
188
191
  }
189
192
  instantAlertConcept() {
190
- const authors = this.getAuthors();
191
- const authorConcept = authors.length === 1 ? authors[0] : null;
193
+ const authors = this.annotations({ byPredicate: Concept_1.predicates.hasAuthor });
192
194
  const displayConcept = this.getDisplayConcept();
193
- if ((this.isOpinion() || this.isAlphaville()) && authorConcept) {
194
- return authorConcept;
195
+ if ((this.isColumn() || this.isAlphaville()) && authors[0]) {
196
+ return authors[0];
195
197
  }
196
198
  else if (displayConcept?.isOrganisation()) {
197
199
  return displayConcept;
@@ -233,14 +235,23 @@ class CapiResponse {
233
235
  return null;
234
236
  }
235
237
  publishedDate() {
238
+ // WARNING:20240815:RB: "publishedDate" is only updated for editorial
239
+ // publishes where they explictly check a box to update it. If you need
240
+ // all editorial changes you may be after "lastModified" instead.
236
241
  return this.capiData.publishedDate;
237
242
  }
238
243
  publishedTimestamp() {
244
+ // WARNING:20240815:RB: "publishedTimestamp" is only updated for editorial
245
+ // publishes where they explictly check a box to update it. If you need
246
+ // all editorial changes you may be after "modifiedTimestamp" instead.
239
247
  return new Date(this.capiData.publishedDate).getTime();
240
248
  }
241
249
  firstPublishedDate() {
242
250
  return this.capiData.firstPublishedDate || this.capiData.publishedDate;
243
251
  }
252
+ modifiedTimestamp() {
253
+ return new Date(this.capiData.lastModified).getTime();
254
+ }
244
255
  publishReference() {
245
256
  return this.capiData.publishReference ?? null;
246
257
  }
@@ -310,7 +321,7 @@ class CapiResponse {
310
321
  }
311
322
  async metaPrefixText() {
312
323
  const meta = await __classPrivateFieldGet(this, _CapiResponse_instances, "m", _CapiResponse_teaserMetadata).call(this);
313
- return meta.prefixText;
324
+ return meta.prefixText ?? null;
314
325
  }
315
326
  teaser() {
316
327
  const clone = (0, clone_deep_1.default)(this.capiData);
@@ -356,16 +367,6 @@ class CapiResponse {
356
367
  rawCapiData() {
357
368
  return (0, clone_deep_1.default)(this.capiData);
358
369
  }
359
- getAuthorUrlMapping() {
360
- const authorAnnotations = this.getAuthors();
361
- return authorAnnotations.reduce((mapping, author) => {
362
- if (author.prefLabel()) {
363
- const nameWithCurlyApostrophes = author.prefLabel().replace("'", '’');
364
- mapping.set(nameWithCurlyApostrophes, __classPrivateFieldGet(this, _CapiResponse_instances, "m", _CapiResponse_createStreamLink).call(this, author.uuid()));
365
- }
366
- return mapping;
367
- }, new Map());
368
- }
369
370
  getBrandConcept() {
370
371
  return this.annotations().find((annotation) => annotation.isBrand());
371
372
  }
@@ -384,11 +385,9 @@ class CapiResponse {
384
385
  getPodcastDisplayConcept() {
385
386
  return this.annotations().find((annotation) => annotation.isPodcastDisplayConcept());
386
387
  }
387
- getAuthors() {
388
- return this.annotations().filter((annotation) => annotation.isAuthor());
389
- }
390
388
  isColumn() {
391
- return this.isOpinion() && this.getAuthors().length === 1;
389
+ return (this.isOpinion() &&
390
+ this.annotations({ byPredicate: Concept_1.predicates.hasAuthor }).length === 1);
392
391
  }
393
392
  isOpinion() {
394
393
  // CI-2038 HACK to identify live blog opinion posts by the "Comment:" prefix in the title
@@ -541,7 +540,5 @@ _CapiResponse_instances = new WeakSet(), _CapiResponse_rawAnnotations = function
541
540
  return new Image_1.CAPIImage(image.members[0], this.context);
542
541
  }
543
542
  return null;
544
- }, _CapiResponse_createStreamLink = function _CapiResponse_createStreamLink(streamUuid) {
545
- return `https://www.ft.com/stream/${streamUuid}`;
546
543
  };
547
544
  //# sourceMappingURL=CapiResponse.js.map