@avaprotocol/sdk-js 2.6.3 → 2.6.4-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
2
+ import Trigger from "./interface";
3
+ import { BlockTriggerProps, BlockTriggerOutput } from "@avaprotocol/types";
4
+ declare class BlockTrigger extends Trigger {
5
+ constructor(props: BlockTriggerProps);
6
+ toRequest(): avs_pb.TaskTrigger;
7
+ static fromResponse(raw: avs_pb.TaskTrigger): BlockTrigger;
8
+ /**
9
+ * Convert the output to the expected format
10
+ * @returns {BlockTriggerOutput | undefined} - The converted data
11
+ */
12
+ getOutput(): BlockTriggerOutput | undefined;
13
+ /**
14
+ * Extract output data from RunTriggerResp for block triggers
15
+ * @param outputData - The RunTriggerResp containing block trigger output
16
+ * @returns Plain JavaScript object with block trigger data
17
+ */
18
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): any;
19
+ }
20
+ export default BlockTrigger;
21
+ //# sourceMappingURL=block.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAC5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAqC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAuB1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAY9D;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAEL,iBAAiB,EAEjB,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAC5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAOpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAoB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IAoB1D;;;OAGG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAY9D;AAED,eAAe,YAAY,CAAC"}
@@ -1,59 +1,44 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
2
  import Trigger from "./interface";
3
- import { TriggerType, } from "@avaprotocol/types";
3
+ import { TriggerType } from "@avaprotocol/types";
4
4
  class BlockTrigger extends Trigger {
5
5
  constructor(props) {
6
- super({ ...props, type: TriggerType.Block, data: props.data });
6
+ super({
7
+ ...props,
8
+ type: TriggerType.Block,
9
+ });
7
10
  }
8
11
  toRequest() {
9
- const request = new avs_pb.TaskTrigger();
10
- request.setName(this.name);
11
- request.setId(this.id);
12
- request.setType(avs_pb.TriggerType.TRIGGER_TYPE_BLOCK);
13
- if (!this.data) {
14
- throw new Error(`Trigger data is missing for block`);
15
- }
16
- const blockData = this.data;
17
- // Validate interval exists
18
- if (blockData.interval === null || blockData.interval === undefined) {
19
- throw new Error("Interval is required for block trigger");
20
- }
21
- // Validate that interval is an integer
22
- if (!Number.isInteger(blockData.interval)) {
23
- throw new Error(`BlockTrigger interval must be an integer, got: ${blockData.interval}`);
24
- }
25
- // Validate interval is positive
26
- if (blockData.interval <= 0) {
27
- throw new Error(`Interval must be greater than 0`);
28
- }
29
- const trigger = new avs_pb.BlockTrigger();
12
+ const trigger = new avs_pb.TaskTrigger();
13
+ trigger.setId(this.id);
14
+ trigger.setName(this.name);
15
+ trigger.setType(avs_pb.TriggerType.TRIGGER_TYPE_BLOCK);
16
+ const blockTrigger = new avs_pb.BlockTrigger();
30
17
  const config = new avs_pb.BlockTrigger.Config();
31
- config.setInterval(blockData.interval);
32
- trigger.setConfig(config);
33
- request.setBlock(trigger);
34
- return request;
18
+ const blockData = this.data;
19
+ config.setInterval(blockData.interval || 0);
20
+ blockTrigger.setConfig(config);
21
+ trigger.setBlock(blockTrigger);
22
+ return trigger;
35
23
  }
36
24
  static fromResponse(raw) {
37
- // Convert the raw object to TriggerProps, which should keep name and id
38
25
  const obj = raw.toObject();
39
26
  let data = { interval: 0 };
40
27
  if (raw.getBlock() && raw.getBlock().hasConfig()) {
41
28
  const config = raw.getBlock().getConfig();
42
- if (config) {
43
- data = {
44
- interval: config.getInterval() || 0,
45
- };
46
- }
29
+ data = {
30
+ interval: config.getInterval(),
31
+ };
47
32
  }
48
33
  return new BlockTrigger({
49
- ...obj,
50
- type: TriggerType.Block,
34
+ id: obj.id,
35
+ name: obj.name,
36
+ type: obj.type,
51
37
  data: data,
52
38
  });
53
39
  }
54
40
  /**
55
- * Convert raw data from runNodeWithInputs response to BlockOutput format
56
- * @param rawData - The raw data from the gRPC response
41
+ * Convert the output to the expected format
57
42
  * @returns {BlockTriggerOutput | undefined} - The converted data
58
43
  */
59
44
  getOutput() {
@@ -0,0 +1,23 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
2
+ import Trigger from "./interface";
3
+ import { CronTriggerProps, CronTriggerOutput } from "@avaprotocol/types";
4
+ declare class CronTrigger extends Trigger {
5
+ constructor(props: CronTriggerProps);
6
+ toRequest(): avs_pb.TaskTrigger;
7
+ static fromResponse(raw: avs_pb.TaskTrigger): CronTrigger;
8
+ /**
9
+ * Convert raw data from runNodeWithInputs response to CronOutput format
10
+ * @param rawData - The raw data from the gRPC response
11
+ * @returns {CronTriggerOutput | undefined} - The converted data
12
+ */
13
+ getOutput(): CronTriggerOutput | undefined;
14
+ /**
15
+ * Extract output data from RunTriggerResp for cron triggers
16
+ * Updated to handle timestamp and timestamp_iso instead of epoch
17
+ * @param outputData - The RunTriggerResp containing cron trigger output
18
+ * @returns Plain JavaScript object with cron trigger data
19
+ */
20
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): any;
21
+ }
22
+ export default CronTrigger;
23
+ //# sourceMappingURL=cron.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/cron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAE5B,cAAM,WAAY,SAAQ,OAAO;gBACnB,KAAK,EAAE,gBAAgB;IAInC,SAAS,IAAI,MAAM,CAAC,WAAW;IAgC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,WAAW;IAuBzD;;;;OAIG;IACH,SAAS,IAAI,iBAAiB,GAAG,SAAS;IAI1C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAY9D;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/cron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAEL,gBAAgB,EAEhB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAE5B,cAAM,WAAY,SAAQ,OAAO;gBACnB,KAAK,EAAE,gBAAgB;IAOnC,SAAS,IAAI,MAAM,CAAC,WAAW;IAiC/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,WAAW;IAmBzD;;;;OAIG;IACH,SAAS,IAAI,iBAAiB,GAAG,SAAS;IAI1C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAY9D;AAED,eAAe,WAAW,CAAC"}
@@ -1,45 +1,45 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
2
  import Trigger from "./interface";
3
- import { TriggerType, } from "@avaprotocol/types";
3
+ import { TriggerType } from "@avaprotocol/types";
4
4
  class CronTrigger extends Trigger {
5
5
  constructor(props) {
6
- super({ ...props, type: TriggerType.Cron, data: props.data });
6
+ super({
7
+ ...props,
8
+ type: TriggerType.Cron,
9
+ });
7
10
  }
8
11
  toRequest() {
9
12
  const request = new avs_pb.TaskTrigger();
10
- request.setName(this.name);
11
13
  request.setId(this.id);
14
+ request.setName(this.name);
12
15
  request.setType(avs_pb.TriggerType.TRIGGER_TYPE_CRON);
13
16
  if (!this.data) {
14
17
  throw new Error(`Trigger data is missing for ${this.type}`);
15
18
  }
16
19
  const cronData = this.data;
17
20
  // Validate schedules is present and not null/undefined
18
- if (cronData.schedules === null || cronData.schedules === undefined) {
19
- throw new Error("Schedules are required for cron trigger");
21
+ if (!cronData.schedules || !Array.isArray(cronData.schedules)) {
22
+ throw new Error("Schedules array is required for cron trigger");
20
23
  }
21
- // Validate schedules is not empty
22
- if (!Array.isArray(cronData.schedules) || cronData.schedules.length === 0) {
23
- throw new Error("Schedules are required for cron trigger");
24
+ // Validate schedules array is not empty
25
+ if (cronData.schedules.length === 0) {
26
+ throw new Error("At least one schedule is required for cron trigger");
24
27
  }
25
- const trigger = new avs_pb.CronTrigger();
26
28
  const config = new avs_pb.CronTrigger.Config();
27
29
  config.setSchedulesList(cronData.schedules);
28
- trigger.setConfig(config);
29
- request.setCron(trigger);
30
+ const cronTrigger = new avs_pb.CronTrigger();
31
+ cronTrigger.setConfig(config);
32
+ request.setCron(cronTrigger);
30
33
  return request;
31
34
  }
32
35
  static fromResponse(raw) {
33
- // Convert the raw object to TriggerProps, which should keep name and id
34
36
  const obj = raw.toObject();
35
37
  let data = { schedules: [] };
36
38
  if (raw.getCron() && raw.getCron().hasConfig()) {
37
39
  const config = raw.getCron().getConfig();
38
- if (config) {
39
- data = {
40
- schedules: config.getSchedulesList() || [],
41
- };
42
- }
40
+ data = {
41
+ schedules: config.getSchedulesList(),
42
+ };
43
43
  }
44
44
  return new CronTrigger({
45
45
  ...obj,
@@ -48,7 +48,7 @@ class CronTrigger extends Trigger {
48
48
  });
49
49
  }
50
50
  /**
51
- * Convert raw data from runTrigger response to CronOutput format
51
+ * Convert raw data from runNodeWithInputs response to CronOutput format
52
52
  * @param rawData - The raw data from the gRPC response
53
53
  * @returns {CronTriggerOutput | undefined} - The converted data
54
54
  */
@@ -0,0 +1,22 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
2
+ import Trigger from "./interface";
3
+ import { EventTriggerOutput, EventTriggerProps } from "@avaprotocol/types";
4
+ declare class EventTrigger extends Trigger {
5
+ constructor(props: EventTriggerProps);
6
+ toRequest(): avs_pb.TaskTrigger;
7
+ static fromResponse(raw: avs_pb.TaskTrigger): EventTrigger;
8
+ /**
9
+ * Convert raw data from runTrigger response to EventOutput format
10
+ * @param rawData - The raw data from the gRPC response
11
+ * @returns {EventTriggerOutput | undefined} - The converted data
12
+ */
13
+ getOutput(): EventTriggerOutput | undefined;
14
+ /**
15
+ * Extract output data from RunTriggerResp for event triggers
16
+ * @param outputData - The RunTriggerResp containing event trigger output
17
+ * @returns Plain JavaScript object with event trigger data
18
+ */
19
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): any;
20
+ }
21
+ export default EventTrigger;
22
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1,27 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
2
+ import BlockTrigger from "./block";
3
+ import CronTrigger from "./cron";
4
+ import EventTrigger from "./event";
5
+ import FixedTimeTrigger from "./fixedTime";
6
+ import ManualTrigger from "./manual";
7
+ import Trigger from "./interface";
8
+ import { TriggerProps, BlockTriggerProps, CronTriggerProps, EventTriggerProps, FixedTimeTriggerProps, ManualTriggerProps } from "@avaprotocol/types";
9
+ declare class TriggerFactory {
10
+ /**
11
+ * Static factory method to create Trigger instances
12
+ * @param props
13
+ * @returns
14
+ */
15
+ static create(props: TriggerProps): Trigger;
16
+ /**
17
+ * Create an instance of Trigger from AVS getWorkflow or getWorkflows response
18
+ * @param trigger
19
+ * @returns
20
+ */
21
+ static fromResponse(raw: avs_pb.TaskTrigger): Trigger;
22
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): any;
23
+ }
24
+ export default TriggerFactory;
25
+ export { Trigger, BlockTrigger, CronTrigger, EventTrigger, FixedTimeTrigger, ManualTrigger, };
26
+ export type { TriggerProps, BlockTriggerProps, CronTriggerProps, EventTriggerProps, FixedTimeTriggerProps, ManualTriggerProps, };
27
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1,23 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
2
+ import Trigger from "./interface";
3
+ import { FixedTimeTriggerProps, FixedTimeTriggerOutput } from "@avaprotocol/types";
4
+ declare class FixedTimeTrigger extends Trigger {
5
+ constructor(props: FixedTimeTriggerProps);
6
+ toRequest(): avs_pb.TaskTrigger;
7
+ static fromResponse(raw: avs_pb.TaskTrigger): FixedTimeTrigger;
8
+ /**
9
+ * Convert raw data from runNodeWithInputs response to FixedTimeOutput format
10
+ * @param rawData - The raw data from the gRPC response
11
+ * @returns {FixedTimeTriggerOutput | undefined} - The converted data
12
+ */
13
+ getOutput(): FixedTimeTriggerOutput | undefined;
14
+ /**
15
+ * Extract output data from RunTriggerResp for fixed time triggers
16
+ * Updated to handle timestamp and timestamp_iso instead of epoch
17
+ * @param outputData - The RunTriggerResp containing fixed time trigger output
18
+ * @returns Plain JavaScript object with fixed time trigger data
19
+ */
20
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): any;
21
+ }
22
+ export default FixedTimeTrigger;
23
+ //# sourceMappingURL=fixedTime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fixedTime.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/fixedTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,sBAAsB,EACtB,qBAAqB,EAGtB,MAAM,oBAAoB,CAAC;AAK5B,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAIxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAsB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,gBAAgB;IAuB9D;;;;OAIG;IACH,SAAS,IAAI,sBAAsB,GAAG,SAAS;IAI/C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAY9D;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"fixedTime.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/fixedTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAEL,qBAAqB,EAErB,sBAAsB,EAEvB,MAAM,oBAAoB,CAAC;AAI5B,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAOxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAsB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,gBAAgB;IAmB9D;;;;OAIG;IACH,SAAS,IAAI,sBAAsB,GAAG,SAAS;IAI/C;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CAY9D;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,15 +1,18 @@
1
1
  import * as avs_pb from "@/grpc_codegen/avs_pb";
2
2
  import Trigger from "./interface";
3
- import { TriggerType, } from "@avaprotocol/types";
3
+ import { TriggerType } from "@avaprotocol/types";
4
4
  // Required props for constructor: id, name, type and data: { epochsList }
5
5
  class FixedTimeTrigger extends Trigger {
6
6
  constructor(props) {
7
- super({ ...props, type: TriggerType.FixedTime, data: props.data });
7
+ super({
8
+ ...props,
9
+ type: TriggerType.FixedTime,
10
+ });
8
11
  }
9
12
  toRequest() {
10
13
  const request = new avs_pb.TaskTrigger();
11
- request.setName(this.name);
12
14
  request.setId(this.id);
15
+ request.setName(this.name);
13
16
  request.setType(avs_pb.TriggerType.TRIGGER_TYPE_FIXED_TIME);
14
17
  if (!this.data) {
15
18
  throw new Error(`Trigger data is missing for ${this.type}`);
@@ -22,16 +25,13 @@ class FixedTimeTrigger extends Trigger {
22
25
  return request;
23
26
  }
24
27
  static fromResponse(raw) {
25
- // Convert the raw object to TriggerProps, which should keep name and id
26
28
  const obj = raw.toObject();
27
29
  let data = { epochsList: [] };
28
30
  if (raw.getFixedTime() && raw.getFixedTime().hasConfig()) {
29
31
  const config = raw.getFixedTime().getConfig();
30
- if (config) {
31
- data = {
32
- epochsList: config.getEpochsList() || [],
33
- };
34
- }
32
+ data = {
33
+ epochsList: config.getEpochsList(),
34
+ };
35
35
  }
36
36
  return new FixedTimeTrigger({
37
37
  ...obj,
@@ -40,7 +40,7 @@ class FixedTimeTrigger extends Trigger {
40
40
  });
41
41
  }
42
42
  /**
43
- * Convert raw data from runTrigger response to FixedTimeOutput format
43
+ * Convert raw data from runNodeWithInputs response to FixedTimeOutput format
44
44
  * @param rawData - The raw data from the gRPC response
45
45
  * @returns {FixedTimeTriggerOutput | undefined} - The converted data
46
46
  */
@@ -0,0 +1,19 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
2
+ import { TriggerType, TriggerProps, TriggerData, TriggerOutput } from "@avaprotocol/types";
3
+ export default abstract class Trigger implements TriggerProps {
4
+ id: string;
5
+ name: string;
6
+ type: TriggerType;
7
+ data: TriggerData;
8
+ output?: TriggerOutput;
9
+ /**
10
+ * Create an instance of Trigger from user inputs
11
+ * @param props
12
+ */
13
+ constructor(props: TriggerProps);
14
+ toRequest(): avs_pb.TaskTrigger;
15
+ static fromResponse(raw: avs_pb.TaskTrigger): Trigger;
16
+ getOutput(): TriggerOutput | undefined;
17
+ toJson(): TriggerProps;
18
+ }
19
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1,16 @@
1
+ import * as avs_pb from "@/grpc_codegen/avs_pb";
2
+ import Trigger from "./interface";
3
+ import { ManualTriggerProps } from "@avaprotocol/types";
4
+ declare class ManualTrigger extends Trigger {
5
+ constructor(props: ManualTriggerProps);
6
+ toRequest(): avs_pb.TaskTrigger;
7
+ static fromResponse(raw: avs_pb.TaskTrigger): ManualTrigger;
8
+ /**
9
+ * Extract output data from RunTriggerResp for manual triggers
10
+ * @param outputData - The RunTriggerResp containing manual trigger output
11
+ * @returns The parsed JSON data directly (similar to CustomCode output)
12
+ */
13
+ static fromOutputData(outputData: avs_pb.RunTriggerResp): unknown;
14
+ }
15
+ export default ManualTrigger;
16
+ //# sourceMappingURL=manual.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "2.6.3",
3
+ "version": "2.6.4-dev.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",