feat: small tidy up and moving things around into alpha exports for actions and actions registry
Signed-off-by: benjdlambert <ben@blam.sh> Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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';
|
||||
import {
|
||||
LoggerService,
|
||||
BackstageCredentials,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
*/
|
||||
export type ActionsRegistryActionContext<TInputSchema extends AnyZodObject> = {
|
||||
input: z.infer<TInputSchema>;
|
||||
logger: LoggerService;
|
||||
credentials: BackstageCredentials;
|
||||
};
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
*/
|
||||
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;
|
||||
};
|
||||
attributes?: {
|
||||
destructive?: boolean;
|
||||
idempotent?: boolean;
|
||||
readOnly?: boolean;
|
||||
};
|
||||
action: (
|
||||
context: ActionsRegistryActionContext<TInputSchema>,
|
||||
) => Promise<
|
||||
z.infer<TOutputSchema> extends void
|
||||
? void
|
||||
: { output: z.infer<TOutputSchema> }
|
||||
>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
*/
|
||||
export interface ActionsRegistryService {
|
||||
register<
|
||||
TInputSchema extends AnyZodObject,
|
||||
TOutputSchema extends AnyZodObject,
|
||||
>(
|
||||
options: ActionsRegistryActionOptions<TInputSchema, TOutputSchema>,
|
||||
): void;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
*/
|
||||
export type ActionsServiceAction = {
|
||||
id: string;
|
||||
name: string;
|
||||
title: string;
|
||||
description: string;
|
||||
schema: {
|
||||
input: JSONSchema7;
|
||||
output: JSONSchema7;
|
||||
};
|
||||
attributes: {
|
||||
readOnly: boolean;
|
||||
destructive: boolean;
|
||||
idempotent: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
*/
|
||||
export interface ActionsService {
|
||||
list: (opts: {
|
||||
credentials: BackstageCredentials;
|
||||
}) => Promise<{ actions: ActionsServiceAction[] }>;
|
||||
invoke(opts: {
|
||||
id: string;
|
||||
input?: JsonObject;
|
||||
credentials: BackstageCredentials;
|
||||
}): Promise<{ output: JsonValue }>;
|
||||
}
|
||||
+16
-15
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
* 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.
|
||||
@@ -14,20 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createServiceRef } from '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* EXPERIMENTAL: Instance metadata service.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export const instanceMetadataServiceRef = createServiceRef<
|
||||
import('./services/definitions/InstanceMetadataService').InstanceMetadataService
|
||||
>({
|
||||
id: 'core.instanceMetadata',
|
||||
});
|
||||
|
||||
export type {
|
||||
BackendFeatureMeta,
|
||||
InstanceMetadataService,
|
||||
} from './services/definitions/InstanceMetadataService';
|
||||
} from './InstanceMetadataService';
|
||||
|
||||
export type {
|
||||
ActionsRegistryService,
|
||||
ActionsRegistryActionOptions,
|
||||
ActionsRegistryActionContext,
|
||||
} from './ActionsRegistryService';
|
||||
|
||||
export type { ActionsService, ActionsServiceAction } from './ActionsService';
|
||||
|
||||
export {
|
||||
actionsRegistryServiceRef,
|
||||
actionsServiceRef,
|
||||
instanceMetadataServiceRef,
|
||||
} from './refs';
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 { createServiceRef } from '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
*/
|
||||
export const instanceMetadataServiceRef = createServiceRef<
|
||||
import('./InstanceMetadataService').InstanceMetadataService
|
||||
>({
|
||||
id: 'core.instanceMetadata',
|
||||
});
|
||||
|
||||
/**
|
||||
* Service for calling distributed actions
|
||||
*
|
||||
* See {@link ActionsService}
|
||||
* and {@link https://backstage.io/docs/backend-system/core-services/actions | the service docs}
|
||||
* for more information.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export const actionsServiceRef = createServiceRef<
|
||||
import('./ActionsService').ActionsService
|
||||
>({
|
||||
id: 'alpha.core.actions',
|
||||
});
|
||||
|
||||
/**
|
||||
* Service for registering and managing distributed actions.
|
||||
*
|
||||
* See {@link ActionsRegistryService}
|
||||
* and {@link https://backstage.io/docs/backend-system/core-services/actions-registry | the service docs}
|
||||
* for more information.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export const actionsRegistryServiceRef = createServiceRef<
|
||||
import('./ActionsRegistryService').ActionsRegistryService
|
||||
>({
|
||||
id: 'alpha.core.actionsRegistry',
|
||||
});
|
||||
@@ -35,36 +35,6 @@ export namespace coreServices {
|
||||
id: 'core.auth',
|
||||
});
|
||||
|
||||
/**
|
||||
* Service for calling distributed actions
|
||||
*
|
||||
* See {@link ActionsService}
|
||||
* and {@link https://backstage.io/docs/backend-system/core-services/actions | the service docs}
|
||||
* for more information.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const actions = createServiceRef<
|
||||
import('./ActionsService').ActionsService
|
||||
>({
|
||||
id: 'core.actions',
|
||||
});
|
||||
|
||||
/**
|
||||
* Service for registering and managing distributed actions.
|
||||
*
|
||||
* See {@link ActionsRegistryService}
|
||||
* and {@link https://backstage.io/docs/backend-system/core-services/actions-registry | the service docs}
|
||||
* for more information.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const actionsRegistry = createServiceRef<
|
||||
import('./ActionsRegistryService').ActionsRegistryService
|
||||
>({
|
||||
id: 'core.actionsRegistry',
|
||||
});
|
||||
|
||||
/**
|
||||
* Authenticated user information retrieval.
|
||||
*
|
||||
|
||||
@@ -13,14 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export type {
|
||||
ActionsRegistryService,
|
||||
ActionsRegistryActionOptions,
|
||||
ActionsRegistryActionContext,
|
||||
} from './ActionsRegistryService';
|
||||
|
||||
export type { ActionsService, ActionsServiceAction } from './ActionsService';
|
||||
export type {
|
||||
AuditorService,
|
||||
AuditorServiceCreateEventOptions,
|
||||
|
||||
Reference in New Issue
Block a user