Merge remote-tracking branch 'refs/remotes/DefinitelyTyped/master'

This commit is contained in:
Frank Tan
2017-08-27 16:11:28 -04:00
21 changed files with 840 additions and 68 deletions
@@ -0,0 +1,23 @@
import chaiJestSnapshot from 'chai-jest-snapshot';
import { expect } from 'chai';
chai.use(chaiJestSnapshot);
expect({}).to.matchSnapshot();
expect({}).to.matchSnapshot(true);
expect({}).to.matchSnapshot("filename");
expect({}).to.matchSnapshot("filename", "snapshotname");
expect({}).to.matchSnapshot("filename", "snapshotname", false);
const mockContext: Mocha.IBeforeAndAfterContext = <any> {
currentTest: {
file: 'testfile',
fullTitle: () => 'fullTitle'
}
};
chaiJestSnapshot.setFileName("filename");
chaiJestSnapshot.setTestName("testname");
chaiJestSnapshot.configureUsingMochaContext(mockContext);
chaiJestSnapshot.resetSnapshotRegistry();
chaiJestSnapshot.addSerializer({});
+63
View File
@@ -0,0 +1,63 @@
// Type definitions for chai-jest-snapshot 1.3
// Project: https://github.com/suchipi/chai-jest-snapshot#readme
// Definitions by: Matt Perry <https://github.com/mattvperry>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="chai" />
/// <reference types="mocha" />
declare global {
namespace Chai {
interface Assertion {
/**
* Assert that the object matches the snapshot
* @param snapshotFilename
* @param snapshotName
* @param update
*/
matchSnapshot(snapshotFilename?: string, snapshotName?: string, update?: boolean): Assertion;
matchSnapshot(update: boolean): Assertion;
}
}
}
interface ChaiJestSnapshot {
/**
* Chai bootstrapper
* @param chai
* @param utils
*/
(chai: any, utils: any): void;
/**
* Set snapshot file name
* @param filename
*/
setFileName(filename: string): void;
/**
* Set snapshot test name
* @param testname
*/
setTestName(testname: string): void;
/**
* Configure snapshot name using mocha context
* @param context
*/
configureUsingMochaContext(context: Mocha.IBeforeAndAfterContext): void;
/**
* Reset snapshot registry
*/
resetSnapshotRegistry(): void;
/**
* Add a serializer plugin
* @param serializer
*/
addSerializer(serializer: any): void;
}
declare var ChaiJestSnapshot: ChaiJestSnapshot;
export default ChaiJestSnapshot;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"chai-jest-snapshot-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+25 -5
View File
@@ -1,17 +1,37 @@
// Type definitions for globby 0.6
// Type definitions for globby 6.1
// Project: https://github.com/sindresorhus/globby#readme
// Definitions by: Douglas Duteil <https://github.com/douglasduteil>
// Ika <https://github.com/ikatyang>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { IOptions } from 'glob';
/**
* Returns a `Promise<Array>` of matching paths.
*/
declare function globby(patterns: string | string[], options?: IOptions): Promise<string[]>;
declare namespace globby {
function sync(patterns: string | string[], options?: IOptions): string[];
function generateGlobTasks(patterns: string | string[], options?: IOptions): Array<{pattern: string, options: IOptions}>;
function hasMagic(patterns: string | string[], options?: IOptions): boolean;
/**
* Returns an `Array` of matching paths.
*/
function sync(patterns: string | string[], options?: IOptions): string[];
/**
* Returns an `Array<Object>` in the format `{ pattern: string, opts: Object }`,
* which can be passed as arguments to [node-glob](https://github.com/isaacs/node-glob).
* This is useful for other globbing-related packages.
*
* Note that you should avoid running the same tasks multiple times as they contain a file system cache.
* Instead, run this method each time to ensure file system changes are taken into consideration.
*/
function generateGlobTasks(patterns: string | string[], options?: IOptions): Array<{pattern: string, options: IOptions}>;
/**
* Returns a `boolean` of whether there are any special glob characters in the patterns.
*
* Note that the options affect the results. If `noext: true` is set, then `+(a|b)` will not be considered a magic pattern.
* If the pattern has a brace expansion, like `a/{b/c,x/y}`, then that is considered magical, unless `nobrace: true` is set.
*/
function hasMagic(patterns: string | string[], options?: IOptions): boolean;
}
export = globby;
+1
View File
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"es6"
],
+113 -8
View File
@@ -7,43 +7,146 @@
import * as React from 'react';
export interface ColumnProps {
tagName?: string;
/**
* You can specify component to use specific tag
* @default 'div'
*/
tagName?: keyof ElementTagNameMap;
/**
* Draws all child columns with "bounding boxes" for easy
* visualization of the grid. This enables debug mode for all the
* children of this component
* @default false
*/
debug?: boolean;
/**
* The amount of horizontal columns this row creates.
* @default 12
*/
divisions?: number;
/**
* If true, disable padding.
*/
fluid?: boolean;
/**
* Width during xs breakpoint.
*/
xs?: number;
/**
* Width during sm breakpoint.
*/
sm?: number;
/**
* Width during md breakpoint.
*/
md?: number;
/**
* Width during lg breakpoint.
*/
lg?: number;
/**
* Width of left margin during xs breakpoint.
*/
xsShift?: number;
/**
* Width of left margin during sm breakpoint.
*/
smShift?: number;
/**
* Width of left margin during md breakpoint.
*/
mdShift?: number;
/**
* Width of left margin during lg breakpoint.
*/
lgShift?: number;
}
export interface PageProps {
tagName?: string;
/**
* You can specify component to use specific tag
* @default 'div'
*/
tagName?: keyof ElementTagNameMap;
/**
* Draws all child columns with "bounding boxes" for easy
* visualization of the grid. This enables debug mode for all the
* children of this component
* @default false
*/
debug?: boolean;
/**
* Enabling fluid mode disables the fixed width of the Page
*/
fluid?: boolean;
/**
* If not using fluid, set a custom width for the page.
*/
width?: string;
}
export interface RowProps {
/**
* Draws all child columns with "bounding boxes" for easy
* visualization of the grid.
* @default false
*/
debug?: boolean;
tagName?: string;
/**
* You can specify component to use specific tag
* @default 'section'
*/
tagName?: keyof ElementTagNameMap;
/**
* The amount of horizontal columns this row creates.
* @default 12
*/
divisions?: number;
/**
* Sets the value of the CSS align-content property
*/
alignContent?: string;
/**
* Sets the value of the CSS align-items property
*/
alignItems?: string;
/**
* Sets the value of the CSS align-self property
*/
alignSelf?: string;
/**
* Sets the value of the CSS justify-content property
*/
justifyContent?: string;
/**
* Sets the value of the CSS order property
*/
order?: string;
}
export interface HiddenProps {
/**
* Draws all child columns with "bounding boxes" for easy
* visualization of the grid. This enables debug mode for all the
* children of this component
* @default false
*/
debug?: boolean;
/**
* Width during xs breakpoint.
*/
xs?: boolean;
/**
* Width during sm breakpoint.
*/
sm?: boolean;
/**
* Width during md breakpoint.
*/
md?: boolean;
/**
* Width during lg breakpoint.
*/
lg?: boolean;
}
@@ -51,11 +154,13 @@ export interface BreakpointProviderProps {
breakpoints: { sm?: number; md?: number; lg?: number };
}
export class Column extends React.Component<ColumnProps> {}
export class Page extends React.Component<PageProps> {}
export class Row extends React.Component<RowProps> {}
export class Hidden extends React.Component<HiddenProps> {}
export class BreakpointProvider extends React.Component<BreakpointProviderProps> {}
export class Column extends React.Component<ColumnProps & React.HTMLProps<HTMLElement>> {}
export class Page extends React.Component<PageProps & React.HTMLProps<HTMLElement>> {}
export class Row extends React.Component<RowProps & React.HTMLProps<HTMLElement>> {}
export class Hidden extends React.Component<HiddenProps & React.HTMLProps<HTMLElement>> {}
export class BreakpointProvider extends React.Component<
BreakpointProviderProps & React.HTMLProps<HTMLElement>
> {}
export function withBreakpoints<T>(
wrappedComponent: React.ComponentClass<T>
): React.ComponentClass<T>;
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for jsonata 1.3
// Project: https://github.com/jsonata-js/jsonata
// Definitions by: Nick <https://github.com/nick121212>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function jsonata(str: string): jsonata.Expression;
declare namespace jsonata {
interface Expression {
evaluate(input: any, bindings?: any, callback?: () => any): any;
assign(key: string, func: (...args: any[]) => any): void;
}
}
export = jsonata;
+12
View File
@@ -0,0 +1,12 @@
import jsonata = require("jsonata");
const data = {
example: [
{ value: 4 },
{ value: 7 },
{ value: 13 }
]
};
const expression = jsonata("$sum(example.value)");
const result = expression.evaluate(data); // returns 24
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es5",
"es6"
],
"target": "es6",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jsonata-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+2
View File
@@ -416,6 +416,7 @@ declare namespace Knex {
dropUnique(columnNames: (string | Raw)[], indexName?: string): TableBuilder;
dropPrimary(constraintName?: string): TableBuilder;
dropIndex(columnNames: (string | Raw)[], indexName?: string): TableBuilder;
dropTimestamps(): ColumnBuilder;
}
interface CreateTableBuilder extends TableBuilder {
@@ -428,6 +429,7 @@ declare namespace Knex {
}
interface AlterTableBuilder extends TableBuilder {
alter(): ColumnBuilder;
}
interface MySqlAlterTableBuilder extends AlterTableBuilder {
+58 -43
View File
@@ -1,8 +1,9 @@
// Type definitions for Loopback 3.1
// Type definitions for Loopback 3.2
// Project: https://github.com/strongloop/loopback
// Definitions by: Andres D Jimenez <https://github.com/kattsushi>
// Tim Schumacher <https://github.com/enko>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
/************************************************
* *
@@ -146,7 +147,7 @@ declare namespace l {
* ``
* @returns {Array} Array of model classes
*/
models(): any[];
models(): Array<typeof Model>;
/**
* Get all remote objects.
@@ -1020,24 +1021,24 @@ declare namespace l {
* @param {any} options An optional options object to pass to underlying data-access calls.
* @param {() => void} callback Callback function
*/
static bulkUpdate(updates: any[], options: any, callback: () => void): void;
static bulkUpdate(updates: any[], options: any, callback?: () => void): Promise<void> | void;
/**
* Get the changes to a model since the specified checkpoint. Provide a filter object
* to reduce the number of results returned.
* @param {number} since Return only changes since this checkpoint.
* @param {any} filter Include only changes that match this filter, the same as for [#persistedmodel-find](find()).
* @callback {() => void} callback Callback function called with `(err, changes)` arguments. Required.
* @callback {() => void} callback Callback function called with `(err, changes)` arguments.
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {Array} changes An Array of [Change](#change) objects
*/
static changes(since: number, filter: any, callback: (err: Error, changes: any[]) => void): void;
static changes(since: number, filter: any, callback?: (err: Error, changes: any[]) => void): Promise<any[]> | void;
/**
* Create a checkpoint
* @param {() => void} callback
*/
static checkpoint(callback: () => void): void;
static checkpoint(callback?: () => void): Promise<void> | void;
/**
* Return the number of records that match the optional "where" filter.
@@ -1051,7 +1052,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {number} count number of instances updated
*/
static count(where?: any, callback?: (err: Error, count: number) => void): void;
static count(where?: any, callback?: (err: Error, count: number) => void): Promise<number> | void;
/**
* Create new instance of Model, and save to database
@@ -1060,14 +1061,14 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} models Model instances or null
*/
static create(data?: any|any[], callback?: (err: Error, models: any) => void): void;
static create<T = any>(data?: any|any[], callback?: (err: Error, models: T|T[]) => void): Promise<T|T[]> | void;
/**
* Create a change stream. See here for more info http://loopback.io/doc/en/lb2/Realtime-server-sent-events.html
* @param {any} options Only changes to models matching this where filter will be included in the ChangeStream.
* @param {() => void} callback
*/
static createChangeStream(options: {where: any}, callback: (err: Error, changes: any) => void): void;
static createChangeStream(options: {where: any}, callback?: (err: Error, changes: any) => void): Promise<any> | void;
/**
* Create an update list (for `Model.bulkUpdate()`) from a delta list
@@ -1075,7 +1076,7 @@ declare namespace l {
* @param {Array} deltas
* @param {() => void} callback
*/
static createUpdates(deltas: any[], callback: () => void): void;
static createUpdates(deltas: any[], callback?: () => void): Promise<void> | void;
/**
* Get the current checkpoint ID
@@ -1083,7 +1084,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {number} currentCheckpointId Current checkpoint ID
*/
static currentCheckpoint(callback: (err: Error, currentCheckpointId: number) => void): void;
static currentCheckpoint(callback?: (err: Error, currentCheckpointId: number) => void): Promise<number> | void;
/**
* Destroy all model instances that match the optional `where` specification
@@ -1099,7 +1100,7 @@ declare namespace l {
* @param {any} info Additional information about the command outcome.
* @param {number} info.count number of instances (rows, documents) destroyed
*/
static destroyAll(where?: any, callback?: (err: Error, info: any, infoCount: number) => void): void;
static destroyAll(where?: any, callback?: (err: Error, info: any, infoCount: number) => void): Promise<{ info: any, infoCount: number}> | void;
/**
* Destroy model instance with the specified ID.
@@ -1107,7 +1108,7 @@ declare namespace l {
* @callback {() => void} callback Callback function called with `(err)` arguments. Required.
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object)
*/
static destroyById(id: any, callback: (err: Error) => void): void;
static destroyById(id: any, callback?: (err: Error) => void): Promise<void> | void;
/**
* Get a set of deltas and conflicts since the given checkpoint
@@ -1118,7 +1119,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} result any with `deltas` and `conflicts` properties; see [Change.diff()](#change-diff) for details
*/
static diff(since: number, remoteChanges: any[], callback: (err: Error, result: any) => void): void;
static diff(since: number, remoteChanges: any[], callback?: (err: Error, result: any) => void): Promise<any> | void;
/**
* Enable the tracking of changes made to the model. Usually for replication.
@@ -1132,7 +1133,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {boolean} exists True if the instance with the specified ID exists; false otherwise
*/
static exists(id: any, callback: (err: Error, exists: boolean) => void): void;
static exists(id: any, callback?: (err: Error, exists: boolean) => void): Promise<boolean> | void;
/**
* Find all model instances that match `filter` specification.
@@ -1158,9 +1159,9 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {Array} models Model instances matching the filter, or null if none found
*/
static find(
static find<T = any>(
filter?: {fields?: string|any|any[]; include?: string|any|any[]; limit?: number; order?: string; skip?: number; where?: any; },
callback?: (err: Error, models: any[]) => void): void;
callback?: (err: Error, models: any[]) => void): Promise<T[]> | void;
/**
* Find object by ID with an optional filter for include/fields
@@ -1174,7 +1175,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} instance Model instance matching the specified ID or null if no instance matches
*/
static findById(id: any, filter?: {fields?: string|any|any[]; include?: string|any|any[]; }, callback?: (err: Error, instance: any) => void): void;
static findById<T = any>(id: any, filter?: {fields?: string|any|any[]; include?: string|any|any[]; }, callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Find one model instance that matches `filter` specification.
@@ -1199,7 +1200,15 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {Array} model First model instance that matches the filter or null if none found
*/
static findOne(filter?: {fields?: string|any|any[]; include?: string|any|any[]; order?: string; skip?: number; where?: any; }, callback?: (err: Error, model: any) => void): void;
static findOne<T = any>(
filter?: {
fields?: string|any|any[];
include?: string|any|any[];
order?: string;
skip?: number;
where?: any;
},
callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Finds one record matching the optional filter object. If not found, creates
@@ -1231,7 +1240,7 @@ declare namespace l {
* @param {any} instance Model instance matching the `where` filter, if found.
* @param {boolean} created True if the instance matching the `where` filter was created
*/
static findOrCreate(
static findOrCreate<T = any>(
data: any,
filter?: {
fields?: string | any | any[];
@@ -1241,7 +1250,7 @@ declare namespace l {
skip?: number;
where?: any;
},
callback?: (err: Error, instance: any, created: boolean) => void): void;
callback?: (err: Error, instance: any, created: boolean) => void): Promise<{instance: T, created: boolean}> | void;
/**
* Get the `Change` model.
@@ -1261,7 +1270,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {string} sourceId Source identifier for the model or dataSource
*/
static getSourceId(callback: (err: Error, sourceId: string) => void): void;
static getSourceId(callback?: (err: Error, sourceId: string) => void): Promise<string> | void;
/**
* Handle a change error. Override this method in a subclassing model to customize
@@ -1276,7 +1285,7 @@ declare namespace l {
* @callback {() => void} callback
* @param {Error} er
*/
static rectifyChange(id: any, callback: (err: Error) => void): void;
static rectifyChange(id: any, callback?: (err: Error) => void): Promise<void> | void;
/**
* Replace attributes for a model instance whose id is the first input
@@ -1290,7 +1299,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} instance Replaced instance
*/
static replaceById(id: any, data: any, options?: {validate: boolean; }, callback?: (err: Error, instance: any) => void): void;
static replaceById<T = any>(id: any, data: any, options?: {validate: boolean; }, callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Replace or insert a model instance; replace existing record if one is found,
@@ -1303,7 +1312,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} model Replaced model instance.
*/
static replaceOrCreate(data: any, options?: {validate: boolean; }, callback?: (err: Error, model: any) => void): void;
static replaceOrCreate<T = any>(data: any, options?: {validate: boolean; }, callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Replicate changes since the given checkpoint to the given target model
@@ -1317,7 +1326,13 @@ declare namespace l {
* @param {any] checkpoints The new checkpoints to use as the "since"
* argument for the next replication
*/
static replicate(since?: number, targetModel?: Model, options?: any, optionsFilter?: any, callback?: (err: Error, conflicts: Conflict[], param: any) => void): void;
static replicate(
since?: number,
targetModel?: Model,
options?: any,
optionsFilter?: any,
callback?: (err: Error, conflicts: Conflict[], param: any) => void
): Promise<{conflicts: Conflict[], params: any}> | void;
/**
* Update multiple instances that match the where clause.
@@ -1344,7 +1359,7 @@ declare namespace l {
* @param {number} info.count number of instances (rows, documents) updated.
*
*/
static updateAll(where?: any, data?: any, callback?: (err: Error, info: any, infoCount: number) => void): void;
static updateAll(where?: any, data?: any, callback?: (err: Error, info: any, infoCount: number) => void): Promise<number> | void;
/**
* Update or insert a model instance
@@ -1353,7 +1368,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} model Updated model instance
*/
static upsert(data: any, callback: (err: Error, model: any) => void): void;
static upsert<T = any>(data: any, callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Update or insert a model instance based on the search criteria.
@@ -1371,14 +1386,14 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} model Updated model instance
*/
static upsertWithWhere(data: any, callback: (err: Error, model: any) => void): void;
static upsertWithWhere<T = any>(data: any, callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Deletes the model from persistence.
* Triggers `destroy` hook (async) before and after destroying object.
* @param {() => void} callback Callback function
*/
destroy(callback: () => void): void;
destroy(callback?: () => void): Promise<void> | void;
/**
* Get the `id` value for the `PersistedModel`
@@ -1404,7 +1419,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} instance Model instance
*/
reload(callback: (err: Error, instance: any) => void): void;
reload<T = any>(callback: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Replace attributes for a model instance and persist it into the datasource.
@@ -1416,7 +1431,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} instance Replaced instance
*/
replaceAttributes(data: any, options?: {validate: boolean}, callback?: (err: Error, instance: any) => void): void;
replaceAttributes<T = any>(data: any, options?: {validate: boolean}, callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Save model instance. If the instance doesn't have an ID, then calls [create](#persistedmodelcreatedata-cb) instead.
@@ -1429,7 +1444,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} instance Model instance saved or created
*/
save(options?: {validate: boolean; throws: boolean}, callback?: (err: Error, instance: any) => void): void;
save<T = any>(options?: {validate: boolean; throws: boolean}, callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Set the correct `id` property for the `PersistedModel`. Uses the `setId` method if the model is attached to
@@ -1448,7 +1463,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} instance Updated instance
*/
updateAttribute(name: string, value: any, callback: (err: Error, instance: any) => void): void;
updateAttribute<T = any>(name: string, value: any, callback?: (err: Error, instance: T) => void): Promise<T> | void;
/**
* Update set of attributes. Performs validation before updating
@@ -1458,7 +1473,7 @@ declare namespace l {
* @param {Error} err Error object; see [Error object](docs.strongloop.com/display/LB/Error+object).
* @param {any} instance Updated instance
*/
updateAttributes(data: any, callback: (err: Error, instance: any) => void): void;
updateAttributes<T = any>(data: any, callback?: (err: Error, instance: T) => void): Promise<T> | void;
// **NOTE** Deprecate for v3.x
// /**
@@ -2642,7 +2657,7 @@ declare namespace l {
* @callback {() => void} callback
* @param {Error} er
*/
static confirm(userId: any, token: string, redirect: string, callback: (err: Error) => void): void;
static confirm(userId: any, token: string, redirect: string, callback?: (err: Error) => void): Promise<void> | void;
/**
* A default verification token generator which accepts the user the token is
@@ -2653,7 +2668,7 @@ declare namespace l {
* @param {any} user The User this token is being generated for.
* @param {() => void} cb The generator must pass back the new token with this function cal
*/
static generateVerificationToken(user: any, cb: () => void): void;
static generateVerificationToken(user: any, callback?: () => void): Promise<void> | void;
/**
* Login a user by with the given `credentials`
@@ -2671,7 +2686,7 @@ declare namespace l {
* @param {Error} err Error object
* @param {AccessToken} token Access token if login is successfu
*/
static login(credentials: any, include?: string[]|string, callback?: (err: Error, token: AccessToken) => void): void;
static login(credentials: any, include?: string[]|string, callback?: (err: Error, token: AccessToken) => void): Promise<AccessToken> | void;
/**
* Logout a user with the given accessToken id
@@ -2686,7 +2701,7 @@ declare namespace l {
* @callback {() => void} callback
* @param {Error} er
*/
static logout(accessTokenID: string, callback: (err: Error) => void): void;
static logout(accessTokenID: string, callback?: (err: Error) => void): Promise<void> | void;
/**
* Normalize the credentials
@@ -2705,7 +2720,7 @@ declare namespace l {
* @callback {() => void} callback
* @param {Error} er
*/
static resetPassword(options: {}, callback: (err: Error) => void): void;
static resetPassword(options: {}, callback?: (err: Error) => void): Promise<void> | void;
/**
* Create access token for the logged in user. This method can be overridden to
@@ -2716,7 +2731,7 @@ declare namespace l {
* @param {string|Error} err The error string or object
* @param {AccessToken} token The generated access token object
*/
createAccessToken(ttl: number, options?: any, cb?: (err: string|Error, token: AccessToken) => void): void;
createAccessToken(ttl: number, options?: any, callback?: (err: string|Error, token: AccessToken) => void): Promise<AccessToken> | void;
/**
* Compare the given `password` with the users hashed password
@@ -2725,7 +2740,7 @@ declare namespace l {
* @param {Error} err Error object
* @param {boolean} isMatch Returns true if the given `password` matches recor
*/
hasPassword(password: string, callback: (err: Error, isMatch: boolean) => void): void;
hasPassword(password: string, callback?: (err: Error, isMatch: boolean) => void): Promise<boolean> | void;
/**
* Verify a user's identity by sending them a confirmation email
+23 -3
View File
@@ -1,19 +1,39 @@
import * as loopback from 'loopback';
import * as cookieParser from 'cookie-parser';
class TestModel {
id: number;
name: string;
}
class Server {
app: loopback.LoopBackApplication;
static boostrap(): Server {
return new Server();
return new Server();
}
constructor() {
this.app = loopback();
this.app.use(cookieParser());
this.app.start = () => {
// start the web server
this.app.start = async () => {
// start the web server
const models = this.app.models();
const model = models[0] as (typeof loopback.PersistedModel);
const data = await model.findOne<TestModel>();
if (data) {
console.dir(data.name);
}
model.findOne<TestModel>({}, (err, instance) => {
if (err) {
console.dir(err);
}
console.dir(instance.name);
});
};
}
}
+147 -6
View File
@@ -3,6 +3,7 @@
// Definitions by: Federico Caselli <https://github.com/CaselIT>
// Alan Marcell <https://github.com/alanmarcell>
// Gady Piazza <https://github.com/kikar>
// Jason Dreyzehner <https://github.com/bitjson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -624,7 +625,6 @@ export interface Collection<TSchema = Default> {
}
// Documentation: http://docs.mongodb.org/manual/reference/command/collStats/
//TODO complete this
export interface CollStats {
// Namespace.
ns: string;
@@ -644,21 +644,162 @@ export interface CollStats {
lastExtentSize: number;
// Padding can speed up updates if documents grow.
paddingFactor: number;
userFlags: number;
// A number that indicates the user-set flags on the collection. userFlags only appears when using the mmapv1 storage engine.
userFlags?: number;
// Total index size in bytes.
totalIndexSize: number;
// Size of specific indexes in bytes.
indexSizes: {
_id_: number;
username: number;
[index: string]: number;
};
// `true` if the collection is capped.
capped: boolean;
maxSize: boolean;
wiredTiger: any;
indexDetails: any;
// The maximum number of documents that may be present in a capped collection.
max: number;
// The maximum size of a capped collection.
maxSize: number;
wiredTiger?: WiredTigerData;
indexDetails?: any;
ok: number;
}
export interface WiredTigerData {
LSM: {
'bloom filter false positives': number,
'bloom filter hits': number;
'bloom filter misses': number;
'bloom filter pages evicted from cache': number;
'bloom filter pages read into cache': number;
'bloom filters in the LSM tree': number;
'chunks in the LSM tree': number;
'highest merge generation in the LSM tree': number;
'queries that could have benefited from a Bloom filter that did not exist': number;
'sleep for LSM checkpoint throttle': number;
'sleep for LSM merge throttle': number;
'total size of bloom filters': number;
};
'block-manager': {
'allocations requiring file extension': number;
'blocks allocated': number;
'blocks freed': number;
'checkpoint size': number;
'file allocation unit size': number;
'file bytes available for reuse': number;
'file magic number': number;
'file major version number': number;
'file size in bytes': number;
'minor version number': number;
};
btree: {
'btree checkpoint generation': number;
'column-store fixed-size leaf pages': number;
'column-store internal pages': number;
'column-store variable-size RLE encoded values': number;
'column-store variable-size deleted values': number;
'column-store variable-size leaf pages': number;
'fixed-record size': number;
'maximum internal page key size': number;
'maximum internal page size': number;
'maximum leaf page key size': number;
'maximum leaf page size': number;
'maximum leaf page value size': number;
'maximum tree depth': number;
'number of key/value pairs': number;
'overflow pages': number;
'pages rewritten by compaction': number;
'row-store internal pages': number;
'row-store leaf pages': number;
};
cache: {
'bytes currently in the cache': number;
'bytes read into cache': number;
'bytes written from cache': number;
'checkpoint blocked page eviction': number;
'data source pages selected for eviction unable to be evicted': number;
'hazard pointer blocked page eviction': number;
'in-memory page passed criteria to be split': number;
'in-memory page splits': number;
'internal pages evicted': number;
'internal pages split during eviction': number;
'leaf pages split during eviction': number;
'modified pages evicted': number;
'overflow pages read into cache': number;
'overflow values cached in memory': number;
'page split during eviction deepened the tree': number;
'page written requiring lookaside records': number;
'pages read into cache': number;
'pages read into cache requiring lookaside entries': number;
'pages requested from the cache': number;
'pages written from cache': number;
'pages written requiring in-memory restoration': number;
'tracked dirty bytes in the cache': number;
'unmodified pages evicted': number;
};
cache_walk: {
'Average difference between current eviction generation when the page was last considered': number;
'Average on-disk page image size seen': number;
'Clean pages currently in cache': number;
'Current eviction generation': number;
'Dirty pages currently in cache': number;
'Entries in the root page': number;
'Internal pages currently in cache': number;
'Leaf pages currently in cache': number;
'Maximum difference between current eviction generation when the page was last considered': number;
'Maximum page size seen': number;
'Minimum on-disk page image size seen': number;
'On-disk page image sizes smaller than a single allocation unit': number;
'Pages created in memory and never written': number;
'Pages currently queued for eviction': number;
'Pages that could not be queued for eviction': number;
'Refs skipped during cache traversal': number;
'Size of the root page': number;
'Total number of pages currently in cache': number;
};
compression: {
'compressed pages read': number;
'compressed pages written': number;
'page written failed to compress': number;
'page written was too small to compress': number;
'raw compression call failed, additional data available': number;
'raw compression call failed, no additional data available': number;
'raw compression call succeeded': number;
};
cursor: {
'bulk-loaded cursor-insert calls': number;
'create calls': number;
'cursor-insert key and value bytes inserted': number;
'cursor-remove key bytes removed': number;
'cursor-update value bytes updated': number;
'insert calls': number;
'next calls': number;
'prev calls': number;
'remove calls': number;
'reset calls': number;
'restarted searches': number;
'search calls': number;
'search near calls': number;
'truncate calls': number;
'update calls': number;
};
reconciliation: {
'dictionary matches': number;
'fast-path pages deleted': number;
'internal page key bytes discarded using suffix compression': number;
'internal page multi-block writes': number;
'internal-page overflow keys': number;
'leaf page key bytes discarded using prefix compression': number;
'leaf page multi-block writes': number;
'leaf-page overflow keys': number;
'maximum blocks required for a page': number;
'overflow values written': number;
'page checksum matches': number;
'page reconciliation calls': number;
'page reconciliation calls for eviction': number;
'pages deleted': number;
};
}
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate
export interface CollectionAggregationOptions {
readPreference?: ReadPreference | string;
+8 -3
View File
@@ -13,12 +13,12 @@ let options = {
promoteValues : {},
pkFactory : {},
poolSize : 1,
socketOptions : {},
reconnectTries : 123456,
reconnectInterval : 123456,
ssl : true,
sslValidate : {},
checkServerIdentity : function (){ },
@@ -49,6 +49,11 @@ let options = {
console.log(stats.count + " documents");
});
//
collection.stats().then(function(stats){
console.log(stats.wiredTiger.cache['bytes currently in the cache']);
})
collection.createIndex({}, {partialFilterExpression: {rating: {$exists: 1}}})
});
+155
View File
@@ -0,0 +1,155 @@
// Type definitions for react-aria-menubutton 5.0
// Project: https://github.com/davidtheclark/react-aria-menubutton
// Definitions by: Muhammad Fawwaz Orabi <https://github.com/forabi>
// Chris Rohlfs <https://github.com/crohlfs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as React from "react";
export interface WrapperState {
isOpen: boolean;
}
export interface WrapperProps<T extends HTMLElement>
extends React.HTMLAttributes<T> {
/**
* A callback to run when the user makes a selection
* (i.e. clicks or presses Enter or Space on a `MenuItem`).
* It will be passed the value of the selected `MenuItem` and
* the React `SyntheticEvent`.
*/
onSelection(value: any, event: React.SyntheticEvent<T>): any;
/**
* A callback to run when the menu is opened or closed.
*/
onMenuToggle?(obj: WrapperState): any;
/**
* By default, it does automatically close.
* If false, the menu will not automatically close when a
* selection is made. Default: `true`.
*/
closeOnSelection?: boolean;
isOpen?: boolean;
tag?: T["tagName"];
}
/**
* A simple component to group a `Button`/`Menu`/`MenuItem` set,
* coordinating their interactions. It should wrap your entire menu button
* widget.
* All `Button`, `Menu`, and `MenuItem` components must be nested within a
* `Wrapper` component.
* Each wrapper can contain only one `Button`, only one `Menu`, and
* multiple `MenuItem`s.
*/
export class Wrapper extends React.Component<WrapperProps<HTMLElement>> {}
export interface ButtonProps<T extends HTMLElement>
extends React.HTMLAttributes<T> {
/**
* If true, the element is disabled
* (aria-disabled='true', not in tab order, clicking has no effect).
*/
disabled?: boolean;
/**
* The HTML tag for this element. Default: 'span'.
*/
tag?: T["tagName"];
}
/**
* A React component to wrap the content of your
* menu-button-pattern's button.
* The `Button` component itself acts as a UI button (with tab-index, role, etc.),
* so you probably do not want to pass an HTML `<button>` element as its child.
* Each `Button` must be wrapped in a Wrapper, and each Wrapper can wrap only
* one `Button`.
*/
export class Button extends React.Component<ButtonProps<HTMLElement>> {}
export interface MenuProps<T extends HTMLElement>
extends React.HTMLAttributes<T> {
/**
* The HTML tag for this element. Default: 'span'.
*/
tag?: T["tagName"];
}
/**
* A React component to wrap the content of your menu-button-pattern's menu.
*/
export class Menu extends React.Component<MenuProps<HTMLElement>> {}
export interface MenuItemProps<T extends HTMLElement>
extends React.HTMLAttributes<T> {
/**
* If value has a value, it will be passed to the onSelection handler
* when the `MenuItem` is selected
*/
value?: string | boolean | number;
/**
* If `text` has a value, its first letter will be the letter a user can
* type to navigate to that item.
*/
text?: string;
/**
* The HTML tag for this element. Default: 'span'.
*/
tag?: T["tagName"];
}
/**
* A React component to wrap the content of one of your
* menu-button-pattern's menu items.
* Each `MenuItem` must be wrapped in a `Wrapper`,
* and each Wrapper can wrap multiple `MenuItem`s.
* When a `MenuItem` is selected (by clicking or focusing and hitting Enter
* or Space), it calls the `onSelection` handler you passed ariaMenuButton
* when creating this set of components.
* It passes that handler a value and the event. The value it passes is
* determined as follows:
* * If the `MenuItem` has a `value` prop, that is passed.
* * If the `MenuItem` has no `value` prop, the component's child is passed
* (so it better be simple text!).
*/
export class MenuItem extends React.Component<MenuItemProps<HTMLElement>> {}
/**
* Open a modal programmatically.
* For this to work, you must provide an id prop to the Wrapper of the menu.
* That id should be your first argument to `openMenu()`.
*/
export function openMenu(
wrapperId: string,
openOptions?: {
/**
* If `true`, the menu's first item will receive focus when the
* menu opens. Default: `false`.
*/
focusMenu: boolean;
}
): void;
/**
* Close a modal programmatically.
* For this to work, you must provide an id prop to the Wrapper of the menu.
* That id should be your first argument to `closeMenu()`.
*/
export function closeMenu(
wrapperId: string,
closeOptions?: {
/**
* If `true`, the widget's button will receive focus when the
* menu closes. Default: `false`.
*/
focusMenu: boolean;
}
): void;
@@ -0,0 +1,126 @@
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
closeMenu,
openMenu,
Wrapper,
Button,
Menu,
MenuItem
} from "react-aria-menubutton";
const menuItemWords = ["foo", "bar", "baz"];
class MyMenuButton extends React.Component {
render() {
const menuItems = menuItemWords.map((word, i) => {
return (
<li key={i}>
<MenuItem className="MyMenuButton-menuItem">
{word}
</MenuItem>
</li>
);
});
return (
<Wrapper
className="MyMenuButton"
onSelection={(value, event) => console.log(value, event)}
>
<Button className="MyMenuButton-button">click me</Button>
<Menu className="MyMenuButton-menu">
<ul>
{menuItems}
</ul>
</Menu>
</Wrapper>
);
}
}
ReactDOM.render(<MyMenuButton />, document.body);
const words = [
"pectinate",
"borborygmus",
"anisodactylous",
"barbar",
"pilcrow",
"destroy"
];
interface DemoOneState {
selected: string;
noMenu: boolean;
}
class DemoOne extends React.Component<{}, DemoOneState> {
constructor(props: any) {
super(props);
this.state = { selected: "", noMenu: false };
}
handleSelection(value: string) {
if (value === "destroy") {
this.setState({ noMenu: true });
} else {
this.setState({ selected: value });
}
}
render() {
const { selected, noMenu } = this.state;
if (noMenu) {
return (
<div>
[You decided to "destroy this menu," so the menu has been destroyed,
according to your wishes. Refresh the page to see it again.]
</div>
);
}
const menuItemElements = words.map((word, i) => {
let itemClass = "AriaMenuButton-menuItem";
if (selected === word) {
itemClass += " is-selected";
}
const display = word === "destroy" ? "destroy this menu" : word;
return (
<li className="AriaMenuButton-menuItemWrapper" key={i}>
<MenuItem className={itemClass} value={word} text={word}>
{display}
</MenuItem>
</li>
);
});
return (
<div>
<Wrapper
className="AriaMenuButton"
onSelection={this.handleSelection.bind(this)}
>
<Button className="AriaMenuButton-trigger">Select a word</Button>
<Menu>
<ul className="AriaMenuButton-menu">
{menuItemElements}
</ul>
</Menu>
</Wrapper>
<span style={{ marginLeft: "1em" }}>
Your last selection was: <strong>{selected}</strong>
</span>
</div>
);
}
}
ReactDOM.render(<DemoOne />, document.getElementById("demo-one"));
closeMenu("");
closeMenu("", { focusMenu: true });
openMenu("");
openMenu("", { focusMenu: true });
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"jsx": "react",
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-aria-menubutton-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1
View File
@@ -22,6 +22,7 @@ declare module "react-jsonschema-form" {
onSubmit?: (e: any) => any;
liveValidate?: boolean;
safeRenderCompletion?: boolean;
FieldTemplate?: any;
}
export interface IChangeEvent {