@avaprotocol/sdk-js 2.5.2-dev.0 → 2.6.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.
- package/CHANGELOG.md +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +598 -1599
- package/dist/index.mjs +613 -1602
- package/dist/models/node/branch.d.ts.map +1 -1
- package/dist/models/node/branch.js +2 -11
- package/dist/models/node/contractRead.d.ts.map +1 -1
- package/dist/models/node/contractRead.js +1 -14
- package/dist/models/node/contractWrite.d.ts +1 -1
- package/dist/models/node/contractWrite.d.ts.map +1 -1
- package/dist/models/node/contractWrite.js +0 -14
- package/dist/models/node/customCode.d.ts.map +1 -1
- package/dist/models/node/customCode.js +1 -14
- package/dist/models/node/ethTransfer.d.ts.map +1 -1
- package/dist/models/node/ethTransfer.js +6 -11
- package/dist/models/node/filter.d.ts.map +1 -1
- package/dist/models/node/filter.js +20 -18
- package/dist/models/node/graphqlQuery.d.ts.map +1 -1
- package/dist/models/node/graphqlQuery.js +5 -11
- package/dist/models/node/interface.d.ts +0 -1
- package/dist/models/node/interface.d.ts.map +1 -1
- package/dist/models/node/interface.js +0 -8
- package/dist/models/node/loop.d.ts.map +1 -1
- package/dist/models/node/loop.js +58 -85
- package/dist/models/node/restApi.d.ts.map +1 -1
- package/dist/models/node/restApi.js +1 -15
- package/dist/models/step.d.ts +3 -1
- package/dist/models/step.d.ts.map +1 -1
- package/dist/models/step.js +104 -365
- package/dist/models/trigger/block.d.ts.map +1 -1
- package/dist/models/trigger/block.js +18 -20
- package/dist/models/trigger/cron.d.ts.map +1 -1
- package/dist/models/trigger/cron.js +9 -28
- package/dist/models/trigger/event.d.ts.map +1 -1
- package/dist/models/trigger/event.js +1 -12
- package/dist/models/trigger/fixedTime.d.ts.map +1 -1
- package/dist/models/trigger/fixedTime.js +9 -20
- package/dist/models/trigger/interface.d.ts +1 -1
- package/dist/models/trigger/interface.d.ts.map +1 -1
- package/dist/models/trigger/interface.js +7 -2
- package/dist/models/trigger/manual.d.ts +0 -3
- package/dist/models/trigger/manual.d.ts.map +1 -1
- package/dist/models/trigger/manual.js +35 -44
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Node from "./interface";
|
|
2
2
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
3
|
import { NodeType, } from "@avaprotocol/types";
|
|
4
|
-
import { convertProtobufValueToJs,
|
|
4
|
+
import { convertProtobufValueToJs, } from "../../utils";
|
|
5
5
|
// Required props for constructor: id, name, type and data: { url, method, headersMap, body }
|
|
6
6
|
class RestAPINode extends Node {
|
|
7
7
|
constructor(props) {
|
|
@@ -30,12 +30,6 @@ class RestAPINode extends Node {
|
|
|
30
30
|
static fromResponse(raw) {
|
|
31
31
|
// Convert the raw object to RestAPINodeProps, which should keep name and id
|
|
32
32
|
const obj = raw.toObject();
|
|
33
|
-
// Extract input data from top-level TaskNode.input field (not nested RestAPINode.input)
|
|
34
|
-
// This matches where we set it in toRequest() and where the Go backend looks for it
|
|
35
|
-
let input = undefined;
|
|
36
|
-
if (raw.hasInput()) {
|
|
37
|
-
input = extractInputFromProtobuf(raw.getInput());
|
|
38
|
-
}
|
|
39
33
|
return new RestAPINode({
|
|
40
34
|
...obj,
|
|
41
35
|
type: NodeType.RestAPI,
|
|
@@ -52,7 +46,6 @@ class RestAPINode extends Node {
|
|
|
52
46
|
return headers;
|
|
53
47
|
})(),
|
|
54
48
|
},
|
|
55
|
-
input: input, // Include input data from top-level TaskNode
|
|
56
49
|
});
|
|
57
50
|
}
|
|
58
51
|
toRequest() {
|
|
@@ -60,13 +53,6 @@ class RestAPINode extends Node {
|
|
|
60
53
|
request.setId(this.id);
|
|
61
54
|
request.setName(this.name);
|
|
62
55
|
const nodeData = RestAPINode.createProtobufNode(this.data);
|
|
63
|
-
// Use the standard utility function to convert input field to protobuf format
|
|
64
|
-
const inputValue = convertInputToProtobuf(this.input);
|
|
65
|
-
if (inputValue) {
|
|
66
|
-
// Set input on the top-level TaskNode, not the nested RestAPINode
|
|
67
|
-
// This matches where the Go backend's ExtractNodeInputData() looks for it
|
|
68
|
-
request.setInput(inputValue);
|
|
69
|
-
}
|
|
70
56
|
request.setRestApi(nodeData);
|
|
71
57
|
return request;
|
|
72
58
|
}
|
package/dist/models/step.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare class Step implements StepProps {
|
|
|
8
8
|
error: string;
|
|
9
9
|
log: string;
|
|
10
10
|
inputsList: string[];
|
|
11
|
-
|
|
11
|
+
config?: any;
|
|
12
12
|
output: OutputDataProps;
|
|
13
13
|
startAt: number;
|
|
14
14
|
endAt: number;
|
|
@@ -19,6 +19,8 @@ declare class Step implements StepProps {
|
|
|
19
19
|
*/
|
|
20
20
|
toJson(): StepProps;
|
|
21
21
|
static getOutput(step: avs_pb.Execution.Step): OutputDataProps;
|
|
22
|
+
private static extractOutputData;
|
|
23
|
+
private static getOutputDataCase;
|
|
22
24
|
static fromResponse(step: avs_pb.Execution.Step): Step;
|
|
23
25
|
}
|
|
24
26
|
export default Step;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAMhD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,cAAM,IAAK,YAAW,SAAS;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAMhD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,cAAM,IAAK,YAAW,SAAS;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,SAAS;IAc5B;;;OAGG;IACH,MAAM,IAAI,SAAS;IAgBnB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IAsB9D,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiEhC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAgChC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAqEvD;AAED,eAAe,IAAI,CAAC"}
|
package/dist/models/step.js
CHANGED
|
@@ -9,7 +9,7 @@ class Step {
|
|
|
9
9
|
this.error = props.error;
|
|
10
10
|
this.log = props.log;
|
|
11
11
|
this.inputsList = props.inputsList;
|
|
12
|
-
this.
|
|
12
|
+
this.config = props.config;
|
|
13
13
|
this.output = props.output;
|
|
14
14
|
this.startAt = props.startAt;
|
|
15
15
|
this.endAt = props.endAt;
|
|
@@ -27,411 +27,150 @@ class Step {
|
|
|
27
27
|
error: this.error,
|
|
28
28
|
log: this.log,
|
|
29
29
|
inputsList: this.inputsList,
|
|
30
|
-
|
|
30
|
+
config: this.config,
|
|
31
31
|
output: this.output,
|
|
32
32
|
startAt: this.startAt,
|
|
33
33
|
endAt: this.endAt,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
static getOutput(step) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const outputData = this.extractOutputData(step);
|
|
38
|
+
if (!outputData)
|
|
39
|
+
return null;
|
|
40
|
+
// STANDARDIZED Direct Mapping - ALL triggers and nodes use the same logic
|
|
41
|
+
if (typeof outputData.hasData === "function" && outputData.hasData()) {
|
|
42
|
+
try {
|
|
43
|
+
return convertProtobufValueToJs(outputData.getData());
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ;
|
|
60
|
-
if (stepObj.contractWrite)
|
|
61
|
-
return avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE;
|
|
62
|
-
if (stepObj.customCode)
|
|
63
|
-
return avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE;
|
|
64
|
-
if (stepObj.restApi)
|
|
65
|
-
return avs_pb.Execution.Step.OutputDataCase.REST_API;
|
|
66
|
-
if (stepObj.branch)
|
|
67
|
-
return avs_pb.Execution.Step.OutputDataCase.BRANCH;
|
|
68
|
-
if (stepObj.filter)
|
|
69
|
-
return avs_pb.Execution.Step.OutputDataCase.FILTER;
|
|
70
|
-
if (stepObj.loop)
|
|
71
|
-
return avs_pb.Execution.Step.OutputDataCase.LOOP;
|
|
72
|
-
return avs_pb.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET;
|
|
73
|
-
};
|
|
74
|
-
switch (getOutputDataCase()) {
|
|
75
|
-
case avs_pb.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET:
|
|
76
|
-
return undefined;
|
|
77
|
-
// Trigger outputs
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.warn("Failed to convert protobuf Value to JavaScript:", error);
|
|
47
|
+
return outputData.getData();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (outputData.data) {
|
|
51
|
+
// For plain objects, try to convert or use directly
|
|
52
|
+
return typeof outputData.data.getKindCase === "function"
|
|
53
|
+
? convertProtobufValueToJs(outputData.data)
|
|
54
|
+
: outputData.data;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
static extractOutputData(step) {
|
|
59
|
+
// Simple switch to get the output object - all handled identically
|
|
60
|
+
const outputCase = this.getOutputDataCase(step);
|
|
61
|
+
switch (outputCase) {
|
|
78
62
|
case avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
|
|
79
|
-
|
|
80
|
-
? step.getBlockTrigger()
|
|
63
|
+
return typeof step.getBlockTrigger === "function"
|
|
64
|
+
? step.getBlockTrigger()
|
|
81
65
|
: step.blockTrigger;
|
|
82
|
-
return { data: blockTrigger }; // ✅ Use standard structure
|
|
83
66
|
case avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
|
|
84
|
-
|
|
85
|
-
? step.getFixedTimeTrigger()
|
|
67
|
+
return typeof step.getFixedTimeTrigger === "function"
|
|
68
|
+
? step.getFixedTimeTrigger()
|
|
86
69
|
: step.fixedTimeTrigger;
|
|
87
|
-
return { data: fixedTimeTrigger }; // ✅ Use standard structure
|
|
88
70
|
case avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER:
|
|
89
|
-
|
|
90
|
-
? step.getCronTrigger()
|
|
71
|
+
return typeof step.getCronTrigger === "function"
|
|
72
|
+
? step.getCronTrigger()
|
|
91
73
|
: step.cronTrigger;
|
|
92
|
-
return { data: cronTrigger }; // ✅ Use standard structure
|
|
93
74
|
case avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER:
|
|
94
|
-
|
|
75
|
+
return typeof step.getEventTrigger === "function"
|
|
95
76
|
? step.getEventTrigger()
|
|
96
77
|
: step.eventTrigger;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (typeof eventTrigger.hasData === "function" &&
|
|
100
|
-
eventTrigger.hasData()) {
|
|
101
|
-
try {
|
|
102
|
-
const eventData = convertProtobufValueToJs(eventTrigger.getData());
|
|
103
|
-
return { data: eventData }; // ✅ Use standard structure
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
console.warn("Failed to convert event trigger data from protobuf Value:", error);
|
|
107
|
-
return { data: eventTrigger.getData() }; // ✅ Use standard structure
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (eventTrigger.data) {
|
|
111
|
-
// For plain objects, try to convert or use directly
|
|
112
|
-
const eventData = typeof eventTrigger.data.getKindCase === "function"
|
|
113
|
-
? convertProtobufValueToJs(eventTrigger.data)
|
|
114
|
-
: eventTrigger.data;
|
|
115
|
-
return { data: eventData }; // ✅ Use standard structure
|
|
116
|
-
}
|
|
117
|
-
// Fallback to old structure for backward compatibility
|
|
118
|
-
if (typeof eventTrigger.hasEvmLog === "function" &&
|
|
119
|
-
eventTrigger.hasEvmLog()) {
|
|
120
|
-
return { data: eventTrigger.getEvmLog()?.toObject() }; // ✅ Use standard structure
|
|
121
|
-
}
|
|
122
|
-
else if (typeof eventTrigger.hasTransferLog === "function" &&
|
|
123
|
-
eventTrigger.hasTransferLog()) {
|
|
124
|
-
return { data: eventTrigger.getTransferLog()?.toObject() }; // ✅ Use standard structure
|
|
125
|
-
}
|
|
126
|
-
else if (eventTrigger.evmLog) {
|
|
127
|
-
return { data: eventTrigger.evmLog }; // ✅ Use standard structure
|
|
128
|
-
}
|
|
129
|
-
else if (eventTrigger.transferLog) {
|
|
130
|
-
return { data: eventTrigger.transferLog }; // ✅ Use standard structure
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return { data: null }; // ✅ Use standard structure
|
|
134
|
-
case avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER: {
|
|
135
|
-
const manualTrigger = typeof step.getManualTrigger === "function"
|
|
78
|
+
case avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
|
|
79
|
+
return typeof step.getManualTrigger === "function"
|
|
136
80
|
? step.getManualTrigger()
|
|
137
81
|
: step.manualTrigger;
|
|
138
|
-
if (manualTrigger) {
|
|
139
|
-
// For manual triggers, return the data content directly (similar to CustomCode)
|
|
140
|
-
// Headers and pathParams are config-only fields, not output fields
|
|
141
|
-
if (typeof manualTrigger.hasData === "function" &&
|
|
142
|
-
manualTrigger.hasData()) {
|
|
143
|
-
try {
|
|
144
|
-
return convertProtobufValueToJs(manualTrigger.getData());
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
console.warn("Failed to convert manual trigger data from protobuf Value:", error);
|
|
148
|
-
return manualTrigger.getData();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else if (manualTrigger.data) {
|
|
152
|
-
// For plain objects, try to convert or use directly
|
|
153
|
-
return typeof manualTrigger.data.getKindCase === "function"
|
|
154
|
-
? convertProtobufValueToJs(manualTrigger.data)
|
|
155
|
-
: manualTrigger.data;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
// Node outputs - RESTORE MISSING CASES
|
|
161
82
|
case avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER:
|
|
162
83
|
return typeof step.getEthTransfer === "function"
|
|
163
|
-
? step.getEthTransfer()
|
|
84
|
+
? step.getEthTransfer()
|
|
164
85
|
: step.ethTransfer;
|
|
165
|
-
case avs_pb.Execution.Step.OutputDataCase.
|
|
166
|
-
|
|
86
|
+
case avs_pb.Execution.Step.OutputDataCase.GRAPHQL:
|
|
87
|
+
return typeof step.getGraphql === "function"
|
|
88
|
+
? step.getGraphql()
|
|
89
|
+
: step.graphql;
|
|
90
|
+
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ:
|
|
91
|
+
return typeof step.getContractRead === "function"
|
|
92
|
+
? step.getContractRead()
|
|
93
|
+
: step.contractRead;
|
|
94
|
+
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE:
|
|
95
|
+
return typeof step.getContractWrite === "function"
|
|
96
|
+
? step.getContractWrite()
|
|
97
|
+
: step.contractWrite;
|
|
98
|
+
case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
|
|
99
|
+
return typeof step.getCustomCode === "function"
|
|
167
100
|
? step.getCustomCode()
|
|
168
101
|
: step.customCode;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
customCodeOutput.hasData()) {
|
|
172
|
-
try {
|
|
173
|
-
return convertProtobufValueToJs(customCodeOutput.getData());
|
|
174
|
-
}
|
|
175
|
-
catch {
|
|
176
|
-
// Fallback: if conversion fails, return the raw data
|
|
177
|
-
return customCodeOutput.getData();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else if (customCodeOutput.data) {
|
|
181
|
-
// For plain objects, try to convert or use directly
|
|
182
|
-
return typeof customCodeOutput.data.getKindCase === "function"
|
|
183
|
-
? convertProtobufValueToJs(customCodeOutput.data)
|
|
184
|
-
: customCodeOutput.data;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
|
-
case avs_pb.Execution.Step.OutputDataCase.REST_API: {
|
|
190
|
-
const restApiOutput = typeof step.getRestApi === "function"
|
|
102
|
+
case avs_pb.Execution.Step.OutputDataCase.REST_API:
|
|
103
|
+
return typeof step.getRestApi === "function"
|
|
191
104
|
? step.getRestApi()
|
|
192
105
|
: step.restApi;
|
|
193
|
-
if (restApiOutput) {
|
|
194
|
-
if (typeof restApiOutput.hasData === "function" &&
|
|
195
|
-
restApiOutput.hasData()) {
|
|
196
|
-
try {
|
|
197
|
-
return convertProtobufValueToJs(restApiOutput.getData());
|
|
198
|
-
}
|
|
199
|
-
catch {
|
|
200
|
-
// Fallback: if conversion fails, return the raw data
|
|
201
|
-
return restApiOutput.getData();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else if (restApiOutput.data) {
|
|
205
|
-
// For plain objects, try to convert or use directly
|
|
206
|
-
return typeof restApiOutput.data.getKindCase === "function"
|
|
207
|
-
? convertProtobufValueToJs(restApiOutput.data)
|
|
208
|
-
: restApiOutput.data;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
106
|
case avs_pb.Execution.Step.OutputDataCase.BRANCH:
|
|
214
107
|
return typeof step.getBranch === "function"
|
|
215
|
-
? step.getBranch()
|
|
108
|
+
? step.getBranch()
|
|
216
109
|
: step.branch;
|
|
217
|
-
case avs_pb.Execution.Step.OutputDataCase.
|
|
218
|
-
|
|
219
|
-
? step.getLoop()
|
|
220
|
-
: step.loop;
|
|
221
|
-
if (loopOutput) {
|
|
222
|
-
if (typeof loopOutput.getData === "function" &&
|
|
223
|
-
loopOutput.getData()) {
|
|
224
|
-
try {
|
|
225
|
-
return JSON.parse(loopOutput.getData());
|
|
226
|
-
}
|
|
227
|
-
catch {
|
|
228
|
-
return loopOutput.getData();
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
else if (loopOutput.data) {
|
|
232
|
-
// For plain objects
|
|
233
|
-
try {
|
|
234
|
-
return typeof loopOutput.data === "string"
|
|
235
|
-
? JSON.parse(loopOutput.data)
|
|
236
|
-
: loopOutput.data;
|
|
237
|
-
}
|
|
238
|
-
catch {
|
|
239
|
-
return loopOutput.data;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
case avs_pb.Execution.Step.OutputDataCase.GRAPHQL: {
|
|
246
|
-
const graphqlOutput = typeof step.getGraphql === "function"
|
|
247
|
-
? step.getGraphql()
|
|
248
|
-
: step.graphql;
|
|
249
|
-
if (graphqlOutput) {
|
|
250
|
-
try {
|
|
251
|
-
return typeof graphqlOutput.toObject === "function"
|
|
252
|
-
? graphqlOutput.toObject()
|
|
253
|
-
: graphqlOutput;
|
|
254
|
-
}
|
|
255
|
-
catch {
|
|
256
|
-
return undefined;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ: {
|
|
262
|
-
const contractReadOutput = typeof step.getContractRead === "function"
|
|
263
|
-
? step.getContractRead()
|
|
264
|
-
: step.contractRead;
|
|
265
|
-
if (contractReadOutput) {
|
|
266
|
-
// Check if the output has a data field that's a protobuf Value
|
|
267
|
-
if (typeof contractReadOutput.hasData === "function" &&
|
|
268
|
-
contractReadOutput.hasData()) {
|
|
269
|
-
try {
|
|
270
|
-
// Convert protobuf Value to JavaScript object
|
|
271
|
-
const data = convertProtobufValueToJs(contractReadOutput.getData());
|
|
272
|
-
// Always return the array directly for contract read outputs
|
|
273
|
-
if (Array.isArray(data)) {
|
|
274
|
-
return data;
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
// If it's a single object, wrap it in an array for consistency
|
|
278
|
-
return [data];
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
catch (error) {
|
|
282
|
-
console.warn("Failed to convert contract read data from protobuf Value:", error);
|
|
283
|
-
// Fallback to raw data
|
|
284
|
-
return contractReadOutput.getData();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
else if (contractReadOutput.data) {
|
|
288
|
-
// For plain objects, try to convert or use directly
|
|
289
|
-
const data = typeof contractReadOutput.data.getKindCase === "function"
|
|
290
|
-
? convertProtobufValueToJs(contractReadOutput.data)
|
|
291
|
-
: contractReadOutput.data;
|
|
292
|
-
// Always return the array directly for contract read outputs
|
|
293
|
-
if (Array.isArray(data)) {
|
|
294
|
-
return data;
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
// If it's a single object, wrap it in an array for consistency
|
|
298
|
-
return [data];
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
// Fallback to old structure for backward compatibility
|
|
302
|
-
const outputObj = typeof contractReadOutput.toObject === "function"
|
|
303
|
-
? contractReadOutput.toObject()
|
|
304
|
-
: contractReadOutput;
|
|
305
|
-
// Convert resultsList to results for consistency with ContractReadNode.fromOutputData
|
|
306
|
-
if (outputObj && outputObj.resultsList) {
|
|
307
|
-
// Return the results array directly
|
|
308
|
-
return outputObj.resultsList.map((result) => ({
|
|
309
|
-
methodName: result.methodName,
|
|
310
|
-
success: result.success,
|
|
311
|
-
error: result.error,
|
|
312
|
-
data: result.dataList || [],
|
|
313
|
-
}));
|
|
314
|
-
}
|
|
315
|
-
return outputObj;
|
|
316
|
-
}
|
|
317
|
-
return undefined;
|
|
318
|
-
}
|
|
319
|
-
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE: {
|
|
320
|
-
const contractWriteOutput = typeof step.getContractWrite === "function"
|
|
321
|
-
? step.getContractWrite()
|
|
322
|
-
: step.contractWrite;
|
|
323
|
-
if (contractWriteOutput) {
|
|
324
|
-
// Check if the output has a data field that's a protobuf Value
|
|
325
|
-
if (typeof contractWriteOutput.hasData === "function" &&
|
|
326
|
-
contractWriteOutput.hasData()) {
|
|
327
|
-
try {
|
|
328
|
-
// Convert protobuf Value to JavaScript object
|
|
329
|
-
const data = convertProtobufValueToJs(contractWriteOutput.getData());
|
|
330
|
-
// Always return the array directly for contract write outputs
|
|
331
|
-
if (Array.isArray(data)) {
|
|
332
|
-
return data;
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
// If it's a single object, wrap it in an array for consistency
|
|
336
|
-
return [data];
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
console.warn("Failed to convert contract write data from protobuf Value:", error);
|
|
341
|
-
// Fallback to raw data
|
|
342
|
-
return contractWriteOutput.getData();
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
else if (contractWriteOutput.data) {
|
|
346
|
-
// For plain objects, try to convert or use directly
|
|
347
|
-
const data = typeof contractWriteOutput.data.getKindCase === "function"
|
|
348
|
-
? convertProtobufValueToJs(contractWriteOutput.data)
|
|
349
|
-
: contractWriteOutput.data;
|
|
350
|
-
// Always return the array directly for contract write outputs
|
|
351
|
-
if (Array.isArray(data)) {
|
|
352
|
-
return data;
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
// If it's a single object, wrap it in an array for consistency
|
|
356
|
-
return [data];
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
// Fallback to old structure for backward compatibility
|
|
360
|
-
const outputObj = typeof contractWriteOutput.toObject === "function"
|
|
361
|
-
? contractWriteOutput.toObject()
|
|
362
|
-
: contractWriteOutput;
|
|
363
|
-
// Convert resultsList to results for consistency with ContractWriteNode.fromOutputData
|
|
364
|
-
if (outputObj && outputObj.resultsList) {
|
|
365
|
-
// Return the results array directly
|
|
366
|
-
return outputObj.resultsList.map((result) => ({
|
|
367
|
-
methodName: result.methodName,
|
|
368
|
-
success: result.success,
|
|
369
|
-
error: result.error,
|
|
370
|
-
transaction: result.transaction,
|
|
371
|
-
events: result.eventsList || [],
|
|
372
|
-
returnData: result.returnData,
|
|
373
|
-
inputData: result.inputData,
|
|
374
|
-
}));
|
|
375
|
-
}
|
|
376
|
-
return outputObj;
|
|
377
|
-
}
|
|
378
|
-
return undefined;
|
|
379
|
-
}
|
|
380
|
-
case avs_pb.Execution.Step.OutputDataCase.FILTER: {
|
|
381
|
-
const filterOutput = typeof step.getFilter === "function"
|
|
110
|
+
case avs_pb.Execution.Step.OutputDataCase.FILTER:
|
|
111
|
+
return typeof step.getFilter === "function"
|
|
382
112
|
? step.getFilter()
|
|
383
113
|
: step.filter;
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
: filterOutput;
|
|
389
|
-
}
|
|
390
|
-
catch {
|
|
391
|
-
return undefined;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return undefined;
|
|
395
|
-
}
|
|
114
|
+
case avs_pb.Execution.Step.OutputDataCase.LOOP:
|
|
115
|
+
return typeof step.getLoop === "function"
|
|
116
|
+
? step.getLoop()
|
|
117
|
+
: step.loop;
|
|
396
118
|
default:
|
|
397
|
-
|
|
398
|
-
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
static getOutputDataCase(step) {
|
|
123
|
+
if (typeof step.getOutputDataCase === "function") {
|
|
124
|
+
return step.getOutputDataCase();
|
|
399
125
|
}
|
|
126
|
+
// For plain objects, determine the case by checking which properties exist
|
|
127
|
+
const stepObj = step;
|
|
128
|
+
if (stepObj.blockTrigger)
|
|
129
|
+
return avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER;
|
|
130
|
+
if (stepObj.fixedTimeTrigger)
|
|
131
|
+
return avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER;
|
|
132
|
+
if (stepObj.cronTrigger)
|
|
133
|
+
return avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER;
|
|
134
|
+
if (stepObj.eventTrigger)
|
|
135
|
+
return avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER;
|
|
136
|
+
if (stepObj.manualTrigger)
|
|
137
|
+
return avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER;
|
|
138
|
+
if (stepObj.ethTransfer)
|
|
139
|
+
return avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER;
|
|
140
|
+
if (stepObj.graphql)
|
|
141
|
+
return avs_pb.Execution.Step.OutputDataCase.GRAPHQL;
|
|
142
|
+
if (stepObj.contractRead)
|
|
143
|
+
return avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ;
|
|
144
|
+
if (stepObj.contractWrite)
|
|
145
|
+
return avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE;
|
|
146
|
+
if (stepObj.customCode)
|
|
147
|
+
return avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE;
|
|
148
|
+
if (stepObj.restApi)
|
|
149
|
+
return avs_pb.Execution.Step.OutputDataCase.REST_API;
|
|
150
|
+
if (stepObj.branch)
|
|
151
|
+
return avs_pb.Execution.Step.OutputDataCase.BRANCH;
|
|
152
|
+
if (stepObj.filter)
|
|
153
|
+
return avs_pb.Execution.Step.OutputDataCase.FILTER;
|
|
154
|
+
if (stepObj.loop)
|
|
155
|
+
return avs_pb.Execution.Step.OutputDataCase.LOOP;
|
|
156
|
+
return avs_pb.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET;
|
|
400
157
|
}
|
|
401
158
|
static fromResponse(step) {
|
|
402
159
|
// Extract input data if present - USE PROPER PROTOBUF GETTER
|
|
403
|
-
let
|
|
160
|
+
let configData = undefined;
|
|
404
161
|
// Check for input using proper protobuf methods
|
|
405
|
-
if (typeof step.
|
|
406
|
-
step.
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
162
|
+
if (typeof step.hasConfig === "function" &&
|
|
163
|
+
step.hasConfig()) {
|
|
164
|
+
const configValue = step.getConfig();
|
|
165
|
+
if (configValue) {
|
|
409
166
|
// If it's a protobuf Value instance, convert it
|
|
410
167
|
try {
|
|
411
|
-
|
|
168
|
+
configData = convertProtobufValueToJs(configValue);
|
|
412
169
|
}
|
|
413
170
|
catch (error) {
|
|
414
171
|
console.warn("Failed to convert protobuf input value:", error);
|
|
415
172
|
// Fallback: if conversion fails, use the raw value
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
else if (step.input) {
|
|
421
|
-
// Fallback for plain objects (from .toObject() calls)
|
|
422
|
-
const inputValue = step.input;
|
|
423
|
-
// If it's already a plain JavaScript object, use it directly
|
|
424
|
-
if (typeof inputValue === "object" && !inputValue.getKindCase) {
|
|
425
|
-
inputData = inputValue;
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
// If it's a protobuf Value instance, convert it
|
|
429
|
-
try {
|
|
430
|
-
inputData = convertProtobufValueToJs(inputValue);
|
|
431
|
-
}
|
|
432
|
-
catch (error) {
|
|
433
|
-
// Fallback: if conversion fails, use the raw value
|
|
434
|
-
inputData = inputValue;
|
|
173
|
+
configData = configValue;
|
|
435
174
|
}
|
|
436
175
|
}
|
|
437
176
|
}
|
|
@@ -463,7 +202,7 @@ class Step {
|
|
|
463
202
|
error: getError(),
|
|
464
203
|
log: getLog(),
|
|
465
204
|
inputsList: getInputsList(),
|
|
466
|
-
|
|
205
|
+
config: configData,
|
|
467
206
|
output: Step.getOutput(step),
|
|
468
207
|
startAt: getStartAt(),
|
|
469
208
|
endAt: getEndAt(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAC5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAqC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAuB1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAY9D;AAED,eAAe,YAAY,CAAC"}
|