@avaprotocol/sdk-js 2.7.2 → 2.7.4

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.
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,22 @@
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
+ }): avs_pb.RestAPINode;
17
+ static fromResponse(raw: avs_pb.TaskNode): RestAPINode;
18
+ toRequest(): avs_pb.TaskNode;
19
+ static fromOutputData(outputData: avs_pb.RunNodeWithInputsResp): Record<string, unknown> | null;
20
+ }
21
+ export default RestAPINode;
22
+ //# sourceMappingURL=restApi.d.ts.map
@@ -0,0 +1,16 @@
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
@@ -14,6 +14,9 @@ declare class Step implements StepProps {
14
14
  endAt: number;
15
15
  metadata?: any;
16
16
  executionContext?: any;
17
+ gasUsed?: string;
18
+ gasPrice?: string;
19
+ totalGasCost?: string;
17
20
  constructor(props: StepProps);
18
21
  /**
19
22
  * Convert Step instance to plain object (StepProps)
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAMhD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,cAAM,IAAK,YAAW,SAAS;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,gBAAgB,CAAC,EAAE,GAAG,CAAC;gBAEX,KAAK,EAAE,SAAS;IAgB5B;;;OAGG;IACH,MAAM,IAAI,SAAS;IAkBnB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IAoC9D,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiEhC,OAAO,CAAC,MAAM,CAAC,iBAAi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
  this.endAt = props.endAt;
16
16
  this.metadata = props.metadata;
17
17
  this.executionContext = props.executionContext;
18
+ this.gasUsed = props.gasUsed;
19
+ this.gasPrice = props.gasPrice;
20
+ this.totalGasCost = props.totalGasCost;
18
21
  }
19
22
  /**
20
23
  * Convert Step instance to plain object (StepProps)
@@ -35,6 +38,9 @@ class Step {
35
38
  endAt: this.endAt,
36
39
  metadata: this.metadata,
37
40
  executionContext: this.executionContext,
41
+ ...(this.gasUsed && { gasUsed: this.gasUsed }),
42
+ ...(this.gasPrice && { gasPrice: this.gasPrice }),
43
+ ...(this.totalGasCost && { totalGasCost: this.totalGasCost }),
38
44
  };
39
45
  }
40
46
  static getOutput(step) {
@@ -209,6 +215,15 @@ class Step {
209
215
  const getEndAt = () => typeof step.getEndAt === "function"
210
216
  ? step.getEndAt()
211
217
  : step.endAt;
218
+ const getGasUsed = () => typeof step.getGasUsed === "function"
219
+ ? step.getGasUsed()
220
+ : step.gasUsed;
221
+ const getGasPrice = () => typeof step.getGasPrice === "function"
222
+ ? step.getGasPrice()
223
+ : step.gasPrice;
224
+ const getTotalGasCost = () => typeof step.getTotalGasCost === "function"
225
+ ? step.getTotalGasCost()
226
+ : step.totalGasCost;
212
227
  // Extract step-level metadata if present (per protobuf: Execution.Step.metadata)
213
228
  let stepMetadata = undefined;
214
229
  if (typeof step.getMetadata === "function" &&
@@ -251,6 +266,9 @@ class Step {
251
266
  endAt: getEndAt(),
252
267
  metadata: stepMetadata,
253
268
  executionContext,
269
+ gasUsed: getGasUsed() || undefined,
270
+ gasPrice: getGasPrice() || undefined,
271
+ totalGasCost: getTotalGasCost() || undefined,
254
272
  });
255
273
  }
256
274
  }
@@ -0,0 +1,48 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
2
+ import Node from "./node/interface";
3
+ import Edge from "./edge";
4
+ import Trigger from "./trigger/interface";
5
+ export declare const DefaultExpiredAt = -1;
6
+ import { WorkflowStatus, WorkflowProps, InputVariables } from "@avaprotocol/types";
7
+ export declare function convertStatusToString(status: avs_pb.TaskStatus): WorkflowStatus;
8
+ declare class Workflow implements WorkflowProps {
9
+ smartWalletAddress: string;
10
+ trigger: Trigger;
11
+ nodes: Node[];
12
+ edges: Edge[];
13
+ startAt: number;
14
+ expiredAt: number;
15
+ maxExecution: number;
16
+ id?: string;
17
+ owner?: string;
18
+ name?: string;
19
+ completedAt?: number;
20
+ status?: WorkflowStatus;
21
+ lastRanAt?: number;
22
+ executionCount?: number;
23
+ inputVariables?: InputVariables;
24
+ /**
25
+ * Create an instance of Workflow from user inputs
26
+ * @param props
27
+ */
28
+ constructor(props: WorkflowProps);
29
+ /**
30
+ * Create an instance of Workflow from AVS getWorkflow response
31
+ * @param res
32
+ * @returns
33
+ */
34
+ static fromResponse(obj: avs_pb.Task): Workflow;
35
+ /**
36
+ * Create an instance of Workflow with only selected fields
37
+ * @param obj
38
+ */
39
+ static fromListResponse(obj: avs_pb.Task): Workflow;
40
+ toRequest(): avs_pb.CreateTaskReq;
41
+ /**
42
+ * Convert Workflow instance to plain object (WorkflowProps)
43
+ * This is useful for serialization, especially with Next.js Server Components
44
+ */
45
+ toJson(): WorkflowProps;
46
+ }
47
+ export default Workflow;
48
+ //# sourceMappingURL=workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/models/workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,UAAU,GACxB,cAAc,CAUhB;AAED,cAAM,QAAS,YAAW,aAAa;IACrC,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cAAM,QAAS,YAAW,aAAa;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAGrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;OAGG;gBACS,KAAK,EAAE,aAAa;IAwBhC;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IAkC/C;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IAyBnD,SAAS,IAAI,MAAM,CAAC,aAAa;IA8DjC;;;OAGG;IACH,MAAM,IAAI,aAAa;CAmBxB;AAED,eAAe,QAAQ,CAAC"}
@@ -5,6 +5,7 @@ import TriggerFactory from "./trigger/factory";
5
5
  import NodeFactory from "./node/factory";
6
6
  export const DefaultExpiredAt = -1; // TODO: explain the meaning of -1
7
7
  import { WorkflowStatus } from "@avaprotocol/types";
8
+ import { convertJSValueToProtobuf } from "../utils";
8
9
  // Function to convert TaskStatus to string
9
10
  export function convertStatusToString(status) {
10
11
  const conversionMap = {
@@ -40,6 +41,7 @@ class Workflow {
40
41
  this.status = props.status;
41
42
  this.completedAt = props.completedAt;
42
43
  this.lastRanAt = props.lastRanAt;
44
+ this.inputVariables = props.inputVariables;
43
45
  }
44
46
  /**
45
47
  * Create an instance of Workflow from AVS getWorkflow response
@@ -145,6 +147,13 @@ class Workflow {
145
147
  if (this.name) {
146
148
  request.setName(this.name);
147
149
  }
150
+ // Add input variables if provided
151
+ if (this.inputVariables) {
152
+ const inputVarsMap = request.getInputVariablesMap();
153
+ for (const [key, value] of Object.entries(this.inputVariables)) {
154
+ inputVarsMap.set(key, convertJSValueToProtobuf(value));
155
+ }
156
+ }
148
157
  return request;
149
158
  }
150
159
  /**
@@ -167,6 +176,7 @@ class Workflow {
167
176
  status: this.status,
168
177
  completedAt: this.completedAt,
169
178
  lastRanAt: this.lastRanAt,
179
+ inputVariables: this.inputVariables,
170
180
  };
171
181
  }
172
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "2.7.2",
3
+ "version": "2.7.4",
4
4
  "description": "A JavaScript/TypeScript SDK designed to simplify integration with Ava Protocol's AVS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "prepare": "node ../../scripts/prepare-package.js"
32
32
  },
33
33
  "dependencies": {
34
- "@avaprotocol/types": "^2.5.2",
34
+ "@avaprotocol/types": "^2.5.4",
35
35
  "@grpc/grpc-js": "^1.11.3",
36
36
  "@grpc/proto-loader": "^0.7.13",
37
37
  "dotenv": "^16.4.5",