@supabase/realtime-js
Advanced tools
Comparing version 2.11.4 to 2.11.5
@@ -38,2 +38,7 @@ export declare const DEFAULT_HEADERS: { | ||
} | ||
export declare enum LOG_LEVEL { | ||
Info = "info", | ||
Warn = "warn", | ||
Error = "error" | ||
} | ||
//# sourceMappingURL=constants.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CONNECTION_STATE = exports.TRANSPORTS = exports.CHANNEL_EVENTS = exports.CHANNEL_STATES = exports.SOCKET_STATES = exports.WS_CLOSE_NORMAL = exports.DEFAULT_TIMEOUT = exports.VERSION = exports.VSN = exports.DEFAULT_HEADERS = void 0; | ||
exports.LOG_LEVEL = exports.CONNECTION_STATE = exports.TRANSPORTS = exports.CHANNEL_EVENTS = exports.CHANNEL_STATES = exports.SOCKET_STATES = exports.WS_CLOSE_NORMAL = exports.DEFAULT_TIMEOUT = exports.VERSION = exports.VSN = exports.DEFAULT_HEADERS = void 0; | ||
const version_1 = require("./version"); | ||
@@ -45,2 +45,8 @@ exports.DEFAULT_HEADERS = { 'X-Client-Info': `realtime-js/${version_1.version}` }; | ||
})(CONNECTION_STATE || (exports.CONNECTION_STATE = CONNECTION_STATE = {})); | ||
var LOG_LEVEL; | ||
(function (LOG_LEVEL) { | ||
LOG_LEVEL["Info"] = "info"; | ||
LOG_LEVEL["Warn"] = "warn"; | ||
LOG_LEVEL["Error"] = "error"; | ||
})(LOG_LEVEL || (exports.LOG_LEVEL = LOG_LEVEL = {})); | ||
//# sourceMappingURL=constants.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const version = "2.11.4"; | ||
export declare const version = "2.11.5"; | ||
//# sourceMappingURL=version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = '2.11.4'; | ||
exports.version = '2.11.5'; | ||
//# sourceMappingURL=version.js.map |
import type { WebSocket as WSWebSocket } from 'ws'; | ||
import { CONNECTION_STATE } from './lib/constants'; | ||
import { CONNECTION_STATE, LOG_LEVEL } from './lib/constants'; | ||
import Serializer from './lib/serializer'; | ||
@@ -14,2 +14,22 @@ import Timer from './lib/timer'; | ||
}; | ||
export type LogLevel = LOG_LEVEL; | ||
export type RealtimeMessage = { | ||
topic: string; | ||
event: string; | ||
payload: any; | ||
ref: string; | ||
join_ref?: string; | ||
}; | ||
export type RealtimeRemoveChannelResponse = 'ok' | 'timed out' | 'error'; | ||
export interface WebSocketLikeConstructor { | ||
new (address: string | URL, _ignored?: any, options?: { | ||
headers: Object | undefined; | ||
}): WebSocketLike; | ||
} | ||
export type WebSocketLike = WebSocket | WSWebSocket | WSWebSocketDummy; | ||
export interface WebSocketLikeError { | ||
error: any; | ||
message: string; | ||
type: string; | ||
} | ||
export type RealtimeClientOptions = { | ||
@@ -29,3 +49,4 @@ transport?: WebSocketLikeConstructor; | ||
}; | ||
log_level?: 'info' | 'debug' | 'warn' | 'error'; | ||
log_level?: LogLevel; | ||
logLevel?: LogLevel; | ||
fetch?: Fetch; | ||
@@ -36,21 +57,2 @@ worker?: boolean; | ||
}; | ||
export type RealtimeMessage = { | ||
topic: string; | ||
event: string; | ||
payload: any; | ||
ref: string; | ||
join_ref?: string; | ||
}; | ||
export type RealtimeRemoveChannelResponse = 'ok' | 'timed out' | 'error'; | ||
export interface WebSocketLikeConstructor { | ||
new (address: string | URL, _ignored?: any, options?: { | ||
headers: Object | undefined; | ||
}): WebSocketLike; | ||
} | ||
export type WebSocketLike = WebSocket | WSWebSocket | WSWebSocketDummy; | ||
export interface WebSocketLikeError { | ||
error: any; | ||
message: string; | ||
type: string; | ||
} | ||
export default class RealtimeClient { | ||
@@ -76,2 +78,3 @@ accessTokenValue: string | null; | ||
logger: Function; | ||
logLevel?: LogLevel; | ||
encode: Function; | ||
@@ -105,2 +108,3 @@ decode: Function; | ||
* @param options.logger The optional function for specialized logging, ie: logger: (kind, msg, data) => { console.log(`${kind}: ${msg}`, data) } | ||
* @param options.logLevel Sets the log level for Realtime | ||
* @param options.encode The function to encode outgoing messages. Defaults to JSON: (payload, callback) => callback(JSON.stringify(payload)) | ||
@@ -107,0 +111,0 @@ * @param options.decode The function to decode incoming messages. Defaults to Serializer's decode. |
@@ -64,2 +64,3 @@ "use strict"; | ||
* @param options.logger The optional function for specialized logging, ie: logger: (kind, msg, data) => { console.log(`${kind}: ${msg}`, data) } | ||
* @param options.logLevel Sets the log level for Realtime | ||
* @param options.encode The function to encode outgoing messages. Defaults to JSON: (payload, callback) => callback(JSON.stringify(payload)) | ||
@@ -81,3 +82,3 @@ * @param options.decode The function to decode incoming messages. Defaults to Serializer's decode. | ||
this.timeout = constants_1.DEFAULT_TIMEOUT; | ||
this.heartbeatIntervalMs = 30000; | ||
this.heartbeatIntervalMs = 25000; | ||
this.heartbeatTimer = undefined; | ||
@@ -131,2 +132,6 @@ this.pendingHeartbeatRef = null; | ||
this.logger = options.logger; | ||
if ((options === null || options === void 0 ? void 0 : options.logLevel) || (options === null || options === void 0 ? void 0 : options.log_level)) { | ||
this.logLevel = options.logLevel || options.log_level; | ||
this.params = Object.assign(Object.assign({}, this.params), { log_level: this.logLevel }); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) | ||
@@ -133,0 +138,0 @@ this.heartbeatIntervalMs = options.heartbeatIntervalMs; |
@@ -38,2 +38,7 @@ export declare const DEFAULT_HEADERS: { | ||
} | ||
export declare enum LOG_LEVEL { | ||
Info = "info", | ||
Warn = "warn", | ||
Error = "error" | ||
} | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -42,2 +42,8 @@ import { version } from './version'; | ||
})(CONNECTION_STATE || (CONNECTION_STATE = {})); | ||
export var LOG_LEVEL; | ||
(function (LOG_LEVEL) { | ||
LOG_LEVEL["Info"] = "info"; | ||
LOG_LEVEL["Warn"] = "warn"; | ||
LOG_LEVEL["Error"] = "error"; | ||
})(LOG_LEVEL || (LOG_LEVEL = {})); | ||
//# sourceMappingURL=constants.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const version = "2.11.4"; | ||
export declare const version = "2.11.5"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = '2.11.4'; | ||
export const version = '2.11.5'; | ||
//# sourceMappingURL=version.js.map |
import type { WebSocket as WSWebSocket } from 'ws'; | ||
import { CONNECTION_STATE } from './lib/constants'; | ||
import { CONNECTION_STATE, LOG_LEVEL } from './lib/constants'; | ||
import Serializer from './lib/serializer'; | ||
@@ -14,2 +14,22 @@ import Timer from './lib/timer'; | ||
}; | ||
export type LogLevel = LOG_LEVEL; | ||
export type RealtimeMessage = { | ||
topic: string; | ||
event: string; | ||
payload: any; | ||
ref: string; | ||
join_ref?: string; | ||
}; | ||
export type RealtimeRemoveChannelResponse = 'ok' | 'timed out' | 'error'; | ||
export interface WebSocketLikeConstructor { | ||
new (address: string | URL, _ignored?: any, options?: { | ||
headers: Object | undefined; | ||
}): WebSocketLike; | ||
} | ||
export type WebSocketLike = WebSocket | WSWebSocket | WSWebSocketDummy; | ||
export interface WebSocketLikeError { | ||
error: any; | ||
message: string; | ||
type: string; | ||
} | ||
export type RealtimeClientOptions = { | ||
@@ -29,3 +49,4 @@ transport?: WebSocketLikeConstructor; | ||
}; | ||
log_level?: 'info' | 'debug' | 'warn' | 'error'; | ||
log_level?: LogLevel; | ||
logLevel?: LogLevel; | ||
fetch?: Fetch; | ||
@@ -36,21 +57,2 @@ worker?: boolean; | ||
}; | ||
export type RealtimeMessage = { | ||
topic: string; | ||
event: string; | ||
payload: any; | ||
ref: string; | ||
join_ref?: string; | ||
}; | ||
export type RealtimeRemoveChannelResponse = 'ok' | 'timed out' | 'error'; | ||
export interface WebSocketLikeConstructor { | ||
new (address: string | URL, _ignored?: any, options?: { | ||
headers: Object | undefined; | ||
}): WebSocketLike; | ||
} | ||
export type WebSocketLike = WebSocket | WSWebSocket | WSWebSocketDummy; | ||
export interface WebSocketLikeError { | ||
error: any; | ||
message: string; | ||
type: string; | ||
} | ||
export default class RealtimeClient { | ||
@@ -76,2 +78,3 @@ accessTokenValue: string | null; | ||
logger: Function; | ||
logLevel?: LogLevel; | ||
encode: Function; | ||
@@ -105,2 +108,3 @@ decode: Function; | ||
* @param options.logger The optional function for specialized logging, ie: logger: (kind, msg, data) => { console.log(`${kind}: ${msg}`, data) } | ||
* @param options.logLevel Sets the log level for Realtime | ||
* @param options.encode The function to encode outgoing messages. Defaults to JSON: (payload, callback) => callback(JSON.stringify(payload)) | ||
@@ -107,0 +111,0 @@ * @param options.decode The function to decode incoming messages. Defaults to Serializer's decode. |
@@ -26,2 +26,3 @@ import { CHANNEL_EVENTS, CONNECTION_STATE, DEFAULT_HEADERS, DEFAULT_TIMEOUT, SOCKET_STATES, TRANSPORTS, VSN, WS_CLOSE_NORMAL, } from './lib/constants'; | ||
* @param options.logger The optional function for specialized logging, ie: logger: (kind, msg, data) => { console.log(`${kind}: ${msg}`, data) } | ||
* @param options.logLevel Sets the log level for Realtime | ||
* @param options.encode The function to encode outgoing messages. Defaults to JSON: (payload, callback) => callback(JSON.stringify(payload)) | ||
@@ -43,3 +44,3 @@ * @param options.decode The function to decode incoming messages. Defaults to Serializer's decode. | ||
this.timeout = DEFAULT_TIMEOUT; | ||
this.heartbeatIntervalMs = 30000; | ||
this.heartbeatIntervalMs = 25000; | ||
this.heartbeatTimer = undefined; | ||
@@ -93,2 +94,6 @@ this.pendingHeartbeatRef = null; | ||
this.logger = options.logger; | ||
if ((options === null || options === void 0 ? void 0 : options.logLevel) || (options === null || options === void 0 ? void 0 : options.log_level)) { | ||
this.logLevel = options.logLevel || options.log_level; | ||
this.params = Object.assign(Object.assign({}, this.params), { log_level: this.logLevel }); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs) | ||
@@ -95,0 +100,0 @@ this.heartbeatIntervalMs = options.heartbeatIntervalMs; |
{ | ||
"name": "@supabase/realtime-js", | ||
"version": "2.11.4", | ||
"version": "2.11.5", | ||
"description": "Listen to realtime updates to your PostgreSQL database", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -47,1 +47,7 @@ import { version } from './version' | ||
} | ||
export enum LOG_LEVEL { | ||
Info = 'info', | ||
Warn = 'warn', | ||
Error = 'error', | ||
} |
@@ -1,1 +0,1 @@ | ||
export const version = '2.11.4' | ||
export const version = '2.11.5' |
@@ -10,6 +10,7 @@ import type { WebSocket as WSWebSocket } from 'ws' | ||
TRANSPORTS, | ||
VERSION, | ||
VSN, | ||
WS_CLOSE_NORMAL, | ||
LOG_LEVEL, | ||
} from './lib/constants' | ||
import Serializer from './lib/serializer' | ||
@@ -30,20 +31,4 @@ import Timer from './lib/timer' | ||
} | ||
export type LogLevel = LOG_LEVEL | ||
export type RealtimeClientOptions = { | ||
transport?: WebSocketLikeConstructor | ||
timeout?: number | ||
heartbeatIntervalMs?: number | ||
logger?: Function | ||
encode?: Function | ||
decode?: Function | ||
reconnectAfterMs?: Function | ||
headers?: { [key: string]: string } | ||
params?: { [key: string]: any } | ||
log_level?: 'info' | 'debug' | 'warn' | 'error' | ||
fetch?: Fetch | ||
worker?: boolean | ||
workerUrl?: string | ||
accessToken?: () => Promise<string | null> | ||
} | ||
export type RealtimeMessage = { | ||
@@ -77,2 +62,21 @@ topic: string | ||
export type RealtimeClientOptions = { | ||
transport?: WebSocketLikeConstructor | ||
timeout?: number | ||
heartbeatIntervalMs?: number | ||
logger?: Function | ||
encode?: Function | ||
decode?: Function | ||
reconnectAfterMs?: Function | ||
headers?: { [key: string]: string } | ||
params?: { [key: string]: any } | ||
//Deprecated: Use it in favour of correct casing `logLevel` | ||
log_level?: LogLevel | ||
logLevel?: LogLevel | ||
fetch?: Fetch | ||
worker?: boolean | ||
workerUrl?: string | ||
accessToken?: () => Promise<string | null> | ||
} | ||
const NATIVE_WEBSOCKET_AVAILABLE = typeof WebSocket !== 'undefined' | ||
@@ -95,3 +99,3 @@ const WORKER_SCRIPT = ` | ||
transport: WebSocketLikeConstructor | null | ||
heartbeatIntervalMs: number = 30000 | ||
heartbeatIntervalMs: number = 25000 | ||
heartbeatTimer: ReturnType<typeof setInterval> | undefined = undefined | ||
@@ -102,2 +106,3 @@ pendingHeartbeatRef: string | null = null | ||
logger: Function = noop | ||
logLevel?: LogLevel | ||
encode: Function | ||
@@ -137,2 +142,3 @@ decode: Function | ||
* @param options.logger The optional function for specialized logging, ie: logger: (kind, msg, data) => { console.log(`${kind}: ${msg}`, data) } | ||
* @param options.logLevel Sets the log level for Realtime | ||
* @param options.encode The function to encode outgoing messages. Defaults to JSON: (payload, callback) => callback(JSON.stringify(payload)) | ||
@@ -156,2 +162,7 @@ * @param options.decode The function to decode incoming messages. Defaults to Serializer's decode. | ||
if (options?.logger) this.logger = options.logger | ||
if (options?.logLevel || options?.log_level) { | ||
this.logLevel = options.logLevel || options.log_level | ||
this.params = { ...this.params, log_level: this.logLevel as string } | ||
} | ||
if (options?.heartbeatIntervalMs) | ||
@@ -158,0 +169,0 @@ this.heartbeatIntervalMs = options.heartbeatIntervalMs |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
394551
7007