chore: api-reports + revert optional key change
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
'@backstage/plugin-scaffolder-node': minor
|
||||
---
|
||||
|
||||
BREAKING ALPHA: The `checkpoint` method now takes an object instead of previous arguments, which allows also for an optional `key` which will be an incrementing counter for each call of the `checkpoint` method per step.
|
||||
BREAKING ALPHA: The `checkpoint` method now takes an object instead of previous arguments.
|
||||
|
||||
```ts
|
||||
await ctx.checkpoint({ key: 'repo.create', fn: () => ockokit.repo.create({...})})
|
||||
|
||||
@@ -166,17 +166,15 @@ describe('NunjucksWorkflowRunner', () => {
|
||||
});
|
||||
|
||||
const key4 = await ctx.checkpoint({
|
||||
key: 'key4',
|
||||
fn: () => {},
|
||||
});
|
||||
|
||||
const key5 = await ctx.checkpoint({
|
||||
key: 'key5',
|
||||
fn: async () => {},
|
||||
});
|
||||
|
||||
const key6 = await ctx.checkpoint({
|
||||
fn: async () => 'look ma no key',
|
||||
});
|
||||
|
||||
ctx.output('key1', key1);
|
||||
ctx.output('key2', key2);
|
||||
ctx.output('key3', key3);
|
||||
@@ -185,8 +183,6 @@ describe('NunjucksWorkflowRunner', () => {
|
||||
ctx.output('key4', key4);
|
||||
// @ts-expect-error - this is void return
|
||||
ctx.output('key5', key5);
|
||||
|
||||
ctx.output('key6', key6);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -688,7 +684,6 @@ describe('NunjucksWorkflowRunner', () => {
|
||||
expect(result.output.key3).toEqual('updated');
|
||||
expect(result.output.key4).toEqual(undefined);
|
||||
expect(result.output.key5).toEqual(undefined);
|
||||
expect(result.output.key6).toEqual('look ma no key');
|
||||
});
|
||||
|
||||
it('should template the output from simple actions', async () => {
|
||||
|
||||
@@ -364,7 +364,6 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
let checkpointCount = 0;
|
||||
|
||||
await action.handler({
|
||||
input: iteration.input,
|
||||
@@ -377,8 +376,7 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
|
||||
key?: string;
|
||||
fn: () => Promise<T> | T;
|
||||
}) {
|
||||
const { key: checkpointKey = checkpointCount++, fn } = opts;
|
||||
// default the task checkpoint to stepId plus count if there's no explict key provided.
|
||||
const { key: checkpointKey, fn } = opts;
|
||||
const key = `v1.task.checkpoint.${step.id}.${checkpointKey}`;
|
||||
|
||||
try {
|
||||
|
||||
@@ -31,10 +31,10 @@ export type ActionContext<
|
||||
secrets?: TaskSecrets;
|
||||
workspacePath: string;
|
||||
input: TActionInput;
|
||||
checkpoint<U extends JsonValue>(
|
||||
key: string,
|
||||
fn: () => Promise<U>,
|
||||
): Promise<U>;
|
||||
checkpoint<U extends JsonValue | void>(opts: {
|
||||
key: string;
|
||||
fn: () => Promise<U> | U;
|
||||
}): Promise<U>;
|
||||
output(
|
||||
name: keyof TActionOutput,
|
||||
value: TActionOutput[keyof TActionOutput],
|
||||
|
||||
@@ -39,7 +39,7 @@ export type ActionContext<
|
||||
workspacePath: string;
|
||||
input: TActionInput;
|
||||
checkpoint<U extends JsonValue | void>(opts: {
|
||||
key?: string;
|
||||
key: string;
|
||||
fn: () => Promise<U> | U;
|
||||
}): Promise<U>;
|
||||
output(
|
||||
|
||||
Reference in New Issue
Block a user