@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.
- package/CHANGELOG.md +20 -0
- package/README.md +11 -1
- package/dist/index.d.ts +1 -370
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +856 -22369
- package/dist/index.mjs +820 -22402
- package/dist/v4/auth.d.ts +79 -0
- package/dist/v4/auth.d.ts.map +1 -0
- package/dist/v4/auth.js +92 -0
- package/dist/v4/builders/nodes.d.ts +106 -0
- package/dist/v4/builders/nodes.d.ts.map +1 -0
- package/dist/v4/builders/nodes.js +133 -0
- package/dist/v4/builders/triggers.d.ts +66 -0
- package/dist/v4/builders/triggers.d.ts.map +1 -0
- package/dist/v4/builders/triggers.js +74 -0
- package/dist/v4/chains.d.ts +19 -0
- package/dist/v4/chains.d.ts.map +1 -0
- package/dist/v4/chains.js +22 -0
- package/dist/v4/client.d.ts +60 -0
- package/dist/v4/client.d.ts.map +1 -0
- package/dist/v4/client.js +53 -0
- package/dist/v4/index.d.ts +19 -0
- package/dist/v4/index.d.ts.map +1 -0
- package/dist/v4/index.js +24 -0
- package/dist/v4/internal/errors.d.ts +36 -0
- package/dist/v4/internal/errors.d.ts.map +1 -0
- package/dist/v4/internal/errors.js +32 -0
- package/dist/v4/internal/transport.d.ts +64 -0
- package/dist/v4/internal/transport.d.ts.map +1 -0
- package/dist/v4/internal/transport.js +133 -0
- package/dist/v4/protocols/index.d.ts +2 -0
- package/dist/v4/protocols/index.d.ts.map +1 -0
- package/dist/v4/protocols/index.js +13 -0
- package/dist/v4/resources/auth.d.ts +45 -0
- package/dist/v4/resources/auth.d.ts.map +1 -0
- package/dist/v4/resources/auth.js +59 -0
- package/dist/v4/resources/executions.d.ts +74 -0
- package/dist/v4/resources/executions.d.ts.map +1 -0
- package/dist/v4/resources/executions.js +132 -0
- package/dist/v4/resources/health.d.ts +19 -0
- package/dist/v4/resources/health.d.ts.map +1 -0
- package/dist/v4/resources/health.js +19 -0
- package/dist/v4/resources/nodes.d.ts +29 -0
- package/dist/v4/resources/nodes.d.ts.map +1 -0
- package/dist/v4/resources/nodes.js +33 -0
- package/dist/v4/resources/operators.d.ts +23 -0
- package/dist/v4/resources/operators.d.ts.map +1 -0
- package/dist/v4/resources/operators.js +23 -0
- package/dist/v4/resources/secrets.d.ts +34 -0
- package/dist/v4/resources/secrets.d.ts.map +1 -0
- package/dist/v4/resources/secrets.js +38 -0
- package/dist/v4/resources/tokens.d.ts +28 -0
- package/dist/v4/resources/tokens.d.ts.map +1 -0
- package/dist/v4/resources/tokens.js +29 -0
- package/dist/v4/resources/triggers.d.ts +29 -0
- package/dist/v4/resources/triggers.d.ts.map +1 -0
- package/dist/v4/resources/triggers.js +33 -0
- package/dist/v4/resources/wallets.d.ts +72 -0
- package/dist/v4/resources/wallets.d.ts.map +1 -0
- package/dist/v4/resources/wallets.js +92 -0
- package/dist/v4/resources/workflows.d.ts +64 -0
- package/dist/v4/resources/workflows.d.ts.map +1 -0
- package/dist/v4/resources/workflows.js +91 -0
- package/package.json +9 -11
- package/dist/auth.d.ts +0 -2
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -10
- package/dist/config.d.ts +0 -9
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -19
- package/dist/models/edge.d.ts +0 -12
- package/dist/models/edge.d.ts.map +0 -1
- package/dist/models/edge.js +0 -19
- package/dist/models/execution.d.ts +0 -30
- package/dist/models/execution.d.ts.map +0 -1
- package/dist/models/execution.js +0 -100
- package/dist/models/node/balance.d.ts +0 -17
- package/dist/models/node/balance.d.ts.map +0 -1
- package/dist/models/node/balance.js +0 -78
- package/dist/models/node/branch.d.ts +0 -11
- package/dist/models/node/branch.d.ts.map +0 -1
- package/dist/models/node/branch.js +0 -63
- package/dist/models/node/contractRead.d.ts +0 -17
- package/dist/models/node/contractRead.d.ts.map +0 -1
- package/dist/models/node/contractRead.js +0 -91
- package/dist/models/node/contractWrite.d.ts +0 -17
- package/dist/models/node/contractWrite.d.ts.map +0 -1
- package/dist/models/node/contractWrite.js +0 -102
- package/dist/models/node/customCode.d.ts +0 -20
- package/dist/models/node/customCode.d.ts.map +0 -1
- package/dist/models/node/customCode.js +0 -74
- package/dist/models/node/ethTransfer.d.ts +0 -20
- package/dist/models/node/ethTransfer.d.ts.map +0 -1
- package/dist/models/node/ethTransfer.js +0 -58
- package/dist/models/node/factory.d.ts +0 -24
- package/dist/models/node/factory.d.ts.map +0 -1
- package/dist/models/node/factory.js +0 -108
- package/dist/models/node/filter.d.ts +0 -11
- package/dist/models/node/filter.d.ts.map +0 -1
- package/dist/models/node/filter.js +0 -57
- package/dist/models/node/graphqlQuery.d.ts +0 -21
- package/dist/models/node/graphqlQuery.d.ts.map +0 -1
- package/dist/models/node/graphqlQuery.js +0 -74
- package/dist/models/node/interface.d.ts +0 -20
- package/dist/models/node/interface.d.ts.map +0 -1
- package/dist/models/node/interface.js +0 -58
- package/dist/models/node/loop.d.ts +0 -15
- package/dist/models/node/loop.d.ts.map +0 -1
- package/dist/models/node/loop.js +0 -235
- package/dist/models/node/restApi.d.ts +0 -23
- package/dist/models/node/restApi.d.ts.map +0 -1
- package/dist/models/node/restApi.js +0 -84
- package/dist/models/secret.d.ts +0 -16
- package/dist/models/secret.d.ts.map +0 -1
- package/dist/models/secret.js +0 -28
- package/dist/models/step.d.ts +0 -33
- package/dist/models/step.d.ts.map +0 -1
- package/dist/models/step.js +0 -287
- package/dist/models/trigger/block.d.ts +0 -21
- package/dist/models/trigger/block.d.ts.map +0 -1
- package/dist/models/trigger/block.js +0 -81
- package/dist/models/trigger/cron.d.ts +0 -23
- package/dist/models/trigger/cron.d.ts.map +0 -1
- package/dist/models/trigger/cron.js +0 -77
- package/dist/models/trigger/event.d.ts +0 -22
- package/dist/models/trigger/event.d.ts.map +0 -1
- package/dist/models/trigger/event.js +0 -244
- package/dist/models/trigger/factory.d.ts +0 -27
- package/dist/models/trigger/factory.d.ts.map +0 -1
- package/dist/models/trigger/factory.js +0 -73
- package/dist/models/trigger/fixedTime.d.ts +0 -23
- package/dist/models/trigger/fixedTime.d.ts.map +0 -1
- package/dist/models/trigger/fixedTime.js +0 -69
- package/dist/models/trigger/interface.d.ts +0 -19
- package/dist/models/trigger/interface.d.ts.map +0 -1
- package/dist/models/trigger/interface.js +0 -35
- package/dist/models/trigger/manual.d.ts +0 -16
- package/dist/models/trigger/manual.d.ts.map +0 -1
- package/dist/models/trigger/manual.js +0 -117
- package/dist/models/workflow.d.ts +0 -53
- package/dist/models/workflow.d.ts.map +0 -1
- package/dist/models/workflow.js +0 -219
- package/dist/utils.d.ts +0 -82
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -286
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
2
|
-
import Node from "./node/interface";
|
|
3
|
-
import Edge from "./edge";
|
|
4
|
-
import Trigger from "./trigger/interface";
|
|
5
|
-
/**
|
|
6
|
-
* Default value for workflow expiration. A value of 0 or negative means the
|
|
7
|
-
* workflow never expires. The backend only enforces expiration when
|
|
8
|
-
* `expiredAt > 0` (interpreted as a Unix timestamp in milliseconds).
|
|
9
|
-
*/
|
|
10
|
-
export declare const DefaultExpiredAt = 0;
|
|
11
|
-
import { WorkflowStatus, WorkflowProps, InputVariables } from "@avaprotocol/types";
|
|
12
|
-
export declare function convertStatusToString(status: avs_pb.TaskStatus): WorkflowStatus;
|
|
13
|
-
declare class Workflow implements WorkflowProps {
|
|
14
|
-
smartWalletAddress: string;
|
|
15
|
-
trigger: Trigger;
|
|
16
|
-
nodes: Node[];
|
|
17
|
-
edges: Edge[];
|
|
18
|
-
startAt: number;
|
|
19
|
-
expiredAt: number;
|
|
20
|
-
maxExecution: number;
|
|
21
|
-
name: string;
|
|
22
|
-
id?: string;
|
|
23
|
-
owner?: string;
|
|
24
|
-
completedAt?: number;
|
|
25
|
-
status?: WorkflowStatus;
|
|
26
|
-
lastRanAt?: number;
|
|
27
|
-
executionCount?: number;
|
|
28
|
-
inputVariables?: InputVariables;
|
|
29
|
-
/**
|
|
30
|
-
* Create an instance of Workflow from user inputs
|
|
31
|
-
* @param props
|
|
32
|
-
*/
|
|
33
|
-
constructor(props: WorkflowProps);
|
|
34
|
-
/**
|
|
35
|
-
* Create an instance of Workflow from AVS getWorkflow response
|
|
36
|
-
* @param res
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
static fromResponse(obj: avs_pb.Task): Workflow;
|
|
40
|
-
/**
|
|
41
|
-
* Create an instance of Workflow with only selected fields
|
|
42
|
-
* @param obj
|
|
43
|
-
*/
|
|
44
|
-
static fromListResponse(obj: avs_pb.Task): Workflow;
|
|
45
|
-
toRequest(): avs_pb.CreateTaskReq;
|
|
46
|
-
/**
|
|
47
|
-
* Convert Workflow instance to plain object (WorkflowProps)
|
|
48
|
-
* This is useful for serialization, especially with Next.js Server Components
|
|
49
|
-
*/
|
|
50
|
-
toJson(): WorkflowProps;
|
|
51
|
-
}
|
|
52
|
-
export default Workflow;
|
|
53
|
-
//# sourceMappingURL=workflow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/models/workflow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAG1C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAInF,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,UAAU,GACxB,cAAc,CAgBhB;AAED,cAAM,QAAS,YAAW,aAAa;IACrC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAGrB,IAAI,EAAE,MAAM,CAAC;IAGb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;OAGG;gBACS,KAAK,EAAE,aAAa;IA2BhC;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IA4C/C;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ;IAmCnD,SAAS,IAAI,MAAM,CAAC,aAAa;IAsEjC;;;OAGG;IACH,MAAM,IAAI,aAAa;CAmBxB;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/models/workflow.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import _ from "lodash";
|
|
2
|
-
import * as avs_pb from "@/grpc_codegen/avs_pb";
|
|
3
|
-
import Edge from "./edge";
|
|
4
|
-
import TriggerFactory from "./trigger/factory";
|
|
5
|
-
import NodeFactory from "./node/factory";
|
|
6
|
-
/**
|
|
7
|
-
* Default value for workflow expiration. A value of 0 or negative means the
|
|
8
|
-
* workflow never expires. The backend only enforces expiration when
|
|
9
|
-
* `expiredAt > 0` (interpreted as a Unix timestamp in milliseconds).
|
|
10
|
-
*/
|
|
11
|
-
export const DefaultExpiredAt = 0;
|
|
12
|
-
import { WorkflowStatus } from "@avaprotocol/types";
|
|
13
|
-
import { convertJSValueToProtobuf } from "../utils";
|
|
14
|
-
// Function to convert TaskStatus to string
|
|
15
|
-
export function convertStatusToString(status) {
|
|
16
|
-
switch (status) {
|
|
17
|
-
case avs_pb.TaskStatus.ENABLED:
|
|
18
|
-
return WorkflowStatus.Enabled;
|
|
19
|
-
case avs_pb.TaskStatus.COMPLETED:
|
|
20
|
-
return WorkflowStatus.Completed;
|
|
21
|
-
case avs_pb.TaskStatus.FAILED:
|
|
22
|
-
return WorkflowStatus.Failed;
|
|
23
|
-
case avs_pb.TaskStatus.RUNNING:
|
|
24
|
-
return WorkflowStatus.Running;
|
|
25
|
-
case avs_pb.TaskStatus.DISABLED:
|
|
26
|
-
return WorkflowStatus.Disabled;
|
|
27
|
-
default: {
|
|
28
|
-
throw new Error(`Unknown TaskStatus: ${status}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
class Workflow {
|
|
33
|
-
/**
|
|
34
|
-
* Create an instance of Workflow from user inputs
|
|
35
|
-
* @param props
|
|
36
|
-
*/
|
|
37
|
-
constructor(props) {
|
|
38
|
-
if (!props.trigger) {
|
|
39
|
-
throw new Error("Trigger is undefined in new Workflow()");
|
|
40
|
-
}
|
|
41
|
-
if (!props.name) {
|
|
42
|
-
throw new Error("name is required in new Workflow()");
|
|
43
|
-
}
|
|
44
|
-
this.smartWalletAddress = props.smartWalletAddress;
|
|
45
|
-
this.name = props.name;
|
|
46
|
-
this.trigger = props.trigger;
|
|
47
|
-
this.nodes = props.nodes;
|
|
48
|
-
this.edges = props.edges;
|
|
49
|
-
this.startAt = props.startAt;
|
|
50
|
-
this.expiredAt = props.expiredAt;
|
|
51
|
-
this.maxExecution = props.maxExecution;
|
|
52
|
-
this.executionCount = props.executionCount;
|
|
53
|
-
// Optional fields
|
|
54
|
-
this.id = props.id;
|
|
55
|
-
this.owner = props.owner;
|
|
56
|
-
this.status = props.status;
|
|
57
|
-
this.completedAt = props.completedAt;
|
|
58
|
-
this.lastRanAt = props.lastRanAt;
|
|
59
|
-
this.inputVariables = props.inputVariables;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Create an instance of Workflow from AVS getWorkflow response
|
|
63
|
-
* @param res
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
static fromResponse(obj) {
|
|
67
|
-
const trigger = TriggerFactory.fromResponse(obj.getTrigger());
|
|
68
|
-
if (!trigger) {
|
|
69
|
-
throw new Error("Trigger is undefined in fromResponse()");
|
|
70
|
-
}
|
|
71
|
-
const nodes = _.map(obj.getNodesList(), (node) => NodeFactory.fromResponse(node));
|
|
72
|
-
const edges = _.map(obj.getEdgesList(), (edge) => Edge.fromResponse(edge));
|
|
73
|
-
// Convert inputVariables from protobuf map back to JavaScript object
|
|
74
|
-
const inputVariables = {};
|
|
75
|
-
const inputVarsMap = obj.getInputVariablesMap();
|
|
76
|
-
if (inputVarsMap && inputVarsMap.getLength() > 0) {
|
|
77
|
-
inputVarsMap.forEach((value, key) => {
|
|
78
|
-
inputVariables[key] = value.toJavaScript();
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
const workflow = new Workflow({
|
|
82
|
-
id: obj.getId(),
|
|
83
|
-
owner: obj.getOwner(),
|
|
84
|
-
smartWalletAddress: obj.getSmartWalletAddress(),
|
|
85
|
-
trigger,
|
|
86
|
-
nodes,
|
|
87
|
-
edges,
|
|
88
|
-
startAt: obj.getStartAt(),
|
|
89
|
-
expiredAt: obj.getExpiredAt(),
|
|
90
|
-
maxExecution: obj.getMaxExecution(),
|
|
91
|
-
executionCount: obj.getExecutionCount(),
|
|
92
|
-
name: obj.getName(),
|
|
93
|
-
status: convertStatusToString(obj.getStatus()),
|
|
94
|
-
completedAt: obj.getCompletedAt(),
|
|
95
|
-
lastRanAt: obj.getLastRanAt(),
|
|
96
|
-
inputVariables: Object.keys(inputVariables).length > 0 ? inputVariables : undefined,
|
|
97
|
-
});
|
|
98
|
-
return workflow;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Create an instance of Workflow with only selected fields
|
|
102
|
-
* @param obj
|
|
103
|
-
*/
|
|
104
|
-
static fromListResponse(obj) {
|
|
105
|
-
const trigger = TriggerFactory.fromResponse(obj.getTrigger());
|
|
106
|
-
if (!trigger) {
|
|
107
|
-
throw new Error("Trigger is undefined in fromListResponse()");
|
|
108
|
-
}
|
|
109
|
-
// Convert inputVariables from protobuf map back to JavaScript object
|
|
110
|
-
const inputVariables = {};
|
|
111
|
-
const inputVarsMap = obj.getInputVariablesMap();
|
|
112
|
-
if (inputVarsMap && inputVarsMap.getLength() > 0) {
|
|
113
|
-
inputVarsMap.forEach((value, key) => {
|
|
114
|
-
inputVariables[key] = value.toJavaScript();
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
return new Workflow({
|
|
118
|
-
id: obj.getId(),
|
|
119
|
-
owner: obj.getOwner(),
|
|
120
|
-
smartWalletAddress: obj.getSmartWalletAddress(),
|
|
121
|
-
trigger: trigger,
|
|
122
|
-
startAt: obj.getStartAt(),
|
|
123
|
-
expiredAt: obj.getExpiredAt(),
|
|
124
|
-
maxExecution: obj.getMaxExecution(),
|
|
125
|
-
executionCount: obj.getExecutionCount(),
|
|
126
|
-
nodes: _.map(obj.getNodesList(), (node) => NodeFactory.fromResponse(node)),
|
|
127
|
-
edges: _.map(obj.getEdgesList(), (edge) => Edge.fromResponse(edge)),
|
|
128
|
-
completedAt: obj.getCompletedAt(),
|
|
129
|
-
status: convertStatusToString(obj.getStatus()),
|
|
130
|
-
name: obj.getName(),
|
|
131
|
-
lastRanAt: obj.getLastRanAt(),
|
|
132
|
-
inputVariables: Object.keys(inputVariables).length > 0 ? inputVariables : undefined,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
toRequest() {
|
|
136
|
-
const request = new avs_pb.CreateTaskReq();
|
|
137
|
-
request.setTrigger(this.trigger.toRequest());
|
|
138
|
-
// Add error handling for node serialization
|
|
139
|
-
try {
|
|
140
|
-
_.map(this.nodes, (node, index) => {
|
|
141
|
-
try {
|
|
142
|
-
const nodeRequest = node.toRequest();
|
|
143
|
-
request.addNodes(nodeRequest);
|
|
144
|
-
}
|
|
145
|
-
catch (nodeError) {
|
|
146
|
-
console.error(`🚨 Node ${index} (${node.name}) serialization failed:`, nodeError);
|
|
147
|
-
const errorMessage = nodeError instanceof Error ? nodeError.message : String(nodeError);
|
|
148
|
-
throw new Error(`Node serialization failed: ${node.name} - ${errorMessage}`);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
catch (nodesError) {
|
|
153
|
-
console.error('🚨 Nodes serialization failed:', nodesError);
|
|
154
|
-
throw nodesError;
|
|
155
|
-
}
|
|
156
|
-
// Add error handling for edge serialization
|
|
157
|
-
try {
|
|
158
|
-
_.map(this.edges, (edge, index) => {
|
|
159
|
-
try {
|
|
160
|
-
const edgeRequest = edge.toRequest();
|
|
161
|
-
request.addEdges(edgeRequest);
|
|
162
|
-
}
|
|
163
|
-
catch (edgeError) {
|
|
164
|
-
console.error(`🚨 Edge ${index} serialization failed:`, edgeError);
|
|
165
|
-
const errorMessage = edgeError instanceof Error ? edgeError.message : String(edgeError);
|
|
166
|
-
throw new Error(`Edge serialization failed: ${edge.id} - ${errorMessage}`);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
catch (edgesError) {
|
|
171
|
-
console.error('🚨 Edges serialization failed:', edgesError);
|
|
172
|
-
throw edgesError;
|
|
173
|
-
}
|
|
174
|
-
request.setStartAt(this.startAt);
|
|
175
|
-
request.setExpiredAt(this.expiredAt);
|
|
176
|
-
request.setMaxExecution(this.maxExecution);
|
|
177
|
-
// Validate inputVariables.settings before sending to aggregator.
|
|
178
|
-
// The aggregator requires settings.name and settings.runner.
|
|
179
|
-
if (!this.inputVariables?.settings) {
|
|
180
|
-
throw new Error("inputVariables.settings is required. Must include at least { name, runner }.");
|
|
181
|
-
}
|
|
182
|
-
const settings = this.inputVariables.settings;
|
|
183
|
-
if (!settings.name || typeof settings.name !== "string" || !settings.name.trim()) {
|
|
184
|
-
throw new Error("inputVariables.settings.name is required and must be a non-empty string.");
|
|
185
|
-
}
|
|
186
|
-
if (!settings.runner || typeof settings.runner !== "string" || !settings.runner.trim()) {
|
|
187
|
-
throw new Error("inputVariables.settings.runner is required and must be a non-empty string (smart wallet address).");
|
|
188
|
-
}
|
|
189
|
-
const inputVarsMap = request.getInputVariablesMap();
|
|
190
|
-
for (const [key, value] of Object.entries(this.inputVariables)) {
|
|
191
|
-
inputVarsMap.set(key, convertJSValueToProtobuf(value));
|
|
192
|
-
}
|
|
193
|
-
return request;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Convert Workflow instance to plain object (WorkflowProps)
|
|
197
|
-
* This is useful for serialization, especially with Next.js Server Components
|
|
198
|
-
*/
|
|
199
|
-
toJson() {
|
|
200
|
-
return {
|
|
201
|
-
id: this.id,
|
|
202
|
-
owner: this.owner,
|
|
203
|
-
smartWalletAddress: this.smartWalletAddress,
|
|
204
|
-
trigger: this.trigger.toJson(),
|
|
205
|
-
nodes: this.nodes,
|
|
206
|
-
edges: this.edges,
|
|
207
|
-
startAt: this.startAt,
|
|
208
|
-
expiredAt: this.expiredAt,
|
|
209
|
-
maxExecution: this.maxExecution,
|
|
210
|
-
executionCount: this.executionCount,
|
|
211
|
-
name: this.name,
|
|
212
|
-
status: this.status,
|
|
213
|
-
completedAt: this.completedAt,
|
|
214
|
-
lastRanAt: this.lastRanAt,
|
|
215
|
-
inputVariables: this.inputVariables,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
export default Workflow;
|
package/dist/utils.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Value as ProtobufValue } from "google-protobuf/google/protobuf/struct_pb";
|
|
2
|
-
/**
|
|
3
|
-
* Convert a protobuf Value to a JavaScript value
|
|
4
|
-
*
|
|
5
|
-
* **🏆 RECOMMENDED for modern protobuf usage**
|
|
6
|
-
*
|
|
7
|
-
* This is the primary implementation using proper TypeScript types and getKindCase()
|
|
8
|
-
* for the latest protobuf libraries. Use this for all new code.
|
|
9
|
-
*
|
|
10
|
-
* @param value - The protobuf Value to convert
|
|
11
|
-
* @returns The converted JavaScript value
|
|
12
|
-
*/
|
|
13
|
-
export declare function convertProtobufValueToJs(value?: ProtobufValue): any;
|
|
14
|
-
/**
|
|
15
|
-
* Convert a JavaScript value to a protobuf Value
|
|
16
|
-
*
|
|
17
|
-
* Uses proper TypeScript types for modern protobuf usage.
|
|
18
|
-
*
|
|
19
|
-
* @param value - The JavaScript value to convert
|
|
20
|
-
* @returns The protobuf Value object
|
|
21
|
-
*/
|
|
22
|
-
export declare function convertJSValueToProtobuf(value: any): ProtobufValue;
|
|
23
|
-
/**
|
|
24
|
-
* Recursively convert object keys from snake_case to camelCase.
|
|
25
|
-
* Leaves non-objects and arrays intact (arrays are mapped over).
|
|
26
|
-
*/
|
|
27
|
-
export declare function toCamelCaseKeys<T = any>(input: any): T;
|
|
28
|
-
/**
|
|
29
|
-
* Recursively convert object keys from camelCase to snake_case.
|
|
30
|
-
* Leaves non-objects and arrays intact (arrays are mapped over).
|
|
31
|
-
*/
|
|
32
|
-
export declare function toSnakeCaseKeys<T = any>(input: any): T;
|
|
33
|
-
/**
|
|
34
|
-
* Convert protobuf trigger type string to SDK trigger type string
|
|
35
|
-
*
|
|
36
|
-
* @param protobufType - The protobuf trigger type string (e.g., "TRIGGER_TYPE_MANUAL")
|
|
37
|
-
* @returns The SDK trigger type string (e.g., "manualTrigger")
|
|
38
|
-
*/
|
|
39
|
-
export declare function convertProtobufTriggerTypeToSdk(protobufType: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* Convert protobuf node type string to SDK node type string
|
|
42
|
-
*
|
|
43
|
-
* @param protobufType - The protobuf node type string (e.g., "NODE_TYPE_CUSTOM_CODE")
|
|
44
|
-
* @returns The SDK node type string (e.g., "customCode")
|
|
45
|
-
*/
|
|
46
|
-
export declare function convertProtobufNodeTypeToSdk(protobufType: string): string;
|
|
47
|
-
/**
|
|
48
|
-
* Convert protobuf step type string to SDK step type string
|
|
49
|
-
*
|
|
50
|
-
* Automatically detects whether the type is a trigger or node type and converts accordingly.
|
|
51
|
-
*
|
|
52
|
-
* @param protobufType - The protobuf type string (e.g., "TRIGGER_TYPE_MANUAL" or "NODE_TYPE_CUSTOM_CODE")
|
|
53
|
-
* @returns The SDK type string (e.g., "manualTrigger" or "customCode")
|
|
54
|
-
*/
|
|
55
|
-
export declare function convertProtobufStepTypeToSdk(protobufType: string): string;
|
|
56
|
-
/**
|
|
57
|
-
* Convert input field from JavaScript object to protobuf Value format
|
|
58
|
-
*
|
|
59
|
-
* Pure utility function for converting trigger/node input data to protobuf format.
|
|
60
|
-
* Can be used by both triggers and nodes.
|
|
61
|
-
*
|
|
62
|
-
* @param input - JavaScript object with input data, or undefined
|
|
63
|
-
* @returns protobuf Value or undefined if no input
|
|
64
|
-
*/
|
|
65
|
-
export declare function convertInputToProtobuf(input?: Record<string, any>): ProtobufValue | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* Extract input field from protobuf Value format to JavaScript object
|
|
68
|
-
*
|
|
69
|
-
* Pure utility function for extracting trigger/node input data from protobuf format.
|
|
70
|
-
* Can be used by both triggers and nodes.
|
|
71
|
-
*
|
|
72
|
-
* @param inputValue - protobuf Value from response, plain JavaScript object, or undefined
|
|
73
|
-
* @returns JavaScript object or undefined
|
|
74
|
-
*/
|
|
75
|
-
export declare function extractInputFromProtobuf(inputValue?: ProtobufValue | Record<string, any>): Record<string, any> | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Clean up gRPC error messages by extracting the actual message
|
|
78
|
-
* @param message - The raw gRPC error message
|
|
79
|
-
* @returns {string} - The cleaned error message
|
|
80
|
-
*/
|
|
81
|
-
export declare function cleanGrpcErrorMessage(message: string): string;
|
|
82
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CA6BlE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,CAatD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,CAatD;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAkB5E;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA4BzE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CASzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,aAAa,GAAG,SAAS,CAK3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC/C,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAiCjC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsB7D"}
|
package/dist/utils.js
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
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";
|
|
3
|
-
/**
|
|
4
|
-
* Convert a protobuf Value to a JavaScript value
|
|
5
|
-
*
|
|
6
|
-
* **🏆 RECOMMENDED for modern protobuf usage**
|
|
7
|
-
*
|
|
8
|
-
* This is the primary implementation using proper TypeScript types and getKindCase()
|
|
9
|
-
* for the latest protobuf libraries. Use this for all new code.
|
|
10
|
-
*
|
|
11
|
-
* @param value - The protobuf Value to convert
|
|
12
|
-
* @returns The converted JavaScript value
|
|
13
|
-
*/
|
|
14
|
-
export function convertProtobufValueToJs(value) {
|
|
15
|
-
if (!value) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
switch (value.getKindCase()) {
|
|
19
|
-
case ProtobufValue.KindCase.NULL_VALUE:
|
|
20
|
-
return null;
|
|
21
|
-
case ProtobufValue.KindCase.NUMBER_VALUE:
|
|
22
|
-
return value.getNumberValue();
|
|
23
|
-
case ProtobufValue.KindCase.STRING_VALUE:
|
|
24
|
-
return value.getStringValue();
|
|
25
|
-
case ProtobufValue.KindCase.BOOL_VALUE:
|
|
26
|
-
return value.getBoolValue();
|
|
27
|
-
case ProtobufValue.KindCase.STRUCT_VALUE: {
|
|
28
|
-
const struct = value.getStructValue();
|
|
29
|
-
if (!struct)
|
|
30
|
-
return {};
|
|
31
|
-
const jsObj = {};
|
|
32
|
-
const fields = struct.getFieldsMap();
|
|
33
|
-
fields.forEach((val, key) => {
|
|
34
|
-
jsObj[key] = convertProtobufValueToJs(val);
|
|
35
|
-
});
|
|
36
|
-
return jsObj;
|
|
37
|
-
}
|
|
38
|
-
case ProtobufValue.KindCase.LIST_VALUE: {
|
|
39
|
-
const list = value.getListValue();
|
|
40
|
-
if (!list)
|
|
41
|
-
return [];
|
|
42
|
-
return list.getValuesList().map((item) => convertProtobufValueToJs(item));
|
|
43
|
-
}
|
|
44
|
-
case ProtobufValue.KindCase.KIND_NOT_SET:
|
|
45
|
-
default:
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Convert a JavaScript value to a protobuf Value
|
|
51
|
-
*
|
|
52
|
-
* Uses proper TypeScript types for modern protobuf usage.
|
|
53
|
-
*
|
|
54
|
-
* @param value - The JavaScript value to convert
|
|
55
|
-
* @returns The protobuf Value object
|
|
56
|
-
*/
|
|
57
|
-
export function convertJSValueToProtobuf(value) {
|
|
58
|
-
const protobufValue = new ProtobufValue();
|
|
59
|
-
if (value === null || value === undefined) {
|
|
60
|
-
protobufValue.setNullValue(0); // NULL_VALUE = 0
|
|
61
|
-
}
|
|
62
|
-
else if (typeof value === "number") {
|
|
63
|
-
protobufValue.setNumberValue(value);
|
|
64
|
-
}
|
|
65
|
-
else if (typeof value === "string") {
|
|
66
|
-
protobufValue.setStringValue(value);
|
|
67
|
-
}
|
|
68
|
-
else if (typeof value === "boolean") {
|
|
69
|
-
protobufValue.setBoolValue(value);
|
|
70
|
-
}
|
|
71
|
-
else if (Array.isArray(value)) {
|
|
72
|
-
const listValue = new ProtobufListValue();
|
|
73
|
-
const convertedValues = value.map((item) => convertJSValueToProtobuf(item));
|
|
74
|
-
listValue.setValuesList(convertedValues);
|
|
75
|
-
protobufValue.setListValue(listValue);
|
|
76
|
-
}
|
|
77
|
-
else if (typeof value === "object") {
|
|
78
|
-
const structValue = new ProtobufStruct();
|
|
79
|
-
const fieldsMap = structValue.getFieldsMap();
|
|
80
|
-
Object.entries(value).forEach(([key, val]) => {
|
|
81
|
-
fieldsMap.set(key, convertJSValueToProtobuf(val));
|
|
82
|
-
});
|
|
83
|
-
protobufValue.setStructValue(structValue);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// Fallback: convert to string
|
|
87
|
-
protobufValue.setStringValue(String(value));
|
|
88
|
-
}
|
|
89
|
-
return protobufValue;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Recursively convert object keys from snake_case to camelCase.
|
|
93
|
-
* Leaves non-objects and arrays intact (arrays are mapped over).
|
|
94
|
-
*/
|
|
95
|
-
export function toCamelCaseKeys(input) {
|
|
96
|
-
if (input === null || input === undefined)
|
|
97
|
-
return input;
|
|
98
|
-
if (Array.isArray(input)) {
|
|
99
|
-
return input.map((item) => toCamelCaseKeys(item));
|
|
100
|
-
}
|
|
101
|
-
if (typeof input !== "object")
|
|
102
|
-
return input;
|
|
103
|
-
const result = {};
|
|
104
|
-
for (const [key, value] of Object.entries(input)) {
|
|
105
|
-
const camelKey = key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
106
|
-
result[camelKey] = toCamelCaseKeys(value);
|
|
107
|
-
}
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Recursively convert object keys from camelCase to snake_case.
|
|
112
|
-
* Leaves non-objects and arrays intact (arrays are mapped over).
|
|
113
|
-
*/
|
|
114
|
-
export function toSnakeCaseKeys(input) {
|
|
115
|
-
if (input === null || input === undefined)
|
|
116
|
-
return input;
|
|
117
|
-
if (Array.isArray(input)) {
|
|
118
|
-
return input.map((item) => toSnakeCaseKeys(item));
|
|
119
|
-
}
|
|
120
|
-
if (typeof input !== "object")
|
|
121
|
-
return input;
|
|
122
|
-
const result = {};
|
|
123
|
-
for (const [key, value] of Object.entries(input)) {
|
|
124
|
-
const snakeKey = key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
125
|
-
result[snakeKey] = toSnakeCaseKeys(value);
|
|
126
|
-
}
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Convert protobuf trigger type string to SDK trigger type string
|
|
131
|
-
*
|
|
132
|
-
* @param protobufType - The protobuf trigger type string (e.g., "TRIGGER_TYPE_MANUAL")
|
|
133
|
-
* @returns The SDK trigger type string (e.g., "manualTrigger")
|
|
134
|
-
*/
|
|
135
|
-
export function convertProtobufTriggerTypeToSdk(protobufType) {
|
|
136
|
-
switch (protobufType) {
|
|
137
|
-
case "TRIGGER_TYPE_MANUAL":
|
|
138
|
-
return TriggerType.Manual; // "manualTrigger"
|
|
139
|
-
case "TRIGGER_TYPE_FIXED_TIME":
|
|
140
|
-
return TriggerType.FixedTime; // "fixedTimeTrigger"
|
|
141
|
-
case "TRIGGER_TYPE_CRON":
|
|
142
|
-
return TriggerType.Cron; // "cronTrigger"
|
|
143
|
-
case "TRIGGER_TYPE_BLOCK":
|
|
144
|
-
return TriggerType.Block; // "blockTrigger"
|
|
145
|
-
case "TRIGGER_TYPE_EVENT":
|
|
146
|
-
return TriggerType.Event; // "eventTrigger"
|
|
147
|
-
case "TRIGGER_TYPE_UNSPECIFIED":
|
|
148
|
-
return TriggerType.Unspecified; // "unspecified"
|
|
149
|
-
default:
|
|
150
|
-
console.warn(`Unknown trigger type: ${protobufType}, using raw value`);
|
|
151
|
-
return protobufType; // fallback to raw value
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Convert protobuf node type string to SDK node type string
|
|
156
|
-
*
|
|
157
|
-
* @param protobufType - The protobuf node type string (e.g., "NODE_TYPE_CUSTOM_CODE")
|
|
158
|
-
* @returns The SDK node type string (e.g., "customCode")
|
|
159
|
-
*/
|
|
160
|
-
export function convertProtobufNodeTypeToSdk(protobufType) {
|
|
161
|
-
switch (protobufType) {
|
|
162
|
-
case "NODE_TYPE_ETH_TRANSFER":
|
|
163
|
-
return NodeType.ETHTransfer; // "ethTransfer"
|
|
164
|
-
case "NODE_TYPE_CONTRACT_WRITE":
|
|
165
|
-
return NodeType.ContractWrite; // "contractWrite"
|
|
166
|
-
case "NODE_TYPE_CONTRACT_READ":
|
|
167
|
-
return NodeType.ContractRead; // "contractRead"
|
|
168
|
-
case "NODE_TYPE_GRAPHQL_QUERY":
|
|
169
|
-
return NodeType.GraphQLQuery; // "graphql"
|
|
170
|
-
case "NODE_TYPE_REST_API":
|
|
171
|
-
return NodeType.RestAPI; // "restApi"
|
|
172
|
-
case "NODE_TYPE_CUSTOM_CODE":
|
|
173
|
-
return NodeType.CustomCode; // "customCode"
|
|
174
|
-
case "NODE_TYPE_BRANCH":
|
|
175
|
-
return NodeType.Branch; // "branch"
|
|
176
|
-
case "NODE_TYPE_FILTER":
|
|
177
|
-
return NodeType.Filter; // "filter"
|
|
178
|
-
case "NODE_TYPE_LOOP":
|
|
179
|
-
return NodeType.Loop; // "loop"
|
|
180
|
-
case "NODE_TYPE_BALANCE":
|
|
181
|
-
return NodeType.Balance; // "balance"
|
|
182
|
-
case "NODE_TYPE_UNSPECIFIED":
|
|
183
|
-
return NodeType.Unspecified; // "unspecified"
|
|
184
|
-
default:
|
|
185
|
-
console.warn(`Unknown node type: ${protobufType}, using raw value`);
|
|
186
|
-
return protobufType; // fallback to raw value
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Convert protobuf step type string to SDK step type string
|
|
191
|
-
*
|
|
192
|
-
* Automatically detects whether the type is a trigger or node type and converts accordingly.
|
|
193
|
-
*
|
|
194
|
-
* @param protobufType - The protobuf type string (e.g., "TRIGGER_TYPE_MANUAL" or "NODE_TYPE_CUSTOM_CODE")
|
|
195
|
-
* @returns The SDK type string (e.g., "manualTrigger" or "customCode")
|
|
196
|
-
*/
|
|
197
|
-
export function convertProtobufStepTypeToSdk(protobufType) {
|
|
198
|
-
if (protobufType.startsWith("TRIGGER_TYPE_")) {
|
|
199
|
-
return convertProtobufTriggerTypeToSdk(protobufType);
|
|
200
|
-
}
|
|
201
|
-
else if (protobufType.startsWith("NODE_TYPE_")) {
|
|
202
|
-
return convertProtobufNodeTypeToSdk(protobufType);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
console.warn(`Unknown step type: ${protobufType}, using raw value`);
|
|
206
|
-
return protobufType; // fallback to raw value
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Convert input field from JavaScript object to protobuf Value format
|
|
211
|
-
*
|
|
212
|
-
* Pure utility function for converting trigger/node input data to protobuf format.
|
|
213
|
-
* Can be used by both triggers and nodes.
|
|
214
|
-
*
|
|
215
|
-
* @param input - JavaScript object with input data, or undefined
|
|
216
|
-
* @returns protobuf Value or undefined if no input
|
|
217
|
-
*/
|
|
218
|
-
export function convertInputToProtobuf(input) {
|
|
219
|
-
if (!input) {
|
|
220
|
-
return undefined;
|
|
221
|
-
}
|
|
222
|
-
return convertJSValueToProtobuf(input);
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Extract input field from protobuf Value format to JavaScript object
|
|
226
|
-
*
|
|
227
|
-
* Pure utility function for extracting trigger/node input data from protobuf format.
|
|
228
|
-
* Can be used by both triggers and nodes.
|
|
229
|
-
*
|
|
230
|
-
* @param inputValue - protobuf Value from response, plain JavaScript object, or undefined
|
|
231
|
-
* @returns JavaScript object or undefined
|
|
232
|
-
*/
|
|
233
|
-
export function extractInputFromProtobuf(inputValue) {
|
|
234
|
-
if (!inputValue) {
|
|
235
|
-
return undefined;
|
|
236
|
-
}
|
|
237
|
-
// Check if it's already a plain JavaScript object
|
|
238
|
-
if (typeof inputValue === "object" && !inputValue.toJavaScript) {
|
|
239
|
-
// It's a plain JavaScript object, return as-is
|
|
240
|
-
if (!Array.isArray(inputValue)) {
|
|
241
|
-
return inputValue;
|
|
242
|
-
}
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
// It's a protobuf Value object, convert it
|
|
246
|
-
try {
|
|
247
|
-
const protobufValue = inputValue;
|
|
248
|
-
const inputJavaScript = protobufValue.toJavaScript();
|
|
249
|
-
if (inputJavaScript &&
|
|
250
|
-
typeof inputJavaScript === "object" &&
|
|
251
|
-
!Array.isArray(inputJavaScript)) {
|
|
252
|
-
return inputJavaScript;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
catch (error) {
|
|
256
|
-
// If conversion fails, try to return the object as-is if it looks like a valid input object
|
|
257
|
-
if (typeof inputValue === "object" && !Array.isArray(inputValue)) {
|
|
258
|
-
return inputValue;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return undefined;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Clean up gRPC error messages by extracting the actual message
|
|
265
|
-
* @param message - The raw gRPC error message
|
|
266
|
-
* @returns {string} - The cleaned error message
|
|
267
|
-
*/
|
|
268
|
-
export function cleanGrpcErrorMessage(message) {
|
|
269
|
-
if (!message)
|
|
270
|
-
return message;
|
|
271
|
-
// Pattern to match: "gRPC Error (Code X): X STATUS_CODE: actual message"
|
|
272
|
-
// We want to extract everything after the status code
|
|
273
|
-
const grpcErrorPattern = /gRPC Error \(Code \d+\): \d+ [A-Z_]+: (.+)$/;
|
|
274
|
-
const match = message.match(grpcErrorPattern);
|
|
275
|
-
if (match && match[1]) {
|
|
276
|
-
return match[1].trim();
|
|
277
|
-
}
|
|
278
|
-
// Fallback: try to extract message after any status code pattern
|
|
279
|
-
const statusCodePattern = /\d+ [A-Z_]+: (.+)$/;
|
|
280
|
-
const statusMatch = message.match(statusCodePattern);
|
|
281
|
-
if (statusMatch && statusMatch[1]) {
|
|
282
|
-
return statusMatch[1].trim();
|
|
283
|
-
}
|
|
284
|
-
// If no pattern matches, return the original message
|
|
285
|
-
return message;
|
|
286
|
-
}
|