mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-10 11:40:16 +08:00
Updated Meteor definitions for Meteor version 1.2.0.2
This commit is contained in:
+41
-23
@@ -1,6 +1,6 @@
|
||||
# Meteor Type Definitions
|
||||
|
||||
These are the definitions for version 1.1.0.1 of Meteor.
|
||||
These are the definitions for version 1.2.0.2 of Meteor.
|
||||
|
||||
Although these definitions can be downloaded separately for use, the recommended way to use these definitions in a Meteor application is by installing the
|
||||
[typescript-libs](https://atmospherejs.com/meteortypescript/typescript-libs) Meteor smart package from atmosphere. The smart package contains TypeScript
|
||||
@@ -14,14 +14,14 @@ These definitions were generated from the from the same [Meteor data.js file] (h
|
||||
to generate the official [Meteor docs] (http://docs.meteor.com/).
|
||||
|
||||
|
||||
## Usage
|
||||
## Usage (OSX/Linux)
|
||||
|
||||
1. Add a symbolic link to the definitions from within some directory within your project (e.g. ".typescript" or "lib"). The definitions can be found somewhere
|
||||
deep within `<project_root_dir>/.meteor/...`. The following will probably work:
|
||||
1. Add a symbolic link to the definitions from within some directory within your project (e.g. ".typescript" or "lib"). The definitions can be found somewhere deep within `<project_root_dir>/.meteor/...`. The following will probably work:
|
||||
|
||||
$ ln -s ../.meteor/local/build/programs/server/assets/packages/meteortypescript_typescript-libs/definitions package_defs
|
||||
|
||||
If the definitions can't be found within the .meteor directory, you will have to manually pull down the definitions from github and add them to your project:
|
||||
If the definitions can't be found within the .meteor directory, you will have to manually pull down the definitions from github and add them to your project:
|
||||
|
||||
<https://github.com/meteor-typescript/meteor-typescript-libs>
|
||||
|
||||
2. Install the [Typescript compiler for Meteor](https://github.com/meteor-typescript/meteor-typescript-compiler) or an [IDE which can transpile TypeScript to JavaScript](#transpiling-typescript).
|
||||
@@ -29,12 +29,23 @@ deep within `<project_root_dir>/.meteor/...`. The following will probably work:
|
||||
|
||||
/// <reference path=".typescript/package_defs/all-definitions.d.ts" /> (substitute path in your project)
|
||||
|
||||
Or you can reference definition files individually:
|
||||
Or you can reference definition files individually:
|
||||
|
||||
/// <reference path=".typescript/package_defs/meteor.d.ts" /> (substitue path in your project)
|
||||
/// <reference path=".typescript/package_defs/meteor.d.ts" /> (substitute path in your project)
|
||||
/// <reference path=".typescript/package_defs/underscore.d.ts" />
|
||||
/// <reference path=".typescript/package_defs/jquery.d.ts" />
|
||||
|
||||
Meteor core definitions can be referenced in an "all-in-one" definition file ( *meteor.d.ts* ) or definition files specific to the locus of execution:
|
||||
|
||||
- *meteor.d.ts*: all meteor core definitions
|
||||
- *meteor.common.d.ts*: meteor core code running on both client and server
|
||||
- *meteor.client.d.ts*: meteor core client-only code
|
||||
- *meteor.server.d.ts*: meteor core server-only code
|
||||
- *meteor.package.d.ts*: meteor core package-only code
|
||||
- *meteor.build.d.ts*: meteor core build-only code
|
||||
|
||||
*meteor.d.ts* contains all of the definitions found in *meteor.common.d.ts*, *meteor.client.d.ts*, *meteor.server.d.ts*, *meteor.package.d.ts*, and *meteor.build.d.ts*
|
||||
|
||||
4. Be aware of differences in coding styles when using TypeScript (see below)
|
||||
|
||||
|
||||
@@ -42,14 +53,15 @@ deep within `<project_root_dir>/.meteor/...`. The following will probably work:
|
||||
|
||||
### References
|
||||
|
||||
Meteor code can run on the client and the server, for this reason you should try to stay away from referencing *file.ts* directly: you may get unexpected results.
|
||||
Rather generate a *file.d.ts* using `tsc --reference file.ts`, and reference it in your file.
|
||||
Meteor code can run on the client and the server, for this reason you should try to stay away from referencing *file.ts* directly: you may get unexpected results.
|
||||
|
||||
Rather generate a *file.d.ts* using `tsc --declaration file.ts`, and reference it in your file.
|
||||
|
||||
Compilation will be much faster and code cleaner - it's always better to split definition from implementation anyways.
|
||||
Compilation will be much faster and code will be cleaner - it's always better to split definition from implementation anyways.
|
||||
|
||||
### Templates
|
||||
|
||||
With the exception of the **body** and **head** templates, Meteor's Template dot notation cannot be used (ie. *Template.mytemplate*). Thanks to Typescript static typing checks, you will need to used the *bracket notation* to access the Template.
|
||||
With the exception of the **body** and **head** templates, Meteor's Template dot notation cannot be used (ie. *Template.mytemplate*). Thanks to Typescript static typing checks, you will need to use the *bracket notation* to access the Template.
|
||||
|
||||
|
||||
Template['myTemplateName'].helpers({
|
||||
@@ -58,16 +70,16 @@ With the exception of the **body** and **head** templates, Meteor's Template dot
|
||||
}
|
||||
});
|
||||
|
||||
Template['myTemplateName'].rendered = function ( ) { ... }
|
||||
Template['myTemplateName'].onRendered(function ( ) { ... });
|
||||
|
||||
|
||||
### Form fields
|
||||
|
||||
Form fields typically need to be casted to <HTMLInputElement>. For instance to read a form field value, use `(<HTMLInputElement>evt.target).value`.
|
||||
Form fields typically need to be cast to `<HTMLInputElement>`. For instance to read a form field value, use `(<HTMLInputElement>evt.target).value`.
|
||||
|
||||
### Global variables
|
||||
|
||||
Preface any global variable declarations with a TypeScript "declare var" statement:
|
||||
Preface any global variable declarations with a TypeScript "declare var" statement (or place the statement in a definition file):
|
||||
|
||||
declare var NavbarHelpers;
|
||||
NavbarHelpers = {};
|
||||
@@ -75,8 +87,7 @@ Preface any global variable declarations with a TypeScript "declare var" stateme
|
||||
|
||||
### Collections
|
||||
|
||||
The majority of extra work required to use TypeScript with Meteor is creating and maintaining the collection interfaces. However, doing so also provides the
|
||||
additional benefit of succinctly documenting collection schema definitions (that are actually enforced).
|
||||
The majority of extra work required to use TypeScript with Meteor is creating and maintaining the collection interfaces. However, doing so also provides the additional benefit of succinctly documenting collection schema definitions (that are actually enforced).
|
||||
|
||||
To define collections, you will need to create an interface representing the collection and then declare a Collection type variable with that interface type (as a generic):
|
||||
|
||||
@@ -104,8 +115,7 @@ If you have lots of custom definitions for a project, you can:
|
||||
|
||||
- Create multiple definition files and include individual references to each definition file.
|
||||
- Create one huge monolithic definition file so you only have to refer to that file.
|
||||
- Create multiple definition files, and create a definition file with references to the other definitions files so that you only have to maintain one reference
|
||||
for all of you custom definitions. e.g. contents of ".typescript/custom_defs/custom-definitions.d.ts":
|
||||
- Create multiple definition files, and create a definition file with references to the other definitions files so that you only have to maintain one reference for all of you custom definitions. e.g. contents of ".typescript/custom_defs/custom-definitions.d.ts":
|
||||
|
||||
/// <reference path='collections.ts' />
|
||||
/// <reference path='paraview_helpers.d.ts'/>
|
||||
@@ -116,18 +126,26 @@ for all of you custom definitions. e.g. contents of ".typescript/custom_defs/cu
|
||||
## Transpiling TypeScript
|
||||
|
||||
### Meteor plugin
|
||||
One solution for transpiling typescript is to install the following meteor package [https://github.com/meteor-typescript/meteor-typescript-compiler](https://github.com/meteor-typescript/meteor-typescript-compiler)
|
||||
One solution for transpiling typescript is to install the following meteor package: [https://github.com/meteor-typescript/meteor-typescript-compiler](https://github.com/meteor-typescript/meteor-typescript-compiler)
|
||||
|
||||
### IDE/Editor Transpilation
|
||||
WebStorm is a good TypeScript-aware editor. It can automatically transpile your TypeScript code into JavaScript every time you save a file. To enable this
|
||||
feature in WebStorm on OSX, first install the TypeScript transpiler on your system:
|
||||
WebStorm, SublimeText, Atom, and VisualStudio all support TypeScript. They can automatically transpile your TypeScript code into JavaScript every time you save a file.
|
||||
|
||||
#### WebStorm ####
|
||||
To support TypeScript in WebStorm on OSX, first install the TypeScript transpiler on your system:
|
||||
|
||||
$ [sudo -H] npm install -g typescript
|
||||
|
||||
Then, within WebStorm, go to Preferences -> File Watchers -> "+" symbol and add TypeScript.
|
||||
On version 10 of WebStorm or later, got to Preferences -> Languages & Frameworks -> TypeScript and check "Enable TypeScript Compiler"
|
||||
|
||||
On older versions of WebStorm (9 or earlier), go to Preferences -> File Watchers -> "+" symbol and add TypeScript.
|
||||
|
||||
#### SublimeText, Atom, and VisualStudio ####
|
||||
Please refer to the documentation for these editors.
|
||||
|
||||
### Command line
|
||||
|
||||
Last option, is to compile code from the command line. With node and the typescript compiler installed:
|
||||
The last option is to compile code from the command line. With node and the TypeScript compiler installed:
|
||||
|
||||
$ tsc *.ts
|
||||
|
||||
|
||||
+86
-202
@@ -1,25 +1,16 @@
|
||||
/// <reference path='meteor.d.ts'/>
|
||||
|
||||
/**
|
||||
* All code below was copied from the examples at http://docs.meteor.com/.
|
||||
* When necessary, code was added to make the examples work (e.g. declaring a variable
|
||||
* that was assumed to have been declared earlier)
|
||||
*/
|
||||
|
||||
|
||||
/*********************************** Begin setup for tests ******************************/
|
||||
var Rooms = new Mongo.Collection('rooms');
|
||||
var Messages = new Mongo.Collection('messages');
|
||||
interface MonkeyDAO {
|
||||
_id: string;
|
||||
name: string;
|
||||
}
|
||||
var Monkeys = new Mongo.Collection<MonkeyDAO>('monkeys');
|
||||
var Monkeys = new Mongo.Collection('monkeys');
|
||||
//var x = new Mongo.Collection<xDAO>('x');
|
||||
//var y = new Mongo.Collection<yDAO>('y');
|
||||
/********************************** End setup for tests *********************************/
|
||||
|
||||
|
||||
/**
|
||||
* From Core, Meteor.startup section
|
||||
* Tests Meteor.isServer, Meteor.startup, Collection.insert(), Collection.find()
|
||||
@@ -27,30 +18,26 @@ var Monkeys = new Mongo.Collection<MonkeyDAO>('monkeys');
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(function () {
|
||||
if (Rooms.find().count() === 0) {
|
||||
Rooms.insert({name: "Initial room"});
|
||||
Rooms.insert({ name: "Initial room" });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* From Publish and Subscribe, Meteor.publish section
|
||||
**/
|
||||
Meteor.publish("rooms", function () {
|
||||
return Rooms.find({}, {fields: {secretInfo: 0}});
|
||||
return Rooms.find({}, { fields: { secretInfo: 0 } });
|
||||
});
|
||||
|
||||
Meteor.publish("adminSecretInfo", function () {
|
||||
return Rooms.find({admin: this.userId}, {fields: {secretInfo: 1}});
|
||||
return Rooms.find({ admin: this.userId }, { fields: { secretInfo: 1 } });
|
||||
});
|
||||
|
||||
Meteor.publish("roomAndMessages", function (roomId) {
|
||||
check(roomId, String);
|
||||
return [
|
||||
Rooms.find({_id: roomId}, {fields: {secretInfo: 0}}),
|
||||
Messages.find({roomId: roomId})
|
||||
Rooms.find({ _id: roomId }, { fields: { secretInfo: 0 } }),
|
||||
Messages.find({ roomId: roomId })
|
||||
];
|
||||
});
|
||||
|
||||
/**
|
||||
* Also from Publish and Subscribe, Meteor.publish section
|
||||
*/
|
||||
@@ -59,55 +46,45 @@ Meteor.publish("counts-by-room", function (roomId) {
|
||||
check(roomId, String);
|
||||
var count = 0;
|
||||
var initializing = true;
|
||||
var handle = Messages.find({roomId: roomId}).observeChanges({
|
||||
var handle = Messages.find({ roomId: roomId }).observeChanges({
|
||||
added: function (id) {
|
||||
count++;
|
||||
// if (!initializing)
|
||||
|
||||
// Todo: Not sure how to define in typescript
|
||||
// self.changed("counts", roomId, {count: count});
|
||||
// if (!initializing)
|
||||
// Todo: Not sure how to define in typescript
|
||||
// self.changed("counts", roomId, {count: count});
|
||||
},
|
||||
removed: function (id) {
|
||||
count--;
|
||||
// Todo: Not sure how to define in typescript
|
||||
// self.changed("counts", roomId, {count: count});
|
||||
// Todo: Not sure how to define in typescript
|
||||
// self.changed("counts", roomId, {count: count});
|
||||
}
|
||||
});
|
||||
|
||||
initializing = false;
|
||||
|
||||
// Todo: Not sure how to define in typescript
|
||||
// self.added("counts", roomId, {count: count});
|
||||
// Todo: Not sure how to define in typescript
|
||||
// self.added("counts", roomId, {count: count});
|
||||
self.ready();
|
||||
|
||||
self.onStop(function () {
|
||||
handle.stop();
|
||||
});
|
||||
});
|
||||
|
||||
var Counts = new Mongo.Collection("counts");
|
||||
|
||||
Tracker.autorun(function () {
|
||||
Meteor.subscribe("counts-by-room", Session.get("roomId"));
|
||||
});
|
||||
|
||||
console.log("Current room has " +
|
||||
Counts.find(Session.get("roomId")).count +
|
||||
" messages.");
|
||||
|
||||
Counts.find(Session.get("roomId")).count +
|
||||
" messages.");
|
||||
/**
|
||||
* From Publish and Subscribe, Meteor.subscribe section
|
||||
*/
|
||||
Meteor.subscribe("allplayers");
|
||||
|
||||
/**
|
||||
* Also from Meteor.subscribe section
|
||||
*/
|
||||
Tracker.autorun(function () {
|
||||
Meteor.subscribe("chat", {room: Session.get("current-room")});
|
||||
Meteor.subscribe("chat", { room: Session.get("current-room") });
|
||||
Meteor.subscribe("privateMessages");
|
||||
});
|
||||
|
||||
/**
|
||||
* From Methods, Meteor.methods section
|
||||
*/
|
||||
@@ -115,51 +92,43 @@ Meteor.methods({
|
||||
foo: function (arg1, arg2) {
|
||||
check(arg1, String);
|
||||
check(arg2, [Number]);
|
||||
|
||||
var you_want_to_throw_an_error = true;
|
||||
if (you_want_to_throw_an_error)
|
||||
throw new Meteor.Error("404", "Can't find my pants");
|
||||
return "some return value";
|
||||
},
|
||||
|
||||
bar: function () {
|
||||
// .. do other stuff ..
|
||||
return "baz";
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* From Methods, Meteor.Error section
|
||||
*/
|
||||
throw new Meteor.Error("logged-out", "The user must be logged in to post a comment.");
|
||||
Meteor.call("methodName", function (error) {
|
||||
if (error.error === "logged-out") {
|
||||
Session.set("errorMessage", "Please log in to post a comment.");
|
||||
}
|
||||
});
|
||||
var error = new Meteor.Error("logged-out", "The user must be logged in to post a comment.");
|
||||
console.log(error.error === "logged-out");
|
||||
console.log(error.reason === "The user must be logged in to post a comment.");
|
||||
console.log(error.details !== "");
|
||||
/**
|
||||
* From Methods, Meteor.call section
|
||||
*/
|
||||
Meteor.call('foo', 1, 2, function (error, result) {} );
|
||||
Meteor.call('foo', 1, 2, function (error, result) { });
|
||||
var result = Meteor.call('foo', 1, 2);
|
||||
|
||||
/**
|
||||
* From Collections, Mongo.Collection section
|
||||
*/
|
||||
// DA: I added the "var" keyword in there
|
||||
|
||||
interface ChatroomsDAO {
|
||||
_id?: string;
|
||||
}
|
||||
interface MessagesDAO {
|
||||
_id?: string;
|
||||
}
|
||||
var Chatrooms = new Mongo.Collection<ChatroomsDAO>("chatrooms");
|
||||
Messages = new Mongo.Collection<MessagesDAO>("messages");
|
||||
|
||||
var myMessages = <MessagesDAO> Messages.find({userId: Session.get('myUserId')}).fetch();
|
||||
|
||||
Messages.insert({text: "Hello, world!"});
|
||||
|
||||
Messages.update(myMessages[0]._id, {$set: {important: true}});
|
||||
|
||||
var Chatrooms = new Mongo.Collection("chatrooms");
|
||||
Messages = new Mongo.Collection("messages");
|
||||
var myMessages = Messages.find({ userId: Session.get('myUserId') }).fetch();
|
||||
Messages.insert({ text: "Hello, world!" });
|
||||
Messages.update(myMessages[0]._id, { $set: { important: true } });
|
||||
var Posts = new Mongo.Collection("posts");
|
||||
Posts.insert({title: "Hello world", body: "First post"});
|
||||
|
||||
Posts.insert({ title: "Hello world", body: "First post" });
|
||||
// Couldn't find assert() in the meteor docs
|
||||
//assert(Posts.find().count() === 1);
|
||||
|
||||
/**
|
||||
* Todo: couldn't figure out how to make this next line work with Typescript
|
||||
* since there is already a Collection constructor with a different signature
|
||||
@@ -169,66 +138,48 @@ Posts.insert({title: "Hello world", body: "First post"});
|
||||
Scratchpad.insert({number: i * 2});
|
||||
assert(Scratchpad.find({number: {$lt: 9}}).count() === 5);
|
||||
**/
|
||||
|
||||
var Animal = function (doc) {
|
||||
// _.extend(this, doc);
|
||||
// _.extend(this, doc);
|
||||
};
|
||||
|
||||
// DA: I altered this to remove dependencies on Underscore
|
||||
Animal.prototype = {
|
||||
makeNoise: function () {
|
||||
console.log(this.sound);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
interface AnimalDAO {
|
||||
_id: string;
|
||||
makeNoise: () => void;
|
||||
}
|
||||
|
||||
// Define a Collection that uses Animal as its document
|
||||
var Animals = new Mongo.Collection<AnimalDAO>("Animals", {
|
||||
var Animals = new Mongo.Collection("Animals", {
|
||||
transform: function (doc) { return new Animal(doc); }
|
||||
});
|
||||
|
||||
// Create an Animal and call its makeNoise method
|
||||
Animals.insert({name: "raptor", sound: "roar"});
|
||||
Animals.findOne({name: "raptor"}).makeNoise(); // prints "roar"
|
||||
|
||||
Animals.insert({ name: "raptor", sound: "roar" });
|
||||
Animals.findOne({ name: "raptor" }).makeNoise(); // prints "roar"
|
||||
/**
|
||||
* From Collections, Collection.insert section
|
||||
*/
|
||||
// DA: I added the variable declaration statements to make this work
|
||||
var Lists = new Mongo.Collection('Lists');
|
||||
var Items = new Mongo.Collection('Lists');
|
||||
|
||||
var groceriesId = Lists.insert({name: "Groceries"});
|
||||
Items.insert({list: groceriesId, name: "Watercress"});
|
||||
Items.insert({list: groceriesId, name: "Persimmons"});
|
||||
|
||||
var groceriesId = Lists.insert({ name: "Groceries" });
|
||||
Items.insert({ list: groceriesId, name: "Watercress" });
|
||||
Items.insert({ list: groceriesId, name: "Persimmons" });
|
||||
/**
|
||||
* From Collections, collection.update section
|
||||
*/
|
||||
var Players = new Mongo.Collection('Players');
|
||||
|
||||
Template['adminDashboard'].events({
|
||||
'click .givePoints': function () {
|
||||
Players.update(Session.get("currentPlayer"), {$inc: {score: 5}});
|
||||
Players.update(Session.get("currentPlayer"), { $inc: { score: 5 } });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Also from Collections, collection.update section
|
||||
*/
|
||||
Meteor.methods({
|
||||
declareWinners: function () {
|
||||
Players.update({score: {$gt: 10}},
|
||||
{$addToSet: {badges: "Winner"}},
|
||||
{multi: true});
|
||||
Players.update({ score: { $gt: 10 } }, { $addToSet: { badges: "Winner" } }, { multi: true });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* From Collections, collection.remove section
|
||||
*/
|
||||
@@ -237,22 +188,15 @@ Template['chat'].events({
|
||||
Messages.remove(this._id);
|
||||
}
|
||||
});
|
||||
|
||||
// DA: I added this next line
|
||||
var Logs = new Mongo.Collection('logs');
|
||||
|
||||
Meteor.startup(function () {
|
||||
if (Meteor.isServer) {
|
||||
Logs.remove({});
|
||||
Players.remove({karma: {$lt: -2}});
|
||||
Players.remove({ karma: { $lt: -2 } });
|
||||
}
|
||||
});
|
||||
|
||||
/***
|
||||
* From Collections, collection.allow section
|
||||
*/
|
||||
Posts = new Mongo.Collection("posts");
|
||||
|
||||
Posts.allow({
|
||||
insert: function (userId, doc) {
|
||||
// the user must be logged in, and the document must be owned by the user
|
||||
@@ -268,11 +212,10 @@ Posts.allow({
|
||||
},
|
||||
fetch: ['owner']
|
||||
});
|
||||
|
||||
Posts.deny({
|
||||
update: function (userId, docs, fields, modifier) {
|
||||
update: function (userId, doc, fields, modifier) {
|
||||
// can't change owners
|
||||
return docs.userId !== userId;
|
||||
return doc.userId !== userId;
|
||||
},
|
||||
remove: function (userId, doc) {
|
||||
// can't remove locked documents
|
||||
@@ -280,25 +223,22 @@ Posts.deny({
|
||||
},
|
||||
fetch: ['locked'] // no need to fetch 'owner'
|
||||
});
|
||||
|
||||
/**
|
||||
* From Collections, cursor.forEach section
|
||||
*/
|
||||
var topPosts = Posts.find({}, {sort: {score: -1}, limit: 5});
|
||||
var topPosts = Posts.find({}, { sort: { score: -1 }, limit: 5 });
|
||||
var count = 0;
|
||||
topPosts.forEach(function (post) {
|
||||
console.log("Title of post " + count + ": " + post.title);
|
||||
count += 1;
|
||||
});
|
||||
|
||||
/**
|
||||
* From Collections, cursor.observeChanges section
|
||||
*/
|
||||
// DA: I added this line to make it work
|
||||
var Users = new Mongo.Collection('users');
|
||||
|
||||
var count1 = 0;
|
||||
var query = Users.find({admin: true, onlineNow: true});
|
||||
var query = Users.find({ admin: true, onlineNow: true });
|
||||
var handle = query.observeChanges({
|
||||
added: function (id, user) {
|
||||
count1++;
|
||||
@@ -309,49 +249,38 @@ var handle = query.observeChanges({
|
||||
console.log("Lost one. We're now down to " + count1 + " admins.");
|
||||
}
|
||||
});
|
||||
|
||||
// After five seconds, stop keeping the count.
|
||||
setTimeout(function () {handle.stop();}, 5000);
|
||||
|
||||
setTimeout(function () { handle.stop(); }, 5000);
|
||||
/**
|
||||
* From Sessions, Session.set section
|
||||
*/
|
||||
Tracker.autorun(function () {
|
||||
Meteor.subscribe("chat-history", {room: Session.get("currentRoomId")});
|
||||
Meteor.subscribe("chat-history", { room: Session.get("currentRoomId") });
|
||||
});
|
||||
|
||||
// Causes the function passed to Tracker.autorun to be re-run, so
|
||||
// that the chat-history subscription is moved to the room "home".
|
||||
Session.set("currentRoomId", "home");
|
||||
|
||||
/**
|
||||
* From Sessions, Session.get section
|
||||
*/
|
||||
// Page will say "We've always been at war with Eastasia"
|
||||
|
||||
// DA: commented out since transpiler didn't like append()
|
||||
//document.body.append(frag1);
|
||||
|
||||
// Page will change to say "We've always been at war with Eurasia"
|
||||
Session.set("enemy", "Eurasia");
|
||||
|
||||
/**
|
||||
* From Sessions, Session.equals section
|
||||
*/
|
||||
var value;
|
||||
Session.get("key") === value;
|
||||
Session.equals("key", value);
|
||||
|
||||
/**
|
||||
* From Accounts, Meteor.users section
|
||||
*/
|
||||
Meteor.publish("userData", function () {
|
||||
return Meteor.users.find({_id: this.userId},
|
||||
{fields: {'other': 1, 'things': 1}});
|
||||
return Meteor.users.find({ _id: this.userId }, { fields: { 'other': 1, 'things': 1 } });
|
||||
});
|
||||
|
||||
Meteor.users.deny({update: function () { return true; }});
|
||||
|
||||
Meteor.users.deny({ update: function () { return true; } });
|
||||
/**
|
||||
* From Accounts, Meteor.loginWithExternalService section
|
||||
*/
|
||||
@@ -361,7 +290,6 @@ Meteor.loginWithGithub({
|
||||
if (err)
|
||||
Session.set('errorMessage', err.reason || 'Unknown error');
|
||||
});
|
||||
|
||||
/**
|
||||
* From Accounts, Accounts.ui.config section
|
||||
*/
|
||||
@@ -375,7 +303,6 @@ Accounts.ui.config({
|
||||
},
|
||||
passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL'
|
||||
});
|
||||
|
||||
/**
|
||||
* From Accounts, Accounts.validateNewUser section
|
||||
*/
|
||||
@@ -388,11 +315,10 @@ Accounts.validateNewUser(function (user) {
|
||||
Accounts.validateNewUser(function (user) {
|
||||
return user.username !== "root";
|
||||
});
|
||||
|
||||
/**
|
||||
* From Accounts, Accounts.onCreateUser section
|
||||
*/
|
||||
Accounts.onCreateUser(function(options, user) {
|
||||
Accounts.onCreateUser(function (options, user) {
|
||||
var d6 = function () { return Math.floor(Math.random() * 6) + 1; };
|
||||
user.dexterity = d6() + d6() + d6();
|
||||
// We still want the default hook's 'profile' behavior.
|
||||
@@ -400,7 +326,6 @@ Accounts.onCreateUser(function(options, user) {
|
||||
user.profile = options.profile;
|
||||
return user;
|
||||
});
|
||||
|
||||
/**
|
||||
* From Passwords, Accounts.emailTemplates section
|
||||
*/
|
||||
@@ -411,10 +336,9 @@ Accounts.emailTemplates.enrollAccount.subject = function (user) {
|
||||
};
|
||||
Accounts.emailTemplates.enrollAccount.text = function (user, url) {
|
||||
return "You have been selected to participate in building a better future!"
|
||||
+ " To activate your account, simply click the link below:\n\n"
|
||||
+ url;
|
||||
+ " To activate your account, simply click the link below:\n\n"
|
||||
+ url;
|
||||
};
|
||||
|
||||
/**
|
||||
* From Templates, Template.myTemplate.helpers section
|
||||
*/
|
||||
@@ -427,45 +351,33 @@ Template['newTemplate'].helpers({
|
||||
helperName: function () {
|
||||
}
|
||||
});
|
||||
|
||||
Template['newTemplate'].created = function () {
|
||||
|
||||
};
|
||||
|
||||
Template['newTemplate'].rendered = function () {
|
||||
|
||||
};
|
||||
|
||||
Template['newTemplate'].destroyed = function () {
|
||||
|
||||
};
|
||||
|
||||
Template['newTemplate'].events({
|
||||
'click .something': function (event) {
|
||||
'click .something': function (event, template) {
|
||||
}
|
||||
});
|
||||
|
||||
Template.registerHelper('testHelper', function() {
|
||||
Template.registerHelper('testHelper', function () {
|
||||
return 'tester';
|
||||
});
|
||||
|
||||
var instance = Template.instance();
|
||||
var data = Template.currentData();
|
||||
var data = Template.parentData(1);
|
||||
var body = Template.body;
|
||||
|
||||
/**
|
||||
* From Match section
|
||||
*/
|
||||
var Chats = new Mongo.Collection('chats');
|
||||
|
||||
Meteor.publish("chats-in-room", function (roomId) {
|
||||
// Make sure roomId is a string, not an arbitrary mongo selector object.
|
||||
check(roomId, String);
|
||||
return Chats.find({room: roomId});
|
||||
return Chats.find({ room: roomId });
|
||||
});
|
||||
|
||||
Meteor.methods({addChat: function (roomId, message) {
|
||||
Meteor.methods({ addChat: function (roomId, message) {
|
||||
check(roomId, String);
|
||||
check(message, {
|
||||
text: String,
|
||||
@@ -473,39 +385,31 @@ Meteor.methods({addChat: function (roomId, message) {
|
||||
// Optional, but if present must be an array of strings.
|
||||
tags: Match.Optional('Test String')
|
||||
});
|
||||
|
||||
// ... do something with the message ...
|
||||
}});
|
||||
|
||||
} });
|
||||
/**
|
||||
* From Match patterns section
|
||||
*/
|
||||
var pat = { name: Match.Optional('test') };
|
||||
check({ name: "something" }, pat) // OK
|
||||
check({}, pat) // OK
|
||||
check({ name: undefined }, pat) // Throws an exception
|
||||
|
||||
check({ name: "something" }, pat); // OK
|
||||
check({}, pat); // OK
|
||||
check({ name: undefined }, pat); // Throws an exception
|
||||
// Outside an object
|
||||
check(undefined, Match.Optional('test')); // OK
|
||||
|
||||
/**
|
||||
* From Deps, Tracker.autorun section
|
||||
*/
|
||||
Tracker.autorun(function () {
|
||||
var oldest = Monkeys.findOne('age = 20');
|
||||
|
||||
if (oldest)
|
||||
Session.set("oldest", oldest.name);
|
||||
});
|
||||
|
||||
Tracker.autorun(function (c) {
|
||||
if (! Session.equals("shouldAlert", true))
|
||||
if (!Session.equals("shouldAlert", true))
|
||||
return;
|
||||
|
||||
c.stop();
|
||||
alert("Oh no!");
|
||||
});
|
||||
|
||||
/**
|
||||
* From Deps, Deps.Computation
|
||||
*/
|
||||
@@ -514,84 +418,64 @@ if (Tracker.active) {
|
||||
console.log('invalidated');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* From Tracker, Tracker.Dependency
|
||||
*/
|
||||
var weather = "sunny";
|
||||
var weatherDep = new Tracker.Dependency;
|
||||
|
||||
var getWeather = function () {
|
||||
weatherDep.depend();
|
||||
return weather;
|
||||
};
|
||||
|
||||
var setWeather = function (w) {
|
||||
weather = w;
|
||||
// (could add logic here to only call changed()
|
||||
// if the new value is different from the old)
|
||||
weatherDep.changed();
|
||||
};
|
||||
|
||||
/**
|
||||
* From HTTP, HTTP.call section
|
||||
*/
|
||||
Meteor.methods({checkTwitter: function (userId) {
|
||||
Meteor.methods({ checkTwitter: function (userId) {
|
||||
check(userId, String);
|
||||
this.unblock();
|
||||
var result = HTTP.call("GET", "http://api.twitter.com/xyz",
|
||||
{params: {user: userId}});
|
||||
var result = HTTP.call("GET", "http://api.twitter.com/xyz", { params: { user: userId } });
|
||||
if (result.statusCode === 200)
|
||||
return true
|
||||
return true;
|
||||
return false;
|
||||
}});
|
||||
|
||||
|
||||
HTTP.call("POST", "http://api.twitter.com/xyz",
|
||||
{data: {some: "json", stuff: 1}},
|
||||
function (error, result) {
|
||||
if (result.statusCode === 200) {
|
||||
Session.set("twizzled", true);
|
||||
}
|
||||
});
|
||||
|
||||
} });
|
||||
HTTP.call("POST", "http://api.twitter.com/xyz", { data: { some: "json", stuff: 1 } }, function (error, result) {
|
||||
if (result.statusCode === 200) {
|
||||
Session.set("twizzled", true);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* From Email, Email.send section
|
||||
*/
|
||||
Meteor.methods({
|
||||
sendEmail: function (to, from, subject, text) {
|
||||
check([to, from, subject, text], [String]);
|
||||
|
||||
// Let other method calls from the same client start running,
|
||||
// without waiting for the email sending to complete.
|
||||
this.unblock();
|
||||
}
|
||||
});
|
||||
|
||||
// In your client code: asynchronously send an email
|
||||
Meteor.call('sendEmail',
|
||||
'alice@example.com',
|
||||
'Hello from Meteor!',
|
||||
'This is a test of Email.send.');
|
||||
|
||||
Meteor.call('sendEmail', 'alice@example.com', 'Hello from Meteor!', 'This is a test of Email.send.');
|
||||
var testTemplate = new Blaze.Template();
|
||||
var testView = new Blaze.View();
|
||||
|
||||
declare var el: HTMLElement;
|
||||
Blaze.render(testTemplate, el);
|
||||
Blaze.renderWithData(testTemplate, {testData: 123}, el);
|
||||
Blaze.renderWithData(testTemplate, { testData: 123 }, el);
|
||||
Blaze.remove(testView);
|
||||
Blaze.getData(el);
|
||||
Blaze.getData(testView);
|
||||
Blaze.toHTML(testTemplate);
|
||||
Blaze.toHTML(testView);
|
||||
Blaze.toHTMLWithData(testTemplate, {test: 1});
|
||||
Blaze.toHTMLWithData(testTemplate, function() {});
|
||||
Blaze.toHTMLWithData(testView, {test: 1});
|
||||
Blaze.toHTMLWithData(testView, function() {});
|
||||
|
||||
var reactiveVar1 = new ReactiveVar<string>('test value');
|
||||
var reactiveVar2 = new ReactiveVar<string>('test value', function(oldVal) { return true; });
|
||||
|
||||
var varValue: string = reactiveVar1.get();
|
||||
reactiveVar1.set('new value');
|
||||
Blaze.toHTMLWithData(testTemplate, { test: 1 });
|
||||
Blaze.toHTMLWithData(testTemplate, function () { });
|
||||
Blaze.toHTMLWithData(testView, { test: 1 });
|
||||
Blaze.toHTMLWithData(testView, function () { });
|
||||
var reactiveVar1 = new ReactiveVar('test value');
|
||||
var reactiveVar2 = new ReactiveVar('test value', function (oldVal) { return true; });
|
||||
var varValue = reactiveVar1.get();
|
||||
reactiveVar1.set('new value');
|
||||
|
||||
Vendored
+313
-204
@@ -1,10 +1,10 @@
|
||||
// Type definitions for Meteor 1.1.0.1
|
||||
// Type definitions for Meteor 1.2.0.2
|
||||
// Project: http://www.meteor.com/
|
||||
// Definitions by: Dave Allen <https://github.com/fullflavedave>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* These are the modules and interfaces that can't be automatically generated from the Meteor data.js file
|
||||
* These are the common (for client and server) modules and interfaces that can't be automatically generated from the Meteor data.js file
|
||||
*/
|
||||
|
||||
interface EJSONable {
|
||||
@@ -16,59 +16,20 @@ interface JSONable {
|
||||
interface EJSON extends EJSONable {}
|
||||
|
||||
declare module Match {
|
||||
var Any:any;
|
||||
var String:any;
|
||||
var Integer:any;
|
||||
var Boolean:any;
|
||||
var undefined:any;
|
||||
var Any: any;
|
||||
var String: any;
|
||||
var Integer: any;
|
||||
var Boolean: any;
|
||||
var undefined: any;
|
||||
//function null(); // not allowed in TypeScript
|
||||
var Object:any;
|
||||
function Optional(pattern:any):boolean;
|
||||
function ObjectIncluding(dico:any):boolean;
|
||||
function OneOf(...patterns:any[]):any;
|
||||
function Where(condition:any):any;
|
||||
var Object: any;
|
||||
function Optional(pattern: any):boolean;
|
||||
function ObjectIncluding(dico: any):boolean;
|
||||
function OneOf(...patterns: any[]): any;
|
||||
function Where(condition: any): any;
|
||||
}
|
||||
|
||||
declare module Meteor {
|
||||
/** Start definitions for Template **/
|
||||
interface Event {
|
||||
type:string;
|
||||
target:HTMLElement;
|
||||
currentTarget:HTMLElement;
|
||||
which: number;
|
||||
stopPropagation():void;
|
||||
stopImmediatePropagation():void;
|
||||
preventDefault():void;
|
||||
isPropagationStopped():boolean;
|
||||
isImmediatePropagationStopped():boolean;
|
||||
isDefaultPrevented():boolean;
|
||||
}
|
||||
|
||||
interface EventHandlerFunction extends Function {
|
||||
(event?:Meteor.Event):void;
|
||||
}
|
||||
|
||||
interface EventMap {
|
||||
[id:string]:Meteor.EventHandlerFunction;
|
||||
}
|
||||
/** End definitions for Template **/
|
||||
|
||||
interface LoginWithExternalServiceOptions {
|
||||
requestPermissions?: string[];
|
||||
requestOfflineToken?: Boolean;
|
||||
forceApprovalPrompt?: Boolean;
|
||||
userEmail?: string;
|
||||
loginStyle?: string;
|
||||
}
|
||||
|
||||
function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithFacebook(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithGithub(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithGoogle(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
|
||||
interface UserEmail {
|
||||
address:string;
|
||||
verified:boolean;
|
||||
@@ -83,16 +44,6 @@ declare module Meteor {
|
||||
services?: any;
|
||||
}
|
||||
|
||||
interface SubscriptionHandle {
|
||||
stop(): void;
|
||||
ready(): boolean;
|
||||
}
|
||||
|
||||
interface Tinytest {
|
||||
add(name:string, func:Function):any;
|
||||
addAsync(name:string, func:Function):any;
|
||||
}
|
||||
|
||||
enum StatusEnum {
|
||||
connected,
|
||||
connecting,
|
||||
@@ -104,53 +55,40 @@ declare module Meteor {
|
||||
interface LiveQueryHandle {
|
||||
stop(): void;
|
||||
}
|
||||
}
|
||||
|
||||
interface EmailFields {
|
||||
subject?: Function;
|
||||
text?: Function;
|
||||
declare module DDP {
|
||||
interface DDPStatic {
|
||||
subscribe(name: string, ...rest: any[]);
|
||||
call(method: string, ...parameters: any[]):void;
|
||||
apply(method: string, ...parameters: any[]):void;
|
||||
methods(IMeteorMethodsDictionary: any): any;
|
||||
status():DDPStatus;
|
||||
reconnect(): void;
|
||||
disconnect(): void;
|
||||
onReconnect(): void;
|
||||
}
|
||||
|
||||
interface EmailTemplates {
|
||||
from: string;
|
||||
siteName: string;
|
||||
resetPassword: Meteor.EmailFields;
|
||||
enrollAccount: Meteor.EmailFields;
|
||||
verifyEmail: Meteor.EmailFields;
|
||||
}
|
||||
|
||||
interface Error {
|
||||
error: number;
|
||||
interface DDPStatus {
|
||||
connected: boolean;
|
||||
status: Meteor.StatusEnum;
|
||||
retryCount: number;
|
||||
//To turn this into an interval until the next reconnection, use retryTime - (new Date()).getTime()
|
||||
retryTime?: number;
|
||||
reason?: string;
|
||||
details?: string;
|
||||
}
|
||||
|
||||
interface Connection {
|
||||
id: string;
|
||||
close: Function;
|
||||
onClose: Function;
|
||||
clientAddress: string;
|
||||
httpHeaders: Object;
|
||||
}
|
||||
}
|
||||
|
||||
declare module Mongo {
|
||||
interface Selector {
|
||||
[key: string]:any;
|
||||
}
|
||||
interface Selector extends Object {}
|
||||
interface Modifier {}
|
||||
interface SortSpecifier {}
|
||||
interface FieldSpecifier {
|
||||
[id: string]: Number;
|
||||
}
|
||||
enum IdGenerationEnum {
|
||||
STRING,
|
||||
MONGO
|
||||
}
|
||||
interface AllowDenyOptions {
|
||||
insert?: (userId:string, doc:any) => boolean;
|
||||
update?: (userId:string, doc:any, fieldNames:string[], modifier:any) => boolean;
|
||||
remove?: (userId:string, doc:any) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
}
|
||||
}
|
||||
|
||||
declare module HTTP {
|
||||
@@ -178,43 +116,6 @@ declare module HTTP {
|
||||
function get(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
|
||||
function post(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
|
||||
function put(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse;
|
||||
|
||||
}
|
||||
|
||||
declare module Email {
|
||||
interface EmailMessage {
|
||||
from: string;
|
||||
to: string|string[];
|
||||
cc?: string|string[];
|
||||
bcc?: string|string[];
|
||||
replyTo?: string|string[];
|
||||
subject: string;
|
||||
text?: string;
|
||||
html?: string;
|
||||
headers?: {[id: string]: string};
|
||||
}
|
||||
}
|
||||
|
||||
declare module DDP {
|
||||
interface DDPStatic {
|
||||
subscribe(name:string, ...rest:any[]):void;
|
||||
call(method:string, ...parameters:any[]):void;
|
||||
apply(method:string, ...parameters:any[]):void;
|
||||
methods(IMeteorMethodsDictionary:any):any;
|
||||
status():DDPStatus;
|
||||
reconnect():void;
|
||||
disconnect():void;
|
||||
onReconnect():void;
|
||||
}
|
||||
|
||||
interface DDPStatus {
|
||||
connected: boolean;
|
||||
status: Meteor.StatusEnum;
|
||||
retryCount: number;
|
||||
//To turn this into an interval until the next reconnection, use retryTime - (new Date()).getTime()
|
||||
retryTime?: number;
|
||||
reason?: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module Random {
|
||||
@@ -226,6 +127,56 @@ declare module Random {
|
||||
function choice(str:string):string; // @param str, @return a random char in str
|
||||
}
|
||||
|
||||
/**
|
||||
* These are the client modules and interfaces that can't be automatically generated from the Meteor data.js file
|
||||
*/
|
||||
|
||||
declare module Meteor {
|
||||
/** Start definitions for Template **/
|
||||
interface Event {
|
||||
type:string;
|
||||
target:HTMLElement;
|
||||
currentTarget:HTMLElement;
|
||||
which: number;
|
||||
stopPropagation():void;
|
||||
stopImmediatePropagation():void;
|
||||
preventDefault():void;
|
||||
isPropagationStopped():boolean;
|
||||
isImmediatePropagationStopped():boolean;
|
||||
isDefaultPrevented():boolean;
|
||||
}
|
||||
|
||||
interface EventHandlerFunction extends Function {
|
||||
(event?:Meteor.Event, templateInstance?: Blaze.TemplateInstance):void;
|
||||
}
|
||||
|
||||
interface EventMap {
|
||||
[id:string]:Meteor.EventHandlerFunction;
|
||||
}
|
||||
/** End definitions for Template **/
|
||||
|
||||
interface LoginWithExternalServiceOptions {
|
||||
requestPermissions?: string[];
|
||||
requestOfflineToken?: Boolean;
|
||||
forceApprovalPrompt?: Boolean;
|
||||
userEmail?: string;
|
||||
loginStyle?: string;
|
||||
}
|
||||
|
||||
function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithFacebook(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithGithub(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithGoogle(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void;
|
||||
|
||||
interface SubscriptionHandle {
|
||||
stop(): void;
|
||||
ready(): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module Blaze {
|
||||
interface View {
|
||||
name: string;
|
||||
@@ -286,25 +237,113 @@ declare module BrowserPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
declare module Tracker {
|
||||
export var ComputationFunction: (computation: Tracker.Computation) => void;
|
||||
|
||||
}
|
||||
|
||||
declare var IterationCallback: <T>(doc: T, index: number, cursor: Mongo.Cursor<T>) => void;
|
||||
|
||||
/**
|
||||
* These modules and interfaces are automatically generated from the Meteor api.js file
|
||||
* These are the server modules and interfaces that can't be automatically generated from the Meteor data.js file
|
||||
*/
|
||||
|
||||
declare module Meteor {
|
||||
interface EmailFields {
|
||||
subject?: Function;
|
||||
text?: Function;
|
||||
}
|
||||
|
||||
interface EmailTemplates {
|
||||
from: string;
|
||||
siteName: string;
|
||||
resetPassword: Meteor.EmailFields;
|
||||
enrollAccount: Meteor.EmailFields;
|
||||
verifyEmail: Meteor.EmailFields;
|
||||
}
|
||||
|
||||
interface Connection {
|
||||
id: string;
|
||||
close: Function;
|
||||
onClose: Function;
|
||||
clientAddress: string;
|
||||
httpHeaders: Object;
|
||||
}
|
||||
}
|
||||
|
||||
declare module Mongo {
|
||||
interface AllowDenyOptions {
|
||||
insert?: (userId: string, doc: any) => boolean;
|
||||
update?: (userId: string, doc: any, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: any) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
}
|
||||
}
|
||||
|
||||
interface MailComposerOptions {
|
||||
escapeSMTP: boolean;
|
||||
encoding: string;
|
||||
charset: string;
|
||||
keepBcc: boolean;
|
||||
forceEmbeddedImages: boolean;
|
||||
}
|
||||
|
||||
declare var MailComposer: MailComposerStatic;
|
||||
interface MailComposerStatic {
|
||||
new(options: MailComposerOptions): MailComposer;
|
||||
}
|
||||
interface MailComposer {
|
||||
addHeader(name: string, value: string): void;
|
||||
setMessageOption(from: string, to: string, body: string, html: string): void;
|
||||
streamMessage();
|
||||
pipe(stream: any /** fs.WriteStream **/);
|
||||
}
|
||||
/**
|
||||
* These are the modules and interfaces for packages that can't be automatically generated from the Meteor data.js file
|
||||
*/
|
||||
|
||||
interface ILengthAble {
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface ITinytestAssertions {
|
||||
ok(doc: Object): void;
|
||||
expect_fail(): void;
|
||||
fail(doc: Object): void;
|
||||
runId(): string;
|
||||
equal<T>(actual: T, expected: T, message?: string, not?: boolean): void;
|
||||
notEqual<T>(actual: T, expected: T, message?: string): void;
|
||||
instanceOf(obj : Object, klass: Function, message?: string): void;
|
||||
notInstanceOf(obj : Object, klass: Function, message?: string): void;
|
||||
matches(actual : any, regexp: RegExp, message?: string): void;
|
||||
notMatches(actual : any, regexp: RegExp, message?: string): void;
|
||||
throws(f: Function, expected?: string|RegExp): void;
|
||||
isTrue(v: boolean, msg?: string): void;
|
||||
isFalse(v: boolean, msg?: string): void;
|
||||
isNull(v: any, msg?: string): void;
|
||||
isNotNull(v: any, msg?: string): void;
|
||||
isUndefined(v: any, msg?: string): void;
|
||||
isNotUndefined(v: any, msg?: string): void;
|
||||
isNan(v: any, msg?: string): void;
|
||||
isNotNan(v: any, msg?: string): void;
|
||||
include<T>(s: Array<T>|Object|string, value: any, msg?: string, not?: boolean): void;
|
||||
|
||||
notInclude<T>(s: Array<T>|Object|string, value: any, msg?: string, not?: boolean): void;
|
||||
length(obj: ILengthAble, expected_length: number, msg?: string): void;
|
||||
_stringEqual(actual: string, expected: string, msg?: string): void;
|
||||
}
|
||||
|
||||
declare module Tinytest {
|
||||
function add(description : string , func : (test : ITinytestAssertions) => void) : void;
|
||||
function addAsync(description : string , func : (test : ITinytestAssertions) => void) : void;
|
||||
}
|
||||
|
||||
// Kept in for backwards compatibility
|
||||
declare module Meteor {
|
||||
interface Tinytest {
|
||||
add(description : string , func : (test : ITinytestAssertions) => void) : void;
|
||||
addAsync(description : string , func : (test : ITinytestAssertions) => void) : void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module Accounts {
|
||||
function changePassword(oldPassword: string, newPassword: string, callback?: Function): void;
|
||||
function config(options: {
|
||||
sendVerificationEmail?: boolean;
|
||||
forbidClientAccountCreation?: boolean;
|
||||
restrictCreationByEmailDomain?: string | Function;
|
||||
loginExpirationInDays?: number;
|
||||
oauthSecretKey?: string;
|
||||
}): void;
|
||||
function addEmail(userId: string, newEmail: string, verified?: boolean); /** TODO: add return value **/
|
||||
function changePassword(oldPassword: string, newPassword: string, callback?: Function): void;
|
||||
function createUser(options: {
|
||||
username?: string;
|
||||
email?: string;
|
||||
@@ -312,40 +351,78 @@ declare module Accounts {
|
||||
profile?: Object;
|
||||
}, callback?: Function): string;
|
||||
var emailTemplates: Meteor.EmailTemplates;
|
||||
function findUserByEmail(email: string): Object;
|
||||
function findUserByUsername(username: string): Object;
|
||||
function forgotPassword(options: {
|
||||
email?: string;
|
||||
}, callback?: Function): void;
|
||||
function onCreateUser(func: Function): void;
|
||||
function onEmailVerificationLink(callback: Function): void;
|
||||
function onEnrollmentLink(callback: Function): void;
|
||||
function onLogin(func: Function): {stop: Function};
|
||||
function onLoginFailure(func: Function): {stop: Function};
|
||||
function onResetPasswordLink(callback: Function): void;
|
||||
function resetPassword(token: string, newPassword: string, callback?: Function): void;
|
||||
function removeEmail(userId: string, email: string); /** TODO: add return value **/
|
||||
function resetPassword(token: string, newPassword: string, callback?: Function): void;
|
||||
function sendEnrollmentEmail(userId: string, email?: string): void;
|
||||
function sendResetPasswordEmail(userId: string, email?: string): void;
|
||||
function sendVerificationEmail(userId: string, email?: string): void;
|
||||
function setPassword(userId: string, newPassword: string, options?: {
|
||||
logout?: Object;
|
||||
}): void;
|
||||
var ui: {
|
||||
config(options: {
|
||||
requestPermissions?: Object;
|
||||
requestOfflineToken?: Object;
|
||||
forceApprovalPrompt?: Object;
|
||||
passwordSignupFields?: string;
|
||||
}): void;
|
||||
};
|
||||
function validateLoginAttempt(func: Function): {stop: Function};
|
||||
function validateNewUser(func: Function): void;
|
||||
function setUsername(userId: string, newUsername: string); /** TODO: add return value **/
|
||||
var ui: {
|
||||
config(options: {
|
||||
requestPermissions?: Object;
|
||||
requestOfflineToken?: Object;
|
||||
forceApprovalPrompt?: Object;
|
||||
passwordSignupFields?: string;
|
||||
}): void;
|
||||
};
|
||||
function verifyEmail(token: string, callback?: Function): void;
|
||||
function config(options: {
|
||||
sendVerificationEmail?: boolean;
|
||||
forbidClientAccountCreation?: boolean;
|
||||
restrictCreationByEmailDomain?: string | Function;
|
||||
loginExpirationInDays?: number;
|
||||
oauthSecretKey?: string;
|
||||
}); /** TODO: add return value **/
|
||||
function onLogin(func: Function); /** TODO: add return value **/
|
||||
function onLoginFailure(func: Function); /** TODO: add return value **/
|
||||
function user(); /** TODO: add return value **/
|
||||
function userId(); /** TODO: add return value **/
|
||||
function config(options: {
|
||||
sendVerificationEmail?: boolean;
|
||||
forbidClientAccountCreation?: boolean;
|
||||
restrictCreationByEmailDomain?: string | Function;
|
||||
loginExpirationInDays?: number;
|
||||
oauthSecretKey?: string;
|
||||
}); /** TODO: add return value **/
|
||||
function loggingIn(); /** TODO: add return value **/
|
||||
function logout(callback?: Function); /** TODO: add return value **/
|
||||
function logoutOtherClients(callback?: Function); /** TODO: add return value **/
|
||||
function onLogin(func: Function); /** TODO: add return value **/
|
||||
function onLoginFailure(func: Function); /** TODO: add return value **/
|
||||
function user(); /** TODO: add return value **/
|
||||
function userId(); /** TODO: add return value **/
|
||||
function config(options: {
|
||||
sendVerificationEmail?: boolean;
|
||||
forbidClientAccountCreation?: boolean;
|
||||
restrictCreationByEmailDomain?: string | Function;
|
||||
loginExpirationInDays?: number;
|
||||
oauthSecretKey?: string;
|
||||
}); /** TODO: add return value **/
|
||||
function onCreateUser(func: Function); /** TODO: add return value **/
|
||||
function onLogin(func: Function); /** TODO: add return value **/
|
||||
function onLoginFailure(func: Function); /** TODO: add return value **/
|
||||
function user(); /** TODO: add return value **/
|
||||
function userId(); /** TODO: add return value **/
|
||||
function validateLoginAttempt(func: Function); /** TODO: add return value **/
|
||||
function validateNewUser(func: Function); /** TODO: add return value **/
|
||||
}
|
||||
|
||||
declare module App {
|
||||
function accessRule(domainRule: string, options?: {
|
||||
launchExternal?: boolean;
|
||||
}):any; /** TODO: add return value **/
|
||||
function configurePlugin(pluginName: string, config: Object): void;
|
||||
}): void;
|
||||
function configurePlugin(id: string, config: Object): void;
|
||||
function icons(icons: Object): void;
|
||||
function info(options: {
|
||||
id?: string;
|
||||
@@ -357,7 +434,7 @@ function configurePlugin(pluginName: string, config: Object): void;
|
||||
website?: string;
|
||||
}): void;
|
||||
function launchScreens(launchScreens: Object): void;
|
||||
function setPreference(name: string, value: string): void;
|
||||
function setPreference(name: string, value: string, platform?: string): void;
|
||||
}
|
||||
|
||||
declare module Assets {
|
||||
@@ -368,6 +445,7 @@ declare module Assets {
|
||||
declare module Blaze {
|
||||
function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
|
||||
function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View;
|
||||
function Let(bindings: Function, contentFunc: Function): Blaze.View;
|
||||
var Template: TemplateStatic;
|
||||
interface TemplateStatic {
|
||||
new(viewName?: string, renderFunction?: Function): Template;
|
||||
@@ -426,6 +504,11 @@ declare module DDP {
|
||||
function connect(url: string): DDP.DDPStatic;
|
||||
}
|
||||
|
||||
declare module DDPCommon {
|
||||
function MethodInvocation(options: {
|
||||
}): any;
|
||||
}
|
||||
|
||||
declare module EJSON {
|
||||
var CustomType: CustomTypeStatic;
|
||||
interface CustomTypeStatic {
|
||||
@@ -434,16 +517,16 @@ declare module EJSON {
|
||||
interface CustomType {
|
||||
clone(): EJSON.CustomType;
|
||||
equals(other: Object): boolean;
|
||||
toJSONValue(): JSON;
|
||||
toJSONValue(): JSONable;
|
||||
typeName(): string;
|
||||
}
|
||||
|
||||
function addType(name: string, factory: (val: EJSONable) => JSONable): void;
|
||||
function addType(name: string, factory: (val: JSONable) => EJSON.CustomType): void;
|
||||
function clone<T>(val:T): T;
|
||||
function equals(a: EJSON, b: EJSON, options?: {
|
||||
keyOrderSensitive?: boolean;
|
||||
}): boolean;
|
||||
function fromJSONValue(val: JSON): any;
|
||||
function fromJSONValue(val: JSONable): any;
|
||||
function isBinary(x: Object): boolean;
|
||||
var newBinary: any;
|
||||
function parse(str: string): EJSON;
|
||||
@@ -451,7 +534,7 @@ declare module EJSON {
|
||||
indent?: boolean | number | string;
|
||||
canonical?: boolean;
|
||||
}): string;
|
||||
function toJSONValue(val: EJSON): JSON;
|
||||
function toJSONValue(val: EJSON): JSONable;
|
||||
}
|
||||
|
||||
declare module Match {
|
||||
@@ -464,8 +547,10 @@ declare module Meteor {
|
||||
new(error: string, reason?: string, details?: string): Error;
|
||||
}
|
||||
interface Error {
|
||||
error: string;
|
||||
reason?: string;
|
||||
details?: string;
|
||||
}
|
||||
|
||||
function absoluteUrl(path?: string, options?: {
|
||||
secure?: boolean;
|
||||
replaceLocalhost?: boolean;
|
||||
@@ -486,9 +571,10 @@ declare module Meteor {
|
||||
function loginWith<ExternalService>(options?: {
|
||||
requestPermissions?: string[];
|
||||
requestOfflineToken?: boolean;
|
||||
forceApprovalPrompt?: boolean;
|
||||
loginUrlParameters?: Object;
|
||||
userEmail?: string;
|
||||
loginStyle?: string;
|
||||
redirectUrl?: string;
|
||||
}, callback?: Function): void;
|
||||
function loginWithPassword(user: Object | string, password: string, callback?: Function): void;
|
||||
function logout(callback?: Function): void;
|
||||
@@ -521,20 +607,20 @@ declare module Mongo {
|
||||
}
|
||||
interface Collection<T> {
|
||||
allow(options: {
|
||||
insert?: (userId:string, doc:any) => boolean;
|
||||
update?: (userId:string, doc:any, fieldNames:string[], modifier:any) => boolean;
|
||||
remove?: (userId:string, doc:any) => boolean;
|
||||
insert?: (userId: string, doc: T) => boolean;
|
||||
update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: T) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
}): boolean;
|
||||
deny(options: {
|
||||
insert?: (userId:string, doc:any) => boolean;
|
||||
update?: (userId:string, doc:any, fieldNames:string[], modifier:any) => boolean;
|
||||
remove?: (userId:string, doc:any) => boolean;
|
||||
insert?: (userId: string, doc: T) => boolean;
|
||||
update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: T) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
}): boolean;
|
||||
find(selector?: Mongo.Selector, options?: {
|
||||
find(selector?: Mongo.Selector | Mongo.ObjectID | string, options?: {
|
||||
sort?: Mongo.SortSpecifier;
|
||||
skip?: number;
|
||||
limit?: number;
|
||||
@@ -542,20 +628,22 @@ declare module Mongo {
|
||||
reactive?: boolean;
|
||||
transform?: Function;
|
||||
}): Mongo.Cursor<T>;
|
||||
findOne(selector?: Mongo.Selector, options?: {
|
||||
findOne(selector?: Mongo.Selector | Mongo.ObjectID | string, options?: {
|
||||
sort?: Mongo.SortSpecifier;
|
||||
skip?: number;
|
||||
fields?: Mongo.FieldSpecifier;
|
||||
reactive?: boolean;
|
||||
transform?: Function;
|
||||
}): T;
|
||||
insert(doc: Object, callback?: Function): string;
|
||||
remove(selector: Mongo.Selector, callback?: Function): void;
|
||||
update(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
|
||||
insert(doc: T, callback?: Function): string;
|
||||
rawCollection(); /** TODO: add return value **/
|
||||
rawDatabase(); /** TODO: add return value **/
|
||||
remove(selector: Mongo.Selector | Mongo.ObjectID | string, callback?: Function): void;
|
||||
update(selector: Mongo.Selector | Mongo.ObjectID | string, modifier: Mongo.Modifier, options?: {
|
||||
multi?: boolean;
|
||||
upsert?: boolean;
|
||||
}, callback?: Function): number;
|
||||
upsert(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
|
||||
upsert(selector: Mongo.Selector | Mongo.ObjectID | string, modifier: Mongo.Modifier, options?: {
|
||||
multi?: boolean;
|
||||
}, callback?: Function): {numberAffected?: number; insertedId?: string;};
|
||||
_ensureIndex(indexName: string, options?: {[key: string]: any}): void;
|
||||
@@ -569,14 +657,14 @@ declare module Mongo {
|
||||
count(): number;
|
||||
fetch(): Array<T>;
|
||||
forEach(callback: <T>(doc: T, index: number, cursor: Mongo.Cursor<T>) => void, thisArg?: any): void;
|
||||
map(callback: <T>(doc: T, index: number, cursor: Mongo.Cursor<T>) => void, thisArg?: any): Array<T>;
|
||||
map<U>(callback: (doc: T, index: number, cursor: Mongo.Cursor<T>) => U, thisArg?: any): Array<U>;
|
||||
observe(callbacks: Object): Meteor.LiveQueryHandle;
|
||||
observeChanges(callbacks: Object): Meteor.LiveQueryHandle;
|
||||
}
|
||||
|
||||
var ObjectID: ObjectIDStatic;
|
||||
interface ObjectIDStatic {
|
||||
new(hexString: string): ObjectID;
|
||||
new(hexString?: string): ObjectID;
|
||||
}
|
||||
interface ObjectID {
|
||||
}
|
||||
@@ -595,6 +683,8 @@ declare module Package {
|
||||
name?: string;
|
||||
git?: string;
|
||||
documentation?: string;
|
||||
debugOnly?: boolean;
|
||||
prodOnly?: boolean;
|
||||
}): void;
|
||||
function onTest(func: Function): void;
|
||||
function onUse(func: Function): void;
|
||||
@@ -613,6 +703,7 @@ declare module Tracker {
|
||||
invalidate(): void;
|
||||
invalidated: boolean;
|
||||
onInvalidate(callback: Function): void;
|
||||
onStop(callback: Function): void;
|
||||
stop(): void;
|
||||
stopped: boolean;
|
||||
}
|
||||
@@ -656,6 +747,7 @@ declare module HTTP {
|
||||
timeout?: number;
|
||||
followRedirects?: boolean;
|
||||
npmRequestOptions?: Object;
|
||||
beforeSend?: Function;
|
||||
}, asyncCallback?: Function): HTTP.HTTPResponse;
|
||||
function del(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
|
||||
function get(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse;
|
||||
@@ -675,6 +767,7 @@ declare module Email {
|
||||
html?: string;
|
||||
headers?: Object;
|
||||
attachments?: Object[];
|
||||
mailComposer?: MailComposer;
|
||||
}): void;
|
||||
}
|
||||
|
||||
@@ -684,30 +777,30 @@ interface CompileStepStatic {
|
||||
}
|
||||
interface CompileStep {
|
||||
addAsset(options: {
|
||||
}, path: string, data: any /** Buffer **/ | string): any; /** TODO: add return value **/
|
||||
}, path: string, data: any /** Buffer **/ | string): any;
|
||||
addHtml(options: {
|
||||
section?: string;
|
||||
data?: string;
|
||||
}): any; /** TODO: add return value **/
|
||||
}): any;
|
||||
addJavaScript(options: {
|
||||
path?: string;
|
||||
data?: string;
|
||||
sourcePath?: string;
|
||||
}): any; /** TODO: add return value **/
|
||||
}): any;
|
||||
addStylesheet(options: {
|
||||
}, path: string, data: string, sourceMap: string): any; /** TODO: add return value **/
|
||||
arch: any; /** TODO: add return value **/
|
||||
declaredExports: any; /** TODO: add return value **/
|
||||
}, path: string, data: string, sourceMap: string): any;
|
||||
arch: any;
|
||||
declaredExports: any;
|
||||
error(options: {
|
||||
}, message: string, sourcePath?: string, line?: number, func?: string): any; /** TODO: add return value **/
|
||||
fileOptions: any; /** TODO: add return value **/
|
||||
fullInputPath: any; /** TODO: add return value **/
|
||||
inputPath: any; /** TODO: add return value **/
|
||||
inputSize: any; /** TODO: add return value **/
|
||||
packageName: any; /** TODO: add return value **/
|
||||
pathForSourceMap: any; /** TODO: add return value **/
|
||||
}, message: string, sourcePath?: string, line?: number, func?: string): any;
|
||||
fileOptions: any;
|
||||
fullInputPath: any;
|
||||
inputPath: any;
|
||||
inputSize: any;
|
||||
packageName: any;
|
||||
pathForSourceMap: any;
|
||||
read(n?: number): any;
|
||||
rootOutputPath: any; /** TODO: add return value **/
|
||||
rootOutputPath: any;
|
||||
}
|
||||
|
||||
declare var PackageAPI: PackageAPIStatic;
|
||||
@@ -715,10 +808,13 @@ interface PackageAPIStatic {
|
||||
new(): PackageAPI;
|
||||
}
|
||||
interface PackageAPI {
|
||||
addFiles(filename: string | string[], architecture?: string): void;
|
||||
export(exportedObject: string, architecture?: string): void;
|
||||
imply(packageSpecs: string | string[]): void;
|
||||
use(packageNames: string | string[], architecture?: string, options?: {
|
||||
addAssets(filenames: string | string[], architecture: string | string[]); /** TODO: add return value **/
|
||||
addFiles(filenames: string | string[], architecture?: string | string[], options?: {
|
||||
bare?: boolean;
|
||||
}): void;
|
||||
export(exportedObjects: string | string[], architecture?: string | string[], exportOptions?: Object, testOnly?: boolean): void;
|
||||
imply(packageNames: string | string[], architecture?: string | string[]): void;
|
||||
use(packageNames: string | string[], architecture?: string | string[], options?: {
|
||||
weak?: boolean;
|
||||
unordered?: boolean;
|
||||
}): void;
|
||||
@@ -768,7 +864,7 @@ interface TemplateStatic {
|
||||
interface Template {
|
||||
created: Function;
|
||||
destroyed: Function;
|
||||
events(eventMap: {[actions: string]: Function}): void;
|
||||
events(eventMap: Meteor.EventMap): void;
|
||||
helpers(helpers:{[id:string]: any}): void;
|
||||
onCreated: Function;
|
||||
onDestroyed: Function;
|
||||
@@ -776,6 +872,19 @@ interface Template {
|
||||
rendered: Function;
|
||||
}
|
||||
|
||||
declare function MethodInvocation(options: {
|
||||
}): any; /** TODO: add return value **/
|
||||
declare function check(value: any, pattern: any): void;
|
||||
declare function execFileAsync(command: string, args?: any[], options?: {
|
||||
cwd?: Object;
|
||||
env?: Object;
|
||||
stdio?: any[] | string;
|
||||
destination?: any;
|
||||
waitForClose?: string;
|
||||
}): any;
|
||||
declare function execFileSync(command: string, args?: any[], options?: {
|
||||
cwd?: Object;
|
||||
env?: Object;
|
||||
stdio?: any[] | string;
|
||||
destination?: any;
|
||||
waitForClose?: string;
|
||||
}): String;
|
||||
declare function getExtension(): String;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
Reference in New Issue
Block a user