diff --git a/meteor/meteor-tests.ts b/meteor/meteor-tests.ts
index ca1973f63..bb7928b1e 100644
--- a/meteor/meteor-tests.ts
+++ b/meteor/meteor-tests.ts
@@ -1,4 +1,4 @@
-///
+///
/**
* All code below was copied from the examples at http://docs.meteor.com/.
@@ -10,16 +10,17 @@
/*********************************** Begin setup for tests ******************************/
// A developer must declare a var Template like this in a separate file to use this TypeScript type definition file
-interface ITemplate {
- adminDashboard: IMeteorViewModel;
- chat: IMeteorViewModel;
-}
-declare var Template: ITemplate;
+//interface ITemplate {
+// adminDashboard: Meteor.Template;
+// chat: Meteor.Template;
+//}
+//declare var Template: ITemplate;
var Rooms = new Meteor.Collection('rooms');
var Messages = new Meteor.Collection('messages');
var Monkeys = new Meteor.Collection('monkeys');
+var check = function(str1, str2) {};
/********************************** End setup for tests *********************************/
@@ -203,7 +204,7 @@ Items.insert({list: groceriesId, name: "Persimmons"});
*/
var Players = new Meteor.Collection('Players');
-Template.adminDashboard.events({
+Template['adminDashboard'].events({
'click .givePoints': function () {
Players.update(Session.get("currentPlayer"), {$inc: {score: 5}});
}
@@ -223,7 +224,7 @@ Meteor.methods({
/**
* From Collections, collection.remove section
*/
-Template.chat.events({
+Template['chat'].events({
'click .remove': function () {
Messages.remove(this._id);
}
@@ -282,16 +283,6 @@ topPosts.forEach(function (post) {
count += 1;
});
-/**
- * From Collections, cursor.count section
- */
-var frag = Meteor.render(function () {
- var highScoring = Posts.find({score: {$gt: 10}});
- return "
There are " + highScoring.count() + " posts with " +
- "scores greater than 10
";
-});
-document.body.appendChild(frag);
-
/**
* From Collections, cursor.observeChanges section
*/
@@ -328,12 +319,6 @@ Session.set("currentRoomId", "home");
/**
* From Sessions, Session.get section
*/
-Session.set("enemy", "Eastasia");
-var frag1 = Meteor.render(function () {
- return "We've always been at war with " +
- Session.get("enemy") + "
";
-});
-
// Page will say "We've always been at war with Eastasia"
// DA: commented out since transpiler didn't like append()
@@ -362,15 +347,6 @@ Meteor.users.deny({update: function () { return true; }});
/**
* From Accounts, Meteor.loginWithExternalService section
*/
-Accounts.loginServiceConfiguration.remove({
- service: "weibo"
-});
-Accounts.loginServiceConfiguration.insert({
- service: "weibo",
- clientId: "1292962797",
- secret: "75a730b58f5691de5522789070c319bc"
-});
-
Meteor.loginWithGithub({
requestPermissions: ['user', 'public_repo']
}, function (err) {
@@ -434,52 +410,12 @@ Accounts.emailTemplates.enrollAccount.text = function (user, url) {
/**
* From Templates, Template.myTemplate.helpers section
*/
-Template.adminDashboard.helpers({
+Template['adminDashboard'].helpers({
foo: function () {
return Session.get("foo");
}
});
-/**
- * From Templates, Template.myTemplate.preserve
- */
-Template.adminDashboard.preserve({
- 'input[id]': function (node) { return node.id; }
-});
-
-/**
- * From Templates, Meteor.render section
- */
-var frag2 = Meteor.render(function () {
- return "There are " + Players.find({online: true}).count() +
- " players online.
";
-});
-document.body.appendChild(frag2);
-
-Players.update({idleTime: {$gt: 30}}, {$set: {online: false}});
-
-/**
- * From Templates, Meteor.renderList section
- */
-var frag3 = Meteor.renderList(
- Posts.find({tags: "frontpage"}),
- function(post) {
- var style = Session.equals("selectedId", post._id) ? "selected" : "";
- // A real app would need to quote/sanitize post.name
- return '' + post.name + '
';
- });
-document.body.appendChild(frag3);
-
-var somePost = Posts.findOne({tags: "frontpage"});
-Session.set("selectedId", somePost._id);
-
-var eventTester = {
- 'click p': function (event: IMeteorEvent) {
- var paragraph = event.currentTarget; // always a P
- var clickedElement = event.target; // could be the P or a child element
- }
-}
-
/**
* From Match section
*/
diff --git a/meteor/meteor.d.ts b/meteor/meteor.d.ts
index a321dc00e..b1611f51a 100644
--- a/meteor/meteor.d.ts
+++ b/meteor/meteor.d.ts
@@ -1,604 +1,545 @@
-// Type definitions for Meteor 0.6.5
-// Project: http://www.meteor.com/
-// Definitions by: Dave Allen
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-
-interface IMeteor {
-
- /********
- * Core *
- ********/
- isClient: boolean;
- isServer: boolean;
- startup(func: Function): void;
- absoluteUrl(path: string,
- options: {
- secure?: boolean;
- replaceLocalhost?: boolean;
- rootUrl?: string;
- }): void;
- settings: Object;
- release: string;
-
-
- /*************************
- * Publish and Subscribe *
- *************************/
-
- /**
- * Publish a record set.
- *
- * @param name Name of the attribute set. If null, the set has no name, and the record set is
- * automatically sent to all connected clients.
- * @param func Function called on the server each time a client subscribes. Inside the function,
- * this is the publish handler object, described below. If the client passed arguments
- * to subscribe, the function is called with the same arguments.
- */
- publish(name: string, func: Function): any;
- //Todo: Figure out a way to define this.userId, this.added, this.changed, etc that can be called from within publish
-
- /**
- * Subscribe to a record set. Returns a handle that provides stop() and ready() methods.
- *
- * @param name Name of the subscription. Matches name of server's publish() call.
- * @param arg1,arg2,arg3 Optional arguments passed to publisher function on server.
- * @param callbacks Optional. May include onError and onReady callbacks. Can be Object or Function. If a function
- * is passed instead of an object, it is interpreted as an onReady callback.
- */
- subscribe(name: string, arg1?: any, arg2?: any, ars3?: any, arg4?: any, callbacks?: Object): IMeteorHandle;
-
-
- /***********
- * Methods *
- ***********/
- methods(methods: Object): void;
- Error(error: number, reason?: string, details?: string): void;
- // DA: Really should be defined like this: call(name: string, ...args?: any[], asyncCallback?: Function): void;
- // But typescript does not allow Rest parameter (..args) to not be the last parameter defined
- call(name: string, param1?: Object, param2?: Object, param3?: Object, param4?: Object, asyncCallback?: Function): void;
- apply(name: string, options: any[], asyncCallback?: Function): void;
- defer(callback: Function): void;
-
-
- /*********************
- * ServerConnections *
- *********************/
- status(): {
- connected: boolean;
- status: string;
- retryCount: number;
- retryTime: number;
- reason: string;
- };
- reconnect(): void;
- disconnect(): void;
-
-
- /***************
- * Collections *
- ***************/
- Collection(name: string,
- options?: {
- connection?: Object;
- idGeneration?: string;
- transform?: Function;
- }): void;
-
-
- /************
- * Accounts *
- ************/
- user(): IMeteorUser;
- userId(): string;
- users: IMeteorUserCollection;
- loggingIn(): boolean;
- logout(callback?: Function): void;
- loginWithPassword(user: Object, password: string, callback?: Function): void;
- loginWithExternalService(options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: boolean;
- },
- callback?: Function): void;
- loginWithFacebook(options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: boolean;
- },
- callback?: Function): void;
- loginWithGithub(options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: boolean;
- },
- callback?: Function): void;
- loginWithGoogle(options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: boolean;
- },
- callback?: Function): void;
- loginWithMeetup(options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: boolean;
- },
- callback?: Function): void;
- loginWithTwitter(options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: boolean;
- },
- callback?: Function): void;
- loginWithWeibo(options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: boolean;
- },
- callback?: Function): void;
-
- /*************
- * Templates *
- *************/
- render(htmlFunc: Function): DocumentFragment;
- renderList(observable: IMeteorCursor, docFunc: Function, elseFunc?: Function): DocumentFragment;
-
- /**********
- * Timers *
- **********/
- setTimeout(func: Function, delay: number): void;
- setInterval(func: Function, delay: number): void;
- clearTimeout(id: number): void;
- clearInterval(id: number): void;
-
-
- /******************** Begin definitions for contributed packages from Atmosphere (or elsewhere) *******************/
-
- /**************************************************
- * For Paginated-Subscription contributed package *
- **************************************************/
- subscribeWithPagination(collection: string, limit: number): IMeteorHandle;
- Template(): void;
-
- /*************************************************
- * For Router or Iron-Router contributed package *
- *************************************************/
- Router: IMeteorRouter;
-
- /*********************************
- * For Error contributed package *
- *********************************/
- Errors: IMeteorErrors;
-
- /******************** End definitions for contributed packages from Atmosphere (or elsewhere) *********************/
-
-} // End Meteor.someFunction definitions
-
-
-/***************
- * Collections *
- ***************/
-interface IMeteorCollection {
- find(selector?, options?: Object): IMeteorCursor;
- findOne(selector, options?: Object): any;
- insert(doc: Object, callback?: Function): string;
- update(selector, modifier, options?: Object, callback?: Function): void;
- remove(selector, callback?: Function): void;
- allow(options: Object): boolean;
- deny(options: Object): boolean;
- ObjectID(hexString?: string): Object;
-}
-
-interface IMeteorCursor {
- forEach(callback: Function): void;
- map(callback: Function): void;
- fetch(): any[];
- count(): number;
- rewind(): void;
- observe(callbacks: Object): void;
- observeChanges(callbacks: Object): void;
-}
-
-
-/*************
- * Templates *
- *************/
-
/**
- * To use Meteor's Template.templateName.function, you must define an interface in a separate file with
- * extension ".d.ts". Within the interface, every template name must have a property by that name that
- * is of type IMeteorViewModel or IMeteorManager (choose either depending on your philosophical
- * preference -- both work the same)
- * e.g. file ".../client/views/view-model-types.d.ts":
*
- * interface ITemplate {
- * postsList: IMeteorViewModel;
- * comment: IMeteorViewModel;
- * notifications: IMeteorViewModel;
- * [your template name]: IMeteorViewModel;
- * }
- * declare var Template: ITemplate;
+ * Meteor definitions for TypeScript
+ * author - Olivier Refalo - orefalo@yahoo.com
+ * author - David Allen - dave@fullflavedave.com
+ *
+ * Thanks to Sam Hatoum for the base code for auto-generating this file
+ *
+ * supports Meteor 0.8.3
+ *
*/
-interface IMeteorViewModel {
- rendered(callback: Function): void;
- created(callback: Function): void;
- destroyed(callback: Function): void;
- events(eventMap: {[eventName: string]: Function;}): void;
- helpers(helpers: Object): void;
- preserve(selector: Object): void;
-}
-interface IMeteorManager {
- rendered(callback: Function): void;
- created(callback: Function): void;
- destroyed(callback: Function): void;
- events(eventMap: {[eventType: string]: Function;}): void;
- helpers(helpers: Object): any;
- preserve(selector: Object): void;
-}
-
-// DA: Currently not used, but I'd like to figure out a way to define the function signature
-// for teh callbacks in IMeteorViewModel, IMeteorManager, and many other interfaces
-interface IMeteorEvent {
- type?: MeteorEventType.Value;
- target?: Element;
- currentTarget?: Element;
- which?: number;
- stopPropogation(): void;
- stopImmediatePropogation(): void;
- preventDefault(): void;
- isPropogationStopped(): boolean;
- isImmediatePropogationStopped(): boolean;
- isDefaultPrevented(): boolean;
-}
-
-declare module MeteorEventType {
- export enum Value {'click', 'dblclick', 'focus', 'blur', 'change',
- 'mouseenter', 'mouseleave', 'mousedown', 'mouseup', 'keydown', 'keypress', 'keyup', 'tap'}
-}
-
-/***********
- * Session *
- ***********/
-interface IMeteorSession {
- set(key: string, value: Object): void;
- setDefault(key: string, value: Object): void;
- get(key: string): Object;
- equals(key: string, value: any): void;
-}
-
-interface IMeteorHandle {
- loaded(): number;
- limit(): number;
- ready(): boolean;
- loadNextPage(): void;
-}
-
-/**************************
- * Accounts and Passwords *
- **************************/
-interface IMeteorUser {
- _id?: string;
- username?: string;
- emails?: {
- address: string;
- verified: boolean;
- };
- profile?: any;
- services?: any;
- createdAt?: number;
-}
-
-interface IMeteorUserCollection {
- find(selector?, options?: Object): IMeteorCursor;
- findOne(selector, options?: Object): IMeteorUser;
- insert(doc: IMeteorUser, callback?: Function): IMeteorUser;
- update(selector, modifier, options?: Object, callback?: Function): void;
- remove(selector, callback?: Function): void;
- allow(options: Object): boolean;
- deny(options: Object): boolean;
- ObjectID(hexString?: string): Object;
-}
-
-interface IMeteorAccounts {
- config(options: {
- sendVerificationEmail?: boolean;
- forbidClientAccountCreation?: boolean;
- }): void;
- ui: {
- config(options: {
- requestPermissions?: Object;
- requestOfflineToken?: Object;
- passwordSignupFields?: string;
- });
- };
- validateNewUser(func: Function): void;
- onCreateUser(func: Function): void;
- createUser(options: {
- username?: string;
- email?: string;
- password?: string;
- profile?: string;
- },
- callback?: Function): void;
- changePassword(oldPassword: string, newPassword: string, callback?: Function): void;
- forgotPassword(options: {
- email: string;
- },
- callback?: Function): void;
- resetPassword(token: string, newPassword: string, callback?: Function): void;
- setPassword(userId: string, newPassword: string): void;
- verifyEmail(token: string, callback?: Function): void;
- sendResetPasswordEmail(userId: string, email?: string): void;
- sendEnrollmentEmail(userId: string, email?: string): void;
- sendVerificationEmail(userId: string, email?: string): void;
- emailTemplates: {
- from: string;
- siteName: string;
- resetPassword: IMeteorEmailValues;
- enrollAccount: IMeteorEmailValues;
- verifyEmail: IMeteorEmailValues;
- };
- // DA: I didn't see the signature for this, but it appears in the examples
- loginServiceConfiguration: {
- remove(options: Object): void;
- insert(options: Object): void;
- };
-}
-
-interface IMeteorEmailValues {
- subject?: Function;
- text?: Function;
-}
-
-interface IMeteorMatch {
- test(value: any, pattern: any): boolean;
- Any;
- String;
- Number;
- Boolean;
- undefined;
- null;
- Integer;
- ObjectIncluding;
- Object;
- Optional(pattern: string);
- OneOf(...args: string[]);
- Where(condition: boolean);
-}
-
-interface IExternalServiceParams {
- options?: {
- requestPermissions?: string[];
- requestOfflineToken?: boolean;
- forceApprovalPrompt?: boolean;
- };
- callback?: Function;
-}
-
-/********
- * Deps *
- ********/
-interface IMeteorDeps {
- autorun(runFunc: Function): IMeteorComputationObject;
- flush(): void;
- nonreactive(func: Function): void;
- active: boolean;
- currentComputation: IMeteorComputationObject;
- onInvalidate(callback: Function): void;
- afterFlush(callback: Function): void;
-
- /**
- * @constructor
- */
- Computation(): void;
-
- /**
- * @constructor
- */
- Dependency(): void;
-}
-
-interface IMeteorComputationObject {
- stop(): void;
- invalidate(): void;
- onInvalidate(callback: Function): void;
- stopped: boolean;
- invalidated: boolean;
- firstRun: boolean;
-}
-
-interface IMeteorDependencyObject {
- changed(): void;
- depend(fromComputation?: IMeteorComputationObject): boolean;
- hasDependents(): boolean;
-}
-
-/*********
- * EJSON *
- *********/
-interface IMeteorEJSON {
- parse(str: string): void;
- stringify(val: any): string;
- fromJSONValue(val): any;
- toJSONValue(val): JSON;
- equals(any: any): boolean;
- clone(val: any): any;
- newBinary(size: number): void;
- isBinary(x: any): boolean;
- addType(name: string, factory: Function): void;
-}
-
-/****************
- * HTTP package *
- ****************/
-interface IMeteorHTTP {
- call(method: string, url: string, options: {
- content?: string;
- data?: Object;
- query?: string;
- params?: Object;
- auth?: string;
- headers?: Object;
- timeout?: number;
- followRedirects?: boolean;
- }, asyncCallback?: Function): IMeteorHTTPResult;
- get(url: string, options?: {
- content?: string;
- data?: Object;
- query?: string;
- params?: Object;
- auth?: string;
- headers?: Object;
- timeout?: number;
- followRedirects?: boolean;
- }, asyncCallback?: Function): IMeteorHTTPResult;
- post(url: string, options?: {
- content?: string;
- data?: Object;
- query?: string;
- params?: Object;
- auth?: string;
- headers?: Object;
- timeout?: number;
- followRedirects?: boolean;
- }, asyncCallback?: Function): IMeteorHTTPResult;
- put(url: string, options?: {
- content?: string;
- data?: Object;
- query?: string;
- params?: Object;
- auth?: string;
- headers?: Object;
- timeout?: number;
- followRedirects?: boolean;
- }, asyncCallback?: Function): IMeteorHTTPResult;
- del(url: string, options?: {
- content?: string;
- data?: Object;
- query?: string;
- params?: Object;
- auth?: string;
- headers?: Object;
- timeout?: number;
- followRedirects?: boolean;
- }, asyncCallback?: Function): IMeteorHTTPResult;
-}
-
-// DA: Currently not used
-// I would like to figure out a way to specify this as type for options for IMeteorHTTP methods.
-// Tests don't work if I simply specify this interface as the type.
-interface IMeteorHTTPCallOptions {
- content?: string;
- data?: Object;
- query?: string;
- params?: Object;
- auth?: string;
- headers?: Object;
- timeout?: number;
- followRedirects?: boolean;
-}
-
-interface IMeteorHTTPResult {
- statusCode: number;
- content: string;
- data?: JSON;
- headers: Object;
-}
-
-/*********
- * Email *
- *********/
-interface IMeteorEmail {
- send(options: {
- from?: string;
- to: any;
- cc?: any;
- bcc?: any;
- replyTo?: any;
- subject?: string;
- text?: string;
- html?: string;
- headers?: Object;
- }): void;
-}
-
-
-/**********
- * Assets *
- **********/
-interface IMeteorAssets {
- getText(assetPath: string, asyncCallback?: Function): string;
- getBinary(assetPath: string, asyncCallback?: Function): any;
-}
-
-/*******
- * DPP *
- *******/
-interface IMeteorDPP {
- connect(url: string): void;
-}
-
-declare var Meteor: IMeteor;
-declare var Collection: IMeteorCollection;
-declare var Session: IMeteorSession;
-declare var Deps: IMeteorDeps;
-declare var Accounts: IMeteorAccounts;
-declare var Match: IMeteorMatch;
-declare function check(value: any, pattern: any): void;
-declare var Computation: IMeteorComputationObject;
-declare var Dependency: IMeteorDependencyObject;
-declare var EJSON: IMeteorEJSON;
-declare var HTTP: IMeteorHTTP;
-declare var Email: IMeteorEmail;
-declare var Assets: IMeteorAssets;
-declare var DPP: IMeteorDPP;
-
-declare function changed(collection: string, id: string, fields, Object): void;
-
-/******************** Begin definitions for contributed packages from Atmosphere (or elsewhere) *********************/
-
-/***************************************************
- * For Router and Iron-Router contributed packages *
- ***************************************************/
-interface IMeteorRouter {
-
- // These are for Router
- page(): void;
- add(route: Object): void;
- to(path: string, ...args: any[]): void;
- filters(filtersMap: Object);
- filter(filterName: string, options?: Object);
-
- // These are for Iron-Router
- map(routeMap: Function): void;
- path(route: string, params?: Object): void;
- url(route: string): void;
- routes: Object;
- configure(options: IMeteorRouterConfig): void;
-}
-
-// For Iron-Router
-interface IMeteorRouterConfig {
- layout: string;
- notFoundTemplate: string;
- loadingTemplate: string;
- renderTemplates: Object;
-}
-
-interface IMeteorErrors {
- throw(message: string): void;
- clear(): void;
-}
-
-// For Router and Iron-Router contributed packages
-declare var Router: IMeteorRouter;
-
-/******************** End definitions for contributed packages from Atmosphere (or elsewhere) ***********************/
+///
/**
- * Todo:
- * Define "this.function" functions.
- * Define the signatures of callback functions and other functions.
- ***/
+ * These are the modules and interfaces that can't be automatically generated from the Meteor api.js file
+ */
+declare module Meteor {
+ interface EJSONObject extends Object {}
+
+ interface LoginWithExternalServiceOptions {
+ requestPermissions?: string[];
+ requestOfflineToken?: Boolean;
+ forceApprovalPrompt?: Boolean;
+ userEmail?: 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;
+ }
+
+ interface User {
+ _id?:string;
+ username?:string;
+ emails?:Meteor.UserEmail[];
+ createdAt?: number;
+ profile?: any;
+ services?: any;
+ }
+
+ interface SubscriptionHandle {
+ stop(): void;
+ ready(): boolean;
+ }
+
+ interface CollectionFieldSpecifier {
+ [id: string]: Number;
+ }
+
+ interface TemplateBase {
+ [templateName: string]: Meteor.Template;
+ }
+
+ interface RenderedTemplate extends Object {}
+
+ interface DataContext extends Object {}
+
+ enum CollectionIdGenerationEnum {
+ STRING,
+ MONGO
+ }
+
+ interface CollectionOptions {
+ connection: Object;
+ idGeneration: Meteor.CollectionIdGenerationEnum;
+ transform?: (document)=>any;
+ }
+
+ function Collection(name:string, options?:Meteor.CollectionOptions) : void;
+
+ interface Tinytest {
+ add(name:string, func:Function);
+ addAsync(name:string, func:Function);
+ }
+
+ enum StatusEnum {
+ connected,
+ connecting,
+ failed,
+ waiting,
+ offline
+ }
+
+ interface LiveQueryHandle {
+ stop(): void;
+ }
+
+ interface EmailFields {
+ subject?: Function;
+ text?: Function;
+ }
+
+ interface EmailTemplates {
+ from: string;
+ siteName: string;
+ resetPassword: Meteor.EmailFields;
+ enrollAccount: Meteor.EmailFields;
+ verifyEmail: Meteor.EmailFields;
+ }
+
+ interface AccountsBase {
+ EmailTemplates: {
+ from: string;
+ siteName: string;
+ resetPassword: Meteor.EmailFields;
+ enrollAccount: Meteor.EmailFields;
+ verifyEmail: Meteor.EmailFields;
+ }
+ loginServicesConfigured(): boolean;
+ }
+
+ interface MatchBase {
+ Any;
+ String;
+ Integer;
+ Boolean;
+ undefined;
+ null;
+ Object;
+ Optional(pattern):boolean;
+ ObjectIncluding(dico):boolean;
+ OneOf(...patterns);
+ Where(condition);
+ }
+
+ interface AllowDenyOptions {
+ insert?: (userId:string, doc) => boolean;
+ update?: (userId, doc, fieldNames, modifier) => boolean;
+ remove?: (userId, doc) => boolean;
+ fetch?: string[];
+ transform?: Function;
+ }
+
+ interface Error {
+ error: number;
+ reason?: string;
+ details?: string;
+ }
+}
+
+declare module Deps {
+ function Computation(): void;
+ function Dependency(): void;
+}
+
+declare module Package {
+ function describe(metadata:PackageDescribeAPI);
+ function on_use(func:{(api:Api, where?:string[]):void});
+ function on_use(func:{(api:Api, where?:string):void});
+ function on_test(func:{(api:Api):void}) ;
+ function register_extension(extension:string, options:PackageRegisterExtensionOptions);
+ interface PackageRegisterExtensionOptions {(bundle:Bundle, source_path:string, serve_path:string, where?:string[]):void}
+ interface PackageDescribeAPI {
+ summary: string;
+ }
+ interface Api {
+ export(variable:string);
+ export(variables:string[]);
+ use(deps:string, where?:string[]);
+ use(deps:string, where?:string);
+ use(deps:string[], where?:string[]);
+ use(deps:string[], where?:string);
+ add_files(file:string, where?:string[]);
+ add_files(file:string, where?:string);
+ add_files(file:string[], where?:string[]);
+ add_files(file:string[], where?:string);
+ imply(package:string);
+ imply(packages:string[]);
+ }
+ interface BundleOptions {
+ type: string;
+ path: string;
+ data: any;
+ where: string[];
+ }
+ interface Bundle {
+ add_resource(options:BundleOptions);
+ error(diagnostics:string);
+ }
+}
+
+declare module Npm {
+ function require(module:string);
+ function depends(dependencies:{[id:string]:string});
+}
+
+declare module HTTP {
+ enum HTTPMethodEnum {
+ GET,
+ POST,
+ PUT,
+ DELETE
+ }
+
+ interface HTTPRequest {
+ content?:string;
+ data?:any;
+ query?:string;
+ params?:{[id:string]:string};
+ auth?:string;
+ headers?:{[id:string]:string};
+ timeout?:number;
+ followRedirects?:boolean;
+ }
+
+ interface HTTPResponse {
+ statusCode:number;
+ content:string;
+ // response is not always json
+ data:any;
+ headers:{[id:string]:string};
+ }
+}
+
+declare module Email {
+ interface EmailMessage {
+ from: string;
+ to: any; // string or string[]
+ cc?: any; // string or string[]
+ bcc?: any; // string or string[]
+ replyTo?: any; // string or string[]
+ subject: string;
+ text?: string;
+ html?: string;
+ headers?: {[id: string]: string};
+ }
+}
+
+declare module DDP {
+ interface DDPStatic {
+ subscribe(name, ...rest);
+ call(method:string, ...parameters):void;
+ apply(method:string, ...parameters):void;
+ methods(IMeteorMethodsDictionary);
+ status():DDPStatus;
+ reconnect();
+ disconnect();
+ onReconnect();
+ }
+
+ 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 {
+ function fraction():number;
+ function hexString(numberOfDigits:number):string; // @param numberOfDigits, @returns a random hex string of the given length
+ function choice(array:any[]):string; // @param array, @return a random element in array
+ function choice(str:string):string; // @param str, @return a random char in str
+}
+
+/**
+ * These modules and interfaces are automatically generated from the Meteor api.js file
+ */
+declare module Meteor {
+ var isClient: boolean;
+ var isServer: boolean;
+ function startup(func: Function): void;
+ function absoluteUrl(path?, options?: {
+ secure?: Boolean;
+ replaceLocalhost?: Boolean;
+ rootUrl?: string;
+ }): string;
+ var settings: {[id:string]: any};
+ var release: string;
+ function publish(name: string, func: Function): void;
+ function subscribe(name, ...args): SubscriptionHandle;
+ function methods(methods: Object): void;
+ function Error(error, reason?, details?): void;
+ function call(name: string, ...params): void;
+ function apply(name: string, params, options?: {
+ wait?: Boolean;
+ onResultReceived?: Function;
+ }, asyncCallback?): void;
+ function status(): Meteor.StatusEnum;
+ function reconnect(): void;
+ function disconnect(): void;
+ function onConnection(callback: Function): void;
+ function Collection(name: string, options?: {
+ connection?: Object;
+ idGeneration?: string;
+ transform?: Function;
+ }): void;
+ function user(): Meteor.User;
+ function userId(): string;
+ var users: Meteor.Collection;
+ function loggingIn(): boolean;
+ function logout(callback?: Function): void;
+ function logoutOtherClients(callback?: Function): void;
+ function loginWithPassword(user: any, password: string, callback?: Function): void;
+ function loginWithExternalService(options?: {
+ requestPermissions?: string[];
+ requestOfflineToken?: Boolean;
+ forceApprovalPrompt?: Boolean;
+ userEmail?: string;
+ }, callback?: Function): void;
+ function setTimeout(func: Function, delay: Number): number;
+ function setInterval(func: Function, delay: Number): number;
+ function clearTimeout(id: Number): void;
+ function clearInterval(id: Number): void;
+ function EnvironmentVariable(): void;
+ function get(): string;
+ function withValue(value: any, func: Function): void;
+ function bindEnvironment(func: Function, onException: Function, _this: Object): Function;
+}
+
+declare module Meteor {
+ interface EJSON {
+ parse(str: string): EJSON;
+ stringify(val: Meteor.EJSON, options?: {
+ indent?: any; // boolean, integer, or string
+ canonical?: Boolean;
+ }): string;
+ fromJSONValue(val: JSON): any;
+ toJSONValue(val: Meteor.EJSON): JSON;
+ equals(a: Meteor.EJSONObject, b: Meteor.EJSONObject, options?: {
+ keyOrderSensitive?: Boolean;
+ }): boolean;
+ clone(v:T): T;
+ newBinary(size: Number): any;
+ isBinary(): boolean;
+ addType(name: string, factory: Function): void;
+ }
+}
+
+declare module DDP {
+ function connect(url: string): DDP.DDPStatic;
+}
+
+declare module Meteor {
+ interface Collection {
+ find(selector?: any, options?: {
+ sort?: any;
+ skip?: Number;
+ limit?: Number;
+ fields?: Meteor.CollectionFieldSpecifier;
+ reactive?: Boolean;
+ transform?: Function;
+ });
+ findOne(selector?: any, options?: {
+ sort?: any;
+ skip?: Number;
+ fields?: Meteor.CollectionFieldSpecifier;
+ reactive?: Boolean;
+ transform?: Function;
+ });
+ insert(doc: Object, callback?: Function);
+ update(selector: any, modifier: any, options?: {
+ multi?: Boolean;
+ upsert?: Boolean;
+ }, callback?: Function): number;
+ upsert(selector: any, modifier: any, options?: {
+ multi?: Boolean;
+ }, callback?: Function): {numberAffected?: number; insertedId?: string;};
+ remove(selector: any, callback?: Function): void;
+ allow(options: Meteor.AllowDenyOptions): boolean;
+ deny(options: Meteor.AllowDenyOptions): boolean;
+ ObjectID(hexString: string): Object;
+ }
+}
+
+declare module Meteor {
+ interface Cursor {
+ count(): number;
+ fetch(): Array;
+ forEach(callback: Function, thisArg?): void;
+ map(callback: Function, thisArg?): void;
+ observe(callbacks: Object): Meteor.LiveQueryHandle;
+ observeChanges(callbacks: Object): Meteor.LiveQueryHandle;
+ }
+}
+
+declare module Random {
+ function id(): string;
+}
+
+declare module Deps {
+ function autorun(runFunc: Function): Deps.Computation;
+ function flush(): void;
+ function nonreactive(func: Function): void;
+ var active: boolean;
+ var currentComputation: Deps.Computation;
+ function onInvalidate(callback: Function): void;
+ function afterFlush(callback: Function): void;
+}
+
+declare module Deps {
+ interface Computation {
+ stop(): void;
+ invalidate(): void;
+ onInvalidate(callback: Function): void;
+ stopped: boolean;
+ invalidated: boolean;
+ firstRun: boolean;
+ }
+}
+
+declare module Deps {
+ interface Dependency {
+ changed(): void;
+ depend(fromComputation?): boolean;
+ hasDependents(): boolean;
+ }
+}
+
+declare module Meteor {
+ interface Accounts extends Meteor.AccountsBase {
+ config(options: {
+ sendVerificationEmail?: Boolean;
+ forbidClientAccountCreation?: Boolean;
+ restrictCreationByEmailDomain?: any; // string or Function
+ loginExpirationInDays?: Number;
+ oauthSecretKey?: string;
+ }): void;
+ ui: {
+ config(options: {
+ requestPermissions?: Object;
+ requestOfflineToken?: Object;
+ forceApprovalPrompt?: Boolean;
+ passwordSignupFields?: string;
+ });
+ }
+ validateNewUser(func: Function): void;
+ onCreateUser(func: Function): void;
+ validateLoginAttempt(func: Function);
+ onLogin(func: Function);
+ onLoginFailure(func: Function);
+ createUser(options: {
+ username?: string;
+ email?: string;
+ password?: string;
+ profile?: Object;
+ }, callback?: Function): string;
+ changePassword(oldPassword: string, newPassword: string, callback?: Function): void;
+ forgotPassword(options: {
+ email?: string;
+ }, callback?: Function): void;
+ resetPassword(token: string, newPassword: string, callback?: Function): void;
+ setPassword(userId: string, newPassword: string): void;
+ verifyEmail(token: string, callback?: Function): void;
+ sendResetPasswordEmail(userId: string, email?): void;
+ sendEnrollmentEmail(userId: string, email?): void;
+ sendVerificationEmail(userId: string, email?): void;
+ emailTemplates: Meteor.EmailTemplates;
+ }
+}
+
+declare module Meteor {
+ interface Match extends Meteor.MatchBase {
+ test(value: any, pattern: any): boolean;
+ }
+}
+
+declare module Meteor {
+ interface Session {
+ set(key: string, value: any): void;
+ setDefault(key: string, value: any): void;
+ get(key: string): any;
+ equals(key: string, value: any): boolean;
+ }
+}
+
+declare module HTTP {
+ function call(method: string, url, options?: {
+ content?: string;
+ data?: Object;
+ query?: string;
+ params?: Object;
+ auth?: string;
+ headers?: Object;
+ timeout?: Number;
+ followRedirects?: Boolean;
+ }, asyncCallback?): HTTP.HTTPResponse;
+ function get(url, options?: {
+ }, asyncCallback?): HTTP.HTTPResponse;
+ function post(url, options?: {
+ }, asyncCallback?): HTTP.HTTPResponse;
+ function put(url, options?: {
+ }, asyncCallback?): HTTP.HTTPResponse;
+ function del(url, options?: {
+ }, asyncCallback?): HTTP.HTTPResponse;
+}
+
+declare module Meteor {
+ interface Template {
+ rendered: Function;
+ created: Function;
+ destroyed: Function;
+ events(eventMap: {[id:string]: Function}): void;
+ helpers(helpers: Object): void;
+ }
+}
+
+declare module Meteor {
+ interface UI {
+ registerHelper(name: string, func: Function): void;
+ body: Meteor.Template;
+ render(template): Meteor.RenderedTemplate;
+ renderWithData(template, data: Object): Meteor.RenderedTemplate;
+ insert(renderedTemplate: RenderedTemplate, parentNode, nextNode?): void;
+ remove(renderedTemplate: RenderedTemplate): void;
+ getElementData(el: HTMLElement): Meteor.DataContext;
+ }
+}
+
+declare module Email {
+ function send(options: {
+ from?: string;
+ to?: any; // string or string[]
+ cc?: any; // string or string[]
+ bcc?: any; // string or string[]
+ replyTo?: any; // string or string[]
+ subject?: string;
+ text?: string;
+ html?: string;
+ headers?: Object;
+ }): void;
+}
+
+declare module Assets {
+ function getText(assetPath: string, asyncCallback?): string;
+ function getBinary(assetPath: string, asyncCallback?): Meteor.EJSON;
+}
+
+declare var Template: Meteor.TemplateBase;
+declare var Session: Meteor.Session;
+declare var Accounts: Meteor.Accounts;
+declare var Match: Meteor.Match;
+declare var EJSON: Meteor.EJSON;
+declare var Tinytest: Meteor.Tinytest;