@graph-compose/client 1.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/README.md +646 -0
- package/dist/core/builder.d.ts +313 -0
- package/dist/core/builder.d.ts.map +1 -0
- package/dist/core/builder.js +538 -0
- package/dist/core/builder.js.map +1 -0
- package/dist/core/node-builder.d.ts +180 -0
- package/dist/core/node-builder.d.ts.map +1 -0
- package/dist/core/node-builder.js +387 -0
- package/dist/core/node-builder.js.map +1 -0
- package/dist/core/tool-builder.d.ts +130 -0
- package/dist/core/tool-builder.d.ts.map +1 -0
- package/dist/core/tool-builder.js +343 -0
- package/dist/core/tool-builder.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +39 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/node-builder.d.ts +64 -0
- package/dist/node-builder.d.ts.map +1 -0
- package/dist/node-builder.js +261 -0
- package/dist/node-builder.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/validation/index.d.ts +34 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +304 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ActivityConfig, JsonataParam, // Assuming Node is needed for GraphToolNode definition
|
|
2
|
+
ToolNode } from "@graph-compose/core";
|
|
3
|
+
import { GraphCompose } from "./builder";
|
|
4
|
+
/**
|
|
5
|
+
* Fluent API for configuring individual tools within a GraphCompose workflow.
|
|
6
|
+
* Tools can be of type 'http' or 'graph'.
|
|
7
|
+
* Chain configuration methods (e.g., `.get()`, `.description()`, `.graph()`).
|
|
8
|
+
* Call `.end()` to finalize the tool definition and add it to the graph.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ToolBuilder {
|
|
11
|
+
private readonly parentGraph;
|
|
12
|
+
protected tool: ToolNode;
|
|
13
|
+
private readonly id;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of ToolBuilder.
|
|
16
|
+
* @param parentGraph The parent GraphCompose instance.
|
|
17
|
+
* @param id The unique identifier for the tool.
|
|
18
|
+
*/
|
|
19
|
+
constructor(parentGraph: GraphCompose, id: string);
|
|
20
|
+
/**
|
|
21
|
+
* Validates a JSONata expression within the context of the current tool.
|
|
22
|
+
* @param expression The JSONata expression string to validate.
|
|
23
|
+
* @param context A descriptive string indicating where the expression is used.
|
|
24
|
+
* @throws {Error} If the expression is invalid.
|
|
25
|
+
*/
|
|
26
|
+
private validateJsonataExpression;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a GET request.
|
|
29
|
+
* @param url The URL endpoint for the GET request.
|
|
30
|
+
* @returns The ToolBuilder instance for chaining.
|
|
31
|
+
*/
|
|
32
|
+
get(url: string): ToolBuilder;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a POST request.
|
|
35
|
+
* @param url The URL endpoint for the POST request.
|
|
36
|
+
* @returns The ToolBuilder instance for chaining.
|
|
37
|
+
*/
|
|
38
|
+
post(url: string): ToolBuilder;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a PUT request.
|
|
41
|
+
* @param url The URL endpoint for the PUT request.
|
|
42
|
+
* @returns The ToolBuilder instance for chaining.
|
|
43
|
+
*/
|
|
44
|
+
put(url: string): ToolBuilder;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a DELETE request.
|
|
47
|
+
* @param url The URL endpoint for the DELETE request.
|
|
48
|
+
* @returns The ToolBuilder instance for chaining.
|
|
49
|
+
*/
|
|
50
|
+
delete(url: string): ToolBuilder;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a PATCH request.
|
|
53
|
+
* @param url The URL endpoint for the PATCH request.
|
|
54
|
+
* @returns The ToolBuilder instance for chaining.
|
|
55
|
+
*/
|
|
56
|
+
patch(url: string): ToolBuilder;
|
|
57
|
+
/**
|
|
58
|
+
* Sets the description for the tool.
|
|
59
|
+
* @param description A brief description of what the tool does.
|
|
60
|
+
* @returns The ToolBuilder instance for chaining.
|
|
61
|
+
*/
|
|
62
|
+
description(description: string): ToolBuilder;
|
|
63
|
+
/**
|
|
64
|
+
* Sets the HTTP headers for the HTTP tool's request.
|
|
65
|
+
* Only applicable if the tool type is 'http'.
|
|
66
|
+
* @param headers A record of header names to string values or JsonataParam objects.
|
|
67
|
+
* @returns The ToolBuilder instance for chaining.
|
|
68
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
69
|
+
* @throws {Error} If any JSONata expression within headers is invalid.
|
|
70
|
+
*/
|
|
71
|
+
withHeaders(headers: Record<string, string | JsonataParam>): ToolBuilder;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the body for the HTTP tool's request.
|
|
74
|
+
* Only applicable if the tool type is 'http'.
|
|
75
|
+
* @param body The request body as an object or string.
|
|
76
|
+
* @returns The ToolBuilder instance for chaining.
|
|
77
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
78
|
+
*/
|
|
79
|
+
withBody(body: Record<string, any> | string): ToolBuilder;
|
|
80
|
+
/**
|
|
81
|
+
* Configures the retry policy for the HTTP tool's request.
|
|
82
|
+
* Only applicable if the tool type is 'http'.
|
|
83
|
+
* @param config Partial configuration for the RetryPolicy.
|
|
84
|
+
* @returns The ToolBuilder instance for chaining.
|
|
85
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
86
|
+
*/
|
|
87
|
+
withRetries(config: Partial<ActivityConfig["retryPolicy"]>): ToolBuilder;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the start-to-close timeout for the HTTP tool's activity execution.
|
|
90
|
+
* @param duration The timeout duration (e.g., '30s', 5000).
|
|
91
|
+
* @returns The ToolBuilder instance for chaining.
|
|
92
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
93
|
+
*/
|
|
94
|
+
withStartToCloseTimeout(duration: string): ToolBuilder;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the schedule-to-close timeout for the HTTP tool's activity execution.
|
|
97
|
+
* @param duration The timeout duration (e.g., '30s', 5000).
|
|
98
|
+
* @returns The ToolBuilder instance for chaining.
|
|
99
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
100
|
+
*/
|
|
101
|
+
withScheduleToCloseTimeout(duration: string): ToolBuilder;
|
|
102
|
+
/**
|
|
103
|
+
* Configures the tool as a 'graph' type using a nested builder.
|
|
104
|
+
* @param builderCallback A function that receives a new GraphCompose instance to define the sub-graph.
|
|
105
|
+
* @returns The ToolBuilder instance for chaining.
|
|
106
|
+
*/
|
|
107
|
+
graph(builderCallback: (subGraph: GraphCompose) => void): ToolBuilder;
|
|
108
|
+
/**
|
|
109
|
+
* Finalizes the configuration of this tool and returns control to the parent GraphCompose builder.
|
|
110
|
+
* Adds the configured tool to the main graph's tool list.
|
|
111
|
+
* This method MUST be called to complete the tool definition.
|
|
112
|
+
*
|
|
113
|
+
* @returns The parent GraphCompose instance, allowing for further chaining on the main graph.
|
|
114
|
+
*/
|
|
115
|
+
end(): GraphCompose;
|
|
116
|
+
/**
|
|
117
|
+
* Builds and returns the configured tool node definition.
|
|
118
|
+
* Primarily used internally by the end() method.
|
|
119
|
+
* @returns The configured ToolNode object.
|
|
120
|
+
*/
|
|
121
|
+
build(): ToolNode;
|
|
122
|
+
/**
|
|
123
|
+
* @internal
|
|
124
|
+
* Retrieves the ID of the tool being built.
|
|
125
|
+
* Used for generating informative error messages.
|
|
126
|
+
* @returns The ID of the tool.
|
|
127
|
+
*/
|
|
128
|
+
getId(): string;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=tool-builder.d.ts.map
|
|
@@ -0,0 +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;IACH,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW;IAatD;;;;;OAKG;IACH,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW;IAezD;;;;OAIG;IACH,KAAK,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,GAAG,WAAW;IAmCrE;;;;;;OAMG;IACH,GAAG,IAAI,YAAY;IAenB;;;;OAIG;IACH,KAAK,IAAI,QAAQ;IAYjB;;;;;OAKG;IACH,KAAK,IAAI,MAAM;CAGhB"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolBuilder = void 0;
|
|
4
|
+
const validation_1 = require("../validation");
|
|
5
|
+
const builder_1 = require("./builder");
|
|
6
|
+
/**
|
|
7
|
+
* Fluent API for configuring individual tools within a GraphCompose workflow.
|
|
8
|
+
* Tools can be of type 'http' or 'graph'.
|
|
9
|
+
* Chain configuration methods (e.g., `.get()`, `.description()`, `.graph()`).
|
|
10
|
+
* Call `.end()` to finalize the tool definition and add it to the graph.
|
|
11
|
+
*/
|
|
12
|
+
class ToolBuilder {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of ToolBuilder.
|
|
15
|
+
* @param parentGraph The parent GraphCompose instance.
|
|
16
|
+
* @param id The unique identifier for the tool.
|
|
17
|
+
*/
|
|
18
|
+
constructor(parentGraph, id) {
|
|
19
|
+
this.parentGraph = parentGraph;
|
|
20
|
+
this.id = id; // Store the ID
|
|
21
|
+
this.tool = {
|
|
22
|
+
id,
|
|
23
|
+
type: "http",
|
|
24
|
+
http: {
|
|
25
|
+
method: "GET",
|
|
26
|
+
url: "",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validates a JSONata expression within the context of the current tool.
|
|
32
|
+
* @param expression The JSONata expression string to validate.
|
|
33
|
+
* @param context A descriptive string indicating where the expression is used.
|
|
34
|
+
* @throws {Error} If the expression is invalid.
|
|
35
|
+
*/
|
|
36
|
+
validateJsonataExpression(expression, context) {
|
|
37
|
+
try {
|
|
38
|
+
const result = (0, validation_1.validateExpression)(expression, this.tool.id);
|
|
39
|
+
if (!result.isValid) {
|
|
40
|
+
throw result.errors[0];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.error(`Error validating expression for tool ${this.tool.id}:`, e);
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a GET request.
|
|
50
|
+
* @param url The URL endpoint for the GET request.
|
|
51
|
+
* @returns The ToolBuilder instance for chaining.
|
|
52
|
+
*/
|
|
53
|
+
get(url) {
|
|
54
|
+
if (this.tool.type !== "http") {
|
|
55
|
+
// Explicitly create a new HTTP tool structure
|
|
56
|
+
this.tool = {
|
|
57
|
+
id: this.tool.id,
|
|
58
|
+
description: this.tool.description,
|
|
59
|
+
type: "http",
|
|
60
|
+
http: { method: "GET", url },
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Ensure http property exists before assigning
|
|
65
|
+
if (!this.tool.http)
|
|
66
|
+
this.tool.http = { method: "GET", url };
|
|
67
|
+
this.tool.http.method = "GET";
|
|
68
|
+
this.tool.http.url = url;
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a POST request.
|
|
74
|
+
* @param url The URL endpoint for the POST request.
|
|
75
|
+
* @returns The ToolBuilder instance for chaining.
|
|
76
|
+
*/
|
|
77
|
+
post(url) {
|
|
78
|
+
if (this.tool.type !== "http") {
|
|
79
|
+
this.tool = {
|
|
80
|
+
id: this.tool.id,
|
|
81
|
+
description: this.tool.description,
|
|
82
|
+
type: "http",
|
|
83
|
+
http: { method: "POST", url },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (!this.tool.http)
|
|
88
|
+
this.tool.http = { method: "POST", url };
|
|
89
|
+
this.tool.http.method = "POST";
|
|
90
|
+
this.tool.http.url = url;
|
|
91
|
+
}
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a PUT request.
|
|
96
|
+
* @param url The URL endpoint for the PUT request.
|
|
97
|
+
* @returns The ToolBuilder instance for chaining.
|
|
98
|
+
*/
|
|
99
|
+
put(url) {
|
|
100
|
+
if (this.tool.type !== "http") {
|
|
101
|
+
this.tool = {
|
|
102
|
+
id: this.tool.id,
|
|
103
|
+
description: this.tool.description,
|
|
104
|
+
type: "http",
|
|
105
|
+
http: { method: "PUT", url },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
if (!this.tool.http)
|
|
110
|
+
this.tool.http = { method: "PUT", url };
|
|
111
|
+
this.tool.http.method = "PUT";
|
|
112
|
+
this.tool.http.url = url;
|
|
113
|
+
}
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a DELETE request.
|
|
118
|
+
* @param url The URL endpoint for the DELETE request.
|
|
119
|
+
* @returns The ToolBuilder instance for chaining.
|
|
120
|
+
*/
|
|
121
|
+
delete(url) {
|
|
122
|
+
if (this.tool.type !== "http") {
|
|
123
|
+
this.tool = {
|
|
124
|
+
id: this.tool.id,
|
|
125
|
+
description: this.tool.description,
|
|
126
|
+
type: "http",
|
|
127
|
+
http: { method: "DELETE", url },
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (!this.tool.http)
|
|
132
|
+
this.tool.http = { method: "DELETE", url };
|
|
133
|
+
this.tool.http.method = "DELETE";
|
|
134
|
+
this.tool.http.url = url;
|
|
135
|
+
}
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Sets the tool type to 'http' (if not already set) and configures it for a PATCH request.
|
|
140
|
+
* @param url The URL endpoint for the PATCH request.
|
|
141
|
+
* @returns The ToolBuilder instance for chaining.
|
|
142
|
+
*/
|
|
143
|
+
patch(url) {
|
|
144
|
+
if (this.tool.type !== "http") {
|
|
145
|
+
this.tool = {
|
|
146
|
+
id: this.tool.id,
|
|
147
|
+
description: this.tool.description,
|
|
148
|
+
type: "http",
|
|
149
|
+
http: { method: "PATCH", url },
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
if (!this.tool.http)
|
|
154
|
+
this.tool.http = { method: "PATCH", url };
|
|
155
|
+
this.tool.http.method = "PATCH";
|
|
156
|
+
this.tool.http.url = url;
|
|
157
|
+
}
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
// --- Configuration methods for HTTP Tools ---
|
|
161
|
+
/**
|
|
162
|
+
* Sets the description for the tool.
|
|
163
|
+
* @param description A brief description of what the tool does.
|
|
164
|
+
* @returns The ToolBuilder instance for chaining.
|
|
165
|
+
*/
|
|
166
|
+
description(description) {
|
|
167
|
+
this.tool.description = description;
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Sets the HTTP headers for the HTTP tool's request.
|
|
172
|
+
* Only applicable if the tool type is 'http'.
|
|
173
|
+
* @param headers A record of header names to string values or JsonataParam objects.
|
|
174
|
+
* @returns The ToolBuilder instance for chaining.
|
|
175
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
176
|
+
* @throws {Error} If any JSONata expression within headers is invalid.
|
|
177
|
+
*/
|
|
178
|
+
withHeaders(headers) {
|
|
179
|
+
if (this.tool.type !== "http") {
|
|
180
|
+
throw new Error("Cannot set headers on a non-HTTP tool.");
|
|
181
|
+
}
|
|
182
|
+
// Ensure http property exists
|
|
183
|
+
if (!this.tool.http)
|
|
184
|
+
this.tool.http = { method: "GET", url: "" }; // Should have URL by now ideally
|
|
185
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
186
|
+
if (typeof value === "object" && "jsonataExpression" in value) {
|
|
187
|
+
this.validateJsonataExpression(value.jsonataExpression, `header '${key}'`);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
this.tool.http.headers = headers;
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Sets the body for the HTTP tool's request.
|
|
195
|
+
* Only applicable if the tool type is 'http'.
|
|
196
|
+
* @param body The request body as an object or string.
|
|
197
|
+
* @returns The ToolBuilder instance for chaining.
|
|
198
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
199
|
+
*/
|
|
200
|
+
withBody(body) {
|
|
201
|
+
if (this.tool.type !== "http") {
|
|
202
|
+
throw new Error("Cannot set body on a non-HTTP tool.");
|
|
203
|
+
}
|
|
204
|
+
if (!this.tool.http)
|
|
205
|
+
this.tool.http = { method: "GET", url: "" };
|
|
206
|
+
this.tool.http.body = body;
|
|
207
|
+
return this;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Configures the retry policy for the HTTP tool's request.
|
|
211
|
+
* Only applicable if the tool type is 'http'.
|
|
212
|
+
* @param config Partial configuration for the RetryPolicy.
|
|
213
|
+
* @returns The ToolBuilder instance for chaining.
|
|
214
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
215
|
+
*/
|
|
216
|
+
withRetries(config) {
|
|
217
|
+
if (this.tool.type !== "http") {
|
|
218
|
+
throw new Error("Cannot set retry policy on a non-HTTP tool.");
|
|
219
|
+
}
|
|
220
|
+
if (!this.tool.http)
|
|
221
|
+
this.tool.http = { method: "GET", url: "" };
|
|
222
|
+
// Ensure activityConfig exists
|
|
223
|
+
if (!this.tool.activityConfig) {
|
|
224
|
+
this.tool.activityConfig = {};
|
|
225
|
+
}
|
|
226
|
+
this.tool.activityConfig.retryPolicy = {
|
|
227
|
+
...this.tool.activityConfig.retryPolicy,
|
|
228
|
+
...config,
|
|
229
|
+
};
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Sets the start-to-close timeout for the HTTP tool's activity execution.
|
|
234
|
+
* @param duration The timeout duration (e.g., '30s', 5000).
|
|
235
|
+
* @returns The ToolBuilder instance for chaining.
|
|
236
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
237
|
+
*/
|
|
238
|
+
withStartToCloseTimeout(duration) {
|
|
239
|
+
if (this.tool.type !== "http") {
|
|
240
|
+
throw new Error("Cannot set startToCloseTimeout on a non-HTTP tool.");
|
|
241
|
+
}
|
|
242
|
+
if (!this.tool.http)
|
|
243
|
+
this.tool.http = { method: "GET", url: "" };
|
|
244
|
+
if (!this.tool.activityConfig) {
|
|
245
|
+
this.tool.activityConfig = {};
|
|
246
|
+
}
|
|
247
|
+
this.tool.activityConfig.startToCloseTimeout = duration;
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Sets the schedule-to-close timeout for the HTTP tool's activity execution.
|
|
252
|
+
* @param duration The timeout duration (e.g., '30s', 5000).
|
|
253
|
+
* @returns The ToolBuilder instance for chaining.
|
|
254
|
+
* @throws {Error} If the tool type is not 'http'.
|
|
255
|
+
*/
|
|
256
|
+
withScheduleToCloseTimeout(duration) {
|
|
257
|
+
if (this.tool.type !== "http") {
|
|
258
|
+
throw new Error("Cannot set scheduleToCloseTimeout on a non-HTTP tool.");
|
|
259
|
+
}
|
|
260
|
+
if (!this.tool.http)
|
|
261
|
+
this.tool.http = { method: "GET", url: "" };
|
|
262
|
+
if (!this.tool.activityConfig) {
|
|
263
|
+
this.tool.activityConfig = {};
|
|
264
|
+
}
|
|
265
|
+
this.tool.activityConfig.scheduleToCloseTimeout = duration;
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
268
|
+
// --- Configuration method for Graph Tools ---
|
|
269
|
+
/**
|
|
270
|
+
* Configures the tool as a 'graph' type using a nested builder.
|
|
271
|
+
* @param builderCallback A function that receives a new GraphCompose instance to define the sub-graph.
|
|
272
|
+
* @returns The ToolBuilder instance for chaining.
|
|
273
|
+
*/
|
|
274
|
+
graph(builderCallback) {
|
|
275
|
+
const subGraphBuilder = new builder_1.GraphCompose({ token: "subgraph-internal" });
|
|
276
|
+
builderCallback(subGraphBuilder);
|
|
277
|
+
const subGraphDefinition = subGraphBuilder.getWorkflow();
|
|
278
|
+
// --- START VALIDATION ---
|
|
279
|
+
const invalidNodes = subGraphDefinition.nodes.filter((node) => node.type !== "http");
|
|
280
|
+
if (invalidNodes.length > 0) {
|
|
281
|
+
const invalidIds = invalidNodes.map((n) => n.id);
|
|
282
|
+
throw new Error(`Graph tool '${this.tool.id}' can only contain HTTP nodes. Found invalid node types for IDs: ${invalidIds.join(", ")}`);
|
|
283
|
+
}
|
|
284
|
+
// --- END VALIDATION ---
|
|
285
|
+
if (subGraphDefinition.tools && subGraphDefinition.tools.length > 0) {
|
|
286
|
+
console.warn(`Tool '${this.tool.id}': Graph tools currently do not support nested tools. Inner tools will be ignored.`);
|
|
287
|
+
}
|
|
288
|
+
this.tool = {
|
|
289
|
+
id: this.tool.id,
|
|
290
|
+
type: "graph",
|
|
291
|
+
description: this.tool.description,
|
|
292
|
+
graph: {
|
|
293
|
+
nodes: subGraphDefinition.nodes,
|
|
294
|
+
},
|
|
295
|
+
}; // Assert final assignment conforms to ToolNode
|
|
296
|
+
delete this.tool.http;
|
|
297
|
+
return this;
|
|
298
|
+
}
|
|
299
|
+
// --- Finalization ---
|
|
300
|
+
/**
|
|
301
|
+
* Finalizes the configuration of this tool and returns control to the parent GraphCompose builder.
|
|
302
|
+
* Adds the configured tool to the main graph's tool list.
|
|
303
|
+
* This method MUST be called to complete the tool definition.
|
|
304
|
+
*
|
|
305
|
+
* @returns The parent GraphCompose instance, allowing for further chaining on the main graph.
|
|
306
|
+
*/
|
|
307
|
+
end() {
|
|
308
|
+
// Basic validation before adding
|
|
309
|
+
if (this.tool.type === "http" && !this.tool.http?.url) {
|
|
310
|
+
throw new Error(`HTTP tool '${this.tool.id}' must have a URL defined.`);
|
|
311
|
+
}
|
|
312
|
+
if (this.tool.type === "graph" && (!this.tool.graph || this.tool.graph.nodes.length === 0)) {
|
|
313
|
+
throw new Error(`Graph tool '${this.tool.id}' must have at least one node defined in its graph.`);
|
|
314
|
+
}
|
|
315
|
+
this.parentGraph._addToolDefinition(this.build());
|
|
316
|
+
return this.parentGraph;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Builds and returns the configured tool node definition.
|
|
320
|
+
* Primarily used internally by the end() method.
|
|
321
|
+
* @returns The configured ToolNode object.
|
|
322
|
+
*/
|
|
323
|
+
build() {
|
|
324
|
+
// Remove empty activityConfig if no activity settings were provided for HTTP tools
|
|
325
|
+
if (this.tool.type === "http" &&
|
|
326
|
+
this.tool.activityConfig &&
|
|
327
|
+
Object.keys(this.tool.activityConfig).length === 0) {
|
|
328
|
+
delete this.tool.activityConfig;
|
|
329
|
+
}
|
|
330
|
+
return this.tool;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* @internal
|
|
334
|
+
* Retrieves the ID of the tool being built.
|
|
335
|
+
* Used for generating informative error messages.
|
|
336
|
+
* @returns The ID of the tool.
|
|
337
|
+
*/
|
|
338
|
+
getId() {
|
|
339
|
+
return this.id;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
exports.ToolBuilder = ToolBuilder;
|
|
343
|
+
//# sourceMappingURL=tool-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-builder.js","sourceRoot":"","sources":["../../src/core/tool-builder.ts"],"names":[],"mappings":";;;AAMA,8CAAmD;AACnD,uCAAyC;AAEzC;;;;;GAKG;AACH,MAAa,WAAW;IAKtB;;;;OAIG;IACH,YACmB,WAAyB,EAC1C,EAAU;QADO,gBAAW,GAAX,WAAW,CAAc;QAG1C,IAAI,CAAC,EAAE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CAAC;QAC1E,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YAC3F,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,CAAC,IAAI,CAAC,EAAE,qDAAqD,CACjF,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,mFAAmF;QACnF,IACE,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;YACzB,IAAI,CAAC,IAAI,CAAC,cAAc;YACxB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,KAAK,CAAC,EAClD,CAAC;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF;AAlWD,kCAkWC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class NodeMethodError extends Error {
|
|
2
|
+
constructor(methodName: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class ValidationError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class CircularDependencyError extends ValidationError {
|
|
8
|
+
constructor(cycle: string[]);
|
|
9
|
+
}
|
|
10
|
+
export declare class InvalidNodeIdError extends ValidationError {
|
|
11
|
+
constructor(id: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class MissingDependencyError extends ValidationError {
|
|
14
|
+
constructor(nodeId: string, missingDeps: string[]);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,UAAU,EAAE,MAAM;CAI/B;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,uBAAwB,SAAQ,eAAe;gBAC9C,KAAK,EAAE,MAAM,EAAE;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,eAAe;gBACzC,EAAE,EAAE,MAAM;CAMvB;AAED,qBAAa,sBAAuB,SAAQ,eAAe;gBAC7C,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE;CAIlD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingDependencyError = exports.InvalidNodeIdError = exports.CircularDependencyError = exports.ValidationError = exports.NodeMethodError = void 0;
|
|
4
|
+
class NodeMethodError extends Error {
|
|
5
|
+
constructor(methodName) {
|
|
6
|
+
super(`${methodName} is not a function - you need to create a node first with .node()`);
|
|
7
|
+
this.name = "NodeMethodError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.NodeMethodError = NodeMethodError;
|
|
11
|
+
class ValidationError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "ValidationError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ValidationError = ValidationError;
|
|
18
|
+
class CircularDependencyError extends ValidationError {
|
|
19
|
+
constructor(cycle) {
|
|
20
|
+
super(`Circular dependencies detected: ${cycle.join(" -> ")}`);
|
|
21
|
+
this.name = "CircularDependencyError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.CircularDependencyError = CircularDependencyError;
|
|
25
|
+
class InvalidNodeIdError extends ValidationError {
|
|
26
|
+
constructor(id) {
|
|
27
|
+
super(`Invalid node ID: "${id}". Node IDs must be alphanumeric and use underscores, not dashes`);
|
|
28
|
+
this.name = "InvalidNodeIdError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.InvalidNodeIdError = InvalidNodeIdError;
|
|
32
|
+
class MissingDependencyError extends ValidationError {
|
|
33
|
+
constructor(nodeId, missingDeps) {
|
|
34
|
+
super(`Node "${nodeId}" depends on non-existent nodes: ${missingDeps.join(", ")}`);
|
|
35
|
+
this.name = "MissingDependencyError";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.MissingDependencyError = MissingDependencyError;
|
|
39
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,UAAkB;QAC5B,KAAK,CAAC,GAAG,UAAU,mEAAmE,CAAC,CAAC;QACxF,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,uBAAwB,SAAQ,eAAe;IAC1D,YAAY,KAAe;QACzB,KAAK,CAAC,mCAAmC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AALD,0DAKC;AAED,MAAa,kBAAmB,SAAQ,eAAe;IACrD,YAAY,EAAU;QACpB,KAAK,CACH,qBAAqB,EAAE,kEAAkE,CAC1F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAPD,gDAOC;AAED,MAAa,sBAAuB,SAAQ,eAAe;IACzD,YAAY,MAAc,EAAE,WAAqB;QAC/C,KAAK,CAAC,SAAS,MAAM,oCAAoC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph Compose Client Package
|
|
3
|
+
*
|
|
4
|
+
* This package provides a type-safe builder pattern for creating and managing workflow graphs.
|
|
5
|
+
* It includes validation, error handling, and execution management capabilities.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import "zod-openapi/extend";
|
|
10
|
+
export declare const VERSION = "1.0.0";
|
|
11
|
+
export * from "./core/builder";
|
|
12
|
+
export * from "./core/node-builder";
|
|
13
|
+
export * from "./types";
|
|
14
|
+
export { validateWorkflow } from "./validation";
|
|
15
|
+
export * from "./errors";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,oBAAoB,CAAC;AAE5B,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AAGpC,cAAc,SAAS,CAAC;AAIxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.validateWorkflow = exports.VERSION = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* Graph Compose Client Package
|
|
20
|
+
*
|
|
21
|
+
* This package provides a type-safe builder pattern for creating and managing workflow graphs.
|
|
22
|
+
* It includes validation, error handling, and execution management capabilities.
|
|
23
|
+
*
|
|
24
|
+
* @packageDocumentation
|
|
25
|
+
*/
|
|
26
|
+
require("zod-openapi/extend");
|
|
27
|
+
exports.VERSION = "1.0.0";
|
|
28
|
+
// Core functionality
|
|
29
|
+
__exportStar(require("./core/builder"), exports);
|
|
30
|
+
__exportStar(require("./core/node-builder"), exports);
|
|
31
|
+
// Type definitions
|
|
32
|
+
__exportStar(require("./types"), exports);
|
|
33
|
+
// Validation utilities
|
|
34
|
+
// Explicitly export only needed members to avoid name clash with types.ts
|
|
35
|
+
var validation_1 = require("./validation");
|
|
36
|
+
Object.defineProperty(exports, "validateWorkflow", { enumerable: true, get: function () { return validation_1.validateWorkflow; } });
|
|
37
|
+
// Error handling
|
|
38
|
+
__exportStar(require("./errors"), exports);
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;GAOG;AACH,8BAA4B;AAEf,QAAA,OAAO,GAAG,OAAO,CAAC;AAE/B,qBAAqB;AACrB,iDAA+B;AAC/B,sDAAoC;AAEpC,mBAAmB;AACnB,0CAAwB;AAExB,uBAAuB;AACvB,0EAA0E;AAC1E,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA;AAEzB,iBAAiB;AACjB,2CAAyB"}
|