@avaprotocol/sdk-js 2.4.4 → 2.5.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 +502 -88
- package/dist/index.mjs +508 -90
- 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 +14 -18
- package/dist/models/step.d.ts.map +1 -1
- package/dist/models/step.js +239 -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
|
}
|
|
@@ -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;IAslB9D,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,254 @@ 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
|
+
// Convert headers to consistent Array<[string, string]> format
|
|
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
|
+
result.headers = userData.headers;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// Convert from Array<{key: value}> to Array<[string, string]>
|
|
161
|
+
const headersArray = [];
|
|
162
|
+
for (const header of userData.headers) {
|
|
163
|
+
for (const [key, value] of Object.entries(header)) {
|
|
164
|
+
headersArray.push([key, value]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
result.headers = headersArray;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
// Convert object to Array<[string, string]> format
|
|
172
|
+
const headersArray = [];
|
|
173
|
+
for (const [key, value] of Object.entries(userData.headers)) {
|
|
174
|
+
headersArray.push([key, value]);
|
|
175
|
+
}
|
|
176
|
+
result.headers = headersArray;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (userData.pathParams) {
|
|
180
|
+
// Convert pathParams to consistent Array<[string, string]> format
|
|
181
|
+
if (Array.isArray(userData.pathParams)) {
|
|
182
|
+
// Check if it's already in Array<[string, string]> format
|
|
183
|
+
if (userData.pathParams.length > 0 && Array.isArray(userData.pathParams[0])) {
|
|
184
|
+
result.pathParams = userData.pathParams;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
// Convert from Array<{key: value}> to Array<[string, string]>
|
|
188
|
+
const pathParamsArray = [];
|
|
189
|
+
for (const pathParam of userData.pathParams) {
|
|
190
|
+
for (const [key, value] of Object.entries(pathParam)) {
|
|
191
|
+
pathParamsArray.push([key, value]);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
result.pathParams = pathParamsArray;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// Convert object to Array<[string, string]> format
|
|
199
|
+
const pathParamsArray = [];
|
|
200
|
+
for (const [key, value] of Object.entries(userData.pathParams)) {
|
|
201
|
+
pathParamsArray.push([key, value]);
|
|
202
|
+
}
|
|
203
|
+
result.pathParams = pathParamsArray;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// This is the old format with just user data
|
|
209
|
+
result.data = userData;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
console.warn("Failed to convert manual trigger data from protobuf Value:", error);
|
|
214
|
+
result.data = manualTrigger.getData();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else if (manualTrigger.data) {
|
|
218
|
+
// For plain objects, try to convert or use directly
|
|
219
|
+
const userData = typeof manualTrigger.data.getKindCase === "function"
|
|
220
|
+
? convertProtobufValueToJs(manualTrigger.data)
|
|
221
|
+
: manualTrigger.data;
|
|
222
|
+
// Check if the userData is the new format with nested structure
|
|
223
|
+
if (userData && typeof userData === 'object' &&
|
|
224
|
+
userData.data !== undefined &&
|
|
225
|
+
(userData.headers !== undefined || userData.pathParams !== undefined)) {
|
|
226
|
+
// This is the new format where the entire structure is in the data field
|
|
227
|
+
// Flatten it by extracting the nested data
|
|
228
|
+
result.data = userData.data;
|
|
229
|
+
if (userData.headers) {
|
|
230
|
+
// Convert headers to consistent Array<[string, string]> format
|
|
231
|
+
if (Array.isArray(userData.headers)) {
|
|
232
|
+
// Check if it's already in Array<[string, string]> format
|
|
233
|
+
if (userData.headers.length > 0 && Array.isArray(userData.headers[0])) {
|
|
234
|
+
result.headers = userData.headers;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// Convert from Array<{key: value}> to Array<[string, string]>
|
|
238
|
+
const headersArray = [];
|
|
239
|
+
for (const header of userData.headers) {
|
|
240
|
+
for (const [key, value] of Object.entries(header)) {
|
|
241
|
+
headersArray.push([key, value]);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
result.headers = headersArray;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
// Convert object to Array<[string, string]> format
|
|
249
|
+
const headersArray = [];
|
|
250
|
+
for (const [key, value] of Object.entries(userData.headers)) {
|
|
251
|
+
headersArray.push([key, value]);
|
|
252
|
+
}
|
|
253
|
+
result.headers = headersArray;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (userData.pathParams) {
|
|
257
|
+
// Convert pathParams to consistent Array<[string, string]> format
|
|
258
|
+
if (Array.isArray(userData.pathParams)) {
|
|
259
|
+
// Check if it's already in Array<[string, string]> format
|
|
260
|
+
if (userData.pathParams.length > 0 && Array.isArray(userData.pathParams[0])) {
|
|
261
|
+
result.pathParams = userData.pathParams;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
// Convert from Array<{key: value}> to Array<[string, string]>
|
|
265
|
+
const pathParamsArray = [];
|
|
266
|
+
for (const pathParam of userData.pathParams) {
|
|
267
|
+
for (const [key, value] of Object.entries(pathParam)) {
|
|
268
|
+
pathParamsArray.push([key, value]);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
result.pathParams = pathParamsArray;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
// Convert object to Array<[string, string]> format
|
|
276
|
+
const pathParamsArray = [];
|
|
277
|
+
for (const [key, value] of Object.entries(userData.pathParams)) {
|
|
278
|
+
pathParamsArray.push([key, value]);
|
|
279
|
+
}
|
|
280
|
+
result.pathParams = pathParamsArray;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
// This is the old format with just user data
|
|
286
|
+
result.data = userData;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// Include headers for webhook testing - use consistent Array<[string, string]> format
|
|
290
|
+
if (typeof manualTrigger.getHeadersMap === "function") {
|
|
291
|
+
const headersMap = manualTrigger.getHeadersMap();
|
|
292
|
+
if (headersMap && headersMap.getLength() > 0) {
|
|
293
|
+
const headersArray = [];
|
|
294
|
+
headersMap.forEach((value, key) => {
|
|
295
|
+
headersArray.push([key, value]);
|
|
296
|
+
});
|
|
297
|
+
result.headers = headersArray;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else if (manualTrigger.headers) {
|
|
301
|
+
// For plain objects, convert to consistent Array<[string, string]> format
|
|
302
|
+
const headersArray = [];
|
|
303
|
+
for (const [key, value] of Object.entries(manualTrigger.headers)) {
|
|
304
|
+
headersArray.push([key, value]);
|
|
305
|
+
}
|
|
306
|
+
result.headers = headersArray;
|
|
307
|
+
}
|
|
308
|
+
// Include pathParams for webhook testing - use consistent Array<[string, string]> format
|
|
309
|
+
if (typeof manualTrigger.getPathparamsMap === "function") {
|
|
310
|
+
const pathParamsMap = manualTrigger.getPathparamsMap();
|
|
311
|
+
if (pathParamsMap && pathParamsMap.getLength() > 0) {
|
|
312
|
+
const pathParamsArray = [];
|
|
313
|
+
pathParamsMap.forEach((value, key) => {
|
|
314
|
+
pathParamsArray.push([key, value]);
|
|
315
|
+
});
|
|
316
|
+
result.pathParams = pathParamsArray;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
else if (manualTrigger.pathparams) {
|
|
320
|
+
// For plain objects, convert to consistent Array<[string, string]> format
|
|
321
|
+
const pathParamsArray = [];
|
|
322
|
+
for (const [key, value] of Object.entries(manualTrigger.pathparams)) {
|
|
323
|
+
pathParamsArray.push([key, value]);
|
|
324
|
+
}
|
|
325
|
+
result.pathParams = pathParamsArray;
|
|
326
|
+
}
|
|
327
|
+
// Check if this is the new format with no data field or null data
|
|
328
|
+
if (Object.keys(result).length === 0) {
|
|
329
|
+
const objData = manualTrigger.toObject?.() || manualTrigger;
|
|
330
|
+
if (objData && objData.data === undefined) {
|
|
331
|
+
// No data was provided, return null
|
|
332
|
+
result.data = null;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
// Fallback to old structure for backward compatibility
|
|
336
|
+
return { data: objData };
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
// For manual triggers, return the flat structure
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
return { data: null };
|
|
343
|
+
}
|
|
133
344
|
// Node outputs - RESTORE MISSING CASES
|
|
134
345
|
case avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER:
|
|
135
346
|
return typeof step.getEthTransfer === "function"
|
|
136
347
|
? step.getEthTransfer()?.toObject()
|
|
137
348
|
: step.ethTransfer;
|
|
138
|
-
case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
|
|
349
|
+
case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE: {
|
|
139
350
|
const customCodeOutput = typeof step.getCustomCode === "function"
|
|
140
351
|
? step.getCustomCode()
|
|
141
352
|
: step.customCode;
|
|
@@ -158,7 +369,8 @@ class Step {
|
|
|
158
369
|
}
|
|
159
370
|
}
|
|
160
371
|
return undefined;
|
|
161
|
-
|
|
372
|
+
}
|
|
373
|
+
case avs_pb.Execution.Step.OutputDataCase.REST_API: {
|
|
162
374
|
const restApiOutput = typeof step.getRestApi === "function"
|
|
163
375
|
? step.getRestApi()
|
|
164
376
|
: step.restApi;
|
|
@@ -181,11 +393,12 @@ class Step {
|
|
|
181
393
|
}
|
|
182
394
|
}
|
|
183
395
|
return undefined;
|
|
396
|
+
}
|
|
184
397
|
case avs_pb.Execution.Step.OutputDataCase.BRANCH:
|
|
185
398
|
return typeof step.getBranch === "function"
|
|
186
399
|
? step.getBranch()?.toObject()
|
|
187
400
|
: step.branch;
|
|
188
|
-
case avs_pb.Execution.Step.OutputDataCase.LOOP:
|
|
401
|
+
case avs_pb.Execution.Step.OutputDataCase.LOOP: {
|
|
189
402
|
const loopOutput = typeof step.getLoop === "function"
|
|
190
403
|
? step.getLoop()
|
|
191
404
|
: step.loop;
|
|
@@ -212,7 +425,8 @@ class Step {
|
|
|
212
425
|
}
|
|
213
426
|
}
|
|
214
427
|
return undefined;
|
|
215
|
-
|
|
428
|
+
}
|
|
429
|
+
case avs_pb.Execution.Step.OutputDataCase.GRAPHQL: {
|
|
216
430
|
const graphqlOutput = typeof step.getGraphql === "function"
|
|
217
431
|
? step.getGraphql()
|
|
218
432
|
: step.graphql;
|
|
@@ -227,7 +441,8 @@ class Step {
|
|
|
227
441
|
}
|
|
228
442
|
}
|
|
229
443
|
return undefined;
|
|
230
|
-
|
|
444
|
+
}
|
|
445
|
+
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ: {
|
|
231
446
|
const contractReadOutput = typeof step.getContractRead === "function"
|
|
232
447
|
? step.getContractRead()
|
|
233
448
|
: step.contractRead;
|
|
@@ -284,7 +499,8 @@ class Step {
|
|
|
284
499
|
return outputObj;
|
|
285
500
|
}
|
|
286
501
|
return undefined;
|
|
287
|
-
|
|
502
|
+
}
|
|
503
|
+
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE: {
|
|
288
504
|
const contractWriteOutput = typeof step.getContractWrite === "function"
|
|
289
505
|
? step.getContractWrite()
|
|
290
506
|
: step.contractWrite;
|
|
@@ -344,7 +560,8 @@ class Step {
|
|
|
344
560
|
return outputObj;
|
|
345
561
|
}
|
|
346
562
|
return undefined;
|
|
347
|
-
|
|
563
|
+
}
|
|
564
|
+
case avs_pb.Execution.Step.OutputDataCase.FILTER: {
|
|
348
565
|
const filterOutput = typeof step.getFilter === "function"
|
|
349
566
|
? step.getFilter()
|
|
350
567
|
: step.filter;
|
|
@@ -359,6 +576,7 @@ class Step {
|
|
|
359
576
|
}
|
|
360
577
|
}
|
|
361
578
|
return undefined;
|
|
579
|
+
}
|
|
362
580
|
default:
|
|
363
581
|
console.warn(`Unhandled output data type in Step.getOutput: ${step.getOutputDataCase()}`);
|
|
364
582
|
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
|
+
headersMap?: Array<[string, string]>;
|
|
6
|
+
pathParamsMap?: Array<[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,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrC,aAAa,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;gBAEnC,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"}
|