otomato-sdk 1.2.1 → 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 (43) hide show
  1. package/dist/examples/create-workflow.js +44 -0
  2. package/dist/examples/load-workflow.js +16 -0
  3. package/dist/examples/sandbox.js +18 -9
  4. package/dist/src/constants/Blocks.js +69 -35
  5. package/dist/src/index.js +1 -1
  6. package/dist/src/models/Edge.js +6 -1
  7. package/dist/src/models/Node.js +68 -2
  8. package/dist/src/models/Workflow.js +67 -0
  9. package/dist/src/services/ApiService.js +24 -18
  10. package/dist/test/action.spec.js +1 -1
  11. package/dist/test/automation.spec.js +19 -19
  12. package/dist/test/node.spec.js +26 -18
  13. package/dist/test/trigger.spec.js +1 -1
  14. package/dist/types/examples/create-workflow.d.ts +1 -0
  15. package/dist/types/examples/load-workflow.d.ts +1 -0
  16. package/dist/types/src/constants/Blocks.d.ts +55 -21
  17. package/dist/types/src/index.d.ts +1 -1
  18. package/dist/types/src/models/Action.d.ts +2 -1
  19. package/dist/types/src/models/Edge.d.ts +3 -0
  20. package/dist/types/src/models/Node.d.ts +9 -2
  21. package/dist/types/src/models/Trigger.d.ts +2 -1
  22. package/dist/types/src/models/Workflow.d.ts +26 -0
  23. package/dist/types/src/services/ApiService.d.ts +8 -3
  24. package/examples/create-workflow.ts +44 -0
  25. package/examples/load-workflow.ts +10 -0
  26. package/package.json +2 -3
  27. package/src/constants/Blocks.ts +69 -35
  28. package/src/index.ts +1 -1
  29. package/src/models/Action.ts +1 -1
  30. package/src/models/Condition.ts +5 -5
  31. package/src/models/Edge.ts +8 -2
  32. package/src/models/Node.ts +80 -6
  33. package/src/models/Parameter.ts +5 -5
  34. package/src/models/Trigger.ts +1 -1
  35. package/src/models/Workflow.ts +69 -0
  36. package/src/services/ApiService.ts +26 -19
  37. package/test/action.spec.ts +1 -1
  38. package/test/automation.spec.ts +20 -20
  39. package/test/node.spec.ts +26 -18
  40. package/test/trigger.spec.ts +1 -1
  41. package/examples/create-automation.ts +0 -35
  42. package/examples/sandbox.ts +0 -12
  43. package/src/models/Automation.ts +0 -47
@@ -1,10 +1,10 @@
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
- describe('Automation Class', () => {
7
- it('should create an automation with a trigger and actions', () => {
6
+ describe('Workflow Class', () => {
7
+ it('should create a workflow with a trigger and actions', () => {
8
8
  const trigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
9
9
  trigger.setChainId(CHAINS.ETHEREUM);
10
10
  trigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
@@ -19,24 +19,24 @@ describe('Automation Class', () => {
19
19
  action2.setParams("webhook", "https://webhook.url");
20
20
  action2.setParams("message", "This is a test message");
21
21
  action2.setPosition(2, 0);
22
- const automation = new Automation("Test Automation", [trigger, action1, action2]);
23
- const json = automation.toJSON();
22
+ const workflow = new Workflow("Test Workflow", [trigger, action1, action2]);
23
+ const json = workflow.toJSON();
24
24
  expect(json).to.deep.equal({
25
- name: "Test Automation",
25
+ name: "Test Workflow",
26
26
  nodes: [trigger.toJSON(), action1.toJSON(), action2.toJSON()],
27
27
  edges: []
28
28
  });
29
29
  });
30
- it('should set the name of the automation', () => {
30
+ it('should set the name of the workflow', () => {
31
31
  const trigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
32
32
  trigger.setChainId(CHAINS.ETHEREUM);
33
33
  trigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
34
34
  trigger.setPosition(0, 0);
35
- const automation = new Automation("Initial Name", [trigger]);
36
- automation.setName("Updated Name");
37
- expect(automation.name).to.equal("Updated Name");
35
+ const workflow = new Workflow("Initial Name", [trigger]);
36
+ workflow.setName("Updated Name");
37
+ expect(workflow.name).to.equal("Updated Name");
38
38
  });
39
- it('should add a trigger to the automation', () => {
39
+ it('should add a trigger to the workflow', () => {
40
40
  const initialTrigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
41
41
  initialTrigger.setChainId(CHAINS.ETHEREUM);
42
42
  initialTrigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
@@ -45,11 +45,11 @@ describe('Automation Class', () => {
45
45
  newTrigger.setChainId(CHAINS.ETHEREUM);
46
46
  newTrigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
47
47
  newTrigger.setPosition(1, 0);
48
- const automation = new Automation("Test Automation", [initialTrigger]);
49
- automation.addNode(newTrigger);
50
- expect(automation.nodes).to.deep.equal([initialTrigger, newTrigger]);
48
+ const workflow = new Workflow("Test Workflow", [initialTrigger]);
49
+ workflow.addNode(newTrigger);
50
+ expect(workflow.nodes).to.deep.equal([initialTrigger, newTrigger]);
51
51
  });
52
- it('should add actions to the automation', () => {
52
+ it('should add actions to the workflow', () => {
53
53
  const trigger = new Trigger(TRIGGERS.TOKENS.ERC20.TRANSFER);
54
54
  trigger.setChainId(CHAINS.ETHEREUM);
55
55
  trigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
@@ -64,9 +64,9 @@ describe('Automation Class', () => {
64
64
  action2.setParams("webhook", "https://webhook.url");
65
65
  action2.setParams("message", "This is a test message");
66
66
  action2.setPosition(2, 0);
67
- const automation = new Automation("Test Automation", [trigger]);
68
- automation.addNode(action1);
69
- automation.addNode(action2);
70
- expect(automation.nodes).to.deep.equal([trigger, action1, action2]);
67
+ const workflow = new Workflow("Test Workflow", [trigger]);
68
+ workflow.addNode(action1);
69
+ workflow.addNode(action2);
70
+ expect(workflow.nodes).to.deep.equal([trigger, action1, action2]);
71
71
  });
72
72
  });
@@ -7,23 +7,25 @@ const DEFAULT_PARAMETERS = [
7
7
  describe('Node Class', () => {
8
8
  it('should create a node without coordinates', () => {
9
9
  const node = new Node({
10
- id: 1,
10
+ blockId: 1,
11
11
  name: 'Test Node',
12
12
  description: 'A node for testing',
13
13
  parameters: DEFAULT_PARAMETERS,
14
- class: 'testClass'
14
+ class: 'testClass',
15
+ image: 'a',
15
16
  });
16
17
  expect(node.position).to.be.undefined;
17
18
  });
18
19
  it('should create a node with coordinates', () => {
19
20
  var _a, _b;
20
21
  const node = new Node({
21
- id: 2,
22
+ blockId: 2,
22
23
  name: 'Test Node with Coordinates',
23
24
  description: 'A node for testing with coordinates',
24
25
  parameters: DEFAULT_PARAMETERS,
25
26
  class: 'testClass',
26
- position: { x: 100, y: 200 }
27
+ position: { x: 100, y: 200 },
28
+ image: 'a',
27
29
  });
28
30
  expect((_a = node.position) === null || _a === void 0 ? void 0 : _a.x).to.equal(100);
29
31
  expect((_b = node.position) === null || _b === void 0 ? void 0 : _b.y).to.equal(200);
@@ -31,11 +33,12 @@ describe('Node Class', () => {
31
33
  it('should set and get coordinates correctly', () => {
32
34
  var _a, _b;
33
35
  const node = new Node({
34
- id: 3,
36
+ blockId: 3,
35
37
  name: 'Test Node for Coordinates',
36
38
  description: 'A node for testing coordinate setting',
37
39
  parameters: DEFAULT_PARAMETERS,
38
- class: 'testClass'
40
+ class: 'testClass',
41
+ image: 'a',
39
42
  });
40
43
  node.setPosition(300, 400);
41
44
  expect((_a = node.position) === null || _a === void 0 ? void 0 : _a.x).to.equal(300);
@@ -43,11 +46,12 @@ describe('Node Class', () => {
43
46
  });
44
47
  it('should create a node and set parameters correctly', () => {
45
48
  const node = new Node({
46
- id: 4,
49
+ blockId: 4,
47
50
  name: 'Test Node for Parameters',
48
51
  description: 'A node for testing parameter setting',
49
52
  parameters: DEFAULT_PARAMETERS,
50
- class: 'testClass'
53
+ class: 'testClass',
54
+ image: 'a',
51
55
  });
52
56
  node.setChainId(1);
53
57
  node.setContractAddress("0x0000000000000000000000000000000000000000");
@@ -57,17 +61,18 @@ describe('Node Class', () => {
57
61
  });
58
62
  it('should be able to export a node as json without coordinates', () => {
59
63
  const node = new Node({
60
- id: 5,
64
+ blockId: 5,
61
65
  name: 'Test Node for JSON',
62
66
  description: 'A node for testing JSON export',
63
67
  parameters: DEFAULT_PARAMETERS,
64
- class: 'testClass'
68
+ class: 'testClass',
69
+ image: 'a',
65
70
  });
66
71
  node.setChainId(1);
67
72
  node.setContractAddress("0x0000000000000000000000000000000000000000");
68
73
  const json = node.toJSON();
69
74
  expect(json).to.deep.equal({
70
- id: 5,
75
+ blockId: 5,
71
76
  ref: node.getRef(),
72
77
  type: 'testClass',
73
78
  parameters: {
@@ -78,19 +83,20 @@ describe('Node Class', () => {
78
83
  });
79
84
  it('should be able to export a node as json with coordinates', () => {
80
85
  const node = new Node({
81
- id: 6,
86
+ blockId: 6,
82
87
  name: 'Test Node for JSON with Coordinates',
83
88
  description: 'A node for testing JSON export with coordinates',
84
89
  parameters: DEFAULT_PARAMETERS,
85
90
  class: 'testClass',
86
- position: { x: 1, y: 2 }
91
+ position: { x: 1, y: 2 },
92
+ image: 'a',
87
93
  });
88
94
  node.setChainId(1);
89
95
  node.setContractAddress("0x0000000000000000000000000000000000000000");
90
96
  const json = node.toJSON();
91
97
  expect(json).to.deep.equal({
92
98
  type: 'testClass',
93
- id: 6,
99
+ blockId: 6,
94
100
  ref: node.getRef(),
95
101
  parameters: {
96
102
  chainId: 1,
@@ -101,21 +107,23 @@ describe('Node Class', () => {
101
107
  });
102
108
  it('should throw an error for invalid parameter type', () => {
103
109
  const node = new Node({
104
- id: 7,
110
+ blockId: 7,
105
111
  name: 'Test Node for Invalid Parameter Type',
106
112
  description: 'A node for testing invalid parameter type',
107
113
  parameters: DEFAULT_PARAMETERS,
108
- class: 'testClass'
114
+ class: 'testClass',
115
+ image: 'a',
109
116
  });
110
117
  expect(() => node.setParams("chainId", "invalid")).to.throw('Invalid type for parameter chainId. Expected integer.');
111
118
  });
112
119
  it('should throw an error for invalid address', () => {
113
120
  const node = new Node({
114
- id: 8,
121
+ blockId: 8,
115
122
  name: 'Test Node for Invalid Address',
116
123
  description: 'A node for testing invalid address',
117
124
  parameters: DEFAULT_PARAMETERS,
118
- class: 'testClass'
125
+ class: 'testClass',
126
+ image: 'a',
119
127
  });
120
128
  expect(() => node.setParams("contractAddress", "invalid_address")).to.throw('Invalid type for parameter contractAddress. Expected address.');
121
129
  });
@@ -31,7 +31,7 @@ describe('Trigger Class', () => {
31
31
  const json = transferTrigger.toJSON();
32
32
  console.log(json);
33
33
  expect(json).to.deep.equal({
34
- id: TRIGGERS.TOKENS.ERC20.TRANSFER.id,
34
+ blockId: TRIGGERS.TOKENS.ERC20.TRANSFER.blockId,
35
35
  ref: transferTrigger.getRef(),
36
36
  type: 'trigger',
37
37
  parameters: {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -2,110 +2,132 @@ import { Parameter } from '../models/Parameter.js';
2
2
  export declare const TRIGGERS: {
3
3
  TOKENS: {
4
4
  ERC20: {
5
- CHAINS: number[];
5
+ description: string;
6
+ chains: number[];
7
+ image: string;
6
8
  TRANSFER: {
7
- id: number;
8
9
  name: string;
9
10
  description: string;
10
11
  type: number;
11
12
  parameters: Parameter[];
13
+ blockId: number;
14
+ image: string;
12
15
  };
13
16
  BALANCE: {
14
- id: number;
15
17
  name: string;
16
18
  description: string;
17
19
  type: number;
18
20
  method: string;
19
21
  handler: string;
20
22
  parameters: Parameter[];
23
+ blockId: number;
24
+ image: string;
21
25
  };
22
26
  };
23
27
  };
24
28
  YIELD: {
25
29
  SPLICE_FI: {
26
- CHAINS: number[];
30
+ description: string;
31
+ chains: number[];
32
+ image: string;
27
33
  SWAP: {
28
- id: number;
29
34
  name: string;
30
35
  description: string;
31
36
  type: number;
32
37
  contractAddress: string;
33
38
  parameters: Parameter[];
39
+ blockId: number;
40
+ image: string;
34
41
  };
35
42
  LIQUIDITY_REMOVED: {
36
- id: number;
37
43
  name: string;
38
44
  description: string;
39
45
  type: number;
40
46
  contractAddress: string;
41
47
  parameters: Parameter[];
48
+ blockId: number;
49
+ image: string;
42
50
  };
43
51
  MARKET_CREATION: {
44
- id: number;
45
52
  name: string;
46
53
  description: string;
47
54
  type: number;
48
55
  contractAddress: string;
49
56
  parameters: Parameter[];
57
+ blockId: number;
58
+ image: string;
50
59
  };
51
60
  INTEREST_RATE_UPDATE: {
52
- id: number;
53
61
  name: string;
54
62
  description: string;
55
63
  type: number;
56
64
  contractAddress: string;
57
65
  parameters: Parameter[];
66
+ blockId: number;
67
+ image: string;
58
68
  };
59
69
  };
60
70
  };
61
71
  LENDING: {
62
72
  ASTARIA: {
63
- CHAINS: number[];
73
+ description: string;
74
+ chains: number[];
75
+ image: string;
64
76
  LEND_RECALLED: {
65
- id: number;
66
77
  name: string;
67
78
  description: string;
68
79
  type: number;
69
80
  contractAddress: string;
70
81
  parameters: Parameter[];
82
+ blockId: number;
83
+ image: string;
71
84
  };
72
85
  };
73
86
  };
74
87
  DEXES: {
75
88
  ODOS: {
76
- CHAINS: number[];
89
+ description: string;
90
+ chains: number[];
91
+ image: string;
77
92
  SWAP: {
78
- id: number;
79
93
  name: string;
80
94
  description: string;
81
95
  type: number;
82
96
  contractAddress: string;
83
97
  parameters: Parameter[];
98
+ blockId: number;
99
+ image: string;
84
100
  };
85
101
  };
86
102
  };
87
103
  SOCIALS: {
88
104
  MODE_NAME_SERVICE: {
89
- CHAINS: number[];
105
+ description: string;
106
+ chains: number[];
107
+ image: string;
90
108
  NAME_REGISTERED: {
91
- id: number;
92
109
  name: string;
93
110
  description: string;
94
111
  type: number;
95
112
  contractAddress: string;
96
113
  parameters: Parameter[];
114
+ blockId: number;
115
+ image: string;
97
116
  };
98
117
  };
99
118
  };
100
119
  PRICE_ACTION: {
101
120
  ON_CHAIN_PRICE_MOVEMENT: {
102
- CHAINS: number[];
121
+ description: string;
122
+ chains: number[];
123
+ image: string;
103
124
  PRICE_MOVEMENT_AGAINST_CURRENCY: {
104
- id: number;
105
125
  name: string;
106
126
  description: string;
107
127
  type: number;
108
128
  parameters: Parameter[];
129
+ blockId: number;
130
+ image: string;
109
131
  };
110
132
  };
111
133
  };
@@ -113,43 +135,55 @@ export declare const TRIGGERS: {
113
135
  export declare const ACTIONS: {
114
136
  NOTIFICATIONS: {
115
137
  SLACK: {
138
+ description: string;
139
+ image: string;
116
140
  SEND_MESSAGE: {
117
- id: number;
118
141
  name: string;
119
142
  type: number;
120
143
  description: string;
121
144
  parameters: Parameter[];
145
+ blockId: number;
146
+ image: string;
122
147
  };
123
148
  };
124
149
  DISCORD: {
150
+ description: string;
151
+ image: string;
125
152
  SEND_MESSAGE: {
126
- id: number;
127
153
  name: string;
128
154
  type: number;
129
155
  description: string;
130
156
  parameters: Parameter[];
157
+ blockId: number;
158
+ image: string;
131
159
  };
132
160
  };
133
161
  TELEGRAM: {
162
+ description: string;
163
+ image: string;
134
164
  SEND_MESSAGE: {
135
- id: number;
136
165
  name: string;
137
166
  type: number;
138
167
  description: string;
139
168
  parameters: Parameter[];
169
+ blockId: number;
170
+ image: string;
140
171
  };
141
172
  };
142
173
  };
143
174
  TOKENS: {
144
175
  ERC20: {
145
- CHAINS: number[];
176
+ description: string;
177
+ chains: number[];
178
+ image: string;
146
179
  TRANSFER: {
147
- id: number;
148
180
  name: string;
149
181
  description: string;
150
182
  type: number;
151
183
  method: string;
152
184
  parameters: Parameter[];
185
+ blockId: number;
186
+ image: string;
153
187
  };
154
188
  };
155
189
  };
@@ -2,7 +2,7 @@ export * from './constants/Blocks.js';
2
2
  export * from './constants/chains.js';
3
3
  export * from './constants/tokens.js';
4
4
  export * from './models/Action.js';
5
- export * from './models/Automation.js';
5
+ export * from './models/Workflow.js';
6
6
  export * from './models/Condition.js';
7
7
  export * from './models/Parameter.js';
8
8
  export * from './models/Trigger.js';
@@ -2,10 +2,11 @@ import { Parameter } from './Parameter.js';
2
2
  import { Node, Position } from './Node.js';
3
3
  export declare class Action extends Node {
4
4
  constructor(action: {
5
- id: number;
5
+ blockId: number;
6
6
  name: string;
7
7
  description: string;
8
8
  parameters: Parameter[];
9
+ image: string;
9
10
  ref?: string;
10
11
  position?: Position;
11
12
  });
@@ -11,4 +11,7 @@ export declare class Edge {
11
11
  toJSON(): {
12
12
  [key: string]: any;
13
13
  };
14
+ static fromJSON(json: {
15
+ [key: string]: any;
16
+ }): Edge;
14
17
  }
@@ -4,7 +4,8 @@ export interface Position {
4
4
  y: number;
5
5
  }
6
6
  export declare class Node {
7
- id: number;
7
+ id: string | null;
8
+ blockId: number;
8
9
  name: string;
9
10
  description: string;
10
11
  parameters: {
@@ -16,15 +17,18 @@ export declare class Node {
16
17
  position?: Position;
17
18
  ref: string;
18
19
  class: string;
20
+ image: string;
19
21
  constructor(node: {
20
- id: number;
22
+ blockId: number;
21
23
  name: string;
22
24
  description: string;
23
25
  parameters: Parameter[];
24
26
  ref?: string;
25
27
  position?: Position;
26
28
  class: string;
29
+ image: string;
27
30
  });
31
+ setId(id: string): void;
28
32
  setChainId(value: number): void;
29
33
  setContractAddress(value: string): void;
30
34
  setParams(key: string, value: any): void;
@@ -39,4 +43,7 @@ export declare class Node {
39
43
  [key: string]: any;
40
44
  };
41
45
  private getSimplifiedKey;
46
+ static fromJSON(json: {
47
+ [key: string]: any;
48
+ }): Node;
42
49
  }
@@ -3,11 +3,12 @@ import { Node, Position } from './Node.js';
3
3
  export declare class Trigger extends Node {
4
4
  type: number;
5
5
  constructor(trigger: {
6
- id: number;
6
+ blockId: number;
7
7
  name: string;
8
8
  description: string;
9
9
  type: number;
10
10
  parameters: Parameter[];
11
+ image: string;
11
12
  ref?: string;
12
13
  position?: Position;
13
14
  });
@@ -0,0 +1,26 @@
1
+ import { Node } from './Node.js';
2
+ import { Edge } from './Edge.js';
3
+ export declare class Workflow {
4
+ id: string | null;
5
+ name: string;
6
+ nodes: Node[];
7
+ edges: Edge[];
8
+ constructor(name?: string, nodes?: Node[], edges?: Edge[]);
9
+ setName(name: string): void;
10
+ addNode(node: Node): void;
11
+ addNodes(nodes: Node[]): void;
12
+ addEdge(edge: Edge): void;
13
+ addEdges(edges: Edge[]): void;
14
+ toJSON(): {
15
+ id: string | null;
16
+ name: string;
17
+ nodes: {
18
+ [key: string]: any;
19
+ }[];
20
+ edges: {
21
+ [key: string]: any;
22
+ }[];
23
+ };
24
+ create(): Promise<any>;
25
+ load(workflowId: string): Promise<Workflow>;
26
+ }
@@ -1,3 +1,8 @@
1
- export declare const apiServices: {
2
- post(endpoint: string, data: any): Promise<any>;
3
- };
1
+ declare class ApiServices {
2
+ private cookie;
3
+ setCookie(cookie: string): void;
4
+ post(url: string, data: any): Promise<any>;
5
+ get(url: string): Promise<any>;
6
+ }
7
+ export declare const apiServices: ApiServices;
8
+ export {};
@@ -0,0 +1,44 @@
1
+ import { ACTIONS, Action, TRIGGERS, Trigger, Workflow, CHAINS, getToken, Edge, apiServices } from '../src/index.js';
2
+
3
+ const main = async () => {
4
+
5
+ apiServices.setCookie("eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIweDdjRUI4ZDgxNDdBYWE5ZEI4MUFjQkRGRTVjMzA1MERGQ2ZGMTg1MzciLCJzdWIiOiIweDg3RkU4YjRmMkZlODM3MGY2Y0M5YTk2MzQ0MmYwN0IwMmY0OTA5QTciLCJhdWQiOiJvdG9tYXRvLXRlc3QubmV0bGlmeS5hcHAiLCJleHAiOjE3MjMzODMxOTksIm5iZiI6MTcyMDc4OTM5OSwiaWF0IjoxNzIwNzkxMTk5LCJqdGkiOiIweDY4ZDkxOWEyMGZiYjIyNDUwZDZmOTFjMzM2ZTBmYjBjMmYyYTc3MmU3Zjg4NWU1ZjRmNzg1NTM2ZGIyYTY5YTAiLCJjdHgiOnt9fQ.MHgyOTM1NTM3MWYwOWM1YzllNWE3YjI4MjVkZTNjMDljZTkwMTQ3OTQwZmU1ZWRlMjM5YTk0MmFjYTQ5YTcwZWI0MGJlNmJiZDk2MDA4ZTIxMzJmNGM3ZTVlZGIzZDZiZjYyMDE4Mzc1MzUwMTRmNTc0ODM0ZDk4YWU3NDQwNDQzOTFi");
6
+
7
+ const usdcTransferTrigger = new Trigger({
8
+ blockId: TRIGGERS.TOKENS.ERC20.TRANSFER.blockId,
9
+ name: TRIGGERS.TOKENS.ERC20.TRANSFER.name,
10
+ description: TRIGGERS.TOKENS.ERC20.TRANSFER.description,
11
+ type: TRIGGERS.TOKENS.ERC20.TRANSFER.type,
12
+ parameters: TRIGGERS.TOKENS.ERC20.TRANSFER.parameters,
13
+ image: TRIGGERS.TOKENS.ERC20.TRANSFER.image,
14
+ ref: 'n-1',
15
+ });
16
+ usdcTransferTrigger.setChainId(CHAINS.ETHEREUM);
17
+ usdcTransferTrigger.setContractAddress(getToken(CHAINS.ETHEREUM, 'USDC').contractAddress);
18
+ usdcTransferTrigger.setPosition(0, 0);
19
+
20
+ const slackAction = new Action(ACTIONS.NOTIFICATIONS.SLACK.SEND_MESSAGE);
21
+ slackAction.setParams("webhook", "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX");
22
+ slackAction.setParams("message", "USDC has been transferred!");
23
+ slackAction.setPosition(0, -10);
24
+
25
+ const workflow = new Workflow("USDC Transfer Notification", [usdcTransferTrigger, slackAction]);
26
+
27
+ const edge = new Edge({
28
+ source: usdcTransferTrigger,
29
+ target: slackAction,
30
+ });
31
+
32
+ workflow.addEdge(edge);
33
+
34
+ // console.log(JSON.stringify(workflow.toJSON(), null, 2));
35
+ return;
36
+ const res = await workflow.create();
37
+ console.log(res);
38
+ console.log(`Workflow ID: ${workflow.id}`); // This will print the ID of the created workflow
39
+ workflow.nodes.forEach(node => {
40
+ console.log(`Node ${node.getRef()} ID: ${node.id}`);
41
+ });
42
+ }
43
+
44
+ main();
@@ -0,0 +1,10 @@
1
+ import { ACTIONS, Action, TRIGGERS, Trigger, Workflow, CHAINS, getToken, Edge, apiServices } from '../src/index.js';
2
+
3
+ const main = async () => {
4
+
5
+ apiServices.setCookie("eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIweDdjRUI4ZDgxNDdBYWE5ZEI4MUFjQkRGRTVjMzA1MERGQ2ZGMTg1MzciLCJzdWIiOiIweDg3RkU4YjRmMkZlODM3MGY2Y0M5YTk2MzQ0MmYwN0IwMmY0OTA5QTciLCJhdWQiOiJvdG9tYXRvLXRlc3QubmV0bGlmeS5hcHAiLCJleHAiOjE3MjMzODMxOTksIm5iZiI6MTcyMDc4OTM5OSwiaWF0IjoxNzIwNzkxMTk5LCJqdGkiOiIweDY4ZDkxOWEyMGZiYjIyNDUwZDZmOTFjMzM2ZTBmYjBjMmYyYTc3MmU3Zjg4NWU1ZjRmNzg1NTM2ZGIyYTY5YTAiLCJjdHgiOnt9fQ.MHgyOTM1NTM3MWYwOWM1YzllNWE3YjI4MjVkZTNjMDljZTkwMTQ3OTQwZmU1ZWRlMjM5YTk0MmFjYTQ5YTcwZWI0MGJlNmJiZDk2MDA4ZTIxMzJmNGM3ZTVlZGIzZDZiZjYyMDE4Mzc1MzUwMTRmNTc0ODM0ZDk4YWU3NDQwNDQzOTFi");
6
+ const workflow = await new Workflow().load("0b9bd533-339c-42b5-9ed3-a6a40fcfa8d3");
7
+ console.log(workflow)
8
+ }
9
+
10
+ main();
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "An SDK for building and managing automations on Otomato",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/types/src/index.d.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "build": "npx tsc",
10
- "test": "mocha --config .mocharc.json",
11
- "publish": "npm publish"
10
+ "test": "mocha --config .mocharc.json"
12
11
  },
13
12
  "keywords": [
14
13
  "sdk",