From e1c35fbaab7f60e108db847c9e95714d7d543774 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 09:55:20 +0100 Subject: [PATCH] catalog-react: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/catalog-react/alpha-api-report.md | 22 +++++++++++++++++++++ plugins/catalog-react/api-report.md | 13 ------------ plugins/catalog-react/package.json | 24 ++++++++++++++++------- plugins/catalog-react/src/alpha.ts | 18 +++++++++++++++++ plugins/catalog-react/src/hooks/index.ts | 1 - plugins/catalog-react/src/index.ts | 6 +----- 6 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 plugins/catalog-react/alpha-api-report.md create mode 100644 plugins/catalog-react/src/alpha.ts diff --git a/plugins/catalog-react/alpha-api-report.md b/plugins/catalog-react/alpha-api-report.md new file mode 100644 index 0000000000..f9b740c07c --- /dev/null +++ b/plugins/catalog-react/alpha-api-report.md @@ -0,0 +1,22 @@ +## API Report File for "@backstage/plugin-catalog-react" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { Entity } from '@backstage/catalog-model'; +import { ResourcePermission } from '@backstage/plugin-permission-common'; + +// @alpha +export function isOwnerOf(owner: Entity, entity: Entity): boolean; + +// @alpha +export function useEntityPermission( + permission: ResourcePermission<'catalog-entity'>, +): { + loading: boolean; + allowed: boolean; + error?: Error; +}; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 4756432857..55c72122f5 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -20,7 +20,6 @@ import { Overrides } from '@material-ui/core/styles/overrides'; import { PropsWithChildren } from 'react'; import { default as React_2 } from 'react'; import { ReactNode } from 'react'; -import { ResourcePermission } from '@backstage/plugin-permission-common'; import { RouteRef } from '@backstage/core-plugin-api'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { StyleRules } from '@material-ui/core/styles/withStyles'; @@ -474,9 +473,6 @@ export function InspectEntityDialog(props: { onClose: () => void; }): JSX.Element | null; -// @alpha -export function isOwnerOf(owner: Entity, entity: Entity): boolean; - // @public (undocumented) export function MockEntityListContextProvider< T extends DefaultEntityFilters = DefaultEntityFilters, @@ -538,15 +534,6 @@ export function useEntityOwnership(): { isOwnedEntity: (entity: Entity) => boolean; }; -// @alpha -export function useEntityPermission( - permission: ResourcePermission<'catalog-entity'>, -): { - loading: boolean; - allowed: boolean; - error?: Error; -}; - // @public export function useEntityTypeFilter(): { loading: boolean; diff --git a/plugins/catalog-react/package.json b/plugins/catalog-react/package.json index e66c2b4bb1..0ca4e3c9e4 100644 --- a/plugins/catalog-react/package.json +++ b/plugins/catalog-react/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "web-library" @@ -24,7 +35,7 @@ "backstage" ], "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -78,7 +89,6 @@ "react-test-renderer": "^16.13.1" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/plugins/catalog-react/src/alpha.ts b/plugins/catalog-react/src/alpha.ts new file mode 100644 index 0000000000..e8ff21609e --- /dev/null +++ b/plugins/catalog-react/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 { isOwnerOf } from './utils'; +export { useEntityPermission } from './hooks/useEntityPermission'; diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts index 3570ed897c..ffd32206ef 100644 --- a/plugins/catalog-react/src/hooks/index.ts +++ b/plugins/catalog-react/src/hooks/index.ts @@ -38,4 +38,3 @@ export { useRelatedEntities } from './useRelatedEntities'; export { useStarredEntities } from './useStarredEntities'; export { useStarredEntity } from './useStarredEntity'; export { useEntityOwnership } from './useEntityOwnership'; -export { useEntityPermission } from './useEntityPermission'; diff --git a/plugins/catalog-react/src/index.ts b/plugins/catalog-react/src/index.ts index 2ca7d67d59..b511116f84 100644 --- a/plugins/catalog-react/src/index.ts +++ b/plugins/catalog-react/src/index.ts @@ -31,9 +31,5 @@ export { entityRouteParams, entityRouteRef } from './routes'; export * from './testUtils'; export * from './types'; export * from './overridableComponents'; -export { - getEntityRelations, - getEntitySourceLocation, - isOwnerOf, -} from './utils'; +export { getEntityRelations, getEntitySourceLocation } from './utils'; export type { EntitySourceLocation } from './utils';