Merge pull request #33916 from backstage/rugvip/remove-dead-actions-service-definitions
backend-plugin-api: 🧹
This commit is contained in:
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 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.
|
||||
*/
|
||||
import { z, AnyZodObject } from 'zod/v3';
|
||||
import { BasicPermission } from '@backstage/plugin-permission-common';
|
||||
import { LoggerService } from './LoggerService';
|
||||
import { BackstageCredentials } from './AuthService';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ActionsRegistryActionContext<TInputSchema extends AnyZodObject> = {
|
||||
input: z.infer<TInputSchema>;
|
||||
logger: LoggerService;
|
||||
credentials: BackstageCredentials;
|
||||
};
|
||||
|
||||
/**
|
||||
* An example of how to use an action registered in the actions registry.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ActionsRegistryActionExample<
|
||||
TInputSchema extends AnyZodObject,
|
||||
TOutputSchema extends AnyZodObject,
|
||||
> = {
|
||||
title: string;
|
||||
description?: string;
|
||||
input: z.infer<TInputSchema>;
|
||||
output?: z.infer<TOutputSchema>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ActionsRegistryActionOptions<
|
||||
TInputSchema extends AnyZodObject,
|
||||
TOutputSchema extends AnyZodObject,
|
||||
> = {
|
||||
name: string;
|
||||
title: string;
|
||||
description: string;
|
||||
schema: {
|
||||
input: (zod: typeof z) => TInputSchema;
|
||||
output: (zod: typeof z) => TOutputSchema;
|
||||
};
|
||||
examples?: Array<ActionsRegistryActionExample<TInputSchema, TOutputSchema>>;
|
||||
visibilityPermission?: BasicPermission;
|
||||
attributes?: {
|
||||
destructive?: boolean;
|
||||
idempotent?: boolean;
|
||||
readOnly?: boolean;
|
||||
};
|
||||
action: (
|
||||
context: ActionsRegistryActionContext<TInputSchema>,
|
||||
) => Promise<
|
||||
z.infer<TOutputSchema> extends void
|
||||
? void
|
||||
: { output: z.infer<TOutputSchema> }
|
||||
>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ActionsRegistryService {
|
||||
register<
|
||||
TInputSchema extends AnyZodObject,
|
||||
TOutputSchema extends AnyZodObject,
|
||||
>(
|
||||
options: ActionsRegistryActionOptions<TInputSchema, TOutputSchema>,
|
||||
): void;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 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.
|
||||
*/
|
||||
import { JsonObject, JsonValue } from '@backstage/types';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { BackstageCredentials } from './AuthService';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ActionsServiceAction = {
|
||||
id: string;
|
||||
name: string;
|
||||
title: string;
|
||||
description: string;
|
||||
schema: {
|
||||
input: JSONSchema7;
|
||||
output: JSONSchema7;
|
||||
};
|
||||
examples?: Array<{
|
||||
title: string;
|
||||
description?: string;
|
||||
input: JsonObject;
|
||||
output?: JsonObject;
|
||||
}>;
|
||||
attributes: {
|
||||
readOnly: boolean;
|
||||
destructive: boolean;
|
||||
idempotent: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ActionsService {
|
||||
list: (opts: {
|
||||
credentials: BackstageCredentials;
|
||||
}) => Promise<{ actions: ActionsServiceAction[] }>;
|
||||
invoke(opts: {
|
||||
id: string;
|
||||
input?: JsonObject;
|
||||
credentials: BackstageCredentials;
|
||||
}): Promise<{ output: JsonValue }>;
|
||||
}
|
||||
Reference in New Issue
Block a user