Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type defs #5

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9e27a45
initial type definitions added
augustblack Apr 10, 2022
a182783
set Connection as return type
augustblack Apr 10, 2022
1ec9c38
use "moduleResolution": "nodenext"
augustblack Apr 11, 2022
d0d59eb
fix typos
augustblack Apr 13, 2022
7e2c227
fix EventEmitter and ./plugins import
augustblack Apr 13, 2022
9ffb6d2
Merge branch 'master' into type_defs
augustblack Apr 21, 2022
a4b1949
Merge branch 'master' into type_defs
augustblack Apr 21, 2022
94b1120
add TRICKLE
augustblack Apr 21, 2022
0fc15a6
update JOINED response type
augustblack Apr 21, 2022
d48266f
add types/**/* to files
augustblack Apr 21, 2022
6d001f9
Add partial support for multistream "updated" videoroom event
atoppi May 23, 2022
6da160a
Fixes by npm audit
atoppi May 23, 2022
eebcf74
Bump version to v1.6.2
atoppi May 24, 2022
3696a67
Add support for "enable_recording" API in the audiobridge plugin
atoppi Jun 6, 2022
0295d07
add enableRecording types
augustblack Jun 8, 2022
0c3f23f
Merge branch 'master' into type_defs
augustblack Jun 13, 2022
6e7d04f
add rec_dir and startForward ptype, ssrc, codec
augustblack Jun 13, 2022
d059b30
Merge branch 'master' into type_defs
augustblack Aug 9, 2023
023f9b4
add host_family to startForward
augustblack Sep 3, 2023
46f2f30
format and add host_family
augustblack Sep 3, 2023
ab5c8cc
Merge branch 'master' into type_defs
augustblack Sep 4, 2023
da4ebe6
Merge branch 'master' into type_defs
augustblack Jan 15, 2024
f6d4e8a
update for suspend/resume requests
augustblack Jan 15, 2024
81d6a14
Merge branch 'master' into type_defs
augustblack Jan 16, 2024
a7c0716
add mute / unmute to audiobridge
augustblack Jan 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"description": "Meetecho adapter for the Janus WebRTC Server",
"version": "1.6.9",
"type": "module",
"main": "src/janode.js",
"types": "./types/janode.d",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a typo?

"keywords": [
"janus",
"webrtc",
Expand All @@ -24,16 +26,48 @@
"license": "ISC",
"main": "./src/janode.js",
"exports": {
".": "./src/janode.js",
"./plugins/audiobridge": "./src/plugins/audiobridge-plugin.js",
"./plugins/echotest": "./src/plugins/echotest-plugin.js",
"./plugins/streaming": "./src/plugins/streaming-plugin.js",
"./plugins/videoroom": "./src/plugins/videoroom-plugin.js"
".": {
"import": {
"types": "./types/janode.d.ts",
"default": "./src/janode.js"
}
},
"./plugins/echotest": {
"import": {
"types": "./types/plugins/echotest-plugin.d.ts",
"default": "./src/plugins/echotest-plugin.js"
}
},
"./plugins/streaming": {
"import": {
"types": "./types/plugins/streaming-plugin.d.ts",
"default": "./src/plugins/streaming-plugin.js"
}
},
"./plugins/videoroom": {
"import": {
"types": "./types/plugins/videoroom-plugin.d.ts",
"default": "./src/plugins/videoroom-plugin.js"
}
},
"./plugins/audiobridge": {
"import": {
"types": "./types/plugins/audiobridge-plugin.d.ts",
"default": "./src/plugins/audiobridge-plugin.js"
}
},
"./session": {
"import": "./types/session.d.ts"
},
"./connection": {
"import": "./types/connection.d.ts"
}
},
"files": [
"src/*.js",
"src/utils/*.js",
"src/plugins/*.js"
"src/plugins/*.js",
"types/**/*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer specifying subfolders and file extension here (likewise the js)

],
"dependencies": {
"isomorphic-ws": "^4.0.1",
Expand Down
47 changes: 47 additions & 0 deletions types/configuration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ServerObjectConf } from './janode.js'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we importing js files from d.ts ?

export default Configuration;
/**
* Class representing a Janode configuration.
* The purpose of the class is basically filtering the input config and distinguish Janus API and Admin API connections.
*/
type AddressConfig = {
url: string
apisecret?: string
}
declare class Configuration {
/**
* Create a configuration.
*
* @private
* @param {module:janode~RawConfiguration} config
*/
private constructor();
address: AddressConfig[];
retry_time_secs: number;
max_retries: number;
is_admin: boolean;
/**
* Get the server list of this configuration.
*
* @returns {module:janode~ServerObjectConf[]} The address array
*/
getAddress(): ServerObjectConf;
/**
* Get the number of seconds between any attempt.
*
* @returns {number} The value of the property
*/
getRetryTimeSeconds(): number;
/**
* Get the max number of retries.
*
* @returns {number} The value of the property
*/
getMaxRetries(): number;
/**
* Check if the configuration is for an admin connection.
*
* @returns {boolean} True if the configuration will be used for an admin connection
*/
isAdmin(): boolean;
}
212 changes: 212 additions & 0 deletions types/connection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
import Session from './session.js'
import { EventEmitter } from 'events'
export default Connection;
/**
* Class representing a Janode connection.<br>
*
* Specific transports are picked by checking the connection URI.<br>
*
* This class implements both the Janus API and Admin API.<br>
*
* Connection extends EventEmitter, so an instance can emit events and users can subscribe to them.<br>
*
* Users are not expected to create Connection instances, but insted use the Janode.connect() API.<br>
*
* @hideconstructor
*/
declare class Connection extends EventEmitter {
/**
* Create a Janode Connection.
*
* @param {module:configuration~Configuration} server_config - The Janode configuration as created by the Configuration constructor.
*/
constructor(server_config: any);
/**
* The configuration in use for this connection.
*
* @private
* @type {module:configuration~Configuration}
*/
private _config;
/**
* The transaction manager used by this connection.
*
* @private
* @type {module:tmanager~TransactionManager}
*/
private _tm;
/**
* Keep track of the sessions.
*
* @private
* @type {Map}
*/
private _sessions;
/**
* The iterator to select available Janus addresses.
*
* @private
* @type {module:utils~CircularIterator}
*/
private _address_iterator;
/**
* A numerical identifier assigned for logging purposes.
*
* @type {number}
*/
id: number;
/**
* A more descriptive, not unique string (used for logging).
*
* @type {string}
*/
name: string;
/**
* The internal transport that will be used for the connection.
*
* @typedef {object} Transport
* @property {function} open
* @property {function} close
* @property {function} send
* @property {function} getRemoteHostname
*/
_transport: WsTransport | UnixTransport | {
open: (_: any) => Promise<never>;
close: (_: any) => Promise<never>;
send: (_: any) => Promise<never>;
getRemoteHostname: (_: any) => never;
};
/**
* Cleanup the connection closing all owned transactions and emitting the destroyed event
* and removing all registered listeners.
*
* @private
* @param {boolean} graceful - True if this is an expected disconnection
*/
private _signalClose;
/**
* Open a connection using the transport defined open method.
* Users do not need to call this method, since the connection is opened by Janode.connect().
*
* @returns {Promise<module:connection~Connection>} A promise resolving with the Janode connection
*/
open(): Promise<Connection>;
/**
* Manage a message sent to this session. If a session is involved let it manage the message.
* If the message involves a owned transaction and the response is a definitive one,
* the transaction will be closed.
*
* @private
* @param {object} janus_message
*/
private _handleMessage;
/**
* Decorate request with apisecret, token and transaction (if missing).
*
* @private
* @param {object} request
*/
private _decorateRequest;
/**
* Gracefully close the connection using the transport defined close method.
*
* @returns {Promise<void>}
*/
close(): Promise<void>;
/**
* Send a request from this connection using the transport defined send method.
*
* @param {object} request - The request to be sent
* @returns {Promise<object>} A promise resolving with a response from Janus
*/
sendRequest(request: object): Promise<object>;
/**
* Get the remote Janus hostname using the transport defined method.
*
* @returns {string} The hostname of the Janus server
*/
getRemoteHostname(): string;
/**
* Create a new session in this connection.
*
* @param {number} [ka_interval] - The time interval (seconds) for session keep-alive requests
* @returns {Promise<module:session~Session>} The newly created session
*
* @example
*
* const session = await connection.create();
* Logger.info(`***** SESSION CREATED *****`);
*/
create(ka_interval?: number): Promise<Session>;
/**
* Janus GET INFO API.
*
* @returns {Promise<object>} The Get Info response
*
* @example
*
* const info = await connection.getInfo();
* Logger.info(`${info.name} ${info.version_string}`);
*/
getInfo(): Promise<object>;
/*************/
/*************/
/**
* (Admin API) List the sessions in a janus instance.
*
* @returns {Promise<object>}
*
* @example
*
* const data = await connection.listSessions();
* Logger.info(`${JSON.stringify(data)}`);
*/
listSessions(): Promise<object>;
/**
* (Admin API) List the handles in a session.
*
* @param {number} session_id - The identifier of the session
* @returns {Promise<object>}
*
* @example
*
* const data = await connection.listSessions();
* Logger.info(`${JSON.stringify(data)}`);
*/
listHandles(session_id: number): Promise<object>;
/**
* (Admin API) Get an handle info.
*
* @param {number} session_id - The session identifier
* @param {number} handle_id - The handle identifier
* @returns {Promise<object>} The Get Handle Info response
*
* @example
*
* const data = await connection.handleInfo(session.id, handle.id);
* Logger.info(`${JSON.stringify(data)}`);
*/
handleInfo(session_id: number, handle_id: number): Promise<object>;
/**
* (Admin API) Start a packet capture on an handle.
*
* @param {number} session_id - The session identifier
* @param {number} handle_id - The handle identifier
* @param {string} folder - The folder in which save the pcap
* @param {string} filename - The pcap file name
* @param {number} [truncate] - Number of bytes to truncate the pcap to
* @returns {Promise<object>} The start pcap response
*/
startPcap(session_id: number, handle_id: number, folder: string, filename: string, truncate?: number): Promise<object>;
/**
* Stop an ogoing packet capture.
*
* @param {number} session_id - The session identifier
* @param {number} handle_id - The handle identifier
* @returns {Promise<object>} The stop pcap response
*/
stopPcap(session_id: number, handle_id: number): Promise<any>;
}
import WsTransport from "./transport-ws.js";
import UnixTransport from "./transport-unix.js";

Loading