@avaprotocol/sdk-js 1.4.0 → 1.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/auth.d.ts +2 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +10 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +19 -0
- package/dist/index.d.ts +58 -2750
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1260 -492
- package/dist/index.mjs +1257 -484
- package/dist/models/edge.d.ts +12 -0
- package/dist/models/edge.d.ts.map +1 -0
- package/dist/models/edge.js +19 -0
- package/dist/models/execution.d.ts +25 -0
- package/dist/models/execution.d.ts.map +1 -0
- package/dist/models/execution.js +48 -0
- package/dist/models/node/branch.d.ts +14 -0
- package/dist/models/node/branch.d.ts.map +1 -0
- package/dist/models/node/branch.js +33 -0
- package/dist/models/node/contractRead.d.ts +14 -0
- package/dist/models/node/contractRead.d.ts.map +1 -0
- package/dist/models/node/contractRead.js +29 -0
- package/dist/models/node/contractWrite.d.ts +14 -0
- package/dist/models/node/contractWrite.d.ts.map +1 -0
- package/dist/models/node/contractWrite.js +29 -0
- package/dist/models/node/customCode.d.ts +15 -0
- package/dist/models/node/customCode.d.ts.map +1 -0
- package/dist/models/node/customCode.js +29 -0
- package/dist/models/node/ethTransfer.d.ts +14 -0
- package/dist/models/node/ethTransfer.d.ts.map +1 -0
- package/dist/models/node/ethTransfer.js +28 -0
- package/dist/models/node/factory.d.ts +20 -0
- package/dist/models/node/factory.d.ts.map +1 -0
- package/dist/models/node/factory.js +67 -0
- package/dist/models/node/filter.d.ts +14 -0
- package/dist/models/node/filter.d.ts.map +1 -0
- package/dist/models/node/filter.js +28 -0
- package/dist/models/node/graphqlQuery.d.ts +14 -0
- package/dist/models/node/graphqlQuery.d.ts.map +1 -0
- package/dist/models/node/graphqlQuery.js +37 -0
- package/dist/models/node/interface.d.ts +18 -0
- package/dist/models/node/interface.d.ts.map +1 -0
- package/dist/models/node/interface.js +37 -0
- package/dist/models/node/restApi.d.ts +15 -0
- package/dist/models/node/restApi.d.ts.map +1 -0
- package/dist/models/node/restApi.js +34 -0
- package/dist/models/secret.d.ts +17 -0
- package/dist/models/secret.d.ts.map +1 -0
- package/dist/models/secret.js +22 -0
- package/dist/models/step.d.ts +19 -0
- package/dist/models/step.d.ts.map +1 -0
- package/dist/models/step.js +78 -0
- package/dist/models/trigger/block.d.ts +13 -0
- package/dist/models/trigger/block.d.ts.map +1 -0
- package/dist/models/trigger/block.js +30 -0
- package/dist/models/trigger/cron.d.ts +13 -0
- package/dist/models/trigger/cron.d.ts.map +1 -0
- package/dist/models/trigger/cron.js +30 -0
- package/dist/models/trigger/event.d.ts +13 -0
- package/dist/models/trigger/event.d.ts.map +1 -0
- package/dist/models/trigger/event.js +61 -0
- package/dist/models/trigger/factory.d.ts +27 -0
- package/dist/models/trigger/factory.d.ts.map +1 -0
- package/dist/models/trigger/factory.js +49 -0
- package/dist/models/trigger/fixedTime.d.ts +13 -0
- package/dist/models/trigger/fixedTime.d.ts.map +1 -0
- package/dist/models/trigger/fixedTime.js +30 -0
- package/dist/models/trigger/interface.d.ts +21 -0
- package/dist/models/trigger/interface.d.ts.map +1 -0
- package/dist/models/trigger/interface.js +16 -0
- package/dist/models/trigger/reason.d.ts +33 -0
- package/dist/models/trigger/reason.d.ts.map +1 -0
- package/dist/models/trigger/reason.js +93 -0
- package/dist/models/workflow.d.ts +54 -0
- package/dist/models/workflow.d.ts.map +1 -0
- package/dist/models/workflow.js +118 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +37 -0
- package/package.json +6 -4
- package/dist/index.d.mts +0 -2937
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
+
export type EdgeProps = avs_pb.TaskEdge.AsObject;
|
|
3
|
+
declare class Edge implements EdgeProps {
|
|
4
|
+
id: string;
|
|
5
|
+
source: string;
|
|
6
|
+
target: string;
|
|
7
|
+
constructor(edge: EdgeProps);
|
|
8
|
+
static fromResponse(edge: avs_pb.TaskEdge): Edge;
|
|
9
|
+
toRequest(): avs_pb.TaskEdge;
|
|
10
|
+
}
|
|
11
|
+
export default Edge;
|
|
12
|
+
//# sourceMappingURL=edge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/models/edge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAEjD,cAAM,IAAK,YAAW,SAAS;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;gBAEH,IAAI,EAAE,SAAS;IAM3B,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,GAAG,IAAI;IAIhD,SAAS,IAAI,MAAM,CAAC,QAAQ;CAQ7B;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
+
import TriggerReason from "./trigger/reason";
|
|
3
|
+
import Step from "./step";
|
|
4
|
+
export type StepProps = avs_pb.Execution.Step.AsObject;
|
|
5
|
+
export type OutputDataProps = avs_pb.Execution.TransferLogOutput.AsObject | avs_pb.Execution.BlockOutput.AsObject | avs_pb.Execution.TimeOutput.AsObject | avs_pb.Evm.Log.AsObject | undefined;
|
|
6
|
+
export type ExecutionProps = Omit<avs_pb.Execution.AsObject, "stepsList" | "reason" | "transferLog" | "evmLog" | "block" | "time"> & {
|
|
7
|
+
stepsList: Step[];
|
|
8
|
+
triggerReason: TriggerReason | undefined;
|
|
9
|
+
triggerOutput: OutputDataProps;
|
|
10
|
+
};
|
|
11
|
+
declare class Execution implements ExecutionProps {
|
|
12
|
+
id: string;
|
|
13
|
+
startAt: number;
|
|
14
|
+
endAt: number;
|
|
15
|
+
success: boolean;
|
|
16
|
+
error: string;
|
|
17
|
+
stepsList: Step[];
|
|
18
|
+
triggerReason: TriggerReason | undefined;
|
|
19
|
+
triggerName: string;
|
|
20
|
+
triggerOutput: OutputDataProps;
|
|
21
|
+
constructor(props: ExecutionProps);
|
|
22
|
+
static fromResponse(execution: avs_pb.Execution): Execution;
|
|
23
|
+
}
|
|
24
|
+
export default Execution;
|
|
25
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/models/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;AAEvD,MAAM,MAAM,eAAe,GACvB,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,QAAQ,GAC3C,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,GACrC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,GACpC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,GACvB,SAAS,CAAC;AAGd,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,MAAM,CAAC,SAAS,CAAC,QAAQ,EACzB,WAAW,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CACrE,GAAG;IACF,SAAS,EAAE,IAAI,EAAE,CAAC;IAClB,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IACzC,aAAa,EAAE,eAAe,CAAC;CAChC,CAAC;AAEF,cAAM,SAAU,YAAW,cAAc;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,EAAE,CAAC;IAClB,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,eAAe,CAAC;gBAEnB,KAAK,EAAE,cAAc;IAYjC,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS;CAoC5D;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
+
import TriggerReason from "./trigger/reason";
|
|
3
|
+
import Step from "./step";
|
|
4
|
+
class Execution {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
this.id = props.id;
|
|
7
|
+
this.startAt = props.startAt;
|
|
8
|
+
this.endAt = props.endAt;
|
|
9
|
+
this.success = props.success;
|
|
10
|
+
this.error = props.error;
|
|
11
|
+
this.stepsList = props.stepsList;
|
|
12
|
+
this.triggerName = props.triggerName;
|
|
13
|
+
this.triggerReason = props.triggerReason;
|
|
14
|
+
this.triggerOutput = props.triggerOutput;
|
|
15
|
+
}
|
|
16
|
+
static fromResponse(execution) {
|
|
17
|
+
const triggerOutputDataType = execution.getOutputDataCase();
|
|
18
|
+
let triggerOutputData;
|
|
19
|
+
switch (triggerOutputDataType) {
|
|
20
|
+
case avs_pb.Execution.OutputDataCase.EVM_LOG:
|
|
21
|
+
triggerOutputData = execution.getEvmLog()?.toObject();
|
|
22
|
+
break;
|
|
23
|
+
case avs_pb.Execution.OutputDataCase.TRANSFER_LOG:
|
|
24
|
+
triggerOutputData = execution.getTransferLog()?.toObject();
|
|
25
|
+
break;
|
|
26
|
+
case avs_pb.Execution.OutputDataCase.BLOCK:
|
|
27
|
+
triggerOutputData = execution.getBlock()?.toObject();
|
|
28
|
+
break;
|
|
29
|
+
case avs_pb.Execution.OutputDataCase.TIME:
|
|
30
|
+
triggerOutputData = execution.getTime()?.toObject();
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return new Execution({
|
|
34
|
+
id: execution.getId(),
|
|
35
|
+
startAt: execution.getStartAt(),
|
|
36
|
+
endAt: execution.getEndAt(),
|
|
37
|
+
success: execution.getSuccess(),
|
|
38
|
+
error: execution.getError(),
|
|
39
|
+
triggerName: execution.getTriggerName(),
|
|
40
|
+
triggerReason: TriggerReason.fromResponse(execution.getReason()),
|
|
41
|
+
triggerOutput: triggerOutputData,
|
|
42
|
+
stepsList: execution
|
|
43
|
+
.getStepsList()
|
|
44
|
+
.map((step) => Step.fromResponse(step)),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export default Execution;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NodeProps } from "./interface";
|
|
2
|
+
import Node from "./interface";
|
|
3
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
+
export type BranchNodeData = avs_pb.BranchNode.AsObject;
|
|
5
|
+
export type BranchNodeProps = NodeProps & {
|
|
6
|
+
data: BranchNodeData;
|
|
7
|
+
};
|
|
8
|
+
declare class BranchNode extends Node {
|
|
9
|
+
constructor(props: BranchNodeProps);
|
|
10
|
+
static fromResponse(raw: avs_pb.TaskNode): BranchNode;
|
|
11
|
+
toRequest(): avs_pb.TaskNode;
|
|
12
|
+
}
|
|
13
|
+
export default BranchNode;
|
|
14
|
+
//# sourceMappingURL=branch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../../src/models/node/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAGhD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACxC,IAAI,EAAE,cAAc,CAAC;CACtB,CAAC;AAEF,cAAM,UAAW,SAAQ,IAAI;gBACf,KAAK,EAAE,eAAe;IAIlC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,UAAU;IAUrD,SAAS,IAAI,MAAM,CAAC,QAAQ;CAuB7B;AACD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NodeType } from "@avaprotocol/types";
|
|
2
|
+
import Node from "./interface";
|
|
3
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
+
class BranchNode extends Node {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super({ ...props, type: NodeType.Branch, data: props.data });
|
|
7
|
+
}
|
|
8
|
+
static fromResponse(raw) {
|
|
9
|
+
// Convert the raw object to BranchNodeProps, which should keep name and id
|
|
10
|
+
const obj = raw.toObject();
|
|
11
|
+
return new BranchNode({
|
|
12
|
+
...obj,
|
|
13
|
+
type: NodeType.Branch,
|
|
14
|
+
data: raw.getBranch().toObject(),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
toRequest() {
|
|
18
|
+
const request = new avs_pb.TaskNode();
|
|
19
|
+
request.setId(this.id);
|
|
20
|
+
request.setName(this.name);
|
|
21
|
+
const nodeData = new avs_pb.BranchNode();
|
|
22
|
+
nodeData.setConditionsList(this.data.conditionsList.map((condition) => {
|
|
23
|
+
const conditionObj = new avs_pb.Condition();
|
|
24
|
+
conditionObj.setId(condition.id);
|
|
25
|
+
conditionObj.setType(condition.type);
|
|
26
|
+
conditionObj.setExpression(condition.expression);
|
|
27
|
+
return conditionObj;
|
|
28
|
+
}));
|
|
29
|
+
request.setBranch(nodeData);
|
|
30
|
+
return request;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export default BranchNode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NodeProps } from "./interface";
|
|
2
|
+
import Node from "./interface";
|
|
3
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
+
export type ContractReadNodeData = avs_pb.ContractReadNode.AsObject;
|
|
5
|
+
export type ContractReadNodeProps = NodeProps & {
|
|
6
|
+
data: ContractReadNodeData;
|
|
7
|
+
};
|
|
8
|
+
declare class ContractReadNode extends Node {
|
|
9
|
+
constructor(props: ContractReadNodeProps);
|
|
10
|
+
static fromResponse(raw: avs_pb.TaskNode): ContractReadNode;
|
|
11
|
+
toRequest(): avs_pb.TaskNode;
|
|
12
|
+
}
|
|
13
|
+
export default ContractReadNode;
|
|
14
|
+
//# sourceMappingURL=contractRead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractRead.d.ts","sourceRoot":"","sources":["../../../src/models/node/contractRead.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAIhD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AACpE,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG;IAC9C,IAAI,EAAE,oBAAoB,CAAC;CAC5B,CAAC;AAEF,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAIxC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAU3D,SAAS,IAAI,MAAM,CAAC,QAAQ;CAiB7B;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Node from "./interface";
|
|
2
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
+
import { NodeType } from "@avaprotocol/types";
|
|
4
|
+
class ContractReadNode extends Node {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super({ ...props, type: NodeType.ContractRead, data: props.data });
|
|
7
|
+
}
|
|
8
|
+
static fromResponse(raw) {
|
|
9
|
+
// Convert the raw object to ContractReadNodeProps, which should keep name and id
|
|
10
|
+
const obj = raw.toObject();
|
|
11
|
+
return new ContractReadNode({
|
|
12
|
+
...obj,
|
|
13
|
+
type: NodeType.ContractRead,
|
|
14
|
+
data: raw.getContractRead().toObject(),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
toRequest() {
|
|
18
|
+
const request = new avs_pb.TaskNode();
|
|
19
|
+
request.setId(this.id);
|
|
20
|
+
request.setName(this.name);
|
|
21
|
+
const nodeData = new avs_pb.ContractReadNode();
|
|
22
|
+
nodeData.setContractAddress(this.data.contractAddress);
|
|
23
|
+
nodeData.setCallData(this.data.callData);
|
|
24
|
+
nodeData.setContractAbi(this.data.contractAbi);
|
|
25
|
+
request.setContractRead(nodeData);
|
|
26
|
+
return request;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default ContractReadNode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NodeProps } from "./interface";
|
|
2
|
+
import Node from "./interface";
|
|
3
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
+
export type ContractWriteNodeData = avs_pb.ContractWriteNode.AsObject;
|
|
5
|
+
export type ContractWriteNodeProps = NodeProps & {
|
|
6
|
+
data: ContractWriteNodeData;
|
|
7
|
+
};
|
|
8
|
+
declare class ContractWriteNode extends Node {
|
|
9
|
+
constructor(props: ContractWriteNodeProps);
|
|
10
|
+
static fromResponse(raw: avs_pb.TaskNode): ContractWriteNode;
|
|
11
|
+
toRequest(): avs_pb.TaskNode;
|
|
12
|
+
}
|
|
13
|
+
export default ContractWriteNode;
|
|
14
|
+
//# sourceMappingURL=contractWrite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractWrite.d.ts","sourceRoot":"","sources":["../../../src/models/node/contractWrite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAIhD,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC;AACtE,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG;IAC/C,IAAI,EAAE,qBAAqB,CAAC;CAC7B,CAAC;AAEF,cAAM,iBAAkB,SAAQ,IAAI;gBACtB,KAAK,EAAE,sBAAsB;IAIzC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,iBAAiB;IAU5D,SAAS,IAAI,MAAM,CAAC,QAAQ;CAiB7B;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Node from "./interface";
|
|
2
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
+
import { NodeType } from "@avaprotocol/types";
|
|
4
|
+
class ContractWriteNode extends Node {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super({ ...props, type: NodeType.ContractWrite, data: props.data });
|
|
7
|
+
}
|
|
8
|
+
static fromResponse(raw) {
|
|
9
|
+
// Convert the raw object to ContractWriteNodeProps, which should keep name and id
|
|
10
|
+
const obj = raw.toObject();
|
|
11
|
+
return new ContractWriteNode({
|
|
12
|
+
...obj,
|
|
13
|
+
type: NodeType.ContractWrite,
|
|
14
|
+
data: raw.getContractWrite().toObject(),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
toRequest() {
|
|
18
|
+
const request = new avs_pb.TaskNode();
|
|
19
|
+
request.setId(this.id);
|
|
20
|
+
request.setName(this.name);
|
|
21
|
+
const nodeData = new avs_pb.ContractWriteNode();
|
|
22
|
+
nodeData.setContractAddress(this.data.contractAddress);
|
|
23
|
+
nodeData.setCallData(this.data.callData);
|
|
24
|
+
nodeData.setContractAbi(this.data.contractAbi);
|
|
25
|
+
request.setContractWrite(nodeData);
|
|
26
|
+
return request;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default ContractWriteNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NodeProps } from "./interface";
|
|
2
|
+
import Node from "./interface";
|
|
3
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
+
export type CustomCodeNodeData = avs_pb.CustomCodeNode.AsObject;
|
|
5
|
+
export declare const CustomCodeLangs: typeof avs_pb.CustomCodeLang;
|
|
6
|
+
export type CustomCodeNodeProps = NodeProps & {
|
|
7
|
+
data: CustomCodeNodeData;
|
|
8
|
+
};
|
|
9
|
+
declare class CustomCodeNode extends Node {
|
|
10
|
+
constructor(props: CustomCodeNodeProps);
|
|
11
|
+
static fromResponse(raw: avs_pb.TaskNode): CustomCodeNode;
|
|
12
|
+
toRequest(): avs_pb.TaskNode;
|
|
13
|
+
}
|
|
14
|
+
export default CustomCodeNode;
|
|
15
|
+
//# sourceMappingURL=customCode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customCode.d.ts","sourceRoot":"","sources":["../../../src/models/node/customCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAIhD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;AAChE,eAAO,MAAM,eAAe,8BAAwB,CAAC;AACrD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG;IAC5C,IAAI,EAAE,kBAAkB,CAAC;CAC1B,CAAC;AAEF,cAAM,cAAe,SAAQ,IAAI;gBACnB,KAAK,EAAE,mBAAmB;IAItC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,cAAc;IAUzD,SAAS,IAAI,MAAM,CAAC,QAAQ;CAc7B;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Node from "./interface";
|
|
2
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
+
import { NodeType } from "@avaprotocol/types";
|
|
4
|
+
export const CustomCodeLangs = avs_pb.CustomCodeLang;
|
|
5
|
+
class CustomCodeNode extends Node {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super({ ...props, type: NodeType.CustomCode, data: props.data });
|
|
8
|
+
}
|
|
9
|
+
static fromResponse(raw) {
|
|
10
|
+
// Convert the raw object to CustomCodeNodeProps, which should keep name and id
|
|
11
|
+
const obj = raw.toObject();
|
|
12
|
+
return new CustomCodeNode({
|
|
13
|
+
...obj,
|
|
14
|
+
type: NodeType.CustomCode,
|
|
15
|
+
data: raw.getCustomCode().toObject(),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
toRequest() {
|
|
19
|
+
const request = new avs_pb.TaskNode();
|
|
20
|
+
request.setId(this.id);
|
|
21
|
+
request.setName(this.name);
|
|
22
|
+
const nodeData = new avs_pb.CustomCodeNode();
|
|
23
|
+
nodeData.setLang(this.data.lang);
|
|
24
|
+
nodeData.setSource(this.data.source);
|
|
25
|
+
request.setCustomCode(nodeData);
|
|
26
|
+
return request;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default CustomCodeNode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NodeProps } from "./interface";
|
|
2
|
+
import Node from "./interface";
|
|
3
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
+
export type ETHTransferNodeData = avs_pb.ETHTransferNode.AsObject;
|
|
5
|
+
export type ETHTransferNodeProps = NodeProps & {
|
|
6
|
+
data: ETHTransferNodeData;
|
|
7
|
+
};
|
|
8
|
+
declare class ETHTransferNode extends Node {
|
|
9
|
+
constructor(props: ETHTransferNodeProps);
|
|
10
|
+
static fromResponse(raw: avs_pb.TaskNode): ETHTransferNode;
|
|
11
|
+
toRequest(): avs_pb.TaskNode;
|
|
12
|
+
}
|
|
13
|
+
export default ETHTransferNode;
|
|
14
|
+
//# sourceMappingURL=ethTransfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ethTransfer.d.ts","sourceRoot":"","sources":["../../../src/models/node/ethTransfer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAIhD,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC;AAClE,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG;IAC7C,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC;AAEF,cAAM,eAAgB,SAAQ,IAAI;gBACpB,KAAK,EAAE,oBAAoB;IAIvC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,eAAe;IAU1D,SAAS,IAAI,MAAM,CAAC,QAAQ;CAc7B;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Node from "./interface";
|
|
2
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
+
import { NodeType } from "@avaprotocol/types";
|
|
4
|
+
class ETHTransferNode extends Node {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super({ ...props, type: NodeType.ETHTransfer, data: props.data });
|
|
7
|
+
}
|
|
8
|
+
static fromResponse(raw) {
|
|
9
|
+
// Convert the raw object to ETHTransferNodeProps, which should keep name and id
|
|
10
|
+
const obj = raw.toObject();
|
|
11
|
+
return new ETHTransferNode({
|
|
12
|
+
...obj,
|
|
13
|
+
type: NodeType.ETHTransfer,
|
|
14
|
+
data: raw.getEthTransfer().toObject(),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
toRequest() {
|
|
18
|
+
const request = new avs_pb.TaskNode();
|
|
19
|
+
request.setId(this.id);
|
|
20
|
+
request.setName(this.name);
|
|
21
|
+
const nodeData = new avs_pb.ETHTransferNode();
|
|
22
|
+
nodeData.setDestination(this.data.destination);
|
|
23
|
+
nodeData.setAmount(this.data.amount);
|
|
24
|
+
request.setEthTransfer(nodeData);
|
|
25
|
+
return request;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export default ETHTransferNode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
+
import ContractWriteNode, { ContractWriteNodeData, ContractWriteNodeProps } from "./contractWrite";
|
|
3
|
+
import CustomCodeNode, { CustomCodeLangs, CustomCodeNodeData, CustomCodeNodeProps } from "./customCode";
|
|
4
|
+
import GraphQLQueryNode, { GraphQLQueryNodeData, GraphQLQueryNodeProps } from "./graphqlQuery";
|
|
5
|
+
import Node, { NodeProps } from "./interface";
|
|
6
|
+
import RestAPINode, { RestAPINodeData, RestAPINodeProps } from "./restApi";
|
|
7
|
+
import ContractReadNode, { ContractReadNodeData, ContractReadNodeProps } from "./contractRead";
|
|
8
|
+
import ETHTransferNode, { ETHTransferNodeData, ETHTransferNodeProps } from "./ethTransfer";
|
|
9
|
+
import BranchNode, { BranchNodeProps, BranchNodeData } from "./branch";
|
|
10
|
+
import FilterNode, { FilterNodeData, FilterNodeProps } from "./filter";
|
|
11
|
+
declare class NodeFactory {
|
|
12
|
+
static create(props: NodeProps): Node;
|
|
13
|
+
static createNodes(props: NodeProps[]): Node[];
|
|
14
|
+
static fromResponse(raw: avs_pb.TaskNode): Node;
|
|
15
|
+
}
|
|
16
|
+
export default NodeFactory;
|
|
17
|
+
export { Node, ContractWriteNode, ContractReadNode, BranchNode, ETHTransferNode, GraphQLQueryNode, RestAPINode, CustomCodeNode, CustomCodeLangs, FilterNode, };
|
|
18
|
+
export type { ContractWriteNodeData, ContractReadNodeData, BranchNodeData, ETHTransferNodeData, GraphQLQueryNodeData, RestAPINodeData, CustomCodeNodeData, FilterNodeData, };
|
|
19
|
+
export type { NodeProps, ContractWriteNodeProps, ContractReadNodeProps, BranchNodeProps, ETHTransferNodeProps, GraphQLQueryNodeProps, RestAPINodeProps, CustomCodeNodeProps, FilterNodeProps, };
|
|
20
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/models/node/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,iBAAiB,EAAE,EACxB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,cAAc,EAAE,EACrB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,gBAAgB,EAAE,EACvB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,WAAW,EAAE,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,gBAAgB,EAAE,EACvB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,eAAe,EAAE,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,UAAU,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,UAAU,EAAE,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGvE,cAAM,WAAW;IACf,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IA2BrC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE;IAI9C,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,IAAI;CAsBhD;AAED,eAAe,WAAW,CAAC;AAG3B,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,eAAe,EACf,UAAU,GACX,CAAC;AAGF,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,CAAC;AAGF,YAAY,EACV,SAAS,EACT,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,GAChB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import ContractWriteNode from "./contractWrite";
|
|
3
|
+
import CustomCodeNode, { CustomCodeLangs, } from "./customCode";
|
|
4
|
+
import GraphQLQueryNode from "./graphqlQuery";
|
|
5
|
+
import Node from "./interface";
|
|
6
|
+
import RestAPINode from "./restApi";
|
|
7
|
+
import ContractReadNode from "./contractRead";
|
|
8
|
+
import ETHTransferNode from "./ethTransfer";
|
|
9
|
+
import BranchNode from "./branch";
|
|
10
|
+
import FilterNode from "./filter";
|
|
11
|
+
import { NodeType } from "@avaprotocol/types";
|
|
12
|
+
class NodeFactory {
|
|
13
|
+
static create(props) {
|
|
14
|
+
switch (props.type) {
|
|
15
|
+
case NodeType.ContractWrite:
|
|
16
|
+
return new ContractWriteNode(props);
|
|
17
|
+
case NodeType.RestAPI:
|
|
18
|
+
return new RestAPINode(props);
|
|
19
|
+
case NodeType.CustomCode:
|
|
20
|
+
return new CustomCodeNode(props);
|
|
21
|
+
case NodeType.ContractRead:
|
|
22
|
+
return new ContractReadNode(props);
|
|
23
|
+
case NodeType.ETHTransfer:
|
|
24
|
+
return new ETHTransferNode(props);
|
|
25
|
+
case NodeType.GraphQLQuery:
|
|
26
|
+
return new GraphQLQueryNode(props);
|
|
27
|
+
case NodeType.Branch:
|
|
28
|
+
return new BranchNode(props);
|
|
29
|
+
case NodeType.Filter:
|
|
30
|
+
return new FilterNode(props);
|
|
31
|
+
case NodeType.Loop:
|
|
32
|
+
throw new Error("Loop node type is not yet implemented");
|
|
33
|
+
case NodeType.Unset:
|
|
34
|
+
throw new Error("Cannot create node with unset type");
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Unsupported node type: ${props.type}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
static createNodes(props) {
|
|
40
|
+
return _.map(props, (node) => this.create(node));
|
|
41
|
+
}
|
|
42
|
+
static fromResponse(raw) {
|
|
43
|
+
switch (true) {
|
|
44
|
+
case !!raw.getEthTransfer():
|
|
45
|
+
return ETHTransferNode.fromResponse(raw);
|
|
46
|
+
case !!raw.getContractRead():
|
|
47
|
+
return ContractReadNode.fromResponse(raw);
|
|
48
|
+
case !!raw.getContractWrite():
|
|
49
|
+
return ContractWriteNode.fromResponse(raw);
|
|
50
|
+
case !!raw.getGraphqlQuery():
|
|
51
|
+
return GraphQLQueryNode.fromResponse(raw);
|
|
52
|
+
case !!raw.getRestApi():
|
|
53
|
+
return RestAPINode.fromResponse(raw);
|
|
54
|
+
case !!raw.getCustomCode():
|
|
55
|
+
return CustomCodeNode.fromResponse(raw);
|
|
56
|
+
case !!raw.getBranch():
|
|
57
|
+
return BranchNode.fromResponse(raw);
|
|
58
|
+
case !!raw.getFilter():
|
|
59
|
+
return FilterNode.fromResponse(raw);
|
|
60
|
+
default:
|
|
61
|
+
throw new Error(`Unsupported node type: ${raw.getName()}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export default NodeFactory;
|
|
66
|
+
// Node object definitions
|
|
67
|
+
export { Node, ContractWriteNode, ContractReadNode, BranchNode, ETHTransferNode, GraphQLQueryNode, RestAPINode, CustomCodeNode, CustomCodeLangs, FilterNode, };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NodeProps } from "./interface";
|
|
2
|
+
import Node from "./interface";
|
|
3
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
+
export type FilterNodeData = avs_pb.FilterNode.AsObject;
|
|
5
|
+
export type FilterNodeProps = NodeProps & {
|
|
6
|
+
data: FilterNodeData;
|
|
7
|
+
};
|
|
8
|
+
declare class FilterNode extends Node {
|
|
9
|
+
constructor(props: FilterNodeProps);
|
|
10
|
+
static fromResponse(raw: avs_pb.TaskNode): FilterNode;
|
|
11
|
+
toRequest(): avs_pb.TaskNode;
|
|
12
|
+
}
|
|
13
|
+
export default FilterNode;
|
|
14
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/models/node/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAIhD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACxC,IAAI,EAAE,cAAc,CAAC;CACtB,CAAC;AAEF,cAAM,UAAW,SAAQ,IAAI;gBACf,KAAK,EAAE,eAAe;IAIlC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,UAAU;IAUrD,SAAS,IAAI,MAAM,CAAC,QAAQ;CAa7B;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Node from "./interface";
|
|
2
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
+
import { NodeType } from "@avaprotocol/types";
|
|
4
|
+
class FilterNode extends Node {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super({ ...props, type: NodeType.Filter, data: props.data });
|
|
7
|
+
}
|
|
8
|
+
static fromResponse(raw) {
|
|
9
|
+
// Convert the raw object to FilterNodeProps, which should keep name and id
|
|
10
|
+
const obj = raw.toObject();
|
|
11
|
+
return new FilterNode({
|
|
12
|
+
...obj,
|
|
13
|
+
type: NodeType.Filter,
|
|
14
|
+
data: raw.getFilter().toObject(),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
toRequest() {
|
|
18
|
+
const request = new avs_pb.TaskNode();
|
|
19
|
+
request.setId(this.id);
|
|
20
|
+
request.setName(this.name);
|
|
21
|
+
const nodeData = new avs_pb.FilterNode();
|
|
22
|
+
nodeData.setExpression(this.data.expression);
|
|
23
|
+
nodeData.setInput(this.data.input);
|
|
24
|
+
request.setFilter(nodeData);
|
|
25
|
+
return request;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export default FilterNode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NodeProps } from "./interface";
|
|
2
|
+
import Node from "./interface";
|
|
3
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
4
|
+
export type GraphQLQueryNodeData = avs_pb.GraphQLQueryNode.AsObject;
|
|
5
|
+
export type GraphQLQueryNodeProps = NodeProps & {
|
|
6
|
+
data: GraphQLQueryNodeData;
|
|
7
|
+
};
|
|
8
|
+
declare class GraphQLQueryNode extends Node {
|
|
9
|
+
constructor(props: GraphQLQueryNodeProps);
|
|
10
|
+
static fromResponse(raw: avs_pb.TaskNode): GraphQLQueryNode;
|
|
11
|
+
toRequest(): avs_pb.TaskNode;
|
|
12
|
+
}
|
|
13
|
+
export default GraphQLQueryNode;
|
|
14
|
+
//# sourceMappingURL=graphqlQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphqlQuery.d.ts","sourceRoot":"","sources":["../../../src/models/node/graphqlQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAIhD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AACpE,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG;IAC9C,IAAI,EAAE,oBAAoB,CAAC;CAC5B,CAAC;AAEF,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAQxC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAU3D,SAAS,IAAI,MAAM,CAAC,QAAQ;CAmB7B;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Node from "./interface";
|
|
2
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
+
import { NodeType } from "@avaprotocol/types";
|
|
4
|
+
class GraphQLQueryNode extends Node {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super({
|
|
7
|
+
...props,
|
|
8
|
+
type: NodeType.GraphQLQuery,
|
|
9
|
+
data: props.data,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
static fromResponse(raw) {
|
|
13
|
+
// Convert the raw object to GraphQLQueryNodeProps, which should keep name and id
|
|
14
|
+
const obj = raw.toObject();
|
|
15
|
+
return new GraphQLQueryNode({
|
|
16
|
+
...obj,
|
|
17
|
+
type: NodeType.GraphQLQuery,
|
|
18
|
+
data: raw.getGraphqlQuery().toObject(),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
toRequest() {
|
|
22
|
+
const request = new avs_pb.TaskNode();
|
|
23
|
+
request.setId(this.id);
|
|
24
|
+
request.setName(this.name);
|
|
25
|
+
const nodeData = new avs_pb.GraphQLQueryNode();
|
|
26
|
+
nodeData.setUrl(this.data.url);
|
|
27
|
+
nodeData.setQuery(this.data.query);
|
|
28
|
+
const variables = this.data.variablesMap;
|
|
29
|
+
const variablesMap = nodeData.getVariablesMap();
|
|
30
|
+
variables.forEach(([key, value]) => {
|
|
31
|
+
variablesMap.set(key, value);
|
|
32
|
+
});
|
|
33
|
+
request.setGraphqlQuery(nodeData);
|
|
34
|
+
return request;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export default GraphQLQueryNode;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
+
import { NodeType } from "@avaprotocol/types";
|
|
3
|
+
export declare function covertNodeTypeToString(status: avs_pb.TaskNode.TaskTypeCase): NodeType;
|
|
4
|
+
export type NodeData = avs_pb.ETHTransferNode.AsObject | avs_pb.ContractWriteNode.AsObject | avs_pb.ContractReadNode.AsObject | avs_pb.GraphQLQueryNode.AsObject | avs_pb.RestAPINode.AsObject | avs_pb.BranchNode.AsObject | avs_pb.FilterNode.AsObject | avs_pb.LoopNode.AsObject | avs_pb.CustomCodeNode.AsObject;
|
|
5
|
+
export type NodeProps = Omit<avs_pb.TaskNode.AsObject, "ethTransfer" | "contractWrite" | "contractRead" | "graphqlDataQuery" | "restApi" | "branch" | "filter" | "loop" | "customCode"> & {
|
|
6
|
+
type: NodeType;
|
|
7
|
+
data: NodeData;
|
|
8
|
+
};
|
|
9
|
+
declare class Node implements NodeProps {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
type: NodeType;
|
|
13
|
+
data: NodeData;
|
|
14
|
+
constructor(props: NodeProps);
|
|
15
|
+
toRequest(): avs_pb.TaskNode;
|
|
16
|
+
}
|
|
17
|
+
export default Node;
|
|
18
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/node/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAI9C,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,GACnC,QAAQ,CAeV;AAED,MAAM,MAAM,QAAQ,GAChB,MAAM,CAAC,eAAe,CAAC,QAAQ,GAC/B,MAAM,CAAC,iBAAiB,CAAC,QAAQ,GACjC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,GAChC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,GAChC,MAAM,CAAC,WAAW,CAAC,QAAQ,GAC3B,MAAM,CAAC,UAAU,CAAC,QAAQ,GAC1B,MAAM,CAAC,UAAU,CAAC,QAAQ,GAC1B,MAAM,CAAC,QAAQ,CAAC,QAAQ,GACxB,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;AAEnC,MAAM,MAAM,SAAS,GAAG,IAAI,CAC1B,MAAM,CAAC,QAAQ,CAAC,QAAQ,EACtB,aAAa,GACb,eAAe,GACf,cAAc,GACd,kBAAkB,GAClB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,YAAY,CACf,GAAG;IACF,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,cAAM,IAAK,YAAW,SAAS;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;gBAEH,KAAK,EAAE,SAAS;IAO5B,SAAS,IAAI,MAAM,CAAC,QAAQ;CAU7B;AAED,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
+
import { NodeType } from "@avaprotocol/types";
|
|
3
|
+
import _ from "lodash";
|
|
4
|
+
// Function to convert TaskStatus to string
|
|
5
|
+
export function covertNodeTypeToString(status) {
|
|
6
|
+
const conversionMap = {
|
|
7
|
+
[avs_pb.TaskNode.TaskTypeCase.ETH_TRANSFER]: NodeType.ETHTransfer,
|
|
8
|
+
[avs_pb.TaskNode.TaskTypeCase.CONTRACT_WRITE]: NodeType.ContractWrite,
|
|
9
|
+
[avs_pb.TaskNode.TaskTypeCase.CONTRACT_READ]: NodeType.ContractRead,
|
|
10
|
+
[avs_pb.TaskNode.TaskTypeCase.GRAPHQL_QUERY]: NodeType.GraphQLQuery,
|
|
11
|
+
[avs_pb.TaskNode.TaskTypeCase.REST_API]: NodeType.RestAPI,
|
|
12
|
+
[avs_pb.TaskNode.TaskTypeCase.BRANCH]: NodeType.Branch,
|
|
13
|
+
[avs_pb.TaskNode.TaskTypeCase.FILTER]: NodeType.Filter,
|
|
14
|
+
[avs_pb.TaskNode.TaskTypeCase.LOOP]: NodeType.Loop,
|
|
15
|
+
[avs_pb.TaskNode.TaskTypeCase.CUSTOM_CODE]: NodeType.CustomCode,
|
|
16
|
+
[avs_pb.TaskNode.TaskTypeCase.TASK_TYPE_NOT_SET]: NodeType.Unset,
|
|
17
|
+
};
|
|
18
|
+
return conversionMap[status];
|
|
19
|
+
}
|
|
20
|
+
class Node {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
this.id = props.id;
|
|
23
|
+
this.name = props.name;
|
|
24
|
+
this.type = props.type;
|
|
25
|
+
this.data = props.data;
|
|
26
|
+
}
|
|
27
|
+
toRequest() {
|
|
28
|
+
const request = new avs_pb.TaskNode();
|
|
29
|
+
const raw = request.serializeBinary();
|
|
30
|
+
const parsed = avs_pb.TaskNode.deserializeBinary(raw);
|
|
31
|
+
if (!_.isEqual(request, parsed)) {
|
|
32
|
+
throw new Error("Invalid request object");
|
|
33
|
+
}
|
|
34
|
+
return request;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export default Node;
|