@avaprotocol/sdk-js 1.6.5 → 1.6.7
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +19 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1201 -741
- package/dist/index.mjs +1213 -743
- package/dist/models/node/branch.d.ts +1 -0
- package/dist/models/node/branch.d.ts.map +1 -1
- package/dist/models/node/branch.js +4 -0
- package/dist/models/node/contractRead.d.ts +1 -0
- package/dist/models/node/contractRead.d.ts.map +1 -1
- package/dist/models/node/contractRead.js +11 -0
- package/dist/models/node/contractWrite.d.ts +1 -0
- package/dist/models/node/contractWrite.d.ts.map +1 -1
- package/dist/models/node/contractWrite.js +4 -0
- package/dist/models/node/customCode.d.ts +1 -0
- package/dist/models/node/customCode.d.ts.map +1 -1
- package/dist/models/node/customCode.js +9 -0
- package/dist/models/node/ethTransfer.d.ts +1 -0
- package/dist/models/node/ethTransfer.d.ts.map +1 -1
- package/dist/models/node/ethTransfer.js +4 -0
- package/dist/models/node/factory.d.ts +1 -0
- package/dist/models/node/factory.d.ts.map +1 -1
- package/dist/models/node/factory.js +54 -0
- package/dist/models/node/filter.d.ts +1 -0
- package/dist/models/node/filter.d.ts.map +1 -1
- package/dist/models/node/filter.js +4 -0
- package/dist/models/node/graphqlQuery.d.ts +1 -0
- package/dist/models/node/graphqlQuery.d.ts.map +1 -1
- package/dist/models/node/graphqlQuery.js +4 -0
- package/dist/models/node/loop.d.ts +1 -0
- package/dist/models/node/loop.d.ts.map +1 -1
- package/dist/models/node/loop.js +4 -0
- package/dist/models/node/restApi.d.ts +1 -0
- package/dist/models/node/restApi.d.ts.map +1 -1
- package/dist/models/node/restApi.js +15 -1
- package/dist/models/trigger/block.d.ts +6 -0
- package/dist/models/trigger/block.d.ts.map +1 -1
- package/dist/models/trigger/block.js +9 -0
- package/dist/models/trigger/cron.d.ts +7 -1
- package/dist/models/trigger/cron.d.ts.map +1 -1
- package/dist/models/trigger/cron.js +10 -1
- package/dist/models/trigger/event.d.ts +7 -1
- package/dist/models/trigger/event.d.ts.map +1 -1
- package/dist/models/trigger/event.js +10 -1
- package/dist/models/trigger/factory.d.ts +1 -0
- package/dist/models/trigger/factory.d.ts.map +1 -1
- package/dist/models/trigger/factory.js +42 -0
- package/dist/models/trigger/fixedTime.d.ts +7 -1
- package/dist/models/trigger/fixedTime.d.ts.map +1 -1
- package/dist/models/trigger/fixedTime.js +10 -1
- package/dist/models/trigger/interface.d.ts +1 -1
- package/dist/models/trigger/interface.d.ts.map +1 -1
- package/dist/models/trigger/manual.d.ts +13 -0
- package/dist/models/trigger/manual.d.ts.map +1 -1
- package/dist/models/trigger/manual.js +17 -0
- package/dist/utils.d.ts +34 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +116 -2
- package/package.json +2 -2
|
@@ -38,12 +38,21 @@ class FixedTimeTrigger extends Trigger {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Convert raw data from
|
|
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
|
+
* @param outputData - The RunTriggerResp containing fixed time trigger output
|
|
51
|
+
* @returns Plain JavaScript object with fixed time trigger data
|
|
52
|
+
*/
|
|
53
|
+
static fromOutputData(outputData) {
|
|
54
|
+
const fixedTimeOutput = outputData.getFixedTimeTrigger();
|
|
55
|
+
return fixedTimeOutput?.toObject() || null;
|
|
56
|
+
}
|
|
48
57
|
}
|
|
49
58
|
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,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
|
+
{"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,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,GACpC,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,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;
|
|
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
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "1.6.7",
|
|
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.
|
|
33
|
+
"@avaprotocol/types": "1.0.7",
|
|
34
34
|
"@grpc/grpc-js": "^1.11.3",
|
|
35
35
|
"@grpc/proto-loader": "^0.7.13",
|
|
36
36
|
"dotenv": "^16.4.5",
|