Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync branch with Release 3.0.4 #7

Open
wants to merge 6 commits into
base: clean-synchronous-cursor-code
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions packages/accounts-base/accounts-base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export namespace Accounts {
profile?: Meteor.UserProfile | undefined;
},
callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void
): string;
): Promise<string>;

function createUserAsync(
options: {
Expand Down Expand Up @@ -113,23 +113,23 @@ export namespace Accounts {
oldPassword: string,
newPassword: string,
callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void
): void;
): Promise<void>;

function forgotPassword(
options: { email?: string | undefined },
callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void
): void;
): Promise<void>;

function resetPassword(
token: string,
newPassword: string,
callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void
): void;
): Promise<void>;

function verifyEmail(
token: string,
callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void
): void;
): Promise<void>;

function onEmailVerificationLink(callback: Function): void;

Expand All @@ -143,11 +143,11 @@ export namespace Accounts {

function logout(
callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void
): void;
): Promise<void>;

function logoutOtherClients(
callback?: (error?: Error | Meteor.Error | Meteor.TypedError) => void
): void;
): Promise<void>;

type PasswordSignupField = 'USERNAME_AND_EMAIL' | 'USERNAME_AND_OPTIONAL_EMAIL' | 'USERNAME_ONLY' | 'EMAIL_ONLY';
type PasswordlessSignupField = 'USERNAME_AND_EMAIL' | 'EMAIL_ONLY';
Expand Down Expand Up @@ -179,9 +179,9 @@ export interface EmailTemplates {
export namespace Accounts {
var emailTemplates: EmailTemplates;

function addEmail(userId: string, newEmail: string, verified?: boolean): void;
function addEmailAsync(userId: string, newEmail: string, verified?: boolean): Promise<void>;

function removeEmail(userId: string, email: string): void;
function removeEmail(userId: string, email: string): Promise<void>;

function onCreateUser(
func: (options: { profile?: {} | undefined }, user: Meteor.User) => void
Expand All @@ -190,35 +190,35 @@ export namespace Accounts {
function findUserByEmail(
email: string,
options?: { fields?: Mongo.FieldSpecifier | undefined }
): Meteor.User | null | undefined;
): Promise<Meteor.User | null | undefined>;

function findUserByUsername(
username: string,
options?: { fields?: Mongo.FieldSpecifier | undefined }
): Meteor.User | null | undefined;
): Promise<Meteor.User | null | undefined>;

function sendEnrollmentEmail(
userId: string,
email?: string,
extraTokenData?: Record<string, unknown>,
extraParams?: Record<string, unknown>
): void;
): Promise<void>;

function sendResetPasswordEmail(
userId: string,
email?: string,
extraTokenData?: Record<string, unknown>,
extraParams?: Record<string, unknown>
): void;
): Promise<void>;

function sendVerificationEmail(
userId: string,
email?: string,
extraTokenData?: Record<string, unknown>,
extraParams?: Record<string, unknown>
): void;
): Promise<void>;

function setUsername(userId: string, newUsername: string): void;
function setUsername(userId: string, newUsername: string): Promise<void>;

function setPasswordAsync(
userId: string,
Expand Down
7 changes: 3 additions & 4 deletions packages/accounts-base/accounts_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,15 +1265,14 @@ export class AccountsServer extends AccountsCommon {
// that would give a lot of power to an attacker with a stolen login
// token and the ability to crash the server.
Meteor.startup(async () => {
const users = await this.users.find({
await this.users.find({
"services.resume.haveLoginTokensToDelete": true
}, {
fields: {
"services.resume.loginTokensToDelete": 1
}
})
users.forEach(user => {
this._deleteSavedTokensForUser(
}).forEachAsync(user => {
return this._deleteSavedTokensForUser(
user._id,
user.services.resume.loginTokensToDelete
)
Expand Down
4 changes: 2 additions & 2 deletions packages/minimongo/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getAsyncMethodName(method) {
return `${method.replace('_', '')}Async`;
}

export const ASYNC_COLLECTION_METHODS = [
export const COLLECTION_METHODS = [
'_createCappedCollection',
'dropCollection',
'dropIndex',
Expand Down Expand Up @@ -90,7 +90,7 @@ export const ASYNC_COLLECTION_METHODS = [
'upsert',
];

export const ASYNC_CURSOR_METHODS = [
export const CURSOR_METHODS = [
/**
* @deprecated in 2.9
* @summary Returns the number of documents that match a query. This method is
Expand Down
4 changes: 2 additions & 2 deletions packages/minimongo/cursor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import LocalCollection from './local_collection.js';
import { hasOwn } from './common.js';
import { ASYNC_CURSOR_METHODS, getAsyncMethodName } from './constants';
import { CURSOR_METHODS, getAsyncMethodName } from './constants';

// Cursor: a specification for a particular subset of documents, w/ a defined
// order, limit, and offset. creating a Cursor with LocalCollection.find(),
Expand Down Expand Up @@ -558,7 +558,7 @@ export default class Cursor {
}

// Implements async version of cursor methods to keep collections isomorphic
ASYNC_CURSOR_METHODS.forEach(method => {
CURSOR_METHODS.forEach(method => {
const asyncName = getAsyncMethodName(method);
Cursor.prototype[asyncName] = function(...args) {
try {
Expand Down
5 changes: 0 additions & 5 deletions packages/mongo/collection.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// options.connection, if given, is a LivedataClient or LivedataServer
// XXX presently there is no way to destroy/clean up a Collection
import {
ASYNC_COLLECTION_METHODS,
getAsyncMethodName,
} from 'meteor/minimongo/constants';

import { normalizeProjection } from "./mongo_utils";

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/mongo/collection_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ Tinytest.add('collection - calling find with a valid readPreference',
// as the cursor options are now private
// You can check on abstract_cursor.ts the exposed public getters
test.equal(
defaultCursor._synchronousCursor._dbCursor.readPreference
defaultCursor._asynchronousCursor._dbCursor.readPreference
.mode,
defaultReadPreference
);
test.equal(
customCursor._synchronousCursor._dbCursor.readPreference.mode,
customCursor._asynchronousCursor._dbCursor.readPreference.mode,
customReadPreference
);
}
Expand All @@ -214,7 +214,7 @@ Tinytest.addAsync('collection - calling find with an invalid readPreference',
);

await test.throwsAsync(async function() {
// Trigger the creation of _synchronousCursor
// Trigger the creation of _asynchronousCursor
await cursor.countAsync();
}, `Invalid read preference mode "${invalidReadPreference}"`);
}
Expand Down
Loading
Loading