From 1d05fea3c14599b43ce77c15105af6f628031490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 11 Jun 2020 09:53:27 +0200 Subject: [PATCH] chore(catalog): rename all pages and components to use Entity nomenclature --- plugins/catalog/src/api/CatalogClient.ts | 7 +- plugins/catalog/src/api/types.ts | 1 + .../CatalogFilter/AllServicesCount.tsx | 1 + .../CatalogFilter/CatalogFilter.tsx | 1 + .../components/CatalogFilter/StarredCount.tsx | 1 + .../components/CatalogPage/CatalogPage.tsx | 2 +- .../CatalogTable/CatalogTable.test.tsx | 5 +- .../components/CatalogTable/CatalogTable.tsx | 3 +- .../EntityContextMenu.test.tsx} | 13 +- .../EntityContextMenu.tsx} | 17 +- .../EntityMetadataCard.test.tsx} | 11 +- .../EntityMetadataCard.tsx} | 3 +- .../EntityPage.test.tsx} | 15 +- .../EntityPage.tsx} | 20 +-- .../UnregisterEntityDialog.tsx} | 8 +- plugins/catalog/src/data/filters.ts | 1 + plugins/catalog/src/data/utils.ts | 1 + .../catalog/src/hooks/useStarredEntites.ts | 7 +- .../src/hooks/useStarredEntities.test.tsx | 1 + plugins/catalog/src/index.ts | 1 - plugins/catalog/src/plugin.ts | 4 +- plugins/catalog/src/types.ts | 159 ------------------ 22 files changed, 64 insertions(+), 218 deletions(-) rename plugins/catalog/src/components/{ComponentContextMenu/ComponentContextMenu.test.tsx => EntityContextMenu/EntityContextMenu.test.tsx} (72%) rename plugins/catalog/src/components/{ComponentContextMenu/ComponentContextMenu.tsx => EntityContextMenu/EntityContextMenu.tsx} (88%) rename plugins/catalog/src/components/{ComponentMetadataCard/ComponentMetadataCard.test.tsx => EntityMetadataCard/EntityMetadataCard.test.tsx} (77%) rename plugins/catalog/src/components/{ComponentMetadataCard/ComponentMetadataCard.tsx => EntityMetadataCard/EntityMetadataCard.tsx} (93%) rename plugins/catalog/src/components/{ComponentPage/ComponentPage.test.tsx => EntityPage/EntityPage.test.tsx} (85%) rename plugins/catalog/src/components/{ComponentPage/ComponentPage.tsx => EntityPage/EntityPage.tsx} (87%) rename plugins/catalog/src/components/{ComponentRemovalDialog/ComponentRemovalDialog.tsx => UnregisterEntityDialog/UnregisterEntityDialog.tsx} (93%) delete mode 100644 plugins/catalog/src/types.ts diff --git a/plugins/catalog/src/api/CatalogClient.ts b/plugins/catalog/src/api/CatalogClient.ts index 86ea6d0624..4d7ab09408 100644 --- a/plugins/catalog/src/api/CatalogClient.ts +++ b/plugins/catalog/src/api/CatalogClient.ts @@ -20,7 +20,6 @@ import { LOCATION_ANNOTATION, } from '@backstage/catalog-model'; import Cache from 'node-cache'; -import { DescriptorEnvelope } from '../types'; import { CatalogApi, EntityCompoundName } from './types'; export class CatalogClient implements CatalogApi { @@ -77,10 +76,8 @@ export class CatalogClient implements CatalogApi { return await this.getOptional(`/locations/${id}`); } - async getEntities( - filter?: Record, - ): Promise { - const cachedValue = this.cache.get( + async getEntities(filter?: Record): Promise { + const cachedValue = this.cache.get( `get:${JSON.stringify(filter)}`, ); if (cachedValue) return cachedValue; diff --git a/plugins/catalog/src/api/types.ts b/plugins/catalog/src/api/types.ts index 3bd2c6de97..8136e4104a 100644 --- a/plugins/catalog/src/api/types.ts +++ b/plugins/catalog/src/api/types.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { createApiRef } from '@backstage/core'; import { Entity, Location } from '@backstage/catalog-model'; diff --git a/plugins/catalog/src/components/CatalogFilter/AllServicesCount.tsx b/plugins/catalog/src/components/CatalogFilter/AllServicesCount.tsx index 07879770b7..5ccac8f772 100644 --- a/plugins/catalog/src/components/CatalogFilter/AllServicesCount.tsx +++ b/plugins/catalog/src/components/CatalogFilter/AllServicesCount.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import React from 'react'; import { useApi } from '@backstage/core'; import { catalogApiRef } from '../../api/types'; diff --git a/plugins/catalog/src/components/CatalogFilter/CatalogFilter.tsx b/plugins/catalog/src/components/CatalogFilter/CatalogFilter.tsx index 2551ebd4d1..5335b33ffa 100644 --- a/plugins/catalog/src/components/CatalogFilter/CatalogFilter.tsx +++ b/plugins/catalog/src/components/CatalogFilter/CatalogFilter.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import React from 'react'; import { Card, diff --git a/plugins/catalog/src/components/CatalogFilter/StarredCount.tsx b/plugins/catalog/src/components/CatalogFilter/StarredCount.tsx index 20e1be1a9a..5e79682783 100644 --- a/plugins/catalog/src/components/CatalogFilter/StarredCount.tsx +++ b/plugins/catalog/src/components/CatalogFilter/StarredCount.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import React from 'react'; import { useStarredEntities } from '../../hooks/useStarredEntites'; diff --git a/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx index c5af3220c0..c2c40ee575 100644 --- a/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx @@ -189,7 +189,7 @@ export const CatalogPage: FC<{}> = () => { > Create Service - All your components + All your software catalog entities
diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx index 6d38319fe9..c04e4c95a8 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { Entity } from '@backstage/catalog-model'; import { wrapInTestApp } from '@backstage/test-utils'; import { render } from '@testing-library/react'; @@ -50,12 +51,12 @@ describe('CatalogTable component', () => { ), ); const errorMessage = await rendered.findByText( - /Error encountered while fetching components./, + /Error encountered while fetching catalog entities./, ); expect(errorMessage).toBeInTheDocument(); }); - it('should display component names when loading has finished and no error occurred', async () => { + it('should display entity names when loading has finished and no error occurred', async () => { const rendered = render( wrapInTestApp( = ({ return (
- Error encountered while fetching components. {error.toString()} + Error encountered while fetching catalog entities. {error.toString()}
); diff --git a/plugins/catalog/src/components/ComponentContextMenu/ComponentContextMenu.test.tsx b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.test.tsx similarity index 72% rename from plugins/catalog/src/components/ComponentContextMenu/ComponentContextMenu.test.tsx rename to plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.test.tsx index 8a1f513f67..68306944a3 100644 --- a/plugins/catalog/src/components/ComponentContextMenu/ComponentContextMenu.test.tsx +++ b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.test.tsx @@ -13,21 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ComponentContextMenu } from './ComponentContextMenu'; -import { render } from '@testing-library/react'; + +import { render, fireEvent } from '@testing-library/react'; import * as React from 'react'; import { act } from 'react-dom/test-utils'; +import { EntityContextMenu } from './EntityContextMenu'; describe('ComponentContextMenu', () => { - it('should call onUnregisterComponent on button click', async () => { + it('should call onUnregisterEntity on button click', async () => { await act(async () => { const mockCallback = jest.fn(); const menu = render( - , + , ); const button = await menu.findByTestId('menu-button'); - button.click(); - const unregister = await menu.findByText('Unregister component'); + fireEvent.click(button); + const unregister = await menu.findByText('Unregister entity'); expect(unregister).toBeInTheDocument(); }); }); diff --git a/plugins/catalog/src/components/ComponentContextMenu/ComponentContextMenu.tsx b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx similarity index 88% rename from plugins/catalog/src/components/ComponentContextMenu/ComponentContextMenu.tsx rename to plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx index 14c68ec7f9..fd52b97cb1 100644 --- a/plugins/catalog/src/components/ComponentContextMenu/ComponentContextMenu.tsx +++ b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { IconButton, ListItemIcon, @@ -34,13 +35,11 @@ const useStyles = makeStyles({ }, }); -type ComponentContextMenuProps = { - onUnregisterComponent: () => void; +type Props = { + onUnregisterEntity: () => void; }; -export const ComponentContextMenu: FC = ({ - onUnregisterComponent, -}) => { +export const EntityContextMenu: FC = ({ onUnregisterEntity }) => { const [anchorEl, setAnchorEl] = useState(); const classes = useStyles(); @@ -53,7 +52,7 @@ export const ComponentContextMenu: FC = ({ }; return ( -
+ <> = ({ { onClose(); - onUnregisterComponent(); + onUnregisterEntity(); }} > - Unregister component + Unregister entity @@ -91,6 +90,6 @@ export const ComponentContextMenu: FC = ({ -
+ ); }; diff --git a/plugins/catalog/src/components/ComponentMetadataCard/ComponentMetadataCard.test.tsx b/plugins/catalog/src/components/EntityMetadataCard/EntityMetadataCard.test.tsx similarity index 77% rename from plugins/catalog/src/components/ComponentMetadataCard/ComponentMetadataCard.test.tsx rename to plugins/catalog/src/components/EntityMetadataCard/EntityMetadataCard.test.tsx index ef12e52363..e0027431ff 100644 --- a/plugins/catalog/src/components/ComponentMetadataCard/ComponentMetadataCard.test.tsx +++ b/plugins/catalog/src/components/EntityMetadataCard/EntityMetadataCard.test.tsx @@ -13,21 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { Entity } from '@backstage/catalog-model'; import { render } from '@testing-library/react'; import React from 'react'; -import { ComponentMetadataCard } from './ComponentMetadataCard'; +import { EntityMetadataCard } from './EntityMetadataCard'; -describe('ComponentMetadataCard component', () => { - it('should display component name if provided', async () => { +describe('EntityMetadataCard component', () => { + it('should display entity name if provided', async () => { const testEntity: Entity = { apiVersion: 'backstage.io/v1beta1', kind: 'Component', metadata: { name: 'test' }, }; - const rendered = await render( - , - ); + const rendered = await render(); expect(await rendered.findByText('test')).toBeInTheDocument(); }); }); diff --git a/plugins/catalog/src/components/ComponentMetadataCard/ComponentMetadataCard.tsx b/plugins/catalog/src/components/EntityMetadataCard/EntityMetadataCard.tsx similarity index 93% rename from plugins/catalog/src/components/ComponentMetadataCard/ComponentMetadataCard.tsx rename to plugins/catalog/src/components/EntityMetadataCard/EntityMetadataCard.tsx index 60c9284121..d7a3bc81f6 100644 --- a/plugins/catalog/src/components/ComponentMetadataCard/ComponentMetadataCard.tsx +++ b/plugins/catalog/src/components/EntityMetadataCard/EntityMetadataCard.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { Entity } from '@backstage/catalog-model'; import { InfoCard, StructuredMetadataTable } from '@backstage/core'; import React, { FC } from 'react'; @@ -21,7 +22,7 @@ type Props = { entity: Entity; }; -export const ComponentMetadataCard: FC = ({ entity }) => ( +export const EntityMetadataCard: FC = ({ entity }) => ( diff --git a/plugins/catalog/src/components/ComponentPage/ComponentPage.test.tsx b/plugins/catalog/src/components/EntityPage/EntityPage.test.tsx similarity index 85% rename from plugins/catalog/src/components/ComponentPage/ComponentPage.test.tsx rename to plugins/catalog/src/components/EntityPage/EntityPage.test.tsx index 75393bd10e..22a47c192e 100644 --- a/plugins/catalog/src/components/ComponentPage/ComponentPage.test.tsx +++ b/plugins/catalog/src/components/EntityPage/EntityPage.test.tsx @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ComponentPage } from './ComponentPage'; + +import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core'; +import { wrapInTestApp } from '@backstage/test-utils'; import { render, wait } from '@testing-library/react'; import * as React from 'react'; -import { wrapInTestApp } from '@backstage/test-utils'; -import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core'; -import { catalogApiRef, CatalogApi } from '../../api/types'; +import { CatalogApi, catalogApiRef } from '../../api/types'; +import { EntityPage } from './EntityPage'; const getTestProps = (name: string) => { return { @@ -36,8 +37,8 @@ const getTestProps = (name: string) => { const errorApi = { post: () => {} }; -describe('ComponentPage', () => { - it('should redirect to component table page when name is not provided', async () => { +describe('EntityPage', () => { + it('should redirect to catalog page when name is not provided', async () => { const props = getTestProps(''); render( wrapInTestApp( @@ -52,7 +53,7 @@ describe('ComponentPage', () => { ], ])} > - + , ), ); diff --git a/plugins/catalog/src/components/ComponentPage/ComponentPage.tsx b/plugins/catalog/src/components/EntityPage/EntityPage.tsx similarity index 87% rename from plugins/catalog/src/components/ComponentPage/ComponentPage.tsx rename to plugins/catalog/src/components/EntityPage/EntityPage.tsx index 247a13247f..96132819e8 100644 --- a/plugins/catalog/src/components/ComponentPage/ComponentPage.tsx +++ b/plugins/catalog/src/components/EntityPage/EntityPage.tsx @@ -31,13 +31,13 @@ import { Alert } from '@material-ui/lab'; import React, { FC, useEffect, useState } from 'react'; import { useAsync } from 'react-use'; import { catalogApiRef } from '../..'; -import { ComponentContextMenu } from '../ComponentContextMenu/ComponentContextMenu'; -import { ComponentMetadataCard } from '../ComponentMetadataCard/ComponentMetadataCard'; -import { ComponentRemovalDialog } from '../ComponentRemovalDialog/ComponentRemovalDialog'; +import { EntityContextMenu } from '../EntityContextMenu/EntityContextMenu'; +import { EntityMetadataCard } from '../EntityMetadataCard/EntityMetadataCard'; +import { UnregisterEntityDialog } from '../UnregisterEntityDialog/UnregisterEntityDialog'; const REDIRECT_DELAY = 1000; -type ComponentPageProps = { +type Props = { match: { params: { optionalNamespaceAndName: string; @@ -68,7 +68,7 @@ function headerProps( }; } -export const ComponentPage: FC = ({ match, history }) => { +export const EntityPage: FC = ({ match, history }) => { const { optionalNamespaceAndName, kind } = match.params; const [name, namespace] = optionalNamespaceAndName.split(':').reverse(); @@ -83,7 +83,7 @@ export const ComponentPage: FC = ({ match, history }) => { useEffect(() => { if (!error && !loading && !entity) { - errorApi.post(new Error('Component not found!')); + errorApi.post(new Error('Entity not found!')); setTimeout(() => { history.push('/'); }, REDIRECT_DELAY); @@ -141,9 +141,7 @@ export const ComponentPage: FC = ({ match, history }) => { // TODO: Switch theme and type props based on component type (website, library, ...)
- {entity && ( - - )} + {entity && }
{loading && } @@ -161,7 +159,7 @@ export const ComponentPage: FC = ({ match, history }) => { - + = ({ match, history }) => { - any; onClose: () => any; @@ -50,7 +50,7 @@ function useColocatedEntities(entity: Entity): AsyncState { }, [catalogApi, entity]); } -export const ComponentRemovalDialog: FC = ({ +export const UnregisterEntityDialog: FC = ({ open, onConfirm, onClose, @@ -76,7 +76,7 @@ export const ComponentRemovalDialog: FC = ({ return ( - Are you sure you want to unregister this component? + Are you sure you want to unregister this entity? {loading ? : null} @@ -108,7 +108,7 @@ export const ComponentRemovalDialog: FC = ({ - To undo, just re-register the component in Backstage. + To undo, just re-register the entity in Backstage. ) : null} diff --git a/plugins/catalog/src/data/filters.ts b/plugins/catalog/src/data/filters.ts index 847e6b624c..6468694952 100644 --- a/plugins/catalog/src/data/filters.ts +++ b/plugins/catalog/src/data/filters.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { CatalogFilterGroup, CatalogFilterItem, diff --git a/plugins/catalog/src/data/utils.ts b/plugins/catalog/src/data/utils.ts index 4eaac6e33a..df14875092 100644 --- a/plugins/catalog/src/data/utils.ts +++ b/plugins/catalog/src/data/utils.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { EntityMeta, LocationSpec, diff --git a/plugins/catalog/src/hooks/useStarredEntites.ts b/plugins/catalog/src/hooks/useStarredEntites.ts index 20f13f8e21..7cbbbb7ce6 100644 --- a/plugins/catalog/src/hooks/useStarredEntites.ts +++ b/plugins/catalog/src/hooks/useStarredEntites.ts @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { useState, useEffect, useCallback } from 'react'; -import { useApi, storageApiRef } from '@backstage/core'; -import { useObservable } from 'react-use'; + import { Entity } from '@backstage/catalog-model'; +import { storageApiRef, useApi } from '@backstage/core'; +import { useCallback, useEffect, useState } from 'react'; +import { useObservable } from 'react-use'; const buildEntityKey = (component: Entity) => `entity:${component.kind}:${component.metadata.namespace ?? 'default'}:${ diff --git a/plugins/catalog/src/hooks/useStarredEntities.test.tsx b/plugins/catalog/src/hooks/useStarredEntities.test.tsx index 1ac9ac799d..6c98690553 100644 --- a/plugins/catalog/src/hooks/useStarredEntities.test.tsx +++ b/plugins/catalog/src/hooks/useStarredEntities.test.tsx @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import React from 'react'; import { renderHook, act } from '@testing-library/react-hooks'; import { useStarredEntities } from './useStarredEntites'; diff --git a/plugins/catalog/src/index.ts b/plugins/catalog/src/index.ts index 2b986b59ea..701394df34 100644 --- a/plugins/catalog/src/index.ts +++ b/plugins/catalog/src/index.ts @@ -17,5 +17,4 @@ export { plugin } from './plugin'; export * from './api/CatalogClient'; export * from './api/types'; -export * from './types'; export * from './routes'; diff --git a/plugins/catalog/src/plugin.ts b/plugins/catalog/src/plugin.ts index 6f9a580edd..8f4ac80f48 100644 --- a/plugins/catalog/src/plugin.ts +++ b/plugins/catalog/src/plugin.ts @@ -16,13 +16,13 @@ import { createPlugin } from '@backstage/core'; import { CatalogPage } from './components/CatalogPage/CatalogPage'; -import { ComponentPage } from './components/ComponentPage/ComponentPage'; +import { EntityPage } from './components/EntityPage/EntityPage'; import { entityRoute, rootRoute } from './routes'; export const plugin = createPlugin({ id: 'catalog', register({ router }) { router.addRoute(rootRoute, CatalogPage); - router.addRoute(entityRoute, ComponentPage); + router.addRoute(entityRoute, EntityPage); }, }); diff --git a/plugins/catalog/src/types.ts b/plugins/catalog/src/types.ts deleted file mode 100644 index 0f91e1ed8e..0000000000 --- a/plugins/catalog/src/types.ts +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2020 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 interface ComponentDescriptorV1beta1 extends DescriptorEnvelope { - spec: { - type: string; - }; -} - -export type ComponentDescriptor = ComponentDescriptorV1beta1; - -/** - * Metadata fields common to all versions/kinds of entity. - * - * @see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#objectmeta-v1-meta - */ -export type EntityMeta = { - /** - * A globally unique ID for the entity. - * - * This field can not be set by the user at creation time, and the server - * will reject an attempt to do so. The field will be populated in read - * operations. The field can (optionally) be specified when performing - * update or delete operations, but the server is free to reject requests - * that do so in such a way that it breaks semantics. - */ - uid?: string; - - /** - * An opaque string that changes for each update operation to any part of - * the entity, including metadata. - * - * This field can not be set by the user at creation time, and the server - * will reject an attempt to do so. The field will be populated in read - * operations. The field can (optionally) be specified when performing - * update or delete operations, and the server will then reject the - * operation if it does not match the current stored value. - */ - etag?: string; - - /** - * A positive nonzero number that indicates the current generation of data - * for this entity; the value is incremented each time the spec changes. - * - * This field can not be set by the user at creation time, and the server - * will reject an attempt to do so. The field will be populated in read - * operations. - */ - generation?: number; - - /** - * The name of the entity. - * - * Must be uniqe within the catalog at any given point in time, for any - * given namespace, for any given kind. - */ - name: string; - - /** - * The short description of the entity. - * - * A a human readable string. - */ - description: string; - - /** - * The namespace that the entity belongs to. - */ - namespace?: string; - - /** - * Key/value pairs of identifying information attached to the entity. - */ - labels?: Record; - - /** - * Key/value pairs of non-identifying auxiliary information attached to the - * entity. - */ - annotations?: Record; -}; - -/** - * The format envelope that's common to all versions/kinds. - * - * @see https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/ - */ -export type DescriptorEnvelope = { - /** - * The version of specification format for this particular entity that - * this is written against. - */ - apiVersion: string; - - /** - * The high level entity type being described. - */ - kind: string; - - /** - * Optional metadata related to the entity. - */ - metadata: EntityMeta; - - /** - * The specification data describing the entity itself. - */ - spec?: object; -}; - -/** - * Parses and validates descriptors. - * - * The output must be validated and well formed. - */ -export type DescriptorParser = { - /** - * Parses and validates a single raw descriptor. - * - * @param descriptor A raw descriptor object - * @returns A structure describing the parsed and validated descriptor - * @throws An Error if the descriptor was malformed - */ - parse(descriptor: object): Promise; -}; - -/** - * Parses and validates a single envelope into its materialized kind. - * - * These parsers may assume that the envelope is already validated and well - * formed. - */ -export type KindParser = { - /** - * Try to parse an envelope into a materialized kind. - * - * @param envelope A valid descriptor envelope - * @returns A materialized type, or undefined if the given version/kind is - * not meant to be handled by this parser - * @throws An Error if the type was handled and found to not be properly - * formatted - */ - tryParse( - envelope: DescriptorEnvelope, - ): Promise; -};