@serverlessworkflow/sdk 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -158,6 +158,8 @@ export declare const Classes: {
158
158
  Workflow: import("./workflow").WorkflowConstructor & {
159
159
  deserialize(text: string): import("./workflow").WorkflowIntersection;
160
160
  serialize(workflow: Partial<import("./workflow").WorkflowIntersection>, format?: "yaml" | "json", normalize?: boolean): string;
161
+ toGraph(workflow: Partial<import("./workflow").WorkflowIntersection>): import("../../graph-builder").Graph;
162
+ toMermaidCode(workflow: Partial<import("./workflow").WorkflowIntersection>): string;
161
163
  };
162
164
  WorkflowMetadata: import("./workflow-metadata").WorkflowMetadataConstructor;
163
165
  WorkflowTags: import("./workflow-tags").WorkflowTagsConstructor;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/generated/classes/index.ts"],"names":[],"mappings":"AAiLA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiKnB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/generated/classes/index.ts"],"names":[],"mappings":"AAiLA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiKnB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { ObjectHydrator } from '../../hydrator';
2
2
  import { Specification } from '../definitions';
3
+ import { Graph } from '../../graph-builder';
3
4
  /**
4
5
  * Represents the intersection between the Workflow class and type
5
6
  */
@@ -36,6 +37,8 @@ export declare class Workflow extends ObjectHydrator<Specification.Workflow> {
36
37
  normalize(): Workflow & Specification.Workflow;
37
38
  static deserialize(text: string): WorkflowIntersection;
38
39
  static serialize(model: Partial<WorkflowIntersection>, format?: 'yaml' | 'json', normalize?: boolean): string;
40
+ static toGraph(model: Partial<WorkflowIntersection>): Graph;
41
+ static toMermaidCode(model: Partial<WorkflowIntersection>): string;
39
42
  /**
40
43
  * Serializes the workflow to YAML or JSON
41
44
  * @param format The format, 'yaml' or 'json', default is 'yaml'
@@ -43,6 +46,16 @@ export declare class Workflow extends ObjectHydrator<Specification.Workflow> {
43
46
  * @returns A string representation of the workflow
44
47
  */
45
48
  serialize(format?: 'yaml' | 'json', normalize?: boolean): string;
49
+ /**
50
+ * Creates a directed graph representation of the workflow
51
+ * @returns A directed graph of the workflow
52
+ */
53
+ toGraph(): Graph;
54
+ /**
55
+ * Generates the MermaidJS code corresponding to the workflow
56
+ * @returns The MermaidJS code
57
+ */
58
+ toMermaidCode(): string;
46
59
  }
47
60
  export declare const _Workflow: WorkflowConstructor & {
48
61
  /**
@@ -59,5 +72,17 @@ export declare const _Workflow: WorkflowConstructor & {
59
72
  * @returns A string representation of the workflow
60
73
  */
61
74
  serialize(workflow: Partial<WorkflowIntersection>, format?: "yaml" | "json", normalize?: boolean): string;
75
+ /**
76
+ * Creates a directed graph representation of the provided workflow
77
+ * @param workflow The workflow to convert
78
+ * @returns A directed graph of the provided workflow
79
+ */
80
+ toGraph(workflow: Partial<WorkflowIntersection>): Graph;
81
+ /**
82
+ * Generates the MermaidJS code corresponding to the provided workflow
83
+ * @param workflow The workflow to convert
84
+ * @returns The MermaidJS code
85
+ */
86
+ toMermaidCode(workflow: Partial<WorkflowIntersection>): string;
62
87
  };
63
88
  //# sourceMappingURL=workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.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C,MAAM,GAAE,MAAM,GAAG,MAAe,EAAE,SAAS,GAAE,OAAc,GAAG,MAAM;IAI9E;;;OAGG;IACH,OAAO,IAAI,KAAK;IAIhB;;;OAGG;IACH,aAAa,IAAI,MAAM;CAGxB;AAED,eAAO,MAAM,SAAS,EAAe,mBAAmB,GAAG;IACzD;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAEhD;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE1G;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC;IAExD;;;;OAIG;IACH,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC;CAChE,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { Workflow } from './generated/definitions/specification';
2
+ /**
3
+ * Represents a generic within a graph.
4
+ * This serves as a base type for nodes, edges, and graphs.
5
+ */
6
+ export type GraphElement = {
7
+ /** A unique identifier for this graph element. */
8
+ id: string;
9
+ /** An optional label to provide additional context or naming. */
10
+ label?: string | null;
11
+ };
12
+ /**
13
+ * Enumeration of possible node types in a graph.
14
+ */
15
+ export declare enum GraphNodeType {
16
+ Root = "root",
17
+ Start = "start",
18
+ End = "end",
19
+ Entry = "entry",
20
+ Exit = "exit",
21
+ Call = "call",
22
+ Catch = "catch",
23
+ Do = "do",
24
+ Emit = "emit",
25
+ For = "for",
26
+ Fork = "fork",
27
+ Listen = "listen",
28
+ Raise = "raise",
29
+ Run = "run",
30
+ Set = "set",
31
+ Switch = "switch",
32
+ Try = "try",
33
+ TryCatch = "try-catch",
34
+ Wait = "wait"
35
+ }
36
+ /**
37
+ * Represents a node within the graph.
38
+ */
39
+ export type GraphNode = GraphElement & {
40
+ /** The type of the node. */
41
+ type: GraphNodeType;
42
+ };
43
+ /**
44
+ * Represents a directed edge connecting two nodes in the graph.
45
+ */
46
+ export type GraphEdge = GraphElement & {
47
+ /** The unique identifier of the node where the edge originates. */
48
+ sourceId: string;
49
+ /** The unique identifier of the node where the edge terminates. */
50
+ destinationId: string;
51
+ };
52
+ /**
53
+ * Represents a graph or a subgraph
54
+ */
55
+ export type Graph = GraphNode & {
56
+ /** The parent graph if this is a subgraph, otherwise null. */
57
+ parent?: Graph | null;
58
+ /** A collection of nodes that belong to this graph. */
59
+ nodes: GraphNode[];
60
+ /** A collection of edges that define relationships between nodes. */
61
+ edges: GraphEdge[];
62
+ /** The entry node of the graph. */
63
+ entryNode: GraphNode;
64
+ /** The exit node of the graph. */
65
+ exitNode: GraphNode;
66
+ };
67
+ /**
68
+ * Constructs a graph representation based on the given workflow.
69
+ *
70
+ * @param workflow The workflow to be converted into a graph structure.
71
+ * @returns A graph representation of the workflow.
72
+ */
73
+ export declare function buildGraph(workflow: Workflow): Graph;
74
+ //# sourceMappingURL=graph-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-builder.d.ts","sourceRoot":"","sources":["../../../src/lib/graph-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAeL,QAAQ,EACT,MAAM,uCAAuC,CAAC;AAa/C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;IACf,EAAE,OAAO;IACT,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,QAAQ,cAAc;IACtB,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG;IACrC,4BAA4B;IAC5B,IAAI,EAAE,aAAa,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG;IACrC,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG;IAC9B,8DAA8D;IAC9D,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACtB,uDAAuD;IACvD,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,qEAAqE;IACrE,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,mCAAmC;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAuFF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CASpD"}
@@ -0,0 +1,21 @@
1
+ import { Workflow } from './generated/definitions/specification';
2
+ /**
3
+ * Converts the provided workflow to Mermaid code
4
+ * @param workflow The workflow to convert
5
+ * @returns The Mermaid diagram
6
+ */
7
+ export declare function convertToMermaidCode(workflow: Workflow): string;
8
+ /**
9
+ * Represents a Mermaid diagram generator for a given workflow.
10
+ * This class takes a workflow definition and converts it into a Mermaid.js-compatible diagram.
11
+ */
12
+ export declare class MermaidDiagram {
13
+ private workflow;
14
+ constructor(workflow: Workflow);
15
+ /**
16
+ * Generates the Mermaid code representation of the workflow.
17
+ * @returns The Mermaid diagram source code as a string.
18
+ */
19
+ sourceCode(): string;
20
+ }
21
+ //# sourceMappingURL=mermaid-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mermaid-converter.d.ts","sourceRoot":"","sources":["../../../src/lib/mermaid-converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAsEjE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAQ/D;AAED;;;GAGG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAEtC;;;OAGG;IACH,UAAU,IAAI,MAAM;CAGrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serverlessworkflow/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "schemaVersion": "1.0.0",
5
5
  "description": "Typescript SDK for Serverless Workflow Specification",
6
6
  "main": "umd/index.umd.min.js",
@@ -2,4 +2,6 @@ export * from './lib/generated/builders';
2
2
  export * from './lib/generated/classes';
3
3
  export * from './lib/generated/definitions';
4
4
  export * from './lib/validation';
5
+ export * from './lib/graph-builder';
6
+ export * from './lib/mermaid-converter';
5
7
  //# sourceMappingURL=serverless-workflow-sdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serverless-workflow-sdk.d.ts","sourceRoot":"","sources":["../../src/serverless-workflow-sdk.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"serverless-workflow-sdk.d.ts","sourceRoot":"","sources":["../../src/serverless-workflow-sdk.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}