Skip to content

Commit ed69891

Browse files
authored
Merge pull request #61 from nibble-4bits/chore/prepare-for-v1-release
Chore/prepare for v1 release
2 parents 0a81a65 + 1becb7b commit ed69891

22 files changed

+129
-80
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: prepare-for-release
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
test-build-prepare-for-release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3
16+
with:
17+
node-version: '16'
18+
registry-url: 'https://registry.npmjs.org'
19+
- name: Install dependencies
20+
run: npm ci
21+
- name: Run tests
22+
run: npm test
23+
- name: Build project
24+
run: npm run build
25+
- name: Create tag from package.json
26+
uses: jaywcjlove/create-tag-action@v1.3.18
27+
with:
28+
token: ${{ github.token }}
29+
package-path: ./package.json

.github/workflows/publish-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: publish-package
22

33
on:
4-
push:
5-
branches:
6-
- 'master'
4+
release:
5+
types:
6+
- published
77

88
concurrency: ${{ github.workflow }}-${{ github.ref }}
99

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22

33
A TypeScript implementation of the [Amazon States Language specification](https://states-language.net/spec.html).
44

5-
This package lets you run AWS Step Functions completely locally, both in Node.js and in the browser!
5+
This package lets you run AWS Step Functions state machines completely locally, both in Node.js and in the browser!
6+
7+
<p align="left">
8+
<a href="/LICENSE">
9+
<img alt="Project license (MIT)" src="https://img.shields.io/github/license/nibble-4bits/aws-local-stepfunctions">
10+
</a>
11+
<a href="https://github.com/nibble-4bits/aws-local-stepfunctions/actions/workflows/pr-run-tests.yml">
12+
<img alt="GitHub Workflow Status (with event)" src="https://img.shields.io/github/actions/workflow/status/nibble-4bits/aws-local-stepfunctions/pr-run-tests.yml">
13+
</a>
14+
<a href="https://www.npmjs.com/package/aws-local-stepfunctions">
15+
<img alt="Latest npm version" src="https://img.shields.io/npm/v/aws-local-stepfunctions">
16+
</a>
17+
<a href="https://www.npmjs.com/package/aws-local-stepfunctions">
18+
<img alt="node-lts" src="https://img.shields.io/node/v-lts/aws-local-stepfunctions">
19+
</a>
20+
<a href="https://www.npmjs.com/package/aws-local-stepfunctions">
21+
<img alt="npm type definitions" src="https://img.shields.io/npm/types/aws-local-stepfunctions">
22+
</a>
23+
</p>
624

725
## Table of contents
826

__tests__/StateMachine.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { StateMachineDefinition } from '../src/typings/StateMachineDefiniti
22
import type { EventLog } from '../src/typings/EventLogs';
33
import { StateMachine } from '../src/stateMachine/StateMachine';
44
import { ExecutionAbortedError } from '../src/error/ExecutionAbortedError';
5-
import { StatesTimeoutError } from '../src/error/predefined/StatesTimeoutError';
5+
import { ExecutionTimeoutError } from '../src/error/ExecutionTimeoutError';
66
import { ExecutionError } from '../src/error/ExecutionError';
77

88
afterEach(() => {
@@ -125,7 +125,7 @@ describe('State Machine', () => {
125125
await expect(execution.result).resolves.toBe(null);
126126
});
127127

128-
test('should throw an `States.Timeout` error if execution times out', async () => {
128+
test('should throw an `ExecutionTimeoutError` error if execution times out', async () => {
129129
const machineDefinition: StateMachineDefinition = {
130130
StartAt: 'WaitState',
131131
TimeoutSeconds: 1,
@@ -142,7 +142,7 @@ describe('State Machine', () => {
142142
const stateMachine = new StateMachine(machineDefinition);
143143
const execution = stateMachine.run(input);
144144

145-
await expect(execution.result).rejects.toThrow(StatesTimeoutError);
145+
await expect(execution.result).rejects.toThrow(ExecutionTimeoutError);
146146
});
147147

148148
test('should throw an `ExecutionError` if execution fails', async () => {
@@ -366,7 +366,7 @@ describe('State Machine', () => {
366366
events.push(event);
367367
}
368368

369-
await expect(execution.result).rejects.toThrow(StatesTimeoutError);
369+
await expect(execution.result).rejects.toThrow(ExecutionTimeoutError);
370370
expect(events).toEqual([
371371
{ type: 'ExecutionStarted', timestamp: 1670198400000, input: {} },
372372
{ type: 'StateEntered', timestamp: 1670198400000, state: { name: 'PassState1', type: 'Pass', input: {} } },

examples/abort-execution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ setTimeout(() => {
3737

3838
try {
3939
const result = await execution.result;
40-
console.log(result); // If not aborted, would log 12 once execution finished
40+
console.log(result); // If not aborted, would log 12 once execution finishes
4141
} catch (e) {
4242
if (e instanceof ExecutionAbortedError) {
4343
// Since execution was aborted, type of error is `ExecutionAbortedError`

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "aws-local-stepfunctions",
33
"version": "0.7.0",
4-
"description": "Execute an AWS Step Function locally",
4+
"description": "Execute an AWS Step Function state machine locally",
55
"keywords": [
66
"aws",
77
"local",
@@ -35,6 +35,9 @@
3535
"browser": "./build/main.browser.esm.js",
3636
"default": "./build/main.browser.esm.js"
3737
},
38+
"engines": {
39+
"node": ">=16.0.0"
40+
},
3841
"bin": {
3942
"local-sfn": "./build/CLI.cjs"
4043
},

src/error/ExecutionTimeoutError.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Represents the timeout of a state machine execution.
3+
*/
4+
export class ExecutionTimeoutError extends Error {
5+
constructor() {
6+
super('Execution timed out');
7+
8+
this.name = 'ExecutionTimeoutError';
9+
}
10+
}

src/error/RuntimeError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Base class for all internal errors that can be thrown during the state machine execution.
33
*/
4-
export class RuntimeError extends Error {
4+
export abstract class RuntimeError extends Error {
55
/**
66
* Whether this runtime error can be matched in a `Retry` field
77
*/

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { StateMachine } from './stateMachine/StateMachine';
22
export { ExecutionError } from './error/ExecutionError';
33
export { ExecutionAbortedError } from './error/ExecutionAbortedError';
4-
export { StatesTimeoutError as ExecutionTimeoutError } from './error/predefined/StatesTimeoutError';
4+
export { ExecutionTimeoutError } from './error/ExecutionTimeoutError';

src/stateMachine/StateExecutor.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AllStates } from '../typings/AllStates';
2-
import type { ExecutionResult } from '../typings/StateActions';
2+
import type { ActionResult } from '../typings/StateActions';
33
import type { RetryResult, CatchResult, StateHandlers } from '../typings/StateExecutor';
44
import type { ExecuteOptions } from '../typings/StateMachineImplementation';
55
import type { ErrorOutput } from '../typings/ErrorHandling';
@@ -105,7 +105,7 @@ export class StateExecutor {
105105
/**
106106
* Execute the current state.
107107
*/
108-
async execute(input: JSONValue, context: Context, options: ExecuteOptions): Promise<ExecutionResult> {
108+
async execute(input: JSONValue, context: Context, options: ExecuteOptions): Promise<ActionResult> {
109109
const rawInput = cloneDeep(input);
110110

111111
try {
@@ -274,7 +274,7 @@ export class StateExecutor {
274274
context: Context,
275275
stateName: string,
276276
options: ExecuteOptions
277-
): Promise<ExecutionResult> {
277+
): Promise<ActionResult> {
278278
const overrideFn = options.runOptions?.overrides?.taskResourceLocalHandlers?.[stateName];
279279
const awsConfig = options.stateMachineOptions?.awsConfig;
280280

@@ -297,7 +297,7 @@ export class StateExecutor {
297297
context: Context,
298298
stateName: string,
299299
options: ExecuteOptions
300-
): Promise<ExecutionResult> {
300+
): Promise<ActionResult> {
301301
const parallelStateAction = new ParallelStateAction(stateDefinition, stateName);
302302
const executionResult = await parallelStateAction.execute(input, context, {
303303
stateMachineOptions: options.stateMachineOptions,
@@ -323,7 +323,7 @@ export class StateExecutor {
323323
context: Context,
324324
stateName: string,
325325
options: ExecuteOptions
326-
): Promise<ExecutionResult> {
326+
): Promise<ActionResult> {
327327
const mapStateAction = new MapStateAction(stateDefinition, stateName);
328328
const executionResult = await mapStateAction.execute(input, context, {
329329
stateMachineOptions: options.stateMachineOptions,
@@ -350,7 +350,7 @@ export class StateExecutor {
350350
stateName: string,
351351
// eslint-disable-next-line @typescript-eslint/no-unused-vars
352352
options: ExecuteOptions
353-
): Promise<ExecutionResult> {
353+
): Promise<ActionResult> {
354354
const passStateAction = new PassStateAction(stateDefinition, stateName);
355355
const executionResult = await passStateAction.execute(input, context);
356356

@@ -370,7 +370,7 @@ export class StateExecutor {
370370
context: Context,
371371
stateName: string,
372372
options: ExecuteOptions
373-
): Promise<ExecutionResult> {
373+
): Promise<ActionResult> {
374374
const waitTimeOverrideOption = options.runOptions?.overrides?.waitTimeOverrides?.[stateName];
375375

376376
const waitStateAction = new WaitStateAction(stateDefinition, stateName);
@@ -406,7 +406,7 @@ export class StateExecutor {
406406
stateName: string,
407407
// eslint-disable-next-line @typescript-eslint/no-unused-vars
408408
options: ExecuteOptions
409-
): Promise<ExecutionResult> {
409+
): Promise<ActionResult> {
410410
const choiceStateAction = new ChoiceStateAction(stateDefinition, stateName);
411411
const executionResult = await choiceStateAction.execute(input, context);
412412

@@ -427,7 +427,7 @@ export class StateExecutor {
427427
stateName: string,
428428
// eslint-disable-next-line @typescript-eslint/no-unused-vars
429429
options: ExecuteOptions
430-
): Promise<ExecutionResult> {
430+
): Promise<ActionResult> {
431431
const succeedStateAction = new SucceedStateAction(stateDefinition, stateName);
432432
const executionResult = await succeedStateAction.execute(input, context);
433433

@@ -448,7 +448,7 @@ export class StateExecutor {
448448
stateName: string,
449449
// eslint-disable-next-line @typescript-eslint/no-unused-vars
450450
options: ExecuteOptions
451-
): Promise<ExecutionResult> {
451+
): Promise<ActionResult> {
452452
const failStateAction = new FailStateAction(stateDefinition, stateName);
453453
const executionResult = await failStateAction.execute(input, context);
454454

0 commit comments

Comments
 (0)