Merge pull request #12250 from meteor/release-2.8.1

Release 2.8.1
This commit is contained in:
Gabriel Grubba
2022-11-17 16:25:35 -03:00
committed by GitHub
149 changed files with 3689 additions and 348 deletions

View File

@@ -343,7 +343,7 @@ jobs:
- run:
name: "Running self-test (Test Group 3)"
command: |
if [ -f ./tmp/test-groups/3.txt ]; then TEST_GROUP=$(<./tmp/test-groups/3.txt); elif [ -f ./tmp/test-groups/0.txt ]; then TEST_GROUP=XXXXX; else TEST_GROUP='^c[p-z]|^[d-g]|^h[a-e]'; fi
if [ -f ./tmp/test-groups/3.txt ]; then TEST_GROUP=$(<./tmp/test-groups/3.txt); elif [ -f ./tmp/test-groups/0.txt ]; then TEST_GROUP=XXXXX; else TEST_GROUP='^c[p-z]|^h[a-e]'; fi
echo $TEST_GROUP;
eval $PRE_TEST_COMMANDS;
./meteor self-test \
@@ -353,7 +353,7 @@ jobs:
--headless \
--junit ./tmp/results/junit/3.xml \
--without-tag "custom-warehouse"
no_output_timeout: 20m
no_output_timeout: 30m
- run:
<<: *run_save_node_bin
- store_test_results:
@@ -648,6 +648,46 @@ jobs:
- store_artifacts:
path: /tmp/memuse.txt
Test Group 11:
<<: *build_machine_environment
steps:
- run:
<<: *run_log_mem_use
- run:
<<: *run_env_change
- attach_workspace:
at: .
- run:
name: "Print environment"
command: printenv
- run:
name: "Running self-test (Test Group 11)"
command: |
if [ -f ./tmp/test-groups/11.txt ]; then TEST_GROUP=$(<./tmp/test-groups/11.txt); elif [ -f ./tmp/test-groups/0.txt ]; then TEST_GROUP=XXXXX; else TEST_GROUP='^[d-g]'; fi
echo $TEST_GROUP;
eval $PRE_TEST_COMMANDS;
./meteor self-test \
"$TEST_GROUP" \
--retries ${METEOR_SELF_TEST_RETRIES} \
--exclude "${SELF_TEST_EXCLUDE}" \
--headless \
--junit ./tmp/results/junit/11.xml \
--without-tag "custom-warehouse"
no_output_timeout: 30m
- run:
<<: *run_save_node_bin
- store_test_results:
path: ./tmp/results
- persist_to_workspace:
root: .
paths: ./tmp/results/junit
- store_artifacts:
path: ./tmp/results
- store_artifacts:
path: /tmp/core_dumps
- store_artifacts:
path: /tmp/memuse.txt
# Test the JSDoc declarations which live within this codebase against the
# Meteor Docs (https://github.com/meteor/docs) repository, where they'll
# eventually be consumed. This test aims to provide an early warning of
@@ -804,6 +844,9 @@ workflows:
- Test Group 10:
requires:
- Get Ready
- Test Group 11:
requires:
- Get Ready
- Clean Up:
requires:
- Isolated Tests
@@ -818,3 +861,4 @@ workflows:
- Test Group 8
- Test Group 9
- Test Group 10
- Test Group 11

View File

@@ -67,7 +67,6 @@ tools/runners/run-app.js
tools/runners/run-mongo.js
tools/runners/run-proxy.js
tools/runners/run-selenium.js
tools/runners/run-updater.js
tools/packaging/package-client.js
tools/packaging/package-map.js

View File

@@ -86,6 +86,7 @@ sidebar_categories:
Command Line:
- commandline
- environment-variables
- using-core-types
Troubleshooting:
- expired-certificate
- windows

View File

@@ -1,3 +1,119 @@
## 2.8.1, 2022-11-14
#### Highlights
- modernize tools/run-updater.js by [afrokick](https://github.com/afrokick)
- feat(error message): Especifing error message when cross-boundary by [Grubba27](https://github.com/Grubba27)
- Type definitions for core packages by [piotrpospiech](https://github.com/piotrpospiech)
- Add https proxy support to meteor-installer by [heschong](https://github.com/heschong)
- Fix case insensitive lookup resource overuse by [ToyboxZach](https://github.com/ToyboxZach)
- Update default Facebook API to v15 and fix local changelog by [StorytellerCZ](https://github.com/StorytellerCZ)
- Bump to Node v14.21.1 by [StorytellerCZ](https://github.com/StorytellerCZ)
- Use true mongo binary types by [znewsham](https://github.com/znewsham)
- Add docs for Accounts.registerLoginHandler by [shivam1646](https://github.com/shivam1646)
- Updated MongoDB driver to 4.11 by [radekmie](https://github.com/radekmie)
- Show port in restart message by [harryadel](https://github.com/harryadel)
- In the client, don't wait if the stub doesn't return a promise by [denihs](https://github.com/denihs)
- The rest of type definitions for core packages by [piotrpospiech](https://github.com/piotrpospiech)
- Removing underscore in packages by [harryadel](https://github.com/harryadel):
- [twitter-oauth] Remove underscore
- [test-in-browser] Remove underscore
- [webapp-hashing] Remove underscore
- [browser-policy] Remove underscore
- [ecmascript] Remove underscore
- [browser-policy-framing] Remove underscore
- [diff-sequence] Remove underscore
- [facts-ui] Remove underscore
- [geojson-utils] Remove underscore
#### Breaking Changes
N/A
#### Migration Steps
_In case you want types in your app using the core packages types/zodern:types (now you do have the option)_
1. Remove `@types/meteor` package
2. Install [`zodern:types`](https://github.com/zodern/meteor-types) package
3. Follow [installation guide for the Meteor Apps](https://github.com/zodern/meteor-types#meteor-apps) to update
#### Meteor Version Release
* `accounts-base@2.2.5`
- added types for package.
* `browser-policy@1.1.1`
- adjusted package tests.
* `browser-policy-common@1.0.12`
- added types for package.
* `browser-policy-framing@1.1.1`
- removed underscore.
* `check@1.3.2`
- added types for package.
* `ddp@1.4.0`
- added types for package.
* `ddp-client@2.6.1`
- In the client, don't wait if the stub doesn't return a promise.
* `ddp-rate-limiter@1.1.1`
- added types for package.
* `diff-sequence@1.1.2`
- removed underscore.
* `ecmascript@0.16.3`
- removed underscore.
* `ejson@1.1.3`
- added types for package.
* `ejson@2.2.2`
- added types for package.
* `facebook-oauth@1.12.0`
- Updated default version of Facebook GraphAPI to v15
* `facts-ui@1.0.1`
- removed underscore.
* `fetch@0.1.2`
- added types for package.
* `geojson-utils@1.0.11`
- removed underscore.
* `hot-module-replacement@0.5.2`
- added types for package.
* `meteor@1.10.2`
- added types for package.
* `modern-browsers@0.1.9`
- added types for package.
* `modules-runtime@0.13.2`
- added accurate error messages.
* `modules-runtime-hot@0.14.1`
- added accurate error messages.
* `mongo@1.16.1`
- added types for package.
- added true mongo binary
* `npm-mongo@4.11.0`
- updated npm mongo version to match npm one.
* `promise@0.13.0`
- added types for package.
* `random@1.2.1`
- added types for package.
* `reactive-dict@1.3.1`
- added types for package.
* `reactive-dict@1.0.12`
- added types for package.
* `server-render@0.4.1`
- added types for package.
* `service-configuration@1.3.1`
- added types for package.
* `session@1.2.1`
- added types for package.
* `test-in-browser@1.3.1`
- removed underscore.
* `tracker@1.2.1`
- added types for package.
* `twitter-oauth@1.3.1`
- removed underscore.
* `underscore@1.0.11`
- added types for package.
* `webapp@1.13.2`
- added types for package.
* `webapp-hashing@1.1.1`
- added types for package.
## v2.8, 2022-10-19
#### Highlights
@@ -77,7 +193,7 @@ Read our [Migration Guide](https://guide.meteor.com/2.8-migration.html) for this
For making this great framework even better!
## v2.7.3, 2022-05-31
## v2.7.3, 2022-05-3
#### Highlights
* `accounts-passwordless@2.1.2`:
@@ -3910,9 +4026,9 @@ N/A
> Note: With this version of Reify, `import` declarations are compiled to
`module.watch(require(id), ...)` instead of `module.importSync(id, ...)`
or the older `module.import(id, ...)`. The behavior of the compiled code
should be the same as before, but the details seemed different enough to
warrant a note.
> or the older `module.import(id, ...)`. The behavior of the compiled code
> should be the same as before, but the details seemed different enough to
> warrant a note.
* The `install` npm package has been upgraded to version 0.10.1.
@@ -4256,15 +4372,15 @@ https://github.com/meteor/meteor/commit/0cbd25111d1249a61ca7adce23fad5215408c821
are once again constrained by the current Meteor release.
> Before Meteor 1.4, the current release dictated the exact version of
every installed core package, which meant newer core packages could not
be installed without publishing a new Meteor release. In order to
support incremental development of core packages, Meteor 1.4 removed all
release-based constraints on core package versions
> every installed core package, which meant newer core packages could not
> be installed without publishing a new Meteor release. In order to
> support incremental development of core packages, Meteor 1.4 removed all
> release-based constraints on core package versions
([#7084](https://github.com/meteor/meteor/pull/7084)). Now, in Meteor
1.4.3, core package versions must remain patch-compatible with the
versions they had when the Meteor release was published. This middle
ground restores meaning to Meteor releases, yet still permits patch
updates to core packages.
> 1.4.3, core package versions must remain patch-compatible with the
> versions they had when the Meteor release was published. This middle
> ground restores meaning to Meteor releases, yet still permits patch
> updates to core packages.
* The `cordova-lib` npm package has been updated to 6.4.0, along with
cordova-android (6.1.1) and cordova-ios (4.3.0), and various plugins.
@@ -4354,11 +4470,11 @@ updates to core packages.
change was deemed too significant for this release.
> Note: The decision to revert the above change was made late in the
Meteor 1.4.2.4 release process, before it was ever recommended but too
late in the process to avoid the additional increment of the version number.
See [#8311](https://github.com/meteor/meteor/pull/8311) for additional
information. This change will still be released in an upcoming version
of Meteor with a more seamless upgrade.
> Meteor 1.4.2.4 release process, before it was ever recommended but too
> late in the process to avoid the additional increment of the version number.
> See [#8311](https://github.com/meteor/meteor/pull/8311) for additional
> information. This change will still be released in an upcoming version
> of Meteor with a more seamless upgrade.
## v1.4.2.4, 2017-02-02
@@ -4367,7 +4483,7 @@ of Meteor with a more seamless upgrade.
* The `npm` npm package has been upgraded from version 3.10.9 to 4.1.2.
> Note: This change was later deemed too substantial for a point release
and was reverted in Meteor 1.4.2.7.
> and was reverted in Meteor 1.4.2.7.
* Fix for [Issue #8136](https://github.com/meteor/meteor/issues/8136).
@@ -4394,9 +4510,9 @@ and was reverted in Meteor 1.4.2.7.
> Note: Meteor 1.4.2.2 was finalized before
[#8045](https://github.com/meteor/meteor/pull/8045) was merged, but
those changes were [deemed important
> those changes were [deemed important
enough](https://github.com/meteor/meteor/pull/8044#issuecomment-260913739)
to skip recommending 1.4.2.2 and instead immediately release 1.4.2.3.
> to skip recommending 1.4.2.2 and instead immediately release 1.4.2.3.
## v1.4.2.2, 2016-11-15
@@ -4483,10 +4599,10 @@ to skip recommending 1.4.2.2 and instead immediately release 1.4.2.3.
See https://github.com/meteor/meteor/pull/7668 for more details.
> Note: the `METEOR_PROFILE` environment variable now provides data for
server startup time as well as build time, which should make it easier
to tell which of your packages are responsible for slow startup times.
Please include the output of `METEOR_PROFILE=10 meteor run` with any
GitHub issue about rebuild performance.
> server startup time as well as build time, which should make it easier
> to tell which of your packages are responsible for slow startup times.
> Please include the output of `METEOR_PROFILE=10 meteor run` with any
> GitHub issue about rebuild performance.
* `npm` has been upgraded to version 3.10.9.
@@ -5063,8 +5179,8 @@ GitHub issue about rebuild performance.
## v1.3.2.4, 2016-04-20
> Meteor 1.3.2.4 was published because publishing 1.3.2.3 failed in an
unrecoverable way. Meteor 1.3.2.4 contains no additional changes beyond
the changes in 1.3.2.3.
> unrecoverable way. Meteor 1.3.2.4 contains no additional changes beyond
> the changes in 1.3.2.3.
## v1.3.2.3, 2016-04-20

View File

@@ -315,6 +315,15 @@ Accounts.setAdditionalFindUserOnExternalLogin(({serviceName, serviceData}) => {
}
})
```
{% apibox "AccountsServer#registerLoginHandler" %}
Use this to register your own custom authentication method. This is also used by all of the other inbuilt accounts packages to integrate with the accounts system.
There can be multiple login handlers that are registered. When a login request is made, it will go through all these handlers to find its own handler.
The registered handler callback is called with a single argument, the `options` object which comes from the login method. For example, if you want to login with a plaintext password, `options` could be `{ user: { username: <username> }, password: <password> }`,or `{ user: { email: <email> }, password: <password> }`.
The login handler should return `undefined` if it's not going to handle the login request or else the login result object.
<h2 id="accounts_rate_limit">Rate Limiting</h2>

View File

@@ -0,0 +1,39 @@
---
title: Using Core Types
description: Using core types with zodern:types
---
For MeteorJS in its version 2.8.1 we have introduced to our core packages an integration with the [zodern:types](https://github.com/zodern/meteor-types) package.
This package allows you to use the TypeScript types for the Meteor core packages in your TypeScript code or JavaScript code.
in order to use the types you need to install the package by running the command:
```bash
meteor add zodern:types
```
And add the following line to your `tsconfig.json` file (if you do not have one, create one and add the code bellow):
```json
{
"compilerOptions": {
"preserveSymlinks": true,
"paths": {
"meteor/*": [
"node_modules/@types/meteor/*",
".meteor/local/types/packages.d.ts"
]
}
}
}
```
then run the command:
```bash
meteor lint
```
this will create a file within your .meteor folder that will have your types for the core packages.
You can continue to use your code as you did before, but now you can use the types for the core packages even if you are in JavaScript.
for more information about the package please visit the [zodern:types](https://github.com/zodern/meteor-types).

2
meteor
View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
BUNDLE_VERSION=14.20.1.0
BUNDLE_VERSION=14.21.1.0
# OS Check. Put here because here is where we download the precompiled
# bundles that are arch specific.

View File

@@ -67,7 +67,6 @@ tools/runners/run-app.js
tools/runners/run-mongo.js
tools/runners/run-proxy.js
tools/runners/run-selenium.js
tools/runners/run-updater.js
tools/packaging/package-client.js
tools/packaging/package-map.js

View File

@@ -14,6 +14,7 @@ npm install -g meteor
| NPM Package | Meteor Official Release |
|-------------|-------------------------|
| 2.8.1 | 2.8.1 |
| 2.8.0 | 2.8.0 |
| 2.7.5 | 2.7.3 |
| 2.7.4 | 2.7.3 |
@@ -57,3 +58,8 @@ npm install -g meteor --ignore-meteor-setup-exec-path
```
(or by setting the environment variable `npm_config_ignore_meteor_setup_exec_path=true`)
### Proxy configuration
Setting the `https_proxy` or `HTTPS_PROXY` environment variable to a valid proxy URL will cause the
downloader to use the configured proxy to retrieve the Meteor files.

View File

@@ -1,7 +1,7 @@
const path = require('path');
const os = require('os');
const METEOR_LATEST_VERSION = '2.8.0';
const METEOR_LATEST_VERSION = '2.8.1';
const sudoUser = process.env.SUDO_USER || '';
function isRoot() {
return process.getuid && process.getuid() === 0;

View File

@@ -1,4 +1,5 @@
const { DownloaderHelper } = require('node-downloader-helper');
const HttpsProxyAgent = require('https-proxy-agent');
const cliProgress = require('cli-progress');
const Seven = require('node-7z');
const path = require('path');
@@ -143,6 +144,15 @@ try {
download();
function generateProxyAgent() {
const proxyUrl = process.env.https_proxy || process.env.HTTPS_PROXY;
if (!proxyUrl) {
return undefined;
}
return new HttpsProxyAgent(proxyUrl);
}
function download() {
const start = Date.now();
const downloadProgress = new cliProgress.SingleBar(
@@ -158,6 +168,9 @@ function download() {
retry: { maxRetries: 5, delay: 5000 },
override: true,
fileName: tarGzName,
httpsRequestOptions: {
agent: generateProxyAgent()
}
});
dl.on('progress', ({ progress }) => {

View File

@@ -1,6 +1,6 @@
{
"name": "meteor",
"version": "2.8.0",
"version": "2.8.1",
"description": "Install Meteor",
"main": "install.js",
"scripts": {

View File

@@ -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<string, unknown>,
extraParams?: Record<string, unknown>
): void;
function sendResetPasswordEmail(
userId: string,
email?: string,
extraTokenData?: Record<string, unknown>,
extraParams?: Record<string, unknown>
): void;
function sendVerificationEmail(
userId: string,
email?: string,
extraTokenData?: Record<string, unknown>,
extraParams?: Record<string, unknown>
): 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<T>(
userId: string,
token: HashedStampedLoginToken,
query?: Mongo.Selector<T> | Mongo.ObjectID | string
): void;
function _hashLoginToken(token: string): string;
}

View File

@@ -318,7 +318,7 @@ export class AccountsServer extends AccountsCommon {
// If user is not found, try a case insensitive lookup
if (!user) {
selector = this._selectorForFastCaseInsensitiveLookup(fieldName, fieldValue);
const candidateUsers = Meteor.users.find(selector, options).fetch();
const candidateUsers = Meteor.users.find(selector, { ...options, limit: 2 }).fetch();
// No match if multiple candidates are found
if (candidateUsers.length === 1) {
user = candidateUsers[0];
@@ -547,19 +547,14 @@ export class AccountsServer extends AccountsCommon {
/// LOGIN HANDLERS
///
// 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
/**
* @summary Registers a new login handler.
* @locus Server
* @param {String} [name] The type of login method like oauth, password, etc.
* @param {Function} handler 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 or a login method result object.
*/
registerLoginHandler(name, handler) {
if (! handler) {
handler = name;

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "accounts-base.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: 'A user account system',
version: '2.2.4',
version: '2.2.5',
});
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 => {

View File

@@ -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;
};
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "browser-policy-common.d.ts"
}

View File

@@ -1,10 +1,11 @@
Package.describe({
summary: "Common code for browser-policy packages",
version: "1.0.11"
version: "1.0.12"
});
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');
});

View File

@@ -12,7 +12,7 @@ var xFrameOptions = defaultXFrameOptions;
const BrowserPolicy = require("meteor/browser-policy-common").BrowserPolicy;
BrowserPolicy.framing = {};
_.extend(BrowserPolicy.framing, {
Object.assign(BrowserPolicy.framing, {
// Exported for tests and browser-policy-common.
_constructXFrameOptions: function () {
return xFrameOptions;

View File

@@ -1,11 +1,11 @@
Package.describe({
summary: "Restrict which websites can frame your app",
version: "1.1.0"
version: '1.1.1'
});
Package.onUse(function (api) {
api.use("modules");
api.use(["underscore", "browser-policy-common"], "server");
api.use(["browser-policy-common"], "server");
api.imply(["browser-policy-common"], "server");
api.mainModule("browser-policy-framing.js", "server");
});

View File

@@ -1,17 +1,34 @@
BrowserPolicy._setRunningTest();
var toObject = function(list, values) {
if (list == null) return {};
var result = {};
for (var i = 0, length = list.length; i < length; i++) {
if (values) {
result[list[i]] = values[i];
} else {
result[list[i][0]] = list[i][1];
}
}
return result;
};
var cspsEqual = function (csp1, csp2) {
var cspToObj = function (csp) {
csp = csp.substring(0, csp.length - 1);
var parts = _.map(csp.split("; "), function (part) {
var parts = csp.split("; ").map(function (part) {
return part.split(" ");
});
var keys = _.map(parts, _.first);
var values = _.map(parts, _.rest);
_.each(values, function (value) {
var keys = parts.map(part => part[0]);
var values = parts.map((part) => {
const [head, ...tail] = part;
return tail;
});
values.forEach(function (value) {
value.sort();
});
return _.object(keys, values);
return toObject(keys, values);
};
return EJSON.equals(cspToObj(csp1), cspToObj(csp2));
@@ -137,11 +154,11 @@ Tinytest.add("browser-policy - csp", function (test) {
"default-src 'none'; frame-src https://foo.com; " +
"object-src http://foo.com https://foo.com;"));
// Check that frame-ancestors property is set correctly.
BrowserPolicy.content.allowFrameAncestorsOrigin("https://foo.com/");
test.isTrue(cspsEqual(BrowserPolicy.content._constructCsp(),
"default-src 'none'; frame-src https://foo.com; " +
"object-src http://foo.com https://foo.com; " +
// Check that frame-ancestors property is set correctly.
BrowserPolicy.content.allowFrameAncestorsOrigin("https://foo.com/");
test.isTrue(cspsEqual(BrowserPolicy.content._constructCsp(),
"default-src 'none'; frame-src https://foo.com; " +
"object-src http://foo.com https://foo.com; " +
"frame-ancestors https://foo.com;"));
// CSP2 options: nonce
@@ -188,4 +205,4 @@ Tinytest.add("browser-policy - X-Content-Type-Options", function (test) {
test.equal(BrowserPolicy.content._xContentTypeOptions(), "nosniff");
BrowserPolicy.content.allowContentTypeSniffing();
test.equal(BrowserPolicy.content._xContentTypeOptions(), undefined);
});
});

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "Configure security policies enforced by the browser",
version: "1.1.0"
version: '1.1.1'
});
Package.onUse(function (api) {
@@ -11,6 +11,6 @@ Package.onUse(function (api) {
});
Package.onTest(function (api) {
api.use(["tinytest", "browser-policy", "ejson", "underscore"], "server");
api.use(["tinytest", "browser-policy", "ejson"], "server");
api.addFiles("browser-policy-test.js", "server");
});

92
packages/check/check.d.ts vendored Normal file
View File

@@ -0,0 +1,92 @@
/**
* The namespace for all Match types and methods.
*/
export namespace Match {
interface Matcher<T> {
_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<any>;
// prettier-ignore
export type PatternMatch<T extends Pattern> =
T extends Matcher<infer U> ? 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[0]>[] :
T extends {[key: string]: Pattern} ? {[K in keyof T]: PatternMatch<T[K]>} :
unknown;
/** Matches any value. */
var Any: Matcher<any>;
/** Matches a signed 32-bit integer. Doesnt match `Infinity`, `-Infinity`, or `NaN`. */
var Integer: Matcher<number>;
/**
* 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<T extends Pattern>(
pattern: T
): Matcher<PatternMatch<T> | undefined | null>;
/** Behaves like `Match.Maybe` except it doesnt accept `null`. If used in an object, the behavior is identical to `Match.Maybe`. */
function Optional<T extends Pattern>(
pattern: T
): Matcher<PatternMatch<T> | undefined>;
/** Matches an Object with the given keys; the value may also have other keys with arbitrary values. */
function ObjectIncluding<T extends { [key: string]: Pattern }>(
dico: T
): Matcher<PatternMatch<T>>;
/** Matches any value that matches at least one of the provided patterns. */
function OneOf<T extends Pattern[]>(
...patterns: T
): Matcher<PatternMatch<T[number]>>;
/**
* 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<T>(condition: (val: any) => val is T): Matcher<T>;
function Where(condition: (val: any) => boolean): Matcher<any>;
/**
* Returns true if the value matches the pattern.
* @param value The value to check
* @param pattern The pattern to match `value` against
*/
function test<T extends Pattern>(
value: any,
pattern: T
): value is PatternMatch<T>;
}
/**
* 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<T extends Match.Pattern>(
value: any,
pattern: T
): asserts value is Match.PatternMatch<T>;

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "check.d.ts"
}

View File

@@ -1,12 +1,14 @@
Package.describe({
summary: 'Check whether a value matches a pattern',
version: '1.3.1',
version: '1.3.2',
});
Package.onUse(api => {
api.use('ecmascript');
api.use('ejson');
api.addAssets('check.d.ts', 'server');
api.mainModule('match.js');
api.export('check');

View File

@@ -695,7 +695,14 @@ export class Connection {
invocation
);
try {
stubOptions.stubReturnValue = await stubInvocation();
const resultOrThenable = stubInvocation();
const isThenable =
resultOrThenable && typeof resultOrThenable.then === 'function';
if (isThenable) {
stubOptions.stubReturnValue = await resultOrThenable;
} else {
stubOptions.stubReturnValue = resultOrThenable;
}
} finally {
DDP._CurrentMethodInvocation._set(currentContext);
}

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "Meteor's latency-compensated distributed data client",
version: '2.6.0',
version: '2.6.1',
documentation: null
});

View File

@@ -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;
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "ddp-rate-limiter.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
name: 'ddp-rate-limiter',
version: '1.1.0',
version: '1.1.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');
});

65
packages/ddp/ddp.d.ts vendored Normal file
View File

@@ -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;
}
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "ddp.d.ts"
}

View File

@@ -1,12 +1,14 @@
Package.describe({
summary: "Meteor's latency-compensated distributed data framework",
version: '1.4.0'
version: '1.4.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');

View File

@@ -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
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
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
underscore@1.0.11
webapp@1.10.1
webapp-hashing@1.1.0

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "An implementation of a diff algorithm on arrays and objects.",
version: '1.1.1',
version: '1.1.2',
documentation: null
});
@@ -14,7 +14,6 @@ Package.onUse(function (api) {
Package.onTest(function (api) {
api.use([
'tinytest',
'underscore',
'ejson'
]);

View File

@@ -1,6 +1,6 @@
Tinytest.add("diff-sequence - diff changes ordering", function (test) {
var makeDocs = function (ids) {
return _.map(ids, function (id) { return {_id: id};});
return ids.map(function (id) { return {_id: id};});
};
var testMutation = function (a, b) {
var aa = makeDocs(a);
@@ -10,12 +10,12 @@ Tinytest.add("diff-sequence - diff changes ordering", function (test) {
addedBefore: function (id, doc, before) {
if (before === null) {
aaCopy.push( _.extend({_id: id}, doc));
aaCopy.push( Object.assign({_id: id}, doc));
return;
}
for (var i = 0; i < aaCopy.length; i++) {
if (aaCopy[i]._id === before) {
aaCopy.splice(i, 0, _.extend({_id: id}, doc));
aaCopy.splice(i, 0, Object.assign({_id: id}, doc));
return;
}
}
@@ -29,12 +29,12 @@ Tinytest.add("diff-sequence - diff changes ordering", function (test) {
}
}
if (before === null) {
aaCopy.push( _.extend({_id: id}, found));
aaCopy.push( Object.assign({_id: id}, found));
return;
}
for (i = 0; i < aaCopy.length; i++) {
if (aaCopy[i]._id === before) {
aaCopy.splice(i, 0, _.extend({_id: id}, found));
aaCopy.splice(i, 0, Object.assign({_id: id}, found));
return;
}
}
@@ -75,7 +75,7 @@ Tinytest.add("diff-sequence - diff", function (test) {
for (var i = 1; i <= origLen; i++)
oldResults[i-1] = {_id: i};
var newResults = _.map(newOldIdx, function(n) {
var newResults = newOldIdx.map(function(n) {
var doc = {_id: Math.abs(n)};
if (n < 0)
doc.changed = true;
@@ -89,7 +89,7 @@ Tinytest.add("diff-sequence - diff", function (test) {
return -1;
};
var results = _.clone(oldResults);
var results = [...oldResults];
var observer = {
addedBefore: function(id, fields, before) {
var before_idx;
@@ -97,7 +97,7 @@ Tinytest.add("diff-sequence - diff", function (test) {
before_idx = results.length;
else
before_idx = find (results, before);
var doc = _.extend({_id: id}, fields);
var doc = Object.assign({_id: id}, fields);
test.isFalse(before_idx < 0 || before_idx > results.length);
results.splice(before_idx, 0, doc);
},
@@ -157,4 +157,3 @@ Tinytest.add("diff-sequence - diff", function (test) {
diffTest(3, [-3, -2, -1]);
diffTest(10, [-2, 7, 4, 6, 11, -3, -8, 9]);
});

View File

@@ -1,6 +1,6 @@
Package.describe({
name: 'ecmascript',
version: '0.16.2',
version: '0.16.3',
summary: 'Compiler plugin that supports ES2015+ in all .js files',
documentation: 'README.md',
});
@@ -31,7 +31,7 @@ Package.onUse(function(api) {
});
Package.onTest(function(api) {
api.use(['tinytest', 'underscore']);
api.use(['tinytest']);
api.use(['es5-shim', 'ecmascript', 'babel-compiler']);
api.addFiles('runtime-tests.js');
api.addFiles('transpilation-tests.js', 'server');

View File

@@ -216,7 +216,7 @@ Tinytest.add('ecmascript - runtime - block scope', test => {
});
}
_.each(thunks, f => f());
thunks.forEach(f => f());
test.equal(buf, [0, 1, 2]);
}
});

71
packages/ejson/ejson.d.ts vendored Normal file
View File

@@ -0,0 +1,71 @@
export interface EJSONableCustomType {
clone?(): EJSONableCustomType;
equals?(other: Object): boolean;
toJSONValue(): JSONable;
typeName(): string;
}
export type EJSONableProperty =
| number
| string
| boolean
| Object
| number[]
| string[]
| Object[]
| Date
| Uint8Array
| EJSONableCustomType
| undefined
| null;
export interface EJSONable {
[key: string]: EJSONableProperty;
}
export interface JSONable {
[key: string]:
| number
| string
| boolean
| Object
| number[]
| string[]
| Object[]
| undefined
| null;
}
export interface EJSON extends EJSONable {}
export namespace EJSON {
function addType(
name: string,
factory: (val: JSONable) => EJSONableCustomType
): void;
function clone<T>(val: T): T;
function equals(
a: EJSON,
b: EJSON,
options?: { keyOrderSensitive?: boolean | undefined }
): boolean;
function fromJSONValue(val: JSONable): any;
function isBinary(x: Object): x is Uint8Array;
function newBinary(size: number): Uint8Array;
function parse(str: string): EJSON;
function stringify(
val: EJSON,
options?: {
indent?: boolean | number | string | undefined;
canonical?: boolean | undefined;
}
): string;
function toJSONValue(val: EJSON): JSONable;
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "ejson.d.ts"
}

View File

@@ -1,10 +1,11 @@
Package.describe({
summary: 'Extended and Extensible JSON library',
version: '1.1.2'
version: '1.1.3'
});
Package.onUse(function onUse(api) {
api.use(['ecmascript', 'base64']);
api.addAssets('ejson.d.ts', 'server');
api.mainModule('ejson.js');
api.export('EJSON');
});

44
packages/email/email.d.ts vendored Normal file
View File

@@ -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;
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "email.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: 'Send email messages',
version: '2.2.1',
version: '2.2.2',
});
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 });

View File

@@ -1,10 +1,26 @@
# Changelog
## 1.8.0 - unreleased
### Breaking changes
- N/A
## 1.12.0 - UNRELEASED
### Changes
- Updated default version of Facebook GraphAPI to v15
## 1.11.0 - 2022-03-24
### Changes
- Updated default version of Facebook GraphAPI to v12
## 1.10.0 - 2021-09-14
### Changes
- Added login handler hook, like in the Google package for easier management in React Native and similar apps. [PR](https://github.com/meteor/meteor/pull/11603)
## 1.9.1 - 2021-08-12
### Changes
- Allow usage of `http` package both v1 and v2 for backward compatibility
## 1.9.0 - 2021-06-24
### Changes
- Upgrade default Facebook API to v10 [#11362](https://github.com/meteor/meteor/pull/11362)
## 1.8.0 - 2021-04-15
### Changes
- Updated to use Facebook GraphAPI v10
- You can now override the default API version by setting `Meteor.settings.public.packages.facebook-oauth.apiVersion` to for example `8.0`
## 1.7.3 - 2020-10-05

View File

@@ -30,7 +30,7 @@ Facebook.requestCredential = (options, credentialRequestCompleteCallback) => {
const loginStyle = OAuth._loginStyle('facebook', config, options);
const API_VERSION = Meteor.settings?.public?.packages?.['facebook-oauth']?.apiVersion || '13.0';
const API_VERSION = Meteor.settings?.public?.packages?.['facebook-oauth']?.apiVersion || '15.0';
let loginUrl =
`https://www.facebook.com/v${API_VERSION}/dialog/oauth?client_id=${config.appId}` +

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "Facebook OAuth flow",
version: "1.11.0"
version: '1.11.1'
});
Package.onUse(api => {

View File

@@ -6,7 +6,7 @@ Template.serverFacts.helpers({
factsByPackage: () => Facts.server.find(),
facts: function () {
const factArray = [];
_.each(this, function (value, name) {
Object.entries(this).forEach(function ([name, value]) {
if (name !== '_id')
factArray.push({name: name, value: value});
});

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "Display internal app statistics",
version: '1.0.0'
version: '1.0.1'
});
Package.onUse(function (api) {
@@ -8,8 +8,7 @@ Package.onUse(function (api) {
'ecmascript',
'facts-base',
'mongo',
'templating@1.2.13',
'underscore',
'templating@1.2.13'
], 'client');
api.imply('facts-base');

4
packages/fetch/fetch.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
export declare function fetch(): typeof globalThis.fetch;
export declare var Headers: typeof globalThis.Headers;
export declare var Request: typeof globalThis.Request;
export declare var Response: typeof globalThis.Response;

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "fetch.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
name: "fetch",
version: "0.1.1",
version: '0.1.2',
summary: "Isomorphic modern/legacy/Node polyfill for WHATWG fetch()",
documentation: "README.md"
});
@@ -19,6 +19,7 @@ Package.onUse(function(api) {
api.mainModule("legacy.js", "legacy");
api.mainModule("server.js", "server");
api.addAssets("fetch.d.ts", "server");
// The other exports (Headers, Request, Response) can be imported
// explicitly from the "meteor/fetch" package.
api.export("fetch");

View File

@@ -85,8 +85,8 @@ Tinytest.add("geojson-utils - points distance generated tests", function (test)
6846704.0253010122, 1368055.9401701286, 14041503.0409814864,
18560499.7346975356, 3793112.6186894816];
_.each(tests, function (pair, testN) {
var distance = GeoJSON.pointDistance.apply(this, _.map(pair, toGeoJSONPoint));
tests.forEach(function (pair, testN) {
var distance = GeoJSON.pointDistance.apply(this, pair.map(toGeoJSONPoint));
test.isTrue(Math.abs(distance - answers[testN]) < 0.000001,
"Wrong distance between points " + JSON.stringify(pair) + ": " + distance + ", " + Math.abs(distance - answers[testN]) + " differenc");
});

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: 'GeoJSON utility functions (from https://github.com/maxogden/geojson-js-utils)',
version: '1.0.10'
version: '1.0.11'
});
Package.onUse(function (api) {
@@ -11,7 +11,6 @@ Package.onUse(function (api) {
Package.onTest(function (api) {
api.use('tinytest');
api.use('underscore');
api.use('geojson-utils');
api.addFiles(['geojson-utils.tests.js'], 'client');
});

View File

@@ -0,0 +1,14 @@
export interface Module {
readonly hot?: {
accept(): void;
decline(): void;
dispose(callback: (data: object) => void): void;
data: object | null;
onRequire<T>(callbacks: {
before?(requiredModule: Module, parentId: string): T;
after?(requiredModule: Module, data: T): void;
}): void;
};
}
export declare var module: NodeJS.Module;

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "hot-module-replacement.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
name: 'hot-module-replacement',
version: '0.5.1',
version: '0.5.2',
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 });

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: 'The Meteor command-line tool',
version: '2.8.0',
version: '2.8.1',
});
Package.includeTool();

504
packages/meteor/meteor.d.ts vendored Normal file
View File

@@ -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>;
/** 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<EJSONable | EJSONableProperty>,
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<TFunc extends Function>(func: TFunc): TFunc;
class EnvironmentVariable<T> {
readonly slot: number;
constructor();
get(): T;
getOrNullIfOutsideFiber(): T | null;
withValue<U>(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 subscriptions data from the clients 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<string> | 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<ExternalService>(
options?: {
requestPermissions?: ReadonlyArray<string> | 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 **/
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "meteor.d.ts"
}

View File

@@ -2,7 +2,7 @@
Package.describe({
summary: "Core Meteor environment",
version: '1.10.1'
version: '1.10.2'
});
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) {

4
packages/modern-browsers/modern.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
export declare function setMinimumBrowserVersions(
versions: Record<string, number | number[]>,
source: string
): void;

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "modern.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
name: 'modern-browsers',
version: '0.1.8',
version: '0.1.9',
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) {

View File

@@ -220,8 +220,8 @@ makeInstaller = function (options) {
var file = fileResolve(filesByModuleId[this.id], id);
if (file) return file.module.id;
var error = makeMissingError(id);
if (fallback && isFunction(fallback.resolve)) {
return fallback.resolve(id, this.id, error);
if (fallback && isFunction(fallback)) {
return fallback(id, this.id, error);
}
throw error;
};

View File

@@ -1,3 +1,5 @@
let verifyErrors = Package['modules-runtime'].verifyErrors;
meteorInstall = makeInstaller({
// On the client, make package resolution prefer the "browser" field of
// package.json over the "module" field over the "main" field.
@@ -8,15 +10,7 @@ meteorInstall = makeInstaller({
mainFields: ["browser", "main", "module"],
fallback: function (id, parentId, error) {
if (id && id.startsWith('meteor/')) {
var packageName = id.split('/', 2)[1];
throw new Error(
'Cannot find package "' + packageName + '". ' +
'Try "meteor add ' + packageName + '".'
);
}
throw error;
verifyErrors(id, parentId, error);
}
});

View File

@@ -1,3 +1,5 @@
let verifyErrors = Package['modules-runtime'].verifyErrors;
meteorInstall = makeInstaller({
// On the client, make package resolution prefer the "browser" field of
// package.json over the "module" field over the "main" field.
@@ -5,15 +7,7 @@ meteorInstall = makeInstaller({
mainFields: ["browser", "module", "main"],
fallback: function (id, parentId, error) {
if (id && id.startsWith('meteor/')) {
var packageName = id.split('/', 2)[1];
throw new Error(
'Cannot find package "' + packageName + '". ' +
'Try "meteor add ' + packageName + '".'
);
}
throw error;
verifyErrors(id, parentId, error);
}
});

View File

@@ -1,6 +1,6 @@
Package.describe({
name: 'modules-runtime-hot',
version: '0.14.0',
version: '0.14.1',
summary: 'Patches modules-runtime to support Hot Module Replacement',
git: 'https://github.com/benjamn/install',
documentation: 'README.md',

View File

@@ -0,0 +1,12 @@
/**
* @description Default error message for when a package is not found
* @param id{string}
* @return {Error}
*/
cannotFindMeteorPackage = function(id) {
var packageName = id.split('/', 2)[1];
return new Error(
'Cannot find package "' + packageName + '". ' +
'Try "meteor add ' + packageName + '".'
);
};

View File

@@ -0,0 +1,46 @@
/**
*
* @param id{string}
* @return {{fromServer: (function(): Error), from: (function(location: string): boolean), fromClient: (function(): Error)}}
*/
imports = function (id) {
/**
*
* @param location{string}
* @return {boolean}
*/
var from =
function (location) {
if (!id) {
return false;
}
// XXX: removed last part of path so that it does not trigger false positives
var path = String(id).split('/').slice(0, -1);
return path.some(function (subPath) {
return subPath === location;
});
};
var fromClientError =
function () {
return new Error(
'Unable to import on the server a module from a client directory: "' + id + '" \n (cross-boundary import) see: https://guide.meteor.com/structure.html#special-directories'
);
};
var fromServerError =
function () {
return new Error(
'Unable to import on the client a module from a server directory: "' + id + '" \n (cross-boundary import) see: https://guide.meteor.com/structure.html#special-directories'
);
};
return {
from: from,
fromClientError: fromClientError,
fromServerError: fromServerError
};
};

View File

@@ -5,17 +5,9 @@ meteorInstall = makeInstaller({
// The difference between legacy.js and modern.js is that this module
// prefers "main" over "module" (see issue #10658).
mainFields: ["browser", "main", "module"],
mainFields: ['browser', 'main', 'module'],
fallback: function(id, parentId, error) {
if (id && id.startsWith('meteor/')) {
var packageName = id.split('/', 2)[1];
throw new Error(
'Cannot find package "' + packageName + '". ' +
'Try "meteor add ' + packageName + '".'
);
}
throw error;
fallback: function (id, parentId, error) {
verifyErrors(id, parentId, error);
}
});

View File

@@ -2,17 +2,9 @@ meteorInstall = makeInstaller({
// On the client, make package resolution prefer the "browser" field of
// package.json over the "module" field over the "main" field.
browser: true,
mainFields: ["browser", "module", "main"],
mainFields: ['browser', 'module', 'main'],
fallback: function(id, parentId, error) {
if (id && id.startsWith('meteor/')) {
var packageName = id.split('/', 2)[1];
throw new Error(
'Cannot find package "' + packageName + '". ' +
'Try "meteor add ' + packageName + '".'
);
}
throw error;
fallback: function (id, parentId, error) {
verifyErrors(id, parentId, error);
}
});

View File

@@ -1,5 +1,76 @@
Tinytest.add('modules', function (test) {
test.equal(typeof meteorInstall, "function");
test.equal(typeof meteorInstall, 'function');
var require = meteorInstall();
test.equal(typeof require, "function");
test.equal(typeof require, 'function');
});
Tinytest.add('errors - standard', function (test) {
var require = meteorInstall();
test.throws(() => {
require('meteor/foo');
}, 'Cannot find package "foo". Try "meteor add foo".');
});
Tinytest.add('errors - node_modules', function (test) {
var require = meteorInstall();
test.throws(() => {
require('./node_modules/foo');
}, "Cannot find module './node_modules/foo'");
});
if (Meteor.isServer) {
Tinytest.add('server - throwClientError', function (test) {
var require = meteorInstall();
test.throws(() => {
require('./../server/main.js');
}, "Cannot find module './../server/main.js'"
);
});
Tinytest.add('server - client and server in path', function (test) {
var require = meteorInstall();
test.throws(() => {
require('/client/graphql/client');
},
'Unable to import on the server a module from a client directory: "/client/graphql/client" \n' +
' (cross-boundary import) see: https://guide.meteor.com/structure.html#special-directories'
);
});
Tinytest.add('server - throwServerError', function (test) {
var require = meteorInstall();
test.throws(() => {
require('./../client/main.js');
},
'Unable to import on the server a module from a client directory: "./../client/main.js" \n' +
' (cross-boundary import) see: https://guide.meteor.com/structure.html#special-directories'
);
});
}
if (Meteor.isClient) {
Tinytest.add('client - throwClientError', function (test) {
var require = meteorInstall();
test.throws(() => {
require('./../server/main.js');
},
'Unable to import on the client a module from a server directory: "./../server/main.js" \n' +
' (cross-boundary import) see: https://guide.meteor.com/structure.html#special-directories'
);
});
Tinytest.add('client - client and server in path', function (test) {
var require = meteorInstall();
test.throws(() => {
require('/server/graphql/client');
},
'Unable to import on the client a module from a server directory: "/server/graphql/client" \n' +
' (cross-boundary import) see: https://guide.meteor.com/structure.html#special-directories'
);
});
Tinytest.add('client - throwServerError', function (test) {
var require = meteorInstall();
test.throws(() => {
require('./../client/main.js');
}, "Cannot find module './../client/main.js'");
});
}

View File

@@ -1,6 +1,6 @@
Package.describe({
name: "modules-runtime",
version: "0.13.0",
version: '0.13.1',
summary: "CommonJS module system",
git: "https://github.com/benjamn/install",
documentation: "README.md"
@@ -18,12 +18,16 @@ Package.onUse(function(api) {
bare: true
});
api.addFiles("modern.js", "modern");
api.addFiles("legacy.js", "legacy");
api.addFiles("server.js", "server");
api.addFiles("profile.js");
api.addFiles(['./errors/importsErrors.js',
'./errors/cannotFindMeteorPackage.js']);
api.addFiles('modern.js', 'modern');
api.addFiles('legacy.js', 'legacy');
api.addFiles('server.js', 'server');
api.addFiles('profile.js');
api.addFiles('verifyErrors.js');
api.export("meteorInstall");
api.export('meteorInstall');
api.export('verifyErrors');
});
Package.onTest(function(api) {

View File

@@ -28,7 +28,7 @@ makeInstallerOptions.fallback = function (id, parentId, error) {
return Npm.require(id, error);
}
}
verifyErrors(id, parentId, error);
throw error;
};

View File

@@ -0,0 +1,34 @@
/**
*
* @param id{string}
* @param parentId{string}
* @param err {Error}
*/
verifyErrors = function (id, parentId,err) {
if (id && id.startsWith('meteor/')) {
throw cannotFindMeteorPackage(id);
}
if(!(id.startsWith('.') || id.startsWith('/'))) {
throw err;
}
if (imports(id).from('node_modules')) {
// Problem with node modules
throw err;
}
// custom errors
if (Meteor.isServer && imports(id).from('client')) {
throw imports(id).fromClientError();
}
if (Meteor.isClient && imports(id).from('server')) {
throw imports(id).fromServerError();
}
if (err) {
throw err;
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

View File

@@ -3,7 +3,7 @@ import { Random } from 'meteor/random';
const MongoID = {};
MongoID._looksLikeObjectID = str => str.length === 24 && str.match(/^[0-9a-f]*$/);
MongoID._looksLikeObjectID = str => str.length === 24 && /^[0-9a-f]*$/.test(str);
MongoID.ObjectID = class ObjectID {
constructor (hexString) {

View File

@@ -1,3 +1,6 @@
var MongoDB = NpmModuleMongodb;
Tinytest.add(
'collection - call Mongo.Collection without new',
function (test) {
@@ -203,3 +206,181 @@ Tinytest.add('collection - calling find with an invalid readPreference',
}
}
);
Tinytest.add('collection - inserting a document with a binary should return a document with a binary',
function(test) {
if (Meteor.isServer) {
const collection = new Mongo.Collection('testBinary1');
const _id = Random.id();
collection.insert({
_id,
binary: new MongoDB.Binary(Buffer.from('hello world'), 6)
});
const doc = collection.findOne({ _id });
test.ok(
doc.binary instanceof MongoDB.Binary
);
test.equal(
doc.binary.buffer,
Buffer.from('hello world')
);
}
}
);
Tinytest.add('collection - inserting a document with a binary (sub type 0) should return a document with a uint8array',
function(test) {
if (Meteor.isServer) {
const collection = new Mongo.Collection('testBinary8');
const _id = Random.id();
collection.insert({
_id,
binary: new MongoDB.Binary(Buffer.from('hello world'), 0)
});
const doc = collection.findOne({ _id });
test.ok(
doc.binary instanceof Uint8Array
);
test.equal(
doc.binary,
new Uint8Array(Buffer.from('hello world'))
);
}
}
);
Tinytest.add('collection - updating a document with a binary should return a document with a binary',
function(test) {
if (Meteor.isServer) {
const collection = new Mongo.Collection('testBinary2');
const _id = Random.id();
collection.insert({
_id
});
collection.update({ _id }, { $set: { binary: new MongoDB.Binary(Buffer.from('hello world'), 6) } });
const doc = collection.findOne({ _id });
test.ok(
doc.binary instanceof MongoDB.Binary
);
test.equal(
doc.binary.buffer,
Buffer.from('hello world')
);
}
}
);
Tinytest.add('collection - updating a document with a binary (sub type 0) should return a document with a uint8array',
function(test) {
if (Meteor.isServer) {
const collection = new Mongo.Collection('testBinary7');
const _id = Random.id();
collection.insert({
_id
});
collection.update({ _id }, { $set: { binary: new MongoDB.Binary(Buffer.from('hello world'), 0) } });
const doc = collection.findOne({ _id });
test.ok(
doc.binary instanceof Uint8Array
);
test.equal(
doc.binary,
new Uint8Array(Buffer.from('hello world'))
);
}
}
);
Tinytest.add('collection - inserting a document with a uint8array should return a document with a uint8array',
function(test) {
if (Meteor.isServer) {
const collection = new Mongo.Collection('testBinary3');
const _id = Random.id();
collection.insert({
_id,
binary: new Uint8Array(Buffer.from('hello world'))
});
const doc = collection.findOne({ _id });
test.ok(
doc.binary instanceof Uint8Array
);
test.equal(
doc.binary,
new Uint8Array(Buffer.from('hello world'))
);
}
}
);
Tinytest.add('collection - updating a document with a uint8array should return a document with a uint8array',
function(test) {
if (Meteor.isServer) {
const collection = new Mongo.Collection('testBinary4');
const _id = Random.id();
collection.insert({
_id
});
collection.update(
{ _id },
{ $set: { binary: new Uint8Array(Buffer.from('hello world')) } }
)
const doc = collection.findOne({ _id });
test.ok(
doc.binary instanceof Uint8Array
);
test.equal(
doc.binary,
new Uint8Array(Buffer.from('hello world'))
);
}
}
);
Tinytest.add('collection - finding with a query with a uint8array field should return the correct document',
function(test) {
if (Meteor.isServer) {
const collection = new Mongo.Collection('testBinary5');
const _id = Random.id();
collection.insert({
_id,
binary: new Uint8Array(Buffer.from('hello world'))
});
const doc = collection.findOne({ binary: new Uint8Array(Buffer.from('hello world')) });
test.equal(
doc._id,
_id
);
collection.remove({});
}
}
);
Tinytest.add('collection - finding with a query with a binary field should return the correct document',
function(test) {
if (Meteor.isServer) {
const collection = new Mongo.Collection('testBinary6');
const _id = Random.id();
collection.insert({
_id,
binary: new MongoDB.Binary(Buffer.from('hello world'), 6)
});
const doc = collection.findOne({ binary: new MongoDB.Binary(Buffer.from('hello world'), 6) });
test.equal(
doc._id,
_id
);
collection.remove({});
}
}
);

598
packages/mongo/mongo.d.ts vendored Normal file
View File

@@ -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, K extends keyof any> = T extends T
? Pick<T, Exclude<keyof T, K>>
: 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<T> = {
$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<T> | undefined;
$expr?: FieldExpression<T> | 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<T> : FieldExpression<T> | undefined;
$size?: number | undefined;
$bitsAllClear?: any;
$bitsAllSet?: any;
$bitsAnyClear?: any;
$bitsAnySet?: any;
$comment?: string | undefined;
};
type Flatten<T> = T extends any[] ? T[0] : T;
type Query<T> = {
[P in keyof T]?: Flatten<T[P]> | RegExp | FieldExpression<Flatten<T[P]>>;
} & {
$or?: Query<T>[] | undefined;
$and?: Query<T>[] | undefined;
$nor?: Query<T>[] | undefined;
} & Dictionary<any>;
type QueryWithModifiers<T> = {
$query: Query<T>;
$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<T> = Query<T> | QueryWithModifiers<T>;
type Dictionary<T> = { [key: string]: T };
type PartialMapTo<T, M> = Partial<Record<keyof T, M>>;
type OnlyArrays<T> = T extends any[] ? T : never;
type OnlyElementsOfArrays<T> = T extends any[] ? Partial<T[0]> : never;
type ElementsOf<T> = {
[P in keyof T]?: OnlyElementsOfArrays<T[P]>;
};
type PushModifier<T> = {
[P in keyof T]?:
| OnlyElementsOfArrays<T[P]>
| {
$each?: T[P] | undefined;
$position?: number | undefined;
$slice?: number | undefined;
$sort?: 1 | -1 | Dictionary<number> | undefined;
};
};
type ArraysOrEach<T> = {
[P in keyof T]?: OnlyElementsOfArrays<T[P]> | { $each: T[P] };
};
type CurrentDateModifier = { $type: 'timestamp' | 'date' } | true;
type Modifier<T> =
| T
| {
$currentDate?:
| (Partial<Record<keyof T, CurrentDateModifier>> &
Dictionary<CurrentDateModifier>)
| undefined;
$inc?: (PartialMapTo<T, number> & Dictionary<number>) | undefined;
$min?:
| (PartialMapTo<T, Date | number> & Dictionary<Date | number>)
| undefined;
$max?:
| (PartialMapTo<T, Date | number> & Dictionary<Date | number>)
| undefined;
$mul?: (PartialMapTo<T, number> & Dictionary<number>) | undefined;
$rename?: (PartialMapTo<T, string> & Dictionary<string>) | undefined;
$set?: (Partial<T> & Dictionary<any>) | undefined;
$setOnInsert?: (Partial<T> & Dictionary<any>) | undefined;
$unset?:
| (PartialMapTo<T, string | boolean | 1 | 0> & Dictionary<any>)
| undefined;
$addToSet?: (ArraysOrEach<T> & Dictionary<any>) | undefined;
$push?: (PushModifier<T> & Dictionary<any>) | undefined;
$pull?: (ElementsOf<T> & Dictionary<any>) | undefined;
$pullAll?: (Partial<T> & Dictionary<any>) | undefined;
$pop?: (PartialMapTo<T, 1 | -1> & Dictionary<1 | -1>) | undefined;
};
type OptionalId<TSchema> = UnionOmit<TSchema, '_id'> & { _id?: any };
interface SortSpecifier {}
interface FieldSpecifier {
[id: string]: Number;
}
type Transform<T> = ((doc: T) => any) | null | undefined;
type Options<T> = {
/** 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<T> | undefined;
};
type DispatchTransform<Transform, T, U> = Transform extends (
...args: any
) => any
? ReturnType<Transform>
: 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 <T extends MongoNpmModule.Document, U = T>(
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<T, U>;
}
interface Collection<T extends MongoNpmModule.Document, U = T> {
allow<Fn extends Transform<T> = undefined>(options: {
insert?:
| ((userId: string, doc: DispatchTransform<Fn, T, U>) => boolean)
| undefined;
update?:
| ((
userId: string,
doc: DispatchTransform<Fn, T, U>,
fieldNames: string[],
modifier: any
) => boolean)
| undefined;
remove?:
| ((userId: string, doc: DispatchTransform<Fn, T, U>) => boolean)
| undefined;
fetch?: string[] | undefined;
transform?: Fn | undefined;
}): boolean;
createCappedCollectionAsync(
byteSize?: number,
maxDocuments?: number
): Promise<void>;
createIndex(
indexSpec: IndexSpecification,
options?: CreateIndexesOptions
): void;
createIndexAsync(
indexSpec: IndexSpecification,
options?: CreateIndexesOptions
): Promise<void>;
deny<Fn extends Transform<T> = undefined>(options: {
insert?:
| ((userId: string, doc: DispatchTransform<Fn, T, U>) => boolean)
| undefined;
update?:
| ((
userId: string,
doc: DispatchTransform<Fn, T, U>,
fieldNames: string[],
modifier: any
) => boolean)
| undefined;
remove?:
| ((userId: string, doc: DispatchTransform<Fn, T, U>) => boolean)
| undefined;
fetch?: string[] | undefined;
transform?: Fn | undefined;
}): boolean;
dropCollectionAsync(): Promise<void>;
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<T> | ObjectID | string): Cursor<T, U>;
/**
* Find the documents in a collection that match the selector.
* @param selector A query describing the documents to find
*/
find<O extends Options<T>>(
selector?: Selector<T> | ObjectID | string,
options?: O
): Cursor<T, DispatchTransform<O['transform'], T, U>>;
/**
* 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<T> | 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<O extends Omit<Options<T>, 'limit'>>(
selector?: Selector<T> | ObjectID | string,
options?: O
): DispatchTransform<O['transform'], T, 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
*/
findOneAsync(
selector?: Selector<T> | ObjectID | string
): Promise<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
*/
findOneAsync<O extends Omit<Options<T>, 'limit'>>(
selector?: Selector<T> | ObjectID | string,
options?: O
): Promise<DispatchTransform<O['transform'], T, U> | 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<T>, 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<T>, callback?: Function): Promise<string>;
/**
* 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<T>;
/**
* 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<T> | 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<T> | ObjectID | string,
callback?: Function
): Promise<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.
*/
update(
selector: Selector<T> | ObjectID | string,
modifier: Modifier<T>,
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<T> | ObjectID | string,
modifier: Modifier<T>,
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<number>;
/**
* 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<T> | ObjectID | string,
modifier: Modifier<T>,
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<T> | ObjectID | string,
modifier: Modifier<T>,
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<void>;
_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 <T, U = T>(): Cursor<T, U>;
}
interface ObserveCallbacks<T> {
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<T> {
added?(id: string, fields: Partial<T>): void;
addedBefore?(id: string, fields: Partial<T>, before: T | null): void;
changed?(id: string, fields: Partial<T>): void;
movedBefore?(id: string, before: T | null): void;
removed?(id: string): void;
}
interface Cursor<T, U = T> {
/**
* 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<number>;
/**
* Return all matching documents as an Array.
*/
fetch(): Array<U>;
/**
* Return all matching documents as an Array.
*/
fetchAsync(): Promise<Array<U>>;
/**
* 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 <em>cursor</em> itself.
* @param thisArg An object which will be the value of `this` inside `callback`.
*/
forEach(
callback: (doc: U, index: number, cursor: Cursor<T, U>) => 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 <em>cursor</em> itself.
* @param thisArg An object which will be the value of `this` inside `callback`.
*/
forEachAsync(
callback: (doc: U, index: number, cursor: Cursor<T, U>) => void,
thisArg?: any
): Promise<void>;
/**
* 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 <em>cursor</em> itself.
* @param thisArg An object which will be the value of `this` inside `callback`.
*/
map<M>(
callback: (doc: U, index: number, cursor: Cursor<T, U>) => M,
thisArg?: any
): Array<M>;
/**
* 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 <em>cursor</em> itself.
* @param thisArg An object which will be the value of `this` inside `callback`.
*/
mapAsync<M>(
callback: (doc: U, index: number, cursor: Cursor<T, U>) => M,
thisArg?: any
): Promise<Array<M>>;
/**
* 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<U>): 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<T>,
options?: { nonMutatingCallbacks?: boolean | undefined }
): Meteor.LiveQueryHandle;
[Symbol.iterator](): Iterator<T, never, never>;
[Symbol.asyncIterator](): AsyncIterator<T, never, never>;
}
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;
};
};
}

View File

@@ -69,6 +69,10 @@ var unmakeMongoLegal = function (name) { return name.substr(5); };
var replaceMongoAtomWithMeteor = function (document) {
if (document instanceof MongoDB.Binary) {
// for backwards compatibility
if (document.sub_type !== 0) {
return document;
}
var buffer = document.value(true);
return new Uint8Array(buffer);
}
@@ -98,6 +102,9 @@ var replaceMeteorAtomWithMongo = function (document) {
// serialize it correctly).
return new MongoDB.Binary(Buffer.from(document));
}
if (document instanceof MongoDB.Binary) {
return document;
}
if (document instanceof Mongo.ObjectID) {
return new MongoDB.ObjectID(document.toHexString());
}

View File

@@ -9,7 +9,7 @@
Package.describe({
summary: "Adaptor for using MongoDB and Minimongo over DDP",
version: '1.16.0'
version: '1.16.1'
});
Npm.depends({
@@ -82,12 +82,14 @@ 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) {
api.use('mongo');
api.use('check');
api.use('ecmascript');
api.use('npm-mongo', 'server');
api.use(['tinytest', 'underscore', 'test-helpers', 'ejson', 'random',
'ddp', 'base64']);
// XXX test order dependency: the allow_tests "partial allow" test

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "mongo.d.ts"
}

View File

@@ -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
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
react-fast-refresh@0.1.1
reactive-var@1.0.11
reactive-var@1.0.12
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
underscore@1.0.11
webapp@1.11.1
webapp-hashing@1.1.0

View File

@@ -1,15 +1,355 @@
{
"lockfileVersion": 1,
"dependencies": {
"@aws-crypto/ie11-detection": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@aws-crypto/ie11-detection/-/ie11-detection-2.0.2.tgz",
"integrity": "sha512-5XDMQY98gMAf/WRTic5G++jfmS/VLM0rwpiOpaainKi4L0nqWMSB1SzsrEG5rjFZGYN6ZAefO+/Yta2dFM0kMw==",
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"@aws-crypto/sha256-browser": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@aws-crypto/sha256-browser/-/sha256-browser-2.0.0.tgz",
"integrity": "sha512-rYXOQ8BFOaqMEHJrLHul/25ckWH6GTJtdLSajhlqGMx0PmSueAuvboCuZCTqEKlxR8CQOwRarxYMZZSYlhRA1A==",
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"@aws-crypto/sha256-js": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-2.0.0.tgz",
"integrity": "sha512-VZY+mCY4Nmrs5WGfitmNqXzaE873fcIZDu54cbaDaaamsaTOP1DBImV9F4pICc3EHjQXujyE8jig+PFCaew9ig==",
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"@aws-crypto/supports-web-crypto": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@aws-crypto/supports-web-crypto/-/supports-web-crypto-2.0.2.tgz",
"integrity": "sha512-6mbSsLHwZ99CTOOswvCRP3C+VCWnzBf+1SnbWxzzJ9lR0mA0JnY2JEAhp8rqmTE0GPFy88rrM27ffgp62oErMQ==",
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"@aws-crypto/util": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-2.0.2.tgz",
"integrity": "sha512-Lgu5v/0e/BcrZ5m/IWqzPUf3UYFTy/PpeED+uc9SWUR1iZQL8XXbGQg10UfllwwBryO3hFF5dizK+78aoXC1eA==",
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"@aws-sdk/abort-controller": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/abort-controller/-/abort-controller-3.190.0.tgz",
"integrity": "sha512-M6qo2exTzEfHT5RuW7K090OgesUojhb2JyWiV4ulu7ngY4DWBUBMKUqac696sHRUZvGE5CDzSi0606DMboM+kA=="
},
"@aws-sdk/client-cognito-identity": {
"version": "3.192.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.192.0.tgz",
"integrity": "sha512-nIRmiv5JY8wWGUadhG7yLx8o8aVETj5CAgO8e8UJIwwqfue/Yv9bHi2mvkUphO1pj0TeBatAtvu79neJQtsR5g=="
},
"@aws-sdk/client-sso": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.190.0.tgz",
"integrity": "sha512-joEKRjJEzgvXnEih/x2UDDCPlvXWCO3MAHmqi44yJ36Ph4YsFS299mOjPdVLuzUtpQ+cST1nRO7hXNFrulW2jQ=="
},
"@aws-sdk/client-sts": {
"version": "3.192.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.192.0.tgz",
"integrity": "sha512-iv72dmRxbZ1cN5jGn4KIVzzu11eduS2fXHbNgd7JsFd5hLBV5TvJaugQzUdXNmy2gN4HiRJr+qa9WkD5b39lsA=="
},
"@aws-sdk/config-resolver": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/config-resolver/-/config-resolver-3.190.0.tgz",
"integrity": "sha512-K+VnDtjTgjpf7yHEdDB0qgGbHToF0pIL0pQMSnmk2yc8BoB3LGG/gg1T0Ki+wRlrFnDCJ6L+8zUdawY2qDsbyw=="
},
"@aws-sdk/credential-provider-cognito-identity": {
"version": "3.192.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.192.0.tgz",
"integrity": "sha512-CWo+KyHCGyYtvjlmDIGtnwBEkdiondergZADiStbFFvie8pPI7IsdTXNVssQQ1VxKIBGGHVebgZGSklHBqthwA=="
},
"@aws-sdk/credential-provider-env": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.190.0.tgz",
"integrity": "sha512-GTY7l3SJhTmRGFpWddbdJOihSqoMN8JMo3CsCtIjk4/h3xirBi02T4GSvbrMyP7FP3Fdl4NAdT+mHJ4q2Bvzxw=="
},
"@aws-sdk/credential-provider-imds": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-imds/-/credential-provider-imds-3.190.0.tgz",
"integrity": "sha512-gI5pfBqGYCKdmx8igPvq+jLzyE2kuNn9Q5u73pdM/JZxiq7GeWYpE/MqqCubHxPtPcTFgAwxCxCFoXlUTBh/2g=="
},
"@aws-sdk/credential-provider-ini": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.190.0.tgz",
"integrity": "sha512-Z7NN/evXJk59hBQlfOSWDfHntwmxwryu6uclgv7ECI6SEVtKt1EKIlPuCLUYgQ4lxb9bomyO5lQAl/1WutNT5w=="
},
"@aws-sdk/credential-provider-node": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.190.0.tgz",
"integrity": "sha512-ctCG5+TsIK2gVgvvFiFjinPjc5nGpSypU3nQKCaihtPh83wDN6gCx4D0p9M8+fUrlPa5y+o/Y7yHo94ATepM8w=="
},
"@aws-sdk/credential-provider-process": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.190.0.tgz",
"integrity": "sha512-sIJhICR80n5XY1kW/EFHTh5ZzBHb5X+744QCH3StcbKYI44mOZvNKfFdeRL2fQ7yLgV7npte2HJRZzQPWpZUrw=="
},
"@aws-sdk/credential-provider-sso": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.190.0.tgz",
"integrity": "sha512-uarU9vk471MHHT+GJj3KWFSmaaqLNL5n1KcMer2CCAZfjs+mStAi8+IjZuuKXB4vqVs5DxdH8cy5aLaJcBlXwQ=="
},
"@aws-sdk/credential-provider-web-identity": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.190.0.tgz",
"integrity": "sha512-nlIBeK9hGHKWC874h+ITAfPZ9Eaok+x/ydZQVKsLHiQ9PH3tuQ8AaGqhuCwBSH0hEAHZ/BiKeEx5VyWAE8/x+Q=="
},
"@aws-sdk/credential-providers": {
"version": "3.192.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.192.0.tgz",
"integrity": "sha512-iBTrEPkfOHlfgQyk7EeUCmZnhUKXsGcc/hhxBbc6Z/Xc7Y8LqRVLbEmHq9lruXraFuvs26xV9oZi1s1UMXneQA=="
},
"@aws-sdk/fetch-http-handler": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/fetch-http-handler/-/fetch-http-handler-3.190.0.tgz",
"integrity": "sha512-5riRpKydARXAPLesTZm6eP6QKJ4HJGQ3k0Tepi3nvxHVx3UddkRNoX0pLS3rvbajkykWPNC2qdfRGApWlwOYsA=="
},
"@aws-sdk/hash-node": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/hash-node/-/hash-node-3.190.0.tgz",
"integrity": "sha512-DNwVT3O8zc9Jk/bXiXcN0WsD98r+JJWryw9F1/ZZbuzbf6rx2qhI8ZK+nh5X6WMtYPU84luQMcF702fJt/1bzg=="
},
"@aws-sdk/invalid-dependency": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/invalid-dependency/-/invalid-dependency-3.190.0.tgz",
"integrity": "sha512-crCh63e8d/Uw9y3dQlVTPja7+IZiXpNXyH6oSuAadTDQwMq6KK87Av1/SDzVf6bAo2KgAOo41MyO2joaCEk0dQ=="
},
"@aws-sdk/is-array-buffer": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/is-array-buffer/-/is-array-buffer-3.188.0.tgz",
"integrity": "sha512-n69N4zJZCNd87Rf4NzufPzhactUeM877Y0Tp/F3KiHqGeTnVjYUa4Lv1vLBjqtfjYb2HWT3NKlYn5yzrhaEwiQ=="
},
"@aws-sdk/middleware-content-length": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-content-length/-/middleware-content-length-3.190.0.tgz",
"integrity": "sha512-sSU347SuC6I8kWum1jlJlpAqeV23KP7enG+ToWcEcgFrJhm3AvuqB//NJxDbkKb2DNroRvJjBckBvrwNAjQnBQ=="
},
"@aws-sdk/middleware-host-header": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-host-header/-/middleware-host-header-3.190.0.tgz",
"integrity": "sha512-cL7Vo/QSpGx/DDmFxjeV0Qlyi1atvHQDPn3MLBBmi1icu+3GKZkCMAJwzsrV3U4+WoVoDYT9FJ9yMQf2HaIjeQ=="
},
"@aws-sdk/middleware-logger": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-logger/-/middleware-logger-3.190.0.tgz",
"integrity": "sha512-rrfLGYSZCBtiXNrIa8pJ2uwUoUMyj6Q82E8zmduTvqKWviCr6ZKes0lttGIkWhjvhql2m4CbjG5MPBnY7RXL4A=="
},
"@aws-sdk/middleware-recursion-detection": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.190.0.tgz",
"integrity": "sha512-5tc1AIIZe5jDNdyuJW+7vIFmQOxz3q031ZVrEtUEIF7cz2ySho2lkOWziz+v+UGSLhjHGKMz3V26+aN1FLZNxQ=="
},
"@aws-sdk/middleware-retry": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-retry/-/middleware-retry-3.190.0.tgz",
"integrity": "sha512-h1bPopkncf2ue/erJdhqvgR2AEh0bIvkNsIHhx93DckWKotZd/GAVDq0gpKj7/f/7B+teHH8Fg5GDOwOOGyKcg=="
},
"@aws-sdk/middleware-sdk-sts": {
"version": "3.192.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-sts/-/middleware-sdk-sts-3.192.0.tgz",
"integrity": "sha512-xzTV7MyG5ipWYTvekWX1tQc5ExsUvCYsDTBCD3LR5hBrP8assUDPo52zGSe+QMcjgnQv7BcYIzeikTkLEG0dUw=="
},
"@aws-sdk/middleware-serde": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-serde/-/middleware-serde-3.190.0.tgz",
"integrity": "sha512-S132hEOK4jwbtZ1bGAgSuQ0DMFG4TiD4ulAwbQRBYooC7tiWZbRiR0Pkt2hV8d7WhOHgUpg7rvqlA7/HXXBAsA=="
},
"@aws-sdk/middleware-signing": {
"version": "3.192.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-signing/-/middleware-signing-3.192.0.tgz",
"integrity": "sha512-qTRIU/TL/dvtTrNj+AkZkgYeTIFslib3Y3XnQNNM6RCm4cMxIgs2K/lnhaUmLdbzHrpOQb4cISkY8yiHo+pNsw=="
},
"@aws-sdk/middleware-stack": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-stack/-/middleware-stack-3.190.0.tgz",
"integrity": "sha512-h1mqiWNJdi1OTSEY8QovpiHgDQEeRG818v8yShpqSYXJKEqdn54MA3Z1D2fg/Wv/8ZJsFrBCiI7waT1JUYOmCg=="
},
"@aws-sdk/middleware-user-agent": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.190.0.tgz",
"integrity": "sha512-y/2cTE1iYHKR0nkb3DvR3G8vt12lcTP95r/iHp8ZO+Uzpc25jM/AyMHWr2ZjqQiHKNlzh8uRw1CmQtgg4sBxXQ=="
},
"@aws-sdk/node-config-provider": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/node-config-provider/-/node-config-provider-3.190.0.tgz",
"integrity": "sha512-TJPUchyeK5KeEXWrwb6oW5/OkY3STCSGR1QIlbPcaTGkbo4kXAVyQmmZsY4KtRPuDM6/HlfUQV17bD716K65rQ=="
},
"@aws-sdk/node-http-handler": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/node-http-handler/-/node-http-handler-3.190.0.tgz",
"integrity": "sha512-3Klkr73TpZkCzcnSP+gmFF0Baluzk3r7BaWclJHqt2LcFUWfIJzYlnbBQNZ4t3EEq7ZlBJX85rIDHBRlS+rUyA=="
},
"@aws-sdk/property-provider": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/property-provider/-/property-provider-3.190.0.tgz",
"integrity": "sha512-uzdKjHE2blbuceTC5zeBgZ0+Uo/hf9pH20CHpJeVNtrrtF3GALtu4Y1Gu5QQVIQBz8gjHnqANx0XhfYzorv69Q=="
},
"@aws-sdk/protocol-http": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/protocol-http/-/protocol-http-3.190.0.tgz",
"integrity": "sha512-s5MVfeONpfZYRzCSbqQ+wJ3GxKED+aSS7+CQoeaYoD6HDTDxaMGNv9aiPxVCzW02sgG7py7f29Q6Vw+5taZXZA=="
},
"@aws-sdk/querystring-builder": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/querystring-builder/-/querystring-builder-3.190.0.tgz",
"integrity": "sha512-w9mTKkCsaLIBC8EA4RAHrqethNGbf60CbpPzN/QM7yCV3ZZJAXkppFfjTVVOMbPaI8GUEOptJtzgqV68CRB7ow=="
},
"@aws-sdk/querystring-parser": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/querystring-parser/-/querystring-parser-3.190.0.tgz",
"integrity": "sha512-vCKP0s33VtS47LSYzEWRRr2aTbi3qNkUuQyIrc5LMqBfS5hsy79P1HL4Q7lCVqZB5fe61N8fKzOxDxWRCF0sXg=="
},
"@aws-sdk/service-error-classification": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/service-error-classification/-/service-error-classification-3.190.0.tgz",
"integrity": "sha512-g+s6xtaMa5fCMA2zJQC4BiFGMP7FN5/L1V/UwxCnKy8skCwaN0K5A1tFffBjjbYiPI7Gu7LVorWD2A0Y4xl01Q=="
},
"@aws-sdk/shared-ini-file-loader": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/shared-ini-file-loader/-/shared-ini-file-loader-3.190.0.tgz",
"integrity": "sha512-CZC/xsGReUEl5w+JgfancrxfkaCbEisyIFy6HALUYrioWQe80WMqLAdUMZSXHWjIaNK9mH0J/qvcSV2MuIoMzQ=="
},
"@aws-sdk/signature-v4": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4/-/signature-v4-3.190.0.tgz",
"integrity": "sha512-L/R/1X2T+/Kg2k/sjoYyDFulVUGrVcRfyEKKVFIUNg0NwUtw5UKa1/gS7geTKcg4q8M2pd/v+OCBrge2X7phUw=="
},
"@aws-sdk/smithy-client": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/smithy-client/-/smithy-client-3.190.0.tgz",
"integrity": "sha512-f5EoCwjBLXMyuN491u1NmEutbolL0cJegaJbtgK9OJw2BLuRHiBknjDF4OEVuK/WqK0kz2JLMGi9xwVPl4BKCA=="
},
"@aws-sdk/types": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.190.0.tgz",
"integrity": "sha512-mkeZ+vJZzElP6OdRXvuLKWHSlDQxZP9u8BjQB9N0Rw0pCXTzYS0vzIhN1pL0uddWp5fMrIE68snto9xNR6BQuA=="
},
"@aws-sdk/url-parser": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/url-parser/-/url-parser-3.190.0.tgz",
"integrity": "sha512-FKFDtxA9pvHmpfWmNVK5BAVRpDgkWMz3u4Sg9UzB+WAFN6UexRypXXUZCFAo8S04FbPKfYOR3O0uVlw7kzmj9g=="
},
"@aws-sdk/util-base64-browser": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-base64-browser/-/util-base64-browser-3.188.0.tgz",
"integrity": "sha512-qlH+5NZBLiyKziL335BEPedYxX6j+p7KFRWXvDQox9S+s+gLCayednpK+fteOhBenCcR9fUZOVuAPScy1I8qCg=="
},
"@aws-sdk/util-base64-node": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-base64-node/-/util-base64-node-3.188.0.tgz",
"integrity": "sha512-r1dccRsRjKq+OhVRUfqFiW3sGgZBjHbMeHLbrAs9jrOjU2PTQ8PSzAXLvX/9lmp7YjmX17Qvlsg0NCr1tbB9OA=="
},
"@aws-sdk/util-body-length-browser": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-body-length-browser/-/util-body-length-browser-3.188.0.tgz",
"integrity": "sha512-8VpnwFWXhnZ/iRSl9mTf+VKOX9wDE8QtN4bj9pBfxwf90H1X7E8T6NkiZD3k+HubYf2J94e7DbeHs7fuCPW5Qg=="
},
"@aws-sdk/util-body-length-node": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-body-length-node/-/util-body-length-node-3.188.0.tgz",
"integrity": "sha512-XwqP3vxk60MKp4YDdvDeCD6BPOiG2e+/Ou4AofZOy5/toB6NKz2pFNibQIUg2+jc7mPMnGnvOW3MQEgSJ+gu/Q=="
},
"@aws-sdk/util-buffer-from": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-buffer-from/-/util-buffer-from-3.188.0.tgz",
"integrity": "sha512-NX1WXZ8TH20IZb4jPFT2CnLKSqZWddGxtfiWxD9M47YOtq/SSQeR82fhqqVjJn4P8w2F5E28f+Du4ntg/sGcxA=="
},
"@aws-sdk/util-config-provider": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-config-provider/-/util-config-provider-3.188.0.tgz",
"integrity": "sha512-LBA7tLbi7v4uvbOJhSnjJrxbcRifKK/1ZVK94JTV2MNSCCyNkFotyEI5UWDl10YKriTIUyf7o5cakpiDZ3O4xg=="
},
"@aws-sdk/util-defaults-mode-browser": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-defaults-mode-browser/-/util-defaults-mode-browser-3.190.0.tgz",
"integrity": "sha512-FKxTU4tIbFk2pdUbBNneStF++j+/pB4NYJ1HRSEAb/g4D2+kxikR/WKIv3p0JTVvAkwcuX/ausILYEPUyDZ4HQ=="
},
"@aws-sdk/util-defaults-mode-node": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-defaults-mode-node/-/util-defaults-mode-node-3.190.0.tgz",
"integrity": "sha512-qBiIMjNynqAP7p6urG1+ZattYkFaylhyinofVcLEiDvM9a6zGt6GZsxru2Loq0kRAXXGew9E9BWGt45HcDc20g=="
},
"@aws-sdk/util-hex-encoding": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-hex-encoding/-/util-hex-encoding-3.188.0.tgz",
"integrity": "sha512-QyWovTtjQ2RYxqVM+STPh65owSqzuXURnfoof778spyX4iQ4z46wOge1YV2ZtwS8w5LWd9eeVvDrLu5POPYOnA=="
},
"@aws-sdk/util-locate-window": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-locate-window/-/util-locate-window-3.188.0.tgz",
"integrity": "sha512-SxobBVLZkkLSawTCfeQnhVX3Azm9O+C2dngZVe1+BqtF8+retUbVTs7OfYeWBlawVkULKF2e781lTzEHBBjCzw=="
},
"@aws-sdk/util-middleware": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-middleware/-/util-middleware-3.190.0.tgz",
"integrity": "sha512-qzTJ/qhFDzHZS+iXdHydQ/0sWAuNIB5feeLm55Io/I8Utv3l3TKYOhbgGwTsXY+jDk7oD+YnAi7hLN5oEBCwpg=="
},
"@aws-sdk/util-uri-escape": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-uri-escape/-/util-uri-escape-3.188.0.tgz",
"integrity": "sha512-4Y6AYZMT483Tiuq8dxz5WHIiPNdSFPGrl6tRTo2Oi2FcwypwmFhqgEGcqxeXDUJktvaCBxeA08DLr/AemVhPCg=="
},
"@aws-sdk/util-user-agent-browser": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.190.0.tgz",
"integrity": "sha512-c074wjsD+/u9vT7DVrBLkwVhn28I+OEHuHaqpTVCvAIjpueZ3oms0e99YJLfpdpEgdLavOroAsNFtAuRrrTZZw=="
},
"@aws-sdk/util-user-agent-node": {
"version": "3.190.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.190.0.tgz",
"integrity": "sha512-R36BMvvPX8frqFhU4lAsrOJ/2PJEHH/Jz1WZzO3GWmVSEAQQdHmo8tVPE3KOM7mZWe5Hj1dZudFAIxWHHFYKJA=="
},
"@aws-sdk/util-utf8-browser": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-utf8-browser/-/util-utf8-browser-3.188.0.tgz",
"integrity": "sha512-jt627x0+jE+Ydr9NwkFstg3cUvgWh56qdaqAMDsqgRlKD21md/6G226z/Qxl7lb1VEW2LlmCx43ai/37Qwcj2Q=="
},
"@aws-sdk/util-utf8-node": {
"version": "3.188.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/util-utf8-node/-/util-utf8-node-3.188.0.tgz",
"integrity": "sha512-hCgP4+C0Lekjpjt2zFJ2R/iHes5sBGljXa5bScOFAEkRUc0Qw0VNgTv7LpEbIOAwGmqyxBoCwBW0YHPW1DfmYQ=="
},
"@types/node": {
"version": "18.7.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.13.tgz",
"integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw=="
"version": "18.11.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.2.tgz",
"integrity": "sha512-BWN3M23gLO2jVG8g/XHIRFWiiV4/GckeFIqbU/C4V3xpoBBWSMk4OZomouN0wCkfQFPqgZikyLr7DOYDysIkkw=="
},
"@types/webidl-conversions": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz",
"integrity": "sha512-XAahCdThVuCFDQLT7R7Pk/vqeObFNL3YqRyFZg+AqAP/W1/w3xHaIxuW7WszQqTbIBOPRcItYJIou3i/mppu3Q=="
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
"integrity": "sha512-xTE1E+YF4aWPJJeUzaZI5DRntlkY3+BCVJi0axFptnjGmAoWxkyREIh/XMrfxVLejwQxMCfDXdICo0VLxThrog=="
},
"@types/whatwg-url": {
"version": "8.2.2",
@@ -21,6 +361,11 @@
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
},
"bowser": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",
"integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA=="
},
"bson": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.0.tgz",
@@ -36,6 +381,11 @@
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
"integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw=="
},
"fast-xml-parser": {
"version": "4.0.11",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.0.11.tgz",
"integrity": "sha512-4aUg3aNRR/WjQAcpceODG1C3x3lFANXRo8+1biqfieHmg9pyMt7qB4lQV/Ta6sJCTbA5vfD8fnA8S54JATiFUA=="
},
"ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
@@ -52,14 +402,14 @@
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg=="
},
"mongodb": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.9.0.tgz",
"integrity": "sha512-tJJEFJz7OQTQPZeVHZJIeSOjMRqc5eSyXTt86vSQENEErpkiG7279tM/GT5AVZ7TgXNh9HQxoa2ZkbrANz5GQw=="
"version": "4.11.0",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.11.0.tgz",
"integrity": "sha512-9l9n4Nk2BYZzljW3vHah3Z0rfS5npKw6ktnkmFgTcnzaXH1DRm3pDl6VMHu84EVb1lzmSaJC4OzWZqTkB5i2wg=="
},
"mongodb-connection-string-url": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.3.tgz",
"integrity": "sha512-f+/WsED+xF4B74l3k9V/XkTVj5/fxFH2o5ToKXd8Iyi5UhM+sO9u0Ape17Mvl/GkZaFtM0HQnzAG5OTmhKw+tQ=="
"version": "2.5.4",
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.4.tgz",
"integrity": "sha512-SeAxuWs0ez3iI3vvmLk/j2y+zHwigTDKQhtdxTgt5ZCOQQS5+HW4g45/Xw5vzzbn7oQXCNQ24Z40AkJsizEy7w=="
},
"punycode": {
"version": "2.1.1",
@@ -77,20 +427,35 @@
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg=="
},
"socks": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/socks/-/socks-2.7.0.tgz",
"integrity": "sha512-scnOe9y4VuiNUULJN72GrM26BNOjVsfPXI+j+98PkyEfsIXroa5ofyjT+FzGvn/xHs73U2JtoBYAVx9Hl4quSA=="
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz",
"integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ=="
},
"sparse-bitfield": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
"integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ=="
},
"strnum": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz",
"integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA=="
},
"tr46": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz",
"integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA=="
},
"tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="
},
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
},
"webidl-conversions": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",

View File

@@ -3,12 +3,12 @@
Package.describe({
summary: "Wrapper around the mongo npm package",
version: "4.9.0",
version: '4.11.0',
documentation: null
});
Npm.depends({
mongodb: "4.9.0"
mongodb: "4.11.0"
});
Package.onUse(function (api) {

View File

@@ -1,6 +1,6 @@
Package.describe({
name: "promise",
version: "0.12.0",
version: "0.12.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) {

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "promise.d.ts"
}

23
packages/promise/promise.d.ts vendored Normal file
View File

@@ -0,0 +1,23 @@
export declare class Promise<T> extends globalThis.Promise<T> {
static async<
Fn extends (this: This, ...args: Args) => any,
This,
Args extends any[]
>(
fn: Fn,
allowReuseOfCurrentFiber?: boolean
): (this: This, ...args: Args) => Promise<ReturnType<Fn>>;
static asyncApply<
Fn extends (this: This, ...args: Args) => any,
This,
Args extends any[]
>(
fn: Fn,
context: This,
args: Args,
allowReuseOfCurrentFiber?: boolean
): Promise<ReturnType<Fn>>;
static await<T>(value: PromiseLike<T>): T;
static awaitAll<T>(values: Iterable<T | PromiseLike<T>>): T[];
await(): T;
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "random.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: 'Random number generator and utilities',
version: '1.2.0',
version: '1.2.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) {

13
packages/random/random.d.ts vendored Normal file
View File

@@ -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<T>(array: T[]): T | undefined;
// @param str, @return a random char in str
function choice(str: string): string;
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "reactive-dict.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "Reactive dictionary",
version: '1.3.0'
version: '1.3.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) {

View File

@@ -0,0 +1,94 @@
import { EJSONable } from 'meteor/ejson';
export declare class ReactiveDict<O = EJSONable> {
/**
* 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<O>);
/**
* 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<P extends keyof O>(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<O>): 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<P extends keyof O>(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<O>): 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<P extends keyof O>(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<P extends keyof O>(
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<O>;
/**
* 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<P extends keyof O>(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;
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "reactive-var.d.ts"
}

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "Reactive variable",
version: '1.0.11'
version: '1.0.12'
});
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');
});

25
packages/reactive-var/reactive-var.d.ts vendored Normal file
View File

@@ -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 <T>(
initialValue: T,
equalsFunc?: (oldValue: T, newValue: T) => boolean
): ReactiveVar<T>;
}
export interface ReactiveVar<T> {
/**
* 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;
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "server-render.d.ts"
}

Some files were not shown because too many files have changed in this diff Show More