@financial-times/cp-content-pipeline-schema 0.7.27 → 0.7.28
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 +12 -0
- package/lib/fixtures/dummyContext.d.ts +3 -0
- package/lib/fixtures/dummyContext.js +24 -0
- package/lib/fixtures/dummyContext.js.map +1 -0
- package/lib/generated/index.d.ts +36 -13
- package/lib/model/Byline.d.ts +6 -3
- package/lib/model/Byline.js +14 -9
- package/lib/model/Byline.js.map +1 -1
- package/lib/model/Byline.test.js +19 -14
- package/lib/model/Byline.test.js.map +1 -1
- package/lib/model/CapiResponse.d.ts +4 -5
- package/lib/model/CapiResponse.js +15 -15
- package/lib/model/CapiResponse.js.map +1 -1
- package/lib/model/CapiResponse.test.js +8 -19
- package/lib/model/CapiResponse.test.js.map +1 -1
- package/lib/resolvers/concept.js +1 -0
- package/lib/resolvers/concept.js.map +1 -1
- package/lib/resolvers/content.d.ts +4 -4
- package/lib/resolvers/content.js +4 -3
- package/lib/resolvers/content.js.map +1 -1
- package/lib/resolvers/index.d.ts +8 -8
- package/lib/resolvers/teaser.d.ts +4 -4
- package/package.json +1 -1
- package/src/fixtures/dummyContext.ts +28 -0
- package/src/generated/index.ts +50 -13
- package/src/model/Byline.test.ts +16 -14
- package/src/model/Byline.ts +27 -19
- package/src/model/CapiResponse.test.ts +1 -25
- package/src/model/CapiResponse.ts +20 -21
- package/src/resolvers/concept.ts +1 -3
- package/src/resolvers/content.ts +11 -3
- package/src/types/internal-content.d.ts +2 -0
- package/src/types/n-display-metadata.d.ts +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/typedefs/concept.graphql +4 -3
- package/typedefs/content.graphql +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CapiResponse.test.js","sourceRoot":"","sources":["../../src/model/CapiResponse.test.ts"],"names":[],"mappings":";;;;;AAAA,iDAA6C;AAC7C,uDAAuD;
|
|
1
|
+
{"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=> parent.apiUrl(),
|
|
6
6
|
directType: (parent) => parent.directType(),
|
|
7
|
+
isPackageBrand: (parent) => parent.isPackageBrand(),
|
|
7
8
|
id: (parent) => parent.uuid(),
|
|
8
9
|
predicate: (parent) => parent.predicate(),
|
|
9
10
|
prefLabel: (parent) => parent.prefLabel(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concept.js","sourceRoot":"","sources":["../../src/resolvers/concept.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"concept.js","sourceRoot":"","sources":["../../src/resolvers/concept.ts"],"names":[],"mappings":";;AAEA,MAAM,SAAS,GAAkC;IAC/C,OAAO,EAAE;QACP,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;QACnC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE;QAC3C,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE;QACnD,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE;QAC7B,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE;QACzC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE;QACzC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE;QAC/B,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;QACjC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;KAC9C;CACF,CAAA;AAED,kBAAe,SAAS,CAAA"}
|
|
@@ -4,14 +4,14 @@ declare const resolvers: {
|
|
|
4
4
|
Content: {
|
|
5
5
|
__resolveType: (parent: import("../model/CapiResponse").CapiResponse) => "Article" | "Video" | "Audio" | "LiveBlogPackage" | "LiveBlogPost" | "ContentPackage";
|
|
6
6
|
body(parent: import("../model/CapiResponse").CapiResponse): RichText;
|
|
7
|
-
topper: (parent: import("../model/CapiResponse").CapiResponse,
|
|
8
|
-
byline(parent: import("../model/CapiResponse").CapiResponse): {
|
|
7
|
+
topper: (parent: import("../model/CapiResponse").CapiResponse, _: {}, context: import("..").QueryContext) => Topper;
|
|
8
|
+
byline(parent: import("../model/CapiResponse").CapiResponse, args: Partial<import("../generated").ContentBylineArgs>, context: import("..").QueryContext): Promise<{
|
|
9
9
|
tree: {
|
|
10
10
|
type: string;
|
|
11
11
|
children: (import("./content-tree/Workarounds").AuthorLink | import("@financial-times/content-tree").ContentTree.Text)[];
|
|
12
12
|
};
|
|
13
13
|
references: never[];
|
|
14
|
-
} | null;
|
|
14
|
+
}> | null;
|
|
15
15
|
url: (parent: import("../model/CapiResponse").CapiResponse, args: Partial<import("../generated").ContentUrlArgs>) => Promise<string>;
|
|
16
16
|
type: (parent: import("../model/CapiResponse").CapiResponse) => "Article" | "Video" | "Audio" | "LiveBlogPackage" | "LiveBlogPost" | "ContentPackage" | "Content" | "MediaResource";
|
|
17
17
|
mainImage: (parent: import("../model/CapiResponse").CapiResponse) => import("../model/Image").CAPIImage | null;
|
|
@@ -32,7 +32,7 @@ declare const resolvers: {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
Article: {
|
|
35
|
-
containedIn: (parent: import("../model/CapiResponse").CapiResponse) => Promise<import("../model/CapiResponse").CapiResponse
|
|
35
|
+
containedIn: (parent: import("../model/CapiResponse").CapiResponse) => Promise<import("../model/CapiResponse").CapiResponse | null>;
|
|
36
36
|
};
|
|
37
37
|
LiveBlogPackage: {
|
|
38
38
|
liveBlogPosts: (parent: import("../model/CapiResponse").CapiResponse) => Promise<[] | import("../model/CapiResponse").CapiResponse[]>;
|
package/lib/resolvers/content.js
CHANGED
|
@@ -18,13 +18,14 @@ const resolvers = {
|
|
|
18
18
|
body(parent) {
|
|
19
19
|
return new RichText_1.RichText('bodyXML', parent.bodyXML(), parent);
|
|
20
20
|
},
|
|
21
|
-
topper: (parent,
|
|
22
|
-
byline(parent) {
|
|
21
|
+
topper: (parent, _, context) => new Topper_1.Topper(parent, context),
|
|
22
|
+
byline(parent, args, context) {
|
|
23
|
+
const vanity = Boolean(args.vanity);
|
|
23
24
|
const bylineText = parent.byline();
|
|
24
25
|
if (!bylineText)
|
|
25
26
|
return null;
|
|
26
27
|
const authorUrlMapping = parent.getAuthorUrlMapping();
|
|
27
|
-
return new Byline_1.Byline(bylineText, authorUrlMapping).buildBylineTree();
|
|
28
|
+
return new Byline_1.Byline(bylineText, vanity, authorUrlMapping, context).buildBylineTree();
|
|
28
29
|
},
|
|
29
30
|
url: (parent, args) => args.relative
|
|
30
31
|
? parent.relativeUrl(args?.vanity)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/resolvers/content.ts"],"names":[],"mappings":";;AAAA,4CAAwC;AACxC,4CAAwC;AAQxC,gDAA4C;AAE5C,MAAM,SAAS,GAAG;IAChB,OAAO,EAAE;QACP,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE;YACxB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;YAC1B,IAAI,IAAI,KAAK,SAAS,EAAE;gBACtB,OAAO,SAAS,CAAA;aACjB;YAED,IAAI,IAAI,KAAK,eAAe,EAAE;gBAC5B,OAAO,OAAO,CAAA;aACf;YAED,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,CAAC,MAAM;YACT,OAAO,IAAI,mBAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAA;QAC1D,CAAC;QACD,MAAM,EAAE,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/resolvers/content.ts"],"names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AC,SAAS,KAAK,YAAY,CAAC;YACrE,IAAI;KACP;CAOF,CAAA;AAED,kBAAe,SAAS,CAAA"}
|
package/lib/resolvers/index.d.ts
CHANGED
|
@@ -41,10 +41,10 @@ declare const resolvers: {
|
|
|
41
41
|
Teaser: {
|
|
42
42
|
url: (parent: import("../model/CapiResponse").CapiResponse, args: Partial<import("../generated").TeaserUrlArgs>) => Promise<string>;
|
|
43
43
|
type: (parent: import("../model/CapiResponse").CapiResponse) => string;
|
|
44
|
-
metaLink: (parent: import("../model/CapiResponse").CapiResponse) => import("../model/Concept").Concept | null
|
|
45
|
-
metaAltLink: (parent: import("../model/CapiResponse").CapiResponse) => import("../model/Concept").Concept | null
|
|
46
|
-
metaPrefixText: (parent: import("../model/CapiResponse").CapiResponse) => string | null
|
|
47
|
-
metaSuffixText: (parent: import("../model/CapiResponse").CapiResponse) => string | null
|
|
44
|
+
metaLink: (parent: import("../model/CapiResponse").CapiResponse) => Promise<import("../model/Concept").Concept | null>;
|
|
45
|
+
metaAltLink: (parent: import("../model/CapiResponse").CapiResponse) => Promise<import("../model/Concept").Concept | null>;
|
|
46
|
+
metaPrefixText: (parent: import("../model/CapiResponse").CapiResponse) => Promise<string | null>;
|
|
47
|
+
metaSuffixText: (parent: import("../model/CapiResponse").CapiResponse) => Promise<string | null>;
|
|
48
48
|
image: (parent: import("../model/CapiResponse").CapiResponse) => import("../model/Image").CAPIImage | null;
|
|
49
49
|
indicators(parent: import("../model/CapiResponse").CapiResponse): {
|
|
50
50
|
accessLevel: "premium" | "subscribed" | "registered" | "free";
|
|
@@ -108,14 +108,14 @@ declare const resolvers: {
|
|
|
108
108
|
Content: {
|
|
109
109
|
__resolveType: (parent: import("../model/CapiResponse").CapiResponse) => "Article" | "Video" | "Audio" | "LiveBlogPackage" | "LiveBlogPost" | "ContentPackage";
|
|
110
110
|
body(parent: import("../model/CapiResponse").CapiResponse): import("../model/RichText").RichText;
|
|
111
|
-
topper: (parent: import("../model/CapiResponse").CapiResponse,
|
|
112
|
-
byline(parent: import("../model/CapiResponse").CapiResponse): {
|
|
111
|
+
topper: (parent: import("../model/CapiResponse").CapiResponse, _: {}, context: import("..").QueryContext) => import("../model/Topper").Topper;
|
|
112
|
+
byline(parent: import("../model/CapiResponse").CapiResponse, args: Partial<import("../generated").ContentBylineArgs>, context: import("..").QueryContext): Promise<{
|
|
113
113
|
tree: {
|
|
114
114
|
type: string;
|
|
115
115
|
children: (import("./content-tree/Workarounds").AuthorLink | import("@financial-times/content-tree").ContentTree.Text)[];
|
|
116
116
|
};
|
|
117
117
|
references: never[];
|
|
118
|
-
} | null;
|
|
118
|
+
}> | null;
|
|
119
119
|
url: (parent: import("../model/CapiResponse").CapiResponse, args: Partial<import("../generated").ContentUrlArgs>) => Promise<string>;
|
|
120
120
|
type: (parent: import("../model/CapiResponse").CapiResponse) => "Article" | "Video" | "Audio" | "LiveBlogPackage" | "LiveBlogPost" | "ContentPackage" | "Content" | "MediaResource";
|
|
121
121
|
mainImage: (parent: import("../model/CapiResponse").CapiResponse) => import("../model/Image").CAPIImage | null;
|
|
@@ -136,7 +136,7 @@ declare const resolvers: {
|
|
|
136
136
|
};
|
|
137
137
|
};
|
|
138
138
|
Article: {
|
|
139
|
-
containedIn: (parent: import("../model/CapiResponse").CapiResponse) => Promise<import("../model/CapiResponse").CapiResponse
|
|
139
|
+
containedIn: (parent: import("../model/CapiResponse").CapiResponse) => Promise<import("../model/CapiResponse").CapiResponse | null>;
|
|
140
140
|
};
|
|
141
141
|
LiveBlogPackage: {
|
|
142
142
|
liveBlogPosts: (parent: import("../model/CapiResponse").CapiResponse) => Promise<[] | import("../model/CapiResponse").CapiResponse[]>;
|
|
@@ -2,10 +2,10 @@ declare const resolvers: {
|
|
|
2
2
|
Teaser: {
|
|
3
3
|
url: (parent: import("../model/CapiResponse").CapiResponse, args: Partial<import("../generated").TeaserUrlArgs>) => Promise<string>;
|
|
4
4
|
type: (parent: import("../model/CapiResponse").CapiResponse) => string;
|
|
5
|
-
metaLink: (parent: import("../model/CapiResponse").CapiResponse) => import("../model/Concept").Concept | null
|
|
6
|
-
metaAltLink: (parent: import("../model/CapiResponse").CapiResponse) => import("../model/Concept").Concept | null
|
|
7
|
-
metaPrefixText: (parent: import("../model/CapiResponse").CapiResponse) => string | null
|
|
8
|
-
metaSuffixText: (parent: import("../model/CapiResponse").CapiResponse) => string | null
|
|
5
|
+
metaLink: (parent: import("../model/CapiResponse").CapiResponse) => Promise<import("../model/Concept").Concept | null>;
|
|
6
|
+
metaAltLink: (parent: import("../model/CapiResponse").CapiResponse) => Promise<import("../model/Concept").Concept | null>;
|
|
7
|
+
metaPrefixText: (parent: import("../model/CapiResponse").CapiResponse) => Promise<string | null>;
|
|
8
|
+
metaSuffixText: (parent: import("../model/CapiResponse").CapiResponse) => Promise<string | null>;
|
|
9
9
|
image: (parent: import("../model/CapiResponse").CapiResponse) => import("../model/Image").CAPIImage | null;
|
|
10
10
|
indicators(parent: import("../model/CapiResponse").CapiResponse): {
|
|
11
11
|
accessLevel: "premium" | "subscribed" | "registered" | "free";
|
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CapiResponse } from '../model/CapiResponse'
|
|
2
|
+
import { baseCapiObject } from './capiObject'
|
|
3
|
+
import cloneDeep from 'clone-deep'
|
|
4
|
+
import { QueryContext } from '..'
|
|
5
|
+
const now = Date.now()
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
dataSources: {
|
|
9
|
+
vanityUrls: {
|
|
10
|
+
get: (url: string) => Promise.resolve(url),
|
|
11
|
+
},
|
|
12
|
+
capi: {
|
|
13
|
+
getContent: (id: string) =>
|
|
14
|
+
Promise.resolve(
|
|
15
|
+
new CapiResponse(
|
|
16
|
+
cloneDeep({
|
|
17
|
+
...baseCapiObject,
|
|
18
|
+
id,
|
|
19
|
+
publishedDate: new Date(
|
|
20
|
+
now + parseInt(id.slice(-1), 10)
|
|
21
|
+
).toISOString(),
|
|
22
|
+
}),
|
|
23
|
+
{} as unknown as QueryContext
|
|
24
|
+
)
|
|
25
|
+
),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
} as unknown as QueryContext
|
package/src/generated/index.ts
CHANGED
|
@@ -70,6 +70,11 @@ export type Article = Content & {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
export type ArticleBylineArgs = {
|
|
74
|
+
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
|
|
73
78
|
export type ArticleUrlArgs = {
|
|
74
79
|
relative?: InputMaybe<Scalars['Boolean']['input']>;
|
|
75
80
|
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
@@ -100,6 +105,11 @@ export type Audio = Content & {
|
|
|
100
105
|
};
|
|
101
106
|
|
|
102
107
|
|
|
108
|
+
export type AudioBylineArgs = {
|
|
109
|
+
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
|
|
103
113
|
export type AudioUrlArgs = {
|
|
104
114
|
relative?: InputMaybe<Scalars['Boolean']['input']>;
|
|
105
115
|
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
@@ -130,13 +140,14 @@ export type BrandedTopper = Topper & TopperWithBrand & TopperWithTheme & {
|
|
|
130
140
|
};
|
|
131
141
|
|
|
132
142
|
export type Concept = {
|
|
133
|
-
readonly apiUrl
|
|
143
|
+
readonly apiUrl?: Maybe<Scalars['String']['output']>;
|
|
134
144
|
readonly directType?: Maybe<Scalars['String']['output']>;
|
|
135
145
|
readonly id: Scalars['ID']['output'];
|
|
136
|
-
readonly
|
|
146
|
+
readonly isPackageBrand?: Maybe<Scalars['Boolean']['output']>;
|
|
147
|
+
readonly predicate?: Maybe<Scalars['String']['output']>;
|
|
137
148
|
readonly prefLabel: Scalars['String']['output'];
|
|
138
149
|
readonly type?: Maybe<Scalars['String']['output']>;
|
|
139
|
-
readonly types
|
|
150
|
+
readonly types?: Maybe<ReadonlyArray<Scalars['String']['output']>>;
|
|
140
151
|
readonly url: Scalars['String']['output'];
|
|
141
152
|
};
|
|
142
153
|
|
|
@@ -170,6 +181,11 @@ export type Content = {
|
|
|
170
181
|
};
|
|
171
182
|
|
|
172
183
|
|
|
184
|
+
export type ContentBylineArgs = {
|
|
185
|
+
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
|
|
173
189
|
export type ContentUrlArgs = {
|
|
174
190
|
relative?: InputMaybe<Scalars['Boolean']['input']>;
|
|
175
191
|
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
@@ -201,6 +217,11 @@ export type ContentPackage = Content & {
|
|
|
201
217
|
};
|
|
202
218
|
|
|
203
219
|
|
|
220
|
+
export type ContentPackageBylineArgs = {
|
|
221
|
+
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
|
|
204
225
|
export type ContentPackageUrlArgs = {
|
|
205
226
|
relative?: InputMaybe<Scalars['Boolean']['input']>;
|
|
206
227
|
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
@@ -512,6 +533,11 @@ export type LiveBlogPackage = Content & {
|
|
|
512
533
|
};
|
|
513
534
|
|
|
514
535
|
|
|
536
|
+
export type LiveBlogPackageBylineArgs = {
|
|
537
|
+
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
|
|
515
541
|
export type LiveBlogPackageUrlArgs = {
|
|
516
542
|
relative?: InputMaybe<Scalars['Boolean']['input']>;
|
|
517
543
|
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
@@ -541,6 +567,11 @@ export type LiveBlogPost = Content & {
|
|
|
541
567
|
};
|
|
542
568
|
|
|
543
569
|
|
|
570
|
+
export type LiveBlogPostBylineArgs = {
|
|
571
|
+
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
|
|
544
575
|
export type LiveBlogPostUrlArgs = {
|
|
545
576
|
relative?: InputMaybe<Scalars['Boolean']['input']>;
|
|
546
577
|
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
@@ -808,6 +839,11 @@ export type Video = Content & {
|
|
|
808
839
|
};
|
|
809
840
|
|
|
810
841
|
|
|
842
|
+
export type VideoBylineArgs = {
|
|
843
|
+
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
|
|
811
847
|
export type VideoUrlArgs = {
|
|
812
848
|
relative?: InputMaybe<Scalars['Boolean']['input']>;
|
|
813
849
|
vanity?: InputMaybe<Scalars['Boolean']['input']>;
|
|
@@ -1077,7 +1113,7 @@ export type ArticleResolvers<ContextType = QueryContext, ParentType extends Reso
|
|
|
1077
1113
|
annotations?: Resolver<Maybe<ReadonlyArray<Maybe<ResolversTypes['Concept']>>>, ParentType, ContextType>;
|
|
1078
1114
|
body?: Resolver<Maybe<ResolversTypes['RichText']>, ParentType, ContextType>;
|
|
1079
1115
|
bodyXML?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1080
|
-
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType
|
|
1116
|
+
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType, Partial<ArticleBylineArgs>>;
|
|
1081
1117
|
canBeSyndicated?: Resolver<Maybe<ResolversTypes['CanBeSyndicated']>, ParentType, ContextType>;
|
|
1082
1118
|
commentsEnabled?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
1083
1119
|
containedIn?: Resolver<Maybe<ResolversTypes['Content']>, ParentType, ContextType>;
|
|
@@ -1102,7 +1138,7 @@ export type AudioResolvers<ContextType = QueryContext, ParentType extends Resolv
|
|
|
1102
1138
|
annotations?: Resolver<Maybe<ReadonlyArray<Maybe<ResolversTypes['Concept']>>>, ParentType, ContextType>;
|
|
1103
1139
|
body?: Resolver<Maybe<ResolversTypes['RichText']>, ParentType, ContextType>;
|
|
1104
1140
|
bodyXML?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1105
|
-
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType
|
|
1141
|
+
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType, Partial<AudioBylineArgs>>;
|
|
1106
1142
|
canBeSyndicated?: Resolver<Maybe<ResolversTypes['CanBeSyndicated']>, ParentType, ContextType>;
|
|
1107
1143
|
commentsEnabled?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
1108
1144
|
design?: Resolver<Maybe<ResolversTypes['Design']>, ParentType, ContextType>;
|
|
@@ -1151,13 +1187,14 @@ export interface CanBeSyndicatedScalarConfig extends GraphQLScalarTypeConfig<Res
|
|
|
1151
1187
|
}
|
|
1152
1188
|
|
|
1153
1189
|
export type ConceptResolvers<ContextType = QueryContext, ParentType extends ResolversParentTypes['Concept'] = ResolversParentTypes['Concept']> = ResolversObject<{
|
|
1154
|
-
apiUrl?: Resolver<ResolversTypes['String']
|
|
1190
|
+
apiUrl?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1155
1191
|
directType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1156
1192
|
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
|
|
1157
|
-
|
|
1193
|
+
isPackageBrand?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
1194
|
+
predicate?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1158
1195
|
prefLabel?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
|
1159
1196
|
type?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1160
|
-
types?: Resolver<ReadonlyArray<ResolversTypes['String']
|
|
1197
|
+
types?: Resolver<Maybe<ReadonlyArray<ResolversTypes['String']>>, ParentType, ContextType>;
|
|
1161
1198
|
url?: Resolver<ResolversTypes['String'], ParentType, ContextType, Partial<ConceptUrlArgs>>;
|
|
1162
1199
|
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
1163
1200
|
}>;
|
|
@@ -1170,7 +1207,7 @@ export type ContentResolvers<ContextType = QueryContext, ParentType extends Reso
|
|
|
1170
1207
|
annotations?: Resolver<Maybe<ReadonlyArray<Maybe<ResolversTypes['Concept']>>>, ParentType, ContextType>;
|
|
1171
1208
|
body?: Resolver<Maybe<ResolversTypes['RichText']>, ParentType, ContextType>;
|
|
1172
1209
|
bodyXML?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1173
|
-
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType
|
|
1210
|
+
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType, Partial<ContentBylineArgs>>;
|
|
1174
1211
|
canBeSyndicated?: Resolver<Maybe<ResolversTypes['CanBeSyndicated']>, ParentType, ContextType>;
|
|
1175
1212
|
commentsEnabled?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
1176
1213
|
design?: Resolver<Maybe<ResolversTypes['Design']>, ParentType, ContextType>;
|
|
@@ -1193,7 +1230,7 @@ export type ContentPackageResolvers<ContextType = QueryContext, ParentType exten
|
|
|
1193
1230
|
annotations?: Resolver<Maybe<ReadonlyArray<Maybe<ResolversTypes['Concept']>>>, ParentType, ContextType>;
|
|
1194
1231
|
body?: Resolver<Maybe<ResolversTypes['RichText']>, ParentType, ContextType>;
|
|
1195
1232
|
bodyXML?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1196
|
-
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType
|
|
1233
|
+
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType, Partial<ContentPackageBylineArgs>>;
|
|
1197
1234
|
canBeSyndicated?: Resolver<Maybe<ResolversTypes['CanBeSyndicated']>, ParentType, ContextType>;
|
|
1198
1235
|
commentsEnabled?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
1199
1236
|
contains?: Resolver<Maybe<ReadonlyArray<Maybe<ResolversTypes['Teaser']>>>, ParentType, ContextType>;
|
|
@@ -1479,7 +1516,7 @@ export type LiveBlogPackageResolvers<ContextType = QueryContext, ParentType exte
|
|
|
1479
1516
|
annotations?: Resolver<Maybe<ReadonlyArray<Maybe<ResolversTypes['Concept']>>>, ParentType, ContextType>;
|
|
1480
1517
|
body?: Resolver<Maybe<ResolversTypes['RichText']>, ParentType, ContextType>;
|
|
1481
1518
|
bodyXML?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1482
|
-
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType
|
|
1519
|
+
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType, Partial<LiveBlogPackageBylineArgs>>;
|
|
1483
1520
|
canBeSyndicated?: Resolver<Maybe<ResolversTypes['CanBeSyndicated']>, ParentType, ContextType>;
|
|
1484
1521
|
commentsEnabled?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
1485
1522
|
design?: Resolver<Maybe<ResolversTypes['Design']>, ParentType, ContextType>;
|
|
@@ -1505,7 +1542,7 @@ export type LiveBlogPostResolvers<ContextType = QueryContext, ParentType extends
|
|
|
1505
1542
|
annotations?: Resolver<Maybe<ReadonlyArray<Maybe<ResolversTypes['Concept']>>>, ParentType, ContextType>;
|
|
1506
1543
|
body?: Resolver<Maybe<ResolversTypes['RichText']>, ParentType, ContextType>;
|
|
1507
1544
|
bodyXML?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1508
|
-
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType
|
|
1545
|
+
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType, Partial<LiveBlogPostBylineArgs>>;
|
|
1509
1546
|
canBeSyndicated?: Resolver<Maybe<ResolversTypes['CanBeSyndicated']>, ParentType, ContextType>;
|
|
1510
1547
|
commentsEnabled?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
1511
1548
|
design?: Resolver<Maybe<ResolversTypes['Design']>, ParentType, ContextType>;
|
|
@@ -1765,7 +1802,7 @@ export type VideoResolvers<ContextType = QueryContext, ParentType extends Resolv
|
|
|
1765
1802
|
annotations?: Resolver<Maybe<ReadonlyArray<Maybe<ResolversTypes['Concept']>>>, ParentType, ContextType>;
|
|
1766
1803
|
body?: Resolver<Maybe<ResolversTypes['RichText']>, ParentType, ContextType>;
|
|
1767
1804
|
bodyXML?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
|
1768
|
-
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType
|
|
1805
|
+
byline?: Resolver<Maybe<ResolversTypes['StructuredContent']>, ParentType, ContextType, Partial<VideoBylineArgs>>;
|
|
1769
1806
|
canBeSyndicated?: Resolver<Maybe<ResolversTypes['CanBeSyndicated']>, ParentType, ContextType>;
|
|
1770
1807
|
commentsEnabled?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
|
|
1771
1808
|
design?: Resolver<Maybe<ResolversTypes['Design']>, ParentType, ContextType>;
|
package/src/model/Byline.test.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Byline } from './Byline'
|
|
2
|
+
import context from '../fixtures/dummyContext'
|
|
3
|
+
const vanity = true
|
|
2
4
|
|
|
3
5
|
describe('byline transformation', () => {
|
|
4
6
|
test('adds a link around a single known author', async () => {
|
|
@@ -10,8 +12,8 @@ describe('byline transformation', () => {
|
|
|
10
12
|
],
|
|
11
13
|
])
|
|
12
14
|
|
|
13
|
-
const byline = new Byline(bylineText, authorUrlMapping)
|
|
14
|
-
const result = byline.buildBylineTree()
|
|
15
|
+
const byline = new Byline(bylineText, vanity, authorUrlMapping, context)
|
|
16
|
+
const result = await byline.buildBylineTree()
|
|
15
17
|
expect(result).toMatchSnapshot()
|
|
16
18
|
})
|
|
17
19
|
|
|
@@ -28,8 +30,8 @@ describe('byline transformation', () => {
|
|
|
28
30
|
],
|
|
29
31
|
])
|
|
30
32
|
|
|
31
|
-
const byline = new Byline(bylineText, authorUrlMapping)
|
|
32
|
-
const result = byline.buildBylineTree()
|
|
33
|
+
const byline = new Byline(bylineText, vanity, authorUrlMapping, context)
|
|
34
|
+
const result = await byline.buildBylineTree()
|
|
33
35
|
expect(result).toMatchSnapshot()
|
|
34
36
|
})
|
|
35
37
|
|
|
@@ -42,8 +44,8 @@ describe('byline transformation', () => {
|
|
|
42
44
|
],
|
|
43
45
|
])
|
|
44
46
|
|
|
45
|
-
const byline = new Byline(bylineText, authorUrlMapping)
|
|
46
|
-
const result = byline.buildBylineTree()
|
|
47
|
+
const byline = new Byline(bylineText, vanity, authorUrlMapping, context)
|
|
48
|
+
const result = await byline.buildBylineTree()
|
|
47
49
|
expect(result).toMatchSnapshot()
|
|
48
50
|
})
|
|
49
51
|
|
|
@@ -60,8 +62,8 @@ describe('byline transformation', () => {
|
|
|
60
62
|
],
|
|
61
63
|
])
|
|
62
64
|
|
|
63
|
-
const byline = new Byline(bylineText, authorUrlMapping)
|
|
64
|
-
const result = byline.buildBylineTree()
|
|
65
|
+
const byline = new Byline(bylineText, vanity, authorUrlMapping, context)
|
|
66
|
+
const result = await byline.buildBylineTree()
|
|
65
67
|
expect(result).toMatchSnapshot()
|
|
66
68
|
})
|
|
67
69
|
|
|
@@ -69,8 +71,8 @@ describe('byline transformation', () => {
|
|
|
69
71
|
const bylineText = 'Chris Giles and Nick Ramsbottom in London'
|
|
70
72
|
const authorUrlMapping: Map<string, string> = new Map([])
|
|
71
73
|
|
|
72
|
-
const byline = new Byline(bylineText, authorUrlMapping)
|
|
73
|
-
const result = byline.buildBylineTree()
|
|
74
|
+
const byline = new Byline(bylineText, vanity, authorUrlMapping, context)
|
|
75
|
+
const result = await byline.buildBylineTree()
|
|
74
76
|
|
|
75
77
|
expect(result).toMatchSnapshot()
|
|
76
78
|
})
|
|
@@ -83,8 +85,8 @@ describe('byline transformation', () => {
|
|
|
83
85
|
'https://www.ft.com/stream/uuid/1d556016-ad16-4fe7-8724-eeeeeeeeeeee',
|
|
84
86
|
],
|
|
85
87
|
])
|
|
86
|
-
const byline = new Byline(bylineText, authorUrlMapping)
|
|
87
|
-
const result = byline.buildBylineTree()
|
|
88
|
+
const byline = new Byline(bylineText, vanity, authorUrlMapping, context)
|
|
89
|
+
const result = await byline.buildBylineTree()
|
|
88
90
|
|
|
89
91
|
expect(result).toMatchSnapshot()
|
|
90
92
|
})
|
|
@@ -97,8 +99,8 @@ describe('byline transformation', () => {
|
|
|
97
99
|
'https://www.ft.com/stream/uuid/1d556016-ad16-4fe7-8724-eeeeeeeeeeee',
|
|
98
100
|
],
|
|
99
101
|
])
|
|
100
|
-
const byline = new Byline(bylineText, authorUrlMapping)
|
|
101
|
-
const result = byline.buildBylineTree()
|
|
102
|
+
const byline = new Byline(bylineText, vanity, authorUrlMapping, context)
|
|
103
|
+
const result = await byline.buildBylineTree()
|
|
102
104
|
|
|
103
105
|
expect(result).toMatchSnapshot()
|
|
104
106
|
})
|
package/src/model/Byline.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { ContentTree } from '@financial-times/content-tree'
|
|
2
2
|
import { AuthorLink } from '../resolvers/content-tree/Workarounds'
|
|
3
|
-
import {
|
|
3
|
+
import { QueryContext } from '..'
|
|
4
4
|
|
|
5
5
|
export class Byline {
|
|
6
6
|
constructor(
|
|
7
7
|
private byline: string,
|
|
8
|
-
private
|
|
8
|
+
private vanity: boolean,
|
|
9
|
+
private authorUrlMapping: Map<string, string>,
|
|
10
|
+
private context: QueryContext
|
|
9
11
|
) {}
|
|
10
12
|
|
|
11
|
-
buildBylineTree() {
|
|
13
|
+
async buildBylineTree() {
|
|
12
14
|
// Normalise apostrophes in byline string
|
|
13
15
|
const bylineWithCorrectApostrophes = this.byline.replace("'", '’')
|
|
14
16
|
|
|
15
17
|
const split = this.#splitBylineByName(bylineWithCorrectApostrophes, [
|
|
16
18
|
...this.authorUrlMapping.keys(),
|
|
17
19
|
])
|
|
18
|
-
return this.#buildUrlTree(this.authorUrlMapping, split)
|
|
20
|
+
return await this.#buildUrlTree(this.authorUrlMapping, split)
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
#splitBylineByName(byline: string, names: string[]) {
|
|
@@ -24,23 +26,29 @@ export class Byline {
|
|
|
24
26
|
return byline.split(regex).filter((string) => string !== '')
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
#buildUrlTree(urlMapping: Map<string, string>, parts: string[]) {
|
|
28
|
-
const children: (AuthorLink | ContentTree.Text)[] =
|
|
29
|
-
|
|
29
|
+
async #buildUrlTree(urlMapping: Map<string, string>, parts: string[]) {
|
|
30
|
+
const children: (AuthorLink | ContentTree.Text)[] = await Promise.all(
|
|
31
|
+
parts.map(async (part) => {
|
|
32
|
+
const fullUrl = urlMapping.get(part)
|
|
33
|
+
const vanityUrl =
|
|
34
|
+
this.vanity && fullUrl
|
|
35
|
+
? await this.context.dataSources.vanityUrls.get(fullUrl)
|
|
36
|
+
: null
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
if (fullUrl) {
|
|
39
|
+
return {
|
|
40
|
+
type: 'author-link',
|
|
41
|
+
href: vanityUrl || fullUrl,
|
|
42
|
+
children: [{ type: 'text', value: part }],
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
return {
|
|
46
|
+
type: 'text',
|
|
47
|
+
value: part,
|
|
48
|
+
}
|
|
36
49
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
type: 'text',
|
|
40
|
-
value: part,
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
})
|
|
50
|
+
})
|
|
51
|
+
)
|
|
44
52
|
|
|
45
53
|
return {
|
|
46
54
|
tree: { type: 'root', children },
|
|
@@ -1,31 +1,7 @@
|
|
|
1
1
|
import { CapiResponse } from './CapiResponse'
|
|
2
2
|
import { baseCapiObject } from '../fixtures/capiObject'
|
|
3
|
-
import { jest } from '@jest/globals'
|
|
4
3
|
import cloneDeep from 'clone-deep'
|
|
5
|
-
|
|
6
|
-
import type { QueryContext } from '..'
|
|
7
|
-
|
|
8
|
-
const now = Date.now()
|
|
9
|
-
|
|
10
|
-
const context = {
|
|
11
|
-
dataSources: {
|
|
12
|
-
capi: {
|
|
13
|
-
getContent: (id: string) =>
|
|
14
|
-
Promise.resolve(
|
|
15
|
-
new CapiResponse(
|
|
16
|
-
cloneDeep({
|
|
17
|
-
...baseCapiObject,
|
|
18
|
-
id,
|
|
19
|
-
publishedDate: new Date(
|
|
20
|
-
now + parseInt(id.slice(-1), 10)
|
|
21
|
-
).toISOString(),
|
|
22
|
-
}),
|
|
23
|
-
{} as unknown as QueryContext
|
|
24
|
-
)
|
|
25
|
-
),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
} as unknown as QueryContext
|
|
4
|
+
import context from '../fixtures/dummyContext'
|
|
29
5
|
|
|
30
6
|
describe('CAPI response', () => {
|
|
31
7
|
describe('Content ID', () => {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
Article,
|
|
3
|
-
LiveBlogPackage,
|
|
4
|
-
ContentPackage,
|
|
5
2
|
ImageSet,
|
|
6
|
-
Audio,
|
|
7
3
|
Annotation,
|
|
4
|
+
ContentTypeSchemas,
|
|
8
5
|
} from '../types/internal-content'
|
|
9
6
|
import conceptIds from '@financial-times/n-concept-ids'
|
|
10
7
|
import metadata, { TeaserMetadata } from '@financial-times/n-display-metadata'
|
|
@@ -34,8 +31,6 @@ import {
|
|
|
34
31
|
|
|
35
32
|
import { Media } from '../generated'
|
|
36
33
|
|
|
37
|
-
type ContentTypeSchemas = Article | LiveBlogPackage | ContentPackage | Audio
|
|
38
|
-
|
|
39
34
|
type Design = {
|
|
40
35
|
theme: LiteralUnionScalarValues<typeof PackageDesign>
|
|
41
36
|
layout?: 'default' | 'wide'
|
|
@@ -276,23 +271,29 @@ export class CapiResponse {
|
|
|
276
271
|
return new CapiResponse(clone, this.context)
|
|
277
272
|
}
|
|
278
273
|
|
|
279
|
-
#teaserMetadata() {
|
|
280
|
-
|
|
274
|
+
async #teaserMetadata() {
|
|
275
|
+
const containedIn = await this.containedIn()
|
|
276
|
+
|
|
277
|
+
return metadata.teaser({
|
|
278
|
+
annotations: this.#rawAnnotations(),
|
|
279
|
+
containedIn: containedIn ? [containedIn.capiData] : null,
|
|
280
|
+
})
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
teaserMetadataLink(
|
|
283
|
+
async teaserMetadataLink(
|
|
284
284
|
field: ConditionalKeys<TeaserMetadata, Annotation | null>
|
|
285
285
|
) {
|
|
286
|
-
const meta = this.#teaserMetadata()
|
|
286
|
+
const meta = await this.#teaserMetadata()
|
|
287
287
|
const metaField = meta[field]
|
|
288
|
+
|
|
288
289
|
return metaField ? new Concept(metaField, this.context) : null
|
|
289
290
|
}
|
|
290
291
|
|
|
291
|
-
teaserMetadataText(
|
|
292
|
+
async teaserMetadataText(
|
|
292
293
|
field: ConditionalKeys<TeaserMetadata, string> | 'suffixText'
|
|
293
294
|
) {
|
|
294
295
|
if (field === 'prefixText') {
|
|
295
|
-
const meta = this.#teaserMetadata()
|
|
296
|
+
const meta = await this.#teaserMetadata()
|
|
296
297
|
return meta[field]
|
|
297
298
|
} else {
|
|
298
299
|
// HACK 20230629 IM: suffixText doesn't actually exist in the metadata
|
|
@@ -474,15 +475,13 @@ export class CapiResponse {
|
|
|
474
475
|
return []
|
|
475
476
|
}
|
|
476
477
|
|
|
477
|
-
containedIn() {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
return this.context.dataSources.capi.getContent(uuidFromUrl(containerId))
|
|
478
|
+
async containedIn() {
|
|
479
|
+
const containerId =
|
|
480
|
+
'containedIn' in this.capiData && this.capiData.containedIn?.[0]?.id
|
|
481
|
+
|
|
482
|
+
return containerId
|
|
483
|
+
? await this.context.dataSources.capi.getContent(uuidFromUrl(containerId))
|
|
484
|
+
: null
|
|
486
485
|
}
|
|
487
486
|
|
|
488
487
|
isContainedInPackage(): boolean {
|