diff --git a/.changeset/forty-pears-laugh.md b/.changeset/forty-pears-laugh.md deleted file mode 100644 index b7c8c58f..00000000 --- a/.changeset/forty-pears-laugh.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -"@wpmedia/feeds-source-content-api-by-day2-block": major -"@wpmedia/feeds-source-content-api-by-day3-block": major -"@wpmedia/feeds-source-content-api-by-day-block": major -"@wpmedia/sitemap-section-index-feature-block": major -"@wpmedia/sitemap-index-by-day-feature-block": major -"@wpmedia/feeds-source-single-content-block": major -"@wpmedia/feeds-source-collections-block": major -"@wpmedia/feeds-source-content-api-block": major -"@wpmedia/rss-google-news-feature-block": major -"@wpmedia/sitemap-section-feature-block": major -"@wpmedia/feeds-source-video-api-block": major -"@wpmedia/rss-flipboard-feature-block": major -"@wpmedia/sitemap-index-feature-block": major -"@wpmedia/sitemap-video-feature-block": major -"@wpmedia/sitemap-news-feature-block": major -"@wpmedia/rss-alexa-feature-block": major -"@wpmedia/rss-fbia-feature-block": major -"@wpmedia/rss-msn-feature-block": major -"@wpmedia/sitemap-feature-block": major -"@wpmedia/mrss-feature-block": major -"@wpmedia/ans-feature-block": major -"@wpmedia/rss-feature-block": major -"@wpmedia/feeds-content-elements": major -"@wpmedia/feeds-promo-items": major -"@wpmedia/feeds-prop-types": major -"@wpmedia/feeds-xml-output": major -"@wpmedia/feeds-resizer": major ---- - -Adds resizer v2 support. diff --git a/.eslintrc.js b/.eslintrc.js index 11dda2b4..41f2f599 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,6 +3,7 @@ module.exports = { plugins: ['standard', 'prettier', 'react'], rules: { 'react/prop-types': 'warn', + 'object-shorthand': 'off', }, settings: { react: { @@ -12,7 +13,6 @@ module.exports = { overrides: [ { files: ['*.test.js', '__mocks__/**'], - }, ], env: { diff --git a/__mocks__/fusion:content-config.js b/__mocks__/fusion:content-config.js index 112b968e..bf59e3ac 100644 --- a/__mocks__/fusion:content-config.js +++ b/__mocks__/fusion:content-config.js @@ -23,8 +23,8 @@ module.exports = (options, ...moreSchemas) => { const args = !(options instanceof Object) ? { schemas: [options].concat(...moreSchemas) } : Array.isArray(options) - ? { schemas: options.concat(...moreSchemas) } - : options + ? { schemas: options.concat(...moreSchemas) } + : options return taggablePrimitive(instance, 'contentConfig', args) } diff --git a/__mocks__/fusion:prop-types.js b/__mocks__/fusion:prop-types.js index 14f8b498..961d0023 100644 --- a/__mocks__/fusion:prop-types.js +++ b/__mocks__/fusion:prop-types.js @@ -47,14 +47,14 @@ function _stringify(value) { return Array.isArray(value) ? `[${value.map(_stringify).join(',')}]` : value instanceof Object - ? `{${Object.keys(value) - .filter(ignorePropTypeMethods) - .filter(exists) - .map((key) => { - return `"${key}":${_stringify(value[key])}` - }) - .join(',')}}` - : JSON.stringify(value) + ? `{${Object.keys(value) + .filter(ignorePropTypeMethods) + .filter(exists) + .map((key) => { + return `"${key}":${_stringify(value[key])}` + }) + .join(',')}}` + : JSON.stringify(value) } FusionPropTypes.stringify = function stringify(value, replacer, space) { const str = _stringify(value) diff --git a/babel.config.js b/babel.config.js index 295c5ca6..d36ac58a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,9 +1,11 @@ module.exports = { - presets: [ [ - '@babel/preset-env', - { - targets: { esmodules: false, node: "current" } - }, + presets: [ + [ + '@babel/preset-env', + { + targets: { esmodules: false, node: 'current' }, + }, + ], + '@babel/preset-react', ], - '@babel/preset-react'], } diff --git a/blocks/ans-feature-block/CHANGELOG.md b/blocks/ans-feature-block/CHANGELOG.md index f570efc7..3214f788 100644 --- a/blocks/ans-feature-block/CHANGELOG.md +++ b/blocks/ans-feature-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/ans-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/ans-feature-block/package.json b/blocks/ans-feature-block/package.json index eed99a90..4fc98692 100644 --- a/blocks/ans-feature-block/package.json +++ b/blocks/ans-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/ans-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building ANS feeds", "main": "index.js", "files": [ @@ -25,6 +25,6 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0" + "@wpmedia/feeds-resizer": "^2.0.0" } } diff --git a/blocks/feeds-source-collections-block/CHANGELOG.md b/blocks/feeds-source-collections-block/CHANGELOG.md index cc199473..22752ab5 100644 --- a/blocks/feeds-source-collections-block/CHANGELOG.md +++ b/blocks/feeds-source-collections-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/feeds-source-collections-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/feeds-source-collections-block/package.json b/blocks/feeds-source-collections-block/package.json index a3155af9..743fd66f 100644 --- a/blocks/feeds-source-collections-block/package.json +++ b/blocks/feeds-source-collections-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-source-collections-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Content source to search collections by _id or alias", "main": "index.js", "files": [ @@ -28,7 +28,7 @@ }, "dependencies": { "@wpmedia/feeds-content-source-utils": "^1.0.8", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "axios": "^1.6.7" }, "devDependencies": { diff --git a/blocks/feeds-source-content-api-block/CHANGELOG.md b/blocks/feeds-source-content-api-block/CHANGELOG.md index f70adacd..7114b6fc 100644 --- a/blocks/feeds-source-content-api-block/CHANGELOG.md +++ b/blocks/feeds-source-content-api-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/feeds-source-content-api-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/feeds-source-content-api-block/package.json b/blocks/feeds-source-content-api-block/package.json index f9750321..41698db0 100644 --- a/blocks/feeds-source-content-api-block/package.json +++ b/blocks/feeds-source-content-api-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-source-content-api-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building sitemaps", "main": "index.js", "files": [ @@ -27,7 +27,7 @@ }, "dependencies": { "@wpmedia/feeds-content-source-utils": "^1.0.8", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "axios": "^1.6.7" }, "devDependencies": { diff --git a/blocks/feeds-source-content-api-block/sources/feeds-content-api.js b/blocks/feeds-source-content-api-block/sources/feeds-content-api.js index 2db35b66..2f9018c7 100644 --- a/blocks/feeds-source-content-api-block/sources/feeds-content-api.js +++ b/blocks/feeds-source-content-api-block/sources/feeds-content-api.js @@ -15,7 +15,6 @@ import { } from '@wpmedia/feeds-content-source-utils' import { signImagesInANSObject, resizerFetch } from '@wpmedia/feeds-resizer' - const fetch = (key, { cachedCall }) => { const requestUri = `${CONTENT_BASE}/content/v4/search/published` const ansFields = [ @@ -218,7 +217,7 @@ const fetch = (key, { cachedCall }) => { RESIZER_TOKEN_VERSION, )(result) }) - .then(({data, ...rest}) => ({ ...rest, data: transform(data, key), })) + .then(({ data, ...rest }) => ({ ...rest, data: transform(data, key) })) .then(({ data }) => data) .catch((error) => console.log('== error ==', error)) diff --git a/blocks/feeds-source-content-api-block/sources/feeds-content-api.test.js b/blocks/feeds-source-content-api-block/sources/feeds-content-api.test.js index 00ee5efd..5ac59553 100644 --- a/blocks/feeds-source-content-api-block/sources/feeds-content-api.test.js +++ b/blocks/feeds-source-content-api-block/sources/feeds-content-api.test.js @@ -1,15 +1,15 @@ -import axios from 'axios'; +import axios from 'axios' // eslint-disable-next-line no-unused-vars import Consumer from 'fusion:consumer' const source = require('./feeds-content-api') // Mock Axios -jest.mock('axios'); +jest.mock('axios') beforeEach(() => { // Reset Axios mocks before each test - axios.mockClear(); -}); + axios.mockClear() +}) it('validate schemaName', () => { expect(source.default.schemaName).toBe('feeds') @@ -39,28 +39,31 @@ it('validate params', () => { }) it('returns query with default values', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Section: '', - Author: '', - Keywords: '', - 'Tags-Text': '', - 'Tags-Slug': '', - 'arc-site': 'demo', - 'Include-Terms': '', - 'Exclude-Terms': '', - 'Exclude-Sections': '', - 'Feed-Size': '', - 'Feed-Offset': '', - Sort: '', - 'Source-Exclude': '', - 'Source-Include': '', - 'Sitemap-at-root': '', - }, { cachedCall: {} }); - - expect(axios).toHaveBeenCalledTimes(1); + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Section: '', + Author: '', + Keywords: '', + 'Tags-Text': '', + 'Tags-Slug': '', + 'arc-site': 'demo', + 'Include-Terms': '', + 'Exclude-Terms': '', + 'Exclude-Sections': '', + 'Feed-Size': '', + 'Feed-Offset': '', + Sort: '', + 'Source-Exclude': '', + 'Source-Include': '', + 'Sitemap-at-root': '', + }, + { cachedCall: {} }, + ) + + expect(axios).toHaveBeenCalledTimes(1) expect(axios).toHaveBeenCalledWith({ url: expect.stringContaining(`/content/v4/search/published`), // Check base URL method: 'GET', @@ -68,252 +71,293 @@ it('returns query with default values', async () => { 'content-type': 'application/json', Authorization: expect.stringContaining('Bearer '), }), - }); + }) - const callUrl = axios.mock.calls[0][0].url; + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/content/v4/search/published?body=%7B%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22type%22:%22story%22%7D%7D,%7B%22range%22:%7B%22last_updated_date%22:%7B%22gte%22:%22now-2d%22,%22lte%22:%22now%22%7D%7D%7D%5D%7D%7D%7D&website=demo&size=100&from=0&sort=publish_date:desc&_sourceInclude=canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,content_elements,websites.demo', ) }) it('returns query with parameter values', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Section: '', - Author: '', - Keywords: '', - 'Tags-Text': '', - 'Tags-Slug': '', - 'arc-site': 'demo', - 'Include-Terms': '', - 'Exclude-Terms': '', - 'Exclude-Sections': '', - 'Feed-Size': '25', - 'Feed-Offset': '3', - Sort: 'display_date:asc', - 'Source-Exclude': 'content_elements,taxonomy', - 'Source-Include': 'source,owner', - 'Sitemap-at-root': '', - 'Include-Distributor-Name': 'AP', - 'Exclude-Distributor-Name': 'paid', - 'Include-Distributor-Category': 'promotions', - 'Exclude-Distributor-Category': 'wires', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; - const queryParams = new URLSearchParams(callUrl.split('?')[1]); - expect(queryParams.has('content_elements')).not.toBeTruthy(); - expect(queryParams.has('paid')).not.toBeTruthy(); - expect(queryParams.has('promotions')).not.toBeTruthy(); - expect(queryParams.has('wires')).not.toBeTruthy(); - expect(queryParams.get('size')).toBe('25'); - expect(queryParams.get('from')).toBe('3'); - expect(queryParams.get('_sourceExclude')).toBe('taxonomy'); - expect(queryParams.get('_sourceInclude')).toBe('canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,websites.demo,source,owner'); - expect(queryParams.get('include_distributor_name')).toBe('AP'); + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Section: '', + Author: '', + Keywords: '', + 'Tags-Text': '', + 'Tags-Slug': '', + 'arc-site': 'demo', + 'Include-Terms': '', + 'Exclude-Terms': '', + 'Exclude-Sections': '', + 'Feed-Size': '25', + 'Feed-Offset': '3', + Sort: 'display_date:asc', + 'Source-Exclude': 'content_elements,taxonomy', + 'Source-Include': 'source,owner', + 'Sitemap-at-root': '', + 'Include-Distributor-Name': 'AP', + 'Exclude-Distributor-Name': 'paid', + 'Include-Distributor-Category': 'promotions', + 'Exclude-Distributor-Category': 'wires', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url + const queryParams = new URLSearchParams(callUrl.split('?')[1]) + expect(queryParams.has('content_elements')).not.toBeTruthy() + expect(queryParams.has('paid')).not.toBeTruthy() + expect(queryParams.has('promotions')).not.toBeTruthy() + expect(queryParams.has('wires')).not.toBeTruthy() + expect(queryParams.get('size')).toBe('25') + expect(queryParams.get('from')).toBe('3') + expect(queryParams.get('_sourceExclude')).toBe('taxonomy') + expect(queryParams.get('_sourceInclude')).toBe( + 'canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,websites.demo,source,owner', + ) + expect(queryParams.get('include_distributor_name')).toBe('AP') }) it('returns query by section', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Section: 'sports/', - Author: '', - Keywords: '', - 'Tags-Text': '', - 'Tags-Slug': '', - 'arc-site': 'demo', - 'Include-Terms': '', - 'Exclude-Terms': '', - 'Exclude-Sections': '', - 'Feed-Size': '', - 'Feed-Offset': '', - Sort: '', - 'Source-Exclude': '', - 'Source-Include': '', - 'Sitemap-at-root': '', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Section: 'sports/', + Author: '', + Keywords: '', + 'Tags-Text': '', + 'Tags-Slug': '', + 'arc-site': 'demo', + 'Include-Terms': '', + 'Exclude-Terms': '', + 'Exclude-Sections': '', + 'Feed-Size': '', + 'Feed-Offset': '', + Sort: '', + 'Source-Exclude': '', + 'Source-Include': '', + 'Sitemap-at-root': '', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toContain('%22taxonomy.sections._id%22:%5B%22/sports%22') }) it('returns query by Exclude-Sections', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Section: '', - Author: '', - Keywords: '', - 'Tags-Text': '', - 'Tags-Slug': '', - 'arc-site': 'demo', - 'Include-Terms': '', - 'Exclude-Terms': '', - 'Exclude-Sections': '/food,politics', - 'Feed-Size': '', - 'Feed-Offset': '', - Sort: '', - 'Source-Exclude': '', - 'Source-Include': '', - 'Sitemap-at-root': '', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Section: '', + Author: '', + Keywords: '', + 'Tags-Text': '', + 'Tags-Slug': '', + 'arc-site': 'demo', + 'Include-Terms': '', + 'Exclude-Terms': '', + 'Exclude-Sections': '/food,politics', + 'Feed-Size': '', + 'Feed-Offset': '', + Sort: '', + 'Source-Exclude': '', + 'Source-Include': '', + 'Sitemap-at-root': '', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/content/v4/search/published?body=%7B%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22type%22:%22story%22%7D%7D,%7B%22range%22:%7B%22last_updated_date%22:%7B%22gte%22:%22now-2d%22,%22lte%22:%22now%22%7D%7D%7D,%7B%22nested%22:%7B%22path%22:%22taxonomy.sections%22,%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22taxonomy.sections._website%22:%22demo%22%7D%7D%5D%7D%7D%7D%7D%5D,%22must_not%22:%5B%7B%22nested%22:%7B%22path%22:%22taxonomy.sections%22,%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22terms%22:%7B%22taxonomy.sections._id%22:%5B%22/food%22,%22/politics%22%5D%7D%7D%5D%7D%7D%7D%7D%5D%7D%7D%7D&website=demo&size=100&from=0&sort=publish_date:desc&_sourceInclude=canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,content_elements,websites.demo', ) }) it('returns query by section and Exclude-Sections', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Section: '/sports/,/news/', - 'arc-site': 'demo', - 'Exclude-Sections': '/food,politics/', - 'Sitemap-at-root': 'false', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Section: '/sports/,/news/', + 'arc-site': 'demo', + 'Exclude-Sections': '/food,politics/', + 'Sitemap-at-root': 'false', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/content/v4/search/published?body=%7B%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22type%22:%22story%22%7D%7D,%7B%22range%22:%7B%22last_updated_date%22:%7B%22gte%22:%22now-2d%22,%22lte%22:%22now%22%7D%7D%7D,%7B%22nested%22:%7B%22path%22:%22taxonomy.sections%22,%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22taxonomy.sections._website%22:%22demo%22%7D%7D,%7B%22terms%22:%7B%22taxonomy.sections._id%22:%5B%22/sports%22,%22/news%22%5D%7D%7D%5D%7D%7D%7D%7D%5D,%22must_not%22:%5B%7B%22nested%22:%7B%22path%22:%22taxonomy.sections%22,%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22terms%22:%7B%22taxonomy.sections._id%22:%5B%22/food%22,%22/politics%22%5D%7D%7D%5D%7D%7D%7D%7D%5D%7D%7D%7D&website=demo&size=100&from=0&sort=publish_date:desc&_sourceInclude=canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,content_elements,websites.demo', ) }) it('returns query by author', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Author: 'John Smith', - 'arc-site': 'demo', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Author: 'John Smith', + 'arc-site': 'demo', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/content/v4/search/published?body=%7B%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22type%22:%22story%22%7D%7D,%7B%22range%22:%7B%22last_updated_date%22:%7B%22gte%22:%22now-2d%22,%22lte%22:%22now%22%7D%7D%7D,%7B%22term%22:%7B%22credits.by._id%22:%22John%20Smith%22%7D%7D%5D%7D%7D%7D&website=demo&size=100&from=0&sort=publish_date:desc&_sourceInclude=canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,content_elements,websites.demo', ) }) it('returns query by author with slash', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Author: '/John /Smith/', - 'arc-site': 'demo', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Author: '/John /Smith/', + 'arc-site': 'demo', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/content/v4/search/published?body=%7B%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22type%22:%22story%22%7D%7D,%7B%22range%22:%7B%22last_updated_date%22:%7B%22gte%22:%22now-2d%22,%22lte%22:%22now%22%7D%7D%7D,%7B%22term%22:%7B%22credits.by._id%22:%22John%20Smith%22%7D%7D%5D%7D%7D%7D&website=demo&size=100&from=0&sort=publish_date:desc&_sourceInclude=canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,content_elements,websites.demo', ) }) it('returns query by keywords', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Keywords: 'washington football,sports', - 'arc-site': 'demo', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Keywords: 'washington football,sports', + 'arc-site': 'demo', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/content/v4/search/published?body=%7B%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22type%22:%22story%22%7D%7D,%7B%22range%22:%7B%22last_updated_date%22:%7B%22gte%22:%22now-2d%22,%22lte%22:%22now%22%7D%7D%7D,%7B%22simple_query_string%22:%7B%22query%22:%22%5C%22washington%20football%5C%22%20%7C%20%5C%22sports%5C%22%22,%22fields%22:%5B%22taxonomy.seo_keywords%22%5D%7D%7D%5D%7D%7D%7D&website=demo&size=100&from=0&sort=publish_date:desc&_sourceInclude=canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,content_elements,websites.demo', ) }) it('returns query by tags text', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - 'Tags-Text': 'football,sports', - 'arc-site': 'demo', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + 'Tags-Text': 'football,sports', + 'arc-site': 'demo', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/content/v4/search/published?body=%7B%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22type%22:%22story%22%7D%7D,%7B%22range%22:%7B%22last_updated_date%22:%7B%22gte%22:%22now-2d%22,%22lte%22:%22now%22%7D%7D%7D,%7B%22terms%22:%7B%22taxonomy.tags.text.raw%22:%5B%22football%22,%22sports%22%5D%7D%7D%5D%7D%7D%7D&website=demo&size=100&from=0&sort=publish_date:desc&_sourceInclude=canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,content_elements,websites.demo', ) }) it('returns query by tags slug', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - 'Tags-Slug': '/football,/sports/', - 'arc-site': 'demo', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + 'Tags-Slug': '/football,/sports/', + 'arc-site': 'demo', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/content/v4/search/published?body=%7B%22query%22:%7B%22bool%22:%7B%22must%22:%5B%7B%22term%22:%7B%22type%22:%22story%22%7D%7D,%7B%22range%22:%7B%22last_updated_date%22:%7B%22gte%22:%22now-2d%22,%22lte%22:%22now%22%7D%7D%7D,%7B%22terms%22:%7B%22taxonomy.tags.slug%22:%5B%22football%22,%22sports%22%5D%7D%7D%5D%7D%7D%7D&website=demo&size=100&from=0&sort=publish_date:desc&_sourceInclude=canonical_url,canonical_website,created_date,credits,description,display_date,duration,first_publish_date,headlines,last_updated_date,promo_image,promo_items,publish_date,streams,subheadlines,subtitles,subtype,taxonomy.primary_section,taxonomy.seo_keywords,taxonomy.tags,type,video_type,content_elements,websites.demo', ) }) it('returns query by Include-Terms', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - 'Include-Terms': '[{"term":{"type":"video"}}]', - 'arc-site': 'demo', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + 'Include-Terms': '[{"term":{"type":"video"}}]', + 'arc-site': 'demo', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).not.toContain('%22term%22:%7B%22type%22:%22story%22') expect(callUrl).toContain('%22term%22:%7B%22type%22:%22video%22') }) it('returns query by Exclude-Terms', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - 'arc-site': 'demo', - 'Exclude-Terms': '[{"term":{"subtype":"premium"}}]', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + 'arc-site': 'demo', + 'Exclude-Terms': '[{"term":{"subtype":"premium"}}]', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toContain('%22term%22:%7B%22type%22:%22story%22') expect(callUrl).toContain('%22term%22:%7B%22subtype%22:%22premium%22') }) it('returns query by Exclude-Terms', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - 'Include-Distributor-Name': 'AP', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + 'Include-Distributor-Name': 'AP', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toContain('include_distributor_name=AP') expect(callUrl).not.toContain('exclude_distributor_name=AP') }) it('Sitemap at Root replace the slashes', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Section: 'sports-football,news', - 'arc-site': 'demo', - 'Exclude-Sections': 'ffg-homepage', - 'Sitemap-at-root': 'X', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Section: 'sports-football,news', + 'arc-site': 'demo', + 'Exclude-Sections': 'ffg-homepage', + 'Sitemap-at-root': 'X', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toContain(encodeURI('["/sports/football","/news"]')) expect(callUrl).toContain(encodeURI('["/ffg-homepage"]')) }) diff --git a/blocks/feeds-source-content-api-by-day-block/CHANGELOG.md b/blocks/feeds-source-content-api-by-day-block/CHANGELOG.md index 528ec33a..c3b09f39 100644 --- a/blocks/feeds-source-content-api-by-day-block/CHANGELOG.md +++ b/blocks/feeds-source-content-api-by-day-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/feeds-source-content-api-by-day-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/feeds-source-content-api-by-day-block/package.json b/blocks/feeds-source-content-api-by-day-block/package.json index 0db764eb..3f7e21e2 100644 --- a/blocks/feeds-source-content-api-by-day-block/package.json +++ b/blocks/feeds-source-content-api-by-day-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-source-content-api-by-day-block", - "version": "1.15.0", + "version": "2.0.0", "description": "content source to search by a single day, for sitemap/YYYY-MM-DD", "main": "index.js", "files": [ @@ -23,7 +23,7 @@ }, "dependencies": { "@wpmedia/feeds-content-source-utils": "^1.0.8", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "axios": "^1.6.7", "moment": "^2.29.4" }, diff --git a/blocks/feeds-source-content-api-by-day-block/sources/feeds-content-api-by-day.js b/blocks/feeds-source-content-api-by-day-block/sources/feeds-content-api-by-day.js index 53d0d51a..b15f74f7 100644 --- a/blocks/feeds-source-content-api-by-day-block/sources/feeds-content-api-by-day.js +++ b/blocks/feeds-source-content-api-by-day-block/sources/feeds-content-api-by-day.js @@ -201,7 +201,7 @@ const fetch = async (key, { cachedCall }) => { RESIZER_TOKEN_VERSION, )(result) }) - .then(({data, ...rest}) => ({ ...rest, data: transform(data, key), })) + .then(({ data, ...rest }) => ({ ...rest, data: transform(data, key) })) .then(({ data }) => data) .catch((error) => console.log('== error ==', error)) diff --git a/blocks/feeds-source-content-api-by-day2-block/CHANGELOG.md b/blocks/feeds-source-content-api-by-day2-block/CHANGELOG.md index 0b735f09..516946cd 100644 --- a/blocks/feeds-source-content-api-by-day2-block/CHANGELOG.md +++ b/blocks/feeds-source-content-api-by-day2-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/feeds-source-content-api-by-day2-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/feeds-source-content-api-by-day2-block/package.json b/blocks/feeds-source-content-api-by-day2-block/package.json index 6718c03c..92c4e43c 100644 --- a/blocks/feeds-source-content-api-by-day2-block/package.json +++ b/blocks/feeds-source-content-api-by-day2-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-source-content-api-by-day2-block", - "version": "1.15.0", + "version": "2.0.0", "description": "content source to search by a single day, 1 hour TTL", "main": "index.js", "files": [ @@ -23,7 +23,7 @@ }, "dependencies": { "@wpmedia/feeds-content-source-utils": "^1.0.8", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "axios": "^1.6.7", "moment": "^2.29.4" }, diff --git a/blocks/feeds-source-content-api-by-day2-block/sources/feeds-content-api-by-day2.js b/blocks/feeds-source-content-api-by-day2-block/sources/feeds-content-api-by-day2.js index c54c0697..375142bd 100644 --- a/blocks/feeds-source-content-api-by-day2-block/sources/feeds-content-api-by-day2.js +++ b/blocks/feeds-source-content-api-by-day2-block/sources/feeds-content-api-by-day2.js @@ -201,7 +201,7 @@ const fetch = async (key, { cachedCall }) => { RESIZER_TOKEN_VERSION, )(result) }) - .then(({data, ...rest}) => ({ ...rest, data: transform(data, key), })) + .then(({ data, ...rest }) => ({ ...rest, data: transform(data, key) })) .then(({ data }) => data) .catch((error) => console.log('== error ==', error)) diff --git a/blocks/feeds-source-content-api-by-day3-block/CHANGELOG.md b/blocks/feeds-source-content-api-by-day3-block/CHANGELOG.md index 78c00058..1692e420 100644 --- a/blocks/feeds-source-content-api-by-day3-block/CHANGELOG.md +++ b/blocks/feeds-source-content-api-by-day3-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/feeds-source-content-api-by-day3-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/feeds-source-content-api-by-day3-block/package.json b/blocks/feeds-source-content-api-by-day3-block/package.json index 0f3bcf9a..d22d6422 100644 --- a/blocks/feeds-source-content-api-by-day3-block/package.json +++ b/blocks/feeds-source-content-api-by-day3-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-source-content-api-by-day3-block", - "version": "1.15.0", + "version": "2.0.0", "description": "content source to search by a single day, for sitemap/YYYY-MM-DD with 24 hour (86400) ttl.", "main": "index.js", "files": [ @@ -23,7 +23,7 @@ }, "dependencies": { "@wpmedia/feeds-content-source-utils": "^1.0.8", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "axios": "^1.6.7", "moment": "^2.29.4" }, diff --git a/blocks/feeds-source-content-api-by-day3-block/sources/feeds-content-api-by-day3.js b/blocks/feeds-source-content-api-by-day3-block/sources/feeds-content-api-by-day3.js index 66b382da..344f30d7 100644 --- a/blocks/feeds-source-content-api-by-day3-block/sources/feeds-content-api-by-day3.js +++ b/blocks/feeds-source-content-api-by-day3-block/sources/feeds-content-api-by-day3.js @@ -201,7 +201,7 @@ const fetch = async (key, { cachedCall }) => { RESIZER_TOKEN_VERSION, )(result) }) - .then(({data, ...rest}) => ({ ...rest, data: transform(data, key), })) + .then(({ data, ...rest }) => ({ ...rest, data: transform(data, key) })) .then(({ data }) => data) .catch((error) => console.log('== error ==', error)) diff --git a/blocks/feeds-source-single-content-block/CHANGELOG.md b/blocks/feeds-source-single-content-block/CHANGELOG.md index 2ff297da..b79a37ae 100644 --- a/blocks/feeds-source-single-content-block/CHANGELOG.md +++ b/blocks/feeds-source-single-content-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/feeds-source-single-content-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/feeds-source-single-content-block/package.json b/blocks/feeds-source-single-content-block/package.json index f8e9f003..656203ff 100644 --- a/blocks/feeds-source-single-content-block/package.json +++ b/blocks/feeds-source-single-content-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-source-single-content-block", - "version": "1.15.0", + "version": "2.0.0", "description": "content source to get by _id or website_url", "main": "index.js", "files": [ @@ -26,7 +26,7 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "axios": "^1.6.7" }, "devDependencies": { diff --git a/blocks/feeds-source-single-content-block/sources/single-content.js b/blocks/feeds-source-single-content-block/sources/single-content.js index 302b83b7..da130206 100644 --- a/blocks/feeds-source-single-content-block/sources/single-content.js +++ b/blocks/feeds-source-single-content-block/sources/single-content.js @@ -14,12 +14,13 @@ const params = { website_url: 'text', } +/* eslint-disable dot-notation */ const fetch = (key, { cachedCall }) => { const urlSearch = new URLSearchParams({ ...(key['_id'] ? { _id: key['_id'] } : { website_url: key['website_url'] }), ...(key['arc-site'] ? { website: key['arc-site'] } : {}), }) - + /* eslint-enable dot-notation */ const ret = axios({ url: `${CONTENT_BASE}/content/v4/?${urlSearch.toString()}`, headers: { diff --git a/blocks/feeds-source-video-api-block/CHANGELOG.md b/blocks/feeds-source-video-api-block/CHANGELOG.md index daedc8c2..21f3ca88 100644 --- a/blocks/feeds-source-video-api-block/CHANGELOG.md +++ b/blocks/feeds-source-video-api-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/feeds-source-video-api-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.8.0 ### Minor Changes diff --git a/blocks/feeds-source-video-api-block/package.json b/blocks/feeds-source-video-api-block/package.json index 378f13f6..d7181383 100644 --- a/blocks/feeds-source-video-api-block/package.json +++ b/blocks/feeds-source-video-api-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-source-video-api-block", - "version": "1.8.0", + "version": "2.0.0", "description": "Fusion components for building sitemaps", "main": "index.js", "files": [ @@ -22,7 +22,7 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "axios": "^1.6.7" }, "devDependencies": { diff --git a/blocks/feeds-source-video-api-block/sources/feeds-video-api.js b/blocks/feeds-source-video-api-block/sources/feeds-video-api.js index 5e279110..52c881e0 100644 --- a/blocks/feeds-source-video-api-block/sources/feeds-video-api.js +++ b/blocks/feeds-source-video-api-block/sources/feeds-video-api.js @@ -58,5 +58,5 @@ const fetch = (key, { cachedCall }) => { export default { fetch, schemaName: 'feeds', - params + params, } diff --git a/blocks/feeds-source-video-api-block/sources/feeds-video-api.test.js b/blocks/feeds-source-video-api-block/sources/feeds-video-api.test.js index 7196005c..2e546bdc 100644 --- a/blocks/feeds-source-video-api-block/sources/feeds-video-api.test.js +++ b/blocks/feeds-source-video-api-block/sources/feeds-video-api.test.js @@ -1,30 +1,33 @@ -import axios from 'axios'; +import axios from 'axios' // eslint-disable-next-line no-unused-vars import Consumer from 'fusion:consumer' const source = require('./feeds-video-api') // Mock Axios -jest.mock('axios'); +jest.mock('axios') beforeEach(() => { // Reset Axios mocks before each test - axios.mockClear(); -}); + axios.mockClear() +}) it('validate schemaName', () => { expect(source.default.schemaName).toBe('feeds') }) it('returns query with default values', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Uuids: - 'db9862d6-be50-11e7-9294-705f80164f6e,4594b2c0-6cc1-11e7-abbc-a53480672286', - }, { cachedCall: {} }); - - expect(axios).toHaveBeenCalledTimes(1); + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Uuids: + 'db9862d6-be50-11e7-9294-705f80164f6e,4594b2c0-6cc1-11e7-abbc-a53480672286', + }, + { cachedCall: {} }, + ) + + expect(axios).toHaveBeenCalledTimes(1) expect(axios).toHaveBeenCalledWith({ url: expect.stringContaining(`/api/v1/ansvideos/findByUuids`), // Check base URL method: 'GET', @@ -32,24 +35,27 @@ it('returns query with default values', async () => { 'content-type': 'application/json', Authorization: expect.stringContaining('Bearer '), }), - }); + }) - const callUrl = axios.mock.calls[0][0].url; + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/api/v1/ansvideos/findByUuids?uuids=db9862d6-be50-11e7-9294-705f80164f6e&uuids=4594b2c0-6cc1-11e7-abbc-a53480672286', ) }) it('returns query with default values', async () => { - const mockData = { data: 'response' }; - axios.mockResolvedValue(mockData); - - await source.default.fetch({ - Playlist: 'playlist5', - Count: '10', - }, { cachedCall: {} }); - - const callUrl = axios.mock.calls[0][0].url; + const mockData = { data: 'response' } + axios.mockResolvedValue(mockData) + + await source.default.fetch( + { + Playlist: 'playlist5', + Count: '10', + }, + { cachedCall: {} }, + ) + + const callUrl = axios.mock.calls[0][0].url expect(callUrl).toBe( 'undefined/api/v1/ans/playlists/findByPlaylist?name=playlist5&count=10', ) diff --git a/blocks/json-output-block/output-types/json.js b/blocks/json-output-block/output-types/json.js index f18134ec..515a7c42 100644 --- a/blocks/json-output-block/output-types/json.js +++ b/blocks/json-output-block/output-types/json.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line react/prop-types const Json = ({ children }) => { return Array.isArray(children) ? children[0] : null } diff --git a/blocks/mrss-feature-block/CHANGELOG.md b/blocks/mrss-feature-block/CHANGELOG.md index 6ad5dac0..1c765d51 100644 --- a/blocks/mrss-feature-block/CHANGELOG.md +++ b/blocks/mrss-feature-block/CHANGELOG.md @@ -1,5 +1,18 @@ # @wpmedia/mrss-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-promo-items@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/mrss-feature-block/package.json b/blocks/mrss-feature-block/package.json index 9db6b198..6ae76289 100644 --- a/blocks/mrss-feature-block/package.json +++ b/blocks/mrss-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/mrss-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building rss", "main": "index.js", "files": [ @@ -25,9 +25,9 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-promo-items": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-promo-items": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "jmespath": "^0.15.0", "moment": "^2.29.4" } diff --git a/blocks/rss-alexa-feature-block/CHANGELOG.md b/blocks/rss-alexa-feature-block/CHANGELOG.md index f9f1c386..74e07d85 100644 --- a/blocks/rss-alexa-feature-block/CHANGELOG.md +++ b/blocks/rss-alexa-feature-block/CHANGELOG.md @@ -1,5 +1,18 @@ # @wpmedia/rss-alexa-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-content-elements@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/rss-alexa-feature-block/package.json b/blocks/rss-alexa-feature-block/package.json index 6ca7368f..c3348108 100644 --- a/blocks/rss-alexa-feature-block/package.json +++ b/blocks/rss-alexa-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/rss-alexa-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building rss alexa feed", "main": "index.js", "files": [ @@ -26,9 +26,9 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-content-elements": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-content-elements": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "cheerio": "1.0.0-rc.10", "jmespath": "^0.15.0", "moment": "^2.29.4" diff --git a/blocks/rss-fbia-feature-block/CHANGELOG.md b/blocks/rss-fbia-feature-block/CHANGELOG.md index 39f734ef..770275e5 100644 --- a/blocks/rss-fbia-feature-block/CHANGELOG.md +++ b/blocks/rss-fbia-feature-block/CHANGELOG.md @@ -1,5 +1,19 @@ # @wpmedia/sitemaps-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-content-elements@2.0.0 + - @wpmedia/feeds-promo-items@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/rss-fbia-feature-block/package.json b/blocks/rss-fbia-feature-block/package.json index b4f8bdd4..34fc93fe 100644 --- a/blocks/rss-fbia-feature-block/package.json +++ b/blocks/rss-fbia-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/rss-fbia-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building Facebook Instant Articles", "main": "index.js", "files": [ @@ -27,10 +27,10 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-content-elements": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-promo-items": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-content-elements": "^2.0.0", + "@wpmedia/feeds-promo-items": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "jmespath": "^0.15.0", "moment": "^2.29.4", "xmlbuilder2": "2.1.7" diff --git a/blocks/rss-feature-block/CHANGELOG.md b/blocks/rss-feature-block/CHANGELOG.md index 3989b619..bbc08d55 100644 --- a/blocks/rss-feature-block/CHANGELOG.md +++ b/blocks/rss-feature-block/CHANGELOG.md @@ -1,5 +1,19 @@ # @wpmedia/rss-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-content-elements@2.0.0 + - @wpmedia/feeds-promo-items@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/rss-feature-block/features/rss/xml.js b/blocks/rss-feature-block/features/rss/xml.js index 9cdccef3..49ece922 100644 --- a/blocks/rss-feature-block/features/rss/xml.js +++ b/blocks/rss-feature-block/features/rss/xml.js @@ -1,4 +1,3 @@ -const jmespath = require('jmespath') import moment from 'moment' import URL from 'url' @@ -11,6 +10,7 @@ import { resizerKey } from 'fusion:environment' import Consumer from 'fusion:consumer' import PropTypes from 'fusion:prop-types' import getProperties from 'fusion:properties' +const jmespath = require('jmespath') const rssTemplate = ( elements, diff --git a/blocks/rss-feature-block/package.json b/blocks/rss-feature-block/package.json index f1b600b9..ea33b7b0 100644 --- a/blocks/rss-feature-block/package.json +++ b/blocks/rss-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/rss-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building rss", "main": "index.js", "files": [ @@ -26,10 +26,10 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-content-elements": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-promo-items": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-content-elements": "^2.0.0", + "@wpmedia/feeds-promo-items": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "jmespath": "^0.15.0", "moment": "^2.29.4" } diff --git a/blocks/rss-flipboard-feature-block/CHANGELOG.md b/blocks/rss-flipboard-feature-block/CHANGELOG.md index c97744cd..d080b081 100644 --- a/blocks/rss-flipboard-feature-block/CHANGELOG.md +++ b/blocks/rss-flipboard-feature-block/CHANGELOG.md @@ -1,5 +1,19 @@ # @wpmedia/rss-google-news-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-content-elements@2.0.0 + - @wpmedia/feeds-promo-items@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/rss-flipboard-feature-block/package.json b/blocks/rss-flipboard-feature-block/package.json index a6f14d4f..01f12a24 100644 --- a/blocks/rss-flipboard-feature-block/package.json +++ b/blocks/rss-flipboard-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/rss-flipboard-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building flipboard-rss", "main": "index.js", "files": [ @@ -25,10 +25,10 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-content-elements": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-promo-items": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-content-elements": "^2.0.0", + "@wpmedia/feeds-promo-items": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "jmespath": "^0.15.0", "moment": "^2.29.4" } diff --git a/blocks/rss-google-news-feature-block/CHANGELOG.md b/blocks/rss-google-news-feature-block/CHANGELOG.md index c529db45..da75ca4f 100644 --- a/blocks/rss-google-news-feature-block/CHANGELOG.md +++ b/blocks/rss-google-news-feature-block/CHANGELOG.md @@ -1,5 +1,19 @@ # @wpmedia/rss-google-news-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-content-elements@2.0.0 + - @wpmedia/feeds-promo-items@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/rss-google-news-feature-block/package.json b/blocks/rss-google-news-feature-block/package.json index d6f6b1ca..4249e61f 100644 --- a/blocks/rss-google-news-feature-block/package.json +++ b/blocks/rss-google-news-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/rss-google-news-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building google-news-rss", "main": "index.js", "files": [ @@ -26,10 +26,10 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-content-elements": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-promo-items": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-content-elements": "^2.0.0", + "@wpmedia/feeds-promo-items": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "jmespath": "^0.15.0", "moment": "^2.29.4" } diff --git a/blocks/rss-msn-feature-block/CHANGELOG.md b/blocks/rss-msn-feature-block/CHANGELOG.md index d72fcb83..eefc3cab 100644 --- a/blocks/rss-msn-feature-block/CHANGELOG.md +++ b/blocks/rss-msn-feature-block/CHANGELOG.md @@ -1,5 +1,19 @@ # @wpmedia/rss-msn-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-content-elements@2.0.0 + - @wpmedia/feeds-promo-items@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/rss-msn-feature-block/package.json b/blocks/rss-msn-feature-block/package.json index 4c9ff180..c3430932 100644 --- a/blocks/rss-msn-feature-block/package.json +++ b/blocks/rss-msn-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/rss-msn-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building msn-rss", "main": "index.js", "files": [ @@ -26,10 +26,10 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-content-elements": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-promo-items": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.10 || ^2.0.0", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-content-elements": "^2.0.0", + "@wpmedia/feeds-promo-items": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "jmespath": "^0.15.0", "moment": "^2.29.4" } diff --git a/blocks/sitemap-feature-block/CHANGELOG.md b/blocks/sitemap-feature-block/CHANGELOG.md index 6dd7d004..593fb3c1 100644 --- a/blocks/sitemap-feature-block/CHANGELOG.md +++ b/blocks/sitemap-feature-block/CHANGELOG.md @@ -1,5 +1,17 @@ # @wpmedia/sitemaps-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-promo-items@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/sitemap-feature-block/package.json b/blocks/sitemap-feature-block/package.json index 143b65d7..86ba536f 100644 --- a/blocks/sitemap-feature-block/package.json +++ b/blocks/sitemap-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/sitemap-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building sitemaps", "main": "index.js", "files": [ @@ -25,7 +25,7 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-promo-items": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.8 || ^2.0.0" + "@wpmedia/feeds-promo-items": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0" } } diff --git a/blocks/sitemap-index-by-day-feature-block/CHANGELOG.md b/blocks/sitemap-index-by-day-feature-block/CHANGELOG.md index 7f935960..388bec0e 100644 --- a/blocks/sitemap-index-by-day-feature-block/CHANGELOG.md +++ b/blocks/sitemap-index-by-day-feature-block/CHANGELOG.md @@ -1,5 +1,11 @@ # @wpmedia/sitemap-index-by-day-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + ## 1.15.0 ### Minor Changes diff --git a/blocks/sitemap-index-by-day-feature-block/package.json b/blocks/sitemap-index-by-day-feature-block/package.json index 2355a57f..f07d2520 100644 --- a/blocks/sitemap-index-by-day-feature-block/package.json +++ b/blocks/sitemap-index-by-day-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/sitemap-index-by-day-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion feature for building sitemap-index by day", "main": "index.js", "files": [ diff --git a/blocks/sitemap-index-feature-block/CHANGELOG.md b/blocks/sitemap-index-feature-block/CHANGELOG.md index 7a6b7b7e..f1c20c94 100644 --- a/blocks/sitemap-index-feature-block/CHANGELOG.md +++ b/blocks/sitemap-index-feature-block/CHANGELOG.md @@ -1,5 +1,11 @@ # @wpmedia/sitemap-index-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + ## 1.15.0 ### Minor Changes diff --git a/blocks/sitemap-index-feature-block/package.json b/blocks/sitemap-index-feature-block/package.json index d25e812a..14d4f2aa 100644 --- a/blocks/sitemap-index-feature-block/package.json +++ b/blocks/sitemap-index-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/sitemap-index-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building sitemap-index", "main": "index.js", "files": [ diff --git a/blocks/sitemap-news-feature-block/CHANGELOG.md b/blocks/sitemap-news-feature-block/CHANGELOG.md index 7b744b38..29b12a39 100644 --- a/blocks/sitemap-news-feature-block/CHANGELOG.md +++ b/blocks/sitemap-news-feature-block/CHANGELOG.md @@ -1,5 +1,17 @@ # @wpmedia/sitemaps-news-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-promo-items@2.0.0 + - @wpmedia/feeds-prop-types@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/sitemap-news-feature-block/package.json b/blocks/sitemap-news-feature-block/package.json index efb88d39..04b1a81f 100644 --- a/blocks/sitemap-news-feature-block/package.json +++ b/blocks/sitemap-news-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/sitemap-news-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building news sitemaps", "main": "index.js", "files": [ @@ -26,8 +26,8 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-promo-items": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-prop-types": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-promo-items": "^2.0.0", + "@wpmedia/feeds-prop-types": "^2.0.0", "jmespath": "^0.15.0" } } diff --git a/blocks/sitemap-section-feature-block/CHANGELOG.md b/blocks/sitemap-section-feature-block/CHANGELOG.md index 0de15781..f9f5533c 100644 --- a/blocks/sitemap-section-feature-block/CHANGELOG.md +++ b/blocks/sitemap-section-feature-block/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/sitemap-section-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-prop-types@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/sitemap-section-feature-block/package.json b/blocks/sitemap-section-feature-block/package.json index b05519b0..b8904c3b 100644 --- a/blocks/sitemap-section-feature-block/package.json +++ b/blocks/sitemap-section-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/sitemap-section-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "sitemaps section using Site Service", "main": "index.js", "files": [ @@ -25,6 +25,6 @@ "build": "" }, "dependencies": { - "@wpmedia/feeds-prop-types": "^1.0.8 || ^2.0.0" + "@wpmedia/feeds-prop-types": "^2.0.0" } } diff --git a/blocks/sitemap-section-index-feature-block/CHANGELOG.md b/blocks/sitemap-section-index-feature-block/CHANGELOG.md index 91550bf7..c336de28 100644 --- a/blocks/sitemap-section-index-feature-block/CHANGELOG.md +++ b/blocks/sitemap-section-index-feature-block/CHANGELOG.md @@ -1,5 +1,11 @@ # @wpmedia/sitemap-section-index-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + ## 1.15.0 ### Minor Changes diff --git a/blocks/sitemap-section-index-feature-block/package.json b/blocks/sitemap-section-index-feature-block/package.json index d850a52c..3548837c 100644 --- a/blocks/sitemap-section-index-feature-block/package.json +++ b/blocks/sitemap-section-index-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/sitemap-section-index-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "sitemaps section index using Site Service", "main": "index.js", "files": [ diff --git a/blocks/sitemap-video-feature-block/CHANGELOG.md b/blocks/sitemap-video-feature-block/CHANGELOG.md index 2ab359bc..78404d18 100644 --- a/blocks/sitemap-video-feature-block/CHANGELOG.md +++ b/blocks/sitemap-video-feature-block/CHANGELOG.md @@ -1,5 +1,17 @@ # @wpmedia/sitemap-video-feature-block +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-prop-types@2.0.0 + - @wpmedia/feeds-resizer@2.0.0 + ## 1.15.0 ### Minor Changes diff --git a/blocks/sitemap-video-feature-block/package.json b/blocks/sitemap-video-feature-block/package.json index 1047cb69..5cea2483 100644 --- a/blocks/sitemap-video-feature-block/package.json +++ b/blocks/sitemap-video-feature-block/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/sitemap-video-feature-block", - "version": "1.15.0", + "version": "2.0.0", "description": "Fusion components for building sitemaps", "main": "index.js", "files": [ @@ -29,7 +29,7 @@ "dependencies": { "jmespath": "^0.15.0", "@wpmedia/feeds-find-video-stream": "^1.0.8", - "@wpmedia/feeds-prop-types": "^1.0.8 || ^2.0.0", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0" + "@wpmedia/feeds-prop-types": "^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0" } } diff --git a/jest.config.js b/jest.config.js index 5f2f5d6a..335c31c6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -18,5 +18,5 @@ module.exports = { coverageDirectory: 'coverage', transform: { '^.+\\.jsx?$': 'babel-jest', - } + }, } diff --git a/package.json b/package.json index d51bdbf6..3aec4618 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "lint:prettier": "prettier --check \"./{blocks,utils}/**/*.js\"", "prettier": "prettier --write \"**/*.{js,jsx}\"", "test": "jest --config=jest.config.js", - "ci": "npm run lint && npm run test", + "ci": "npm run lint && npm run build && npm run test", "release:snapshotDev": "changeset version --snapshot canary", "release:develop": "changeset publish --tag canary", "release:snapshotSandbox": "changeset version --snapshot beta", diff --git a/utils/content-elements/CHANGELOG.md b/utils/content-elements/CHANGELOG.md index 1017c3f7..06f2eb11 100644 --- a/utils/content-elements/CHANGELOG.md +++ b/utils/content-elements/CHANGELOG.md @@ -1,5 +1,16 @@ # @wpmedia/feeds-content-elements +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 + ## 1.0.2 ### Patch Changes diff --git a/utils/content-elements/package.json b/utils/content-elements/package.json index f987cf57..3657172c 100644 --- a/utils/content-elements/package.json +++ b/utils/content-elements/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-content-elements", - "version": "1.0.10", + "version": "2.0.0", "description": "Shared arcio content_elements module", "main": "dist/es/index.js", "type": "module", @@ -24,7 +24,7 @@ "license": "CC-BY-NC-ND-4.0", "dependencies": { "@wpmedia/feeds-find-video-stream": "^1.0.8", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "cheerio": "1.0.0-rc.10", "he": "^1.2.0", "jmespath": "^0.15.0", diff --git a/utils/promo-items/CHANGELOG.md b/utils/promo-items/CHANGELOG.md new file mode 100644 index 00000000..ba25ce89 --- /dev/null +++ b/utils/promo-items/CHANGELOG.md @@ -0,0 +1,12 @@ +# @wpmedia/feeds-promo-items + +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + +### Patch Changes + +- Updated dependencies [[`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995)]: + - @wpmedia/feeds-resizer@2.0.0 diff --git a/utils/promo-items/package.json b/utils/promo-items/package.json index 0fc83b3a..64cc9669 100644 --- a/utils/promo-items/package.json +++ b/utils/promo-items/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-promo-items", - "version": "1.0.8", + "version": "2.0.0", "description": "Shared arcio promo_items module", "main": "dist/es/index.js", "type": "module", @@ -24,7 +24,7 @@ "license": "CC-BY-NC-ND-4.0", "dependencies": { "@wpmedia/feeds-find-video-stream": "^1.0.8", - "@wpmedia/feeds-resizer": "^1.0.8 || ^2.0.0", + "@wpmedia/feeds-resizer": "^2.0.0", "jmespath": "^0.15.0" }, "devDependencies": { diff --git a/utils/promo-items/src/promoItems.js b/utils/promo-items/src/promoItems.js index 6e821a7a..f375db92 100644 --- a/utils/promo-items/src/promoItems.js +++ b/utils/promo-items/src/promoItems.js @@ -1,7 +1,6 @@ -const jmespath = require('jmespath') - import { buildResizerURL } from '@wpmedia/feeds-resizer' import { findVideo } from '@wpmedia/feeds-find-video-stream' +const jmespath = require('jmespath') export function BuildPromoItems() { // A constructor to allow prototypal inheritance to override the behavior of member functions diff --git a/utils/prop-types/CHANGELOG.md b/utils/prop-types/CHANGELOG.md index adfc8d83..fb2c3517 100644 --- a/utils/prop-types/CHANGELOG.md +++ b/utils/prop-types/CHANGELOG.md @@ -1,5 +1,11 @@ # @wpmedia/feeds-prop-types +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + ## 1.0.2 ### Patch Changes diff --git a/utils/prop-types/package.json b/utils/prop-types/package.json index 90294fe4..c9ac44be 100644 --- a/utils/prop-types/package.json +++ b/utils/prop-types/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-prop-types", - "version": "1.0.10", + "version": "2.0.0", "description": "Shared fusion prop-type tag info", "main": "dist/es/index.js", "type": "module", diff --git a/utils/resizer/CHANGELOG.md b/utils/resizer/CHANGELOG.md index 52e94c87..0ddeda00 100644 --- a/utils/resizer/CHANGELOG.md +++ b/utils/resizer/CHANGELOG.md @@ -1,5 +1,11 @@ # @wpmedia/feeds-resizer +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + ## 0.3.0 ### Minor Changes diff --git a/utils/resizer/package.json b/utils/resizer/package.json index e677b630..361633c6 100644 --- a/utils/resizer/package.json +++ b/utils/resizer/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-resizer", - "version": "1.0.8", + "version": "2.0.0", "description": "Utilities to manage image resizing", "main": "dist/es/index.js", "type": "module", diff --git a/utils/resizer/src/calculateWidthAndHeight.js b/utils/resizer/src/calculateWidthAndHeight.js index 0e61e49d..da4f2752 100644 --- a/utils/resizer/src/calculateWidthAndHeight.js +++ b/utils/resizer/src/calculateWidthAndHeight.js @@ -1,37 +1,37 @@ const calculateWidthAndHeight = ({ - aspectRatio = '', - width, - height, - ansImage = {}, + aspectRatio = '', + width, + height, + ansImage = {}, }) => { - if (width && height) { - return { width, height } - } + if (width && height) { + return { width, height } + } - const [w, h] = aspectRatio.split(':') - const imageWidth = ansImage?.width || width - const imageHeight = ansImage?.height || height + const [w, h] = aspectRatio.split(':') + const imageWidth = ansImage?.width || width + const imageHeight = ansImage?.height || height - if (aspectRatio && imageWidth) { - const calculatedHeight = (h / w) * imageWidth - return { - width: imageWidth, - height: Math.floor(calculatedHeight), - } - } + if (aspectRatio && imageWidth) { + const calculatedHeight = (h / w) * imageWidth + return { + width: imageWidth, + height: Math.floor(calculatedHeight), + } + } - if (aspectRatio && imageHeight) { - const calculatedWidth = (w / h) * imageHeight - return { - width: Math.floor(calculatedWidth), - height: imageHeight, - } - } + if (aspectRatio && imageHeight) { + const calculatedWidth = (w / h) * imageHeight + return { + width: Math.floor(calculatedWidth), + height: imageHeight, + } + } - return { - width: imageWidth || null, - height: imageHeight || null, - } + return { + width: imageWidth || null, + height: imageHeight || null, + } } export default calculateWidthAndHeight diff --git a/utils/resizer/src/handle-fetch-error/index.js b/utils/resizer/src/handle-fetch-error/index.js index a78ffb0e..6c80f626 100644 --- a/utils/resizer/src/handle-fetch-error/index.js +++ b/utils/resizer/src/handle-fetch-error/index.js @@ -1,22 +1,22 @@ const handleFetchError = (error) => { - if (error.response?.status === 404) { - const NotFoundError = (message = "Not Found") => { - const err = new Error(message); - err.statusCode = 404; - return err; - }; - throw NotFoundError(); - } else if (error?.statusCode === 302 || error.statusCode === 404) { - throw error; - } else if (error?.response) { - throw new Error( - `The response from the server was an error with the status code ${error?.response?.status}.` - ); - } else if (error?.request) { - throw new Error("The request to the server failed with no response."); - } else { - throw new Error("An error occured creating the request."); - } -}; + if (error.response?.status === 404) { + const NotFoundError = (message = 'Not Found') => { + const err = new Error(message) + err.statusCode = 404 + return err + } + throw NotFoundError() + } else if (error?.statusCode === 302 || error.statusCode === 404) { + throw error + } else if (error?.response) { + throw new Error( + `The response from the server was an error with the status code ${error?.response?.status}.`, + ) + } else if (error?.request) { + throw new Error('The request to the server failed with no response.') + } else { + throw new Error('An error occured creating the request.') + } +} -export default handleFetchError; +export default handleFetchError diff --git a/utils/resizer/src/handle-fetch-error/index.test.js b/utils/resizer/src/handle-fetch-error/index.test.js index 384331e3..d50a9232 100644 --- a/utils/resizer/src/handle-fetch-error/index.test.js +++ b/utils/resizer/src/handle-fetch-error/index.test.js @@ -1,45 +1,47 @@ -import handleFetchError from "."; +import handleFetchError from '.' -describe("handleFetchError()", () => { - it("handles 404 errors", () => { - try { - handleFetchError({ response: { status: 404 } }); - } catch (e) { - expect(e.message).toEqual("Not Found"); - } - }); +describe('handleFetchError()', () => { + it('handles 404 errors', () => { + try { + handleFetchError({ response: { status: 404 } }) + } catch (e) { + expect(e.message).toEqual('Not Found') + } + }) - it("handles 302 redirects", () => { - try { - handleFetchError({ location: "test.com", statusCode: 302 }); - } catch (e) { - expect(e).toEqual({ location: "test.com", statusCode: 302 }); - } - }); + it('handles 302 redirects', () => { + try { + handleFetchError({ location: 'test.com', statusCode: 302 }) + } catch (e) { + expect(e).toEqual({ location: 'test.com', statusCode: 302 }) + } + }) - it("handles errors with the response", () => { - try { - handleFetchError({ response: { status: "400" } }); - } catch (e) { - expect(e.message).toEqual( - "The response from the server was an error with the status code 400." - ); - } - }); + it('handles errors with the response', () => { + try { + handleFetchError({ response: { status: '400' } }) + } catch (e) { + expect(e.message).toEqual( + 'The response from the server was an error with the status code 400.', + ) + } + }) - it("handles errors with the request", () => { - try { - handleFetchError({ request: {} }); - } catch (e) { - expect(e.message).toEqual("The request to the server failed with no response."); - } - }); + it('handles errors with the request', () => { + try { + handleFetchError({ request: {} }) + } catch (e) { + expect(e.message).toEqual( + 'The request to the server failed with no response.', + ) + } + }) - it("handles errors creating the request", () => { - try { - handleFetchError({}); - } catch (e) { - expect(e.message).toEqual("An error occured creating the request."); - } - }); -}); + it('handles errors creating the request', () => { + try { + handleFetchError({}) + } catch (e) { + expect(e.message).toEqual('An error occured creating the request.') + } + }) +}) diff --git a/utils/resizer/src/image-ans-to-image-src/index.js b/utils/resizer/src/image-ans-to-image-src/index.js index 978bf6aa..62f026c3 100644 --- a/utils/resizer/src/image-ans-to-image-src/index.js +++ b/utils/resizer/src/image-ans-to-image-src/index.js @@ -6,20 +6,20 @@ * @return an image string to be used in the src of a image tag */ const imageANSToImageSrc = (data) => { - const { _id: id, auth, url } = data || {}; - if (url) { - if (id) { - const fileExtension = url.match(/\.\w{3,4}$/); - if (fileExtension) { - return `${id}${fileExtension[0]}`; - } - // Return the id as a string if no file extension is found. - return `${id}` - } else if (auth) { - return encodeURIComponent(url); - } - } - return null; -}; + const { _id: id, auth, url } = data || {} + if (url) { + if (id) { + const fileExtension = url.match(/\.\w{3,4}$/) + if (fileExtension) { + return `${id}${fileExtension[0]}` + } + // Return the id as a string if no file extension is found. + return `${id}` + } else if (auth) { + return encodeURIComponent(url) + } + } + return null +} -export default imageANSToImageSrc; +export default imageANSToImageSrc diff --git a/utils/resizer/src/image-ans-to-image-src/index.test.js b/utils/resizer/src/image-ans-to-image-src/index.test.js index 31a750bc..5443206a 100644 --- a/utils/resizer/src/image-ans-to-image-src/index.test.js +++ b/utils/resizer/src/image-ans-to-image-src/index.test.js @@ -1,25 +1,36 @@ -import imageANSToImageSrc from "."; +import imageANSToImageSrc from '.' -describe("imageANSToImageSrc", () => { - it("return image src with ext", () => { - expect(imageANSToImageSrc({ _id: 123, url: "http://image.com/test.jpg" })).toBe("123.jpg"); - expect(imageANSToImageSrc({ _id: 123, url: "http://image.com/test.test.jpg" })).toBe("123.jpg"); - expect(imageANSToImageSrc({ _id: 321, url: "http://image.com/test.test.jpeg" })).toBe("321.jpeg"); - }); +describe('imageANSToImageSrc', () => { + it('return image src with ext', () => { + expect( + imageANSToImageSrc({ _id: 123, url: 'http://image.com/test.jpg' }), + ).toBe('123.jpg') + expect( + imageANSToImageSrc({ _id: 123, url: 'http://image.com/test.test.jpg' }), + ).toBe('123.jpg') + expect( + imageANSToImageSrc({ _id: 321, url: 'http://image.com/test.test.jpeg' }), + ).toBe('321.jpeg') + }) - it("return image src without ext", () => { - expect(imageANSToImageSrc({ _id: 123, url: "http://image.com/123" })).toBe("123"); - }); + it('return image src without ext', () => { + expect(imageANSToImageSrc({ _id: 123, url: 'http://image.com/123' })).toBe( + '123', + ) + }) - it("return image src as encoded url when no _id but an auth exists", () => { - expect(imageANSToImageSrc({ url: "http://image.com/test.jpg", auth: { 1: "123" } })).toBe( - encodeURIComponent("http://image.com/test.jpg") - ); - }); + it('return image src as encoded url when no _id but an auth exists', () => { + expect( + imageANSToImageSrc({ + url: 'http://image.com/test.jpg', + auth: { 1: '123' }, + }), + ).toBe(encodeURIComponent('http://image.com/test.jpg')) + }) - it("will return null if incorrect ANS data", () => { - expect(imageANSToImageSrc({ _id: 123 })).toBe(null); - expect(imageANSToImageSrc({ url: "testjpg" })).toBe(null); - expect(imageANSToImageSrc()).toBe(null); - }); -}); + it('will return null if incorrect ANS data', () => { + expect(imageANSToImageSrc({ _id: 123 })).toBe(null) + expect(imageANSToImageSrc({ url: 'testjpg' })).toBe(null) + expect(imageANSToImageSrc()).toBe(null) + }) +}) diff --git a/utils/resizer/src/index.test.js b/utils/resizer/src/index.test.js index 21c71fc1..ba27419f 100644 --- a/utils/resizer/src/index.test.js +++ b/utils/resizer/src/index.test.js @@ -1,76 +1,79 @@ jest.mock('fusion:environment', () => ({ - RESIZER_TOKEN_VERSION: 1, -})); + RESIZER_TOKEN_VERSION: 1, +})) // eslint-disable-next-line import/first -import { buildResizerURL } from '.'; // Adjust the path as necessary - +import { buildResizerURL } from '.' // Adjust the path as necessary describe('buildResizerURL', () => { - beforeEach(() => { - // Reset mocks - jest.resetModules(); - jest.clearAllMocks(); - - // Mock 'thumbor-lite' for each test to ensure a fresh mock - jest.mock('thumbor-lite', () => { - return function () { - return { - setImagePath: jest.fn().mockReturnThis(), - resize: jest.fn().mockReturnThis(), - buildUrl: jest.fn().mockReturnValue('http://resizer.url/resized-image.jpg'), - }; - }; - }); - jest.mock('./calculateWidthAndHeight', () => ({ - __esModule: true, // This is required to mock a module that has a default export - default: jest.fn(), - })); - - }); + beforeEach(() => { + // Reset mocks + jest.resetModules() + jest.clearAllMocks() + + // Mock 'thumbor-lite' for each test to ensure a fresh mock + jest.mock('thumbor-lite', () => { + return function () { + return { + setImagePath: jest.fn().mockReturnThis(), + resize: jest.fn().mockReturnThis(), + buildUrl: jest + .fn() + .mockReturnValue('http://resizer.url/resized-image.jpg'), + } + } + }) + jest.mock('./calculateWidthAndHeight', () => ({ + __esModule: true, // This is required to mock a module that has a default export + default: jest.fn(), + })) + }) + + it('formats URL correctly for ANS image with auth token', () => { + const ansImage = { + auth: { 1: 'someAuthToken' }, + } + + require('./calculateWidthAndHeight').default.mockReturnValue({ + width: 100, + height: 100, + }) - it('formats URL correctly for ANS image with auth token', () => { - const ansImage = { - auth: { 1: 'someAuthToken' }, - }; + const result = buildResizerURL( + 'http://example.com/image.jpg', + 'dummyResizerKey', + 'http://resizer.url', + 100, + 100, + ansImage, + ) - require('./calculateWidthAndHeight').default.mockReturnValue({ width: 100, height: 100 }); + expect(result).toContain('http://resizer.url/') + expect(result).toContain('width=100') + expect(result).toContain('height=100') + expect(result).toContain('auth=someAuthToken') + expect(result).toContain('smart=true') + }) - const result = buildResizerURL( - 'http://example.com/image.jpg', - 'dummyResizerKey', - 'http://resizer.url', - 100, - 100, - ansImage - ); + it('uses Thumbor for resizing', () => { + const originalUrl = 'http://example.com/image.jpg' + const resizerKey = 'dummyResizerKey' + const resizerURL = 'http://resizer.url' - expect(result).toContain('http://resizer.url/'); - expect(result).toContain('width=100'); - expect(result).toContain('height=100'); - expect(result).toContain('auth=someAuthToken'); - expect(result).toContain('smart=true'); - }); + const result = buildResizerURL( + originalUrl, + resizerKey, + resizerURL, + 100, + 100, + ) - it('uses Thumbor for resizing', () => { - const originalUrl = 'http://example.com/image.jpg'; - const resizerKey = 'dummyResizerKey'; - const resizerURL = 'http://resizer.url'; + expect(result).toEqual('http://resizer.url/resized-image.jpg') + }) - const result = buildResizerURL( - originalUrl, - resizerKey, - resizerURL, - 100, - 100 - ); - - expect(result).toEqual('http://resizer.url/resized-image.jpg'); - }); + it('returns the original URL if no resizing is needed and no auth token is present', () => { + const originalUrl = 'http://example.com/image.jpg' + const result = buildResizerURL(originalUrl, '', '', 0, 0) - it('returns the original URL if no resizing is needed and no auth token is present', () => { - const originalUrl = 'http://example.com/image.jpg'; - const result = buildResizerURL(originalUrl, '', '', 0, 0); - - expect(result).toEqual(originalUrl); - }); -}); + expect(result).toEqual(originalUrl) + }) +}) diff --git a/utils/resizer/src/sign-images-in-ans-object/index.js b/utils/resizer/src/sign-images-in-ans-object/index.js index 03289f96..3520621b 100644 --- a/utils/resizer/src/sign-images-in-ans-object/index.js +++ b/utils/resizer/src/sign-images-in-ans-object/index.js @@ -1,45 +1,45 @@ const signImagesInANSObject = - (cachedCall, fetcher, resizerAppVersion, cacheKey = "image-token") => - ({ data, ...rest }) => { - const replacements = new Set(); + (cachedCall, fetcher, resizerAppVersion, cacheKey = 'image-token') => + ({ data, ...rest }) => { + const replacements = new Set() - const stringData = JSON.stringify(data, (key, value) => { - if (value === null || typeof value === "undefined") { - return value; - } - const { _id, type, auth, url } = value; - if (!auth?.[resizerAppVersion] && type === "image") { - replacements.add(_id || url); - return { - ...value, - auth: { - ...value.auth, - [resizerAppVersion]: `__replaceMe${_id || url}__`, - }, - }; - } - return value; - }); + const stringData = JSON.stringify(data, (key, value) => { + if (value === null || typeof value === 'undefined') { + return value + } + const { _id, type, auth, url } = value + if (!auth?.[resizerAppVersion] && type === 'image') { + replacements.add(_id || url) + return { + ...value, + auth: { + ...value.auth, + [resizerAppVersion]: `__replaceMe${_id || url}__`, + }, + } + } + return value + }) - return Promise.all( - Array.from(replacements).map((id) => - cachedCall(`${cacheKey}-${id}`, fetcher, { - query: { id }, - ttl: 31536000, - independent: true, - }).then((auth) => ({ id, auth })) - ) - ).then((authResults) => { - const replaced = authResults.reduce( - (accumulator, { id, auth }) => - accumulator.replace(new RegExp(`__replaceMe${id}__`, "g"), auth.hash), - stringData - ); - return { - data: JSON.parse(replaced), - ...rest, - }; - }); - }; + return Promise.all( + Array.from(replacements).map((id) => + cachedCall(`${cacheKey}-${id}`, fetcher, { + query: { id }, + ttl: 31536000, + independent: true, + }).then((auth) => ({ id, auth })), + ), + ).then((authResults) => { + const replaced = authResults.reduce( + (accumulator, { id, auth }) => + accumulator.replace(new RegExp(`__replaceMe${id}__`, 'g'), auth.hash), + stringData, + ) + return { + data: JSON.parse(replaced), + ...rest, + } + }) + } -export default signImagesInANSObject; +export default signImagesInANSObject diff --git a/utils/resizer/src/sign-images-in-ans-object/index.test.js b/utils/resizer/src/sign-images-in-ans-object/index.test.js index 1efa22e9..601ab98e 100644 --- a/utils/resizer/src/sign-images-in-ans-object/index.test.js +++ b/utils/resizer/src/sign-images-in-ans-object/index.test.js @@ -1,162 +1,162 @@ -import signImagesInANSObject from "."; +import signImagesInANSObject from '.' const data = { - _id: "43UU6MCQERAMRPTD23B3CEXE7E", - type: "story", - undefinedValue: undefined, - content_elements: [ - { - _id: "LJJSIEXMZ5FTDBP7PFHXI5A4XY", - type: "image", // should fill auth - }, - { - _id: "LJJSIEXMZ5FTDBP7PFHXI5A4XY", - type: "image", // should fill with first items auth - }, - { - _id: "LJJSIEXMZ5FTDBP7PFHXI5A4XZ", - type: "image", - auth: { - 1: "40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6c1", - }, // should get 2 - }, - { - _id: "LJJSIEXMZ5FTDBP7PFHXI5A4X2", - type: "image", - auth: { - 2: "40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6c2", - }, // should skip - }, - ], - promo_items: { - basic: { - _id: "OYRQQIJJLNBVNN4QLERLG2FZZ4", - type: "image", // should fill auth - }, - }, -}; + _id: '43UU6MCQERAMRPTD23B3CEXE7E', + type: 'story', + undefinedValue: undefined, + content_elements: [ + { + _id: 'LJJSIEXMZ5FTDBP7PFHXI5A4XY', + type: 'image', // should fill auth + }, + { + _id: 'LJJSIEXMZ5FTDBP7PFHXI5A4XY', + type: 'image', // should fill with first items auth + }, + { + _id: 'LJJSIEXMZ5FTDBP7PFHXI5A4XZ', + type: 'image', + auth: { + 1: '40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6c1', + }, // should get 2 + }, + { + _id: 'LJJSIEXMZ5FTDBP7PFHXI5A4X2', + type: 'image', + auth: { + 2: '40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6c2', + }, // should skip + }, + ], + promo_items: { + basic: { + _id: 'OYRQQIJJLNBVNN4QLERLG2FZZ4', + type: 'image', // should fill auth + }, + }, +} const noIDImageData = { - _id: "43UU6MCQERAMRPTD23B3CEXE7E", - type: "story", - promo_items: { - lead_art: { - embed_html: "", - promo_items: { - basic: { - type: "image", - url: "https://test.img/filename.jpg", - }, - }, - type: "video", - }, - }, -}; + _id: '43UU6MCQERAMRPTD23B3CEXE7E', + type: 'story', + promo_items: { + lead_art: { + embed_html: '', + promo_items: { + basic: { + type: 'image', + url: 'https://test.img/filename.jpg', + }, + }, + type: 'video', + }, + }, +} const idAuthMap = { - LJJSIEXMZ5FTDBP7PFHXI5A4XY: { - hash: "40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cy", - }, - LJJSIEXMZ5FTDBP7PFHXI5A4XZ: { - hash: "40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cz", - }, - LJJSIEXMZ5FTDBP7PFHXI5A4X2: { - hash: "40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6c2", - }, - OYRQQIJJLNBVNN4QLERLG2FZZ4: { - hash: "545c018dbf2bbc8e4488c7546167e6afacc259cf4fe0b2f28c8043990f689e40", - }, - "https://test.img/filename.jpg": { - hash: "545c018dbf2bbc8e4488c7546167e6afacc259cf4fe0b2f28c8043990f689e41", - }, -}; + LJJSIEXMZ5FTDBP7PFHXI5A4XY: { + hash: '40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cy', + }, + LJJSIEXMZ5FTDBP7PFHXI5A4XZ: { + hash: '40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cz', + }, + LJJSIEXMZ5FTDBP7PFHXI5A4X2: { + hash: '40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6c2', + }, + OYRQQIJJLNBVNN4QLERLG2FZZ4: { + hash: '545c018dbf2bbc8e4488c7546167e6afacc259cf4fe0b2f28c8043990f689e40', + }, + 'https://test.img/filename.jpg': { + hash: '545c018dbf2bbc8e4488c7546167e6afacc259cf4fe0b2f28c8043990f689e41', + }, +} -const fetcher = jest.fn((id) => idAuthMap[id]); +const fetcher = jest.fn((id) => idAuthMap[id]) const cachedCall = jest.fn((cacheId, fetchMethod, options) => - Promise.resolve(fetchMethod(options.query.id)) -); + Promise.resolve(fetchMethod(options.query.id)), +) -describe("Sign Images In ANS Object", () => { - beforeEach(() => { - cachedCall.mockClear(); - }); +describe('Sign Images In ANS Object', () => { + beforeEach(() => { + cachedCall.mockClear() + }) - it("returns the correct auth key values in the returned ans object", async () => { - const signIt = signImagesInANSObject(cachedCall, fetcher, 2); + it('returns the correct auth key values in the returned ans object', async () => { + const signIt = signImagesInANSObject(cachedCall, fetcher, 2) - const { data: signedData, status } = await signIt({ data, status: 2 }); + const { data: signedData, status } = await signIt({ data, status: 2 }) - expect(status).toBe(2); - expect(cachedCall).toHaveBeenCalledWith( - "image-token-LJJSIEXMZ5FTDBP7PFHXI5A4XY", - fetcher, - expect.objectContaining({ - query: { id: "LJJSIEXMZ5FTDBP7PFHXI5A4XY" }, - ttl: 31536000, - independent: true, - }) - ); - expect(cachedCall).toHaveBeenCalledWith( - "image-token-LJJSIEXMZ5FTDBP7PFHXI5A4XZ", - fetcher, - expect.objectContaining({ - query: { id: "LJJSIEXMZ5FTDBP7PFHXI5A4XZ" }, - ttl: 31536000, - independent: true, - }) - ); - expect(cachedCall).toHaveBeenCalledWith( - "image-token-OYRQQIJJLNBVNN4QLERLG2FZZ4", - fetcher, - expect.objectContaining({ - query: { id: "OYRQQIJJLNBVNN4QLERLG2FZZ4" }, - ttl: 31536000, - independent: true, - }) - ); - expect(cachedCall).not.toHaveBeenCalledWith( - "image-token-LJJSIEXMZ5FTDBP7PFHXI5A4X2", - fetcher, - expect.objectContaining({ - query: { id: "LJJSIEXMZ5FTDBP7PFHXI5A4X2" }, - ttl: 31536000, - independent: true, - }) - ); - expect(cachedCall).toHaveBeenCalledTimes(3); - expect(signedData.promo_items.basic.auth[2]).toBe( - "545c018dbf2bbc8e4488c7546167e6afacc259cf4fe0b2f28c8043990f689e40" - ); - expect(signedData.content_elements[0].auth[2]).toBe( - "40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cy" - ); - expect(signedData.content_elements[1].auth[2]).toBe( - "40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cy" - ); - expect(signedData.content_elements[2].auth[2]).toBe( - "40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cz" - ); - }); + expect(status).toBe(2) + expect(cachedCall).toHaveBeenCalledWith( + 'image-token-LJJSIEXMZ5FTDBP7PFHXI5A4XY', + fetcher, + expect.objectContaining({ + query: { id: 'LJJSIEXMZ5FTDBP7PFHXI5A4XY' }, + ttl: 31536000, + independent: true, + }), + ) + expect(cachedCall).toHaveBeenCalledWith( + 'image-token-LJJSIEXMZ5FTDBP7PFHXI5A4XZ', + fetcher, + expect.objectContaining({ + query: { id: 'LJJSIEXMZ5FTDBP7PFHXI5A4XZ' }, + ttl: 31536000, + independent: true, + }), + ) + expect(cachedCall).toHaveBeenCalledWith( + 'image-token-OYRQQIJJLNBVNN4QLERLG2FZZ4', + fetcher, + expect.objectContaining({ + query: { id: 'OYRQQIJJLNBVNN4QLERLG2FZZ4' }, + ttl: 31536000, + independent: true, + }), + ) + expect(cachedCall).not.toHaveBeenCalledWith( + 'image-token-LJJSIEXMZ5FTDBP7PFHXI5A4X2', + fetcher, + expect.objectContaining({ + query: { id: 'LJJSIEXMZ5FTDBP7PFHXI5A4X2' }, + ttl: 31536000, + independent: true, + }), + ) + expect(cachedCall).toHaveBeenCalledTimes(3) + expect(signedData.promo_items.basic.auth[2]).toBe( + '545c018dbf2bbc8e4488c7546167e6afacc259cf4fe0b2f28c8043990f689e40', + ) + expect(signedData.content_elements[0].auth[2]).toBe( + '40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cy', + ) + expect(signedData.content_elements[1].auth[2]).toBe( + '40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cy', + ) + expect(signedData.content_elements[2].auth[2]).toBe( + '40b3b900866998ec98c4a286eef727080a10ac968d5eed7bd4a6a084511db6cz', + ) + }) - it("returns the correct auth key for a non-id image (third party url)", async () => { - const signIt = signImagesInANSObject(cachedCall, fetcher, 2); + it('returns the correct auth key for a non-id image (third party url)', async () => { + const signIt = signImagesInANSObject(cachedCall, fetcher, 2) - const { data: signedData } = await signIt({ data: noIDImageData }); + const { data: signedData } = await signIt({ data: noIDImageData }) - expect(cachedCall).toHaveBeenCalledWith( - "image-token-https://test.img/filename.jpg", - fetcher, - expect.objectContaining({ - query: { id: "https://test.img/filename.jpg" }, - ttl: 31536000, - independent: true, - }) - ); + expect(cachedCall).toHaveBeenCalledWith( + 'image-token-https://test.img/filename.jpg', + fetcher, + expect.objectContaining({ + query: { id: 'https://test.img/filename.jpg' }, + ttl: 31536000, + independent: true, + }), + ) - expect(cachedCall).toHaveBeenCalledTimes(1); + expect(cachedCall).toHaveBeenCalledTimes(1) - expect(signedData.promo_items.lead_art.promo_items.basic.auth[2]).toBe( - "545c018dbf2bbc8e4488c7546167e6afacc259cf4fe0b2f28c8043990f689e41" - ); - }); -}); + expect(signedData.promo_items.lead_art.promo_items.basic.auth[2]).toBe( + '545c018dbf2bbc8e4488c7546167e6afacc259cf4fe0b2f28c8043990f689e41', + ) + }) +}) diff --git a/utils/resizer/src/signing-service/index.js b/utils/resizer/src/signing-service/index.js index 5db70aa0..a20439c3 100644 --- a/utils/resizer/src/signing-service/index.js +++ b/utils/resizer/src/signing-service/index.js @@ -1,42 +1,42 @@ import axios from 'axios' import { - ARC_ACCESS_TOKEN, - CONTENT_BASE, - SIGNING_SERVICE_DEFAULT_APP, - RESIZER_TOKEN_VERSION, + ARC_ACCESS_TOKEN, + CONTENT_BASE, + SIGNING_SERVICE_DEFAULT_APP, + RESIZER_TOKEN_VERSION, } from 'fusion:environment' import handleFetchError from '../handle-fetch-error/index.js' const params = { - id: 'text', - service: 'text', - serviceVersion: 'text', + id: 'text', + service: 'text', + serviceVersion: 'text', } export const fetch = ({ - id, - service = SIGNING_SERVICE_DEFAULT_APP, - serviceVersion = RESIZER_TOKEN_VERSION, + id, + service = SIGNING_SERVICE_DEFAULT_APP, + serviceVersion = RESIZER_TOKEN_VERSION, }) => { - const urlSearch = new URLSearchParams({ - value: id, - }) - return axios({ - url: `${CONTENT_BASE}/signing-service/v2/sign/${service}/${serviceVersion}?${urlSearch.toString()}`, - headers: { - 'content-type': 'application/json', - Authorization: `Bearer ${ARC_ACCESS_TOKEN}`, - }, - method: 'GET', - }) - .then(({ data: content }) => content) - .catch(handleFetchError) + const urlSearch = new URLSearchParams({ + value: id, + }) + return axios({ + url: `${CONTENT_BASE}/signing-service/v2/sign/${service}/${serviceVersion}?${urlSearch.toString()}`, + headers: { + 'content-type': 'application/json', + Authorization: `Bearer ${ARC_ACCESS_TOKEN}`, + }, + method: 'GET', + }) + .then(({ data: content }) => content) + .catch(handleFetchError) } export default { - fetch, - params, - http: false, - // 365 day ttl - ttl: 31536000, + fetch, + params, + http: false, + // 365 day ttl + ttl: 31536000, } diff --git a/utils/resizer/src/signing-service/index.test.js b/utils/resizer/src/signing-service/index.test.js index f724544f..026e7d19 100644 --- a/utils/resizer/src/signing-service/index.test.js +++ b/utils/resizer/src/signing-service/index.test.js @@ -1,25 +1,25 @@ -import contentSource from "."; +import contentSource from '.' -jest.mock("fusion:environment", () => ({ - CONTENT_BASE: "", - SIGNING_SERVICE_DEFAULT_APP: "resizer", - RESIZER_TOKEN_VERSION: 1, -})); +jest.mock('fusion:environment', () => ({ + CONTENT_BASE: '', + SIGNING_SERVICE_DEFAULT_APP: 'resizer', + RESIZER_TOKEN_VERSION: 1, +})) -jest.mock("axios", () => ({ - __esModule: true, - default: jest.fn((data) => Promise.resolve({ data })), -})); +jest.mock('axios', () => ({ + __esModule: true, + default: jest.fn((data) => Promise.resolve({ data })), +})) -describe("Test Signing Service content source", () => { - it("should build the correct url", async () => { - const key = { - id: "test://id", - }; - const contentSourceRequest = await contentSource.fetch(key); +describe('Test Signing Service content source', () => { + it('should build the correct url', async () => { + const key = { + id: 'test://id', + } + const contentSourceRequest = await contentSource.fetch(key) - expect(contentSourceRequest.url).toEqual( - `/signing-service/v2/sign/resizer/1?value=test%3A%2F%2Fid` - ); - }); -}); + expect(contentSourceRequest.url).toEqual( + `/signing-service/v2/sign/resizer/1?value=test%3A%2F%2Fid`, + ) + }) +}) diff --git a/utils/xml-output/CHANGELOG.md b/utils/xml-output/CHANGELOG.md index d25706fe..90faef71 100644 --- a/utils/xml-output/CHANGELOG.md +++ b/utils/xml-output/CHANGELOG.md @@ -1,5 +1,11 @@ # @wpmedia/feeds-xml-output +## 2.0.0 + +### Major Changes + +- [#665](https://github.com/WPMedia/feed-components/pull/665) [`c39ce40`](https://github.com/WPMedia/feed-components/commit/c39ce40bc95a95755bff01b4616a170e69572995) Thanks [@nschubach](https://github.com/nschubach)! - Adds resizer v2 support. + ## 1.1.0 ### Minor Changes diff --git a/utils/xml-output/package.json b/utils/xml-output/package.json index 102abe4a..2d7866f2 100644 --- a/utils/xml-output/package.json +++ b/utils/xml-output/package.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/feeds-xml-output", - "version": "1.1.0", + "version": "2.0.0", "description": "For use in creating an XML output type", "main": "dist/es/index.js", "type": "module", diff --git a/utils/xml-output/src/index.js b/utils/xml-output/src/index.js index bfc29700..8013f9af 100644 --- a/utils/xml-output/src/index.js +++ b/utils/xml-output/src/index.js @@ -1,5 +1,6 @@ import { create } from 'xmlbuilder2' +// eslint-disable-next-line react/prop-types export const XmlOutput = ({ children }) => { return children ? create({ invalidCharReplacement: '' }, children[0]) diff --git a/utils/xml-output/src/xmlOutput.test.js b/utils/xml-output/src/xmlOutput.test.js index bdaeb6c4..10ef9db2 100644 --- a/utils/xml-output/src/xmlOutput.test.js +++ b/utils/xml-output/src/xmlOutput.test.js @@ -1,8 +1,8 @@ import { XmlOutput } from './index' -const { JSDOM } = require('jsdom'); +const { JSDOM } = require('jsdom') -const dom = new JSDOM(); -global.DOMParser = dom.window.DOMParser; +const dom = new JSDOM() +global.DOMParser = dom.window.DOMParser const exampleData = [ {