@financial-times/cp-content-pipeline-schema 0.3.4 → 0.3.5
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 +8 -0
- package/lib/tags/Flourish.d.ts +24 -0
- package/lib/tags/Flourish.js +37 -0
- package/lib/tags/Flourish.js.map +1 -0
- package/lib/tags/index.js +2 -0
- package/lib/tags/index.js.map +1 -1
- package/lib/tags/model/Flourish.d.ts +16 -0
- package/lib/tags/model/Flourish.js +54 -0
- package/lib/tags/model/Flourish.js.map +1 -0
- package/lib/tags/model/Flourish.test.d.ts +1 -0
- package/lib/tags/model/Flourish.test.js +208 -0
- package/lib/tags/model/Flourish.test.js.map +1 -0
- package/package.json +1 -1
- package/src/tags/Flourish.ts +51 -0
- package/src/tags/index.ts +2 -0
- package/src/tags/model/Flourish.test.ts +257 -0
- package/src/tags/model/Flourish.ts +61 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.5](https://github.com/Financial-Times/cp-content-pipeline/compare/cp-content-pipeline-schema-v0.3.4...cp-content-pipeline-schema-v0.3.5) (2022-11-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* create a new Flourish tag class ([95b7e9e](https://github.com/Financial-Times/cp-content-pipeline/commit/95b7e9e2962914679019938e9f4670d54b033cba))
|
|
9
|
+
* use the new Flourish tag in the schema and article query ([5e87745](https://github.com/Financial-Times/cp-content-pipeline/commit/5e87745e8d0ad0df51adbf4cf4790127e03f758d))
|
|
10
|
+
|
|
3
11
|
## [0.3.4](https://github.com/Financial-Times/cp-content-pipeline/compare/cp-content-pipeline-schema-v0.3.3...cp-content-pipeline-schema-v0.3.4) (2022-10-27)
|
|
4
12
|
|
|
5
13
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TagConstructor } from './index.js';
|
|
2
|
+
import type * as hast from 'hast';
|
|
3
|
+
import { QueryContext } from '../index.js';
|
|
4
|
+
import { Flourish as FlourishModel } from './model/Flourish.js';
|
|
5
|
+
declare class Flourish {
|
|
6
|
+
id: string;
|
|
7
|
+
model: FlourishModel;
|
|
8
|
+
static selector: string;
|
|
9
|
+
constructor(node: hast.Element);
|
|
10
|
+
static resolve: {
|
|
11
|
+
id: (parent: Flourish) => string;
|
|
12
|
+
type: (parent: Flourish) => string;
|
|
13
|
+
description: (parent: Flourish) => string;
|
|
14
|
+
fullGrid: (parent: Flourish) => boolean;
|
|
15
|
+
fallbackImage: (parent: Flourish, _args: any, context: QueryContext) => Promise<{
|
|
16
|
+
url: string;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
static typeDef: import("graphql").DocumentNode;
|
|
22
|
+
}
|
|
23
|
+
declare const FlourishClass: TagConstructor<Flourish>;
|
|
24
|
+
export { FlourishClass as Flourish };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { gql } from 'graphql-tag';
|
|
3
|
+
import { Flourish as FlourishModel } from './model/Flourish.js';
|
|
4
|
+
class Flourish {
|
|
5
|
+
constructor(node) {
|
|
6
|
+
var _b;
|
|
7
|
+
if (typeof ((_b = node.properties) === null || _b === void 0 ? void 0 : _b.id) !== 'string') {
|
|
8
|
+
throw new Error('Flourish is missing a href');
|
|
9
|
+
}
|
|
10
|
+
this.id = node.properties.id;
|
|
11
|
+
// Adding the model to the instance is required until we refactor how the resolve method integrates
|
|
12
|
+
this.model = new FlourishModel(node, this.id);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
_a = Flourish;
|
|
16
|
+
Flourish.selector = '[data-asset-type="flourish"]';
|
|
17
|
+
Flourish.resolve = {
|
|
18
|
+
id: (parent) => parent.id,
|
|
19
|
+
type: (parent) => parent.model.type(),
|
|
20
|
+
description: (parent) => parent.model.description(),
|
|
21
|
+
fullGrid: (parent) => parent.model.fullGrid(),
|
|
22
|
+
fallbackImage: async (parent, _args, context) => parent.model.fallbackImage(context),
|
|
23
|
+
};
|
|
24
|
+
Flourish.typeDef = gql `
|
|
25
|
+
type Flourish {
|
|
26
|
+
id: String!
|
|
27
|
+
type: String!
|
|
28
|
+
fullGrid: Boolean!
|
|
29
|
+
description: String
|
|
30
|
+
fallbackImage: FlourishFallback
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
${FlourishModel.typedef}
|
|
34
|
+
`;
|
|
35
|
+
const FlourishClass = Flourish;
|
|
36
|
+
export { FlourishClass as Flourish };
|
|
37
|
+
//# sourceMappingURL=Flourish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flourish.js","sourceRoot":"","sources":["../../src/tags/Flourish.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAIjC,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE/D,MAAM,QAAQ;IAMZ,YAAY,IAAkB;;QAC5B,IAAI,OAAO,CAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,EAAE,CAAA,KAAK,QAAQ,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC9C;QAED,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAA;QAE5B,mGAAmG;QACnG,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;IAC/C,CAAC;;;AAXM,iBAAQ,GAAG,8BAA8B,CAAA;AAazC,gBAAO,GAAG;IACf,EAAE,EAAE,CAAC,MAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE;IACnC,IAAI,EAAE,CAAC,MAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;IAC/C,WAAW,EAAE,CAAC,MAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE;IAC7D,QAAQ,EAAE,CAAC,MAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE;IACvD,aAAa,EAAE,KAAK,EAClB,MAAgB,EAChB,KAAU,EACV,OAAqB,EACrB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;CACzC,CAAA;AAEM,gBAAO,GAAG,GAAG,CAAA;;;;;;;;;MAShB,aAAa,CAAC,OAAO;GACxB,CAAA;AAGH,MAAM,aAAa,GAA6B,QAAQ,CAAA;AAExD,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,CAAA"}
|
package/lib/tags/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { ImageSet } from './ImageSet.js';
|
|
|
4
4
|
import { PullQuote } from './PullQuote.js';
|
|
5
5
|
import { Recommended } from './Recommended.js';
|
|
6
6
|
import { Tweet } from './Tweet.js';
|
|
7
|
+
import { Flourish } from './Flourish.js';
|
|
7
8
|
import { gql } from 'graphql-tag';
|
|
8
9
|
function createTagWithoutReference(name, selector) {
|
|
9
10
|
var _a;
|
|
@@ -38,6 +39,7 @@ export const tags = {
|
|
|
38
39
|
Emphasis: createTagWithoutReference('Emphasis', 'em'),
|
|
39
40
|
Strong: createTagWithoutReference('Strong', 'strong'),
|
|
40
41
|
Strikethrough: createTagWithoutReference('Strikethrough', 's'),
|
|
42
|
+
Flourish,
|
|
41
43
|
};
|
|
42
44
|
const tagEntries = Object.entries(tags);
|
|
43
45
|
const tagsWithReferences = tagEntries.filter(([, tag]) => tag.typeDef);
|
package/lib/tags/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tags/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,M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;AAEtE,MAAM,CAAC,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAC/C,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,OAAuB,CAC7C,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA,qBAAqB,kBAAkB;KACtE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC;KACvB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAA;AAEhB,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CACzC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAC9E,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as hast from 'hast';
|
|
2
|
+
import { QueryContext } from '../../index.js';
|
|
3
|
+
export declare class Flourish {
|
|
4
|
+
private node;
|
|
5
|
+
private id;
|
|
6
|
+
constructor(node: hast.Element, id: string);
|
|
7
|
+
type(): string;
|
|
8
|
+
description(): string;
|
|
9
|
+
fullGrid(): boolean;
|
|
10
|
+
fallbackImage(context: QueryContext): Promise<{
|
|
11
|
+
url: string;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}>;
|
|
15
|
+
static typedef: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import imageServiceUrl from '../../helpers/imageService.js';
|
|
2
|
+
export class Flourish {
|
|
3
|
+
constructor(node, id) {
|
|
4
|
+
this.node = node;
|
|
5
|
+
this.id = id;
|
|
6
|
+
}
|
|
7
|
+
type() {
|
|
8
|
+
var _a;
|
|
9
|
+
// Default to visulisation for backwards compatibility
|
|
10
|
+
return typeof ((_a = this.node.properties) === null || _a === void 0 ? void 0 : _a.dataFlourishType) === 'string'
|
|
11
|
+
? this.node.properties.dataFlourishType
|
|
12
|
+
: 'visulisation';
|
|
13
|
+
}
|
|
14
|
+
description() {
|
|
15
|
+
var _a;
|
|
16
|
+
return typeof ((_a = this.node.properties) === null || _a === void 0 ? void 0 : _a.description) === 'string'
|
|
17
|
+
? this.node.properties.description
|
|
18
|
+
: '';
|
|
19
|
+
}
|
|
20
|
+
fullGrid() {
|
|
21
|
+
var _a;
|
|
22
|
+
return ((_a = this.node.properties) === null || _a === void 0 ? void 0 : _a.dataLayoutWidth) === 'full-grid' ? true : false;
|
|
23
|
+
}
|
|
24
|
+
async fallbackImage(context) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
// Some magic numbers that exist in the current code base and I don't know why these numbers
|
|
27
|
+
const DEFAULT_WIDTH = 2626;
|
|
28
|
+
const DEFAULT_HEIGHT = 1459;
|
|
29
|
+
const type = this.type();
|
|
30
|
+
const timestamp = typeof ((_a = this.node.properties) === null || _a === void 0 ? void 0 : _a.dataTimeStamp) === 'string'
|
|
31
|
+
? (_b = this.node.properties) === null || _b === void 0 ? void 0 : _b.dataTimeStamp
|
|
32
|
+
: false;
|
|
33
|
+
const flourishUrl = `https://public.flourish.studio/${type}/${this.id}/thumbnail${timestamp ? '?cacheBuster=' + timestamp : ''}`;
|
|
34
|
+
const imageMetadata = await context.dataSources.origami.getImageMetadata(flourishUrl);
|
|
35
|
+
const imageServiceWrappedUrl = imageServiceUrl({
|
|
36
|
+
url: flourishUrl,
|
|
37
|
+
systemCode: context.systemCode,
|
|
38
|
+
width: (imageMetadata === null || imageMetadata === void 0 ? void 0 : imageMetadata.width) || DEFAULT_WIDTH,
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
url: imageServiceWrappedUrl,
|
|
42
|
+
width: (imageMetadata === null || imageMetadata === void 0 ? void 0 : imageMetadata.width) ? imageMetadata === null || imageMetadata === void 0 ? void 0 : imageMetadata.width : DEFAULT_WIDTH,
|
|
43
|
+
height: (imageMetadata === null || imageMetadata === void 0 ? void 0 : imageMetadata.height) ? imageMetadata === null || imageMetadata === void 0 ? void 0 : imageMetadata.height : DEFAULT_HEIGHT,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
Flourish.typedef = `
|
|
48
|
+
type FlourishFallback {
|
|
49
|
+
url: String
|
|
50
|
+
width: Int
|
|
51
|
+
height: Int
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
//# sourceMappingURL=Flourish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flourish.js","sourceRoot":"","sources":["../../../src/tags/model/Flourish.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAG3D,MAAM,OAAO,QAAQ;IACnB,YAAoB,IAAkB,EAAU,EAAU;QAAtC,SAAI,GAAJ,IAAI,CAAc;QAAU,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;IAE9D,IAAI;;QACF,sDAAsD;QACtD,OAAO,OAAO,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,UAAU,0CAAE,gBAAgB,CAAA,KAAK,QAAQ;YAC/D,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB;YACvC,CAAC,CAAC,cAAc,CAAA;IACpB,CAAC;IAED,WAAW;;QACT,OAAO,OAAO,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,UAAU,0CAAE,WAAW,CAAA,KAAK,QAAQ;YAC1D,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW;YAClC,CAAC,CAAC,EAAE,CAAA;IACR,CAAC;IAED,QAAQ;;QACN,OAAO,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,UAAU,0CAAE,eAAe,MAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KA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AAG;;;;;;KAMd,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { h as hastscript } from 'hastscript';
|
|
2
|
+
import { jest } from '@jest/globals';
|
|
3
|
+
import { Flourish as FlourishModel } from './Flourish.js';
|
|
4
|
+
function createNode(tagname, properties) {
|
|
5
|
+
return hastscript(tagname, properties);
|
|
6
|
+
}
|
|
7
|
+
describe('Flourish Model', () => {
|
|
8
|
+
const origamiGetImageMetadataMock = jest.fn();
|
|
9
|
+
const context = {
|
|
10
|
+
systemCode: 'example-system',
|
|
11
|
+
dataSources: {
|
|
12
|
+
origami: {
|
|
13
|
+
getImageMetadata: origamiGetImageMetadataMock,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
jest.resetAllMocks();
|
|
19
|
+
});
|
|
20
|
+
describe('.type()', () => {
|
|
21
|
+
describe('the flourish type exists', () => {
|
|
22
|
+
it('returns the type', () => {
|
|
23
|
+
const node = createNode('ft-content', {
|
|
24
|
+
dataAssetType: 'flourish',
|
|
25
|
+
id: 'example-id',
|
|
26
|
+
dataFlourishType: 'example-type',
|
|
27
|
+
dataLayoutWidth: 'full-grid',
|
|
28
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
29
|
+
alt: 'Example alt',
|
|
30
|
+
description: 'Example description',
|
|
31
|
+
});
|
|
32
|
+
const model = new FlourishModel(node, 'example-id');
|
|
33
|
+
expect(model.type()).toBe('example-type');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe('the flourish type is missing', () => {
|
|
37
|
+
it('returns the backwards compatible fallback', () => {
|
|
38
|
+
const node = createNode('ft-content', {
|
|
39
|
+
dataAssetType: 'flourish',
|
|
40
|
+
id: 'example-id',
|
|
41
|
+
dataLayoutWidth: 'full-grid',
|
|
42
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
43
|
+
alt: 'Example alt',
|
|
44
|
+
description: 'Example description',
|
|
45
|
+
});
|
|
46
|
+
const model = new FlourishModel(node, 'example-id');
|
|
47
|
+
expect(model.type()).toBe('visulisation');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('.fullGrid()', () => {
|
|
52
|
+
it('returns true when the graphic is full grid', () => {
|
|
53
|
+
const node = createNode('ft-content', {
|
|
54
|
+
dataAssetType: 'flourish',
|
|
55
|
+
id: 'example-id',
|
|
56
|
+
dataFlourishType: 'example-type',
|
|
57
|
+
dataLayoutWidth: 'full-grid',
|
|
58
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
59
|
+
alt: 'Example alt',
|
|
60
|
+
description: 'Example description',
|
|
61
|
+
});
|
|
62
|
+
const model = new FlourishModel(node, 'example-id');
|
|
63
|
+
expect(model.fullGrid()).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
it('returns false when the graphic is NOT full grid', () => {
|
|
66
|
+
const node = createNode('ft-content', {
|
|
67
|
+
dataAssetType: 'flourish',
|
|
68
|
+
id: 'example-id',
|
|
69
|
+
dataFlourishType: 'example-type',
|
|
70
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
71
|
+
alt: 'Example alt',
|
|
72
|
+
description: 'Example description',
|
|
73
|
+
});
|
|
74
|
+
const model = new FlourishModel(node, 'example-id');
|
|
75
|
+
expect(model.fullGrid()).toBe(false);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe('.description()', () => {
|
|
79
|
+
it('returns the description when one is provided', () => {
|
|
80
|
+
const node = createNode('ft-content', {
|
|
81
|
+
dataAssetType: 'flourish',
|
|
82
|
+
id: 'example-id',
|
|
83
|
+
dataFlourishType: 'example-type',
|
|
84
|
+
dataLayoutWidth: 'full-grid',
|
|
85
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
86
|
+
alt: 'Example alt',
|
|
87
|
+
description: 'Example description',
|
|
88
|
+
});
|
|
89
|
+
const model = new FlourishModel(node, 'example-id');
|
|
90
|
+
expect(model.description()).toBe('Example description');
|
|
91
|
+
});
|
|
92
|
+
it('returns empty string when no description is provided', () => {
|
|
93
|
+
const node = createNode('ft-content', {
|
|
94
|
+
dataAssetType: 'flourish',
|
|
95
|
+
id: 'example-id',
|
|
96
|
+
dataFlourishType: 'example-type',
|
|
97
|
+
dataLayoutWidth: 'full-grid',
|
|
98
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
99
|
+
alt: 'Example alt',
|
|
100
|
+
});
|
|
101
|
+
const model = new FlourishModel(node, 'example-id');
|
|
102
|
+
expect(model.description()).toBe('');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe('.fallbackImage()', () => {
|
|
106
|
+
describe('url', () => {
|
|
107
|
+
it('The Flourish base image url is used', async () => {
|
|
108
|
+
const node = createNode('ft-content', {
|
|
109
|
+
dataAssetType: 'flourish',
|
|
110
|
+
id: 'example-id',
|
|
111
|
+
dataFlourishType: 'example-type',
|
|
112
|
+
dataLayoutWidth: 'full-grid',
|
|
113
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
114
|
+
alt: 'Example alt',
|
|
115
|
+
description: 'Example description',
|
|
116
|
+
});
|
|
117
|
+
const model = new FlourishModel(node, 'example-id');
|
|
118
|
+
const fallbackResponse = await model.fallbackImage(context);
|
|
119
|
+
// Regex checks for flourish url whilst leaving spaces for arguments
|
|
120
|
+
// https://public.flourish.studio/{type}/{id}/thumbnail
|
|
121
|
+
const flourishImageUrlRegex = new RegExp(/https:\/\/public.flourish.studio\/.*\/.*\/thumbnail/);
|
|
122
|
+
expect(decodeURIComponent(fallbackResponse.url)).toMatch(flourishImageUrlRegex);
|
|
123
|
+
});
|
|
124
|
+
it('The Flourish id is included in the flourish image url', async () => {
|
|
125
|
+
const node = createNode('ft-content', {
|
|
126
|
+
dataAssetType: 'flourish',
|
|
127
|
+
id: 'example-id',
|
|
128
|
+
dataFlourishType: 'example-type',
|
|
129
|
+
dataLayoutWidth: 'full-grid',
|
|
130
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
131
|
+
alt: 'Example alt',
|
|
132
|
+
description: 'Example description',
|
|
133
|
+
});
|
|
134
|
+
const model = new FlourishModel(node, 'example-id');
|
|
135
|
+
const fallbackResponse = await model.fallbackImage(context);
|
|
136
|
+
const flourishImageUrlRegex = new RegExp(/https:\/\/public.flourish.studio\/.*\/example-id/);
|
|
137
|
+
expect(decodeURIComponent(fallbackResponse.url)).toMatch(flourishImageUrlRegex);
|
|
138
|
+
});
|
|
139
|
+
describe('the flourish type exists', () => {
|
|
140
|
+
it('The Flourish graphic type is included in the flourish image url', async () => {
|
|
141
|
+
const node = createNode('ft-content', {
|
|
142
|
+
dataAssetType: 'flourish',
|
|
143
|
+
id: 'example-id',
|
|
144
|
+
dataFlourishType: 'example-type',
|
|
145
|
+
dataLayoutWidth: 'full-grid',
|
|
146
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
147
|
+
alt: 'Example alt',
|
|
148
|
+
description: 'Example description',
|
|
149
|
+
});
|
|
150
|
+
const model = new FlourishModel(node, 'example-id');
|
|
151
|
+
const fallbackResponse = await model.fallbackImage(context);
|
|
152
|
+
const flourishImageUrl = 'https://public.flourish.studio/example-type';
|
|
153
|
+
expect(fallbackResponse.url).toContain(encodeURIComponent(flourishImageUrl));
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
describe('the flourish type is missing', () => {
|
|
157
|
+
it('The Flourish graphic type fallback is included in the flourish image url', async () => {
|
|
158
|
+
const node = createNode('ft-content', {
|
|
159
|
+
dataAssetType: 'flourish',
|
|
160
|
+
id: 'example-id',
|
|
161
|
+
dataLayoutWidth: 'full-grid',
|
|
162
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
163
|
+
alt: 'Example alt',
|
|
164
|
+
description: 'Example description',
|
|
165
|
+
});
|
|
166
|
+
const model = new FlourishModel(node, 'example-id');
|
|
167
|
+
const fallbackResponse = await model.fallbackImage(context);
|
|
168
|
+
const flourishImageUrl = 'https://public.flourish.studio/visulisation';
|
|
169
|
+
expect(fallbackResponse.url).toContain(encodeURIComponent(flourishImageUrl));
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
describe('the flourish timestamp exists', () => {
|
|
173
|
+
it('The Flourish cache buster is appended to the flourish image url', async () => {
|
|
174
|
+
const node = createNode('ft-content', {
|
|
175
|
+
dataAssetType: 'flourish',
|
|
176
|
+
id: 'example-id',
|
|
177
|
+
dataFlourishType: 'example-type',
|
|
178
|
+
dataLayoutWidth: 'full-grid',
|
|
179
|
+
dataTimeStamp: '2022-01-06T14:41:01.102Z',
|
|
180
|
+
alt: 'Example alt',
|
|
181
|
+
description: 'Example description',
|
|
182
|
+
});
|
|
183
|
+
const model = new FlourishModel(node, 'example-id');
|
|
184
|
+
const fallbackResponse = await model.fallbackImage(context);
|
|
185
|
+
const flourishImageCacheBuster = '?cacheBuster=2022-01-06T14:41:01.102Z';
|
|
186
|
+
expect(fallbackResponse.url).toContain(encodeURIComponent(flourishImageCacheBuster));
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe('the flourish timestamp is missing', () => {
|
|
190
|
+
it('The Flourish cache buster is not appended to the flourish image url', async () => {
|
|
191
|
+
const node = createNode('ft-content', {
|
|
192
|
+
dataAssetType: 'flourish',
|
|
193
|
+
id: 'example-id',
|
|
194
|
+
dataFlourishType: 'example-type',
|
|
195
|
+
dataLayoutWidth: 'full-grid',
|
|
196
|
+
alt: 'Example alt',
|
|
197
|
+
description: 'Example description',
|
|
198
|
+
});
|
|
199
|
+
const model = new FlourishModel(node, 'example-id');
|
|
200
|
+
const fallbackResponse = await model.fallbackImage(context);
|
|
201
|
+
const flourishImageCacheBuster = '?cacheBuster=';
|
|
202
|
+
expect(fallbackResponse.url).not.toContain(encodeURIComponent(flourishImageCacheBuster));
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
//# sourceMappingURL=Flourish.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flourish.test.js","sourceRoot":"","sources":["../../../src/tags/model/Flourish.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,IAAI,UAAU,EAA+B,MAAM,YAAY,CAAA;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEpC,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AAGzD,SAAS,UAAU,CAAC,OAAe,EAAE,UAA2B;IAC/D,OAAO,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;AACvC,CAAC;AAED,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC/B,MAAM,2BAA2B,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAE7C,MAAM,OAAO,GAAG;QACf,UAAU,EAAE,gBAAgB;QAC5B,WAAW,EAAE;YACZ,OAAO,EAAE;gBACR,gBAAgB,EAAE,2BAA2B;aAC7C;SACD;KAC0B,CAAA;IAE5B,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAA;IACrB,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;QACxB,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;YACzC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;gBAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,YAAY,EAAE;oBACrC,aAAa,EAAE,UAAU;oBACzB,EAAE,EAAE,YAAY;oBAChB,gBAAgB,EAAE,cAAc;oBAChC,eAAe,EAAE,WAAW;oBAC5B,aAAa,EAAE,0BAA0B;oBACzC,GAAG,EAAE,aAAa;oBAClB,WAAW,EAAE,qBAAqB;iBAClC,CAAC,CAAA;gBAEF,MAAM,KAAK,GAAG,IAAI,aAAa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;gBAErF,CAAC,CAAC,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;gBAClD,EAAE,CAAC,qEAAqE,EAAE,KAAK,IAAI,EAAE;oBACpF,MAAM,IAAI,GAAG,UAAU,CAAC,YAAY,EAAE;wBACrC,aAAa,EAAE,UAAU;wBACzB,EAAE,EAAE,YAAY;wBAChB,gBAAgB,EAAE,cAAc;wBAChC,eAAe,EAAE,WAAW;wBAC5B,GAAG,EAAE,aAAa;wBAClB,WAAW,EAAE,qBAAqB;qBAClC,CAAC,CAAA;oBAEF,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;oBACnD,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;oBAE3D,MAAM,wBAAwB,GAAG,eAAe,CAAA;oBAEhD,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAC,CAAA;gBAEzF,CAAC,CAAC,CAAA;YACH,CAAC,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag'
|
|
2
|
+
import type { TagConstructor } from './index.js'
|
|
3
|
+
import type * as hast from 'hast'
|
|
4
|
+
import { QueryContext } from '../index.js'
|
|
5
|
+
import { Flourish as FlourishModel } from './model/Flourish.js'
|
|
6
|
+
|
|
7
|
+
class Flourish {
|
|
8
|
+
id: string
|
|
9
|
+
model: FlourishModel
|
|
10
|
+
|
|
11
|
+
static selector = '[data-asset-type="flourish"]'
|
|
12
|
+
|
|
13
|
+
constructor(node: hast.Element) {
|
|
14
|
+
if (typeof node.properties?.id !== 'string') {
|
|
15
|
+
throw new Error('Flourish is missing a href')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
this.id = node.properties.id
|
|
19
|
+
|
|
20
|
+
// Adding the model to the instance is required until we refactor how the resolve method integrates
|
|
21
|
+
this.model = new FlourishModel(node, this.id)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static resolve = {
|
|
25
|
+
id: (parent: Flourish) => parent.id,
|
|
26
|
+
type: (parent: Flourish) => parent.model.type(),
|
|
27
|
+
description: (parent: Flourish) => parent.model.description(),
|
|
28
|
+
fullGrid: (parent: Flourish) => parent.model.fullGrid(),
|
|
29
|
+
fallbackImage: async (
|
|
30
|
+
parent: Flourish,
|
|
31
|
+
_args: any,
|
|
32
|
+
context: QueryContext
|
|
33
|
+
) => parent.model.fallbackImage(context),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static typeDef = gql`
|
|
37
|
+
type Flourish {
|
|
38
|
+
id: String!
|
|
39
|
+
type: String!
|
|
40
|
+
fullGrid: Boolean!
|
|
41
|
+
description: String
|
|
42
|
+
fallbackImage: FlourishFallback
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
${FlourishModel.typedef}
|
|
46
|
+
`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const FlourishClass: TagConstructor<Flourish> = Flourish
|
|
50
|
+
|
|
51
|
+
export { FlourishClass as Flourish }
|
package/src/tags/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { ImageSet } from './ImageSet.js'
|
|
|
9
9
|
import { PullQuote } from './PullQuote.js'
|
|
10
10
|
import { Recommended } from './Recommended.js'
|
|
11
11
|
import { Tweet } from './Tweet.js'
|
|
12
|
+
import { Flourish } from './Flourish.js'
|
|
12
13
|
import { gql } from 'graphql-tag'
|
|
13
14
|
|
|
14
15
|
export type Tag = object
|
|
@@ -69,6 +70,7 @@ export const tags: Record<string, TagConstructor> = {
|
|
|
69
70
|
Emphasis: createTagWithoutReference('Emphasis', 'em'),
|
|
70
71
|
Strong: createTagWithoutReference('Strong', 'strong'),
|
|
71
72
|
Strikethrough: createTagWithoutReference('Strikethrough', 's'),
|
|
73
|
+
Flourish,
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
const tagEntries = Object.entries(tags)
|