otomato-sdk 1.2.0 → 1.3.0

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.
Files changed (55) hide show
  1. package/dist/examples/create-action.js +2 -2
  2. package/dist/examples/create-automation.js +2 -8
  3. package/dist/examples/create-trigger.js +2 -2
  4. package/dist/examples/create-workflow.js +44 -0
  5. package/dist/examples/load-workflow.js +16 -0
  6. package/dist/examples/sandbox.js +18 -0
  7. package/dist/src/constants/Blocks.js +422 -293
  8. package/dist/src/index.js +1 -1
  9. package/dist/src/models/Edge.js +6 -1
  10. package/dist/src/models/Node.js +79 -6
  11. package/dist/src/models/Trigger.js +6 -3
  12. package/dist/src/models/Workflow.js +67 -0
  13. package/dist/src/services/ApiService.js +24 -18
  14. package/dist/src/utils/typeValidator.js +2 -1
  15. package/dist/test/action.spec.js +20 -17
  16. package/dist/test/automation.spec.js +26 -25
  17. package/dist/test/node.spec.js +34 -30
  18. package/dist/test/trigger.spec.js +8 -3
  19. package/dist/test/typeValidator.spec.js +2 -1
  20. package/dist/types/examples/create-workflow.d.ts +1 -0
  21. package/dist/types/examples/load-workflow.d.ts +1 -0
  22. package/dist/types/examples/sandbox.d.ts +1 -0
  23. package/dist/types/src/constants/Blocks.d.ts +101 -29
  24. package/dist/types/src/index.d.ts +1 -1
  25. package/dist/types/src/models/Action.d.ts +2 -1
  26. package/dist/types/src/models/Edge.d.ts +3 -0
  27. package/dist/types/src/models/Node.d.ts +9 -2
  28. package/dist/types/src/models/Parameter.d.ts +1 -1
  29. package/dist/types/src/models/Trigger.d.ts +3 -1
  30. package/dist/types/src/models/Workflow.d.ts +26 -0
  31. package/dist/types/src/services/ApiService.d.ts +8 -3
  32. package/examples/create-action.ts +2 -2
  33. package/examples/create-trigger.ts +2 -2
  34. package/examples/create-workflow.ts +44 -0
  35. package/examples/load-workflow.ts +10 -0
  36. package/package.json +2 -3
  37. package/src/constants/Blocks.ts +422 -292
  38. package/src/index.ts +1 -1
  39. package/src/models/Action.ts +1 -1
  40. package/src/models/Condition.ts +5 -5
  41. package/src/models/Edge.ts +8 -2
  42. package/src/models/Node.ts +90 -10
  43. package/src/models/Parameter.ts +5 -5
  44. package/src/models/Trigger.ts +9 -5
  45. package/src/models/Workflow.ts +69 -0
  46. package/src/services/ApiService.ts +26 -19
  47. package/src/utils/typeValidator.ts +2 -1
  48. package/test/action.spec.ts +11 -9
  49. package/test/automation.spec.ts +27 -26
  50. package/test/node.spec.ts +34 -30
  51. package/test/trigger.spec.ts +8 -3
  52. package/test/typeValidator.spec.ts +2 -1
  53. package/examples/create-automation.ts +0 -41
  54. package/src/constants/json.json +0 -16
  55. package/src/models/Automation.ts +0 -47
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ export * from './constants/tokens.js';
5
5
 
6
6
  // Exporting models
7
7
  export * from './models/Action.js';
8
- export * from './models/Automation.js';
8
+ export * from './models/Workflow.js';
9
9
  export * from './models/Condition.js';
10
10
  export * from './models/Parameter.js';
11
11
  export * from './models/Trigger.js';
@@ -2,7 +2,7 @@ import { Parameter } from './Parameter.js';
2
2
  import { Node, Position } from './Node.js';
3
3
 
4
4
  export class Action extends Node {
5
- constructor(action: { id: number; name: string; description: string; parameters: Parameter[], ref?: string, position?: Position }) {
5
+ constructor(action: { blockId: number; name: string; description: string; parameters: Parameter[], image: string, ref?: string, position?: Position }) {
6
6
  super({ ...action, class: 'action' });
7
7
  }
8
8
  }
@@ -1,6 +1,6 @@
1
1
  export interface COndition {
2
- key: string;
3
- type: string;
4
- description: string;
5
- value: any;
6
- }
2
+ key: string;
3
+ type: string;
4
+ description: string;
5
+ value: any;
6
+ }
@@ -25,9 +25,15 @@ export class Edge {
25
25
 
26
26
  toJSON(): { [key: string]: any } {
27
27
  return {
28
- id: this.id,
29
28
  source: this.source.getRef(),
30
29
  target: this.target.getRef(),
31
30
  };
32
31
  }
33
- }
32
+
33
+ static fromJSON(json: { [key: string]: any }): Edge {
34
+ return new Edge({
35
+ source: json.source,
36
+ target: json.target,
37
+ });
38
+ }
39
+ }
@@ -1,5 +1,8 @@
1
+ // Assuming you have the ACTIONS constant defined as you provided
2
+
1
3
  import { Parameter } from './Parameter.js';
2
4
  import { validateType } from '../utils/typeValidator.js';
5
+ import { ACTIONS, TRIGGERS } from '../constants/Blocks.js';
3
6
 
4
7
  export interface Position {
5
8
  x: number;
@@ -10,23 +13,27 @@ let nodeCounter = 0;
10
13
  const generatedRefs = new Set<string>();
11
14
 
12
15
  export class Node {
13
- id: number;
16
+ id: string | null = null;
17
+ blockId: number;
14
18
  name: string;
15
19
  description: string;
16
20
  parameters: { [key: string]: Parameter };
17
21
  keyMap: { [key: string]: string };
18
22
  position?: Position;
19
23
  ref: string;
20
- class: string; // Updated to use class instead of type
24
+ class: string;
25
+ image: string;
21
26
 
22
- constructor(node: { id: number; name: string; description: string; parameters: Parameter[], ref?: string, position?: Position, class: string }) {
23
- this.id = node.id;
27
+ constructor(node: { blockId: number; name: string; description: string; parameters: Parameter[], ref?: string, position?: Position, class: string; image: string }) {
28
+ this.id = null;
29
+ this.blockId = node.blockId;
24
30
  this.name = node.name;
25
31
  this.description = node.description;
32
+ this.image = node.image;
26
33
  this.parameters = {};
27
34
  this.keyMap = {};
28
- this.class = node.class; // Set class property
29
-
35
+ this.class = node.class;
36
+
30
37
  if (node.ref) {
31
38
  this.ref = node.ref;
32
39
  } else {
@@ -48,6 +55,10 @@ export class Node {
48
55
  }
49
56
  }
50
57
 
58
+ setId(id: string): void {
59
+ this.id = id;
60
+ }
61
+
51
62
  setChainId(value: number): void {
52
63
  this.setParameter('chainId', value);
53
64
  }
@@ -92,7 +103,15 @@ export class Node {
92
103
 
93
104
  getParameters(): { [key: string]: any } {
94
105
  return Object.keys(this.parameters).reduce((acc, key) => {
95
- acc[key] = this.parameters[key].value;
106
+ if (key.startsWith('abiParams.')) {
107
+ const abiKey = key.replace('abiParams.', '');
108
+ if (!acc.abi) {
109
+ acc.abi = { parameters: {} };
110
+ }
111
+ acc.abi.parameters[abiKey] = this.parameters[key].value;
112
+ } else {
113
+ acc[key] = this.parameters[key].value;
114
+ }
96
115
  return acc;
97
116
  }, {} as { [key: string]: any });
98
117
  }
@@ -101,10 +120,9 @@ export class Node {
101
120
  const json: { [key: string]: any } = {
102
121
  id: this.id,
103
122
  ref: this.ref,
123
+ blockId: this.blockId,
104
124
  type: this.class,
105
- data: {
106
- parameters: this.getParameters(),
107
- }
125
+ parameters: this.getParameters(),
108
126
  };
109
127
  if (this.position) {
110
128
  json.position = this.position;
@@ -115,4 +133,66 @@ export class Node {
115
133
  private getSimplifiedKey(key: string): string {
116
134
  return key.replace(/[.\[\]]/g, '_');
117
135
  }
136
+
137
+ static fromJSON(json: { [key: string]: any }): Node {
138
+
139
+ let enriched = findActionByBlockId(json.blockId);
140
+ if (!enriched)
141
+ enriched = findTriggerByBlockId(json.blockId);
142
+ if (!enriched)
143
+ enriched = {name: "Unknown", description: "Unknown", image: "Unknown"}
144
+
145
+ const parameters = Object.keys(json.parameters).map(key => ({
146
+ key,
147
+ type: typeof json.parameters[key], // Assuming type can be derived from the value's type
148
+ description: '', // Add appropriate description if needed
149
+ value: json.parameters[key]
150
+ }));
151
+ const node = new Node({
152
+ blockId: json.blockId,
153
+ name: enriched.name,
154
+ description: enriched.description,
155
+ image: enriched.image,
156
+ parameters,
157
+ ref: json.ref,
158
+ position: json.position,
159
+ class: json.type
160
+ });
161
+ node.setId(json.id);
162
+ return node;
163
+ }
118
164
  }
165
+
166
+ const findActionByBlockId = (blockId: number): { name: string; description: string; image: string } | null => {
167
+ for (const category in ACTIONS) {
168
+ for (const service in (ACTIONS as any)[category]) {
169
+ for (const actionKey in (ACTIONS as any)[category][service]) {
170
+ if ((ACTIONS as any)[category][service][actionKey].blockId === blockId) {
171
+ return {
172
+ name: (ACTIONS as any)[category][service][actionKey].name,
173
+ description: (ACTIONS as any)[category][service][actionKey].description,
174
+ image: (ACTIONS as any)[category][service][actionKey].image,
175
+ };
176
+ }
177
+ }
178
+ }
179
+ }
180
+ return null;
181
+ };
182
+
183
+ const findTriggerByBlockId = (blockId: number): { name: string; description: string; image: string } | null => {
184
+ for (const category in TRIGGERS) {
185
+ for (const service in (TRIGGERS as any)[category]) {
186
+ for (const triggerKey in (TRIGGERS as any)[category][service]) {
187
+ if ((TRIGGERS as any)[category][service][triggerKey].blockId === blockId) {
188
+ return {
189
+ name: (TRIGGERS as any)[category][service][triggerKey].name,
190
+ description: (TRIGGERS as any)[category][service][triggerKey].description,
191
+ image: (TRIGGERS as any)[category][service][triggerKey].image,
192
+ };
193
+ }
194
+ }
195
+ }
196
+ }
197
+ return null;
198
+ };
@@ -1,6 +1,6 @@
1
1
  export interface Parameter {
2
- key: string;
3
- type: string;
4
- description: string;
5
- value: any;
6
- }
2
+ key: string;
3
+ type: string;
4
+ description: string;
5
+ value?: any;
6
+ }
@@ -4,29 +4,33 @@ import { Node, Position } from './Node.js';
4
4
  export class Trigger extends Node {
5
5
  type: number;
6
6
 
7
- constructor(trigger: { id: number; name: string; description: string; type: number; parameters: Parameter[], ref?: string, position?: Position }) {
7
+ constructor(trigger: { blockId: number; name: string; description: string; type: number; parameters: Parameter[], image: string, ref?: string, position?: Position }) {
8
8
  super({ ...trigger, class: 'trigger' });
9
9
  this.type = trigger.type;
10
10
  }
11
11
 
12
+ private notAPollingTrigger(): boolean {
13
+ return this.type === 0;
14
+ }
15
+
12
16
  setCondition(value: string): void {
13
- if (this.type !== 1) {
17
+ if (this.notAPollingTrigger()) {
14
18
  throw new Error('Condition setting is not applicable for subscription based triggers.');
15
19
  }
16
20
  this.setParameter('condition', value);
17
21
  }
18
22
 
19
23
  setComparisonValue(value: number): void {
20
- if (this.type !== 1) {
24
+ if (this.notAPollingTrigger()) {
21
25
  throw new Error('Comparison value setting is not applicable for subscription based triggers.');
22
26
  }
23
27
  this.setParameter('comparisonValue', value);
24
28
  }
25
29
 
26
30
  setInterval(value: number): void {
27
- if (this.type !== 1) {
31
+ if (this.notAPollingTrigger()) {
28
32
  throw new Error('Interval setting is not applicable for subscription based triggers.');
29
33
  }
30
34
  this.setParameter('interval', value);
31
35
  }
32
- }
36
+ }
@@ -0,0 +1,69 @@
1
+ import { Node } from './Node.js';
2
+ import { Edge } from './Edge.js';
3
+ import { apiServices } from '../services/ApiService.js';
4
+
5
+ export class Workflow {
6
+ id: string | null = null;
7
+ name: string;
8
+ nodes: Node[];
9
+ edges: Edge[];
10
+
11
+ constructor(name: string = '', nodes: Node[] = [], edges: Edge[] = []) {
12
+ this.name = name;
13
+ this.nodes = nodes;
14
+ this.edges = edges;
15
+ }
16
+
17
+ setName(name: string): void {
18
+ this.name = name;
19
+ }
20
+
21
+ addNode(node: Node): void {
22
+ this.nodes.push(node);
23
+ }
24
+
25
+ addNodes(nodes: Node[]): void {
26
+ this.nodes.push(...nodes);
27
+ }
28
+
29
+ addEdge(edge: Edge): void {
30
+ this.edges.push(edge);
31
+ }
32
+
33
+ addEdges(edges: Edge[]): void {
34
+ this.edges.push(...edges);
35
+ }
36
+
37
+ toJSON() {
38
+ return {
39
+ id: this.id,
40
+ name: this.name,
41
+ nodes: this.nodes.map(node => node.toJSON()),
42
+ edges: this.edges.map(edge => edge.toJSON()),
43
+ };
44
+ }
45
+
46
+ async create() {
47
+ const response = await apiServices.post('/workflows', this.toJSON());
48
+ this.id = response.id; // Assign the returned ID to the workflow instance
49
+
50
+ // Assign IDs to the nodes based on the response
51
+ response.nodes.forEach((nodeResponse: any) => {
52
+ const node = this.nodes.find(n => n.getRef() === nodeResponse.ref);
53
+ if (node) {
54
+ node.setId(nodeResponse.id);
55
+ }
56
+ });
57
+
58
+ return response;
59
+ }
60
+
61
+ async load(workflowId: string): Promise<Workflow> {
62
+ const response = await apiServices.get(`/workflows/${workflowId}`);
63
+ this.id = response.id;
64
+ this.name = response.name;
65
+ this.nodes = response.nodes.map((nodeData: any) => Node.fromJSON(nodeData));
66
+ this.edges = response.edges.map((edgeData: any) => Edge.fromJSON(edgeData));
67
+ return this;
68
+ }
69
+ }
@@ -2,30 +2,37 @@
2
2
  import axios from 'axios';
3
3
 
4
4
  const API_CONFIG = {
5
- BASE_URL: 'http://localhost:3040/api',
5
+ BASE_URL: 'https://staging-api.otomato.xyz/api',
6
6
  HEADERS: {
7
- 'Content-Type': 'application/json'
7
+ 'Content-Type': 'application/json',
8
8
  }
9
- }
9
+ };
10
10
 
11
11
  const axiosInstance = axios.create({
12
12
  baseURL: API_CONFIG.BASE_URL,
13
13
  headers: API_CONFIG.HEADERS
14
14
  });
15
15
 
16
- export const apiServices = {
17
- async post(endpoint: string, data: any) {
18
- try {
19
- const response = await axiosInstance.post(endpoint, data);
20
- return response.data;
21
- } catch (error) {
22
- console.error('Network request failed', error);
23
- throw error;
24
- }
25
- },
26
-
27
- // Add other HTTP methods if needed
28
- // async get(endpoint: string) { ... }
29
- // async put(endpoint: string, data: any) { ... }
30
- // async delete(endpoint: string) { ... }
31
- };
16
+ class ApiServices {
17
+ private cookie: string | null = null;
18
+
19
+ setCookie(cookie: string) {
20
+ this.cookie = `token=${cookie}`;
21
+ }
22
+
23
+ async post(url: string, data: any) {
24
+ const headers = this.cookie ? { 'Cookie': this.cookie } : {};
25
+ const response = await axiosInstance.post(url, data, { headers });
26
+ return response.data;
27
+ }
28
+
29
+ async get(url: string) {
30
+ const headers = this.cookie ? { 'Cookie': this.cookie } : {};
31
+ const response = await axiosInstance.get(url, { headers });
32
+ return response.data;
33
+ }
34
+
35
+ // You can add other methods (get, put, delete) similarly
36
+ }
37
+
38
+ export const apiServices = new ApiServices();
@@ -24,10 +24,11 @@ export function validateType(expectedType: string, value: any): boolean {
24
24
  return typeof value === 'string' && isValidUrl(value);
25
25
  case 'phone_number':
26
26
  return typeof value === 'string' && isValidPhoneNumber(value);
27
+ case 'string':
27
28
  case 'paragraph':
28
29
  return typeof value === 'string';
29
30
  case 'logic_operator':
30
- const validOperators = new Set(['<', '>', '<=', '>=', '==', '!=']);
31
+ const validOperators = new Set(['gte', 'gt', 'lte', 'lt', 'eq', 'neq']);
31
32
  return typeof value === 'string' && validOperators.has(value);
32
33
  case 'any':
33
34
  return true;
@@ -38,7 +38,9 @@ describe('Action Class', () => {
38
38
 
39
39
  const json = transferAction.toJSON();
40
40
  expect(json).to.deep.equal({
41
- id: ACTIONS.TOKENS.ERC20.TRANSFER.id,
41
+ blockId: ACTIONS.TOKENS.ERC20.TRANSFER.blockId,
42
+ ref: transferAction.getRef(),
43
+ type: 'action',
42
44
  parameters: {
43
45
  chainId: CHAINS.ETHEREUM,
44
46
  'abiParams.value': 1000,
@@ -48,7 +50,7 @@ describe('Action Class', () => {
48
50
  });
49
51
  });
50
52
 
51
- it('should create an SMS action and set parameters correctly', () => {
53
+ /*it('should create an SMS action and set parameters correctly', () => {
52
54
  const smsAction = new Action(ACTIONS.NOTIFICATIONS.SMS);
53
55
  smsAction.setParams("phoneNumber", "+1234567890");
54
56
  smsAction.setParams("text", "Hello, this is a test message!");
@@ -56,16 +58,16 @@ describe('Action Class', () => {
56
58
  const params = smsAction.getParameters();
57
59
  expect(params.phoneNumber).to.equal("+1234567890");
58
60
  expect(params.text).to.equal("Hello, this is a test message!");
59
- });
61
+ });*/
60
62
 
61
63
  it('should create a Slack action and set parameters correctly', () => {
62
- const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK);
64
+ const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK.SEND_MESSAGE);
63
65
  slackAction.setParams("webhook", "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX");
64
- slackAction.setParams("text", "This is a test message!");
66
+ slackAction.setParams("message", "This is a test message!");
65
67
 
66
68
  const params = slackAction.getParameters();
67
69
  expect(params.webhook).to.equal("https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX");
68
- expect(params.text).to.equal("This is a test message!");
70
+ expect(params.message).to.equal("This is a test message!");
69
71
  });
70
72
 
71
73
  it('should throw an error for invalid parameter type', () => {
@@ -79,12 +81,12 @@ describe('Action Class', () => {
79
81
  });
80
82
 
81
83
  it('should throw an error for invalid URL', () => {
82
- const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK);
84
+ const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK.SEND_MESSAGE);
83
85
  expect(() => slackAction.setParams("webhook", "invalid_url")).to.throw('Invalid type for parameter webhook. Expected url.');
84
86
  });
85
87
 
86
- it('should throw an error for invalid phone number', () => {
88
+ /*it('should throw an error for invalid phone number', () => {
87
89
  const smsAction = new Action(ACTIONS.NOTIFICATIONS.SMS);
88
90
  expect(() => smsAction.setParams("phoneNumber", "invalid_phone_number")).to.throw('Invalid type for parameter phoneNumber. Expected phone_number.');
89
- });
91
+ });*/
90
92
  });
@@ -1,11 +1,11 @@
1
1
  import { expect } from 'chai';
2
- import { Automation } from '../src/models/Automation.js';
2
+ import { Workflow } from '../src/models/Workflow.js';
3
3
  import { Trigger } from '../src/models/Trigger.js';
4
4
  import { Action } from '../src/models/Action.js';
5
5
  import { TRIGGERS, ACTIONS, getToken, CHAINS } from '../src/index.js';
6
6
 
7
- describe('Automation Class', () => {
8
- it('should create an automation with a trigger and actions', () => {
7
+ describe('Workflow Class', () => {
8
+ it('should create a workflow with a trigger and actions', () => {
9
9
  const trigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
10
10
  trigger.setChainId(CHAINS.ETHEREUM);
11
11
  trigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
@@ -18,33 +18,34 @@ describe('Automation Class', () => {
18
18
  action1.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
19
19
  action1.setPosition(1, 0);
20
20
 
21
- const action2 = new Action(ACTIONS.NOTIFICATIONS.SMS);
22
- action2.setParams("phoneNumber", "+1234567890");
23
- action2.setParams("text", "This is a test message");
21
+ const action2 = new Action(ACTIONS.NOTIFICATIONS.SLACK.SEND_MESSAGE);
22
+ action2.setParams("webhook", "https://webhook.url");
23
+ action2.setParams("message", "This is a test message");
24
24
  action2.setPosition(2, 0);
25
25
 
26
- const automation = new Automation("Test Automation", [trigger, action1, action2]);
26
+ const workflow = new Workflow("Test Workflow", [trigger, action1, action2]);
27
27
 
28
- const json = automation.toJSON();
28
+ const json = workflow.toJSON();
29
29
  expect(json).to.deep.equal({
30
- name: "Test Automation",
30
+ name: "Test Workflow",
31
31
  nodes: [trigger.toJSON(), action1.toJSON(), action2.toJSON()],
32
+ edges: []
32
33
  });
33
34
  });
34
35
 
35
- it('should set the name of the automation', () => {
36
+ it('should set the name of the workflow', () => {
36
37
  const trigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
37
38
  trigger.setChainId(CHAINS.ETHEREUM);
38
39
  trigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
39
40
  trigger.setPosition(0, 0);
40
41
 
41
- const automation = new Automation("Initial Name", [trigger]);
42
- automation.setName("Updated Name");
42
+ const workflow = new Workflow("Initial Name", [trigger]);
43
+ workflow.setName("Updated Name");
43
44
 
44
- expect(automation.name).to.equal("Updated Name");
45
+ expect(workflow.name).to.equal("Updated Name");
45
46
  });
46
47
 
47
- it('should add a trigger to the automation', () => {
48
+ it('should add a trigger to the workflow', () => {
48
49
  const initialTrigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
49
50
  initialTrigger.setChainId(CHAINS.ETHEREUM);
50
51
  initialTrigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
@@ -55,13 +56,13 @@ describe('Automation Class', () => {
55
56
  newTrigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
56
57
  newTrigger.setPosition(1, 0);
57
58
 
58
- const automation = new Automation("Test Automation", [initialTrigger]);
59
- automation.addNode(newTrigger);
59
+ const workflow = new Workflow("Test Workflow", [initialTrigger]);
60
+ workflow.addNode(newTrigger);
60
61
 
61
- expect(automation.nodes).to.deep.equal([initialTrigger, newTrigger]);
62
+ expect(workflow.nodes).to.deep.equal([initialTrigger, newTrigger]);
62
63
  });
63
64
 
64
- it('should add actions to the automation', () => {
65
+ it('should add actions to the workflow', () => {
65
66
  const trigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
66
67
  trigger.setChainId(CHAINS.ETHEREUM);
67
68
  trigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
@@ -74,15 +75,15 @@ describe('Automation Class', () => {
74
75
  action1.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
75
76
  action1.setPosition(1, 0);
76
77
 
77
- const action2 = new Action(ACTIONS.NOTIFICATIONS.SMS);
78
- action2.setParams("phoneNumber", "+1234567890");
79
- action2.setParams("text", "This is a test message");
78
+ const action2 = new Action(ACTIONS.NOTIFICATIONS.SLACK.SEND_MESSAGE);
79
+ action2.setParams("webhook", "https://webhook.url");
80
+ action2.setParams("message", "This is a test message");
80
81
  action2.setPosition(2, 0);
81
82
 
82
- const automation = new Automation("Test Automation", [trigger]);
83
- automation.addNode(action1);
84
- automation.addNode(action2);
83
+ const workflow = new Workflow("Test Workflow", [trigger]);
84
+ workflow.addNode(action1);
85
+ workflow.addNode(action2);
85
86
 
86
- expect(automation.nodes).to.deep.equal([trigger, action1, action2]);
87
+ expect(workflow.nodes).to.deep.equal([trigger, action1, action2]);
87
88
  });
88
- });
89
+ });