From 5e70312d67babc7b443064c771de4118cb6dd4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20N=C3=A4sman?= Date: Fri, 26 Feb 2021 15:17:37 +0100 Subject: [PATCH] unwind dependencies Signed-off-by: Eric Peterson --- packages/search-common/package.json | 11 +---- packages/search-common/src/types.ts | 47 +++++++++++++++++- plugins/catalog-backend/package.json | 1 + .../catalog-backend/src/search/Collator.ts | 2 +- plugins/search-backend/package.json | 6 +-- plugins/search-backend/src/service/router.ts | 2 +- plugins/search-indexer-backend/package.json | 3 +- plugins/search-indexer-backend/src/index.ts | 6 --- .../search-indexer-backend/src/registry.ts | 2 + plugins/search-indexer-backend/src/types.ts | 49 ++----------------- 10 files changed, 59 insertions(+), 70 deletions(-) diff --git a/packages/search-common/package.json b/packages/search-common/package.json index 6336a13449..18e3557a49 100644 --- a/packages/search-common/package.json +++ b/packages/search-common/package.json @@ -36,17 +36,10 @@ "url": "https://github.com/backstage/backstage/issues" }, "dependencies": { - "@backstage/config": "^0.1.3", - "@backstage/plugin-search-indexer-backend": "^0.1.1" + "@backstage/config": "^0.1.3" }, "devDependencies": { - "@backstage/cli": "^0.6.2", - "@types/fs-extra": "^9.0.5", - "@types/git-url-parse": "^9.0.0", - "@types/js-yaml": "^3.12.5", - "@types/mime-types": "^2.1.0", - "@types/mock-fs": "^4.13.0", - "@types/recursive-readdir": "^2.2.0" + "@backstage/cli": "^0.6.2" }, "jest": { "roots": [ diff --git a/packages/search-common/src/types.ts b/packages/search-common/src/types.ts index 1a05e85f69..3a47187945 100644 --- a/packages/search-common/src/types.ts +++ b/packages/search-common/src/types.ts @@ -14,7 +14,6 @@ * limitations under the License. */ import { JsonObject } from '@backstage/config'; -import { IndexableDocument } from '@backstage/plugin-search-indexer-backend'; export interface SearchQuery { term: string; @@ -29,3 +28,49 @@ export interface SearchResult { export interface SearchResultSet { results: SearchResult[]; } + +/** + * Base properties that all indexed documents must include, as well as some + * common properties that documents are encouraged to use where appropriate. + */ +export interface IndexableDocument { + /** + * The primary name of the document (e.g. name, title, identifier, etc). + */ + title: string; + + /** + * Free-form text of the document (e.g. description, content, etc). + */ + text: string; + + /** + * The relative or absolute URL of the document (target when a search result + * is clicked). + */ + location: string; + + /** + * (Optional) The owner of the document (e.g. spec.owner on a catalog entity). + */ + owner?: string; + + /** + * (Optional) The lifecycle of the document (e.g. spec.lifecycle on a catalog entity). + */ + lifecycle?: string; +} + +/** + * Signature for the callback function that implementors must register to have + * their documents indexed. + */ +export type IndexableDocumentCollator = () => Promise; + +/** + * Signature for the callback function that implementors must register to + * decorate existing documents with additional metadata. + */ +export type IndexableDocumentDecorator = ( + documents: IndexableDocument[], +) => Promise; diff --git a/plugins/catalog-backend/package.json b/plugins/catalog-backend/package.json index c99221b05f..f178e05f68 100644 --- a/plugins/catalog-backend/package.json +++ b/plugins/catalog-backend/package.json @@ -36,6 +36,7 @@ "@backstage/errors": "^0.1.1", "@backstage/integration": "^0.5.1", "@backstage/plugin-search-indexer-backend": "^0.1.1", + "@backstage/search-common": "^0.1.1", "@octokit/graphql": "^4.5.8", "@types/express": "^4.17.6", "@types/ldapjs": "^1.0.9", diff --git a/plugins/catalog-backend/src/search/Collator.ts b/plugins/catalog-backend/src/search/Collator.ts index e7d5483230..1513060384 100644 --- a/plugins/catalog-backend/src/search/Collator.ts +++ b/plugins/catalog-backend/src/search/Collator.ts @@ -17,7 +17,7 @@ import { IndexableDocument, IndexableDocumentCollator, -} from '@backstage/plugin-search-indexer-backend'; +} from '@backstage/search-common'; import { EntitiesCatalog } from '../catalog'; export interface CatalogEntityDocument extends IndexableDocument { diff --git a/plugins/search-backend/package.json b/plugins/search-backend/package.json index 7717b4c7ee..9a1150de8a 100644 --- a/plugins/search-backend/package.json +++ b/plugins/search-backend/package.json @@ -20,21 +20,17 @@ }, "dependencies": { "@backstage/backend-common": "^0.5.3", - "@backstage/config": "^0.1.2", - "@backstage/plugin-search-indexer-backend": "^0.1.1", "@backstage/search-common": "^0.1.1", "@types/express": "^4.17.6", "express": "^4.17.1", "express-promise-router": "^3.0.3", "winston": "^3.2.1", - "cross-fetch": "^3.0.6", "yn": "^4.0.0" }, "devDependencies": { "@backstage/cli": "^0.6.0", "@types/supertest": "^2.0.8", - "supertest": "^4.0.2", - "msw": "^0.21.2" + "supertest": "^4.0.2" }, "files": [ "dist" diff --git a/plugins/search-backend/src/service/router.ts b/plugins/search-backend/src/service/router.ts index 7dab206b6a..1a0c67bdb8 100644 --- a/plugins/search-backend/src/service/router.ts +++ b/plugins/search-backend/src/service/router.ts @@ -17,7 +17,7 @@ import express from 'express'; import Router from 'express-promise-router'; import { Logger } from 'winston'; -import { SearchQuery, SearchResultSet } from '../types'; +import { SearchQuery, SearchResultSet } from '@backstage/search-common'; type RouterOptions = { logger: Logger; diff --git a/plugins/search-indexer-backend/package.json b/plugins/search-indexer-backend/package.json index 7b010442d0..656fb2dca5 100644 --- a/plugins/search-indexer-backend/package.json +++ b/plugins/search-indexer-backend/package.json @@ -19,8 +19,7 @@ "clean": "backstage-cli clean" }, "dependencies": { - "@backstage/backend-common": "^0.5.3", - "@backstage/config": "^0.1.2" + "@backstage/search-common": "^0.1.1" }, "devDependencies": { "@backstage/cli": "^0.6.0" diff --git a/plugins/search-indexer-backend/src/index.ts b/plugins/search-indexer-backend/src/index.ts index 13d1a298b7..cde6e268b1 100644 --- a/plugins/search-indexer-backend/src/index.ts +++ b/plugins/search-indexer-backend/src/index.ts @@ -27,9 +27,3 @@ export const registerCollator = (params: RegisterCollatorParameters) => { export const registerDecorator = (params: RegisterDecoratorParameters) => { registry.addDecorator(params); }; - -export type { - IndexableDocument, - IndexableDocumentCollator, - IndexableDocumentDecorator, -} from './types'; diff --git a/plugins/search-indexer-backend/src/registry.ts b/plugins/search-indexer-backend/src/registry.ts index 1e5363401a..6125e8f6a3 100644 --- a/plugins/search-indexer-backend/src/registry.ts +++ b/plugins/search-indexer-backend/src/registry.ts @@ -17,6 +17,8 @@ import { IndexableDocumentCollator, IndexableDocumentDecorator, +} from '@backstage/search-common'; +import { RegisterCollatorParameters, RegisterDecoratorParameters, } from './types'; diff --git a/plugins/search-indexer-backend/src/types.ts b/plugins/search-indexer-backend/src/types.ts index 63a10be2ea..08ba475df8 100644 --- a/plugins/search-indexer-backend/src/types.ts +++ b/plugins/search-indexer-backend/src/types.ts @@ -14,51 +14,10 @@ * limitations under the License. */ -/** - * Base properties that all indexed documents must include, as well as some - * common properties that documents are encouraged to use where appropriate. - */ -export interface IndexableDocument { - /** - * The primary name of the document (e.g. name, title, identifier, etc). - */ - title: string; - - /** - * Free-form text of the document (e.g. description, content, etc). - */ - text: string; - - /** - * The relative or absolute URL of the document (target when a search result - * is clicked). - */ - location: string; - - /** - * (Optional) The owner of the document (e.g. spec.owner on a catalog entity). - */ - owner?: string; - - /** - * (Optional) The lifecycle of the document (e.g. spec.lifecycle on a catalog entity). - */ - lifecycle?: string; -} - -/** - * Signature for the callback function that implementors must register to have - * their documents indexed. - */ -export type IndexableDocumentCollator = () => Promise; - -/** - * Signature for the callback function that implementors must register to - * decorate existing documents with additional metadata. - */ -export type IndexableDocumentDecorator = ( - documents: IndexableDocument[], -) => Promise; +import { + IndexableDocumentCollator, + IndexableDocumentDecorator, +} from '@backstage/search-common'; /** * Parameters required to register a collator.