Skip to content

fix-155 #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,25 @@ npm install && npm run build && npm run test

#### Install

For the latest stable version:

##### Version >= 4.0.0
Note: Version 4.0.0 has not been released yet.
```sh
npm i @serverlessworkflow/sdk-typescript
```


##### Version < 4.0.0
```sh
npm i @severlessworkflow/sdk-typescript
```



#### Create Workflow using builder API

```typescript
import { workflowBuilder, injectstateBuilder, Specification } from '@severlessworkflow/sdk-typescript';
import { workflowBuilder, injectstateBuilder, Specification } from '@serverlessworkflow/sdk-typescript';

const workflow: Specification.Workflow = workflowBuilder()
.id("helloworld")
Expand All @@ -69,7 +78,7 @@ const workflow: Specification.Workflow = workflowBuilder()
#### Create Workflow from JSON/YAML source

```typescript
import { Specification, Workflow } from '@severlessworkflow/sdk-typescript';
import { Specification, Workflow } from '@serverlessworkflow/sdk-typescript';

const source = `id: helloworld
version: '1.0'
Expand All @@ -93,7 +102,7 @@ Where `source` can be in both JSON or YAML format.
Having the following workflow instance:

```typescript
import { workflowBuilder, injectstateBuilder, Specification } from '@severlessworkflow/sdk-typescript';
import { workflowBuilder, injectstateBuilder, Specification } from '@serverlessworkflow/sdk-typescript';

const workflow: Specification.Workflow = workflowBuilder()
.id("helloworld")
Expand All @@ -118,15 +127,23 @@ You can convert it to its string representation in JSON or YAML format
by using the static methods `Workflow.toJson` or `Workflow.toYaml` respectively:

```typescript
import { Workflow } from '../src/lib/definitions/workflow';
import {Specification, workflowBuilder} from "@severlessworkflow/sdk-typescript";

const workflow: Specification.Workflow = workflowBuilder()
//...
.build()

const workflowAsJson: string = Workflow.toJson(workflow);
const workflowAsJson: string = Specification.Workflow.toJson(workflow);
```

```typescript
import { Workflow } from '../src/lib/definitions/workflow';
import {Specification, workflowBuilder} from "@severlessworkflow/sdk-typescript";

const workflow: Specification.Workflow = workflowBuilder()
//...
.build()

const workflowAsYaml: string = Workflow.toYaml(workflow);
const workflowAsYaml: string = Specification.Workflow.toYaml(workflow);
```


Expand All @@ -139,7 +156,7 @@ The sdk provides a way to validate if a workflow object is compliant with the se
- `validate(): boolean`

```typescript
import {WorkflowValidator, Specification} from '@severlessworkflow/sdk-typescript';
import {WorkflowValidator, Specification} from '@serverlessworkflow/sdk-typescript';
import {Workflow} from "./workflow";

const workflow = {
Expand Down Expand Up @@ -171,7 +188,7 @@ You can also validate parts of a workflow using `validators`:

```typescript
import { ValidateFunction } from 'ajv';
import { validators, Specification } from '@severlessworkflow/sdk-typescript';
import { validators, Specification } from '@serverlessworkflow/sdk-typescript';

const injectionState: Specification.Injectstate = workflow.states[0];
const injectionStateValidator: ValidateFunction<Specification.Injectstate> = validators.get('Injectstate');
Expand Down
Loading