@avaprotocol/sdk-js 2.5.2-dev.1 → 2.6.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 +597 -1600
- package/dist/index.mjs +612 -1603
- package/dist/models/node/branch.d.ts.map +1 -1
- package/dist/models/node/branch.js +2 -11
- package/dist/models/node/contractRead.d.ts.map +1 -1
- package/dist/models/node/contractRead.js +1 -14
- package/dist/models/node/contractWrite.d.ts +1 -1
- package/dist/models/node/contractWrite.d.ts.map +1 -1
- package/dist/models/node/contractWrite.js +0 -14
- package/dist/models/node/customCode.d.ts.map +1 -1
- package/dist/models/node/customCode.js +1 -14
- package/dist/models/node/ethTransfer.d.ts.map +1 -1
- package/dist/models/node/ethTransfer.js +6 -11
- package/dist/models/node/filter.d.ts.map +1 -1
- package/dist/models/node/filter.js +20 -18
- package/dist/models/node/graphqlQuery.d.ts.map +1 -1
- package/dist/models/node/graphqlQuery.js +5 -11
- package/dist/models/node/interface.d.ts +0 -1
- package/dist/models/node/interface.d.ts.map +1 -1
- package/dist/models/node/interface.js +0 -8
- package/dist/models/node/loop.d.ts.map +1 -1
- package/dist/models/node/loop.js +58 -85
- package/dist/models/node/restApi.d.ts.map +1 -1
- package/dist/models/node/restApi.js +1 -15
- package/dist/models/step.d.ts +3 -1
- package/dist/models/step.d.ts.map +1 -1
- package/dist/models/step.js +104 -365
- package/dist/models/trigger/block.d.ts.map +1 -1
- package/dist/models/trigger/block.js +18 -20
- package/dist/models/trigger/cron.d.ts.map +1 -1
- package/dist/models/trigger/cron.js +9 -28
- package/dist/models/trigger/event.d.ts.map +1 -1
- package/dist/models/trigger/event.js +1 -12
- package/dist/models/trigger/fixedTime.d.ts.map +1 -1
- package/dist/models/trigger/fixedTime.js +9 -20
- package/dist/models/trigger/interface.d.ts +1 -1
- package/dist/models/trigger/interface.d.ts.map +1 -1
- package/dist/models/trigger/interface.js +7 -2
- package/dist/models/trigger/manual.d.ts +0 -3
- package/dist/models/trigger/manual.d.ts.map +1 -1
- package/dist/models/trigger/manual.js +33 -44
- package/package.json +2 -2
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
2
|
import Trigger from "./interface";
|
|
3
|
-
import { TriggerType } from "@avaprotocol/types";
|
|
4
|
-
import { convertInputToProtobuf, extractInputFromProtobuf } from "../../utils";
|
|
5
|
-
// Required props for constructor: id, name, type and data: { interval }
|
|
3
|
+
import { TriggerType, } from "@avaprotocol/types";
|
|
6
4
|
class BlockTrigger extends Trigger {
|
|
7
5
|
constructor(props) {
|
|
8
6
|
super({ ...props, type: TriggerType.Block, data: props.data });
|
|
@@ -16,23 +14,22 @@ class BlockTrigger extends Trigger {
|
|
|
16
14
|
throw new Error(`Trigger data is missing for block`);
|
|
17
15
|
}
|
|
18
16
|
const blockData = this.data;
|
|
19
|
-
// Validate interval
|
|
17
|
+
// Validate interval exists
|
|
20
18
|
if (blockData.interval === null || blockData.interval === undefined) {
|
|
21
19
|
throw new Error("Interval is required for block trigger");
|
|
22
20
|
}
|
|
23
|
-
// Validate interval is
|
|
21
|
+
// Validate that interval is an integer
|
|
22
|
+
if (!Number.isInteger(blockData.interval)) {
|
|
23
|
+
throw new Error(`BlockTrigger interval must be an integer, got: ${blockData.interval}`);
|
|
24
|
+
}
|
|
25
|
+
// Validate interval is positive
|
|
24
26
|
if (blockData.interval <= 0) {
|
|
25
|
-
throw new Error(
|
|
27
|
+
throw new Error(`Interval must be greater than 0`);
|
|
26
28
|
}
|
|
27
29
|
const trigger = new avs_pb.BlockTrigger();
|
|
28
30
|
const config = new avs_pb.BlockTrigger.Config();
|
|
29
31
|
config.setInterval(blockData.interval);
|
|
30
32
|
trigger.setConfig(config);
|
|
31
|
-
// Use utility function to convert input field to protobuf format
|
|
32
|
-
const inputValue = convertInputToProtobuf(this.input);
|
|
33
|
-
if (inputValue) {
|
|
34
|
-
trigger.setInput(inputValue);
|
|
35
|
-
}
|
|
36
33
|
request.setBlock(trigger);
|
|
37
34
|
return request;
|
|
38
35
|
}
|
|
@@ -40,25 +37,18 @@ class BlockTrigger extends Trigger {
|
|
|
40
37
|
// Convert the raw object to TriggerProps, which should keep name and id
|
|
41
38
|
const obj = raw.toObject();
|
|
42
39
|
let data = { interval: 0 };
|
|
43
|
-
let input = undefined;
|
|
44
40
|
if (raw.getBlock() && raw.getBlock().hasConfig()) {
|
|
45
41
|
const config = raw.getBlock().getConfig();
|
|
46
42
|
if (config) {
|
|
47
43
|
data = {
|
|
48
|
-
interval: config.getInterval() || 0
|
|
44
|
+
interval: config.getInterval() || 0,
|
|
49
45
|
};
|
|
50
46
|
}
|
|
51
|
-
// Use utility function to extract input field from protobuf format
|
|
52
|
-
const blockTrigger = raw.getBlock();
|
|
53
|
-
if (blockTrigger.hasInput()) {
|
|
54
|
-
input = extractInputFromProtobuf(blockTrigger.getInput());
|
|
55
|
-
}
|
|
56
47
|
}
|
|
57
48
|
return new BlockTrigger({
|
|
58
49
|
...obj,
|
|
59
50
|
type: TriggerType.Block,
|
|
60
51
|
data: data,
|
|
61
|
-
input: input,
|
|
62
52
|
});
|
|
63
53
|
}
|
|
64
54
|
/**
|
|
@@ -76,7 +66,15 @@ class BlockTrigger extends Trigger {
|
|
|
76
66
|
*/
|
|
77
67
|
static fromOutputData(outputData) {
|
|
78
68
|
const blockOutput = outputData.getBlockTrigger();
|
|
79
|
-
|
|
69
|
+
if (!blockOutput)
|
|
70
|
+
return null;
|
|
71
|
+
// Extract data from the new data field
|
|
72
|
+
const dataValue = blockOutput.getData();
|
|
73
|
+
if (!dataValue)
|
|
74
|
+
return null;
|
|
75
|
+
// Convert the Value to JavaScript object
|
|
76
|
+
const result = dataValue.toJavaScript();
|
|
77
|
+
return result;
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
80
|
export default BlockTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/cron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/cron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAE5B,cAAM,WAAY,SAAQ,OAAO;gBACnB,KAAK,EAAE,gBAAgB;IAInC,SAAS,IAAI,MAAM,CAAC,WAAW;IAgC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,WAAW;IAuBzD;;;;OAIG;IACH,SAAS,IAAI,iBAAiB,GAAG,SAAS;IAI1C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAY9D;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
|
|
3
2
|
import Trigger from "./interface";
|
|
4
|
-
import { TriggerType } from "@avaprotocol/types";
|
|
3
|
+
import { TriggerType, } from "@avaprotocol/types";
|
|
5
4
|
class CronTrigger extends Trigger {
|
|
6
5
|
constructor(props) {
|
|
7
6
|
super({ ...props, type: TriggerType.Cron, data: props.data });
|
|
@@ -27,16 +26,6 @@ class CronTrigger extends Trigger {
|
|
|
27
26
|
const config = new avs_pb.CronTrigger.Config();
|
|
28
27
|
config.setSchedulesList(cronData.schedules);
|
|
29
28
|
trigger.setConfig(config);
|
|
30
|
-
// ✨ NEW: Set input data if provided
|
|
31
|
-
if (this.input) {
|
|
32
|
-
try {
|
|
33
|
-
const inputValue = google_protobuf_struct_pb.Value.fromJavaScript(this.input);
|
|
34
|
-
trigger.setInput(inputValue);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
throw new Error(`Failed to convert input data to protobuf.Value: ${error}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
29
|
request.setCron(trigger);
|
|
41
30
|
return request;
|
|
42
31
|
}
|
|
@@ -48,23 +37,14 @@ class CronTrigger extends Trigger {
|
|
|
48
37
|
const config = raw.getCron().getConfig();
|
|
49
38
|
if (config) {
|
|
50
39
|
data = {
|
|
51
|
-
schedules: config.getSchedulesList() || []
|
|
40
|
+
schedules: config.getSchedulesList() || [],
|
|
52
41
|
};
|
|
53
42
|
}
|
|
54
43
|
}
|
|
55
|
-
// ✨ NEW: Extract input data if present
|
|
56
|
-
let input;
|
|
57
|
-
if (raw.getCron() && raw.getCron().hasInput()) {
|
|
58
|
-
const inputValue = raw.getCron().getInput();
|
|
59
|
-
if (inputValue) {
|
|
60
|
-
input = inputValue.toObject();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
44
|
return new CronTrigger({
|
|
64
45
|
...obj,
|
|
65
46
|
type: TriggerType.Cron,
|
|
66
47
|
data: data,
|
|
67
|
-
input: input, // ✨ NEW: Include input data
|
|
68
48
|
});
|
|
69
49
|
}
|
|
70
50
|
/**
|
|
@@ -85,12 +65,13 @@ class CronTrigger extends Trigger {
|
|
|
85
65
|
const cronOutput = outputData.getCronTrigger();
|
|
86
66
|
if (!cronOutput)
|
|
87
67
|
return null;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
68
|
+
// Extract data from the new data field
|
|
69
|
+
const dataValue = cronOutput.getData();
|
|
70
|
+
if (!dataValue)
|
|
71
|
+
return null;
|
|
72
|
+
// Convert the Value to JavaScript object
|
|
73
|
+
const result = dataValue.toJavaScript();
|
|
74
|
+
return result;
|
|
94
75
|
}
|
|
95
76
|
}
|
|
96
77
|
export default CronTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAIlB,MAAM,oBAAoB,CAAC;AAkD5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAIlB,MAAM,oBAAoB,CAAC;AAkD5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAkG/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAqF1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CA0B9D;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
2
|
import Trigger from "./interface";
|
|
3
3
|
import { TriggerType, } from "@avaprotocol/types";
|
|
4
|
-
import {
|
|
4
|
+
import { convertProtobufValueToJs, } from "../../utils";
|
|
5
5
|
// Ref: https://github.com/AvaProtocol/EigenLayer-AVS/issues/94
|
|
6
6
|
// The trigger is an array of Condition, which can be topics, dateRage, etc.
|
|
7
7
|
// We imply or operator among all conditions.
|
|
@@ -119,11 +119,6 @@ class EventTrigger extends Trigger {
|
|
|
119
119
|
});
|
|
120
120
|
config.setQueriesList(queryMessages);
|
|
121
121
|
trigger.setConfig(config);
|
|
122
|
-
// Convert input field to protobuf format and set on EventTrigger
|
|
123
|
-
const inputValue = convertInputToProtobuf(this.input);
|
|
124
|
-
if (inputValue) {
|
|
125
|
-
trigger.setInput(inputValue);
|
|
126
|
-
}
|
|
127
122
|
request.setEvent(trigger);
|
|
128
123
|
return request;
|
|
129
124
|
}
|
|
@@ -131,7 +126,6 @@ class EventTrigger extends Trigger {
|
|
|
131
126
|
// Convert the raw object to TriggerProps, which should keep name and id
|
|
132
127
|
const obj = raw.toObject();
|
|
133
128
|
let data = { queries: [] };
|
|
134
|
-
let input = undefined;
|
|
135
129
|
if (raw.getEvent() && raw.getEvent().hasConfig()) {
|
|
136
130
|
const config = raw.getEvent().getConfig();
|
|
137
131
|
if (config) {
|
|
@@ -187,16 +181,11 @@ class EventTrigger extends Trigger {
|
|
|
187
181
|
}
|
|
188
182
|
data = { queries: queries };
|
|
189
183
|
}
|
|
190
|
-
// Extract input data if present
|
|
191
|
-
if (raw.getEvent().hasInput()) {
|
|
192
|
-
input = extractInputFromProtobuf(raw.getEvent().getInput());
|
|
193
|
-
}
|
|
194
184
|
}
|
|
195
185
|
return new EventTrigger({
|
|
196
186
|
...obj,
|
|
197
187
|
type: TriggerType.Event,
|
|
198
188
|
data: data,
|
|
199
|
-
input: input,
|
|
200
189
|
});
|
|
201
190
|
}
|
|
202
191
|
/**
|
|
@@ -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,MAAM,aAAa,CAAC;AAClC,OAAO,
|
|
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,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,sBAAsB,EACtB,qBAAqB,EAGtB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAIxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAsB/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;CAY9D;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
2
|
import Trigger from "./interface";
|
|
3
|
-
import { TriggerType } from "@avaprotocol/types";
|
|
4
|
-
import { convertInputToProtobuf, extractInputFromProtobuf } from "../../utils";
|
|
3
|
+
import { TriggerType, } from "@avaprotocol/types";
|
|
5
4
|
// Required props for constructor: id, name, type and data: { epochsList }
|
|
6
5
|
class FixedTimeTrigger extends Trigger {
|
|
7
6
|
constructor(props) {
|
|
@@ -19,11 +18,6 @@ class FixedTimeTrigger extends Trigger {
|
|
|
19
18
|
const config = new avs_pb.FixedTimeTrigger.Config();
|
|
20
19
|
config.setEpochsList(this.data.epochsList || []);
|
|
21
20
|
trigger.setConfig(config);
|
|
22
|
-
// Convert input field to protobuf format and set on FixedTimeTrigger
|
|
23
|
-
const inputValue = convertInputToProtobuf(this.input);
|
|
24
|
-
if (inputValue) {
|
|
25
|
-
trigger.setInput(inputValue);
|
|
26
|
-
}
|
|
27
21
|
request.setFixedTime(trigger);
|
|
28
22
|
return request;
|
|
29
23
|
}
|
|
@@ -31,24 +25,18 @@ class FixedTimeTrigger extends Trigger {
|
|
|
31
25
|
// Convert the raw object to TriggerProps, which should keep name and id
|
|
32
26
|
const obj = raw.toObject();
|
|
33
27
|
let data = { epochsList: [] };
|
|
34
|
-
let input = undefined;
|
|
35
28
|
if (raw.getFixedTime() && raw.getFixedTime().hasConfig()) {
|
|
36
29
|
const config = raw.getFixedTime().getConfig();
|
|
37
30
|
if (config) {
|
|
38
31
|
data = {
|
|
39
|
-
epochsList: config.getEpochsList() || []
|
|
32
|
+
epochsList: config.getEpochsList() || [],
|
|
40
33
|
};
|
|
41
34
|
}
|
|
42
|
-
// Extract input data if present
|
|
43
|
-
if (raw.getFixedTime().hasInput()) {
|
|
44
|
-
input = extractInputFromProtobuf(raw.getFixedTime().getInput());
|
|
45
|
-
}
|
|
46
35
|
}
|
|
47
36
|
return new FixedTimeTrigger({
|
|
48
37
|
...obj,
|
|
49
38
|
type: TriggerType.FixedTime,
|
|
50
39
|
data: data,
|
|
51
|
-
input: input,
|
|
52
40
|
});
|
|
53
41
|
}
|
|
54
42
|
/**
|
|
@@ -69,12 +57,13 @@ class FixedTimeTrigger extends Trigger {
|
|
|
69
57
|
const fixedTimeOutput = outputData.getFixedTimeTrigger();
|
|
70
58
|
if (!fixedTimeOutput)
|
|
71
59
|
return null;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
// Extract data from the new data field
|
|
61
|
+
const dataValue = fixedTimeOutput.getData();
|
|
62
|
+
if (!dataValue)
|
|
63
|
+
return null;
|
|
64
|
+
// Convert the Value to JavaScript object
|
|
65
|
+
const result = dataValue.toJavaScript();
|
|
66
|
+
return result;
|
|
78
67
|
}
|
|
79
68
|
}
|
|
80
69
|
export default FixedTimeTrigger;
|
|
@@ -6,13 +6,13 @@ export default abstract class Trigger implements TriggerProps {
|
|
|
6
6
|
type: TriggerType;
|
|
7
7
|
data: TriggerData;
|
|
8
8
|
output?: TriggerOutput;
|
|
9
|
-
input?: Record<string, any>;
|
|
10
9
|
/**
|
|
11
10
|
* Create an instance of Trigger from user inputs
|
|
12
11
|
* @param props
|
|
13
12
|
*/
|
|
14
13
|
constructor(props: TriggerProps);
|
|
15
14
|
toRequest(): avs_pb.TaskTrigger;
|
|
15
|
+
static fromResponse(raw: avs_pb.TaskTrigger): Trigger;
|
|
16
16
|
getOutput(): TriggerOutput | undefined;
|
|
17
17
|
toJson(): TriggerProps;
|
|
18
18
|
}
|
|
@@ -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;
|
|
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,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACd,MAAM,oBAAoB,CAAC;AAG5B,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,OAAQ,YAAW,YAAY;IAC3D,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;IAGvB;;;OAGG;gBACS,KAAK,EAAE,YAAY;IAQ/B,SAAS,IAAI,MAAM,CAAC,WAAW;IAI/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,OAAO;IASrD,SAAS,IAAI,aAAa,GAAG,SAAS;IAItC,MAAM,IAAI,YAAY;CASvB"}
|
|
@@ -9,11 +9,17 @@ export default class Trigger {
|
|
|
9
9
|
this.type = props.type;
|
|
10
10
|
this.data = props.data;
|
|
11
11
|
this.output = props.output;
|
|
12
|
-
this.input = props.input;
|
|
13
12
|
}
|
|
14
13
|
toRequest() {
|
|
15
14
|
throw new Error("Method not implemented.");
|
|
16
15
|
}
|
|
16
|
+
static fromResponse(raw) {
|
|
17
|
+
// Convert the raw object to TriggerProps
|
|
18
|
+
const obj = raw.toObject();
|
|
19
|
+
return new this({
|
|
20
|
+
...obj,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
17
23
|
getOutput() {
|
|
18
24
|
return this.output;
|
|
19
25
|
}
|
|
@@ -24,7 +30,6 @@ export default class Trigger {
|
|
|
24
30
|
type: this.type,
|
|
25
31
|
data: this.data,
|
|
26
32
|
output: this.output,
|
|
27
|
-
input: this.input,
|
|
28
33
|
};
|
|
29
34
|
}
|
|
30
35
|
}
|
|
@@ -2,12 +2,9 @@ import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
|
2
2
|
import Trigger from "./interface";
|
|
3
3
|
import { ManualTriggerProps } from "@avaprotocol/types";
|
|
4
4
|
declare class ManualTrigger extends Trigger {
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
pathParams?: Record<string, string>;
|
|
7
5
|
constructor(props: ManualTriggerProps);
|
|
8
6
|
toRequest(): avs_pb.TaskTrigger;
|
|
9
7
|
static fromResponse(raw: avs_pb.TaskTrigger): ManualTrigger;
|
|
10
|
-
getInputVariables(): Record<string, unknown> | null;
|
|
11
8
|
/**
|
|
12
9
|
* Extract output data from RunTriggerResp for manual triggers
|
|
13
10
|
* @param outputData - The RunTriggerResp containing manual trigger output
|
|
@@ -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,MAAM,aAAa,CAAC;AAMlC,OAAO,EAEL,kBAAkB,
|
|
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,MAAM,aAAa,CAAC;AAMlC,OAAO,EAEL,kBAAkB,EAGnB,MAAM,oBAAoB,CAAC;AAE5B,cAAM,aAAc,SAAQ,OAAO;gBACrB,KAAK,EAAE,kBAAkB;IASrC,SAAS,IAAI,MAAM,CAAC,WAAW;IAgE/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,aAAa;IA4C3D;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,OAAO;CAuBlE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -10,8 +10,6 @@ class ManualTrigger extends Trigger {
|
|
|
10
10
|
data: props.data,
|
|
11
11
|
input: props.input,
|
|
12
12
|
});
|
|
13
|
-
this.headers = props.headers;
|
|
14
|
-
this.pathParams = props.pathParams;
|
|
15
13
|
}
|
|
16
14
|
toRequest() {
|
|
17
15
|
const trigger = new avs_pb.TaskTrigger();
|
|
@@ -21,27 +19,39 @@ class ManualTrigger extends Trigger {
|
|
|
21
19
|
// Create ManualTrigger with proper config structure
|
|
22
20
|
const manualTrigger = new avs_pb.ManualTrigger();
|
|
23
21
|
const config = new avs_pb.ManualTrigger.Config();
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
if (dataToSend === null || dataToSend === undefined) {
|
|
22
|
+
// Handle ManualTriggerDataType structure: { data: actualData, headers?: {}, pathParams?: {} }
|
|
23
|
+
if (this.data === null || this.data === undefined) {
|
|
27
24
|
throw new Error("ManualTrigger data is required");
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
// Extract data, headers, and pathParams from ManualTriggerDataType
|
|
27
|
+
let actualData = this.data;
|
|
28
|
+
let headers = {};
|
|
29
|
+
let pathParams = {};
|
|
30
|
+
if (typeof this.data === 'object' && this.data !== null && !Array.isArray(this.data)) {
|
|
31
|
+
const dataObj = this.data;
|
|
32
|
+
// If this.data has the ManualTriggerDataType structure
|
|
33
|
+
if ('data' in dataObj) {
|
|
34
|
+
actualData = dataObj.data;
|
|
35
|
+
headers = dataObj.headers || {};
|
|
36
|
+
pathParams = dataObj.pathParams || {};
|
|
37
|
+
}
|
|
38
|
+
// Otherwise, use this.data directly as the data content
|
|
39
|
+
}
|
|
40
|
+
const dataValue = convertInputToProtobuf(actualData);
|
|
41
|
+
if (!dataValue) {
|
|
31
42
|
throw new Error("Failed to convert ManualTrigger data to protobuf format");
|
|
32
43
|
}
|
|
33
|
-
config.setData(
|
|
34
|
-
// Set headers
|
|
35
|
-
if (
|
|
44
|
+
config.setData(dataValue);
|
|
45
|
+
// Set headers and pathParams in the config for execution step debugging
|
|
46
|
+
if (Object.keys(headers).length > 0) {
|
|
36
47
|
const headersMap = config.getHeadersMap();
|
|
37
|
-
Object.entries(
|
|
48
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
38
49
|
headersMap.set(key, value);
|
|
39
50
|
});
|
|
40
51
|
}
|
|
41
|
-
|
|
42
|
-
if (this.pathParams && Object.keys(this.pathParams).length > 0) {
|
|
52
|
+
if (Object.keys(pathParams).length > 0) {
|
|
43
53
|
const pathParamsMap = config.getPathparamsMap();
|
|
44
|
-
Object.entries(
|
|
54
|
+
Object.entries(pathParams).forEach(([key, value]) => {
|
|
45
55
|
pathParamsMap.set(key, value);
|
|
46
56
|
});
|
|
47
57
|
}
|
|
@@ -51,49 +61,28 @@ class ManualTrigger extends Trigger {
|
|
|
51
61
|
}
|
|
52
62
|
static fromResponse(raw) {
|
|
53
63
|
const obj = raw.toObject();
|
|
54
|
-
let
|
|
55
|
-
const input = undefined;
|
|
56
|
-
let headers = undefined;
|
|
57
|
-
let pathParams = undefined;
|
|
64
|
+
let actualData = null;
|
|
58
65
|
const manualTrigger = raw.getManual();
|
|
59
66
|
if (manualTrigger) {
|
|
60
67
|
const config = manualTrigger.getConfig();
|
|
61
68
|
if (config) {
|
|
62
|
-
// Extract data
|
|
69
|
+
// Extract data only - headers and pathParams are handled by base class
|
|
63
70
|
if (config.hasData()) {
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
// Extract headers - direct protobuf map to object mapping
|
|
67
|
-
const headersMapProto = config.getHeadersMap();
|
|
68
|
-
if (headersMapProto && headersMapProto.getLength() > 0) {
|
|
69
|
-
headers = {};
|
|
70
|
-
headersMapProto.forEach((value, key) => {
|
|
71
|
-
headers[key] = value;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// Extract pathParams - direct protobuf map to object mapping
|
|
75
|
-
const pathParamsMapProto = config.getPathparamsMap();
|
|
76
|
-
if (pathParamsMapProto && pathParamsMapProto.getLength() > 0) {
|
|
77
|
-
pathParams = {};
|
|
78
|
-
pathParamsMapProto.forEach((value, key) => {
|
|
79
|
-
pathParams[key] = value;
|
|
80
|
-
});
|
|
71
|
+
actualData = extractInputFromProtobuf(config.getData());
|
|
81
72
|
}
|
|
82
73
|
}
|
|
83
74
|
}
|
|
75
|
+
// Create ManualTriggerDataType structure with just the data
|
|
76
|
+
// Headers and pathParams are available in baseInput for execution step display
|
|
77
|
+
const manualTriggerData = {
|
|
78
|
+
data: actualData,
|
|
79
|
+
};
|
|
84
80
|
return new ManualTrigger({
|
|
85
81
|
...obj,
|
|
86
82
|
type: TriggerType.Manual,
|
|
87
|
-
data:
|
|
88
|
-
input: input,
|
|
89
|
-
headers: headers,
|
|
90
|
-
pathParams: pathParams,
|
|
83
|
+
data: manualTriggerData,
|
|
91
84
|
});
|
|
92
85
|
}
|
|
93
|
-
getInputVariables() {
|
|
94
|
-
// Return input variables that can be referenced by other nodes
|
|
95
|
-
return this.input;
|
|
96
|
-
}
|
|
97
86
|
/**
|
|
98
87
|
* Extract output data from RunTriggerResp for manual triggers
|
|
99
88
|
* @param outputData - The RunTriggerResp containing manual trigger output
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/sdk-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.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.4.0",
|
|
35
35
|
"@grpc/grpc-js": "^1.11.3",
|
|
36
36
|
"@grpc/proto-loader": "^0.7.13",
|
|
37
37
|
"dotenv": "^16.4.5",
|