@cosmoner/sdk 1.5.0 → 1.7.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 CHANGED
@@ -263,6 +263,7 @@ try {
263
263
  console.error(err.code); // e.g. "INSUFFICIENT_SCOPE"
264
264
  console.error(err.status); // e.g. 403
265
265
  console.error(err.details); // field-level validation errors, when present
266
+ console.error(err.docsUrl); // page explaining the fix, when the API links one
266
267
  console.error(err.message); // Human-readable message
267
268
  }
268
269
  }
package/dist/errors.d.ts CHANGED
@@ -3,6 +3,8 @@
3
3
  export interface CosmonerErrorOptions {
4
4
  details?: unknown;
5
5
  requestId?: string;
6
+ /** Page explaining how to fix the error, when the API links one. */
7
+ docsUrl?: string;
6
8
  }
7
9
  /**
8
10
  * Base class for every error the SDK throws.
@@ -16,6 +18,12 @@ export declare class CosmonerError extends Error {
16
18
  readonly status: number;
17
19
  readonly details?: unknown;
18
20
  readonly requestId?: string;
21
+ /**
22
+ * Page explaining how to fix the error. The API links one only for errors
23
+ * the caller can fix (a missing scope, a rate limit, a failed validation),
24
+ * and older API versions never do, so it is often undefined.
25
+ */
26
+ readonly docsUrl?: string;
19
27
  constructor(status: number, code: string, message: string, options?: CosmonerErrorOptions);
20
28
  }
21
29
  /** The request never produced a response (DNS, TCP, TLS or socket failure). */
package/dist/index.js CHANGED
@@ -422,6 +422,7 @@ var CosmonerError = class extends Error {
422
422
  this.status = status;
423
423
  this.details = options.details;
424
424
  this.requestId = options.requestId;
425
+ this.docsUrl = options.docsUrl;
425
426
  }
426
427
  };
427
428
  var CosmonerConnectionError = class extends CosmonerError {
@@ -491,7 +492,8 @@ function errorFromResponse(status, body, headers, retryAfter) {
491
492
  const message = envelope.error?.message ?? "Unknown error";
492
493
  const options = {
493
494
  details: envelope.error?.details,
494
- requestId: headers?.get("x-request-id") ?? void 0
495
+ requestId: headers?.get("x-request-id") ?? void 0,
496
+ docsUrl: typeof envelope.error?.docsUrl === "string" ? envelope.error.docsUrl : void 0
495
497
  };
496
498
  switch (status) {
497
499
  case 400:
@@ -794,7 +796,7 @@ function sleep(ms) {
794
796
  }
795
797
 
796
798
  // src/version.ts
797
- var VERSION = "1.5.0";
799
+ var VERSION = "1.7.0";
798
800
  var USER_AGENT = `cosmoner-node/${VERSION}`;
799
801
 
800
802
  // src/transport.ts
package/dist/index.mjs CHANGED
@@ -358,6 +358,7 @@ var CosmonerError = class extends Error {
358
358
  this.status = status;
359
359
  this.details = options.details;
360
360
  this.requestId = options.requestId;
361
+ this.docsUrl = options.docsUrl;
361
362
  }
362
363
  };
363
364
  var CosmonerConnectionError = class extends CosmonerError {
@@ -427,7 +428,8 @@ function errorFromResponse(status, body, headers, retryAfter) {
427
428
  const message = envelope.error?.message ?? "Unknown error";
428
429
  const options = {
429
430
  details: envelope.error?.details,
430
- requestId: headers?.get("x-request-id") ?? void 0
431
+ requestId: headers?.get("x-request-id") ?? void 0,
432
+ docsUrl: typeof envelope.error?.docsUrl === "string" ? envelope.error.docsUrl : void 0
431
433
  };
432
434
  switch (status) {
433
435
  case 400:
@@ -730,7 +732,7 @@ function sleep(ms) {
730
732
  }
731
733
 
732
734
  // src/version.ts
733
- var VERSION = "1.5.0";
735
+ var VERSION = "1.7.0";
734
736
  var USER_AGENT = `cosmoner-node/${VERSION}`;
735
737
 
736
738
  // src/transport.ts
package/dist/version.d.ts CHANGED
@@ -8,5 +8,5 @@
8
8
  * the release workflow runs that straight after `npm version`, and
9
9
  * `version.test.ts` fails the build if the two ever disagree.
10
10
  */
11
- export declare const VERSION = "1.5.0";
12
- export declare const USER_AGENT = "cosmoner-node/1.5.0";
11
+ export declare const VERSION = "1.7.0";
12
+ export declare const USER_AGENT = "cosmoner-node/1.7.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoner/sdk",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Cosmoner SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",