mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Merge branch 'master' of github.com:DefinitelyTyped/DefinitelyTyped into inquirer
This commit is contained in:
@@ -2,6 +2,7 @@ Please fill in this template.
|
||||
|
||||
- [ ] Use a meaningful title for the pull request. Include the name of the package modified.
|
||||
- [ ] Test the change in your own code. (Compile and run.)
|
||||
- [ ] Add or edit tests to reflect the change. (Run with `npm test`.)
|
||||
- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request).
|
||||
- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes).
|
||||
- [ ] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present).
|
||||
|
||||
Vendored
+3
-6
@@ -16,16 +16,13 @@
|
||||
declare var AFRAME: AFrame.AFrameGlobal;
|
||||
declare var hasNativeWebVRImplementation: boolean;
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector(selectors: 'a-scene'): AFrame.Scene;
|
||||
interface Document {
|
||||
createElement(tagName: string): AFrame.Entity;
|
||||
querySelector(selectors: 'a-scene'): AFrame.Scene;
|
||||
querySelector<T extends AFrame.Entity<any>>(selectors: string): T;
|
||||
querySelectorAll(selectors: string): NodeListOf<AFrame.Entity<any> | Element>;
|
||||
}
|
||||
|
||||
interface Document {
|
||||
createElement(tagName: string): AFrame.Entity;
|
||||
}
|
||||
|
||||
// Interfaces
|
||||
declare namespace AFrame {
|
||||
interface ObjectMap<T = any> {
|
||||
|
||||
@@ -719,6 +719,9 @@ function testDisplayMarker() {
|
||||
|
||||
// DisplayMarkerLayer =========================================================
|
||||
function testDisplayMarkerLayer() {
|
||||
// Properties
|
||||
str = displayMarkerLayer.id;
|
||||
|
||||
// Lifecycle
|
||||
displayMarkerLayer.destroy();
|
||||
displayMarkerLayer.clear();
|
||||
@@ -953,7 +956,8 @@ function testFile() {
|
||||
|
||||
// Reading and Writing
|
||||
async function readFile() {
|
||||
str = await file.read();
|
||||
const res = await file.read();
|
||||
if (res !== null) str = res;
|
||||
}
|
||||
|
||||
const stream = file.createReadStream();
|
||||
@@ -1274,6 +1278,9 @@ function testMarker() {
|
||||
|
||||
// MarkerLayer ================================================================
|
||||
function testMarkerLayer() {
|
||||
// Properties
|
||||
str = markerLayer.id;
|
||||
|
||||
// Lifecycle
|
||||
markerLayer = markerLayer.copy();
|
||||
bool = markerLayer.destroy();
|
||||
|
||||
Vendored
+7
-1
@@ -654,6 +654,9 @@ export interface DisplayMarker {
|
||||
* This API is experimental and subject to change on any release.
|
||||
*/
|
||||
export interface DisplayMarkerLayer {
|
||||
/** The identifier for the underlying MarkerLayer. */
|
||||
id: string;
|
||||
|
||||
// Lifecycle
|
||||
/** Destroy this layer. */
|
||||
destroy(): void;
|
||||
@@ -949,6 +952,9 @@ export interface Marker {
|
||||
|
||||
/** Experimental: A container for a related set of markers. */
|
||||
export interface MarkerLayer {
|
||||
/** The identifier for this MarkerLayer. */
|
||||
id: string;
|
||||
|
||||
// Lifecycle
|
||||
/** Create a copy of this layer with markers in the same state and locations. */
|
||||
copy(): MarkerLayer;
|
||||
@@ -3547,7 +3553,7 @@ export class File {
|
||||
|
||||
// Reading and Writing
|
||||
/** Reads the contents of the file. */
|
||||
read(flushCache?: boolean): Promise<string>;
|
||||
read(flushCache?: boolean): Promise<string | null>;
|
||||
|
||||
/** Returns a stream to read the content of the file. */
|
||||
createReadStream(): ReadStream;
|
||||
|
||||
+40
-36
@@ -1,10 +1,10 @@
|
||||
import Boom = require('boom');
|
||||
import * as Boom from 'boom';
|
||||
|
||||
// 4xx and data type
|
||||
|
||||
const badRequestError = Boom.badRequest('message', {some: 'data'});
|
||||
badRequestError.data.some;
|
||||
const badRequestError2: Boom.Boom = Boom.badImplementation('message');
|
||||
const badRequestError2: Boom = Boom.badImplementation('message');
|
||||
|
||||
const unauthorizedError1 = Boom.unauthorized('message', 'scheme', {some: 'attribute'});
|
||||
unauthorizedError1.output.payload.attributes === { some: 'attribute', error: 'message' };
|
||||
@@ -24,127 +24,131 @@ unauthorizedError4.output.headers === { 'WWW-Authenticate': 'scheme some="attrib
|
||||
|
||||
const paymentRequiredError = Boom.paymentRequired('message', {some: 'data'});
|
||||
paymentRequiredError.data.some;
|
||||
const paymentRequiredError2: Boom.Boom = Boom.paymentRequired('message');
|
||||
const paymentRequiredError2: Boom = Boom.paymentRequired('message');
|
||||
|
||||
const forbiddenError = Boom.forbidden('message', {some: 'data'});
|
||||
forbiddenError.data.some;
|
||||
const forbiddenError2: Boom.Boom = Boom.forbidden('message');
|
||||
const forbiddenError2: Boom = Boom.forbidden('message');
|
||||
|
||||
const notFoundError = Boom.notFound('message', {some: 'data'});
|
||||
notFoundError.data.some;
|
||||
const notFoundError2: Boom.Boom = Boom.notFound('message');
|
||||
const notFoundError2: Boom = Boom.notFound('message');
|
||||
|
||||
const methodNotAllowedError = Boom.methodNotAllowed('message', {some: 'data'});
|
||||
methodNotAllowedError.data.some;
|
||||
const methodNotAllowedError2: Boom.Boom = Boom.methodNotAllowed('message');
|
||||
const methodNotAllowedError2: Boom = Boom.methodNotAllowed('message');
|
||||
|
||||
const notAcceptableError = Boom.notAcceptable('message', {some: 'data'});
|
||||
notAcceptableError.data.some;
|
||||
const notAcceptableError2: Boom.Boom = Boom.notAcceptable('message');
|
||||
const notAcceptableError2: Boom = Boom.notAcceptable('message');
|
||||
|
||||
const proxyAuthRequiredError = Boom.proxyAuthRequired('message', {some: 'data'});
|
||||
proxyAuthRequiredError.data.some;
|
||||
const proxyAuthRequiredError2: Boom.Boom = Boom.proxyAuthRequired('message');
|
||||
const proxyAuthRequiredError2: Boom = Boom.proxyAuthRequired('message');
|
||||
|
||||
const clientTimeoutError = Boom.clientTimeout('message', {some: 'data'});
|
||||
clientTimeoutError.data.some;
|
||||
const clientTimeoutError2: Boom.Boom = Boom.clientTimeout('message');
|
||||
const clientTimeoutError2: Boom = Boom.clientTimeout('message');
|
||||
|
||||
const conflictError = Boom.conflict('message', {some: 'data'});
|
||||
conflictError.data.some;
|
||||
|
||||
const resourceGoneError = Boom.resourceGone('message', {some: 'data'});
|
||||
resourceGoneError.data.some;
|
||||
const resourceGoneError2: Boom.Boom = Boom.resourceGone('message');
|
||||
const resourceGoneError2: Boom = Boom.resourceGone('message');
|
||||
|
||||
const lengthRequiredError = Boom.lengthRequired('message', {some: 'data'});
|
||||
lengthRequiredError.data.some;
|
||||
const lengthRequiredError2: Boom.Boom = Boom.lengthRequired('message');
|
||||
const lengthRequiredError2: Boom = Boom.lengthRequired('message');
|
||||
|
||||
const preconditionFailedError = Boom.preconditionFailed('message', {some: 'data'});
|
||||
preconditionFailedError.data.some;
|
||||
const preconditionFailedError2: Boom.Boom = Boom.preconditionFailed('message');
|
||||
const preconditionFailedError2: Boom = Boom.preconditionFailed('message');
|
||||
|
||||
const entityTooLargeError = Boom.entityTooLarge('message', {some: 'data'});
|
||||
entityTooLargeError.data.some;
|
||||
const entityTooLargeError2: Boom.Boom = Boom.lengthRequired('message');
|
||||
const entityTooLargeError2: Boom = Boom.lengthRequired('message');
|
||||
|
||||
const uriTooLongError = Boom.uriTooLong('message', {some: 'data'});
|
||||
uriTooLongError.data.some;
|
||||
const uriTooLongError2: Boom.Boom = Boom.uriTooLong('message');
|
||||
const uriTooLongError2: Boom = Boom.uriTooLong('message');
|
||||
|
||||
const unsupportedMediaTypeError = Boom.unsupportedMediaType('message', {some: 'data'});
|
||||
unsupportedMediaTypeError.data.some;
|
||||
const unsupportedMediaTypeError2: Boom.Boom = Boom.unsupportedMediaType('message');
|
||||
const unsupportedMediaTypeError2: Boom = Boom.unsupportedMediaType('message');
|
||||
|
||||
const rangeNotSatisfiableError = Boom.rangeNotSatisfiable('message', {some: 'data'});
|
||||
rangeNotSatisfiableError.data.some;
|
||||
const rangeNotSatisfiableError2: Boom.Boom = Boom.rangeNotSatisfiable('message');
|
||||
const rangeNotSatisfiableError2: Boom = Boom.rangeNotSatisfiable('message');
|
||||
|
||||
const expectationFailedError = Boom.expectationFailed('message', {some: 'data'});
|
||||
expectationFailedError.data.some;
|
||||
const expectationFailedError2: Boom.Boom = Boom.expectationFailed('message');
|
||||
const expectationFailedError2: Boom = Boom.expectationFailed('message');
|
||||
|
||||
const teapotError = Boom.teapot('message', {some: 'data'});
|
||||
teapotError.data.some;
|
||||
const teapotError2: Boom.Boom = Boom.teapot('message');
|
||||
const teapotError2: Boom = Boom.teapot('message');
|
||||
|
||||
const badDataError = Boom.badData('message', {some: 'data'});
|
||||
badDataError.data.some;
|
||||
const badDataError2: Boom.Boom = Boom.badData('message');
|
||||
const badDataError2: Boom = Boom.badData('message');
|
||||
|
||||
const lockedError = Boom.locked('message', {some: 'data'});
|
||||
lockedError.data.some;
|
||||
const lockedError2: Boom.Boom = Boom.locked('message');
|
||||
const lockedError2: Boom = Boom.locked('message');
|
||||
|
||||
const failedDependencyError = Boom.failedDependency('message', {some: 'data'});
|
||||
failedDependencyError.data.some;
|
||||
const failedDependencyError2: Boom = Boom.failedDependency('message');
|
||||
|
||||
const preconditionRequiredError = Boom.preconditionRequired('message', {some: 'data'});
|
||||
preconditionRequiredError.data.some;
|
||||
const preconditionRequiredError2: Boom.Boom = Boom.preconditionRequired('message');
|
||||
const preconditionRequiredError2: Boom = Boom.preconditionRequired('message');
|
||||
|
||||
const tooManyRequestsError = Boom.tooManyRequests('message', {some: 'data'});
|
||||
tooManyRequestsError.data.some;
|
||||
const tooManyRequestsError2: Boom.Boom = Boom.tooManyRequests('message');
|
||||
const tooManyRequestsError2: Boom = Boom.tooManyRequests('message');
|
||||
|
||||
const illegalError = Boom.illegal('message', {some: 'data'});
|
||||
illegalError.data.some;
|
||||
const illegalError2: Boom.Boom = Boom.illegal('message');
|
||||
const illegalError2: Boom = Boom.illegal('message');
|
||||
|
||||
// 5xx and data type
|
||||
|
||||
const badImplementationError = Boom.badImplementation('message', {some: 'data'});
|
||||
badImplementationError.data.some;
|
||||
const badImplementationError2: Boom.Boom = Boom.badImplementation('message');
|
||||
const badImplementationError2: Boom = Boom.badImplementation('message');
|
||||
|
||||
const internalError = Boom.internal('message', {some: 'data'});
|
||||
internalError.data.some;
|
||||
const internalError2: Boom.Boom = Boom.internal('message');
|
||||
const internalError2: Boom = Boom.internal('message');
|
||||
|
||||
const notImplementedError = Boom.notImplemented('message', {some: 'data'});
|
||||
notImplementedError.data.some;
|
||||
const notImplementedError2: Boom.Boom = Boom.notImplemented('message');
|
||||
const notImplementedError2: Boom = Boom.notImplemented('message');
|
||||
|
||||
const badGatewayError = Boom.badGateway('message', {some: 'data'});
|
||||
badGatewayError.data.some;
|
||||
const badGatewayError2: Boom.Boom = Boom.badGateway('message');
|
||||
const badGatewayError2: Boom = Boom.badGateway('message');
|
||||
|
||||
const serverUnavailableError = Boom.serverUnavailable('message', {some: 'data'});
|
||||
serverUnavailableError.data.some;
|
||||
const serverUnavailableError2: Boom.Boom = Boom.serverUnavailable('message');
|
||||
const serverUnavailableError2: Boom = Boom.serverUnavailable('message');
|
||||
|
||||
const gatewayTimeoutError = Boom.gatewayTimeout('message', {some: 'data'});
|
||||
gatewayTimeoutError.data.some;
|
||||
const gatewayTimeoutError2: Boom.Boom = Boom.gatewayTimeout('message');
|
||||
const gatewayTimeoutError2: Boom = Boom.gatewayTimeout('message');
|
||||
|
||||
// boomify
|
||||
const boomifiedError = Boom.boomify(new Error('test'), { statusCode: 400, message: 'some message' });
|
||||
|
||||
// isBoom
|
||||
|
||||
const isBoomError = new Boom.Boom('test')
|
||||
const isBoomError = new Boom('test')
|
||||
|
||||
Boom.isBoom(isBoomError);
|
||||
|
||||
const maybeBoom = <any>new Boom.Boom('test');
|
||||
const maybeBoom = <any>new Boom('test');
|
||||
if(Boom.isBoom(maybeBoom)) {
|
||||
// isBoom is a type guard that allows accessing these properties:
|
||||
maybeBoom.output.headers;
|
||||
@@ -152,7 +156,7 @@ if(Boom.isBoom(maybeBoom)) {
|
||||
|
||||
// constructor
|
||||
|
||||
const constructorError: Boom.Boom = new Boom.Boom('test');
|
||||
const constructorError: Boom = new Boom('test');
|
||||
|
||||
constructorError.message;
|
||||
|
||||
@@ -180,11 +184,11 @@ interface CustomPayload extends Boom.Payload {
|
||||
* Test assignment of custom error data:
|
||||
*/
|
||||
const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: 'Custom1', isCustom: true } as CustomData1);
|
||||
const errorWithNoExplicitDataType: Boom.Boom = errorWithData; // can assign to error without explicit data type
|
||||
const errorWithExplicitType: Boom.Boom<CustomData> = errorWithData; // can assign to union data type
|
||||
const errorWithConcreteCustomData: Boom.Boom<CustomData1> = errorWithData; // can assign to concrete data type
|
||||
const errorWithNoExplicitDataType: Boom = errorWithData; // can assign to error without explicit data type
|
||||
const errorWithExplicitType: Boom<CustomData> = errorWithData; // can assign to union data type
|
||||
const errorWithConcreteCustomData: Boom<CustomData1> = errorWithData; // can assign to concrete data type
|
||||
// assignment to CustomData2 would not be possible
|
||||
// const errorWithConcreteCustomData2: Boom.Boom<CustomData2> = errorWithData;
|
||||
// const errorWithConcreteCustomData2: Boom<CustomData2> = errorWithData;
|
||||
|
||||
// Some complex error data types for testing purposes:
|
||||
interface CustomDataBase {
|
||||
|
||||
Vendored
+54
-47
@@ -1,23 +1,22 @@
|
||||
// Type definitions for boom 7.1.1
|
||||
// Type definitions for boom 7.2.0
|
||||
// Project: https://github.com/hapijs/boom
|
||||
// Definitions by: Igor Rogatty <https://github.com/rogatty>
|
||||
// AJP <https://github.com/AJamesPhillips>
|
||||
// Jinesh Shah <https://github.com/jineshshah36>
|
||||
// Timon van Spronsen <https://github.com/TimonVS>
|
||||
// Daniel Machado <https://github.com/danielmachado>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
export = Boom;
|
||||
|
||||
declare namespace Boom {
|
||||
|
||||
/**
|
||||
export = Boom;
|
||||
/**
|
||||
* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties:
|
||||
* @see {@link https://github.com/hapijs/boom#boom}
|
||||
*/
|
||||
export class Boom<Data = any> extends Error {
|
||||
declare class Boom<Data = any> extends Error {
|
||||
|
||||
/** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */
|
||||
constructor(message?: string | Error, options?: Options<Data>);
|
||||
constructor(message?: string | Error, options?: Boom.Options<Data>);
|
||||
/** isBoom - if true, indicates this is a Boom object instance. */
|
||||
isBoom: boolean;
|
||||
/** isServer - convenience bool indicating status code >= 500. */
|
||||
@@ -25,7 +24,7 @@ declare namespace Boom {
|
||||
/** message - the error message. */
|
||||
message: string;
|
||||
/** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */
|
||||
output: Output;
|
||||
output: Boom.Output;
|
||||
/** reformat() - rebuilds error.output using the other object properties. */
|
||||
reformat: () => string;
|
||||
/** "If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object." mentioned in @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */
|
||||
@@ -33,7 +32,7 @@ declare namespace Boom {
|
||||
/** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */
|
||||
data: Data;
|
||||
}
|
||||
|
||||
declare namespace Boom {
|
||||
interface Options<Data> {
|
||||
/** statusCode - the HTTP status code. Defaults to 500 if no status code is already set. */
|
||||
statusCode?: number;
|
||||
@@ -49,7 +48,7 @@ declare namespace Boom {
|
||||
override?: boolean;
|
||||
}
|
||||
|
||||
export interface Output {
|
||||
interface Output {
|
||||
/** statusCode - the HTTP status code (typically 4xx or 5xx). */
|
||||
statusCode: number;
|
||||
/** headers - an object containing any HTTP headers where each key is a header name and value is the header content. (Limited value type to string https://github.com/hapijs/boom/issues/151 ) */
|
||||
@@ -58,7 +57,7 @@ declare namespace Boom {
|
||||
payload: Payload;
|
||||
}
|
||||
|
||||
export interface Payload {
|
||||
interface Payload {
|
||||
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
|
||||
statusCode: number;
|
||||
/** error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode. */
|
||||
@@ -80,13 +79,13 @@ declare namespace Boom {
|
||||
* @param options optional additional options
|
||||
* @see {@link https://github.com/hapijs/boom#boomifyerror-options}
|
||||
*/
|
||||
export function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom<null>;
|
||||
function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom<null>;
|
||||
|
||||
/**
|
||||
* Identifies whether an error is a Boom object. Same as calling instanceof Boom.
|
||||
* @param error the error object to identify.
|
||||
*/
|
||||
export function isBoom(error: Error): error is Boom
|
||||
function isBoom(error: Error): error is Boom
|
||||
|
||||
// 4xx
|
||||
/**
|
||||
@@ -95,7 +94,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data}
|
||||
*/
|
||||
export function badRequest<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function badRequest<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 401 Unauthorized error
|
||||
@@ -106,10 +105,10 @@ declare namespace Boom {
|
||||
* @param attributes an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when scheme is a string, otherwise it is ignored. Every key/value pair will be included in the 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the attributes key. Alternatively value can be a string which is use to set the value of the scheme, for example setting the token value for negotiate header. If string is used message parameter must be null. null and undefined will be replaced with an empty string. If attributes is set, message will be used as the 'error' segment of the 'WWW-Authenticate' header. If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
|
||||
*/
|
||||
export function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom<null>;
|
||||
export function unauthorized(message?: string, scheme?: string[]): Boom<null>;
|
||||
export function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom<null>;
|
||||
export function unauthorized(message?: null, scheme?: string[]): Boom<null>;
|
||||
function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom<null>;
|
||||
function unauthorized(message?: string, scheme?: string[]): Boom<null>;
|
||||
function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom<null>;
|
||||
function unauthorized(message?: null, scheme?: string[]): Boom<null>;
|
||||
|
||||
/**
|
||||
* Returns a 402 Payment Required error
|
||||
@@ -117,7 +116,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data}
|
||||
*/
|
||||
export function paymentRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function paymentRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 403 Forbidden error
|
||||
@@ -125,7 +124,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data}
|
||||
*/
|
||||
export function forbidden<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function forbidden<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 404 Not Found error
|
||||
@@ -133,7 +132,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data}
|
||||
*/
|
||||
export function notFound<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function notFound<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 405 Method Not Allowed error
|
||||
@@ -142,7 +141,7 @@ declare namespace Boom {
|
||||
* @param allow optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header.
|
||||
* @see {@link https://github.com/hapijs/boom#boommethodnotallowedmessage-data-allow}
|
||||
*/
|
||||
export function methodNotAllowed<Data = null>(message?: string, data?: Data, allow?: string | string[]): Boom<Data>;
|
||||
function methodNotAllowed<Data = null>(message?: string, data?: Data, allow?: string | string[]): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 406 Not Acceptable error
|
||||
@@ -150,7 +149,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data}
|
||||
*/
|
||||
export function notAcceptable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function notAcceptable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 407 Proxy Authentication Required error
|
||||
@@ -158,7 +157,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data}
|
||||
*/
|
||||
export function proxyAuthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function proxyAuthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 408 Request Time-out error
|
||||
@@ -166,7 +165,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data}
|
||||
*/
|
||||
export function clientTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function clientTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 409 Conflict error
|
||||
@@ -174,7 +173,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomconflictmessage-data}
|
||||
*/
|
||||
export function conflict<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function conflict<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 410 Gone error
|
||||
@@ -182,7 +181,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data}
|
||||
*/
|
||||
export function resourceGone<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function resourceGone<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 411 Length Required error
|
||||
@@ -190,7 +189,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data}
|
||||
*/
|
||||
export function lengthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function lengthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 412 Precondition Failed error
|
||||
@@ -198,7 +197,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data}
|
||||
*/
|
||||
export function preconditionFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function preconditionFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 413 Request Entity Too Large error
|
||||
@@ -206,7 +205,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data}
|
||||
*/
|
||||
export function entityTooLarge<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function entityTooLarge<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 414 Request-URI Too Large error
|
||||
@@ -214,7 +213,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data}
|
||||
*/
|
||||
export function uriTooLong<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function uriTooLong<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 415 Unsupported Media Type error
|
||||
@@ -222,7 +221,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data}
|
||||
*/
|
||||
export function unsupportedMediaType<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function unsupportedMediaType<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 416 Requested Range Not Satisfiable error
|
||||
@@ -230,7 +229,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data}
|
||||
*/
|
||||
export function rangeNotSatisfiable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function rangeNotSatisfiable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 417 Expectation Failed error
|
||||
@@ -238,7 +237,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data}
|
||||
*/
|
||||
export function expectationFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function expectationFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 418 I'm a Teapot error
|
||||
@@ -246,7 +245,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomteapotmessage-data}
|
||||
*/
|
||||
export function teapot<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function teapot<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 422 Unprocessable Entity error
|
||||
@@ -254,7 +253,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombaddatamessage-data}
|
||||
*/
|
||||
export function badData<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function badData<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 423 Locked error
|
||||
@@ -262,7 +261,15 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomlockedmessage-data}
|
||||
*/
|
||||
export function locked<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function locked<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 424 Failed Dependency error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomfaileddependencymessage-data}
|
||||
*/
|
||||
function failedDependency<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 428 Precondition Required error
|
||||
@@ -270,7 +277,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data}
|
||||
*/
|
||||
export function preconditionRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function preconditionRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 429 Too Many Requests error
|
||||
@@ -278,7 +285,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data}
|
||||
*/
|
||||
export function tooManyRequests<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function tooManyRequests<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 451 Unavailable For Legal Reasons error
|
||||
@@ -286,7 +293,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomillegalmessage-data}
|
||||
*/
|
||||
export function illegal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function illegal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
// 5xx
|
||||
/**
|
||||
@@ -296,7 +303,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
export function badImplementation<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function badImplementation<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 500 Internal Server Error error
|
||||
@@ -305,7 +312,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
|
||||
*/
|
||||
export function internal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function internal<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 501 Not Implemented error with your error message to the user
|
||||
@@ -313,7 +320,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data}
|
||||
*/
|
||||
export function notImplemented<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function notImplemented<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 502 Bad Gateway error with your error message to the user
|
||||
@@ -321,7 +328,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data}
|
||||
*/
|
||||
export function badGateway<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function badGateway<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 503 Service Unavailable error with your error message to the user
|
||||
@@ -329,7 +336,7 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data}
|
||||
*/
|
||||
export function serverUnavailable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function serverUnavailable<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 504 Gateway Time-out error with your error message to the user
|
||||
@@ -337,5 +344,5 @@ declare namespace Boom {
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data}
|
||||
*/
|
||||
export function gatewayTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
function gatewayTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -48,6 +48,7 @@ declare namespace Boom {
|
||||
export function expectationFailed(message?: string, data?: any): BoomError;
|
||||
export function badData(message?: string, data?: any): BoomError;
|
||||
export function locked(message?: string, data?: any): BoomError;
|
||||
export function failedDependency(message?: string, data?: any): BoomError;
|
||||
export function preconditionRequired(message?: string, data?: any): BoomError;
|
||||
export function tooManyRequests(message?: string, data?: any): BoomError;
|
||||
export function illegal(message?: string, data?: any): BoomError;
|
||||
|
||||
@@ -98,6 +98,10 @@ const lockedError = Boom.locked('message', {some: 'data'});
|
||||
lockedError.data.some;
|
||||
const lockedError2: Boom.BoomError = Boom.locked('message');
|
||||
|
||||
const failedDependencyError = Boom.failedDependency('message', {some: 'data'});
|
||||
failedDependencyError.data.some;
|
||||
const failedDependencyError2: Boom.BoomError = Boom.failedDependency('message');
|
||||
|
||||
const preconditionRequiredError = Boom.preconditionRequired('message', {some: 'data'});
|
||||
preconditionRequiredError.data.some;
|
||||
const preconditionRequiredError2: Boom.BoomError = Boom.preconditionRequired('message');
|
||||
|
||||
Vendored
+9
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Igor Rogatty <https://github.com/rogatty>
|
||||
// AJP <https://github.com/AJamesPhillips>
|
||||
// Jinesh Shah <https://github.com/jineshshah36>
|
||||
// Daniel Machado <https://github.com/danielmachado>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@@ -258,6 +259,14 @@ declare namespace Boom {
|
||||
*/
|
||||
export function locked<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 424 Failed Dependency error
|
||||
* @param message optional message.
|
||||
* @param data optional additional error data.
|
||||
* @see {@link https://github.com/hapijs/boom#boomfaileddependencymessage-data}
|
||||
*/
|
||||
export function failedDependency<Data = null>(message?: string, data?: Data): BoomError<Data>;
|
||||
|
||||
/**
|
||||
* Returns a 428 Precondition Required error
|
||||
* @param message optional message.
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
function BootstrapDialogOptionsTests() {
|
||||
const options1: BootstrapDialog.DialogOptions = { };
|
||||
const options2: BootstrapDialog.DialogOptions = {
|
||||
animate: false,
|
||||
buttons: [{id: "btn-1"}],
|
||||
callback: (result: boolean) => { },
|
||||
closable: false,
|
||||
closeByBackdrop: false,
|
||||
closeByKeyboard: false,
|
||||
data: {name: "value"},
|
||||
draggable: false,
|
||||
description: "",
|
||||
buttonLabel: "",
|
||||
message: "",
|
||||
onhide: (dialog: BootstrapDialog.DialogContext) => { },
|
||||
onhidden: (dialog: BootstrapDialog.DialogContext) => { },
|
||||
onshow: (dialog: BootstrapDialog.DialogContext) => { },
|
||||
onshown: (dialog: BootstrapDialog.DialogContext) => { },
|
||||
size: BootstrapDialog.SIZE_LARGE,
|
||||
title: "",
|
||||
type: BootstrapDialog.TYPE_DEFAULT,
|
||||
btnCancelLabel: "",
|
||||
btnOKClass: "",
|
||||
btnOKLabel: "",
|
||||
cssClass: "",
|
||||
spinicon: "",
|
||||
autodestroy: false,
|
||||
nl2br: false,
|
||||
};
|
||||
options2.onhide = (dialog: BootstrapDialog.DialogContext): void => { };
|
||||
options2.onhide = (dialog: BootstrapDialog.DialogContext): boolean => false;
|
||||
options2.message = "";
|
||||
options2.message = $("#element");
|
||||
options2.message = (dialog?: BootstrapDialog.DialogContext): string => {
|
||||
return "";
|
||||
};
|
||||
options2.message = (dialog?: BootstrapDialog.DialogContext): JQuery => {
|
||||
return $("#element");
|
||||
};
|
||||
// BootstrapDialog.SIZE_xxx constants.
|
||||
options2.size = BootstrapDialog.SIZE_LARGE;
|
||||
options2.size = BootstrapDialog.SIZE_NORMAL;
|
||||
options2.size = BootstrapDialog.SIZE_SMALL;
|
||||
options2.size = BootstrapDialog.SIZE_WIDE;
|
||||
options2.title = "";
|
||||
options2.title = $("#element");
|
||||
// BootstrapDialog.TYPE_xxx constants.
|
||||
options2.type = BootstrapDialog.TYPE_DANGER;
|
||||
options2.type = BootstrapDialog.TYPE_DEFAULT;
|
||||
options2.type = BootstrapDialog.TYPE_INFO;
|
||||
options2.type = BootstrapDialog.TYPE_PRIMARY;
|
||||
options2.type = BootstrapDialog.TYPE_SUCCESS;
|
||||
options2.type = BootstrapDialog.TYPE_WARNING;
|
||||
}
|
||||
|
||||
function BootstrapDialogStaticTests() {
|
||||
BootstrapDialog.alert("");
|
||||
BootstrapDialog.alert("", () => { });
|
||||
BootstrapDialog.confirm("");
|
||||
BootstrapDialog.confirm("", (result: boolean) => { });
|
||||
const instance1: BootstrapDialog.DialogInstance = BootstrapDialog.show({});
|
||||
// BUTTON_SIZES
|
||||
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL] = '';
|
||||
const buttonSize: string = BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL];
|
||||
// Buttons order
|
||||
BootstrapDialog.BUTTONS_ORDER_CANCEL_OK = "";
|
||||
BootstrapDialog.BUTTONS_ORDER_OK_CANCEL = "";
|
||||
// DEFAULT_TEXTS
|
||||
BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT] = 'Information';
|
||||
const defaultText: string = BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT];
|
||||
// Miscellaneous
|
||||
BootstrapDialog.ICON_SPINNER = "";
|
||||
BootstrapDialog.NAMESPACE = "";
|
||||
}
|
||||
|
||||
function BootstrapDialogContextTests() {
|
||||
const dialog1: BootstrapDialog.DialogContext = BootstrapDialog({});
|
||||
dialog1.close();
|
||||
dialog1.enableButtons(false);
|
||||
const button: JQuery = dialog1.getButton("");
|
||||
const value: any = dialog1.getData("name");
|
||||
const modal: JQuery = dialog1.getModal();
|
||||
const content: JQuery = dialog1.getModalContent();
|
||||
const dialog: JQuery = dialog1.getModalDialog();
|
||||
const header: JQuery = dialog1.getModalHeader();
|
||||
const footer: JQuery = dialog1.getModalFooter();
|
||||
const body: JQuery = dialog1.getModalBody();
|
||||
const title: string = dialog1.getTitle();
|
||||
dialog1.open();
|
||||
dialog1.realize();
|
||||
dialog1.setClosable(false);
|
||||
dialog1.setData("name", "value");
|
||||
dialog1.setData("", null);
|
||||
dialog1.setMessage("");
|
||||
dialog1.setTitle("");
|
||||
dialog1.setType(BootstrapDialog.TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
function BootstrapDialogInstanceTests() {
|
||||
const instance1: BootstrapDialog.DialogInstance = BootstrapDialog.show({});
|
||||
const modal: JQuery = instance1.$modal;
|
||||
const modalBody: JQuery = instance1.$modalBody;
|
||||
const modalContent: JQuery = instance1.$modalContent;
|
||||
const modalDialog: JQuery = instance1.$modalDialog;
|
||||
const modalHeader: JQuery = instance1.$modalHeader;
|
||||
const modalFooter: JQuery = instance1.$modalFooter;
|
||||
const options: BootstrapDialog.DialogOptions = instance1.options;
|
||||
const opened: boolean = instance1.opened;
|
||||
}
|
||||
|
||||
function BootstrapDialogButtonTests() {
|
||||
const button1: BootstrapDialog.DialogButton = { };
|
||||
const button2: BootstrapDialog.DialogButton = {
|
||||
id: "",
|
||||
label: "",
|
||||
hotkey: 0,
|
||||
icon: "",
|
||||
cssClass: "",
|
||||
data: {name: "value"},
|
||||
autospin: false,
|
||||
action: (dialog: BootstrapDialog.DialogContext) => { },
|
||||
};
|
||||
}
|
||||
Vendored
+197
@@ -0,0 +1,197 @@
|
||||
// Type definitions for bootstrap3-dialog 1.35
|
||||
// Project: http://nakupanda.github.io/bootstrap3-dialog
|
||||
// Definitions by: Dante <https://github.com/nakupanda>
|
||||
// Craig Boland <https://github.com/cnboland>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
declare namespace BootstrapDialog {
|
||||
interface DialogStatic {
|
||||
BUTTON_SIZES: any;
|
||||
BUTTONS_ORDER_CANCEL_OK: string;
|
||||
BUTTONS_ORDER_OK_CANCEL: string;
|
||||
DEFAULT_TEXTS: any; /** For text localization. */
|
||||
ICON_SPINNER: string;
|
||||
NAMESPACE: string;
|
||||
|
||||
SIZE_NORMAL: string;
|
||||
SIZE_SMALL: string;
|
||||
SIZE_WIDE: string;
|
||||
SIZE_LARGE: string;
|
||||
|
||||
TYPE_DEFAULT: string;
|
||||
TYPE_INFO: string;
|
||||
TYPE_PRIMARY: string;
|
||||
TYPE_SUCCESS: string;
|
||||
TYPE_WARNING: string;
|
||||
TYPE_DANGER: string;
|
||||
|
||||
(options: DialogOptions): DialogContext;
|
||||
alert(message: string, closeCallback?: () => void): void;
|
||||
confirm(message: string, closeCallback?: (result: boolean) => void): void;
|
||||
show(options: DialogOptions): DialogInstance;
|
||||
}
|
||||
|
||||
interface DialogOptions {
|
||||
/** Dialog header type. See BootstrapDialog.TYPE_xxx constants. */
|
||||
type?: string;
|
||||
/** Text size. See BootstrapDialog.SIZE_xxx constants. By default - SIZE_NORMAL */
|
||||
size?: string;
|
||||
/** Dialog title. Either string or JQuery element. */
|
||||
title?: string | JQuery;
|
||||
/** Dialog message. Either string, JQuery element, or function that returns either string or JQuery element. */
|
||||
message?: string | JQuery | ((dialog?: DialogContext) => string | JQuery);
|
||||
/**
|
||||
* When set to true, you can close the dialog by:
|
||||
* - Clicking the close icon in dialog header.
|
||||
* - Clicking outside the dialog.
|
||||
* - ESC key.
|
||||
*
|
||||
* FALSE by default.
|
||||
*/
|
||||
closable?: boolean;
|
||||
/** Whether dialog will close by clicking outside of it. */
|
||||
closeByBackdrop?: boolean;
|
||||
/** Whether dialog will close by ESC. */
|
||||
closeByKeyboard?: boolean;
|
||||
/** Whether fade-out background while showing the dialog. TRUE by default. */
|
||||
animate?: boolean;
|
||||
/** Data to be bound to the dialog. */
|
||||
data?: any;
|
||||
/** Whether dialog could be dragged by its header. Cursor could be changed (see doc)! FALSE by default. */
|
||||
draggable?: boolean;
|
||||
/**
|
||||
* If provided, 'aria-describedby' attribute will be added to the dialog with the description string as its value. This can improve accessibility, as the description can be read by screen
|
||||
* readers.
|
||||
*/
|
||||
description?: string;
|
||||
/** Default button title. OK by default. */
|
||||
buttonLabel?: string;
|
||||
buttons?: DialogButton[];
|
||||
/** Result will be true if button was click, while it will be false if users close the dialog directly. */
|
||||
callback?: (result: boolean) => void;
|
||||
/** If provided, it will be invoked when the dialog is popping up. */
|
||||
onshow?(dialog?: DialogContext): void;
|
||||
/** If provided, it will be invoked when the dialog is popped up. */
|
||||
onshown?(dialog?: DialogContext): void;
|
||||
/**
|
||||
* If provided, it will be invoked when the dialog is popping down.
|
||||
* Return FALSE to don`t close the dialog. Don`t return anything by default.
|
||||
*/
|
||||
onhide?(dialog?: DialogContext): any;
|
||||
/** If provided, it will be invoked when the dialog is popped down. */
|
||||
onhidden?(dialog?: DialogContext): void;
|
||||
|
||||
/** 'Cancel' by default. */
|
||||
btnCancelLabel?: string;
|
||||
/** 'OK' by default. */
|
||||
btnOKLabel?: string;
|
||||
/** If you didn't specify it, dialog type will be used. */
|
||||
btnOKClass?: string;
|
||||
/** Additional css classes that will be added to your dialog. */
|
||||
cssClass?: string;
|
||||
/** Icon class name, for example 'glyphicon glyphicon-check'. */
|
||||
spinicon?: string;
|
||||
/**
|
||||
* When it's true, all modal stuff will be removed from the DOM tree after the dialog is popped down,
|
||||
* set it to false if you need your dialog (same instance) pups up and down again and again.
|
||||
* Default is true.
|
||||
*/
|
||||
autodestroy?: boolean;
|
||||
/**
|
||||
* Automatically convert line breaking character to <br /> if it's set to true,
|
||||
* everything keeps original if it's false.
|
||||
*/
|
||||
nl2br?: boolean;
|
||||
}
|
||||
|
||||
interface DialogInstance {
|
||||
$modal: JQuery;
|
||||
$modalBody: JQuery;
|
||||
$modalContent: JQuery;
|
||||
$modalDialog: JQuery;
|
||||
$modalHeader: JQuery;
|
||||
$modalFooter: JQuery;
|
||||
options: DialogOptions;
|
||||
opened: boolean;
|
||||
}
|
||||
|
||||
interface DialogButton {
|
||||
/** If id is set, you can use dialogInstance.getButton(id) to get the button later. */
|
||||
id?: string;
|
||||
label?: string;
|
||||
/** Hotkey char code */
|
||||
hotkey?: number;
|
||||
/** If set, the specified icon will be added to the button. */
|
||||
icon?: string;
|
||||
/** Additional css class to be added to the button. */
|
||||
cssClass?: string;
|
||||
/** Object containing data attributes to be added to the button. */
|
||||
data?: any;
|
||||
/** If it's true, after clicked the button a spinning icon appears. */
|
||||
autospin?: boolean;
|
||||
/**
|
||||
* If provided, the callback will be invoked after the button is clicked, and the dialog instance
|
||||
* will be passed to the callback function.
|
||||
*/
|
||||
action?: (dialog: DialogContext) => void;
|
||||
}
|
||||
|
||||
interface DialogButtonInstance {
|
||||
toggleEnable(enabled: boolean): void;
|
||||
/** Equals to $button.toggleEnable(true); */
|
||||
enable(): void;
|
||||
/** Equals to $button.toggleEnable(false); */
|
||||
disable(): void;
|
||||
toggleSpin(spin: boolean): void;
|
||||
/** Equals to $button.toggleSpin(true); */
|
||||
spin(): void;
|
||||
/** Equals to $button.toggleSpin(false); */
|
||||
stopSpin(): void;
|
||||
}
|
||||
|
||||
interface DialogContext {
|
||||
/** Open the dialog. Usage: dialogInstance.open() */
|
||||
open(): void;
|
||||
/** Close the dialog. Usage: dialogInstance.close() */
|
||||
close(): void;
|
||||
/**
|
||||
* Calling dialog.open() will automatically get this method called first, but if you want to do something on your dialog
|
||||
* before it's shown, you can manually call dialog.realize() before calling dialog.open().
|
||||
*/
|
||||
realize(): void;
|
||||
getTitle(): string;
|
||||
setTitle(title: string): void;
|
||||
setMessage(message: string): void;
|
||||
/** Bind data entry to dialog instance, value can be any types that javascript supports. */
|
||||
setData(dataName: string, value: any): void;
|
||||
/** Get data entry according to the given key, returns null if no data entry found. */
|
||||
getData(dataName: string): any;
|
||||
getButton(buttonId: string): JQuery;
|
||||
/**
|
||||
* When set to true (default), dialog can be closed by clicking close icon in dialog header,
|
||||
* or by clicking outside the dialog, or, ESC key is pressed.
|
||||
*/
|
||||
setClosable(closable: boolean): void;
|
||||
/** See BootstrapDialog.TYPE_xxx constants. */
|
||||
setType(dialogType: string): void;
|
||||
/** Disable all buttons in dialog footer when it's false, enable all when it's true. */
|
||||
enableButtons(enable: boolean): void;
|
||||
/** Return the raw modal, equivalent to $('<div class='modal fade'...></div>') */
|
||||
getModal(): JQuery;
|
||||
/** Return the raw modal content. */
|
||||
getModalContent(): JQuery;
|
||||
/** Return the raw modal dialog. */
|
||||
getModalDialog(): JQuery;
|
||||
/** Return the raw modal header. */
|
||||
getModalHeader(): JQuery;
|
||||
/** Return the raw modal footer. */
|
||||
getModalFooter(): JQuery;
|
||||
/** Return the raw modal body. */
|
||||
getModalBody(): JQuery;
|
||||
}
|
||||
}
|
||||
|
||||
declare const BootstrapDialog: BootstrapDialog.DialogStatic;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bootstrap3-dialog-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,8 @@
|
||||
import csv2json = require("csv2json");
|
||||
import fs = require("fs");
|
||||
|
||||
fs.createReadStream('data.csv')
|
||||
.pipe(csv2json({
|
||||
separator: ';'
|
||||
}))
|
||||
.pipe(fs.createWriteStream('data.json'));
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for csv2json 1.4
|
||||
// Project: https://github.com/julien-f/csv2json
|
||||
// Definitions by: Piotr Roszatycki <https://github.com/dex4er>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Writable } from "stream";
|
||||
|
||||
declare namespace csv2json {
|
||||
interface Options {
|
||||
dynamicTyping?: boolean;
|
||||
separator?: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare function csv2json(options?: csv2json.Options): Writable;
|
||||
|
||||
export = csv2json;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"csv2json-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -63,6 +63,8 @@ let contGen: d3Contour.Contours = d3Contour.contours();
|
||||
|
||||
// size(...) -------------------------------------------------------------------
|
||||
|
||||
const multiPolygon: d3Contour.ContourMultiPolygon = contGen.contour(values, 5);
|
||||
|
||||
// set with chainability
|
||||
contGen = contGen.size([n, m]);
|
||||
|
||||
|
||||
Vendored
+13
-2
@@ -1,10 +1,10 @@
|
||||
// Type definitions for d3-contour 1.1
|
||||
// Type definitions for d3-contour 1.2
|
||||
// Project: https://d3js.org/d3-contour/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Hugues Stefanski <https://github.com/Ledragon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.1.0
|
||||
// Last module patch version validated against: 1.2.0
|
||||
|
||||
import { MultiPolygon } from 'geojson';
|
||||
import { ThresholdArrayGenerator, ThresholdCountGenerator } from 'd3-array';
|
||||
@@ -41,6 +41,17 @@ export interface Contours {
|
||||
*/
|
||||
(values: number[]): ContourMultiPolygon[];
|
||||
|
||||
/**
|
||||
* Computes a single contour, returning a GeoJSON MultiPolygon geometry object.
|
||||
* This geometry object represents the area where the input values are greater than or equal to the given threshold value;
|
||||
* the threshold value for the geometry object is exposed as geometry.value.
|
||||
*
|
||||
* @param values Array of input values. The input values must be an array of length n×m where [n, m] is the contour generator’s size;
|
||||
* furthermore, each values[i + jn] must represent the value at the position ⟨i, j⟩.
|
||||
* @param threshold Threshold value.
|
||||
*/
|
||||
contour(values: number[], threshold: number): ContourMultiPolygon;
|
||||
|
||||
/**
|
||||
* Return the expected size of the input values grid, which defaults to [1,1].
|
||||
*/
|
||||
|
||||
@@ -67,7 +67,8 @@ let containerAccessor: (this: SVGCircleElement, d: CircleDatum, i: number, group
|
||||
containerAccessor = function(d, i, group) {
|
||||
console.log('Node Id of circle: ', d.nodeId);
|
||||
// console.log(this.a); // fails, a is not a property of SVGCircleElement
|
||||
return this.ownerSVGElement; // this-type is SVGCircleElement
|
||||
/* tslint:disable-next-line:no-unnecessary-type-assertion */
|
||||
return this.ownerSVGElement!; // this-type is SVGCircleElement
|
||||
};
|
||||
|
||||
// Test chainability
|
||||
@@ -75,7 +76,8 @@ circleDrag = circleDrag
|
||||
.container(function(d, i, group) { // container accessor function setter
|
||||
console.log('Node Id of circle: ', d.nodeId); // CircleDatum type
|
||||
// console.log(this.a); // fails, a is not a property of SVGCircleElement
|
||||
return this.ownerSVGElement; // this-type is SVGCircleElement
|
||||
/* tslint:disable-next-line:no-unnecessary-type-assertion */
|
||||
return this.ownerSVGElement!; // this-type is SVGCircleElement
|
||||
});
|
||||
|
||||
// Test chainability
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import Tracer = require('datadog-tracer');
|
||||
|
||||
const tracer = new Tracer({
|
||||
service: 'test'
|
||||
});
|
||||
|
||||
tracer.on('error', (e: any) => {
|
||||
void(0);
|
||||
});
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for datadog-tracer 0.4
|
||||
// Project: https://github.com/rochdev/datadog-tracer-js#readme
|
||||
// Definitions by: Dinesh Saravanan Kumaraswamy <https://github.com/dineshsaravanan>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
import * as opentracing from "opentracing";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
export as namespace Tracer;
|
||||
export = Tracer;
|
||||
|
||||
interface TracerOptions {
|
||||
service: string;
|
||||
hostname?: string;
|
||||
port?: number;
|
||||
protocol?: string;
|
||||
endpoint?: string;
|
||||
}
|
||||
|
||||
declare class Tracer extends opentracing.Tracer {
|
||||
constructor(tracerOptions: TracerOptions);
|
||||
|
||||
on(method: "error", cb?: (e: any) => void): void;
|
||||
addEventListener(method: "error", cb?: (e: any) => void): void;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"opentracing": "^0.14.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"datadog-tracer-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+2
-1
@@ -176,6 +176,7 @@ declare namespace dc {
|
||||
legend: IGetSet<Legend, T>;
|
||||
options(optionsObject: any): T;
|
||||
renderlet(fn: (chart: T) => any): T;
|
||||
useViewBoxResizing: IGetSet<boolean, T>;
|
||||
|
||||
on(event: "renderlet", fn: (chart: T, filter: any) => any): T;
|
||||
on(event: "pretransition", fn: (chart: T, filter: any) => any): T;
|
||||
@@ -484,4 +485,4 @@ declare namespace dc {
|
||||
boxPlot(parent: string, chartGroup?: string): BoxPlot;
|
||||
selectMenu(parent: string, chartGroup?: string): SelectMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,3 +99,13 @@ function downloadImage() {
|
||||
DWObject.HTTPDownload("www.dynamsoft.com", "img.png", () => {}, (errorCode: number, errorString: string) => {});
|
||||
}
|
||||
}
|
||||
|
||||
function loadPDF() {
|
||||
const DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
if (DWObject) {
|
||||
DWObject.Addon.PDF.SetResolution(200);
|
||||
DWObject.Addon.PDF.SetConvertMode(1);
|
||||
DWObject.IfShowFileDialog = true;
|
||||
DWObject.LoadImageEx(" ", 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import EventEmitter = require("event-emitter-es6");
|
||||
|
||||
const ee = new EventEmitter();
|
||||
const ee1 = new EventEmitter({ emitDelay: 50 });
|
||||
const ee2 = new EventEmitter({ strictMode: true });
|
||||
const ee3 = new EventEmitter({ strictMode: false, emitDelay: 5 });
|
||||
const ee4 = new EventEmitter({});
|
||||
|
||||
ee.on("test", () => {});
|
||||
ee.once("test", () => {});
|
||||
ee.off("test", () => {});
|
||||
ee.off("test");
|
||||
ee.emit("test");
|
||||
ee.emit("test", 1, 2, 3, "a", "b", "c");
|
||||
ee.emitSync("test");
|
||||
ee.emitSync("test", 1, 2, 3, "a", "b", "c");
|
||||
ee.destroy();
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// Type definitions for event-emitter-es6 1.1
|
||||
// Project: https://github.com/insane-jo/event-emitter#readme
|
||||
// Definitions by: Anton Strömkvist <https://github.com/ahstro>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Options {
|
||||
emitDelay?: number;
|
||||
strictMode?: boolean;
|
||||
}
|
||||
|
||||
type Listener = (...args: any[]) => void;
|
||||
|
||||
declare class EventEmitter {
|
||||
constructor(options?: Options);
|
||||
on(type: string, listener: Listener): void;
|
||||
once(type: string, listener: Listener): void;
|
||||
off(type: string, listener?: Listener): void;
|
||||
emit(type: string, ...eventArgs: any[]): void;
|
||||
emitSync(type: string, ...eventArgs: any[]): void;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export = EventEmitter;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"event-emitter-es6-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,24 @@
|
||||
import Bunyan = require('bunyan');
|
||||
import expressBunyan = require('express-bunyan-logger');
|
||||
|
||||
// works with no options
|
||||
const middleware = expressBunyan({});
|
||||
const middleware2 = expressBunyan.errorLogger({});
|
||||
|
||||
// format accepts both string and function
|
||||
const middleware3 = expressBunyan({
|
||||
format: ':name'
|
||||
});
|
||||
const middleware4 = expressBunyan({
|
||||
format(meta: any) {
|
||||
return 'foo';
|
||||
}
|
||||
});
|
||||
|
||||
// works when provided a bunyan logger
|
||||
const logger = Bunyan.createLogger({
|
||||
name: 'myLogger'
|
||||
});
|
||||
const middleware5 = expressBunyan({
|
||||
logger
|
||||
});
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for express-bunyan-logger 1.3
|
||||
// Project: https://github.com/villadora/express-bunyan-logger
|
||||
// Definitions by: Shrey Jain <https://github.com/shreyjain1994>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import Bunyan = require('bunyan');
|
||||
import express = require('express');
|
||||
|
||||
export = Factory;
|
||||
|
||||
declare function Factory(options?: Factory.Options): express.RequestHandler;
|
||||
|
||||
declare namespace Factory {
|
||||
type FormatFunction = (meta: any) => string;
|
||||
type IncludesFunction = (req: express.Request, res: express.Response) => any;
|
||||
type RequestIdGenFunction = (req: express.Request) => string;
|
||||
type LevelFunction = (status: number, err: Error | null, meta: any) => string;
|
||||
|
||||
interface Options {
|
||||
logger?: Bunyan;
|
||||
format?: string | FormatFunction;
|
||||
parseUA?: boolean;
|
||||
levelFn?: LevelFunction;
|
||||
includesFn?: IncludesFunction;
|
||||
excludes?: string[];
|
||||
obfuscate?: string[];
|
||||
obfuscatePlaceholder?: string;
|
||||
serializers?: { [field: string]: Bunyan.Serializer };
|
||||
immediate?: boolean;
|
||||
genReqId?: RequestIdGenFunction;
|
||||
}
|
||||
|
||||
function errorLogger(options?: Options): express.ErrorRequestHandler;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"express-bunyan-logger-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -52,17 +52,6 @@ configuration = {
|
||||
]
|
||||
};
|
||||
|
||||
configuration = {
|
||||
// ...
|
||||
plugins: [
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: "commons",
|
||||
filename: "commons.js",
|
||||
}),
|
||||
new ExtractTextPlugin("[name].css")
|
||||
]
|
||||
};
|
||||
|
||||
configuration = {
|
||||
// ...
|
||||
module: {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Options } from "ez-plus";
|
||||
|
||||
$(document).ready(() => {
|
||||
// basic usage
|
||||
$('#image').ezPlus();
|
||||
|
||||
// with options
|
||||
const options: Options = {
|
||||
zoomLens: true,
|
||||
zoomType: 'lens',
|
||||
cursor: 'crosshair'
|
||||
};
|
||||
$('#image').ezPlus(options);
|
||||
});
|
||||
Vendored
+214
@@ -0,0 +1,214 @@
|
||||
// Type definitions for jQuery ElevateZoom Plus Plugin 1.2
|
||||
// Project: https://github.com/igorlino/elevatezoom-plus
|
||||
// Definitions by: Anderson Friaça <https://github.com/AndersonFriaca>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* Activate responsivenes
|
||||
*/
|
||||
responsive?: boolean;
|
||||
|
||||
/**
|
||||
* Activate zoom on mouse scroll
|
||||
*/
|
||||
scrollZoom?: boolean;
|
||||
|
||||
/**
|
||||
* Activate simultaneous crossfade of images on gallery change
|
||||
*/
|
||||
imageCrossfade?: boolean;
|
||||
|
||||
/**
|
||||
* Activate spinner icon or url
|
||||
*/
|
||||
loadingIcon?: boolean | string;
|
||||
|
||||
/**
|
||||
* Activate easing
|
||||
*/
|
||||
easing?: boolean;
|
||||
easingType?: string;
|
||||
easingDuration?: number;
|
||||
|
||||
/**
|
||||
* Used when zoomType set to lens
|
||||
*/
|
||||
lensSize?: number;
|
||||
|
||||
/**
|
||||
* Width of the zoomWindow
|
||||
*/
|
||||
zoomWindowWidth?: number;
|
||||
|
||||
/**
|
||||
* Height of the zoomWindow
|
||||
*/
|
||||
zoomWindowHeight?: number;
|
||||
|
||||
/**
|
||||
* x-axis offset of the zoom window
|
||||
*/
|
||||
zoomWindowOffsetX?: number;
|
||||
|
||||
/**
|
||||
* y-axis offset of the zoom window
|
||||
*/
|
||||
zoomWindowOffsetY?: number;
|
||||
zoomWindowPosition?: number | string;
|
||||
|
||||
/**
|
||||
* Speed of Lens fadeIn
|
||||
*/
|
||||
lensFadeIn?: number;
|
||||
|
||||
/**
|
||||
* Speed of Lens fadeOut
|
||||
*/
|
||||
lensFadeOut?: number;
|
||||
|
||||
/**
|
||||
* Speed of Window fadeIn
|
||||
*/
|
||||
zoomWindowFadeIn?: number;
|
||||
|
||||
/**
|
||||
* Speed of Window fadeOut
|
||||
*/
|
||||
zoomWindowFadeOut?: number;
|
||||
|
||||
/**
|
||||
* Speed of Tint fadeIn
|
||||
*/
|
||||
zoomTintFadeIn?: number;
|
||||
|
||||
/**
|
||||
* Speed of Tint fadeOut
|
||||
*/
|
||||
zoomTintFadeOut?: number;
|
||||
|
||||
/**
|
||||
* Border Size of the ZoomBox
|
||||
*/
|
||||
borderSize?: number;
|
||||
|
||||
/**
|
||||
* Enable Lens
|
||||
*/
|
||||
zoomLens?: boolean;
|
||||
|
||||
/**
|
||||
* Border Colour
|
||||
*/
|
||||
borderColour?: string;
|
||||
|
||||
/**
|
||||
* Width in pixels of the lens border
|
||||
*/
|
||||
lensBorder?: number;
|
||||
|
||||
/**
|
||||
* Type of lens
|
||||
*/
|
||||
lensShape?: 'square' | 'round';
|
||||
|
||||
/**
|
||||
* Type of zoom
|
||||
*/
|
||||
zoomType?: 'lens' | 'window' | 'inner';
|
||||
containLensZoom?: boolean;
|
||||
|
||||
/**
|
||||
* Colour of the lens background
|
||||
*/
|
||||
lensColour?: string;
|
||||
|
||||
/**
|
||||
* Opacity of lens
|
||||
*/
|
||||
lensOpacity?: number;
|
||||
lenszoom?: boolean;
|
||||
|
||||
/**
|
||||
* Enable a tint overlay
|
||||
*/
|
||||
tint?: boolean;
|
||||
|
||||
/**
|
||||
* Colour of the tin
|
||||
*/
|
||||
tintColour?: string;
|
||||
|
||||
/**
|
||||
* Opacity of the tint
|
||||
*/
|
||||
tintOpacity?: number;
|
||||
|
||||
/**
|
||||
* This assigns a set of gallery links to the zoom image
|
||||
*/
|
||||
gallery?: string;
|
||||
|
||||
/**
|
||||
* Type of cursor
|
||||
*/
|
||||
cursor?: 'default' | 'cursor' | 'crosshair';
|
||||
container?: string;
|
||||
|
||||
/**
|
||||
* Attribute to plugin use for zoom
|
||||
*/
|
||||
attrImageZoomSrc?: string;
|
||||
|
||||
/**
|
||||
* In pixels the dimensions you want to constrain on
|
||||
*/
|
||||
constrainSize?: number | false;
|
||||
constrainType?: 'width' | 'height';
|
||||
debug?: boolean;
|
||||
easingAmount?: number;
|
||||
enabled?: boolean;
|
||||
galleryActiveClass?: string;
|
||||
gallerySelector?: string | false;
|
||||
galleryItem?: string;
|
||||
galleryEvent?: string;
|
||||
mantainZoomAspectRatio?: boolean;
|
||||
maxZoomLevel?: number | false;
|
||||
minZoomLevel?: number;
|
||||
preloading?: 0 | 1;
|
||||
respond?: any[];
|
||||
|
||||
/**
|
||||
* Steps of the scrollzoom
|
||||
*/
|
||||
scrollZoomIncrement?: number;
|
||||
touchEnabled?: boolean;
|
||||
zoomActivation?: 'click' | 'hover';
|
||||
|
||||
/**
|
||||
* Zoom container parent selector
|
||||
*/
|
||||
zoomContainerAppendTo?: string;
|
||||
|
||||
/**
|
||||
* Identifier for the zoom container
|
||||
*/
|
||||
zoomId?: number;
|
||||
|
||||
/**
|
||||
* Zoom level of image
|
||||
*/
|
||||
zoomLevel?: number;
|
||||
zIndex?: number;
|
||||
}
|
||||
declare global {
|
||||
interface JQuery {
|
||||
/**
|
||||
* Initialize ElevateZoom Plugin
|
||||
*/
|
||||
ezPlus(options?: Options): JQuery;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ez-plus-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"extends": "dtslint/dt.json"}
|
||||
@@ -2,6 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Abraao Alves <https://github.com/AbraaoAlves>, Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export default function feathersAuthClient(config?: FeathersAuthClientConfig): () => void;
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Application } from '@feathersjs/feathers';
|
||||
import { Request } from 'express';
|
||||
@@ -45,7 +45,7 @@ export interface FeathersAuthenticationJWTOptions {
|
||||
}
|
||||
|
||||
export class JWTVerifier {
|
||||
constructor(app: Application<any>, options: any); // the class constructor
|
||||
constructor(app: Application, options: any); // the class constructor
|
||||
|
||||
verify(req: Request, payload: any, done: (error: any, user?: any, info?: any) => void): void;
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import {
|
||||
Application,
|
||||
@@ -57,7 +57,7 @@ export interface FeathersAuthenticationLocalOptions {
|
||||
}
|
||||
|
||||
export class LocalVerifier {
|
||||
constructor(app: Application<any>, options: any);
|
||||
constructor(app: Application, options: any);
|
||||
|
||||
_comparePassword<T>(entity: T, password: string): Promise<T>; // compares password using bcrypt
|
||||
_normalizeResult<T>(results: T[] | Paginated<T>): Promise<T>; // normalizes result from service to account for pagination
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import {
|
||||
Application,
|
||||
@@ -60,7 +60,7 @@ export interface FeathersAuthenticationOAuth1Options {
|
||||
}
|
||||
|
||||
export class OAuth1Verifier {
|
||||
constructor(app: Application<any>, options: any);
|
||||
constructor(app: Application, options: any);
|
||||
|
||||
_updateEntity(entity: any, data: { profile: any, accessToken: string, refreshToken: string }): Promise<any>; // updates an existing entity
|
||||
_createEntity(data: { profile: any, accessToken: string, refreshToken: string }): Promise<any>; // creates an entity if they didn't exist already
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import {
|
||||
Application,
|
||||
@@ -62,7 +62,7 @@ export interface FeathersAuthenticationOAuth2Options {
|
||||
}
|
||||
|
||||
export class OAuth2Verifier {
|
||||
constructor(app: Application<any>, options: any)
|
||||
constructor(app: Application, options: any)
|
||||
|
||||
_updateEntity(entity: any, data: { profile: any, accessToken: string, refreshToken: string }): Promise<any>; // updates an existing entity
|
||||
_createEntity(data: { profile: any, accessToken: string, refreshToken: string }): Promise<any>; // creates an entity if they didn't exist already
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Application } from '@feathersjs/feathers';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Application as FeathersApplication } from '@feathersjs/feathers';
|
||||
import * as express from 'express';
|
||||
|
||||
+1
@@ -2,6 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// primus removed its typings from the repo https://github.com/primus/primus/pull/623, as of 01/2018 there are none on DT
|
||||
export default function feathersPrimusClient(socket: any, options?: FeathersPrimusClientOptions): () => void;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Project: http://feathersjs.com/
|
||||
// Definitions by: Jan Lohage <https://github.com/j2L4e>
|
||||
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="socket.io-client" />
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ fetchMock.patch("http://test.com", 200);
|
||||
fetchMock.patchOnce("http://test.com", 200);
|
||||
|
||||
fetchMock.get("http://test.com", 200, {method: "GET"});
|
||||
fetchMock.get("http://test.com", 200, {method: "GET", overwriteRoutes: true});
|
||||
fetchMock.post("http://test.com", 200, {method: "POST"});
|
||||
fetchMock.put("http://test.com", 200, {method: "PUT"});
|
||||
fetchMock.delete("http://test.com", 200, {method: "DELETE"});
|
||||
|
||||
Vendored
+7
@@ -5,6 +5,7 @@
|
||||
// Risto Keravuori <https://github.com/merrywhether>
|
||||
// Chris Sinclair <https://github.com/chrissinclair>
|
||||
// Matt Tennison <https://github.com/matttennison>
|
||||
// Quentin Bouygues <https://github.com/quentinbouygues>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -120,6 +121,12 @@ declare namespace fetchMock {
|
||||
* as specified above
|
||||
*/
|
||||
matcher?: MockMatcher;
|
||||
/**
|
||||
* This option allows for existing routes in a mock to be overwritten.
|
||||
* It’s also possible to define multiple routes with ‘the same’ matcher.
|
||||
* Default behaviour is to error
|
||||
*/
|
||||
overwriteRoutes?: boolean;
|
||||
/**
|
||||
* as specified above
|
||||
*/
|
||||
|
||||
@@ -8,3 +8,7 @@ browser.manifest; // $ExpectError
|
||||
browser._manifest; // $ExpectType typeof _manifest
|
||||
browser._manifest.WebExtensionLangpackManifest; // $ExpectError
|
||||
browser._manifest.NativeManifest; // $ExpectError
|
||||
|
||||
// browser.runtime
|
||||
const port = browser.runtime.connect();
|
||||
port.postMessage(); // $ExpectError
|
||||
|
||||
+2
-2
@@ -2296,10 +2296,10 @@ declare namespace browser.runtime {
|
||||
/** An object which allows two way communication with other pages. */
|
||||
interface Port {
|
||||
name: string;
|
||||
disconnect: () => void;
|
||||
disconnect(): void;
|
||||
onDisconnect: events.Event;
|
||||
onMessage: events.Event;
|
||||
postMessage: () => void;
|
||||
postMessage(message: object): void;
|
||||
/** This property will **only** be present on ports passed to onConnect/onConnectExternal listeners. */
|
||||
sender?: MessageSender;
|
||||
}
|
||||
|
||||
Vendored
+18
-7
@@ -18,16 +18,27 @@ export import Joi = require("joi");
|
||||
|
||||
// #region Frisby FrisbySpec Methods
|
||||
// Reference file: https://github.com/vlucas/frisby/blob/master/src/frisby/spec.js
|
||||
|
||||
// **************************************CHANGE LOG**************************************
|
||||
// C.E.W. This is an attempt to create some sort of changelog for these types.
|
||||
// If you make any changes, please try and note those changes in this section.
|
||||
// If this section gets too long we can always trim it.
|
||||
// ## 2018-03-05
|
||||
// ### Changed
|
||||
// - Update _Frisbyspec.get_, _Frisbyspec.post_, _Frisbyspec.put_, _Frisbyspec.del_, _Frisbyspec.patch_, _Frisbyspec.fetch_ to allow _params_ to be optional.
|
||||
// - Update _FrisbySpec.then_ to allow _onRejected_ to be optional.
|
||||
// **************************************CHANGE LOG**************************************
|
||||
|
||||
export class FrisbySpec {
|
||||
constructor(...args: any[]);
|
||||
catch(onRejected?: (error: Error) => void): FrisbySpec;
|
||||
del(url: string, params: {}): FrisbySpec;
|
||||
del(url: string, params?: {}): FrisbySpec;
|
||||
done(doneFn: (...args: any[]) => void): FrisbySpec;
|
||||
expect(expectName: string, ...args: any[]): FrisbySpec;
|
||||
expectNot(expectName: string): FrisbySpec;
|
||||
fetch(url: string, params: {}, options?: {}): FrisbySpec;
|
||||
fetch(url: string, params?: {}, options?: {}): FrisbySpec;
|
||||
fromJSON(json: {}): FrisbySpec;
|
||||
get(url: string, params: {}): FrisbySpec;
|
||||
get(url: string, params?: {}): FrisbySpec;
|
||||
getBaseUrl(): string | boolean;
|
||||
inspectBody(): FrisbySpec;
|
||||
inspectHeaders(): FrisbySpec;
|
||||
@@ -37,12 +48,12 @@ export class FrisbySpec {
|
||||
inspectRequestHeaders(): FrisbySpec;
|
||||
inspectResponse(): FrisbySpec;
|
||||
inspectStatus(): FrisbySpec;
|
||||
patch(url: string, params: {}): FrisbySpec;
|
||||
post(url: string, params: {}): FrisbySpec;
|
||||
patch(url: string, params?: {}): FrisbySpec;
|
||||
post(url: string, params?: {}): FrisbySpec;
|
||||
promise(): Promise<nodeFetch.Response>;
|
||||
put(url: string, params: {}): FrisbySpec;
|
||||
put(url: string, params?: {}): FrisbySpec;
|
||||
setup(opts: {}, replace: boolean): FrisbySpec;
|
||||
then(onFulfilled: {} | ((...args: any[]) => void), onRejected: (...args: any[]) => void): FrisbySpec;
|
||||
then(onFulfilled: {} | ((...args: any[]) => void), onRejected?: (...args: any[]) => void): FrisbySpec;
|
||||
timeout(timeout: number): number;
|
||||
use(fn: (...args: any[]) => void): FrisbySpec;
|
||||
static addExpectHandler(expectName: string, expectFn: (...args: any[]) => any): void;
|
||||
|
||||
@@ -231,7 +231,7 @@ interface TestProperty {
|
||||
}
|
||||
|
||||
const testProps: TestProperty = {
|
||||
foo: "bar",
|
||||
foo: "baz",
|
||||
hello: "world"
|
||||
};
|
||||
|
||||
@@ -248,3 +248,77 @@ const typedPropertiesFeatureCollection: FeatureCollection<Point> = {
|
||||
type: "FeatureCollection",
|
||||
features: [typedPropertiesFeature]
|
||||
};
|
||||
|
||||
// Strict Null Checks
|
||||
|
||||
let isNull: null;
|
||||
let isPoint: Point;
|
||||
let isPointOrNull: Point | null;
|
||||
let isProperty: TestProperty;
|
||||
let isPropertyOrNull: TestProperty | null;
|
||||
|
||||
const featureAllNull: Feature<null, null> = {
|
||||
type: "Feature",
|
||||
properties: null,
|
||||
geometry: null
|
||||
};
|
||||
|
||||
const featurePropertyNull: Feature<Point, null> = {
|
||||
type: "Feature",
|
||||
properties: null,
|
||||
geometry: point
|
||||
};
|
||||
|
||||
const featureGeometryNull: Feature<null, TestProperty> = {
|
||||
type: "Feature",
|
||||
properties: testProps,
|
||||
geometry: null
|
||||
};
|
||||
|
||||
const featureNoNull: Feature<Point, TestProperty> = {
|
||||
type: "Feature",
|
||||
properties: testProps,
|
||||
geometry: point
|
||||
};
|
||||
|
||||
const collectionAllNull: FeatureCollection<null, null> = {
|
||||
type: "FeatureCollection",
|
||||
features: [featureAllNull],
|
||||
};
|
||||
|
||||
const collectionMaybeNull: FeatureCollection<Point | null, TestProperty | null> = {
|
||||
type: "FeatureCollection",
|
||||
features: [featureAllNull, featurePropertyNull, featureGeometryNull, featureNoNull],
|
||||
};
|
||||
|
||||
const collectionPropertyMaybeNull: FeatureCollection<Point, TestProperty | null> = {
|
||||
type: "FeatureCollection",
|
||||
features: [featurePropertyNull, featureNoNull],
|
||||
};
|
||||
|
||||
const collectionGeometryMaybeNull: FeatureCollection<Point | null, TestProperty> = {
|
||||
type: "FeatureCollection",
|
||||
features: [featureGeometryNull, featureNoNull],
|
||||
};
|
||||
|
||||
const collectionNoNull: FeatureCollection<Point, TestProperty> = {
|
||||
type: "FeatureCollection",
|
||||
features: [featureNoNull],
|
||||
};
|
||||
|
||||
isNull = featureAllNull.geometry;
|
||||
isPoint = featurePropertyNull.geometry;
|
||||
isNull = featureAllNull.properties;
|
||||
isProperty = featureGeometryNull.properties;
|
||||
|
||||
isNull = collectionAllNull.features[0].geometry;
|
||||
isPointOrNull = collectionMaybeNull.features[0].geometry;
|
||||
isPoint = collectionPropertyMaybeNull.features[0].geometry;
|
||||
isPointOrNull = collectionGeometryMaybeNull.features[0].geometry;
|
||||
isPoint = collectionNoNull.features[0].geometry;
|
||||
|
||||
isNull = collectionAllNull.features[0].properties;
|
||||
isPropertyOrNull = collectionMaybeNull.features[0].properties;
|
||||
isPropertyOrNull = collectionPropertyMaybeNull.features[0].properties;
|
||||
isProperty = collectionGeometryMaybeNull.features[0].properties;
|
||||
isProperty = collectionNoNull.features[0].properties;
|
||||
|
||||
Vendored
+4
-4
@@ -139,12 +139,12 @@ export type GeoJsonProperties = { [name: string]: any; } | null;
|
||||
* A feature object which contains a geometry and associated properties.
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.2
|
||||
*/
|
||||
export interface Feature<G extends GeometryObject, P = GeoJsonProperties> extends GeoJsonObject {
|
||||
export interface Feature<G extends GeometryObject | null, P = GeoJsonProperties> extends GeoJsonObject {
|
||||
type: "Feature";
|
||||
/**
|
||||
* The feature's geometry
|
||||
*/
|
||||
geometry: G | null;
|
||||
geometry: G;
|
||||
/**
|
||||
* A value that uniquely identifies this feature in a
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.2.
|
||||
@@ -153,14 +153,14 @@ export interface Feature<G extends GeometryObject, P = GeoJsonProperties> extend
|
||||
/**
|
||||
* Properties associated with this feature.
|
||||
*/
|
||||
properties: P | null;
|
||||
properties: P;
|
||||
}
|
||||
|
||||
/**
|
||||
* A collection of feature objects.
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.3
|
||||
*/
|
||||
export interface FeatureCollection<G extends GeometryObject, P = GeoJsonProperties> extends GeoJsonObject {
|
||||
export interface FeatureCollection<G extends GeometryObject | null, P = GeoJsonProperties> extends GeoJsonObject {
|
||||
type: "FeatureCollection";
|
||||
features: Array<Feature<G, P>>;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
|
||||
Vendored
+9
-4
@@ -1,4 +1,4 @@
|
||||
// Type definitions for grid-styled 3.0
|
||||
// Type definitions for grid-styled 3.2
|
||||
// Project: https://github.com/jxnblk/grid-styled
|
||||
// Definitions by: Anton Vasin <https://github.com/antonvasin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -44,9 +44,14 @@ export interface BoxProps
|
||||
}
|
||||
|
||||
export interface FlexProps extends BoxProps {
|
||||
align: ResponsiveProp | boolean;
|
||||
justify: ResponsiveProp | boolean;
|
||||
flexDirection: ResponsiveProp | boolean;
|
||||
alignItems: ResponsiveProp;
|
||||
justifyContent: ResponsiveProp;
|
||||
flexDirection: ResponsiveProp;
|
||||
flexWrap: ResponsiveProp;
|
||||
|
||||
// legacy aliases https://github.com/jxnblk/styled-system/releases/tag/v2.0.0
|
||||
justify: ResponsiveProp;
|
||||
align: ResponsiveProp;
|
||||
wrap: ResponsiveProp | boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import Hapi = require('hapi');
|
||||
import hapiAuthJwt2 = require('hapi-auth-jwt2');
|
||||
import { Server } from 'hapi';
|
||||
import * as hapiAuthJwt2 from 'hapi-auth-jwt2';
|
||||
|
||||
const server = new Hapi.Server();
|
||||
server.connection({port: 8000});
|
||||
const server = new Server({port: 8000});
|
||||
|
||||
interface User {
|
||||
id: number;
|
||||
@@ -20,19 +19,28 @@ const users: Users = {
|
||||
}
|
||||
};
|
||||
|
||||
function validate(decoded: User, request: Hapi.Request, callback: hapiAuthJwt2.ValidateCallback) {
|
||||
callback(null, !!users[decoded.id]);
|
||||
}
|
||||
|
||||
server.register(hapiAuthJwt2, err => {
|
||||
const options: hapiAuthJwt2.Options = {
|
||||
key: 'NeverShareYourSecret',
|
||||
validateFunc: validate,
|
||||
verifyOptions: {
|
||||
algorithms: ['HS256']
|
||||
server.register({
|
||||
plugin: hapiAuthJwt2,
|
||||
options: {
|
||||
async verify() {
|
||||
return {
|
||||
isValid: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
server.auth.strategy('jwt', 'jwt', options);
|
||||
})
|
||||
.then(() => {
|
||||
const opts: hapiAuthJwt2.Options = {
|
||||
key: 'NeverShareYourSecret',
|
||||
async validate(decoded: { id: number }, request) {
|
||||
return {
|
||||
isValid: !!users[decoded.id],
|
||||
};
|
||||
},
|
||||
verifyOptions: {
|
||||
algorithms: ['HS256'],
|
||||
issuer: 'test',
|
||||
}
|
||||
};
|
||||
server.auth.strategy('jwt', 'jwt', opts);
|
||||
});
|
||||
|
||||
server.start();
|
||||
|
||||
Vendored
+58
-54
@@ -1,39 +1,43 @@
|
||||
// Type definitions for hapi-auth-jwt2 7.0
|
||||
// Type definitions for hapi-auth-jwt2 8.0
|
||||
// Project: https://github.com/dwyl/hapi-auth-jwt2
|
||||
// Definitions by: Warren Seymour <https://github.com/warrenseymour>
|
||||
// Simon Schick <https://github.com/SimonSchick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
import { Request, Response, PluginFunction } from 'hapi';
|
||||
import { Request, ResponseObject, Plugin, ResponseToolkit } from 'hapi';
|
||||
import { VerifyOptions } from 'jsonwebtoken';
|
||||
|
||||
declare module 'hapi' {
|
||||
interface ServerAuth {
|
||||
strategy(name: string, scheme: 'jwt', options?: hapiAuthJwt2.Options): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace hapiAuthJwt2 {
|
||||
/**
|
||||
* A key lookup function
|
||||
*
|
||||
* @param decoded the *decoded* but *unverified* JWT received from client
|
||||
* @param callback the key lookup callback
|
||||
*/
|
||||
type KeyLookup = (decoded: any, callback: KeyLookupCallback) => void;
|
||||
interface ExtraInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when key lookup function has completed
|
||||
*
|
||||
* @param err an internal error
|
||||
* @param key the secret key
|
||||
* @param extraInfo any additional information that you would like
|
||||
* to use in `validateFunc` which can be accessed via
|
||||
* `request.plugins['hapi-auth-jwt2'].extraInfo`
|
||||
*/
|
||||
type KeyLookupCallback = (err: any, key: string, extraInfo?: any) => void;
|
||||
|
||||
/**
|
||||
* Called when Validation has completed
|
||||
*
|
||||
* @param err an internal error
|
||||
* @param valid `true` if the JWT was valid, otherwise `false`
|
||||
* @param credentials alternative credentials to be set instead of `decoded`
|
||||
*/
|
||||
type ValidateCallback = (err: any, valid: boolean, credentials?: any) => void;
|
||||
interface ErrorContext {
|
||||
/**
|
||||
* Boom method to call (eg. unauthorized)
|
||||
*/
|
||||
errorType: string;
|
||||
/**
|
||||
* message passed into the Boom method call
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* schema passed into the Boom method call
|
||||
*/
|
||||
schema: string;
|
||||
/**
|
||||
* attributes passed into the Boom method call
|
||||
*/
|
||||
attributes?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Options passed to `hapi.auth.strategy` when this plugin is used
|
||||
@@ -42,41 +46,24 @@ declare namespace hapiAuthJwt2 {
|
||||
/**
|
||||
* The secret key used to check the signature of the token *or* a *key lookup function*
|
||||
*/
|
||||
key?: string | KeyLookup;
|
||||
key?: string | string[] | Promise<{ isValid: boolean; key: string; extraInfo?: ExtraInfo }>;
|
||||
|
||||
/**
|
||||
* The function which is run once the Token has been decoded
|
||||
*
|
||||
* @param decoded the *decoded* and *verified* JWT received from the client in *request.headers.authorization*
|
||||
* @param request the original *request* received from the client
|
||||
* @param callback the validation callback
|
||||
*/
|
||||
validateFunc(decoded: {}, request: Request, callback: ValidateCallback): void;
|
||||
validate(decoded: {}, request: Request, tk: ResponseToolkit): Promise<{
|
||||
isValid: boolean;
|
||||
credentials?: any;
|
||||
response?: ResponseObject
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Settings to define how tokens are verified by the jsonwebtoken library
|
||||
*/
|
||||
verifyOptions?: {
|
||||
/**
|
||||
* Ignore expired tokens
|
||||
*/
|
||||
ignoreExpiration?: boolean;
|
||||
|
||||
/**
|
||||
* Do not enforce token audience
|
||||
*/
|
||||
audience?: boolean;
|
||||
|
||||
/**
|
||||
* Do not require the issuer to be valid
|
||||
*/
|
||||
issuer?: boolean;
|
||||
|
||||
/**
|
||||
* List of allowed algorithms
|
||||
*/
|
||||
algorithms?: string[];
|
||||
};
|
||||
verifyOptions?: VerifyOptions;
|
||||
|
||||
/**
|
||||
* function called to decorate the response with authentication headers
|
||||
@@ -85,7 +72,14 @@ declare namespace hapiAuthJwt2 {
|
||||
* @param request the Request object
|
||||
* @param reply is called if an error occurred
|
||||
*/
|
||||
responseFunc?(request: Request, reply: (err: any, response: Response) => void): void;
|
||||
responseFunc?(request: Request, reply: (err: any, response: ResponseObject) => void): void;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ctx called when an error has been raised.
|
||||
* It provides an extension point to allow the host the ability to customise the error messages returned.
|
||||
*/
|
||||
errorFunc?(ctx: ErrorContext): ErrorContext;
|
||||
|
||||
/**
|
||||
* If you prefer to pass your token via url, simply add a token url
|
||||
@@ -125,8 +119,18 @@ declare namespace hapiAuthJwt2 {
|
||||
*/
|
||||
complete?: boolean;
|
||||
}
|
||||
|
||||
interface RegisterOptions {
|
||||
/**
|
||||
* function which is run once the Token has been decoded (instead of a validate) with signature async function(decoded, request) where:
|
||||
*/
|
||||
verify?(decoded: any, request: Request): Promise<{
|
||||
isValid: boolean;
|
||||
credentials?: any;
|
||||
}>;
|
||||
}
|
||||
}
|
||||
|
||||
declare var hapiAuthJwt2: PluginFunction<{}>;
|
||||
declare const hapiAuthJwt2: Plugin<hapiAuthJwt2.RegisterOptions>;
|
||||
|
||||
export = hapiAuthJwt2;
|
||||
|
||||
@@ -13,20 +13,6 @@
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"paths": {
|
||||
"boom": [
|
||||
"boom/v4"
|
||||
],
|
||||
"catbox": [
|
||||
"catbox/v7"
|
||||
],
|
||||
"hapi": [
|
||||
"hapi/v16"
|
||||
],
|
||||
"inert": [
|
||||
"inert/v4"
|
||||
]
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-empty-interface": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import Hapi = require('hapi');
|
||||
import hapiAuthJwt2 = require('hapi-auth-jwt2');
|
||||
|
||||
const server = new Hapi.Server();
|
||||
server.connection({port: 8000});
|
||||
|
||||
interface User {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface Users {
|
||||
[id: number]: User;
|
||||
}
|
||||
|
||||
const users: Users = {
|
||||
1: {
|
||||
id: 1,
|
||||
name: 'Test User'
|
||||
}
|
||||
};
|
||||
|
||||
function validate(decoded: User, request: Hapi.Request, callback: hapiAuthJwt2.ValidateCallback) {
|
||||
callback(null, !!users[decoded.id]);
|
||||
}
|
||||
|
||||
server.register(hapiAuthJwt2, err => {
|
||||
const options: hapiAuthJwt2.Options = {
|
||||
key: 'NeverShareYourSecret',
|
||||
validateFunc: validate,
|
||||
verifyOptions: {
|
||||
algorithms: ['HS256']
|
||||
}
|
||||
};
|
||||
server.auth.strategy('jwt', 'jwt', options);
|
||||
});
|
||||
|
||||
server.start();
|
||||
Vendored
+132
@@ -0,0 +1,132 @@
|
||||
// Type definitions for hapi-auth-jwt2 7.0
|
||||
// Project: https://github.com/dwyl/hapi-auth-jwt2
|
||||
// Definitions by: Warren Seymour <https://github.com/warrenseymour>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
import { Request, Response, PluginFunction } from 'hapi';
|
||||
|
||||
declare namespace hapiAuthJwt2 {
|
||||
/**
|
||||
* A key lookup function
|
||||
*
|
||||
* @param decoded the *decoded* but *unverified* JWT received from client
|
||||
* @param callback the key lookup callback
|
||||
*/
|
||||
type KeyLookup = (decoded: any, callback: KeyLookupCallback) => void;
|
||||
|
||||
/**
|
||||
* Called when key lookup function has completed
|
||||
*
|
||||
* @param err an internal error
|
||||
* @param key the secret key
|
||||
* @param extraInfo any additional information that you would like
|
||||
* to use in `validateFunc` which can be accessed via
|
||||
* `request.plugins['hapi-auth-jwt2'].extraInfo`
|
||||
*/
|
||||
type KeyLookupCallback = (err: any, key: string, extraInfo?: any) => void;
|
||||
|
||||
/**
|
||||
* Called when Validation has completed
|
||||
*
|
||||
* @param err an internal error
|
||||
* @param valid `true` if the JWT was valid, otherwise `false`
|
||||
* @param credentials alternative credentials to be set instead of `decoded`
|
||||
*/
|
||||
type ValidateCallback = (err: any, valid: boolean, credentials?: any) => void;
|
||||
|
||||
/**
|
||||
* Options passed to `hapi.auth.strategy` when this plugin is used
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* The secret key used to check the signature of the token *or* a *key lookup function*
|
||||
*/
|
||||
key?: string | KeyLookup;
|
||||
|
||||
/**
|
||||
* The function which is run once the Token has been decoded
|
||||
*
|
||||
* @param decoded the *decoded* and *verified* JWT received from the client in *request.headers.authorization*
|
||||
* @param request the original *request* received from the client
|
||||
* @param callback the validation callback
|
||||
*/
|
||||
validateFunc(decoded: {}, request: Request, callback: ValidateCallback): void;
|
||||
|
||||
/**
|
||||
* Settings to define how tokens are verified by the jsonwebtoken library
|
||||
*/
|
||||
verifyOptions?: {
|
||||
/**
|
||||
* Ignore expired tokens
|
||||
*/
|
||||
ignoreExpiration?: boolean;
|
||||
|
||||
/**
|
||||
* Do not enforce token audience
|
||||
*/
|
||||
audience?: boolean;
|
||||
|
||||
/**
|
||||
* Do not require the issuer to be valid
|
||||
*/
|
||||
issuer?: boolean;
|
||||
|
||||
/**
|
||||
* List of allowed algorithms
|
||||
*/
|
||||
algorithms?: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
* function called to decorate the response with authentication headers
|
||||
* before the response headers or payload is written
|
||||
*
|
||||
* @param request the Request object
|
||||
* @param reply is called if an error occurred
|
||||
*/
|
||||
responseFunc?(request: Request, reply: (err: any, response: Response) => void): void;
|
||||
|
||||
/**
|
||||
* If you prefer to pass your token via url, simply add a token url
|
||||
* parameter to your request or use a custom parameter by setting `urlKey.
|
||||
* To disable the url parameter set urlKey to `false` or ''.
|
||||
* @default 'token'
|
||||
*/
|
||||
urlKey?: string | boolean;
|
||||
|
||||
/**
|
||||
* If you prefer to set your own cookie key or your project has a cookie
|
||||
* called 'token' for another purpose, you can set a custom key for your
|
||||
* cookie by setting `options.cookieKey='yourkeyhere'`. To disable cookies
|
||||
* set cookieKey to `false` or ''.
|
||||
* @default 'token'
|
||||
*/
|
||||
cookieKey?: string | boolean;
|
||||
|
||||
/**
|
||||
* If you want to set a custom key for your header token use the
|
||||
* `headerKey` option. To disable header token set headerKey to `false` or
|
||||
* ''.
|
||||
* @default 'authorization'
|
||||
*/
|
||||
headerKey?: string | boolean;
|
||||
|
||||
/**
|
||||
* Allow custom token type, e.g. `Authorization: <tokenType> 12345678`
|
||||
*/
|
||||
tokenType?: string;
|
||||
|
||||
/**
|
||||
* Set to `true` to receive the complete token (`decoded.header`,
|
||||
* `decoded.payload` and `decoded.signature`) as decoded argument to key
|
||||
* lookup and `verifyFunc` callbacks (*not `validateFunc`*)
|
||||
* @default false
|
||||
*/
|
||||
complete?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare var hapiAuthJwt2: PluginFunction<{}>;
|
||||
|
||||
export = hapiAuthJwt2;
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"paths": {
|
||||
"hapi-auth-jwt2": [
|
||||
"hapi-auth-jwt2/v7"
|
||||
],
|
||||
"boom": [
|
||||
"boom/v4"
|
||||
],
|
||||
"catbox": [
|
||||
"catbox/v7"
|
||||
],
|
||||
"hapi": [
|
||||
"hapi/v16"
|
||||
],
|
||||
"inert": [
|
||||
"inert/v4"
|
||||
]
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hapi-auth-jwt2-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+2
-2
@@ -457,7 +457,7 @@ export interface Request extends Podium {
|
||||
* The response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to
|
||||
* override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects).
|
||||
*/
|
||||
response: ResponseObject | Boom.Boom | null;
|
||||
response: ResponseObject | Boom | null;
|
||||
|
||||
/**
|
||||
* Same as pre but represented as the response object created by the pre method.
|
||||
@@ -3873,7 +3873,7 @@ export namespace Lifecycle {
|
||||
type ReturnValueTypes =
|
||||
(null | string | number | boolean) |
|
||||
(Buffer) |
|
||||
(Error | Boom.Boom) |
|
||||
(Error | Boom) |
|
||||
(stream.Stream) |
|
||||
(object | object[]) |
|
||||
symbol |
|
||||
|
||||
@@ -86,6 +86,21 @@ let polyline = new H.map.Polyline(new H.geo.Strip());
|
||||
let clipArr: Array<Array<number>>;
|
||||
clipArr = polyline.clip(new H.geo.Rect(5, 5, 5, 5));
|
||||
|
||||
let lineString = new H.geo.LineString();
|
||||
lineString.pushPoint({ lat: 53.3477, lng: -6.2597 });
|
||||
lineString.pushPoint({ lat: 51.5008, lng: -0.1224 });
|
||||
lineString.pushPoint({ lat: 48.8567, lng: 2.3508 });
|
||||
lineString.pushPoint({ lat: 52.5166, lng: 13.3833 });
|
||||
lineString.eachLatLngAlt((lat: number, lng: number, alt: number, i: number) => {
|
||||
console.log(lat, lng, alt, i);
|
||||
});
|
||||
lineString.getBounds();
|
||||
lineString.getPointCount();
|
||||
lineString.insertPoint(2, { lat: 53.3477, lng: -6.2597 });
|
||||
lineString.removePoint(2);
|
||||
|
||||
let polyline2 = new H.map.Polyline(lineString);
|
||||
|
||||
let router = platform.getRoutingService();
|
||||
let calculateRouteParams = {
|
||||
waypoint0: 'geo!52.5,13.4',
|
||||
|
||||
Vendored
+509
-14
@@ -756,6 +756,31 @@ declare namespace H {
|
||||
|
||||
/***** geo *****/
|
||||
namespace geo {
|
||||
/**
|
||||
* The base class for all geometry types.
|
||||
*/
|
||||
class AbstractGeometry {
|
||||
/**
|
||||
* Returns the bounding rectangle of the geometry.
|
||||
* @return {H.geo.Rect} - the bounding rectangle of the geometry or null if the bounding rectangle can't be computed (e.g. for a geometry without coordinates)
|
||||
*/
|
||||
getBounds(): H.geo.Rect;
|
||||
|
||||
/**
|
||||
* Checks whether the geometry is equal to the geometry supplied by the caller.
|
||||
* Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.
|
||||
* @param other {any} - The geometry to check against
|
||||
* @return {boolean} - true if the two geometries are equal, otherwise false
|
||||
*/
|
||||
equals(other: any): boolean;
|
||||
|
||||
/**
|
||||
* To obtain a Well-Known-Text (WKT) representation of the geometry.
|
||||
* @return {string} - the resulting WKT string
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Geographic coordinate that specifies the height of a point in meters. A value of undefined is treated as 0.
|
||||
*/
|
||||
@@ -812,6 +837,277 @@ declare namespace H {
|
||||
*/
|
||||
type Longitude = number;
|
||||
|
||||
class LineString {
|
||||
/**
|
||||
* Constructor
|
||||
* @param opt_latLngAlts {number[]=} - An optional array of latitude, longitude and altitude triples to initialize the LineString with.
|
||||
* @param opt_ctx {H.geo.AltitudeContext=} - An optional altitude context for all altitudes contained in this LineString.
|
||||
* @throws {H.lang.InvalidArgumentError} - in case of invalid lat, lng, alt values
|
||||
*/
|
||||
constructor(opt_latLngAlts?: number[], opt_ctx?: H.geo.AltitudeContext);
|
||||
|
||||
/**
|
||||
* This method pushes a lat, lng, alt to the end of this LineString.
|
||||
* @param lat {H.geo.Latitude}
|
||||
* @param lng {H.geo.Longitude}
|
||||
* @param alt {H.geo.Altitude}
|
||||
* @throws {H.lang.InvalidArgumentError} - in case of invalid lat, lng, alt value
|
||||
*/
|
||||
pushLatLngAlt(lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude): void;
|
||||
|
||||
/**
|
||||
* This method splices the LineString at the provided index, removing the specified number of items at that index and inserting the lat, lng, alt array.
|
||||
* @param index {number} - The index at which to splice
|
||||
* @param opt_nRemove {number=} - The number of lat, lng, alt values to remove
|
||||
* @param opt_latLngAlts {number[]=} - The lat, lng, alt values to add
|
||||
* @return {number[]} - An array of removed elements
|
||||
* @throws {H.lang.InvalidArgumentError} - in case of invalid opt_latLngAlts argument
|
||||
*/
|
||||
spliceLatLngAlts(index: number, opt_nRemove?: number, opt_latLngAlts?: number[]): number[];
|
||||
|
||||
/**
|
||||
* This method inserts one set of lat, lng, alt values into the LineString at the specified index.
|
||||
* @param index {number} - the index at which to add the element
|
||||
* @param lat {H.geo.Latitude} - the latitude to insert
|
||||
* @param lng {H.geo.Longitude} - the longitude to insert
|
||||
* @param alt {H.geo.Altitude} - the altitude to insert
|
||||
*/
|
||||
insertLatLngAlt(index: number, lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude): void;
|
||||
|
||||
/**
|
||||
* This method removes one set of lat, lng, alt values from the LineString at the specified index
|
||||
* @param index {number}
|
||||
*/
|
||||
removeLatLngAlt(index: number): void;
|
||||
|
||||
/**
|
||||
* This method pushes the lat, lng, alt values of a {H.geo.Point} to the end of this LineString.
|
||||
* @param geoPoint {H.geo.IPoint}
|
||||
* @throws {H.lang.InvalidArgumentError} - in case of invalid geoPoint argument
|
||||
*/
|
||||
pushPoint(geoPoint: H.geo.IPoint): void;
|
||||
|
||||
/**
|
||||
* This method inserts the lat, lng, alt values of a H.geo.Point into the list at the specified index.
|
||||
* @param pointIndex {number}
|
||||
* @param geoPoint {H.geo.IPoint}
|
||||
*/
|
||||
insertPoint(pointIndex: number, geoPoint: H.geo.IPoint): void;
|
||||
|
||||
/**
|
||||
* This method removes one set of lat, lng, alt values from this LineString at the virtual point index specified.
|
||||
* @param pointIndex {number} - the virtual point index
|
||||
*/
|
||||
removePoint(pointIndex: number): void;
|
||||
|
||||
/**
|
||||
* This method extracts a H.geo.Point from this LineString at the virtual point index.
|
||||
* If the extracted point has an alt value, the LineString's altitude context will be supplied to the point.
|
||||
* @param pointIndex {number} - the virtual point index in the LineString
|
||||
* @param opt_out {H.geo.Point=} - an optional point object to store the lat, lng, alt values
|
||||
* @return {H.geo.Point} - Returns either the 'opt_out' point object or a new point object.
|
||||
*/
|
||||
extractPoint(pointIndex: number, opt_out?: H.geo.Point): H.geo.Point;
|
||||
|
||||
/**
|
||||
* A utility method to iterate over the points of a line string.
|
||||
* @param eachFn {function(lat, lng, alt, index)} - The function to invoke for every point. It gets the point's latitude, longitude, altitude and index as arguments.
|
||||
* @param opt_start {number=} - The point's start index (inclusive) to iterate from, defaults to 0.
|
||||
* @param opt_end {number=} - The point's end index (exclusive) to iterate to, defaults to Infinity.
|
||||
*/
|
||||
eachLatLngAlt(eachFn: (lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude, index: number) => void, opt_start?: number, opt_end?: number): void;
|
||||
|
||||
/**
|
||||
* To obtain whether a leg (formed by the given two longitudes) crosses the International Date Line.
|
||||
* @param lng1 {H.geo.Longitude} - The start longitude of the leg
|
||||
* @param lng2 {H.geo.Longitude} - The end longitude of the leg
|
||||
* @return {boolean}
|
||||
*/
|
||||
static isDBC(lng1: H.geo.Longitude, lng2: H.geo.Longitude): boolean;
|
||||
|
||||
/**
|
||||
* To obtain the number of times that this LineString cross the International Date Line.
|
||||
* @param opt_asClosed {boolean=} - Indicates whether the LineString is treated as closed (the LineString's last and first coordinates form the closing leg of a polygon).
|
||||
* It defaults to false.
|
||||
* @return {number}
|
||||
*/
|
||||
getDBCs(opt_asClosed?: boolean): number;
|
||||
|
||||
/**
|
||||
* This method return the number of points stored in this LineString.
|
||||
* @return {number} - The number of points in this LineString
|
||||
*/
|
||||
getPointCount(): number;
|
||||
|
||||
/**
|
||||
* Returns the vertices of the line segments as an array of alternating latitude, longitude and altitude coordinates.
|
||||
* The returned array must be treated as read-only to not violate the integrity of the line-string.
|
||||
* @return {number[]} - Returns the raw lat, lng, alt values of this LineString
|
||||
*/
|
||||
getLatLngAltArray(): number[];
|
||||
|
||||
/**
|
||||
* This method returns the bounding box of this LineString.
|
||||
* Note: The LineString is treated as an open path. If the bounding rectangle for a closed shape is required, the closing leg must be merged in an extra step.
|
||||
* @return {H.geo.Rect} - This LineString's bounding rectangle
|
||||
*/
|
||||
getBounds(): H.geo.Rect;
|
||||
|
||||
/**
|
||||
* This method initializes a new LineString with an array of lat, lng values. Arrays are expected to have an even length with the format [lat, lng, lat, lng, ...].
|
||||
* @param latLngs {number[]} - the array of lat, lng value.
|
||||
* @return {H.geo.LineString} - The LineString containing the lat, lng values
|
||||
* @throws {H.lang.InvalidArgumentError} - throws an error in case the latLngs array has an odd length
|
||||
*/
|
||||
static fromLatLngArray(latLngs: number[]): H.geo.LineString;
|
||||
|
||||
/**
|
||||
* Checks whether the geometry is equal to the geometry supplied by the caller.
|
||||
* Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.
|
||||
* @param other {any} - The geometry to check against
|
||||
* @return {boolean} - true if the two geometries are equal, otherwise false
|
||||
*/
|
||||
equals(other: any): boolean;
|
||||
|
||||
/**
|
||||
* To obtain a Well-Known-Text (WKT) representation of the geometry.
|
||||
* @return {string} - the resulting WKT string
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
class MultiGeometry<T> extends H.geo.AbstractGeometry {
|
||||
/**
|
||||
* The base class for a geometry that is a container for multiple geometries of a generic type. The type of the contained geometries is specified by the generic type parameter T
|
||||
* @param geometries {T[]} - The list of geometries which are initially aggregated.
|
||||
* @throws {H.lang.InvalidArgumentError} - if geometries parameter is not valid
|
||||
*/
|
||||
constructor(geometries: T[]);
|
||||
|
||||
/**
|
||||
* This method splices the specified MultiGeometry at the provided index, removing the specified number of items at that index and inserting new items.
|
||||
* @param index {number} - The index at which to start changing the list.
|
||||
* @param opt_deleteCount {number=} - The number of geometries to remove.
|
||||
* @param opt_items {T[]=} - The geometries to add.
|
||||
* @return {T[]} - the removed geometries.
|
||||
*/
|
||||
splice(index: number, opt_deleteCount?: number, opt_items?: T[]): T[];
|
||||
|
||||
/**
|
||||
* Removes a contained geometry at the given index.
|
||||
* @param index {number} - The index of the geometry to remove.
|
||||
* @return {T} - the removed geometry.
|
||||
* @throws {H.lang.OutOfRangeError} - if no geometry exists at the given index.
|
||||
*/
|
||||
removeAt(index: number): T;
|
||||
|
||||
/**
|
||||
* Removes the specified geometry from the multi-geometry
|
||||
* @param geometry {T} - The geometry (by reference) to remove from this multi-geometry.
|
||||
* @return {T} - the removed geometry or null if the geometry was not found
|
||||
*/
|
||||
remove(geometry: T): T;
|
||||
|
||||
/**
|
||||
* Returns the aggregated geometries of the multi-geometry. The returned geometries must be treated as read-only to not violate the integrity of the multi-geometry.
|
||||
* @return {T[]} - An array of geometries
|
||||
*/
|
||||
getGeometries(): T[];
|
||||
|
||||
/**
|
||||
* Adds the specified geometry to the current multi-geometry.
|
||||
* @param geometry {T} - A geometry which will be added to the current multi-geometry
|
||||
* @throws {H.lang.InvalidArgumentError} - in case of invalid geometry argument
|
||||
*/
|
||||
push(geometry: T): void;
|
||||
|
||||
/**
|
||||
* Returns the bounding rectangle of the geometry.
|
||||
* @return {H.geo.Rect} - the bounding rectangle of the geometry or null if the bounding rectangle can't be computed (e.g. for a geometry without coordinates)
|
||||
*/
|
||||
getBounds(): H.geo.Rect;
|
||||
|
||||
/**
|
||||
* Checks whether the geometry is equal to the geometry supplied by the caller.
|
||||
* Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.
|
||||
* @param other {any} - The geometry to check against
|
||||
* @return {boolean} - true if the two geometries are equal, otherwise false
|
||||
*/
|
||||
equals(other: any): boolean;
|
||||
|
||||
/**
|
||||
* To obtain a Well-Known-Text (WKT) representation of the geometry.
|
||||
* @return {string} - the resulting WKT string
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
class MultiLineString extends H.geo.MultiGeometry<H.geo.LineString> {
|
||||
/**
|
||||
* A MultiLineString is a collection of line strings represented as a H.geo.MultiGeometry with a H.geo.LineString as generic type parameter T.
|
||||
* @param lineStrings {H.geo.LineString[]} - The list of line-strings which are initially represented by the MultiLineString.
|
||||
* @throws {H.lang.InvalidArgumentError} - if the lineStrings argument is not valid
|
||||
*/
|
||||
constructor(lineStrings: H.geo.LineString[]);
|
||||
|
||||
/**
|
||||
* This method splices the specified MultiGeometry at the provided index, removing the specified number of items at that index and inserting new items.
|
||||
* @param index {number} - The index at which to start changing the list.
|
||||
* @param opt_deleteCount {number?} - The number of geometries to remove.
|
||||
* @param opt_items {H.geo.LineString[]?} - The geometries to add.
|
||||
* @return {H.geo.LineString[]} - the removed geometries
|
||||
*/
|
||||
splice(index: number, opt_deleteCount?: number, opt_items?: H.geo.LineString[]): H.geo.LineString[];
|
||||
|
||||
/**
|
||||
* Removes a contained geometry at the given index.
|
||||
* @param index {number} - The index of the geometry to remove.
|
||||
* @return {H.geo.LineString} - the removed geometry.
|
||||
* @throws {H.lang.OutOfRangeError} - if no geometry exists at the given index.
|
||||
*/
|
||||
removeAt(index: number): H.geo.LineString;
|
||||
|
||||
/**
|
||||
* Removes the specified geometry from the multi-geometry
|
||||
* @param geometry {H.geo.LineString} -The geometry (by reference) to remove from this multi-geometry
|
||||
* @return {H.geo.LineString} -the removed geometry or null if the geometry was not found
|
||||
*/
|
||||
remove(geometry: H.geo.LineString): H.geo.LineString;
|
||||
|
||||
/**
|
||||
* Returns the aggregated geometries of the multi-geometry. The returned geometries must be treated as read-only to not violate the integrity of the multi-geometry.
|
||||
* @return {H.geo.LineString[]} - An array of geometries
|
||||
*/
|
||||
getGeometries(): H.geo.LineString[];
|
||||
|
||||
/**
|
||||
* Adds the specified geometry to the current multi-geometry.
|
||||
* @param geometry {H.geo.LineString} - A geometry which will be added to the current multi-geometry
|
||||
* @throws {H.lang.InvalidArgumentError} - in case of invalid geometry argument
|
||||
*/
|
||||
push(geometry: H.geo.LineString): void;
|
||||
|
||||
/**
|
||||
* Returns the bounding rectangle of the geometry.
|
||||
* @return {H.geo.Rect} - the bounding rectangle of the geometry or null if the bounding rectangle can't be computed (e.g. for a geometry without coordinates)
|
||||
*/
|
||||
getBounds(): H.geo.Rect;
|
||||
|
||||
/**
|
||||
* Checks whether the geometry is equal to the geometry supplied by the caller.
|
||||
* Two geometries are considered as equal if they represent the same geometry type and have equal coordinate values.
|
||||
* @param other {any} - The geometry to check against
|
||||
* @return {boolean} - true if the two geometries are equal, otherwise false
|
||||
*/
|
||||
equals(other: any): boolean;
|
||||
|
||||
/**
|
||||
* To obtain a Well-Known-Text (WKT) representation of the geometry.
|
||||
* @return {string} - the resulting WKT string
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* PixelProjection transforms pixel world coordinates at a certain scale (zoom level) to geographical coordinates and vice versa.
|
||||
* By default, it uses the Mercator projection to transform geographic points into the 2d plane map points, which are adjusted to the current scale.
|
||||
@@ -2240,17 +2536,216 @@ declare namespace H {
|
||||
class Polyline extends H.map.GeoShape {
|
||||
/**
|
||||
* Constructor
|
||||
* @param strip {H.geo.Strip} - the strip describing this polygon's vertices
|
||||
* @param geometry {H.geo.Strip | H.geo.LineString | H.geo.MultiLineString} - The geometry that defines the line segments of the polyline
|
||||
* @param opt_options {H.map.Polyline.Options=} - optional initialization parameters
|
||||
*/
|
||||
constructor(strip: H.geo.Strip, opt_options?: H.map.Polyline.Options);
|
||||
constructor(geometry: H.geo.Strip | H.geo.LineString | H.geo.MultiLineString, opt_options?: H.map.Polyline.Options);
|
||||
|
||||
/**
|
||||
* This method clips this polyline against a rectangular area and returns the intersecting sub-lines.
|
||||
* @param geoRect {H.geo.Rect}
|
||||
* @returns {Array<Array<number>>}
|
||||
* To set the polyline's geometry. If the given geometry is modified afterwards, it must be set again via setGeometry(geometry) to not violate the integrity of the polyline.
|
||||
* @param geometry {H.geo.LineString | H.geo.MultiLineString} - the geometry to set.
|
||||
* @return {H.map.Polyline} - The polyline instance itself.
|
||||
*/
|
||||
setGeometry(geometry: H.geo.LineString | H.geo.MultiLineString): H.map.Polyline;
|
||||
|
||||
/**
|
||||
* To obtain the polyline's geometry. If you modify the obtained geometry, you must call setGeometry(geometry) afterwards to not violate the integrity of the polyline.
|
||||
* @return {H.geo.LineString | H.geo.MultiLineString}
|
||||
*/
|
||||
getGeometry(): H.geo.LineString | H.geo.MultiLineString;
|
||||
|
||||
/**
|
||||
* Clips the geometry of the Polyline to a rectangular area
|
||||
* @param geoRect {H.geo.Rect} - The rectangle to clip against.
|
||||
* @returns {Array<Array<number>>} - a list of geometry segments that intersecting the given rectangle.
|
||||
* Each segment is represented as a list of alternating latitude and longitude coordinates that describes a line string.
|
||||
*/
|
||||
clip(geoRect: H.geo.Rect): number[][];
|
||||
|
||||
/**
|
||||
* Returns the geometry.
|
||||
* @deprecated since 3.0.15.0
|
||||
* @return {H.geo.Strip} - spatial object.
|
||||
*/
|
||||
getStrip(): H.geo.Strip;
|
||||
|
||||
/**
|
||||
* Sets the geometry.
|
||||
* @deprecated since 3.0.15.0
|
||||
* @param strip {H.geo.Strip} - The strip which represents geometry.
|
||||
* @return {H.map.GeoShape} - The given spatial object
|
||||
*/
|
||||
setStrip(strip: H.geo.Strip): H.map.GeoShape;
|
||||
|
||||
/**
|
||||
* Returns the smallest rectangle which encloses the whole geometry of the GeoShape.
|
||||
* @return {H.geo.Rect}
|
||||
*/
|
||||
getBounds(): H.geo.Rect;
|
||||
|
||||
/**
|
||||
* This method retrieves the drawing style of the given spatial object. The returned style is treated as immutable and must not be modified afterwards to prevent inconsistencies!
|
||||
* @return {H.map.SpatialStyle} - The given spatial object
|
||||
*/
|
||||
getStyle(): H.map.SpatialStyle;
|
||||
|
||||
/**
|
||||
* This method sets the drawing style of the given spatial object. If the argument opt_style is an instance of H.map.SpatialStyle,
|
||||
* it is treated as immutable and must not be modified afterwards to prevent inconsistencies!
|
||||
* @param opt_style {(H.map.SpatialStyle | H.map.SpatialStyle.Options)=} - The style to set. If it evaluates to a false, the H.map.SpatialStyle.DEFAULT_STYLE is used.
|
||||
* @return {H.map.Spatial} - The given spatial object
|
||||
*/
|
||||
setStyle(opt_style?: H.map.SpatialStyle | H.map.SpatialStyle.Options): H.map.Spatial;
|
||||
|
||||
/**
|
||||
* This method retrieves the arrow style of the given spatial object or undefined if the style is not defined.
|
||||
* The returned arrow style is treated as immutable and must not be modified afterwards to prevent inconsistencies!
|
||||
* @return {H.map.ArrowStyle} - An object encapsulating information about the arrow style or undefined if the arrow style is not defined.
|
||||
*/
|
||||
getArrows(): H.map.ArrowStyle | undefined;
|
||||
|
||||
/**
|
||||
* This method sets the arrow style of the given spatial object.
|
||||
* @param opt_arrows {(H.map.ArrowStyle | H.map.ArrowStyle.Options)=} - The arrow style to be applied
|
||||
* @return {H.map.Spatial} - The given spatial object
|
||||
*/
|
||||
setArrows(opt_arrows?: H.map.ArrowStyle | H.map.ArrowStyle.Options): H.map.Spatial;
|
||||
|
||||
/**
|
||||
* This method indicates whether this spatial object represents a closed shape
|
||||
* @return {boolean} - true if the given spatial object is a closed shape, false otherwise
|
||||
*/
|
||||
isClosed(): boolean;
|
||||
|
||||
/**
|
||||
* This method retrieves the ID of the given object.
|
||||
* @return {any} The identifier of the given object.
|
||||
*/
|
||||
getId(): any;
|
||||
|
||||
/**
|
||||
* This method sets the visibility of the given object.
|
||||
* @param opt_visibility {boolean=} - Indicates whether the map object should be visible.
|
||||
* @return {H.map.Object} - The given object
|
||||
*/
|
||||
setVisibility(opt_visibility?: boolean): H.map.Object;
|
||||
|
||||
/**
|
||||
* This method retrieves a value indicating the visibility of the given object.
|
||||
* @param opt_effective {boolean} - Indicates that the effective visibility is requested. In this case the visibility of all possible ancestor groups is also taken into account
|
||||
* @return {boolean} - A value indicating if the object is visible (true) or not false
|
||||
*/
|
||||
getVisibility(opt_effective?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* This method retrieves the z-index of the given object.
|
||||
* @return {number} - A value reflecting the z-index of the given object.
|
||||
*/
|
||||
getZIndex(): number | undefined;
|
||||
|
||||
/**
|
||||
* This method sets the z-index of the given object.
|
||||
* @param zIndex {number | undefined} - A value indicating the new z-index
|
||||
* @return {H.map.Object} - The given object
|
||||
*/
|
||||
setZIndex(zIndex: number | undefined): H.map.Object;
|
||||
|
||||
/**
|
||||
* This method compares the rendering z-order of the given object with another object. (The 'given object' mean the object on which the method has been invoke.)
|
||||
* @param other {H.map.Object} -The map object with which to compare the given object.
|
||||
* @return {number} - A value lower than 0 indicates that the given object has a lower z-order. 0 indicates that both objects have the same z-order.
|
||||
* A value greater than 0, indicates that the given object has a higher z-order.
|
||||
*/
|
||||
compareZOrder(other: H.map.Object): number;
|
||||
|
||||
/**
|
||||
* This method retrieves the parent group which contains the given object or null if the object is not contained in any group.
|
||||
* @return {H.map.Group} - An object representing the containing group object or null if the given object is not contained in any group.
|
||||
*/
|
||||
getParentGroup(): H.map.Group;
|
||||
|
||||
/**
|
||||
* The root object to which the given object is attached or the object itself if it is not attached to another.
|
||||
* @return {H.map.Object} - An object representing the root group for the given object or the given object if it is not part of a group.
|
||||
*/
|
||||
getRootGroup(): H.map.Object;
|
||||
|
||||
/**
|
||||
* This method checks whether the received object is an inclusive descendant of the given object.
|
||||
* @param object {any} - The object to check.
|
||||
* @return {boolean} - true if the given object is contained in the given object, otherwise false
|
||||
*/
|
||||
contains(object: any): boolean;
|
||||
|
||||
/**
|
||||
* This method obtains the current provider of the given object
|
||||
* @return {H.map.provider.ObjectProvider} - An object representing the provider
|
||||
*/
|
||||
getProvider(): H.map.provider.ObjectProvider;
|
||||
|
||||
/**
|
||||
* This method retrieves the invalidation states for the given object.
|
||||
* @return {H.map.provider.Invalidations} - An object containing the invalidation states
|
||||
*/
|
||||
getInvalidations(): H.map.provider.Invalidations;
|
||||
|
||||
/**
|
||||
* This method invalidates the given map object.
|
||||
* @param flags {H.math.BitMask} - The flags indicating the types of changes to the given object
|
||||
* @return {boolean} - Indicates whether a validation was executed (only if the object has a provider)
|
||||
*/
|
||||
invalidate(flags: H.math.BitMask): boolean;
|
||||
|
||||
/**
|
||||
* This method retrieves previously stored arbitrary data from the given object.
|
||||
* @return {any} - The previously stored data or undefined if no data was stored.
|
||||
*/
|
||||
getData(): any;
|
||||
|
||||
/**
|
||||
* This method stores arbitrary data with the given map object.
|
||||
* @param data {any} - The data to be stored
|
||||
* @return {H.map.Object} - The given map object
|
||||
*/
|
||||
setData(data: any): H.map.Object;
|
||||
|
||||
/**
|
||||
* This method adds a listener for a specific event.
|
||||
* Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it.
|
||||
* @param type {string} - The name of the event
|
||||
* @param handler {function()} - An event handler function
|
||||
* @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise)
|
||||
* @param opt_scope {{}=} - An object defining the scope for the handler function
|
||||
*/
|
||||
addEventListener(type: string, handler: () => void, opt_capture?: boolean, opt_scope?: {}): void;
|
||||
|
||||
/**
|
||||
* This method removes a previously added listener from the EventTarget instance.
|
||||
* @param type {string} - The name of the event
|
||||
* @param handler {function()} - An event handler function
|
||||
* @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise)
|
||||
* @param opt_scope {{}=} - An object defining the scope for the handler function
|
||||
*/
|
||||
removeEventListener(type: string, handler: () => void, opt_capture?: boolean, opt_scope?: {}): void;
|
||||
|
||||
/**
|
||||
* This method dispatches an event on the EventTarget object.
|
||||
* @param evt {H.util.Event | string} - An object representing the event or a string with the event name
|
||||
*/
|
||||
dispatchEvent(evt: H.util.Event | string): void;
|
||||
|
||||
/**
|
||||
* This method removes listeners from the given object.
|
||||
* Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.
|
||||
*/
|
||||
dispose(): void;
|
||||
|
||||
/**
|
||||
* This method adds a callback which is triggered when the EventTarget object is being disposed.
|
||||
* @param callback {function()} - The callback function.
|
||||
* @param opt_scope {{}=} - An optional scope for the callback function
|
||||
*/
|
||||
addOnDisposeCallback(callback: () => void, opt_scope?: {}): void;
|
||||
}
|
||||
|
||||
namespace Polyline {
|
||||
@@ -3164,7 +3659,7 @@ declare namespace H {
|
||||
* sessions consistent IDs is needed (e.g. for storing provider data) this property must be specified.
|
||||
* @property min {number=} - The minimal supported zoom level, default is 0
|
||||
* @property max {number=} - The maximal supported zoom level, default is 22
|
||||
* @property getCopyrights {(function(H.geo.Rect, number) : ?Array<H.map.ICopyright>)=} - A function to replace the default implementation of H.map.provider.Provider#getCopyrights
|
||||
* @property getCopyrights {(function(H.geo.Rect, number): ?Array<H.map.ICopyright>)=} - A function to replace the default implementation of H.map.provider.Provider#getCopyrights
|
||||
* @property tileSize {number=} - The size of a tile as edge length in pixels. It must be 2^n where n is in range [0 ... 30], default is 256
|
||||
* @property getURL {function(number, number, number)} - The function to create an URL for the specified tile. If it returns a falsy the tile is not requested.
|
||||
* @property crossOrigin {(string | boolean=)} - The CORS settings to use for the crossOrigin attribute for the image, if omitted or if the value evaluates to false no CORS settings
|
||||
@@ -3299,7 +3794,7 @@ declare namespace H {
|
||||
* Options which are used to initialize the MarkerTileProvider object.
|
||||
* @property min {number=} - The minimal supported zoom level, default is 0
|
||||
* @property max {number=} - The maximal supported zoom level, default is 22
|
||||
* @property requestData {function(number, number, number, function(Array<H.map.AbstractMarker>), Function) : H.util.ICancelable} - function that fetches marker data and creates array
|
||||
* @property requestData {function(number, number, number, function(Array<H.map.AbstractMarker>), Function): H.util.ICancelable} - function that fetches marker data and creates array
|
||||
* of H.map.AbstractMarker that is passed success callback, if function fails to fetch data onError callback must be called
|
||||
* @property providesDomMarkers {boolean=} - indicates if markers provided are of type H.map.DomMarker or H.map.Marker, default is H.map.Marker
|
||||
*/
|
||||
@@ -3463,7 +3958,7 @@ declare namespace H {
|
||||
* sessions consistent IDs is needed (e.g. for storing provider data) this property must be specified.
|
||||
* @property min {number=} - The minimal supported zoom level, default is 0
|
||||
* @property max {number=} - The maximal supported zoom level, default is 22
|
||||
* @property getCopyrights {(function(H.geo.Rect, number) : ?Array<H.map.ICopyright>)=} - A function to replace the default implementation of H.map.provider.Provider#getCopyrights
|
||||
* @property getCopyrights {(function(H.geo.Rect, number): ?Array<H.map.ICopyright>)=} - A function to replace the default implementation of H.map.provider.Provider#getCopyrights
|
||||
*/
|
||||
interface Options {
|
||||
uri?: string;
|
||||
@@ -6137,7 +6632,7 @@ declare namespace H {
|
||||
namespace ZoomRectangle {
|
||||
/**
|
||||
* @property alignment {H.ui.LayoutAlignment=} - the layout alignment which should be applied to this control, default is H.ui.LayoutAlignment.BOTTOM_RIGHT
|
||||
* @property adjustZoom {function(number, H.Map) : number=} - optional function that defines how zoom level should be changed, by default zoom level is picked to fit the
|
||||
* @property adjustZoom {function(number, H.Map): number=} - optional function that defines how zoom level should be changed, by default zoom level is picked to fit the
|
||||
* bounding rectangle into the view port.
|
||||
*/
|
||||
interface Options {
|
||||
@@ -6381,7 +6876,7 @@ declare namespace H {
|
||||
* Constructor
|
||||
* @param maxSize {number} - the maximum size of the cache
|
||||
* @param opt_onDrop {function(string, ?, number)=} - A callback to be invoked when a data element is dropped from the cache
|
||||
* @param opt_filter {(function(string, ?, number) : boolean)=} - A function to filter data elements that are not to be cached
|
||||
* @param opt_filter {(function(string, ?, number): boolean)=} - A function to filter data elements that are not to be cached
|
||||
*/
|
||||
constructor(maxSize: number, opt_onDrop?: (s: string, i: any, n: number) => void, opt_filter?: (s: string, i: any, n: number) => boolean);
|
||||
|
||||
@@ -6432,14 +6927,14 @@ declare namespace H {
|
||||
* on those entries for which the predicated returns true.
|
||||
* @param callback {function(string, ?, number)} - the callback to be invoked for each entry
|
||||
* @param opt_ctx {Object=} - an optional context object to be used as this within the callback
|
||||
* @param opt_matcher {(function(string, ?, number) : boolean)=} - an optional match predicate to customize on which entries the callback will be called
|
||||
* @param opt_matcher {(function(string, ?, number): boolean)=} - an optional match predicate to customize on which entries the callback will be called
|
||||
*/
|
||||
forEach(callback: (s: string, i: any, n: number) => void, opt_ctx?: any, opt_matcher?: (s: string, i: any, n: number) => boolean): void;
|
||||
|
||||
/**
|
||||
* This method removes all data elements from the cache. If the optional match predicate is passed to this method only those data elements will be removed for which the predicate
|
||||
* return true.
|
||||
* @param opt_matcher {(function(string, ?, number) : boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or
|
||||
* @param opt_matcher {(function(string, ?, number): boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or
|
||||
* leave the entry in the cache respectively
|
||||
*/
|
||||
removeAll(opt_matcher?: (s: string, i: any, n: number) => boolean): void;
|
||||
@@ -6683,14 +7178,14 @@ declare namespace H {
|
||||
* those entries for which the predicated returns true.
|
||||
* @param callback {function(string, ?, number)} - the callback to be invoked for each entry
|
||||
* @param opt_ctx {Object=} - an optional context object to be used as this within the callback
|
||||
* @param opt_matcher {(function(string, ?, number) : boolean)=} - an optional match predicate to customize on which entries the callback will be called
|
||||
* @param opt_matcher {(function(string, ?, number): boolean)=} - an optional match predicate to customize on which entries the callback will be called
|
||||
*/
|
||||
forEach(callback: (s: string, t: any, n: number) => void, opt_ctx?: {}, opt_matcher?: ((s: string, t: any, n: number) => boolean)): void;
|
||||
|
||||
/**
|
||||
* This method removes all data elements from the cache. If the optional match predicate is passed to this method only those data elements will be removed for which the predicate
|
||||
* return true.
|
||||
* @param opt_matcher {(function(string, ?, number) : boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or
|
||||
* @param opt_matcher {(function(string, ?, number): boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or
|
||||
* leave the entry in the cache respectively
|
||||
*/
|
||||
removeAll(opt_matcher?: ((s: string, t: any, n: number) => boolean)): void;
|
||||
|
||||
Vendored
+23
-22
@@ -3,10 +3,11 @@
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Parvez <https://github.com/ppathan>
|
||||
// Jouderian <https://github.com/jouderianjr>
|
||||
// Qibang <https://github.com/bang88>
|
||||
// Jason Dreyzehner <https://github.com/bitjson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
// TypeScript Version: 2.3
|
||||
/// <reference types="rx" />
|
||||
|
||||
import through = require('through');
|
||||
@@ -14,10 +15,10 @@ import through = require('through');
|
||||
declare namespace inquirer {
|
||||
type Prompts = { [name: string]: PromptModule };
|
||||
type ChoiceType = string | objects.ChoiceOption | objects.Separator;
|
||||
type Questions =
|
||||
| Question
|
||||
| ReadonlyArray<Question>
|
||||
| Rx.Observable<Question>;
|
||||
type Questions<T> =
|
||||
| Question<T>
|
||||
| ReadonlyArray<Question<T>>
|
||||
| Rx.Observable<Question<T>>;
|
||||
|
||||
interface Inquirer {
|
||||
restoreDefaultPrompts(): void;
|
||||
@@ -37,8 +38,8 @@ declare namespace inquirer {
|
||||
* @param cb Callback being passed the user answers
|
||||
* @return
|
||||
*/
|
||||
prompt(questions: Questions, cb: (answers: Answers) => any): ui.Prompt;
|
||||
prompt(questions: Questions): Promise<Answers>;
|
||||
prompt<T>(questions: Questions<T>, cb: (answers: T) => any): ui.Prompt;
|
||||
prompt<T>(questions: Questions<T>): Promise<T>;
|
||||
prompts: Prompts;
|
||||
Separator: objects.SeparatorStatic;
|
||||
ui: {
|
||||
@@ -48,8 +49,8 @@ declare namespace inquirer {
|
||||
}
|
||||
|
||||
interface PromptModule {
|
||||
(questions: Questions): Promise<Answers>;
|
||||
(questions: Questions, cb: (answers: Answers) => any): ui.Prompt;
|
||||
<T>(questions: Questions<T>): Promise<T>;
|
||||
<T>(questions: Questions<T>, cb: (answers: T) => any): ui.Prompt;
|
||||
/**
|
||||
* Register a prompt type
|
||||
* @param name Prompt type name
|
||||
@@ -62,7 +63,7 @@ declare namespace inquirer {
|
||||
restoreDefaultPrompts(): void;
|
||||
}
|
||||
|
||||
interface Question {
|
||||
interface Question<T = Answers> {
|
||||
/**
|
||||
* Type of the prompt.
|
||||
* Possible values:
|
||||
@@ -84,12 +85,12 @@ declare namespace inquirer {
|
||||
* The question to print. If defined as a function,
|
||||
* the first parameter will be the current inquirer session answers.
|
||||
*/
|
||||
message?: string | ((answers: Answers) => string);
|
||||
message?: string | ((answers: T) => string);
|
||||
/**
|
||||
* Default value(s) to use if nothing is entered, or a function that returns the default value(s).
|
||||
* If defined as a function, the first parameter will be the current inquirer session answers.
|
||||
*/
|
||||
default?: any | ((answers: Answers) => any);
|
||||
default?: any | ((answers: T) => any);
|
||||
/**
|
||||
* Choices array or a function returning a choices array. If defined as a function,
|
||||
* the first parameter will be the current inquirer session answers.
|
||||
@@ -98,12 +99,12 @@ declare namespace inquirer {
|
||||
*/
|
||||
choices?:
|
||||
| ReadonlyArray<ChoiceType>
|
||||
| ((answers: Answers) => ReadonlyArray<ChoiceType>);
|
||||
| ((answers: T) => ReadonlyArray<ChoiceType>);
|
||||
/**
|
||||
* Receive the user input and should return true if the value is valid, and an error message (String)
|
||||
* otherwise. If false is returned, a default error message is provided.
|
||||
*/
|
||||
validate?(input: string, answers?: Answers): boolean | string;
|
||||
validate?(input: string, answers?: T): boolean | string;
|
||||
/**
|
||||
* Receive the user input and return the filtered value to be used inside the program.
|
||||
* The value returned will be added to the Answers hash.
|
||||
@@ -113,7 +114,7 @@ declare namespace inquirer {
|
||||
* Receive the current user answers hash and should return true or false depending on whether or
|
||||
* not this question should be asked. The value can also be a simple boolean.
|
||||
*/
|
||||
when?: boolean | ((answers: Answers) => boolean);
|
||||
when?: boolean | ((answers: T) => boolean);
|
||||
paginated?: boolean;
|
||||
/**
|
||||
* Change the number of lines that will be rendered when using list, rawList, expand or checkbox.
|
||||
@@ -150,10 +151,10 @@ declare namespace inquirer {
|
||||
* Once all prompt are over
|
||||
*/
|
||||
onCompletion(): void;
|
||||
processQuestion(question: Question): any;
|
||||
fetchAnswer(question: Question): any;
|
||||
setDefaultType(question: Question): any;
|
||||
filterIfRunnable(question: Question): any;
|
||||
processQuestion<T>(question: Question<T>): any;
|
||||
fetchAnswer<T>(question: Question<T>): any;
|
||||
setDefaultType<T>(question: Question<T>): any;
|
||||
filterIfRunnable<T>(question: Question<T>): any;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +245,7 @@ declare namespace inquirer {
|
||||
extra?: any;
|
||||
key?: string;
|
||||
checked?: boolean;
|
||||
disabled?: string | ((answers: Answers) => any);
|
||||
disabled?: string | (<T = Answers>(answers: T) => any);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,9 +255,9 @@ declare namespace inquirer {
|
||||
* @param choices All `choice` to keep in the collection
|
||||
*/
|
||||
interface Choices {
|
||||
new (
|
||||
new <T = Answers>(
|
||||
choices: ReadonlyArray<string | Separator | ChoiceOption>,
|
||||
answers?: Answers
|
||||
answers?: T
|
||||
): Choices;
|
||||
choices: ReadonlyArray<Choice>;
|
||||
realChoices: ReadonlyArray<Choice>;
|
||||
|
||||
+247
-209
@@ -1,9 +1,13 @@
|
||||
import inquirer = require('inquirer');
|
||||
import inquirer = require("inquirer");
|
||||
|
||||
|
||||
inquirer.prompt([/* Pass your questions in here */], function( answers: inquirer.Answers ) {
|
||||
// Use user feedback for... whatever!!
|
||||
});
|
||||
inquirer.prompt(
|
||||
[
|
||||
/* Pass your questions in here */
|
||||
],
|
||||
function(answers: inquirer.Answers) {
|
||||
// Use user feedback for... whatever!!
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
// examples/bottom-bar.js
|
||||
@@ -13,29 +17,25 @@ inquirer.prompt([/* Pass your questions in here */], function( answers: inquirer
|
||||
var BottomBar = inquirer.ui.BottomBar;
|
||||
declare var cmdify: any;
|
||||
|
||||
var loader = [
|
||||
"/ Installing",
|
||||
"| Installing",
|
||||
"\\ Installing",
|
||||
"- Installing"
|
||||
];
|
||||
var loader = ["/ Installing", "| Installing", "\\ Installing", "- Installing"];
|
||||
var i = 4;
|
||||
var ui = new BottomBar({ bottomBar: loader[i % 4] });
|
||||
|
||||
setInterval(function() {
|
||||
ui.updateBottomBar( loader[i++ % 4] );
|
||||
}, 300 );
|
||||
ui.updateBottomBar(loader[i++ % 4]);
|
||||
}, 300);
|
||||
|
||||
var spawn = require("child_process").spawn;
|
||||
|
||||
var cmd = spawn(cmdify("npm"), [ "-g", "install", "inquirer" ], { stdio: "pipe" });
|
||||
cmd.stdout.pipe( ui.log );
|
||||
cmd.on( "close", function() {
|
||||
var cmd = spawn(cmdify("npm"), ["-g", "install", "inquirer"], {
|
||||
stdio: "pipe"
|
||||
});
|
||||
cmd.stdout.pipe(ui.log);
|
||||
cmd.on("close", function() {
|
||||
ui.updateBottomBar("Installation done!\n");
|
||||
process.exit();
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
// examples/checkbox.js
|
||||
//
|
||||
@@ -47,49 +47,51 @@ cmd.on( "close", function() {
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
|
||||
inquirer.prompt([
|
||||
{
|
||||
type: "checkbox",
|
||||
message: "Select toppings",
|
||||
name: "toppings",
|
||||
choices: [
|
||||
new inquirer.Separator("The usual:"),
|
||||
{
|
||||
name: "Pepperoni"
|
||||
},
|
||||
{
|
||||
name: "Cheese",
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: "Mushroom"
|
||||
},
|
||||
new inquirer.Separator("The extras:"),
|
||||
{
|
||||
name: "Pineapple",
|
||||
},
|
||||
{
|
||||
name: "Bacon"
|
||||
},
|
||||
{
|
||||
name: "Olives",
|
||||
disabled: "out of stock"
|
||||
},
|
||||
{
|
||||
name: "Extra cheese"
|
||||
inquirer.prompt<{ toppings: string }>(
|
||||
[
|
||||
{
|
||||
type: "checkbox",
|
||||
message: "Select toppings",
|
||||
name: "toppings",
|
||||
choices: [
|
||||
new inquirer.Separator("The usual:"),
|
||||
{
|
||||
name: "Pepperoni"
|
||||
},
|
||||
{
|
||||
name: "Cheese",
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: "Mushroom"
|
||||
},
|
||||
new inquirer.Separator("The extras:"),
|
||||
{
|
||||
name: "Pineapple"
|
||||
},
|
||||
{
|
||||
name: "Bacon"
|
||||
},
|
||||
{
|
||||
name: "Olives",
|
||||
disabled: "out of stock"
|
||||
},
|
||||
{
|
||||
name: "Extra cheese"
|
||||
}
|
||||
],
|
||||
validate: function(answer) {
|
||||
if (answer.length < 1) {
|
||||
return "You must choose at least one topping.";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
],
|
||||
validate: function( answer ) {
|
||||
if ( answer.length < 1 ) {
|
||||
return "You must choose at least one topping.";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
],
|
||||
function(answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
}
|
||||
], function( answers: inquirer.Answers ) {
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
});
|
||||
|
||||
);
|
||||
|
||||
//
|
||||
// examples/expand.js
|
||||
@@ -102,39 +104,41 @@ inquirer.prompt([
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
|
||||
inquirer.prompt([
|
||||
{
|
||||
type: "expand",
|
||||
message: "Conflict on `file.js`: ",
|
||||
name: "overwrite",
|
||||
choices: [
|
||||
{
|
||||
key: "y",
|
||||
name: "Overwrite",
|
||||
value: "overwrite"
|
||||
},
|
||||
{
|
||||
key: "a",
|
||||
name: "Overwrite this one and all next",
|
||||
value: "overwrite_all"
|
||||
},
|
||||
{
|
||||
key: "d",
|
||||
name: "Show diff",
|
||||
value: "diff"
|
||||
},
|
||||
new inquirer.Separator(),
|
||||
{
|
||||
key: "x",
|
||||
name: "Abort",
|
||||
value: "abort"
|
||||
}
|
||||
]
|
||||
inquirer.prompt(
|
||||
[
|
||||
{
|
||||
type: "expand",
|
||||
message: "Conflict on `file.js`: ",
|
||||
name: "overwrite",
|
||||
choices: [
|
||||
{
|
||||
key: "y",
|
||||
name: "Overwrite",
|
||||
value: "overwrite"
|
||||
},
|
||||
{
|
||||
key: "a",
|
||||
name: "Overwrite this one and all next",
|
||||
value: "overwrite_all"
|
||||
},
|
||||
{
|
||||
key: "d",
|
||||
name: "Show diff",
|
||||
value: "diff"
|
||||
},
|
||||
new inquirer.Separator(),
|
||||
{
|
||||
key: "x",
|
||||
name: "Abort",
|
||||
value: "abort"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
function(answers: inquirer.Answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
}
|
||||
], function( answers: inquirer.Answers ) {
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
});
|
||||
|
||||
);
|
||||
|
||||
//
|
||||
// examples/input.js
|
||||
@@ -152,21 +156,25 @@ var questions = [
|
||||
type: "input",
|
||||
name: "first_name",
|
||||
message: "What's your first name",
|
||||
prefix: "1 - ",
|
||||
prefix: "1 - "
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "last_name",
|
||||
message: "What's your last name",
|
||||
default: function () { return "Doe"; },
|
||||
default: function() {
|
||||
return "Doe";
|
||||
},
|
||||
suffix: "!!"
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "phone",
|
||||
message: "What's your phone number",
|
||||
validate: function( value: string ): string|boolean {
|
||||
var pass = value.match(/^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i);
|
||||
validate: function(value: string): string | boolean {
|
||||
var pass = value.match(
|
||||
/^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i
|
||||
);
|
||||
if (pass) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -176,15 +184,14 @@ var questions = [
|
||||
}
|
||||
];
|
||||
|
||||
inquirer.prompt( questions, function( answers ) {
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
inquirer.prompt(questions, function(answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
});
|
||||
|
||||
//
|
||||
// examples/list.js
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* List prompt example
|
||||
*/
|
||||
@@ -192,29 +199,34 @@ inquirer.prompt( questions, function( answers ) {
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
|
||||
inquirer.prompt([
|
||||
{
|
||||
type: "list",
|
||||
name: "theme",
|
||||
message: "What do you want to do?",
|
||||
choices: [
|
||||
"Order a pizza",
|
||||
"Make a reservation",
|
||||
new inquirer.Separator(),
|
||||
"Ask opening hours",
|
||||
"Talk to the receptionist"
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "list",
|
||||
name: "size",
|
||||
message: "What size do you need",
|
||||
choices: [ "Jumbo", "Large", "Standard", "Medium", "Small", "Micro" ],
|
||||
filter: function( val: string ) { return val.toLowerCase(); }
|
||||
inquirer.prompt(
|
||||
[
|
||||
{
|
||||
type: "list",
|
||||
name: "theme",
|
||||
message: "What do you want to do?",
|
||||
choices: [
|
||||
"Order a pizza",
|
||||
"Make a reservation",
|
||||
new inquirer.Separator(),
|
||||
"Ask opening hours",
|
||||
"Talk to the receptionist"
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "list",
|
||||
name: "size",
|
||||
message: "What size do you need",
|
||||
choices: ["Jumbo", "Large", "Standard", "Medium", "Small", "Micro"],
|
||||
filter: function(val: string) {
|
||||
return val.toLowerCase();
|
||||
}
|
||||
}
|
||||
],
|
||||
function(answers: inquirer.Answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
}
|
||||
], function( answers: inquirer.Answers ) {
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
});
|
||||
);
|
||||
|
||||
//
|
||||
// examples/long-list.js
|
||||
@@ -227,30 +239,35 @@ inquirer.prompt([
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
|
||||
var choices = Array.apply(0, new Array(26)).map(function(x: number,y: number) {
|
||||
var choices = Array.apply(0, new Array(26)).map(function(x: number, y: number) {
|
||||
return String.fromCharCode(y + 65);
|
||||
});
|
||||
choices.push("Multiline option \n super cool feature");
|
||||
choices.push("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.");
|
||||
choices.push(
|
||||
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium."
|
||||
);
|
||||
|
||||
inquirer.prompt([
|
||||
{
|
||||
type : "list",
|
||||
name : "letter",
|
||||
message : "What's your favorite letter?",
|
||||
paginated : true,
|
||||
choices : choices
|
||||
},
|
||||
{
|
||||
type : "checkbox",
|
||||
name : "name",
|
||||
message : "Select the letter contained in your name:",
|
||||
paginated : true,
|
||||
choices : choices
|
||||
inquirer.prompt(
|
||||
[
|
||||
{
|
||||
type: "list",
|
||||
name: "letter",
|
||||
message: "What's your favorite letter?",
|
||||
paginated: true,
|
||||
choices: choices
|
||||
},
|
||||
{
|
||||
type: "checkbox",
|
||||
name: "name",
|
||||
message: "Select the letter contained in your name:",
|
||||
paginated: true,
|
||||
choices: choices
|
||||
}
|
||||
],
|
||||
function(answers: inquirer.Answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
}
|
||||
], function( answers: inquirer.Answers ) {
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
});
|
||||
);
|
||||
|
||||
//
|
||||
// examples/nested-call.js
|
||||
@@ -263,19 +280,22 @@ inquirer.prompt([
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
|
||||
inquirer.prompt({
|
||||
type: "list",
|
||||
name: "chocolate",
|
||||
message: "What's your favorite chocolate?",
|
||||
choices: [ "Mars", "Oh Henry", "Hershey" ]
|
||||
}, function( answers: inquirer.Answers ) {
|
||||
inquirer.prompt({
|
||||
inquirer.prompt(
|
||||
{
|
||||
type: "list",
|
||||
name: "beverage",
|
||||
message: "And your favorite beverage?",
|
||||
choices: [ "Pepsi", "Coke", "7up", "Mountain Dew", "Red Bull" ]
|
||||
});
|
||||
});
|
||||
name: "chocolate",
|
||||
message: "What's your favorite chocolate?",
|
||||
choices: ["Mars", "Oh Henry", "Hershey"]
|
||||
},
|
||||
function(answers: inquirer.Answers) {
|
||||
inquirer.prompt({
|
||||
type: "list",
|
||||
name: "beverage",
|
||||
message: "And your favorite beverage?",
|
||||
choices: ["Pepsi", "Coke", "7up", "Mountain Dew", "Red Bull"]
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
// examples/password.js
|
||||
@@ -288,15 +308,18 @@ inquirer.prompt({
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
|
||||
inquirer.prompt([
|
||||
{
|
||||
type: "password",
|
||||
message: "Enter your git password",
|
||||
name: "password"
|
||||
inquirer.prompt(
|
||||
[
|
||||
{
|
||||
type: "password",
|
||||
message: "Enter your git password",
|
||||
name: "password"
|
||||
}
|
||||
],
|
||||
function(answers: inquirer.Answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
}
|
||||
], function( answers: inquirer.Answers ) {
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
});
|
||||
);
|
||||
|
||||
//
|
||||
// examples/pizza.js
|
||||
@@ -323,8 +346,10 @@ var questions2 = [
|
||||
type: "input",
|
||||
name: "phone",
|
||||
message: "What's your phone number",
|
||||
validate: function( value: string ): string|boolean {
|
||||
var pass = value.match(/^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i);
|
||||
validate: function(value: string): string | boolean {
|
||||
var pass = value.match(
|
||||
/^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i
|
||||
);
|
||||
if (pass) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -336,14 +361,16 @@ var questions2 = [
|
||||
type: "list",
|
||||
name: "size",
|
||||
message: "What size do you need",
|
||||
choices: [ "Large", "Medium", "Small" ],
|
||||
filter: function( val: string ) { return val.toLowerCase(); }
|
||||
choices: ["Large", "Medium", "Small"],
|
||||
filter: function(val: string) {
|
||||
return val.toLowerCase();
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "quantity",
|
||||
message: "How many do you need",
|
||||
validate: function( value: string ) {
|
||||
validate: function(value: string) {
|
||||
var valid = !isNaN(parseFloat(value));
|
||||
return valid || "Please enter a number";
|
||||
},
|
||||
@@ -375,7 +402,7 @@ var questions2 = [
|
||||
type: "rawlist",
|
||||
name: "beverage",
|
||||
message: "You also get a free 2L beverage",
|
||||
choices: [ "Pepsi", "7up", "Coke" ]
|
||||
choices: ["Pepsi", "7up", "Coke"]
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
@@ -387,16 +414,16 @@ var questions2 = [
|
||||
type: "list",
|
||||
name: "prize",
|
||||
message: "For leaving a comments, you get a freebie",
|
||||
choices: [ "cake", "fries" ],
|
||||
when: function( answers: inquirer.Answers ) {
|
||||
return answers['comments'] !== "Nope, all good!";
|
||||
choices: ["cake", "fries"],
|
||||
when: function(answers: inquirer.Answers) {
|
||||
return answers["comments"] !== "Nope, all good!";
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
inquirer.prompt( questions, function( answers ) {
|
||||
inquirer.prompt(questions, function(answers) {
|
||||
console.log("\nOrder receipt:");
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
});
|
||||
|
||||
//
|
||||
@@ -410,29 +437,34 @@ inquirer.prompt( questions, function( answers ) {
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
|
||||
inquirer.prompt([
|
||||
{
|
||||
type: "rawlist",
|
||||
name: "theme",
|
||||
message: "What do you want to do?",
|
||||
choices: [
|
||||
"Order a pizza",
|
||||
"Make a reservation",
|
||||
new inquirer.Separator(),
|
||||
"Ask opening hours",
|
||||
"Talk to the receptionist"
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "rawlist",
|
||||
name: "size",
|
||||
message: "What size do you need",
|
||||
choices: [ "Jumbo", "Large", "Standard", "Medium", "Small", "Micro" ],
|
||||
filter: function( val: string ) { return val.toLowerCase(); }
|
||||
inquirer.prompt(
|
||||
[
|
||||
{
|
||||
type: "rawlist",
|
||||
name: "theme",
|
||||
message: "What do you want to do?",
|
||||
choices: [
|
||||
"Order a pizza",
|
||||
"Make a reservation",
|
||||
new inquirer.Separator(),
|
||||
"Ask opening hours",
|
||||
"Talk to the receptionist"
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "rawlist",
|
||||
name: "size",
|
||||
message: "What size do you need",
|
||||
choices: ["Jumbo", "Large", "Standard", "Medium", "Small", "Micro"],
|
||||
filter: function(val: string) {
|
||||
return val.toLowerCase();
|
||||
}
|
||||
}
|
||||
],
|
||||
function(answers: inquirer.Answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
}
|
||||
], function( answers: inquirer.Answers ) {
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
});
|
||||
);
|
||||
|
||||
//
|
||||
// examples/recursive.js
|
||||
@@ -445,7 +477,7 @@ inquirer.prompt([
|
||||
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
var output2: (string|boolean)[] = [];
|
||||
var output2: (string | boolean)[] = [];
|
||||
|
||||
var questions3 = [
|
||||
{
|
||||
@@ -456,18 +488,21 @@ var questions3 = [
|
||||
{
|
||||
type: "confirm",
|
||||
name: "askAgain",
|
||||
message: "Want to enter another TV show favorite (just hit enter for YES)?",
|
||||
message:
|
||||
"Want to enter another TV show favorite (just hit enter for YES)?",
|
||||
default: true
|
||||
}
|
||||
];
|
||||
|
||||
function ask() {
|
||||
inquirer.prompt( questions3, function( answers: inquirer.Answers ) {
|
||||
output2.push( answers['tvShow'] );
|
||||
if ( answers['askAgain'] ) {
|
||||
inquirer.prompt<{ tvShow: string; askAgain: boolean }>(questions3, function(
|
||||
answers
|
||||
) {
|
||||
output2.push(answers.tvShow);
|
||||
if (answers.askAgain) {
|
||||
ask();
|
||||
} else {
|
||||
console.log( "Your favorite TV Shows:", output2.join(", ") );
|
||||
console.log("Your favorite TV Shows:", output2.join(", "));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -478,14 +513,17 @@ ask();
|
||||
// examples/when.js
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* When example
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
//var inquirer = require("../lib/inquirer");
|
||||
|
||||
interface Answers4 {
|
||||
bacon: boolean;
|
||||
favorite: string;
|
||||
pizza: boolean;
|
||||
}
|
||||
var questions4 = [
|
||||
{
|
||||
type: "confirm",
|
||||
@@ -496,34 +534,34 @@ var questions4 = [
|
||||
type: "input",
|
||||
name: "favorite",
|
||||
message: "Bacon lover, what is your favorite type of bacon?",
|
||||
when: function ( answers: inquirer.Answers ) {
|
||||
return answers['bacon'];
|
||||
when: function(answers: Answers4) {
|
||||
return answers.bacon;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "confirm",
|
||||
name: "pizza",
|
||||
message: "Ok... Do you like pizza?",
|
||||
when: function (answers: inquirer.Answers) {
|
||||
return !likesFood( "bacon" )(answers);
|
||||
when: function(answers: Answers4) {
|
||||
return !likesFood("bacon")(answers);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "favorite",
|
||||
message: "Whew! What is your favorite type of pizza?",
|
||||
when: likesFood( "pizza" )
|
||||
when: likesFood("pizza")
|
||||
}
|
||||
];
|
||||
|
||||
function likesFood ( aFood: string ) {
|
||||
return function ( answers: inquirer.Answers ) {
|
||||
return answers[ aFood ];
|
||||
}
|
||||
function likesFood(aFood: string) {
|
||||
return function(answers: inquirer.Answers) {
|
||||
return answers[aFood];
|
||||
};
|
||||
}
|
||||
|
||||
inquirer.prompt(questions, function (answers) {
|
||||
console.log( JSON.stringify(answers, null, " ") );
|
||||
inquirer.prompt<Answers4>(questions, function(answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
});
|
||||
|
||||
// immutable usage
|
||||
|
||||
Vendored
+7
-3
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Jest 22.1
|
||||
// Type definitions for Jest 22.2
|
||||
// Project: http://facebook.github.io/jest/
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// Ivo Stratev <https://github.com/NoHomey>
|
||||
@@ -527,16 +527,20 @@ declare namespace jest {
|
||||
} & T;
|
||||
|
||||
interface MockInstance<T> {
|
||||
getMockName(): string;
|
||||
mock: MockContext<T>;
|
||||
mockClear(): void;
|
||||
mockReset(): void;
|
||||
mockImplementation(fn: (...args: any[]) => any): Mock<T>;
|
||||
mockImplementationOnce(fn: (...args: any[]) => any): Mock<T>;
|
||||
mockName(name: string): Mock<T>;
|
||||
mockReturnThis(): Mock<T>;
|
||||
mockReturnValue(value: any): Mock<T>;
|
||||
mockReturnValueOnce(value: any): Mock<T>;
|
||||
mockName(name: string): Mock<T>;
|
||||
getMockName(): string;
|
||||
mockResolvedValue(value: any): Mock<T>;
|
||||
mockResolvedValueOnce(value: any): Mock<T>;
|
||||
mockRejectedValue(value: any): Mock<T>;
|
||||
mockRejectedValueOnce(value: any): Mock<T>;
|
||||
}
|
||||
|
||||
interface MockContext<T> {
|
||||
|
||||
@@ -309,7 +309,7 @@ describe('missing tests', () => {
|
||||
expect(spy).lastCalledWith('jest');
|
||||
expect(spy).toBeCalledWith('jest');
|
||||
expect(jest.isMockFunction(spy)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('tests all missing Mocks functionality', () => {
|
||||
type FruitsGetter = () => string[];
|
||||
@@ -328,6 +328,35 @@ describe('missing tests', () => {
|
||||
expect(thisMock()).toBe(this);
|
||||
});
|
||||
|
||||
it('async test with mockResolvedValue and mockResolvedValueOnce', async () => {
|
||||
const asyncMock = jest
|
||||
.fn()
|
||||
.mockResolvedValue('default')
|
||||
.mockResolvedValueOnce('first call')
|
||||
.mockResolvedValueOnce('second call');
|
||||
|
||||
await asyncMock(); // first call
|
||||
await asyncMock(); // second call
|
||||
await asyncMock(); // default
|
||||
await asyncMock(); // default
|
||||
});
|
||||
|
||||
it('async test with mockRejectedValue', async () => {
|
||||
const asyncMock = jest.fn().mockRejectedValue(new Error('Async error'));
|
||||
|
||||
await asyncMock(); // throws "Async error"
|
||||
});
|
||||
|
||||
it('async test with mockResolvedValueOnce and mockRejectedValueOnce', async () => {
|
||||
const asyncMock = jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce('first call')
|
||||
.mockRejectedValueOnce(new Error('Async error'));
|
||||
|
||||
await asyncMock(); // first call
|
||||
await asyncMock(); // throws "Async error"
|
||||
});
|
||||
|
||||
it('tests mock name functionality', () => {
|
||||
const mock: jest.Mock = jest.fn();
|
||||
mock.mockName('Carrot');
|
||||
@@ -339,27 +368,27 @@ describe('missing tests', () => {
|
||||
const render: () => string = require('./render');
|
||||
expect(render()).toMatch(/Link/);
|
||||
jest.enableAutomock();
|
||||
});
|
||||
});
|
||||
|
||||
it('runs only pending timers', () => {
|
||||
jest.useRealTimers();
|
||||
setTimeout(() => expect(1).not.toEqual(0), 3000);
|
||||
jest.runOnlyPendingTimers().runTimersToTime(300);
|
||||
});
|
||||
});
|
||||
|
||||
it('runs all timers', () => {
|
||||
jest.clearAllTimers();
|
||||
jest.useFakeTimers();
|
||||
setTimeout(() => expect(0).not.toEqual(1), 3000);
|
||||
jest.runAllTimers();
|
||||
});
|
||||
});
|
||||
|
||||
it('cleares cache', () => {
|
||||
const sum1 = require('../sum');
|
||||
jest.resetModules();
|
||||
const sum2 = require('../sum');
|
||||
expect(sum1).not.toBe(sum2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('toMatchSnapshot', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as jq from 'jquery/dist/jquery.slim';
|
||||
import jq = require('jquery/dist/jquery.slim');
|
||||
|
||||
const $window = jq(window);
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as jq from 'jquery';
|
||||
import jq = require('jquery');
|
||||
|
||||
const $window = jq(window);
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
|
||||
Vendored
+166
@@ -0,0 +1,166 @@
|
||||
// Type definitions for js-money 0.6
|
||||
// Project: https://github.com/davidkalosi/js-money
|
||||
// Definitions by: Kanat Kubash <https://github.com/kanatkubash>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Currency } from './lib/currency';
|
||||
|
||||
interface MoneyObjectOut {
|
||||
amount: number;
|
||||
currency: string;
|
||||
}
|
||||
|
||||
type Rounders = 'round' | 'floor' | 'ceil';
|
||||
|
||||
type RoundFunction = (num: number) => number;
|
||||
|
||||
declare class Money {
|
||||
constructor(amount: number, currency: string | Currency);
|
||||
amount: number;
|
||||
currency: string;
|
||||
static fromInteger(amount: number, currency: string | Currency): Money;
|
||||
static fromDecimal(amount: number, currency: string | Currency, rounder?: Rounders | RoundFunction): Money;
|
||||
equals(other: Money): boolean;
|
||||
add(other: Money): Money;
|
||||
subtract(other: Money): Money;
|
||||
multiply(multiplier: number, rounder?: RoundFunction): Money;
|
||||
divide(divisor: number, rounder?: RoundFunction): Money;
|
||||
allocate(ratios: number[]): Money[];
|
||||
compare(other: Money): number;
|
||||
greaterThan(other: Money): boolean;
|
||||
greaterThanOrEqual(other: Money): boolean;
|
||||
lessThan(other: Money): boolean;
|
||||
lessThanOrEqual(other: Money): boolean;
|
||||
isZero(): boolean;
|
||||
isPositive(): boolean;
|
||||
isNegative(): boolean;
|
||||
toDecimal(): number;
|
||||
toString(): string;
|
||||
toJSON(): MoneyObjectOut;
|
||||
getAmount(): number;
|
||||
getCurrency(): string;
|
||||
//#region Currencies
|
||||
static USD: Currency;
|
||||
static CAD: Currency;
|
||||
static EUR: Currency;
|
||||
static BTC: Currency;
|
||||
static AED: Currency;
|
||||
static AFN: Currency;
|
||||
static ALL: Currency;
|
||||
static AMD: Currency;
|
||||
static ARS: Currency;
|
||||
static AUD: Currency;
|
||||
static AZN: Currency;
|
||||
static BAM: Currency;
|
||||
static BDT: Currency;
|
||||
static BGN: Currency;
|
||||
static BHD: Currency;
|
||||
static BIF: Currency;
|
||||
static BND: Currency;
|
||||
static BOB: Currency;
|
||||
static BRL: Currency;
|
||||
static BWP: Currency;
|
||||
static BYR: Currency;
|
||||
static BZD: Currency;
|
||||
static CDF: Currency;
|
||||
static CHF: Currency;
|
||||
static CLP: Currency;
|
||||
static CNY: Currency;
|
||||
static COP: Currency;
|
||||
static CRC: Currency;
|
||||
static CVE: Currency;
|
||||
static CZK: Currency;
|
||||
static DJF: Currency;
|
||||
static DKK: Currency;
|
||||
static DOP: Currency;
|
||||
static DZD: Currency;
|
||||
static EEK: Currency;
|
||||
static EGP: Currency;
|
||||
static ERN: Currency;
|
||||
static ETB: Currency;
|
||||
static GBP: Currency;
|
||||
static GEL: Currency;
|
||||
static GHS: Currency;
|
||||
static GNF: Currency;
|
||||
static GTQ: Currency;
|
||||
static HKD: Currency;
|
||||
static HNL: Currency;
|
||||
static HRK: Currency;
|
||||
static HUF: Currency;
|
||||
static IDR: Currency;
|
||||
static ILS: Currency;
|
||||
static INR: Currency;
|
||||
static IQD: Currency;
|
||||
static IRR: Currency;
|
||||
static ISK: Currency;
|
||||
static JMD: Currency;
|
||||
static JOD: Currency;
|
||||
static JPY: Currency;
|
||||
static KES: Currency;
|
||||
static KHR: Currency;
|
||||
static KMF: Currency;
|
||||
static KRW: Currency;
|
||||
static KWD: Currency;
|
||||
static KZT: Currency;
|
||||
static LAK: Currency;
|
||||
static LBP: Currency;
|
||||
static LKR: Currency;
|
||||
static LTL: Currency;
|
||||
static LVL: Currency;
|
||||
static LYD: Currency;
|
||||
static MAD: Currency;
|
||||
static MDL: Currency;
|
||||
static MGA: Currency;
|
||||
static MKD: Currency;
|
||||
static MMK: Currency;
|
||||
static MOP: Currency;
|
||||
static MUR: Currency;
|
||||
static MXN: Currency;
|
||||
static MYR: Currency;
|
||||
static MZN: Currency;
|
||||
static NAD: Currency;
|
||||
static NGN: Currency;
|
||||
static NIO: Currency;
|
||||
static NOK: Currency;
|
||||
static NPR: Currency;
|
||||
static NZD: Currency;
|
||||
static OMR: Currency;
|
||||
static PAB: Currency;
|
||||
static PEN: Currency;
|
||||
static PHP: Currency;
|
||||
static PKR: Currency;
|
||||
static PLN: Currency;
|
||||
static PYG: Currency;
|
||||
static QAR: Currency;
|
||||
static RON: Currency;
|
||||
static RSD: Currency;
|
||||
static RUB: Currency;
|
||||
static RWF: Currency;
|
||||
static SAR: Currency;
|
||||
static SDG: Currency;
|
||||
static SEK: Currency;
|
||||
static SGD: Currency;
|
||||
static SOS: Currency;
|
||||
static SYP: Currency;
|
||||
static THB: Currency;
|
||||
static TND: Currency;
|
||||
static TOP: Currency;
|
||||
static TRY: Currency;
|
||||
static TTD: Currency;
|
||||
static TWD: Currency;
|
||||
static TZS: Currency;
|
||||
static UAH: Currency;
|
||||
static UGX: Currency;
|
||||
static UYU: Currency;
|
||||
static UZS: Currency;
|
||||
static VEF: Currency;
|
||||
static VND: Currency;
|
||||
static XAF: Currency;
|
||||
static XOF: Currency;
|
||||
static YER: Currency;
|
||||
static ZAR: Currency;
|
||||
static ZMK: Currency;
|
||||
//#endregion
|
||||
}
|
||||
|
||||
export = Money;
|
||||
@@ -0,0 +1,63 @@
|
||||
import Money = require('js-money');
|
||||
import * as CurrencyObjects from 'js-money/lib/currency';
|
||||
|
||||
const money = new Money(1500, 'USD');
|
||||
const other = new Money(100, Money.THB);
|
||||
|
||||
// instance method checks
|
||||
new Money(123, Money.TRY); // $ExpectType Money
|
||||
new Money(1500, 'USD'); // $ExpectType Money
|
||||
money.amount; // $ExpectType number
|
||||
money.currency; // $ExpectType string
|
||||
money.equals(other); // $ExpectType boolean
|
||||
money.add(other); // $ExpectType Money
|
||||
money.subtract(other); // $ExpectType Money
|
||||
money.multiply(1); // $ExpectType Money
|
||||
money.multiply(2, Math.round); // $ExpectType Money
|
||||
money.divide(1); // $ExpectType Money
|
||||
money.divide(1, Math.ceil); // $ExpectType Money
|
||||
money.allocate([1, 2, 3]); // $ExpectType Money[]
|
||||
money.compare(other); // $ExpectType number
|
||||
money.greaterThan(other); // $ExpectType boolean
|
||||
money.greaterThanOrEqual(other); // $ExpectType boolean
|
||||
money.lessThan(other); // $ExpectType boolean
|
||||
money.lessThanOrEqual(other); // $ExpectType boolean
|
||||
money.isZero(); // $ExpectType boolean
|
||||
money.isPositive(); // $ExpectType boolean
|
||||
money.isNegative(); // $ExpectType boolean
|
||||
money.toDecimal(); // $ExpectType number
|
||||
money.toString(); // $ExpectType string
|
||||
money.toJSON(); // $ExpectType MoneyObjectOut
|
||||
money.toJSON().amount; // $ExpectType number
|
||||
money.toJSON().currency; // $ExpectType string
|
||||
money.getAmount(); // $ExpectType number
|
||||
money.getCurrency(); // $ExpectType string
|
||||
|
||||
// static method checks
|
||||
Money.fromInteger(100, 'USD'); // $ExpectType Money
|
||||
Money.fromDecimal(100, Money.KZT, 'ceil'); // $ExpectType Money
|
||||
Money.fromDecimal(100, Money.KZT); // $ExpectType Money
|
||||
Money.fromDecimal(100, Money.KZT, Math.ceil); // $ExpectType Money
|
||||
|
||||
// static properties (currency) check
|
||||
Money.KZT; // $ExpectType Currency
|
||||
Money.RUB; // $ExpectType Currency
|
||||
Money.BLABLA; // $ExpectError
|
||||
// currency object check
|
||||
Money.RUB.code; // $ExpectType string
|
||||
Money.RUB.decimal_digits; // $ExpectType number
|
||||
Money.RUB.name; // $ExpectType string
|
||||
Money.RUB.name_plural; // $ExpectType string
|
||||
Money.RUB.rounding; // $ExpectType number
|
||||
Money.RUB.symbol; // $ExpectType string
|
||||
Money.RUB.symbol_native; // $ExpectType string
|
||||
|
||||
// Currency module check
|
||||
CurrencyObjects.NIO.code; // $ExpectType string
|
||||
CurrencyObjects.NIO.decimal_digits; // $ExpectType number
|
||||
CurrencyObjects.NIO.name; // $ExpectType string
|
||||
CurrencyObjects.NIO.name_plural; // $ExpectType string
|
||||
CurrencyObjects.NIO.rounding; // $ExpectType number
|
||||
CurrencyObjects.NIO.symbol; // $ExpectType string
|
||||
CurrencyObjects.NIO.symbol_native; // $ExpectType string
|
||||
CurrencyObjects['UAH'].code; // $ExpectType string
|
||||
Vendored
+142
@@ -0,0 +1,142 @@
|
||||
// Type definitions for js-money 0.6
|
||||
// Project: https://github.com/davidkalosi/js-money#readme
|
||||
// Definitions by: Kanat Kubash <https://github.com/kanatkubash>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Currencies {
|
||||
interface Currency {
|
||||
symbol: string;
|
||||
name: string;
|
||||
symbol_native: string;
|
||||
decimal_digits: number;
|
||||
rounding: number;
|
||||
code: string;
|
||||
name_plural: string;
|
||||
}
|
||||
interface Currencies {
|
||||
[key: string]: Currencies.Currency;
|
||||
USD: Currencies.Currency;
|
||||
CAD: Currencies.Currency;
|
||||
EUR: Currencies.Currency;
|
||||
BTC: Currencies.Currency;
|
||||
AED: Currencies.Currency;
|
||||
AFN: Currencies.Currency;
|
||||
ALL: Currencies.Currency;
|
||||
AMD: Currencies.Currency;
|
||||
ARS: Currencies.Currency;
|
||||
AUD: Currencies.Currency;
|
||||
AZN: Currencies.Currency;
|
||||
BAM: Currencies.Currency;
|
||||
BDT: Currencies.Currency;
|
||||
BGN: Currencies.Currency;
|
||||
BHD: Currencies.Currency;
|
||||
BIF: Currencies.Currency;
|
||||
BND: Currencies.Currency;
|
||||
BOB: Currencies.Currency;
|
||||
BRL: Currencies.Currency;
|
||||
BWP: Currencies.Currency;
|
||||
BYR: Currencies.Currency;
|
||||
BZD: Currencies.Currency;
|
||||
CDF: Currencies.Currency;
|
||||
CHF: Currencies.Currency;
|
||||
CLP: Currencies.Currency;
|
||||
CNY: Currencies.Currency;
|
||||
COP: Currencies.Currency;
|
||||
CRC: Currencies.Currency;
|
||||
CVE: Currencies.Currency;
|
||||
CZK: Currencies.Currency;
|
||||
DJF: Currencies.Currency;
|
||||
DKK: Currencies.Currency;
|
||||
DOP: Currencies.Currency;
|
||||
DZD: Currencies.Currency;
|
||||
EEK: Currencies.Currency;
|
||||
EGP: Currencies.Currency;
|
||||
ERN: Currencies.Currency;
|
||||
ETB: Currencies.Currency;
|
||||
GBP: Currencies.Currency;
|
||||
GEL: Currencies.Currency;
|
||||
GHS: Currencies.Currency;
|
||||
GNF: Currencies.Currency;
|
||||
GTQ: Currencies.Currency;
|
||||
HKD: Currencies.Currency;
|
||||
HNL: Currencies.Currency;
|
||||
HRK: Currencies.Currency;
|
||||
HUF: Currencies.Currency;
|
||||
IDR: Currencies.Currency;
|
||||
ILS: Currencies.Currency;
|
||||
INR: Currencies.Currency;
|
||||
IQD: Currencies.Currency;
|
||||
IRR: Currencies.Currency;
|
||||
ISK: Currencies.Currency;
|
||||
JMD: Currencies.Currency;
|
||||
JOD: Currencies.Currency;
|
||||
JPY: Currencies.Currency;
|
||||
KES: Currencies.Currency;
|
||||
KHR: Currencies.Currency;
|
||||
KMF: Currencies.Currency;
|
||||
KRW: Currencies.Currency;
|
||||
KWD: Currencies.Currency;
|
||||
KZT: Currencies.Currency;
|
||||
LAK: Currencies.Currency;
|
||||
LBP: Currencies.Currency;
|
||||
LKR: Currencies.Currency;
|
||||
LTL: Currencies.Currency;
|
||||
LVL: Currencies.Currency;
|
||||
LYD: Currencies.Currency;
|
||||
MAD: Currencies.Currency;
|
||||
MDL: Currencies.Currency;
|
||||
MGA: Currencies.Currency;
|
||||
MKD: Currencies.Currency;
|
||||
MMK: Currencies.Currency;
|
||||
MOP: Currencies.Currency;
|
||||
MUR: Currencies.Currency;
|
||||
MXN: Currencies.Currency;
|
||||
MYR: Currencies.Currency;
|
||||
MZN: Currencies.Currency;
|
||||
NAD: Currencies.Currency;
|
||||
NGN: Currencies.Currency;
|
||||
NIO: Currencies.Currency;
|
||||
NOK: Currencies.Currency;
|
||||
NPR: Currencies.Currency;
|
||||
NZD: Currencies.Currency;
|
||||
OMR: Currencies.Currency;
|
||||
PAB: Currencies.Currency;
|
||||
PEN: Currencies.Currency;
|
||||
PHP: Currencies.Currency;
|
||||
PKR: Currencies.Currency;
|
||||
PLN: Currencies.Currency;
|
||||
PYG: Currencies.Currency;
|
||||
QAR: Currencies.Currency;
|
||||
RON: Currencies.Currency;
|
||||
RSD: Currencies.Currency;
|
||||
RUB: Currencies.Currency;
|
||||
RWF: Currencies.Currency;
|
||||
SAR: Currencies.Currency;
|
||||
SDG: Currencies.Currency;
|
||||
SEK: Currencies.Currency;
|
||||
SGD: Currencies.Currency;
|
||||
SOS: Currencies.Currency;
|
||||
SYP: Currencies.Currency;
|
||||
THB: Currencies.Currency;
|
||||
TND: Currencies.Currency;
|
||||
TOP: Currencies.Currency;
|
||||
TRY: Currencies.Currency;
|
||||
TTD: Currencies.Currency;
|
||||
TWD: Currencies.Currency;
|
||||
TZS: Currencies.Currency;
|
||||
UAH: Currencies.Currency;
|
||||
UGX: Currencies.Currency;
|
||||
UYU: Currencies.Currency;
|
||||
UZS: Currencies.Currency;
|
||||
VEF: Currencies.Currency;
|
||||
VND: Currencies.Currency;
|
||||
XAF: Currencies.Currency;
|
||||
XOF: Currencies.Currency;
|
||||
YER: Currencies.Currency;
|
||||
ZAR: Currencies.Currency;
|
||||
ZMK: Currencies.Currency;
|
||||
}
|
||||
}
|
||||
|
||||
declare var Currencies: Currencies.Currencies;
|
||||
export = Currencies;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"strictFunctionTypes": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"js-money-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for js-string-escape 1.0
|
||||
// Project: https://github.com/joliss/js-string-escape
|
||||
// Definitions by: Jamie Davies <https://github.com/viralpickaxe>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function jsStringEscape(str: string): string;
|
||||
|
||||
export = jsStringEscape;
|
||||
@@ -0,0 +1,3 @@
|
||||
import jsStringEscape = require('js-string-escape');
|
||||
|
||||
jsStringEscape('hello world');
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"js-string-escape-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+108
@@ -0,0 +1,108 @@
|
||||
export declare namespace json2csv {
|
||||
export interface FieldValueCallback<T> {
|
||||
(row: T, field: string): string;
|
||||
}
|
||||
|
||||
export interface FieldInfo<T> {
|
||||
label: string;
|
||||
default?: string;
|
||||
value?: string | FieldValueCallback<T>;
|
||||
}
|
||||
|
||||
export interface Options<T> {
|
||||
fields?: (string | FieldInfo<T>);
|
||||
ndjson?: boolean;
|
||||
unwind?: string | string[];
|
||||
flatten?: boolean;
|
||||
defaultValue?: string;
|
||||
quote?: string;
|
||||
doubleQuote?: string;
|
||||
delimiter?: string;
|
||||
eol?: string;
|
||||
excelStrings?: boolean;
|
||||
header?: boolean;
|
||||
includeEmptyRows?: boolean;
|
||||
withBOM?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare abstract class JSON2CSVBase<T> {
|
||||
constructor(opts?: json2csv.Options<T>);
|
||||
|
||||
/**
|
||||
* Check passing opts and set defaults.
|
||||
*
|
||||
* @param {json2csv.Options} opts Options object containing fields,
|
||||
* delimiter, default value, quote mark, header, etc.
|
||||
* @returns {json2csv.Options} preprocessed Options object
|
||||
*/
|
||||
protected preprocessOpts(opts?: json2csv.Options<T>) : json2csv.Options<T>;
|
||||
|
||||
/**
|
||||
* Create the title row with all the provided fields as column headings
|
||||
*
|
||||
* @returns {string} titles as a string
|
||||
*/
|
||||
protected getHeader(): string;
|
||||
|
||||
/**
|
||||
* Preprocess each object according to the give opts (unwind, flatten, etc.).
|
||||
*
|
||||
* @param {object} row JSON object to be converted in a CSV row
|
||||
*/
|
||||
protected preprocessRow(row: T): object;
|
||||
|
||||
/**
|
||||
* Create the content of a specific CSV row
|
||||
*
|
||||
* @param {object} row JSON object to be converted in a CSV row
|
||||
* @returns {string} CSV string (row)
|
||||
*/
|
||||
protected processRow(row: T): string;
|
||||
|
||||
/**
|
||||
* Create the content of a specfic CSV row cell
|
||||
*
|
||||
* @param {object} row JSON object representing the CSV row that the cell belongs to
|
||||
* @param {object} fieldInfo Details of the field to process to be a CSV cell
|
||||
* @returns {string} CSV string (cell)
|
||||
*/
|
||||
protected processCell(row: T, fieldInfo: json2csv.FieldInfo<T>) : string;
|
||||
|
||||
/**
|
||||
* Create the content of a specfic CSV row cell
|
||||
*
|
||||
* @param {object} row JSON object representing the CSV row that the cell belongs to
|
||||
* @param {json2csv.FieldInfo} fieldInfo Details of the field to process to be a CSV cell
|
||||
* @returns {any} Field value
|
||||
*/
|
||||
protected getValue(row: T, fieldInfo: json2csv.FieldInfo<T>): any;
|
||||
|
||||
/**
|
||||
* Create the content of a specfic CSV row cell
|
||||
*
|
||||
* @param {any} value Value to be included in a CSV cell
|
||||
* @param {Boolean} stringify Details of the field to process to be a CSV cell
|
||||
* @returns {string} Value stringified and processed
|
||||
*/
|
||||
protected processValue(value: any, stringify: Boolean): string;
|
||||
|
||||
/**
|
||||
* Performs the flattening of a data row recursively
|
||||
*
|
||||
* @param {object} dataRow Original JSON object
|
||||
* @returns {object} Flattened object
|
||||
*/
|
||||
protected flatten(dataRow: T): object;
|
||||
|
||||
/**
|
||||
* Performs the unwind recursively in specified sequence
|
||||
*
|
||||
* @param {object[]} dataRow Original JSON object
|
||||
* @param {string[]} unwindPaths The paths as strings to be used to deconstruct the array
|
||||
* @returns {Array} Array of objects containing all rows after unwind of chosen paths
|
||||
*/
|
||||
protected unwindData(dataRow: Array<T>, unwindPaths: Array<string>): Array<object>;
|
||||
}
|
||||
|
||||
export default JSON2CSVBase;
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
import JSON2CSVBase from './JSON2CSVBase';
|
||||
|
||||
declare class JSON2CSVParser<T> extends JSON2CSVBase<T> {
|
||||
/**
|
||||
* Main function that converts json to csv.
|
||||
*
|
||||
* @param {object|object[]} data Array of JSON objects to be converted to CSV
|
||||
* @returns {string} The CSV formated data as a string
|
||||
*/
|
||||
public parse(data: Readonly<T> | ReadonlyArray<T>): string;
|
||||
|
||||
/**
|
||||
* Preprocess the data according to the give opts (unwind, flatten, etc.)
|
||||
and calculate the fields and field names if they are not provided.
|
||||
*
|
||||
* @param {object|object[]} data Array or object to be converted to CSV
|
||||
* @returns {object[]} Preprocessed data ready to be processed
|
||||
*/
|
||||
protected preprocessData(data: T | Array<T>): Array<T>;
|
||||
|
||||
/**
|
||||
* Create the content row by row below the header
|
||||
*
|
||||
* @param {object[]} data Array of JSON objects to be converted to CSV
|
||||
* @returns {string} CSV string (body)
|
||||
*/
|
||||
protected processData(data: Array<T>): string;
|
||||
}
|
||||
|
||||
export default JSON2CSVParser;
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import { json2csv } from './JSON2CSVBase';
|
||||
import JSON2CSVBase from './JSON2CSVBase';
|
||||
import { Transform, TransformOptions } from 'stream';
|
||||
|
||||
declare class JSON2CSVTransform<T> extends Transform { // implements JSON2CSVBase<T>
|
||||
constructor(opts?: json2csv.Options<T>, transformOpts?: TransformOptions);
|
||||
|
||||
/**
|
||||
* Transforms an incoming json data to csv and pushes it downstream.
|
||||
*
|
||||
* @param {object} data JSON object to be converted in a CSV row
|
||||
*/
|
||||
protected pushLine(data: T): void;
|
||||
|
||||
/*******************************************************************************
|
||||
* Everything below is copy-pasted from JSON2CSVBase and should be keep in sync *
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* Check passing opts and set defaults.
|
||||
*
|
||||
* @param {json2csv.Options} opts Options object containing fields,
|
||||
* delimiter, default value, quote mark, header, etc.
|
||||
* @returns {json2csv.Options} preprocessed Options object
|
||||
*/
|
||||
protected preprocessOpts(opts?: json2csv.Options<T>) : json2csv.Options<T>;
|
||||
|
||||
/**
|
||||
* Create the title row with all the provided fields as column headings
|
||||
*
|
||||
* @returns {string} titles as a string
|
||||
*/
|
||||
protected getHeader(): string;
|
||||
|
||||
/**
|
||||
* Preprocess each object according to the give opts (unwind, flatten, etc.).
|
||||
*
|
||||
* @param {object} row JSON object to be converted in a CSV row
|
||||
*/
|
||||
protected preprocessRow(row: T): object;
|
||||
|
||||
/**
|
||||
* Create the content of a specific CSV row
|
||||
*
|
||||
* @param {object} row JSON object to be converted in a CSV row
|
||||
* @returns {string} CSV string (row)
|
||||
*/
|
||||
protected processRow(row: T): string;
|
||||
|
||||
/**
|
||||
* Create the content of a specfic CSV row cell
|
||||
*
|
||||
* @param {object} row JSON object representing the CSV row that the cell belongs to
|
||||
* @param {object} fieldInfo Details of the field to process to be a CSV cell
|
||||
* @returns {string} CSV string (cell)
|
||||
*/
|
||||
protected processCell(row: T, fieldInfo: json2csv.FieldInfo<T>) : string;
|
||||
|
||||
/**
|
||||
* Create the content of a specfic CSV row cell
|
||||
*
|
||||
* @param {object} row JSON object representing the CSV row that the cell belongs to
|
||||
* @param {json2csv.FieldInfo} fieldInfo Details of the field to process to be a CSV cell
|
||||
* @returns {any} Field value
|
||||
*/
|
||||
protected getValue(row: T, fieldInfo: json2csv.FieldInfo<T>): any;
|
||||
|
||||
/**
|
||||
* Create the content of a specfic CSV row cell
|
||||
*
|
||||
* @param {any} value Value to be included in a CSV cell
|
||||
* @param {Boolean} stringify Details of the field to process to be a CSV cell
|
||||
* @returns {string} Value stringified and processed
|
||||
*/
|
||||
protected processValue(value: any, stringify: Boolean): string;
|
||||
|
||||
/**
|
||||
* Performs the flattening of a data row recursively
|
||||
*
|
||||
* @param {object} dataRow Original JSON object
|
||||
* @returns {object} Flattened object
|
||||
*/
|
||||
protected flatten(dataRow: T): object;
|
||||
|
||||
/**
|
||||
* Performs the unwind recursively in specified sequence
|
||||
*
|
||||
* @param {object[]} dataRow Original JSON object
|
||||
* @param {string[]} unwindPaths The paths as strings to be used to deconstruct the array
|
||||
* @returns {Array} Array of objects containing all rows after unwind of chosen paths
|
||||
*/
|
||||
protected unwindData(dataRow: Array<T>, unwindPaths: Array<string>): Array<object>;
|
||||
}
|
||||
|
||||
export default JSON2CSVTransform;
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// Type definitions for json2csv 4.0
|
||||
// Project: https://github.com/zemirco/json2csv
|
||||
// Definitions by: Juanjo Diaz <https://github.com/juanjoDiaz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { json2csv } from './JSON2CSVBase';
|
||||
import JSON2CSVParser from './JSON2CSVParser';
|
||||
import JSON2CSVTransform from './JSON2CSVTransform';
|
||||
|
||||
export {
|
||||
json2csv,
|
||||
JSON2CSVParser as Parser,
|
||||
JSON2CSVTransform as Transform
|
||||
};
|
||||
|
||||
// Convenience method to keep the API similar to version 3.X
|
||||
export function parse<T>(data: Readonly<T> | ReadonlyArray<T>, opts?: json2csv.Options<T>): string;
|
||||
@@ -0,0 +1,98 @@
|
||||
import { json2csv, parse, Parser, Transform } from 'json2csv';
|
||||
import { Transform as NodeTransform } from 'stream';
|
||||
|
||||
let s: string;
|
||||
let obj: object;
|
||||
|
||||
interface ExampleObj {
|
||||
str?: string;
|
||||
num?: number;
|
||||
obj?: object;
|
||||
}
|
||||
|
||||
/**************
|
||||
* Public API *
|
||||
**************/
|
||||
parse({});
|
||||
parse([]);
|
||||
parse({}, {});
|
||||
|
||||
new Parser();
|
||||
const parser: Parser<ExampleObj> = new Parser({});
|
||||
s = parser.parse({ str: '', num: 1, obj: {} });
|
||||
parser.parse([]);
|
||||
const transform: Transform<ExampleObj> = new Transform<ExampleObj>({ quote: '' });
|
||||
const nodeTransform: NodeTransform = transform;
|
||||
|
||||
/********************
|
||||
* Internal Methods *
|
||||
********************/
|
||||
class ParserExt extends Parser<ExampleObj> {
|
||||
constructor() {
|
||||
super();
|
||||
// Parser methods
|
||||
obj = this.preprocessData({});
|
||||
obj = this.preprocessData({ str: '', num: 1, obj: {} });
|
||||
obj = this.preprocessData([]);
|
||||
s = this.processData([]);
|
||||
|
||||
// JSON2CSVBase methods
|
||||
let opts: json2csv.Options<ExampleObj>;
|
||||
opts = this.preprocessOpts();
|
||||
opts = this.preprocessOpts(opts);
|
||||
s = this.getHeader();
|
||||
obj = this.preprocessRow({});
|
||||
obj = this.preprocessRow({ str: '', num: 1, obj: {} });
|
||||
s = this.processRow({});
|
||||
s = this.processRow({ str: '', num: 1, obj: {} });
|
||||
s = this.processCell({}, { label: 'test', default: 'test2', value: 'field' });
|
||||
s = this.processCell({ str: '', num: 1, obj: {} }, { label: 'test', default: 'test2', value: 'field' });
|
||||
s = this.processCell({}, { label: 'test', default: 'test2', value: (row: object, field: string) => 'string' });
|
||||
s = this.processCell({ str: '', num: 1, obj: {} }, { label: 'test', default: 'test2', value: (row: object, field: string) => 'string' });
|
||||
this.getValue({}, { label: 'test' });
|
||||
this.getValue({ str: '', num: 1, obj: {} }, { label: 'test' });
|
||||
s = this.processValue(undefined, true);
|
||||
s = this.processValue(null, true);
|
||||
s = this.processValue(1, true);
|
||||
s = this.processValue('test', true);
|
||||
s = this.processValue(new Date(), true);
|
||||
s = this.processValue({}, true);
|
||||
s = this.processValue([], true);
|
||||
const flattenedData: object = this.flatten({});
|
||||
const unwindedData: object[] = this.unwindData([], []);
|
||||
}
|
||||
}
|
||||
|
||||
class TransformExt extends Transform<ExampleObj> {
|
||||
constructor() {
|
||||
super();
|
||||
// Transform methods
|
||||
this.pushLine({});
|
||||
this.pushLine({ str: '', num: 1, obj: {} });
|
||||
|
||||
// JSON2CSVBase methods
|
||||
let opts: json2csv.Options<ExampleObj>;
|
||||
opts = this.preprocessOpts();
|
||||
opts = this.preprocessOpts(opts);
|
||||
s = this.getHeader();
|
||||
obj = this.preprocessRow({});
|
||||
obj = this.preprocessRow({ str: '', num: 1, obj: {} });
|
||||
s = this.processRow({});
|
||||
s = this.processRow({ str: '', num: 1, obj: {} });
|
||||
s = this.processCell({}, { label: 'test', default: 'test2', value: 'field' });
|
||||
s = this.processCell({ str: '', num: 1, obj: {} }, { label: 'test', default: 'test2', value: 'field' });
|
||||
s = this.processCell({}, { label: 'test', default: 'test2', value: (row: object, field: string) => 'string' });
|
||||
s = this.processCell({ str: '', num: 1, obj: {} }, { label: 'test', default: 'test2', value: (row: object, field: string) => 'string' });
|
||||
this.getValue({}, { label: 'test' });
|
||||
this.getValue({ str: '', num: 1, obj: {} }, { label: 'test' });
|
||||
s = this.processValue(undefined, true);
|
||||
s = this.processValue(null, true);
|
||||
s = this.processValue(1, true);
|
||||
s = this.processValue('test', true);
|
||||
s = this.processValue(new Date(), true);
|
||||
s = this.processValue({}, true);
|
||||
s = this.processValue([], true);
|
||||
const flattenedData: object = this.flatten({});
|
||||
const unwindedData: object[] = this.unwindData([], []);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"json2csv-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+28
@@ -182,6 +182,10 @@ export class Point {
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface Coords extends Point {
|
||||
z: number;
|
||||
}
|
||||
|
||||
export type PointExpression = Point | PointTuple;
|
||||
|
||||
export function point(x: number, y: number, round?: boolean): Point;
|
||||
@@ -420,6 +424,8 @@ export class Layer extends Evented {
|
||||
getEvents?(): {[name: string]: (event: LeafletEvent) => void};
|
||||
getAttribution?(): string | null;
|
||||
beforeAdd?(map: Map): this;
|
||||
|
||||
protected _map: Map;
|
||||
}
|
||||
|
||||
export interface GridLayerOptions {
|
||||
@@ -439,6 +445,19 @@ export interface GridLayerOptions {
|
||||
keepBuffer?: number;
|
||||
}
|
||||
|
||||
export type DoneCallback = (error?: Error, tile?: HTMLElement) => void;
|
||||
|
||||
export interface InternalTiles {
|
||||
[key: string]: {
|
||||
active?: boolean,
|
||||
coords: Coords,
|
||||
current: boolean,
|
||||
el: HTMLElement,
|
||||
loaded?: Date,
|
||||
retain?: boolean,
|
||||
};
|
||||
}
|
||||
|
||||
export class GridLayer extends Layer {
|
||||
constructor(options?: GridLayerOptions);
|
||||
bringToFront(): this;
|
||||
@@ -449,6 +468,12 @@ export class GridLayer extends Layer {
|
||||
isLoading(): boolean;
|
||||
redraw(): this;
|
||||
getTileSize(): Point;
|
||||
|
||||
protected createTile(coords: Coords, done: DoneCallback): HTMLElement;
|
||||
protected _tileCoordsToKey(coords: Coords): string;
|
||||
|
||||
protected _tiles: InternalTiles;
|
||||
protected _tileZoom?: number;
|
||||
}
|
||||
|
||||
export function gridLayer(options?: GridLayerOptions): GridLayer;
|
||||
@@ -472,6 +497,9 @@ export class TileLayer extends GridLayer {
|
||||
constructor(urlTemplate: string, options?: TileLayerOptions);
|
||||
setUrl(url: string, noRedraw?: boolean): this;
|
||||
|
||||
protected _abortLoading(): void;
|
||||
protected _getZoomForUrl(): number;
|
||||
|
||||
options: TileLayerOptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -510,3 +510,50 @@ lg = new L.LayerGroup([new L.Layer(), new L.Layer()], {
|
||||
pane: 'overlayPane',
|
||||
attribution: 'test'
|
||||
});
|
||||
|
||||
// adapted from GridLayer documentation
|
||||
const CanvasLayer = L.GridLayer.extend({
|
||||
createTile(coords: L.Coords, done: L.DoneCallback) {
|
||||
const tile = (L.DomUtil.create('canvas', 'leaflet-tile') as HTMLCanvasElement);
|
||||
const size = this.getTileSize();
|
||||
tile.width = size.x;
|
||||
tile.height = size.y;
|
||||
return tile;
|
||||
}
|
||||
});
|
||||
|
||||
// adapted from GridLayer documentation
|
||||
const AsyncCanvasLayer = L.GridLayer.extend({
|
||||
createTile(coords: L.Coords, done: L.DoneCallback) {
|
||||
const tile = (L.DomUtil.create('canvas', 'leaflet-tile') as HTMLCanvasElement);
|
||||
const size = this.getTileSize();
|
||||
tile.width = size.x;
|
||||
tile.height = size.y;
|
||||
setTimeout(() => done(undefined, tile), 1000);
|
||||
return tile;
|
||||
}
|
||||
});
|
||||
|
||||
export class ExtendedTileLayer extends L.TileLayer {
|
||||
options: L.TileLayerOptions;
|
||||
createTile(coords: L.Coords, done: L.DoneCallback) {
|
||||
const newCoords: L.Coords = (new L.Point(coords.x, coords.y) as L.Coords);
|
||||
newCoords.z = coords.z;
|
||||
return super.createTile(newCoords, done);
|
||||
}
|
||||
_abortLoading() {
|
||||
// adapted from TileLayer's implementation
|
||||
for (const i in this._tiles) {
|
||||
if (this._tiles[i].coords.z !== this._tileZoom) {
|
||||
const tile = this._tiles[i].el;
|
||||
tile.onload = L.Util.falseFn;
|
||||
tile.onerror = L.Util.falseFn;
|
||||
if (tile instanceof HTMLImageElement && !tile.complete) {
|
||||
tile.src = L.Util.emptyImageUrl;
|
||||
L.DomUtil.remove(tile);
|
||||
this._tiles[i] = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Type definitions for listr 0.13
|
||||
// Project: https://github.com/samverschueren/listr#readme
|
||||
// Definitions by: Dusan Radovanovic <https://github.com/durad>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as stream from "stream";
|
||||
|
||||
declare namespace Listr {
|
||||
interface ListrRenderer {
|
||||
nonTTY: boolean;
|
||||
render(): void;
|
||||
end(): void;
|
||||
}
|
||||
|
||||
interface ListrOptions {
|
||||
concurrent?: boolean | number;
|
||||
exitOnError?: boolean;
|
||||
renderer?: "silent" | "default" | "verbose" | ListrRenderer;
|
||||
nonTTYRenderer?: "silent" | "default" | "verbose" | ListrRenderer;
|
||||
}
|
||||
|
||||
interface ListrTask {
|
||||
title: string;
|
||||
output?: string;
|
||||
task: (ctx: any, task: ListrTaskWrapper) => void | string | Promise<any> | stream.Readable | Listr;
|
||||
skip?: (ctx: any, task: ListrTaskWrapper) => boolean | Promise<boolean> | string | void;
|
||||
enabled?: (ctx: any, task: ListrTaskWrapper) => boolean | Promise<boolean>;
|
||||
}
|
||||
|
||||
interface ListrTaskWrapper {
|
||||
title: string;
|
||||
output: any;
|
||||
report(error: Error): void;
|
||||
skip(message: string): void;
|
||||
run(ctx?: any): Promise<any>;
|
||||
}
|
||||
}
|
||||
|
||||
declare class Listr {
|
||||
constructor(tasks?: ReadonlyArray<Listr.ListrTask>, options?: Listr.ListrOptions);
|
||||
constructor(options?: Listr.ListrOptions);
|
||||
add(tasks: Listr.ListrTask | ReadonlyArray<Listr.ListrTask>): void;
|
||||
run(ctx?: any): Promise<any>;
|
||||
}
|
||||
|
||||
export = Listr;
|
||||
@@ -0,0 +1,167 @@
|
||||
import Listr = require("listr");
|
||||
import * as fs from "fs";
|
||||
|
||||
const tasks = new Listr([
|
||||
{
|
||||
title: 'Git',
|
||||
task: () => {
|
||||
return new Listr([
|
||||
{
|
||||
title: 'Checking git status',
|
||||
task: () => new Promise(resolve => resolve())
|
||||
.then(result => {
|
||||
if (result !== '') {
|
||||
throw new Error('Unclean working tree. Commit or stash changes first.');
|
||||
}
|
||||
})
|
||||
},
|
||||
{
|
||||
title: 'Checking remote history',
|
||||
task: () => new Promise(resolve => resolve())
|
||||
.then(result => {
|
||||
if (result !== '0') {
|
||||
throw new Error('Remote history differ. Please pull changes.');
|
||||
}
|
||||
})
|
||||
}
|
||||
],
|
||||
{ concurrent: true });
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Install package dependencies with Yarn',
|
||||
task: (ctx, task) => new Promise(resolve => resolve())
|
||||
.catch(() => {
|
||||
ctx.yarn = false;
|
||||
|
||||
task.skip('Yarn not available, install it via `npm install -g yarn`');
|
||||
})
|
||||
},
|
||||
{
|
||||
title: 'Install package dependencies with npm',
|
||||
enabled: ctx => ctx.yarn === false,
|
||||
task: () => new Promise(resolve => resolve())
|
||||
},
|
||||
{
|
||||
title: 'Run tests',
|
||||
task: () => new Promise(resolve => resolve())
|
||||
},
|
||||
{
|
||||
title: 'Publish package',
|
||||
task: () => new Promise(resolve => resolve())
|
||||
}
|
||||
]);
|
||||
|
||||
tasks.run().catch(err => {
|
||||
});
|
||||
|
||||
const tasks21 = new Listr([
|
||||
{
|
||||
title: 'Success',
|
||||
task: () => 'Foo'
|
||||
},
|
||||
{
|
||||
title: 'Failure',
|
||||
task: () => {
|
||||
throw new Error('Bar');
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
const taskA: Listr.ListrTask = {
|
||||
title: 'Success',
|
||||
task: () => 'Foo'
|
||||
};
|
||||
|
||||
const taskB: Listr.ListrTask = {
|
||||
title: 'Failure',
|
||||
task: () => {
|
||||
throw new Error('Bar');
|
||||
}
|
||||
};
|
||||
|
||||
const tasks22 = new Listr([taskA, taskB]);
|
||||
|
||||
const tasks3 = new Listr([
|
||||
{
|
||||
title: 'Success',
|
||||
task: () => Promise.resolve('Foo')
|
||||
},
|
||||
{
|
||||
title: 'Failure',
|
||||
task: () => Promise.reject(new Error('Bar'))
|
||||
}
|
||||
]);
|
||||
|
||||
const tasks4 = new Listr([
|
||||
{
|
||||
title: 'File',
|
||||
task: () => fs.createReadStream('data.txt', 'utf8')
|
||||
}
|
||||
]);
|
||||
|
||||
const tasks5 = new Listr([
|
||||
{
|
||||
title: 'Task 1',
|
||||
task: () => Promise.resolve('Foo')
|
||||
},
|
||||
{
|
||||
title: 'Can be skipped',
|
||||
skip: () => {
|
||||
if (Math.random() > 0.5) {
|
||||
return 'Reason for skipping';
|
||||
}
|
||||
},
|
||||
task: () => 'Bar'
|
||||
},
|
||||
{
|
||||
title: 'Task 3',
|
||||
task: () => Promise.resolve('Bar')
|
||||
}
|
||||
]);
|
||||
|
||||
const tasks6 = new Listr([
|
||||
{
|
||||
title: 'Install package dependencies with Yarn',
|
||||
task: (ctx, task) => new Promise(resolve => resolve())
|
||||
.catch(() => {
|
||||
ctx.yarn = false;
|
||||
|
||||
task.skip('Yarn not available, install it via `npm install -g yarn`');
|
||||
})
|
||||
},
|
||||
{
|
||||
title: 'Install package dependencies with npm',
|
||||
enabled: ctx => ctx.yarn === false,
|
||||
task: () => new Promise(resolve => resolve())
|
||||
}
|
||||
]);
|
||||
|
||||
const tasks7 = new Listr([
|
||||
{
|
||||
title: 'Task 1',
|
||||
skip: ctx => ctx.foo === 'bar',
|
||||
task: () => Promise.resolve('Foo')
|
||||
},
|
||||
{
|
||||
title: 'Can be skipped',
|
||||
skip: () => {
|
||||
if (Math.random() > 0.5) {
|
||||
return 'Reason for skipping';
|
||||
}
|
||||
},
|
||||
task: ctx => {
|
||||
ctx.unicorn = 'rainbow';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Task 3',
|
||||
task: ctx => Promise.resolve(`${ctx.foo} ${ctx.bar}`)
|
||||
}
|
||||
]);
|
||||
|
||||
tasks.run({
|
||||
foo: 'bar'
|
||||
}).then(ctx => {
|
||||
console.log(ctx);
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"listr-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+13
-6
@@ -1,20 +1,27 @@
|
||||
// Type definitions for meow 4.x
|
||||
// Project: https://github.com/sindresorhus/meow
|
||||
// Definitions by: KnisterPeter <https://github.com/KnisterPeter>, Lindsey Smith <https://github.com/praxxis>
|
||||
// Definitions by: KnisterPeter <https://github.com/KnisterPeter>
|
||||
// Lindsey Smith <https://github.com/praxxis>
|
||||
// Jason Dreyzehner <https://github.com/bitjson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as buildOptions from "minimist-options";
|
||||
import * as buildOptions from 'minimist-options';
|
||||
|
||||
declare function meow(helpMessage: string | string[], options: meow.Options): meow.Result;
|
||||
declare function meow(options: string | string[] | meow.Options): meow.Result;
|
||||
declare function meow(
|
||||
helpMessage: string | ReadonlyArray<string>,
|
||||
options: meow.Options
|
||||
): meow.Result;
|
||||
declare function meow(
|
||||
options: string | ReadonlyArray<string> | meow.Options
|
||||
): meow.Result;
|
||||
declare namespace meow {
|
||||
interface Options {
|
||||
description?: string | boolean;
|
||||
help?: string | boolean;
|
||||
version?: string | boolean;
|
||||
pkg?: any;
|
||||
argv?: string[];
|
||||
argv?: ReadonlyArray<string>;
|
||||
inferType?: boolean;
|
||||
flags?: buildOptions.Options;
|
||||
autoHelp?: boolean;
|
||||
@@ -24,7 +31,7 @@ declare namespace meow {
|
||||
interface Result {
|
||||
input: string[];
|
||||
flags: { [name: string]: any };
|
||||
pkg: object;
|
||||
pkg: any;
|
||||
help: string;
|
||||
showHelp(code?: number): void;
|
||||
showVersion(): void;
|
||||
|
||||
+20
-17
@@ -1,28 +1,31 @@
|
||||
import meow = require('meow');
|
||||
|
||||
const cli = meow("Help text",
|
||||
{
|
||||
flags: {
|
||||
unicorn: {
|
||||
type: 'boolean',
|
||||
alias: 'u'
|
||||
},
|
||||
fooBar: {
|
||||
type: 'string',
|
||||
default: 'foo'
|
||||
}
|
||||
const cli = meow('Help text', {
|
||||
flags: {
|
||||
unicorn: {
|
||||
type: 'boolean',
|
||||
alias: 'u'
|
||||
},
|
||||
fooBar: {
|
||||
type: 'string',
|
||||
default: 'foo'
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const cli2 = meow("Help text");
|
||||
const input: string = cli.input[0];
|
||||
const version: string = cli.pkg.version;
|
||||
|
||||
const cli2 = meow('Help text');
|
||||
|
||||
const args: ReadonlyArray<string> = ['foo', 'bar'];
|
||||
|
||||
const cli3 = meow({
|
||||
description: "version string",
|
||||
help: "help string",
|
||||
version: "1.0.0",
|
||||
description: 'version string',
|
||||
help: 'help string',
|
||||
version: '1.0.0',
|
||||
pkg: {},
|
||||
argv: ['foo', 'bar'],
|
||||
argv: args,
|
||||
inferType: true,
|
||||
autoHelp: true,
|
||||
autoVersion: true,
|
||||
|
||||
Vendored
+73
-33
@@ -6,6 +6,7 @@
|
||||
// Jason Dreyzehner <https://github.com/bitjson>
|
||||
// Gaurav Lahoti <https://github.com/dante-101>
|
||||
// Mariano Cortesi <https://github.com/mcortesi>
|
||||
// Enrico Picci <https://github.com/EnricoPicci>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -482,13 +483,13 @@ export interface Collection<TSchema = Default> {
|
||||
createIndexes(indexSpecs: Object[], options?: {session?: ClientSession}): Promise<any>;
|
||||
createIndexes(indexSpecs: Object[], options: {session?: ClientSession}, callback: MongoCallback<any>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#deleteMany */
|
||||
deleteMany(filter: Object, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
||||
deleteMany(filter: Object, options?: CommonOptions): Promise<DeleteWriteOpResultObject>;
|
||||
deleteMany(filter: Object, options: CommonOptions, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
||||
deleteMany(filter: FilterQuery<TSchema>, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
||||
deleteMany(filter: FilterQuery<TSchema>, options?: CommonOptions): Promise<DeleteWriteOpResultObject>;
|
||||
deleteMany(filter: FilterQuery<TSchema>, options: CommonOptions, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#deleteOne */
|
||||
deleteOne(filter: Object, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
||||
deleteOne(filter: Object, options?: CommonOptions & { bypassDocumentValidation?: boolean }): Promise<DeleteWriteOpResultObject>;
|
||||
deleteOne(filter: Object, options: CommonOptions & { bypassDocumentValidation?: boolean }, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
||||
deleteOne(filter: FilterQuery<TSchema>, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
||||
deleteOne(filter: FilterQuery<TSchema>, options?: CommonOptions & { bypassDocumentValidation?: boolean }): Promise<DeleteWriteOpResultObject>;
|
||||
deleteOne(filter: FilterQuery<TSchema>, options: CommonOptions & { bypassDocumentValidation?: boolean }, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#distinct */
|
||||
distinct(key: string, query: Object, callback: MongoCallback<any>): void;
|
||||
distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number, session?: ClientSession }): Promise<any>;
|
||||
@@ -506,25 +507,25 @@ export interface Collection<TSchema = Default> {
|
||||
dropIndexes(callback?: MongoCallback<any>): void;
|
||||
dropIndexes(options: {session?: ClientSession, maxTimeMS?: number}, callback: MongoCallback<any>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#find */
|
||||
find<T = TSchema>(query?: Object): Cursor<T>;
|
||||
find<T = TSchema>(query?: FilterQuery<T>): Cursor<T>;
|
||||
/** @deprecated */
|
||||
find<T = TSchema>(query: Object, options?: FindOneOptions): Cursor<T>;
|
||||
find<T = TSchema>(query: FilterQuery<T>, options?: FindOneOptions): Cursor<T>;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOne */
|
||||
findOne<T = TSchema>(filter: Object, callback: MongoCallback<T | null>): void;
|
||||
findOne<T = TSchema>(filter: Object, options?: FindOneOptions): Promise<T | null>;
|
||||
findOne<T = TSchema>(filter: Object, options: FindOneOptions, callback: MongoCallback<T | null>): void;
|
||||
findOne<T = TSchema>(filter: FilterQuery<TSchema>, callback: MongoCallback<T | null>): void;
|
||||
findOne<T = TSchema>(filter: FilterQuery<TSchema>, options?: FindOneOptions): Promise<T | null>;
|
||||
findOne<T = TSchema>(filter: FilterQuery<TSchema>, options: FindOneOptions, callback: MongoCallback<T | null>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndDelete */
|
||||
findOneAndDelete(filter: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
||||
findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndDelete(filter: FilterQuery<TSchema>, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndDelete(filter: FilterQuery<TSchema>, options?: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
||||
findOneAndDelete(filter: FilterQuery<TSchema>, options: { projection?: Object, sort?: Object, maxTimeMS?: number, session?: ClientSession }, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndReplace */
|
||||
findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
||||
findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndReplace(filter: FilterQuery<TSchema>, replacement: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndReplace(filter: FilterQuery<TSchema>, replacement: Object, options?: FindOneAndReplaceOption): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
||||
findOneAndReplace(filter: FilterQuery<TSchema>, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndUpdate */
|
||||
findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
||||
findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndUpdate(filter: FilterQuery<TSchema>, update: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
findOneAndUpdate(filter: FilterQuery<TSchema>, update: Object, options?: FindOneAndReplaceOption): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
||||
findOneAndUpdate(filter: FilterQuery<TSchema>, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#geoHaystackSearch */
|
||||
geoHaystackSearch(x: number, y: number, callback: MongoCallback<any>): void;
|
||||
geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise<any>;
|
||||
@@ -602,9 +603,9 @@ export interface Collection<TSchema = Default> {
|
||||
rename(newName: string, options?: { dropTarget?: boolean, session?: ClientSession }): Promise<Collection<TSchema>>;
|
||||
rename(newName: string, options: { dropTarget?: boolean, session?: ClientSession }, callback: MongoCallback<Collection<TSchema>>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#replaceOne */
|
||||
replaceOne(filter: Object, doc: Object, callback: MongoCallback<ReplaceWriteOpResult>): void;
|
||||
replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
|
||||
replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback<ReplaceWriteOpResult>): void;
|
||||
replaceOne(filter: FilterQuery<TSchema>, doc: Object, callback: MongoCallback<ReplaceWriteOpResult>): void;
|
||||
replaceOne(filter: FilterQuery<TSchema>, doc: Object, options?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
|
||||
replaceOne(filter: FilterQuery<TSchema>, doc: Object, options: ReplaceOneOptions, callback: MongoCallback<ReplaceWriteOpResult>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#save */
|
||||
/** @deprecated Use insertOne, insertMany, updateOne or updateMany */
|
||||
save(doc: Object, callback: MongoCallback<WriteOpResult>): void;
|
||||
@@ -618,23 +619,62 @@ export interface Collection<TSchema = Default> {
|
||||
stats(options: { scale: number, session?: ClientSession }, callback: MongoCallback<CollStats>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#update */
|
||||
/** @deprecated use updateOne, updateMany or bulkWrite */
|
||||
update(filter: Object, update: Object, callback: MongoCallback<WriteOpResult>): void;
|
||||
update(filter: FilterQuery<TSchema>, update: Object, callback: MongoCallback<WriteOpResult>): void;
|
||||
/** @deprecated use updateOne, updateMany or bulkWrite */
|
||||
update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise<WriteOpResult>;
|
||||
update(filter: FilterQuery<TSchema>, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise<WriteOpResult>;
|
||||
/** @deprecated use updateOne, updateMany or bulkWrite */
|
||||
update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback<WriteOpResult>): void;
|
||||
update(filter: FilterQuery<TSchema>, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback<WriteOpResult>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#updateMany */
|
||||
updateMany(filter: Object, update: Object, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
updateMany(filter: Object, update: Object, options?: CommonOptions & { upsert?: boolean }): Promise<UpdateWriteOpResult>;
|
||||
updateMany(filter: Object, update: Object, options: CommonOptions & { upsert?: boolean }, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
updateMany(filter: FilterQuery<TSchema>, update: Object, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
updateMany(filter: FilterQuery<TSchema>, update: Object, options?: CommonOptions & { upsert?: boolean }): Promise<UpdateWriteOpResult>;
|
||||
updateMany(filter: FilterQuery<TSchema>, update: Object, options: CommonOptions & { upsert?: boolean }, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#updateOne */
|
||||
updateOne(filter: Object, update: Object, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise<UpdateWriteOpResult>;
|
||||
updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
updateOne(filter: FilterQuery<TSchema>, update: Object, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
updateOne(filter: FilterQuery<TSchema>, update: Object, options?: ReplaceOneOptions): Promise<UpdateWriteOpResult>;
|
||||
updateOne(filter: FilterQuery<TSchema>, update: Object, options: ReplaceOneOptions, callback: MongoCallback<UpdateWriteOpResult>): void;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#watch */
|
||||
watch(pipeline?: Object[], options?: ChangeStreamOptions & { session?: ClientSession }): ChangeStream;
|
||||
}
|
||||
|
||||
type FilterQuery<T> = {
|
||||
[P in keyof T]?: T[P] | {
|
||||
$eq?: T[P];
|
||||
$gt?: T[P];
|
||||
$gte?: T[P];
|
||||
$in?: T[P][];
|
||||
$lt?: T[P];
|
||||
$lte?: T[P];
|
||||
$ne?: T[P];
|
||||
$nin?: T[P][];
|
||||
$and?: (FilterQuery<T[P]> | T[P])[];
|
||||
$or?: (FilterQuery<T[P]> | T[P])[];
|
||||
$not?: (FilterQuery<T[P]> | T[P])[] | T[P];
|
||||
$expr?: any;
|
||||
$jsonSchema?: any;
|
||||
$mod?: [number, number];
|
||||
$regex?: RegExp;
|
||||
$options?: string;
|
||||
$text?: {
|
||||
$search: string;
|
||||
$language?: string;
|
||||
$caseSensitive?: boolean;
|
||||
$diacraticSensitive?: boolean;
|
||||
};
|
||||
$where: Object;
|
||||
$geoIntersects?: Object;
|
||||
$geoWithin?: Object;
|
||||
$near?: Object;
|
||||
$nearSphere?: Object;
|
||||
$elemMatch?: Object;
|
||||
$size?: number;
|
||||
$bitsAllClear?: Object;
|
||||
$bitsAllSet?: Object;
|
||||
$bitsAnyClear?: Object;
|
||||
$bitsAnySet?: Object;
|
||||
[key: string]: any;
|
||||
};
|
||||
} | { [key:string]: any };
|
||||
|
||||
// Documentation: http://docs.mongodb.org/manual/reference/command/collStats/
|
||||
export interface CollStats {
|
||||
// Namespace.
|
||||
@@ -1070,7 +1110,7 @@ export interface FindOneOptions {
|
||||
export interface InsertWriteOpResult {
|
||||
insertedCount: number;
|
||||
ops: Array<any>;
|
||||
insertedIds: Array<ObjectID>;
|
||||
insertedIds: {[key: number]: ObjectID};
|
||||
connection: any;
|
||||
result: { ok: number, n: number }
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user