Skip to content

Commit a459962

Browse files
committed
feat: migrate to specification v1.0.0
Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
1 parent 025f3a9 commit a459962

7 files changed

+938
-802
lines changed

.vscode/extensions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// for the documentation about the extensions.json format
44
"recommendations": [
55
"dbaeumer.vscode-eslint",
6-
"ms-vscode.extension-test-runner"
6+
"ms-vscode.extension-test-runner",
7+
"redhat.vscode-yaml"
78
]
89
}

package-lock.json

+811-738
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+39-25
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
"name": "serverless-workflow",
33
"displayName": "Serverless Workflow",
44
"description": "",
5-
"version": "2.0.0",
5+
"version": "2.1.0",
66
"engines": {
77
"vscode": "^1.86.0"
88
},
99
"categories": [
10+
"Snippets",
1011
"Other"
1112
],
1213
"activationEvents": [
@@ -16,12 +17,16 @@
1617
],
1718
"main": "./out/extension.js",
1819
"contributes": {
19-
"jsonValidation": [
20-
{
21-
"fileMatch": ["*.json", "*.yml", "*.yaml"],
22-
"url": "https://serverlessworkflow.io/schemas/latest/workflow.json"
23-
}
24-
],
20+
"jsonValidation": [
21+
{
22+
"fileMatch": [
23+
"*.json",
24+
"*.yml",
25+
"*.yaml"
26+
],
27+
"url": "https://serverlessworkflow.io/schemas/1.0.0/workflow.json"
28+
}
29+
],
2530
"commands": [
2631
{
2732
"command": "serverlessWorkflow.diagram.preview",
@@ -54,7 +59,7 @@
5459
"group": "2_workspace"
5560
}
5661
],
57-
"editor/context": [
62+
"editor/context": [
5863
{
5964
"when": "resourceLangId == json || resourceLangId == yaml",
6065
"command": "serverlessWorkflow.diagram.preview",
@@ -70,7 +75,7 @@
7075
"command": "serverlessWorkflow.diagram.png",
7176
"group": "2_workspace"
7277
}
73-
]
78+
]
7479
},
7580
"snippets": [
7681
{
@@ -82,20 +87,29 @@
8287
"path": "./snippets/serverless-workflow.yaml.code-snippets"
8388
}
8489
],
85-
"keybindings": [
86-
{
87-
"command": "serverlessWorkflow.diagram.preview",
88-
"key": "alt+shift+s p"
89-
},
90-
{
91-
"command": "serverlessWorkflow.diagram.svg",
92-
"key": "alt+shift+s v"
93-
},
94-
{
95-
"command": "serverlessWorkflow.diagram.png",
96-
"key": "alt+shift+s i"
97-
}
98-
]
90+
"keybindings": [
91+
{
92+
"command": "serverlessWorkflow.diagram.preview",
93+
"key": "alt+shift+s p"
94+
},
95+
{
96+
"command": "serverlessWorkflow.diagram.svg",
97+
"key": "alt+shift+s v"
98+
},
99+
{
100+
"command": "serverlessWorkflow.diagram.png",
101+
"key": "alt+shift+s i"
102+
}
103+
],
104+
"configurationDefaults": {
105+
"[yaml]": {
106+
"editor.quickSuggestions.other": true,
107+
"editor.quickSuggestions.strings": true
108+
},
109+
"yaml.schemas": {
110+
"https://serverlessworkflow.io/schemas/1.0.0/workflow.json": ["*.yml", "*.yaml"]
111+
}
112+
}
99113
},
100114
"scripts": {
101115
"vscode:prepublish": "npm run compile",
@@ -117,8 +131,8 @@
117131
"typescript": "^5.3.3"
118132
},
119133
"dependencies": {
120-
"@severlessworkflow/sdk-typescript": "^3.0.3",
121-
"mermaid": "^10.8.0",
134+
"@serverlessworkflow/sdk": "^1.0.1",
135+
"mermaid": "^11.6.0",
122136
"npm": "^10.4.0"
123137
}
124138
}
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,56 @@
11
{
2-
"New YAML Workflow": {
3-
"scope": "yaml",
4-
"prefix": ["swy", "serverless-workflow-yaml"],
5-
"body": [
6-
"id: ${1:id}",
7-
"name: ${2:name}",
8-
"version: ${3:version}",
9-
"functions: []",
10-
"events: []",
11-
"states: []"
12-
],
13-
"description": "An empty Serverless Workflow"
14-
},
15-
162
"New JSON Workflow": {
173
"scope": "json",
184
"prefix": ["swj", "serverless-workflow-json"],
195
"body": [
206
"{",
21-
"\"id\": \"${1:id}\",",
22-
"\"name\": \"${2:name}\",",
23-
"\"version\": \"${3:version}\",",
24-
"\"functions\": [",
25-
"",
26-
"],",
27-
"\"events\": [",
28-
"",
29-
"],",
30-
"\"states\": [",
31-
"",
32-
"]",
33-
"}"
7+
" \"document\": {",
8+
" \"dsl\": \"1.0.0\",",
9+
" \"namespace\": \"default\",",
10+
" \"name\": \"sample-workflow\",",
11+
" \"version\": \"0.1.0\",",
12+
" \"title\": \"A Sample Workflow\",",
13+
" \"summary\": \"A sample workflow generated by the VSCode extension\",",
14+
" \"tags\": {},",
15+
" \"metadata\": {}",
16+
" },",
17+
" \"do\": [",
18+
" {",
19+
" \"step1\": {",
20+
" \"set\": {",
21+
" \"someVariable\": \"${ .data }\"",
22+
" }",
23+
" }",
24+
" }",
25+
" ],",
26+
" \"input\": {",
27+
" \"schema\": {",
28+
" \"format\": \"json\",",
29+
" \"document\": {",
30+
" \"type\": \"object\",",
31+
" \"properties\": {",
32+
" \"data\": {",
33+
" \"type\": \"string\"",
34+
" }",
35+
" }",
36+
" }",
37+
" }",
38+
" },",
39+
" \"output\": {",
40+
" \"schema\": {",
41+
" \"format\": \"json\",",
42+
" \"document\": {",
43+
" \"type\": \"object\",",
44+
" \"properties\": {",
45+
" \"data\": {",
46+
" \"someVariable\": \"string\"",
47+
" }",
48+
" }",
49+
" }",
50+
" }",
51+
" }",
52+
"}"
3453
],
35-
"description": "An empty Serverless Workflow"
54+
"description": "A sample JSON Serverless Workflow"
3655
}
3756
}

snippets/serverless-workflow.yaml.code-snippets

+30-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,37 @@
22
"New YAML Workflow": {
33
"prefix": ["swy", "serverless-workflow-yaml"],
44
"body": [
5-
"id: ${1:id}",
6-
"name: ${2:name}",
7-
"version: ${3:version}",
8-
"functions: []",
9-
"events: []",
10-
"states: []"
5+
"document:",
6+
" dsl: '1.0.0'",
7+
" namespace: default",
8+
" name: sample-workflow",
9+
" version: '0.1.0'",
10+
" title: 'A Sample Workflow'",
11+
" summary: 'A sample workflow generated by the VSCode extension'",
12+
" tags: {}",
13+
" metadata: {}",
14+
"do:",
15+
"- step1:",
16+
" set:",
17+
" someVariable: ${ .data }",
18+
"input:",
19+
" schema:",
20+
" format: json",
21+
" document:",
22+
" type: object",
23+
" properties:",
24+
" data:",
25+
" type: string",
26+
"output:",
27+
" schema:",
28+
" format: json",
29+
" document:",
30+
" type: object",
31+
" properties:",
32+
" data:",
33+
" someVariable: string"
1134
],
12-
"description": "An empty Serverless Workflow"
35+
"description": "A sample YAML Serverless Workflow"
1336
},
1437

1538
}

src/diagram-panel.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import * as vscode from 'vscode';
22
import * as path from 'path';
33

4-
import { MermaidDiagram, Specification } from '@severlessworkflow/sdk-typescript';
4+
import {
5+
MermaidDiagram,
6+
Specification,
7+
Classes
8+
} from '@serverlessworkflow/sdk';
59

610
export const diagramViewPanelType = 'serverlessWorkflowDiagramPanel';
711
export const diagramViewPanelTitle = 'Diagram Preview';
@@ -75,6 +79,7 @@ export class DiagramPanel {
7579
);
7680
vscode.workspace.onDidChangeTextDocument(
7781
(event) => {
82+
console.log('onDidChangeTextDocument -- diagram');
7883
if (event.document === this.#target) {
7984
this.#updateDiagram();
8085
}
@@ -225,7 +230,7 @@ export class DiagramPanel {
225230
case 'general-exception':
226231
{
227232
const { ex } = args;
228-
await vscode.window.showErrorMessage(`An error occured while processing the workflow: ${JSON.stringify(ex)}`)
233+
await vscode.window.showErrorMessage(`An error occured while processing the workflow: ${JSON.stringify(ex)}`);
229234
}
230235
}
231236
}
@@ -249,7 +254,7 @@ export class DiagramPanel {
249254
}
250255
let graphDefinition: string | undefined;
251256
try {
252-
const workflow: Specification.Workflow = Specification.Workflow.fromSource(content);
257+
const workflow: Specification.Workflow = Classes.Workflow.deserialize(content);
253258
graphDefinition = new MermaidDiagram(workflow).sourceCode();
254259
}
255260
catch (ex) {

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"target": "ES2022",
55
"outDir": "out",
66
"lib": [
7+
"DOM",
78
"ES2022"
89
],
910
"sourceMap": true,

0 commit comments

Comments
 (0)