@avaprotocol/sdk-js 2.6.3 → 2.6.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.
- package/CHANGELOG.md +8 -0
- package/dist/index.d.ts +350 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -55
- package/dist/index.mjs +81 -56
- package/dist/models/trigger/block.d.ts +21 -0
- package/dist/models/trigger/block.d.ts.map +1 -1
- package/dist/models/trigger/block.js +31 -30
- package/dist/models/trigger/cron.d.ts +23 -0
- package/dist/models/trigger/cron.d.ts.map +1 -1
- package/dist/models/trigger/cron.js +16 -16
- package/dist/models/trigger/event.d.ts +22 -0
- package/dist/models/trigger/factory.d.ts +27 -0
- package/dist/models/trigger/fixedTime.d.ts +23 -0
- package/dist/models/trigger/fixedTime.d.ts.map +1 -1
- package/dist/models/trigger/fixedTime.js +10 -10
- package/dist/models/trigger/interface.d.ts +19 -0
- package/dist/models/trigger/manual.d.ts +16 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -15363,53 +15363,54 @@ import {
|
|
|
15363
15363
|
} from "@avaprotocol/types";
|
|
15364
15364
|
var BlockTrigger2 = class _BlockTrigger extends Trigger {
|
|
15365
15365
|
constructor(props) {
|
|
15366
|
-
super({
|
|
15366
|
+
super({
|
|
15367
|
+
...props,
|
|
15368
|
+
type: TriggerType2.Block
|
|
15369
|
+
});
|
|
15367
15370
|
}
|
|
15368
15371
|
toRequest() {
|
|
15369
|
-
const
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
}
|
|
15372
|
+
const trigger = new avs_pb2.TaskTrigger();
|
|
15373
|
+
trigger.setId(this.id);
|
|
15374
|
+
trigger.setName(this.name);
|
|
15375
|
+
trigger.setType(avs_pb2.TriggerType.TRIGGER_TYPE_BLOCK);
|
|
15376
|
+
const blockTrigger = new avs_pb2.BlockTrigger();
|
|
15377
|
+
const config = new avs_pb2.BlockTrigger.Config();
|
|
15376
15378
|
const blockData = this.data;
|
|
15379
|
+
if (!blockData) {
|
|
15380
|
+
throw new Error("Trigger data is missing for block");
|
|
15381
|
+
}
|
|
15377
15382
|
if (blockData.interval === null || blockData.interval === void 0) {
|
|
15378
15383
|
throw new Error("Interval is required for block trigger");
|
|
15379
15384
|
}
|
|
15385
|
+
if (blockData.interval <= 0) {
|
|
15386
|
+
throw new Error("Interval must be greater than 0");
|
|
15387
|
+
}
|
|
15380
15388
|
if (!Number.isInteger(blockData.interval)) {
|
|
15381
15389
|
throw new Error(`BlockTrigger interval must be an integer, got: ${blockData.interval}`);
|
|
15382
15390
|
}
|
|
15383
|
-
if (blockData.interval <= 0) {
|
|
15384
|
-
throw new Error(`Interval must be greater than 0`);
|
|
15385
|
-
}
|
|
15386
|
-
const trigger = new avs_pb2.BlockTrigger();
|
|
15387
|
-
const config = new avs_pb2.BlockTrigger.Config();
|
|
15388
15391
|
config.setInterval(blockData.interval);
|
|
15389
|
-
|
|
15390
|
-
|
|
15391
|
-
return
|
|
15392
|
+
blockTrigger.setConfig(config);
|
|
15393
|
+
trigger.setBlock(blockTrigger);
|
|
15394
|
+
return trigger;
|
|
15392
15395
|
}
|
|
15393
15396
|
static fromResponse(raw) {
|
|
15394
15397
|
const obj = raw.toObject();
|
|
15395
15398
|
let data = { interval: 0 };
|
|
15396
15399
|
if (raw.getBlock() && raw.getBlock().hasConfig()) {
|
|
15397
15400
|
const config = raw.getBlock().getConfig();
|
|
15398
|
-
|
|
15399
|
-
|
|
15400
|
-
|
|
15401
|
-
};
|
|
15402
|
-
}
|
|
15401
|
+
data = {
|
|
15402
|
+
interval: config.getInterval()
|
|
15403
|
+
};
|
|
15403
15404
|
}
|
|
15404
15405
|
return new _BlockTrigger({
|
|
15405
|
-
|
|
15406
|
-
|
|
15406
|
+
id: obj.id,
|
|
15407
|
+
name: obj.name,
|
|
15408
|
+
type: obj.type,
|
|
15407
15409
|
data
|
|
15408
15410
|
});
|
|
15409
15411
|
}
|
|
15410
15412
|
/**
|
|
15411
|
-
* Convert
|
|
15412
|
-
* @param rawData - The raw data from the gRPC response
|
|
15413
|
+
* Convert the output to the expected format
|
|
15413
15414
|
* @returns {BlockTriggerOutput | undefined} - The converted data
|
|
15414
15415
|
*/
|
|
15415
15416
|
getOutput() {
|
|
@@ -15438,28 +15439,31 @@ import {
|
|
|
15438
15439
|
} from "@avaprotocol/types";
|
|
15439
15440
|
var CronTrigger2 = class _CronTrigger extends Trigger {
|
|
15440
15441
|
constructor(props) {
|
|
15441
|
-
super({
|
|
15442
|
+
super({
|
|
15443
|
+
...props,
|
|
15444
|
+
type: TriggerType4.Cron
|
|
15445
|
+
});
|
|
15442
15446
|
}
|
|
15443
15447
|
toRequest() {
|
|
15444
15448
|
const request = new avs_pb3.TaskTrigger();
|
|
15445
|
-
request.setName(this.name);
|
|
15446
15449
|
request.setId(this.id);
|
|
15450
|
+
request.setName(this.name);
|
|
15447
15451
|
request.setType(avs_pb3.TriggerType.TRIGGER_TYPE_CRON);
|
|
15448
15452
|
if (!this.data) {
|
|
15449
15453
|
throw new Error(`Trigger data is missing for ${this.type}`);
|
|
15450
15454
|
}
|
|
15451
15455
|
const cronData = this.data;
|
|
15452
|
-
if (cronData.schedules
|
|
15456
|
+
if (!cronData.schedules || !Array.isArray(cronData.schedules)) {
|
|
15453
15457
|
throw new Error("Schedules are required for cron trigger");
|
|
15454
15458
|
}
|
|
15455
|
-
if (
|
|
15459
|
+
if (cronData.schedules.length === 0) {
|
|
15456
15460
|
throw new Error("Schedules are required for cron trigger");
|
|
15457
15461
|
}
|
|
15458
|
-
const trigger = new avs_pb3.CronTrigger();
|
|
15459
15462
|
const config = new avs_pb3.CronTrigger.Config();
|
|
15460
15463
|
config.setSchedulesList(cronData.schedules);
|
|
15461
|
-
|
|
15462
|
-
|
|
15464
|
+
const cronTrigger = new avs_pb3.CronTrigger();
|
|
15465
|
+
cronTrigger.setConfig(config);
|
|
15466
|
+
request.setCron(cronTrigger);
|
|
15463
15467
|
return request;
|
|
15464
15468
|
}
|
|
15465
15469
|
static fromResponse(raw) {
|
|
@@ -15467,11 +15471,9 @@ var CronTrigger2 = class _CronTrigger extends Trigger {
|
|
|
15467
15471
|
let data = { schedules: [] };
|
|
15468
15472
|
if (raw.getCron() && raw.getCron().hasConfig()) {
|
|
15469
15473
|
const config = raw.getCron().getConfig();
|
|
15470
|
-
|
|
15471
|
-
|
|
15472
|
-
|
|
15473
|
-
};
|
|
15474
|
-
}
|
|
15474
|
+
data = {
|
|
15475
|
+
schedules: config.getSchedulesList()
|
|
15476
|
+
};
|
|
15475
15477
|
}
|
|
15476
15478
|
return new _CronTrigger({
|
|
15477
15479
|
...obj,
|
|
@@ -15480,7 +15482,7 @@ var CronTrigger2 = class _CronTrigger extends Trigger {
|
|
|
15480
15482
|
});
|
|
15481
15483
|
}
|
|
15482
15484
|
/**
|
|
15483
|
-
* Convert raw data from
|
|
15485
|
+
* Convert raw data from runNodeWithInputs response to CronOutput format
|
|
15484
15486
|
* @param rawData - The raw data from the gRPC response
|
|
15485
15487
|
* @returns {CronTriggerOutput | undefined} - The converted data
|
|
15486
15488
|
*/
|
|
@@ -15886,12 +15888,15 @@ import {
|
|
|
15886
15888
|
} from "@avaprotocol/types";
|
|
15887
15889
|
var FixedTimeTrigger2 = class _FixedTimeTrigger extends Trigger {
|
|
15888
15890
|
constructor(props) {
|
|
15889
|
-
super({
|
|
15891
|
+
super({
|
|
15892
|
+
...props,
|
|
15893
|
+
type: TriggerType9.FixedTime
|
|
15894
|
+
});
|
|
15890
15895
|
}
|
|
15891
15896
|
toRequest() {
|
|
15892
15897
|
const request = new avs_pb5.TaskTrigger();
|
|
15893
|
-
request.setName(this.name);
|
|
15894
15898
|
request.setId(this.id);
|
|
15899
|
+
request.setName(this.name);
|
|
15895
15900
|
request.setType(avs_pb5.TriggerType.TRIGGER_TYPE_FIXED_TIME);
|
|
15896
15901
|
if (!this.data) {
|
|
15897
15902
|
throw new Error(`Trigger data is missing for ${this.type}`);
|
|
@@ -15910,11 +15915,9 @@ var FixedTimeTrigger2 = class _FixedTimeTrigger extends Trigger {
|
|
|
15910
15915
|
let data = { epochsList: [] };
|
|
15911
15916
|
if (raw.getFixedTime() && raw.getFixedTime().hasConfig()) {
|
|
15912
15917
|
const config = raw.getFixedTime().getConfig();
|
|
15913
|
-
|
|
15914
|
-
|
|
15915
|
-
|
|
15916
|
-
};
|
|
15917
|
-
}
|
|
15918
|
+
data = {
|
|
15919
|
+
epochsList: config.getEpochsList()
|
|
15920
|
+
};
|
|
15918
15921
|
}
|
|
15919
15922
|
return new _FixedTimeTrigger({
|
|
15920
15923
|
...obj,
|
|
@@ -15923,7 +15926,7 @@ var FixedTimeTrigger2 = class _FixedTimeTrigger extends Trigger {
|
|
|
15923
15926
|
});
|
|
15924
15927
|
}
|
|
15925
15928
|
/**
|
|
15926
|
-
* Convert raw data from
|
|
15929
|
+
* Convert raw data from runNodeWithInputs response to FixedTimeOutput format
|
|
15927
15930
|
* @param rawData - The raw data from the gRPC response
|
|
15928
15931
|
* @returns {FixedTimeTriggerOutput | undefined} - The converted data
|
|
15929
15932
|
*/
|
|
@@ -17371,6 +17374,7 @@ var Secret = class {
|
|
|
17371
17374
|
var secret_default = Secret;
|
|
17372
17375
|
|
|
17373
17376
|
// src/index.ts
|
|
17377
|
+
var import_avs_pb = __toESM(require_avs_pb());
|
|
17374
17378
|
import {
|
|
17375
17379
|
TriggerType as TriggerType13,
|
|
17376
17380
|
NodeTypeGoConverter as NodeTypeGoConverter2,
|
|
@@ -17378,12 +17382,26 @@ import {
|
|
|
17378
17382
|
TriggerTypeConverter,
|
|
17379
17383
|
AUTH_KEY_HEADER,
|
|
17380
17384
|
DEFAULT_LIMIT,
|
|
17381
|
-
TimeoutPresets
|
|
17385
|
+
TimeoutPresets,
|
|
17386
|
+
ExecutionStatus
|
|
17382
17387
|
} from "@avaprotocol/types";
|
|
17383
17388
|
import * as google_protobuf_struct_pb4 from "google-protobuf/google/protobuf/struct_pb";
|
|
17384
17389
|
import {
|
|
17385
17390
|
TimeoutPresets as TimeoutPresets2
|
|
17386
17391
|
} from "@avaprotocol/types";
|
|
17392
|
+
function convertProtobufExecutionStatus(protobufStatus) {
|
|
17393
|
+
switch (protobufStatus) {
|
|
17394
|
+
case import_avs_pb.ExecutionStatus.EXECUTION_STATUS_PENDING:
|
|
17395
|
+
return ExecutionStatus.Pending;
|
|
17396
|
+
case import_avs_pb.ExecutionStatus.EXECUTION_STATUS_COMPLETED:
|
|
17397
|
+
return ExecutionStatus.Completed;
|
|
17398
|
+
case import_avs_pb.ExecutionStatus.EXECUTION_STATUS_FAILED:
|
|
17399
|
+
return ExecutionStatus.Failed;
|
|
17400
|
+
case import_avs_pb.ExecutionStatus.EXECUTION_STATUS_UNSPECIFIED:
|
|
17401
|
+
default:
|
|
17402
|
+
return ExecutionStatus.Unspecified;
|
|
17403
|
+
}
|
|
17404
|
+
}
|
|
17387
17405
|
var BaseClient = class {
|
|
17388
17406
|
constructor(opts) {
|
|
17389
17407
|
this.endpoint = opts.endpoint;
|
|
@@ -17874,7 +17892,7 @@ var Client = class extends BaseClient {
|
|
|
17874
17892
|
request.setTaskId(workflowId);
|
|
17875
17893
|
request.setExecutionId(executionId);
|
|
17876
17894
|
const result = await this.sendGrpcRequest("getExecutionStatus", request, options);
|
|
17877
|
-
return result.getStatus();
|
|
17895
|
+
return convertProtobufExecutionStatus(result.getStatus());
|
|
17878
17896
|
}
|
|
17879
17897
|
/**
|
|
17880
17898
|
* Get a workflow by id
|
|
@@ -17918,7 +17936,9 @@ var Client = class extends BaseClient {
|
|
|
17918
17936
|
timestampIso: triggerData.timestampIso
|
|
17919
17937
|
};
|
|
17920
17938
|
const dataValue = new google_protobuf_struct_pb4.Value();
|
|
17921
|
-
dataValue.setStructValue(
|
|
17939
|
+
dataValue.setStructValue(
|
|
17940
|
+
google_protobuf_struct_pb4.Struct.fromJavaScript(triggerOutputData)
|
|
17941
|
+
);
|
|
17922
17942
|
fixedTimeOutput.setData(dataValue);
|
|
17923
17943
|
request.setFixedTimeTrigger(fixedTimeOutput);
|
|
17924
17944
|
break;
|
|
@@ -17930,7 +17950,9 @@ var Client = class extends BaseClient {
|
|
|
17930
17950
|
timestampIso: triggerData.timestampIso
|
|
17931
17951
|
};
|
|
17932
17952
|
const dataValue = new google_protobuf_struct_pb4.Value();
|
|
17933
|
-
dataValue.setStructValue(
|
|
17953
|
+
dataValue.setStructValue(
|
|
17954
|
+
google_protobuf_struct_pb4.Struct.fromJavaScript(triggerOutputData)
|
|
17955
|
+
);
|
|
17934
17956
|
cronOutput.setData(dataValue);
|
|
17935
17957
|
request.setCronTrigger(cronOutput);
|
|
17936
17958
|
break;
|
|
@@ -17948,7 +17970,9 @@ var Client = class extends BaseClient {
|
|
|
17948
17970
|
gasUsed: blockData.gasUsed || 0
|
|
17949
17971
|
};
|
|
17950
17972
|
const dataValue = new google_protobuf_struct_pb4.Value();
|
|
17951
|
-
dataValue.setStructValue(
|
|
17973
|
+
dataValue.setStructValue(
|
|
17974
|
+
google_protobuf_struct_pb4.Struct.fromJavaScript(triggerOutputData)
|
|
17975
|
+
);
|
|
17952
17976
|
blockOutput.setData(dataValue);
|
|
17953
17977
|
request.setBlockTrigger(blockOutput);
|
|
17954
17978
|
break;
|
|
@@ -17981,7 +18005,11 @@ var Client = class extends BaseClient {
|
|
|
17981
18005
|
);
|
|
17982
18006
|
}
|
|
17983
18007
|
const result = await this.sendGrpcRequest("triggerTask", request, options);
|
|
17984
|
-
|
|
18008
|
+
const responseObject = result.toObject();
|
|
18009
|
+
return {
|
|
18010
|
+
...responseObject,
|
|
18011
|
+
status: convertProtobufExecutionStatus(result.getStatus())
|
|
18012
|
+
};
|
|
17985
18013
|
}
|
|
17986
18014
|
/**
|
|
17987
18015
|
* Cancel a workflow
|
|
@@ -18239,10 +18267,7 @@ var Client = class extends BaseClient {
|
|
|
18239
18267
|
try {
|
|
18240
18268
|
metadata = convertProtobufValueToJs(metadataValue);
|
|
18241
18269
|
} catch (error) {
|
|
18242
|
-
console.warn(
|
|
18243
|
-
"Failed to convert metadata from protobuf Value:",
|
|
18244
|
-
error
|
|
18245
|
-
);
|
|
18270
|
+
console.warn("Failed to convert metadata from protobuf Value:", error);
|
|
18246
18271
|
metadata = metadataValue;
|
|
18247
18272
|
}
|
|
18248
18273
|
}
|
|
@@ -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,
|
|
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;IAwC/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,60 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
2
|
import Trigger from "./interface";
|
|
3
|
-
import { TriggerType
|
|
3
|
+
import { TriggerType } from "@avaprotocol/types";
|
|
4
4
|
class BlockTrigger extends Trigger {
|
|
5
5
|
constructor(props) {
|
|
6
|
-
super({
|
|
6
|
+
super({
|
|
7
|
+
...props,
|
|
8
|
+
type: TriggerType.Block,
|
|
9
|
+
});
|
|
7
10
|
}
|
|
8
11
|
toRequest() {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
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();
|
|
17
|
+
const config = new avs_pb.BlockTrigger.Config();
|
|
16
18
|
const blockData = this.data;
|
|
17
|
-
// Validate
|
|
19
|
+
// Validate trigger data exists
|
|
20
|
+
if (!blockData) {
|
|
21
|
+
throw new Error("Trigger data is missing for block");
|
|
22
|
+
}
|
|
23
|
+
// Validate interval is present and not null/undefined
|
|
18
24
|
if (blockData.interval === null || blockData.interval === undefined) {
|
|
19
25
|
throw new Error("Interval is required for block trigger");
|
|
20
26
|
}
|
|
21
|
-
// Validate
|
|
27
|
+
// Validate interval is a positive integer
|
|
28
|
+
if (blockData.interval <= 0) {
|
|
29
|
+
throw new Error("Interval must be greater than 0");
|
|
30
|
+
}
|
|
31
|
+
// Validate interval is an integer (not decimal)
|
|
22
32
|
if (!Number.isInteger(blockData.interval)) {
|
|
23
33
|
throw new Error(`BlockTrigger interval must be an integer, got: ${blockData.interval}`);
|
|
24
34
|
}
|
|
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();
|
|
30
|
-
const config = new avs_pb.BlockTrigger.Config();
|
|
31
35
|
config.setInterval(blockData.interval);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
36
|
+
blockTrigger.setConfig(config);
|
|
37
|
+
trigger.setBlock(blockTrigger);
|
|
38
|
+
return trigger;
|
|
35
39
|
}
|
|
36
40
|
static fromResponse(raw) {
|
|
37
|
-
// Convert the raw object to TriggerProps, which should keep name and id
|
|
38
41
|
const obj = raw.toObject();
|
|
39
42
|
let data = { interval: 0 };
|
|
40
43
|
if (raw.getBlock() && raw.getBlock().hasConfig()) {
|
|
41
44
|
const config = raw.getBlock().getConfig();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
}
|
|
45
|
+
data = {
|
|
46
|
+
interval: config.getInterval(),
|
|
47
|
+
};
|
|
47
48
|
}
|
|
48
49
|
return new BlockTrigger({
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
id: obj.id,
|
|
51
|
+
name: obj.name,
|
|
52
|
+
type: obj.type,
|
|
51
53
|
data: data,
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
|
-
* Convert
|
|
56
|
-
* @param rawData - The raw data from the gRPC response
|
|
57
|
+
* Convert the output to the expected format
|
|
57
58
|
* @returns {BlockTriggerOutput | undefined} - The converted data
|
|
58
59
|
*/
|
|
59
60
|
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,
|
|
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
|
|
3
|
+
import { TriggerType } from "@avaprotocol/types";
|
|
4
4
|
class CronTrigger extends Trigger {
|
|
5
5
|
constructor(props) {
|
|
6
|
-
super({
|
|
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
|
|
21
|
+
if (!cronData.schedules || !Array.isArray(cronData.schedules)) {
|
|
19
22
|
throw new Error("Schedules are required for cron trigger");
|
|
20
23
|
}
|
|
21
|
-
// Validate schedules is not empty
|
|
22
|
-
if (
|
|
24
|
+
// Validate schedules array is not empty
|
|
25
|
+
if (cronData.schedules.length === 0) {
|
|
23
26
|
throw new Error("Schedules are 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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
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,
|
|
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
|
|
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({
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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
|