@avaprotocol/sdk-js 1.6.7 → 1.7.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.
- package/CHANGELOG.md +19 -0
- package/dist/index.d.ts +25 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +741 -15847
- package/dist/index.mjs +1401 -973
- package/dist/models/execution.d.ts +6 -14
- package/dist/models/execution.d.ts.map +1 -1
- package/dist/models/execution.js +2 -43
- package/dist/models/step.d.ts +7 -5
- package/dist/models/step.d.ts.map +1 -1
- package/dist/models/step.js +48 -15
- package/dist/models/trigger/cron.d.ts +1 -0
- package/dist/models/trigger/cron.d.ts.map +1 -1
- package/dist/models/trigger/cron.js +9 -1
- package/dist/models/trigger/fixedTime.d.ts +1 -0
- package/dist/models/trigger/fixedTime.d.ts.map +1 -1
- package/dist/models/trigger/fixedTime.js +9 -1
- package/dist/utils.d.ts +23 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +79 -0
- package/package.json +2 -2
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import TriggerReason from "./trigger/reason";
|
|
3
2
|
import Step from "./step";
|
|
4
3
|
export type StepProps = avs_pb.Execution.Step.AsObject;
|
|
5
|
-
export type OutputDataProps = avs_pb.BlockTrigger.Output.AsObject | avs_pb.FixedTimeTrigger.Output.AsObject | avs_pb.CronTrigger.Output.AsObject | avs_pb.EventTrigger.Output.AsObject | avs_pb.EventTrigger.TransferLogOutput.AsObject | avs_pb.Evm.Log.AsObject | {
|
|
4
|
+
export type OutputDataProps = avs_pb.BlockTrigger.Output.AsObject | avs_pb.FixedTimeTrigger.Output.AsObject | avs_pb.CronTrigger.Output.AsObject | avs_pb.EventTrigger.Output.AsObject | avs_pb.EventTrigger.TransferLogOutput.AsObject | avs_pb.ManualTrigger.Output.AsObject | avs_pb.Evm.Log.AsObject | {
|
|
6
5
|
blockNumber: number;
|
|
7
6
|
} | {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
epoch: number;
|
|
11
|
-
scheduleMatched: string;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
timestampIso: string;
|
|
12
9
|
} | undefined;
|
|
13
|
-
export type ExecutionProps = Omit<avs_pb.Execution.AsObject, "stepsList"
|
|
14
|
-
|
|
15
|
-
triggerReason: TriggerReason | undefined;
|
|
16
|
-
triggerOutput: OutputDataProps;
|
|
10
|
+
export type ExecutionProps = Omit<avs_pb.Execution.AsObject, "stepsList"> & {
|
|
11
|
+
steps: Step[];
|
|
17
12
|
};
|
|
18
13
|
declare class Execution implements ExecutionProps {
|
|
19
14
|
id: string;
|
|
@@ -21,10 +16,7 @@ declare class Execution implements ExecutionProps {
|
|
|
21
16
|
endAt: number;
|
|
22
17
|
success: boolean;
|
|
23
18
|
error: string;
|
|
24
|
-
|
|
25
|
-
triggerReason: TriggerReason | undefined;
|
|
26
|
-
triggerName: string;
|
|
27
|
-
triggerOutput: OutputDataProps;
|
|
19
|
+
steps: Step[];
|
|
28
20
|
constructor(props: ExecutionProps);
|
|
29
21
|
static fromResponse(execution: avs_pb.Execution): Execution;
|
|
30
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/models/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/models/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;AAEvD,MAAM,MAAM,eAAe,GACvB,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,GACnC,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,iBAAiB,CAAC,QAAQ,GAC9C,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,GACpC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,GACvB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACvB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAC3C,SAAS,CAAC;AAEd,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,MAAM,CAAC,SAAS,CAAC,QAAQ,EACvB,WAAW,CACd,GAAG;IACF,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,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"}
|
package/dist/models/execution.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import TriggerReason from "./trigger/reason";
|
|
3
1
|
import Step from "./step";
|
|
4
2
|
class Execution {
|
|
5
3
|
constructor(props) {
|
|
@@ -8,55 +6,16 @@ class Execution {
|
|
|
8
6
|
this.endAt = props.endAt;
|
|
9
7
|
this.success = props.success;
|
|
10
8
|
this.error = props.error;
|
|
11
|
-
this.
|
|
12
|
-
this.triggerName = props.triggerName;
|
|
13
|
-
this.triggerReason = props.triggerReason;
|
|
14
|
-
this.triggerOutput = props.triggerOutput;
|
|
9
|
+
this.steps = props.steps;
|
|
15
10
|
}
|
|
16
11
|
static fromResponse(execution) {
|
|
17
|
-
const triggerOutputDataType = execution.getOutputDataCase();
|
|
18
|
-
let triggerOutputData;
|
|
19
|
-
switch (triggerOutputDataType) {
|
|
20
|
-
case avs_pb.Execution.OutputDataCase.BLOCK_TRIGGER:
|
|
21
|
-
const blockOutput = execution.getBlockTrigger()?.toObject();
|
|
22
|
-
// Filter to only return blockNumber for block triggers
|
|
23
|
-
triggerOutputData = blockOutput ? { blockNumber: blockOutput.blockNumber } : undefined;
|
|
24
|
-
break;
|
|
25
|
-
case avs_pb.Execution.OutputDataCase.FIXED_TIME_TRIGGER:
|
|
26
|
-
const fixedTimeOutput = execution.getFixedTimeTrigger()?.toObject();
|
|
27
|
-
// Filter to only return epoch for fixed time triggers
|
|
28
|
-
triggerOutputData = fixedTimeOutput ? { epoch: fixedTimeOutput.epoch } : undefined;
|
|
29
|
-
break;
|
|
30
|
-
case avs_pb.Execution.OutputDataCase.CRON_TRIGGER:
|
|
31
|
-
const cronOutput = execution.getCronTrigger()?.toObject();
|
|
32
|
-
// Filter to only return epoch and scheduleMatched for cron triggers
|
|
33
|
-
triggerOutputData = cronOutput ? { epoch: cronOutput.epoch, scheduleMatched: cronOutput.scheduleMatched } : undefined;
|
|
34
|
-
break;
|
|
35
|
-
case avs_pb.Execution.OutputDataCase.EVENT_TRIGGER:
|
|
36
|
-
const eventTrigger = execution.getEventTrigger();
|
|
37
|
-
if (eventTrigger) {
|
|
38
|
-
if (eventTrigger.hasEvmLog()) {
|
|
39
|
-
triggerOutputData = eventTrigger.getEvmLog()?.toObject();
|
|
40
|
-
}
|
|
41
|
-
else if (eventTrigger.hasTransferLog()) {
|
|
42
|
-
triggerOutputData = eventTrigger.getTransferLog()?.toObject();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
case avs_pb.Execution.OutputDataCase.OUTPUT_DATA_NOT_SET:
|
|
47
|
-
triggerOutputData = undefined;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
12
|
return new Execution({
|
|
51
13
|
id: execution.getId(),
|
|
52
14
|
startAt: execution.getStartAt(),
|
|
53
15
|
endAt: execution.getEndAt(),
|
|
54
16
|
success: execution.getSuccess(),
|
|
55
17
|
error: execution.getError(),
|
|
56
|
-
|
|
57
|
-
triggerReason: TriggerReason.fromResponse(execution.getReason()),
|
|
58
|
-
triggerOutput: triggerOutputData,
|
|
59
|
-
stepsList: execution
|
|
18
|
+
steps: execution
|
|
60
19
|
.getStepsList()
|
|
61
20
|
.map((step) => Step.fromResponse(step)),
|
|
62
21
|
});
|
package/dist/models/step.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
export type StepProps = Omit<avs_pb.Execution.Step.AsObject, "outputDataCase" | "ethTransfer" | "graphql" | "contractRead" | "contractWrite" | "customCode" | "restApi" | "branch" | "filter" | "loop"> & {
|
|
2
|
+
export type StepProps = Omit<avs_pb.Execution.Step.AsObject, "outputDataCase" | "ethTransfer" | "graphql" | "contractRead" | "contractWrite" | "customCode" | "restApi" | "branch" | "filter" | "loop" | "blockTrigger" | "fixedTimeTrigger" | "cronTrigger" | "eventTrigger" | "manualTrigger"> & {
|
|
3
3
|
output: any;
|
|
4
4
|
};
|
|
5
5
|
declare class Step implements StepProps {
|
|
6
|
-
|
|
6
|
+
id: string;
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
7
9
|
success: boolean;
|
|
8
|
-
log: string;
|
|
9
10
|
error: string;
|
|
10
|
-
|
|
11
|
-
endAt: number;
|
|
11
|
+
log: string;
|
|
12
12
|
inputsList: string[];
|
|
13
13
|
output: any;
|
|
14
|
+
startAt: number;
|
|
15
|
+
endAt: number;
|
|
14
16
|
constructor(props: StepProps);
|
|
15
17
|
static getOutput(step: avs_pb.Execution.Step): any;
|
|
16
18
|
static fromResponse(step: avs_pb.Execution.Step): Step;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAGhD,MAAM,MAAM,SAAS,GAAG,IAAI,CAC1B,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAC5B,gBAAgB,GAChB,aAAa,GACb,SAAS,GACT,cAAc,GACd,eAAe,GACf,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,MAAM,
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAGhD,MAAM,MAAM,SAAS,GAAG,IAAI,CAC1B,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAC5B,gBAAgB,GAChB,aAAa,GACb,SAAS,GACT,cAAc,GACd,eAAe,GACf,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,cAAc,GACd,kBAAkB,GAClB,aAAa,GACb,cAAc,GACd,eAAe,CAClB,GAAG;IACF,MAAM,EAAE,GAAG,CAAC;CACb,CAAC;AAKF,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,GAAG,CAAC;IACZ,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,GAAG;IAmFlD,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CAgBvD;AAED,eAAe,IAAI,CAAC"}
|
package/dist/models/step.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import { convertProtobufValueToJs } from "../utils";
|
|
2
|
+
import { convertProtobufValueToJs, convertProtobufStepTypeToSdk } from "../utils";
|
|
3
3
|
// OutputDataProps is no longer a union of AsObject, it will be the converted JS type via 'output'
|
|
4
4
|
// export type OutputDataProps = ... (removed)
|
|
5
5
|
class Step {
|
|
6
6
|
constructor(props) {
|
|
7
|
-
this.
|
|
7
|
+
this.id = props.id;
|
|
8
|
+
this.type = props.type;
|
|
9
|
+
this.name = props.name;
|
|
8
10
|
this.success = props.success;
|
|
9
|
-
this.log = props.log;
|
|
10
11
|
this.error = props.error;
|
|
11
|
-
this.
|
|
12
|
-
this.endAt = props.endAt;
|
|
12
|
+
this.log = props.log;
|
|
13
13
|
this.inputsList = props.inputsList;
|
|
14
14
|
this.output = props.output;
|
|
15
|
+
this.startAt = props.startAt;
|
|
16
|
+
this.endAt = props.endAt;
|
|
15
17
|
}
|
|
16
18
|
static getOutput(step) {
|
|
17
19
|
const outputDataType = step.getOutputDataCase();
|
|
@@ -19,24 +21,54 @@ class Step {
|
|
|
19
21
|
switch (outputDataType) {
|
|
20
22
|
case avs_pb.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET:
|
|
21
23
|
return null;
|
|
24
|
+
// Trigger outputs
|
|
25
|
+
case avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
|
|
26
|
+
const blockOutput = step.getBlockTrigger()?.toObject();
|
|
27
|
+
return blockOutput ? { blockNumber: blockOutput.blockNumber } : undefined;
|
|
28
|
+
case avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
|
|
29
|
+
const fixedTimeOutput = step.getFixedTimeTrigger()?.toObject();
|
|
30
|
+
return fixedTimeOutput ? {
|
|
31
|
+
timestamp: fixedTimeOutput.timestamp,
|
|
32
|
+
timestampIso: fixedTimeOutput.timestampIso
|
|
33
|
+
} : undefined;
|
|
34
|
+
case avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER:
|
|
35
|
+
const cronOutput = step.getCronTrigger()?.toObject();
|
|
36
|
+
return cronOutput ? {
|
|
37
|
+
timestamp: cronOutput.timestamp,
|
|
38
|
+
timestampIso: cronOutput.timestampIso
|
|
39
|
+
} : undefined;
|
|
40
|
+
case avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER:
|
|
41
|
+
const eventTrigger = step.getEventTrigger();
|
|
42
|
+
if (eventTrigger) {
|
|
43
|
+
if (eventTrigger.hasEvmLog()) {
|
|
44
|
+
return eventTrigger.getEvmLog()?.toObject();
|
|
45
|
+
}
|
|
46
|
+
else if (eventTrigger.hasTransferLog()) {
|
|
47
|
+
return eventTrigger.getTransferLog()?.toObject();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
case avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
|
|
52
|
+
const manualOutput = step.getManualTrigger()?.toObject();
|
|
53
|
+
return manualOutput || undefined;
|
|
54
|
+
// Node outputs
|
|
22
55
|
case avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER:
|
|
23
|
-
return step.getEthTransfer()?.toObject();
|
|
56
|
+
return step.getEthTransfer()?.toObject();
|
|
24
57
|
case avs_pb.Execution.Step.OutputDataCase.GRAPHQL:
|
|
25
58
|
nodeOutputMessage = step.getGraphql();
|
|
26
59
|
return nodeOutputMessage && nodeOutputMessage.hasData()
|
|
27
60
|
? nodeOutputMessage.getData()
|
|
28
61
|
: undefined;
|
|
29
62
|
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ:
|
|
30
|
-
// ContractReadNode.Output has 'repeated google.protobuf.Value data'
|
|
31
63
|
nodeOutputMessage = step.getContractRead();
|
|
32
64
|
if (nodeOutputMessage) {
|
|
33
65
|
return nodeOutputMessage
|
|
34
66
|
.getDataList()
|
|
35
67
|
.map((val) => convertProtobufValueToJs(val));
|
|
36
68
|
}
|
|
37
|
-
return [];
|
|
69
|
+
return [];
|
|
38
70
|
case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE:
|
|
39
|
-
return step.getContractWrite()?.toObject();
|
|
71
|
+
return step.getContractWrite()?.toObject();
|
|
40
72
|
case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
|
|
41
73
|
nodeOutputMessage = step.getCustomCode();
|
|
42
74
|
return nodeOutputMessage && nodeOutputMessage.hasData()
|
|
@@ -48,14 +80,13 @@ class Step {
|
|
|
48
80
|
? nodeOutputMessage.getData()
|
|
49
81
|
: undefined;
|
|
50
82
|
case avs_pb.Execution.Step.OutputDataCase.BRANCH:
|
|
51
|
-
return step.getBranch()?.toObject();
|
|
83
|
+
return step.getBranch()?.toObject();
|
|
52
84
|
case avs_pb.Execution.Step.OutputDataCase.FILTER:
|
|
53
85
|
nodeOutputMessage = step.getFilter();
|
|
54
86
|
return nodeOutputMessage && nodeOutputMessage.hasData()
|
|
55
87
|
? nodeOutputMessage.getData()
|
|
56
88
|
: undefined;
|
|
57
89
|
case avs_pb.Execution.Step.OutputDataCase.LOOP:
|
|
58
|
-
// LoopNode.Output has 'string data' - handle as plain string for now
|
|
59
90
|
return step.getLoop()?.getData();
|
|
60
91
|
default:
|
|
61
92
|
console.warn(`Unhandled output data type in Step.getOutput: ${outputDataType}`);
|
|
@@ -64,14 +95,16 @@ class Step {
|
|
|
64
95
|
}
|
|
65
96
|
static fromResponse(step) {
|
|
66
97
|
return new Step({
|
|
67
|
-
|
|
98
|
+
id: step.getId(),
|
|
99
|
+
type: convertProtobufStepTypeToSdk(step.getType()),
|
|
100
|
+
name: step.getName(),
|
|
68
101
|
success: step.getSuccess(),
|
|
69
|
-
log: step.getLog(),
|
|
70
102
|
error: step.getError(),
|
|
71
|
-
|
|
72
|
-
endAt: step.getEndAt(),
|
|
103
|
+
log: step.getLog(),
|
|
73
104
|
inputsList: step.getInputsList(),
|
|
74
105
|
output: Step.getOutput(step),
|
|
106
|
+
startAt: step.getStartAt(),
|
|
107
|
+
endAt: step.getEndAt(),
|
|
75
108
|
});
|
|
76
109
|
}
|
|
77
110
|
}
|
|
@@ -16,6 +16,7 @@ declare class CronTrigger extends Trigger {
|
|
|
16
16
|
getOutput(): CronTriggerOutput | undefined;
|
|
17
17
|
/**
|
|
18
18
|
* Extract output data from RunTriggerResp for cron triggers
|
|
19
|
+
* Updated to handle timestamp and timestamp_iso instead of epoch
|
|
19
20
|
* @param outputData - The RunTriggerResp containing cron trigger output
|
|
20
21
|
* @returns Plain JavaScript object with cron trigger data
|
|
21
22
|
*/
|
|
@@ -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,EAAE,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAe,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGzF,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAE5E,cAAM,WAAY,SAAQ,OAAO;gBACnB,KAAK,EAAE,gBAAgB;IAInC,SAAS,IAAI,MAAM,CAAC,WAAW;IAmB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,WAAW;IAuBzD;;;;OAIG;IACH,SAAS,IAAI,iBAAiB,GAAG,SAAS;IAI1C
|
|
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,EAAE,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAe,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGzF,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAE5E,cAAM,WAAY,SAAQ,OAAO;gBACnB,KAAK,EAAE,gBAAgB;IAInC,SAAS,IAAI,MAAM,CAAC,WAAW;IAmB/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;CAW9D;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -47,12 +47,20 @@ class CronTrigger extends Trigger {
|
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Extract output data from RunTriggerResp for cron triggers
|
|
50
|
+
* Updated to handle timestamp and timestamp_iso instead of epoch
|
|
50
51
|
* @param outputData - The RunTriggerResp containing cron trigger output
|
|
51
52
|
* @returns Plain JavaScript object with cron trigger data
|
|
52
53
|
*/
|
|
53
54
|
static fromOutputData(outputData) {
|
|
54
55
|
const cronOutput = outputData.getCronTrigger();
|
|
55
|
-
|
|
56
|
+
if (!cronOutput)
|
|
57
|
+
return null;
|
|
58
|
+
const outputObj = cronOutput.toObject();
|
|
59
|
+
// The output now contains timestamp and timestampIso instead of epoch
|
|
60
|
+
return {
|
|
61
|
+
timestamp: outputObj.timestamp,
|
|
62
|
+
timestampIso: outputObj.timestampIso
|
|
63
|
+
};
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
export default CronTrigger;
|
|
@@ -16,6 +16,7 @@ declare class FixedTimeTrigger extends Trigger {
|
|
|
16
16
|
getOutput(): FixedTimeTriggerOutput | undefined;
|
|
17
17
|
/**
|
|
18
18
|
* Extract output data from RunTriggerResp for fixed time triggers
|
|
19
|
+
* Updated to handle timestamp and timestamp_iso instead of epoch
|
|
19
20
|
* @param outputData - The RunTriggerResp containing fixed time trigger output
|
|
20
21
|
* @returns Plain JavaScript object with fixed time trigger data
|
|
21
22
|
*/
|
|
@@ -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,EAAE,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAe,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGnG,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG;IACjD,IAAI,EAAE,wBAAwB,CAAC;CAChC,CAAC;AAEF,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAIxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAmB/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,gBAAgB;IAuB9D;;;;OAIG;IACH,SAAS,IAAI,sBAAsB,GAAG,SAAS;IAI/C
|
|
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,EAAE,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAe,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGnG,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG;IACjD,IAAI,EAAE,wBAAwB,CAAC;CAChC,CAAC;AAEF,cAAM,gBAAiB,SAAQ,OAAO;gBACxB,KAAK,EAAE,qBAAqB;IAIxC,SAAS,IAAI,MAAM,CAAC,WAAW;IAmB/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;CAW9D;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -47,12 +47,20 @@ class FixedTimeTrigger extends Trigger {
|
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Extract output data from RunTriggerResp for fixed time triggers
|
|
50
|
+
* Updated to handle timestamp and timestamp_iso instead of epoch
|
|
50
51
|
* @param outputData - The RunTriggerResp containing fixed time trigger output
|
|
51
52
|
* @returns Plain JavaScript object with fixed time trigger data
|
|
52
53
|
*/
|
|
53
54
|
static fromOutputData(outputData) {
|
|
54
55
|
const fixedTimeOutput = outputData.getFixedTimeTrigger();
|
|
55
|
-
|
|
56
|
+
if (!fixedTimeOutput)
|
|
57
|
+
return null;
|
|
58
|
+
const outputObj = fixedTimeOutput.toObject();
|
|
59
|
+
// The output now contains timestamp and timestampIso instead of epoch
|
|
60
|
+
return {
|
|
61
|
+
timestamp: outputObj.timestamp,
|
|
62
|
+
timestampIso: outputObj.timestampIso
|
|
63
|
+
};
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
export default FixedTimeTrigger;
|
package/dist/utils.d.ts
CHANGED
|
@@ -34,4 +34,27 @@ export declare function convertProtobufValueToJS(value: any): any;
|
|
|
34
34
|
* @returns The protobuf Value object
|
|
35
35
|
*/
|
|
36
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;
|
|
37
60
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,aAAa,EAGvB,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,aAAa,EAGvB,MAAM,2CAA2C,CAAC;AAGnD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,GAAG,CAiCnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAkDxD;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CA6BlE;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAkB5E;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA0BzE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CASzE"}
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Value as ProtobufValue, Struct as ProtobufStruct, ListValue as ProtobufListValue } from "google-protobuf/google/protobuf/struct_pb";
|
|
2
|
+
import { TriggerType, NodeType } from "@avaprotocol/types";
|
|
2
3
|
/**
|
|
3
4
|
* Convert a protobuf Value to a JavaScript value
|
|
4
5
|
*
|
|
@@ -149,3 +150,81 @@ export function convertJSValueToProtobuf(value) {
|
|
|
149
150
|
}
|
|
150
151
|
return protobufValue;
|
|
151
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Convert protobuf trigger type string to SDK trigger type string
|
|
155
|
+
*
|
|
156
|
+
* @param protobufType - The protobuf trigger type string (e.g., "TRIGGER_TYPE_MANUAL")
|
|
157
|
+
* @returns The SDK trigger type string (e.g., "manualTrigger")
|
|
158
|
+
*/
|
|
159
|
+
export function convertProtobufTriggerTypeToSdk(protobufType) {
|
|
160
|
+
switch (protobufType) {
|
|
161
|
+
case 'TRIGGER_TYPE_MANUAL':
|
|
162
|
+
return TriggerType.Manual; // "manualTrigger"
|
|
163
|
+
case 'TRIGGER_TYPE_FIXED_TIME':
|
|
164
|
+
return TriggerType.FixedTime; // "fixedTimeTrigger"
|
|
165
|
+
case 'TRIGGER_TYPE_CRON':
|
|
166
|
+
return TriggerType.Cron; // "cronTrigger"
|
|
167
|
+
case 'TRIGGER_TYPE_BLOCK':
|
|
168
|
+
return TriggerType.Block; // "blockTrigger"
|
|
169
|
+
case 'TRIGGER_TYPE_EVENT':
|
|
170
|
+
return TriggerType.Event; // "eventTrigger"
|
|
171
|
+
case 'TRIGGER_TYPE_UNSPECIFIED':
|
|
172
|
+
return TriggerType.Unspecified; // "unspecified"
|
|
173
|
+
default:
|
|
174
|
+
console.warn(`Unknown trigger type: ${protobufType}, using raw value`);
|
|
175
|
+
return protobufType; // fallback to raw value
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Convert protobuf node type string to SDK node type string
|
|
180
|
+
*
|
|
181
|
+
* @param protobufType - The protobuf node type string (e.g., "NODE_TYPE_CUSTOM_CODE")
|
|
182
|
+
* @returns The SDK node type string (e.g., "customCode")
|
|
183
|
+
*/
|
|
184
|
+
export function convertProtobufNodeTypeToSdk(protobufType) {
|
|
185
|
+
switch (protobufType) {
|
|
186
|
+
case 'NODE_TYPE_ETH_TRANSFER':
|
|
187
|
+
return NodeType.ETHTransfer; // "ethTransfer"
|
|
188
|
+
case 'NODE_TYPE_CONTRACT_WRITE':
|
|
189
|
+
return NodeType.ContractWrite; // "contractWrite"
|
|
190
|
+
case 'NODE_TYPE_CONTRACT_READ':
|
|
191
|
+
return NodeType.ContractRead; // "contractRead"
|
|
192
|
+
case 'NODE_TYPE_GRAPHQL_QUERY':
|
|
193
|
+
return NodeType.GraphQLQuery; // "graphql"
|
|
194
|
+
case 'NODE_TYPE_REST_API':
|
|
195
|
+
return NodeType.RestAPI; // "restApi"
|
|
196
|
+
case 'NODE_TYPE_CUSTOM_CODE':
|
|
197
|
+
return NodeType.CustomCode; // "customCode"
|
|
198
|
+
case 'NODE_TYPE_BRANCH':
|
|
199
|
+
return NodeType.Branch; // "branch"
|
|
200
|
+
case 'NODE_TYPE_FILTER':
|
|
201
|
+
return NodeType.Filter; // "filter"
|
|
202
|
+
case 'NODE_TYPE_LOOP':
|
|
203
|
+
return NodeType.Loop; // "loop"
|
|
204
|
+
case 'NODE_TYPE_UNSPECIFIED':
|
|
205
|
+
return NodeType.Unspecified; // "unspecified"
|
|
206
|
+
default:
|
|
207
|
+
console.warn(`Unknown node type: ${protobufType}, using raw value`);
|
|
208
|
+
return protobufType; // fallback to raw value
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Convert protobuf step type string to SDK step type string
|
|
213
|
+
*
|
|
214
|
+
* Automatically detects whether the type is a trigger or node type and converts accordingly.
|
|
215
|
+
*
|
|
216
|
+
* @param protobufType - The protobuf type string (e.g., "TRIGGER_TYPE_MANUAL" or "NODE_TYPE_CUSTOM_CODE")
|
|
217
|
+
* @returns The SDK type string (e.g., "manualTrigger" or "customCode")
|
|
218
|
+
*/
|
|
219
|
+
export function convertProtobufStepTypeToSdk(protobufType) {
|
|
220
|
+
if (protobufType.startsWith('TRIGGER_TYPE_')) {
|
|
221
|
+
return convertProtobufTriggerTypeToSdk(protobufType);
|
|
222
|
+
}
|
|
223
|
+
else if (protobufType.startsWith('NODE_TYPE_')) {
|
|
224
|
+
return convertProtobufNodeTypeToSdk(protobufType);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
console.warn(`Unknown step type: ${protobufType}, using raw value`);
|
|
228
|
+
return protobufType; // fallback to raw value
|
|
229
|
+
}
|
|
230
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avaprotocol/sdk-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"clean": "rm -rf node_modules dist tsconfig.tsbuildinfo"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@avaprotocol/types": "1.0
|
|
33
|
+
"@avaprotocol/types": "1.1.0",
|
|
34
34
|
"@grpc/grpc-js": "^1.11.3",
|
|
35
35
|
"@grpc/proto-loader": "^0.7.13",
|
|
36
36
|
"dotenv": "^16.4.5",
|