@avaprotocol/sdk-js 2.16.0 → 3.0.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.
Files changed (145) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +11 -1
  3. package/dist/index.d.ts +1 -370
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +854 -22403
  6. package/dist/index.mjs +817 -22436
  7. package/dist/v4/auth.d.ts +79 -0
  8. package/dist/v4/auth.d.ts.map +1 -0
  9. package/dist/v4/auth.js +92 -0
  10. package/dist/v4/builders/nodes.d.ts +106 -0
  11. package/dist/v4/builders/nodes.d.ts.map +1 -0
  12. package/dist/v4/builders/nodes.js +133 -0
  13. package/dist/v4/builders/triggers.d.ts +66 -0
  14. package/dist/v4/builders/triggers.d.ts.map +1 -0
  15. package/dist/v4/builders/triggers.js +74 -0
  16. package/dist/v4/chains.d.ts +19 -0
  17. package/dist/v4/chains.d.ts.map +1 -0
  18. package/dist/v4/chains.js +22 -0
  19. package/dist/v4/client.d.ts +60 -0
  20. package/dist/v4/client.d.ts.map +1 -0
  21. package/dist/v4/client.js +53 -0
  22. package/dist/v4/index.d.ts +19 -0
  23. package/dist/v4/index.d.ts.map +1 -0
  24. package/dist/v4/index.js +24 -0
  25. package/dist/v4/internal/errors.d.ts +36 -0
  26. package/dist/v4/internal/errors.d.ts.map +1 -0
  27. package/dist/v4/internal/errors.js +32 -0
  28. package/dist/v4/internal/transport.d.ts +64 -0
  29. package/dist/v4/internal/transport.d.ts.map +1 -0
  30. package/dist/v4/internal/transport.js +133 -0
  31. package/dist/v4/protocols/index.d.ts +2 -0
  32. package/dist/v4/protocols/index.d.ts.map +1 -0
  33. package/dist/v4/protocols/index.js +13 -0
  34. package/dist/v4/resources/auth.d.ts +45 -0
  35. package/dist/v4/resources/auth.d.ts.map +1 -0
  36. package/dist/v4/resources/auth.js +59 -0
  37. package/dist/v4/resources/executions.d.ts +74 -0
  38. package/dist/v4/resources/executions.d.ts.map +1 -0
  39. package/dist/v4/resources/executions.js +132 -0
  40. package/dist/v4/resources/health.d.ts +19 -0
  41. package/dist/v4/resources/health.d.ts.map +1 -0
  42. package/dist/v4/resources/health.js +19 -0
  43. package/dist/v4/resources/nodes.d.ts +29 -0
  44. package/dist/v4/resources/nodes.d.ts.map +1 -0
  45. package/dist/v4/resources/nodes.js +33 -0
  46. package/dist/v4/resources/operators.d.ts +23 -0
  47. package/dist/v4/resources/operators.d.ts.map +1 -0
  48. package/dist/v4/resources/operators.js +23 -0
  49. package/dist/v4/resources/secrets.d.ts +34 -0
  50. package/dist/v4/resources/secrets.d.ts.map +1 -0
  51. package/dist/v4/resources/secrets.js +38 -0
  52. package/dist/v4/resources/tokens.d.ts +28 -0
  53. package/dist/v4/resources/tokens.d.ts.map +1 -0
  54. package/dist/v4/resources/tokens.js +29 -0
  55. package/dist/v4/resources/triggers.d.ts +29 -0
  56. package/dist/v4/resources/triggers.d.ts.map +1 -0
  57. package/dist/v4/resources/triggers.js +33 -0
  58. package/dist/v4/resources/wallets.d.ts +72 -0
  59. package/dist/v4/resources/wallets.d.ts.map +1 -0
  60. package/dist/v4/resources/wallets.js +92 -0
  61. package/dist/v4/resources/workflows.d.ts +64 -0
  62. package/dist/v4/resources/workflows.d.ts.map +1 -0
  63. package/dist/v4/resources/workflows.js +91 -0
  64. package/package.json +9 -11
  65. package/dist/auth.d.ts +0 -2
  66. package/dist/auth.d.ts.map +0 -1
  67. package/dist/auth.js +0 -10
  68. package/dist/config.d.ts +0 -9
  69. package/dist/config.d.ts.map +0 -1
  70. package/dist/config.js +0 -19
  71. package/dist/models/edge.d.ts +0 -12
  72. package/dist/models/edge.d.ts.map +0 -1
  73. package/dist/models/edge.js +0 -19
  74. package/dist/models/execution.d.ts +0 -20
  75. package/dist/models/execution.d.ts.map +0 -1
  76. package/dist/models/execution.js +0 -97
  77. package/dist/models/node/balance.d.ts +0 -17
  78. package/dist/models/node/balance.d.ts.map +0 -1
  79. package/dist/models/node/balance.js +0 -78
  80. package/dist/models/node/branch.d.ts +0 -11
  81. package/dist/models/node/branch.d.ts.map +0 -1
  82. package/dist/models/node/branch.js +0 -63
  83. package/dist/models/node/contractRead.d.ts +0 -17
  84. package/dist/models/node/contractRead.d.ts.map +0 -1
  85. package/dist/models/node/contractRead.js +0 -91
  86. package/dist/models/node/contractWrite.d.ts +0 -17
  87. package/dist/models/node/contractWrite.d.ts.map +0 -1
  88. package/dist/models/node/contractWrite.js +0 -102
  89. package/dist/models/node/customCode.d.ts +0 -20
  90. package/dist/models/node/customCode.d.ts.map +0 -1
  91. package/dist/models/node/customCode.js +0 -74
  92. package/dist/models/node/ethTransfer.d.ts +0 -20
  93. package/dist/models/node/ethTransfer.d.ts.map +0 -1
  94. package/dist/models/node/ethTransfer.js +0 -58
  95. package/dist/models/node/factory.d.ts +0 -24
  96. package/dist/models/node/factory.d.ts.map +0 -1
  97. package/dist/models/node/factory.js +0 -108
  98. package/dist/models/node/filter.d.ts +0 -11
  99. package/dist/models/node/filter.d.ts.map +0 -1
  100. package/dist/models/node/filter.js +0 -57
  101. package/dist/models/node/graphqlQuery.d.ts +0 -21
  102. package/dist/models/node/graphqlQuery.d.ts.map +0 -1
  103. package/dist/models/node/graphqlQuery.js +0 -74
  104. package/dist/models/node/interface.d.ts +0 -20
  105. package/dist/models/node/interface.d.ts.map +0 -1
  106. package/dist/models/node/interface.js +0 -58
  107. package/dist/models/node/loop.d.ts +0 -15
  108. package/dist/models/node/loop.d.ts.map +0 -1
  109. package/dist/models/node/loop.js +0 -235
  110. package/dist/models/node/restApi.d.ts +0 -23
  111. package/dist/models/node/restApi.d.ts.map +0 -1
  112. package/dist/models/node/restApi.js +0 -84
  113. package/dist/models/secret.d.ts +0 -16
  114. package/dist/models/secret.d.ts.map +0 -1
  115. package/dist/models/secret.js +0 -28
  116. package/dist/models/step.d.ts +0 -33
  117. package/dist/models/step.d.ts.map +0 -1
  118. package/dist/models/step.js +0 -287
  119. package/dist/models/trigger/block.d.ts +0 -21
  120. package/dist/models/trigger/block.d.ts.map +0 -1
  121. package/dist/models/trigger/block.js +0 -81
  122. package/dist/models/trigger/cron.d.ts +0 -23
  123. package/dist/models/trigger/cron.d.ts.map +0 -1
  124. package/dist/models/trigger/cron.js +0 -77
  125. package/dist/models/trigger/event.d.ts +0 -22
  126. package/dist/models/trigger/event.d.ts.map +0 -1
  127. package/dist/models/trigger/event.js +0 -244
  128. package/dist/models/trigger/factory.d.ts +0 -27
  129. package/dist/models/trigger/factory.d.ts.map +0 -1
  130. package/dist/models/trigger/factory.js +0 -73
  131. package/dist/models/trigger/fixedTime.d.ts +0 -23
  132. package/dist/models/trigger/fixedTime.d.ts.map +0 -1
  133. package/dist/models/trigger/fixedTime.js +0 -69
  134. package/dist/models/trigger/interface.d.ts +0 -19
  135. package/dist/models/trigger/interface.d.ts.map +0 -1
  136. package/dist/models/trigger/interface.js +0 -35
  137. package/dist/models/trigger/manual.d.ts +0 -16
  138. package/dist/models/trigger/manual.d.ts.map +0 -1
  139. package/dist/models/trigger/manual.js +0 -117
  140. package/dist/models/workflow.d.ts +0 -53
  141. package/dist/models/workflow.d.ts.map +0 -1
  142. package/dist/models/workflow.js +0 -219
  143. package/dist/utils.d.ts +0 -82
  144. package/dist/utils.d.ts.map +0 -1
  145. package/dist/utils.js +0 -286
@@ -1,57 +0,0 @@
1
- import Node from "./interface";
2
- import * as avs_pb from "@/grpc_codegen/avs_pb";
3
- import { NodeType, } from "@avaprotocol/types";
4
- // Required props for constructor: id, name, type and data: { expression, inputVariable }
5
- class FilterNode extends Node {
6
- constructor(props) {
7
- super({ ...props, type: NodeType.Filter, data: props.data });
8
- }
9
- static fromResponse(raw) {
10
- // Convert the raw object to FilterNodeProps, which should keep name and id
11
- const obj = raw.toObject();
12
- return new FilterNode({
13
- ...obj,
14
- type: NodeType.Filter,
15
- data: raw.getFilter().getConfig().toObject(),
16
- });
17
- }
18
- toRequest() {
19
- const request = new avs_pb.TaskNode();
20
- request.setId(this.id);
21
- request.setName(this.name);
22
- request.setType(avs_pb.NodeType.NODE_TYPE_FILTER);
23
- const node = new avs_pb.FilterNode();
24
- const config = new avs_pb.FilterNode.Config();
25
- config.setExpression(this.data.expression);
26
- config.setInputVariable(this.data.inputVariable || "");
27
- node.setConfig(config);
28
- request.setFilter(node);
29
- return request;
30
- }
31
- static fromOutputData(outputData) {
32
- const filterOutput = outputData.getFilter();
33
- if (!filterOutput) {
34
- throw new Error("FilterNode output data is missing");
35
- }
36
- const anyData = filterOutput.getData();
37
- if (!anyData) {
38
- throw new Error("FilterNode output data.getData() is missing");
39
- }
40
- // The data is now directly a Value containing the filtered array
41
- const result = anyData.toJavaScript();
42
- // If result is already an array, return it directly (this should be the normal case now)
43
- if (Array.isArray(result)) {
44
- return result;
45
- }
46
- // Fallback: if result is an object with data field
47
- if (result &&
48
- typeof result === "object" &&
49
- !Array.isArray(result) &&
50
- result.data &&
51
- Array.isArray(result.data)) {
52
- return result.data;
53
- }
54
- throw new Error("FilterNode output data does not contain expected data structure");
55
- }
56
- }
57
- export default FilterNode;
@@ -1,21 +0,0 @@
1
- import Node from "./interface";
2
- import * as avs_pb from "@/grpc_codegen/avs_pb";
3
- import { GraphQLQueryNodeProps } from "@avaprotocol/types";
4
- declare class GraphQLQueryNode extends Node {
5
- constructor(props: GraphQLQueryNodeProps);
6
- /**
7
- * Create a protobuf GraphQLQueryNode from config data
8
- * @param configData - The configuration data for the GraphQL query node
9
- * @returns Configured avs_pb.GraphQLQueryNode
10
- */
11
- static createProtobufNode(configData: {
12
- url: string;
13
- query: string;
14
- variables?: Record<string, string>;
15
- }): avs_pb.GraphQLQueryNode;
16
- static fromResponse(raw: avs_pb.TaskNode): GraphQLQueryNode;
17
- toRequest(): avs_pb.TaskNode;
18
- static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): Record<string, unknown> | null;
19
- }
20
- export default GraphQLQueryNode;
21
- //# sourceMappingURL=graphqlQuery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graphqlQuery.d.ts","sourceRoot":"","sources":["../../../src/models/node/graphqlQuery.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,qBAAqB,EAEtB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,gBAAiB,SAAQ,IAAI;gBACrB,KAAK,EAAE,qBAAqB;IAQxC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACpC,GAAG,MAAM,CAAC,gBAAgB;IAkB3B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,gBAAgB;IAuB3D,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,qBAAqB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAclC;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,74 +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: { url, query, variablesMap }
6
- class GraphQLQueryNode extends Node {
7
- constructor(props) {
8
- super({
9
- ...props,
10
- type: NodeType.GraphQLQuery,
11
- data: props.data,
12
- });
13
- }
14
- /**
15
- * Create a protobuf GraphQLQueryNode from config data
16
- * @param configData - The configuration data for the GraphQL query node
17
- * @returns Configured avs_pb.GraphQLQueryNode
18
- */
19
- static createProtobufNode(configData) {
20
- const node = new avs_pb.GraphQLQueryNode();
21
- const config = new avs_pb.GraphQLQueryNode.Config();
22
- config.setUrl(configData.url);
23
- config.setQuery(configData.query);
24
- if (configData.variables && Object.keys(configData.variables).length > 0) {
25
- const variablesMap = config.getVariablesMap();
26
- Object.entries(configData.variables).forEach(([key, value]) => {
27
- variablesMap.set(key, value);
28
- });
29
- }
30
- node.setConfig(config);
31
- return node;
32
- }
33
- static fromResponse(raw) {
34
- // Convert the raw object to GraphQLQueryNodeProps, which should keep name and id
35
- const obj = raw.toObject();
36
- const config = raw.getGraphqlQuery().getConfig();
37
- const variablesMap = config.getVariablesMap();
38
- const variables = {};
39
- variablesMap.forEach((value, key) => {
40
- variables[key] = value;
41
- });
42
- return new GraphQLQueryNode({
43
- ...obj,
44
- type: NodeType.GraphQLQuery,
45
- data: {
46
- url: config.getUrl(),
47
- query: config.getQuery(),
48
- variables: variables,
49
- },
50
- });
51
- }
52
- toRequest() {
53
- const request = new avs_pb.TaskNode();
54
- request.setId(this.id);
55
- request.setName(this.name);
56
- request.setType(avs_pb.NodeType.NODE_TYPE_GRAPHQL_QUERY);
57
- const node = GraphQLQueryNode.createProtobufNode(this.data);
58
- request.setGraphqlQuery(node);
59
- return request;
60
- }
61
- static fromOutputData(outputData) {
62
- const graphqlOutput = outputData.getGraphql();
63
- if (!graphqlOutput) {
64
- return null;
65
- }
66
- // Use convertProtobufValueToJs to get clean JavaScript objects
67
- const rawData = graphqlOutput.getData();
68
- if (rawData) {
69
- return convertProtobufValueToJs(rawData);
70
- }
71
- return null;
72
- }
73
- }
74
- export default GraphQLQueryNode;
@@ -1,20 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import { NodeType, NodeProps, NodeData } from "@avaprotocol/types";
3
- export declare function covertNodeTypeToString(status: avs_pb.TaskNode.TaskTypeCase): NodeType;
4
- export type ProtobufNodeProps = Omit<avs_pb.TaskNode.AsObject, "ethTransfer" | "contractWrite" | "contractRead" | "graphqlDataQuery" | "restApi" | "branch" | "filter" | "loop" | "customCode"> & {
5
- data: any;
6
- };
7
- export declare const ProtobufNodePropsUtils: {
8
- getGoStringType: (props: ProtobufNodeProps) => string;
9
- fromGoStringType: (goStringType: string, baseProps: Omit<ProtobufNodeProps, "type">) => ProtobufNodeProps;
10
- };
11
- export default abstract class Node implements NodeProps {
12
- id: string;
13
- name: string;
14
- type: NodeType;
15
- data: NodeData;
16
- constructor(props: NodeProps);
17
- toRequest(): avs_pb.TaskNode;
18
- static fromResponse(raw: avs_pb.TaskNode): Node;
19
- }
20
- //# sourceMappingURL=interface.d.ts.map
@@ -1 +0,0 @@
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,EACL,QAAQ,EAER,SAAS,EACT,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAI5B,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,GACnC,QAAQ,CAgBV;AAGD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,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;IAEF,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAGF,eAAO,MAAM,sBAAsB;6BAER,iBAAiB,KAAG,MAAM;qCAMnC,MAAM,aACT,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,KACzC,iBAAiB;CAMrB,CAAC;AAEF,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,IAAK,YAAW,SAAS;IACrD,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;IAW5B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,IAAI;CAQhD"}
@@ -1,58 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import { NodeType, NodeTypeGoConverter, } 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.BALANCE]: NodeType.Balance,
17
- [avs_pb.TaskNode.TaskTypeCase.TASK_TYPE_NOT_SET]: NodeType.Unspecified,
18
- };
19
- return conversionMap[status];
20
- }
21
- // Utility functions to work with protobuf NodeProps
22
- export const ProtobufNodePropsUtils = {
23
- // Get the Go backend string representation of the node type
24
- getGoStringType: (props) => {
25
- return NodeTypeGoConverter.toGoString(props.type);
26
- },
27
- // Create ProtobufNodeProps from Go string type
28
- fromGoStringType: (goStringType, baseProps) => {
29
- return {
30
- ...baseProps,
31
- type: NodeTypeGoConverter.fromGoString(goStringType),
32
- };
33
- },
34
- };
35
- export default class Node {
36
- constructor(props) {
37
- this.id = props.id;
38
- this.name = props.name;
39
- this.type = props.type;
40
- this.data = props.data;
41
- }
42
- toRequest() {
43
- const request = new avs_pb.TaskNode();
44
- const raw = request.serializeBinary();
45
- const parsed = avs_pb.TaskNode.deserializeBinary(raw);
46
- if (!_.isEqual(request, parsed)) {
47
- throw new Error("Invalid request object");
48
- }
49
- return request;
50
- }
51
- static fromResponse(raw) {
52
- // Convert the raw object to NodeProps, which should keep name and id
53
- const obj = raw.toObject();
54
- return new this({
55
- ...obj,
56
- });
57
- }
58
- }
@@ -1,15 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import Node from "./interface";
3
- import { LoopNodeProps } from "@avaprotocol/types";
4
- declare class LoopNode extends Node {
5
- constructor(props: LoopNodeProps);
6
- static fromResponse(raw: avs_pb.TaskNode): LoopNode;
7
- private static extractRunnerFromProtobuf;
8
- private static mapExecutionModeFromProtobuf;
9
- private mapExecutionModeToProtobuf;
10
- toRequest(): avs_pb.TaskNode;
11
- private setRunnerOnProtobuf;
12
- static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): unknown;
13
- }
14
- export default LoopNode;
15
- //# sourceMappingURL=loop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/models/node/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,aAAa,CAAC;AAO/B,OAAO,EAGL,aAAa,EAKd,MAAM,oBAAoB,CAAC;AAG5B,cAAM,QAAS,SAAQ,IAAI;gBACb,KAAK,EAAE,aAAa;IAIhC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ;IA4BnD,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAsBxC,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAe3C,OAAO,CAAC,0BAA0B;IA4BlC,SAAS,IAAI,MAAM,CAAC,QAAQ;IAoC5B,OAAO,CAAC,mBAAmB;IAuH3B,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,qBAAqB,GAAG,OAAO;CAkCzE;AAED,eAAe,QAAQ,CAAC"}
@@ -1,235 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import Node from "./interface";
3
- import CustomCodeNode from "./customCode";
4
- import ETHTransferNode from "./ethTransfer";
5
- import RestAPINode from "./restApi";
6
- import GraphQLQueryNode from "./graphqlQuery";
7
- import ContractReadNode from "./contractRead";
8
- import ContractWriteNode from "./contractWrite";
9
- import { NodeType, ExecutionMode, } from "@avaprotocol/types";
10
- import { convertProtobufValueToJs } from "../../utils";
11
- class LoopNode extends Node {
12
- constructor(props) {
13
- super({ ...props, type: NodeType.Loop, data: props.data });
14
- }
15
- static fromResponse(raw) {
16
- const obj = raw.toObject();
17
- const loopNode = raw.getLoop();
18
- if (!loopNode) {
19
- throw new Error("Response does not contain a Loop node");
20
- }
21
- // Get the config data directly as flat structure
22
- const configData = loopNode.getConfig()?.toObject();
23
- const loopNodeData = loopNode.toObject();
24
- const data = {
25
- ...configData,
26
- // Extract runner data from the oneof runner field
27
- runner: this.extractRunnerFromProtobuf(loopNodeData),
28
- // Map execution mode from protobuf enum to ExecutionMode enum
29
- executionMode: this.mapExecutionModeFromProtobuf(configData?.executionMode),
30
- };
31
- return new LoopNode({
32
- ...obj,
33
- type: NodeType.Loop,
34
- data: data,
35
- });
36
- }
37
- static extractRunnerFromProtobuf(loopNodeData) {
38
- // Define a mapping of runner types to their corresponding data keys
39
- const runnerMapping = {
40
- restApi: "restApi",
41
- customCode: "customCode",
42
- ethTransfer: "ethTransfer",
43
- contractRead: "contractRead",
44
- contractWrite: "contractWrite",
45
- graphqlDataQuery: "graphqlDataQuery",
46
- };
47
- // Iterate over the mapping to find the matching runner type
48
- for (const [type, key] of Object.entries(runnerMapping)) {
49
- if (loopNodeData[key]) {
50
- return { type, config: loopNodeData[key] };
51
- }
52
- }
53
- return null;
54
- }
55
- static mapExecutionModeFromProtobuf(executionMode) {
56
- // Map protobuf ExecutionMode enum to ExecutionMode enum
57
- // EXECUTION_MODE_SEQUENTIAL = 0, EXECUTION_MODE_PARALLEL = 1
58
- switch (executionMode) {
59
- case 0:
60
- return ExecutionMode.Sequential;
61
- case 1:
62
- return ExecutionMode.Parallel;
63
- default:
64
- return ExecutionMode.Sequential; // Default to sequential for safety
65
- }
66
- }
67
- mapExecutionModeToProtobuf(executionMode) {
68
- // Map ExecutionMode enum or string to protobuf ExecutionMode enum
69
- // EXECUTION_MODE_SEQUENTIAL = 0, EXECUTION_MODE_PARALLEL = 1
70
- if (!executionMode) {
71
- return 0; // Default to sequential for safety
72
- }
73
- if (typeof executionMode === "string") {
74
- switch (executionMode.toLowerCase()) {
75
- case ExecutionMode.Parallel:
76
- return 1;
77
- case ExecutionMode.Sequential:
78
- default:
79
- return 0; // Default to sequential for safety
80
- }
81
- }
82
- else {
83
- switch (executionMode) {
84
- case ExecutionMode.Parallel:
85
- return 1;
86
- case ExecutionMode.Sequential:
87
- default:
88
- return 0; // Default to sequential for safety
89
- }
90
- }
91
- }
92
- toRequest() {
93
- const node = new avs_pb.TaskNode();
94
- const loopNode = new avs_pb.LoopNode();
95
- node.setId(this.id);
96
- node.setName(this.name);
97
- node.setType(avs_pb.NodeType.NODE_TYPE_LOOP);
98
- const data = this.data;
99
- // Set the loop config from the flat data structure
100
- const config = new avs_pb.LoopNode.Config();
101
- config.setInputVariable(data.inputVariable || "");
102
- config.setIterVal(data.iterVal || "");
103
- config.setIterKey(data.iterKey || "");
104
- // Set execution mode - map ExecutionMode enum to protobuf enum
105
- const executionMode = this.mapExecutionModeToProtobuf(data.executionMode);
106
- config.setExecutionMode(executionMode);
107
- // Per-iteration timeout in seconds. The server requires this field and will
108
- // reject the request if it is 0 or missing. No default is applied here —
109
- // the caller must explicitly provide iterationTimeout in their node config.
110
- config.setIterationTimeout(data.iterationTimeout);
111
- loopNode.setConfig(config);
112
- // Handle runner - check the runner field and set the appropriate oneof field
113
- if (data.runner) {
114
- this.setRunnerOnProtobuf(loopNode, data.runner);
115
- }
116
- node.setLoop(loopNode);
117
- return node;
118
- }
119
- setRunnerOnProtobuf(loopNode, runner) {
120
- if (!runner || !runner.type) {
121
- return;
122
- }
123
- // Support both old structure (runner.data.config) and new structure (runner.config)
124
- const config = runner.config || (runner.data && runner.data.config);
125
- if (!config) {
126
- return;
127
- }
128
- switch (runner.type) {
129
- case "ethTransfer": {
130
- const ethConfig = config;
131
- const ethTransfer = ETHTransferNode.createProtobufNode({
132
- destination: ethConfig.destination,
133
- amount: ethConfig.amount,
134
- });
135
- loopNode.setEthTransfer(ethTransfer);
136
- break;
137
- }
138
- case "contractWrite": {
139
- const writeConfig = config;
140
- const contractWriteData = {
141
- contractAddress: writeConfig.contractAddress,
142
- contractAbi: writeConfig.contractAbi,
143
- methodCalls: writeConfig.methodCalls?.map((call) => ({
144
- methodName: call.methodName || "",
145
- methodParams: call.methodParams || [],
146
- ...(call.callData && { callData: call.callData }),
147
- })) || [],
148
- };
149
- // Include isSimulated if present
150
- if (writeConfig.isSimulated !== undefined) {
151
- contractWriteData.isSimulated = writeConfig.isSimulated;
152
- }
153
- const contractWrite = ContractWriteNode.createProtobufNode(contractWriteData);
154
- loopNode.setContractWrite(contractWrite);
155
- break;
156
- }
157
- case "contractRead": {
158
- const readConfig = config;
159
- const contractRead = ContractReadNode.createProtobufNode({
160
- contractAddress: readConfig.contractAddress,
161
- contractAbi: readConfig.contractAbi,
162
- methodCalls: readConfig.methodCalls?.map((call) => ({
163
- methodName: call.methodName || "",
164
- methodParams: call.methodParams || [],
165
- ...(call.callData && { callData: call.callData }),
166
- ...(call.applyToFields && { applyToFields: call.applyToFields }),
167
- })) || [],
168
- });
169
- loopNode.setContractRead(contractRead);
170
- break;
171
- }
172
- case "graphqlQuery":
173
- case "graphqlDataQuery": {
174
- const gqlConfig = config;
175
- const graphqlQuery = GraphQLQueryNode.createProtobufNode({
176
- url: gqlConfig.url,
177
- query: gqlConfig.query,
178
- variables: gqlConfig.variables,
179
- });
180
- loopNode.setGraphqlDataQuery(graphqlQuery);
181
- break;
182
- }
183
- case "restApi": {
184
- const apiConfig = config;
185
- const restApi = RestAPINode.createProtobufNode({
186
- url: apiConfig.url,
187
- method: apiConfig.method,
188
- body: apiConfig.body || "",
189
- headers: apiConfig.headers,
190
- });
191
- loopNode.setRestApi(restApi);
192
- break;
193
- }
194
- case "customCode": {
195
- const codeConfig = config;
196
- const customCode = CustomCodeNode.createProtobufNode({
197
- lang: codeConfig.lang,
198
- source: codeConfig.source,
199
- });
200
- loopNode.setCustomCode(customCode);
201
- break;
202
- }
203
- }
204
- }
205
- static fromOutputData(outputData) {
206
- // For workflow execution, data comes as Loop format with new protobuf Value
207
- const loopOutput = outputData.getLoop();
208
- if (loopOutput) {
209
- // Extract data from the new data field
210
- const dataValue = loopOutput.getData();
211
- if (dataValue) {
212
- try {
213
- // Use the standard protobuf conversion utility
214
- return convertProtobufValueToJs(dataValue);
215
- }
216
- catch (error) {
217
- console.warn("Failed to convert loop data from protobuf Value:", error);
218
- return null;
219
- }
220
- }
221
- }
222
- // Fallback: For immediate execution, data might come as CustomCode format
223
- const customCodeOutput = outputData.getCustomCode();
224
- if (customCodeOutput) {
225
- // Use convertProtobufValueToJs to get clean JavaScript objects
226
- const rawData = customCodeOutput.getData();
227
- if (rawData) {
228
- return convertProtobufValueToJs(rawData);
229
- }
230
- return null;
231
- }
232
- return null;
233
- }
234
- }
235
- export default LoopNode;
@@ -1,23 +0,0 @@
1
- import Node from "./interface";
2
- import * as avs_pb from "@/grpc_codegen/avs_pb";
3
- import { RestAPINodeProps } from "@avaprotocol/types";
4
- declare class RestAPINode extends Node {
5
- constructor(props: RestAPINodeProps);
6
- /**
7
- * Create a protobuf RestAPINode from config data
8
- * @param configData - The configuration data for the REST API node
9
- * @returns Configured avs_pb.RestAPINode
10
- */
11
- static createProtobufNode(configData: {
12
- url: string;
13
- method: string;
14
- body?: string;
15
- headers?: Record<string, string>;
16
- options?: Record<string, unknown>;
17
- }): avs_pb.RestAPINode;
18
- static fromResponse(raw: avs_pb.TaskNode): RestAPINode;
19
- toRequest(): avs_pb.TaskNode;
20
- static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): Record<string, unknown> | null;
21
- }
22
- export default RestAPINode;
23
- //# sourceMappingURL=restApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restApi.d.ts","sourceRoot":"","sources":["../../../src/models/node/restApi.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAGL,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,WAAY,SAAQ,IAAI;gBAChB,KAAK,EAAE,gBAAgB;IAInC;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE;QACpC,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,GAAG,MAAM,CAAC,WAAW;IAuBtB,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,WAAW;IAgCtD,SAAS,IAAI,MAAM,CAAC,QAAQ;IAgB5B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,MAAM,CAAC,qBAAqB,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAclC;AAED,eAAe,WAAW,CAAC"}
@@ -1,84 +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, convertJSValueToProtobuf } from "../../utils";
5
- // Required props for constructor: id, name, type and data: { url, method, headersMap, body }
6
- class RestAPINode extends Node {
7
- constructor(props) {
8
- super({ ...props, type: NodeType.RestAPI, data: props.data });
9
- }
10
- /**
11
- * Create a protobuf RestAPINode from config data
12
- * @param configData - The configuration data for the REST API node
13
- * @returns Configured avs_pb.RestAPINode
14
- */
15
- static createProtobufNode(configData) {
16
- const node = new avs_pb.RestAPINode();
17
- const config = new avs_pb.RestAPINode.Config();
18
- config.setUrl(configData.url);
19
- config.setMethod(configData.method);
20
- config.setBody(configData.body || "");
21
- if (configData.headers && Object.keys(configData.headers).length > 0) {
22
- const headersMap = config.getHeadersMap();
23
- Object.entries(configData.headers).forEach(([key, value]) => {
24
- headersMap.set(key, value);
25
- });
26
- }
27
- if (configData.options) {
28
- config.setOptions(convertJSValueToProtobuf(configData.options));
29
- }
30
- node.setConfig(config);
31
- return node;
32
- }
33
- static fromResponse(raw) {
34
- // Convert the raw object to RestAPINodeProps, which should keep name and id
35
- const obj = raw.toObject();
36
- const config = raw.getRestApi().getConfig();
37
- return new RestAPINode({
38
- ...obj,
39
- type: NodeType.RestAPI,
40
- data: {
41
- url: config.getUrl(),
42
- method: config.getMethod(),
43
- body: config.getBody(),
44
- headers: (() => {
45
- const headersMap = config.getHeadersMap();
46
- const headers = {};
47
- headersMap.forEach((value, key) => {
48
- headers[key] = value;
49
- });
50
- return headers;
51
- })(),
52
- options: (() => {
53
- const optionsProto = config.getOptions();
54
- if (optionsProto) {
55
- return convertProtobufValueToJs(optionsProto);
56
- }
57
- return undefined;
58
- })(),
59
- },
60
- });
61
- }
62
- toRequest() {
63
- const request = new avs_pb.TaskNode();
64
- request.setId(this.id);
65
- request.setName(this.name);
66
- request.setType(avs_pb.NodeType.NODE_TYPE_REST_API);
67
- const nodeData = RestAPINode.createProtobufNode(this.data);
68
- request.setRestApi(nodeData);
69
- return request;
70
- }
71
- static fromOutputData(outputData) {
72
- const restApiOutput = outputData.getRestApi();
73
- if (!restApiOutput) {
74
- return null;
75
- }
76
- // Use convertProtobufValueToJs to get clean JavaScript objects
77
- const rawData = restApiOutput.getData();
78
- if (rawData) {
79
- return convertProtobufValueToJs(rawData);
80
- }
81
- return restApiOutput.toObject();
82
- }
83
- }
84
- export default RestAPINode;
@@ -1,16 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import { SecretProps } from "@avaprotocol/types";
3
- declare class Secret implements SecretProps {
4
- name: string;
5
- secret?: string;
6
- workflowId?: string;
7
- orgId?: string;
8
- createdAt?: number;
9
- updatedAt?: number;
10
- createdBy?: string;
11
- description?: string;
12
- constructor(props: SecretProps);
13
- toRequest(): avs_pb.CreateOrUpdateSecretReq;
14
- }
15
- export default Secret;
16
- //# sourceMappingURL=secret.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../../src/models/secret.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,cAAM,MAAO,YAAW,WAAW;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,KAAK,EAAE,WAAW;IAW9B,SAAS,IAAI,MAAM,CAAC,uBAAuB;CAgB5C;AAED,eAAe,MAAM,CAAC"}
@@ -1,28 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- class Secret {
3
- constructor(props) {
4
- this.name = props.name;
5
- this.secret = props.secret;
6
- this.workflowId = props.workflowId;
7
- this.orgId = props.orgId;
8
- this.createdAt = props.createdAt;
9
- this.updatedAt = props.updatedAt;
10
- this.createdBy = props.createdBy;
11
- this.description = props.description;
12
- }
13
- toRequest() {
14
- const request = new avs_pb.CreateOrUpdateSecretReq();
15
- request.setName(this.name);
16
- if (this.secret) {
17
- request.setSecret(this.secret);
18
- }
19
- if (this.orgId) {
20
- request.setOrgId(this.orgId);
21
- }
22
- if (this.workflowId) {
23
- request.setWorkflowId(this.workflowId);
24
- }
25
- return request;
26
- }
27
- }
28
- export default Secret;