diff --git a/.changeset/grumpy-buttons-cheat.md b/.changeset/storybook-styling.md
similarity index 100%
rename from .changeset/grumpy-buttons-cheat.md
rename to .changeset/storybook-styling.md
diff --git a/.changeset/workflow-examples.md b/.changeset/workflow-examples.md
new file mode 100644
index 00000000..db2d54fb
--- /dev/null
+++ b/.changeset/workflow-examples.md
@@ -0,0 +1,5 @@
+---
+"@serverlessworkflow/diagram-editor": minor
+---
+
+Add workflow examples to Storybook
diff --git a/packages/serverless-workflow-diagram-editor/.storybook/preview.tsx b/packages/serverless-workflow-diagram-editor/.storybook/preview.tsx
index 8d6107d8..c43d6a91 100644
--- a/packages/serverless-workflow-diagram-editor/.storybook/preview.tsx
+++ b/packages/serverless-workflow-diagram-editor/.storybook/preview.tsx
@@ -30,12 +30,22 @@ const preview: Preview = {
},
},
+ backgrounds: {
+ disable: true,
+ },
+
a11y: {
// 'todo' - show a11y violations in the test UI only
// 'error' - fail CI on a11y violations
// 'off' - skip a11y checks entirely
test: "todo",
},
+
+ options: {
+ storySort: {
+ order: ["Introduction", "Features", "Examples", "Use Cases"],
+ },
+ },
},
globalTypes: {
diff --git a/packages/serverless-workflow-diagram-editor/stories/README.md b/packages/serverless-workflow-diagram-editor/stories/README.md
index dc1bd9f9..68f44e6a 100644
--- a/packages/serverless-workflow-diagram-editor/stories/README.md
+++ b/packages/serverless-workflow-diagram-editor/stories/README.md
@@ -22,6 +22,7 @@ This directory contains Storybook stories and documentation.
- **`introduction/`** - Introductory documentation and welcome pages
- **`features/`** - Component features and interactive stories
+- **`examples/`** - Serverless workflow specification examples
- **`use-cases/`** - Real-world use case examples
- **`assets/`** - Images and media files used in stories
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/Examples.stories.tsx b/packages/serverless-workflow-diagram-editor/stories/examples/Examples.stories.tsx
new file mode 100644
index 00000000..b20960ec
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/Examples.stories.tsx
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { DiagramEditor } from "../features/DiagramEditor";
+import * as workflows from "./index";
+
+const meta = {
+ title: "Examples/Examples",
+ component: DiagramEditor,
+ parameters: {
+ layout: "fullscreen",
+ },
+ render: (args, { globals }) => {
+ return ;
+ },
+} satisfies Meta;
+
+export default meta;
+type Story = StoryObj;
+
+// Constants for shared configuration
+const DEFAULT_STORY_ARGS = {
+ isReadOnly: true,
+ locale: "en" as const,
+} as const;
+
+/**
+ * Factory function to create workflow story configurations
+ * @param workflowContent - The YAML workflow content to display
+ * @returns Story configuration object
+ */
+const createWorkflowStory = (workflowContent: string): Story => {
+ return {
+ args: {
+ ...DEFAULT_STORY_ARGS,
+ content: workflowContent,
+ },
+ };
+};
+
+// Story definitions using the factory function
+export const AccumulateRoomReadings: Story = createWorkflowStory(workflows.accumulateRoomReadings);
+export const AuthenticationOAuth2: Story = createWorkflowStory(workflows.authenticationOAuth2);
+export const AuthenticationReusable: Story = createWorkflowStory(workflows.authenticationReusable);
+export const CallAsyncAPIPublish: Story = createWorkflowStory(workflows.callAsyncAPIPublish);
+export const CallAsyncAPISubscribe: Story = createWorkflowStory(workflows.callAsyncAPISubscribe);
+export const CallCustomFunctionCataloged: Story = createWorkflowStory(
+ workflows.callCustomFunctionCataloged,
+);
+export const CallCustomFunctionInline: Story = createWorkflowStory(
+ workflows.callCustomFunctionInline,
+);
+export const CallGrpc: Story = createWorkflowStory(workflows.callGrpc);
+export const CallHttpQueryHeadersExpressions: Story = createWorkflowStory(
+ workflows.callHttpQueryHeadersExpressions,
+);
+export const CallMCP: Story = createWorkflowStory(workflows.callMCP);
+export const CallOpenAPI: Story = createWorkflowStory(workflows.callOpenApi);
+export const ConditionalTask: Story = createWorkflowStory(workflows.conditionalTask);
+export const DoMultiple: Story = createWorkflowStory(workflows.doMultiple);
+export const DoSingle: Story = createWorkflowStory(workflows.doSingle);
+export const Emit: Story = createWorkflowStory(workflows.emit);
+export const For: Story = createWorkflowStory(workflows.forExample);
+export const Fork: Story = createWorkflowStory(workflows.fork);
+export const ListenToAll: Story = createWorkflowStory(workflows.listenToAll);
+export const ListenToOne: Story = createWorkflowStory(workflows.listenToOne);
+export const ListenToAnyForeverForeach: Story = createWorkflowStory(
+ workflows.listenToAnyForeverForeach,
+);
+export const MockServiceExtension: Story = createWorkflowStory(workflows.mockServiceExtension);
+export const RaiseReusable: Story = createWorkflowStory(workflows.raiseReusable);
+export const RunContainerStdinAndArguments: Story = createWorkflowStory(
+ workflows.runContainerStdinAndArguments,
+);
+export const RunReturnAll: Story = createWorkflowStory(workflows.runReturnAll);
+export const RunScriptWithStdinAndArguments: Story = createWorkflowStory(
+ workflows.runScriptWithStdinAndArguments,
+);
+export const RunShellStdinAndArguments: Story = createWorkflowStory(
+ workflows.runShellStdinAndArguments,
+);
+export const RunSubflow: Story = createWorkflowStory(workflows.runSubflow);
+export const ScheduleCron: Story = createWorkflowStory(workflows.scheduleCron);
+export const ScheduleEventDriven: Story = createWorkflowStory(workflows.scheduleEventDriven);
+export const SetExample: Story = createWorkflowStory(workflows.set);
+export const StarWarsHomeworld: Story = createWorkflowStory(workflows.starWarsHomeworld);
+export const SwitchThenString: Story = createWorkflowStory(workflows.switchThenString);
+export const TryCatchRetryReusable: Story = createWorkflowStory(workflows.tryCatchRetryReusable);
+export const TryCatchThen: Story = createWorkflowStory(workflows.tryCatchThen);
+export const WaitDurationInline: Story = createWorkflowStory(workflows.waitDurationInline);
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/Overview.mdx b/packages/serverless-workflow-diagram-editor/stories/examples/Overview.mdx
new file mode 100644
index 00000000..bb2bf29b
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/Overview.mdx
@@ -0,0 +1,29 @@
+{/*
+ * 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.
+ */}
+
+import { Meta } from "@storybook/addon-docs/blocks";
+
+
+
+# Examples
+
+This section showcases workflow examples from the [Serverless Workflow Specification](https://github.com/serverlessworkflow/specification/tree/main/examples).
+
+Each example demonstrates different workflow patterns and capabilities supported by the diagram editor.
+
+## Available Examples
+
+Browse through the examples in the sidebar to see how different workflow patterns are visualized.
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/index.ts b/packages/serverless-workflow-diagram-editor/stories/examples/index.ts
new file mode 100644
index 00000000..037f6ebf
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/index.ts
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+export { default as accumulateRoomReadings } from "./workflows/accumulate-room-readings.yaml?raw";
+export { default as authenticationOAuth2 } from "./workflows/authentication-oauth2.yaml?raw";
+export { default as authenticationReusable } from "./workflows/authentication-reusable.yaml?raw";
+export { default as callAsyncAPIPublish } from "./workflows/call-asyncapi-publish.yaml?raw";
+export { default as callAsyncAPISubscribe } from "./workflows/call-asyncapi-subscribe-consume-forever-foreach.yaml?raw";
+export { default as callCustomFunctionCataloged } from "./workflows/call-custom-function-cataloged.yaml?raw";
+export { default as callCustomFunctionInline } from "./workflows/call-custom-function-inline.yaml?raw";
+export { default as callGrpc } from "./workflows/call-grpc.yaml?raw";
+export { default as callHttpQueryHeadersExpressions } from "./workflows/call-http-query-headers-expressions.yaml?raw";
+export { default as callMCP } from "./workflows/call-mcp.yaml?raw";
+export { default as callOpenApi } from "./workflows/call-openapi.yaml?raw";
+export { default as conditionalTask } from "./workflows/conditional-task.yaml?raw";
+export { default as doMultiple } from "./workflows/do-multiple.yaml?raw";
+export { default as doSingle } from "./workflows/do-single.yaml?raw";
+export { default as emit } from "./workflows/emit.yaml?raw";
+export { default as forExample } from "./workflows/for.yaml?raw";
+export { default as fork } from "./workflows/fork.yaml?raw";
+export { default as listenToAll } from "./workflows/listen-to-all.yaml?raw";
+export { default as listenToOne } from "./workflows/listen-to-one.yaml?raw";
+export { default as listenToAnyForeverForeach } from "./workflows/listen-to-any-forever-foreach.yaml?raw";
+export { default as mockServiceExtension } from "./workflows/mock-service-extension.yaml?raw";
+export { default as raiseReusable } from "./workflows/raise-reusable.yaml?raw";
+export { default as runContainerStdinAndArguments } from "./workflows/run-container-stdin-and-arguments.yaml?raw";
+export { default as runReturnAll } from "./workflows/run-return-all.yaml?raw";
+export { default as runScriptWithStdinAndArguments } from "./workflows/run-script-with-stdin-and-arguments.yaml?raw";
+export { default as runShellStdinAndArguments } from "./workflows/run-shell-stdin-and-arguments.yaml?raw";
+export { default as runSubflow } from "./workflows/run-subflow.yaml?raw";
+export { default as scheduleCron } from "./workflows/schedule-cron.yaml?raw";
+export { default as scheduleEventDriven } from "./workflows/schedule-event-driven.yaml?raw";
+export { default as set } from "./workflows/set.yaml?raw";
+export { default as starWarsHomeworld } from "./workflows/star-wars-homeworld.yaml?raw";
+export { default as switchThenString } from "./workflows/switch-then-string.yaml?raw";
+export { default as tryCatchRetryReusable } from "./workflows/try-catch-retry-reusable.yaml?raw";
+export { default as tryCatchThen } from "./workflows/try-catch-then.yaml?raw";
+export { default as waitDurationInline } from "./workflows/wait-duration-inline.yaml?raw";
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/accumulate-room-readings.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/accumulate-room-readings.yaml
new file mode 100644
index 00000000..7ff4f67a
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/accumulate-room-readings.yaml
@@ -0,0 +1,59 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: accumulate-room-readings
+ version: "0.1.0"
+do:
+ - consumeReading:
+ listen:
+ to:
+ all:
+ - with:
+ source: https://my.home.com/sensor
+ type: my.home.sensors.temperature
+ correlate:
+ roomId:
+ from: .roomid
+ - with:
+ source: https://my.home.com/sensor
+ type: my.home.sensors.humidity
+ correlate:
+ roomId:
+ from: .roomid
+ output:
+ as: .data.reading
+ - logReading:
+ for:
+ each: reading
+ in: .readings
+ do:
+ - callOrderService:
+ call: openapi
+ with:
+ document:
+ endpoint: http://myorg.io/ordersservices.json
+ operationId: logreading
+ - generateReport:
+ call: openapi
+ with:
+ document:
+ endpoint: http://myorg.io/ordersservices.json
+ operationId: produceReport
+timeout:
+ after:
+ hours: 1
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/authentication-oauth2.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/authentication-oauth2.yaml
new file mode 100644
index 00000000..4042bb7c
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/authentication-oauth2.yaml
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: oauth2-authentication
+ version: "0.1.0"
+do:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint:
+ uri: https://petstore.swagger.io/v2/pet/{petId}
+ authentication:
+ oauth2:
+ authority: http://keycloak/realms/fake-authority
+ endpoints: #optional
+ token: /auth/token #defaults to /oauth2/token
+ introspection: /auth/introspect #defaults to /oauth2/introspect
+ grant: client_credentials
+ client:
+ id: workflow-runtime-id
+ secret: workflow-runtime-secret
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/authentication-reusable.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/authentication-reusable.yaml
new file mode 100644
index 00000000..dfc47056
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/authentication-reusable.yaml
@@ -0,0 +1,34 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: bearer-auth
+ version: "0.1.0"
+use:
+ authentications:
+ petStoreAuth:
+ bearer:
+ token: ${ .token }
+do:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint:
+ uri: https://petstore.swagger.io/v2/pet/{petId}
+ authentication:
+ use: petStoreAuth
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-asyncapi-publish.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-asyncapi-publish.yaml
new file mode 100644
index 00000000..5d8046af
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-asyncapi-publish.yaml
@@ -0,0 +1,35 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: bearer-auth
+ version: "0.1.0"
+do:
+ - findPet:
+ call: asyncapi
+ with:
+ document:
+ endpoint: https://fake.com/docs/asyncapi.json
+ operation: findPetsByStatus
+ server:
+ name: staging
+ message:
+ payload:
+ petId: ${ .pet.id }
+ authentication:
+ bearer:
+ token: ${ .token }
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-asyncapi-subscribe-consume-forever-foreach.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-asyncapi-subscribe-consume-forever-foreach.yaml
new file mode 100644
index 00000000..1df07d5d
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-asyncapi-subscribe-consume-forever-foreach.yaml
@@ -0,0 +1,42 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: bearer-auth
+ version: "0.1.0"
+do:
+ - getNotifications:
+ call: asyncapi
+ with:
+ document:
+ endpoint: https://fake.com/docs/asyncapi.json
+ operation: getNotifications
+ subscription:
+ filter: "${ .correlationId == $context.userId and .payload.from.firstName == $context.contact.firstName and .payload.from.lastName == $context.contact.lastName }"
+ consume:
+ while: "${ true }"
+ foreach:
+ item: message
+ do:
+ - publishCloudEvent:
+ emit:
+ event:
+ with:
+ source: https://serverlessworkflow.io/samples
+ type: io.serverlessworkflow.samples.asyncapi.message.consumed.v1
+ data:
+ message: "${ $message }"
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-custom-function-cataloged.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-custom-function-cataloged.yaml
new file mode 100644
index 00000000..b286d803
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-custom-function-cataloged.yaml
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: samples
+ name: call-custom-function-cataloged
+ version: "0.1.0"
+do:
+ - log:
+ call: https://raw.githubusercontent.com/serverlessworkflow/catalog/main/functions/log/1.0.0/function.yaml
+ with:
+ message: Hello, world!
+ level: information
+ timestamp: true
+ format: "{TIMESTAMP} [{LEVEL}] ({CONTEXT}): {MESSAGE}"
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-custom-function-inline.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-custom-function-inline.yaml
new file mode 100644
index 00000000..cf47dc3b
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-custom-function-inline.yaml
@@ -0,0 +1,40 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: samples
+ name: call-custom-function-inline
+ version: "0.1.0"
+use:
+ functions:
+ getPetById:
+ input:
+ schema:
+ document:
+ type: object
+ properties:
+ petId:
+ type: integer
+ required: [petId]
+ call: http
+ with:
+ method: get
+ endpoint: https://petstore.swagger.io/v2/pet/{petId}
+do:
+ - getPet:
+ call: getPetById
+ with:
+ petId: 69
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-grpc.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-grpc.yaml
new file mode 100644
index 00000000..3d8e0721
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-grpc.yaml
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: grpc-example
+ version: "0.1.0"
+do:
+ - greet:
+ call: grpc
+ with:
+ proto:
+ endpoint: file://app/greet.proto
+ service:
+ name: GreeterApi.Greeter
+ host: localhost
+ port: 5011
+ method: SayHello
+ arguments:
+ name: ${ .user.preferredDisplayName }
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-http-query-headers-expressions.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-http-query-headers-expressions.yaml
new file mode 100644
index 00000000..4310e03f
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-http-query-headers-expressions.yaml
@@ -0,0 +1,45 @@
+#
+# 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.
+#
+# yaml-language-server: $schema=../schema/workflow.yaml
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: http-query-headers-expressions
+ version: "1.0.0"
+input:
+ schema:
+ format: json
+ document:
+ type: object
+ required:
+ - searchQuery
+ properties:
+ searchQuery:
+ type: string
+do:
+ - setQueryAndHeaders:
+ set:
+ query:
+ search: ${.searchQuery}
+ headers:
+ Accept: application/json
+ - searchStarWarsCharacters:
+ call: http
+ with:
+ method: get
+ endpoint: https://swapi.dev/api/people/
+ headers: ${.headers}
+ query: ${.query}
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-mcp.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-mcp.yaml
new file mode 100644
index 00000000..8bf44493
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-mcp.yaml
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: mcp-example
+ version: "0.1.0"
+do:
+ - publishMessageToSlack:
+ call: mcp
+ with:
+ method: tools/call
+ parameters:
+ name: conversations_add_message
+ arguments:
+ channel_id: "C1234567890"
+ thread_ts: "1623456789.123456"
+ payload: "Hello, world! :wave:"
+ content_type: text/markdown
+ transport:
+ stdio:
+ command: npx
+ arguments: [slack-mcp-serverr@latest, --transport, stdio]
+ environment:
+ SLACK_MCP_XOXP_TOKEN: xoxp-xv6Cv3jKqNW8esm5YnsftKwIzoQHUzAP
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-openapi.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-openapi.yaml
new file mode 100644
index 00000000..7566be96
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/call-openapi.yaml
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: openapi-example
+ version: "0.1.0"
+do:
+ - findPet:
+ call: openapi
+ with:
+ document:
+ endpoint: https://petstore.swagger.io/v2/swagger.json
+ operationId: findPetsByStatus
+ parameters:
+ status: available
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/conditional-task.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/conditional-task.yaml
new file mode 100644
index 00000000..ee6c81c3
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/conditional-task.yaml
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: default
+ name: conditional-task
+ version: "0.1.0"
+do:
+ - raiseErrorIfUnderage:
+ if: .customer.age < 18
+ raise:
+ error:
+ type: https://superbet-casinos.com/customer/access-forbidden
+ status: 400
+ title: Access Forbidden
+ then: end
+ - placeBet:
+ call: http
+ with:
+ method: post
+ endpoint: https://superbet-casinos.com/api/bet/on/football
+ body:
+ customer: .customer
+ bet: .bet
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/do-multiple.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/do-multiple.yaml
new file mode 100644
index 00000000..18686063
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/do-multiple.yaml
@@ -0,0 +1,32 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: call-http-shorthand-endpoint
+ version: "0.1.0"
+do:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint: https://petstore.swagger.io/v2/pet/{petId}
+ - buyPet:
+ call: http
+ with:
+ method: put
+ endpoint: https://petstore.swagger.io/v2/pet/{petId}
+ body: '${ . + { status: "sold" } }'
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/do-single.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/do-single.yaml
new file mode 100644
index 00000000..f58374c3
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/do-single.yaml
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: call-http-shorthand-endpoint
+ version: "0.1.0"
+do:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint: https://petstore.swagger.io/v2/pet/{petId}
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/emit.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/emit.yaml
new file mode 100644
index 00000000..6b77fe71
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/emit.yaml
@@ -0,0 +1,34 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: emit
+ version: "0.1.0"
+do:
+ - emitEvent:
+ emit:
+ event:
+ with:
+ source: https://petstore.com
+ type: com.petstore.order.placed.v1
+ data:
+ client:
+ firstName: Cruella
+ lastName: de Vil
+ items:
+ - breed: dalmatian
+ quantity: 101
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/for.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/for.yaml
new file mode 100644
index 00000000..0b9a7259
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/for.yaml
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: for-example
+ version: "0.1.0"
+do:
+ - checkup:
+ for:
+ each: pet
+ in: .pets
+ at: index
+ while: .vet != null
+ do:
+ - waitForCheckup:
+ listen:
+ to:
+ one:
+ with:
+ type: com.fake.petclinic.pets.checkup.completed.v2
+ output:
+ as: '.pets + [{ "id": $pet.id }]'
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/fork.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/fork.yaml
new file mode 100644
index 00000000..4e03835b
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/fork.yaml
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: fork-example
+ version: "0.1.0"
+do:
+ - raiseAlarm:
+ fork:
+ compete: true
+ branches:
+ - callNurse:
+ call: http
+ with:
+ method: put
+ endpoint: https://fake-hospital.com/api/v3/alert/nurses
+ body:
+ patientId: ${ .patient.fullName }
+ room: ${ .room.number }
+ - callDoctor:
+ call: http
+ with:
+ method: put
+ endpoint: https://fake-hospital.com/api/v3/alert/doctor
+ body:
+ patientId: ${ .patient.fullName }
+ room: ${ .room.number }
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-all.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-all.yaml
new file mode 100644
index 00000000..3f01e2ef
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-all.yaml
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: listen-to-all
+ version: "0.1.0"
+do:
+ - callDoctor:
+ listen:
+ to:
+ all:
+ - with:
+ type: com.fake-hospital.vitals.measurements.temperature
+ data: ${ .temperature > 38 }
+ - with:
+ type: com.fake-hospital.vitals.measurements.bpm
+ data: ${ .bpm < 60 or .bpm > 100 }
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-any-forever-foreach.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-any-forever-foreach.yaml
new file mode 100644
index 00000000..69a4ac8a
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-any-forever-foreach.yaml
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: listen-to-any-while-foreach
+ version: "0.1.0"
+do:
+ - listenToGossips:
+ listen:
+ to:
+ any: []
+ until: "${ false }"
+ foreach:
+ item: event
+ at: i
+ do:
+ - postToChatApi:
+ call: http
+ with:
+ method: post
+ endpoint: https://fake-chat-api.com/room/{roomId}
+ body:
+ event: ${ $event }
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-one.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-one.yaml
new file mode 100644
index 00000000..5c5acc00
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/listen-to-one.yaml
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: listen-to-one
+ version: "0.1.0"
+do:
+ - waitForStartup:
+ listen:
+ to:
+ one:
+ with:
+ type: com.virtual-wf-powered-race.events.race.started.v1
+ - startup:
+ call: http
+ with:
+ method: post
+ endpoint:
+ uri: https://virtual-wf-powered-race.com/api/v4/cars/{carId}/start
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/mock-service-extension.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/mock-service-extension.yaml
new file mode 100644
index 00000000..27834258
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/mock-service-extension.yaml
@@ -0,0 +1,42 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: sample-workflow
+ version: 0.1.0
+use:
+ extensions:
+ - mockService:
+ extend: call
+ when: ($task.with.endpoint != null and ($task.with.endpoint | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com")))
+ before:
+ - mockResponse:
+ set:
+ statusCode: 200
+ headers:
+ Content-Type: application/json
+ content:
+ foo:
+ bar: baz
+ then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected
+do:
+ - callHttp:
+ call: http
+ with:
+ method: get
+ endpoint:
+ uri: https://fake.com/sample
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/raise-reusable.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/raise-reusable.yaml
new file mode 100644
index 00000000..00bcaaa3
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/raise-reusable.yaml
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: raise-not-implemented
+ version: "0.1.0"
+use:
+ errors:
+ notImplemented:
+ type: https://serverlessworkflow.io/errors/not-implemented
+ status: 500
+ title: Not Implemented
+ detail: ${ "The workflow '\( $workflow.definition.document.name ):\( $workflow.definition.document.version )' is a work in progress and cannot be run yet" }
+do:
+ - notImplemented:
+ raise:
+ error: notImplemented
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-container-stdin-and-arguments.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-container-stdin-and-arguments.yaml
new file mode 100644
index 00000000..9a734013
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-container-stdin-and-arguments.yaml
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: run-container-stdin-and-arguments
+ version: "0.1.0"
+do:
+ - setInput:
+ set:
+ message: Hello World
+ - runContainer:
+ input:
+ from: ${ .message }
+ run:
+ container:
+ image: alpine
+ command: |
+ input=$(cat)
+ echo "STDIN was: $input"
+ echo "ARGS are $1 $2"
+ stdin: ${ . }
+ arguments:
+ - Foo
+ - Bar
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-return-all.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-return-all.yaml
new file mode 100644
index 00000000..ba68f7e8
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-return-all.yaml
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: run-container
+ version: "0.1.0"
+do:
+ - runContainer:
+ run:
+ container:
+ image: hello-world
+ return: all
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-script-with-stdin-and-arguments.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-script-with-stdin-and-arguments.yaml
new file mode 100644
index 00000000..2c4cea89
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-script-with-stdin-and-arguments.yaml
@@ -0,0 +1,43 @@
+#
+# 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.
+#
+document:
+ dsl: 1.0.3
+ namespace: examples
+ name: run-script-with-stdin-and-arguments
+ version: 1.0.0
+do:
+ - runScript:
+ run:
+ script:
+ language: javascript
+ stdin: "Hello Workflow"
+ environment:
+ foo: bar
+ arguments:
+ - hello
+ code: |
+ // Reading Input from STDIN
+ import { readFileSync } from 'node:fs';
+ const stdin = readFileSync(process.stdin.fd, 'utf8');
+ console.log('stdin > ', stdin) // Output: stdin > Hello Workflow
+
+ // Reading from argv
+ const [_, __, arg] = process.argv;
+ console.log('arg > ', arg) // Output: arg > hello
+
+ // Reading from env
+ const foo = process.env.foo;
+ console.log('env > ', foo) // Output: env > bar
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-shell-stdin-and-arguments.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-shell-stdin-and-arguments.yaml
new file mode 100644
index 00000000..1fe04ded
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-shell-stdin-and-arguments.yaml
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+document:
+ dsl: 1.0.3
+ namespace: examples
+ name: run-shell-with-stdin-and-arguments
+ version: 1.0.0
+do:
+ - setInput:
+ set:
+ message: Hello World
+ - runShell:
+ input:
+ from: ${ .message }
+ run:
+ shell:
+ stdin: ${ . }
+ command: |
+ input=$(cat)
+ echo "STDIN was: $input"
+ echo "ARGS are $1 $2"
+ arguments:
+ - Foo
+ - Bar
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-subflow.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-subflow.yaml
new file mode 100644
index 00000000..c53a90c9
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/run-subflow.yaml
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: run-subflow
+ version: "0.1.0"
+do:
+ - registerCustomer:
+ run:
+ workflow:
+ namespace: test
+ name: register-customer
+ version: "0.1.0"
+ input:
+ customer: .user
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/schedule-cron.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/schedule-cron.yaml
new file mode 100644
index 00000000..166ec6e7
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/schedule-cron.yaml
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: cron-schedule
+ version: "0.1.0"
+schedule:
+ cron: 0 0 * * *
+do:
+ - backup:
+ call: http
+ with:
+ method: post
+ endpoint: https://example.com/api/v1/backup/start
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/schedule-event-driven.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/schedule-event-driven.yaml
new file mode 100644
index 00000000..0db682c0
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/schedule-event-driven.yaml
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: event-driven-schedule
+ version: "0.1.0"
+schedule:
+ on:
+ one:
+ with:
+ type: com.example.hospital.events.patients.heartbeat.low
+do:
+ - callNurse:
+ call: http
+ with:
+ method: post
+ endpoint: https://hospital.example.com/api/v1/notify
+ body:
+ patientId: ${ $workflow.input[0].data.patient.id }
+ patientName: ${ $workflow.input[0].data.patient.name }
+ roomNumber: ${ $workflow.input[0].data.patient.room.number }
+ vitals:
+ heartRate: ${ $workflow.input[0].data.patient.vitals.bpm }
+ timestamp: ${ $workflow.input[0].data.timestamp }
+ message: "Alert: Patient's heartbeat is critically low. Immediate attention required."
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/set.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/set.yaml
new file mode 100644
index 00000000..716079e6
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/set.yaml
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: set
+ version: "0.1.0"
+schedule:
+ on:
+ one:
+ with:
+ type: io.serverlessworkflow.samples.events.trigger.v1
+do:
+ - initialize:
+ set:
+ startEvent: ${ $workflow.input[0] }
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/star-wars-homeworld.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/star-wars-homeworld.yaml
new file mode 100644
index 00000000..42bd702c
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/star-wars-homeworld.yaml
@@ -0,0 +1,48 @@
+#
+# 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.
+#
+# yaml-language-server: $schema=../schema/workflow.yaml
+document:
+ dsl: "1.0.3"
+ namespace: examples
+ name: star-wars-homeplanet
+ version: "1.0.0"
+input:
+ schema:
+ format: json
+ document:
+ type: object
+ required:
+ - id
+ properties:
+ id:
+ type: integer
+ description: The id of the star wars character to get
+ minimum: 1
+do:
+ - getStarWarsCharacter:
+ call: http
+ with:
+ method: get
+ endpoint: https://swapi.dev/api/people/{id}
+ output: response
+ export:
+ as:
+ homeworld: ${ .content.homeworld }
+ - getStarWarsHomeworld:
+ call: http
+ with:
+ method: get
+ endpoint: ${ $context.homeworld }
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/switch-then-string.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/switch-then-string.yaml
new file mode 100644
index 00000000..4b681917
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/switch-then-string.yaml
@@ -0,0 +1,46 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: sample-workflow
+ version: 0.1.0
+do:
+ - processOrder:
+ switch:
+ - case1:
+ when: .orderType == "electronic"
+ then: processElectronicOrder
+ - case2:
+ when: .orderType == "physical"
+ then: processPhysicalOrder
+ - default:
+ then: handleUnknownOrderType
+ - processElectronicOrder:
+ set:
+ validate: true
+ status: fulfilled
+ then: exit
+ - processPhysicalOrder:
+ set:
+ inventory: clear
+ items: 1
+ address: Elmer St
+ then: exit
+ - handleUnknownOrderType:
+ set:
+ log: warn
+ message: something's wrong
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/try-catch-retry-reusable.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/try-catch-retry-reusable.yaml
new file mode 100644
index 00000000..15b24aea
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/try-catch-retry-reusable.yaml
@@ -0,0 +1,44 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: default
+ name: try-catch-retry
+ version: "0.1.0"
+use:
+ retries:
+ default:
+ delay:
+ seconds: 3
+ backoff:
+ exponential: {}
+ limit:
+ attempt:
+ count: 5
+do:
+ - tryGetPet:
+ try:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint: https://petstore.swagger.io/v2/pet/{petId}
+ catch:
+ errors:
+ with:
+ type: https://serverlessworkflow.io/spec/1.0.0/errors/communication
+ status: 503
+ retry: default
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/try-catch-then.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/try-catch-then.yaml
new file mode 100644
index 00000000..99fbc645
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/try-catch-then.yaml
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: default
+ name: try-catch
+ version: "0.1.0"
+do:
+ - tryGetPet:
+ try:
+ - getPet:
+ call: http
+ with:
+ method: get
+ endpoint: https://petstore.swagger.io/v2/pet/{petId}
+ catch:
+ errors:
+ with:
+ type: https://serverlessworkflow.io/spec/1.0.0/errors/communication
+ status: 404
+ as: error
+ do:
+ - notifySupport:
+ emit:
+ event:
+ with:
+ source: https://petstore.swagger.io
+ type: io.swagger.petstore.events.pets.not-found.v1
+ data: ${ $error }
+ - setError:
+ set:
+ error: $error
+ export:
+ as: "$context + { error: $error }"
+ - buyPet:
+ if: $context.error == null
+ call: http
+ with:
+ method: put
+ endpoint: https://petstore.swagger.io/v2/pet/{petId}
+ body: '${ . + { status: "sold" } }'
diff --git a/packages/serverless-workflow-diagram-editor/stories/examples/workflows/wait-duration-inline.yaml b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/wait-duration-inline.yaml
new file mode 100644
index 00000000..d1e21ff1
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/examples/workflows/wait-duration-inline.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: test
+ name: wait-duration-inline
+ version: "0.1.0"
+do:
+ - wait30Seconds:
+ wait:
+ seconds: 30
diff --git a/packages/serverless-workflow-diagram-editor/stories/use-cases/Overview.mdx b/packages/serverless-workflow-diagram-editor/stories/use-cases/Overview.mdx
new file mode 100644
index 00000000..29c47b38
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/use-cases/Overview.mdx
@@ -0,0 +1,29 @@
+{/*
+ * 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.
+ */}
+
+import { Meta } from "@storybook/addon-docs/blocks";
+
+
+
+# Use Cases
+
+This directory contains a collection of high-level use cases that demonstrate the capabilities and potential applications of the Serverless Workflow DSL.
+
+Each use case provides insights into how to effectively implement workflows in various scenarios, helping newcomers understand the framework's power and flexibility.
+
+## Available Use Cases
+
+Browse through the use cases in the sidebar to explore workflow implementations for different scenarios.
\ No newline at end of file
diff --git a/packages/serverless-workflow-diagram-editor/stories/use-cases/UseCases.stories.tsx b/packages/serverless-workflow-diagram-editor/stories/use-cases/UseCases.stories.tsx
new file mode 100644
index 00000000..b5aa500c
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/use-cases/UseCases.stories.tsx
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { DiagramEditor } from "../features/DiagramEditor";
+import * as workflows from "./index";
+
+const meta = {
+ title: "Use Cases/Use Cases",
+ component: DiagramEditor,
+ parameters: {
+ layout: "fullscreen",
+ },
+ render: (args, { globals }) => {
+ return ;
+ },
+} satisfies Meta;
+
+export default meta;
+type Story = StoryObj;
+
+const DEFAULT_STORY_ARGS = {
+ isReadOnly: true,
+ locale: "en" as const,
+} as const;
+
+const createWorkflowStory = (workflowContent: string): Story => {
+ return {
+ args: {
+ ...DEFAULT_STORY_ARGS,
+ content: workflowContent,
+ },
+ };
+};
+
+export const AutomatedDataBackup: Story = createWorkflowStory(workflows.automatedDataBackup);
+export const ManagingEVChargingStations: Story = createWorkflowStory(
+ workflows.managingEVChargingStations,
+);
+export const ManagingGithubIssues: Story = createWorkflowStory(workflows.managingGithubIssues);
+export const MultiAgentAIContentGeneration: Story = createWorkflowStory(
+ workflows.multiAgentAIContentGeneration,
+);
diff --git a/packages/serverless-workflow-diagram-editor/stories/use-cases/index.ts b/packages/serverless-workflow-diagram-editor/stories/use-cases/index.ts
new file mode 100644
index 00000000..9405f793
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/use-cases/index.ts
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+export { default as automatedDataBackup } from "./workflows/automated-data-backup.yaml?raw";
+export { default as managingEVChargingStations } from "./workflows/managing-ev-charging-stations.yaml?raw";
+export { default as managingGithubIssues } from "./workflows/managing-github-issues.yaml?raw";
+export { default as multiAgentAIContentGeneration } from "./workflows/multi-agent-ai-content-generation.yaml?raw";
diff --git a/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/automated-data-backup.yaml b/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/automated-data-backup.yaml
new file mode 100644
index 00000000..6b1a76be
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/automated-data-backup.yaml
@@ -0,0 +1,58 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: default
+ name: sql-export-to-minio
+ version: 0.1.2
+do:
+ - exportDatabase:
+ run:
+ container:
+ image: mcr.microsoft.com/mssql-tools
+ command: >
+ /bin/bash -c "sqlcmd -S $SQLSERVER_HOST -U $SQLSERVER_USER -P '$SQLSERVER_PASSWORD' -Q 'BACKUP DATABASE [$DATABASE_NAME] TO DISK = N\'/var/backup/db.bak\'' && echo 'Database backup completed'"
+ volumes:
+ /var/backup: /backup
+ environment:
+ SQLSERVERHOST: sqlserver
+ SQLSERVERUSER: SA
+ SQLSERVERPASSWORD: P@ssw0rd
+ DATABASENAME: YourDatabase
+ - readBackupFile:
+ run:
+ container:
+ image: alpine
+ command: >
+ /bin/sh -c "cat /backup/YourDatabase.bak | base64"
+ volumes:
+ /var/backup: /backup
+ export:
+ as: "$context + { base64Backup: . }"
+ - uploadToMinio:
+ call: http
+ with:
+ method: put
+ endpoint:
+ uri: https://minio.example.com/backups/db.bak
+ authentication:
+ bearer:
+ token: 2548qsd5a8qsd43a
+ headers:
+ contentType: application/octet-stream
+ body: ${ $context.base64Backup }
+schedule:
+ cron: 0 0 * * *
diff --git a/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/managing-ev-charging-stations.yaml b/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/managing-ev-charging-stations.yaml
new file mode 100644
index 00000000..7cca3495
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/managing-ev-charging-stations.yaml
@@ -0,0 +1,199 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: default
+ name: manage-ev-charging-stations
+ version: "0.1.0"
+schedule:
+ on:
+ any:
+ - with:
+ type: com.ev-power-supplier.charging-station.card-scanned.v1
+ - with:
+ type: com.ev-power-supplier.charging-station.faulted.v1
+do:
+ - initialize:
+ set:
+ event: ${ $workflow.input[0].data }
+ export:
+ as: .event
+
+ - handleStationEvents:
+ switch:
+ - sessionStarted:
+ when: .event.type == "com.ev-power-supplier.charging-station.card-scanned.v1"
+ then: tryGetActiveSession
+ - stationError:
+ when: .event.type == "com.ev-power-supplier.charging.station-faulted.v1"
+ then: handleError
+ then: raiseUnsupportedEventError
+
+ - tryGetActiveSession:
+ try:
+ - getSessionForCard:
+ call: http
+ with:
+ method: get
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/session/{cardId}
+ - setSessionInfo:
+ set:
+ session: ${ .session }
+ catch:
+ errors:
+ with:
+ status: 404
+
+ - handleActiveSession:
+ switch:
+ - sessionInProgress:
+ when: .session != null
+ then: endSession
+ - noActiveSession:
+ then: tryAquireSlot
+
+ - tryAquireSlot:
+ try:
+ - acquireSlot:
+ call: http
+ with:
+ method: post
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}
+ body:
+ card: ${ $context.card }
+ export:
+ as: "$context + { slot: .slot }"
+ catch:
+ errors:
+ with:
+ status: 400
+ when: .detail == "No charging slots available"
+ do:
+ - noSlotsAvailable:
+ call: http
+ with:
+ method: post
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/leds/main
+ body:
+ action: flicker
+ color: red
+ duration: 3000
+ then: end
+
+ - startSession:
+ do:
+ - initialize:
+ set:
+ session:
+ card: ${ $context.card }
+ slotNumber: ${ $context.slot.number }
+ export:
+ as: "$context + { session: . }"
+ - feedBack:
+ call: http
+ with:
+ method: post
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/leds/{slotNumber}
+ body:
+ action: "on"
+ color: blue
+ - lockSlot:
+ call: http
+ with:
+ method: put
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/slot/{slotNumber}/lock
+ - start:
+ call: http
+ with:
+ method: put
+ endpoint: https://ev-power-supplier.com/api/v2/sessions/{sessionId}/start
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://ev-power-supplier.com
+ type: com.ev-power-supplier.charging-station.session-started.v1
+ data: ${ $context.session }
+
+ - endSession:
+ do:
+ - end:
+ call: http
+ with:
+ method: put
+ endpoint: https://ev-power-supplier.com/api/v2/sessions/{sessionId}/end
+ - processPayment:
+ call: http
+ with:
+ method: put
+ endpoint: https://ev-power-supplier.com/api/v2/sessions/{sessionId}/pay
+ - unlockSlot:
+ call: http
+ with:
+ method: put
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/slot/{slotNumber}/unlock
+ - feedBack:
+ call: http
+ with:
+ method: post
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/leds/{slotNumber}
+ body:
+ action: flicker
+ color: white
+ duration: 3000
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://ev-power-supplier.com
+ type: com.ev-power-supplier.charging-station.session-ended.v1
+ data: ${ $context.session }
+ then: end
+
+ - handleError:
+ do:
+ - contactSupport:
+ call: http
+ with:
+ method: post
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/support
+ body:
+ error: ${ $context.event.data.error }
+ - feedBack:
+ call: http
+ with:
+ method: post
+ endpoint: https://ev-power-supplier.com/api/v2/stations/{stationId}/leds/main
+ body:
+ action: "on"
+ color: red
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://ev-power-supplier.com
+ type: com.ev-power-supplier.charging-station.out-of-order.v1
+ data: ${ $context.event.data.error }
+ then: end
+
+ - raiseUnsupportedEventError:
+ raise:
+ error:
+ type: https://serverlessworkflow.io/spec/1.0.0/errors/runtime
+ status: 400
+ title: Unsupported Event
+ detail: ${ "The specified station event '\($context.event.type)' is not supported in this context" }
+ then: end
diff --git a/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/managing-github-issues.yaml b/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/managing-github-issues.yaml
new file mode 100644
index 00000000..dd10f755
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/managing-github-issues.yaml
@@ -0,0 +1,206 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: default
+ name: manage-github-issues
+ version: "0.1.0"
+schedule:
+ on:
+ one:
+ with:
+ type: com.github.events.issues.opened.v1
+ data: ${ .data.author.team == "QA" }
+do:
+ - initialize:
+ set:
+ issue: ${ $workflow.input[0].data }
+ export:
+ as: .issue
+
+ - awaitForDevWork:
+ do:
+ - assign:
+ set:
+ issue:
+ assignedTo: DevTeam
+ status: inProgress
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://serverlessworkflow.io
+ type: com.github.events.issues.assignedToDevTeam.v1
+ data:
+ issue: ${ .issue }
+ - await:
+ listen:
+ to:
+ one:
+ with:
+ type: com.github.events.issues.devWorkCompleted.v1
+ export:
+ as: "$context + { issue: ($context.issue + { action: .data.nextAction, dev: .data.dev }) }"
+ then: evaluateDevWorkOutcome
+
+ - evaluateDevWorkOutcome:
+ switch:
+ - review:
+ when: $context.issue.action == "review"
+ then: reviewIssue
+ - requestDetails:
+ when: $context.issue.action == "requestDetails"
+ then: awaitDetailsFromQA
+ - default:
+ then: raiseUnsupportedActionError
+
+ - awaitDetailsFromQA:
+ do:
+ - assign:
+ set:
+ issue:
+ assignedTo: QA
+ status: awaitingDetails
+ assignTo: ${ $context.issue.author }
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://serverlessworkflow.io
+ type: com.github.events.issues.assignedToQATeam.v1
+ data:
+ issue: ${ $context.issue }
+ - await:
+ listen:
+ to:
+ one:
+ with:
+ type: com.github.events.issues.detailsProvided.v1
+ export:
+ as: "$context + { issue: ($context.issue + { action: .data.nextAction }) }"
+ then: awaitForDevWork
+
+ - reviewIssue:
+ do:
+ - assign:
+ set:
+ issue:
+ assignedTo: DevTeam
+ status: reviewing
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://serverlessworkflow.io
+ type: com.github.events.issues.pendingReview.v1
+ data:
+ issue: ${ $context.issue }
+ review:
+ exclude: ${ $context.issue.dev }
+ - await:
+ listen:
+ to:
+ one:
+ with:
+ type: com.github.events.issues.reviewed.v1
+ export:
+ as: "$context + { issue: ($context.issue + { reviewer: .data.reviewer }) }"
+
+ - validateReview:
+ switch:
+ - reviewerIsNotAssignedDev:
+ when: $context.issue.reviewer != $context.issue.dev
+ then: evaluateReview
+ - reviewerIsAssignedDev:
+ then: raiseAssignedDevCannotBeReviewer
+
+ - evaluateReview:
+ do:
+ - assign:
+ set:
+ issue:
+ assignedTo: QA
+ status: evaluating
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://serverlessworkflow.io
+ type: com.github.events.issues.evaluateReview.v1
+ data:
+ issue: ${ $context.issue }
+ assignTo: ${ $context.issue.author }
+ - await:
+ listen:
+ to:
+ one:
+ with:
+ type: com.github.events.issues.evaluated.v1
+ export:
+ as: "$context + { issue: ($context.issue + { action: .data.nextAction }) }"
+ - evaluate:
+ switch:
+ - closeIssue:
+ when: $context.issue.action == "close"
+ then: closeIssue
+ - default:
+ then: exit
+ - closeIssue:
+ do:
+ - initialize:
+ set:
+ organization: ${ $context.issue.repository.organization }
+ repository: ${ $context.issue.repository.name }
+ issueNumber: ${ $context.issue.number }
+ - closeIssueOnGithub:
+ call: http
+ with:
+ endpoint: https://api.github.com/repos/{organization}/{repository}/issues/{issueNumber}
+ method: patch
+ body:
+ state: closed
+ - setIssueInfo:
+ set:
+ issue:
+ status: closed
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://serverlessworkflow.io
+ type: com.github.events.issues.closed.v1
+ data:
+ issue: ${ $context.issue }
+ then: end
+ then: awaitForDevWork
+
+ - raiseUnsupportedActionError:
+ raise:
+ error:
+ type: https://serverlessworkflow.io/spec/1.0.0/errors/runtime
+ status: 400
+ title: Unsupported Action
+ detail: The specified action is not supported in this context
+ then: end
+
+ - raiseAssignedDevCannotBeReviewer:
+ raise:
+ error:
+ type: https://serverlessworkflow.io/spec/1.0.0/errors/runtime
+ status: 400
+ title: Invalid Reviewer
+ detail: The developer that has performed the work associated with the issue cannot be the reviewer of its own work
+ then: end
diff --git a/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/multi-agent-ai-content-generation.yaml b/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/multi-agent-ai-content-generation.yaml
new file mode 100644
index 00000000..1f6828e9
--- /dev/null
+++ b/packages/serverless-workflow-diagram-editor/stories/use-cases/workflows/multi-agent-ai-content-generation.yaml
@@ -0,0 +1,117 @@
+#
+# 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.
+#
+document:
+ dsl: "1.0.3"
+ namespace: default
+ name: multi-agent-collaboration-for-ai-content
+ version: "0.1.0"
+input:
+ schema:
+ document:
+ type: object
+ properties:
+ prompt:
+ type: string
+ required: [prompt]
+do:
+ - initialize:
+ set:
+ prompt: ${ $workflow.input.prompt }
+ export:
+ as: .prompt
+
+ - generateText:
+ call: http
+ with:
+ method: post
+ endpoint: https://ai-content-generator.com/api/v1/generate-text
+ body:
+ prompt: ${ .prompt }
+ export:
+ as: "$context + { text: .text }"
+
+ - generateImage:
+ call: http
+ with:
+ method: post
+ endpoint: https://ai-content-generator.com/api/v1/generate-image
+ body:
+ text: ${ .text }
+ export:
+ as: "$context + { image: .image }"
+
+ - evaluateQuality:
+ call: http
+ with:
+ method: post
+ endpoint: https://ai-content-generator.com/api/v1/evaluate
+ body:
+ text: ${ .text }
+ image: ${ .image }
+ export:
+ as: "$context + { evaluation: .evaluation }"
+
+ - refineContent:
+ switch:
+ - needsRefinement:
+ when: .evaluation.needsRefinement == true
+ then: refine
+ - noRefinementNeeded:
+ when: .evaluation.needsRefinement == false
+ then: deliverContent
+
+ - refine:
+ do:
+ - refineText:
+ call: http
+ with:
+ method: post
+ endpoint: https://ai-content-generator.com/api/v1/refine-text
+ body:
+ text: ${ .text }
+ feedback: ${ .evaluation.text_feedback }
+ - refineImage:
+ call: http
+ with:
+ method: post
+ endpoint: https://ai-content-generator.com/api/v1/refine-image
+ body:
+ image: ${ .image }
+ feedback: ${ .evaluation.image_feedback }
+ - reevaluate:
+ call: http
+ with:
+ method: post
+ endpoint: https://ai-content-generator.com/api/v1/evaluate
+ body:
+ text: ${ .refined_text }
+ image: ${ .refined_image }
+ export:
+ as: .evaluation
+ then: evaluateQuality
+
+ - deliverContent:
+ do:
+ - notify:
+ emit:
+ event:
+ with:
+ source: https://ai-content-generator.com
+ type: com.ai-content-generator.content.ready.v1
+ data:
+ text: ${ .text }
+ image: ${ .image }
+ then: end