From d2da49c568c43301feab5ac333eb24d3148e8b94 Mon Sep 17 00:00:00 2001 From: solimant Date: Fri, 27 Dec 2024 07:22:58 +0000 Subject: [PATCH] Deprecate and re-export Signed-off-by: solimant --- .../src/scaffolder/dryrun/createDryRunner.ts | 22 +- .../src/scaffolder/tasks/DatabaseTaskStore.ts | 2 +- .../scaffolder/tasks/taskRecoveryHelper.ts | 2 +- .../src/schema/openapi.yaml | 826 +++++++++--------- .../openapi/generated/apis/Api.server.ts | 10 +- .../models/Autocomplete200Response.model.ts | 2 +- ...tocomplete200ResponseResultsInner.model.ts | 1 + .../models/DryRun200Response.model.ts | 2 +- .../models/DryRun200ResponseAllOf.model.ts | 2 +- .../DryRun200ResponseAllOfStepsInner.model.ts | 6 +- .../generated/models/DryRunRequest.model.ts | 10 +- .../models/DryRunResultLogInner.model.ts | 6 +- ...l.ts => DryRunResultLogInnerBody.model.ts} | 8 +- ...=> DryRunResultLogInnerBodyAllOf.model.ts} | 7 +- .../models/Scaffold201Response.model.ts | 2 +- .../models/ScaffolderScaffoldOptions.model.ts | 3 +- .../openapi/generated/models/Schema.model.ts | 64 -- .../models/SchemaAdditionalItems.model.ts | 25 - .../models/SchemaDependenciesValue.model.ts | 25 - .../generated/models/SchemaItems.model.ts | 25 - .../generated/models/SchemaRequired.model.ts | 24 - .../generated/models/SchemaType.model.ts | 24 - .../generated/models/SerializedTask.model.ts | 3 +- .../models/SerializedTaskEvent.model.ts | 6 +- .../generated/models/TaskEventType.model.ts | 4 +- .../generated/models/TaskSecrets.model.ts | 2 - .../models/TaskSecretsAllOf.model.ts} | 4 +- .../generated/models/TaskSpecV1beta3.model.ts | 55 -- .../models/TaskSpecV1beta3User.model.ts | 34 - .../generated/models/TaskStatus.model.ts | 4 +- .../models/TemplateEntityStepV1beta3.model.ts | 35 - .../TemplateEntityStepV1beta3AllOf.model.ts | 32 - .../models/TemplateEntityV1beta3.model.ts | 53 -- .../TemplateEntityV1beta3AllOf.model.ts | 45 - .../TemplateEntityV1beta3AllOfSpec.model.ts | 49 -- ...eEntityV1beta3AllOfSpecParameters.model.ts | 28 - .../models/TemplateParameterSchema.model.ts | 2 - ...TemplateParameterSchemaStepsInner.model.ts | 3 +- .../models/TemplateParametersV1beta3.model.ts | 25 - .../TemplatePresentationV1beta3.model.ts | 30 - ...tePresentationV1beta3ButtonLabels.model.ts | 38 - .../models/TemplateRecoveryV1beta3.model.ts | 25 - .../generated/models/ValidationError.model.ts | 4 +- .../models/ValidationErrorSchema.model.ts | 25 - .../schema/openapi/generated/models/index.ts | 26 +- .../src/schema/openapi/generated/router.ts | 591 +++---------- .../openapi/generated/apis/Api.client.ts | 12 +- .../models/Autocomplete200Response.model.ts | 2 +- ...tocomplete200ResponseResultsInner.model.ts | 1 + .../models/DryRun200Response.model.ts | 2 +- .../models/DryRun200ResponseAllOf.model.ts | 2 +- .../DryRun200ResponseAllOfStepsInner.model.ts | 6 +- .../generated/models/DryRunRequest.model.ts | 10 +- .../models/DryRunResultLogInner.model.ts | 6 +- .../models/DryRunResultLogInnerBody.model.ts} | 8 +- ...=> DryRunResultLogInnerBodyAllOf.model.ts} | 8 +- .../models/Scaffold201Response.model.ts | 2 +- .../models/ScaffolderScaffoldOptions.model.ts | 3 +- .../openapi/generated/models/Schema.model.ts | 64 -- .../models/SchemaAdditionalItems.model.ts | 25 - .../models/SchemaDependenciesValue.model.ts | 25 - .../generated/models/SchemaItems.model.ts | 25 - .../generated/models/SchemaRequired.model.ts | 24 - .../generated/models/SchemaType.model.ts | 24 - .../generated/models/SerializedTask.model.ts | 3 +- .../models/SerializedTaskEvent.model.ts | 6 +- .../generated/models/TaskEventType.model.ts | 4 +- .../generated/models/TaskSecrets.model.ts | 2 - .../models/TaskSecretsAllOf.model.ts} | 4 +- .../generated/models/TaskSpecV1beta3.model.ts | 55 -- .../models/TaskSpecV1beta3User.model.ts | 34 - .../generated/models/TaskStatus.model.ts | 4 +- .../models/TemplateEntityStepV1beta3.model.ts | 35 - .../TemplateEntityStepV1beta3AllOf.model.ts | 32 - .../models/TemplateEntityV1beta3.model.ts | 53 -- .../TemplateEntityV1beta3AllOf.model.ts | 45 - .../TemplateEntityV1beta3AllOfSpec.model.ts | 49 -- ...eEntityV1beta3AllOfSpecParameters.model.ts | 28 - .../models/TemplateParameterSchema.model.ts | 2 - ...TemplateParameterSchemaStepsInner.model.ts | 3 +- .../models/TemplateParametersV1beta3.model.ts | 25 - .../TemplatePermissionsV1beta3.model.ts | 27 - .../TemplatePermissionsV1beta3AllOf.model.ts | 26 - .../TemplatePresentationV1beta3.model.ts | 30 - ...tePresentationV1beta3ButtonLabels.model.ts | 38 - .../models/TemplateRecoveryV1beta3.model.ts | 25 - .../generated/models/ValidationError.model.ts | 4 +- .../models/ValidationErrorSchema.model.ts | 25 - .../schema/openapi/generated/models/index.ts | 26 +- plugins/scaffolder-common/package.json | 9 +- .../scaffolder-common/src/ScaffolderClient.ts | 430 +++++++++ .../src/TemplateEntityV1beta3.ts | 18 + plugins/scaffolder-common/src/api.ts | 362 ++++++++ plugins/scaffolder-common/src/index.ts | 5 + plugins/scaffolder-node/src/tasks/types.ts | 9 +- plugins/scaffolder-react/src/api/types.ts | 277 ++---- plugins/scaffolder-react/src/types.ts | 17 +- plugins/scaffolder/package.json | 6 - .../DryRunResults/DryRunResultsList.tsx | 2 +- plugins/scaffolder/src/api.ts | 383 +------- .../components/OngoingTask/OngoingTask.tsx | 2 +- .../RepoUrlPicker/BitbucketRepoPicker.tsx | 1 + plugins/scaffolder/src/deprecated.ts | 61 +- 103 files changed, 1619 insertions(+), 3018 deletions(-) rename plugins/scaffolder-backend/src/schema/openapi/generated/models/{DryRun200ResponseAllOfStepsInnerAllOf.model.ts => DryRunResultLogInnerBody.model.ts} (83%) rename plugins/scaffolder-backend/src/schema/openapi/generated/models/{TemplatePermissionsV1beta3AllOf.model.ts => DryRunResultLogInnerBodyAllOf.model.ts} (83%) delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/Schema.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaAdditionalItems.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaDependenciesValue.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaItems.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaRequired.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaType.model.ts rename plugins/{scaffolder-common/client/src/schema/openapi/generated/models/SchemaExclusiveMaximum.model.ts => scaffolder-backend/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts} (92%) delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSpecV1beta3.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSpecV1beta3User.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityStepV1beta3.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityStepV1beta3AllOf.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOf.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpec.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpecParameters.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParametersV1beta3.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePresentationV1beta3.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePresentationV1beta3ButtonLabels.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateRecoveryV1beta3.model.ts delete mode 100644 plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorSchema.model.ts rename plugins/{scaffolder-backend/src/schema/openapi/generated/models/TemplatePermissionsV1beta3.model.ts => scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts} (83%) rename plugins/scaffolder-common/client/src/schema/openapi/generated/models/{DryRun200ResponseAllOfStepsInnerAllOf.model.ts => DryRunResultLogInnerBodyAllOf.model.ts} (83%) delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/Schema.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaAdditionalItems.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaDependenciesValue.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaItems.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaRequired.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaType.model.ts rename plugins/{scaffolder-backend/src/schema/openapi/generated/models/SchemaExclusiveMaximum.model.ts => scaffolder-common/client/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts} (92%) delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSpecV1beta3.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSpecV1beta3User.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityStepV1beta3.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityStepV1beta3AllOf.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOf.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpec.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpecParameters.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParametersV1beta3.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePermissionsV1beta3.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePermissionsV1beta3AllOf.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePresentationV1beta3.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePresentationV1beta3ButtonLabels.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateRecoveryV1beta3.model.ts delete mode 100644 plugins/scaffolder-common/client/src/schema/openapi/generated/models/ValidationErrorSchema.model.ts create mode 100644 plugins/scaffolder-common/src/ScaffolderClient.ts create mode 100644 plugins/scaffolder-common/src/api.ts 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 index b89c270e59..b1a88c5a49 100644 --- a/plugins/scaffolder-backend/src/schema/openapi.yaml +++ b/plugins/scaffolder-backend/src/schema/openapi.yaml @@ -20,11 +20,14 @@ components: required: false allowReserved: true schema: - type: string + type: array + items: + type: string eventsAfter: name: after in: query description: Offset event ID to stream events after. + required: false schema: type: integer kind: @@ -41,8 +44,10 @@ components: required: false allowReserved: true schema: - type: integer - minimum: 0 + type: array + items: + type: integer + minimum: 0 namespace: name: namespace in: path @@ -64,8 +69,10 @@ components: required: false allowReserved: true schema: - type: integer - minimum: 0 + type: array + items: + type: integer + minimum: 0 order: name: order in: query @@ -73,10 +80,9 @@ components: required: false allowReserved: true schema: - type: string - enum: - - asc - - desc + type: array + items: + type: string status: name: status in: query @@ -84,7 +90,9 @@ components: required: false allowReserved: true schema: - type: string + type: array + items: + type: string taskId: name: taskId in: path @@ -142,7 +150,20 @@ components: type: object properties: body: - $ref: '#/components/schemas/JsonObject' + 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: @@ -339,7 +360,8 @@ components: - type: boolean - type: number - type: string - - nullable: true + - type: object + nullable: true description: A type representing all allowed JSON primitive values. JsonValue: oneOf: @@ -377,8 +399,7 @@ components: type: string values: type: object - additionalProperties: - $ref: '#/components/schemas/JsonValue' + additionalProperties: {} secrets: type: object additionalProperties: @@ -387,128 +408,125 @@ components: - templateRef - values description: The input options to the `scaffold` method of the `ScaffolderClient`. - # come back to this one - done - # check generated - done - Schema: - type: object - properties: - # $id: - # type: string - id: - type: string - # $schema: - # type: string - # $ref: - # type: string - title: - type: string - description: - type: string - multipleOf: - type: number - maximum: - type: number - exclusiveMaximum: - oneOf: - - type: number - - type: boolean - minimum: - type: number - exclusiveMinimum: - oneOf: - - type: number - - type: boolean - maxLength: - type: integer - minLength: - type: integer - pattern: - type: object - additionalItems: - oneOf: - - type: boolean - - $ref: '#/components/schemas/Schema' - items: - oneOf: - - $ref: '#/components/schemas/Schema' - - type: array - items: - $ref: '#/components/schemas/Schema' - maxItems: - type: integer - minItems: - type: integer - uniqueItems: - type: boolean - maxProperties: - type: integer - minProperties: - type: integer - required: - oneOf: - - type: array - items: - type: string - - type: boolean - additionalProperties: - oneOf: - - type: boolean - - $ref: '#/components/schemas/Schema' - definitions: - type: object - additionalProperties: - $ref: '#/components/schemas/Schema' - properties: - type: object - additionalProperties: - $ref: '#/components/schemas/Schema' - patternProperties: - type: object - additionalProperties: - $ref: '#/components/schemas/Schema' - dependencies: - type: object - additionalProperties: - oneOf: - - $ref: '#/components/schemas/Schema' - - type: array - items: - type: string - # const: - # type: object - # enum: - # type: array - # items: - # type: object - type: - oneOf: - - type: string - - type: array - items: - type: string - format: - type: string - allOf: - type: array - items: - $ref: '#/components/schemas/Schema' - anyOf: - type: array - items: - $ref: '#/components/schemas/Schema' - oneOf: - type: array - items: - $ref: '#/components/schemas/Schema' - not: - $ref: '#/components/schemas/Schema' - # if: - # $ref: '#/components/schemas/Schema' - then: - $ref: '#/components/schemas/Schema' - # else: - # $ref: '#/components/schemas/Schema' - additionalProperties: {} + # Schema: + # type: object + # properties: + # $id: + # type: string + # id: + # type: string + # $schema: + # type: string + # $ref: + # type: string + # title: + # type: string + # description: + # type: string + # multipleOf: + # type: number + # maximum: + # type: number + # exclusiveMaximum: + # oneOf: + # - type: number + # - type: boolean + # minimum: + # type: number + # exclusiveMinimum: + # oneOf: + # - type: number + # - type: boolean + # maxLength: + # type: integer + # minLength: + # type: integer + # pattern: + # type: object + # additionalItems: + # oneOf: + # - type: boolean + # - $ref: '#/components/schemas/Schema' + # items: + # oneOf: + # - $ref: '#/components/schemas/Schema' + # - type: array + # items: + # $ref: '#/components/schemas/Schema' + # maxItems: + # type: integer + # minItems: + # type: integer + # uniqueItems: + # type: boolean + # maxProperties: + # type: integer + # minProperties: + # type: integer + # required: + # oneOf: + # - type: array + # items: + # type: string + # - type: boolean + # additionalProperties: + # oneOf: + # - type: boolean + # - $ref: '#/components/schemas/Schema' + # definitions: + # type: object + # additionalProperties: + # $ref: '#/components/schemas/Schema' + # properties: + # type: object + # additionalProperties: + # $ref: '#/components/schemas/Schema' + # patternProperties: + # type: object + # additionalProperties: + # $ref: '#/components/schemas/Schema' + # dependencies: + # type: object + # additionalProperties: + # oneOf: + # - $ref: '#/components/schemas/Schema' + # - type: array + # items: + # type: string + # const: + # type: object + # enum: + # type: array + # items: + # type: object + # type: + # oneOf: + # - type: string + # - type: array + # items: + # type: string + # format: + # type: string + # allOf: + # type: array + # items: + # $ref: '#/components/schemas/Schema' + # anyOf: + # type: array + # items: + # $ref: '#/components/schemas/Schema' + # oneOf: + # type: array + # items: + # $ref: '#/components/schemas/Schema' + # not: + # $ref: '#/components/schemas/Schema' + # if: + # $ref: '#/components/schemas/Schema' + # then: + # $ref: '#/components/schemas/Schema' + # else: + # $ref: '#/components/schemas/Schema' SerializedFile: type: object properties: @@ -534,7 +552,18 @@ components: taskId: type: string body: - $ref: '#/components/schemas/JsonObject' + 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: @@ -552,7 +581,8 @@ components: id: type: string spec: - $ref: '#/components/schemas/TaskSpec' + type: object + # $ref: '#/components/schemas/TaskSpec' status: $ref: '#/components/schemas/TaskStatus' createdAt: @@ -571,27 +601,25 @@ components: - status - createdAt description: SerializedTask + # additionalProperties: {} TaskEventType: type: string description: TaskEventType enum: + - cancelled - completion - log - - cancelled - recovered TaskRecovery: type: object # properties: - # come back to this one - done - # EXPERIMENTAL_strategy: - # $ref: '#/components/schemas/TaskRecoverStrategy' + # EXPERIMENTAL_strategy: + # $ref: '#/components/schemas/TaskRecoverStrategy' description: |- When task didn't have a chance to complete due to system restart you can define the strategy what to do with such tasks, by defining a strategy. By default, it is none, what means to not recover but updating the status from 'processing' to 'failed'. - additionalProperties: - $ref: '#/components/schemas/TaskRecoverStrategy' TaskRecoverStrategy: type: string description: | @@ -601,76 +629,77 @@ components: - none - startOver TaskSecrets: - type: object - properties: - backstageToken: - type: string - description: TaskSecrets - additionalProperties: {} - TaskSpec: - $ref: '#/components/schemas/TaskSpecV1beta3' - TaskSpecV1beta3: - type: object - properties: - apiVersion: - type: string - enum: - - "scaffolder.backstage.io/v1beta3" - description: The apiVersion string of the TaskSpec. - parameters: - $ref: '#/components/schemas/JsonObject' - description: | - This is a JSONSchema which is used to render a form in the frontend - to collect user input and validate it against that schema. This can then be used in the `steps` part below to template - variables passed from the user into each action in the template. - steps: - type: array - items: - $ref: '#/components/schemas/TaskStep' - description: | - A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying - javascript action and some optional input parameters that may or may not have been collected from the end user. - output: - type: object + allOf: + - type: object additionalProperties: - $ref: '#/components/schemas/JsonValue' - description: | - The output is an object where template authors can pull out information from template actions and return them in a known standard way. - templateInfo: - $ref: '#/components/schemas/TemplateInfo' - description: Some information about the template that is stored on the task spec. - user: - type: object + type: string + - type: object properties: - entity: - type: object - description: The decorated entity from the Catalog - ref: + backstageToken: type: string - description: An entity ref for the author of the task - description: Some decoration of the author of the task that should be available in the context - # come back to this one - done - # EXPERIMENTAL_recovery: - # $ref: '#/components/schemas/TaskRecovery' - # description: How to recover the task after system restart or system crash. - required: - - apiVersion - - parameters - - steps - - output - description: |- - A scaffolder task as stored in the database, generated from a v1beta3 - apiVersion Template. - additionalProperties: - $ref: '#/components/schemas/TaskRecovery' + description: TaskSecrets + # TaskSpec: + # $ref: '#/components/schemas/TaskSpecV1beta3' + # TaskSpecV1beta3: + # type: object + # properties: + # apiVersion: + # type: string + # enum: + # - scaffolder.backstage.io/v1beta3 + # description: The apiVersion string of the TaskSpec. + # parameters: + # $ref: '#/components/schemas/JsonObject' + # description: | + # This is a JSONSchema which is used to render a form in the frontend + # to collect user input and validate it against that schema. This can then be used in the `steps` part below to template + # variables passed from the user into each action in the template. + # steps: + # type: array + # items: + # $ref: '#/components/schemas/TaskStep' + # description: | + # A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying + # javascript action and some optional input parameters that may or may not have been collected from the end user. + # output: + # type: object + # additionalProperties: + # $ref: '#/components/schemas/JsonValue' + # description: | + # The output is an object where template authors can pull out information from template actions and return them in a known standard way. + # templateInfo: + # $ref: '#/components/schemas/TemplateInfo' + # description: Some information about the template that is stored on the task spec. + # user: + # type: object + # properties: + # entity: + # type: object + # description: The decorated entity from the Catalog + # ref: + # type: string + # description: An entity ref for the author of the task + # description: Some decoration of the author of the task that should be available in the context + # EXPERIMENTAL_recovery: + # $ref: '#/components/schemas/TaskRecovery' + # description: How to recover the task after system restart or system crash. + # required: + # - apiVersion + # - parameters + # - steps + # - output + # description: |- + # A scaffolder task as stored in the database, generated from a v1beta3 + # apiVersion Template. TaskStatus: type: string enum: - - 'cancelled' - - 'completed' - - 'failed' - - 'open' - - 'processing' + - cancelled + - completed + - failed + - open + - processing + - skipped description: The status of each step of the Task TaskStep: type: object @@ -703,94 +732,103 @@ components: - action description: An individual step of a scaffolder task, as stored in the database. additionalProperties: {} - TemplateEntityStepV1beta3: - allOf: - - $ref: '#/components/schemas/JsonObject' - - type: object - properties: - id: - type: string - name: - type: string - action: - type: string - input: - $ref: '#/components/schemas/JsonObject' - # if: - # oneOf: - # - type: string - # - type: boolean - # come back to this one - done - # backstage:permissions: - # $ref: '#/components/schemas/TemplatePermissionsV1beta3' - required: - - action - description: Step that is part of a Template Entity. - additionalProperties: {} - TemplateEntityV1beta3: - allOf: - # come back to this one - done - - $ref: '#/components/schemas/Entity' - - type: object - properties: - apiVersion: - type: string - enum: ['scaffolder.backstage.io/v1beta3'] - description: The apiVersion string of the TaskSpec. - kind: - type: string - enum: ['Template'] - description: The kind of the entity - spec: - type: object - properties: - type: - type: string - description: The type that the Template will create. For example service, website or library. - presentation: - $ref: '#/components/schemas/TemplatePresentationV1beta3' - description: Template specific configuration of the presentation layer. - # come back to this one - done - # EXPERIMENTAL_recovery: - # $ref: '#/components/schemas/TemplateRecoveryV1beta3' - # description: Recovery strategy for the template - parameters: - oneOf: - - $ref: '#/components/schemas/TemplateParametersV1beta3' - - type: array - items: - $ref: '#/components/schemas/TemplateParametersV1beta3' - description: |- - This is a JSONSchema or an array of JSONSchema's which is used to render a form in the frontend - to collect user input and validate it against that schema. This can then be used in the `steps` part below to template - variables passed from the user into each action in the template. - steps: - type: array - items: - $ref: '#/components/schemas/TemplateEntityStepV1beta3' - description: |- - A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying - javascript action and some optional input parameters that may or may not have been collected from the end user. - output: - type: object - additionalProperties: - type: string - description: The output is an object where template authors can pull out information from template actions and return them in a known standard way. - owner: - type: string - description: The owner entityRef of the TemplateEntity - required: - - type - - steps - description: The specification of the Template Entity - additionalProperties: {} - required: - - apiVersion - - kind - - spec - description: |- - Backstage catalog Template kind Entity. Templates are used by the Scaffolder - plugin to create new entities, such as Components. + # TemplateEntityStepV1beta3: + # allOf: + # - $ref: '#/components/schemas/JsonObject' + # - type: object + # properties: + # id: + # type: string + # name: + # type: string + # action: + # type: string + # input: + # $ref: '#/components/schemas/JsonObject' + # if: + # oneOf: + # - type: string + # - type: boolean + # backstage:permissions: + # $ref: '#/components/schemas/TemplatePermissionsV1beta3' + # required: + # - action + # description: Step that is part of a Template Entity. + # additionalProperties: {} + # TemplateEntityV1beta3: + # allOf: + # - $ref: '#/components/schemas/Entity' + # - type: object + # properties: + # apiVersion: + # type: string + # enum: + # - scaffolder.backstage.io/v1beta3 + # description: The apiVersion string of the TaskSpec. + # kind: + # type: string + # enum: + # - Template + # description: The kind of the entity + # spec: + # type: object + # properties: + # type: + # type: string + # description: The type that the Template will create. For example service, website or library. + # presentation: + # $ref: '#/components/schemas/TemplatePresentationV1beta3' + # description: Template specific configuration of the presentation layer. + # EXPERIMENTAL_recovery: + # $ref: '#/components/schemas/TemplateRecoveryV1beta3' + # description: Recovery strategy for the template + # EXPERIMENTAL_formDecorators: + # type: array + # items: + # type: object + # properties: + # id: + # type: string + # input: + # $ref: '#/components/schemas/JsonObject' + # required: + # - id + # parameters: + # oneOf: + # - $ref: '#/components/schemas/TemplateParametersV1beta3' + # - type: array + # items: + # $ref: '#/components/schemas/TemplateParametersV1beta3' + # description: |- + # This is a JSONSchema or an array of JSONSchema's which is used to render a form in the frontend + # to collect user input and validate it against that schema. This can then be used in the `steps` part below to template + # variables passed from the user into each action in the template. + # steps: + # type: array + # items: + # $ref: '#/components/schemas/TemplateEntityStepV1beta3' + # description: |- + # A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying + # javascript action and some optional input parameters that may or may not have been collected from the end user. + # output: + # type: object + # additionalProperties: + # type: string + # description: The output is an object where template authors can pull out information from template actions and return them in a known standard way. + # owner: + # type: string + # description: The owner entityRef of the TemplateEntity + # required: + # - type + # - steps + # description: The specification of the Template Entity + # required: + # - apiVersion + # - kind + # - spec + # description: |- + # Backstage catalog Template kind Entity. Templates are used by the Scaffolder + # plugin to create new entities, such as Components. TemplateInfo: type: object properties: @@ -804,7 +842,6 @@ components: type: object properties: metadata: - # come back to this one - done $ref: '#/components/schemas/EntityMeta' description: The metadata of the Template. required: @@ -820,11 +857,10 @@ components: properties: title: type: string - presentation: - $ref: '#/components/schemas/TemplatePresentationV1beta3' + # presentation: + # $ref: '#/components/schemas/TemplatePresentationV1beta3' description: type: string - # come back to this one - done # 'ui:options': # $ref: '#/components/schemas/JsonValue' steps: @@ -837,20 +873,22 @@ components: description: $ref: '#/components/schemas/JsonValue' schema: - $ref: '#/components/schemas/TemplateParametersV1beta3' + type: object + # additionalProperties: {} required: - title - schema - # come back to this one - done # EXPERIMENTAL_formDecorators: # type: array # items: - # - type: object - # properties: - # id: - # type: string - # input: - # $ref: '#/components/schemas/JsonObject' + # type: object + # properties: + # id: + # type: string + # input: + # $ref: '#/components/schemas/JsonObject' + # required: + # - id required: - title - steps @@ -858,72 +896,59 @@ components: The shape of each entry of parameters which gets rendered as a separate step in the wizard input additionalProperties: {} - # check generated - TemplateParametersV1beta3: - allOf: - - $ref: '#/components/schemas/JsonObject' - # - type: object - # properties: - # # come back to this one - done - # backstage:permissions: - # $ref: '#/components/schemas/TemplatePermissionsV1beta3' - - type: object - additionalProperties: - $ref: '#/components/schemas/TemplatePermissionsV1beta3' - description: Parameter that is part of a Template Entity. - TemplatePermissionsV1beta3: - allOf: - - $ref: '#/components/schemas/JsonObject' - - type: object - properties: - tags: - type: array - items: - type: string - description: Access control properties for parts of a template. - TemplatePresentationV1beta3: - type: object - properties: - buttonLabels: - type: object - properties: - backButtonText: - type: string - description: The text for the button which leads to the previous template page - createButtonText: - type: string - description: The text for the button which starts the execution of the template - reviewButtonText: - type: string - description: The text for the button which opens template's review/summary - description: Overrides default buttons' text - additionalProperties: false - description: The presentation of the template. - additionalProperties: {} - # check generated - TemplateRecoveryV1beta3: - allOf: - - $ref: '#/components/schemas/JsonObject' - - type: object - # properties: - # # come back to this one - done - # EXPERIMENTAL_strategy: - # type: string - # enum: - # - none - # - startOver - # description: |- - # none - not recover, let the task be marked as failed - # startOver - do recover, start the execution of the task from the first step. - additionalProperties: - type: string - enum: - - none - - startOver - description: |- - none - not recover, let the task be marked as failed - startOver - do recover, start the execution of the task from the first step. - description: Depends on how you designed your task you might tailor the behaviour for each of them. + # TemplateParametersV1beta3: + # allOf: + # - $ref: '#/components/schemas/JsonObject' + # - type: object + # properties: + # backstage:permissions: + # $ref: '#/components/schemas/TemplatePermissionsV1beta3' + # additionalProperties: {} + # description: Parameter that is part of a Template Entity. + # TemplatePermissionsV1beta3: + # allOf: + # - $ref: '#/components/schemas/JsonObject' + # - type: object + # properties: + # tags: + # type: array + # items: + # type: string + # description: Access control properties for parts of a template. + # TemplatePresentationV1beta3: + # allOf: + # - $ref: '#/components/schemas/JsonObject' + # - type: object + # properties: + # buttonLabels: + # type: object + # properties: + # backButtonText: + # type: string + # description: The text for the button which leads to the previous template page + # createButtonText: + # type: string + # description: The text for the button which starts the execution of the template + # reviewButtonText: + # type: string + # description: The text for the button which opens template's review/summary + # description: Overrides default buttons' text + # description: The presentation of the template. + # additionalProperties: {} + # TemplateRecoveryV1beta3: + # allOf: + # - $ref: '#/components/schemas/JsonObject' + # - type: object + # properties: + # EXPERIMENTAL_strategy: + # type: string + # enum: + # - none + # - startOver + # description: |- + # none - not recover, let the task be marked as failed + # startOver - do recover, start the execution of the task from the first step. + # description: Depends on how you designed your task you might tailor the behaviour for each of them. ValidationError: type: object properties: @@ -937,10 +962,10 @@ components: type: string message: type: string - schema: - oneOf: - - type: string - - $ref: '#/components/schemas/Schema' + # schema: + # oneOf: + # - type: string + # - $ref: '#/components/schemas/Schema' instance: type: object name: @@ -958,6 +983,7 @@ components: - name - argument - stack + additionalProperties: {} securitySchemes: JWT: type: http @@ -1044,6 +1070,8 @@ paths: properties: id: type: string + required: + - id '400': description: Validation errors. content: @@ -1124,6 +1152,8 @@ paths: properties: id: type: string + required: + - id security: - {} - JWT: [] @@ -1174,11 +1204,15 @@ paths: type: object properties: template: - $ref: '#/components/schemas/TemplateEntityV1beta3' - values: type: object + # check generation + # additionalProperties: {} + values: + $ref: '#/components/schemas/JsonObject' secrets: type: object + additionalProperties: + type: string directoryContents: type: array items: @@ -1205,17 +1239,19 @@ paths: steps: type: array items: - allOf: - - $ref: '#/components/schemas/TemplateEntityStepV1beta3' - - type: object - properties: - id: - type: string - name: - type: string - required: - - id - - name + type: object + properties: + id: + type: string + name: + type: string + action: + type: string + required: + - id + - name + - action + additionalProperties: {} directoryContents: type: array items: @@ -1230,6 +1266,8 @@ paths: required: - path - base64Content + required: + - steps '400': description: Validation errors. content: @@ -1280,6 +1318,12 @@ paths: properties: title: type: string + id: + type: string + required: + - id + required: + - results parameters: - in: path name: provider 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 index a288266d2f..d723bf2de3 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts @@ -92,11 +92,11 @@ export type ListActions = { */ export type ListTasks = { query: { - createdBy?: string; - limit?: number; - offset?: number; - order?: 'asc' | 'desc'; - status?: string; + createdBy?: Array; + limit?: Array; + offset?: Array; + order?: Array; + status?: Array; }; response: ListTasksResponse; }; 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 index cad9a0dd29..b104dcbcc2 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200Response.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200Response.model.ts @@ -23,5 +23,5 @@ import { Autocomplete200ResponseResultsInner } from '../models/Autocomplete200Re * @public */ export interface Autocomplete200Response { - results?: Array; + 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 index bc8ea23cbb..68e8a77723 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts @@ -23,4 +23,5 @@ */ export interface Autocomplete200ResponseResultsInner { title?: string; + id: string; } 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 index 92b8d723a0..963b71135f 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200Response.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200Response.model.ts @@ -31,5 +31,5 @@ export interface DryRun200Response { * A type representing all allowed JSON object values. */ output: { [key: string]: any }; - steps?: Array; + 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 index 553c6f765a..85d99f90cf 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts @@ -24,6 +24,6 @@ import { DryRun200ResponseAllOfStepsInner } from '../models/DryRun200ResponseAll * @public */ export interface DryRun200ResponseAllOf { - steps?: Array; + steps: Array; directoryContents?: Array; } 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 index 229860f81a..5a2c0639db 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts @@ -22,11 +22,9 @@ * @public */ export interface DryRun200ResponseAllOfStepsInner { + [key: string]: any; + id: string; name: string; action: string; - /** - * A type representing all allowed JSON object values. - */ - input?: { [key: string]: any }; } 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 index 510e7fa353..c9f10fd0b0 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunRequest.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunRequest.model.ts @@ -18,14 +18,16 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { DryRunRequestDirectoryContentsInner } from '../models/DryRunRequestDirectoryContentsInner.model'; -import { TemplateEntityV1beta3 } from '../models/TemplateEntityV1beta3.model'; /** * @public */ export interface DryRunRequest { - template: TemplateEntityV1beta3; - values: any; - secrets?: any; + template: any; + /** + * A type representing all allowed JSON object values. + */ + values: { [key: string]: any }; + secrets?: { [key: string]: string }; directoryContents: Array; } 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 index 0f987091c0..f0da311b91 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts @@ -17,13 +17,11 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** +import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model'; /** * @public */ export interface DryRunResultLogInner { - /** - * A type representing all allowed JSON object values. - */ - body?: { [key: string]: any }; + body: DryRunResultLogInnerBody; } diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInnerAllOf.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts similarity index 83% rename from plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInnerAllOf.model.ts rename to plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts index 6416143493..a675d4b1ae 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInnerAllOf.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts @@ -17,11 +17,13 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; /** * @public */ -export interface DryRun200ResponseAllOfStepsInnerAllOf { - id: string; - name: string; +export interface DryRunResultLogInnerBody { + message: string; + status?: TaskStatus; + stepId?: string; } diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePermissionsV1beta3AllOf.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts similarity index 83% rename from plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePermissionsV1beta3AllOf.model.ts rename to plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts index c7eda5cd8a..665213a954 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePermissionsV1beta3AllOf.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts @@ -17,10 +17,13 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; /** * @public */ -export interface TemplatePermissionsV1beta3AllOf { - tags?: Array; +export interface DryRunResultLogInnerBodyAllOf { + message: string; + status?: TaskStatus; + stepId?: 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 index 9ff2cc8494..8c0185ca58 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Scaffold201Response.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Scaffold201Response.model.ts @@ -22,5 +22,5 @@ * @public */ export interface Scaffold201Response { - id?: string; + id: string; } 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 index 68b9927966..d02f776ebc 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts @@ -17,7 +17,6 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** -import { JsonValue } from '../models/JsonValue.model'; /** * The input options to the `scaffold` method of the `ScaffolderClient`. @@ -25,6 +24,6 @@ import { JsonValue } from '../models/JsonValue.model'; */ export interface ScaffolderScaffoldOptions { templateRef: string; - values: { [key: string]: JsonValue }; + values: { [key: string]: any }; secrets?: { [key: string]: string }; } diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Schema.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/Schema.model.ts deleted file mode 100644 index 0e24d46c30..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/Schema.model.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { SchemaAdditionalItems } from '../models/SchemaAdditionalItems.model'; -import { SchemaDependenciesValue } from '../models/SchemaDependenciesValue.model'; -import { SchemaExclusiveMaximum } from '../models/SchemaExclusiveMaximum.model'; -import { SchemaItems } from '../models/SchemaItems.model'; -import { SchemaRequired } from '../models/SchemaRequired.model'; -import { SchemaType } from '../models/SchemaType.model'; - -/** - * @public - */ -export interface Schema { - [key: string]: any; - - id?: string; - title?: string; - description?: string; - multipleOf?: number; - maximum?: number; - exclusiveMaximum?: SchemaExclusiveMaximum; - minimum?: number; - exclusiveMinimum?: SchemaExclusiveMaximum; - maxLength?: number; - minLength?: number; - pattern?: any; - additionalItems?: SchemaAdditionalItems; - items?: SchemaItems; - maxItems?: number; - minItems?: number; - uniqueItems?: boolean; - maxProperties?: number; - minProperties?: number; - required?: SchemaRequired; - additionalProperties?: SchemaAdditionalItems; - definitions?: { [key: string]: Schema }; - properties?: { [key: string]: Schema }; - patternProperties?: { [key: string]: Schema }; - dependencies?: { [key: string]: SchemaDependenciesValue }; - type?: SchemaType; - format?: string; - allOf?: Array; - anyOf?: Array; - oneOf?: Array; - not?: Schema; - then?: Schema; -} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaAdditionalItems.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaAdditionalItems.model.ts deleted file mode 100644 index 2039e2f9bb..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaAdditionalItems.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { Schema } from '../models/Schema.model'; - -/** - * @public - */ -export type SchemaAdditionalItems = Schema | boolean; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaDependenciesValue.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaDependenciesValue.model.ts deleted file mode 100644 index 97609dda50..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaDependenciesValue.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { Schema } from '../models/Schema.model'; - -/** - * @public - */ -export type SchemaDependenciesValue = Array | Schema; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaItems.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaItems.model.ts deleted file mode 100644 index c63c6700aa..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaItems.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { Schema } from '../models/Schema.model'; - -/** - * @public - */ -export type SchemaItems = Array | Schema; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaRequired.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaRequired.model.ts deleted file mode 100644 index b1b879cb3b..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaRequired.model.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * @public - */ -export type SchemaRequired = Array | boolean; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaType.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaType.model.ts deleted file mode 100644 index dd0cbb93db..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaType.model.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * @public - */ -export type SchemaType = Array | string; 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 index 7ba1196cab..f661fe07c7 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTask.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTask.model.ts @@ -18,7 +18,6 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { TaskSecrets } from '../models/TaskSecrets.model'; -import { TaskSpecV1beta3 } from '../models/TaskSpecV1beta3.model'; import { TaskStatus } from '../models/TaskStatus.model'; /** @@ -27,7 +26,7 @@ import { TaskStatus } from '../models/TaskStatus.model'; */ export interface SerializedTask { id: string; - spec: TaskSpecV1beta3; + spec: any; status: TaskStatus; createdAt: string; lastHeartbeatAt?: string; 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 index 484688e324..cc75de3a0f 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts @@ -17,6 +17,7 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** +import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model'; import { TaskEventType } from '../models/TaskEventType.model'; /** @@ -27,10 +28,7 @@ export interface SerializedTaskEvent { id: number; isTaskRecoverable?: boolean; taskId: string; - /** - * A type representing all allowed JSON object values. - */ - body: { [key: string]: any }; + body: DryRunResultLogInnerBody; type: TaskEventType; createdAt: string; } 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 index 8531d19de8..dd3d36d64e 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskEventType.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskEventType.model.ts @@ -21,14 +21,14 @@ /** * @public */ -export type TaskEventType = 'completion' | 'log' | 'cancelled' | 'recovered'; +export type TaskEventType = 'cancelled' | 'completion' | 'log' | 'recovered'; /** * @public */ export const TaskEventType = { + Cancelled: 'cancelled' as TaskEventType, Completion: 'completion' as TaskEventType, Log: 'log' as TaskEventType, - Cancelled: 'cancelled' as TaskEventType, Recovered: 'recovered' as TaskEventType, }; 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 index ae7c6a891c..74da6527a4 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecrets.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecrets.model.ts @@ -23,7 +23,5 @@ * @public */ export interface TaskSecrets { - [key: string]: any; - backstageToken?: string; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaExclusiveMaximum.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts similarity index 92% rename from plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaExclusiveMaximum.model.ts rename to plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts index c22a44e80b..7c1e5d2e9e 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaExclusiveMaximum.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts @@ -21,4 +21,6 @@ /** * @public */ -export type SchemaExclusiveMaximum = boolean | number; +export interface TaskSecretsAllOf { + backstageToken?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSpecV1beta3.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSpecV1beta3.model.ts deleted file mode 100644 index bb32940062..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSpecV1beta3.model.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { JsonValue } from '../models/JsonValue.model'; -import { TaskSpecV1beta3User } from '../models/TaskSpecV1beta3User.model'; -import { TaskStep } from '../models/TaskStep.model'; -import { TemplateInfo } from '../models/TemplateInfo.model'; - -/** - * A scaffolder task as stored in the database, generated from a v1beta3 apiVersion Template. - * @public - */ -export interface TaskSpecV1beta3 { - [key: string]: any; - - /** - * The apiVersion string of the TaskSpec. - */ - apiVersion: TaskSpecV1beta3ApiVersionEnum; - /** - * A type representing all allowed JSON object values. - */ - parameters: { [key: string]: any }; - /** - * A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying javascript action and some optional input parameters that may or may not have been collected from the end user. - */ - steps: Array; - /** - * The output is an object where template authors can pull out information from template actions and return them in a known standard way. - */ - output: { [key: string]: JsonValue }; - templateInfo?: TemplateInfo; - user?: TaskSpecV1beta3User; -} - -/** - * @public - */ -export type TaskSpecV1beta3ApiVersionEnum = 'scaffolder.backstage.io/v1beta3'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSpecV1beta3User.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSpecV1beta3User.model.ts deleted file mode 100644 index a47b103213..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskSpecV1beta3User.model.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Some decoration of the author of the task that should be available in the context - * @public - */ -export interface TaskSpecV1beta3User { - /** - * The decorated entity from the Catalog - */ - entity?: any; - /** - * An entity ref for the author of the task - */ - ref?: string; -} 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 index 42f8137fb3..622aa758c0 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskStatus.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TaskStatus.model.ts @@ -26,7 +26,8 @@ export type TaskStatus = | 'completed' | 'failed' | 'open' - | 'processing'; + | 'processing' + | 'skipped'; /** * @public @@ -37,4 +38,5 @@ export const TaskStatus = { Failed: 'failed' as TaskStatus, Open: 'open' as TaskStatus, Processing: 'processing' as TaskStatus, + Skipped: 'skipped' as TaskStatus, }; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityStepV1beta3.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityStepV1beta3.model.ts deleted file mode 100644 index e125c46f1d..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityStepV1beta3.model.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Step that is part of a Template Entity. - * @public - */ -export interface TemplateEntityStepV1beta3 { - [key: string]: any; - - id?: string; - name?: string; - action: string; - /** - * A type representing all allowed JSON object values. - */ - input?: { [key: string]: any }; -} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityStepV1beta3AllOf.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityStepV1beta3AllOf.model.ts deleted file mode 100644 index dfba72bf8d..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityStepV1beta3AllOf.model.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * @public - */ -export interface TemplateEntityStepV1beta3AllOf { - id?: string; - name?: string; - action: string; - /** - * A type representing all allowed JSON object values. - */ - input?: { [key: string]: any }; -} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3.model.ts deleted file mode 100644 index efe325cfeb..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3.model.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { EntityMeta } from '../models/EntityMeta.model'; -import { EntityRelation } from '../models/EntityRelation.model'; -import { TemplateEntityV1beta3AllOfSpec } from '../models/TemplateEntityV1beta3AllOfSpec.model'; - -/** - * Backstage catalog Template kind Entity. Templates are used by the Scaffolder plugin to create new entities, such as Components. - * @public - */ -export interface TemplateEntityV1beta3 { - /** - * The relations that this entity has with other entities. - */ - relations?: Array; - spec: TemplateEntityV1beta3AllOfSpec; - metadata: EntityMeta; - /** - * The kind of the entity - */ - kind: TemplateEntityV1beta3KindEnum; - /** - * The apiVersion string of the TaskSpec. - */ - apiVersion: TemplateEntityV1beta3ApiVersionEnum; -} - -/** - * @public - */ -export type TemplateEntityV1beta3KindEnum = 'Template'; -/** - * @public - */ -export type TemplateEntityV1beta3ApiVersionEnum = - 'scaffolder.backstage.io/v1beta3'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOf.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOf.model.ts deleted file mode 100644 index acc9f8c991..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOf.model.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { TemplateEntityV1beta3AllOfSpec } from '../models/TemplateEntityV1beta3AllOfSpec.model'; - -/** - * @public - */ -export interface TemplateEntityV1beta3AllOf { - /** - * The apiVersion string of the TaskSpec. - */ - apiVersion: TemplateEntityV1beta3AllOfApiVersionEnum; - /** - * The kind of the entity - */ - kind: TemplateEntityV1beta3AllOfKindEnum; - spec: TemplateEntityV1beta3AllOfSpec; -} - -/** - * @public - */ -export type TemplateEntityV1beta3AllOfApiVersionEnum = - 'scaffolder.backstage.io/v1beta3'; -/** - * @public - */ -export type TemplateEntityV1beta3AllOfKindEnum = 'Template'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpec.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpec.model.ts deleted file mode 100644 index 3fa0063e08..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpec.model.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { TemplateEntityStepV1beta3 } from '../models/TemplateEntityStepV1beta3.model'; -import { TemplateEntityV1beta3AllOfSpecParameters } from '../models/TemplateEntityV1beta3AllOfSpecParameters.model'; -import { TemplatePresentationV1beta3 } from '../models/TemplatePresentationV1beta3.model'; - -/** - * The specification of the Template Entity - * @public - */ -export interface TemplateEntityV1beta3AllOfSpec { - [key: string]: any; - - /** - * The type that the Template will create. For example service, website or library. - */ - type: string; - presentation?: TemplatePresentationV1beta3; - parameters?: TemplateEntityV1beta3AllOfSpecParameters; - /** - * A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying javascript action and some optional input parameters that may or may not have been collected from the end user. - */ - steps: Array; - /** - * The output is an object where template authors can pull out information from template actions and return them in a known standard way. - */ - output?: { [key: string]: string }; - /** - * The owner entityRef of the TemplateEntity - */ - owner?: string; -} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpecParameters.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpecParameters.model.ts deleted file mode 100644 index 1444a74e19..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpecParameters.model.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.model'; - -/** - * This is a JSONSchema or an array of JSONSchema's which is used to render a form in the frontend to collect user input and validate it against that schema. This can then be used in the `steps` part below to template variables passed from the user into each action in the template. - * @public - */ -export type TemplateEntityV1beta3AllOfSpecParameters = - | Array - | TemplateParametersV1beta3; 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 index aab495d098..20e9e5c121 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts @@ -18,7 +18,6 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { TemplateParameterSchemaStepsInner } from '../models/TemplateParameterSchemaStepsInner.model'; -import { TemplatePresentationV1beta3 } from '../models/TemplatePresentationV1beta3.model'; /** * The shape of each entry of parameters which gets rendered as a separate step in the wizard input @@ -28,7 +27,6 @@ export interface TemplateParameterSchema { [key: string]: any; title: string; - presentation?: TemplatePresentationV1beta3; description?: string; steps: Array; } 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 index 2f170b6fc6..43da448f7f 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts @@ -18,7 +18,6 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { JsonValue } from '../models/JsonValue.model'; -import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.model'; /** * @public @@ -26,5 +25,5 @@ import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.m export interface TemplateParameterSchemaStepsInner { title: JsonValue; description?: JsonValue; - schema: TemplateParametersV1beta3; + schema: any; } diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParametersV1beta3.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParametersV1beta3.model.ts deleted file mode 100644 index e106f9a1de..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateParametersV1beta3.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Parameter that is part of a Template Entity. - * @public - */ -export interface TemplateParametersV1beta3 {} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePresentationV1beta3.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePresentationV1beta3.model.ts deleted file mode 100644 index 83405f15aa..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePresentationV1beta3.model.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { TemplatePresentationV1beta3ButtonLabels } from '../models/TemplatePresentationV1beta3ButtonLabels.model'; - -/** - * The presentation of the template. - * @public - */ -export interface TemplatePresentationV1beta3 { - [key: string]: any; - - buttonLabels?: TemplatePresentationV1beta3ButtonLabels; -} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePresentationV1beta3ButtonLabels.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePresentationV1beta3ButtonLabels.model.ts deleted file mode 100644 index 37015a5468..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePresentationV1beta3ButtonLabels.model.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Overrides default buttons' text - * @public - */ -export interface TemplatePresentationV1beta3ButtonLabels { - /** - * The text for the button which leads to the previous template page - */ - backButtonText?: string; - /** - * The text for the button which starts the execution of the template - */ - createButtonText?: string; - /** - * The text for the button which opens template's review/summary - */ - reviewButtonText?: string; -} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateRecoveryV1beta3.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateRecoveryV1beta3.model.ts deleted file mode 100644 index 3613718ac0..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateRecoveryV1beta3.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Depends on how you designed your task you might tailor the behaviour for each of them. - * @public - */ -export interface TemplateRecoveryV1beta3 {} 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 index e37d3b4af9..a7c30935df 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationError.model.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationError.model.ts @@ -18,16 +18,16 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { ValidationErrorPathInner } from '../models/ValidationErrorPathInner.model'; -import { ValidationErrorSchema } from '../models/ValidationErrorSchema.model'; /** * @public */ export interface ValidationError { + [key: string]: any; + path: Array; property: string; message: string; - schema: ValidationErrorSchema; instance: any; name: string; argument: any; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorSchema.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorSchema.model.ts deleted file mode 100644 index 851b031d8d..0000000000 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ValidationErrorSchema.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { Schema } from '../models/Schema.model'; - -/** - * @public - */ -export type ValidationErrorSchema = Schema | string; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts index 598c41822b..41a96e63ae 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts @@ -25,11 +25,12 @@ export * from '../models/DryRun200Response.model'; export * from '../models/DryRun200ResponseAllOf.model'; export * from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model'; export * from '../models/DryRun200ResponseAllOfStepsInner.model'; -export * from '../models/DryRun200ResponseAllOfStepsInnerAllOf.model'; export * from '../models/DryRunRequest.model'; export * from '../models/DryRunRequestDirectoryContentsInner.model'; export * from '../models/DryRunResult.model'; export * from '../models/DryRunResultLogInner.model'; +export * from '../models/DryRunResultLogInnerBody.model'; +export * from '../models/DryRunResultLogInnerBodyAllOf.model'; export * from '../models/Entity.model'; export * from '../models/EntityLink.model'; export * from '../models/EntityMeta.model'; @@ -45,40 +46,19 @@ export * from '../models/RetryRequest.model'; export * from '../models/Scaffold201Response.model'; export * from '../models/Scaffold400Response.model'; export * from '../models/ScaffolderScaffoldOptions.model'; -export * from '../models/Schema.model'; -export * from '../models/SchemaAdditionalItems.model'; -export * from '../models/SchemaDependenciesValue.model'; -export * from '../models/SchemaExclusiveMaximum.model'; -export * from '../models/SchemaItems.model'; -export * from '../models/SchemaRequired.model'; -export * from '../models/SchemaType.model'; export * from '../models/SerializedFile.model'; export * from '../models/SerializedTask.model'; export * from '../models/SerializedTaskEvent.model'; export * from '../models/TaskEventType.model'; export * from '../models/TaskRecoverStrategy.model'; export * from '../models/TaskSecrets.model'; -export * from '../models/TaskSpecV1beta3.model'; -export * from '../models/TaskSpecV1beta3User.model'; +export * from '../models/TaskSecretsAllOf.model'; export * from '../models/TaskStatus.model'; export * from '../models/TaskStep.model'; export * from '../models/TaskStepEach.model'; -export * from '../models/TemplateEntityStepV1beta3.model'; -export * from '../models/TemplateEntityStepV1beta3AllOf.model'; -export * from '../models/TemplateEntityV1beta3.model'; -export * from '../models/TemplateEntityV1beta3AllOf.model'; -export * from '../models/TemplateEntityV1beta3AllOfSpec.model'; -export * from '../models/TemplateEntityV1beta3AllOfSpecParameters.model'; export * from '../models/TemplateInfo.model'; export * from '../models/TemplateInfoEntity.model'; export * from '../models/TemplateParameterSchema.model'; export * from '../models/TemplateParameterSchemaStepsInner.model'; -export * from '../models/TemplateParametersV1beta3.model'; -export * from '../models/TemplatePermissionsV1beta3.model'; -export * from '../models/TemplatePermissionsV1beta3AllOf.model'; -export * from '../models/TemplatePresentationV1beta3.model'; -export * from '../models/TemplatePresentationV1beta3ButtonLabels.model'; -export * from '../models/TemplateRecoveryV1beta3.model'; export * from '../models/ValidationError.model'; export * from '../models/ValidationErrorPathInner.model'; -export * from '../models/ValidationErrorSchema.model'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts index 531561a61b..1a94e60653 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts @@ -49,13 +49,17 @@ export const spec = { required: false, allowReserved: true, schema: { - type: 'string', + type: 'array', + items: { + type: 'string', + }, }, }, eventsAfter: { name: 'after', in: 'query', description: 'Offset event ID to stream events after.', + required: false, schema: { type: 'integer', }, @@ -76,8 +80,11 @@ export const spec = { required: false, allowReserved: true, schema: { - type: 'integer', - minimum: 0, + type: 'array', + items: { + type: 'integer', + minimum: 0, + }, }, }, namespace: { @@ -105,8 +112,11 @@ export const spec = { required: false, allowReserved: true, schema: { - type: 'integer', - minimum: 0, + type: 'array', + items: { + type: 'integer', + minimum: 0, + }, }, }, order: { @@ -116,8 +126,10 @@ export const spec = { required: false, allowReserved: true, schema: { - type: 'string', - enum: ['asc', 'desc'], + type: 'array', + items: { + type: 'string', + }, }, }, status: { @@ -127,7 +139,10 @@ export const spec = { required: false, allowReserved: true, schema: { - type: 'string', + type: 'array', + items: { + type: 'string', + }, }, }, taskId: { @@ -207,9 +222,29 @@ export const spec = { type: 'object', properties: { body: { - $ref: '#/components/schemas/JsonObject', + allOf: [ + { + $ref: '#/components/schemas/JsonObject', + }, + { + type: 'object', + properties: { + message: { + type: 'string', + }, + status: { + $ref: '#/components/schemas/TaskStatus', + }, + stepId: { + type: 'string', + }, + }, + required: ['message'], + }, + ], }, }, + required: ['body'], }, }, directoryContents: { @@ -428,6 +463,7 @@ export const spec = { type: 'string', }, { + type: 'object', nullable: true, }, ], @@ -488,9 +524,7 @@ export const spec = { }, values: { type: 'object', - additionalProperties: { - $ref: '#/components/schemas/JsonValue', - }, + additionalProperties: {}, }, secrets: { type: 'object', @@ -503,194 +537,6 @@ export const spec = { description: 'The input options to the `scaffold` method of the `ScaffolderClient`.', }, - Schema: { - type: 'object', - properties: { - id: { - type: 'string', - }, - title: { - type: 'string', - }, - description: { - type: 'string', - }, - multipleOf: { - type: 'number', - }, - maximum: { - type: 'number', - }, - exclusiveMaximum: { - oneOf: [ - { - type: 'number', - }, - { - type: 'boolean', - }, - ], - }, - minimum: { - type: 'number', - }, - exclusiveMinimum: { - oneOf: [ - { - type: 'number', - }, - { - type: 'boolean', - }, - ], - }, - maxLength: { - type: 'integer', - }, - minLength: { - type: 'integer', - }, - pattern: { - type: 'object', - }, - additionalItems: { - oneOf: [ - { - type: 'boolean', - }, - { - $ref: '#/components/schemas/Schema', - }, - ], - }, - items: { - oneOf: [ - { - $ref: '#/components/schemas/Schema', - }, - { - type: 'array', - items: { - $ref: '#/components/schemas/Schema', - }, - }, - ], - }, - maxItems: { - type: 'integer', - }, - minItems: { - type: 'integer', - }, - uniqueItems: { - type: 'boolean', - }, - maxProperties: { - type: 'integer', - }, - minProperties: { - type: 'integer', - }, - required: { - oneOf: [ - { - type: 'array', - items: { - type: 'string', - }, - }, - { - type: 'boolean', - }, - ], - }, - additionalProperties: { - oneOf: [ - { - type: 'boolean', - }, - { - $ref: '#/components/schemas/Schema', - }, - ], - }, - definitions: { - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/Schema', - }, - }, - properties: { - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/Schema', - }, - }, - patternProperties: { - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/Schema', - }, - }, - dependencies: { - type: 'object', - additionalProperties: { - oneOf: [ - { - $ref: '#/components/schemas/Schema', - }, - { - type: 'array', - items: { - type: 'string', - }, - }, - ], - }, - }, - type: { - oneOf: [ - { - type: 'string', - }, - { - type: 'array', - items: { - type: 'string', - }, - }, - ], - }, - format: { - type: 'string', - }, - allOf: { - type: 'array', - items: { - $ref: '#/components/schemas/Schema', - }, - }, - anyOf: { - type: 'array', - items: { - $ref: '#/components/schemas/Schema', - }, - }, - oneOf: { - type: 'array', - items: { - $ref: '#/components/schemas/Schema', - }, - }, - not: { - $ref: '#/components/schemas/Schema', - }, - then: { - $ref: '#/components/schemas/Schema', - }, - }, - additionalProperties: {}, - }, SerializedFile: { type: 'object', properties: { @@ -723,7 +569,26 @@ export const spec = { type: 'string', }, body: { - $ref: '#/components/schemas/JsonObject', + 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', @@ -742,7 +607,7 @@ export const spec = { type: 'string', }, spec: { - $ref: '#/components/schemas/TaskSpec', + type: 'object', }, status: { $ref: '#/components/schemas/TaskStatus', @@ -769,15 +634,12 @@ export const spec = { TaskEventType: { type: 'string', description: 'TaskEventType', - enum: ['completion', 'log', 'cancelled', 'recovered'], + enum: ['cancelled', 'completion', 'log', 'recovered'], }, TaskRecovery: { type: 'object', description: "When task didn't have a chance to complete due to system restart you can define the strategy what to do with such tasks,\nby defining a strategy.\n\nBy default, it is none, what means to not recover but updating the status from 'processing' to 'failed'.", - additionalProperties: { - $ref: '#/components/schemas/TaskRecoverStrategy', - }, }, TaskRecoverStrategy: { type: 'string', @@ -786,78 +648,34 @@ export const spec = { enum: ['none', 'startOver'], }, TaskSecrets: { - type: 'object', - properties: { - backstageToken: { - type: 'string', - }, - }, - description: 'TaskSecrets', - additionalProperties: {}, - }, - TaskSpec: { - $ref: '#/components/schemas/TaskSpecV1beta3', - }, - TaskSpecV1beta3: { - type: 'object', - properties: { - apiVersion: { - type: 'string', - enum: ['scaffolder.backstage.io/v1beta3'], - description: 'The apiVersion string of the TaskSpec.', - }, - parameters: { - $ref: '#/components/schemas/JsonObject', - description: - 'This is a JSONSchema which is used to render a form in the frontend\nto collect user input and validate it against that schema. This can then be used in the `steps` part below to template\nvariables passed from the user into each action in the template.\n', - }, - steps: { - type: 'array', - items: { - $ref: '#/components/schemas/TaskStep', - }, - description: - 'A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying\njavascript action and some optional input parameters that may or may not have been collected from the end user.\n', - }, - output: { + allOf: [ + { type: 'object', additionalProperties: { - $ref: '#/components/schemas/JsonValue', + type: 'string', }, - description: - 'The output is an object where template authors can pull out information from template actions and return them in a known standard way.\n', }, - templateInfo: { - $ref: '#/components/schemas/TemplateInfo', - description: - 'Some information about the template that is stored on the task spec.', - }, - user: { + { type: 'object', properties: { - entity: { - type: 'object', - description: 'The decorated entity from the Catalog', - }, - ref: { + backstageToken: { type: 'string', - description: 'An entity ref for the author of the task', }, }, - description: - 'Some decoration of the author of the task that should be available in the context', }, - }, - required: ['apiVersion', 'parameters', 'steps', 'output'], - description: - 'A scaffolder task as stored in the database, generated from a v1beta3\napiVersion Template.', - additionalProperties: { - $ref: '#/components/schemas/TaskRecovery', - }, + ], + description: 'TaskSecrets', }, TaskStatus: { type: 'string', - enum: ['cancelled', 'completed', 'failed', 'open', 'processing'], + enum: [ + 'cancelled', + 'completed', + 'failed', + 'open', + 'processing', + 'skipped', + ], description: 'The status of each step of the Task', }, TaskStep: { @@ -897,111 +715,6 @@ export const spec = { 'An individual step of a scaffolder task, as stored in the database.', additionalProperties: {}, }, - TemplateEntityStepV1beta3: { - allOf: [ - { - $ref: '#/components/schemas/JsonObject', - }, - { - type: 'object', - properties: { - id: { - type: 'string', - }, - name: { - type: 'string', - }, - action: { - type: 'string', - }, - input: { - $ref: '#/components/schemas/JsonObject', - }, - }, - required: ['action'], - }, - ], - description: 'Step that is part of a Template Entity.', - additionalProperties: {}, - }, - TemplateEntityV1beta3: { - allOf: [ - { - $ref: '#/components/schemas/Entity', - }, - { - type: 'object', - properties: { - apiVersion: { - type: 'string', - enum: ['scaffolder.backstage.io/v1beta3'], - description: 'The apiVersion string of the TaskSpec.', - }, - kind: { - type: 'string', - enum: ['Template'], - description: 'The kind of the entity', - }, - spec: { - type: 'object', - properties: { - type: { - type: 'string', - description: - 'The type that the Template will create. For example service, website or library.', - }, - presentation: { - $ref: '#/components/schemas/TemplatePresentationV1beta3', - description: - 'Template specific configuration of the presentation layer.', - }, - parameters: { - oneOf: [ - { - $ref: '#/components/schemas/TemplateParametersV1beta3', - }, - { - type: 'array', - items: { - $ref: '#/components/schemas/TemplateParametersV1beta3', - }, - }, - ], - description: - "This is a JSONSchema or an array of JSONSchema's which is used to render a form in the frontend\nto collect user input and validate it against that schema. This can then be used in the `steps` part below to template\nvariables passed from the user into each action in the template.", - }, - steps: { - type: 'array', - items: { - $ref: '#/components/schemas/TemplateEntityStepV1beta3', - }, - description: - 'A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying\njavascript action and some optional input parameters that may or may not have been collected from the end user.', - }, - output: { - type: 'object', - additionalProperties: { - type: 'string', - }, - description: - 'The output is an object where template authors can pull out information from template actions and return them in a known standard way.', - }, - owner: { - type: 'string', - description: 'The owner entityRef of the TemplateEntity', - }, - }, - required: ['type', 'steps'], - description: 'The specification of the Template Entity', - additionalProperties: {}, - }, - }, - required: ['apiVersion', 'kind', 'spec'], - }, - ], - description: - 'Backstage catalog Template kind Entity. Templates are used by the Scaffolder\nplugin to create new entities, such as Components.', - }, TemplateInfo: { type: 'object', properties: { @@ -1036,9 +749,6 @@ export const spec = { title: { type: 'string', }, - presentation: { - $ref: '#/components/schemas/TemplatePresentationV1beta3', - }, description: { type: 'string', }, @@ -1054,7 +764,7 @@ export const spec = { $ref: '#/components/schemas/JsonValue', }, schema: { - $ref: '#/components/schemas/TemplateParametersV1beta3', + type: 'object', }, }, required: ['title', 'schema'], @@ -1066,86 +776,6 @@ export const spec = { 'The shape of each entry of parameters which gets rendered\nas a separate step in the wizard input', additionalProperties: {}, }, - TemplateParametersV1beta3: { - allOf: [ - { - $ref: '#/components/schemas/JsonObject', - }, - { - type: 'object', - additionalProperties: { - $ref: '#/components/schemas/TemplatePermissionsV1beta3', - }, - }, - ], - description: 'Parameter that is part of a Template Entity.', - }, - TemplatePermissionsV1beta3: { - allOf: [ - { - $ref: '#/components/schemas/JsonObject', - }, - { - type: 'object', - properties: { - tags: { - type: 'array', - items: { - type: 'string', - }, - }, - }, - }, - ], - description: 'Access control properties for parts of a template.', - }, - TemplatePresentationV1beta3: { - type: 'object', - properties: { - buttonLabels: { - type: 'object', - properties: { - backButtonText: { - type: 'string', - description: - 'The text for the button which leads to the previous template page', - }, - createButtonText: { - type: 'string', - description: - 'The text for the button which starts the execution of the template', - }, - reviewButtonText: { - type: 'string', - description: - "The text for the button which opens template's review/summary", - }, - }, - description: "Overrides default buttons' text", - additionalProperties: false, - }, - }, - description: 'The presentation of the template.', - additionalProperties: {}, - }, - TemplateRecoveryV1beta3: { - allOf: [ - { - $ref: '#/components/schemas/JsonObject', - }, - { - type: 'object', - additionalProperties: { - type: 'string', - enum: ['none', 'startOver'], - description: - 'none - not recover, let the task be marked as failed\nstartOver - do recover, start the execution of the task from the first step.', - }, - }, - ], - description: - 'Depends on how you designed your task you might tailor the behaviour for each of them.', - }, ValidationError: { type: 'object', properties: { @@ -1168,16 +798,6 @@ export const spec = { message: { type: 'string', }, - schema: { - oneOf: [ - { - type: 'string', - }, - { - $ref: '#/components/schemas/Schema', - }, - ], - }, instance: { type: 'object', }, @@ -1201,6 +821,7 @@ export const spec = { 'argument', 'stack', ], + additionalProperties: {}, }, }, securitySchemes: { @@ -1345,6 +966,7 @@ export const spec = { type: 'string', }, }, + required: ['id'], }, }, }, @@ -1476,6 +1098,7 @@ export const spec = { type: 'string', }, }, + required: ['id'], }, }, }, @@ -1561,13 +1184,16 @@ export const spec = { type: 'object', properties: { template: { - $ref: '#/components/schemas/TemplateEntityV1beta3', + type: 'object', }, values: { - type: 'object', + $ref: '#/components/schemas/JsonObject', }, secrets: { type: 'object', + additionalProperties: { + type: 'string', + }, }, directoryContents: { type: 'array', @@ -1605,23 +1231,20 @@ export const spec = { steps: { type: 'array', items: { - allOf: [ - { - $ref: '#/components/schemas/TemplateEntityStepV1beta3', + type: 'object', + properties: { + id: { + type: 'string', }, - { - type: 'object', - properties: { - id: { - type: 'string', - }, - name: { - type: 'string', - }, - }, - required: ['id', 'name'], + name: { + type: 'string', }, - ], + action: { + type: 'string', + }, + }, + required: ['id', 'name', 'action'], + additionalProperties: {}, }, }, directoryContents: { @@ -1643,6 +1266,7 @@ export const spec = { }, }, }, + required: ['steps'], }, ], }, @@ -1715,10 +1339,15 @@ export const spec = { title: { type: 'string', }, + id: { + type: 'string', + }, }, + required: ['id'], }, }, }, + required: ['results'], }, }, }, diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/apis/Api.client.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/apis/Api.client.ts index 87a2cc94eb..ef188b6a4d 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/apis/Api.client.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/apis/Api.client.ts @@ -104,11 +104,11 @@ export type ListActions = {}; */ export type ListTasks = { query: { - createdBy?: string; - limit?: number; - offset?: number; - order?: 'asc' | 'desc'; - status?: string; + createdBy?: Array; + limit?: Array; + offset?: Array; + order?: Array; + status?: Array; }; }; /** @@ -339,7 +339,7 @@ export class DefaultApiClient { ): Promise> { const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); - const uriTemplate = `/v2/tasks{?createdBy,limit,offset,order,status}`; + const uriTemplate = `/v2/tasks{?createdBy*,limit*,offset*,order*,status*}`; const uri = parser.parse(uriTemplate).expand({ ...request.query, diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Autocomplete200Response.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Autocomplete200Response.model.ts index cad9a0dd29..b104dcbcc2 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Autocomplete200Response.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Autocomplete200Response.model.ts @@ -23,5 +23,5 @@ import { Autocomplete200ResponseResultsInner } from '../models/Autocomplete200Re * @public */ export interface Autocomplete200Response { - results?: Array; + results: Array; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts index bc8ea23cbb..68e8a77723 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Autocomplete200ResponseResultsInner.model.ts @@ -23,4 +23,5 @@ */ export interface Autocomplete200ResponseResultsInner { title?: string; + id: string; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200Response.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200Response.model.ts index 92b8d723a0..963b71135f 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200Response.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200Response.model.ts @@ -31,5 +31,5 @@ export interface DryRun200Response { * A type representing all allowed JSON object values. */ output: { [key: string]: any }; - steps?: Array; + steps: Array; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts index 553c6f765a..85d99f90cf 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOf.model.ts @@ -24,6 +24,6 @@ import { DryRun200ResponseAllOfStepsInner } from '../models/DryRun200ResponseAll * @public */ export interface DryRun200ResponseAllOf { - steps?: Array; + steps: Array; directoryContents?: Array; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts index 229860f81a..5a2c0639db 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInner.model.ts @@ -22,11 +22,9 @@ * @public */ export interface DryRun200ResponseAllOfStepsInner { + [key: string]: any; + id: string; name: string; action: string; - /** - * A type representing all allowed JSON object values. - */ - input?: { [key: string]: any }; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunRequest.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunRequest.model.ts index 510e7fa353..c9f10fd0b0 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunRequest.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunRequest.model.ts @@ -18,14 +18,16 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { DryRunRequestDirectoryContentsInner } from '../models/DryRunRequestDirectoryContentsInner.model'; -import { TemplateEntityV1beta3 } from '../models/TemplateEntityV1beta3.model'; /** * @public */ export interface DryRunRequest { - template: TemplateEntityV1beta3; - values: any; - secrets?: any; + template: any; + /** + * A type representing all allowed JSON object values. + */ + values: { [key: string]: any }; + secrets?: { [key: string]: string }; directoryContents: Array; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts index 0f987091c0..f0da311b91 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInner.model.ts @@ -17,13 +17,11 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** +import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model'; /** * @public */ export interface DryRunResultLogInner { - /** - * A type representing all allowed JSON object values. - */ - body?: { [key: string]: any }; + body: DryRunResultLogInnerBody; } diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePermissionsV1beta3.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts similarity index 83% rename from plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePermissionsV1beta3.model.ts rename to plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts index 68c2df70a8..a675d4b1ae 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplatePermissionsV1beta3.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInnerBody.model.ts @@ -17,11 +17,13 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; /** - * Access control properties for parts of a template. * @public */ -export interface TemplatePermissionsV1beta3 { - tags?: Array; +export interface DryRunResultLogInnerBody { + message: string; + status?: TaskStatus; + stepId?: string; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInnerAllOf.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts similarity index 83% rename from plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInnerAllOf.model.ts rename to plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts index 6416143493..665213a954 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRun200ResponseAllOfStepsInnerAllOf.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/DryRunResultLogInnerBodyAllOf.model.ts @@ -17,11 +17,13 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** +import { TaskStatus } from '../models/TaskStatus.model'; /** * @public */ -export interface DryRun200ResponseAllOfStepsInnerAllOf { - id: string; - name: string; +export interface DryRunResultLogInnerBodyAllOf { + message: string; + status?: TaskStatus; + stepId?: string; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Scaffold201Response.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Scaffold201Response.model.ts index 9ff2cc8494..8c0185ca58 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Scaffold201Response.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Scaffold201Response.model.ts @@ -22,5 +22,5 @@ * @public */ export interface Scaffold201Response { - id?: string; + id: string; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts index 68b9927966..d02f776ebc 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ScaffolderScaffoldOptions.model.ts @@ -17,7 +17,6 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** -import { JsonValue } from '../models/JsonValue.model'; /** * The input options to the `scaffold` method of the `ScaffolderClient`. @@ -25,6 +24,6 @@ import { JsonValue } from '../models/JsonValue.model'; */ export interface ScaffolderScaffoldOptions { templateRef: string; - values: { [key: string]: JsonValue }; + values: { [key: string]: any }; secrets?: { [key: string]: string }; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Schema.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Schema.model.ts deleted file mode 100644 index 0e24d46c30..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/Schema.model.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { SchemaAdditionalItems } from '../models/SchemaAdditionalItems.model'; -import { SchemaDependenciesValue } from '../models/SchemaDependenciesValue.model'; -import { SchemaExclusiveMaximum } from '../models/SchemaExclusiveMaximum.model'; -import { SchemaItems } from '../models/SchemaItems.model'; -import { SchemaRequired } from '../models/SchemaRequired.model'; -import { SchemaType } from '../models/SchemaType.model'; - -/** - * @public - */ -export interface Schema { - [key: string]: any; - - id?: string; - title?: string; - description?: string; - multipleOf?: number; - maximum?: number; - exclusiveMaximum?: SchemaExclusiveMaximum; - minimum?: number; - exclusiveMinimum?: SchemaExclusiveMaximum; - maxLength?: number; - minLength?: number; - pattern?: any; - additionalItems?: SchemaAdditionalItems; - items?: SchemaItems; - maxItems?: number; - minItems?: number; - uniqueItems?: boolean; - maxProperties?: number; - minProperties?: number; - required?: SchemaRequired; - additionalProperties?: SchemaAdditionalItems; - definitions?: { [key: string]: Schema }; - properties?: { [key: string]: Schema }; - patternProperties?: { [key: string]: Schema }; - dependencies?: { [key: string]: SchemaDependenciesValue }; - type?: SchemaType; - format?: string; - allOf?: Array; - anyOf?: Array; - oneOf?: Array; - not?: Schema; - then?: Schema; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaAdditionalItems.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaAdditionalItems.model.ts deleted file mode 100644 index 2039e2f9bb..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaAdditionalItems.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { Schema } from '../models/Schema.model'; - -/** - * @public - */ -export type SchemaAdditionalItems = Schema | boolean; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaDependenciesValue.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaDependenciesValue.model.ts deleted file mode 100644 index 97609dda50..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaDependenciesValue.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { Schema } from '../models/Schema.model'; - -/** - * @public - */ -export type SchemaDependenciesValue = Array | Schema; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaItems.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaItems.model.ts deleted file mode 100644 index c63c6700aa..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaItems.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { Schema } from '../models/Schema.model'; - -/** - * @public - */ -export type SchemaItems = Array | Schema; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaRequired.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaRequired.model.ts deleted file mode 100644 index b1b879cb3b..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaRequired.model.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * @public - */ -export type SchemaRequired = Array | boolean; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaType.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaType.model.ts deleted file mode 100644 index dd0cbb93db..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SchemaType.model.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * @public - */ -export type SchemaType = Array | string; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SerializedTask.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SerializedTask.model.ts index 7ba1196cab..f661fe07c7 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SerializedTask.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SerializedTask.model.ts @@ -18,7 +18,6 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { TaskSecrets } from '../models/TaskSecrets.model'; -import { TaskSpecV1beta3 } from '../models/TaskSpecV1beta3.model'; import { TaskStatus } from '../models/TaskStatus.model'; /** @@ -27,7 +26,7 @@ import { TaskStatus } from '../models/TaskStatus.model'; */ export interface SerializedTask { id: string; - spec: TaskSpecV1beta3; + spec: any; status: TaskStatus; createdAt: string; lastHeartbeatAt?: string; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts index 484688e324..cc75de3a0f 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/SerializedTaskEvent.model.ts @@ -17,6 +17,7 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** +import { DryRunResultLogInnerBody } from '../models/DryRunResultLogInnerBody.model'; import { TaskEventType } from '../models/TaskEventType.model'; /** @@ -27,10 +28,7 @@ export interface SerializedTaskEvent { id: number; isTaskRecoverable?: boolean; taskId: string; - /** - * A type representing all allowed JSON object values. - */ - body: { [key: string]: any }; + body: DryRunResultLogInnerBody; type: TaskEventType; createdAt: string; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskEventType.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskEventType.model.ts index 8531d19de8..dd3d36d64e 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskEventType.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskEventType.model.ts @@ -21,14 +21,14 @@ /** * @public */ -export type TaskEventType = 'completion' | 'log' | 'cancelled' | 'recovered'; +export type TaskEventType = 'cancelled' | 'completion' | 'log' | 'recovered'; /** * @public */ export const TaskEventType = { + Cancelled: 'cancelled' as TaskEventType, Completion: 'completion' as TaskEventType, Log: 'log' as TaskEventType, - Cancelled: 'cancelled' as TaskEventType, Recovered: 'recovered' as TaskEventType, }; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSecrets.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSecrets.model.ts index ae7c6a891c..74da6527a4 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSecrets.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSecrets.model.ts @@ -23,7 +23,5 @@ * @public */ export interface TaskSecrets { - [key: string]: any; - backstageToken?: string; } diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaExclusiveMaximum.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts similarity index 92% rename from plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaExclusiveMaximum.model.ts rename to plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts index c22a44e80b..7c1e5d2e9e 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/SchemaExclusiveMaximum.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSecretsAllOf.model.ts @@ -21,4 +21,6 @@ /** * @public */ -export type SchemaExclusiveMaximum = boolean | number; +export interface TaskSecretsAllOf { + backstageToken?: string; +} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSpecV1beta3.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSpecV1beta3.model.ts deleted file mode 100644 index bb32940062..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSpecV1beta3.model.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { JsonValue } from '../models/JsonValue.model'; -import { TaskSpecV1beta3User } from '../models/TaskSpecV1beta3User.model'; -import { TaskStep } from '../models/TaskStep.model'; -import { TemplateInfo } from '../models/TemplateInfo.model'; - -/** - * A scaffolder task as stored in the database, generated from a v1beta3 apiVersion Template. - * @public - */ -export interface TaskSpecV1beta3 { - [key: string]: any; - - /** - * The apiVersion string of the TaskSpec. - */ - apiVersion: TaskSpecV1beta3ApiVersionEnum; - /** - * A type representing all allowed JSON object values. - */ - parameters: { [key: string]: any }; - /** - * A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying javascript action and some optional input parameters that may or may not have been collected from the end user. - */ - steps: Array; - /** - * The output is an object where template authors can pull out information from template actions and return them in a known standard way. - */ - output: { [key: string]: JsonValue }; - templateInfo?: TemplateInfo; - user?: TaskSpecV1beta3User; -} - -/** - * @public - */ -export type TaskSpecV1beta3ApiVersionEnum = 'scaffolder.backstage.io/v1beta3'; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSpecV1beta3User.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSpecV1beta3User.model.ts deleted file mode 100644 index a47b103213..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskSpecV1beta3User.model.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Some decoration of the author of the task that should be available in the context - * @public - */ -export interface TaskSpecV1beta3User { - /** - * The decorated entity from the Catalog - */ - entity?: any; - /** - * An entity ref for the author of the task - */ - ref?: string; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskStatus.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskStatus.model.ts index 42f8137fb3..622aa758c0 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskStatus.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TaskStatus.model.ts @@ -26,7 +26,8 @@ export type TaskStatus = | 'completed' | 'failed' | 'open' - | 'processing'; + | 'processing' + | 'skipped'; /** * @public @@ -37,4 +38,5 @@ export const TaskStatus = { Failed: 'failed' as TaskStatus, Open: 'open' as TaskStatus, Processing: 'processing' as TaskStatus, + Skipped: 'skipped' as TaskStatus, }; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityStepV1beta3.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityStepV1beta3.model.ts deleted file mode 100644 index e125c46f1d..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityStepV1beta3.model.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Step that is part of a Template Entity. - * @public - */ -export interface TemplateEntityStepV1beta3 { - [key: string]: any; - - id?: string; - name?: string; - action: string; - /** - * A type representing all allowed JSON object values. - */ - input?: { [key: string]: any }; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityStepV1beta3AllOf.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityStepV1beta3AllOf.model.ts deleted file mode 100644 index dfba72bf8d..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityStepV1beta3AllOf.model.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * @public - */ -export interface TemplateEntityStepV1beta3AllOf { - id?: string; - name?: string; - action: string; - /** - * A type representing all allowed JSON object values. - */ - input?: { [key: string]: any }; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3.model.ts deleted file mode 100644 index efe325cfeb..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3.model.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { EntityMeta } from '../models/EntityMeta.model'; -import { EntityRelation } from '../models/EntityRelation.model'; -import { TemplateEntityV1beta3AllOfSpec } from '../models/TemplateEntityV1beta3AllOfSpec.model'; - -/** - * Backstage catalog Template kind Entity. Templates are used by the Scaffolder plugin to create new entities, such as Components. - * @public - */ -export interface TemplateEntityV1beta3 { - /** - * The relations that this entity has with other entities. - */ - relations?: Array; - spec: TemplateEntityV1beta3AllOfSpec; - metadata: EntityMeta; - /** - * The kind of the entity - */ - kind: TemplateEntityV1beta3KindEnum; - /** - * The apiVersion string of the TaskSpec. - */ - apiVersion: TemplateEntityV1beta3ApiVersionEnum; -} - -/** - * @public - */ -export type TemplateEntityV1beta3KindEnum = 'Template'; -/** - * @public - */ -export type TemplateEntityV1beta3ApiVersionEnum = - 'scaffolder.backstage.io/v1beta3'; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOf.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOf.model.ts deleted file mode 100644 index acc9f8c991..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOf.model.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { TemplateEntityV1beta3AllOfSpec } from '../models/TemplateEntityV1beta3AllOfSpec.model'; - -/** - * @public - */ -export interface TemplateEntityV1beta3AllOf { - /** - * The apiVersion string of the TaskSpec. - */ - apiVersion: TemplateEntityV1beta3AllOfApiVersionEnum; - /** - * The kind of the entity - */ - kind: TemplateEntityV1beta3AllOfKindEnum; - spec: TemplateEntityV1beta3AllOfSpec; -} - -/** - * @public - */ -export type TemplateEntityV1beta3AllOfApiVersionEnum = - 'scaffolder.backstage.io/v1beta3'; -/** - * @public - */ -export type TemplateEntityV1beta3AllOfKindEnum = 'Template'; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpec.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpec.model.ts deleted file mode 100644 index 3fa0063e08..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpec.model.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { TemplateEntityStepV1beta3 } from '../models/TemplateEntityStepV1beta3.model'; -import { TemplateEntityV1beta3AllOfSpecParameters } from '../models/TemplateEntityV1beta3AllOfSpecParameters.model'; -import { TemplatePresentationV1beta3 } from '../models/TemplatePresentationV1beta3.model'; - -/** - * The specification of the Template Entity - * @public - */ -export interface TemplateEntityV1beta3AllOfSpec { - [key: string]: any; - - /** - * The type that the Template will create. For example service, website or library. - */ - type: string; - presentation?: TemplatePresentationV1beta3; - parameters?: TemplateEntityV1beta3AllOfSpecParameters; - /** - * A list of steps to be executed in sequence which are defined by the template. These steps are a list of the underlying javascript action and some optional input parameters that may or may not have been collected from the end user. - */ - steps: Array; - /** - * The output is an object where template authors can pull out information from template actions and return them in a known standard way. - */ - output?: { [key: string]: string }; - /** - * The owner entityRef of the TemplateEntity - */ - owner?: string; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpecParameters.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpecParameters.model.ts deleted file mode 100644 index 1444a74e19..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateEntityV1beta3AllOfSpecParameters.model.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.model'; - -/** - * This is a JSONSchema or an array of JSONSchema's which is used to render a form in the frontend to collect user input and validate it against that schema. This can then be used in the `steps` part below to template variables passed from the user into each action in the template. - * @public - */ -export type TemplateEntityV1beta3AllOfSpecParameters = - | Array - | TemplateParametersV1beta3; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts index aab495d098..20e9e5c121 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParameterSchema.model.ts @@ -18,7 +18,6 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { TemplateParameterSchemaStepsInner } from '../models/TemplateParameterSchemaStepsInner.model'; -import { TemplatePresentationV1beta3 } from '../models/TemplatePresentationV1beta3.model'; /** * The shape of each entry of parameters which gets rendered as a separate step in the wizard input @@ -28,7 +27,6 @@ export interface TemplateParameterSchema { [key: string]: any; title: string; - presentation?: TemplatePresentationV1beta3; description?: string; steps: Array; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts index 2f170b6fc6..43da448f7f 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParameterSchemaStepsInner.model.ts @@ -18,7 +18,6 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { JsonValue } from '../models/JsonValue.model'; -import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.model'; /** * @public @@ -26,5 +25,5 @@ import { TemplateParametersV1beta3 } from '../models/TemplateParametersV1beta3.m export interface TemplateParameterSchemaStepsInner { title: JsonValue; description?: JsonValue; - schema: TemplateParametersV1beta3; + schema: any; } diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParametersV1beta3.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParametersV1beta3.model.ts deleted file mode 100644 index e106f9a1de..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateParametersV1beta3.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Parameter that is part of a Template Entity. - * @public - */ -export interface TemplateParametersV1beta3 {} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePermissionsV1beta3.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePermissionsV1beta3.model.ts deleted file mode 100644 index 68c2df70a8..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePermissionsV1beta3.model.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Access control properties for parts of a template. - * @public - */ -export interface TemplatePermissionsV1beta3 { - tags?: Array; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePermissionsV1beta3AllOf.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePermissionsV1beta3AllOf.model.ts deleted file mode 100644 index c7eda5cd8a..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePermissionsV1beta3AllOf.model.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * @public - */ -export interface TemplatePermissionsV1beta3AllOf { - tags?: Array; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePresentationV1beta3.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePresentationV1beta3.model.ts deleted file mode 100644 index 83405f15aa..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePresentationV1beta3.model.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { TemplatePresentationV1beta3ButtonLabels } from '../models/TemplatePresentationV1beta3ButtonLabels.model'; - -/** - * The presentation of the template. - * @public - */ -export interface TemplatePresentationV1beta3 { - [key: string]: any; - - buttonLabels?: TemplatePresentationV1beta3ButtonLabels; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePresentationV1beta3ButtonLabels.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePresentationV1beta3ButtonLabels.model.ts deleted file mode 100644 index 37015a5468..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplatePresentationV1beta3ButtonLabels.model.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Overrides default buttons' text - * @public - */ -export interface TemplatePresentationV1beta3ButtonLabels { - /** - * The text for the button which leads to the previous template page - */ - backButtonText?: string; - /** - * The text for the button which starts the execution of the template - */ - createButtonText?: string; - /** - * The text for the button which opens template's review/summary - */ - reviewButtonText?: string; -} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateRecoveryV1beta3.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateRecoveryV1beta3.model.ts deleted file mode 100644 index 3613718ac0..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/TemplateRecoveryV1beta3.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** - -/** - * Depends on how you designed your task you might tailor the behaviour for each of them. - * @public - */ -export interface TemplateRecoveryV1beta3 {} diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ValidationError.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ValidationError.model.ts index e37d3b4af9..a7c30935df 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ValidationError.model.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ValidationError.model.ts @@ -18,16 +18,16 @@ // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** import { ValidationErrorPathInner } from '../models/ValidationErrorPathInner.model'; -import { ValidationErrorSchema } from '../models/ValidationErrorSchema.model'; /** * @public */ export interface ValidationError { + [key: string]: any; + path: Array; property: string; message: string; - schema: ValidationErrorSchema; instance: any; name: string; argument: any; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ValidationErrorSchema.model.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ValidationErrorSchema.model.ts deleted file mode 100644 index 851b031d8d..0000000000 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/ValidationErrorSchema.model.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2024 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ****************************************************************** -// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * -// ****************************************************************** -import { Schema } from '../models/Schema.model'; - -/** - * @public - */ -export type ValidationErrorSchema = Schema | string; diff --git a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/index.ts b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/index.ts index 598c41822b..41a96e63ae 100644 --- a/plugins/scaffolder-common/client/src/schema/openapi/generated/models/index.ts +++ b/plugins/scaffolder-common/client/src/schema/openapi/generated/models/index.ts @@ -25,11 +25,12 @@ export * from '../models/DryRun200Response.model'; export * from '../models/DryRun200ResponseAllOf.model'; export * from '../models/DryRun200ResponseAllOfDirectoryContentsInner.model'; export * from '../models/DryRun200ResponseAllOfStepsInner.model'; -export * from '../models/DryRun200ResponseAllOfStepsInnerAllOf.model'; export * from '../models/DryRunRequest.model'; export * from '../models/DryRunRequestDirectoryContentsInner.model'; export * from '../models/DryRunResult.model'; export * from '../models/DryRunResultLogInner.model'; +export * from '../models/DryRunResultLogInnerBody.model'; +export * from '../models/DryRunResultLogInnerBodyAllOf.model'; export * from '../models/Entity.model'; export * from '../models/EntityLink.model'; export * from '../models/EntityMeta.model'; @@ -45,40 +46,19 @@ export * from '../models/RetryRequest.model'; export * from '../models/Scaffold201Response.model'; export * from '../models/Scaffold400Response.model'; export * from '../models/ScaffolderScaffoldOptions.model'; -export * from '../models/Schema.model'; -export * from '../models/SchemaAdditionalItems.model'; -export * from '../models/SchemaDependenciesValue.model'; -export * from '../models/SchemaExclusiveMaximum.model'; -export * from '../models/SchemaItems.model'; -export * from '../models/SchemaRequired.model'; -export * from '../models/SchemaType.model'; export * from '../models/SerializedFile.model'; export * from '../models/SerializedTask.model'; export * from '../models/SerializedTaskEvent.model'; export * from '../models/TaskEventType.model'; export * from '../models/TaskRecoverStrategy.model'; export * from '../models/TaskSecrets.model'; -export * from '../models/TaskSpecV1beta3.model'; -export * from '../models/TaskSpecV1beta3User.model'; +export * from '../models/TaskSecretsAllOf.model'; export * from '../models/TaskStatus.model'; export * from '../models/TaskStep.model'; export * from '../models/TaskStepEach.model'; -export * from '../models/TemplateEntityStepV1beta3.model'; -export * from '../models/TemplateEntityStepV1beta3AllOf.model'; -export * from '../models/TemplateEntityV1beta3.model'; -export * from '../models/TemplateEntityV1beta3AllOf.model'; -export * from '../models/TemplateEntityV1beta3AllOfSpec.model'; -export * from '../models/TemplateEntityV1beta3AllOfSpecParameters.model'; export * from '../models/TemplateInfo.model'; export * from '../models/TemplateInfoEntity.model'; export * from '../models/TemplateParameterSchema.model'; export * from '../models/TemplateParameterSchemaStepsInner.model'; -export * from '../models/TemplateParametersV1beta3.model'; -export * from '../models/TemplatePermissionsV1beta3.model'; -export * from '../models/TemplatePermissionsV1beta3AllOf.model'; -export * from '../models/TemplatePresentationV1beta3.model'; -export * from '../models/TemplatePresentationV1beta3ButtonLabels.model'; -export * from '../models/TemplateRecoveryV1beta3.model'; export * from '../models/ValidationError.model'; export * from '../models/ValidationErrorPathInner.model'; -export * from '../models/ValidationErrorSchema.model'; diff --git a/plugins/scaffolder-common/package.json b/plugins/scaffolder-common/package.json index 50d695cdee..4fb33b8156 100644 --- a/plugins/scaffolder-common/package.json +++ b/plugins/scaffolder-common/package.json @@ -61,8 +61,15 @@ }, "dependencies": { "@backstage/catalog-model": "workspace:^", + "@backstage/core-plugin-api": "workspace:^", + "@backstage/errors": "workspace:^", + "@backstage/integration": "workspace:^", "@backstage/plugin-permission-common": "workspace:^", - "@backstage/types": "workspace:^" + "@backstage/types": "workspace:^", + "@microsoft/fetch-event-source": "^2.0.1", + "json-schema": "^0.4.0", + "qs": "^6.9.4", + "zen-observable": "^0.10.0" }, "devDependencies": { "@backstage/cli": "workspace:^", diff --git a/plugins/scaffolder-common/src/ScaffolderClient.ts b/plugins/scaffolder-common/src/ScaffolderClient.ts new file mode 100644 index 0000000000..44973ca569 --- /dev/null +++ b/plugins/scaffolder-common/src/ScaffolderClient.ts @@ -0,0 +1,430 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { parseEntityRef } from '@backstage/catalog-model'; +import { + DiscoveryApi, + FetchApi, + IdentityApi, +} from '@backstage/core-plugin-api'; +import { ResponseError } from '@backstage/errors'; +import { ScmIntegrationRegistry } from '@backstage/integration'; +import { Observable } from '@backstage/types'; +import { + EventSourceMessage, + fetchEventSource, +} from '@microsoft/fetch-event-source'; +import ObservableImpl from 'zen-observable'; + +import { type TemplateParameterSchema } from './TemplateEntityV1beta3'; +import { + ListActionsResponse, + ListTemplatingExtensionsResponse, + LogEvent, + ScaffolderApi, + ScaffolderDryRunOptions, + ScaffolderDryRunResponse, + ScaffolderGetIntegrationsListOptions, + ScaffolderGetIntegrationsListResponse, + ScaffolderRequestOptions, + ScaffolderScaffoldOptions, + ScaffolderScaffoldResponse, + ScaffolderStreamLogsOptions, + ScaffolderTask, +} from './api'; +import { + DefaultApiClient, + TaskStatus, + TypedResponse, +} from '../client/src/schema/openapi'; + +/** + * An API to interact with the scaffolder backend. + * + * @public + */ +export class ScaffolderClient implements ScaffolderApi { + private readonly apiClient: DefaultApiClient; + private readonly discoveryApi: DiscoveryApi; + private readonly scmIntegrationsApi: ScmIntegrationRegistry; + private readonly fetchApi: FetchApi; + private readonly identityApi?: IdentityApi; + private readonly useLongPollingLogs: boolean; + + constructor(options: { + discoveryApi: DiscoveryApi; + fetchApi: FetchApi; + identityApi?: IdentityApi; + scmIntegrationsApi: ScmIntegrationRegistry; + useLongPollingLogs?: boolean; + }) { + this.apiClient = new DefaultApiClient(options); + this.discoveryApi = options.discoveryApi; + this.fetchApi = options.fetchApi ?? { fetch }; + this.scmIntegrationsApi = options.scmIntegrationsApi; + this.useLongPollingLogs = options.useLongPollingLogs ?? false; + this.identityApi = options.identityApi; + } + + /** + * {@inheritdoc ScaffolderApi.listTasks} + */ + async listTasks( + request: { + filterByOwnership: 'owned' | 'all'; + limit?: number; + offset?: number; + }, + options?: ScaffolderRequestOptions, + ): Promise<{ tasks: ScaffolderTask[]; totalTasks?: number }> { + if (!this.identityApi) { + throw new Error( + 'IdentityApi is not available in the ScaffolderClient, please pass through the IdentityApi to the ScaffolderClient constructor in order to use the listTasks method', + ); + } + + const { userEntityRef } = await this.identityApi.getBackstageIdentity(); + + return await this.requestRequired( + await this.apiClient.listTasks( + { + query: { + createdBy: + request.filterByOwnership === 'owned' + ? [userEntityRef] + : undefined, + limit: request.limit ? [request.limit] : undefined, + offset: request.offset ? [request.offset] : undefined, + }, + }, + options, + ), + ); + } + + async getIntegrationsList( + options: ScaffolderGetIntegrationsListOptions, + ): Promise { + 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), + ); + } + + 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(); + } + + /** + * {@inheritdoc ScaffolderApi.cancelTask} + */ + async cancelTask( + taskId: string, + options?: ScaffolderRequestOptions, + ): Promise<{ status?: TaskStatus }> { + return await this.requestRequired( + await this.apiClient.cancelTask({ path: { taskId } }, options), + ); + } + + /** + * {@inheritdoc ScaffolderApi.retry} + */ + async retry?( + { + secrets, + taskId, + }: { + secrets?: Record; + taskId: string; + }, + options?: ScaffolderRequestOptions, + ): Promise<{ id: string }> { + return await this.requestRequired( + await this.apiClient.retry( + { body: { secrets }, path: { taskId } }, + options, + ), + ); + } + + /** + * {@inheritdoc ScaffolderApi.retry} + */ + async autocomplete({ + token, + resource, + provider, + context, + }: { + token: string; + provider: string; + resource: string; + context: Record; + }): 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..f9a5dbcb17 --- /dev/null +++ b/plugins/scaffolder-common/src/api.ts @@ -0,0 +1,362 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { JsonObject, JsonValue, Observable } from '@backstage/types'; +import { JSONSchema7 } from 'json-schema'; +import { TaskSpec, TaskStep } from './TaskSpec'; +import type { + TemplateEntityV1beta3, + TemplateParameterSchema, +} from './TemplateEntityV1beta3'; +import { TaskStatus } from '../client/src/schema/openapi'; + +/** + * Options you can pass into a Scaffolder request for additional information. + * + * @public + */ +export interface ScaffolderRequestOptions { + token?: string; +} + +/** + * The status of each task in a Scaffolder Job + * + * @public + */ +export type ScaffolderTaskStatus = + | 'cancelled' + | 'completed' + | 'failed' + | 'open' + | 'processing' + | 'skipped'; + +/** + * The shape of each task returned from the `scaffolder-backend` + * + * @public + */ +export type ScaffolderTask = { + id: string; + spec: TaskSpec; + status: ScaffolderTaskStatus; + lastHeartbeatAt?: string; + createdAt: string; +}; + +/** + * A single scaffolder usage example + * + * @public + */ +export type ScaffolderUsageExample = { + description?: string; + example: string; + notes?: string; +}; + +/** + * A single action example + * + * @public + * @deprecated in favor of ScaffolderUsageExample + */ +export type ActionExample = { + description: string; + example: string; +}; + +/** + * The response shape for a single action in the `listActions` call to the `scaffolder-backend` + * + * @public + */ +export type Action = { + id: string; + description?: string; + schema?: { + input?: JSONSchema7; + output?: JSONSchema7; + }; + examples?: ActionExample[]; +}; + +/** + * The response shape for the `listActions` call to the `scaffolder-backend` + * + * @public + */ +export type ListActionsResponse = Array; + +/** + * 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: 'log' | 'completion' | 'cancelled' | 'recovered'; + body: { + message: string; + stepId?: string; + status?: ScaffolderTaskStatus; + }; + createdAt: string; + id: number; + taskId: string; +}; + +/** + * The input options to the `scaffold` method of the `ScaffolderClient`. + * + * @public + */ +export interface ScaffolderScaffoldOptions { + templateRef: string; + values: Record; + 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?: TaskStatus }>; + + /** + * Starts the task again from the point where it failed. + * + * @param taskId - the id of the task + */ + retry?( + { + secrets, + taskId, + }: { + secrets?: Record; + 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-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/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..1b547762ef 100644 --- a/plugins/scaffolder/package.json +++ b/plugins/scaffolder/package.json @@ -63,9 +63,7 @@ "@backstage/core-compat-api": "workspace:^", "@backstage/core-components": "workspace:^", "@backstage/core-plugin-api": "workspace:^", - "@backstage/errors": "workspace:^", "@backstage/frontend-plugin-api": "workspace:^", - "@backstage/integration": "workspace:^", "@backstage/integration-react": "workspace:^", "@backstage/plugin-catalog-common": "workspace:^", "@backstage/plugin-catalog-react": "workspace:^", @@ -79,7 +77,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", @@ -90,17 +87,14 @@ "git-url-parse": "^15.0.0", "humanize-duration": "^3.25.1", "idb-keyval": "5.1.5", - "json-schema": "^0.4.0", "json-schema-library": "^9.0.0", "jszip": "^3.10.1", "lodash": "^4.17.21", "luxon": "^3.0.0", - "qs": "^6.9.4", "react-resizable": "^3.0.5", "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" }, 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/OngoingTask/OngoingTask.tsx b/plugins/scaffolder/src/components/OngoingTask/OngoingTask.tsx index bc0d5fe1aa..ce765abb01 100644 --- a/plugins/scaffolder/src/components/OngoingTask/OngoingTask.tsx +++ b/plugins/scaffolder/src/components/OngoingTask/OngoingTask.tsx @@ -223,7 +223,7 @@ function OngoingTaskContent(props: { const [, { execute: triggerRetry }] = useAsync(async () => { if (taskId) { analytics.captureEvent('retried', 'Template has been retried'); - await scaffolderApi.retry?.(taskId); + await scaffolderApi.retry?.({ taskId }); } }); 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; /**