Deprecate and re-export
Signed-off-by: solimant <solimant@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { parseEntityRef } from '@backstage/catalog-model';
|
||||
import {
|
||||
DiscoveryApi,
|
||||
FetchApi,
|
||||
IdentityApi,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { ResponseError } from '@backstage/errors';
|
||||
import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
import { Observable } from '@backstage/types';
|
||||
import {
|
||||
EventSourceMessage,
|
||||
fetchEventSource,
|
||||
} from '@microsoft/fetch-event-source';
|
||||
import ObservableImpl from 'zen-observable';
|
||||
|
||||
import { type TemplateParameterSchema } from './TemplateEntityV1beta3';
|
||||
import {
|
||||
ListActionsResponse,
|
||||
ListTemplatingExtensionsResponse,
|
||||
LogEvent,
|
||||
ScaffolderApi,
|
||||
ScaffolderDryRunOptions,
|
||||
ScaffolderDryRunResponse,
|
||||
ScaffolderGetIntegrationsListOptions,
|
||||
ScaffolderGetIntegrationsListResponse,
|
||||
ScaffolderRequestOptions,
|
||||
ScaffolderScaffoldOptions,
|
||||
ScaffolderScaffoldResponse,
|
||||
ScaffolderStreamLogsOptions,
|
||||
ScaffolderTask,
|
||||
} from './api';
|
||||
import {
|
||||
DefaultApiClient,
|
||||
TaskStatus,
|
||||
TypedResponse,
|
||||
} from '../client/src/schema/openapi';
|
||||
|
||||
/**
|
||||
* An API to interact with the scaffolder backend.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class ScaffolderClient implements ScaffolderApi {
|
||||
private readonly apiClient: DefaultApiClient;
|
||||
private readonly discoveryApi: DiscoveryApi;
|
||||
private readonly scmIntegrationsApi: ScmIntegrationRegistry;
|
||||
private readonly fetchApi: FetchApi;
|
||||
private readonly identityApi?: IdentityApi;
|
||||
private readonly useLongPollingLogs: boolean;
|
||||
|
||||
constructor(options: {
|
||||
discoveryApi: DiscoveryApi;
|
||||
fetchApi: FetchApi;
|
||||
identityApi?: IdentityApi;
|
||||
scmIntegrationsApi: ScmIntegrationRegistry;
|
||||
useLongPollingLogs?: boolean;
|
||||
}) {
|
||||
this.apiClient = new DefaultApiClient(options);
|
||||
this.discoveryApi = options.discoveryApi;
|
||||
this.fetchApi = options.fetchApi ?? { fetch };
|
||||
this.scmIntegrationsApi = options.scmIntegrationsApi;
|
||||
this.useLongPollingLogs = options.useLongPollingLogs ?? false;
|
||||
this.identityApi = options.identityApi;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.listTasks}
|
||||
*/
|
||||
async listTasks(
|
||||
request: {
|
||||
filterByOwnership: 'owned' | 'all';
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
},
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<{ tasks: ScaffolderTask[]; totalTasks?: number }> {
|
||||
if (!this.identityApi) {
|
||||
throw new Error(
|
||||
'IdentityApi is not available in the ScaffolderClient, please pass through the IdentityApi to the ScaffolderClient constructor in order to use the listTasks method',
|
||||
);
|
||||
}
|
||||
|
||||
const { userEntityRef } = await this.identityApi.getBackstageIdentity();
|
||||
|
||||
return await this.requestRequired(
|
||||
await this.apiClient.listTasks(
|
||||
{
|
||||
query: {
|
||||
createdBy:
|
||||
request.filterByOwnership === 'owned'
|
||||
? [userEntityRef]
|
||||
: undefined,
|
||||
limit: request.limit ? [request.limit] : undefined,
|
||||
offset: request.offset ? [request.offset] : undefined,
|
||||
},
|
||||
},
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async getIntegrationsList(
|
||||
options: ScaffolderGetIntegrationsListOptions,
|
||||
): Promise<ScaffolderGetIntegrationsListResponse> {
|
||||
const integrations = [
|
||||
...this.scmIntegrationsApi.azure.list(),
|
||||
...this.scmIntegrationsApi.bitbucket
|
||||
.list()
|
||||
.filter(
|
||||
item =>
|
||||
!this.scmIntegrationsApi.bitbucketCloud.byHost(item.config.host) &&
|
||||
!this.scmIntegrationsApi.bitbucketServer.byHost(item.config.host),
|
||||
),
|
||||
...this.scmIntegrationsApi.bitbucketCloud.list(),
|
||||
...this.scmIntegrationsApi.bitbucketServer.list(),
|
||||
...this.scmIntegrationsApi.gerrit.list(),
|
||||
...this.scmIntegrationsApi.gitea.list(),
|
||||
...this.scmIntegrationsApi.github.list(),
|
||||
...this.scmIntegrationsApi.gitlab.list(),
|
||||
]
|
||||
.map(c => ({ type: c.type, title: c.title, host: c.config.host }))
|
||||
.filter(c => options.allowedHosts.includes(c.host));
|
||||
|
||||
return {
|
||||
integrations,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.getTemplateParameterSchema}
|
||||
*/
|
||||
async getTemplateParameterSchema(
|
||||
templateRef: string,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<TemplateParameterSchema> {
|
||||
return await this.requestRequired(
|
||||
await this.apiClient.getTemplateParameterSchema(
|
||||
{
|
||||
path: parseEntityRef(templateRef, {
|
||||
defaultKind: 'template',
|
||||
}),
|
||||
},
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.scaffold}
|
||||
*/
|
||||
async scaffold(
|
||||
request: ScaffolderScaffoldOptions,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<ScaffolderScaffoldResponse> {
|
||||
const response = await this.apiClient.scaffold(
|
||||
{
|
||||
body: request,
|
||||
},
|
||||
options,
|
||||
);
|
||||
|
||||
if (response.status !== 201) {
|
||||
const status = `${response.status} ${response.statusText}`;
|
||||
const body = await response.text();
|
||||
throw new Error(`Backend request failed, ${status} ${body.trim()}`);
|
||||
}
|
||||
|
||||
const { id } = await response.json();
|
||||
return { taskId: id };
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.getTask}
|
||||
*/
|
||||
async getTask(
|
||||
taskId: string,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<ScaffolderTask> {
|
||||
return await this.requestRequired(
|
||||
await this.apiClient.getTask(
|
||||
{
|
||||
path: { taskId },
|
||||
},
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.streamLogs}
|
||||
*/
|
||||
streamLogs(
|
||||
request: ScaffolderStreamLogsOptions,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Observable<LogEvent> {
|
||||
if (this.useLongPollingLogs) {
|
||||
return this.streamLogsPolling(request, options);
|
||||
}
|
||||
|
||||
return this.streamLogsEventStream(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.dryRun}
|
||||
*/
|
||||
async dryRun(
|
||||
request: ScaffolderDryRunOptions,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<ScaffolderDryRunResponse> {
|
||||
return await this.requestRequired(
|
||||
await this.apiClient.dryRun(
|
||||
{
|
||||
body: {
|
||||
template: request.template,
|
||||
values: request.values,
|
||||
secrets: request.secrets,
|
||||
directoryContents: request.directoryContents,
|
||||
},
|
||||
},
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private streamLogsEventStream({
|
||||
isTaskRecoverable,
|
||||
taskId,
|
||||
after,
|
||||
}: ScaffolderStreamLogsOptions): Observable<LogEvent> {
|
||||
return new ObservableImpl(subscriber => {
|
||||
const params = new URLSearchParams();
|
||||
if (after !== undefined) {
|
||||
params.set('after', String(Number(after)));
|
||||
}
|
||||
|
||||
this.discoveryApi.getBaseUrl('scaffolder').then(
|
||||
baseUrl => {
|
||||
const url = `${baseUrl}/v2/tasks/${encodeURIComponent(
|
||||
taskId,
|
||||
)}/eventstream`;
|
||||
|
||||
const processEvent = (event: any) => {
|
||||
if (event.data) {
|
||||
try {
|
||||
subscriber.next(JSON.parse(event.data));
|
||||
} catch (ex) {
|
||||
subscriber.error(ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const ctrl = new AbortController();
|
||||
void fetchEventSource(url, {
|
||||
fetch: this.fetchApi.fetch,
|
||||
signal: ctrl.signal,
|
||||
onmessage(e: EventSourceMessage) {
|
||||
if (e.event === 'log') {
|
||||
processEvent(e);
|
||||
return;
|
||||
} else if (e.event === 'completion' && !isTaskRecoverable) {
|
||||
processEvent(e);
|
||||
subscriber.complete();
|
||||
ctrl.abort();
|
||||
return;
|
||||
}
|
||||
processEvent(e);
|
||||
},
|
||||
onerror(err) {
|
||||
subscriber.error(err);
|
||||
},
|
||||
});
|
||||
},
|
||||
error => {
|
||||
subscriber.error(error);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private streamLogsPolling(
|
||||
{
|
||||
taskId,
|
||||
after: inputAfter,
|
||||
}: {
|
||||
taskId: string;
|
||||
after?: number;
|
||||
},
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Observable<LogEvent> {
|
||||
let after = inputAfter;
|
||||
|
||||
return new ObservableImpl(subscriber => {
|
||||
(async () => {
|
||||
while (!subscriber.closed) {
|
||||
const response = await this.apiClient.streamLogsPolling(
|
||||
{
|
||||
path: { taskId },
|
||||
query: { after },
|
||||
},
|
||||
options,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
// wait for one second to not run into an
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
continue;
|
||||
}
|
||||
|
||||
const logs = (await response.json()) as LogEvent[];
|
||||
|
||||
for (const event of logs) {
|
||||
after = Number(event.id);
|
||||
|
||||
subscriber.next(event);
|
||||
|
||||
if (event.type === 'completion') {
|
||||
subscriber.complete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.listActions}
|
||||
*/
|
||||
async listActions(
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<ListActionsResponse> {
|
||||
return await this.requestRequired(
|
||||
await this.apiClient.listActions(null as any, options),
|
||||
);
|
||||
}
|
||||
|
||||
async listTemplatingExtensions(): Promise<ListTemplatingExtensionsResponse> {
|
||||
const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');
|
||||
const response = await this.fetchApi.fetch(
|
||||
`${baseUrl}/v2/templating-extensions`,
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw ResponseError.fromResponse(response);
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.cancelTask}
|
||||
*/
|
||||
async cancelTask(
|
||||
taskId: string,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<{ status?: TaskStatus }> {
|
||||
return await this.requestRequired(
|
||||
await this.apiClient.cancelTask({ path: { taskId } }, options),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.retry}
|
||||
*/
|
||||
async retry?(
|
||||
{
|
||||
secrets,
|
||||
taskId,
|
||||
}: {
|
||||
secrets?: Record<string, string>;
|
||||
taskId: string;
|
||||
},
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<{ id: string }> {
|
||||
return await this.requestRequired(
|
||||
await this.apiClient.retry(
|
||||
{ body: { secrets }, path: { taskId } },
|
||||
options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc ScaffolderApi.retry}
|
||||
*/
|
||||
async autocomplete({
|
||||
token,
|
||||
resource,
|
||||
provider,
|
||||
context,
|
||||
}: {
|
||||
token: string;
|
||||
provider: string;
|
||||
resource: string;
|
||||
context: Record<string, string>;
|
||||
}): Promise<{ results: { title?: string; id: string }[] }> {
|
||||
return await this.requestRequired(
|
||||
await this.apiClient.autocomplete({
|
||||
path: { provider, resource },
|
||||
body: { token, context },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Private methods
|
||||
//
|
||||
|
||||
private async requestRequired<T>(response: TypedResponse<T>): Promise<T> {
|
||||
if (!response.ok) {
|
||||
throw await ResponseError.fromResponse(response);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
}
|
||||
@@ -142,6 +142,24 @@ export interface TemplateEntityStepV1beta3 extends JsonObject {
|
||||
'backstage:permissions'?: TemplatePermissionsV1beta3;
|
||||
}
|
||||
|
||||
/**
|
||||
* The shape of each entry of parameters which gets rendered
|
||||
* as a separate step in the wizard input
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TemplateParameterSchema = {
|
||||
title: string;
|
||||
description?: string;
|
||||
presentation?: TemplatePresentationV1beta3;
|
||||
steps: Array<{
|
||||
title: string;
|
||||
description?: string;
|
||||
schema: JsonObject;
|
||||
}>;
|
||||
EXPERIMENTAL_formDecorators?: { id: string; input?: JsonObject }[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameter that is part of a Template Entity.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
import { JsonObject, JsonValue, Observable } from '@backstage/types';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { TaskSpec, TaskStep } from './TaskSpec';
|
||||
import type {
|
||||
TemplateEntityV1beta3,
|
||||
TemplateParameterSchema,
|
||||
} from './TemplateEntityV1beta3';
|
||||
import { TaskStatus } from '../client/src/schema/openapi';
|
||||
|
||||
/**
|
||||
* Options you can pass into a Scaffolder request for additional information.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ScaffolderRequestOptions {
|
||||
token?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The status of each task in a Scaffolder Job
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ScaffolderTaskStatus =
|
||||
| 'cancelled'
|
||||
| 'completed'
|
||||
| 'failed'
|
||||
| 'open'
|
||||
| 'processing'
|
||||
| 'skipped';
|
||||
|
||||
/**
|
||||
* The shape of each task returned from the `scaffolder-backend`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ScaffolderTask = {
|
||||
id: string;
|
||||
spec: TaskSpec;
|
||||
status: ScaffolderTaskStatus;
|
||||
lastHeartbeatAt?: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A single scaffolder usage example
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ScaffolderUsageExample = {
|
||||
description?: string;
|
||||
example: string;
|
||||
notes?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A single action example
|
||||
*
|
||||
* @public
|
||||
* @deprecated in favor of ScaffolderUsageExample
|
||||
*/
|
||||
export type ActionExample = {
|
||||
description: string;
|
||||
example: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The response shape for a single action in the `listActions` call to the `scaffolder-backend`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type Action = {
|
||||
id: string;
|
||||
description?: string;
|
||||
schema?: {
|
||||
input?: JSONSchema7;
|
||||
output?: JSONSchema7;
|
||||
};
|
||||
examples?: ActionExample[];
|
||||
};
|
||||
|
||||
/**
|
||||
* The response shape for the `listActions` call to the `scaffolder-backend`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ListActionsResponse = Array<Action>;
|
||||
|
||||
/**
|
||||
* The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TemplateFilter = {
|
||||
description?: string;
|
||||
schema?: {
|
||||
input?: JSONSchema7;
|
||||
arguments?: JSONSchema7[];
|
||||
output?: JSONSchema7;
|
||||
};
|
||||
examples?: ScaffolderUsageExample[];
|
||||
};
|
||||
|
||||
/**
|
||||
* The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TemplateGlobalFunction = {
|
||||
description?: string;
|
||||
schema?: {
|
||||
arguments?: JSONSchema7[];
|
||||
output?: JSONSchema7;
|
||||
};
|
||||
examples?: ScaffolderUsageExample[];
|
||||
};
|
||||
|
||||
/**
|
||||
* The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TemplateGlobalValue = {
|
||||
description?: string;
|
||||
value: JsonValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ListTemplatingExtensionsResponse = {
|
||||
filters: Record<string, TemplateFilter>;
|
||||
globals: {
|
||||
functions: Record<string, TemplateGlobalFunction>;
|
||||
values: Record<string, TemplateGlobalValue>;
|
||||
};
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type ScaffolderOutputLink = {
|
||||
title?: string;
|
||||
icon?: string;
|
||||
url?: string;
|
||||
entityRef?: string;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type ScaffolderOutputText = {
|
||||
title?: string;
|
||||
icon?: string;
|
||||
content?: string;
|
||||
default?: boolean;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type ScaffolderTaskOutput = {
|
||||
links?: ScaffolderOutputLink[];
|
||||
text?: ScaffolderOutputText[];
|
||||
} & {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* The shape of a `LogEvent` message from the `scaffolder-backend`
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type LogEvent = {
|
||||
type: 'log' | 'completion' | 'cancelled' | 'recovered';
|
||||
body: {
|
||||
message: string;
|
||||
stepId?: string;
|
||||
status?: ScaffolderTaskStatus;
|
||||
};
|
||||
createdAt: string;
|
||||
id: number;
|
||||
taskId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The input options to the `scaffold` method of the `ScaffolderClient`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ScaffolderScaffoldOptions {
|
||||
templateRef: string;
|
||||
values: Record<string, JsonValue>;
|
||||
secrets?: Record<string, string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The response shape of the `scaffold` method of the `ScaffolderClient`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ScaffolderScaffoldResponse {
|
||||
taskId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The arguments for `getIntegrationsList`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ScaffolderGetIntegrationsListOptions {
|
||||
allowedHosts: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The response shape for `getIntegrationsList`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ScaffolderGetIntegrationsListResponse {
|
||||
integrations: { type: string; title: string; host: string }[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The input options to the `streamLogs` method of the `ScaffolderClient`.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ScaffolderStreamLogsOptions {
|
||||
isTaskRecoverable?: boolean;
|
||||
taskId: string;
|
||||
after?: number;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface ScaffolderDryRunOptions {
|
||||
template: TemplateEntityV1beta3;
|
||||
values: JsonObject;
|
||||
secrets?: Record<string, string>;
|
||||
directoryContents: { path: string; base64Content: string }[];
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface ScaffolderDryRunResponse {
|
||||
directoryContents: Array<{
|
||||
path: string;
|
||||
base64Content: string;
|
||||
executable?: boolean;
|
||||
}>;
|
||||
log: Array<Pick<LogEvent, 'body'>>;
|
||||
steps: TaskStep[];
|
||||
output: ScaffolderTaskOutput;
|
||||
}
|
||||
/**
|
||||
* An API to interact with the scaffolder backend.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ScaffolderApi {
|
||||
getTemplateParameterSchema(
|
||||
templateRef: string,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<TemplateParameterSchema>;
|
||||
|
||||
/**
|
||||
* Executes the scaffolding of a component, given a template and its
|
||||
* parameter values.
|
||||
*
|
||||
* @param options - The {@link ScaffolderScaffoldOptions} the scaffolding.
|
||||
*/
|
||||
scaffold(
|
||||
request: ScaffolderScaffoldOptions,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<ScaffolderScaffoldResponse>;
|
||||
|
||||
getTask(
|
||||
taskId: string,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<ScaffolderTask>;
|
||||
|
||||
/**
|
||||
* Sends a signal to a task broker to cancel the running task by taskId.
|
||||
*
|
||||
* @param taskId - the id of the task
|
||||
*/
|
||||
cancelTask(
|
||||
taskId: string,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<{ status?: TaskStatus }>;
|
||||
|
||||
/**
|
||||
* Starts the task again from the point where it failed.
|
||||
*
|
||||
* @param taskId - the id of the task
|
||||
*/
|
||||
retry?(
|
||||
{
|
||||
secrets,
|
||||
taskId,
|
||||
}: {
|
||||
secrets?: Record<string, string>;
|
||||
taskId: string;
|
||||
},
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<{ id: string }>;
|
||||
|
||||
listTasks?(
|
||||
request: {
|
||||
filterByOwnership: 'owned' | 'all';
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
},
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<{ tasks: ScaffolderTask[]; totalTasks?: number }>;
|
||||
|
||||
getIntegrationsList(
|
||||
options: ScaffolderGetIntegrationsListOptions,
|
||||
): Promise<ScaffolderGetIntegrationsListResponse>;
|
||||
|
||||
/**
|
||||
* Returns a list of all installed actions.
|
||||
*/
|
||||
listActions(options?: ScaffolderRequestOptions): Promise<ListActionsResponse>;
|
||||
|
||||
/**
|
||||
* Returns a structure describing the available templating extensions.
|
||||
*/
|
||||
listTemplatingExtensions?(
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<ListTemplatingExtensionsResponse>;
|
||||
|
||||
streamLogs(
|
||||
request: ScaffolderStreamLogsOptions,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Observable<LogEvent>;
|
||||
|
||||
dryRun?(
|
||||
request: ScaffolderDryRunOptions,
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<ScaffolderDryRunResponse>;
|
||||
|
||||
autocomplete?(
|
||||
request: {
|
||||
token: string;
|
||||
provider: string;
|
||||
resource: string;
|
||||
context: Record<string, string>;
|
||||
},
|
||||
options?: ScaffolderRequestOptions,
|
||||
): Promise<{ results: { title?: string; id: string }[] }>;
|
||||
}
|
||||
@@ -30,7 +30,12 @@ export type {
|
||||
TemplatePresentationV1beta3,
|
||||
TemplateEntityV1beta3,
|
||||
TemplateEntityStepV1beta3,
|
||||
TemplateParameterSchema,
|
||||
TemplateParametersV1beta3,
|
||||
TemplatePermissionsV1beta3,
|
||||
TemplateRecoveryV1beta3,
|
||||
} from './TemplateEntityV1beta3';
|
||||
|
||||
export * from './ScaffolderClient';
|
||||
|
||||
export * from './api';
|
||||
|
||||
Reference in New Issue
Block a user