Skip to content

feat: migrate to specification v1.0.0 #33

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"ms-vscode.extension-test-runner"
"ms-vscode.extension-test-runner",
"redhat.vscode-yaml"
]
}
1,549 changes: 811 additions & 738 deletions package-lock.json

Large diffs are not rendered by default.

64 changes: 39 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "serverless-workflow",
"displayName": "Serverless Workflow",
"description": "",
"version": "2.0.0",
"version": "2.1.0",
"engines": {
"vscode": "^1.86.0"
},
"categories": [
"Snippets",
"Other"
],
"activationEvents": [
Expand All @@ -16,12 +17,16 @@
],
"main": "./out/extension.js",
"contributes": {
"jsonValidation": [
{
"fileMatch": ["*.json", "*.yml", "*.yaml"],
"url": "https://serverlessworkflow.io/schemas/latest/workflow.json"
}
],
"jsonValidation": [
{
"fileMatch": [
"*.json",
"*.yml",
"*.yaml"
],
"url": "https://serverlessworkflow.io/schemas/1.0.0/workflow.json"
}
],
"commands": [
{
"command": "serverlessWorkflow.diagram.preview",
Expand Down Expand Up @@ -54,7 +59,7 @@
"group": "2_workspace"
}
],
"editor/context": [
"editor/context": [
{
"when": "resourceLangId == json || resourceLangId == yaml",
"command": "serverlessWorkflow.diagram.preview",
Expand All @@ -70,7 +75,7 @@
"command": "serverlessWorkflow.diagram.png",
"group": "2_workspace"
}
]
]
},
"snippets": [
{
Expand All @@ -82,20 +87,29 @@
"path": "./snippets/serverless-workflow.yaml.code-snippets"
}
],
"keybindings": [
{
"command": "serverlessWorkflow.diagram.preview",
"key": "alt+shift+s p"
},
{
"command": "serverlessWorkflow.diagram.svg",
"key": "alt+shift+s v"
},
{
"command": "serverlessWorkflow.diagram.png",
"key": "alt+shift+s i"
}
]
"keybindings": [
{
"command": "serverlessWorkflow.diagram.preview",
"key": "alt+shift+s p"
},
{
"command": "serverlessWorkflow.diagram.svg",
"key": "alt+shift+s v"
},
{
"command": "serverlessWorkflow.diagram.png",
"key": "alt+shift+s i"
}
],
"configurationDefaults": {
"[yaml]": {
"editor.quickSuggestions.other": true,
"editor.quickSuggestions.strings": true
},
"yaml.schemas": {
"https://serverlessworkflow.io/schemas/1.0.0/workflow.json": ["*.yml", "*.yaml"]
}
}
},
"scripts": {
"vscode:prepublish": "npm run compile",
Expand All @@ -117,8 +131,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@severlessworkflow/sdk-typescript": "^3.0.3",
"mermaid": "^10.8.0",
"@serverlessworkflow/sdk": "^1.0.1",
"mermaid": "^11.6.0",
"npm": "^10.4.0"
}
}
75 changes: 47 additions & 28 deletions snippets/serverless-workflow.json.code-snippets
Original file line number Diff line number Diff line change
@@ -1,37 +1,56 @@
{
"New YAML Workflow": {
"scope": "yaml",
"prefix": ["swy", "serverless-workflow-yaml"],
"body": [
"id: ${1:id}",
"name: ${2:name}",
"version: ${3:version}",
"functions: []",
"events: []",
"states: []"
],
"description": "An empty Serverless Workflow"
},

"New JSON Workflow": {
"scope": "json",
"prefix": ["swj", "serverless-workflow-json"],
"body": [
"{",
"\"id\": \"${1:id}\",",
"\"name\": \"${2:name}\",",
"\"version\": \"${3:version}\",",
"\"functions\": [",
"",
"],",
"\"events\": [",
"",
"],",
"\"states\": [",
"",
"]",
"}"
" \"document\": {",
" \"dsl\": \"1.0.0\",",
" \"namespace\": \"default\",",
" \"name\": \"sample-workflow\",",
" \"version\": \"0.1.0\",",
" \"title\": \"A Sample Workflow\",",
" \"summary\": \"A sample workflow generated by the VSCode extension\",",
" \"tags\": {},",
" \"metadata\": {}",
" },",
" \"do\": [",
" {",
" \"step1\": {",
" \"set\": {",
" \"someVariable\": \"${ .data }\"",
" }",
" }",
" }",
" ],",
" \"input\": {",
" \"schema\": {",
" \"format\": \"json\",",
" \"document\": {",
" \"type\": \"object\",",
" \"properties\": {",
" \"data\": {",
" \"type\": \"string\"",
" }",
" }",
" }",
" }",
" },",
" \"output\": {",
" \"schema\": {",
" \"format\": \"json\",",
" \"document\": {",
" \"type\": \"object\",",
" \"properties\": {",
" \"data\": {",
" \"someVariable\": \"string\"",
" }",
" }",
" }",
" }",
" }",
"}"
],
"description": "An empty Serverless Workflow"
"description": "A sample JSON Serverless Workflow"
}
}
37 changes: 30 additions & 7 deletions snippets/serverless-workflow.yaml.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,37 @@
"New YAML Workflow": {
"prefix": ["swy", "serverless-workflow-yaml"],
"body": [
"id: ${1:id}",
"name: ${2:name}",
"version: ${3:version}",
"functions: []",
"events: []",
"states: []"
"document:",
" dsl: '1.0.0'",
" namespace: default",
" name: sample-workflow",
" version: '0.1.0'",
" title: 'A Sample Workflow'",
" summary: 'A sample workflow generated by the VSCode extension'",
" tags: {}",
" metadata: {}",
"do:",
"- step1:",
" set:",
" someVariable: ${ .data }",
"input:",
" schema:",
" format: json",
" document:",
" type: object",
" properties:",
" data:",
" type: string",
"output:",
" schema:",
" format: json",
" document:",
" type: object",
" properties:",
" data:",
" someVariable: string"
],
"description": "An empty Serverless Workflow"
"description": "A sample YAML Serverless Workflow"
},

}
11 changes: 8 additions & 3 deletions src/diagram-panel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as vscode from 'vscode';
import * as path from 'path';

import { MermaidDiagram, Specification } from '@severlessworkflow/sdk-typescript';
import {
MermaidDiagram,
Specification,
Classes
} from '@serverlessworkflow/sdk';

export const diagramViewPanelType = 'serverlessWorkflowDiagramPanel';
export const diagramViewPanelTitle = 'Diagram Preview';
Expand Down Expand Up @@ -75,6 +79,7 @@ export class DiagramPanel {
);
vscode.workspace.onDidChangeTextDocument(
(event) => {
console.log('onDidChangeTextDocument -- diagram');
if (event.document === this.#target) {
this.#updateDiagram();
}
Expand Down Expand Up @@ -225,7 +230,7 @@ export class DiagramPanel {
case 'general-exception':
{
const { ex } = args;
await vscode.window.showErrorMessage(`An error occured while processing the workflow: ${JSON.stringify(ex)}`)
await vscode.window.showErrorMessage(`An error occured while processing the workflow: ${JSON.stringify(ex)}`);
}
}
}
Expand All @@ -249,7 +254,7 @@ export class DiagramPanel {
}
let graphDefinition: string | undefined;
try {
const workflow: Specification.Workflow = Specification.Workflow.fromSource(content);
const workflow: Specification.Workflow = Classes.Workflow.deserialize(content);
graphDefinition = new MermaidDiagram(workflow).sourceCode();
}
catch (ex) {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"target": "ES2022",
"outDir": "out",
"lib": [
"DOM",
"ES2022"
],
"sourceMap": true,
Expand Down