@avaprotocol/sdk-js 2.0.3 → 2.1.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.
@@ -9,6 +9,11 @@ declare class Execution implements ExecutionProps {
9
9
  error: string;
10
10
  steps: Step[];
11
11
  constructor(props: ExecutionProps);
12
+ /**
13
+ * Convert Execution instance to plain object (ExecutionProps)
14
+ * This is useful for serialization, especially with Next.js Server Components
15
+ */
16
+ toJson(): ExecutionProps;
12
17
  static fromResponse(execution: avs_pb.Execution): Execution;
13
18
  }
14
19
  export default Execution;
@@ -1 +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,EAAqC,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,IAAI,MAAM,QAAQ,CAAC;AAI1B,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,KAAK,EAAE,IAAI,EAAE,CAAC;gBAEF,KAAK,EAAE,cAAc;IASjC,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS;CAc5D;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/models/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAqC,cAAc,EAAa,MAAM,oBAAoB,CAAC;AAClG,OAAO,IAAI,MAAM,QAAQ,CAAC;AAI1B,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,KAAK,EAAE,IAAI,EAAE,CAAC;gBAEF,KAAK,EAAE,cAAc;IASjC;;;OAGG;IACH,MAAM,IAAI,cAAc;IAWxB,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS;CAc5D;AAED,eAAe,SAAS,CAAC"}
@@ -6,7 +6,21 @@ class Execution {
6
6
  this.endAt = props.endAt;
7
7
  this.success = props.success;
8
8
  this.error = props.error;
9
- this.steps = props.steps;
9
+ this.steps = props.steps.map(s => new Step(s));
10
+ }
11
+ /**
12
+ * Convert Execution instance to plain object (ExecutionProps)
13
+ * This is useful for serialization, especially with Next.js Server Components
14
+ */
15
+ toJson() {
16
+ return {
17
+ id: this.id,
18
+ startAt: this.startAt,
19
+ endAt: this.endAt,
20
+ success: this.success,
21
+ error: this.error,
22
+ steps: this.steps.map(step => step.toJson()),
23
+ };
10
24
  }
11
25
  static fromResponse(execution) {
12
26
  return new Execution({
@@ -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
@@ -12,6 +12,11 @@ declare class Step implements StepProps {
12
12
  startAt: number;
13
13
  endAt: number;
14
14
  constructor(props: StepProps);
15
+ /**
16
+ * Convert Step instance to plain object (StepProps)
17
+ * This is useful for serialization, especially with Next.js Server Components
18
+ */
19
+ toJson(): StepProps;
15
20
  static getOutput(step: avs_pb.Execution.Step): OutputDataProps;
16
21
  static fromResponse(step: avs_pb.Execution.Step): Step;
17
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAKhD,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,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,SAAS;IAa5B,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IA8F9D,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAgBvD;AAED,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAKhD,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,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,SAAS;IAa5B;;;OAGG;IACH,MAAM,IAAI,SAAS;IAenB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IA8F9D,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAgBvD;AAED,eAAe,IAAI,CAAC"}
@@ -13,6 +13,24 @@ class Step {
13
13
  this.startAt = props.startAt;
14
14
  this.endAt = props.endAt;
15
15
  }
16
+ /**
17
+ * Convert Step instance to plain object (StepProps)
18
+ * This is useful for serialization, especially with Next.js Server Components
19
+ */
20
+ toJson() {
21
+ return {
22
+ id: this.id,
23
+ type: this.type,
24
+ name: this.name,
25
+ success: this.success,
26
+ error: this.error,
27
+ log: this.log,
28
+ inputsList: this.inputsList,
29
+ output: this.output,
30
+ startAt: this.startAt,
31
+ endAt: this.endAt,
32
+ };
33
+ }
16
34
  static getOutput(step) {
17
35
  const outputDataType = step.getOutputDataCase();
18
36
  let nodeOutputMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAA0B,MAAM,aAAa,CAAC;AACrD,OAAO,EAAqC,kBAAkB,EAAE,iBAAiB,EAAgB,MAAM,oBAAoB,CAAC;AAwB5H,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAyC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAiC1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAA0B,MAAM,aAAa,CAAC;AACrD,OAAO,EAAqC,kBAAkB,EAAE,iBAAiB,EAAgB,MAAM,oBAAoB,CAAC;AA6C5H,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAuD/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAoD1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAW9D;AAED,eAAe,YAAY,CAAC"}
@@ -1,4 +1,3 @@
1
- import * as _ from "lodash";
2
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
3
2
  import Trigger from "./interface";
4
3
  import { TriggerType } from "@avaprotocol/types";
@@ -21,6 +20,27 @@ import { TriggerType } from "@avaprotocol/types";
21
20
  // ]
22
21
  // ```
23
22
  // Required props for constructor: id, name, type and data: { expression, matcherList }
23
+ // EventTrigger now uses queries-based filtering instead of expression/matcher
24
+ // Each query represents an independent filter that creates its own subscription
25
+ // For FROM-OR-TO scenarios, provide two queries: one for FROM, one for TO.
26
+ //
27
+ // Example queries structure:
28
+ // ```
29
+ // [
30
+ // {
31
+ // addressesList: ["0xA0b86a33E6441e6067ec0da4Cc2C8ae77d85e7b1"],
32
+ // topicsList: [
33
+ // {
34
+ // valuesList: [
35
+ // "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
36
+ // null,
37
+ // "0x000000000000000000000000c60e71bd0f2e6d8832fea1a2d56091c48493c788"
38
+ // ]
39
+ // }
40
+ // ]
41
+ // }
42
+ // ]
43
+ // ```
24
44
  class EventTrigger extends Trigger {
25
45
  constructor(props) {
26
46
  super({ ...props, type: TriggerType.Event, data: props.data });
@@ -34,23 +54,36 @@ class EventTrigger extends Trigger {
34
54
  throw new Error(`Trigger data is missing for ${this.type}`);
35
55
  }
36
56
  const trigger = new avs_pb.EventTrigger();
37
- const dataConfig = this.data;
38
57
  const config = new avs_pb.EventTrigger.Config();
39
- const expression = dataConfig.expression;
40
- const matcherList = dataConfig.matcherList;
41
- if (_.isUndefined(expression) || _.isNull(expression)) {
42
- throw new Error(`Expression is undefined for ${this.type}`);
43
- }
44
- config.setExpression(expression);
45
- if (matcherList && matcherList.length > 0) {
46
- const matchers = matcherList.map((element) => {
47
- const m = new avs_pb.EventTrigger.Matcher();
48
- m.setType(element.type);
49
- m.setValueList(element.valueList || []);
50
- return m;
51
- });
52
- config.setMatcherList(matchers);
58
+ const dataConfig = this.data;
59
+ const queries = dataConfig.queriesList;
60
+ if (!queries || queries.length === 0) {
61
+ throw new Error(`Queries array is required for ${this.type}`);
53
62
  }
63
+ const queryMessages = queries.map((queryData) => {
64
+ const query = new avs_pb.EventTrigger.Query();
65
+ // Set addresses if provided
66
+ if (queryData.addressesList && queryData.addressesList.length > 0) {
67
+ query.setAddressesList(queryData.addressesList);
68
+ }
69
+ // Set topics if provided
70
+ if (queryData.topicsList && queryData.topicsList.length > 0) {
71
+ const topicsMessages = queryData.topicsList.map((topicData) => {
72
+ const topics = new avs_pb.EventTrigger.Topics();
73
+ if (topicData.valuesList) {
74
+ topics.setValuesList(topicData.valuesList);
75
+ }
76
+ return topics;
77
+ });
78
+ query.setTopicsList(topicsMessages);
79
+ }
80
+ // Set maxEventsPerBlock if provided
81
+ if (queryData.maxEventsPerBlock !== undefined) {
82
+ query.setMaxEventsPerBlock(queryData.maxEventsPerBlock);
83
+ }
84
+ return query;
85
+ });
86
+ config.setQueriesList(queryMessages);
54
87
  trigger.setConfig(config);
55
88
  request.setEvent(trigger);
56
89
  return request;
@@ -58,22 +91,36 @@ class EventTrigger extends Trigger {
58
91
  static fromResponse(raw) {
59
92
  // Convert the raw object to TriggerProps, which should keep name and id
60
93
  const obj = raw.toObject();
61
- let data = { expression: "", matcherList: [] };
94
+ let data = { queriesList: [] };
62
95
  if (raw.getEvent() && raw.getEvent().hasConfig()) {
63
96
  const config = raw.getEvent().getConfig();
64
97
  if (config) {
65
- data = {
66
- expression: config.getExpression(),
67
- matcherList: []
68
- };
69
- if (config.getMatcherList && config.getMatcherList().length > 0) {
70
- data.matcherList = config.getMatcherList().map((item) => {
71
- return {
72
- type: item.getType(),
73
- valueList: item.getValueList() || [],
98
+ const queries = [];
99
+ if (config.getQueriesList && config.getQueriesList().length > 0) {
100
+ config.getQueriesList().forEach((query) => {
101
+ const queryData = {
102
+ addressesList: [],
103
+ topicsList: [],
74
104
  };
105
+ // Extract addresses
106
+ if (query.getAddressesList && query.getAddressesList().length > 0) {
107
+ queryData.addressesList = query.getAddressesList();
108
+ }
109
+ // Extract topics
110
+ if (query.getTopicsList && query.getTopicsList().length > 0) {
111
+ queryData.topicsList = query.getTopicsList().map((topics) => ({
112
+ valuesList: topics.getValuesList() || []
113
+ }));
114
+ }
115
+ // Extract maxEventsPerBlock
116
+ const maxEvents = query.getMaxEventsPerBlock();
117
+ if (maxEvents && maxEvents > 0) {
118
+ queryData.maxEventsPerBlock = maxEvents;
119
+ }
120
+ queries.push(queryData);
75
121
  });
76
122
  }
123
+ data = { queriesList: queries };
77
124
  }
78
125
  }
79
126
  return new EventTrigger({
@@ -15,6 +15,7 @@ declare class Trigger implements TriggerProps {
15
15
  constructor(props: TriggerProps);
16
16
  toRequest(): avs_pb.TaskTrigger;
17
17
  getOutput(): TriggerOutput | undefined;
18
+ toJson(): TriggerProps;
18
19
  }
19
20
  export default Trigger;
20
21
  //# sourceMappingURL=interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,MAAM,WAAW,GACnB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,GAChC,MAAM,CAAC,WAAW,CAAC,QAAQ,GAC3B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,IAAI,CAAC;AAET,MAAM,MAAM,aAAa,GACrB,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,GACvC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,GAClC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,GACpC,IAAI,CAAC;AAIT,cAAM,OAAQ,YAAW,YAAY;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB;;;OAGG;gBACS,KAAK,EAAE,YAAY;IAQ/B,SAAS,IAAI,MAAM,CAAC,WAAW;IAI/B,SAAS,IAAI,aAAa,GAAG,SAAS;CAGvC;AAED,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,MAAM,WAAW,GACnB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,GAChC,MAAM,CAAC,WAAW,CAAC,QAAQ,GAC3B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,YAAY,CAAC,QAAQ,GAC5B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,IAAI,CAAC;AAET,MAAM,MAAM,aAAa,GACrB,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,GACvC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,GAClC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,GACpC,IAAI,CAAC;AAIT,cAAM,OAAQ,YAAW,YAAY;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB;;;OAGG;gBACS,KAAK,EAAE,YAAY;IAQ/B,SAAS,IAAI,MAAM,CAAC,WAAW;IAI/B,SAAS,IAAI,aAAa,GAAG,SAAS;IAItC,MAAM,IAAI,YAAY;CASvB;AAED,eAAe,OAAO,CAAC"}
@@ -16,5 +16,14 @@ class Trigger {
16
16
  getOutput() {
17
17
  return this.output;
18
18
  }
19
+ toJson() {
20
+ return {
21
+ id: this.id,
22
+ name: this.name,
23
+ type: this.type,
24
+ data: this.data,
25
+ output: this.output,
26
+ };
27
+ }
19
28
  }
20
29
  export default Trigger;
@@ -37,6 +37,11 @@ declare class Workflow implements WorkflowProps {
37
37
  */
38
38
  static fromListResponse(obj: avs_pb.Task): Workflow;
39
39
  toRequest(): avs_pb.CreateTaskReq;
40
+ /**
41
+ * Convert Workflow instance to plain object (WorkflowProps)
42
+ * This is useful for serialization, especially with Next.js Server Components
43
+ */
44
+ toJson(): WorkflowProps;
40
45
  }
41
46
  export default Workflow;
42
47
  //# 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;AAEhD,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;AAID,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;IAExB;;;OAGG;gBACS,KAAK,EAAE,aAAa;IAuBhC;;;;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;CAsBlC;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/models/workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,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;AAID,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;IAExB;;;OAGG;gBACS,KAAK,EAAE,aAAa;IAuBhC;;;;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;IAuBjC;;;OAGG;IACH,MAAM,IAAI,aAAa;CAkBxB;AAED,eAAe,QAAQ,CAAC"}
@@ -113,5 +113,27 @@ class Workflow {
113
113
  }
114
114
  return request;
115
115
  }
116
+ /**
117
+ * Convert Workflow instance to plain object (WorkflowProps)
118
+ * This is useful for serialization, especially with Next.js Server Components
119
+ */
120
+ toJson() {
121
+ return {
122
+ id: this.id,
123
+ owner: this.owner,
124
+ smartWalletAddress: this.smartWalletAddress,
125
+ trigger: this.trigger.toJson(),
126
+ nodes: this.nodes,
127
+ edges: this.edges,
128
+ startAt: this.startAt,
129
+ expiredAt: this.expiredAt,
130
+ maxExecution: this.maxExecution,
131
+ executionCount: this.executionCount,
132
+ name: this.name,
133
+ status: this.status,
134
+ completedAt: this.completedAt,
135
+ lastRanAt: this.lastRanAt,
136
+ };
137
+ }
116
138
  }
117
139
  export default Workflow;
@@ -0,0 +1,60 @@
1
+ import { Value as ProtobufValue } from "google-protobuf/google/protobuf/struct_pb";
2
+ /**
3
+ * Convert a protobuf Value to a JavaScript value
4
+ *
5
+ * **🏆 RECOMMENDED for modern protobuf usage**
6
+ *
7
+ * This is the primary implementation using proper TypeScript types and getKindCase()
8
+ * for the latest protobuf libraries. Use this for all new code.
9
+ *
10
+ * @param value - The protobuf Value to convert
11
+ * @returns The converted JavaScript value
12
+ */
13
+ export declare function convertProtobufValueToJs(value?: ProtobufValue): any;
14
+ /**
15
+ * Convert a protobuf Value to a JavaScript value
16
+ *
17
+ * **⚠️ DEPRECATED - Use convertProtobufValueToJs() for new code**
18
+ *
19
+ * This is a legacy compatibility version for existing code that may use
20
+ * dynamically typed protobuf objects. It uses older has*() methods and
21
+ * fallback logic. Only use this if you need backward compatibility.
22
+ *
23
+ * @deprecated Use convertProtobufValueToJs() instead for better type safety
24
+ * @param value - The protobuf Value object (may be dynamically typed)
25
+ * @returns The converted JavaScript value
26
+ */
27
+ export declare function convertProtobufValueToJS(value: any): any;
28
+ /**
29
+ * Convert a JavaScript value to a protobuf Value
30
+ *
31
+ * Uses proper TypeScript types for modern protobuf usage.
32
+ *
33
+ * @param value - The JavaScript value to convert
34
+ * @returns The protobuf Value object
35
+ */
36
+ export declare function convertJSValueToProtobuf(value: any): ProtobufValue;
37
+ /**
38
+ * Convert protobuf trigger type string to SDK trigger type string
39
+ *
40
+ * @param protobufType - The protobuf trigger type string (e.g., "TRIGGER_TYPE_MANUAL")
41
+ * @returns The SDK trigger type string (e.g., "manualTrigger")
42
+ */
43
+ export declare function convertProtobufTriggerTypeToSdk(protobufType: string): string;
44
+ /**
45
+ * Convert protobuf node type string to SDK node type string
46
+ *
47
+ * @param protobufType - The protobuf node type string (e.g., "NODE_TYPE_CUSTOM_CODE")
48
+ * @returns The SDK node type string (e.g., "customCode")
49
+ */
50
+ export declare function convertProtobufNodeTypeToSdk(protobufType: string): string;
51
+ /**
52
+ * Convert protobuf step type string to SDK step type string
53
+ *
54
+ * Automatically detects whether the type is a trigger or node type and converts accordingly.
55
+ *
56
+ * @param protobufType - The protobuf type string (e.g., "TRIGGER_TYPE_MANUAL" or "NODE_TYPE_CUSTOM_CODE")
57
+ * @returns The SDK type string (e.g., "manualTrigger" or "customCode")
58
+ */
59
+ export declare function convertProtobufStepTypeToSdk(protobufType: string): string;
60
+ //# sourceMappingURL=utils.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "A JavaScript/TypeScript SDK designed to simplify integration with Ava Protocol's AVS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",