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:
@@ -20,7 +20,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./alpha": "./src/alpha.ts",
|
||||
"./alpha": "./src/alpha/index.ts",
|
||||
"./testUtils": "./src/testUtils.ts",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
@@ -29,7 +29,7 @@
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"alpha": [
|
||||
"src/alpha.ts"
|
||||
"src/alpha/index.ts"
|
||||
],
|
||||
"testUtils": [
|
||||
"src/testUtils.ts"
|
||||
|
||||
@@ -3,7 +3,105 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { AnyZodObject } from 'zod';
|
||||
import { BackstageCredentials } from '@backstage/backend-plugin-api';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
import { ServiceRef } from '@backstage/backend-plugin-api';
|
||||
import { z } from 'zod';
|
||||
|
||||
// @alpha (undocumented)
|
||||
export type ActionsRegistryActionContext<TInputSchema extends AnyZodObject> = {
|
||||
input: z.infer<TInputSchema>;
|
||||
logger: LoggerService;
|
||||
credentials: BackstageCredentials;
|
||||
};
|
||||
|
||||
// @alpha (undocumented)
|
||||
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 (undocumented)
|
||||
export interface ActionsRegistryService {
|
||||
// (undocumented)
|
||||
register<
|
||||
TInputSchema extends AnyZodObject,
|
||||
TOutputSchema extends AnyZodObject,
|
||||
>(
|
||||
options: ActionsRegistryActionOptions<TInputSchema, TOutputSchema>,
|
||||
): void;
|
||||
}
|
||||
|
||||
// @alpha
|
||||
export const actionsRegistryServiceRef: ServiceRef<
|
||||
ActionsRegistryService,
|
||||
'plugin',
|
||||
'singleton'
|
||||
>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
export interface ActionsService {
|
||||
// (undocumented)
|
||||
invoke(opts: {
|
||||
id: string;
|
||||
input?: JsonObject;
|
||||
credentials: BackstageCredentials;
|
||||
}): Promise<{
|
||||
output: JsonValue;
|
||||
}>;
|
||||
// (undocumented)
|
||||
list: (opts: { credentials: BackstageCredentials }) => Promise<{
|
||||
actions: ActionsServiceAction[];
|
||||
}>;
|
||||
}
|
||||
|
||||
// @alpha (undocumented)
|
||||
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 const actionsServiceRef: ServiceRef<
|
||||
ActionsService,
|
||||
'plugin',
|
||||
'singleton'
|
||||
>;
|
||||
|
||||
// @alpha (undocumented)
|
||||
export type BackendFeatureMeta =
|
||||
@@ -23,7 +121,7 @@ export interface InstanceMetadataService {
|
||||
getInstalledFeatures: () => BackendFeatureMeta[];
|
||||
}
|
||||
|
||||
// @alpha
|
||||
// @alpha (undocumented)
|
||||
export const instanceMetadataServiceRef: ServiceRef<
|
||||
InstanceMetadataService,
|
||||
'plugin',
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { AnyZodObject } from 'zod';
|
||||
import { AuthorizePermissionRequest } from '@backstage/plugin-permission-common';
|
||||
import { AuthorizePermissionResponse } from '@backstage/plugin-permission-common';
|
||||
import { Config } from '@backstage/config';
|
||||
@@ -13,7 +12,6 @@ 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';
|
||||
@@ -27,84 +25,6 @@ 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';
|
||||
|
||||
// @public (undocumented)
|
||||
export type ActionsRegistryActionContext<TInputSchema extends AnyZodObject> = {
|
||||
input: z.infer<TInputSchema>;
|
||||
logger: LoggerService;
|
||||
credentials: BackstageCredentials;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
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>;
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ActionsRegistryService {
|
||||
// (undocumented)
|
||||
register<
|
||||
TInputSchema extends AnyZodObject,
|
||||
TOutputSchema extends AnyZodObject,
|
||||
>(
|
||||
options: ActionsRegistryActionOptions<TInputSchema, TOutputSchema>,
|
||||
): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ActionsService {
|
||||
// (undocumented)
|
||||
invoke(opts: {
|
||||
id: string;
|
||||
input?: JsonObject;
|
||||
credentials: BackstageCredentials;
|
||||
}): Promise<{
|
||||
output: JsonValue;
|
||||
}>;
|
||||
// (undocumented)
|
||||
list: (opts: { credentials: BackstageCredentials }) => Promise<{
|
||||
actions: ActionsServiceAction[];
|
||||
}>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type ActionsServiceAction = {
|
||||
id: string;
|
||||
name: string;
|
||||
title: string;
|
||||
description: string;
|
||||
schema: {
|
||||
input: JSONSchema7;
|
||||
output: JSONSchema7;
|
||||
};
|
||||
attributes: {
|
||||
readOnly: boolean;
|
||||
destructive: boolean;
|
||||
idempotent: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
// @public
|
||||
export interface AuditorService {
|
||||
@@ -285,12 +205,6 @@ 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'>;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
"*": {
|
||||
"package.json": [
|
||||
"package.json"
|
||||
],
|
||||
"alpha": [
|
||||
"src/alpha/index.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user