Meteor's underscore and ServiceConfiguration types and new version for publish-composite are added (#20413)

* ServiceConfiguration types added

* New usage of publishComposite added to meteor-publish-composite

* meteor/underscore added
This commit is contained in:
Arda TANRIKULU 2017-10-13 17:54:04 -04:00 committed by Wesley Wigham
parent 7671753459
commit 795cd33932
6 changed files with 57 additions and 55 deletions

View File

@ -6,75 +6,60 @@
/// <reference types="meteor" />
declare interface PublishCompositeConfigN {
children? : PublishCompositeConfigN[];
children?: PublishCompositeConfigN[];
find(
...args : any[]
) : Mongo.Cursor<any>;
...args: any[]
): Mongo.Cursor<any>;
}
declare interface PublishCompositeConfig4<InLevel1, InLevel2, InLevel3, InLevel4, OutLevel> {
children? : PublishCompositeConfigN[];
children?: PublishCompositeConfigN[];
find(
arg4 : InLevel4,
arg3 : InLevel3,
arg2 : InLevel2,
arg1 : InLevel1
) : Mongo.Cursor<OutLevel>;
arg4: InLevel4,
arg3: InLevel3,
arg2: InLevel2,
arg1: InLevel1
): Mongo.Cursor<OutLevel>;
}
declare interface PublishCompositeConfig3<InLevel1, InLevel2, InLevel3, OutLevel> {
children? : PublishCompositeConfig4<InLevel1, InLevel2, InLevel3, OutLevel, any>[];
children?: PublishCompositeConfig4<InLevel1, InLevel2, InLevel3, OutLevel, any>[];
find(
arg3 : InLevel3,
arg2 : InLevel2,
arg1 : InLevel1
) : Mongo.Cursor<OutLevel>;
arg3: InLevel3,
arg2: InLevel2,
arg1: InLevel1
): Mongo.Cursor<OutLevel>;
}
declare interface PublishCompositeConfig2<InLevel1, InLevel2, OutLevel> {
children? : PublishCompositeConfig3<InLevel1, InLevel2, OutLevel, any>[];
children?: PublishCompositeConfig3<InLevel1, InLevel2, OutLevel, any>[];
find(
arg2 : InLevel2,
arg1 : InLevel1
) : Mongo.Cursor<OutLevel>;
arg2: InLevel2,
arg1: InLevel1
): Mongo.Cursor<OutLevel>;
}
declare interface PublishCompositeConfig1<InLevel1, OutLevel> {
children? : PublishCompositeConfig2<InLevel1, OutLevel, any>[];
children?: PublishCompositeConfig2<InLevel1, OutLevel, any>[];
find(
arg1 : InLevel1
) : Mongo.Cursor<OutLevel>;
arg1: InLevel1
): Mongo.Cursor<OutLevel>;
}
declare interface PublishCompositeConfig<OutLevel> {
children? : PublishCompositeConfig1<OutLevel, any>[];
find() : Mongo.Cursor<OutLevel>;
children?: PublishCompositeConfig1<OutLevel, any>[];
find(): Mongo.Cursor<OutLevel>;
}
declare namespace Meteor {
declare module "meteor/reywood:publish-composite" {
function publishComposite(
name : string,
config : PublishCompositeConfig<any>|PublishCompositeConfig<any>[]
) : void;
name: string,
config: PublishCompositeConfig<any> | PublishCompositeConfig<any>[]
): void;
function publishComposite(
name : string,
configFunc : (...args : any[]) =>
PublishCompositeConfig<any>|PublishCompositeConfig<any>[]
) : void;
}
declare module 'meteor/meteor' {
namespace Meteor {
function publishComposite(
name : string,
config : PublishCompositeConfig<any>|PublishCompositeConfig<any>[]
) : void;
function publishComposite(
name : string,
configFunc : (...args : any[]) =>
PublishCompositeConfig<any>|PublishCompositeConfig<any>[]
) : void;
}
name: string,
configFunc: (...args: any[]) =>
PublishCompositeConfig<any> | PublishCompositeConfig<any>[]
): void;
}

View File

@ -1,14 +1,14 @@
import { publishComposite } from 'meteor/reywood:publish-composite';
import User = Meteor.User;
interface IPost { _id : string, authorId : string };
interface IComment { authorId : string };
var Posts : Mongo.Collection<IPost> = new Mongo.Collection<IPost>('Posts');
var Comments : Mongo.Collection<IComment> = new Mongo.Collection<IComment>('Comments');
interface IPost { _id: string, authorId: string };
interface IComment { authorId: string };
var Posts: Mongo.Collection<IPost> = new Mongo.Collection<IPost>('Posts');
var Comments: Mongo.Collection<IComment> = new Mongo.Collection<IComment>('Comments');
// Server
Meteor.publishComposite('topTenPosts', {
find: function() : Mongo.Cursor<IPost> {
publishComposite('topTenPosts', {
find: function(): Mongo.Cursor<IPost> {
// Find top ten highest scoring posts
return Posts.find({}, { sort: { score: -1 }, limit: 10 });
},
@ -45,7 +45,7 @@ Meteor.publishComposite('topTenPosts', {
});
// Server
Meteor.publishComposite('postsByUser', function(userId, limit) {
publishComposite('postsByUser', function(userId, limit) {
return {
find: function() {
// Find posts made by user. Note arguments for callback function

View File

@ -17,9 +17,11 @@
/// <reference path="./random.d.ts" />
/// <reference path="./reactive-var.d.ts" />
/// <reference path="./server-render.d.ts" />
/// <reference path="./service-configuration.d.ts" />
/// <reference path="./session.d.ts" />
/// <reference path="./templating.d.ts" />
/// <reference path="./tiny-test.d.ts" />
/// <reference path="./tools.d.ts" />
/// <reference path="./tracker.d.ts" />
/// <reference path="./underscore.d.ts" />
/// <reference path="./webapp.d.ts" />

View File

@ -0,0 +1,9 @@
declare module "meteor/service-configuration" {
interface Configuration {
appId: string;
secret: string;
}
class ServiceConfiguration {
configurations: Mongo.Collection<Configuration>;
}
}

View File

@ -31,12 +31,14 @@
"mongo.d.ts",
"reactive-var.d.ts",
"server-render.d.ts",
"service-configuration.d.ts",
"session.d.ts",
"tiny-test.d.ts",
"tools.d.ts",
"tracker.d.ts",
"underscore.d.ts",
"webapp.d.ts",
"index.d.ts",
"meteor-tests.ts"
]
}
}

4
types/meteor/underscore.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
declare module "meteor/underscore" {
import * as _ from 'underscore';
export { _ };
}