diff --git a/data/entities.js b/data/entities.js index a9a3669..cb39343 100644 --- a/data/entities.js +++ b/data/entities.js @@ -1343,6 +1343,7 @@ module.exports = [ }, { name: 'SpeedCurve LUX', + company: 'SpeedCurve', homepage: 'https://speedcurve.com/features/lux/', categories: ['analytics'], domains: ['*.speedcurve.com'], diff --git a/lib/create-entity-finder-api.js b/lib/create-entity-finder-api.js index e266c01..bf09ae8 100644 --- a/lib/create-entity-finder-api.js +++ b/lib/create-entity-finder-api.js @@ -44,16 +44,25 @@ function getProductInDataset(entityByDomain, entityByRootDomain, originOrURL) { } function cloneEntities(entities) { - return entities.map(entity => ({ - ...entity, - products: (entity.products || []).map(product => ({ + return entities.map(entity_ => { + const entity = { + company: entity_.name, + ...entity_, + } + + const products = (entity_.products || []).map(product => ({ + company: entity.company, + categories: entity.categories, facades: [], ...product, - urlPatterns: product.urlPatterns.map(s => + urlPatterns: (product.urlPatterns || []).map(s => s.startsWith('REGEXP:') ? new RegExp(s.slice('REGEXP:'.length)) : s ), - })), - })) + })) + + entity.products = products + return entity + }) } function createAPIFromDataset(entities_) { @@ -62,7 +71,6 @@ function createAPIFromDataset(entities_) { const entityByRootDomain = new Map() for (const entity of entities) { - if (!entity.company) entity.company = entity.name entity.totalExecutionTime = Number(entity.totalExecutionTime) || 0 entity.totalOccurrences = Number(entity.totalOccurrences) || 0 entity.averageExecutionTime = entity.totalExecutionTime / entity.totalOccurrences diff --git a/lib/index.d.ts b/lib/index.d.ts index 633a18d..10e7d2a 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -5,7 +5,10 @@ export interface IFacade { export interface IProduct { name: string - urlPatterns: string[] + company: string + homepage?: string + categories: string[] + urlPatterns?: string[] facades?: IFacade[] } diff --git a/lib/index.test.js b/lib/index.test.js index e8399c0..f7f350b 100644 --- a/lib/index.test.js +++ b/lib/index.test.js @@ -85,6 +85,10 @@ describe('getEntity', () => { "name": "Facebook", "products": Array [ Object { + "categories": Array [ + "social", + ], + "company": "Facebook", "facades": Array [ Object { "name": "React Live Chat Loader", @@ -152,6 +156,8 @@ describe('getProduct', () => { it('works on basic url', () => { expect(getProduct('https://www.youtube.com/embed/alGcULGtiv8')).toMatchObject({ name: 'YouTube Embedded Player', + company: 'YouTube', + categories: ['video'], facades: [ { name: 'Lite YouTube',