@cosmoner/sdk 1.6.0 → 1.7.1

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
@@ -170,8 +170,9 @@ Two API behaviours are worth knowing before you debug them:
170
170
  - **Writes need an owner or admin.** The API checks the member's role
171
171
  independently of the key's scopes, so a plain member's key is refused with a
172
172
  403 even when it carries `secrets:write`.
173
- - **Creating is rate-limited** to 10 requests per 10 minutes, and a project at
174
- its secret limit answers 402.
173
+ - **Creating is rate-limited** to 100 per project every 10 minutes, shared by
174
+ every key and machine working on the project, and a project at its secret
175
+ limit answers 402.
175
176
 
176
177
  ## Variables
177
178
 
@@ -263,6 +264,7 @@ try {
263
264
  console.error(err.code); // e.g. "INSUFFICIENT_SCOPE"
264
265
  console.error(err.status); // e.g. 403
265
266
  console.error(err.details); // field-level validation errors, when present
267
+ console.error(err.docsUrl); // page explaining the fix, when the API links one
266
268
  console.error(err.message); // Human-readable message
267
269
  }
268
270
  }
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
@@ -299,9 +299,9 @@ var SecretsService = class {
299
299
  /**
300
300
  * Stores a new secret, and returns its plaintext value once.
301
301
  *
302
- * Creation is rate-limited to 10 requests per 10 minutes, so a loop that
303
- * imports many secrets will meet a `RateLimitError`. A project at its limit
304
- * answers 402 — see `usage()`.
302
+ * Creation is rate-limited to 100 per project every 10 minutes, shared by
303
+ * every key and machine working on the project; past it, a `RateLimitError`.
304
+ * A project at its secret limit answers 402 — see `usage()`.
305
305
  */
306
306
  async create(params) {
307
307
  requireEntryName(params.name);
@@ -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.6.0";
799
+ var VERSION = "1.7.1";
798
800
  var USER_AGENT = `cosmoner-node/${VERSION}`;
799
801
 
800
802
  // src/transport.ts
package/dist/index.mjs CHANGED
@@ -235,9 +235,9 @@ var SecretsService = class {
235
235
  /**
236
236
  * Stores a new secret, and returns its plaintext value once.
237
237
  *
238
- * Creation is rate-limited to 10 requests per 10 minutes, so a loop that
239
- * imports many secrets will meet a `RateLimitError`. A project at its limit
240
- * answers 402 — see `usage()`.
238
+ * Creation is rate-limited to 100 per project every 10 minutes, shared by
239
+ * every key and machine working on the project; past it, a `RateLimitError`.
240
+ * A project at its secret limit answers 402 — see `usage()`.
241
241
  */
242
242
  async create(params) {
243
243
  requireEntryName(params.name);
@@ -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.6.0";
735
+ var VERSION = "1.7.1";
734
736
  var USER_AGENT = `cosmoner-node/${VERSION}`;
735
737
 
736
738
  // src/transport.ts
@@ -130,9 +130,9 @@ export declare class SecretsService {
130
130
  /**
131
131
  * Stores a new secret, and returns its plaintext value once.
132
132
  *
133
- * Creation is rate-limited to 10 requests per 10 minutes, so a loop that
134
- * imports many secrets will meet a `RateLimitError`. A project at its limit
135
- * answers 402 — see `usage()`.
133
+ * Creation is rate-limited to 100 per project every 10 minutes, shared by
134
+ * every key and machine working on the project; past it, a `RateLimitError`.
135
+ * A project at its secret limit answers 402 — see `usage()`.
136
136
  */
137
137
  create(params: CreateSecretParams): Promise<SetSecretResponse>;
138
138
  /** Replaces a secret's value, bumps its version, and returns the new value once. */
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.6.0";
12
- export declare const USER_AGENT = "cosmoner-node/1.6.0";
11
+ export declare const VERSION = "1.7.1";
12
+ export declare const USER_AGENT = "cosmoner-node/1.7.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoner/sdk",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Cosmoner SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",