@avaprotocol/sdk-js 2.4.4 → 2.5.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
@@ -2947,7 +2947,11 @@ var require_avs_pb = __commonJS({
2947
2947
  return proto.aggregator.ManualTrigger.Config.toObject(opt_includeInstance, this);
2948
2948
  };
2949
2949
  proto.aggregator.ManualTrigger.Config.toObject = function(includeInstance, msg) {
2950
- var f, obj = {};
2950
+ var f, obj = {
2951
+ data: (f = msg.getData()) && google_protobuf_struct_pb2.Value.toObject(includeInstance, f),
2952
+ headersMap: (f = msg.getHeadersMap()) ? f.toObject(includeInstance, void 0) : [],
2953
+ pathparamsMap: (f = msg.getPathparamsMap()) ? f.toObject(includeInstance, void 0) : []
2954
+ };
2951
2955
  if (includeInstance) {
2952
2956
  obj.$jspbMessageInstance = msg;
2953
2957
  }
@@ -2966,6 +2970,23 @@ var require_avs_pb = __commonJS({
2966
2970
  }
2967
2971
  var field = reader.getFieldNumber();
2968
2972
  switch (field) {
2973
+ case 1:
2974
+ var value = new google_protobuf_struct_pb2.Value();
2975
+ reader.readMessage(value, google_protobuf_struct_pb2.Value.deserializeBinaryFromReader);
2976
+ msg.setData(value);
2977
+ break;
2978
+ case 2:
2979
+ var value = msg.getHeadersMap();
2980
+ reader.readMessage(value, function(message, reader2) {
2981
+ jspb.Map.deserializeBinary(message, reader2, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", "");
2982
+ });
2983
+ break;
2984
+ case 3:
2985
+ var value = msg.getPathparamsMap();
2986
+ reader.readMessage(value, function(message, reader2) {
2987
+ jspb.Map.deserializeBinary(message, reader2, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", "");
2988
+ });
2989
+ break;
2969
2990
  default:
2970
2991
  reader.skipField();
2971
2992
  break;
@@ -2980,6 +3001,67 @@ var require_avs_pb = __commonJS({
2980
3001
  };
2981
3002
  proto.aggregator.ManualTrigger.Config.serializeBinaryToWriter = function(message, writer) {
2982
3003
  var f = void 0;
3004
+ f = message.getData();
3005
+ if (f != null) {
3006
+ writer.writeMessage(
3007
+ 1,
3008
+ f,
3009
+ google_protobuf_struct_pb2.Value.serializeBinaryToWriter
3010
+ );
3011
+ }
3012
+ f = message.getHeadersMap(true);
3013
+ if (f && f.getLength() > 0) {
3014
+ f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString);
3015
+ }
3016
+ f = message.getPathparamsMap(true);
3017
+ if (f && f.getLength() > 0) {
3018
+ f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString);
3019
+ }
3020
+ };
3021
+ proto.aggregator.ManualTrigger.Config.prototype.getData = function() {
3022
+ return (
3023
+ /** @type{?proto.google.protobuf.Value} */
3024
+ jspb.Message.getWrapperField(this, google_protobuf_struct_pb2.Value, 1)
3025
+ );
3026
+ };
3027
+ proto.aggregator.ManualTrigger.Config.prototype.setData = function(value) {
3028
+ return jspb.Message.setWrapperField(this, 1, value);
3029
+ };
3030
+ proto.aggregator.ManualTrigger.Config.prototype.clearData = function() {
3031
+ return this.setData(void 0);
3032
+ };
3033
+ proto.aggregator.ManualTrigger.Config.prototype.hasData = function() {
3034
+ return jspb.Message.getField(this, 1) != null;
3035
+ };
3036
+ proto.aggregator.ManualTrigger.Config.prototype.getHeadersMap = function(opt_noLazyCreate) {
3037
+ return (
3038
+ /** @type {!jspb.Map<string,string>} */
3039
+ jspb.Message.getMapField(
3040
+ this,
3041
+ 2,
3042
+ opt_noLazyCreate,
3043
+ null
3044
+ )
3045
+ );
3046
+ };
3047
+ proto.aggregator.ManualTrigger.Config.prototype.clearHeadersMap = function() {
3048
+ this.getHeadersMap().clear();
3049
+ return this;
3050
+ };
3051
+ proto.aggregator.ManualTrigger.Config.prototype.getPathparamsMap = function(opt_noLazyCreate) {
3052
+ return (
3053
+ /** @type {!jspb.Map<string,string>} */
3054
+ jspb.Message.getMapField(
3055
+ this,
3056
+ 3,
3057
+ opt_noLazyCreate,
3058
+ null
3059
+ )
3060
+ );
3061
+ };
3062
+ proto.aggregator.ManualTrigger.Config.prototype.clearPathparamsMap = function() {
3063
+ this.getPathparamsMap().clear();
3064
+ return this;
2983
3065
  };
2984
3066
  if (jspb.Message.GENERATE_TO_OBJECT) {
2985
3067
  proto.aggregator.ManualTrigger.Output.prototype.toObject = function(opt_includeInstance) {
@@ -2987,7 +3069,9 @@ var require_avs_pb = __commonJS({
2987
3069
  };
2988
3070
  proto.aggregator.ManualTrigger.Output.toObject = function(includeInstance, msg) {
2989
3071
  var f, obj = {
2990
- runAt: jspb.Message.getFieldWithDefault(msg, 1, 0)
3072
+ data: (f = msg.getData()) && google_protobuf_struct_pb2.Value.toObject(includeInstance, f),
3073
+ headersMap: (f = msg.getHeadersMap()) ? f.toObject(includeInstance, void 0) : [],
3074
+ pathparamsMap: (f = msg.getPathparamsMap()) ? f.toObject(includeInstance, void 0) : []
2991
3075
  };
2992
3076
  if (includeInstance) {
2993
3077
  obj.$jspbMessageInstance = msg;
@@ -3008,11 +3092,21 @@ var require_avs_pb = __commonJS({
3008
3092
  var field = reader.getFieldNumber();
3009
3093
  switch (field) {
3010
3094
  case 1:
3011
- var value = (
3012
- /** @type {number} */
3013
- reader.readUint64()
3014
- );
3015
- msg.setRunAt(value);
3095
+ var value = new google_protobuf_struct_pb2.Value();
3096
+ reader.readMessage(value, google_protobuf_struct_pb2.Value.deserializeBinaryFromReader);
3097
+ msg.setData(value);
3098
+ break;
3099
+ case 2:
3100
+ var value = msg.getHeadersMap();
3101
+ reader.readMessage(value, function(message, reader2) {
3102
+ jspb.Map.deserializeBinary(message, reader2, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", "");
3103
+ });
3104
+ break;
3105
+ case 3:
3106
+ var value = msg.getPathparamsMap();
3107
+ reader.readMessage(value, function(message, reader2) {
3108
+ jspb.Map.deserializeBinary(message, reader2, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", "");
3109
+ });
3016
3110
  break;
3017
3111
  default:
3018
3112
  reader.skipField();
@@ -3028,22 +3122,67 @@ var require_avs_pb = __commonJS({
3028
3122
  };
3029
3123
  proto.aggregator.ManualTrigger.Output.serializeBinaryToWriter = function(message, writer) {
3030
3124
  var f = void 0;
3031
- f = message.getRunAt();
3032
- if (f !== 0) {
3033
- writer.writeUint64(
3125
+ f = message.getData();
3126
+ if (f != null) {
3127
+ writer.writeMessage(
3034
3128
  1,
3035
- f
3129
+ f,
3130
+ google_protobuf_struct_pb2.Value.serializeBinaryToWriter
3036
3131
  );
3037
3132
  }
3133
+ f = message.getHeadersMap(true);
3134
+ if (f && f.getLength() > 0) {
3135
+ f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString);
3136
+ }
3137
+ f = message.getPathparamsMap(true);
3138
+ if (f && f.getLength() > 0) {
3139
+ f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString);
3140
+ }
3038
3141
  };
3039
- proto.aggregator.ManualTrigger.Output.prototype.getRunAt = function() {
3142
+ proto.aggregator.ManualTrigger.Output.prototype.getData = function() {
3040
3143
  return (
3041
- /** @type {number} */
3042
- jspb.Message.getFieldWithDefault(this, 1, 0)
3144
+ /** @type{?proto.google.protobuf.Value} */
3145
+ jspb.Message.getWrapperField(this, google_protobuf_struct_pb2.Value, 1)
3043
3146
  );
3044
3147
  };
3045
- proto.aggregator.ManualTrigger.Output.prototype.setRunAt = function(value) {
3046
- return jspb.Message.setProto3IntField(this, 1, value);
3148
+ proto.aggregator.ManualTrigger.Output.prototype.setData = function(value) {
3149
+ return jspb.Message.setWrapperField(this, 1, value);
3150
+ };
3151
+ proto.aggregator.ManualTrigger.Output.prototype.clearData = function() {
3152
+ return this.setData(void 0);
3153
+ };
3154
+ proto.aggregator.ManualTrigger.Output.prototype.hasData = function() {
3155
+ return jspb.Message.getField(this, 1) != null;
3156
+ };
3157
+ proto.aggregator.ManualTrigger.Output.prototype.getHeadersMap = function(opt_noLazyCreate) {
3158
+ return (
3159
+ /** @type {!jspb.Map<string,string>} */
3160
+ jspb.Message.getMapField(
3161
+ this,
3162
+ 2,
3163
+ opt_noLazyCreate,
3164
+ null
3165
+ )
3166
+ );
3167
+ };
3168
+ proto.aggregator.ManualTrigger.Output.prototype.clearHeadersMap = function() {
3169
+ this.getHeadersMap().clear();
3170
+ return this;
3171
+ };
3172
+ proto.aggregator.ManualTrigger.Output.prototype.getPathparamsMap = function(opt_noLazyCreate) {
3173
+ return (
3174
+ /** @type {!jspb.Map<string,string>} */
3175
+ jspb.Message.getMapField(
3176
+ this,
3177
+ 3,
3178
+ opt_noLazyCreate,
3179
+ null
3180
+ )
3181
+ );
3182
+ };
3183
+ proto.aggregator.ManualTrigger.Output.prototype.clearPathparamsMap = function() {
3184
+ this.getPathparamsMap().clear();
3185
+ return this;
3047
3186
  };
3048
3187
  proto.aggregator.ManualTrigger.prototype.getConfig = function() {
3049
3188
  return (
@@ -3098,7 +3237,7 @@ var require_avs_pb = __commonJS({
3098
3237
  var f, obj = {
3099
3238
  name: jspb.Message.getFieldWithDefault(msg, 1, ""),
3100
3239
  type: jspb.Message.getFieldWithDefault(msg, 8, 0),
3101
- manual: jspb.Message.getBooleanFieldWithDefault(msg, 2, false),
3240
+ manual: (f = msg.getManual()) && proto.aggregator.ManualTrigger.toObject(includeInstance, f),
3102
3241
  fixedTime: (f = msg.getFixedTime()) && proto.aggregator.FixedTimeTrigger.toObject(includeInstance, f),
3103
3242
  cron: (f = msg.getCron()) && proto.aggregator.CronTrigger.toObject(includeInstance, f),
3104
3243
  block: (f = msg.getBlock()) && proto.aggregator.BlockTrigger.toObject(includeInstance, f),
@@ -3139,10 +3278,8 @@ var require_avs_pb = __commonJS({
3139
3278
  msg.setType(value);
3140
3279
  break;
3141
3280
  case 2:
3142
- var value = (
3143
- /** @type {boolean} */
3144
- reader.readBool()
3145
- );
3281
+ var value = new proto.aggregator.ManualTrigger();
3282
+ reader.readMessage(value, proto.aggregator.ManualTrigger.deserializeBinaryFromReader);
3146
3283
  msg.setManual(value);
3147
3284
  break;
3148
3285
  case 3:
@@ -3205,12 +3342,12 @@ var require_avs_pb = __commonJS({
3205
3342
  f
3206
3343
  );
3207
3344
  }
3208
- f = /** @type {boolean} */
3209
- jspb.Message.getField(message, 2);
3345
+ f = message.getManual();
3210
3346
  if (f != null) {
3211
- writer.writeBool(
3347
+ writer.writeMessage(
3212
3348
  2,
3213
- f
3349
+ f,
3350
+ proto.aggregator.ManualTrigger.serializeBinaryToWriter
3214
3351
  );
3215
3352
  }
3216
3353
  f = message.getFixedTime();
@@ -3281,15 +3418,15 @@ var require_avs_pb = __commonJS({
3281
3418
  };
3282
3419
  proto.aggregator.TaskTrigger.prototype.getManual = function() {
3283
3420
  return (
3284
- /** @type {boolean} */
3285
- jspb.Message.getBooleanFieldWithDefault(this, 2, false)
3421
+ /** @type{?proto.aggregator.ManualTrigger} */
3422
+ jspb.Message.getWrapperField(this, proto.aggregator.ManualTrigger, 2)
3286
3423
  );
3287
3424
  };
3288
3425
  proto.aggregator.TaskTrigger.prototype.setManual = function(value) {
3289
- return jspb.Message.setOneofField(this, 2, proto.aggregator.TaskTrigger.oneofGroups_[0], value);
3426
+ return jspb.Message.setOneofWrapperField(this, 2, proto.aggregator.TaskTrigger.oneofGroups_[0], value);
3290
3427
  };
3291
3428
  proto.aggregator.TaskTrigger.prototype.clearManual = function() {
3292
- return jspb.Message.setOneofField(this, 2, proto.aggregator.TaskTrigger.oneofGroups_[0], void 0);
3429
+ return this.setManual(void 0);
3293
3430
  };
3294
3431
  proto.aggregator.TaskTrigger.prototype.hasManual = function() {
3295
3432
  return jspb.Message.getField(this, 2) != null;
@@ -17288,59 +17425,136 @@ var fixedTime_default = FixedTimeTrigger2;
17288
17425
 
17289
17426
  // src/models/trigger/manual.ts
17290
17427
  var avs_pb6 = __toESM(require_avs_pb());
17291
- import { TriggerType as TriggerType11 } from "@avaprotocol/types";
17292
- var ManualTrigger = class _ManualTrigger extends Trigger {
17428
+ import {
17429
+ TriggerType as TriggerType11
17430
+ } from "@avaprotocol/types";
17431
+ var ManualTrigger2 = class _ManualTrigger extends Trigger {
17293
17432
  constructor(props) {
17294
- super({ ...props, type: TriggerType11.Manual, data: props.data || null });
17433
+ super({
17434
+ ...props,
17435
+ type: TriggerType11.Manual,
17436
+ data: props.data,
17437
+ input: props.input
17438
+ });
17439
+ this.headers = props.headers;
17440
+ this.pathParams = props.pathParams;
17295
17441
  }
17296
17442
  toRequest() {
17297
17443
  const trigger = new avs_pb6.TaskTrigger();
17298
17444
  trigger.setId(this.id);
17299
17445
  trigger.setName(this.name);
17300
17446
  trigger.setType(avs_pb6.TriggerType.TRIGGER_TYPE_MANUAL);
17301
- trigger.setManual(true);
17302
- const inputValue = convertInputToProtobuf(this.input);
17303
- if (inputValue) {
17304
- trigger.setInput(inputValue);
17447
+ const manualTrigger = new avs_pb6.ManualTrigger();
17448
+ const config = new avs_pb6.ManualTrigger.Config();
17449
+ const dataToSend = this.data ?? this.input;
17450
+ if (dataToSend !== null && dataToSend !== void 0) {
17451
+ const inputValue = convertInputToProtobuf(dataToSend);
17452
+ if (inputValue) {
17453
+ config.setData(inputValue);
17454
+ }
17305
17455
  }
17456
+ if (this.headers && Object.keys(this.headers).length > 0) {
17457
+ const headersMap = config.getHeadersMap();
17458
+ Object.entries(this.headers).forEach(([key, value]) => {
17459
+ headersMap.set(key, value);
17460
+ });
17461
+ }
17462
+ if (this.pathParams && Object.keys(this.pathParams).length > 0) {
17463
+ const pathParamsMap = config.getPathparamsMap();
17464
+ Object.entries(this.pathParams).forEach(([key, value]) => {
17465
+ pathParamsMap.set(key, value);
17466
+ });
17467
+ }
17468
+ manualTrigger.setConfig(config);
17469
+ trigger.setManual(manualTrigger);
17306
17470
  return trigger;
17307
17471
  }
17308
17472
  static fromResponse(raw) {
17309
17473
  const obj = raw.toObject();
17310
- let input = void 0;
17311
- if (raw.hasInput()) {
17312
- input = extractInputFromProtobuf(raw.getInput());
17474
+ let data = null;
17475
+ const input = void 0;
17476
+ let headers = void 0;
17477
+ let pathParams = void 0;
17478
+ const manualTrigger = raw.getManual();
17479
+ if (manualTrigger) {
17480
+ const config = manualTrigger.getConfig();
17481
+ if (config) {
17482
+ if (config.hasData()) {
17483
+ data = extractInputFromProtobuf(config.getData());
17484
+ }
17485
+ const headersMapProto = config.getHeadersMap();
17486
+ if (headersMapProto && headersMapProto.getLength() > 0) {
17487
+ headers = {};
17488
+ headersMapProto.forEach((value, key) => {
17489
+ headers[key] = value;
17490
+ });
17491
+ }
17492
+ const pathParamsMapProto = config.getPathparamsMap();
17493
+ if (pathParamsMapProto && pathParamsMapProto.getLength() > 0) {
17494
+ pathParams = {};
17495
+ pathParamsMapProto.forEach((value, key) => {
17496
+ pathParams[key] = value;
17497
+ });
17498
+ }
17499
+ }
17313
17500
  }
17314
17501
  return new _ManualTrigger({
17315
17502
  ...obj,
17316
17503
  type: TriggerType11.Manual,
17317
- data: null,
17318
- // Manual triggers don't have data in the protobuf response
17319
- input
17504
+ data,
17505
+ input,
17506
+ headers,
17507
+ pathParams
17320
17508
  });
17321
17509
  }
17322
17510
  getInputVariables() {
17323
- return this.data;
17324
- }
17325
- /**
17326
- * Convert raw data from runTrigger response to ManualOutput format
17327
- * @param rawData - The raw data from the gRPC response
17328
- * @returns {ManualTriggerOutput | undefined} - The converted data
17329
- */
17330
- getOutput() {
17331
- return this.output;
17511
+ return this.input;
17332
17512
  }
17333
17513
  /**
17334
17514
  * Extract output data from RunTriggerResp for manual triggers
17335
17515
  * @param outputData - The RunTriggerResp containing manual trigger output
17336
- * @returns Plain JavaScript object with manual trigger data
17516
+ * @returns Plain JavaScript object with manual trigger data in standard structure
17337
17517
  */
17338
17518
  static fromOutputData(outputData) {
17339
17519
  const manualOutput = outputData.getManualTrigger();
17340
- return manualOutput?.toObject() || null;
17520
+ if (!manualOutput) {
17521
+ return null;
17522
+ }
17523
+ const result = {};
17524
+ const dataValue = manualOutput.getData();
17525
+ if (dataValue) {
17526
+ try {
17527
+ result.data = convertProtobufValueToJs(dataValue);
17528
+ } catch (error) {
17529
+ console.warn(
17530
+ "Failed to convert manual trigger data from protobuf Value:",
17531
+ error
17532
+ );
17533
+ result.data = dataValue;
17534
+ }
17535
+ } else {
17536
+ result.data = null;
17537
+ }
17538
+ const headersMapProto = manualOutput.getHeadersMap();
17539
+ if (headersMapProto && headersMapProto.getLength() > 0) {
17540
+ const headersObject = {};
17541
+ headersMapProto.forEach((value, key) => {
17542
+ headersObject[key] = value;
17543
+ });
17544
+ result.headers = headersObject;
17545
+ }
17546
+ const pathParamsMapProto = manualOutput.getPathparamsMap();
17547
+ if (pathParamsMapProto && pathParamsMapProto.getLength() > 0) {
17548
+ const pathParamsObject = {};
17549
+ pathParamsMapProto.forEach((value, key) => {
17550
+ pathParamsObject[key] = value;
17551
+ });
17552
+ result.pathParams = pathParamsObject;
17553
+ }
17554
+ return result;
17341
17555
  }
17342
17556
  };
17343
- var manual_default = ManualTrigger;
17557
+ var manual_default = ManualTrigger2;
17344
17558
 
17345
17559
  // src/models/trigger/factory.ts
17346
17560
  import {
@@ -17676,9 +17890,9 @@ var RestAPINode2 = class _RestAPINode extends Node {
17676
17890
  config.setUrl(configData.url);
17677
17891
  config.setMethod(configData.method);
17678
17892
  config.setBody(configData.body || "");
17679
- if (configData.headersMap && configData.headersMap.length > 0) {
17893
+ if (configData.headers && Object.keys(configData.headers).length > 0) {
17680
17894
  const headersMap = config.getHeadersMap();
17681
- configData.headersMap.forEach(([key, value]) => {
17895
+ Object.entries(configData.headers).forEach(([key, value]) => {
17682
17896
  headersMap.set(key, value);
17683
17897
  });
17684
17898
  }
@@ -17694,7 +17908,19 @@ var RestAPINode2 = class _RestAPINode extends Node {
17694
17908
  return new _RestAPINode({
17695
17909
  ...obj,
17696
17910
  type: NodeType6.RestAPI,
17697
- data: raw.getRestApi().getConfig().toObject(),
17911
+ data: {
17912
+ url: raw.getRestApi().getConfig().getUrl(),
17913
+ method: raw.getRestApi().getConfig().getMethod(),
17914
+ body: raw.getRestApi().getConfig().getBody(),
17915
+ headers: (() => {
17916
+ const headersMap = raw.getRestApi().getConfig().getHeadersMap();
17917
+ const headers = {};
17918
+ headersMap.forEach((value, key) => {
17919
+ headers[key] = value;
17920
+ });
17921
+ return headers;
17922
+ })()
17923
+ },
17698
17924
  input
17699
17925
  // Include input data from top-level TaskNode
17700
17926
  });
@@ -17934,7 +18160,10 @@ var branch_default = BranchNode2;
17934
18160
 
17935
18161
  // src/models/node/filter.ts
17936
18162
  var avs_pb16 = __toESM(require_avs_pb());
17937
- import { NodeType as NodeType10 } from "@avaprotocol/types";
18163
+ import {
18164
+ NodeType as NodeType10
18165
+ } from "@avaprotocol/types";
18166
+ import { Value as Value2 } from "google-protobuf/google/protobuf/struct_pb";
17938
18167
  var FilterNode2 = class _FilterNode extends Node {
17939
18168
  constructor(props) {
17940
18169
  super({ ...props, type: NodeType10.Filter, data: props.data });
@@ -17967,7 +18196,21 @@ var FilterNode2 = class _FilterNode extends Node {
17967
18196
  }
17968
18197
  static fromOutputData(outputData) {
17969
18198
  const filterOutput = outputData.getFilter();
17970
- return filterOutput?.toObject() || null;
18199
+ if (!filterOutput) {
18200
+ throw new Error("FilterNode output data is missing");
18201
+ }
18202
+ const anyData = filterOutput.getData();
18203
+ if (!anyData) {
18204
+ throw new Error("FilterNode output data.getData() is missing");
18205
+ }
18206
+ const value = Value2.deserializeBinary(anyData.getValue_asU8());
18207
+ const result = value.toJavaScript();
18208
+ if (result && typeof result === "object" && !Array.isArray(result) && result.data) {
18209
+ return result.data;
18210
+ }
18211
+ throw new Error(
18212
+ "FilterNode output data does not contain expected data structure"
18213
+ );
17971
18214
  }
17972
18215
  };
17973
18216
  var filter_default = FilterNode2;
@@ -18011,18 +18254,18 @@ var LoopNode2 = class _LoopNode extends Node {
18011
18254
  });
18012
18255
  }
18013
18256
  static extractRunnerFromProtobuf(loopNodeData) {
18014
- if (loopNodeData.restApi) {
18015
- return { type: "restApi", data: loopNodeData.restApi };
18016
- } else if (loopNodeData.customCode) {
18017
- return { type: "customCode", data: loopNodeData.customCode };
18018
- } else if (loopNodeData.ethTransfer) {
18019
- return { type: "ethTransfer", data: loopNodeData.ethTransfer };
18020
- } else if (loopNodeData.contractRead) {
18021
- return { type: "contractRead", data: loopNodeData.contractRead };
18022
- } else if (loopNodeData.contractWrite) {
18023
- return { type: "contractWrite", data: loopNodeData.contractWrite };
18024
- } else if (loopNodeData.graphqlDataQuery) {
18025
- return { type: "graphqlDataQuery", data: loopNodeData.graphqlDataQuery };
18257
+ const runnerMapping = {
18258
+ restApi: "restApi",
18259
+ customCode: "customCode",
18260
+ ethTransfer: "ethTransfer",
18261
+ contractRead: "contractRead",
18262
+ contractWrite: "contractWrite",
18263
+ graphqlDataQuery: "graphqlDataQuery"
18264
+ };
18265
+ for (const [type, key] of Object.entries(runnerMapping)) {
18266
+ if (loopNodeData[key]) {
18267
+ return { type, data: loopNodeData[key] };
18268
+ }
18026
18269
  }
18027
18270
  return null;
18028
18271
  }
@@ -18042,9 +18285,9 @@ var LoopNode2 = class _LoopNode extends Node {
18042
18285
  }
18043
18286
  if (typeof executionMode === "string") {
18044
18287
  switch (executionMode.toLowerCase()) {
18045
- case "parallel":
18288
+ case ExecutionMode.Parallel:
18046
18289
  return 1;
18047
- case "sequential":
18290
+ case ExecutionMode.Sequential:
18048
18291
  default:
18049
18292
  return 0;
18050
18293
  }
@@ -18146,7 +18389,7 @@ var LoopNode2 = class _LoopNode extends Node {
18146
18389
  url: apiConfig.url,
18147
18390
  method: apiConfig.method,
18148
18391
  body: apiConfig.body || "",
18149
- headersMap: apiConfig.headersMap
18392
+ headers: apiConfig.headers
18150
18393
  });
18151
18394
  loopNode.setRestApi(restApi);
18152
18395
  }
@@ -18413,7 +18656,6 @@ var Workflow = class _Workflow {
18413
18656
  if (this.name) {
18414
18657
  request.setName(this.name);
18415
18658
  }
18416
- console.log(`\u{1F4E4} Workflow serialization: ${this.nodes.length} nodes, ${this.edges.length} edges -> protobuf: ${request.getNodesList().length} nodes, ${request.getEdgesList().length} edges`);
18417
18659
  return request;
18418
18660
  }
18419
18661
  /**
@@ -18512,44 +18754,218 @@ var Step = class _Step {
18512
18754
  return void 0;
18513
18755
  // Trigger outputs
18514
18756
  case avs_pb20.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
18515
- return typeof step.getBlockTrigger === "function" ? step.getBlockTrigger()?.toObject() : step.blockTrigger;
18757
+ const blockTrigger = typeof step.getBlockTrigger === "function" ? step.getBlockTrigger()?.toObject() : step.blockTrigger;
18758
+ return { data: blockTrigger };
18759
+ // ✅ Use standard structure
18516
18760
  case avs_pb20.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
18517
- return typeof step.getFixedTimeTrigger === "function" ? step.getFixedTimeTrigger()?.toObject() : step.fixedTimeTrigger;
18761
+ const fixedTimeTrigger = typeof step.getFixedTimeTrigger === "function" ? step.getFixedTimeTrigger()?.toObject() : step.fixedTimeTrigger;
18762
+ return { data: fixedTimeTrigger };
18763
+ // ✅ Use standard structure
18518
18764
  case avs_pb20.Execution.Step.OutputDataCase.CRON_TRIGGER:
18519
- return typeof step.getCronTrigger === "function" ? step.getCronTrigger()?.toObject() : step.cronTrigger;
18765
+ const cronTrigger = typeof step.getCronTrigger === "function" ? step.getCronTrigger()?.toObject() : step.cronTrigger;
18766
+ return { data: cronTrigger };
18767
+ // ✅ Use standard structure
18520
18768
  case avs_pb20.Execution.Step.OutputDataCase.EVENT_TRIGGER:
18521
18769
  const eventTrigger = typeof step.getEventTrigger === "function" ? step.getEventTrigger() : step.eventTrigger;
18522
18770
  if (eventTrigger) {
18523
18771
  if (typeof eventTrigger.hasData === "function" && eventTrigger.hasData()) {
18524
18772
  try {
18525
- return convertProtobufValueToJs(eventTrigger.getData());
18773
+ const eventData = convertProtobufValueToJs(
18774
+ eventTrigger.getData()
18775
+ );
18776
+ return { data: eventData };
18526
18777
  } catch (error) {
18527
18778
  console.warn(
18528
18779
  "Failed to convert event trigger data from protobuf Value:",
18529
18780
  error
18530
18781
  );
18531
- return eventTrigger.getData();
18782
+ return { data: eventTrigger.getData() };
18532
18783
  }
18533
18784
  } else if (eventTrigger.data) {
18534
- return typeof eventTrigger.data.getKindCase === "function" ? convertProtobufValueToJs(eventTrigger.data) : eventTrigger.data;
18785
+ const eventData = typeof eventTrigger.data.getKindCase === "function" ? convertProtobufValueToJs(eventTrigger.data) : eventTrigger.data;
18786
+ return { data: eventData };
18535
18787
  }
18536
18788
  if (typeof eventTrigger.hasEvmLog === "function" && eventTrigger.hasEvmLog()) {
18537
- return eventTrigger.getEvmLog()?.toObject();
18789
+ return { data: eventTrigger.getEvmLog()?.toObject() };
18538
18790
  } else if (typeof eventTrigger.hasTransferLog === "function" && eventTrigger.hasTransferLog()) {
18539
- return eventTrigger.getTransferLog()?.toObject();
18791
+ return { data: eventTrigger.getTransferLog()?.toObject() };
18540
18792
  } else if (eventTrigger.evmLog) {
18541
- return eventTrigger.evmLog;
18793
+ return { data: eventTrigger.evmLog };
18542
18794
  } else if (eventTrigger.transferLog) {
18543
- return eventTrigger.transferLog;
18795
+ return { data: eventTrigger.transferLog };
18544
18796
  }
18545
18797
  }
18546
- return void 0;
18547
- case avs_pb20.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
18548
- return typeof step.getManualTrigger === "function" ? step.getManualTrigger()?.toObject() || void 0 : step.manualTrigger;
18798
+ return { data: null };
18799
+ // ✅ Use standard structure
18800
+ case avs_pb20.Execution.Step.OutputDataCase.MANUAL_TRIGGER: {
18801
+ const manualTrigger = typeof step.getManualTrigger === "function" ? step.getManualTrigger() : step.manualTrigger;
18802
+ if (manualTrigger) {
18803
+ const result = {};
18804
+ if (typeof manualTrigger.hasData === "function" && manualTrigger.hasData()) {
18805
+ try {
18806
+ const userData = convertProtobufValueToJs(
18807
+ manualTrigger.getData()
18808
+ );
18809
+ if (userData && typeof userData === "object" && userData.data !== void 0 && (userData.headers !== void 0 || userData.pathParams !== void 0)) {
18810
+ result.data = userData.data;
18811
+ if (userData.headers) {
18812
+ if (Array.isArray(userData.headers)) {
18813
+ if (userData.headers.length > 0 && Array.isArray(userData.headers[0])) {
18814
+ const headersObject = {};
18815
+ for (const [key, value] of userData.headers) {
18816
+ headersObject[key] = value;
18817
+ }
18818
+ result.headers = headersObject;
18819
+ } else {
18820
+ const headersObject = {};
18821
+ for (const header of userData.headers) {
18822
+ for (const [key, value] of Object.entries(header)) {
18823
+ headersObject[key] = value;
18824
+ }
18825
+ }
18826
+ result.headers = headersObject;
18827
+ }
18828
+ } else {
18829
+ result.headers = userData.headers;
18830
+ }
18831
+ }
18832
+ if (userData.pathParams) {
18833
+ if (Array.isArray(userData.pathParams)) {
18834
+ if (userData.pathParams.length > 0 && Array.isArray(userData.pathParams[0])) {
18835
+ const pathParamsObject = {};
18836
+ for (const [key, value] of userData.pathParams) {
18837
+ pathParamsObject[key] = value;
18838
+ }
18839
+ result.pathParams = pathParamsObject;
18840
+ } else {
18841
+ const pathParamsObject = {};
18842
+ for (const pathParam of userData.pathParams) {
18843
+ for (const [key, value] of Object.entries(pathParam)) {
18844
+ pathParamsObject[key] = value;
18845
+ }
18846
+ }
18847
+ result.pathParams = pathParamsObject;
18848
+ }
18849
+ } else {
18850
+ result.pathParams = userData.pathParams;
18851
+ }
18852
+ }
18853
+ } else {
18854
+ result.data = userData;
18855
+ }
18856
+ } catch (error) {
18857
+ console.warn(
18858
+ "Failed to convert manual trigger data from protobuf Value:",
18859
+ error
18860
+ );
18861
+ result.data = manualTrigger.getData();
18862
+ }
18863
+ } else if (manualTrigger.data) {
18864
+ const userData = typeof manualTrigger.data.getKindCase === "function" ? convertProtobufValueToJs(manualTrigger.data) : manualTrigger.data;
18865
+ if (userData && typeof userData === "object" && userData.data !== void 0 && (userData.headers !== void 0 || userData.pathParams !== void 0)) {
18866
+ result.data = userData.data;
18867
+ if (userData.headers) {
18868
+ if (Array.isArray(userData.headers)) {
18869
+ if (userData.headers.length > 0 && Array.isArray(userData.headers[0])) {
18870
+ const headersObject = {};
18871
+ for (const [key, value] of userData.headers) {
18872
+ headersObject[key] = value;
18873
+ }
18874
+ result.headers = headersObject;
18875
+ } else {
18876
+ const headersObject = {};
18877
+ for (const header of userData.headers) {
18878
+ for (const [key, value] of Object.entries(header)) {
18879
+ headersObject[key] = value;
18880
+ }
18881
+ }
18882
+ result.headers = headersObject;
18883
+ }
18884
+ } else {
18885
+ result.headers = userData.headers;
18886
+ }
18887
+ }
18888
+ if (userData.pathParams) {
18889
+ if (Array.isArray(userData.pathParams)) {
18890
+ if (userData.pathParams.length > 0 && Array.isArray(userData.pathParams[0])) {
18891
+ const pathParamsObject = {};
18892
+ for (const [key, value] of userData.pathParams) {
18893
+ pathParamsObject[key] = value;
18894
+ }
18895
+ result.pathParams = pathParamsObject;
18896
+ } else {
18897
+ const pathParamsObject = {};
18898
+ for (const pathParam of userData.pathParams) {
18899
+ for (const [key, value] of Object.entries(pathParam)) {
18900
+ pathParamsObject[key] = value;
18901
+ }
18902
+ }
18903
+ result.pathParams = pathParamsObject;
18904
+ }
18905
+ } else {
18906
+ result.pathParams = userData.pathParams;
18907
+ }
18908
+ }
18909
+ } else {
18910
+ result.data = userData;
18911
+ }
18912
+ }
18913
+ if (typeof manualTrigger.getHeadersMap === "function") {
18914
+ const headersMap = manualTrigger.getHeadersMap();
18915
+ if (headersMap && headersMap.getLength() > 0) {
18916
+ const headersObject = {};
18917
+ headersMap.forEach((value, key) => {
18918
+ headersObject[key] = value;
18919
+ });
18920
+ result.headers = headersObject;
18921
+ }
18922
+ } else if (manualTrigger.headers) {
18923
+ if (Array.isArray(manualTrigger.headers)) {
18924
+ const headersObject = {};
18925
+ for (const [key, value] of Object.entries(manualTrigger.headers)) {
18926
+ headersObject[key] = value;
18927
+ }
18928
+ result.headers = headersObject;
18929
+ } else {
18930
+ result.headers = manualTrigger.headers;
18931
+ }
18932
+ }
18933
+ if (typeof manualTrigger.getPathparamsMap === "function") {
18934
+ const pathParamsMap = manualTrigger.getPathparamsMap();
18935
+ if (pathParamsMap && pathParamsMap.getLength() > 0) {
18936
+ const pathParamsObject = {};
18937
+ pathParamsMap.forEach((value, key) => {
18938
+ pathParamsObject[key] = value;
18939
+ });
18940
+ result.pathParams = pathParamsObject;
18941
+ }
18942
+ } else if (manualTrigger.pathparams) {
18943
+ if (Array.isArray(manualTrigger.pathparams)) {
18944
+ const pathParamsObject = {};
18945
+ for (const [key, value] of Object.entries(manualTrigger.pathparams)) {
18946
+ pathParamsObject[key] = value;
18947
+ }
18948
+ result.pathParams = pathParamsObject;
18949
+ } else {
18950
+ result.pathParams = manualTrigger.pathparams;
18951
+ }
18952
+ }
18953
+ if (Object.keys(result).length === 0) {
18954
+ const objData = manualTrigger.toObject?.() || manualTrigger;
18955
+ if (objData && objData.data === void 0) {
18956
+ result.data = null;
18957
+ } else {
18958
+ return { data: objData };
18959
+ }
18960
+ }
18961
+ return result;
18962
+ }
18963
+ return { data: null };
18964
+ }
18549
18965
  // Node outputs - RESTORE MISSING CASES
18550
18966
  case avs_pb20.Execution.Step.OutputDataCase.ETH_TRANSFER:
18551
18967
  return typeof step.getEthTransfer === "function" ? step.getEthTransfer()?.toObject() : step.ethTransfer;
18552
- case avs_pb20.Execution.Step.OutputDataCase.CUSTOM_CODE:
18968
+ case avs_pb20.Execution.Step.OutputDataCase.CUSTOM_CODE: {
18553
18969
  const customCodeOutput = typeof step.getCustomCode === "function" ? step.getCustomCode() : step.customCode;
18554
18970
  if (customCodeOutput) {
18555
18971
  if (typeof customCodeOutput.hasData === "function" && customCodeOutput.hasData()) {
@@ -18563,7 +18979,8 @@ var Step = class _Step {
18563
18979
  }
18564
18980
  }
18565
18981
  return void 0;
18566
- case avs_pb20.Execution.Step.OutputDataCase.REST_API:
18982
+ }
18983
+ case avs_pb20.Execution.Step.OutputDataCase.REST_API: {
18567
18984
  const restApiOutput = typeof step.getRestApi === "function" ? step.getRestApi() : step.restApi;
18568
18985
  if (restApiOutput) {
18569
18986
  if (typeof restApiOutput.hasData === "function" && restApiOutput.hasData()) {
@@ -18577,9 +18994,10 @@ var Step = class _Step {
18577
18994
  }
18578
18995
  }
18579
18996
  return void 0;
18997
+ }
18580
18998
  case avs_pb20.Execution.Step.OutputDataCase.BRANCH:
18581
18999
  return typeof step.getBranch === "function" ? step.getBranch()?.toObject() : step.branch;
18582
- case avs_pb20.Execution.Step.OutputDataCase.LOOP:
19000
+ case avs_pb20.Execution.Step.OutputDataCase.LOOP: {
18583
19001
  const loopOutput = typeof step.getLoop === "function" ? step.getLoop() : step.loop;
18584
19002
  if (loopOutput) {
18585
19003
  if (typeof loopOutput.getData === "function" && loopOutput.getData()) {
@@ -18597,7 +19015,8 @@ var Step = class _Step {
18597
19015
  }
18598
19016
  }
18599
19017
  return void 0;
18600
- case avs_pb20.Execution.Step.OutputDataCase.GRAPHQL:
19018
+ }
19019
+ case avs_pb20.Execution.Step.OutputDataCase.GRAPHQL: {
18601
19020
  const graphqlOutput = typeof step.getGraphql === "function" ? step.getGraphql() : step.graphql;
18602
19021
  if (graphqlOutput) {
18603
19022
  try {
@@ -18607,7 +19026,8 @@ var Step = class _Step {
18607
19026
  }
18608
19027
  }
18609
19028
  return void 0;
18610
- case avs_pb20.Execution.Step.OutputDataCase.CONTRACT_READ:
19029
+ }
19030
+ case avs_pb20.Execution.Step.OutputDataCase.CONTRACT_READ: {
18611
19031
  const contractReadOutput = typeof step.getContractRead === "function" ? step.getContractRead() : step.contractRead;
18612
19032
  if (contractReadOutput) {
18613
19033
  if (typeof contractReadOutput.hasData === "function" && contractReadOutput.hasData()) {
@@ -18647,7 +19067,8 @@ var Step = class _Step {
18647
19067
  return outputObj;
18648
19068
  }
18649
19069
  return void 0;
18650
- case avs_pb20.Execution.Step.OutputDataCase.CONTRACT_WRITE:
19070
+ }
19071
+ case avs_pb20.Execution.Step.OutputDataCase.CONTRACT_WRITE: {
18651
19072
  const contractWriteOutput = typeof step.getContractWrite === "function" ? step.getContractWrite() : step.contractWrite;
18652
19073
  if (contractWriteOutput) {
18653
19074
  if (typeof contractWriteOutput.hasData === "function" && contractWriteOutput.hasData()) {
@@ -18690,7 +19111,8 @@ var Step = class _Step {
18690
19111
  return outputObj;
18691
19112
  }
18692
19113
  return void 0;
18693
- case avs_pb20.Execution.Step.OutputDataCase.FILTER:
19114
+ }
19115
+ case avs_pb20.Execution.Step.OutputDataCase.FILTER: {
18694
19116
  const filterOutput = typeof step.getFilter === "function" ? step.getFilter() : step.filter;
18695
19117
  if (filterOutput) {
18696
19118
  try {
@@ -18700,6 +19122,7 @@ var Step = class _Step {
18700
19122
  }
18701
19123
  }
18702
19124
  return void 0;
19125
+ }
18703
19126
  default:
18704
19127
  console.warn(
18705
19128
  `Unhandled output data type in Step.getOutput: ${step.getOutputDataCase()}`
@@ -19408,7 +19831,22 @@ var Client = class extends BaseClient {
19408
19831
  case TriggerType13.Manual: {
19409
19832
  const manualData = triggerData;
19410
19833
  const manualOutput = new avs_pb22.ManualTrigger.Output();
19411
- if (manualData.runAt) manualOutput.setRunAt(manualData.runAt);
19834
+ if (manualData.data) {
19835
+ const protobufValue = convertJSValueToProtobuf(manualData.data);
19836
+ manualOutput.setData(protobufValue);
19837
+ }
19838
+ if (manualData.headers) {
19839
+ const headersMap = manualOutput.getHeadersMap();
19840
+ Object.entries(manualData.headers).forEach(([key, value]) => {
19841
+ headersMap.set(key, value);
19842
+ });
19843
+ }
19844
+ if (manualData.pathParams) {
19845
+ const pathParamsMap = manualOutput.getPathparamsMap();
19846
+ Object.entries(manualData.pathParams).forEach(([key, value]) => {
19847
+ pathParamsMap.set(key, value);
19848
+ });
19849
+ }
19412
19850
  request.setManualTrigger(manualOutput);
19413
19851
  break;
19414
19852
  }