@@ -12,6 +12,7 @@ import type { Handler } from 'express';
|
||||
import { HumanDuration } from '@backstage/types';
|
||||
import { isChildPath } from '@backstage/cli-common';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import { Knex } from 'knex';
|
||||
import { Permission } from '@backstage/plugin-permission-common';
|
||||
@@ -25,6 +26,72 @@ import { QueryPermissionResponse } from '@backstage/plugin-permission-common';
|
||||
import { Readable } from 'stream';
|
||||
import type { Request as Request_2 } from 'express';
|
||||
import type { Response as Response_2 } from 'express';
|
||||
import { z } from 'zod';
|
||||
import { ZodType } from 'zod';
|
||||
|
||||
// @public (undocumented)
|
||||
export type ActionsRegistryActionContext<TInputSchema extends ZodType> = {
|
||||
input: z.infer<TInputSchema>;
|
||||
logger: LoggerService;
|
||||
credentials: BackstageCredentials;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type ActionsRegistryActionOptions<
|
||||
TInputSchema extends ZodType,
|
||||
TOutputSchema extends ZodType,
|
||||
> = {
|
||||
name: string;
|
||||
title: string;
|
||||
description: string;
|
||||
schema?: {
|
||||
input?: (zod: typeof z) => TInputSchema;
|
||||
output?: (zod: typeof z) => TOutputSchema;
|
||||
};
|
||||
action: (context: ActionsRegistryActionContext<TInputSchema>) => Promise<
|
||||
TOutputSchema extends ZodType
|
||||
? {
|
||||
output: z.infer<TOutputSchema>;
|
||||
}
|
||||
: void
|
||||
>;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ActionsRegistryService {
|
||||
// (undocumented)
|
||||
register<TInputSchema extends ZodType, TOutputSchema extends ZodType>(
|
||||
options: ActionsRegistryActionOptions<TInputSchema, TOutputSchema>,
|
||||
): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ActionsService {
|
||||
// (undocumented)
|
||||
invokeAction(opts: {
|
||||
id: string;
|
||||
input?: JsonObject;
|
||||
credentials: BackstageCredentials;
|
||||
}): Promise<{
|
||||
output: JsonValue;
|
||||
}>;
|
||||
// (undocumented)
|
||||
listActions: (opts: { credentials: BackstageCredentials }) => Promise<{
|
||||
actions: ActionsServiceAction[];
|
||||
}>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type ActionsServiceAction = {
|
||||
id: string;
|
||||
name: string;
|
||||
title: string;
|
||||
description: string;
|
||||
schema?: {
|
||||
input?: JSONSchema7;
|
||||
output?: JSONSchema7;
|
||||
};
|
||||
};
|
||||
|
||||
// @public
|
||||
export interface AuditorService {
|
||||
@@ -205,6 +272,12 @@ export type CacheServiceSetOptions = {
|
||||
// @public
|
||||
export namespace coreServices {
|
||||
const auth: ServiceRef<AuthService, 'plugin', 'singleton'>;
|
||||
const actions: ServiceRef<ActionsService, 'plugin', 'singleton'>;
|
||||
const actionsRegistry: ServiceRef<
|
||||
ActionsRegistryService,
|
||||
'plugin',
|
||||
'singleton'
|
||||
>;
|
||||
const userInfo: ServiceRef<UserInfoService, 'plugin', 'singleton'>;
|
||||
const cache: ServiceRef<CacheService, 'plugin', 'singleton'>;
|
||||
const rootConfig: ServiceRef<RootConfigService, 'root', 'singleton'>;
|
||||
|
||||
@@ -17,12 +17,18 @@ import { z, ZodType } from 'zod';
|
||||
import { LoggerService } from './LoggerService';
|
||||
import { BackstageCredentials } from './AuthService';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ActionsRegistryActionContext<TInputSchema extends ZodType> = {
|
||||
input: z.infer<TInputSchema>;
|
||||
logger: LoggerService;
|
||||
credentials: BackstageCredentials;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ActionsRegistryActionOptions<
|
||||
TInputSchema extends ZodType,
|
||||
TOutputSchema extends ZodType,
|
||||
@@ -41,6 +47,9 @@ export type ActionsRegistryActionOptions<
|
||||
>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ActionsRegistryService {
|
||||
register<TInputSchema extends ZodType, TOutputSchema extends ZodType>(
|
||||
options: ActionsRegistryActionOptions<TInputSchema, TOutputSchema>,
|
||||
|
||||
@@ -17,6 +17,9 @@ import { JsonObject, JsonValue } from '@backstage/types';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { BackstageCredentials } from './AuthService';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ActionsServiceAction = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -28,6 +31,9 @@ export type ActionsServiceAction = {
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ActionsService {
|
||||
listActions: (opts: {
|
||||
credentials: BackstageCredentials;
|
||||
|
||||
Reference in New Issue
Block a user