@avaprotocol/sdk-js 2.6.12 → 2.6.13
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 +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +184 -103
- package/dist/index.mjs +184 -103
- package/dist/models/step.d.ts +29 -0
- package/dist/models/step.d.ts.map +1 -1
- package/dist/models/step.js +52 -39
- package/dist/utils.d.ts +77 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +19 -0
- package/package.json +2 -2
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
*/
|
|
13
|
+
export declare function convertProtobufValueToJs(value?: ProtobufValue): any;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a JavaScript value to a protobuf Value
|
|
16
|
+
*
|
|
17
|
+
* Uses proper TypeScript types for modern protobuf usage.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The JavaScript value to convert
|
|
20
|
+
* @returns The protobuf Value object
|
|
21
|
+
*/
|
|
22
|
+
export declare function convertJSValueToProtobuf(value: any): ProtobufValue;
|
|
23
|
+
/**
|
|
24
|
+
* Recursively convert object keys from snake_case to camelCase.
|
|
25
|
+
* Leaves non-objects and arrays intact (arrays are mapped over).
|
|
26
|
+
*/
|
|
27
|
+
export declare function toCamelCaseKeys<T = any>(input: any): T;
|
|
28
|
+
/**
|
|
29
|
+
* Convert protobuf trigger type string to SDK trigger type string
|
|
30
|
+
*
|
|
31
|
+
* @param protobufType - The protobuf trigger type string (e.g., "TRIGGER_TYPE_MANUAL")
|
|
32
|
+
* @returns The SDK trigger type string (e.g., "manualTrigger")
|
|
33
|
+
*/
|
|
34
|
+
export declare function convertProtobufTriggerTypeToSdk(protobufType: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Convert protobuf node type string to SDK node type string
|
|
37
|
+
*
|
|
38
|
+
* @param protobufType - The protobuf node type string (e.g., "NODE_TYPE_CUSTOM_CODE")
|
|
39
|
+
* @returns The SDK node type string (e.g., "customCode")
|
|
40
|
+
*/
|
|
41
|
+
export declare function convertProtobufNodeTypeToSdk(protobufType: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Convert protobuf step type string to SDK step type string
|
|
44
|
+
*
|
|
45
|
+
* Automatically detects whether the type is a trigger or node type and converts accordingly.
|
|
46
|
+
*
|
|
47
|
+
* @param protobufType - The protobuf type string (e.g., "TRIGGER_TYPE_MANUAL" or "NODE_TYPE_CUSTOM_CODE")
|
|
48
|
+
* @returns The SDK type string (e.g., "manualTrigger" or "customCode")
|
|
49
|
+
*/
|
|
50
|
+
export declare function convertProtobufStepTypeToSdk(protobufType: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Convert input field from JavaScript object to protobuf Value format
|
|
53
|
+
*
|
|
54
|
+
* Pure utility function for converting trigger/node input data to protobuf format.
|
|
55
|
+
* Can be used by both triggers and nodes.
|
|
56
|
+
*
|
|
57
|
+
* @param input - JavaScript object with input data, or undefined
|
|
58
|
+
* @returns protobuf Value or undefined if no input
|
|
59
|
+
*/
|
|
60
|
+
export declare function convertInputToProtobuf(input?: Record<string, any>): ProtobufValue | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Extract input field from protobuf Value format to JavaScript object
|
|
63
|
+
*
|
|
64
|
+
* Pure utility function for extracting trigger/node input data from protobuf format.
|
|
65
|
+
* Can be used by both triggers and nodes.
|
|
66
|
+
*
|
|
67
|
+
* @param inputValue - protobuf Value from response, plain JavaScript object, or undefined
|
|
68
|
+
* @returns JavaScript object or undefined
|
|
69
|
+
*/
|
|
70
|
+
export declare function extractInputFromProtobuf(inputValue?: ProtobufValue | Record<string, any>): Record<string, any> | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Clean up gRPC error messages by extracting the actual message
|
|
73
|
+
* @param message - The raw gRPC error message
|
|
74
|
+
* @returns {string} - The cleaned error message
|
|
75
|
+
*/
|
|
76
|
+
export declare function cleanGrpcErrorMessage(message: string): string;
|
|
77
|
+
//# 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,EACL,KAAK,IAAI,aAAa,EAGvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,GAAG,CAiCnE;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CA6BlE;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAkB5E;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA0BzE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CASzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,aAAa,GAAG,SAAS,CAK3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC/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88,25 @@ export function convertJSValueToProtobuf(value) {
|
|
|
88
88
|
}
|
|
89
89
|
return protobufValue;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Recursively convert object keys from snake_case to camelCase.
|
|
93
|
+
* Leaves non-objects and arrays intact (arrays are mapped over).
|
|
94
|
+
*/
|
|
95
|
+
export function toCamelCaseKeys(input) {
|
|
96
|
+
if (input === null || input === undefined)
|
|
97
|
+
return input;
|
|
98
|
+
if (Array.isArray(input)) {
|
|
99
|
+
return input.map((item) => toCamelCaseKeys(item));
|
|
100
|
+
}
|
|
101
|
+
if (typeof input !== "object")
|
|
102
|
+
return input;
|
|
103
|
+
const result = {};
|
|
104
|
+
for (const [key, value] of Object.entries(input)) {
|
|
105
|
+
const camelKey = key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
106
|
+
result[camelKey] = toCamelCaseKeys(value);
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
91
110
|
/**
|
|
92
111
|
* Convert protobuf trigger type string to SDK trigger type string
|
|
93
112
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/sdk-js",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.13",
|
|
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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"prepare": "node ../../scripts/prepare-package.js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@avaprotocol/types": "^2.4.
|
|
34
|
+
"@avaprotocol/types": "^2.4.11",
|
|
35
35
|
"@grpc/grpc-js": "^1.11.3",
|
|
36
36
|
"@grpc/proto-loader": "^0.7.13",
|
|
37
37
|
"dotenv": "^16.4.5",
|