From 1de7dd85b00185472a07edf9b03d5fe2c36b39e4 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 3 Mar 2022 11:08:57 +0100 Subject: [PATCH] chore: moving the CatalogEntityDocument to catalog-common Signed-off-by: blam --- plugins/catalog-backend/api-report.md | 16 ++-------- .../search/DefaultCatalogCollatorFactory.ts | 20 +++++-------- plugins/catalog-common/api-report.md | 15 ++++++++++ plugins/catalog-common/package.json | 3 +- plugins/catalog-common/src/index.ts | 2 ++ .../src/search/CatalogEntityDocument.ts | 29 +++++++++++++++++++ plugins/catalog-common/src/search/index.ts | 16 ++++++++++ 7 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 plugins/catalog-common/src/search/CatalogEntityDocument.ts create mode 100644 plugins/catalog-common/src/search/index.ts diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index ee7b419a71..9dcb2db752 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -7,6 +7,7 @@ import { BitbucketIntegration } from '@backstage/integration'; import { CatalogApi } from '@backstage/catalog-client'; +import { CatalogEntityDocument } from '@backstage/plugin-catalog-common'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { ConditionalPolicyDecision } from '@backstage/plugin-permission-node'; import { Conditions } from '@backstage/plugin-permission-node'; @@ -18,7 +19,6 @@ import express from 'express'; import { GetEntitiesRequest } from '@backstage/catalog-client'; import { GithubCredentialsProvider } from '@backstage/integration'; import { GitHubIntegrationConfig } from '@backstage/integration'; -import { IndexableDocument } from '@backstage/search-common'; import { JsonObject } from '@backstage/types'; import { JsonValue } from '@backstage/types'; import { Location as Location_2 } from '@backstage/catalog-client'; @@ -248,19 +248,7 @@ export const catalogConditions: Conditions<{ >; }>; -// @public (undocumented) -export interface CatalogEntityDocument extends IndexableDocument { - // (undocumented) - componentType: string; - // (undocumented) - kind: string; - // (undocumented) - lifecycle: string; - // (undocumented) - namespace: string; - // (undocumented) - owner: string; -} +export { CatalogEntityDocument }; // @public (undocumented) export type CatalogEnvironment = { diff --git a/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts b/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts index 99377b2ca0..811ac10210 100644 --- a/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts +++ b/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts @@ -29,21 +29,17 @@ import { UserEntity, } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; +import { DocumentCollatorFactory } from '@backstage/search-common'; import { - DocumentCollatorFactory, - IndexableDocument, -} from '@backstage/search-common'; -import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common'; + catalogEntityReadPermission, + CatalogEntityDocument, +} from '@backstage/plugin-catalog-common'; import { Readable } from 'stream'; -/** @public */ -export interface CatalogEntityDocument extends IndexableDocument { - componentType: string; - namespace: string; - kind: string; - lifecycle: string; - owner: string; -} +/** + * @deprecated import from `@backstage/plugin-catalog-common` instead + */ +export type { CatalogEntityDocument }; /** @public */ export type DefaultCatalogCollatorFactoryOptions = { diff --git a/plugins/catalog-common/api-report.md b/plugins/catalog-common/api-report.md index 57f8c3983e..8ae9571d4c 100644 --- a/plugins/catalog-common/api-report.md +++ b/plugins/catalog-common/api-report.md @@ -3,6 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { IndexableDocument } from '@backstage/search-common'; import { Permission } from '@backstage/plugin-permission-common'; // @alpha @@ -11,6 +12,20 @@ export const catalogEntityCreatePermission: Permission; // @alpha export const catalogEntityDeletePermission: Permission; +// @public +export interface CatalogEntityDocument extends IndexableDocument { + // (undocumented) + componentType: string; + // (undocumented) + kind: string; + // (undocumented) + lifecycle: string; + // (undocumented) + namespace: string; + // (undocumented) + owner: string; +} + // @alpha export const catalogEntityReadPermission: Permission; diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json index acf4ed4aaa..bc0d3750ba 100644 --- a/plugins/catalog-common/package.json +++ b/plugins/catalog-common/package.json @@ -34,7 +34,8 @@ "clean": "backstage-cli package clean" }, "dependencies": { - "@backstage/plugin-permission-common": "^0.5.1" + "@backstage/plugin-permission-common": "^0.5.1", + "@backstage/search-common": "^0.2.4" }, "devDependencies": { "@backstage/cli": "^0.14.0" diff --git a/plugins/catalog-common/src/index.ts b/plugins/catalog-common/src/index.ts index 9eddf37452..08184eb871 100644 --- a/plugins/catalog-common/src/index.ts +++ b/plugins/catalog-common/src/index.ts @@ -31,3 +31,5 @@ export { catalogLocationCreatePermission, catalogLocationDeletePermission, } from './permissions'; + +export * from './search'; diff --git a/plugins/catalog-common/src/search/CatalogEntityDocument.ts b/plugins/catalog-common/src/search/CatalogEntityDocument.ts new file mode 100644 index 0000000000..e48cde431a --- /dev/null +++ b/plugins/catalog-common/src/search/CatalogEntityDocument.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2022 The Backstage Authors + * + * 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 { IndexableDocument } from '@backstage/search-common'; + +/** + * The Document format for an Entity in the Catalog for search + * + * @public + */ +export interface CatalogEntityDocument extends IndexableDocument { + componentType: string; + namespace: string; + kind: string; + lifecycle: string; + owner: string; +} diff --git a/plugins/catalog-common/src/search/index.ts b/plugins/catalog-common/src/search/index.ts new file mode 100644 index 0000000000..82e713aba0 --- /dev/null +++ b/plugins/catalog-common/src/search/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2022 The Backstage Authors + * + * 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 type { CatalogEntityDocument } from './CatalogEntityDocument';