@financial-times/cp-content-pipeline-schema 3.18.0 → 3.20.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 +20 -0
- package/lib/generated/index.d.ts +11 -2
- package/lib/helpers/qualityWorkaround.d.ts +2 -0
- package/lib/helpers/qualityWorkaround.js +38 -0
- package/lib/helpers/qualityWorkaround.js.map +1 -0
- package/lib/model/Clip.d.ts +1 -17
- package/lib/model/Clip.js +27 -8
- package/lib/model/Clip.js.map +1 -1
- package/lib/model/Clip.test.js +77 -0
- package/lib/model/Clip.test.js.map +1 -1
- package/lib/model/schemas/capi/article.d.ts +18 -0
- package/lib/model/schemas/capi/audio.d.ts +14 -0
- package/lib/model/schemas/capi/base-schema.d.ts +42 -0
- package/lib/model/schemas/capi/base-schema.js +2 -0
- package/lib/model/schemas/capi/base-schema.js.map +1 -1
- package/lib/model/schemas/capi/content-package.d.ts +14 -0
- package/lib/model/schemas/capi/custom-code-component.d.ts +18 -0
- package/lib/model/schemas/capi/index.d.ts +96 -0
- package/lib/model/schemas/capi/live-blog-package.d.ts +18 -0
- package/lib/model/schemas/capi/placeholder.d.ts +18 -0
- package/lib/model/schemas/capi/video.d.ts +14 -0
- package/lib/resolvers/clip.d.ts +4 -9
- package/lib/resolvers/clip.js +3 -0
- package/lib/resolvers/clip.js.map +1 -1
- package/lib/resolvers/content-tree/Workarounds.d.ts +1 -0
- package/lib/resolvers/content-tree/references/RecommendedList.d.ts +4 -3
- package/lib/resolvers/content-tree/references/RecommendedList.js +5 -32
- package/lib/resolvers/content-tree/references/RecommendedList.js.map +1 -1
- package/lib/resolvers/content-tree/tagMappings.js +1 -0
- package/lib/resolvers/content-tree/tagMappings.js.map +1 -1
- package/lib/resolvers/index.d.ts +4 -9
- package/lib/types/clip.d.ts +21 -0
- package/lib/types/clip.js +3 -0
- package/lib/types/clip.js.map +1 -0
- package/package.json +1 -1
- package/queries/article.graphql +5 -3
- package/src/generated/index.ts +11 -2
- package/src/helpers/qualityWorkaround.ts +44 -0
- package/src/model/Clip.test.ts +95 -0
- package/src/model/Clip.ts +33 -27
- package/src/model/__snapshots__/RichText.test.ts.snap +3 -1
- package/src/model/schemas/capi/base-schema.ts +2 -0
- package/src/resolvers/clip.ts +3 -0
- package/src/resolvers/content-tree/Workarounds.ts +1 -0
- package/src/resolvers/content-tree/references/RecommendedList.ts +5 -45
- package/src/resolvers/content-tree/tagMappings.ts +1 -0
- package/src/types/clip.ts +23 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/typedefs/clip.graphql +9 -0
- package/typedefs/references/recommendedList.graphql +1 -1
|
@@ -1,52 +1,12 @@
|
|
|
1
|
-
import { uuidFromUrl } from '../../../helpers/metadata'
|
|
2
1
|
import { RecommendedListResolvers } from '../../../generated'
|
|
3
|
-
import { OperationalError } from '@dotcom-reliability-kit/errors'
|
|
4
|
-
import { ContentTree } from '@financial-times/content-tree'
|
|
5
|
-
import { Logger } from '@dotcom-reliability-kit/logger'
|
|
6
|
-
import { CapiDataSource } from '../../../datasources/capi'
|
|
7
|
-
|
|
8
|
-
function getTeaser(context: {
|
|
9
|
-
logger: Logger
|
|
10
|
-
dataSources: { capi: CapiDataSource }
|
|
11
|
-
}) {
|
|
12
|
-
return async function (child: ContentTree.Recommended) {
|
|
13
|
-
try {
|
|
14
|
-
let content = await context.dataSources.capi.getContent(
|
|
15
|
-
uuidFromUrl(child.id)
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
if (!content) {
|
|
19
|
-
throw new Error('Invalid content from recommended article teaser')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (child.teaserTitleOverride) {
|
|
23
|
-
content = content.overrideTitle(child.teaserTitleOverride)
|
|
24
|
-
}
|
|
25
|
-
return content
|
|
26
|
-
} catch (error) {
|
|
27
|
-
if (error instanceof Error) {
|
|
28
|
-
context.logger.warn({
|
|
29
|
-
event: 'RECOVERABLE_ERROR',
|
|
30
|
-
error: new OperationalError({
|
|
31
|
-
code: 'RECOMMENDED_TEASER_ERROR',
|
|
32
|
-
message: `Couldn't load teaser for recommended article ${child.id}`,
|
|
33
|
-
cause: error,
|
|
34
|
-
}),
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
2
|
|
|
41
3
|
export const RecommendedList = {
|
|
42
|
-
async teasers(parent, _args, context) {
|
|
43
|
-
const responses = await Promise.all(
|
|
44
|
-
parent.reference.children.map(getTeaser(context))
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
return responses.filter((response) => response !== undefined)
|
|
48
|
-
},
|
|
49
4
|
type(parent) {
|
|
50
5
|
return parent.reference.type
|
|
51
6
|
},
|
|
7
|
+
children(parent) {
|
|
8
|
+
return parent.reference.children.map((child) => ({
|
|
9
|
+
reference: child,
|
|
10
|
+
}))
|
|
11
|
+
},
|
|
52
12
|
} satisfies RecommendedListResolvers
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LiteralUnionScalarValues } from '../resolvers/literal-union'
|
|
2
|
+
import { ClipFormat } from '../resolvers/scalars'
|
|
3
|
+
|
|
4
|
+
export type ClipSource = {
|
|
5
|
+
binaryUrl: string
|
|
6
|
+
mediaType: string
|
|
7
|
+
audioCodec?: string
|
|
8
|
+
duration?: number
|
|
9
|
+
pixelHeight?: number
|
|
10
|
+
pixelWidth?: number
|
|
11
|
+
videoCodec?: string
|
|
12
|
+
quality?: string
|
|
13
|
+
dppx?: number
|
|
14
|
+
previousSourceWidth?: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ClipVideo {
|
|
18
|
+
id(): string
|
|
19
|
+
type(): string
|
|
20
|
+
format(): LiteralUnionScalarValues<typeof ClipFormat>
|
|
21
|
+
poster(): string
|
|
22
|
+
dataSource(): ClipSource[]
|
|
23
|
+
}
|