@avaprotocol/sdk-js 2.4.4 → 2.5.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.
- package/CHANGELOG.md +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +528 -94
- package/dist/index.mjs +534 -96
- package/dist/models/node/filter.d.ts.map +1 -1
- package/dist/models/node/filter.js +22 -3
- package/dist/models/node/loop.d.ts.map +1 -1
- package/dist/models/node/loop.js +17 -21
- package/dist/models/node/restApi.d.ts +2 -2
- package/dist/models/node/restApi.d.ts.map +1 -1
- package/dist/models/node/restApi.js +15 -3
- package/dist/models/step.d.ts.map +1 -1
- package/dist/models/step.js +253 -21
- package/dist/models/trigger/manual.d.ts +6 -10
- package/dist/models/trigger/manual.d.ts.map +1 -1
- package/dist/models/trigger/manual.js +108 -25
- package/dist/models/workflow.d.ts.map +1 -1
- package/dist/models/workflow.js +0 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/models/node/filter.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/models/node/filter.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,eAAe,EAEhB,MAAM,oBAAoB,CAAC;AAM5B,cAAM,UAAW,SAAQ,IAAI;gBACf,KAAK,EAAE,eAAe;IAIlC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,UAAU;IAerD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAuB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAgCrE;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Node from "./interface";
|
|
2
2
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { NodeType } from "@avaprotocol/types";
|
|
3
|
+
import { NodeType, } from "@avaprotocol/types";
|
|
4
4
|
import { convertInputToProtobuf, extractInputFromProtobuf } from "../../utils";
|
|
5
|
+
import { Value } from "google-protobuf/google/protobuf/struct_pb";
|
|
5
6
|
// Required props for constructor: id, name, type and data: { expression, sourceId }
|
|
6
7
|
class FilterNode extends Node {
|
|
7
8
|
constructor(props) {
|
|
@@ -26,7 +27,7 @@ class FilterNode extends Node {
|
|
|
26
27
|
const node = new avs_pb.FilterNode();
|
|
27
28
|
const config = new avs_pb.FilterNode.Config();
|
|
28
29
|
config.setExpression(this.data.expression);
|
|
29
|
-
config.setSourceId(this.data.sourceId ||
|
|
30
|
+
config.setSourceId(this.data.sourceId || "");
|
|
30
31
|
node.setConfig(config);
|
|
31
32
|
// Set input data if provided
|
|
32
33
|
const inputValue = convertInputToProtobuf(this.input);
|
|
@@ -38,7 +39,25 @@ class FilterNode extends Node {
|
|
|
38
39
|
}
|
|
39
40
|
static fromOutputData(outputData) {
|
|
40
41
|
const filterOutput = outputData.getFilter();
|
|
41
|
-
|
|
42
|
+
if (!filterOutput) {
|
|
43
|
+
throw new Error("FilterNode output data is missing");
|
|
44
|
+
}
|
|
45
|
+
const anyData = filterOutput.getData();
|
|
46
|
+
if (!anyData) {
|
|
47
|
+
throw new Error("FilterNode output data.getData() is missing");
|
|
48
|
+
}
|
|
49
|
+
// Unpack the Any to get the Value
|
|
50
|
+
const value = Value.deserializeBinary(anyData.getValue_asU8());
|
|
51
|
+
// Convert the Value to JavaScript
|
|
52
|
+
const result = value.toJavaScript();
|
|
53
|
+
// The result contains the entire response object, extract the data array
|
|
54
|
+
if (result &&
|
|
55
|
+
typeof result === "object" &&
|
|
56
|
+
!Array.isArray(result) &&
|
|
57
|
+
result.data) {
|
|
58
|
+
return result.data;
|
|
59
|
+
}
|
|
60
|
+
throw new Error("FilterNode output data does not contain expected data structure");
|
|
42
61
|
}
|
|
43
62
|
}
|
|
44
63
|
export default FilterNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/models/node/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,aAAa,CAAC;AAO/B,OAAO,EAGL,aAAa,EAGd,MAAM,oBAAoB,CAAC;AAG5B,cAAM,QAAS,SAAQ,IAAI;gBACb,KAAK,EAAE,aAAa;IAIhC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ;IAsCnD,OAAO,CAAC,MAAM,CAAC,yBAAyB;
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/models/node/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,aAAa,CAAC;AAO/B,OAAO,EAGL,aAAa,EAGd,MAAM,oBAAoB,CAAC;AAG5B,cAAM,QAAS,SAAQ,IAAI;gBACb,KAAK,EAAE,aAAa;IAIhC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ;IAsCnD,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAsBxC,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAe3C,OAAO,CAAC,0BAA0B;IA4BlC,SAAS,IAAI,MAAM,CAAC,QAAQ;IAqC5B,OAAO,CAAC,mBAAmB;IA2G3B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO;CAuCzE;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/models/node/loop.js
CHANGED
|
@@ -44,24 +44,20 @@ class LoopNode extends Node {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
static extractRunnerFromProtobuf(loopNodeData) {
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return { type: "contractWrite", data: loopNodeData.contractWrite };
|
|
62
|
-
}
|
|
63
|
-
else if (loopNodeData.graphqlDataQuery) {
|
|
64
|
-
return { type: "graphqlDataQuery", data: loopNodeData.graphqlDataQuery };
|
|
47
|
+
// Define a mapping of runner types to their corresponding data keys
|
|
48
|
+
const runnerMapping = {
|
|
49
|
+
restApi: "restApi",
|
|
50
|
+
customCode: "customCode",
|
|
51
|
+
ethTransfer: "ethTransfer",
|
|
52
|
+
contractRead: "contractRead",
|
|
53
|
+
contractWrite: "contractWrite",
|
|
54
|
+
graphqlDataQuery: "graphqlDataQuery",
|
|
55
|
+
};
|
|
56
|
+
// Iterate over the mapping to find the matching runner type
|
|
57
|
+
for (const [type, key] of Object.entries(runnerMapping)) {
|
|
58
|
+
if (loopNodeData[key]) {
|
|
59
|
+
return { type, data: loopNodeData[key] };
|
|
60
|
+
}
|
|
65
61
|
}
|
|
66
62
|
return null;
|
|
67
63
|
}
|
|
@@ -85,9 +81,9 @@ class LoopNode extends Node {
|
|
|
85
81
|
}
|
|
86
82
|
if (typeof executionMode === "string") {
|
|
87
83
|
switch (executionMode.toLowerCase()) {
|
|
88
|
-
case
|
|
84
|
+
case ExecutionMode.Parallel:
|
|
89
85
|
return 1;
|
|
90
|
-
case
|
|
86
|
+
case ExecutionMode.Sequential:
|
|
91
87
|
default:
|
|
92
88
|
return 0; // Default to sequential for safety
|
|
93
89
|
}
|
|
@@ -195,7 +191,7 @@ class LoopNode extends Node {
|
|
|
195
191
|
url: apiConfig.url,
|
|
196
192
|
method: apiConfig.method,
|
|
197
193
|
body: apiConfig.body || "",
|
|
198
|
-
|
|
194
|
+
headers: apiConfig.headers,
|
|
199
195
|
});
|
|
200
196
|
loopNode.setRestApi(restApi);
|
|
201
197
|
}
|
|
@@ -12,11 +12,11 @@ declare class RestAPINode extends Node {
|
|
|
12
12
|
url: string;
|
|
13
13
|
method: string;
|
|
14
14
|
body?: string;
|
|
15
|
-
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
16
|
}): avs_pb.RestAPINode;
|
|
17
17
|
static fromResponse(raw: avs_pb.TaskNode): RestAPINode;
|
|
18
18
|
toRequest(): avs_pb.TaskNode;
|
|
19
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp):
|
|
19
|
+
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): Record<string, unknown> | null;
|
|
20
20
|
}
|
|
21
21
|
export default RestAPINode;
|
|
22
22
|
//# sourceMappingURL=restApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restApi.d.ts","sourceRoot":"","sources":["../../../src/models/node/restApi.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAS5B,cAAM,WAAY,SAAQ,IAAI;gBAChB,KAAK,EAAE,gBAAgB;IAInC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,
|
|
1
|
+
{"version":3,"file":"restApi.d.ts","sourceRoot":"","sources":["../../../src/models/node/restApi.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAS5B,cAAM,WAAY,SAAQ,IAAI;gBAChB,KAAK,EAAE,gBAAgB;IAInC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,MAAM,CAAC,WAAW;IAmBtB,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,WAAW;IA+BtD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAwB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAehG;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -18,9 +18,9 @@ class RestAPINode extends Node {
|
|
|
18
18
|
config.setUrl(configData.url);
|
|
19
19
|
config.setMethod(configData.method);
|
|
20
20
|
config.setBody(configData.body || "");
|
|
21
|
-
if (configData.
|
|
21
|
+
if (configData.headers && Object.keys(configData.headers).length > 0) {
|
|
22
22
|
const headersMap = config.getHeadersMap();
|
|
23
|
-
configData.
|
|
23
|
+
Object.entries(configData.headers).forEach(([key, value]) => {
|
|
24
24
|
headersMap.set(key, value);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -39,7 +39,19 @@ class RestAPINode extends Node {
|
|
|
39
39
|
return new RestAPINode({
|
|
40
40
|
...obj,
|
|
41
41
|
type: NodeType.RestAPI,
|
|
42
|
-
data:
|
|
42
|
+
data: {
|
|
43
|
+
url: raw.getRestApi().getConfig().getUrl(),
|
|
44
|
+
method: raw.getRestApi().getConfig().getMethod(),
|
|
45
|
+
body: raw.getRestApi().getConfig().getBody(),
|
|
46
|
+
headers: (() => {
|
|
47
|
+
const headersMap = raw.getRestApi().getConfig().getHeadersMap();
|
|
48
|
+
const headers = {};
|
|
49
|
+
headersMap.forEach((value, key) => {
|
|
50
|
+
headers[key] = value;
|
|
51
|
+
});
|
|
52
|
+
return headers;
|
|
53
|
+
})(),
|
|
54
|
+
},
|
|
43
55
|
input: input, // Include input data from top-level TaskNode
|
|
44
56
|
});
|
|
45
57
|
}
|
|
@@ -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,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,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;
|
|
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,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,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;IAkmB9D,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAqFvD;AAED,eAAe,IAAI,CAAC"}
|
package/dist/models/step.js
CHANGED
|
@@ -76,17 +76,20 @@ class Step {
|
|
|
76
76
|
return undefined;
|
|
77
77
|
// Trigger outputs
|
|
78
78
|
case avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
|
|
79
|
-
|
|
79
|
+
const blockTrigger = typeof step.getBlockTrigger === "function"
|
|
80
80
|
? step.getBlockTrigger()?.toObject()
|
|
81
81
|
: step.blockTrigger;
|
|
82
|
+
return { data: blockTrigger }; // ✅ Use standard structure
|
|
82
83
|
case avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
|
|
83
|
-
|
|
84
|
+
const fixedTimeTrigger = typeof step.getFixedTimeTrigger === "function"
|
|
84
85
|
? step.getFixedTimeTrigger()?.toObject()
|
|
85
86
|
: step.fixedTimeTrigger;
|
|
87
|
+
return { data: fixedTimeTrigger }; // ✅ Use standard structure
|
|
86
88
|
case avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER:
|
|
87
|
-
|
|
89
|
+
const cronTrigger = typeof step.getCronTrigger === "function"
|
|
88
90
|
? step.getCronTrigger()?.toObject()
|
|
89
91
|
: step.cronTrigger;
|
|
92
|
+
return { data: cronTrigger }; // ✅ Use standard structure
|
|
90
93
|
case avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER:
|
|
91
94
|
const eventTrigger = typeof step.getEventTrigger === "function"
|
|
92
95
|
? step.getEventTrigger()
|
|
@@ -96,46 +99,268 @@ class Step {
|
|
|
96
99
|
if (typeof eventTrigger.hasData === "function" &&
|
|
97
100
|
eventTrigger.hasData()) {
|
|
98
101
|
try {
|
|
99
|
-
|
|
102
|
+
const eventData = convertProtobufValueToJs(eventTrigger.getData());
|
|
103
|
+
return { data: eventData }; // ✅ Use standard structure
|
|
100
104
|
}
|
|
101
105
|
catch (error) {
|
|
102
106
|
console.warn("Failed to convert event trigger data from protobuf Value:", error);
|
|
103
|
-
return eventTrigger.getData();
|
|
107
|
+
return { data: eventTrigger.getData() }; // ✅ Use standard structure
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
else if (eventTrigger.data) {
|
|
107
111
|
// For plain objects, try to convert or use directly
|
|
108
|
-
|
|
112
|
+
const eventData = typeof eventTrigger.data.getKindCase === "function"
|
|
109
113
|
? convertProtobufValueToJs(eventTrigger.data)
|
|
110
114
|
: eventTrigger.data;
|
|
115
|
+
return { data: eventData }; // ✅ Use standard structure
|
|
111
116
|
}
|
|
112
117
|
// Fallback to old structure for backward compatibility
|
|
113
118
|
if (typeof eventTrigger.hasEvmLog === "function" &&
|
|
114
119
|
eventTrigger.hasEvmLog()) {
|
|
115
|
-
return eventTrigger.getEvmLog()?.toObject();
|
|
120
|
+
return { data: eventTrigger.getEvmLog()?.toObject() }; // ✅ Use standard structure
|
|
116
121
|
}
|
|
117
122
|
else if (typeof eventTrigger.hasTransferLog === "function" &&
|
|
118
123
|
eventTrigger.hasTransferLog()) {
|
|
119
|
-
return eventTrigger.getTransferLog()?.toObject();
|
|
124
|
+
return { data: eventTrigger.getTransferLog()?.toObject() }; // ✅ Use standard structure
|
|
120
125
|
}
|
|
121
126
|
else if (eventTrigger.evmLog) {
|
|
122
|
-
return eventTrigger.evmLog;
|
|
127
|
+
return { data: eventTrigger.evmLog }; // ✅ Use standard structure
|
|
123
128
|
}
|
|
124
129
|
else if (eventTrigger.transferLog) {
|
|
125
|
-
return eventTrigger.transferLog;
|
|
130
|
+
return { data: eventTrigger.transferLog }; // ✅ Use standard structure
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
|
-
return
|
|
129
|
-
case avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
|
|
130
|
-
|
|
131
|
-
? step.getManualTrigger()
|
|
133
|
+
return { data: null }; // ✅ Use standard structure
|
|
134
|
+
case avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER: {
|
|
135
|
+
const manualTrigger = typeof step.getManualTrigger === "function"
|
|
136
|
+
? step.getManualTrigger()
|
|
132
137
|
: step.manualTrigger;
|
|
138
|
+
if (manualTrigger) {
|
|
139
|
+
const result = {};
|
|
140
|
+
// Check for the new data field structure
|
|
141
|
+
if (typeof manualTrigger.hasData === "function" &&
|
|
142
|
+
manualTrigger.hasData()) {
|
|
143
|
+
try {
|
|
144
|
+
const userData = convertProtobufValueToJs(manualTrigger.getData());
|
|
145
|
+
// Check if the userData is the new format with nested structure
|
|
146
|
+
if (userData && typeof userData === 'object' &&
|
|
147
|
+
userData.data !== undefined &&
|
|
148
|
+
(userData.headers !== undefined || userData.pathParams !== undefined)) {
|
|
149
|
+
// This is the new format where the entire structure is in the data field
|
|
150
|
+
// Flatten it by extracting the nested data
|
|
151
|
+
result.data = userData.data;
|
|
152
|
+
if (userData.headers) {
|
|
153
|
+
// Keep headers as object format for consistency
|
|
154
|
+
if (Array.isArray(userData.headers)) {
|
|
155
|
+
// Check if it's already in Array<[string, string]> format
|
|
156
|
+
if (userData.headers.length > 0 && Array.isArray(userData.headers[0])) {
|
|
157
|
+
// Convert from Array<[string, string]> to object format
|
|
158
|
+
const headersObject = {};
|
|
159
|
+
for (const [key, value] of userData.headers) {
|
|
160
|
+
headersObject[key] = value;
|
|
161
|
+
}
|
|
162
|
+
result.headers = headersObject;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Convert from Array<{key: value}> to object format
|
|
166
|
+
const headersObject = {};
|
|
167
|
+
for (const header of userData.headers) {
|
|
168
|
+
for (const [key, value] of Object.entries(header)) {
|
|
169
|
+
headersObject[key] = value;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
result.headers = headersObject;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// Already in object format
|
|
177
|
+
result.headers = userData.headers;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (userData.pathParams) {
|
|
181
|
+
// Keep pathParams as object format for consistency
|
|
182
|
+
if (Array.isArray(userData.pathParams)) {
|
|
183
|
+
// Check if it's already in Array<[string, string]> format
|
|
184
|
+
if (userData.pathParams.length > 0 && Array.isArray(userData.pathParams[0])) {
|
|
185
|
+
// Convert from Array<[string, string]> to object format
|
|
186
|
+
const pathParamsObject = {};
|
|
187
|
+
for (const [key, value] of userData.pathParams) {
|
|
188
|
+
pathParamsObject[key] = value;
|
|
189
|
+
}
|
|
190
|
+
result.pathParams = pathParamsObject;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
// Convert from Array<{key: value}> to object format
|
|
194
|
+
const pathParamsObject = {};
|
|
195
|
+
for (const pathParam of userData.pathParams) {
|
|
196
|
+
for (const [key, value] of Object.entries(pathParam)) {
|
|
197
|
+
pathParamsObject[key] = value;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
result.pathParams = pathParamsObject;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
// Already in object format
|
|
205
|
+
result.pathParams = userData.pathParams;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// This is the old format with just user data
|
|
211
|
+
result.data = userData;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
console.warn("Failed to convert manual trigger data from protobuf Value:", error);
|
|
216
|
+
result.data = manualTrigger.getData();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else if (manualTrigger.data) {
|
|
220
|
+
// For plain objects, try to convert or use directly
|
|
221
|
+
const userData = typeof manualTrigger.data.getKindCase === "function"
|
|
222
|
+
? convertProtobufValueToJs(manualTrigger.data)
|
|
223
|
+
: manualTrigger.data;
|
|
224
|
+
// Check if the userData is the new format with nested structure
|
|
225
|
+
if (userData && typeof userData === 'object' &&
|
|
226
|
+
userData.data !== undefined &&
|
|
227
|
+
(userData.headers !== undefined || userData.pathParams !== undefined)) {
|
|
228
|
+
// This is the new format where the entire structure is in the data field
|
|
229
|
+
// Flatten it by extracting the nested data
|
|
230
|
+
result.data = userData.data;
|
|
231
|
+
if (userData.headers) {
|
|
232
|
+
// Keep headers as object format for consistency
|
|
233
|
+
if (Array.isArray(userData.headers)) {
|
|
234
|
+
// Check if it's already in Array<[string, string]> format
|
|
235
|
+
if (userData.headers.length > 0 && Array.isArray(userData.headers[0])) {
|
|
236
|
+
// Convert from Array<[string, string]> to object format
|
|
237
|
+
const headersObject = {};
|
|
238
|
+
for (const [key, value] of userData.headers) {
|
|
239
|
+
headersObject[key] = value;
|
|
240
|
+
}
|
|
241
|
+
result.headers = headersObject;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
// Convert from Array<{key: value}> to object format
|
|
245
|
+
const headersObject = {};
|
|
246
|
+
for (const header of userData.headers) {
|
|
247
|
+
for (const [key, value] of Object.entries(header)) {
|
|
248
|
+
headersObject[key] = value;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
result.headers = headersObject;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
// Already in object format
|
|
256
|
+
result.headers = userData.headers;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (userData.pathParams) {
|
|
260
|
+
// Keep pathParams as object format for consistency
|
|
261
|
+
if (Array.isArray(userData.pathParams)) {
|
|
262
|
+
// Check if it's already in Array<[string, string]> format
|
|
263
|
+
if (userData.pathParams.length > 0 && Array.isArray(userData.pathParams[0])) {
|
|
264
|
+
// Convert from Array<[string, string]> to object format
|
|
265
|
+
const pathParamsObject = {};
|
|
266
|
+
for (const [key, value] of userData.pathParams) {
|
|
267
|
+
pathParamsObject[key] = value;
|
|
268
|
+
}
|
|
269
|
+
result.pathParams = pathParamsObject;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
// Convert from Array<{key: value}> to object format
|
|
273
|
+
const pathParamsObject = {};
|
|
274
|
+
for (const pathParam of userData.pathParams) {
|
|
275
|
+
for (const [key, value] of Object.entries(pathParam)) {
|
|
276
|
+
pathParamsObject[key] = value;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
result.pathParams = pathParamsObject;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// Already in object format
|
|
284
|
+
result.pathParams = userData.pathParams;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
// This is the old format with just user data
|
|
290
|
+
result.data = userData;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// Include headers for webhook testing - use object format for consistency
|
|
294
|
+
if (typeof manualTrigger.getHeadersMap === "function") {
|
|
295
|
+
const headersMap = manualTrigger.getHeadersMap();
|
|
296
|
+
if (headersMap && headersMap.getLength() > 0) {
|
|
297
|
+
const headersObject = {};
|
|
298
|
+
headersMap.forEach((value, key) => {
|
|
299
|
+
headersObject[key] = value;
|
|
300
|
+
});
|
|
301
|
+
result.headers = headersObject;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else if (manualTrigger.headers) {
|
|
305
|
+
// For plain objects, convert to object format
|
|
306
|
+
if (Array.isArray(manualTrigger.headers)) {
|
|
307
|
+
const headersObject = {};
|
|
308
|
+
for (const [key, value] of Object.entries(manualTrigger.headers)) {
|
|
309
|
+
headersObject[key] = value;
|
|
310
|
+
}
|
|
311
|
+
result.headers = headersObject;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
result.headers = manualTrigger.headers;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// Include pathParams for webhook testing - use object format for consistency
|
|
318
|
+
if (typeof manualTrigger.getPathparamsMap === "function") {
|
|
319
|
+
const pathParamsMap = manualTrigger.getPathparamsMap();
|
|
320
|
+
if (pathParamsMap && pathParamsMap.getLength() > 0) {
|
|
321
|
+
const pathParamsObject = {};
|
|
322
|
+
pathParamsMap.forEach((value, key) => {
|
|
323
|
+
pathParamsObject[key] = value;
|
|
324
|
+
});
|
|
325
|
+
result.pathParams = pathParamsObject;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else if (manualTrigger.pathparams) {
|
|
329
|
+
// For plain objects, convert to object format
|
|
330
|
+
if (Array.isArray(manualTrigger.pathparams)) {
|
|
331
|
+
const pathParamsObject = {};
|
|
332
|
+
for (const [key, value] of Object.entries(manualTrigger.pathparams)) {
|
|
333
|
+
pathParamsObject[key] = value;
|
|
334
|
+
}
|
|
335
|
+
result.pathParams = pathParamsObject;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
result.pathParams = manualTrigger.pathparams;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// Check if this is the new format with no data field or null data
|
|
342
|
+
if (Object.keys(result).length === 0) {
|
|
343
|
+
const objData = manualTrigger.toObject?.() || manualTrigger;
|
|
344
|
+
if (objData && objData.data === undefined) {
|
|
345
|
+
// No data was provided, return null
|
|
346
|
+
result.data = null;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
// Fallback to old structure for backward compatibility
|
|
350
|
+
return { data: objData };
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// For manual triggers, return the flat structure
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
return { data: null };
|
|
357
|
+
}
|
|
133
358
|
// Node outputs - RESTORE MISSING CASES
|
|
134
359
|
case avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER:
|
|
135
360
|
return typeof step.getEthTransfer === "function"
|
|
136
361
|
? step.getEthTransfer()?.toObject()
|
|
137
362
|
: step.ethTransfer;
|
|
138
|
-
case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
|
|
363
|
+
case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE: {
|
|
139
364
|
const customCodeOutput = typeof step.getCustomCode === "function"
|
|
140
365
|
? step.getCustomCode()
|
|
141
366
|
: step.customCode;
|
|
@@ -158,7 +383,8 @@ class Step {
|
|
|
158
383
|
}
|
|
159
384
|
}
|
|
160
385
|
return undefined;
|
|
161
|
-
|
|
386
|
+
}
|
|
387
|
+
case avs_pb.Execution.Step.OutputDataCase.REST_API: {
|
|
162
388
|
const restApiOutput = typeof step.getRestApi === "function"
|
|
163
389
|
? step.getRestApi()
|
|
164
390
|
: step.restApi;
|
|
@@ -181,11 +407,12 @@ class Step {
|
|
|
181
407
|
}
|
|
182
408
|
}
|
|
183
409
|
return undefined;
|
|
410
|
+
}
|
|
184
411
|
case avs_pb.Execution.Step.OutputDataCase.BRANCH:
|
|
185
412
|
return typeof step.getBranch === "function"
|
|
186
413
|
? step.getBranch()?.toObject()
|
|
187
414
|
: step.branch;
|
|
188
|
-
case avs_pb.Execution.Step.OutputDataCase.LOOP:
|
|
415
|
+
case avs_pb.Execution.Step.OutputDataCase.LOOP: {
|
|
189
416
|
const loopOutput = typeof step.getLoop === "function"
|
|
190
417
|
? step.getLoop()
|
|
191
418
|
: step.loop;
|
|
@@ -212,7 +439,8 @@ class Step {
|
|
|
212
439
|
}
|
|
213
440
|
}
|
|
214
441
|
return undefined;
|
|
215
|
-
|
|
442
|
+
}
|
|
443
|
+
case avs_pb.Execution.Step.OutputDataCase.GRAPHQL: {
|
|
216
444
|
const graphqlOutput = typeof step.getGraphql === "function"
|
|
217
445
|
? step.getGraphql()
|
|
218
446
|
: step.graphql;
|
|
@@ -227,7 +455,8 @@ class Step {
|
|
|
227
455
|
}
|
|
228
456
|
}
|
|
229
457
|
return undefined;
|
|
230
|
-
|
|
458
|
+
}
|
|
459
|
+
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ: {
|
|
231
460
|
const contractReadOutput = typeof step.getContractRead === "function"
|
|
232
461
|
? step.getContractRead()
|
|
233
462
|
: step.contractRead;
|
|
@@ -284,7 +513,8 @@ class Step {
|
|
|
284
513
|
return outputObj;
|
|
285
514
|
}
|
|
286
515
|
return undefined;
|
|
287
|
-
|
|
516
|
+
}
|
|
517
|
+
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE: {
|
|
288
518
|
const contractWriteOutput = typeof step.getContractWrite === "function"
|
|
289
519
|
? step.getContractWrite()
|
|
290
520
|
: step.contractWrite;
|
|
@@ -344,7 +574,8 @@ class Step {
|
|
|
344
574
|
return outputObj;
|
|
345
575
|
}
|
|
346
576
|
return undefined;
|
|
347
|
-
|
|
577
|
+
}
|
|
578
|
+
case avs_pb.Execution.Step.OutputDataCase.FILTER: {
|
|
348
579
|
const filterOutput = typeof step.getFilter === "function"
|
|
349
580
|
? step.getFilter()
|
|
350
581
|
: step.filter;
|
|
@@ -359,6 +590,7 @@ class Step {
|
|
|
359
590
|
}
|
|
360
591
|
}
|
|
361
592
|
return undefined;
|
|
593
|
+
}
|
|
362
594
|
default:
|
|
363
595
|
console.warn(`Unhandled output data type in Step.getOutput: ${step.getOutputDataCase()}`);
|
|
364
596
|
return undefined;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
2
|
import Trigger from "./interface";
|
|
3
|
-
import {
|
|
3
|
+
import { ManualTriggerProps } from "@avaprotocol/types";
|
|
4
4
|
declare class ManualTrigger extends Trigger {
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
pathParams?: Record<string, string>;
|
|
5
7
|
constructor(props: ManualTriggerProps);
|
|
6
8
|
toRequest(): avs_pb.TaskTrigger;
|
|
7
9
|
static fromResponse(raw: avs_pb.TaskTrigger): ManualTrigger;
|
|
8
|
-
getInputVariables(): Record<string,
|
|
9
|
-
/**
|
|
10
|
-
* Convert raw data from runTrigger response to ManualOutput format
|
|
11
|
-
* @param rawData - The raw data from the gRPC response
|
|
12
|
-
* @returns {ManualTriggerOutput | undefined} - The converted data
|
|
13
|
-
*/
|
|
14
|
-
getOutput(): ManualTriggerOutput | undefined;
|
|
10
|
+
getInputVariables(): Record<string, unknown> | null;
|
|
15
11
|
/**
|
|
16
12
|
* Extract output data from RunTriggerResp for manual triggers
|
|
17
13
|
* @param outputData - The RunTriggerResp containing manual trigger output
|
|
18
|
-
* @returns Plain JavaScript object with manual trigger data
|
|
14
|
+
* @returns Plain JavaScript object with manual trigger data in standard structure
|
|
19
15
|
*/
|
|
20
|
-
static fromOutputData(outputData: avs_pb.RunTriggerResp):
|
|
16
|
+
static fromOutputData(outputData: avs_pb.RunTriggerResp): Record<string, unknown> | null;
|
|
21
17
|
}
|
|
22
18
|
export default ManualTrigger;
|
|
23
19
|
//# sourceMappingURL=manual.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAMlC,OAAO,EAEL,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAE5B,cAAM,aAAc,SAAQ,OAAO;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAE/B,KAAK,EAAE,kBAAkB;IAWrC,SAAS,IAAI,MAAM,CAAC,WAAW;IAyC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,aAAa;IA+C3D,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAKnD;;;;OAIG;IACH,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,cAAc,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CA6ClC;AAED,eAAe,aAAa,CAAC"}
|