@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.mjs CHANGED
@@ -16596,39 +16596,6 @@ var avs_pb7 = __toESM(require_avs_pb());
16596
16596
  // src/models/trigger/block.ts
16597
16597
  var avs_pb2 = __toESM(require_avs_pb());
16598
16598
 
16599
- // src/models/trigger/interface.ts
16600
- var Trigger = class {
16601
- /**
16602
- * Create an instance of Trigger from user inputs
16603
- * @param props
16604
- */
16605
- constructor(props) {
16606
- this.id = props.id;
16607
- this.name = props.name;
16608
- this.type = props.type;
16609
- this.data = props.data;
16610
- this.output = props.output;
16611
- this.input = props.input;
16612
- }
16613
- toRequest() {
16614
- throw new Error("Method not implemented.");
16615
- }
16616
- getOutput() {
16617
- return this.output;
16618
- }
16619
- toJson() {
16620
- return {
16621
- id: this.id,
16622
- name: this.name,
16623
- type: this.type,
16624
- data: this.data,
16625
- output: this.output,
16626
- input: this.input
16627
- };
16628
- }
16629
- };
16630
- var interface_default = Trigger;
16631
-
16632
16599
  // src/utils.ts
16633
16600
  import {
16634
16601
  Value as ProtobufValue,
@@ -16778,16 +16745,61 @@ function extractInputFromProtobuf(inputValue) {
16778
16745
  if (!inputValue) {
16779
16746
  return void 0;
16780
16747
  }
16781
- const inputJavaScript = inputValue.toJavaScript();
16782
- if (inputJavaScript && typeof inputJavaScript === "object" && !Array.isArray(inputJavaScript)) {
16783
- return inputJavaScript;
16748
+ if (typeof inputValue === "object" && !inputValue.toJavaScript) {
16749
+ if (!Array.isArray(inputValue)) {
16750
+ return inputValue;
16751
+ }
16752
+ return void 0;
16753
+ }
16754
+ try {
16755
+ const protobufValue = inputValue;
16756
+ const inputJavaScript = protobufValue.toJavaScript();
16757
+ if (inputJavaScript && typeof inputJavaScript === "object" && !Array.isArray(inputJavaScript)) {
16758
+ return inputJavaScript;
16759
+ }
16760
+ } catch (error) {
16761
+ if (typeof inputValue === "object" && !Array.isArray(inputValue)) {
16762
+ return inputValue;
16763
+ }
16784
16764
  }
16785
16765
  return void 0;
16786
16766
  }
16787
16767
 
16768
+ // src/models/trigger/interface.ts
16769
+ var Trigger = class {
16770
+ /**
16771
+ * Create an instance of Trigger from user inputs
16772
+ * @param props
16773
+ */
16774
+ constructor(props) {
16775
+ this.id = props.id;
16776
+ this.name = props.name;
16777
+ this.type = props.type;
16778
+ this.data = props.data;
16779
+ this.output = props.output;
16780
+ this.input = props.input ? extractInputFromProtobuf(props.input) : void 0;
16781
+ }
16782
+ toRequest() {
16783
+ throw new Error("Method not implemented.");
16784
+ }
16785
+ getOutput() {
16786
+ return this.output;
16787
+ }
16788
+ toJson() {
16789
+ return {
16790
+ id: this.id,
16791
+ name: this.name,
16792
+ type: this.type,
16793
+ data: this.data,
16794
+ output: this.output,
16795
+ input: this.input
16796
+ };
16797
+ }
16798
+ };
16799
+
16788
16800
  // src/models/trigger/block.ts
16789
16801
  import { TriggerType as TriggerType3 } from "@avaprotocol/types";
16790
- var BlockTrigger2 = class _BlockTrigger extends interface_default {
16802
+ var BlockTrigger2 = class _BlockTrigger extends Trigger {
16791
16803
  constructor(props) {
16792
16804
  super({ ...props, type: TriggerType3.Block, data: props.data });
16793
16805
  }
@@ -16864,7 +16876,7 @@ var block_default = BlockTrigger2;
16864
16876
  var avs_pb3 = __toESM(require_avs_pb());
16865
16877
  import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
16866
16878
  import { TriggerType as TriggerType5 } from "@avaprotocol/types";
16867
- var CronTrigger2 = class _CronTrigger extends interface_default {
16879
+ var CronTrigger2 = class _CronTrigger extends Trigger {
16868
16880
  constructor(props) {
16869
16881
  super({ ...props, type: TriggerType5.Cron, data: props.data });
16870
16882
  }
@@ -16955,7 +16967,7 @@ var avs_pb4 = __toESM(require_avs_pb());
16955
16967
  import {
16956
16968
  TriggerType as TriggerType7
16957
16969
  } from "@avaprotocol/types";
16958
- var EventTrigger2 = class _EventTrigger extends interface_default {
16970
+ var EventTrigger2 = class _EventTrigger extends Trigger {
16959
16971
  constructor(props) {
16960
16972
  super({ ...props, type: TriggerType7.Event, data: props.data });
16961
16973
  }
@@ -17072,7 +17084,7 @@ var event_default = EventTrigger2;
17072
17084
  // src/models/trigger/fixedTime.ts
17073
17085
  var avs_pb5 = __toESM(require_avs_pb());
17074
17086
  import { TriggerType as TriggerType9 } from "@avaprotocol/types";
17075
- var FixedTimeTrigger2 = class _FixedTimeTrigger extends interface_default {
17087
+ var FixedTimeTrigger2 = class _FixedTimeTrigger extends Trigger {
17076
17088
  constructor(props) {
17077
17089
  super({ ...props, type: TriggerType9.FixedTime, data: props.data });
17078
17090
  }
@@ -17137,7 +17149,7 @@ var fixedTime_default = FixedTimeTrigger2;
17137
17149
  // src/models/trigger/manual.ts
17138
17150
  var avs_pb6 = __toESM(require_avs_pb());
17139
17151
  import { TriggerType as TriggerType11 } from "@avaprotocol/types";
17140
- var ManualTrigger = class _ManualTrigger extends interface_default {
17152
+ var ManualTrigger = class _ManualTrigger extends Trigger {
17141
17153
  constructor(props) {
17142
17154
  super({ ...props, type: TriggerType11.Manual, data: props.data || null });
17143
17155
  }
@@ -17291,12 +17303,13 @@ var avs_pb8 = __toESM(require_avs_pb());
17291
17303
  import { NodeType as NodeType2, NodeTypeGoConverter } from "@avaprotocol/types";
17292
17304
  import _ from "lodash";
17293
17305
  var Node = class {
17306
+ // Use JavaScript object type for internal storage
17294
17307
  constructor(props) {
17295
17308
  this.id = props.id;
17296
17309
  this.name = props.name;
17297
17310
  this.type = props.type;
17298
17311
  this.data = props.data;
17299
- this.input = props.input;
17312
+ this.input = props.input ? extractInputFromProtobuf(props.input) : void 0;
17300
17313
  }
17301
17314
  toRequest() {
17302
17315
  const request = new avs_pb8.TaskNode();
@@ -17307,13 +17320,23 @@ var Node = class {
17307
17320
  }
17308
17321
  return request;
17309
17322
  }
17323
+ static fromResponse(raw) {
17324
+ const obj = raw.toObject();
17325
+ let input = void 0;
17326
+ if (raw.hasInput()) {
17327
+ input = raw.getInput().toObject();
17328
+ }
17329
+ return new this({
17330
+ ...obj,
17331
+ input
17332
+ });
17333
+ }
17310
17334
  };
17311
- var interface_default2 = Node;
17312
17335
 
17313
17336
  // src/models/node/contractWrite.ts
17314
17337
  var avs_pb9 = __toESM(require_avs_pb());
17315
17338
  import { NodeType as NodeType3 } from "@avaprotocol/types";
17316
- var ContractWriteNode2 = class _ContractWriteNode extends interface_default2 {
17339
+ var ContractWriteNode2 = class _ContractWriteNode extends Node {
17317
17340
  constructor(props) {
17318
17341
  super({ ...props, type: NodeType3.ContractWrite, data: props.data });
17319
17342
  }
@@ -17341,7 +17364,7 @@ var ContractWriteNode2 = class _ContractWriteNode extends interface_default2 {
17341
17364
  const request = new avs_pb9.TaskNode();
17342
17365
  request.setId(this.id);
17343
17366
  request.setName(this.name);
17344
- const nodeData = new avs_pb9.ContractWriteNode();
17367
+ const node = new avs_pb9.ContractWriteNode();
17345
17368
  const config = new avs_pb9.ContractWriteNode.Config();
17346
17369
  config.setContractAddress(this.data.contractAddress);
17347
17370
  config.setCallData(this.data.callData);
@@ -17355,12 +17378,12 @@ var ContractWriteNode2 = class _ContractWriteNode extends interface_default2 {
17355
17378
  }
17356
17379
  config.addMethodCalls(methodCallMsg);
17357
17380
  });
17358
- nodeData.setConfig(config);
17381
+ node.setConfig(config);
17359
17382
  const inputValue = convertInputToProtobuf(this.input);
17360
17383
  if (inputValue) {
17361
- nodeData.setInput(inputValue);
17384
+ node.setInput(inputValue);
17362
17385
  }
17363
- request.setContractWrite(nodeData);
17386
+ request.setContractWrite(node);
17364
17387
  return request;
17365
17388
  }
17366
17389
  static fromOutputData(outputData) {
@@ -17424,7 +17447,7 @@ var avs_pb10 = __toESM(require_avs_pb());
17424
17447
  import {
17425
17448
  NodeType as NodeType4
17426
17449
  } from "@avaprotocol/types";
17427
- var CustomCodeNode2 = class _CustomCodeNode extends interface_default2 {
17450
+ var CustomCodeNode2 = class _CustomCodeNode extends Node {
17428
17451
  constructor(props) {
17429
17452
  super({ ...props, type: NodeType4.CustomCode, data: props.data });
17430
17453
  }
@@ -17447,16 +17470,16 @@ var CustomCodeNode2 = class _CustomCodeNode extends interface_default2 {
17447
17470
  const request = new avs_pb10.TaskNode();
17448
17471
  request.setId(this.id);
17449
17472
  request.setName(this.name);
17450
- const nodeData = new avs_pb10.CustomCodeNode();
17473
+ const node = new avs_pb10.CustomCodeNode();
17451
17474
  const config = new avs_pb10.CustomCodeNode.Config();
17452
17475
  config.setLang(this.data.lang);
17453
17476
  config.setSource(this.data.source);
17454
- nodeData.setConfig(config);
17477
+ node.setConfig(config);
17455
17478
  const inputValue = convertInputToProtobuf(this.input);
17456
17479
  if (inputValue) {
17457
- nodeData.setInput(inputValue);
17480
+ node.setInput(inputValue);
17458
17481
  }
17459
- request.setCustomCode(nodeData);
17482
+ request.setCustomCode(node);
17460
17483
  return request;
17461
17484
  }
17462
17485
  static fromOutputData(outputData) {
@@ -17476,7 +17499,7 @@ var customCode_default = CustomCodeNode2;
17476
17499
  // src/models/node/graphqlQuery.ts
17477
17500
  var avs_pb11 = __toESM(require_avs_pb());
17478
17501
  import { NodeType as NodeType5 } from "@avaprotocol/types";
17479
- var GraphQLQueryNode2 = class _GraphQLQueryNode extends interface_default2 {
17502
+ var GraphQLQueryNode2 = class _GraphQLQueryNode extends Node {
17480
17503
  constructor(props) {
17481
17504
  super({
17482
17505
  ...props,
@@ -17498,7 +17521,7 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends interface_default2 {
17498
17521
  const request = new avs_pb11.TaskNode();
17499
17522
  request.setId(this.id);
17500
17523
  request.setName(this.name);
17501
- const nodeData = new avs_pb11.GraphQLQueryNode();
17524
+ const node = new avs_pb11.GraphQLQueryNode();
17502
17525
  const config = new avs_pb11.GraphQLQueryNode.Config();
17503
17526
  config.setUrl(this.data.url);
17504
17527
  config.setQuery(this.data.query);
@@ -17508,12 +17531,12 @@ var GraphQLQueryNode2 = class _GraphQLQueryNode extends interface_default2 {
17508
17531
  variablesMap.set(key, value);
17509
17532
  });
17510
17533
  }
17511
- nodeData.setConfig(config);
17534
+ node.setConfig(config);
17512
17535
  const inputValue = convertInputToProtobuf(this.input);
17513
17536
  if (inputValue) {
17514
- nodeData.setInput(inputValue);
17537
+ node.setInput(inputValue);
17515
17538
  }
17516
- request.setGraphqlQuery(nodeData);
17539
+ request.setGraphqlQuery(node);
17517
17540
  return request;
17518
17541
  }
17519
17542
  static fromOutputData(outputData) {
@@ -17528,7 +17551,7 @@ var avs_pb12 = __toESM(require_avs_pb());
17528
17551
  import {
17529
17552
  NodeType as NodeType6
17530
17553
  } from "@avaprotocol/types";
17531
- var RestAPINode2 = class _RestAPINode extends interface_default2 {
17554
+ var RestAPINode2 = class _RestAPINode extends Node {
17532
17555
  constructor(props) {
17533
17556
  super({ ...props, type: NodeType6.RestAPI, data: props.data });
17534
17557
  }
@@ -17589,7 +17612,7 @@ var restApi_default = RestAPINode2;
17589
17612
  // src/models/node/contractRead.ts
17590
17613
  var avs_pb13 = __toESM(require_avs_pb());
17591
17614
  import { NodeType as NodeType7 } from "@avaprotocol/types";
17592
- var ContractReadNode2 = class _ContractReadNode extends interface_default2 {
17615
+ var ContractReadNode2 = class _ContractReadNode extends Node {
17593
17616
  constructor(props) {
17594
17617
  super({ ...props, type: NodeType7.ContractRead, data: props.data });
17595
17618
  }
@@ -17616,7 +17639,7 @@ var ContractReadNode2 = class _ContractReadNode extends interface_default2 {
17616
17639
  const request = new avs_pb13.TaskNode();
17617
17640
  request.setId(this.id);
17618
17641
  request.setName(this.name);
17619
- const nodeData = new avs_pb13.ContractReadNode();
17642
+ const node = new avs_pb13.ContractReadNode();
17620
17643
  const config = new avs_pb13.ContractReadNode.Config();
17621
17644
  config.setContractAddress(this.data.contractAddress);
17622
17645
  config.setContractAbi(this.data.contractAbi);
@@ -17629,12 +17652,12 @@ var ContractReadNode2 = class _ContractReadNode extends interface_default2 {
17629
17652
  }
17630
17653
  config.addMethodCalls(methodCallMsg);
17631
17654
  });
17632
- nodeData.setConfig(config);
17655
+ node.setConfig(config);
17633
17656
  const inputValue = convertInputToProtobuf(this.input);
17634
17657
  if (inputValue) {
17635
- nodeData.setInput(inputValue);
17658
+ node.setInput(inputValue);
17636
17659
  }
17637
- request.setContractRead(nodeData);
17660
+ request.setContractRead(node);
17638
17661
  return request;
17639
17662
  }
17640
17663
  static fromOutputData(outputData) {
@@ -17662,7 +17685,7 @@ var contractRead_default = ContractReadNode2;
17662
17685
  // src/models/node/ethTransfer.ts
17663
17686
  var avs_pb14 = __toESM(require_avs_pb());
17664
17687
  import { NodeType as NodeType8 } from "@avaprotocol/types";
17665
- var ETHTransferNode2 = class _ETHTransferNode extends interface_default2 {
17688
+ var ETHTransferNode2 = class _ETHTransferNode extends Node {
17666
17689
  constructor(props) {
17667
17690
  super({ ...props, type: NodeType8.ETHTransfer, data: props.data });
17668
17691
  }
@@ -17680,16 +17703,16 @@ var ETHTransferNode2 = class _ETHTransferNode extends interface_default2 {
17680
17703
  const request = new avs_pb14.TaskNode();
17681
17704
  request.setId(this.id);
17682
17705
  request.setName(this.name);
17683
- const nodeData = new avs_pb14.ETHTransferNode();
17706
+ const node = new avs_pb14.ETHTransferNode();
17684
17707
  const config = new avs_pb14.ETHTransferNode.Config();
17685
17708
  config.setDestination(this.data.destination);
17686
17709
  config.setAmount(this.data.amount);
17687
- nodeData.setConfig(config);
17710
+ node.setConfig(config);
17688
17711
  const inputValue = convertInputToProtobuf(this.input);
17689
17712
  if (inputValue) {
17690
- nodeData.setInput(inputValue);
17713
+ node.setInput(inputValue);
17691
17714
  }
17692
- request.setEthTransfer(nodeData);
17715
+ request.setEthTransfer(node);
17693
17716
  return request;
17694
17717
  }
17695
17718
  static fromOutputData(outputData) {
@@ -17702,7 +17725,7 @@ var ethTransfer_default = ETHTransferNode2;
17702
17725
  // src/models/node/branch.ts
17703
17726
  import { NodeType as NodeType9 } from "@avaprotocol/types";
17704
17727
  var avs_pb15 = __toESM(require_avs_pb());
17705
- var BranchNode2 = class _BranchNode extends interface_default2 {
17728
+ var BranchNode2 = class _BranchNode extends Node {
17706
17729
  constructor(props) {
17707
17730
  super({ ...props, type: NodeType9.Branch, data: props.data });
17708
17731
  }
@@ -17728,7 +17751,7 @@ var BranchNode2 = class _BranchNode extends interface_default2 {
17728
17751
  const request = new avs_pb15.TaskNode();
17729
17752
  request.setId(this.id);
17730
17753
  request.setName(this.name);
17731
- const nodeData = new avs_pb15.BranchNode();
17754
+ const node = new avs_pb15.BranchNode();
17732
17755
  const config = new avs_pb15.BranchNode.Config();
17733
17756
  if (this.data.conditions && this.data.conditions.length > 0) {
17734
17757
  const conditionsList = this.data.conditions.map(
@@ -17742,12 +17765,12 @@ var BranchNode2 = class _BranchNode extends interface_default2 {
17742
17765
  );
17743
17766
  config.setConditionsList(conditionsList);
17744
17767
  }
17745
- nodeData.setConfig(config);
17768
+ node.setConfig(config);
17746
17769
  const inputValue = convertInputToProtobuf(this.input);
17747
17770
  if (inputValue) {
17748
- nodeData.setInput(inputValue);
17771
+ node.setInput(inputValue);
17749
17772
  }
17750
- request.setBranch(nodeData);
17773
+ request.setBranch(node);
17751
17774
  return request;
17752
17775
  }
17753
17776
  static fromOutputData(outputData) {
@@ -17761,7 +17784,7 @@ var branch_default = BranchNode2;
17761
17784
  // src/models/node/filter.ts
17762
17785
  var avs_pb16 = __toESM(require_avs_pb());
17763
17786
  import { NodeType as NodeType10 } from "@avaprotocol/types";
17764
- var FilterNode2 = class _FilterNode extends interface_default2 {
17787
+ var FilterNode2 = class _FilterNode extends Node {
17765
17788
  constructor(props) {
17766
17789
  super({ ...props, type: NodeType10.Filter, data: props.data });
17767
17790
  }
@@ -17779,16 +17802,16 @@ var FilterNode2 = class _FilterNode extends interface_default2 {
17779
17802
  const request = new avs_pb16.TaskNode();
17780
17803
  request.setId(this.id);
17781
17804
  request.setName(this.name);
17782
- const nodeData = new avs_pb16.FilterNode();
17805
+ const node = new avs_pb16.FilterNode();
17783
17806
  const config = new avs_pb16.FilterNode.Config();
17784
17807
  config.setExpression(this.data.expression);
17785
17808
  config.setSourceId(this.data.sourceId || "");
17786
- nodeData.setConfig(config);
17809
+ node.setConfig(config);
17787
17810
  const inputValue = convertInputToProtobuf(this.input);
17788
17811
  if (inputValue) {
17789
- nodeData.setInput(inputValue);
17812
+ node.setInput(inputValue);
17790
17813
  }
17791
- request.setFilter(nodeData);
17814
+ request.setFilter(node);
17792
17815
  return request;
17793
17816
  }
17794
17817
  static fromOutputData(outputData) {
@@ -17803,7 +17826,7 @@ var avs_pb17 = __toESM(require_avs_pb());
17803
17826
  import {
17804
17827
  NodeType as NodeType11
17805
17828
  } from "@avaprotocol/types";
17806
- var LoopNode2 = class _LoopNode extends interface_default2 {
17829
+ var LoopNode2 = class _LoopNode extends Node {
17807
17830
  constructor(props) {
17808
17831
  super({ ...props, type: NodeType11.Loop, data: props.data });
17809
17832
  }
@@ -18196,7 +18219,6 @@ var workflow_default = Workflow;
18196
18219
 
18197
18220
  // src/models/step.ts
18198
18221
  var avs_pb20 = __toESM(require_avs_pb());
18199
- import { Value as ProtobufValue2 } from "google-protobuf/google/protobuf/struct_pb";
18200
18222
  var Step = class _Step {
18201
18223
  constructor(props) {
18202
18224
  this.id = props.id;
@@ -18231,222 +18253,261 @@ var Step = class _Step {
18231
18253
  };
18232
18254
  }
18233
18255
  static getOutput(step) {
18234
- const outputDataType = step.getOutputDataCase();
18235
- let nodeOutputMessage;
18236
- switch (outputDataType) {
18256
+ const getOutputDataCase = () => {
18257
+ if (typeof step.getOutputDataCase === "function") {
18258
+ return step.getOutputDataCase();
18259
+ }
18260
+ const stepObj = step;
18261
+ if (stepObj.blockTrigger)
18262
+ return avs_pb20.Execution.Step.OutputDataCase.BLOCK_TRIGGER;
18263
+ if (stepObj.fixedTimeTrigger)
18264
+ return avs_pb20.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER;
18265
+ if (stepObj.cronTrigger)
18266
+ return avs_pb20.Execution.Step.OutputDataCase.CRON_TRIGGER;
18267
+ if (stepObj.eventTrigger)
18268
+ return avs_pb20.Execution.Step.OutputDataCase.EVENT_TRIGGER;
18269
+ if (stepObj.manualTrigger)
18270
+ return avs_pb20.Execution.Step.OutputDataCase.MANUAL_TRIGGER;
18271
+ if (stepObj.ethTransfer)
18272
+ return avs_pb20.Execution.Step.OutputDataCase.ETH_TRANSFER;
18273
+ if (stepObj.graphql) return avs_pb20.Execution.Step.OutputDataCase.GRAPHQL;
18274
+ if (stepObj.contractRead)
18275
+ return avs_pb20.Execution.Step.OutputDataCase.CONTRACT_READ;
18276
+ if (stepObj.contractWrite)
18277
+ return avs_pb20.Execution.Step.OutputDataCase.CONTRACT_WRITE;
18278
+ if (stepObj.customCode)
18279
+ return avs_pb20.Execution.Step.OutputDataCase.CUSTOM_CODE;
18280
+ if (stepObj.restApi) return avs_pb20.Execution.Step.OutputDataCase.REST_API;
18281
+ if (stepObj.branch) return avs_pb20.Execution.Step.OutputDataCase.BRANCH;
18282
+ if (stepObj.filter) return avs_pb20.Execution.Step.OutputDataCase.FILTER;
18283
+ if (stepObj.loop) return avs_pb20.Execution.Step.OutputDataCase.LOOP;
18284
+ return avs_pb20.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET;
18285
+ };
18286
+ switch (getOutputDataCase()) {
18237
18287
  case avs_pb20.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET:
18238
18288
  return void 0;
18239
18289
  // Trigger outputs
18240
18290
  case avs_pb20.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
18241
- const blockOutput = step.getBlockTrigger()?.toObject();
18242
- return blockOutput ? { blockNumber: blockOutput.blockNumber } : void 0;
18291
+ return typeof step.getBlockTrigger === "function" ? step.getBlockTrigger()?.toObject() : step.blockTrigger;
18243
18292
  case avs_pb20.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
18244
- const fixedTimeOutput = step.getFixedTimeTrigger()?.toObject();
18245
- return fixedTimeOutput ? {
18246
- timestamp: fixedTimeOutput.timestamp,
18247
- timestampIso: fixedTimeOutput.timestampIso
18248
- } : void 0;
18293
+ return typeof step.getFixedTimeTrigger === "function" ? step.getFixedTimeTrigger()?.toObject() : step.fixedTimeTrigger;
18249
18294
  case avs_pb20.Execution.Step.OutputDataCase.CRON_TRIGGER:
18250
- const cronOutput = step.getCronTrigger()?.toObject();
18251
- return cronOutput ? {
18252
- timestamp: cronOutput.timestamp,
18253
- timestampIso: cronOutput.timestampIso
18254
- } : void 0;
18295
+ return typeof step.getCronTrigger === "function" ? step.getCronTrigger()?.toObject() : step.cronTrigger;
18255
18296
  case avs_pb20.Execution.Step.OutputDataCase.EVENT_TRIGGER:
18256
- const eventTrigger = step.getEventTrigger();
18297
+ const eventTrigger = typeof step.getEventTrigger === "function" ? step.getEventTrigger() : step.eventTrigger;
18257
18298
  if (eventTrigger) {
18258
- if (eventTrigger.hasEvmLog()) {
18299
+ if (typeof eventTrigger.hasEvmLog === "function" && eventTrigger.hasEvmLog()) {
18259
18300
  return eventTrigger.getEvmLog()?.toObject();
18260
- } else if (eventTrigger.hasTransferLog()) {
18301
+ } else if (typeof eventTrigger.hasTransferLog === "function" && eventTrigger.hasTransferLog()) {
18261
18302
  return eventTrigger.getTransferLog()?.toObject();
18303
+ } else if (eventTrigger.evmLog) {
18304
+ return eventTrigger.evmLog;
18305
+ } else if (eventTrigger.transferLog) {
18306
+ return eventTrigger.transferLog;
18262
18307
  }
18263
18308
  }
18264
18309
  return void 0;
18265
18310
  case avs_pb20.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
18266
- const manualOutput = step.getManualTrigger()?.toObject();
18267
- return manualOutput || void 0;
18268
- // Node outputs
18311
+ return typeof step.getManualTrigger === "function" ? step.getManualTrigger()?.toObject() || void 0 : step.manualTrigger;
18312
+ // Node outputs - RESTORE MISSING CASES
18269
18313
  case avs_pb20.Execution.Step.OutputDataCase.ETH_TRANSFER:
18270
- const ethTransferOutput = step.getEthTransfer()?.toObject();
18271
- return ethTransferOutput ? {
18272
- transactionHash: ethTransferOutput.transactionHash
18273
- } : void 0;
18314
+ return typeof step.getEthTransfer === "function" ? step.getEthTransfer()?.toObject() : step.ethTransfer;
18315
+ case avs_pb20.Execution.Step.OutputDataCase.CUSTOM_CODE:
18316
+ const customCodeOutput = typeof step.getCustomCode === "function" ? step.getCustomCode() : step.customCode;
18317
+ if (customCodeOutput) {
18318
+ if (typeof customCodeOutput.hasData === "function" && customCodeOutput.hasData()) {
18319
+ try {
18320
+ return convertProtobufValueToJs(customCodeOutput.getData());
18321
+ } catch {
18322
+ return customCodeOutput.getData();
18323
+ }
18324
+ } else if (customCodeOutput.data) {
18325
+ return typeof customCodeOutput.data.getKindCase === "function" ? convertProtobufValueToJs(customCodeOutput.data) : customCodeOutput.data;
18326
+ }
18327
+ }
18328
+ return void 0;
18329
+ case avs_pb20.Execution.Step.OutputDataCase.REST_API:
18330
+ const restApiOutput = typeof step.getRestApi === "function" ? step.getRestApi() : step.restApi;
18331
+ if (restApiOutput) {
18332
+ if (typeof restApiOutput.hasData === "function" && restApiOutput.hasData()) {
18333
+ try {
18334
+ return convertProtobufValueToJs(restApiOutput.getData());
18335
+ } catch {
18336
+ return restApiOutput.getData();
18337
+ }
18338
+ } else if (restApiOutput.data) {
18339
+ return typeof restApiOutput.data.getKindCase === "function" ? convertProtobufValueToJs(restApiOutput.data) : restApiOutput.data;
18340
+ }
18341
+ }
18342
+ return void 0;
18343
+ case avs_pb20.Execution.Step.OutputDataCase.BRANCH:
18344
+ return typeof step.getBranch === "function" ? step.getBranch()?.toObject() : step.branch;
18345
+ case avs_pb20.Execution.Step.OutputDataCase.LOOP:
18346
+ const loopOutput = typeof step.getLoop === "function" ? step.getLoop() : step.loop;
18347
+ if (loopOutput) {
18348
+ if (typeof loopOutput.getData === "function" && loopOutput.getData()) {
18349
+ try {
18350
+ return JSON.parse(loopOutput.getData());
18351
+ } catch {
18352
+ return loopOutput.getData();
18353
+ }
18354
+ } else if (loopOutput.data) {
18355
+ try {
18356
+ return typeof loopOutput.data === "string" ? JSON.parse(loopOutput.data) : loopOutput.data;
18357
+ } catch {
18358
+ return loopOutput.data;
18359
+ }
18360
+ }
18361
+ }
18362
+ return void 0;
18274
18363
  case avs_pb20.Execution.Step.OutputDataCase.GRAPHQL:
18275
- nodeOutputMessage = step.getGraphql();
18276
- return nodeOutputMessage && nodeOutputMessage.hasData() ? nodeOutputMessage.getData() : void 0;
18364
+ const graphqlOutput = typeof step.getGraphql === "function" ? step.getGraphql() : step.graphql;
18365
+ if (graphqlOutput) {
18366
+ try {
18367
+ return typeof graphqlOutput.toObject === "function" ? graphqlOutput.toObject() : graphqlOutput;
18368
+ } catch {
18369
+ return void 0;
18370
+ }
18371
+ }
18372
+ return void 0;
18277
18373
  case avs_pb20.Execution.Step.OutputDataCase.CONTRACT_READ:
18278
- nodeOutputMessage = step.getContractRead();
18279
- if (nodeOutputMessage) {
18280
- const results = nodeOutputMessage.getResultsList();
18281
- if (results && results.length > 0) {
18282
- const resultArray = results.map((result) => {
18283
- const dataFields = result.getDataList().map((field) => ({
18284
- name: field.getName(),
18285
- type: field.getType(),
18286
- value: field.getValue()
18287
- }));
18288
- return {
18289
- methodName: result.getMethodName(),
18290
- success: result.getSuccess(),
18291
- error: result.getError(),
18292
- data: dataFields
18293
- };
18294
- });
18295
- return { results: resultArray };
18374
+ const contractReadOutput = typeof step.getContractRead === "function" ? step.getContractRead() : step.contractRead;
18375
+ if (contractReadOutput) {
18376
+ const outputObj = typeof contractReadOutput.toObject === "function" ? contractReadOutput.toObject() : contractReadOutput;
18377
+ if (outputObj && outputObj.resultsList) {
18378
+ return {
18379
+ ...outputObj,
18380
+ results: outputObj.resultsList.map((result) => ({
18381
+ methodName: result.methodName,
18382
+ success: result.success,
18383
+ error: result.error,
18384
+ data: result.dataList || []
18385
+ }))
18386
+ };
18296
18387
  }
18388
+ return outputObj;
18297
18389
  }
18298
18390
  return void 0;
18299
18391
  case avs_pb20.Execution.Step.OutputDataCase.CONTRACT_WRITE:
18300
- nodeOutputMessage = step.getContractWrite();
18301
- if (nodeOutputMessage) {
18302
- const results = nodeOutputMessage.getResultsList();
18303
- if (results && results.length > 0) {
18304
- const transformedResults = results.map((result) => ({
18305
- methodName: result.getMethodName(),
18306
- success: result.getSuccess(),
18307
- transaction: result.getTransaction() ? {
18308
- hash: result.getTransaction()?.getHash(),
18309
- status: result.getTransaction()?.getStatus(),
18310
- blockNumber: result.getTransaction()?.getBlockNumber(),
18311
- blockHash: result.getTransaction()?.getBlockHash(),
18312
- gasUsed: result.getTransaction()?.getGasUsed(),
18313
- gasLimit: result.getTransaction()?.getGasLimit(),
18314
- gasPrice: result.getTransaction()?.getGasPrice(),
18315
- effectiveGasPrice: result.getTransaction()?.getEffectiveGasPrice(),
18316
- from: result.getTransaction()?.getFrom(),
18317
- to: result.getTransaction()?.getTo(),
18318
- value: result.getTransaction()?.getValue(),
18319
- nonce: result.getTransaction()?.getNonce(),
18320
- transactionIndex: result.getTransaction()?.getTransactionIndex(),
18321
- confirmations: result.getTransaction()?.getConfirmations(),
18322
- timestamp: result.getTransaction()?.getTimestamp()
18392
+ const contractWriteOutput = typeof step.getContractWrite === "function" ? step.getContractWrite() : step.contractWrite;
18393
+ if (contractWriteOutput) {
18394
+ const outputObj = typeof contractWriteOutput.toObject === "function" ? contractWriteOutput.toObject() : contractWriteOutput;
18395
+ if (outputObj && outputObj.resultsList) {
18396
+ const transformedResults = outputObj.resultsList.map((result) => ({
18397
+ methodName: result.methodName,
18398
+ success: result.success,
18399
+ transaction: result.transaction ? {
18400
+ hash: result.transaction.hash,
18401
+ status: result.transaction.status,
18402
+ blockNumber: result.transaction.blockNumber,
18403
+ blockHash: result.transaction.blockHash,
18404
+ gasUsed: result.transaction.gasUsed,
18405
+ gasLimit: result.transaction.gasLimit,
18406
+ gasPrice: result.transaction.gasPrice,
18407
+ effectiveGasPrice: result.transaction.effectiveGasPrice,
18408
+ from: result.transaction.from,
18409
+ to: result.transaction.to,
18410
+ value: result.transaction.value,
18411
+ nonce: result.transaction.nonce,
18412
+ transactionIndex: result.transaction.transactionIndex,
18413
+ confirmations: result.transaction.confirmations,
18414
+ timestamp: result.transaction.timestamp
18323
18415
  } : null,
18324
- events: result.getEventsList().map((event) => ({
18325
- eventName: event.getEventName(),
18326
- address: event.getAddress(),
18327
- topics: event.getTopicsList(),
18328
- data: event.getData(),
18329
- decoded: event.getDecodedMap() ? Object.fromEntries(event.getDecodedMap().toArray()) : {}
18330
- })),
18331
- error: result.getError() ? {
18332
- code: result.getError()?.getCode(),
18333
- message: result.getError()?.getMessage(),
18334
- revertReason: result.getError()?.getRevertReason()
18416
+ events: result.eventsList?.map((event) => ({
18417
+ eventName: event.eventName,
18418
+ address: event.address,
18419
+ topics: event.topicsList || [],
18420
+ data: event.data,
18421
+ decoded: event.decodedMap || {}
18422
+ })) || [],
18423
+ error: result.error ? {
18424
+ code: result.error.code,
18425
+ message: result.error.message,
18426
+ revertReason: result.error.revertReason
18335
18427
  } : null,
18336
- returnData: result.getReturnData() ? {
18337
- name: result.getReturnData()?.getName(),
18338
- type: result.getReturnData()?.getType(),
18339
- value: result.getReturnData()?.getValue()
18428
+ returnData: result.returnData ? {
18429
+ name: result.returnData.name,
18430
+ type: result.returnData.type,
18431
+ value: result.returnData.value
18340
18432
  } : null,
18341
- inputData: result.getInputData()
18433
+ inputData: result.inputData
18342
18434
  }));
18343
- if (transformedResults.length === 1) {
18344
- return {
18345
- results: transformedResults,
18346
- // Legacy compatibility fields
18435
+ return {
18436
+ ...outputObj,
18437
+ results: transformedResults,
18438
+ // For backward compatibility, provide legacy fields from first result
18439
+ ...transformedResults.length > 0 && {
18347
18440
  transaction: transformedResults[0].transaction,
18348
18441
  success: transformedResults[0].success,
18349
18442
  hash: transformedResults[0].transaction?.hash
18350
- };
18351
- } else {
18352
- return { results: transformedResults };
18353
- }
18443
+ }
18444
+ };
18354
18445
  }
18446
+ return outputObj;
18355
18447
  }
18356
18448
  return void 0;
18357
- case avs_pb20.Execution.Step.OutputDataCase.CUSTOM_CODE:
18358
- nodeOutputMessage = step.getCustomCode();
18359
- return nodeOutputMessage && nodeOutputMessage.hasData() ? convertProtobufValueToJs(nodeOutputMessage.getData()) : void 0;
18360
- case avs_pb20.Execution.Step.OutputDataCase.REST_API:
18361
- nodeOutputMessage = step.getRestApi();
18362
- return nodeOutputMessage && nodeOutputMessage.hasData() ? convertProtobufValueToJs(nodeOutputMessage.getData()) : void 0;
18363
- case avs_pb20.Execution.Step.OutputDataCase.BRANCH:
18364
- return step.getBranch()?.toObject();
18365
18449
  case avs_pb20.Execution.Step.OutputDataCase.FILTER:
18366
- nodeOutputMessage = step.getFilter();
18367
- if (nodeOutputMessage && nodeOutputMessage.hasData()) {
18368
- const rawData = nodeOutputMessage.getData();
18369
- if (rawData) {
18370
- if (typeof rawData.unpack === "function") {
18371
- try {
18372
- const unpackedValue = rawData.unpack(ProtobufValue2.deserializeBinary, "google.protobuf.Value");
18373
- if (unpackedValue) {
18374
- return convertProtobufValueToJs(unpackedValue);
18375
- }
18376
- } catch (error) {
18377
- console.warn("Failed to unpack FilterNode Any wrapper:", error);
18378
- return void 0;
18379
- }
18380
- }
18381
- console.warn("FilterNode output data is not an Any wrapper - this is unexpected");
18450
+ const filterOutput = typeof step.getFilter === "function" ? step.getFilter() : step.filter;
18451
+ if (filterOutput) {
18452
+ try {
18453
+ return typeof filterOutput.toObject === "function" ? filterOutput.toObject() : filterOutput;
18454
+ } catch {
18382
18455
  return void 0;
18383
18456
  }
18384
18457
  }
18385
18458
  return void 0;
18386
- case avs_pb20.Execution.Step.OutputDataCase.LOOP:
18387
- const loopOutput = step.getLoop();
18388
- if (!loopOutput) return void 0;
18389
- const loopData = loopOutput.getData();
18390
- if (!loopData) return void 0;
18391
- try {
18392
- const parsedData = JSON.parse(loopData);
18393
- if (Array.isArray(parsedData)) {
18394
- return parsedData.map((item, index) => {
18395
- if (!item || typeof item !== "object") {
18396
- return item;
18397
- }
18398
- if (item.statusCode !== void 0 && (item.body !== void 0 || item.headers !== void 0)) {
18399
- return item;
18400
- }
18401
- if (item.result !== void 0 || item.output !== void 0 || item.error !== void 0) {
18402
- return item;
18403
- }
18404
- if (item.transactionHash !== void 0) {
18405
- return { transactionHash: item.transactionHash };
18406
- }
18407
- if (item.methodName !== void 0 && item.data !== void 0) {
18408
- return item;
18409
- }
18410
- if (item.data !== void 0 && typeof item.data === "object") {
18411
- return item;
18412
- }
18413
- return item;
18414
- });
18415
- }
18416
- if (parsedData && typeof parsedData === "object") {
18417
- return parsedData;
18418
- }
18419
- return { data: parsedData };
18420
- } catch (e) {
18421
- return { data: loopData };
18422
- }
18423
18459
  default:
18424
18460
  console.warn(
18425
- `Unhandled output data type in Step.getOutput: ${outputDataType}`
18461
+ `Unhandled output data type in Step.getOutput: ${step.getOutputDataCase()}`
18426
18462
  );
18427
18463
  return void 0;
18428
18464
  }
18429
18465
  }
18430
18466
  static fromResponse(step) {
18431
18467
  let inputData = void 0;
18432
- if (step.hasInput()) {
18468
+ if (typeof step.hasInput === "function" && step.hasInput()) {
18433
18469
  const inputValue = step.getInput();
18434
18470
  if (inputValue) {
18435
- inputData = convertProtobufValueToJs(inputValue);
18471
+ try {
18472
+ inputData = convertProtobufValueToJs(inputValue);
18473
+ } catch (error) {
18474
+ console.warn("Failed to convert protobuf input value:", error);
18475
+ inputData = inputValue;
18476
+ }
18477
+ }
18478
+ } else if (step.input) {
18479
+ const inputValue = step.input;
18480
+ if (typeof inputValue === "object" && !inputValue.getKindCase) {
18481
+ inputData = inputValue;
18482
+ } else {
18483
+ try {
18484
+ inputData = convertProtobufValueToJs(inputValue);
18485
+ } catch (error) {
18486
+ inputData = inputValue;
18487
+ }
18436
18488
  }
18437
18489
  }
18490
+ const getId = () => typeof step.getId === "function" ? step.getId() : step.id;
18491
+ const getType = () => typeof step.getType === "function" ? step.getType() : step.type;
18492
+ const getName = () => typeof step.getName === "function" ? step.getName() : step.name;
18493
+ const getSuccess = () => typeof step.getSuccess === "function" ? step.getSuccess() : step.success;
18494
+ const getError = () => typeof step.getError === "function" ? step.getError() : step.error;
18495
+ const getLog = () => typeof step.getLog === "function" ? step.getLog() : step.log;
18496
+ const getInputsList = () => typeof step.getInputsList === "function" ? step.getInputsList() : step.inputsList || [];
18497
+ const getStartAt = () => typeof step.getStartAt === "function" ? step.getStartAt() : step.startAt;
18498
+ const getEndAt = () => typeof step.getEndAt === "function" ? step.getEndAt() : step.endAt;
18438
18499
  return new _Step({
18439
- id: step.getId(),
18440
- type: convertProtobufStepTypeToSdk(step.getType()),
18441
- name: step.getName(),
18442
- success: step.getSuccess(),
18443
- error: step.getError(),
18444
- log: step.getLog(),
18445
- inputsList: step.getInputsList(),
18500
+ id: getId(),
18501
+ type: convertProtobufStepTypeToSdk(getType()),
18502
+ name: getName(),
18503
+ success: getSuccess(),
18504
+ error: getError(),
18505
+ log: getLog(),
18506
+ inputsList: getInputsList(),
18446
18507
  input: inputData,
18447
18508
  output: _Step.getOutput(step),
18448
- startAt: step.getStartAt(),
18449
- endAt: step.getEndAt()
18509
+ startAt: getStartAt(),
18510
+ endAt: getEndAt()
18450
18511
  });
18451
18512
  }
18452
18513
  // Client side does not generate the step, so there's no toRequest() method
@@ -19415,13 +19476,13 @@ export {
19415
19476
  graphqlQuery_default as GraphQLQueryNode,
19416
19477
  loop_default as LoopNode,
19417
19478
  manual_default as ManualTrigger,
19418
- interface_default2 as Node,
19479
+ Node,
19419
19480
  factory_default2 as NodeFactory,
19420
19481
  restApi_default as RestAPINode,
19421
19482
  secret_default as Secret,
19422
19483
  step_default as Step,
19423
19484
  TimeoutPresets2 as TimeoutPresets,
19424
- interface_default as Trigger,
19485
+ Trigger,
19425
19486
  factory_default as TriggerFactory,
19426
19487
  workflow_default as Workflow
19427
19488
  };