Fix API report

Signed-off-by: solimant <solimant@users.noreply.github.com>
This commit is contained in:
solimant
2024-12-30 22:28:21 +00:00
parent bd7ae8559d
commit 68eca7b9a0
9 changed files with 483 additions and 351 deletions
+371 -1
View File
@@ -7,15 +7,369 @@ import { Entity } from '@backstage/catalog-model';
import type { EntityMeta } from '@backstage/catalog-model';
import type { JsonArray } from '@backstage/types';
import { JsonObject } from '@backstage/types';
import type { JsonValue } from '@backstage/types';
import { JSONSchema7 } from 'json-schema';
import { JsonValue } from '@backstage/types';
import { KindValidator } from '@backstage/catalog-model';
import { Observable } from '@backstage/types';
import { ScmIntegrationRegistry } from '@backstage/integration';
import type { UserEntity } from '@backstage/catalog-model';
// @public
export type Action = {
id: string;
description?: string;
schema?: {
input?: JSONSchema7;
output?: JSONSchema7;
};
examples?: ActionExample[];
};
// @public
export interface ActionExample {
// (undocumented)
description: string;
// (undocumented)
example: string;
}
// @public
export const isTemplateEntityV1beta3: (
entity: Entity,
) => entity is TemplateEntityV1beta3;
// @public
export type ListActionsResponse = Array<Action>;
// @public
export type LogEvent = {
type: TaskEventType;
body: {
message: string;
stepId?: string;
status?: ScaffolderTaskStatus;
};
createdAt: string;
id: number;
taskId: string;
};
// @public
export interface ScaffolderApi {
// (undocumented)
autocomplete?(
request: {
token: string;
provider: string;
resource: string;
context: Record<string, string>;
},
options?: ScaffolderRequestOptions,
): Promise<{
results: {
title?: string;
id: string;
}[];
}>;
cancelTask(
taskId: string,
options?: ScaffolderRequestOptions,
): Promise<{
status?: ScaffolderTaskStatus;
}>;
// (undocumented)
dryRun?(
request: ScaffolderDryRunOptions,
options?: ScaffolderRequestOptions,
): Promise<ScaffolderDryRunResponse>;
// (undocumented)
getIntegrationsList(
options: ScaffolderGetIntegrationsListOptions,
): Promise<ScaffolderGetIntegrationsListResponse>;
// (undocumented)
getTask(
taskId: string,
options?: ScaffolderRequestOptions,
): Promise<ScaffolderTask>;
// (undocumented)
getTemplateParameterSchema(
templateRef: string,
options?: ScaffolderRequestOptions,
): Promise<TemplateParameterSchema>;
listActions(options?: ScaffolderRequestOptions): Promise<ListActionsResponse>;
// (undocumented)
listTasks?(
request: {
filterByOwnership: 'owned' | 'all';
limit?: number;
offset?: number;
},
options?: ScaffolderRequestOptions,
): Promise<{
tasks: ScaffolderTask[];
totalTasks?: number;
}>;
retry?(
{
secrets,
taskId,
}: {
secrets?: Record<string, string>;
taskId: string;
},
options?: ScaffolderRequestOptions,
): Promise<{
id: string;
}>;
scaffold(
request: ScaffolderScaffoldOptions,
options?: ScaffolderRequestOptions,
): Promise<ScaffolderScaffoldResponse>;
// (undocumented)
streamLogs(
request: ScaffolderStreamLogsOptions,
options?: ScaffolderRequestOptions,
): Observable<LogEvent>;
}
// @public
export class ScaffolderClient implements ScaffolderApi {
constructor(options: {
discoveryApi: {
getBaseUrl(pluginId: string): Promise<string>;
};
fetchApi: {
fetch: typeof fetch;
};
identityApi?: {
getBackstageIdentity(): Promise<{
type: 'user';
userEntityRef: string;
ownershipEntityRefs: string[];
}>;
};
scmIntegrationsApi: ScmIntegrationRegistry;
useLongPollingLogs?: boolean;
});
autocomplete({
token,
resource,
provider,
context,
}: {
token: string;
provider: string;
resource: string;
context: Record<string, string>;
}): Promise<{
results: {
title?: string;
id: string;
}[];
}>;
cancelTask(
taskId: string,
options?: ScaffolderRequestOptions,
): Promise<{
status?: ScaffolderTaskStatus;
}>;
// (undocumented)
dryRun(
request: ScaffolderDryRunOptions,
options?: ScaffolderRequestOptions,
): Promise<ScaffolderDryRunResponse>;
// (undocumented)
getIntegrationsList(
options: ScaffolderGetIntegrationsListOptions,
): Promise<ScaffolderGetIntegrationsListResponse>;
// (undocumented)
getTask(
taskId: string,
options?: ScaffolderRequestOptions,
): Promise<ScaffolderTask>;
// (undocumented)
getTemplateParameterSchema(
templateRef: string,
options?: ScaffolderRequestOptions,
): Promise<TemplateParameterSchema>;
listActions(options?: ScaffolderRequestOptions): Promise<ListActionsResponse>;
// (undocumented)
listTasks(
request: {
filterByOwnership: 'owned' | 'all';
limit?: number;
offset?: number;
},
options?: ScaffolderRequestOptions,
): Promise<{
tasks: ScaffolderTask[];
totalTasks?: number;
}>;
retry?(
{
secrets,
taskId,
}: {
secrets?: Record<string, string>;
taskId: string;
},
options?: ScaffolderRequestOptions,
): Promise<{
id: string;
}>;
scaffold(
request: ScaffolderScaffoldOptions,
options?: ScaffolderRequestOptions,
): Promise<ScaffolderScaffoldResponse>;
// (undocumented)
streamLogs(
request: ScaffolderStreamLogsOptions,
options?: ScaffolderRequestOptions,
): Observable<LogEvent>;
}
// @public (undocumented)
export interface ScaffolderDryRunOptions {
// (undocumented)
directoryContents: {
path: string;
base64Content: string;
}[];
// (undocumented)
secrets?: Record<string, string>;
// (undocumented)
template: TemplateEntityV1beta3;
// (undocumented)
values: JsonObject;
}
// @public (undocumented)
export interface ScaffolderDryRunResponse {
// (undocumented)
directoryContents: Array<{
path: string;
base64Content: string;
executable?: boolean;
}>;
// (undocumented)
log: Array<Pick<LogEvent, 'body'>>;
// (undocumented)
output: ScaffolderTaskOutput;
// (undocumented)
steps: TaskStep[];
}
// @public
export interface ScaffolderGetIntegrationsListOptions {
// (undocumented)
allowedHosts: string[];
}
// @public
export interface ScaffolderGetIntegrationsListResponse {
// (undocumented)
integrations: {
type: string;
title: string;
host: string;
}[];
}
// @public (undocumented)
export type ScaffolderOutputLink = {
title?: string;
icon?: string;
url?: string;
entityRef?: string;
};
// @public (undocumented)
export type ScaffolderOutputText = {
title?: string;
icon?: string;
content?: string;
default?: boolean;
};
// @public
export interface ScaffolderRequestOptions {
// (undocumented)
token?: string;
}
// @public
export interface ScaffolderScaffoldOptions {
// (undocumented)
secrets?: Record<string, string>;
// (undocumented)
templateRef: string;
// (undocumented)
values: Record<string, JsonValue>;
}
// @public
export interface ScaffolderScaffoldResponse {
// (undocumented)
taskId: string;
}
// @public
export interface ScaffolderStreamLogsOptions {
// (undocumented)
after?: number;
// (undocumented)
isTaskRecoverable?: boolean;
// (undocumented)
taskId: string;
}
// @public
export type ScaffolderTask = {
id: string;
spec: TaskSpec;
status: ScaffolderTaskStatus;
lastHeartbeatAt?: string;
createdAt: string;
};
// @public (undocumented)
export type ScaffolderTaskOutput = {
links?: ScaffolderOutputLink[];
text?: ScaffolderOutputText[];
} & {
[key: string]: unknown;
};
// @public (undocumented)
export type ScaffolderTaskStatus =
| 'cancelled'
| 'completed'
| 'failed'
| 'open'
| 'processing'
| 'skipped';
// @public (undocumented)
export const ScaffolderTaskStatus: {
Cancelled: ScaffolderTaskStatus;
Completed: ScaffolderTaskStatus;
Failed: ScaffolderTaskStatus;
Open: ScaffolderTaskStatus;
Processing: ScaffolderTaskStatus;
Skipped: ScaffolderTaskStatus;
};
// @public (undocumented)
export type TaskEventType = 'cancelled' | 'completion' | 'log' | 'recovered';
// @public (undocumented)
export const TaskEventType: {
Cancelled: TaskEventType;
Completion: TaskEventType;
Log: TaskEventType;
Recovered: TaskEventType;
};
// @public
export type TaskRecoverStrategy = 'none' | 'startOver';
@@ -103,6 +457,22 @@ export type TemplateInfo = {
};
};
// @public
export type TemplateParameterSchema = {
title: string;
description?: string;
presentation?: TemplatePresentationV1beta3;
steps: Array<{
title: string;
description?: string;
schema: JsonObject;
}>;
EXPERIMENTAL_formDecorators?: {
id: string;
input?: JsonObject;
}[];
};
// @public
export interface TemplateParametersV1beta3 extends JsonObject {
// (undocumented)
@@ -45,9 +45,6 @@ import {
TaskStatus,
TypedResponse,
} from '../client/src/schema/openapi';
import { DiscoveryApi } from '../client/src/schema/openapi/generated/types/discovery';
import { FetchApi } from '../client/src/schema/openapi/generated/types/fetch';
import { IdentityApi } from './types/IdentityApi';
/**
* An API to interact with the scaffolder backend.
@@ -56,16 +53,30 @@ import { IdentityApi } from './types/IdentityApi';
*/
export class ScaffolderClient implements ScaffolderApi {
private readonly apiClient: DefaultApiClient;
private readonly discoveryApi: DiscoveryApi;
private readonly discoveryApi: {
getBaseUrl(pluginId: string): Promise<string>;
};
private readonly scmIntegrationsApi: ScmIntegrationRegistry;
private readonly fetchApi: FetchApi;
private readonly identityApi?: IdentityApi;
private readonly fetchApi: { fetch: typeof fetch };
private readonly identityApi?: {
getBackstageIdentity(): Promise<{
type: 'user';
userEntityRef: string;
ownershipEntityRefs: string[];
}>;
};
private readonly useLongPollingLogs: boolean;
constructor(options: {
discoveryApi: DiscoveryApi;
fetchApi: FetchApi;
identityApi?: IdentityApi;
discoveryApi: { getBaseUrl(pluginId: string): Promise<string> };
fetchApi: { fetch: typeof fetch };
identityApi?: {
getBackstageIdentity(): Promise<{
type: 'user';
userEntityRef: string;
ownershipEntityRefs: string[];
}>;
};
scmIntegrationsApi: ScmIntegrationRegistry;
useLongPollingLogs?: boolean;
}) {
+1 -1
View File
@@ -25,7 +25,7 @@ import type {
TaskStatus as ScaffolderTaskStatus,
} from '../client/src/schema/openapi';
export type { ScaffolderTaskStatus };
export type { ScaffolderTaskStatus, TaskEventType };
/**
* Options you can pass into a Scaffolder request for additional information.
@@ -1,47 +0,0 @@
/*
* Copyright 2020 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.
*/
/**
* This is a copy of the BackstageUserIdentity, to avoid importing core-plugin-api.
*/
type BackstageUserIdentity = {
/**
* The type of identity that this structure represents. In the frontend app
* this will currently always be 'user'.
*/
type: 'user';
/**
* The entityRef of the user in the catalog.
* For example User:default/sandra
*/
userEntityRef: string;
/**
* The user and group entities that the user claims ownership through
*/
ownershipEntityRefs: string[];
};
/**
* This is a partial copy of the IdentityApi, to avoid importing core-plugin-api.
*/
export type IdentityApi = {
/**
* User identity information within Backstage.
*/
getBackstageIdentity(): Promise<BackstageUserIdentity>;
};