diff --git a/packages/accounts-base/accounts-base.d.ts b/packages/accounts-base/accounts-base.d.ts new file mode 100644 index 0000000000..923625be79 --- /dev/null +++ b/packages/accounts-base/accounts-base.d.ts @@ -0,0 +1,326 @@ +import { Mongo } from 'meteor/mongo'; +import { Meteor } from 'meteor/meteor'; + +export interface URLS { + resetPassword: (token: string) => string; + verifyEmail: (token: string) => string; + enrollAccount: (token: string) => string; +} + +export interface EmailFields { + from?: ((user: Meteor.User) => string) | undefined; + subject?: ((user: Meteor.User) => string) | undefined; + text?: ((user: Meteor.User, url: string) => string) | undefined; + html?: ((user: Meteor.User, url: string) => string) | undefined; +} + +export namespace Accounts { + var urls: URLS; + + function user(options?: { + fields?: Mongo.FieldSpecifier | undefined; + }): Meteor.User | null; + + function userId(): string | null; + + function createUser( + options: { + username?: string | undefined; + email?: string | undefined; + password?: string | undefined; + profile?: Object | undefined; + }, + callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void + ): string; + + function config(options: { + sendVerificationEmail?: boolean | undefined; + forbidClientAccountCreation?: boolean | undefined; + restrictCreationByEmailDomain?: string | Function | undefined; + loginExpirationInDays?: number | undefined; + oauthSecretKey?: string | undefined; + passwordResetTokenExpirationInDays?: number | undefined; + passwordEnrollTokenExpirationInDays?: number | undefined; + ambiguousErrorMessages?: boolean | undefined; + defaultFieldSelector?: { [key: string]: 0 | 1 } | undefined; + }): void; + + function onLogin( + func: Function + ): { + stop: () => void; + }; + + function onLoginFailure( + func: Function + ): { + stop: () => void; + }; + + function loginServicesConfigured(): boolean; + + function onPageLoadLogin(func: Function): void; +} + +export namespace Accounts { + function changePassword( + oldPassword: string, + newPassword: string, + callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function forgotPassword( + options: { email?: string | undefined }, + callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function resetPassword( + token: string, + newPassword: string, + callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function verifyEmail( + token: string, + callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function onEmailVerificationLink(callback: Function): void; + + function onEnrollmentLink(callback: Function): void; + + function onResetPasswordLink(callback: Function): void; + + function loggingIn(): boolean; + + function loggingOut(): boolean; + + function logout( + callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function logoutOtherClients( + callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + var ui: { + config(options: { + requestPermissions?: Object | undefined; + requestOfflineToken?: Object | undefined; + forceApprovalPrompt?: Object | undefined; + passwordSignupFields?: string | undefined; + }): void; + }; +} + +export interface Header { + [id: string]: string; +} + +export interface EmailTemplates { + from: string; + siteName: string; + headers?: Header | undefined; + resetPassword: EmailFields; + enrollAccount: EmailFields; + verifyEmail: EmailFields; +} + +export namespace Accounts { + var emailTemplates: EmailTemplates; + + function addEmail(userId: string, newEmail: string, verified?: boolean): void; + + function removeEmail(userId: string, email: string): void; + + function onCreateUser( + func: (options: { profile?: {} | undefined }, user: Meteor.User) => void + ): void; + + function findUserByEmail( + email: string, + options?: { fields?: Mongo.FieldSpecifier | undefined } + ): Meteor.User | null | undefined; + + function findUserByUsername( + username: string, + options?: { fields?: Mongo.FieldSpecifier | undefined } + ): Meteor.User | null | undefined; + + function sendEnrollmentEmail( + userId: string, + email?: string, + extraTokenData?: Record, + extraParams?: Record + ): void; + + function sendResetPasswordEmail( + userId: string, + email?: string, + extraTokenData?: Record, + extraParams?: Record + ): void; + + function sendVerificationEmail( + userId: string, + email?: string, + extraTokenData?: Record, + extraParams?: Record + ): void; + + function setUsername(userId: string, newUsername: string): void; + + function setPassword( + userId: string, + newPassword: string, + options?: { logout?: Object | undefined } + ): void; + + function validateNewUser(func: Function): boolean; + + function validateLoginAttempt( + func: Function + ): { + stop: () => void; + }; + + function _hashPassword( + password: string + ): { digest: string; algorithm: string }; + + interface IValidateLoginAttemptCbOpts { + type: string; + allowed: boolean; + error: Meteor.Error; + user: Meteor.User; + connection: Meteor.Connection; + methodName: string; + methodArguments: any[]; + } +} + +export namespace Accounts { + function onLogout(func: Function): void; +} + +export namespace Accounts { + function onLogout( + func: (options: { + user: Meteor.User; + connection: Meteor.Connection; + }) => void + ): void; +} + +export namespace Accounts { + interface LoginMethodOptions { + /** + * The method to call (default 'login') + */ + methodName?: string | undefined; + /** + * The arguments for the method + */ + methodArguments?: any[] | undefined; + /** + * If provided, will be called with the result of the + * method. If it throws, the client will not be logged in (and + * its error will be passed to the callback). + */ + validateResult?: Function | undefined; + /** + * Will be called with no arguments once the user is fully + * logged in, or with the error on error. + */ + userCallback?: ((err?: any) => void) | undefined; + } + + /** + * + * Call a login method on the server. + * + * A login method is a method which on success calls `this.setUserId(id)` and + * `Accounts._setLoginToken` on the server and returns an object with fields + * 'id' (containing the user id), 'token' (containing a resume token), and + * optionally `tokenExpires`. + * + * This function takes care of: + * - Updating the Meteor.loggingIn() reactive data source + * - Calling the method in 'wait' mode + * - On success, saving the resume token to localStorage + * - On success, calling Accounts.connection.setUserId() + * - Setting up an onReconnect handler which logs in with + * the resume token + * + * Options: + * - methodName: The method to call (default 'login') + * - methodArguments: The arguments for the method + * - validateResult: If provided, will be called with the result of the + * method. If it throws, the client will not be logged in (and + * its error will be passed to the callback). + * - userCallback: Will be called with no arguments once the user is fully + * logged in, or with the error on error. + * + * */ + function callLoginMethod(options: LoginMethodOptions): void; + + /** + * + * The main entry point for auth packages to hook in to login. + * + * A login handler is a login method which can return `undefined` to + * indicate that the login request is not handled by this handler. + * + * @param name {String} Optional. The service name, used by default + * if a specific service name isn't returned in the result. + * + * @param handler {Function} A function that receives an options object + * (as passed as an argument to the `login` method) and returns one of: + * - `undefined`, meaning don't handle; + * - a login method result object + **/ + function registerLoginHandler( + name: string, + handler: (options: any) => undefined | Object + ): void; + + type Password = + | string + | { + digest: string; + algorithm: 'sha-256'; + }; + + /** + * + * Check whether the provided password matches the bcrypt'ed password in + * the database user record. `password` can be a string (in which case + * it will be run through SHA256 before bcrypt) or an object with + * properties `digest` and `algorithm` (in which case we bcrypt + * `password.digest`). + */ + function _checkPassword( + user: Meteor.User, + password: Password + ): { userId: string; error?: any }; +} + +export namespace Accounts { + type StampedLoginToken = { + token: string; + when: Date; + }; + type HashedStampedLoginToken = { + hashedToken: string; + when: Date; + }; + + function _generateStampedLoginToken(): StampedLoginToken; + function _hashStampedToken(token: StampedLoginToken): HashedStampedLoginToken; + function _insertHashedLoginToken( + userId: string, + token: HashedStampedLoginToken, + query?: Mongo.Selector | Mongo.ObjectID | string + ): void; + function _hashLoginToken(token: string): string; +} diff --git a/packages/accounts-base/package-types.json b/packages/accounts-base/package-types.json new file mode 100644 index 0000000000..033f6cab29 --- /dev/null +++ b/packages/accounts-base/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "accounts-base.d.ts" +} diff --git a/packages/accounts-base/package.js b/packages/accounts-base/package.js index 32a6df946c..3627de74eb 100644 --- a/packages/accounts-base/package.js +++ b/packages/accounts-base/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: 'A user account system', - version: '2.2.4', + version: '2.2.5-beta.1', }); Package.onUse(api => { @@ -48,6 +48,8 @@ Package.onUse(api => { // modules that import the accounts-base package. api.mainModule('server_main.js', 'server'); api.mainModule('client_main.js', 'client'); + + api.addAssets('accounts-base.d.ts', 'server'); }); Package.onTest(api => { diff --git a/packages/browser-policy-common/browser-policy-common.d.ts b/packages/browser-policy-common/browser-policy-common.d.ts new file mode 100644 index 0000000000..0cfa8678a3 --- /dev/null +++ b/packages/browser-policy-common/browser-policy-common.d.ts @@ -0,0 +1,38 @@ +export namespace BrowserPolicy { + var framing: { + disallow(): void; + restrictToOrigin(origin: string): void; + allowAll(): void; + }; + + var content: { + allowEval(): void; + allowInlineStyles(): void; + allowInlineScripts(): void; + allowSameOriginForAll(): void; + allowDataUrlForAll(): void; + allowOriginForAll(origin: string): void; + allowImageOrigin(origin: string): void; + allowMediaOrigin(origin: string): void; + allowFontOrigin(origin: string): void; + allowStyleOrigin(origin: string): void; + allowScriptOrigin(origin: string): void; + allowFrameOrigin(origin: string): void; + allowFrameAncestorsOrigin(origin: string): void; + allowContentTypeSniffing(): void; + allowAllContentOrigin(): void; + allowAllContentDataUrl(): void; + allowAllContentSameOrigin(): void; + allowConnectOrigin(origin: string): void; + allowObjectOrigin(origin: string): void; + + disallowAll(): void; + disallowInlineStyles(): void; + disallowEval(): void; + disallowInlineScripts(): void; + disallowFont(): void; + disallowObject(): void; + disallowAllContent(): void; + disallowConnect(): void; + }; +} diff --git a/packages/browser-policy-common/package-types.json b/packages/browser-policy-common/package-types.json new file mode 100644 index 0000000000..1b2482b244 --- /dev/null +++ b/packages/browser-policy-common/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "browser-policy-common.d.ts" +} diff --git a/packages/browser-policy-common/package.js b/packages/browser-policy-common/package.js index 85c2554c3e..14a26977dc 100644 --- a/packages/browser-policy-common/package.js +++ b/packages/browser-policy-common/package.js @@ -1,10 +1,11 @@ Package.describe({ summary: "Common code for browser-policy packages", - version: "1.0.11" + version: "1.0.11-beta.1" }); Package.onUse(function (api) { api.use('webapp', 'server'); api.addFiles('browser-policy-common.js', 'server'); api.export('BrowserPolicy', 'server'); + api.addAssets('browser-policy-common.d.ts', 'server'); }); diff --git a/packages/browser-policy-framing/package.js b/packages/browser-policy-framing/package.js index 06ebdfe2e6..22f88cec8a 100644 --- a/packages/browser-policy-framing/package.js +++ b/packages/browser-policy-framing/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Restrict which websites can frame your app", - version: '1.1.1-beta.0' + version: '1.1.1-beta.1' }); Package.onUse(function (api) { diff --git a/packages/browser-policy/package.js b/packages/browser-policy/package.js index aa3ab9dd80..81ebcdb92c 100644 --- a/packages/browser-policy/package.js +++ b/packages/browser-policy/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Configure security policies enforced by the browser", - version: '1.1.1-beta.0' + version: '1.1.1-beta.1' }); Package.onUse(function (api) { diff --git a/packages/check/check.d.ts b/packages/check/check.d.ts new file mode 100644 index 0000000000..0322aab9e9 --- /dev/null +++ b/packages/check/check.d.ts @@ -0,0 +1,92 @@ +/** + * The namespace for all Match types and methods. + */ +export namespace Match { + interface Matcher { + _meteorCheckMatcherBrand: void; + } + // prettier-ignore + export type Pattern = + typeof String | + typeof Number | + typeof Boolean | + typeof Object | + typeof Function | + (new (...args: any[]) => any) | + undefined | null | string | number | boolean | + [Pattern] | + {[key: string]: Pattern} | + Matcher; + // prettier-ignore + export type PatternMatch = + T extends Matcher ? U : + T extends typeof String ? string : + T extends typeof Number ? number : + T extends typeof Boolean ? boolean : + T extends typeof Object ? object : + T extends typeof Function ? Function : + T extends undefined | null | string | number | boolean ? T : + T extends new (...args: any[]) => infer U ? U : + T extends [Pattern] ? PatternMatch[] : + T extends {[key: string]: Pattern} ? {[K in keyof T]: PatternMatch} : + unknown; + + /** Matches any value. */ + var Any: Matcher; + /** Matches a signed 32-bit integer. Doesn’t match `Infinity`, `-Infinity`, or `NaN`. */ + var Integer: Matcher; + + /** + * Matches either `undefined`, `null`, or pattern. If used in an object, matches only if the key is not set as opposed to the value being set to `undefined` or `null`. This set of conditions + * was chosen because `undefined` arguments to Meteor Methods are converted to `null` when sent over the wire. + */ + function Maybe( + pattern: T + ): Matcher | undefined | null>; + + /** Behaves like `Match.Maybe` except it doesn’t accept `null`. If used in an object, the behavior is identical to `Match.Maybe`. */ + function Optional( + pattern: T + ): Matcher | undefined>; + + /** Matches an Object with the given keys; the value may also have other keys with arbitrary values. */ + function ObjectIncluding( + dico: T + ): Matcher>; + + /** Matches any value that matches at least one of the provided patterns. */ + function OneOf( + ...patterns: T + ): Matcher>; + + /** + * Calls the function condition with the value as the argument. If condition returns true, this matches. If condition throws a `Match.Error` or returns false, this fails. If condition throws + * any other error, that error is thrown from the call to `check` or `Match.test`. + */ + function Where(condition: (val: any) => val is T): Matcher; + function Where(condition: (val: any) => boolean): Matcher; + + /** + * Returns true if the value matches the pattern. + * @param value The value to check + * @param pattern The pattern to match `value` against + */ + function test( + value: any, + pattern: T + ): value is PatternMatch; +} + +/** + * Check that a value matches a pattern. + * If the value does not match the pattern, throw a `Match.Error`. + * + * Particularly useful to assert that arguments to a function have the right + * types and structure. + * @param value The value to check + * @param pattern The pattern to match `value` against + */ +export declare function check( + value: any, + pattern: T +): asserts value is Match.PatternMatch; diff --git a/packages/check/package-types.json b/packages/check/package-types.json new file mode 100644 index 0000000000..19e3d36ba9 --- /dev/null +++ b/packages/check/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "check.d.ts" +} diff --git a/packages/check/package.js b/packages/check/package.js index ee260f6f24..c2ab8cecd9 100644 --- a/packages/check/package.js +++ b/packages/check/package.js @@ -1,12 +1,14 @@ Package.describe({ summary: 'Check whether a value matches a pattern', - version: '1.3.1', + version: '1.3.2-beta.1', }); Package.onUse(api => { api.use('ecmascript'); api.use('ejson'); + api.addAssets('check.d.ts', 'server'); + api.mainModule('match.js'); api.export('check'); diff --git a/packages/ddp-client/package.js b/packages/ddp-client/package.js index 7b9eef3eb6..6bd131ffd3 100644 --- a/packages/ddp-client/package.js +++ b/packages/ddp-client/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Meteor's latency-compensated distributed data client", - version: '2.6.1-beta.0', + version: '2.6.1-beta.1', documentation: null }); diff --git a/packages/ddp-rate-limiter/ddp-rate-limiter.d.ts b/packages/ddp-rate-limiter/ddp-rate-limiter.d.ts new file mode 100644 index 0000000000..fbce221f5a --- /dev/null +++ b/packages/ddp-rate-limiter/ddp-rate-limiter.d.ts @@ -0,0 +1,17 @@ +export namespace DDPRateLimiter { + interface Matcher { + type?: string | ((type: string) => boolean) | undefined; + name?: string | ((name: string) => boolean) | undefined; + userId?: string | ((userId: string) => boolean) | undefined; + connectionId?: string | ((connectionId: string) => boolean) | undefined; + clientAddress?: string | ((clientAddress: string) => boolean) | undefined; + } + + function addRule( + matcher: Matcher, + numRequests: number, + timeInterval: number + ): string; + + function removeRule(ruleId: string): boolean; +} diff --git a/packages/ddp-rate-limiter/package-types.json b/packages/ddp-rate-limiter/package-types.json new file mode 100644 index 0000000000..34869b7735 --- /dev/null +++ b/packages/ddp-rate-limiter/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "ddp-rate-limiter.d.ts" +} diff --git a/packages/ddp-rate-limiter/package.js b/packages/ddp-rate-limiter/package.js index a38d55936e..b2a63f9da3 100644 --- a/packages/ddp-rate-limiter/package.js +++ b/packages/ddp-rate-limiter/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'ddp-rate-limiter', - version: '1.1.0', + version: '1.1.0-beta.1', // Brief, one-line summary of the package. summary: 'The DDPRateLimiter allows users to add rate limits to DDP' + ' methods and subscriptions.', @@ -14,6 +14,7 @@ Package.describe({ Package.onUse(function(api) { api.use('rate-limit', 'server'); api.use('ecmascript'); + api.addAssets('ddp-rate-limiter.d.ts', 'server'); api.export('DDPRateLimiter', 'server'); api.mainModule('ddp-rate-limiter.js', 'server'); }); diff --git a/packages/ddp/ddp.d.ts b/packages/ddp/ddp.d.ts new file mode 100644 index 0000000000..199adb3d55 --- /dev/null +++ b/packages/ddp/ddp.d.ts @@ -0,0 +1,65 @@ +import { Meteor } from 'meteor/meteor'; + +export namespace DDP { + interface DDPStatic { + subscribe(name: string, ...rest: any[]): Meteor.SubscriptionHandle; + call(method: string, ...parameters: any[]): any; + apply(method: string, ...parameters: any[]): any; + methods(IMeteorMethodsDictionary: any): any; + status(): DDPStatus; + reconnect(): void; + disconnect(): void; + onReconnect(): void; + } + + function _allSubscriptionsReady(): boolean; + + type Status = 'connected' | 'connecting' | 'failed' | 'waiting' | 'offline'; + + interface DDPStatus { + connected: boolean; + status: Status; + retryCount: number; + retryTime?: number | undefined; + reason?: string | undefined; + } + + function connect(url: string): DDPStatic; +} + +export namespace DDPCommon { + interface MethodInvocationOptions { + userId: string | null; + setUserId?: ((newUserId: string) => void) | undefined; + isSimulation: boolean; + connection: Meteor.Connection; + randomSeed: string; + } + + /** The state for a single invocation of a method, referenced by this inside a method definition. */ + interface MethodInvocation { + new (options: MethodInvocationOptions): MethodInvocation; + /** + * Call inside a method invocation. Allow subsequent method from this client to begin running in a new fiber. + */ + unblock(): void; + /** + * Set the logged in user. + * @param userId The value that should be returned by `userId` on this connection. + */ + setUserId(userId: string | null): void; + /** + * The id of the user that made this method call, or `null` if no user was logged in. + */ + userId: string | null; + /** + * Access inside a method invocation. Boolean value, true if this invocation is a stub. + */ + isSimulation: boolean; + /** + * Access inside a method invocation. The [connection](#meteor_onconnection) that this method was received on. `null` if the method is not associated with a connection, eg. a server + * initiated method call. Calls to methods made from a server method which was in turn initiated from the client share the same `connection`. + */ + connection: Meteor.Connection; + } +} diff --git a/packages/ddp/package-types.json b/packages/ddp/package-types.json new file mode 100644 index 0000000000..31646e57c4 --- /dev/null +++ b/packages/ddp/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "ddp.d.ts" +} diff --git a/packages/ddp/package.js b/packages/ddp/package.js index 49cace9e05..57d3a8f392 100644 --- a/packages/ddp/package.js +++ b/packages/ddp/package.js @@ -1,12 +1,14 @@ Package.describe({ summary: "Meteor's latency-compensated distributed data framework", - version: '1.4.0' + version: '1.4.0-beta.1' }); Package.onUse(function (api) { api.use(['ddp-client'], ['client', 'server']); api.use(['ddp-server'], 'server'); + api.addAssets('ddp.d.ts', 'server'); + api.export('DDP'); api.export('DDPServer', 'server'); diff --git a/packages/deprecated/jshint/.versions b/packages/deprecated/jshint/.versions index c5612a10eb..805d53d29e 100644 --- a/packages/deprecated/jshint/.versions +++ b/packages/deprecated/jshint/.versions @@ -5,7 +5,7 @@ base64@1.0.12 binary-heap@1.0.11 boilerplate-generator@1.7.1 callback-hook@1.3.0 -check@1.3.1 +check@1.3.2-beta.1 ddp@1.4.0 ddp-client@2.4.1 ddp-common@1.4.0 @@ -36,14 +36,14 @@ mongo-id@1.0.8 npm-mongo@3.9.0 ordered-dict@1.1.0 promise@0.11.2 -random@1.2.0 +random@1.2.1-beta.1 react-fast-refresh@0.1.1 reload@1.3.1 retry@1.1.0 routepolicy@1.1.0 socket-stream-client@0.3.3 tinytest@1.1.0 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.10.1 webapp-hashing@1.1.0 diff --git a/packages/diff-sequence/package.js b/packages/diff-sequence/package.js index e81b548ccf..724d07f5cc 100644 --- a/packages/diff-sequence/package.js +++ b/packages/diff-sequence/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "An implementation of a diff algorithm on arrays and objects.", - version: '1.1.2-beta.0', + version: '1.1.2-beta.1', documentation: null }); diff --git a/packages/ecmascript/package.js b/packages/ecmascript/package.js index a7db21c514..912d667c79 100644 --- a/packages/ecmascript/package.js +++ b/packages/ecmascript/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'ecmascript', - version: '0.16.3-beta.0', + version: '0.16.3-beta.1', summary: 'Compiler plugin that supports ES2015+ in all .js files', documentation: 'README.md', }); diff --git a/packages/ejson/package.js b/packages/ejson/package.js index 24754970e9..7bb97eaf35 100644 --- a/packages/ejson/package.js +++ b/packages/ejson/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: 'Extended and Extensible JSON library', - version: '1.1.3-beta.0' + version: '1.1.3-beta.1' }); Package.onUse(function onUse(api) { diff --git a/packages/email/email.d.ts b/packages/email/email.d.ts new file mode 100644 index 0000000000..71380d328e --- /dev/null +++ b/packages/email/email.d.ts @@ -0,0 +1,44 @@ +export namespace Email { + interface EmailOptions { + from?: string | undefined; + to?: string | string[] | undefined; + cc?: string | string[] | undefined; + bcc?: string | string[] | undefined; + replyTo?: string | string[] | undefined; + subject?: string | undefined; + text?: string | undefined; + html?: string | undefined; + headers?: Object | undefined; + attachments?: Object[] | undefined; + mailComposer?: MailComposer | undefined; + } + + interface CustomEmailOptions extends EmailOptions { + packageSettings?: unknown; + } + + function send(options: EmailOptions): void; + function hookSend(fn: (options: EmailOptions) => boolean): void; + function customTransport(fn: (options: CustomEmailOptions) => void): void; +} + +export interface MailComposerOptions { + escapeSMTP: boolean; + encoding: string; + charset: string; + keepBcc: boolean; + forceEmbeddedImages: boolean; +} + +export declare var MailComposer: MailComposerStatic; + +export interface MailComposerStatic { + new (options: MailComposerOptions): MailComposer; +} + +export interface MailComposer { + addHeader(name: string, value: string): void; + setMessageOption(from: string, to: string, body: string, html: string): void; + streamMessage(): void; + pipe(stream: any /** fs.WriteStream **/): void; +} diff --git a/packages/email/package-types.json b/packages/email/package-types.json new file mode 100644 index 0000000000..de228d2fc5 --- /dev/null +++ b/packages/email/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "email.d.ts" +} diff --git a/packages/email/package.js b/packages/email/package.js index 3fb07dae92..165485bef1 100644 --- a/packages/email/package.js +++ b/packages/email/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: 'Send email messages', - version: '2.2.1', + version: '2.2.1-beta.1', }); Npm.depends({ @@ -10,6 +10,7 @@ Npm.depends({ Package.onUse(function(api) { api.use(['ecmascript', 'logging', 'callback-hook'], 'server'); + api.addAssets('email.d.ts', 'server'); api.mainModule('email.js', 'server'); api.export(['Email', 'EmailInternals'], 'server'); api.export('EmailTest', 'server', { testOnly: true }); diff --git a/packages/facebook-oauth/package.js b/packages/facebook-oauth/package.js index db269c6ef9..c743758fa8 100644 --- a/packages/facebook-oauth/package.js +++ b/packages/facebook-oauth/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Facebook OAuth flow", - version: '1.11.1-beta.0' + version: '1.11.1-beta.1' }); Package.onUse(api => { diff --git a/packages/facts-ui/package.js b/packages/facts-ui/package.js index 7267d44a8e..af39e4abbc 100644 --- a/packages/facts-ui/package.js +++ b/packages/facts-ui/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Display internal app statistics", - version: '1.0.1-beta.0' + version: '1.0.1-beta.1' }); Package.onUse(function (api) { diff --git a/packages/fetch/package.js b/packages/fetch/package.js index b56e1265b8..ff7ae07f4f 100644 --- a/packages/fetch/package.js +++ b/packages/fetch/package.js @@ -1,6 +1,6 @@ Package.describe({ name: "fetch", - version: '0.1.2-beta.0', + version: '0.1.2-beta.1', summary: "Isomorphic modern/legacy/Node polyfill for WHATWG fetch()", documentation: "README.md" }); diff --git a/packages/geojson-utils/package.js b/packages/geojson-utils/package.js index 7bb6607532..27d9790229 100644 --- a/packages/geojson-utils/package.js +++ b/packages/geojson-utils/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: 'GeoJSON utility functions (from https://github.com/maxogden/geojson-js-utils)', - version: '1.0.11-beta.0' + version: '1.0.11-beta.1' }); Package.onUse(function (api) { diff --git a/packages/hot-module-replacement/hot-module-replacement.d.ts b/packages/hot-module-replacement/hot-module-replacement.d.ts new file mode 100644 index 0000000000..767262f3ac --- /dev/null +++ b/packages/hot-module-replacement/hot-module-replacement.d.ts @@ -0,0 +1,14 @@ +export interface Module { + readonly hot?: { + accept(): void; + decline(): void; + dispose(callback: (data: object) => void): void; + data: object | null; + onRequire(callbacks: { + before?(requiredModule: Module, parentId: string): T; + after?(requiredModule: Module, data: T): void; + }): void; + }; +} + +export declare var module: NodeJS.Module; diff --git a/packages/hot-module-replacement/package-types.json b/packages/hot-module-replacement/package-types.json new file mode 100644 index 0000000000..b11c5dadfe --- /dev/null +++ b/packages/hot-module-replacement/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "hot-module-replacement.d.ts" +} diff --git a/packages/hot-module-replacement/package.js b/packages/hot-module-replacement/package.js index 2d92f97b09..e25f30ec79 100644 --- a/packages/hot-module-replacement/package.js +++ b/packages/hot-module-replacement/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'hot-module-replacement', - version: '0.5.1', + version: '0.5.1-beta.1', summary: 'Update code in development without reloading the page', documentation: 'README.md', debugOnly: true, @@ -11,6 +11,8 @@ Package.onUse(function(api) { api.use('meteor'); api.use('hot-code-push', { unordered: true }); + api.addAssets('hot-module-replacement.d.ts', 'server'); + // Provides polyfills needed by Meteor.absoluteUrl in legacy browsers api.use('ecmascript-runtime-client', { weak: true }); diff --git a/packages/meteor-tool/package.js b/packages/meteor-tool/package.js index 68565fa34c..e5c8ded7c7 100644 --- a/packages/meteor-tool/package.js +++ b/packages/meteor-tool/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: 'The Meteor command-line tool', - version: '2.8.1-beta.0', + version: '2.8.1-beta.1', }); Package.includeTool(); diff --git a/packages/meteor/meteor.d.ts b/packages/meteor/meteor.d.ts new file mode 100644 index 0000000000..0a482c0aa9 --- /dev/null +++ b/packages/meteor/meteor.d.ts @@ -0,0 +1,504 @@ +import { Mongo } from 'meteor/mongo'; +import { EJSONable, EJSONableProperty } from 'meteor/ejson'; +import { Blaze } from 'meteor/blaze'; +import { DDP } from 'meteor/ddp'; + +export type global_Error = Error; + +export namespace Meteor { + /** Global props **/ + /** True if running in client environment. */ + var isClient: boolean; + /** True if running in a Cordova mobile environment. */ + var isCordova: boolean; + /** True if running in server environment. */ + var isServer: boolean; + /** True if running in production environment. */ + var isProduction: boolean; + /** + * `Meteor.release` is a string containing the name of the release with which the project was built (for example, `"1.2.3"`). It is `undefined` if the project was built using a git checkout + * of Meteor. + */ + var release: string; + /** Global props **/ + + /** Settings **/ + interface Settings { + public: { [id: string]: any }; + [id: string]: any; + } + /** + * `Meteor.settings` contains deployment-specific configuration options. You can initialize settings by passing the `--settings` option (which takes the name of a file containing JSON data) + * to `meteor run` or `meteor deploy`. When running your server directly (e.g. from a bundle), you instead specify settings by putting the JSON directly into the `METEOR_SETTINGS` environment + * variable. If the settings object contains a key named `public`, then `Meteor.settings.public` will be available on the client as well as the server. All other properties of + * `Meteor.settings` are only defined on the server. You can rely on `Meteor.settings` and `Meteor.settings.public` being defined objects (not undefined) on both client and server even if + * there are no settings specified. Changes to `Meteor.settings.public` at runtime will be picked up by new client connections. + */ + var settings: Settings; + /** Settings **/ + + /** User **/ + interface UserEmail { + address: string; + verified: boolean; + } + /** + * UserProfile is left intentionally underspecified here, to allow you + * to override it in your application (but keep in mind that the default + * Meteor configuration allows users to write directly to their user + * record's profile field) + */ + interface UserProfile {} + interface User { + _id: string; + username?: string | undefined; + emails?: UserEmail[] | undefined; + createdAt?: Date | undefined; + profile?: UserProfile; + services?: any; + } + + function user(options?: { + fields?: Mongo.FieldSpecifier | undefined; + }): User | null; + + function userId(): string | null; + var users: Mongo.Collection; + /** User **/ + + /** Error **/ + /** + * This class represents a symbolic error thrown by a method. + */ + var Error: ErrorStatic; + interface ErrorStatic { + /** + * @param error A string code uniquely identifying this kind of error. + * This string should be used by callers of the method to determine the + * appropriate action to take, instead of attempting to parse the reason + * or details fields. For example: + * + * ``` + * // on the server, pick a code unique to this error + * // the reason field should be a useful debug message + * throw new Meteor.Error("logged-out", + * "The user must be logged in to post a comment."); + * + * // on the client + * Meteor.call("methodName", function (error) { + * // identify the error + * if (error && error.error === "logged-out") { + * // show a nice error message + * Session.set("errorMessage", "Please log in to post a comment."); + * } + * }); + * ``` + * + * For legacy reasons, some built-in Meteor functions such as `check` throw + * errors with a number in this field. + * + * @param reason Optional. A short human-readable summary of the + * error, like 'Not Found'. + * @param details Optional. Additional information about the error, + * like a textual stack trace. + */ + new (error: string | number, reason?: string, details?: string): Error; + } + interface Error extends global_Error { + error: string | number; + reason?: string | undefined; + details?: string | undefined; + } + var TypedError: TypedErrorStatic; + interface TypedErrorStatic { + new (message: string, errorType: string): TypedError; + } + interface TypedError extends global_Error { + message: string; + errorType: string; + } + /** Error **/ + + /** Method **/ + interface MethodThisType { + /** Access inside a method invocation. Boolean value, true if this invocation is a stub. */ + isSimulation: boolean; + /** The id of the user that made this method call, or `null` if no user was logged in. */ + userId: string | null; + /** + * Access inside a method invocation. The connection that this method was received on. `null` if the method is not associated with a connection, eg. a server initiated method call. Calls + * to methods made from a server method which was in turn initiated from the client share the same `connection`. */ + connection: Connection | null; + /** + * Set the logged in user. + * @param userId The value that should be returned by `userId` on this connection. + */ + setUserId(userId: string | null): void; + /** Call inside a method invocation. Allow subsequent method from this client to begin running in a new fiber. */ + unblock(): void; + } + + /** + * Defines functions that can be invoked over the network by clients. + * @param methods Dictionary whose keys are method names and values are functions. + */ + function methods(methods: { + [key: string]: (this: MethodThisType, ...args: any[]) => any; + }): void; + + /** + * Invokes a method passing any number of arguments. + * @param name Name of method to invoke + * @param args Optional method arguments + */ + function call(name: string, ...args: any[]): any; + + function apply< + Result extends + | EJSONable + | EJSONable[] + | EJSONableProperty + | EJSONableProperty[] + >( + name: string, + args: ReadonlyArray, + options?: { + wait?: boolean | undefined; + onResultReceived?: + | (( + error: global_Error | Meteor.Error | undefined, + result?: Result + ) => void) + | undefined; + /** + * (Client only) if true, don't send this method again on reload, simply call the callback an error with the error code 'invocation-failed'. + */ + noRetry?: boolean | undefined; + returnStubValue?: boolean | undefined; + throwStubExceptions?: boolean | undefined; + }, + asyncCallback?: ( + error: global_Error | Meteor.Error | undefined, + result?: Result + ) => void + ): any; + /** Method **/ + + /** Url **/ + /** + * Generate an absolute URL pointing to the application. The server reads from the `ROOT_URL` environment variable to determine where it is running. This is taken care of automatically for + * apps deployed to Galaxy, but must be provided when using `meteor build`. + */ + var absoluteUrl: { + /** + * @param path A path to append to the root URL. Do not include a leading "`/`". + */ + (path?: string, options?: absoluteUrlOptions): string; + defaultOptions: absoluteUrlOptions; + }; + + interface absoluteUrlOptions { + /** Create an HTTPS URL. */ + secure?: boolean | undefined; + /** Replace localhost with 127.0.0.1. Useful for services that don't recognize localhost as a domain name. */ + replaceLocalhost?: boolean | undefined; + /** Override the default ROOT_URL from the server environment. For example: "`http://foo.example.com`" */ + rootUrl?: string | undefined; + } + /** Url **/ + + /** Timeout **/ + /** + * Call a function repeatedly, with a time delay between calls. + * @param func The function to run + * @param delay Number of milliseconds to wait between each function call. + */ + function setInterval(func: Function, delay: number): number; + + /** + * Call a function in the future after waiting for a specified delay. + * @param func The function to run + * @param delay Number of milliseconds to wait before calling function + */ + function setTimeout(func: Function, delay: number): number; + /** + * Cancel a repeating function call scheduled by `Meteor.setInterval`. + * @param id The handle returned by `Meteor.setInterval` + */ + function clearInterval(id: number): void; + + /** + * Cancel a function call scheduled by `Meteor.setTimeout`. + * @param id The handle returned by `Meteor.setTimeout` + */ + function clearTimeout(id: number): void; + /** + * Defer execution of a function to run asynchronously in the background (similar to `Meteor.setTimeout(func, 0)`. + * @param func The function to run + */ + function defer(func: Function): void; + /** Timeout **/ + + /** utils **/ + /** + * Run code when a client or a server starts. + * @param func A function to run on startup. + */ + function startup(func: Function): void; + + /** + * Wrap a function that takes a callback function as its final parameter. + * The signature of the callback of the wrapped function should be `function(error, result){}`. + * On the server, the wrapped function can be used either synchronously (without passing a callback) or asynchronously + * (when a callback is passed). On the client, a callback is always required; errors will be logged if there is no callback. + * If a callback is provided, the environment captured when the original function was called will be restored in the callback. + * The parameters of the wrapped function must not contain any optional parameters or be undefined, as the callback function is expected to be the final, non-undefined parameter. + * @param func A function that takes a callback as its final parameter + * @param context Optional `this` object against which the original function will be invoked + */ + function wrapAsync(func: Function, context?: Object): any; + + function bindEnvironment(func: TFunc): TFunc; + + class EnvironmentVariable { + readonly slot: number; + constructor(); + get(): T; + getOrNullIfOutsideFiber(): T | null; + withValue(value: T, fn: () => U): U; + } + /** utils **/ + + /** Pub/Sub **/ + interface SubscriptionHandle { + /** Cancel the subscription. This will typically result in the server directing the client to remove the subscription’s data from the client’s cache. */ + stop(): void; + /** True if the server has marked the subscription as ready. A reactive data source. */ + ready(): boolean; + } + interface LiveQueryHandle { + stop(): void; + } + /** Pub/Sub **/ +} + +export namespace Meteor { + /** Login **/ + interface LoginWithExternalServiceOptions { + requestPermissions?: ReadonlyArray | undefined; + requestOfflineToken?: Boolean | undefined; + forceApprovalPrompt?: Boolean | undefined; + loginUrlParameters?: Object | undefined; + redirectUrl?: string | undefined; + loginHint?: string | undefined; + loginStyle?: string | undefined; + } + + function loginWithMeteorDeveloperAccount( + options?: Meteor.LoginWithExternalServiceOptions, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWithFacebook( + options?: Meteor.LoginWithExternalServiceOptions, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWithGithub( + options?: Meteor.LoginWithExternalServiceOptions, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWithGoogle( + options?: Meteor.LoginWithExternalServiceOptions, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWithMeetup( + options?: Meteor.LoginWithExternalServiceOptions, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWithTwitter( + options?: Meteor.LoginWithExternalServiceOptions, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWithWeibo( + options?: Meteor.LoginWithExternalServiceOptions, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWith( + options?: { + requestPermissions?: ReadonlyArray | undefined; + requestOfflineToken?: boolean | undefined; + loginUrlParameters?: Object | undefined; + userEmail?: string | undefined; + loginStyle?: string | undefined; + redirectUrl?: string | undefined; + }, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWithPassword( + user: Object | string, + password: string, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loginWithToken( + token: string, + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function loggingIn(): boolean; + + function loggingOut(): boolean; + + function logout( + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + + function logoutOtherClients( + callback?: (error?: global_Error | Meteor.Error | Meteor.TypedError) => void + ): void; + /** Login **/ + + /** Event **/ + 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; + } + /** Event **/ + + /** Connection **/ + function reconnect(): void; + + function disconnect(): void; + /** Connection **/ + + /** Status **/ + function status(): DDP.DDPStatus; + /** Status **/ + + /** Pub/Sub **/ + /** + * Subscribe to a record set. Returns a handle that provides + * `stop()` and `ready()` methods. + * @param name Name of the subscription. Matches the name of the + * server's `publish()` call. + * @param args Optional arguments passed to publisher + * function on server. + * @param callbacks Optional. May include `onStop` + * and `onReady` callbacks. If there is an error, it is passed as an + * argument to `onStop`. If a function is passed instead of an object, it + * is interpreted as an `onReady` callback. + */ + function subscribe(name: string, ...args: any[]): Meteor.SubscriptionHandle; + /** Pub/Sub **/ +} + +export namespace Meteor { + /** Connection **/ + interface Connection { + id: string; + close: () => void; + onClose: (callback: () => void) => void; + clientAddress: string; + httpHeaders: Object; + } + + function onConnection(callback: (connection: Connection) => void): void; + /** Connection **/ + /** + * Publish a record set. + * @param name If String, name of the record set. If Object, publications Dictionary of publish functions by name. 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. + */ + function publish( + name: string | null, + func: (this: Subscription, ...args: any[]) => void, + options?: { is_auto: boolean } + ): void; + + function _debug(...args: any[]): void; +} + +export interface Subscription { + /** + * Call inside the publish function. Informs the subscriber that a document has been added to the record set. + * @param collection The name of the collection that contains the new document. + * @param id The new document's ID. + * @param fields The fields in the new document. If `_id` is present it is ignored. + */ + added(collection: string, id: string, fields: Object): void; + /** + * Call inside the publish function. Informs the subscriber that a document in the record set has been modified. + * @param collection The name of the collection that contains the changed document. + * @param id The changed document's ID. + * @param fields The fields in the document that have changed, together with their new values. If a field is not present in `fields` it was left unchanged; if it is present in `fields` and + * has a value of `undefined` it was removed from the document. If `_id` is present it is ignored. + */ + changed(collection: string, id: string, fields: Object): void; + /** Access inside the publish function. The incoming connection for this subscription. */ + connection: Meteor.Connection; + /** + * Call inside the publish function. Stops this client's subscription, triggering a call on the client to the `onStop` callback passed to `Meteor.subscribe`, if any. If `error` is not a + * `Meteor.Error`, it will be sanitized. + * @param error The error to pass to the client. + */ + error(error: Error): void; + /** + * Call inside the publish function. Registers a callback function to run when the subscription is stopped. + * @param func The callback function + */ + onStop(func: Function): void; + /** + * Call inside the publish function. Informs the subscriber that an initial, complete snapshot of the record set has been sent. This will trigger a call on the client to the `onReady` + * callback passed to `Meteor.subscribe`, if any. + */ + ready(): void; + /** + * Call inside the publish function. Informs the subscriber that a document has been removed from the record set. + * @param collection The name of the collection that the document has been removed from. + * @param id The ID of the document that has been removed. + */ + removed(collection: string, id: string): void; + /** + * Access inside the publish function. The incoming connection for this subscription. + */ + stop(): void; + /** + * Call inside the publish function. Allows subsequent methods or subscriptions for the client of this subscription + * to begin running without waiting for the publishing to become ready. + */ + unblock(): void; + /** Access inside the publish function. The id of the logged-in user, or `null` if no user is logged in. */ + userId: string | null; +} + +export namespace Meteor { + /** Global props **/ + /** True if running in development environment. */ + var isDevelopment: boolean; + var isTest: boolean; + var isAppTest: boolean; + /** Global props **/ +} diff --git a/packages/meteor/package-types.json b/packages/meteor/package-types.json new file mode 100644 index 0000000000..bc20149ad0 --- /dev/null +++ b/packages/meteor/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "meteor.d.ts" +} diff --git a/packages/meteor/package.js b/packages/meteor/package.js index 98e5453a3c..d5a6bba164 100644 --- a/packages/meteor/package.js +++ b/packages/meteor/package.js @@ -2,7 +2,7 @@ Package.describe({ summary: "Core Meteor environment", - version: '1.10.1' + version: '1.10.1-beta.1' }); Package.registerBuildPlugin({ @@ -54,6 +54,8 @@ Package.onUse(function (api) { // People expect process.exit() to not swallow console output. // On Windows, it sometimes does, so we fix it for all apps and packages api.addFiles('flush-buffers-on-exit-in-windows.js', 'server'); + + api.addAssets('meteor.d.ts', 'server'); }); Package.onTest(function (api) { diff --git a/packages/modern-browsers/modern.d.ts b/packages/modern-browsers/modern.d.ts new file mode 100644 index 0000000000..69f1268f74 --- /dev/null +++ b/packages/modern-browsers/modern.d.ts @@ -0,0 +1,4 @@ +export declare function setMinimumBrowserVersions( + versions: Record, + source: string +): void; diff --git a/packages/modern-browsers/package-types.json b/packages/modern-browsers/package-types.json new file mode 100644 index 0000000000..ee517974a2 --- /dev/null +++ b/packages/modern-browsers/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "modern.d.ts" +} diff --git a/packages/modern-browsers/package.js b/packages/modern-browsers/package.js index 40e95833a3..f036e318d4 100644 --- a/packages/modern-browsers/package.js +++ b/packages/modern-browsers/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'modern-browsers', - version: '0.1.8', + version: '0.1.8-beta.1', summary: 'API for defining the boundary between modern and legacy ' + 'JavaScript clients', @@ -10,6 +10,7 @@ Package.describe({ Package.onUse(function(api) { api.use('modules'); api.mainModule('modern.js', 'server'); + api.addAssets('modern.d.ts', 'server'); }); Package.onTest(function(api) { diff --git a/packages/modules-runtime-hot/package.js b/packages/modules-runtime-hot/package.js index 4d303badb3..e06c2b1892 100644 --- a/packages/modules-runtime-hot/package.js +++ b/packages/modules-runtime-hot/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'modules-runtime-hot', - version: '0.14.1-beta.0', + version: '0.14.1-beta.1', summary: 'Patches modules-runtime to support Hot Module Replacement', git: 'https://github.com/benjamn/install', documentation: 'README.md', diff --git a/packages/modules-runtime/package.js b/packages/modules-runtime/package.js index 66b80c028e..8253f2ecdd 100644 --- a/packages/modules-runtime/package.js +++ b/packages/modules-runtime/package.js @@ -1,6 +1,6 @@ Package.describe({ name: "modules-runtime", - version: '0.13.2-beta.0', + version: '0.13.2-beta.1', summary: "CommonJS module system", git: "https://github.com/benjamn/install", documentation: "README.md" diff --git a/packages/mongo/mongo.d.ts b/packages/mongo/mongo.d.ts new file mode 100644 index 0000000000..43e8e9c3e7 --- /dev/null +++ b/packages/mongo/mongo.d.ts @@ -0,0 +1,598 @@ +import * as MongoNpmModule from 'mongodb'; +import { + Collection as MongoCollection, + CreateIndexesOptions, + Db as MongoDb, + Hint, + IndexSpecification, + MongoClient, +} from 'mongodb'; +import { Meteor } from 'meteor/meteor'; + +// Based on https://github.com/microsoft/TypeScript/issues/28791#issuecomment-443520161 +export type UnionOmit = T extends T + ? Pick> + : never; + +export namespace Mongo { + // prettier-ignore + type BsonType = 1 | "double" | + 2 | "string" | + 3 | "object" | + 4 | "array" | + 5 | "binData" | + 6 | "undefined" | + 7 | "objectId" | + 8 | "bool" | + 9 | "date" | + 10 | "null" | + 11 | "regex" | + 12 | "dbPointer" | + 13 | "javascript" | + 14 | "symbol" | + 15 | "javascriptWithScope" | + 16 | "int" | + 17 | "timestamp" | + 18 | "long" | + 19 | "decimal" | + -1 | "minKey" | + 127 | "maxKey" | "number"; + + type FieldExpression = { + $eq?: T | undefined; + $gt?: T | undefined; + $gte?: T | undefined; + $lt?: T | undefined; + $lte?: T | undefined; + $in?: T[] | undefined; + $nin?: T[] | undefined; + $ne?: T | undefined; + $exists?: boolean | undefined; + $type?: BsonType[] | BsonType | undefined; + $not?: FieldExpression | undefined; + $expr?: FieldExpression | undefined; + $jsonSchema?: any; + $mod?: number[] | undefined; + $regex?: RegExp | string | undefined; + $options?: string | undefined; + $text?: + | { + $search: string; + $language?: string | undefined; + $caseSensitive?: boolean | undefined; + $diacriticSensitive?: boolean | undefined; + } + | undefined; + $where?: string | Function | undefined; + $geoIntersects?: any; + $geoWithin?: any; + $near?: any; + $nearSphere?: any; + $all?: T[] | undefined; + $elemMatch?: T extends {} ? Query : FieldExpression | undefined; + $size?: number | undefined; + $bitsAllClear?: any; + $bitsAllSet?: any; + $bitsAnyClear?: any; + $bitsAnySet?: any; + $comment?: string | undefined; + }; + + type Flatten = T extends any[] ? T[0] : T; + + type Query = { + [P in keyof T]?: Flatten | RegExp | FieldExpression>; + } & { + $or?: Query[] | undefined; + $and?: Query[] | undefined; + $nor?: Query[] | undefined; + } & Dictionary; + + type QueryWithModifiers = { + $query: Query; + $comment?: string | undefined; + $explain?: any; + $hint?: Hint; + $maxScan?: any; + $max?: any; + $maxTimeMS?: any; + $min?: any; + $orderby?: any; + $returnKey?: any; + $showDiskLoc?: any; + $natural?: any; + }; + + type Selector = Query | QueryWithModifiers; + + type Dictionary = { [key: string]: T }; + type PartialMapTo = Partial>; + type OnlyArrays = T extends any[] ? T : never; + type OnlyElementsOfArrays = T extends any[] ? Partial : never; + type ElementsOf = { + [P in keyof T]?: OnlyElementsOfArrays; + }; + type PushModifier = { + [P in keyof T]?: + | OnlyElementsOfArrays + | { + $each?: T[P] | undefined; + $position?: number | undefined; + $slice?: number | undefined; + $sort?: 1 | -1 | Dictionary | undefined; + }; + }; + type ArraysOrEach = { + [P in keyof T]?: OnlyElementsOfArrays | { $each: T[P] }; + }; + type CurrentDateModifier = { $type: 'timestamp' | 'date' } | true; + type Modifier = + | T + | { + $currentDate?: + | (Partial> & + Dictionary) + | undefined; + $inc?: (PartialMapTo & Dictionary) | undefined; + $min?: + | (PartialMapTo & Dictionary) + | undefined; + $max?: + | (PartialMapTo & Dictionary) + | undefined; + $mul?: (PartialMapTo & Dictionary) | undefined; + $rename?: (PartialMapTo & Dictionary) | undefined; + $set?: (Partial & Dictionary) | undefined; + $setOnInsert?: (Partial & Dictionary) | undefined; + $unset?: + | (PartialMapTo & Dictionary) + | undefined; + $addToSet?: (ArraysOrEach & Dictionary) | undefined; + $push?: (PushModifier & Dictionary) | undefined; + $pull?: (ElementsOf & Dictionary) | undefined; + $pullAll?: (Partial & Dictionary) | undefined; + $pop?: (PartialMapTo & Dictionary<1 | -1>) | undefined; + }; + + type OptionalId = UnionOmit & { _id?: any }; + + interface SortSpecifier {} + interface FieldSpecifier { + [id: string]: Number; + } + + type Transform = ((doc: T) => any) | null | undefined; + + type Options = { + /** Sort order (default: natural order) */ + sort?: SortSpecifier | undefined; + /** Number of results to skip at the beginning */ + skip?: number | undefined; + /** Maximum number of results to return */ + limit?: number | undefined; + /** Dictionary of fields to return or exclude. */ + fields?: FieldSpecifier | undefined; + /** (Server only) Overrides MongoDB's default index selection and query optimization process. Specify an index to force its use, either by its name or index specification. */ + hint?: Hint | undefined; + /** (Client only) Default `true`; pass `false` to disable reactivity */ + reactive?: boolean | undefined; + /** Overrides `transform` on the [`Collection`](#collections) for this cursor. Pass `null` to disable transformation. */ + transform?: Transform | undefined; + }; + + type DispatchTransform = Transform extends ( + ...args: any + ) => any + ? ReturnType + : Transform extends null + ? T + : U; + + var Collection: CollectionStatic; + interface CollectionStatic { + /** + * Constructor for a Collection + * @param name The name of the collection. If null, creates an unmanaged (unsynchronized) local collection. + */ + new ( + name: string | null, + options?: { + /** + * The server connection that will manage this collection. Uses the default connection if not specified. Pass the return value of calling `DDP.connect` to specify a different + * server. Pass `null` to specify no connection. Unmanaged (`name` is null) collections cannot specify a connection. + */ + connection?: Object | null | undefined; + /** The method of generating the `_id` fields of new documents in this collection. Possible values: + * - **`'STRING'`**: random strings + * - **`'MONGO'`**: random [`Mongo.ObjectID`](#mongo_object_id) values + * + * The default id generation technique is `'STRING'`. + */ + idGeneration?: string | undefined; + /** + * An optional transformation function. Documents will be passed through this function before being returned from `fetch` or `findOne`, and before being passed to callbacks of + * `observe`, `map`, `forEach`, `allow`, and `deny`. Transforms are *not* applied for the callbacks of `observeChanges` or to cursors returned from publish functions. + */ + transform?: (doc: T) => U; + /** Set to `false` to skip setting up the mutation methods that enable insert/update/remove from client code. Default `true`. */ + defineMutationMethods?: boolean | undefined; + } + ): Collection; + } + interface Collection { + allow = undefined>(options: { + insert?: + | ((userId: string, doc: DispatchTransform) => boolean) + | undefined; + update?: + | (( + userId: string, + doc: DispatchTransform, + fieldNames: string[], + modifier: any + ) => boolean) + | undefined; + remove?: + | ((userId: string, doc: DispatchTransform) => boolean) + | undefined; + fetch?: string[] | undefined; + transform?: Fn | undefined; + }): boolean; + createCappedCollectionAsync( + byteSize?: number, + maxDocuments?: number + ): Promise; + createIndex( + indexSpec: IndexSpecification, + options?: CreateIndexesOptions + ): void; + createIndexAsync( + indexSpec: IndexSpecification, + options?: CreateIndexesOptions + ): Promise; + deny = undefined>(options: { + insert?: + | ((userId: string, doc: DispatchTransform) => boolean) + | undefined; + update?: + | (( + userId: string, + doc: DispatchTransform, + fieldNames: string[], + modifier: any + ) => boolean) + | undefined; + remove?: + | ((userId: string, doc: DispatchTransform) => boolean) + | undefined; + fetch?: string[] | undefined; + transform?: Fn | undefined; + }): boolean; + dropCollectionAsync(): Promise; + dropIndexAsync(indexName: string): void; + /** + * Find the documents in a collection that match the selector. + * @param selector A query describing the documents to find + */ + find(selector?: Selector | ObjectID | string): Cursor; + /** + * Find the documents in a collection that match the selector. + * @param selector A query describing the documents to find + */ + find>( + selector?: Selector | ObjectID | string, + options?: O + ): Cursor>; + /** + * Finds the first document that matches the selector, as ordered by sort and skip options. Returns `undefined` if no matching document is found. + * @param selector A query describing the documents to find + */ + findOne(selector?: Selector | ObjectID | string): U | undefined; + /** + * Finds the first document that matches the selector, as ordered by sort and skip options. Returns `undefined` if no matching document is found. + * @param selector A query describing the documents to find + */ + findOne, 'limit'>>( + selector?: Selector | ObjectID | string, + options?: O + ): DispatchTransform | undefined; + /** + * Finds the first document that matches the selector, as ordered by sort and skip options. Returns `undefined` if no matching document is found. + * @param selector A query describing the documents to find + */ + findOneAsync( + selector?: Selector | ObjectID | string + ): Promise; + /** + * Finds the first document that matches the selector, as ordered by sort and skip options. Returns `undefined` if no matching document is found. + * @param selector A query describing the documents to find + */ + findOneAsync, 'limit'>>( + selector?: Selector | ObjectID | string, + options?: O + ): Promise | undefined>; + /** + * Insert a document in the collection. Returns its unique _id. + * @param doc The document to insert. May not yet have an _id attribute, in which case Meteor will generate one for you. + * @param callback If present, called with an error object as the first argument and, if no error, the _id as the second. + */ + insert(doc: OptionalId, callback?: Function): string; + /** + * Insert a document in the collection. Returns its unique _id. + * @param doc The document to insert. May not yet have an _id attribute, in which case Meteor will generate one for you. + * @param callback If present, called with an error object as the first argument and, if no error, the _id as the second. + */ + insertAsync(doc: OptionalId, callback?: Function): Promise; + /** + * Returns the [`Collection`](http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html) object corresponding to this collection from the + * [npm `mongodb` driver module](https://www.npmjs.com/package/mongodb) which is wrapped by `Mongo.Collection`. + */ + rawCollection(): MongoCollection; + /** + * Returns the [`Db`](http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html) object corresponding to this collection's database connection from the + * [npm `mongodb` driver module](https://www.npmjs.com/package/mongodb) which is wrapped by `Mongo.Collection`. + */ + rawDatabase(): MongoDb; + /** + * Remove documents from the collection + * @param selector Specifies which documents to remove + * @param callback If present, called with an error object as its argument. + */ + remove( + selector: Selector | ObjectID | string, + callback?: Function + ): number; + /** + * Remove documents from the collection + * @param selector Specifies which documents to remove + * @param callback If present, called with an error object as its argument. + */ + removeAsync( + selector: Selector | ObjectID | string, + callback?: Function + ): Promise; + /** + * Modify one or more documents in the collection. Returns the number of matched documents. + * @param selector Specifies which documents to modify + * @param modifier Specifies how to modify the documents + * @param callback If present, called with an error object as the first argument and, if no error, the number of affected documents as the second. + */ + update( + selector: Selector | ObjectID | string, + modifier: Modifier, + options?: { + /** True to modify all matching documents; false to only modify one of the matching documents (the default). */ + multi?: boolean | undefined; + /** True to insert a document if no matching documents are found. */ + upsert?: boolean | undefined; + /** + * Used in combination with MongoDB [filtered positional operator](https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/) to specify which elements to + * modify in an array field. + */ + arrayFilters?: { [identifier: string]: any }[] | undefined; + }, + callback?: Function + ): number; + /** + * Modify one or more documents in the collection. Returns the number of matched documents. + * @param selector Specifies which documents to modify + * @param modifier Specifies how to modify the documents + * @param callback If present, called with an error object as the first argument and, if no error, the number of affected documents as the second. + */ + updateAsync( + selector: Selector | ObjectID | string, + modifier: Modifier, + options?: { + /** True to modify all matching documents; false to only modify one of the matching documents (the default). */ + multi?: boolean | undefined; + /** True to insert a document if no matching documents are found. */ + upsert?: boolean | undefined; + /** + * Used in combination with MongoDB [filtered positional operator](https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/) to specify which elements to + * modify in an array field. + */ + arrayFilters?: { [identifier: string]: any }[] | undefined; + }, + callback?: Function + ): Promise; + /** + * Modify one or more documents in the collection, or insert one if no matching documents were found. Returns an object with keys `numberAffected` (the number of documents modified) and + * `insertedId` (the unique _id of the document that was inserted, if any). + * @param selector Specifies which documents to modify + * @param modifier Specifies how to modify the documents + * @param callback If present, called with an error object as the first argument and, if no error, the number of affected documents as the second. + */ + upsert( + selector: Selector | ObjectID | string, + modifier: Modifier, + options?: { + /** True to modify all matching documents; false to only modify one of the matching documents (the default). */ + multi?: boolean | undefined; + }, + callback?: Function + ): { + numberAffected?: number | undefined; + insertedId?: string | undefined; + }; + /** + * Modify one or more documents in the collection, or insert one if no matching documents were found. Returns an object with keys `numberAffected` (the number of documents modified) and + * `insertedId` (the unique _id of the document that was inserted, if any). + * @param selector Specifies which documents to modify + * @param modifier Specifies how to modify the documents + * @param callback If present, called with an error object as the first argument and, if no error, the number of affected documents as the second. + */ + upsertAsync( + selector: Selector | ObjectID | string, + modifier: Modifier, + options?: { + /** True to modify all matching documents; false to only modify one of the matching documents (the default). */ + multi?: boolean | undefined; + }, + callback?: Function + ): Promise<{ + numberAffected?: number | undefined; + insertedId?: string | undefined; + }>; + _createCappedCollection(byteSize?: number, maxDocuments?: number): void; + /** @deprecated */ + _ensureIndex( + indexSpec: IndexSpecification, + options?: CreateIndexesOptions + ): void; + _dropCollection(): Promise; + _dropIndex(indexName: string): void; + } + + var Cursor: CursorStatic; + interface CursorStatic { + /** + * To create a cursor, use find. To access the documents in a cursor, use forEach, map, or fetch. + */ + new (): Cursor; + } + interface ObserveCallbacks { + added?(document: T): void; + addedAt?(document: T, atIndex: number, before: T | null): void; + changed?(newDocument: T, oldDocument: T): void; + changedAt?(newDocument: T, oldDocument: T, indexAt: number): void; + removed?(oldDocument: T): void; + removedAt?(oldDocument: T, atIndex: number): void; + movedTo?( + document: T, + fromIndex: number, + toIndex: number, + before: T | null + ): void; + } + interface ObserveChangesCallbacks { + added?(id: string, fields: Partial): void; + addedBefore?(id: string, fields: Partial, before: T | null): void; + changed?(id: string, fields: Partial): void; + movedBefore?(id: string, before: T | null): void; + removed?(id: string): void; + } + interface Cursor { + /** + * Returns the number of documents that match a query. + * @param applySkipLimit If set to `false`, the value returned will reflect the total number of matching documents, ignoring any value supplied for limit. (Default: true) + */ + count(applySkipLimit?: boolean): number; + /** + * Returns the number of documents that match a query. + * @param applySkipLimit If set to `false`, the value returned will reflect the total number of matching documents, ignoring any value supplied for limit. (Default: true) + */ + countAsync(applySkipLimit?: boolean): Promise; + /** + * Return all matching documents as an Array. + */ + fetch(): Array; + /** + * Return all matching documents as an Array. + */ + fetchAsync(): Promise>; + /** + * Call `callback` once for each matching document, sequentially and + * synchronously. + * @param callback Function to call. It will be called with three arguments: the document, a 0-based index, and cursor itself. + * @param thisArg An object which will be the value of `this` inside `callback`. + */ + forEach( + callback: (doc: U, index: number, cursor: Cursor) => void, + thisArg?: any + ): void; + /** + * Call `callback` once for each matching document, sequentially and + * synchronously. + * @param callback Function to call. It will be called with three arguments: the document, a 0-based index, and cursor itself. + * @param thisArg An object which will be the value of `this` inside `callback`. + */ + forEachAsync( + callback: (doc: U, index: number, cursor: Cursor) => void, + thisArg?: any + ): Promise; + /** + * Map callback over all matching documents. Returns an Array. + * @param callback Function to call. It will be called with three arguments: the document, a 0-based index, and cursor itself. + * @param thisArg An object which will be the value of `this` inside `callback`. + */ + map( + callback: (doc: U, index: number, cursor: Cursor) => M, + thisArg?: any + ): Array; + /** + * Map callback over all matching documents. Returns an Array. + * @param callback Function to call. It will be called with three arguments: the document, a 0-based index, and cursor itself. + * @param thisArg An object which will be the value of `this` inside `callback`. + */ + mapAsync( + callback: (doc: U, index: number, cursor: Cursor) => M, + thisArg?: any + ): Promise>; + /** + * Watch a query. Receive callbacks as the result set changes. + * @param callbacks Functions to call to deliver the result set as it changes + */ + observe(callbacks: ObserveCallbacks): Meteor.LiveQueryHandle; + /** + * Watch a query. Receive callbacks as the result set changes. Only the differences between the old and new documents are passed to the callbacks. + * @param callbacks Functions to call to deliver the result set as it changes + */ + observeChanges( + callbacks: ObserveChangesCallbacks, + options?: { nonMutatingCallbacks?: boolean | undefined } + ): Meteor.LiveQueryHandle; + [Symbol.iterator](): Iterator; + [Symbol.asyncIterator](): AsyncIterator; + } + + var ObjectID: ObjectIDStatic; + interface ObjectIDStatic { + /** + * Create a Mongo-style `ObjectID`. If you don't specify a `hexString`, the `ObjectID` will generated randomly (not using MongoDB's ID construction rules). + + * @param hexString The 24-character hexadecimal contents of the ObjectID to create + */ + new (hexString?: string): ObjectID; + } + interface ObjectID { + toHexString(): string; + equals(otherID: ObjectID): boolean; + } + + function setConnectionOptions(options: any): void; +} + +export namespace Mongo { + interface AllowDenyOptions { + insert?: ((userId: string, doc: any) => boolean) | undefined; + update?: + | (( + userId: string, + doc: any, + fieldNames: string[], + modifier: any + ) => boolean) + | undefined; + remove?: ((userId: string, doc: any) => boolean) | undefined; + fetch?: string[] | undefined; + transform?: Function | null | undefined; + } +} + +export declare module MongoInternals { + interface MongoConnection { + db: MongoDb; + client: MongoClient; + } + + function defaultRemoteCollectionDriver(): { + mongo: MongoConnection; + }; + + var NpmModules: { + mongodb: { + version: string; + module: typeof MongoNpmModule; + }; + }; +} diff --git a/packages/mongo/package.js b/packages/mongo/package.js index 0ec175d219..b5a848fd14 100644 --- a/packages/mongo/package.js +++ b/packages/mongo/package.js @@ -9,7 +9,7 @@ Package.describe({ summary: "Adaptor for using MongoDB and Minimongo over DDP", - version: '1.16.1-beta.0' + version: '1.16.1-beta.1' }); Npm.depends({ @@ -82,6 +82,7 @@ Package.onUse(function (api) { api.addFiles('remote_collection_driver.js', 'server'); api.addFiles('collection.js', ['client', 'server']); api.addFiles('connection_options.js', 'server'); + api.addAssets('mongo.d.ts', 'server'); }); Package.onTest(function (api) { diff --git a/packages/mongo/package.types.json b/packages/mongo/package.types.json new file mode 100644 index 0000000000..97c9c11e61 --- /dev/null +++ b/packages/mongo/package.types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "mongo.d.ts" +} diff --git a/packages/non-core/less/.versions b/packages/non-core/less/.versions index b8dac39441..624d37670b 100644 --- a/packages/non-core/less/.versions +++ b/packages/non-core/less/.versions @@ -7,7 +7,7 @@ blaze@2.3.4 boilerplate-generator@1.7.1 caching-compiler@1.2.2 callback-hook@1.3.1 -check@1.3.1 +check@1.3.2-beta.1 ddp@1.4.0 ddp-client@2.5.0 ddp-common@1.4.0 @@ -40,16 +40,16 @@ npm-mongo@3.9.0 observe-sequence@1.0.19 ordered-dict@1.1.0 promise@0.12.0 -random@1.2.0 +random@1.2.1-beta.1 react-fast-refresh@0.1.1 -reactive-var@1.0.11 +reactive-var@1.0.12-beta.1 reload@1.3.1 retry@1.1.0 routepolicy@1.1.1 socket-stream-client@0.4.0 test-helpers@1.2.0 tinytest@1.1.1 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.11.1 webapp-hashing@1.1.0 diff --git a/packages/npm-mongo/package.js b/packages/npm-mongo/package.js index 25a4b4ecb6..37d5a3ccfb 100644 --- a/packages/npm-mongo/package.js +++ b/packages/npm-mongo/package.js @@ -3,7 +3,7 @@ Package.describe({ summary: "Wrapper around the mongo npm package", - version: '4.11.0-beta.0', + version: '4.11.0-beta.1', documentation: null }); diff --git a/packages/promise/package.js b/packages/promise/package.js index fad988b619..1789319d61 100644 --- a/packages/promise/package.js +++ b/packages/promise/package.js @@ -1,6 +1,6 @@ Package.describe({ name: "promise", - version: "0.12.0", + version: "0.12.0-beta.1", summary: "ECMAScript 2015 Promise polyfill with Fiber support", git: "https://github.com/meteor/promise", documentation: "README.md" @@ -20,6 +20,7 @@ Package.onUse(function(api) { api.mainModule("client.js", "client"); api.mainModule("server.js", "server"); api.export("Promise"); + api.addAssets("promise.d.ts", ["client", "server"]); }); Package.onTest(function(api) { diff --git a/packages/promise/package.types.json b/packages/promise/package.types.json new file mode 100644 index 0000000000..b939961149 --- /dev/null +++ b/packages/promise/package.types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "promise.d.ts" +} diff --git a/packages/promise/promise.d.ts b/packages/promise/promise.d.ts new file mode 100644 index 0000000000..38698fc7cb --- /dev/null +++ b/packages/promise/promise.d.ts @@ -0,0 +1,23 @@ +export declare class Promise extends globalThis.Promise { + static async< + Fn extends (this: This, ...args: Args) => any, + This, + Args extends any[] + >( + fn: Fn, + allowReuseOfCurrentFiber?: boolean + ): (this: This, ...args: Args) => Promise>; + static asyncApply< + Fn extends (this: This, ...args: Args) => any, + This, + Args extends any[] + >( + fn: Fn, + context: This, + args: Args, + allowReuseOfCurrentFiber?: boolean + ): Promise>; + static await(value: PromiseLike): T; + static awaitAll(values: Iterable>): T[]; + await(): T; +} diff --git a/packages/random/package-types.json b/packages/random/package-types.json new file mode 100644 index 0000000000..71bd4af0cd --- /dev/null +++ b/packages/random/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "random.d.ts" +} diff --git a/packages/random/package.js b/packages/random/package.js index 370077010c..083dca351b 100644 --- a/packages/random/package.js +++ b/packages/random/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: 'Random number generator and utilities', - version: '1.2.0', + version: '1.2.1-beta.1', }); Package.onUse(function (api) { @@ -8,6 +8,7 @@ Package.onUse(function (api) { api.export('Random'); api.mainModule('main_client.js', 'client'); api.mainModule('main_server.js', 'server'); + api.addAssets('random.d.ts', 'server'); }); Package.onTest(function (api) { diff --git a/packages/random/random.d.ts b/packages/random/random.d.ts new file mode 100644 index 0000000000..fd529f9a4d --- /dev/null +++ b/packages/random/random.d.ts @@ -0,0 +1,13 @@ +export namespace Random { + function id(numberOfChars?: number): string; + + function secret(numberOfChars?: number): string; + + function fraction(): number; + // @param numberOfDigits, @returns a random hex string of the given length + function hexString(numberOfDigits: number): string; + // @param array, @return a random element in array + function choice(array: T[]): T | undefined; + // @param str, @return a random char in str + function choice(str: string): string; +} diff --git a/packages/reactive-dict/package-types.json b/packages/reactive-dict/package-types.json new file mode 100644 index 0000000000..089231243f --- /dev/null +++ b/packages/reactive-dict/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "reactive-dict.d.ts" +} diff --git a/packages/reactive-dict/package.js b/packages/reactive-dict/package.js index ee7d4e4e9f..4feee4b9ae 100644 --- a/packages/reactive-dict/package.js +++ b/packages/reactive-dict/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Reactive dictionary", - version: '1.3.0' + version: '1.3.0-beta.1' }); Package.onUse(function (api) { @@ -9,6 +9,7 @@ Package.onUse(function (api) { api.use(['mongo', 'reload'], { weak: true }); api.mainModule('migration.js'); api.export('ReactiveDict'); + api.addAssets('reactive-dict.d.ts', 'server'); }); Package.onTest(function (api) { diff --git a/packages/reactive-dict/reactive-dict.d.ts b/packages/reactive-dict/reactive-dict.d.ts new file mode 100644 index 0000000000..b9a32ec4d8 --- /dev/null +++ b/packages/reactive-dict/reactive-dict.d.ts @@ -0,0 +1,94 @@ +import { EJSONable } from 'meteor/ejson'; + +export declare class ReactiveDict { + /** + * Constructor for a ReactiveDict, which represents a reactive dictionary of key/value pairs. + * @param name When a name is passed, preserves contents across Hot Code Pushes + * @param initialValue The default values for the dictionary + */ + constructor(name?: string, initialValue?: Partial); + /** + * Set a value for a key if it hasn't been set before. + * Otherwise works exactly the same as `ReactiveDict.set`. + * @param key The key to set, eg, `selectedItem` + * @param value The new value for `key` + */ + setDefault

(key: P, value?: O[P]): void; + /** + * Set a value for a key if it hasn't been set before. + * Otherwise works exactly the same as `ReactiveDict.set`. + */ + setDefault(object: Partial): void; + /** + * Set a value for a key in the ReactiveDict. Notify any listeners + * that the value has changed (eg: redraw templates, and rerun any + * `Tracker.autorun` computations, that called + * `ReactiveDict.get` on this `key`.) + * @param key The key to set, eg, `selectedItem` + * @param value The new value for `key` + */ + set

(key: P, value?: O[P]): void; + /** + * Set a value for a key in the ReactiveDict. Notify any listeners + * that the value has changed (eg: redraw templates, and rerun any + * `Tracker.autorun` computations, that called + * `ReactiveDict.get` on this `key`.) + */ + set(object: Partial): void; + /** + * Get the value assiciated with a key. If inside a reactive + * computation, invalidate the computation the next time the + * value associated with this key is changed by `ReactiveDict.set`. + * This returns a clone of the value, so if it's an object or an array, + * mutating the returned value has no effect on the value stored in the + * ReactiveDict. + * @param key The key of the element to return + */ + get

(key: P): O[P] | undefined; + /** + * Test if the stored entry for a key is equal to a value. If inside a + * reactive computation, invalidate the computation the next + * time the variable changes to or from the value. + * @param key The name of the session variable to test + * @param value The value to + * test against + */ + equals

( + key: P, + value: string | number | boolean | undefined | null + ): boolean; + /** + * Get all key-value pairs as a plain object. If inside a reactive + * computation, invalidate the computation the next time the + * value associated with any key is changed by `ReactiveDict.set`. + * This returns a clone of each value, so if it's an object or an array, + * mutating the returned value has no effect on the value stored in the + * ReactiveDict. + */ + all(): Partial; + /** + * remove all key-value pairs from the ReactiveDict. Notify any + * listeners that the value has changed (eg: redraw templates, and rerun any + * `Tracker.autorun` computations, that called + * `ReactiveDict.get` on this `key`.) + */ + clear(): void; + + /** + * remove a key-value pair from the ReactiveDict. Notify any listeners + * that the value has changed (eg: redraw templates, and rerun any + * `Tracker.autorun` computations, that called + * `ReactiveDict.get` on this `key`.) + * @param key The key to delete, eg, `selectedItem` + * @return did remove + */ + delete

(key: P): boolean; + /** + * Clear all values from the reactiveDict and prevent it from being + * migrated on a Hot Code Pushes. Notify any listeners + * that the value has changed (eg: redraw templates, and rerun any + * `Tracker.autorun` computations, that called + * `ReactiveDict.get` on this `key`.) + */ + destroy(): void; +} diff --git a/packages/reactive-var/package-types.json b/packages/reactive-var/package-types.json new file mode 100644 index 0000000000..24149d998a --- /dev/null +++ b/packages/reactive-var/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "reactive-var.d.ts" +} diff --git a/packages/reactive-var/package.js b/packages/reactive-var/package.js index 029608a876..7569f084c5 100644 --- a/packages/reactive-var/package.js +++ b/packages/reactive-var/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Reactive variable", - version: '1.0.11' + version: '1.0.12-beta.1' }); Package.onUse(function (api) { @@ -9,4 +9,5 @@ Package.onUse(function (api) { api.use('tracker'); api.addFiles('reactive-var.js'); + api.addAssets('reactive-var.d.ts', 'server'); }); diff --git a/packages/reactive-var/reactive-var.d.ts b/packages/reactive-var/reactive-var.d.ts new file mode 100644 index 0000000000..f7d22c7559 --- /dev/null +++ b/packages/reactive-var/reactive-var.d.ts @@ -0,0 +1,25 @@ +export declare var ReactiveVar: ReactiveVarStatic; + +export interface ReactiveVarStatic { + /** + * Constructor for a ReactiveVar, which represents a single reactive variable. + * @param initialValue The initial value to set. `equalsFunc` is ignored when setting the initial value. + * @param equalsFunc A function of two arguments, called on the old value and the new value whenever the ReactiveVar is set. If it returns true, no set is performed. If omitted, the default + * `equalsFunc` returns true if its arguments are `===` and are of type number, boolean, string, undefined, or null. + */ + new ( + initialValue: T, + equalsFunc?: (oldValue: T, newValue: T) => boolean + ): ReactiveVar; +} + +export interface ReactiveVar { + /** + * Returns the current value of the ReactiveVar, establishing a reactive dependency. + */ + get(): T; + /** + * Sets the current value of the ReactiveVar, invalidating the Computations that called `get` if `newValue` is different from the old value. + */ + set(newValue: T): void; +} diff --git a/packages/server-render/package-types.json b/packages/server-render/package-types.json new file mode 100644 index 0000000000..11840961ec --- /dev/null +++ b/packages/server-render/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "server-render.d.ts" +} diff --git a/packages/server-render/package.js b/packages/server-render/package.js index 47d3cadc5c..ebb95e39a1 100644 --- a/packages/server-render/package.js +++ b/packages/server-render/package.js @@ -1,6 +1,6 @@ Package.describe({ name: "server-render", - version: "0.4.0", + version: "0.4.0-beta.1", summary: "Generic support for server-side rendering in Meteor apps", documentation: "README.md" }); @@ -17,6 +17,7 @@ Package.onUse(function(api) { api.use("webapp"); api.mainModule("client.js", "client", { lazy: true }); api.mainModule("server.js", "server"); + api.addAssets('server-render.d.ts', 'server'); }); Package.onTest(function(api) { diff --git a/packages/server-render/server-render.d.ts b/packages/server-render/server-render.d.ts new file mode 100644 index 0000000000..8f55c0fe07 --- /dev/null +++ b/packages/server-render/server-render.d.ts @@ -0,0 +1,36 @@ +import * as http from 'http'; + +// NodeJS.ReadableStream only works on server. +// HTMLElement only works on client. +export type Content = string | Content[] | NodeJS.ReadableStream | HTMLElement; + +export interface ClientSink { + // Client and server. Only client + appendToHead(html: Content): void; + appendToBody(html: Content): void; + appendToElementById(id: string, html: Content): void; + renderIntoElementById(id: string, html: Content): void; + redirect(location: string, code?: number): void; + + // Server-only, but error-raising stubs provided to client: + setStatusCode(code: number): void; + setHeader(key: string, value: number | string | string[]): void; + getHeaders(): http.IncomingHttpHeaders; + getCookies(): { [key: string]: string }; +} + +export interface ServerSink extends ClientSink { + // Server-only: + request: http.IncomingMessage; + arch: string; + head: string; + body: string; + htmlById: { [key: string]: string }; + maybeMadeChanges: boolean; +} + +export type Sink = ClientSink | ServerSink; + +export type Callback = (sink: Sink) => Promise | any; + +export function onPageLoad(callback: T): T; diff --git a/packages/service-configuration/package-types.json b/packages/service-configuration/package-types.json new file mode 100644 index 0000000000..16883a4dac --- /dev/null +++ b/packages/service-configuration/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "service-configuration.d.ts" +} diff --git a/packages/service-configuration/package.js b/packages/service-configuration/package.js index ec496a1fff..bfb4d322ec 100644 --- a/packages/service-configuration/package.js +++ b/packages/service-configuration/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: 'Manage the configuration for third-party services', - version: '1.3.0', + version: '1.3.0-beta.1', }); Package.onUse(function(api) { @@ -10,4 +10,5 @@ Package.onUse(function(api) { api.export('ServiceConfiguration'); api.addFiles('service_configuration_common.js', ['client', 'server']); api.addFiles('service_configuration_server.js', 'server'); + api.addAssets('service-configuration.d.ts', 'server'); }); diff --git a/packages/service-configuration/service-configuration.d.ts b/packages/service-configuration/service-configuration.d.ts new file mode 100644 index 0000000000..3c18cfaac3 --- /dev/null +++ b/packages/service-configuration/service-configuration.d.ts @@ -0,0 +1,10 @@ +import { Mongo } from 'meteor/mongo'; + +export interface Configuration { + appId: string; + secret: string; +} + +export declare var ServiceConfiguration: { + configurations: Mongo.Collection; +}; diff --git a/packages/session/package-types.json b/packages/session/package-types.json new file mode 100644 index 0000000000..ee5a93cac4 --- /dev/null +++ b/packages/session/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "session.d.ts" +} diff --git a/packages/session/package.js b/packages/session/package.js index 5515510f25..58532f2810 100644 --- a/packages/session/package.js +++ b/packages/session/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Session variable", - version: '1.2.0' + version: '1.2.1-beta.1' }); Package.onUse(function (api) { @@ -13,6 +13,7 @@ Package.onUse(function (api) { api.export('Session', 'client'); api.mainModule('session.js', 'client'); + api.addAssets('session.d.ts', 'server'); }); Package.onTest(function (api) { diff --git a/packages/session/session.d.ts b/packages/session/session.d.ts new file mode 100644 index 0000000000..6e5afd4420 --- /dev/null +++ b/packages/session/session.d.ts @@ -0,0 +1,41 @@ +import { EJSONable } from 'meteor/ejson'; + +export namespace Session { + /** + * Test if a session variable is equal to a value. If inside a + * reactive computation, invalidate the computation the next + * time the variable changes to or from the value. + * @param key The name of the session variable to test + * @param value The value to test against + */ + function equals(key: string, value: string | number | boolean | any): boolean; + + /** + * Get the value of a session variable. If inside a reactive + * computation, invalidate the computation the next time the + * value of the variable is changed by `Session.set`. This + * returns a clone of the session value, so if it's an object or an array, + * mutating the returned value has no effect on the value stored in the + * session. + * @param key The name of the session variable to return + */ + function get(key: string): any; + + /** + * Set a variable in the session. Notify any listeners that the value + * has changed (eg: redraw templates, and rerun any + * `Tracker.autorun` computations, that called + * `Session.get` on this `key`.) + * @param key The key to set, eg, `selectedItem` + * @param value The new value for `key` + */ + function set(key: string, value: EJSONable | any): void; + + /** + * Set a variable in the session if it hasn't been set before. + * Otherwise works exactly the same as `Session.set`. + * @param key The key to set, eg, `selectedItem` + * @param value The new value for `key` + */ + function setDefault(key: string, value: EJSONable | any): void; +} diff --git a/packages/test-in-browser/package.js b/packages/test-in-browser/package.js index fb5e49cf72..8c8b78bea0 100644 --- a/packages/test-in-browser/package.js +++ b/packages/test-in-browser/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Run tests interactively in the browser", - version: '1.3.1-beta.0', + version: '1.3.1-beta.1', documentation: null }); diff --git a/packages/tracker/package-types.json b/packages/tracker/package-types.json new file mode 100644 index 0000000000..7e03462336 --- /dev/null +++ b/packages/tracker/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "tracker.d.ts" +} diff --git a/packages/tracker/package.js b/packages/tracker/package.js index 9475828977..69789f0e6c 100644 --- a/packages/tracker/package.js +++ b/packages/tracker/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Dependency tracker to allow reactive callbacks", - version: "1.2.0" + version: "1.2.1-beta.1" }); Package.onUse(function (api) { @@ -8,6 +8,7 @@ Package.onUse(function (api) { api.addFiles("tracker.js"); api.export("Tracker"); api.export("Deps"); + api.addAssets("tracker.d.ts", ["client", "server"]); }); Package.onTest(function (api) { diff --git a/packages/tracker/tracker.d.ts b/packages/tracker/tracker.d.ts new file mode 100644 index 0000000000..9ab6e0bdc5 --- /dev/null +++ b/packages/tracker/tracker.d.ts @@ -0,0 +1,128 @@ +/** + * The namespace for Tracker-related methods. + */ +export namespace Tracker { + function Computation(): void; + /** + * A Computation object represents code that is repeatedly rerun + * in response to + * reactive data changes. Computations don't have return values; they just + * perform actions, such as rerendering a template on the screen. Computations + * are created using Tracker.autorun. Use stop to prevent further rerunning of a + * computation. + */ + interface Computation { + /** + * True during the initial run of the computation at the time `Tracker.autorun` is called, and false on subsequent reruns and at other times. + */ + firstRun: boolean; + /** + * Invalidates this computation so that it will be rerun. + */ + invalidate(): void; + /** + * True if this computation has been invalidated (and not yet rerun), or if it has been stopped. + */ + invalidated: boolean; + /** + * Registers `callback` to run when this computation is next invalidated, or runs it immediately if the computation is already invalidated. The callback is run exactly once and not upon + * future invalidations unless `onInvalidate` is called again after the computation becomes valid again. + * @param callback Function to be called on invalidation. Receives one argument, the computation that was invalidated. + */ + onInvalidate(callback: Function): void; + /** + * Registers `callback` to run when this computation is stopped, or runs it immediately if the computation is already stopped. The callback is run after any `onInvalidate` callbacks. + * @param callback Function to be called on stop. Receives one argument, the computation that was stopped. + */ + onStop(callback: Function): void; + /** + * Prevents this computation from rerunning. + */ + stop(): void; + /** + * True if this computation has been stopped. + */ + stopped: boolean; + } + /** + * The current computation, or `null` if there isn't one. The current computation is the `Tracker.Computation` object created by the innermost active call to + * `Tracker.autorun`, and it's the computation that gains dependencies when reactive data sources are accessed. + */ + var currentComputation: Computation; + + var Dependency: DependencyStatic; + /** + * A Dependency represents an atomic unit of reactive data that a + * computation might depend on. Reactive data sources such as Session or + * Minimongo internally create different Dependency objects for different + * pieces of data, each of which may be depended on by multiple computations. + * When the data changes, the computations are invalidated. + */ + interface DependencyStatic { + new (): Dependency; + } + interface Dependency { + /** + * Invalidate all dependent computations immediately and remove them as dependents. + */ + changed(): void; + /** + * Declares that the current computation (or `fromComputation` if given) depends on `dependency`. The computation will be invalidated the next time `dependency` changes. + * If there is no current computation and `depend()` is called with no arguments, it does nothing and returns false. + * Returns true if the computation is a new dependent of `dependency` rather than an existing one. + * @param fromComputation An optional computation declared to depend on `dependency` instead of the current computation. + */ + depend(fromComputation?: Computation): boolean; + /** + * True if this Dependency has one or more dependent Computations, which would be invalidated if this Dependency were to change. + */ + hasDependents(): boolean; + } + + /** + * True if there is a current computation, meaning that dependencies on reactive data sources will be tracked and potentially cause the current computation to be rerun. + */ + var active: boolean; + + /** + * Schedules a function to be called during the next flush, or later in the current flush if one is in progress, after all invalidated computations have been rerun. The function will be run + * once and not on subsequent flushes unless `afterFlush` is called again. + * @param callback A function to call at flush time. + */ + function afterFlush(callback: Function): void; + + /** + * Run a function now and rerun it later whenever its dependencies + * change. Returns a Computation object that can be used to stop or observe the + * rerunning. + * @param runFunc The function to run. It receives one argument: the Computation object that will be returned. + */ + function autorun( + runFunc: (computation: Computation) => void, + options?: { + /** + * The function to run when an error + * happens in the Computation. The only argument it receives is the Error + * thrown. Defaults to the error being logged to the console. + */ + onError?: Function | undefined; + } + ): Computation; + + /** + * Process all reactive updates immediately and ensure that all invalidated computations are rerun. + */ + function flush(): void; + + /** + * Run a function without tracking dependencies. + * @param func A function to call immediately. + */ + function nonreactive(func: () => T): T; + + /** + * Registers a new `onInvalidate` callback on the current computation (which must exist), to be called immediately when the current computation is invalidated or stopped. + * @param callback A callback function that will be invoked as `func(c)`, where `c` is the computation on which the callback is registered. + */ + function onInvalidate(callback: Function): void; +} diff --git a/packages/twitter-oauth/package.js b/packages/twitter-oauth/package.js index 27eb65c32f..a24f7f32dc 100644 --- a/packages/twitter-oauth/package.js +++ b/packages/twitter-oauth/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Twitter OAuth flow", - version: '1.3.1-beta.0' + version: '1.3.1-beta.1' }); Package.onUse(function(api) { diff --git a/packages/underscore/package-types.json b/packages/underscore/package-types.json new file mode 100644 index 0000000000..347b86d05e --- /dev/null +++ b/packages/underscore/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "underscore.d.ts" +} diff --git a/packages/underscore/package.js b/packages/underscore/package.js index 483509a727..527d7d17e9 100644 --- a/packages/underscore/package.js +++ b/packages/underscore/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Collection of small helpers: _.map, _.each, ...", - version: '1.0.10' + version: '1.0.11-beta.1' }); Package.onUse(function (api) { @@ -27,6 +27,8 @@ Package.onUse(function (api) { // numeric length field whose constructor === Object are still treated as // objects, not as arrays. Search for looksLikeArray. api.addFiles(['pre.js', 'underscore.js', 'post.js']); + + api.addAssets('underscore.d.ts', 'server'); }); diff --git a/packages/underscore/underscore.d.ts b/packages/underscore/underscore.d.ts new file mode 100644 index 0000000000..ffbb281e51 --- /dev/null +++ b/packages/underscore/underscore.d.ts @@ -0,0 +1,2 @@ +import * as _ from 'underscore'; +export { _ }; diff --git a/packages/webapp-hashing/package.js b/packages/webapp-hashing/package.js index 088b184ffe..5c9e43a12d 100644 --- a/packages/webapp-hashing/package.js +++ b/packages/webapp-hashing/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Used internally by WebApp. Knows how to hash programs from manifests.", - version: '1.1.1-beta.0' + version: '1.1.1-beta.1' }); Package.onUse(function(api) { diff --git a/packages/webapp/package-types.json b/packages/webapp/package-types.json new file mode 100644 index 0000000000..ba477f3ba8 --- /dev/null +++ b/packages/webapp/package-types.json @@ -0,0 +1,3 @@ +{ + "typesEntry": "webapp.d.ts" +} diff --git a/packages/webapp/package.js b/packages/webapp/package.js index 5464ea7dc8..65011e6f5d 100644 --- a/packages/webapp/package.js +++ b/packages/webapp/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: 'Serves a Meteor app over HTTP', - version: '1.13.1', + version: '1.13.1-beta.1', }); Npm.depends({ @@ -57,6 +57,7 @@ Package.onUse(function(api) { api.export('WebApp', 'client'); api.mainModule('webapp_cordova.js', 'web.cordova'); + api.addAssets('webapp.d.ts', 'server'); }); Package.onTest(function(api) { diff --git a/packages/webapp/webapp.d.ts b/packages/webapp/webapp.d.ts new file mode 100644 index 0000000000..e13bb9ccf0 --- /dev/null +++ b/packages/webapp/webapp.d.ts @@ -0,0 +1,87 @@ +import * as http from 'http'; +import * as connect from 'connect'; + +export interface StaticFiles { + [key: string]: { + content?: string | undefined; + absolutePath: string; + cacheable: boolean; + hash: string; + sourceMapUrl?: string | undefined; + type: string; + }; +} + +export declare module WebApp { + var defaultArch: string; + var clientPrograms: { + [key: string]: { + format: string; + manifest: any; + version: string; + cordovaCompatibilityVersions?: any; + PUBLIC_SETTINGS: any; + }; + }; + var connectHandlers: connect.Server; + var rawConnectHandlers: connect.Server; + var httpServer: http.Server; + var connectApp: connect.Server; + function suppressConnectErrors(): void; + function onListening(callback: Function): void; + + type RuntimeConfigHookCallback = (options: { + arch: 'web.browser' | 'web.browser.legacy' | 'web.cordova'; + request: http.IncomingMessage; + encodedCurrentConfig: string; + updated: boolean; + }) => string | undefined | null | false; + function addRuntimeConfigHook(callback: RuntimeConfigHookCallback): void; + function decodeRuntimeConfig(rtimeConfigString: string): unknown; + function encodeRuntimeConfig(rtimeConfig: unknown): string; +} + +export declare module WebAppInternals { + var NpmModules: { + [key: string]: { + version: string; + module: any; + }; + }; + function identifyBrowser( + userAgentString: string + ): { + name: string; + major: string; + minor: string; + patch: string; + }; + function registerBoilerplateDataCallback( + key: string, + callback: Function + ): Function; + function generateBoilerplateInstance( + arch: string, + manifest: any, + additionalOptions: any + ): any; + + function staticFilesMiddleware( + staticFiles: StaticFiles, + req: http.IncomingMessage, + res: http.ServerResponse, + next: Function + ): void; + function parsePort(port: string): number; + function reloadClientPrograms(): void; + function generateBoilerplate(): void; + var staticFiles: StaticFiles; + function inlineScriptsAllowed(): boolean; + function setInlineScriptsAllowed(inlineScriptsAllowed: boolean): void; + + function setBundledJsCssUrlRewriteHook(hookFn: (url: string) => string): void; + function setBundledJsCssPrefix(bundledJsCssPrefix: string): void; + function addStaticJs(): void; + function getBoilerplate(request: http.IncomingMessage, arch: string): string; + var additionalStaticJs: any; +} diff --git a/scripts/admin/meteor-release-experimental.json b/scripts/admin/meteor-release-experimental.json index 2295f3302d..d60ac53c6c 100644 --- a/scripts/admin/meteor-release-experimental.json +++ b/scripts/admin/meteor-release-experimental.json @@ -1,6 +1,6 @@ { "track": "METEOR", - "version": "2.8.1-beta.0", + "version": "2.8.1-beta.1", "recommended": false, "official": false, "description": "Meteor experimental release" diff --git a/scripts/admin/update-semver/index.js b/scripts/admin/update-semver/index.js index 3024508bb1..73c4a0fce8 100644 --- a/scripts/admin/update-semver/index.js +++ b/scripts/admin/update-semver/index.js @@ -7,6 +7,7 @@ const semver = require('semver'); const fs = require('fs'); const { exec } = require("child_process"); +const { readdir } = require("fs/promises"); const runCommand = async (command) => { return new Promise((resolve, reject) => { @@ -45,12 +46,23 @@ async function getFile(path) { } +const getDirectories = async source => + (await readdir(source, { withFileTypes: true })) + .filter(dirent => dirent.isDirectory()) + .map(dirent => dirent.name); + async function main() { /** * @type {string[]} */ let args = process.argv.slice(2); + if (args[0].startsWith('@all')) { + const [_, type] = args[0].split('.'); + const allPackages = await getDirectories('../../../packages'); + args = allPackages.map((packageName) => `${ packageName }.${ type }`); + } + if (args[0].startsWith('@auto')) { const [_, type] = args[0].split('.'); // List of packages that for some reason are not in the diff. @@ -60,6 +72,10 @@ async function main() { // ddp-common const p = await getPackages(); + console.log('****************') + console.log('Will be updating the following packages:'); + console.dir(p) + console.log('****************') const packages = p.concat(`packages/meteor-tool.${ type }`); args = packages .split('/') @@ -88,8 +104,13 @@ async function main() { // version: '1.2.3' <--- this is the line we want, we assure that it has a version in the previous if //}); const [_, versionValue] = line.split(':'); - const currentVersion = versionValue.trim().replace(',', ''); - const semverVersion = semver.coerce(currentVersion); + if (!versionValue) continue; + const currentVersion = versionValue + .trim() + .replace(',', '') + .replace(/'/g, '') + .replace(/"/g, ''); + /** * @@ -98,14 +119,14 @@ async function main() { */ function incrementNewVersion(release) { if (release.includes('beta') || release.includes('rc')) { - return semver.inc(semverVersion, 'prerelease', release); + return semver.inc(currentVersion, 'prerelease', release); } - return semver.inc(semverVersion, release); + return semver.inc(currentVersion, release); } const newVersion = incrementNewVersion(release); console.log(`Updating ${ name } from ${ currentVersion } to ${ newVersion }`); - const newCode = code.replace(currentVersion, "'" + newVersion + "'"); + const newCode = code.replace(currentVersion, `${ newVersion }`); await fs.promises.writeFile(filePath, newCode); } } diff --git a/tools/tests/apps/app-config/.meteor/versions b/tools/tests/apps/app-config/.meteor/versions index 23b1d17616..741cf5b27c 100644 --- a/tools/tests/apps/app-config/.meteor/versions +++ b/tools/tests/apps/app-config/.meteor/versions @@ -57,8 +57,8 @@ standard-minifier-css@1.4.1 standard-minifier-js@2.3.2 static-html@1.2.2 templating-tools@1.1.2 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 url@1.2.0 webapp@1.5.0 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/client-refresh/.meteor/versions b/tools/tests/apps/client-refresh/.meteor/versions index 087c94fa51..dfd474adf1 100644 --- a/tools/tests/apps/client-refresh/.meteor/versions +++ b/tools/tests/apps/client-refresh/.meteor/versions @@ -7,7 +7,7 @@ boilerplate-generator@1.6.0 caching-compiler@1.2.1 caching-html-compiler@1.1.3 callback-hook@1.1.0 -check@1.3.1 +check@1.3.2-beta.1 ddp@1.4.0 ddp-client@2.3.3 ddp-common@1.4.0 @@ -47,8 +47,8 @@ standard-minifier-js@2.4.1 static-html@1.2.2 templating-tools@1.1.2 test-package@0.0.1 -tracker@1.2.0 +tracker@1.2.1-beta.1 typescript@3.5.2-beta182.17 -underscore@1.0.10 +underscore@1.0.11-beta.1 webapp@1.7.4 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/compiler-plugin-static-html-error/.meteor/versions b/tools/tests/apps/compiler-plugin-static-html-error/.meteor/versions index 2112029aa3..c0e1bc65a8 100644 --- a/tools/tests/apps/compiler-plugin-static-html-error/.meteor/versions +++ b/tools/tests/apps/compiler-plugin-static-html-error/.meteor/versions @@ -7,7 +7,7 @@ boilerplate-generator@1.6.0 caching-compiler@1.2.1 caching-html-compiler@1.1.3 callback-hook@1.1.0 -check@1.3.1 +check@1.3.2-beta.1 ddp@1.4.0 ddp-client@2.3.3 ddp-common@1.4.0 @@ -49,7 +49,7 @@ standard-minifier-css@1.5.3 standard-minifier-js@2.4.1 static-html@1.2.2 templating-tools@1.1.2 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.7.4 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/compiler-plugin-static-html/.meteor/versions b/tools/tests/apps/compiler-plugin-static-html/.meteor/versions index 2112029aa3..c0e1bc65a8 100644 --- a/tools/tests/apps/compiler-plugin-static-html/.meteor/versions +++ b/tools/tests/apps/compiler-plugin-static-html/.meteor/versions @@ -7,7 +7,7 @@ boilerplate-generator@1.6.0 caching-compiler@1.2.1 caching-html-compiler@1.1.3 callback-hook@1.1.0 -check@1.3.1 +check@1.3.2-beta.1 ddp@1.4.0 ddp-client@2.3.3 ddp-common@1.4.0 @@ -49,7 +49,7 @@ standard-minifier-css@1.5.3 standard-minifier-js@2.4.1 static-html@1.2.2 templating-tools@1.1.2 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.7.4 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/custom-minifier/.meteor/versions b/tools/tests/apps/custom-minifier/.meteor/versions index 0aacfc62db..6f55d66e80 100644 --- a/tools/tests/apps/custom-minifier/.meteor/versions +++ b/tools/tests/apps/custom-minifier/.meteor/versions @@ -7,7 +7,7 @@ boilerplate-generator@1.6.0 caching-compiler@1.2.1 caching-html-compiler@1.1.3 callback-hook@1.2.0 -check@1.3.1 +check@1.3.2-beta.1 custom-minifier@0.0.1 ddp@1.4.0 ddp-client@2.3.3 @@ -45,7 +45,7 @@ socket-stream-client@0.2.2 spacebars-compiler@1.1.3 static-html@1.2.2 templating-tools@1.1.2 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.7.5 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/dynamic-import/.meteor/packages b/tools/tests/apps/dynamic-import/.meteor/packages index b74a849e52..e75977188d 100644 --- a/tools/tests/apps/dynamic-import/.meteor/packages +++ b/tools/tests/apps/dynamic-import/.meteor/packages @@ -8,8 +8,8 @@ meteor-base@1.4.0 # Packages every Meteor app needs to have mobile-experience@1.1.0 # Packages for a great mobile UX mongo@1.9.0 # The database Meteor supports right now blaze-html-templates@1.0.4 # Compile .html files into Meteor Blaze views -reactive-var@1.0.11 # Reactive variable for tracker -tracker@1.2.0 # Meteor's client-side reactive programming library +reactive-var@1.0.12-beta.1 # Reactive variable for tracker +tracker@1.2.1-beta.1 # Meteor's client-side reactive programming library standard-minifier-css@1.6.0 # CSS minifier run for production mode standard-minifier-js@2.6.0 # JS minifier run for production mode @@ -23,6 +23,6 @@ dynamic-import@0.5.1 lazy-test-package helper-package user:colon-name -underscore@1.0.10 +underscore@1.0.11-beta.1 fetch@0.1.1 jquery diff --git a/tools/tests/apps/dynamic-import/.meteor/versions b/tools/tests/apps/dynamic-import/.meteor/versions index a99df3012b..3872664234 100644 --- a/tools/tests/apps/dynamic-import/.meteor/versions +++ b/tools/tests/apps/dynamic-import/.meteor/versions @@ -12,7 +12,7 @@ boilerplate-generator@1.7.0 caching-compiler@1.2.1 caching-html-compiler@1.1.3 callback-hook@1.3.0 -check@1.3.1 +check@1.3.2-beta.1 coffeescript@2.4.1 coffeescript-compiler@2.4.1 ddp@1.4.0 @@ -60,8 +60,8 @@ npm-mongo@3.7.0 observe-sequence@1.0.16 ordered-dict@1.1.0 promise@0.11.2 -random@1.2.0 -reactive-var@1.0.11 +random@1.2.1-beta.1 +reactive-var@1.0.12-beta.1 reload@1.3.0 retry@1.1.0 routepolicy@1.1.0 @@ -75,9 +75,9 @@ templating@1.3.2 templating-compiler@1.3.3 templating-runtime@1.3.2 templating-tools@1.1.2 -tracker@1.2.0 +tracker@1.2.1-beta.1 ui@1.0.13 -underscore@1.0.10 +underscore@1.0.11-beta.1 user:colon-name@0.0.1 webapp@1.9.0 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/ecmascript-regression/.meteor/packages b/tools/tests/apps/ecmascript-regression/.meteor/packages index ab27ff6225..5dc670f631 100644 --- a/tools/tests/apps/ecmascript-regression/.meteor/packages +++ b/tools/tests/apps/ecmascript-regression/.meteor/packages @@ -7,7 +7,7 @@ meteor-base@1.5.1 # Packages every Meteor app needs to have mobile-experience@1.1.0 # Packages for a great mobile UX mongo@1.13.0 # The database Meteor supports right now -reactive-var@1.0.11 # Reactive variable for tracker +reactive-var@1.0.12-beta.1 # Reactive variable for tracker standard-minifier-css@1.7.4 # CSS minifier run for production mode standard-minifier-js@2.7.0 # JS minifier run for production mode diff --git a/tools/tests/apps/ecmascript-regression/.meteor/versions b/tools/tests/apps/ecmascript-regression/.meteor/versions index de86973195..697b4d7acc 100644 --- a/tools/tests/apps/ecmascript-regression/.meteor/versions +++ b/tools/tests/apps/ecmascript-regression/.meteor/versions @@ -10,7 +10,7 @@ boilerplate-generator@1.7.1 caching-compiler@1.2.2 caching-html-compiler@1.2.1 callback-hook@1.4.0 -check@1.3.1 +check@1.3.2-beta.1 ddp@1.4.0 ddp-client@2.5.0 ddp-common@1.4.0 @@ -56,10 +56,10 @@ mongo-id@1.0.8 npm-mongo@3.9.1 ordered-dict@1.1.0 promise@0.12.0 -random@1.2.0 +random@1.2.1-beta.1 react-fast-refresh@0.1.1 react-meteor-data@2.3.3 -reactive-var@1.0.11 +reactive-var@1.0.12-beta.1 reload@1.3.1 retry@1.1.0 routepolicy@1.1.1 @@ -70,9 +70,9 @@ standard-minifier-css@1.7.4 standard-minifier-js@2.7.1 static-html@1.3.2 templating-tools@1.2.1 -tracker@1.2.0 +tracker@1.2.1-beta.1 typescript@4.3.5 -underscore@1.0.10 +underscore@1.0.11-beta.1 url@1.3.2 webapp@1.12.0 webapp-hashing@1.1.0 diff --git a/tools/tests/apps/git-commit-hash/.meteor/versions b/tools/tests/apps/git-commit-hash/.meteor/versions index a10ed1d9c8..fb9d3c8a07 100644 --- a/tools/tests/apps/git-commit-hash/.meteor/versions +++ b/tools/tests/apps/git-commit-hash/.meteor/versions @@ -33,7 +33,7 @@ standard-minifier-css@1.5.2 standard-minifier-js@2.4.0 static-html@1.2.2 templating-tools@1.1.2 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.7.3-beta181.16 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/link-config-npm-package/.meteor/versions b/tools/tests/apps/link-config-npm-package/.meteor/versions index 91816ff622..4df92e6329 100644 --- a/tools/tests/apps/link-config-npm-package/.meteor/versions +++ b/tools/tests/apps/link-config-npm-package/.meteor/versions @@ -33,7 +33,7 @@ standard-minifier-css@1.4.1 standard-minifier-js@2.4.0-rc171.6 static-html@1.2.2 templating-tools@1.1.2 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.7.0-rc171.6 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/linked-external-npm-package/.meteor/versions b/tools/tests/apps/linked-external-npm-package/.meteor/versions index 91816ff622..4df92e6329 100644 --- a/tools/tests/apps/linked-external-npm-package/.meteor/versions +++ b/tools/tests/apps/linked-external-npm-package/.meteor/versions @@ -33,7 +33,7 @@ standard-minifier-css@1.4.1 standard-minifier-js@2.4.0-rc171.6 static-html@1.2.2 templating-tools@1.1.2 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.7.0-rc171.6 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/meteor-ignore/.meteor/versions b/tools/tests/apps/meteor-ignore/.meteor/versions index 2a0c9c4a0e..d0550519a5 100644 --- a/tools/tests/apps/meteor-ignore/.meteor/versions +++ b/tools/tests/apps/meteor-ignore/.meteor/versions @@ -47,7 +47,7 @@ npm-mongo@2.2.30 ordered-dict@1.0.9 promise@0.9.0 random@1.0.10 -reactive-var@1.0.11 +reactive-var@1.0.12-beta.1 reload@1.1.11 retry@1.0.9 routepolicy@1.0.12 @@ -58,7 +58,7 @@ standard-minifier-js@2.1.1 static-html@1.2.2 templating-tools@1.1.2 tracker@1.1.3 -underscore@1.0.10 +underscore@1.0.11-beta.1 url@1.1.0 webapp@1.3.19 webapp-hashing@1.0.9 diff --git a/tools/tests/apps/modules/.meteor/packages b/tools/tests/apps/modules/.meteor/packages index 2f92a7e262..a8cbf16ab4 100644 --- a/tools/tests/apps/modules/.meteor/packages +++ b/tools/tests/apps/modules/.meteor/packages @@ -8,9 +8,9 @@ meteor-base@1.4.0 # Packages every Meteor app needs to have mobile-experience@1.1.0 # Packages for a great mobile UX mongo@1.9.0 # The database Meteor supports right now blaze-html-templates # Compile .html files into Meteor Blaze views -session@1.2.0 # Client-side reactive dictionary for your app +session@1.2.1-beta.1 # Client-side reactive dictionary for your app jquery # Helpful client-side library -tracker@1.2.0 # Meteor's client-side reactive programming library +tracker@1.2.1-beta.1 # Meteor's client-side reactive programming library es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers. ecmascript@0.14.2 # Enable ECMAScript2015+ syntax in app code @@ -23,7 +23,7 @@ client-only-ecmascript modules-test-plugin shell-server@0.5.0 dynamic-import@0.5.1 -underscore@1.0.10 +underscore@1.0.11-beta.1 import-local-json-module akryum:vue-component dummy-compiler diff --git a/tools/tests/apps/standard-app/.meteor/versions b/tools/tests/apps/standard-app/.meteor/versions index a574733bd2..563d1ca0f3 100644 --- a/tools/tests/apps/standard-app/.meteor/versions +++ b/tools/tests/apps/standard-app/.meteor/versions @@ -6,7 +6,7 @@ base64@1.0.11 binary-heap@1.0.11 boilerplate-generator@1.6.0 callback-hook@1.1.0 -check@1.3.1 +check@1.3.2-beta.1 ddp@1.4.0 ddp-client@2.3.3 ddp-common@1.4.0 @@ -49,7 +49,7 @@ shell-server@0.4.0 socket-stream-client@0.2.2 standard-minifier-css@1.5.2 standard-minifier-js@2.4.0 -tracker@1.2.0 -underscore@1.0.10 +tracker@1.2.1-beta.1 +underscore@1.0.11-beta.1 webapp@1.7.2 webapp-hashing@1.0.9 diff --git a/tools/tests/old/app-with-private/.meteor/versions b/tools/tests/old/app-with-private/.meteor/versions index 4a33deb24f..d3261ace0f 100644 --- a/tools/tests/old/app-with-private/.meteor/versions +++ b/tools/tests/old/app-with-private/.meteor/versions @@ -47,7 +47,7 @@ npm-mongo@2.2.33 ordered-dict@1.0.9 promise@0.10.0 random@1.0.10 -reactive-var@1.0.11 +reactive-var@1.0.12-beta.1 reload@1.1.11 retry@1.0.9 routepolicy@1.0.12 @@ -58,7 +58,7 @@ standard-minifier-js@2.2.1 static-html@1.2.2 templating-tools@1.1.2 tracker@1.1.3 -underscore@1.0.10 +underscore@1.0.11-beta.1 url@1.1.0 webapp@1.4.0 webapp-hashing@1.0.9