@avaprotocol/sdk-js 1.6.6 → 1.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/index.d.ts +17 -30
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1262 -853
  5. package/dist/index.mjs +1273 -856
  6. package/dist/models/execution.d.ts +7 -9
  7. package/dist/models/execution.d.ts.map +1 -1
  8. package/dist/models/execution.js +17 -7
  9. package/dist/models/node/branch.d.ts +1 -0
  10. package/dist/models/node/branch.d.ts.map +1 -1
  11. package/dist/models/node/branch.js +4 -0
  12. package/dist/models/node/contractRead.d.ts +1 -0
  13. package/dist/models/node/contractRead.d.ts.map +1 -1
  14. package/dist/models/node/contractRead.js +11 -0
  15. package/dist/models/node/contractWrite.d.ts +1 -0
  16. package/dist/models/node/contractWrite.d.ts.map +1 -1
  17. package/dist/models/node/contractWrite.js +4 -0
  18. package/dist/models/node/customCode.d.ts +1 -0
  19. package/dist/models/node/customCode.d.ts.map +1 -1
  20. package/dist/models/node/customCode.js +9 -0
  21. package/dist/models/node/ethTransfer.d.ts +1 -0
  22. package/dist/models/node/ethTransfer.d.ts.map +1 -1
  23. package/dist/models/node/ethTransfer.js +4 -0
  24. package/dist/models/node/factory.d.ts +1 -0
  25. package/dist/models/node/factory.d.ts.map +1 -1
  26. package/dist/models/node/factory.js +54 -0
  27. package/dist/models/node/filter.d.ts +1 -0
  28. package/dist/models/node/filter.d.ts.map +1 -1
  29. package/dist/models/node/filter.js +4 -0
  30. package/dist/models/node/graphqlQuery.d.ts +1 -0
  31. package/dist/models/node/graphqlQuery.d.ts.map +1 -1
  32. package/dist/models/node/graphqlQuery.js +4 -0
  33. package/dist/models/node/loop.d.ts +1 -0
  34. package/dist/models/node/loop.d.ts.map +1 -1
  35. package/dist/models/node/loop.js +4 -0
  36. package/dist/models/node/restApi.d.ts +1 -0
  37. package/dist/models/node/restApi.d.ts.map +1 -1
  38. package/dist/models/node/restApi.js +15 -1
  39. package/dist/models/trigger/block.d.ts +6 -0
  40. package/dist/models/trigger/block.d.ts.map +1 -1
  41. package/dist/models/trigger/block.js +9 -0
  42. package/dist/models/trigger/cron.d.ts +8 -1
  43. package/dist/models/trigger/cron.d.ts.map +1 -1
  44. package/dist/models/trigger/cron.js +18 -1
  45. package/dist/models/trigger/event.d.ts +7 -1
  46. package/dist/models/trigger/event.d.ts.map +1 -1
  47. package/dist/models/trigger/event.js +10 -1
  48. package/dist/models/trigger/factory.d.ts +1 -0
  49. package/dist/models/trigger/factory.d.ts.map +1 -1
  50. package/dist/models/trigger/factory.js +42 -0
  51. package/dist/models/trigger/fixedTime.d.ts +8 -1
  52. package/dist/models/trigger/fixedTime.d.ts.map +1 -1
  53. package/dist/models/trigger/fixedTime.js +18 -1
  54. package/dist/models/trigger/interface.d.ts +1 -1
  55. package/dist/models/trigger/interface.d.ts.map +1 -1
  56. package/dist/models/trigger/manual.d.ts +13 -0
  57. package/dist/models/trigger/manual.d.ts.map +1 -1
  58. package/dist/models/trigger/manual.js +17 -0
  59. package/dist/utils.d.ts +34 -0
  60. package/dist/utils.d.ts.map +1 -1
  61. package/dist/utils.js +116 -2
  62. package/package.json +2 -2
@@ -18,6 +18,7 @@ declare class TriggerFactory {
18
18
  * @returns
19
19
  */
20
20
  static fromResponse(raw: avs_pb.TaskTrigger): Trigger;
21
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): any;
21
22
  }
22
23
  export default TriggerFactory;
23
24
  export { Trigger, BlockTrigger, CronTrigger, EventTrigger, FixedTimeTrigger, ManualTrigger, };
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,WA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AM,cAAc;IAClB;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAkB3C;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,OAAO;IAiBrD,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CA+C9D;AAED,eAAe,cAAc,CAAC;AAG9B,OAAO,EACL,OAAO,EACP,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,aAAa,GACd,CAAC;AAGF,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
1
2
  import BlockTrigger from "./block";
2
3
  import CronTrigger from "./cron";
3
4
  import EventTrigger from "./event";
@@ -5,6 +6,7 @@ import FixedTimeTrigger from "./fixedTime";
5
6
  import ManualTrigger from "./manual";
6
7
  import Trigger from "./interface";
7
8
  import { TriggerType } from "@avaprotocol/types";
9
+ import { convertProtobufValueToJs } from "../../utils";
8
10
  class TriggerFactory {
9
11
  /**
10
12
  * Static factory method to create Trigger instances
@@ -48,6 +50,46 @@ class TriggerFactory {
48
50
  throw new Error("Unknown trigger type");
49
51
  }
50
52
  }
53
+ static fromOutputData(outputData) {
54
+ // Generic approach: try to extract data from any output type using getData() method
55
+ // This works for all trigger types that follow the pattern of having a getData() method
56
+ let triggerOutput = null;
57
+ let rawData = null;
58
+ // Get the specific trigger output based on the case
59
+ switch (outputData.getOutputDataCase()) {
60
+ case avs_pb.RunTriggerResp.OutputDataCase.BLOCK_TRIGGER:
61
+ triggerOutput = outputData.getBlockTrigger();
62
+ break;
63
+ case avs_pb.RunTriggerResp.OutputDataCase.FIXED_TIME_TRIGGER:
64
+ triggerOutput = outputData.getFixedTimeTrigger();
65
+ break;
66
+ case avs_pb.RunTriggerResp.OutputDataCase.CRON_TRIGGER:
67
+ triggerOutput = outputData.getCronTrigger();
68
+ break;
69
+ case avs_pb.RunTriggerResp.OutputDataCase.EVENT_TRIGGER:
70
+ triggerOutput = outputData.getEventTrigger();
71
+ break;
72
+ case avs_pb.RunTriggerResp.OutputDataCase.MANUAL_TRIGGER:
73
+ triggerOutput = outputData.getManualTrigger();
74
+ break;
75
+ case avs_pb.RunTriggerResp.OutputDataCase.OUTPUT_DATA_NOT_SET:
76
+ default:
77
+ throw new Error(`Unsupported output data case: ${outputData.getOutputDataCase()}`);
78
+ }
79
+ if (!triggerOutput) {
80
+ return null;
81
+ }
82
+ // Try to get data using getData() method (works for most trigger types)
83
+ if (typeof triggerOutput.getData === 'function') {
84
+ rawData = triggerOutput.getData();
85
+ if (rawData) {
86
+ return convertProtobufValueToJs(rawData);
87
+ }
88
+ }
89
+ // For trigger types that don't have getData() or have special structures,
90
+ // fall back to toObject() for now (can be specialized later if needed)
91
+ return triggerOutput.toObject();
92
+ }
51
93
  }
52
94
  export default TriggerFactory;
53
95
  // Trigger object definitions
@@ -9,11 +9,18 @@ declare class FixedTimeTrigger extends Trigger {
9
9
  toRequest(): avs_pb.TaskTrigger;
10
10
  static fromResponse(raw: avs_pb.TaskTrigger): FixedTimeTrigger;
11
11
  /**
12
- * Convert raw data from runNodeWithInputs response to FixedTimeOutput format
12
+ * Convert raw data from runTrigger response to FixedTimeOutput format
13
13
  * @param rawData - The raw data from the gRPC response
14
14
  * @returns {FixedTimeTriggerOutput | undefined} - The converted data
15
15
  */
16
16
  getOutput(): FixedTimeTriggerOutput | undefined;
17
+ /**
18
+ * Extract output data from RunTriggerResp for fixed time triggers
19
+ * Updated to handle timestamp and timestamp_iso instead of epoch
20
+ * @param outputData - The RunTriggerResp containing fixed time trigger output
21
+ * @returns Plain JavaScript object with fixed time trigger data
22
+ */
23
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): any;
17
24
  }
18
25
  export default FixedTimeTrigger;
19
26
  //# sourceMappingURL=fixedTime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fixedTime.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/fixedTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,EAAE,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAe,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGnG,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG;IACjD,IAAI,EAAE,wBAAwB,CAAC;CAChC,CAAC;AAEF,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAIxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAmB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,gBAAgB;IAuB9D;;;;OAIG;IACH,SAAS,IAAI,sBAAsB,GAAG,SAAS;CAGhD;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"fixedTime.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/fixedTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,EAAE,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAe,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGnG,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG;IACjD,IAAI,EAAE,wBAAwB,CAAC;CAChC,CAAC;AAEF,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAIxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAmB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,gBAAgB;IAuB9D;;;;OAIG;IACH,SAAS,IAAI,sBAAsB,GAAG,SAAS;IAI/C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;AAED,eAAe,gBAAgB,CAAC"}
@@ -38,12 +38,29 @@ class FixedTimeTrigger extends Trigger {
38
38
  });
39
39
  }
40
40
  /**
41
- * Convert raw data from runNodeWithInputs response to FixedTimeOutput format
41
+ * Convert raw data from runTrigger response to FixedTimeOutput format
42
42
  * @param rawData - The raw data from the gRPC response
43
43
  * @returns {FixedTimeTriggerOutput | undefined} - The converted data
44
44
  */
45
45
  getOutput() {
46
46
  return this.output;
47
47
  }
48
+ /**
49
+ * Extract output data from RunTriggerResp for fixed time triggers
50
+ * Updated to handle timestamp and timestamp_iso instead of epoch
51
+ * @param outputData - The RunTriggerResp containing fixed time trigger output
52
+ * @returns Plain JavaScript object with fixed time trigger data
53
+ */
54
+ static fromOutputData(outputData) {
55
+ const fixedTimeOutput = outputData.getFixedTimeTrigger();
56
+ if (!fixedTimeOutput)
57
+ return null;
58
+ const outputObj = fixedTimeOutput.toObject();
59
+ // The output now contains timestamp and timestampIso instead of epoch
60
+ return {
61
+ timestamp: outputObj.timestamp,
62
+ timestampIso: outputObj.timestampIso
63
+ };
64
+ }
48
65
  }
49
66
  export default FixedTimeTrigger;
@@ -1,7 +1,7 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
2
  import { TriggerType } from "@avaprotocol/types";
3
3
  export type TriggerData = avs_pb.FixedTimeTrigger.AsObject | avs_pb.CronTrigger.AsObject | avs_pb.BlockTrigger.AsObject | avs_pb.EventTrigger.AsObject | Record<string, any> | null;
4
- export type TriggerOutput = avs_pb.FixedTimeTrigger.Output.AsObject | avs_pb.CronTrigger.Output.AsObject | avs_pb.BlockTrigger.Output.AsObject | avs_pb.EventTrigger.Output.AsObject | null;
4
+ export type TriggerOutput = avs_pb.FixedTimeTrigger.Output.AsObject | avs_pb.CronTrigger.Output.AsObject | avs_pb.BlockTrigger.Output.AsObject | avs_pb.EventTrigger.Output.AsObject | avs_pb.ManualTrigger.Output.AsObject | null;
5
5
  export type TriggerProps = Omit<avs_pb.TaskTrigger.AsObject, "manual" | "fixedTime" | "cron" | "block" | "event" | "type"> & {
6
6
  type: TriggerType;
7
7
  data: TriggerData;
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,WAAW,GACnB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,GAChC,MAAM,CAAC,WAAW,CAAC,QAAQ,GAC3B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,IAAI,CAAC;AAET,MAAM,MAAM,aAAa,GACrB,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,GACvC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,GAClC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,IAAI,CAAC;AAET,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,MAAM,CAAC,WAAW,CAAC,QAAQ,EAC3B,QAAQ,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAC7D,GAAG;IACF,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,cAAM,OAAQ,YAAW,YAAY;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,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Y;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB;;;OAGG;gBACS,KAAK,EAAE,YAAY;IAQ/B,SAAS,IAAI,MAAM,CAAC,WAAW;IAI/B,SAAS,IAAI,aAAa,GAAG,SAAS;CAGvC;AAED,eAAe,OAAO,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
2
  import Trigger, { TriggerProps } from "./interface";
3
+ import { ManualTriggerOutput } from "@avaprotocol/types";
3
4
  export type ManualTriggerProps = TriggerProps & {
4
5
  data?: Record<string, any> | null;
5
6
  };
@@ -8,6 +9,18 @@ declare class ManualTrigger extends Trigger {
8
9
  toRequest(): avs_pb.TaskTrigger;
9
10
  static fromResponse(raw: avs_pb.TaskTrigger): ManualTrigger;
10
11
  getInputVariables(): Record<string, any> | null;
12
+ /**
13
+ * Convert raw data from runTrigger response to ManualOutput format
14
+ * @param rawData - The raw data from the gRPC response
15
+ * @returns {ManualTriggerOutput | undefined} - The converted data
16
+ */
17
+ getOutput(): ManualTriggerOutput | undefined;
18
+ /**
19
+ * Extract output data from RunTriggerResp for manual triggers
20
+ * @param outputData - The RunTriggerResp containing manual trigger output
21
+ * @returns Plain JavaScript object with manual trigger data
22
+ */
23
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): any;
11
24
  }
12
25
  export default ManualTrigger;
13
26
  //# sourceMappingURL=manual.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAA;CAClC,CAAC;AAEF,cAAM,aAAc,SAAQ,OAAO;gBACrB,KAAK,EAAE,kBAAkB;IAIrC,SAAS,IAAI,MAAM,CAAC,WAAW;IAU/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,aAAa;IAU3D,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;CAGhD;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"manual.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/manual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAe,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAA;CAClC,CAAC;AAEF,cAAM,aAAc,SAAQ,OAAO;gBACrB,KAAK,EAAE,kBAAkB;IAIrC,SAAS,IAAI,MAAM,CAAC,WAAW;IAU/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,aAAa;IAU3D,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAI/C;;;;OAIG;IACH,SAAS,IAAI,mBAAmB,GAAG,SAAS;IAI5C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAI9D;AAED,eAAe,aAAa,CAAC"}
@@ -23,5 +23,22 @@ class ManualTrigger extends Trigger {
23
23
  getInputVariables() {
24
24
  return this.data;
25
25
  }
26
+ /**
27
+ * Convert raw data from runTrigger response to ManualOutput format
28
+ * @param rawData - The raw data from the gRPC response
29
+ * @returns {ManualTriggerOutput | undefined} - The converted data
30
+ */
31
+ getOutput() {
32
+ return this.output;
33
+ }
34
+ /**
35
+ * Extract output data from RunTriggerResp for manual triggers
36
+ * @param outputData - The RunTriggerResp containing manual trigger output
37
+ * @returns Plain JavaScript object with manual trigger data
38
+ */
39
+ static fromOutputData(outputData) {
40
+ const manualOutput = outputData.getManualTrigger();
41
+ return manualOutput?.toObject() || null;
42
+ }
26
43
  }
27
44
  export default ManualTrigger;
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,37 @@
1
1
  import { Value as ProtobufValue } from "google-protobuf/google/protobuf/struct_pb";
2
+ /**
3
+ * Convert a protobuf Value to a JavaScript value
4
+ *
5
+ * **🏆 RECOMMENDED for modern protobuf usage**
6
+ *
7
+ * This is the primary implementation using proper TypeScript types and getKindCase()
8
+ * for the latest protobuf libraries. Use this for all new code.
9
+ *
10
+ * @param value - The protobuf Value to convert
11
+ * @returns The converted JavaScript value
12
+ */
2
13
  export declare function convertProtobufValueToJs(value?: ProtobufValue): any;
14
+ /**
15
+ * Convert a protobuf Value to a JavaScript value
16
+ *
17
+ * **⚠️ DEPRECATED - Use convertProtobufValueToJs() for new code**
18
+ *
19
+ * This is a legacy compatibility version for existing code that may use
20
+ * dynamically typed protobuf objects. It uses older has*() methods and
21
+ * fallback logic. Only use this if you need backward compatibility.
22
+ *
23
+ * @deprecated Use convertProtobufValueToJs() instead for better type safety
24
+ * @param value - The protobuf Value object (may be dynamically typed)
25
+ * @returns The converted JavaScript value
26
+ */
27
+ export declare function convertProtobufValueToJS(value: any): any;
28
+ /**
29
+ * Convert a JavaScript value to a protobuf Value
30
+ *
31
+ * Uses proper TypeScript types for modern protobuf usage.
32
+ *
33
+ * @param value - The JavaScript value to convert
34
+ * @returns The protobuf Value object
35
+ */
36
+ export declare function convertJSValueToProtobuf(value: any): ProtobufValue;
3
37
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAGnF,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,GAAG,CAiCnE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,aAAa,EAGvB,MAAM,2CAA2C,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,GAAG,CAiCnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAkDxD;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CA6BlE"}
package/dist/utils.js CHANGED
@@ -1,5 +1,15 @@
1
- import { Value as ProtobufValue } from "google-protobuf/google/protobuf/struct_pb";
2
- // Helper function to convert google.protobuf.Value to native JavaScript types
1
+ import { Value as ProtobufValue, Struct as ProtobufStruct, ListValue as ProtobufListValue } from "google-protobuf/google/protobuf/struct_pb";
2
+ /**
3
+ * Convert a protobuf Value to a JavaScript value
4
+ *
5
+ * **🏆 RECOMMENDED for modern protobuf usage**
6
+ *
7
+ * This is the primary implementation using proper TypeScript types and getKindCase()
8
+ * for the latest protobuf libraries. Use this for all new code.
9
+ *
10
+ * @param value - The protobuf Value to convert
11
+ * @returns The converted JavaScript value
12
+ */
3
13
  export function convertProtobufValueToJs(value) {
4
14
  if (!value) {
5
15
  return undefined;
@@ -35,3 +45,107 @@ export function convertProtobufValueToJs(value) {
35
45
  return undefined;
36
46
  }
37
47
  }
48
+ /**
49
+ * Convert a protobuf Value to a JavaScript value
50
+ *
51
+ * **⚠️ DEPRECATED - Use convertProtobufValueToJs() for new code**
52
+ *
53
+ * This is a legacy compatibility version for existing code that may use
54
+ * dynamically typed protobuf objects. It uses older has*() methods and
55
+ * fallback logic. Only use this if you need backward compatibility.
56
+ *
57
+ * @deprecated Use convertProtobufValueToJs() instead for better type safety
58
+ * @param value - The protobuf Value object (may be dynamically typed)
59
+ * @returns The converted JavaScript value
60
+ */
61
+ export function convertProtobufValueToJS(value) {
62
+ if (!value)
63
+ return null;
64
+ // Handle different value types based on protobuf Value structure
65
+ if (value.hasNullValue && value.hasNullValue()) {
66
+ return null;
67
+ }
68
+ if (value.hasNumberValue && value.hasNumberValue()) {
69
+ return value.getNumberValue();
70
+ }
71
+ if (value.hasStringValue && value.hasStringValue()) {
72
+ return value.getStringValue();
73
+ }
74
+ if (value.hasBoolValue && value.hasBoolValue()) {
75
+ return value.getBoolValue();
76
+ }
77
+ if (value.hasStructValue && value.hasStructValue()) {
78
+ const struct = value.getStructValue();
79
+ const result = {};
80
+ if (struct && struct.getFieldsMap) {
81
+ const fieldsMap = struct.getFieldsMap();
82
+ fieldsMap.forEach((fieldValue, key) => {
83
+ result[key] = convertProtobufValueToJS(fieldValue);
84
+ });
85
+ }
86
+ return result;
87
+ }
88
+ if (value.hasListValue && value.hasListValue()) {
89
+ const list = value.getListValue();
90
+ if (list && list.getValuesList) {
91
+ return list
92
+ .getValuesList()
93
+ .map((item) => convertProtobufValueToJS(item));
94
+ }
95
+ return [];
96
+ }
97
+ // Fallback: try to extract primitive values directly
98
+ if (typeof value.getNumberValue === "function") {
99
+ return value.getNumberValue();
100
+ }
101
+ if (typeof value.getStringValue === "function") {
102
+ return value.getStringValue();
103
+ }
104
+ if (typeof value.getBoolValue === "function") {
105
+ return value.getBoolValue();
106
+ }
107
+ // If all else fails, return the raw value
108
+ return value;
109
+ }
110
+ /**
111
+ * Convert a JavaScript value to a protobuf Value
112
+ *
113
+ * Uses proper TypeScript types for modern protobuf usage.
114
+ *
115
+ * @param value - The JavaScript value to convert
116
+ * @returns The protobuf Value object
117
+ */
118
+ export function convertJSValueToProtobuf(value) {
119
+ const protobufValue = new ProtobufValue();
120
+ if (value === null || value === undefined) {
121
+ protobufValue.setNullValue(0); // NULL_VALUE = 0
122
+ }
123
+ else if (typeof value === "number") {
124
+ protobufValue.setNumberValue(value);
125
+ }
126
+ else if (typeof value === "string") {
127
+ protobufValue.setStringValue(value);
128
+ }
129
+ else if (typeof value === "boolean") {
130
+ protobufValue.setBoolValue(value);
131
+ }
132
+ else if (Array.isArray(value)) {
133
+ const listValue = new ProtobufListValue();
134
+ const convertedValues = value.map((item) => convertJSValueToProtobuf(item));
135
+ listValue.setValuesList(convertedValues);
136
+ protobufValue.setListValue(listValue);
137
+ }
138
+ else if (typeof value === "object") {
139
+ const structValue = new ProtobufStruct();
140
+ const fieldsMap = structValue.getFieldsMap();
141
+ Object.entries(value).forEach(([key, val]) => {
142
+ fieldsMap.set(key, convertJSValueToProtobuf(val));
143
+ });
144
+ protobufValue.setStructValue(structValue);
145
+ }
146
+ else {
147
+ // Fallback: convert to string
148
+ protobufValue.setStringValue(String(value));
149
+ }
150
+ return protobufValue;
151
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "description": "A JavaScript/TypeScript SDK designed to simplify integration with Ava Protocol's AVS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "clean": "rm -rf node_modules dist tsconfig.tsbuildinfo"
31
31
  },
32
32
  "dependencies": {
33
- "@avaprotocol/types": "1.0.6",
33
+ "@avaprotocol/types": "1.0.8",
34
34
  "@grpc/grpc-js": "^1.11.3",
35
35
  "@grpc/proto-loader": "^0.7.13",
36
36
  "dotenv": "^16.4.5",