Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-02-08 21:20:16 +01:00
parent 92582f17a0
commit a2ee37bc6d
7 changed files with 83 additions and 6 deletions
+41
View File
@@ -30,6 +30,10 @@ export type ActionContext<
secrets?: TaskSecrets;
workspacePath: string;
input: TActionInput;
checkpoint?<U extends JsonValue>(
key: string,
fn: () => Promise<U>,
): Promise<U>;
output(
name: keyof TActionOutput,
value: TActionOutput[keyof TActionOutput],
@@ -60,6 +64,19 @@ export function addFiles(options: {
logger?: Logger | undefined;
}): Promise<void>;
// @public
export type CheckpointRecord =
| {
key: string;
status: 'success';
value: JsonValue;
}
| {
key: string;
status: 'failed';
reason: string;
};
// @public (undocumented)
export function cloneRepo(options: {
url: string;
@@ -345,6 +362,13 @@ export interface TaskContext {
// (undocumented)
emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
// (undocumented)
getCheckpoints?(): Promise<
| {
state: TaskState;
}
| undefined
>;
// (undocumented)
getWorkspaceName(): Promise<string>;
// (undocumented)
isDryRun?: boolean;
@@ -352,6 +376,10 @@ export interface TaskContext {
secrets?: TaskSecrets;
// (undocumented)
spec: TaskSpec;
// (undocumented)
state?: TaskState;
// (undocumented)
updateCheckpoint?(options: CheckpointRecord): Promise<void>;
}
// @public
@@ -362,6 +390,19 @@ export type TaskSecrets = Record<string, string> & {
backstageToken?: string;
};
// @public
export type TaskState = {
[key: string]:
| {
status: 'failed';
reason: string;
}
| {
status: 'success';
value: JsonValue;
};
};
// @public
export type TaskStatus =
| 'cancelled'
+1 -1
View File
@@ -35,7 +35,7 @@ export type ActionContext<
secrets?: TaskSecrets;
workspacePath: string;
input: TActionInput;
checkpoint<U extends JsonValue>(
checkpoint?<U extends JsonValue>(
key: string,
fn: () => Promise<U>,
): Promise<U>;
+2 -2
View File
@@ -27,7 +27,7 @@ export type TaskSecrets = Record<string, string> & {
};
/**
* The record passed to {@link TaskBroker.updateCheckpoint?}
* The record passed to TaskBroker for updating a checkpoint.
* Parameters to store the result of the executed checkpoint
*
* @public
@@ -45,7 +45,7 @@ export type CheckpointRecord =
};
/**
* TaskState
* The state of all task's checkpoints
*
* @public
*/