@avaprotocol/sdk-js 2.3.13-de.0 → 2.3.13-dev.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.
Files changed (41) hide show
  1. package/dist/index.js +1103 -401
  2. package/dist/index.mjs +1107 -405
  3. package/dist/models/node/branch.d.ts.map +1 -1
  4. package/dist/models/node/branch.js +12 -3
  5. package/dist/models/node/contractRead.d.ts.map +1 -1
  6. package/dist/models/node/contractRead.js +12 -3
  7. package/dist/models/node/contractWrite.d.ts.map +1 -1
  8. package/dist/models/node/contractWrite.js +12 -3
  9. package/dist/models/node/customCode.d.ts.map +1 -1
  10. package/dist/models/node/customCode.js +12 -4
  11. package/dist/models/node/ethTransfer.d.ts.map +1 -1
  12. package/dist/models/node/ethTransfer.js +12 -3
  13. package/dist/models/node/filter.d.ts.map +1 -1
  14. package/dist/models/node/filter.js +12 -3
  15. package/dist/models/node/graphqlQuery.d.ts.map +1 -1
  16. package/dist/models/node/graphqlQuery.js +12 -3
  17. package/dist/models/node/interface.d.ts +3 -2
  18. package/dist/models/node/interface.d.ts.map +1 -1
  19. package/dist/models/node/interface.js +17 -2
  20. package/dist/models/node/loop.d.ts.map +1 -1
  21. package/dist/models/node/loop.js +9 -0
  22. package/dist/models/node/restApi.d.ts.map +1 -1
  23. package/dist/models/node/restApi.js +15 -1
  24. package/dist/models/step.d.ts +1 -0
  25. package/dist/models/step.d.ts.map +1 -1
  26. package/dist/models/step.js +308 -206
  27. package/dist/models/trigger/block.d.ts.map +1 -1
  28. package/dist/models/trigger/block.js +13 -0
  29. package/dist/models/trigger/cron.d.ts.map +1 -1
  30. package/dist/models/trigger/cron.js +20 -0
  31. package/dist/models/trigger/event.d.ts.map +1 -1
  32. package/dist/models/trigger/fixedTime.d.ts.map +1 -1
  33. package/dist/models/trigger/interface.d.ts +4 -5
  34. package/dist/models/trigger/interface.d.ts.map +1 -1
  35. package/dist/models/trigger/interface.js +4 -2
  36. package/dist/models/trigger/manual.d.ts.map +1 -1
  37. package/dist/models/trigger/manual.js +13 -0
  38. package/dist/utils.d.ts +20 -0
  39. package/dist/utils.d.ts.map +1 -1
  40. package/dist/utils.js +52 -0
  41. package/package.json +2 -2
@@ -1,5 +1,4 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import { Value as ProtobufValue } from "google-protobuf/google/protobuf/struct_pb";
3
2
  import { convertProtobufValueToJs, convertProtobufStepTypeToSdk, } from "../utils";
4
3
  class Step {
5
4
  constructor(props) {
@@ -10,6 +9,7 @@ class Step {
10
9
  this.error = props.error;
11
10
  this.log = props.log;
12
11
  this.inputsList = props.inputsList;
12
+ this.input = props.input;
13
13
  this.output = props.output;
14
14
  this.startAt = props.startAt;
15
15
  this.endAt = props.endAt;
@@ -27,262 +27,364 @@ class Step {
27
27
  error: this.error,
28
28
  log: this.log,
29
29
  inputsList: this.inputsList,
30
+ input: this.input,
30
31
  output: this.output,
31
32
  startAt: this.startAt,
32
33
  endAt: this.endAt,
33
34
  };
34
35
  }
35
36
  static getOutput(step) {
36
- const outputDataType = step.getOutputDataCase();
37
- let nodeOutputMessage;
38
- switch (outputDataType) {
37
+ // Handle both protobuf instances and plain objects
38
+ const getOutputDataCase = () => {
39
+ if (typeof step.getOutputDataCase === "function") {
40
+ return step.getOutputDataCase();
41
+ }
42
+ // For plain objects, determine the case by checking which properties exist
43
+ const stepObj = step;
44
+ if (stepObj.blockTrigger)
45
+ return avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER;
46
+ if (stepObj.fixedTimeTrigger)
47
+ return avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER;
48
+ if (stepObj.cronTrigger)
49
+ return avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER;
50
+ if (stepObj.eventTrigger)
51
+ return avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER;
52
+ if (stepObj.manualTrigger)
53
+ return avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER;
54
+ if (stepObj.ethTransfer)
55
+ return avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER;
56
+ if (stepObj.graphql)
57
+ return avs_pb.Execution.Step.OutputDataCase.GRAPHQL;
58
+ if (stepObj.contractRead)
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()) {
39
75
  case avs_pb.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET:
40
76
  return undefined;
41
77
  // Trigger outputs
42
78
  case avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
43
- const blockOutput = step.getBlockTrigger()?.toObject();
44
- return blockOutput
45
- ? { blockNumber: blockOutput.blockNumber }
46
- : undefined;
79
+ return typeof step.getBlockTrigger === "function"
80
+ ? step.getBlockTrigger()?.toObject()
81
+ : step.blockTrigger;
47
82
  case avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
48
- const fixedTimeOutput = step.getFixedTimeTrigger()?.toObject();
49
- return fixedTimeOutput
50
- ? {
51
- timestamp: fixedTimeOutput.timestamp,
52
- timestampIso: fixedTimeOutput.timestampIso,
53
- }
54
- : undefined;
83
+ return typeof step.getFixedTimeTrigger === "function"
84
+ ? step.getFixedTimeTrigger()?.toObject()
85
+ : step.fixedTimeTrigger;
55
86
  case avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER:
56
- const cronOutput = step.getCronTrigger()?.toObject();
57
- return cronOutput
58
- ? {
59
- timestamp: cronOutput.timestamp,
60
- timestampIso: cronOutput.timestampIso,
61
- }
62
- : undefined;
87
+ return typeof step.getCronTrigger === "function"
88
+ ? step.getCronTrigger()?.toObject()
89
+ : step.cronTrigger;
63
90
  case avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER:
64
- const eventTrigger = step.getEventTrigger();
91
+ const eventTrigger = typeof step.getEventTrigger === "function"
92
+ ? step.getEventTrigger()
93
+ : step.eventTrigger;
65
94
  if (eventTrigger) {
66
- if (eventTrigger.hasEvmLog()) {
95
+ if (typeof eventTrigger.hasEvmLog === "function" &&
96
+ eventTrigger.hasEvmLog()) {
67
97
  return eventTrigger.getEvmLog()?.toObject();
68
98
  }
69
- else if (eventTrigger.hasTransferLog()) {
99
+ else if (typeof eventTrigger.hasTransferLog === "function" &&
100
+ eventTrigger.hasTransferLog()) {
70
101
  return eventTrigger.getTransferLog()?.toObject();
71
102
  }
103
+ else if (eventTrigger.evmLog) {
104
+ return eventTrigger.evmLog;
105
+ }
106
+ else if (eventTrigger.transferLog) {
107
+ return eventTrigger.transferLog;
108
+ }
72
109
  }
73
110
  return undefined;
74
111
  case avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
75
- const manualOutput = step.getManualTrigger()?.toObject();
76
- return manualOutput || undefined;
77
- // Node outputs
112
+ return typeof step.getManualTrigger === "function"
113
+ ? step.getManualTrigger()?.toObject() || undefined
114
+ : step.manualTrigger;
115
+ // Node outputs - RESTORE MISSING CASES
78
116
  case avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER:
79
- const ethTransferOutput = step.getEthTransfer()?.toObject();
80
- return ethTransferOutput
81
- ? {
82
- transactionHash: ethTransferOutput.transactionHash,
117
+ return typeof step.getEthTransfer === "function"
118
+ ? step.getEthTransfer()?.toObject()
119
+ : step.ethTransfer;
120
+ case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
121
+ const customCodeOutput = typeof step.getCustomCode === "function"
122
+ ? step.getCustomCode()
123
+ : step.customCode;
124
+ if (customCodeOutput) {
125
+ if (typeof customCodeOutput.hasData === "function" &&
126
+ customCodeOutput.hasData()) {
127
+ try {
128
+ return convertProtobufValueToJs(customCodeOutput.getData());
129
+ }
130
+ catch {
131
+ // Fallback: if conversion fails, return the raw data
132
+ return customCodeOutput.getData();
133
+ }
134
+ }
135
+ else if (customCodeOutput.data) {
136
+ // For plain objects, try to convert or use directly
137
+ return typeof customCodeOutput.data.getKindCase === "function"
138
+ ? convertProtobufValueToJs(customCodeOutput.data)
139
+ : customCodeOutput.data;
83
140
  }
84
- : undefined;
141
+ }
142
+ return undefined;
143
+ case avs_pb.Execution.Step.OutputDataCase.REST_API:
144
+ const restApiOutput = typeof step.getRestApi === "function"
145
+ ? step.getRestApi()
146
+ : step.restApi;
147
+ if (restApiOutput) {
148
+ if (typeof restApiOutput.hasData === "function" &&
149
+ restApiOutput.hasData()) {
150
+ try {
151
+ return convertProtobufValueToJs(restApiOutput.getData());
152
+ }
153
+ catch {
154
+ // Fallback: if conversion fails, return the raw data
155
+ return restApiOutput.getData();
156
+ }
157
+ }
158
+ else if (restApiOutput.data) {
159
+ // For plain objects, try to convert or use directly
160
+ return typeof restApiOutput.data.getKindCase === "function"
161
+ ? convertProtobufValueToJs(restApiOutput.data)
162
+ : restApiOutput.data;
163
+ }
164
+ }
165
+ return undefined;
166
+ case avs_pb.Execution.Step.OutputDataCase.BRANCH:
167
+ return typeof step.getBranch === "function"
168
+ ? step.getBranch()?.toObject()
169
+ : step.branch;
170
+ case avs_pb.Execution.Step.OutputDataCase.LOOP:
171
+ const loopOutput = typeof step.getLoop === "function"
172
+ ? step.getLoop()
173
+ : step.loop;
174
+ if (loopOutput) {
175
+ if (typeof loopOutput.getData === "function" &&
176
+ loopOutput.getData()) {
177
+ try {
178
+ return JSON.parse(loopOutput.getData());
179
+ }
180
+ catch {
181
+ return loopOutput.getData();
182
+ }
183
+ }
184
+ else if (loopOutput.data) {
185
+ // For plain objects
186
+ try {
187
+ return typeof loopOutput.data === "string"
188
+ ? JSON.parse(loopOutput.data)
189
+ : loopOutput.data;
190
+ }
191
+ catch {
192
+ return loopOutput.data;
193
+ }
194
+ }
195
+ }
196
+ return undefined;
85
197
  case avs_pb.Execution.Step.OutputDataCase.GRAPHQL:
86
- nodeOutputMessage = step.getGraphql();
87
- return nodeOutputMessage && nodeOutputMessage.hasData()
88
- ? nodeOutputMessage.getData()
89
- : undefined;
198
+ const graphqlOutput = typeof step.getGraphql === "function"
199
+ ? step.getGraphql()
200
+ : step.graphql;
201
+ if (graphqlOutput) {
202
+ try {
203
+ return typeof graphqlOutput.toObject === "function"
204
+ ? graphqlOutput.toObject()
205
+ : graphqlOutput;
206
+ }
207
+ catch {
208
+ return undefined;
209
+ }
210
+ }
211
+ return undefined;
90
212
  case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ:
91
- nodeOutputMessage = step.getContractRead();
92
- if (nodeOutputMessage) {
93
- const results = nodeOutputMessage.getResultsList();
94
- if (results && results.length > 0) {
95
- // Always return wrapped format { results: [...] } to match ContractReadNode.fromOutputData
96
- const resultArray = results.map((result) => {
97
- // Match the exact format from ContractReadNode.fromOutputData
98
- const dataFields = result.getDataList().map((field) => ({
99
- name: field.getName(),
100
- type: field.getType(),
101
- value: field.getValue()
102
- }));
103
- return {
104
- methodName: result.getMethodName(),
105
- success: result.getSuccess(),
106
- error: result.getError(),
107
- data: dataFields,
108
- };
109
- });
110
- // Return wrapped format consistently for all cases
111
- return { results: resultArray };
213
+ const contractReadOutput = typeof step.getContractRead === "function"
214
+ ? step.getContractRead()
215
+ : step.contractRead;
216
+ if (contractReadOutput) {
217
+ // Get the raw output object
218
+ const outputObj = typeof contractReadOutput.toObject === "function"
219
+ ? contractReadOutput.toObject()
220
+ : contractReadOutput;
221
+ // Convert resultsList to results for consistency with ContractReadNode.fromOutputData
222
+ if (outputObj && outputObj.resultsList) {
223
+ return {
224
+ ...outputObj,
225
+ results: outputObj.resultsList.map((result) => ({
226
+ methodName: result.methodName,
227
+ success: result.success,
228
+ error: result.error,
229
+ data: result.dataList || []
230
+ }))
231
+ };
112
232
  }
233
+ return outputObj;
113
234
  }
114
235
  return undefined;
115
236
  case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE:
116
- nodeOutputMessage = step.getContractWrite();
117
- if (nodeOutputMessage) {
118
- const results = nodeOutputMessage.getResultsList();
119
- if (results && results.length > 0) {
120
- // Transform enhanced results structure
121
- const transformedResults = results.map((result) => ({
122
- methodName: result.getMethodName(),
123
- success: result.getSuccess(),
124
- transaction: result.getTransaction() ? {
125
- hash: result.getTransaction()?.getHash(),
126
- status: result.getTransaction()?.getStatus(),
127
- blockNumber: result.getTransaction()?.getBlockNumber(),
128
- blockHash: result.getTransaction()?.getBlockHash(),
129
- gasUsed: result.getTransaction()?.getGasUsed(),
130
- gasLimit: result.getTransaction()?.getGasLimit(),
131
- gasPrice: result.getTransaction()?.getGasPrice(),
132
- effectiveGasPrice: result.getTransaction()?.getEffectiveGasPrice(),
133
- from: result.getTransaction()?.getFrom(),
134
- to: result.getTransaction()?.getTo(),
135
- value: result.getTransaction()?.getValue(),
136
- nonce: result.getTransaction()?.getNonce(),
137
- transactionIndex: result.getTransaction()?.getTransactionIndex(),
138
- confirmations: result.getTransaction()?.getConfirmations(),
139
- timestamp: result.getTransaction()?.getTimestamp(),
237
+ const contractWriteOutput = typeof step.getContractWrite === "function"
238
+ ? step.getContractWrite()
239
+ : step.contractWrite;
240
+ if (contractWriteOutput) {
241
+ // Get the raw output object
242
+ const outputObj = typeof contractWriteOutput.toObject === "function"
243
+ ? contractWriteOutput.toObject()
244
+ : contractWriteOutput;
245
+ // Convert resultsList to results for consistency with ContractWriteNode.fromOutputData
246
+ if (outputObj && outputObj.resultsList) {
247
+ const transformedResults = outputObj.resultsList.map((result) => ({
248
+ methodName: result.methodName,
249
+ success: result.success,
250
+ transaction: result.transaction ? {
251
+ hash: result.transaction.hash,
252
+ status: result.transaction.status,
253
+ blockNumber: result.transaction.blockNumber,
254
+ blockHash: result.transaction.blockHash,
255
+ gasUsed: result.transaction.gasUsed,
256
+ gasLimit: result.transaction.gasLimit,
257
+ gasPrice: result.transaction.gasPrice,
258
+ effectiveGasPrice: result.transaction.effectiveGasPrice,
259
+ from: result.transaction.from,
260
+ to: result.transaction.to,
261
+ value: result.transaction.value,
262
+ nonce: result.transaction.nonce,
263
+ transactionIndex: result.transaction.transactionIndex,
264
+ confirmations: result.transaction.confirmations,
265
+ timestamp: result.transaction.timestamp,
140
266
  } : null,
141
- events: result.getEventsList().map((event) => ({
142
- eventName: event.getEventName(),
143
- address: event.getAddress(),
144
- topics: event.getTopicsList(),
145
- data: event.getData(),
146
- decoded: event.getDecodedMap() ? Object.fromEntries(event.getDecodedMap().toArray()) : {},
147
- })),
148
- error: result.getError() ? {
149
- code: result.getError()?.getCode(),
150
- message: result.getError()?.getMessage(),
151
- revertReason: result.getError()?.getRevertReason(),
267
+ events: result.eventsList?.map((event) => ({
268
+ eventName: event.eventName,
269
+ address: event.address,
270
+ topics: event.topicsList || [],
271
+ data: event.data,
272
+ decoded: event.decodedMap || {},
273
+ })) || [],
274
+ error: result.error ? {
275
+ code: result.error.code,
276
+ message: result.error.message,
277
+ revertReason: result.error.revertReason,
152
278
  } : null,
153
- returnData: result.getReturnData() ? {
154
- name: result.getReturnData()?.getName(),
155
- type: result.getReturnData()?.getType(),
156
- value: result.getReturnData()?.getValue(),
279
+ returnData: result.returnData ? {
280
+ name: result.returnData.name,
281
+ type: result.returnData.type,
282
+ value: result.returnData.value,
157
283
  } : null,
158
- inputData: result.getInputData(),
284
+ inputData: result.inputData,
159
285
  }));
160
- // For single result, also provide legacy fields for backward compatibility
161
- if (transformedResults.length === 1) {
162
- return {
163
- results: transformedResults,
164
- // Legacy compatibility fields
286
+ return {
287
+ ...outputObj,
288
+ results: transformedResults,
289
+ // For backward compatibility, provide legacy fields from first result
290
+ ...(transformedResults.length > 0 && {
165
291
  transaction: transformedResults[0].transaction,
166
292
  success: transformedResults[0].success,
167
293
  hash: transformedResults[0].transaction?.hash,
168
- };
169
- }
170
- else {
171
- return { results: transformedResults };
172
- }
294
+ }),
295
+ };
173
296
  }
297
+ return outputObj;
174
298
  }
175
299
  return undefined;
176
- case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
177
- nodeOutputMessage = step.getCustomCode();
178
- return nodeOutputMessage && nodeOutputMessage.hasData()
179
- ? convertProtobufValueToJs(nodeOutputMessage.getData())
180
- : undefined;
181
- case avs_pb.Execution.Step.OutputDataCase.REST_API:
182
- nodeOutputMessage = step.getRestApi();
183
- return nodeOutputMessage && nodeOutputMessage.hasData()
184
- ? convertProtobufValueToJs(nodeOutputMessage.getData())
185
- : undefined;
186
- case avs_pb.Execution.Step.OutputDataCase.BRANCH:
187
- return step.getBranch()?.toObject();
188
300
  case avs_pb.Execution.Step.OutputDataCase.FILTER:
189
- nodeOutputMessage = step.getFilter();
190
- if (nodeOutputMessage && nodeOutputMessage.hasData()) {
191
- const rawData = nodeOutputMessage.getData();
192
- if (rawData) {
193
- // Handle Any wrapper - need to unpack it first
194
- if (typeof rawData.unpack === 'function') {
195
- try {
196
- // For Any types, unpack to Value and then convert
197
- const unpackedValue = rawData.unpack(ProtobufValue.deserializeBinary, 'google.protobuf.Value');
198
- if (unpackedValue) {
199
- return convertProtobufValueToJs(unpackedValue);
200
- }
201
- }
202
- catch (error) {
203
- // If unpacking fails, log error and return undefined
204
- console.warn('Failed to unpack FilterNode Any wrapper:', error);
205
- return undefined;
206
- }
207
- }
208
- // If no unpack method, this is unexpected for FilterNode
209
- console.warn('FilterNode output data is not an Any wrapper - this is unexpected');
301
+ const filterOutput = typeof step.getFilter === "function"
302
+ ? step.getFilter()
303
+ : step.filter;
304
+ if (filterOutput) {
305
+ try {
306
+ return typeof filterOutput.toObject === "function"
307
+ ? filterOutput.toObject()
308
+ : filterOutput;
309
+ }
310
+ catch {
210
311
  return undefined;
211
312
  }
212
313
  }
213
314
  return undefined;
214
- case avs_pb.Execution.Step.OutputDataCase.LOOP:
215
- const loopOutput = step.getLoop();
216
- if (!loopOutput)
217
- return undefined;
218
- const loopData = loopOutput.getData();
219
- if (!loopData)
220
- return undefined;
221
- // Loop nodes return an array of results from child node executions
222
- // The backend should serialize this as JSON, but may have issues
223
- // Try to parse as JSON first (expected format for array of child results)
224
- try {
225
- const parsedData = JSON.parse(loopData);
226
- // If it's an array, process each item with appropriate child node conversion
227
- if (Array.isArray(parsedData)) {
228
- return parsedData.map((item, index) => {
229
- if (!item || typeof item !== 'object') {
230
- return item; // Primitive values, return as-is
231
- }
232
- // Apply child node-specific conversions based on detected structure
233
- // REST API child output (has statusCode, body, headers)
234
- if (item.statusCode !== undefined && (item.body !== undefined || item.headers !== undefined)) {
235
- return item; // Already in raw format
236
- }
237
- // Custom Code child output (arbitrary object structure)
238
- if (item.result !== undefined || item.output !== undefined || item.error !== undefined) {
239
- return item; // Already processed by convertProtobufValueToJs in backend
240
- }
241
- // ETH Transfer child output (has transactionHash)
242
- if (item.transactionHash !== undefined) {
243
- return { transactionHash: item.transactionHash };
244
- }
245
- // Contract Read child output (has methodName and data)
246
- if (item.methodName !== undefined && item.data !== undefined) {
247
- return item; // Already in structured format
248
- }
249
- // GraphQL child output (has data field)
250
- if (item.data !== undefined && typeof item.data === 'object') {
251
- return item; // Already processed
252
- }
253
- // Generic object - return as-is (might be custom structure)
254
- return item;
255
- });
256
- }
257
- // Single object result (not an array)
258
- if (parsedData && typeof parsedData === 'object') {
259
- return parsedData;
260
- }
261
- // Parsed successfully but primitive value
262
- return { data: parsedData };
263
- }
264
- catch (e) {
265
- // Not JSON or parsing failed - could be a simple string result
266
- // This might happen if backend has serialization issues
267
- return { data: loopData };
268
- }
269
315
  default:
270
- console.warn(`Unhandled output data type in Step.getOutput: ${outputDataType}`);
316
+ console.warn(`Unhandled output data type in Step.getOutput: ${step.getOutputDataCase()}`);
271
317
  return undefined;
272
318
  }
273
319
  }
274
320
  static fromResponse(step) {
321
+ // Extract input data if present - USE PROPER PROTOBUF GETTER
322
+ let inputData = undefined;
323
+ // Check for input using proper protobuf methods
324
+ if (typeof step.hasInput === "function" && step.hasInput()) {
325
+ const inputValue = step.getInput();
326
+ if (inputValue) {
327
+ // If it's a protobuf Value instance, convert it
328
+ try {
329
+ inputData = convertProtobufValueToJs(inputValue);
330
+ }
331
+ catch (error) {
332
+ console.warn('Failed to convert protobuf input value:', error);
333
+ // Fallback: if conversion fails, use the raw value
334
+ inputData = inputValue;
335
+ }
336
+ }
337
+ }
338
+ else if (step.input) {
339
+ // Fallback for plain objects (from .toObject() calls)
340
+ const inputValue = step.input;
341
+ // If it's already a plain JavaScript object, use it directly
342
+ if (typeof inputValue === "object" && !inputValue.getKindCase) {
343
+ inputData = inputValue;
344
+ }
345
+ else {
346
+ // If it's a protobuf Value instance, convert it
347
+ try {
348
+ inputData = convertProtobufValueToJs(inputValue);
349
+ }
350
+ catch (error) {
351
+ // Fallback: if conversion fails, use the raw value
352
+ inputData = inputValue;
353
+ }
354
+ }
355
+ }
356
+ // Handle method calls safely for both protobuf instances and plain objects
357
+ const getId = () => typeof step.getId === "function" ? step.getId() : step.id;
358
+ const getType = () => typeof step.getType === "function" ? step.getType() : step.type;
359
+ const getName = () => typeof step.getName === "function" ? step.getName() : step.name;
360
+ const getSuccess = () => typeof step.getSuccess === "function"
361
+ ? step.getSuccess()
362
+ : step.success;
363
+ const getError = () => typeof step.getError === "function"
364
+ ? step.getError()
365
+ : step.error;
366
+ const getLog = () => typeof step.getLog === "function" ? step.getLog() : step.log;
367
+ const getInputsList = () => typeof step.getInputsList === "function"
368
+ ? step.getInputsList()
369
+ : step.inputsList || [];
370
+ const getStartAt = () => typeof step.getStartAt === "function"
371
+ ? step.getStartAt()
372
+ : step.startAt;
373
+ const getEndAt = () => typeof step.getEndAt === "function"
374
+ ? step.getEndAt()
375
+ : step.endAt;
275
376
  return new Step({
276
- id: step.getId(),
277
- type: convertProtobufStepTypeToSdk(step.getType()),
278
- name: step.getName(),
279
- success: step.getSuccess(),
280
- error: step.getError(),
281
- log: step.getLog(),
282
- inputsList: step.getInputsList(),
377
+ id: getId(),
378
+ type: convertProtobufStepTypeToSdk(getType()),
379
+ name: getName(),
380
+ success: getSuccess(),
381
+ error: getError(),
382
+ log: getLog(),
383
+ inputsList: getInputsList(),
384
+ input: inputData,
283
385
  output: Step.getOutput(step),
284
- startAt: step.getStartAt(),
285
- endAt: step.getEndAt(),
386
+ startAt: getStartAt(),
387
+ endAt: getEndAt(),
286
388
  });
287
389
  }
288
390
  }
@@ -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,OAA0B,MAAM,aAAa,CAAC;AACrD,OAAO,EAAqC,kBAAkB,EAAE,iBAAiB,EAAgB,MAAM,oBAAoB,CAAC;AAK5H,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAgC/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;CAI9D;AAED,eAAe,YAAY,CAAC"}
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,EAAqC,kBAAkB,EAAE,iBAAiB,EAA+B,MAAM,oBAAoB,CAAC;AAM3I,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAsC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IA+B1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAI9D;AAED,eAAe,YAAY,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
2
  import Trigger from "./interface";
3
3
  import { TriggerType } from "@avaprotocol/types";
4
+ import { convertInputToProtobuf, extractInputFromProtobuf } from "../../utils";
4
5
  // Required props for constructor: id, name, type and data: { interval }
5
6
  class BlockTrigger extends Trigger {
6
7
  constructor(props) {
@@ -27,6 +28,11 @@ class BlockTrigger extends Trigger {
27
28
  const config = new avs_pb.BlockTrigger.Config();
28
29
  config.setInterval(blockData.interval);
29
30
  trigger.setConfig(config);
31
+ // Use utility function to convert input field to protobuf format
32
+ const inputValue = convertInputToProtobuf(this.input);
33
+ if (inputValue) {
34
+ trigger.setInput(inputValue);
35
+ }
30
36
  request.setBlock(trigger);
31
37
  return request;
32
38
  }
@@ -34,6 +40,7 @@ class BlockTrigger extends Trigger {
34
40
  // Convert the raw object to TriggerProps, which should keep name and id
35
41
  const obj = raw.toObject();
36
42
  let data = { interval: 0 };
43
+ let input = undefined;
37
44
  if (raw.getBlock() && raw.getBlock().hasConfig()) {
38
45
  const config = raw.getBlock().getConfig();
39
46
  if (config) {
@@ -41,11 +48,17 @@ class BlockTrigger extends Trigger {
41
48
  interval: config.getInterval() || 0
42
49
  };
43
50
  }
51
+ // Use utility function to extract input field from protobuf format
52
+ const blockTrigger = raw.getBlock();
53
+ if (blockTrigger.hasInput()) {
54
+ input = extractInputFromProtobuf(blockTrigger.getInput());
55
+ }
44
56
  }
45
57
  return new BlockTrigger({
46
58
  ...obj,
47
59
  type: TriggerType.Block,
48
60
  data: data,
61
+ input: input,
49
62
  });
50
63
  }
51
64
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/cron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAA0B,MAAM,aAAa,CAAC;AACrD,OAAO,EAAoC,iBAAiB,EAAE,gBAAgB,EAAgB,MAAM,oBAAoB,CAAC;AAEzH,cAAM,WAAY,SAAQ,OAAO;gBACnB,KAAK,EAAE,gBAAgB;IAInC,SAAS,IAAI,MAAM,CAAC,WAAW;IAgC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,WAAW;IAuBzD;;;;OAIG;IACH,SAAS,IAAI,iBAAiB,GAAG,SAAS;IAI1C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/cron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAAoC,iBAAiB,EAAE,gBAAgB,EAAgB,MAAM,oBAAoB,CAAC;AAEzH,cAAM,WAAY,SAAQ,OAAO;gBACnB,KAAK,EAAE,gBAAgB;IAInC,SAAS,IAAI,MAAM,CAAC,WAAW;IA0C/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,WAAW;IAiCzD;;;;OAIG;IACH,SAAS,IAAI,iBAAiB,GAAG,SAAS;IAI1C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;AAED,eAAe,WAAW,CAAC"}