diff --git a/.changeset/scaffolder-breakages-3.md b/.changeset/scaffolder-breakages-3.md new file mode 100644 index 0000000000..f6dca6416f --- /dev/null +++ b/.changeset/scaffolder-breakages-3.md @@ -0,0 +1,11 @@ +--- +'@backstage/plugin-scaffolder-backend': major +--- + +**BREAKING CHANGES** + +The following functions have been re-exported from the `scaffolder-backend` plugin for quite some time, and now it's time to clean them up. They've been moved as follows: + +- `SerializedTask`, `SerializedTaskEvent`, `TaskBroker`, `TaskBrokerDispatchOptions`, `TaskBrokerDispatchResult`, `TaskCompletionState`, `TaskContext`, `TaskEventType`, `TaskStatus`, `TemplateFilter`, and `TemplateGlobal` should be imported from `@backstage/plugin-scaffolder-node` instead. + +- The deprecated `copyWithoutRender` option has been removed from `fetch:template` action. You should rename the option to `copyWithoutTemplating` instead. diff --git a/.changeset/scaffolder-deprecations-1.md b/.changeset/scaffolder-deprecations-1.md new file mode 100644 index 0000000000..7d87013536 --- /dev/null +++ b/.changeset/scaffolder-deprecations-1.md @@ -0,0 +1,20 @@ +--- +'@backstage/plugin-scaffolder-backend': minor +--- + +**DEPRECATIONS** + +The following types and implementations have been deprecated, either because they're no longer relevant, or because upcoming changes to the `scaffolder-backend` after `2.0.0` will influence the changes to these API surfaces. + +- `CreateWorkerOptions` +- `DatabaseTaskStore` +- `DatabaseTaskStoreOptions` +- `TaskManager` +- `TaskStoreCreateTaskOptions` +- `TaskStoreCreateTaskResult` +- `TaskStoreEmitOptions` +- `TaskStoreListEventsOptions` +- `TaskStoreRecoverTaskOptions` +- `TaskStoreShutDownTaskOptions` + +There is no current path off deprecation, these types are going to be removed and rethought with a better way to define workers in the new backend system. diff --git a/plugins/scaffolder-backend/report.api.md b/plugins/scaffolder-backend/report.api.md index 769403df9a..edfddb9a27 100644 --- a/plugins/scaffolder-backend/report.api.md +++ b/plugins/scaffolder-backend/report.api.md @@ -23,23 +23,20 @@ import { PermissionRuleParams } from '@backstage/plugin-permission-common'; import { RESOURCE_TYPE_SCAFFOLDER_ACTION } from '@backstage/plugin-scaffolder-common/alpha'; import { RESOURCE_TYPE_SCAFFOLDER_TEMPLATE } from '@backstage/plugin-scaffolder-common/alpha'; import { ScmIntegrations } from '@backstage/integration'; -import { SerializedTask as SerializedTask_2 } from '@backstage/plugin-scaffolder-node'; -import { SerializedTaskEvent as SerializedTaskEvent_2 } from '@backstage/plugin-scaffolder-node'; -import { TaskBroker as TaskBroker_2 } from '@backstage/plugin-scaffolder-node'; -import { TaskBrokerDispatchOptions as TaskBrokerDispatchOptions_2 } from '@backstage/plugin-scaffolder-node'; -import { TaskBrokerDispatchResult as TaskBrokerDispatchResult_2 } from '@backstage/plugin-scaffolder-node'; -import { TaskCompletionState as TaskCompletionState_2 } from '@backstage/plugin-scaffolder-node'; -import { TaskContext as TaskContext_2 } from '@backstage/plugin-scaffolder-node'; -import { TaskEventType as TaskEventType_2 } from '@backstage/plugin-scaffolder-node'; +import { SerializedTask } from '@backstage/plugin-scaffolder-node'; +import { SerializedTaskEvent } from '@backstage/plugin-scaffolder-node'; +import { TaskBroker } from '@backstage/plugin-scaffolder-node'; +import { TaskCompletionState } from '@backstage/plugin-scaffolder-node'; +import { TaskContext } from '@backstage/plugin-scaffolder-node'; import { TaskRecovery } from '@backstage/plugin-scaffolder-common'; import { TaskSecrets } from '@backstage/plugin-scaffolder-node'; import { TaskSpec } from '@backstage/plugin-scaffolder-common'; import { TaskSpecV1beta3 } from '@backstage/plugin-scaffolder-common'; -import { TaskStatus as TaskStatus_2 } from '@backstage/plugin-scaffolder-node'; +import { TaskStatus } from '@backstage/plugin-scaffolder-node'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; import { TemplateEntityStepV1beta3 } from '@backstage/plugin-scaffolder-common'; -import { TemplateFilter as TemplateFilter_2 } from '@backstage/plugin-scaffolder-node'; -import { TemplateGlobal as TemplateGlobal_2 } from '@backstage/plugin-scaffolder-node'; +import { TemplateFilter } from '@backstage/plugin-scaffolder-node'; +import { TemplateGlobal } from '@backstage/plugin-scaffolder-node'; import { TemplateParametersV1beta3 } from '@backstage/plugin-scaffolder-common'; import { UrlReaderService } from '@backstage/backend-plugin-api'; import { WorkspaceProvider } from '@backstage/plugin-scaffolder-node/alpha'; @@ -61,9 +58,9 @@ export const createBuiltinActions: ( // @public export interface CreateBuiltInActionsOptions { - additionalTemplateFilters?: Record; + additionalTemplateFilters?: Record; // (undocumented) - additionalTemplateGlobals?: Record; + additionalTemplateGlobals?: Record; auth?: AuthService; catalogClient: CatalogApi; config: Config; @@ -154,15 +151,14 @@ export function createFetchPlainFileAction(options: { export function createFetchTemplateAction(options: { reader: UrlReaderService; integrations: ScmIntegrations; - additionalTemplateFilters?: Record; - additionalTemplateGlobals?: Record; + additionalTemplateFilters?: Record; + additionalTemplateGlobals?: Record; }): TemplateAction< { url: string; targetPath?: string; values: any; templateFileExtension?: string | boolean; - copyWithoutRender?: string[]; copyWithoutTemplating?: string[]; cookiecutterCompat?: boolean; replace?: boolean; @@ -178,8 +174,8 @@ export function createFetchTemplateAction(options: { export function createFetchTemplateFileAction(options: { reader: UrlReaderService; integrations: ScmIntegrations; - additionalTemplateFilters?: Record; - additionalTemplateGlobals?: Record; + additionalTemplateFilters?: Record; + additionalTemplateGlobals?: Record; }): TemplateAction< { url: string; @@ -243,17 +239,17 @@ export function createWaitAction(options?: { maxWaitTime?: Duration | HumanDuration; }): TemplateAction; -// @public +// @public @deprecated export type CreateWorkerOptions = { - taskBroker: TaskBroker_2; + taskBroker: TaskBroker; actionRegistry: TemplateActionRegistry; integrations: ScmIntegrations; workingDirectory: string; logger: Logger; auditor?: AuditorService; - additionalTemplateFilters?: Record; + additionalTemplateFilters?: Record; concurrentTasksLimit?: number; - additionalTemplateGlobals?: Record; + additionalTemplateGlobals?: Record; permissions?: PermissionEvaluator; gracefulShutdown?: boolean; }; @@ -268,7 +264,7 @@ export interface CurrentClaimedTask { workspace?: Promise; } -// @public +// @public @deprecated export class DatabaseTaskStore implements TaskStore { // (undocumented) cancelTask( @@ -279,13 +275,13 @@ export class DatabaseTaskStore implements TaskStore { >, ): Promise; // (undocumented) - claimTask(): Promise; + claimTask(): Promise; // (undocumented) cleanWorkspace({ taskId }: { taskId: string }): Promise; // (undocumented) completeTask(options: { taskId: string; - status: TaskStatus_2; + status: TaskStatus; eventBody: JsonObject; }): Promise; // (undocumented) @@ -303,7 +299,7 @@ export class DatabaseTaskStore implements TaskStore { >, ): Promise; // (undocumented) - getTask(taskId: string): Promise; + getTask(taskId: string): Promise; // (undocumented) getTaskState({ taskId }: { taskId: string }): Promise< | { @@ -316,10 +312,10 @@ export class DatabaseTaskStore implements TaskStore { // (undocumented) list(options: { createdBy?: string; - status?: TaskStatus_2; + status?: TaskStatus; filters?: { createdBy?: string | string[]; - status?: TaskStatus_2 | TaskStatus_2[]; + status?: TaskStatus | TaskStatus[]; }; pagination?: { limit?: number; @@ -330,12 +326,12 @@ export class DatabaseTaskStore implements TaskStore { field: string; }[]; }): Promise<{ - tasks: SerializedTask_2[]; + tasks: SerializedTask[]; totalTasks?: number; }>; // (undocumented) listEvents(options: TaskStoreListEventsOptions): Promise<{ - events: SerializedTaskEvent_2[]; + events: SerializedTaskEvent[]; }>; // (undocumented) listStaleTasks(options: { timeoutS: number }): Promise<{ @@ -363,7 +359,7 @@ export class DatabaseTaskStore implements TaskStore { shutdownTask(options: TaskStoreShutDownTaskOptions): Promise; } -// @public +// @public @deprecated export type DatabaseTaskStoreOptions = { database: DatabaseService | Knex; events?: EventsService; @@ -374,37 +370,13 @@ const scaffolderPlugin: BackendFeature; export default scaffolderPlugin; // @public @deprecated -export type SerializedTask = SerializedTask_2; - -// @public @deprecated -export type SerializedTaskEvent = SerializedTaskEvent_2; - -// @public @deprecated -export type TaskBroker = TaskBroker_2; - -// @public @deprecated -export type TaskBrokerDispatchOptions = TaskBrokerDispatchOptions_2; - -// @public @deprecated -export type TaskBrokerDispatchResult = TaskBrokerDispatchResult_2; - -// @public @deprecated -export type TaskCompletionState = TaskCompletionState_2; - -// @public @deprecated -export type TaskContext = TaskContext_2; - -// @public @deprecated -export type TaskEventType = TaskEventType_2; - -// @public -export class TaskManager implements TaskContext_2 { +export class TaskManager implements TaskContext { // (undocumented) get cancelSignal(): AbortSignal; // (undocumented) cleanWorkspace?(): Promise; // (undocumented) - complete(result: TaskCompletionState_2, metadata?: JsonObject): Promise; + complete(result: TaskCompletionState, metadata?: JsonObject): Promise; // (undocumented) static create( task: CurrentClaimedTask, @@ -460,9 +432,6 @@ export class TaskManager implements TaskContext_2 { } // @public @deprecated -export type TaskStatus = TaskStatus_2; - -// @public export interface TaskStore { // (undocumented) cancelTask?(options: TaskStoreEmitOptions): Promise; @@ -569,42 +538,42 @@ export interface TaskStore { shutdownTask?(options: TaskStoreShutDownTaskOptions): Promise; } -// @public +// @public @deprecated export type TaskStoreCreateTaskOptions = { spec: TaskSpec; createdBy?: string; secrets?: TaskSecrets; }; -// @public +// @public @deprecated export type TaskStoreCreateTaskResult = { taskId: string; }; -// @public +// @public @deprecated export type TaskStoreEmitOptions = { taskId: string; body: TBody; }; -// @public +// @public @deprecated export type TaskStoreListEventsOptions = { isTaskRecoverable?: boolean; taskId: string; after?: number | undefined; }; -// @public +// @public @deprecated export type TaskStoreRecoverTaskOptions = { timeout: HumanDuration; }; -// @public +// @public @deprecated export type TaskStoreShutDownTaskOptions = { taskId: string; }; -// @public +// @public @deprecated export class TaskWorker { // (undocumented) static create(options: CreateWorkerOptions): Promise; @@ -613,14 +582,14 @@ export class TaskWorker { // (undocumented) recoverTasks(): Promise; // (undocumented) - runOneTask(task: TaskContext_2): Promise; + runOneTask(task: TaskContext): Promise; // (undocumented) start(): void; // (undocumented) stop(): Promise; } -// @public +// @public @deprecated export class TemplateActionRegistry { // (undocumented) get(actionId: string): TemplateAction; @@ -630,12 +599,6 @@ export class TemplateActionRegistry { register(action: TemplateAction): void; } -// @public @deprecated (undocumented) -export type TemplateFilter = TemplateFilter_2; - -// @public @deprecated (undocumented) -export type TemplateGlobal = TemplateGlobal_2; - // @public (undocumented) export type TemplatePermissionRuleInput< TParams extends PermissionRuleParams = PermissionRuleParams, diff --git a/plugins/scaffolder-backend/src/index.ts b/plugins/scaffolder-backend/src/index.ts index e7f2de94a9..4273ed8197 100644 --- a/plugins/scaffolder-backend/src/index.ts +++ b/plugins/scaffolder-backend/src/index.ts @@ -22,7 +22,6 @@ export { scaffolderPlugin as default } from './ScaffolderPlugin'; export * from './scaffolder'; -export * from './lib'; export { type TemplatePermissionRuleInput, type ActionPermissionRuleInput, diff --git a/plugins/scaffolder-backend/src/lib/index.ts b/plugins/scaffolder-backend/src/lib/index.ts deleted file mode 100644 index 20096f9c03..0000000000 --- a/plugins/scaffolder-backend/src/lib/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2022 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export * from './templating'; diff --git a/plugins/scaffolder-backend/src/lib/templating/SecureTemplater.ts b/plugins/scaffolder-backend/src/lib/templating/SecureTemplater.ts index fea04c0c1c..709cb1308d 100644 --- a/plugins/scaffolder-backend/src/lib/templating/SecureTemplater.ts +++ b/plugins/scaffolder-backend/src/lib/templating/SecureTemplater.ts @@ -17,8 +17,8 @@ import { Isolate } from 'isolated-vm'; import { resolvePackagePath } from '@backstage/backend-plugin-api'; import { - TemplateFilter as _TemplateFilter, - TemplateGlobal as _TemplateGlobal, + TemplateFilter, + TemplateGlobal, } from '@backstage/plugin-scaffolder-node'; import fs from 'fs-extra'; import { JsonValue } from '@backstage/types'; @@ -96,18 +96,6 @@ const { render, renderCompat } = (() => { })(); `; -/** - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TemplateFilter = _TemplateFilter; - -/** - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TemplateGlobal = _TemplateGlobal; - interface SecureTemplaterOptions { /* Enables jinja compatibility and the "jsonify" filter */ cookiecutterCompat?: boolean; diff --git a/plugins/scaffolder-backend/src/lib/templating/index.ts b/plugins/scaffolder-backend/src/lib/templating/index.ts deleted file mode 100644 index 1f9e5eb855..0000000000 --- a/plugins/scaffolder-backend/src/lib/templating/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2022 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export type { TemplateFilter, TemplateGlobal } from './SecureTemplater'; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/TemplateActionRegistry.ts b/plugins/scaffolder-backend/src/scaffolder/actions/TemplateActionRegistry.ts index 11d6234083..c819d4c21f 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/TemplateActionRegistry.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/TemplateActionRegistry.ts @@ -19,6 +19,7 @@ import { TemplateAction } from '@backstage/plugin-scaffolder-node'; /** * Registry of all registered template actions. * @public + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. */ export class TemplateActionRegistry { private readonly actions = new Map(); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts index 61918e8450..6494e562d2 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.test.ts @@ -98,42 +98,6 @@ describe('fetch:template', () => { ); }); - it('throws if copyWithoutRender parameter is not an array', async () => { - await expect(() => - action.handler( - mockContext({ copyWithoutRender: 'abc' as unknown as string[] }), - ), - ).rejects.toThrow( - /copyWithoutRender\/copyWithoutTemplating must be an array/i, - ); - }); - - it('throws if both copyWithoutRender and copyWithoutTemplating are used', async () => { - await expect(() => - action.handler( - mockContext({ - copyWithoutRender: 'abc' as unknown as string[], - copyWithoutTemplating: 'def' as unknown as string[], - }), - ), - ).rejects.toThrow( - /copyWithoutRender and copyWithoutTemplating can not be used at the same time/i, - ); - }); - - it('throws if copyWithoutRender is used with extension', async () => { - await expect(() => - action.handler( - mockContext({ - copyWithoutRender: ['abc'], - templateFileExtension: true, - }), - ), - ).rejects.toThrow( - /input extension incompatible with copyWithoutRender\/copyWithoutTemplating and cookiecutterCompat/, - ); - }); - it('throws if cookiecutterCompat is used with extension', async () => { await expect(() => action.handler( @@ -143,7 +107,7 @@ describe('fetch:template', () => { }), ), ).rejects.toThrow( - /input extension incompatible with copyWithoutRender\/copyWithoutTemplating and cookiecutterCompat/, + /input extension incompatible with copyWithoutTemplating and cookiecutterCompat/, ); }); @@ -378,55 +342,6 @@ describe('fetch:template', () => { }); }); - describe('copyWithoutRender', () => { - let context: ActionContext; - - beforeEach(async () => { - context = mockContext({ - values: { - name: 'test-project', - count: 1234, - }, - copyWithoutRender: ['.unprocessed'], - }); - - mockFetchContents.mockImplementation(({ outputPath }) => { - mockDir.setContent({ - [outputPath]: { - processed: { - 'templated-content-${{ values.name }}.txt': '${{ values.count }}', - }, - '.unprocessed': { - 'templated-content-${{ values.name }}.txt': '${{ values.count }}', - }, - }, - }); - - return Promise.resolve(); - }); - - await action.handler(context); - }); - - it('ignores template syntax in files matched in copyWithoutRender', async () => { - await expect( - fs.readFile( - `${workspacePath}/target/.unprocessed/templated-content-\${{ values.name }}.txt`, - 'utf-8', - ), - ).resolves.toEqual('${{ values.count }}'); - }); - - it('processes files not matched in copyWithoutRender', async () => { - await expect( - fs.readFile( - `${workspacePath}/target/processed/templated-content-test-project.txt`, - 'utf-8', - ), - ).resolves.toEqual('1234'); - }); - }); - describe('copyWithoutTemplating', () => { let context: ActionContext; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts index 4a80cd208d..3b8ca6f227 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/template.ts @@ -48,10 +48,6 @@ export function createFetchTemplateAction(options: { templateFileExtension?: string | boolean; // Cookiecutter compat options - /** - * @deprecated This field is deprecated in favor of copyWithoutTemplating. - */ - copyWithoutRender?: string[]; copyWithoutTemplating?: string[]; cookiecutterCompat?: boolean; replace?: boolean; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/templateActionHandler.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/templateActionHandler.ts index f280841bfa..e436616651 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/templateActionHandler.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/templateActionHandler.ts @@ -36,12 +36,6 @@ export type TemplateActionInput = { targetPath?: string; values: any; templateFileExtension?: string | boolean; - - // Cookiecutter compat options - /** - * @deprecated This field is deprecated in favor of copyWithoutTemplating. - */ - copyWithoutRender?: string[]; copyWithoutTemplating?: string[]; cookiecutterCompat?: boolean; replace?: boolean; @@ -206,26 +200,12 @@ function resolveTemplateActionSettings( const targetPath = ctx.input.targetPath ?? './'; const outputDir = resolveSafeChildPath(ctx.workspacePath, targetPath); - if (ctx.input.copyWithoutRender && ctx.input.copyWithoutTemplating) { - throw new InputError( - 'Fetch action input copyWithoutRender and copyWithoutTemplating can not be used at the same time', - ); - } - let copyOnlyPatterns: string[] | undefined; - let renderFilename: boolean; - if (ctx.input.copyWithoutRender) { - ctx.logger.warn( - '[Deprecated] copyWithoutRender is deprecated Please use copyWithoutTemplating instead.', - ); - copyOnlyPatterns = ctx.input.copyWithoutRender; - renderFilename = false; - } else { - copyOnlyPatterns = ctx.input.copyWithoutTemplating; - renderFilename = true; - } + const copyOnlyPatterns = ctx.input.copyWithoutTemplating; + const renderFilename = true; + if (copyOnlyPatterns && !Array.isArray(copyOnlyPatterns)) { throw new InputError( - 'Fetch action input copyWithoutRender/copyWithoutTemplating must be an Array', + 'Fetch action input copyWithoutTemplating must be an Array', ); } if ( @@ -233,7 +213,7 @@ function resolveTemplateActionSettings( (copyOnlyPatterns || ctx.input.cookiecutterCompat) ) { throw new InputError( - 'Fetch action input extension incompatible with copyWithoutRender/copyWithoutTemplating and cookiecutterCompat', + 'Fetch action input extension incompatible with copyWithoutTemplating and cookiecutterCompat', ); } let extension: string | false = false; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/workspaceTemplate.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/workspaceTemplate.test.ts index 92b17aa2c9..2a9b4ef68e 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/workspaceTemplate.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/fetch/workspaceTemplate.test.ts @@ -92,7 +92,7 @@ describe('workspace:template', () => { }), ), ).rejects.toThrow( - /input extension incompatible with copyWithoutRender\/copyWithoutTemplating and cookiecutterCompat/, + /input extension incompatible with copyWithoutTemplating and cookiecutterCompat/, ); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts index 51a30a20ec..f81a79a5a0 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/DatabaseTaskStore.ts @@ -76,7 +76,7 @@ export type RawDbTaskEventRow = { /** * DatabaseTaskStore - * + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. * @public */ export type DatabaseTaskStoreOptions = { @@ -86,9 +86,7 @@ export type DatabaseTaskStoreOptions = { /** * Type guard to help DatabaseTaskStore understand when database is DatabaseService vs. when database is a Knex instance. - * - * * @public - */ + * */ function isDatabaseService( opt: DatabaseService | Knex, ): opt is DatabaseService { @@ -111,7 +109,7 @@ const parseSqlDateToIsoString = (input: T): T | string => { /** * DatabaseTaskStore - * + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. * @public */ export class DatabaseTaskStore implements TaskStore { diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/StorageTaskBroker.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/StorageTaskBroker.ts index 27a4499772..7c7b3e6ac3 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/StorageTaskBroker.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/StorageTaskBroker.ts @@ -59,7 +59,7 @@ type TaskState = { }; /** * TaskManager - * + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. * @public */ export class TaskManager implements TaskContext { diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts index 4441a2f0ca..10fa5d4245 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts @@ -33,7 +33,7 @@ import { setTimeout } from 'timers/promises'; /** * TaskWorkerOptions - * + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. * @public */ export type TaskWorkerOptions = { @@ -50,7 +50,7 @@ export type TaskWorkerOptions = { /** * CreateWorkerOptions - * + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. * @public */ export type CreateWorkerOptions = { @@ -81,7 +81,7 @@ export type CreateWorkerOptions = { /** * TaskWorker - * + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. * @public */ export class TaskWorker { diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/index.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/index.ts index 9d231d7e7c..265151d73b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/index.ts @@ -21,19 +21,10 @@ export type { CurrentClaimedTask } from './StorageTaskBroker'; export { TaskWorker } from './TaskWorker'; export type { CreateWorkerOptions } from './TaskWorker'; export type { - TaskCompletionState, TaskStoreEmitOptions, TaskStoreListEventsOptions, TaskStoreShutDownTaskOptions, - SerializedTask, - SerializedTaskEvent, - TaskStatus, - TaskEventType, - TaskBroker, - TaskContext, TaskStore, - TaskBrokerDispatchResult, - TaskBrokerDispatchOptions, TaskStoreCreateTaskOptions, TaskStoreRecoverTaskOptions, TaskStoreCreateTaskResult, diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/types.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/types.ts index 1556c4838c..a3d9e3b741 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/types.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/types.ts @@ -17,96 +17,19 @@ import { HumanDuration, JsonObject, JsonValue } from '@backstage/types'; import { TaskSpec, TaskStep } from '@backstage/plugin-scaffolder-common'; import { - SerializedTask as _SerializedTask, - SerializedTaskEvent as _SerializedTaskEvent, - TaskBroker as _TaskBroker, - TaskBrokerDispatchOptions as _TaskBrokerDispatchOptions, - TaskBrokerDispatchResult as _TaskBrokerDispatchResult, - TaskCompletionState as _TaskCompletionState, - TaskContext as _TaskContext, - TaskEventType as _TaskEventType, TaskSecrets, - TaskStatus as _TaskStatus, TemplateAction, + TaskContext, + SerializedTaskEvent, + SerializedTask, + TaskStatus, } from '@backstage/plugin-scaffolder-node'; -/** - * The status of each step of the Task - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TaskStatus = _TaskStatus; - -/** - * The state of a completed task. - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TaskCompletionState = _TaskCompletionState; - -/** - * SerializedTask - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type SerializedTask = _SerializedTask; - -/** - * TaskEventType - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TaskEventType = _TaskEventType; - -/** - * SerializedTaskEvent - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type SerializedTaskEvent = _SerializedTaskEvent; - -/** - * The result of `TaskBroker.dispatch`. - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TaskBrokerDispatchResult = _TaskBrokerDispatchResult; - -/** - * The options passed to `TaskBroker.dispatch`. - * Currently a spec and optional secrets - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TaskBrokerDispatchOptions = _TaskBrokerDispatchOptions; - -/** - * Task - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TaskContext = _TaskContext; - -/** - * TaskBroker - * - * @public - * @deprecated Import from `@backstage/plugin-scaffolder-node` instead. - */ -export type TaskBroker = _TaskBroker; - /** * TaskStoreEmitOptions * * @public + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. */ export type TaskStoreEmitOptions = { taskId: string; @@ -117,6 +40,7 @@ export type TaskStoreEmitOptions = { * TaskStoreListEventsOptions * * @public + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. */ export type TaskStoreListEventsOptions = { isTaskRecoverable?: boolean; @@ -128,6 +52,7 @@ export type TaskStoreListEventsOptions = { * TaskStoreShutDownTaskOptions * * @public + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. */ export type TaskStoreShutDownTaskOptions = { taskId: string; @@ -136,6 +61,7 @@ export type TaskStoreShutDownTaskOptions = { /** * The options passed to {@link TaskStore.createTask} * @public + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. */ export type TaskStoreCreateTaskOptions = { spec: TaskSpec; @@ -146,6 +72,7 @@ export type TaskStoreCreateTaskOptions = { /** * The options passed to {@link TaskStore.recoverTasks} * @public + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. */ export type TaskStoreRecoverTaskOptions = { timeout: HumanDuration; @@ -154,6 +81,7 @@ export type TaskStoreRecoverTaskOptions = { /** * The response from {@link TaskStore.createTask} * @public + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. */ export type TaskStoreCreateTaskResult = { taskId: string; @@ -163,6 +91,7 @@ export type TaskStoreCreateTaskResult = { * TaskStore * * @public + * @deprecated this type is deprecated, and there will be a new way to create Workers in the next major version. */ export interface TaskStore { cancelTask?(options: TaskStoreEmitOptions): Promise;