@axiom-lattice/client-sdk 2.1.24 → 2.1.26

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/index.js CHANGED
@@ -2363,6 +2363,151 @@ var AbstractClient = class {
2363
2363
  ...config
2364
2364
  };
2365
2365
  this.assistantId = config.assistantId;
2366
+ this.serverTools = {
2367
+ list: async () => {
2368
+ const response = await this.makeRequest("/api/tools");
2369
+ return response.data.records;
2370
+ },
2371
+ get: async (id) => {
2372
+ const response = await this.makeRequest(`/api/tools/${id}`);
2373
+ if (!response.data)
2374
+ throw new ApiError("Tool not found", 404);
2375
+ return response.data;
2376
+ },
2377
+ create: async (data) => {
2378
+ const response = await this.makeRequest("/api/tools", { method: "POST", body: data });
2379
+ if (!response.data)
2380
+ throw new ApiError("Failed to create tool", 500);
2381
+ return response.data;
2382
+ },
2383
+ update: async (id, data) => {
2384
+ const response = await this.makeRequest(`/api/tools/${id}`, { method: "PUT", body: data });
2385
+ if (!response.data)
2386
+ throw new ApiError("Failed to update tool", 500);
2387
+ return response.data;
2388
+ },
2389
+ delete: async (id) => {
2390
+ await this.makeRequest(`/api/tools/${id}`, { method: "DELETE" });
2391
+ }
2392
+ };
2393
+ this.databaseConfigs = {
2394
+ list: async () => {
2395
+ const response = await this.makeRequest("/api/database-configs");
2396
+ return response.data.records;
2397
+ },
2398
+ get: async (id) => {
2399
+ const response = await this.makeRequest(`/api/database-configs/${id}`);
2400
+ if (!response.data)
2401
+ throw new ApiError("Database config not found", 404);
2402
+ return response.data;
2403
+ },
2404
+ create: async (data) => {
2405
+ const response = await this.makeRequest("/api/database-configs", { method: "POST", body: data });
2406
+ if (!response.data)
2407
+ throw new ApiError("Failed to create database config", 500);
2408
+ return response.data;
2409
+ },
2410
+ update: async (id, data) => {
2411
+ const response = await this.makeRequest(`/api/database-configs/${id}`, { method: "PUT", body: data });
2412
+ if (!response.data)
2413
+ throw new ApiError("Failed to update database config", 500);
2414
+ return response.data;
2415
+ },
2416
+ delete: async (id) => {
2417
+ await this.makeRequest(`/api/database-configs/${id}`, { method: "DELETE" });
2418
+ },
2419
+ test: async (id) => {
2420
+ return await this.makeRequest(`/api/database-configs/${id}/test`, { method: "POST" });
2421
+ }
2422
+ };
2423
+ this.metricsConfigs = {
2424
+ list: async () => {
2425
+ const response = await this.makeRequest("/api/metrics-configs");
2426
+ return response.data.records;
2427
+ },
2428
+ get: async (id) => {
2429
+ const response = await this.makeRequest(`/api/metrics-configs/${id}`);
2430
+ if (!response.data)
2431
+ throw new ApiError("Metrics config not found", 404);
2432
+ return response.data;
2433
+ },
2434
+ create: async (data) => {
2435
+ const response = await this.makeRequest("/api/metrics-configs", { method: "POST", body: data });
2436
+ if (!response.data)
2437
+ throw new ApiError("Failed to create metrics config", 500);
2438
+ return response.data;
2439
+ },
2440
+ update: async (id, data) => {
2441
+ const response = await this.makeRequest(`/api/metrics-configs/${id}`, { method: "PUT", body: data });
2442
+ if (!response.data)
2443
+ throw new ApiError("Failed to update metrics config", 500);
2444
+ return response.data;
2445
+ },
2446
+ delete: async (id) => {
2447
+ await this.makeRequest(`/api/metrics-configs/${id}`, { method: "DELETE" });
2448
+ },
2449
+ test: async (id) => {
2450
+ return await this.makeRequest(`/api/metrics-configs/${id}/test`, { method: "POST" });
2451
+ },
2452
+ getDatasources: async (id) => {
2453
+ const response = await this.makeRequest(`/api/metrics-configs/${id}/datasources`);
2454
+ return response.data?.datasources || [];
2455
+ }
2456
+ };
2457
+ this.mcpServers = {
2458
+ list: async () => {
2459
+ const response = await this.makeRequest("/api/mcp-servers");
2460
+ return response.data.records;
2461
+ },
2462
+ get: async (id) => {
2463
+ const response = await this.makeRequest(`/api/mcp-servers/${id}`);
2464
+ if (!response.data)
2465
+ throw new ApiError("MCP server config not found", 404);
2466
+ return response.data;
2467
+ },
2468
+ create: async (data) => {
2469
+ const response = await this.makeRequest("/api/mcp-servers", { method: "POST", body: data });
2470
+ if (!response.data)
2471
+ throw new ApiError("Failed to create MCP server config", 500);
2472
+ return response.data;
2473
+ },
2474
+ update: async (id, data) => {
2475
+ const response = await this.makeRequest(`/api/mcp-servers/${id}`, { method: "PUT", body: data });
2476
+ if (!response.data)
2477
+ throw new ApiError("Failed to update MCP server config", 500);
2478
+ return response.data;
2479
+ },
2480
+ delete: async (id) => {
2481
+ await this.makeRequest(`/api/mcp-servers/${id}`, { method: "DELETE" });
2482
+ },
2483
+ test: async (id) => {
2484
+ return await this.makeRequest(`/api/mcp-servers/${id}/test`, { method: "POST" });
2485
+ }
2486
+ };
2487
+ }
2488
+ /**
2489
+ * Set handler for 401 unauthorized errors
2490
+ * @param handler - Callback function to handle unauthorized errors
2491
+ */
2492
+ setUnauthorizedHandler(handler) {
2493
+ this.onUnauthorizedHandler = handler;
2494
+ }
2495
+ /**
2496
+ * Get the unauthorized handler
2497
+ * @returns The handler function or undefined
2498
+ */
2499
+ getUnauthorizedHandler() {
2500
+ return this.onUnauthorizedHandler;
2501
+ }
2502
+ /**
2503
+ * Make a generic API request
2504
+ * Exposed as public for advanced use cases
2505
+ * @param url - The URL to make the request to
2506
+ * @param options - Request options
2507
+ * @returns A promise that resolves to the response data
2508
+ */
2509
+ async request(url, options) {
2510
+ return this.makeRequest(url, options);
2366
2511
  }
2367
2512
  /**
2368
2513
  * Set assistant ID for the client
@@ -2980,7 +3125,7 @@ var WeChatClient = class extends AbstractClient {
2980
3125
  if (this.tenantId) {
2981
3126
  headers["x-tenant-id"] = this.tenantId;
2982
3127
  }
2983
- return this.request({
3128
+ return this.wechatRequest({
2984
3129
  url: fullUrl,
2985
3130
  method,
2986
3131
  data: options?.body
@@ -3062,7 +3207,7 @@ var WeChatClient = class extends AbstractClient {
3062
3207
  * Helper method to make WeChat HTTP requests
3063
3208
  * @private
3064
3209
  */
3065
- async request(options) {
3210
+ async wechatRequest(options) {
3066
3211
  const { url, method, data } = options;
3067
3212
  const headers = {
3068
3213
  "Content-Type": "application/json",
@@ -3215,6 +3360,7 @@ var WeChatClient = class extends AbstractClient {
3215
3360
  var WorkspaceClient = class {
3216
3361
  constructor(config, tenantId = "default") {
3217
3362
  this.baseURL = config.baseURL;
3363
+ this.tenantId = tenantId;
3218
3364
  this.headers = {
3219
3365
  "Content-Type": "application/json",
3220
3366
  Authorization: `Bearer ${config.apiKey}`,
@@ -3360,7 +3506,14 @@ var WorkspaceClient = class {
3360
3506
  return json.data;
3361
3507
  }
3362
3508
  getFileDownloadUrl(workspaceId, projectId, filePath) {
3363
- return `${this.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/downloadfile?path=${encodeURIComponent(filePath)}`;
3509
+ return `${this.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/downloadfile?path=${encodeURIComponent(filePath)}&tenantId=${encodeURIComponent(this.tenantId)}`;
3510
+ }
3511
+ /**
3512
+ * Get a URL for viewing a file inline in the browser (not download).
3513
+ * The file will be displayed in the browser rather than downloaded.
3514
+ */
3515
+ getFileViewUrl(workspaceId, projectId, filePath) {
3516
+ return `${this.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/viewfile?path=${encodeURIComponent(filePath)}&tenantId=${encodeURIComponent(this.tenantId)}`;
3364
3517
  }
3365
3518
  };
3366
3519