@spooled/sdk 1.0.21 → 1.0.23

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.
@@ -35,7 +35,7 @@ interface CircuitBreakerConfig {
35
35
  type DebugFn = (message: string, meta?: unknown) => void;
36
36
  /** Main SDK configuration options */
37
37
  interface SpooledClientConfig {
38
- /** API key for authentication (starts with sk_live_ or sk_test_) */
38
+ /** API key for authentication (starts with sp_live_, sp_test_, sk_live_, or sk_test_) */
39
39
  apiKey?: string;
40
40
  /** JWT access token (alternative to API key) */
41
41
  accessToken?: string;
@@ -107,11 +107,11 @@ declare const DEFAULT_CONFIG: {
107
107
  successThreshold: number;
108
108
  timeout: number;
109
109
  };
110
- readonly userAgent: "@spooled/sdk-nodejs/1.0.21";
110
+ readonly userAgent: "@spooled/sdk-nodejs/1.0.23";
111
111
  readonly autoRefreshToken: true;
112
112
  };
113
113
  /** SDK version */
114
- declare const SDK_VERSION = "1.0.21";
114
+ declare const SDK_VERSION = "1.0.23";
115
115
  /** API version prefix */
116
116
  declare const API_VERSION = "v1";
117
117
  /**
@@ -584,6 +584,8 @@ interface ListJobsParams extends ListParams {
584
584
  queueName?: string;
585
585
  /** Filter by status */
586
586
  status?: JobStatus;
587
+ /** Filter by a single tag (matches Postgres `tags ? tag` semantics) */
588
+ tag?: string;
587
589
  }
588
590
  /** Job statistics */
589
591
  interface JobStats {
@@ -35,7 +35,7 @@ interface CircuitBreakerConfig {
35
35
  type DebugFn = (message: string, meta?: unknown) => void;
36
36
  /** Main SDK configuration options */
37
37
  interface SpooledClientConfig {
38
- /** API key for authentication (starts with sk_live_ or sk_test_) */
38
+ /** API key for authentication (starts with sp_live_, sp_test_, sk_live_, or sk_test_) */
39
39
  apiKey?: string;
40
40
  /** JWT access token (alternative to API key) */
41
41
  accessToken?: string;
@@ -107,11 +107,11 @@ declare const DEFAULT_CONFIG: {
107
107
  successThreshold: number;
108
108
  timeout: number;
109
109
  };
110
- readonly userAgent: "@spooled/sdk-nodejs/1.0.21";
110
+ readonly userAgent: "@spooled/sdk-nodejs/1.0.23";
111
111
  readonly autoRefreshToken: true;
112
112
  };
113
113
  /** SDK version */
114
- declare const SDK_VERSION = "1.0.21";
114
+ declare const SDK_VERSION = "1.0.23";
115
115
  /** API version prefix */
116
116
  declare const API_VERSION = "v1";
117
117
  /**
@@ -584,6 +584,8 @@ interface ListJobsParams extends ListParams {
584
584
  queueName?: string;
585
585
  /** Filter by status */
586
586
  status?: JobStatus;
587
+ /** Filter by a single tag (matches Postgres `tags ? tag` semantics) */
588
+ tag?: string;
587
589
  }
588
590
  /** Job statistics */
589
591
  interface JobStats {
package/dist/index.cjs CHANGED
@@ -56,10 +56,10 @@ var DEFAULT_CONFIG = {
56
56
  successThreshold: 3,
57
57
  timeout: 3e4
58
58
  },
59
- userAgent: "@spooled/sdk-nodejs/1.0.21",
59
+ userAgent: "@spooled/sdk-nodejs/1.0.23",
60
60
  autoRefreshToken: true
61
61
  };
62
- var SDK_VERSION = "1.0.21";
62
+ var SDK_VERSION = "1.0.23";
63
63
  var API_VERSION = "v1";
64
64
  var API_BASE_PATH = `/api/${API_VERSION}`;
65
65
  function resolveConfig(options) {
@@ -114,9 +114,9 @@ function validateConfig(config) {
114
114
  "SpooledClient requires either apiKey or accessToken for authentication"
115
115
  );
116
116
  }
117
- if (config.apiKey && !config.apiKey.startsWith("sk_")) {
117
+ if (config.apiKey && !config.apiKey.startsWith("sp_") && !config.apiKey.startsWith("sk_")) {
118
118
  throw new Error(
119
- "Invalid API key format. API keys should start with sk_live_ or sk_test_"
119
+ "Invalid API key format. API keys should start with sp_live_, sp_test_, sk_live_, or sk_test_"
120
120
  );
121
121
  }
122
122
  if (!config.baseUrl.startsWith("http://") && !config.baseUrl.startsWith("https://")) {
@@ -2088,16 +2088,33 @@ var SseRealtimeClient = class {
2088
2088
  return;
2089
2089
  }
2090
2090
  this.filter = filter || null;
2091
+ this.setState("connecting");
2092
+ const sseUrl = this.buildSseUrl(filter);
2093
+ this.options.debug(`Connecting to SSE: ${sseUrl}`);
2094
+ let EventSourceImpl;
2095
+ if (typeof EventSource !== "undefined") {
2096
+ EventSourceImpl = EventSource;
2097
+ } else {
2098
+ try {
2099
+ const mod = await import('eventsource');
2100
+ EventSourceImpl = mod.default || mod.EventSource || mod;
2101
+ } catch {
2102
+ this.setState("disconnected");
2103
+ throw new Error("eventsource package is required for SSE in Node.js. Install it with: npm install eventsource");
2104
+ }
2105
+ }
2091
2106
  return new Promise((resolve, reject) => {
2092
- this.setState("connecting");
2093
- const sseUrl = this.buildSseUrl(filter);
2094
- this.options.debug(`Connecting to SSE: ${sseUrl}`);
2095
2107
  try {
2096
- const EventSourceImpl = typeof EventSource !== "undefined" ? EventSource : __require("eventsource");
2108
+ const token = this.options.token;
2097
2109
  this.eventSource = new EventSourceImpl(sseUrl, {
2098
- headers: {
2099
- Authorization: `Bearer ${this.options.token}`
2100
- }
2110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2111
+ fetch: (input, init) => fetch(input, {
2112
+ ...init,
2113
+ headers: {
2114
+ ...init?.headers,
2115
+ Authorization: `Bearer ${token}`
2116
+ }
2117
+ })
2101
2118
  });
2102
2119
  this.eventSource.onopen = () => {
2103
2120
  this.options.debug("SSE connected");
@@ -3033,7 +3050,7 @@ var SpooledWorker = class {
3033
3050
  ...DEFAULT_OPTIONS,
3034
3051
  hostname: os.hostname(),
3035
3052
  workerType: "nodejs",
3036
- version: "1.0.21",
3053
+ version: "1.0.23",
3037
3054
  metadata: {},
3038
3055
  ...options
3039
3056
  };