scaffolder-backend: move more types to -node
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Deprecated the following type exports, which have been moved to `@backstage/plugin-scaffolder-node` instead:
|
||||
|
||||
- `TemplateFilter`
|
||||
- `TemplateGlobal`
|
||||
- `TaskStatus`
|
||||
- `TaskCompletionState`
|
||||
- `SerializedTask`
|
||||
- `TaskEventType`
|
||||
- `SerializedTaskEvent`
|
||||
- `TaskBrokerDispatchResult`
|
||||
- `TaskBrokerDispatchOptions`
|
||||
- `TaskContext`
|
||||
- `TaskBroker`
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-node': patch
|
||||
---
|
||||
|
||||
Added several new types that were moved from `@backstage/plugin-scaffolder-backend`.
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
import { Isolate } from 'isolated-vm';
|
||||
import { resolvePackagePath } from '@backstage/backend-common';
|
||||
import {
|
||||
TemplateFilter as _TemplateFilter,
|
||||
TemplateGlobal as _TemplateGlobal,
|
||||
} from '@backstage/plugin-scaffolder-node';
|
||||
import fs from 'fs-extra';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
|
||||
@@ -86,13 +90,17 @@ const { render, renderCompat } = (() => {
|
||||
})();
|
||||
`;
|
||||
|
||||
/** @public */
|
||||
export type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
|
||||
/**
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export type TemplateFilter = _TemplateFilter;
|
||||
|
||||
/** @public */
|
||||
export type TemplateGlobal =
|
||||
| ((...args: JsonValue[]) => JsonValue | undefined)
|
||||
| JsonValue;
|
||||
/**
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export type TemplateGlobal = _TemplateGlobal;
|
||||
|
||||
export interface SecureTemplaterOptions {
|
||||
/* Enables jinja compatibility and the "jsonify" filter */
|
||||
|
||||
@@ -14,131 +14,94 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { JsonValue, JsonObject, Observable } from '@backstage/types';
|
||||
import { JsonValue, JsonObject } from '@backstage/types';
|
||||
import { TaskSpec, TaskStep } from '@backstage/plugin-scaffolder-common';
|
||||
import { TaskSecrets } from '@backstage/plugin-scaffolder-node';
|
||||
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
import {
|
||||
TemplateAction,
|
||||
TaskStatus as _TaskStatus,
|
||||
TaskCompletionState as _TaskCompletionState,
|
||||
SerializedTask as _SerializedTask,
|
||||
TaskEventType as _TaskEventType,
|
||||
SerializedTaskEvent as _SerializedTaskEvent,
|
||||
TaskBrokerDispatchResult as _TaskBrokerDispatchResult,
|
||||
TaskBrokerDispatchOptions as _TaskBrokerDispatchOptions,
|
||||
TaskContext as _TaskContext,
|
||||
TaskBroker as _TaskBroker,
|
||||
} 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 =
|
||||
| 'cancelled'
|
||||
| 'completed'
|
||||
| 'failed'
|
||||
| 'open'
|
||||
| 'processing';
|
||||
export type TaskStatus = _TaskStatus;
|
||||
|
||||
/**
|
||||
* The state of a completed task.
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export type TaskCompletionState = 'failed' | 'completed';
|
||||
export type TaskCompletionState = _TaskCompletionState;
|
||||
|
||||
/**
|
||||
* SerializedTask
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export type SerializedTask = {
|
||||
id: string;
|
||||
spec: TaskSpec;
|
||||
status: TaskStatus;
|
||||
createdAt: string;
|
||||
lastHeartbeatAt?: string;
|
||||
createdBy?: string;
|
||||
secrets?: TaskSecrets;
|
||||
};
|
||||
export type SerializedTask = _SerializedTask;
|
||||
|
||||
/**
|
||||
* TaskEventType
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export type TaskEventType = 'completion' | 'log' | 'cancelled';
|
||||
export type TaskEventType = _TaskEventType;
|
||||
|
||||
/**
|
||||
* SerializedTaskEvent
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export type SerializedTaskEvent = {
|
||||
id: number;
|
||||
taskId: string;
|
||||
body: JsonObject;
|
||||
type: TaskEventType;
|
||||
createdAt: string;
|
||||
};
|
||||
export type SerializedTaskEvent = _SerializedTaskEvent;
|
||||
|
||||
/**
|
||||
* The result of {@link TaskBroker.dispatch}
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export type TaskBrokerDispatchResult = {
|
||||
taskId: string;
|
||||
};
|
||||
export type TaskBrokerDispatchResult = _TaskBrokerDispatchResult;
|
||||
|
||||
/**
|
||||
* The options passed to {@link TaskBroker.dispatch}
|
||||
* Currently a spec and optional secrets
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export type TaskBrokerDispatchOptions = {
|
||||
spec: TaskSpec;
|
||||
secrets?: TaskSecrets;
|
||||
createdBy?: string;
|
||||
};
|
||||
export type TaskBrokerDispatchOptions = _TaskBrokerDispatchOptions;
|
||||
|
||||
/**
|
||||
* Task
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export interface TaskContext {
|
||||
cancelSignal: AbortSignal;
|
||||
spec: TaskSpec;
|
||||
secrets?: TaskSecrets;
|
||||
createdBy?: string;
|
||||
done: boolean;
|
||||
isDryRun?: boolean;
|
||||
|
||||
complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
|
||||
|
||||
emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
|
||||
|
||||
getWorkspaceName(): Promise<string>;
|
||||
}
|
||||
export type TaskContext = _TaskContext;
|
||||
|
||||
/**
|
||||
* TaskBroker
|
||||
*
|
||||
* @public
|
||||
* @deprecated Import from `@backstage/plugin-scaffolder-node` instead.
|
||||
*/
|
||||
export interface TaskBroker {
|
||||
cancel?(taskId: string): Promise<void>;
|
||||
|
||||
claim(): Promise<TaskContext>;
|
||||
|
||||
dispatch(
|
||||
options: TaskBrokerDispatchOptions,
|
||||
): Promise<TaskBrokerDispatchResult>;
|
||||
|
||||
vacuumTasks(options: { timeoutS: number }): Promise<void>;
|
||||
|
||||
event$(options: {
|
||||
taskId: string;
|
||||
after: number | undefined;
|
||||
}): Observable<{ events: SerializedTaskEvent[] }>;
|
||||
|
||||
get(taskId: string): Promise<SerializedTask>;
|
||||
|
||||
list?(options?: { createdBy?: string }): Promise<{ tasks: SerializedTask[] }>;
|
||||
}
|
||||
export type TaskBroker = _TaskBroker;
|
||||
|
||||
/**
|
||||
* TaskStoreEmitOptions
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
export * from './actions';
|
||||
export * from './tasks';
|
||||
export type { TemplateFilter, TemplateGlobal } from './types';
|
||||
export {
|
||||
scaffolderActionsExtensionPoint,
|
||||
type ScaffolderActionsExtensionPoint,
|
||||
|
||||
@@ -14,4 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { type TaskSecrets } from './types';
|
||||
export type {
|
||||
TaskSecrets,
|
||||
SerializedTask,
|
||||
SerializedTaskEvent,
|
||||
TaskBroker,
|
||||
TaskBrokerDispatchOptions,
|
||||
TaskBrokerDispatchResult,
|
||||
TaskCompletionState,
|
||||
TaskContext,
|
||||
TaskEventType,
|
||||
TaskStatus,
|
||||
} from './types';
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TaskSpec } from '@backstage/plugin-scaffolder-common';
|
||||
import { JsonObject, Observable } from '@backstage/types';
|
||||
|
||||
/**
|
||||
* TaskSecrets
|
||||
*
|
||||
@@ -22,3 +25,124 @@
|
||||
export type TaskSecrets = Record<string, string> & {
|
||||
backstageToken?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The status of each step of the Task
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TaskStatus =
|
||||
| 'cancelled'
|
||||
| 'completed'
|
||||
| 'failed'
|
||||
| 'open'
|
||||
| 'processing';
|
||||
|
||||
/**
|
||||
* The state of a completed task.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TaskCompletionState = 'failed' | 'completed';
|
||||
|
||||
/**
|
||||
* SerializedTask
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type SerializedTask = {
|
||||
id: string;
|
||||
spec: TaskSpec;
|
||||
status: TaskStatus;
|
||||
createdAt: string;
|
||||
lastHeartbeatAt?: string;
|
||||
createdBy?: string;
|
||||
secrets?: TaskSecrets;
|
||||
};
|
||||
|
||||
/**
|
||||
* TaskEventType
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TaskEventType = 'completion' | 'log' | 'cancelled';
|
||||
|
||||
/**
|
||||
* SerializedTaskEvent
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type SerializedTaskEvent = {
|
||||
id: number;
|
||||
taskId: string;
|
||||
body: JsonObject;
|
||||
type: TaskEventType;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The result of {@link TaskBroker.dispatch}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TaskBrokerDispatchResult = {
|
||||
taskId: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The options passed to {@link TaskBroker.dispatch}
|
||||
* Currently a spec and optional secrets
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type TaskBrokerDispatchOptions = {
|
||||
spec: TaskSpec;
|
||||
secrets?: TaskSecrets;
|
||||
createdBy?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Task
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface TaskContext {
|
||||
cancelSignal: AbortSignal;
|
||||
spec: TaskSpec;
|
||||
secrets?: TaskSecrets;
|
||||
createdBy?: string;
|
||||
done: boolean;
|
||||
isDryRun?: boolean;
|
||||
|
||||
complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
|
||||
|
||||
emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
|
||||
|
||||
getWorkspaceName(): Promise<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* TaskBroker
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface TaskBroker {
|
||||
cancel?(taskId: string): Promise<void>;
|
||||
|
||||
claim(): Promise<TaskContext>;
|
||||
|
||||
dispatch(
|
||||
options: TaskBrokerDispatchOptions,
|
||||
): Promise<TaskBrokerDispatchResult>;
|
||||
|
||||
vacuumTasks(options: { timeoutS: number }): Promise<void>;
|
||||
|
||||
event$(options: {
|
||||
taskId: string;
|
||||
after: number | undefined;
|
||||
}): Observable<{ events: SerializedTaskEvent[] }>;
|
||||
|
||||
get(taskId: string): Promise<SerializedTask>;
|
||||
|
||||
list?(options?: { createdBy?: string }): Promise<{ tasks: SerializedTask[] }>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { JsonValue } from '@backstage/types';
|
||||
|
||||
/** @public */
|
||||
export type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
|
||||
|
||||
/** @public */
|
||||
export type TemplateGlobal =
|
||||
| ((...args: JsonValue[]) => JsonValue | undefined)
|
||||
| JsonValue;
|
||||
Reference in New Issue
Block a user