@financial-times/cp-content-pipeline-client 0.2.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.
@@ -0,0 +1,350 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getSdk = exports.ArticleDocument = exports.StructuredContentFragmentDoc = exports.ArticleReferencesFragmentDoc = exports.LayoutImageFragmentDoc = exports.ImageSetFragmentDoc = exports.PictureFragmentDoc = exports.RecommendedFragmentDoc = exports.TeaserFragmentDoc = exports.DisplayConceptFragmentDoc = exports.TopperFragmentDoc = exports.ConceptFragmentDoc = exports.StructuredTreeFragmentDoc = exports.TopperImagesFragmentDoc = exports.ImageFragmentDoc = exports.ImageSourceFragmentDoc = exports.TopperBackgroundColour = exports.Source = exports.ImageType = exports.AccessLevel = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ var AccessLevel;
9
+ (function (AccessLevel) {
10
+ AccessLevel["Free"] = "free";
11
+ AccessLevel["Premium"] = "premium";
12
+ AccessLevel["Registered"] = "registered";
13
+ AccessLevel["Subscribed"] = "subscribed";
14
+ })(AccessLevel = exports.AccessLevel || (exports.AccessLevel = {}));
15
+ var ImageType;
16
+ (function (ImageType) {
17
+ ImageType["Graphic"] = "Graphic";
18
+ ImageType["Image"] = "Image";
19
+ })(ImageType = exports.ImageType || (exports.ImageType = {}));
20
+ var Source;
21
+ (function (Source) {
22
+ Source["Standfirst"] = "standfirst";
23
+ Source["Summary"] = "summary";
24
+ })(Source = exports.Source || (exports.Source = {}));
25
+ var TopperBackgroundColour;
26
+ (function (TopperBackgroundColour) {
27
+ TopperBackgroundColour["Black"] = "black";
28
+ TopperBackgroundColour["Claret"] = "claret";
29
+ TopperBackgroundColour["Crimson"] = "crimson";
30
+ TopperBackgroundColour["Oxford"] = "oxford";
31
+ TopperBackgroundColour["Paper"] = "paper";
32
+ TopperBackgroundColour["Sky"] = "sky";
33
+ TopperBackgroundColour["Slate"] = "slate";
34
+ TopperBackgroundColour["Wheat"] = "wheat";
35
+ TopperBackgroundColour["White"] = "white";
36
+ })(TopperBackgroundColour = exports.TopperBackgroundColour || (exports.TopperBackgroundColour = {}));
37
+ exports.ImageSourceFragmentDoc = (0, graphql_tag_1.default) `
38
+ fragment ImageSource on ImageSource {
39
+ dpr
40
+ width
41
+ url
42
+ }
43
+ `;
44
+ exports.ImageFragmentDoc = (0, graphql_tag_1.default) `
45
+ fragment Image on Image {
46
+ sources {
47
+ ...ImageSource
48
+ }
49
+ minDisplayWidth
50
+ maxDisplayWidth
51
+ originalHeight
52
+ originalWidth
53
+ copyright
54
+ }
55
+ ${exports.ImageSourceFragmentDoc}`;
56
+ exports.TopperImagesFragmentDoc = (0, graphql_tag_1.default) `
57
+ fragment TopperImages on TopperImages {
58
+ standard {
59
+ ...Image
60
+ }
61
+ square {
62
+ ...Image
63
+ }
64
+ fallback {
65
+ ...Image
66
+ }
67
+ wide {
68
+ ...Image
69
+ }
70
+ }
71
+ ${exports.ImageFragmentDoc}`;
72
+ exports.StructuredTreeFragmentDoc = (0, graphql_tag_1.default) `
73
+ fragment StructuredTree on StructuredContent {
74
+ tree
75
+ }
76
+ `;
77
+ exports.ConceptFragmentDoc = (0, graphql_tag_1.default) `
78
+ fragment Concept on Concept {
79
+ id
80
+ prefLabel
81
+ url(vanity: $useVanities)
82
+ relativeUrl: url(relative: true, vanity: $useVanities)
83
+ }
84
+ `;
85
+ exports.TopperFragmentDoc = (0, graphql_tag_1.default) `
86
+ fragment Topper on Topper {
87
+ __typename
88
+ headline
89
+ intro {
90
+ source
91
+ structured {
92
+ ...StructuredTree
93
+ }
94
+ }
95
+ displayConcept {
96
+ ...Concept
97
+ }
98
+ backgroundColour
99
+ ... on SplitTextTopper {
100
+ images {
101
+ standard {
102
+ sources(width: 800) {
103
+ ...ImageSource
104
+ }
105
+ minDisplayWidth(width: 1440)
106
+ }
107
+ square {
108
+ sources(width: 720) {
109
+ ...ImageSource
110
+ }
111
+ maxDisplayWidth(width: 1440)
112
+ }
113
+ fallback {
114
+ sources(width: 1440) {
115
+ ...ImageSource
116
+ }
117
+ copyright
118
+ }
119
+ }
120
+ }
121
+ ... on FullBleedTopper {
122
+ images {
123
+ standard {
124
+ sources(width: 1220) {
125
+ ...ImageSource
126
+ }
127
+ minDisplayWidth(width: 491)
128
+ maxDisplayWidth(width: 1220)
129
+ }
130
+ square {
131
+ sources(width: 490) {
132
+ ...ImageSource
133
+ }
134
+ maxDisplayWidth(width: 490)
135
+ }
136
+ wide {
137
+ sources(width: 1440) {
138
+ ...ImageSource
139
+ }
140
+ minDisplayWidth(width: 1440)
141
+ }
142
+ fallback {
143
+ sources(width: 1440) {
144
+ ...ImageSource
145
+ }
146
+ copyright
147
+ }
148
+ }
149
+ }
150
+ ... on OpinionTopper {
151
+ headshot(dpr: 2, width: 150)
152
+ columnist {
153
+ ...Concept
154
+ }
155
+ }
156
+ ... on BrandedTopper {
157
+ brandConcept {
158
+ ...Concept
159
+ }
160
+ }
161
+ ... on TopperWithTheme {
162
+ isLargeHeadline
163
+ layout
164
+ }
165
+ }
166
+ ${exports.StructuredTreeFragmentDoc}
167
+ ${exports.ConceptFragmentDoc}
168
+ ${exports.ImageSourceFragmentDoc}`;
169
+ exports.DisplayConceptFragmentDoc = (0, graphql_tag_1.default) `
170
+ fragment DisplayConcept on Content {
171
+ metaPrefixText
172
+ metaLink {
173
+ ...Concept
174
+ }
175
+ metaAltLink {
176
+ ...Concept
177
+ }
178
+ }
179
+ ${exports.ConceptFragmentDoc}`;
180
+ exports.TeaserFragmentDoc = (0, graphql_tag_1.default) `
181
+ fragment Teaser on Content {
182
+ title
183
+ id
184
+ url
185
+ relativeUrl: url(relative: true)
186
+ type
187
+ publishedDate
188
+ firstPublishedDate
189
+ ...DisplayConcept
190
+ image: mainImage {
191
+ url: binaryUrl
192
+ width: originalWidth
193
+ height: originalHeight
194
+ }
195
+ indicators {
196
+ accessLevel
197
+ isOpinion
198
+ isColumn
199
+ isPodcast
200
+ isEditorsChoice
201
+ isExclusive
202
+ isScoop
203
+ }
204
+ }
205
+ ${exports.DisplayConceptFragmentDoc}`;
206
+ exports.RecommendedFragmentDoc = (0, graphql_tag_1.default) `
207
+ fragment Recommended on Recommended {
208
+ title
209
+ teaser {
210
+ ...Teaser
211
+ }
212
+ }
213
+ ${exports.TeaserFragmentDoc}`;
214
+ exports.PictureFragmentDoc = (0, graphql_tag_1.default) `
215
+ fragment Picture on Picture {
216
+ __typename
217
+ alt
218
+ caption
219
+ imageType
220
+ ... on PictureStandard {
221
+ images {
222
+ standard {
223
+ sources(width: 700) {
224
+ ...ImageSource
225
+ }
226
+ originalWidth
227
+ originalHeight
228
+ }
229
+ S: small {
230
+ sources(width: 490) {
231
+ ...ImageSource
232
+ }
233
+ maxDisplayWidth(width: 490)
234
+ originalWidth
235
+ originalHeight
236
+ }
237
+ L: standard {
238
+ sources(width: 540) {
239
+ ...ImageSource
240
+ }
241
+ minDisplayWidth(width: 980)
242
+ maxDisplayWidth(width: 1219)
243
+ originalWidth
244
+ originalHeight
245
+ }
246
+ }
247
+ }
248
+ ... on PictureInline {
249
+ images {
250
+ standard {
251
+ sources(width: 350) {
252
+ ...ImageSource
253
+ }
254
+ originalWidth
255
+ originalHeight
256
+ }
257
+ }
258
+ }
259
+ ... on PictureFullBleed {
260
+ images {
261
+ standard {
262
+ sources(width: 700) {
263
+ ...ImageSource
264
+ }
265
+ originalWidth
266
+ originalHeight
267
+ }
268
+ small {
269
+ sources(width: 490) {
270
+ ...ImageSource
271
+ }
272
+ maxDisplayWidth(width: 490)
273
+ originalWidth
274
+ originalHeight
275
+ }
276
+ large {
277
+ sources(width: 1200) {
278
+ ...ImageSource
279
+ }
280
+ minDisplayWidth
281
+ maxDisplayWidth
282
+ originalWidth
283
+ originalHeight
284
+ }
285
+ }
286
+ }
287
+ }
288
+ ${exports.ImageSourceFragmentDoc}`;
289
+ exports.ImageSetFragmentDoc = (0, graphql_tag_1.default) `
290
+ fragment ImageSet on ImageSet {
291
+ picture {
292
+ ...Picture
293
+ }
294
+ }
295
+ ${exports.PictureFragmentDoc}`;
296
+ exports.LayoutImageFragmentDoc = (0, graphql_tag_1.default) `
297
+ fragment LayoutImage on LayoutImage {
298
+ picture {
299
+ ...Picture
300
+ }
301
+ }
302
+ ${exports.PictureFragmentDoc}`;
303
+ exports.ArticleReferencesFragmentDoc = (0, graphql_tag_1.default) `
304
+ fragment ArticleReferences on Reference {
305
+ __typename
306
+ ...Recommended
307
+ ...ImageSet
308
+ ...LayoutImage
309
+ }
310
+ ${exports.RecommendedFragmentDoc}
311
+ ${exports.ImageSetFragmentDoc}
312
+ ${exports.LayoutImageFragmentDoc}`;
313
+ exports.StructuredContentFragmentDoc = (0, graphql_tag_1.default) `
314
+ fragment StructuredContent on StructuredContent {
315
+ ...StructuredTree
316
+ references {
317
+ ...ArticleReferences
318
+ }
319
+ }
320
+ ${exports.StructuredTreeFragmentDoc}
321
+ ${exports.ArticleReferencesFragmentDoc}`;
322
+ exports.ArticleDocument = (0, graphql_tag_1.default) `
323
+ query Article($uuid: String!, $useVanities: Boolean!) {
324
+ content(uuid: $uuid) {
325
+ title
326
+ byline {
327
+ tree
328
+ }
329
+ topper {
330
+ ...Topper
331
+ }
332
+ body {
333
+ structured {
334
+ ...StructuredContent
335
+ }
336
+ }
337
+ }
338
+ }
339
+ ${exports.TopperFragmentDoc}
340
+ ${exports.StructuredContentFragmentDoc}`;
341
+ const defaultWrapper = (action, _operationName, _operationType) => action();
342
+ function getSdk(client, withWrapper = defaultWrapper) {
343
+ return {
344
+ Article(variables, requestHeaders) {
345
+ return withWrapper((wrappedRequestHeaders) => client.request(exports.ArticleDocument, variables, { ...requestHeaders, ...wrappedRequestHeaders }), 'Article', 'query');
346
+ }
347
+ };
348
+ }
349
+ exports.getSdk = getSdk;
350
+ //# sourceMappingURL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AO,CAAC,SAAgC,EAAE,cAA2C;YACnF,OAAO,WAAW,CAAC,CAAC,qBAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAe,uBAAe,EAAE,SAAS,EAAE,EAAC,GAAG,cAAc,EAAE,GAAG,qBAAqB,EAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC7K,CAAC;KACF,CAAC;AACJ,CAAC;AAND,wBAMC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { Sdk } from './generated/index.js';
2
+ declare type ClientOptions = {
3
+ systemCode: string;
4
+ baseUrl?: string;
5
+ };
6
+ export default function init(options: ClientOptions): Sdk;
7
+ export * from './generated/index.js';
package/lib/index.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const index_js_1 = require("./generated/index.js");
18
+ const graphql_request_1 = require("graphql-request");
19
+ function init(options) {
20
+ var _a;
21
+ if (!options.systemCode) {
22
+ throw new Error('A systemCode option is required. This should be the Biz Ops system code of the app sending requests to cp-content-pipeline');
23
+ }
24
+ const client = new graphql_request_1.GraphQLClient((_a = options.baseUrl) !== null && _a !== void 0 ? _a : 'https://www.ft.com/__content', {
25
+ headers: {
26
+ 'system-code': options.systemCode,
27
+ },
28
+ });
29
+ return (0, index_js_1.getSdk)(client);
30
+ }
31
+ exports.default = init;
32
+ __exportStar(require("./generated/index.js"), exports);
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAkD;AAClD,qDAA+C;AAO/C,SAAwB,IAAI,CAAC,OAAsB;;IACjD,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;QACvB,MAAM,IAAI,KAAK,CACb,4HAA4H,CAC7H,CAAA;KACF;IAED,MAAM,MAAM,GAAG,IAAI,+BAAa,CAC9B,MAAA,OAAO,CAAC,OAAO,mCAAI,8BAA8B,EACjD;QACE,OAAO,EAAE;YACP,aAAa,EAAE,OAAO,CAAC,UAAU;SAClC;KACF,CACF,CAAA;IAED,OAAO,IAAA,iBAAM,EAAC,MAAM,CAAC,CAAA;AACvB,CAAC;AAjBD,uBAiBC;AAED,uDAAoC"}
package/loader.js ADDED
@@ -0,0 +1,11 @@
1
+ const { mergeTypeDefs } = require('@graphql-tools/merge')
2
+
3
+ module.exports = async function () {
4
+ // need a cachebust query parameter so it's imported fresh
5
+ // each time. yes, this actually works, imports use URLs (ish)
6
+ const { typeDefs } = await import(
7
+ `@financial-times/cp-content-pipeline-schema/lib/index.js?cachebust=${Date.now()}`
8
+ )
9
+
10
+ return mergeTypeDefs(typeDefs)
11
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@financial-times/cp-content-pipeline-client",
3
+ "version": "0.2.0",
4
+ "description": "",
5
+ "main": "lib/index.js",
6
+ "scripts": {
7
+ "build": "dotcom-tool-kit build:local",
8
+ "test": "dotcom-tool-kit test:local",
9
+ "start": "dotcom-tool-kit run:local"
10
+ },
11
+ "devDependencies": {
12
+ "@dotcom-tool-kit/npm": "^2.0.8",
13
+ "@financial-times/cp-content-pipeline-schema": "^0.2.0",
14
+ "@graphql-codegen/typescript": "^2.7.3",
15
+ "@graphql-codegen/typescript-generic-sdk": "^3.0.1",
16
+ "@graphql-codegen/typescript-graphql-request": "^4.5.3",
17
+ "@graphql-codegen/typescript-operations": "^2.5.3",
18
+ "@graphql-tools/merge": "^8.3.6",
19
+ "graphql": "^16.6.0"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/Financial-Times/cp-content-pipeline.git"
24
+ },
25
+ "author": "",
26
+ "license": "ISC",
27
+ "bugs": {
28
+ "url": "https://github.com/Financial-Times/cp-content-pipeline/issues"
29
+ },
30
+ "homepage": "https://github.com/Financial-Times/cp-content-pipeline#readme",
31
+ "dependencies": {
32
+ "@graphql-typed-document-node/core": "^3.1.1",
33
+ "graphql-request": "^4.3.0"
34
+ }
35
+ }