chore: fixing up the types to actually be correct and use the returnValue types

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-03-01 10:40:48 +01:00
parent 2d5783aa5b
commit 194011ce84
7 changed files with 77 additions and 52 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
'@backstage/plugin-scaffolder': minor
---
**BREAKING**: Removing the exports of the raw components that back the `CustomFieldExtensions`.
+22 -16
View File
@@ -28,16 +28,13 @@ import { ScmIntegrationRegistry } from '@backstage/integration';
import { TaskSpec } from '@backstage/plugin-scaffolder-common';
import { TemplateEntityV1beta2 } from '@backstage/plugin-scaffolder-common';
// Warning: (ae-forgotten-export) The symbol "FieldExtensionComponent" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "createScaffolderFieldExtension" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
// @public
export function createScaffolderFieldExtension<
TReturnValue = unknown,
TInputProps = unknown,
>(
options: FieldExtensionOptions<TReturnValue, TInputProps>,
): Extension<FieldExtensionComponent<TInputProps>>;
): Extension<FieldExtensionComponent<TReturnValue, TInputProps>>;
// @public
export type CustomFieldValidator<TFieldReturnValue> = (
@@ -52,14 +49,16 @@ export type CustomFieldValidator<TFieldReturnValue> = (
//
// @public (undocumented)
export const EntityNamePickerFieldExtension: FieldExtensionComponent<
FieldExtensionComponentProps<string, {}>
string,
{}
>;
// Warning: (ae-missing-release-tag) "EntityPickerFieldExtension" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityPickerFieldExtension: FieldExtensionComponent<
FieldExtensionComponentProps<string, EntityPickerUiOptions>
string,
EntityPickerUiOptions
>;
// Warning: (ae-missing-release-tag) "EntityPickerUiOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -76,7 +75,8 @@ export interface EntityPickerUiOptions {
// @public
export const EntityTagsPickerFieldExtension: FieldExtensionComponent<
FieldExtensionComponentProps<string[], EntityTagsPickerUiOptions>
string[],
EntityTagsPickerUiOptions
>;
// Warning: (ae-missing-release-tag) "EntityTagsPickerUiOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -93,6 +93,9 @@ export interface EntityTagsPickerUiOptions {
// @public
export const FavouriteTemplate: (props: Props) => JSX.Element;
// @public
export type FieldExtensionComponent<_TReturnValue, _TInputProps> = () => null;
// @public
export interface FieldExtensionComponentProps<
TFieldReturnValue,
@@ -107,10 +110,12 @@ export interface FieldExtensionComponentProps<
// @public
export type FieldExtensionOptions<
TFieldReturnValue = unknown,
TProps = FieldProps<TFieldReturnValue>,
TInputProps = unknown,
> = {
name: string;
component: (props: TProps) => JSX.Element | null;
component: (
props: FieldExtensionComponentProps<TFieldReturnValue, TInputProps>,
) => JSX.Element | null;
validation?: CustomFieldValidator<TFieldReturnValue>;
};
@@ -150,7 +155,8 @@ export type LogEvent = {
//
// @public (undocumented)
export const OwnedEntityPickerFieldExtension: FieldExtensionComponent<
FieldExtensionComponentProps<string, OwnedEntityPickerUiOptions>
string,
OwnedEntityPickerUiOptions
>;
// Warning: (ae-missing-release-tag) "OwnedEntityPickerUiOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -167,7 +173,8 @@ export interface OwnedEntityPickerUiOptions {
//
// @public (undocumented)
export const OwnerPickerFieldExtension: FieldExtensionComponent<
FieldExtensionComponentProps<string, OwnerPickerUiOptions>
string,
OwnerPickerUiOptions
>;
// Warning: (ae-missing-release-tag) "OwnerPickerUiOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -193,7 +200,8 @@ export const repoPickerValidation: (
//
// @public (undocumented)
export const RepoUrlPickerFieldExtension: FieldExtensionComponent<
FieldExtensionComponentProps<string, RepoUrlPickerUiOptions>
string,
RepoUrlPickerUiOptions
>;
// Warning: (ae-missing-release-tag) "RepoUrlPickerUiOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -291,9 +299,7 @@ export class ScaffolderClient implements ScaffolderApi {
streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent>;
}
// Warning: (ae-missing-release-tag) "ScaffolderFieldExtensions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
// @public
export const ScaffolderFieldExtensions: React_2.ComponentType;
// Warning: (ae-missing-release-tag) "ScaffolderGetIntegrationsListOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -109,7 +109,7 @@ export const createValidator = (
export const TemplatePage = ({
customFieldExtensions = [],
}: {
customFieldExtensions?: FieldExtensionOptions[];
customFieldExtensions?: FieldExtensionOptions<any, any>[];
}) => {
const apiHolder = useApiHolder();
const secretsContext = useContext(SecretsContext);
+28 -30
View File
@@ -20,35 +20,33 @@ import { EntityTagsPicker } from '../components/fields/EntityTagsPicker/EntityTa
import { OwnerPicker } from '../components/fields/OwnerPicker/OwnerPicker';
import { RepoUrlPicker } from '../components/fields/RepoUrlPicker/RepoUrlPicker';
import { repoPickerValidation } from '../components/fields/RepoUrlPicker/validation';
import { FieldExtensionOptions } from './types';
import { OwnedEntityPicker } from '../components/fields/OwnedEntityPicker/OwnedEntityPicker';
export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS: FieldExtensionOptions<any>[] =
[
{
component: EntityPicker,
name: 'EntityPicker',
},
{
component: EntityNamePicker,
name: 'EntityNamePicker',
validation: entityNamePickerValidation,
},
{
component: EntityTagsPicker,
name: 'EntityTagsPicker',
},
{
component: RepoUrlPicker,
name: 'RepoUrlPicker',
validation: repoPickerValidation,
},
{
component: OwnerPicker,
name: 'OwnerPicker',
},
{
component: OwnedEntityPicker,
name: 'OwnedEntityPicker',
},
];
export const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [
{
component: EntityPicker,
name: 'EntityPicker',
},
{
component: EntityNamePicker,
name: 'EntityNamePicker',
validation: entityNamePickerValidation,
},
{
component: EntityTagsPicker,
name: 'EntityTagsPicker',
},
{
component: RepoUrlPicker,
name: 'RepoUrlPicker',
validation: repoPickerValidation,
},
{
component: OwnerPicker,
name: 'OwnerPicker',
},
{
component: OwnedEntityPicker,
name: 'OwnedEntityPicker',
},
];
@@ -25,8 +25,18 @@ import { Extension, attachComponentData } from '@backstage/core-plugin-api';
export const FIELD_EXTENSION_WRAPPER_KEY = 'scaffolder.extensions.wrapper.v1';
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;
/**
* Method for creating field extensions that can be used in the scaffolder
* frontend form.
* @public
*/
export function createScaffolderFieldExtension<
TReturnValue = unknown,
TInputProps = unknown,
@@ -48,6 +58,11 @@ export function createScaffolderFieldExtension<
};
}
/**
* The Wrapping component for defining fields extensions inside
*
* @public
*/
export const ScaffolderFieldExtensions: React.ComponentType =
(): JSX.Element | null => null;
+4 -2
View File
@@ -35,10 +35,12 @@ export type CustomFieldValidator<TFieldReturnValue> = (
*/
export type FieldExtensionOptions<
TFieldReturnValue = unknown,
TProps = FieldProps<TFieldReturnValue>,
TInputProps = unknown,
> = {
name: string;
component: (props: TProps) => JSX.Element | null;
component: (
props: FieldExtensionComponentProps<TFieldReturnValue, TInputProps>,
) => JSX.Element | null;
validation?: CustomFieldValidator<TFieldReturnValue>;
};
+6 -2
View File
@@ -40,7 +40,12 @@ export {
createScaffolderFieldExtension,
ScaffolderFieldExtensions,
} from './extensions';
export type {
CustomFieldValidator,
FieldExtensionOptions,
FieldExtensionComponentProps,
FieldExtensionComponent,
} from './extensions';
export {
EntityPickerFieldExtension,
EntityNamePickerFieldExtension,
@@ -52,5 +57,4 @@ export {
scaffolderPlugin,
} from './plugin';
export * from './components';
export * from './extensions';
export type { TaskPageProps } from './components/TaskPage';