@spooled/sdk 1.0.10 → 1.0.12
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 +2 -1
- package/dist/{index-4Qr6pGB3.d.cts → index-ZwiiavfA.d.cts} +13 -6
- package/dist/{index-4Qr6pGB3.d.ts → index-ZwiiavfA.d.ts} +13 -6
- package/dist/index.cjs +13 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +1 -1
- package/dist/worker/index.d.ts +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/worker/index.js.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -29,7 +29,8 @@ npm install @spooled/sdk
|
|
|
29
29
|
import { SpooledClient } from '@spooled/sdk';
|
|
30
30
|
|
|
31
31
|
const client = new SpooledClient({
|
|
32
|
-
apiKey: 'sk_live_your_api_key'
|
|
32
|
+
apiKey: 'sk_live_your_api_key',
|
|
33
|
+
// For self-hosted: baseUrl: 'https://your-spooled-server.com'
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
// Create a job
|
|
@@ -43,10 +43,12 @@ interface SpooledClientConfig {
|
|
|
43
43
|
refreshToken?: string;
|
|
44
44
|
/** Admin API key (for /api/v1/admin/* endpoints; uses X-Admin-Key header) */
|
|
45
45
|
adminKey?: string;
|
|
46
|
+
/** Base URL for the REST API (default: https://api.spooled.cloud) */
|
|
47
|
+
baseUrl?: string;
|
|
48
|
+
/** WebSocket URL for realtime events (default: derived from baseUrl, e.g., wss://api.spooled.cloud) */
|
|
49
|
+
wsUrl?: string;
|
|
46
50
|
/** gRPC server address (default: grpc.spooled.cloud:443) */
|
|
47
51
|
grpcAddress?: string;
|
|
48
|
-
/** Base URL for the API (default: https://api.spooled.cloud) */
|
|
49
|
-
baseUrl?: string;
|
|
50
52
|
/** Request timeout in milliseconds (default: 30000) */
|
|
51
53
|
timeout?: number;
|
|
52
54
|
/** Number of retry attempts (shorthand for retry.maxRetries) */
|
|
@@ -74,8 +76,9 @@ interface ResolvedConfig {
|
|
|
74
76
|
accessToken?: string;
|
|
75
77
|
refreshToken?: string;
|
|
76
78
|
adminKey?: string;
|
|
77
|
-
grpcAddress: string;
|
|
78
79
|
baseUrl: string;
|
|
80
|
+
wsUrl: string;
|
|
81
|
+
grpcAddress: string;
|
|
79
82
|
timeout: number;
|
|
80
83
|
retry: RetryConfig;
|
|
81
84
|
circuitBreaker: CircuitBreakerConfig;
|
|
@@ -88,6 +91,7 @@ interface ResolvedConfig {
|
|
|
88
91
|
/** Default configuration values */
|
|
89
92
|
declare const DEFAULT_CONFIG: {
|
|
90
93
|
readonly baseUrl: "https://api.spooled.cloud";
|
|
94
|
+
readonly wsUrl: "wss://api.spooled.cloud";
|
|
91
95
|
readonly grpcAddress: "grpc.spooled.cloud:443";
|
|
92
96
|
readonly timeout: 30000;
|
|
93
97
|
readonly retry: {
|
|
@@ -103,11 +107,11 @@ declare const DEFAULT_CONFIG: {
|
|
|
103
107
|
successThreshold: number;
|
|
104
108
|
timeout: number;
|
|
105
109
|
};
|
|
106
|
-
readonly userAgent: "@spooled/sdk-nodejs/1.0.
|
|
110
|
+
readonly userAgent: "@spooled/sdk-nodejs/1.0.12";
|
|
107
111
|
readonly autoRefreshToken: true;
|
|
108
112
|
};
|
|
109
113
|
/** SDK version */
|
|
110
|
-
declare const SDK_VERSION = "1.0.
|
|
114
|
+
declare const SDK_VERSION = "1.0.12";
|
|
111
115
|
/** API version prefix */
|
|
112
116
|
declare const API_VERSION = "v1";
|
|
113
117
|
/**
|
|
@@ -2150,8 +2154,10 @@ type RealtimeEventData<T extends RealtimeEventType> = Extract<RealtimeEvent, {
|
|
|
2150
2154
|
type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
2151
2155
|
/** Realtime connection options */
|
|
2152
2156
|
interface RealtimeConnectionOptions {
|
|
2153
|
-
/** Base URL for the API */
|
|
2157
|
+
/** Base URL for the REST API (e.g., https://api.spooled.cloud) - used for SSE */
|
|
2154
2158
|
baseUrl: string;
|
|
2159
|
+
/** WebSocket URL for realtime connection (e.g., wss://api.spooled.cloud) - used for WebSocket */
|
|
2160
|
+
wsUrl: string;
|
|
2155
2161
|
/** JWT token for authentication */
|
|
2156
2162
|
token: string;
|
|
2157
2163
|
/** Auto-reconnect on disconnect (default: true) */
|
|
@@ -2194,6 +2200,7 @@ interface SpooledRealtimeOptions {
|
|
|
2194
2200
|
/** Full options including internal fields */
|
|
2195
2201
|
interface FullRealtimeOptions extends SpooledRealtimeOptions {
|
|
2196
2202
|
baseUrl: string;
|
|
2203
|
+
wsUrl: string;
|
|
2197
2204
|
token: string;
|
|
2198
2205
|
debug?: (message: string, meta?: unknown) => void;
|
|
2199
2206
|
}
|
|
@@ -43,10 +43,12 @@ interface SpooledClientConfig {
|
|
|
43
43
|
refreshToken?: string;
|
|
44
44
|
/** Admin API key (for /api/v1/admin/* endpoints; uses X-Admin-Key header) */
|
|
45
45
|
adminKey?: string;
|
|
46
|
+
/** Base URL for the REST API (default: https://api.spooled.cloud) */
|
|
47
|
+
baseUrl?: string;
|
|
48
|
+
/** WebSocket URL for realtime events (default: derived from baseUrl, e.g., wss://api.spooled.cloud) */
|
|
49
|
+
wsUrl?: string;
|
|
46
50
|
/** gRPC server address (default: grpc.spooled.cloud:443) */
|
|
47
51
|
grpcAddress?: string;
|
|
48
|
-
/** Base URL for the API (default: https://api.spooled.cloud) */
|
|
49
|
-
baseUrl?: string;
|
|
50
52
|
/** Request timeout in milliseconds (default: 30000) */
|
|
51
53
|
timeout?: number;
|
|
52
54
|
/** Number of retry attempts (shorthand for retry.maxRetries) */
|
|
@@ -74,8 +76,9 @@ interface ResolvedConfig {
|
|
|
74
76
|
accessToken?: string;
|
|
75
77
|
refreshToken?: string;
|
|
76
78
|
adminKey?: string;
|
|
77
|
-
grpcAddress: string;
|
|
78
79
|
baseUrl: string;
|
|
80
|
+
wsUrl: string;
|
|
81
|
+
grpcAddress: string;
|
|
79
82
|
timeout: number;
|
|
80
83
|
retry: RetryConfig;
|
|
81
84
|
circuitBreaker: CircuitBreakerConfig;
|
|
@@ -88,6 +91,7 @@ interface ResolvedConfig {
|
|
|
88
91
|
/** Default configuration values */
|
|
89
92
|
declare const DEFAULT_CONFIG: {
|
|
90
93
|
readonly baseUrl: "https://api.spooled.cloud";
|
|
94
|
+
readonly wsUrl: "wss://api.spooled.cloud";
|
|
91
95
|
readonly grpcAddress: "grpc.spooled.cloud:443";
|
|
92
96
|
readonly timeout: 30000;
|
|
93
97
|
readonly retry: {
|
|
@@ -103,11 +107,11 @@ declare const DEFAULT_CONFIG: {
|
|
|
103
107
|
successThreshold: number;
|
|
104
108
|
timeout: number;
|
|
105
109
|
};
|
|
106
|
-
readonly userAgent: "@spooled/sdk-nodejs/1.0.
|
|
110
|
+
readonly userAgent: "@spooled/sdk-nodejs/1.0.12";
|
|
107
111
|
readonly autoRefreshToken: true;
|
|
108
112
|
};
|
|
109
113
|
/** SDK version */
|
|
110
|
-
declare const SDK_VERSION = "1.0.
|
|
114
|
+
declare const SDK_VERSION = "1.0.12";
|
|
111
115
|
/** API version prefix */
|
|
112
116
|
declare const API_VERSION = "v1";
|
|
113
117
|
/**
|
|
@@ -2150,8 +2154,10 @@ type RealtimeEventData<T extends RealtimeEventType> = Extract<RealtimeEvent, {
|
|
|
2150
2154
|
type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
2151
2155
|
/** Realtime connection options */
|
|
2152
2156
|
interface RealtimeConnectionOptions {
|
|
2153
|
-
/** Base URL for the API */
|
|
2157
|
+
/** Base URL for the REST API (e.g., https://api.spooled.cloud) - used for SSE */
|
|
2154
2158
|
baseUrl: string;
|
|
2159
|
+
/** WebSocket URL for realtime connection (e.g., wss://api.spooled.cloud) - used for WebSocket */
|
|
2160
|
+
wsUrl: string;
|
|
2155
2161
|
/** JWT token for authentication */
|
|
2156
2162
|
token: string;
|
|
2157
2163
|
/** Auto-reconnect on disconnect (default: true) */
|
|
@@ -2194,6 +2200,7 @@ interface SpooledRealtimeOptions {
|
|
|
2194
2200
|
/** Full options including internal fields */
|
|
2195
2201
|
interface FullRealtimeOptions extends SpooledRealtimeOptions {
|
|
2196
2202
|
baseUrl: string;
|
|
2203
|
+
wsUrl: string;
|
|
2197
2204
|
token: string;
|
|
2198
2205
|
debug?: (message: string, meta?: unknown) => void;
|
|
2199
2206
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
40
40
|
// src/config.ts
|
|
41
41
|
var DEFAULT_CONFIG = {
|
|
42
42
|
baseUrl: "https://api.spooled.cloud",
|
|
43
|
+
wsUrl: "wss://api.spooled.cloud",
|
|
43
44
|
grpcAddress: "grpc.spooled.cloud:443",
|
|
44
45
|
timeout: 3e4,
|
|
45
46
|
retry: {
|
|
@@ -55,10 +56,10 @@ var DEFAULT_CONFIG = {
|
|
|
55
56
|
successThreshold: 3,
|
|
56
57
|
timeout: 3e4
|
|
57
58
|
},
|
|
58
|
-
userAgent: "@spooled/sdk-nodejs/1.0.
|
|
59
|
+
userAgent: "@spooled/sdk-nodejs/1.0.12",
|
|
59
60
|
autoRefreshToken: true
|
|
60
61
|
};
|
|
61
|
-
var SDK_VERSION = "1.0.
|
|
62
|
+
var SDK_VERSION = "1.0.12";
|
|
62
63
|
var API_VERSION = "v1";
|
|
63
64
|
var API_BASE_PATH = `/api/${API_VERSION}`;
|
|
64
65
|
function resolveConfig(options) {
|
|
@@ -86,13 +87,17 @@ function resolveConfig(options) {
|
|
|
86
87
|
Accept: "application/json",
|
|
87
88
|
...options.headers
|
|
88
89
|
};
|
|
90
|
+
const baseUrl = options.baseUrl ?? DEFAULT_CONFIG.baseUrl;
|
|
91
|
+
const derivedWsUrl = baseUrl.replace(/^http/, "ws");
|
|
92
|
+
const wsUrl = options.wsUrl ?? derivedWsUrl;
|
|
89
93
|
return {
|
|
90
94
|
apiKey: options.apiKey,
|
|
91
95
|
accessToken: options.accessToken,
|
|
92
96
|
refreshToken: options.refreshToken,
|
|
93
97
|
adminKey: options.adminKey,
|
|
98
|
+
baseUrl,
|
|
99
|
+
wsUrl,
|
|
94
100
|
grpcAddress: options.grpcAddress ?? DEFAULT_CONFIG.grpcAddress,
|
|
95
|
-
baseUrl: options.baseUrl ?? DEFAULT_CONFIG.baseUrl,
|
|
96
101
|
timeout: options.timeout ?? DEFAULT_CONFIG.timeout,
|
|
97
102
|
retry,
|
|
98
103
|
circuitBreaker,
|
|
@@ -1832,8 +1837,8 @@ var WebSocketRealtimeClient = class {
|
|
|
1832
1837
|
}
|
|
1833
1838
|
// Private methods
|
|
1834
1839
|
buildWsUrl() {
|
|
1835
|
-
const
|
|
1836
|
-
return `${
|
|
1840
|
+
const wsBase = this.options.wsUrl;
|
|
1841
|
+
return `${wsBase}/api/v1/ws?token=${encodeURIComponent(this.options.token)}`;
|
|
1837
1842
|
}
|
|
1838
1843
|
setState(state) {
|
|
1839
1844
|
if (this.state !== state) {
|
|
@@ -2155,6 +2160,7 @@ var SpooledRealtime = class {
|
|
|
2155
2160
|
constructor(options) {
|
|
2156
2161
|
const connectionOptions = {
|
|
2157
2162
|
baseUrl: options.baseUrl,
|
|
2163
|
+
wsUrl: options.wsUrl,
|
|
2158
2164
|
token: options.token,
|
|
2159
2165
|
autoReconnect: options.autoReconnect,
|
|
2160
2166
|
maxReconnectAttempts: options.maxReconnectAttempts,
|
|
@@ -2732,6 +2738,7 @@ var SpooledClient = class _SpooledClient {
|
|
|
2732
2738
|
const token = await this.getJwtToken();
|
|
2733
2739
|
return new SpooledRealtime({
|
|
2734
2740
|
baseUrl: this.config.baseUrl,
|
|
2741
|
+
wsUrl: this.config.wsUrl,
|
|
2735
2742
|
token,
|
|
2736
2743
|
...options,
|
|
2737
2744
|
debug: this.config.debug ?? void 0
|
|
@@ -2933,7 +2940,7 @@ var SpooledWorker = class {
|
|
|
2933
2940
|
...DEFAULT_OPTIONS,
|
|
2934
2941
|
hostname: os.hostname(),
|
|
2935
2942
|
workerType: "nodejs",
|
|
2936
|
-
version: "1.0.
|
|
2943
|
+
version: "1.0.12",
|
|
2937
2944
|
metadata: {},
|
|
2938
2945
|
...options
|
|
2939
2946
|
};
|