Deprecate and re-export

Signed-off-by: solimant <solimant@users.noreply.github.com>
This commit is contained in:
solimant
2024-12-27 07:22:58 +00:00
parent e2fa65af59
commit d2da49c568
103 changed files with 1619 additions and 3018 deletions
@@ -104,11 +104,11 @@ export type ListActions = {};
*/
export type ListTasks = {
query: {
createdBy?: string;
limit?: number;
offset?: number;
order?: 'asc' | 'desc';
status?: string;
createdBy?: Array<string>;
limit?: Array<number>;
offset?: Array<number>;
order?: Array<string>;
status?: Array<string>;
};
};
/**
@@ -339,7 +339,7 @@ export class DefaultApiClient {
): Promise<TypedResponse<ListTasksResponse>> {
const baseUrl = await this.discoveryApi.getBaseUrl(pluginId);
const uriTemplate = `/v2/tasks{?createdBy,limit,offset,order,status}`;
const uriTemplate = `/v2/tasks{?createdBy*,limit*,offset*,order*,status*}`;
const uri = parser.parse(uriTemplate).expand({
...request.query,
@@ -23,5 +23,5 @@ import { Autocomplete200ResponseResultsInner } from '../models/Autocomplete200Re
* @public
*/
export interface Autocomplete200Response {
results?: Array<Autocomplete200ResponseResultsInner>;
results: Array<Autocomplete200ResponseResultsInner>;
}
@@ -23,4 +23,5 @@
*/
export interface Autocomplete200ResponseResultsInner {
title?: string;
id: string;
}
@@ -31,5 +31,5 @@ export interface DryRun200Response {
* A type representing all allowed JSON object values.
*/
output: { [key: string]: any };
steps?: Array<DryRun200ResponseAllOfStepsInner>;
steps: Array<DryRun200ResponseAllOfStepsInner>;
}
@@ -24,6 +24,6 @@ import { DryRun200ResponseAllOfStepsInner } from '../models/DryRun200ResponseAll
* @public
*/
export interface DryRun200ResponseAllOf {
steps?: Array<DryRun200ResponseAllOfStepsInner>;
steps: Array<DryRun200ResponseAllOfStepsInner>;
directoryContents?: Array<DryRun200ResponseAllOfDirectoryContentsInner>;
}
@@ -22,11 +22,9 @@
* @public
*/
export interface DryRun200ResponseAllOfStepsInner {
[key: string]: any;
id: string;
name: string;
action: string;
/**
* A type representing all allowed JSON object values.
*/
input?: { [key: string]: any };
}
@@ -18,14 +18,16 @@
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { DryRunRequestDirectoryContentsInner } from '../models/DryRunRequestDirectoryContentsInner.model';
import { TemplateEntityV1beta3 } from '../models/TemplateEntityV1beta3.model';
/**
* @public
*/
export interface DryRunRequest {
template: TemplateEntityV1beta3;
values: any;
secrets?: any;
template: any;
/**
* A type representing all allowed JSON object values.
*/
values: { [key: string]: any };
secrets?: { [key: string]: string };
directoryContents: Array<DryRunRequestDirectoryContentsInner>;
}
@@ -17,13 +17,11 @@
// ******************************************************************
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model';
/**
* @public
*/
export interface DryRunResultLogInner {
/**
* A type representing all allowed JSON object values.
*/
body?: { [key: string]: any };
body: DryRunResultLogInnerBody;
}
@@ -17,11 +17,13 @@
// ******************************************************************
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { TaskStatus } from '../models/TaskStatus.model';
/**
* @public
*/
export interface DryRun200ResponseAllOfStepsInnerAllOf {
id: string;
name: string;
export interface DryRunResultLogInnerBody {
message: string;
status?: TaskStatus;
stepId?: string;
}
@@ -17,11 +17,13 @@
// ******************************************************************
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { TaskStatus } from '../models/TaskStatus.model';
/**
* Access control properties for parts of a template.
* @public
*/
export interface TemplatePermissionsV1beta3 {
tags?: Array<string>;
export interface DryRunResultLogInnerBodyAllOf {
message: string;
status?: TaskStatus;
stepId?: string;
}
@@ -22,5 +22,5 @@
* @public
*/
export interface Scaffold201Response {
id?: string;
id: string;
}
@@ -17,7 +17,6 @@
// ******************************************************************
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { JsonValue } from '../models/JsonValue.model';
/**
* The input options to the `scaffold` method of the `ScaffolderClient`.
@@ -25,6 +24,6 @@ import { JsonValue } from '../models/JsonValue.model';
*/
export interface ScaffolderScaffoldOptions {
templateRef: string;
values: { [key: string]: JsonValue };
values: { [key: string]: any };
secrets?: { [key: string]: string };
}
@@ -1,64 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { SchemaAdditionalItems } from '../models/SchemaAdditionalItems.model';
import { SchemaDependenciesValue } from '../models/SchemaDependenciesValue.model';
import { SchemaExclusiveMaximum } from '../models/SchemaExclusiveMaximum.model';
import { SchemaItems } from '../models/SchemaItems.model';
import { SchemaRequired } from '../models/SchemaRequired.model';
import { SchemaType } from '../models/SchemaType.model';
/**
* @public
*/
export interface Schema {
[key: string]: any;
id?: string;
title?: string;
description?: string;
multipleOf?: number;
maximum?: number;
exclusiveMaximum?: SchemaExclusiveMaximum;
minimum?: number;
exclusiveMinimum?: SchemaExclusiveMaximum;
maxLength?: number;
minLength?: number;
pattern?: any;
additionalItems?: SchemaAdditionalItems;
items?: SchemaItems;
maxItems?: number;
minItems?: number;
uniqueItems?: boolean;
maxProperties?: number;
minProperties?: number;
required?: SchemaRequired;
additionalProperties?: SchemaAdditionalItems;
definitions?: { [key: string]: Schema };
properties?: { [key: string]: Schema };
patternProperties?: { [key: string]: Schema };
dependencies?: { [key: string]: SchemaDependenciesValue };
type?: SchemaType;
format?: string;
allOf?: Array<Schema>;
anyOf?: Array<Schema>;
oneOf?: Array<Schema>;
not?: Schema;
then?: Schema;
}
@@ -1,25 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { Schema } from '../models/Schema.model';
/**
* @public
*/
export type SchemaAdditionalItems = Schema | boolean;
@@ -1,25 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { Schema } from '../models/Schema.model';
/**
* @public
*/
export type SchemaDependenciesValue = Array<string> | Schema;
@@ -1,25 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { Schema } from '../models/Schema.model';
/**
* @public
*/
export type SchemaItems = Array<Schema> | Schema;
@@ -1,24 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* @public
*/
export type SchemaRequired = Array<string> | boolean;
@@ -1,24 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* @public
*/
export type SchemaType = Array<string> | string;
@@ -18,7 +18,6 @@
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { TaskSecrets } from '../models/TaskSecrets.model';
import { TaskSpecV1beta3 } from '../models/TaskSpecV1beta3.model';
import { TaskStatus } from '../models/TaskStatus.model';
/**
@@ -27,7 +26,7 @@ import { TaskStatus } from '../models/TaskStatus.model';
*/
export interface SerializedTask {
id: string;
spec: TaskSpecV1beta3;
spec: any;
status: TaskStatus;
createdAt: string;
lastHeartbeatAt?: string;
@@ -17,6 +17,7 @@
// ******************************************************************
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model';
import { TaskEventType } from '../models/TaskEventType.model';
/**
@@ -27,10 +28,7 @@ export interface SerializedTaskEvent {
id: number;
isTaskRecoverable?: boolean;
taskId: string;
/**
* A type representing all allowed JSON object values.
*/
body: { [key: string]: any };
body: DryRunResultLogInnerBody;
type: TaskEventType;
createdAt: string;
}
@@ -21,14 +21,14 @@
/**
* @public
*/
export type TaskEventType = 'completion' | 'log' | 'cancelled' | 'recovered';
export type TaskEventType = 'cancelled' | 'completion' | 'log' | 'recovered';
/**
* @public
*/
export const TaskEventType = {
Cancelled: 'cancelled' as TaskEventType,
Completion: 'completion' as TaskEventType,
Log: 'log' as TaskEventType,
Cancelled: 'cancelled' as TaskEventType,
Recovered: 'recovered' as TaskEventType,
};
@@ -23,7 +23,5 @@
* @public
*/
export interface TaskSecrets {
[key: string]: any;
backstageToken?: string;
}
@@ -21,4 +21,6 @@
/**
* @public
*/
export type SchemaExclusiveMaximum = boolean | number;
export interface TaskSecretsAllOf {
backstageToken?: string;
}
@@ -1,55 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { JsonValue } from '../models/JsonValue.model';
import { TaskSpecV1beta3User } from '../models/TaskSpecV1beta3User.model';
import { TaskStep } from '../models/TaskStep.model';
import { TemplateInfo } from '../models/TemplateInfo.model';
/**
* A scaffolder task as stored in the database, generated from a v1beta3 apiVersion Template.
* @public
*/
export interface TaskSpecV1beta3 {
[key: string]: any;
/**
* The apiVersion string of the TaskSpec.
*/
apiVersion: TaskSpecV1beta3ApiVersionEnum;
/**
* A type representing all allowed JSON object values.
*/
parameters: { [key: string]: any };
/**
* A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying javascript action and some optional input parameters that may or may not have been collected from the end user.
*/
steps: Array<TaskStep>;
/**
* The output is an object where template authors can pull out information from template actions and return them in a known standard way.
*/
output: { [key: string]: JsonValue };
templateInfo?: TemplateInfo;
user?: TaskSpecV1beta3User;
}
/**
* @public
*/
export type TaskSpecV1beta3ApiVersionEnum = 'scaffolder.backstage.io/v1beta3';
@@ -1,34 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* Some decoration of the author of the task that should be available in the context
* @public
*/
export interface TaskSpecV1beta3User {
/**
* The decorated entity from the Catalog
*/
entity?: any;
/**
* An entity ref for the author of the task
*/
ref?: string;
}
@@ -26,7 +26,8 @@ export type TaskStatus =
| 'completed'
| 'failed'
| 'open'
| 'processing';
| 'processing'
| 'skipped';
/**
* @public
@@ -37,4 +38,5 @@ export const TaskStatus = {
Failed: 'failed' as TaskStatus,
Open: 'open' as TaskStatus,
Processing: 'processing' as TaskStatus,
Skipped: 'skipped' as TaskStatus,
};
@@ -1,35 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* Step that is part of a Template Entity.
* @public
*/
export interface TemplateEntityStepV1beta3 {
[key: string]: any;
id?: string;
name?: string;
action: string;
/**
* A type representing all allowed JSON object values.
*/
input?: { [key: string]: any };
}
@@ -1,32 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* @public
*/
export interface TemplateEntityStepV1beta3AllOf {
id?: string;
name?: string;
action: string;
/**
* A type representing all allowed JSON object values.
*/
input?: { [key: string]: any };
}
@@ -1,53 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { EntityMeta } from '../models/EntityMeta.model';
import { EntityRelation } from '../models/EntityRelation.model';
import { TemplateEntityV1beta3AllOfSpec } from '../models/TemplateEntityV1beta3AllOfSpec.model';
/**
* Backstage catalog Template kind Entity. Templates are used by the Scaffolder plugin to create new entities, such as Components.
* @public
*/
export interface TemplateEntityV1beta3 {
/**
* The relations that this entity has with other entities.
*/
relations?: Array<EntityRelation>;
spec: TemplateEntityV1beta3AllOfSpec;
metadata: EntityMeta;
/**
* The kind of the entity
*/
kind: TemplateEntityV1beta3KindEnum;
/**
* The apiVersion string of the TaskSpec.
*/
apiVersion: TemplateEntityV1beta3ApiVersionEnum;
}
/**
* @public
*/
export type TemplateEntityV1beta3KindEnum = 'Template';
/**
* @public
*/
export type TemplateEntityV1beta3ApiVersionEnum =
'scaffolder.backstage.io/v1beta3';
@@ -1,45 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { TemplateEntityV1beta3AllOfSpec } from '../models/TemplateEntityV1beta3AllOfSpec.model';
/**
* @public
*/
export interface TemplateEntityV1beta3AllOf {
/**
* The apiVersion string of the TaskSpec.
*/
apiVersion: TemplateEntityV1beta3AllOfApiVersionEnum;
/**
* The kind of the entity
*/
kind: TemplateEntityV1beta3AllOfKindEnum;
spec: TemplateEntityV1beta3AllOfSpec;
}
/**
* @public
*/
export type TemplateEntityV1beta3AllOfApiVersionEnum =
'scaffolder.backstage.io/v1beta3';
/**
* @public
*/
export type TemplateEntityV1beta3AllOfKindEnum = 'Template';
@@ -1,49 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { TemplateEntityStepV1beta3 } from '../models/TemplateEntityStepV1beta3.model';
import { TemplateEntityV1beta3AllOfSpecParameters } from '../models/TemplateEntityV1beta3AllOfSpecParameters.model';
import { TemplatePresentationV1beta3 } from '../models/TemplatePresentationV1beta3.model';
/**
* The specification of the Template Entity
* @public
*/
export interface TemplateEntityV1beta3AllOfSpec {
[key: string]: any;
/**
* The type that the Template will create. For example service, website or library.
*/
type: string;
presentation?: TemplatePresentationV1beta3;
parameters?: TemplateEntityV1beta3AllOfSpecParameters;
/**
* A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying javascript action and some optional input parameters that may or may not have been collected from the end user.
*/
steps: Array<TemplateEntityStepV1beta3>;
/**
* The output is an object where template authors can pull out information from template actions and return them in a known standard way.
*/
output?: { [key: string]: string };
/**
* The owner entityRef of the TemplateEntity
*/
owner?: string;
}
@@ -1,28 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.model';
/**
* This is a JSONSchema or an array of JSONSchema's which is used to render a form in the frontend to collect user input and validate it against that schema. This can then be used in the `steps` part below to template variables passed from the user into each action in the template.
* @public
*/
export type TemplateEntityV1beta3AllOfSpecParameters =
| Array<TemplateParametersV1beta3>
| TemplateParametersV1beta3;
@@ -18,7 +18,6 @@
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { TemplateParameterSchemaStepsInner } from '../models/TemplateParameterSchemaStepsInner.model';
import { TemplatePresentationV1beta3 } from '../models/TemplatePresentationV1beta3.model';
/**
* The shape of each entry of parameters which gets rendered as a separate step in the wizard input
@@ -28,7 +27,6 @@ export interface TemplateParameterSchema {
[key: string]: any;
title: string;
presentation?: TemplatePresentationV1beta3;
description?: string;
steps: Array<TemplateParameterSchemaStepsInner>;
}
@@ -18,7 +18,6 @@
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { JsonValue } from '../models/JsonValue.model';
import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.model';
/**
* @public
@@ -26,5 +25,5 @@ import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.m
export interface TemplateParameterSchemaStepsInner {
title: JsonValue;
description?: JsonValue;
schema: TemplateParametersV1beta3;
schema: any;
}
@@ -1,25 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* Parameter that is part of a Template Entity.
* @public
*/
export interface TemplateParametersV1beta3 {}
@@ -1,26 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* @public
*/
export interface TemplatePermissionsV1beta3AllOf {
tags?: Array<string>;
}
@@ -1,30 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { TemplatePresentationV1beta3ButtonLabels } from '../models/TemplatePresentationV1beta3ButtonLabels.model';
/**
* The presentation of the template.
* @public
*/
export interface TemplatePresentationV1beta3 {
[key: string]: any;
buttonLabels?: TemplatePresentationV1beta3ButtonLabels;
}
@@ -1,38 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* Overrides default buttons' text
* @public
*/
export interface TemplatePresentationV1beta3ButtonLabels {
/**
* The text for the button which leads to the previous template page
*/
backButtonText?: string;
/**
* The text for the button which starts the execution of the template
*/
createButtonText?: string;
/**
* The text for the button which opens template's review/summary
*/
reviewButtonText?: string;
}
@@ -1,25 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
/**
* Depends on how you designed your task you might tailor the behaviour for each of them.
* @public
*/
export interface TemplateRecoveryV1beta3 {}
@@ -18,16 +18,16 @@
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { ValidationErrorPathInner } from '../models/ValidationErrorPathInner.model';
import { ValidationErrorSchema } from '../models/ValidationErrorSchema.model';
/**
* @public
*/
export interface ValidationError {
[key: string]: any;
path: Array<ValidationErrorPathInner>;
property: string;
message: string;
schema: ValidationErrorSchema;
instance: any;
name: string;
argument: any;
@@ -1,25 +0,0 @@
/*
* Copyright 2024 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 AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
// ******************************************************************
import { Schema } from '../models/Schema.model';
/**
* @public
*/
export type ValidationErrorSchema = Schema | string;
@@ -25,11 +25,12 @@ export * from '../models/DryRun200Response.model';
export * from '../models/DryRun200ResponseAllOf.model';
export * from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model';
export * from '../models/DryRun200ResponseAllOfStepsInner.model';
export * from '../models/DryRun200ResponseAllOfStepsInnerAllOf.model';
export * from '../models/DryRunRequest.model';
export * from '../models/DryRunRequestDirectoryContentsInner.model';
export * from '../models/DryRunResult.model';
export * from '../models/DryRunResultLogInner.model';
export * from '../models/DryRunResultLogInnerBody.model';
export * from '../models/DryRunResultLogInnerBodyAllOf.model';
export * from '../models/Entity.model';
export * from '../models/EntityLink.model';
export * from '../models/EntityMeta.model';
@@ -45,40 +46,19 @@ export * from '../models/RetryRequest.model';
export * from '../models/Scaffold201Response.model';
export * from '../models/Scaffold400Response.model';
export * from '../models/ScaffolderScaffoldOptions.model';
export * from '../models/Schema.model';
export * from '../models/SchemaAdditionalItems.model';
export * from '../models/SchemaDependenciesValue.model';
export * from '../models/SchemaExclusiveMaximum.model';
export * from '../models/SchemaItems.model';
export * from '../models/SchemaRequired.model';
export * from '../models/SchemaType.model';
export * from '../models/SerializedFile.model';
export * from '../models/SerializedTask.model';
export * from '../models/SerializedTaskEvent.model';
export * from '../models/TaskEventType.model';
export * from '../models/TaskRecoverStrategy.model';
export * from '../models/TaskSecrets.model';
export * from '../models/TaskSpecV1beta3.model';
export * from '../models/TaskSpecV1beta3User.model';
export * from '../models/TaskSecretsAllOf.model';
export * from '../models/TaskStatus.model';
export * from '../models/TaskStep.model';
export * from '../models/TaskStepEach.model';
export * from '../models/TemplateEntityStepV1beta3.model';
export * from '../models/TemplateEntityStepV1beta3AllOf.model';
export * from '../models/TemplateEntityV1beta3.model';
export * from '../models/TemplateEntityV1beta3AllOf.model';
export * from '../models/TemplateEntityV1beta3AllOfSpec.model';
export * from '../models/TemplateEntityV1beta3AllOfSpecParameters.model';
export * from '../models/TemplateInfo.model';
export * from '../models/TemplateInfoEntity.model';
export * from '../models/TemplateParameterSchema.model';
export * from '../models/TemplateParameterSchemaStepsInner.model';
export * from '../models/TemplateParametersV1beta3.model';
export * from '../models/TemplatePermissionsV1beta3.model';
export * from '../models/TemplatePermissionsV1beta3AllOf.model';
export * from '../models/TemplatePresentationV1beta3.model';
export * from '../models/TemplatePresentationV1beta3ButtonLabels.model';
export * from '../models/TemplateRecoveryV1beta3.model';
export * from '../models/ValidationError.model';
export * from '../models/ValidationErrorPathInner.model';
export * from '../models/ValidationErrorSchema.model';
+8 -1
View File
@@ -61,8 +61,15 @@
},
"dependencies": {
"@backstage/catalog-model": "workspace:^",
"@backstage/core-plugin-api": "workspace:^",
"@backstage/errors": "workspace:^",
"@backstage/integration": "workspace:^",
"@backstage/plugin-permission-common": "workspace:^",
"@backstage/types": "workspace:^"
"@backstage/types": "workspace:^",
"@microsoft/fetch-event-source": "^2.0.1",
"json-schema": "^0.4.0",
"qs": "^6.9.4",
"zen-observable": "^0.10.0"
},
"devDependencies": {
"@backstage/cli": "workspace:^",
@@ -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.
*
+362
View File
@@ -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 }[] }>;
}
+5
View File
@@ -30,7 +30,12 @@ export type {
TemplatePresentationV1beta3,
TemplateEntityV1beta3,
TemplateEntityStepV1beta3,
TemplateParameterSchema,
TemplateParametersV1beta3,
TemplatePermissionsV1beta3,
TemplateRecoveryV1beta3,
} from './TemplateEntityV1beta3';
export * from './ScaffolderClient';
export * from './api';