graphlit-client 1.0.20250710001 → 1.0.20250710002
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/dist/client.js +21 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
@@ -111,6 +111,14 @@ catch (e) {
|
|
111
111
|
}
|
112
112
|
}
|
113
113
|
const DEFAULT_MAX_TOOL_ROUNDS = 1000;
|
114
|
+
// Helper function to validate GUID format
|
115
|
+
function isValidGuid(guid) {
|
116
|
+
if (!guid)
|
117
|
+
return false;
|
118
|
+
// GUID regex pattern: 8-4-4-4-12 hexadecimal characters
|
119
|
+
const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
120
|
+
return guidRegex.test(guid);
|
121
|
+
}
|
114
122
|
// Define the Graphlit class
|
115
123
|
class Graphlit {
|
116
124
|
client;
|
@@ -189,12 +197,25 @@ class Graphlit {
|
|
189
197
|
if (!this.organizationId) {
|
190
198
|
throw new Error("Graphlit organization identifier is required.");
|
191
199
|
}
|
200
|
+
if (!isValidGuid(this.organizationId)) {
|
201
|
+
throw new Error(`Invalid organization ID format. Expected a valid GUID, but received: '${this.organizationId}'. ` +
|
202
|
+
"A valid GUID should be in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
|
203
|
+
}
|
192
204
|
if (!this.environmentId) {
|
193
205
|
throw new Error("Graphlit environment identifier is required.");
|
194
206
|
}
|
207
|
+
if (!isValidGuid(this.environmentId)) {
|
208
|
+
throw new Error(`Invalid environment ID format. Expected a valid GUID, but received: '${this.environmentId}'. ` +
|
209
|
+
"A valid GUID should be in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
|
210
|
+
}
|
195
211
|
if (!this.jwtSecret) {
|
196
212
|
throw new Error("Graphlit environment JWT secret is required.");
|
197
213
|
}
|
214
|
+
// Validate optional userId if provided (ownerId can be any format)
|
215
|
+
if (this.userId && !isValidGuid(this.userId)) {
|
216
|
+
throw new Error(`Invalid user ID format. Expected a valid GUID, but received: '${this.userId}'. ` +
|
217
|
+
"A valid GUID should be in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
|
218
|
+
}
|
198
219
|
this.refreshClient();
|
199
220
|
}
|
200
221
|
refreshClient() {
|