@financial-times/cp-content-pipeline-client 3.3.5 → 3.3.7
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/README.md +86 -68
- package/lib/client-version.d.ts +1 -1
- package/lib/client-version.js +1 -1
- package/lib/generated/index.d.ts +546 -2
- package/lib/generated/index.js.map +1 -1
- package/lib/schema-version.d.ts +1 -1
- package/lib/schema-version.js +1 -1
- package/package.json +2 -2
- package/src/client-version.ts +1 -1
- package/src/generated/index.ts +546 -2
- package/src/schema-version.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -420,6 +420,18 @@
|
|
|
420
420
|
* devDependencies
|
|
421
421
|
* @financial-times/cp-content-pipeline-schema bumped from ^2.5.1 to ^2.5.2
|
|
422
422
|
|
|
423
|
+
### Dependencies
|
|
424
|
+
|
|
425
|
+
* The following workspace dependencies were updated
|
|
426
|
+
* devDependencies
|
|
427
|
+
* @financial-times/cp-content-pipeline-schema bumped from ^2.5.2 to ^2.5.3
|
|
428
|
+
|
|
429
|
+
### Dependencies
|
|
430
|
+
|
|
431
|
+
* The following workspace dependencies were updated
|
|
432
|
+
* devDependencies
|
|
433
|
+
* @financial-times/cp-content-pipeline-schema bumped from ^2.5.3 to ^2.5.4
|
|
434
|
+
|
|
423
435
|
## [3.3.1](https://github.com/Financial-Times/cp-content-pipeline/compare/cp-content-pipeline-client-v3.3.0...cp-content-pipeline-client-v3.3.1) (2024-03-22)
|
|
424
436
|
|
|
425
437
|
|
package/README.md
CHANGED
|
@@ -1,83 +1,111 @@
|
|
|
1
|
-
# Content Pipeline
|
|
1
|
+
# Content Pipeline Client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A JavaScript client for querying the GraphQL API.
|
|
4
|
+
|
|
5
|
+
It exports:
|
|
6
|
+
|
|
7
|
+
- The generated TypeScript type definitions for `cp-content-pipeline-ui`, which are the output of [@graphql-codegen](https://www.npmjs.com/package/@graphql-codegen/cli) on `typeDefs` defined in `cp-content-pipeline-schema`.
|
|
8
|
+
- A pre-defined query for a complete article written in `cp-content-pipeline-schema`.
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Getting Started](#getting-started)
|
|
13
|
+
- [Versioning](#versioning)
|
|
14
|
+
- [Overview](#overview)
|
|
4
15
|
|
|
5
|
-
The published `cp-content-pipeline-client` package mainly consists of generated code. To understand more about how this package is produced read the ["How this package is produced"](#how-this-package-is-produced) section below
|
|
6
16
|
|
|
7
17
|
## Getting Started
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
To run the client, see [Quick Start](../../README.md#quick-start).
|
|
10
20
|
|
|
11
|
-
|
|
21
|
+
### Usage
|
|
12
22
|
|
|
13
|
-
|
|
23
|
+
#### Initialising the client
|
|
14
24
|
|
|
15
25
|
```js
|
|
16
26
|
import initContentPipelineClient from '@financial-times/cp-content-pipeline-client'
|
|
27
|
+
import { Body } from '@financial-times/cp-content-pipeline-ui'
|
|
17
28
|
|
|
29
|
+
// initialise the content pipeline client
|
|
18
30
|
const client = initContentPipelineClient({
|
|
19
31
|
apiKey: 'some-secret',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
systemCode: 'app-name',
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### Calling the client
|
|
37
|
+
|
|
38
|
+
You can either query the client by using the main `.Article` method:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
// query the client instance, passing in a `uuid` parameter
|
|
42
|
+
const { content } = await client.Article({
|
|
43
|
+
uuid: 'a70c927-ff16-4977-942f-897cfd1349af',
|
|
23
44
|
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or by using the `.ArticleCannedQuery` method, which uses the canned query `GET` endpoint:
|
|
24
48
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
```js
|
|
50
|
+
// query the client instance, passing in a `uuid` parameter
|
|
51
|
+
const { content } = await client.ArticleCannedQuery({
|
|
52
|
+
uuid: 'a70c927-ff16-4977-942f-897cfd1349af',
|
|
28
53
|
})
|
|
29
54
|
```
|
|
30
55
|
|
|
31
|
-
|
|
56
|
+
```js
|
|
57
|
+
// render JSX component with the fetched content
|
|
58
|
+
const ArticleBody = () => {
|
|
59
|
+
return (
|
|
60
|
+
...
|
|
61
|
+
<Body content={content} />
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
```
|
|
32
65
|
|
|
33
|
-
|
|
66
|
+
## Versioning
|
|
34
67
|
|
|
35
|
-
|
|
68
|
+
The client requests versions of the API based on the version of the schema it has installed as a dependency. For example, a client that depends on
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
@financial-times/cp-content-pipeline-schema: "2.0.x"
|
|
72
|
+
```
|
|
36
73
|
|
|
37
|
-
|
|
74
|
+
will send requests to `https://www.ft.com/__content/v2`.
|
|
38
75
|
|
|
39
|
-
|
|
76
|
+
When we release a new major version of the schema, we'll release a new major version of the client alongside it, so consuming apps can install the new version of the client to get the breaking schema changes, and consumers still depending on the old client version will get the old schema.
|
|
40
77
|
|
|
41
|
-
The
|
|
78
|
+
The `baseUrl` option overrides this logic:
|
|
42
79
|
|
|
43
|
-
|
|
80
|
+
```js
|
|
81
|
+
const client = initContentPipelineClient({
|
|
82
|
+
apiKey: 'some-secret',
|
|
83
|
+
systemCode: 'app-name'
|
|
84
|
+
baseUrl: 'https://ft.com/__content/v3'
|
|
85
|
+
});
|
|
86
|
+
```
|
|
44
87
|
|
|
45
|
-
|
|
88
|
+
It forces all requests to go to that URL. If the version is not included, it will default to the latest schema version.
|
|
46
89
|
|
|
47
|
-
|
|
90
|
+
This means if you're overriding `baseUrl`, you're **opting out** of having the client handle versioning for you. For this reason, **`baseUrl` should only be used for testing purposes**, e.g. to force the client to send requests to a locally-running API.
|
|
48
91
|
|
|
49
|
-
|
|
92
|
+
### Overview
|
|
50
93
|
|
|
51
|
-
|
|
94
|
+
This diagram visualises how various parts piece together to produce the published `cp-content-pipeline-client`:
|
|
52
95
|
|
|
53
|
-
This diagram visualises how these parts piece together to produce the published `cp-content-pipeline-client`:
|
|
54
96
|
|
|
55
97
|
```mermaid
|
|
56
98
|
flowchart TB
|
|
57
99
|
|
|
58
100
|
subgraph cpContentPipelineSchema[cp-content-pipeline-schema]
|
|
59
|
-
subgraph
|
|
60
|
-
id1[Schema, Resolvers & Typedefs for each article feature <br> Article features are things like toppers, teasters, links, pullquotes, etc]:::description
|
|
101
|
+
subgraph typeDefs[typeDefs, resolvers, articleDocumentQuery]
|
|
61
102
|
end
|
|
62
|
-
|
|
103
|
+
typeDefs:::internalComponent
|
|
63
104
|
end
|
|
64
|
-
cpContentPipelineSchema:::internalContainer
|
|
65
105
|
|
|
66
106
|
subgraph cpContentPipelineClient[cp-content-pipeline-client]
|
|
67
|
-
subgraph codegenConfig[Codegen config]
|
|
68
|
-
id2[A codegen config file]:::description
|
|
69
|
-
end
|
|
70
|
-
codegenConfig:::internalComponent
|
|
71
|
-
subgraph articleQuery[Article GraphQL Query]
|
|
72
|
-
id3[A article.graphql file is a hand crafted query for a complete article]:::description
|
|
73
|
-
end
|
|
74
|
-
articleQuery:::internalComponent
|
|
75
|
-
|
|
76
|
-
|
|
77
107
|
subgraph toolkitPlugin[Codegen Toolkit Plugin]
|
|
78
|
-
|
|
79
|
-
subgraph codegenPackage[graphql-codegen package]
|
|
80
|
-
id5[A third party package that takes GraphQL schemas to produce a variety of outputs]:::description
|
|
108
|
+
subgraph codegenPackage[graphql-codegen third party package]
|
|
81
109
|
end
|
|
82
110
|
codegenPackage:::externalSystem
|
|
83
111
|
|
|
@@ -85,52 +113,42 @@ subgraph cpContentPipelineClient[cp-content-pipeline-client]
|
|
|
85
113
|
toolkitPlugin:::internalComponent
|
|
86
114
|
|
|
87
115
|
|
|
88
|
-
subgraph generatedOuput[
|
|
89
|
-
|
|
116
|
+
subgraph generatedOuput[Generated Output]
|
|
117
|
+
id0[Published exports]:::description
|
|
90
118
|
subgraph graphqlClient[GraphQL Client]
|
|
91
|
-
id7[A client for querying the GraphQL API]:::description
|
|
92
119
|
end
|
|
93
120
|
graphqlClient:::internalComponent
|
|
94
121
|
subgraph tsTypes[Typescript Types]
|
|
95
|
-
id8[TypeScript types generated from the GraphQL schema]:::description
|
|
96
122
|
end
|
|
97
123
|
tsTypes:::internalComponent
|
|
98
124
|
end
|
|
99
125
|
generatedOuput:::internalGrouping
|
|
100
126
|
end
|
|
101
|
-
cpContentPipelineClient:::internalContainer
|
|
102
127
|
|
|
103
|
-
subgraph key[Key]
|
|
104
|
-
subgraph keyPackage[cp-content-pipeline package]
|
|
105
|
-
id9[A package from the cp-content-pipeline monorepo]:::description
|
|
106
|
-
end
|
|
107
|
-
keyPackage:::internalContainer
|
|
108
128
|
|
|
109
|
-
|
|
110
|
-
id10[A component within a cp-content-pipeline package]:::description
|
|
111
|
-
end
|
|
112
|
-
keyComponent:::internalComponent
|
|
129
|
+
class cpContentPipelineSchema cpContentPipelineSchema
|
|
113
130
|
|
|
114
|
-
subgraph keyExternal[External Component]
|
|
115
|
-
id11[An external package/component/dependency]:::description
|
|
116
|
-
end
|
|
117
|
-
keyExternal:::externalSystem
|
|
118
|
-
end
|
|
119
|
-
key:::keyContainer
|
|
120
131
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
codegenPackage--Produces the TypeScript types---->tsTypes
|
|
125
|
-
articleFeatures--Codegen uses the Schema package to generate the client <br> The typedefs are also used to generate TypeScript Types-->codegenPackage
|
|
132
|
+
codegenPackage--Outputs-->graphqlClient
|
|
133
|
+
codegenPackage--Outputs---->tsTypes
|
|
134
|
+
cpContentPipelineSchema-->toolkitPlugin
|
|
126
135
|
|
|
127
136
|
classDef internalContainer fill:#D4DFE8,stroke-width:0px
|
|
128
137
|
classDef internalComponent fill:#BDA8FA,stroke-width:0px
|
|
129
138
|
classDef internalGrouping stroke-width:2px,fill:none,stroke:black
|
|
130
139
|
classDef externalSystem fill:#03A696,stroke-width:1px,stroke:black
|
|
131
140
|
classDef description stroke-width:0px,color:#000,fill:transparent,font-size:13px
|
|
132
|
-
classDef keyContainer fill: transparent, stroke: black
|
|
141
|
+
classDef keyContainer fill: transparent, stroke: black
|
|
142
|
+
|
|
143
|
+
%% Styling
|
|
144
|
+
classDef cpContentPipelineClient margin-right:10.5cm
|
|
145
|
+
class cpContentPipelineClient cpContentPipelineClient
|
|
146
|
+
|
|
147
|
+
classDef cpContentPipelineSchema margin-right:3.5cm
|
|
148
|
+
|
|
149
|
+
classDef generatedOuput margin-right:8.7cm
|
|
150
|
+
class generatedOuput generatedOuput
|
|
133
151
|
|
|
134
152
|
style generatedOuput stroke-dasharray: 5 5
|
|
135
153
|
|
|
136
|
-
```
|
|
154
|
+
```
|
package/lib/client-version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "3.3.
|
|
1
|
+
export declare const version = "3.3.7";
|
package/lib/client-version.js
CHANGED