@spooled/sdk 1.0.27 → 1.0.28

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 (2) hide show
  1. package/README.md +13 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -37,7 +37,7 @@ npm install @spooled/sdk
37
37
  import { SpooledClient } from '@spooled/sdk';
38
38
 
39
39
  const client = new SpooledClient({
40
- apiKey: 'sk_live_your_api_key',
40
+ apiKey: 'sp_live_your_api_key',
41
41
  // For self-hosted: baseUrl: 'https://your-spooled-server.com'
42
42
  });
43
43
 
@@ -116,7 +116,7 @@ Process jobs with the built-in worker runtime:
116
116
  ```typescript
117
117
  import { SpooledClient, SpooledWorker } from '@spooled/sdk';
118
118
 
119
- const client = new SpooledClient({ apiKey: 'sk_live_...' });
119
+ const client = new SpooledClient({ apiKey: 'sp_live_...' });
120
120
 
121
121
  const worker = new SpooledWorker(client, {
122
122
  queueName: 'my-queue',
@@ -293,7 +293,7 @@ const { exists } = await client.auth.checkEmail('user@example.com');
293
293
 
294
294
  // Exchange API key for JWT
295
295
  const { accessToken, refreshToken } = await client.auth.login({
296
- apiKey: 'sk_live_...'
296
+ apiKey: 'sp_live_...'
297
297
  });
298
298
 
299
299
  // Use JWT for subsequent requests
@@ -323,13 +323,15 @@ All operations automatically enforce tier-based limits:
323
323
  When limits are exceeded, you'll receive a `403 Forbidden` response with details:
324
324
 
325
325
  ```typescript
326
+ import { AuthorizationError } from '@spooled/sdk';
327
+
326
328
  try {
327
329
  await client.jobs.create({ /* ... */ });
328
330
  } catch (error) {
329
- if (error.statusCode === 403 && error.code === 'limit_exceeded') {
330
- console.log(`Limit: ${error.message}`);
331
- console.log(`Current: ${error.current}, Max: ${error.limit}`);
332
- console.log(`Upgrade to: ${error.upgradeTo}`);
331
+ if (error instanceof AuthorizationError) {
332
+ // Plan limit reached (HTTP 403); the message describes the limit
333
+ console.log(`Plan limit: ${error.message}`);
334
+ console.log('Details:', error.details);
333
335
  }
334
336
  }
335
337
  ```
@@ -343,7 +345,7 @@ import {
343
345
  NotFoundError,
344
346
  RateLimitError,
345
347
  ValidationError,
346
- LimitExceededError,
348
+ AuthorizationError,
347
349
  isSpooledError,
348
350
  } from '@spooled/sdk';
349
351
 
@@ -352,9 +354,8 @@ try {
352
354
  } catch (error) {
353
355
  if (error instanceof NotFoundError) {
354
356
  console.log('Job not found');
355
- } else if (error instanceof LimitExceededError) {
356
- console.log(`Plan limit: ${error.message}`);
357
- console.log(`Upgrade to ${error.upgradeTo} for more capacity`);
357
+ } else if (error instanceof AuthorizationError) {
358
+ console.log(`Forbidden (e.g. plan limit): ${error.message}`);
358
359
  } else if (error instanceof RateLimitError) {
359
360
  console.log(`Retry after ${error.getRetryAfter()} seconds`);
360
361
  } else if (isSpooledError(error)) {
@@ -375,7 +376,7 @@ import { SpooledGrpcClient } from '@spooled/sdk';
375
376
  // useTls: false if connecting to localhost or direct backend
376
377
  const grpcClient = new SpooledGrpcClient({
377
378
  address: 'grpc.spooled.cloud:443',
378
- apiKey: 'sk_live_your_key',
379
+ apiKey: 'sp_live_your_key',
379
380
  useTls: true
380
381
  });
381
382
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spooled/sdk",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "type": "module",
5
5
  "description": "Official Node.js/TypeScript SDK for Spooled Cloud job queue service",
6
6
  "author": "Spooled Cloud <support@spooled.cloud>",