diff --git a/node-xmpp-core/index.d.ts b/node-xmpp-core/index.d.ts new file mode 100644 index 0000000000..dd2b89ca22 --- /dev/null +++ b/node-xmpp-core/index.d.ts @@ -0,0 +1,97 @@ +// Type definitions for node-xmpp-core 5.0 +// Project: github.com/node-xmpp/node-xmpp/ +// Definitions by: PJakcson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 +/// +import {Element} from 'ltx'; +import {EventEmitter} from 'events'; + +// fixme: not ideal +export {createElement, Element, escapeXML, escapeXMLText} from 'ltx'; + +export declare class Connection extends EventEmitter { + constructor(opts?: any); +} + +export declare namespace SRV { + /** + * returns a lazy iterator which can be restarted via connection.connect() + */ + function connect(opts?: any): any; +} + +export declare class Stanza extends Element { + from: string; + to: string; + id: string; + type: string; + + constructor(name: string, attrs?: any); +} + +/** + * JSX compatible API, use this function as pragma + * https://facebook.github.io/jsx/ + * Returns a Stanza if name is presence, message or iq an ltx Element otherwise. + * + * @param {string} name name of the element + * @param {any} attrs attribute key/value pairs + * @return {Element} Stanza or Element + */ +export declare function createStanza(name: string, attrs?: any): Element; + +export declare class IQ extends Stanza { + constructor(attrs?: any); +} + +export declare class Message extends Stanza { + constructor(attrs?: any); +} + +export declare class Presence extends Stanza { + constructor(attrs?: any); +} + +export declare class JID { + local: string; + domain: string; + resource: string; + + constructor(local: string, domain?: string, resource?: string); + + parseJID(jid: string): void; + + toString(unescape?: any): string; + + /** + * Convenience method to distinguish users + **/ + bare(): JID; + + /** + * Comparison function + **/ + equals(other: JID): boolean; + + /** + * http://xmpp.org/rfcs/rfc6122.html#addressing-localpart + **/ + setLocal(local: string, escape?: any): void; + + getLocal(unescape?: any): string; + + /** + * http://xmpp.org/rfcs/rfc6122.html#addressing-domain + */ + setDomain(value: string): void; + + getDomain(): string; + + /** + * http://xmpp.org/rfcs/rfc6122.html#addressing-resourcepart + */ + setResource(value: string): void; + + getResource(): string; +} diff --git a/node-xmpp-core/node-xmpp-core-tests.ts b/node-xmpp-core/node-xmpp-core-tests.ts new file mode 100644 index 0000000000..ebb27f3b17 --- /dev/null +++ b/node-xmpp-core/node-xmpp-core-tests.ts @@ -0,0 +1,6 @@ +import {Connection} from './index'; + +const con = new Connection(); +con.on('online', () => { + con.eventNames(); +}); diff --git a/node-xmpp-core/tsconfig.json b/node-xmpp-core/tsconfig.json new file mode 100644 index 0000000000..61048d84cb --- /dev/null +++ b/node-xmpp-core/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-xmpp-core-tests.ts" + ] +} diff --git a/node-xmpp-core/tslint.json b/node-xmpp-core/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/node-xmpp-core/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +}