chore: small cleanup

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-11-19 09:51:15 +01:00
parent 7e3ca8be71
commit aac1e45bc5
3 changed files with 12 additions and 19 deletions
@@ -32,11 +32,8 @@ export type ScaffolderFormDecoratorContext<TInput> = {
/** @alpha */
export type ScaffolderFormDecorator<
TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType } = {},
TDeps extends { [key in string]: AnyApiRef } = { [key in string]: AnyApiRef },
TInput extends {} = {
[key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
},
TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType },
TDeps extends { [key in string]: AnyApiRef },
> = {
version: 'v1';
id: string;
@@ -45,7 +42,9 @@ export type ScaffolderFormDecorator<
};
deps?: TDeps;
fn: (
ctx: ScaffolderFormDecoratorContext<TInput>,
ctx: ScaffolderFormDecoratorContext<{
[key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
}>,
deps: TDeps extends { [key in string]: AnyApiRef }
? { [key in keyof TDeps]: TDeps[key]['T'] }
: never,
@@ -53,22 +52,15 @@ export type ScaffolderFormDecorator<
};
/** @alpha */
export type AnyScaffolderFormDecorator = ScaffolderFormDecorator<
{ [key in string]: (zImpl: typeof z) => z.ZodType },
{ [key in string]: AnyApiRef },
any
>;
export type AnyScaffolderFormDecorator = ScaffolderFormDecorator<any, any>;
/**
* Method for creating decorators which can be used to collect
* secrets from the user before submitting to the backend.
* @alpha
*/
export function createScaffolderFormDecorator<
TDeps extends { [key in string]: AnyApiRef },
TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType },
TInput extends {} = {
[key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
},
TDeps extends { [key in string]: AnyApiRef },
>(options: {
id: string;
schema?: {
@@ -76,12 +68,14 @@ export function createScaffolderFormDecorator<
};
deps?: TDeps;
fn: (
ctx: ScaffolderFormDecoratorContext<TInput>,
ctx: ScaffolderFormDecoratorContext<{
[key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
}>,
deps: TDeps extends { [key in string]: AnyApiRef }
? { [key in keyof TDeps]: TDeps[key]['T'] }
: never,
) => Promise<void>;
}): ScaffolderFormDecorator<TInputSchema, TDeps, TInput> {
}): ScaffolderFormDecorator<TInputSchema, TDeps> {
return {
...options,
version: 'v1',
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useApi, useApiHolder } from '@backstage/core-plugin-api';
import { AnyApiRef, useApi, useApiHolder } from '@backstage/core-plugin-api';
import { formDecoratorsApiRef } from '../api/ref';
import useAsync from 'react-use/esm/useAsync';
import { useMemo } from 'react';
@@ -64,7 +64,6 @@ import {
taskReadPermission,
templateManagementPermission,
} from '@backstage/plugin-scaffolder-common/alpha';
import { ScaffolderFormHook } from '@backstage/plugin-scaffolder-react/alpha';
/**
* The Props for the Scaffolder Router