@avaprotocol/sdk-js 2.4.4 → 2.5.0
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 +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +502 -88
- package/dist/index.mjs +508 -90
- package/dist/models/node/filter.d.ts.map +1 -1
- package/dist/models/node/filter.js +22 -3
- package/dist/models/node/loop.d.ts.map +1 -1
- package/dist/models/node/loop.js +14 -18
- package/dist/models/step.d.ts.map +1 -1
- package/dist/models/step.js +239 -21
- package/dist/models/trigger/manual.d.ts +6 -10
- package/dist/models/trigger/manual.d.ts.map +1 -1
- package/dist/models/trigger/manual.js +108 -25
- package/dist/models/workflow.d.ts.map +1 -1
- package/dist/models/workflow.js +0 -2
- package/package.json +2 -2
|
@@ -1,58 +1,141 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
2
|
import Trigger from "./interface";
|
|
3
|
-
import { convertInputToProtobuf, extractInputFromProtobuf } from "../../utils";
|
|
4
|
-
import { TriggerType } from "@avaprotocol/types";
|
|
3
|
+
import { convertInputToProtobuf, extractInputFromProtobuf, convertProtobufValueToJs, } from "../../utils";
|
|
4
|
+
import { TriggerType, } from "@avaprotocol/types";
|
|
5
5
|
class ManualTrigger extends Trigger {
|
|
6
6
|
constructor(props) {
|
|
7
|
-
super({
|
|
7
|
+
super({
|
|
8
|
+
...props,
|
|
9
|
+
type: TriggerType.Manual,
|
|
10
|
+
data: props.data,
|
|
11
|
+
input: props.input,
|
|
12
|
+
});
|
|
13
|
+
this.headersMap = props.headersMap;
|
|
14
|
+
this.pathParamsMap = props.pathParamsMap;
|
|
8
15
|
}
|
|
9
16
|
toRequest() {
|
|
10
17
|
const trigger = new avs_pb.TaskTrigger();
|
|
11
18
|
trigger.setId(this.id);
|
|
12
19
|
trigger.setName(this.name);
|
|
13
20
|
trigger.setType(avs_pb.TriggerType.TRIGGER_TYPE_MANUAL);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
// Create ManualTrigger with proper config structure
|
|
22
|
+
const manualTrigger = new avs_pb.ManualTrigger();
|
|
23
|
+
const config = new avs_pb.ManualTrigger.Config();
|
|
24
|
+
// Set the data
|
|
25
|
+
const dataToSend = this.data ?? this.input;
|
|
26
|
+
if (dataToSend !== null && dataToSend !== undefined) {
|
|
27
|
+
const inputValue = convertInputToProtobuf(dataToSend);
|
|
28
|
+
if (inputValue) {
|
|
29
|
+
config.setData(inputValue);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Set headers if provided - use map format consistent with REST API nodes
|
|
33
|
+
if (this.headersMap && this.headersMap.length > 0) {
|
|
34
|
+
const headersMap = config.getHeadersMap();
|
|
35
|
+
this.headersMap.forEach(([key, value]) => {
|
|
36
|
+
headersMap.set(key, value);
|
|
37
|
+
});
|
|
20
38
|
}
|
|
39
|
+
// Set pathParams if provided - use map format consistent with REST API nodes
|
|
40
|
+
if (this.pathParamsMap && this.pathParamsMap.length > 0) {
|
|
41
|
+
const pathParamsMap = config.getPathparamsMap();
|
|
42
|
+
this.pathParamsMap.forEach(([key, value]) => {
|
|
43
|
+
pathParamsMap.set(key, value);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
manualTrigger.setConfig(config);
|
|
47
|
+
trigger.setManual(manualTrigger);
|
|
21
48
|
return trigger;
|
|
22
49
|
}
|
|
23
50
|
static fromResponse(raw) {
|
|
24
51
|
const obj = raw.toObject();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
52
|
+
let data = null;
|
|
53
|
+
const input = undefined;
|
|
54
|
+
let headersMap = undefined;
|
|
55
|
+
let pathParamsMap = undefined;
|
|
56
|
+
const manualTrigger = raw.getManual();
|
|
57
|
+
if (manualTrigger) {
|
|
58
|
+
const config = manualTrigger.getConfig();
|
|
59
|
+
if (config) {
|
|
60
|
+
// Extract data
|
|
61
|
+
if (config.hasData()) {
|
|
62
|
+
data = extractInputFromProtobuf(config.getData());
|
|
63
|
+
}
|
|
64
|
+
// Extract headers - convert map to array format
|
|
65
|
+
const headersMapProto = config.getHeadersMap();
|
|
66
|
+
if (headersMapProto && headersMapProto.getLength() > 0) {
|
|
67
|
+
headersMap = [];
|
|
68
|
+
headersMapProto.forEach((value, key) => {
|
|
69
|
+
headersMap.push([key, value]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Extract pathParams - convert map to array format
|
|
73
|
+
const pathParamsMapProto = config.getPathparamsMap();
|
|
74
|
+
if (pathParamsMapProto && pathParamsMapProto.getLength() > 0) {
|
|
75
|
+
pathParamsMap = [];
|
|
76
|
+
pathParamsMapProto.forEach((value, key) => {
|
|
77
|
+
pathParamsMap.push([key, value]);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
29
81
|
}
|
|
30
82
|
return new ManualTrigger({
|
|
31
83
|
...obj,
|
|
32
84
|
type: TriggerType.Manual,
|
|
33
|
-
data:
|
|
85
|
+
data: data,
|
|
34
86
|
input: input,
|
|
87
|
+
headersMap: headersMap,
|
|
88
|
+
pathParamsMap: pathParamsMap,
|
|
35
89
|
});
|
|
36
90
|
}
|
|
37
91
|
getInputVariables() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Convert raw data from runTrigger response to ManualOutput format
|
|
42
|
-
* @param rawData - The raw data from the gRPC response
|
|
43
|
-
* @returns {ManualTriggerOutput | undefined} - The converted data
|
|
44
|
-
*/
|
|
45
|
-
getOutput() {
|
|
46
|
-
return this.output;
|
|
92
|
+
// Return input variables that can be referenced by other nodes
|
|
93
|
+
return this.input;
|
|
47
94
|
}
|
|
48
95
|
/**
|
|
49
96
|
* Extract output data from RunTriggerResp for manual triggers
|
|
50
97
|
* @param outputData - The RunTriggerResp containing manual trigger output
|
|
51
|
-
* @returns Plain JavaScript object with manual trigger data
|
|
98
|
+
* @returns Plain JavaScript object with manual trigger data in standard structure
|
|
52
99
|
*/
|
|
53
100
|
static fromOutputData(outputData) {
|
|
54
101
|
const manualOutput = outputData.getManualTrigger();
|
|
55
|
-
|
|
102
|
+
if (!manualOutput) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const result = {};
|
|
106
|
+
// Extract data
|
|
107
|
+
const dataValue = manualOutput.getData();
|
|
108
|
+
if (dataValue) {
|
|
109
|
+
try {
|
|
110
|
+
result.data = convertProtobufValueToJs(dataValue);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.warn("Failed to convert manual trigger data from protobuf Value:", error);
|
|
114
|
+
result.data = dataValue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
result.data = null;
|
|
119
|
+
}
|
|
120
|
+
// Extract headers - convert map to array format for consistency
|
|
121
|
+
const headersMapProto = manualOutput.getHeadersMap();
|
|
122
|
+
if (headersMapProto && headersMapProto.getLength() > 0) {
|
|
123
|
+
const headersArray = [];
|
|
124
|
+
headersMapProto.forEach((value, key) => {
|
|
125
|
+
headersArray.push([key, value]);
|
|
126
|
+
});
|
|
127
|
+
result.headers = headersArray;
|
|
128
|
+
}
|
|
129
|
+
// Extract pathParams - convert map to array format for consistency
|
|
130
|
+
const pathParamsMapProto = manualOutput.getPathparamsMap();
|
|
131
|
+
if (pathParamsMapProto && pathParamsMapProto.getLength() > 0) {
|
|
132
|
+
const pathParamsArray = [];
|
|
133
|
+
pathParamsMapProto.forEach((value, key) => {
|
|
134
|
+
pathParamsArray.push([key, value]);
|
|
135
|
+
});
|
|
136
|
+
result.pathParams = pathParamsArray;
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
56
139
|
}
|
|
57
140
|
}
|
|
58
141
|
export default ManualTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/models/workflow.ts"],"names":[],"mappings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.name);
|
|
147
147
|
}
|
|
148
|
-
// Log final summary for debugging (only errors and counts)
|
|
149
|
-
console.log(`📤 Workflow serialization: ${this.nodes.length} nodes, ${this.edges.length} edges -> protobuf: ${request.getNodesList().length} nodes, ${request.getEdgesList().length} edges`);
|
|
150
148
|
return request;
|
|
151
149
|
}
|
|
152
150
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/sdk-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
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.
|
|
34
|
+
"@avaprotocol/types": "^2.3.0",
|
|
35
35
|
"@grpc/grpc-js": "^1.11.3",
|
|
36
36
|
"@grpc/proto-loader": "^0.7.13",
|
|
37
37
|
"dotenv": "^16.4.5",
|