@avaprotocol/sdk-js 2.4.3 → 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 +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +791 -255
- package/dist/index.mjs +799 -258
- package/dist/models/node/contractRead.d.ts +14 -0
- package/dist/models/node/contractRead.d.ts.map +1 -1
- package/dist/models/node/contractRead.js +27 -18
- package/dist/models/node/contractWrite.d.ts +14 -0
- package/dist/models/node/contractWrite.d.ts.map +1 -1
- package/dist/models/node/contractWrite.js +25 -16
- package/dist/models/node/customCode.d.ts +10 -1
- package/dist/models/node/customCode.d.ts.map +1 -1
- package/dist/models/node/customCode.js +19 -9
- package/dist/models/node/ethTransfer.d.ts +9 -0
- package/dist/models/node/ethTransfer.d.ts.map +1 -1
- package/dist/models/node/ethTransfer.js +14 -5
- package/dist/models/node/filter.d.ts.map +1 -1
- package/dist/models/node/filter.js +22 -3
- package/dist/models/node/graphqlQuery.d.ts +10 -0
- package/dist/models/node/graphqlQuery.d.ts.map +1 -1
- package/dist/models/node/graphqlQuery.js +20 -12
- package/dist/models/node/loop.d.ts +5 -1
- package/dist/models/node/loop.d.ts.map +1 -1
- package/dist/models/node/loop.js +151 -99
- package/dist/models/node/restApi.d.ts +11 -0
- package/dist/models/node/restApi.d.ts.map +1 -1
- package/dist/models/node/restApi.js +21 -13
- 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/dist/utils.d.ts +0 -14
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -62
- package/package.json +2 -2
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"}
|
|
@@ -1,58 +1,141 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
2
|
import Trigger from "./interface";
|
|
3
|
-
import { convertInputToProtobuf, extractInputFromProtobuf } from "../../utils";
|
|
4
|
-
import { TriggerType } from "@avaprotocol/types";
|
|
3
|
+
import { convertInputToProtobuf, extractInputFromProtobuf, convertProtobufValueToJs, } from "../../utils";
|
|
4
|
+
import { TriggerType, } from "@avaprotocol/types";
|
|
5
5
|
class ManualTrigger extends Trigger {
|
|
6
6
|
constructor(props) {
|
|
7
|
-
super({
|
|
7
|
+
super({
|
|
8
|
+
...props,
|
|
9
|
+
type: TriggerType.Manual,
|
|
10
|
+
data: props.data,
|
|
11
|
+
input: props.input,
|
|
12
|
+
});
|
|
13
|
+
this.headersMap = props.headersMap;
|
|
14
|
+
this.pathParamsMap = props.pathParamsMap;
|
|
8
15
|
}
|
|
9
16
|
toRequest() {
|
|
10
17
|
const trigger = new avs_pb.TaskTrigger();
|
|
11
18
|
trigger.setId(this.id);
|
|
12
19
|
trigger.setName(this.name);
|
|
13
20
|
trigger.setType(avs_pb.TriggerType.TRIGGER_TYPE_MANUAL);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
// Create ManualTrigger with proper config structure
|
|
22
|
+
const manualTrigger = new avs_pb.ManualTrigger();
|
|
23
|
+
const config = new avs_pb.ManualTrigger.Config();
|
|
24
|
+
// Set the data
|
|
25
|
+
const dataToSend = this.data ?? this.input;
|
|
26
|
+
if (dataToSend !== null && dataToSend !== undefined) {
|
|
27
|
+
const inputValue = convertInputToProtobuf(dataToSend);
|
|
28
|
+
if (inputValue) {
|
|
29
|
+
config.setData(inputValue);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Set headers if provided - use map format consistent with REST API nodes
|
|
33
|
+
if (this.headersMap && this.headersMap.length > 0) {
|
|
34
|
+
const headersMap = config.getHeadersMap();
|
|
35
|
+
this.headersMap.forEach(([key, value]) => {
|
|
36
|
+
headersMap.set(key, value);
|
|
37
|
+
});
|
|
20
38
|
}
|
|
39
|
+
// Set pathParams if provided - use map format consistent with REST API nodes
|
|
40
|
+
if (this.pathParamsMap && this.pathParamsMap.length > 0) {
|
|
41
|
+
const pathParamsMap = config.getPathparamsMap();
|
|
42
|
+
this.pathParamsMap.forEach(([key, value]) => {
|
|
43
|
+
pathParamsMap.set(key, value);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
manualTrigger.setConfig(config);
|
|
47
|
+
trigger.setManual(manualTrigger);
|
|
21
48
|
return trigger;
|
|
22
49
|
}
|
|
23
50
|
static fromResponse(raw) {
|
|
24
51
|
const obj = raw.toObject();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
52
|
+
let data = null;
|
|
53
|
+
const input = undefined;
|
|
54
|
+
let headersMap = undefined;
|
|
55
|
+
let pathParamsMap = undefined;
|
|
56
|
+
const manualTrigger = raw.getManual();
|
|
57
|
+
if (manualTrigger) {
|
|
58
|
+
const config = manualTrigger.getConfig();
|
|
59
|
+
if (config) {
|
|
60
|
+
// Extract data
|
|
61
|
+
if (config.hasData()) {
|
|
62
|
+
data = extractInputFromProtobuf(config.getData());
|
|
63
|
+
}
|
|
64
|
+
// Extract headers - convert map to array format
|
|
65
|
+
const headersMapProto = config.getHeadersMap();
|
|
66
|
+
if (headersMapProto && headersMapProto.getLength() > 0) {
|
|
67
|
+
headersMap = [];
|
|
68
|
+
headersMapProto.forEach((value, key) => {
|
|
69
|
+
headersMap.push([key, value]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Extract pathParams - convert map to array format
|
|
73
|
+
const pathParamsMapProto = config.getPathparamsMap();
|
|
74
|
+
if (pathParamsMapProto && pathParamsMapProto.getLength() > 0) {
|
|
75
|
+
pathParamsMap = [];
|
|
76
|
+
pathParamsMapProto.forEach((value, key) => {
|
|
77
|
+
pathParamsMap.push([key, value]);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
29
81
|
}
|
|
30
82
|
return new ManualTrigger({
|
|
31
83
|
...obj,
|
|
32
84
|
type: TriggerType.Manual,
|
|
33
|
-
data:
|
|
85
|
+
data: data,
|
|
34
86
|
input: input,
|
|
87
|
+
headersMap: headersMap,
|
|
88
|
+
pathParamsMap: pathParamsMap,
|
|
35
89
|
});
|
|
36
90
|
}
|
|
37
91
|
getInputVariables() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Convert raw data from runTrigger response to ManualOutput format
|
|
42
|
-
* @param rawData - The raw data from the gRPC response
|
|
43
|
-
* @returns {ManualTriggerOutput | undefined} - The converted data
|
|
44
|
-
*/
|
|
45
|
-
getOutput() {
|
|
46
|
-
return this.output;
|
|
92
|
+
// Return input variables that can be referenced by other nodes
|
|
93
|
+
return this.input;
|
|
47
94
|
}
|
|
48
95
|
/**
|
|
49
96
|
* Extract output data from RunTriggerResp for manual triggers
|
|
50
97
|
* @param outputData - The RunTriggerResp containing manual trigger output
|
|
51
|
-
* @returns Plain JavaScript object with manual trigger data
|
|
98
|
+
* @returns Plain JavaScript object with manual trigger data in standard structure
|
|
52
99
|
*/
|
|
53
100
|
static fromOutputData(outputData) {
|
|
54
101
|
const manualOutput = outputData.getManualTrigger();
|
|
55
|
-
|
|
102
|
+
if (!manualOutput) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const result = {};
|
|
106
|
+
// Extract data
|
|
107
|
+
const dataValue = manualOutput.getData();
|
|
108
|
+
if (dataValue) {
|
|
109
|
+
try {
|
|
110
|
+
result.data = convertProtobufValueToJs(dataValue);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.warn("Failed to convert manual trigger data from protobuf Value:", error);
|
|
114
|
+
result.data = dataValue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
result.data = null;
|
|
119
|
+
}
|
|
120
|
+
// Extract headers - convert map to array format for consistency
|
|
121
|
+
const headersMapProto = manualOutput.getHeadersMap();
|
|
122
|
+
if (headersMapProto && headersMapProto.getLength() > 0) {
|
|
123
|
+
const headersArray = [];
|
|
124
|
+
headersMapProto.forEach((value, key) => {
|
|
125
|
+
headersArray.push([key, value]);
|
|
126
|
+
});
|
|
127
|
+
result.headers = headersArray;
|
|
128
|
+
}
|
|
129
|
+
// Extract pathParams - convert map to array format for consistency
|
|
130
|
+
const pathParamsMapProto = manualOutput.getPathparamsMap();
|
|
131
|
+
if (pathParamsMapProto && pathParamsMapProto.getLength() > 0) {
|
|
132
|
+
const pathParamsArray = [];
|
|
133
|
+
pathParamsMapProto.forEach((value, key) => {
|
|
134
|
+
pathParamsArray.push([key, value]);
|
|
135
|
+
});
|
|
136
|
+
result.pathParams = pathParamsArray;
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
56
139
|
}
|
|
57
140
|
}
|
|
58
141
|
export default ManualTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/models/workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,UAAU,GACxB,cAAc,CAUhB;AAED,cAAM,QAAS,YAAW,aAAa;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAGrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;gBACS,KAAK,EAAE,aAAa;IAuBhC;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IAkC/C;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IAyBnD,SAAS,IAAI,MAAM,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/models/workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,UAAU,GACxB,cAAc,CAUhB;AAED,cAAM,QAAS,YAAW,aAAa;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAGrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;gBACS,KAAK,EAAE,aAAa;IAuBhC;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IAkC/C;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IAyBnD,SAAS,IAAI,MAAM,CAAC,aAAa;IAsDjC;;;OAGG;IACH,MAAM,IAAI,aAAa;CAkBxB;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/models/workflow.js
CHANGED
|
@@ -145,8 +145,6 @@ class Workflow {
|
|
|
145
145
|
if (this.name) {
|
|
146
146
|
request.setName(this.name);
|
|
147
147
|
}
|
|
148
|
-
// Log final summary for debugging (only errors and counts)
|
|
149
|
-
console.log(`📤 Workflow serialization: ${this.nodes.length} nodes, ${this.edges.length} edges -> protobuf: ${request.getNodesList().length} nodes, ${request.getEdgesList().length} edges`);
|
|
150
148
|
return request;
|
|
151
149
|
}
|
|
152
150
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -11,20 +11,6 @@ import { Value as ProtobufValue } from "google-protobuf/google/protobuf/struct_p
|
|
|
11
11
|
* @returns The converted JavaScript value
|
|
12
12
|
*/
|
|
13
13
|
export declare function convertProtobufValueToJs(value?: ProtobufValue): any;
|
|
14
|
-
/**
|
|
15
|
-
* Convert a protobuf Value to a JavaScript value
|
|
16
|
-
*
|
|
17
|
-
* **⚠️ DEPRECATED - Use convertProtobufValueToJs() for new code**
|
|
18
|
-
*
|
|
19
|
-
* This is a legacy compatibility version for existing code that may use
|
|
20
|
-
* dynamically typed protobuf objects. It uses older has*() methods and
|
|
21
|
-
* fallback logic. Only use this if you need backward compatibility.
|
|
22
|
-
*
|
|
23
|
-
* @deprecated Use convertProtobufValueToJs() instead for better type safety
|
|
24
|
-
* @param value - The protobuf Value object (may be dynamically typed)
|
|
25
|
-
* @returns The converted JavaScript value
|
|
26
|
-
*/
|
|
27
|
-
export declare function convertProtobufValueToJS(value: any): any;
|
|
28
14
|
/**
|
|
29
15
|
* Convert a JavaScript value to a protobuf Value
|
|
30
16
|
*
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,aAAa,EAGvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,GAAG,CAiCnE;AAED
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,aAAa,EAGvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,GAAG,CAiCnE;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CA6BlE;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAkB5E;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA0BzE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CASzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,aAAa,GAAG,SAAS,CAK3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC/C,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAiCjC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsB7D"}
|