@avaprotocol/sdk-js 2.17.0 → 3.0.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.
Files changed (145) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +11 -1
  3. package/dist/index.d.ts +1 -370
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +856 -22369
  6. package/dist/index.mjs +820 -22402
  7. package/dist/v4/auth.d.ts +79 -0
  8. package/dist/v4/auth.d.ts.map +1 -0
  9. package/dist/v4/auth.js +92 -0
  10. package/dist/v4/builders/nodes.d.ts +106 -0
  11. package/dist/v4/builders/nodes.d.ts.map +1 -0
  12. package/dist/v4/builders/nodes.js +133 -0
  13. package/dist/v4/builders/triggers.d.ts +66 -0
  14. package/dist/v4/builders/triggers.d.ts.map +1 -0
  15. package/dist/v4/builders/triggers.js +74 -0
  16. package/dist/v4/chains.d.ts +19 -0
  17. package/dist/v4/chains.d.ts.map +1 -0
  18. package/dist/v4/chains.js +22 -0
  19. package/dist/v4/client.d.ts +60 -0
  20. package/dist/v4/client.d.ts.map +1 -0
  21. package/dist/v4/client.js +53 -0
  22. package/dist/v4/index.d.ts +19 -0
  23. package/dist/v4/index.d.ts.map +1 -0
  24. package/dist/v4/index.js +24 -0
  25. package/dist/v4/internal/errors.d.ts +36 -0
  26. package/dist/v4/internal/errors.d.ts.map +1 -0
  27. package/dist/v4/internal/errors.js +32 -0
  28. package/dist/v4/internal/transport.d.ts +64 -0
  29. package/dist/v4/internal/transport.d.ts.map +1 -0
  30. package/dist/v4/internal/transport.js +133 -0
  31. package/dist/v4/protocols/index.d.ts +2 -0
  32. package/dist/v4/protocols/index.d.ts.map +1 -0
  33. package/dist/v4/protocols/index.js +13 -0
  34. package/dist/v4/resources/auth.d.ts +45 -0
  35. package/dist/v4/resources/auth.d.ts.map +1 -0
  36. package/dist/v4/resources/auth.js +59 -0
  37. package/dist/v4/resources/executions.d.ts +74 -0
  38. package/dist/v4/resources/executions.d.ts.map +1 -0
  39. package/dist/v4/resources/executions.js +132 -0
  40. package/dist/v4/resources/health.d.ts +19 -0
  41. package/dist/v4/resources/health.d.ts.map +1 -0
  42. package/dist/v4/resources/health.js +19 -0
  43. package/dist/v4/resources/nodes.d.ts +29 -0
  44. package/dist/v4/resources/nodes.d.ts.map +1 -0
  45. package/dist/v4/resources/nodes.js +33 -0
  46. package/dist/v4/resources/operators.d.ts +23 -0
  47. package/dist/v4/resources/operators.d.ts.map +1 -0
  48. package/dist/v4/resources/operators.js +23 -0
  49. package/dist/v4/resources/secrets.d.ts +34 -0
  50. package/dist/v4/resources/secrets.d.ts.map +1 -0
  51. package/dist/v4/resources/secrets.js +38 -0
  52. package/dist/v4/resources/tokens.d.ts +28 -0
  53. package/dist/v4/resources/tokens.d.ts.map +1 -0
  54. package/dist/v4/resources/tokens.js +29 -0
  55. package/dist/v4/resources/triggers.d.ts +29 -0
  56. package/dist/v4/resources/triggers.d.ts.map +1 -0
  57. package/dist/v4/resources/triggers.js +33 -0
  58. package/dist/v4/resources/wallets.d.ts +72 -0
  59. package/dist/v4/resources/wallets.d.ts.map +1 -0
  60. package/dist/v4/resources/wallets.js +92 -0
  61. package/dist/v4/resources/workflows.d.ts +64 -0
  62. package/dist/v4/resources/workflows.d.ts.map +1 -0
  63. package/dist/v4/resources/workflows.js +91 -0
  64. package/package.json +9 -11
  65. package/dist/auth.d.ts +0 -2
  66. package/dist/auth.d.ts.map +0 -1
  67. package/dist/auth.js +0 -10
  68. package/dist/config.d.ts +0 -9
  69. package/dist/config.d.ts.map +0 -1
  70. package/dist/config.js +0 -19
  71. package/dist/models/edge.d.ts +0 -12
  72. package/dist/models/edge.d.ts.map +0 -1
  73. package/dist/models/edge.js +0 -19
  74. package/dist/models/execution.d.ts +0 -30
  75. package/dist/models/execution.d.ts.map +0 -1
  76. package/dist/models/execution.js +0 -100
  77. package/dist/models/node/balance.d.ts +0 -17
  78. package/dist/models/node/balance.d.ts.map +0 -1
  79. package/dist/models/node/balance.js +0 -78
  80. package/dist/models/node/branch.d.ts +0 -11
  81. package/dist/models/node/branch.d.ts.map +0 -1
  82. package/dist/models/node/branch.js +0 -63
  83. package/dist/models/node/contractRead.d.ts +0 -17
  84. package/dist/models/node/contractRead.d.ts.map +0 -1
  85. package/dist/models/node/contractRead.js +0 -91
  86. package/dist/models/node/contractWrite.d.ts +0 -17
  87. package/dist/models/node/contractWrite.d.ts.map +0 -1
  88. package/dist/models/node/contractWrite.js +0 -102
  89. package/dist/models/node/customCode.d.ts +0 -20
  90. package/dist/models/node/customCode.d.ts.map +0 -1
  91. package/dist/models/node/customCode.js +0 -74
  92. package/dist/models/node/ethTransfer.d.ts +0 -20
  93. package/dist/models/node/ethTransfer.d.ts.map +0 -1
  94. package/dist/models/node/ethTransfer.js +0 -58
  95. package/dist/models/node/factory.d.ts +0 -24
  96. package/dist/models/node/factory.d.ts.map +0 -1
  97. package/dist/models/node/factory.js +0 -108
  98. package/dist/models/node/filter.d.ts +0 -11
  99. package/dist/models/node/filter.d.ts.map +0 -1
  100. package/dist/models/node/filter.js +0 -57
  101. package/dist/models/node/graphqlQuery.d.ts +0 -21
  102. package/dist/models/node/graphqlQuery.d.ts.map +0 -1
  103. package/dist/models/node/graphqlQuery.js +0 -74
  104. package/dist/models/node/interface.d.ts +0 -20
  105. package/dist/models/node/interface.d.ts.map +0 -1
  106. package/dist/models/node/interface.js +0 -58
  107. package/dist/models/node/loop.d.ts +0 -15
  108. package/dist/models/node/loop.d.ts.map +0 -1
  109. package/dist/models/node/loop.js +0 -235
  110. package/dist/models/node/restApi.d.ts +0 -23
  111. package/dist/models/node/restApi.d.ts.map +0 -1
  112. package/dist/models/node/restApi.js +0 -84
  113. package/dist/models/secret.d.ts +0 -16
  114. package/dist/models/secret.d.ts.map +0 -1
  115. package/dist/models/secret.js +0 -28
  116. package/dist/models/step.d.ts +0 -33
  117. package/dist/models/step.d.ts.map +0 -1
  118. package/dist/models/step.js +0 -287
  119. package/dist/models/trigger/block.d.ts +0 -21
  120. package/dist/models/trigger/block.d.ts.map +0 -1
  121. package/dist/models/trigger/block.js +0 -81
  122. package/dist/models/trigger/cron.d.ts +0 -23
  123. package/dist/models/trigger/cron.d.ts.map +0 -1
  124. package/dist/models/trigger/cron.js +0 -77
  125. package/dist/models/trigger/event.d.ts +0 -22
  126. package/dist/models/trigger/event.d.ts.map +0 -1
  127. package/dist/models/trigger/event.js +0 -244
  128. package/dist/models/trigger/factory.d.ts +0 -27
  129. package/dist/models/trigger/factory.d.ts.map +0 -1
  130. package/dist/models/trigger/factory.js +0 -73
  131. package/dist/models/trigger/fixedTime.d.ts +0 -23
  132. package/dist/models/trigger/fixedTime.d.ts.map +0 -1
  133. package/dist/models/trigger/fixedTime.js +0 -69
  134. package/dist/models/trigger/interface.d.ts +0 -19
  135. package/dist/models/trigger/interface.d.ts.map +0 -1
  136. package/dist/models/trigger/interface.js +0 -35
  137. package/dist/models/trigger/manual.d.ts +0 -16
  138. package/dist/models/trigger/manual.d.ts.map +0 -1
  139. package/dist/models/trigger/manual.js +0 -117
  140. package/dist/models/workflow.d.ts +0 -53
  141. package/dist/models/workflow.d.ts.map +0 -1
  142. package/dist/models/workflow.js +0 -219
  143. package/dist/utils.d.ts +0 -82
  144. package/dist/utils.d.ts.map +0 -1
  145. package/dist/utils.js +0 -286
@@ -1,33 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import { StepProps, OutputDataProps } from "@avaprotocol/types";
3
- declare class Step implements StepProps {
4
- id: string;
5
- type: string;
6
- name: string;
7
- success: boolean;
8
- error: string;
9
- errorCode: number;
10
- log: string;
11
- inputsList: string[];
12
- config?: any;
13
- output: OutputDataProps;
14
- startAt: number;
15
- endAt: number;
16
- metadata?: any;
17
- executionContext?: any;
18
- gasUsed?: string;
19
- gasPrice?: string;
20
- totalGasCost?: string;
21
- constructor(props: StepProps);
22
- /**
23
- * Convert Step instance to plain object (StepProps)
24
- * This is useful for serialization, especially with Next.js Server Components
25
- */
26
- toJson(): StepProps;
27
- static getOutput(step: avs_pb.Execution.Step): OutputDataProps;
28
- private static extractOutputData;
29
- private static getOutputDataCase;
30
- static fromResponse(step: avs_pb.Execution.Step): Step;
31
- }
32
- export default Step;
33
- //# sourceMappingURL=step.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/models/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAMhD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhE,cAAM,IAAK,YAAW,SAAS;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,gBAAgB,CAAC,EAAE,GAAG,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEV,KAAK,EAAE,SAAS;IAoB5B;;;OAGG;IACH,MAAM,IAAI,SAAS;IAsBnB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,eAAe;IAoC9D,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAqEhC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAmChC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI;CA2HvD;AAED,eAAe,IAAI,CAAC"}
@@ -1,287 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import { convertProtobufValueToJs, convertProtobufStepTypeToSdk, } from "../utils";
3
- class Step {
4
- constructor(props) {
5
- this.id = props.id;
6
- this.type = props.type;
7
- this.name = props.name;
8
- this.success = props.success;
9
- this.error = props.error;
10
- this.errorCode = props.errorCode;
11
- this.log = props.log;
12
- this.inputsList = props.inputsList;
13
- this.config = props.config;
14
- this.output = props.output;
15
- this.startAt = props.startAt;
16
- this.endAt = props.endAt;
17
- this.metadata = props.metadata;
18
- this.executionContext = props.executionContext;
19
- this.gasUsed = props.gasUsed;
20
- this.gasPrice = props.gasPrice;
21
- this.totalGasCost = props.totalGasCost;
22
- }
23
- /**
24
- * Convert Step instance to plain object (StepProps)
25
- * This is useful for serialization, especially with Next.js Server Components
26
- */
27
- toJson() {
28
- return {
29
- id: this.id,
30
- type: this.type,
31
- name: this.name,
32
- success: this.success,
33
- error: this.error,
34
- errorCode: this.errorCode,
35
- log: this.log,
36
- inputsList: this.inputsList,
37
- config: this.config,
38
- output: this.output,
39
- startAt: this.startAt,
40
- endAt: this.endAt,
41
- metadata: this.metadata,
42
- executionContext: this.executionContext,
43
- ...(this.gasUsed && { gasUsed: this.gasUsed }),
44
- ...(this.gasPrice && { gasPrice: this.gasPrice }),
45
- ...(this.totalGasCost && { totalGasCost: this.totalGasCost }),
46
- };
47
- }
48
- static getOutput(step) {
49
- // Always return Output.data; step-level metadata is separate.
50
- const outputObj = this.extractOutputData(step);
51
- if (!outputObj)
52
- return null;
53
- // Protobuf accessor path
54
- if (typeof outputObj.getData === "function") {
55
- const val = outputObj.getData();
56
- if (!val)
57
- return null;
58
- try {
59
- return convertProtobufValueToJs(val);
60
- }
61
- catch (error) {
62
- console.warn("Failed to convert protobuf Value to JavaScript:", error);
63
- return val;
64
- }
65
- }
66
- // Plain object fallback
67
- const data = outputObj.data;
68
- if (data) {
69
- try {
70
- return typeof data.getKindCase === "function"
71
- ? convertProtobufValueToJs(data)
72
- : data;
73
- }
74
- catch (error) {
75
- console.warn("Failed to convert plain object Value to JavaScript:", error);
76
- return data;
77
- }
78
- }
79
- return null;
80
- }
81
- static extractOutputData(step) {
82
- // Simple switch to get the output object - all handled identically
83
- const outputCase = this.getOutputDataCase(step);
84
- switch (outputCase) {
85
- case avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER:
86
- return typeof step.getBlockTrigger === "function"
87
- ? step.getBlockTrigger()
88
- : step.blockTrigger;
89
- case avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER:
90
- return typeof step.getFixedTimeTrigger === "function"
91
- ? step.getFixedTimeTrigger()
92
- : step.fixedTimeTrigger;
93
- case avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER:
94
- return typeof step.getCronTrigger === "function"
95
- ? step.getCronTrigger()
96
- : step.cronTrigger;
97
- case avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER:
98
- return typeof step.getEventTrigger === "function"
99
- ? step.getEventTrigger()
100
- : step.eventTrigger;
101
- case avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER:
102
- return typeof step.getManualTrigger === "function"
103
- ? step.getManualTrigger()
104
- : step.manualTrigger;
105
- case avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER:
106
- return typeof step.getEthTransfer === "function"
107
- ? step.getEthTransfer()
108
- : step.ethTransfer;
109
- case avs_pb.Execution.Step.OutputDataCase.GRAPHQL:
110
- return typeof step.getGraphql === "function"
111
- ? step.getGraphql()
112
- : step.graphql;
113
- case avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ:
114
- return typeof step.getContractRead === "function"
115
- ? step.getContractRead()
116
- : step.contractRead;
117
- case avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE:
118
- return typeof step.getContractWrite === "function"
119
- ? step.getContractWrite()
120
- : step.contractWrite;
121
- case avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE:
122
- return typeof step.getCustomCode === "function"
123
- ? step.getCustomCode()
124
- : step.customCode;
125
- case avs_pb.Execution.Step.OutputDataCase.REST_API:
126
- return typeof step.getRestApi === "function"
127
- ? step.getRestApi()
128
- : step.restApi;
129
- case avs_pb.Execution.Step.OutputDataCase.BRANCH:
130
- return typeof step.getBranch === "function"
131
- ? step.getBranch()
132
- : step.branch;
133
- case avs_pb.Execution.Step.OutputDataCase.FILTER:
134
- return typeof step.getFilter === "function"
135
- ? step.getFilter()
136
- : step.filter;
137
- case avs_pb.Execution.Step.OutputDataCase.LOOP:
138
- return typeof step.getLoop === "function"
139
- ? step.getLoop()
140
- : step.loop;
141
- case avs_pb.Execution.Step.OutputDataCase.BALANCE:
142
- return typeof step.getBalance === "function"
143
- ? step.getBalance()
144
- : step.balance;
145
- default:
146
- return null;
147
- }
148
- }
149
- static getOutputDataCase(step) {
150
- if (typeof step.getOutputDataCase === "function") {
151
- return step.getOutputDataCase();
152
- }
153
- // For plain objects, determine the case by checking which properties exist
154
- const stepObj = step;
155
- if (stepObj.blockTrigger)
156
- return avs_pb.Execution.Step.OutputDataCase.BLOCK_TRIGGER;
157
- if (stepObj.fixedTimeTrigger)
158
- return avs_pb.Execution.Step.OutputDataCase.FIXED_TIME_TRIGGER;
159
- if (stepObj.cronTrigger)
160
- return avs_pb.Execution.Step.OutputDataCase.CRON_TRIGGER;
161
- if (stepObj.eventTrigger)
162
- return avs_pb.Execution.Step.OutputDataCase.EVENT_TRIGGER;
163
- if (stepObj.manualTrigger)
164
- return avs_pb.Execution.Step.OutputDataCase.MANUAL_TRIGGER;
165
- if (stepObj.ethTransfer)
166
- return avs_pb.Execution.Step.OutputDataCase.ETH_TRANSFER;
167
- if (stepObj.graphql)
168
- return avs_pb.Execution.Step.OutputDataCase.GRAPHQL;
169
- if (stepObj.contractRead)
170
- return avs_pb.Execution.Step.OutputDataCase.CONTRACT_READ;
171
- if (stepObj.contractWrite)
172
- return avs_pb.Execution.Step.OutputDataCase.CONTRACT_WRITE;
173
- if (stepObj.customCode)
174
- return avs_pb.Execution.Step.OutputDataCase.CUSTOM_CODE;
175
- if (stepObj.restApi)
176
- return avs_pb.Execution.Step.OutputDataCase.REST_API;
177
- if (stepObj.branch)
178
- return avs_pb.Execution.Step.OutputDataCase.BRANCH;
179
- if (stepObj.filter)
180
- return avs_pb.Execution.Step.OutputDataCase.FILTER;
181
- if (stepObj.loop)
182
- return avs_pb.Execution.Step.OutputDataCase.LOOP;
183
- if (stepObj.balance)
184
- return avs_pb.Execution.Step.OutputDataCase.BALANCE;
185
- return avs_pb.Execution.Step.OutputDataCase.OUTPUT_DATA_NOT_SET;
186
- }
187
- static fromResponse(step) {
188
- // Extract input data if present - USE PROPER PROTOBUF GETTER
189
- let configData = undefined;
190
- // Check for input using proper protobuf methods
191
- if (typeof step.hasConfig === "function" &&
192
- step.hasConfig()) {
193
- const configValue = step.getConfig();
194
- if (configValue) {
195
- // If it's a protobuf Value instance, convert it
196
- try {
197
- configData = convertProtobufValueToJs(configValue);
198
- }
199
- catch (error) {
200
- console.warn("Failed to convert protobuf input value:", error);
201
- // Fallback: if conversion fails, use the raw value
202
- configData = configValue;
203
- }
204
- }
205
- }
206
- // Handle method calls safely for both protobuf instances and plain objects
207
- const getId = () => typeof step.getId === "function" ? step.getId() : step.id;
208
- const getType = () => typeof step.getType === "function" ? step.getType() : step.type;
209
- const getName = () => typeof step.getName === "function" ? step.getName() : step.name;
210
- const getSuccess = () => typeof step.getSuccess === "function"
211
- ? step.getSuccess()
212
- : step.success;
213
- const getError = () => typeof step.getError === "function"
214
- ? step.getError()
215
- : step.error;
216
- const getErrorCode = () => typeof step.getErrorCode === "function"
217
- ? step.getErrorCode()
218
- : step.errorCode;
219
- const getLog = () => typeof step.getLog === "function" ? step.getLog() : step.log;
220
- const getInputsList = () => typeof step.getInputsList === "function"
221
- ? step.getInputsList()
222
- : step.inputsList || [];
223
- const getStartAt = () => typeof step.getStartAt === "function"
224
- ? step.getStartAt()
225
- : step.startAt;
226
- const getEndAt = () => typeof step.getEndAt === "function"
227
- ? step.getEndAt()
228
- : step.endAt;
229
- const getGasUsed = () => typeof step.getGasUsed === "function"
230
- ? step.getGasUsed()
231
- : step.gasUsed;
232
- const getGasPrice = () => typeof step.getGasPrice === "function"
233
- ? step.getGasPrice()
234
- : step.gasPrice;
235
- const getTotalGasCost = () => typeof step.getTotalGasCost === "function"
236
- ? step.getTotalGasCost()
237
- : step.totalGasCost;
238
- // Extract step-level metadata if present (per protobuf: Execution.Step.metadata)
239
- let stepMetadata = undefined;
240
- if (typeof step.getMetadata === "function" &&
241
- step.getMetadata()) {
242
- try {
243
- stepMetadata = convertProtobufValueToJs(step.getMetadata());
244
- }
245
- catch (e) {
246
- stepMetadata = step.getMetadata();
247
- }
248
- }
249
- else if (step.metadata) {
250
- stepMetadata = step.metadata;
251
- }
252
- // Extract executionContext if present on the step
253
- let executionContext = undefined;
254
- if (typeof step.getExecutionContext === "function" &&
255
- step.getExecutionContext()) {
256
- try {
257
- executionContext = convertProtobufValueToJs(step.getExecutionContext());
258
- }
259
- catch (e) {
260
- executionContext = step.getExecutionContext();
261
- }
262
- }
263
- else if (step.executionContext) {
264
- executionContext = step.executionContext;
265
- }
266
- return new Step({
267
- id: getId(),
268
- type: convertProtobufStepTypeToSdk(getType()),
269
- name: getName(),
270
- success: getSuccess(),
271
- error: getError(),
272
- errorCode: getErrorCode(),
273
- log: getLog(),
274
- inputsList: getInputsList(),
275
- config: configData,
276
- output: Step.getOutput(step),
277
- startAt: getStartAt(),
278
- endAt: getEndAt(),
279
- metadata: stepMetadata,
280
- executionContext,
281
- gasUsed: getGasUsed() || undefined,
282
- gasPrice: getGasPrice() || undefined,
283
- totalGasCost: getTotalGasCost() || undefined,
284
- });
285
- }
286
- }
287
- export default Step;
@@ -1,21 +0,0 @@
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 +0,0 @@
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,81 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import Trigger from "./interface";
3
- import { TriggerType } from "@avaprotocol/types";
4
- class BlockTrigger extends Trigger {
5
- constructor(props) {
6
- super({
7
- ...props,
8
- type: TriggerType.Block,
9
- });
10
- }
11
- toRequest() {
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();
18
- const blockData = this.data;
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
24
- if (blockData.interval === null || blockData.interval === undefined) {
25
- throw new Error("Interval is required for block trigger");
26
- }
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)
32
- if (!Number.isInteger(blockData.interval)) {
33
- throw new Error(`BlockTrigger interval must be an integer, got: ${blockData.interval}`);
34
- }
35
- config.setInterval(blockData.interval);
36
- blockTrigger.setConfig(config);
37
- trigger.setBlock(blockTrigger);
38
- return trigger;
39
- }
40
- static fromResponse(raw) {
41
- const obj = raw.toObject();
42
- let data = { interval: 0 };
43
- if (raw.getBlock() && raw.getBlock().hasConfig()) {
44
- const config = raw.getBlock().getConfig();
45
- data = {
46
- interval: config.getInterval(),
47
- };
48
- }
49
- return new BlockTrigger({
50
- id: obj.id,
51
- name: obj.name,
52
- type: obj.type,
53
- data: data,
54
- });
55
- }
56
- /**
57
- * Convert the output to the expected format
58
- * @returns {BlockTriggerOutput | undefined} - The converted data
59
- */
60
- getOutput() {
61
- return this.output;
62
- }
63
- /**
64
- * Extract output data from RunTriggerResp for block triggers
65
- * @param outputData - The RunTriggerResp containing block trigger output
66
- * @returns Plain JavaScript object with block trigger data
67
- */
68
- static fromOutputData(outputData) {
69
- const blockOutput = outputData.getBlockTrigger();
70
- if (!blockOutput)
71
- return null;
72
- // Extract data from the new data field
73
- const dataValue = blockOutput.getData();
74
- if (!dataValue)
75
- return null;
76
- // Convert the Value to JavaScript object
77
- const result = dataValue.toJavaScript();
78
- return result;
79
- }
80
- }
81
- export default BlockTrigger;
@@ -1,23 +0,0 @@
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 +0,0 @@
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,77 +0,0 @@
1
- import * as avs_pb from "@/grpc_codegen/avs_pb";
2
- import Trigger from "./interface";
3
- import { TriggerType } from "@avaprotocol/types";
4
- class CronTrigger extends Trigger {
5
- constructor(props) {
6
- super({
7
- ...props,
8
- type: TriggerType.Cron,
9
- });
10
- }
11
- toRequest() {
12
- const request = new avs_pb.TaskTrigger();
13
- request.setId(this.id);
14
- request.setName(this.name);
15
- request.setType(avs_pb.TriggerType.TRIGGER_TYPE_CRON);
16
- if (!this.data) {
17
- throw new Error(`Trigger data is missing for ${this.type}`);
18
- }
19
- const cronData = this.data;
20
- // Validate schedules is present and not null/undefined
21
- if (!cronData.schedules || !Array.isArray(cronData.schedules)) {
22
- throw new Error("Schedules are required for cron trigger");
23
- }
24
- // Validate schedules array is not empty
25
- if (cronData.schedules.length === 0) {
26
- throw new Error("Schedules are required for cron trigger");
27
- }
28
- const config = new avs_pb.CronTrigger.Config();
29
- config.setSchedulesList(cronData.schedules);
30
- const cronTrigger = new avs_pb.CronTrigger();
31
- cronTrigger.setConfig(config);
32
- request.setCron(cronTrigger);
33
- return request;
34
- }
35
- static fromResponse(raw) {
36
- const obj = raw.toObject();
37
- let data = { schedules: [] };
38
- if (raw.getCron() && raw.getCron().hasConfig()) {
39
- const config = raw.getCron().getConfig();
40
- data = {
41
- schedules: config.getSchedulesList(),
42
- };
43
- }
44
- return new CronTrigger({
45
- ...obj,
46
- type: TriggerType.Cron,
47
- data: data,
48
- });
49
- }
50
- /**
51
- * Convert raw data from runNodeWithInputs response to CronOutput format
52
- * @param rawData - The raw data from the gRPC response
53
- * @returns {CronTriggerOutput | undefined} - The converted data
54
- */
55
- getOutput() {
56
- return this.output;
57
- }
58
- /**
59
- * Extract output data from RunTriggerResp for cron triggers
60
- * Updated to handle timestamp and timestamp_iso instead of epoch
61
- * @param outputData - The RunTriggerResp containing cron trigger output
62
- * @returns Plain JavaScript object with cron trigger data
63
- */
64
- static fromOutputData(outputData) {
65
- const cronOutput = outputData.getCronTrigger();
66
- if (!cronOutput)
67
- return null;
68
- // Extract data from the new data field
69
- const dataValue = cronOutput.getData();
70
- if (!dataValue)
71
- return null;
72
- // Convert the Value to JavaScript object
73
- const result = dataValue.toJavaScript();
74
- return result;
75
- }
76
- }
77
- export default CronTrigger;
@@ -1,22 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/models/trigger/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAIlB,MAAM,oBAAoB,CAAC;AA0C5B,cAAM,YAAa,SAAQ,OAAO;gBACpB,KAAK,EAAE,iBAAiB;IAIpC,SAAS,IAAI,MAAM,CAAC,WAAW;IAqH/B,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,GAAG,YAAY;IA0F1D;;;;OAIG;IACH,SAAS,IAAI,kBAAkB,GAAG,SAAS;IAI3C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,GAAG,GAAG;CA0B9D;AAED,eAAe,YAAY,CAAC"}