@tthr/server 0.0.4 → 0.0.6
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/dist/index.d.ts +260 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +502 -2
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
package/dist/index.d.ts
CHANGED
|
@@ -12,33 +12,58 @@ export interface AuthContext {
|
|
|
12
12
|
claims: Record<string, unknown>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Table operations interface
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
18
|
-
findMany: (options?:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
export interface TableOperations<T = unknown> {
|
|
18
|
+
findMany: (options?: {
|
|
19
|
+
where?: Partial<T>;
|
|
20
|
+
orderBy?: Partial<Record<keyof T, 'asc' | 'desc'>>;
|
|
21
|
+
limit?: number;
|
|
22
|
+
offset?: number;
|
|
23
|
+
}) => Promise<T[]>;
|
|
24
|
+
findFirst: (options?: {
|
|
25
|
+
where?: Partial<T>;
|
|
26
|
+
orderBy?: Partial<Record<keyof T, 'asc' | 'desc'>>;
|
|
27
|
+
}) => Promise<T | null>;
|
|
28
|
+
findUnique: (options?: {
|
|
29
|
+
where?: Partial<T>;
|
|
30
|
+
}) => Promise<T | null>;
|
|
31
|
+
findById: (id: unknown) => Promise<T | null>;
|
|
32
|
+
count: (options?: {
|
|
33
|
+
where?: Partial<T>;
|
|
34
|
+
}) => Promise<number>;
|
|
35
|
+
insert: (data: T) => Promise<T>;
|
|
36
|
+
insertMany: (data: T[]) => Promise<T[]>;
|
|
25
37
|
create: (options: {
|
|
26
|
-
data:
|
|
27
|
-
}) => Promise<
|
|
38
|
+
data: T;
|
|
39
|
+
}) => Promise<T>;
|
|
28
40
|
update: (options: {
|
|
29
|
-
where:
|
|
30
|
-
data:
|
|
41
|
+
where: Partial<T>;
|
|
42
|
+
data: Partial<T>;
|
|
31
43
|
}) => Promise<number>;
|
|
32
44
|
upsert: (options: {
|
|
33
|
-
where:
|
|
34
|
-
create:
|
|
35
|
-
update:
|
|
36
|
-
}) => Promise<
|
|
45
|
+
where: Partial<T>;
|
|
46
|
+
create: T;
|
|
47
|
+
update: Partial<T>;
|
|
48
|
+
}) => Promise<T>;
|
|
37
49
|
delete: (options: {
|
|
38
|
-
where:
|
|
50
|
+
where: Partial<T>;
|
|
39
51
|
}) => Promise<number>;
|
|
40
52
|
deleteById: (id: unknown) => Promise<boolean>;
|
|
41
|
-
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Database client type - represents the generated db object
|
|
56
|
+
* Can be used with a schema type for full type safety:
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import type { Schema } from '~/tether/_generated/db';
|
|
61
|
+
* type DB = DatabaseClient<Schema>;
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export type DatabaseClient<TSchema = Record<string, unknown>> = {
|
|
65
|
+
[K in keyof TSchema]: TableOperations<TSchema[K]>;
|
|
66
|
+
};
|
|
42
67
|
/**
|
|
43
68
|
* Tether context for actions - provides access to queries, mutations, and env vars
|
|
44
69
|
*/
|
|
@@ -71,47 +96,47 @@ export interface ExecutionCtx {
|
|
|
71
96
|
/**
|
|
72
97
|
* Base handler context (without args) for queries/mutations with no arguments
|
|
73
98
|
*/
|
|
74
|
-
export interface BaseHandlerContext {
|
|
99
|
+
export interface BaseHandlerContext<TSchema = Record<string, unknown>> {
|
|
75
100
|
/** Database client for the project */
|
|
76
|
-
db: DatabaseClient
|
|
101
|
+
db: DatabaseClient<TSchema>;
|
|
77
102
|
/** Execution context with auth info */
|
|
78
103
|
ctx: ExecutionCtx;
|
|
79
104
|
}
|
|
80
105
|
/**
|
|
81
106
|
* Query/Mutation handler context with typed args
|
|
82
107
|
*/
|
|
83
|
-
export type FunctionHandlerContext<TArgs
|
|
108
|
+
export type FunctionHandlerContext<TArgs, TSchema = Record<string, unknown>> = TArgs extends void ? BaseHandlerContext<TSchema> : BaseHandlerContext<TSchema> & {
|
|
84
109
|
args: TArgs;
|
|
85
110
|
};
|
|
86
111
|
/**
|
|
87
112
|
* Action handler context with typed args
|
|
88
113
|
*/
|
|
89
|
-
export type ActionHandlerCtx<TArgs
|
|
114
|
+
export type ActionHandlerCtx<TArgs, TSchema = Record<string, unknown>> = TArgs extends void ? BaseHandlerContext<TSchema> & {
|
|
90
115
|
tether: TetherContext;
|
|
91
|
-
} : BaseHandlerContext & {
|
|
116
|
+
} : BaseHandlerContext<TSchema> & {
|
|
92
117
|
args: TArgs;
|
|
93
118
|
tether: TetherContext;
|
|
94
119
|
};
|
|
95
120
|
/**
|
|
96
121
|
* Query function definition
|
|
97
122
|
*/
|
|
98
|
-
export interface QueryDefinition<TArgs, TResult
|
|
123
|
+
export interface QueryDefinition<TArgs, TResult, TSchema = Record<string, unknown>> {
|
|
99
124
|
args?: ZodType<TArgs>;
|
|
100
|
-
handler: (context: FunctionHandlerContext<TArgs>) => Promise<TResult> | TResult;
|
|
125
|
+
handler: (context: FunctionHandlerContext<TArgs, TSchema>) => Promise<TResult> | TResult;
|
|
101
126
|
}
|
|
102
127
|
/**
|
|
103
128
|
* Mutation function definition
|
|
104
129
|
*/
|
|
105
|
-
export interface MutationDefinition<TArgs, TResult
|
|
130
|
+
export interface MutationDefinition<TArgs, TResult, TSchema = Record<string, unknown>> {
|
|
106
131
|
args?: ZodType<TArgs>;
|
|
107
|
-
handler: (context: FunctionHandlerContext<TArgs>) => Promise<TResult> | TResult;
|
|
132
|
+
handler: (context: FunctionHandlerContext<TArgs, TSchema>) => Promise<TResult> | TResult;
|
|
108
133
|
}
|
|
109
134
|
/**
|
|
110
135
|
* Action function definition
|
|
111
136
|
*/
|
|
112
|
-
export interface ActionDefinition<TArgs, TResult
|
|
137
|
+
export interface ActionDefinition<TArgs, TResult, TSchema = Record<string, unknown>> {
|
|
113
138
|
args?: ZodType<TArgs>;
|
|
114
|
-
handler: (context: ActionHandlerCtx<TArgs>) => Promise<TResult> | TResult;
|
|
139
|
+
handler: (context: ActionHandlerCtx<TArgs, TSchema>) => Promise<TResult> | TResult;
|
|
115
140
|
}
|
|
116
141
|
/**
|
|
117
142
|
* Define a query function
|
|
@@ -142,7 +167,7 @@ export interface ActionDefinition<TArgs, TResult> {
|
|
|
142
167
|
* });
|
|
143
168
|
* ```
|
|
144
169
|
*/
|
|
145
|
-
export declare function query<TArgs = void, TResult = unknown
|
|
170
|
+
export declare function query<TArgs = void, TResult = unknown, TSchema = Record<string, unknown>>(definition: QueryDefinition<TArgs, TResult, TSchema>): QueryDefinition<TArgs, TResult, TSchema>;
|
|
146
171
|
/**
|
|
147
172
|
* Define a mutation function
|
|
148
173
|
*
|
|
@@ -171,7 +196,7 @@ export declare function query<TArgs = void, TResult = unknown>(definition: Query
|
|
|
171
196
|
* });
|
|
172
197
|
* ```
|
|
173
198
|
*/
|
|
174
|
-
export declare function mutation<TArgs = void, TResult = unknown
|
|
199
|
+
export declare function mutation<TArgs = void, TResult = unknown, TSchema = Record<string, unknown>>(definition: MutationDefinition<TArgs, TResult, TSchema>): MutationDefinition<TArgs, TResult, TSchema>;
|
|
175
200
|
/**
|
|
176
201
|
* Define an action function
|
|
177
202
|
*
|
|
@@ -203,17 +228,26 @@ export declare function mutation<TArgs = void, TResult = unknown>(definition: Mu
|
|
|
203
228
|
* });
|
|
204
229
|
* ```
|
|
205
230
|
*/
|
|
206
|
-
export declare function action<TArgs = void, TResult = unknown
|
|
231
|
+
export declare function action<TArgs = void, TResult = unknown, TSchema = Record<string, unknown>>(definition: ActionDefinition<TArgs, TResult, TSchema>): ActionDefinition<TArgs, TResult, TSchema>;
|
|
207
232
|
/**
|
|
208
233
|
* Server-side Tether client for direct function calls
|
|
209
234
|
*/
|
|
210
235
|
export interface ServerClientOptions {
|
|
211
236
|
url: string;
|
|
237
|
+
/** Project ID */
|
|
238
|
+
projectId: string;
|
|
239
|
+
/** Environment name (defaults to 'production') */
|
|
240
|
+
environment?: string;
|
|
241
|
+
/** API key for authentication */
|
|
212
242
|
apiKey: string;
|
|
213
243
|
}
|
|
214
244
|
export declare class TetherServerClient {
|
|
215
245
|
private options;
|
|
216
246
|
constructor(options: ServerClientOptions);
|
|
247
|
+
/**
|
|
248
|
+
* Get the base URL for API calls
|
|
249
|
+
*/
|
|
250
|
+
private getBaseUrl;
|
|
217
251
|
/**
|
|
218
252
|
* Execute a query function
|
|
219
253
|
*/
|
|
@@ -227,5 +261,198 @@ export declare class TetherServerClient {
|
|
|
227
261
|
* Create a server-side Tether client
|
|
228
262
|
*/
|
|
229
263
|
export declare function createClient(options: ServerClientOptions): TetherServerClient;
|
|
264
|
+
/**
|
|
265
|
+
* Runtime configuration
|
|
266
|
+
*/
|
|
267
|
+
export interface TetherRuntimeConfig {
|
|
268
|
+
/** Tether API URL */
|
|
269
|
+
url: string;
|
|
270
|
+
/** Project ID */
|
|
271
|
+
projectId: string;
|
|
272
|
+
/** Environment name (defaults to 'production') */
|
|
273
|
+
environment?: string;
|
|
274
|
+
/** API key or auth token */
|
|
275
|
+
apiKey?: string;
|
|
276
|
+
/** Auth token function (for user context) */
|
|
277
|
+
authToken?: string | (() => string | Promise<string>);
|
|
278
|
+
/** Whether to send logs to Tether (default: true in production) */
|
|
279
|
+
enableLogging?: boolean;
|
|
280
|
+
/** Batch size before flushing logs (default: 10) */
|
|
281
|
+
batchSize?: number;
|
|
282
|
+
/** Flush interval in ms (default: 5000) */
|
|
283
|
+
flushInterval?: number;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Initialise the Tether runtime
|
|
287
|
+
*
|
|
288
|
+
* Call this once at app startup to enable console capture and logging.
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```ts
|
|
292
|
+
* // In your Nuxt plugin or app entry
|
|
293
|
+
* import { initTetherRuntime } from '@tthr/server';
|
|
294
|
+
*
|
|
295
|
+
* initTetherRuntime({
|
|
296
|
+
* url: process.env.TETHER_URL!,
|
|
297
|
+
* projectId: process.env.TETHER_PROJECT_ID!,
|
|
298
|
+
* apiKey: process.env.TETHER_API_KEY,
|
|
299
|
+
* });
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
export declare function initTetherRuntime(config: TetherRuntimeConfig): void;
|
|
303
|
+
/**
|
|
304
|
+
* Get the current runtime config
|
|
305
|
+
*/
|
|
306
|
+
export declare function getRuntimeConfig(): TetherRuntimeConfig | null;
|
|
307
|
+
/**
|
|
308
|
+
* Execute a function with Tether console capture
|
|
309
|
+
*
|
|
310
|
+
* Wraps the function execution to capture all console.* calls and send them
|
|
311
|
+
* to Tether for dashboard visibility.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* // In your Nuxt server route
|
|
316
|
+
* import { executeWithLogging } from '@tthr/server';
|
|
317
|
+
* import { list } from '~/tether/functions/posts';
|
|
318
|
+
*
|
|
319
|
+
* export default defineEventHandler(async (event) => {
|
|
320
|
+
* return executeWithLogging('posts.list', async (ctx) => {
|
|
321
|
+
* return list.handler(ctx);
|
|
322
|
+
* }, { db, ctx });
|
|
323
|
+
* });
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
export declare function executeWithLogging<TResult>(functionName: string, fn: () => Promise<TResult> | TResult): Promise<TResult>;
|
|
327
|
+
/**
|
|
328
|
+
* Manually flush any pending logs
|
|
329
|
+
*
|
|
330
|
+
* Call this before your server shuts down to ensure all logs are sent.
|
|
331
|
+
*/
|
|
332
|
+
export declare function flushTetherLogs(): Promise<void>;
|
|
230
333
|
export { z };
|
|
334
|
+
/**
|
|
335
|
+
* Cron trigger message from Tether server
|
|
336
|
+
*/
|
|
337
|
+
export interface CronTriggerMessage {
|
|
338
|
+
type: 'cron_trigger';
|
|
339
|
+
executionId: string;
|
|
340
|
+
cronId: string;
|
|
341
|
+
functionName: string;
|
|
342
|
+
functionType: 'query' | 'mutation' | 'action';
|
|
343
|
+
args?: unknown;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Cron handler function type
|
|
347
|
+
*/
|
|
348
|
+
export type CronHandler = (functionName: string, args: unknown) => Promise<{
|
|
349
|
+
success: boolean;
|
|
350
|
+
result?: unknown;
|
|
351
|
+
error?: string;
|
|
352
|
+
}>;
|
|
353
|
+
/**
|
|
354
|
+
* Options for TetherCronConnection
|
|
355
|
+
*/
|
|
356
|
+
export interface TetherCronConnectionOptions {
|
|
357
|
+
/** Tether API URL */
|
|
358
|
+
url: string;
|
|
359
|
+
/** Project ID */
|
|
360
|
+
projectId: string;
|
|
361
|
+
/** Environment name (defaults to 'production') */
|
|
362
|
+
environment?: string;
|
|
363
|
+
/** API key for authentication */
|
|
364
|
+
apiKey: string;
|
|
365
|
+
/** Handler function for cron triggers */
|
|
366
|
+
onCronTrigger: CronHandler;
|
|
367
|
+
/** Called when connection is established */
|
|
368
|
+
onConnected?: () => void;
|
|
369
|
+
/** Called when connection is closed */
|
|
370
|
+
onDisconnected?: () => void;
|
|
371
|
+
/** Called on connection error */
|
|
372
|
+
onError?: (error: Error) => void;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Server-side WebSocket connection for receiving cron triggers.
|
|
376
|
+
*
|
|
377
|
+
* This connects to Tether with `?type=server` to identify as a server connection.
|
|
378
|
+
* Only server connections receive cron triggers - client connections do not.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* import { TetherCronConnection } from '@tthr/server';
|
|
383
|
+
*
|
|
384
|
+
* const cronConnection = new TetherCronConnection({
|
|
385
|
+
* url: process.env.TETHER_URL!,
|
|
386
|
+
* projectId: process.env.TETHER_PROJECT_ID!,
|
|
387
|
+
* apiKey: process.env.TETHER_API_KEY!,
|
|
388
|
+
* onCronTrigger: async (functionName, args) => {
|
|
389
|
+
* // Execute your function here
|
|
390
|
+
* try {
|
|
391
|
+
* const result = await executeFunction(functionName, args);
|
|
392
|
+
* return { success: true, result };
|
|
393
|
+
* } catch (error) {
|
|
394
|
+
* return { success: false, error: error.message };
|
|
395
|
+
* }
|
|
396
|
+
* },
|
|
397
|
+
* });
|
|
398
|
+
*
|
|
399
|
+
* await cronConnection.connect();
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
export declare class TetherCronConnection {
|
|
403
|
+
private options;
|
|
404
|
+
private ws;
|
|
405
|
+
private connectionId;
|
|
406
|
+
private reconnectAttempts;
|
|
407
|
+
private maxReconnectAttempts;
|
|
408
|
+
private reconnectDelay;
|
|
409
|
+
private isConnecting;
|
|
410
|
+
private shouldReconnect;
|
|
411
|
+
private heartbeatInterval;
|
|
412
|
+
private heartbeatTimeout;
|
|
413
|
+
private heartbeatTimer;
|
|
414
|
+
private heartbeatTimeoutTimer;
|
|
415
|
+
private awaitingPong;
|
|
416
|
+
constructor(options: TetherCronConnectionOptions);
|
|
417
|
+
/**
|
|
418
|
+
* Get the WebSocket URL with server type parameter
|
|
419
|
+
*/
|
|
420
|
+
private getWsUrl;
|
|
421
|
+
/**
|
|
422
|
+
* Connect to Tether server
|
|
423
|
+
*/
|
|
424
|
+
connect(): Promise<void>;
|
|
425
|
+
/**
|
|
426
|
+
* Handle incoming WebSocket message
|
|
427
|
+
*/
|
|
428
|
+
private handleMessage;
|
|
429
|
+
/**
|
|
430
|
+
* Handle a cron trigger message
|
|
431
|
+
*/
|
|
432
|
+
private handleCronTrigger;
|
|
433
|
+
/**
|
|
434
|
+
* Report execution result back to Tether
|
|
435
|
+
*/
|
|
436
|
+
private reportExecution;
|
|
437
|
+
/**
|
|
438
|
+
* Start heartbeat timer
|
|
439
|
+
*/
|
|
440
|
+
private startHeartbeat;
|
|
441
|
+
/**
|
|
442
|
+
* Stop heartbeat timer
|
|
443
|
+
*/
|
|
444
|
+
private stopHeartbeat;
|
|
445
|
+
/**
|
|
446
|
+
* Handle reconnection
|
|
447
|
+
*/
|
|
448
|
+
private handleReconnect;
|
|
449
|
+
/**
|
|
450
|
+
* Disconnect from Tether
|
|
451
|
+
*/
|
|
452
|
+
disconnect(): void;
|
|
453
|
+
/**
|
|
454
|
+
* Check if connected
|
|
455
|
+
*/
|
|
456
|
+
get isConnected(): boolean;
|
|
457
|
+
}
|
|
231
458
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CA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B,iCAAiC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,oBAAoB,CAAM;IAClC,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAAQ;IAG/B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,cAAc,CAA+C;IACrE,OAAO,CAAC,qBAAqB,CAA8C;IAC3E,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE,2BAA2B;IAIhD;;OAEG;IACH,OAAO,CAAC,QAAQ;IAmBhB;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqD9B;;OAEG;YACW,aAAa;IAmC3B;;OAEG;YACW,iBAAiB;IAuB/B;;OAEG;YACW,eAAe;IA2C7B;;OAEG;IACH,OAAO,CAAC,cAAc;IAkBtB;;OAEG;IACH,OAAO,CAAC,aAAa;IAYrB;;OAEG;IACH,OAAO,CAAC,eAAe;IAsBvB;;OAEG;IACH,UAAU,IAAI,IAAI;IAUlB;;OAEG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;CACF"}
|
package/dist/index.js
CHANGED
|
@@ -106,11 +106,23 @@ export class TetherServerClient {
|
|
|
106
106
|
constructor(options) {
|
|
107
107
|
this.options = options;
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the base URL for API calls
|
|
111
|
+
*/
|
|
112
|
+
getBaseUrl() {
|
|
113
|
+
const base = this.options.url.replace(/\/$/, '');
|
|
114
|
+
const env = this.options.environment;
|
|
115
|
+
// Only include /env/{env} if not production (production is the default)
|
|
116
|
+
if (env && env !== 'production') {
|
|
117
|
+
return `${base}/api/v1/projects/${this.options.projectId}/env/${env}`;
|
|
118
|
+
}
|
|
119
|
+
return `${base}/api/v1/projects/${this.options.projectId}`;
|
|
120
|
+
}
|
|
109
121
|
/**
|
|
110
122
|
* Execute a query function
|
|
111
123
|
*/
|
|
112
124
|
async query(name, args) {
|
|
113
|
-
const response = await fetch(`${this.
|
|
125
|
+
const response = await fetch(`${this.getBaseUrl()}/query`, {
|
|
114
126
|
method: 'POST',
|
|
115
127
|
headers: {
|
|
116
128
|
'Content-Type': 'application/json',
|
|
@@ -129,7 +141,7 @@ export class TetherServerClient {
|
|
|
129
141
|
* Execute a mutation function
|
|
130
142
|
*/
|
|
131
143
|
async mutation(name, args) {
|
|
132
|
-
const response = await fetch(`${this.
|
|
144
|
+
const response = await fetch(`${this.getBaseUrl()}/mutation`, {
|
|
133
145
|
method: 'POST',
|
|
134
146
|
headers: {
|
|
135
147
|
'Content-Type': 'application/json',
|
|
@@ -151,6 +163,494 @@ export class TetherServerClient {
|
|
|
151
163
|
export function createClient(options) {
|
|
152
164
|
return new TetherServerClient(options);
|
|
153
165
|
}
|
|
166
|
+
// Global runtime instance
|
|
167
|
+
let _runtimeConfig = null;
|
|
168
|
+
let _logBuffer = [];
|
|
169
|
+
let _flushTimer = null;
|
|
170
|
+
/**
|
|
171
|
+
* Initialise the Tether runtime
|
|
172
|
+
*
|
|
173
|
+
* Call this once at app startup to enable console capture and logging.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* // In your Nuxt plugin or app entry
|
|
178
|
+
* import { initTetherRuntime } from '@tthr/server';
|
|
179
|
+
*
|
|
180
|
+
* initTetherRuntime({
|
|
181
|
+
* url: process.env.TETHER_URL!,
|
|
182
|
+
* projectId: process.env.TETHER_PROJECT_ID!,
|
|
183
|
+
* apiKey: process.env.TETHER_API_KEY,
|
|
184
|
+
* });
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export function initTetherRuntime(config) {
|
|
188
|
+
_runtimeConfig = {
|
|
189
|
+
enableLogging: process.env.NODE_ENV === 'production',
|
|
190
|
+
batchSize: 10,
|
|
191
|
+
flushInterval: 5000,
|
|
192
|
+
...config,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get the current runtime config
|
|
197
|
+
*/
|
|
198
|
+
export function getRuntimeConfig() {
|
|
199
|
+
return _runtimeConfig;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Flush pending logs to Tether
|
|
203
|
+
*/
|
|
204
|
+
async function flushLogs() {
|
|
205
|
+
if (!_runtimeConfig || _logBuffer.length === 0)
|
|
206
|
+
return;
|
|
207
|
+
const logs = _logBuffer.splice(0, _logBuffer.length);
|
|
208
|
+
try {
|
|
209
|
+
const token = typeof _runtimeConfig.authToken === 'function'
|
|
210
|
+
? await _runtimeConfig.authToken()
|
|
211
|
+
: _runtimeConfig.authToken ?? _runtimeConfig.apiKey;
|
|
212
|
+
// Build URL with optional environment
|
|
213
|
+
const base = _runtimeConfig.url.replace(/\/$/, '');
|
|
214
|
+
const env = _runtimeConfig.environment;
|
|
215
|
+
const baseUrl = env && env !== 'production'
|
|
216
|
+
? `${base}/api/v1/projects/${_runtimeConfig.projectId}/env/${env}`
|
|
217
|
+
: `${base}/api/v1/projects/${_runtimeConfig.projectId}`;
|
|
218
|
+
const response = await fetch(`${baseUrl}/logs`, {
|
|
219
|
+
method: 'POST',
|
|
220
|
+
headers: {
|
|
221
|
+
'Content-Type': 'application/json',
|
|
222
|
+
...(token ? { 'Authorization': `Bearer ${token}` } : {}),
|
|
223
|
+
},
|
|
224
|
+
body: JSON.stringify({ logs }),
|
|
225
|
+
});
|
|
226
|
+
if (!response.ok) {
|
|
227
|
+
// Re-add logs on failure (with limit to prevent memory issues)
|
|
228
|
+
if (_logBuffer.length < 1000) {
|
|
229
|
+
_logBuffer.unshift(...logs);
|
|
230
|
+
}
|
|
231
|
+
console.error('[Tether] Failed to send logs:', response.statusText);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
// Re-add logs on failure
|
|
236
|
+
if (_logBuffer.length < 1000) {
|
|
237
|
+
_logBuffer.unshift(...logs);
|
|
238
|
+
}
|
|
239
|
+
console.error('[Tether] Failed to send logs:', error);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Schedule a flush of logs
|
|
244
|
+
*/
|
|
245
|
+
function scheduleFlush() {
|
|
246
|
+
if (_flushTimer)
|
|
247
|
+
return;
|
|
248
|
+
_flushTimer = setTimeout(() => {
|
|
249
|
+
_flushTimer = null;
|
|
250
|
+
flushLogs();
|
|
251
|
+
}, _runtimeConfig?.flushInterval ?? 5000);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Add a log entry to the buffer
|
|
255
|
+
*/
|
|
256
|
+
function addLog(entry) {
|
|
257
|
+
if (!_runtimeConfig?.enableLogging)
|
|
258
|
+
return;
|
|
259
|
+
_logBuffer.push(entry);
|
|
260
|
+
// Flush if batch size reached
|
|
261
|
+
if (_logBuffer.length >= (_runtimeConfig.batchSize ?? 10)) {
|
|
262
|
+
flushLogs();
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
scheduleFlush();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Create a wrapped console that captures logs for a specific function execution
|
|
270
|
+
*/
|
|
271
|
+
function createTetherConsole(functionName, executionId) {
|
|
272
|
+
const originalConsole = globalThis.console;
|
|
273
|
+
const createMethod = (level) => {
|
|
274
|
+
return (...args) => {
|
|
275
|
+
// Still call original console
|
|
276
|
+
originalConsole[level](...args);
|
|
277
|
+
// Capture for Tether
|
|
278
|
+
const message = args
|
|
279
|
+
.map(arg => typeof arg === 'string' ? arg : JSON.stringify(arg))
|
|
280
|
+
.join(' ');
|
|
281
|
+
// Extract structured data if first arg is an object
|
|
282
|
+
const data = args.length === 1 && typeof args[0] === 'object' && args[0] !== null
|
|
283
|
+
? args[0]
|
|
284
|
+
: args.length > 1
|
|
285
|
+
? args
|
|
286
|
+
: undefined;
|
|
287
|
+
addLog({
|
|
288
|
+
function: functionName,
|
|
289
|
+
level,
|
|
290
|
+
message,
|
|
291
|
+
data,
|
|
292
|
+
execution_id: executionId,
|
|
293
|
+
timestamp: new Date().toISOString(),
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
// Create a proxy that wraps console methods
|
|
298
|
+
return new Proxy(originalConsole, {
|
|
299
|
+
get(target, prop) {
|
|
300
|
+
if (prop === 'log')
|
|
301
|
+
return createMethod('log');
|
|
302
|
+
if (prop === 'info')
|
|
303
|
+
return createMethod('info');
|
|
304
|
+
if (prop === 'warn')
|
|
305
|
+
return createMethod('warn');
|
|
306
|
+
if (prop === 'error')
|
|
307
|
+
return createMethod('error');
|
|
308
|
+
if (prop === 'debug')
|
|
309
|
+
return createMethod('debug');
|
|
310
|
+
return target[prop];
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Generate a unique execution ID
|
|
316
|
+
*/
|
|
317
|
+
function generateExecutionId() {
|
|
318
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Execute a function with Tether console capture
|
|
322
|
+
*
|
|
323
|
+
* Wraps the function execution to capture all console.* calls and send them
|
|
324
|
+
* to Tether for dashboard visibility.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* // In your Nuxt server route
|
|
329
|
+
* import { executeWithLogging } from '@tthr/server';
|
|
330
|
+
* import { list } from '~/tether/functions/posts';
|
|
331
|
+
*
|
|
332
|
+
* export default defineEventHandler(async (event) => {
|
|
333
|
+
* return executeWithLogging('posts.list', async (ctx) => {
|
|
334
|
+
* return list.handler(ctx);
|
|
335
|
+
* }, { db, ctx });
|
|
336
|
+
* });
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
export async function executeWithLogging(functionName, fn) {
|
|
340
|
+
const executionId = generateExecutionId();
|
|
341
|
+
const tetherConsole = createTetherConsole(functionName, executionId);
|
|
342
|
+
// Store original console
|
|
343
|
+
const originalConsole = globalThis.console;
|
|
344
|
+
try {
|
|
345
|
+
// Replace global console
|
|
346
|
+
globalThis.console = tetherConsole;
|
|
347
|
+
// Execute function
|
|
348
|
+
const result = await fn();
|
|
349
|
+
return result;
|
|
350
|
+
}
|
|
351
|
+
catch (error) {
|
|
352
|
+
// Log the error
|
|
353
|
+
tetherConsole.error(error instanceof Error ? error.message : String(error), error instanceof Error ? { stack: error.stack } : undefined);
|
|
354
|
+
throw error;
|
|
355
|
+
}
|
|
356
|
+
finally {
|
|
357
|
+
// Restore original console
|
|
358
|
+
globalThis.console = originalConsole;
|
|
359
|
+
// Flush logs after execution (don't await to not block response)
|
|
360
|
+
flushLogs().catch(() => { });
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Manually flush any pending logs
|
|
365
|
+
*
|
|
366
|
+
* Call this before your server shuts down to ensure all logs are sent.
|
|
367
|
+
*/
|
|
368
|
+
export async function flushTetherLogs() {
|
|
369
|
+
if (_flushTimer) {
|
|
370
|
+
clearTimeout(_flushTimer);
|
|
371
|
+
_flushTimer = null;
|
|
372
|
+
}
|
|
373
|
+
await flushLogs();
|
|
374
|
+
}
|
|
154
375
|
// Re-export zod for convenience
|
|
155
376
|
export { z };
|
|
377
|
+
/**
|
|
378
|
+
* Server-side WebSocket connection for receiving cron triggers.
|
|
379
|
+
*
|
|
380
|
+
* This connects to Tether with `?type=server` to identify as a server connection.
|
|
381
|
+
* Only server connections receive cron triggers - client connections do not.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* import { TetherCronConnection } from '@tthr/server';
|
|
386
|
+
*
|
|
387
|
+
* const cronConnection = new TetherCronConnection({
|
|
388
|
+
* url: process.env.TETHER_URL!,
|
|
389
|
+
* projectId: process.env.TETHER_PROJECT_ID!,
|
|
390
|
+
* apiKey: process.env.TETHER_API_KEY!,
|
|
391
|
+
* onCronTrigger: async (functionName, args) => {
|
|
392
|
+
* // Execute your function here
|
|
393
|
+
* try {
|
|
394
|
+
* const result = await executeFunction(functionName, args);
|
|
395
|
+
* return { success: true, result };
|
|
396
|
+
* } catch (error) {
|
|
397
|
+
* return { success: false, error: error.message };
|
|
398
|
+
* }
|
|
399
|
+
* },
|
|
400
|
+
* });
|
|
401
|
+
*
|
|
402
|
+
* await cronConnection.connect();
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
export class TetherCronConnection {
|
|
406
|
+
options;
|
|
407
|
+
ws = null;
|
|
408
|
+
connectionId = null;
|
|
409
|
+
reconnectAttempts = 0;
|
|
410
|
+
maxReconnectAttempts = 10;
|
|
411
|
+
reconnectDelay = 1000;
|
|
412
|
+
isConnecting = false;
|
|
413
|
+
shouldReconnect = true;
|
|
414
|
+
// Heartbeat configuration
|
|
415
|
+
heartbeatInterval = 30000; // 30 seconds
|
|
416
|
+
heartbeatTimeout = 10000; // 10 seconds to receive pong
|
|
417
|
+
heartbeatTimer = null;
|
|
418
|
+
heartbeatTimeoutTimer = null;
|
|
419
|
+
awaitingPong = false;
|
|
420
|
+
constructor(options) {
|
|
421
|
+
this.options = options;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Get the WebSocket URL with server type parameter
|
|
425
|
+
*/
|
|
426
|
+
getWsUrl() {
|
|
427
|
+
const base = this.options.url
|
|
428
|
+
.replace('https://', 'wss://')
|
|
429
|
+
.replace('http://', 'ws://')
|
|
430
|
+
.replace(/\/$/, '');
|
|
431
|
+
const env = this.options.environment;
|
|
432
|
+
let wsPath;
|
|
433
|
+
if (env && env !== 'production') {
|
|
434
|
+
wsPath = `${base}/ws/${this.options.projectId}/${env}`;
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
wsPath = `${base}/ws/${this.options.projectId}`;
|
|
438
|
+
}
|
|
439
|
+
// Add type=server to identify as server connection and token for auth
|
|
440
|
+
return `${wsPath}?type=server&token=${encodeURIComponent(this.options.apiKey)}`;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Connect to Tether server
|
|
444
|
+
*/
|
|
445
|
+
async connect() {
|
|
446
|
+
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (this.isConnecting) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
this.isConnecting = true;
|
|
453
|
+
this.shouldReconnect = true;
|
|
454
|
+
return new Promise((resolve, reject) => {
|
|
455
|
+
try {
|
|
456
|
+
const url = this.getWsUrl();
|
|
457
|
+
// Use ws package for Node.js if available, otherwise use global WebSocket
|
|
458
|
+
const WebSocketImpl = typeof WebSocket !== 'undefined' ? WebSocket : require('ws');
|
|
459
|
+
this.ws = new WebSocketImpl(url);
|
|
460
|
+
this.ws.onopen = () => {
|
|
461
|
+
this.reconnectAttempts = 0;
|
|
462
|
+
console.log('[Tether Cron] WebSocket connected');
|
|
463
|
+
};
|
|
464
|
+
this.ws.onmessage = async (event) => {
|
|
465
|
+
const data = typeof event.data === 'string' ? event.data : event.data.toString();
|
|
466
|
+
await this.handleMessage(data, resolve);
|
|
467
|
+
};
|
|
468
|
+
this.ws.onerror = (error) => {
|
|
469
|
+
const err = error instanceof Error ? error : new Error('WebSocket error');
|
|
470
|
+
console.error('[Tether Cron] WebSocket error:', err.message);
|
|
471
|
+
this.isConnecting = false;
|
|
472
|
+
this.options.onError?.(err);
|
|
473
|
+
reject(err);
|
|
474
|
+
};
|
|
475
|
+
this.ws.onclose = () => {
|
|
476
|
+
this.connectionId = null;
|
|
477
|
+
this.isConnecting = false;
|
|
478
|
+
this.stopHeartbeat();
|
|
479
|
+
console.log('[Tether Cron] WebSocket disconnected');
|
|
480
|
+
this.options.onDisconnected?.();
|
|
481
|
+
this.handleReconnect();
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
this.isConnecting = false;
|
|
486
|
+
reject(error);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Handle incoming WebSocket message
|
|
492
|
+
*/
|
|
493
|
+
async handleMessage(data, resolveConnect) {
|
|
494
|
+
try {
|
|
495
|
+
const message = JSON.parse(data);
|
|
496
|
+
switch (message.type) {
|
|
497
|
+
case 'connected':
|
|
498
|
+
this.connectionId = message.connection_id ?? null;
|
|
499
|
+
this.isConnecting = false;
|
|
500
|
+
this.startHeartbeat();
|
|
501
|
+
console.log(`[Tether Cron] Connected with ID: ${this.connectionId}`);
|
|
502
|
+
this.options.onConnected?.();
|
|
503
|
+
resolveConnect?.();
|
|
504
|
+
break;
|
|
505
|
+
case 'cron_trigger':
|
|
506
|
+
await this.handleCronTrigger(message);
|
|
507
|
+
break;
|
|
508
|
+
case 'pong':
|
|
509
|
+
this.awaitingPong = false;
|
|
510
|
+
if (this.heartbeatTimeoutTimer) {
|
|
511
|
+
clearTimeout(this.heartbeatTimeoutTimer);
|
|
512
|
+
this.heartbeatTimeoutTimer = null;
|
|
513
|
+
}
|
|
514
|
+
break;
|
|
515
|
+
case 'error':
|
|
516
|
+
console.error('[Tether Cron] Server error:', message.error);
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
catch (e) {
|
|
521
|
+
console.error('[Tether Cron] Failed to parse message:', e);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Handle a cron trigger message
|
|
526
|
+
*/
|
|
527
|
+
async handleCronTrigger(trigger) {
|
|
528
|
+
console.log(`[Tether Cron] Received trigger for ${trigger.functionName} (execution: ${trigger.executionId})`);
|
|
529
|
+
const startTime = Date.now();
|
|
530
|
+
try {
|
|
531
|
+
// Execute the handler
|
|
532
|
+
const result = await this.options.onCronTrigger(trigger.functionName, trigger.args);
|
|
533
|
+
const durationMs = Date.now() - startTime;
|
|
534
|
+
// Report result back to Tether
|
|
535
|
+
await this.reportExecution(trigger, result, durationMs);
|
|
536
|
+
}
|
|
537
|
+
catch (error) {
|
|
538
|
+
const durationMs = Date.now() - startTime;
|
|
539
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
540
|
+
console.error(`[Tether Cron] Handler error for ${trigger.functionName}:`, errorMessage);
|
|
541
|
+
// Report failure
|
|
542
|
+
await this.reportExecution(trigger, { success: false, error: errorMessage }, durationMs);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Report execution result back to Tether
|
|
547
|
+
*/
|
|
548
|
+
async reportExecution(trigger, result, durationMs) {
|
|
549
|
+
const base = this.options.url.replace(/\/$/, '');
|
|
550
|
+
const env = this.options.environment;
|
|
551
|
+
let apiPath;
|
|
552
|
+
if (env && env !== 'production') {
|
|
553
|
+
apiPath = `${base}/api/v1/projects/${this.options.projectId}/env/${env}`;
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
apiPath = `${base}/api/v1/projects/${this.options.projectId}`;
|
|
557
|
+
}
|
|
558
|
+
const url = `${apiPath}/crons/${trigger.cronId}/executions`;
|
|
559
|
+
try {
|
|
560
|
+
const response = await fetch(url, {
|
|
561
|
+
method: 'POST',
|
|
562
|
+
headers: {
|
|
563
|
+
'Content-Type': 'application/json',
|
|
564
|
+
'Authorization': `Bearer ${this.options.apiKey}`,
|
|
565
|
+
},
|
|
566
|
+
body: JSON.stringify({
|
|
567
|
+
executionId: trigger.executionId,
|
|
568
|
+
success: result.success,
|
|
569
|
+
errorMessage: result.error,
|
|
570
|
+
result: result.result,
|
|
571
|
+
durationMs,
|
|
572
|
+
}),
|
|
573
|
+
});
|
|
574
|
+
if (!response.ok) {
|
|
575
|
+
console.error(`[Tether Cron] Failed to report execution: ${response.status} ${response.statusText}`);
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
console.log(`[Tether Cron] Reported execution ${trigger.executionId}: ${result.success ? 'success' : 'failed'}`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
console.error('[Tether Cron] Failed to report execution:', error);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Start heartbeat timer
|
|
587
|
+
*/
|
|
588
|
+
startHeartbeat() {
|
|
589
|
+
this.stopHeartbeat();
|
|
590
|
+
this.heartbeatTimer = setInterval(() => {
|
|
591
|
+
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
592
|
+
this.awaitingPong = true;
|
|
593
|
+
this.ws.send(JSON.stringify({ type: 'ping' }));
|
|
594
|
+
this.heartbeatTimeoutTimer = setTimeout(() => {
|
|
595
|
+
if (this.awaitingPong) {
|
|
596
|
+
console.warn('[Tether Cron] Heartbeat timeout - forcing reconnect');
|
|
597
|
+
this.ws?.close();
|
|
598
|
+
}
|
|
599
|
+
}, this.heartbeatTimeout);
|
|
600
|
+
}
|
|
601
|
+
}, this.heartbeatInterval);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Stop heartbeat timer
|
|
605
|
+
*/
|
|
606
|
+
stopHeartbeat() {
|
|
607
|
+
if (this.heartbeatTimer) {
|
|
608
|
+
clearInterval(this.heartbeatTimer);
|
|
609
|
+
this.heartbeatTimer = null;
|
|
610
|
+
}
|
|
611
|
+
if (this.heartbeatTimeoutTimer) {
|
|
612
|
+
clearTimeout(this.heartbeatTimeoutTimer);
|
|
613
|
+
this.heartbeatTimeoutTimer = null;
|
|
614
|
+
}
|
|
615
|
+
this.awaitingPong = false;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Handle reconnection
|
|
619
|
+
*/
|
|
620
|
+
handleReconnect() {
|
|
621
|
+
if (!this.shouldReconnect) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
625
|
+
console.error('[Tether Cron] Max reconnection attempts reached');
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
this.reconnectAttempts++;
|
|
629
|
+
const delay = Math.min(this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1), 30000);
|
|
630
|
+
console.log(`[Tether Cron] Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
|
|
631
|
+
setTimeout(() => {
|
|
632
|
+
this.connect().catch((error) => {
|
|
633
|
+
console.error('[Tether Cron] Reconnection failed:', error);
|
|
634
|
+
});
|
|
635
|
+
}, delay);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Disconnect from Tether
|
|
639
|
+
*/
|
|
640
|
+
disconnect() {
|
|
641
|
+
this.shouldReconnect = false;
|
|
642
|
+
this.stopHeartbeat();
|
|
643
|
+
if (this.ws) {
|
|
644
|
+
this.ws.close();
|
|
645
|
+
this.ws = null;
|
|
646
|
+
}
|
|
647
|
+
this.connectionId = null;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Check if connected
|
|
651
|
+
*/
|
|
652
|
+
get isConnected() {
|
|
653
|
+
return this.ws?.readyState === WebSocket.OPEN;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
156
656
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAgB,MAAM,KAAK,CAAC;AA6GtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,KAAK,CACnB,UAA2C;IAE3C,OAAO,UAAU,CAAC;AACpB,CAAC;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,CAAC,IAAI,CAAC;IAChD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tthr/server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Tether server SDK for Node.js/Bun/Deno",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,15 +14,18 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"dev": "tsc --watch",
|
|
20
|
-
"typecheck": "tsc --noEmit"
|
|
21
|
-
},
|
|
22
17
|
"dependencies": {
|
|
18
|
+
"ws": "^8.18.0",
|
|
23
19
|
"zod": "^3.24.0"
|
|
24
20
|
},
|
|
25
21
|
"devDependencies": {
|
|
22
|
+
"@types/node": "^22.0.0",
|
|
23
|
+
"@types/ws": "^8.5.13",
|
|
26
24
|
"typescript": "^5.7.2"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"dev": "tsc --watch",
|
|
29
|
+
"typecheck": "tsc --noEmit"
|
|
27
30
|
}
|
|
28
|
-
}
|
|
31
|
+
}
|