Update Meteor type definitions v1.4

This commit is contained in:
Birk Skyum
2017-03-07 12:47:22 +01:00
parent ac8fb9a68d
commit 1eae9816b7
3 changed files with 2133 additions and 850 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
# Meteor Type Definitions [DEPRECATED]
# Meteor Type Definitions
## Deprecated
@@ -9,7 +9,7 @@ The canonical TypeScript definitions for Meteor can now be found using the NPM [
## Description
These are the definitions for version 1.3 of Meteor. These definitions were generated from the from the same [Meteor data.js file] (https://github.com/meteor/meteor/blob/devel/docs/client/data.js) that is used to generate the official [Meteor docs] (http://docs.meteor.com/). The code that generates these definitions can be found [here](https://github.com/meteor-typescript/meteor-typescript-libs/).
These are the definitions for version 1.4 of Meteor. These definitions were generated from the from the same [Meteor data.js file] (https://github.com/meteor/meteor/blob/devel/docs/client/data.js) that is used to generate the official [Meteor docs] (http://docs.meteor.com/). The code that generates these definitions can be found [here](https://github.com/meteor-typescript/meteor-typescript-libs/).
## Upcoming Meteor `typescript` package
+2061 -833
View File
File diff suppressed because it is too large Load Diff
+70 -15
View File
@@ -6,6 +6,19 @@
/*********************************** Begin setup for tests ******************************/
import {Mongo} from "meteor/mongo";
import {Meteor} from "meteor/meteor";
import {check, Match} from "meteor/check";
import {Tracker} from "meteor/tracker";
import {Template} from "meteor/templating";
import {Blaze} from "meteor/blaze";
import {Session} from "meteor/session";
import {HTTP} from "meteor/http";
import {ReactiveVar} from "meteor/reactive-var";
import {Accounts} from "meteor/accounts-base";
import {BrowserPolicy} from "meteor/browser-policy-common";
import {DDPRateLimiter} from "meteor/ddp-rate-limiter";
var Rooms = new Mongo.Collection('rooms');
var Messages = new Mongo.Collection('messages');
interface MonkeyDAO {
@@ -60,10 +73,8 @@ Meteor.publish("counts-by-room", function (roomId: string) {
var handle = Messages.find({roomId: roomId}).observeChanges({
added: function (id: any) {
count++;
// if (!initializing)
// Todo: Not sure how to define in typescript
// self.changed("counts", roomId, {count: count});
// if (!initializing)
// this.changed("counts", roomId, {count: count});
},
removed: function (id: any) {
count--;
@@ -89,6 +100,9 @@ Tracker.autorun(function () {
Meteor.subscribe("counts-by-room", Session.get("roomId"));
});
// Checking status
let status: DDP.Status = 'connected';
console.log("Current room has " +
Counts.find(Session.get("roomId")).count +
" messages.");
@@ -339,6 +353,8 @@ var handle = query.observeChanges({
}
});
let cursor: Mongo.Cursor<Object>;
// After five seconds, stop keeping the count.
setTimeout(function () {handle.stop();}, 5000);
@@ -452,20 +468,21 @@ Template['adminDashboard'].helpers({
return Session.get("foo");
}
});
Template['newTemplate'].helpers({
helperName: function () {
}
});
Template['newTemplate'].created = function () {
Template['newTemplate'].created = function() {
};
Template['newTemplate'].rendered = function () {
Template['newTemplate'].rendered = function() {
};
Template['newTemplate'].destroyed = function () {
Template['newTemplate'].destroyed = function() {
};
@@ -603,8 +620,9 @@ Meteor.call('sendEmail',
'Hello from Meteor!',
'This is a test of Email.send.');
var testTemplate = new Blaze.Template();
var testView = new Blaze.View();
var testTemplate = new Blaze.Template('foo');
var testView = new Blaze.View('foo');
Blaze.Template.instance();
declare var el: HTMLElement;
Blaze.render(testTemplate, el);
@@ -632,15 +650,14 @@ Accounts.onPageLoadLogin(function() {
});
// Covers this PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/8065
var loginOpts: Meteor.LoginWithExternalServiceOptions = {
var loginOpts = <Meteor.LoginWithExternalServiceOptions> {
requestPermissions: ["a", "b"],
requestOfflineToken: true,
loginUrlParameters: {asdf: 1, qwer: "1234"},
loginHint: "Help me",
loginStyle: "Bold and powerful",
redirectUrl: "popup",
profile: "asdfasdf",
email: "asdf@ASDf.com"
profile: "asdfasdf"
};
Meteor.loginWithMeteorDeveloperAccount(loginOpts, function(error: Meteor.Error) {});
@@ -648,16 +665,16 @@ Accounts.emailTemplates.siteName = "AwesomeSite";
Accounts.emailTemplates.from = "AwesomeSite Admin <accounts@example.com>";
Accounts.emailTemplates.headers = { asdf: 'asdf', qwer: 'qwer' };
Accounts.emailTemplates.enrollAccount.subject = function (user: Meteor.User) {
Accounts.emailTemplates.enrollAccount.subject = function(user: Meteor.User) {
return "Welcome to Awesome Town, " + user.profile.name;
};
Accounts.emailTemplates.enrollAccount.html = function (user: Meteor.User, url: string) {
Accounts.emailTemplates.enrollAccount.html = function(user: Meteor.User, url: string) {
return "<h1>Some html here</h1>";
};
Accounts.emailTemplates.enrollAccount.from = function() {
return "asdf@asdf.com";
};
Accounts.emailTemplates.enrollAccount.text = function (user: Meteor.User, url: string) {
Accounts.emailTemplates.enrollAccount.text = function(user: Meteor.User, url: string) {
return "You have been selected to participate in building a better future!"
+ " To activate your account, simply click the link below:\n\n"
+ url;
@@ -674,3 +691,41 @@ var handle = Accounts.validateLoginAttempt(function(attemptInfoObject: Accounts.
return true;
});
handle.stop();
// Covers https://github.com/meteor-typings/meteor/issues/8
const publicSetting = Meteor.settings.public['somePublicSetting'];
const deeperPublicSetting = Meteor.settings.public['somePublicSetting']['deeperSetting'];
const privateSetting = Meteor.settings['somePrivateSetting'];
const deeperPrivateSetting = Meteor.settings['somePrivateSettings']['deeperSetting'];
// Covers https://github.com/meteor-typings/meteor/issues/9
const username = (<HTMLInputElement> Template.instance().find('#username')).value;
// Covers https://github.com/meteor-typings/meteor/issues/3
BrowserPolicy.framing.disallow();
BrowserPolicy.content.allowEval();
// Covers https://github.com/meteor-typings/meteor/issues/18
if (Meteor.isDevelopment) {
Rooms._dropIndex({field: 1});
}
// Covers https://github.com/meteor-typings/meteor/issues/20
Rooms.find().count(true);
// Covers https://github.com/meteor-typings/meteor/issues/21
if (Meteor.isTest) {
// do something
}
DDPRateLimiter.addRule({ userId: 'foo' }, 5, 1000);
DDPRateLimiter.addRule((userId: string) => userId =='foo', 5, 1000);
Template.instance().autorun(() => {}).stop();