diff --git a/meteor/meteor-tests.ts b/meteor/meteor-tests.ts index 05f4f4b310..fa81ec23d3 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/. @@ -124,7 +124,7 @@ Meteor.methods({ 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"); + throw new Meteor.Error("404", "Can't find my pants"); return "some return value"; }, @@ -376,7 +376,7 @@ Accounts.ui.config({ Accounts.validateNewUser(function (user) { if (user.username && user.username.length >= 3) return true; - throw new Meteor.Error(403, "Username must have at least 3 characters"); + throw new Meteor.Error("403", "Username must have at least 3 characters"); }); // Validate username, without a specific error message. Accounts.validateNewUser(function (user) { @@ -530,13 +530,6 @@ Meteor.methods({ // Let other method calls from the same client start running, // without waiting for the email sending to complete. this.unblock(); - - Email.send({ - to: to, - from: from, - subject: subject, - text: text - }); } }); @@ -561,3 +554,9 @@ 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: string = reactiveVar1.get(); +reactiveVar1.set('new value'); \ No newline at end of file diff --git a/meteor/meteor.d.ts b/meteor/meteor.d.ts index 48fa3266c1..7049e02f93 100644 --- a/meteor/meteor.d.ts +++ b/meteor/meteor.d.ts @@ -1,19 +1,93 @@ -// Type definitions for Meteor 0.9.1 -// Project: http://www.meteor.com/ -// Definitions by: Dave Allen -// Definitions: https://github.com/borisyankov/DefinitelyTyped +/** + * + * 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 1.0.2.1 + * + */ /** - * These are the modules and interfaces that can't be automatically generated from the Meteor api.js file + * These are the modules and interfaces that can't be automatically generated from the Meteor data.js file */ + +interface EJSON extends JSON {} +interface Template { + [templateName: string]: Meteor.Template; +} + +declare module Match { + var Any; + var String; + var Integer; + var Boolean; + var undefined; + //function null(); // not allowed in TypeScript + var Object; + function Optional(pattern):boolean; + function ObjectIncluding(dico):boolean; + function OneOf(...patterns); + function Where(condition); +} + declare module Meteor { - interface EJSONObject extends Object {} + //interface EJSONObject extends Object {} + + /** Start definitions for Template **/ + // DA: "Template" needs to support these functions: + // Template..rendered + // Template..created + // Template..destroyed + // Template..helpers + // Template..events + // and + // Template.currentData + // Template.parentData, etc. + + 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):any; + } + + interface EventMap { + [id:string]:Meteor.EventHandlerFunction; + } + + // Same definition as top-level Template Interface + interface TemplateBase { + [templateName: string]: Meteor.Template; + } + + interface Template { + rendered: Function; + created: Function; + destroyed: Function; + events(eventMap:Meteor.EventMap): void; + helpers(helpers:{[id:string]: any}): void; + } + /** End definitions for Template **/ interface LoginWithExternalServiceOptions { requestPermissions?: string[]; requestOfflineToken?: Boolean; forceApprovalPrompt?: Boolean; userEmail?: string; + loginStyle?: string; } function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; @@ -43,14 +117,6 @@ declare module Meteor { ready(): boolean; } - interface TemplateBase { - [templateName: string]: Meteor.Template; - } - - interface RenderedTemplate extends Object {} - - interface DataContext extends Object {} - interface Tinytest { add(name:string, func:Function); addAsync(name:string, func:Function); @@ -81,31 +147,32 @@ declare module Meteor { verifyEmail: Meteor.EmailFields; } - interface AccountsBase { - EmailTemplates: { - from: string; - siteName: string; - resetPassword: Meteor.EmailFields; - enrollAccount: Meteor.EmailFields; - verifyEmail: Meteor.EmailFields; - } - loginServicesConfigured(): boolean; + interface Error { + error: number; + reason?: string; + details?: string; } - interface MatchBase { - Any; - String; - Integer; - Boolean; - undefined; - null; - Object; - Optional(pattern):boolean; - ObjectIncluding(dico):boolean; - OneOf(...patterns); - Where(condition); + interface Connection { + id: string; + close: Function; + onClose: Function; + clientAddress: string; + httpHeaders: Object; } +} +declare module Mongo { + interface Selector extends Object {} + interface Modifier {} + interface SortSpecifier {} + interface FieldSpecifier { + [id: string]: Number; + } + enum IdGenerationEnum { + STRING, + MONGO + } interface AllowDenyOptions { insert?: (userId:string, doc) => boolean; update?: (userId, doc, fieldNames, modifier) => boolean; @@ -113,95 +180,9 @@ declare module Meteor { fetch?: string[]; transform?: Function; } - - interface Error { - error: number; - reason?: string; - details?: string; - } -} - -declare module Mongo { - interface CollectionFieldSpecifier { - [id: string]: Number; - } - - enum CollectionIdGenerationEnum { - STRING, - MONGO - } - -// interface CollectionOptions { -// connection: Object; -// idGeneration: Mongo.CollectionIdGenerationEnum; -// transform?: (document)=>any; -// } -// -// function Collection(name:string, options?: Mongo.CollectionOptions) : void; -} - -declare module Tracker { - function Computation(): void; - interface Computation { - - } - function Dependency(): void; - interface Dependency { - changed(): void; - depend(fromComputation: Tracker.Computation): boolean; - hasDependents(): boolean; - } -} - -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; @@ -259,6 +240,8 @@ declare module DDP { } declare module Random { + function id(numberOfChars?: number): string; + function secret(numberOfChars?: number): string; 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 @@ -292,339 +275,428 @@ declare module Blaze { /** * These modules and interfaces are automatically generated from the Meteor api.js file */ -declare module Meteor { - var isClient: boolean; - var isServer: boolean; - var isCordova: boolean; - function startup(func: Function): void; - function wrapAsync(func: Function, context?: Object): any; - function absoluteUrl(path?: string, 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 user(): Meteor.User; - function userId(): string; - var users: Mongo.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; - loginStyle?: 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 Accounts { + var ui: { + config(options: { + requestPermissions?: Object; + requestOfflineToken?: Object; + forceApprovalPrompt?: Object; + passwordSignupFields?: string; + }): void; + }; + var emailTemplates: Meteor.EmailTemplates; + function config(options: { + sendVerificationEmail?: boolean; + forbidClientAccountCreation?: Boolean; + restrictCreationByEmailDomain?: string; + loginExpirationInDays?: number; + oauthSecretKey?: string; + }): void; + function validateLoginAttempt(func: Function): {stop: Function}; + function onLogin(func: Function): {stop: Function}; + function onLoginFailure(func: Function): {stop: Function}; + function onCreateUser(func: Function): void; + function validateNewUser(func: Function): void; + function onResetPasswordLink(callback: Function): void; + function onEmailVerificationLink(callback: Function): void; + function onEnrollmentLink(callback: Function): void; + function createUser(options: { + username?: string; + email?: string; + password?: string; + profile?: Object; + }, callback?: Function): string; + function changePassword(oldPassword: string, newPassword: string, callback?: Function): void; + function forgotPassword(options: { + email?: string; + }, callback?: Function): void; + function resetPassword(token: string, newPassword: string, callback?: Function): void; + function verifyEmail(token: string, callback?: Function): void; + function setPassword(userId: string, newPassword: string): void; + function sendResetPasswordEmail(userId: string, email?: string): void; + function sendEnrollmentEmail(userId: string, email?: string): void; + function sendVerificationEmail(userId: string, email?: string): void; } -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; /** TODO: add return value **/ - newBinary(size: number): any; - isBinary(x): boolean; - addType(name: string, factory: Function): void; +declare module Blaze { + var currentView: Blaze.View; + function With(data: Object, contentFunc: Function): Blaze.View; + function With(data: Function, contentFunc: Function): Blaze.View; + function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View; + function Unless(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View; + function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View; + function isTemplate(value: any): boolean; + function render(templateOrView: Template, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View; + function render(templateOrView: Blaze.View, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View; + function renderWithData(templateOrView: Template, data: Object, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View; + function renderWithData(templateOrView: Template, data: Function, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View; + function renderWithData(templateOrView: Blaze.View, data: Object, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View; + function renderWithData(templateOrView: Blaze.View, data: Function, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View; + function remove(renderedView: Blaze.View): void; + function toHTML(templateOrView: Template): string; + function toHTML(templateOrView: Blaze.View): string; + function toHTMLWithData(templateOrView: Template, data: Object): string; + function toHTMLWithData(templateOrView: Template, data: Function): string; + function toHTMLWithData(templateOrView: Blaze.View, data: Object): string; + function toHTMLWithData(templateOrView: Blaze.View, data: Function): string; + function getData(elementOrView?: HTMLElement): Object; + function getData(elementOrView?: Blaze.View): Object; + function getView(element?: HTMLElement): Blaze.View; + function Template(viewName?: string, renderFunction?: Function): void; + function TemplateInstance(view: Blaze.View): void; + interface TemplateInstance { + data(): Object; + view(): Object; + firstNode(): Object; + lastNode(): Object; + $(selector: string): Node[]; + findAll(selector: string): HTMLElement[]; + find(selector?: string): HTMLElement; + autorun(runFunc: Function): Object; } + + function View(name?: string, renderFunction?: Function): void; +} + +declare module Match { + function test(value: any, pattern: any): boolean; } declare module DDP { function connect(url: string): DDP.DDPStatic; } +declare module EJSON { + var newBinary: any; + function addType(name: string, factory: Function): void; + function toJSONValue(val: EJSON): JSON; + function fromJSONValue(val: JSON): any; + function stringify(val: EJSON, options?: { + indent?: boolean; + canonical?: Boolean; + }): string; + function parse(str: string): EJSON; + function isBinary(x: Object): boolean; + function equals(a: EJSON, b: EJSON, options?: { + keyOrderSensitive?: boolean; + }): boolean; + function clone(val:T): T; + function CustomType(): void; + interface CustomType { + typeName(): string; + toJSONValue(): JSON; + clone(): EJSON.CustomType; + equals(other: Object): boolean; + } + +} + +declare module Meteor { + var users: Mongo.Collection; + var isClient: boolean; + var isServer: boolean; + var settings: {[id:string]: any}; + var isCordova: boolean; + var release: string; + function userId(): string; + function loggingIn(): boolean; + function user(): Meteor.User; + function logout(callback?: Function): void; + function logoutOtherClients(callback?: Function): void; + function loginWith(options?: { + requestPermissions?: string[]; + requestOfflineToken?: boolean; + forceApprovalPrompt?: Boolean; + userEmail?: string; + loginStyle?: string; + }, callback?: Function): void; + function loginWithPassword(user: Object, password: string, callback?: Function): void; + function loginWithPassword(user: string, password: string, callback?: Function): void; + function subscribe(name: string, ...args): SubscriptionHandle; + function subscribe(name: string, ...args): SubscriptionHandle; + function call(name: string, ...args): void; + function apply(name: string, args: EJSON[], options?: { + wait?: boolean; + onResultReceived?: Function; + }, asyncCallback?: Function): void; + function status(): Meteor.StatusEnum; + function reconnect(): void; + function disconnect(): void; + function onConnection(callback: Function): void; + function publish(name: string, func: Function): void; + function methods(methods: Object): void; + function wrapAsync(func: Function, context?: Object): any; + function startup(func: Function): void; + function setTimeout(func: Function, delay: number): number; + function setInterval(func: Function, delay: number): number; + function clearInterval(id: number): void; + function clearTimeout(id: number): void; + function absoluteUrl(path?: string, options?: { + secure?: boolean; + replaceLocalhost?: Boolean; + rootUrl?: string; + }): string; + function Error(error: string, reason?: string, details?: string): void; +} + declare module Mongo { function Collection(name: string, options?: { - connection?: Object; - idGeneration?: Mongo.CollectionIdGenerationEnum; - transform?: (document)=>any; - }): void; - function ObjectID(hexString: string): void; -} - -declare module Mongo { + connection?: Object; + idGeneration?: string; + transform?: Function; + }): void; interface Collection { - find(selector?: any, options?: { - sort?: any; - skip?: number; - limit?: number; - fields?: Mongo.CollectionFieldSpecifier; - reactive?: Boolean; - transform?: (document)=>any; - }): Mongo.Cursor; - findOne(selector?: any, options?: { - sort?: any; - skip?: number; - fields?: Mongo.CollectionFieldSpecifier; - reactive?: Boolean; - transform?: (document)=>any; - }): Meteor.EJSONObject; - insert(doc: Object, callback?: Function): string; - 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; + insert(doc: Object, callback?: Function): string; + update(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: { + multi?: boolean; + upsert?: Boolean; + }, callback?: Function): number; + find(selector?: Mongo.Selector, options?: { + sort?: Mongo.SortSpecifier; + skip?: number; + limit?: number; + fields?: Mongo.FieldSpecifier; + reactive?: boolean; + transform?: Function; + }): Mongo.Cursor; + findOne(selector?: Mongo.Selector, options?: { + sort?: Mongo.SortSpecifier; + skip?: number; + fields?: Mongo.FieldSpecifier; + reactive?: boolean; + transform?: Function; + }): T; + remove(selector: Mongo.Selector, callback?: Function): void; + upsert(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: { + multi?: boolean; + }, callback?: Function): {numberAffected?: number; insertedId?: string;}; + allow(options: { + insert?: (userId:string, doc) => boolean; + update?: (userId, doc, fieldNames, modifier) => boolean; + remove?: (userId, doc) => boolean; + fetch?: string[]; + transform?: Function; + }): boolean; + deny(options: { + insert?: (userId:string, doc) => boolean; + update?: (userId, doc, fieldNames, modifier) => boolean; + remove?: (userId, doc) => boolean; + fetch?: string[]; + transform?: Function; + }): boolean; } -} -declare module Mongo { + function ObjectID(hexString: string): void; + function Cursor(): void; interface Cursor { - count(): number; - fetch(): any[]; - forEach(callback: Function, thisArg?: any): void; + forEach(callback: Function, thisArg?: any): void; map(callback: Function, thisArg?: any): void; + fetch(): Array; + count(): number; observe(callbacks: Object): Meteor.LiveQueryHandle; observeChanges(callbacks: Object): Meteor.LiveQueryHandle; } -} -declare module Random { - function id(): string; } declare module Tracker { - function autorun(runFunc: Function): Tracker.Computation; - function flush(): void; - function nonreactive(func: Function): void; var active: boolean; var currentComputation: Tracker.Computation; + function Computation(): void; + interface Computation { + stopped(): boolean; + invalidated(): boolean; + firstRun(): boolean; + onInvalidate(callback: Function): void; + invalidate(): void; + stop(): void; + } + + function flush(): void; + function autorun(runFunc: Function): Tracker.Computation; + function nonreactive(func: Function): void; function onInvalidate(callback: Function): void; function afterFlush(callback: Function): void; -} - -declare module Tracker { - interface Computation { - stop(): void; - invalidate(): void; - onInvalidate(callback: Function): void; - stopped: boolean; - invalidated: boolean; - firstRun: boolean; - } -} - -declare module Tracker { + function Dependency(): void; interface Dependency { + depend(fromComputation?: Tracker.Computation): boolean changed(): void; - depend(fromComputation?: Tracker.Computation): boolean; - hasDependents(): 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; - }); /** TODO: add return value **/ - } - validateNewUser(func: Function): void; - onCreateUser(func: Function): void; - validateLoginAttempt(func: Function); /** TODO: add return value **/ - onLogin(func: Function); /** TODO: add return value **/ - onLoginFailure(func: Function); /** TODO: add return value **/ - 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?: string): void; - sendEnrollmentEmail(userId: string, email?: string): void; - sendVerificationEmail(userId: string, email?: string): 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; - findAll(selector: string); /** TODO: add return value **/ - $(selector: string); /** TODO: add return value **/ - find(selector?: string); /** TODO: add return value **/ - firstNode; /** TODO: add return value **/ - lastNode; /** TODO: add return value **/ - data; /** TODO: add return value **/ - autorun(runFunc: Function); /** TODO: add return value **/ - view; /** TODO: add return value **/ - registerHelper(name: string, func: Function); /** TODO: add return value **/ - body; /** TODO: add return value **/ - currentData(); /** TODO: add return value **/ - instance(); /** TODO: add return value **/ - parentData(numLevels: number); /** TODO: add return value **/ - } -} - -declare module Blaze { - function render(templateOrView: any, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View; - function renderWithData(templateOrView: any, data: any, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View; - function remove(renderedView: Blaze.View): void; - function With(data: any, contentFunc: Function); /** TODO: add return value **/ - function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function); /** TODO: add return value **/ - function Unless(conditionFunc: Function, contentFunc: Function, elseFunc?: Function); /** TODO: add return value **/ - function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function); /** TODO: add return value **/ - function getData(elementOrView?: any); /** TODO: add return value **/ - var currentView; /** TODO: add return value **/ - function getView(element?: HTMLElement); /** TODO: add return value **/ - function toHTML(templateOrView: any): string; - function toHTMLWithData(templateOrView: any, data: any): string; - function View(name?: string, renderFunction?: Function): void; - function Template(viewName?: string, renderFunction?: Function): void; - function isTemplate(value: any): boolean; -} - -declare module Meteor { - interface ReactiveVar { - get(); /** TODO: add return value **/ - set(newValue: any); /** TODO: add return value **/ - } -} - -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?: Function): string; - function getBinary(assetPath: string, asyncCallback?: Function): Meteor.EJSON; + function getBinary(assetPath: string, asyncCallback?: Function): EJSON; } -declare module Meteor { - interface Package { - describe(options: { - summary?: string; - version?: string; - name?: string; - git?: string; - }); /** TODO: add return value **/ - onUse(f: Function); /** TODO: add return value **/ - onTest(f: Function); /** TODO: add return value **/ - describe(options: { - }); /** TODO: add return value **/ - } +declare module App { + function info(options: { + id?: string; + version?: string; + name?: string; + description?: string; + author?: string; + email?: string; + website?: string; + }): void; + function setPreference(name: string, value: string): void; + function configurePlugin(pluginName: string, config: Object): void; + function icons(icons: Object): void; + function launchScreens(launchScreens: Object): void; } -declare module Meteor { - interface Api { - use(packageNameAndVersion?: string, architecture?: string, options?: { - weak?: Boolean; - unordered?: Boolean; - }); /** TODO: add return value **/ - versionsFrom(meteorversion: string); /** TODO: add return value **/ - imply(packagespecOrpackagespecs: any); /** TODO: add return value **/ - export(exportedObject: string, architecture?: string); /** TODO: add return value **/ - addFiles(filenameOrfilenames: any); /** TODO: add return value **/ - } +declare module Package { + function describe(options: { + summary?: string; + version?: string; + name?: string; + git?: string; + }): void; + function onUse(func: Function): void; + function onTest(func: Function): void; + function registerBuildPlugin(options?: { + name?: string; + use?: string; + sources?: string[]; + npmDependencies?: Object; + }): void; +} + +declare module Npm { + function depends(dependencies:{[id:string]:string}): void; + function require(name: string): void; +} + +declare module Cordova { + function depends(dependencies:{[id:string]:string}): void; +} + +declare module Session { + function set(key: string, value: EJSON): void; + function set(key: string, value: any /** Undefined **/): void; + function setDefault(key: string, value: EJSON): void; + function setDefault(key: string, value: any /** Undefined **/): void; + function get(key: string): any; + function equals(key: string, value: string): boolean; + function equals(key: string, value: number): boolean; + function equals(key: string, value: boolean): boolean; + function equals(key: string, value: any /** Null **/): boolean; + function equals(key: string, value: any /** Undefined **/): boolean; +} + +declare module HTTP { + function call(method: string, url: string, options?: { + content?: string; + data?: Object; + query?: string; + params?: Object; + auth?: string; + headers?: Object; + timeout?: number; + followRedirects?: boolean; + }, asyncCallback?: Function): HTTP.HTTPResponse; + function get(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; + function post(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; + function put(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; + function del(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; +} + +declare module Email { + function send(options: { + from?: string; + to?: string; + cc?: string; + bcc?: string; + replyTo?: string; + subject?: string; + text?: string; + html?: string; + headers?: Object; + }): void; +} + +declare function Subscription(): void; +declare module Subscription { + var connection: Meteor.Connection; + var userId: string; + function error(error: Error): void; + function stop(): void; + function onStop(func: Function): void; + function added(collection: string, id: string, fields: Object): void; + function changed(collection: string, id: string, fields: Object): void; + function removed(collection: string, id: string): void; + function ready(): void; +} + +declare function ReactiveVar(initialValue: any, equalsFunc?: (oldVal:any, newVal:any)=>boolean): void; +declare module ReactiveVar { + function get(): any; + function set(newValue: any): void; +} + +declare function Template(): void; +declare module Template { + var created: Function; + var rendered: Function; + var destroyed: Function; + var body: Meteor.TemplateBase; + function helpers(helpers:{[id:string]: any}): void; + function events(eventMap: {[actions: string]: Function}): void; + function instance(): Blaze.TemplateInstance; + function currentData(): {}; + function parentData(numLevels?: number): {}; + function registerHelper(name: string, func: Function): void; +} + +declare function CompileStep(): void; +declare module CompileStep { + var inputSize; /** TODO: add return value **/ + var inputPath; /** TODO: add return value **/ + var fullInputPath; /** TODO: add return value **/ + var pathForSourceMap; /** TODO: add return value **/ + var packageName; /** TODO: add return value **/ + var rootOutputPath; /** TODO: add return value **/ + var arch; /** TODO: add return value **/ + var fileOptions; /** TODO: add return value **/ + var declaredExports; /** TODO: add return value **/ + function read(n?: number); /** TODO: add return value **/ + function addHtml(options: { + section?: string; + data?: string; + }); /** TODO: add return value **/ + function addStylesheet(options: { + }, path: string, data: string, sourceMap: string); /** TODO: add return value **/ + function addJavaScript(options: { + path?: string; + data?: string; + sourcePath?: string; + }); /** TODO: add return value **/ + function addAsset(options: { + }, path: string, data: any /** Buffer **/); /** TODO: add return value **/ + function addAsset(options: { + }, path: string, data: string); /** TODO: add return value **/ + function error(options: { + }, message: string, sourcePath?: string, line?: number, func?: string); /** TODO: add return value **/ +} + +declare function PackageAPI(): void; +declare module PackageAPI { + function use(packageNames: string, architecture?: string, options?: { + weak?: boolean; + unordered?: Boolean; + }): void; + function use(packageNames: string[], architecture?: string, options?: { + weak?: boolean; + unordered?: Boolean; + }): void; + function imply(packageSpecs: string): void; + function imply(packageSpecs: string[]): void; + function addFiles(filename: string, architecture?: string): void; + function addFiles(filename: string[], architecture?: string): void; + function versionsFrom(meteorRelease: string): void; + function versionsFrom(meteorRelease: string[]): void; + // function export(exportedObject: string, architecture?: string): void; } -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;