@compass-labs/api-sdk 0.5.7 → 0.5.8

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 (36) hide show
  1. package/FUNCTIONS.md +6 -26
  2. package/README.md +41 -72
  3. package/bin/mcp-server.js +9 -9
  4. package/bin/mcp-server.js.map +6 -6
  5. package/dist/commonjs/lib/config.d.ts +3 -3
  6. package/dist/commonjs/lib/config.js +3 -3
  7. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  8. package/dist/commonjs/mcp-server/server.js +1 -1
  9. package/dist/commonjs/models/errors/apierror.d.ts +14 -2
  10. package/dist/commonjs/models/errors/apierror.d.ts.map +1 -1
  11. package/dist/commonjs/models/errors/apierror.js +1 -1
  12. package/dist/commonjs/models/errors/apierror.js.map +1 -1
  13. package/dist/esm/lib/config.d.ts +3 -3
  14. package/dist/esm/lib/config.js +3 -3
  15. package/dist/esm/mcp-server/mcp-server.js +1 -1
  16. package/dist/esm/mcp-server/server.js +1 -1
  17. package/dist/esm/models/errors/apierror.d.ts +14 -2
  18. package/dist/esm/models/errors/apierror.d.ts.map +1 -1
  19. package/dist/esm/models/errors/apierror.js +1 -1
  20. package/dist/esm/models/errors/apierror.js.map +1 -1
  21. package/docs/sdks/aavev3/README.md +83 -199
  22. package/docs/sdks/aerodromeslipstream/README.md +39 -79
  23. package/docs/sdks/morpho/README.md +84 -182
  24. package/docs/sdks/pendle/README.md +53 -113
  25. package/docs/sdks/sky/README.md +27 -51
  26. package/docs/sdks/smartaccount/README.md +5 -9
  27. package/docs/sdks/token/README.md +24 -56
  28. package/docs/sdks/transactionbatching/README.md +15 -27
  29. package/docs/sdks/uniswapv3/README.md +60 -132
  30. package/docs/sdks/universal/README.md +50 -106
  31. package/jsr.json +1 -1
  32. package/package.json +1 -1
  33. package/src/lib/config.ts +3 -3
  34. package/src/mcp-server/mcp-server.ts +1 -1
  35. package/src/mcp-server/server.ts +1 -1
  36. package/src/models/errors/apierror.ts +18 -3
package/FUNCTIONS.md CHANGED
@@ -21,7 +21,6 @@ specific category of applications.
21
21
  ```typescript
22
22
  import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
23
23
  import { aaveV3Rate } from "@compass-labs/api-sdk/funcs/aaveV3Rate.js";
24
- import { SDKValidationError } from "@compass-labs/api-sdk/models/errors/sdkvalidationerror.js";
25
24
 
26
25
  // Use `CompassApiSDKCore` for best tree-shaking performance.
27
26
  // You can create one instance of it to use across an application.
@@ -30,32 +29,13 @@ const compassApiSDK = new CompassApiSDKCore({
30
29
  });
31
30
 
32
31
  async function run() {
33
- const res = await aaveV3Rate(compassApiSDK, {
34
- chain: "arbitrum:mainnet",
35
- token: "USDC",
36
- });
37
-
38
- switch (true) {
39
- case res.ok:
40
- // The success case will be handled outside of the switch block
41
- break;
42
- case res.error instanceof SDKValidationError:
43
- // Pretty-print validation errors.
44
- return console.log(res.error.pretty());
45
- case res.error instanceof Error:
46
- return console.log(res.error);
47
- default:
48
- // TypeScript's type checking will fail on the following line if the above
49
- // cases were not exhaustive.
50
- res.error satisfies never;
51
- throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error);
32
+ const res = await aaveV3Rate(compassApiSDK, {});
33
+ if (res.ok) {
34
+ const { value: result } = res;
35
+ console.log(result);
36
+ } else {
37
+ console.log("aaveV3Rate failed:", res.error);
52
38
  }
53
-
54
-
55
- const { value: result } = res;
56
-
57
- // Handle the result
58
- console.log(result);
59
39
  }
60
40
 
61
41
  run();
package/README.md CHANGED
@@ -168,12 +168,8 @@ const compassApiSDK = new CompassApiSDK({
168
168
  });
169
169
 
170
170
  async function run() {
171
- const result = await compassApiSDK.aaveV3.rate({
172
- chain: "arbitrum:mainnet",
173
- token: "USDC",
174
- });
171
+ const result = await compassApiSDK.aaveV3.rate({});
175
172
 
176
- // Handle the result
177
173
  console.log(result);
178
174
  }
179
175
 
@@ -202,12 +198,8 @@ const compassApiSDK = new CompassApiSDK({
202
198
  });
203
199
 
204
200
  async function run() {
205
- const result = await compassApiSDK.aaveV3.rate({
206
- chain: "arbitrum:mainnet",
207
- token: "USDC",
208
- });
201
+ const result = await compassApiSDK.aaveV3.rate({});
209
202
 
210
- // Handle the result
211
203
  console.log(result);
212
204
  }
213
205
 
@@ -437,10 +429,7 @@ const compassApiSDK = new CompassApiSDK({
437
429
  });
438
430
 
439
431
  async function run() {
440
- const result = await compassApiSDK.aaveV3.rate({
441
- chain: "arbitrum:mainnet",
442
- token: "USDC",
443
- }, {
432
+ const result = await compassApiSDK.aaveV3.rate({}, {
444
433
  retries: {
445
434
  strategy: "backoff",
446
435
  backoff: {
@@ -453,7 +442,6 @@ async function run() {
453
442
  },
454
443
  });
455
444
 
456
- // Handle the result
457
445
  console.log(result);
458
446
  }
459
447
 
@@ -480,12 +468,8 @@ const compassApiSDK = new CompassApiSDK({
480
468
  });
481
469
 
482
470
  async function run() {
483
- const result = await compassApiSDK.aaveV3.rate({
484
- chain: "arbitrum:mainnet",
485
- token: "USDC",
486
- });
471
+ const result = await compassApiSDK.aaveV3.rate({});
487
472
 
488
- // Handle the result
489
473
  console.log(result);
490
474
  }
491
475
 
@@ -497,55 +481,45 @@ run();
497
481
  <!-- Start Error Handling [errors] -->
498
482
  ## Error Handling
499
483
 
500
- Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `rate` method may throw the following errors:
484
+ This table shows properties which are common on error classes. For full details see [error classes](#error-classes).
501
485
 
502
- | Error Type | Status Code | Content Type |
503
- | -------------------------- | ----------- | ---------------- |
504
- | errors.HTTPValidationError | 422 | application/json |
505
- | errors.APIError | 4XX, 5XX | \*/\* |
506
-
507
- If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
486
+ | Property | Type | Description |
487
+ | ------------------- | ---------- | --------------------------------------------------------------------------------------- |
488
+ | `error.name` | `string` | Error class name eg `APIError` |
489
+ | `error.message` | `string` | Error message |
490
+ | `error.statusCode` | `number` | HTTP status code eg `404` |
491
+ | `error.contentType` | `string` | HTTP content type eg `application/json` |
492
+ | `error.body` | `string` | HTTP body. Can be empty string if no body is returned. |
493
+ | `error.rawResponse` | `Response` | Raw HTTP response. Access to headers and more. |
494
+ | `error.data$` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
508
495
 
496
+ ### Example
509
497
  ```typescript
510
498
  import { CompassApiSDK } from "@compass-labs/api-sdk";
511
- import {
512
- HTTPValidationError,
513
- SDKValidationError,
514
- } from "@compass-labs/api-sdk/models/errors";
499
+ import * as errors from "@compass-labs/api-sdk/models/errors";
515
500
 
516
501
  const compassApiSDK = new CompassApiSDK({
517
502
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
518
503
  });
519
504
 
520
505
  async function run() {
521
- let result;
522
506
  try {
523
- result = await compassApiSDK.aaveV3.rate({
524
- chain: "arbitrum:mainnet",
525
- token: "USDC",
526
- });
507
+ const result = await compassApiSDK.aaveV3.rate({});
527
508
 
528
- // Handle the result
529
509
  console.log(result);
530
- } catch (err) {
531
- switch (true) {
532
- // The server response does not match the expected SDK schema
533
- case (err instanceof SDKValidationError): {
534
- // Pretty-print will provide a human-readable multi-line error message
535
- console.error(err.pretty());
536
- // Raw value may also be inspected
537
- console.error(err.rawValue);
538
- return;
539
- }
540
- case (err instanceof HTTPValidationError): {
541
- // Handle err.data$: HTTPValidationErrorData
542
- console.error(err);
543
- return;
544
- }
545
- default: {
546
- // Other errors such as network errors, see HTTPClientErrors for more details
547
- throw err;
548
- }
510
+ } catch (error) {
511
+ // Depending on the method different errors may be thrown
512
+ if (error instanceof errors.HTTPValidationError) {
513
+ console.log(error.message);
514
+ console.log(error.data$.detail); // ValidationError[]
515
+ }
516
+
517
+ // Fallback error class, if no other more specific error class is matched
518
+ if (error instanceof errors.APIError) {
519
+ console.log(error.message);
520
+ console.log(error.statusCode);
521
+ console.log(error.body);
522
+ console.log(error.rawResponse.headers);
549
523
  }
550
524
  }
551
525
  }
@@ -554,17 +528,16 @@ run();
554
528
 
555
529
  ```
556
530
 
557
- Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
558
-
559
- In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module:
560
-
561
- | HTTP Client Error | Description |
562
- | ---------------------------------------------------- | ---------------------------------------------------- |
563
- | RequestAbortedError | HTTP request was aborted by the client |
564
- | RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
565
- | ConnectionError | HTTP client was unable to make a request to a server |
566
- | InvalidRequestError | Any input used to create a request is invalid |
567
- | UnexpectedClientError | Unrecognised or unexpected error |
531
+ ### Error Classes
532
+ * [`HTTPValidationError`](docs/models/errors/httpvalidationerror.md): Validation Error. Status code `422`.
533
+ * `APIError`: The fallback error class, if no other more specific error class is matched.
534
+ * `SDKValidationError`: Type mismatch between the data returned from the server and the structure expected by the SDK. This can also be thrown for invalid method arguments. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.
535
+ * Network errors:
536
+ * `ConnectionError`: HTTP client was unable to make a request to a server.
537
+ * `RequestTimeoutError`: HTTP request timed out due to an AbortSignal signal.
538
+ * `RequestAbortedError`: HTTP request was aborted by the client.
539
+ * `InvalidRequestError`: Any input used to create a request is invalid.
540
+ * `UnexpectedClientError`: Unrecognised or unexpected error.
568
541
  <!-- End Error Handling [errors] -->
569
542
 
570
543
  <!-- Start Server Selection [server] -->
@@ -582,12 +555,8 @@ const compassApiSDK = new CompassApiSDK({
582
555
  });
583
556
 
584
557
  async function run() {
585
- const result = await compassApiSDK.aaveV3.rate({
586
- chain: "arbitrum:mainnet",
587
- token: "USDC",
588
- });
558
+ const result = await compassApiSDK.aaveV3.rate({});
589
559
 
590
- // Handle the result
591
560
  console.log(result);
592
561
  }
593
562
 
package/bin/mcp-server.js CHANGED
@@ -34205,9 +34205,9 @@ var init_config = __esm(() => {
34205
34205
  SDK_METADATA = {
34206
34206
  language: "typescript",
34207
34207
  openapiDocVersion: "0.0.1",
34208
- sdkVersion: "0.5.7",
34209
- genVersion: "2.618.0",
34210
- userAgent: "speakeasy-sdk/typescript 0.5.7 2.618.0 0.0.1 @compass-labs/api-sdk"
34208
+ sdkVersion: "0.5.8",
34209
+ genVersion: "2.620.2",
34210
+ userAgent: "speakeasy-sdk/typescript 0.5.8 2.620.2 0.0.1 @compass-labs/api-sdk"
34211
34211
  };
34212
34212
  });
34213
34213
 
@@ -35130,18 +35130,18 @@ var init_tools = __esm(() => {
35130
35130
  var APIError;
35131
35131
  var init_apierror = __esm(() => {
35132
35132
  APIError = class APIError extends Error {
35133
- rawResponse;
35134
- body;
35135
35133
  statusCode;
35136
35134
  contentType;
35135
+ body;
35136
+ rawResponse;
35137
35137
  constructor(message, rawResponse, body = "") {
35138
35138
  const statusCode = rawResponse.status;
35139
35139
  const contentType2 = rawResponse.headers.get("content-type") || "";
35140
35140
  const bodyString = body.length > 0 ? `
35141
35141
  ${body}` : "";
35142
35142
  super(`${message}: Status ${statusCode} Content-Type ${contentType2} Body ${bodyString}`);
35143
- this.rawResponse = rawResponse;
35144
35143
  this.body = body;
35144
+ this.rawResponse = rawResponse;
35145
35145
  this.statusCode = statusCode;
35146
35146
  this.contentType = contentType2;
35147
35147
  this.name = "APIError";
@@ -53044,7 +53044,7 @@ it to be traded on DeFi protocols.`,
53044
53044
  function createMCPServer(deps) {
53045
53045
  const server = new McpServer({
53046
53046
  name: "CompassApiSDK",
53047
- version: "0.5.7"
53047
+ version: "0.5.8"
53048
53048
  });
53049
53049
  const client = new CompassApiSDKCore({
53050
53050
  apiKeyAuth: deps.apiKeyAuth,
@@ -54403,7 +54403,7 @@ var routes = an({
54403
54403
  var app = He(routes, {
54404
54404
  name: "mcp",
54405
54405
  versionInfo: {
54406
- currentVersion: "0.5.7"
54406
+ currentVersion: "0.5.8"
54407
54407
  }
54408
54408
  });
54409
54409
  zt(app, process3.argv.slice(2), buildContext(process3));
@@ -54411,5 +54411,5 @@ export {
54411
54411
  app
54412
54412
  };
54413
54413
 
54414
- //# debugId=179ADF50CFAAB88C64756E2164756E21
54414
+ //# debugId=D98B0B01A5F7083564756E2164756E21
54415
54415
  //# sourceMappingURL=mcp-server.js.map