chore: nearly there, just not matching the overload

Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
benjdlambert
2025-02-28 14:00:39 +01:00
parent 3ece40f8c4
commit 6d0b7a9ce0
3 changed files with 39 additions and 29 deletions
@@ -21,6 +21,7 @@ import { createBitbucketPipelinesRunAction } from './bitbucketCloudPipelinesRun'
import { ConfigReader } from '@backstage/config';
import { ScmIntegrations } from '@backstage/integration';
import { createMockActionContext } from '@backstage/plugin-scaffolder-node-test-utils';
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
describe('bitbucket:pipelines:run', () => {
const config = new ConfigReader({
@@ -65,9 +66,11 @@ describe('bitbucket:pipelines:run', () => {
const actionNoCreds = createBitbucketPipelinesRunAction({
integrations: integrationsNoCreds,
});
const testContext = Object.assign({}, mockContext, {
input: { workspace, repo_slug },
});
await expect(actionNoCreds.handler(testContext)).rejects.toThrow(
/Authorization has not been provided for Bitbucket Cloud/,
);
@@ -30,12 +30,19 @@ export const createBitbucketPipelinesRunAction = (options: {
integrations: ScmIntegrationRegistry;
}) => {
const { integrations } = options;
return createTemplateAction<{
workspace: string;
repo_slug: string;
body?: object;
token?: string;
}>({
return createTemplateAction<
{
workspace: string;
repo_slug: string;
body?: object;
token?: string;
},
{
buildNumber: number;
repoUrl: string;
pipelinesUrl: string;
}
>({
id,
description: 'Run a bitbucket cloud pipeline',
examples,
@@ -58,7 +65,7 @@ export const createBitbucketPipelinesRunAction = (options: {
type: 'number',
},
repoUrl: {
title: 'A URL to the pipeline repositry',
title: 'A URL to the pipeline repository',
type: 'string',
},
repoContentsUrl: {
@@ -64,26 +64,6 @@ type FlattenOptionalProperties<T extends { [key in string]: unknown }> = Expand<
}
>;
/**
* @public
* @deprecated migrate to using the new built in zod schema definitions for schemas
*/
export function createTemplateAction<
TInputParams extends JsonObject = JsonObject,
TOutputParams extends JsonObject = JsonObject,
TInputSchema extends JSONSchema7 = JSONSchema7,
TOutputSchema extends JSONSchema7 = JSONSchema7,
TActionInput extends JsonObject = TInputParams,
TActionOutput extends JsonObject = TOutputParams,
>(
action: TemplateActionOptions<
TActionInput,
TActionOutput,
TInputSchema,
TOutputSchema,
'v1'
>,
): TemplateAction<TActionInput, TActionOutput, 'v1'>;
/**
* @public
* @deprecated migrate to using the new built in zod schema definitions for schemas
@@ -133,17 +113,37 @@ export function createTemplateAction<
}>,
'v2'
>;
/**
* @public
* @deprecated migrate to using the new built in zod schema definitions for schemas
*/
export function createTemplateAction<
TInputParams extends JsonObject = JsonObject,
TOutputParams extends JsonObject = JsonObject,
TInputSchema extends JSONSchema7 = JSONSchema7,
TOutputSchema extends JSONSchema7 = JSONSchema7,
TActionInput extends JsonObject = TInputParams,
TActionOutput extends JsonObject = TOutputParams,
>(
action: TemplateActionOptions<
TActionInput,
TActionOutput,
TInputSchema,
TOutputSchema,
'v1'
>,
): TemplateAction<TActionInput, TActionOutput, 'v1'>;
export function createTemplateAction<
TInputParams extends JsonObject = JsonObject,
TOutputParams extends JsonObject = JsonObject,
TInputSchema extends
| JSONSchema7
| z.ZodType
| { [key in string]: (zImpl: typeof z) => z.ZodType } = {},
| { [key in string]: (zImpl: typeof z) => z.ZodType } = JSONSchema7,
TOutputSchema extends
| JSONSchema7
| z.ZodType
| { [key in string]: (zImpl: typeof z) => z.ZodType } = {},
| { [key in string]: (zImpl: typeof z) => z.ZodType } = JSONSchema7,
TActionInput extends JsonObject = TInputSchema extends z.ZodType<
any,
any,