chore: fixing the api-report and making things green so far

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-12-23 11:56:31 +01:00
parent 70beaaaa22
commit ccba7df9ac
17 changed files with 146 additions and 41 deletions
+60 -28
View File
@@ -6,6 +6,7 @@
/// <reference types="react" />
import { ApiHolder } from '@backstage/core-plugin-api';
import { Dispatch } from 'react';
import { Extension } from '@backstage/core-plugin-api';
import { ExternalRouteRef } from '@backstage/core-plugin-api';
import { FieldProps } from '@rjsf/core';
@@ -20,13 +21,12 @@ import { PathParams } from '@backstage/core-plugin-api';
import { PropsWithChildren } from 'react';
import { default as React_2 } from 'react';
import { RouteRef } from '@backstage/core-plugin-api';
import { SetStateAction } from 'react';
import { SubRouteRef } from '@backstage/core-plugin-api';
import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
import { UIOptionsType } from '@rjsf/utils';
import { UiSchema } from '@rjsf/utils';
// Warning: (ae-missing-release-tag) "actionsRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const actionsRouteRef: SubRouteRef<undefined>;
@@ -64,8 +64,6 @@ export type CustomFieldValidator<TFieldReturnValue> = (
},
) => void | Promise<void>;
// Warning: (ae-missing-release-tag) "editRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const editRouteRef: SubRouteRef<undefined>;
@@ -75,14 +73,10 @@ export const extractSchemaFromStep: (inputStep: JsonObject) => {
schema: JsonObject;
};
// Warning: (ae-missing-release-tag) "FIELD_EXTENSION_KEY" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
// @public
export const FIELD_EXTENSION_KEY = 'scaffolder.extensions.field.v1';
// Warning: (ae-missing-release-tag) "FIELD_EXTENSION_WRAPPER_KEY" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
// @public
export const FIELD_EXTENSION_WRAPPER_KEY = 'scaffolder.extensions.wrapper.v1';
// @public
@@ -118,8 +112,6 @@ export type FormProps = Pick<
'transformErrors' | 'noHtml5Validate'
>;
// Warning: (ae-missing-release-tag) "legacySelectedTemplateRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public @deprecated (undocumented)
export const legacySelectedTemplateRouteRef: SubRouteRef<
PathParams<'/templates/:templateName'>
@@ -162,9 +154,7 @@ export type NextFieldExtensionOptions<
// @alpha (undocumented)
export const nextRouteRef: RouteRef<undefined>;
// Warning: (ae-missing-release-tag) "nextScaffolderTaskRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
// @alpha (undocumented)
export const nextScaffolderTaskRouteRef: SubRouteRef<
PathParams<'/tasks/:taskId'>
>;
@@ -174,29 +164,41 @@ export const nextSelectedTemplateRouteRef: SubRouteRef<
PathParams<'/templates/:namespace/:templateName'>
>;
// Warning: (ae-missing-release-tag) "registerComponentRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @alpha
export interface ParsedTemplateSchema {
// (undocumented)
description?: string;
// (undocumented)
mergedSchema: JsonObject;
// (undocumented)
schema: JsonObject;
// (undocumented)
title: string;
// (undocumented)
uiSchema: UiSchema;
}
// @public (undocumented)
export const registerComponentRouteRef: ExternalRouteRef<undefined, true>;
// Warning: (ae-forgotten-export) The symbol "ReviewStateProps" needs to be exported by the entry point index.d.ts
//
// @alpha
export const ReviewState: (props: ReviewStateProps) => JSX.Element;
// @alpha
export type ReviewStateProps = {
schemas: ParsedTemplateSchema[];
formState: JsonObject;
};
// @public (undocumented)
export const rootRouteRef: RouteRef<undefined>;
// @public
export const ScaffolderFieldExtensions: React_2.ComponentType;
// Warning: (ae-missing-release-tag) "scaffolderListTaskRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const scaffolderListTaskRouteRef: SubRouteRef<undefined>;
// Warning: (ae-missing-release-tag) "scaffolderTaskRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const scaffolderTaskRouteRef: SubRouteRef<PathParams<'/tasks/:taskId'>>;
@@ -205,11 +207,17 @@ export const selectedTemplateRouteRef: SubRouteRef<
PathParams<'/templates/:namespace/:templateName'>
>;
// Warning: (ae-forgotten-export) The symbol "StepperProps" needs to be exported by the entry point index.d.ts
//
// @alpha (undocumented)
// @alpha
export const Stepper: (props: StepperProps) => JSX.Element;
// @alpha
export type StepperProps = {
manifest: TemplateParameterSchema;
extensions: NextFieldExtensionOptions<any, any>[];
onComplete: (values: Record<string, JsonValue>) => Promise<void>;
FormProps?: FormProps;
};
// @alpha
export const TemplateCard: (props: TemplateCardProps) => JSX.Element;
@@ -221,6 +229,21 @@ export interface TemplateCardProps {
template: TemplateEntityV1beta3;
}
// @alpha
export const TemplateGroup: (props: TemplateGroupProps) => JSX.Element;
// @alpha
export interface TemplateGroupProps {
// (undocumented)
components?: {
CardComponent?: React_2.ComponentType<TemplateCardProps>;
};
// (undocumented)
templates: TemplateEntityV1beta3[];
// (undocumented)
title: React_2.ReactNode;
}
// @public
export type TemplateParameterSchema = {
title: string;
@@ -232,8 +255,17 @@ export type TemplateParameterSchema = {
}>;
};
// Warning: (ae-missing-release-tag) "viewTechDocRouteRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @alpha
export const useFormData: () => [
Record<string, any>,
Dispatch<SetStateAction<Record<string, any>>>,
];
// @alpha
export const useTemplateSchema: (manifest: TemplateParameterSchema) => {
steps: ParsedTemplateSchema[];
};
// @public (undocumented)
export const viewTechDocRouteRef: ExternalRouteRef<
{
@@ -23,12 +23,19 @@ import {
} from './types';
import { Extension, attachComponentData } from '@backstage/core-plugin-api';
/**
* The key used to store the field extension data for the `<ScaffolderFieldExtensions />` component
* @public
*/
export const FIELD_EXTENSION_WRAPPER_KEY = 'scaffolder.extensions.wrapper.v1';
/**
* The key used to store the field extension data for any `<FieldExtension />` component
* @public
*/
export const FIELD_EXTENSION_KEY = 'scaffolder.extensions.field.v1';
/**
* A type used to wrap up the FieldExtension to embed the ReturnValue and the InputProps
*
* @public
*/
export type FieldExtensionComponent<_TReturnValue, _TInputProps> = () => null;
@@ -19,13 +19,17 @@ import { JsonObject } from '@backstage/types';
import { Draft07 as JSONSchema } from 'json-schema-library';
import { ParsedTemplateSchema } from '../../hooks/useTemplateSchema';
interface ReviewStateProps {
/**
* The props for the {@link ReviewState} component.
* @alpha
*/
export type ReviewStateProps = {
schemas: ParsedTemplateSchema[];
formState: JsonObject;
}
};
/**
* The ReviewState component used by the Stepper
* The component used by the {@link Stepper} to render the review step.
* @alpha
*/
export const ReviewState = (props: ReviewStateProps) => {
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { ReviewState } from './ReviewState';
export { ReviewState, type ReviewStateProps } from './ReviewState';
@@ -54,6 +54,10 @@ const useStyles = makeStyles(theme => ({
},
}));
/**
* The Props for {@link Stepper} component
* @alpha
*/
export type StepperProps = {
manifest: TemplateParameterSchema;
extensions: NextFieldExtensionOptions<any, any>[];
@@ -67,6 +71,7 @@ export type StepperProps = {
const Form = withTheme(require('@rjsf/material-ui-v5').Theme);
/**
* The `Stepper` component is the Wizard that is rendered when a user selects a template
* @alpha
*/
export const Stepper = (props: StepperProps) => {
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { Stepper } from './Stepper';
export { Stepper, type StepperProps } from './Stepper';
@@ -83,7 +83,7 @@ const useStyles = makeStyles<BackstageTheme>(theme => ({
}));
/**
* The Props for the Template Card component
* The Props for the {@link TemplateCard} component
* @alpha
*/
export interface TemplateCardProps {
@@ -92,7 +92,7 @@ export interface TemplateCardProps {
}
/**
* The Template Card component that is rendered in a list for each template
* The `TemplateCard` component that is rendered in a list for each template
* @alpha
*/
export const TemplateCard = (props: TemplateCardProps) => {
@@ -13,5 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { TemplateCard } from './TemplateCard';
export type { TemplateCardProps } from './TemplateCard';
export { TemplateCard, type TemplateCardProps } from './TemplateCard';
@@ -25,6 +25,10 @@ import { Typography } from '@material-ui/core';
import { stringifyEntityRef } from '@backstage/catalog-model';
import { TemplateCardProps, TemplateCard } from '../TemplateCard';
/**
* The props for the {@link TemplateGroup} component.
* @alpha
*/
export interface TemplateGroupProps {
templates: TemplateEntityV1beta3[];
title: React.ReactNode;
@@ -33,6 +37,10 @@ export interface TemplateGroupProps {
};
}
/**
* The `TemplateGroup` component is used to display a group of templates with a title.
* @alpha
*/
export const TemplateGroup = (props: TemplateGroupProps) => {
const { templates, title, components: { CardComponent } = {} } = props;
const titleComponent =
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { TemplateGroup } from './TemplateGroup';
export { TemplateGroup, type TemplateGroupProps } from './TemplateGroup';
@@ -0,0 +1,20 @@
/*
* 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 { useFormData } from './useFormData';
export {
useTemplateSchema,
type ParsedTemplateSchema,
} from './useTemplateSchema';
@@ -17,6 +17,10 @@
import qs from 'qs';
import { useState } from 'react';
/**
* This hook is used to get the formData from the query string.
* @alpha
*/
export const useFormData = () => {
return useState<Record<string, any>>(() => {
const query = qs.parse(window.location.search, {
@@ -19,6 +19,10 @@ import { UiSchema } from '@rjsf/utils';
import { TemplateParameterSchema } from '../../types';
import { extractSchemaFromStep } from '../lib';
/**
* This is the parsed template schema that is returned from the {@link useTemplateSchema} hook.
* @alpha
*/
export interface ParsedTemplateSchema {
uiSchema: UiSchema;
mergedSchema: JsonObject;
@@ -27,6 +31,12 @@ export interface ParsedTemplateSchema {
description?: string;
}
/**
* This hook will parse the template schema and return the steps with the
* parsed schema and uiSchema. Filtering out any steps or properties that
* are not enabled with feature flags.
* @alpha
*/
export const useTemplateSchema = (
manifest: TemplateParameterSchema,
): { steps: ParsedTemplateSchema[] } => {
@@ -17,3 +17,4 @@ export * from './components';
export * from './extensions';
export * from './types';
export * from './lib';
export * from './hooks';
@@ -99,8 +99,8 @@ function extractUiSchema(schema: JsonObject, uiSchema: JsonObject) {
}
/**
* @alpha
* Takes a step from a Backstage Template Manifest and converts it to a JSON Schema and UI Schema for rjsf
* @alpha
*/
export const extractSchemaFromStep = (
inputStep: JsonObject,
@@ -112,8 +112,8 @@ export const extractSchemaFromStep = (
};
/**
* @alpha
* Creates a field validation object for use in react jsonschema form
* @alpha
*/
export const createFieldValidation = (): FieldValidation => {
const fieldValidation: FieldValidation = {
+8
View File
@@ -19,11 +19,13 @@ import {
createSubRouteRef,
} from '@backstage/core-plugin-api';
/** @public */
export const registerComponentRouteRef = createExternalRouteRef({
id: 'register-component',
optional: true,
});
/** @public */
export const viewTechDocRouteRef = createExternalRouteRef({
id: 'view-techdoc',
optional: true,
@@ -37,6 +39,7 @@ export const rootRouteRef = createRouteRef({
/**
* @deprecated This is the old template route, can be deleted before next major release
* @public
*/
export const legacySelectedTemplateRouteRef = createSubRouteRef({
id: 'scaffolder/legacy/selected-template',
@@ -63,30 +66,35 @@ export const nextSelectedTemplateRouteRef = createSubRouteRef({
path: '/templates/:namespace/:templateName',
});
/** @public */
export const scaffolderTaskRouteRef = createSubRouteRef({
id: 'scaffolder/task',
parent: rootRouteRef,
path: '/tasks/:taskId',
});
/** @alpha */
export const nextScaffolderTaskRouteRef = createSubRouteRef({
id: 'scaffolder/next/task',
parent: nextRouteRef,
path: '/tasks/:taskId',
});
/** @public */
export const scaffolderListTaskRouteRef = createSubRouteRef({
id: 'scaffolder/list-tasks',
parent: rootRouteRef,
path: '/tasks',
});
/** @public */
export const actionsRouteRef = createSubRouteRef({
id: 'scaffolder/actions',
parent: rootRouteRef,
path: '/actions',
});
/** @public */
export const editRouteRef = createSubRouteRef({
id: 'scaffolder/edit',
parent: rootRouteRef,