Skip to content
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

Updated for spec v1.0.0 #189

Merged
merged 1 commit into from
Jan 29, 2025
Merged
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ The npm [`@serverlessworkflow/sdk`](https://www.npmjs.com/package/@serverlesswor

| Latest Releases | Conformance to Spec Version |
| :---: | :---: |
| [v1.0.0-alpha5.\*](https://github.com/serverlessworkflow/sdk-typescript/releases/) | [v1.0.0-alpha5](https://github.com/serverlessworkflow/specification) |
| [v1.0.0.\*](https://github.com/serverlessworkflow/sdk-typescript/releases/) | [v1.0.0](https://github.com/serverlessworkflow/specification) |

> [!WARNING]
> Previous versions of the SDK were published with a typo in the scope:
@@ -60,7 +60,7 @@ The `validate` function is directly exported and can be used as `validate('Workf

### Installation
> [!NOTE]
> Version v1.0.0-alpha5.\* has not been released yet.
> Version v1.0.0.\* has not been released yet.

```sh
npm install @serverlessworkflow/sdk
@@ -77,7 +77,7 @@ import { Classes } from '@serverlessworkflow/sdk';
// const text = await fetch('https://myserver.com/my-workflow-definition.json');
const text = `
document:
dsl: 1.0.0-alpha5
dsl: 1.0.0
name: test
version: 1.0.0
namespace: default
@@ -98,7 +98,7 @@ import { Classes, Specification, validate } from '@serverlessworkflow/sdk';
// Simply cast an object:
const workflowDefinition = {
document: {
dsl: '1.0.0-alpha5',
dsl: '1.0.0',
name: 'test',
version: '1.0.0',
namespace: 'default',
@@ -134,7 +134,7 @@ import { Classes, validate } from '@serverlessworkflow/sdk';
// Simply use the constructor
const workflowDefinition = new Classes.Workflow({
document: {
dsl: '1.0.0-alpha5',
dsl: '1.0.0',
name: 'test',
version: '1.0.0',
namespace: 'default',
@@ -177,7 +177,7 @@ import { documentBuilder, setTaskBuilder, taskListBuilder, workflowBuilder } fro
const workflowDefinition = workflowBuilder(/*workflowDefinitionObject*/)
.document(
documentBuilder()
.dsl('1.0.0-alpha5')
.dsl('1.0.0')
.name('test')
.version('1.0.0')
.namespace('default')
2 changes: 1 addition & 1 deletion examples/browser/using-class.html
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
const { Classes: { Workflow } } = serverWorkflowSdk;
const workflow = new Workflow({
document: {
dsl: '1.0.0-alpha5',
dsl: '1.0.0',
name: 'using-class',
version: '1.0.0',
namespace: 'default',
2 changes: 1 addition & 1 deletion examples/browser/using-fluent-api.html
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
const { workflowBuilder, documentBuilder, taskListBuilder, setTaskBuilder } = serverWorkflowSdk;
try {
const workflow = workflowBuilder()
.document(documentBuilder().dsl('1.0.0-alpha5').name('using-fluent-api').version('1.0.0').namespace('default').build())
.document(documentBuilder().dsl('1.0.0').name('using-fluent-api').version('1.0.0').namespace('default').build())
.do(
taskListBuilder()
.push({
2 changes: 1 addition & 1 deletion examples/browser/using-json.html
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
const { Classes: { Workflow } } = serverWorkflowSdk;
const myJsonWorkflow = `{
"document": {
"dsl": "1.0.0-alpha5",
"dsl": "1.0.0",
"name": "using-json",
"version": "1.0.0",
"namespace": "default"
2 changes: 1 addition & 1 deletion examples/browser/using-plain-object.html
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
const { Classes, Specification, validate } = serverWorkflowSdk;
const workflowDefinition = {
document: {
dsl: '1.0.0-alpha5',
dsl: '1.0.0',
name: 'using-plain-object',
version: '1.0.0',
namespace: 'default',
2 changes: 1 addition & 1 deletion examples/node/using-class.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ const { Workflow } = Classes;

const workflow = new Workflow({
document: {
dsl: '1.0.0-alpha5',
dsl: '1.0.0',
name: 'using-class',
version: '1.0.0',
namespace: 'default',
4 changes: 1 addition & 3 deletions examples/node/using-fluent-api.ts
Original file line number Diff line number Diff line change
@@ -22,9 +22,7 @@ import {

try {
const workflow = workflowBuilder()
.document(
documentBuilder().dsl('1.0.0-alpha5').name('using-fluent-api').version('1.0.0').namespace('default').build(),
)
.document(documentBuilder().dsl('1.0.0').name('using-fluent-api').version('1.0.0').namespace('default').build())
.do(
taskListBuilder()
.push({
2 changes: 1 addition & 1 deletion examples/node/using-json.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { Classes } from /*'@serverlessworkflow/sdk';*/ '../../dist';
const myJsonWorkflow = `
{
"document": {
"dsl": "1.0.0-alpha5",
"dsl": "1.0.0",
"name": "using-json",
"version": "1.0.0",
"namespace": "default"
2 changes: 1 addition & 1 deletion examples/node/using-plain-object.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { Classes, Specification, validate } from /*'@serverlessworkflow/sdk';*/

const workflowDefinition = {
document: {
dsl: '1.0.0-alpha5',
dsl: '1.0.0',
name: 'using-plain-object',
version: '1.0.0',
namespace: 'default',
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@serverlessworkflow/sdk",
"version": "1.0.0-alpha5.0",
"schemaVersion": "1.0.0-alpha5",
"version": "1.0.0",
"schemaVersion": "1.0.0",
"description": "Typescript SDK for Serverless Workflow Specification",
"main": "umd/index.umd.min.js",
"browser": "umd/index.umd.min.js",
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2021-Present The Serverless Workflow Specification 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.
*/

/*****************************************************************************************
*
* /!\ This file is computer generated. Any manual modification can and will be lost. /!\
*
*****************************************************************************************/

import { builder, Builder, BuildOptions } from '../../builder';
import { Classes } from '../classes';
import { AnyEventConsumptionStrategyUntilIntersection } from '../classes/any-event-consumption-strategy-until';
import { Specification } from '../definitions';

/**
* The internal function used by the builder proxy to validate and return its underlying object
* @param {Specification.AnyEventConsumptionStrategyUntil} model The proxied object
* @param {BuildOptions} options The build options to use
* @returns {AnyEventConsumptionStrategyUntilIntersection} The built object
*/
function buildingFn(
model: Specification.AnyEventConsumptionStrategyUntil,
options: BuildOptions,
): AnyEventConsumptionStrategyUntilIntersection {
const instance = new Classes.AnyEventConsumptionStrategyUntil(model);
if (options.validate) instance.validate();
return (options.normalize ? instance.normalize() : instance) as AnyEventConsumptionStrategyUntilIntersection;
}

/**
* A factory to create a builder proxy for the type `AnyEventConsumptionStrategyUntilIntersection`
* @returns {Builder<AnyEventConsumptionStrategyUntilIntersection, AnyEventConsumptionStrategyUntilIntersection>} A builder for `AnyEventConsumptionStrategyUntilIntersection`
*/
export const anyEventConsumptionStrategyUntilBuilder = (
model?: Partial<Specification.AnyEventConsumptionStrategyUntil>,
): Builder<Partial<Specification.AnyEventConsumptionStrategyUntil>, AnyEventConsumptionStrategyUntilIntersection> =>
builder<Specification.AnyEventConsumptionStrategyUntil, AnyEventConsumptionStrategyUntilIntersection>(
model,
buildingFn,
);
Original file line number Diff line number Diff line change
@@ -22,26 +22,29 @@

import { builder, Builder, BuildOptions } from '../../builder';
import { Classes } from '../classes';
import { WithAsyncAPIPayloadIntersection } from '../classes/with-async-api-payload';
import { AnyEventUntilConsumedIntersection } from '../classes/any-event-until-consumed';
import { Specification } from '../definitions';

/**
* The internal function used by the builder proxy to validate and return its underlying object
* @param {Specification.WithAsyncAPIPayload} model The proxied object
* @param {Specification.AnyEventUntilConsumed} model The proxied object
* @param {BuildOptions} options The build options to use
* @returns {WithAsyncAPIPayloadIntersection} The built object
* @returns {AnyEventUntilConsumedIntersection} The built object
*/
function buildingFn(model: Specification.WithAsyncAPIPayload, options: BuildOptions): WithAsyncAPIPayloadIntersection {
const instance = new Classes.WithAsyncAPIPayload(model);
function buildingFn(
model: Specification.AnyEventUntilConsumed,
options: BuildOptions,
): AnyEventUntilConsumedIntersection {
const instance = new Classes.AnyEventUntilConsumed(model);
if (options.validate) instance.validate();
return (options.normalize ? instance.normalize() : instance) as WithAsyncAPIPayloadIntersection;
return (options.normalize ? instance.normalize() : instance) as AnyEventUntilConsumedIntersection;
}

/**
* A factory to create a builder proxy for the type `WithAsyncAPIPayloadIntersection`
* @returns {Builder<WithAsyncAPIPayloadIntersection, WithAsyncAPIPayloadIntersection>} A builder for `WithAsyncAPIPayloadIntersection`
* A factory to create a builder proxy for the type `AnyEventUntilConsumedIntersection`
* @returns {Builder<AnyEventUntilConsumedIntersection, AnyEventUntilConsumedIntersection>} A builder for `AnyEventUntilConsumedIntersection`
*/
export const withAsyncAPIPayloadBuilder = (
model?: Partial<Specification.WithAsyncAPIPayload>,
): Builder<Partial<Specification.WithAsyncAPIPayload>, WithAsyncAPIPayloadIntersection> =>
builder<Specification.WithAsyncAPIPayload, WithAsyncAPIPayloadIntersection>(model, buildingFn);
export const anyEventUntilConsumedBuilder = (
model?: Partial<Specification.AnyEventUntilConsumed>,
): Builder<Partial<Specification.AnyEventUntilConsumed>, AnyEventUntilConsumedIntersection> =>
builder<Specification.AnyEventUntilConsumed, AnyEventUntilConsumedIntersection>(model, buildingFn);
47 changes: 47 additions & 0 deletions src/lib/generated/builders/container-lifetime-builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2021-Present The Serverless Workflow Specification 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.
*/

/*****************************************************************************************
*
* /!\ This file is computer generated. Any manual modification can and will be lost. /!\
*
*****************************************************************************************/

import { builder, Builder, BuildOptions } from '../../builder';
import { Classes } from '../classes';
import { ContainerLifetimeIntersection } from '../classes/container-lifetime';
import { Specification } from '../definitions';

/**
* The internal function used by the builder proxy to validate and return its underlying object
* @param {Specification.ContainerLifetime} model The proxied object
* @param {BuildOptions} options The build options to use
* @returns {ContainerLifetimeIntersection} The built object
*/
function buildingFn(model: Specification.ContainerLifetime, options: BuildOptions): ContainerLifetimeIntersection {
const instance = new Classes.ContainerLifetime(model);
if (options.validate) instance.validate();
return (options.normalize ? instance.normalize() : instance) as ContainerLifetimeIntersection;
}

/**
* A factory to create a builder proxy for the type `ContainerLifetimeIntersection`
* @returns {Builder<ContainerLifetimeIntersection, ContainerLifetimeIntersection>} A builder for `ContainerLifetimeIntersection`
*/
export const containerLifetimeBuilder = (
model?: Partial<Specification.ContainerLifetime>,
): Builder<Partial<Specification.ContainerLifetime>, ContainerLifetimeIntersection> =>
builder<Specification.ContainerLifetime, ContainerLifetimeIntersection>(model, buildingFn);
Original file line number Diff line number Diff line change
@@ -22,26 +22,26 @@

import { builder, Builder, BuildOptions } from '../../builder';
import { Classes } from '../classes';
import { WithHTTPBodyIntersection } from '../classes/with-http-body';
import { ErrorFilterIntersection } from '../classes/error-filter';
import { Specification } from '../definitions';

/**
* The internal function used by the builder proxy to validate and return its underlying object
* @param {Specification.WithHTTPBody} model The proxied object
* @param {Specification.ErrorFilter} model The proxied object
* @param {BuildOptions} options The build options to use
* @returns {WithHTTPBodyIntersection} The built object
* @returns {ErrorFilterIntersection} The built object
*/
function buildingFn(model: Specification.WithHTTPBody, options: BuildOptions): WithHTTPBodyIntersection {
const instance = new Classes.WithHTTPBody(model);
function buildingFn(model: Specification.ErrorFilter, options: BuildOptions): ErrorFilterIntersection {
const instance = new Classes.ErrorFilter(model);
if (options.validate) instance.validate();
return (options.normalize ? instance.normalize() : instance) as WithHTTPBodyIntersection;
return (options.normalize ? instance.normalize() : instance) as ErrorFilterIntersection;
}

/**
* A factory to create a builder proxy for the type `WithHTTPBodyIntersection`
* @returns {Builder<WithHTTPBodyIntersection, WithHTTPBodyIntersection>} A builder for `WithHTTPBodyIntersection`
* A factory to create a builder proxy for the type `ErrorFilterIntersection`
* @returns {Builder<ErrorFilterIntersection, ErrorFilterIntersection>} A builder for `ErrorFilterIntersection`
*/
export const withHTTPBodyBuilder = (
model?: Partial<Specification.WithHTTPBody>,
): Builder<Partial<Specification.WithHTTPBody>, WithHTTPBodyIntersection> =>
builder<Specification.WithHTTPBody, WithHTTPBodyIntersection>(model, buildingFn);
export const errorFilterBuilder = (
model?: Partial<Specification.ErrorFilter>,
): Builder<Partial<Specification.ErrorFilter>, ErrorFilterIntersection> =>
builder<Specification.ErrorFilter, ErrorFilterIntersection>(model, buildingFn);
Original file line number Diff line number Diff line change
@@ -22,26 +22,26 @@

import { builder, Builder, BuildOptions } from '../../builder';
import { Classes } from '../classes';
import { WithHTTPQueryIntersection } from '../classes/with-http-query';
import { EventDataIntersection } from '../classes/event-data';
import { Specification } from '../definitions';

/**
* The internal function used by the builder proxy to validate and return its underlying object
* @param {Specification.WithHTTPQuery} model The proxied object
* @param {Specification.EventData} model The proxied object
* @param {BuildOptions} options The build options to use
* @returns {WithHTTPQueryIntersection} The built object
* @returns {EventDataIntersection} The built object
*/
function buildingFn(model: Specification.WithHTTPQuery, options: BuildOptions): WithHTTPQueryIntersection {
const instance = new Classes.WithHTTPQuery(model);
function buildingFn(model: Specification.EventData, options: BuildOptions): EventDataIntersection {
const instance = new Classes.EventData(model);
if (options.validate) instance.validate();
return (options.normalize ? instance.normalize() : instance) as WithHTTPQueryIntersection;
return (options.normalize ? instance.normalize() : instance) as EventDataIntersection;
}

/**
* A factory to create a builder proxy for the type `WithHTTPQueryIntersection`
* @returns {Builder<WithHTTPQueryIntersection, WithHTTPQueryIntersection>} A builder for `WithHTTPQueryIntersection`
* A factory to create a builder proxy for the type `EventDataIntersection`
* @returns {Builder<EventDataIntersection, EventDataIntersection>} A builder for `EventDataIntersection`
*/
export const withHTTPQueryBuilder = (
model?: Partial<Specification.WithHTTPQuery>,
): Builder<Partial<Specification.WithHTTPQuery>, WithHTTPQueryIntersection> =>
builder<Specification.WithHTTPQuery, WithHTTPQueryIntersection>(model, buildingFn);
export const eventDataBuilder = (
model?: Partial<Specification.EventData>,
): Builder<Partial<Specification.EventData>, EventDataIntersection> =>
builder<Specification.EventData, EventDataIntersection>(model, buildingFn);
Loading