@avaprotocol/sdk-js 2.3.13-dev.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.
package/dist/index.js CHANGED
@@ -16579,13 +16579,13 @@ __export(index_exports, {
16579
16579
  GraphQLQueryNode: () => graphqlQuery_default,
16580
16580
  LoopNode: () => loop_default,
16581
16581
  ManualTrigger: () => manual_default,
16582
- Node: () => interface_default2,
16582
+ Node: () => Node,
16583
16583
  NodeFactory: () => factory_default2,
16584
16584
  RestAPINode: () => restApi_default,
16585
16585
  Secret: () => secret_default,
16586
16586
  Step: () => step_default,
16587
16587
  TimeoutPresets: () => import_types21.TimeoutPresets,
16588
- Trigger: () => interface_default,
16588
+ Trigger: () => Trigger,
16589
16589
  TriggerFactory: () => factory_default,
16590
16590
  Workflow: () => workflow_default
16591
16591
  });
@@ -16625,39 +16625,6 @@ var avs_pb7 = __toESM(require_avs_pb());
16625
16625
  // src/models/trigger/block.ts
16626
16626
  var avs_pb2 = __toESM(require_avs_pb());
16627
16627
 
16628
- // src/models/trigger/interface.ts
16629
- var Trigger = class {
16630
- /**
16631
- * Create an instance of Trigger from user inputs
16632
- * @param props
16633
- */
16634
- constructor(props) {
16635
- this.id = props.id;
16636
- this.name = props.name;
16637
- this.type = props.type;
16638
- this.data = props.data;
16639
- this.output = props.output;
16640
- this.input = props.input;
16641
- }
16642
- toRequest() {
16643
- throw new Error("Method not implemented.");
16644
- }
16645
- getOutput() {
16646
- return this.output;
16647
- }
16648
- toJson() {
16649
- return {
16650
- id: this.id,
16651
- name: this.name,
16652
- type: this.type,
16653
- data: this.data,
16654
- output: this.output,
16655
- input: this.input
16656
- };
16657
- }
16658
- };
16659
- var interface_default = Trigger;
16660
-
16661
16628
  // src/utils.ts
16662
16629
  var import_struct_pb = require("google-protobuf/google/protobuf/struct_pb");
16663
16630
  var import_types = require("@avaprotocol/types");
@@ -16803,16 +16770,61 @@ function extractInputFromProtobuf(inputValue) {
16803
16770
  if (!inputValue) {
16804
16771
  return void 0;
16805
16772
  }
16806
- const inputJavaScript = inputValue.toJavaScript();
16807
- if (inputJavaScript && typeof inputJavaScript === "object" && !Array.isArray(inputJavaScript)) {
16808
- return inputJavaScript;
16773
+ if (typeof inputValue === "object" && !inputValue.toJavaScript) {
16774
+ if (!Array.isArray(inputValue)) {
16775
+ return inputValue;
16776
+ }
16777
+ return void 0;
16778
+ }
16779
+ try {
16780
+ const protobufValue = inputValue;
16781
+ const inputJavaScript = protobufValue.toJavaScript();
16782
+ if (inputJavaScript && typeof inputJavaScript === "object" && !Array.isArray(inputJavaScript)) {
16783
+ return inputJavaScript;
16784
+ }
16785
+ } catch (error) {
16786
+ if (typeof inputValue === "object" && !Array.isArray(inputValue)) {
16787
+ return inputValue;
16788
+ }
16809
16789
  }
16810
16790
  return void 0;
16811
16791
  }
16812
16792
 
16793
+ // src/models/trigger/interface.ts
16794
+ var Trigger = class {
16795
+ /**
16796
+ * Create an instance of Trigger from user inputs
16797
+ * @param props
16798
+ */
16799
+ constructor(props) {
16800
+ this.id = props.id;
16801
+ this.name = props.name;
16802
+ this.type = props.type;
16803
+ this.data = props.data;
16804
+ this.output = props.output;
16805
+ this.input = props.input ? extractInputFromProtobuf(props.input) : void 0;
16806
+ }
16807
+ toRequest() {
16808
+ throw new Error("Method not implemented.");
16809
+ }
16810
+ getOutput() {
16811
+ return this.output;
16812
+ }
16813
+ toJson() {
16814
+ return {
16815
+ id: this.id,
16816
+ name: this.name,
16817
+ type: this.type,
16818
+ data: this.data,
16819
+ output: this.output,
16820
+ input: this.input
16821
+ };
16822
+ }
16823
+ };
16824
+
16813
16825
  // src/models/trigger/block.ts
16814
16826
  var import_types2 = require("@avaprotocol/types");
16815
- var BlockTrigger2 = class _BlockTrigger extends interface_default {
16827
+ var BlockTrigger2 = class _BlockTrigger extends Trigger {
16816
16828
  constructor(props) {
16817
16829
  super({ ...props, type: import_types2.TriggerType.Block, data: props.data });
16818
16830
  }
@@ -16889,7 +16901,7 @@ var block_default = BlockTrigger2;
16889
16901
  var avs_pb3 = __toESM(require_avs_pb());
16890
16902
  var google_protobuf_struct_pb = __toESM(require("google-protobuf/google/protobuf/struct_pb"));
16891
16903
  var import_types3 = require("@avaprotocol/types");
16892
- var CronTrigger2 = class _CronTrigger extends interface_default {
16904
+ var CronTrigger2 = class _CronTrigger extends Trigger {
16893
16905
  constructor(props) {
16894
16906
  super({ ...props, type: import_types3.TriggerType.Cron, data: props.data });
16895
16907
  }
@@ -16978,7 +16990,7 @@ var cron_default = CronTrigger2;
16978
16990
  // src/models/trigger/event.ts
16979
16991
  var avs_pb4 = __toESM(require_avs_pb());
16980
16992
  var import_types4 = require("@avaprotocol/types");
16981
- var EventTrigger2 = class _EventTrigger extends interface_default {
16993
+ var EventTrigger2 = class _EventTrigger extends Trigger {
16982
16994
  constructor(props) {
16983
16995
  super({ ...props, type: import_types4.TriggerType.Event, data: props.data });
16984
16996
  }
@@ -17095,7 +17107,7 @@ var event_default = EventTrigger2;
17095
17107
  // src/models/trigger/fixedTime.ts
17096
17108
  var avs_pb5 = __toESM(require_avs_pb());
17097
17109
  var import_types5 = require("@avaprotocol/types");
17098
- var FixedTimeTrigger2 = class _FixedTimeTrigger extends interface_default {
17110
+ var FixedTimeTrigger2 = class _FixedTimeTrigger extends Trigger {
17099
17111
  constructor(props) {
17100
17112
  super({ ...props, type: import_types5.TriggerType.FixedTime, data: props.data });
17101
17113
  }
@@ -17160,7 +17172,7 @@ var fixedTime_default = FixedTimeTrigger2;
17160
17172
  // src/models/trigger/manual.ts
17161
17173
  var avs_pb6 = __toESM(require_avs_pb());
17162
17174
  var import_types6 = require("@avaprotocol/types");
17163
- var ManualTrigger = class _ManualTrigger extends interface_default {
17175
+ var ManualTrigger = class _ManualTrigger extends Trigger {
17164
17176
  constructor(props) {
17165
17177
  super({ ...props, type: import_types6.TriggerType.Manual, data: props.data || null });
17166
17178
  }
@@ -17312,12 +17324,13 @@ var avs_pb8 = __toESM(require_avs_pb());
17312
17324
  var import_types8 = require("@avaprotocol/types");
17313
17325
  var import_lodash = __toESM(require("lodash"));
17314
17326
  var Node = class {
17327
+ // Use JavaScript object type for internal storage
17315
17328
  constructor(props) {
17316
17329
  this.id = props.id;
17317
17330
  this.name = props.name;
17318
17331
  this.type = props.type;
17319
17332
  this.data = props.data;
17320
- this.input = props.input;
17333
+ this.input = props.input ? extractInputFromProtobuf(props.input) : void 0;
17321
17334
  }
17322
17335
  toRequest() {
17323
17336
  const request = new avs_pb8.TaskNode();
@@ -17328,13 +17341,23 @@ var Node = class {
17328
17341
  }
17329
17342
  return request;
17330
17343
  }
17344
+ static fromResponse(raw) {
17345
+ const obj = raw.toObject();
17346
+ let input = void 0;
17347
+ if (raw.hasInput()) {
17348
+ input = raw.getInput().toObject();
17349
+ }
17350
+ return new this({
17351
+ ...obj,
17352
+ input
17353
+ });
17354
+ }
17331
17355
  };
17332
- var interface_default2 = Node;
17333
17356
 
17334
17357
  // src/models/node/contractWrite.ts
17335
17358
  var avs_pb9 = __toESM(require_avs_pb());
17336
17359
  var import_types9 = require("@avaprotocol/types");
17337
- var ContractWriteNode2 = class _ContractWriteNode extends interface_default2 {
17360
+ var ContractWriteNode2 = class _ContractWriteNode extends Node {
17338
17361
  constructor(props) {
17339
17362
  super({ ...props, type: import_types9.NodeType.ContractWrite, data: props.data });
17340
17363
  }
@@ -17362,7 +17385,7 @@ var ContractWriteNode2 = class _ContractWriteNode extends interface_default2 {
17362
17385
  const request = new avs_pb9.TaskNode();
17363
17386
  request.setId(this.id);
17364
17387
  request.setName(this.name);
17365
- const nodeData = new avs_pb9.ContractWriteNode();
17388
+ const node = new avs_pb9.ContractWriteNode();
17366
17389
  const config = new avs_pb9.ContractWriteNode.Config();
17367
17390
  config.setContractAddress(this.data.contractAddress);
17368
17391
  config.setCallData(this.data.callData);
@@ -17376,12 +17399,12 @@ var ContractWriteNode2 = class _ContractWriteNode extends interface_default2 {
17376
17399
  }
17377
17400
  config.addMethodCalls(methodCallMsg);
17378
17401
  });
17379
- nodeData.setConfig(config);
17402
+ node.setConfig(config);
17380
17403
  const inputValue = convertInputToProtobuf(this.input);
17381
17404
  if (inputValue) {
17382
- nodeData.setInput(inputValue);
17405
+ node.setInput(inputValue);
17383
17406
  }
17384
- request.setContractWrite(nodeData);
17407
+ request.setContractWrite(node);
17385
17408
  return request;
17386
17409
  }
17387
17410
  static fromOutputData(outputData) {
@@ -17443,7 +17466,7 @@ var contractWrite_default = ContractWriteNode2;
17443
17466
  // src/models/node/customCode.ts
17444
17467
  var avs_pb10 = __toESM(require_avs_pb());
17445
17468
  var import_types10 = require("@avaprotocol/types");
17446
- var CustomCodeNode2 = class _CustomCodeNode extends interface_default2 {
17469
+ var CustomCodeNode2 = class _CustomCodeNode extends Node {
17447
17470
  constructor(props) {
17448
17471
  super({ ...props, type: import_types10.NodeType.CustomCode, data: props.data });
17449
17472
  }
@@ -17466,16 +17489,16 @@ var CustomCodeNode2 = class _CustomCodeNode extends interface_default2 {
17466
17489
  const request = new avs_pb10.TaskNode();
17467
17490
  request.setId(this.id);
17468
17491
  request.setName(this.name);
17469
- const nodeData = new avs_pb10.CustomCodeNode();
17492
+ const node = new avs_pb10.CustomCodeNode();
17470
17493
  const config = new avs_pb10.CustomCodeNode.Config();
17471
17494
  config.setLang(this.data.lang);
17472
17495
  config.setSource(this.data.source);
17473
- nodeData.setConfig(config);
17496
+ node.setConfig(config);
17474
17497
  const inputValue = convertInputToProtobuf(this.input);
17475
17498
  if (inputValue) {
17476
- nodeData.setInput(inputValue);
17499
+ node.setInput(inputValue);
17477
17500
  }
17478
- request.setCustomCode(nodeData);
17501
+ request.setCustomCode(node);
17479
17502
  return request;
17480
17503
  }
17481
17504
  static fromOutputData(outputData) {
@@ -17495,7 +17518,7 @@ var customCode_default = CustomCodeNode2;
17495
17518
  // src/models/node/graphqlQuery.ts
17496
17519
  var avs_pb11 = __toESM(require_avs_pb());
17497
17520
  var import_types11 = require("@avaprotocol/types");
17498
- var GraphQLQueryNode2 = class _GraphQLQueryNode extends interface_default2 {
17521
+ var GraphQLQueryNode2 = class _GraphQLQueryNode extends Node {
17499
17522
  constructor(props) {
17500
17523
  super({
17501
17524
  ...props,
@@ -17517,7 +17540,7 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends interface_default2 {
17517
17540
  const request = new avs_pb11.TaskNode();
17518
17541
  request.setId(this.id);
17519
17542
  request.setName(this.name);
17520
- const nodeData = new avs_pb11.GraphQLQueryNode();
17543
+ const node = new avs_pb11.GraphQLQueryNode();
17521
17544
  const config = new avs_pb11.GraphQLQueryNode.Config();
17522
17545
  config.setUrl(this.data.url);
17523
17546
  config.setQuery(this.data.query);
@@ -17527,12 +17550,12 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends interface_default2 {
17527
17550
  variablesMap.set(key, value);
17528
17551
  });
17529
17552
  }
17530
- nodeData.setConfig(config);
17553
+ node.setConfig(config);
17531
17554
  const inputValue = convertInputToProtobuf(this.input);
17532
17555
  if (inputValue) {
17533
- nodeData.setInput(inputValue);
17556
+ node.setInput(inputValue);
17534
17557
  }
17535
- request.setGraphqlQuery(nodeData);
17558
+ request.setGraphqlQuery(node);
17536
17559
  return request;
17537
17560
  }
17538
17561
  static fromOutputData(outputData) {
@@ -17545,7 +17568,7 @@ var graphqlQuery_default = GraphQLQueryNode2;
17545
17568
  // src/models/node/restApi.ts
17546
17569
  var avs_pb12 = __toESM(require_avs_pb());
17547
17570
  var import_types12 = require("@avaprotocol/types");
17548
- var RestAPINode2 = class _RestAPINode extends interface_default2 {
17571
+ var RestAPINode2 = class _RestAPINode extends Node {
17549
17572
  constructor(props) {
17550
17573
  super({ ...props, type: import_types12.NodeType.RestAPI, data: props.data });
17551
17574
  }
@@ -17606,7 +17629,7 @@ var restApi_default = RestAPINode2;
17606
17629
  // src/models/node/contractRead.ts
17607
17630
  var avs_pb13 = __toESM(require_avs_pb());
17608
17631
  var import_types13 = require("@avaprotocol/types");
17609
- var ContractReadNode2 = class _ContractReadNode extends interface_default2 {
17632
+ var ContractReadNode2 = class _ContractReadNode extends Node {
17610
17633
  constructor(props) {
17611
17634
  super({ ...props, type: import_types13.NodeType.ContractRead, data: props.data });
17612
17635
  }
@@ -17633,7 +17656,7 @@ var ContractReadNode2 = class _ContractReadNode extends interface_default2 {
17633
17656
  const request = new avs_pb13.TaskNode();
17634
17657
  request.setId(this.id);
17635
17658
  request.setName(this.name);
17636
- const nodeData = new avs_pb13.ContractReadNode();
17659
+ const node = new avs_pb13.ContractReadNode();
17637
17660
  const config = new avs_pb13.ContractReadNode.Config();
17638
17661
  config.setContractAddress(this.data.contractAddress);
17639
17662
  config.setContractAbi(this.data.contractAbi);
@@ -17646,12 +17669,12 @@ var ContractReadNode2 = class _ContractReadNode extends interface_default2 {
17646
17669
  }
17647
17670
  config.addMethodCalls(methodCallMsg);
17648
17671
  });
17649
- nodeData.setConfig(config);
17672
+ node.setConfig(config);
17650
17673
  const inputValue = convertInputToProtobuf(this.input);
17651
17674
  if (inputValue) {
17652
- nodeData.setInput(inputValue);
17675
+ node.setInput(inputValue);
17653
17676
  }
17654
- request.setContractRead(nodeData);
17677
+ request.setContractRead(node);
17655
17678
  return request;
17656
17679
  }
17657
17680
  static fromOutputData(outputData) {
@@ -17679,7 +17702,7 @@ var contractRead_default = ContractReadNode2;
17679
17702
  // src/models/node/ethTransfer.ts
17680
17703
  var avs_pb14 = __toESM(require_avs_pb());
17681
17704
  var import_types14 = require("@avaprotocol/types");
17682
- var ETHTransferNode2 = class _ETHTransferNode extends interface_default2 {
17705
+ var ETHTransferNode2 = class _ETHTransferNode extends Node {
17683
17706
  constructor(props) {
17684
17707
  super({ ...props, type: import_types14.NodeType.ETHTransfer, data: props.data });
17685
17708
  }
@@ -17697,16 +17720,16 @@ var ETHTransferNode2 = class _ETHTransferNode extends interface_default2 {
17697
17720
  const request = new avs_pb14.TaskNode();
17698
17721
  request.setId(this.id);
17699
17722
  request.setName(this.name);
17700
- const nodeData = new avs_pb14.ETHTransferNode();
17723
+ const node = new avs_pb14.ETHTransferNode();
17701
17724
  const config = new avs_pb14.ETHTransferNode.Config();
17702
17725
  config.setDestination(this.data.destination);
17703
17726
  config.setAmount(this.data.amount);
17704
- nodeData.setConfig(config);
17727
+ node.setConfig(config);
17705
17728
  const inputValue = convertInputToProtobuf(this.input);
17706
17729
  if (inputValue) {
17707
- nodeData.setInput(inputValue);
17730
+ node.setInput(inputValue);
17708
17731
  }
17709
- request.setEthTransfer(nodeData);
17732
+ request.setEthTransfer(node);
17710
17733
  return request;
17711
17734
  }
17712
17735
  static fromOutputData(outputData) {
@@ -17719,7 +17742,7 @@ var ethTransfer_default = ETHTransferNode2;
17719
17742
  // src/models/node/branch.ts
17720
17743
  var import_types15 = require("@avaprotocol/types");
17721
17744
  var avs_pb15 = __toESM(require_avs_pb());
17722
- var BranchNode2 = class _BranchNode extends interface_default2 {
17745
+ var BranchNode2 = class _BranchNode extends Node {
17723
17746
  constructor(props) {
17724
17747
  super({ ...props, type: import_types15.NodeType.Branch, data: props.data });
17725
17748
  }
@@ -17745,7 +17768,7 @@ var BranchNode2 = class _BranchNode extends interface_default2 {
17745
17768
  const request = new avs_pb15.TaskNode();
17746
17769
  request.setId(this.id);
17747
17770
  request.setName(this.name);
17748
- const nodeData = new avs_pb15.BranchNode();
17771
+ const node = new avs_pb15.BranchNode();
17749
17772
  const config = new avs_pb15.BranchNode.Config();
17750
17773
  if (this.data.conditions && this.data.conditions.length > 0) {
17751
17774
  const conditionsList = this.data.conditions.map(
@@ -17759,12 +17782,12 @@ var BranchNode2 = class _BranchNode extends interface_default2 {
17759
17782
  );
17760
17783
  config.setConditionsList(conditionsList);
17761
17784
  }
17762
- nodeData.setConfig(config);
17785
+ node.setConfig(config);
17763
17786
  const inputValue = convertInputToProtobuf(this.input);
17764
17787
  if (inputValue) {
17765
- nodeData.setInput(inputValue);
17788
+ node.setInput(inputValue);
17766
17789
  }
17767
- request.setBranch(nodeData);
17790
+ request.setBranch(node);
17768
17791
  return request;
17769
17792
  }
17770
17793
  static fromOutputData(outputData) {
@@ -17778,7 +17801,7 @@ var branch_default = BranchNode2;
17778
17801
  // src/models/node/filter.ts
17779
17802
  var avs_pb16 = __toESM(require_avs_pb());
17780
17803
  var import_types16 = require("@avaprotocol/types");
17781
- var FilterNode2 = class _FilterNode extends interface_default2 {
17804
+ var FilterNode2 = class _FilterNode extends Node {
17782
17805
  constructor(props) {
17783
17806
  super({ ...props, type: import_types16.NodeType.Filter, data: props.data });
17784
17807
  }
@@ -17796,16 +17819,16 @@ var FilterNode2 = class _FilterNode extends interface_default2 {
17796
17819
  const request = new avs_pb16.TaskNode();
17797
17820
  request.setId(this.id);
17798
17821
  request.setName(this.name);
17799
- const nodeData = new avs_pb16.FilterNode();
17822
+ const node = new avs_pb16.FilterNode();
17800
17823
  const config = new avs_pb16.FilterNode.Config();
17801
17824
  config.setExpression(this.data.expression);
17802
17825
  config.setSourceId(this.data.sourceId || "");
17803
- nodeData.setConfig(config);
17826
+ node.setConfig(config);
17804
17827
  const inputValue = convertInputToProtobuf(this.input);
17805
17828
  if (inputValue) {
17806
- nodeData.setInput(inputValue);
17829
+ node.setInput(inputValue);
17807
17830
  }
17808
- request.setFilter(nodeData);
17831
+ request.setFilter(node);
17809
17832
  return request;
17810
17833
  }
17811
17834
  static fromOutputData(outputData) {
@@ -17818,7 +17841,7 @@ var filter_default = FilterNode2;
17818
17841
  // src/models/node/loop.ts
17819
17842
  var avs_pb17 = __toESM(require_avs_pb());
17820
17843
  var import_types17 = require("@avaprotocol/types");
17821
- var LoopNode2 = class _LoopNode extends interface_default2 {
17844
+ var LoopNode2 = class _LoopNode extends Node {
17822
17845
  constructor(props) {
17823
17846
  super({ ...props, type: import_types17.NodeType.Loop, data: props.data });
17824
17847
  }
@@ -18209,7 +18232,6 @@ var workflow_default = Workflow;
18209
18232
 
18210
18233
  // src/models/step.ts
18211
18234
  var avs_pb20 = __toESM(require_avs_pb());
18212
- var import_struct_pb2 = require("google-protobuf/google/protobuf/struct_pb");
18213
18235
  var Step = class _Step {
18214
18236
  constructor(props) {
18215
18237
  this.id = props.id;
@@ -18244,222 +18266,261 @@ var Step = class _Step {
18244
18266
  };
18245
18267
  }
18246
18268
  static getOutput(step) {
18247
- const outputDataType = step.getOutputDataCase();
18248
- let nodeOutputMessage;
18249
- switch (outputDataType) {
18269
+ const getOutputDataCase = () => {
18270
+ if (typeof step.getOutputDataCase === "function") {
18271
+ return step.getOutputDataCase();
18272
+ }
18273
+ const stepObj = step;
18274
+ if (stepObj.blockTrigger)
18275
+ return avs_pb20.Execution.Step.OutputDataCase.BLOCK_TRIGGER;
18276
+ if (stepObj.fixedTimeTrigger)
18277
+ return avs_pb20.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER;
18278
+ if (stepObj.cronTrigger)
18279
+ return avs_pb20.Execution.Step.OutputDataCase.CRON_TRIGGER;
18280
+ if (stepObj.eventTrigger)
18281
+ return avs_pb20.Execution.Step.OutputDataCase.EVENT_TRIGGER;
18282
+ if (stepObj.manualTrigger)
18283
+ return avs_pb20.Execution.Step.OutputDataCase.MANUAL_TRIGGER;
18284
+ if (stepObj.ethTransfer)
18285
+ return avs_pb20.Execution.Step.OutputDataCase.ETH_TRANSFER;
18286
+ if (stepObj.graphql) return avs_pb20.Execution.Step.OutputDataCase.GRAPHQL;
18287
+ if (stepObj.contractRead)
18288
+ return avs_pb20.Execution.Step.OutputDataCase.CONTRACT_READ;
18289
+ if (stepObj.contractWrite)
18290
+ return avs_pb20.Execution.Step.OutputDataCase.CONTRACT_WRITE;
18291
+ if (stepObj.customCode)
18292
+ return avs_pb20.Execution.Step.OutputDataCase.CUSTOM_CODE;
18293
+ if (stepObj.restApi) return avs_pb20.Execution.Step.OutputDataCase.REST_API;
18294
+ if (stepObj.branch) return avs_pb20.Execution.Step.OutputDataCase.BRANCH;
18295
+ if (stepObj.filter) return avs_pb20.Execution.Step.OutputDataCase.FILTER;
18296
+ if (stepObj.loop) return avs_pb20.Execution.Step.OutputDataCase.LOOP;
18297
+ return avs_pb20.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET;
18298
+ };
18299
+ switch (getOutputDataCase()) {
18250
18300
  case avs_pb20.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET:
18251
18301
  return void 0;
18252
18302
  // Trigger outputs
18253
18303
  case avs_pb20.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
18254
- const blockOutput = step.getBlockTrigger()?.toObject();
18255
- return blockOutput ? { blockNumber: blockOutput.blockNumber } : void 0;
18304
+ return typeof step.getBlockTrigger === "function" ? step.getBlockTrigger()?.toObject() : step.blockTrigger;
18256
18305
  case avs_pb20.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
18257
- const fixedTimeOutput = step.getFixedTimeTrigger()?.toObject();
18258
- return fixedTimeOutput ? {
18259
- timestamp: fixedTimeOutput.timestamp,
18260
- timestampIso: fixedTimeOutput.timestampIso
18261
- } : void 0;
18306
+ return typeof step.getFixedTimeTrigger === "function" ? step.getFixedTimeTrigger()?.toObject() : step.fixedTimeTrigger;
18262
18307
  case avs_pb20.Execution.Step.OutputDataCase.CRON_TRIGGER:
18263
- const cronOutput = step.getCronTrigger()?.toObject();
18264
- return cronOutput ? {
18265
- timestamp: cronOutput.timestamp,
18266
- timestampIso: cronOutput.timestampIso
18267
- } : void 0;
18308
+ return typeof step.getCronTrigger === "function" ? step.getCronTrigger()?.toObject() : step.cronTrigger;
18268
18309
  case avs_pb20.Execution.Step.OutputDataCase.EVENT_TRIGGER:
18269
- const eventTrigger = step.getEventTrigger();
18310
+ const eventTrigger = typeof step.getEventTrigger === "function" ? step.getEventTrigger() : step.eventTrigger;
18270
18311
  if (eventTrigger) {
18271
- if (eventTrigger.hasEvmLog()) {
18312
+ if (typeof eventTrigger.hasEvmLog === "function" && eventTrigger.hasEvmLog()) {
18272
18313
  return eventTrigger.getEvmLog()?.toObject();
18273
- } else if (eventTrigger.hasTransferLog()) {
18314
+ } else if (typeof eventTrigger.hasTransferLog === "function" && eventTrigger.hasTransferLog()) {
18274
18315
  return eventTrigger.getTransferLog()?.toObject();
18316
+ } else if (eventTrigger.evmLog) {
18317
+ return eventTrigger.evmLog;
18318
+ } else if (eventTrigger.transferLog) {
18319
+ return eventTrigger.transferLog;
18275
18320
  }
18276
18321
  }
18277
18322
  return void 0;
18278
18323
  case avs_pb20.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
18279
- const manualOutput = step.getManualTrigger()?.toObject();
18280
- return manualOutput || void 0;
18281
- // Node outputs
18324
+ return typeof step.getManualTrigger === "function" ? step.getManualTrigger()?.toObject() || void 0 : step.manualTrigger;
18325
+ // Node outputs - RESTORE MISSING CASES
18282
18326
  case avs_pb20.Execution.Step.OutputDataCase.ETH_TRANSFER:
18283
- const ethTransferOutput = step.getEthTransfer()?.toObject();
18284
- return ethTransferOutput ? {
18285
- transactionHash: ethTransferOutput.transactionHash
18286
- } : void 0;
18327
+ return typeof step.getEthTransfer === "function" ? step.getEthTransfer()?.toObject() : step.ethTransfer;
18328
+ case avs_pb20.Execution.Step.OutputDataCase.CUSTOM_CODE:
18329
+ const customCodeOutput = typeof step.getCustomCode === "function" ? step.getCustomCode() : step.customCode;
18330
+ if (customCodeOutput) {
18331
+ if (typeof customCodeOutput.hasData === "function" && customCodeOutput.hasData()) {
18332
+ try {
18333
+ return convertProtobufValueToJs(customCodeOutput.getData());
18334
+ } catch {
18335
+ return customCodeOutput.getData();
18336
+ }
18337
+ } else if (customCodeOutput.data) {
18338
+ return typeof customCodeOutput.data.getKindCase === "function" ? convertProtobufValueToJs(customCodeOutput.data) : customCodeOutput.data;
18339
+ }
18340
+ }
18341
+ return void 0;
18342
+ case avs_pb20.Execution.Step.OutputDataCase.REST_API:
18343
+ const restApiOutput = typeof step.getRestApi === "function" ? step.getRestApi() : step.restApi;
18344
+ if (restApiOutput) {
18345
+ if (typeof restApiOutput.hasData === "function" && restApiOutput.hasData()) {
18346
+ try {
18347
+ return convertProtobufValueToJs(restApiOutput.getData());
18348
+ } catch {
18349
+ return restApiOutput.getData();
18350
+ }
18351
+ } else if (restApiOutput.data) {
18352
+ return typeof restApiOutput.data.getKindCase === "function" ? convertProtobufValueToJs(restApiOutput.data) : restApiOutput.data;
18353
+ }
18354
+ }
18355
+ return void 0;
18356
+ case avs_pb20.Execution.Step.OutputDataCase.BRANCH:
18357
+ return typeof step.getBranch === "function" ? step.getBranch()?.toObject() : step.branch;
18358
+ case avs_pb20.Execution.Step.OutputDataCase.LOOP:
18359
+ const loopOutput = typeof step.getLoop === "function" ? step.getLoop() : step.loop;
18360
+ if (loopOutput) {
18361
+ if (typeof loopOutput.getData === "function" && loopOutput.getData()) {
18362
+ try {
18363
+ return JSON.parse(loopOutput.getData());
18364
+ } catch {
18365
+ return loopOutput.getData();
18366
+ }
18367
+ } else if (loopOutput.data) {
18368
+ try {
18369
+ return typeof loopOutput.data === "string" ? JSON.parse(loopOutput.data) : loopOutput.data;
18370
+ } catch {
18371
+ return loopOutput.data;
18372
+ }
18373
+ }
18374
+ }
18375
+ return void 0;
18287
18376
  case avs_pb20.Execution.Step.OutputDataCase.GRAPHQL:
18288
- nodeOutputMessage = step.getGraphql();
18289
- return nodeOutputMessage && nodeOutputMessage.hasData() ? nodeOutputMessage.getData() : void 0;
18377
+ const graphqlOutput = typeof step.getGraphql === "function" ? step.getGraphql() : step.graphql;
18378
+ if (graphqlOutput) {
18379
+ try {
18380
+ return typeof graphqlOutput.toObject === "function" ? graphqlOutput.toObject() : graphqlOutput;
18381
+ } catch {
18382
+ return void 0;
18383
+ }
18384
+ }
18385
+ return void 0;
18290
18386
  case avs_pb20.Execution.Step.OutputDataCase.CONTRACT_READ:
18291
- nodeOutputMessage = step.getContractRead();
18292
- if (nodeOutputMessage) {
18293
- const results = nodeOutputMessage.getResultsList();
18294
- if (results && results.length > 0) {
18295
- const resultArray = results.map((result) => {
18296
- const dataFields = result.getDataList().map((field) => ({
18297
- name: field.getName(),
18298
- type: field.getType(),
18299
- value: field.getValue()
18300
- }));
18301
- return {
18302
- methodName: result.getMethodName(),
18303
- success: result.getSuccess(),
18304
- error: result.getError(),
18305
- data: dataFields
18306
- };
18307
- });
18308
- return { results: resultArray };
18387
+ const contractReadOutput = typeof step.getContractRead === "function" ? step.getContractRead() : step.contractRead;
18388
+ if (contractReadOutput) {
18389
+ const outputObj = typeof contractReadOutput.toObject === "function" ? contractReadOutput.toObject() : contractReadOutput;
18390
+ if (outputObj && outputObj.resultsList) {
18391
+ return {
18392
+ ...outputObj,
18393
+ results: outputObj.resultsList.map((result) => ({
18394
+ methodName: result.methodName,
18395
+ success: result.success,
18396
+ error: result.error,
18397
+ data: result.dataList || []
18398
+ }))
18399
+ };
18309
18400
  }
18401
+ return outputObj;
18310
18402
  }
18311
18403
  return void 0;
18312
18404
  case avs_pb20.Execution.Step.OutputDataCase.CONTRACT_WRITE:
18313
- nodeOutputMessage = step.getContractWrite();
18314
- if (nodeOutputMessage) {
18315
- const results = nodeOutputMessage.getResultsList();
18316
- if (results && results.length > 0) {
18317
- const transformedResults = results.map((result) => ({
18318
- methodName: result.getMethodName(),
18319
- success: result.getSuccess(),
18320
- transaction: result.getTransaction() ? {
18321
- hash: result.getTransaction()?.getHash(),
18322
- status: result.getTransaction()?.getStatus(),
18323
- blockNumber: result.getTransaction()?.getBlockNumber(),
18324
- blockHash: result.getTransaction()?.getBlockHash(),
18325
- gasUsed: result.getTransaction()?.getGasUsed(),
18326
- gasLimit: result.getTransaction()?.getGasLimit(),
18327
- gasPrice: result.getTransaction()?.getGasPrice(),
18328
- effectiveGasPrice: result.getTransaction()?.getEffectiveGasPrice(),
18329
- from: result.getTransaction()?.getFrom(),
18330
- to: result.getTransaction()?.getTo(),
18331
- value: result.getTransaction()?.getValue(),
18332
- nonce: result.getTransaction()?.getNonce(),
18333
- transactionIndex: result.getTransaction()?.getTransactionIndex(),
18334
- confirmations: result.getTransaction()?.getConfirmations(),
18335
- timestamp: result.getTransaction()?.getTimestamp()
18405
+ const contractWriteOutput = typeof step.getContractWrite === "function" ? step.getContractWrite() : step.contractWrite;
18406
+ if (contractWriteOutput) {
18407
+ const outputObj = typeof contractWriteOutput.toObject === "function" ? contractWriteOutput.toObject() : contractWriteOutput;
18408
+ if (outputObj && outputObj.resultsList) {
18409
+ const transformedResults = outputObj.resultsList.map((result) => ({
18410
+ methodName: result.methodName,
18411
+ success: result.success,
18412
+ transaction: result.transaction ? {
18413
+ hash: result.transaction.hash,
18414
+ status: result.transaction.status,
18415
+ blockNumber: result.transaction.blockNumber,
18416
+ blockHash: result.transaction.blockHash,
18417
+ gasUsed: result.transaction.gasUsed,
18418
+ gasLimit: result.transaction.gasLimit,
18419
+ gasPrice: result.transaction.gasPrice,
18420
+ effectiveGasPrice: result.transaction.effectiveGasPrice,
18421
+ from: result.transaction.from,
18422
+ to: result.transaction.to,
18423
+ value: result.transaction.value,
18424
+ nonce: result.transaction.nonce,
18425
+ transactionIndex: result.transaction.transactionIndex,
18426
+ confirmations: result.transaction.confirmations,
18427
+ timestamp: result.transaction.timestamp
18336
18428
  } : null,
18337
- events: result.getEventsList().map((event) => ({
18338
- eventName: event.getEventName(),
18339
- address: event.getAddress(),
18340
- topics: event.getTopicsList(),
18341
- data: event.getData(),
18342
- decoded: event.getDecodedMap() ? Object.fromEntries(event.getDecodedMap().toArray()) : {}
18343
- })),
18344
- error: result.getError() ? {
18345
- code: result.getError()?.getCode(),
18346
- message: result.getError()?.getMessage(),
18347
- revertReason: result.getError()?.getRevertReason()
18429
+ events: result.eventsList?.map((event) => ({
18430
+ eventName: event.eventName,
18431
+ address: event.address,
18432
+ topics: event.topicsList || [],
18433
+ data: event.data,
18434
+ decoded: event.decodedMap || {}
18435
+ })) || [],
18436
+ error: result.error ? {
18437
+ code: result.error.code,
18438
+ message: result.error.message,
18439
+ revertReason: result.error.revertReason
18348
18440
  } : null,
18349
- returnData: result.getReturnData() ? {
18350
- name: result.getReturnData()?.getName(),
18351
- type: result.getReturnData()?.getType(),
18352
- value: result.getReturnData()?.getValue()
18441
+ returnData: result.returnData ? {
18442
+ name: result.returnData.name,
18443
+ type: result.returnData.type,
18444
+ value: result.returnData.value
18353
18445
  } : null,
18354
- inputData: result.getInputData()
18446
+ inputData: result.inputData
18355
18447
  }));
18356
- if (transformedResults.length === 1) {
18357
- return {
18358
- results: transformedResults,
18359
- // Legacy compatibility fields
18448
+ return {
18449
+ ...outputObj,
18450
+ results: transformedResults,
18451
+ // For backward compatibility, provide legacy fields from first result
18452
+ ...transformedResults.length > 0 && {
18360
18453
  transaction: transformedResults[0].transaction,
18361
18454
  success: transformedResults[0].success,
18362
18455
  hash: transformedResults[0].transaction?.hash
18363
- };
18364
- } else {
18365
- return { results: transformedResults };
18366
- }
18456
+ }
18457
+ };
18367
18458
  }
18459
+ return outputObj;
18368
18460
  }
18369
18461
  return void 0;
18370
- case avs_pb20.Execution.Step.OutputDataCase.CUSTOM_CODE:
18371
- nodeOutputMessage = step.getCustomCode();
18372
- return nodeOutputMessage && nodeOutputMessage.hasData() ? convertProtobufValueToJs(nodeOutputMessage.getData()) : void 0;
18373
- case avs_pb20.Execution.Step.OutputDataCase.REST_API:
18374
- nodeOutputMessage = step.getRestApi();
18375
- return nodeOutputMessage && nodeOutputMessage.hasData() ? convertProtobufValueToJs(nodeOutputMessage.getData()) : void 0;
18376
- case avs_pb20.Execution.Step.OutputDataCase.BRANCH:
18377
- return step.getBranch()?.toObject();
18378
18462
  case avs_pb20.Execution.Step.OutputDataCase.FILTER:
18379
- nodeOutputMessage = step.getFilter();
18380
- if (nodeOutputMessage && nodeOutputMessage.hasData()) {
18381
- const rawData = nodeOutputMessage.getData();
18382
- if (rawData) {
18383
- if (typeof rawData.unpack === "function") {
18384
- try {
18385
- const unpackedValue = rawData.unpack(import_struct_pb2.Value.deserializeBinary, "google.protobuf.Value");
18386
- if (unpackedValue) {
18387
- return convertProtobufValueToJs(unpackedValue);
18388
- }
18389
- } catch (error) {
18390
- console.warn("Failed to unpack FilterNode Any wrapper:", error);
18391
- return void 0;
18392
- }
18393
- }
18394
- console.warn("FilterNode output data is not an Any wrapper - this is unexpected");
18463
+ const filterOutput = typeof step.getFilter === "function" ? step.getFilter() : step.filter;
18464
+ if (filterOutput) {
18465
+ try {
18466
+ return typeof filterOutput.toObject === "function" ? filterOutput.toObject() : filterOutput;
18467
+ } catch {
18395
18468
  return void 0;
18396
18469
  }
18397
18470
  }
18398
18471
  return void 0;
18399
- case avs_pb20.Execution.Step.OutputDataCase.LOOP:
18400
- const loopOutput = step.getLoop();
18401
- if (!loopOutput) return void 0;
18402
- const loopData = loopOutput.getData();
18403
- if (!loopData) return void 0;
18404
- try {
18405
- const parsedData = JSON.parse(loopData);
18406
- if (Array.isArray(parsedData)) {
18407
- return parsedData.map((item, index) => {
18408
- if (!item || typeof item !== "object") {
18409
- return item;
18410
- }
18411
- if (item.statusCode !== void 0 && (item.body !== void 0 || item.headers !== void 0)) {
18412
- return item;
18413
- }
18414
- if (item.result !== void 0 || item.output !== void 0 || item.error !== void 0) {
18415
- return item;
18416
- }
18417
- if (item.transactionHash !== void 0) {
18418
- return { transactionHash: item.transactionHash };
18419
- }
18420
- if (item.methodName !== void 0 && item.data !== void 0) {
18421
- return item;
18422
- }
18423
- if (item.data !== void 0 && typeof item.data === "object") {
18424
- return item;
18425
- }
18426
- return item;
18427
- });
18428
- }
18429
- if (parsedData && typeof parsedData === "object") {
18430
- return parsedData;
18431
- }
18432
- return { data: parsedData };
18433
- } catch (e) {
18434
- return { data: loopData };
18435
- }
18436
18472
  default:
18437
18473
  console.warn(
18438
- `Unhandled output data type in Step.getOutput: ${outputDataType}`
18474
+ `Unhandled output data type in Step.getOutput: ${step.getOutputDataCase()}`
18439
18475
  );
18440
18476
  return void 0;
18441
18477
  }
18442
18478
  }
18443
18479
  static fromResponse(step) {
18444
18480
  let inputData = void 0;
18445
- if (step.hasInput()) {
18481
+ if (typeof step.hasInput === "function" && step.hasInput()) {
18446
18482
  const inputValue = step.getInput();
18447
18483
  if (inputValue) {
18448
- inputData = convertProtobufValueToJs(inputValue);
18484
+ try {
18485
+ inputData = convertProtobufValueToJs(inputValue);
18486
+ } catch (error) {
18487
+ console.warn("Failed to convert protobuf input value:", error);
18488
+ inputData = inputValue;
18489
+ }
18490
+ }
18491
+ } else if (step.input) {
18492
+ const inputValue = step.input;
18493
+ if (typeof inputValue === "object" && !inputValue.getKindCase) {
18494
+ inputData = inputValue;
18495
+ } else {
18496
+ try {
18497
+ inputData = convertProtobufValueToJs(inputValue);
18498
+ } catch (error) {
18499
+ inputData = inputValue;
18500
+ }
18449
18501
  }
18450
18502
  }
18503
+ const getId = () => typeof step.getId === "function" ? step.getId() : step.id;
18504
+ const getType = () => typeof step.getType === "function" ? step.getType() : step.type;
18505
+ const getName = () => typeof step.getName === "function" ? step.getName() : step.name;
18506
+ const getSuccess = () => typeof step.getSuccess === "function" ? step.getSuccess() : step.success;
18507
+ const getError = () => typeof step.getError === "function" ? step.getError() : step.error;
18508
+ const getLog = () => typeof step.getLog === "function" ? step.getLog() : step.log;
18509
+ const getInputsList = () => typeof step.getInputsList === "function" ? step.getInputsList() : step.inputsList || [];
18510
+ const getStartAt = () => typeof step.getStartAt === "function" ? step.getStartAt() : step.startAt;
18511
+ const getEndAt = () => typeof step.getEndAt === "function" ? step.getEndAt() : step.endAt;
18451
18512
  return new _Step({
18452
- id: step.getId(),
18453
- type: convertProtobufStepTypeToSdk(step.getType()),
18454
- name: step.getName(),
18455
- success: step.getSuccess(),
18456
- error: step.getError(),
18457
- log: step.getLog(),
18458
- inputsList: step.getInputsList(),
18513
+ id: getId(),
18514
+ type: convertProtobufStepTypeToSdk(getType()),
18515
+ name: getName(),
18516
+ success: getSuccess(),
18517
+ error: getError(),
18518
+ log: getLog(),
18519
+ inputsList: getInputsList(),
18459
18520
  input: inputData,
18460
18521
  output: _Step.getOutput(step),
18461
- startAt: step.getStartAt(),
18462
- endAt: step.getEndAt()
18522
+ startAt: getStartAt(),
18523
+ endAt: getEndAt()
18463
18524
  });
18464
18525
  }
18465
18526
  // Client side does not generate the step, so there's no toRequest() method