diff --git a/.changeset/clean-chairs-sit-2.md b/.changeset/clean-chairs-sit-2.md new file mode 100644 index 0000000000..6fb7d6c844 --- /dev/null +++ b/.changeset/clean-chairs-sit-2.md @@ -0,0 +1,9 @@ +--- +'@backstage/plugin-scaffolder-react': minor +--- + +**DEPRECATION**: The following types have been deprecated from this package and moved into `@backstage/plugin-scaffolder-common` and should be imported from there instead. + +`Action`, `ListActionsResponse`, `LogEvent`, `ScaffolderApi`, `ScaffolderDryRunOptions`, `ScaffolderDryRunResponse`, `ScaffolderGetIntegrationsListOptions`, `ScaffolderGetIntegrationsListResponse`, +`ScaffolderOutputLink`, `ScaffolderOutputText`, `ScaffolderScaffoldOptions`, `ScaffolderScaffoldResponse`, `ScaffolderStreamLogsOptions`, `ScaffolderTask`, `ScaffolderTaskOutput`, `ScaffolderTaskStatus`, +`ScaffolderUsageExample`, `TemplateFilter`, `TemplateGlobalFunction`, `TemplateGlobalValue`, `TemplateParameterSchema`. diff --git a/.changeset/clean-chairs-sit.md b/.changeset/clean-chairs-sit.md new file mode 100644 index 0000000000..9e76e56887 --- /dev/null +++ b/.changeset/clean-chairs-sit.md @@ -0,0 +1,10 @@ +--- +'@backstage/backend-openapi-utils': minor +'@backstage/plugin-scaffolder-backend': minor +'@backstage/plugin-scaffolder-common': minor +'@backstage/plugin-scaffolder-react': minor +'@backstage/plugin-scaffolder-node': minor +'@backstage/plugin-scaffolder': minor +--- + +Move Scaffolder API to OpenAPI diff --git a/.changeset/spotty-clowns-lose.md b/.changeset/spotty-clowns-lose.md new file mode 100644 index 0000000000..e550fe48de --- /dev/null +++ b/.changeset/spotty-clowns-lose.md @@ -0,0 +1,5 @@ +--- +'@backstage/repo-tools': patch +--- + +Added `stringEnums` to `mustache` templates diff --git a/packages/backend-openapi-utils/report.api.md b/packages/backend-openapi-utils/report.api.md index 6606f88b4a..75bf53cdf1 100644 --- a/packages/backend-openapi-utils/report.api.md +++ b/packages/backend-openapi-utils/report.api.md @@ -274,7 +274,7 @@ type EndpointMap = Record< { query?: object; body?: object; - response?: object | void; + response?: object | string | void; path?: object; } >; diff --git a/packages/backend-openapi-utils/src/types/generated.ts b/packages/backend-openapi-utils/src/types/generated.ts index e4d5dada72..ffbabb6f92 100644 --- a/packages/backend-openapi-utils/src/types/generated.ts +++ b/packages/backend-openapi-utils/src/types/generated.ts @@ -21,7 +21,12 @@ import { PathTemplate, ValueOf } from './common'; */ export type EndpointMap = Record< string, - { query?: object; body?: object; response?: object | void; path?: object } + { + query?: object; + body?: object; + response?: object | string | void; + path?: object; + } >; // OpenAPI generator doesn't emit regular lowercase 'delete'. diff --git a/packages/repo-tools/templates/typescript-backstage-client/modelEnum.mustache b/packages/repo-tools/templates/typescript-backstage-client/modelEnum.mustache index 2461d8c549..09bc5bdbca 100644 --- a/packages/repo-tools/templates/typescript-backstage-client/modelEnum.mustache +++ b/packages/repo-tools/templates/typescript-backstage-client/modelEnum.mustache @@ -17,4 +17,4 @@ export enum {{classname}} { * @public */ export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; - +{{/stringEnums}} diff --git a/packages/repo-tools/templates/typescript-backstage-server/modelEnum.mustache b/packages/repo-tools/templates/typescript-backstage-server/modelEnum.mustache index 2461d8c549..09bc5bdbca 100644 --- a/packages/repo-tools/templates/typescript-backstage-server/modelEnum.mustache +++ b/packages/repo-tools/templates/typescript-backstage-server/modelEnum.mustache @@ -17,4 +17,4 @@ export enum {{classname}} { * @public */ export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; - +{{/stringEnums}} diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index 6cef18efce..0f7816dc51 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -54,6 +54,7 @@ "build": "backstage-cli package build", "build:assets": "node scripts/build-nunjucks.js", "clean": "backstage-cli package clean", + "generate": "backstage-repo-tools package schema openapi generate --server --client-package plugins/scaffolder-common", "lint": "backstage-cli package lint", "prepack": "backstage-cli package prepack", "postpack": "backstage-cli package postpack", @@ -62,6 +63,7 @@ }, "dependencies": { "@backstage/backend-defaults": "workspace:^", + "@backstage/backend-openapi-utils": "workspace:^", "@backstage/backend-plugin-api": "workspace:^", "@backstage/catalog-model": "workspace:^", "@backstage/config": "workspace:^", @@ -89,7 +91,6 @@ "@types/luxon": "^3.0.0", "concat-stream": "^2.0.0", "express": "^4.17.1", - "express-promise-router": "^4.1.0", "fs-extra": "^11.2.0", "globby": "^11.0.0", "isbinaryfile": "^5.0.0", @@ -119,6 +120,7 @@ "@backstage/backend-test-utils": "workspace:^", "@backstage/cli": "workspace:^", "@backstage/plugin-scaffolder-node-test-utils": "workspace:^", + "@backstage/repo-tools": "workspace:^", "@types/express": "^4.17.6", "@types/fs-extra": "^11.0.0", "@types/nunjucks": "^3.1.4", diff --git a/plugins/scaffolder-backend/src/ScaffolderPlugin.test.ts b/plugins/scaffolder-backend/src/ScaffolderPlugin.test.ts index b9cb397ae6..f3b3456e79 100644 --- a/plugins/scaffolder-backend/src/ScaffolderPlugin.test.ts +++ b/plugins/scaffolder-backend/src/ScaffolderPlugin.test.ts @@ -737,9 +737,10 @@ describe('scaffolderPlugin', () => { }); // Retry the task by ID - response = await request(server).post( - `/api/scaffolder/v2/tasks/${taskId}/retry`, - ); + response = await request(server) + .post(`/api/scaffolder/v2/tasks/${taskId}/retry`) + .send({}); + expect(response.status).toBe(201); expect(response.body).toMatchObject({ id: taskId }); diff --git a/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts b/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts index 9d4494c536..d384443252 100644 --- a/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts +++ b/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts @@ -22,7 +22,11 @@ import { import type { UserEntity } from '@backstage/catalog-model'; import { ScmIntegrations } from '@backstage/integration'; import { PermissionEvaluator } from '@backstage/plugin-permission-common'; -import { TaskSpec, TemplateInfo } from '@backstage/plugin-scaffolder-common'; +import { + ScaffolderTaskStatus, + TaskSpec, + TemplateInfo, +} from '@backstage/plugin-scaffolder-common'; import { createTemplateAction, deserializeDirectoryContents, @@ -54,7 +58,13 @@ interface DryRunInput { } interface DryRunResult { - log: Array<{ body: JsonObject }>; + log: Array<{ + body: { + message: string; + stepId?: string; + status?: ScaffolderTaskStatus; + }; + }>; directoryContents: SerializedFile[]; output: JsonObject; } @@ -106,7 +116,13 @@ export function createDryRunner(options: TemplateTesterCreateOptions) { const contentsPath = path.dirname(basePath); const dryRunId = uuid(); - const log = new Array<{ body: JsonObject }>(); + const log = new Array<{ + body: { + message: string; + stepId?: string; + status?: ScaffolderTaskStatus; + }; + }>(); try { await deserializeDirectoryContents(contentsPath, input.directoryContents); diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts index f07d827f45..fdcaa8613e 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts @@ -607,7 +607,7 @@ export class DatabaseTaskStore implements TaskStore { const events = rawEvents.map(event => { try { - const body = JSON.parse(event.body) as JsonObject; + const body = JSON.parse(event.body) as SerializedTaskEvent['body']; return { id: Number(event.id), isTaskRecoverable, diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/taskRecoveryHelper.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/taskRecoveryHelper.ts index f3b8b321fe..fa75bdb2df 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/taskRecoveryHelper.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/taskRecoveryHelper.ts @@ -28,7 +28,7 @@ export const trimEventsTillLastRecovery = ( if (recoveredEventInd >= 0) { const ind = events.length - recoveredEventInd - 1; const { recoverStrategy } = events[ind].body as { - recoverStrategy: TaskRecoverStrategy; + recoverStrategy?: TaskRecoverStrategy; }; if (recoverStrategy === 'startOver') { return { diff --git a/plugins/scaffolder-backend/src/schema/openapi.yaml b/plugins/scaffolder-backend/src/schema/openapi.yaml new file mode 100644 index 0000000000..b89f54603c --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi.yaml @@ -0,0 +1,887 @@ +openapi: 3.0.3 +info: + title: scaffolder + version: '1' + description: The Backstage backend plugin that helps you create new things + license: + name: Apache-2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + contact: {} +servers: + - url: / +components: + examples: {} + headers: {} + parameters: + createdBy: + name: createdBy + in: query + description: Created by + required: false + allowReserved: true + schema: + type: array + items: + type: string + eventsAfter: + name: after + in: query + description: Offset event ID to stream events after. + required: false + allowReserved: true + schema: + type: integer + kind: + name: kind + in: path + required: true + allowReserved: true + schema: + type: string + limit: + name: limit + in: query + description: Number of records to return in the response. + required: false + allowReserved: true + schema: + type: integer + minimum: 0 + namespace: + name: namespace + in: path + required: true + allowReserved: true + schema: + type: string + name: + name: name + in: path + required: true + allowReserved: true + schema: + type: string + offset: + name: offset + in: query + description: Number of records to skip in the query page. + required: false + allowReserved: true + schema: + type: integer + minimum: 0 + order: + name: order + in: query + description: Order + required: false + allowReserved: true + schema: + type: array + items: + type: string + status: + name: status + in: query + description: Status + required: false + allowReserved: true + schema: + type: array + items: + type: string + taskId: + name: taskId + in: path + required: true + allowReserved: true + schema: + type: string + requestBodies: {} + responses: + ErrorResponse: + description: An error response from the backend. + content: + application/json; charset=utf-8: + schema: + $ref: '#/components/schemas/Error' + schemas: + Action: + type: object + properties: + id: + type: string + description: + type: string + "'examples'": + type: array + items: + $ref: '#/components/schemas/ActionExample' + schema: + type: object + properties: + input: + $ref: '#/components/schemas/JsonObject' + output: + $ref: '#/components/schemas/JsonObject' + required: + - id + description: The response shape for a single action in the `listActions` call to the `scaffolder-backend` + ActionExample: + type: object + properties: + description: + type: string + example: + type: string + required: + - description + - example + description: A single action example + DryRunResult: + type: object + properties: + log: + type: array + items: + type: object + properties: + body: + allOf: + - $ref: '#/components/schemas/JsonObject' + - type: object + properties: + message: + type: string + status: + $ref: '#/components/schemas/TaskStatus' + stepId: + type: string + required: + - message + required: + - body + directoryContents: + type: array + items: + $ref: '#/components/schemas/SerializedFile' + output: + $ref: '#/components/schemas/JsonObject' + required: + - log + - directoryContents + - output + Error: + type: object + properties: + error: + type: object + properties: + name: + type: string + message: + type: string + stack: + type: string + code: + type: string + required: + - name + - message + request: + type: object + properties: + method: + type: string + url: + type: string + required: + - method + - url + response: + type: object + properties: + statusCode: + type: number + required: + - statusCode + required: + - error + - response + additionalProperties: {} + JsonArray: + type: array + items: + $ref: '#/components/schemas/JsonValue' + description: A type representing all allowed JSON array values. + JsonObject: + type: object + properties: {} + description: A type representing all allowed JSON object values. + additionalProperties: {} + JsonPrimitive: + oneOf: + - type: boolean + - type: number + - type: string + - type: object + nullable: true + description: A type representing all allowed JSON primitive values. + JsonValue: + oneOf: + - $ref: '#/components/schemas/JsonObject' + - $ref: '#/components/schemas/JsonArray' + - $ref: '#/components/schemas/JsonPrimitive' + description: A type representing all allowed JSON values. + ListActionsResponse: + type: array + items: + $ref: '#/components/schemas/Action' + description: The response shape for the `listActions` call to the `scaffolder-backend` + ListTasksResponse: + type: object + properties: + tasks: + type: array + items: + $ref: '#/components/schemas/SerializedTask' + totalTasks: + type: number + required: + - tasks + description: The response shape for the `listTasks` call to the `scaffolder-backend` + ListTemplatingExtensionsResponse: + type: object + properties: + filters: + type: object + additionalProperties: + $ref: '#/components/schemas/TemplateFilter' + globals: + type: object + properties: + functions: + type: object + additionalProperties: + $ref: '#/components/schemas/TemplateGlobalFunction' + values: + type: object + additionalProperties: + $ref: '#/components/schemas/TemplateGlobalValue' + required: + - functions + - values + required: + - filters + - globals + description: The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend` + ScaffolderScaffoldOptions: + type: object + properties: + templateRef: + type: string + values: + type: object + additionalProperties: {} + secrets: + type: object + additionalProperties: + type: string + required: + - templateRef + - values + description: The input options to the `scaffold` method of the `ScaffolderClient`. + ScaffolderUsageExample: + type: object + properties: + description: + type: string + example: + type: string + notes: + type: string + required: + - example + description: A single scaffolder usage example + SerializedFile: + type: object + properties: + path: + type: string + content: + type: string + executable: + type: boolean + symlink: + type: boolean + required: + - path + - content + SerializedTaskEvent: + type: object + properties: + id: + type: integer + isTaskRecoverable: + type: boolean + taskId: + type: string + body: + allOf: + - $ref: '#/components/schemas/JsonObject' + - type: object + properties: + message: + type: string + status: + $ref: '#/components/schemas/TaskStatus' + stepId: + type: string + required: + - message + type: + $ref: '#/components/schemas/TaskEventType' + createdAt: + type: string + required: + - id + - taskId + - body + - type + - createdAt + description: SerializedTaskEvent + SerializedTask: + type: object + properties: + id: + type: string + spec: + type: object + status: + $ref: '#/components/schemas/TaskStatus' + createdAt: + type: string + lastHeartbeatAt: + type: string + createdBy: + type: string + secrets: + $ref: '#/components/schemas/TaskSecrets' + state: + $ref: '#/components/schemas/JsonObject' + required: + - id + - spec + - status + - createdAt + description: SerializedTask + TaskEventType: + type: string + description: TaskEventType + enum: + - cancelled + - completion + - log + - recovered + TaskSecrets: + allOf: + - type: object + additionalProperties: + type: string + - type: object + properties: + backstageToken: + type: string + description: TaskSecrets + TaskStatus: + type: string + enum: + - cancelled + - completed + - failed + - open + - processing + - skipped + description: The status of each step of the Task + TemplateGlobalFunction: + type: object + properties: + description: + type: string + schema: + type: object + properties: + arguments: + type: array + items: + $ref: '#/components/schemas/JsonObject' + output: + $ref: '#/components/schemas/JsonObject' + "'examples'": + type: array + items: + $ref: '#/components/schemas/ScaffolderUsageExample' + description: The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend` + TemplateGlobalValue: + type: object + properties: + description: + type: string + value: + type: object + nullable: true + required: + - value + description: The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend` + TemplateFilter: + type: object + properties: + description: + type: string + schema: + type: object + properties: + input: + $ref: '#/components/schemas/JsonObject' + arguments: + type: array + items: + $ref: '#/components/schemas/JsonObject' + output: + $ref: '#/components/schemas/JsonObject' + "'examples'": + type: array + items: + $ref: '#/components/schemas/ScaffolderUsageExample' + description: The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend` + TemplateParameterSchema: + type: object + properties: + title: + type: string + description: + type: string + steps: + type: array + items: + type: object + properties: + title: + type: string + description: + type: string + schema: + type: object + required: + - title + - schema + required: + - title + - steps + description: |- + The shape of each entry of parameters which gets rendered + as a separate step in the wizard input + additionalProperties: {} + ValidationError: + type: object + properties: + path: + type: array + items: + oneOf: + - type: string + - type: integer + property: + type: string + message: + type: string + instance: + type: object + name: + type: string + argument: + oneOf: + - type: boolean + - type: number + - type: object + - type: string + stack: + type: string + required: + - path + - property + - message + - schema + - instance + - name + - argument + - stack + additionalProperties: {} + securitySchemes: + JWT: + type: http + scheme: bearer + bearerFormat: JWT +paths: + /v2/templates/{namespace}/{kind}/{name}/parameter-schema: + get: + operationId: GetTemplateParameterSchema + description: Get template parameter schema. + responses: + '200': + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/TemplateParameterSchema' + '400': + $ref: '#/components/responses/ErrorResponse' + default: + $ref: '#/components/responses/ErrorResponse' + security: + - {} + - JWT: [] + parameters: + - $ref: '#/components/parameters/namespace' + - $ref: '#/components/parameters/kind' + - $ref: '#/components/parameters/name' + + /v2/actions: + get: + operationId: ListActions + description: Returns a list of all installed actions. + responses: + '200': + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/ListActionsResponse' + security: + - {} + - JWT: [] + parameters: [] + + /v2/tasks: + get: + operationId: ListTasks + description: Returns a list of tasks, filtering by ownership and/or status if given. + responses: + '200': + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/ListTasksResponse' + security: + - {} + - JWT: [] + parameters: + - $ref: '#/components/parameters/createdBy' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + - $ref: '#/components/parameters/order' + - $ref: '#/components/parameters/status' + post: + operationId: Scaffold + description: |- + Executes the scaffolding of a component, given a template and its + parameter values. + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ScaffolderScaffoldOptions' + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + id: + type: string + required: + - id + '400': + description: Validation errors. + content: + application/json: + schema: + type: object + properties: + errors: + type: array + items: + $ref: '#/components/schemas/ValidationError' + required: + - errors + security: + - {} + - JWT: [] + parameters: [] + + /v2/tasks/{taskId}: + get: + operationId: GetTask + description: Get a task by ID. + responses: + '200': + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/SerializedTask' + '403': + $ref: '#/components/responses/ErrorResponse' + security: + - {} + - JWT: [] + parameters: + - $ref: '#/components/parameters/taskId' + + /v2/tasks/{taskId}/cancel: + post: + operationId: CancelTask + description: Sends a signal to a task broker to cancel the running task by taskId. + responses: + '200': + description: Ok + content: + application/json: + schema: + type: object + properties: + status: + $ref: '#/components/schemas/TaskStatus' + security: + - {} + - JWT: [] + parameters: + - $ref: '#/components/parameters/taskId' + + /v2/tasks/{taskId}/retry: + post: + operationId: Retry + description: Starts the task again from the point where it failed. + requestBody: + # this should probably be marked as required, but for legacy reasons we're not. + required: false + content: + application/json: + schema: + type: object + properties: + secrets: + type: object + additionalProperties: + type: string + responses: + '201': + description: Ok + content: + application/json: + schema: + type: object + properties: + id: + type: string + required: + - id + security: + - {} + - JWT: [] + parameters: + - $ref: '#/components/parameters/taskId' + + /v2/tasks/{taskId}/events: + get: + operationId: StreamLogsPolling + description: Get events for a task by ID. + responses: + '200': + description: Ok + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/SerializedTaskEvent' + '403': + $ref: '#/components/responses/ErrorResponse' + parameters: + - $ref: '#/components/parameters/eventsAfter' + - $ref: '#/components/parameters/taskId' + + /v2/dry-run: + post: + operationId: DryRun + description: Perform a dry-run of a template + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + template: + type: object + values: + $ref: '#/components/schemas/JsonObject' + secrets: + type: object + additionalProperties: + type: string + directoryContents: + type: array + items: + type: object + properties: + path: + type: string + base64Content: + type: string + required: + - template + - values + - directoryContents + responses: + '200': + description: Ok + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/DryRunResult' + - type: object + properties: + steps: + type: array + items: + type: object + properties: + id: + type: string + name: + type: string + action: + type: string + required: + - id + - name + - action + additionalProperties: {} + directoryContents: + type: array + items: + type: object + properties: + path: + type: string + executable: + type: boolean + base64Content: + type: string + required: + - path + - base64Content + required: + - steps + '400': + description: Validation errors. + content: + application/json: + schema: + type: object + properties: + errors: + type: array + items: + $ref: '#/components/schemas/ValidationError' + required: + - errors + parameters: [] + + /v2/autocomplete/{provider}/{resource}: + post: + operationId: Autocomplete + description: Perform an autocomplete for the given provider and resource. + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + context: + type: object + additionalProperties: + type: string + token: + type: string + required: + - context + - token + responses: + '200': + description: Ok + content: + application/json: + schema: + type: object + properties: + results: + type: array + items: + type: object + properties: + title: + type: string + id: + type: string + required: + - id + required: + - results + '400': + description: Unsupported provider. + content: + application/json: + schema: + type: object + properties: + message: + type: string + name: + type: string + parameters: + - in: path + name: provider + required: true + allowReserved: true + schema: + type: string + - in: path + name: resource + required: true + allowReserved: true + schema: + type: string + + /v2/templating-extensions: + get: + operationId: ListTemplatingExtensions + description: Returns a structure describing the available templating extensions. + responses: + '200': + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/ListTemplatingExtensionsResponse' + security: + - {} + - JWT: [] + parameters: [] diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts new file mode 100644 index 0000000000..c5bd9f0ac2 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts @@ -0,0 +1,163 @@ +/* + * 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. + */ + +// + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { Action } from '../models/Action.model'; +import { Autocomplete200Response } from '../models/Autocomplete200Response.model'; +import { Autocomplete400Response } from '../models/Autocomplete400Response.model'; +import { AutocompleteRequest } from '../models/AutocompleteRequest.model'; +import { CancelTask200Response } from '../models/CancelTask200Response.model'; +import { DryRun200Response } from '../models/DryRun200Response.model'; +import { DryRunRequest } from '../models/DryRunRequest.model'; +import { ListTasksResponse } from '../models/ListTasksResponse.model'; +import { ListTemplatingExtensionsResponse } from '../models/ListTemplatingExtensionsResponse.model'; +import { RetryRequest } from '../models/RetryRequest.model'; +import { Scaffold201Response } from '../models/Scaffold201Response.model'; +import { Scaffold400Response } from '../models/Scaffold400Response.model'; +import { ScaffolderScaffoldOptions } from '../models/ScaffolderScaffoldOptions.model'; +import { SerializedTask } from '../models/SerializedTask.model'; +import { SerializedTaskEvent } from '../models/SerializedTaskEvent.model'; +import { TemplateParameterSchema } from '../models/TemplateParameterSchema.model'; + +/** + * @public + */ +export type Autocomplete = { + path: { + provider: string; + resource: string; + }; + body: AutocompleteRequest; + response: Autocomplete200Response | Autocomplete400Response; +}; +/** + * @public + */ +export type CancelTask = { + path: { + taskId: string; + }; + response: CancelTask200Response; +}; +/** + * @public + */ +export type DryRun = { + body: DryRunRequest; + response: DryRun200Response | Scaffold400Response; +}; +/** + * @public + */ +export type GetTask = { + path: { + taskId: string; + }; + response: SerializedTask | Error; +}; +/** + * @public + */ +export type GetTemplateParameterSchema = { + path: { + namespace: string; + kind: string; + name: string; + }; + response: TemplateParameterSchema | Error | Error; +}; +/** + * @public + */ +export type ListActions = { + response: Array; +}; +/** + * @public + */ +export type ListTasks = { + query: { + createdBy?: Array; + limit?: number; + offset?: number; + order?: Array; + status?: Array; + }; + response: ListTasksResponse; +}; +/** + * @public + */ +export type ListTemplatingExtensions = { + response: ListTemplatingExtensionsResponse; +}; +/** + * @public + */ +export type Retry = { + path: { + taskId: string; + }; + body: RetryRequest; + response: Scaffold201Response; +}; +/** + * @public + */ +export type Scaffold = { + body: ScaffolderScaffoldOptions; + response: Scaffold201Response | Scaffold400Response; +}; +/** + * @public + */ +export type StreamLogsPolling = { + path: { + taskId: string; + }; + query: { + after?: number; + }; + response: Array | Error; +}; + +export type EndpointMap = { + '#post|/v2/autocomplete/{provider}/{resource}': Autocomplete; + + '#post|/v2/tasks/{taskId}/cancel': CancelTask; + + '#post|/v2/dry-run': DryRun; + + '#get|/v2/tasks/{taskId}': GetTask; + + '#get|/v2/templates/{namespace}/{kind}/{name}/parameter-schema': GetTemplateParameterSchema; + + '#get|/v2/actions': ListActions; + + '#get|/v2/tasks': ListTasks; + + '#get|/v2/templating-extensions': ListTemplatingExtensions; + + '#post|/v2/tasks/{taskId}/retry': Retry; + + '#post|/v2/tasks': Scaffold; + + '#get|/v2/tasks/{taskId}/events': StreamLogsPolling; +}; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/apis/index.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/apis/index.ts new file mode 100644 index 0000000000..8d81cbaf39 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/apis/index.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +// + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +export * from './Api.server'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/index.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/index.ts new file mode 100644 index 0000000000..dec4b8804e --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/index.ts @@ -0,0 +1,18 @@ +/* + * 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. + */ + +export * from './apis'; +export * from './router'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Action.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Action.model.ts new file mode 100644 index 0000000000..f9c028f3e3 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Action.model.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ActionExample } from '../models/ActionExample.model'; +import { ActionSchema } from '../models/ActionSchema.model'; + +/** + * The response shape for a single action in the `listActions` call to the `scaffolder-backend` + * @public + */ +export interface Action { + id: string; + description?: string; + examples?: Array; + schema?: ActionSchema; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ActionExample.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ActionExample.model.ts new file mode 100644 index 0000000000..50550e2883 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ActionExample.model.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * A single action example + * @public + */ +export interface ActionExample { + description: string; + example: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ActionSchema.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ActionSchema.model.ts new file mode 100644 index 0000000000..35d2014181 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ActionSchema.model.ts @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ActionSchema { + /** + * A type representing all allowed JSON object values. + */ + input?: { [key: string]: any }; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200Response.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200Response.model.ts new file mode 100644 index 0000000000..e3eec0aa20 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200Response.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { Autocomplete200ResponseResultsInner } from '../models/Autocomplete200ResponseResultsInner.model'; + +/** + * @public + */ +export interface Autocomplete200Response { + results: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts new file mode 100644 index 0000000000..00ccb41b0f --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface Autocomplete200ResponseResultsInner { + title?: string; + id: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete400Response.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete400Response.model.ts new file mode 100644 index 0000000000..1456babb96 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete400Response.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface Autocomplete400Response { + message?: string; + name?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/AutocompleteRequest.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/AutocompleteRequest.model.ts new file mode 100644 index 0000000000..769a929918 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/AutocompleteRequest.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface AutocompleteRequest { + context: { [key: string]: string }; + token: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/CancelTask200Response.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/CancelTask200Response.model.ts new file mode 100644 index 0000000000..f29c509d41 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/CancelTask200Response.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; + +/** + * @public + */ +export interface CancelTask200Response { + status?: TaskStatus; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200Response.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200Response.model.ts new file mode 100644 index 0000000000..62e3689d5d --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200Response.model.ts @@ -0,0 +1,35 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRun200ResponseAllOfDirectoryContentsInner } from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model'; +import { DryRun200ResponseAllOfStepsInner } from '../models/DryRun200ResponseAllOfStepsInner.model'; +import { DryRunResultLogInner } from '../models/DryRunResultLogInner.model'; + +/** + * @public + */ +export interface DryRun200Response { + log: Array; + directoryContents: Array; + /** + * A type representing all allowed JSON object values. + */ + output: { [key: string]: any }; + steps: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts new file mode 100644 index 0000000000..5b6c2ff9c7 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRun200ResponseAllOfDirectoryContentsInner } from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model'; +import { DryRun200ResponseAllOfStepsInner } from '../models/DryRun200ResponseAllOfStepsInner.model'; + +/** + * @public + */ +export interface DryRun200ResponseAllOf { + steps: Array; + directoryContents?: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfDirectoryContentsInner.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfDirectoryContentsInner.model.ts new file mode 100644 index 0000000000..2646ca49f9 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfDirectoryContentsInner.model.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface DryRun200ResponseAllOfDirectoryContentsInner { + path: string; + executable?: boolean; + base64Content: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts new file mode 100644 index 0000000000..2a462edefa --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface DryRun200ResponseAllOfStepsInner { + [key: string]: any; + + id: string; + name: string; + action: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunRequest.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunRequest.model.ts new file mode 100644 index 0000000000..212b36c26b --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunRequest.model.ts @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRunRequestDirectoryContentsInner } from '../models/DryRunRequestDirectoryContentsInner.model'; + +/** + * @public + */ +export interface DryRunRequest { + template: any; + /** + * A type representing all allowed JSON object values. + */ + values: { [key: string]: any }; + secrets?: { [key: string]: string }; + directoryContents: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunRequestDirectoryContentsInner.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunRequestDirectoryContentsInner.model.ts new file mode 100644 index 0000000000..ddcae4fd9d --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunRequestDirectoryContentsInner.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface DryRunRequestDirectoryContentsInner { + path?: string; + base64Content?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResult.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResult.model.ts new file mode 100644 index 0000000000..6e2ad23ef4 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResult.model.ts @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRunResultLogInner } from '../models/DryRunResultLogInner.model'; +import { SerializedFile } from '../models/SerializedFile.model'; + +/** + * @public + */ +export interface DryRunResult { + log: Array; + directoryContents: Array; + /** + * A type representing all allowed JSON object values. + */ + output: { [key: string]: any }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts new file mode 100644 index 0000000000..4c6b786d82 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model'; + +/** + * @public + */ +export interface DryRunResultLogInner { + body: DryRunResultLogInnerBody; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts new file mode 100644 index 0000000000..e3b19be045 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; + +/** + * @public + */ +export interface DryRunResultLogInnerBody { + message: string; + status?: TaskStatus; + stepId?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts new file mode 100644 index 0000000000..e67240ee54 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; + +/** + * @public + */ +export interface DryRunResultLogInnerBodyAllOf { + message: string; + status?: TaskStatus; + stepId?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorError.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorError.model.ts new file mode 100644 index 0000000000..e0265e95d7 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorError.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorError { + name: string; + message: string; + stack?: string; + code?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorRequest.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorRequest.model.ts new file mode 100644 index 0000000000..3eb5e15740 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorRequest.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorRequest { + method: string; + url: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorResponse.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorResponse.model.ts new file mode 100644 index 0000000000..edbcc32df7 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ErrorResponse.model.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorResponse { + statusCode: number; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/JsonPrimitive.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/JsonPrimitive.model.ts new file mode 100644 index 0000000000..6aa6394c14 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/JsonPrimitive.model.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * A type representing all allowed JSON primitive values. + * @public + */ +export type JsonPrimitive = any | boolean | number | string; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/JsonValue.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/JsonValue.model.ts new file mode 100644 index 0000000000..9fe2ac9de3 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/JsonValue.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { JsonPrimitive } from '../models/JsonPrimitive.model'; + +/** + * A type representing all allowed JSON values. + * @public + */ +export type JsonValue = + | Array + | JsonPrimitive + | { [key: string]: any }; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTasksResponse.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTasksResponse.model.ts new file mode 100644 index 0000000000..9347c766a9 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTasksResponse.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { SerializedTask } from '../models/SerializedTask.model'; + +/** + * The response shape for the `listTasks` call to the `scaffolder-backend` + * @public + */ +export interface ListTasksResponse { + tasks: Array; + totalTasks?: number; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts new file mode 100644 index 0000000000..74b7cd3780 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ListTemplatingExtensionsResponseGlobals } from '../models/ListTemplatingExtensionsResponseGlobals.model'; +import { TemplateFilter } from '../models/TemplateFilter.model'; + +/** + * The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface ListTemplatingExtensionsResponse { + filters: { [key: string]: TemplateFilter }; + globals: ListTemplatingExtensionsResponseGlobals; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts new file mode 100644 index 0000000000..1f022a0675 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TemplateGlobalFunction } from '../models/TemplateGlobalFunction.model'; +import { TemplateGlobalValue } from '../models/TemplateGlobalValue.model'; + +/** + * @public + */ +export interface ListTemplatingExtensionsResponseGlobals { + functions: { [key: string]: TemplateGlobalFunction }; + values: { [key: string]: TemplateGlobalValue }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ModelError.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ModelError.model.ts new file mode 100644 index 0000000000..958fde7d0b --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ModelError.model.ts @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ErrorError } from '../models/ErrorError.model'; +import { ErrorRequest } from '../models/ErrorRequest.model'; +import { ErrorResponse } from '../models/ErrorResponse.model'; + +/** + * @public + */ +export interface ModelError { + [key: string]: any; + + error: ErrorError; + request?: ErrorRequest; + response: ErrorResponse; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/RetryRequest.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/RetryRequest.model.ts new file mode 100644 index 0000000000..858fa67566 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/RetryRequest.model.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface RetryRequest { + secrets?: { [key: string]: string }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Scaffold201Response.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Scaffold201Response.model.ts new file mode 100644 index 0000000000..1271642e81 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Scaffold201Response.model.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface Scaffold201Response { + id: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Scaffold400Response.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Scaffold400Response.model.ts new file mode 100644 index 0000000000..e3cb7eaa45 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Scaffold400Response.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ValidationError } from '../models/ValidationError.model'; + +/** + * @public + */ +export interface Scaffold400Response { + errors: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts new file mode 100644 index 0000000000..93f4ae71c0 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * The input options to the `scaffold` method of the `ScaffolderClient`. + * @public + */ +export interface ScaffolderScaffoldOptions { + templateRef: string; + values: { [key: string]: any }; + secrets?: { [key: string]: string }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts new file mode 100644 index 0000000000..3e0f4ef866 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * A single scaffolder usage example + * @public + */ +export interface ScaffolderUsageExample { + description?: string; + example: string; + notes?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedFile.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedFile.model.ts new file mode 100644 index 0000000000..65a3c714a7 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedFile.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface SerializedFile { + path: string; + content: string; + executable?: boolean; + symlink?: boolean; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTask.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTask.model.ts new file mode 100644 index 0000000000..67cbf14279 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTask.model.ts @@ -0,0 +1,39 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TaskSecrets } from '../models/TaskSecrets.model'; +import { TaskStatus } from '../models/TaskStatus.model'; + +/** + * SerializedTask + * @public + */ +export interface SerializedTask { + id: string; + spec: any; + status: TaskStatus; + createdAt: string; + lastHeartbeatAt?: string; + createdBy?: string; + secrets?: TaskSecrets; + /** + * A type representing all allowed JSON object values. + */ + state?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts new file mode 100644 index 0000000000..6e4ddaa296 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts @@ -0,0 +1,34 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model'; +import { TaskEventType } from '../models/TaskEventType.model'; + +/** + * SerializedTaskEvent + * @public + */ +export interface SerializedTaskEvent { + id: number; + isTaskRecoverable?: boolean; + taskId: string; + body: DryRunResultLogInnerBody; + type: TaskEventType; + createdAt: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskEventType.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskEventType.model.ts new file mode 100644 index 0000000000..d32d77a448 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskEventType.model.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export type TaskEventType = 'cancelled' | 'completion' | 'log' | 'recovered'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecrets.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecrets.model.ts new file mode 100644 index 0000000000..c78c39c1ec --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecrets.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * TaskSecrets + * @public + */ +export interface TaskSecrets { + backstageToken?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts new file mode 100644 index 0000000000..0b33852cc9 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TaskSecretsAllOf { + backstageToken?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskStatus.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskStatus.model.ts new file mode 100644 index 0000000000..1f209a3656 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskStatus.model.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export type TaskStatus = + | 'cancelled' + | 'completed' + | 'failed' + | 'open' + | 'processing' + | 'skipped'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilter.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilter.model.ts new file mode 100644 index 0000000000..7c631978e6 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilter.model.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ScaffolderUsageExample } from '../models/ScaffolderUsageExample.model'; +import { TemplateFilterSchema } from '../models/TemplateFilterSchema.model'; + +/** + * The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateFilter { + description?: string; + schema?: TemplateFilterSchema; + examples?: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts new file mode 100644 index 0000000000..5a95a58ead --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts @@ -0,0 +1,34 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateFilterSchema { + /** + * A type representing all allowed JSON object values. + */ + input?: { [key: string]: any }; + arguments?: Array<{ [key: string]: any }>; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts new file mode 100644 index 0000000000..ee19ce723b --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ScaffolderUsageExample } from '../models/ScaffolderUsageExample.model'; +import { TemplateGlobalFunctionSchema } from '../models/TemplateGlobalFunctionSchema.model'; + +/** + * The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateGlobalFunction { + description?: string; + schema?: TemplateGlobalFunctionSchema; + examples?: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts new file mode 100644 index 0000000000..b3a39c3b24 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateGlobalFunctionSchema { + arguments?: Array<{ [key: string]: any }>; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts new file mode 100644 index 0000000000..95d177a05a --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateGlobalValue { + description?: string; + value: any | null; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts new file mode 100644 index 0000000000..8638ee8114 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TemplateParameterSchemaStepsInner } from '../models/TemplateParameterSchemaStepsInner.model'; + +/** + * The shape of each entry of parameters which gets rendered as a separate step in the wizard input + * @public + */ +export interface TemplateParameterSchema { + [key: string]: any; + + title: string; + description?: string; + steps: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts new file mode 100644 index 0000000000..2f7892fd41 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateParameterSchemaStepsInner { + title: string; + description?: string; + schema: any; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationError.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationError.model.ts new file mode 100644 index 0000000000..7e762f616c --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationError.model.ts @@ -0,0 +1,36 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ValidationErrorArgument } from '../models/ValidationErrorArgument.model'; +import { ValidationErrorPathInner } from '../models/ValidationErrorPathInner.model'; + +/** + * @public + */ +export interface ValidationError { + [key: string]: any; + + path: Array; + property: string; + message: string; + instance: any; + name: string; + argument: ValidationErrorArgument; + stack: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorArgument.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorArgument.model.ts new file mode 100644 index 0000000000..85c9576fd0 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorArgument.model.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export type ValidationErrorArgument = any | boolean | number | string; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorPathInner.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorPathInner.model.ts new file mode 100644 index 0000000000..4535c735db --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorPathInner.model.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export type ValidationErrorPathInner = number | string; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts new file mode 100644 index 0000000000..1bc447fa3d --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts @@ -0,0 +1,65 @@ +/* + * 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. + */ + +export * from '../models/Action.model'; +export * from '../models/ActionExample.model'; +export * from '../models/ActionSchema.model'; +export * from '../models/Autocomplete200Response.model'; +export * from '../models/Autocomplete200ResponseResultsInner.model'; +export * from '../models/Autocomplete400Response.model'; +export * from '../models/AutocompleteRequest.model'; +export * from '../models/CancelTask200Response.model'; +export * from '../models/DryRun200Response.model'; +export * from '../models/DryRun200ResponseAllOf.model'; +export * from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model'; +export * from '../models/DryRun200ResponseAllOfStepsInner.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/ErrorError.model'; +export * from '../models/ErrorRequest.model'; +export * from '../models/ErrorResponse.model'; +export * from '../models/JsonPrimitive.model'; +export * from '../models/JsonValue.model'; +export * from '../models/ListTasksResponse.model'; +export * from '../models/ListTemplatingExtensionsResponse.model'; +export * from '../models/ListTemplatingExtensionsResponseGlobals.model'; +export * from '../models/ModelError.model'; +export * from '../models/RetryRequest.model'; +export * from '../models/Scaffold201Response.model'; +export * from '../models/Scaffold400Response.model'; +export * from '../models/ScaffolderScaffoldOptions.model'; +export * from '../models/ScaffolderUsageExample.model'; +export * from '../models/SerializedFile.model'; +export * from '../models/SerializedTask.model'; +export * from '../models/SerializedTaskEvent.model'; +export * from '../models/TaskEventType.model'; +export * from '../models/TaskSecrets.model'; +export * from '../models/TaskSecretsAllOf.model'; +export * from '../models/TaskStatus.model'; +export * from '../models/TemplateFilter.model'; +export * from '../models/TemplateFilterSchema.model'; +export * from '../models/TemplateGlobalFunction.model'; +export * from '../models/TemplateGlobalFunctionSchema.model'; +export * from '../models/TemplateGlobalValue.model'; +export * from '../models/TemplateParameterSchema.model'; +export * from '../models/TemplateParameterSchemaStepsInner.model'; +export * from '../models/ValidationError.model'; +export * from '../models/ValidationErrorArgument.model'; +export * from '../models/ValidationErrorPathInner.model'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts new file mode 100644 index 0000000000..669dd63878 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts @@ -0,0 +1,1328 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { createValidatedOpenApiRouterFromGeneratedEndpointMap } from '@backstage/backend-openapi-utils'; +import { EndpointMap } from './apis'; + +export const spec = { + openapi: '3.0.3', + info: { + title: 'scaffolder', + version: '1', + description: + 'The Backstage backend plugin that helps you create new things', + license: { + name: 'Apache-2.0', + url: 'http://www.apache.org/licenses/LICENSE-2.0.html', + }, + contact: {}, + }, + servers: [ + { + url: '/', + }, + ], + components: { + examples: {}, + headers: {}, + parameters: { + createdBy: { + name: 'createdBy', + in: 'query', + description: 'Created by', + required: false, + allowReserved: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + eventsAfter: { + name: 'after', + in: 'query', + description: 'Offset event ID to stream events after.', + required: false, + allowReserved: true, + schema: { + type: 'integer', + }, + }, + kind: { + name: 'kind', + in: 'path', + required: true, + allowReserved: true, + schema: { + type: 'string', + }, + }, + limit: { + name: 'limit', + in: 'query', + description: 'Number of records to return in the response.', + required: false, + allowReserved: true, + schema: { + type: 'integer', + minimum: 0, + }, + }, + namespace: { + name: 'namespace', + in: 'path', + required: true, + allowReserved: true, + schema: { + type: 'string', + }, + }, + name: { + name: 'name', + in: 'path', + required: true, + allowReserved: true, + schema: { + type: 'string', + }, + }, + offset: { + name: 'offset', + in: 'query', + description: 'Number of records to skip in the query page.', + required: false, + allowReserved: true, + schema: { + type: 'integer', + minimum: 0, + }, + }, + order: { + name: 'order', + in: 'query', + description: 'Order', + required: false, + allowReserved: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + status: { + name: 'status', + in: 'query', + description: 'Status', + required: false, + allowReserved: true, + schema: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + taskId: { + name: 'taskId', + in: 'path', + required: true, + allowReserved: true, + schema: { + type: 'string', + }, + }, + }, + requestBodies: {}, + responses: { + ErrorResponse: { + description: 'An error response from the backend.', + content: { + 'application/json; charset=utf-8': { + schema: { + $ref: '#/components/schemas/Error', + }, + }, + }, + }, + }, + schemas: { + Action: { + type: 'object', + properties: { + id: { + type: 'string', + }, + description: { + type: 'string', + }, + "'examples'": { + type: 'array', + items: { + $ref: '#/components/schemas/ActionExample', + }, + }, + schema: { + type: 'object', + properties: { + input: { + $ref: '#/components/schemas/JsonObject', + }, + output: { + $ref: '#/components/schemas/JsonObject', + }, + }, + }, + }, + required: ['id'], + description: + 'The response shape for a single action in the `listActions` call to the `scaffolder-backend`', + }, + ActionExample: { + type: 'object', + properties: { + description: { + type: 'string', + }, + example: { + type: 'string', + }, + }, + required: ['description', 'example'], + description: 'A single action example', + }, + DryRunResult: { + type: 'object', + properties: { + log: { + type: 'array', + items: { + type: 'object', + properties: { + body: { + allOf: [ + { + $ref: '#/components/schemas/JsonObject', + }, + { + type: 'object', + properties: { + message: { + type: 'string', + }, + status: { + $ref: '#/components/schemas/TaskStatus', + }, + stepId: { + type: 'string', + }, + }, + required: ['message'], + }, + ], + }, + }, + required: ['body'], + }, + }, + directoryContents: { + type: 'array', + items: { + $ref: '#/components/schemas/SerializedFile', + }, + }, + output: { + $ref: '#/components/schemas/JsonObject', + }, + }, + required: ['log', 'directoryContents', 'output'], + }, + Error: { + type: 'object', + properties: { + error: { + type: 'object', + properties: { + name: { + type: 'string', + }, + message: { + type: 'string', + }, + stack: { + type: 'string', + }, + code: { + type: 'string', + }, + }, + required: ['name', 'message'], + }, + request: { + type: 'object', + properties: { + method: { + type: 'string', + }, + url: { + type: 'string', + }, + }, + required: ['method', 'url'], + }, + response: { + type: 'object', + properties: { + statusCode: { + type: 'number', + }, + }, + required: ['statusCode'], + }, + }, + required: ['error', 'response'], + additionalProperties: {}, + }, + JsonArray: { + type: 'array', + items: { + $ref: '#/components/schemas/JsonValue', + }, + description: 'A type representing all allowed JSON array values.', + }, + JsonObject: { + type: 'object', + properties: {}, + description: 'A type representing all allowed JSON object values.', + additionalProperties: {}, + }, + JsonPrimitive: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'number', + }, + { + type: 'string', + }, + { + type: 'object', + nullable: true, + }, + ], + description: 'A type representing all allowed JSON primitive values.', + }, + JsonValue: { + oneOf: [ + { + $ref: '#/components/schemas/JsonObject', + }, + { + $ref: '#/components/schemas/JsonArray', + }, + { + $ref: '#/components/schemas/JsonPrimitive', + }, + ], + description: 'A type representing all allowed JSON values.', + }, + ListActionsResponse: { + type: 'array', + items: { + $ref: '#/components/schemas/Action', + }, + description: + 'The response shape for the `listActions` call to the `scaffolder-backend`', + }, + ListTasksResponse: { + type: 'object', + properties: { + tasks: { + type: 'array', + items: { + $ref: '#/components/schemas/SerializedTask', + }, + }, + totalTasks: { + type: 'number', + }, + }, + required: ['tasks'], + description: + 'The response shape for the `listTasks` call to the `scaffolder-backend`', + }, + ListTemplatingExtensionsResponse: { + type: 'object', + properties: { + filters: { + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/TemplateFilter', + }, + }, + globals: { + type: 'object', + properties: { + functions: { + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/TemplateGlobalFunction', + }, + }, + values: { + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/TemplateGlobalValue', + }, + }, + }, + required: ['functions', 'values'], + }, + }, + required: ['filters', 'globals'], + description: + 'The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend`', + }, + ScaffolderScaffoldOptions: { + type: 'object', + properties: { + templateRef: { + type: 'string', + }, + values: { + type: 'object', + additionalProperties: {}, + }, + secrets: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + required: ['templateRef', 'values'], + description: + 'The input options to the `scaffold` method of the `ScaffolderClient`.', + }, + ScaffolderUsageExample: { + type: 'object', + properties: { + description: { + type: 'string', + }, + example: { + type: 'string', + }, + notes: { + type: 'string', + }, + }, + required: ['example'], + description: 'A single scaffolder usage example', + }, + SerializedFile: { + type: 'object', + properties: { + path: { + type: 'string', + }, + content: { + type: 'string', + }, + executable: { + type: 'boolean', + }, + symlink: { + type: 'boolean', + }, + }, + required: ['path', 'content'], + }, + SerializedTaskEvent: { + type: 'object', + properties: { + id: { + type: 'integer', + }, + isTaskRecoverable: { + type: 'boolean', + }, + taskId: { + type: 'string', + }, + body: { + allOf: [ + { + $ref: '#/components/schemas/JsonObject', + }, + { + type: 'object', + properties: { + message: { + type: 'string', + }, + status: { + $ref: '#/components/schemas/TaskStatus', + }, + stepId: { + type: 'string', + }, + }, + required: ['message'], + }, + ], + }, + type: { + $ref: '#/components/schemas/TaskEventType', + }, + createdAt: { + type: 'string', + }, + }, + required: ['id', 'taskId', 'body', 'type', 'createdAt'], + description: 'SerializedTaskEvent', + }, + SerializedTask: { + type: 'object', + properties: { + id: { + type: 'string', + }, + spec: { + type: 'object', + }, + status: { + $ref: '#/components/schemas/TaskStatus', + }, + createdAt: { + type: 'string', + }, + lastHeartbeatAt: { + type: 'string', + }, + createdBy: { + type: 'string', + }, + secrets: { + $ref: '#/components/schemas/TaskSecrets', + }, + state: { + $ref: '#/components/schemas/JsonObject', + }, + }, + required: ['id', 'spec', 'status', 'createdAt'], + description: 'SerializedTask', + }, + TaskEventType: { + type: 'string', + description: 'TaskEventType', + enum: ['cancelled', 'completion', 'log', 'recovered'], + }, + TaskSecrets: { + allOf: [ + { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + { + type: 'object', + properties: { + backstageToken: { + type: 'string', + }, + }, + }, + ], + description: 'TaskSecrets', + }, + TaskStatus: { + type: 'string', + enum: [ + 'cancelled', + 'completed', + 'failed', + 'open', + 'processing', + 'skipped', + ], + description: 'The status of each step of the Task', + }, + TemplateGlobalFunction: { + type: 'object', + properties: { + description: { + type: 'string', + }, + schema: { + type: 'object', + properties: { + arguments: { + type: 'array', + items: { + $ref: '#/components/schemas/JsonObject', + }, + }, + output: { + $ref: '#/components/schemas/JsonObject', + }, + }, + }, + "'examples'": { + type: 'array', + items: { + $ref: '#/components/schemas/ScaffolderUsageExample', + }, + }, + }, + description: + 'The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend`', + }, + TemplateGlobalValue: { + type: 'object', + properties: { + description: { + type: 'string', + }, + value: { + type: 'object', + nullable: true, + }, + }, + required: ['value'], + description: + 'The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend`', + }, + TemplateFilter: { + type: 'object', + properties: { + description: { + type: 'string', + }, + schema: { + type: 'object', + properties: { + input: { + $ref: '#/components/schemas/JsonObject', + }, + arguments: { + type: 'array', + items: { + $ref: '#/components/schemas/JsonObject', + }, + }, + output: { + $ref: '#/components/schemas/JsonObject', + }, + }, + }, + "'examples'": { + type: 'array', + items: { + $ref: '#/components/schemas/ScaffolderUsageExample', + }, + }, + }, + description: + 'The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend`', + }, + TemplateParameterSchema: { + type: 'object', + properties: { + title: { + type: 'string', + }, + description: { + type: 'string', + }, + steps: { + type: 'array', + items: { + type: 'object', + properties: { + title: { + type: 'string', + }, + description: { + type: 'string', + }, + schema: { + type: 'object', + }, + }, + required: ['title', 'schema'], + }, + }, + }, + required: ['title', 'steps'], + description: + 'The shape of each entry of parameters which gets rendered\nas a separate step in the wizard input', + additionalProperties: {}, + }, + ValidationError: { + type: 'object', + properties: { + path: { + type: 'array', + items: { + oneOf: [ + { + type: 'string', + }, + { + type: 'integer', + }, + ], + }, + }, + property: { + type: 'string', + }, + message: { + type: 'string', + }, + instance: { + type: 'object', + }, + name: { + type: 'string', + }, + argument: { + oneOf: [ + { + type: 'boolean', + }, + { + type: 'number', + }, + { + type: 'object', + }, + { + type: 'string', + }, + ], + }, + stack: { + type: 'string', + }, + }, + required: [ + 'path', + 'property', + 'message', + 'schema', + 'instance', + 'name', + 'argument', + 'stack', + ], + additionalProperties: {}, + }, + }, + securitySchemes: { + JWT: { + type: 'http', + scheme: 'bearer', + bearerFormat: 'JWT', + }, + }, + }, + paths: { + '/v2/templates/{namespace}/{kind}/{name}/parameter-schema': { + get: { + operationId: 'GetTemplateParameterSchema', + description: 'Get template parameter schema.', + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/TemplateParameterSchema', + }, + }, + }, + }, + '400': { + $ref: '#/components/responses/ErrorResponse', + }, + default: { + $ref: '#/components/responses/ErrorResponse', + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [ + { + $ref: '#/components/parameters/namespace', + }, + { + $ref: '#/components/parameters/kind', + }, + { + $ref: '#/components/parameters/name', + }, + ], + }, + }, + '/v2/actions': { + get: { + operationId: 'ListActions', + description: 'Returns a list of all installed actions.', + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ListActionsResponse', + }, + }, + }, + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [], + }, + }, + '/v2/tasks': { + get: { + operationId: 'ListTasks', + description: + 'Returns a list of tasks, filtering by ownership and/or status if given.', + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ListTasksResponse', + }, + }, + }, + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [ + { + $ref: '#/components/parameters/createdBy', + }, + { + $ref: '#/components/parameters/limit', + }, + { + $ref: '#/components/parameters/offset', + }, + { + $ref: '#/components/parameters/order', + }, + { + $ref: '#/components/parameters/status', + }, + ], + }, + post: { + operationId: 'Scaffold', + description: + 'Executes the scaffolding of a component, given a template and its\nparameter values.', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ScaffolderScaffoldOptions', + }, + }, + }, + }, + responses: { + '201': { + description: 'Created', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { + type: 'string', + }, + }, + required: ['id'], + }, + }, + }, + }, + '400': { + description: 'Validation errors.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + errors: { + type: 'array', + items: { + $ref: '#/components/schemas/ValidationError', + }, + }, + }, + required: ['errors'], + }, + }, + }, + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [], + }, + }, + '/v2/tasks/{taskId}': { + get: { + operationId: 'GetTask', + description: 'Get a task by ID.', + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/SerializedTask', + }, + }, + }, + }, + '403': { + $ref: '#/components/responses/ErrorResponse', + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [ + { + $ref: '#/components/parameters/taskId', + }, + ], + }, + }, + '/v2/tasks/{taskId}/cancel': { + post: { + operationId: 'CancelTask', + description: + 'Sends a signal to a task broker to cancel the running task by taskId.', + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { + $ref: '#/components/schemas/TaskStatus', + }, + }, + }, + }, + }, + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [ + { + $ref: '#/components/parameters/taskId', + }, + ], + }, + }, + '/v2/tasks/{taskId}/retry': { + post: { + operationId: 'Retry', + description: 'Starts the task again from the point where it failed.', + requestBody: { + required: false, + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + secrets: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + responses: { + '201': { + description: 'Ok', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { + type: 'string', + }, + }, + required: ['id'], + }, + }, + }, + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [ + { + $ref: '#/components/parameters/taskId', + }, + ], + }, + }, + '/v2/tasks/{taskId}/events': { + get: { + operationId: 'StreamLogsPolling', + description: 'Get events for a task by ID.', + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + $ref: '#/components/schemas/SerializedTaskEvent', + }, + }, + }, + }, + }, + '403': { + $ref: '#/components/responses/ErrorResponse', + }, + }, + parameters: [ + { + $ref: '#/components/parameters/eventsAfter', + }, + { + $ref: '#/components/parameters/taskId', + }, + ], + }, + }, + '/v2/dry-run': { + post: { + operationId: 'DryRun', + description: 'Perform a dry-run of a template', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + template: { + type: 'object', + }, + values: { + $ref: '#/components/schemas/JsonObject', + }, + secrets: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + directoryContents: { + type: 'array', + items: { + type: 'object', + properties: { + path: { + type: 'string', + }, + base64Content: { + type: 'string', + }, + }, + }, + }, + }, + required: ['template', 'values', 'directoryContents'], + }, + }, + }, + }, + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + allOf: [ + { + $ref: '#/components/schemas/DryRunResult', + }, + { + type: 'object', + properties: { + steps: { + type: 'array', + items: { + type: 'object', + properties: { + id: { + type: 'string', + }, + name: { + type: 'string', + }, + action: { + type: 'string', + }, + }, + required: ['id', 'name', 'action'], + additionalProperties: {}, + }, + }, + directoryContents: { + type: 'array', + items: { + type: 'object', + properties: { + path: { + type: 'string', + }, + executable: { + type: 'boolean', + }, + base64Content: { + type: 'string', + }, + }, + required: ['path', 'base64Content'], + }, + }, + }, + required: ['steps'], + }, + ], + }, + }, + }, + }, + '400': { + description: 'Validation errors.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + errors: { + type: 'array', + items: { + $ref: '#/components/schemas/ValidationError', + }, + }, + }, + required: ['errors'], + }, + }, + }, + }, + }, + parameters: [], + }, + }, + '/v2/autocomplete/{provider}/{resource}': { + post: { + operationId: 'Autocomplete', + description: + 'Perform an autocomplete for the given provider and resource.', + requestBody: { + required: true, + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + context: { + type: 'object', + additionalProperties: { + type: 'string', + }, + }, + token: { + type: 'string', + }, + }, + required: ['context', 'token'], + }, + }, + }, + }, + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + results: { + type: 'array', + items: { + type: 'object', + properties: { + title: { + type: 'string', + }, + id: { + type: 'string', + }, + }, + required: ['id'], + }, + }, + }, + required: ['results'], + }, + }, + }, + }, + '400': { + description: 'Unsupported provider.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + message: { + type: 'string', + }, + name: { + type: 'string', + }, + }, + }, + }, + }, + }, + }, + parameters: [ + { + in: 'path', + name: 'provider', + required: true, + allowReserved: true, + schema: { + type: 'string', + }, + }, + { + in: 'path', + name: 'resource', + required: true, + allowReserved: true, + schema: { + type: 'string', + }, + }, + ], + }, + }, + '/v2/templating-extensions': { + get: { + operationId: 'ListTemplatingExtensions', + description: + 'Returns a structure describing the available templating extensions.', + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ListTemplatingExtensionsResponse', + }, + }, + }, + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [], + }, + }, + }, +} as const; +export const createOpenApiRouter = async ( + options?: Parameters< + typeof createValidatedOpenApiRouterFromGeneratedEndpointMap + >['1'], +) => + createValidatedOpenApiRouterFromGeneratedEndpointMap( + spec, + options, + ); diff --git a/plugins/scaffolder-backend/src/schema/openapi/index.ts b/plugins/scaffolder-backend/src/schema/openapi/index.ts new file mode 100644 index 0000000000..196aad553a --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/index.ts @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export * from './generated'; diff --git a/plugins/scaffolder-backend/src/service/router.test.ts b/plugins/scaffolder-backend/src/service/router.test.ts index bebfadb9b1..467b590bed 100644 --- a/plugins/scaffolder-backend/src/service/router.test.ts +++ b/plugins/scaffolder-backend/src/service/router.test.ts @@ -16,6 +16,7 @@ import { DatabaseManager } from '@backstage/backend-defaults/database'; import { ConfigReader } from '@backstage/config'; +import express from 'express'; import request from 'supertest'; import ObservableImpl from 'zen-observable'; @@ -41,6 +42,7 @@ import { TaskSpec } from '@backstage/plugin-scaffolder-common'; import { JsonValue } from '@backstage/types'; import { StorageTaskBroker } from '../scaffolder/tasks/StorageTaskBroker'; import { AuthorizeResult } from '@backstage/plugin-permission-common'; +import { wrapServer } from '@backstage/backend-openapi-utils/testUtils'; import { mockCredentials, mockErrorHandler, @@ -56,7 +58,7 @@ import { } from '@backstage/plugin-scaffolder-node/alpha'; import { catalogServiceMock } from '@backstage/plugin-catalog-node/testUtils'; import { DatabaseService } from '@backstage/backend-plugin-api'; - +import { createDebugLogAction } from '../scaffolder/actions/builtin'; import { ScmIntegrations } from '@backstage/integration'; import { extractFilterMetadata, @@ -242,11 +244,20 @@ const createTestRouter = async ( }, handler: async () => {}, }), + createDebugLogAction(), ], }); router.use(mockErrorHandler()); - return { router, logger, taskBroker, permissions, catalog }; + const wrappedRouter = await wrapServer(express().use(router)); + return { + router: wrappedRouter, + unwrappedRouter: router, + logger, + taskBroker, + permissions, + catalog, + }; }; describe('scaffolder router', () => { @@ -262,7 +273,7 @@ describe('scaffolder router', () => { const response = await request(router).get('/v2/actions').send(); expect(response.status).toEqual(200); expect(response.body[0].id).toBeDefined(); - expect(response.body.length).toBe(1); + expect(response.body.length).toBe(2); }); }); @@ -704,7 +715,10 @@ describe('scaffolder router', () => { }, }); - console.log(status, body); + expect(status).toBe(201); + expect(body).toMatchObject({ + id: expect.any(String), + }); expect(logger.info).toHaveBeenCalledTimes(1); expect(logger.info).toHaveBeenCalledWith( 'Scaffolding task for template:default/create-react-app-template created by user:default/mock', @@ -1034,7 +1048,7 @@ describe('scaffolder router', () => { describe('GET /v2/tasks/:taskId/eventstream', () => { it('should return log messages', async () => { - const { router, taskBroker } = await createTestRouter(); + const { unwrappedRouter: router, taskBroker } = await createTestRouter(); (taskBroker.get as jest.Mocked['get']).mockResolvedValue({ id: 'a-random-id', spec: {} as any, @@ -1129,7 +1143,7 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{ }); it('should return log messages with after query', async () => { - const { router, taskBroker } = await createTestRouter(); + const { unwrappedRouter: router, taskBroker } = await createTestRouter(); (taskBroker.get as jest.Mocked['get']).mockResolvedValue({ id: 'a-random-id', spec: {} as any, @@ -1433,7 +1447,7 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{ it('should call the autocomplete handler', async () => { const handleAutocompleteRequest = jest.fn().mockResolvedValue({ - results: [{ title: 'blob' }], + results: [{ id: 'a-random-id', title: 'blob' }], }); const { router } = await createTestRouter({ @@ -1454,7 +1468,9 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{ expect(response.status).toEqual(200); - expect(response.body).toEqual({ results: [{ title: 'blob' }] }); + expect(response.body).toEqual({ + results: [{ id: 'a-random-id', title: 'blob' }], + }); expect(handleAutocompleteRequest).toHaveBeenCalledWith({ token: mockToken, context, diff --git a/plugins/scaffolder-backend/src/service/router.ts b/plugins/scaffolder-backend/src/service/router.ts index 6e476d9a19..e8b9f04797 100644 --- a/plugins/scaffolder-backend/src/service/router.ts +++ b/plugins/scaffolder-backend/src/service/router.ts @@ -79,7 +79,6 @@ import { } from '@backstage/plugin-scaffolder-node/alpha'; import { HumanDuration, JsonObject } from '@backstage/types'; import express from 'express'; -import Router from 'express-promise-router'; import { validate } from 'jsonschema'; import { Duration } from 'luxon'; import { pathToFileURL } from 'url'; @@ -93,6 +92,7 @@ import { import { createDryRunner } from '../scaffolder/dryrun'; import { StorageTaskBroker } from '../scaffolder/tasks/StorageTaskBroker'; import { InternalTaskSecrets } from '../scaffolder/tasks/types'; +import { createOpenApiRouter } from '../schema/openapi'; import { checkPermission, checkTaskPermission, @@ -102,7 +102,6 @@ import { findTemplate, getEntityBaseUrl, getWorkingDirectory, - parseNumberParam, parseStringsParam, } from './helpers'; @@ -187,7 +186,7 @@ const readDuration = ( export async function createRouter( options: RouterOptions, ): Promise { - const router = Router(); + const router = await createOpenApiRouter(); // Be generous in upload size to support a wide range of templates in dry-run mode. router.use(express.json({ limit: '10MB' })); @@ -404,8 +403,10 @@ export async function createRouter( description: template.metadata.description, 'ui:options': template.metadata['ui:options'], steps: parameters.map(schema => ({ - title: schema.title ?? 'Please enter the following information', - description: schema.description, + title: + (schema.title as string) ?? + 'Please enter the following information', + description: schema.description as string, schema, })), EXPERIMENTAL_formDecorators: @@ -587,8 +588,7 @@ export async function createRouter( }; }); - const limit = parseNumberParam(req.query.limit, 'limit'); - const offset = parseNumberParam(req.query.offset, 'offset'); + const { limit, offset } = req.query; const taskPermissionFilters = await getAuthorizeConditions({ credentials: credentials, @@ -604,8 +604,8 @@ export async function createRouter( }, order, pagination: { - limit: limit ? limit[0] : undefined, - offset: offset ? offset[0] : undefined, + limit, + offset, }, permissionFilters: taskPermissionFilters, }); @@ -747,8 +747,10 @@ export async function createRouter( await auditorEvent?.fail({ error: err }); throw err; } - }) - .get('/v2/tasks/:taskId/eventstream', async (req, res) => { + }); + (router as express.Router).get( + '/v2/tasks/:taskId/eventstream', + async (req, res) => { const { taskId } = req.params; const auditorEvent = await auditor?.createEvent({ @@ -823,7 +825,9 @@ export async function createRouter( await auditorEvent?.fail({ error: err }); throw err; } - }) + }, + ); + router .get('/v2/tasks/:taskId/events', async (req, res) => { const { taskId } = req.params; diff --git a/plugins/scaffolder-common/.eslintrc.js b/plugins/scaffolder-common/.eslintrc.js index e2a53a6ad2..c8ec42e57a 100644 --- a/plugins/scaffolder-common/.eslintrc.js +++ b/plugins/scaffolder-common/.eslintrc.js @@ -1 +1,10 @@ -module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); +module.exports = require('@backstage/cli/config/eslint-factory')(__dirname, { + overrides: [ + { + files: ['src/schema/openapi/generated/models/*.model.ts'], + rules: { + '@typescript-eslint/no-redeclare': 'off', + }, + }, + ], +}); diff --git a/plugins/scaffolder-common/package.json b/plugins/scaffolder-common/package.json index 631c106ef3..90af23777c 100644 --- a/plugins/scaffolder-common/package.json +++ b/plugins/scaffolder-common/package.json @@ -61,10 +61,20 @@ }, "dependencies": { "@backstage/catalog-model": "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", + "@types/json-schema": "^7.0.9", + "cross-fetch": "^4.0.0", + "json-schema": "^0.4.0", + "uri-template": "^2.0.0", + "zen-observable": "^0.10.0" }, "devDependencies": { - "@backstage/cli": "workspace:^" + "@backstage/cli": "workspace:^", + "@backstage/test-utils": "workspace:^", + "msw": "^1.0.0" } } diff --git a/plugins/scaffolder-common/report.api.md b/plugins/scaffolder-common/report.api.md index 455921c085..c6c5141cf2 100644 --- a/plugins/scaffolder-common/report.api.md +++ b/plugins/scaffolder-common/report.api.md @@ -7,15 +7,353 @@ 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?: ScaffolderUsageExample[]; +}; + // @public export const isTemplateEntityV1beta3: ( entity: Entity, ) => entity is TemplateEntityV1beta3; +// @public +export type ListActionsResponse = Array; + +// @public +export type ListTemplatingExtensionsResponse = { + filters: Record; + globals: { + functions: Record; + values: Record; + }; +}; + +// @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; + }, + options?: ScaffolderRequestOptions, + ): Promise<{ + results: { + title?: string; + id: string; + }[]; + }>; + cancelTask( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise<{ + status?: ScaffolderTaskStatus; + }>; + // (undocumented) + dryRun?( + request: ScaffolderDryRunOptions, + options?: ScaffolderRequestOptions, + ): Promise; + // (undocumented) + getIntegrationsList( + options: ScaffolderGetIntegrationsListOptions, + ): Promise; + // (undocumented) + getTask( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise; + // (undocumented) + getTemplateParameterSchema( + templateRef: string, + options?: ScaffolderRequestOptions, + ): Promise; + listActions(options?: ScaffolderRequestOptions): Promise; + // (undocumented) + listTasks?( + request: { + filterByOwnership: 'owned' | 'all'; + limit?: number; + offset?: number; + }, + options?: ScaffolderRequestOptions, + ): Promise<{ + tasks: ScaffolderTask[]; + totalTasks?: number; + }>; + listTemplatingExtensions?( + options?: ScaffolderRequestOptions, + ): Promise; + retry?( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise<{ + id: string; + }>; + scaffold( + request: ScaffolderScaffoldOptions, + options?: ScaffolderRequestOptions, + ): Promise; + // (undocumented) + streamLogs( + request: ScaffolderStreamLogsOptions, + options?: ScaffolderRequestOptions, + ): Observable; +} + +// @public +export class ScaffolderClient implements ScaffolderApi { + constructor(options: { + discoveryApi: { + getBaseUrl(pluginId: string): Promise; + }; + 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; + }): Promise<{ + results: { + title?: string; + id: string; + }[]; + }>; + cancelTask( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise<{ + status?: ScaffolderTaskStatus; + }>; + // (undocumented) + dryRun( + request: ScaffolderDryRunOptions, + options?: ScaffolderRequestOptions, + ): Promise; + // (undocumented) + getIntegrationsList( + options: ScaffolderGetIntegrationsListOptions, + ): Promise; + // (undocumented) + getTask( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise; + // (undocumented) + getTemplateParameterSchema( + templateRef: string, + options?: ScaffolderRequestOptions, + ): Promise; + listActions(options?: ScaffolderRequestOptions): Promise; + // (undocumented) + listTasks( + request: { + filterByOwnership: 'owned' | 'all'; + limit?: number; + offset?: number; + }, + options?: ScaffolderRequestOptions, + ): Promise<{ + tasks: ScaffolderTask[]; + totalTasks?: number; + }>; + listTemplatingExtensions( + options?: ScaffolderRequestOptions, + ): Promise; + retry?( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise<{ + id: string; + }>; + scaffold( + request: ScaffolderScaffoldOptions, + options?: ScaffolderRequestOptions, + ): Promise; + // (undocumented) + streamLogs( + request: ScaffolderStreamLogsOptions, + options?: ScaffolderRequestOptions, + ): Observable; +} + +// @public (undocumented) +export interface ScaffolderDryRunOptions { + // (undocumented) + directoryContents: { + path: string; + base64Content: string; + }[]; + // (undocumented) + secrets?: Record; + // (undocumented) + template: TemplateEntityV1beta3; + // (undocumented) + values: JsonObject; +} + +// @public (undocumented) +export interface ScaffolderDryRunResponse { + // (undocumented) + directoryContents: Array<{ + path: string; + base64Content: string; + executable?: boolean; + }>; + // (undocumented) + log: Array>; + // (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; + // (undocumented) + templateRef: string; + // (undocumented) + values: Record; +} + +// @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 +export type ScaffolderUsageExample = { + description?: string; + example: string; + notes?: string; +}; + +// @public (undocumented) +export type TaskEventType = 'cancelled' | 'completion' | 'log' | 'recovered'; + // @public export type TaskRecoverStrategy = 'none' | 'startOver'; @@ -94,6 +432,33 @@ export interface TemplateEntityV1beta3 extends Entity { // @public export const templateEntityV1beta3Validator: KindValidator; +// @public +export type TemplateFilter = { + description?: string; + schema?: { + input?: JSONSchema7; + arguments?: JSONSchema7[]; + output?: JSONSchema7; + }; + examples?: ScaffolderUsageExample[]; +}; + +// @public +export type TemplateGlobalFunction = { + description?: string; + schema?: { + arguments?: JSONSchema7[]; + output?: JSONSchema7; + }; + examples?: ScaffolderUsageExample[]; +}; + +// @public +export type TemplateGlobalValue = { + description?: string; + value: JsonValue; +}; + // @public export type TemplateInfo = { entityRef: string; @@ -103,6 +468,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) diff --git a/plugins/scaffolder/src/api.test.ts b/plugins/scaffolder-common/src/ScaffolderClient.test.ts similarity index 97% rename from plugins/scaffolder/src/api.test.ts rename to plugins/scaffolder-common/src/ScaffolderClient.test.ts index 1df2dacb17..03064d7086 100644 --- a/plugins/scaffolder/src/api.test.ts +++ b/plugins/scaffolder-common/src/ScaffolderClient.test.ts @@ -14,12 +14,15 @@ * limitations under the License. */ -import { ConfigReader } from '@backstage/core-app-api'; import { ScmIntegrations } from '@backstage/integration'; -import { MockFetchApi, registerMswTestHooks } from '@backstage/test-utils'; +import { + MockFetchApi, + mockApis, + registerMswTestHooks, +} from '@backstage/test-utils'; import { rest } from 'msw'; import { setupServer } from 'msw/node'; -import { ScaffolderClient } from './api'; +import { ScaffolderClient } from './ScaffolderClient'; import { fetchEventSource } from '@microsoft/fetch-event-source'; jest.mock('@microsoft/fetch-event-source'); @@ -31,6 +34,17 @@ const server = setupServer(); describe('api', () => { registerMswTestHooks(server); + const githubIntegrationConfig = mockApis.config({ + data: { + integrations: { + github: [ + { + host: 'hello.com', + }, + ], + }, + }, + }); const mockBaseUrl = 'http://backstage/api'; const discoveryApi = { getBaseUrl: async () => mockBaseUrl }; @@ -43,15 +57,7 @@ describe('api', () => { }; const scmIntegrationsApi = ScmIntegrations.fromConfig( - new ConfigReader({ - integrations: { - github: [ - { - host: 'hello.com', - }, - ], - }, - }), + githubIntegrationConfig, ); let apiClient: ScaffolderClient; diff --git a/plugins/scaffolder-common/src/ScaffolderClient.ts b/plugins/scaffolder-common/src/ScaffolderClient.ts new file mode 100644 index 0000000000..d40f7a4637 --- /dev/null +++ b/plugins/scaffolder-common/src/ScaffolderClient.ts @@ -0,0 +1,426 @@ +/* + * 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 { 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 './schema/openapi'; + +/** + * An API to interact with the scaffolder backend. + * + * @public + */ +export class ScaffolderClient implements ScaffolderApi { + private readonly apiClient: DefaultApiClient; + private readonly discoveryApi: { + getBaseUrl(pluginId: string): Promise; + }; + private readonly scmIntegrationsApi: ScmIntegrationRegistry; + private readonly fetchApi: { fetch: typeof fetch }; + private readonly identityApi?: { + getBackstageIdentity(): Promise<{ + type: 'user'; + userEntityRef: string; + ownershipEntityRefs: string[]; + }>; + }; + private readonly useLongPollingLogs: boolean; + + constructor(options: { + discoveryApi: { getBaseUrl(pluginId: string): Promise }; + fetchApi: { fetch: typeof fetch }; + identityApi?: { + getBackstageIdentity(): Promise<{ + type: 'user'; + userEntityRef: string; + ownershipEntityRefs: string[]; + }>; + }; + 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, + offset: request.offset, + }, + }, + options, + ), + ); + } + + async getIntegrationsList( + options: ScaffolderGetIntegrationsListOptions, + ): Promise { + 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 { + return await this.requestRequired( + await this.apiClient.getTemplateParameterSchema( + { + path: parseEntityRef(templateRef, { + defaultKind: 'template', + }), + }, + options, + ), + ); + } + + /** + * {@inheritdoc ScaffolderApi.scaffold} + */ + async scaffold( + request: ScaffolderScaffoldOptions, + options?: ScaffolderRequestOptions, + ): Promise { + 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 { + return await this.requestRequired( + await this.apiClient.getTask( + { + path: { taskId }, + }, + options, + ), + ); + } + + /** + * {@inheritdoc ScaffolderApi.streamLogs} + */ + streamLogs( + request: ScaffolderStreamLogsOptions, + options?: ScaffolderRequestOptions, + ): Observable { + if (this.useLongPollingLogs) { + return this.streamLogsPolling(request, options); + } + + return this.streamLogsEventStream(request); + } + + /** + * {@inheritdoc ScaffolderApi.dryRun} + */ + async dryRun( + request: ScaffolderDryRunOptions, + options?: ScaffolderRequestOptions, + ): Promise { + 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 { + 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 { + 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 { + return await this.requestRequired( + await this.apiClient.listActions(null as any, options), + ); + } + + /** + * {@inheritdoc ScaffolderApi.listTemplatingExtensions} + */ + async listTemplatingExtensions( + options?: ScaffolderRequestOptions, + ): Promise { + return await this.requestRequired( + await this.apiClient.listTemplatingExtensions(null as any, options), + ); + } + + /** + * {@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?( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise<{ id: string }> { + return await this.requestRequired( + await this.apiClient.retry({ body: {}, path: { taskId } }, options), + ); + } + + /** + * {@inheritdoc ScaffolderApi.retry} + */ + async autocomplete({ + token, + resource, + provider, + context, + }: { + token: string; + provider: string; + resource: string; + context: Record; + }): 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(response: TypedResponse): Promise { + if (!response.ok) { + throw await ResponseError.fromResponse(response); + } + + return response.json(); + } +} diff --git a/plugins/scaffolder-common/src/TemplateEntityV1beta3.ts b/plugins/scaffolder-common/src/TemplateEntityV1beta3.ts index 304057af77..1851b7e70f 100644 --- a/plugins/scaffolder-common/src/TemplateEntityV1beta3.ts +++ b/plugins/scaffolder-common/src/TemplateEntityV1beta3.ts @@ -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. * diff --git a/plugins/scaffolder-common/src/api.ts b/plugins/scaffolder-common/src/api.ts new file mode 100644 index 0000000000..5425607d34 --- /dev/null +++ b/plugins/scaffolder-common/src/api.ts @@ -0,0 +1,337 @@ +/* + * 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 type { + TaskEventType, + TaskStatus as ScaffolderTaskStatus, +} from './schema/openapi'; + +export type { ScaffolderTaskStatus, TaskEventType }; + +/** + * Options you can pass into a Scaffolder request for additional information. + * + * @public + */ +export interface ScaffolderRequestOptions { + token?: string; +} + +/** + * 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; +}; + +/** + * 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?: ScaffolderUsageExample[]; +}; + +/** + * The response shape for the `listActions` call to the `scaffolder-backend` + * + * @public + */ +export type ListActionsResponse = Array; + +/** + * 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; + globals: { + functions: Record; + values: Record; + }; +}; + +/** @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: TaskEventType; + 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; + secrets?: Record; +} + +/** + * 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; + directoryContents: { path: string; base64Content: string }[]; +} + +/** @public */ +export interface ScaffolderDryRunResponse { + directoryContents: Array<{ + path: string; + base64Content: string; + executable?: boolean; + }>; + log: Array>; + steps: TaskStep[]; + output: ScaffolderTaskOutput; +} +/** + * An API to interact with the scaffolder backend. + * + * @public + */ +export interface ScaffolderApi { + getTemplateParameterSchema( + templateRef: string, + options?: ScaffolderRequestOptions, + ): Promise; + + /** + * 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; + + getTask( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise; + + /** + * 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?: ScaffolderTaskStatus }>; + + /** + * Starts the task again from the point where it failed. + * + * @param taskId - the id of the task + */ + retry?( + 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; + + /** + * Returns a list of all installed actions. + */ + listActions(options?: ScaffolderRequestOptions): Promise; + + /** + * Returns a structure describing the available templating extensions. + */ + listTemplatingExtensions?( + options?: ScaffolderRequestOptions, + ): Promise; + + streamLogs( + request: ScaffolderStreamLogsOptions, + options?: ScaffolderRequestOptions, + ): Observable; + + dryRun?( + request: ScaffolderDryRunOptions, + options?: ScaffolderRequestOptions, + ): Promise; + + autocomplete?( + request: { + token: string; + provider: string; + resource: string; + context: Record; + }, + options?: ScaffolderRequestOptions, + ): Promise<{ results: { title?: string; id: string }[] }>; +} diff --git a/plugins/scaffolder-common/src/index.ts b/plugins/scaffolder-common/src/index.ts index 4d9b5e39c6..ad37973a7b 100644 --- a/plugins/scaffolder-common/src/index.ts +++ b/plugins/scaffolder-common/src/index.ts @@ -30,7 +30,12 @@ export type { TemplatePresentationV1beta3, TemplateEntityV1beta3, TemplateEntityStepV1beta3, + TemplateParameterSchema, TemplateParametersV1beta3, TemplatePermissionsV1beta3, TemplateRecoveryV1beta3, } from './TemplateEntityV1beta3'; + +export * from './ScaffolderClient'; + +export * from './api'; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/apis/Api.client.ts b/plugins/scaffolder-common/src/schema/openapi/generated/apis/Api.client.ts new file mode 100644 index 0000000000..ca5ae10b8f --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/apis/Api.client.ts @@ -0,0 +1,454 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DiscoveryApi } from '../types/discovery'; +import { FetchApi } from '../types/fetch'; +import crossFetch from 'cross-fetch'; +import { pluginId } from '../pluginId'; +import * as parser from 'uri-template'; +import { Action } from '../models/Action.model'; +import { Autocomplete200Response } from '../models/Autocomplete200Response.model'; +import { AutocompleteRequest } from '../models/AutocompleteRequest.model'; +import { CancelTask200Response } from '../models/CancelTask200Response.model'; +import { DryRun200Response } from '../models/DryRun200Response.model'; +import { DryRunRequest } from '../models/DryRunRequest.model'; +import { ListTasksResponse } from '../models/ListTasksResponse.model'; +import { ListTemplatingExtensionsResponse } from '../models/ListTemplatingExtensionsResponse.model'; +import { RetryRequest } from '../models/RetryRequest.model'; +import { Scaffold201Response } from '../models/Scaffold201Response.model'; +import { ScaffolderScaffoldOptions } from '../models/ScaffolderScaffoldOptions.model'; +import { SerializedTask } from '../models/SerializedTask.model'; +import { SerializedTaskEvent } from '../models/SerializedTaskEvent.model'; +import { TemplateParameterSchema } from '../models/TemplateParameterSchema.model'; + +/** + * Wraps the Response type to convey a type on the json call. + * + * @public + */ +export type TypedResponse = Omit & { + json: () => Promise; +}; + +/** + * Options you can pass into a request for additional information. + * + * @public + */ +export interface RequestOptions { + token?: string; +} +/** + * @public + */ +export type Autocomplete = { + path: { + provider: string; + resource: string; + }; + body: AutocompleteRequest; +}; +/** + * @public + */ +export type CancelTask = { + path: { + taskId: string; + }; +}; +/** + * @public + */ +export type DryRun = { + body: DryRunRequest; +}; +/** + * @public + */ +export type GetTask = { + path: { + taskId: string; + }; +}; +/** + * @public + */ +export type GetTemplateParameterSchema = { + path: { + namespace: string; + kind: string; + name: string; + }; +}; +/** + * @public + */ +export type ListActions = {}; +/** + * @public + */ +export type ListTasks = { + query: { + createdBy?: Array; + limit?: number; + offset?: number; + order?: Array; + status?: Array; + }; +}; +/** + * @public + */ +export type ListTemplatingExtensions = {}; +/** + * @public + */ +export type Retry = { + path: { + taskId: string; + }; + body: RetryRequest; +}; +/** + * @public + */ +export type Scaffold = { + body: ScaffolderScaffoldOptions; +}; +/** + * @public + */ +export type StreamLogsPolling = { + path: { + taskId: string; + }; + query: { + after?: number; + }; +}; + +/** + * @public + */ +export class DefaultApiClient { + private readonly discoveryApi: DiscoveryApi; + private readonly fetchApi: FetchApi; + + constructor(options: { + discoveryApi: { getBaseUrl(pluginId: string): Promise }; + fetchApi?: { fetch: typeof fetch }; + }) { + this.discoveryApi = options.discoveryApi; + this.fetchApi = options.fetchApi || { fetch: crossFetch }; + } + + /** + * Perform an autocomplete for the given provider and resource. + * @param provider - + * @param resource - + * @param autocompleteRequest - + */ + public async autocomplete( + // @ts-ignore + request: Autocomplete, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/autocomplete/{provider}/{resource}`; + + const uri = parser.parse(uriTemplate).expand({ + provider: request.path.provider, + resource: request.path.resource, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'POST', + body: JSON.stringify(request.body), + }); + } + + /** + * Sends a signal to a task broker to cancel the running task by taskId. + * @param taskId - + */ + public async cancelTask( + // @ts-ignore + request: CancelTask, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/tasks/{taskId}/cancel`; + + const uri = parser.parse(uriTemplate).expand({ + taskId: request.path.taskId, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'POST', + }); + } + + /** + * Perform a dry-run of a template + * @param dryRunRequest - + */ + public async dryRun( + // @ts-ignore + request: DryRun, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/dry-run`; + + const uri = parser.parse(uriTemplate).expand({}); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'POST', + body: JSON.stringify(request.body), + }); + } + + /** + * Get a task by ID. + * @param taskId - + */ + public async getTask( + // @ts-ignore + request: GetTask, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/tasks/{taskId}`; + + const uri = parser.parse(uriTemplate).expand({ + taskId: request.path.taskId, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } + + /** + * Get template parameter schema. + * @param namespace - + * @param kind - + * @param name - + */ + public async getTemplateParameterSchema( + // @ts-ignore + request: GetTemplateParameterSchema, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/templates/{namespace}/{kind}/{name}/parameter-schema`; + + const uri = parser.parse(uriTemplate).expand({ + namespace: request.path.namespace, + kind: request.path.kind, + name: request.path.name, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } + + /** + * Returns a list of all installed actions. + */ + public async listActions( + // @ts-ignore + request: ListActions, + options?: RequestOptions, + ): Promise>> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/actions`; + + const uri = parser.parse(uriTemplate).expand({}); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } + + /** + * Returns a list of tasks, filtering by ownership and/or status if given. + * @param createdBy - Created by + * @param limit - Number of records to return in the response. + * @param offset - Number of records to skip in the query page. + * @param order - Order + * @param status - Status + */ + public async listTasks( + // @ts-ignore + request: ListTasks, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/tasks{?createdBy*,limit,offset,order*,status*}`; + + const uri = parser.parse(uriTemplate).expand({ + ...request.query, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } + + /** + * Returns a structure describing the available templating extensions. + */ + public async listTemplatingExtensions( + // @ts-ignore + request: ListTemplatingExtensions, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/templating-extensions`; + + const uri = parser.parse(uriTemplate).expand({}); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } + + /** + * Starts the task again from the point where it failed. + * @param taskId - + * @param retryRequest - + */ + public async retry( + // @ts-ignore + request: Retry, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/tasks/{taskId}/retry`; + + const uri = parser.parse(uriTemplate).expand({ + taskId: request.path.taskId, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'POST', + body: JSON.stringify(request.body), + }); + } + + /** + * Executes the scaffolding of a component, given a template and its parameter values. + * @param scaffolderScaffoldOptions - + */ + public async scaffold( + // @ts-ignore + request: Scaffold, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/tasks`; + + const uri = parser.parse(uriTemplate).expand({}); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'POST', + body: JSON.stringify(request.body), + }); + } + + /** + * Get events for a task by ID. + * @param taskId - + * @param after - Offset event ID to stream events after. + */ + public async streamLogsPolling( + // @ts-ignore + request: StreamLogsPolling, + options?: RequestOptions, + ): Promise>> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/tasks/{taskId}/events{?after}`; + + const uri = parser.parse(uriTemplate).expand({ + taskId: request.path.taskId, + ...request.query, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/apis/index.ts b/plugins/scaffolder-common/src/schema/openapi/generated/apis/index.ts new file mode 100644 index 0000000000..fc7c83b736 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/apis/index.ts @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export * from './Api.client'; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/index.ts b/plugins/scaffolder-common/src/schema/openapi/generated/index.ts new file mode 100644 index 0000000000..dc3055033d --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/index.ts @@ -0,0 +1,18 @@ +/* + * 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. + */ + +export * from './apis'; +export * from './models'; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/Action.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/Action.model.ts new file mode 100644 index 0000000000..f9c028f3e3 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/Action.model.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ActionExample } from '../models/ActionExample.model'; +import { ActionSchema } from '../models/ActionSchema.model'; + +/** + * The response shape for a single action in the `listActions` call to the `scaffolder-backend` + * @public + */ +export interface Action { + id: string; + description?: string; + examples?: Array; + schema?: ActionSchema; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ActionExample.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ActionExample.model.ts new file mode 100644 index 0000000000..50550e2883 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ActionExample.model.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * A single action example + * @public + */ +export interface ActionExample { + description: string; + example: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ActionSchema.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ActionSchema.model.ts new file mode 100644 index 0000000000..35d2014181 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ActionSchema.model.ts @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ActionSchema { + /** + * A type representing all allowed JSON object values. + */ + input?: { [key: string]: any }; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete200Response.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete200Response.model.ts new file mode 100644 index 0000000000..e3eec0aa20 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete200Response.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { Autocomplete200ResponseResultsInner } from '../models/Autocomplete200ResponseResultsInner.model'; + +/** + * @public + */ +export interface Autocomplete200Response { + results: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts new file mode 100644 index 0000000000..00ccb41b0f --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface Autocomplete200ResponseResultsInner { + title?: string; + id: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete400Response.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete400Response.model.ts new file mode 100644 index 0000000000..1456babb96 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/Autocomplete400Response.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface Autocomplete400Response { + message?: string; + name?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/AutocompleteRequest.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/AutocompleteRequest.model.ts new file mode 100644 index 0000000000..769a929918 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/AutocompleteRequest.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface AutocompleteRequest { + context: { [key: string]: string }; + token: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/CancelTask200Response.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/CancelTask200Response.model.ts new file mode 100644 index 0000000000..f29c509d41 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/CancelTask200Response.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; + +/** + * @public + */ +export interface CancelTask200Response { + status?: TaskStatus; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200Response.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200Response.model.ts new file mode 100644 index 0000000000..62e3689d5d --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200Response.model.ts @@ -0,0 +1,35 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRun200ResponseAllOfDirectoryContentsInner } from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model'; +import { DryRun200ResponseAllOfStepsInner } from '../models/DryRun200ResponseAllOfStepsInner.model'; +import { DryRunResultLogInner } from '../models/DryRunResultLogInner.model'; + +/** + * @public + */ +export interface DryRun200Response { + log: Array; + directoryContents: Array; + /** + * A type representing all allowed JSON object values. + */ + output: { [key: string]: any }; + steps: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts new file mode 100644 index 0000000000..5b6c2ff9c7 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRun200ResponseAllOfDirectoryContentsInner } from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model'; +import { DryRun200ResponseAllOfStepsInner } from '../models/DryRun200ResponseAllOfStepsInner.model'; + +/** + * @public + */ +export interface DryRun200ResponseAllOf { + steps: Array; + directoryContents?: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOfDirectoryContentsInner.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOfDirectoryContentsInner.model.ts new file mode 100644 index 0000000000..2646ca49f9 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOfDirectoryContentsInner.model.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface DryRun200ResponseAllOfDirectoryContentsInner { + path: string; + executable?: boolean; + base64Content: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts new file mode 100644 index 0000000000..2a462edefa --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface DryRun200ResponseAllOfStepsInner { + [key: string]: any; + + id: string; + name: string; + action: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunRequest.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunRequest.model.ts new file mode 100644 index 0000000000..212b36c26b --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunRequest.model.ts @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRunRequestDirectoryContentsInner } from '../models/DryRunRequestDirectoryContentsInner.model'; + +/** + * @public + */ +export interface DryRunRequest { + template: any; + /** + * A type representing all allowed JSON object values. + */ + values: { [key: string]: any }; + secrets?: { [key: string]: string }; + directoryContents: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunRequestDirectoryContentsInner.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunRequestDirectoryContentsInner.model.ts new file mode 100644 index 0000000000..ddcae4fd9d --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunRequestDirectoryContentsInner.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface DryRunRequestDirectoryContentsInner { + path?: string; + base64Content?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResult.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResult.model.ts new file mode 100644 index 0000000000..6e2ad23ef4 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResult.model.ts @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRunResultLogInner } from '../models/DryRunResultLogInner.model'; +import { SerializedFile } from '../models/SerializedFile.model'; + +/** + * @public + */ +export interface DryRunResult { + log: Array; + directoryContents: Array; + /** + * A type representing all allowed JSON object values. + */ + output: { [key: string]: any }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts new file mode 100644 index 0000000000..4c6b786d82 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model'; + +/** + * @public + */ +export interface DryRunResultLogInner { + body: DryRunResultLogInnerBody; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts new file mode 100644 index 0000000000..e3b19be045 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; + +/** + * @public + */ +export interface DryRunResultLogInnerBody { + message: string; + status?: TaskStatus; + stepId?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts new file mode 100644 index 0000000000..e67240ee54 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; + +/** + * @public + */ +export interface DryRunResultLogInnerBodyAllOf { + message: string; + status?: TaskStatus; + stepId?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorError.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorError.model.ts new file mode 100644 index 0000000000..e0265e95d7 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorError.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorError { + name: string; + message: string; + stack?: string; + code?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorRequest.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorRequest.model.ts new file mode 100644 index 0000000000..3eb5e15740 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorRequest.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorRequest { + method: string; + url: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorResponse.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorResponse.model.ts new file mode 100644 index 0000000000..edbcc32df7 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ErrorResponse.model.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorResponse { + statusCode: number; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/JsonPrimitive.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/JsonPrimitive.model.ts new file mode 100644 index 0000000000..6aa6394c14 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/JsonPrimitive.model.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * A type representing all allowed JSON primitive values. + * @public + */ +export type JsonPrimitive = any | boolean | number | string; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/JsonValue.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/JsonValue.model.ts new file mode 100644 index 0000000000..9fe2ac9de3 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/JsonValue.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { JsonPrimitive } from '../models/JsonPrimitive.model'; + +/** + * A type representing all allowed JSON values. + * @public + */ +export type JsonValue = + | Array + | JsonPrimitive + | { [key: string]: any }; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTasksResponse.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTasksResponse.model.ts new file mode 100644 index 0000000000..9347c766a9 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTasksResponse.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { SerializedTask } from '../models/SerializedTask.model'; + +/** + * The response shape for the `listTasks` call to the `scaffolder-backend` + * @public + */ +export interface ListTasksResponse { + tasks: Array; + totalTasks?: number; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts new file mode 100644 index 0000000000..74b7cd3780 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ListTemplatingExtensionsResponseGlobals } from '../models/ListTemplatingExtensionsResponseGlobals.model'; +import { TemplateFilter } from '../models/TemplateFilter.model'; + +/** + * The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface ListTemplatingExtensionsResponse { + filters: { [key: string]: TemplateFilter }; + globals: ListTemplatingExtensionsResponseGlobals; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts new file mode 100644 index 0000000000..1f022a0675 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TemplateGlobalFunction } from '../models/TemplateGlobalFunction.model'; +import { TemplateGlobalValue } from '../models/TemplateGlobalValue.model'; + +/** + * @public + */ +export interface ListTemplatingExtensionsResponseGlobals { + functions: { [key: string]: TemplateGlobalFunction }; + values: { [key: string]: TemplateGlobalValue }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ModelError.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ModelError.model.ts new file mode 100644 index 0000000000..958fde7d0b --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ModelError.model.ts @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ErrorError } from '../models/ErrorError.model'; +import { ErrorRequest } from '../models/ErrorRequest.model'; +import { ErrorResponse } from '../models/ErrorResponse.model'; + +/** + * @public + */ +export interface ModelError { + [key: string]: any; + + error: ErrorError; + request?: ErrorRequest; + response: ErrorResponse; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/RetryRequest.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/RetryRequest.model.ts new file mode 100644 index 0000000000..858fa67566 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/RetryRequest.model.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface RetryRequest { + secrets?: { [key: string]: string }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/Scaffold201Response.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/Scaffold201Response.model.ts new file mode 100644 index 0000000000..1271642e81 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/Scaffold201Response.model.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface Scaffold201Response { + id: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/Scaffold400Response.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/Scaffold400Response.model.ts new file mode 100644 index 0000000000..e3cb7eaa45 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/Scaffold400Response.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ValidationError } from '../models/ValidationError.model'; + +/** + * @public + */ +export interface Scaffold400Response { + errors: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts new file mode 100644 index 0000000000..93f4ae71c0 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * The input options to the `scaffold` method of the `ScaffolderClient`. + * @public + */ +export interface ScaffolderScaffoldOptions { + templateRef: string; + values: { [key: string]: any }; + secrets?: { [key: string]: string }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts new file mode 100644 index 0000000000..3e0f4ef866 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * A single scaffolder usage example + * @public + */ +export interface ScaffolderUsageExample { + description?: string; + example: string; + notes?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedFile.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedFile.model.ts new file mode 100644 index 0000000000..65a3c714a7 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedFile.model.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface SerializedFile { + path: string; + content: string; + executable?: boolean; + symlink?: boolean; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedTask.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedTask.model.ts new file mode 100644 index 0000000000..67cbf14279 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedTask.model.ts @@ -0,0 +1,39 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TaskSecrets } from '../models/TaskSecrets.model'; +import { TaskStatus } from '../models/TaskStatus.model'; + +/** + * SerializedTask + * @public + */ +export interface SerializedTask { + id: string; + spec: any; + status: TaskStatus; + createdAt: string; + lastHeartbeatAt?: string; + createdBy?: string; + secrets?: TaskSecrets; + /** + * A type representing all allowed JSON object values. + */ + state?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts new file mode 100644 index 0000000000..6e4ddaa296 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts @@ -0,0 +1,34 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model'; +import { TaskEventType } from '../models/TaskEventType.model'; + +/** + * SerializedTaskEvent + * @public + */ +export interface SerializedTaskEvent { + id: number; + isTaskRecoverable?: boolean; + taskId: string; + body: DryRunResultLogInnerBody; + type: TaskEventType; + createdAt: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskEventType.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskEventType.model.ts new file mode 100644 index 0000000000..d32d77a448 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskEventType.model.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export type TaskEventType = 'cancelled' | 'completion' | 'log' | 'recovered'; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskSecrets.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskSecrets.model.ts new file mode 100644 index 0000000000..c78c39c1ec --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskSecrets.model.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * TaskSecrets + * @public + */ +export interface TaskSecrets { + backstageToken?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts new file mode 100644 index 0000000000..0b33852cc9 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TaskSecretsAllOf { + backstageToken?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskStatus.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskStatus.model.ts new file mode 100644 index 0000000000..1f209a3656 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TaskStatus.model.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export type TaskStatus = + | 'cancelled' + | 'completed' + | 'failed' + | 'open' + | 'processing' + | 'skipped'; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilter.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilter.model.ts new file mode 100644 index 0000000000..7c631978e6 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilter.model.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ScaffolderUsageExample } from '../models/ScaffolderUsageExample.model'; +import { TemplateFilterSchema } from '../models/TemplateFilterSchema.model'; + +/** + * The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateFilter { + description?: string; + schema?: TemplateFilterSchema; + examples?: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts new file mode 100644 index 0000000000..5a95a58ead --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts @@ -0,0 +1,34 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateFilterSchema { + /** + * A type representing all allowed JSON object values. + */ + input?: { [key: string]: any }; + arguments?: Array<{ [key: string]: any }>; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts new file mode 100644 index 0000000000..ee19ce723b --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts @@ -0,0 +1,31 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ScaffolderUsageExample } from '../models/ScaffolderUsageExample.model'; +import { TemplateGlobalFunctionSchema } from '../models/TemplateGlobalFunctionSchema.model'; + +/** + * The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateGlobalFunction { + description?: string; + schema?: TemplateGlobalFunctionSchema; + examples?: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts new file mode 100644 index 0000000000..b3a39c3b24 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateGlobalFunctionSchema { + arguments?: Array<{ [key: string]: any }>; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts new file mode 100644 index 0000000000..95d177a05a --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateGlobalValue { + description?: string; + value: any | null; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts new file mode 100644 index 0000000000..8638ee8114 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TemplateParameterSchemaStepsInner } from '../models/TemplateParameterSchemaStepsInner.model'; + +/** + * The shape of each entry of parameters which gets rendered as a separate step in the wizard input + * @public + */ +export interface TemplateParameterSchema { + [key: string]: any; + + title: string; + description?: string; + steps: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts new file mode 100644 index 0000000000..2f7892fd41 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts @@ -0,0 +1,28 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateParameterSchemaStepsInner { + title: string; + description?: string; + schema: any; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationError.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationError.model.ts new file mode 100644 index 0000000000..7e762f616c --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationError.model.ts @@ -0,0 +1,36 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ValidationErrorArgument } from '../models/ValidationErrorArgument.model'; +import { ValidationErrorPathInner } from '../models/ValidationErrorPathInner.model'; + +/** + * @public + */ +export interface ValidationError { + [key: string]: any; + + path: Array; + property: string; + message: string; + instance: any; + name: string; + argument: ValidationErrorArgument; + stack: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationErrorArgument.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationErrorArgument.model.ts new file mode 100644 index 0000000000..85c9576fd0 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationErrorArgument.model.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export type ValidationErrorArgument = any | boolean | number | string; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationErrorPathInner.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationErrorPathInner.model.ts new file mode 100644 index 0000000000..4535c735db --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ValidationErrorPathInner.model.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export type ValidationErrorPathInner = number | string; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/index.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/index.ts new file mode 100644 index 0000000000..1bc447fa3d --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/index.ts @@ -0,0 +1,65 @@ +/* + * 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. + */ + +export * from '../models/Action.model'; +export * from '../models/ActionExample.model'; +export * from '../models/ActionSchema.model'; +export * from '../models/Autocomplete200Response.model'; +export * from '../models/Autocomplete200ResponseResultsInner.model'; +export * from '../models/Autocomplete400Response.model'; +export * from '../models/AutocompleteRequest.model'; +export * from '../models/CancelTask200Response.model'; +export * from '../models/DryRun200Response.model'; +export * from '../models/DryRun200ResponseAllOf.model'; +export * from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model'; +export * from '../models/DryRun200ResponseAllOfStepsInner.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/ErrorError.model'; +export * from '../models/ErrorRequest.model'; +export * from '../models/ErrorResponse.model'; +export * from '../models/JsonPrimitive.model'; +export * from '../models/JsonValue.model'; +export * from '../models/ListTasksResponse.model'; +export * from '../models/ListTemplatingExtensionsResponse.model'; +export * from '../models/ListTemplatingExtensionsResponseGlobals.model'; +export * from '../models/ModelError.model'; +export * from '../models/RetryRequest.model'; +export * from '../models/Scaffold201Response.model'; +export * from '../models/Scaffold400Response.model'; +export * from '../models/ScaffolderScaffoldOptions.model'; +export * from '../models/ScaffolderUsageExample.model'; +export * from '../models/SerializedFile.model'; +export * from '../models/SerializedTask.model'; +export * from '../models/SerializedTaskEvent.model'; +export * from '../models/TaskEventType.model'; +export * from '../models/TaskSecrets.model'; +export * from '../models/TaskSecretsAllOf.model'; +export * from '../models/TaskStatus.model'; +export * from '../models/TemplateFilter.model'; +export * from '../models/TemplateFilterSchema.model'; +export * from '../models/TemplateGlobalFunction.model'; +export * from '../models/TemplateGlobalFunctionSchema.model'; +export * from '../models/TemplateGlobalValue.model'; +export * from '../models/TemplateParameterSchema.model'; +export * from '../models/TemplateParameterSchemaStepsInner.model'; +export * from '../models/ValidationError.model'; +export * from '../models/ValidationErrorArgument.model'; +export * from '../models/ValidationErrorPathInner.model'; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/pluginId.ts b/plugins/scaffolder-common/src/schema/openapi/generated/pluginId.ts new file mode 100644 index 0000000000..b898028be5 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/pluginId.ts @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export const pluginId = 'scaffolder'; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/types/discovery.ts b/plugins/scaffolder-common/src/schema/openapi/generated/types/discovery.ts new file mode 100644 index 0000000000..a7f87d3780 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/types/discovery.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2023 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 DiscoveryApi, to avoid importing core-plugin-api. + */ +export type DiscoveryApi = { + getBaseUrl(pluginId: string): Promise; +}; diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/types/fetch.ts b/plugins/scaffolder-common/src/schema/openapi/generated/types/fetch.ts new file mode 100644 index 0000000000..3de56c028e --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/types/fetch.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2023 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 FetchApi, to avoid importing core-plugin-api. + */ +export type FetchApi = { + fetch: typeof fetch; +}; diff --git a/plugins/scaffolder-common/src/schema/openapi/index.ts b/plugins/scaffolder-common/src/schema/openapi/index.ts new file mode 100644 index 0000000000..196aad553a --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/index.ts @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export * from './generated'; diff --git a/plugins/scaffolder-node/report.api.md b/plugins/scaffolder-node/report.api.md index 3d758baebf..c97344867a 100644 --- a/plugins/scaffolder-node/report.api.md +++ b/plugins/scaffolder-node/report.api.md @@ -344,7 +344,11 @@ export type SerializedTaskEvent = { id: number; isTaskRecoverable?: boolean; taskId: string; - body: JsonObject; + body: { + message: string; + stepId?: string; + status?: TaskStatus; + } & JsonObject; type: TaskEventType; createdAt: string; }; @@ -489,7 +493,8 @@ export type TaskStatus = | 'completed' | 'failed' | 'open' - | 'processing'; + | 'processing' + | 'skipped'; // @public (undocumented) export type TemplateAction< diff --git a/plugins/scaffolder-node/src/tasks/types.ts b/plugins/scaffolder-node/src/tasks/types.ts index b55a2729b7..aaac468fce 100644 --- a/plugins/scaffolder-node/src/tasks/types.ts +++ b/plugins/scaffolder-node/src/tasks/types.ts @@ -39,7 +39,8 @@ export type TaskStatus = | 'completed' | 'failed' | 'open' - | 'processing'; + | 'processing' + | 'skipped'; /** * The state of a completed task. @@ -80,7 +81,11 @@ export type SerializedTaskEvent = { id: number; isTaskRecoverable?: boolean; taskId: string; - body: JsonObject; + body: { + message: string; + stepId?: string; + status?: TaskStatus; + } & JsonObject; type: TaskEventType; createdAt: string; }; diff --git a/plugins/scaffolder-react/report.api.md b/plugins/scaffolder-react/report.api.md index d66ec36acb..4b81a18eb6 100644 --- a/plugins/scaffolder-react/report.api.md +++ b/plugins/scaffolder-react/report.api.md @@ -3,6 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { Action as Action_2 } from '@backstage/plugin-scaffolder-common'; import { ApiHolder } from '@backstage/core-plugin-api'; import { ApiRef } from '@backstage/frontend-plugin-api'; import { ComponentType } from 'react'; @@ -23,9 +24,10 @@ import { IChangeEvent } from '@rjsf/core'; import { IdSchema } from '@rjsf/utils'; import { JsonObject } from '@backstage/types'; import { JSONSchema7 } from 'json-schema'; -import { JsonValue } from '@backstage/types'; import { JSX as JSX_2 } from 'react/jsx-runtime'; -import { Observable } from '@backstage/types'; +import { ListActionsResponse as ListActionsResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { ListTemplatingExtensionsResponse as ListTemplatingExtensionsResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { LogEvent as LogEvent_2 } from '@backstage/plugin-scaffolder-common'; import { PropsWithChildren } from 'react'; import { ReactNode } from 'react'; import { Ref } from 'react'; @@ -33,27 +35,34 @@ import { Registry } from '@rjsf/utils'; import { RegistryWidgetsType } from '@rjsf/utils'; import { RJSFSchema } from '@rjsf/utils'; import { RJSFValidationError } from '@rjsf/utils'; +import { ScaffolderApi as ScaffolderApi_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderDryRunOptions as ScaffolderDryRunOptions_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderDryRunResponse as ScaffolderDryRunResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderGetIntegrationsListOptions as ScaffolderGetIntegrationsListOptions_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderGetIntegrationsListResponse as ScaffolderGetIntegrationsListResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderOutputLink as ScaffolderOutputLink_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderOutputText as ScaffolderOutputText_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderScaffoldOptions as ScaffolderScaffoldOptions_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderScaffoldResponse as ScaffolderScaffoldResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderStreamLogsOptions as ScaffolderStreamLogsOptions_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderTask as ScaffolderTask_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderTaskOutput as ScaffolderTaskOutput_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderTaskStatus as ScaffolderTaskStatus_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderUsageExample as ScaffolderUsageExample_2 } from '@backstage/plugin-scaffolder-common'; import { StrictRJSFSchema } from '@rjsf/utils'; -import { TaskSpec } from '@backstage/plugin-scaffolder-common'; -import { TaskStep } from '@backstage/plugin-scaffolder-common'; import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; -import { TemplatePresentationV1beta3 } from '@backstage/plugin-scaffolder-common'; +import { TemplateFilter as TemplateFilter_2 } from '@backstage/plugin-scaffolder-common'; +import { TemplateGlobalFunction as TemplateGlobalFunction_2 } from '@backstage/plugin-scaffolder-common'; +import { TemplateGlobalValue as TemplateGlobalValue_2 } from '@backstage/plugin-scaffolder-common'; +import { TemplateParameterSchema as TemplateParameterSchema_2 } from '@backstage/plugin-scaffolder-common'; import { TemplatesType } from '@rjsf/utils'; import { UIOptionsType } from '@rjsf/utils'; import { UiSchema } from '@rjsf/utils'; import { ValidatorType } from '@rjsf/utils'; import { z } from 'zod'; -// @public -export type Action = { - id: string; - description?: string; - schema?: { - input?: JSONSchema7; - output?: JSONSchema7; - }; - examples?: ActionExample[]; -}; +// @public @deprecated +export type Action = Action_2; // @public @deprecated export type ActionExample = ScaffolderUsageExample; @@ -162,30 +171,15 @@ export type LayoutTemplate = NonNullable< FormProps_2['uiSchema'] >['ui:ObjectFieldTemplate']; -// @public -export type ListActionsResponse = Array; +// @public @deprecated +export type ListActionsResponse = ListActionsResponse_2; -// @public -export type ListTemplatingExtensionsResponse = { - filters: Record; - globals: { - functions: Record; - values: Record; - }; -}; +// @public @deprecated +export type ListTemplatingExtensionsResponse = + ListTemplatingExtensionsResponse_2; -// @public -export type LogEvent = { - type: 'log' | 'completion' | 'cancelled' | 'recovered'; - body: { - message: string; - stepId?: string; - status?: ScaffolderTaskStatus; - }; - createdAt: string; - id: string; - taskId: string; -}; +// @public @deprecated +export type LogEvent = LogEvent_2; // @public (undocumented) export function makeFieldSchema< @@ -210,125 +204,39 @@ export type ReviewStepProps = { }[]; }; -// @public -export interface ScaffolderApi { - // (undocumented) - autocomplete?(options: { - token: string; - provider: string; - resource: string; - context?: Record; - }): Promise<{ - results: { - title?: string; - id: string; - }[]; - }>; - cancelTask(taskId: string): Promise; - // (undocumented) - dryRun?(options: ScaffolderDryRunOptions): Promise; - // (undocumented) - getIntegrationsList( - options: ScaffolderGetIntegrationsListOptions, - ): Promise; - // (undocumented) - getTask(taskId: string): Promise; - // (undocumented) - getTemplateParameterSchema( - templateRef: string, - ): Promise; - listActions(): Promise; - // (undocumented) - listTasks?(options: { - filterByOwnership: 'owned' | 'all'; - limit?: number; - offset?: number; - }): Promise<{ - tasks: ScaffolderTask[]; - totalTasks?: number; - }>; - listTemplatingExtensions?(): Promise; - retry?(taskId: string): Promise; - scaffold( - options: ScaffolderScaffoldOptions, - ): Promise; - // (undocumented) - streamLogs(options: ScaffolderStreamLogsOptions): Observable; -} +// @public @deprecated +export type ScaffolderApi = ScaffolderApi_2; // @public (undocumented) -export const scaffolderApiRef: ApiRef; +export const scaffolderApiRef: ApiRef; -// @public (undocumented) -export interface ScaffolderDryRunOptions { - // (undocumented) - directoryContents: { - path: string; - base64Content: string; - }[]; - // (undocumented) - secrets?: Record; - // (undocumented) - template: JsonValue; - // (undocumented) - values: JsonObject; -} +// @public @deprecated (undocumented) +export type ScaffolderDryRunOptions = ScaffolderDryRunOptions_2; -// @public (undocumented) -export interface ScaffolderDryRunResponse { - // (undocumented) - directoryContents: Array<{ - path: string; - base64Content: string; - executable: boolean; - }>; - // (undocumented) - log: Array>; - // (undocumented) - output: ScaffolderTaskOutput; - // (undocumented) - steps: TaskStep[]; -} +// @public @deprecated (undocumented) +export type ScaffolderDryRunResponse = ScaffolderDryRunResponse_2; // @public export const ScaffolderFieldExtensions: React.ComponentType< React.PropsWithChildren<{}> >; -// @public -export interface ScaffolderGetIntegrationsListOptions { - // (undocumented) - allowedHosts: string[]; -} +// @public @deprecated +export type ScaffolderGetIntegrationsListOptions = + ScaffolderGetIntegrationsListOptions_2; -// @public -export interface ScaffolderGetIntegrationsListResponse { - // (undocumented) - integrations: { - type: string; - title: string; - host: string; - }[]; -} +// @public @deprecated +export type ScaffolderGetIntegrationsListResponse = + ScaffolderGetIntegrationsListResponse_2; // @public export const ScaffolderLayouts: ComponentType>; -// @public (undocumented) -export type ScaffolderOutputLink = { - title?: string; - icon?: string; - url?: string; - entityRef?: string; -}; +// @public @deprecated (undocumented) +export type ScaffolderOutputLink = ScaffolderOutputLink_2; -// @public (undocumented) -export type ScaffolderOutputText = { - title?: string; - icon?: string; - content?: string; - default?: boolean; -}; +// @public @deprecated (undocumented) +export type ScaffolderOutputText = ScaffolderOutputText_2; // @public export type ScaffolderRJSFField< @@ -437,21 +345,11 @@ export type ScaffolderRJSFRegistryFieldsType< [name: string]: ScaffolderRJSFField; }; -// @public -export interface ScaffolderScaffoldOptions { - // (undocumented) - secrets?: Record; - // (undocumented) - templateRef: string; - // (undocumented) - values: Record; -} +// @public @deprecated +export type ScaffolderScaffoldOptions = ScaffolderScaffoldOptions_2; -// @public -export interface ScaffolderScaffoldResponse { - // (undocumented) - taskId: string; -} +// @public @deprecated +export type ScaffolderScaffoldResponse = ScaffolderScaffoldResponse_2; // @public export type ScaffolderStep = { @@ -461,48 +359,20 @@ export type ScaffolderStep = { startedAt?: string; }; -// @public -export interface ScaffolderStreamLogsOptions { - // (undocumented) - after?: number; - // (undocumented) - isTaskRecoverable?: boolean; - // (undocumented) - taskId: string; -} +// @public @deprecated +export type ScaffolderStreamLogsOptions = ScaffolderStreamLogsOptions_2; -// @public -export type ScaffolderTask = { - id: string; - spec: TaskSpec; - status: 'failed' | 'completed' | 'processing' | 'open' | 'cancelled'; - lastHeartbeatAt: string; - createdAt: string; -}; +// @public @deprecated +export type ScaffolderTask = ScaffolderTask_2; -// @public (undocumented) -export type ScaffolderTaskOutput = { - links?: ScaffolderOutputLink[]; - text?: ScaffolderOutputText[]; -} & { - [key: string]: unknown; -}; +// @public @deprecated (undocumented) +export type ScaffolderTaskOutput = ScaffolderTaskOutput_2; -// @public -export type ScaffolderTaskStatus = - | 'cancelled' - | 'completed' - | 'failed' - | 'open' - | 'processing' - | 'skipped'; +// @public @deprecated +export type ScaffolderTaskStatus = ScaffolderTaskStatus_2; -// @public -export type ScaffolderUsageExample = { - description?: string; - example: string; - notes?: string; -}; +// @public @deprecated +export type ScaffolderUsageExample = ScaffolderUsageExample_2; // @public export interface ScaffolderUseTemplateSecrets { @@ -535,32 +405,14 @@ export type TaskStream = { output?: ScaffolderTaskOutput; }; -// @public -export type TemplateFilter = { - description?: string; - schema?: { - input?: JSONSchema7; - arguments?: JSONSchema7[]; - output?: JSONSchema7; - }; - examples?: ScaffolderUsageExample[]; -}; +// @public @deprecated +export type TemplateFilter = TemplateFilter_2; -// @public -export type TemplateGlobalFunction = { - description?: string; - schema?: { - arguments?: JSONSchema7[]; - output?: JSONSchema7; - }; - examples?: ScaffolderUsageExample[]; -}; +// @public @deprecated +export type TemplateGlobalFunction = TemplateGlobalFunction_2; -// @public -export type TemplateGlobalValue = { - description?: string; - value: JsonValue; -}; +// @public @deprecated +export type TemplateGlobalValue = TemplateGlobalValue_2; // @public (undocumented) export type TemplateGroupFilter = { @@ -568,21 +420,8 @@ export type TemplateGroupFilter = { filter: (entity: TemplateEntityV1beta3) => boolean; }; -// @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 @deprecated +export type TemplateParameterSchema = TemplateParameterSchema_2; // @public export const useCustomFieldExtensions: < diff --git a/plugins/scaffolder-react/src/api/types.ts b/plugins/scaffolder-react/src/api/types.ts index d4a9bbe0f8..b3cb177128 100644 --- a/plugins/scaffolder-react/src/api/types.ts +++ b/plugins/scaffolder-react/src/api/types.ts @@ -13,47 +13,54 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { TaskSpec, TaskStep } from '@backstage/plugin-scaffolder-common'; -import { JsonObject, JsonValue, Observable } from '@backstage/types'; -import { JSONSchema7 } from 'json-schema'; -import { TemplateParameterSchema } from '../types'; + +import { + type ScaffolderApi as _ScaffolderApi, + type ScaffolderDryRunOptions as _ScaffolderDryRunOptions, + type ScaffolderDryRunResponse as _ScaffolderDryRunResponse, + type ScaffolderGetIntegrationsListOptions as _ScaffolderGetIntegrationsListOptions, + type ScaffolderGetIntegrationsListResponse as _ScaffolderGetIntegrationsListResponse, + type ScaffolderScaffoldOptions as _ScaffolderScaffoldOptions, + type ScaffolderScaffoldResponse as _ScaffolderScaffoldResponse, + type ScaffolderStreamLogsOptions as _ScaffolderStreamLogsOptions, + type ScaffolderUsageExample as _ScaffolderUsageExample, + type Action as _Action, + type ListActionsResponse as _ListActionsResponse, + type ListTemplatingExtensionsResponse as _ListTemplatingExtensionsResponse, + type LogEvent as _LogEvent, + type ScaffolderOutputLink as _ScaffolderOutputLink, + type ScaffolderOutputText as _ScaffolderOutputText, + type ScaffolderTask as _ScaffolderTask, + type ScaffolderTaskOutput as _ScaffolderTaskOutput, + type ScaffolderTaskStatus as _ScaffolderTaskStatus, + type TemplateFilter as _TemplateFilter, + type TemplateGlobalFunction as _TemplateGlobalFunction, + type TemplateGlobalValue as _TemplateGlobalValue, +} from '@backstage/plugin-scaffolder-common'; /** * The status of each task in a Scaffolder Job * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderTaskStatus} instead as this has now been moved. */ -export type ScaffolderTaskStatus = - | 'cancelled' - | 'completed' - | 'failed' - | 'open' - | 'processing' - | 'skipped'; +export type ScaffolderTaskStatus = _ScaffolderTaskStatus; /** * The shape of each task returned from the `scaffolder-backend` * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderTask} instead as this has now been moved. */ -export type ScaffolderTask = { - id: string; - spec: TaskSpec; - status: 'failed' | 'completed' | 'processing' | 'open' | 'cancelled'; - lastHeartbeatAt: string; - createdAt: string; -}; +export type ScaffolderTask = _ScaffolderTask; /** * A single scaffolder usage example * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderUsageExample} instead as this has now been moved. */ -export type ScaffolderUsageExample = { - description?: string; - example: string; - notes?: string; -}; +export type ScaffolderUsageExample = _ScaffolderUsageExample; /** * A single action example @@ -67,249 +74,135 @@ export type ActionExample = ScaffolderUsageExample; * The response shape for a single action in the `listActions` call to the `scaffolder-backend` * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#Action} instead as this has now been moved. */ -export type Action = { - id: string; - description?: string; - schema?: { - input?: JSONSchema7; - output?: JSONSchema7; - }; - examples?: ActionExample[]; -}; +export type Action = _Action; /** * The response shape for the `listActions` call to the `scaffolder-backend` * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ListActionsResponse} instead as this has now been moved. */ -export type ListActionsResponse = Array; +export type ListActionsResponse = _ListActionsResponse; /** * The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend` * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#TemplateFilter} instead as this has now been moved. */ -export type TemplateFilter = { - description?: string; - schema?: { - input?: JSONSchema7; - arguments?: JSONSchema7[]; - output?: JSONSchema7; - }; - examples?: ScaffolderUsageExample[]; -}; +export type TemplateFilter = _TemplateFilter; /** * The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend` * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#TemplateGlobalFunction} instead as this has now been moved. */ -export type TemplateGlobalFunction = { - description?: string; - schema?: { - arguments?: JSONSchema7[]; - output?: JSONSchema7; - }; - examples?: ScaffolderUsageExample[]; -}; +export type TemplateGlobalFunction = _TemplateGlobalFunction; /** * The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend` * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#TemplateGlobalValue} instead as this has now been moved. */ -export type TemplateGlobalValue = { - description?: string; - value: JsonValue; -}; +export type TemplateGlobalValue = _TemplateGlobalValue; /** * The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend` * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ListTemplatingExtensionsResponse} instead as this has now been moved. */ -export type ListTemplatingExtensionsResponse = { - filters: Record; - globals: { - functions: Record; - values: Record; - }; -}; +export type ListTemplatingExtensionsResponse = + _ListTemplatingExtensionsResponse; -/** @public */ -export type ScaffolderOutputLink = { - title?: string; - icon?: string; - url?: string; - entityRef?: string; -}; +/** + * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderOutputLink} instead as this has now been moved. + */ +export type ScaffolderOutputLink = _ScaffolderOutputLink; -/** @public */ -export type ScaffolderOutputText = { - title?: string; - icon?: string; - content?: string; - default?: boolean; -}; +/** + * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderOutputText} instead as this has now been moved. + */ +export type ScaffolderOutputText = _ScaffolderOutputText; -/** @public */ -export type ScaffolderTaskOutput = { - links?: ScaffolderOutputLink[]; - text?: ScaffolderOutputText[]; -} & { - [key: string]: unknown; -}; +/** + * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderTaskOutput} instead as this has now been moved. + */ +export type ScaffolderTaskOutput = _ScaffolderTaskOutput; /** * The shape of a `LogEvent` message from the `scaffolder-backend` * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#LogEvent} instead as this has now been moved. */ -export type LogEvent = { - type: 'log' | 'completion' | 'cancelled' | 'recovered'; - body: { - message: string; - stepId?: string; - status?: ScaffolderTaskStatus; - }; - createdAt: string; - id: string; - taskId: string; -}; +export type LogEvent = _LogEvent; /** * The input options to the `scaffold` method of the `ScaffolderClient`. * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderScaffoldOptions} instead as this has now been moved. */ -export interface ScaffolderScaffoldOptions { - templateRef: string; - values: Record; - secrets?: Record; -} +export type ScaffolderScaffoldOptions = _ScaffolderScaffoldOptions; /** * The response shape of the `scaffold` method of the `ScaffolderClient`. * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderScaffoldResponse} instead as this has now been moved. */ -export interface ScaffolderScaffoldResponse { - taskId: string; -} +export type ScaffolderScaffoldResponse = _ScaffolderScaffoldResponse; /** * The arguments for `getIntegrationsList`. * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderGetIntegrationsListOptions} instead as this has now been moved. */ -export interface ScaffolderGetIntegrationsListOptions { - allowedHosts: string[]; -} +export type ScaffolderGetIntegrationsListOptions = + _ScaffolderGetIntegrationsListOptions; /** * The response shape for `getIntegrationsList`. * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderGetIntegrationsListResponse} instead as this has now been moved. */ -export interface ScaffolderGetIntegrationsListResponse { - integrations: { type: string; title: string; host: string }[]; -} +export type ScaffolderGetIntegrationsListResponse = + _ScaffolderGetIntegrationsListResponse; /** * The input options to the `streamLogs` method of the `ScaffolderClient`. * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderStreamLogsOptions} instead as this has now been moved. */ -export interface ScaffolderStreamLogsOptions { - isTaskRecoverable?: boolean; - taskId: string; - after?: number; -} +export type ScaffolderStreamLogsOptions = _ScaffolderStreamLogsOptions; -/** @public */ -export interface ScaffolderDryRunOptions { - template: JsonValue; - values: JsonObject; - secrets?: Record; - directoryContents: { path: string; base64Content: string }[]; -} +/** + * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderDryRunOptions} instead as this has now been moved. + */ +export type ScaffolderDryRunOptions = _ScaffolderDryRunOptions; + +/** + * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderDryRunResponse} instead as this has now been moved. + */ +export type ScaffolderDryRunResponse = _ScaffolderDryRunResponse; -/** @public */ -export interface ScaffolderDryRunResponse { - directoryContents: Array<{ - path: string; - base64Content: string; - executable: boolean; - }>; - log: Array>; - steps: TaskStep[]; - output: ScaffolderTaskOutput; -} /** * An API to interact with the scaffolder backend. * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderApi} instead as this has now been moved. */ -export interface ScaffolderApi { - getTemplateParameterSchema( - templateRef: string, - ): Promise; - - /** - * Executes the scaffolding of a component, given a template and its - * parameter values. - * - * @param options - The {@link ScaffolderScaffoldOptions} the scaffolding. - */ - scaffold( - options: ScaffolderScaffoldOptions, - ): Promise; - - getTask(taskId: string): Promise; - - /** - * Sends a signal to a task broker to cancel the running task by taskId. - * - * @param taskId - the id of the task - */ - cancelTask(taskId: string): Promise; - - /** - * Starts the task again from the point where it failed. - * - * @param taskId - the id of the task - */ - retry?(taskId: string): Promise; - - listTasks?(options: { - filterByOwnership: 'owned' | 'all'; - limit?: number; - offset?: number; - }): Promise<{ tasks: ScaffolderTask[]; totalTasks?: number }>; - - getIntegrationsList( - options: ScaffolderGetIntegrationsListOptions, - ): Promise; - - /** - * Returns a list of all installed actions. - */ - listActions(): Promise; - - /** - * Returns a structure describing the available templating extensions. - */ - listTemplatingExtensions?(): Promise; - - streamLogs(options: ScaffolderStreamLogsOptions): Observable; - - dryRun?(options: ScaffolderDryRunOptions): Promise; - - autocomplete?(options: { - token: string; - provider: string; - resource: string; - context?: Record; - }): Promise<{ results: { title?: string; id: string }[] }>; -} +export type ScaffolderApi = _ScaffolderApi; diff --git a/plugins/scaffolder-react/src/types.ts b/plugins/scaffolder-react/src/types.ts index 5f557198c6..5b724c5871 100644 --- a/plugins/scaffolder-react/src/types.ts +++ b/plugins/scaffolder-react/src/types.ts @@ -14,24 +14,13 @@ * limitations under the License. */ -import { JsonObject } from '@backstage/types'; - -import { TemplatePresentationV1beta3 } from '@backstage/plugin-scaffolder-common'; +import { TemplateParameterSchema as _TemplateParameterSchema } from '@backstage/plugin-scaffolder-common'; /** * The shape of each entry of parameters which gets rendered * as a separate step in the wizard input * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#TemplateParameterSchema} instead as this has now been moved. */ -export type TemplateParameterSchema = { - title: string; - description?: string; - presentation?: TemplatePresentationV1beta3; - steps: Array<{ - title: string; - description?: string; - schema: JsonObject; - }>; - EXPERIMENTAL_formDecorators?: { id: string; input?: JsonObject }[]; -}; +export type TemplateParameterSchema = _TemplateParameterSchema; diff --git a/plugins/scaffolder/package.json b/plugins/scaffolder/package.json index 6027359335..6f39c60914 100644 --- a/plugins/scaffolder/package.json +++ b/plugins/scaffolder/package.json @@ -79,7 +79,6 @@ "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.61", - "@microsoft/fetch-event-source": "^2.0.1", "@react-hookz/web": "^24.0.0", "@rjsf/core": "5.23.2", "@rjsf/material-ui": "5.23.2", @@ -100,7 +99,6 @@ "react-use": "^17.2.4", "react-window": "^1.8.10", "yaml": "^2.0.0", - "zen-observable": "^0.10.0", "zod": "^3.22.4", "zod-to-json-schema": "^3.20.4" }, @@ -120,7 +118,6 @@ "@types/react": "^18.0.0", "@types/react-resizable": "^3.0.8", "@types/react-window": "^1.8.8", - "msw": "^1.0.0", "react": "^18.0.2", "react-dom": "^18.0.2", "react-router-dom": "^6.3.0", diff --git a/plugins/scaffolder/report.api.md b/plugins/scaffolder/report.api.md index b44889cded..fbb73f6225 100644 --- a/plugins/scaffolder/report.api.md +++ b/plugins/scaffolder/report.api.md @@ -11,47 +11,43 @@ import { createScaffolderFieldExtension as createScaffolderFieldExtension_2 } fr import { createScaffolderLayout as createScaffolderLayout_2 } from '@backstage/plugin-scaffolder-react'; import { CustomFieldExtensionSchema as CustomFieldExtensionSchema_2 } from '@backstage/plugin-scaffolder-react'; import { CustomFieldValidator as CustomFieldValidator_2 } from '@backstage/plugin-scaffolder-react'; -import { DiscoveryApi } from '@backstage/core-plugin-api'; import { ExternalRouteRef } from '@backstage/core-plugin-api'; -import { FetchApi } from '@backstage/core-plugin-api'; import { FieldExtensionComponent as FieldExtensionComponent_2 } from '@backstage/plugin-scaffolder-react'; import { FieldExtensionComponentProps as FieldExtensionComponentProps_2 } from '@backstage/plugin-scaffolder-react'; import { FieldExtensionOptions as FieldExtensionOptions_2 } from '@backstage/plugin-scaffolder-react'; import { FieldSchema as FieldSchema_2 } from '@backstage/plugin-scaffolder-react'; import { FieldValidation } from '@rjsf/utils'; import { FormProps } from '@backstage/plugin-scaffolder-react'; -import { IdentityApi } from '@backstage/core-plugin-api'; import { JSX as JSX_2 } from 'react/jsx-runtime'; import { LayoutOptions as LayoutOptions_2 } from '@backstage/plugin-scaffolder-react'; import { LayoutTemplate as LayoutTemplate_2 } from '@backstage/plugin-scaffolder-react'; -import { ListActionsResponse as ListActionsResponse_2 } from '@backstage/plugin-scaffolder-react'; -import { ListTemplatingExtensionsResponse } from '@backstage/plugin-scaffolder-react'; -import { LogEvent as LogEvent_2 } from '@backstage/plugin-scaffolder-react'; -import { Observable } from '@backstage/types'; +import { ListActionsResponse as ListActionsResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { LogEvent as LogEvent_2 } from '@backstage/plugin-scaffolder-common'; import { PathParams } from '@backstage/core-plugin-api'; import { PropsWithChildren } from 'react'; import { ReactNode } from 'react'; import { ReviewStepProps } from '@backstage/plugin-scaffolder-react'; import { RouteRef } from '@backstage/core-plugin-api'; -import { ScaffolderApi as ScaffolderApi_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderDryRunOptions as ScaffolderDryRunOptions_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderDryRunResponse as ScaffolderDryRunResponse_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderGetIntegrationsListOptions as ScaffolderGetIntegrationsListOptions_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderGetIntegrationsListResponse as ScaffolderGetIntegrationsListResponse_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderOutputLink } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderScaffoldOptions as ScaffolderScaffoldOptions_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderScaffoldResponse as ScaffolderScaffoldResponse_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderStreamLogsOptions as ScaffolderStreamLogsOptions_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderTask as ScaffolderTask_2 } from '@backstage/plugin-scaffolder-react'; +import { ScaffolderApi as ScaffolderApi_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderClient as ScaffolderClient_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderDryRunOptions as ScaffolderDryRunOptions_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderDryRunResponse as ScaffolderDryRunResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderGetIntegrationsListOptions as ScaffolderGetIntegrationsListOptions_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderGetIntegrationsListResponse as ScaffolderGetIntegrationsListResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderOutputLink } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderScaffoldOptions as ScaffolderScaffoldOptions_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderScaffoldResponse as ScaffolderScaffoldResponse_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderStreamLogsOptions as ScaffolderStreamLogsOptions_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderTask as ScaffolderTask_2 } from '@backstage/plugin-scaffolder-common'; import { ScaffolderTaskOutput as ScaffolderTaskOutput_2 } from '@backstage/plugin-scaffolder-react'; -import { ScaffolderTaskStatus as ScaffolderTaskStatus_2 } from '@backstage/plugin-scaffolder-react'; +import { ScaffolderTaskOutput as ScaffolderTaskOutput_3 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderTaskStatus as ScaffolderTaskStatus_2 } from '@backstage/plugin-scaffolder-common'; import { ScaffolderUseTemplateSecrets as ScaffolderUseTemplateSecrets_2 } from '@backstage/plugin-scaffolder-react'; -import { ScmIntegrationRegistry } from '@backstage/integration'; import { SubRouteRef } from '@backstage/core-plugin-api'; import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; import { TemplateGroupFilter } from '@backstage/plugin-scaffolder-react'; import { TemplateListPageProps } from '@backstage/plugin-scaffolder/alpha'; -import { TemplateParameterSchema as TemplateParameterSchema_2 } from '@backstage/plugin-scaffolder-react'; +import { TemplateParameterSchema as TemplateParameterSchema_2 } from '@backstage/plugin-scaffolder-common'; import { TemplateWizardPageProps } from '@backstage/plugin-scaffolder/alpha'; import { z } from 'zod'; @@ -505,70 +501,8 @@ export type ScaffolderApi = ScaffolderApi_2; // @public @deprecated (undocumented) export const scaffolderApiRef: ApiRef; -// @public -export class ScaffolderClient implements ScaffolderApi_2 { - constructor(options: { - discoveryApi: DiscoveryApi; - fetchApi: FetchApi; - identityApi?: IdentityApi; - scmIntegrationsApi: ScmIntegrationRegistry; - useLongPollingLogs?: boolean; - }); - // (undocumented) - autocomplete({ - token, - resource, - provider, - context, - }: { - token: string; - provider: string; - resource: string; - context?: Record; - }): Promise<{ - results: { - title?: string; - id: string; - }[]; - }>; - // (undocumented) - cancelTask(taskId: string): Promise; - // (undocumented) - dryRun( - options: ScaffolderDryRunOptions_2, - ): Promise; - // (undocumented) - getIntegrationsList( - options: ScaffolderGetIntegrationsListOptions_2, - ): Promise; - // (undocumented) - getTask(taskId: string): Promise; - // (undocumented) - getTemplateParameterSchema( - templateRef: string, - ): Promise; - // (undocumented) - listActions(): Promise; - // (undocumented) - listTasks(options: { - filterByOwnership: 'owned' | 'all'; - limit?: number; - offset?: number; - }): Promise<{ - tasks: ScaffolderTask_2[]; - totalTasks?: number; - }>; - // (undocumented) - listTemplatingExtensions(): Promise; - // (undocumented) - retry?(taskId: string): Promise; - // (undocumented) - scaffold( - options: ScaffolderScaffoldOptions_2, - ): Promise; - // (undocumented) - streamLogs(options: ScaffolderStreamLogsOptions_2): Observable; -} +// @public @deprecated +export class ScaffolderClient extends ScaffolderClient_2 {} // @public @deprecated (undocumented) export type ScaffolderDryRunOptions = ScaffolderDryRunOptions_2; @@ -644,7 +578,7 @@ export type ScaffolderStreamLogsOptions = ScaffolderStreamLogsOptions_2; export type ScaffolderTask = ScaffolderTask_2; // @public @deprecated (undocumented) -export type ScaffolderTaskOutput = ScaffolderTaskOutput_2; +export type ScaffolderTaskOutput = ScaffolderTaskOutput_3; // @public @deprecated (undocumented) export type ScaffolderTaskStatus = ScaffolderTaskStatus_2; diff --git a/plugins/scaffolder/src/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx b/plugins/scaffolder/src/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx index 2657565a38..5cbe524d3e 100644 --- a/plugins/scaffolder/src/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx +++ b/plugins/scaffolder/src/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx @@ -118,7 +118,7 @@ async function downloadDirectoryContents( directoryContents: { path: string; base64Content: string; - executable: boolean; + executable?: boolean; }[], name: string, ) { diff --git a/plugins/scaffolder/src/api.ts b/plugins/scaffolder/src/api.ts index 4fb3627917..d880521cf2 100644 --- a/plugins/scaffolder/src/api.ts +++ b/plugins/scaffolder/src/api.ts @@ -14,389 +14,12 @@ * 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 { - ListActionsResponse, - ListTemplatingExtensionsResponse, - LogEvent, - ScaffolderApi, - ScaffolderDryRunOptions, - ScaffolderDryRunResponse, - ScaffolderGetIntegrationsListOptions, - ScaffolderGetIntegrationsListResponse, - ScaffolderScaffoldOptions, - ScaffolderScaffoldResponse, - ScaffolderStreamLogsOptions, - ScaffolderTask, - TemplateParameterSchema, -} from '@backstage/plugin-scaffolder-react'; -import { Observable } from '@backstage/types'; -import { - EventSourceMessage, - fetchEventSource, -} from '@microsoft/fetch-event-source'; -import { default as qs, default as queryString } from 'qs'; -import ObservableImpl from 'zen-observable'; +import { ScaffolderClient as _ScaffolderClient } from '@backstage/plugin-scaffolder-common'; /** * An API to interact with the scaffolder backend. * * @public + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderClient} instead as this has now been moved. */ -export class ScaffolderClient implements ScaffolderApi { - 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.discoveryApi = options.discoveryApi; - this.fetchApi = options.fetchApi ?? { fetch }; - this.scmIntegrationsApi = options.scmIntegrationsApi; - this.useLongPollingLogs = options.useLongPollingLogs ?? false; - this.identityApi = options.identityApi; - } - - async listTasks(options: { - filterByOwnership: 'owned' | 'all'; - limit?: number; - offset?: number; - }): 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 baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - const { userEntityRef } = await this.identityApi.getBackstageIdentity(); - - const query = queryString.stringify({ - createdBy: - options.filterByOwnership === 'owned' ? userEntityRef : undefined, - limit: options.limit, - offset: options.offset, - }); - - const response = await this.fetchApi.fetch(`${baseUrl}/v2/tasks?${query}`); - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - - return await response.json(); - } - - async getIntegrationsList( - options: ScaffolderGetIntegrationsListOptions, - ): Promise { - 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, - }; - } - - async getTemplateParameterSchema( - templateRef: string, - ): Promise { - const { namespace, kind, name } = parseEntityRef(templateRef, { - defaultKind: 'template', - }); - - const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - const templatePath = [namespace, kind, name] - .map(s => encodeURIComponent(s)) - .join('/'); - - const url = `${baseUrl}/v2/templates/${templatePath}/parameter-schema`; - - const response = await this.fetchApi.fetch(url); - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - - const schema: TemplateParameterSchema = await response.json(); - return schema; - } - - async scaffold( - options: ScaffolderScaffoldOptions, - ): Promise { - const { templateRef, values, secrets = {} } = options; - const url = `${await this.discoveryApi.getBaseUrl('scaffolder')}/v2/tasks`; - const response = await this.fetchApi.fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - templateRef, - values: { ...values }, - secrets, - }), - }); - - 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()) as { id: string }; - return { taskId: id }; - } - - async getTask(taskId: string): Promise { - const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}`; - - const response = await this.fetchApi.fetch(url); - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - - return await response.json(); - } - - streamLogs(options: ScaffolderStreamLogsOptions): Observable { - if (this.useLongPollingLogs) { - return this.streamLogsPolling(options); - } - - return this.streamLogsEventStream(options); - } - - async dryRun( - options: ScaffolderDryRunOptions, - ): Promise { - const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - const response = await this.fetchApi.fetch(`${baseUrl}/v2/dry-run`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - template: options.template, - values: options.values, - secrets: options.secrets, - directoryContents: options.directoryContents, - }), - }); - - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - - return response.json(); - } - - private streamLogsEventStream({ - isTaskRecoverable, - taskId, - after, - }: ScaffolderStreamLogsOptions): Observable { - 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; - }): Observable { - let after = inputAfter; - - return new ObservableImpl(subscriber => { - this.discoveryApi.getBaseUrl('scaffolder').then(async baseUrl => { - while (!subscriber.closed) { - const url = `${baseUrl}/v2/tasks/${encodeURIComponent( - taskId, - )}/events?${qs.stringify({ after })}`; - const response = await this.fetchApi.fetch(url); - - 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; - } - } - } - }); - }); - } - - async listActions(): Promise { - const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - const response = await this.fetchApi.fetch(`${baseUrl}/v2/actions`); - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - - return await response.json(); - } - - async listTemplatingExtensions(): Promise { - 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(); - } - - async cancelTask(taskId: string): Promise { - const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}/cancel`; - - const response = await this.fetchApi.fetch(url, { - method: 'POST', - }); - - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - - return await response.json(); - } - - async retry?(taskId: string): Promise { - const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}/retry`; - - const response = await this.fetchApi.fetch(url, { - method: 'POST', - }); - - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - - return await response.json(); - } - - async autocomplete({ - token, - resource, - provider, - context, - }: { - token: string; - provider: string; - resource: string; - context?: Record; - }): Promise<{ results: { title?: string; id: string }[] }> { - const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - - const url = `${baseUrl}/v2/autocomplete/${provider}/${resource}`; - - const response = await this.fetchApi.fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - token, - context: context ?? {}, - }), - }); - - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - - const { results } = await response.json(); - return { results }; - } -} +export class ScaffolderClient extends _ScaffolderClient {} diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/BitbucketRepoPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/BitbucketRepoPicker.tsx index 696b33e9d0..f5861d4946 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/BitbucketRepoPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/BitbucketRepoPicker.tsx @@ -85,6 +85,7 @@ export const BitbucketRepoPicker = ( scaffolderApi .autocomplete({ + context: {}, token: accessToken, resource: 'workspaces', provider: 'bitbucket-cloud', diff --git a/plugins/scaffolder/src/deprecated.ts b/plugins/scaffolder/src/deprecated.ts index 907871946c..f3230ab287 100644 --- a/plugins/scaffolder/src/deprecated.ts +++ b/plugins/scaffolder/src/deprecated.ts @@ -21,22 +21,8 @@ */ import { - createScaffolderFieldExtension as createScaffolderFieldExtensionTemp, - ScaffolderFieldExtensions as ScaffolderFieldExtensionsTemp, - useTemplateSecrets as useTemplateSecretsTemp, - scaffolderApiRef as scaffolderApiRefTemp, - createScaffolderLayout as createScaffolderLayoutTemp, - ScaffolderLayouts as ScaffolderLayoutsTemp, - type LayoutOptions as LayoutOptionsTemp, - type LayoutTemplate as LayoutTemplateTemp, type ScaffolderApi as ScaffolderApiTemp, - type ScaffolderUseTemplateSecrets as ScaffolderUseTemplateSecretsTemp, type TemplateParameterSchema as TemplateParameterSchemaTemp, - type CustomFieldExtensionSchema as CustomFieldExtensionSchemaTemp, - type CustomFieldValidator as CustomFieldValidatorTemp, - type FieldExtensionOptions as FieldExtensionOptionsTemp, - type FieldExtensionComponentProps as FieldExtensionComponentPropsTemp, - type FieldExtensionComponent as FieldExtensionComponentTemp, type ListActionsResponse as ListActionsResponseTemp, type LogEvent as LogEventTemp, type ScaffolderDryRunOptions as ScaffolderDryRunOptionsTemp, @@ -50,6 +36,23 @@ import { type ScaffolderTask as ScaffolderTaskTemp, type ScaffolderTaskOutput as ScaffolderTaskOutputTemp, type ScaffolderTaskStatus as ScaffolderTaskStatusTemp, +} from '@backstage/plugin-scaffolder-common'; + +import { + createScaffolderFieldExtension as createScaffolderFieldExtensionTemp, + ScaffolderFieldExtensions as ScaffolderFieldExtensionsTemp, + useTemplateSecrets as useTemplateSecretsTemp, + scaffolderApiRef as scaffolderApiRefTemp, + createScaffolderLayout as createScaffolderLayoutTemp, + ScaffolderLayouts as ScaffolderLayoutsTemp, + type LayoutOptions as LayoutOptionsTemp, + type LayoutTemplate as LayoutTemplateTemp, + type ScaffolderUseTemplateSecrets as ScaffolderUseTemplateSecretsTemp, + type CustomFieldExtensionSchema as CustomFieldExtensionSchemaTemp, + type CustomFieldValidator as CustomFieldValidatorTemp, + type FieldExtensionOptions as FieldExtensionOptionsTemp, + type FieldExtensionComponentProps as FieldExtensionComponentPropsTemp, + type FieldExtensionComponent as FieldExtensionComponentTemp, } from '@backstage/plugin-scaffolder-react'; import { rootRouteRef as rootRouteRefTemp } from './routes'; @@ -82,7 +85,7 @@ export const useTemplateSecrets = useTemplateSecretsTemp; export const scaffolderApiRef = scaffolderApiRefTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderApi} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderApi} instead as this has now been moved. */ export type ScaffolderApi = ScaffolderApiTemp; /** @@ -92,7 +95,7 @@ export type ScaffolderApi = ScaffolderApiTemp; export type ScaffolderUseTemplateSecrets = ScaffolderUseTemplateSecretsTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#TemplateParameterSchema} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#TemplateParameterSchema} instead as this has now been moved. */ export type TemplateParameterSchema = TemplateParameterSchemaTemp; /** @@ -127,69 +130,69 @@ export type FieldExtensionComponent<_TReturnValue, _TInputProps> = FieldExtensionComponentTemp<_TReturnValue, _TInputProps>; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ListActionsResponse} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ListActionsResponse} instead as this has now been moved. */ export type ListActionsResponse = ListActionsResponseTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#LogEvent} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#LogEvent} instead as this has now been moved. */ export type LogEvent = LogEventTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderDryRunOptions} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderDryRunOptions} instead as this has now been moved. */ export type ScaffolderDryRunOptions = ScaffolderDryRunOptionsTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderDryRunResponse} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderDryRunResponse} instead as this has now been moved. */ export type ScaffolderDryRunResponse = ScaffolderDryRunResponseTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderGetIntegrationsListOptions} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderGetIntegrationsListOptions} instead as this has now been moved. */ export type ScaffolderGetIntegrationsListOptions = ScaffolderGetIntegrationsListOptionsTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderGetIntegrationsListResponse} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderGetIntegrationsListResponse} instead as this has now been moved. */ export type ScaffolderGetIntegrationsListResponse = ScaffolderGetIntegrationsListResponseTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderOutputlink} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderOutputlink} instead as this has now been moved. */ export type ScaffolderOutputlink = ScaffolderOutputLinkTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderScaffoldOptions} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderScaffoldOptions} instead as this has now been moved. */ export type ScaffolderScaffoldOptions = ScaffolderScaffoldOptionsTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderScaffoldResponse} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderScaffoldResponse} instead as this has now been moved. */ export type ScaffolderScaffoldResponse = ScaffolderScaffoldResponseTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderStreamLogsOptions} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderStreamLogsOptions} instead as this has now been moved. */ export type ScaffolderStreamLogsOptions = ScaffolderStreamLogsOptionsTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderTask} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderTask} instead as this has now been moved. */ export type ScaffolderTask = ScaffolderTaskTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderTaskOutput} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderTaskOutput} instead as this has now been moved. */ export type ScaffolderTaskOutput = ScaffolderTaskOutputTemp; /** * @public - * @deprecated use import from {@link @backstage/plugin-scaffolder-react#ScaffolderTaskStatus} instead as this has now been moved. + * @deprecated use import from {@link @backstage/plugin-scaffolder-common#ScaffolderTaskStatus} instead as this has now been moved. */ export type ScaffolderTaskStatus = ScaffolderTaskStatusTemp; /** diff --git a/yarn.lock b/yarn.lock index 192ea5831a..4621fdd8b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7323,6 +7323,7 @@ __metadata: dependencies: "@backstage/backend-app-api": "workspace:^" "@backstage/backend-defaults": "workspace:^" + "@backstage/backend-openapi-utils": "workspace:^" "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/catalog-model": "workspace:^" @@ -7348,6 +7349,7 @@ __metadata: "@backstage/plugin-scaffolder-common": "workspace:^" "@backstage/plugin-scaffolder-node": "workspace:^" "@backstage/plugin-scaffolder-node-test-utils": "workspace:^" + "@backstage/repo-tools": "workspace:^" "@backstage/types": "workspace:^" "@opentelemetry/api": "npm:^1.9.0" "@types/express": "npm:^4.17.6" @@ -7359,7 +7361,6 @@ __metadata: concat-stream: "npm:^2.0.0" esbuild: "npm:^0.25.0" express: "npm:^4.17.1" - express-promise-router: "npm:^4.1.0" fs-extra: "npm:^11.2.0" globby: "npm:^11.0.0" isbinaryfile: "npm:^5.0.0" @@ -7394,8 +7395,18 @@ __metadata: dependencies: "@backstage/catalog-model": "workspace:^" "@backstage/cli": "workspace:^" + "@backstage/errors": "workspace:^" + "@backstage/integration": "workspace:^" "@backstage/plugin-permission-common": "workspace:^" + "@backstage/test-utils": "workspace:^" "@backstage/types": "workspace:^" + "@microsoft/fetch-event-source": "npm:^2.0.1" + "@types/json-schema": "npm:^7.0.9" + cross-fetch: "npm:^4.0.0" + json-schema: "npm:^0.4.0" + msw: "npm:^1.0.0" + uri-template: "npm:^2.0.0" + zen-observable: "npm:^0.10.0" languageName: unknown linkType: soft @@ -7555,7 +7566,6 @@ __metadata: "@material-ui/core": "npm:^4.12.2" "@material-ui/icons": "npm:^4.9.1" "@material-ui/lab": "npm:4.0.0-alpha.61" - "@microsoft/fetch-event-source": "npm:^2.0.1" "@react-hookz/web": "npm:^24.0.0" "@rjsf/core": "npm:5.23.2" "@rjsf/material-ui": "npm:5.23.2" @@ -7580,7 +7590,6 @@ __metadata: jszip: "npm:^3.10.1" lodash: "npm:^4.17.21" luxon: "npm:^3.0.0" - msw: "npm:^1.0.0" qs: "npm:^6.9.4" react: "npm:^18.0.2" react-dom: "npm:^18.0.2" @@ -7590,7 +7599,6 @@ __metadata: react-window: "npm:^1.8.10" swr: "npm:^2.0.0" yaml: "npm:^2.0.0" - zen-observable: "npm:^0.10.0" zod: "npm:^3.22.4" zod-to-json-schema: "npm:^3.20.4" peerDependencies: