@avaprotocol/sdk-js 2.16.0 → 4.0.0-dev.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 +17 -0
- package/dist/index.d.ts +1 -370
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +736 -22391
- package/dist/index.mjs +698 -22422
- package/dist/v4/auth.d.ts +54 -0
- package/dist/v4/auth.d.ts.map +1 -0
- package/dist/v4/auth.js +70 -0
- package/dist/v4/builders/nodes.d.ts +103 -0
- package/dist/v4/builders/nodes.d.ts.map +1 -0
- package/dist/v4/builders/nodes.js +132 -0
- package/dist/v4/builders/triggers.d.ts +66 -0
- package/dist/v4/builders/triggers.d.ts.map +1 -0
- package/dist/v4/builders/triggers.js +74 -0
- package/dist/v4/chains.d.ts +16 -0
- package/dist/v4/chains.d.ts.map +1 -0
- package/dist/v4/chains.js +23 -0
- package/dist/v4/client.d.ts +60 -0
- package/dist/v4/client.d.ts.map +1 -0
- package/dist/v4/client.js +53 -0
- package/dist/v4/index.d.ts +18 -0
- package/dist/v4/index.d.ts.map +1 -0
- package/dist/v4/index.js +23 -0
- package/dist/v4/internal/errors.d.ts +36 -0
- package/dist/v4/internal/errors.d.ts.map +1 -0
- package/dist/v4/internal/errors.js +32 -0
- package/dist/v4/internal/transport.d.ts +64 -0
- package/dist/v4/internal/transport.d.ts.map +1 -0
- package/dist/v4/internal/transport.js +133 -0
- package/dist/v4/resources/auth.d.ts +39 -0
- package/dist/v4/resources/auth.d.ts.map +1 -0
- package/dist/v4/resources/auth.js +53 -0
- package/dist/v4/resources/executions.d.ts +68 -0
- package/dist/v4/resources/executions.d.ts.map +1 -0
- package/dist/v4/resources/executions.js +126 -0
- package/dist/v4/resources/health.d.ts +9 -0
- package/dist/v4/resources/health.d.ts.map +1 -0
- package/dist/v4/resources/health.js +9 -0
- package/dist/v4/resources/nodes.d.ts +9 -0
- package/dist/v4/resources/nodes.d.ts.map +1 -0
- package/dist/v4/resources/nodes.js +13 -0
- package/dist/v4/resources/operators.d.ts +9 -0
- package/dist/v4/resources/operators.d.ts.map +1 -0
- package/dist/v4/resources/operators.js +9 -0
- package/dist/v4/resources/secrets.d.ts +24 -0
- package/dist/v4/resources/secrets.d.ts.map +1 -0
- package/dist/v4/resources/secrets.js +28 -0
- package/dist/v4/resources/tokens.d.ts +16 -0
- package/dist/v4/resources/tokens.d.ts.map +1 -0
- package/dist/v4/resources/tokens.js +17 -0
- package/dist/v4/resources/triggers.d.ts +9 -0
- package/dist/v4/resources/triggers.d.ts.map +1 -0
- package/dist/v4/resources/triggers.js +13 -0
- package/dist/v4/resources/wallets.d.ts +25 -0
- package/dist/v4/resources/wallets.d.ts.map +1 -0
- package/dist/v4/resources/wallets.js +45 -0
- package/dist/v4/resources/workflows.d.ts +54 -0
- package/dist/v4/resources/workflows.d.ts.map +1 -0
- package/dist/v4/resources/workflows.js +81 -0
- package/package.json +4 -12
- package/dist/auth.d.ts +0 -2
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -10
- package/dist/config.d.ts +0 -9
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -19
- package/dist/models/edge.d.ts +0 -12
- package/dist/models/edge.d.ts.map +0 -1
- package/dist/models/edge.js +0 -19
- package/dist/models/execution.d.ts +0 -20
- package/dist/models/execution.d.ts.map +0 -1
- package/dist/models/execution.js +0 -97
- package/dist/models/node/balance.d.ts +0 -17
- package/dist/models/node/balance.d.ts.map +0 -1
- package/dist/models/node/balance.js +0 -78
- package/dist/models/node/branch.d.ts +0 -11
- package/dist/models/node/branch.d.ts.map +0 -1
- package/dist/models/node/branch.js +0 -63
- package/dist/models/node/contractRead.d.ts +0 -17
- package/dist/models/node/contractRead.d.ts.map +0 -1
- package/dist/models/node/contractRead.js +0 -91
- package/dist/models/node/contractWrite.d.ts +0 -17
- package/dist/models/node/contractWrite.d.ts.map +0 -1
- package/dist/models/node/contractWrite.js +0 -102
- package/dist/models/node/customCode.d.ts +0 -20
- package/dist/models/node/customCode.d.ts.map +0 -1
- package/dist/models/node/customCode.js +0 -74
- package/dist/models/node/ethTransfer.d.ts +0 -20
- package/dist/models/node/ethTransfer.d.ts.map +0 -1
- package/dist/models/node/ethTransfer.js +0 -58
- package/dist/models/node/factory.d.ts +0 -24
- package/dist/models/node/factory.d.ts.map +0 -1
- package/dist/models/node/factory.js +0 -108
- package/dist/models/node/filter.d.ts +0 -11
- package/dist/models/node/filter.d.ts.map +0 -1
- package/dist/models/node/filter.js +0 -57
- package/dist/models/node/graphqlQuery.d.ts +0 -21
- package/dist/models/node/graphqlQuery.d.ts.map +0 -1
- package/dist/models/node/graphqlQuery.js +0 -74
- package/dist/models/node/interface.d.ts +0 -20
- package/dist/models/node/interface.d.ts.map +0 -1
- package/dist/models/node/interface.js +0 -58
- package/dist/models/node/loop.d.ts +0 -15
- package/dist/models/node/loop.d.ts.map +0 -1
- package/dist/models/node/loop.js +0 -235
- package/dist/models/node/restApi.d.ts +0 -23
- package/dist/models/node/restApi.d.ts.map +0 -1
- package/dist/models/node/restApi.js +0 -84
- package/dist/models/secret.d.ts +0 -16
- package/dist/models/secret.d.ts.map +0 -1
- package/dist/models/secret.js +0 -28
- package/dist/models/step.d.ts +0 -33
- package/dist/models/step.d.ts.map +0 -1
- package/dist/models/step.js +0 -287
- package/dist/models/trigger/block.d.ts +0 -21
- package/dist/models/trigger/block.d.ts.map +0 -1
- package/dist/models/trigger/block.js +0 -81
- package/dist/models/trigger/cron.d.ts +0 -23
- package/dist/models/trigger/cron.d.ts.map +0 -1
- package/dist/models/trigger/cron.js +0 -77
- package/dist/models/trigger/event.d.ts +0 -22
- package/dist/models/trigger/event.d.ts.map +0 -1
- package/dist/models/trigger/event.js +0 -244
- package/dist/models/trigger/factory.d.ts +0 -27
- package/dist/models/trigger/factory.d.ts.map +0 -1
- package/dist/models/trigger/factory.js +0 -73
- package/dist/models/trigger/fixedTime.d.ts +0 -23
- package/dist/models/trigger/fixedTime.d.ts.map +0 -1
- package/dist/models/trigger/fixedTime.js +0 -69
- package/dist/models/trigger/interface.d.ts +0 -19
- package/dist/models/trigger/interface.d.ts.map +0 -1
- package/dist/models/trigger/interface.js +0 -35
- package/dist/models/trigger/manual.d.ts +0 -16
- package/dist/models/trigger/manual.d.ts.map +0 -1
- package/dist/models/trigger/manual.js +0 -117
- package/dist/models/workflow.d.ts +0 -53
- package/dist/models/workflow.d.ts.map +0 -1
- package/dist/models/workflow.js +0 -219
- package/dist/utils.d.ts +0 -82
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -286
package/dist/models/edge.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
class Edge {
|
|
3
|
-
constructor(edge) {
|
|
4
|
-
this.id = edge.id;
|
|
5
|
-
this.source = edge.source;
|
|
6
|
-
this.target = edge.target;
|
|
7
|
-
}
|
|
8
|
-
static fromResponse(edge) {
|
|
9
|
-
return new Edge(edge.toObject());
|
|
10
|
-
}
|
|
11
|
-
toRequest() {
|
|
12
|
-
const edge = new avs_pb.TaskEdge();
|
|
13
|
-
edge.setId(this.id);
|
|
14
|
-
edge.setSource(this.source);
|
|
15
|
-
edge.setTarget(this.target);
|
|
16
|
-
return edge;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export default Edge;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import { ExecutionProps, ExecutionStatus, type Fee, type NodeCOGS, type ValueFee } from "@avaprotocol/types";
|
|
3
|
-
import Step from "./step";
|
|
4
|
-
declare class Execution implements ExecutionProps {
|
|
5
|
-
id: string;
|
|
6
|
-
startAt: number;
|
|
7
|
-
endAt: number;
|
|
8
|
-
status: ExecutionStatus;
|
|
9
|
-
error: string;
|
|
10
|
-
index: number;
|
|
11
|
-
steps: Step[];
|
|
12
|
-
executionFee?: Fee;
|
|
13
|
-
cogs: NodeCOGS[];
|
|
14
|
-
valueFee?: ValueFee;
|
|
15
|
-
constructor(props: ExecutionProps);
|
|
16
|
-
toJson(): ExecutionProps;
|
|
17
|
-
static fromResponse(execution: avs_pb.Execution): Execution;
|
|
18
|
-
}
|
|
19
|
-
export default Execution;
|
|
20
|
-
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/models/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EACL,cAAc,EAEd,eAAe,EACf,KAAK,GAAG,EAER,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAwD1B,cAAM,SAAU,YAAW,cAAc;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;gBAER,KAAK,EAAE,cAAc;IAajC,MAAM,IAAI,cAAc;IAexB,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS;CAgB5D;AAED,eAAe,SAAS,CAAC"}
|
package/dist/models/execution.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import { ExecutionStatus, } from "@avaprotocol/types";
|
|
3
|
-
import Step from "./step";
|
|
4
|
-
/**
|
|
5
|
-
* Convert protobuf ExecutionStatus to types ExecutionStatus
|
|
6
|
-
*/
|
|
7
|
-
function convertProtobufExecutionStatusToTypes(protobufStatus) {
|
|
8
|
-
switch (protobufStatus) {
|
|
9
|
-
case avs_pb.ExecutionStatus.EXECUTION_STATUS_PENDING:
|
|
10
|
-
return ExecutionStatus.Pending;
|
|
11
|
-
case avs_pb.ExecutionStatus.EXECUTION_STATUS_SUCCESS:
|
|
12
|
-
return ExecutionStatus.Success;
|
|
13
|
-
case avs_pb.ExecutionStatus.EXECUTION_STATUS_FAILED:
|
|
14
|
-
return ExecutionStatus.Failed;
|
|
15
|
-
case avs_pb.ExecutionStatus.EXECUTION_STATUS_PARTIAL_SUCCESS:
|
|
16
|
-
return ExecutionStatus.PartialSuccess;
|
|
17
|
-
case avs_pb.ExecutionStatus.EXECUTION_STATUS_UNSPECIFIED:
|
|
18
|
-
default:
|
|
19
|
-
return ExecutionStatus.Unspecified;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function convertFee(feePb) {
|
|
23
|
-
if (!feePb)
|
|
24
|
-
return undefined;
|
|
25
|
-
return {
|
|
26
|
-
amount: feePb.getAmount(),
|
|
27
|
-
unit: feePb.getUnit(),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function convertNodeCOGS(cogsPb) {
|
|
31
|
-
return {
|
|
32
|
-
nodeId: cogsPb.getNodeId(),
|
|
33
|
-
costType: cogsPb.getCostType(),
|
|
34
|
-
fee: convertFee(cogsPb.getFee()) || { amount: "0", unit: "WEI" },
|
|
35
|
-
gasUnits: cogsPb.getGasUnits() || undefined,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function convertExecutionTier(tier) {
|
|
39
|
-
return avs_pb.ExecutionTier[tier] ?? tier.toString();
|
|
40
|
-
}
|
|
41
|
-
function convertValueFee(valuePb) {
|
|
42
|
-
if (!valuePb)
|
|
43
|
-
return undefined;
|
|
44
|
-
return {
|
|
45
|
-
fee: convertFee(valuePb.getFee()) || { amount: "0", unit: "PERCENTAGE" },
|
|
46
|
-
tier: convertExecutionTier(valuePb.getTier()),
|
|
47
|
-
valueBase: valuePb.getValueBase() || undefined,
|
|
48
|
-
classificationMethod: valuePb.getClassificationMethod(),
|
|
49
|
-
confidence: valuePb.getConfidence(),
|
|
50
|
-
reason: valuePb.getReason(),
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
class Execution {
|
|
54
|
-
constructor(props) {
|
|
55
|
-
this.id = props.id;
|
|
56
|
-
this.startAt = props.startAt;
|
|
57
|
-
this.endAt = props.endAt;
|
|
58
|
-
this.status = props.status;
|
|
59
|
-
this.error = props.error;
|
|
60
|
-
this.index = props.index;
|
|
61
|
-
this.steps = props.steps.map(s => new Step(s));
|
|
62
|
-
this.executionFee = props.executionFee;
|
|
63
|
-
this.cogs = props.cogs || [];
|
|
64
|
-
this.valueFee = props.valueFee;
|
|
65
|
-
}
|
|
66
|
-
toJson() {
|
|
67
|
-
return {
|
|
68
|
-
id: this.id,
|
|
69
|
-
startAt: this.startAt,
|
|
70
|
-
endAt: this.endAt,
|
|
71
|
-
status: this.status,
|
|
72
|
-
error: this.error,
|
|
73
|
-
index: this.index,
|
|
74
|
-
steps: this.steps.map(step => step.toJson()),
|
|
75
|
-
...(this.executionFee && { executionFee: this.executionFee }),
|
|
76
|
-
cogs: this.cogs,
|
|
77
|
-
...(this.valueFee && { valueFee: this.valueFee }),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
static fromResponse(execution) {
|
|
81
|
-
return new Execution({
|
|
82
|
-
id: execution.getId(),
|
|
83
|
-
startAt: execution.getStartAt(),
|
|
84
|
-
endAt: execution.getEndAt(),
|
|
85
|
-
status: convertProtobufExecutionStatusToTypes(execution.getStatus()),
|
|
86
|
-
error: execution.getError(),
|
|
87
|
-
index: execution.getIndex(),
|
|
88
|
-
executionFee: convertFee(execution.getExecutionFee()),
|
|
89
|
-
cogs: execution.getCogsList().map(convertNodeCOGS),
|
|
90
|
-
valueFee: convertValueFee(execution.getValueFee()),
|
|
91
|
-
steps: execution
|
|
92
|
-
.getStepsList()
|
|
93
|
-
.map((step) => Step.fromResponse(step)),
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export default Execution;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { BalanceNodeData, BalanceNodeProps } from "@avaprotocol/types";
|
|
4
|
-
declare class BalanceNode extends Node {
|
|
5
|
-
constructor(props: BalanceNodeProps);
|
|
6
|
-
/**
|
|
7
|
-
* Create a protobuf BalanceNode from config data
|
|
8
|
-
* @param configData - The configuration data for the balance node
|
|
9
|
-
* @returns Configured avs_pb.BalanceNode
|
|
10
|
-
*/
|
|
11
|
-
static createProtobufNode(configData: BalanceNodeData): avs_pb.BalanceNode;
|
|
12
|
-
static fromResponse(raw: avs_pb.TaskNode): BalanceNode;
|
|
13
|
-
toRequest(): avs_pb.TaskNode;
|
|
14
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown | null;
|
|
15
|
-
}
|
|
16
|
-
export default BalanceNode;
|
|
17
|
-
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../../src/models/node/balance.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAEL,eAAe,EACf,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,WAAY,SAAQ,IAAI;gBAChB,KAAK,EAAE,gBAAgB;IAInC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,eAAe,GAAG,MAAM,CAAC,WAAW;IA+B1E,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,WAAW;IAwBtD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAc5B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,qBAAqB,GACvC,OAAO,GAAG,IAAI;CAWlB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { NodeType, } from "@avaprotocol/types";
|
|
4
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
5
|
-
// Required props for constructor: id, name, type and data
|
|
6
|
-
class BalanceNode extends Node {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
super({ ...props, type: NodeType.Balance, data: props.data });
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Create a protobuf BalanceNode from config data
|
|
12
|
-
* @param configData - The configuration data for the balance node
|
|
13
|
-
* @returns Configured avs_pb.BalanceNode
|
|
14
|
-
*/
|
|
15
|
-
static createProtobufNode(configData) {
|
|
16
|
-
const node = new avs_pb.BalanceNode();
|
|
17
|
-
const config = new avs_pb.BalanceNode.Config();
|
|
18
|
-
config.setAddress(configData.address);
|
|
19
|
-
config.setChain(configData.chain);
|
|
20
|
-
if (configData.includeSpam !== undefined) {
|
|
21
|
-
config.setIncludeSpam(configData.includeSpam);
|
|
22
|
-
}
|
|
23
|
-
if (configData.includeZeroBalances !== undefined) {
|
|
24
|
-
config.setIncludeZeroBalances(configData.includeZeroBalances);
|
|
25
|
-
}
|
|
26
|
-
if (configData.minUsdValue !== undefined) {
|
|
27
|
-
// Convert dollars to cents for protobuf (validation happens on backend)
|
|
28
|
-
config.setMinUsdValueCents(Math.round(configData.minUsdValue * 100));
|
|
29
|
-
}
|
|
30
|
-
if (configData.tokenAddresses !== undefined &&
|
|
31
|
-
configData.tokenAddresses.length > 0) {
|
|
32
|
-
config.setTokenAddressesList(configData.tokenAddresses);
|
|
33
|
-
}
|
|
34
|
-
node.setConfig(config);
|
|
35
|
-
return node;
|
|
36
|
-
}
|
|
37
|
-
static fromResponse(raw) {
|
|
38
|
-
// Convert the raw object to BalanceNodeProps, which should keep name and id
|
|
39
|
-
const obj = raw.toObject();
|
|
40
|
-
const balanceNode = raw.getBalance();
|
|
41
|
-
const config = balanceNode.getConfig();
|
|
42
|
-
const protobufData = config.toObject();
|
|
43
|
-
// Convert protobuf data to our custom interface
|
|
44
|
-
const data = {
|
|
45
|
-
address: protobufData.address,
|
|
46
|
-
chain: protobufData.chain,
|
|
47
|
-
includeSpam: protobufData.includeSpam,
|
|
48
|
-
includeZeroBalances: protobufData.includeZeroBalances,
|
|
49
|
-
minUsdValue: protobufData.minUsdValueCents / 100,
|
|
50
|
-
tokenAddresses: protobufData.tokenAddressesList,
|
|
51
|
-
};
|
|
52
|
-
return new BalanceNode({
|
|
53
|
-
...obj,
|
|
54
|
-
type: NodeType.Balance,
|
|
55
|
-
data: data,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
toRequest() {
|
|
59
|
-
const request = new avs_pb.TaskNode();
|
|
60
|
-
request.setId(this.id);
|
|
61
|
-
request.setName(this.name);
|
|
62
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_BALANCE);
|
|
63
|
-
const node = BalanceNode.createProtobufNode(this.data);
|
|
64
|
-
request.setBalance(node);
|
|
65
|
-
return request;
|
|
66
|
-
}
|
|
67
|
-
static fromOutputData(outputData) {
|
|
68
|
-
const balanceOutput = outputData.getBalance();
|
|
69
|
-
if (!balanceOutput)
|
|
70
|
-
return null;
|
|
71
|
-
// Get the data from the data field (array of token balances)
|
|
72
|
-
const dataValue = balanceOutput.getData();
|
|
73
|
-
const balanceData = dataValue ? convertProtobufValueToJs(dataValue) : [];
|
|
74
|
-
// Return the array directly without wrapping
|
|
75
|
-
return balanceData;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
export default BalanceNode;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BranchNodeProps } from "@avaprotocol/types";
|
|
2
|
-
import Node from "./interface";
|
|
3
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
-
declare class BranchNode extends Node {
|
|
5
|
-
constructor(props: BranchNodeProps);
|
|
6
|
-
static fromResponse(raw: avs_pb.TaskNode): BranchNode;
|
|
7
|
-
toRequest(): avs_pb.TaskNode;
|
|
8
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
|
|
9
|
-
}
|
|
10
|
-
export default BranchNode;
|
|
11
|
-
//# sourceMappingURL=branch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../../src/models/node/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAKhD,cAAM,UAAW,SAAQ,IAAI;gBACf,KAAK,EAAE,eAAe;IAIlC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,UAAU;IAsBrD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAkC5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAgBrE;AACD,eAAe,UAAU,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { NodeType, } from "@avaprotocol/types";
|
|
2
|
-
import Node from "./interface";
|
|
3
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
5
|
-
// Required props for constructor: id, name, type and data: { conditions }
|
|
6
|
-
class BranchNode extends Node {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
super({ ...props, type: NodeType.Branch, data: props.data });
|
|
9
|
-
}
|
|
10
|
-
static fromResponse(raw) {
|
|
11
|
-
// Convert the raw object to BranchNodeProps, which should keep name and id
|
|
12
|
-
const obj = raw.toObject();
|
|
13
|
-
const protobufData = raw.getBranch().toObject().config;
|
|
14
|
-
// Convert protobuf data to our custom interface
|
|
15
|
-
const data = {
|
|
16
|
-
conditions: protobufData?.conditionsList?.map((condition) => ({
|
|
17
|
-
id: condition.id,
|
|
18
|
-
type: condition.type,
|
|
19
|
-
expression: condition.expression,
|
|
20
|
-
})) || [],
|
|
21
|
-
};
|
|
22
|
-
return new BranchNode({
|
|
23
|
-
...obj,
|
|
24
|
-
type: NodeType.Branch,
|
|
25
|
-
data: data,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
toRequest() {
|
|
29
|
-
const request = new avs_pb.TaskNode();
|
|
30
|
-
request.setId(this.id);
|
|
31
|
-
request.setName(this.name);
|
|
32
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_BRANCH);
|
|
33
|
-
const node = new avs_pb.BranchNode();
|
|
34
|
-
const config = new avs_pb.BranchNode.Config();
|
|
35
|
-
if (this.data.conditions &&
|
|
36
|
-
this.data.conditions.length > 0) {
|
|
37
|
-
const conditionsList = this.data.conditions.map((condition) => {
|
|
38
|
-
const conditionObj = new avs_pb.BranchNode.Condition();
|
|
39
|
-
conditionObj.setId(condition.id);
|
|
40
|
-
conditionObj.setType(condition.type);
|
|
41
|
-
conditionObj.setExpression(condition.expression);
|
|
42
|
-
return conditionObj;
|
|
43
|
-
});
|
|
44
|
-
config.setConditionsList(conditionsList);
|
|
45
|
-
}
|
|
46
|
-
node.setConfig(config);
|
|
47
|
-
request.setBranch(node);
|
|
48
|
-
return request;
|
|
49
|
-
}
|
|
50
|
-
static fromOutputData(outputData) {
|
|
51
|
-
const branchOutput = outputData.getBranch();
|
|
52
|
-
if (!branchOutput) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
// Use convertProtobufValueToJs to get clean JavaScript objects
|
|
56
|
-
const rawData = branchOutput.getData();
|
|
57
|
-
if (rawData) {
|
|
58
|
-
return convertProtobufValueToJs(rawData);
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
export default BranchNode;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { ContractReadNodeData, ContractReadNodeProps } from "@avaprotocol/types";
|
|
4
|
-
declare class ContractReadNode extends Node {
|
|
5
|
-
constructor(props: ContractReadNodeProps);
|
|
6
|
-
/**
|
|
7
|
-
* Create a protobuf ContractReadNode from config data
|
|
8
|
-
* @param configData - The configuration data for the contract read node
|
|
9
|
-
* @returns Configured avs_pb.ContractReadNode
|
|
10
|
-
*/
|
|
11
|
-
static createProtobufNode(configData: ContractReadNodeData): avs_pb.ContractReadNode;
|
|
12
|
-
static fromResponse(raw: avs_pb.TaskNode): ContractReadNode;
|
|
13
|
-
toRequest(): avs_pb.TaskNode;
|
|
14
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown | null;
|
|
15
|
-
}
|
|
16
|
-
export default ContractReadNode;
|
|
17
|
-
//# sourceMappingURL=contractRead.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contractRead.d.ts","sourceRoot":"","sources":["../../../src/models/node/contractRead.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAEL,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAIxC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CACvB,UAAU,EAAE,oBAAoB,GAC/B,MAAM,CAAC,gBAAgB;IAuC1B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IA8B3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,qBAAqB,GACvC,OAAO,GAAG,IAAI;CAUlB;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
|
|
4
|
-
import { NodeType, } from "@avaprotocol/types";
|
|
5
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
6
|
-
// Required props for constructor: id, name, type and data
|
|
7
|
-
class ContractReadNode extends Node {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
super({ ...props, type: NodeType.ContractRead, data: props.data });
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Create a protobuf ContractReadNode from config data
|
|
13
|
-
* @param configData - The configuration data for the contract read node
|
|
14
|
-
* @returns Configured avs_pb.ContractReadNode
|
|
15
|
-
*/
|
|
16
|
-
static createProtobufNode(configData) {
|
|
17
|
-
const node = new avs_pb.ContractReadNode();
|
|
18
|
-
const config = new avs_pb.ContractReadNode.Config();
|
|
19
|
-
config.setContractAddress(configData.contractAddress);
|
|
20
|
-
// Convert array to protobuf Value list
|
|
21
|
-
const abiValueList = configData.contractAbi.map((item) => {
|
|
22
|
-
const value = new google_protobuf_struct_pb.Value();
|
|
23
|
-
value.setStructValue(google_protobuf_struct_pb.Struct.fromJavaScript(item));
|
|
24
|
-
return value;
|
|
25
|
-
});
|
|
26
|
-
config.setContractAbiList(abiValueList);
|
|
27
|
-
// Handle method calls array (now required)
|
|
28
|
-
const methodCalls = configData.methodCalls;
|
|
29
|
-
methodCalls.forEach((methodCall) => {
|
|
30
|
-
const methodCallMsg = new avs_pb.ContractReadNode.MethodCall();
|
|
31
|
-
methodCallMsg.setMethodName(methodCall.methodName);
|
|
32
|
-
methodCallMsg.setMethodParamsList(methodCall.methodParams);
|
|
33
|
-
// Optional: Set callData if provided
|
|
34
|
-
if (methodCall.callData) {
|
|
35
|
-
methodCallMsg.setCallData(methodCall.callData);
|
|
36
|
-
}
|
|
37
|
-
// Optional: Set applyToFields if provided
|
|
38
|
-
if (methodCall.applyToFields) {
|
|
39
|
-
methodCallMsg.setApplyToFieldsList(methodCall.applyToFields);
|
|
40
|
-
}
|
|
41
|
-
config.addMethodCalls(methodCallMsg);
|
|
42
|
-
});
|
|
43
|
-
node.setConfig(config);
|
|
44
|
-
return node;
|
|
45
|
-
}
|
|
46
|
-
static fromResponse(raw) {
|
|
47
|
-
// Convert the raw object to ContractReadNodeProps, which should keep name and id
|
|
48
|
-
const obj = raw.toObject();
|
|
49
|
-
const contractReadNode = raw.getContractRead();
|
|
50
|
-
const config = contractReadNode.getConfig();
|
|
51
|
-
const protobufData = config.toObject();
|
|
52
|
-
// Convert protobuf data to our custom interface
|
|
53
|
-
const data = {
|
|
54
|
-
contractAddress: protobufData.contractAddress,
|
|
55
|
-
contractAbi: config
|
|
56
|
-
.getContractAbiList()
|
|
57
|
-
.map((value) => convertProtobufValueToJs(value)),
|
|
58
|
-
methodCalls: protobufData.methodCallsList?.map((call) => ({
|
|
59
|
-
methodName: call.methodName,
|
|
60
|
-
applyToFields: call.applyToFieldsList || [],
|
|
61
|
-
methodParams: call.methodParamsList || [],
|
|
62
|
-
// Only include callData if present
|
|
63
|
-
...(call.callData && { callData: call.callData }),
|
|
64
|
-
})) || [],
|
|
65
|
-
};
|
|
66
|
-
return new ContractReadNode({
|
|
67
|
-
...obj,
|
|
68
|
-
type: NodeType.ContractRead,
|
|
69
|
-
data: data,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
toRequest() {
|
|
73
|
-
const request = new avs_pb.TaskNode();
|
|
74
|
-
request.setId(this.id);
|
|
75
|
-
request.setName(this.name);
|
|
76
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_CONTRACT_READ);
|
|
77
|
-
const node = ContractReadNode.createProtobufNode(this.data);
|
|
78
|
-
request.setContractRead(node);
|
|
79
|
-
return request;
|
|
80
|
-
}
|
|
81
|
-
static fromOutputData(outputData) {
|
|
82
|
-
const contractReadOutput = outputData.getContractRead();
|
|
83
|
-
if (!contractReadOutput)
|
|
84
|
-
return null;
|
|
85
|
-
// Get the clean data from the data field (now a single flattened object)
|
|
86
|
-
const dataValue = contractReadOutput.getData();
|
|
87
|
-
const cleanData = dataValue ? convertProtobufValueToJs(dataValue) : {};
|
|
88
|
-
return cleanData;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export default ContractReadNode;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { ContractWriteNodeData, ContractWriteNodeProps } from "@avaprotocol/types";
|
|
4
|
-
declare class ContractWriteNode extends Node {
|
|
5
|
-
constructor(props: ContractWriteNodeProps);
|
|
6
|
-
/**
|
|
7
|
-
* Create a protobuf ContractWriteNode from config data
|
|
8
|
-
* @param configData - The configuration data for the contract write node
|
|
9
|
-
* @returns Configured avs_pb.ContractWriteNode
|
|
10
|
-
*/
|
|
11
|
-
static createProtobufNode(configData: ContractWriteNodeData): avs_pb.ContractWriteNode;
|
|
12
|
-
static fromResponse(raw: avs_pb.TaskNode): ContractWriteNode;
|
|
13
|
-
toRequest(): avs_pb.TaskNode;
|
|
14
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
|
|
15
|
-
}
|
|
16
|
-
export default ContractWriteNode;
|
|
17
|
-
//# sourceMappingURL=contractWrite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contractWrite.d.ts","sourceRoot":"","sources":["../../../src/models/node/contractWrite.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAEL,qBAAqB,EACrB,sBAAsB,EAEvB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,iBAAkB,SAAQ,IAAI;gBACtB,KAAK,EAAE,sBAAsB;IAIzC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,CAAC,iBAAiB;IA6CtF,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,iBAAiB;IAmC5D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAYrE;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";
|
|
4
|
-
import { NodeType, } from "@avaprotocol/types";
|
|
5
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
6
|
-
// Required props for constructor: id, name, type and data: { config: { contractAddress, callData, contractAbi, methodCallsList? } }
|
|
7
|
-
class ContractWriteNode extends Node {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
super({ ...props, type: NodeType.ContractWrite, data: props.data });
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Create a protobuf ContractWriteNode from config data
|
|
13
|
-
* @param configData - The configuration data for the contract write node
|
|
14
|
-
* @returns Configured avs_pb.ContractWriteNode
|
|
15
|
-
*/
|
|
16
|
-
static createProtobufNode(configData) {
|
|
17
|
-
const node = new avs_pb.ContractWriteNode();
|
|
18
|
-
const config = new avs_pb.ContractWriteNode.Config();
|
|
19
|
-
config.setContractAddress(configData.contractAddress);
|
|
20
|
-
// Remove the top-level callData since it's no longer part of ContractWriteNodeData
|
|
21
|
-
// Convert array to protobuf Value list
|
|
22
|
-
const abiValueList = configData.contractAbi.map(item => {
|
|
23
|
-
const value = new google_protobuf_struct_pb.Value();
|
|
24
|
-
value.setStructValue(google_protobuf_struct_pb.Struct.fromJavaScript(item));
|
|
25
|
-
return value;
|
|
26
|
-
});
|
|
27
|
-
config.setContractAbiList(abiValueList);
|
|
28
|
-
// Handle method calls array (now required)
|
|
29
|
-
const methodCalls = configData.methodCalls;
|
|
30
|
-
methodCalls.forEach((methodCall) => {
|
|
31
|
-
const methodCallMsg = new avs_pb.ContractWriteNode.MethodCall();
|
|
32
|
-
// Set callData only if provided (now optional)
|
|
33
|
-
if (methodCall.callData) {
|
|
34
|
-
methodCallMsg.setCallData(methodCall.callData);
|
|
35
|
-
}
|
|
36
|
-
if (methodCall.methodName) {
|
|
37
|
-
methodCallMsg.setMethodName(methodCall.methodName);
|
|
38
|
-
}
|
|
39
|
-
if (methodCall.methodParams) {
|
|
40
|
-
methodCallMsg.setMethodParamsList(methodCall.methodParams);
|
|
41
|
-
}
|
|
42
|
-
// Note: applyToFields is not supported for ContractWrite nodes
|
|
43
|
-
config.addMethodCalls(methodCallMsg);
|
|
44
|
-
});
|
|
45
|
-
// Set isSimulated only if explicitly provided (optional field in protobuf)
|
|
46
|
-
// When unset, the backend defaults to true (simulation mode)
|
|
47
|
-
if (configData.isSimulated !== undefined) {
|
|
48
|
-
config.setIsSimulated(configData.isSimulated);
|
|
49
|
-
}
|
|
50
|
-
node.setConfig(config);
|
|
51
|
-
return node;
|
|
52
|
-
}
|
|
53
|
-
static fromResponse(raw) {
|
|
54
|
-
// Convert the raw object to ContractWriteNodeProps, which should keep name and id
|
|
55
|
-
const obj = raw.toObject();
|
|
56
|
-
const contractWriteNode = raw.getContractWrite();
|
|
57
|
-
const config = contractWriteNode.getConfig();
|
|
58
|
-
const protobufData = config.toObject();
|
|
59
|
-
// Convert protobuf data to our custom interface
|
|
60
|
-
const data = {
|
|
61
|
-
contractAddress: protobufData.contractAddress,
|
|
62
|
-
contractAbi: config.getContractAbiList().map(value => convertProtobufValueToJs(value)),
|
|
63
|
-
methodCalls: protobufData.methodCallsList?.map((call) => ({
|
|
64
|
-
methodName: call.methodName,
|
|
65
|
-
methodParams: call.methodParamsList || [],
|
|
66
|
-
// Note: applyToFields is not supported for ContractWrite nodes in protobuf
|
|
67
|
-
// callData is optional, only include if present
|
|
68
|
-
...(call.callData && { callData: call.callData }),
|
|
69
|
-
})) || [],
|
|
70
|
-
};
|
|
71
|
-
// Include isSimulated if present in protobuf
|
|
72
|
-
if (protobufData.isSimulated !== undefined) {
|
|
73
|
-
data.isSimulated = protobufData.isSimulated;
|
|
74
|
-
}
|
|
75
|
-
return new ContractWriteNode({
|
|
76
|
-
...obj,
|
|
77
|
-
type: NodeType.ContractWrite,
|
|
78
|
-
data: data,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
toRequest() {
|
|
82
|
-
const request = new avs_pb.TaskNode();
|
|
83
|
-
request.setId(this.id);
|
|
84
|
-
request.setName(this.name);
|
|
85
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_CONTRACT_WRITE);
|
|
86
|
-
const node = ContractWriteNode.createProtobufNode(this.data);
|
|
87
|
-
request.setContractWrite(node);
|
|
88
|
-
return request;
|
|
89
|
-
}
|
|
90
|
-
static fromOutputData(outputData) {
|
|
91
|
-
const contractWriteOutput = outputData.getContractWrite();
|
|
92
|
-
if (!contractWriteOutput)
|
|
93
|
-
return null;
|
|
94
|
-
// ContractWrite decoded events are stored in data field (flattened object format)
|
|
95
|
-
// This contains parsed receipt logs/events, similar to ContractRead format
|
|
96
|
-
const dataValue = contractWriteOutput.getData();
|
|
97
|
-
// Convert protobuf Value to JavaScript object (decoded events object)
|
|
98
|
-
// Return empty object if no events were decoded from transaction receipts
|
|
99
|
-
return dataValue ? convertProtobufValueToJs(dataValue) : {};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export default ContractWriteNode;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { CustomCodeNodeProps, Lang } from "@avaprotocol/types";
|
|
4
|
-
declare class CustomCodeNode extends Node {
|
|
5
|
-
constructor(props: CustomCodeNodeProps);
|
|
6
|
-
/**
|
|
7
|
-
* Create a protobuf CustomCodeNode from config data
|
|
8
|
-
* @param configData - The configuration data for the custom code node
|
|
9
|
-
* @returns Configured avs_pb.CustomCodeNode
|
|
10
|
-
*/
|
|
11
|
-
static createProtobufNode(configData: {
|
|
12
|
-
lang: Lang;
|
|
13
|
-
source: string;
|
|
14
|
-
}): avs_pb.CustomCodeNode;
|
|
15
|
-
static fromResponse(raw: avs_pb.TaskNode): CustomCodeNode;
|
|
16
|
-
toRequest(): avs_pb.TaskNode;
|
|
17
|
-
static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): any;
|
|
18
|
-
}
|
|
19
|
-
export default CustomCodeNode;
|
|
20
|
-
//# sourceMappingURL=customCode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customCode.d.ts","sourceRoot":"","sources":["../../../src/models/node/customCode.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,mBAAmB,EAEnB,IAAI,EAEL,MAAM,oBAAoB,CAAC;AAK5B,cAAM,cAAe,SAAQ,IAAI;gBACnB,KAAK,EAAE,mBAAmB;IAItC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,IAAI,EAAE,IAAI,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,MAAM,CAAC,cAAc;IAazB,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,cAAc;IA2BzD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,GAAG;CAqBrE;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import Node from "./interface";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import { NodeType, LangConverter, } from "@avaprotocol/types";
|
|
4
|
-
import { convertProtobufValueToJs } from "../../utils";
|
|
5
|
-
// Required props for constructor: id, name, type and data: { lang: number, source: string }
|
|
6
|
-
class CustomCodeNode extends Node {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
super({ ...props, type: NodeType.CustomCode, data: props.data });
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Create a protobuf CustomCodeNode from config data
|
|
12
|
-
* @param configData - The configuration data for the custom code node
|
|
13
|
-
* @returns Configured avs_pb.CustomCodeNode
|
|
14
|
-
*/
|
|
15
|
-
static createProtobufNode(configData) {
|
|
16
|
-
const node = new avs_pb.CustomCodeNode();
|
|
17
|
-
const config = new avs_pb.CustomCodeNode.Config();
|
|
18
|
-
// Convert lang to protobuf enum using centralized converter
|
|
19
|
-
const langValue = LangConverter.toProtobuf(configData.lang);
|
|
20
|
-
config.setLang(langValue);
|
|
21
|
-
config.setSource(configData.source);
|
|
22
|
-
node.setConfig(config);
|
|
23
|
-
return node;
|
|
24
|
-
}
|
|
25
|
-
static fromResponse(raw) {
|
|
26
|
-
// Convert the raw object to CustomCodeNodeProps, which should keep name and id
|
|
27
|
-
const obj = raw.toObject();
|
|
28
|
-
// Get the raw protobuf config
|
|
29
|
-
const customCodeNode = raw.getCustomCode();
|
|
30
|
-
if (!customCodeNode) {
|
|
31
|
-
throw new Error("CustomCode node data is missing");
|
|
32
|
-
}
|
|
33
|
-
const config = customCodeNode.getConfig();
|
|
34
|
-
if (!config) {
|
|
35
|
-
throw new Error("CustomCode config is missing");
|
|
36
|
-
}
|
|
37
|
-
const convertedConfig = {
|
|
38
|
-
lang: LangConverter.fromProtobuf(config.getLang()),
|
|
39
|
-
source: config.getSource(),
|
|
40
|
-
};
|
|
41
|
-
return new CustomCodeNode({
|
|
42
|
-
...obj,
|
|
43
|
-
type: NodeType.CustomCode,
|
|
44
|
-
data: convertedConfig,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
toRequest() {
|
|
48
|
-
const request = new avs_pb.TaskNode();
|
|
49
|
-
request.setId(this.id);
|
|
50
|
-
request.setName(this.name);
|
|
51
|
-
request.setType(avs_pb.NodeType.NODE_TYPE_CUSTOM_CODE);
|
|
52
|
-
const node = CustomCodeNode.createProtobufNode(this.data);
|
|
53
|
-
request.setCustomCode(node);
|
|
54
|
-
return request;
|
|
55
|
-
}
|
|
56
|
-
static fromOutputData(outputData) {
|
|
57
|
-
const customCodeOutput = outputData.getCustomCode();
|
|
58
|
-
if (customCodeOutput?.getData()) {
|
|
59
|
-
// Use the modern protobuf conversion function
|
|
60
|
-
const result = convertProtobufValueToJs(customCodeOutput.getData());
|
|
61
|
-
// SPECIAL FIX: Check if the result is incorrectly wrapped with a single "data" property
|
|
62
|
-
// This handles the case where primitive values get wrapped as {"data": value}
|
|
63
|
-
if (result &&
|
|
64
|
-
typeof result === "object" &&
|
|
65
|
-
Object.keys(result).length === 1 &&
|
|
66
|
-
"data" in result) {
|
|
67
|
-
return result.data;
|
|
68
|
-
}
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export default CustomCodeNode;
|