@signalwire/js 4.0.0-beta.8 → 4.0.0-beta.9
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/{base-BxFSgMTI.d.cts → base-CQPEW1lJ.d.mts} +8 -7
- package/dist/base-CQPEW1lJ.d.mts.map +1 -0
- package/dist/{base-DKDZK4Rr.d.mts → base-Cif20s3C.d.cts} +8 -7
- package/dist/base-Cif20s3C.d.cts.map +1 -0
- package/dist/browser.mjs +176 -63
- package/dist/browser.mjs.map +1 -1
- package/dist/browser.umd.js +176 -63
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +173 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +58 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +174 -53
- package/dist/index.mjs.map +1 -1
- package/dist/operators/index.cjs +1 -1
- package/dist/operators/index.d.cts +1 -1
- package/dist/operators/index.d.mts +1 -1
- package/dist/operators/index.mjs +1 -1
- package/dist/{operators-CJEML6aa.cjs → operators-mm21prWr.cjs} +3 -17
- package/dist/operators-mm21prWr.cjs.map +1 -0
- package/dist/{operators-C8Tqm86j.mjs → operators-uT_fb8ba.mjs} +4 -12
- package/dist/operators-uT_fb8ba.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/base-BxFSgMTI.d.cts.map +0 -1
- package/dist/base-DKDZK4Rr.d.mts.map +0 -1
- package/dist/operators-C8Tqm86j.mjs.map +0 -1
- package/dist/operators-CJEML6aa.cjs.map +0 -1
package/dist/operators/index.cjs
CHANGED
package/dist/operators/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as filterNull, n as filterAs, r as ifIsMap, t as throwOnRPCError } from "../operators-
|
|
1
|
+
import { a as filterNull, n as filterAs, r as ifIsMap, t as throwOnRPCError } from "../operators-uT_fb8ba.mjs";
|
|
2
2
|
|
|
3
3
|
export { filterAs, filterNull, ifIsMap, throwOnRPCError };
|
|
@@ -159,20 +159,12 @@ var CallCreateError = class extends Error {
|
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
161
|
var JSONRPCError = class extends Error {
|
|
162
|
-
constructor(code, message, data, options) {
|
|
162
|
+
constructor(code, message, data, options, requestId) {
|
|
163
163
|
super(message, options);
|
|
164
164
|
this.code = code;
|
|
165
165
|
this.data = data;
|
|
166
|
-
this.name = "JSONRPCError";
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
var RPCError = class extends Error {
|
|
170
|
-
constructor(code, requestId, message, data, options) {
|
|
171
|
-
super(message, options);
|
|
172
|
-
this.code = code;
|
|
173
166
|
this.requestId = requestId;
|
|
174
|
-
this.
|
|
175
|
-
this.name = "RPCError";
|
|
167
|
+
this.name = "JSONRPCError";
|
|
176
168
|
}
|
|
177
169
|
};
|
|
178
170
|
var InvalidParams = class extends Error {
|
|
@@ -471,12 +463,6 @@ Object.defineProperty(exports, 'MessageParseError', {
|
|
|
471
463
|
return MessageParseError;
|
|
472
464
|
}
|
|
473
465
|
});
|
|
474
|
-
Object.defineProperty(exports, 'RPCError', {
|
|
475
|
-
enumerable: true,
|
|
476
|
-
get: function () {
|
|
477
|
-
return RPCError;
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
466
|
Object.defineProperty(exports, 'RPCTimeoutError', {
|
|
481
467
|
enumerable: true,
|
|
482
468
|
get: function () {
|
|
@@ -609,4 +595,4 @@ Object.defineProperty(exports, 'throwOnRPCError', {
|
|
|
609
595
|
return throwOnRPCError;
|
|
610
596
|
}
|
|
611
597
|
});
|
|
612
|
-
//# sourceMappingURL=operators-
|
|
598
|
+
//# sourceMappingURL=operators-mm21prWr.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators-mm21prWr.cjs","names":["at?: string","requestId: string","timeoutMs: number","error: unknown","storageType: string","key: string","originalError: Error","description: string","message: string","direction: 'inbound' | 'outbound'","code: number | string","data?: unknown","requestId?: string","originalError: unknown","operation: string","kind: string","log","userLogger: SDKLogger | null","debugOptions: LoggerOptions['debug']","wsTraffic: InternalSDKLogger['wsTraffic']","logger"],"sources":["../src/core/errors.ts","../src/utils/logger.ts","../src/operators/filterNull.ts","../src/utils/getValueFrom.ts","../src/operators/filterEventAs.ts","../src/operators/throwOnRPCError.ts"],"sourcesContent":["export class UnexpectedError extends Error {\n constructor(\n public at?: string,\n options?: ErrorOptions\n ) {\n super(`Unexpected Error${at ? ` at ${at}` : ''}`, options);\n this.name = 'UnexpectedError';\n }\n}\n\nexport class UnimplementedError extends Error {\n constructor(\n public reason = 'Not Implemented',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'UnimplementedError';\n }\n}\n\nexport class NotConnectedError extends Error {\n constructor(\n public reason = 'Not Connected',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'NotConnectedError';\n }\n}\n\nexport class InvalidCredentialsError extends Error {\n constructor(\n public reason = 'Invalid Credentials',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'InvalidCredentialsError';\n }\n}\n\nexport class WebSocketConnectionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WebSocketConnectionError';\n }\n}\n\nexport class TransportConnectionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'TransportConnectionError';\n }\n}\n\nexport class WebSocketTimeoutError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WebSocketTimeoutError';\n }\n}\n\nexport class RequestTimeoutError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RequestTimeoutError';\n }\n}\n\nexport class RequestError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RequestError';\n }\n}\n\nexport class InvalidListenerError extends Error {\n constructor(options?: ErrorOptions) {\n super('listener is not a function', options);\n this.name = 'InvalidListenerError';\n }\n}\n\nexport class RPCTimeoutError extends Error {\n constructor(\n public requestId: string,\n public timeoutMs: number,\n options?: ErrorOptions\n ) {\n super(`RPC request ${requestId} timed out after ${timeoutMs}ms`, options);\n this.name = 'RPCTimeoutError';\n }\n}\n\nexport class AuthStateHandlerError extends Error {\n constructor(\n public error: unknown = null,\n options?: ErrorOptions\n ) {\n super('Error handling authorization state update', {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'AuthStateHandlerError';\n }\n}\n\nexport class InvalidStateTransitionError extends Error {\n constructor(\n public currentState: string,\n public targetState: string,\n options?: ErrorOptions\n ) {\n super(\n `Invalid transition: cannot transition from \"${currentState}\" to \"${targetState}\"`,\n options\n );\n this.name = 'InvalidStateTransitionError';\n }\n}\n\nexport class InvalidOptionError extends Error {\n constructor(\n public value: string,\n public availableOptions: string[],\n options?: ErrorOptions\n ) {\n super(\n `Invalid option: \"${value}\" must be one of the available options: ${availableOptions.join(', ')}`,\n options\n );\n this.name = 'InvalidOptionError';\n }\n}\n\nexport class StorageNotAvailableError extends Error {\n constructor(\n public storageType: string = 'localStorage',\n options?: ErrorOptions\n ) {\n super(`${storageType} is not available in this environment`, options);\n this.name = 'StorageNotAvailableError';\n }\n}\n\nexport class SerializationError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to serialize value for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'SerializationError';\n }\n}\n\nexport class DeserializationError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to deserialize value for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'DeserializationError';\n }\n}\n\nexport class StorageWriteError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to write to storage for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'StorageWriteError';\n }\n}\n\nexport class StorageReadError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to read from storage \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'StorageReadError';\n }\n}\n\nexport class InvalidStorageValueError extends Error {\n constructor(\n public key: string,\n public valueType: string,\n options?: ErrorOptions\n ) {\n super(\n `Cannot serialize value of type \"${valueType}\" for key \"${key}\": This type cannot be serialized to JSON`,\n options\n );\n this.name = 'InvalidStorageValueError';\n }\n}\n\nexport class DependencyError extends Error {\n constructor(\n public description: string,\n options?: ErrorOptions\n ) {\n super(`Dependency ${description} is not set or available.`, options);\n this.name = 'DependencyError';\n }\n}\n\nexport class DeviceNotFoundError extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'DeviceNotFoundError';\n }\n}\n\n// =============================================================================\n// CALL ERROR TYPES\n// =============================================================================\n\n/**\n * Semantic category of a call-lifecycle error.\n *\n * - `'media'` – RTCPeerConnection / media device failure\n * - `'signaling'` – Verto / JSON-RPC protocol error\n * - `'timeout'` – Call setup timed out waiting for a response\n * - `'rejected'` – Remote side rejected the call\n * - `'network'` – Transport lost during an active call\n * - `'internal'` – Unexpected / unknown error\n */\nexport type CallErrorKind = 'media' | 'signaling' | 'timeout' | 'rejected' | 'network' | 'internal';\n\n/**\n * Structured error emitted on `call.errors$`.\n *\n * Provides actionable metadata so consumers can react without\n * resorting to `instanceof` checks on raw `Error` objects.\n */\nexport interface CallError {\n /** Semantic category of the error. */\n readonly kind: CallErrorKind;\n /**\n * Whether the error terminates the call.\n * When `true`, the call will automatically transition to `'failed'`\n * and be destroyed — no further action is needed from the consumer.\n */\n readonly fatal: boolean;\n /** The underlying error. */\n readonly error: Error;\n /** ID of the call that produced this error. */\n readonly callId: string;\n}\n\nexport class CallCreateError extends Error {\n constructor(\n public message: string,\n public error: unknown = null,\n public direction: 'inbound' | 'outbound' = 'outbound',\n options?: ErrorOptions\n ) {\n super(message, {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'CallCreateError';\n }\n}\n\nexport class JSONRPCError extends Error {\n constructor(\n public code: number | string,\n message: string,\n public data?: unknown,\n options?: ErrorOptions,\n public requestId?: string\n ) {\n super(message, options);\n this.name = 'JSONRPCError';\n }\n}\n\nexport class InvalidParams extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'InvalidParams';\n }\n}\n\nexport class ConversationError extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'ConversationError';\n }\n}\n\nexport class VertoInviteHandlerError extends Error {\n constructor(\n public error: unknown = null,\n options?: ErrorOptions\n ) {\n super('Error handling Verto invite', {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'VertoInviteHandlerError';\n }\n}\n\nexport class HttpRequestError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'HttpRequestError';\n }\n}\n\nexport class ValidationError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'ValidationError';\n }\n}\n\nexport class VertoPongError extends Error {\n constructor(public originalError: unknown) {\n super('Failed to send Verto pong - call may disconnect', {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'VertoPongError';\n }\n}\n\nexport class MessageParseError extends Error {\n constructor(public originalError: unknown) {\n super('Failed to parse incoming WebSocket message', {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'MessageParseError';\n }\n}\n\nexport class CollectionFetchError extends Error {\n constructor(\n public operation: string,\n public originalError: unknown\n ) {\n super(`Collection fetch failed during ${operation}`, {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'CollectionFetchError';\n }\n}\n\nexport class MediaTrackError extends Error {\n constructor(\n public operation: string,\n public kind: string,\n public originalError: unknown\n ) {\n super(`Media track ${operation} failed for ${kind}`, {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'MediaTrackError';\n }\n}\n","import log from 'loglevel';\n\ninterface LogFn {\n <T extends object>(obj: T, msg?: string, ...args: unknown[]): void;\n (obj: unknown, msg?: string, ...args: unknown[]): void;\n (msg: string, ...args: unknown[]): void;\n}\nexport interface SDKLogger {\n fatal: LogFn;\n error: LogFn;\n warn: LogFn;\n info: LogFn;\n debug: LogFn;\n trace: LogFn;\n}\n\nexport interface WsTrafficOptions {\n type: 'send' | 'recv' | 'http';\n payload: unknown;\n}\n\nexport interface LoggerOptions {\n /** @internal */\n devTools?: boolean;\n /** @internal */\n debug?: {\n logWsTraffic?: boolean;\n };\n /** @internal */\n logger?: SDKLogger;\n}\n\nexport interface InternalSDKLogger extends SDKLogger {\n wsTraffic: (options: WsTrafficOptions) => void;\n}\n\nconst datetime = () => new Date().toISOString();\nconst defaultLogger = log.getLogger('signalwire');\n\nconst originalFactory = defaultLogger.methodFactory;\ndefaultLogger.methodFactory = (methodName, logLevel, loggerName) => {\n const rawMethod = originalFactory(methodName, logLevel, loggerName);\n\n return function (...args: unknown[]) {\n args.unshift(datetime(), '-');\n // eslint-disable-next-line prefer-spread\n rawMethod.apply(undefined, args);\n };\n};\n\nconst defaultLoggerLevel = defaultLogger.levels.DEBUG;\ndefaultLogger.setLevel(defaultLoggerLevel);\n\nlet userLogger: SDKLogger | null;\nconst setLogger = (logger: SDKLogger | null): void => {\n userLogger = logger;\n};\n\nlet debugOptions: LoggerOptions['debug'] = {};\nconst setDebugOptions = (options: unknown): void => {\n if (options == null) {\n debugOptions = {};\n return;\n }\n debugOptions = {\n ...debugOptions,\n ...options\n } as LoggerOptions['debug'];\n};\n\nconst getLoggerInstance = (): SDKLogger => {\n return userLogger ?? (defaultLogger as unknown as SDKLogger);\n};\n\nconst shouldStringify = (payload: WsTrafficOptions['payload']) => {\n //@ts-expect-error we don;t cara that payload is unknown\n if ('method' in payload && payload.method === 'signalwire.ping') {\n return false;\n }\n\n return true;\n};\n\nconst wsTraffic: InternalSDKLogger['wsTraffic'] = ({ type, payload }) => {\n const logger = getLoggerInstance();\n const { logWsTraffic } = debugOptions ?? {};\n\n if (!logWsTraffic) {\n return undefined;\n }\n\n const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;\n\n return logger.debug(`${type.toUpperCase()}: \\n`, msg, '\\n');\n};\n\nconst getLogger = (): InternalSDKLogger => {\n const logger = getLoggerInstance();\n\n return new Proxy(logger, {\n get(target, prop: keyof InternalSDKLogger, receiver) {\n if (prop === 'wsTraffic') {\n return wsTraffic;\n }\n\n return Reflect.get(target, prop, receiver);\n }\n }) as InternalSDKLogger;\n};\n\nexport { setLogger, getLogger, setDebugOptions };\n","import { filter } from 'rxjs';\n\nimport type { OperatorFunction } from 'rxjs';\n\n/**\n * RxJS operator that filters out `null` and `undefined` values with type narrowing.\n *\n * @example\n * ```ts\n * source$.pipe(filterNull()).subscribe(value => {\n * // value is guaranteed non-null\n * });\n * ```\n */\nexport function filterNull<T>(): OperatorFunction<T | null | undefined, T> {\n return filter((value): value is T => value != null);\n}\n","export const getValueFrom = <T = unknown>(\n obj: unknown,\n path: string,\n defaultValue?: T\n): T | undefined => {\n const keys = path.split('.');\n let result = obj;\n for (const key of keys) {\n if (result && typeof result === 'object' && key in result) {\n result = (result as Record<string, unknown>)[key];\n } else {\n return defaultValue;\n }\n }\n return (result === undefined ? defaultValue : result) as T;\n};\n","import { pipe } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\n\nimport { getValueFrom } from '../utils/getValueFrom';\n\nimport type { OperatorFunction } from 'rxjs';\n\n/**\n * Type helper to extract nested property types using dot notation.\n * Supports up to 4 levels of nesting.\n *\n * @example\n * type Example = { a: { b: { c: string } } }\n * type Result = PathValue<Example, 'a.b.c'> // string\n */\ntype PathValue<T, P extends string> = P extends `${infer Key}.${infer Rest}`\n ? Key extends keyof T\n ? PathValue<T[Key], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n// Usage:\n// source$.pipe(\n// isEvent(\n// (event) => event.type === 'call.started',\n// (event) => ({ id: event.id, timestamp: event.timestamp })\n// )\n// );\n\n/**\n * RxJS operator that filters events based on a predicate and maps matching events.\n *\n * This operator combines filter and map operations:\n * 1. Only events that match the predicate are emitted\n * 2. Matching events are transformed using the map function\n *\n * @template TInput - The type of input events\n * @template TOutput - The type of output after mapping\n * @param predicate - Function to test each event. Returns true to include the event.\n * @param mapFn - Function to transform matching events\n * @returns An operator function that filters and maps events\n *\n * @example\n * ```typescript\n * interface CallEvent {\n * type: 'call.started' | 'call.ended';\n * id: string;\n * timestamp: number;\n * }\n *\n * events$.pipe(\n * isEvent(\n * (event: CallEvent) => event.type === 'call.started',\n * (event: CallEvent) => ({ id: event.id, timestamp: event.timestamp })\n * )\n * ).subscribe(startEvent => {\n * console.log('Call started:', startEvent);\n * });\n * ```\n */\nexport function ifIsMap<TInput, TOutput>(\n predicate: (event: unknown) => event is TInput,\n mapFn: (event: TInput) => TOutput\n): OperatorFunction<unknown, TOutput> {\n return pipe(filter(predicate), map(mapFn));\n}\n\n/**\n * Generic RxJS operator that filters events using a type guard and extracts a property.\n *\n * This is the generic version that works with any type, not just JSONRPCRequest.\n * Use this when you need to filter and extract properties from already-narrowed types.\n *\n * **Type inference**: The output type is automatically inferred from the input type and path!\n *\n * @template TInput - The type to narrow to (via type guard)\n * @template TPath - The dot-notation path to extract (inferred from parameter)\n * @param predicate - Type guard function to filter events\n * @param resultPath - Dot-notation path to extract (e.g., 'params', 'params.data')\n * @returns An operator function that filters and extracts\n *\n * @example\n * ```typescript\n * interface EventParams {\n * event_type: string;\n * data: { value: number };\n * }\n *\n * const isAuthEvent = (e: unknown): e is EventParams =>\n * typeof e === 'object' && e !== null && 'event_type' in e;\n *\n * // Type of 'data' is automatically inferred as { value: number }\n * params$.pipe(\n * filterAs(isAuthEvent, 'data')\n * ).subscribe(data => {\n * console.log('Event data:', data.value); // TypeScript knows about .value!\n * });\n *\n * // Deeply nested properties are also inferred\n * params$.pipe(\n * filterAs(isAuthEvent, 'data.value')\n * ).subscribe(value => {\n * console.log(value); // Type is 'number'\n * });\n * ```\n */\nexport function filterAs<TInput, TPath extends string>(\n predicate: (event: unknown) => event is TInput,\n resultPath: TPath\n): OperatorFunction<unknown, PathValue<TInput, TPath>> {\n return pipe(\n ifIsMap(predicate, (event) => {\n const result = getValueFrom<PathValue<TInput, TPath>>(event, resultPath);\n return result;\n }),\n filter((value): value is PathValue<TInput, TPath> => value !== undefined)\n );\n}\n","import { map, type OperatorFunction } from 'rxjs';\n\nimport { JSONRPCError } from '../core/errors';\nimport { getLogger } from '../utils/logger';\n\nimport type { JSONRPCResponse } from '../core/RPCMessages/types/base';\n\nconst logger = getLogger();\n\n/**\n * RxJS operator that throws a {@link JSONRPCError} when the RPC response contains an error.\n * Passes successful responses through unchanged.\n */\nexport function throwOnRPCError<T extends JSONRPCResponse>(): OperatorFunction<T, T> {\n return map((response: T) => {\n if (response.error) {\n logger.error('[throwOnRPCError] RPC error response:', {\n code: response.error.code,\n message: response.error.message,\n data: response.error.data\n });\n\n throw new JSONRPCError(response.error.code, response.error.message, response.error.data);\n }\n logger.debug('[throwOnRPCError] RPC successful response:', response);\n return response;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,AAAOA,IACP,SACA;AACA,QAAM,mBAAmB,KAAK,OAAO,OAAO,MAAM,QAAQ;EAHnD;AAIP,OAAK,OAAO;;;AAIhB,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YACE,AAAO,SAAS,mBAChB,SACA;AACA,QAAM,QAAQ,QAAQ;EAHf;AAIP,OAAK,OAAO;;;AAchB,IAAa,0BAAb,cAA6C,MAAM;CACjD,YACE,AAAO,SAAS,uBAChB,SACA;AACA,QAAM,QAAQ,QAAQ;EAHf;AAIP,OAAK,OAAO;;;AAIhB,IAAa,2BAAb,cAA8C,MAAM;CAClD,YAAY,SAAiB,SAAwB;AACnD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;AAIhB,IAAa,2BAAb,cAA8C,MAAM;CAClD,YAAY,SAAiB,SAAwB;A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I,SAAS,OAAO;AAClB,UAAO,MAAM,yCAAyC;IACpD,MAAM,SAAS,MAAM;IACrB,SAAS,SAAS,MAAM;IACxB,MAAM,SAAS,MAAM;IACtB,CAAC;AAEF,SAAM,IAAI,aAAa,SAAS,MAAM,MAAM,SAAS,MAAM,SAAS,SAAS,MAAM,KAAK;;AAE1F,SAAO,MAAM,8CAA8C,SAAS;AACpE,SAAO;GACP"}
|
|
@@ -131,20 +131,12 @@ var CallCreateError = class extends Error {
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
var JSONRPCError = class extends Error {
|
|
134
|
-
constructor(code, message, data, options) {
|
|
134
|
+
constructor(code, message, data, options, requestId) {
|
|
135
135
|
super(message, options);
|
|
136
136
|
this.code = code;
|
|
137
137
|
this.data = data;
|
|
138
|
-
this.name = "JSONRPCError";
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var RPCError = class extends Error {
|
|
142
|
-
constructor(code, requestId, message, data, options) {
|
|
143
|
-
super(message, options);
|
|
144
|
-
this.code = code;
|
|
145
138
|
this.requestId = requestId;
|
|
146
|
-
this.
|
|
147
|
-
this.name = "RPCError";
|
|
139
|
+
this.name = "JSONRPCError";
|
|
148
140
|
}
|
|
149
141
|
};
|
|
150
142
|
var InvalidParams = class extends Error {
|
|
@@ -377,5 +369,5 @@ function throwOnRPCError() {
|
|
|
377
369
|
}
|
|
378
370
|
|
|
379
371
|
//#endregion
|
|
380
|
-
export {
|
|
381
|
-
//# sourceMappingURL=operators-
|
|
372
|
+
export { VertoPongError as A, StorageReadError as C, UnimplementedError as D, UnexpectedError as E, WebSocketTimeoutError as M, ValidationError as O, StorageNotAvailableError as S, TransportConnectionError as T, MessageParseError as _, filterNull as a, RequestTimeoutError as b, CallCreateError as c, DependencyError as d, DeserializationError as f, MediaTrackError as g, JSONRPCError as h, getValueFrom as i, WebSocketConnectionError as j, VertoInviteHandlerError as k, CollectionFetchError as l, InvalidParams as m, filterAs as n, getLogger as o, InvalidCredentialsError as p, ifIsMap as r, AuthStateHandlerError as s, throwOnRPCError as t, ConversationError as u, RPCTimeoutError as v, StorageWriteError as w, SerializationError as x, RequestError as y };
|
|
373
|
+
//# sourceMappingURL=operators-uT_fb8ba.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators-uT_fb8ba.mjs","names":["at?: string","requestId: string","timeoutMs: number","error: unknown","storageType: string","key: string","originalError: Error","description: string","message: string","direction: 'inbound' | 'outbound'","code: number | string","data?: unknown","requestId?: string","originalError: unknown","operation: string","kind: string","userLogger: SDKLogger | null","debugOptions: LoggerOptions['debug']","wsTraffic: InternalSDKLogger['wsTraffic']","logger","filter","map"],"sources":["../src/core/errors.ts","../src/utils/logger.ts","../src/operators/filterNull.ts","../src/utils/getValueFrom.ts","../src/operators/filterEventAs.ts","../src/operators/throwOnRPCError.ts"],"sourcesContent":["export class UnexpectedError extends Error {\n constructor(\n public at?: string,\n options?: ErrorOptions\n ) {\n super(`Unexpected Error${at ? ` at ${at}` : ''}`, options);\n this.name = 'UnexpectedError';\n }\n}\n\nexport class UnimplementedError extends Error {\n constructor(\n public reason = 'Not Implemented',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'UnimplementedError';\n }\n}\n\nexport class NotConnectedError extends Error {\n constructor(\n public reason = 'Not Connected',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'NotConnectedError';\n }\n}\n\nexport class InvalidCredentialsError extends Error {\n constructor(\n public reason = 'Invalid Credentials',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'InvalidCredentialsError';\n }\n}\n\nexport class WebSocketConnectionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WebSocketConnectionError';\n }\n}\n\nexport class TransportConnectionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'TransportConnectionError';\n }\n}\n\nexport class WebSocketTimeoutError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WebSocketTimeoutError';\n }\n}\n\nexport class RequestTimeoutError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RequestTimeoutError';\n }\n}\n\nexport class RequestError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RequestError';\n }\n}\n\nexport class InvalidListenerError extends Error {\n constructor(options?: ErrorOptions) {\n super('listener is not a function', options);\n this.name = 'InvalidListenerError';\n }\n}\n\nexport class RPCTimeoutError extends Error {\n constructor(\n public requestId: string,\n public timeoutMs: number,\n options?: ErrorOptions\n ) {\n super(`RPC request ${requestId} timed out after ${timeoutMs}ms`, options);\n this.name = 'RPCTimeoutError';\n }\n}\n\nexport class AuthStateHandlerError extends Error {\n constructor(\n public error: unknown = null,\n options?: ErrorOptions\n ) {\n super('Error handling authorization state update', {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'AuthStateHandlerError';\n }\n}\n\nexport class InvalidStateTransitionError extends Error {\n constructor(\n public currentState: string,\n public targetState: string,\n options?: ErrorOptions\n ) {\n super(\n `Invalid transition: cannot transition from \"${currentState}\" to \"${targetState}\"`,\n options\n );\n this.name = 'InvalidStateTransitionError';\n }\n}\n\nexport class InvalidOptionError extends Error {\n constructor(\n public value: string,\n public availableOptions: string[],\n options?: ErrorOptions\n ) {\n super(\n `Invalid option: \"${value}\" must be one of the available options: ${availableOptions.join(', ')}`,\n options\n );\n this.name = 'InvalidOptionError';\n }\n}\n\nexport class StorageNotAvailableError extends Error {\n constructor(\n public storageType: string = 'localStorage',\n options?: ErrorOptions\n ) {\n super(`${storageType} is not available in this environment`, options);\n this.name = 'StorageNotAvailableError';\n }\n}\n\nexport class SerializationError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to serialize value for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'SerializationError';\n }\n}\n\nexport class DeserializationError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to deserialize value for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'DeserializationError';\n }\n}\n\nexport class StorageWriteError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to write to storage for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'StorageWriteError';\n }\n}\n\nexport class StorageReadError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to read from storage \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'StorageReadError';\n }\n}\n\nexport class InvalidStorageValueError extends Error {\n constructor(\n public key: string,\n public valueType: string,\n options?: ErrorOptions\n ) {\n super(\n `Cannot serialize value of type \"${valueType}\" for key \"${key}\": This type cannot be serialized to JSON`,\n options\n );\n this.name = 'InvalidStorageValueError';\n }\n}\n\nexport class DependencyError extends Error {\n constructor(\n public description: string,\n options?: ErrorOptions\n ) {\n super(`Dependency ${description} is not set or available.`, options);\n this.name = 'DependencyError';\n }\n}\n\nexport class DeviceNotFoundError extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'DeviceNotFoundError';\n }\n}\n\n// =============================================================================\n// CALL ERROR TYPES\n// =============================================================================\n\n/**\n * Semantic category of a call-lifecycle error.\n *\n * - `'media'` – RTCPeerConnection / media device failure\n * - `'signaling'` – Verto / JSON-RPC protocol error\n * - `'timeout'` – Call setup timed out waiting for a response\n * - `'rejected'` – Remote side rejected the call\n * - `'network'` – Transport lost during an active call\n * - `'internal'` – Unexpected / unknown error\n */\nexport type CallErrorKind = 'media' | 'signaling' | 'timeout' | 'rejected' | 'network' | 'internal';\n\n/**\n * Structured error emitted on `call.errors$`.\n *\n * Provides actionable metadata so consumers can react without\n * resorting to `instanceof` checks on raw `Error` objects.\n */\nexport interface CallError {\n /** Semantic category of the error. */\n readonly kind: CallErrorKind;\n /**\n * Whether the error terminates the call.\n * When `true`, the call will automatically transition to `'failed'`\n * and be destroyed — no further action is needed from the consumer.\n */\n readonly fatal: boolean;\n /** The underlying error. */\n readonly error: Error;\n /** ID of the call that produced this error. */\n readonly callId: string;\n}\n\nexport class CallCreateError extends Error {\n constructor(\n public message: string,\n public error: unknown = null,\n public direction: 'inbound' | 'outbound' = 'outbound',\n options?: ErrorOptions\n ) {\n super(message, {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'CallCreateError';\n }\n}\n\nexport class JSONRPCError extends Error {\n constructor(\n public code: number | string,\n message: string,\n public data?: unknown,\n options?: ErrorOptions,\n public requestId?: string\n ) {\n super(message, options);\n this.name = 'JSONRPCError';\n }\n}\n\nexport class InvalidParams extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'InvalidParams';\n }\n}\n\nexport class ConversationError extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'ConversationError';\n }\n}\n\nexport class VertoInviteHandlerError extends Error {\n constructor(\n public error: unknown = null,\n options?: ErrorOptions\n ) {\n super('Error handling Verto invite', {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'VertoInviteHandlerError';\n }\n}\n\nexport class HttpRequestError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'HttpRequestError';\n }\n}\n\nexport class ValidationError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'ValidationError';\n }\n}\n\nexport class VertoPongError extends Error {\n constructor(public originalError: unknown) {\n super('Failed to send Verto pong - call may disconnect', {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'VertoPongError';\n }\n}\n\nexport class MessageParseError extends Error {\n constructor(public originalError: unknown) {\n super('Failed to parse incoming WebSocket message', {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'MessageParseError';\n }\n}\n\nexport class CollectionFetchError extends Error {\n constructor(\n public operation: string,\n public originalError: unknown\n ) {\n super(`Collection fetch failed during ${operation}`, {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'CollectionFetchError';\n }\n}\n\nexport class MediaTrackError extends Error {\n constructor(\n public operation: string,\n public kind: string,\n public originalError: unknown\n ) {\n super(`Media track ${operation} failed for ${kind}`, {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'MediaTrackError';\n }\n}\n","import log from 'loglevel';\n\ninterface LogFn {\n <T extends object>(obj: T, msg?: string, ...args: unknown[]): void;\n (obj: unknown, msg?: string, ...args: unknown[]): void;\n (msg: string, ...args: unknown[]): void;\n}\nexport interface SDKLogger {\n fatal: LogFn;\n error: LogFn;\n warn: LogFn;\n info: LogFn;\n debug: LogFn;\n trace: LogFn;\n}\n\nexport interface WsTrafficOptions {\n type: 'send' | 'recv' | 'http';\n payload: unknown;\n}\n\nexport interface LoggerOptions {\n /** @internal */\n devTools?: boolean;\n /** @internal */\n debug?: {\n logWsTraffic?: boolean;\n };\n /** @internal */\n logger?: SDKLogger;\n}\n\nexport interface InternalSDKLogger extends SDKLogger {\n wsTraffic: (options: WsTrafficOptions) => void;\n}\n\nconst datetime = () => new Date().toISOString();\nconst defaultLogger = log.getLogger('signalwire');\n\nconst originalFactory = defaultLogger.methodFactory;\ndefaultLogger.methodFactory = (methodName, logLevel, loggerName) => {\n const rawMethod = originalFactory(methodName, logLevel, loggerName);\n\n return function (...args: unknown[]) {\n args.unshift(datetime(), '-');\n // eslint-disable-next-line prefer-spread\n rawMethod.apply(undefined, args);\n };\n};\n\nconst defaultLoggerLevel = defaultLogger.levels.DEBUG;\ndefaultLogger.setLevel(defaultLoggerLevel);\n\nlet userLogger: SDKLogger | null;\nconst setLogger = (logger: SDKLogger | null): void => {\n userLogger = logger;\n};\n\nlet debugOptions: LoggerOptions['debug'] = {};\nconst setDebugOptions = (options: unknown): void => {\n if (options == null) {\n debugOptions = {};\n return;\n }\n debugOptions = {\n ...debugOptions,\n ...options\n } as LoggerOptions['debug'];\n};\n\nconst getLoggerInstance = (): SDKLogger => {\n return userLogger ?? (defaultLogger as unknown as SDKLogger);\n};\n\nconst shouldStringify = (payload: WsTrafficOptions['payload']) => {\n //@ts-expect-error we don;t cara that payload is unknown\n if ('method' in payload && payload.method === 'signalwire.ping') {\n return false;\n }\n\n return true;\n};\n\nconst wsTraffic: InternalSDKLogger['wsTraffic'] = ({ type, payload }) => {\n const logger = getLoggerInstance();\n const { logWsTraffic } = debugOptions ?? {};\n\n if (!logWsTraffic) {\n return undefined;\n }\n\n const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;\n\n return logger.debug(`${type.toUpperCase()}: \\n`, msg, '\\n');\n};\n\nconst getLogger = (): InternalSDKLogger => {\n const logger = getLoggerInstance();\n\n return new Proxy(logger, {\n get(target, prop: keyof InternalSDKLogger, receiver) {\n if (prop === 'wsTraffic') {\n return wsTraffic;\n }\n\n return Reflect.get(target, prop, receiver);\n }\n }) as InternalSDKLogger;\n};\n\nexport { setLogger, getLogger, setDebugOptions };\n","import { filter } from 'rxjs';\n\nimport type { OperatorFunction } from 'rxjs';\n\n/**\n * RxJS operator that filters out `null` and `undefined` values with type narrowing.\n *\n * @example\n * ```ts\n * source$.pipe(filterNull()).subscribe(value => {\n * // value is guaranteed non-null\n * });\n * ```\n */\nexport function filterNull<T>(): OperatorFunction<T | null | undefined, T> {\n return filter((value): value is T => value != null);\n}\n","export const getValueFrom = <T = unknown>(\n obj: unknown,\n path: string,\n defaultValue?: T\n): T | undefined => {\n const keys = path.split('.');\n let result = obj;\n for (const key of keys) {\n if (result && typeof result === 'object' && key in result) {\n result = (result as Record<string, unknown>)[key];\n } else {\n return defaultValue;\n }\n }\n return (result === undefined ? defaultValue : result) as T;\n};\n","import { pipe } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\n\nimport { getValueFrom } from '../utils/getValueFrom';\n\nimport type { OperatorFunction } from 'rxjs';\n\n/**\n * Type helper to extract nested property types using dot notation.\n * Supports up to 4 levels of nesting.\n *\n * @example\n * type Example = { a: { b: { c: string } } }\n * type Result = PathValue<Example, 'a.b.c'> // string\n */\ntype PathValue<T, P extends string> = P extends `${infer Key}.${infer Rest}`\n ? Key extends keyof T\n ? PathValue<T[Key], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n// Usage:\n// source$.pipe(\n// isEvent(\n// (event) => event.type === 'call.started',\n// (event) => ({ id: event.id, timestamp: event.timestamp })\n// )\n// );\n\n/**\n * RxJS operator that filters events based on a predicate and maps matching events.\n *\n * This operator combines filter and map operations:\n * 1. Only events that match the predicate are emitted\n * 2. Matching events are transformed using the map function\n *\n * @template TInput - The type of input events\n * @template TOutput - The type of output after mapping\n * @param predicate - Function to test each event. Returns true to include the event.\n * @param mapFn - Function to transform matching events\n * @returns An operator function that filters and maps events\n *\n * @example\n * ```typescript\n * interface CallEvent {\n * type: 'call.started' | 'call.ended';\n * id: string;\n * timestamp: number;\n * }\n *\n * events$.pipe(\n * isEvent(\n * (event: CallEvent) => event.type === 'call.started',\n * (event: CallEvent) => ({ id: event.id, timestamp: event.timestamp })\n * )\n * ).subscribe(startEvent => {\n * console.log('Call started:', startEvent);\n * });\n * ```\n */\nexport function ifIsMap<TInput, TOutput>(\n predicate: (event: unknown) => event is TInput,\n mapFn: (event: TInput) => TOutput\n): OperatorFunction<unknown, TOutput> {\n return pipe(filter(predicate), map(mapFn));\n}\n\n/**\n * Generic RxJS operator that filters events using a type guard and extracts a property.\n *\n * This is the generic version that works with any type, not just JSONRPCRequest.\n * Use this when you need to filter and extract properties from already-narrowed types.\n *\n * **Type inference**: The output type is automatically inferred from the input type and path!\n *\n * @template TInput - The type to narrow to (via type guard)\n * @template TPath - The dot-notation path to extract (inferred from parameter)\n * @param predicate - Type guard function to filter events\n * @param resultPath - Dot-notation path to extract (e.g., 'params', 'params.data')\n * @returns An operator function that filters and extracts\n *\n * @example\n * ```typescript\n * interface EventParams {\n * event_type: string;\n * data: { value: number };\n * }\n *\n * const isAuthEvent = (e: unknown): e is EventParams =>\n * typeof e === 'object' && e !== null && 'event_type' in e;\n *\n * // Type of 'data' is automatically inferred as { value: number }\n * params$.pipe(\n * filterAs(isAuthEvent, 'data')\n * ).subscribe(data => {\n * console.log('Event data:', data.value); // TypeScript knows about .value!\n * });\n *\n * // Deeply nested properties are also inferred\n * params$.pipe(\n * filterAs(isAuthEvent, 'data.value')\n * ).subscribe(value => {\n * console.log(value); // Type is 'number'\n * });\n * ```\n */\nexport function filterAs<TInput, TPath extends string>(\n predicate: (event: unknown) => event is TInput,\n resultPath: TPath\n): OperatorFunction<unknown, PathValue<TInput, TPath>> {\n return pipe(\n ifIsMap(predicate, (event) => {\n const result = getValueFrom<PathValue<TInput, TPath>>(event, resultPath);\n return result;\n }),\n filter((value): value is PathValue<TInput, TPath> => value !== undefined)\n );\n}\n","import { map, type OperatorFunction } from 'rxjs';\n\nimport { JSONRPCError } from '../core/errors';\nimport { getLogger } from '../utils/logger';\n\nimport type { JSONRPCResponse } from '../core/RPCMessages/types/base';\n\nconst logger = getLogger();\n\n/**\n * RxJS operator that throws a {@link JSONRPCError} when the RPC response contains an error.\n * Passes successful responses through unchanged.\n */\nexport function throwOnRPCError<T extends JSONRPCResponse>(): OperatorFunction<T, T> {\n return map((response: T) => {\n if (response.error) {\n logger.error('[throwOnRPCError] RPC error response:', {\n code: response.error.code,\n message: response.error.message,\n data: response.error.data\n });\n\n throw new JSONRPCError(response.error.code, response.error.message, response.error.data);\n }\n logger.debug('[throwOnRPCError] RPC successful response:', response);\n return response;\n });\n}\n"],"mappings":";;;;;AAAA,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,AAAOA,IACP,SACA;AACA,QAAM,mBAAmB,KAAK,OAAO,OAAO,MAAM,QAAQ;EAHnD;AAIP,OAAK,OAAO;;;AAIhB,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YACE,AAAO,SAAS,mBAChB,SACA;AACA,QAAM,QAAQ,QAAQ;EAHf;AAIP,OAAK,OAAO;;;AAchB,IAAa,0BAAb,c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AAI,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0C5C,SAAgB,SACd,WACA,YACqD;AACrD,QAAO,KACL,QAAQ,YAAY,UAAU;AAE5B,SADe,aAAuC,OAAO,WAAW;GAExE,EACFD,UAAQ,UAA6C,UAAU,OAAU,CAC1E;;;;;AC/GH,MAAM,SAAS,WAAW;;;;;AAM1B,SAAgB,kBAAqE;AACnF,QAAO,KAAK,aAAgB;AAC1B,MAAI,SAAS,OAAO;AAClB,UAAO,MAAM,yCAAyC;IACpD,MAAM,SAAS,MAAM;IACrB,SAAS,SAAS,MAAM;IACxB,MAAM,SAAS,MAAM;IACtB,CAAC;AAEF,SAAM,IAAI,aAAa,SAAS,MAAM,MAAM,SAAS,MAAM,SAAS,SAAS,MAAM,KAAK;;AAE1F,SAAO,MAAM,8CAA8C,SAAS;AACpE,SAAO;GACP"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-BxFSgMTI.d.cts","names":[],"sources":["../src/core/RPCMessages/types/base.ts"],"sourcesContent":[],"mappings":";KAUY,YAAA;AAOA,KAAA,cAAA,GAAc,KAAA;AACd,KAAA,aAAA,GAAa,MAAA;AAER,UAAA,cAAc,CAAA,UAAA,OAAA,CAAA,CAAA;EACpB,OAAA,EAAA,cAAA;EAED,EAAA,EAAA,MAAA;EACC,MAAA,EADD,aACC;EAAO,MAAA,CAAA,EAAP,OAAO;AAGlB;AAOiB,UAPA,sBAOoB,CAAA,UAAA,OAAA,CAAA,CAAA;EAOzB,OAAA,EAAA,KAAA;EACe,EAAA,EAAA,MAAA;EAAvB,MAAA,EAZM,OAYN;EACA,KAAA,CAAA,EAAA,KAAA;;UATa,oBAAA;;;;;;;;;;KAOL,qCACR,uBAAuB,WACvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-DKDZK4Rr.d.mts","names":[],"sources":["../src/core/RPCMessages/types/base.ts"],"sourcesContent":[],"mappings":";KAUY,YAAA;AAOA,KAAA,cAAA,GAAc,KAAA;AACd,KAAA,aAAA,GAAa,MAAA;AAER,UAAA,cAAc,CAAA,UAAA,OAAA,CAAA,CAAA;EACpB,OAAA,EAAA,cAAA;EAED,EAAA,EAAA,MAAA;EACC,MAAA,EADD,aACC;EAAO,MAAA,CAAA,EAAP,OAAO;AAGlB;AAOiB,UAPA,sBAOoB,CAAA,UAAA,OAAA,CAAA,CAAA;EAOzB,OAAA,EAAA,KAAA;EACe,EAAA,EAAA,MAAA;EAAvB,MAAA,EAZM,OAYN;EACA,KAAA,CAAA,EAAA,KAAA;;UATa,oBAAA;;;;;;;;;;KAOL,qCACR,uBAAuB,WACvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operators-C8Tqm86j.mjs","names":["at?: string","requestId: string","timeoutMs: number","error: unknown","storageType: string","key: string","originalError: Error","description: string","message: string","direction: 'inbound' | 'outbound'","code: number","data?: unknown","originalError: unknown","operation: string","kind: string","userLogger: SDKLogger | null","debugOptions: LoggerOptions['debug']","wsTraffic: InternalSDKLogger['wsTraffic']","logger","filter","map"],"sources":["../src/core/errors.ts","../src/utils/logger.ts","../src/operators/filterNull.ts","../src/utils/getValueFrom.ts","../src/operators/filterEventAs.ts","../src/operators/throwOnRPCError.ts"],"sourcesContent":["export class UnexpectedError extends Error {\n constructor(\n public at?: string,\n options?: ErrorOptions\n ) {\n super(`Unexpected Error${at ? ` at ${at}` : ''}`, options);\n this.name = 'UnexpectedError';\n }\n}\n\nexport class UnimplementedError extends Error {\n constructor(\n public reason = 'Not Implemented',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'UnimplementedError';\n }\n}\n\nexport class NotConnectedError extends Error {\n constructor(\n public reason = 'Not Connected',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'NotConnectedError';\n }\n}\n\nexport class InvalidCredentialsError extends Error {\n constructor(\n public reason = 'Invalid Credentials',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'InvalidCredentialsError';\n }\n}\n\nexport class WebSocketConnectionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WebSocketConnectionError';\n }\n}\n\nexport class TransportConnectionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'TransportConnectionError';\n }\n}\n\nexport class WebSocketTimeoutError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WebSocketTimeoutError';\n }\n}\n\nexport class RequestTimeoutError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RequestTimeoutError';\n }\n}\n\nexport class RequestError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RequestError';\n }\n}\n\nexport class InvalidListenerError extends Error {\n constructor(options?: ErrorOptions) {\n super('listener is not a function', options);\n this.name = 'InvalidListenerError';\n }\n}\n\nexport class RPCTimeoutError extends Error {\n constructor(\n public requestId: string,\n public timeoutMs: number,\n options?: ErrorOptions\n ) {\n super(`RPC request ${requestId} timed out after ${timeoutMs}ms`, options);\n this.name = 'RPCTimeoutError';\n }\n}\n\nexport class AuthStateHandlerError extends Error {\n constructor(\n public error: unknown = null,\n options?: ErrorOptions\n ) {\n super('Error handling authorization state update', {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'AuthStateHandlerError';\n }\n}\n\nexport class InvalidStateTransitionError extends Error {\n constructor(\n public currentState: string,\n public targetState: string,\n options?: ErrorOptions\n ) {\n super(\n `Invalid transition: cannot transition from \"${currentState}\" to \"${targetState}\"`,\n options\n );\n this.name = 'InvalidStateTransitionError';\n }\n}\n\nexport class InvalidOptionError extends Error {\n constructor(\n public value: string,\n public availableOptions: string[],\n options?: ErrorOptions\n ) {\n super(\n `Invalid option: \"${value}\" must be one of the available options: ${availableOptions.join(', ')}`,\n options\n );\n this.name = 'InvalidOptionError';\n }\n}\n\nexport class StorageNotAvailableError extends Error {\n constructor(\n public storageType: string = 'localStorage',\n options?: ErrorOptions\n ) {\n super(`${storageType} is not available in this environment`, options);\n this.name = 'StorageNotAvailableError';\n }\n}\n\nexport class SerializationError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to serialize value for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'SerializationError';\n }\n}\n\nexport class DeserializationError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to deserialize value for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'DeserializationError';\n }\n}\n\nexport class StorageWriteError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to write to storage for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'StorageWriteError';\n }\n}\n\nexport class StorageReadError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to read from storage \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'StorageReadError';\n }\n}\n\nexport class InvalidStorageValueError extends Error {\n constructor(\n public key: string,\n public valueType: string,\n options?: ErrorOptions\n ) {\n super(\n `Cannot serialize value of type \"${valueType}\" for key \"${key}\": This type cannot be serialized to JSON`,\n options\n );\n this.name = 'InvalidStorageValueError';\n }\n}\n\nexport class DependencyError extends Error {\n constructor(\n public description: string,\n options?: ErrorOptions\n ) {\n super(`Dependency ${description} is not set or available.`, options);\n this.name = 'DependencyError';\n }\n}\n\nexport class DeviceNotFoundError extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'DeviceNotFoundError';\n }\n}\n\n// =============================================================================\n// CALL ERROR TYPES\n// =============================================================================\n\n/**\n * Semantic category of a call-lifecycle error.\n *\n * - `'media'` – RTCPeerConnection / media device failure\n * - `'signaling'` – Verto / JSON-RPC protocol error\n * - `'timeout'` – Call setup timed out waiting for a response\n * - `'rejected'` – Remote side rejected the call\n * - `'network'` – Transport lost during an active call\n * - `'internal'` – Unexpected / unknown error\n */\nexport type CallErrorKind = 'media' | 'signaling' | 'timeout' | 'rejected' | 'network' | 'internal';\n\n/**\n * Structured error emitted on `call.errors$`.\n *\n * Provides actionable metadata so consumers can react without\n * resorting to `instanceof` checks on raw `Error` objects.\n */\nexport interface CallError {\n /** Semantic category of the error. */\n readonly kind: CallErrorKind;\n /**\n * Whether the error terminates the call.\n * When `true`, the call will automatically transition to `'failed'`\n * and be destroyed — no further action is needed from the consumer.\n */\n readonly fatal: boolean;\n /** The underlying error. */\n readonly error: Error;\n /** ID of the call that produced this error. */\n readonly callId: string;\n}\n\nexport class CallCreateError extends Error {\n constructor(\n public message: string,\n public error: unknown = null,\n public direction: 'inbound' | 'outbound' = 'outbound',\n options?: ErrorOptions\n ) {\n super(message, {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'CallCreateError';\n }\n}\n\nexport class JSONRPCError extends Error {\n constructor(\n public code: number,\n message: string,\n public data?: unknown,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'JSONRPCError';\n }\n}\n\nexport class RPCError extends Error {\n constructor(\n public code: number,\n public requestId: string,\n message: string,\n public data?: unknown,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'RPCError';\n }\n}\n\nexport class InvalidParams extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'InvalidParams';\n }\n}\n\nexport class ConversationError extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'ConversationError';\n }\n}\n\nexport class VertoInviteHandlerError extends Error {\n constructor(\n public error: unknown = null,\n options?: ErrorOptions\n ) {\n super('Error handling Verto invite', {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'VertoInviteHandlerError';\n }\n}\n\nexport class HttpRequestError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'HttpRequestError';\n }\n}\n\nexport class ValidationError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'ValidationError';\n }\n}\n\nexport class VertoPongError extends Error {\n constructor(public originalError: unknown) {\n super('Failed to send Verto pong - call may disconnect', {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'VertoPongError';\n }\n}\n\nexport class MessageParseError extends Error {\n constructor(public originalError: unknown) {\n super('Failed to parse incoming WebSocket message', {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'MessageParseError';\n }\n}\n\nexport class CollectionFetchError extends Error {\n constructor(\n public operation: string,\n public originalError: unknown\n ) {\n super(`Collection fetch failed during ${operation}`, {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'CollectionFetchError';\n }\n}\n\nexport class MediaTrackError extends Error {\n constructor(\n public operation: string,\n public kind: string,\n public originalError: unknown\n ) {\n super(`Media track ${operation} failed for ${kind}`, {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'MediaTrackError';\n }\n}\n","import log from 'loglevel';\n\ninterface LogFn {\n <T extends object>(obj: T, msg?: string, ...args: unknown[]): void;\n (obj: unknown, msg?: string, ...args: unknown[]): void;\n (msg: string, ...args: unknown[]): void;\n}\nexport interface SDKLogger {\n fatal: LogFn;\n error: LogFn;\n warn: LogFn;\n info: LogFn;\n debug: LogFn;\n trace: LogFn;\n}\n\nexport interface WsTrafficOptions {\n type: 'send' | 'recv' | 'http';\n payload: unknown;\n}\n\nexport interface LoggerOptions {\n /** @internal */\n devTools?: boolean;\n /** @internal */\n debug?: {\n logWsTraffic?: boolean;\n };\n /** @internal */\n logger?: SDKLogger;\n}\n\nexport interface InternalSDKLogger extends SDKLogger {\n wsTraffic: (options: WsTrafficOptions) => void;\n}\n\nconst datetime = () => new Date().toISOString();\nconst defaultLogger = log.getLogger('signalwire');\n\nconst originalFactory = defaultLogger.methodFactory;\ndefaultLogger.methodFactory = (methodName, logLevel, loggerName) => {\n const rawMethod = originalFactory(methodName, logLevel, loggerName);\n\n return function (...args: unknown[]) {\n args.unshift(datetime(), '-');\n // eslint-disable-next-line prefer-spread\n rawMethod.apply(undefined, args);\n };\n};\n\nconst defaultLoggerLevel = defaultLogger.levels.DEBUG;\ndefaultLogger.setLevel(defaultLoggerLevel);\n\nlet userLogger: SDKLogger | null;\nconst setLogger = (logger: SDKLogger | null): void => {\n userLogger = logger;\n};\n\nlet debugOptions: LoggerOptions['debug'] = {};\nconst setDebugOptions = (options: unknown): void => {\n if (options == null) {\n debugOptions = {};\n return;\n }\n debugOptions = {\n ...debugOptions,\n ...options\n } as LoggerOptions['debug'];\n};\n\nconst getLoggerInstance = (): SDKLogger => {\n return userLogger ?? (defaultLogger as unknown as SDKLogger);\n};\n\nconst shouldStringify = (payload: WsTrafficOptions['payload']) => {\n //@ts-expect-error we don;t cara that payload is unknown\n if ('method' in payload && payload.method === 'signalwire.ping') {\n return false;\n }\n\n return true;\n};\n\nconst wsTraffic: InternalSDKLogger['wsTraffic'] = ({ type, payload }) => {\n const logger = getLoggerInstance();\n const { logWsTraffic } = debugOptions ?? {};\n\n if (!logWsTraffic) {\n return undefined;\n }\n\n const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;\n\n return logger.debug(`${type.toUpperCase()}: \\n`, msg, '\\n');\n};\n\nconst getLogger = (): InternalSDKLogger => {\n const logger = getLoggerInstance();\n\n return new Proxy(logger, {\n get(target, prop: keyof InternalSDKLogger, receiver) {\n if (prop === 'wsTraffic') {\n return wsTraffic;\n }\n\n return Reflect.get(target, prop, receiver);\n }\n }) as InternalSDKLogger;\n};\n\nexport { setLogger, getLogger, setDebugOptions };\n","import { filter } from 'rxjs';\n\nimport type { OperatorFunction } from 'rxjs';\n\n/**\n * RxJS operator that filters out `null` and `undefined` values with type narrowing.\n *\n * @example\n * ```ts\n * source$.pipe(filterNull()).subscribe(value => {\n * // value is guaranteed non-null\n * });\n * ```\n */\nexport function filterNull<T>(): OperatorFunction<T | null | undefined, T> {\n return filter((value): value is T => value != null);\n}\n","export const getValueFrom = <T = unknown>(\n obj: unknown,\n path: string,\n defaultValue?: T\n): T | undefined => {\n const keys = path.split('.');\n let result = obj;\n for (const key of keys) {\n if (result && typeof result === 'object' && key in result) {\n result = (result as Record<string, unknown>)[key];\n } else {\n return defaultValue;\n }\n }\n return (result === undefined ? defaultValue : result) as T;\n};\n","import { pipe } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\n\nimport { getValueFrom } from '../utils/getValueFrom';\n\nimport type { OperatorFunction } from 'rxjs';\n\n/**\n * Type helper to extract nested property types using dot notation.\n * Supports up to 4 levels of nesting.\n *\n * @example\n * type Example = { a: { b: { c: string } } }\n * type Result = PathValue<Example, 'a.b.c'> // string\n */\ntype PathValue<T, P extends string> = P extends `${infer Key}.${infer Rest}`\n ? Key extends keyof T\n ? PathValue<T[Key], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n// Usage:\n// source$.pipe(\n// isEvent(\n// (event) => event.type === 'call.started',\n// (event) => ({ id: event.id, timestamp: event.timestamp })\n// )\n// );\n\n/**\n * RxJS operator that filters events based on a predicate and maps matching events.\n *\n * This operator combines filter and map operations:\n * 1. Only events that match the predicate are emitted\n * 2. Matching events are transformed using the map function\n *\n * @template TInput - The type of input events\n * @template TOutput - The type of output after mapping\n * @param predicate - Function to test each event. Returns true to include the event.\n * @param mapFn - Function to transform matching events\n * @returns An operator function that filters and maps events\n *\n * @example\n * ```typescript\n * interface CallEvent {\n * type: 'call.started' | 'call.ended';\n * id: string;\n * timestamp: number;\n * }\n *\n * events$.pipe(\n * isEvent(\n * (event: CallEvent) => event.type === 'call.started',\n * (event: CallEvent) => ({ id: event.id, timestamp: event.timestamp })\n * )\n * ).subscribe(startEvent => {\n * console.log('Call started:', startEvent);\n * });\n * ```\n */\nexport function ifIsMap<TInput, TOutput>(\n predicate: (event: unknown) => event is TInput,\n mapFn: (event: TInput) => TOutput\n): OperatorFunction<unknown, TOutput> {\n return pipe(filter(predicate), map(mapFn));\n}\n\n/**\n * Generic RxJS operator that filters events using a type guard and extracts a property.\n *\n * This is the generic version that works with any type, not just JSONRPCRequest.\n * Use this when you need to filter and extract properties from already-narrowed types.\n *\n * **Type inference**: The output type is automatically inferred from the input type and path!\n *\n * @template TInput - The type to narrow to (via type guard)\n * @template TPath - The dot-notation path to extract (inferred from parameter)\n * @param predicate - Type guard function to filter events\n * @param resultPath - Dot-notation path to extract (e.g., 'params', 'params.data')\n * @returns An operator function that filters and extracts\n *\n * @example\n * ```typescript\n * interface EventParams {\n * event_type: string;\n * data: { value: number };\n * }\n *\n * const isAuthEvent = (e: unknown): e is EventParams =>\n * typeof e === 'object' && e !== null && 'event_type' in e;\n *\n * // Type of 'data' is automatically inferred as { value: number }\n * params$.pipe(\n * filterAs(isAuthEvent, 'data')\n * ).subscribe(data => {\n * console.log('Event data:', data.value); // TypeScript knows about .value!\n * });\n *\n * // Deeply nested properties are also inferred\n * params$.pipe(\n * filterAs(isAuthEvent, 'data.value')\n * ).subscribe(value => {\n * console.log(value); // Type is 'number'\n * });\n * ```\n */\nexport function filterAs<TInput, TPath extends string>(\n predicate: (event: unknown) => event is TInput,\n resultPath: TPath\n): OperatorFunction<unknown, PathValue<TInput, TPath>> {\n return pipe(\n ifIsMap(predicate, (event) => {\n const result = getValueFrom<PathValue<TInput, TPath>>(event, resultPath);\n return result;\n }),\n filter((value): value is PathValue<TInput, TPath> => value !== undefined)\n );\n}\n","import { map, type OperatorFunction } from 'rxjs';\n\nimport { JSONRPCError } from '../core/errors';\nimport { getLogger } from '../utils/logger';\n\nimport type { JSONRPCResponse } from '../core/RPCMessages/types/base';\n\nconst logger = getLogger();\n\n/**\n * RxJS operator that throws a {@link JSONRPCError} when the RPC response contains an error.\n * Passes successful responses through unchanged.\n */\nexport function throwOnRPCError<T extends JSONRPCResponse>(): OperatorFunction<T, T> {\n return map((response: T) => {\n if (response.error) {\n logger.error('[throwOnRPCError] RPC error response:', {\n code: response.error.code,\n message: response.error.message,\n data: response.error.data\n });\n\n throw new JSONRPCError(response.error.code, response.error.message, response.error.data);\n }\n logger.debug('[throwOnRPCError] RPC successful response:', response);\n return response;\n });\n}\n"],"mappings":";;;;;AAAA,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,AAAOA,IACP,SACA;AACA,QAAM,mBAAmB,KAAK,OAAO,OAAO,MAAM,QAAQ;EAHnD;AAIP,OAAK,OAAO;;;AAIhB,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YACE,AAAO,SAAS,mBAChB,SACA;AACA,QAAM,QAAQ,QAAQ;EAHf;AAIP,OAAK,OAAO;;;AAchB,IAAa,0BAAb,cAA6C,MAAM;CACjD,YACE,AAAO,SAAS,uBAChB,SACA;AACA,QAAM,QAAQ,QAAQ;EAHf;AAIP,OAAK,OAAO;;;AAIhB,IAAa,2BAAb,cAA8C,MAAM;CAClD,YAAY,SAAiB,SAAwB;AACnD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;AAIhB,IAAa,2BAAb,cAA8C,MAAM;CAClD,YAAY,SAAiB,SAAwB;AACnD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;AAIhB,IAAa,wBAAb,cAA2C,MAAM;CAC/C,YAAY,SAAiB,SAAwB;AACnD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;AAIhB,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,SAAiB,SAAwB;AACnD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;AAIhB,IAAa,eAAb,cAAkC,MAAM;CACtC,YAAY,SAAiB,SAAwB;AACnD,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;;;AAWhB,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,AAAOC,WACP,AAAOC,WACP,SACA;AACA,QAAM,eAAe,UAAU,mBAAmB,UAAU,KAAK,QAAQ;EAJlE;EACA;AAIP,OAAK,OAAO;;;AAIhB,IAAa,wBAAb,cAA2C,MAAM;CAC/C,YACE,AAAOC,Q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QAAQ,MAA+B,UAAU;AACnD,MAAI,SAAS,YACX,QAAO;AAGT,SAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC;;;;;;;;;;;;;;;AC7FJ,SAAgB,aAA2D;AACzE,QAAO,QAAQ,UAAsB,SAAS,KAAK;;;;;ACfrD,MAAa,gBACX,KACA,MACA,iBACkB;CAClB,MAAM,OAAO,KAAK,MAAM,IAAI;CAC5B,IAAI,SAAS;AACb,MAAK,MAAM,OAAO,KAChB,KAAI,UAAU,OAAO,WAAW,YAAY,OAAO,OACjD,UAAU,OAAmC;KAE7C,QAAO;AAGX,QAAQ,WAAW,SAAY,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgDhD,SAAgB,QACd,WACA,OACoC;AACpC,QAAO,KAAKC,SAAO,UAAU,EAAEC,MAAI,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0C5C,SAAgB,SACd,WACA,YACqD;AACrD,QAAO,KACL,QAAQ,YAAY,UAAU;AAE5B,SADe,aAAuC,OAAO,WAAW;GAExE,EACFD,UAAQ,UAA6C,UAAU,OAAU,CAC1E;;;;;AC/GH,MAAM,SAAS,WAAW;;;;;AAM1B,SAAgB,kBAAqE;AACnF,QAAO,KAAK,aAAgB;AAC1B,MAAI,SAAS,OAAO;AAClB,UAAO,MAAM,yCAAyC;IACpD,MAAM,SAAS,MAAM;IACrB,SAAS,SAAS,MAAM;IACxB,MAAM,SAAS,MAAM;IACtB,CAAC;AAEF,SAAM,IAAI,aAAa,SAAS,MAAM,MAAM,SAAS,MAAM,SAAS,SAAS,MAAM,KAAK;;AAE1F,SAAO,MAAM,8CAA8C,SAAS;AACpE,SAAO;GACP"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operators-CJEML6aa.cjs","names":["at?: string","requestId: string","timeoutMs: number","error: unknown","storageType: string","key: string","originalError: Error","description: string","message: string","direction: 'inbound' | 'outbound'","code: number","data?: unknown","originalError: unknown","operation: string","kind: string","log","userLogger: SDKLogger | null","debugOptions: LoggerOptions['debug']","wsTraffic: InternalSDKLogger['wsTraffic']","logger"],"sources":["../src/core/errors.ts","../src/utils/logger.ts","../src/operators/filterNull.ts","../src/utils/getValueFrom.ts","../src/operators/filterEventAs.ts","../src/operators/throwOnRPCError.ts"],"sourcesContent":["export class UnexpectedError extends Error {\n constructor(\n public at?: string,\n options?: ErrorOptions\n ) {\n super(`Unexpected Error${at ? ` at ${at}` : ''}`, options);\n this.name = 'UnexpectedError';\n }\n}\n\nexport class UnimplementedError extends Error {\n constructor(\n public reason = 'Not Implemented',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'UnimplementedError';\n }\n}\n\nexport class NotConnectedError extends Error {\n constructor(\n public reason = 'Not Connected',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'NotConnectedError';\n }\n}\n\nexport class InvalidCredentialsError extends Error {\n constructor(\n public reason = 'Invalid Credentials',\n options?: ErrorOptions\n ) {\n super(reason, options);\n this.name = 'InvalidCredentialsError';\n }\n}\n\nexport class WebSocketConnectionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WebSocketConnectionError';\n }\n}\n\nexport class TransportConnectionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'TransportConnectionError';\n }\n}\n\nexport class WebSocketTimeoutError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'WebSocketTimeoutError';\n }\n}\n\nexport class RequestTimeoutError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RequestTimeoutError';\n }\n}\n\nexport class RequestError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RequestError';\n }\n}\n\nexport class InvalidListenerError extends Error {\n constructor(options?: ErrorOptions) {\n super('listener is not a function', options);\n this.name = 'InvalidListenerError';\n }\n}\n\nexport class RPCTimeoutError extends Error {\n constructor(\n public requestId: string,\n public timeoutMs: number,\n options?: ErrorOptions\n ) {\n super(`RPC request ${requestId} timed out after ${timeoutMs}ms`, options);\n this.name = 'RPCTimeoutError';\n }\n}\n\nexport class AuthStateHandlerError extends Error {\n constructor(\n public error: unknown = null,\n options?: ErrorOptions\n ) {\n super('Error handling authorization state update', {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'AuthStateHandlerError';\n }\n}\n\nexport class InvalidStateTransitionError extends Error {\n constructor(\n public currentState: string,\n public targetState: string,\n options?: ErrorOptions\n ) {\n super(\n `Invalid transition: cannot transition from \"${currentState}\" to \"${targetState}\"`,\n options\n );\n this.name = 'InvalidStateTransitionError';\n }\n}\n\nexport class InvalidOptionError extends Error {\n constructor(\n public value: string,\n public availableOptions: string[],\n options?: ErrorOptions\n ) {\n super(\n `Invalid option: \"${value}\" must be one of the available options: ${availableOptions.join(', ')}`,\n options\n );\n this.name = 'InvalidOptionError';\n }\n}\n\nexport class StorageNotAvailableError extends Error {\n constructor(\n public storageType: string = 'localStorage',\n options?: ErrorOptions\n ) {\n super(`${storageType} is not available in this environment`, options);\n this.name = 'StorageNotAvailableError';\n }\n}\n\nexport class SerializationError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to serialize value for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'SerializationError';\n }\n}\n\nexport class DeserializationError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to deserialize value for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'DeserializationError';\n }\n}\n\nexport class StorageWriteError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to write to storage for key \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'StorageWriteError';\n }\n}\n\nexport class StorageReadError extends Error {\n constructor(\n public key: string,\n public originalError: Error\n ) {\n super(`Failed to read from storage \"${key}\": ${originalError.message}`, {\n cause: originalError\n });\n this.name = 'StorageReadError';\n }\n}\n\nexport class InvalidStorageValueError extends Error {\n constructor(\n public key: string,\n public valueType: string,\n options?: ErrorOptions\n ) {\n super(\n `Cannot serialize value of type \"${valueType}\" for key \"${key}\": This type cannot be serialized to JSON`,\n options\n );\n this.name = 'InvalidStorageValueError';\n }\n}\n\nexport class DependencyError extends Error {\n constructor(\n public description: string,\n options?: ErrorOptions\n ) {\n super(`Dependency ${description} is not set or available.`, options);\n this.name = 'DependencyError';\n }\n}\n\nexport class DeviceNotFoundError extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'DeviceNotFoundError';\n }\n}\n\n// =============================================================================\n// CALL ERROR TYPES\n// =============================================================================\n\n/**\n * Semantic category of a call-lifecycle error.\n *\n * - `'media'` – RTCPeerConnection / media device failure\n * - `'signaling'` – Verto / JSON-RPC protocol error\n * - `'timeout'` – Call setup timed out waiting for a response\n * - `'rejected'` – Remote side rejected the call\n * - `'network'` – Transport lost during an active call\n * - `'internal'` – Unexpected / unknown error\n */\nexport type CallErrorKind = 'media' | 'signaling' | 'timeout' | 'rejected' | 'network' | 'internal';\n\n/**\n * Structured error emitted on `call.errors$`.\n *\n * Provides actionable metadata so consumers can react without\n * resorting to `instanceof` checks on raw `Error` objects.\n */\nexport interface CallError {\n /** Semantic category of the error. */\n readonly kind: CallErrorKind;\n /**\n * Whether the error terminates the call.\n * When `true`, the call will automatically transition to `'failed'`\n * and be destroyed — no further action is needed from the consumer.\n */\n readonly fatal: boolean;\n /** The underlying error. */\n readonly error: Error;\n /** ID of the call that produced this error. */\n readonly callId: string;\n}\n\nexport class CallCreateError extends Error {\n constructor(\n public message: string,\n public error: unknown = null,\n public direction: 'inbound' | 'outbound' = 'outbound',\n options?: ErrorOptions\n ) {\n super(message, {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'CallCreateError';\n }\n}\n\nexport class JSONRPCError extends Error {\n constructor(\n public code: number,\n message: string,\n public data?: unknown,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'JSONRPCError';\n }\n}\n\nexport class RPCError extends Error {\n constructor(\n public code: number,\n public requestId: string,\n message: string,\n public data?: unknown,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'RPCError';\n }\n}\n\nexport class InvalidParams extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'InvalidParams';\n }\n}\n\nexport class ConversationError extends Error {\n constructor(\n public message: string,\n options?: ErrorOptions\n ) {\n super(message, options);\n this.name = 'ConversationError';\n }\n}\n\nexport class VertoInviteHandlerError extends Error {\n constructor(\n public error: unknown = null,\n options?: ErrorOptions\n ) {\n super('Error handling Verto invite', {\n ...options,\n cause: options?.cause ?? (error instanceof Error ? error : undefined)\n });\n this.name = 'VertoInviteHandlerError';\n }\n}\n\nexport class HttpRequestError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'HttpRequestError';\n }\n}\n\nexport class ValidationError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'ValidationError';\n }\n}\n\nexport class VertoPongError extends Error {\n constructor(public originalError: unknown) {\n super('Failed to send Verto pong - call may disconnect', {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'VertoPongError';\n }\n}\n\nexport class MessageParseError extends Error {\n constructor(public originalError: unknown) {\n super('Failed to parse incoming WebSocket message', {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'MessageParseError';\n }\n}\n\nexport class CollectionFetchError extends Error {\n constructor(\n public operation: string,\n public originalError: unknown\n ) {\n super(`Collection fetch failed during ${operation}`, {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'CollectionFetchError';\n }\n}\n\nexport class MediaTrackError extends Error {\n constructor(\n public operation: string,\n public kind: string,\n public originalError: unknown\n ) {\n super(`Media track ${operation} failed for ${kind}`, {\n cause: originalError instanceof Error ? originalError : undefined\n });\n this.name = 'MediaTrackError';\n }\n}\n","import log from 'loglevel';\n\ninterface LogFn {\n <T extends object>(obj: T, msg?: string, ...args: unknown[]): void;\n (obj: unknown, msg?: string, ...args: unknown[]): void;\n (msg: string, ...args: unknown[]): void;\n}\nexport interface SDKLogger {\n fatal: LogFn;\n error: LogFn;\n warn: LogFn;\n info: LogFn;\n debug: LogFn;\n trace: LogFn;\n}\n\nexport interface WsTrafficOptions {\n type: 'send' | 'recv' | 'http';\n payload: unknown;\n}\n\nexport interface LoggerOptions {\n /** @internal */\n devTools?: boolean;\n /** @internal */\n debug?: {\n logWsTraffic?: boolean;\n };\n /** @internal */\n logger?: SDKLogger;\n}\n\nexport interface InternalSDKLogger extends SDKLogger {\n wsTraffic: (options: WsTrafficOptions) => void;\n}\n\nconst datetime = () => new Date().toISOString();\nconst defaultLogger = log.getLogger('signalwire');\n\nconst originalFactory = defaultLogger.methodFactory;\ndefaultLogger.methodFactory = (methodName, logLevel, loggerName) => {\n const rawMethod = originalFactory(methodName, logLevel, loggerName);\n\n return function (...args: unknown[]) {\n args.unshift(datetime(), '-');\n // eslint-disable-next-line prefer-spread\n rawMethod.apply(undefined, args);\n };\n};\n\nconst defaultLoggerLevel = defaultLogger.levels.DEBUG;\ndefaultLogger.setLevel(defaultLoggerLevel);\n\nlet userLogger: SDKLogger | null;\nconst setLogger = (logger: SDKLogger | null): void => {\n userLogger = logger;\n};\n\nlet debugOptions: LoggerOptions['debug'] = {};\nconst setDebugOptions = (options: unknown): void => {\n if (options == null) {\n debugOptions = {};\n return;\n }\n debugOptions = {\n ...debugOptions,\n ...options\n } as LoggerOptions['debug'];\n};\n\nconst getLoggerInstance = (): SDKLogger => {\n return userLogger ?? (defaultLogger as unknown as SDKLogger);\n};\n\nconst shouldStringify = (payload: WsTrafficOptions['payload']) => {\n //@ts-expect-error we don;t cara that payload is unknown\n if ('method' in payload && payload.method === 'signalwire.ping') {\n return false;\n }\n\n return true;\n};\n\nconst wsTraffic: InternalSDKLogger['wsTraffic'] = ({ type, payload }) => {\n const logger = getLoggerInstance();\n const { logWsTraffic } = debugOptions ?? {};\n\n if (!logWsTraffic) {\n return undefined;\n }\n\n const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;\n\n return logger.debug(`${type.toUpperCase()}: \\n`, msg, '\\n');\n};\n\nconst getLogger = (): InternalSDKLogger => {\n const logger = getLoggerInstance();\n\n return new Proxy(logger, {\n get(target, prop: keyof InternalSDKLogger, receiver) {\n if (prop === 'wsTraffic') {\n return wsTraffic;\n }\n\n return Reflect.get(target, prop, receiver);\n }\n }) as InternalSDKLogger;\n};\n\nexport { setLogger, getLogger, setDebugOptions };\n","import { filter } from 'rxjs';\n\nimport type { OperatorFunction } from 'rxjs';\n\n/**\n * RxJS operator that filters out `null` and `undefined` values with type narrowing.\n *\n * @example\n * ```ts\n * source$.pipe(filterNull()).subscribe(value => {\n * // value is guaranteed non-null\n * });\n * ```\n */\nexport function filterNull<T>(): OperatorFunction<T | null | undefined, T> {\n return filter((value): value is T => value != null);\n}\n","export const getValueFrom = <T = unknown>(\n obj: unknown,\n path: string,\n defaultValue?: T\n): T | undefined => {\n const keys = path.split('.');\n let result = obj;\n for (const key of keys) {\n if (result && typeof result === 'object' && key in result) {\n result = (result as Record<string, unknown>)[key];\n } else {\n return defaultValue;\n }\n }\n return (result === undefined ? defaultValue : result) as T;\n};\n","import { pipe } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\n\nimport { getValueFrom } from '../utils/getValueFrom';\n\nimport type { OperatorFunction } from 'rxjs';\n\n/**\n * Type helper to extract nested property types using dot notation.\n * Supports up to 4 levels of nesting.\n *\n * @example\n * type Example = { a: { b: { c: string } } }\n * type Result = PathValue<Example, 'a.b.c'> // string\n */\ntype PathValue<T, P extends string> = P extends `${infer Key}.${infer Rest}`\n ? Key extends keyof T\n ? PathValue<T[Key], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n// Usage:\n// source$.pipe(\n// isEvent(\n// (event) => event.type === 'call.started',\n// (event) => ({ id: event.id, timestamp: event.timestamp })\n// )\n// );\n\n/**\n * RxJS operator that filters events based on a predicate and maps matching events.\n *\n * This operator combines filter and map operations:\n * 1. Only events that match the predicate are emitted\n * 2. Matching events are transformed using the map function\n *\n * @template TInput - The type of input events\n * @template TOutput - The type of output after mapping\n * @param predicate - Function to test each event. Returns true to include the event.\n * @param mapFn - Function to transform matching events\n * @returns An operator function that filters and maps events\n *\n * @example\n * ```typescript\n * interface CallEvent {\n * type: 'call.started' | 'call.ended';\n * id: string;\n * timestamp: number;\n * }\n *\n * events$.pipe(\n * isEvent(\n * (event: CallEvent) => event.type === 'call.started',\n * (event: CallEvent) => ({ id: event.id, timestamp: event.timestamp })\n * )\n * ).subscribe(startEvent => {\n * console.log('Call started:', startEvent);\n * });\n * ```\n */\nexport function ifIsMap<TInput, TOutput>(\n predicate: (event: unknown) => event is TInput,\n mapFn: (event: TInput) => TOutput\n): OperatorFunction<unknown, TOutput> {\n return pipe(filter(predicate), map(mapFn));\n}\n\n/**\n * Generic RxJS operator that filters events using a type guard and extracts a property.\n *\n * This is the generic version that works with any type, not just JSONRPCRequest.\n * Use this when you need to filter and extract properties from already-narrowed types.\n *\n * **Type inference**: The output type is automatically inferred from the input type and path!\n *\n * @template TInput - The type to narrow to (via type guard)\n * @template TPath - The dot-notation path to extract (inferred from parameter)\n * @param predicate - Type guard function to filter events\n * @param resultPath - Dot-notation path to extract (e.g., 'params', 'params.data')\n * @returns An operator function that filters and extracts\n *\n * @example\n * ```typescript\n * interface EventParams {\n * event_type: string;\n * data: { value: number };\n * }\n *\n * const isAuthEvent = (e: unknown): e is EventParams =>\n * typeof e === 'object' && e !== null && 'event_type' in e;\n *\n * // Type of 'data' is automatically inferred as { value: number }\n * params$.pipe(\n * filterAs(isAuthEvent, 'data')\n * ).subscribe(data => {\n * console.log('Event data:', data.value); // TypeScript knows about .value!\n * });\n *\n * // Deeply nested properties are also inferred\n * params$.pipe(\n * filterAs(isAuthEvent, 'data.value')\n * ).subscribe(value => {\n * console.log(value); // Type is 'number'\n * });\n * ```\n */\nexport function filterAs<TInput, TPath extends string>(\n predicate: (event: unknown) => event is TInput,\n resultPath: TPath\n): OperatorFunction<unknown, PathValue<TInput, TPath>> {\n return pipe(\n ifIsMap(predicate, (event) => {\n const result = getValueFrom<PathValue<TInput, TPath>>(event, resultPath);\n return result;\n }),\n filter((value): value is PathValue<TInput, TPath> => value !== undefined)\n );\n}\n","import { map, type OperatorFunction } from 'rxjs';\n\nimport { JSONRPCError } from '../core/errors';\nimport { getLogger } from '../utils/logger';\n\nimport type { JSONRPCResponse } from '../core/RPCMessages/types/base';\n\nconst logger = getLogger();\n\n/**\n * RxJS operator that throws a {@link JSONRPCError} when the RPC response contains an error.\n * Passes successful responses through unchanged.\n */\nexport function throwOnRPCError<T extends JSONRPCResponse>(): OperatorFunction<T, T> {\n return map((response: T) => {\n if (response.error) {\n logger.error('[throwOnRPCError] RPC error response:', {\n code: response.error.code,\n message: response.error.message,\n data: response.error.data\n });\n\n throw new JSONRPCError(response.error.code, response.error.message, response.error.data);\n }\n logger.debug('[throwOnRPCError] RPC successful response:', response);\n return response;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACE,AAAOA,IACP,SACA;AACA,QAAM,mBAAmB,KAAK,OAAO,OAAO,MAAM,QAAQ;EAHnD;AAIP,OAAK,OAAO;;;AAIhB,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YACE,AAAO,SAAS,mBAChB,SACA;AACA,QAAM,QAAQ,QAAQ;EAHf;AAIP,OAAK,OAAO;;;AAchB,IAAa,0BAAb,cAA6C,MAAM;CACjD,YACE,AAAO,SAAS,uBAChB,SACA;AACA,QAAM,QAAQ,QAAQ;EAHf;AAIP,OAAK,OAAO;;;AAIhB,IAAa,2BAAb,cAA8C,MAAM;CAClD,YAAY,SAAiB,SAAwB;AACnD,QAAM,SA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