chore: simplify the types a little bit
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
```ts
|
||||
import { Config } from '@backstage/config';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
import { UrlReader } from '@backstage/backend-common';
|
||||
@@ -18,6 +19,6 @@ export const createConfluenceToMarkdownAction: (options: {
|
||||
confluenceUrls: string[];
|
||||
repoUrl: string;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
```
|
||||
|
||||
@@ -25,6 +25,6 @@ export function createFetchCookiecutterAction(options: {
|
||||
extensions?: string[] | undefined;
|
||||
imageName?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
```
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
|
||||
@@ -18,7 +19,7 @@ export const createGitlabProjectAccessTokenAction: (options: {
|
||||
scopes: string[];
|
||||
token?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -33,7 +34,7 @@ export const createGitlabProjectDeployTokenAction: (options: {
|
||||
scopes: string[];
|
||||
token?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -52,6 +53,6 @@ export const createGitlabProjectVariableAction: (options: {
|
||||
environmentScope: string;
|
||||
token?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
```
|
||||
|
||||
@@ -22,6 +22,6 @@ export function createFetchRailsAction(options: {
|
||||
values: JsonObject;
|
||||
imageName?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
```
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
```ts
|
||||
import { Config } from '@backstage/config';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
|
||||
// @public
|
||||
@@ -17,7 +18,7 @@ export function createSentryCreateProjectAction(options: {
|
||||
slug?: string | undefined;
|
||||
authToken?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
@@ -13,6 +13,6 @@ export function createRunYeomanAction(): TemplateAction<
|
||||
args?: string[] | undefined;
|
||||
options?: JsonObject | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
```
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import { ActionContext as ActionContext_2 } from '@backstage/plugin-scaffolder-node';
|
||||
import { ActionOutputType } from '@backstage/plugin-scaffolder-node';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { CatalogProcessor } from '@backstage/plugin-catalog-node';
|
||||
import { CatalogProcessorEmit } from '@backstage/plugin-catalog-node';
|
||||
@@ -80,16 +79,18 @@ export function createCatalogRegisterAction(options: {
|
||||
catalogInfoPath?: string | undefined;
|
||||
optional?: boolean | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
export function createCatalogWriteAction(): TemplateAction_2<
|
||||
{
|
||||
entity: {} & {
|
||||
[k: string]: unknown;
|
||||
};
|
||||
filePath?: string | undefined;
|
||||
entity: {};
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -98,7 +99,7 @@ export function createDebugLogAction(): TemplateAction_2<
|
||||
message?: string | undefined;
|
||||
listWorkspace?: boolean | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -106,13 +107,13 @@ export function createFetchCatalogEntityAction(options: {
|
||||
catalogClient: CatalogApi;
|
||||
}): TemplateAction_2<
|
||||
{
|
||||
optional?: boolean | undefined;
|
||||
entityRef?: string | undefined;
|
||||
entityRefs?: string[] | undefined;
|
||||
optional?: boolean | undefined;
|
||||
},
|
||||
{
|
||||
entities?: any[] | undefined;
|
||||
entity?: any;
|
||||
entities?: any[] | undefined;
|
||||
}
|
||||
>;
|
||||
|
||||
@@ -125,7 +126,7 @@ export function createFetchPlainAction(options: {
|
||||
url: string;
|
||||
targetPath?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -137,7 +138,7 @@ export function createFetchPlainFileAction(options: {
|
||||
url: string;
|
||||
targetPath: string;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -157,7 +158,7 @@ export function createFetchTemplateAction(options: {
|
||||
cookiecutterCompat?: boolean | undefined;
|
||||
replace?: boolean | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -165,7 +166,7 @@ export const createFilesystemDeleteAction: () => TemplateAction_2<
|
||||
{
|
||||
files: string[];
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -177,7 +178,7 @@ export const createFilesystemRenameAction: () => TemplateAction_2<
|
||||
overwrite?: boolean;
|
||||
}>;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -196,7 +197,7 @@ export function createGithubActionsDispatchAction(options: {
|
||||
| undefined;
|
||||
token?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -210,7 +211,7 @@ export function createGithubIssuesLabelAction(options: {
|
||||
labels: string[];
|
||||
token?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -298,7 +299,7 @@ export function createGithubRepoCreateAction(options: {
|
||||
topics?: string[] | undefined;
|
||||
requireCommitSigning?: boolean | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -340,7 +341,7 @@ export function createGithubRepoPushAction(options: {
|
||||
token?: string | undefined;
|
||||
requiredCommitSigning?: boolean | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -359,7 +360,7 @@ export function createGithubWebhookAction(options: {
|
||||
insecureSsl?: boolean | undefined;
|
||||
token?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -377,7 +378,7 @@ export function createPublishAzureAction(options: {
|
||||
gitAuthorName?: string | undefined;
|
||||
gitAuthorEmail?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public @deprecated
|
||||
@@ -397,7 +398,7 @@ export function createPublishBitbucketAction(options: {
|
||||
gitAuthorName?: string | undefined;
|
||||
gitAuthorEmail?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -413,7 +414,7 @@ export function createPublishBitbucketCloudAction(options: {
|
||||
sourcePath?: string | undefined;
|
||||
token?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -433,7 +434,7 @@ export function createPublishBitbucketServerAction(options: {
|
||||
gitAuthorName?: string | undefined;
|
||||
gitAuthorEmail?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -450,7 +451,7 @@ export function createPublishGerritAction(options: {
|
||||
gitAuthorEmail?: string | undefined;
|
||||
sourcePath?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -466,7 +467,7 @@ export function createPublishGerritReviewAction(options: {
|
||||
gitAuthorName?: string | undefined;
|
||||
gitAuthorEmail?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -542,7 +543,7 @@ export function createPublishGithubAction(options: {
|
||||
topics?: string[] | undefined;
|
||||
requiredCommitSigning?: boolean | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -561,7 +562,7 @@ export const createPublishGithubPullRequestAction: (
|
||||
reviewers?: string[] | undefined;
|
||||
teamReviewers?: string[] | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -581,7 +582,7 @@ export function createPublishGitlabAction(options: {
|
||||
setUserAsOwner?: boolean | undefined;
|
||||
topics?: string[] | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -601,7 +602,7 @@ export const createPublishGitlabMergeRequestAction: (options: {
|
||||
removeSourceBranch?: boolean | undefined;
|
||||
assignee?: string | undefined;
|
||||
},
|
||||
unknown
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
// @public
|
||||
@@ -609,30 +610,29 @@ export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export const createTemplateAction: <
|
||||
TInputParams,
|
||||
TOutputParams = unknown,
|
||||
TInputParams extends JsonObject = JsonObject,
|
||||
TOutputParams extends JsonObject = JsonObject,
|
||||
TInputSchema extends ZodType<any, ZodTypeDef, any> | Schema = {},
|
||||
TOutputSchema extends ZodType<any, ZodTypeDef, any> | Schema = {},
|
||||
TActionInput = TInputSchema extends ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TInputParams,
|
||||
TActionOutput extends ActionOutputType<
|
||||
TOutputSchema,
|
||||
TOutputParams
|
||||
> = ActionOutputType<TOutputSchema, TOutputParams>,
|
||||
TActionOutput = TOutputSchema extends ZodType<any, any, infer IReturn_1>
|
||||
? IReturn_1
|
||||
: TOutputParams,
|
||||
>(
|
||||
action: TemplateActionOptions<
|
||||
TActionInput,
|
||||
TActionOutput,
|
||||
TInputSchema,
|
||||
TOutputSchema,
|
||||
TActionOutput
|
||||
TOutputSchema
|
||||
>,
|
||||
) => TemplateAction_2<TActionInput, TActionOutput>;
|
||||
|
||||
// @public
|
||||
export function createWaitAction(options?: {
|
||||
maxWaitTime?: Duration | HumanDuration;
|
||||
}): TemplateAction_2<HumanDuration, unknown>;
|
||||
}): TemplateAction_2<HumanDuration, JsonObject>;
|
||||
|
||||
// @public
|
||||
export type CreateWorkerOptions = {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import { ExtensionPoint } from '@backstage/backend-plugin-api';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import { Logger } from 'winston';
|
||||
import { Schema } from 'jsonschema';
|
||||
import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
|
||||
@@ -18,24 +17,16 @@ import { z } from 'zod';
|
||||
// @public
|
||||
export type ActionContext<
|
||||
TActionInput extends JsonObject,
|
||||
TActionOutput extends JsonObject | unknown | undefined = unknown,
|
||||
TActionOutput extends JsonObject = JsonObject,
|
||||
> = {
|
||||
logger: Logger;
|
||||
logStream: Writable;
|
||||
secrets?: TaskSecrets;
|
||||
workspacePath: string;
|
||||
input: TActionInput;
|
||||
output<KEY extends keyof TActionOutput>(
|
||||
name: TActionOutput extends JsonObject
|
||||
? KEY
|
||||
: TActionOutput extends undefined
|
||||
? never
|
||||
: string,
|
||||
value: TActionOutput extends JsonObject
|
||||
? TActionOutput[KEY]
|
||||
: TActionOutput extends undefined
|
||||
? never
|
||||
: JsonValue,
|
||||
output(
|
||||
name: keyof TActionOutput,
|
||||
value: TActionOutput[keyof TActionOutput],
|
||||
): void;
|
||||
createTemporaryDirectory(): Promise<string>;
|
||||
templateInfo?: TemplateInfo;
|
||||
@@ -47,35 +38,24 @@ export type ActionContext<
|
||||
signal?: AbortSignal;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type ActionOutputType<
|
||||
TOutputSchema,
|
||||
FallbackOutput = unknown,
|
||||
> = TOutputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TOutputSchema extends undefined
|
||||
? undefined
|
||||
: FallbackOutput;
|
||||
|
||||
// @public
|
||||
export const createTemplateAction: <
|
||||
TInputParams,
|
||||
TOutputParams = unknown,
|
||||
TInputParams extends JsonObject = JsonObject,
|
||||
TOutputParams extends JsonObject = JsonObject,
|
||||
TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {},
|
||||
TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {},
|
||||
TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TInputParams,
|
||||
TActionOutput extends ActionOutputType<
|
||||
TOutputSchema,
|
||||
TOutputParams
|
||||
> = ActionOutputType<TOutputSchema, TOutputParams>,
|
||||
TActionOutput = TOutputSchema extends z.ZodType<any, any, infer IReturn_1>
|
||||
? IReturn_1
|
||||
: TOutputParams,
|
||||
>(
|
||||
action: TemplateActionOptions<
|
||||
TActionInput,
|
||||
TActionOutput,
|
||||
TInputSchema,
|
||||
TOutputSchema,
|
||||
TActionOutput
|
||||
TOutputSchema
|
||||
>,
|
||||
) => TemplateAction<TActionInput, TActionOutput>;
|
||||
|
||||
@@ -94,7 +74,10 @@ export type TaskSecrets = Record<string, string> & {
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type TemplateAction<TActionInput = unknown, TActionOutput = unknown> = {
|
||||
export type TemplateAction<
|
||||
TActionInput = unknown,
|
||||
TActionOutput = JsonObject,
|
||||
> = {
|
||||
id: string;
|
||||
description?: string;
|
||||
examples?: {
|
||||
@@ -112,9 +95,9 @@ export type TemplateAction<TActionInput = unknown, TActionOutput = unknown> = {
|
||||
// @public (undocumented)
|
||||
export type TemplateActionOptions<
|
||||
TActionInput = {},
|
||||
TActionOutput = {},
|
||||
TInputSchema extends Schema | z.ZodType = {},
|
||||
TOutputSchema extends Schema | z.ZodType = {},
|
||||
TActionOutput extends ActionOutputType<TOutputSchema> = ActionOutputType<TOutputSchema>,
|
||||
> = {
|
||||
id: string;
|
||||
description?: string;
|
||||
|
||||
@@ -18,23 +18,14 @@ import { ActionContext, TemplateAction } from './types';
|
||||
import { z } from 'zod';
|
||||
import { Schema } from 'jsonschema';
|
||||
import zodToJsonSchema from 'zod-to-json-schema';
|
||||
|
||||
/** @public */
|
||||
export type ActionOutputType<
|
||||
TOutputSchema,
|
||||
FallbackOutput = unknown,
|
||||
> = TOutputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TOutputSchema extends undefined
|
||||
? undefined
|
||||
: FallbackOutput;
|
||||
import { JsonObject } from '@backstage/types';
|
||||
|
||||
/** @public */
|
||||
export type TemplateActionOptions<
|
||||
TActionInput = {},
|
||||
TActionOutput = {},
|
||||
TInputSchema extends Schema | z.ZodType = {},
|
||||
TOutputSchema extends Schema | z.ZodType = {},
|
||||
TActionOutput extends ActionOutputType<TOutputSchema> = ActionOutputType<TOutputSchema>,
|
||||
> = {
|
||||
id: string;
|
||||
description?: string;
|
||||
@@ -53,23 +44,22 @@ export type TemplateActionOptions<
|
||||
* @public
|
||||
*/
|
||||
export const createTemplateAction = <
|
||||
TInputParams,
|
||||
TOutputParams = unknown,
|
||||
TInputParams extends JsonObject = JsonObject,
|
||||
TOutputParams extends JsonObject = JsonObject,
|
||||
TInputSchema extends Schema | z.ZodType = {},
|
||||
TOutputSchema extends Schema | z.ZodType = {},
|
||||
TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TInputParams,
|
||||
TActionOutput extends ActionOutputType<
|
||||
TOutputSchema,
|
||||
TOutputParams
|
||||
> = ActionOutputType<TOutputSchema, TOutputParams>,
|
||||
TActionOutput = TOutputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TOutputParams,
|
||||
>(
|
||||
action: TemplateActionOptions<
|
||||
TActionInput,
|
||||
TActionOutput,
|
||||
TInputSchema,
|
||||
TOutputSchema,
|
||||
TActionOutput
|
||||
TOutputSchema
|
||||
>,
|
||||
): TemplateAction<TActionInput, TActionOutput> => {
|
||||
const inputSchema =
|
||||
|
||||
@@ -17,6 +17,5 @@
|
||||
export {
|
||||
createTemplateAction,
|
||||
type TemplateActionOptions,
|
||||
type ActionOutputType,
|
||||
} from './createTemplateAction';
|
||||
export { type ActionContext, type TemplateAction } from './types';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import { Logger } from 'winston';
|
||||
import { Writable } from 'stream';
|
||||
import { JsonObject, JsonValue } from '@backstage/types';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { TaskSecrets } from '../tasks';
|
||||
import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
|
||||
import { UserEntity } from '@backstage/catalog-model';
|
||||
@@ -28,24 +28,16 @@ import { Schema } from 'jsonschema';
|
||||
*/
|
||||
export type ActionContext<
|
||||
TActionInput extends JsonObject,
|
||||
TActionOutput extends JsonObject | unknown | undefined = unknown,
|
||||
TActionOutput extends JsonObject = JsonObject,
|
||||
> = {
|
||||
logger: Logger;
|
||||
logStream: Writable;
|
||||
secrets?: TaskSecrets;
|
||||
workspacePath: string;
|
||||
input: TActionInput;
|
||||
output<KEY extends keyof TActionOutput>(
|
||||
name: TActionOutput extends JsonObject
|
||||
? KEY
|
||||
: TActionOutput extends undefined
|
||||
? never
|
||||
: string,
|
||||
value: TActionOutput extends JsonObject
|
||||
? TActionOutput[KEY]
|
||||
: TActionOutput extends undefined
|
||||
? never
|
||||
: JsonValue,
|
||||
output(
|
||||
name: keyof TActionOutput,
|
||||
value: TActionOutput[keyof TActionOutput],
|
||||
): void;
|
||||
|
||||
/**
|
||||
@@ -82,7 +74,10 @@ export type ActionContext<
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type TemplateAction<TActionInput = unknown, TActionOutput = unknown> = {
|
||||
export type TemplateAction<
|
||||
TActionInput = unknown,
|
||||
TActionOutput = JsonObject,
|
||||
> = {
|
||||
id: string;
|
||||
description?: string;
|
||||
examples?: { description: string; example: string }[];
|
||||
|
||||
Reference in New Issue
Block a user