You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
Add more jsdoc.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
var httpApi = require("./http-api");
|
||||
var MatrixEvent = require("./models/event").MatrixEvent;
|
||||
var MatrixInMemoryStore = require("./store/memory").MatrixInMemoryStore;
|
||||
var utils = require("./utils");
|
||||
|
||||
// TODO:
|
||||
@@ -20,7 +21,8 @@ var utils = require("./utils");
|
||||
* @param {boolean} opts.usePromises True to use promises rather than callbacks.
|
||||
* @param {string} opts.accessToken The access_token for this user.
|
||||
* @param {string} opts.userId The user ID for this user.
|
||||
* @param {Object} opts.store The data store to use. See {@link store/memory}.
|
||||
* @param {Object} opts.store Optional. The data store to use. Defaults to
|
||||
* {@link module:store/memory.MatrixInMemoryStore}.
|
||||
*/
|
||||
module.exports.MatrixClient = function MatrixClient(opts) {
|
||||
utils.checkObjectHasKeys(opts, ["baseUrl", "request"]);
|
||||
@@ -28,7 +30,7 @@ module.exports.MatrixClient = function MatrixClient(opts) {
|
||||
["baseUrl", "request", "usePromises", "accessToken", "userId", "store"]
|
||||
);
|
||||
|
||||
this.store = opts.store || null;
|
||||
this.store = opts.store || new MatrixInMemoryStore();
|
||||
// track our position in the overall eventstream
|
||||
this.fromToken = undefined;
|
||||
this.clientRunning = false;
|
||||
@@ -49,6 +51,13 @@ module.exports.MatrixClient.prototype = {
|
||||
// Room operations
|
||||
// ===============
|
||||
|
||||
/**
|
||||
* Create a new room.
|
||||
* @param {Object} options a list of options, which can include 'visibility',
|
||||
* 'room_alias_name' and 'invite'.
|
||||
* @param {Function} callback Optional. The callback to invoke.
|
||||
* @return {(Promise|undefined)} A Promise if a callback is not specified.
|
||||
*/
|
||||
createRoom: function(options, callback) {
|
||||
// valid options include: room_alias_name, visibility, invite
|
||||
return this._http.authedRequest(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
/** The Matrix Event class. */
|
||||
/** The {@link module:models/event.MatrixEvent|MatrixEvent} class. */
|
||||
module.exports.MatrixEvent = require("./models/event").MatrixEvent;
|
||||
/** An in-memory store for the SDK */
|
||||
/** The {@link module:store/memory.MatrixInMemoryStore|MatrixInMemoryStore} class. */
|
||||
module.exports.MatrixInMemoryStore = require("./store/memory");
|
||||
/** The {@link module:http-api.MatrixHttpApi|MatrixHttpApi} class. */
|
||||
module.exports.MatrixHttpApi = require("./http-api").MatrixHttpApi;
|
||||
@@ -29,6 +29,8 @@ module.exports.request = function(r) {
|
||||
* @param {boolean} opts.usePromises True to use promises rather than callbacks.
|
||||
* @param {string} opts.accessToken The access_token for this user.
|
||||
* @param {string} opts.userId The user ID for this user.
|
||||
* @param {Object} opts.store Optional. The data store to use. Defaults to
|
||||
* {@link module:store/memory.MatrixInMemoryStore}.
|
||||
* @return {MatrixClient} A new matrix client.
|
||||
*/
|
||||
module.exports.createClient = function(opts) {
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
"use strict";
|
||||
/**
|
||||
* This is an internal module. See {@link MatrixEvent} and {@link RoomEvent} for
|
||||
* the public classes.
|
||||
* @module models/event
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* Construct a Matrix Event object
|
||||
* @constructor
|
||||
* @param {Object} event The raw event to be wrapped in this DAO
|
||||
*/
|
||||
function MatrixEvent(event) {
|
||||
module.exports.MatrixEvent = function MatrixEvent(event) {
|
||||
this.event = event || {};
|
||||
}
|
||||
MatrixEvent.prototype = {
|
||||
};
|
||||
module.exports.MatrixEvent.prototype = {
|
||||
getId: function() {
|
||||
return this.event.event_id;
|
||||
},
|
||||
@@ -30,8 +36,3 @@ MatrixEvent.prototype = {
|
||||
return this.event.state_key !== undefined;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* An event from Matrix.
|
||||
*/
|
||||
module.exports.MatrixEvent = MatrixEvent;
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
"use strict";
|
||||
/**
|
||||
* This is an internal module. See {@link MatrixInMemoryStore} for the public class.
|
||||
* @module store/memory
|
||||
*/
|
||||
|
||||
function MatrixInMemoryStore() {
|
||||
/**
|
||||
* Construct a new in-memory data store for the Matrix Client.
|
||||
* @constructor
|
||||
*/
|
||||
module.exports.MatrixInMemoryStore = function MatrixInMemoryStore() {
|
||||
this.rooms = {
|
||||
// state: { },
|
||||
// timeline: [ ],
|
||||
@@ -9,11 +17,11 @@ function MatrixInMemoryStore() {
|
||||
this.presence = {
|
||||
// presence objects keyed by userId
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// XXX: this is currently quite procedural - we could possibly pass back
|
||||
// models of Rooms, Users, Events, etc instead.
|
||||
MatrixInMemoryStore.prototype = {
|
||||
module.exports.MatrixInMemoryStore.prototype = {
|
||||
|
||||
/*
|
||||
* Add an array of one or more state MatrixEvents into the store, overwriting
|
||||
@@ -156,8 +164,3 @@ MatrixInMemoryStore.prototype = {
|
||||
// TODO
|
||||
//reapOldMessages: function() {},
|
||||
};
|
||||
|
||||
/**
|
||||
* An in-memory store for Matrix.
|
||||
*/
|
||||
module.exports = MatrixInMemoryStore;
|
||||
|
||||
Reference in New Issue
Block a user