From 608649b13cb0b320f1ccf02f60a077e02dfb42bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20N=C3=A4sman?= Date: Fri, 26 Feb 2021 14:55:01 +0100 Subject: [PATCH] add search-common package Signed-off-by: Eric Peterson --- packages/search-common/.eslintrc.js | 3 ++ packages/search-common/README.md | 3 ++ packages/search-common/package.json | 56 +++++++++++++++++++++++++++++ packages/search-common/src/index.ts | 16 +++++++++ packages/search-common/src/types.ts | 31 ++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 packages/search-common/.eslintrc.js create mode 100644 packages/search-common/README.md create mode 100644 packages/search-common/package.json create mode 100644 packages/search-common/src/index.ts create mode 100644 packages/search-common/src/types.ts diff --git a/packages/search-common/.eslintrc.js b/packages/search-common/.eslintrc.js new file mode 100644 index 0000000000..16a033dbc6 --- /dev/null +++ b/packages/search-common/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: [require.resolve('@backstage/cli/config/eslint.backend')], +}; diff --git a/packages/search-common/README.md b/packages/search-common/README.md new file mode 100644 index 0000000000..66828cc7af --- /dev/null +++ b/packages/search-common/README.md @@ -0,0 +1,3 @@ +# @backstage/search-common + +Common functionalities for Search, to be shared between various search-enabled plugins. diff --git a/packages/search-common/package.json b/packages/search-common/package.json new file mode 100644 index 0000000000..6336a13449 --- /dev/null +++ b/packages/search-common/package.json @@ -0,0 +1,56 @@ +{ + "name": "@backstage/search-common", + "description": "Common functionalities for Search, to be shared between various search-enabled plugins", + "version": "0.1.1", + "main": "src/index.ts", + "types": "src/index.ts", + "private": false, + "publishConfig": { + "access": "public", + "main": "dist/index.cjs.js", + "types": "dist/index.d.ts" + }, + "homepage": "https://backstage.io", + "repository": { + "type": "git", + "url": "https://github.com/backstage/backstage", + "directory": "packages/search-common" + }, + "keywords": [ + "backstage", + "search" + ], + "license": "Apache-2.0", + "files": [ + "dist" + ], + "scripts": { + "build": "backstage-cli build --outputs cjs,types", + "lint": "backstage-cli lint", + "test": "backstage-cli test", + "prepack": "backstage-cli prepack", + "postpack": "backstage-cli postpack", + "clean": "backstage-cli clean" + }, + "bugs": { + "url": "https://github.com/backstage/backstage/issues" + }, + "dependencies": { + "@backstage/config": "^0.1.3", + "@backstage/plugin-search-indexer-backend": "^0.1.1" + }, + "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" + }, + "jest": { + "roots": [ + ".." + ] + } +} diff --git a/packages/search-common/src/index.ts b/packages/search-common/src/index.ts new file mode 100644 index 0000000000..e6432477f2 --- /dev/null +++ b/packages/search-common/src/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export * from './types'; diff --git a/packages/search-common/src/types.ts b/packages/search-common/src/types.ts new file mode 100644 index 0000000000..1a05e85f69 --- /dev/null +++ b/packages/search-common/src/types.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2021 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { JsonObject } from '@backstage/config'; +import { IndexableDocument } from '@backstage/plugin-search-indexer-backend'; + +export interface SearchQuery { + term: string; + filters?: JsonObject; + pageCursor: string; +} + +export interface SearchResult { + document: IndexableDocument; +} + +export interface SearchResultSet { + results: SearchResult[]; +}