diff --git a/.github/actions/setup-for-scripts/action.yml b/.github/actions/setup-for-scripts/action.yml index 2c75e6fc2d8fd9..93196bbc5d3d78 100644 --- a/.github/actions/setup-for-scripts/action.yml +++ b/.github/actions/setup-for-scripts/action.yml @@ -7,7 +7,7 @@ runs: - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: '24' - - uses: pnpm/action-setup@739bfe42ca9233c5e6aca07c1a25a9d34aca49b0 # v6.0.7 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 with: run_install: | - args: [--filter, ., --filter, '{./scripts}...'] diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c80482860b5d77..52ecbc00412664 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -39,7 +39,7 @@ jobs: with: node-version: '24' - - uses: pnpm/action-setup@739bfe42ca9233c5e6aca07c1a25a9d34aca49b0 # v6.0.7 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - id: matrix run: | @@ -79,7 +79,7 @@ jobs: printf "Aborting: symlinks found:\n%s" "$symlinks"; exit 1 fi - - uses: pnpm/action-setup@739bfe42ca9233c5e6aca07c1a25a9d34aca49b0 # v6.0.7 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Get pnpm cache info id: pnpm-cache diff --git a/.github/workflows/pnpm-cache.yml b/.github/workflows/pnpm-cache.yml index 90d7ea81f7d522..da41cf6fa3fe03 100644 --- a/.github/workflows/pnpm-cache.yml +++ b/.github/workflows/pnpm-cache.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: '24' - - uses: pnpm/action-setup@739bfe42ca9233c5e6aca07c1a25a9d34aca49b0 # v6.0.7 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - name: Get pnpm cache info id: pnpm-cache diff --git a/types/koa/index.d.ts b/types/koa/index.d.ts index 2da645b512f9f5..3ea4b4ae81171c 100644 --- a/types/koa/index.d.ts +++ b/types/koa/index.d.ts @@ -543,6 +543,9 @@ declare class Application< } declare namespace Application { + interface DefaultContextDelegatedRequest extends ContextDelegatedRequest {} + interface DefaultContextDelegatedResponse extends ContextDelegatedResponse {} + type DefaultStateExtends = any; /** * This interface can be augmented by users to add types to Koa's default state @@ -564,7 +567,7 @@ declare namespace Application { ParameterizedContext >; - interface BaseRequest extends ContextDelegatedRequest { + interface BaseRequest extends DefaultContextDelegatedRequest { /** * Get the charset when present or undefined. */ @@ -592,7 +595,7 @@ declare namespace Application { toJSON(): any; } - interface BaseResponse extends ContextDelegatedResponse { + interface BaseResponse extends DefaultContextDelegatedResponse { /** * Return the request socket. * @@ -654,7 +657,7 @@ declare namespace Application { toJSON(): any; } - interface BaseContext extends ContextDelegatedRequest, ContextDelegatedResponse { + interface BaseContext extends DefaultContextDelegatedRequest, DefaultContextDelegatedResponse { /** * util.inspect() implementation, which * just returns the JSON output. diff --git a/types/koa/test/augment-delegated.ts b/types/koa/test/augment-delegated.ts new file mode 100644 index 00000000000000..89c5fa72ad0f44 --- /dev/null +++ b/types/koa/test/augment-delegated.ts @@ -0,0 +1,31 @@ +import Koa = require("koa"); + +declare module "koa" { + interface DefaultContextDelegatedRequest { + requestId: string; + } + + interface DefaultContextDelegatedResponse { + sendCustom(payload: unknown): void; + } +} + +const app = new Koa(); + +app.use((ctx, next) => { + // Augmented members are visible on ctx (delegated through BaseContext). + ctx.requestId; // $ExpectType string + ctx.sendCustom({ ok: true }); + + // Augmented members are visible on request/response as well. + ctx.request.requestId; // $ExpectType string + ctx.response.sendCustom("hello"); + + // Original delegated members still exist — augmentation must not erase them. + ctx.redirect("/login"); + ctx.attachment("file.txt"); + ctx.header; // $ExpectType IncomingHttpHeaders + ctx.method; // $ExpectType string + + return next(); +}); diff --git a/types/koa/tsconfig.json b/types/koa/tsconfig.json index aa8f83fee67449..0e3820f3a7947d 100644 --- a/types/koa/tsconfig.json +++ b/types/koa/tsconfig.json @@ -5,7 +5,8 @@ "test/constructor.ts", "test/default.ts", "test/settings.ts", - "test/typed-response-body.ts" + "test/typed-response-body.ts", + "test/augment-delegated.ts" ], "compilerOptions": { "module": "node16", diff --git a/types/koa/v2/index.d.ts b/types/koa/v2/index.d.ts index d3cb0d11917634..ccb9f9e7cd93c0 100644 --- a/types/koa/v2/index.d.ts +++ b/types/koa/v2/index.d.ts @@ -532,6 +532,9 @@ declare class Application< } declare namespace Application { + interface DefaultContextDelegatedRequest extends ContextDelegatedRequest {} + interface DefaultContextDelegatedResponse extends ContextDelegatedResponse {} + type DefaultStateExtends = any; /** * This interface can be augmented by users to add types to Koa's default state @@ -553,7 +556,7 @@ declare namespace Application { ParameterizedContext >; - interface BaseRequest extends ContextDelegatedRequest { + interface BaseRequest extends DefaultContextDelegatedRequest { /** * Get the charset when present or undefined. */ @@ -581,7 +584,7 @@ declare namespace Application { toJSON(): any; } - interface BaseResponse extends ContextDelegatedResponse { + interface BaseResponse extends DefaultContextDelegatedResponse { /** * Return the request socket. * @@ -643,7 +646,7 @@ declare namespace Application { toJSON(): any; } - interface BaseContext extends ContextDelegatedRequest, ContextDelegatedResponse { + interface BaseContext extends DefaultContextDelegatedRequest, DefaultContextDelegatedResponse { /** * util.inspect() implementation, which * just returns the JSON output. diff --git a/types/koa/v2/test/augment-delegated.ts b/types/koa/v2/test/augment-delegated.ts new file mode 100644 index 00000000000000..89c5fa72ad0f44 --- /dev/null +++ b/types/koa/v2/test/augment-delegated.ts @@ -0,0 +1,31 @@ +import Koa = require("koa"); + +declare module "koa" { + interface DefaultContextDelegatedRequest { + requestId: string; + } + + interface DefaultContextDelegatedResponse { + sendCustom(payload: unknown): void; + } +} + +const app = new Koa(); + +app.use((ctx, next) => { + // Augmented members are visible on ctx (delegated through BaseContext). + ctx.requestId; // $ExpectType string + ctx.sendCustom({ ok: true }); + + // Augmented members are visible on request/response as well. + ctx.request.requestId; // $ExpectType string + ctx.response.sendCustom("hello"); + + // Original delegated members still exist — augmentation must not erase them. + ctx.redirect("/login"); + ctx.attachment("file.txt"); + ctx.header; // $ExpectType IncomingHttpHeaders + ctx.method; // $ExpectType string + + return next(); +}); diff --git a/types/koa/v2/tsconfig.json b/types/koa/v2/tsconfig.json index aa8f83fee67449..0e3820f3a7947d 100644 --- a/types/koa/v2/tsconfig.json +++ b/types/koa/v2/tsconfig.json @@ -5,7 +5,8 @@ "test/constructor.ts", "test/default.ts", "test/settings.ts", - "test/typed-response-body.ts" + "test/typed-response-body.ts", + "test/augment-delegated.ts" ], "compilerOptions": { "module": "node16", diff --git a/types/node/node-tests/stream-iter.ts b/types/node/node-tests/stream-iter.ts index 34460498514e97..45cfb162b6614e 100644 --- a/types/node/node-tests/stream-iter.ts +++ b/types/node/node-tests/stream-iter.ts @@ -1,5 +1,6 @@ import { FileHandle, open } from "node:fs/promises"; import { bytes, from, fromSync, pipeTo, pull, pullSync, text, textSync } from "node:stream/iter"; +import { setTimeout } from "node:timers/promises"; import { compressGzip, compressGzipSync, decompressGzip, decompressGzipSync } from "node:zlib/iter"; // Async round-trip @@ -31,3 +32,10 @@ void async function() { using syncDispose = fh.writer(); await using asyncDispose = fh.writer(); }; + +void async function() { + pull("hello", async (chunk: Uint8Array[] | null) => { + await setTimeout(1000); + return chunk; + }); +}; diff --git a/types/node/stream/iter.d.ts b/types/node/stream/iter.d.ts index 0b77eb3d0b4f2e..121f78232e9c62 100644 --- a/types/node/stream/iter.d.ts +++ b/types/node/stream/iter.d.ts @@ -111,7 +111,10 @@ declare module "node:stream/iter" { signal: AbortSignal; } interface StatelessTransformFn { - (chunks: Uint8Array[] | null, options: TransformCallbackOptions): TransformResult | null; + ( + chunks: Uint8Array[] | null, + options: TransformCallbackOptions, + ): Promise | TransformResult | null; } interface SyncStatelessTransformFn { (chunks: Uint8Array[] | null): SyncTransformResult | null; diff --git a/types/oracledb/index.d.ts b/types/oracledb/index.d.ts index c2fa4cb95a70e9..7c31d1acc55ffa 100644 --- a/types/oracledb/index.d.ts +++ b/types/oracledb/index.d.ts @@ -658,7 +658,7 @@ declare namespace OracleDB { * * For non-CLOB types, the conversion to string is handled by Oracle client libraries and is often referred to as defining the fetch type. */ - let fetchAsString: Array; + let fetchAsString: Array; /** * Converter can be used with fetch type handlers to change the returned data. * If the value returned by the fetch type handler function is undefined then no conversion takes place. diff --git a/types/oracledb/oracledb-tests.ts b/types/oracledb/oracledb-tests.ts index a84d75544dd064..60dc9f3622c464 100644 --- a/types/oracledb/oracledb-tests.ts +++ b/types/oracledb/oracledb-tests.ts @@ -720,7 +720,7 @@ export const fetchAsBufferTests = (): void => { }; export const fetchAsStringTests = (): void => { - defaultOracledb.fetchAsString = [oracledb.DATE, oracledb.NUMBER, oracledb.BUFFER, oracledb.CLOB]; + defaultOracledb.fetchAsString = [oracledb.DATE, oracledb.NUMBER, oracledb.BUFFER, oracledb.CLOB, oracledb.NCLOB]; // @ts-expect-error defaultOracledb.fetchAsString = [{}]; // @ts-expect-error diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 750b493498ad1d..681f8928f9bf8d 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -3166,7 +3166,7 @@ declare namespace React { alt?: string | undefined; crossOrigin?: CrossOrigin; decoding?: "async" | "auto" | "sync" | undefined; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; height?: number | string | undefined; loading?: "eager" | "lazy" | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; @@ -3339,7 +3339,7 @@ declare namespace React { as?: string | undefined; blocking?: "render" | (string & {}) | undefined; crossOrigin?: CrossOrigin; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; href?: string | undefined; hrefLang?: string | undefined; integrity?: string | undefined; diff --git a/types/react/ts5.0/index.d.ts b/types/react/ts5.0/index.d.ts index 169dc36532488b..f3c6be2c82be1b 100644 --- a/types/react/ts5.0/index.d.ts +++ b/types/react/ts5.0/index.d.ts @@ -3165,7 +3165,7 @@ declare namespace React { alt?: string | undefined; crossOrigin?: CrossOrigin; decoding?: "async" | "auto" | "sync" | undefined; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; height?: number | string | undefined; loading?: "eager" | "lazy" | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; @@ -3338,7 +3338,7 @@ declare namespace React { as?: string | undefined; blocking?: "render" | (string & {}) | undefined; crossOrigin?: CrossOrigin; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; href?: string | undefined; hrefLang?: string | undefined; integrity?: string | undefined; diff --git a/types/react/v15/index.d.ts b/types/react/v15/index.d.ts index 4887eba90db52c..b969fde670b0ba 100644 --- a/types/react/v15/index.d.ts +++ b/types/react/v15/index.d.ts @@ -3032,7 +3032,7 @@ declare namespace React { interface LinkHTMLAttributes extends HTMLAttributes { as?: string | undefined; crossOrigin?: CrossOrigin; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; href?: string | undefined; hrefLang?: string | undefined; integrity?: string | undefined; diff --git a/types/react/v16/index.d.ts b/types/react/v16/index.d.ts index 4ef639a161887d..6cbc8c8e7988fe 100644 --- a/types/react/v16/index.d.ts +++ b/types/react/v16/index.d.ts @@ -2299,7 +2299,7 @@ declare namespace React { as?: string | undefined; blocking?: "render" | (string & {}) | undefined; crossOrigin?: CrossOrigin; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; href?: string | undefined; hrefLang?: string | undefined; integrity?: string | undefined; diff --git a/types/react/v17/index.d.ts b/types/react/v17/index.d.ts index 6fc8e255069f37..71ab3500d0b15a 100644 --- a/types/react/v17/index.d.ts +++ b/types/react/v17/index.d.ts @@ -2324,7 +2324,7 @@ declare namespace React { as?: string | undefined; blocking?: "render" | (string & {}) | undefined; crossOrigin?: CrossOrigin; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; href?: string | undefined; hrefLang?: string | undefined; integrity?: string | undefined; diff --git a/types/react/v18/index.d.ts b/types/react/v18/index.d.ts index 1673098eae63eb..e393c4ab8f13a7 100644 --- a/types/react/v18/index.d.ts +++ b/types/react/v18/index.d.ts @@ -3271,7 +3271,7 @@ declare namespace React { alt?: string | undefined; crossOrigin?: CrossOrigin; decoding?: "async" | "auto" | "sync" | undefined; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; height?: number | string | undefined; loading?: "eager" | "lazy" | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; @@ -3436,7 +3436,7 @@ declare namespace React { as?: string | undefined; blocking?: "render" | (string & {}) | undefined; crossOrigin?: CrossOrigin; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; href?: string | undefined; hrefLang?: string | undefined; integrity?: string | undefined; diff --git a/types/react/v18/ts5.0/index.d.ts b/types/react/v18/ts5.0/index.d.ts index b5446b5f670f66..ac1396c7b97bcd 100644 --- a/types/react/v18/ts5.0/index.d.ts +++ b/types/react/v18/ts5.0/index.d.ts @@ -3272,7 +3272,7 @@ declare namespace React { alt?: string | undefined; crossOrigin?: CrossOrigin; decoding?: "async" | "auto" | "sync" | undefined; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; height?: number | string | undefined; loading?: "eager" | "lazy" | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; @@ -3437,7 +3437,7 @@ declare namespace React { as?: string | undefined; blocking?: "render" | (string & {}) | undefined; crossOrigin?: CrossOrigin; - fetchPriority?: "high" | "low" | "auto"; + fetchPriority?: "high" | "low" | "auto" | undefined; href?: string | undefined; hrefLang?: string | undefined; integrity?: string | undefined; diff --git a/types/rtpengine-client/.npmignore b/types/rtpengine-client/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/rtpengine-client/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/rtpengine-client/index.d.ts b/types/rtpengine-client/index.d.ts new file mode 100644 index 00000000000000..15834bf5a8c42e --- /dev/null +++ b/types/rtpengine-client/index.d.ts @@ -0,0 +1,168 @@ +/// + +import { EventEmitter } from "events"; + +export interface RtpEngineResponse { + result: string; + sdp?: string; + "error-reason"?: string; + [key: string]: any; +} + +export interface ClientOptions { + localPort?: number; + localAddress?: string; + timeout?: number; + rejectOnError?: boolean; +} + +export interface WsClientOptions { + url: string; + timeout?: number; +} + +export interface TcpClientOptions { + hostport: string; + timeout?: number; +} + +export interface UdpDestination { + port: number; + host: string; +} + +export interface UdpCommand { + (port: number, host: string, opts?: object): Promise; + (port: number, host: string, opts: object, callback: (err: any, data: RtpEngineResponse) => void): Client; + (dest: UdpDestination, opts?: object): Promise; + (dest: UdpDestination, opts: object, callback: (err: any, data: RtpEngineResponse) => void): Client; +} + +export interface WsCommand { + (opts?: object): Promise; + (opts: object, callback: (err: any, data: RtpEngineResponse) => void): WsClient; +} + +export interface TcpCommand { + (opts?: object): Promise; + (opts: object, callback: (err: any, data: RtpEngineResponse) => void): TcpClient; +} + +export class RtpEngineError extends Error { + constructor(message?: string); +} + +export class BaseClient extends EventEmitter { + connected: boolean; + timeout: number; + readonly type: string; + close(): void; + on(event: "listening", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "end", listener: () => void): this; + on(event: string, listener: (...args: any[]) => void): this; +} + +export class Client extends BaseClient { + constructor(callback?: () => void); + constructor(port: number, callback?: () => void); + constructor(port: number, host: string, callback?: () => void); + constructor(opts: ClientOptions, callback?: () => void); + + answer: UdpCommand; + delete: UdpCommand; + list: UdpCommand; + offer: UdpCommand; + ping: UdpCommand; + query: UdpCommand; + startRecording: UdpCommand; + stopRecording: UdpCommand; + blockDTMF: UdpCommand; + unblockDTMF: UdpCommand; + playDTMF: UdpCommand; + blockMedia: UdpCommand; + unblockMedia: UdpCommand; + silenceMedia: UdpCommand; + unsilenceMedia: UdpCommand; + startForwarding: UdpCommand; + stopForwarding: UdpCommand; + playMedia: UdpCommand; + stopMedia: UdpCommand; + statistics: UdpCommand; + publish: UdpCommand; + subscribeRequest: UdpCommand; + subscribeAnswer: UdpCommand; + unsubscribe: UdpCommand; +} + +export class WsClient extends BaseClient { + constructor(url: string); + constructor(opts: WsClientOptions); + + on(event: "close", listener: () => void): this; + on(event: "reconnected", listener: () => void): this; + on(event: "listening", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: string, listener: (...args: any[]) => void): this; + + answer: WsCommand; + delete: WsCommand; + list: WsCommand; + offer: WsCommand; + ping: WsCommand; + query: WsCommand; + startRecording: WsCommand; + stopRecording: WsCommand; + blockDTMF: WsCommand; + unblockDTMF: WsCommand; + playDTMF: WsCommand; + blockMedia: WsCommand; + unblockMedia: WsCommand; + silenceMedia: WsCommand; + unsilenceMedia: WsCommand; + startForwarding: WsCommand; + stopForwarding: WsCommand; + playMedia: WsCommand; + stopMedia: WsCommand; + statistics: WsCommand; + publish: WsCommand; + subscribeRequest: WsCommand; + subscribeAnswer: WsCommand; + unsubscribe: WsCommand; +} + +export class TcpClient extends BaseClient { + constructor(hostport: string); + constructor(opts: TcpClientOptions); + + on(event: "connect", listener: () => void): this; + on(event: "listening", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "end", listener: () => void): this; + on(event: string, listener: (...args: any[]) => void): this; + + answer: TcpCommand; + delete: TcpCommand; + list: TcpCommand; + offer: TcpCommand; + ping: TcpCommand; + query: TcpCommand; + startRecording: TcpCommand; + stopRecording: TcpCommand; + blockDTMF: TcpCommand; + unblockDTMF: TcpCommand; + playDTMF: TcpCommand; + blockMedia: TcpCommand; + unblockMedia: TcpCommand; + silenceMedia: TcpCommand; + unsilenceMedia: TcpCommand; + startForwarding: TcpCommand; + stopForwarding: TcpCommand; + playMedia: TcpCommand; + stopMedia: TcpCommand; + statistics: TcpCommand; + publish: TcpCommand; + subscribeRequest: TcpCommand; + subscribeAnswer: TcpCommand; + unsubscribe: TcpCommand; +} diff --git a/types/rtpengine-client/package.json b/types/rtpengine-client/package.json new file mode 100644 index 00000000000000..24bf9f8f513286 --- /dev/null +++ b/types/rtpengine-client/package.json @@ -0,0 +1,20 @@ +{ + "private": true, + "name": "@types/rtpengine-client", + "version": "0.4.9999", + "projects": [ + "https://github.com/drachtio/rtpengine-client" + ], + "dependencies": { + "@types/node": "*" + }, + "devDependencies": { + "@types/rtpengine-client": "workspace:." + }, + "owners": [ + { + "name": "Dan Virsén", + "githubUsername": "danvirsen" + } + ] +} diff --git a/types/rtpengine-client/rtpengine-client-tests.ts b/types/rtpengine-client/rtpengine-client-tests.ts new file mode 100644 index 00000000000000..8261f131b3014f --- /dev/null +++ b/types/rtpengine-client/rtpengine-client-tests.ts @@ -0,0 +1,105 @@ +import { Client, RtpEngineError, RtpEngineResponse, TcpClient, WsClient } from "rtpengine-client"; + +// --- Client (UDP) --- + +// Constructor forms +const c1 = new Client(); +const c2 = new Client(12345); +const c3 = new Client(12345, "127.0.0.1"); +const c4 = new Client({ localPort: 12345, localAddress: "0.0.0.0", timeout: 1000, rejectOnError: true }); +const c5 = new Client(() => {/* listening */}); + +// Events +c1.on("listening", () => {}); +c1.on("error", (err: Error) => {}); +c1.on("end", () => {}); + +// Command: port+host form — Promise +c1.offer(22222, "10.0.0.1", { "call-id": "abc", sdp: "v=0..." }).then((res: RtpEngineResponse) => { + const result: string = res.result; + const sdp: string | undefined = res.sdp; +}); + +// Command: {port, host} form — Promise +c1.answer({ port: 22222, host: "10.0.0.1" }, { "call-id": "abc", sdp: "v=0..." }).then((res) => {}); + +// Command: callback form — returns Client +c1.offer(22222, "10.0.0.1", { "call-id": "abc" }, (err, data) => { + if (err) return; + const result: string = data.result; +}).on("error", () => {}); + +// Other commands +c1.ping(22222, "10.0.0.1"); +c1.delete(22222, "10.0.0.1", { "call-id": "abc" }); +c1.query(22222, "10.0.0.1", { "call-id": "abc" }); +c1.startRecording(22222, "10.0.0.1", { "call-id": "abc" }); +c1.stopRecording(22222, "10.0.0.1", { "call-id": "abc" }); +c1.blockDTMF(22222, "10.0.0.1", { "call-id": "abc" }); +c1.unblockDTMF(22222, "10.0.0.1", { "call-id": "abc" }); +c1.playDTMF(22222, "10.0.0.1", { "call-id": "abc", code: "1" }); +c1.blockMedia(22222, "10.0.0.1", { "call-id": "abc" }); +c1.unblockMedia(22222, "10.0.0.1", { "call-id": "abc" }); +c1.silenceMedia(22222, "10.0.0.1", { "call-id": "abc" }); +c1.unsilenceMedia(22222, "10.0.0.1", { "call-id": "abc" }); +c1.startForwarding(22222, "10.0.0.1", { "call-id": "abc" }); +c1.stopForwarding(22222, "10.0.0.1", { "call-id": "abc" }); +c1.playMedia(22222, "10.0.0.1", { "call-id": "abc" }); +c1.stopMedia(22222, "10.0.0.1", { "call-id": "abc" }); +c1.statistics(22222, "10.0.0.1"); +c1.publish(22222, "10.0.0.1", { "call-id": "abc" }); +c1.subscribeRequest(22222, "10.0.0.1", { "call-id": "abc" }); +c1.subscribeAnswer(22222, "10.0.0.1", { "call-id": "abc" }); +c1.unsubscribe(22222, "10.0.0.1", { "call-id": "abc" }); +c1.list(22222, "10.0.0.1"); + +c1.close(); + +// --- WsClient --- + +const ws1 = new WsClient("ws://10.0.0.1:9900"); +const ws2 = new WsClient({ url: "ws://10.0.0.1:9900", timeout: 2000 }); + +ws1.on("listening", () => {}); +ws1.on("close", () => {}); +ws1.on("reconnected", () => {}); +ws1.on("error", (err: Error) => {}); + +// Command: Promise form +ws1.offer({ "call-id": "abc", sdp: "v=0..." }).then((res: RtpEngineResponse) => { + const result: string = res.result; +}); + +// Command: no opts +ws1.ping().then((res) => {}); +ws1.statistics(); + +// Command: callback form — returns WsClient +ws1.offer({ "call-id": "abc" }, (err, data) => { + if (err) return; +}).on("error", () => {}); + +ws1.close(); + +// --- TcpClient --- + +const tcp1 = new TcpClient("10.0.0.1:9900"); +const tcp2 = new TcpClient({ hostport: "10.0.0.1:9900", timeout: 2000 }); + +tcp1.on("connect", () => {}); +tcp1.on("listening", () => {}); +tcp1.on("error", (err: Error) => {}); +tcp1.on("end", () => {}); + +// Command: Promise form +tcp1.offer({ "call-id": "abc", sdp: "v=0..." }).then((res: RtpEngineResponse) => {}); + +// Command: callback form — returns TcpClient +tcp1.answer({ "call-id": "abc" }, (err, data) => {}).on("error", () => {}); + +tcp1.close(); + +// --- RtpEngineError --- + +const err = new RtpEngineError("timeout"); +const msg: string = err.message; diff --git a/types/rtpengine-client/tsconfig.json b/types/rtpengine-client/tsconfig.json new file mode 100644 index 00000000000000..828620e00c6077 --- /dev/null +++ b/types/rtpengine-client/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "rtpengine-client": ["./index.d.ts"] + } + }, + "files": [ + "index.d.ts", + "rtpengine-client-tests.ts" + ] +}