@financial-times/cp-content-pipeline-schema 2.15.0 → 3.0.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.
- package/CHANGELOG.md +39 -0
- package/lib/datasources/capi.d.ts +2 -2
- package/lib/datasources/capi.js +4 -2
- package/lib/datasources/capi.js.map +1 -1
- package/lib/datasources/capi.test.js +2 -2
- package/lib/fixtures/capiObject.d.ts +2 -2
- package/lib/fixtures/capiObject.js +2 -0
- package/lib/fixtures/capiObject.js.map +1 -1
- package/lib/fixtures/capiPerson.d.ts +1 -1
- package/lib/generated/index.d.ts +296 -131
- package/lib/helpers/decorateHeadshotUrl.d.ts +1 -2
- package/lib/helpers/decorateHeadshotUrl.js +2 -3
- package/lib/helpers/decorateHeadshotUrl.js.map +1 -1
- package/lib/model/Byline.d.ts +8 -10
- package/lib/model/Byline.js +34 -33
- package/lib/model/Byline.js.map +1 -1
- package/lib/model/Byline.test.js +105 -52
- package/lib/model/Byline.test.js.map +1 -1
- package/lib/model/CapiResponse.d.ts +12 -16
- package/lib/model/CapiResponse.js +38 -41
- package/lib/model/CapiResponse.js.map +1 -1
- package/lib/model/CapiResponse.test.js +7 -18
- package/lib/model/CapiResponse.test.js.map +1 -1
- package/lib/model/Clip.d.ts +1 -1
- package/lib/model/Concept.d.ts +1 -1
- package/lib/model/Concept.js +1 -2
- package/lib/model/Concept.js.map +1 -1
- package/lib/model/FlourishSource.d.ts +1 -1
- package/lib/model/FlourishSource.js.map +1 -1
- package/lib/model/Image.d.ts +1 -1
- package/lib/model/LeadFlourish.test.js +1 -0
- package/lib/model/LeadFlourish.test.js.map +1 -1
- package/lib/model/Person.d.ts +6 -12
- package/lib/model/Person.js +39 -66
- package/lib/model/Person.js.map +1 -1
- package/lib/model/Person.test.js +7 -60
- package/lib/model/Person.test.js.map +1 -1
- package/lib/model/Picture.d.ts +1 -1
- package/lib/model/RichText.d.ts +1 -2
- package/lib/model/Topper.d.ts +1 -1
- package/lib/model/Topper.js +10 -8
- package/lib/model/Topper.js.map +1 -1
- package/lib/model/Topper.test.js +9 -10
- package/lib/model/Topper.test.js.map +1 -1
- package/lib/model/schemas/capi/article.d.ts +7 -4
- package/lib/model/schemas/capi/article.js +1 -0
- package/lib/model/schemas/capi/article.js.map +1 -1
- package/lib/model/schemas/capi/audio.d.ts +7 -4
- package/lib/model/schemas/capi/audio.js +1 -0
- package/lib/model/schemas/capi/audio.js.map +1 -1
- package/lib/model/schemas/capi/base-schema.d.ts +14 -123
- package/lib/model/schemas/capi/base-schema.js +7 -6
- package/lib/model/schemas/capi/base-schema.js.map +1 -1
- package/lib/model/schemas/capi/content-package.d.ts +10 -5
- package/lib/model/schemas/capi/content-package.js +2 -0
- package/lib/model/schemas/capi/content-package.js.map +1 -1
- package/lib/model/schemas/capi/index.d.ts +41 -22
- package/lib/model/schemas/capi/internal-content.d.ts +24 -0
- package/lib/model/schemas/capi/internal-content.js +3 -0
- package/lib/model/schemas/capi/internal-content.js.map +1 -0
- package/lib/model/schemas/capi/live-blog-package.d.ts +7 -4
- package/lib/model/schemas/capi/live-blog-package.js +1 -0
- package/lib/model/schemas/capi/live-blog-package.js.map +1 -1
- package/lib/model/schemas/capi/placeholder.d.ts +7 -4
- package/lib/model/schemas/capi/placeholder.js +1 -0
- package/lib/model/schemas/capi/placeholder.js.map +1 -1
- package/lib/model/schemas/capi/video.d.ts +10 -5
- package/lib/model/schemas/capi/video.js +2 -0
- package/lib/model/schemas/capi/video.js.map +1 -1
- package/lib/resolvers/concept.d.ts +37 -2
- package/lib/resolvers/concept.js +17 -10
- package/lib/resolvers/concept.js.map +1 -1
- package/lib/resolvers/content-tree/Workarounds.d.ts +19 -11
- package/lib/resolvers/content-tree/references/Author.d.ts +4 -0
- package/lib/resolvers/content-tree/references/Author.js +14 -0
- package/lib/resolvers/content-tree/references/Author.js.map +1 -0
- package/lib/resolvers/content-tree/references/ClipSet.d.ts +1 -1
- package/lib/resolvers/content-tree/references/ClipSet.js +1 -1
- package/lib/resolvers/content-tree/references/ClipSet.js.map +1 -1
- package/lib/resolvers/content-tree/references/Flourish.d.ts +1 -1
- package/lib/resolvers/content-tree/references/Reference.d.ts +1 -1
- package/lib/resolvers/content-tree/references/index.d.ts +4 -2
- package/lib/resolvers/content-tree/references/index.js +4 -1
- package/lib/resolvers/content-tree/references/index.js.map +1 -1
- package/lib/resolvers/content-tree/updateTreeWithReferenceIds.d.ts +3 -3
- package/lib/resolvers/content-tree/updateTreeWithReferenceIds.js +2 -3
- package/lib/resolvers/content-tree/updateTreeWithReferenceIds.js.map +1 -1
- package/lib/resolvers/content.d.ts +27 -18
- package/lib/resolvers/content.js +4 -2
- package/lib/resolvers/content.js.map +1 -1
- package/lib/resolvers/image.d.ts +12 -12
- package/lib/resolvers/index.d.ts +89 -42
- package/lib/resolvers/leadFlourish.d.ts +2 -1
- package/lib/resolvers/leadFlourish.js +1 -0
- package/lib/resolvers/leadFlourish.js.map +1 -1
- package/lib/resolvers/person.d.ts +1 -1
- package/lib/resolvers/person.js +1 -1
- package/lib/resolvers/person.js.map +1 -1
- package/lib/resolvers/picture.d.ts +4 -4
- package/lib/resolvers/richText.d.ts +1 -1
- package/lib/resolvers/teaser.d.ts +1 -1
- package/lib/resolvers/topper.d.ts +3 -3
- package/package.json +1 -1
- package/queries/article.graphql +35 -13
- package/src/datasources/capi.test.ts +3 -3
- package/src/datasources/capi.ts +5 -3
- package/src/fixtures/capiObject.ts +4 -2
- package/src/fixtures/capiPerson.ts +1 -1
- package/src/generated/index.ts +321 -132
- package/src/helpers/decorateHeadshotUrl.ts +2 -2
- package/src/model/Byline.test.ts +136 -55
- package/src/model/Byline.ts +49 -39
- package/src/model/CapiResponse.test.ts +9 -25
- package/src/model/CapiResponse.ts +83 -56
- package/src/model/Clip.ts +1 -1
- package/src/model/Concept.ts +3 -3
- package/src/model/FlourishSource.ts +1 -1
- package/src/model/Image.test.ts +1 -1
- package/src/model/Image.ts +1 -1
- package/src/model/LeadFlourish.test.ts +1 -0
- package/src/model/Person.test.ts +11 -62
- package/src/model/Person.ts +47 -51
- package/src/model/Picture.test.ts +1 -1
- package/src/model/Picture.ts +1 -1
- package/src/model/Topper.test.ts +22 -18
- package/src/model/Topper.ts +10 -9
- package/src/model/__snapshots__/Byline.test.ts.snap +166 -27
- package/src/model/schemas/capi/article.ts +1 -0
- package/src/model/schemas/capi/audio.ts +1 -0
- package/src/model/schemas/capi/base-schema.ts +5 -4
- package/src/model/schemas/capi/content-package.ts +2 -0
- package/src/model/schemas/capi/internal-content.ts +45 -0
- package/src/model/schemas/capi/live-blog-package.ts +1 -0
- package/src/model/schemas/capi/placeholder.ts +1 -0
- package/src/model/schemas/capi/video.ts +2 -0
- package/src/resolvers/concept.ts +29 -12
- package/src/resolvers/content-tree/Workarounds.ts +39 -20
- package/src/resolvers/content-tree/references/Author.ts +18 -0
- package/src/resolvers/content-tree/references/ClipSet.ts +6 -8
- package/src/resolvers/content-tree/references/ImageSet.ts +1 -1
- package/src/resolvers/content-tree/references/ScrollyImage.ts +1 -1
- package/src/resolvers/content-tree/references/index.ts +6 -1
- package/src/resolvers/content-tree/updateTreeWithReferenceIds.ts +6 -8
- package/src/resolvers/content.ts +4 -2
- package/src/resolvers/leadFlourish.ts +1 -0
- package/src/resolvers/person.ts +1 -1
- package/src/types/n-display-metadata.d.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/typedefs/clip.graphql +2 -2
- package/typedefs/concept.graphql +64 -2
- package/typedefs/content.graphql +63 -39
- package/typedefs/image.graphql +12 -12
- package/typedefs/leadFlourish.graphql +32 -0
- package/typedefs/person.graphql +2 -2
- package/typedefs/picture.graphql +6 -6
- package/typedefs/references/author.graphql +7 -0
- package/typedefs/references/clipSet.graphql +14 -2
- package/typedefs/references/tweet.graphql +1 -1
- package/typedefs/teaser.graphql +10 -10
- package/src/types/internal-content.d.ts +0 -55
- package/typedefs/leadFlouish.graphql +0 -29
|
@@ -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
|
-
|
|
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
|
|
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":"
|
|
1
|
+
{"version":3,"file":"decorateHeadshotUrl.js","sourceRoot":"","sources":["../../src/helpers/decorateHeadshotUrl.ts"],"names":[],"mappings":";;AAOA,sCAoBC;AAzBD,MAAM,UAAU,GACd,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,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC7B,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjC,CAAC"}
|
package/lib/model/Byline.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { ContentTree } from '@financial-times/content-tree';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
|
9
|
-
private
|
|
10
|
-
|
|
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
|
-
|
|
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
|
}
|
package/lib/model/Byline.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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.
|
|
16
|
-
this.
|
|
22
|
+
this.authors = authors;
|
|
23
|
+
this.contentApiData = contentApiData;
|
|
17
24
|
}
|
|
18
25
|
async buildBylineTree() {
|
|
19
26
|
// Normalise apostrophes in byline string
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
package/lib/model/Byline.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Byline.js","sourceRoot":"","sources":["../../src/model/Byline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Byline.js","sourceRoot":"","sources":["../../src/model/Byline.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,sHAA6F;AAG7F,MAAa,MAAM;IACjB,MAAM,CAAC,eAAe,CAAC,GAAW;QAChC,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACjC,CAAC;IAED,YACU,MAAc,EACd,MAAe,EACf,OAAkB,EAClB,cAA6B;;QAH7B,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAS;QACf,YAAO,GAAP,OAAO,CAAW;QAClB,mBAAc,GAAd,cAAc,CAAe;IACpC,CAAC;IAEJ,KAAK,CAAC,eAAe;QACnB,yCAAyC;QACzC,MAAM,gBAAgB,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAE5D,MAAM,WAAW,GAAG,uBAAA,IAAI,oDAAmB,MAAvB,IAAI,EACtB,gBAAgB,EAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CACzE,CAAA;QAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAC1C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1B,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,MAAM,CAAU,CAAA;QACtE,CAAC,CAAC,CACH,CAAA;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAiC,EAAE;YACvE,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;YACtC,MAAM,IAAI,GAAqB;gBAC7B,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,IAAI;aACZ,CAAA;YAED,OAAO,MAAM;gBACX,CAAC,CAAC;oBACE,IAAI,EAAE,QAAQ;oBACd,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE;oBACjB,QAAQ,EAAE,CAAC,IAAI,CAAC;iBACjB;gBACH,CAAC,CAAC,IAAI,CAAA;QACV,CAAC,CAAC,CAAA;QAEF,OAAO,IAAA,oCAA0B,EAC/B;YACE,IAAI,EAAE,QAAQ;YACd,QAAQ;SACY,EACtB,IAAI,CAAC,cAAc,CACpB,CAAA;IACH,CAAC;CAQF;AA1DD,wBA0DC;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"}
|
package/lib/model/Byline.test.js
CHANGED
|
@@ -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
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'https://
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
'https://
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
'https://
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'https://
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
69
|
-
const byline = new Byline_1.Byline(bylineText, vanity,
|
|
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
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
'https://
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'https://
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"Byline.test.js","sourceRoot":"","sources":["../../src/model/Byline.test.ts"],"names":[],"mappings":";;;;;AAAA,qCAAiC;AACjC,4EAA8C;AAC9C,uCAAmC;AAEnC,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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gBACpE,MAAM,EACJ,gEAAgE;gBAClE,SAAS,EAAE,gBAAgB;gBAC3B,UAAU,EAAE,0CAA0C;gBACtD,SAAS,EAAE,iDAAiD;gBAC5D,KAAK,EAAE;oBACL,uCAAuC;oBACvC,4CAA4C;oBAC5C,0CAA0C;iBAC3C;aACF,EACD,sBAAO,CACR;SACF,CAAA;QAED,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACtD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,eAAe,EAAE,CAAA;QAC7C,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAA;IAClC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ImageSet, ContentTypeSchemas, ClipSet } from '
|
|
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
|
-
|
|
32
|
-
|
|
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[]
|
|
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():
|
|
85
|
+
originatingParty(): "Reuters" | "FT";
|
|
89
86
|
summary(): {
|
|
90
87
|
bodyXML: string;
|
|
91
88
|
} | null | undefined;
|
|
@@ -95,7 +92,8 @@ export declare class CapiResponse {
|
|
|
95
92
|
publishedDate(): string;
|
|
96
93
|
publishedTimestamp(): number;
|
|
97
94
|
firstPublishedDate(): string;
|
|
98
|
-
|
|
95
|
+
modifiedTimestamp(): number;
|
|
96
|
+
publishReference(): string | null;
|
|
99
97
|
alternativeTitle(): {
|
|
100
98
|
promotionalTitle: string;
|
|
101
99
|
} | null;
|
|
@@ -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
|
|
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
|
-
|
|
121
|
-
if (!bylineText)
|
|
118
|
+
async byline({ vanity }) {
|
|
119
|
+
if (!this.capiData.byline)
|
|
122
120
|
return null;
|
|
123
|
-
const
|
|
124
|
-
return
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
|
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.
|
|
176
|
-
return authors.
|
|
177
|
-
|
|
178
|
-
|
|
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.
|
|
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.
|
|
194
|
-
return
|
|
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,16 +235,25 @@ 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
|
-
return this.capiData.publishReference;
|
|
256
|
+
return this.capiData.publishReference ?? null;
|
|
246
257
|
}
|
|
247
258
|
alternativeTitle() {
|
|
248
259
|
return this.capiData.alternativeTitles ?? null;
|
|
@@ -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() &&
|
|
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
|